summaryrefslogtreecommitdiff
path: root/loadlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-09-06 14:20:25 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-09-06 14:20:25 -0300
commit2bcbd3c72539ef121cbde5ccbe355171a0722381 (patch)
tree18c1ec7eaba6281a9e803a23162d2dc6097e2094 /loadlib.c
parent5fa6604f00f7ccf44b0c61d9d272ad5ea66082bd (diff)
downloadlua-2bcbd3c72539ef121cbde5ccbe355171a0722381.tar.gz
lua-2bcbd3c72539ef121cbde5ccbe355171a0722381.tar.bz2
lua-2bcbd3c72539ef121cbde5ccbe355171a0722381.zip
avoid 'PathRemoveFileSpec' (not very portable)
Diffstat (limited to '')
-rw-r--r--loadlib.c8
1 files 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 @@
1/* 1/*
2** $Id: loadlib.c,v 1.42 2005/08/26 17:36:32 roberto Exp roberto $ 2** $Id: loadlib.c,v 1.43 2005/08/31 23:17:29 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**
@@ -93,18 +93,18 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
93*/ 93*/
94 94
95#include <windows.h> 95#include <windows.h>
96#include "Shlwapi.h"
97 96
98 97
99#undef setprogdir 98#undef setprogdir
100 99
101void setprogdir (lua_State *L) { 100void setprogdir (lua_State *L) {
102 char buff[MAX_PATH + 1]; 101 char buff[MAX_PATH + 1];
102 char *lb;
103 DWORD nsize = sizeof(buff)/sizeof(char); 103 DWORD nsize = sizeof(buff)/sizeof(char);
104 DWORD n = GetModuleFileName(NULL, buff, nsize); 104 DWORD n = GetModuleFileName(NULL, buff, nsize);
105 if (n == 0 || n == nsize) 105 if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
106 luaL_error(L, "unable to get ModuleFileName"); 106 luaL_error(L, "unable to get ModuleFileName");
107 PathRemoveFileSpec(buff); 107 *lb = '\0';
108 luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); 108 luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff);
109 lua_remove(L, -2); /* remove original string */ 109 lua_remove(L, -2); /* remove original string */
110} 110}