[latex3-commits] [git/LaTeX3-latex3-latex3] spaces: Support space tokens in \char_generate:nn (fddb67ea3)

Marcel Fabian Krüger tex at 2krueger.de
Sat Mar 26 21:24:02 CET 2022


Repository : https://github.com/latex3/latex3
On branch  : spaces
Link       : https://github.com/latex3/latex3/commit/fddb67ea3245ddca3e7a782466d3f0a2545543ae

>---------------------------------------------------------------

commit fddb67ea3245ddca3e7a782466d3f0a2545543ae
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Sat Mar 26 21:24:02 2022 +0100

    Support space tokens in \char_generate:nn


>---------------------------------------------------------------

fddb67ea3245ddca3e7a782466d3f0a2545543ae
 l3kernel/l3luatex.dtx                   |  1 +
 l3kernel/l3msg.dtx                      |  2 --
 l3kernel/l3names.dtx                    | 17 +++++++++-----
 l3kernel/l3token.dtx                    | 10 ++++-----
 l3kernel/testfiles/m3char001.luatex.tlg | 40 +++++++++++++++++++++++++--------
 l3kernel/testfiles/m3char001.lvt        |  8 +++++--
 l3kernel/testfiles/m3char001.ptex.tlg   | 40 +++++++++++++++++++++++++--------
 l3kernel/testfiles/m3char001.tlg        | 40 +++++++++++++++++++++++++--------
 l3kernel/testfiles/m3char001.uptex.tlg  | 40 +++++++++++++++++++++++++--------
 l3kernel/testfiles/m3char001.xetex.tlg  | 40 +++++++++++++++++++++++++--------
 10 files changed, 177 insertions(+), 61 deletions(-)

diff --git a/l3kernel/l3luatex.dtx b/l3kernel/l3luatex.dtx
index 456a02293..36e8b79d8 100644
--- a/l3kernel/l3luatex.dtx
+++ b/l3kernel/l3luatex.dtx
@@ -317,6 +317,7 @@ local scan_string  = token.scan_string
 local scan_keyword = token.scan_keyword
 local put_next     = token.put_next
 local token_create = token.create
+local token_new    = token.new
 %    \end{macrocode}
 %
 %   Since token.create only returns useful values after the tokens
diff --git a/l3kernel/l3msg.dtx b/l3kernel/l3msg.dtx
index 23add4a7c..94ca08790 100644
--- a/l3kernel/l3msg.dtx
+++ b/l3kernel/l3msg.dtx
@@ -1854,8 +1854,6 @@
   { Cannot~generate~null~char~as~a~space. }
 \msg_new:nnn { char } { out-of-range }
   { Charcode~requested~out~of~engine~range. }
-\msg_new:nnn { char } { space }
-  { Cannot~generate~space~chars. }
 \msg_new:nnnn { ior } { quote-in-shell }
   { Quotes~in~shell~command~'#1'. }
   { Shell~commands~cannot~contain~quotes~("). }
diff --git a/l3kernel/l3names.dtx b/l3kernel/l3names.dtx
index f330647e3..ceb599518 100644
--- a/l3kernel/l3names.dtx
+++ b/l3kernel/l3names.dtx
@@ -1470,9 +1470,9 @@
 %   Here \enquote{smaller} refers to codepoint order which does not correspond to
 %   the user expected order for most non-ASCII strings.
 %    \begin{macrocode}
-local minus_tok = token.new(string.byte'-', 12)
-local zero_tok = token.new(string.byte'0', 12)
-local one_tok = token.new(string.byte'1', 12)
+local minus_tok = token_new(string.byte'-', 12)
+local zero_tok = token_new(string.byte'0', 12)
+local one_tok = token_new(string.byte'1', 12)
 luacmd('tex_strcmp:D', function()
   local first = scan_string()
   local second = scan_string()
@@ -1487,14 +1487,19 @@ end, 'global')
 %
 % \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.
+%   The alternative approach using |token.new(...)| is about 10\% slower
+%   but needed to create arbitrary space tokens.
 %    \begin{macrocode}
+local sprint = tex.sprint
 local cprint = tex.cprint
 luacmd('tex_Ucharcat:D', function()
   local charcode = scan_int()
   local catcode = scan_int()
-  cprint(catcode, utf8_char(charcode))
+  if catcode == 10 then
+    sprint(token_new(charcode, 10))
+  else
+    cprint(catcode, utf8_char(charcode))
+  end
 end, 'global')
 %    \end{macrocode}
 % \end{macro}
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index 909dff2b7..275d5cc62 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -1527,12 +1527,10 @@
 %    \begin{macrocode}
 \cs_new:Npn \@@_generate_aux:w #1 ; #2 ;
   {
-    \if_int_compare:w #2 = 10 \exp_stop_f:
-      \if_int_compare:w #1 =  \c_zero_int
-        \msg_expandable_error:nn { char } { null-space }
-      \else:
-        \msg_expandable_error:nn { char } { space }
-      \fi:
+    \if_int_odd:w 1
+        \if_int_compare:w #2 = 10 \exp_stop_f: \else: 0 \fi:
+        \if_int_compare:w #1 = \c_zero_int     \else: 0 \fi: \exp_stop_f:
+      \msg_expandable_error:nn { char } { null-space }
     \else:
       \if_int_odd:w 0
           \if_int_compare:w #2 < 1  \exp_stop_f: 1 \fi:
diff --git a/l3kernel/testfiles/m3char001.luatex.tlg b/l3kernel/testfiles/m3char001.luatex.tlg
index 68e34c81e..9e4cdefd6 100644
--- a/l3kernel/testfiles/m3char001.luatex.tlg
+++ b/l3kernel/testfiles/m3char001.luatex.tlg
@@ -78,7 +78,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 2: Generate 7-bit alignment and math tokens
+TEST 2: Generate 7-bit alignment and math and space tokens
 ============================================================
 > \l_tmpa_tl=^^@.
 <recently read> }
@@ -224,6 +224,36 @@ l. ...  }
 > subscript character ^^?.
 \l_tmpa_tl ->^^?
 l. ...  }
+> \l_tmpa_tl=^^L.
+<recently read> }
+l. ...  }
+> blank space ^^L.
+\l_tmpa_tl ->^^L
+l. ...  }
+> \l_tmpa_tl= .
+<recently read> }
+l. ...  }
+> blank space  .
+\l_tmpa_tl -> 
+l. ...  }
+> \l_tmpa_tl=@.
+<recently read> }
+l. ...  }
+> blank space @.
+\l_tmpa_tl ->@
+l. ...  }
+> \l_tmpa_tl=P.
+<recently read> }
+l. ...  }
+> blank space P.
+\l_tmpa_tl ->P
+l. ...  }
+> \l_tmpa_tl=^^?.
+<recently read> }
+l. ...  }
+> blank space ^^?.
+\l_tmpa_tl ->^^?
+l. ...  }
 ============================================================
 ============================================================
 TEST 3: Generate 7-bit awkward
@@ -350,14 +380,6 @@ If you say, e.g., `\def\a1{...}', then you must always
 put `1' after `\a', since control sequence names are
 made up of letters only. The macro here has not been
 followed by the required stuff, so I'm ignoring it.
-! Use of \??? doesn't match its definition.
-<argument> \???  
-      ! LaTeX3 Error: Cannot generate space chars.
-l. ...  }
-If you say, e.g., `\def\a1{...}', then you must always
-put `1' after `\a', since control sequence names are
-made up of letters only. The macro here has not been
-followed by the required stuff, so I'm ignoring it.
 ! Undefined control sequence.
 l. ...@
 l. ...  }
diff --git a/l3kernel/testfiles/m3char001.lvt b/l3kernel/testfiles/m3char001.lvt
index 7badcd0ca..26f9fdf70 100644
--- a/l3kernel/testfiles/m3char001.lvt
+++ b/l3kernel/testfiles/m3char001.lvt
@@ -52,7 +52,7 @@
     \test:nn { 127 }  { 12 }
   }
 
-\TEST { Generate~7-bit~alignment~and~math~tokens }
+\TEST { Generate~7-bit~alignment~and~math~and~space~tokens }
   {
     \test:nn { 0 }    { 3 }
     \test:nn { 12 }   { 3 }
@@ -78,6 +78,11 @@
     \test:nn { 64 }   { 8 }
     \test:nn { 80 }   { 8 }
     \test:nn { 127 }  { 8 }
+    \test:nn { 12 }   { 10 }
+    \test:nn { 32 }   { 10 }
+    \test:nn { 64 }   { 10 }
+    \test:nn { 80 }   { 10 }
+    \test:nn { 127 }  { 10 }
   }
 
 \TEST { Generate~7-bit~awkward }
@@ -105,7 +110,6 @@
     \char_generate:nn { 64 } { 0 }
     \char_generate:nn { 64 } { 5 }
     \char_generate:nn { 64 } { 9 }
-    \char_generate:nn { 64 } { 10 }
     \char_generate:nn { 64 } { 13 }
     \char_generate:nn { 64 } { 14 }
     \char_generate:nn { 64 } { 15 }
diff --git a/l3kernel/testfiles/m3char001.ptex.tlg b/l3kernel/testfiles/m3char001.ptex.tlg
index 93c27477c..41b7f00ac 100644
--- a/l3kernel/testfiles/m3char001.ptex.tlg
+++ b/l3kernel/testfiles/m3char001.ptex.tlg
@@ -78,7 +78,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 2: Generate 7-bit alignment and math tokens
+TEST 2: Generate 7-bit alignment and math and space tokens
 ============================================================
 > \l_tmpa_tl=^^@.
 <recently read> }
@@ -224,6 +224,36 @@ l. ...  }
 > subscript character ^^?.
 \l_tmpa_tl ->^^?
 l. ...  }
+> \l_tmpa_tl=^^L.
+<recently read> }
+l. ...  }
+> blank space ^^L.
+\l_tmpa_tl ->^^L
+l. ...  }
+> \l_tmpa_tl= .
+<recently read> }
+l. ...  }
+> blank space  .
+\l_tmpa_tl -> 
+l. ...  }
+> \l_tmpa_tl=@.
+<recently read> }
+l. ...  }
+> blank space @.
+\l_tmpa_tl ->@
+l. ...  }
+> \l_tmpa_tl=P.
+<recently read> }
+l. ...  }
+> blank space P.
+\l_tmpa_tl ->P
+l. ...  }
+> \l_tmpa_tl=^^?.
+<recently read> }
+l. ...  }
+> blank space ^^?.
+\l_tmpa_tl ->^^?
+l. ...  }
 ============================================================
 ============================================================
 TEST 3: Generate 7-bit awkward
@@ -350,14 +380,6 @@ If you say, e.g., `\def\a1{...}', then you must always
 put `1' after `\a', since control sequence names are
 made up of letters only. The macro here has not been
 followed by the required stuff, so I'm ignoring it.
-! Use of \??? doesn't match its definition.
-<argument> \???  
-                 ! LaTeX3 Error: Cannot generate space chars.
-l. ...  }
-If you say, e.g., `\def\a1{...}', then you must always
-put `1' after `\a', since control sequence names are
-made up of letters only. The macro here has not been
-followed by the required stuff, so I'm ignoring it.
 ! Undefined control sequence.
 <recently read> @
 l. ...  }
diff --git a/l3kernel/testfiles/m3char001.tlg b/l3kernel/testfiles/m3char001.tlg
index fca0db0c5..264cb5252 100644
--- a/l3kernel/testfiles/m3char001.tlg
+++ b/l3kernel/testfiles/m3char001.tlg
@@ -78,7 +78,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 2: Generate 7-bit alignment and math tokens
+TEST 2: Generate 7-bit alignment and math and space tokens
 ============================================================
 > \l_tmpa_tl=^^@.
 <recently read> }
@@ -224,6 +224,36 @@ l. ...  }
 > subscript character ^^?.
 \l_tmpa_tl ->^^?
 l. ...  }
+> \l_tmpa_tl=^^L.
+<recently read> }
+l. ...  }
+> blank space ^^L.
+\l_tmpa_tl ->^^L
+l. ...  }
+> \l_tmpa_tl= .
+<recently read> }
+l. ...  }
+> blank space  .
+\l_tmpa_tl -> 
+l. ...  }
+> \l_tmpa_tl=@.
+<recently read> }
+l. ...  }
+> blank space @.
+\l_tmpa_tl ->@
+l. ...  }
+> \l_tmpa_tl=P.
+<recently read> }
+l. ...  }
+> blank space P.
+\l_tmpa_tl ->P
+l. ...  }
+> \l_tmpa_tl=^^?.
+<recently read> }
+l. ...  }
+> blank space ^^?.
+\l_tmpa_tl ->^^?
+l. ...  }
 ============================================================
 ============================================================
 TEST 3: Generate 7-bit awkward
@@ -350,14 +380,6 @@ If you say, e.g., `\def\a1{...}', then you must always
 put `1' after `\a', since control sequence names are
 made up of letters only. The macro here has not been
 followed by the required stuff, so I'm ignoring it.
-! Use of \??? doesn't match its definition.
-<argument> \???  
-                 ! LaTeX3 Error: Cannot generate space chars.
-l. ...  }
-If you say, e.g., `\def\a1{...}', then you must always
-put `1' after `\a', since control sequence names are
-made up of letters only. The macro here has not been
-followed by the required stuff, so I'm ignoring it.
 ! Undefined control sequence.
 <recently read> @
 l. ...  }
diff --git a/l3kernel/testfiles/m3char001.uptex.tlg b/l3kernel/testfiles/m3char001.uptex.tlg
index 93c27477c..41b7f00ac 100644
--- a/l3kernel/testfiles/m3char001.uptex.tlg
+++ b/l3kernel/testfiles/m3char001.uptex.tlg
@@ -78,7 +78,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 2: Generate 7-bit alignment and math tokens
+TEST 2: Generate 7-bit alignment and math and space tokens
 ============================================================
 > \l_tmpa_tl=^^@.
 <recently read> }
@@ -224,6 +224,36 @@ l. ...  }
 > subscript character ^^?.
 \l_tmpa_tl ->^^?
 l. ...  }
+> \l_tmpa_tl=^^L.
+<recently read> }
+l. ...  }
+> blank space ^^L.
+\l_tmpa_tl ->^^L
+l. ...  }
+> \l_tmpa_tl= .
+<recently read> }
+l. ...  }
+> blank space  .
+\l_tmpa_tl -> 
+l. ...  }
+> \l_tmpa_tl=@.
+<recently read> }
+l. ...  }
+> blank space @.
+\l_tmpa_tl ->@
+l. ...  }
+> \l_tmpa_tl=P.
+<recently read> }
+l. ...  }
+> blank space P.
+\l_tmpa_tl ->P
+l. ...  }
+> \l_tmpa_tl=^^?.
+<recently read> }
+l. ...  }
+> blank space ^^?.
+\l_tmpa_tl ->^^?
+l. ...  }
 ============================================================
 ============================================================
 TEST 3: Generate 7-bit awkward
@@ -350,14 +380,6 @@ If you say, e.g., `\def\a1{...}', then you must always
 put `1' after `\a', since control sequence names are
 made up of letters only. The macro here has not been
 followed by the required stuff, so I'm ignoring it.
-! Use of \??? doesn't match its definition.
-<argument> \???  
-                 ! LaTeX3 Error: Cannot generate space chars.
-l. ...  }
-If you say, e.g., `\def\a1{...}', then you must always
-put `1' after `\a', since control sequence names are
-made up of letters only. The macro here has not been
-followed by the required stuff, so I'm ignoring it.
 ! Undefined control sequence.
 <recently read> @
 l. ...  }
diff --git a/l3kernel/testfiles/m3char001.xetex.tlg b/l3kernel/testfiles/m3char001.xetex.tlg
index cc836e26a..01e578476 100644
--- a/l3kernel/testfiles/m3char001.xetex.tlg
+++ b/l3kernel/testfiles/m3char001.xetex.tlg
@@ -78,7 +78,7 @@ l. ...  }
 l. ...  }
 ============================================================
 ============================================================
-TEST 2: Generate 7-bit alignment and math tokens
+TEST 2: Generate 7-bit alignment and math and space tokens
 ============================================================
 > \l_tmpa_tl=^^@.
 <recently read> }
@@ -224,6 +224,36 @@ l. ...  }
 > subscript character ^^?.
 \l_tmpa_tl ->^^?
 l. ...  }
+> \l_tmpa_tl=^^L.
+<recently read> }
+l. ...  }
+> blank space ^^L.
+\l_tmpa_tl ->^^L
+l. ...  }
+> \l_tmpa_tl= .
+<recently read> }
+l. ...  }
+> blank space  .
+\l_tmpa_tl -> 
+l. ...  }
+> \l_tmpa_tl=@.
+<recently read> }
+l. ...  }
+> blank space @.
+\l_tmpa_tl ->@
+l. ...  }
+> \l_tmpa_tl=P.
+<recently read> }
+l. ...  }
+> blank space P.
+\l_tmpa_tl ->P
+l. ...  }
+> \l_tmpa_tl=^^?.
+<recently read> }
+l. ...  }
+> blank space ^^?.
+\l_tmpa_tl ->^^?
+l. ...  }
 ============================================================
 ============================================================
 TEST 3: Generate 7-bit awkward
@@ -350,14 +380,6 @@ If you say, e.g., `\def\a1{...}', then you must always
 put `1' after `\a', since control sequence names are
 made up of letters only. The macro here has not been
 followed by the required stuff, so I'm ignoring it.
-! Use of \??? doesn't match its definition.
-<argument> \???  
-                 ! LaTeX3 Error: Cannot generate space chars.
-l. ...  }
-If you say, e.g., `\def\a1{...}', then you must always
-put `1' after `\a', since control sequence names are
-made up of letters only. The macro here has not been
-followed by the required stuff, so I'm ignoring it.
 ! Undefined control sequence.
 <inserted text> @
 l. ...  }





More information about the latex3-commits mailing list.