From 7490fa4d0750f6f5769e53f84aba9c263479a48e Mon Sep 17 00:00:00 2001 From: Marius Date: Thu, 6 Dec 2012 20:00:13 +0200 Subject: beta 2012.12.06 18:39 --- scripts/context/lua/mtxrun.lua | 39 +++++++++++++++++++++++++++++++++- scripts/context/stubs/mswin/mtxrun.lua | 39 +++++++++++++++++++++++++++++++++- scripts/context/stubs/unix/mtxrun | 39 +++++++++++++++++++++++++++++++++- 3 files changed, 114 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 3a1972640..be3acb7da 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -3143,7 +3143,6 @@ function file.replacesuffix(filename, suffix) return (gsub(filename,"%.[%a%d]+$","")) .. "." .. suffix end - local trick_1 = char(1) local trick_2 = "^" .. trick_1 .. "/+" @@ -3170,6 +3169,44 @@ function file.join(...) -- rather dirty return (gsub(pth,"//+","/")) end +-- local slash = P("/") +-- local colon = P(":") + +-- local replacer = lpeg.replacer(S("\\/")^1,"/") +-- local stripper = Cs(P(slash)^0/"" * replacer) +-- local isnetwork = slash * slash * (1-slash) + (1-slash-colon)^1 * colon +-- local isroot = slash^1 * -1 +-- local hasroot = slash^1 + +-- function file.newjoin(...) -- rather dirty +-- local lst = { ... } +-- local one = lst[1] +-- if lpegmatch(isnetwork,one) then +-- local two = lpegmatch(replacer,concat(lst,"/",2)) +-- return one .. two +-- elseif lpegmatch(isroot,one) then +-- local two = lpegmatch(replacer,concat(lst,"/",2)) +-- if lpegmatch(hasroot,two) then +-- return two +-- else +-- return "/" .. two +-- end +-- elseif one == "" then +-- return lpegmatch(stripper,concat(lst,"/",2)) +-- else +-- return lpegmatch(replacer,concat(lst,"/")) +-- end +-- end + +-- print(file.join("//","/y")) +-- print(file.join("/","/y")) +-- print(file.join("","/y")) +-- print(file.join("/x/","/y")) +-- print(file.join("x/","/y")) +-- print(file.join("http://","/y")) +-- print(file.join("http://a","/y")) +-- print(file.join("http:///a","/y")) +-- print(file.join("//nas-1","/y")) -- We should be able to use: -- diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 3a1972640..be3acb7da 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -3143,7 +3143,6 @@ function file.replacesuffix(filename, suffix) return (gsub(filename,"%.[%a%d]+$","")) .. "." .. suffix end - local trick_1 = char(1) local trick_2 = "^" .. trick_1 .. "/+" @@ -3170,6 +3169,44 @@ function file.join(...) -- rather dirty return (gsub(pth,"//+","/")) end +-- local slash = P("/") +-- local colon = P(":") + +-- local replacer = lpeg.replacer(S("\\/")^1,"/") +-- local stripper = Cs(P(slash)^0/"" * replacer) +-- local isnetwork = slash * slash * (1-slash) + (1-slash-colon)^1 * colon +-- local isroot = slash^1 * -1 +-- local hasroot = slash^1 + +-- function file.newjoin(...) -- rather dirty +-- local lst = { ... } +-- local one = lst[1] +-- if lpegmatch(isnetwork,one) then +-- local two = lpegmatch(replacer,concat(lst,"/",2)) +-- return one .. two +-- elseif lpegmatch(isroot,one) then +-- local two = lpegmatch(replacer,concat(lst,"/",2)) +-- if lpegmatch(hasroot,two) then +-- return two +-- else +-- return "/" .. two +-- end +-- elseif one == "" then +-- return lpegmatch(stripper,concat(lst,"/",2)) +-- else +-- return lpegmatch(replacer,concat(lst,"/")) +-- end +-- end + +-- print(file.join("//","/y")) +-- print(file.join("/","/y")) +-- print(file.join("","/y")) +-- print(file.join("/x/","/y")) +-- print(file.join("x/","/y")) +-- print(file.join("http://","/y")) +-- print(file.join("http://a","/y")) +-- print(file.join("http:///a","/y")) +-- print(file.join("//nas-1","/y")) -- We should be able to use: -- diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 3a1972640..be3acb7da 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -3143,7 +3143,6 @@ function file.replacesuffix(filename, suffix) return (gsub(filename,"%.[%a%d]+$","")) .. "." .. suffix end - local trick_1 = char(1) local trick_2 = "^" .. trick_1 .. "/+" @@ -3170,6 +3169,44 @@ function file.join(...) -- rather dirty return (gsub(pth,"//+","/")) end +-- local slash = P("/") +-- local colon = P(":") + +-- local replacer = lpeg.replacer(S("\\/")^1,"/") +-- local stripper = Cs(P(slash)^0/"" * replacer) +-- local isnetwork = slash * slash * (1-slash) + (1-slash-colon)^1 * colon +-- local isroot = slash^1 * -1 +-- local hasroot = slash^1 + +-- function file.newjoin(...) -- rather dirty +-- local lst = { ... } +-- local one = lst[1] +-- if lpegmatch(isnetwork,one) then +-- local two = lpegmatch(replacer,concat(lst,"/",2)) +-- return one .. two +-- elseif lpegmatch(isroot,one) then +-- local two = lpegmatch(replacer,concat(lst,"/",2)) +-- if lpegmatch(hasroot,two) then +-- return two +-- else +-- return "/" .. two +-- end +-- elseif one == "" then +-- return lpegmatch(stripper,concat(lst,"/",2)) +-- else +-- return lpegmatch(replacer,concat(lst,"/")) +-- end +-- end + +-- print(file.join("//","/y")) +-- print(file.join("/","/y")) +-- print(file.join("","/y")) +-- print(file.join("/x/","/y")) +-- print(file.join("x/","/y")) +-- print(file.join("http://","/y")) +-- print(file.join("http://a","/y")) +-- print(file.join("http:///a","/y")) +-- print(file.join("//nas-1","/y")) -- We should be able to use: -- -- cgit v1.2.3