MCPcopy Create free account
hub / github.com/TASEmulators/fceux / g_write

Function g_write

src/lua/src/liolib.c:410–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408
409
410static 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
429static int io_write (lua_State *L) {

Callers 2

io_writeFunction · 0.85
f_writeFunction · 0.85

Calls 5

lua_gettopFunction · 0.85
lua_typeFunction · 0.85
lua_tonumberFunction · 0.85
luaL_checklstringFunction · 0.85
pushresultFunction · 0.85

Tested by

no test coverage detected