MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / g_write

Function g_write

lua/liolib.c:418–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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