2 ** $Id: lzio.c,v 1.37.1.1 2017/04/19 17:20:42 roberto Exp $
4 ** See Copyright Notice in lua.h
23 int luaZ_fill (ZIO *z) {
28 buff = z->reader(L, z->data, &size);
30 if (buff == NULL || size == 0)
32 z->n = size - 1; /* discount char being returned */
34 return cast_uchar(*(z->p++));
38 void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
47 /* --------------------------------------------------------------- read --- */
48 size_t luaZ_read (ZIO *z, void *b, size_t n) {
51 if (z->n == 0) { /* no bytes in buffer? */
52 if (luaZ_fill(z) == EOZ) /* try to read more */
53 return n; /* no more input; return number of missing bytes */
55 z->n++; /* luaZ_fill consumed first byte; put it back */
59 m = (n <= z->n) ? n : z->n; /* min. between n and z->n */