| 408 | |
| 409 | |
| 410 | static int g_write (lua_State *L, FILE *f, int arg) { |
| 411 | int nargs = lua_gettop(L) - 1; |
| 412 | int status = 1; |
| 413 | for (; nargs--; arg++) { |
| 414 | if (lua_type(L, arg) == LUA_TNUMBER) { |
| 415 | /* optimization: could be done exactly as for strings */ |
| 416 | status = status && |
| 417 | fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; |
| 418 | } |
| 419 | else { |
| 420 | size_t l; |
| 421 | const char *s = luaL_checklstring(L, arg, &l); |
| 422 | status = status && (fwrite(s, sizeof(char), l, f) == l); |
| 423 | } |
| 424 | } |
| 425 | return pushresult(L, status, NULL); |
| 426 | } |
| 427 | |
| 428 | |
| 429 | static int io_write (lua_State *L) { |
no test coverage detected