[latex3-commits] [git/LaTeX3-latex3-latex3] l3bitset-2: Standardise expl3 formatting in l3bitset (606e1cd03)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Jan 26 16:02:33 CET 2021


Repository : https://github.com/latex3/latex3
On branch  : l3bitset-2
Link       : https://github.com/latex3/latex3/commit/606e1cd037776966bc01604e13d4603f737eb52c

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

commit 606e1cd037776966bc01604e13d4603f737eb52c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jan 26 15:02:33 2021 +0000

    Standardise expl3 formatting in l3bitset


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

606e1cd037776966bc01604e13d4603f737eb52c
 l3experimental/l3bitset/l3bitset.dtx | 173 ++++++++++++++++-------------------
 1 file changed, 78 insertions(+), 95 deletions(-)

diff --git a/l3experimental/l3bitset/l3bitset.dtx b/l3experimental/l3bitset/l3bitset.dtx
index 3a777579b..b5e34e4bc 100644
--- a/l3experimental/l3bitset/l3bitset.dtx
+++ b/l3experimental/l3bitset/l3bitset.dtx
@@ -277,19 +277,19 @@
   {
     \__kernel_chk_if_free_cs:N #1
     \cs_gset_eq:NN #1 \c_zero_str
-    \prop_new:c { g__bitset_\cs_to_str:N #1 _name_prop }
+    \prop_new:c { g__bitset_ \cs_to_str:N #1 _name_prop }
   }
 
 \cs_new_protected:Npn \bitset_new:Nn #1 #2
   {
     \__kernel_chk_if_free_cs:N #1
     \cs_gset_eq:NN #1 \c_zero_str
-    \prop_new:c { g__bitset_\cs_to_str:N #1 _name_prop }
+    \prop_new:c { g__bitset_ \cs_to_str:N #1 _name_prop }
     \prop_gset_from_keyval:cn
-       { g__bitset_\cs_to_str:N #1 _name_prop }
-       { #2 }
+       { g__bitset_ \cs_to_str:N #1 _name_prop }
+       {#2}
   }
-\cs_generate_variant:Nn \bitset_new:N {c}
+\cs_generate_variant:Nn \bitset_new:N { c }
 %    \end{macrocode}
 % \end{macro}
 % \begin{variable}{\l_@@_tmpa_prop}
@@ -303,21 +303,20 @@
 %    \bitset_addto_named_index:Nn
 %  }
 %    \begin{macrocode}
-\cs_new_protected:Npn  \bitset_addto_named_index:Nn #1 #2
+\cs_new_protected:Npn \bitset_addto_named_index:Nn #1#2
   {
-     \prop_set_from_keyval:Nn \l_@@_tmpa_prop
-       { #2 }
+     \prop_set_from_keyval:Nn \l_@@_tmpa_prop {#2}
      \prop_map_inline:Nn \l_@@_tmpa_prop
        {
          \prop_gput:cnn
-           { g_@@_\cs_to_str:N #1 _name_prop }
-           { ##1 }
-           { ##2 }
+           { g_@@_ \cs_to_str:N #1 _name_prop }
+           {##1}
+           {##2}
        }
   }
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}[pTF]
+% \begin{macro}[EXP,pTF]
 %   {
 %     \bitset_if_exist:N, \bitset_if_exist:c
 %   }
@@ -338,46 +337,41 @@
 % The internal command uses only numbers (integer expressions) for the
 % position.
 % A bit is set by either extending the string or by splitting it and
-% then inserting an 1. It is not checked if the value was already 1.
+% then inserting an $1$. It is not checked if the value was already $1$.
 %    \begin{macrocode}
-% #1 name, #2 index (integer expression, 1-based)
-\cs_new_protected:Npn \@@_set_true:Nn #1 #2
+\cs_new_protected:Npn \@@_set_true:Nn #1#2
   {
-    \int_compare:nNnT {#2 } > { 0 }
+    \int_compare:nNnT {#2} > { 0 }
       {
-        \int_compare:nNnTF {\str_count:N #1 } < { #2  }
+        \int_compare:nNnTF { \str_count:N #1 } < { #2 }
           {
-            %extend the str
             \exp_args:NNe
-            \str_put_left:Nn #1 { \prg_replicate:nn {  #2 - \str_count:N #1 -1 } {0} }
+            \str_put_left:Nn #1
+              { \prg_replicate:nn {  #2 - \str_count:N #1 - 1 } { 0 } }
             \str_put_left:Nn #1 { 1 }
           }
           {
-            %replace value
             \str_set:Nx #1
               {
-                \str_range:Nnn #1 {1}{-1 - (#2)}
+                \str_range:Nnn #1 { 1 } { -1 - (#2) }
                 1
-                \str_range:Nnn #1 {1 -(#2)}{-1}
+                \str_range:Nnn #1 { 1 - (#2) } { -1 }
              }
           }
       }
   }
-
-%#1 name, #2 index (integer expression,1-based)
-\cs_new_protected:Npn \@@_gset_true:Nn #1 #2
+\cs_new_protected:Npn \@@_gset_true:Nn #1#2
   {
-    \int_compare:nNnT {#2 } > { 0 }
+    \int_compare:nNnT { #2 } > { 0 }
       {
-        \int_compare:nNnTF {\str_count:N #1 } < { #2  }
+        \int_compare:nNnTF { \str_count:N #1 } < { #2 }
           {
-          %  %extend the str
             \exp_args:NNe
-            \str_gput_left:Nn #1 { \prg_replicate:nn {  #2 - \str_count:N #1 -1 } {0} }
-            \str_gput_left:Nn #1 { 1 }
+              \str_gput_left:Nn #1
+                { \prg_replicate:nn {  #2 - \str_count:N #1 - 1 } {0} }
+              \str_gput_left:Nn #1 { 1 }
           }
           {
-            % replace the value
             \str_gset:Nx #1
               {
                 \str_range:Nnn #1 {1}{-1 -(#2)}
@@ -396,60 +390,55 @@
 %   }
 % The user commands must first translate the argument to an index number.
 %    \begin{macrocode}
-% #1 name, #2 index (name or number)
-\cs_new_protected:Npn \bitset_set_true:Nn #1 #2
+\cs_new_protected:Npn \bitset_set_true:Nn #1#2
   {
-    \prop_if_in:cnTF { g_@@_\cs_to_str:N #1 _name_prop } {#2}
+    \prop_if_in:cnTF { g_@@_ \cs_to_str:N #1 _name_prop } {#2}
       {
         \@@_set_true:Nn #1
           {
-            \prop_item:cn{ g_@@_\cs_to_str:N #1 _name_prop }{#2}
+            \prop_item:cn  { g_@@_ \cs_to_str:N #1 _name_prop } {#2}
           }
       }
       {
         \regex_match:nnTF { ^[\d]+$ } {#2}
           {
-            %is number
-            \@@_set_true:Nn #1 { #2}
-            \prop_gput:cnn { g_@@_\cs_to_str:N #1 _name_prop }{#2} {#2}
+            \@@_set_true:Nn #1 {#2}
+            \prop_gput:cnn { g_@@_ \cs_to_str:N #1 _name_prop } {#2} {#2}
           }
           {
             \__kernel_msg_warning:nnxx { bitset } { bitset-unknown-name }
               { \token_to_str:N #1 }
-              { \tl_to_str:n { #2} }
+              { \tl_to_str:n {#2} }
           }
       }
   }
-
-%#1 name, #2 index (name or number)
-\cs_new_protected:Npn \bitset_gset_true:Nn #1 #2
+\cs_new_protected:Npn \bitset_gset_true:Nn #1#2
   {
-    \prop_if_in:cnTF { g_@@_\cs_to_str:N #1 _name_prop } {#2}
+    \prop_if_in:cnTF { g_@@_ \cs_to_str:N #1 _name_prop } {#2}
       {
         \@@_gset_true:Nn #1
           {
-            \prop_item:cn{ g_@@_\cs_to_str:N #1 _name_prop }{#2}
+            \prop_item:cn{ g_@@_ \cs_to_str:N #1 _name_prop }{#2}
           }
       }
       {
         \regex_match:nnTF { ^[\d]+$ } {#2}
           {
-            %is number
             \@@_gset_true:Nn #1 { #2}
-            \prop_gput:cnn { g_@@_\cs_to_str:N #1 _name_prop }{#2} {#2}
+            \prop_gput:cnn { g_@@_ \cs_to_str:N #1 _name_prop } {#2} {#2}
           }
           {
             \__kernel_msg_warning:nnxx { bitset } { bitset-unknown-name }
               { \token_to_str:N #1 }
-              { \tl_to_str:n { #2} }
+              { \tl_to_str:n {#2} }
           }
       }
   }
-\cs_generate_variant:Nn \bitset_set_true:Nn  {cn}
-\cs_generate_variant:Nn \bitset_gset_true:Nn {cn}
+\cs_generate_variant:Nn \bitset_set_true:Nn  { c }
+\cs_generate_variant:Nn \bitset_gset_true:Nn { c }
 %    \end{macrocode}
 % \end{macro}
-
+%
 % \begin{macro}
 %   {
 %     \@@_set_false:Nn, \@@_gset_false:Nn
@@ -458,35 +447,33 @@
 % position.
 % Unsetting a bit has only to do something if the string is longer than then index.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_set_false:Nn #1 #2  %#1 name, #2 index (1-based)
+\cs_new_protected:Npn \@@_set_false:Nn #1#2
  {
-   \int_compare:nNnT {#2 } > { 0 }
+   \int_compare:nNnT {#2} > { 0 }
      {
-       \int_compare:nNnT {\str_count:N #1 } > { #2 -1 }
+       \int_compare:nNnT { \str_count:N #1 } > { #2 - 1 }
          {
-           % need to replace the str
            \str_set:Nx #1
              {
-               \str_range:Nnn #1 {1}{-1 - (#2)}
+               \str_range:Nnn #1 { 1 } { -1 - (#2) }
                 0
-               \str_range:Nnn #1 { 1 - (#2)}{-1}
+               \str_range:Nnn #1 { 1 - (#2) } { -1 }
              }
          }
      }
  }
 
-\cs_new_protected:Npn \@@_gset_false:Nn #1 #2  %#1 name, #2 index (1-based)
+\cs_new_protected:Npn \@@_gset_false:Nn #1#2
  {
-   \int_compare:nNnT {#2 } > { 0 }
+   \int_compare:nNnT {#2} > { 0 }
      {
-       \int_compare:nNnT {\str_count:N #1 } > { #2 -1 }
+       \int_compare:nNnT { \str_count:N #1 } > { #2 - 1 }
          {
-           % need to replace the str
            \str_gset:Nx #1
              {
-               \str_range:Nnn #1 {1}{-1 -(#2)}
+               \str_range:Nnn #1 { 1 } { -1 - (#2) }
                 0
-               \str_range:Nnn #1 {1 - (#2)}{-1}
+               \str_range:Nnn #1 { 1 - (#2) } { -1 }
              }
          }
      }
@@ -500,55 +487,53 @@
 %     \bitset_gset_false:Nn, \bitset_gset_false:cn
 %   }
 %    \begin{macrocode}
-\cs_new_protected:Npn \bitset_set_false:Nn #1 #2  %#1 name, #2 index (1-based)
+\cs_new_protected:Npn \bitset_set_false:Nn #1#2
  {
-    \prop_if_in:cnTF { g_@@_\cs_to_str:N #1 _name_prop } {#2}
+    \prop_if_in:cnTF { g_@@_ \cs_to_str:N #1 _name_prop } {#2}
       {
         \@@_set_false:Nn #1
           {
-            \prop_item:cn{ g_@@_\cs_to_str:N #1 _name_prop }{#2}
+            \prop_item:cn{ g_@@_ \cs_to_str:N #1 _name_prop } {#2}
           }
       }
       {
         \regex_match:nnTF { ^[\d]+$ } {#2}
           {
-            %is number
             \@@_set_false:Nn #1 { #2}
-            \prop_gput:cnn { g_@@_\cs_to_str:N #1 _name_prop }{#2} {#2}
+            \prop_gput:cnn { g_@@_ \cs_to_str:N #1 _name_prop } {#2} {#2}
           }
           {
             \__kernel_msg_warning:nnxx { bitset } { bitset-unknown-name }
               { \token_to_str:N #1 }
-              { \tl_to_str:n { #2} }
+              { \tl_to_str:n {#2} }
           }
       }
  }
 
-\cs_new_protected:Npn \bitset_gset_false:Nn #1 #2  %#1 name, #2 index (1-based)
+\cs_new_protected:Npn \bitset_gset_false:Nn #1#2
  {
-   \prop_if_in:cnTF { g_@@_\cs_to_str:N #1 _name_prop } {#2}
+   \prop_if_in:cnTF { g_@@_ \cs_to_str:N #1 _name_prop } {#2}
      {
        \@@_gset_false:Nn #1
          {
-           \prop_item:cn{ g_@@_\cs_to_str:N #1 _name_prop }{#2}
+           \prop_item:cn{ g_@@_ \cs_to_str:N #1 _name_prop } {#2}
          }
      }
      {
        \regex_match:nnTF { ^[\d]+$ } {#2}
          {
-           %is number
            \@@_gset_false:Nn #1 { #2}
-           \prop_gput:cnn { g_@@_\cs_to_str:N #1 _name_prop }{#2} {#2}
+           \prop_gput:cnn { g_@@_ \cs_to_str:N #1 _name_prop } {#2} {#2}
          }
          {
            \__kernel_msg_warning:nnxx { bitset } { bitset-unknown-name }
              { \token_to_str:N #1 }
-             { \tl_to_str:n { #2} }
+             { \tl_to_str:n {#2} }
          }
      }
  }
-\cs_generate_variant:Nn \bitset_set_false:Nn {cn}
-\cs_generate_variant:Nn \bitset_gset_false:Nn {cn}
+\cs_generate_variant:Nn \bitset_set_false:Nn { c }
+\cs_generate_variant:Nn \bitset_gset_false:Nn { c }
 %    \end{macrocode}
 %  \end{macro}
 % \begin{macro}
@@ -565,8 +550,8 @@
   {
     \str_gset_eq:NN #1 \c_zero_str
   }
-\cs_generate_variant:Nn \bitset_clear:N {c}
-\cs_generate_variant:Nn \bitset_gclear:N {c}
+\cs_generate_variant:Nn \bitset_clear:N { c }
+\cs_generate_variant:Nn \bitset_gclear:N { c }
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}
@@ -576,12 +561,11 @@
 %   }
 %   The naming of the commands follow the names in the \texttt{int} module.
 %   \cs{bitset_to_arabic:N} uses \cs{int_from_bin:n} if the string is shorter
-%   then 32 and  the slower \cs{fp_eval} for larger bitsets.
-%
+%   then $32$ and the slower \cs{fp_eval} for larger bitsets.
 %    \begin{macrocode}
 \cs_new:Npn \bitset_to_arabic:N #1
   {
-    \int_compare:nNnTF { \str_count:N #1 } < {32}
+    \int_compare:nNnTF { \str_count:N #1 } < { 32 }
       { \exp_args:No \int_from_bin:n {#1} }
       {
         \exp_after:wN \@@_to_int:nN \exp_after:wN 0
@@ -599,9 +583,8 @@
   {
     #1
   }
-
-\cs_generate_variant:Nn \bitset_to_arabic:N  {c}
-\cs_generate_variant:Nn \bitset_to_bin:N {c}
+\cs_generate_variant:Nn \bitset_to_arabic:N  { c }
+\cs_generate_variant:Nn \bitset_to_bin:N { c }
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}
@@ -609,16 +592,16 @@
 %     \bitset_item:Nn, \bitset_item:cn
 %   }
 % All bits that have been set at anytime have an entry in the prop,
-% so we can take everything else as 0.
+% so we can take everything else as $0$.
 %    \begin{macrocode}
-\cs_new:Npn \bitset_item:Nn #1 #2
+\cs_new:Npn \bitset_item:Nn #1#2
   {
-    \prop_if_in:cnTF { g_@@_\cs_to_str:N #1 _name_prop } {#2}
+    \prop_if_in:cnTF { g_@@_ \cs_to_str:N #1 _name_prop } {#2}
       {
         \int_eval:n
           {
             \str_item:Nn #1
-              { 0 - ( \prop_item:cn { g_@@_\cs_to_str:N #1 _name_prop }{#2} ) }
+              { 0 - ( \prop_item:cn { g_@@_ \cs_to_str:N #1 _name_prop } {#2} ) }
             +0
           }
      }
@@ -626,7 +609,7 @@
        0
      }
   }
-\cs_generate_variant:Nn \bitset_item:Nn {cn}
+\cs_generate_variant:Nn \bitset_item:Nn { c }
 %    \end{macrocode}
 % \end{macro}
 
@@ -648,26 +631,25 @@
       {
         #1 { LaTeX/bitset } { show-bitset }
            { \token_to_str:N #2 }
-           { \bitset_to_bin:N #2  }
-           { \bitset_to_arabic:N #2  }
+           { \bitset_to_bin:N #2 }
+           { \bitset_to_arabic:N #2 }
            { }
       }
   }
-
 \cs_new_protected:Npn \__bitset_show_named_index:NN #1#2
   {
     \__kernel_chk_defined:NT #2
       {
         #1 { LaTeX/bitset } { show-names }
            { \token_to_str:N #2 }
-           { \prop_map_function:cN { g_@@_\cs_to_str:N #2 _name_prop }  \msg_show_item:nn  }
+           { \prop_map_function:cN { g_@@_ \cs_to_str:N #2 _name_prop }  \msg_show_item:nn  }
            { }
            { }
       }
   }
 %    \end{macrocode}
 % \end{macro}
-
+%
 % \subsection{Messages}
 %    \begin{macrocode}
  \__kernel_msg_new:nnn { bitset } { show-bitset }
@@ -690,7 +672,8 @@
 %    \begin{macrocode}
 %</package>
 %    \end{macrocode}
-% \end{macro}%
+% \end{macro}
+%
 % \end{implementation}
 %
 % \PrintIndex





More information about the latex3-commits mailing list.