avoid some warnings

This commit is contained in:
Roberto Ierusalimschy 2005-10-06 17:46:10 -03:00
parent 37b49aa451
commit 522481a788
1 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/* /*
** $Id: loadlib.c,v 1.45 2005/09/30 13:50:05 roberto Exp roberto $ ** $Id: loadlib.c,v 1.46 2005/10/03 14:36:45 roberto Exp roberto $
** Dynamic library loader for Lua ** Dynamic library loader for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
** **
@ -97,16 +97,18 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
#undef setprogdir #undef setprogdir
void setprogdir (lua_State *L) { static void setprogdir (lua_State *L) {
char buff[MAX_PATH + 1]; char buff[MAX_PATH + 1];
char *lb; char *lb;
DWORD nsize = sizeof(buff)/sizeof(char); DWORD nsize = sizeof(buff)/sizeof(char);
DWORD n = GetModuleFileName(NULL, buff, nsize); DWORD n = GetModuleFileName(NULL, buff, nsize);
if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
luaL_error(L, "unable to get ModuleFileName"); luaL_error(L, "unable to get ModuleFileName");
*lb = '\0'; else {
luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); *lb = '\0';
lua_remove(L, -2); /* remove original string */ luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff);
lua_remove(L, -2); /* remove original string */
}
} }