summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-10-25 21:34:47 +0000
committerKarl Berry <karl@freefriends.org>2018-10-25 21:34:47 +0000
commit02aa0c181c36eb53c436478eeb878a070972ac16 (patch)
treee6803181aa2bf1a9bbe4ccda4841b4f6d9b1e31a /Master/texmf-dist/scripts/l3build/l3build-file-functions.lua
parent56ff75d2dc5bee2624945e8dd43945f1670e040d (diff)
l3build (25oct18)
git-svn-id: svn://tug.org/texlive/trunk@48991 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/l3build/l3build-file-functions.lua')
-rw-r--r--Master/texmf-dist/scripts/l3build/l3build-file-functions.lua109
1 files changed, 29 insertions, 80 deletions
diff --git a/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua b/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua
index bc462d3ff33..bf5ce872b15 100644
--- a/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua
+++ b/Master/texmf-dist/scripts/l3build/l3build-file-functions.lua
@@ -33,6 +33,7 @@ local chdir = lfs.chdir
local lfs_dir = lfs.dir
local execute = os.execute
+local exit = os.exit
local getenv = os.getenv
local remove = os.remove
local os_time = os.time
@@ -90,67 +91,6 @@ 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
@@ -163,24 +103,9 @@ local function glob_to_pattern(glob)
elseif char == "*" then
pattern = pattern .. ".*"
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
+ -- Ignored
+ print("[...] syntax not supported in globs!")
+ elseif char == "\\" then
i = i + 1
char = sub(glob, i, i)
if char == "" then
@@ -206,6 +131,8 @@ 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"
@@ -213,10 +140,13 @@ 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"
os_grepexe = "findstr /r"
+ os_newline = "\n"
if tonumber(luatex_version) < 100 or
(tonumber(luatex_version) == 100
and tonumber(luatex_revision) < 4) then
@@ -246,7 +176,26 @@ function abspath(path)
chdir(path)
local result = currentdir()
chdir(oldpwd)
- return gsub(result, "\\", "/")
+ return escapepath(gsub(result, "\\", "/"))
+end
+
+function escapepath(path)
+ if os_type == "windows" then
+ local path,count = gsub(path,'"','')
+ if count % 2 ~= 0 then
+ print("Unbalanced quotes in path")
+ exit(0)
+ else
+ if match(path," ") then
+ return '"' .. path .. '"'
+ end
+ return path
+ end
+ else
+ path = gsub(path,"\\ ","[PATH-SPACE]")
+ path = gsub(path," ","\\ ")
+ return gsub(path,"[PATH-SPACE]","\\ ")
+ end
end
-- For cleaning out a directory, which also ensures that it exists