MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / g_write

Function g_write

third-party/lua-5.3.5/src/liolib.c:620–641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

618
619
620static int g_write (lua_State *L, FILE *f, int arg) {
621 int nargs = lua_gettop(L) - arg;
622 int status = 1;
623 for (; nargs--; arg++) {
624 if (lua_type(L, arg) == LUA_TNUMBER) {
625 /* optimization: could be done exactly as for strings */
626 int len = lua_isinteger(L, arg)
627 ? fprintf(f, LUA_INTEGER_FMT,
628 (LUAI_UACINT)lua_tointeger(L, arg))
629 : fprintf(f, LUA_NUMBER_FMT,
630 (LUAI_UACNUMBER)lua_tonumber(L, arg));
631 status = status && (len > 0);
632 }
633 else {
634 size_t l;
635 const char *s = luaL_checklstring(L, arg, &l);
636 status = status && (fwrite(s, sizeof(char), l, f) == l);
637 }
638 }
639 if (status) return 1; /* file handle already on stack top */
640 else return luaL_fileresult(L, status, NULL);
641}
642
643
644static int io_write (lua_State *L) {

Callers 2

io_writeFunction · 0.70
f_writeFunction · 0.70

Calls 7

lua_gettopFunction · 0.70
lua_typeFunction · 0.70
lua_isintegerFunction · 0.70
luaL_checklstringFunction · 0.70
luaL_fileresultFunction · 0.70
lua_tointegerFunction · 0.50
lua_tonumberFunction · 0.50

Tested by

no test coverage detected