MCPcopy Create free account
hub / github.com/defold/defold / g_write

Function g_write

engine/lua/src/lua/liolib.c:414–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412
413
414static 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
433static 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