| 537 | |
| 538 | |
| 539 | static int read_chars (lua_State *L, FILE *f, size_t n) { |
| 540 | size_t nr; /* number of chars actually read */ |
| 541 | char *p; |
| 542 | luaL_Buffer b; |
| 543 | luaL_buffinit(L, &b); |
| 544 | p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */ |
| 545 | nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */ |
| 546 | luaL_addsize(&b, nr); |
| 547 | luaL_pushresult(&b); /* close buffer */ |
| 548 | return (nr > 0); /* true iff read something */ |
| 549 | } |
| 550 | |
| 551 | |
| 552 | static int g_read (lua_State *L, FILE *f, int first) { |
no test coverage detected