MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / g_write

Function g_write

deps/lua/src/liolib.c:413–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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