diff options
Diffstat (limited to 'Master/texmf-dist/scripts/l3build/l3build-file-functions.lua')
-rw-r--r-- | Master/texmf-dist/scripts/l3build/l3build-file-functions.lua | 86 |
1 files changed, 79 insertions, 7 deletions
diff --git a/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua b/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua index 83b4bfb6539..510567e5342 100644 --- a/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua +++ b/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua @@ -90,6 +90,67 @@ local function glob_to_pattern(glob) return match(char, "^%w$") and char or "%" .. char end + -- remove a leading "\" if one is present: + -- this can simple be discarded + local function unescape() + if char == "\\" then + i = i + 1 + char = sub(glob,i,i) + if char == "" then + pattern = "[^]" + return false + end + end + return true + end + + -- look for the body of a set: + -- char is already the first token + local function collect_set() + while true do + if char == "" then + pattern = "[^]" + return false + elseif char == "]" then + pattern = pattern .. "]" + break + else + if not unescape(char) then break end + local char_one = char + i = i + 1 + char = sub(glob,i,i) + if char == "" then + pattern = "[^]" + return false + elseif char == "-" then + i = i + 1 + char = sub(glob,i,i) + if char == "" then + pattern = "[^]" + return false + elseif char == "]" then + -- Not a range + pattern = pattern .. escape(char_one) .. "%-]" + return true + else + if not unescape(char) then break end + pattern = pattern .. escape(char_one) .. "-" .. escape(char) + end + elseif char == "]" then + -- Successfully done + pattern = pattern .. escape(char_one) .. "]" + return true + else + pattern = pattern .. escape(char_one) + i = i - 1 -- Back up one + end + end + i = i + 1 + char = sub(glob,i,i) + end + return true + end + -- Convert tokens. while true do i = i + 1 @@ -102,9 +163,24 @@ local function glob_to_pattern(glob) elseif char == "*" then pattern = pattern .. ".*" elseif char == "[" then - -- Ignored - print("[...] syntax not supported in globs!") - elseif char == "\\" then + -- Search inside a charset + i = i + 1 + char = sub(glob,i,i) + if char == "" or char == "]" then -- Matches nothing + pattern = "[^]" + break + elseif char == "^" or char == "!" then + i = i + 1 + char = sub(glob,i,i) + if char ~= "]" then -- Matches anything so ignore + pattern = pattern .. "[^" + if not collect_set() then break end + end + else + pattern = pattern .. "[" + if not collect_set() then break end + end + elseif char == "\\" then -- Discarded i = i + 1 char = sub(glob, i, i) if char == "" then @@ -130,8 +206,6 @@ os_setenv = "export" os_yes = "printf 'y\\n%.0s' {1..200}" os_ascii = "echo \"\"" -os_cmpexe = getenv("cmpexe") or "cmp" -os_cmpext = getenv("cmpext") or ".cmp" os_diffext = getenv("diffext") or ".diff" os_diffexe = getenv("diffexe") or "diff -c --strip-trailing-cr" os_grepexe = "grep" @@ -139,8 +213,6 @@ os_newline = "\n" if os_type == "windows" then os_ascii = "@echo." - os_cmpexe = getenv("cmpexe") or "fc /b" - os_cmpext = getenv("cmpext") or ".cmp" os_concat = "&" os_diffext = getenv("diffext") or ".fc" os_diffexe = getenv("diffexe") or "fc /n" |