| 22 | |
| 23 | |
| 24 | static 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" |
nothing calls this directly
no test coverage detected