aboutsummaryrefslogtreecommitdiff
path: root/lzio.c
diff options
context:
space:
mode:
Diffstat (limited to 'lzio.c')
-rw-r--r--lzio.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lzio.c b/lzio.c
index 8e11ef4d..04fba442 100644
--- a/lzio.c
+++ b/lzio.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.c,v 1.3 1997/12/22 20:57:18 roberto Exp roberto $ 2** $Id: lzio.c,v 1.4 1998/12/28 13:44:54 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*/
@@ -64,16 +64,15 @@ ZIO* zFopen (ZIO* z, FILE* f, char *name)
64 64
65 65
66/* --------------------------------------------------------------- read --- */ 66/* --------------------------------------------------------------- read --- */
67int zread (ZIO *z, void *b, int n) 67int zread (ZIO *z, void *b, int n) {
68{
69 while (n) { 68 while (n) {
70 int m; 69 int m;
71 if (z->n == 0) { 70 if (z->n == 0) {
72 if (z->filbuf(z) == EOZ) 71 if (z->filbuf(z) == EOZ)
73 return n; /* retorna quantos faltaram ler */ 72 return n; /* return number of missing bytes */
74 zungetc(z); /* poe o resultado de filbuf no buffer */ 73 zungetc(z); /* put result from 'filbuf' in the buffer */
75 } 74 }
76 m = (n <= z->n) ? n : z->n; /* minimo de n e z->n */ 75 m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
77 memcpy(b, z->p, m); 76 memcpy(b, z->p, m);
78 z->n -= m; 77 z->n -= m;
79 z->p += m; 78 z->p += m;