| 516 | |
| 517 | |
| 518 | static 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 | |
| 531 | static int g_read (lua_State *L, FILE *f, int first) { |
no test coverage detected