[latex3-commits] [git/LaTeX3-latex3-latex3] master: Alternative approach to getting \char_generate:nn right (071c4d3)
Joseph Wright
joseph.wright at morningstar2.co.uk
Fri Apr 20 11:19:41 CEST 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/071c4d3c40ac1ef0d5c307a26f92159512bb35b6
>---------------------------------------------------------------
commit 071c4d3c40ac1ef0d5c307a26f92159512bb35b6
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Fri Apr 20 10:19:41 2018 +0100
Alternative approach to getting \char_generate:nn right
>---------------------------------------------------------------
071c4d3c40ac1ef0d5c307a26f92159512bb35b6
l3kernel/l3luatex.dtx | 42 ++++++++++++++++++++++---------
l3kernel/l3str.dtx | 4 +--
l3kernel/l3token.dtx | 2 +-
l3kernel/testfiles/m3expl001.luatex.tlg | 9 ++++---
l3kernel/testfiles/m3expl001.ptex.tlg | 7 +++++-
l3kernel/testfiles/m3expl001.tlg | 7 +++++-
l3kernel/testfiles/m3expl001.uptex.tlg | 7 +++++-
l3kernel/testfiles/m3expl001.xetex.tlg | 7 +++++-
l3kernel/testfiles/m3expl003.luatex.tlg | 9 ++++---
l3kernel/testfiles/m3expl003.ptex.tlg | 7 +++++-
l3kernel/testfiles/m3expl003.tlg | 7 +++++-
l3kernel/testfiles/m3expl003.uptex.tlg | 7 +++++-
l3kernel/testfiles/m3expl003.xetex.tlg | 7 +++++-
13 files changed, 93 insertions(+), 29 deletions(-)
diff --git a/l3kernel/l3luatex.dtx b/l3kernel/l3luatex.dtx
index 11102fc..035156a 100644
--- a/l3kernel/l3luatex.dtx
+++ b/l3kernel/l3luatex.dtx
@@ -58,8 +58,7 @@
%
% \subsection{\TeX{} code interfaces}
%
-% \begin{function}[EXP, added = 2015-06-29, updated = 2018-04-19]
-% {\lua_now_x:n, \lua_now:n}
+% \begin{function}[EXP, added = 2015-06-29]{\lua_now_x:n, \lua_now:n}
% \begin{syntax}
% \cs{lua_now:n} \Arg{token list}
% \end{syntax}
@@ -75,8 +74,9 @@
% by \TeX{} in an \texttt{x}-type manner \emph{but} the function remains
% fully expandable.
% \begin{texnote}
-% \cs{lua_now_x:n} is the primitive \tn{directlua}, and thus
-% acts in one expansion.
+% \cs{lua_now_x:n} is a macro wrapper around \tn{directlua}: when
+% \LuaTeX{} is in use two expansions are required to yield the
+% result of the \Lua{} code.
% \end{texnote}
% \end{function}
%
@@ -103,8 +103,7 @@
% \end{texnote}
% \end{function}
%
-% \begin{function}[EXP, added = 2015-06-29, updated = 2018-04-19]
-% {\lua_escape_x:n, \lua_escape:n}
+% \begin{function}[EXP, added = 2015-06-29]{\lua_escape_x:n, \lua_escape:n}
% \begin{syntax}
% \cs{lua_escape:n} \Arg{token list}
% \end{syntax}
@@ -118,8 +117,9 @@
% by \TeX{} in an \texttt{x}-type manner \emph{but} the function remains
% fully expandable.
% \begin{texnote}
-% \cs{lua_escape_x:n} is the primitive \tn{luaescapestring}, and thus
-% acts in one expansion.
+% \cs{lua_escape_x:n} is a macro wrapper around \tn{luaescapestring}:
+% when \LuaTeX{} is in use two expansions are required to yield the
+% result of the \Lua{} code.
% \end{texnote}
% \end{function}
%
@@ -193,17 +193,35 @@
%<@@=luatex>
% \end{macrocode}
%
+% \begin{macro}[EXP]{\@@_escape_x:n, \@@_now_x:n, \@@_shipout_x:n}
+% Copies of primitives.
+% \begin{macrocode}
+\cs_new_eq:NN \@@_escape_x:n \luatex_luaescapestring:D
+\cs_new_eq:NN \@@_now_x:n \luatex_directlua:D
+\cs_new_eq:NN \@@_shipout_x:n \luatex_latelua:D
+% \end{macrocode}
+% \end{macro}
+%
+% These functions are set up in \pkg{l3str} for bootstrapping: we want to
+% replace them with a \enquote{proper} version at this stage, so clean up.
+% \begin{macrocode}
+\cs_undefine:N \lua_escape_x:n
+\cs_undefine:N \lua_now_x:n
+% \end{macrocode}
+%
% \begin{macro}[EXP]{\lua_now_x:n, \lua_now:n}
% \begin{macro}{\lua_shipout_x:n, \lua_shipout:n}
% \begin{macro}[EXP]{\lua_escape_x:n, \lua_escape:n}
-% Primitives or equivalent wrappers. Note that \cs{lua_escape_x:n}
-% and \cs{lua_now_x:n} are covered in \pkg{l3str} (for bootstrapping
-% purposes).
+% Wrappers around the primitives. As with engines other than \LuaTeX{}
+% these have to be macros, we give them the same status in all cases.
+% When \LuaTeX{} is not in use, simply give an error message/
% \begin{macrocode}
-\cs_new_eq:NN \lua_shipout_x:n \luatex_latelua:D
+\cs_new:Npn \lua_now_x:n #1 { \@@_now_x:n {#1} }
\cs_new:Npn \lua_now:n #1 { \lua_now_x:n { \exp_not:n {#1} } }
+\cs_new_protected:Npn \lua_shipout_x:n #1 { \@@_shiphout_x:n {#1} }
\cs_new_protected:Npn \lua_shipout:n #1
{ \lua_shipout_x:n { \exp_not:n {#1} } }
+\cs_new:Npn \lua_escape_x:n #1 { \@@_escape_x:n {#1} }
\cs_new:Npn \lua_escape:n #1 { \lua_escape_x:n { \exp_not:n {#1} } }
\sys_if_engine_luatex:F
{
diff --git a/l3kernel/l3str.dtx b/l3kernel/l3str.dtx
index a307e1f..c1e969a 100644
--- a/l3kernel/l3str.dtx
+++ b/l3kernel/l3str.dtx
@@ -1039,8 +1039,8 @@
\cs_new:Npn \@@_if_eq_x:nn #1#2 { \pdftex_strcmp:D {#1} {#2} }
\cs_if_exist:NT \luatex_luatexversion:D
{
- \cs_new_eq:NN \lua_escape_x:n \luatex_luaescapestring:D
- \cs_new_eq:NN \lua_now_x:n \luatex_directlua:D
+ \cs_set_eq:NN \lua_escape_x:n \luatex_luaescapestring:D
+ \cs_set_eq:NN \lua_now_x:n \luatex_directlua:D
\cs_set:Npn \@@_if_eq_x:nn #1#2
{
\lua_now_x:n
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index 5db4438..09d8294 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -1434,7 +1434,7 @@
{
#3
\exp_after:wN \exp_end:
- \lua_now_x:n { l3kernel.charcat(#1, #2) }
+ \use_x:n { \lua_now_x:n { l3kernel.charcat(#1, #2) } }
}
}
{
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 14f5a23..5730d37 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -717,8 +717,6 @@ Defining \str_if_empty:cT on line ...
Defining \str_if_empty:cF on line ...
Defining \str_if_empty:cTF on line ...
Defining \__str_if_eq_x:nn on line ...
-Defining \lua_escape_x:n on line ...
-Defining \lua_now_x:n on line ...
Defining \__str_escape_x:n on line ...
Defining \str_if_eq_p:nn on line ...
Defining \str_if_eq:nnT on line ...
@@ -5247,9 +5245,14 @@ Defining \sys_if_output_pdf:F on line ...
Defining \sys_if_output_pdf:TF on line ...
Defining \sys_if_output_pdf_p: on line ...
Defining \c_sys_output_str on line ...
-Defining \lua_shipout_x:n on line ...
+Defining \__luatex_escape_x:n on line ...
+Defining \__luatex_now_x:n on line ...
+Defining \__luatex_shipout_x:n on line ...
+Defining \lua_now_x:n on line ...
Defining \lua_now:n on line ...
+Defining \lua_shipout_x:n on line ...
Defining \lua_shipout:n on line ...
+Defining \lua_escape_x:n on line ...
Defining \lua_escape:n on line ...
Defining message LaTeX/kernel/luatex-required on line ...
Defining \g__char_data_ior on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 810057e..4553dfb 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5501,9 +5501,14 @@ Defining \sys_if_output_pdf:F on line ...
Defining \sys_if_output_pdf:TF on line ...
Defining \sys_if_output_pdf_p: on line ...
Defining \c_sys_output_str on line ...
-Defining \lua_shipout_x:n on line ...
+Defining \__luatex_escape_x:n on line ...
+Defining \__luatex_now_x:n on line ...
+Defining \__luatex_shipout_x:n on line ...
+Defining \lua_now_x:n on line ...
Defining \lua_now:n on line ...
+Defining \lua_shipout_x:n on line ...
Defining \lua_shipout:n on line ...
+Defining \lua_escape_x:n on line ...
Defining \lua_escape:n on line ...
Defining message LaTeX/kernel/luatex-required on line ...
Defining \g__char_data_ior on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index fe9edd3..649098b 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -5501,9 +5501,14 @@ Defining \sys_if_output_pdf:F on line ...
Defining \sys_if_output_pdf:TF on line ...
Defining \sys_if_output_pdf_p: on line ...
Defining \c_sys_output_str on line ...
-Defining \lua_shipout_x:n on line ...
+Defining \__luatex_escape_x:n on line ...
+Defining \__luatex_now_x:n on line ...
+Defining \__luatex_shipout_x:n on line ...
+Defining \lua_now_x:n on line ...
Defining \lua_now:n on line ...
+Defining \lua_shipout_x:n on line ...
Defining \lua_shipout:n on line ...
+Defining \lua_escape_x:n on line ...
Defining \lua_escape:n on line ...
Defining message LaTeX/kernel/luatex-required on line ...
Defining \g__char_data_ior on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index a0fd59d..67813b1 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -5499,9 +5499,14 @@ Defining \sys_if_output_pdf:F on line ...
Defining \sys_if_output_pdf:TF on line ...
Defining \sys_if_output_pdf_p: on line ...
Defining \c_sys_output_str on line ...
-Defining \lua_shipout_x:n on line ...
+Defining \__luatex_escape_x:n on line ...
+Defining \__luatex_now_x:n on line ...
+Defining \__luatex_shipout_x:n on line ...
+Defining \lua_now_x:n on line ...
Defining \lua_now:n on line ...
+Defining \lua_shipout_x:n on line ...
Defining \lua_shipout:n on line ...
+Defining \lua_escape_x:n on line ...
Defining \lua_escape:n on line ...
Defining message LaTeX/kernel/luatex-required on line ...
Defining \g__char_data_ior on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index ad9bb18..871cece 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5219,9 +5219,14 @@ Defining \sys_if_output_pdf:F on line ...
Defining \sys_if_output_pdf:TF on line ...
Defining \sys_if_output_pdf_p: on line ...
Defining \c_sys_output_str on line ...
-Defining \lua_shipout_x:n on line ...
+Defining \__luatex_escape_x:n on line ...
+Defining \__luatex_now_x:n on line ...
+Defining \__luatex_shipout_x:n on line ...
+Defining \lua_now_x:n on line ...
Defining \lua_now:n on line ...
+Defining \lua_shipout_x:n on line ...
Defining \lua_shipout:n on line ...
+Defining \lua_escape_x:n on line ...
Defining \lua_escape:n on line ...
Defining message LaTeX/kernel/luatex-required on line ...
Defining \g__char_data_ior on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 14f5a23..5730d37 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -717,8 +717,6 @@ Defining \str_if_empty:cT on line ...
Defining \str_if_empty:cF on line ...
Defining \str_if_empty:cTF on line ...
Defining \__str_if_eq_x:nn on line ...
-Defining \lua_escape_x:n on line ...
-Defining \lua_now_x:n on line ...
Defining \__str_escape_x:n on line ...
Defining \str_if_eq_p:nn on line ...
Defining \str_if_eq:nnT on line ...
@@ -5247,9 +5245,14 @@ Defining \sys_if_output_pdf:F on line ...
Defining \sys_if_output_pdf:TF on line ...
Defining \sys_if_output_pdf_p: on line ...
Defining \c_sys_output_str on line ...
-Defining \lua_shipout_x:n on line ...
+Defining \__luatex_escape_x:n on line ...
+Defining \__luatex_now_x:n on line ...
+Defining \__luatex_shipout_x:n on line ...
+Defining \lua_now_x:n on line ...
Defining \lua_now:n on line ...
+Defining \lua_shipout_x:n on line ...
Defining \lua_shipout:n on line ...
+Defining \lua_escape_x:n on line ...
Defining \lua_escape:n on line ...
Defining message LaTeX/kernel/luatex-required on line ...
Defining \g__char_data_ior on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 810057e..4553dfb 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5501,9 +5501,14 @@ Defining \sys_if_output_pdf:F on line ...
Defining \sys_if_output_pdf:TF on line ...
Defining \sys_if_output_pdf_p: on line ...
Defining \c_sys_output_str on line ...
-Defining \lua_shipout_x:n on line ...
+Defining \__luatex_escape_x:n on line ...
+Defining \__luatex_now_x:n on line ...
+Defining \__luatex_shipout_x:n on line ...
+Defining \lua_now_x:n on line ...
Defining \lua_now:n on line ...
+Defining \lua_shipout_x:n on line ...
Defining \lua_shipout:n on line ...
+Defining \lua_escape_x:n on line ...
Defining \lua_escape:n on line ...
Defining message LaTeX/kernel/luatex-required on line ...
Defining \g__char_data_ior on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index fe9edd3..649098b 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -5501,9 +5501,14 @@ Defining \sys_if_output_pdf:F on line ...
Defining \sys_if_output_pdf:TF on line ...
Defining \sys_if_output_pdf_p: on line ...
Defining \c_sys_output_str on line ...
-Defining \lua_shipout_x:n on line ...
+Defining \__luatex_escape_x:n on line ...
+Defining \__luatex_now_x:n on line ...
+Defining \__luatex_shipout_x:n on line ...
+Defining \lua_now_x:n on line ...
Defining \lua_now:n on line ...
+Defining \lua_shipout_x:n on line ...
Defining \lua_shipout:n on line ...
+Defining \lua_escape_x:n on line ...
Defining \lua_escape:n on line ...
Defining message LaTeX/kernel/luatex-required on line ...
Defining \g__char_data_ior on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index a0fd59d..67813b1 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -5499,9 +5499,14 @@ Defining \sys_if_output_pdf:F on line ...
Defining \sys_if_output_pdf:TF on line ...
Defining \sys_if_output_pdf_p: on line ...
Defining \c_sys_output_str on line ...
-Defining \lua_shipout_x:n on line ...
+Defining \__luatex_escape_x:n on line ...
+Defining \__luatex_now_x:n on line ...
+Defining \__luatex_shipout_x:n on line ...
+Defining \lua_now_x:n on line ...
Defining \lua_now:n on line ...
+Defining \lua_shipout_x:n on line ...
Defining \lua_shipout:n on line ...
+Defining \lua_escape_x:n on line ...
Defining \lua_escape:n on line ...
Defining message LaTeX/kernel/luatex-required on line ...
Defining \g__char_data_ior on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index ad9bb18..871cece 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5219,9 +5219,14 @@ Defining \sys_if_output_pdf:F on line ...
Defining \sys_if_output_pdf:TF on line ...
Defining \sys_if_output_pdf_p: on line ...
Defining \c_sys_output_str on line ...
-Defining \lua_shipout_x:n on line ...
+Defining \__luatex_escape_x:n on line ...
+Defining \__luatex_now_x:n on line ...
+Defining \__luatex_shipout_x:n on line ...
+Defining \lua_now_x:n on line ...
Defining \lua_now:n on line ...
+Defining \lua_shipout_x:n on line ...
Defining \lua_shipout:n on line ...
+Defining \lua_escape_x:n on line ...
Defining \lua_escape:n on line ...
Defining message LaTeX/kernel/luatex-required on line ...
Defining \g__char_data_ior on line ...
More information about the latex3-commits
mailing list