[latex3-commits] [git/LaTeX3-latex3-latex3] main: Allow for \..code changes in \char__str_...case:n (9cef4160d)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Apr 21 07:46:59 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/9cef4160da375b881d96ad7d18c5a47bf9b11d1e

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

commit 9cef4160da375b881d96ad7d18c5a47bf9b11d1e
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Apr 21 06:46:12 2022 +0100

    Allow for \..code changes in \char__str_...case:n


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

9cef4160da375b881d96ad7d18c5a47bf9b11d1e
 l3kernel/CHANGELOG.md                   |  3 +++
 l3kernel/l3token.dtx                    | 10 ++++++++-
 l3kernel/l3unicode.dtx                  | 19 ++---------------
 l3kernel/testfiles/m3char001.luatex.tlg | 36 +++++++++++++++++++++++++++++++++
 l3kernel/testfiles/m3char001.lvt        | 10 +++++++++
 l3kernel/testfiles/m3char001.ptex.tlg   | 36 +++++++++++++++++++++++++++++++++
 l3kernel/testfiles/m3char001.tlg        | 36 +++++++++++++++++++++++++++++++++
 l3kernel/testfiles/m3char001.uptex.tlg  | 36 +++++++++++++++++++++++++++++++++
 l3kernel/testfiles/m3char001.xetex.tlg  | 36 +++++++++++++++++++++++++++++++++
 9 files changed, 204 insertions(+), 18 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 39130c2ab..0701ee995 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Changed
+- Allow for `\lccode`/`\uccode` changes in `\char_str_...case:n` functions
+
 ## [2022-04-20]
 
 ### Changed
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index 6b1b1759f..d359f9dc4 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -1975,7 +1975,15 @@
   { \cs_if_exist_p:N \tex_XeTeXversion:D }
   {
     \cs_set:Npn \@@_str_change_case:nN #1#2
-      { \tl_to_str:n {#2} }
+      {
+        \int_compare:nNnTF {#1} = 0
+          { \tl_to_str:n {#2} }
+          {
+            \int_compare:nTF { `A <= #1 <= `z }
+              { \char_generate:nn {#1} { 12 } }
+              { \tl_to_str:n {#2} }
+          }
+      }
   }
 %    \end{macrocode}
 % \end{macro}
diff --git a/l3kernel/l3unicode.dtx b/l3kernel/l3unicode.dtx
index 19134440a..7a31b48af 100644
--- a/l3kernel/l3unicode.dtx
+++ b/l3kernel/l3unicode.dtx
@@ -240,26 +240,11 @@
     \group_end:
   }
 %    \end{macrocode}
-% For the $8$-bit engines, the above is skipped but there is still some
-% set up required. As case changing can only be applied to bytes, and
-% they have to be in the ASCII range, we define a series of data stores
-% to represent them, and the data are used such that only these are
-% ever case-changed. We do open and close one file to force allocation of
-% a read: this keeps all engines in line.
+% For the $8$-bit engines, open the stream and close again: this keeps
+% file records the same.
 %    \begin{macrocode}
   {
     \group_begin:
-      \cs_set_protected:Npn \@@_tmp:NN #1#2
-        {
-          \quark_if_recursion_tail_stop:N #2
-          \tl_const:cn { c_@@_uppercase_ #2 _tl } {#1}
-          \tl_const:cn { c_@@_lowercase_ #1 _tl } {#2}
-          \tl_const:cn { c_@@_foldcase_  #1 _tl } {#2}
-          \@@_tmp:NN
-        }
-      \@@_tmp:NN
-        AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz
-        ? \q_recursion_tail \q_recursion_stop
       \ior_open:Nn \g_@@_data_ior { UnicodeData.txt }
       \ior_close:N \g_@@_data_ior
     \group_end:
diff --git a/l3kernel/testfiles/m3char001.luatex.tlg b/l3kernel/testfiles/m3char001.luatex.tlg
index 9e4cdefd6..984019cdd 100644
--- a/l3kernel/testfiles/m3char001.luatex.tlg
+++ b/l3kernel/testfiles/m3char001.luatex.tlg
@@ -678,3 +678,39 @@ The token list contains the tokens:
 <recently read> }
 l. ...    }
 ============================================================
+============================================================
+TEST 11: Changing \lccode and \uccode 
+============================================================
+The token list contains the tokens:
+>  x (the character x).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  Q (the character Q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  x (the character x).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  Q (the character Q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  q (the character q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  X (the character X).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  q (the character q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  X (the character X).
+<recently read> }
+l. ...    }
+============================================================
diff --git a/l3kernel/testfiles/m3char001.lvt b/l3kernel/testfiles/m3char001.lvt
index 26f9fdf70..3a217d4e4 100644
--- a/l3kernel/testfiles/m3char001.lvt
+++ b/l3kernel/testfiles/m3char001.lvt
@@ -217,4 +217,14 @@
     }
 \group_end:
 
+\group_begin:
+  \tex_uccode:D `q  = `X
+  \tex_lccode:D `Q  = `x
+  \TEST { Changing~\lccode and~\uccode }
+    {
+      \test:N Q
+      \test:N q
+    }
+\group_end:
+
 \END
diff --git a/l3kernel/testfiles/m3char001.ptex.tlg b/l3kernel/testfiles/m3char001.ptex.tlg
index 264cb5252..7ebcd0a82 100644
--- a/l3kernel/testfiles/m3char001.ptex.tlg
+++ b/l3kernel/testfiles/m3char001.ptex.tlg
@@ -1135,3 +1135,39 @@ The token list contains the tokens:
 <recently read> }
 l. ...    }
 ============================================================
+============================================================
+TEST 11: Changing \lccode and \uccode 
+============================================================
+The token list contains the tokens:
+>  x (the character x).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  Q (the character Q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  x (the character x).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  Q (the character Q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  q (the character q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  X (the character X).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  q (the character q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  X (the character X).
+<recently read> }
+l. ...    }
+============================================================
diff --git a/l3kernel/testfiles/m3char001.tlg b/l3kernel/testfiles/m3char001.tlg
index 264cb5252..7ebcd0a82 100644
--- a/l3kernel/testfiles/m3char001.tlg
+++ b/l3kernel/testfiles/m3char001.tlg
@@ -1135,3 +1135,39 @@ The token list contains the tokens:
 <recently read> }
 l. ...    }
 ============================================================
+============================================================
+TEST 11: Changing \lccode and \uccode 
+============================================================
+The token list contains the tokens:
+>  x (the character x).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  Q (the character Q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  x (the character x).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  Q (the character Q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  q (the character q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  X (the character X).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  q (the character q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  X (the character X).
+<recently read> }
+l. ...    }
+============================================================
diff --git a/l3kernel/testfiles/m3char001.uptex.tlg b/l3kernel/testfiles/m3char001.uptex.tlg
index 264cb5252..7ebcd0a82 100644
--- a/l3kernel/testfiles/m3char001.uptex.tlg
+++ b/l3kernel/testfiles/m3char001.uptex.tlg
@@ -1135,3 +1135,39 @@ The token list contains the tokens:
 <recently read> }
 l. ...    }
 ============================================================
+============================================================
+TEST 11: Changing \lccode and \uccode 
+============================================================
+The token list contains the tokens:
+>  x (the character x).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  Q (the character Q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  x (the character x).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  Q (the character Q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  q (the character q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  X (the character X).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  q (the character q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  X (the character X).
+<recently read> }
+l. ...    }
+============================================================
diff --git a/l3kernel/testfiles/m3char001.xetex.tlg b/l3kernel/testfiles/m3char001.xetex.tlg
index 01e578476..a69f481a4 100644
--- a/l3kernel/testfiles/m3char001.xetex.tlg
+++ b/l3kernel/testfiles/m3char001.xetex.tlg
@@ -678,3 +678,39 @@ The token list contains the tokens:
 <recently read> }
 l. ...    }
 ============================================================
+============================================================
+TEST 11: Changing \lccode and \uccode 
+============================================================
+The token list contains the tokens:
+>  x (the character x).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  Q (the character Q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  x (the character x).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  Q (the character Q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  q (the character q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  X (the character X).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  q (the character q).
+<recently read> }
+l. ...    }
+The token list contains the tokens:
+>  X (the character X).
+<recently read> }
+l. ...    }
+============================================================





More information about the latex3-commits mailing list.