| 551 | |
| 552 | |
| 553 | static int read_chars (lua_State *L, FILE *f, size_t n) { |
| 554 | size_t nr; /* number of chars actually read */ |
| 555 | char *p; |
| 556 | luaL_Buffer b; |
| 557 | luaL_buffinit(L, &b); |
| 558 | p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */ |
| 559 | nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */ |
| 560 | luaL_addsize(&b, nr); |
| 561 | luaL_pushresult(&b); /* close buffer */ |
| 562 | return (nr > 0); /* true iff read something */ |
| 563 | } |
| 564 | |
| 565 | |
| 566 | static int g_read (lua_State *L, FILE *f, int first) { |
no test coverage detected