diff options
Diffstat (limited to 'lzio.c')
-rw-r--r-- | lzio.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lzio.c,v 1.12 2000/05/24 13:54:49 roberto Exp roberto $ | 2 | ** $Id: lzio.c,v 1.13 2000/06/12 13:52:05 roberto Exp roberto $ |
3 | ** a generic input stream interface | 3 | ** a generic input stream interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -9,6 +9,7 @@ | |||
9 | #include <stdio.h> | 9 | #include <stdio.h> |
10 | #include <string.h> | 10 | #include <string.h> |
11 | 11 | ||
12 | #define LUA_PRIVATE | ||
12 | #include "lua.h" | 13 | #include "lua.h" |
13 | 14 | ||
14 | #include "lzio.h" | 15 | #include "lzio.h" |
@@ -71,7 +72,10 @@ size_t zread (ZIO *z, void *b, size_t n) { | |||
71 | if (z->n == 0) { | 72 | if (z->n == 0) { |
72 | if (z->filbuf(z) == EOZ) | 73 | if (z->filbuf(z) == EOZ) |
73 | return n; /* return number of missing bytes */ | 74 | return n; /* return number of missing bytes */ |
74 | zungetc(z); /* put result from `filbuf' in the buffer */ | 75 | else { |
76 | ++z->n; /* filbuf removed first byte; put back it */ | ||
77 | --z->p; | ||
78 | } | ||
75 | } | 79 | } |
76 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ | 80 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ |
77 | memcpy(b, z->p, m); | 81 | memcpy(b, z->p, m); |