aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 01091602..16f84ec4 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.95 2002/08/06 18:01:50 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.96 2002/08/06 18:54:18 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*/
@@ -75,7 +75,16 @@ static int luaB_tonumber (lua_State *L) {
75 75
76 76
77static int luaB_error (lua_State *L) { 77static int luaB_error (lua_State *L) {
78 int level = luaL_opt_int(L, 2, 1);
78 luaL_check_any(L, 1); 79 luaL_check_any(L, 1);
80 if (!lua_isstring(L, 1) || level == 0)
81 lua_pushvalue(L, 1); /* propagate error mesage without changes */
82 else { /* add extra information */
83 luaL_where(L, level);
84 lua_pushvalue(L, 1);
85 lua_pushliteral(L, "\n");
86 lua_concat(L, 3);
87 }
79 return lua_error(L); 88 return lua_error(L);
80} 89}
81 90
@@ -285,7 +294,7 @@ static int luaB_unpack (lua_State *L) {
285 lua_rawget(L, 1); 294 lua_rawget(L, 1);
286 n = (lua_isnumber(L, -1)) ? (int)lua_tonumber(L, -1) : -1; 295 n = (lua_isnumber(L, -1)) ? (int)lua_tonumber(L, -1) : -1;
287 for (i=0; i<n || n==-1; i++) { /* push arg[1...n] */ 296 for (i=0; i<n || n==-1; i++) { /* push arg[1...n] */
288 luaL_check_stack(L, 1, "table too big to unpack"); 297 luaL_check_stack(L, LUA_MINSTACK, "table too big to unpack");
289 lua_rawgeti(L, 1, i+1); 298 lua_rawgeti(L, 1, i+1);
290 if (n == -1) { /* no explicit limit? */ 299 if (n == -1) { /* no explicit limit? */
291 if (lua_isnil(L, -1)) { /* stop at first `nil' element */ 300 if (lua_isnil(L, -1)) { /* stop at first `nil' element */