commit 46b543ebef302ddb70cee59bb47ca542828de1d2
parent 79909a92e194ccf4bf34e045993b88c89154f3ad
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 9 Oct 2000 13:46:21 -0200
better treatment for errors inside _ERRORMETHOD
Diffstat:
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/lbaselib.c b/lbaselib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbaselib.c,v 1.9 2000/10/05 12:14:08 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.10 2000/10/06 19:13:29 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -229,7 +229,8 @@ static int luaB_next (lua_State *L) {
static int passresults (lua_State *L, int status, int oldtop) {
static const char *const errornames[] =
- {"ok", "run-time error", "file error", "syntax error", "memory error"};
+ {"ok", "run-time error", "file error", "syntax error",
+ "memory error", "error in error handling"};
if (status == 0) {
int nresults = lua_gettop(L) - oldtop;
if (nresults > 0)
diff --git a/ldo.c b/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 1.104 2000/10/06 12:45:25 roberto Exp roberto $
+** $Id: ldo.c,v 1.105 2000/10/09 13:47:32 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -43,9 +43,8 @@ void luaD_init (lua_State *L, int stacksize) {
void luaD_checkstack (lua_State *L, int n) {
if (L->stack_last - L->top <= n) { /* stack overflow? */
if (L->stack_last-L->stack > (L->stacksize-1)) {
- /* overflow while handling overflow: do what?? */
- L->top -= EXTRA_STACK;
- lua_error(L, "BAD STACK OVERFLOW! DATA CORRUPTED!");
+ /* overflow while handling overflow */
+ luaD_breakrun(L, LUA_ERRERR); /* break run without error message */
}
else {
L->stack_last += EXTRA_STACK; /* to be used by error message */
diff --git a/lua.c b/lua.c
@@ -1,5 +1,5 @@
/*
-** $Id: lua.c,v 1.51 2000/09/11 19:42:57 roberto Exp roberto $
+** $Id: lua.c,v 1.52 2000/09/25 16:15:52 roberto Exp roberto $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -91,10 +91,12 @@ static int ldo (int (*f)(lua_State *l, const char *), const char *name) {
res = f(L, name); /* dostring | dofile */
lua_settop(L, top); /* remove eventual results */
signal(SIGINT, h); /* restore old action */
+ /* Lua gives no message in such cases, so lua.c provides one */
if (res == LUA_ERRMEM) {
- /* Lua gives no message in such case, so lua.c provides one */
fprintf(stderr, "lua: memory allocation error\n");
}
+ else if (res == LUA_ERRERR)
+ fprintf(stderr, "lua: error in error message\n");
return res;
}
diff --git a/lua.h b/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.72 2000/10/02 20:10:55 roberto Exp roberto $
+** $Id: lua.h,v 1.73 2000/10/05 12:14:08 roberto Exp roberto $
** Lua - An Extensible Extension Language
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
** e-mail: lua@tecgraf.puc-rio.br
@@ -41,6 +41,7 @@
#define LUA_ERRFILE 2
#define LUA_ERRSYNTAX 3
#define LUA_ERRMEM 4
+#define LUA_ERRERR 5
typedef struct lua_State lua_State;