summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2012-12-06 20:00:13 +0200
committerMarius <mariausol@gmail.com>2012-12-06 20:00:13 +0200
commit7490fa4d0750f6f5769e53f84aba9c263479a48e (patch)
treec8d1e8f0f816009cb79238a636d9db3d4954f7ea /scripts
parentc5eeba726820e576380fadff494ce494b625b6ae (diff)
downloadcontext-7490fa4d0750f6f5769e53f84aba9c263479a48e.tar.gz
beta 2012.12.06 18:39
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtxrun.lua39
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua39
-rw-r--r--scripts/context/stubs/unix/mtxrun39
3 files changed, 114 insertions, 3 deletions
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:
--