MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaB_print

Function luaB_print

depends/lua/src/lbaselib.c:24–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23
24static int luaB_print (lua_State *L) {
25 int n = lua_gettop(L); /* number of arguments */
26 int i;
27 lua_getglobal(L, "tostring");
28 for (i=1; i<=n; i++) {
29 const char *s;
30 size_t l;
31 lua_pushvalue(L, -1); /* function to be called */
32 lua_pushvalue(L, i); /* value to print */
33 lua_call(L, 1, 1);
34 s = lua_tolstring(L, -1, &l); /* get result */
35 if (s == NULL)
36 return luaL_error(L, "'tostring' must return a string to 'print'");
37 if (i>1) lua_writestring("\t", 1);
38 lua_writestring(s, l);
39 lua_pop(L, 1); /* pop result */
40 }
41 lua_writeline();
42 return 0;
43}
44
45
46#define SPACECHARS " \f\n\r\t\v"

Callers

nothing calls this directly

Calls 5

lua_gettopFunction · 0.85
lua_getglobalFunction · 0.85
lua_pushvalueFunction · 0.85
lua_tolstringFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected