From 2bcbd3c72539ef121cbde5ccbe355171a0722381 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 6 Sep 2005 14:20:25 -0300 Subject: avoid 'PathRemoveFileSpec' (not very portable) --- loadlib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/loadlib.c b/loadlib.c index d378fdcc..0ec2a912 100644 --- 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 -#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 */ } -- cgit v1.2.3-55-g6feb