aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lbaselib.c8
-rw-r--r--lua.c9
2 files changed, 7 insertions, 10 deletions
diff --git a/lbaselib.c b/lbaselib.c
index b552fa4b..2e04a9a4 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.134 2003/10/07 20:13:41 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.135 2003/10/10 12:57:55 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*/
@@ -78,10 +78,8 @@ static int luaB_tonumber (lua_State *L) {
78 78
79static int luaB_error (lua_State *L) { 79static int luaB_error (lua_State *L) {
80 int level = luaL_optint(L, 2, 1); 80 int level = luaL_optint(L, 2, 1);
81 luaL_checkany(L, 1); 81 lua_settop(L, 1);
82 if (!lua_isstring(L, 1) || level == 0) 82 if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
83 lua_pushvalue(L, 1); /* propagate error message without changes */
84 else { /* add extra information */
85 luaL_where(L, level); 83 luaL_where(L, level);
86 lua_pushvalue(L, 1); 84 lua_pushvalue(L, 1);
87 lua_concat(L, 2); 85 lua_concat(L, 2);
diff --git a/lua.c b/lua.c
index 761da8e7..7f0fc4ba 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.122 2003/04/03 13:34:42 roberto Exp roberto $ 2** $Id: lua.c,v 1.123 2003/05/07 16:02:16 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*/
@@ -117,10 +117,9 @@ static void l_message (const char *pname, const char *msg) {
117 117
118 118
119static int report (int status) { 119static int report (int status) {
120 const char *msg; 120 if (status && !lua_isnil(L, -1)) {
121 if (status) { 121 const char *msg = lua_tostring(L, -1);
122 msg = lua_tostring(L, -1); 122 if (msg == NULL) msg = "(error object is not a string)";
123 if (msg == NULL) msg = "(error with no message)";
124 l_message(progname, msg); 123 l_message(progname, msg);
125 lua_pop(L, 1); 124 lua_pop(L, 1);
126 } 125 }