lua-users home
lua-l archive

Re: loadlib 5.1 alpha - bug1

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


Hi,
David Burgess wrote:
> #define LUA_CPATH_DEFAULT \
> 	"?.dll;" LUA_CDIR"\\?.dll;" LUA_CDIR"\\loadall.dll"
> 
> This is not the best default. The first call to LoadLibrary() will
> make an unqualified call to LoadLibrary() using the Win32
> search strategy(not good and slow). e.g. LoadLibrary("my.dll")
Doesn't ".\\?.dll" work? This would be analogous to the way
the POSIX variant avoids a (useless and dangerous) path search
("./?.so").
> The point of the module directory idea was to provide a fully
> qualified path(quick).
Yes. And while I'm at it ... why are Lua modules searched in the
Lua path _and_ the C module path? This is a regression from 51w6.
Especially since Lua modules are searched first.
Doing it this way will only encourage sloppy module authors
to install everything in the C module directories. This of
course breaks mixed-architecture installations (I already
explained that this is more relevant than ever due to mixed
x86/x64 systems).
> I believe the above define should be:
> 
> #define LUA_CPATH_DEFAULT \
> 	LUA_CDIR"\\?.dll;" "?.dll;" LUA_CDIR"\\loadall.dll"
IMHO if ".\\?.dll" works (I haven't tried) then this should
be in front. Otherwise you can't override an installed module
with one in the current directory.
> PS.
> my preference is also to change
> 
> #define LUA_CDIR	"!\\dll"
> to
> #define LUA_CDIR	"!"
Ok, this would mirror the standard way most Windows programs
are installed: all EXEs and DLLs in one directory. It's all
about following system conventions ...
Summary:
#if defined(_WIN32)
#define LUA_LDIR "!lua\\"
#define LUA_CDIR "!"
#define LUA_PATH_DEFAULT \
 "?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;"
#define LUA_CPATH_DEFAULT
 ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
#else
#define LUA_ROOT "/usr/local"
#define LUA_LDIR LUA_ROOT "/share/lua/5.1" 
#define LUA_CDIR LUA_ROOT "/lib/lua/5.1"
#define LUA_PATH_DEFAULT \
 "?.lua;" LUA_LDIR"/?.lua;" LUA_LDIR"/?/init.lua;"
#define LUA_CPATH_DEFAULT \
 "./?.so;" LUA_CDIR"/?.so;" LUA_CDIR"/loadall.so"
#endif
[Plus the "!" substitution fix with strrchr that includes the
last backslash.]
Bye,
 Mike

AltStyle によって変換されたページ (->オリジナル) /