MCPcopy Create free account
hub / github.com/TASEmulators/fceux / rawToCString

Function rawToCString

src/lua-engine.cpp:1793–1822  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1791static char s_tempStr [s_tempStrMaxLen];
1792
1793static 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

Callers 3

tostringFunction · 0.85
toCStringFunction · 0.85
printFunction · 0.85

Calls 2

lua_gettopFunction · 0.85
toCStringConverterFunction · 0.85

Tested by

no test coverage detected