summaryrefslogtreecommitdiff
path: root/lualibs-dir.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-09-03 13:25:54 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-09-03 13:25:54 +0200
commit5a4a4188ea6b7796cd4795c84866e8b0db553949 (patch)
tree0274fb1094de1786db3a814346c95fab097259fb /lualibs-dir.lua
parent36085526a0d2e5f35d0c6a9fc4daae0b6b69326f (diff)
downloadlualibs-5a4a4188ea6b7796cd4795c84866e8b0db553949.tar.gz
sync with Context as of 2013-09-03
Diffstat (limited to 'lualibs-dir.lua')
-rw-r--r--lualibs-dir.lua36
1 files changed, 29 insertions, 7 deletions
diff --git a/lualibs-dir.lua b/lualibs-dir.lua
index e47de60..40081cc 100644
--- a/lualibs-dir.lua
+++ b/lualibs-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(...)