From c2bb9abceceef125554595e23b7cc18ad3555c7c Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 16 May 2005 18:19:00 -0300 Subject: better quotes for strings in error messages --- loadlib.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'loadlib.c') diff --git a/loadlib.c b/loadlib.c index d1de0e69..0545c328 100644 --- a/loadlib.c +++ b/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.25 2005/03/30 19:50:29 roberto Exp roberto $ +** $Id: loadlib.c,v 1.26 2005/04/13 17:24:20 roberto Exp roberto $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -191,7 +191,7 @@ static void *ll_load (lua_State *L, const char *path) { static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); if (nss == NULL) { - lua_pushfstring(L, "symbol `%s' not found", sym); + lua_pushfstring(L, "symbol " LUA_SM " not found", sym); return NULL; } return (lua_CFunction)NSAddressOfSymbol(nss); @@ -213,9 +213,9 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { #if defined(__ELF__) || defined(__sun) || defined(sgi) || defined(__hpux) -#define DLMSG "`loadlib' not enabled; check your Lua installation" +#define DLMSG "'loadlib' not enabled; check your Lua installation" #else -#define DLMSG "`loadlib' not supported" +#define DLMSG "'loadlib' not supported" #endif static void ll_unloadlib (void *lib) { @@ -327,11 +327,12 @@ static int loader_Lua (lua_State *L) { path = lua_tostring(L, -1); } if (path == NULL) - luaL_error(L, "`package.path' must be a string"); + luaL_error(L, LUA_SM " must be a string", "package.path"); fname = luaL_searchpath(L, fname, path); if (fname == NULL) return 0; /* library not found in this path */ if (luaL_loadfile(L, fname) != 0) - luaL_error(L, "error loading package `%s' (%s)", name, lua_tostring(L, -1)); + luaL_error(L, "error loading package " LUA_SM " (%s)", + name, lua_tostring(L, -1)); return 1; /* library loaded successfully */ } @@ -344,13 +345,14 @@ static int loader_C (lua_State *L) { lua_getfield(L, LUA_ENVIRONINDEX, "cpath"); path = lua_tostring(L, -1); if (path == NULL) - luaL_error(L, "`package.cpath' must be a string"); + luaL_error(L, LUA_SM " must be a string", "package.cpath"); fname = luaL_searchpath(L, fname, path); if (fname == NULL) return 0; /* library not found in this path */ funcname = luaL_gsub(L, name, ".", LUA_OFSEP); funcname = lua_pushfstring(L, "%s%s", POF, funcname); if (ll_loadfunc(L, fname, funcname) != 1) - luaL_error(L, "error loading package `%s' (%s)", name, lua_tostring(L, -2)); + luaL_error(L, "error loading package " LUA_SM " (%s)", + name, lua_tostring(L, -2)); return 1; /* library loaded successfully */ } @@ -358,7 +360,7 @@ static int loader_C (lua_State *L) { static int loader_preload (lua_State *L) { lua_getfield(L, LUA_ENVIRONINDEX, "preload"); if (!lua_istable(L, -1)) - luaL_error(L, "`package.preload' must be a table"); + luaL_error(L, LUA_SM " must be a table", "package.preload"); lua_getfield(L, -1, luaL_checkstring(L, 1)); return 1; } @@ -378,11 +380,11 @@ static int ll_require (lua_State *L) { /* iterate over available loaders */ lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); if (!lua_istable(L, -1)) - luaL_error(L, "`package.loaders' must be a table"); + luaL_error(L, LUA_SM " must be a table", "package.loaders"); for (i=1;; i++) { lua_rawgeti(L, -1, i); /* get a loader */ if (lua_isnil(L, -1)) - return luaL_error(L, "package `%s' not found", name); + return luaL_error(L, "package " LUA_SM " not found", name); lua_pushstring(L, name); lua_call(L, 1, 1); /* call it */ if (lua_isnil(L, -1)) lua_pop(L, 1); @@ -421,7 +423,7 @@ static int ll_module (lua_State *L) { luaL_setfield(L, LUA_GLOBALSINDEX, modname); } else if (!lua_istable(L, -1)) - return luaL_error(L, "name conflict for module `%s'", modname); + return luaL_error(L, "name conflict for module " LUA_SM, modname); /* check whether table already has a _NAME field */ lua_getfield(L, -1, "_NAME"); if (!lua_isnil(L, -1)) /* is table an initialized module? */ -- cgit v1.2.3-55-g6feb