aboutsummaryrefslogtreecommitdiff
path: root/loadlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-12-17 11:06:47 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-12-17 11:06:47 -0200
commit2108754e4624273e473a64ad30c4d75b4f6c4e7f (patch)
tree6aaac5d8162d08f695be0989aa897c0e2d5582c9 /loadlib.c
parent46f1429936ff7cde274f9896d022ab494567ee7a (diff)
downloadlua-2108754e4624273e473a64ad30c4d75b4f6c4e7f.tar.gz
lua-2108754e4624273e473a64ad30c4d75b4f6c4e7f.tar.bz2
lua-2108754e4624273e473a64ad30c4d75b4f6c4e7f.zip
macro name change: LUA_PATH->LUA_PATH_VAR, LUA_CPATH->LUA_CPATH_VAR,
LUA_PATHSEP->LUA_PATH_SEP, LUA_EXECDIR->LUA_EXEC_DIR
Diffstat (limited to 'loadlib.c')
-rw-r--r--loadlib.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/loadlib.c b/loadlib.c
index 6d7c5628..f336babd 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loadlib.c,v 1.68 2009/11/24 12:05:44 roberto Exp roberto $ 2** $Id: loadlib.c,v 1.69 2009/12/17 12:26:09 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**
@@ -23,35 +23,35 @@
23 23
24 24
25/* 25/*
26** LUA_PATH and LUA_CPATH are the names of the environment variables that 26** LUA_PATH_VAR and LUA_CPATH_VAR are the names of the environment
27** Lua check to set its paths. 27** variables that Lua check to set its paths.
28*/ 28*/
29#if !defined(LUA_PATH) 29#if !defined(LUA_PATH_VAR)
30#define LUA_PATH "LUA_PATH" 30#define LUA_PATH_VAR "LUA_PATH"
31#endif 31#endif
32 32
33#if !defined(LUA_CPATH) 33#if !defined(LUA_CPATH_VAR)
34#define LUA_CPATH "LUA_CPATH" 34#define LUA_CPATH_VAR "LUA_CPATH"
35#endif 35#endif
36 36
37 37
38/* 38/*
39** LUA_PATHSEP is the character that separates templates in a path. 39** LUA_PATH_SEP is the character that separates templates in a path.
40** LUA_PATH_MARK is the string that marks the substitution points in a 40** LUA_PATH_MARK is the string that marks the substitution points in a
41** template. 41** template.
42** LUA_EXECDIR in a Windows path is replaced by the executable's 42** LUA_EXEC_DIR in a Windows path is replaced by the executable's
43** directory. 43** directory.
44** LUA_IGMARK is a mark to ignore all before it when building the 44** LUA_IGMARK is a mark to ignore all before it when building the
45** luaopen_ function name. 45** luaopen_ function name.
46*/ 46*/
47#if !defined (LUA_PATHSEP) 47#if !defined (LUA_PATH_SEP)
48#define LUA_PATHSEP ";" 48#define LUA_PATH_SEP ";"
49#endif 49#endif
50#if !defined (LUA_PATH_MARK) 50#if !defined (LUA_PATH_MARK)
51#define LUA_PATH_MARK "?" 51#define LUA_PATH_MARK "?"
52#endif 52#endif
53#if !defined (LUA_EXECDIR) 53#if !defined (LUA_EXEC_DIR)
54#define LUA_EXECDIR "!" 54#define LUA_EXEC_DIR "!"
55#endif 55#endif
56#if !defined (LUA_IGMARK) 56#if !defined (LUA_IGMARK)
57#define LUA_IGMARK "-" 57#define LUA_IGMARK "-"
@@ -138,7 +138,7 @@ static void setprogdir (lua_State *L) {
138 luaL_error(L, "unable to get ModuleFileName"); 138 luaL_error(L, "unable to get ModuleFileName");
139 else { 139 else {
140 *lb = '\0'; 140 *lb = '\0';
141 luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); 141 luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff);
142 lua_remove(L, -2); /* remove original string */ 142 lua_remove(L, -2); /* remove original string */
143 } 143 }
144} 144}
@@ -381,9 +381,9 @@ static int readable (const char *filename) {
381 381
382static const char *pushnexttemplate (lua_State *L, const char *path) { 382static const char *pushnexttemplate (lua_State *L, const char *path) {
383 const char *l; 383 const char *l;
384 while (*path == *LUA_PATHSEP) path++; /* skip separators */ 384 while (*path == *LUA_PATH_SEP) path++; /* skip separators */
385 if (*path == '\0') return NULL; /* no more templates */ 385 if (*path == '\0') return NULL; /* no more templates */
386 l = strchr(path, *LUA_PATHSEP); /* find next separator */ 386 l = strchr(path, *LUA_PATH_SEP); /* find next separator */
387 if (l == NULL) l = path + strlen(path); 387 if (l == NULL) l = path + strlen(path);
388 lua_pushlstring(L, path, l - path); /* template */ 388 lua_pushlstring(L, path, l - path); /* template */
389 return l; 389 return l;
@@ -655,8 +655,8 @@ static void setpath (lua_State *L, const char *fieldname, const char *envname,
655 lua_pushstring(L, def); /* use default */ 655 lua_pushstring(L, def); /* use default */
656 else { 656 else {
657 /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ 657 /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
658 path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, 658 path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP,
659 LUA_PATHSEP AUXMARK LUA_PATHSEP); 659 LUA_PATH_SEP AUXMARK LUA_PATH_SEP);
660 luaL_gsub(L, path, AUXMARK, def); 660 luaL_gsub(L, path, AUXMARK, def);
661 lua_remove(L, -2); 661 lua_remove(L, -2);
662 } 662 }
@@ -701,11 +701,11 @@ LUAMOD_API int luaopen_package (lua_State *L) {
701 lua_rawseti(L, -2, i+1); 701 lua_rawseti(L, -2, i+1);
702 } 702 }
703 lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ 703 lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */
704 setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ 704 setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT); /* set field `path' */
705 setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ 705 setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT); /* set field `cpath' */
706 /* store config information */ 706 /* store config information */
707 lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" 707 lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
708 LUA_EXECDIR "\n" LUA_IGMARK "\n"); 708 LUA_EXEC_DIR "\n" LUA_IGMARK "\n");
709 lua_setfield(L, -2, "config"); 709 lua_setfield(L, -2, "config");
710 /* set field `loaded' */ 710 /* set field `loaded' */
711 luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); 711 luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2);