[latex3-commits] [git/LaTeX3-latex3-latex3] master: Improve logic (4b4efa0)

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Mar 16 08:26:17 CET 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/4b4efa096de5d9bdeb014935fed923226c081449

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

commit 4b4efa096de5d9bdeb014935fed923226c081449
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Mar 16 07:26:17 2018 +0000

    Improve logic


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

4b4efa096de5d9bdeb014935fed923226c081449
 l3kernel/l3str.dtx |  205 ++++++++++++++++++++++++++--------------------------
 1 file changed, 103 insertions(+), 102 deletions(-)

diff --git a/l3kernel/l3str.dtx b/l3kernel/l3str.dtx
index b1fdb82..5abbb3e 100644
--- a/l3kernel/l3str.dtx
+++ b/l3kernel/l3str.dtx
@@ -2046,6 +2046,8 @@
 % is set up inside a group.
 %    \begin{macrocode}
 \group_begin:
+  \cs_if_exist:NTF \utex_char:D
+    {
 %    \end{macrocode}
 % A read stream is needed. The I/O module is not yet in place \emph{and}
 % we do not want to use up a stream. We therefore use a known free one in
@@ -2053,20 +2055,20 @@
 % \LaTeXe{} and Con\TeX{}t MkII and MkIV).
 %    \begin{macrocode}
 %<*initex>
-  \tex_chardef:D \g_@@_data_ior = 0 \scan_stop:
+      \tex_chardef:D \g_@@_data_ior = 0 \scan_stop:
 %</initex>
 %<*package>
-  \tex_chardef:D \g_@@_data_ior
-    \etex_numexpr:D
-      \cs_if_exist:NTF \lastallocatedread
-        { \lastallocatedread }
-        {
-          \cs_if_exist:NTF \c_syst_last_allocated_read
-            { \c_syst_last_allocated_read }
-            { \tex_count:D 16 ~ }
-        }
-        + 1
-    \scan_stop:
+      \tex_chardef:D \g_@@_data_ior
+        \etex_numexpr:D
+          \cs_if_exist:NTF \lastallocatedread
+            { \lastallocatedread }
+            {
+              \cs_if_exist:NTF \c_syst_last_allocated_read
+                { \c_syst_last_allocated_read }
+                { \tex_count:D 16 ~ }
+            }
+            + 1
+        \scan_stop:
 %</package>
 %    \end{macrocode}
 % Set up to read each file. As they use C-style comments, there is a need to
@@ -2075,33 +2077,32 @@
 % scheme works fine. With no I/O loop available, hard-code one that works
 % quickly.
 %    \begin{macrocode}
-  \cs_set_protected:Npn \@@_map_inline:n #1
-    {
-      \group_begin:
-        \tex_catcode:D `\# = 12 \scan_stop:
-        \tex_catcode:D `\  = 10 \scan_stop:
-        \tex_openin:D \g_@@_data_ior = #1 \scan_stop:
-        \cs_if_exist:NT \utex_char:D
-          { \@@_map_loop: }
-        \tex_closein:D \g_@@_data_ior
-      \group_end:
-    }
-  \cs_set_protected:Npn \@@_map_loop:
-    {
-      \tex_ifeof:D \g_@@_data_ior
-        \exp_after:wN \use_none:n
-      \else:
-        \exp_after:wN \use:n
-      \fi:
+      \cs_set_protected:Npn \@@_map_inline:n #1
+        {
+          \group_begin:
+            \tex_catcode:D `\# = 12 \scan_stop:
+            \tex_catcode:D `\  = 10 \scan_stop:
+            \tex_openin:D \g_@@_data_ior = #1 \scan_stop:
+            \@@_map_loop:
+            \tex_closein:D \g_@@_data_ior
+          \group_end:
+        }
+      \cs_set_protected:Npn \@@_map_loop:
         {
-          \tex_read:D \g_@@_data_ior to \l_@@_tmp_tl
-          \if_meaning:w \c_empty_tl \l_@@_tmp_tl
+          \tex_ifeof:D \g_@@_data_ior
+            \exp_after:wN \use_none:n
           \else:
-            \exp_after:wN \@@_parse:w \l_@@_tmp_tl \q_stop
+            \exp_after:wN \use:n
           \fi:
-          \@@_map_loop:
+            {
+              \tex_read:D \g_@@_data_ior to \l_@@_tmp_tl
+              \if_meaning:w \c_empty_tl \l_@@_tmp_tl
+              \else:
+                \exp_after:wN \@@_parse:w \l_@@_tmp_tl \q_stop
+              \fi:
+              \@@_map_loop:
+            }
         }
-    }
 %    \end{macrocode}
 % The lead-off parser for each line is common for all of the files. If
 % the line starts with a |#| it's a comment. There's one special comment
@@ -2110,98 +2111,99 @@
 % and the test is quite quick (there are relatively few comment lines), it
 % can be present in all of the passes.
 %    \begin{macrocode}
-  \cs_set_protected:Npn \@@_parse:w #1#2 \q_stop
-    {
-      \reverse_if:N \if:w \c_hash_str #1
-        \@@_parse_auxi:w #1#2 \q_stop
-      \else:
-        \if_int_compare:w \__str_if_eq_x:nn
-          { \exp_not:n {#2} } { ~Conditional~Mappings~ } = 0 \exp_stop_f:
-          \cs_set_protected:Npn \@@_parse:w ##1 \q_stop { }
-        \fi:
-      \fi:
-    }
+      \cs_set_protected:Npn \@@_parse:w #1#2 \q_stop
+        {
+          \reverse_if:N \if:w \c_hash_str #1
+            \@@_parse_auxi:w #1#2 \q_stop
+          \else:
+            \if_int_compare:w \__str_if_eq_x:nn
+              { \exp_not:n {#2} } { ~Conditional~Mappings~ } = 0 \exp_stop_f:
+              \cs_set_protected:Npn \@@_parse:w ##1 \q_stop { }
+            \fi:
+          \fi:
+        }
 %    \end{macrocode}
 % Storing each exception is always done in the same way: create a constant
 % token list which expands to exactly the mapping. These have the
 % category codes \enquote{now} (so should be letters) but are later detokenized
 % for string use.
 %    \begin{macrocode}
-  \cs_set_protected:Npn \@@_store:nnnnn #1#2#3#4#5
-    {
-      \tl_const:cx { c_@@_ #2 _ \utex_char:D "#1 _tl }
+      \cs_set_protected:Npn \@@_store:nnnnn #1#2#3#4#5
         {
-          \utex_char:D "#3 ~
-          \utex_char:D "#4 ~
-          \tl_if_blank:nF {#5}
-            { \utex_char:D "#5 }
+          \tl_const:cx { c_@@_ #2 _ \utex_char:D "#1 _tl }
+            {
+              \utex_char:D "#3 ~
+              \utex_char:D "#4 ~
+              \tl_if_blank:nF {#5}
+                { \utex_char:D "#5 }
+            }
         }
-    }
 %    \end{macrocode}
 % Parse the main Unicode data file for title case exceptions (the one-to-one
 % lower and upper case mappings it contains are all be covered by the \TeX{}
 % data).
 %    \begin{macrocode}
-  \cs_set_protected:Npn \@@_parse_auxi:w
-    #1 ; #2 ; #3 ; #4 ; #5 ; #6 ; #7 ; #8 ; #9 ;
-    { \@@_parse_auxii:w #1 ; }
-  \cs_set_protected:Npn \@@_parse_auxii:w
-    #1 ; #2 ; #3 ; #4 ; #5 ; #6 ; #7 \q_stop
-    {
-      \tl_if_blank:nF {#7}
+      \cs_set_protected:Npn \@@_parse_auxi:w
+        #1 ; #2 ; #3 ; #4 ; #5 ; #6 ; #7 ; #8 ; #9 ;
+        { \@@_parse_auxii:w #1 ; }
+      \cs_set_protected:Npn \@@_parse_auxii:w
+        #1 ; #2 ; #3 ; #4 ; #5 ; #6 ; #7 \q_stop
         {
-          \if_int_compare:w \__str_if_eq_x:nn { #5 ~ } {#7} = 0 \exp_stop_f:
-          \else:
-            \tl_const:cx
-              { c_@@_mixed_ \utex_char:D "#1 _tl }
-              { \utex_char:D "#7 }
-          \fi:
+          \tl_if_blank:nF {#7}
+            {
+              \if_int_compare:w \__str_if_eq_x:nn { #5 ~ } {#7} = 0 \exp_stop_f:
+              \else:
+                \tl_const:cx
+                  { c_@@_mixed_ \utex_char:D "#1 _tl }
+                  { \utex_char:D "#7 }
+              \fi:
+            }
         }
-    }
-  \@@_map_inline:n { UnicodeData.txt }
+      \@@_map_inline:n { UnicodeData.txt }
 %    \end{macrocode}
 %  The set up for case folding is in two parts. For the basic (core) mappings,
 %  folding is the same as lower casing in most positions so only store
 %  the differences. For the more complex foldings, always store the result,
 %  splitting up the two or three code points in the input as required.
 %    \begin{macrocode}
-  \cs_set_protected:Npn \@@_parse_auxi:w #1 ;~ #2 ;~ #3 ; #4 \q_stop
-    {
-      \if_int_compare:w \__str_if_eq_x:nn {#2} { C } = 0 \exp_stop_f:
-        \if_int_compare:w \tex_lccode:D "#1 = "#3 \scan_stop:
-        \else:
-          \tl_const:cx
-            { c_@@_fold_ \utex_char:D "#1 _tl }
-            { \utex_char:D "#3 ~ }
-        \fi:
-      \else:
-        \if_int_compare:w \__str_if_eq_x:nn {#2} { F } = 0 \exp_stop_f:
-          \@@_parse_auxii:w #1 ~ #3 ~ \q_stop
-        \fi:
-      \fi:
-    }
-  \cs_set_protected:Npn \@@_parse_auxii:w #1 ~ #2 ~ #3 ~ #4 \q_stop
-    { \@@_store:nnnnn {#1} { fold } {#2} {#3} {#4} }
-  \@@_map_inline:n { CaseFolding.txt }
+      \cs_set_protected:Npn \@@_parse_auxi:w #1 ;~ #2 ;~ #3 ; #4 \q_stop
+        {
+          \if_int_compare:w \__str_if_eq_x:nn {#2} { C } = 0 \exp_stop_f:
+            \if_int_compare:w \tex_lccode:D "#1 = "#3 \scan_stop:
+            \else:
+              \tl_const:cx
+                { c_@@_fold_ \utex_char:D "#1 _tl }
+                { \utex_char:D "#3 ~ }
+            \fi:
+          \else:
+            \if_int_compare:w \__str_if_eq_x:nn {#2} { F } = 0 \exp_stop_f:
+              \@@_parse_auxii:w #1 ~ #3 ~ \q_stop
+            \fi:
+          \fi:
+        }
+      \cs_set_protected:Npn \@@_parse_auxii:w #1 ~ #2 ~ #3 ~ #4 \q_stop
+        { \@@_store:nnnnn {#1} { fold } {#2} {#3} {#4} }
+      \@@_map_inline:n { CaseFolding.txt }
 %    \end{macrocode}
 % For upper and lower casing special situations, there is a bit more to
 % do as we also have title casing to consider.
 %    \begin{macrocode}
-  \cs_set_protected:Npn \@@_parse_auxi:w #1 ;~ #2 ;~ #3 ;~ #4 ; #5 \q_stop
-    {
-      \use:n { \@@_parse_auxii:w #1 ~ lower ~ #2 ~ } ~ \q_stop
-      \use:n { \@@_parse_auxii:w #1 ~ upper ~ #4 ~ } ~ \q_stop
-      \if_int_compare:w \__str_if_eq_x:nn {#3} {#4} = 0 \exp_stop_f:
-      \else:
-        \use:n { \@@_parse_auxii:w #1 ~ mixed ~ #3 ~ } ~ \q_stop
-      \fi:
-    }
-  \cs_set_protected:Npn \@@_parse_auxii:w #1 ~ #2 ~ #3 ~ #4 ~ #5 \q_stop
-    {
-      \tl_if_empty:nF {#4}
-        { \@@_store:nnnnn {#1} {#2} {#3} {#4} {#5} }
+      \cs_set_protected:Npn \@@_parse_auxi:w #1 ;~ #2 ;~ #3 ;~ #4 ; #5 \q_stop
+        {
+          \use:n { \@@_parse_auxii:w #1 ~ lower ~ #2 ~ } ~ \q_stop
+          \use:n { \@@_parse_auxii:w #1 ~ upper ~ #4 ~ } ~ \q_stop
+          \if_int_compare:w \__str_if_eq_x:nn {#3} {#4} = 0 \exp_stop_f:
+          \else:
+            \use:n { \@@_parse_auxii:w #1 ~ mixed ~ #3 ~ } ~ \q_stop
+          \fi:
+        }
+      \cs_set_protected:Npn \@@_parse_auxii:w #1 ~ #2 ~ #3 ~ #4 ~ #5 \q_stop
+        {
+          \tl_if_empty:nF {#4}
+            { \@@_store:nnnnn {#1} {#2} {#3} {#4} {#5} }
+        }
+      \@@_map_inline:n { SpecialCasing.txt }
     }
-  \@@_map_inline:n { SpecialCasing.txt }
 %    \end{macrocode}
 % For the $8$-bit engines, the above does nothing but there is some set
 % up needed. There is no expandable character generator primitive so some
@@ -2209,7 +2211,6 @@
 % can go for the fast approach here of one name per letter. Keeping folding
 % and lower casing separate makes the use later a bit easier.
 %    \begin{macrocode}
-  \cs_if_exist:NF \utex_char:D
     {
       \cs_set_protected:Npn \@@_tmp:NN #1#2
         {





More information about the latex3-commits mailing list