aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-05-07 14:36:56 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-05-07 14:36:56 -0300
commitdea6b6da9422f34ad91c8f6ad9ad3ed650e95713 (patch)
tree3016b2fbcd67d75c71ee1b190aff2c24ada9b168
parent71144e3ff0cb81bd9b8bb56d94dc76074c638c64 (diff)
downloadlua-dea6b6da9422f34ad91c8f6ad9ad3ed650e95713.tar.gz
lua-dea6b6da9422f34ad91c8f6ad9ad3ed650e95713.tar.bz2
lua-dea6b6da9422f34ad91c8f6ad9ad3ed650e95713.zip
new function `lua_vpushstr' to replace uses of `sprintf'
-rw-r--r--lapi.c11
-rw-r--r--lauxlib.c34
-rw-r--r--lcode.c11
-rw-r--r--lcode.h3
-rw-r--r--ldblib.c9
-rw-r--r--ldebug.c10
-rw-r--r--ldo.c10
-rw-r--r--llex.c91
-rw-r--r--llex.h6
-rw-r--r--lobject.c94
-rw-r--r--lobject.h4
-rw-r--r--lparser.c37
-rw-r--r--lstate.c4
-rw-r--r--lua.h6
-rw-r--r--lundump.c20
15 files changed, 194 insertions, 156 deletions
diff --git a/lapi.c b/lapi.c
index fa05ca49..87a2abbe 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.188 2002/05/06 15:51:41 roberto Exp roberto $ 2** $Id: lapi.c,v 1.189 2002/05/06 19:05:10 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -354,6 +354,13 @@ LUA_API void lua_pushstring (lua_State *L, const char *s) {
354} 354}
355 355
356 356
357LUA_API void lua_vpushstr (lua_State *L, const char *fmt, va_list argp) {
358 lua_lock(L);
359 luaO_vpushstr(L, fmt, argp);
360 lua_unlock(L);
361}
362
363
357LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { 364LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
358 Closure *cl; 365 Closure *cl;
359 lua_lock(L); 366 lua_lock(L);
@@ -514,7 +521,7 @@ LUA_API void lua_setmetatable (lua_State *L, int objindex) {
514 uvalue(obj)->uv.metatable = hvalue(mt); 521 uvalue(obj)->uv.metatable = hvalue(mt);
515 break; 522 break;
516 default: 523 default:
517 luaO_verror(L, "cannot change the meta table of a %.20s", 524 luaO_verror(L, "cannot change the meta table of a %s",
518 luaT_typenames[ttype(obj)]); 525 luaT_typenames[ttype(obj)]);
519 } 526 }
520 lua_unlock(L); 527 lua_unlock(L);
diff --git a/lauxlib.c b/lauxlib.c
index 7be33892..2537ca8c 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.67 2002/05/01 20:40:42 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.68 2002/05/06 19:05:10 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*/
@@ -142,38 +142,10 @@ LUALIB_API void luaL_opennamedlib (lua_State *L, const char *libname,
142} 142}
143 143
144 144
145static void vstr (lua_State *L, const char *fmt, va_list argp) {
146 luaL_Buffer b;
147 luaL_buffinit(L, &b);
148 for (;;) {
149 const char *e = strchr(fmt, '%');
150 if (e == NULL) break;
151 luaL_addlstring(&b, fmt, e-fmt);
152 switch (*(e+1)) {
153 case 's':
154 luaL_addstring(&b, va_arg(argp, char *));
155 break;
156 case 'd':
157 lua_pushnumber(L, va_arg(argp, int));
158 luaL_addvalue (&b);
159 break;
160 case '%':
161 luaL_putchar(&b, '%');
162 break;
163 default:
164 lua_error(L, "invalid format option");
165 }
166 fmt = e+2;
167 }
168 luaL_addstring(&b, fmt);
169 luaL_pushresult(&b);
170}
171
172
173LUALIB_API void luaL_vstr (lua_State *L, const char *fmt, ...) { 145LUALIB_API void luaL_vstr (lua_State *L, const char *fmt, ...) {
174 va_list argp; 146 va_list argp;
175 va_start(argp, fmt); 147 va_start(argp, fmt);
176 vstr(L, fmt, argp); 148 lua_vpushstr(L, fmt, argp);
177 va_end(argp); 149 va_end(argp);
178} 150}
179 151
@@ -181,7 +153,7 @@ LUALIB_API void luaL_vstr (lua_State *L, const char *fmt, ...) {
181LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...) { 153LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...) {
182 va_list argp; 154 va_list argp;
183 va_start(argp, fmt); 155 va_start(argp, fmt);
184 vstr(L, fmt, argp); 156 lua_vpushstr(L, fmt, argp);
185 va_end(argp); 157 va_end(argp);
186 return lua_errorobj(L); 158 return lua_errorobj(L);
187} 159}
diff --git a/lcode.c b/lcode.c
index a11ca0e4..a34eed8e 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.97 2002/04/24 20:07:46 roberto Exp roberto $ 2** $Id: lcode.c,v 1.98 2002/05/06 15:51:41 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -23,11 +23,6 @@
23#define hasjumps(e) ((e)->t != (e)->f) 23#define hasjumps(e) ((e)->t != (e)->f)
24 24
25 25
26void luaK_error (LexState *ls, const char *msg) {
27 luaX_error(ls, msg, ls->t.token);
28}
29
30
31void luaK_nil (FuncState *fs, int from, int n) { 26void luaK_nil (FuncState *fs, int from, int n) {
32 Instruction *previous; 27 Instruction *previous;
33 if (fs->pc > fs->lasttarget && /* no jumps to current position? */ 28 if (fs->pc > fs->lasttarget && /* no jumps to current position? */
@@ -67,7 +62,7 @@ static void luaK_fixjump (FuncState *fs, int pc, int dest) {
67 else { /* jump is relative to position following jump instruction */ 62 else { /* jump is relative to position following jump instruction */
68 int offset = dest-(pc+1); 63 int offset = dest-(pc+1);
69 if (abs(offset) > MAXARG_sBx) 64 if (abs(offset) > MAXARG_sBx)
70 luaK_error(fs->ls, "control structure too long"); 65 luaX_syntaxerror(fs->ls, "control structure too long");
71 SETARG_sBx(*jmp, offset); 66 SETARG_sBx(*jmp, offset);
72 } 67 }
73} 68}
@@ -182,7 +177,7 @@ static void luaK_checkstack (FuncState *fs, int n) {
182 int newstack = fs->freereg + n; 177 int newstack = fs->freereg + n;
183 if (newstack > fs->f->maxstacksize) { 178 if (newstack > fs->f->maxstacksize) {
184 if (newstack >= MAXSTACK) 179 if (newstack >= MAXSTACK)
185 luaK_error(fs->ls, "function or expression too complex"); 180 luaX_syntaxerror(fs->ls, "function or expression too complex");
186 fs->f->maxstacksize = cast(lu_byte, newstack); 181 fs->f->maxstacksize = cast(lu_byte, newstack);
187 } 182 }
188} 183}
diff --git a/lcode.h b/lcode.h
index 66ee9a36..472b4ebc 100644
--- a/lcode.h
+++ b/lcode.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.h,v 1.31 2002/04/09 18:49:30 roberto Exp roberto $ 2** $Id: lcode.h,v 1.32 2002/04/24 20:07:46 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -41,7 +41,6 @@ typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_NOUNOPR } UnOpr;
41 41
42#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 42#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
43 43
44void luaK_error (LexState *ls, const char *msg);
45int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 44int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
46int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 45int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
47void luaK_nil (FuncState *fs, int from, int n); 46void luaK_nil (FuncState *fs, int from, int n);
diff --git a/ldblib.c b/ldblib.c
index 106c1e02..8fe60179 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.49 2002/05/01 20:40:42 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.50 2002/05/06 19:05:10 roberto Exp roberto $
3** Interface from Lua to its debug API 3** Interface from Lua to its debug API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -34,7 +34,6 @@ static void settabsi (lua_State *L, const char *i, int v) {
34static int getinfo (lua_State *L) { 34static int getinfo (lua_State *L) {
35 lua_Debug ar; 35 lua_Debug ar;
36 const char *options = luaL_opt_string(L, 2, "flnSu"); 36 const char *options = luaL_opt_string(L, 2, "flnSu");
37 char buff[20];
38 if (lua_isnumber(L, 1)) { 37 if (lua_isnumber(L, 1)) {
39 if (!lua_getstack(L, (int)(lua_tonumber(L, 1)), &ar)) { 38 if (!lua_getstack(L, (int)(lua_tonumber(L, 1)), &ar)) {
40 lua_pushnil(L); /* level out of range */ 39 lua_pushnil(L); /* level out of range */
@@ -42,9 +41,9 @@ static int getinfo (lua_State *L) {
42 } 41 }
43 } 42 }
44 else if (lua_isfunction(L, 1)) { 43 else if (lua_isfunction(L, 1)) {
44 luaL_vstr(L, ">%s", options);
45 options = lua_tostring(L, -1);
45 lua_pushvalue(L, 1); 46 lua_pushvalue(L, 1);
46 sprintf(buff, ">%.10s", options);
47 options = buff;
48 } 47 }
49 else 48 else
50 return luaL_argerror(L, 1, "function or level expected"); 49 return luaL_argerror(L, 1, "function or level expected");
@@ -170,7 +169,7 @@ static int setlinehook (lua_State *L) {
170static int debug (lua_State *L) { 169static int debug (lua_State *L) {
171 for (;;) { 170 for (;;) {
172 char buffer[250]; 171 char buffer[250];
173 fprintf(stderr, "lua_debug> "); 172 fputs("lua_debug> ", stderr);
174 if (fgets(buffer, sizeof(buffer), stdin) == 0 || 173 if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
175 strcmp(buffer, "cont\n") == 0) 174 strcmp(buffer, "cont\n") == 0)
176 return 0; 175 return 0;
diff --git a/ldebug.c b/ldebug.c
index 8cb5f48b..a86f32e5 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.110 2002/04/24 20:07:46 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.111 2002/05/02 13:06:20 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -487,10 +487,10 @@ void luaG_typeerror (lua_State *L, const TObject *o, const char *op) {
487 if (isinstack(L->ci, o)) 487 if (isinstack(L->ci, o))
488 kind = getobjname(L, L->ci, o - L->ci->base, &name); 488 kind = getobjname(L, L->ci, o - L->ci->base, &name);
489 if (kind) 489 if (kind)
490 luaO_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)", 490 luaO_verror(L, "attempt to %s %s `%s' (a %s value)",
491 op, kind, name, t); 491 op, kind, name, t);
492 else 492 else
493 luaO_verror(L, "attempt to %.30s a %.10s value", op, t); 493 luaO_verror(L, "attempt to %s a %s value", op, t);
494} 494}
495 495
496 496
@@ -513,8 +513,8 @@ void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) {
513 const char *t1 = luaT_typenames[ttype(p1)]; 513 const char *t1 = luaT_typenames[ttype(p1)];
514 const char *t2 = luaT_typenames[ttype(p2)]; 514 const char *t2 = luaT_typenames[ttype(p2)];
515 if (t1[2] == t2[2]) 515 if (t1[2] == t2[2])
516 luaO_verror(L, "attempt to compare two %.10s values", t1); 516 luaO_verror(L, "attempt to compare two %s values", t1);
517 else 517 else
518 luaO_verror(L, "attempt to compare %.10s with %.10s", t1, t2); 518 luaO_verror(L, "attempt to compare %s with %s", t1, t2);
519} 519}
520 520
diff --git a/ldo.c b/ldo.c
index 4dfb7d9e..87a78ed8 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.172 2002/04/22 14:40:50 roberto Exp roberto $ 2** $Id: ldo.c,v 1.173 2002/05/01 20:40:42 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -436,8 +436,7 @@ int luaD_protectedparser (lua_State *L, ZIO *z, int bin) {
436 } 436 }
437 else { 437 else {
438 setobj(L->top++, &p.err); 438 setobj(L->top++, &p.err);
439 if (status == LUA_ERRRUN) /* an error occurred: correct error code */ 439 lua_assert(status != LUA_ERRRUN);
440 status = LUA_ERRSYNTAX;
441 } 440 }
442 lua_unlock(L); 441 lua_unlock(L);
443 return status; 442 return status;
@@ -459,9 +458,8 @@ static void message (lua_State *L, const TObject *msg, int nofunc) {
459 } 458 }
460 else { /* call error function */ 459 else { /* call error function */
461 setobj(L->top, m); 460 setobj(L->top, m);
462 incr_top(L); 461 setobj(L->top + 1, msg);
463 setobj(L->top, msg); 462 L->top += 2;
464 incr_top(L);
465 luaD_call(L, L->top - 2, 1); 463 luaD_call(L, L->top - 2, 1);
466 setobj(m, L->top - 1); 464 setobj(m, L->top - 1);
467 } 465 }
diff --git a/llex.c b/llex.c
index 0004c9a8..91dd6379 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.98 2002/03/08 19:07:01 roberto Exp roberto $ 2** $Id: llex.c,v 1.99 2002/03/08 19:25:24 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -11,6 +11,7 @@
11 11
12#include "lua.h" 12#include "lua.h"
13 13
14#include "ldo.h"
14#include "llex.h" 15#include "llex.h"
15#include "lobject.h" 16#include "lobject.h"
16#include "lparser.h" 17#include "lparser.h"
@@ -29,9 +30,9 @@ static const char *const token2string [] = {
29 "and", "break", "do", "else", "elseif", 30 "and", "break", "do", "else", "elseif",
30 "end", "false", "for", "function", "global", "if", 31 "end", "false", "for", "function", "global", "if",
31 "in", "local", "nil", "not", "or", "repeat", 32 "in", "local", "nil", "not", "or", "repeat",
32 "return", "then", "true", "until", "while", "", 33 "return", "then", "true", "until", "while", "*name",
33 "..", "...", "==", ">=", "<=", "~=", 34 "..", "...", "==", ">=", "<=", "~=",
34 "", "", "<eof>" 35 "*number", "*string", "<eof>"
35}; 36};
36 37
37 38
@@ -50,53 +51,57 @@ void luaX_init (lua_State *L) {
50 51
51void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) { 52void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
52 if (val > limit) { 53 if (val > limit) {
53 char buff[90]; 54 msg = luaO_pushstr(ls->L, "too many %s (limit=%d)", msg, limit);
54 sprintf(buff, "too many %.40s (limit=%d)", msg, limit); 55 luaX_syntaxerror(ls, msg);
55 luaX_error(ls, buff, ls->t.token);
56 } 56 }
57} 57}
58 58
59 59
60static void luaX_syntaxerror (LexState *ls, const char *s, 60static void luaX_error (LexState *ls, const char *s, const char *token) {
61 const char *token) { 61 lua_State *L = ls->L;
62 char buff[MAXSRC]; 62 char buff[MAXSRC];
63 luaO_chunkid(buff, getstr(ls->source), MAXSRC); 63 luaO_chunkid(buff, getstr(ls->source), MAXSRC);
64 luaO_verror(ls->L, 64 luaO_pushstr(L, "%s;\n last token read: `%s' at line %d in %s",
65 "%.99s;\n last token read: `%.30s' at line %d in %.80s", 65 s, token, ls->linenumber, buff);
66 s, token, ls->linenumber, buff); 66 luaD_errorobj(L, L->top - 1, LUA_ERRSYNTAX);
67} 67}
68 68
69 69
70void luaX_token2str (int token, char *s) { 70void luaX_syntaxerror (LexState *ls, const char *msg) {
71 if (token < FIRST_RESERVED) { 71 const char *lasttoken;
72 lua_assert(token == (char)token); 72 switch (ls->t.token) {
73 s[0] = (char)token; 73 case TK_NAME:
74 s[1] = '\0'; 74 lasttoken = luaO_pushstr(ls->L, "%s", getstr(ls->t.seminfo.ts));
75 break;
76 case TK_STRING:
77 lasttoken = luaO_pushstr(ls->L, "\"%s\"", getstr(ls->t.seminfo.ts));
78 break;
79 case TK_NUMBER:
80 lasttoken = luaO_pushstr(ls->L, "%f", ls->t.seminfo.r);
81 break;
82 default:
83 lasttoken = luaX_token2str(ls, ls->t.token);
84 break;
75 } 85 }
76 else 86 luaX_error(ls, msg, lasttoken);
77 strcpy(s, token2string[token-FIRST_RESERVED]);
78} 87}
79 88
80 89
81static char *token2str_all (LexState *ls, int token, char *s) { 90const char *luaX_token2str (LexState *ls, int token) {
82 luaX_token2str(token, s); 91 if (token < FIRST_RESERVED) {
83 if (s[0] == '\0') 92 lua_assert(token == (char)token);
84 return cast(char *, G(ls->L)->Mbuffer); 93 return luaO_pushstr(ls->L, "%c", token);
94 }
85 else 95 else
86 return s; 96 return token2string[token-FIRST_RESERVED];
87}
88
89
90void luaX_error (LexState *ls, const char *s, int token) {
91 char buff[TOKEN_LEN];
92 luaX_syntaxerror(ls, s, token2str_all(ls, token, buff));
93} 97}
94 98
95 99
96static void luaX_invalidchar (LexState *ls, int c) { 100static void luaX_lexerror (LexState *ls, const char *s, int token) {
97 char buff[8]; 101 if (token == TK_EOS)
98 sprintf(buff, "0x%02X", (unsigned char)c); 102 luaX_error(ls, s, luaX_token2str(ls, token));
99 luaX_syntaxerror(ls, "invalid control char", buff); 103 else
104 luaX_error(ls, s, cast(char *, G(ls->L)->Mbuffer));
100} 105}
101 106
102 107
@@ -171,7 +176,7 @@ static void read_number (LexState *LS, int comma, SemInfo *seminfo) {
171 if (LS->current == '.') { 176 if (LS->current == '.') {
172 save_and_next(L, LS, l); 177 save_and_next(L, LS, l);
173 save(L, '\0', l); 178 save(L, '\0', l);
174 luaX_error(LS, 179 luaX_lexerror(LS,
175 "ambiguous syntax (decimal point x string concatenation)", 180 "ambiguous syntax (decimal point x string concatenation)",
176 TK_NUMBER); 181 TK_NUMBER);
177 } 182 }
@@ -191,7 +196,7 @@ static void read_number (LexState *LS, int comma, SemInfo *seminfo) {
191 } 196 }
192 save(L, '\0', l); 197 save(L, '\0', l);
193 if (!luaO_str2d(cast(char *, G(L)->Mbuffer), &seminfo->r)) 198 if (!luaO_str2d(cast(char *, G(L)->Mbuffer), &seminfo->r))
194 luaX_error(LS, "malformed number", TK_NUMBER); 199 luaX_lexerror(LS, "malformed number", TK_NUMBER);
195} 200}
196 201
197 202
@@ -209,7 +214,7 @@ static void read_long_string (LexState *LS, SemInfo *seminfo) {
209 switch (LS->current) { 214 switch (LS->current) {
210 case EOZ: 215 case EOZ:
211 save(L, '\0', l); 216 save(L, '\0', l);
212 luaX_error(LS, (seminfo) ? "unfinished long string" : 217 luaX_lexerror(LS, (seminfo) ? "unfinished long string" :
213 "unfinished long comment", TK_EOS); 218 "unfinished long comment", TK_EOS);
214 break; /* to avoid warnings */ 219 break; /* to avoid warnings */
215 case '[': 220 case '[':
@@ -251,10 +256,13 @@ static void read_string (LexState *LS, int del, SemInfo *seminfo) {
251 while (LS->current != del) { 256 while (LS->current != del) {
252 checkbuffer(L, l); 257 checkbuffer(L, l);
253 switch (LS->current) { 258 switch (LS->current) {
254 case EOZ: case '\n': 259 case EOZ:
260 save(L, '\0', l);
261 luaX_lexerror(LS, "unfinished string", TK_EOS);
262 break; /* to avoid warnings */
263 case '\n':
255 save(L, '\0', l); 264 save(L, '\0', l);
256 luaX_error(LS, "unfinished string", 265 luaX_lexerror(LS, "unfinished string", TK_STRING);
257 (LS->current == EOZ) ? TK_EOS : TK_STRING);
258 break; /* to avoid warnings */ 266 break; /* to avoid warnings */
259 case '\\': 267 case '\\':
260 next(LS); /* do not save the `\' */ 268 next(LS); /* do not save the `\' */
@@ -279,7 +287,7 @@ static void read_string (LexState *LS, int del, SemInfo *seminfo) {
279 } while (++i<3 && isdigit(LS->current)); 287 } while (++i<3 && isdigit(LS->current));
280 if (c > UCHAR_MAX) { 288 if (c > UCHAR_MAX) {
281 save(L, '\0', l); 289 save(L, '\0', l);
282 luaX_error(LS, "escape sequence too large", TK_STRING); 290 luaX_lexerror(LS, "escape sequence too large", TK_STRING);
283 } 291 }
284 save(L, c, l); 292 save(L, c, l);
285 } 293 }
@@ -389,7 +397,8 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
389 else { 397 else {
390 int c = LS->current; 398 int c = LS->current;
391 if (iscntrl(c)) 399 if (iscntrl(c))
392 luaX_invalidchar(LS, c); 400 luaX_error(LS, "invalid control char",
401 luaO_pushstr(LS->L, "char(%d)", c));
393 next(LS); 402 next(LS);
394 return c; /* single-char tokens (+ - / ...) */ 403 return c; /* single-char tokens (+ - / ...) */
395 } 404 }
diff --git a/llex.h b/llex.h
index 67edd491..ed53e2a3 100644
--- a/llex.h
+++ b/llex.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.h,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $ 2** $Id: llex.h,v 1.42 2002/02/08 22:42:41 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -65,8 +65,8 @@ void luaX_init (lua_State *L);
65void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source); 65void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source);
66int luaX_lex (LexState *LS, SemInfo *seminfo); 66int luaX_lex (LexState *LS, SemInfo *seminfo);
67void luaX_checklimit (LexState *ls, int val, int limit, const char *msg); 67void luaX_checklimit (LexState *ls, int val, int limit, const char *msg);
68void luaX_error (LexState *ls, const char *s, int token); 68void luaX_syntaxerror (LexState *ls, const char *s);
69void luaX_token2str (int token, char *s); 69const char *luaX_token2str (LexState *ls, int token);
70 70
71 71
72#endif 72#endif
diff --git a/lobject.c b/lobject.c
index b555c8ce..96590aa5 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 1.77 2002/04/22 14:40:23 roberto Exp roberto $ 2** $Id: lobject.c,v 1.78 2002/05/06 15:51:41 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -16,6 +16,8 @@
16#include "lmem.h" 16#include "lmem.h"
17#include "lobject.h" 17#include "lobject.h"
18#include "lstate.h" 18#include "lstate.h"
19#include "lstring.h"
20#include "lvm.h"
19 21
20 22
21 23
@@ -89,17 +91,72 @@ int luaO_str2d (const char *s, lua_Number *result) {
89} 91}
90 92
91 93
92/* maximum length of a string format for `luaO_verror' */
93#define MAX_VERROR 280
94 94
95/* this function needs to handle only '%d' and '%.XXs' formats */ 95static void pushstr (lua_State *L, const char *str) {
96 setsvalue(L->top, luaS_new(L, str));
97 incr_top(L);
98}
99
100
101/* this function handles only `%d', `%c', %f, and `%s' formats */
102const char *luaO_vpushstr (lua_State *L, const char *fmt, va_list argp) {
103 int n = 0;
104 for (;;) {
105 const char *e = strchr(fmt, '%');
106 if (e == NULL) break;
107 setsvalue(L->top, luaS_newlstr(L, fmt, e-fmt));
108 incr_top(L);
109 switch (*(e+1)) {
110 case 's':
111 pushstr(L, va_arg(argp, char *));
112 break;
113 case 'c': {
114 char buff[2];
115 buff[0] = va_arg(argp, int);
116 buff[1] = '\0';
117 pushstr(L, buff);
118 break;
119 }
120 case 'd':
121 setnvalue(L->top, va_arg(argp, int));
122 incr_top(L);
123 break;
124 case 'f':
125 setnvalue(L->top, va_arg(argp, lua_Number));
126 incr_top(L);
127 break;
128 case '%':
129 pushstr(L, "%");
130 break;
131 default: lua_assert(0);
132 }
133 n += 2;
134 fmt = e+2;
135 }
136 pushstr(L, fmt);
137 luaV_strconc(L, n+1, L->top - L->ci->base - 1);
138 L->top -= n;
139 return svalue(L->top - 1);
140}
141
142
143const char *luaO_pushstr (lua_State *L, const char *fmt, ...) {
144 const char *msg;
145 va_list argp;
146 va_start(argp, fmt);
147 msg = luaO_vpushstr(L, fmt, argp);
148 va_end(argp);
149 return msg;
150}
151
152
96void luaO_verror (lua_State *L, const char *fmt, ...) { 153void luaO_verror (lua_State *L, const char *fmt, ...) {
154 const char *msg;
97 va_list argp; 155 va_list argp;
98 char buff[MAX_VERROR]; /* to hold formatted message */
99 va_start(argp, fmt); 156 va_start(argp, fmt);
100 vsprintf(buff, fmt, argp); 157 msg = luaO_vpushstr(L, fmt, argp);
101 va_end(argp); 158 va_end(argp);
102 luaD_runerror(L, buff); 159 luaD_runerror(L, msg);
103} 160}
104 161
105 162
@@ -108,31 +165,32 @@ void luaO_chunkid (char *out, const char *source, int bufflen) {
108 strncpy(out, source+1, bufflen); /* remove first char */ 165 strncpy(out, source+1, bufflen); /* remove first char */
109 out[bufflen-1] = '\0'; /* ensures null termination */ 166 out[bufflen-1] = '\0'; /* ensures null termination */
110 } 167 }
111 else { 168 else { /* out = "file `source'", or "file `...source'" */
112 if (*source == '@') { 169 if (*source == '@') {
113 int l; 170 int l;
114 source++; /* skip the `@' */ 171 source++; /* skip the `@' */
115 bufflen -= sizeof("file `...%s'"); 172 bufflen -= sizeof(" file `...' ");
116 l = strlen(source); 173 l = strlen(source);
174 strcpy(out, "file `");
117 if (l>bufflen) { 175 if (l>bufflen) {
118 source += (l-bufflen); /* get last part of file name */ 176 source += (l-bufflen); /* get last part of file name */
119 sprintf(out, "file `...%.99s'", source); 177 strcat(out, "...");
120 } 178 }
121 else 179 strcat(out, source);
122 sprintf(out, "file `%.99s'", source); 180 strcat(out, "'");
123 } 181 }
124 else { 182 else {
125 int len = strcspn(source, "\n"); /* stop at first newline */ 183 int len = strcspn(source, "\n"); /* stop at first newline */
126 bufflen -= sizeof("string \"%.*s...\""); 184 bufflen -= sizeof(" string \"...\" ");
127 if (len > bufflen) len = bufflen; 185 if (len > bufflen) len = bufflen;
186 strcpy(out, "string \"");
128 if (source[len] != '\0') { /* must truncate? */ 187 if (source[len] != '\0') { /* must truncate? */
129 strcpy(out, "string \""); 188 strncat(out, source, len);
130 out += strlen(out); 189 strcat(out, "...");
131 strncpy(out, source, len);
132 strcpy(out+len, "...\"");
133 } 190 }
134 else 191 else
135 sprintf(out, "string \"%.99s\"", source); 192 strcat(out, source);
193 strcat(out, "\"");
136 } 194 }
137 } 195 }
138} 196}
diff --git a/lobject.h b/lobject.h
index 6637631a..ad3233f6 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.129 2002/04/05 18:54:31 roberto Exp roberto $ 2** $Id: lobject.h,v 1.130 2002/05/06 15:51:41 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -250,6 +250,8 @@ void *luaO_openspaceaux (lua_State *L, size_t n);
250int luaO_equalObj (const TObject *t1, const TObject *t2); 250int luaO_equalObj (const TObject *t1, const TObject *t2);
251int luaO_str2d (const char *s, lua_Number *result); 251int luaO_str2d (const char *s, lua_Number *result);
252 252
253const char *luaO_vpushstr (lua_State *L, const char *fmt, va_list argp);
254const char *luaO_pushstr (lua_State *L, const char *fmt, ...);
253void luaO_verror (lua_State *L, const char *fmt, ...); 255void luaO_verror (lua_State *L, const char *fmt, ...);
254void luaO_chunkid (char *out, const char *source, int len); 256void luaO_chunkid (char *out, const char *source, int len);
255 257
diff --git a/lparser.c b/lparser.c
index 9e6458e0..b6e500b8 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.177 2002/04/22 14:38:52 roberto Exp roberto $ 2** $Id: lparser.c,v 1.178 2002/04/24 20:07:46 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -66,10 +66,8 @@ static void lookahead (LexState *ls) {
66 66
67 67
68static void error_expected (LexState *ls, int token) { 68static void error_expected (LexState *ls, int token) {
69 char buff[30], t[TOKEN_LEN]; 69 luaX_syntaxerror(ls,
70 luaX_token2str(token, t); 70 luaO_pushstr(ls->L, "`%s' expected", luaX_token2str(ls, token)));
71 sprintf(buff, "`%.10s' expected", t);
72 luaK_error(ls, buff);
73} 71}
74 72
75 73
@@ -80,7 +78,7 @@ static void check (LexState *ls, int c) {
80} 78}
81 79
82 80
83#define check_condition(ls,c,msg) { if (!(c)) luaK_error(ls, msg); } 81#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); }
84 82
85 83
86static int optional (LexState *ls, int c) { 84static int optional (LexState *ls, int c) {
@@ -97,13 +95,9 @@ static void check_match (LexState *ls, int what, int who, int where) {
97 if (where == ls->linenumber) 95 if (where == ls->linenumber)
98 error_expected(ls, what); 96 error_expected(ls, what);
99 else { 97 else {
100 char buff[70]; 98 luaX_syntaxerror(ls, luaO_pushstr(ls->L,
101 char t_what[TOKEN_LEN], t_who[TOKEN_LEN]; 99 "`%s' expected (to close `%s' at line %d)",
102 luaX_token2str(what, t_what); 100 luaX_token2str(ls, what), luaX_token2str(ls, who), where));
103 luaX_token2str(who, t_who);
104 sprintf(buff, "`%.10s' expected (to close `%.10s' at line %d)",
105 t_what, t_who, where);
106 luaK_error(ls, buff);
107 } 101 }
108 } 102 }
109 next(ls); 103 next(ls);
@@ -256,7 +250,7 @@ static int singlevar_aux (FuncState *fs, TString *n, expdesc *var, int nd) {
256 if (var->k == VGLOBAL) { 250 if (var->k == VGLOBAL) {
257 if (k == VNIL && nd && fs->defaultglob != NO_REG) { 251 if (k == VNIL && nd && fs->defaultglob != NO_REG) {
258 if (fs->defaultglob == NO_REG1) 252 if (fs->defaultglob == NO_REG1)
259 luaK_error(fs->ls, "undeclared global"); 253 luaX_syntaxerror(fs->ls, "undeclared global");
260 init_exp(var, VLOCAL, fs->defaultglob); 254 init_exp(var, VLOCAL, fs->defaultglob);
261 k = VGLOBAL; /* now there is a declaration */ 255 k = VGLOBAL; /* now there is a declaration */
262 } 256 }
@@ -479,7 +473,7 @@ static void funcargs (LexState *ls, expdesc *f) {
479 switch (ls->t.token) { 473 switch (ls->t.token) {
480 case '(': { /* funcargs -> `(' [ explist1 ] `)' */ 474 case '(': { /* funcargs -> `(' [ explist1 ] `)' */
481 if (line != ls->lastline) 475 if (line != ls->lastline)
482 luaK_error(ls, "ambiguous syntax (function call x new statement)"); 476 luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)");
483 next(ls); 477 next(ls);
484 if (ls->t.token == ')') /* arg list is empty? */ 478 if (ls->t.token == ')') /* arg list is empty? */
485 args.k = VVOID; 479 args.k = VVOID;
@@ -500,7 +494,7 @@ static void funcargs (LexState *ls, expdesc *f) {
500 break; 494 break;
501 } 495 }
502 default: { 496 default: {
503 luaK_error(ls, "function arguments expected"); 497 luaX_syntaxerror(ls, "function arguments expected");
504 return; 498 return;
505 } 499 }
506 } 500 }
@@ -657,9 +651,10 @@ static void prefixexp (LexState *ls, expdesc *v) {
657 /* prefixexp -> NAME | '(' expr ')' */ 651 /* prefixexp -> NAME | '(' expr ')' */
658 switch (ls->t.token) { 652 switch (ls->t.token) {
659 case '(': { 653 case '(': {
654 int line = ls->linenumber;
660 next(ls); 655 next(ls);
661 expr(ls, v); 656 expr(ls, v);
662 check(ls, ')'); 657 check_match(ls, ')', '(', line);
663 luaK_dischargevars(ls->fs, v); 658 luaK_dischargevars(ls->fs, v);
664 return; 659 return;
665 } 660 }
@@ -676,7 +671,7 @@ static void prefixexp (LexState *ls, expdesc *v) {
676 return; 671 return;
677 } 672 }
678 default: { 673 default: {
679 luaK_error(ls, "unexpected symbol"); 674 luaX_syntaxerror(ls, "unexpected symbol");
680 return; 675 return;
681 } 676 }
682 } 677 }
@@ -1070,7 +1065,7 @@ static void forstat (LexState *ls, int line) {
1070 switch (ls->t.token) { 1065 switch (ls->t.token) {
1071 case '=': fornum(ls, varname, line); break; 1066 case '=': fornum(ls, varname, line); break;
1072 case ',': case TK_IN: forlist(ls, varname); break; 1067 case ',': case TK_IN: forlist(ls, varname); break;
1073 default: luaK_error(ls, "`=' or `in' expected"); 1068 default: luaX_syntaxerror(ls, "`=' or `in' expected");
1074 } 1069 }
1075 check_match(ls, TK_END, TK_FOR, line); 1070 check_match(ls, TK_END, TK_FOR, line);
1076 leaveblock(fs); 1071 leaveblock(fs);
@@ -1245,7 +1240,7 @@ static void breakstat (LexState *ls) {
1245 bl = bl->previous; 1240 bl = bl->previous;
1246 } 1241 }
1247 if (!bl) 1242 if (!bl)
1248 luaK_error(ls, "no loop to break"); 1243 luaX_syntaxerror(ls, "no loop to break");
1249 if (upval) 1244 if (upval)
1250 luaK_codeABC(fs, OP_CLOSE, bl->nactloc, 0, 0); 1245 luaK_codeABC(fs, OP_CLOSE, bl->nactloc, 0, 0);
1251 luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); 1246 luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
@@ -1314,7 +1309,7 @@ static void parlist (LexState *ls) {
1314 switch (ls->t.token) { 1309 switch (ls->t.token) {
1315 case TK_DOTS: dots = 1; break; 1310 case TK_DOTS: dots = 1; break;
1316 case TK_NAME: new_localvar(ls, str_checkname(ls), nparams++); break; 1311 case TK_NAME: new_localvar(ls, str_checkname(ls), nparams++); break;
1317 default: luaK_error(ls, "<name> or `...' expected"); 1312 default: luaX_syntaxerror(ls, "<name> or `...' expected");
1318 } 1313 }
1319 next(ls); 1314 next(ls);
1320 } while (!dots && optional(ls, ',')); 1315 } while (!dots && optional(ls, ','));
diff --git a/lstate.c b/lstate.c
index bb568aa0..372dcc17 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 1.91 2002/04/23 15:04:39 roberto Exp roberto $ 2** $Id: lstate.c,v 1.92 2002/05/01 20:40:42 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -30,7 +30,7 @@ static void close_state (lua_State *L);
30** call `lua_setpanicf' 30** call `lua_setpanicf'
31*/ 31*/
32static int default_panic (lua_State *L) { 32static int default_panic (lua_State *L) {
33 fprintf(stderr, "unable to recover; exiting\n"); 33 fputs("unable to recover; exiting\n", stderr);
34 return 0; 34 return 0;
35} 35}
36 36
diff --git a/lua.h b/lua.h
index 47f50f1f..ba2069e7 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.130 2002/05/01 20:48:12 roberto Exp roberto $ 2** $Id: lua.h,v 1.131 2002/05/06 19:05:10 roberto Exp roberto $
3** Lua - An Extensible Extension Language 3** Lua - An Extensible Extension Language
4** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil 4** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
5** e-mail: info@lua.org 5** e-mail: info@lua.org
@@ -12,6 +12,9 @@
12#define lua_h 12#define lua_h
13 13
14 14
15/* definition of `va_list' */
16#include <stdarg.h>
17
15/* definition of `size_t' */ 18/* definition of `size_t' */
16#include <stddef.h> 19#include <stddef.h>
17 20
@@ -141,6 +144,7 @@ LUA_API void lua_pushnil (lua_State *L);
141LUA_API void lua_pushnumber (lua_State *L, lua_Number n); 144LUA_API void lua_pushnumber (lua_State *L, lua_Number n);
142LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len); 145LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len);
143LUA_API void lua_pushstring (lua_State *L, const char *s); 146LUA_API void lua_pushstring (lua_State *L, const char *s);
147LUA_API void lua_vpushstr (lua_State *L, const char *fmt, va_list argp);
144LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); 148LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
145LUA_API void lua_pushboolean (lua_State *L, int b); 149LUA_API void lua_pushboolean (lua_State *L, int b);
146LUA_API void lua_pushudataval (lua_State *L, void *p); 150LUA_API void lua_pushudataval (lua_State *L, void *p);
diff --git a/lundump.c b/lundump.c
index 6b2bb759..b9b7b505 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 1.44 2001/11/28 20:13:13 roberto Exp roberto $ 2** $Id: lundump.c,v 1.45 2002/03/25 17:47:14 roberto Exp roberto $
3** load pre-compiled Lua chunks 3** load pre-compiled Lua chunks
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -27,7 +27,7 @@ static const char* ZNAME (ZIO* Z)
27 27
28static void unexpectedEOZ (lua_State* L, ZIO* Z) 28static void unexpectedEOZ (lua_State* L, ZIO* Z)
29{ 29{
30 luaO_verror(L,"unexpected end of file in `%.99s'",ZNAME(Z)); 30 luaO_verror(L,"unexpected end of file in `%s'",ZNAME(Z));
31} 31}
32 32
33static int ezgetc (lua_State* L, ZIO* Z) 33static int ezgetc (lua_State* L, ZIO* Z)
@@ -157,7 +157,7 @@ static void LoadConstants (lua_State* L, Proto* f, ZIO* Z, int swap)
157 tsvalue(o)=LoadString(L,Z,swap); 157 tsvalue(o)=LoadString(L,Z,swap);
158 break; 158 break;
159 default: 159 default:
160 luaO_verror(L,"bad constant type (%d) in `%.99s'",ttype(o),ZNAME(Z)); 160 luaO_verror(L,"bad constant type (%d) in `%s'",ttype(o),ZNAME(Z));
161 break; 161 break;
162 } 162 }
163 } 163 }
@@ -181,7 +181,7 @@ static Proto* LoadFunction (lua_State* L, TString* p, ZIO* Z, int swap)
181 LoadConstants(L,f,Z,swap); 181 LoadConstants(L,f,Z,swap);
182 LoadCode(L,f,Z,swap); 182 LoadCode(L,f,Z,swap);
183#ifndef TRUST_BINARIES 183#ifndef TRUST_BINARIES
184 if (!luaG_checkcode(f)) luaO_verror(L,"bad code in `%.99s'",ZNAME(Z)); 184 if (!luaG_checkcode(f)) luaO_verror(L,"bad code in `%s'",ZNAME(Z));
185#endif 185#endif
186 return f; 186 return f;
187} 187}
@@ -191,14 +191,14 @@ static void LoadSignature (lua_State* L, ZIO* Z)
191 const char* s=LUA_SIGNATURE; 191 const char* s=LUA_SIGNATURE;
192 while (*s!=0 && ezgetc(L,Z)==*s) 192 while (*s!=0 && ezgetc(L,Z)==*s)
193 ++s; 193 ++s;
194 if (*s!=0) luaO_verror(L,"bad signature in `%.99s'",ZNAME(Z)); 194 if (*s!=0) luaO_verror(L,"bad signature in `%s'",ZNAME(Z));
195} 195}
196 196
197static void TestSize (lua_State* L, int s, const char* what, ZIO* Z) 197static void TestSize (lua_State* L, int s, const char* what, ZIO* Z)
198{ 198{
199 int r=LoadByte(L,Z); 199 int r=LoadByte(L,Z);
200 if (r!=s) 200 if (r!=s)
201 luaO_verror(L,"virtual machine mismatch in `%.99s':\n" 201 luaO_verror(L,"virtual machine mismatch in `%s':\n"
202 " size of %.20s is %d but read %d",ZNAME(Z),what,s,r); 202 " size of %.20s is %d but read %d",ZNAME(Z),what,s,r);
203} 203}
204 204
@@ -212,11 +212,11 @@ static int LoadHeader (lua_State* L, ZIO* Z)
212 LoadSignature(L,Z); 212 LoadSignature(L,Z);
213 version=LoadByte(L,Z); 213 version=LoadByte(L,Z);
214 if (version>VERSION) 214 if (version>VERSION)
215 luaO_verror(L,"`%.99s' too new:\n" 215 luaO_verror(L,"`%s' too new:\n"
216 " read version %d.%d; expected at most %d.%d", 216 " read version %d.%d; expected at most %d.%d",
217 ZNAME(Z),V(version),V(VERSION)); 217 ZNAME(Z),V(version),V(VERSION));
218 if (version<VERSION0) /* check last major change */ 218 if (version<VERSION0) /* check last major change */
219 luaO_verror(L,"`%.99s' too old:\n" 219 luaO_verror(L,"`%s' too old:\n"
220 " read version %d.%d; expected at least %d.%d", 220 " read version %d.%d; expected at least %d.%d",
221 ZNAME(Z),V(version),V(VERSION)); 221 ZNAME(Z),V(version),V(VERSION));
222 swap=(luaU_endianness()!=LoadByte(L,Z)); /* need to swap bytes? */ 222 swap=(luaU_endianness()!=LoadByte(L,Z)); /* need to swap bytes? */
@@ -230,7 +230,7 @@ static int LoadHeader (lua_State* L, ZIO* Z)
230 TESTSIZE(sizeof(lua_Number), "number"); 230 TESTSIZE(sizeof(lua_Number), "number");
231 x=LoadNumber(L,Z,swap); 231 x=LoadNumber(L,Z,swap);
232 if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */ 232 if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */
233 luaO_verror(L,"unknown number format in `%.99s':\n" 233 luaO_verror(L,"unknown number format in `%s':\n"
234 " read " LUA_NUMBER_FMT "; expected " LUA_NUMBER_FMT, 234 " read " LUA_NUMBER_FMT "; expected " LUA_NUMBER_FMT,
235 ZNAME(Z),x,tx); 235 ZNAME(Z),x,tx);
236 return swap; 236 return swap;
@@ -248,7 +248,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z)
248{ 248{
249 Proto* f=LoadChunk(L,Z); 249 Proto* f=LoadChunk(L,Z);
250 if (zgetc(Z)!=EOZ) 250 if (zgetc(Z)!=EOZ)
251 luaO_verror(L,"`%.99s' apparently contains more than one chunk",ZNAME(Z)); 251 luaO_verror(L,"`%s' apparently contains more than one chunk",ZNAME(Z));
252 return f; 252 return f;
253} 253}
254 254