MCPcopy Create free account
hub / github.com/WilliamLCobb/iNDS / rawToCString

Function rawToCString

desmume/src/lua-engine.cpp:1032–1061  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1030static char s_tempStr [s_tempStrMaxLen];
1031
1032static char* rawToCString(lua_State* L, int idx)
1033{
1034 int a = idx>0 ? idx : 1;
1035 int n = idx>0 ? idx : lua_gettop(L);
1036
1037 char* ptr = s_tempStr;
1038 *ptr = 0;
1039
1040 int remaining = s_tempStrMaxLen;
1041 for(int i = a; i <= n; i++)
1042 {
1043 toCStringConverter(L, i, ptr, remaining);
1044 if(i != n)
1045 APPENDPRINT " " END
1046 }
1047
1048 if(remaining < 3)
1049 {
1050 while(remaining < 6)
1051 remaining++, ptr--;
1052 APPENDPRINT "..." END
1053 }
1054 APPENDPRINT "\r\n" END
1055 // the trailing newline is so print() can avoid having to do wasteful things to print its newline
1056 // (string copying would be wasteful and calling info.print() twice can be extremely slow)
1057 // at the cost of functions that don't want the newline needing to trim off the last two characters
1058 // (which is a very fast operation and thus acceptable in this case)
1059
1060 return s_tempStr;
1061}
1062#undef APPENDPRINT
1063#undef END
1064

Callers 3

lua-engine.cppFile · 0.85
toCStringConverterFunction · 0.85
toCStringFunction · 0.85

Calls 1

toCStringConverterFunction · 0.85

Tested by

no test coverage detected