aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lbaselib.c b/lbaselib.c
index bb66ab32..8f53a0d9 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -216,10 +216,8 @@ static int luaB_type (lua_State *L) {
216 if (lua_isnull(L, 2)) 216 if (lua_isnull(L, 2))
217 lua_pushstring(L, lua_typename(L, lua_type(L, 1))); 217 lua_pushstring(L, lua_typename(L, lua_type(L, 1)));
218 else { 218 else {
219 if (strcmp(lua_typename(L, lua_type(L, 1)), luaL_check_string(L, 2)) == 0) 219 lua_pushboolean(L,
220 lua_pushnumber(L, 1); 220 (strcmp(lua_typename(L, lua_type(L, 1)), luaL_check_string(L, 2)) == 0));
221 else
222 lua_pushnil(L);
223 } 221 }
224 return 1; 222 return 1;
225} 223}
@@ -401,8 +399,12 @@ static int luaB_tostring (lua_State *L) {
401 case LUA_TSTRING: 399 case LUA_TSTRING:
402 lua_pushvalue(L, 1); 400 lua_pushvalue(L, 1);
403 return 1; 401 return 1;
402 case LUA_TBOOLEAN:
403 lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false"));
404 return 1;
404 case LUA_TTABLE: 405 case LUA_TTABLE:
405 sprintf(buff, "%.40s: %p", lua_typename(L, lua_type(L, 1)), lua_topointer(L, 1)); 406 sprintf(buff, "%.40s: %p", lua_typename(L, lua_type(L, 1)),
407 lua_topointer(L, 1));
406 break; 408 break;
407 case LUA_TFUNCTION: 409 case LUA_TFUNCTION:
408 sprintf(buff, "function: %p", lua_topointer(L, 1)); 410 sprintf(buff, "function: %p", lua_topointer(L, 1));
@@ -464,9 +466,8 @@ static int luaB_foreach (lua_State *L) {
464 466
465static int luaB_assert (lua_State *L) { 467static int luaB_assert (lua_State *L) {
466 luaL_check_any(L, 1); 468 luaL_check_any(L, 1);
467 if (lua_isnil(L, 1)) 469 if (!lua_istrue(L, 1))
468 luaL_verror(L, "assertion failed! %.90s", 470 luaL_verror(L, "assertion failed! %.90s", luaL_opt_string(L, 2, ""));
469 luaL_opt_string(L, 2, ""));
470 lua_settop(L, 1); 471 lua_settop(L, 1);
471 return 1; 472 return 1;
472} 473}
@@ -542,7 +543,7 @@ static int sort_comp (lua_State *L, int a, int b) {
542 lua_pushvalue(L, a-1); /* -1 to compensate function */ 543 lua_pushvalue(L, a-1); /* -1 to compensate function */
543 lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ 544 lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
544 lua_rawcall(L, 2, 1); 545 lua_rawcall(L, 2, 1);
545 res = !lua_isnil(L, -1); 546 res = lua_istrue(L, -1);
546 lua_pop(L, 1); 547 lua_pop(L, 1);
547 return res; 548 return res;
548 } 549 }