| 1791 | static char s_tempStr [s_tempStrMaxLen]; |
| 1792 | |
| 1793 | static char* rawToCString(lua_State* L, int idx) |
| 1794 | { |
| 1795 | int a = idx>0 ? idx : 1; |
| 1796 | int n = idx>0 ? idx : lua_gettop(L); |
| 1797 | |
| 1798 | char* ptr = s_tempStr; |
| 1799 | *ptr = 0; |
| 1800 | |
| 1801 | int remaining = s_tempStrMaxLen; |
| 1802 | for(int i = a; i <= n; i++) |
| 1803 | { |
| 1804 | toCStringConverter(L, i, ptr, remaining); |
| 1805 | if(i != n) |
| 1806 | APPENDPRINT " " END |
| 1807 | } |
| 1808 | |
| 1809 | if(remaining < 3) |
| 1810 | { |
| 1811 | while(remaining < 6) |
| 1812 | remaining++, ptr--; |
| 1813 | APPENDPRINT "..." END |
| 1814 | } |
| 1815 | APPENDPRINT "\r\n" END |
| 1816 | // the trailing newline is so print() can avoid having to do wasteful things to print its newline |
| 1817 | // (string copying would be wasteful and calling info.print() twice can be extremely slow) |
| 1818 | // at the cost of functions that don't want the newline needing to trim off the last two characters |
| 1819 | // (which is a very fast operation and thus acceptable in this case) |
| 1820 | |
| 1821 | return s_tempStr; |
| 1822 | } |
| 1823 | #undef APPENDPRINT |
| 1824 | #undef END |
| 1825 |
no test coverage detected