[latex3-commits] [git/LaTeX3-latex3-l3build] master: Only quote path on Windows if spaces are present (4d9885b)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Oct 25 10:54:40 CEST 2018


Repository : https://github.com/latex3/l3build
On branch  : master
Link       : https://github.com/latex3/l3build/commit/4d9885bf5dbacf66b014ba509f5152cea7f695c9

>---------------------------------------------------------------

commit 4d9885bf5dbacf66b014ba509f5152cea7f695c9
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Oct 25 09:54:40 2018 +0100

    Only quote path on Windows if spaces are present


>---------------------------------------------------------------

4d9885bf5dbacf66b014ba509f5152cea7f695c9
 l3build-file-functions.lua |   92 ++++++--------------------------------------
 1 file changed, 12 insertions(+), 80 deletions(-)

diff --git a/l3build-file-functions.lua b/l3build-file-functions.lua
index ff2bff4..bf5ce87 100644
--- a/l3build-file-functions.lua
+++ b/l3build-file-functions.lua
@@ -91,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
@@ -164,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
@@ -207,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"
@@ -214,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
@@ -257,7 +186,10 @@ function escapepath(path)
       print("Unbalanced quotes in path")
       exit(0)
     else
-      return '"' .. path .. '"'
+      if match(path," ") then
+        return '"' .. path .. '"'
+      end
+      return path
     end
   else
     path = gsub(path,"\\ ","[PATH-SPACE]")





More information about the latex3-commits mailing list