| 541 | |
| 542 | |
| 543 | static void read_all (lua_State *L, FILE *f) { |
| 544 | size_t nr; |
| 545 | luaL_Buffer b; |
| 546 | luaL_buffinit(L, &b); |
| 547 | do { /* read file in chunks of LUAL_BUFFERSIZE bytes */ |
| 548 | char *p = luaL_prepbuffer(&b); |
| 549 | nr = fread(p, sizeof(char), LUAL_BUFFERSIZE, f); |
| 550 | luaL_addsize(&b, nr); |
| 551 | } while (nr == LUAL_BUFFERSIZE); |
| 552 | luaL_pushresult(&b); /* close buffer */ |
| 553 | } |
| 554 | |
| 555 | |
| 556 | static int read_chars (lua_State *L, FILE *f, size_t n) { |
no test coverage detected