aboutsummaryrefslogtreecommitdiff
path: root/lzio.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-08-16 17:52:00 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-08-16 17:52:00 -0300
commitc787dccd9b5c3e55547a2c4bb598c0276de65034 (patch)
treec4cdf2f7319fee48e048472a2044119f541e8da2 /lzio.c
parentb44e35b773bcaa9891d80a117392911ab5f656e5 (diff)
downloadlua-c787dccd9b5c3e55547a2c4bb598c0276de65034.tar.gz
lua-c787dccd9b5c3e55547a2c4bb598c0276de65034.tar.bz2
lua-c787dccd9b5c3e55547a2c4bb598c0276de65034.zip
"const" !!!
Diffstat (limited to 'lzio.c')
-rw-r--r--lzio.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/lzio.c b/lzio.c
index aaa900c4..c59ec559 100644
--- a/lzio.c
+++ b/lzio.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.c,v 1.6 1999/03/04 14:49:18 roberto Exp roberto $ 2** $Id: lzio.c,v 1.7 1999/03/05 13:15:50 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*/
@@ -16,51 +16,48 @@
16/* ----------------------------------------------------- memory buffers --- */ 16/* ----------------------------------------------------- memory buffers --- */
17 17
18static int zmfilbuf (ZIO* z) { 18static int zmfilbuf (ZIO* z) {
19 return EOZ; 19 return EOZ;
20} 20}
21 21
22 22
23ZIO* zmopen (ZIO* z, char* b, int size, char *name) 23ZIO* zmopen (ZIO* z, const char* b, int size, const char *name) {
24{ 24 if (b==NULL) return NULL;
25 if (b==NULL) return NULL; 25 z->n = size;
26 z->n=size; 26 z->p = (unsigned const char *)b;
27 z->p= (unsigned char *)b; 27 z->filbuf = zmfilbuf;
28 z->filbuf=zmfilbuf; 28 z->u = NULL;
29 z->u=NULL; 29 z->name = name;
30 z->name=name; 30 return z;
31 return z;
32} 31}
33 32
34/* ------------------------------------------------------------ strings --- */ 33/* ------------------------------------------------------------ strings --- */
35 34
36ZIO* zsopen (ZIO* z, char* s, char *name) 35ZIO* zsopen (ZIO* z, const char* s, const char *name) {
37{ 36 if (s==NULL) return NULL;
38 if (s==NULL) return NULL; 37 return zmopen(z,s,strlen(s),name);
39 return zmopen(z,s,strlen(s),name);
40} 38}
41 39
42/* -------------------------------------------------------------- FILEs --- */ 40/* -------------------------------------------------------------- FILEs --- */
43 41
44static int zffilbuf (ZIO* z) { 42static int zffilbuf (ZIO* z) {
45 int n; 43 int n;
46 if (feof((FILE *)z->u)) return EOZ; 44 if (feof((FILE *)z->u)) return EOZ;
47 n=fread(z->buffer,1,ZBSIZE,z->u); 45 n = fread(z->buffer,1,ZBSIZE,z->u);
48 if (n==0) return EOZ; 46 if (n==0) return EOZ;
49 z->n=n-1; 47 z->n = n-1;
50 z->p=z->buffer; 48 z->p = z->buffer;
51 return *(z->p++); 49 return *(z->p++);
52} 50}
53 51
54 52
55ZIO* zFopen (ZIO* z, FILE* f, char *name) 53ZIO* zFopen (ZIO* z, FILE* f, const char *name) {
56{ 54 if (f==NULL) return NULL;
57 if (f==NULL) return NULL; 55 z->n = 0;
58 z->n=0; 56 z->p = z->buffer;
59 z->p=z->buffer; 57 z->filbuf = zffilbuf;
60 z->filbuf=zffilbuf; 58 z->u = f;
61 z->u=f; 59 z->name = name;
62 z->name=name; 60 return z;
63 return z;
64} 61}
65 62
66 63