diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-10-17 16:01:51 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-10-17 16:01:51 -0200 |
commit | 5511bf6b9d6018665f5c184c5a464bb8b0aceca5 (patch) | |
tree | 62f5c3e026c8f13ec0e899e27c1de783bf9e4cf1 | |
parent | 86704cffe938872bca8e911a37aa05a5549a29eb (diff) | |
download | lua-5511bf6b9d6018665f5c184c5a464bb8b0aceca5.tar.gz lua-5511bf6b9d6018665f5c184c5a464bb8b0aceca5.tar.bz2 lua-5511bf6b9d6018665f5c184c5a464bb8b0aceca5.zip |
avoid comparisons between (void *) and (int *)
-rw-r--r-- | loadlib.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loadlib.c,v 1.46 2005/10/03 14:36:45 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.47 2005/10/06 20:46:10 roberto Exp roberto $ |
3 | ** Dynamic library loader for Lua | 3 | ** Dynamic library loader for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | ** | 5 | ** |
@@ -442,7 +442,8 @@ static int loader_preload (lua_State *L) { | |||
442 | } | 442 | } |
443 | 443 | ||
444 | 444 | ||
445 | static const int sentinel = 0; | 445 | static const int sentinel_ = 0; |
446 | #define sentinel ((void *)&sentinel_) | ||
446 | 447 | ||
447 | 448 | ||
448 | static int ll_require (lua_State *L) { | 449 | static int ll_require (lua_State *L) { |
@@ -452,7 +453,7 @@ static int ll_require (lua_State *L) { | |||
452 | lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); | 453 | lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); |
453 | lua_getfield(L, 2, name); | 454 | lua_getfield(L, 2, name); |
454 | if (lua_toboolean(L, -1)) { /* is it there? */ | 455 | if (lua_toboolean(L, -1)) { /* is it there? */ |
455 | if (lua_touserdata(L, -1) == &sentinel) /* check loops */ | 456 | if (lua_touserdata(L, -1) == sentinel) /* check loops */ |
456 | luaL_error(L, "loop or previous error loading module " LUA_QS, name); | 457 | luaL_error(L, "loop or previous error loading module " LUA_QS, name); |
457 | return 1; /* package is already loaded */ | 458 | return 1; /* package is already loaded */ |
458 | } | 459 | } |
@@ -469,14 +470,14 @@ static int ll_require (lua_State *L) { | |||
469 | if (lua_isnil(L, -1)) lua_pop(L, 1); /* did not found module */ | 470 | if (lua_isnil(L, -1)) lua_pop(L, 1); /* did not found module */ |
470 | else break; /* module loaded successfully */ | 471 | else break; /* module loaded successfully */ |
471 | } | 472 | } |
472 | lua_pushlightuserdata(L, (void *)&sentinel); | 473 | lua_pushlightuserdata(L, sentinel); |
473 | lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ | 474 | lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ |
474 | lua_pushstring(L, name); /* pass name as argument to module */ | 475 | lua_pushstring(L, name); /* pass name as argument to module */ |
475 | lua_call(L, 1, 1); /* run loaded module */ | 476 | lua_call(L, 1, 1); /* run loaded module */ |
476 | if (!lua_isnil(L, -1)) /* non-nil return? */ | 477 | if (!lua_isnil(L, -1)) /* non-nil return? */ |
477 | lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ | 478 | lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ |
478 | lua_getfield(L, 2, name); | 479 | lua_getfield(L, 2, name); |
479 | if (lua_touserdata(L, -1) == &sentinel) { /* module did not set a value? */ | 480 | if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ |
480 | lua_pushboolean(L, 1); /* use true as result */ | 481 | lua_pushboolean(L, 1); /* use true as result */ |
481 | lua_pushvalue(L, -1); /* extra copy to be returned */ | 482 | lua_pushvalue(L, -1); /* extra copy to be returned */ |
482 | lua_setfield(L, 2, name); /* _LOADED[name] = true */ | 483 | lua_setfield(L, 2, name); /* _LOADED[name] = true */ |