From d948cb4eddff16f17051d8078b4c55cdd8e8f681 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 18 Apr 2008 14:17:00 +0200 Subject: stable 2008.04.18 14:17 --- tex/context/base/l-dir.lua | 57 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'tex/context/base/l-dir.lua') diff --git a/tex/context/base/l-dir.lua b/tex/context/base/l-dir.lua index 0600d72fa..b6c70d264 100644 --- a/tex/context/base/l-dir.lua +++ b/tex/context/base/l-dir.lua @@ -85,29 +85,29 @@ if lfs then do dir.glob_pattern = glob_pattern - local function glob(pattern, action) - local t = { } - local path, rest, patt, recurse - local action = action or function(name) t[#t+1] = name end - local pattern = pattern:gsub("^%*%*","./**") - local pattern = pattern:gsub("/%*/","/**/") - path, rest = pattern:match("^(/)(.-)$") - if path then - path = path - else - path, rest = pattern:match("^([^/]*)/(.-)$") - end - if rest then - patt = rest:gsub("([%.%-%+])", "%%%1") - end - patt = patt:gsub("%*", "[^/]*") - patt = patt:gsub("%?", "[^/]") - patt = patt:gsub("%[%^/%]%*%[%^/%]%*", ".*") - if path == "" then path = "." end - recurse = patt:find("%.%*/") ~= nil - glob_pattern(path,patt,recurse,action) - return t - end + --~ local function glob(pattern, action) + --~ local t = { } + --~ local path, rest, patt, recurse + --~ local action = action or function(name) t[#t+1] = name end + --~ local pattern = pattern:gsub("^%*%*","./**") + --~ local pattern = pattern:gsub("/%*/","/**/") + --~ path, rest = pattern:match("^(/)(.-)$") + --~ if path then + --~ path = path + --~ else + --~ path, rest = pattern:match("^([^/]*)/(.-)$") + --~ end + --~ if rest then + --~ patt = rest:gsub("([%.%-%+])", "%%%1") + --~ end + --~ patt = patt:gsub("%*", "[^/]*") + --~ patt = patt:gsub("%?", "[^/]") + --~ patt = patt:gsub("%[%^/%]%*%[%^/%]%*", ".*") + --~ if path == "" then path = "." end + --~ recurse = patt:find("%.%*/") ~= nil + --~ glob_pattern(path,patt,recurse,action) + --~ return t + --~ end local P, S, R, C, Cc, Cs, Ct, Cv, V = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct, lpeg.Cv, lpeg.V @@ -121,13 +121,13 @@ if lfs then do P("**") / ".*" + P("*") / "[^/]*" + P("?") / "[^/]" + - P(".") / "%." + - P("+") / "%+" + - P("-") / "%-" + + P(".") / "%%." + + P("+") / "%%+" + + P("-") / "%%-" + P(1) )^0 ) - function glob(str) + local function glob(str) local split = pattern:match(str) if split then local t = { } @@ -136,7 +136,8 @@ if lfs then do local recurse = base:find("**") local start = root .. path local result = filter:match(start .. base) - -- print(str, start, result) +--~ print(str, start, result) +--~ print(start, result) glob_pattern(start,result,recurse,action) return t else -- cgit v1.2.3