From ce8261713a3c6542d6509919d8dc0f75329432ad Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 14 Sep 2015 21:54:24 +0000 Subject: l3build (14sep15) git-svn-id: svn://tug.org/texlive/trunk@38376 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/l3build/l3build.lua | 185 +++++++++++++++++------- 1 file changed, 136 insertions(+), 49 deletions(-) (limited to 'Master/texmf-dist/tex/latex') diff --git a/Master/texmf-dist/tex/latex/l3build/l3build.lua b/Master/texmf-dist/tex/latex/l3build/l3build.lua index 62728f04072..e8fffc16c43 100644 --- a/Master/texmf-dist/tex/latex/l3build/l3build.lua +++ b/Master/texmf-dist/tex/latex/l3build/l3build.lua @@ -17,8 +17,8 @@ --]] -- Version information: should be identical to that in l3build.dtx -release_date = "2015/09/06" -release_ver = "5925" +release_date = "2015/09/14" +release_ver = "6007" -- "module" is a deprecated function in Lua 5.2: as we want the name -- for other purposes, and it should eventually be 'free', simply @@ -146,6 +146,7 @@ makeindexexe = makeindexexe or "makeindex" makeindexopts = makeindexopts or "" -- Other required settings +asciiengines = asciiengines or {"pdftex"} checkruns = checkruns or 1 packtdszip = packtdszip or false -- Not actually needed but clearer scriptname = scriptname or "build.lua" -- Script used in each directory @@ -373,9 +374,10 @@ end -- both Windows and Unix cases: more complex situations are handled inside -- the support functions if os.type == "windows" then + os_ascii = "@echo." os_concat = "&" - os_diffext = ".fc" - os_diffexe = "fc /n" + os_diffext = os.getenv("diffext") or ".fc" + os_diffexe = os.getenv("diffexe") or "fc /n" os_grepexe = "findstr /r" os_newline = "\r\n" os_null = "nul" @@ -384,9 +386,10 @@ if os.type == "windows" then os_windows = true os_yes = "for /l %I in (1,1,200) do @echo y" else + os_ascii = "echo \"\"" os_concat = ";" - os_diffext = ".diff" - os_diffexe = "diff -c --strip-trailing-cr" + os_diffext = os.getenv("diffext") or ".diff" + os_diffexe = os.getenv("diffexe") or "diff -c --strip-trailing-cr" os_grepexe = "grep" os_newline = "\n" os_null = "/dev/null" @@ -491,13 +494,13 @@ function relpath(target, source) local resultdir = "" local trimpattern = "^[^/]*/" -- Trim off identical leading directories - while + while (string.match(target, trimpattern) or "X") == (string.match(target, trimpattern) or "Y") do target = string.gsub(target, trimpattern, "") source = string.gsub(source, trimpattern, "") end - -- Go up from the source + -- Go up from the source for i = 0, select(2, string.gsub(target, "/", "")) do resultdir = resultdir .. "../" end @@ -598,6 +601,7 @@ function checkinit() for _,i in ipairs(checksuppfiles) do cp(i, supportdir, testdir) end + os.execute(os_ascii .. ">" .. testdir .. "/ascii.tcx") end -- Copy files to the main CTAN release directory @@ -721,9 +725,9 @@ function formatlog(logfile, newfile, engine) line = string.gsub(line, "%(.*/([%w-]+%.[%w-]+)%s*$", "(../%1") end -- Zap map loading of map - line = string.gsub(line, "%{[%w/%-]*/pdftex%.map%}", "") + line = string.gsub(line, "%{%w?:?[%w/%-]*/pdftex%.map%}", "") -- Merge all of .fd data into one line so will be removed later - if string.match(line, "^%([%.%/%w]+%.fd[^%)]*$") then + if string.match(line, "^ *%([%.%/%w]+%.fd[^%)]*$") then lastline = (lastline or "") .. line return "" end @@ -736,23 +740,29 @@ function formatlog(logfile, newfile, engine) -- Zap "on line " and replace with "on line ..." line = string.gsub(line, "on line %d*", "on line ...") -- Tidy up to ^^ notation - for i = 1, 31, 1 do + for i = 0, 31 do line = string.gsub(line, string.char(i), "^^" .. string.char(64 + i)) end -- Zap line numbers from \show, \showbox, \box_show and the like -- Two stages as line wrapping alters some of them and restore the break line = string.gsub(line, "^l%.%d+ ", "l. ...") - line = string.gsub(line, "%.%.%.l%.%d+ ( *)%}$", "...\nl. ...%1}") + line = string.gsub( + line, "%.%.%.l%.%d+ ( *)%}$", "..." .. os_newline .. "l. ...%1}" + ) -- Remove spaces at the start of lines: deals with the fact that LuaTeX -- uses a different number to the other engines line = string.gsub(line, "^%s+", "") -- Remove 'normal' direction information on boxes with (u)pTeX - line = string.gsub(line, ", yoko direction", "") + line = string.gsub(line, ",? yoko direction,?", "") + -- A tidy-up to keep LuaTeX and other engines in sync + local utf8_char = unicode.utf8.char + line = string.gsub(line, utf8_char(127), "^^?") -- Unicode engines display chars in the upper half of the 8-bit range: - -- tidy up to match pdfTeX - local utf8 = unicode.utf8 - for i = 128, 255, 1 do - line = string.gsub(line, utf8.char(i), "^^" .. string.format("%02x", i)) + -- tidy up to match pdfTeX if an ASCII engine is in use + if next(asciiengines) then + for i = 128, 255 do + line = string.gsub(line, utf8_char(i), "^^" .. string.format("%02x", i)) + end end return line end @@ -791,14 +801,16 @@ end -- Additional normalization for LuaTeX function formatlualog(logfile, newfile) local function normalize(line, lastline, dropping) - local line = line - -- Find discretionary lines skip: may get re-added - if string.match(line, "^%.+\\discretionary$") then - return "", line, false + -- Find \discretionary or \whatsit lines: + -- These may come back later + if string.match(line, "^%.+\\discretionary$") or + string.match(line, "^%.+\\whatsit$") then + return "", line end - -- Find whatsit lines skip: may get re-added - if string.match(line, "^%.+\\whatsit$") then - return "", line, false + -- For \mathon, we always need this line but the next + -- may be affected + if string.match(line, "^%.+\\mathon$") then + return line, line end -- Remove 'display' at end of display math boxes: -- LuaTeX omits this as it includes direction in all cases @@ -807,50 +819,114 @@ function formatlualog(logfile, newfile) -- any bidi/vertical stuff will still show line = string.gsub(line, ", direction TLT", "") -- Find glue setting and round out the last place - line = string.gsub( - line, - "glue set (%-? ?)%d+.%d+fil$", - "glue set %1" .. string.format( - "%.4f", string.match(line, "glue set %-? ?(%d+.%d+)fil$") or 0 - ) - .. "fil" + local function round_digits(l, m) + return string.gsub( + l, + m .. " (%-?)%d+%.%d+", + m .. " %1" + .. string.format( + "%.3f", + string.match(line, m .. " %-?(%d+%.%d+)") or 0 + ) ) + end + if string.match(line, "glue set %-?%d+%.%d+") then + line = round_digits(line, "glue set") + end + if string.match( + line, "glue %-?%d+%.%d+ plus %-?%d+%.%d+ minus %-?%d+%.%d+$" + ) + then + line = round_digits(line, "glue") + line = round_digits(line, "plus") + line = round_digits(line, "minus") + end + -- LuaTeX writes ^^M as a new line, which we loose + line = string.gsub(line, "%^%^M", "") -- Remove U+ notation in the "Missing character" message line = string.gsub( line, "Missing character: There is no (%^%^..) %(U%+(....)%)", "Missing character: There is no %1" ) + -- A function to handle the box prefix part + local function boxprefix(s) + return string.gsub(string.match(s, "^(%.+)"), "%.", "%%.") + end -- Where the last line was a discretionary, looks for the -- info one level in about what it represents if string.match(lastline, "^%.+\\discretionary$") then - prefix = string.gsub(string.match(lastline, "^(%.+)"), "%.", "%%.") + local prefix = boxprefix(lastline) if string.match(line, prefix .. "%.") or string.match(line, prefix .. "%|") then return "", lastline, true else if dropping then -- End of a \discretionary block - return line, "", false + return line, "" else -- A normal (TeX90) discretionary: -- add with the line break reintroduced - return lastline .. "\n" .. line, "" + return lastline .. os_newline .. line, "" end end end + -- Look for another form of \discretionary, replacing a "-" + pattern = "^%.+\\discretionary replacing *$" + if string.match(line, pattern) then + return "", line + else + if string.match(lastline, pattern) then + local prefix = boxprefix(lastline) + if string.match(line, prefix .. "%.\\kern") then + return string.gsub(line, "^%.", ""), lastline, true + elseif dropping then + return "", "" + else + return lastline .. os_newline .. line, "" + end + end + end + -- For \mathon, if the current line is an empty \hbox then + -- drop it + if string.match(lastline, "^%.+\\mathon$") then + local prefix = boxprefix(lastline) + if string.match(line, prefix .. "\\hbox%(0%.0%+0%.0%)x0%.0$") then + return "", "" + end + end -- Much the same idea when the last line was a whatsit, -- but things are simpler in this case if string.match(lastline, "^%.+\\whatsit$") then - prefix = string.gsub(string.match(lastline, "^(%.+)"), "%.", "%%.") + local prefix = boxprefix(lastline) if string.match(line, prefix .. "%.") then return "", lastline, true else -- End of a \whatsit block - return line, "", false + return line, "" + end + end + -- Wrap some cases that can be picked out + -- In some places LuaTeX does use max_print_line, then we + -- get into issues with different wrapping approaches + local kpse = require("kpse") + kpse.set_program_name("luatex") + local maxprintline = tonumber(kpse.expand_var("$max_print_line")) + if (string.len(line) == maxprintline) then + return "", line + elseif (string.len(lastline) == maxprintline) then + if string.match(line, "\\ETC%.%}$") then + -- If the line wrapped at \ETC we might have lost a space + return lastline + .. ((string.match(line, "^\\ETC%.%}$") and " ") or "") + .. line, "" + elseif string.match(line, "^%}%}%}$") then + return lastline .. line, "" + else + return lastline .. os_newline .. line, "" end end - return line, lastline, false + return line, "" end local newlog = "" local lastline = "" @@ -858,7 +934,7 @@ function formatlualog(logfile, newfile) for line in io.lines(logfile) do line, lastline, dropping = normalize(line, lastline, dropping) if not string.match(line, "^ *$") then - newlog = newlog .. line .. "\n" + newlog = newlog .. line .. os_newline end end local newfile = io.open(newfile, "w") @@ -948,7 +1024,7 @@ function runcheck(name, hide) errlevel = os.execute( os_diffexe .. " " .. luatlgfile .. " " .. newfile .. " > " .. difffile - ) + ) else errlevel = os.execute( os_diffexe .. " " .. tlgfile .. " " .. newfile .. " > " .. difffile @@ -998,6 +1074,13 @@ function runtest(name, engine, hide, ext) end local logfile = testdir .. "/" .. name .. logext local newfile = testdir .. "/" .. name .. "." .. engine .. logext + local asciiopt = "" + for _,i in ipairs(asciiengines) do + if realengine == i then + asciiopt = "-translate-file ./ascii.tcx " + break + end + end for i = 1, checkruns do run( testdir, @@ -1005,7 +1088,11 @@ function runtest(name, engine, hide, ext) -- avoids any paths in the logs os_setenv .. " TEXINPUTS=." .. (checksearch and os_pathsep or "") .. os_concat .. - realengine .. format .. " " .. checkopts .. " " .. lvtfile + -- Avoid spurious output from (u)pTeX + os_setenv .. " GUESS_INPUT_KANJI_ENCODING=0" + .. os_concat .. + realengine .. format .. " " + .. checkopts .. " " .. asciiopt .. lvtfile .. (hide and (" > " .. os_null) or "") ) end @@ -1049,7 +1136,7 @@ function runtool(envvar, command) .. relpath(localdir, typesetdir) .. (typesetsearch and os_pathsep or "") .. os_concat .. - command + command ) ) end @@ -1089,7 +1176,7 @@ function bibtex(name) os_setenv .. " BSTINPUTS=." .. os_pathsep .. relpath(localdir, typesetdir) .. (typesetsearch and os_pathsep or "") .. - os_concat .. + os_concat .. bibtexexe .. " " .. bibtexopts .. " " .. name ) ) @@ -1220,7 +1307,7 @@ function check(names) local errlevel = runcheck(name, hide) -- Return value must be 1 not errlevel if errlevel ~= 0 then - if opthalt then + if opthalt then return 1 else errorlevel = 1 @@ -1287,7 +1374,7 @@ function cmdcheck() os_setenv .. " TEXINPUTS=." .. os_pathsep .. localdir .. os_pathsep .. os_concat .. - engine .. " " .. cmdchkopts .. + engine .. " " .. cmdchkopts .. " \"\\PassOptionsToClass{check}{l3doc} \\input " .. j .. "\"" .. " > " .. os_null ) @@ -1318,11 +1405,11 @@ function ctan(standalone) -- First, zip up all of the text files run( dir, - zipexe .. " " .. zipopts .. " -ll ".. zipname .. " " .. "." - .. ( + zipexe .. " " .. zipopts .. " -ll ".. zipname .. " " .. "." + .. ( (binfiles or exclude) and (" -x" .. binfiles .. " " .. exclude) or "" - ) + ) ) -- Then add the binary ones run( @@ -1447,7 +1534,7 @@ function doc(files) local errorlevel = typesetpdf(j) if errorlevel ~= 0 then return errorlevel - end + end end end end @@ -1539,7 +1626,7 @@ bundleunpack = bundleunpack or function(sourcedir) os_setenv .. " TEXINPUTS=." .. os_pathsep .. localdir .. (unpacksearch and os_pathsep or "") .. os_concat .. - unpackexe .. " " .. unpackopts .. " " .. j .. " < " + unpackexe .. " " .. unpackopts .. " " .. j .. " < " .. localdir .. "/yes" ) end -- cgit v1.2.3