MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / read_chars

Function read_chars

lib/lua/src/liolib.c:556–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

554
555
556static int read_chars (lua_State *L, FILE *f, size_t n) {
557 size_t nr; /* number of chars actually read */
558 char *p;
559 luaL_Buffer b;
560 luaL_buffinit(L, &b);
561 p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */
562 nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */
563 luaL_addsize(&b, nr);
564 luaL_pushresult(&b); /* close buffer */
565 return (nr > 0); /* true iff read something */
566}
567
568
569static 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