diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-06-02 00:06:26 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-06-02 00:06:26 -0300 |
commit | 9e68c047ae809608f53245e0e0f0b76f30b27c0f (patch) | |
tree | 618dd7a466f1018b7e26f2064fe7ead9e9d1a9ba /lbaselib.c | |
parent | e9d86eddf348fb8a9852782a4a4b17c594a5c556 (diff) | |
download | lua-9e68c047ae809608f53245e0e0f0b76f30b27c0f.tar.gz lua-9e68c047ae809608f53245e0e0f0b76f30b27c0f.tar.bz2 lua-9e68c047ae809608f53245e0e0f0b76f30b27c0f.zip |
'assert' does not assume that the error object is a string
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.286 2014/05/01 18:18:06 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.287 2014/05/16 18:54:01 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 | */ |
@@ -357,9 +357,14 @@ static int luaB_dofile (lua_State *L) { | |||
357 | 357 | ||
358 | 358 | ||
359 | static int luaB_assert (lua_State *L) { | 359 | static int luaB_assert (lua_State *L) { |
360 | if (!lua_toboolean(L, 1)) | 360 | if (lua_toboolean(L, 1)) /* condition is true? */ |
361 | return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); | 361 | return lua_gettop(L); /* return all arguments */ |
362 | return lua_gettop(L); | 362 | else { /* error */ |
363 | if (lua_isnone(L, 2)) /* no error message? */ | ||
364 | lua_pushliteral(L, "assertion failed!"); /* use standard message */ | ||
365 | lua_remove(L, 1); /* remove the condition (if there is one...) */ | ||
366 | return luaB_error(L); /* call 'error' */ | ||
367 | } | ||
363 | } | 368 | } |
364 | 369 | ||
365 | 370 | ||