From 56c9134f4aa02292ed17e726efd8e493b90e6011 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 25 Sep 2020 03:01:58 +0000 Subject: CTAN sync 202009250301 --- macros/latex/contrib/l3kernel/CHANGELOG.md | 9 +- macros/latex/contrib/l3kernel/README.md | 4 +- macros/latex/contrib/l3kernel/expl3.dtx | 4 +- macros/latex/contrib/l3kernel/expl3.pdf | Bin 585393 -> 585194 bytes macros/latex/contrib/l3kernel/interface3.pdf | Bin 1556273 -> 1558261 bytes macros/latex/contrib/l3kernel/interface3.tex | 2 +- macros/latex/contrib/l3kernel/l3.ins | 13 +- macros/latex/contrib/l3kernel/l3basics.dtx | 2 +- macros/latex/contrib/l3kernel/l3bootstrap.dtx | 18 +- macros/latex/contrib/l3kernel/l3box.dtx | 2 +- macros/latex/contrib/l3kernel/l3candidates.dtx | 2 +- macros/latex/contrib/l3kernel/l3cctab.dtx | 2 +- macros/latex/contrib/l3kernel/l3clist.dtx | 2 +- macros/latex/contrib/l3kernel/l3coffins.dtx | 2 +- macros/latex/contrib/l3kernel/l3color-base.dtx | 2 +- macros/latex/contrib/l3kernel/l3debug.dtx | 2 +- macros/latex/contrib/l3kernel/l3deprecation.dtx | 2 +- macros/latex/contrib/l3kernel/l3doc.dtx | 2 +- macros/latex/contrib/l3kernel/l3docstrip.dtx | 2 +- macros/latex/contrib/l3kernel/l3docstrip.pdf | Bin 263496 -> 263299 bytes macros/latex/contrib/l3kernel/l3expan.dtx | 2 +- macros/latex/contrib/l3kernel/l3file.dtx | 109 ++------ macros/latex/contrib/l3kernel/l3flag.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-assign.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-aux.dtx | 24 +- macros/latex/contrib/l3kernel/l3fp-basics.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-convert.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-expo.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-extended.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-logic.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-parse.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-random.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-round.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-traps.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp-trig.dtx | 2 +- macros/latex/contrib/l3kernel/l3fp.dtx | 2 +- macros/latex/contrib/l3kernel/l3fparray.dtx | 2 +- macros/latex/contrib/l3kernel/l3int.dtx | 2 +- macros/latex/contrib/l3kernel/l3intarray.dtx | 2 +- .../latex/contrib/l3kernel/l3kernel-functions.dtx | 2 +- macros/latex/contrib/l3kernel/l3keys.dtx | 2 +- macros/latex/contrib/l3kernel/l3legacy.dtx | 2 +- macros/latex/contrib/l3kernel/l3luatex.dtx | 309 ++++++++++++++------- macros/latex/contrib/l3kernel/l3msg.dtx | 2 +- macros/latex/contrib/l3kernel/l3names.dtx | 140 ++++++++-- macros/latex/contrib/l3kernel/l3news.pdf | Bin 379235 -> 379235 bytes macros/latex/contrib/l3kernel/l3news01.pdf | Bin 113527 -> 113527 bytes macros/latex/contrib/l3kernel/l3news02.pdf | Bin 140776 -> 140776 bytes macros/latex/contrib/l3kernel/l3news03.pdf | Bin 144785 -> 144785 bytes macros/latex/contrib/l3kernel/l3news04.pdf | Bin 107115 -> 107115 bytes macros/latex/contrib/l3kernel/l3news05.pdf | Bin 105090 -> 105090 bytes macros/latex/contrib/l3kernel/l3news06.pdf | Bin 140795 -> 140795 bytes macros/latex/contrib/l3kernel/l3news07.pdf | Bin 119094 -> 119094 bytes macros/latex/contrib/l3kernel/l3news08.pdf | Bin 152413 -> 152413 bytes macros/latex/contrib/l3kernel/l3news09.pdf | Bin 235322 -> 235322 bytes macros/latex/contrib/l3kernel/l3news10.pdf | Bin 147097 -> 147097 bytes macros/latex/contrib/l3kernel/l3news11.pdf | Bin 165946 -> 165946 bytes macros/latex/contrib/l3kernel/l3news12.pdf | Bin 199139 -> 199139 bytes macros/latex/contrib/l3kernel/l3prefixes.pdf | Bin 75889 -> 75889 bytes macros/latex/contrib/l3kernel/l3prg.dtx | 2 +- macros/latex/contrib/l3kernel/l3prop.dtx | 2 +- macros/latex/contrib/l3kernel/l3quark.dtx | 2 +- macros/latex/contrib/l3kernel/l3regex.dtx | 2 +- macros/latex/contrib/l3kernel/l3seq.dtx | 2 +- macros/latex/contrib/l3kernel/l3skip.dtx | 2 +- macros/latex/contrib/l3kernel/l3sort.dtx | 2 +- macros/latex/contrib/l3kernel/l3str-convert.dtx | 2 +- macros/latex/contrib/l3kernel/l3str.dtx | 40 +-- macros/latex/contrib/l3kernel/l3styleguide.pdf | Bin 280233 -> 280036 bytes macros/latex/contrib/l3kernel/l3styleguide.tex | 2 +- macros/latex/contrib/l3kernel/l3syntax-changes.pdf | Bin 228529 -> 228324 bytes macros/latex/contrib/l3kernel/l3syntax-changes.tex | 2 +- macros/latex/contrib/l3kernel/l3sys.dtx | 102 +++++-- macros/latex/contrib/l3kernel/l3term-glossary.pdf | Bin 217900 -> 217704 bytes macros/latex/contrib/l3kernel/l3term-glossary.tex | 2 +- macros/latex/contrib/l3kernel/l3text-case.dtx | 2 +- macros/latex/contrib/l3kernel/l3text-purify.dtx | 2 +- macros/latex/contrib/l3kernel/l3text.dtx | 2 +- macros/latex/contrib/l3kernel/l3tl-analysis.dtx | 2 +- macros/latex/contrib/l3kernel/l3tl.dtx | 2 +- macros/latex/contrib/l3kernel/l3token.dtx | 250 +++++++++++------ macros/latex/contrib/l3kernel/l3unicode.dtx | 21 +- macros/latex/contrib/l3kernel/source3.pdf | Bin 5860559 -> 5873517 bytes macros/latex/contrib/l3kernel/source3.tex | 2 +- 84 files changed, 692 insertions(+), 451 deletions(-) (limited to 'macros/latex/contrib/l3kernel') diff --git a/macros/latex/contrib/l3kernel/CHANGELOG.md b/macros/latex/contrib/l3kernel/CHANGELOG.md index 1c8206f28f..b3ccf0b773 100644 --- a/macros/latex/contrib/l3kernel/CHANGELOG.md +++ b/macros/latex/contrib/l3kernel/CHANGELOG.md @@ -7,6 +7,12 @@ this project uses date-based 'snapshot' version identifiers. ## [Unreleased] +## [2020-09-24] + +### Changed +- Use Lua pseudo-primitives instead of `\directlua` +- `\token_if_primitive:N(TF)` now reports pseudo-primitives as primitives in LuaTeX + ## [2020-09-06] ### Fixed @@ -765,7 +771,8 @@ this project uses date-based 'snapshot' version identifiers. - Step func­tions have been added for dim vari­ables, e.g. `\dim_step_in­line:nnnn` -[Unreleased]: https://github.com/latex3/latex3/compare/2020-09-06...HEAD +[Unreleased]: https://github.com/latex3/latex3/compare/2020-09-24...HEAD +[2020-09-24]: https://github.com/latex3/latex3/compare/2020-09-06...2020-09-24 [2020-09-06]: https://github.com/latex3/latex3/compare/2020-09-03...2020-09-06 [2020-09-03]: https://github.com/latex3/latex3/compare/2020-09-01...2020-09-03 [2020-09-01]: https://github.com/latex3/latex3/compare/2020-08-07...2020-09-01 diff --git a/macros/latex/contrib/l3kernel/README.md b/macros/latex/contrib/l3kernel/README.md index d90d237fe6..9f52369eb7 100644 --- a/macros/latex/contrib/l3kernel/README.md +++ b/macros/latex/contrib/l3kernel/README.md @@ -1,7 +1,7 @@ LaTeX3 Programming Conventions ============================== -Release 2020-09-06 +Release 2020-09-24 Overview -------- @@ -33,7 +33,7 @@ category codes (for Unicode engines) and PDF support primitives (where direct PDF generation is used). The bundle only works with the following engines: * pdfTeX v1.40 or later * XeTeX v0.99992 or later -* LuaTeX v0.76 or later +* LuaTeX v1.10 or later * e-(u)pTeX from mid-2012 onward pdfTeX v1.40 was released in 2007, and so any recent TeX distribution diff --git a/macros/latex/contrib/l3kernel/expl3.dtx b/macros/latex/contrib/l3kernel/expl3.dtx index 140e507b63..003502090e 100644 --- a/macros/latex/contrib/l3kernel/expl3.dtx +++ b/macros/latex/contrib/l3kernel/expl3.dtx @@ -24,7 +24,7 @@ % %<*driver|generic|package|2ekernel> % -\def\ExplFileDate{2020-09-06}% +\def\ExplFileDate{2020-09-24}% %<*driver> \documentclass[full]{l3doc} \usepackage{graphicx} @@ -51,7 +51,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/expl3.pdf b/macros/latex/contrib/l3kernel/expl3.pdf index b48b54946a..dbe8f29701 100644 Binary files a/macros/latex/contrib/l3kernel/expl3.pdf and b/macros/latex/contrib/l3kernel/expl3.pdf differ diff --git a/macros/latex/contrib/l3kernel/interface3.pdf b/macros/latex/contrib/l3kernel/interface3.pdf index 79ba503768..a19a9a94ad 100644 Binary files a/macros/latex/contrib/l3kernel/interface3.pdf and b/macros/latex/contrib/l3kernel/interface3.pdf differ diff --git a/macros/latex/contrib/l3kernel/interface3.tex b/macros/latex/contrib/l3kernel/interface3.tex index 8a163631f1..020a23120a 100644 --- a/macros/latex/contrib/l3kernel/interface3.tex +++ b/macros/latex/contrib/l3kernel/interface3.tex @@ -54,7 +54,7 @@ for those people who are interested. {latex-team@latex-project.org}% }% } -\date{Released 2020-09-06} +\date{Released 2020-09-24} \pagenumbering{roman} \maketitle diff --git a/macros/latex/contrib/l3kernel/l3.ins b/macros/latex/contrib/l3kernel/l3.ins index 5e7d1bfff9..ad3b5267dd 100644 --- a/macros/latex/contrib/l3kernel/l3.ins +++ b/macros/latex/contrib/l3kernel/l3.ins @@ -60,7 +60,7 @@ and all files in that bundle must be distributed together. { \from{expl3.dtx} {package} \from{l3bootstrap.dtx} {package} - \from{l3names.dtx} {package} + \from{l3names.dtx} {package,tex} \from{l3basics.dtx} {package} \from{l3expan.dtx} {package} \from{l3quark.dtx} {package} @@ -70,9 +70,9 @@ and all files in that bundle must be distributed together. \from{l3int.dtx} {package} \from{l3flag.dtx} {package} \from{l3prg.dtx} {package} - \from{l3sys.dtx} {package} + \from{l3sys.dtx} {package,tex} \from{l3clist.dtx} {package} - \from{l3token.dtx} {package} + \from{l3token.dtx} {package,tex} \from{l3prop.dtx} {package} \from{l3msg.dtx} {package} \from{l3file.dtx} {package} @@ -165,6 +165,11 @@ and all files in that bundle must be distributed together. \endpreamble \nopostamble -\generate{\file{expl3.lua}{\from{l3luatex.dtx}{package,lua}}} +\generate{\file{expl3.lua}{ + \from{l3luatex.dtx}{package,lua} + \from{l3names.dtx}{package,lua} + \from{l3sys.dtx}{package,lua} + \from{l3token.dtx}{package,lua} +}} \endbatchfile diff --git a/macros/latex/contrib/l3kernel/l3basics.dtx b/macros/latex/contrib/l3kernel/l3basics.dtx index b167eb6dcf..0d2594ca74 100644 --- a/macros/latex/contrib/l3kernel/l3basics.dtx +++ b/macros/latex/contrib/l3kernel/l3basics.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3bootstrap.dtx b/macros/latex/contrib/l3kernel/l3bootstrap.dtx index 810de9812c..c3b597031a 100644 --- a/macros/latex/contrib/l3kernel/l3bootstrap.dtx +++ b/macros/latex/contrib/l3kernel/l3bootstrap.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % @@ -176,16 +176,23 @@ \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname directlua\endcsname\relax \else - \ifnum\luatexversion<95 % + \ifnum\luatexversion<110 % \else % \end{macrocode} % For \LuaTeX{} we make sure the basic support is loaded: % this is only necessary in plain. +% +% Additionally we just ensure that \TeX{} has seen the csnames \cs{prg_return_true:} +% and \cs{prg_return_false:} before the Lua code builds these tokens. % \begin{macrocode} \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname newcatcodetable\endcsname\relax \input{ltluatex}% \fi + \begingroup\edef\ignored{% + \expandafter\noexpand\csname prg_return_true:\endcsname + \expandafter\noexpand\csname prg_return_false:\endcsname + }\endgroup \directlua{require("expl3")}% % \end{macrocode} % As the user might be making a custom format, no assumption is made about @@ -212,6 +219,9 @@ % The code currently requires \eTeX{} and functionality equivalent to % \tn{pdfstrcmp}, and also driver and Unicode character support. This is % available in a reasonably-wide range of engines. +% +% For \LuaTeX, we require at least Lua 5.3 and the |token.set_lua| function. +% This is available at least since \LuaTeX{} 1.10. % \begin{macrocode} \begingroup \def\next{\endgroup}% @@ -224,7 +234,7 @@ These are available in the engines\LineBreak - pdfTeX v1.40\LineBreak - XeTeX v0.99992\LineBreak - - LuaTeX v0.95\LineBreak + - LuaTeX v1.10\LineBreak - e-(u)pTeX mid-2012\LineBreak or later.\LineBreak \LineBreak @@ -247,7 +257,7 @@ \fi \expandafter\ifx\csname directlua\endcsname\relax \else - \ifnum\luatexversion<76 \else 1\fi + \ifnum\luatexversion<110 \else 1\fi \fi =0 % \newlinechar`\^^J % diff --git a/macros/latex/contrib/l3kernel/l3box.dtx b/macros/latex/contrib/l3kernel/l3box.dtx index d3a00d00f3..dbf1619275 100644 --- a/macros/latex/contrib/l3kernel/l3box.dtx +++ b/macros/latex/contrib/l3kernel/l3box.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3candidates.dtx b/macros/latex/contrib/l3kernel/l3candidates.dtx index 7c745269ec..3014f8a118 100644 --- a/macros/latex/contrib/l3kernel/l3candidates.dtx +++ b/macros/latex/contrib/l3kernel/l3candidates.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3cctab.dtx b/macros/latex/contrib/l3kernel/l3cctab.dtx index 79f1f45fcd..f07f1a1b6d 100644 --- a/macros/latex/contrib/l3kernel/l3cctab.dtx +++ b/macros/latex/contrib/l3kernel/l3cctab.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3clist.dtx b/macros/latex/contrib/l3kernel/l3clist.dtx index b125b7f2f8..e2931f26de 100644 --- a/macros/latex/contrib/l3kernel/l3clist.dtx +++ b/macros/latex/contrib/l3kernel/l3clist.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3coffins.dtx b/macros/latex/contrib/l3kernel/l3coffins.dtx index 849eddaaea..3ec8d95ff9 100644 --- a/macros/latex/contrib/l3kernel/l3coffins.dtx +++ b/macros/latex/contrib/l3kernel/l3coffins.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3color-base.dtx b/macros/latex/contrib/l3kernel/l3color-base.dtx index f34fab4020..47515cd30e 100644 --- a/macros/latex/contrib/l3kernel/l3color-base.dtx +++ b/macros/latex/contrib/l3kernel/l3color-base.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3debug.dtx b/macros/latex/contrib/l3kernel/l3debug.dtx index 5a214de133..72cd83ed35 100644 --- a/macros/latex/contrib/l3kernel/l3debug.dtx +++ b/macros/latex/contrib/l3kernel/l3debug.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3deprecation.dtx b/macros/latex/contrib/l3kernel/l3deprecation.dtx index be0f204446..fff81d47ad 100644 --- a/macros/latex/contrib/l3kernel/l3deprecation.dtx +++ b/macros/latex/contrib/l3kernel/l3deprecation.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3doc.dtx b/macros/latex/contrib/l3kernel/l3doc.dtx index 60f5e465c3..db015fd372 100644 --- a/macros/latex/contrib/l3kernel/l3doc.dtx +++ b/macros/latex/contrib/l3kernel/l3doc.dtx @@ -79,7 +79,7 @@ and all files in that bundle must be distributed together. % % \title{The \cls{l3doc} class} % \author{\Team} -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % \maketitle % \tableofcontents % diff --git a/macros/latex/contrib/l3kernel/l3docstrip.dtx b/macros/latex/contrib/l3kernel/l3docstrip.dtx index c0e139cb3b..171d20f694 100644 --- a/macros/latex/contrib/l3kernel/l3docstrip.dtx +++ b/macros/latex/contrib/l3kernel/l3docstrip.dtx @@ -63,7 +63,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3docstrip.pdf b/macros/latex/contrib/l3kernel/l3docstrip.pdf index 6eaac9700b..057b880d3f 100644 Binary files a/macros/latex/contrib/l3kernel/l3docstrip.pdf and b/macros/latex/contrib/l3kernel/l3docstrip.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3expan.dtx b/macros/latex/contrib/l3kernel/l3expan.dtx index 41af274e8b..4c2039f911 100644 --- a/macros/latex/contrib/l3kernel/l3expan.dtx +++ b/macros/latex/contrib/l3kernel/l3expan.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3file.dtx b/macros/latex/contrib/l3kernel/l3file.dtx index 67d708da28..d96d9c7e31 100644 --- a/macros/latex/contrib/l3kernel/l3file.dtx +++ b/macros/latex/contrib/l3kernel/l3file.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % @@ -2636,18 +2636,9 @@ % \end{macro} % % \begin{macro}{\@@_size:n} -% A copy of the primitive where it's available, or the \LuaTeX{} -% equivalent if relevant. +% A copy of the primitive where it's available. % \begin{macrocode} \cs_new_eq:NN \@@_size:n \tex_filesize:D -\sys_if_engine_luatex:T - { - \cs_gset:Npn \@@_size:n #1 - { - \lua_now:e - { l3kernel.filesize ( " \lua_escape:e {#1} " ) } - } - } % \end{macrocode} % \end{macro} % @@ -2753,9 +2744,7 @@ % \end{macrocode} % Deal with the fact that the primitive might not be available. % \begin{macrocode} -\bool_lazy_or:nnF - { \cs_if_exist_p:N \tex_filesize:D } - { \sys_if_engine_luatex_p: } +\cs_if_exist:NF \tex_filesize:D { \cs_gset:Npn \file_full_name:n #1 { @@ -2817,9 +2806,7 @@ % existence of the file with |.tex| extension in that directory, and % if it exists we include the |.tex| extension in the result. % \begin{macrocode} -\bool_lazy_or:nnF - { \cs_if_exist_p:N \tex_filesize:D } - { \sys_if_engine_luatex_p: } +\cs_if_exist:NF \tex_filesize:D { \prg_set_protected_conditional:Npnn \file_get_full_name:nN #1#2 { T , F , TF } { @@ -2882,8 +2869,6 @@ % As the MD5 function has a slightly different syntax from the other commands, % there is a little cleaning up to do. % \begin{macrocode} -\cs_new:Npn \file_mdfive_hash:n #1 - { \@@_details:nn {#1} { mdfivesum } } \cs_new:Npn \file_size:n #1 { \@@_details:nn {#1} { size } } \cs_new:Npn \file_timestamp:n #1 @@ -2898,20 +2883,10 @@ \tl_if_blank:nF {#1} { \use:c { tex_file #2 :D } {#1} } } -\sys_if_engine_luatex:TF - { - \cs_gset:Npn \@@_details_aux:nn #1#2 - { - \lua_now:e - { l3kernel.file#2 ( " \lua_escape:e { #1 } " ) } - } - } - { - \cs_gset:Npn \file_mdfive_hash:n #1 - { \exp_args:Ne \@@_mdfive_hash:n { \file_full_name:n {#1} } } - \cs_new:Npn \@@_mdfive_hash:n #1 - { \tex_mdfivesum:D file {#1} } - } +\cs_new:Npn \file_mdfive_hash:n #1 + { \exp_args:Ne \@@_mdfive_hash:n { \file_full_name:n {#1} } } +\cs_new:Npn \@@_mdfive_hash:n #1 + { \tex_mdfivesum:D file {#1} } % \end{macrocode} % \end{macro} % \end{macro} @@ -2973,34 +2948,21 @@ length ~ \int_eval:n { #1 - #2 + 1 } {#3} } -\sys_if_engine_luatex:T - { - \cs_gset:Npn \@@_hex_dump_auxiv:nnn #1#2#3 - { - \lua_now:e - { - l3kernel.filedump - ( - " \lua_escape:e {#3} " , - \int_eval:n { #2 - 1 } , - \int_eval:n { #1 - #2 + 1 } - ) - } - } - } \cs_new:Npn \file_hex_dump:n #1 { \exp_args:Ne \@@_hex_dump:n { \file_full_name:n {#1} } } -\cs_new:Npn \@@_hex_dump:n #1 +\sys_if_engine_luatex:TF { - \tl_if_blank:nF {#1} - { \tex_filedump:D length \tex_filesize:D {#1} {#1} } + \cs_new:Npn \@@_hex_dump:n #1 + { + \tl_if_blank:nF {#1} + { \tex_filedump:D whole {#1} {#1} } + } } -\sys_if_engine_luatex:T { - \cs_gset:Npn \@@_hex_dump:n #1 + \cs_new:Npn \@@_hex_dump:n #1 { - \lua_now:e - { l3kernel.filedump ( " \lua_escape:e { #1 } " ) } + \tl_if_blank:nF {#1} + { \tex_filedump:D length \tex_filesize:D {#1} {#1} } } } % \end{macrocode} @@ -3048,9 +3010,7 @@ % Where the primitive is not available, issue an error: this is a little % more conservative than absolutely needed, but does work. % \begin{macrocode} -\bool_lazy_or:nnF - { \cs_if_exist_p:N \tex_filesize:D } - { \sys_if_engine_luatex_p: } +\cs_if_exist:NF \tex_filesize:D { \cs_set_protected:Npn \@@_get_details:nnN #1#2#3 { @@ -3095,33 +3055,12 @@ % \end{macro} % % \begin{macro}[EXP]{\@@_str_cmp:nn} -% \begin{macro}[EXP]{\@@_str_escape:n} % As we are doing a fixed-length \enquote{big} integer comparison, it % is easiest to use the low-level behavior of string comparisons. % \begin{macrocode} -\cs_new:Npn \@@_str_cmp:nn #1#2 { \tex_strcmp:D {#1} {#2} } -\sys_if_engine_luatex:T - { - \cs_set:Npn \@@_str_cmp:nn #1#2 - { - \lua_now:e - { - l3kernel.strcmp - ( - " \@@_str_escape:n {#1}", - " \@@_str_escape:n {#2}" - ) - } - } - \cs_new:Npn \@@_str_escape:n #1 - { - \lua_escape:e - { \__kernel_tl_to_str:w \use:e { {#1} } } - } - } +\cs_new_eq:NN \@@_str_cmp:nn \tex_strcmp:D % \end{macrocode} % \end{macro} -% \end{macro} % % \begin{macro}[EXP, pTF]{\file_compare_timestamp:nNn} % \begin{macro}[EXP]{\@@_compare_timestamp:nnN} @@ -3169,15 +3108,7 @@ } } } -\sys_if_engine_luatex:TF - { - \cs_new:Npn \@@_timestamp:n #1 - { - \lua_now:e - { l3kernel.filemoddate ( " \lua_escape:e {#1} " ) } - } - } - { \cs_new_eq:NN \@@_timestamp:n \tex_filemoddate:D } +\cs_new_eq:NN \@@_timestamp:n \tex_filemoddate:D \cs_if_exist:NF \@@_timestamp:n { \prg_set_conditional:Npnn \file_compare_timestamp:nNn #1#2#3 diff --git a/macros/latex/contrib/l3kernel/l3flag.dtx b/macros/latex/contrib/l3kernel/l3flag.dtx index 697a9bd0de..66c065a0e7 100644 --- a/macros/latex/contrib/l3kernel/l3flag.dtx +++ b/macros/latex/contrib/l3kernel/l3flag.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-assign.dtx b/macros/latex/contrib/l3kernel/l3fp-assign.dtx index 4635d8a5af..cddaff1eba 100644 --- a/macros/latex/contrib/l3kernel/l3fp-assign.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-assign.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % \maketitle % % \begin{documentation} diff --git a/macros/latex/contrib/l3kernel/l3fp-aux.dtx b/macros/latex/contrib/l3kernel/l3fp-aux.dtx index a01a2aa3a3..9e917ddb9d 100644 --- a/macros/latex/contrib/l3kernel/l3fp-aux.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-aux.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % @@ -1239,27 +1239,9 @@ % \subsection{Fast string comparison} % % \begin{macro}{\@@_str_if_eq:nn} -% A private version of the low-level string comparison function. As -% the nature of the arguments is restricted and as speed is of the essence, -% this version does not seek to deal with |#| tokens. -% No \pkg{l3sys} or \pkg{l3luatex} just yet so we have to define in terms of -% primitives. +% A private version of the low-level string comparison function. % \begin{macrocode} -\sys_if_engine_luatex:TF - { - \cs_new:Npn \@@_str_if_eq:nn #1#2 - { - \tex_directlua:D - { - l3kernel.strcmp - ( - " \tex_luaescapestring:D {#1}", - " \tex_luaescapestring:D {#2}" - ) - } - } - } - { \cs_new_eq:NN \@@_str_if_eq:nn \tex_strcmp:D } +\cs_new_eq:NN \@@_str_if_eq:nn \tex_strcmp:D % \end{macrocode} % \end{macro} % diff --git a/macros/latex/contrib/l3kernel/l3fp-basics.dtx b/macros/latex/contrib/l3kernel/l3fp-basics.dtx index e0a2b26b1a..29e30ecc1f 100644 --- a/macros/latex/contrib/l3kernel/l3fp-basics.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-basics.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-convert.dtx b/macros/latex/contrib/l3kernel/l3fp-convert.dtx index a18213f911..3b0dd3360e 100644 --- a/macros/latex/contrib/l3kernel/l3fp-convert.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-convert.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-expo.dtx b/macros/latex/contrib/l3kernel/l3fp-expo.dtx index b7e4e1bb29..c86808203c 100644 --- a/macros/latex/contrib/l3kernel/l3fp-expo.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-expo.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-extended.dtx b/macros/latex/contrib/l3kernel/l3fp-extended.dtx index f801c860b5..7ed1e42736 100644 --- a/macros/latex/contrib/l3kernel/l3fp-extended.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-extended.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-logic.dtx b/macros/latex/contrib/l3kernel/l3fp-logic.dtx index daf38c1a39..8c0a215652 100644 --- a/macros/latex/contrib/l3kernel/l3fp-logic.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-logic.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-parse.dtx b/macros/latex/contrib/l3kernel/l3fp-parse.dtx index 0753398abc..7d43b526ea 100644 --- a/macros/latex/contrib/l3kernel/l3fp-parse.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-parse.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-random.dtx b/macros/latex/contrib/l3kernel/l3fp-random.dtx index 4b86d9aa07..7a125bc22f 100644 --- a/macros/latex/contrib/l3kernel/l3fp-random.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-random.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-round.dtx b/macros/latex/contrib/l3kernel/l3fp-round.dtx index 76400b3bac..551902b58b 100644 --- a/macros/latex/contrib/l3kernel/l3fp-round.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-round.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp-traps.dtx b/macros/latex/contrib/l3kernel/l3fp-traps.dtx index 6948b7104a..89f47bfafc 100644 --- a/macros/latex/contrib/l3kernel/l3fp-traps.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-traps.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % \maketitle % % \begin{documentation} diff --git a/macros/latex/contrib/l3kernel/l3fp-trig.dtx b/macros/latex/contrib/l3kernel/l3fp-trig.dtx index 3719dd113d..319e825bd0 100644 --- a/macros/latex/contrib/l3kernel/l3fp-trig.dtx +++ b/macros/latex/contrib/l3kernel/l3fp-trig.dtx @@ -40,7 +40,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fp.dtx b/macros/latex/contrib/l3kernel/l3fp.dtx index f19f21c1c3..144a59bb7e 100644 --- a/macros/latex/contrib/l3kernel/l3fp.dtx +++ b/macros/latex/contrib/l3kernel/l3fp.dtx @@ -49,7 +49,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3fparray.dtx b/macros/latex/contrib/l3kernel/l3fparray.dtx index 449f786201..41824d7478 100644 --- a/macros/latex/contrib/l3kernel/l3fparray.dtx +++ b/macros/latex/contrib/l3kernel/l3fparray.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3int.dtx b/macros/latex/contrib/l3kernel/l3int.dtx index 02c29627da..175a9e07dd 100644 --- a/macros/latex/contrib/l3kernel/l3int.dtx +++ b/macros/latex/contrib/l3kernel/l3int.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3intarray.dtx b/macros/latex/contrib/l3kernel/l3intarray.dtx index e41a839d39..dbeddb1ca1 100644 --- a/macros/latex/contrib/l3kernel/l3intarray.dtx +++ b/macros/latex/contrib/l3kernel/l3intarray.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3kernel-functions.dtx b/macros/latex/contrib/l3kernel/l3kernel-functions.dtx index e73b8d6c55..c7a577d8ba 100644 --- a/macros/latex/contrib/l3kernel/l3kernel-functions.dtx +++ b/macros/latex/contrib/l3kernel/l3kernel-functions.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3keys.dtx b/macros/latex/contrib/l3kernel/l3keys.dtx index 812b0941e1..3e79e8c464 100644 --- a/macros/latex/contrib/l3kernel/l3keys.dtx +++ b/macros/latex/contrib/l3kernel/l3keys.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3legacy.dtx b/macros/latex/contrib/l3kernel/l3legacy.dtx index 0dcb0a5cb6..f5453f5fe1 100644 --- a/macros/latex/contrib/l3kernel/l3legacy.dtx +++ b/macros/latex/contrib/l3kernel/l3legacy.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3luatex.dtx b/macros/latex/contrib/l3kernel/l3luatex.dtx index b8f00b1187..ca26662658 100644 --- a/macros/latex/contrib/l3kernel/l3luatex.dtx +++ b/macros/latex/contrib/l3kernel/l3luatex.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % @@ -120,9 +120,15 @@ % As well as interfaces for \TeX{}, there are a small number of Lua functions % provided here. % -% \begin{function}{l3kernel} -% All public interfaces provided by the module are stored within the -% |l3kernel| table. +% \begin{function}{ltx.utils} +% Most public interfaces provided by the module are stored within the +% |ltx.utils| table. +% \end{function} +% +% \begin{function}[deprecated = 2021-12-31]{l3kernel} +% For compatibility reasons, there are also some deprecated interfaces provided +% in the |l3kernel| table. These do not return their result as Lua values but +% instead print them to \TeX. % \end{function} % % \begin{function}{l3kernel.charcat} @@ -143,8 +149,9 @@ % for user input. % \end{function} % -% \begin{function}{l3kernel.filedump} +% \begin{function}{ltx.utils.filedump, l3kernel.filedump} % \begin{syntax} +% \meta{dump}| = ltx.utils.filedump(|\meta{file}|,|\meta{offset}|,|\meta{length}|)| \\ % |l3kernel.filedump(|\meta{file}|,|\meta{offset}|,|\meta{length}|)| % \end{syntax} % Returns the uppercase hexadecimal representation of the content of the @@ -154,8 +161,9 @@ % is read starting at the \meta{offset}. % \end{function} % -% \begin{function}{l3kernel.filemdfivesum} +% \begin{function}{ltx.utils.filemd5sum, l3kernel.filemdfivesum} % \begin{syntax} +% \meta{hash}| = ltx.utils.filemd5sum(|\meta{file}|)| \\ % |l3kernel.filemdfivesum(|\meta{file}|)| % \end{syntax} % Returns the MD5 sum of the file contents read as bytes; note that @@ -164,8 +172,9 @@ % nothing is returned with \emph{no error raised}. % \end{function} % -% \begin{function}{l3kernel.filemoddate} +% \begin{function}{ltx.utils.filemoddate, l3kernel.filemoddate} % \begin{syntax} +% \meta{date}| = ltx.utils.filemoddate(|\meta{file}|)| \\ % |l3kernel.filemoddate(|\meta{file}|)| % \end{syntax} % Returns the date/time of last modification of the \meta{file} in the @@ -179,8 +188,9 @@ % not found, nothing is returned with \emph{no error raised}. % \end{function} % -% \begin{function}{l3kernel.filesize} +% \begin{function}{ltx.utils.filesize, l3kernel.filesize} % \begin{syntax} +% |size = ltx.utils.filesize(|\meta{file}|)| \\ % |l3kernel.filesize(|\meta{file}|)| % \end{syntax} % Returns the size of the \meta{file} in bytes. If the \meta{file} is not @@ -313,11 +323,17 @@ % \pkg{pdftexcmds} package. % % \begin{macro}{l3kernel} +% \begin{macro}{ltx.utils} % Create a table for the kernel's own use. % \begin{macrocode} l3kernel = l3kernel or { } +local l3kernel = l3kernel +ltx = ltx or {utils={}} +ltx.utils = ltx.utils or { } +local ltxutils = ltx.utils % \end{macrocode} % \end{macro} +% \end{macro} % % Local copies of global tables. % \begin{macrocode} @@ -331,7 +347,6 @@ local string = string local tex = tex local texio = texio local tonumber = tonumber -local unicode = unicode % \end{macrocode} % % Local copies of standard functions. @@ -342,23 +357,33 @@ local floor = math.floor local format = string.format local gsub = string.gsub local lfs_attr = lfs.attributes -local md5_sum = md5.sum local open = io.open -local os_clock = os.clock local os_date = os.date -local os_exec = os.execute local setcatcode = tex.setcatcode local sprint = tex.sprint local cprint = tex.cprint local write = tex.write local write_nl = texio.write_nl +local utf8_char = utf8.char + +local scan_int = token.scan_int or token.scan_integer +local scan_string = token.scan_string +local scan_keyword = token.scan_keyword +local put_next = token.put_next + +local true_tok = token.create'prg_return_true:' +local false_tok = token.create'prg_return_false:' % \end{macrocode} % -% Newer Con\TeX{}t releases replace the |unicode| library by |utf| and -% since Lua 5.3 we can even use the Lua standard |utf8| library. % \begin{macrocode} -local utf8_char = (utf8 and utf8.char) or (utf and utf.char) or unicode.utf8.char -% \end{macrocode} +local function deprecated(table, name, func) + table[name] = function(...) + write_nl(format("Calling deprecated Lua function %s", name)) + table[name] = func + return func(...) + end +end +% \end{macrocode % % Deal with Con\TeX{}t: doesn't use |kpse| library. % \begin{macrocode} @@ -371,20 +396,20 @@ local kpse_find = (resolvers and resolvers.findfile) or kpse.find_file % covered in \pkg{pdftexcmds} but is not currently required here. % \begin{macrocode} local function escapehex(str) - write((gsub(str, ".", - function (ch) return format("%02X", byte(ch)) end))) + return (gsub(str, ".", + function (ch) return format("%02X", byte(ch)) end)) end % \end{macrocode} % \end{macro} % % \begin{macro}{l3kernel.charcat} % Creating arbitrary chars using |tex.cprint|. +% The alternative approach using |token.put_next(token.create(...))| +% would be about 10\% slower. % \begin{macrocode} -local charcat -function charcat(charcode, catcode) +deprecated(l3kernel, 'charcat', function(charcode, catcode) cprint(catcode, utf8_char(charcode)) -end -l3kernel.charcat = charcat +end) % \end{macrocode} % \end{macro} % @@ -392,9 +417,10 @@ l3kernel.charcat = charcat % Simple timing set up: give the result from the system clock in scaled % seconds. % \begin{macrocode} -local base_time = 0 +local os_clock = os.clock +local base_clock_time = 0 local function elapsedtime() - local val = (os_clock() - base_time) * 65536 + 0.5 + local val = (os_clock() - base_clock_time) * 65536 + 0.5 if val > 2147483647 then val = 2147483647 end @@ -402,36 +428,56 @@ local function elapsedtime() end l3kernel.elapsedtime = elapsedtime local function resettimer() - base_time = os_clock() + base_clock_time = os_clock() end l3kernel.resettimer = resettimer % \end{macrocode} % \end{macro} % +% \begin{macro}{ltx.utils.filedump} % \begin{macro}{l3kernel.filedump} % Similar comments here to the next function: read the file in binary mode % to avoid any line-end weirdness. % \begin{macrocode} local function filedump(name,offset,length) local file = kpse_find(name,"tex",true) - if file then - local length = tonumber(length) or lfs_attr(file,"size") - local offset = tonumber(offset) or 0 - local f = open(file,"rb") - if f then - if offset > 0 then - f:seek("set",offset) - end - local data = f:read(length) - escapehex(data) - f:close() - end + if not file then return end + local f = open(file,"rb") + if not f then return end + if offset and offset > 0 then + f:seek("set", offset) end + local data = f:read(length or 'a') + f:close() + return escapehex(data) end -l3kernel.filedump = filedump +ltxutils.filedump = filedump +deprecated(l3kernel, "filedump", function(name, offset, length) + local dump = filedump(name, tonumber(offset), tonumber(length)) + if dump then + write(dump) + end +end) % \end{macrocode} % \end{macro} +% \end{macro} % +% \begin{macro}{md5.HEX} +% Hash a string and return the hash in uppercase hexadecimal format. +% In some engines, this is build-in. For traditional \LuaTeX{}, the conversion +% to hexadecimal has to be done by us. +% \begin{macrocode} +local md5_HEX = md5.HEX +if not md5_HEX then + local md5_sum = md5.sum + function md5_HEX(data) + return escapehex(md5_sum(data)) + end + md5.HEX = md5_HEX +end +% \end{macrocode} +% \end{macro} +% \begin{macro}{ltx.utils.filemd5sum} % \begin{macro}{l3kernel.filemdfivesum} % Read an entire file and hash it: the hash function itself is a built-in. % As Lua is byte-based there is no work needed here in terms of UTF-8 @@ -439,94 +485,129 @@ l3kernel.filedump = filedump % \LuaTeX{}). The file is read in binary mode so that no line ending % normalisation occurs. % \begin{macrocode} -local function filemdfivesum(name) - local file = kpse_find(name, "tex", true) - if file then - local f = open(file, "rb") - if f then - local data = f:read("*a") - escapehex(md5_sum(data)) - f:close() - end - end +local function filemd5sum(name) + local file = kpse_find(name, "tex", true) if not file then return end + local f = open(file, "rb") if not f then return end + + local data = f:read("*a") + f:close() + return md5_HEX(data) end -l3kernel.filemdfivesum = filemdfivesum +ltxutils.filemd5sum = filemd5sum +deprecated(l3kernel, "filemdfivesum", function(name) + local hash = filemd5sum(name) + if hash then + write(hash) + end +end) % \end{macrocode} % \end{macro} +% \end{macro} % +% \begin{macro}{ltx.utils.filemoddate} % \begin{macro}{l3kernel.filemoddate} +% There are two cases: If the C standard library is C99 compliant, +% we can use |%z| to get the timezone in almost the right format. +% We only have to add primes and replace a zero or missing offset +% with |Z|. +% +% Of course this would be boring, so Windows does things differently. +% There we have to manually calculate the offset. % See procedure \texttt{makepdftime} in \texttt{utils.c} of % \pdfTeX{}. % \begin{macrocode} -local function filemoddate(name) - local file = kpse_find(name, "tex", true) - if file then +local filemoddate +if os_date'%z':match'^[+-]%d%d%d%d$' then + local pattern = lpeg.Cs(16 * + (lpeg.Cg(lpeg.S'+-' * '0000' * lpeg.Cc'Z') + + 3 * lpeg.Cc"'" * 2 * lpeg.Cc"'" + + lpeg.Cc'Z') + * -1) + function filemoddate(name) + local file = kpse_find(name, "tex", true) + if not file then return end + local date = lfs_attr(file, "modification") + if not date then return end + return pattern:match(os_date("D:%Y%m%d%H%M%S%z", date)) + end +else + local function filemoddate(name) + local file = kpse_find(name, "tex", true) + if not file then return end local date = lfs_attr(file, "modification") - if date then - local d = os_date("*t", date) - if d.sec >= 60 then - d.sec = 59 + if not date then return end + local d = os_date("*t", date) + local u = os_date("!*t", date) + local off = 60 * (d.hour - u.hour) + d.min - u.min + if d.year ~= u.year then + if d.year > u.year then + off = off + 1440 + else + off = off - 1440 end - local u = os_date("!*t", date) - local off = 60 * (d.hour - u.hour) + d.min - u.min - if d.year ~= u.year then - if d.year > u.year then - off = off + 1440 - else - off = off - 1440 - end - elseif d.yday ~= u.yday then - if d.yday > u.yday then - off = off + 1440 - else - off = off - 1440 - end + elseif d.yday ~= u.yday then + if d.yday > u.yday then + off = off + 1440 + else + off = off - 1440 end - local timezone - if off == 0 then - timezone = "Z" + end + local timezone + if off == 0 then + timezone = "Z" + else + if off < 0 then + timezone = "-" + off = -off else - local hours = floor(off / 60) - local mins = abs(off - hours * 60) - timezone = format("%+03d", hours) - .. "'" .. format("%02d", mins) .. "'" + timezone = "+" end - write("D:" - .. format("%04d", d.year) - .. format("%02d", d.month) - .. format("%02d", d.day) - .. format("%02d", d.hour) - .. format("%02d", d.min) - .. format("%02d", d.sec) - .. timezone) + timezone = format("%s%02d'%02d'", timezone, hours // 60, hours % 60) end + return format("D:%04d%02d%02d%02d%02d%02d%s", + d.year, d.month, d.day, d.hour, d.min, d.sec, timezone) end end -l3kernel.filemoddate = filemoddate +ltxutils.filemoddate = filemoddate +deprecated(l3kernel, "filemoddate", function(name) + local hash = filemoddate(name) + if hash then + write(hash) + end +end) % \end{macrocode} % \end{macro} +% \end{macro} % +% \begin{macro}{ltx.utils.filesize} % \begin{macro}{l3kernel.filesize} % A simple disk lookup. % \begin{macrocode} local function filesize(name) - local file = kpse_find(name, "tex", true) + local file = kpse_find(name, "tex", true) if file then local size = lfs_attr(file, "size") if size then - write(size) + return size end end end -l3kernel.filesize = filesize +ltxutils.filesize = filesize +deprecated(l3kernel, "filesize", function(name) + local size = filesize(name) + if size then + write(size) + end +end) % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}{l3kernel.strcmp} % String comparison which gives the same results as \pdfTeX{}'s % \tn{pdfstrcmp}, although the ordering should likely not be relied upon! % \begin{macrocode} -local function strcmp(A, B) +deprecated(l3kernel, "strcmp", function (A, B) if A == B then write("0") elseif A < B then @@ -534,15 +615,15 @@ local function strcmp(A, B) else write("1") end -end -l3kernel.strcmp = strcmp +end) % \end{macrocode} % \end{macro} % % \begin{macro}{l3kernel.shellescape} % Replicating the \pdfTeX{} log interaction for shell escape. % \begin{macrocode} -local function shellescape(cmd) +local os_exec = os.execute +deprecated(l3kernel, "shellescape", function(cmd) local status,msg = os_exec(cmd) if status == nil then write_nl("log","runsystem(" .. cmd .. ")...(" .. msg .. ")\n") @@ -551,8 +632,48 @@ local function shellescape(cmd) else write_nl("log","runsystem(" .. cmd .. ")...failed " .. (msg or "") .. "\n") end +end) +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{luadef} +% An internal function for defining control sequences form Lua which behave +% like primitives. This acts as a wrapper around |token.set_lua| which accepts +% a function instead of an index into the functions table. +% \begin{macrocode} +local luacmd do + local token_create = token.create + local set_lua = token.set_lua + local undefined_cs = token.command_id'undefined_cs' + + if not context and not luatexbase then require'ltluatex' end + if luatexbase then + local new_luafunction = luatexbase.new_luafunction + local functions = lua.get_functions_table() + function luacmd(name, func, ...) + local id + local tok = token_create(name) + if tok.command == undefined_cs then + id = new_luafunction(name) + set_lua(name, id, ...) + else + id = tok.index or tok.mode + end + functions[id] = func + end + elseif context then + local register = context.functions.register + local functions = context.functions.known + function luacmd(name, func, ...) + local tok = token.create(name) + if tok.command == undefined_cs then + token.set_lua(name, register(func), ...) + else + functions[tok.index or tok.mode] = func + end + end + end end -l3kernel.shellescape = shellescape % \end{macrocode} % \end{macro} % diff --git a/macros/latex/contrib/l3kernel/l3msg.dtx b/macros/latex/contrib/l3kernel/l3msg.dtx index 748aa87885..56040ef207 100644 --- a/macros/latex/contrib/l3kernel/l3msg.dtx +++ b/macros/latex/contrib/l3kernel/l3msg.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3names.dtx b/macros/latex/contrib/l3kernel/l3names.dtx index 08dad0f48d..e7b7a0e50a 100644 --- a/macros/latex/contrib/l3kernel/l3names.dtx +++ b/macros/latex/contrib/l3kernel/l3names.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % @@ -55,18 +55,19 @@ % performs the following tasks: % \begin{itemize} % \item defines new names for all \TeX{} primitives; +% \item emulate required primitives not provided by default in \LuaTeX; % \item switches to the category code r{\'e}gime for programming; % \end{itemize} % -% This module is entirely dedicated to primitives, which should not be -% used directly within \LaTeX3 code (outside of \enquote{kernel-level} -% code). As such, the primitives are not documented here: \emph{The -% \TeX{}book}, \emph{\TeX{} by Topic} and the manuals for \pdfTeX{}, -% \XeTeX{}, \LuaTeX{}, \pTeX{} and \upTeX{} should be consulted for -% details of the primitives. These are named -% \cs[no-index]{tex_\meta{name}:D}, typically based on the primitive's -% \meta{name} in \pdfTeX{} and omitting a leading |pdf| when the -% primitive is not related to pdf output. +% This module is entirely dedicated to primitives (and emulations of +% these), which should not be used directly within \LaTeX3 code +% (outside of \enquote{kernel-level} code). As such, the primitives +% are not documented here: \emph{The \TeX{}book}, \emph{\TeX{} by +% Topic} and the manuals for \pdfTeX{}, \XeTeX{}, \LuaTeX{}, \pTeX{} +% and \upTeX{} should be consulted for details of the primitives. +% These are named \cs[no-index]{tex_\meta{name}:D}, typically based +% on the primitive's \meta{name} in \pdfTeX{} and omitting a leading +% |pdf| when the primitive is not related to pdf output. % % \end{documentation} % @@ -75,7 +76,7 @@ % \section{\pkg{l3names} implementation} % % \begin{macrocode} -%<*package> +%<*package&tex> % \end{macrocode} % % The prefix here is \texttt{kernel}. A few places need |@@| to be left @@ -111,7 +112,8 @@ % % To allow extracting \enquote{just the names}, a bit of DocStrip fiddling. % \begin{macrocode} -% +% +%<*names|tex> %<*names|package> % \end{macrocode} % @@ -609,9 +611,6 @@ \@@_primitive:NN \pdfeachlinedepth \tex_eachlinedepth:D \@@_primitive:NN \pdfeachlineheight \tex_eachlineheight:D \@@_primitive:NN \pdfelapsedtime \tex_elapsedtime:D - \@@_primitive:NN \pdffiledump \tex_filedump:D - \@@_primitive:NN \pdffilemoddate \tex_filemoddate:D - \@@_primitive:NN \pdffilesize \tex_filesize:D \@@_primitive:NN \pdffirstlineheight \tex_firstlineheight:D \@@_primitive:NN \pdffontexpand \tex_fontexpand:D \@@_primitive:NN \pdffontsize \tex_fontsize:D @@ -622,7 +621,6 @@ \@@_primitive:NN \pdflastypos \tex_lastypos:D \@@_primitive:NN \pdfmapfile \tex_mapfile:D \@@_primitive:NN \pdfmapline \tex_mapline:D - \@@_primitive:NN \pdfmdfivesum \tex_mdfivesum:D \@@_primitive:NN \pdfnoligatures \tex_noligatures:D \@@_primitive:NN \pdfnormaldeviate \tex_normaldeviate:D \@@_primitive:NN \pdfpageheight \tex_pageheight:D @@ -635,7 +633,6 @@ \@@_primitive:NN \pdfrandomseed \tex_randomseed:D \@@_primitive:NN \pdfresettimer \tex_resettimer:D \@@_primitive:NN \pdfsavepos \tex_savepos:D - \@@_primitive:NN \pdfstrcmp \tex_strcmp:D \@@_primitive:NN \pdfsetrandomseed \tex_setrandomseed:D \@@_primitive:NN \pdfshellescape \tex_shellescape:D \@@_primitive:NN \pdftracingfonts \tex_tracingfonts:D @@ -681,6 +678,16 @@ % %<*names|package> % \end{macrocode} +% Some \pdfTeX{} primitives are handled here because they got dropped in +% \LuaTeX{} but the corresponding internal names are emulated later. The +% Lua code is already loaded at this point, so we shouldn't overwrite them. +% \begin{macrocode} + \@@_primitive:NN \pdfstrcmp \tex_strcmp:D + \@@_primitive:NN \pdffilesize \tex_filesize:D + \@@_primitive:NN \pdfmdfivesum \tex_mdfivesum:D + \@@_primitive:NN \pdffilemoddate \tex_filemoddate:D + \@@_primitive:NN \pdffiledump \tex_filedump:D +% \end{macrocode} % \XeTeX{}-specific primitives. Note that \XeTeX{}'s \tn{strcmp} is % handled earlier and is \enquote{rolled up} into \tn{pdfstrcmp}. % A few cross-compatibility names which lack @@ -1187,7 +1194,9 @@ % End of the \enquote{just the names} part of the source. % \begin{macrocode} % +% %<*package> +%<*tex> % \end{macrocode} % % The job is done: close the group (using the primitive renamed!). @@ -1441,6 +1450,103 @@ % \end{macrocode} % % \begin{macrocode} +% +% \end{macrocode} +% +% In \LuaTeX{}, we additionally emulate some primitives using Lua code. +% \begin{macrocode} +%<*lua> +% \end{macrocode} +% +% \begin{macro}{\tex_strcmp:D} +% Compare two strings, expanding to |0| if they are equal, +% |-1| if the first one is smaller and |1| if the second one is smaller. +% Here \enquote{smaller} refers to codepoint order which does not correspond to +% the user expected order for most non-ASCII strings. +% \begin{macrocode} +luacmd('tex_strcmp:D', function() + local first = scan_string() + local second = scan_string() + write(first == second and '0' + or first < second and '-1' + or '1') +end, 'global') +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tex_Ucharcat:D} +% Creating arbitrary chars using |tex.cprint|. +% The alternative approach using |token.put_next(token.create(...))| +% would be about 10\% slower. +% \begin{macrocode} +local cprint = tex.cprint +luacmd('tex_Ucharcat:D', function() + local charcode = scan_int() + local catcode = scan_int() + cprint(catcode, utf8_char(charcode)) +end, 'global') +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tex_filesize:D} +% Wrap the function from |ltxutils|. +% \begin{macrocode} +luacmd('tex_filesize:D', function() + local size = filesize(scan_string()) + if size then write(size) end +end, 'global') +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tex_mdfivesum:D} +% There are two cases: Either hash a file or a string. +% Both are already implemented in l3luatex or built-in. +% \begin{macrocode} +luacmd('tex_mdfivesum:D', function() + local hash + if scan_keyword"file" then + hash = filemd5sum(scan_string()) + else + hash = md5_HEX(scan_string()) + end + if hash then write(hash) end +end, 'global') +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tex_filemoddate:D} +% A primitive for getting the modification date of a file. +% \begin{macrocode} +luacmd('tex_filemoddate:D', function() + local date = filemoddate(scan_string()) + if date then write(date) end +end, 'global') +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tex_filedump:D} +% An emulated primitive for getting a hexdump from a (partial) file. +% The length has a default of |0|. This is consistent with +% \pdfTeX, but it effectivly makes the primitive useless without an +% explicit |length|. Therefore we allow the keyword |whole| to be used +% instead of a length, indicating that the whole remaining file should +% be read. +% \begin{macrocode} +luacmd('tex_filedump:D', function() + local offset = scan_keyword'offset' and scan_int() or nil + local length = scan_keyword'length' and scan_int() + or not scan_keyword'whole' and 0 or nil + local data = filedump(scan_string(), offset, length) + if data then write(data) end +end, 'global') +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +% +% \end{macrocode} +% +% \begin{macrocode} % % \end{macrocode} % diff --git a/macros/latex/contrib/l3kernel/l3news.pdf b/macros/latex/contrib/l3kernel/l3news.pdf index c33a4eeb9b..85d68ca396 100644 Binary files a/macros/latex/contrib/l3kernel/l3news.pdf and b/macros/latex/contrib/l3kernel/l3news.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news01.pdf b/macros/latex/contrib/l3kernel/l3news01.pdf index 3c03c1e8aa..24fabf8f76 100644 Binary files a/macros/latex/contrib/l3kernel/l3news01.pdf and b/macros/latex/contrib/l3kernel/l3news01.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news02.pdf b/macros/latex/contrib/l3kernel/l3news02.pdf index 837f5d75a7..291ac8d6e2 100644 Binary files a/macros/latex/contrib/l3kernel/l3news02.pdf and b/macros/latex/contrib/l3kernel/l3news02.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news03.pdf b/macros/latex/contrib/l3kernel/l3news03.pdf index 1ff9ae5d1d..9e7dd26e24 100644 Binary files a/macros/latex/contrib/l3kernel/l3news03.pdf and b/macros/latex/contrib/l3kernel/l3news03.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news04.pdf b/macros/latex/contrib/l3kernel/l3news04.pdf index b1338bc9b7..bfb74bced2 100644 Binary files a/macros/latex/contrib/l3kernel/l3news04.pdf and b/macros/latex/contrib/l3kernel/l3news04.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news05.pdf b/macros/latex/contrib/l3kernel/l3news05.pdf index c23deb667e..afcd4e9d36 100644 Binary files a/macros/latex/contrib/l3kernel/l3news05.pdf and b/macros/latex/contrib/l3kernel/l3news05.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news06.pdf b/macros/latex/contrib/l3kernel/l3news06.pdf index 3baec319d1..20cba420c3 100644 Binary files a/macros/latex/contrib/l3kernel/l3news06.pdf and b/macros/latex/contrib/l3kernel/l3news06.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news07.pdf b/macros/latex/contrib/l3kernel/l3news07.pdf index 95a233af7a..09b667c8f3 100644 Binary files a/macros/latex/contrib/l3kernel/l3news07.pdf and b/macros/latex/contrib/l3kernel/l3news07.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news08.pdf b/macros/latex/contrib/l3kernel/l3news08.pdf index b7c4726818..90598b9c33 100644 Binary files a/macros/latex/contrib/l3kernel/l3news08.pdf and b/macros/latex/contrib/l3kernel/l3news08.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news09.pdf b/macros/latex/contrib/l3kernel/l3news09.pdf index ae6753d976..f49ebc28ba 100644 Binary files a/macros/latex/contrib/l3kernel/l3news09.pdf and b/macros/latex/contrib/l3kernel/l3news09.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news10.pdf b/macros/latex/contrib/l3kernel/l3news10.pdf index 2891b8cbf2..636cf07342 100644 Binary files a/macros/latex/contrib/l3kernel/l3news10.pdf and b/macros/latex/contrib/l3kernel/l3news10.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news11.pdf b/macros/latex/contrib/l3kernel/l3news11.pdf index 92eeb57981..62c41629d9 100644 Binary files a/macros/latex/contrib/l3kernel/l3news11.pdf and b/macros/latex/contrib/l3kernel/l3news11.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3news12.pdf b/macros/latex/contrib/l3kernel/l3news12.pdf index e71980d1cf..fe33650fcf 100644 Binary files a/macros/latex/contrib/l3kernel/l3news12.pdf and b/macros/latex/contrib/l3kernel/l3news12.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3prefixes.pdf b/macros/latex/contrib/l3kernel/l3prefixes.pdf index 2e60fc555c..5a97242228 100644 Binary files a/macros/latex/contrib/l3kernel/l3prefixes.pdf and b/macros/latex/contrib/l3kernel/l3prefixes.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3prg.dtx b/macros/latex/contrib/l3kernel/l3prg.dtx index 6003f49343..882e0367af 100644 --- a/macros/latex/contrib/l3kernel/l3prg.dtx +++ b/macros/latex/contrib/l3kernel/l3prg.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3prop.dtx b/macros/latex/contrib/l3kernel/l3prop.dtx index 9125c5ec8e..0f10a77def 100644 --- a/macros/latex/contrib/l3kernel/l3prop.dtx +++ b/macros/latex/contrib/l3kernel/l3prop.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3quark.dtx b/macros/latex/contrib/l3kernel/l3quark.dtx index 8361fa47f2..0251fc2e82 100644 --- a/macros/latex/contrib/l3kernel/l3quark.dtx +++ b/macros/latex/contrib/l3kernel/l3quark.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3regex.dtx b/macros/latex/contrib/l3kernel/l3regex.dtx index faa41bc68a..4d63d5bd80 100644 --- a/macros/latex/contrib/l3kernel/l3regex.dtx +++ b/macros/latex/contrib/l3kernel/l3regex.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3seq.dtx b/macros/latex/contrib/l3kernel/l3seq.dtx index 0201692ebb..63156f66da 100644 --- a/macros/latex/contrib/l3kernel/l3seq.dtx +++ b/macros/latex/contrib/l3kernel/l3seq.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3skip.dtx b/macros/latex/contrib/l3kernel/l3skip.dtx index 3ecd3004d0..d9ea8d1e20 100644 --- a/macros/latex/contrib/l3kernel/l3skip.dtx +++ b/macros/latex/contrib/l3kernel/l3skip.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3sort.dtx b/macros/latex/contrib/l3kernel/l3sort.dtx index 4c981becf9..55471855e0 100644 --- a/macros/latex/contrib/l3kernel/l3sort.dtx +++ b/macros/latex/contrib/l3kernel/l3sort.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3str-convert.dtx b/macros/latex/contrib/l3kernel/l3str-convert.dtx index 324f9f8b92..805a3ebeb3 100644 --- a/macros/latex/contrib/l3kernel/l3str-convert.dtx +++ b/macros/latex/contrib/l3kernel/l3str-convert.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3str.dtx b/macros/latex/contrib/l3kernel/l3str.dtx index 84d2e2d7ae..a7731373d2 100644 --- a/macros/latex/contrib/l3kernel/l3str.dtx +++ b/macros/latex/contrib/l3kernel/l3str.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % @@ -1121,44 +1121,12 @@ % \end{macro} % % \begin{macro}[EXP]{\@@_if_eq:nn} -% \begin{macro}[EXP]{\@@_escape:n} -% String comparisons rely on the primitive \cs[index=pdfstrcmp]{(pdf)strcmp} if available: -% \LuaTeX{} does not have it, so emulation is required. As the net result -% is that we do not \emph{always} use the primitive, the correct approach -% is to wrap up in a function with defined behaviour. That's done by -% providing a wrapper and then redefining in the \LuaTeX{} case. Note that -% the necessary Lua code is loaded in \pkg{l3boostrap}. -% The need to detokenize and force -% expansion of input arises from the case where a |#| token is used in the -% input, \emph{e.g.}~|\__str_if_eq:nn {#} { \tl_to_str:n {#} }|, which -% otherwise would fail as \cs{tex_luaescapestring:D} does not double -% such tokens. +% String comparisons rely on the primitive \cs[index=pdfstrcmp]{(pdf)strcmp}, +% so we define a new name for it. % \begin{macrocode} -\cs_new:Npn \@@_if_eq:nn #1#2 { \tex_strcmp:D {#1} {#2} } -\cs_if_exist:NT \tex_luatexversion:D - { - \cs_set_eq:NN \lua_escape:e \tex_luaescapestring:D - \cs_set_eq:NN \lua_now:e \tex_directlua:D - \cs_set:Npn \@@_if_eq:nn #1#2 - { - \lua_now:e - { - l3kernel.strcmp - ( - " \@@_escape:n {#1} " , - " \@@_escape:n {#2} " - ) - } - } - \cs_new:Npn \@@_escape:n #1 - { - \lua_escape:e - { \__kernel_tl_to_str:w \use:e { {#1} } } - } - } +\cs_new_eq:NN \@@_if_eq:nn \tex_strcmp:D % \end{macrocode} % \end{macro} -% \end{macro} % % \begin{macro}[pTF, EXP] % { diff --git a/macros/latex/contrib/l3kernel/l3styleguide.pdf b/macros/latex/contrib/l3kernel/l3styleguide.pdf index 75a93c51d5..b8ac3f7d17 100644 Binary files a/macros/latex/contrib/l3kernel/l3styleguide.pdf and b/macros/latex/contrib/l3kernel/l3styleguide.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3styleguide.tex b/macros/latex/contrib/l3kernel/l3styleguide.tex index 096b29e3e7..1a16ec70a3 100644 --- a/macros/latex/contrib/l3kernel/l3styleguide.tex +++ b/macros/latex/contrib/l3kernel/l3styleguide.tex @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2020-09-06} +\date{Released 2020-09-24} \begin{document} diff --git a/macros/latex/contrib/l3kernel/l3syntax-changes.pdf b/macros/latex/contrib/l3kernel/l3syntax-changes.pdf index c86eef33d3..6ebb091dee 100644 Binary files a/macros/latex/contrib/l3kernel/l3syntax-changes.pdf and b/macros/latex/contrib/l3kernel/l3syntax-changes.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3syntax-changes.tex b/macros/latex/contrib/l3kernel/l3syntax-changes.tex index ee8f8abed3..f9a7680bf8 100644 --- a/macros/latex/contrib/l3kernel/l3syntax-changes.tex +++ b/macros/latex/contrib/l3kernel/l3syntax-changes.tex @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2020-09-06} +\date{Released 2020-09-24} \newcommand{\TF}{\textit{(TF)}} diff --git a/macros/latex/contrib/l3kernel/l3sys.dtx b/macros/latex/contrib/l3kernel/l3sys.dtx index 9c9b8fa84b..6ca5313c50 100644 --- a/macros/latex/contrib/l3kernel/l3sys.dtx +++ b/macros/latex/contrib/l3kernel/l3sys.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % @@ -317,6 +317,7 @@ % % \begin{macrocode} %<*package> +%<*tex> % \end{macrocode} % % \subsubsection{Detecting the engine} @@ -391,23 +392,26 @@ % however, is reliable only if the user doesn't change % \cs{tex_pdfoutput:D} before loading this code. % \begin{macrocode} -\str_const:Nx \c_sys_engine_exec_str - { - \sys_if_engine_pdftex:T { pdf } - \sys_if_engine_xetex:T { xe } - \sys_if_engine_ptex:T { ep } - \sys_if_engine_uptex:T { eup } - \sys_if_engine_luatex:T - { - lua \lua_now:e - { - if (pcall(require, 'luaharfbuzz')) then ~ - tex.print("hb") ~ - end - } - } - tex - } +\group_begin: + \cs_set_eq:NN \lua_now:e \tex_directlua:D + \str_const:Nx \c_sys_engine_exec_str + { + \sys_if_engine_pdftex:T { pdf } + \sys_if_engine_xetex:T { xe } + \sys_if_engine_ptex:T { ep } + \sys_if_engine_uptex:T { eup } + \sys_if_engine_luatex:T + { + lua \lua_now:e + { + if (pcall(require, 'luaharfbuzz')) then ~ + tex.print("hb") ~ + end + } + } + tex + } +\group_end: \str_const:Nx \c_sys_engine_format_str { \cs_if_exist:NTF \fmtname @@ -647,34 +651,78 @@ % \end{variable} % % \begin{macro}{\sys_shell_now:n} +% \begin{macro}{\@@_shell_now:e} % Execute commands through shell escape immediately. +% +% For \LuaTeX{}, we use a pseudo-primitive to do the actual work. +% \begin{macrocode} +% +%<*lua> +do + local os_exec = os.execute + + local function shellescape(cmd) + local status,msg = os_exec(cmd) + if status == nil then + write_nl("log","runsystem(" .. cmd .. ")...(" .. msg .. ")\n") + elseif status == 0 then + write_nl("log","runsystem(" .. cmd .. ")...executed\n") + else + write_nl("log","runsystem(" .. cmd .. ")...failed " .. (msg or "") .. "\n") + end + end + luacmd("@@_shell_now:e", function() + shellescape(scan_string()) + end, "global", "protected") +% +% \end{macrocode} +% % \begin{macrocode} +%<*tex> \sys_if_engine_luatex:TF { \cs_new_protected:Npn \sys_shell_now:n #1 - { - \lua_now:e - { l3kernel.shellescape(" \lua_escape:e { \tl_to_str:n {#1} } ") } - } + { \@@_shell_now:e { \exp_not:n {#1} } } } { \cs_new_protected:Npn \sys_shell_now:n #1 { \iow_now:Nn \c_@@_shell_stream_int {#1} } } \cs_generate_variant:Nn \sys_shell_now:n { x } +% % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}{\sys_shell_shipout:n} +% \begin{macro}{\@@_shell_shipout:e} % Execute commands through shell escape at shipout. +% +% For \LuaTeX, we use the same helper as above but delayed to using a late_lua whatsit. % \begin{macrocode} +%<*lua> + local whatsit_id = node.id'whatsit' + local latelua_sub = node.subtype'late_lua' + local node_new = node.direct.new + local setfield = node.direct.setwhatsitfield or node.direct.setfield + local node_write = node.direct.write + + luacmd("@@_shell_shipout:e", function() + local cmd = scan_string() + local n = node_new(whatsit_id, latelua_sub) + setfield(n, 'data', function() shellescape(cmd) end) + node_write(n) + end, "global", "protected") +end +% +% \end{macrocode} +% +% \begin{macrocode} +%<*tex> \sys_if_engine_luatex:TF { \cs_new_protected:Npn \sys_shell_shipout:n #1 - { - \lua_shipout_e:n - { l3kernel.shellescape(" \lua_escape:e { \tl_to_str:n {#1} } ") } - } + { \@@_shell_shipout:e { \exp_not:n {#1} } } } { \cs_new_protected:Npn \sys_shell_shipout:n #1 @@ -683,6 +731,7 @@ \cs_generate_variant:Nn \sys_shell_shipout:n { x } % \end{macrocode} % \end{macro} +% \end{macro} % % \subsection{Dynamic (every job) code} % @@ -969,6 +1018,7 @@ % \end{variable} % % \begin{macrocode} +% % % \end{macrocode} % diff --git a/macros/latex/contrib/l3kernel/l3term-glossary.pdf b/macros/latex/contrib/l3kernel/l3term-glossary.pdf index 10cb4d25f8..85f5bc67fd 100644 Binary files a/macros/latex/contrib/l3kernel/l3term-glossary.pdf and b/macros/latex/contrib/l3kernel/l3term-glossary.pdf differ diff --git a/macros/latex/contrib/l3kernel/l3term-glossary.tex b/macros/latex/contrib/l3kernel/l3term-glossary.tex index 59b3a89bbe..140525f76e 100644 --- a/macros/latex/contrib/l3kernel/l3term-glossary.tex +++ b/macros/latex/contrib/l3kernel/l3term-glossary.tex @@ -32,7 +32,7 @@ The released version of this bundle is available from CTAN. {latex-team@latex-project.org}% }% } -\date{Released 2020-09-06} +\date{Released 2020-09-24} \newcommand{\TF}{\textit{(TF)}} diff --git a/macros/latex/contrib/l3kernel/l3text-case.dtx b/macros/latex/contrib/l3kernel/l3text-case.dtx index c44bede9f7..b89de90efd 100644 --- a/macros/latex/contrib/l3kernel/l3text-case.dtx +++ b/macros/latex/contrib/l3kernel/l3text-case.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3text-purify.dtx b/macros/latex/contrib/l3kernel/l3text-purify.dtx index 5b0770e6f3..4833e91f41 100644 --- a/macros/latex/contrib/l3kernel/l3text-purify.dtx +++ b/macros/latex/contrib/l3kernel/l3text-purify.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3text.dtx b/macros/latex/contrib/l3kernel/l3text.dtx index e062326286..325b7f2763 100644 --- a/macros/latex/contrib/l3kernel/l3text.dtx +++ b/macros/latex/contrib/l3kernel/l3text.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3tl-analysis.dtx b/macros/latex/contrib/l3kernel/l3tl-analysis.dtx index 532c514263..55559abdbb 100644 --- a/macros/latex/contrib/l3kernel/l3tl-analysis.dtx +++ b/macros/latex/contrib/l3kernel/l3tl-analysis.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3tl.dtx b/macros/latex/contrib/l3kernel/l3tl.dtx index 095a51d948..7ac12bb127 100644 --- a/macros/latex/contrib/l3kernel/l3tl.dtx +++ b/macros/latex/contrib/l3kernel/l3tl.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % diff --git a/macros/latex/contrib/l3kernel/l3token.dtx b/macros/latex/contrib/l3kernel/l3token.dtx index 473cd48a82..6d3f13581f 100644 --- a/macros/latex/contrib/l3kernel/l3token.dtx +++ b/macros/latex/contrib/l3kernel/l3token.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % @@ -737,12 +737,13 @@ % (not used by \LaTeX3). % \end{function} % -% \begin{function}[updated = 2011-05-23, EXP,pTF]{\token_if_primitive:N} +% \begin{function}[updated = 2020-09-11, EXP,pTF]{\token_if_primitive:N} % \begin{syntax} % \cs{token_if_primitive_p:N} \meta{token} \\ % \cs{token_if_primitive:NTF} \meta{token} \Arg{true code} \Arg{false code} % \end{syntax} -% Tests if the \meta{token} is an engine primitive. +% Tests if the \meta{token} is an engine primitive. In \LuaTeX{} +% this includes primitive-like commands defined using |{token.set_lua}|. % \end{function} % % \section{Peeking ahead at the next token} @@ -1112,6 +1113,10 @@ % \end{macrocode} % % \begin{macrocode} +%<*tex> +% \end{macrocode} +% +% \begin{macrocode} %<@@=char> % \end{macrocode} % @@ -1454,37 +1459,26 @@ \if_int_odd:w 0 \sys_if_engine_luatex:T { 1 } \sys_if_engine_xetex:T { 1 } \exp_stop_f: - \sys_if_engine_luatex:TF - { - \cs_new:Npn \@@_generate_aux:nnw #1#2#3 \exp_end: - { - #3 - \exp_after:wN \exp_after:wN \exp_after:wN \exp_end: - \lua_now:e { l3kernel.charcat(#1, #2) } - } - } - { - \cs_new:Npn \@@_generate_aux:nnw #1#2#3 \exp_end: - { - #3 - \exp_after:wN \exp_end: - \tex_Ucharcat:D #1 \exp_stop_f: #2 \exp_stop_f: - } - \cs_if_exist:NF \tex_expanded:D - { - \cs_new_eq:NN \@@_generate_auxii:nnw \@@_generate_aux:nnw - \cs_gset:Npn \@@_generate_aux:nnw #1#2#3 \exp_end: - { - #3 - \if_int_compare:w #2 = 13 \exp_stop_f: - \__kernel_msg_expandable_error:nn { kernel } { char-active } - \else: - \@@_generate_auxii:nnw {#1} {#2} - \fi: - \exp_end: - } - } - } + \cs_new:Npn \@@_generate_aux:nnw #1#2#3 \exp_end: + { + #3 + \exp_after:wN \exp_end: + \tex_Ucharcat:D #1 \exp_stop_f: #2 \exp_stop_f: + } + \cs_if_exist:NF \tex_expanded:D + { + \cs_new_eq:NN \@@_generate_auxii:nnw \@@_generate_aux:nnw + \cs_gset:Npn \@@_generate_aux:nnw #1#2#3 \exp_end: + { + #3 + \if_int_compare:w #2 = 13 \exp_stop_f: + \__kernel_msg_expandable_error:nn { kernel } { char-active } + \else: + \@@_generate_auxii:nnw {#1} {#2} + \fi: + \exp_end: + } + } \else: % \end{macrocode} % For engines where \tn{Ucharcat} isn't available or emulated, we have @@ -2369,7 +2363,8 @@ % \@@_if_primitive_nullfont:N, % \@@_if_primitive_loop:N, % \@@_if_primitive:Nw, -% \@@_if_primitive_undefined:N} +% \@@_if_primitive_undefined:N, +% \@@_if_primitive_lua:N} %^^A See http://groups.google.com/group/comp.text.tex/browse_thread/thread/0a72666873f8753d# % % We filter out macros first, because they cause endless trouble later @@ -2414,67 +2409,142 @@ % \cs{tex_undefined:D}, and if it is |"| or a digit, then the token % is not a primitive. % +% For \LuaTeX{} we use a different implementation which just looks at the +% command code for the token and compaes it to a list of non-primitives. +% Again, \tn{nullfont} is a special case because it is the only primitive +% with the normally non-primitive |set_font| command code. +% % \begin{macrocode} -\tex_chardef:D \c_@@_A_int = `A ~ % -\use:x +\sys_if_engine_luatex:TF { - \prg_new_conditional:Npnn \exp_not:N \token_if_primitive:N ##1 - { p , T , F , TF } +% +%<*lua> +do + local get_next = token.get_next + local get_command = token.get_command + local get_index = token.get_index + local get_mode = token.get_mode or token.get_index + local cmd = token.command_id + local set_font = cmd'get_font' + local biggest_char = token.biggest_char() + + local mode_below_biggest_char = {} + local index_not_nil = {} + local mode_not_null = {} + local non_primitive = { + [cmd'left_brace'] = true, + [cmd'right_brace'] = true, + [cmd'math_shift'] = true, + [cmd'mac_param'] = mode_below_biggest_char, + [cmd'sup_mark'] = true, + [cmd'sub_mark'] = true, + [cmd'endv'] = true, + [cmd'spacer'] = true, + [cmd'letter'] = true, + [cmd'other_char'] = true, + [cmd'tab_mark'] = mode_below_biggest_char, + [cmd'char_given'] = true, + [cmd'math_given'] = true, + [cmd'xmath_given'] = true, + [cmd'set_font'] = mode_not_null, + [cmd'undefined_cs'] = true, + [cmd'call'] = true, + [cmd'long_call'] = true, + [cmd'outer_call'] = true, + [cmd'long_outer_call'] = true, + [cmd'assign_glue'] = index_not_nil, + [cmd'assign_mu_glue'] = index_not_nil, + [cmd'assign_toks'] = index_not_nil, + [cmd'assign_int'] = index_not_nil, + [cmd'assign_attr'] = true, + [cmd'assign_dimen'] = index_not_nil, + } + + luacmd("@@_if_primitive_lua:N", function() + local tok = get_next() + local is_non_primitive = non_primitive[get_command(tok)] + return put_next( + is_non_primitive == true + and false_tok + or is_non_primitive == nil + and true_tok + or is_non_primitive == mode_not_null + and (get_mode(tok) == 0 and true_tok or false_tok) + or is_non_primitive == index_not_nil + and (get_index(tok) and false_tok or true_tok) + or is_non_primitive == mode_below_biggest_char + and (get_mode(tok) > biggest_char and true_tok or false_tok)) + end, "global") +end +% +%<*tex> + \prg_new_conditional:Npnn \token_if_primitive:N #1 { p , T , F , TF } { - \exp_not:N \token_if_macro:NTF ##1 - \exp_not:N \prg_return_false: - { - \exp_not:N \exp_after:wN \exp_not:N \@@_if_primitive:NNw - \exp_not:N \token_to_meaning:N ##1 - \tl_to_str:n { : : : } \s_@@_stop ##1 - } + \@@_if_primitive_lua:N #1 } - \cs_new:Npn \exp_not:N \@@_if_primitive:NNw - ##1##2 ##3 \c_colon_str ##4 \s_@@_stop + } + { + \tex_chardef:D \c_@@_A_int = `A ~ % + \use:x { - \exp_not:N \tl_if_empty:oTF - { \exp_not:N \@@_if_primitive_space:w ##3 ~ } + \prg_new_conditional:Npnn \exp_not:N \token_if_primitive:N ##1 + { p , T , F , TF } { - \exp_not:N \@@_if_primitive_loop:N ##3 - \c_colon_str \s_@@_stop + \exp_not:N \token_if_macro:NTF ##1 + \exp_not:N \prg_return_false: + { + \exp_not:N \exp_after:wN \exp_not:N \@@_if_primitive:NNw + \exp_not:N \token_to_meaning:N ##1 + \tl_to_str:n { : : : } \s_@@_stop ##1 + } + } + \cs_new:Npn \exp_not:N \@@_if_primitive:NNw + ##1##2 ##3 \c_colon_str ##4 \s_@@_stop + { + \exp_not:N \tl_if_empty:oTF + { \exp_not:N \@@_if_primitive_space:w ##3 ~ } + { + \exp_not:N \@@_if_primitive_loop:N ##3 + \c_colon_str \s_@@_stop + } + { \exp_not:N \@@_if_primitive_nullfont:N } } - { \exp_not:N \@@_if_primitive_nullfont:N } } - } -\cs_new:Npn \@@_if_primitive_space:w #1 ~ { } -\cs_new:Npn \@@_if_primitive_nullfont:N #1 - { - \if_meaning:w \tex_nullfont:D #1 - \prg_return_true: - \else: - \prg_return_false: - \fi: - } -\cs_new:Npn \@@_if_primitive_loop:N #1 - { - \if_int_compare:w `#1 < \c_@@_A_int % - \exp_after:wN \@@_if_primitive:Nw - \exp_after:wN #1 - \else: - \exp_after:wN \@@_if_primitive_loop:N - \fi: - } -\cs_new:Npn \@@_if_primitive:Nw #1 #2 \s_@@_stop - { - \if:w : #1 - \exp_after:wN \@@_if_primitive_undefined:N - \else: - \prg_return_false: - \exp_after:wN \use_none:n - \fi: - } -\cs_new:Npn \@@_if_primitive_undefined:N #1 - { - \if_cs_exist:N #1 - \prg_return_true: - \else: - \prg_return_false: - \fi: + \cs_new:Npn \@@_if_primitive_space:w #1 ~ { } + \cs_new:Npn \@@_if_primitive_nullfont:N #1 + { + \if_meaning:w \tex_nullfont:D #1 + \prg_return_true: + \else: + \prg_return_false: + \fi: + } + \cs_new:Npn \@@_if_primitive_loop:N #1 + { + \if_int_compare:w `#1 < \c_@@_A_int % + \exp_after:wN \@@_if_primitive:Nw + \exp_after:wN #1 + \else: + \exp_after:wN \@@_if_primitive_loop:N + \fi: + } + \cs_new:Npn \@@_if_primitive:Nw #1 #2 \s_@@_stop + { + \if:w : #1 + \exp_after:wN \@@_if_primitive_undefined:N + \else: + \prg_return_false: + \exp_after:wN \use_none:n + \fi: + } + \cs_new:Npn \@@_if_primitive_undefined:N #1 + { + \if_cs_exist:N #1 + \prg_return_true: + \else: + \prg_return_false: + \fi: + } } % \end{macrocode} % \end{macro} @@ -2869,6 +2939,10 @@ % \end{macro} % % \begin{macrocode} +% +% \end{macrocode} +% +% \begin{macrocode} % % \end{macrocode} % diff --git a/macros/latex/contrib/l3kernel/l3unicode.dtx b/macros/latex/contrib/l3kernel/l3unicode.dtx index 4b024350af..3cc420f68f 100644 --- a/macros/latex/contrib/l3kernel/l3unicode.dtx +++ b/macros/latex/contrib/l3kernel/l3unicode.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-09-06} +% \date{Released 2020-09-24} % % \maketitle % @@ -97,22 +97,9 @@ { \exp_not:N \tex_unexpanded:D \exp_not:N \exp_after:wN { - \sys_if_engine_luatex:TF - { - \exp_not:N \tex_directlua:D - { - l3kernel.charcat - ( - \exp_not:N \tex_number:D #1 , - \exp_not:N \tex_the:D \tex_catcode:D #1 - ) - } - } - { - \exp_not:N \tex_Ucharcat:D - #1 ~ - \tex_catcode:D #1 ~ - } + \exp_not:N \tex_Ucharcat:D + #1 ~ + \tex_catcode:D #1 ~ } } % \end{macrocode} diff --git a/macros/latex/contrib/l3kernel/source3.pdf b/macros/latex/contrib/l3kernel/source3.pdf index cf1f926b77..7994f7f8cf 100644 Binary files a/macros/latex/contrib/l3kernel/source3.pdf and b/macros/latex/contrib/l3kernel/source3.pdf differ diff --git a/macros/latex/contrib/l3kernel/source3.tex b/macros/latex/contrib/l3kernel/source3.tex index 33b5ecbb45..9ae358c63f 100644 --- a/macros/latex/contrib/l3kernel/source3.tex +++ b/macros/latex/contrib/l3kernel/source3.tex @@ -53,7 +53,7 @@ for those people who are interested. {latex-team@latex-project.org}% }% } -\date{Released 2020-09-06} +\date{Released 2020-09-24} \pagenumbering{roman} \maketitle -- cgit v1.2.3