[latex3-commits] [git/LaTeX3-latex3-latex3] l3text: Move \char_<thing>case:N to stable (a756e4ad2)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Nov 27 12:57:35 CET 2019


Repository : https://github.com/latex3/latex3
On branch  : l3text
Link       : https://github.com/latex3/latex3/commit/a756e4ad2fe2dc46cec49f806c3dc6404fdac12c

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

commit a756e4ad2fe2dc46cec49f806c3dc6404fdac12c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Nov 27 10:25:04 2019 +0000

    Move \char_<thing>case:N to stable


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

a756e4ad2fe2dc46cec49f806c3dc6404fdac12c
 l3kernel/CHANGELOG.md     |   1 +
 l3kernel/l3candidates.dtx | 198 ----------------------------------------------
 l3kernel/l3token.dtx      | 192 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 193 insertions(+), 198 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index b3ccfeda6..ee67e698b 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -16,6 +16,7 @@ this project uses date-based 'snapshot' version identifiers.
 ### Changed
 - Distribute LaTeX3 News
 - Moved `\char_codepoint_to_bytes:n` to stable
+- Moved `\char_<thing>case:n` to stable
 
 ### Deprecated
 - `\str_fold_case:n`,
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index cea20d221..8fc38afa5 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -848,26 +848,6 @@
 %   (\enquote{active}), and character code $32$ (space).
 % \end{variable}
 %
-% \begin{function}[added = 2019-11-26, EXP]
-%   {
-%     \char_lowercase:N, \char_uppercase:N,
-%     \char_titlecase:N, \char_foldcase:N,
-%     \char_str_lowercase:N, \char_str_uppercase:N,
-%     \char_str_titlecase:N, \char_str_foldcase:N,
-%   }
-%   \begin{syntax}
-%     \cs{char_lowercase:N} \meta{char}
-%   \end{syntax}
-%   Converts the \meta{char} to the equivalent case-changed character
-%   as detailed by the function name (see \cs{str_fold_case:n}
-%   and \cs{tl_mixed_case:n} for details of these terms). The case mapping
-%   is carried out with no context-dependence (\emph{cf.}~\cs{tl_upper_case:n},
-%   \emph{etc.}) The \texttt{str} versions always generate \enquote{other}
-%   (category code $12$) characters, whilst the standard versions generate
-%   characters with the category code of the \meta{char} (i.e.~only
-%   the character code changes).
-% \end{function}
-%
 % \begin{function}[added = 2018-09-23]
 %   {
 %     \peek_catcode_collect_inline:Nn,
@@ -1541,184 +1521,6 @@
 % appropriate data extracted from the Unicode documentation (either manually
 % or automatically).
 %
-% First, some code which \enquote{belongs} in \pkg{l3tokens} but has to come
-% here.
-%    \begin{macrocode}
-%<@@=char>
-%    \end{macrocode}
-%
-% \begin{macro}[EXP]
-%   {
-%     \char_lowercase:N, \char_uppercase:N,
-%     \char_titlecase:N, \char_foldcase:N
-%   }
-% \begin{macro}[EXP]{\@@_change_case:nNN}
-% \begin{macro}[EXP]{\@@_change_case:nN}
-% \begin{macro}[EXP]{\@@_change_case_multi:nN, \@@_change_case_multi:vN}
-% \begin{macro}[EXP]{\@@_change_case_multi:NNNNw}
-% \begin{macro}[EXP]{\@@_change_case:NNN}
-% \begin{macro}[EXP]{\@@_change_case:NNNN}
-% \begin{macro}[EXP]{\@@_change_case:NN}
-% \begin{macro}[EXP]{\@@_change_case_catcode:N}
-% \begin{macro}[EXP]
-%   {
-%     \char_str_lowercase:N, \char_str_uppercase:N,
-%     \char_str_titlecase:N, \char_str_foldcase:N
-%   }
-% \begin{macro}[EXP]{\@@_str_change_case:nNN}
-% \begin{macro}[EXP]{\@@_str_change_case:nN}
-%   Expandable character generation is done using a two-part approach.
-%   First, see if the current character has a special mapping for the current
-%   transformation. If it does, insert that. Otherwise, use the \TeX{} data
-%   to look up the one-to-one mapping, and generate the appropriate character
-%   with the appropriate category code. Titlecase needs an extra step as it
-%   may be special-cased or might be a special upper case outcome. The internal
-%   when using non-Unicode engines has to be set up to only do anything
-%   with ASCII characters.
-%
-%  To ensure that the category codes produced are predictable, every character
-%  is re-generated even if it is otherwise unchanged. This makes life a little
-%  interesting when we might have multiple output characters: we have to
-%  grab each of them and case change them in reverse order to maintain
-%  \texttt{f}-type expandability.
-%    \begin{macrocode}
-\cs_new:Npn \char_lowercase:N #1
-  { \@@_change_case:nNN { lower } \char_value_lccode:n #1 }
-\cs_new:Npn \char_uppercase:N #1
-  { \@@_change_case:nNN { upper } \char_value_uccode:n #1 }
-\cs_new:Npn \char_titlecase:N #1
-  {
-    \tl_if_exist:cTF { c_@@_titlecase_ \token_to_str:N #1 _tl }
-      {
-        \@@_change_case_multi:vN
-          { c_@@_titlecase_ \token_to_str:N #1 _tl } #1
-      }
-      { \char_uppercase:N #1 }
-  }
-\cs_new:Npn \char_foldcase:N #1
-  { \@@_change_case:nNN { fold } \char_value_lccode:n #1 }
-\cs_new:Npn \@@_change_case:nNN #1#2#3
-  {
-    \tl_if_exist:cTF { c_@@_ #1 case_ \token_to_str:N #3 _tl }
-      {
-        \@@_change_case_multi:vN
-          { c_@@_ #1 case_ \token_to_str:N #3 _tl } #3
-      }
-      { \exp_args:Nf \@@_change_case:nN { #2 { `#3 } } #3 }
-  }
-\cs_new:Npn \@@_change_case:nN #1#2
-  {
-    \int_compare:nNnTF {#1} = 0
-      { #2 }
-      { \char_generate:nn {#1} { \@@_change_case_catcode:N #2 } }
-  }
-\cs_new:Npn \@@_change_case_multi:nN #1#2
-  { \@@_change_case_multi:NNNNw #2 #1 \q_no_value \q_no_value \q_stop }
-\cs_generate_variant:Nn \@@_change_case_multi:nN { v }
-\cs_new:Npn \@@_change_case_multi:NNNNw #1#2#3#4#5 \q_stop
-  {
-    \quark_if_no_value:NTF #4
-      {
-        \quark_if_no_value:NTF #3
-          { \@@_change_case:NN #1 #2 }
-          { \@@_change_case:NNN #1 #2#3 }
-      }
-      { \@@_change_case:NNNN #1 #2#3#4 }
-  }
-\cs_new:Npn \@@_change_case:NNN #1#2#3
-  {
-    \exp_args:Nnf \use:nn
-      { \@@_change_case:NN #1 #2 }
-      { \@@_change_case:NN #1 #3 }
-  }
-\cs_new:Npn \@@_change_case:NNNN #1#2#3#4
-  {
-    \exp_args:Nnff \use:nnn
-      { \@@_change_case:NN #1 #2 }
-      { \@@_change_case:NN #1 #3 }
-      { \@@_change_case:NN #1 #4 }
-  }
-\cs_new:Npn \@@_change_case:NN #1#2
-  { \char_generate:nn { `#2 } { \@@_change_case_catcode:N #1 } }
-\cs_new:Npn \@@_change_case_catcode:N #1
-  {
-    \if_catcode:w \exp_not:N #1 \c_math_toggle_token
-      3
-    \else:
-      \if_catcode:w \exp_not:N #1 \c_alignment_token
-        4
-      \else:
-        \if_catcode:w \exp_not:N #1 \c_math_superscript_token
-          7
-        \else:
-          \if_catcode:w \exp_not:N #1 \c_math_subscript_token
-            8
-          \else:
-            \if_catcode:w \exp_not:N #1 \c_space_token
-              10
-            \else:
-             \if_catcode:w \exp_not:N #1 \c_catcode_letter_token
-               11
-             \else:
-               \if_catcode:w \exp_not:N #1 \c_catcode_other_token
-                 12
-               \else:
-                 13
-               \fi:
-             \fi:
-            \fi:
-          \fi:
-        \fi:
-      \fi:
-    \fi:
-  }
-%    \end{macrocode}
-%   Same story for the string version, except category code is easier
-%   to follow. This of course makes this version significantly faster.
-%    \begin{macrocode}
-\cs_new:Npn \char_str_lowercase:N #1
-  { \@@_str_change_case:nNN { lower } \char_value_lccode:n #1 }
-\cs_new:Npn \char_str_uppercase:N #1
-  { \@@_str_change_case:nNN { upper } \char_value_uccode:n #1 }
-\cs_new:Npn \char_str_titlecase:N #1
-  {
-    \tl_if_exist:cTF { c_@@_titlecase_ \token_to_str:N #1 _tl }
-      { \tl_to_str:c { c_@@_titlecase_ \token_to_str:N #1 _tl } }
-      { \char_str_uppercase:N #1 }
-  }
-\cs_new:Npn \char_str_foldcase:N #1
-  { \@@_str_change_case:nNN { fold } \char_value_lccode:n #1 }
-\cs_new:Npn \@@_str_change_case:nNN #1#2#3
-  {
-    \tl_if_exist:cTF { c_@@_ #1 case_ \token_to_str:N #3 _tl }
-      { \tl_to_str:c { c_@@_ #1 case_ \token_to_str:N #3 _tl } }
-      { \exp_args:Nf \@@_str_change_case:nN { #2 { `#3 } } #3 }
-  }
-\cs_new:Npn \@@_str_change_case:nN #1#2
-  {
-    \int_compare:nNnTF {#1} = 0
-      { \tl_to_str:n {#2} }
-      { \char_generate:nn {#1} { 12 } }
-  }
-\cs_if_exist:NF \tex_Uchar:D
-  {
-    \cs_set:Npn \@@_str_change_case:nN #1#2
-      { \tl_to_str:n {#2} }
-  }
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
 %    \begin{macrocode}
 \cs_new_eq:NN \char_mixedcase:N \char_titlecase:N
 %     \end{macrocode}
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index 672cf04bf..05ebd3078 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -413,6 +413,26 @@
 %   and |#3| and |#4| empty.
 % \end{function}
 %
+% \begin{function}[added = 2019-11-26, EXP]
+%   {
+%     \char_lowercase:N, \char_uppercase:N,
+%     \char_titlecase:N, \char_foldcase:N,
+%     \char_str_lowercase:N, \char_str_uppercase:N,
+%     \char_str_titlecase:N, \char_str_foldcase:N,
+%   }
+%   \begin{syntax}
+%     \cs{char_lowercase:N} \meta{char}
+%   \end{syntax}
+%   Converts the \meta{char} to the equivalent case-changed character
+%   as detailed by the function name (see \cs{str_fold_case:n}
+%   and \cs{tl_mixed_case:n} for details of these terms). The case mapping
+%   is carried out with no context-dependence (\emph{cf.}~\cs{tl_upper_case:n},
+%   \emph{etc.}) The \texttt{str} versions always generate \enquote{other}
+%   (category code $12$) characters, whilst the standard versions generate
+%   characters with the category code of the \meta{char} (i.e.~only
+%   the character code changes).
+% \end{function}
+%
 % \section{Generic tokens}
 %
 % \begin{variable}
@@ -1651,6 +1671,178 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}[EXP]
+%   {
+%     \char_lowercase:N, \char_uppercase:N,
+%     \char_titlecase:N, \char_foldcase:N
+%   }
+% \begin{macro}[EXP]{\@@_change_case:nNN}
+% \begin{macro}[EXP]{\@@_change_case:nN}
+% \begin{macro}[EXP]{\@@_change_case_multi:nN, \@@_change_case_multi:vN}
+% \begin{macro}[EXP]{\@@_change_case_multi:NNNNw}
+% \begin{macro}[EXP]{\@@_change_case:NNN}
+% \begin{macro}[EXP]{\@@_change_case:NNNN}
+% \begin{macro}[EXP]{\@@_change_case:NN}
+% \begin{macro}[EXP]{\@@_change_case_catcode:N}
+% \begin{macro}[EXP]
+%   {
+%     \char_str_lowercase:N, \char_str_uppercase:N,
+%     \char_str_titlecase:N, \char_str_foldcase:N
+%   }
+% \begin{macro}[EXP]{\@@_str_change_case:nNN}
+% \begin{macro}[EXP]{\@@_str_change_case:nN}
+%   Expandable character generation is done using a two-part approach.
+%   First, see if the current character has a special mapping for the current
+%   transformation. If it does, insert that. Otherwise, use the \TeX{} data
+%   to look up the one-to-one mapping, and generate the appropriate character
+%   with the appropriate category code. Titlecase needs an extra step as it
+%   may be special-cased or might be a special upper case outcome. The internal
+%   when using non-Unicode engines has to be set up to only do anything
+%   with ASCII characters.
+%
+%  To ensure that the category codes produced are predictable, every character
+%  is re-generated even if it is otherwise unchanged. This makes life a little
+%  interesting when we might have multiple output characters: we have to
+%  grab each of them and case change them in reverse order to maintain
+%  \texttt{f}-type expandability.
+%    \begin{macrocode}
+\cs_new:Npn \char_lowercase:N #1
+  { \@@_change_case:nNN { lower } \char_value_lccode:n #1 }
+\cs_new:Npn \char_uppercase:N #1
+  { \@@_change_case:nNN { upper } \char_value_uccode:n #1 }
+\cs_new:Npn \char_titlecase:N #1
+  {
+    \tl_if_exist:cTF { c_@@_titlecase_ \token_to_str:N #1 _tl }
+      {
+        \@@_change_case_multi:vN
+          { c_@@_titlecase_ \token_to_str:N #1 _tl } #1
+      }
+      { \char_uppercase:N #1 }
+  }
+\cs_new:Npn \char_foldcase:N #1
+  { \@@_change_case:nNN { fold } \char_value_lccode:n #1 }
+\cs_new:Npn \@@_change_case:nNN #1#2#3
+  {
+    \tl_if_exist:cTF { c_@@_ #1 case_ \token_to_str:N #3 _tl }
+      {
+        \@@_change_case_multi:vN
+          { c_@@_ #1 case_ \token_to_str:N #3 _tl } #3
+      }
+      { \exp_args:Nf \@@_change_case:nN { #2 { `#3 } } #3 }
+  }
+\cs_new:Npn \@@_change_case:nN #1#2
+  {
+    \int_compare:nNnTF {#1} = 0
+      { #2 }
+      { \char_generate:nn {#1} { \@@_change_case_catcode:N #2 } }
+  }
+\cs_new:Npn \@@_change_case_multi:nN #1#2
+  { \@@_change_case_multi:NNNNw #2 #1 \q_no_value \q_no_value \q_stop }
+\cs_generate_variant:Nn \@@_change_case_multi:nN { v }
+\cs_new:Npn \@@_change_case_multi:NNNNw #1#2#3#4#5 \q_stop
+  {
+    \quark_if_no_value:NTF #4
+      {
+        \quark_if_no_value:NTF #3
+          { \@@_change_case:NN #1 #2 }
+          { \@@_change_case:NNN #1 #2#3 }
+      }
+      { \@@_change_case:NNNN #1 #2#3#4 }
+  }
+\cs_new:Npn \@@_change_case:NNN #1#2#3
+  {
+    \exp_args:Nnf \use:nn
+      { \@@_change_case:NN #1 #2 }
+      { \@@_change_case:NN #1 #3 }
+  }
+\cs_new:Npn \@@_change_case:NNNN #1#2#3#4
+  {
+    \exp_args:Nnff \use:nnn
+      { \@@_change_case:NN #1 #2 }
+      { \@@_change_case:NN #1 #3 }
+      { \@@_change_case:NN #1 #4 }
+  }
+\cs_new:Npn \@@_change_case:NN #1#2
+  { \char_generate:nn { `#2 } { \@@_change_case_catcode:N #1 } }
+\cs_new:Npn \@@_change_case_catcode:N #1
+  {
+    \if_catcode:w \exp_not:N #1 \c_math_toggle_token
+      3
+    \else:
+      \if_catcode:w \exp_not:N #1 \c_alignment_token
+        4
+      \else:
+        \if_catcode:w \exp_not:N #1 \c_math_superscript_token
+          7
+        \else:
+          \if_catcode:w \exp_not:N #1 \c_math_subscript_token
+            8
+          \else:
+            \if_catcode:w \exp_not:N #1 \c_space_token
+              10
+            \else:
+             \if_catcode:w \exp_not:N #1 \c_catcode_letter_token
+               11
+             \else:
+               \if_catcode:w \exp_not:N #1 \c_catcode_other_token
+                 12
+               \else:
+                 13
+               \fi:
+             \fi:
+            \fi:
+          \fi:
+        \fi:
+      \fi:
+    \fi:
+  }
+%    \end{macrocode}
+%   Same story for the string version, except category code is easier
+%   to follow. This of course makes this version significantly faster.
+%    \begin{macrocode}
+\cs_new:Npn \char_str_lowercase:N #1
+  { \@@_str_change_case:nNN { lower } \char_value_lccode:n #1 }
+\cs_new:Npn \char_str_uppercase:N #1
+  { \@@_str_change_case:nNN { upper } \char_value_uccode:n #1 }
+\cs_new:Npn \char_str_titlecase:N #1
+  {
+    \tl_if_exist:cTF { c_@@_titlecase_ \token_to_str:N #1 _tl }
+      { \tl_to_str:c { c_@@_titlecase_ \token_to_str:N #1 _tl } }
+      { \char_str_uppercase:N #1 }
+  }
+\cs_new:Npn \char_str_foldcase:N #1
+  { \@@_str_change_case:nNN { fold } \char_value_lccode:n #1 }
+\cs_new:Npn \@@_str_change_case:nNN #1#2#3
+  {
+    \tl_if_exist:cTF { c_@@_ #1 case_ \token_to_str:N #3 _tl }
+      { \tl_to_str:c { c_@@_ #1 case_ \token_to_str:N #3 _tl } }
+      { \exp_args:Nf \@@_str_change_case:nN { #2 { `#3 } } #3 }
+  }
+\cs_new:Npn \@@_str_change_case:nN #1#2
+  {
+    \int_compare:nNnTF {#1} = 0
+      { \tl_to_str:n {#2} }
+      { \char_generate:nn {#1} { 12 } }
+  }
+\cs_if_exist:NF \tex_Uchar:D
+  {
+    \cs_set:Npn \@@_str_change_case:nN #1#2
+      { \tl_to_str:n {#2} }
+  }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
 % \begin{macro}{\c_catcode_other_space_tl}
 %   Create a space with category code $12$: an \enquote{other} space.
 %    \begin{macrocode}





More information about the latex3-commits mailing list