aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-09 11:50:08 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-09 11:50:08 -0200
commit80b3d28f4a9e518bf40b35f786199919180bfcd4 (patch)
treee25a410ba61883244207e25b16a853991b417ebb
parent69d97712ecfcd06aa4edb7374b262131210d0bbc (diff)
downloadlua-80b3d28f4a9e518bf40b35f786199919180bfcd4.tar.gz
lua-80b3d28f4a9e518bf40b35f786199919180bfcd4.tar.bz2
lua-80b3d28f4a9e518bf40b35f786199919180bfcd4.zip
details (mainly error messages)
-rw-r--r--lapi.c6
-rw-r--r--lauxlib.c17
-rw-r--r--lauxlib.h4
-rw-r--r--lbuiltin.c39
-rw-r--r--ldo.c5
-rw-r--r--lfunc.c10
-rw-r--r--lgc.c3
-rw-r--r--liolib.c8
-rw-r--r--llex.c8
-rw-r--r--lmathlib.c25
-rw-r--r--lstring.c6
-rw-r--r--lstrlib.c8
-rw-r--r--ltable.c4
-rw-r--r--lua.h8
-rw-r--r--lua.stx24
-rw-r--r--lvm.c6
16 files changed, 89 insertions, 92 deletions
diff --git a/lapi.c b/lapi.c
index b813d73d..63409950 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.10 1997/11/27 18:25:14 roberto Exp roberto $ 2** $Id: lapi.c,v 1.11 1997/11/28 16:56:05 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*/
@@ -142,7 +142,7 @@ lua_Object lua_rawgettable (void)
142{ 142{
143 checkCparams(2); 143 checkCparams(2);
144 if (ttype(L->stack.top-2) != LUA_T_ARRAY) 144 if (ttype(L->stack.top-2) != LUA_T_ARRAY)
145 lua_error("indexed expression not a table in raw gettable"); 145 lua_error("indexed expression not a table in rawgettable");
146 else { 146 else {
147 TObject *h = luaH_get(avalue(L->stack.top-2), L->stack.top-1); 147 TObject *h = luaH_get(avalue(L->stack.top-2), L->stack.top-1);
148 --L->stack.top; 148 --L->stack.top;
@@ -490,7 +490,7 @@ char *lua_getobjname (lua_Object o, char **name)
490void lua_beginblock (void) 490void lua_beginblock (void)
491{ 491{
492 if (L->numCblocks >= MAX_C_BLOCKS) 492 if (L->numCblocks >= MAX_C_BLOCKS)
493 lua_error("`lua_beginblock': too many nested blocks"); 493 lua_error("too many nested blocks");
494 L->Cblocks[L->numCblocks] = L->Cstack; 494 L->Cblocks[L->numCblocks] = L->Cstack;
495 L->numCblocks++; 495 L->numCblocks++;
496} 496}
diff --git a/lauxlib.c b/lauxlib.c
index 85bb04ac..ed893f70 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.3 1997/11/04 15:27:53 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.4 1997/11/21 19:00:46 roberto Exp roberto $
3** Auxiliar functions for building Lua libraries 3** Auxiliar functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -55,6 +55,21 @@ double luaL_opt_number (int numArg, double def)
55{ 55{
56 return (lua_getparam(numArg) == LUA_NOOBJECT) ? def : 56 return (lua_getparam(numArg) == LUA_NOOBJECT) ? def :
57 luaL_check_number(numArg); 57 luaL_check_number(numArg);
58}
59
60
61lua_Object luaL_tablearg (int arg)
62{
63 lua_Object o = lua_getparam(arg);
64 luaL_arg_check(lua_istable(o), arg, "table expected");
65 return o;
66}
67
68lua_Object luaL_functionarg (int arg)
69{
70 lua_Object o = lua_getparam(arg);
71 luaL_arg_check(lua_isfunction(o), arg, "function expected");
72 return o;
58} 73}
59 74
60lua_Object luaL_nonnullarg (int numArg) 75lua_Object luaL_nonnullarg (int numArg)
diff --git a/lauxlib.h b/lauxlib.h
index f1b59a3a..712c484c 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.2 1997/09/26 15:02:26 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.3 1997/11/21 19:00:46 roberto Exp roberto $
3** Auxiliar functions for building Lua libraries 3** Auxiliar functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -23,6 +23,8 @@ char *luaL_check_string (int numArg);
23char *luaL_opt_string (int numArg, char *def); 23char *luaL_opt_string (int numArg, char *def);
24double luaL_check_number (int numArg); 24double luaL_check_number (int numArg);
25double luaL_opt_number (int numArg, double def); 25double luaL_opt_number (int numArg, double def);
26lua_Object luaL_functionarg (int arg);
27lua_Object luaL_tablearg (int arg);
26lua_Object luaL_nonnullarg (int numArg); 28lua_Object luaL_nonnullarg (int numArg);
27void luaL_verror (char *fmt, ...); 29void luaL_verror (char *fmt, ...);
28 30
diff --git a/lbuiltin.c b/lbuiltin.c
index 5d6274c3..e48e1d5d 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.13 1997/11/28 12:39:45 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.14 1997/12/01 20:30:44 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*/
@@ -23,21 +23,6 @@
23 23
24 24
25 25
26static lua_Object tablearg (int arg)
27{
28 lua_Object o = lua_getparam(arg);
29 luaL_arg_check(lua_istable(o), arg, "table expected");
30 return o;
31}
32
33static lua_Object functionarg (int arg)
34{
35 lua_Object o = lua_getparam(arg);
36 luaL_arg_check(lua_isfunction(o), arg, "function expected");
37 return o;
38}
39
40
41static void pushstring (TaggedString *s) 26static void pushstring (TaggedString *s)
42{ 27{
43 TObject o; 28 TObject o;
@@ -71,7 +56,7 @@ static void nextvar (void)
71 56
72static void foreachvar (void) 57static void foreachvar (void)
73{ 58{
74 TObject f = *luaA_Address(functionarg(1)); 59 TObject f = *luaA_Address(luaL_functionarg(1));
75 GCnode *g; 60 GCnode *g;
76 StkId name = L->Cstack.base++; /* place to keep var name (to avoid GC) */ 61 StkId name = L->Cstack.base++; /* place to keep var name (to avoid GC) */
77 ttype(L->stack.stack+name) = LUA_T_NIL; 62 ttype(L->stack.stack+name) = LUA_T_NIL;
@@ -95,7 +80,7 @@ static void foreachvar (void)
95 80
96static void next (void) 81static void next (void)
97{ 82{
98 lua_Object o = tablearg(1); 83 lua_Object o = luaL_tablearg(1);
99 lua_Object r = luaL_nonnullarg(2); 84 lua_Object r = luaL_nonnullarg(2);
100 Node *n = luaH_next(luaA_Address(o), luaA_Address(r)); 85 Node *n = luaH_next(luaA_Address(o), luaA_Address(r));
101 if (n) { 86 if (n) {
@@ -107,8 +92,8 @@ static void next (void)
107 92
108static void foreach (void) 93static void foreach (void)
109{ 94{
110 TObject t = *luaA_Address(tablearg(1)); 95 TObject t = *luaA_Address(luaL_tablearg(1));
111 TObject f = *luaA_Address(functionarg(2)); 96 TObject f = *luaA_Address(luaL_functionarg(2));
112 int i; 97 int i;
113 for (i=0; i<avalue(&t)->nhash; i++) { 98 for (i=0; i<avalue(&t)->nhash; i++) {
114 Node *nd = &(avalue(&t)->node[i]); 99 Node *nd = &(avalue(&t)->node[i]);
@@ -165,7 +150,9 @@ static char *to_string (lua_Object obj)
165 } 150 }
166 case LUA_T_NIL: 151 case LUA_T_NIL:
167 return "nil"; 152 return "nil";
168 default: return "<unknown object>"; 153 default:
154 lua_error("internal error");
155 return NULL; /* to avoid warnings */
169 } 156 }
170} 157}
171 158
@@ -203,9 +190,7 @@ static void lua_obj2number (void)
203 190
204static void luaI_error (void) 191static void luaI_error (void)
205{ 192{
206 char *s = lua_getstring(lua_getparam(1)); 193 lua_error(lua_getstring(lua_getparam(1)));
207 if (s == NULL) s = "(no message)";
208 lua_error(s);
209} 194}
210 195
211 196
@@ -262,7 +247,7 @@ static int getnarg (lua_Object table)
262static void luaI_call (void) 247static void luaI_call (void)
263{ 248{
264 lua_Object f = luaL_nonnullarg(1); 249 lua_Object f = luaL_nonnullarg(1);
265 lua_Object arg = tablearg(2); 250 lua_Object arg = luaL_tablearg(2);
266 char *options = luaL_opt_string(3, ""); 251 char *options = luaL_opt_string(3, "");
267 lua_Object err = lua_getparam(4); 252 lua_Object err = lua_getparam(4);
268 int narg = getnarg(arg); 253 int narg = getnarg(arg);
@@ -302,7 +287,7 @@ static void luaI_call (void)
302 287
303static void settag (void) 288static void settag (void)
304{ 289{
305 lua_Object o = tablearg(1); 290 lua_Object o = luaL_tablearg(1);
306 lua_pushobject(o); 291 lua_pushobject(o);
307 lua_settag(luaL_check_number(2)); 292 lua_settag(luaL_check_number(2));
308} 293}
@@ -354,7 +339,7 @@ static void gettagmethod (void)
354 339
355static void seterrormethod (void) 340static void seterrormethod (void)
356{ 341{
357 lua_Object nf = functionarg(1); 342 lua_Object nf = luaL_functionarg(1);
358 lua_pushobject(nf); 343 lua_pushobject(nf);
359 lua_pushobject(lua_seterrormethod()); 344 lua_pushobject(lua_seterrormethod());
360} 345}
diff --git a/ldo.c b/ldo.c
index 4a37fe5d..f813922e 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.12 1997/11/26 20:44:52 roberto Exp roberto $ 2** $Id: ldo.c,v 1.13 1997/11/27 18:25:14 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*/
@@ -381,6 +381,7 @@ int lua_dofile (char *filename)
381 381
382 382
383#define SIZE_PREF 20 /* size of string prefix to appear in error messages */ 383#define SIZE_PREF 20 /* size of string prefix to appear in error messages */
384#define SSIZE_PREF "20"
384 385
385 386
386int lua_dostring (char *str) 387int lua_dostring (char *str)
@@ -390,7 +391,7 @@ int lua_dostring (char *str)
390 char *temp; 391 char *temp;
391 ZIO z; 392 ZIO z;
392 if (str == NULL) return 1; 393 if (str == NULL) return 1;
393 sprintf(buff, "(dostring) >> %.20s", str); 394 sprintf(buff, "(dostring) >> %." SSIZE_PREF "s", str);
394 temp = strchr(buff, '\n'); 395 temp = strchr(buff, '\n');
395 if (temp) *temp = 0; /* end string after first line */ 396 if (temp) *temp = 0; /* end string after first line */
396 luaZ_sopen(&z, str); 397 luaZ_sopen(&z, str);
diff --git a/lfunc.c b/lfunc.c
index 2ab76335..82f3407b 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,6 +1,6 @@
1/* 1/*
2** $Id: lfunc.c,v 1.5 1997/10/24 17:17:24 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.6 1997/11/19 17:29:23 roberto Exp roberto $
3** Lua Funcion auxiliar 3** Auxiliar functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
6 6
@@ -11,8 +11,8 @@
11#include "lmem.h" 11#include "lmem.h"
12#include "lstate.h" 12#include "lstate.h"
13 13
14#define gcsizeproto(p) 5 14#define gcsizeproto(p) 5 /* approximate "weight" for a prototype */
15#define gcsizeclosure(c) 1 15#define gcsizeclosure(c) 1 /* approximate "weight" for a closure */
16 16
17 17
18 18
@@ -83,7 +83,7 @@ void luaF_freeclosure (Closure *l)
83 83
84 84
85/* 85/*
86** Look for n-esim local variable at line "line" in function "func". 86** Look for n-th local variable at line "line" in function "func".
87** Returns NULL if not found. 87** Returns NULL if not found.
88*/ 88*/
89char *luaF_getlocalname (TProtoFunc *func, int local_number, int line) 89char *luaF_getlocalname (TProtoFunc *func, int local_number, int line)
diff --git a/lgc.c b/lgc.c
index 203e9d93..dac3b632 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.9 1997/11/27 15:59:25 roberto Exp roberto $ 2** $Id: lgc.c,v 1.10 1997/12/01 20:31:25 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -268,7 +268,6 @@ long lua_collectgarbage (long limit)
268 luaF_freeclosure(freeclos); 268 luaF_freeclosure(freeclos);
269 luaM_clearbuffer(); 269 luaM_clearbuffer();
270 recovered = recovered-L->nblocks; 270 recovered = recovered-L->nblocks;
271/*printf("==total %ld coletados %ld\n", L->nblocks+recovered, recovered);*/
272 L->GCthreshold = (limit == 0) ? 2*L->nblocks : L->nblocks+limit; 271 L->GCthreshold = (limit == 0) ? 2*L->nblocks : L->nblocks+limit;
273 return recovered; 272 return recovered;
274} 273}
diff --git a/liolib.c b/liolib.c
index 22668404..4befcfa6 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 1.7 1997/11/27 15:59:44 roberto Exp roberto $ 2** $Id: liolib.c,v 1.8 1997/11/28 12:40:37 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*/
@@ -28,7 +28,7 @@
28#define LC_MONETARY 0 28#define LC_MONETARY 0
29#define LC_NUMERIC 0 29#define LC_NUMERIC 0
30#define LC_TIME 0 30#define LC_TIME 0
31#define strerror(e) "O.S. is unable to define the error" 31#define strerror(e) "(no error message provided by operating system)"
32#endif 32#endif
33 33
34 34
@@ -72,7 +72,7 @@ static int ishandler (lua_Object f)
72{ 72{
73 if (lua_isuserdata(f)) { 73 if (lua_isuserdata(f)) {
74 if (lua_tag(f) == gettag(CLOSEDTAG)) 74 if (lua_tag(f) == gettag(CLOSEDTAG))
75 lua_error("trying to access a closed file"); 75 lua_error("cannot access a closed file");
76 return lua_tag(f) == gettag(IOTAG); 76 return lua_tag(f) == gettag(IOTAG);
77 } 77 }
78 else return 0; 78 else return 0;
@@ -82,7 +82,7 @@ static FILE *getfile (char *name)
82{ 82{
83 lua_Object f = lua_getglobal(name); 83 lua_Object f = lua_getglobal(name);
84 if (!ishandler(f)) 84 if (!ishandler(f))
85 luaL_verror("global variable %.50s is not a file handle", name); 85 luaL_verror("global variable `%.50s' is not a file handle", name);
86 return lua_getuserdata(f); 86 return lua_getuserdata(f);
87} 87}
88 88
diff --git a/llex.c b/llex.c
index 8f4553f9..9c8bcb3d 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.8 1997/11/21 19:00:46 roberto Exp roberto $ 2** $Id: llex.c,v 1.9 1997/12/02 12:43:54 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*/
@@ -166,7 +166,7 @@ static void inclinenumber (LexState *LS)
166 /* go through */ 166 /* go through */
167 case 5: /* if */ 167 case 5: /* if */
168 if (LS->iflevel == MAX_IFS-1) 168 if (LS->iflevel == MAX_IFS-1)
169 luaY_syntaxerror("too many nested `$ifs'", "$if"); 169 luaY_syntaxerror("too many nested $ifs", "$if");
170 readname(LS, buff); 170 readname(LS, buff);
171 LS->iflevel++; 171 LS->iflevel++;
172 LS->ifstate[LS->iflevel].elsepart = 0; 172 LS->ifstate[LS->iflevel].elsepart = 0;
@@ -181,7 +181,7 @@ static void inclinenumber (LexState *LS)
181 LS->ifstate[LS->iflevel].condition; 181 LS->ifstate[LS->iflevel].condition;
182 break; 182 break;
183 default: 183 default:
184 luaY_syntaxerror("invalid pragma", buff); 184 luaY_syntaxerror("unknown pragma", buff);
185 } 185 }
186 skipspace(LS); 186 skipspace(LS);
187 if (LS->current == '\n') /* pragma must end with a '\n' ... */ 187 if (LS->current == '\n') /* pragma must end with a '\n' ... */
@@ -414,7 +414,7 @@ int luaY_lex (YYSTYPE *l)
414 case EOZ: 414 case EOZ:
415 save(LS, 0); 415 save(LS, 0);
416 if (LS->iflevel > 0) 416 if (LS->iflevel > 0)
417 luaY_error("missing $endif"); 417 luaY_syntaxerror("input ends inside a $if", "");
418 return 0; 418 return 0;
419 419
420 default: 420 default:
diff --git a/lmathlib.c b/lmathlib.c
index cd28b1a1..13c74a0a 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.5 1997/11/19 18:16:33 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.6 1997/11/28 12:39:22 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*/
@@ -12,28 +12,15 @@
12#include "lua.h" 12#include "lua.h"
13#include "lualib.h" 13#include "lualib.h"
14 14
15#ifndef PI 15#ifdef M_PI
16#define PI M_PI
17#else
16#define PI ((double)3.14159265358979323846) 18#define PI ((double)3.14159265358979323846)
17#endif 19#endif
18 20
19 21
20 22#define FROMRAD(a) ((a)*(180.0/PI))
21#define FROMRAD(a) ((a)/torad()) 23#define TORAD(a) ((a)*(PI/180.0))
22#define TORAD(a) ((a)*torad())
23
24
25static double torad (void)
26{
27 char *s = luaL_opt_string(2, "d");
28 switch (*s) {
29 case 'd' : return PI/180.0;
30 case 'r' : return (double)1.0;
31 case 'g' : return PI/50.0;
32 default:
33 luaL_arg_check(0, 2, "invalid mode");
34 return 0; /* to avoid warnings */
35 }
36}
37 24
38 25
39static void math_abs (void) 26static void math_abs (void)
diff --git a/lstring.c b/lstring.c
index 6f3ba519..b750acfd 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,6 +1,6 @@
1/* 1/*
2** $Id: lstring.c,v 1.6 1997/11/21 19:00:46 roberto Exp roberto $ 2** $Id: lstring.c,v 1.7 1997/12/01 20:31:25 roberto Exp roberto $
3** String table (keep all strings handled by Lua) 3** String table (keeps all strings handled by Lua)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
6 6
@@ -17,7 +17,7 @@
17#define NUM_HASHS 61 17#define NUM_HASHS 61
18 18
19 19
20#define gcsizestring(l) (1+(l/64)) 20#define gcsizestring(l) (1+(l/64)) /* "weight" for a string with length 'l' */
21 21
22 22
23 23
diff --git a/lstrlib.c b/lstrlib.c
index cdd2ffe5..e5b87598 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.2 1997/11/26 18:53:45 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*/
@@ -283,7 +283,7 @@ static char *matchitem (char *s, char *p, int level, char **ep)
283 else if (*p == 'b') { /* balanced string */ 283 else if (*p == 'b') { /* balanced string */
284 p++; 284 p++;
285 if (*p == 0 || *(p+1) == 0) 285 if (*p == 0 || *(p+1) == 0)
286 lua_error("bad balanced pattern specification"); 286 lua_error("unbalanced pattern");
287 *ep = p+2; 287 *ep = p+2;
288 return matchbalance(s, *p, *(p+1)); 288 return matchbalance(s, *p, *(p+1));
289 } 289 }
@@ -484,7 +484,7 @@ static void str_format (void)
484 arg++; 484 arg++;
485 strncpy(form+1, initf, strfrmt-initf+1); /* +1 to include convertion */ 485 strncpy(form+1, initf, strfrmt-initf+1); /* +1 to include convertion */
486 form[strfrmt-initf+2] = 0; 486 form[strfrmt-initf+2] = 0;
487 buff = openspace(1000); /* to store the formated value */ 487 buff = openspace(1000); /* to store the formatted value */
488 switch (*strfrmt++) { 488 switch (*strfrmt++) {
489 case 'q': 489 case 'q':
490 luaI_addquoted(luaL_check_string(arg)); 490 luaI_addquoted(luaL_check_string(arg));
@@ -503,7 +503,7 @@ static void str_format (void)
503 sprintf(buff, form, luaL_check_number(arg)); 503 sprintf(buff, form, luaL_check_number(arg));
504 break; 504 break;
505 default: /* also treat cases 'pnLlh' */ 505 default: /* also treat cases 'pnLlh' */
506 lua_error("invalid format option in function `format'"); 506 lua_error("invalid option in `format'");
507 } 507 }
508 lbuffer.size += strlen(buff); 508 lbuffer.size += strlen(buff);
509 } 509 }
diff --git a/ltable.c b/ltable.c
index c5c1f714..270d1fa3 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.6 1997/11/19 17:29:23 roberto Exp roberto $ 2** $Id: ltable.c,v 1.7 1997/11/21 19:00:46 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -44,7 +44,7 @@ static long int hashindex (TObject *ref)
44 break; 44 break;
45 default: 45 default:
46 lua_error("unexpected type to index table"); 46 lua_error("unexpected type to index table");
47 h = 0; /* UNREACHEABLE */ 47 h = 0; /* to avoid warnings */
48 } 48 }
49 return (h >= 0 ? h : -(h+1)); 49 return (h >= 0 ? h : -(h+1));
50} 50}
diff --git a/lua.h b/lua.h
index 3cc871dc..a83826c9 100644
--- a/lua.h
+++ b/lua.h
@@ -1,13 +1,15 @@
1/* 1/*
2** $Id: lua.h,v 1.7 1997/11/27 18:25:14 roberto Exp roberto $ 2** $Id: lua.h,v 1.8 1997/12/01 20:31:25 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: lua@tecgraf.puc-rio.br 5** e-mail: lua@tecgraf.puc-rio.br
6** www: http://www.tecgraf.puc-rio.br/lua/
6*/ 7*/
7 8
8/********************************************************************* 9/*********************************************************************
9* Copyright © 1994-1996 TeCGraf, PUC-Rio. Written by Waldemar Ce­ 10* Copyright © 1994-1996 TeCGraf, PUC-Rio.
10* les Filho, Roberto Ierusalimschy and Luiz Henrique de Figueiredo. 11* Written by Waldemar Celes Filho, Roberto Ierusalimschy and
12* Luiz Henrique de Figueiredo.
11* All rights reserved. 13* All rights reserved.
12* 14*
13* Permission is hereby granted, without written agreement and with­ 15* Permission is hereby granted, without written agreement and with­
diff --git a/lua.stx b/lua.stx
index b1afe6b4..0b794fee 100644
--- a/lua.stx
+++ b/lua.stx
@@ -1,6 +1,6 @@
1%{ 1%{
2/* 2/*
3** $Id: lua.stx,v 1.19 1997/11/21 19:00:46 roberto Exp roberto $ 3** $Id: lua.stx,v 1.20 1997/12/02 12:43:54 roberto Exp roberto $
4** Syntax analizer and code generator 4** Syntax analizer and code generator
5** See Copyright Notice in lua.h 5** See Copyright Notice in lua.h
6*/ 6*/
@@ -26,6 +26,10 @@
26int luaY_parse (void); 26int luaY_parse (void);
27 27
28 28
29#define AMES_LIM(x) #x
30#define MES_LIM(x) "(limit=" AMES_LIM(x) ")"
31
32
29/* size of a "normal" jump instruction: OpCode + 1 byte */ 33/* size of a "normal" jump instruction: OpCode + 1 byte */
30#define JMPSIZE 2 34#define JMPSIZE 2
31 35
@@ -43,6 +47,8 @@ int luaY_parse (void);
43/* maximum number of upvalues */ 47/* maximum number of upvalues */
44#define MAXUPVALUES 16 48#define MAXUPVALUES 16
45 49
50
51
46/* 52/*
47** Variable descriptor: 53** Variable descriptor:
48** if 0<n<MINGLOBAL, represents local variable indexed by (n-1); 54** if 0<n<MINGLOBAL, represents local variable indexed by (n-1);
@@ -132,7 +138,7 @@ static void deltastack (int delta)
132 L->currState->stacksize += delta; 138 L->currState->stacksize += delta;
133 if (L->currState->stacksize > L->currState->maxstacksize) { 139 if (L->currState->stacksize > L->currState->maxstacksize) {
134 if (L->currState->stacksize > 255) 140 if (L->currState->stacksize > 255)
135 luaY_error("function/expression too complex (limit 256)"); 141 luaY_error("function/expression too complex");
136 L->currState->maxstacksize = L->currState->stacksize; 142 L->currState->maxstacksize = L->currState->stacksize;
137 } 143 }
138} 144}
@@ -156,7 +162,7 @@ static int code_oparg_at (int pc, OpCode op, int builtin, int arg, int delta)
156 L->currState->f->code[pc+2] = arg>>8; 162 L->currState->f->code[pc+2] = arg>>8;
157 return 3; 163 return 3;
158 } 164 }
159 else luaY_error("code too long (limit 64K)"); 165 else luaY_error("code too long " MES_LIM(64K));
160 return 0; /* to avoid warnings */ 166 return 0; /* to avoid warnings */
161} 167}
162 168
@@ -314,7 +320,7 @@ static void store_localvar (TaggedString *name, int n)
314 if (L->currState->nlocalvar+n < MAXLOCALS) 320 if (L->currState->nlocalvar+n < MAXLOCALS)
315 L->currState->localvar[L->currState->nlocalvar+n] = name; 321 L->currState->localvar[L->currState->nlocalvar+n] = name;
316 else 322 else
317 luaY_error("too many local variables (limit 32)"); 323 luaY_error("too many local variables " MES_LIM(MAXLOCALS));
318 luaI_registerlocalvar(name, L->lexstate->linenumber); 324 luaI_registerlocalvar(name, L->lexstate->linenumber);
319} 325}
320 326
@@ -341,7 +347,7 @@ static vardesc var2store (vardesc var)
341static void add_varbuffer (vardesc var, int n) 347static void add_varbuffer (vardesc var, int n)
342{ 348{
343 if (n >= MAXVAR) 349 if (n >= MAXVAR)
344 luaY_error("variable buffer overflow (limit 32)"); 350 luaY_error("variable buffer overflow " MES_LIM(MAXVAR));
345 L->currState->varbuffer[n] = var2store(var); 351 L->currState->varbuffer[n] = var2store(var);
346} 352}
347 353
@@ -379,7 +385,7 @@ static int indexupvalue (TaggedString *n)
379 } 385 }
380 /* new one */ 386 /* new one */
381 if (++(L->currState->nupvalues) > MAXUPVALUES) 387 if (++(L->currState->nupvalues) > MAXUPVALUES)
382 luaY_error("too many upvalues in a single function (limit 16)"); 388 luaY_error("too many upvalues in a single function " MES_LIM(MAXUPVALUES));
383 L->currState->upvalues[i] = v; /* i = L->currState->nupvalues - 1 */ 389 L->currState->upvalues[i] = v; /* i = L->currState->nupvalues - 1 */
384 return i; 390 return i;
385} 391}
@@ -493,7 +499,7 @@ static int lua_codestore (int i, int left)
493 } 499 }
494 else { /* indexed var with values in between*/ 500 else { /* indexed var with values in between*/
495 code_oparg(SETTABLE, 0, left+i, -1); 501 code_oparg(SETTABLE, 0, left+i, -1);
496 return left+2; /* table/index are not poped, since they are not on top */ 502 return left+2; /* table/index are not popped, since they are not on top */
497 } 503 }
498} 504}
499 505
@@ -580,7 +586,7 @@ static void init_state (TaggedString *filename)
580static void init_func (void) 586static void init_func (void)
581{ 587{
582 if (L->currState-L->mainState >= MAXSTATES-1) 588 if (L->currState-L->mainState >= MAXSTATES-1)
583 luaY_error("too many nested functions (limit 6)"); 589 luaY_error("too many nested functions " MES_LIM(MAXSTATES));
584 L->currState++; 590 L->currState++;
585 init_state(L->mainState->f->fileName); 591 init_state(L->mainState->f->fileName);
586 luaY_codedebugline(L->lexstate->linenumber); 592 luaY_codedebugline(L->lexstate->linenumber);
@@ -604,7 +610,7 @@ static TProtoFunc *close_func (void)
604 610
605 611
606/* 612/*
607** Parse LUA code. 613** Parse Lua code.
608*/ 614*/
609TProtoFunc *luaY_parser (ZIO *z, char *chunkname) 615TProtoFunc *luaY_parser (ZIO *z, char *chunkname)
610{ 616{
diff --git a/lvm.c b/lvm.c
index 0b6f68fa..bb3d9d8c 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.14 1997/11/19 17:29:23 roberto Exp roberto $ 2** $Id: lvm.c,v 1.15 1997/11/21 19:00:46 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -213,7 +213,7 @@ static void call_binTM (IMS event, char *msg)
213 213
214static void call_arith (IMS event) 214static void call_arith (IMS event)
215{ 215{
216 call_binTM(event, "unexpected type at arithmetic operation"); 216 call_binTM(event, "unexpected type in arithmetic operation");
217} 217}
218 218
219 219
@@ -229,7 +229,7 @@ static void comparison (lua_Type ttype_less, lua_Type ttype_equal,
229 else if (ttype(l) == LUA_T_STRING && ttype(r) == LUA_T_STRING) 229 else if (ttype(l) == LUA_T_STRING && ttype(r) == LUA_T_STRING)
230 result = strcoll(svalue(l), svalue(r)); 230 result = strcoll(svalue(l), svalue(r));
231 else { 231 else {
232 call_binTM(op, "unexpected type at comparison"); 232 call_binTM(op, "unexpected type in comparison");
233 return; 233 return;
234 } 234 }
235 S->top--; 235 S->top--;