details (from lhf)

This commit is contained in:
Roberto Ierusalimschy
1999-02-25 18:07:26 -03:00
parent 31bea2190b
commit 6a853fcb8b
13 changed files with 106 additions and 103 deletions

11
lzio.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lzio.c,v 1.3 1997/12/22 20:57:18 roberto Exp roberto $
** $Id: lzio.c,v 1.4 1998/12/28 13:44:54 roberto Exp roberto $
** a generic input stream interface
** See Copyright Notice in lua.h
*/
@@ -64,16 +64,15 @@ ZIO* zFopen (ZIO* z, FILE* f, char *name)
/* --------------------------------------------------------------- read --- */
int zread (ZIO *z, void *b, int n)
{
int zread (ZIO *z, void *b, int n) {
while (n) {
int m;
if (z->n == 0) {
if (z->filbuf(z) == EOZ)
return n; /* retorna quantos faltaram ler */
zungetc(z); /* poe o resultado de filbuf no buffer */
return n; /* return number of missing bytes */
zungetc(z); /* put result from 'filbuf' in the buffer */
}
m = (n <= z->n) ? n : z->n; /* minimo de n e z->n */
m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
memcpy(b, z->p, m);
z->n -= m;
z->p += m;