diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-17 16:49:15 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-17 16:49:15 -0300 |
| commit | 67578ec51f1a3ec2c967f15d370067caf9e0b87b (patch) | |
| tree | d77b292ddec33d7e6987bae808fa1db250ebd830 /loadlib.c | |
| parent | c2bb9abceceef125554595e23b7cc18ad3555c7c (diff) | |
| download | lua-67578ec51f1a3ec2c967f15d370067caf9e0b87b.tar.gz lua-67578ec51f1a3ec2c967f15d370067caf9e0b87b.tar.bz2 lua-67578ec51f1a3ec2c967f15d370067caf9e0b87b.zip | |
several small details
Diffstat (limited to 'loadlib.c')
| -rw-r--r-- | loadlib.c | 24 |
1 files changed, 12 insertions, 12 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: loadlib.c,v 1.26 2005/04/13 17:24:20 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.27 2005/05/16 21:19:00 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 | ** |
| @@ -191,7 +191,7 @@ static void *ll_load (lua_State *L, const char *path) { | |||
| 191 | static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { | 191 | static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { |
| 192 | NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); | 192 | NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); |
| 193 | if (nss == NULL) { | 193 | if (nss == NULL) { |
| 194 | lua_pushfstring(L, "symbol " LUA_SM " not found", sym); | 194 | lua_pushfstring(L, "symbol " LUA_QS " not found", sym); |
| 195 | return NULL; | 195 | return NULL; |
| 196 | } | 196 | } |
| 197 | return (lua_CFunction)NSAddressOfSymbol(nss); | 197 | return (lua_CFunction)NSAddressOfSymbol(nss); |
| @@ -213,9 +213,9 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { | |||
| 213 | 213 | ||
| 214 | 214 | ||
| 215 | #if defined(__ELF__) || defined(__sun) || defined(sgi) || defined(__hpux) | 215 | #if defined(__ELF__) || defined(__sun) || defined(sgi) || defined(__hpux) |
| 216 | #define DLMSG "'loadlib' not enabled; check your Lua installation" | 216 | #define DLMSG LUA_QL("loadlib") " not enabled; check your Lua installation" |
| 217 | #else | 217 | #else |
| 218 | #define DLMSG "'loadlib' not supported" | 218 | #define DLMSG LUA_QL("loadlib") " not supported" |
| 219 | #endif | 219 | #endif |
| 220 | 220 | ||
| 221 | static void ll_unloadlib (void *lib) { | 221 | static void ll_unloadlib (void *lib) { |
| @@ -327,11 +327,11 @@ static int loader_Lua (lua_State *L) { | |||
| 327 | path = lua_tostring(L, -1); | 327 | path = lua_tostring(L, -1); |
| 328 | } | 328 | } |
| 329 | if (path == NULL) | 329 | if (path == NULL) |
| 330 | luaL_error(L, LUA_SM " must be a string", "package.path"); | 330 | luaL_error(L, LUA_QL("package.path") " must be a string"); |
| 331 | fname = luaL_searchpath(L, fname, path); | 331 | fname = luaL_searchpath(L, fname, path); |
| 332 | if (fname == NULL) return 0; /* library not found in this path */ | 332 | if (fname == NULL) return 0; /* library not found in this path */ |
| 333 | if (luaL_loadfile(L, fname) != 0) | 333 | if (luaL_loadfile(L, fname) != 0) |
| 334 | luaL_error(L, "error loading package " LUA_SM " (%s)", | 334 | luaL_error(L, "error loading package " LUA_QS " (%s)", |
| 335 | name, lua_tostring(L, -1)); | 335 | name, lua_tostring(L, -1)); |
| 336 | return 1; /* library loaded successfully */ | 336 | return 1; /* library loaded successfully */ |
| 337 | } | 337 | } |
| @@ -345,13 +345,13 @@ static int loader_C (lua_State *L) { | |||
| 345 | lua_getfield(L, LUA_ENVIRONINDEX, "cpath"); | 345 | lua_getfield(L, LUA_ENVIRONINDEX, "cpath"); |
| 346 | path = lua_tostring(L, -1); | 346 | path = lua_tostring(L, -1); |
| 347 | if (path == NULL) | 347 | if (path == NULL) |
| 348 | luaL_error(L, LUA_SM " must be a string", "package.cpath"); | 348 | luaL_error(L, LUA_QL("package.cpath") " must be a string"); |
| 349 | fname = luaL_searchpath(L, fname, path); | 349 | fname = luaL_searchpath(L, fname, path); |
| 350 | if (fname == NULL) return 0; /* library not found in this path */ | 350 | if (fname == NULL) return 0; /* library not found in this path */ |
| 351 | funcname = luaL_gsub(L, name, ".", LUA_OFSEP); | 351 | funcname = luaL_gsub(L, name, ".", LUA_OFSEP); |
| 352 | funcname = lua_pushfstring(L, "%s%s", POF, funcname); | 352 | funcname = lua_pushfstring(L, "%s%s", POF, funcname); |
| 353 | if (ll_loadfunc(L, fname, funcname) != 1) | 353 | if (ll_loadfunc(L, fname, funcname) != 1) |
| 354 | luaL_error(L, "error loading package " LUA_SM " (%s)", | 354 | luaL_error(L, "error loading package " LUA_QS " (%s)", |
| 355 | name, lua_tostring(L, -2)); | 355 | name, lua_tostring(L, -2)); |
| 356 | return 1; /* library loaded successfully */ | 356 | return 1; /* library loaded successfully */ |
| 357 | } | 357 | } |
| @@ -360,7 +360,7 @@ static int loader_C (lua_State *L) { | |||
| 360 | static int loader_preload (lua_State *L) { | 360 | static int loader_preload (lua_State *L) { |
| 361 | lua_getfield(L, LUA_ENVIRONINDEX, "preload"); | 361 | lua_getfield(L, LUA_ENVIRONINDEX, "preload"); |
| 362 | if (!lua_istable(L, -1)) | 362 | if (!lua_istable(L, -1)) |
| 363 | luaL_error(L, LUA_SM " must be a table", "package.preload"); | 363 | luaL_error(L, LUA_QL("package.preload") " must be a table"); |
| 364 | lua_getfield(L, -1, luaL_checkstring(L, 1)); | 364 | lua_getfield(L, -1, luaL_checkstring(L, 1)); |
| 365 | return 1; | 365 | return 1; |
| 366 | } | 366 | } |
| @@ -380,11 +380,11 @@ static int ll_require (lua_State *L) { | |||
| 380 | /* iterate over available loaders */ | 380 | /* iterate over available loaders */ |
| 381 | lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); | 381 | lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); |
| 382 | if (!lua_istable(L, -1)) | 382 | if (!lua_istable(L, -1)) |
| 383 | luaL_error(L, LUA_SM " must be a table", "package.loaders"); | 383 | luaL_error(L, LUA_QL("package.loaders") " must be a table"); |
| 384 | for (i=1;; i++) { | 384 | for (i=1;; i++) { |
| 385 | lua_rawgeti(L, -1, i); /* get a loader */ | 385 | lua_rawgeti(L, -1, i); /* get a loader */ |
| 386 | if (lua_isnil(L, -1)) | 386 | if (lua_isnil(L, -1)) |
| 387 | return luaL_error(L, "package " LUA_SM " not found", name); | 387 | return luaL_error(L, "package " LUA_QS " not found", name); |
| 388 | lua_pushstring(L, name); | 388 | lua_pushstring(L, name); |
| 389 | lua_call(L, 1, 1); /* call it */ | 389 | lua_call(L, 1, 1); /* call it */ |
| 390 | if (lua_isnil(L, -1)) lua_pop(L, 1); | 390 | if (lua_isnil(L, -1)) lua_pop(L, 1); |
| @@ -423,7 +423,7 @@ static int ll_module (lua_State *L) { | |||
| 423 | luaL_setfield(L, LUA_GLOBALSINDEX, modname); | 423 | luaL_setfield(L, LUA_GLOBALSINDEX, modname); |
| 424 | } | 424 | } |
| 425 | else if (!lua_istable(L, -1)) | 425 | else if (!lua_istable(L, -1)) |
| 426 | return luaL_error(L, "name conflict for module " LUA_SM, modname); | 426 | return luaL_error(L, "name conflict for module " LUA_QS, modname); |
| 427 | /* check whether table already has a _NAME field */ | 427 | /* check whether table already has a _NAME field */ |
| 428 | lua_getfield(L, -1, "_NAME"); | 428 | lua_getfield(L, -1, "_NAME"); |
| 429 | if (!lua_isnil(L, -1)) /* is table an initialized module? */ | 429 | if (!lua_isnil(L, -1)) /* is table an initialized module? */ |
