diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2010-06-10 21:20:17 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2010-06-10 21:20:17 +0000 |
commit | d9582113cc8503cf43001d5e8d06e42ecad947af (patch) | |
tree | 50e2dc6ae002b0926087cade86c5d598be71a546 /Master/bin | |
parent | ddf12e2123c9f0d23bddbcb2c81e0f787b2adc12 (diff) |
fix context mkiv SELFAUTODIR/SELFAUTOPARENT discovery for paths with dots in the directory names
git-svn-id: svn://tug.org/texlive/trunk@18876 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/bin')
-rwxr-xr-x | Master/bin/win32/luatools.lua | 54 | ||||
-rwxr-xr-x | Master/bin/win32/mtxrun.lua | 54 |
2 files changed, 84 insertions, 24 deletions
diff --git a/Master/bin/win32/luatools.lua b/Master/bin/win32/luatools.lua index 581ba70c86a..ac1e38f4c6d 100755 --- a/Master/bin/win32/luatools.lua +++ b/Master/bin/win32/luatools.lua @@ -2214,22 +2214,52 @@ end -- we can hash them weakly + +local insert = table.insert + function file.collapse_path(str) + if str == "" or str =="." then + return "." + elseif find(str,"^%.%.") then + return str + elseif not find(str,"%.") then + return str + end + str = gsub(str,"^%./",lfs.currentdir() .. "/") -- ./xx in qualified str = gsub(str,"\\","/") - if find(str,"/") then - str = gsub(str,"^%./",(gsub(lfs.currentdir(),"\\","/")) .. "/") -- ./xx in qualified - str = gsub(str,"/%./","/") - local n, m = 1, 1 - while n > 0 or m > 0 do - str, n = gsub(str,"[^/%.]+/%.%.$","") - str, m = gsub(str,"[^/%.]+/%.%./","") + local oldelements = checkedsplit(str,"/") + local newelements = { } + local i = #oldelements + while i > 0 do + local element = oldelements[i] + if element == '.' then + -- do nothing + elseif element == '..' then + local n = i -1 + while n > 0 do + local element = oldelements[n] + if element ~= '..' and element ~= '.' then + oldelements[n] = '.' + break + else + n = n - 1 + end + end + if n<1 then + insert(newelements,1,'..') + end + elseif element ~= "" then + insert(newelements,1,element) end - str = gsub(str,"([^/])/$","%1") - -- str = gsub(str,"^%./","") -- ./xx in qualified - str = gsub(str,"/%.$","") + i = i - 1 + end + if #newelements == 0 then + return "." + elseif find(str,"^/") then + return "/" .. concat(newelements,'/') + else + return concat(newelements, '/') end - if str == "" then str = "." end - return str end --~ print(file.collapse_path("/a")) diff --git a/Master/bin/win32/mtxrun.lua b/Master/bin/win32/mtxrun.lua index d6b2d13a71a..574335c58d5 100755 --- a/Master/bin/win32/mtxrun.lua +++ b/Master/bin/win32/mtxrun.lua @@ -2223,22 +2223,52 @@ end -- we can hash them weakly + +local insert = table.insert + function file.collapse_path(str) + if str == "" or str =="." then + return "." + elseif find(str,"^%.%.") then + return str + elseif not find(str,"%.") then + return str + end + str = gsub(str,"^%./",lfs.currentdir() .. "/") -- ./xx in qualified str = gsub(str,"\\","/") - if find(str,"/") then - str = gsub(str,"^%./",(gsub(lfs.currentdir(),"\\","/")) .. "/") -- ./xx in qualified - str = gsub(str,"/%./","/") - local n, m = 1, 1 - while n > 0 or m > 0 do - str, n = gsub(str,"[^/%.]+/%.%.$","") - str, m = gsub(str,"[^/%.]+/%.%./","") + local oldelements = checkedsplit(str,"/") + local newelements = { } + local i = #oldelements + while i > 0 do + local element = oldelements[i] + if element == '.' then + -- do nothing + elseif element == '..' then + local n = i -1 + while n > 0 do + local element = oldelements[n] + if element ~= '..' and element ~= '.' then + oldelements[n] = '.' + break + else + n = n - 1 + end + end + if n<1 then + insert(newelements,1,'..') + end + elseif element ~= "" then + insert(newelements,1,element) end - str = gsub(str,"([^/])/$","%1") - -- str = gsub(str,"^%./","") -- ./xx in qualified - str = gsub(str,"/%.$","") + i = i - 1 + end + if #newelements == 0 then + return "." + elseif find(str,"^/") then + return "/" .. concat(newelements,'/') + else + return concat(newelements, '/') end - if str == "" then str = "." end - return str end --~ print(file.collapse_path("/a")) |