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