[latex3-commits] [l3svn] 02/09: replace basename with a more generic path split

noreply at latex-project.org noreply at latex-project.org
Sun Jun 25 09:30:22 CEST 2017


This is an automated email from the git hooks/post-receive script.

joseph pushed a commit to branch master
in repository l3svn.

commit 8a54f3ea1219b07313e606eb4fcd38fafe29424d
Author: XZS <d.f.fischer at web.de>
Date:   Fri Apr 14 17:30:45 2017 +0200

    replace basename with a more generic path split
    
    One pattern can return both parts of the path at once, yielding a
    function that not only replaces basename but also is usable as its
    counterpart, dirname.
    
    Selecting the second of the two return values replaces the old
    functionality. A legacy basename function was not retained, as it was
    only used in two places, which in a coming commit will also be gone and
    replaced with the need to further process both path components - the
    ideal case for the new function.
---
 l3build/l3build.lua |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/l3build/l3build.lua b/l3build/l3build.lua
index 5abd4ef..7d37877 100644
--- a/l3build/l3build.lua
+++ b/l3build/l3build.lua
@@ -1417,15 +1417,19 @@ function dvitopdf(name, dir, engine, hide)
   end
 end
 
--- Strip the path from a file name (if present)
-function basename(file)
-  local name = match(file, "^.*/([^/]*)$")
-  return name or file
+-- Split a path into file and directory component
+function splitpath(file)
+  local path, name = match(file, "^(.*)/([^/]*)$")
+  if path then
+    return path, name
+  else
+    return ".", file
+  end
 end
 
 -- Strip the extension from a file name (if present)
 function jobname(file)
-  local name = match(basename(file), "^(.*)%.")
+  local name = match(select(2, splitpath(file)), "^(.*)%.")
   return name or file
 end
 
@@ -1521,7 +1525,7 @@ function tex(file)
 end
 
 function typesetpdf(file)
-  local name = jobname(file)
+  local name = jobname(select(2, splitpath(file))
   print("Typesetting " .. name)
   local errorlevel = typeset(file)
   if errorlevel == 0 then
@@ -1538,7 +1542,7 @@ typeset = typeset or function(file)
   if errorlevel ~= 0 then
     return errorlevel
   else
-    local name = jobname(file)
+    local name = jobname(select(2, splitpath(file)))
     errorlevel = biber(name) + bibtex(name)
     if errorlevel == 0 then
       local function cycle(name)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the latex3-commits mailing list