lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 2bcbd3c72539ef121cbde5ccbe355171a0722381
parent 5fa6604f00f7ccf44b0c61d9d272ad5ea66082bd
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Tue,  6 Sep 2005 14:20:03 -0300

avoid 'PathRemoveFileSpec' (not very portable)

Diffstat:
Mloadlib.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/loadlib.c b/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.42 2005/08/26 17:36:32 roberto Exp roberto $ +** $Id: loadlib.c,v 1.43 2005/08/31 23:17:29 roberto Exp roberto $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -93,18 +93,18 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { */ #include <windows.h> -#include "Shlwapi.h" #undef setprogdir void setprogdir (lua_State *L) { char buff[MAX_PATH + 1]; + char *lb; DWORD nsize = sizeof(buff)/sizeof(char); DWORD n = GetModuleFileName(NULL, buff, nsize); - if (n == 0 || n == nsize) + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) luaL_error(L, "unable to get ModuleFileName"); - PathRemoveFileSpec(buff); + *lb = '\0'; luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); lua_remove(L, -2); /* remove original string */ }