summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2010-06-10 21:20:17 +0000
committerTaco Hoekwater <taco@elvenkind.com>2010-06-10 21:20:17 +0000
commitd9582113cc8503cf43001d5e8d06e42ecad947af (patch)
tree50e2dc6ae002b0926087cade86c5d598be71a546 /Master/texmf-dist/tex
parentddf12e2123c9f0d23bddbcb2c81e0f787b2adc12 (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/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/context/base/l-file.lua54
1 files changed, 42 insertions, 12 deletions
diff --git a/Master/texmf-dist/tex/context/base/l-file.lua b/Master/texmf-dist/tex/context/base/l-file.lua
index 2bfc0709007..52e8ed1fbfd 100644
--- a/Master/texmf-dist/tex/context/base/l-file.lua
+++ b/Master/texmf-dist/tex/context/base/l-file.lua
@@ -140,22 +140,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"))