[latex3-commits] [git/LaTeX3-latex3-latex3] pdfescape: Simplify the loop (65f31c9fe)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu May 21 14:50:31 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : pdfescape
Link       : https://github.com/latex3/latex3/commit/65f31c9fe776e4315401c83aebda5745e39365e6

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

commit 65f31c9fe776e4315401c83aebda5745e39365e6
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu May 21 13:50:31 2020 +0100

    Simplify the loop


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

65f31c9fe776e4315401c83aebda5745e39365e6
 l3kernel/l3str-convert.dtx | 53 ++++++----------------------------------------
 1 file changed, 7 insertions(+), 46 deletions(-)

diff --git a/l3kernel/l3str-convert.dtx b/l3kernel/l3str-convert.dtx
index 372aed8af..6ced9ec28 100644
--- a/l3kernel/l3str-convert.dtx
+++ b/l3kernel/l3str-convert.dtx
@@ -2582,16 +2582,14 @@
 %
 % \subsection{PDF names and strings by expansion}
 %
-% \begin{macro}[EXP]{\str_convert_pdfname:n, \@@_convert_pdfname:n}
-% \begin{macro}[EXP]{\@@_convert_pdfname_first:w, \@@_convert_pdfname_loop:w}
-% \begin{macro}[EXP]{\@@_convert_pdfname_outer:n}
-% \begin{macro}[EXP]{\@@_convert_pdfname_inner:w}
+% \begin{macro}[EXP]{\str_convert_pdfname:n}
+% \begin{macro}[EXP]{\@@_convert_pdfname:N}
 % \begin{macro}[EXP]
 %   {\@@_convert_pdfname_bytes:n, \@@_convert_pdfname_bytes_aux:n}
 % \begin{macro}[EXP]{\@@_convert_pdfname_bytes_aux:nnn}
 %   To convert to PDF names by expansion, we work purely on UTF-8 input. The
-%   first step is to make a string, after which we use a space-based mapping to
-%   divide up the input, then a simple token-by-token approach. In Unicode
+%   first step is to make a string with \enquote{other} spaces,
+%   after which we use a simple token-by-token approach. In Unicode
 %   engines, we break down everything before one-byte codepoints, but for
 %   $8$-bit engines there is no need to worry. Actual escaping is covered
 %   by the same code as used in the non-expandable route.
@@ -2599,45 +2597,17 @@
 \cs_new:Npn \str_convert_pdfname:n #1
   {
     \exp_args:Ne \tl_to_str:n
-      {
-         \exp_after:wN \@@_convert_pdfname:n \exp_after:wN
-           { \tl_to_str:n {#1} }
-      }
-  }
-\cs_new:Npx \@@_convert_pdfname:n #1
-  {
-    \exp_not:N \@@_convert_pdfname_first:w #1 ~
-      \exp_not:N \q_recursion_tail \c_space_tl
-      \exp_not:N \q_recursion_stop
-  }
-\cs_new:Npn \@@_convert_pdfname_first:w #1 ~
-  {
-    \quark_if_recursion_tail_stop:n {#1}
-    \@@_convert_pdfname_outer:n {#1}
-  }
-\cs_new:Npn \@@_convert_pdfname_loop:w #1 ~
-  {
-    \quark_if_recursion_tail_stop:n {#1}
-    \c_hash_str 20
-    \@@_convert_pdfname_outer:n {#1}
-  }
-\cs_new:Npx \@@_convert_pdfname_outer:n #1
-  {
-    \exp_not:N \@@_convert_pdfname_inner:w #1
-      \exp_not:N \q_recursion_tail \exp_not:N \q_recursion_stop
-    \exp_not:N \@@_convert_pdfname_loop:w
+      { \str_map_function:nN {#1} \@@_convert_pdfname:N }
   }
 \bool_lazy_or:nnTF
   { \sys_if_engine_luatex_p: }
   { \sys_if_engine_xetex_p: }
   {
-    \cs_new:Npn \@@_convert_pdfname_inner:w #1
+    \cs_new:Npn \@@_convert_pdfname:N #1
       {
-        \quark_if_recursion_tail_stop:n {#1}
         \int_compare:nNnTF { `#1 } > { "7F }
           { \@@_convert_pdfname_bytes:n {#1} }
           { \@@_escape_name_char:N #1 }
-        \@@_convert_pdfname_inner:w
       }
     \cs_new:Npn \@@_convert_pdfname_bytes:n #1
       {
@@ -2660,21 +2630,12 @@
           }
       }
   }
-  {
-    \cs_new:Npn \@@_convert_pdfname_inner:w #1
-      {
-        \quark_if_recursion_tail_stop:n {#1}
-        \@@_escape_name_char:N #1
-        \@@_convert_pdfname_inner:w
-      }
-  }
+  { \cs_new_eq:NN \@@_convert_pdfname:N \@@_escape_name_char:N }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
 % \end{macro}
 % \end{macro}
-% \end{macro}
-% \end{macro}
 %
 %    \begin{macrocode}
 %</initex|package>





More information about the latex3-commits mailing list.