summaryrefslogtreecommitdiff
path: root/tex/context/base/l-dir.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2013-10-20 01:21:09 +0300
committerMarius <mariausol@gmail.com>2013-10-20 01:21:09 +0300
commitb8ac6d7b7fdb16293c28034c349efd5b0b7b20b3 (patch)
tree0e9051dbe21b4e9cfc72fe594df5b0fe7bc511f3 /tex/context/base/l-dir.lua
parent965214d981e6129b782c67adcaf3a81aedcb0bac (diff)
downloadcontext-b8ac6d7b7fdb16293c28034c349efd5b0b7b20b3.tar.gz
beta 2013.10.20 07:09
Diffstat (limited to 'tex/context/base/l-dir.lua')
-rw-r--r--tex/context/base/l-dir.lua39
1 files changed, 30 insertions, 9 deletions
diff --git a/tex/context/base/l-dir.lua b/tex/context/base/l-dir.lua
index 3d0576eeb..40081cc3b 100644
--- a/tex/context/base/l-dir.lua
+++ b/tex/context/base/l-dir.lua
@@ -26,6 +26,8 @@ local isfile = lfs.isfile
local currentdir = lfs.currentdir
local chdir = lfs.chdir
+local onwindows = os.type == "windows" or find(os.getenv("PATH"),";")
+
-- in case we load outside luatex
if not isdir then
@@ -136,11 +138,33 @@ end
dir.collectpattern = collectpattern
-local pattern = Ct {
- [1] = (C(P(".") + P("/")^1) + C(R("az","AZ") * P(":") * P("/")^0) + Cc("./")) * V(2) * V(3),
- [2] = C(((1-S("*?/"))^0 * P("/"))^0),
- [3] = C(P(1)^0)
-}
+local separator
+
+if onwindows then -- we could sanitize here
+
+-- pattern = Ct {
+-- [1] = (C(P(".") + S("/\\")^1) + C(R("az","AZ") * P(":") * S("/\\")^0) + Cc("./")) * V(2) * V(3),
+-- [2] = C(((1-S("*?/\\"))^0 * S("/\\"))^0),
+-- [3] = C(P(1)^0)
+-- }
+
+ local slash = S("/\\") / "/"
+
+ pattern = Ct {
+ [1] = (Cs(P(".") + slash^1) + Cs(R("az","AZ") * P(":") * slash^0) + Cc("./")) * V(2) * V(3),
+ [2] = Cs(((1-S("*?/\\"))^0 * slash)^0),
+ [3] = Cs(P(1)^0)
+ }
+
+else -- assume unix
+
+ pattern = Ct {
+ [1] = (C(P(".") + P("/")^1) + Cc("./")) * V(2) * V(3),
+ [2] = C(((1-S("*?/"))^0 * P("/"))^0),
+ [3] = C(P(1)^0)
+ }
+
+end
local filter = Cs ( (
P("**") / ".*" +
@@ -257,8 +281,6 @@ end
local make_indeed = true -- false
-local onwindows = os.type == "windows" or find(os.getenv("PATH"),";")
-
if onwindows then
function dir.mkdirs(...)
@@ -273,9 +295,8 @@ if onwindows then
str = str .. "/" .. s
end
end
- local first, middle, last
local drive = false
- first, middle, last = match(str,"^(//)(//*)(.*)$")
+ local first, middle, last = match(str,"^(//)(//*)(.*)$")
if first then
-- empty network path == local path
else