MCPcopy Create free account
hub / github.com/DFHack/dfhack / read_chars

Function read_chars

depends/lua/src/liolib.c:518–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

516
517
518static int read_chars (lua_State *L, FILE *f, size_t n) {
519 size_t nr; /* number of chars actually read */
520 char *p;
521 luaL_Buffer b;
522 luaL_buffinit(L, &b);
523 p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */
524 nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */
525 luaL_addsize(&b, nr);
526 luaL_pushresult(&b); /* close buffer */
527 return (nr > 0); /* true iff read something */
528}
529
530
531static int g_read (lua_State *L, FILE *f, int first) {

Callers 1

g_readFunction · 0.85

Calls 3

luaL_buffinitFunction · 0.85
luaL_prepbuffsizeFunction · 0.85
luaL_pushresultFunction · 0.85

Tested by

no test coverage detected