aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/dir.lua7
-rw-r--r--src/luarocks/persist.lua2
2 files changed, 4 insertions, 5 deletions
diff --git a/src/luarocks/dir.lua b/src/luarocks/dir.lua
index b496c962..3c7465bb 100644
--- a/src/luarocks/dir.lua
+++ b/src/luarocks/dir.lua
@@ -17,13 +17,12 @@ end
17 17
18--- Strip the name off a path+filename. 18--- Strip the name off a path+filename.
19-- @param pathname string: A path+name, such as "/a/b/c". 19-- @param pathname string: A path+name, such as "/a/b/c".
20-- @return string: The filename without its path, such as "/a/b/". 20-- @return string: The filename without its path, such as "/a/b".
21-- For entries such as "/a/b/", "/a/" is returned. If there are 21-- For entries such as "/a/b/", "/a" is returned. If there are
22-- no directory separators in input, "" is returned. 22-- no directory separators in input, "" is returned.
23function dir_name(pathname) 23function dir_name(pathname)
24 assert(type(pathname) == "string") 24 assert(type(pathname) == "string")
25 25 return (pathname:gsub("/*$", ""):match("(.*)[/]+[^/]*")) or ""
26 return (pathname:gsub("/*$", ""):match("(.*/)[^/]*")) or ""
27end 26end
28 27
29--- Describe a path in a cross-platform way. 28--- Describe a path in a cross-platform way.
diff --git a/src/luarocks/persist.lua b/src/luarocks/persist.lua
index 208aee02..376a242a 100644
--- a/src/luarocks/persist.lua
+++ b/src/luarocks/persist.lua
@@ -20,7 +20,7 @@ function load_into_table(filename, tbl)
20 20
21 local result, chunk, ran, err 21 local result, chunk, ran, err
22 local result = tbl or {} 22 local result = tbl or {}
23 if setfenv then -- Lua 5.1 23 if _VERSION == "Lua 5.1" then -- Lua 5.1
24 chunk, err = loadfile(filename) 24 chunk, err = loadfile(filename)
25 if chunk then 25 if chunk then
26 setfenv(chunk, result) 26 setfenv(chunk, result)