From e0c5d6d38a1f285f20a66692e46d2e607d6ff1dd Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 14 May 2017 22:40:58 +0000 Subject: l3 (14may17) git-svn-id: svn://tug.org/texlive/trunk@44351 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/l3build/l3build.lua | 742 ++++++------ .../tex/latex/l3experimental/l3str/l3intarray.sty | 104 ++ .../latex/l3experimental/l3str/l3regex-trace.sty | 643 ++++++----- .../tex/latex/l3experimental/l3str/l3regex.sty | 641 ++++++----- .../latex/l3experimental/l3str/l3str-convert.sty | 38 +- .../l3experimental/l3str/l3str-enc-iso88591.def | 2 +- .../l3experimental/l3str/l3str-enc-iso885910.def | 2 +- .../l3experimental/l3str/l3str-enc-iso885911.def | 2 +- .../l3experimental/l3str/l3str-enc-iso885913.def | 2 +- .../l3experimental/l3str/l3str-enc-iso885914.def | 2 +- .../l3experimental/l3str/l3str-enc-iso885915.def | 2 +- .../l3experimental/l3str/l3str-enc-iso885916.def | 2 +- .../l3experimental/l3str/l3str-enc-iso88592.def | 2 +- .../l3experimental/l3str/l3str-enc-iso88593.def | 2 +- .../l3experimental/l3str/l3str-enc-iso88594.def | 2 +- .../l3experimental/l3str/l3str-enc-iso88595.def | 2 +- .../l3experimental/l3str/l3str-enc-iso88596.def | 2 +- .../l3experimental/l3str/l3str-enc-iso88597.def | 2 +- .../l3experimental/l3str/l3str-enc-iso88598.def | 2 +- .../l3experimental/l3str/l3str-enc-iso88599.def | 2 +- .../latex/l3experimental/l3str/l3str-enc-utf16.def | 2 +- .../latex/l3experimental/l3str/l3str-enc-utf32.def | 2 +- .../latex/l3experimental/l3str/l3str-enc-utf8.def | 2 +- .../latex/l3experimental/l3str/l3str-esc-hex.def | 2 +- .../latex/l3experimental/l3str/l3str-esc-name.def | 2 +- .../l3experimental/l3str/l3str-esc-string.def | 2 +- .../latex/l3experimental/l3str/l3str-esc-url.def | 2 +- .../latex/l3experimental/l3str/l3str-format.sty | 4 +- .../latex/l3experimental/l3str/l3tl-analysis.sty | 21 +- .../tex/latex/l3experimental/l3str/l3tl-build.sty | 8 +- .../tex/latex/l3experimental/xcoffins/xcoffins.sty | 2 +- .../tex/latex/l3experimental/xgalley/l3galley.sty | 8 +- .../tex/latex/l3experimental/xgalley/xgalley.sty | 2 +- .../texmf-dist/tex/latex/l3kernel/expl3-code.tex | 1191 ++++++++++---------- .../tex/latex/l3kernel/expl3-generic.tex | 3 +- Master/texmf-dist/tex/latex/l3kernel/expl3.sty | 24 +- Master/texmf-dist/tex/latex/l3kernel/l3basics.sty | 1 + .../texmf-dist/tex/latex/l3kernel/l3bootstrap.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3box.sty | 1 + .../texmf-dist/tex/latex/l3kernel/l3candidates.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3clist.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3coffins.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3color.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3doc.cls | 4 +- .../texmf-dist/tex/latex/l3kernel/l3dvipdfmx.def | 67 +- Master/texmf-dist/tex/latex/l3kernel/l3expan.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3file.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3fp.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3int.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3keys.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3msg.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3names.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def | 50 +- Master/texmf-dist/tex/latex/l3kernel/l3prg.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3prop.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3quark.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3seq.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3skip.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3sort.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3str.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3tl.sty | 1 + Master/texmf-dist/tex/latex/l3kernel/l3token.sty | 1 + .../texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def | 95 +- .../tex/latex/l3packages/l3keys2e/l3keys2e.sty | 6 +- Master/texmf-dist/tex/latex/l3packages/xfp/xfp.sty | 6 +- .../tex/latex/l3packages/xfrac/xfrac.sty | 6 +- .../tex/latex/l3packages/xparse/xparse.sty | 101 +- .../tex/latex/l3packages/xtemplate/xtemplate.sty | 6 +- 68 files changed, 2091 insertions(+), 1748 deletions(-) create mode 100644 Master/texmf-dist/tex/latex/l3experimental/l3str/l3intarray.sty (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 b3d55b0fb00..f514429cf7d 100644 --- a/Master/texmf-dist/tex/latex/l3build/l3build.lua +++ b/Master/texmf-dist/tex/latex/l3build/l3build.lua @@ -22,8 +22,8 @@ for those people who are interested. --]] --- Version information: should be identical to that in l3build.dtx -release_date = "2017/04/01" +-- Version information +release_date = "2017/05/13" -- "module" is a deprecated function in Lua 5.2: as we want the name -- for other purposes, and it should eventually be 'free', simply @@ -38,7 +38,7 @@ bundle = bundle or "" -- Sanity check if module == "" and bundle == "" then - if string.match(arg[0], ".*l3build%.lua$") then + if string.match(arg[0], "l3build%.lua$") then print( "\n" .. "Error: Call l3build using a configuration file, not directly.\n" @@ -57,7 +57,7 @@ end maindir = maindir or "." -- Substructure for tests and support files -testfiledir = testfiledir or "testfiles" -- Set to "" to cancel any tests +testfiledir = testfiledir or "testfiles" testsuppdir = testsuppdir or testfiledir .. "/support" supportdir = supportdir or maindir .. "/support" @@ -113,7 +113,7 @@ unpackdeps = unpackdeps or { } -- Executable names plus following options typesetexe = typesetexe or "pdflatex" unpackexe = unpackexe or "tex" -zipexe = "zip" +zipexe = zipexe or "zip" checkopts = checkopts or "-interaction=nonstopmode" cmdchkopts = cmdchkopts or "-interaction=batchmode" @@ -128,7 +128,6 @@ stdengine = stdengine or "pdftex" -- Enable access to trees outside of the repo -- As these may be set false, a more elaborate test than normal is needed --- here if checksearch == nil then checksearch = true end @@ -156,8 +155,8 @@ asciiengines = asciiengines or {"pdftex"} checkruns = checkruns or 1 epoch = epoch or 1463734800 maxprintline = maxprintline or 79 -packtdszip = packtdszip or false -- Not actually needed but clearer -scriptname = scriptname or "build.lua" -- Script used in each directory +packtdszip = packtdszip or false +scriptname = scriptname or "build.lua" typesetcmds = typesetcmds or "" versionform = versionform or "" @@ -171,11 +170,50 @@ pdfext = pdfext or ".pdf" psext = psext or ".ps" tlgext = tlgext or ".tlg" --- Run time options --- These are parsed into a global table, and all optional args --- are made available as a related global var - -function argparse() +-- File operations are aided by the LuaFileSystem module +local lfs = require("lfs") + +-- Local access to functions +local assert = assert +local ipairs = ipairs +local next = next +local print = print +local select = select +local tonumber = tonumber +local close = io.close +local lines = io.lines +local open = io.open +local output = io.output +local stderr = io.stderr +local write = io.write +local set_program_name = kpse.set_program_name +local var_value = kpse.var_value +local lfs_attributes = lfs.attributes +local lfs_dir = lfs.dir +local os_date = os.date +local execute = os.execute +local exit = os.exit +local getenv = os.getenv +local os_remove = os.remove +local os_type = os.type +local luatex_revision = status.luatex_revision +local luatex_version = status.luatex_version +local char = string.char +local find = string.find +local format = string.format +local gmatch = string.gmatch +local gsub = string.gsub +local len = string.len +local match = string.match +local sub = string.sub +local concat = table.concat +local insert = table.insert +local utf8_char = unicode.utf8.char + +-- Parse command line options +-- This is done as a function (rather than do ... end) as it allows early +-- termination (break) +local function argparse() local result = { } local files = { } local long_options = @@ -212,6 +250,7 @@ function argparse() release = true, testfiledir = true } + local args = args -- arg[1] is a special case: must be a command or "-h"/"--help" -- Deal with this by assuming help and storing only apparently-valid -- input @@ -219,7 +258,7 @@ function argparse() result["target"] = "help" if a then -- No options are allowed in position 1, so filter those out - if not string.match(a, "^%-") then + if not match(a, "^%-") then result["target"] = a end end @@ -231,7 +270,7 @@ function argparse() local function remainder(num) local files = { } for i = num, #arg do - table.insert(files, arg[i]) + insert(files, arg[i]) end return files end @@ -247,25 +286,26 @@ function argparse() break end -- Look for optionals - local opt, optarg + local opt + local optarg local opts -- Look for and option and get it into a variable - if string.match(a, "^%-") then - if string.match(a, "^%-%-") then + if match(a, "^%-") then + if match(a, "^%-%-") then opts = long_options - local pos = string.find(a, "=", 1, true) + local pos = find(a, "=", 1, true) if pos then - opt = string.sub(a, 3, pos - 1) - optarg = string.sub(a, pos + 1) + opt = sub(a, 3, pos - 1) + optarg = sub(a, pos + 1) else - opt = string.sub(a,3) + opt = sub(a, 3) end else opts = short_options - opt = string.sub(a, 2, 2) + opt = sub(a, 2, 2) -- Only set optarg if it is there if #a > 2 then - optarg = string.sub(a, 3) + optarg = sub(a, 3) end end -- Now check that the option is valid and sort out the argument @@ -277,25 +317,24 @@ function argparse() if reqarg and not optarg then optarg = arg[i + 1] if not optarg then - io.stderr:write("Missing value for option " .. a .."\n") + stderr:write("Missing value for option " .. a .."\n") return {"help"} end i = i + 1 end if not reqarg and optarg then - io.stderr:write("Value not allowed for option " .. a .."\n") + stderr:write("Value not allowed for option " .. a .."\n") return {"help"} end else - io.stderr:write("Unknown option " .. a .."\n") + stderr:write("Unknown option " .. a .."\n") return {"help"} end -- Store the result if optarg then local opts = result[optname] or { } - local match - for match in string.gmatch(optarg, "([^,%s]+)") do - table.insert(opts, match) + for hit in gmatch(optarg, "([^,%s]+)") do + insert(opts, hit) end result[optname] = opts else @@ -312,15 +351,14 @@ function argparse() return result end -userargs = argparse() +options = argparse() -optdate = userargs["date"] -optengines = userargs["engine"] -opthalt = userargs["halt"] -opthelp = userargs["help"] -optpdf = userargs["pdf"] -optquiet = userargs["quiet"] -optrelease = userargs["release"] +local optdate = options["date"] +local optengines = options["engine"] +local opthalt = options["halt"] +local optpdf = options["pdf"] +local optquiet = options["quiet"] +local optrelease = options["release"] -- Convert a file glob into a pattern for use by e.g. string.gub -- Based on https://github.com/davidm/lua-glob-pattern @@ -353,7 +391,7 @@ optrelease = userargs["release"] (end license) --]] -function glob_to_pattern(glob) +local function glob_to_pattern(glob) local pattern = "^" -- pattern being built local i = 0 -- index in glob @@ -361,13 +399,13 @@ function glob_to_pattern(glob) -- escape pattern char local function escape(char) - return string.match(char, "^%w$") and char or "%" .. char + return match(char, "^%w$") and char or "%" .. char end -- Convert tokens. while true do i = i + 1 - char = string.sub(glob, i, i) + char = sub(glob, i, i) if char == "" then pattern = pattern .. "$" break @@ -380,7 +418,7 @@ function glob_to_pattern(glob) print("[...] syntax not supported in globs!") elseif char == "\\" then i = i + 1 - char = string.sub(glob, i, i) + char = sub(glob, i, i) if char == "" then pattern = pattern .. "\\$" break @@ -393,52 +431,41 @@ function glob_to_pattern(glob) return pattern end --- File operation support --- Much of this is OS-dependent as Lua offers a very limited range of file --- operations 'natively'. - -- Detect the operating system in use -- Support items are defined here for cases where a single string can cover -- both Windows and Unix cases: more complex situations are handled inside -- the support functions -if os.type == "windows" then - os_ascii = "@echo." - os_cmpexe = os.getenv("cmpexe") or "fc /b" - os_cmpext = os.getenv("cmpext") or ".cmp" - os_concat = "&" - os_diffext = os.getenv("diffext") or ".fc" - os_diffexe = os.getenv("diffexe") or "fc /n" - os_grepexe = "findstr /r" - os_newline = "\n" - if tonumber(status.luatex_version) < 100 or - (tonumber(status.luatex_version) == 100 - and tonumber(status.luatex_revision) < 4) then +os_concat = ";" +os_null = "/dev/null" +os_pathsep = ":" +os_setenv = "export" +os_yes = "printf 'y\\n%.0s' {1..200}" +local os_ascii = "echo \"\"" +local os_cmpexe = getenv("cmpexe") or "cmp" +local os_cmpext = getenv("cmpext") or ".cmp" +local os_diffext = getenv("diffext") or ".diff" +local os_diffexe = getenv("diffexe") or "diff -c --strip-trailing-cr" +local os_grepexe = "grep" +local 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 os_newline = "\r\n" end - os_null = "nul" - os_pathsep = ";" - os_setenv = "set" - os_windows = true - os_yes = "for /l %I in (1,1,200) do @echo y" -else - os_ascii = "echo \"\"" - os_cmpexe = os.getenv("cmpexe") or "cmp" - os_cmpext = os.getenv("cmpext") or ".cmp" - os_concat = ";" - 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" - os_pathsep = ":" - os_setenv = "export" - os_windows = false - os_yes = "printf 'y\\n%.0s' {1..200}" -end - --- File operations are aided by the LuaFileSystem module, which is available --- within texlua -lfs = require("lfs") + os_null = "nul" + os_pathsep = ";" + os_setenv = "set" + os_yes = "for /l %I in (1,1,200) do @echo y" +end -- For cleaning out a directory, which also ensures that it exists function cleandir(dir) @@ -454,20 +481,20 @@ function cp(glob, source, dest) local errorlevel for _,i in ipairs(filelist(source, glob)) do local source = source .. "/" .. i - if os_windows then - if lfs.attributes(source)["mode"] == "directory" then - errorlevel = os.execute( + if os_type == "windows" then + if lfs_attributes(source)["mode"] == "directory" then + errorlevel = execute( "xcopy /y /e /i " .. unix_to_win(source) .. " " .. unix_to_win(dest .. "/" .. i) .. " > nul" ) else - errorlevel = os.execute( + errorlevel = execute( "xcopy /y " .. unix_to_win(source) .. " " .. unix_to_win(dest) .. " > nul" ) end else - errorlevel = os.execute("cp -rf " .. source .. " " .. dest) + errorlevel = execute("cp -rf " .. source .. " " .. dest) end if errorlevel ~=0 then return errorlevel @@ -479,11 +506,11 @@ end -- OS-dependent test for a directory function direxists(dir) local errorlevel - if os_windows then + if os_type == "windows" then errorlevel = - os.execute("if not exist \"" .. unix_to_win(dir) .. "\" exit 1") + execute("if not exist \"" .. unix_to_win(dir) .. "\" exit 1") else - errorlevel = os.execute("[ -d " .. dir .. " ]") + errorlevel = execute("[ -d " .. dir .. " ]") end if errorlevel ~= 0 then return false @@ -492,9 +519,9 @@ function direxists(dir) end function fileexists(file) - local f = io.open(file, "r") + local f = open(file, "r") if f ~= nil then - io.close(f) + close(f) return true else return false @@ -503,7 +530,6 @@ end -- Generate a table containing all file names of the given glob or all files -- if absent --- Not actually OS-dependent but in the same area function filelist(path, glob) local files = { } local pattern @@ -511,14 +537,14 @@ function filelist(path, glob) pattern = glob_to_pattern(glob) end if direxists(path) then - for entry in lfs.dir(path) do + for entry in lfs_dir(path) do if pattern then - if string.match(entry, pattern) then - table.insert(files, entry) + if match(entry, pattern) then + insert(files, entry) end else if entry ~= "." and entry ~= ".." then - table.insert(files, entry) + insert(files, entry) end end end @@ -527,57 +553,43 @@ function filelist(path, glob) end function mkdir(dir) - if os_windows then + if os_type == "windows" then -- Windows (with the extensions) will automatically make directory trees -- but issues a warning if the dir already exists: avoid by including a test local dir = unix_to_win(dir) - return os.execute( + return execute( "if not exist " .. dir .. "\\nul " .. "mkdir " .. dir ) else - return os.execute("mkdir -p " .. dir) + return execute("mkdir -p " .. dir) end end --- Find the relationship between two directories -function relpath(target, source) - -- A shortcut for the case where the two are the same - if target == source then - return "" - end - local resultdir = "" - local trimpattern = "^[^/]*/" - -- Trim off identical leading directories - 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 - for i = 0, select(2, string.gsub(target, "/", "")) do - resultdir = resultdir .. "../" - end - -- Return the relative part plus the unique part of the target - return resultdir .. target +-- Return an absolute path from a relative one +function abspath(path) + local oldpwd = lfs.currentdir() + lfs.chdir(path) + local result = lfs.currentdir() + lfs.chdir(oldpwd) + return result end -- Rename function ren(dir, source, dest) local dir = dir .. "/" - if os_windows then - return os.execute("ren " .. unix_to_win(dir) .. source .. " " .. dest) + if os_type == "windows" then + return execute("ren " .. unix_to_win(dir) .. source .. " " .. dest) else - return os.execute("mv " .. dir .. source .. " " .. dir .. dest) + return execute("mv " .. dir .. source .. " " .. dir .. dest) end end -- Remove file(s) based on a glob function rm(source, glob) for _,i in ipairs(filelist(source, glob)) do - os.remove(source .. "/" .. i) + os_remove(source .. "/" .. i) end - -- os.remove doesn't give a sensible errorlevel + -- os_remove doesn't give a sensible errorlevel return 0 end @@ -585,21 +597,21 @@ end function rmdir(dir) -- First, make sure it exists to avoid any errors mkdir(dir) - if os_windows then - return os.execute("rmdir /s /q " .. unix_to_win(dir)) + if os_type == "windows" then + return execute("rmdir /s /q " .. unix_to_win(dir)) else - return os.execute("rm -r " .. dir) + return execute("rm -r " .. dir) end end -- Run a command in a given directory function run(dir, cmd) - return os.execute("cd " .. dir .. os_concat .. cmd) + return execute("cd " .. dir .. os_concat .. cmd) end -- Deal with the fact that Windows and Unix use different path separators function unix_to_win(path) - return string.gsub(path, "/", "\\") + return gsub(path, "/", "\\") end -- @@ -607,25 +619,25 @@ end -- -- Do some subtarget for all modules in a bundle -function allmodules(target) +local function allmodules(target) + local date = "" + if optdate then + date = " --date=" .. optdate[1] + end + local engines = "" + if optengines then + engines = " --engine=" .. concat(optengines, ",") + end + local release = "" + if optrelease then + release = " --release=" .. optrelease[1] + end for _,i in ipairs(modules) do print( "Running script " .. scriptname .. " with target \"" .. target .. "\" for module " .. i ) - local date = "" - if optdate then - date = " --date=" .. optdate[1] - end - local engines = "" - if optengines then - engines = " --engine=" .. table.concat(optengines, ",") - end - local release = "" - if optrelease then - release = " --release=" .. optrelease[1] - end local errorlevel = run( i, "texlua " .. scriptname .. " " .. target @@ -645,7 +657,7 @@ end -- Set up the check system files: needed for checking one or more tests and -- for saving the test files -function checkinit() +local function checkinit() cleandir(testdir) depinstall(checkdeps) -- Copy dependencies to the test directory itself: this makes the paths @@ -669,7 +681,7 @@ function checkinit() for _,i in ipairs(checksuppfiles) do cp(i, supportdir, testdir) end - os.execute(os_ascii .. ">" .. testdir .. "/ascii.tcx") + execute(os_ascii .. ">" .. testdir .. "/ascii.tcx") end -- Copy files to the main CTAN release directory @@ -709,18 +721,18 @@ function copytds() moduledir = module end end - local installdir = tdsdir .. "/" .. dest .. "/" .. moduledir -- Convert the file table(s) to a list of individual files local filenames = { } for _,i in ipairs(files) do for _,j in ipairs(i) do for _,k in ipairs(filelist(source, j)) do - table.insert(filenames, k) + insert(filenames, k) end end end -- The target is only created if there are actual files to install if next(filenames) ~= nil then + local installdir = tdsdir .. "/" .. dest .. "/" .. moduledir mkdir(installdir) for _,i in ipairs(filenames) do cp(i, source, installdir) @@ -753,21 +765,21 @@ end -- Convert the raw log file into one for comparison/storage: keeps only -- the 'business' part from the tests and removes system-dependent stuff -function formatlog(logfile, newfile, engine) +local function formatlog(logfile, newfile, engine) local maxprintline = maxprintline if engine == "luatex" or engine == "luajittex" then maxprintline = maxprintline + 1 -- Deal with an out-by-one error end local function killcheck(line) -- Skip lines containing file dates - if string.match(line, "[^<]%d%d%d%d/%d%d/%d%d") then + if match(line, "[^<]%d%d%d%d/%d%d/%d%d") then return true elseif -- Skip \openin/\openout lines in web2c 7.x -- As Lua doesn't allow "(in|out)", a slightly complex approach: -- do a substitution to check the line is exactly what is required! - string.match( - string.gsub(line, "^\\openin", "\\openout"), "^\\openout%d%d? = " + match( + gsub(line, "^\\openin", "\\openout"), "^\\openout%d%d? = " ) then return true end @@ -777,13 +789,13 @@ function formatlog(logfile, newfile, engine) local function normalize(line, lastline) -- Zap line numbers from \show, \showbox, \box_show and the like: -- do this before wrapping lines - line = string.gsub(line, "^l%.%d+ ", "l. ...") + line = gsub(line, "^l%.%d+ ", "l. ...") -- Also from lua stack traces. - line = string.gsub(line, "lua:%d+: in function", "lua:...: in function") + line = gsub(line, "lua:%d+: in function", "lua:...: in function") -- Allow for wrapped lines: preserve the content and wrap -- Skip lines that have an explicit marker for truncation - if string.len(line) == maxprintline and - not string.match(line, "%.%.%.$") then + if len(line) == maxprintline and + not match(line, "%.%.%.$") then return "", (lastline or "") .. line end local line = (lastline or "") .. line @@ -792,77 +804,76 @@ function formatlog(logfile, newfile, engine) -- This needs to extract the base name from the log name, -- and one to allow for the case that there might be "-" chars -- in the name (other cases are ignored) - line = string.gsub( + line = gsub( line, - string.gsub( - string.match("/" .. logfile, ".*/(.*)%" .. logext .. "$"), + gsub( + match("/" .. logfile, ".*/(.*)%" .. logext .. "$"), "-", "%%-" ), "" ) -- Zap ./ at begin of filename - line = string.gsub(line, "%(%.%/", "(") + line = gsub(line, "%(%.%/", "(") -- Zap paths if places other than 'here' are accessible if checksearch then local pattern = "%w?:?/[^ ]*/([^/%(%)]*%.%w*)" -- Files loaded from TeX: all start ( -- ) - line = string.gsub(line, "%(" .. pattern, "(../%1") + line = gsub(line, "%(" .. pattern, "(../%1") -- luaotfload files start with keywords - line = string.gsub(line, "from " .. pattern .. "%(", "from. ./%1(") - line = string.gsub(line, ": " .. pattern .. "%)", ": ../%1)") + line = gsub(line, "from " .. pattern .. "%(", "from. ./%1(") + line = gsub(line, ": " .. pattern .. "%)", ": ../%1)") end -- Deal with the fact that "(.aux)" may have still a leading space - line = string.gsub(line, "^ %(%.aux%)", "(.aux)") + line = gsub(line, "^ %(%.aux%)", "(.aux)") -- Merge all of .fd data into one line so will be removed later - if string.match(line, "^ *%([%.%/%w]+%.fd[^%)]*$") then + if match(line, "^ *%([%.%/%w]+%.fd[^%)]*$") then lastline = (lastline or "") .. line return "", (lastline or "") .. line end -- TeX90/XeTeX knows only the smaller set of dimension units - line = string.gsub( + line = gsub( line, "cm, mm, dd, cc, bp, or sp", "cm, mm, dd, cc, nd, nc, bp, or sp" ) -- Normalise a case where fixing a TeX bug changes the message text - line = string.gsub(line, "\\csname\\endcsname ", "\\csname\\endcsname") + line = gsub(line, "\\csname\\endcsname ", "\\csname\\endcsname") -- Zap "on line " and replace with "on line ..." -- Two similar cases, Lua patterns mean we need to do them separately - line = string.gsub(line, "on line %d*", "on line ...") - line = string.gsub(line, "on input line %d*", "on input line ...") + line = gsub(line, "on line %d*", "on line ...") + line = gsub(line, "on input line %d*", "on input line ...") -- Tidy up to ^^ notation for i = 0, 31 do - line = string.gsub(line, string.char(i), "^^" .. string.char(64 + i)) + line = gsub(line, char(i), "^^" .. char(64 + i)) end -- Remove 'normal' direction information on boxes with (u)pTeX - line = string.gsub(line, ",? yoko direction,?", "") + line = gsub(line, ",? yoko direction,?", "") -- Remove the \special line that in DVI mode keeps PDFs comparable - if string.match(line, "^%.*\\special%{pdf: docinfo << /Creator") then + if match(line, "^%.*\\special%{pdf: docinfo << /Creator") then return "" end -- Remove the \special line possibly present in DVI mode for paper size - if string.match(line, "^%.*\\special%{papersize") then + if match(line, "^%.*\\special%{papersize") then return "" end -- Remove ConTeXt stuff - if string.match(line, "^backend >") or - string.match(line, "^close source >") or - string.match(line, "^mkiv lua stats >") or - string.match(line, "^pages >") or - string.match(line, "^system >") or - string.match(line, "^used file >") or - string.match(line, "^used option >") or - string.match(line, "^used structure >") then + if match(line, "^backend >") or + match(line, "^close source >") or + match(line, "^mkiv lua stats >") or + match(line, "^pages >") or + match(line, "^system >") or + match(line, "^used file >") or + match(line, "^used option >") or + match(line, "^used structure >") then return "" end -- A tidy-up to keep LuaTeX and other engines in sync - local utf8_char = unicode.utf8.char - line = string.gsub(line, utf8_char(127), "^^?") + line = gsub(line, utf8_char(127), "^^?") -- Unicode engines display chars in the upper half of the 8-bit range: -- 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)) + line = gsub(line, utf8_char(i), "^^" .. format("%02x", i)) end end return line, lastline @@ -872,74 +883,74 @@ function formatlog(logfile, newfile, engine) local prestart = true local skipping = false -- Read the entire log file as a binary: deals with ^@/^[, etc. - local file = assert(io.open(logfile, "rb")) - local contents = string.gsub(file:read("*all") .. "\n", "\r\n", "\n") - io.close(file) - for line in string.gmatch(contents, "([^\n]*)\n") do + local file = assert(open(logfile, "rb")) + local contents = gsub(file:read("*all") .. "\n", "\r\n", "\n") + close(file) + for line in gmatch(contents, "([^\n]*)\n") do if line == "START-TEST-LOG" then prestart = false elseif line == "END-TEST-LOG" then break elseif line == "OMIT" then skipping = true - elseif string.match(line, "^%)?TIMO$") then + elseif match(line, "^%)?TIMO$") then skipping = false elseif not prestart and not skipping then line, lastline = normalize(line, lastline) - if not string.match(line, "^ *$") and not killcheck(line) then + if not match(line, "^ *$") and not killcheck(line) then newlog = newlog .. line .. os_newline end end end - local newfile = io.open(newfile, "w") - io.output(newfile) - io.write(newlog) - io.close(newfile) + local newfile = open(newfile, "w") + output(newfile) + write(newlog) + close(newfile) end -- Additional normalization for LuaTeX -function formatlualog(logfile, newfile) +local function formatlualog(logfile, newfile) local function normalize(line, lastline, dropping) -- Find \discretionary or \whatsit lines: -- These may come back later - if string.match(line, "^%.+\\discretionary$") or - string.match(line, "^%.+\\discretionary %(penalty 50%)$") or - string.match(line, "^%.+\\discretionary50%|$") or - string.match(line, "^%.+\\discretionary50%| replacing $") or - string.match(line, "^%.+\\whatsit$") then + if match(line, "^%.+\\discretionary$") or + match(line, "^%.+\\discretionary %(penalty 50%)$") or + match(line, "^%.+\\discretionary50%|$") or + match(line, "^%.+\\discretionary50%| replacing $") or + match(line, "^%.+\\whatsit$") then return "", line end -- For \mathon, we always need this line but the next -- may be affected - if string.match(line, "^%.+\\mathon$") then + if match(line, "^%.+\\mathon$") then return line, line end -- LuaTeX has a flexible output box - line = string.gsub(line,"\\box\\outputbox", "\\box255") + line = gsub(line,"\\box\\outputbox", "\\box255") -- LuaTeX identifies spaceskip glue - line = string.gsub(line,"%(\\spaceskip%) ", " ") + line = gsub(line,"%(\\spaceskip%) ", " ") -- Remove 'display' at end of display math boxes: -- LuaTeX omits this as it includes direction in all cases - line = string.gsub(line, "(\\hbox%(.*), display$", "%1") + line = gsub(line, "(\\hbox%(.*), display$", "%1") -- Remove 'normal' direction information on boxes: -- any bidi/vertical stuff will still show - line = string.gsub(line, ", direction TLT", "") + line = gsub(line, ", direction TLT", "") -- Find glue setting and round out the last place local function round_digits(l, m) - return string.gsub( + return gsub( l, m .. " (%-?)%d+%.%d+", m .. " %1" - .. string.format( + .. format( "%.3f", - string.match(line, m .. " %-?(%d+%.%d+)") or 0 + match(line, m .. " %-?(%d+%.%d+)") or 0 ) ) end - if string.match(line, "glue set %-?%d+%.%d+") then + if match(line, "glue set %-?%d+%.%d+") then line = round_digits(line, "glue set") end - if string.match( + if match( line, "glue %-?%d+%.%d+ plus %-?%d+%.%d+ minus %-?%d+%.%d+$" ) then @@ -948,35 +959,35 @@ function formatlualog(logfile, newfile) line = round_digits(line, "minus") end -- LuaTeX writes ^^M as a new line, which we lose - line = string.gsub(line, "%^%^M", "") + line = gsub(line, "%^%^M", "") -- Remove U+ notation in the "Missing character" message - line = string.gsub( + line = 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, "^(%.+)"), "%.", "%%.") + return gsub(match(s, "^(%.+)"), "%.", "%%.") end -- 'Recover' some discretionary data - if string.match(lastline, "^%.+\\discretionary %(penalty 50%)$") and - string.match(line, boxprefix(lastline) .. "%.= ") then - return string.gsub(line, "%.= ", ""),"" + if match(lastline, "^%.+\\discretionary %(penalty 50%)$") and + match(line, boxprefix(lastline) .. "%.= ") then + return gsub(line, "%.= ", ""),"" end -- Where the last line was a discretionary, looks for the -- info one level in about what it represents - if string.match(lastline, "^%.+\\discretionary$") or - string.match(lastline, "^%.+\\discretionary %(penalty 50%)$") or - string.match(lastline, "^%.+\\discretionary50%|$") or - string.match(lastline, "^%.+\\discretionary50%| replacing $") then + if match(lastline, "^%.+\\discretionary$") or + match(lastline, "^%.+\\discretionary %(penalty 50%)$") or + match(lastline, "^%.+\\discretionary50%|$") or + match(lastline, "^%.+\\discretionary50%| replacing $") then local prefix = boxprefix(lastline) - if string.match(line, prefix .. "%.") or - string.match(line, prefix .. "%|") then - if string.match(lastline, " replacing $") and + if match(line, prefix .. "%.") or + match(line, prefix .. "%|") then + if match(lastline, " replacing $") and not dropping then -- Modify the return line - return string.gsub(line, "^%.", ""), lastline, true + return gsub(line, "^%.", ""), lastline, true else return "", lastline, true end @@ -986,11 +997,11 @@ function formatlualog(logfile, newfile) return line, "" else -- Not quite a normal discretionary - if string.match(lastline, "^%.+\\discretionary50%|$") then - lastline = string.gsub(lastline, "50%|$", "") + if match(lastline, "^%.+\\discretionary50%|$") then + lastline = gsub(lastline, "50%|$", "") end -- Remove some info that TeX90 lacks - lastline = string.gsub(lastline, " %(penalty 50%)$", "") + lastline = gsub(lastline, " %(penalty 50%)$", "") -- A normal (TeX90) discretionary: -- add with the line break reintroduced return lastline .. os_newline .. line, "" @@ -999,13 +1010,13 @@ function formatlualog(logfile, newfile) end -- Look for another form of \discretionary, replacing a "-" pattern = "^%.+\\discretionary replacing *$" - if string.match(line, pattern) then + if match(line, pattern) then return "", line else - if string.match(lastline, pattern) then + if match(lastline, pattern) then local prefix = boxprefix(lastline) - if string.match(line, prefix .. "%.\\kern") then - return string.gsub(line, "^%.", ""), lastline, true + if match(line, prefix .. "%.\\kern") then + return gsub(line, "^%.", ""), lastline, true elseif dropping then return "", "" else @@ -1015,26 +1026,26 @@ function formatlualog(logfile, newfile) end -- For \mathon, if the current line is an empty \hbox then -- drop it - if string.match(lastline, "^%.+\\mathon$") then + if match(lastline, "^%.+\\mathon$") then local prefix = boxprefix(lastline) - if string.match(line, prefix .. "\\hbox%(0%.0%+0%.0%)x0%.0$") then + if match(line, prefix .. "\\hbox%(0%.0%+0%.0%)x0%.0$") then return "", "" end end -- Various \local... things that other engines do not do: -- Only remove the no-op versions - if string.match(line, "^%.+\\localpar$") or - string.match(line, "^%.+\\localinterlinepenalty=0$") or - string.match(line, "^%.+\\localbrokenpenalty=0$") or - string.match(line, "^%.+\\localleftbox=null$") or - string.match(line, "^%.+\\localrightbox=null$") then + if match(line, "^%.+\\localpar$") or + match(line, "^%.+\\localinterlinepenalty=0$") or + match(line, "^%.+\\localbrokenpenalty=0$") or + match(line, "^%.+\\localleftbox=null$") or + match(line, "^%.+\\localrightbox=null$") then return "", "" end -- Older LuaTeX versions set the above up as a whatsit -- (at some stage this can therefore go) - if string.match(lastline, "^%.+\\whatsit$") then + if match(lastline, "^%.+\\whatsit$") then local prefix = boxprefix(lastline) - if string.match(line, prefix .. "%.") then + if match(line, prefix .. "%.") then return "", lastline, true else -- End of a \whatsit block @@ -1044,44 +1055,44 @@ function formatlualog(logfile, newfile) -- 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 - if string.len(line) == maxprintline then + if len(line) == maxprintline then return "", lastline .. line - elseif string.len(lastline) == maxprintline then - if string.match(line, "\\ETC%.%}$") then + elseif len(lastline) == maxprintline then + if match(line, "\\ETC%.%}$") then -- If the line wrapped at \ETC we might have lost a space return lastline - .. ((string.match(line, "^\\ETC%.%}$") and " ") or "") + .. ((match(line, "^\\ETC%.%}$") and " ") or "") .. line, "" - elseif string.match(line, "^%}%}%}$") then + elseif match(line, "^%}%}%}$") then return lastline .. line, "" else return lastline .. os_newline .. line, "" end -- Return all of the text for a wrapped (multi)line - elseif string.len(lastline) > maxprintline then + elseif len(lastline) > maxprintline then return lastline .. line, "" end -- Remove spaces at the start of lines: deals with the fact that LuaTeX -- uses a different number to the other engines - return string.gsub(line, "^%s+", ""), "" + return gsub(line, "^%s+", ""), "" end local newlog = "" local lastline = "" local dropping = false -- Read the entire log file as a binary: deals with ^@/^[, etc. - local file = assert(io.open(logfile, "rb")) - local contents = string.gsub(file:read("*all") .. "\n", "\r\n", "\n") - io.close(file) - for line in string.gmatch(contents, "([^\n]*)\n") do + local file = assert(open(logfile, "rb")) + local contents = gsub(file:read("*all") .. "\n", "\r\n", "\n") + close(file) + for line in gmatch(contents, "([^\n]*)\n") do line, lastline, dropping = normalize(line, lastline, dropping) - if not string.match(line, "^ *$") then + if not match(line, "^ *$") then newlog = newlog .. line .. os_newline end end - local newfile = io.open(newfile, "w") - io.output(newfile) - io.write(newlog) - io.close(newfile) + local newfile = open(newfile, "w") + output(newfile) + write(newlog) + close(newfile) end -- Look for files, directory by directory, and return the first existing @@ -1100,13 +1111,13 @@ end function listmodules() local modules = { } local exclmodules = exclmodules or { } - for entry in lfs.dir(".") do + for entry in lfs_dir(".") do if entry ~= "." and entry ~= ".." then - local attr = lfs.attributes(entry) + local attr = lfs_attributes(entry) assert(type(attr) == "table") if attr.mode == "directory" then if not exclmodules[entry] then - table.insert(modules, entry) + insert(modules, entry) end end end @@ -1167,7 +1178,7 @@ function setup_check(name, engine) "Error: failed to find " .. pdfext .. ", " .. tlgext .. " or " .. lveext .. " file for " .. name .. "!" ) - os.exit(1) + exit(1) end runtest(name, engine, true, lveext, true) pdffile = testdir .. "/" .. testname .. pdfext @@ -1181,19 +1192,19 @@ function setup_check(name, engine) for _,v in pairs({pdffile, tlgfile}) do if v then cp( - string.match(v, ".*/(.*)"), - string.match(v, "(.*)/.*"), + match(v, ".*/(.*)"), + match(v, "(.*)/.*"), testdir ) end end end if pdffile then - local pdffile = string.match(pdffile, ".*/(.*)") + local pdffile = match(pdffile, ".*/(.*)") ren( testdir, pdffile, - string.gsub(pdffile, pdfext .. "$", ".ref" .. pdfext) + gsub(pdffile, pdfext .. "$", ".ref" .. pdfext) ) return true else @@ -1212,14 +1223,14 @@ function compare_pdf(name, engine) if not refpdffile then return end - if os_windows then + if os_type == "windows" then refpdffile = unix_to_win(refpdffile) end - errorlevel = os.execute( + errorlevel = execute( os_cmpexe .. " " .. refpdffile .. " " .. pdffile .. " > " .. cmpfile ) if errorlevel == 0 then - os.remove(cmpfile) + os_remove(cmpfile) end return errorlevel end @@ -1233,18 +1244,18 @@ function compare_tlg(name, engine) if not tlgfile then return end - if os_windows then + if os_type == "windows" then tlgfile = unix_to_win(tlgfile) end -- Do additional log formatting if the engine is LuaTeX, there is no -- LuaTeX-specific .tlg file and the default engine is not LuaTeX if engine == "luatex" - and not string.match(tlgfile, "%.luatex" .. "%" .. tlgext) + and not match(tlgfile, "%.luatex" .. "%" .. tlgext) and stdengine ~= "luatex" and stdengine ~= "luajittex" then local luatlgfile = testdir .. "/" .. name .. ".luatex" .. tlgext - if os_windows then + if os_type == "windows" then luatlgfile = unix_to_win(luatlgfile) end formatlualog(tlgfile, luatlgfile) @@ -1252,11 +1263,11 @@ function compare_tlg(name, engine) -- This allows code sharing below: we only need the .tlg name in one place tlgfile = luatlgfile end - errorlevel = os.execute( + errorlevel = execute( os_diffexe .. " " .. tlgfile .. " " .. logfile .. " > " .. difffile ) if errorlevel == 0 then - os.remove(difffile) + os_remove(difffile) end return errorlevel end @@ -1272,31 +1283,31 @@ function runtest(name, engine, hide, ext, makepdf) local realengine = engine local format if - string.match(checkformat, "tex$") and - not string.match(engine, checkformat) then - format = " -fmt=" .. string.gsub(engine, "(.*)tex$", "%1") .. checkformat + match(checkformat, "tex$") and + not match(engine, checkformat) then + format = " -fmt=" .. gsub(engine, "(.*)tex$", "%1") .. checkformat else format = "" end -- Special casing for e-LaTeX format if - string.match(checkformat, "^latex$") and - string.match(engine, "^etex$") then + match(checkformat, "^latex$") and + match(engine, "^etex$") then format = " -fmt=latex" end -- Special casing for (u)pTeX LaTeX formats if - string.match(checkformat, "^latex$") and - string.match(engine, "^u?ptex$") then + match(checkformat, "^latex$") and + match(engine, "^u?ptex$") then realengine = "e" .. engine end -- Special casing for XeTeX engine local checkopts = checkopts - if string.match(engine, "xetex") and not makepdf then + if match(engine, "xetex") and not makepdf then checkopts = checkopts .. " -no-pdf" end -- Special casing for ConTeXt - if string.match(checkformat, "^context$") then + if match(checkformat, "^context$") then format = "" if engine == "luatex" or engine == "luajittex" then realengine = "context" @@ -1306,7 +1317,7 @@ function runtest(name, engine, hide, ext, makepdf) realengine = "texexec --xetex" else print("Engine incompatible with format") - os.exit(1) + exit(1) end end local logfile = testdir .. "/" .. name .. logext @@ -1349,12 +1360,12 @@ function runtest(name, engine, hide, ext, makepdf) formatlog(logfile, newfile, engine) -- Store secondary files for this engine for _,i in ipairs(filelist(testdir, name .. ".???")) do - local ext = string.match(i, "%....") + local ext = match(i, "%....") if ext ~= lvtext and ext ~= tlgext and ext ~= lveext and ext ~= logext then if not fileexists(testsuppdir .. "/" .. i) then ren( - testdir, i, string.gsub( - i, string.gsub(name, "%-", "%%-"), name .. "." .. engine + testdir, i, gsub( + i, gsub(name, "%-", "%%-"), name .. "." .. engine ) ) end @@ -1368,7 +1379,7 @@ runtest_tasks = runtest_tasks or function(name) end function dvitopdf(name, dir, engine, hide) - if string.match(engine, "^u?ptex$") then + if match(engine, "^u?ptex$") then run( dir, os_setenv .. " SOURCE_DATE_EPOCH=" .. epoch @@ -1392,7 +1403,13 @@ end -- Strip the extension from a file name (if present) function stripext(file) - local name = string.match(file, "^(.*)%.") + local name = match(file, "^(.*)%.") + return name or file +end + +-- Strip the path from a file name (if present) +function basename(file) + local name = match(file, "^.*/([^/]*)$") return name or file end @@ -1411,7 +1428,7 @@ function runtool(envvar, command) run( typesetdir, os_setenv .. " " .. envvar .. "=." .. os_pathsep - .. relpath(localdir, typesetdir) + .. abspath(localdir) .. (typesetsearch and os_pathsep or "") .. os_concat .. command @@ -1433,7 +1450,7 @@ function bibtex(name) -- LaTeX always generates an .aux file, so there is a need to -- look inside it for a \citation line local grep - if os_windows then + if os_type == "windows" then grep = "\\\\" else grep = "\\\\\\\\" @@ -1452,7 +1469,7 @@ function bibtex(name) runtool( "BIBINPUTS", os_setenv .. " BSTINPUTS=." .. os_pathsep - .. relpath(localdir, typesetdir) + .. abspath(localdir) .. (typesetsearch and os_pathsep or "") .. os_concat .. bibtexexe .. " " .. bibtexopts .. " " .. name @@ -1488,11 +1505,11 @@ function tex(file) end function typesetpdf(file) - local name = stripext(file) + local name = stripext(basename(file)) print("Typesetting " .. name) local errorlevel = typeset(file) if errorlevel == 0 then - os.remove(name .. ".pdf") + os_remove(name .. ".pdf") cp(name .. ".pdf", typesetdir, ".") else print(" ! Compilation failed") @@ -1505,7 +1522,7 @@ typeset = typeset or function(file) if errorlevel ~= 0 then return errorlevel else - local name = stripext(file) + local name = stripext(basename(file)) errorlevel = biber(name) + bibtex(name) if errorlevel == 0 then local function cycle(name) @@ -1572,14 +1589,14 @@ function check(names) -- No names passed: find all test files if not next(names) then for _,i in pairs(filelist(testfiledir, "*" .. lvtext)) do - table.insert(names, stripext(i)) + insert(names, stripext(i)) end for _,i in ipairs(filelist(unpackdir, "*" .. lvtext)) do if fileexists(testfiledir .. "/" .. i) then print("Duplicate test file: " .. i) return 1 else - table.insert(names, stripext(i)) + insert(names, stripext(i)) end end end @@ -1623,7 +1640,7 @@ function showfaileddiff() for _,i in ipairs(filelist(testdir, "*" .. os_diffext)) do print(" - " .. testdir .. "/" .. i) print("") - local f = io.open(testdir .. "/" .. i,"r") + local f = open(testdir .. "/" .. i,"r") local content = f:read("*all") f:close() print("-----------------------------------------------------------------------------------") @@ -1678,8 +1695,8 @@ function cmdcheck() for _,i in ipairs(typesetsuppfiles) do cp(i, supportdir, testdir) end - local engine = string.gsub(stdengine, "tex$", "latex") - local localdir = relpath(localdir, testdir) + local engine = gsub(stdengine, "tex$", "latex") + local localdir = abspath(localdir) print("Checking source files") for _,i in ipairs(cmdchkfiles) do for _,j in ipairs(filelist(".", i)) do @@ -1693,9 +1710,9 @@ function cmdcheck() " \"\\PassOptionsToClass{check}{l3doc} \\input " .. j .. "\"" .. " > " .. os_null ) - for line in io.lines(testdir .. "/" .. stripext(j) .. ".cmds") do - if string.match(line, "^%!") then - print(" - " .. string.match(line, "^%! (.*)")) + for line in lines(testdir .. "/" .. stripext(j) .. ".cmds") do + if match(line, "^%!") then + print(" - " .. match(line, "^%! (.*)")) end end end @@ -1793,7 +1810,7 @@ function bundlectan() for _,i in ipairs(include) do for _,j in ipairs(filelist(".", i)) do if not excludelist[j] then - table.insert(includelist, j) + insert(includelist, j) end end end @@ -1805,7 +1822,7 @@ function bundlectan() -- Work out what PDF files are available pdffiles = { } for _,i in ipairs(typesetfiles) do - table.insert(pdffiles, (string.gsub(i, "%.%w+$", ".pdf"))) + insert(pdffiles, (gsub(i, "%.%w+$", ".pdf"))) end typesetlist = excludelist(typesetfiles, {sourcefiles}) sourcelist = excludelist( @@ -1834,22 +1851,24 @@ function doc(files) unpack() -- Main loop for doc creation for _,i in ipairs(typesetfiles) do - for _,j in ipairs(filelist(".", i)) do - -- Allow for command line selection of files - local typeset = true - if files and next(files) then - typeset = false - for _,k in ipairs(files) do - if k == stripext(j) then - typeset = true - break + for _, dir in ipairs({unpackdir, typesetdir}) do + for _,j in ipairs(filelist(dir, i)) do + -- Allow for command line selection of files + local typeset = true + if files and next(files) then + typeset = false + for _,k in ipairs(files) do + if k == stripext(j) then + typeset = true + break + end end end - end - if typeset then - local errorlevel = typesetpdf(j) - if errorlevel ~= 0 then - return errorlevel + if typeset then + local errorlevel = typesetpdf(abspath(dir) .. "/" .. j) + if errorlevel ~= 0 then + return errorlevel + end end end end @@ -1863,8 +1882,8 @@ function install() if errorlevel ~= 0 then return errorlevel end - kpse.set_program_name("latex") - local texmfhome = kpse.var_value("TEXMFHOME") + set_program_name("latex") + local texmfhome = var_value("TEXMFHOME") local installdir = texmfhome .. "/tex/" .. moduledir errorlevel = cleandir(installdir) if errorlevel ~= 0 then @@ -1928,13 +1947,13 @@ if versionform ~= "" and not setversion_update_line then function setversion_update_line(line, date, release) -- No real regex so do it one type at a time for _,i in pairs({"Class", "File", "Package"}) do - if string.match( + if match( line, "^\\Provides" .. i .. "{[a-zA-Z0-9%-%.]+}%[[^%]]*%]$" ) then - line = string.gsub(line, "%[%d%d%d%d/%d%d/%d%d", "[" - .. string.gsub(date, "%-", "/")) - line = string.gsub( + line = gsub(line, "%[%d%d%d%d/%d%d/%d%d", "[" + .. gsub(date, "%-", "/")) + line = gsub( line, "(%[%d%d%d%d/%d%d/%d%d) [^ ]*", "%1 " .. release ) break @@ -1946,14 +1965,14 @@ if versionform ~= "" and not setversion_update_line then function setversion_update_line(line, date, release) -- No real regex so do it one type at a time for _,i in pairs({"Class", "File", "Package"}) do - if string.match( + if match( line, "^\\ProvidesExpl" .. i .. " *{[a-zA-Z0-9%-%.]+}" ) then - line = string.gsub( + line = gsub( line, "{%d%d%d%d/%d%d/%d%d}( *){[^}]*}", - "{" .. string.gsub(date, "%-", "/") .. "}%1{" .. release .. "}" + "{" .. gsub(date, "%-", "/") .. "}%1{" .. release .. "}" ) break end @@ -1962,20 +1981,20 @@ if versionform ~= "" and not setversion_update_line then end elseif versionform == "filename" then function setversion_update_line(line, date, release) - if string.match(line, "^\\def\\filedate{%d%d%d%d/%d%d/%d%d}$") then - line = "\\def\\filedate{" .. string.gsub(date, "%-", "/") .. "}" + if match(line, "^\\def\\filedate{%d%d%d%d/%d%d/%d%d}$") then + line = "\\def\\filedate{" .. gsub(date, "%-", "/") .. "}" end - if string.match(line, "^\\def\\fileversion{[^}]+}$") then + if match(line, "^\\def\\fileversion{[^}]+}$") then line = "\\def\\fileversion{" .. release .. "}" end return line end elseif versionform == "ExplFileDate" then function setversion_update_line(line, date, release) - if string.match(line, "^\\def\\ExplFileDate{%d%d%d%d/%d%d/%d%d}$") then - line = "\\def\\ExplFileDate{" .. string.gsub(date, "%-", "/") .. "}" + if match(line, "^\\def\\ExplFileDate{%d%d%d%d/%d%d/%d%d}$") then + line = "\\def\\ExplFileDate{" .. gsub(date, "%-", "/") .. "}" end - if string.match(line, "^\\def\\ExplFileVersion{[^}]+}$") then + if match(line, "^\\def\\ExplFileVersion{[^}]+}$") then line = "\\def\\ExplFileVersion{" .. release .. "}" end return line @@ -1988,36 +2007,36 @@ setversion_update_line = setversion_update_line or function(line, date, release) return line end -function setversion() - local function rewrite(file, date, version) +function setversion(dir) + local function rewrite(dir, file, date, release) local changed = false - local lines = "" - for line in io.lines(file) do - local newline = setversion_update_line(line, date, version) + local result = "" + for line in lines(dir .. "/" .. file) do + local newline = setversion_update_line(line, date, release) if newline ~= line then line = newline changed = true end - lines = lines .. line .. os_newline + result = result .. line .. os_newline end if changed then -- Avoid adding/removing end-of-file newline - local f = io.open(file, "rb") + local f = open(dir .. "/" .. file, "rb") local content = f:read("*all") - io.close(f) - if not string.match(content, os_newline .. "$") then - string.gsub(lines, os_newline .. "$", "") + close(f) + if not match(content, os_newline .. "$") then + gsub(result, os_newline .. "$", "") end -- Write the new file - ren(".", file, file .. bakext) - local f = io.open(file, "w") - io.output(f) - io.write(lines) - io.close(f) - rm(".", file .. bakext) + ren(dir, file, file .. bakext) + local f = open(dir .. "/" .. file, "w") + output(f) + write(result) + close(f) + rm(dir, file .. bakext) end end - local date = os.date("%Y-%m-%d") + local date = os_date("%Y-%m-%d") if optdate then date = optdate[1] or date end @@ -2025,9 +2044,10 @@ function setversion() if optrelease then release = optrelease[1] or release end + local dir = dir or "." for _,i in pairs(versionfiles) do - for _,j in pairs(filelist(".", i)) do - rewrite(j, date, release) + for _,j in pairs(filelist(dir, i)) do + rewrite(dir, j, date, release) end end return 0 @@ -2083,10 +2103,10 @@ bundleunpack = bundleunpack or function(sourcedir) -- This 'yes' business is needed to pass a series of "y\n" to -- TeX if \askforoverwrite is true -- That is all done using a file as it's the only way on Windows and - -- on Unix the "yes" command can't be used inside os.execute (it never + -- on Unix the "yes" command can't be used inside execute (it never -- stops, which confuses Lua) - os.execute(os_yes .. ">>" .. localdir .. "/yes") - local localdir = relpath(localdir, unpackdir) + execute(os_yes .. ">>" .. localdir .. "/yes") + local localdir = abspath(localdir) errorlevel = run( unpackdir, os_setenv .. " TEXINPUTS=." .. os_pathsep @@ -2107,7 +2127,7 @@ end function version() print( "\n" - .. "l3build Release " .. string.gsub(release_date, "/", "-") .. "\n" + .. "l3build Release " .. gsub(release_date, "/", "-") .. "\n" ) end @@ -2187,9 +2207,9 @@ function stdmain(target, files) end end if errorlevel ~= 0 then - os.exit(1) + exit(1) else - os.exit(0) + exit(0) end end @@ -2197,9 +2217,9 @@ end main = main or stdmain -- Pick up and read any per-run testfiledir -if userargs["testfiledir"] then - if #userargs["testfiledir"] == 1 then - testfiledir = userargs["testfiledir"][1] +if options["testfiledir"] then + if #options["testfiledir"] == 1 then + testfiledir = options["testfiledir"][1] if fileexists(testfiledir .. "/config.lua") then dofile(testfiledir .. "/config.lua") end @@ -2210,4 +2230,4 @@ if userargs["testfiledir"] then end -- Call the main function -main(userargs["target"], userargs["files"]) +main(options["target"], options["files"]) diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3intarray.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3intarray.sty new file mode 100644 index 00000000000..8239e693bbc --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3intarray.sty @@ -0,0 +1,104 @@ +%% +%% This is file `l3intarray.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% l3intarray.dtx (with options: `package') +%% +%% Copyright (C) 2011-2017 The LaTeX3 Project +%% +%% It may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License (LPPL), either version 1.3c of +%% this license or (at your option) any later version. The latest +%% version of this license is in the file: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This file is part of the "l3experimental bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% File: l3intarray.dtx Copyright (C) 2017 The LaTeX3 Project +\RequirePackage{expl3}[2017/05/13] +\@ifpackagelater{expl3}{2017/05/13} + {} + {% + \PackageError{l3intarray}{Support package l3kernel too old} + {% + Please install an up to date version of l3kernel\MessageBreak + using your TeX package manager or from CTAN.\MessageBreak + \MessageBreak + Loading l3intarray will abort!% + }% + \endinput + } +\ProvidesExplPackage{l3intarray}{2017/05/13}{} + {L3 Experimental low-level arrays of small integers} +\int_new:N \g__intarray_font_int +\cs_new_protected:Npn \__intarray_new:Nn #1#2 + { + \__chk_if_free_cs:N #1 + \int_gincr:N \g__intarray_font_int + \tex_global:D \tex_font:D #1 = cmr10~at~ \g__intarray_font_int sp \scan_stop: + \tex_hyphenchar:D #1 = \int_eval:n {#2} \scan_stop: + \int_compare:nNnT { \tex_hyphenchar:D #1 } > 0 + { \tex_fontdimen:D \tex_hyphenchar:D #1 #1 = 0 sp \scan_stop: } + \int_step_inline:nnnn { 1 } { 1 } { 8 } + { \tex_fontdimen:D ##1 #1 = 0 sp \scan_stop: } + } +\cs_new:Npn \__intarray_count:N #1 { \tex_the:D \tex_hyphenchar:D #1 } +\cs_new_protected:Npn \__intarray_gset_fast:Nnn #1#2#3 + { \tex_fontdimen:D \int_eval:n {#2} #1 = \int_eval:n {#3} sp \scan_stop: } +\cs_new_protected:Npn \__intarray_gset:Nnn #1#2#3 + { + \exp_args:Nff \__intarray_gset_aux:Nnn #1 + { \int_eval:n {#2} } { \int_eval:n {#3} } + } +\cs_new_protected:Npn \__intarray_gset_aux:Nnn #1#2#3 + { + \int_compare:nTF { 1 <= #2 <= \__intarray_count:N #1 } + { + \int_compare:nTF { - \c_max_dim <= \int_abs:n {#3} <= \c_max_dim } + { \__intarray_gset_fast:Nnn #1 {#2} {#3} } + { + \__msg_kernel_error:nnxxxx { intarray } { overflow } + { \token_to_str:N #1 } {#2} {#3} + { \int_compare:nNnT {#3} < 0 { - } \__int_value:w \c_max_dim } + \__intarray_gset_fast:Nnn #1 {#2} + { \int_compare:nNnT {#3} < 0 { - } \c_max_dim } + } + } + { + \__msg_kernel_error:nnxxx { intarray } { out-of-bounds } + { \token_to_str:N #1 } {#2} { \__intarray_count:N #1 } + } + } +\cs_new:Npn \__intarray_item_fast:Nn #1#2 + { \__int_value:w \tex_fontdimen:D \int_eval:n {#2} #1 } +\cs_new:Npn \__intarray_item:Nn #1#2 + { \exp_args:Nf \__intarray_item_aux:Nn #1 { \int_eval:n {#2} } } +\cs_new:Npn \__intarray_item_aux:Nn #1#2 + { + \int_compare:nTF { 1 <= #2 <= \__intarray_count:N #1 } + { \__intarray_item_fast:Nn #1 {#2} } + { + \__msg_kernel_expandable_error:nnnnn { intarray } { out-of-bounds } + { \token_to_str:N #1 } {#2} { \__intarray_count:N #1 } + 0 + } + } +\__msg_kernel_new:nnnn { intarray } { overflow } + { Integers~larger~than~2^{30}-1~cannot~be~stored~in~arrays. } + { + An~attempt~was~made~to~store~#3~at~position~#2~in~the~array~'#1'.~ + The~largest~allowed~value~#4~will~be~used~instead. + } +\__msg_kernel_new:nnnn { intarray } { out-of-bounds } + { Access~to~an~entry~beyond~an~array's~bounds. } + { + An~attempt~was~made~to~access~or~store~data~at~position~#2~of~the~ + array~'#1',~but~this~array~has~entries~at~positions~from~1~to~#3. + } +%% +%% +%% End of file `l3intarray.sty'. diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex-trace.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex-trace.sty index e74c484390d..abb10d12edf 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex-trace.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex-trace.sty @@ -6,7 +6,7 @@ %% %% l3regex.dtx (with options: `package,trace') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of @@ -19,8 +19,8 @@ %% and all files in that bundle must be distributed together. %% %% File: l3regex.dtx Copyright (C) 2011-2017 The LaTeX3 Project -\RequirePackage{expl3}[2017/04/01] -\@ifpackagelater{expl3}{2017/04/01} +\RequirePackage{expl3}[2017/05/13] +\@ifpackagelater{expl3}{2017/05/13} {} {% \PackageError{l3regex}{Support package l3kernel too old} @@ -32,10 +32,46 @@ }% \endinput } -\ProvidesExplPackage{l3regex}{2017/04/01}{} +\ProvidesExplPackage{l3regex}{2017/05/13}{} {L3 Experimental regular expressions} -\RequirePackage{l3tl-build, l3tl-analysis, l3str-convert} +\RequirePackage{l3tl-build, l3tl-analysis, l3intarray} \cs_generate_variant:Nn \tl_to_str:n { V } +\cs_new_protected:Npn \__regex_standard_escapechar: + { \int_set:Nn \tex_escapechar:D { `\\ } } +\cs_new:Npn \__regex_toks_use:w { \tex_the:D \tex_toks:D } +\cs_new_protected:Npn \__regex_toks_clear:N #1 + { \tex_toks:D #1 { } } +\cs_new_eq:NN \__regex_toks_set:Nn \tex_toks:D +\cs_new_protected:Npn \__regex_toks_set:No #1 + { \__regex_toks_set:Nn #1 \exp_after:wN } +\cs_new_protected:Npn \__regex_toks_memcpy:NNn #1#2#3 + { + \prg_replicate:nn {#3} + { + \tex_toks:D #1 = \tex_toks:D #2 + \int_incr:N #1 + \int_incr:N #2 + } + } +\cs_new_protected:Npn \__regex_toks_put_left:Nx #1#2 + { + \cs_set:Npx \__regex_tmp:w { #2 } + \tex_toks:D #1 \exp_after:wN \exp_after:wN \exp_after:wN + { \exp_after:wN \__regex_tmp:w \tex_the:D \tex_toks:D #1 } + } +\cs_new_protected:Npn \__regex_toks_put_right:Nx #1#2 + { + \cs_set:Npx \__regex_tmp:w {#2} + \tex_toks:D #1 \exp_after:wN + { \tex_the:D \tex_toks:D \exp_after:wN #1 \__regex_tmp:w } + } +\cs_new_protected:Npn \__regex_toks_put_right:Nn #1#2 + { \tex_toks:D #1 \exp_after:wN { \tex_the:D \tex_toks:D #1 #2 } } +\cs_new:Npn \__regex_current_cs_to_str: + { + \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N + \tex_the:D \tex_toks:D \l__regex_current_pos_int + } \cs_new:Npn \__regex_tmp:w { } \tl_new:N \l__regex_internal_a_tl \tl_new:N \l__regex_internal_b_tl @@ -50,8 +86,15 @@ \__regex_branch:n { \__regex_class:NnnnN \c_true_bool { } { 1 } { 0 } \c_true_bool } } +\__intarray_new:Nn \g__regex_charcode_intarray { 65536 } +\__intarray_new:Nn \g__regex_catcode_intarray { 65536 } +\__intarray_new:Nn \g__regex_balance_intarray { 65536 } \int_new:N \l__regex_balance_int \tl_new:N \l__regex_cs_name_tl +\int_const:Nn \c__regex_ascii_min_int { 0 } +\int_const:Nn \c__regex_ascii_max_control_int { 31 } +\int_const:Nn \c__regex_ascii_max_int { 127 } +\int_const:Nn \c__regex_ascii_lower_int { `a - `A } \cs_new_protected:Npn \__regex_break_true:w #1 \__regex_break_point:TF #2 #3 {#2} \cs_new_protected:Npn \__regex_break_point:TF #1 #2 { #2 } @@ -108,12 +151,12 @@ \if_int_compare:w \l__regex_current_char_int > `Z \exp_stop_f: \if_int_compare:w \l__regex_current_char_int > `z \exp_stop_f: \else: \if_int_compare:w \l__regex_current_char_int < `a \exp_stop_f: \else: - \int_sub:Nn \l__regex_case_changed_char_int { \c__str_ascii_lower_int } + \int_sub:Nn \l__regex_case_changed_char_int { \c__regex_ascii_lower_int } \fi: \fi: \else: \if_int_compare:w \l__regex_current_char_int < `A \exp_stop_f: \else: - \int_add:Nn \l__regex_case_changed_char_int { \c__str_ascii_lower_int } + \int_add:Nn \l__regex_case_changed_char_int { \c__regex_ascii_lower_int } \fi: \fi: } @@ -152,12 +195,7 @@ \int_compare:nNnTF \l__regex_current_catcode_int = 0 { \tl_set:Nx \l__regex_internal_a_tl - { - \scan_stop: - \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N - \tex_the:D \tex_toks:D \l__regex_current_pos_int - \scan_stop: - } + { \scan_stop: \__regex_current_cs_to_str: \scan_stop: } \tl_if_in:noTF { \scan_stop: #1 \scan_stop: } \l__regex_internal_a_tl { \__regex_break_true:w } { } } @@ -168,12 +206,7 @@ \int_compare:nNnT \l__regex_current_catcode_int = 0 { \group_begin: - \tl_set:Nx \l__regex_cs_name_tl - { - \exp_after:wN \exp_after:wN - \exp_after:wN \cs_to_str:N - \tex_the:D \tex_toks:D \l__regex_current_pos_int - } + \tl_set:Nx \l__regex_cs_name_tl { \__regex_current_cs_to_str: } \__regex_single_match: \__regex_disable_submatches: \__regex_build_for_cs:n {#1} @@ -222,16 +255,16 @@ \cs_new_protected:Npn \__regex_posix_ascii: { \__regex_item_caseful_range:nn - \c__str_ascii_min_int - \c__str_ascii_max_int + \c__regex_ascii_min_int + \c__regex_ascii_max_int } \cs_new_eq:NN \__regex_posix_blank: \__regex_prop_h: \cs_new_protected:Npn \__regex_posix_cntrl: { \__regex_item_caseful_range:nn - \c__str_ascii_min_int - \c__str_ascii_max_control_int - \__regex_item_caseful_equal:n \c__str_ascii_max_int + \c__regex_ascii_min_int + \c__regex_ascii_max_control_int + \__regex_item_caseful_equal:n \c__regex_ascii_max_int } \cs_new_eq:NN \__regex_posix_digit: \__regex_prop_d: \cs_new_protected:Npn \__regex_posix_graph: @@ -268,8 +301,8 @@ \cs_set:Npn \__regex_escape_unescaped:N ##1 { #1 } \cs_set:Npn \__regex_escape_escaped:N ##1 { #2 } \cs_set:Npn \__regex_escape_raw:N ##1 { #3 } - \int_set:Nn \tex_escapechar:D { `\\ } - \__str_gset_other:Nn \g__regex_internal_tl { #4 } + \__regex_standard_escapechar: + \tl_gset:Nx \g__regex_internal_tl { \__str_to_other_fast:n {#4} } \tl_set:Nx \l__regex_internal_b_tl { \exp_after:wN \__regex_escape_loop:N \g__regex_internal_tl @@ -323,36 +356,19 @@ } \cs_new:Npn \__regex_escape_x_end:w #1 ; { - \int_compare:nNnTF {#1} > \c__str_max_byte_int - { \__regex_escape_x_large:n {#1} } + \int_compare:nNnTF {#1} > \c_max_char_int + { + \if_false: { \fi: } + \__tl_build_one:o \l__regex_internal_b_tl + \__msg_kernel_error:nnx { regex } { x-overflow } {#1} + \tl_set:Nx \l__regex_internal_b_tl + { \if_false: } \fi: + } { \exp_last_unbraced:Nf \__regex_escape_raw:N - { \__str_output_byte:n {#1} } + { \char_generate:nn {#1} { 12 } } } } -\group_begin: - \char_set_catcode_other:n { 0 } - \cs_new:Npn \__regex_escape_x_large:n #1 - { - \if_false: { \fi: } - \__tl_build_one:o \l__regex_internal_b_tl - \int_compare:nNnTF {#1} > \c_max_char_int - { - \__msg_kernel_error:nnx { regex } { x-overflow } {#1} - \tl_set:Nx \l__regex_internal_b_tl - { \if_false: } \fi: - } - { - \char_set_lccode:nn { 0 } {#1} - \tex_lowercase:D - { - \tl_set:Nx \l__regex_internal_b_tl - { \if_false: } \fi: - \__regex_escape_raw:N ^^@ - } - } - } -\group_end: \cs_new:Npn \__regex_escape_x_test:N #1 { \str_if_eq_x:nnTF {#1} { break } { ; } @@ -370,7 +386,7 @@ \if_charcode:w \c_left_brace_str #1 \exp_after:wN \__regex_escape_x_loop:N \else: - \__str_hexadecimal_use:NTF #1 + \__regex_hexadecimal_use:NTF #1 { \exp_after:wN \__regex_escape_x:N } { ; \exp_after:wN \__regex_escape_loop:N \exp_after:wN #1 } \fi: @@ -379,7 +395,7 @@ { \str_if_eq_x:nnTF {#1} { break } { ; } { - \__str_hexadecimal_use:NTF #1 + \__regex_hexadecimal_use:NTF #1 { ; \__regex_escape_loop:N } { ; \__regex_escape_loop:N #1 } } @@ -389,7 +405,7 @@ \str_if_eq_x:nnTF {#1} { break } { ; \__regex_escape_x_loop_error:n { } {#1} } { - \__str_hexadecimal_use:NTF #1 + \__regex_hexadecimal_use:NTF #1 { \__regex_escape_x_loop:N } { \token_if_eq_charcode:NNTF \c_space_token #1 @@ -412,11 +428,32 @@ \tl_set:Nx \l__regex_internal_b_tl { \if_false: } \fi: \__regex_escape_loop:N #1 } +\prg_new_conditional:Npnn \__regex_hexadecimal_use:N #1 { TF } + { + \if_int_compare:w 1 < "1 \token_to_str:N #1 \exp_stop_f: + #1 \prg_return_true: + \else: + \if_case:w \__int_eval:w + \exp_after:wN ` \token_to_str:N #1 - `a + \__int_eval_end: + A + \or: B + \or: C + \or: D + \or: E + \or: F + \else: + \prg_return_false: + \exp_after:wN \use_none:n + \fi: + \prg_return_true: + \fi: + } \prg_new_conditional:Npnn \__regex_char_if_special:N #1 { TF } { \if_int_compare:w `#1 > `Z \exp_stop_f: \if_int_compare:w `#1 > `z \exp_stop_f: - \if_int_compare:w `#1 < \c__str_ascii_max_int + \if_int_compare:w `#1 < \c__regex_ascii_max_int \prg_return_true: \else: \prg_return_false: \fi: \else: \if_int_compare:w `#1 < `a \exp_stop_f: @@ -607,7 +644,7 @@ \cs_new_protected:Npn \__regex_compile:n #1 { \__regex_compile:w - \int_set:Nn \tex_escapechar:D { `\\ } + \__regex_standard_escapechar: \int_set_eq:NN \l__regex_mode_int \c__regex_outer_mode_int \__regex_escape_use:nnnn { @@ -1201,7 +1238,7 @@ { \if_int_odd:w \__int_eval:w \l__regex_catcodes_int / #1 \__int_eval_end: \else: - \tex_advance:D \l__regex_catcodes_int #1 + \int_add:Nn \l__regex_catcodes_int {#1} \fi: } \cs_new_protected:Npn \__regex_compile_c_lbrack_end: @@ -1329,8 +1366,8 @@ } \cs_new_protected:Npn \__regex_compile_u_in_cs: { - \exp_args:NNo \__str_gset_other:Nn \g__regex_internal_tl - { \l__regex_internal_a_tl } + \tl_gset:Nx \g__regex_internal_tl + { \exp_args:No \__str_to_other_fast:n { \l__regex_internal_a_tl } } \__tl_build_one:x { \tl_map_function:NN \g__regex_internal_tl @@ -1522,6 +1559,7 @@ { control~sequence~ \seq_use:Nn \l__regex_internal_seq { ~or~ } } } \int_new:N \l__regex_min_state_int +\int_set:Nn \l__regex_min_state_int { 1 } \int_new:N \l__regex_max_state_int \int_new:N \l__regex_left_state_int \int_new:N \l__regex_right_state_int @@ -1536,7 +1574,7 @@ \cs_new_protected:Npn \__regex_build:N #1 { \trace_push:nnn { regex } { 1 } { __regex_build } - \int_set:Nn \tex_escapechar:D { `\\ } + \__regex_standard_escapechar: \int_zero:N \l__regex_capturing_group_int \int_set_eq:NN \l__regex_max_state_int \l__regex_min_state_int \__regex_build_new_state: @@ -1581,20 +1619,6 @@ \seq_pop:NN \l__regex_right_state_seq \l__regex_internal_a_tl \int_set:Nn \l__regex_right_state_int \l__regex_internal_a_tl } -\cs_new_protected:Npn \__regex_toks_put_left:Nx #1#2 - { - \cs_set:Npx \__regex_tmp:w { #2 } - \tex_toks:D #1 \exp_after:wN \exp_after:wN \exp_after:wN - { \exp_after:wN \__regex_tmp:w \tex_the:D \tex_toks:D #1 } - } -\cs_new_protected:Npn \__regex_toks_put_right:Nx #1#2 - { - \cs_set:Npx \__regex_tmp:w {#2} - \tex_toks:D #1 \exp_after:wN - { \tex_the:D \tex_toks:D \exp_after:wN #1 \__regex_tmp:w } - } -\cs_new_protected:Npn \__regex_toks_put_right:Nn #1#2 - { \tex_toks:D #1 \exp_after:wN { \tex_the:D \tex_toks:D #1 #2 } } \cs_new_protected:Npn \__regex_build_transition_left:NNN #1#2#3 { \__regex_toks_put_left:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } \cs_new_protected:Npn \__regex_build_transition_right:nNn #1#2#3 @@ -1609,7 +1633,7 @@ M=\int_use:N \l__regex_max_state_int ~ -> ~ \int_eval:n { \l__regex_max_state_int + 1 } } - \tex_toks:D \l__regex_max_state_int { } + \__regex_toks_clear:N \l__regex_max_state_int \int_set_eq:NN \l__regex_left_state_int \l__regex_right_state_int \int_set_eq:NN \l__regex_right_state_int \l__regex_max_state_int \int_incr:N \l__regex_max_state_int @@ -1776,15 +1800,12 @@ ( #1 - 1 ) * ( \l__regex_internal_b_int - \l__regex_internal_a_int ) } - \tex_advance:D \l__regex_right_state_int \l__regex_internal_c_int - \tex_advance:D \l__regex_max_state_int \l__regex_internal_c_int - \prg_replicate:nn \l__regex_internal_c_int - { - \tex_toks:D \l__regex_internal_b_int - = \tex_toks:D \l__regex_internal_a_int - \int_incr:N \l__regex_internal_a_int - \int_incr:N \l__regex_internal_b_int - } + \int_add:Nn \l__regex_right_state_int { \l__regex_internal_c_int } + \int_add:Nn \l__regex_max_state_int { \l__regex_internal_c_int } + \__regex_toks_memcpy:NNn + \l__regex_internal_b_int + \l__regex_internal_a_int + \l__regex_internal_c_int \fi: } \cs_new_protected:Npn \__regex_group_repeat:nnN #1#2#3 @@ -1912,6 +1933,8 @@ \int_new:N \l__regex_step_int \int_new:N \l__regex_min_active_int \int_new:N \l__regex_max_active_int +\__intarray_new:Nn \g__regex_state_active_intarray { 65536 } +\__intarray_new:Nn \g__regex_thread_state_intarray { 65536 } \tl_new:N \l__regex_every_match_tl \bool_new:N \l__regex_fresh_thread_bool \bool_new:N \l__regex_empty_success_bool @@ -1935,12 +1958,13 @@ \bool_gset_false:N \g__regex_success_bool \int_step_inline:nnnn \l__regex_min_state_int { 1 } { \l__regex_max_state_int - 1 } - { \tex_dimen:D ##1 ~ 1 sp \scan_stop: } + { \__intarray_gset_fast:Nnn \g__regex_state_active_intarray {##1} { 1 } } \int_set_eq:NN \l__regex_min_active_int \l__regex_max_state_int \int_zero:N \l__regex_step_int \int_set_eq:NN \l__regex_success_pos_int \l__regex_min_pos_int - \int_set:Nn \l__regex_submatch_int + \int_set:Nn \l__regex_min_submatch_int { 2 * \l__regex_max_state_int } + \int_set_eq:NN \l__regex_submatch_int \l__regex_min_submatch_int \bool_set_false:N \l__regex_empty_success_bool \__regex_match_once: \trace_pop:nnx { regex } { 1 } { __regex_match } @@ -1982,7 +2006,7 @@ } \cs_new_protected:Npn \__regex_match_loop: { - \tex_advance:D \l__regex_step_int 2 \exp_stop_f: + \int_add:Nn \l__regex_step_int { 2 } \int_incr:N \l__regex_current_pos_int \int_set_eq:NN \l__regex_last_char_int \l__regex_current_char_int \int_set_eq:NN \l__regex_case_changed_char_int \c_max_int @@ -1990,8 +2014,11 @@ \use:x { \int_set_eq:NN \l__regex_max_active_int \l__regex_min_active_int - \exp_after:wN \__regex_match_one_active:w - \int_use:N \l__regex_min_active_int ; + \int_step_function:nnnN + { \l__regex_min_active_int } + { 1 } + { \l__regex_max_active_int - 1 } + \__regex_match_one_active:n } \__prg_break_point: \bool_set_false:N \l__regex_fresh_thread_bool %^^A was arg of break_point:n @@ -2001,25 +2028,21 @@ \fi: \fi: } -\cs_new:Npn \__regex_match_one_active:w #1; +\cs_new:Npn \__regex_match_one_active:n #1 { - \if_int_compare:w #1 < \l__regex_max_active_int - \__regex_use_state_and_submatches:nn - { \__int_value:w \tex_skip:D #1 } - { \tex_the:D \tex_toks:D #1 } - \exp_after:wN \__regex_match_one_active:w - \__int_value:w \__int_eval:w #1 + 1 \exp_after:wN ; - \fi: + \__regex_use_state_and_submatches:nn + { \__intarray_item_fast:Nn \g__regex_thread_state_intarray {#1} } + { \__regex_toks_use:w #1 } } \cs_new_protected:Npn \__regex_query_set:nnn #1#2#3 { - \tex_muskip:D \l__regex_current_pos_int - = \etex_gluetomu:D - #3 sp - plus #2 sp - minus \l__regex_balance_int sp - \scan_stop: - \tex_toks:D \l__regex_current_pos_int {#1} + \__intarray_gset_fast:Nnn \g__regex_charcode_intarray + { \l__regex_current_pos_int } {#3} + \__intarray_gset_fast:Nnn \g__regex_catcode_intarray + { \l__regex_current_pos_int } {#2} + \__intarray_gset_fast:Nnn \g__regex_balance_intarray + { \l__regex_current_pos_int } { \l__regex_balance_int } + \__regex_toks_set:Nn \l__regex_current_pos_int {#1} \int_incr:N \l__regex_current_pos_int \if_case:w #2 \exp_stop_f: \or: \int_incr:N \l__regex_balance_int @@ -2029,23 +2052,27 @@ \cs_new_protected:Npn \__regex_query_get: { \l__regex_current_char_int - = \etex_mutoglue:D \tex_muskip:D \l__regex_current_pos_int - \l__regex_current_catcode_int = \etex_gluestretch:D - \etex_mutoglue:D \tex_muskip:D \l__regex_current_pos_int + = \__intarray_item_fast:Nn \g__regex_charcode_intarray + { \l__regex_current_pos_int } \scan_stop: + \l__regex_current_catcode_int + = \__intarray_item_fast:Nn \g__regex_catcode_intarray + { \l__regex_current_pos_int } \scan_stop: } \cs_new_protected:Npn \__regex_use_state: { \trace:nnx { regex } { 2 } { state~\int_use:N \l__regex_current_state_int } - \tex_dimen:D \l__regex_current_state_int - = \l__regex_step_int sp \scan_stop: - \tex_the:D \tex_toks:D \l__regex_current_state_int - \tex_dimen:D \l__regex_current_state_int - = \__int_eval:w \l__regex_step_int + 1 \__int_eval_end: sp \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_state_active_intarray + { \l__regex_current_state_int } { \l__regex_step_int } + \__regex_toks_use:w \l__regex_current_state_int + \__intarray_gset_fast:Nnn \g__regex_state_active_intarray + { \l__regex_current_state_int } { \l__regex_step_int + 1 } } \cs_new_protected:Npn \__regex_use_state_and_submatches:nn #1 #2 { \int_set:Nn \l__regex_current_state_int {#1} - \if_int_compare:w \tex_dimen:D \l__regex_current_state_int + \if_int_compare:w + \__intarray_item_fast:Nn \g__regex_state_active_intarray + { \l__regex_current_state_int } < \l__regex_step_int \tl_set:Nn \l__regex_current_submatches_prop {#2} \exp_after:wN \__regex_use_state: @@ -2070,7 +2097,10 @@ \int_add:Nn \l__regex_current_state_int {#2} \exp_not:n { - \if_int_compare:w \tex_dimen:D \l__regex_current_state_int #1 + \if_int_compare:w + \__intarray_item_fast:Nn \g__regex_state_active_intarray + { \l__regex_current_state_int } + #1 \exp_after:wN \__regex_use_state: \fi: } @@ -2088,12 +2118,13 @@ \cs_new_protected:Npn \__regex_store_state:n #1 { \__regex_store_submatches: - \tex_skip:D \l__regex_max_active_int = #1 sp \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_thread_state_intarray + { \l__regex_max_active_int } {#1} \int_incr:N \l__regex_max_active_int } \cs_new_protected:Npn \__regex_store_submatches: { - \tex_toks:D \l__regex_max_active_int \exp_after:wN + \__regex_toks_set:No \l__regex_max_active_int { \l__regex_current_submatches_prop } } \cs_new_protected:Npn \__regex_disable_submatches: @@ -2120,14 +2151,16 @@ } } \int_new:N \l__regex_replacement_csnames_int +\tl_new:N \l__regex_replacement_category_tl +\seq_new:N \l__regex_replacement_category_seq \tl_new:N \l__regex_balance_tl \cs_new:Npn \__regex_replacement_balance_one_match:n #1 { - \__regex_submatch_balance:n {#1} } \cs_new:Npn \__regex_replacement_do_one_match:n #1 { \__regex_query_range:nn - { \etex_glueshrink:D \tex_skip:D #1 } - { \tex_skip:D #1 } + { \__intarray_item_fast:Nn \g__regex_submatch_prev_intarray {#1} } + { \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray {#1} } } \cs_new:Npn \__regex_replacement_exp_not:N #1 { \exp_not:n {#1} } \cs_new:Npn \__regex_query_range:nn #1#2 @@ -2143,22 +2176,35 @@ \else: \exp_after:wN \__prg_break: \fi: - \tex_the:D \tex_toks:D #1 \exp_stop_f: + \__regex_toks_use:w #1 \exp_stop_f: \exp_after:wN \__regex_query_range_loop:ww \__int_value:w \__int_eval:w #1 + 1 ; #2 ; } \cs_new:Npn \__regex_query_submatch:n #1 { \__regex_query_range:nn - { \tex_skip:D \__int_eval:w #1 } - { \etex_gluestretch:D \tex_skip:D \__int_eval:w #1 } + { \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray {#1} } + { \__intarray_item_fast:Nn \g__regex_submatch_end_intarray {#1} } } \cs_new_protected:Npn \__regex_submatch_balance:n #1 { - \etex_glueshrink:D \etex_mutoglue:D \etex_muexpr:D - \tex_muskip:D \etex_gluestretch:D \tex_skip:D #1 - - \tex_muskip:D \tex_skip:D #1 - \scan_stop: + \__int_eval:w + \int_compare:nNnTF + { \__intarray_item_fast:Nn \g__regex_submatch_end_intarray {#1} } = 0 + { 0 } + { + \__intarray_item_fast:Nn \g__regex_balance_intarray + { \__intarray_item_fast:Nn \g__regex_submatch_end_intarray {#1} } + } + - + \int_compare:nNnTF + { \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray {#1} } = 0 + { 0 } + { + \__intarray_item_fast:Nn \g__regex_balance_intarray + { \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray {#1} } + } + \__int_eval_end: } \cs_new_protected:Npn \__regex_replacement:n #1 { @@ -2169,10 +2215,14 @@ \__regex_escape_use:nnnn { \if_charcode:w \c_right_brace_str ##1 - \__regex_replacement_rbrace:N \else: \__tl_build_one:n \fi: ##1 + \__regex_replacement_rbrace:N + \else: + \__regex_replacement_normal:n + \fi: + ##1 } { \__regex_replacement_escaped:N ##1 } - { \__tl_build_one:n ##1 } + { \__regex_replacement_normal:n ##1 } {#1} \prg_do_nothing: \prg_do_nothing: \if_int_compare:w \l__regex_replacement_csnames_int > 0 \exp_stop_f: @@ -2181,6 +2231,12 @@ \__tl_build_one:x { \prg_replicate:nn \l__regex_replacement_csnames_int \cs_end: } \fi: + \seq_if_empty:NF \l__regex_replacement_category_seq + { + \__msg_kernel_error:nnx { regex } { replacement-missing-rparen } + { \seq_count:N \l__regex_replacement_category_seq } + \seq_clear:N \l__regex_replacement_category_seq + } \cs_gset:Npx \__regex_replacement_balance_one_match:n ##1 { + \int_use:N \l__regex_balance_int @@ -2196,11 +2252,27 @@ \cs_set:Npn \__regex_replacement_do_one_match:n ##1 { \__regex_query_range:nn - { \etex_glueshrink:D \tex_skip:D ##1 } - { \tex_skip:D ##1 } + { \__intarray_item_fast:Nn \g__regex_submatch_prev_intarray {##1} } + { \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray {##1} } #1 } } +\cs_new_protected:Npn \__regex_replacement_normal:n #1 + { + \tl_if_empty:NTF \l__regex_replacement_category_tl + { \__tl_build_one:n {#1} } + { % ( + \token_if_eq_charcode:NNTF #1 ) + { + \seq_pop:NN \l__regex_replacement_category_seq + \l__regex_replacement_category_tl + } + { + \use:c { __regex_replacement_c_ \l__regex_replacement_category_tl :w } + \__regex_replacement_normal:n {#1} + } + } + } \cs_new_protected:Npn \__regex_replacement_escaped:N #1 { \cs_if_exist_use:cF { __regex_replacement_#1:w } @@ -2208,7 +2280,8 @@ \if_int_compare:w 1 < 1#1 \exp_stop_f: \__regex_replacement_put_submatch:n {#1} \else: - \__tl_build_one:o { \token_to_str:N #1 } + \exp_args:No \__regex_replacement_normal:n + { \token_to_str:N #1 } \fi: } } @@ -2224,28 +2297,26 @@ } \cs_new_protected:Npn \__regex_replacement_g:w #1#2 { - \str_if_eq_x:nnTF { #1#2 } { \__tl_build_one:n \c_left_brace_str } - { - \int_zero:N \l__regex_internal_a_int - \__regex_replacement_g_digits:NN - } + \str_if_eq_x:nnTF { #1#2 } { \__regex_replacement_normal:n \c_left_brace_str } + { \l__regex_internal_a_int = \__regex_replacement_g_digits:NN } { \__regex_replacement_error:NNN g #1 #2 } } -\cs_new_protected:Npn \__regex_replacement_g_digits:NN #1#2 +\cs_new:Npn \__regex_replacement_g_digits:NN #1#2 { - \token_if_eq_meaning:NNTF #1 \__tl_build_one:n + \token_if_eq_meaning:NNTF #1 \__regex_replacement_normal:n { \if_int_compare:w 1 < 1#2 \exp_stop_f: - \int_set:Nn \l__regex_internal_a_int - { 10 * \l__regex_internal_a_int + #2 } + #2 \exp_after:wN \use_i:nnn \exp_after:wN \__regex_replacement_g_digits:NN \else: + \exp_stop_f: \exp_after:wN \__regex_replacement_error:NNN \exp_after:wN g \fi: } { + \exp_stop_f: \if_meaning:w \__regex_replacement_rbrace:N #1 \exp_args:No \__regex_replacement_put_submatch:n { \int_use:N \l__regex_internal_a_int } @@ -2259,34 +2330,31 @@ } \cs_new_protected:Npn \__regex_replacement_c:w #1#2 { - \token_if_eq_meaning:NNTF #1 \__tl_build_one:n + \token_if_eq_meaning:NNTF #1 \__regex_replacement_normal:n { - \cs_if_exist_use:cF { __regex_replacement_c_#2:w } - { \__regex_replacement_error:NNN c #1#2 } + \exp_after:wN \token_if_eq_charcode:NNTF \c_left_brace_str #2 + { \__regex_replacement_cu_aux:Nw \__regex_replacement_exp_not:N } + { + \cs_if_exist:cTF { __regex_replacement_c_#2:w } + { \__regex_replacement_cat:NNN #2 } + { \__regex_replacement_error:NNN c #1#2 } + } } { \__regex_replacement_error:NNN c #1#2 } } -\cs_new_protected:cpn { __regex_replacement_c_ \c_left_brace_str :w } +\cs_new_protected:Npn \__regex_replacement_cu_aux:Nw #1 { \if_case:w \l__regex_replacement_csnames_int - \__tl_build_one:n - { \exp_not:n { \exp_after:wN \__regex_replacement_exp_not:N \cs:w } } + \__tl_build_one:n { \exp_not:n { \exp_after:wN #1 \cs:w } } \else: - \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:N \cs:w } } + \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } } \fi: \int_incr:N \l__regex_replacement_csnames_int } \cs_new_protected:Npn \__regex_replacement_u:w #1#2 { - \str_if_eq_x:nnTF { #1#2 } { \__tl_build_one:n \c_left_brace_str } - { - \if_case:w \l__regex_replacement_csnames_int - \__tl_build_one:n { \exp_not:n { \exp_after:wN \exp_not:V \cs:w } } - \else: - \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } } - \fi: - \int_incr:N \l__regex_replacement_csnames_int - } + \str_if_eq_x:nnTF { #1#2 } { \__regex_replacement_normal:n \c_left_brace_str } + { \__regex_replacement_cu_aux:Nw \exp_not:V } { \__regex_replacement_error:NNN u #1#2 } } \cs_new_protected:Npn \__regex_replacement_rbrace:N #1 @@ -2295,18 +2363,36 @@ \__tl_build_one:n \cs_end: \int_decr:N \l__regex_replacement_csnames_int \else: - \__tl_build_one:n #1 + \__regex_replacement_normal:n {#1} \fi: } +\cs_new_protected:Npn \__regex_replacement_cat:NNN #1#2#3 + { + \token_if_eq_meaning:NNTF \prg_do_nothing: #3 + { \__msg_kernel_error:nn { regex } { replacement-catcode-end } } + { + \int_compare:nNnTF { \l__regex_replacement_csnames_int } > 0 + { + \__msg_kernel_error:nnnn + { regex } { replacement-catcode-in-cs } {#1} {#3} + #2 #3 + } + { + \str_if_eq:nnTF { #2 #3 } { \__regex_replacement_normal:n ( } % ) + { + \seq_push:NV \l__regex_replacement_category_seq + \l__regex_replacement_category_tl + \tl_set:Nn \l__regex_replacement_category_tl {#1} + } + { \use:c { __regex_replacement_c_#1:w } #2 #3 } + } + } + } \group_begin: \cs_new_protected:Npn \__regex_replacement_char:nNN #1#2#3 { - \if_meaning:w \prg_do_nothing: #3 - \__msg_kernel_error:nn { regex } { replacement-catcode-end } - \else: - \tex_lccode:D 0 = `#3 \scan_stop: - \tex_lowercase:D { \__tl_build_one:n {#1} } - \fi: + \tex_lccode:D 0 = `#3 \scan_stop: + \tex_lowercase:D { \__tl_build_one:n {#1} } } \char_set_catcode_active:N \^^@ \cs_new_protected:Npn \__regex_replacement_c_A:w @@ -2351,15 +2437,11 @@ } \cs_new_protected:Npn \__regex_replacement_c_S:w #1#2 { - \if_meaning:w \prg_do_nothing: #2 - \__msg_kernel_error:nn { regex } { replacement-catcode-end } - \else: - \if_int_compare:w `#2 = 0 \exp_stop_f: - \__msg_kernel_error:nn { regex } { replacement-null-space } - \fi: - \tex_lccode:D `\ = `#2 \scan_stop: - \tex_lowercase:D { \__tl_build_one:n {~} } + \if_int_compare:w `#2 = 0 \exp_stop_f: + \__msg_kernel_error:nn { regex } { replacement-null-space } \fi: + \tex_lccode:D `\ = `#2 \scan_stop: + \tex_lowercase:D { \__tl_build_one:n {~} } } \char_set_catcode_alignment:N \^^@ \cs_new_protected:Npn \__regex_replacement_c_T:w @@ -2433,8 +2515,12 @@ \int_new:N \l__regex_match_count_int \flag_new:n { __regex_begin } \flag_new:n { __regex_end } +\int_new:N \l__regex_min_submatch_int \int_new:N \l__regex_submatch_int \int_new:N \l__regex_zeroth_submatch_int +\__intarray_new:Nn \g__regex_submatch_prev_intarray { 65536 } +\__intarray_new:Nn \g__regex_submatch_begin_intarray { 65536 } +\__intarray_new:Nn \g__regex_submatch_end_intarray { 65536 } \cs_new_protected:Npn \__regex_return: { \if_meaning:w \c_true_bool \g__regex_success_bool @@ -2488,15 +2574,29 @@ { \if_int_compare:w \l__regex_start_pos_int < \l__regex_success_pos_int \__regex_extract: - \tex_skip:D \l__regex_zeroth_submatch_int - = \l__regex_start_pos_int sp - plus \tex_skip:D \l__regex_zeroth_submatch_int \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_submatch_prev_intarray + { \l__regex_zeroth_submatch_int } { 0 } + \__intarray_gset_fast:Nnn \g__regex_submatch_end_intarray + { \l__regex_zeroth_submatch_int } + { + \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray + { \l__regex_zeroth_submatch_int } + } + \__intarray_gset_fast:Nnn \g__regex_submatch_begin_intarray + { \l__regex_zeroth_submatch_int } + { \l__regex_start_pos_int } \fi: } #1 \__regex_match:n {#2} - \tex_skip:D \l__regex_submatch_int - = \l__regex_start_pos_int sp plus \l__regex_max_pos_int sp \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_submatch_prev_intarray + { \l__regex_submatch_int } { 0 } + \__intarray_gset_fast:Nnn \g__regex_submatch_end_intarray + { \l__regex_submatch_int } + { \l__regex_max_pos_int } + \__intarray_gset_fast:Nnn \g__regex_submatch_begin_intarray + { \l__regex_submatch_int } + { \l__regex_start_pos_int } \int_incr:N \l__regex_submatch_int \if_meaning:w \c_true_bool \l__regex_empty_success_bool \if_int_compare:w \l__regex_start_pos_int = \l__regex_max_pos_int @@ -2514,7 +2614,7 @@ { \s__seq \int_step_function:nnnN - { 2 * \l__regex_max_state_int } + { \l__regex_min_submatch_int } { 1 } { \l__regex_submatch_int - 1 } \__regex_extract_seq_aux:n @@ -2560,7 +2660,12 @@ \int_set_eq:NN \l__regex_zeroth_submatch_int \l__regex_submatch_int \prg_replicate:nn \l__regex_capturing_group_int { - \tex_skip:D \l__regex_submatch_int 0 sp \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_submatch_begin_intarray + { \l__regex_submatch_int } { 0 } + \__intarray_gset_fast:Nnn \g__regex_submatch_end_intarray + { \l__regex_submatch_int } { 0 } + \__intarray_gset_fast:Nnn \g__regex_submatch_prev_intarray + { \l__regex_submatch_int } { 0 } \int_incr:N \l__regex_submatch_int } \prop_map_inline:Nn \l__regex_success_submatches_prop @@ -2572,21 +2677,14 @@ \fi: \__int_eval:w \l__regex_zeroth_submatch_int + ##1 {##2} } - \tex_skip:D \l__regex_zeroth_submatch_int - = \tex_the:D \tex_skip:D \l__regex_zeroth_submatch_int - minus \l__regex_start_pos_int sp \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_submatch_prev_intarray + { \l__regex_zeroth_submatch_int } { \l__regex_start_pos_int } \fi: } \cs_new_protected:Npn \__regex_extract_b:wn #1 < #2 - { - \tex_skip:D #1 = #2 sp - plus \etex_gluestretch:D \tex_skip:D #1 \scan_stop: - } + { \__intarray_gset_fast:Nnn \g__regex_submatch_begin_intarray {#1} {#2} } \cs_new_protected:Npn \__regex_extract_e:wn #1 > #2 - { - \tex_skip:D #1 - = 1 \tex_skip:D #1 plus #2 sp \scan_stop: - } + { \__intarray_gset_fast:Nnn \g__regex_submatch_end_intarray {#1} {#2} } \cs_new_protected:Npn \__regex_replace_once:nnN #1#2#3 { \group_begin: @@ -2607,7 +2705,10 @@ { \__regex_replacement_do_one_match:n { \l__regex_zeroth_submatch_int } \__regex_query_range:nn - { \etex_gluestretch:D \tex_skip:D \l__regex_zeroth_submatch_int } + { + \__intarray_item_fast:Nn \g__regex_submatch_end_intarray + { \l__regex_zeroth_submatch_int } + } { \l__regex_max_pos_int } } \__regex_group_end_replace:N #3 @@ -2624,7 +2725,7 @@ { 0 \int_step_function:nnnN - { 2 * \l__regex_max_state_int } + { \l__regex_min_submatch_int } \l__regex_capturing_group_int { \l__regex_submatch_int - 1 } \__regex_replacement_balance_one_match:n @@ -2632,7 +2733,7 @@ \tl_set:Nx \l__regex_internal_a_tl { \int_step_function:nnnN - { 2 * \l__regex_max_state_int } + { \l__regex_min_submatch_int } \l__regex_capturing_group_int { \l__regex_submatch_int - 1 } \__regex_replacement_do_one_match:n @@ -2668,38 +2769,38 @@ } } \__msg_kernel_new:nnnn { regex } { trailing-backslash } - { Trailing~escape~character~`\iow_char:N\\'. } + { Trailing~escape~character~'\iow_char:N\\'. } { A~regular~expression~or~its~replacement~text~ends~with~ - the~escape~character~`\iow_char:N\\'.~It~will~be~ignored. + the~escape~character~'\iow_char:N\\'.~It~will~be~ignored. } \__msg_kernel_new:nnnn { regex } { x-missing-rbrace } - { Missing~closing~brace~in~`\iow_char:N\\x'~hexadecimal~sequence. } + { Missing~closing~brace~in~'\iow_char:N\\x'~hexadecimal~sequence. } { You~wrote~something~like~ - `\iow_char:N\\x\{...#1'.~ + '\iow_char:N\\x\{...#1'.~ The~closing~brace~is~missing. } \__msg_kernel_new:nnnn { regex } { x-overflow } - { Character~code~`#1'~too~large~in~`\iow_char:N\\x'~hexadecimal~sequence. } + { Character~code~'#1'~too~large~in~'\iow_char:N\\x'~hexadecimal~sequence. } { You~wrote~something~like~ - `\iow_char:N\\x\{\int_to_Hex:n{#1}\}'.~ + '\iow_char:N\\x\{\int_to_Hex:n{#1}\}'.~ The~character~code~#1~is~larger~than~ the~maximum~value~\int_use:N \c_max_char_int. } \__msg_kernel_new:nnnn { regex } { invalid-quantifier } - { Braced~quantifier~`#1'~may~not~be~followed~by~`#2'. } + { Braced~quantifier~'#1'~may~not~be~followed~by~'#2'. } { - The~character~`#2'~is~invalid~in~the~braced~quantifier~`#1'.~ - The~only~valid~quantifiers~are~`*',~`?',~`+',~`{}',~ - `{,}'~and~`{,}',~optionally~followed~by~`?'. + The~character~'#2'~is~invalid~in~the~braced~quantifier~'#1'.~ + The~only~valid~quantifiers~are~'*',~'?',~'+',~'{}',~ + '{,}'~and~'{,}',~optionally~followed~by~'?'. } \__msg_kernel_new:nnnn { regex } { missing-rbrack } { Missing~right~bracket~inserted~in~regular~expression. } { LaTeX~was~given~a~regular~expression~where~a~character~class~ - was~started~with~`[',~but~the~matching~`]'~is~missing. + was~started~with~'[',~but~the~matching~']'~is~missing. } \__msg_kernel_new:nnnn { regex } { missing-rparen } { @@ -2719,7 +2820,7 @@ } \__msg_kernel_new:nnnn { regex } { bad-escape } { - Invalid~escape~`\iow_char:N\\#1'~ + Invalid~escape~'\iow_char:N\\#1'~ \__regex_if_in_cs:TF { within~a~control~sequence. } { \__regex_if_in_class:TF @@ -2728,102 +2829,102 @@ } } { - The~escape~sequence~`\iow_char:N\\#1'~may~not~appear~ + The~escape~sequence~'\iow_char:N\\#1'~may~not~appear~ \__regex_if_in_cs:TF { within~a~control~sequence~test~introduced~by~ - `\iow_char:N\\c\iow_char:N\{'. + '\iow_char:N\\c\iow_char:N\{'. } { \__regex_if_in_class:TF { within~a~character~class~ } - { following~a~category~test~such~as~`\iow_char:N\\cL'~ } + { following~a~category~test~such~as~'\iow_char:N\\cL'~ } because~it~does~not~match~exactly~one~character. } } \__msg_kernel_new:nnnn { regex } { range-missing-end } - { Invalid~end-point~for~range~`#1-#2'~in~character~class. } + { Invalid~end-point~for~range~'#1-#2'~in~character~class. } { - The~end-point~`#2'~of~the~range~`#1-#2'~may~not~serve~as~an~ + The~end-point~'#2'~of~the~range~'#1-#2'~may~not~serve~as~an~ end-point~for~a~range:~alphanumeric~characters~should~not~be~ escaped,~and~non-alphanumeric~characters~should~be~escaped. } \__msg_kernel_new:nnnn { regex } { range-backwards } - { Range~`[#1-#2]'~out~of~order~in~character~class. } + { Range~'[#1-#2]'~out~of~order~in~character~class. } { - In~ranges~of~characters~`[x-y]'~appearing~in~character~classes,~ + In~ranges~of~characters~'[x-y]'~appearing~in~character~classes,~ the~first~character~code~must~not~be~larger~than~the~second.~ - Here,~`#1'~has~character~code~\int_eval:n {`#1},~while~ - `#2'~has~character~code~\int_eval:n {`#2}. + Here,~'#1'~has~character~code~\int_eval:n {`#1},~while~ + '#2'~has~character~code~\int_eval:n {`#2}. } \__msg_kernel_new:nnnn { regex } { c-bad-mode } - { Invalid~nested~`\iow_char:N\\c'~escape~in~regular~expression. } + { Invalid~nested~'\iow_char:N\\c'~escape~in~regular~expression. } { - The~`\iow_char:N\\c'~escape~cannot~be~used~within~ - a~control~sequence~test~`\iow_char:N\\c{...}'.~ - To~combine~several~category~tests,~use~`\iow_char:N\\c[...]'. + The~'\iow_char:N\\c'~escape~cannot~be~used~within~ + a~control~sequence~test~'\iow_char:N\\c{...}'.~ + To~combine~several~category~tests,~use~'\iow_char:N\\c[...]'. } \__msg_kernel_new:nnnn { regex } { c-missing-rbrace } - { Missing~right~brace~inserted~for~`\iow_char:N\\c'~escape. } + { Missing~right~brace~inserted~for~'\iow_char:N\\c'~escape. } { LaTeX~was~given~a~regular~expression~where~a~ - `\iow_char:N\\c\iow_char:N\{...'~construction~was~not~ended~ - with~a~closing~brace~`\iow_char:N\}'. + '\iow_char:N\\c\iow_char:N\{...'~construction~was~not~ended~ + with~a~closing~brace~'\iow_char:N\}'. } \__msg_kernel_new:nnnn { regex } { c-missing-rbrack } - { Missing~right~bracket~inserted~for~`\iow_char:N\\c'~escape. } + { Missing~right~bracket~inserted~for~'\iow_char:N\\c'~escape. } { - A~construction~`\iow_char:N\\c[...'~appears~in~a~ - regular~expression,~but~the~closing~`]'~is~not~present. + A~construction~'\iow_char:N\\c[...'~appears~in~a~ + regular~expression,~but~the~closing~']'~is~not~present. } \__msg_kernel_new:nnnn { regex } { c-missing-category } - { Invalid~character~`#1'~following~`\iow_char:N\\c'~escape. } + { Invalid~character~'#1'~following~'\iow_char:N\\c'~escape. } { - In~regular~expressions,~the~`\iow_char:N\\c'~escape~sequence~ + In~regular~expressions,~the~'\iow_char:N\\c'~escape~sequence~ may~only~be~followed~by~a~left~brace,~a~left~bracket,~or~a~ capital~letter~representing~a~character~category,~namely~ - one~of~`ABCDELMOPSTU'. + one~of~'ABCDELMOPSTU'. } \__msg_kernel_new:nnnn { regex } { c-trailing } - { Trailing~category~code~escape~`\iow_char:N\\c'... } + { Trailing~category~code~escape~'\iow_char:N\\c'... } { - A~regular~expression~ends~with~`\iow_char:N\\c'~followed~ + A~regular~expression~ends~with~'\iow_char:N\\c'~followed~ by~a~letter.~It~will~be~ignored. } \__msg_kernel_new:nnnn { regex } { u-missing-lbrace } - { Missing~left~brace~following~`\iow_char:N\\u'~escape. } + { Missing~left~brace~following~'\iow_char:N\\u'~escape. } { - The~`\iow_char:N\\u'~escape~sequence~must~be~followed~by~ + The~'\iow_char:N\\u'~escape~sequence~must~be~followed~by~ a~brace~group~with~the~name~of~the~variable~to~use. } \__msg_kernel_new:nnnn { regex } { u-missing-rbrace } - { Missing~right~brace~inserted~for~`\iow_char:N\\u'~escape. } + { Missing~right~brace~inserted~for~'\iow_char:N\\u'~escape. } { LaTeX~ \str_if_eq_x:nnTF { } {#2} { reached~the~end~of~the~string~ } - { encountered~an~escaped~alphanumeric~character `\iow_char:N\\#2'~ } - when~parsing~the~argument~of~an~`\iow_char:N\\u\iow_char:N\{...\}'~escape. + { encountered~an~escaped~alphanumeric~character '\iow_char:N\\#2'~ } + when~parsing~the~argument~of~an~'\iow_char:N\\u\iow_char:N\{...\}'~escape. } \__msg_kernel_new:nnnn { regex } { posix-unsupported } - { POSIX~collating~element~`[#1 ~ #1]'~not~supported. } + { POSIX~collating~element~'[#1 ~ #1]'~not~supported. } { - The~`[.foo.]'~and~`[=bar=]'~syntaxes~have~a~special~meaning~ + The~'[.foo.]'~and~'[=bar=]'~syntaxes~have~a~special~meaning~ in~POSIX~regular~expressions.~This~is~not~supported~by~LaTeX.~ Maybe~you~forgot~to~escape~a~left~bracket~in~a~character~class? } \__msg_kernel_new:nnnn { regex } { posix-unknown } - { POSIX~class~`[:#1:]'~unknown. } + { POSIX~class~'[:#1:]'~unknown. } { - `[:#1:]'~is~not~among~the~known~POSIX~classes~ - `[:alnum:]',~`[:alpha:]',~`[:ascii:]',~`[:blank:]',~ - `[:cntrl:]',~`[:digit:]',~`[:graph:]',~`[:lower:]',~ - `[:print:]',~`[:punct:]',~`[:space:]',~`[:upper:]',~ - `[:word:]',~and~`[:xdigit:]'. + '[:#1:]'~is~not~among~the~known~POSIX~classes~ + '[:alnum:]',~'[:alpha:]',~'[:ascii:]',~'[:blank:]',~ + '[:cntrl:]',~'[:digit:]',~'[:graph:]',~'[:lower:]',~ + '[:print:]',~'[:punct:]',~'[:space:]',~'[:upper:]',~ + '[:word:]',~and~'[:xdigit:]'. } \__msg_kernel_new:nnnn { regex } { posix-missing-close } - { Missing~closing~`:]'~for~POSIX~class. } - { The~POSIX~syntax~`#1'~must~be~followed~by~`:]',~not~`#2'. } + { Missing~closing~':]'~for~POSIX~class. } + { The~POSIX~syntax~'#1'~must~be~followed~by~':]',~not~'#2'. } \__msg_kernel_new:nnnn { regex } { result-unbalanced } { Missing~brace~inserted~when~#1. } { @@ -2833,58 +2934,68 @@ #2~left,~#3~right. } \__msg_kernel_new:nnnn { regex } { unknown-option } - { Unknown~option~`#1'~for~regular~expressions. } + { Unknown~option~'#1'~for~regular~expressions. } { - The~only~available~option~is~`case-insensitive',~toggled~by~ - `(?i)'~and~`(?-i)'. + The~only~available~option~is~'case-insensitive',~toggled~by~ + '(?i)'~and~'(?-i)'. } \__msg_kernel_new:nnnn { regex } { special-group-unknown } - { Unknown~special~group~`#1~...'~in~a~regular~expression. } + { Unknown~special~group~'#1~...'~in~a~regular~expression. } { - The~only~valid~constructions~starting~with~`(?'~are~ - `(?:~...~)',~`(?|~...~)',~`(?i)',~and~`(?-i)'. + The~only~valid~constructions~starting~with~'(?'~are~ + '(?:~...~)',~'(?|~...~)',~'(?i)',~and~'(?-i)'. } \__msg_kernel_new:nnnn { regex } { replacement-c } - { Misused~`\iow_char:N\\c'~command~in~a~replacement~text. } + { Misused~'\iow_char:N\\c'~command~in~a~replacement~text. } { - In~a~replacement~text,~the~`\iow_char:N\\c'~escape~sequence~ - can~be~followed~by~one~of~the~letters~`ABCDELMOPSTU'~ - or~a~brace~group,~not~by~`#1'. + In~a~replacement~text,~the~'\iow_char:N\\c'~escape~sequence~ + can~be~followed~by~one~of~the~letters~'ABCDELMOPSTU'~ + or~a~brace~group,~not~by~'#1'. } \__msg_kernel_new:nnnn { regex } { replacement-u } - { Misused~`\iow_char:N\\u'~command~in~a~replacement~text. } + { Misused~'\iow_char:N\\u'~command~in~a~replacement~text. } { - In~a~replacement~text,~the~`\iow_char:N\\u'~escape~sequence~ + In~a~replacement~text,~the~'\iow_char:N\\u'~escape~sequence~ must~be~~followed~by~a~brace~group~holding~the~name~of~the~ variable~to~use. } \__msg_kernel_new:nnnn { regex } { replacement-g } { - Missing~brace~for~the~`\iow_char:N\\g'~construction~ + Missing~brace~for~the~'\iow_char:N\\g'~construction~ in~a~replacement~text. } { In~the~replacement~text~for~a~regular~expression~search,~ - submatches~are~represented~either~as~`\iow_char:N \\g{dd..d}',~ - or~`\\d',~where~`d'~are~single~digits.~Here,~a~brace~is~missing. + submatches~are~represented~either~as~'\iow_char:N \\g{dd..d}',~ + or~'\\d',~where~'d'~are~single~digits.~Here,~a~brace~is~missing. } \__msg_kernel_new:nnnn { regex } { replacement-catcode-end } { - Missing~character~for~the~`\iow_char:N\\c'~ + Missing~character~for~the~'\iow_char:N\\c'~ construction~in~a~replacement~text. } { - In~a~replacement~text,~the~`\iow_char:N\\c'~escape~sequence~ - can~be~followed~by~one~of~the~letters~`ABCDELMOPSTU'~representing~ + In~a~replacement~text,~the~'\iow_char:N\\c'~escape~sequence~ + can~be~followed~by~one~of~the~letters~'ABCDELMOPSTU'~representing~ the~character~category.~Then,~a~character~must~follow.~LaTeX~ reached~the~end~of~the~replacement~when~looking~for~that. } +\__msg_kernel_new:nnnn { regex } { replacement-catcode-in-cs } + { + Category~code~'\iow_char:N\\c#1#3'~ignored~inside~ + '\iow_char:N\\c\{...\}'~in~a~replacement~text. + } + { + In~a~replacement~text,~the~category~codes~of~the~argument~of~ + '\iow_char:N\\c\{...\}'~are~ignored~when~building~the~control~ + sequence~name. + } \__msg_kernel_new:nnnn { regex } { replacement-null-space } { TeX~cannot~build~a~space~token~with~character~code~0. } { You~asked~for~a~character~token~with~category~space,~ and~character~code~0,~for~instance~through~ - `\iow_char:N\\cS\iow_char:N\\x00'.~ + '\iow_char:N\\cS\iow_char:N\\x00'.~ This~specific~case~is~impossible~and~will~be~replaced~ by~a~normal~space. } @@ -2894,6 +3005,12 @@ There~ \int_compare:nTF { #1 = 1 } { was } { were } ~ #1~ missing~right~\int_compare:nTF { #1 = 1 } { brace } { braces } . } +\__msg_kernel_new:nnnn { regex } { replacement-missing-rparen } + { Missing~right~parenthesis~inserted~in~replacement~text. } + { + There~ \int_compare:nTF { #1 = 1 } { was } { were } ~ #1~ + missing~right~\int_compare:nTF { #1 = 1 } { parenthesis } { parentheses } . + } \cs_new:Npn \__regex_msg_repeated:nnN #1#2#3 { \str_if_eq_x:nnF { #1 #2 } { 1 0 } @@ -2918,7 +3035,7 @@ { \l__regex_max_state_int - 1 } { \trace:nnx { regex } { #1 } - { \iow_char:N \\toks ##1 = { \tex_the:D \tex_toks:D ##1 } } + { \iow_char:N \\toks ##1 = { \__regex_toks_use:w ##1 } } } } %% diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty index 671cb91fc11..b3ce165d5e8 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty @@ -6,7 +6,7 @@ %% %% l3regex.dtx (with options: `package') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of @@ -19,8 +19,8 @@ %% and all files in that bundle must be distributed together. %% %% File: l3regex.dtx Copyright (C) 2011-2017 The LaTeX3 Project -\RequirePackage{expl3}[2017/04/01] -\@ifpackagelater{expl3}{2017/04/01} +\RequirePackage{expl3}[2017/05/13] +\@ifpackagelater{expl3}{2017/05/13} {} {% \PackageError{l3regex}{Support package l3kernel too old} @@ -32,10 +32,46 @@ }% \endinput } -\ProvidesExplPackage{l3regex}{2017/04/01}{} +\ProvidesExplPackage{l3regex}{2017/05/13}{} {L3 Experimental regular expressions} -\RequirePackage{l3tl-build, l3tl-analysis, l3str-convert} +\RequirePackage{l3tl-build, l3tl-analysis, l3intarray} \cs_generate_variant:Nn \tl_to_str:n { V } +\cs_new_protected:Npn \__regex_standard_escapechar: + { \int_set:Nn \tex_escapechar:D { `\\ } } +\cs_new:Npn \__regex_toks_use:w { \tex_the:D \tex_toks:D } +\cs_new_protected:Npn \__regex_toks_clear:N #1 + { \tex_toks:D #1 { } } +\cs_new_eq:NN \__regex_toks_set:Nn \tex_toks:D +\cs_new_protected:Npn \__regex_toks_set:No #1 + { \__regex_toks_set:Nn #1 \exp_after:wN } +\cs_new_protected:Npn \__regex_toks_memcpy:NNn #1#2#3 + { + \prg_replicate:nn {#3} + { + \tex_toks:D #1 = \tex_toks:D #2 + \int_incr:N #1 + \int_incr:N #2 + } + } +\cs_new_protected:Npn \__regex_toks_put_left:Nx #1#2 + { + \cs_set:Npx \__regex_tmp:w { #2 } + \tex_toks:D #1 \exp_after:wN \exp_after:wN \exp_after:wN + { \exp_after:wN \__regex_tmp:w \tex_the:D \tex_toks:D #1 } + } +\cs_new_protected:Npn \__regex_toks_put_right:Nx #1#2 + { + \cs_set:Npx \__regex_tmp:w {#2} + \tex_toks:D #1 \exp_after:wN + { \tex_the:D \tex_toks:D \exp_after:wN #1 \__regex_tmp:w } + } +\cs_new_protected:Npn \__regex_toks_put_right:Nn #1#2 + { \tex_toks:D #1 \exp_after:wN { \tex_the:D \tex_toks:D #1 #2 } } +\cs_new:Npn \__regex_current_cs_to_str: + { + \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N + \tex_the:D \tex_toks:D \l__regex_current_pos_int + } \cs_new:Npn \__regex_tmp:w { } \tl_new:N \l__regex_internal_a_tl \tl_new:N \l__regex_internal_b_tl @@ -50,8 +86,15 @@ \__regex_branch:n { \__regex_class:NnnnN \c_true_bool { } { 1 } { 0 } \c_true_bool } } +\__intarray_new:Nn \g__regex_charcode_intarray { 65536 } +\__intarray_new:Nn \g__regex_catcode_intarray { 65536 } +\__intarray_new:Nn \g__regex_balance_intarray { 65536 } \int_new:N \l__regex_balance_int \tl_new:N \l__regex_cs_name_tl +\int_const:Nn \c__regex_ascii_min_int { 0 } +\int_const:Nn \c__regex_ascii_max_control_int { 31 } +\int_const:Nn \c__regex_ascii_max_int { 127 } +\int_const:Nn \c__regex_ascii_lower_int { `a - `A } \cs_new_protected:Npn \__regex_break_true:w #1 \__regex_break_point:TF #2 #3 {#2} \cs_new_protected:Npn \__regex_break_point:TF #1 #2 { #2 } @@ -108,12 +151,12 @@ \if_int_compare:w \l__regex_current_char_int > `Z \exp_stop_f: \if_int_compare:w \l__regex_current_char_int > `z \exp_stop_f: \else: \if_int_compare:w \l__regex_current_char_int < `a \exp_stop_f: \else: - \int_sub:Nn \l__regex_case_changed_char_int { \c__str_ascii_lower_int } + \int_sub:Nn \l__regex_case_changed_char_int { \c__regex_ascii_lower_int } \fi: \fi: \else: \if_int_compare:w \l__regex_current_char_int < `A \exp_stop_f: \else: - \int_add:Nn \l__regex_case_changed_char_int { \c__str_ascii_lower_int } + \int_add:Nn \l__regex_case_changed_char_int { \c__regex_ascii_lower_int } \fi: \fi: } @@ -152,12 +195,7 @@ \int_compare:nNnTF \l__regex_current_catcode_int = 0 { \tl_set:Nx \l__regex_internal_a_tl - { - \scan_stop: - \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N - \tex_the:D \tex_toks:D \l__regex_current_pos_int - \scan_stop: - } + { \scan_stop: \__regex_current_cs_to_str: \scan_stop: } \tl_if_in:noTF { \scan_stop: #1 \scan_stop: } \l__regex_internal_a_tl { \__regex_break_true:w } { } } @@ -168,12 +206,7 @@ \int_compare:nNnT \l__regex_current_catcode_int = 0 { \group_begin: - \tl_set:Nx \l__regex_cs_name_tl - { - \exp_after:wN \exp_after:wN - \exp_after:wN \cs_to_str:N - \tex_the:D \tex_toks:D \l__regex_current_pos_int - } + \tl_set:Nx \l__regex_cs_name_tl { \__regex_current_cs_to_str: } \__regex_single_match: \__regex_disable_submatches: \__regex_build_for_cs:n {#1} @@ -222,16 +255,16 @@ \cs_new_protected:Npn \__regex_posix_ascii: { \__regex_item_caseful_range:nn - \c__str_ascii_min_int - \c__str_ascii_max_int + \c__regex_ascii_min_int + \c__regex_ascii_max_int } \cs_new_eq:NN \__regex_posix_blank: \__regex_prop_h: \cs_new_protected:Npn \__regex_posix_cntrl: { \__regex_item_caseful_range:nn - \c__str_ascii_min_int - \c__str_ascii_max_control_int - \__regex_item_caseful_equal:n \c__str_ascii_max_int + \c__regex_ascii_min_int + \c__regex_ascii_max_control_int + \__regex_item_caseful_equal:n \c__regex_ascii_max_int } \cs_new_eq:NN \__regex_posix_digit: \__regex_prop_d: \cs_new_protected:Npn \__regex_posix_graph: @@ -267,8 +300,8 @@ \cs_set:Npn \__regex_escape_unescaped:N ##1 { #1 } \cs_set:Npn \__regex_escape_escaped:N ##1 { #2 } \cs_set:Npn \__regex_escape_raw:N ##1 { #3 } - \int_set:Nn \tex_escapechar:D { `\\ } - \__str_gset_other:Nn \g__regex_internal_tl { #4 } + \__regex_standard_escapechar: + \tl_gset:Nx \g__regex_internal_tl { \__str_to_other_fast:n {#4} } \tl_set:Nx \l__regex_internal_b_tl { \exp_after:wN \__regex_escape_loop:N \g__regex_internal_tl @@ -321,36 +354,19 @@ } \cs_new:Npn \__regex_escape_x_end:w #1 ; { - \int_compare:nNnTF {#1} > \c__str_max_byte_int - { \__regex_escape_x_large:n {#1} } + \int_compare:nNnTF {#1} > \c_max_char_int + { + \if_false: { \fi: } + \__tl_build_one:o \l__regex_internal_b_tl + \__msg_kernel_error:nnx { regex } { x-overflow } {#1} + \tl_set:Nx \l__regex_internal_b_tl + { \if_false: } \fi: + } { \exp_last_unbraced:Nf \__regex_escape_raw:N - { \__str_output_byte:n {#1} } + { \char_generate:nn {#1} { 12 } } } } -\group_begin: - \char_set_catcode_other:n { 0 } - \cs_new:Npn \__regex_escape_x_large:n #1 - { - \if_false: { \fi: } - \__tl_build_one:o \l__regex_internal_b_tl - \int_compare:nNnTF {#1} > \c_max_char_int - { - \__msg_kernel_error:nnx { regex } { x-overflow } {#1} - \tl_set:Nx \l__regex_internal_b_tl - { \if_false: } \fi: - } - { - \char_set_lccode:nn { 0 } {#1} - \tex_lowercase:D - { - \tl_set:Nx \l__regex_internal_b_tl - { \if_false: } \fi: - \__regex_escape_raw:N ^^@ - } - } - } -\group_end: \cs_new:Npn \__regex_escape_x_test:N #1 { \str_if_eq_x:nnTF {#1} { break } { ; } @@ -368,7 +384,7 @@ \if_charcode:w \c_left_brace_str #1 \exp_after:wN \__regex_escape_x_loop:N \else: - \__str_hexadecimal_use:NTF #1 + \__regex_hexadecimal_use:NTF #1 { \exp_after:wN \__regex_escape_x:N } { ; \exp_after:wN \__regex_escape_loop:N \exp_after:wN #1 } \fi: @@ -377,7 +393,7 @@ { \str_if_eq_x:nnTF {#1} { break } { ; } { - \__str_hexadecimal_use:NTF #1 + \__regex_hexadecimal_use:NTF #1 { ; \__regex_escape_loop:N } { ; \__regex_escape_loop:N #1 } } @@ -387,7 +403,7 @@ \str_if_eq_x:nnTF {#1} { break } { ; \__regex_escape_x_loop_error:n { } {#1} } { - \__str_hexadecimal_use:NTF #1 + \__regex_hexadecimal_use:NTF #1 { \__regex_escape_x_loop:N } { \token_if_eq_charcode:NNTF \c_space_token #1 @@ -410,11 +426,32 @@ \tl_set:Nx \l__regex_internal_b_tl { \if_false: } \fi: \__regex_escape_loop:N #1 } +\prg_new_conditional:Npnn \__regex_hexadecimal_use:N #1 { TF } + { + \if_int_compare:w 1 < "1 \token_to_str:N #1 \exp_stop_f: + #1 \prg_return_true: + \else: + \if_case:w \__int_eval:w + \exp_after:wN ` \token_to_str:N #1 - `a + \__int_eval_end: + A + \or: B + \or: C + \or: D + \or: E + \or: F + \else: + \prg_return_false: + \exp_after:wN \use_none:n + \fi: + \prg_return_true: + \fi: + } \prg_new_conditional:Npnn \__regex_char_if_special:N #1 { TF } { \if_int_compare:w `#1 > `Z \exp_stop_f: \if_int_compare:w `#1 > `z \exp_stop_f: - \if_int_compare:w `#1 < \c__str_ascii_max_int + \if_int_compare:w `#1 < \c__regex_ascii_max_int \prg_return_true: \else: \prg_return_false: \fi: \else: \if_int_compare:w `#1 < `a \exp_stop_f: @@ -605,7 +642,7 @@ \cs_new_protected:Npn \__regex_compile:n #1 { \__regex_compile:w - \int_set:Nn \tex_escapechar:D { `\\ } + \__regex_standard_escapechar: \int_set_eq:NN \l__regex_mode_int \c__regex_outer_mode_int \__regex_escape_use:nnnn { @@ -1199,7 +1236,7 @@ { \if_int_odd:w \__int_eval:w \l__regex_catcodes_int / #1 \__int_eval_end: \else: - \tex_advance:D \l__regex_catcodes_int #1 + \int_add:Nn \l__regex_catcodes_int {#1} \fi: } \cs_new_protected:Npn \__regex_compile_c_lbrack_end: @@ -1327,8 +1364,8 @@ } \cs_new_protected:Npn \__regex_compile_u_in_cs: { - \exp_args:NNo \__str_gset_other:Nn \g__regex_internal_tl - { \l__regex_internal_a_tl } + \tl_gset:Nx \g__regex_internal_tl + { \exp_args:No \__str_to_other_fast:n { \l__regex_internal_a_tl } } \__tl_build_one:x { \tl_map_function:NN \g__regex_internal_tl @@ -1520,6 +1557,7 @@ { control~sequence~ \seq_use:Nn \l__regex_internal_seq { ~or~ } } } \int_new:N \l__regex_min_state_int +\int_set:Nn \l__regex_min_state_int { 1 } \int_new:N \l__regex_max_state_int \int_new:N \l__regex_left_state_int \int_new:N \l__regex_right_state_int @@ -1533,7 +1571,7 @@ } \cs_new_protected:Npn \__regex_build:N #1 { - \int_set:Nn \tex_escapechar:D { `\\ } + \__regex_standard_escapechar: \int_zero:N \l__regex_capturing_group_int \int_set_eq:NN \l__regex_max_state_int \l__regex_min_state_int \__regex_build_new_state: @@ -1573,27 +1611,13 @@ \seq_pop:NN \l__regex_right_state_seq \l__regex_internal_a_tl \int_set:Nn \l__regex_right_state_int \l__regex_internal_a_tl } -\cs_new_protected:Npn \__regex_toks_put_left:Nx #1#2 - { - \cs_set:Npx \__regex_tmp:w { #2 } - \tex_toks:D #1 \exp_after:wN \exp_after:wN \exp_after:wN - { \exp_after:wN \__regex_tmp:w \tex_the:D \tex_toks:D #1 } - } -\cs_new_protected:Npn \__regex_toks_put_right:Nx #1#2 - { - \cs_set:Npx \__regex_tmp:w {#2} - \tex_toks:D #1 \exp_after:wN - { \tex_the:D \tex_toks:D \exp_after:wN #1 \__regex_tmp:w } - } -\cs_new_protected:Npn \__regex_toks_put_right:Nn #1#2 - { \tex_toks:D #1 \exp_after:wN { \tex_the:D \tex_toks:D #1 #2 } } \cs_new_protected:Npn \__regex_build_transition_left:NNN #1#2#3 { \__regex_toks_put_left:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } \cs_new_protected:Npn \__regex_build_transition_right:nNn #1#2#3 { \__regex_toks_put_right:Nx #2 { #1 { \int_eval:n { #3 - #2 } } } } \cs_new_protected:Npn \__regex_build_new_state: { - \tex_toks:D \l__regex_max_state_int { } + \__regex_toks_clear:N \l__regex_max_state_int \int_set_eq:NN \l__regex_left_state_int \l__regex_right_state_int \int_set_eq:NN \l__regex_right_state_int \l__regex_max_state_int \int_incr:N \l__regex_max_state_int @@ -1756,15 +1780,12 @@ ( #1 - 1 ) * ( \l__regex_internal_b_int - \l__regex_internal_a_int ) } - \tex_advance:D \l__regex_right_state_int \l__regex_internal_c_int - \tex_advance:D \l__regex_max_state_int \l__regex_internal_c_int - \prg_replicate:nn \l__regex_internal_c_int - { - \tex_toks:D \l__regex_internal_b_int - = \tex_toks:D \l__regex_internal_a_int - \int_incr:N \l__regex_internal_a_int - \int_incr:N \l__regex_internal_b_int - } + \int_add:Nn \l__regex_right_state_int { \l__regex_internal_c_int } + \int_add:Nn \l__regex_max_state_int { \l__regex_internal_c_int } + \__regex_toks_memcpy:NNn + \l__regex_internal_b_int + \l__regex_internal_a_int + \l__regex_internal_c_int \fi: } \cs_new_protected:Npn \__regex_group_repeat:nnN #1#2#3 @@ -1892,6 +1913,8 @@ \int_new:N \l__regex_step_int \int_new:N \l__regex_min_active_int \int_new:N \l__regex_max_active_int +\__intarray_new:Nn \g__regex_state_active_intarray { 65536 } +\__intarray_new:Nn \g__regex_thread_state_intarray { 65536 } \tl_new:N \l__regex_every_match_tl \bool_new:N \l__regex_fresh_thread_bool \bool_new:N \l__regex_empty_success_bool @@ -1912,12 +1935,13 @@ \bool_gset_false:N \g__regex_success_bool \int_step_inline:nnnn \l__regex_min_state_int { 1 } { \l__regex_max_state_int - 1 } - { \tex_dimen:D ##1 ~ 1 sp \scan_stop: } + { \__intarray_gset_fast:Nnn \g__regex_state_active_intarray {##1} { 1 } } \int_set_eq:NN \l__regex_min_active_int \l__regex_max_state_int \int_zero:N \l__regex_step_int \int_set_eq:NN \l__regex_success_pos_int \l__regex_min_pos_int - \int_set:Nn \l__regex_submatch_int + \int_set:Nn \l__regex_min_submatch_int { 2 * \l__regex_max_state_int } + \int_set_eq:NN \l__regex_submatch_int \l__regex_min_submatch_int \bool_set_false:N \l__regex_empty_success_bool \__regex_match_once: } @@ -1958,7 +1982,7 @@ } \cs_new_protected:Npn \__regex_match_loop: { - \tex_advance:D \l__regex_step_int 2 \exp_stop_f: + \int_add:Nn \l__regex_step_int { 2 } \int_incr:N \l__regex_current_pos_int \int_set_eq:NN \l__regex_last_char_int \l__regex_current_char_int \int_set_eq:NN \l__regex_case_changed_char_int \c_max_int @@ -1966,8 +1990,11 @@ \use:x { \int_set_eq:NN \l__regex_max_active_int \l__regex_min_active_int - \exp_after:wN \__regex_match_one_active:w - \int_use:N \l__regex_min_active_int ; + \int_step_function:nnnN + { \l__regex_min_active_int } + { 1 } + { \l__regex_max_active_int - 1 } + \__regex_match_one_active:n } \__prg_break_point: \bool_set_false:N \l__regex_fresh_thread_bool %^^A was arg of break_point:n @@ -1977,25 +2004,21 @@ \fi: \fi: } -\cs_new:Npn \__regex_match_one_active:w #1; +\cs_new:Npn \__regex_match_one_active:n #1 { - \if_int_compare:w #1 < \l__regex_max_active_int - \__regex_use_state_and_submatches:nn - { \__int_value:w \tex_skip:D #1 } - { \tex_the:D \tex_toks:D #1 } - \exp_after:wN \__regex_match_one_active:w - \__int_value:w \__int_eval:w #1 + 1 \exp_after:wN ; - \fi: + \__regex_use_state_and_submatches:nn + { \__intarray_item_fast:Nn \g__regex_thread_state_intarray {#1} } + { \__regex_toks_use:w #1 } } \cs_new_protected:Npn \__regex_query_set:nnn #1#2#3 { - \tex_muskip:D \l__regex_current_pos_int - = \etex_gluetomu:D - #3 sp - plus #2 sp - minus \l__regex_balance_int sp - \scan_stop: - \tex_toks:D \l__regex_current_pos_int {#1} + \__intarray_gset_fast:Nnn \g__regex_charcode_intarray + { \l__regex_current_pos_int } {#3} + \__intarray_gset_fast:Nnn \g__regex_catcode_intarray + { \l__regex_current_pos_int } {#2} + \__intarray_gset_fast:Nnn \g__regex_balance_intarray + { \l__regex_current_pos_int } { \l__regex_balance_int } + \__regex_toks_set:Nn \l__regex_current_pos_int {#1} \int_incr:N \l__regex_current_pos_int \if_case:w #2 \exp_stop_f: \or: \int_incr:N \l__regex_balance_int @@ -2005,22 +2028,26 @@ \cs_new_protected:Npn \__regex_query_get: { \l__regex_current_char_int - = \etex_mutoglue:D \tex_muskip:D \l__regex_current_pos_int - \l__regex_current_catcode_int = \etex_gluestretch:D - \etex_mutoglue:D \tex_muskip:D \l__regex_current_pos_int + = \__intarray_item_fast:Nn \g__regex_charcode_intarray + { \l__regex_current_pos_int } \scan_stop: + \l__regex_current_catcode_int + = \__intarray_item_fast:Nn \g__regex_catcode_intarray + { \l__regex_current_pos_int } \scan_stop: } \cs_new_protected:Npn \__regex_use_state: { - \tex_dimen:D \l__regex_current_state_int - = \l__regex_step_int sp \scan_stop: - \tex_the:D \tex_toks:D \l__regex_current_state_int - \tex_dimen:D \l__regex_current_state_int - = \__int_eval:w \l__regex_step_int + 1 \__int_eval_end: sp \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_state_active_intarray + { \l__regex_current_state_int } { \l__regex_step_int } + \__regex_toks_use:w \l__regex_current_state_int + \__intarray_gset_fast:Nnn \g__regex_state_active_intarray + { \l__regex_current_state_int } { \l__regex_step_int + 1 } } \cs_new_protected:Npn \__regex_use_state_and_submatches:nn #1 #2 { \int_set:Nn \l__regex_current_state_int {#1} - \if_int_compare:w \tex_dimen:D \l__regex_current_state_int + \if_int_compare:w + \__intarray_item_fast:Nn \g__regex_state_active_intarray + { \l__regex_current_state_int } < \l__regex_step_int \tl_set:Nn \l__regex_current_submatches_prop {#2} \exp_after:wN \__regex_use_state: @@ -2045,7 +2072,10 @@ \int_add:Nn \l__regex_current_state_int {#2} \exp_not:n { - \if_int_compare:w \tex_dimen:D \l__regex_current_state_int #1 + \if_int_compare:w + \__intarray_item_fast:Nn \g__regex_state_active_intarray + { \l__regex_current_state_int } + #1 \exp_after:wN \__regex_use_state: \fi: } @@ -2063,12 +2093,13 @@ \cs_new_protected:Npn \__regex_store_state:n #1 { \__regex_store_submatches: - \tex_skip:D \l__regex_max_active_int = #1 sp \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_thread_state_intarray + { \l__regex_max_active_int } {#1} \int_incr:N \l__regex_max_active_int } \cs_new_protected:Npn \__regex_store_submatches: { - \tex_toks:D \l__regex_max_active_int \exp_after:wN + \__regex_toks_set:No \l__regex_max_active_int { \l__regex_current_submatches_prop } } \cs_new_protected:Npn \__regex_disable_submatches: @@ -2095,14 +2126,16 @@ } } \int_new:N \l__regex_replacement_csnames_int +\tl_new:N \l__regex_replacement_category_tl +\seq_new:N \l__regex_replacement_category_seq \tl_new:N \l__regex_balance_tl \cs_new:Npn \__regex_replacement_balance_one_match:n #1 { - \__regex_submatch_balance:n {#1} } \cs_new:Npn \__regex_replacement_do_one_match:n #1 { \__regex_query_range:nn - { \etex_glueshrink:D \tex_skip:D #1 } - { \tex_skip:D #1 } + { \__intarray_item_fast:Nn \g__regex_submatch_prev_intarray {#1} } + { \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray {#1} } } \cs_new:Npn \__regex_replacement_exp_not:N #1 { \exp_not:n {#1} } \cs_new:Npn \__regex_query_range:nn #1#2 @@ -2118,22 +2151,35 @@ \else: \exp_after:wN \__prg_break: \fi: - \tex_the:D \tex_toks:D #1 \exp_stop_f: + \__regex_toks_use:w #1 \exp_stop_f: \exp_after:wN \__regex_query_range_loop:ww \__int_value:w \__int_eval:w #1 + 1 ; #2 ; } \cs_new:Npn \__regex_query_submatch:n #1 { \__regex_query_range:nn - { \tex_skip:D \__int_eval:w #1 } - { \etex_gluestretch:D \tex_skip:D \__int_eval:w #1 } + { \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray {#1} } + { \__intarray_item_fast:Nn \g__regex_submatch_end_intarray {#1} } } \cs_new_protected:Npn \__regex_submatch_balance:n #1 { - \etex_glueshrink:D \etex_mutoglue:D \etex_muexpr:D - \tex_muskip:D \etex_gluestretch:D \tex_skip:D #1 - - \tex_muskip:D \tex_skip:D #1 - \scan_stop: + \__int_eval:w + \int_compare:nNnTF + { \__intarray_item_fast:Nn \g__regex_submatch_end_intarray {#1} } = 0 + { 0 } + { + \__intarray_item_fast:Nn \g__regex_balance_intarray + { \__intarray_item_fast:Nn \g__regex_submatch_end_intarray {#1} } + } + - + \int_compare:nNnTF + { \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray {#1} } = 0 + { 0 } + { + \__intarray_item_fast:Nn \g__regex_balance_intarray + { \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray {#1} } + } + \__int_eval_end: } \cs_new_protected:Npn \__regex_replacement:n #1 { @@ -2143,10 +2189,14 @@ \__regex_escape_use:nnnn { \if_charcode:w \c_right_brace_str ##1 - \__regex_replacement_rbrace:N \else: \__tl_build_one:n \fi: ##1 + \__regex_replacement_rbrace:N + \else: + \__regex_replacement_normal:n + \fi: + ##1 } { \__regex_replacement_escaped:N ##1 } - { \__tl_build_one:n ##1 } + { \__regex_replacement_normal:n ##1 } {#1} \prg_do_nothing: \prg_do_nothing: \if_int_compare:w \l__regex_replacement_csnames_int > 0 \exp_stop_f: @@ -2155,6 +2205,12 @@ \__tl_build_one:x { \prg_replicate:nn \l__regex_replacement_csnames_int \cs_end: } \fi: + \seq_if_empty:NF \l__regex_replacement_category_seq + { + \__msg_kernel_error:nnx { regex } { replacement-missing-rparen } + { \seq_count:N \l__regex_replacement_category_seq } + \seq_clear:N \l__regex_replacement_category_seq + } \cs_gset:Npx \__regex_replacement_balance_one_match:n ##1 { + \int_use:N \l__regex_balance_int @@ -2169,11 +2225,27 @@ \cs_set:Npn \__regex_replacement_do_one_match:n ##1 { \__regex_query_range:nn - { \etex_glueshrink:D \tex_skip:D ##1 } - { \tex_skip:D ##1 } + { \__intarray_item_fast:Nn \g__regex_submatch_prev_intarray {##1} } + { \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray {##1} } #1 } } +\cs_new_protected:Npn \__regex_replacement_normal:n #1 + { + \tl_if_empty:NTF \l__regex_replacement_category_tl + { \__tl_build_one:n {#1} } + { % ( + \token_if_eq_charcode:NNTF #1 ) + { + \seq_pop:NN \l__regex_replacement_category_seq + \l__regex_replacement_category_tl + } + { + \use:c { __regex_replacement_c_ \l__regex_replacement_category_tl :w } + \__regex_replacement_normal:n {#1} + } + } + } \cs_new_protected:Npn \__regex_replacement_escaped:N #1 { \cs_if_exist_use:cF { __regex_replacement_#1:w } @@ -2181,7 +2253,8 @@ \if_int_compare:w 1 < 1#1 \exp_stop_f: \__regex_replacement_put_submatch:n {#1} \else: - \__tl_build_one:o { \token_to_str:N #1 } + \exp_args:No \__regex_replacement_normal:n + { \token_to_str:N #1 } \fi: } } @@ -2197,28 +2270,26 @@ } \cs_new_protected:Npn \__regex_replacement_g:w #1#2 { - \str_if_eq_x:nnTF { #1#2 } { \__tl_build_one:n \c_left_brace_str } - { - \int_zero:N \l__regex_internal_a_int - \__regex_replacement_g_digits:NN - } + \str_if_eq_x:nnTF { #1#2 } { \__regex_replacement_normal:n \c_left_brace_str } + { \l__regex_internal_a_int = \__regex_replacement_g_digits:NN } { \__regex_replacement_error:NNN g #1 #2 } } -\cs_new_protected:Npn \__regex_replacement_g_digits:NN #1#2 +\cs_new:Npn \__regex_replacement_g_digits:NN #1#2 { - \token_if_eq_meaning:NNTF #1 \__tl_build_one:n + \token_if_eq_meaning:NNTF #1 \__regex_replacement_normal:n { \if_int_compare:w 1 < 1#2 \exp_stop_f: - \int_set:Nn \l__regex_internal_a_int - { 10 * \l__regex_internal_a_int + #2 } + #2 \exp_after:wN \use_i:nnn \exp_after:wN \__regex_replacement_g_digits:NN \else: + \exp_stop_f: \exp_after:wN \__regex_replacement_error:NNN \exp_after:wN g \fi: } { + \exp_stop_f: \if_meaning:w \__regex_replacement_rbrace:N #1 \exp_args:No \__regex_replacement_put_submatch:n { \int_use:N \l__regex_internal_a_int } @@ -2232,34 +2303,31 @@ } \cs_new_protected:Npn \__regex_replacement_c:w #1#2 { - \token_if_eq_meaning:NNTF #1 \__tl_build_one:n + \token_if_eq_meaning:NNTF #1 \__regex_replacement_normal:n { - \cs_if_exist_use:cF { __regex_replacement_c_#2:w } - { \__regex_replacement_error:NNN c #1#2 } + \exp_after:wN \token_if_eq_charcode:NNTF \c_left_brace_str #2 + { \__regex_replacement_cu_aux:Nw \__regex_replacement_exp_not:N } + { + \cs_if_exist:cTF { __regex_replacement_c_#2:w } + { \__regex_replacement_cat:NNN #2 } + { \__regex_replacement_error:NNN c #1#2 } + } } { \__regex_replacement_error:NNN c #1#2 } } -\cs_new_protected:cpn { __regex_replacement_c_ \c_left_brace_str :w } +\cs_new_protected:Npn \__regex_replacement_cu_aux:Nw #1 { \if_case:w \l__regex_replacement_csnames_int - \__tl_build_one:n - { \exp_not:n { \exp_after:wN \__regex_replacement_exp_not:N \cs:w } } + \__tl_build_one:n { \exp_not:n { \exp_after:wN #1 \cs:w } } \else: - \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:N \cs:w } } + \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } } \fi: \int_incr:N \l__regex_replacement_csnames_int } \cs_new_protected:Npn \__regex_replacement_u:w #1#2 { - \str_if_eq_x:nnTF { #1#2 } { \__tl_build_one:n \c_left_brace_str } - { - \if_case:w \l__regex_replacement_csnames_int - \__tl_build_one:n { \exp_not:n { \exp_after:wN \exp_not:V \cs:w } } - \else: - \__tl_build_one:n { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } } - \fi: - \int_incr:N \l__regex_replacement_csnames_int - } + \str_if_eq_x:nnTF { #1#2 } { \__regex_replacement_normal:n \c_left_brace_str } + { \__regex_replacement_cu_aux:Nw \exp_not:V } { \__regex_replacement_error:NNN u #1#2 } } \cs_new_protected:Npn \__regex_replacement_rbrace:N #1 @@ -2268,18 +2336,36 @@ \__tl_build_one:n \cs_end: \int_decr:N \l__regex_replacement_csnames_int \else: - \__tl_build_one:n #1 + \__regex_replacement_normal:n {#1} \fi: } +\cs_new_protected:Npn \__regex_replacement_cat:NNN #1#2#3 + { + \token_if_eq_meaning:NNTF \prg_do_nothing: #3 + { \__msg_kernel_error:nn { regex } { replacement-catcode-end } } + { + \int_compare:nNnTF { \l__regex_replacement_csnames_int } > 0 + { + \__msg_kernel_error:nnnn + { regex } { replacement-catcode-in-cs } {#1} {#3} + #2 #3 + } + { + \str_if_eq:nnTF { #2 #3 } { \__regex_replacement_normal:n ( } % ) + { + \seq_push:NV \l__regex_replacement_category_seq + \l__regex_replacement_category_tl + \tl_set:Nn \l__regex_replacement_category_tl {#1} + } + { \use:c { __regex_replacement_c_#1:w } #2 #3 } + } + } + } \group_begin: \cs_new_protected:Npn \__regex_replacement_char:nNN #1#2#3 { - \if_meaning:w \prg_do_nothing: #3 - \__msg_kernel_error:nn { regex } { replacement-catcode-end } - \else: - \tex_lccode:D 0 = `#3 \scan_stop: - \tex_lowercase:D { \__tl_build_one:n {#1} } - \fi: + \tex_lccode:D 0 = `#3 \scan_stop: + \tex_lowercase:D { \__tl_build_one:n {#1} } } \char_set_catcode_active:N \^^@ \cs_new_protected:Npn \__regex_replacement_c_A:w @@ -2324,15 +2410,11 @@ } \cs_new_protected:Npn \__regex_replacement_c_S:w #1#2 { - \if_meaning:w \prg_do_nothing: #2 - \__msg_kernel_error:nn { regex } { replacement-catcode-end } - \else: - \if_int_compare:w `#2 = 0 \exp_stop_f: - \__msg_kernel_error:nn { regex } { replacement-null-space } - \fi: - \tex_lccode:D `\ = `#2 \scan_stop: - \tex_lowercase:D { \__tl_build_one:n {~} } + \if_int_compare:w `#2 = 0 \exp_stop_f: + \__msg_kernel_error:nn { regex } { replacement-null-space } \fi: + \tex_lccode:D `\ = `#2 \scan_stop: + \tex_lowercase:D { \__tl_build_one:n {~} } } \char_set_catcode_alignment:N \^^@ \cs_new_protected:Npn \__regex_replacement_c_T:w @@ -2406,8 +2488,12 @@ \int_new:N \l__regex_match_count_int \flag_new:n { __regex_begin } \flag_new:n { __regex_end } +\int_new:N \l__regex_min_submatch_int \int_new:N \l__regex_submatch_int \int_new:N \l__regex_zeroth_submatch_int +\__intarray_new:Nn \g__regex_submatch_prev_intarray { 65536 } +\__intarray_new:Nn \g__regex_submatch_begin_intarray { 65536 } +\__intarray_new:Nn \g__regex_submatch_end_intarray { 65536 } \cs_new_protected:Npn \__regex_return: { \if_meaning:w \c_true_bool \g__regex_success_bool @@ -2461,15 +2547,29 @@ { \if_int_compare:w \l__regex_start_pos_int < \l__regex_success_pos_int \__regex_extract: - \tex_skip:D \l__regex_zeroth_submatch_int - = \l__regex_start_pos_int sp - plus \tex_skip:D \l__regex_zeroth_submatch_int \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_submatch_prev_intarray + { \l__regex_zeroth_submatch_int } { 0 } + \__intarray_gset_fast:Nnn \g__regex_submatch_end_intarray + { \l__regex_zeroth_submatch_int } + { + \__intarray_item_fast:Nn \g__regex_submatch_begin_intarray + { \l__regex_zeroth_submatch_int } + } + \__intarray_gset_fast:Nnn \g__regex_submatch_begin_intarray + { \l__regex_zeroth_submatch_int } + { \l__regex_start_pos_int } \fi: } #1 \__regex_match:n {#2} - \tex_skip:D \l__regex_submatch_int - = \l__regex_start_pos_int sp plus \l__regex_max_pos_int sp \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_submatch_prev_intarray + { \l__regex_submatch_int } { 0 } + \__intarray_gset_fast:Nnn \g__regex_submatch_end_intarray + { \l__regex_submatch_int } + { \l__regex_max_pos_int } + \__intarray_gset_fast:Nnn \g__regex_submatch_begin_intarray + { \l__regex_submatch_int } + { \l__regex_start_pos_int } \int_incr:N \l__regex_submatch_int \if_meaning:w \c_true_bool \l__regex_empty_success_bool \if_int_compare:w \l__regex_start_pos_int = \l__regex_max_pos_int @@ -2487,7 +2587,7 @@ { \s__seq \int_step_function:nnnN - { 2 * \l__regex_max_state_int } + { \l__regex_min_submatch_int } { 1 } { \l__regex_submatch_int - 1 } \__regex_extract_seq_aux:n @@ -2533,7 +2633,12 @@ \int_set_eq:NN \l__regex_zeroth_submatch_int \l__regex_submatch_int \prg_replicate:nn \l__regex_capturing_group_int { - \tex_skip:D \l__regex_submatch_int 0 sp \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_submatch_begin_intarray + { \l__regex_submatch_int } { 0 } + \__intarray_gset_fast:Nnn \g__regex_submatch_end_intarray + { \l__regex_submatch_int } { 0 } + \__intarray_gset_fast:Nnn \g__regex_submatch_prev_intarray + { \l__regex_submatch_int } { 0 } \int_incr:N \l__regex_submatch_int } \prop_map_inline:Nn \l__regex_success_submatches_prop @@ -2545,21 +2650,14 @@ \fi: \__int_eval:w \l__regex_zeroth_submatch_int + ##1 {##2} } - \tex_skip:D \l__regex_zeroth_submatch_int - = \tex_the:D \tex_skip:D \l__regex_zeroth_submatch_int - minus \l__regex_start_pos_int sp \scan_stop: + \__intarray_gset_fast:Nnn \g__regex_submatch_prev_intarray + { \l__regex_zeroth_submatch_int } { \l__regex_start_pos_int } \fi: } \cs_new_protected:Npn \__regex_extract_b:wn #1 < #2 - { - \tex_skip:D #1 = #2 sp - plus \etex_gluestretch:D \tex_skip:D #1 \scan_stop: - } + { \__intarray_gset_fast:Nnn \g__regex_submatch_begin_intarray {#1} {#2} } \cs_new_protected:Npn \__regex_extract_e:wn #1 > #2 - { - \tex_skip:D #1 - = 1 \tex_skip:D #1 plus #2 sp \scan_stop: - } + { \__intarray_gset_fast:Nnn \g__regex_submatch_end_intarray {#1} {#2} } \cs_new_protected:Npn \__regex_replace_once:nnN #1#2#3 { \group_begin: @@ -2580,7 +2678,10 @@ { \__regex_replacement_do_one_match:n { \l__regex_zeroth_submatch_int } \__regex_query_range:nn - { \etex_gluestretch:D \tex_skip:D \l__regex_zeroth_submatch_int } + { + \__intarray_item_fast:Nn \g__regex_submatch_end_intarray + { \l__regex_zeroth_submatch_int } + } { \l__regex_max_pos_int } } \__regex_group_end_replace:N #3 @@ -2597,7 +2698,7 @@ { 0 \int_step_function:nnnN - { 2 * \l__regex_max_state_int } + { \l__regex_min_submatch_int } \l__regex_capturing_group_int { \l__regex_submatch_int - 1 } \__regex_replacement_balance_one_match:n @@ -2605,7 +2706,7 @@ \tl_set:Nx \l__regex_internal_a_tl { \int_step_function:nnnN - { 2 * \l__regex_max_state_int } + { \l__regex_min_submatch_int } \l__regex_capturing_group_int { \l__regex_submatch_int - 1 } \__regex_replacement_do_one_match:n @@ -2641,38 +2742,38 @@ } } \__msg_kernel_new:nnnn { regex } { trailing-backslash } - { Trailing~escape~character~`\iow_char:N\\'. } + { Trailing~escape~character~'\iow_char:N\\'. } { A~regular~expression~or~its~replacement~text~ends~with~ - the~escape~character~`\iow_char:N\\'.~It~will~be~ignored. + the~escape~character~'\iow_char:N\\'.~It~will~be~ignored. } \__msg_kernel_new:nnnn { regex } { x-missing-rbrace } - { Missing~closing~brace~in~`\iow_char:N\\x'~hexadecimal~sequence. } + { Missing~closing~brace~in~'\iow_char:N\\x'~hexadecimal~sequence. } { You~wrote~something~like~ - `\iow_char:N\\x\{...#1'.~ + '\iow_char:N\\x\{...#1'.~ The~closing~brace~is~missing. } \__msg_kernel_new:nnnn { regex } { x-overflow } - { Character~code~`#1'~too~large~in~`\iow_char:N\\x'~hexadecimal~sequence. } + { Character~code~'#1'~too~large~in~'\iow_char:N\\x'~hexadecimal~sequence. } { You~wrote~something~like~ - `\iow_char:N\\x\{\int_to_Hex:n{#1}\}'.~ + '\iow_char:N\\x\{\int_to_Hex:n{#1}\}'.~ The~character~code~#1~is~larger~than~ the~maximum~value~\int_use:N \c_max_char_int. } \__msg_kernel_new:nnnn { regex } { invalid-quantifier } - { Braced~quantifier~`#1'~may~not~be~followed~by~`#2'. } + { Braced~quantifier~'#1'~may~not~be~followed~by~'#2'. } { - The~character~`#2'~is~invalid~in~the~braced~quantifier~`#1'.~ - The~only~valid~quantifiers~are~`*',~`?',~`+',~`{}',~ - `{,}'~and~`{,}',~optionally~followed~by~`?'. + The~character~'#2'~is~invalid~in~the~braced~quantifier~'#1'.~ + The~only~valid~quantifiers~are~'*',~'?',~'+',~'{}',~ + '{,}'~and~'{,}',~optionally~followed~by~'?'. } \__msg_kernel_new:nnnn { regex } { missing-rbrack } { Missing~right~bracket~inserted~in~regular~expression. } { LaTeX~was~given~a~regular~expression~where~a~character~class~ - was~started~with~`[',~but~the~matching~`]'~is~missing. + was~started~with~'[',~but~the~matching~']'~is~missing. } \__msg_kernel_new:nnnn { regex } { missing-rparen } { @@ -2692,7 +2793,7 @@ } \__msg_kernel_new:nnnn { regex } { bad-escape } { - Invalid~escape~`\iow_char:N\\#1'~ + Invalid~escape~'\iow_char:N\\#1'~ \__regex_if_in_cs:TF { within~a~control~sequence. } { \__regex_if_in_class:TF @@ -2701,102 +2802,102 @@ } } { - The~escape~sequence~`\iow_char:N\\#1'~may~not~appear~ + The~escape~sequence~'\iow_char:N\\#1'~may~not~appear~ \__regex_if_in_cs:TF { within~a~control~sequence~test~introduced~by~ - `\iow_char:N\\c\iow_char:N\{'. + '\iow_char:N\\c\iow_char:N\{'. } { \__regex_if_in_class:TF { within~a~character~class~ } - { following~a~category~test~such~as~`\iow_char:N\\cL'~ } + { following~a~category~test~such~as~'\iow_char:N\\cL'~ } because~it~does~not~match~exactly~one~character. } } \__msg_kernel_new:nnnn { regex } { range-missing-end } - { Invalid~end-point~for~range~`#1-#2'~in~character~class. } + { Invalid~end-point~for~range~'#1-#2'~in~character~class. } { - The~end-point~`#2'~of~the~range~`#1-#2'~may~not~serve~as~an~ + The~end-point~'#2'~of~the~range~'#1-#2'~may~not~serve~as~an~ end-point~for~a~range:~alphanumeric~characters~should~not~be~ escaped,~and~non-alphanumeric~characters~should~be~escaped. } \__msg_kernel_new:nnnn { regex } { range-backwards } - { Range~`[#1-#2]'~out~of~order~in~character~class. } + { Range~'[#1-#2]'~out~of~order~in~character~class. } { - In~ranges~of~characters~`[x-y]'~appearing~in~character~classes,~ + In~ranges~of~characters~'[x-y]'~appearing~in~character~classes,~ the~first~character~code~must~not~be~larger~than~the~second.~ - Here,~`#1'~has~character~code~\int_eval:n {`#1},~while~ - `#2'~has~character~code~\int_eval:n {`#2}. + Here,~'#1'~has~character~code~\int_eval:n {`#1},~while~ + '#2'~has~character~code~\int_eval:n {`#2}. } \__msg_kernel_new:nnnn { regex } { c-bad-mode } - { Invalid~nested~`\iow_char:N\\c'~escape~in~regular~expression. } + { Invalid~nested~'\iow_char:N\\c'~escape~in~regular~expression. } { - The~`\iow_char:N\\c'~escape~cannot~be~used~within~ - a~control~sequence~test~`\iow_char:N\\c{...}'.~ - To~combine~several~category~tests,~use~`\iow_char:N\\c[...]'. + The~'\iow_char:N\\c'~escape~cannot~be~used~within~ + a~control~sequence~test~'\iow_char:N\\c{...}'.~ + To~combine~several~category~tests,~use~'\iow_char:N\\c[...]'. } \__msg_kernel_new:nnnn { regex } { c-missing-rbrace } - { Missing~right~brace~inserted~for~`\iow_char:N\\c'~escape. } + { Missing~right~brace~inserted~for~'\iow_char:N\\c'~escape. } { LaTeX~was~given~a~regular~expression~where~a~ - `\iow_char:N\\c\iow_char:N\{...'~construction~was~not~ended~ - with~a~closing~brace~`\iow_char:N\}'. + '\iow_char:N\\c\iow_char:N\{...'~construction~was~not~ended~ + with~a~closing~brace~'\iow_char:N\}'. } \__msg_kernel_new:nnnn { regex } { c-missing-rbrack } - { Missing~right~bracket~inserted~for~`\iow_char:N\\c'~escape. } + { Missing~right~bracket~inserted~for~'\iow_char:N\\c'~escape. } { - A~construction~`\iow_char:N\\c[...'~appears~in~a~ - regular~expression,~but~the~closing~`]'~is~not~present. + A~construction~'\iow_char:N\\c[...'~appears~in~a~ + regular~expression,~but~the~closing~']'~is~not~present. } \__msg_kernel_new:nnnn { regex } { c-missing-category } - { Invalid~character~`#1'~following~`\iow_char:N\\c'~escape. } + { Invalid~character~'#1'~following~'\iow_char:N\\c'~escape. } { - In~regular~expressions,~the~`\iow_char:N\\c'~escape~sequence~ + In~regular~expressions,~the~'\iow_char:N\\c'~escape~sequence~ may~only~be~followed~by~a~left~brace,~a~left~bracket,~or~a~ capital~letter~representing~a~character~category,~namely~ - one~of~`ABCDELMOPSTU'. + one~of~'ABCDELMOPSTU'. } \__msg_kernel_new:nnnn { regex } { c-trailing } - { Trailing~category~code~escape~`\iow_char:N\\c'... } + { Trailing~category~code~escape~'\iow_char:N\\c'... } { - A~regular~expression~ends~with~`\iow_char:N\\c'~followed~ + A~regular~expression~ends~with~'\iow_char:N\\c'~followed~ by~a~letter.~It~will~be~ignored. } \__msg_kernel_new:nnnn { regex } { u-missing-lbrace } - { Missing~left~brace~following~`\iow_char:N\\u'~escape. } + { Missing~left~brace~following~'\iow_char:N\\u'~escape. } { - The~`\iow_char:N\\u'~escape~sequence~must~be~followed~by~ + The~'\iow_char:N\\u'~escape~sequence~must~be~followed~by~ a~brace~group~with~the~name~of~the~variable~to~use. } \__msg_kernel_new:nnnn { regex } { u-missing-rbrace } - { Missing~right~brace~inserted~for~`\iow_char:N\\u'~escape. } + { Missing~right~brace~inserted~for~'\iow_char:N\\u'~escape. } { LaTeX~ \str_if_eq_x:nnTF { } {#2} { reached~the~end~of~the~string~ } - { encountered~an~escaped~alphanumeric~character `\iow_char:N\\#2'~ } - when~parsing~the~argument~of~an~`\iow_char:N\\u\iow_char:N\{...\}'~escape. + { encountered~an~escaped~alphanumeric~character '\iow_char:N\\#2'~ } + when~parsing~the~argument~of~an~'\iow_char:N\\u\iow_char:N\{...\}'~escape. } \__msg_kernel_new:nnnn { regex } { posix-unsupported } - { POSIX~collating~element~`[#1 ~ #1]'~not~supported. } + { POSIX~collating~element~'[#1 ~ #1]'~not~supported. } { - The~`[.foo.]'~and~`[=bar=]'~syntaxes~have~a~special~meaning~ + The~'[.foo.]'~and~'[=bar=]'~syntaxes~have~a~special~meaning~ in~POSIX~regular~expressions.~This~is~not~supported~by~LaTeX.~ Maybe~you~forgot~to~escape~a~left~bracket~in~a~character~class? } \__msg_kernel_new:nnnn { regex } { posix-unknown } - { POSIX~class~`[:#1:]'~unknown. } + { POSIX~class~'[:#1:]'~unknown. } { - `[:#1:]'~is~not~among~the~known~POSIX~classes~ - `[:alnum:]',~`[:alpha:]',~`[:ascii:]',~`[:blank:]',~ - `[:cntrl:]',~`[:digit:]',~`[:graph:]',~`[:lower:]',~ - `[:print:]',~`[:punct:]',~`[:space:]',~`[:upper:]',~ - `[:word:]',~and~`[:xdigit:]'. + '[:#1:]'~is~not~among~the~known~POSIX~classes~ + '[:alnum:]',~'[:alpha:]',~'[:ascii:]',~'[:blank:]',~ + '[:cntrl:]',~'[:digit:]',~'[:graph:]',~'[:lower:]',~ + '[:print:]',~'[:punct:]',~'[:space:]',~'[:upper:]',~ + '[:word:]',~and~'[:xdigit:]'. } \__msg_kernel_new:nnnn { regex } { posix-missing-close } - { Missing~closing~`:]'~for~POSIX~class. } - { The~POSIX~syntax~`#1'~must~be~followed~by~`:]',~not~`#2'. } + { Missing~closing~':]'~for~POSIX~class. } + { The~POSIX~syntax~'#1'~must~be~followed~by~':]',~not~'#2'. } \__msg_kernel_new:nnnn { regex } { result-unbalanced } { Missing~brace~inserted~when~#1. } { @@ -2806,58 +2907,68 @@ #2~left,~#3~right. } \__msg_kernel_new:nnnn { regex } { unknown-option } - { Unknown~option~`#1'~for~regular~expressions. } + { Unknown~option~'#1'~for~regular~expressions. } { - The~only~available~option~is~`case-insensitive',~toggled~by~ - `(?i)'~and~`(?-i)'. + The~only~available~option~is~'case-insensitive',~toggled~by~ + '(?i)'~and~'(?-i)'. } \__msg_kernel_new:nnnn { regex } { special-group-unknown } - { Unknown~special~group~`#1~...'~in~a~regular~expression. } + { Unknown~special~group~'#1~...'~in~a~regular~expression. } { - The~only~valid~constructions~starting~with~`(?'~are~ - `(?:~...~)',~`(?|~...~)',~`(?i)',~and~`(?-i)'. + The~only~valid~constructions~starting~with~'(?'~are~ + '(?:~...~)',~'(?|~...~)',~'(?i)',~and~'(?-i)'. } \__msg_kernel_new:nnnn { regex } { replacement-c } - { Misused~`\iow_char:N\\c'~command~in~a~replacement~text. } + { Misused~'\iow_char:N\\c'~command~in~a~replacement~text. } { - In~a~replacement~text,~the~`\iow_char:N\\c'~escape~sequence~ - can~be~followed~by~one~of~the~letters~`ABCDELMOPSTU'~ - or~a~brace~group,~not~by~`#1'. + In~a~replacement~text,~the~'\iow_char:N\\c'~escape~sequence~ + can~be~followed~by~one~of~the~letters~'ABCDELMOPSTU'~ + or~a~brace~group,~not~by~'#1'. } \__msg_kernel_new:nnnn { regex } { replacement-u } - { Misused~`\iow_char:N\\u'~command~in~a~replacement~text. } + { Misused~'\iow_char:N\\u'~command~in~a~replacement~text. } { - In~a~replacement~text,~the~`\iow_char:N\\u'~escape~sequence~ + In~a~replacement~text,~the~'\iow_char:N\\u'~escape~sequence~ must~be~~followed~by~a~brace~group~holding~the~name~of~the~ variable~to~use. } \__msg_kernel_new:nnnn { regex } { replacement-g } { - Missing~brace~for~the~`\iow_char:N\\g'~construction~ + Missing~brace~for~the~'\iow_char:N\\g'~construction~ in~a~replacement~text. } { In~the~replacement~text~for~a~regular~expression~search,~ - submatches~are~represented~either~as~`\iow_char:N \\g{dd..d}',~ - or~`\\d',~where~`d'~are~single~digits.~Here,~a~brace~is~missing. + submatches~are~represented~either~as~'\iow_char:N \\g{dd..d}',~ + or~'\\d',~where~'d'~are~single~digits.~Here,~a~brace~is~missing. } \__msg_kernel_new:nnnn { regex } { replacement-catcode-end } { - Missing~character~for~the~`\iow_char:N\\c'~ + Missing~character~for~the~'\iow_char:N\\c'~ construction~in~a~replacement~text. } { - In~a~replacement~text,~the~`\iow_char:N\\c'~escape~sequence~ - can~be~followed~by~one~of~the~letters~`ABCDELMOPSTU'~representing~ + In~a~replacement~text,~the~'\iow_char:N\\c'~escape~sequence~ + can~be~followed~by~one~of~the~letters~'ABCDELMOPSTU'~representing~ the~character~category.~Then,~a~character~must~follow.~LaTeX~ reached~the~end~of~the~replacement~when~looking~for~that. } +\__msg_kernel_new:nnnn { regex } { replacement-catcode-in-cs } + { + Category~code~'\iow_char:N\\c#1#3'~ignored~inside~ + '\iow_char:N\\c\{...\}'~in~a~replacement~text. + } + { + In~a~replacement~text,~the~category~codes~of~the~argument~of~ + '\iow_char:N\\c\{...\}'~are~ignored~when~building~the~control~ + sequence~name. + } \__msg_kernel_new:nnnn { regex } { replacement-null-space } { TeX~cannot~build~a~space~token~with~character~code~0. } { You~asked~for~a~character~token~with~category~space,~ and~character~code~0,~for~instance~through~ - `\iow_char:N\\cS\iow_char:N\\x00'.~ + '\iow_char:N\\cS\iow_char:N\\x00'.~ This~specific~case~is~impossible~and~will~be~replaced~ by~a~normal~space. } @@ -2867,6 +2978,12 @@ There~ \int_compare:nTF { #1 = 1 } { was } { were } ~ #1~ missing~right~\int_compare:nTF { #1 = 1 } { brace } { braces } . } +\__msg_kernel_new:nnnn { regex } { replacement-missing-rparen } + { Missing~right~parenthesis~inserted~in~replacement~text. } + { + There~ \int_compare:nTF { #1 = 1 } { was } { were } ~ #1~ + missing~right~\int_compare:nTF { #1 = 1 } { parenthesis } { parentheses } . + } \cs_new:Npn \__regex_msg_repeated:nnN #1#2#3 { \str_if_eq_x:nnF { #1 #2 } { 1 0 } diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-convert.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-convert.sty index d7998754945..b7216bd406a 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-convert.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-convert.sty @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `package') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of @@ -20,7 +20,7 @@ %% %% File: l3str-convert.dtx Copyright (C) 2013-2017 The LaTeX3 Project \RequirePackage{expl3} -\ProvidesExplPackage{l3str-convert}{2017/04/01}{} +\ProvidesExplPackage{l3str-convert}{2017/05/13}{} {L3 Experimental string encoding conversions} \RequirePackage{l3tl-analysis,l3tl-build} \cs_if_exist:NF \use_ii_i:nn @@ -31,10 +31,6 @@ \tl_new:N \g__str_result_tl \int_const:Nn \c__str_replacement_char_int { "FFFD } \int_const:Nn \c__str_max_byte_int { 255 } -\int_const:Nn \c__str_ascii_min_int { 0 } -\int_const:Nn \c__str_ascii_max_control_int { 31 } -\int_const:Nn \c__str_ascii_max_int { 127 } -\int_const:Nn \c__str_ascii_lower_int { `a - `A } \prop_new:N \g__str_alias_prop \prop_gput:Nnn \g__str_alias_prop { latin1 } { iso88591 } \prop_gput:Nnn \g__str_alias_prop { latin2 } { iso88592 } @@ -54,32 +50,6 @@ \bool_new:N \g__str_error_bool \flag_new:n { str_byte } \flag_new:n { str_error } -\group_begin: -\char_set_lccode:nn { `\* } { `\ } -\char_set_lccode:nn { `\A } { `\A } -\tex_lowercase:D - { - \group_end: - \cs_new_protected:Npn \__str_gset_other:Nn #1#2 - { - \tl_gset:Nx #1 - { - \exp_after:wN \__str_gset_other_loop:w \tl_to_str:n {#2} ~ % - A ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ A ~ \q_stop - } - } - \cs_new:Npn \__str_gset_other_loop:w - #1 ~ #2 ~ #3 ~ #4 ~ #5 ~ #6 ~ #7 ~ #8 ~ #9 ~ - { - \if_meaning:w A #9 - \__str_gset_other_end:w - \fi: - #1 * #2 * #3 * #4 * #5 * #6 * #7 * #8 * #9 - \__str_gset_other_loop:w * - } - \cs_new:Npn \__str_gset_other_end:w \fi: #1 * A #2 \q_stop - { \fi: #1 } - } \prg_new_conditional:Npnn \__str_if_contains_char:NN #1#2 { T , TF } { \exp_after:wN \__str_if_contains_char_aux:NN \exp_after:wN #2 @@ -245,7 +215,7 @@ { \group_begin: #1 - \__str_gset_other:Nn \g__str_result_tl {#4} + \tl_gset:Nx \g__str_result_tl { \__str_to_other_fast:n {#4} } \exp_after:wN \__str_convert:wwwnn \tl_to_str:n {#5} /// \q_stop { decode } { unescape } @@ -335,7 +305,7 @@ #1 \fi: \else: - \__str_output_byte:n { `#1 + \c__str_ascii_lower_int } + \__str_output_byte:n { `#1 + `a - `A } \fi: \fi: \__str_convert_lowercase_alphanum_loop:N diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88591.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88591.def index 4ec7d5c8d75..60be5c7f1b2 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88591.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88591.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso88591') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885910.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885910.def index 6aed0dcb9ef..a651b227cc1 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885910.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885910.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso885910') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885911.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885911.def index f551a2ac4ad..1a48cc8bec3 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885911.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885911.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso885911') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885913.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885913.def index 1c44066f1af..948072f8ac6 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885913.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885913.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso885913') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885914.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885914.def index 75814fbb8ad..6faf3e101b2 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885914.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885914.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso885914') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885915.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885915.def index fb0bba2e5ad..f6846a10f99 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885915.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885915.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso885915') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885916.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885916.def index 89d59900f77..ef5c375d337 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885916.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso885916.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso885916') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88592.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88592.def index 584fb3de28b..9b036d2488f 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88592.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88592.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso88592') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88593.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88593.def index 3ec8d60de3f..f7014f192af 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88593.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88593.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso88593') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88594.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88594.def index c2c3aaf7ed3..d388165099a 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88594.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88594.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso88594') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88595.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88595.def index 9a22152f36e..d9f12eed1da 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88595.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88595.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso88595') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88596.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88596.def index 37d058df1ac..0431f27c25d 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88596.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88596.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso88596') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88597.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88597.def index 101b2225c5c..d7358bdb9b1 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88597.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88597.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso88597') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88598.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88598.def index 8183ea85048..68f7b576f29 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88598.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88598.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso88598') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88599.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88599.def index 0f6bf25306e..4ac243c585c 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88599.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-iso88599.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `iso88599') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf16.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf16.def index 431b242f550..f180be34a57 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf16.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf16.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `utf16') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf32.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf32.def index 6f466ba400d..c1c2c5ca595 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf32.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf32.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `utf32') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf8.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf8.def index 4518878b883..c3bc0506f64 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf8.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-enc-utf8.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `utf8') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-hex.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-hex.def index 3a5e52a5fdc..d3ed4b3c947 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-hex.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-hex.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `hex') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-name.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-name.def index b01837f7369..150e208bafb 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-name.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-name.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `name') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-string.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-string.def index 83982d00b9f..b2c8c75fbd0 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-string.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-string.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `string') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-url.def b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-url.def index 8176cf9106e..5459b12971b 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-url.def +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-esc-url.def @@ -6,7 +6,7 @@ %% %% l3str-convert.dtx (with options: `url') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-format.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-format.sty index 8c2f7a98001..abbaec08ea3 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-format.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3str-format.sty @@ -6,7 +6,7 @@ %% %% l3str-format.dtx (with options: `package') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of @@ -20,7 +20,7 @@ %% %% File: l3str-format.dtx Copyright (C) 2012-2013,2015-2017 The LaTeX3 Project \RequirePackage{expl3} -\ProvidesExplPackage{l3str-format}{2017/04/01}{} +\ProvidesExplPackage{l3str-format}{2017/05/13}{} {L3 Experimental string formatting} \RequirePackage{l3str} \cs_generate_variant:Nn \use:nn { nf } diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-analysis.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-analysis.sty index 0a8ca847851..9b336143d14 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-analysis.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-analysis.sty @@ -6,7 +6,7 @@ %% %% l3tl-analysis.dtx (with options: `package') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of @@ -20,7 +20,7 @@ %% %% File: l3tl-analysis.dtx Copyright (C) 2011-2012,2015-2017 The LaTeX3 Project \RequirePackage{expl3} -\ProvidesExplPackage{l3tl-analysis}{2017/04/01}{} +\ProvidesExplPackage{l3tl-analysis}{2017/05/13}{} {L3 Experimental token list analysis} \__scan_new:N \s__tl \tl_new:N \l__tl_analysis_internal_tl @@ -67,8 +67,9 @@ { \int_set:Nn \tex_escapechar:D { -1 } \exp_after:wN \__tl_analysis_disable_loop:N - \tl_to_str:n {#1} { ~ } { ? ~ \__prg_break: } + \tl_to_str:n {#1} { ~ } { ? \__prg_break: } \__prg_break_point: + \scan_stop: } \group_begin: \char_set_catcode_active:N \^^@ @@ -78,6 +79,20 @@ \tex_lowercase:D { \tex_let:D ^^@ } \tex_undefined:D \__tl_analysis_disable_loop:N } + \bool_lazy_or:nnT + { \sys_if_engine_ptex_p: } + { \sys_if_engine_uptex_p: } + { + \cs_gset_protected:Npn \__tl_analysis_disable_loop:N #1 + { + \use_none:n #1 \scan_stop: + \if_int_compare:w 256 > `#1 \exp_stop_f: + \tex_lccode:D 0 = `#1 ~ + \tex_lowercase:D { \tex_let:D ^^@ } \tex_undefined:D + \fi: + \__tl_analysis_disable_loop:N + } + } \group_end: \cs_new_protected:Npn \__tl_analysis_a:n #1 { diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-build.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-build.sty index a176d86fde3..9feca451233 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-build.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3tl-build.sty @@ -6,7 +6,7 @@ %% %% l3tl-build.dtx (with options: `package') %% -%% Copyright (C) 2011-2016 The LaTeX3 Project +%% Copyright (C) 2011-2017 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of %% the LaTeX Project Public License (LPPL), either version 1.3c of @@ -19,8 +19,8 @@ %% and all files in that bundle must be distributed together. %% %% File: l3tl-build.dtx Copyright (C) 2011-2017 The LaTeX3 Project -\RequirePackage{expl3}[2017/04/01] -\@ifpackagelater{expl3}{2017/04/01} +\RequirePackage{expl3}[2017/05/13] +\@ifpackagelater{expl3}{2017/05/13} {} {% \PackageError{l3tl-build}{Support package l3kernel too old} @@ -32,7 +32,7 @@ }% \endinput } -\ProvidesExplPackage{l3tl-build}{2017/04/01}{} +\ProvidesExplPackage{l3tl-build}{2017/05/13}{} {L3 Experimental token list construction} \int_new:N \l__tl_build_start_index_int \int_new:N \l__tl_build_index_int diff --git a/Master/texmf-dist/tex/latex/l3experimental/xcoffins/xcoffins.sty b/Master/texmf-dist/tex/latex/l3experimental/xcoffins/xcoffins.sty index 9df0824a280..1e2905d4cf4 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/xcoffins/xcoffins.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/xcoffins/xcoffins.sty @@ -20,7 +20,7 @@ %% %% File: xcoffins.dtx Copyright(C) 2010-2012,2014,2016,2017 The LaTeX3 Project \RequirePackage{xparse} -\ProvidesExplPackage{xcoffins}{2017/04/01}{} +\ProvidesExplPackage{xcoffins}{2017/05/13}{} {L3 Experimental design level coffins} \keys_define:nn { coffin } { diff --git a/Master/texmf-dist/tex/latex/l3experimental/xgalley/l3galley.sty b/Master/texmf-dist/tex/latex/l3experimental/xgalley/l3galley.sty index 6318649f93e..f4e6e5574f4 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/xgalley/l3galley.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/xgalley/l3galley.sty @@ -20,8 +20,8 @@ %% %% File: l3galley.dtx Copyright (C) 1999-2001, 2004-2009 Frank Mittelbach %% (C) 2010-2017 The LaTeX3 Project -\RequirePackage{expl3}[2017/04/01] -\@ifpackagelater{expl3}{2017/04/01} +\RequirePackage{expl3}[2017/05/13] +\@ifpackagelater{expl3}{2017/05/13} {} {% \PackageError{l3galley}{Support package l3kernel too old} @@ -33,7 +33,7 @@ }% \endinput } -\ProvidesExplPackage{l3galley}{2017/04/01}{} +\ProvidesExplPackage{l3galley}{2017/05/13}{} {L3 Experimental galley code} \int_new:N \l__galley_tmp_int \seq_new:N \g__galley_tmpa_seq @@ -274,7 +274,7 @@ \cs_new_protected:Npn \galley_par:n #1 { \s__par_omit - \bool_if:nF \g__galley_begin_level_bool + \bool_if:NF \g__galley_begin_level_bool { #1 \galley_par: diff --git a/Master/texmf-dist/tex/latex/l3experimental/xgalley/xgalley.sty b/Master/texmf-dist/tex/latex/l3experimental/xgalley/xgalley.sty index 8027687f2eb..13e44bce0fd 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/xgalley/xgalley.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/xgalley/xgalley.sty @@ -21,7 +21,7 @@ %% File: xgalley.dtx Copyright (C) 1999-2001, 2004-2009 Frank Mittelbach %% (C) 2010-2012,2014,2016-2017 The LaTeX3 Project \RequirePackage{xparse} -\ProvidesExplPackage{xgalley}{2017/04/01}{} +\ProvidesExplPackage{xgalley}{2017/05/13}{} {L3 Experimental galley} \RequirePackage{xparse,xtemplate,l3galley} \clist_new:N \l__galley_tmpa_clist diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex b/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex index f0604e11f7c..16769c81796 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex @@ -58,7 +58,7 @@ %% and all files in that bundle must be distributed together. %% %% File: expl3.dtx Copyright (C) 1990-2017 The LaTeX3 Project -\def\ExplFileDate{2017/04/01}% +\def\ExplFileDate{2017/05/13}% \begingroup \def\next{\endgroup}% \expandafter\ifx\csname PackageError\endcsname\relax @@ -3064,7 +3064,8 @@ \cs_new_protected:Npn \tl_map_inline:nn #1#2 { \int_gincr:N \g__prg_map_int - \cs_gset:cpn { __prg_map_ \int_use:N \g__prg_map_int :w } ##1 {#2} + \cs_gset_protected:cpn + { __prg_map_ \int_use:N \g__prg_map_int :w } ##1 {#2} \exp_args:Nc \__tl_map_function:Nn { __prg_map_ \int_use:N \g__prg_map_int :w } #1 \q_recursion_tail @@ -4788,7 +4789,7 @@ \cs_generate_variant:Nn \int_gincr:N { c } \cs_generate_variant:Nn \int_gdecr:N { c } \cs_new_protected:Npn \int_set:Nn #1#2 - { #1 ~ \__int_eval:w #2\__int_eval_end: } + { #1 ~ \__int_eval:w #2 \__int_eval_end: } \cs_new_protected:Npn \int_gset:Nn { \tex_global:D \int_set:Nn } \cs_generate_variant:Nn \int_set:Nn { c } \cs_generate_variant:Nn \int_gset:Nn { c } @@ -5005,14 +5006,14 @@ { \int_gincr:N \g__prg_map_int \exp_args:NNc \__int_step:NNnnnn - \cs_gset:Npn + \cs_gset_protected:Npn { __prg_map_ \int_use:N \g__prg_map_int :w } } \cs_new_protected:Npn \int_step_variable:nnnNn #1#2#3#4#5 { \int_gincr:N \g__prg_map_int \exp_args:NNc \__int_step:NNnnnn - \cs_gset:Npx + \cs_gset_protected:Npx { __prg_map_ \int_use:N \g__prg_map_int :w } {#1}{#2}{#3} { @@ -6307,7 +6308,8 @@ \clist_if_empty:NF #1 { \int_gincr:N \g__prg_map_int - \cs_gset:cpn { __prg_map_ \int_use:N \g__prg_map_int :w } ##1 {#2} + \cs_gset_protected:cpn + { __prg_map_ \int_use:N \g__prg_map_int :w } ##1 {#2} \exp_last_unbraced:Nco \__clist_map_function:Nw { __prg_map_ \int_use:N \g__prg_map_int :w } #1 , \q_recursion_tail , @@ -7474,7 +7476,7 @@ \cs_gset_eq:cN { __prg_map_ \int_use:N \g__prg_map_int :wn } \__prop_pair:wn \int_gincr:N \g__prg_map_int - \cs_gset:Npn \__prop_pair:wn ##1 \s__prop ##2 {#2} + \cs_gset_protected:Npn \__prop_pair:wn ##1 \s__prop ##2 {#2} #1 \__prg_break_point:Nn \prop_map_break: { @@ -11329,10 +11331,13 @@ { \cs_if_exist_use:cF { __fp_parse_word_#2:N } { - \__msg_kernel_expandable_error:nnn - { kernel } { unknown-fp-word } {#2} - \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w - \__fp_parse_infix:NN + \cs_if_exist_use:cF { __fp_parse_caseless_ \str_fold_case:n {#2} :N } + { + \__msg_kernel_expandable_error:nnn + { kernel } { unknown-fp-word } {#2} + \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w + \__fp_parse_infix:NN + } } #1 } @@ -11823,6 +11828,9 @@ \__fp_tmp:w { deg } \c_one_degree_fp \__fp_tmp:w { true } \c_one_fp \__fp_tmp:w { false } \c_zero_fp +\cs_new_eq:NN \__fp_parse_caseless_inf:N \__fp_parse_word_inf:N +\cs_new_eq:NN \__fp_parse_caseless_infinity:N \__fp_parse_word_inf:N +\cs_new_eq:NN \__fp_parse_caseless_nan:N \__fp_parse_word_nan:N \cs_set_protected:Npn \__fp_tmp:w #1 #2 { \cs_new:cpn { __fp_parse_word_#1:N } @@ -12512,13 +12520,29 @@ } } \cs_generate_variant:Nn \__fp_step:NnnnnN { Nf } -\cs_new_protected:Npn \fp_step_inline:nnnn #1#2#3#4 +\cs_new_protected:Npn \fp_step_inline:nnnn + { + \int_gincr:N \g__prg_map_int + \exp_args:NNc \__fp_step:NNnnnn + \cs_gset_protected:Npn + { __prg_map_ \int_use:N \g__prg_map_int :w } + } +\cs_new_protected:Npn \fp_step_variable:nnnNn #1#2#3#4#5 { \int_gincr:N \g__prg_map_int - \cs_gset_protected:cpn { __prg_map_ \int_use:N \g__prg_map_int :w } - ##1 {#4} - \fp_step_function:nnnc {#1} {#2} {#3} + \exp_args:NNc \__fp_step:NNnnnn + \cs_gset_protected:Npx { __prg_map_ \int_use:N \g__prg_map_int :w } + {#1} {#2} {#3} + { + \tl_set:Nn \exp_not:N #4 {##1} + \exp_not:n {#5} + } + } +\cs_new_protected:Npn \__fp_step:NNnnnn #1#2#3#4#5#6 + { + #1 #2 ##1 {#6} + \fp_step_function:nnnN {#3} {#4} {#5} #2 \__prg_break_point:Nn \scan_stop: { \int_gdecr:N \g__prg_map_int } } \__msg_kernel_new:nnn { kernel } { fp-bad-step } @@ -16320,29 +16344,45 @@ } } \cs_generate_variant:Nn \__box_show:NNnn { NNff } -\cs_new_protected:Npn \hbox:n #1 { \tex_hbox:D \scan_stop: {#1} } +\cs_new_protected:Npn \hbox:n #1 + { \tex_hbox:D \scan_stop: { \group_begin: #1 \group_end: } } \cs_new_protected:Npn \hbox_set:Nn #1#2 - { \tex_setbox:D #1 \tex_hbox:D {#2} } + { \tex_setbox:D #1 \tex_hbox:D { \group_begin: #2 \group_end: } } \cs_new_protected:Npn \hbox_gset:Nn { \tex_global:D \hbox_set:Nn } \cs_generate_variant:Nn \hbox_set:Nn { c } \cs_generate_variant:Nn \hbox_gset:Nn { c } \cs_new_protected:Npn \hbox_set_to_wd:Nnn #1#2#3 - { \tex_setbox:D #1 \tex_hbox:D to \__dim_eval:w #2 \__dim_eval_end: {#3} } + { + \tex_setbox:D #1 \tex_hbox:D to \__dim_eval:w #2 \__dim_eval_end: + { \group_begin: #3 \group_end: } + } \cs_new_protected:Npn \hbox_gset_to_wd:Nnn { \tex_global:D \hbox_set_to_wd:Nnn } \cs_generate_variant:Nn \hbox_set_to_wd:Nnn { c } \cs_generate_variant:Nn \hbox_gset_to_wd:Nnn { c } \cs_new_protected:Npn \hbox_set:Nw #1 - { \tex_setbox:D #1 \tex_hbox:D \c_group_begin_token } + { + \tex_setbox:D #1 \tex_hbox:D + \c_group_begin_token + \group_begin: + } \cs_new_protected:Npn \hbox_gset:Nw { \tex_global:D \hbox_set:Nw } \cs_generate_variant:Nn \hbox_set:Nw { c } \cs_generate_variant:Nn \hbox_gset:Nw { c } -\cs_new_eq:NN \hbox_set_end: \c_group_end_token -\cs_new_eq:NN \hbox_gset_end: \c_group_end_token +\cs_new_protected:Npn \hbox_set_end: + { + \group_end: + \c_group_end_token + } +\cs_new_eq:NN \hbox_gset_end: \hbox_set_end: \cs_new_protected:Npn \hbox_to_wd:nn #1#2 - { \tex_hbox:D to \__dim_eval:w #1 \__dim_eval_end: {#2} } -\cs_new_protected:Npn \hbox_to_zero:n #1 { \tex_hbox:D to \c_zero_dim {#1} } + { + \tex_hbox:D to \__dim_eval:w #1 \__dim_eval_end: + { \group_begin: #2 \group_end: } + } +\cs_new_protected:Npn \hbox_to_zero:n #1 + { \tex_hbox:D to \c_zero_dim { \group_begin: #1 \group_end: } } \cs_new_protected:Npn \hbox_overlap_left:n #1 { \hbox_to_zero:n { \tex_hss:D #1 } } \cs_new_protected:Npn \hbox_overlap_right:n #1 @@ -16351,19 +16391,33 @@ \cs_new_eq:NN \hbox_unpack_clear:N \tex_unhbox:D \cs_generate_variant:Nn \hbox_unpack:N { c } \cs_generate_variant:Nn \hbox_unpack_clear:N { c } -\cs_new_protected:Npn \vbox:n #1 { \tex_vbox:D { #1 \par } } -\cs_new_protected:Npn \vbox_top:n #1 { \tex_vtop:D { #1 \par } } +\cs_new_protected:Npn \vbox:n #1 + { \tex_vbox:D { \group_begin: #1 \par \group_end: } } +\cs_new_protected:Npn \vbox_top:n #1 + { \tex_vtop:D { \group_begin: #1 \par \group_end: } } \cs_new_protected:Npn \vbox_to_ht:nn #1#2 - { \tex_vbox:D to \__dim_eval:w #1 \__dim_eval_end: { #2 \par } } + { + \tex_vbox:D to \__dim_eval:w #1 \__dim_eval_end: + { \group_begin: #2 \par \group_end: } + } \cs_new_protected:Npn \vbox_to_zero:n #1 - { \tex_vbox:D to \c_zero_dim { #1 \par } } + { + \tex_vbox:D to \c_zero_dim + { \group_begin: #1 \par \group_end: } + } \cs_new_protected:Npn \vbox_set:Nn #1#2 - { \tex_setbox:D #1 \tex_vbox:D { #2 \par } } + { + \tex_setbox:D #1 \tex_vbox:D + { \group_begin: #2 \par \group_end: } + } \cs_new_protected:Npn \vbox_gset:Nn { \tex_global:D \vbox_set:Nn } \cs_generate_variant:Nn \vbox_set:Nn { c } \cs_generate_variant:Nn \vbox_gset:Nn { c } \cs_new_protected:Npn \vbox_set_top:Nn #1#2 - { \tex_setbox:D #1 \tex_vtop:D { #2 \par } } + { + \tex_setbox:D #1 \tex_vtop:D + { \group_begin: #2 \par \group_end: } + } \cs_new_protected:Npn \vbox_gset_top:Nn { \tex_global:D \vbox_set_top:Nn } \cs_generate_variant:Nn \vbox_set_top:Nn { c } @@ -16371,21 +16425,26 @@ \cs_new_protected:Npn \vbox_set_to_ht:Nnn #1#2#3 { \tex_setbox:D #1 \tex_vbox:D to \__dim_eval:w #2 \__dim_eval_end: - { #3 \par } + { \group_begin: #3 \par \group_end: } } \cs_new_protected:Npn \vbox_gset_to_ht:Nnn { \tex_global:D \vbox_set_to_ht:Nnn } \cs_generate_variant:Nn \vbox_set_to_ht:Nnn { c } \cs_generate_variant:Nn \vbox_gset_to_ht:Nnn { c } \cs_new_protected:Npn \vbox_set:Nw #1 - { \tex_setbox:D #1 \tex_vbox:D \c_group_begin_token } + { + \tex_setbox:D #1 \tex_vbox:D + \c_group_begin_token + \group_begin: + } \cs_new_protected:Npn \vbox_gset:Nw { \tex_global:D \vbox_set:Nw } \cs_generate_variant:Nn \vbox_set:Nw { c } \cs_generate_variant:Nn \vbox_gset:Nw { c } \cs_new_protected:Npn \vbox_set_end: { - \par + \par + \group_end: \c_group_end_token } \cs_new_eq:NN \vbox_gset_end: \vbox_set_end: @@ -16395,210 +16454,504 @@ \cs_generate_variant:Nn \vbox_unpack_clear:N { c } \cs_new_protected:Npn \vbox_set_split_to_ht:NNn #1#2#3 { \tex_setbox:D #1 \tex_vsplit:D #2 to \__dim_eval:w #3 \__dim_eval_end: } -%% File: l3coffins.dtx Copyright(C) 2010-2017 The LaTeX3 Project -\box_new:N \l__coffin_internal_box -\dim_new:N \l__coffin_internal_dim -\tl_new:N \l__coffin_internal_tl -\prop_new:N \c__coffin_corners_prop -\prop_put:Nnn \c__coffin_corners_prop { tl } { { 0 pt } { 0 pt } } -\prop_put:Nnn \c__coffin_corners_prop { tr } { { 0 pt } { 0 pt } } -\prop_put:Nnn \c__coffin_corners_prop { bl } { { 0 pt } { 0 pt } } -\prop_put:Nnn \c__coffin_corners_prop { br } { { 0 pt } { 0 pt } } -\prop_new:N \c__coffin_poles_prop -\tl_set:Nn \l__coffin_internal_tl { { 0 pt } { 0 pt } { 0 pt } { 1000 pt } } -\prop_put:Nno \c__coffin_poles_prop { l } { \l__coffin_internal_tl } -\prop_put:Nno \c__coffin_poles_prop { hc } { \l__coffin_internal_tl } -\prop_put:Nno \c__coffin_poles_prop { r } { \l__coffin_internal_tl } -\tl_set:Nn \l__coffin_internal_tl { { 0 pt } { 0 pt } { 1000 pt } { 0 pt } } -\prop_put:Nno \c__coffin_poles_prop { b } { \l__coffin_internal_tl } -\prop_put:Nno \c__coffin_poles_prop { vc } { \l__coffin_internal_tl } -\prop_put:Nno \c__coffin_poles_prop { t } { \l__coffin_internal_tl } -\prop_put:Nno \c__coffin_poles_prop { B } { \l__coffin_internal_tl } -\prop_put:Nno \c__coffin_poles_prop { H } { \l__coffin_internal_tl } -\prop_put:Nno \c__coffin_poles_prop { T } { \l__coffin_internal_tl } -\fp_new:N \l__coffin_slope_x_fp -\fp_new:N \l__coffin_slope_y_fp -\bool_new:N \l__coffin_error_bool -\dim_new:N \l__coffin_offset_x_dim -\dim_new:N \l__coffin_offset_y_dim -\tl_new:N \l__coffin_pole_a_tl -\tl_new:N \l__coffin_pole_b_tl -\dim_new:N \l__coffin_x_dim -\dim_new:N \l__coffin_y_dim -\dim_new:N \l__coffin_x_prime_dim -\dim_new:N \l__coffin_y_prime_dim -\prg_new_conditional:Npnn \coffin_if_exist:N #1 { p , T , F , TF } +\fp_new:N \l__box_angle_fp +\fp_new:N \l__box_cos_fp +\fp_new:N \l__box_sin_fp +\dim_new:N \l__box_top_dim +\dim_new:N \l__box_bottom_dim +\dim_new:N \l__box_left_dim +\dim_new:N \l__box_right_dim +\dim_new:N \l__box_top_new_dim +\dim_new:N \l__box_bottom_new_dim +\dim_new:N \l__box_left_new_dim +\dim_new:N \l__box_right_new_dim +\box_new:N \l__box_internal_box +\cs_new_protected:Npn \box_rotate:Nn #1#2 { - \cs_if_exist:NTF #1 + \hbox_set:Nn #1 { - \cs_if_exist:cTF { l__coffin_poles_ \__int_value:w #1 _prop } - { \prg_return_true: } - { \prg_return_false: } + \fp_set:Nn \l__box_angle_fp {#2} + \fp_set:Nn \l__box_sin_fp { sind ( \l__box_angle_fp ) } + \fp_set:Nn \l__box_cos_fp { cosd ( \l__box_angle_fp ) } + \__box_rotate:N #1 } - { \prg_return_false: } } -\cs_generate_variant:Nn \coffin_if_exist_p:N { c } -\cs_generate_variant:Nn \coffin_if_exist:NT { c } -\cs_generate_variant:Nn \coffin_if_exist:NF { c } -\cs_generate_variant:Nn \coffin_if_exist:NTF { c } -\cs_new_protected:Npn \__coffin_if_exist:NT #1#2 +\cs_new_protected:Npn \__box_rotate:N #1 { - \coffin_if_exist:NTF #1 - { #2 } + \dim_set:Nn \l__box_top_dim { \box_ht:N #1 } + \dim_set:Nn \l__box_bottom_dim { -\box_dp:N #1 } + \dim_set:Nn \l__box_right_dim { \box_wd:N #1 } + \dim_zero:N \l__box_left_dim + \fp_compare:nNnTF \l__box_sin_fp > \c_zero_fp { - \__msg_kernel_error:nnx { kernel } { unknown-coffin } - { \token_to_str:N #1 } + \fp_compare:nNnTF \l__box_cos_fp > \c_zero_fp + { \__box_rotate_quadrant_one: } + { \__box_rotate_quadrant_two: } } - } -\cs_new_protected:Npn \coffin_clear:N #1 - { - \__coffin_if_exist:NT #1 { - \box_clear:N #1 - \__coffin_reset_structure:N #1 + \fp_compare:nNnTF \l__box_cos_fp < \c_zero_fp + { \__box_rotate_quadrant_three: } + { \__box_rotate_quadrant_four: } } - } -\cs_generate_variant:Nn \coffin_clear:N { c } -\cs_new_protected:Npn \coffin_new:N #1 - { - \box_new:N #1 - \__chk_suspend_log: - \prop_clear_new:c { l__coffin_corners_ \__int_value:w #1 _prop } - \prop_clear_new:c { l__coffin_poles_ \__int_value:w #1 _prop } - \prop_gset_eq:cN { l__coffin_corners_ \__int_value:w #1 _prop } - \c__coffin_corners_prop - \prop_gset_eq:cN { l__coffin_poles_ \__int_value:w #1 _prop } - \c__coffin_poles_prop - \__chk_resume_log: - } -\cs_generate_variant:Nn \coffin_new:N { c } -\cs_new_protected:Npn \hcoffin_set:Nn #1#2 - { - \__coffin_if_exist:NT #1 + \hbox_set:Nn \l__box_internal_box { \box_use:N #1 } + \hbox_set:Nn \l__box_internal_box { - \hbox_set:Nn #1 + \tex_kern:D -\l__box_left_new_dim + \hbox:n { - \color_group_begin: - \color_ensure_current: - #2 - \color_group_end: + \__driver_box_use_rotate:Nn + \l__box_internal_box + \l__box_angle_fp } - \__coffin_reset_structure:N #1 - \__coffin_update_poles:N #1 - \__coffin_update_corners:N #1 } + \box_set_ht:Nn \l__box_internal_box { \l__box_top_new_dim } + \box_set_dp:Nn \l__box_internal_box { -\l__box_bottom_new_dim } + \box_set_wd:Nn \l__box_internal_box + { \l__box_right_new_dim - \l__box_left_new_dim } + \box_use:N \l__box_internal_box } -\cs_generate_variant:Nn \hcoffin_set:Nn { c } -\cs_new_protected:Npn \vcoffin_set:Nnn #1#2#3 +\cs_new_protected:Npn \__box_rotate_x:nnN #1#2#3 { - \__coffin_if_exist:NT #1 + \dim_set:Nn #3 { - \vbox_set:Nn #1 - { - \dim_set:Nn \tex_hsize:D {#2} - \dim_set_eq:NN \linewidth \tex_hsize:D - \dim_set_eq:NN \columnwidth \tex_hsize:D - \color_group_begin: - #3 - \color_group_end: - } - \__coffin_reset_structure:N #1 - \__coffin_update_poles:N #1 - \__coffin_update_corners:N #1 - \vbox_set_top:Nn \l__coffin_internal_box { \vbox_unpack:N #1 } - \__coffin_set_pole:Nnx #1 { T } + \fp_to_dim:n { - { 0 pt } - { - \dim_eval:n - { \box_ht:N #1 - \box_ht:N \l__coffin_internal_box } - } - { 1000 pt } - { 0 pt } + \l__box_cos_fp * \dim_to_fp:n {#1} + - \l__box_sin_fp * \dim_to_fp:n {#2} } - \box_clear:N \l__coffin_internal_box } } -\cs_generate_variant:Nn \vcoffin_set:Nnn { c } -\cs_new_protected:Npn \hcoffin_set:Nw #1 +\cs_new_protected:Npn \__box_rotate_y:nnN #1#2#3 { - \__coffin_if_exist:NT #1 + \dim_set:Nn #3 { - \hbox_set:Nw #1 \color_group_begin: \color_ensure_current: - \cs_set_protected:Npn \hcoffin_set_end: - { - \color_group_end: - \hbox_set_end: - \__coffin_reset_structure:N #1 - \__coffin_update_poles:N #1 - \__coffin_update_corners:N #1 - } + \fp_to_dim:n + { + \l__box_sin_fp * \dim_to_fp:n {#1} + + \l__box_cos_fp * \dim_to_fp:n {#2} + } } } -\cs_new_protected:Npn \hcoffin_set_end: { } -\cs_generate_variant:Nn \hcoffin_set:Nw { c } -\cs_new_protected:Npn \vcoffin_set:Nnw #1#2 +\cs_new_protected:Npn \__box_rotate_quadrant_one: { - \__coffin_if_exist:NT #1 - { - \vbox_set:Nw #1 - \dim_set:Nn \tex_hsize:D {#2} - \dim_set_eq:NN \linewidth \tex_hsize:D - \dim_set_eq:NN \columnwidth \tex_hsize:D - \color_group_begin: - \cs_set_protected:Npn \vcoffin_set_end: - { - \color_group_end: - \vbox_set_end: - \__coffin_reset_structure:N #1 - \__coffin_update_poles:N #1 - \__coffin_update_corners:N #1 - \vbox_set_top:Nn \l__coffin_internal_box { \vbox_unpack:N #1 } - \__coffin_set_pole:Nnx #1 { T } - { - { 0 pt } - { - \dim_eval:n - { \box_ht:N #1 - \box_ht:N \l__coffin_internal_box } - } - { 1000 pt } - { 0 pt } - } - \box_clear:N \l__coffin_internal_box - } - } + \__box_rotate_y:nnN \l__box_right_dim \l__box_top_dim + \l__box_top_new_dim + \__box_rotate_y:nnN \l__box_left_dim \l__box_bottom_dim + \l__box_bottom_new_dim + \__box_rotate_x:nnN \l__box_left_dim \l__box_top_dim + \l__box_left_new_dim + \__box_rotate_x:nnN \l__box_right_dim \l__box_bottom_dim + \l__box_right_new_dim } -\cs_new_protected:Npn \vcoffin_set_end: { } -\cs_generate_variant:Nn \vcoffin_set:Nnw { c } -\cs_new_protected:Npn \coffin_set_eq:NN #1#2 +\cs_new_protected:Npn \__box_rotate_quadrant_two: { - \__coffin_if_exist:NT #1 - { - \box_set_eq:NN #1 #2 - \__coffin_set_eq_structure:NN #1 #2 - } + \__box_rotate_y:nnN \l__box_right_dim \l__box_bottom_dim + \l__box_top_new_dim + \__box_rotate_y:nnN \l__box_left_dim \l__box_top_dim + \l__box_bottom_new_dim + \__box_rotate_x:nnN \l__box_right_dim \l__box_top_dim + \l__box_left_new_dim + \__box_rotate_x:nnN \l__box_left_dim \l__box_bottom_dim + \l__box_right_new_dim } -\cs_generate_variant:Nn \coffin_set_eq:NN { c , Nc , cc } -\coffin_new:N \c_empty_coffin -\hbox_set:Nn \c_empty_coffin { } -\coffin_new:N \l__coffin_aligned_coffin -\coffin_new:N \l__coffin_aligned_internal_coffin -\coffin_new:N \l_tmpa_coffin -\coffin_new:N \l_tmpb_coffin -\cs_new_eq:NN \coffin_dp:N \box_dp:N -\cs_new_eq:NN \coffin_dp:c \box_dp:c -\cs_new_eq:NN \coffin_ht:N \box_ht:N -\cs_new_eq:NN \coffin_ht:c \box_ht:c -\cs_new_eq:NN \coffin_wd:N \box_wd:N -\cs_new_eq:NN \coffin_wd:c \box_wd:c -\cs_new_protected:Npn \__coffin_get_pole:NnN #1#2#3 +\cs_new_protected:Npn \__box_rotate_quadrant_three: { - \prop_get:cnNF - { l__coffin_poles_ \__int_value:w #1 _prop } {#2} #3 + \__box_rotate_y:nnN \l__box_left_dim \l__box_bottom_dim + \l__box_top_new_dim + \__box_rotate_y:nnN \l__box_right_dim \l__box_top_dim + \l__box_bottom_new_dim + \__box_rotate_x:nnN \l__box_right_dim \l__box_bottom_dim + \l__box_left_new_dim + \__box_rotate_x:nnN \l__box_left_dim \l__box_top_dim + \l__box_right_new_dim + } +\cs_new_protected:Npn \__box_rotate_quadrant_four: + { + \__box_rotate_y:nnN \l__box_left_dim \l__box_top_dim + \l__box_top_new_dim + \__box_rotate_y:nnN \l__box_right_dim \l__box_bottom_dim + \l__box_bottom_new_dim + \__box_rotate_x:nnN \l__box_left_dim \l__box_bottom_dim + \l__box_left_new_dim + \__box_rotate_x:nnN \l__box_right_dim \l__box_top_dim + \l__box_right_new_dim + } +\fp_new:N \l__box_scale_x_fp +\fp_new:N \l__box_scale_y_fp +\cs_new_protected:Npn \box_resize_to_wd_and_ht_plus_dp:Nnn #1#2#3 + { + \hbox_set:Nn #1 + { + \__box_resize_set_corners:N #1 + \fp_set:Nn \l__box_scale_x_fp + { \dim_to_fp:n {#2} / \dim_to_fp:n { \l__box_right_dim } } + \fp_set:Nn \l__box_scale_y_fp + { + \dim_to_fp:n {#3} + / \dim_to_fp:n { \l__box_top_dim - \l__box_bottom_dim } + } + \__box_resize:N #1 + } + } +\cs_generate_variant:Nn \box_resize_to_wd_and_ht_plus_dp:Nnn { c } +\cs_new_protected:Npn \__box_resize_set_corners:N #1 + { + \dim_set:Nn \l__box_top_dim { \box_ht:N #1 } + \dim_set:Nn \l__box_bottom_dim { -\box_dp:N #1 } + \dim_set:Nn \l__box_right_dim { \box_wd:N #1 } + \dim_zero:N \l__box_left_dim + } +\cs_new_protected:Npn \__box_resize:N #1 + { + \__box_resize:NNN \l__box_right_new_dim + \l__box_scale_x_fp \l__box_right_dim + \__box_resize:NNN \l__box_bottom_new_dim + \l__box_scale_y_fp \l__box_bottom_dim + \__box_resize:NNN \l__box_top_new_dim + \l__box_scale_y_fp \l__box_top_dim + \__box_resize_common:N #1 + } +\cs_new_protected:Npn \__box_resize:NNN #1#2#3 + { + \dim_set:Nn #1 + { \fp_to_dim:n { \fp_abs:n { #2 } * \dim_to_fp:n { #3 } } } + } +\cs_new_protected:Npn \box_resize_to_ht:Nn #1#2 + { + \hbox_set:Nn #1 + { + \__box_resize_set_corners:N #1 + \fp_set:Nn \l__box_scale_y_fp + { + \dim_to_fp:n {#2} + / \dim_to_fp:n { \l__box_top_dim } + } + \fp_set_eq:NN \l__box_scale_x_fp \l__box_scale_y_fp + \__box_resize:N #1 + } + } +\cs_generate_variant:Nn \box_resize_to_ht:Nn { c } +\cs_new_protected:Npn \box_resize_to_ht_plus_dp:Nn #1#2 + { + \hbox_set:Nn #1 + { + \__box_resize_set_corners:N #1 + \fp_set:Nn \l__box_scale_y_fp + { + \dim_to_fp:n {#2} + / \dim_to_fp:n { \l__box_top_dim - \l__box_bottom_dim } + } + \fp_set_eq:NN \l__box_scale_x_fp \l__box_scale_y_fp + \__box_resize:N #1 + } + } +\cs_generate_variant:Nn \box_resize_to_ht_plus_dp:Nn { c } +\cs_new_protected:Npn \box_resize_to_wd:Nn #1#2 + { + \hbox_set:Nn #1 + { + \__box_resize_set_corners:N #1 + \fp_set:Nn \l__box_scale_x_fp + { \dim_to_fp:n {#2} / \dim_to_fp:n { \l__box_right_dim } } + \fp_set_eq:NN \l__box_scale_y_fp \l__box_scale_x_fp + \__box_resize:N #1 + } + } +\cs_generate_variant:Nn \box_resize_to_wd:Nn { c } +\cs_new_protected:Npn \box_resize_to_wd_and_ht:Nnn #1#2#3 + { + \hbox_set:Nn #1 + { + \__box_resize_set_corners:N #1 + \fp_set:Nn \l__box_scale_x_fp + { \dim_to_fp:n {#2} / \dim_to_fp:n { \l__box_right_dim } } + \fp_set:Nn \l__box_scale_y_fp + { + \dim_to_fp:n {#3} + / \dim_to_fp:n { \l__box_top_dim } + } + \__box_resize:N #1 + } + } +\cs_generate_variant:Nn \box_resize_to_wd_and_ht:Nnn { c } +\cs_new_protected:Npn \box_scale:Nnn #1#2#3 + { + \hbox_set:Nn #1 + { + \fp_set:Nn \l__box_scale_x_fp {#2} + \fp_set:Nn \l__box_scale_y_fp {#3} + \__box_scale_aux:N #1 + } + } +\cs_generate_variant:Nn \box_scale:Nnn { c } +\cs_new_protected:Npn \__box_scale_aux:N #1 + { + \dim_set:Nn \l__box_top_dim { \box_ht:N #1 } + \dim_set:Nn \l__box_bottom_dim { -\box_dp:N #1 } + \dim_set:Nn \l__box_right_dim { \box_wd:N #1 } + \dim_zero:N \l__box_left_dim + \dim_set:Nn \l__box_top_new_dim + { \fp_abs:n { \l__box_scale_y_fp } \l__box_top_dim } + \dim_set:Nn \l__box_bottom_new_dim + { \fp_abs:n { \l__box_scale_y_fp } \l__box_bottom_dim } + \dim_set:Nn \l__box_right_new_dim + { \fp_abs:n { \l__box_scale_x_fp } \l__box_right_dim } + \__box_resize_common:N #1 + } +\cs_new_protected:Npn \box_autosize_to_wd_and_ht:Nnn #1#2#3 + { \__box_autosize:Nnnn #1 {#2} {#3} { \box_ht:N #1 } } +\cs_generate_variant:Nn \box_autosize_to_wd_and_ht:Nnn { c } +\cs_new_protected:Npn \box_autosize_to_wd_and_ht_plus_dp:Nnn #1#2#3 + { \__box_autosize:Nnnn #1 {#2} {#3} { \box_ht:N #1 + \box_dp:N #1 } } +\cs_generate_variant:Nn \box_autosize_to_wd_and_ht_plus_dp:Nnn { c } +\cs_new_protected:Npn \__box_autosize:Nnnn #1#2#3#4 + { + \hbox_set:Nn #1 + { + \fp_set:Nn \l__box_scale_x_fp { ( #2 ) / \box_wd:N #1 } + \fp_set:Nn \l__box_scale_y_fp { ( #3 ) / ( #4 ) } + \fp_compare:nNnTF \l__box_scale_x_fp > \l__box_scale_y_fp + { \fp_set_eq:NN \l__box_scale_x_fp \l__box_scale_y_fp } + { \fp_set_eq:NN \l__box_scale_y_fp \l__box_scale_x_fp } + \__box_scale_aux:N #1 + } + } +\cs_new_protected:Npn \__box_resize_common:N #1 + { + \hbox_set:Nn \l__box_internal_box + { + \__driver_box_use_scale:Nnn + #1 + \l__box_scale_x_fp + \l__box_scale_y_fp + } + \fp_compare:nNnTF \l__box_scale_y_fp > \c_zero_fp + { + \box_set_ht:Nn \l__box_internal_box { \l__box_top_new_dim } + \box_set_dp:Nn \l__box_internal_box { -\l__box_bottom_new_dim } + } + { + \box_set_dp:Nn \l__box_internal_box { \l__box_top_new_dim } + \box_set_ht:Nn \l__box_internal_box { -\l__box_bottom_new_dim } + } + \fp_compare:nNnTF \l__box_scale_x_fp < \c_zero_fp + { + \hbox_to_wd:nn { \l__box_right_new_dim } + { + \tex_kern:D \l__box_right_new_dim + \box_use:N \l__box_internal_box + \tex_hss:D + } + } + { + \box_set_wd:Nn \l__box_internal_box { \l__box_right_new_dim } + \hbox:n + { + \tex_kern:D \c_zero_dim + \box_use:N \l__box_internal_box + \tex_hss:D + } + } + } +\cs_new_eq:NN \box_resize:Nnn \box_resize_to_wd_and_ht_plus_dp:Nnn +\cs_new_eq:NN \box_resize:cnn \box_resize_to_wd_and_ht_plus_dp:cnn +%% File: l3coffins.dtx Copyright(C) 2010-2017 The LaTeX3 Project +\box_new:N \l__coffin_internal_box +\dim_new:N \l__coffin_internal_dim +\tl_new:N \l__coffin_internal_tl +\prop_new:N \c__coffin_corners_prop +\prop_put:Nnn \c__coffin_corners_prop { tl } { { 0pt } { 0pt } } +\prop_put:Nnn \c__coffin_corners_prop { tr } { { 0pt } { 0pt } } +\prop_put:Nnn \c__coffin_corners_prop { bl } { { 0pt } { 0pt } } +\prop_put:Nnn \c__coffin_corners_prop { br } { { 0pt } { 0pt } } +\prop_new:N \c__coffin_poles_prop +\tl_set:Nn \l__coffin_internal_tl { { 0pt } { 0pt } { 0pt } { 1000pt } } +\prop_put:Nno \c__coffin_poles_prop { l } { \l__coffin_internal_tl } +\prop_put:Nno \c__coffin_poles_prop { hc } { \l__coffin_internal_tl } +\prop_put:Nno \c__coffin_poles_prop { r } { \l__coffin_internal_tl } +\tl_set:Nn \l__coffin_internal_tl { { 0pt } { 0pt } { 1000pt } { 0pt } } +\prop_put:Nno \c__coffin_poles_prop { b } { \l__coffin_internal_tl } +\prop_put:Nno \c__coffin_poles_prop { vc } { \l__coffin_internal_tl } +\prop_put:Nno \c__coffin_poles_prop { t } { \l__coffin_internal_tl } +\prop_put:Nno \c__coffin_poles_prop { B } { \l__coffin_internal_tl } +\prop_put:Nno \c__coffin_poles_prop { H } { \l__coffin_internal_tl } +\prop_put:Nno \c__coffin_poles_prop { T } { \l__coffin_internal_tl } +\fp_new:N \l__coffin_slope_x_fp +\fp_new:N \l__coffin_slope_y_fp +\bool_new:N \l__coffin_error_bool +\dim_new:N \l__coffin_offset_x_dim +\dim_new:N \l__coffin_offset_y_dim +\tl_new:N \l__coffin_pole_a_tl +\tl_new:N \l__coffin_pole_b_tl +\dim_new:N \l__coffin_x_dim +\dim_new:N \l__coffin_y_dim +\dim_new:N \l__coffin_x_prime_dim +\dim_new:N \l__coffin_y_prime_dim +\prg_new_conditional:Npnn \coffin_if_exist:N #1 { p , T , F , TF } + { + \cs_if_exist:NTF #1 + { + \cs_if_exist:cTF { l__coffin_poles_ \__int_value:w #1 _prop } + { \prg_return_true: } + { \prg_return_false: } + } + { \prg_return_false: } + } +\cs_generate_variant:Nn \coffin_if_exist_p:N { c } +\cs_generate_variant:Nn \coffin_if_exist:NT { c } +\cs_generate_variant:Nn \coffin_if_exist:NF { c } +\cs_generate_variant:Nn \coffin_if_exist:NTF { c } +\cs_new_protected:Npn \__coffin_if_exist:NT #1#2 + { + \coffin_if_exist:NTF #1 + { #2 } + { + \__msg_kernel_error:nnx { kernel } { unknown-coffin } + { \token_to_str:N #1 } + } + } +\cs_new_protected:Npn \coffin_clear:N #1 + { + \__coffin_if_exist:NT #1 + { + \box_clear:N #1 + \__coffin_reset_structure:N #1 + } + } +\cs_generate_variant:Nn \coffin_clear:N { c } +\cs_new_protected:Npn \coffin_new:N #1 + { + \box_new:N #1 + \__chk_suspend_log: + \prop_clear_new:c { l__coffin_corners_ \__int_value:w #1 _prop } + \prop_clear_new:c { l__coffin_poles_ \__int_value:w #1 _prop } + \prop_gset_eq:cN { l__coffin_corners_ \__int_value:w #1 _prop } + \c__coffin_corners_prop + \prop_gset_eq:cN { l__coffin_poles_ \__int_value:w #1 _prop } + \c__coffin_poles_prop + \__chk_resume_log: + } +\cs_generate_variant:Nn \coffin_new:N { c } +\cs_new_protected:Npn \hcoffin_set:Nn #1#2 + { + \__coffin_if_exist:NT #1 + { + \hbox_set:Nn #1 + { + \color_ensure_current: + #2 + } + \__coffin_reset_structure:N #1 + \__coffin_update_poles:N #1 + \__coffin_update_corners:N #1 + } + } +\cs_generate_variant:Nn \hcoffin_set:Nn { c } +\cs_new_protected:Npn \vcoffin_set:Nnn #1#2#3 + { + \__coffin_if_exist:NT #1 + { + \vbox_set:Nn #1 + { + \dim_set:Nn \tex_hsize:D {#2} + \dim_set_eq:NN \linewidth \tex_hsize:D + \dim_set_eq:NN \columnwidth \tex_hsize:D + #3 + } + \__coffin_reset_structure:N #1 + \__coffin_update_poles:N #1 + \__coffin_update_corners:N #1 + \vbox_set_top:Nn \l__coffin_internal_box { \vbox_unpack:N #1 } + \__coffin_set_pole:Nnx #1 { T } + { + { 0pt } + { + \dim_eval:n + { \box_ht:N #1 - \box_ht:N \l__coffin_internal_box } + } + { 1000pt } + { 0pt } + } + \box_clear:N \l__coffin_internal_box + } + } +\cs_generate_variant:Nn \vcoffin_set:Nnn { c } +\cs_new_protected:Npn \hcoffin_set:Nw #1 + { + \__coffin_if_exist:NT #1 + { + \hbox_set:Nw #1 \color_ensure_current: + \cs_set_protected:Npn \hcoffin_set_end: + { + \hbox_set_end: + \__coffin_reset_structure:N #1 + \__coffin_update_poles:N #1 + \__coffin_update_corners:N #1 + } + } + } +\cs_new_protected:Npn \hcoffin_set_end: { } +\cs_generate_variant:Nn \hcoffin_set:Nw { c } +\cs_new_protected:Npn \vcoffin_set:Nnw #1#2 + { + \__coffin_if_exist:NT #1 + { + \vbox_set:Nw #1 + \dim_set:Nn \tex_hsize:D {#2} + \dim_set_eq:NN \linewidth \tex_hsize:D + \dim_set_eq:NN \columnwidth \tex_hsize:D + \cs_set_protected:Npn \vcoffin_set_end: + { + \vbox_set_end: + \__coffin_reset_structure:N #1 + \__coffin_update_poles:N #1 + \__coffin_update_corners:N #1 + \vbox_set_top:Nn \l__coffin_internal_box { \vbox_unpack:N #1 } + \__coffin_set_pole:Nnx #1 { T } + { + { 0pt } + { + \dim_eval:n + { \box_ht:N #1 - \box_ht:N \l__coffin_internal_box } + } + { 1000pt } + { 0pt } + } + \box_clear:N \l__coffin_internal_box + } + } + } +\cs_new_protected:Npn \vcoffin_set_end: { } +\cs_generate_variant:Nn \vcoffin_set:Nnw { c } +\cs_new_protected:Npn \coffin_set_eq:NN #1#2 + { + \__coffin_if_exist:NT #1 + { + \box_set_eq:NN #1 #2 + \__coffin_set_eq_structure:NN #1 #2 + } + } +\cs_generate_variant:Nn \coffin_set_eq:NN { c , Nc , cc } +\coffin_new:N \c_empty_coffin +\hbox_set:Nn \c_empty_coffin { } +\coffin_new:N \l__coffin_aligned_coffin +\coffin_new:N \l__coffin_aligned_internal_coffin +\coffin_new:N \l_tmpa_coffin +\coffin_new:N \l_tmpb_coffin +\cs_new_eq:NN \coffin_dp:N \box_dp:N +\cs_new_eq:NN \coffin_dp:c \box_dp:c +\cs_new_eq:NN \coffin_ht:N \box_ht:N +\cs_new_eq:NN \coffin_ht:c \box_ht:c +\cs_new_eq:NN \coffin_wd:N \box_wd:N +\cs_new_eq:NN \coffin_wd:c \box_wd:c +\cs_new_protected:Npn \__coffin_get_pole:NnN #1#2#3 + { + \prop_get:cnNF + { l__coffin_poles_ \__int_value:w #1 _prop } {#2} #3 { \__msg_kernel_error:nnxx { kernel } { unknown-coffin-pole } {#2} { \token_to_str:N #1 } - \tl_set:Nn #3 { { 0 pt } { 0 pt } { 0 pt } { 0 pt } } + \tl_set:Nn #3 { { 0pt } { 0pt } { 0pt } { 0pt } } } } \cs_new_protected:Npn \__coffin_reset_structure:N #1 @@ -16628,8 +16981,8 @@ { \__coffin_set_pole:Nnx #1 {#2} { - { 0 pt } { \dim_eval:n {#3} } - { 1000 pt } { 0 pt } + { 0pt } { \dim_eval:n {#3} } + { 1000pt } { 0pt } } } } @@ -16639,8 +16992,8 @@ { \__coffin_set_pole:Nnx #1 {#2} { - { \dim_eval:n {#3} } { 0 pt } - { 0 pt } { 1000 pt } + { \dim_eval:n {#3} } { 0pt } + { 0pt } { 1000pt } } } } @@ -16652,11 +17005,11 @@ \cs_new_protected:Npn \__coffin_update_corners:N #1 { \prop_put:cnx { l__coffin_corners_ \__int_value:w #1 _prop } { tl } - { { 0 pt } { \dim_eval:n { \box_ht:N #1 } } } + { { 0pt } { \dim_eval:n { \box_ht:N #1 } } } \prop_put:cnx { l__coffin_corners_ \__int_value:w #1 _prop } { tr } { { \dim_eval:n { \box_wd:N #1 } } { \dim_eval:n { \box_ht:N #1 } } } \prop_put:cnx { l__coffin_corners_ \__int_value:w #1 _prop } { bl } - { { 0 pt } { \dim_eval:n { - \box_dp:N #1 } } } + { { 0pt } { \dim_eval:n { -\box_dp:N #1 } } } \prop_put:cnx { l__coffin_corners_ \__int_value:w #1 _prop } { br } { { \dim_eval:n { \box_wd:N #1 } } { \dim_eval:n { -\box_dp:N #1 } } } } @@ -16665,33 +17018,33 @@ \prop_put:cnx { l__coffin_poles_ \__int_value:w #1 _prop } { hc } { { \dim_eval:n { 0.5 \box_wd:N #1 } } - { 0 pt } { 0 pt } { 1000 pt } + { 0pt } { 0pt } { 1000pt } } \prop_put:cnx { l__coffin_poles_ \__int_value:w #1 _prop } { r } { { \dim_eval:n { \box_wd:N #1 } } - { 0 pt } { 0 pt } { 1000 pt } + { 0pt } { 0pt } { 1000pt } } \prop_put:cnx { l__coffin_poles_ \__int_value:w #1 _prop } { vc } { - { 0 pt } + { 0pt } { \dim_eval:n { ( \box_ht:N #1 - \box_dp:N #1 ) / 2 } } - { 1000 pt } - { 0 pt } + { 1000pt } + { 0pt } } \prop_put:cnx { l__coffin_poles_ \__int_value:w #1 _prop } { t } { - { 0 pt } + { 0pt } { \dim_eval:n { \box_ht:N #1 } } - { 1000 pt } - { 0 pt } + { 1000pt } + { 0pt } } \prop_put:cnx { l__coffin_poles_ \__int_value:w #1 _prop } { b } { - { 0 pt } - { \dim_eval:n { - \box_dp:N #1 } } - { 1000 pt } - { 0 pt } + { 0pt } + { \dim_eval:n { -\box_dp:N #1 } } + { 1000pt } + { 0pt } } } \cs_new_protected:Npn \__coffin_calculate_intersection:Nnn #1#2#3 @@ -16816,21 +17169,21 @@ { \tex_kern:D -\l__coffin_internal_dim } } \__coffin_reset_structure:N \l__coffin_aligned_coffin - \prop_clear:c - { l__coffin_corners_ \__int_value:w \l__coffin_aligned_coffin _ prop } - \__coffin_update_poles:N \l__coffin_aligned_coffin + \prop_clear:c + { l__coffin_corners_ \__int_value:w \l__coffin_aligned_coffin _ prop } + \__coffin_update_poles:N \l__coffin_aligned_coffin \dim_compare:nNnTF \l__coffin_offset_x_dim < \c_zero_dim { - \__coffin_offset_poles:Nnn #1 { -\l__coffin_offset_x_dim } { 0 pt } - \__coffin_offset_poles:Nnn #4 { 0 pt } { \l__coffin_offset_y_dim } - \__coffin_offset_corners:Nnn #1 { -\l__coffin_offset_x_dim } { 0 pt } - \__coffin_offset_corners:Nnn #4 { 0 pt } { \l__coffin_offset_y_dim } + \__coffin_offset_poles:Nnn #1 { -\l__coffin_offset_x_dim } { 0pt } + \__coffin_offset_poles:Nnn #4 { 0pt } { \l__coffin_offset_y_dim } + \__coffin_offset_corners:Nnn #1 { -\l__coffin_offset_x_dim } { 0pt } + \__coffin_offset_corners:Nnn #4 { 0pt } { \l__coffin_offset_y_dim } } { - \__coffin_offset_poles:Nnn #1 { 0 pt } { 0 pt } + \__coffin_offset_poles:Nnn #1 { 0pt } { 0pt } \__coffin_offset_poles:Nnn #4 { \l__coffin_offset_x_dim } { \l__coffin_offset_y_dim } - \__coffin_offset_corners:Nnn #1 { 0 pt } { 0 pt } + \__coffin_offset_corners:Nnn #1 { 0pt } { 0pt } \__coffin_offset_corners:Nnn #4 { \l__coffin_offset_x_dim } { \l__coffin_offset_y_dim } } @@ -16850,7 +17203,7 @@ { l__coffin_corners_ \__int_value:w \l__coffin_aligned_coffin _prop } { l__coffin_corners_ \__int_value:w #1 _prop } \__coffin_update_poles:N \l__coffin_aligned_coffin - \__coffin_offset_poles:Nnn #1 { 0 pt } { 0 pt } + \__coffin_offset_poles:Nnn #1 { 0pt } { 0pt } \__coffin_offset_poles:Nnn #4 { \l__coffin_offset_x_dim } { \l__coffin_offset_y_dim } \__coffin_update_vertical_poles:NNN #1 #4 \l__coffin_aligned_coffin @@ -16935,11 +17288,11 @@ \dim_compare:nNnTF {#2} < {#6} { \__coffin_set_pole:Nnx #9 { T } - { { 0 pt } {#6} { 1000 pt } { 0 pt } } + { { 0pt } {#6} { 1000pt } { 0pt } } } { \__coffin_set_pole:Nnx #9 { T } - { { 0 pt } {#2} { 1000 pt } { 0 pt } } + { { 0pt } {#2} { 1000pt } { 0pt } } } } \cs_new_protected:Npn \__coffin_update_B:nnnnnnnnN #1#2#3#4#5#6#7#8#9 @@ -16947,11 +17300,11 @@ \dim_compare:nNnTF {#2} < {#6} { \__coffin_set_pole:Nnx #9 { B } - { { 0 pt } {#2} { 1000 pt } { 0 pt } } + { { 0pt } {#2} { 1000pt } { 0pt } } } { \__coffin_set_pole:Nnx #9 { B } - { { 0 pt } {#6} { 1000 pt } { 0 pt } } + { { 0pt } {#6} { 1000pt } { 0pt } } } } \cs_new_protected:Npn \coffin_typeset:Nnnnn #1#2#3#4#5 @@ -17003,7 +17356,7 @@ \prop_put:Nnn \l__coffin_display_handles_prop { Br } { { b } { l } { 1 } { -1 } } \dim_new:N \l__coffin_display_offset_dim -\dim_set:Nn \l__coffin_display_offset_dim { 2 pt } +\dim_set:Nn \l__coffin_display_offset_dim { 2pt } \dim_new:N \l__coffin_display_x_dim \dim_new:N \l__coffin_display_y_dim \prop_new:N \l__coffin_display_poles_prop @@ -17014,10 +17367,10 @@ \hcoffin_set:Nn \l__coffin_display_pole_coffin { \color {#4} - \rule { 1 pt } { 1 pt } + \rule { 1pt } { 1pt } } \coffin_attach_mark:NnnNnnnn #1 {#2} {#3} - \l__coffin_display_pole_coffin { hc } { vc } { 0 pt } { 0 pt } + \l__coffin_display_pole_coffin { hc } { vc } { 0pt } { 0pt } \hcoffin_set:Nn \l__coffin_display_coord_coffin { \color {#4} @@ -17034,7 +17387,7 @@ { \coffin_attach_mark:NnnNnnnn #1 {#2} {#3} \l__coffin_display_coord_coffin { l } { vc } - { 1 pt } { 0 pt } + { 1pt } { 0pt } } { \exp_last_unbraced:No \__coffin_mark_handle_aux:nnnnNnn @@ -17059,7 +17412,7 @@ \hcoffin_set:Nn \l__coffin_display_pole_coffin { \color {#2} - \rule { 1 pt } { 1 pt } + \rule { 1pt } { 1pt } } \prop_set_eq:Nc \l__coffin_display_poles_prop { l__coffin_poles_ \__int_value:w #1 _prop } @@ -17090,7 +17443,7 @@ \dim_set:Nn \l__coffin_display_y_dim { \l__coffin_y_dim } \__coffin_display_attach:Nnnnn \l__coffin_display_pole_coffin { hc } { vc } - { 0 pt } { 0 pt } + { 0pt } { 0pt } \hcoffin_set:Nn \l__coffin_display_coord_coffin { \color {#6} @@ -17107,7 +17460,7 @@ { \__coffin_display_attach:Nnnnn \l__coffin_display_coord_coffin { l } { vc } - { 1 pt } { 0 pt } + { 1pt } { 0pt } } { \exp_last_unbraced:No @@ -17202,28 +17555,14 @@ Poles~of~coffin~#1 : } %% File: l3color.dtx Copyright(C) 2011,2012,2014,2016,2017 The LaTeX3 Project -\cs_new_eq:NN \color_group_begin: \group_begin: -\cs_new_protected:Npn \color_group_end: - { - \tex_par:D - \group_end: - } -\cs_new_protected:Npn \color_ensure_current: { } -\AtBeginDocument - { - \cs_if_exist:NTF \__driver_color_ensure_current: - { - \cs_set_protected:Npn \color_ensure_current: - { \__driver_color_ensure_current: } - } - { - \cs_if_exist:NT \set@color - { - \cs_set_protected:Npn \color_ensure_current: - { \set@color } - } - } +\cs_new_eq:NN \color_group_begin: \group_begin: +\cs_new_protected:Npn \color_group_end: + { + \par + \group_end: } +\cs_new_protected:Npn \color_ensure_current: + { \__driver_color_ensure_current: } %% File: l3sys.dtx Copyright (C) 2015-2017 The LaTeX3 Project \str_const:Nx \c_sys_jobname_str { \tex_jobname:D } \int_const:Nn \c_sys_minute_int @@ -17258,11 +17597,9 @@ } \cs_if_exist:NT \ptex_kanjiskip:D { - \bool_if:nTF - { - \cs_if_exist_p:N \uptex_disablecjktoken:D && - \int_compare_p:nNn { \ptex_jis:D "2121 } = { "3000 } - } + \bool_lazy_and:nnTF + { \cs_if_exist_p:N \uptex_disablecjktoken:D } + { \int_compare_p:nNn { \ptex_jis:D "2121 } = { "3000 } } { \cs_gset_eq:NN \sys_if_engine_uptex:T \use:n \cs_gset_eq:NN \sys_if_engine_uptex:F \use_none:n @@ -17359,6 +17696,8 @@ \__deprecation_error:Nnn \tl_to_lowercase:n { } { 2017-12-31 } \__deprecation_error:Nnn \tl_to_uppercase:n { } { 2017-12-31 } \__deprecation_error:Nnn \ior_get_str:NN { \ior_str_get:NN } { 2017-12-31 } + \__deprecation_error:Nnn \box_resize:Nnn { \box_resize_to_wd_and_ht_plus_dp:Nnn } { 2018-12-31 } + \__deprecation_error:Nnn \box_resize:cnn { \box_resize_to_wd_and_ht_plus_dp:cnn } { 2018-12-31 } \__deprecation_error:Nnn \c_minus_one { - 1 } { 2018-12-31 } \__deprecation_error:Nnn \sort_ordered: { \sort_return_same: } { 2018-12-31 } \__deprecation_error:Nnn \sort_reversed: { \sort_return_swapped: } { 2018-12-31 } @@ -17366,297 +17705,6 @@ \cs_set_eq:NN \deprecation_error: \scan_stop: } %% File: l3candidates.dtx Copyright (C) 2012-2017 The LaTeX3 Project -\fp_new:N \l__box_angle_fp -\fp_new:N \l__box_cos_fp -\fp_new:N \l__box_sin_fp -\dim_new:N \l__box_top_dim -\dim_new:N \l__box_bottom_dim -\dim_new:N \l__box_left_dim -\dim_new:N \l__box_right_dim -\dim_new:N \l__box_top_new_dim -\dim_new:N \l__box_bottom_new_dim -\dim_new:N \l__box_left_new_dim -\dim_new:N \l__box_right_new_dim -\box_new:N \l__box_internal_box -\cs_new_protected:Npn \box_rotate:Nn #1#2 - { - \hbox_set:Nn #1 - { - \group_begin: - \fp_set:Nn \l__box_angle_fp {#2} - \fp_set:Nn \l__box_sin_fp { sind ( \l__box_angle_fp ) } - \fp_set:Nn \l__box_cos_fp { cosd ( \l__box_angle_fp ) } - \__box_rotate:N #1 - \group_end: - } - } -\cs_new_protected:Npn \__box_rotate:N #1 - { - \dim_set:Nn \l__box_top_dim { \box_ht:N #1 } - \dim_set:Nn \l__box_bottom_dim { -\box_dp:N #1 } - \dim_set:Nn \l__box_right_dim { \box_wd:N #1 } - \dim_zero:N \l__box_left_dim - \fp_compare:nNnTF \l__box_sin_fp > \c_zero_fp - { - \fp_compare:nNnTF \l__box_cos_fp > \c_zero_fp - { \__box_rotate_quadrant_one: } - { \__box_rotate_quadrant_two: } - } - { - \fp_compare:nNnTF \l__box_cos_fp < \c_zero_fp - { \__box_rotate_quadrant_three: } - { \__box_rotate_quadrant_four: } - } - \hbox_set:Nn \l__box_internal_box { \box_use:N #1 } - \hbox_set:Nn \l__box_internal_box - { - \tex_kern:D -\l__box_left_new_dim - \hbox:n - { - \__driver_box_use_rotate:Nn - \l__box_internal_box - \l__box_angle_fp - } - } - \box_set_ht:Nn \l__box_internal_box { \l__box_top_new_dim } - \box_set_dp:Nn \l__box_internal_box { -\l__box_bottom_new_dim } - \box_set_wd:Nn \l__box_internal_box - { \l__box_right_new_dim - \l__box_left_new_dim } - \box_use:N \l__box_internal_box - } -\cs_new_protected:Npn \__box_rotate_x:nnN #1#2#3 - { - \dim_set:Nn #3 - { - \fp_to_dim:n - { - \l__box_cos_fp * \dim_to_fp:n {#1} - - \l__box_sin_fp * \dim_to_fp:n {#2} - } - } - } -\cs_new_protected:Npn \__box_rotate_y:nnN #1#2#3 - { - \dim_set:Nn #3 - { - \fp_to_dim:n - { - \l__box_sin_fp * \dim_to_fp:n {#1} - + \l__box_cos_fp * \dim_to_fp:n {#2} - } - } - } -\cs_new_protected:Npn \__box_rotate_quadrant_one: - { - \__box_rotate_y:nnN \l__box_right_dim \l__box_top_dim - \l__box_top_new_dim - \__box_rotate_y:nnN \l__box_left_dim \l__box_bottom_dim - \l__box_bottom_new_dim - \__box_rotate_x:nnN \l__box_left_dim \l__box_top_dim - \l__box_left_new_dim - \__box_rotate_x:nnN \l__box_right_dim \l__box_bottom_dim - \l__box_right_new_dim - } -\cs_new_protected:Npn \__box_rotate_quadrant_two: - { - \__box_rotate_y:nnN \l__box_right_dim \l__box_bottom_dim - \l__box_top_new_dim - \__box_rotate_y:nnN \l__box_left_dim \l__box_top_dim - \l__box_bottom_new_dim - \__box_rotate_x:nnN \l__box_right_dim \l__box_top_dim - \l__box_left_new_dim - \__box_rotate_x:nnN \l__box_left_dim \l__box_bottom_dim - \l__box_right_new_dim - } -\cs_new_protected:Npn \__box_rotate_quadrant_three: - { - \__box_rotate_y:nnN \l__box_left_dim \l__box_bottom_dim - \l__box_top_new_dim - \__box_rotate_y:nnN \l__box_right_dim \l__box_top_dim - \l__box_bottom_new_dim - \__box_rotate_x:nnN \l__box_right_dim \l__box_bottom_dim - \l__box_left_new_dim - \__box_rotate_x:nnN \l__box_left_dim \l__box_top_dim - \l__box_right_new_dim - } -\cs_new_protected:Npn \__box_rotate_quadrant_four: - { - \__box_rotate_y:nnN \l__box_left_dim \l__box_top_dim - \l__box_top_new_dim - \__box_rotate_y:nnN \l__box_right_dim \l__box_bottom_dim - \l__box_bottom_new_dim - \__box_rotate_x:nnN \l__box_left_dim \l__box_bottom_dim - \l__box_left_new_dim - \__box_rotate_x:nnN \l__box_right_dim \l__box_top_dim - \l__box_right_new_dim - } -\fp_new:N \l__box_scale_x_fp -\fp_new:N \l__box_scale_y_fp -\cs_new_protected:Npn \box_resize:Nnn #1#2#3 - { - \hbox_set:Nn #1 - { - \group_begin: - \__box_resize_set_corners:N #1 - \fp_set:Nn \l__box_scale_x_fp - { \dim_to_fp:n {#2} / \dim_to_fp:n { \l__box_right_dim } } - \fp_set:Nn \l__box_scale_y_fp - { - \dim_to_fp:n {#3} - / \dim_to_fp:n { \l__box_top_dim - \l__box_bottom_dim } - } - \__box_resize:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_resize:Nnn { c } -\cs_new_protected:Npn \__box_resize_set_corners:N #1 - { - \dim_set:Nn \l__box_top_dim { \box_ht:N #1 } - \dim_set:Nn \l__box_bottom_dim { -\box_dp:N #1 } - \dim_set:Nn \l__box_right_dim { \box_wd:N #1 } - \dim_zero:N \l__box_left_dim - } -\cs_new_protected:Npn \__box_resize:N #1 - { - \__box_resize:NNN \l__box_right_new_dim - \l__box_scale_x_fp \l__box_right_dim - \__box_resize:NNN \l__box_bottom_new_dim - \l__box_scale_y_fp \l__box_bottom_dim - \__box_resize:NNN \l__box_top_new_dim - \l__box_scale_y_fp \l__box_top_dim - \__box_resize_common:N #1 - } -\cs_new_protected:Npn \__box_resize:NNN #1#2#3 - { - \dim_set:Nn #1 - { \fp_to_dim:n { \fp_abs:n { #2 } * \dim_to_fp:n { #3 } } } - } -\cs_new_protected:Npn \box_resize_to_ht:Nn #1#2 - { - \hbox_set:Nn #1 - { - \group_begin: - \__box_resize_set_corners:N #1 - \fp_set:Nn \l__box_scale_y_fp - { - \dim_to_fp:n {#2} - / \dim_to_fp:n { \l__box_top_dim } - } - \fp_set_eq:NN \l__box_scale_x_fp \l__box_scale_y_fp - \__box_resize:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_resize_to_ht:Nn { c } -\cs_new_protected:Npn \box_resize_to_ht_plus_dp:Nn #1#2 - { - \hbox_set:Nn #1 - { - \group_begin: - \__box_resize_set_corners:N #1 - \fp_set:Nn \l__box_scale_y_fp - { - \dim_to_fp:n {#2} - / \dim_to_fp:n { \l__box_top_dim - \l__box_bottom_dim } - } - \fp_set_eq:NN \l__box_scale_x_fp \l__box_scale_y_fp - \__box_resize:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_resize_to_ht_plus_dp:Nn { c } -\cs_new_protected:Npn \box_resize_to_wd:Nn #1#2 - { - \hbox_set:Nn #1 - { - \group_begin: - \__box_resize_set_corners:N #1 - \fp_set:Nn \l__box_scale_x_fp - { \dim_to_fp:n {#2} / \dim_to_fp:n { \l__box_right_dim } } - \fp_set_eq:NN \l__box_scale_y_fp \l__box_scale_x_fp - \__box_resize:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_resize_to_wd:Nn { c } -\cs_new_protected:Npn \box_resize_to_wd_and_ht:Nnn #1#2#3 - { - \hbox_set:Nn #1 - { - \group_begin: - \__box_resize_set_corners:N #1 - \fp_set:Nn \l__box_scale_x_fp - { \dim_to_fp:n {#2} / \dim_to_fp:n { \l__box_right_dim } } - \fp_set:Nn \l__box_scale_y_fp - { - \dim_to_fp:n {#3} - / \dim_to_fp:n { \l__box_top_dim } - } - \__box_resize:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_resize_to_wd_and_ht:Nnn { c } -\cs_new_protected:Npn \box_scale:Nnn #1#2#3 - { - \hbox_set:Nn #1 - { - \group_begin: - \fp_set:Nn \l__box_scale_x_fp {#2} - \fp_set:Nn \l__box_scale_y_fp {#3} - \dim_set:Nn \l__box_top_dim { \box_ht:N #1 } - \dim_set:Nn \l__box_bottom_dim { -\box_dp:N #1 } - \dim_set:Nn \l__box_right_dim { \box_wd:N #1 } - \dim_zero:N \l__box_left_dim - \dim_set:Nn \l__box_top_new_dim - { \fp_abs:n { \l__box_scale_y_fp } \l__box_top_dim } - \dim_set:Nn \l__box_bottom_new_dim - { \fp_abs:n { \l__box_scale_y_fp } \l__box_bottom_dim } - \dim_set:Nn \l__box_right_new_dim - { \fp_abs:n { \l__box_scale_x_fp } \l__box_right_dim } - \__box_resize_common:N #1 - \group_end: - } - } -\cs_generate_variant:Nn \box_scale:Nnn { c } -\cs_new_protected:Npn \__box_resize_common:N #1 - { - \hbox_set:Nn \l__box_internal_box - { - \__driver_box_use_scale:Nnn - #1 - \l__box_scale_x_fp - \l__box_scale_y_fp - } - \fp_compare:nNnTF \l__box_scale_y_fp > \c_zero_fp - { - \box_set_ht:Nn \l__box_internal_box { \l__box_top_new_dim } - \box_set_dp:Nn \l__box_internal_box { -\l__box_bottom_new_dim } - } - { - \box_set_dp:Nn \l__box_internal_box { \l__box_top_new_dim } - \box_set_ht:Nn \l__box_internal_box { -\l__box_bottom_new_dim } - } - \fp_compare:nNnTF \l__box_scale_x_fp < \c_zero_fp - { - \hbox_to_wd:nn { \l__box_right_new_dim } - { - \tex_kern:D \l__box_right_new_dim - \box_use:N \l__box_internal_box - \tex_hss:D - } - } - { - \box_set_wd:Nn \l__box_internal_box { \l__box_right_new_dim } - \hbox:n - { - \tex_kern:D \c_zero_dim - \box_use:N \l__box_internal_box - \tex_hss:D - } - } - } \cs_new_protected:Npn \box_clip:N #1 { \hbox_set:Nn #1 { \__driver_box_use_clip:N #1 } } \cs_generate_variant:Nn \box_clip:N { c } @@ -17925,7 +17973,7 @@ \dim_to_fp:n {#3} / \dim_to_fp:n { \coffin_ht:N #1 + \coffin_dp:N #1 } } - \box_resize:Nnn #1 {#2} {#3} + \box_resize_to_wd_and_ht_plus_dp:Nnn #1 {#2} {#3} \__coffin_resize_common:Nnn #1 {#2} {#3} } \cs_generate_variant:Nn \coffin_resize:Nnn { c } @@ -18037,7 +18085,7 @@ } \cs_new_protected:Npn \__ior_map_inline:NNNn #1#2#3#4 { - \cs_set:Npn #1 ##1 {#4} + \cs_gset_protected:Npn #1 ##1 {#4} \ior_if_eof:NF #3 { \__ior_map_inline_loop:NNN #1#2#3 } \__prg_break_point:Nn \ior_map_break: { \int_gdecr:N \g__prg_map_int } @@ -18245,6 +18293,18 @@ #2 } } +\cs_if_exist:NTF \pdftex_uniformdeviate:D + { + \prg_new_conditional:Npnn \sys_if_rand_exist: { p , T , F , TF } + { \prg_return_true: } + } + { + \prg_new_conditional:Npnn \sys_if_rand_exist: { p , T , F , TF } + { \prg_return_false: } + } +\cs_new:Npn \sys_rand_seed: { \tex_the:D \pdftex_randomseed:D } +\cs_new_protected:Npn \sys_gset_rand_seed:n #1 + { \pdftex_setrandomseed:D \__int_eval:w #1 \__int_eval_end: } \prg_new_conditional:Npnn \tl_if_single_token:n #1 { p , T , F , TF } { \tl_if_head_is_N_type:nTF {#1} @@ -18934,10 +18994,9 @@ \__tl_tmp:w \c__unicode_I_ogonek_tl { 012E } \group_end: \group_begin: - \bool_if:nT - { - \sys_if_engine_pdftex_p: || \sys_if_engine_uptex_p: - } + \bool_lazy_or:nnT + { \sys_if_engine_pdftex_p: } + { \sys_if_engine_uptex_p: } { \cs_set_protected:Npn \__tl_loop:nn #1#2 { diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex b/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex index d219cea798d..7ff0bc2bb26 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3-generic.tex @@ -19,7 +19,7 @@ %% and all files in that bundle must be distributed together. %% %% File: expl3.dtx Copyright (C) 1990-2017 The LaTeX3 Project -\def\ExplFileDate{2017/04/01}% +\def\ExplFileDate{2017/05/13}% \let\ExplLoaderFileDate\ExplFileDate \begingroup \def\tempa{LaTeX2e}% @@ -73,7 +73,6 @@ \expandafter\endinput \fi \cs_set_eq:NN \__iow_wrap_set:Nx \tl_set:Nx -\protected\def\GetIdInfoLog{} \cs_set_protected:Npn \ProvidesExplFile { \group_begin: diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3.sty b/Master/texmf-dist/tex/latex/l3kernel/expl3.sty index b72e6e3ac4b..ffdcd396e0b 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3.sty @@ -19,7 +19,7 @@ %% and all files in that bundle must be distributed together. %% %% File: expl3.dtx Copyright (C) 1990-2017 The LaTeX3 Project -\def\ExplFileDate{2017/04/01}% +\def\ExplFileDate{2017/05/13}% \let\ExplLoaderFileDate\ExplFileDate \ProvidesPackage{expl3} [% @@ -95,11 +95,9 @@ \sys_if_output_pdf:TF { pdfmode } { - \bool_if:nTF - { - \sys_if_engine_pdftex_p: || - \sys_if_engine_luatex_p: - } + \bool_lazy_or:nnTF + { \sys_if_engine_pdftex_p: } + { \sys_if_engine_luatex_p: } { dvips } { dvipdfmx } } @@ -226,7 +224,7 @@ } \cs_set_protected:Npn \box_rotate:Nn #1#2 { \hbox_set:Nn #1 { \rotatebox {#2} { \box_use:N #1 } } } - \cs_set_protected:Npn \box_resize:Nnn #1#2#3 + \cs_set_protected:Npn \box_resize_to_wd_and_ht_plus_dp:Nnn #1#2#3 { \hbox_set:Nn #1 { @@ -252,15 +250,13 @@ { \box_use:N #1 } } } - \cs_set_protected:Npn \box_scale:Nnn #1#2#3 + \cs_set_protected:Npn \__box_scale_aux:N #1 { - \hbox_set:Nn #1 - { - \exp_last_unbraced:Nx \scalebox - { { \fp_eval:n {#2} } [ \fp_eval:n {#3} ] } - { \box_use:N #1 } - } + \exp_last_unbraced:Nx \scalebox + { { \fp_use:N \l__box_scale_x_fp } [ \fp_use:N \l__box_scale_y_fp ] } + { \box_use:N #1 } } + \cs_set_protected:Npn \color_ensure_current: { \set@color } } { \group_begin: diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3basics.sty b/Master/texmf-dist/tex/latex/l3kernel/l3basics.sty index ecc4ec63d8b..01247fc3cc7 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3basics.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3basics.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3basics.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3bootstrap.sty b/Master/texmf-dist/tex/latex/l3kernel/l3bootstrap.sty index 5802b76351d..10179692ae8 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3bootstrap.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3bootstrap.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3bootstrap.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3box.sty b/Master/texmf-dist/tex/latex/l3kernel/l3box.sty index e97f3c82e8a..772f216bda4 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3box.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3box.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3box.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3candidates.sty b/Master/texmf-dist/tex/latex/l3kernel/l3candidates.sty index 3e9cc1ca2a0..b285554a278 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3candidates.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3candidates.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3candidates.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty b/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty index 448c5e6416c..398a0a2c985 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3clist.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3clist.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3coffins.sty b/Master/texmf-dist/tex/latex/l3kernel/l3coffins.sty index 8402a41fea2..ec1a9cc35b5 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3coffins.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3coffins.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3coffins.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3color.sty b/Master/texmf-dist/tex/latex/l3kernel/l3color.sty index b40efec230e..61cbb081a93 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3color.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3color.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3color.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3doc.cls b/Master/texmf-dist/tex/latex/l3kernel/l3doc.cls index 7282e860ae8..87a276fbd8b 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3doc.cls +++ b/Master/texmf-dist/tex/latex/l3kernel/l3doc.cls @@ -20,7 +20,7 @@ %% %% File: l3doc.dtx Copyright (C) 1990-2017 The LaTeX3 project \RequirePackage{expl3,xparse,calc} -\ProvidesExplClass{l3doc}{2017/04/01}{} +\ProvidesExplClass{l3doc}{2017/05/13}{} {L3 Experimental documentation class} \clist_new:N \g_docinput_clist \seq_new:N \g_doc_functions_seq @@ -892,7 +892,7 @@ \clist_clear:N \l__codedoc_function_label_clist \tl_set:Nn \l__codedoc_override_module_tl { \q_no_value } \char_set_catcode_active:N \< - \cs_set_protected:Npn < ##1 > { \meta {##1} } + \cs_set_protected_nopar:Npn < ##1 > { \meta {##1} } } \group_end: \cs_new_protected:Npn \__codedoc_function_reset: diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3dvipdfmx.def b/Master/texmf-dist/tex/latex/l3kernel/l3dvipdfmx.def index 421757e959a..a2e1fb7ee87 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3dvipdfmx.def +++ b/Master/texmf-dist/tex/latex/l3kernel/l3dvipdfmx.def @@ -25,26 +25,9 @@ \cs_new_protected:Npn \__driver_literal:n #1 { \tex_special:D { pdf:literal~ #1 } } \cs_new_protected:Npn \__driver_scope_begin: - { \__driver_literal:n { q } } + { \tex_special:D { x:gsave } } \cs_new_protected:Npn \__driver_scope_end: - { \__driver_literal:n { Q } } -\cs_new_protected:Npn \__driver_matrix:n #1 - { \__driver_literal:n { #1 \c_space_tl 0~0~cm } } -\tl_new:N \l__driver_current_color_tl -\tl_set:Nn \l__driver_current_color_tl { [ 0 ] } -\AtBeginDocument - { - \@ifpackageloaded { color } - { \tl_set:Nn \l__driver_current_color_tl { \current@color } } - { } - } -\cs_new_protected:Npn \__driver_color_ensure_current: - { - \tex_special:D { pdf:bcolor~\l__driver_current_color_tl } - \group_insert_after:N \__driver_color_reset: - } -\cs_new_protected:Npn \__driver_color_reset: - { \tex_special:D { pdf:ecolor } } + { \tex_special:D { x:grestore } } \cs_new_protected:Npn \__driver_box_use_clip:N #1 { \__driver_scope_begin: @@ -63,41 +46,43 @@ \cs_new_protected:Npn \__driver_box_use_rotate:Nn #1#2 { \__driver_scope_begin: - \box_set_wd:Nn #1 \c_zero_dim - \fp_set:Nn \l__driver_cos_fp { round ( cosd ( #2 ) , 5 ) } - \fp_compare:nNnT \l__driver_cos_fp = \c_zero_fp - { \fp_zero:N \l__driver_cos_fp } - \fp_set:Nn \l__driver_sin_fp { round ( sind ( #2 ) , 5 ) } - \__driver_matrix:n + \tex_special:D { - \fp_use:N \l__driver_cos_fp \c_space_tl - \fp_compare:nNnTF \l__driver_sin_fp = \c_zero_fp - { 0~0 } - { - \fp_use:N \l__driver_sin_fp - \c_space_tl - \fp_eval:n { -\l__driver_sin_fp } - } - \c_space_tl - \fp_use:N \l__driver_cos_fp + x:rotate~ + \fp_compare:nNnTF {#2} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( #2 , 5 ) } } } - \box_use:N #1 - \__driver_scope_end: + \box_use:N #1 + \__driver_scope_end: } -\fp_new:N \l__driver_cos_fp -\fp_new:N \l__driver_sin_fp \cs_new_protected:Npn \__driver_box_use_scale:Nnn #1#2#3 { \__driver_scope_begin: - \__driver_matrix:n + \tex_special:D { + x:scale~ \fp_eval:n { round ( #2 , 5 ) } ~ - 0~0~ \fp_eval:n { round ( #3 , 5 ) } } \hbox_overlap_right:n { \box_use:N #1 } \__driver_scope_end: } +\tl_new:N \l__driver_current_color_tl +\tl_set:Nn \l__driver_current_color_tl { [ 0 ] } +\AtBeginDocument + { + \@ifpackageloaded { color } + { \tl_set:Nn \l__driver_current_color_tl { \current@color } } + { } + } +\cs_new_protected:Npn \__driver_color_ensure_current: + { + \tex_special:D { pdf:bcolor~\l__driver_current_color_tl } + \group_insert_after:N \__driver_color_reset: + } +\cs_new_protected:Npn \__driver_color_reset: + { \tex_special:D { pdf:ecolor } } \cs_new_eq:NN \__driver_draw_literal:n \__driver_literal:n \cs_generate_variant:Nn \__driver_draw_literal:n { x } \cs_new_protected:Npn \__driver_draw_begin: diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3expan.sty b/Master/texmf-dist/tex/latex/l3kernel/l3expan.sty index 1384b917ae2..d359460c6a9 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3expan.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3expan.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3expan.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3file.sty b/Master/texmf-dist/tex/latex/l3kernel/l3file.sty index 1d304be09b0..e3885146b5b 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3file.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3file.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3file.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty b/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty index b0db3df4086..25d5f463f93 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3fp.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3int.sty b/Master/texmf-dist/tex/latex/l3kernel/l3int.sty index 39f59525ccd..2cf8d17adaf 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3int.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3int.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3int.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3keys.sty b/Master/texmf-dist/tex/latex/l3kernel/l3keys.sty index 6bf04e91edf..f70076e7624 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3keys.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3keys.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3keys.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3msg.sty b/Master/texmf-dist/tex/latex/l3kernel/l3msg.sty index 5f56f117b47..a69bed4d629 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3msg.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3msg.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3msg.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3names.sty b/Master/texmf-dist/tex/latex/l3kernel/l3names.sty index d3ed998a594..70dfa8a8f9e 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3names.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3names.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3names.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def b/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def index c4e02851cbd..aa41c1f1c1b 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def +++ b/Master/texmf-dist/tex/latex/l3kernel/l3pdfmode.def @@ -48,31 +48,6 @@ { \pdftex_pdfsetmatrix:D } {#1} } -\tl_new:N \l__driver_current_color_tl -\tl_set:Nn \l__driver_current_color_tl { 0~g~0~G } -\AtBeginDocument - { - \@ifpackageloaded { color } - { \tl_set:Nn \l__driver_current_color_tl { \current@color } } - { } - } -\int_new:N \l__driver_color_stack_int -\cs_new_protected:Npx \__driver_color_ensure_current: - { - \cs_if_exist:NTF \luatex_pdfextension:D - { \luatex_pdfextension:D colorstack } - { \pdftex_pdfcolorstack:D } - \exp_not:N \l__driver_color_stack_int push - { \exp_not:N \l__driver_current_color_tl } - \group_insert_after:N \exp_not:N \__driver_color_reset: - } -\cs_new_protected:Npx \__driver_color_reset: - { - \cs_if_exist:NTF \luatex_pdfextension:D - { \luatex_pdfextension:D colorstack } - { \pdftex_pdfcolorstack:D } - \exp_not:N \l__driver_color_stack_int pop \scan_stop: - } \cs_new_protected:Npn \__driver_box_use_clip:N #1 { \__driver_scope_begin: @@ -126,6 +101,31 @@ \hbox_overlap_right:n { \box_use:N #1 } \__driver_scope_end: } +\tl_new:N \l__driver_current_color_tl +\tl_set:Nn \l__driver_current_color_tl { 0~g~0~G } +\AtBeginDocument + { + \@ifpackageloaded { color } + { \tl_set:Nn \l__driver_current_color_tl { \current@color } } + { } + } +\int_new:N \l__driver_color_stack_int +\cs_new_protected:Npx \__driver_color_ensure_current: + { + \cs_if_exist:NTF \luatex_pdfextension:D + { \luatex_pdfextension:D colorstack } + { \pdftex_pdfcolorstack:D } + \exp_not:N \l__driver_color_stack_int push + { \exp_not:N \l__driver_current_color_tl } + \group_insert_after:N \exp_not:N \__driver_color_reset: + } +\cs_new_protected:Npx \__driver_color_reset: + { + \cs_if_exist:NTF \luatex_pdfextension:D + { \luatex_pdfextension:D colorstack } + { \pdftex_pdfcolorstack:D } + \exp_not:N \l__driver_color_stack_int pop \scan_stop: + } \cs_new_eq:NN \__driver_draw_literal:n \__driver_literal:n \cs_generate_variant:Nn \__driver_draw_literal:n { x } \cs_new_protected:Npn \__driver_draw_begin: diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3prg.sty b/Master/texmf-dist/tex/latex/l3kernel/l3prg.sty index a17d2ea2240..0dd86d4d6fa 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3prg.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3prg.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3prg.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3prop.sty b/Master/texmf-dist/tex/latex/l3kernel/l3prop.sty index 77f6d1baa0e..ee0bec1c87e 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3prop.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3prop.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3prop.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3quark.sty b/Master/texmf-dist/tex/latex/l3kernel/l3quark.sty index 11fb023c9f8..40673cd62b0 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3quark.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3quark.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3quark.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty b/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty index a37f41ed175..dbd89d0a301 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3seq.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3seq.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3skip.sty b/Master/texmf-dist/tex/latex/l3kernel/l3skip.sty index 0ecd47abf7a..bff54263790 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3skip.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3skip.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3skip.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3sort.sty b/Master/texmf-dist/tex/latex/l3kernel/l3sort.sty index 618a56f4d66..9c562ad9755 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3sort.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3sort.sty @@ -41,6 +41,7 @@ \old@liii@module@name{This package is obsolete --- use 'expl3' instead} \RequirePackage{expl3} + %% %% %% End of file `l3sort.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3str.sty b/Master/texmf-dist/tex/latex/l3kernel/l3str.sty index d1e5a9b7512..1f7effda4f6 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3str.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3str.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3str.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty b/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty index f3e6f71ab09..4faa54e46e2 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3tl.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3tl.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3token.sty b/Master/texmf-dist/tex/latex/l3kernel/l3token.sty index dfdf3bde38f..53f89cae6fc 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3token.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3token.sty @@ -44,6 +44,7 @@ use 'expl3' instead} \@ehc \RequirePackage{expl3} + %% %% %% End of file `l3token.sty'. diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def b/Master/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def index 53f51576a3c..80de21c81dd 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def +++ b/Master/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def @@ -25,40 +25,9 @@ \cs_new_protected:Npn \__driver_literal:n #1 { \tex_special:D { pdf:literal~ #1 } } \cs_new_protected:Npn \__driver_scope_begin: - { \__driver_literal:n { q } } + { \tex_special:D { x:gsave } } \cs_new_protected:Npn \__driver_scope_end: - { \__driver_literal:n { Q } } -\cs_new_protected:Npn \__driver_matrix:n #1 - { \__driver_literal:n { #1 \c_space_tl 0~0~cm } } -\tl_new:N \l__driver_current_color_tl -\tl_set:Nn \l__driver_current_color_tl { [ 0 ] } -\AtBeginDocument - { - \@ifpackageloaded { color } - { \tl_set:Nn \l__driver_current_color_tl { \current@color } } - { } - } -\cs_new_protected:Npn \__driver_color_ensure_current: - { - \tex_special:D { pdf:bcolor~\l__driver_current_color_tl } - \group_insert_after:N \__driver_color_reset: - } -\cs_new_protected:Npn \__driver_color_reset: - { \tex_special:D { pdf:ecolor } } -\AtBeginDocument - { - \@ifpackageloaded { color } - { - \cs_set_protected:Npn \__driver_color_ensure_current: - { - \tex_special:D { color~push~\l__driver_current_color_tl } - \group_insert_after:N \__driver_color_reset: - } - \cs_set_protected:Npn \__driver_color_reset: - { \tex_special:D { color~pop } } - } - { } - } + { \tex_special:D { x:grestore } } \cs_new_protected:Npn \__driver_box_use_clip:N #1 { \__driver_scope_begin: @@ -77,41 +46,57 @@ \cs_new_protected:Npn \__driver_box_use_rotate:Nn #1#2 { \__driver_scope_begin: - \box_set_wd:Nn #1 \c_zero_dim - \fp_set:Nn \l__driver_cos_fp { round ( cosd ( #2 ) , 5 ) } - \fp_compare:nNnT \l__driver_cos_fp = \c_zero_fp - { \fp_zero:N \l__driver_cos_fp } - \fp_set:Nn \l__driver_sin_fp { round ( sind ( #2 ) , 5 ) } - \__driver_matrix:n + \tex_special:D { - \fp_use:N \l__driver_cos_fp \c_space_tl - \fp_compare:nNnTF \l__driver_sin_fp = \c_zero_fp - { 0~0 } - { - \fp_use:N \l__driver_sin_fp - \c_space_tl - \fp_eval:n { -\l__driver_sin_fp } - } - \c_space_tl - \fp_use:N \l__driver_cos_fp + x:rotate~ + \fp_compare:nNnTF {#2} = \c_zero_fp + { 0 } + { \fp_eval:n { round ( #2 , 5 ) } } } - \box_use:N #1 - \__driver_scope_end: + \box_use:N #1 + \__driver_scope_end: } -\fp_new:N \l__driver_cos_fp -\fp_new:N \l__driver_sin_fp \cs_new_protected:Npn \__driver_box_use_scale:Nnn #1#2#3 { \__driver_scope_begin: - \__driver_matrix:n + \tex_special:D { + x:scale~ \fp_eval:n { round ( #2 , 5 ) } ~ - 0~0~ \fp_eval:n { round ( #3 , 5 ) } } \hbox_overlap_right:n { \box_use:N #1 } \__driver_scope_end: } +\tl_new:N \l__driver_current_color_tl +\tl_set:Nn \l__driver_current_color_tl { [ 0 ] } +\AtBeginDocument + { + \@ifpackageloaded { color } + { \tl_set:Nn \l__driver_current_color_tl { \current@color } } + { } + } +\cs_new_protected:Npn \__driver_color_ensure_current: + { + \tex_special:D { pdf:bcolor~\l__driver_current_color_tl } + \group_insert_after:N \__driver_color_reset: + } +\cs_new_protected:Npn \__driver_color_reset: + { \tex_special:D { pdf:ecolor } } +\AtBeginDocument + { + \@ifpackageloaded { color } + { + \cs_set_protected:Npn \__driver_color_ensure_current: + { + \tex_special:D { color~push~\l__driver_current_color_tl } + \group_insert_after:N \__driver_color_reset: + } + \cs_set_protected:Npn \__driver_color_reset: + { \tex_special:D { color~pop } } + } + { } + } \cs_new_eq:NN \__driver_draw_literal:n \__driver_literal:n \cs_generate_variant:Nn \__driver_draw_literal:n { x } \cs_new_protected:Npn \__driver_draw_begin: diff --git a/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty b/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty index 05598c500d7..6b8976fe27d 100644 --- a/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty +++ b/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty @@ -19,8 +19,8 @@ %% and all files in that bundle must be distributed together. %% %% File: l3keys2e.dtx (C) Copyright 2009,2011-2017 The LaTeX3 Project -\RequirePackage{expl3}[2017/04/01] -\@ifpackagelater{expl3}{2017/04/01} +\RequirePackage{expl3}[2017/05/13] +\@ifpackagelater{expl3}{2017/05/13} {} {% \PackageError{l3keys2e}{Support package l3kernel too old} @@ -32,7 +32,7 @@ }% \endinput } -\ProvidesExplPackage{l3keys2e}{2017/04/01}{} +\ProvidesExplPackage{l3keys2e}{2017/05/13}{} {LaTeX2e option processing using LaTeX3 keys} \cs_generate_variant:Nn \clist_put_right:Nn { Nv } \cs_generate_variant:Nn \keys_if_exist:nnT { nx } diff --git a/Master/texmf-dist/tex/latex/l3packages/xfp/xfp.sty b/Master/texmf-dist/tex/latex/l3packages/xfp/xfp.sty index 6d1e87919e3..306c0b6ed95 100644 --- a/Master/texmf-dist/tex/latex/l3packages/xfp/xfp.sty +++ b/Master/texmf-dist/tex/latex/l3packages/xfp/xfp.sty @@ -19,8 +19,8 @@ %% and all files in that bundle must be distributed together. %% %% File: xfp.dtx (C) Copyright 2017 The LaTeX3 Project -\RequirePackage{expl3}[2017/04/01] -\@ifpackagelater{expl3}{2017/04/01} +\RequirePackage{expl3}[2017/05/13] +\@ifpackagelater{expl3}{2017/05/13} {} {% \PackageError{xfpu}{Support package l3kernel too old} @@ -33,7 +33,7 @@ \endinput } \RequirePackage{xparse} -\ProvidesExplPackage{xfp}{2017/04/01}{} +\ProvidesExplPackage{xfp}{2017/05/13}{} {L3 Floating point unit} \NewExpandableDocumentCommand \fpeval { m } { \fp_eval:n {#1} } %% diff --git a/Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty b/Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty index 0321ddae4c5..db51d303b99 100644 --- a/Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty +++ b/Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty @@ -20,8 +20,8 @@ %% %% File: xfrac.dtx Copyright (C) 2004, 2008-2010 Morten Hoegholm %% (C) 2011,2012,2014-2017 The LaTeX3 Project -\RequirePackage{expl3}[2017/04/01] -\@ifpackagelater{expl3}{2017/04/01} +\RequirePackage{expl3}[2017/05/13] +\@ifpackagelater{expl3}{2017/05/13} {} {% \PackageError{xfrac}{Support package l3kernel too old} @@ -34,7 +34,7 @@ \endinput } \RequirePackage{amstext,graphicx,l3keys2e,textcomp,xparse,xtemplate} -\ProvidesExplPackage{xfrac}{2017/04/01}{} +\ProvidesExplPackage{xfrac}{2017/05/13}{} {L3 Experimental split-level fractions} \keys_define:nn { xfrac } { diff --git a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty index d266150d793..14e8e59eec0 100644 --- a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty +++ b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty @@ -23,8 +23,8 @@ %% (C) Copyright 2004-2008 Frank Mittelbach, %% The LaTeX3 Project %% (C) Copyright 2009-2017 The LaTeX3 Project -\RequirePackage{expl3}[2017/04/01] -\@ifpackagelater{expl3}{2017/04/01} +\RequirePackage{expl3}[2017/05/13] +\@ifpackagelater{expl3}{2017/05/13} {} {% \PackageError{xparse}{Support package l3kernel too old} @@ -36,7 +36,7 @@ }% \endinput } -\ProvidesExplPackage{xparse}{2017/04/01}{} +\ProvidesExplPackage{xparse}{2017/05/13}{} {L3 Experimental document command parser} \tl_const:Nx \c__xparse_no_value_tl { \char_generate:nn { `\- } { 11 } NoValue- } @@ -285,36 +285,18 @@ } \cs_new_protected:Npn \__xparse_defaults_def:nnn #1#2#3 { - \tl_if_head_is_group:nTF {#3} + \tl_put_right:Nx \l__xparse_tmpa_tl { - \tl_put_right:Nn \l__xparse_tmpa_tl - { + { + \exp_not:N \exp_not:n { - \exp_args:Nf \__xparse_tl_mapthread_function:nnN - { \tl_item:Nn \l__xparse_args_tl {#1} } - {#3} - \__xparse_defaults_def_aux:nn + \__xparse_if_no_value:nTF {#2} + { \exp_not:o {#3} } + { \exp_not:n { ## #1 } } } - } - } - { - \__xparse_if_no_value:nTF {#2} - { - \tl_put_right:Nx \l__xparse_tmpa_tl - { { \exp_not:N \exp_not:n { \exp_not:o {#3} } } } - } - { - \tl_put_right:Nn \l__xparse_tmpa_tl - { { \exp_not:n { ## #1 } } } - } + } } } -\cs_new:Npn \__xparse_defaults_def_aux:nn #1#2 - { - \__xparse_if_no_value:nTF {#1} - { { \exp_not:n {#2} } } - { { \exp_not:n {#1} } } - } \cs_new_protected:Npn \__xparse_args_process: { \tl_clear:N \l__xparse_args_ii_tl @@ -367,28 +349,9 @@ } \cs_new:Npn \__xparse_end_expandable_defaults:nnw #1#2 { - \tl_if_head_is_group:nTF {#1} - { - \__xparse_end_expandable_defaults_E:nnw { } - #1 \q_nil \q_mark - #2 \q_nil - } - { - \__xparse_if_no_value:nTF {#2} - { \exp_args:No \__xparse_end_expandable_defaults:nw {#1} } - { \__xparse_end_expandable_defaults:nw {#2} } - } - } -\cs_new:Npn \__xparse_end_expandable_defaults_E:nnw #1#2#3 \q_mark #4 - { - \quark_if_nil:nTF {#2} - { \__xparse_end_expandable_defaults:nw {#1} } - { - \__xparse_if_no_value:nTF {#4} - { \__xparse_end_expandable_defaults_E:nnw { #1 {#2} } } - { \__xparse_end_expandable_defaults_E:nnw { #1 {#4} } } - #3 \q_mark - } + \__xparse_if_no_value:nTF {#2} + { \exp_args:No \__xparse_end_expandable_defaults:nw {#1} } + { \__xparse_end_expandable_defaults:nw {#2} } } \cs_new:Npn \__xparse_end_expandable_defaults:nw #1#2 \__xparse_end_expandable_defaults:nnnNNn #3 @@ -506,6 +469,7 @@ \__xparse_add_arg_spec:n { E {#1} {#2} } \tl_put_right:Nn \l__xparse_last_delimiters_tl {#1} \bool_set_false:N \l__xparse_grab_expandably_bool + \int_add:Nn \l__xparse_current_arg_int { \tl_count:n {#1} - 1 } \__xparse_normalize_arg_spec_loop:n } \cs_new_protected:Npn \__xparse_normalize_E_unique_check:w #1#2 \q_stop @@ -672,7 +636,6 @@ \cs_new_protected:Npn \__xparse_prepare_signature_bypass:N #1 { \quark_if_recursion_tail_stop:N #1 - \int_incr:N \l__xparse_current_arg_int \use:c { __xparse_add @@ -685,7 +648,6 @@ \__xparse_flush_m_args: \bool_set_true:N \l__xparse_long_bool \bool_set_true:N \l__xparse_prefixed_bool - \int_decr:N \l__xparse_current_arg_int \__xparse_prepare_signature_bypass:N } \cs_new_protected:cpn { __xparse_add_type_>:w } #1 @@ -693,7 +655,6 @@ \__xparse_flush_m_args: \bool_set_true:N \l__xparse_prefixed_bool \bool_set_true:N \l__xparse_process_some_bool - \int_decr:N \l__xparse_current_arg_int \tl_put_left:Nn \l__xparse_process_one_tl { {#1} } \__xparse_prepare_signature_bypass:N } @@ -814,30 +775,26 @@ \__xparse_if_no_value:nTF {#1} { \__xparse_add_default: } { + \int_incr:N \l__xparse_current_arg_int \bool_set_true:N \l__xparse_defaults_bool \tl_put_right:Nn \l__xparse_defaults_tl { { \prg_do_nothing: #1 } } } } \cs_new_protected:Npn \__xparse_add_default: - { \tl_put_right:Nn \l__xparse_defaults_tl { \c__xparse_no_value_tl } } + { + \int_incr:N \l__xparse_current_arg_int + \tl_put_right:Nn \l__xparse_defaults_tl { \c__xparse_no_value_tl } + } \cs_new_protected:Npn \__xparse_add_default_E:nn #1#2 { - \bool_set_true:N \l__xparse_defaults_bool - \tl_put_right:Nx \l__xparse_defaults_tl - { - { - \tl_map_function:nN {#2} \__xparse_add_default_E_aux:n - \prg_replicate:nn - { \tl_count:n {#1} - \tl_count:n {#2} } - { { \c__xparse_no_value_tl } } - } - } + \tl_map_function:nN {#2} \__xparse_add_default:n + \prg_replicate:nn + { \tl_count:n {#1} - \tl_count:n {#2} } + { \__xparse_add_default: } } -\cs_new:Npn \__xparse_add_default_E_aux:n #1 { \exp_not:n { {#1} } } \cs_new_protected:cpn { __xparse_add_expandable_type_+:w } { \bool_set_true:N \l__xparse_long_bool - \int_decr:N \l__xparse_current_arg_int \__xparse_prepare_signature:N } \cs_new_protected:Npn \__xparse_add_expandable_type_D:w @@ -1091,18 +1048,14 @@ \tl_set:Nn \l__xparse_signature_tl {#2} \cs_set_protected:Npn \__xparse_grab_E_finalise: { - \tl_clear:N \l__xparse_tmpa_tl \tl_map_inline:nn {#1} { \prop_get:NnNF \l__xparse_tmp_prop {####1} \l__xparse_tmpb_tl { \tl_set_eq:NN \l__xparse_tmpb_tl \c__xparse_no_value_tl } - \tl_set:Nx \l__xparse_tmpa_tl - { - \exp_not:V \l__xparse_tmpa_tl - { \exp_not:V \l__xparse_tmpb_tl } - } + \tl_put_right:Nx \l__xparse_args_tl + { { \exp_not:V \l__xparse_tmpb_tl } } } - \__xparse_add_arg:V \l__xparse_tmpa_tl + \l__xparse_signature_tl \__xparse_run_code: } \__xparse_grab_E_loop:nnN {#4} { } #1 \q_recursion_tail \q_recursion_stop } @@ -1540,7 +1493,7 @@ \cs_new:Npn \__xparse_expandable_grab_E_find:nnw #1#2#3 \q_nil #4 \q__xparse #5#6#7#8 { \__xparse_expandable_grab_E_aux:w {#1} { #2 {#8} #3 } #4 \q__xparse #5 #6 #7 } \cs_new:Npn \__xparse_expandable_grab_E_end:nnw #1#2#3 \q__xparse #4#5#6 - { #3 {#2} \q__xparse #4 #5 {#1} } + { #3 #2 \q__xparse #4 #5 {#1} } \cs_new:Npn \__xparse_expandable_grab_m:w #1 \q__xparse #2#3 { #3 { \__xparse_expandable_grab_m_aux:wNn #1 \q__xparse #2 #3 } } \cs_new:Npn \__xparse_expandable_grab_m_long:w #1 \q__xparse #2#3 diff --git a/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty b/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty index d3a040d8b8d..91b6e775335 100644 --- a/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty +++ b/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty @@ -23,8 +23,8 @@ %% (C) Copyright 2004-2010 Frank Mittelbach, %% The LaTeX3 Project %% (C) Copyright 2011-2016 The LaTeX3 Project -\RequirePackage{expl3}[2017/04/01] -\@ifpackagelater{expl3}{2017/04/01} +\RequirePackage{expl3}[2017/05/13] +\@ifpackagelater{expl3}{2017/05/13} {} {% \PackageError{xtemplate}{Support package l3kernel too old} @@ -36,7 +36,7 @@ }% \endinput } -\ProvidesExplPackage{xtemplate}{2017/04/01}{} +\ProvidesExplPackage{xtemplate}{2017/05/13}{} {L3 Experimental prototype document functions} \tl_const:Nn \c__xtemplate_code_root_tl { template~code~>~ } \tl_const:Nn \c__xtemplate_defaults_root_tl { template~defaults~>~ } -- cgit v1.2.3