diff options
author | Karl Berry <karl@freefriends.org> | 2017-03-08 23:01:35 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-03-08 23:01:35 +0000 |
commit | 6fca20c09474a7f6a3559af1c984243a83669f61 (patch) | |
tree | cbfda048c91853241ef903a84a088c1e3a66fd50 /Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx | |
parent | ddbc1f2a5f193876d6f1df544e286029c6d671f8 (diff) |
l3 (8mar17)
git-svn-id: svn://tug.org/texlive/trunk@43432 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx | 124 |
1 files changed, 63 insertions, 61 deletions
diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx index 7e43d73d790..ad0dad50e0d 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-convert.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3str-convert.dtx Copyright (C) 2013-2016 The LaTeX3 Project +%% File: l3str-convert.dtx Copyright (C) 2013-2017 The LaTeX3 Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -22,7 +22,7 @@ % %<*driver|package> \RequirePackage{expl3} -\GetIdInfo$Id: l3str-convert.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3str-convert.dtx 6969 2017-02-20 18:32:23Z bruno $ {L3 Experimental string encoding conversions} %</driver|package> %<*driver> @@ -278,7 +278,7 @@ % \begin{macrocode} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} -\RequirePackage{l3tl-analysis,l3tl-build,l3flag} +\RequirePackage{l3tl-analysis,l3tl-build} % \end{macrocode} % % \subsection{Helpers} @@ -327,25 +327,27 @@ % \end{macrocode} % \end{variable} % -% \begin{variable} -% { -% \c_forty_eight, \c_fifty_eight, \c_sixty_five, \c_ninety_one, -% \c_ninety_seven, \c_one_hundred_twenty_three, -% \c_one_hundred_twenty_seven -% } -% We declare here some integer values which delimit ranges of \textsc{ascii} -% characters of various types. This is mostly used in \pkg{l3regex}. +% \begin{variable}{\c_@@_max_byte_int} +% The maximal byte number. % \begin{macrocode} -\int_const:Nn \c_forty_eight { 48 } -\int_const:Nn \c_fifty_eight { 58 } -\int_const:Nn \c_sixty_five { 65 } -\int_const:Nn \c_ninety_one { 91 } -\int_const:Nn \c_ninety_seven { 97 } -\int_const:Nn \c_one_hundred_twenty_three { 123 } -\int_const:Nn \c_one_hundred_twenty_seven { 127 } +\int_const:Nn \c_@@_max_byte_int { 255 } % \end{macrocode} % \end{variable} % +% \begin{macro}{\c_@@_ascii_min_int, \c_@@_ascii_max_control_int, \c_@@_ascii_max_int} +% \begin{macrocode} +\int_const:Nn \c_@@_ascii_min_int { 0 } +\int_const:Nn \c_@@_ascii_max_control_int { 31 } +\int_const:Nn \c_@@_ascii_max_int { 127 } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[aux]{\c_@@_ascii_lower_int} +% \begin{macrocode} +\int_const:Nn \c_@@_ascii_lower_int { `a - `A } +% \end{macrocode} +% \end{macro} +% % \begin{variable}{\g_@@_alias_prop} % To avoid needing one file per encoding/escaping alias, we keep track % of those in a property list. @@ -494,7 +496,7 @@ % \begin{macrocode} \prg_new_conditional:Npnn \@@_octal_use:N #1 { TF } { - \if_int_compare:w \c_one < '1 \token_to_str:N #1 \exp_stop_f: + \if_int_compare:w 1 < '1 \token_to_str:N #1 \exp_stop_f: #1 \prg_return_true: \else: \prg_return_false: @@ -510,7 +512,7 @@ % \begin{macrocode} \prg_new_conditional:Npnn \@@_hexadecimal_use:N #1 { TF } { - \if_int_compare:w \c_two < "1 \token_to_str:N #1 \exp_stop_f: + \if_int_compare:w 1 < "1 \token_to_str:N #1 \exp_stop_f: #1 \prg_return_true: \else: \if_case:w \__int_eval:w @@ -941,20 +943,19 @@ \cs_new:Npn \@@_convert_lowercase_alphanum_loop:N #1 { \use_none:n #1 - \if_int_compare:w `#1 < \c_ninety_one - \if_int_compare:w `#1 < \c_sixty_five - \if_int_compare:w \c_one < 1#1 \exp_stop_f: + \if_int_compare:w `#1 > `Z \exp_stop_f: + \if_int_compare:w `#1 > `z \exp_stop_f: \else: + \if_int_compare:w `#1 < `a \exp_stop_f: \else: #1 \fi: - \else: - \@@_output_byte:n { `#1 + \c_thirty_two } \fi: \else: - \if_int_compare:w `#1 < \c_one_hundred_twenty_three - \if_int_compare:w `#1 < \c_ninety_seven - \else: + \if_int_compare:w `#1 < `A \exp_stop_f: + \if_int_compare:w 1 < 1#1 \exp_stop_f: #1 \fi: + \else: + \@@_output_byte:n { `#1 + \c_@@_ascii_lower_int } \fi: \fi: \@@_convert_lowercase_alphanum_loop:N @@ -1003,9 +1004,9 @@ % to raise the flag \texttt{str_byte}. Spaces have already been given % the correct category code when this function is called. % \begin{macrocode} -\bool_if:nTF +\bool_lazy_any:nTF { - \sys_if_engine_luatex_p: || + \sys_if_engine_luatex_p: \sys_if_engine_xetex_p: } { @@ -1036,9 +1037,9 @@ % The simplest unescaping method removes non-bytes from % \cs{g_@@_result_tl}. % \begin{macrocode} -\bool_if:nTF +\bool_lazy_any:nTF { - \sys_if_engine_luatex_p: || + \sys_if_engine_luatex_p: \sys_if_engine_xetex_p: } { @@ -1089,9 +1090,9 @@ % \begin{macrocode} \group_begin: \char_set_catcode_other:n { 0 } - \bool_if:nTF + \bool_lazy_any:nTF { - \sys_if_engine_luatex_p: || + \sys_if_engine_luatex_p: \sys_if_engine_xetex_p: } % \end{macrocode} @@ -1146,11 +1147,11 @@ } \cs_new:Npn \@@_encode_native_char:n #1 { - \if_int_compare:w #1 < \c_two_hundred_fifty_six - \@@_output_byte:n {#1} - \else: + \if_int_compare:w #1 > \c_@@_max_byte_int \flag_raise:n { str_error } ? + \else: + \@@_output_byte:n {#1} \fi: } \__msg_kernel_new:nnnn { str } { pdfTeX-native-overflow } @@ -1292,7 +1293,7 @@ \tex_dimen:D "#1 = \l_@@_internal_int sp \scan_stop: \tex_skip:D \l_@@_internal_int = "#1 sp \scan_stop: \tex_toks:D \l_@@_internal_int \exp_after:wN { \__int_value:w "#2 } - \tex_advance:D \l_@@_internal_int \c_one + \int_incr:N \l_@@_internal_int \@@_decode_eight_bit_load:nn } \cs_new_protected:Npn \@@_decode_eight_bit_load_missing:n #1 @@ -1302,7 +1303,7 @@ \tex_skip:D \l_@@_internal_int = "#1 sp \scan_stop: \tex_toks:D \l_@@_internal_int \exp_after:wN { \int_use:N \c_@@_replacement_char_int } - \tex_advance:D \l_@@_internal_int \c_one + \int_incr:N \l_@@_internal_int \@@_decode_eight_bit_load_missing:n } \cs_new:Npn \@@_decode_eight_bit_char:N #1 @@ -1347,7 +1348,7 @@ \tex_skip:D \l_@@_internal_int = "#2 sp \scan_stop: \exp_args:NNf \tex_toks:D \l_@@_internal_int { \@@_output_byte:n { "#1 } } - \tex_advance:D \l_@@_internal_int \c_one + \int_incr:N \l_@@_internal_int \@@_encode_eight_bit_load:nn } \cs_new:Npn \@@_encode_eight_bit_char:n #1 @@ -1366,10 +1367,10 @@ } \cs_new:Npn \@@_encode_eight_bit_char_aux:n #1 { - \if_int_compare:w #1 < \c_two_hundred_fifty_six - \@@_output_byte:n {#1} - \else: + \if_int_compare:w #1 > \c_@@_max_byte_int \flag_raise:n { str_error } + \else: + \@@_output_byte:n {#1} \fi: } % \end{macrocode} @@ -1404,9 +1405,9 @@ % Messages used for other escapings and % encodings are defined in each definition file. % \begin{macrocode} -\bool_if:nT +\bool_lazy_any:nT { - \sys_if_engine_luatex_p: || + \sys_if_engine_luatex_p: \sys_if_engine_xetex_p: } { @@ -1485,7 +1486,7 @@ \@@_output_byte:w " \exp_last_unbraced:Nf \@@_unescape_hex_auxi:N { \tl_to_str:N \g_@@_result_tl } - 0 { ? 0 - \c_one \__prg_break: } + 0 { ? 0 - 1 \__prg_break: } \__prg_break_point: \@@_output_end: } @@ -1582,7 +1583,7 @@ { } { \flag_raise:n { str_error } - * \c_zero + `#1 \use_i:nn + * 0 + `#1 \use_i:nn } } { @@ -1683,7 +1684,7 @@ { \@@_octal_use:NTF #4 { - \if_int_compare:w #2 > \c_three + \if_int_compare:w #2 > 3 \exp_stop_f: - 256 \fi: \@@_unescape_string_repeat:NNNNNN @@ -1703,11 +1704,11 @@ { n } { 12 } { t } { 11 } { b } { 10 } - { ^^J } { 0 - \c_one } + { ^^J } { 0 - 1 } } { \flag_raise:n { str_error } - 0 - \c_one \use_i:nn + 0 - 1 \use_i:nn } } \@@_output_end: @@ -1825,8 +1826,8 @@ { \c_backslash_str \int_div_truncate:nn {`#1} {64} - \int_mod:nn { \int_div_truncate:nn {`#1} \c_eight } \c_eight - \int_mod:nn {`#1} \c_eight + \int_mod:nn { \int_div_truncate:nn {`#1} { 8 } } { 8 } + \int_mod:nn {`#1} { 8 } } } \prg_new_conditional:Npnn \@@_if_escape_string:N #1 { TF } @@ -1936,15 +1937,15 @@ % step: use the quotient of |#1| by $64$, and |#1| as arguments for % the looping auxiliary, and output the continuation byte % corresponding to the remainder $|#2|-64|#1|+128$. The bizarre -% construction |- \c_one + \c_zero *| removes the spurious initial +% construction |- 1 + 0 *| removes the spurious initial % continuation byte (better methods welcome). % \begin{macrocode} \cs_new_protected:cpn { @@_convert_encode_utf8: } { \@@_convert_gmap_internal:N \@@_encode_utf_viii_char:n } \cs_new:Npn \@@_encode_utf_viii_char:n #1 { - \@@_encode_utf_viii_loop:wwnnw #1 ; - \c_one + \c_zero * ; - { 128 } { \c_zero } + \@@_encode_utf_viii_loop:wwnnw #1 ; - 1 + 0 * ; + { 128 } { 0 } { 32 } { 192 } { 16 } { 224 } { 8 } { 240 } @@ -1959,7 +1960,7 @@ \exp_after:wN \@@_encode_utf_viii_loop:wwnnw \__int_value:w \int_div_truncate:nn {#1} {64} ; #1 ; #5 \q_stop - \@@_output_byte:n { #2 - 64 * ( #1 - \c_two ) } + \@@_output_byte:n { #2 - 64 * ( #1 - 2 ) } } % \end{macrocode} % \end{macro} @@ -2478,7 +2479,7 @@ \@@_decode_utf_xvi_pair_end:Nw #1 \fi: \if_case:w - \__int_eval:w ( \@@_tmp:w #1#2 - "D6 ) / \c_four \__int_eval_end: + \__int_eval:w ( \@@_tmp:w #1#2 - "D6 ) / 4 \__int_eval_end: \or: \exp_after:wN \@@_decode_utf_xvi_quad:NNwNN \or: \exp_after:wN \@@_decode_utf_xvi_extra:NNw \fi: @@ -2495,10 +2496,11 @@ \fi: \if_int_compare:w \if_int_compare:w \@@_tmp:w #4#5 < "DC \exp_stop_f: - \c_zero = \c_one + 0 = 1 \else: - \@@_tmp:w #4#5 < "E0 \exp_stop_f: + \@@_tmp:w #4#5 < "E0 \fi: + \exp_stop_f: #1 #2 #4 #5 \s__tl \int_eval:n { @@ -2714,12 +2716,12 @@ \exp_after:wN \@@_decode_utf_xxxii_end:w \fi: #1#2#3#4 \s__tl - \if_int_compare:w \@@_tmp:w #1#4 > \c_zero + \if_int_compare:w \@@_tmp:w #1#4 > 0 \exp_stop_f: \flag_raise:n { str_overflow } \flag_raise:n { str_error } \int_use:N \c_@@_replacement_char_int \else: - \if_int_compare:w \@@_tmp:w #2#3 > \c_sixteen + \if_int_compare:w \@@_tmp:w #2#3 > 16 \exp_stop_f: \flag_raise:n { str_overflow } \flag_raise:n { str_error } \int_use:N \c_@@_replacement_char_int |