diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-09 13:46:43 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-09 13:46:43 -0200 |
commit | 46b543ebef302ddb70cee59bb47ca542828de1d2 (patch) | |
tree | d18b1bd072a679d0805e5b75349a5a3596bc27b4 | |
parent | 79909a92e194ccf4bf34e045993b88c89154f3ad (diff) | |
download | lua-46b543ebef302ddb70cee59bb47ca542828de1d2.tar.gz lua-46b543ebef302ddb70cee59bb47ca542828de1d2.tar.bz2 lua-46b543ebef302ddb70cee59bb47ca542828de1d2.zip |
better treatment for errors inside _ERRORMETHOD
-rw-r--r-- | lbaselib.c | 5 | ||||
-rw-r--r-- | ldo.c | 7 | ||||
-rw-r--r-- | lua.c | 6 | ||||
-rw-r--r-- | lua.h | 3 |
4 files changed, 12 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.9 2000/10/05 12:14:08 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.10 2000/10/06 19:13:29 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -229,7 +229,8 @@ static int luaB_next (lua_State *L) { | |||
229 | 229 | ||
230 | static int passresults (lua_State *L, int status, int oldtop) { | 230 | static int passresults (lua_State *L, int status, int oldtop) { |
231 | static const char *const errornames[] = | 231 | static const char *const errornames[] = |
232 | {"ok", "run-time error", "file error", "syntax error", "memory error"}; | 232 | {"ok", "run-time error", "file error", "syntax error", |
233 | "memory error", "error in error handling"}; | ||
233 | if (status == 0) { | 234 | if (status == 0) { |
234 | int nresults = lua_gettop(L) - oldtop; | 235 | int nresults = lua_gettop(L) - oldtop; |
235 | if (nresults > 0) | 236 | if (nresults > 0) |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.104 2000/10/06 12:45:25 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.105 2000/10/09 13:47:32 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 | */ |
@@ -43,9 +43,8 @@ void luaD_init (lua_State *L, int stacksize) { | |||
43 | void luaD_checkstack (lua_State *L, int n) { | 43 | void luaD_checkstack (lua_State *L, int n) { |
44 | if (L->stack_last - L->top <= n) { /* stack overflow? */ | 44 | if (L->stack_last - L->top <= n) { /* stack overflow? */ |
45 | if (L->stack_last-L->stack > (L->stacksize-1)) { | 45 | if (L->stack_last-L->stack > (L->stacksize-1)) { |
46 | /* overflow while handling overflow: do what?? */ | 46 | /* overflow while handling overflow */ |
47 | L->top -= EXTRA_STACK; | 47 | luaD_breakrun(L, LUA_ERRERR); /* break run without error message */ |
48 | lua_error(L, "BAD STACK OVERFLOW! DATA CORRUPTED!"); | ||
49 | } | 48 | } |
50 | else { | 49 | else { |
51 | L->stack_last += EXTRA_STACK; /* to be used by error message */ | 50 | L->stack_last += EXTRA_STACK; /* to be used by error message */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.51 2000/09/11 19:42:57 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.52 2000/09/25 16:15:52 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 | */ |
@@ -91,10 +91,12 @@ static int ldo (int (*f)(lua_State *l, const char *), const char *name) { | |||
91 | res = f(L, name); /* dostring | dofile */ | 91 | res = f(L, name); /* dostring | dofile */ |
92 | lua_settop(L, top); /* remove eventual results */ | 92 | lua_settop(L, top); /* remove eventual results */ |
93 | signal(SIGINT, h); /* restore old action */ | 93 | signal(SIGINT, h); /* restore old action */ |
94 | /* Lua gives no message in such cases, so lua.c provides one */ | ||
94 | if (res == LUA_ERRMEM) { | 95 | if (res == LUA_ERRMEM) { |
95 | /* Lua gives no message in such case, so lua.c provides one */ | ||
96 | fprintf(stderr, "lua: memory allocation error\n"); | 96 | fprintf(stderr, "lua: memory allocation error\n"); |
97 | } | 97 | } |
98 | else if (res == LUA_ERRERR) | ||
99 | fprintf(stderr, "lua: error in error message\n"); | ||
98 | return res; | 100 | return res; |
99 | } | 101 | } |
100 | 102 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.72 2000/10/02 20:10:55 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.73 2000/10/05 12:14:08 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 |
@@ -41,6 +41,7 @@ | |||
41 | #define LUA_ERRFILE 2 | 41 | #define LUA_ERRFILE 2 |
42 | #define LUA_ERRSYNTAX 3 | 42 | #define LUA_ERRSYNTAX 3 |
43 | #define LUA_ERRMEM 4 | 43 | #define LUA_ERRMEM 4 |
44 | #define LUA_ERRERR 5 | ||
44 | 45 | ||
45 | 46 | ||
46 | typedef struct lua_State lua_State; | 47 | typedef struct lua_State lua_State; |