mirror of https://github.com/rusefi/lua.git
LUA_PATH components may have multiple interrogation marks
This commit is contained in:
parent
7c3857cded
commit
430d6db928
24
lbaselib.c
24
lbaselib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lbaselib.c,v 1.124 2003/02/27 11:52:30 roberto Exp roberto $
|
** $Id: lbaselib.c,v 1.125 2003/03/06 19:36:16 roberto Exp roberto $
|
||||||
** Basic library
|
** Basic library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -408,6 +408,10 @@ static int luaB_newproxy (lua_State *L) {
|
||||||
#define LUA_PATH_SEP ';'
|
#define LUA_PATH_SEP ';'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef LUA_PATH_MARK
|
||||||
|
#define LUA_PATH_MARK '?'
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef LUA_PATH_DEFAULT
|
#ifndef LUA_PATH_DEFAULT
|
||||||
#define LUA_PATH_DEFAULT "?;?.lua"
|
#define LUA_PATH_DEFAULT "?;?.lua"
|
||||||
#endif
|
#endif
|
||||||
|
@ -438,12 +442,18 @@ static const char *pushnextpath (lua_State *L, const char *path) {
|
||||||
|
|
||||||
static void pushcomposename (lua_State *L) {
|
static void pushcomposename (lua_State *L) {
|
||||||
const char *path = lua_tostring(L, -1);
|
const char *path = lua_tostring(L, -1);
|
||||||
const char *wild = strchr(path, '?');
|
const char *wild;
|
||||||
if (wild == NULL) return; /* no wild char; path is the file name */
|
int n = 1;
|
||||||
lua_pushlstring(L, path, wild - path);
|
while ((wild = strchr(path, LUA_PATH_MARK)) != NULL) {
|
||||||
lua_pushvalue(L, 1); /* package name */
|
/* is there stack space for prefix, name, and eventual last sufix? */
|
||||||
lua_pushstring(L, wild + 1);
|
luaL_checkstack(L, 3, "too many marks in a path component");
|
||||||
lua_concat(L, 3);
|
lua_pushlstring(L, path, wild - path); /* push prefix */
|
||||||
|
lua_pushvalue(L, 1); /* push package name (in place of MARK) */
|
||||||
|
path = wild + 1; /* continue after MARK */
|
||||||
|
n += 2;
|
||||||
|
}
|
||||||
|
lua_pushstring(L, path); /* push last sufix (`n' already includes this) */
|
||||||
|
lua_concat(L, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue