summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lauxlib.h6
-rw-r--r--lbuffer.c4
-rw-r--r--lbuiltin.c18
-rw-r--r--liolib.c15
-rw-r--r--llex.c8
-rw-r--r--lmathlib.c9
-rw-r--r--lparser.c30
-rw-r--r--lstrlib.c18
-rw-r--r--lua.c36
-rw-r--r--lzio.c6
10 files changed, 75 insertions, 75 deletions
diff --git a/lauxlib.h b/lauxlib.h
index e26c7fa4..508b1cd0 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.8 1998/06/18 16:57:03 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.9 1998/06/19 16:14:09 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -28,7 +28,11 @@ char *luaL_check_lstr (int numArg, long *len);
28#define luaL_opt_string(n, d) (luaL_opt_lstr((n), (d), NULL)) 28#define luaL_opt_string(n, d) (luaL_opt_lstr((n), (d), NULL))
29char *luaL_opt_lstr (int numArg, char *def, long *len); 29char *luaL_opt_lstr (int numArg, char *def, long *len);
30double luaL_check_number (int numArg); 30double luaL_check_number (int numArg);
31#define luaL_check_int(n) ((int)luaL_check_number(n))
32#define luaL_check_long(n) ((long)luaL_check_number(n))
31double luaL_opt_number (int numArg, double def); 33double luaL_opt_number (int numArg, double def);
34#define luaL_opt_int(n,d) ((int)luaL_opt_number(n,d))
35#define luaL_opt_long(n,d) ((long)luaL_opt_number(n,d))
32lua_Object luaL_functionarg (int arg); 36lua_Object luaL_functionarg (int arg);
33lua_Object luaL_tablearg (int arg); 37lua_Object luaL_tablearg (int arg);
34lua_Object luaL_nonnullarg (int numArg); 38lua_Object luaL_nonnullarg (int numArg);
diff --git a/lbuffer.c b/lbuffer.c
index 9ec37a73..6bcc9c5a 100644
--- a/lbuffer.c
+++ b/lbuffer.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuffer.c,v 1.3 1998/06/02 20:37:04 roberto Exp roberto $ 2** $Id: lbuffer.c,v 1.4 1998/06/19 16:14:09 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -42,7 +42,7 @@ char *luaL_openspace (int size)
42void luaL_addchar (int c) 42void luaL_addchar (int c)
43{ 43{
44 openspace(BUFF_STEP); 44 openspace(BUFF_STEP);
45 L->Mbuffer[L->Mbuffnext++] = c; 45 L->Mbuffer[L->Mbuffnext++] = (char)c;
46} 46}
47 47
48 48
diff --git a/lbuiltin.c b/lbuiltin.c
index 574e5fae..d4dd0716 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.38 1998/12/15 15:21:09 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.40 1998/12/27 20:22:36 roberto Exp roberto $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -133,7 +133,7 @@ static void luaB_print (void) {
133 133
134 134
135static void luaB_tonumber (void) { 135static void luaB_tonumber (void) {
136 int base = luaL_opt_number(2, 10); 136 int base = luaL_opt_int(2, 10);
137 if (base == 10) { /* standard conversion */ 137 if (base == 10) { /* standard conversion */
138 lua_Object o = lua_getparam(1); 138 lua_Object o = lua_getparam(1);
139 if (lua_isnumber(o)) 139 if (lua_isnumber(o))
@@ -186,7 +186,7 @@ static void luaB_luatag (void) {
186static void luaB_settag (void) { 186static void luaB_settag (void) {
187 lua_Object o = luaL_tablearg(1); 187 lua_Object o = luaL_tablearg(1);
188 lua_pushobject(o); 188 lua_pushobject(o);
189 lua_settag(luaL_check_number(2)); 189 lua_settag(luaL_check_int(2));
190 lua_pushobject(o); /* returns first argument */ 190 lua_pushobject(o); /* returns first argument */
191} 191}
192 192
@@ -195,8 +195,8 @@ static void luaB_newtag (void) {
195} 195}
196 196
197static void luaB_copytagmethods (void) { 197static void luaB_copytagmethods (void) {
198 lua_pushnumber(lua_copytagmethods(luaL_check_number(1), 198 lua_pushnumber(lua_copytagmethods(luaL_check_int(1),
199 luaL_check_number(2))); 199 luaL_check_int(2)));
200} 200}
201 201
202static void luaB_rawgettable (void) { 202static void luaB_rawgettable (void) {
@@ -215,13 +215,11 @@ static void luaB_rawsettable (void) {
215static void luaB_settagmethod (void) { 215static void luaB_settagmethod (void) {
216 lua_Object nf = luaL_nonnullarg(3); 216 lua_Object nf = luaL_nonnullarg(3);
217 lua_pushobject(nf); 217 lua_pushobject(nf);
218 lua_pushobject(lua_settagmethod((int)luaL_check_number(1), 218 lua_pushobject(lua_settagmethod(luaL_check_int(1), luaL_check_string(2)));
219 luaL_check_string(2)));
220} 219}
221 220
222static void luaB_gettagmethod (void) { 221static void luaB_gettagmethod (void) {
223 lua_pushobject(lua_gettagmethod((int)luaL_check_number(1), 222 lua_pushobject(lua_gettagmethod(luaL_check_int(1), luaL_check_string(2)));
224 luaL_check_string(2)));
225} 223}
226 224
227static void luaB_seterrormethod (void) { 225static void luaB_seterrormethod (void) {
@@ -231,7 +229,7 @@ static void luaB_seterrormethod (void) {
231} 229}
232 230
233static void luaB_collectgarbage (void) { 231static void luaB_collectgarbage (void) {
234 lua_pushnumber(lua_collectgarbage(luaL_opt_number(1, 0))); 232 lua_pushnumber(lua_collectgarbage(luaL_opt_int(1, 0)));
235} 233}
236 234
237 235
diff --git a/liolib.c b/liolib.c
index 764dd883..638fe9a6 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 1.26 1998/11/20 15:41:43 roberto Exp roberto $ 2** $Id: liolib.c,v 1.27 1998/12/27 20:21:28 roberto Exp roberto $
3** Standard I/O (and system) library 3** Standard I/O (and system) library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -105,8 +105,11 @@ static FILE *getfileparam (char *name, int *arg) {
105static char *getmode (char mode) { 105static char *getmode (char mode) {
106 static char m[3]; 106 static char m[3];
107 m[0] = mode; 107 m[0] = mode;
108 m[1] = (*luaL_opt_string(FIRSTARG+1, "text") == 'b') ? 'b' : '\0'; 108 if (*luaL_opt_string(FIRSTARG+1, "text") == 'b') {
109 m[2] = '\0'; 109 m[1] = 'b';
110 m[2] = '\0';
111 }
112 else m[1] = '\0';
110 return m; 113 return m;
111} 114}
112 115
@@ -308,7 +311,7 @@ static void io_read (void) {
308 l = luaL_getsize(); 311 l = luaL_getsize();
309 if (!success && l==0) return; /* read fails */ 312 if (!success && l==0) return; /* read fails */
310 lua_pushlstring(luaL_buffer(), l); 313 lua_pushlstring(luaL_buffer(), l);
311 } while ((p = luaL_opt_string(arg++, NULL))); 314 } while ((p = luaL_opt_string(arg++, NULL)) != NULL);
312} 315}
313 316
314 317
@@ -319,7 +322,7 @@ static void io_write (void) {
319 char *s; 322 char *s;
320 long l; 323 long l;
321 while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL) 324 while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL)
322 status = status && (fwrite(s, 1, l, f) == l); 325 status = status && ((long)fwrite(s, 1, l, f) == l);
323 pushresult(status); 326 pushresult(status);
324} 327}
325 328
@@ -329,7 +332,7 @@ static void io_seek (void) {
329 static char *modenames[] = {"set", "cur", "end", NULL}; 332 static char *modenames[] = {"set", "cur", "end", NULL};
330 FILE *f = getfile(FIRSTARG-1+1); 333 FILE *f = getfile(FIRSTARG-1+1);
331 int op = luaL_findstring(luaL_opt_string(FIRSTARG-1+2, "cur"), modenames); 334 int op = luaL_findstring(luaL_opt_string(FIRSTARG-1+2, "cur"), modenames);
332 long offset = luaL_opt_number(FIRSTARG-1+3, 0); 335 long offset = luaL_opt_long(FIRSTARG-1+3, 0);
333 luaL_arg_check(f, FIRSTARG-1+1, "invalid file handler"); 336 luaL_arg_check(f, FIRSTARG-1+1, "invalid file handler");
334 luaL_arg_check(op != -1, FIRSTARG-1+2, "invalid mode"); 337 luaL_arg_check(op != -1, FIRSTARG-1+2, "invalid mode");
335 op = fseek(f, offset, mode[op]); 338 op = fseek(f, offset, mode[op]);
diff --git a/llex.c b/llex.c
index 941e6b8a..a0b63fe1 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.25 1998/12/03 15:45:15 roberto Exp $ 2** $Id: llex.c,v 1.26 1998/12/27 20:25:20 roberto Exp roberto $
3** Lexical Analizer 3** Lexical Analizer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -61,7 +61,7 @@ void luaX_error (LexState *ls, char *s) {
61 61
62void luaX_token2str (int token, char *s) { 62void luaX_token2str (int token, char *s) {
63 if (token < 255) { 63 if (token < 255) {
64 s[0] = token; 64 s[0] = (char)token;
65 s[1] = '\0'; 65 s[1] = '\0';
66 } 66 }
67 else 67 else
@@ -138,7 +138,7 @@ static void readname (LexState *LS, char *buff)
138 buff[PRAGMASIZE] = 0; 138 buff[PRAGMASIZE] = 0;
139 luaX_syntaxerror(LS, "pragma too long", buff); 139 luaX_syntaxerror(LS, "pragma too long", buff);
140 } 140 }
141 buff[i++] = LS->current; 141 buff[i++] = (char)LS->current;
142 next(LS); 142 next(LS);
143 } 143 }
144 buff[i] = 0; 144 buff[i] = 0;
@@ -344,7 +344,7 @@ int luaX_lex (LexState *LS) {
344 c = 10*c + (LS->current-'0'); 344 c = 10*c + (LS->current-'0');
345 next(LS); 345 next(LS);
346 } while (++i<3 && isdigit(LS->current)); 346 } while (++i<3 && isdigit(LS->current));
347 if (c > (unsigned char)c) 347 if (c != (unsigned char)c)
348 luaX_error(LS, "escape sequence too large"); 348 luaX_error(LS, "escape sequence too large");
349 save(c); 349 save(c);
350 } 350 }
diff --git a/lmathlib.c b/lmathlib.c
index 181ee8d4..1d99df32 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.10 1998/06/19 16:14:09 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.11 1998/09/08 19:25:35 roberto Exp roberto $
3** Lua standard mathematical library 3** Lua standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -122,7 +122,7 @@ static void math_frexp (void) {
122} 122}
123 123
124static void math_ldexp (void) { 124static void math_ldexp (void) {
125 lua_pushnumber(ldexp(luaL_check_number(1), luaL_check_number(2))); 125 lua_pushnumber(ldexp(luaL_check_number(1), luaL_check_int(2)));
126} 126}
127 127
128 128
@@ -166,9 +166,8 @@ static void math_random (void)
166} 166}
167 167
168 168
169static void math_randomseed (void) 169static void math_randomseed (void) {
170{ 170 srand(luaL_check_int(1));
171 srand(luaL_check_number(1));
172} 171}
173 172
174 173
diff --git a/lparser.c b/lparser.c
index 659d64d6..e1f0372e 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.5 1998/08/11 13:28:05 roberto Exp roberto $ 2** $Id: lparser.c,v 1.6 1998/12/23 14:06:57 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -158,18 +158,18 @@ static int code_oparg_at (LexState *ls, int pc, OpCode op, int builtin,
158 Byte *code = ls->fs->f->code; 158 Byte *code = ls->fs->f->code;
159 deltastack(ls, delta); 159 deltastack(ls, delta);
160 if (arg < builtin) { 160 if (arg < builtin) {
161 code[pc] = op+1+arg; 161 code[pc] = (Byte)(op+1+arg);
162 return 1; 162 return 1;
163 } 163 }
164 else if (arg <= 255) { 164 else if (arg <= 255) {
165 code[pc] = op; 165 code[pc] = (Byte)op;
166 code[pc+1] = arg; 166 code[pc+1] = (Byte)arg;
167 return 2; 167 return 2;
168 } 168 }
169 else if (arg <= MAX_WORD) { 169 else if (arg <= MAX_WORD) {
170 code[pc] = op+1+builtin; 170 code[pc] = (Byte)(op+1+builtin);
171 code[pc+1] = arg>>8; 171 code[pc+1] = (Byte)(arg>>8);
172 code[pc+2] = arg&0xFF; 172 code[pc+2] = (Byte)(arg&0xFF);
173 return 3; 173 return 3;
174 } 174 }
175 else luaX_error(ls, "code too long " MES_LIM("64K") 175 else luaX_error(ls, "code too long " MES_LIM("64K")
@@ -202,7 +202,7 @@ static void code_oparg (LexState *ls, OpCode op, int builtin, int arg,
202 202
203static void code_opcode (LexState *ls, OpCode op, int delta) { 203static void code_opcode (LexState *ls, OpCode op, int delta) {
204 deltastack(ls, delta); 204 deltastack(ls, delta);
205 code_byte(ls->fs, op); 205 code_byte(ls->fs, (Byte)op);
206} 206}
207 207
208 208
@@ -277,7 +277,7 @@ static void flush_record (LexState *ls, int n) {
277static void flush_list (LexState *ls, int m, int n) { 277static void flush_list (LexState *ls, int m, int n) {
278 if (n == 0) return; 278 if (n == 0) return;
279 code_oparg(ls, SETLIST, 1, m, -n); 279 code_oparg(ls, SETLIST, 1, m, -n);
280 code_byte(ls->fs, n); 280 code_byte(ls->fs, (Byte)n);
281} 281}
282 282
283 283
@@ -391,7 +391,7 @@ static void adjuststack (LexState *ls, int n) {
391static void close_exp (LexState *ls, int pc, int nresults) { 391static void close_exp (LexState *ls, int pc, int nresults) {
392 if (pc > 0) { /* expression is an open function call */ 392 if (pc > 0) { /* expression is an open function call */
393 Byte *code = ls->fs->f->code; 393 Byte *code = ls->fs->f->code;
394 int nparams = code[pc]; /* save nparams */ 394 Byte nparams = code[pc]; /* save nparams */
395 pc += fix_opcode(ls, pc-2, CALLFUNC, 2, nresults); 395 pc += fix_opcode(ls, pc-2, CALLFUNC, 2, nresults);
396 code[pc] = nparams; /* restore nparams */ 396 code[pc] = nparams; /* restore nparams */
397 if (nresults != MULT_RET) 397 if (nresults != MULT_RET)
@@ -426,11 +426,11 @@ static void code_args (LexState *ls, int nparams, int dots) {
426 fs->nlocalvar += nparams; /* "self" may already be there */ 426 fs->nlocalvar += nparams; /* "self" may already be there */
427 nparams = fs->nlocalvar; 427 nparams = fs->nlocalvar;
428 if (!dots) { 428 if (!dots) {
429 fs->f->code[1] = nparams; /* fill-in arg information */ 429 fs->f->code[1] = (Byte)nparams; /* fill-in arg information */
430 deltastack(ls, nparams); 430 deltastack(ls, nparams);
431 } 431 }
432 else { 432 else {
433 fs->f->code[1] = nparams+ZEROVARARG; 433 fs->f->code[1] = (Byte)(nparams+ZEROVARARG);
434 deltastack(ls, nparams+1); 434 deltastack(ls, nparams+1);
435 add_localvar(ls, luaS_new("arg")); 435 add_localvar(ls, luaS_new("arg"));
436 } 436 }
@@ -515,7 +515,7 @@ static void func_onstack (LexState *ls, FuncState *func) {
515 for (i=0; i<func->nupvalues; i++) 515 for (i=0; i<func->nupvalues; i++)
516 lua_pushvar(ls, &func->upvalues[i]); 516 lua_pushvar(ls, &func->upvalues[i]);
517 code_oparg(ls, CLOSURE, 0, c, -func->nupvalues+1); 517 code_oparg(ls, CLOSURE, 0, c, -func->nupvalues+1);
518 code_byte(fs, func->nupvalues); 518 code_byte(fs, (Byte)func->nupvalues);
519 } 519 }
520} 520}
521 521
@@ -548,7 +548,7 @@ static void close_func (LexState *ls) {
548 FuncState *fs = ls->fs; 548 FuncState *fs = ls->fs;
549 TProtoFunc *f = fs->f; 549 TProtoFunc *f = fs->f;
550 code_opcode(ls, ENDCODE, 0); 550 code_opcode(ls, ENDCODE, 0);
551 f->code[0] = fs->maxstacksize; 551 f->code[0] = (Byte)fs->maxstacksize;
552 f->code = luaM_reallocvector(f->code, fs->pc, Byte); 552 f->code = luaM_reallocvector(f->code, fs->pc, Byte);
553 f->consts = luaM_reallocvector(f->consts, f->nconsts, TObject); 553 f->consts = luaM_reallocvector(f->consts, f->nconsts, TObject);
554 if (fs->maxvars != -1) { /* debug information? */ 554 if (fs->maxvars != -1) { /* debug information? */
@@ -1092,7 +1092,7 @@ static int funcparams (LexState *ls, int slf) {
1092 } 1092 }
1093 code_byte(fs, 0); /* save space for opcode */ 1093 code_byte(fs, 0); /* save space for opcode */
1094 code_byte(fs, 0); /* and nresult */ 1094 code_byte(fs, 0); /* and nresult */
1095 code_byte(fs, nparams+slf); 1095 code_byte(fs, (Byte)(nparams+slf));
1096 return fs->pc-1; 1096 return fs->pc-1;
1097} 1097}
1098 1098
diff --git a/lstrlib.c b/lstrlib.c
index 98e90ab2..e1eac354 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.20 1998/11/10 19:38:12 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.21 1998/12/01 18:41:25 roberto Exp roberto $
3** Standard library for strings and pattern-matching 3** Standard library for strings and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -46,8 +46,8 @@ static long posrelat (long pos, long len) {
46static void str_sub (void) { 46static void str_sub (void) {
47 long l; 47 long l;
48 char *s = luaL_check_lstr(1, &l); 48 char *s = luaL_check_lstr(1, &l);
49 long start = posrelat(luaL_check_number(2), l); 49 long start = posrelat(luaL_check_long(2), l);
50 long end = posrelat(luaL_opt_number(3, -1), l); 50 long end = posrelat(luaL_opt_long(3, -1), l);
51 if (start < 1) start = 1; 51 if (start < 1) start = 1;
52 if (end > l) end = l; 52 if (end > l) end = l;
53 if (start <= end) 53 if (start <= end)
@@ -82,7 +82,7 @@ static void str_rep (void)
82{ 82{
83 long l; 83 long l;
84 char *s = luaL_check_lstr(1, &l); 84 char *s = luaL_check_lstr(1, &l);
85 int n = (int)luaL_check_number(2); 85 int n = luaL_check_int(2);
86 luaL_resetbuffer(); 86 luaL_resetbuffer();
87 while (n-- > 0) 87 while (n-- > 0)
88 addnchar(s, l); 88 addnchar(s, l);
@@ -94,7 +94,7 @@ static void str_byte (void)
94{ 94{
95 long l; 95 long l;
96 char *s = luaL_check_lstr(1, &l); 96 char *s = luaL_check_lstr(1, &l);
97 long pos = posrelat(luaL_opt_number(2, 1), l); 97 long pos = posrelat(luaL_opt_long(2, 1), l);
98 luaL_arg_check(0<pos && pos<=l, 2, "out of range"); 98 luaL_arg_check(0<pos && pos<=l, 2, "out of range");
99 lua_pushnumber((unsigned char)s[pos-1]); 99 lua_pushnumber((unsigned char)s[pos-1]);
100} 100}
@@ -105,7 +105,7 @@ static void str_char (void) {
105 while (lua_getparam(++i) != LUA_NOOBJECT) { 105 while (lua_getparam(++i) != LUA_NOOBJECT) {
106 double c = luaL_check_number(i); 106 double c = luaL_check_number(i);
107 luaL_arg_check((unsigned char)c == c, i, "invalid value"); 107 luaL_arg_check((unsigned char)c == c, i, "invalid value");
108 luaL_addchar((int)c); 108 luaL_addchar((unsigned char)c);
109 } 109 }
110 closeandpush(); 110 closeandpush();
111} 111}
@@ -338,7 +338,7 @@ static void str_find (void)
338 long l; 338 long l;
339 char *s = luaL_check_lstr(1, &l); 339 char *s = luaL_check_lstr(1, &l);
340 char *p = luaL_check_string(2); 340 char *p = luaL_check_string(2);
341 long init = posrelat(luaL_opt_number(3, 1), l) - 1; 341 long init = posrelat(luaL_opt_long(3, 1), l) - 1;
342 struct Capture cap; 342 struct Capture cap;
343 luaL_arg_check(0 <= init && init <= l, 3, "out of range"); 343 luaL_arg_check(0 <= init && init <= l, 3, "out of range");
344 if (lua_getparam(4) != LUA_NOOBJECT || 344 if (lua_getparam(4) != LUA_NOOBJECT ||
@@ -418,7 +418,7 @@ static void str_gsub (void)
418 char *src = luaL_check_lstr(1, &srcl); 418 char *src = luaL_check_lstr(1, &srcl);
419 char *p = luaL_check_string(2); 419 char *p = luaL_check_string(2);
420 lua_Object newp = lua_getparam(3); 420 lua_Object newp = lua_getparam(3);
421 int max_s = (int)luaL_opt_number(4, srcl+1); 421 int max_s = luaL_opt_int(4, srcl+1);
422 int anchor = (*p == '^') ? (p++, 1) : 0; 422 int anchor = (*p == '^') ? (p++, 1) : 0;
423 int n = 0; 423 int n = 0;
424 struct Capture cap; 424 struct Capture cap;
@@ -507,7 +507,7 @@ static void str_format (void)
507 break; 507 break;
508 } 508 }
509 case 'c': case 'd': case 'i': 509 case 'c': case 'd': case 'i':
510 sprintf(buff, form, (int)luaL_check_number(arg)); 510 sprintf(buff, form, luaL_check_int(arg));
511 break; 511 break;
512 case 'o': case 'u': case 'x': case 'X': 512 case 'o': case 'u': case 'x': case 'X':
513 sprintf(buff, form, (unsigned int)luaL_check_number(arg)); 513 sprintf(buff, form, (unsigned int)luaL_check_number(arg));
diff --git a/lua.c b/lua.c
index fccf5236..c7f22188 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.13 1998/01/19 19:49:49 roberto Exp roberto $ 2** $Id: lua.c,v 1.14 1998/02/11 20:56:05 roberto Exp roberto $
3** Lua stand-alone interpreter 3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -32,27 +32,27 @@ typedef void (*handler)(int); /* type for signal actions */
32 32
33static void laction (int i); 33static void laction (int i);
34 34
35static handler lreset (void) 35
36{ 36static handler lreset (void) {
37 lua_linehook = NULL; 37 lua_linehook = NULL;
38 lua_callhook = NULL; 38 lua_callhook = NULL;
39 return signal(SIGINT, laction); 39 return signal(SIGINT, laction);
40} 40}
41 41
42static void lstop (void) 42
43{ 43static void lstop (void) {
44 lreset(); 44 lreset();
45 lua_error("interrupted!"); 45 lua_error("interrupted!");
46} 46}
47 47
48static void laction (int i) 48
49{ 49static void laction (int i) {
50 lua_linehook = (lua_LHFunction)lstop; 50 lua_linehook = (lua_LHFunction)lstop;
51 lua_callhook = (lua_CHFunction)lstop; 51 lua_callhook = (lua_CHFunction)lstop;
52} 52}
53 53
54static int ldo (int (*f)(char *), char *name) 54
55{ 55static int ldo (int (*f)(char *), char *name) {
56 int res; 56 int res;
57 handler h = lreset(); 57 handler h = lreset();
58 res = f(name); /* dostring | dofile */ 58 res = f(name); /* dostring | dofile */
@@ -61,8 +61,7 @@ static int ldo (int (*f)(char *), char *name)
61} 61}
62 62
63 63
64static void print_message (void) 64static void print_message (void) {
65{
66 fprintf(stderr, 65 fprintf(stderr,
67"Lua: command line options:\n" 66"Lua: command line options:\n"
68" -v print version information\n" 67" -v print version information\n"
@@ -76,8 +75,7 @@ static void print_message (void)
76} 75}
77 76
78 77
79static void assign (char *arg) 78static void assign (char *arg) {
80{
81 if (strlen(arg) >= 500) 79 if (strlen(arg) >= 500)
82 fprintf(stderr, "lua: shell argument too long"); 80 fprintf(stderr, "lua: shell argument too long");
83 else { 81 else {
@@ -90,13 +88,11 @@ static void assign (char *arg)
90 } 88 }
91} 89}
92 90
93#define BUF_SIZE 512
94 91
95static void manual_input (int prompt) 92static void manual_input (int prompt) {
96{
97 int cont = 1; 93 int cont = 1;
98 while (cont) { 94 while (cont) {
99 char buffer[BUF_SIZE]; 95 char buffer[BUFSIZ];
100 int i = 0; 96 int i = 0;
101 lua_beginblock(); 97 lua_beginblock();
102 if (prompt) 98 if (prompt)
@@ -112,13 +108,13 @@ static void manual_input (int prompt)
112 buffer[i-1] = '\n'; 108 buffer[i-1] = '\n';
113 else break; 109 else break;
114 } 110 }
115 else if (i >= BUF_SIZE-1) { 111 else if (i >= BUFSIZ-1) {
116 fprintf(stderr, "lua: argument line too long\n"); 112 fprintf(stderr, "lua: argument line too long\n");
117 break; 113 break;
118 } 114 }
119 else buffer[i++] = c; 115 else buffer[i++] = (char)c;
120 } 116 }
121 buffer[i] = 0; 117 buffer[i] = '\0';
122 ldo(lua_dostring, buffer); 118 ldo(lua_dostring, buffer);
123 lua_endblock(); 119 lua_endblock();
124 } 120 }
diff --git a/lzio.c b/lzio.c
index 35a2d6a7..8e11ef4d 100644
--- a/lzio.c
+++ b/lzio.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.c,v 1.2 1997/11/21 19:00:46 roberto Exp roberto $ 2** $Id: lzio.c,v 1.3 1997/12/22 20:57:18 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*/
@@ -15,11 +15,11 @@
15 15
16/* ----------------------------------------------------- memory buffers --- */ 16/* ----------------------------------------------------- memory buffers --- */
17 17
18static int zmfilbuf (ZIO* z) 18static int zmfilbuf (ZIO* z) {
19{
20 return EOZ; 19 return EOZ;
21} 20}
22 21
22
23ZIO* zmopen (ZIO* z, char* b, int size, char *name) 23ZIO* zmopen (ZIO* z, char* b, int size, char *name)
24{ 24{
25 if (b==NULL) return NULL; 25 if (b==NULL) return NULL;