lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 1028f296a8e6477cb556c75fe1397cd4e2762abe
parent 6d042a178fba32d10ec23c98fb2fd284397ccddc
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon, 13 Nov 2023 13:41:32 -0300

Default paths stored as external strings

Diffstat:
Mloadlib.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/loadlib.c b/loadlib.c @@ -283,7 +283,8 @@ static int noenv (lua_State *L) { /* -** Set a path +** Set a path. (If using the default path, assume it is a string +** literal in C and create it as an external string.) */ static void setpath (lua_State *L, const char *fieldname, const char *envname, @@ -294,7 +295,7 @@ static void setpath (lua_State *L, const char *fieldname, if (path == NULL) /* no versioned environment variable? */ path = getenv(envname); /* try unversioned name */ if (path == NULL || noenv(L)) /* no environment variable? */ - lua_pushstring(L, dft); /* use default */ + lua_pushextlstring(L, dft, strlen(dft), NULL, NULL); /* use default */ else if ((dftmark = strstr(path, LUA_PATH_SEP LUA_PATH_SEP)) == NULL) lua_pushstring(L, path); /* nothing to change */ else { /* path contains a ";;": insert default path in its place */