lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Wim Couwenberg wrote:
> The call to PathRemoveFileSpec in loadlib.c (and only this one)
> introduces a dependency of SHLWAPI.dll, a shell libray.  I would
> suggest to simply use strrchr or the more fundamental GetFullPathName
> instead.  (version issues are more likely with SHLWAPI than the core
> OS dll's.)

Yep. And I have to add that the way PathRemoveFileSpec is
used may fail with network drives or if you place Lua in
the root directory of a drive (you get a double backslash).

I have to apologize to Roberto because he asked whether
it was ok to use this API call and I just said 'yes' because
MS recommended it. Sorry, should have checked this better.

Also the #include "Shlwapi.h" fails with MinGW32 because
the cross-compiler is still case-sensitive wrt. file names.

The correct fix is to change
  #define LUA_LDIR  "!lua"
  #define LUA_CDIR  "!dll"
and then use strrchr to find the last backslash and use
everything up to _and including it_ to replace the "!".

Not doing it this way fails for the root directory because
an executable C:\lua.exe needs to resolve the path to
C:\lua\?.lua and not to C:lua\?.lua or C:\\lua\?.lua.