diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex | 424 |
1 files changed, 410 insertions, 14 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex b/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex index 0447f49538b..32d9b6e7f7f 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex +++ b/Master/texmf-dist/tex/latex/l3kernel/expl3-code.tex @@ -35,6 +35,7 @@ %% l3fp-convert.dtx (with options: `package') %% l3fp-random.dtx (with options: `package') %% l3fp-assign.dtx (with options: `package') +%% l3sort.dtx (with options: `package') %% l3box.dtx (with options: `package') %% l3coffins.dtx (with options: `package') %% l3color.dtx (with options: `package') @@ -42,7 +43,7 @@ %% l3candidates.dtx (with options: `package') %% l3luatex.dtx (with options: `package,tex') %% -%% Copyright (C) 1990-2016 The LaTeX3 Project +%% Copyright (C) 1990-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 @@ -54,11 +55,11 @@ %% This file is part of the "l3kernel bundle" (The Work in LPPL) %% and all files in that bundle must be distributed together. %% -%% File: expl3.dtx Copyright (C) 1990-2016 The LaTeX3 Project +%% File: expl3.dtx Copyright (C) 1990-2017 The LaTeX3 Project \def\ExplFileName{expl3}% \def\ExplFileDescription{L3 programming layer}% -\def\ExplFileDate{2017/01/28}% -\def\ExplFileVersion{6834}% +\def\ExplFileDate{2017/02/07}% +\def\ExplFileVersion{6846}% \begingroup \def\next{\endgroup}% \expandafter\ifx\csname PackageError\endcsname\relax @@ -2554,7 +2555,7 @@ \__cs_generate_internal_variant_loop:n } %% File: l3tl.dtx Copyright (C) 1990-2016 The LaTeX3 Project -\GetIdInfo$Id: l3tl.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3tl.dtx 6842 2017-02-06 21:51:22Z joseph $ {L3 Token lists} \cs_new_protected:Npn \tl_new:N #1 { @@ -4064,8 +4065,8 @@ ? \q_recursion_tail \q_recursion_stop } \group_end: -%% File: l3seq.dtx Copyright (C) 1990-2016 The LaTeX3 Project -\GetIdInfo$Id: l3seq.dtx 6805 2016-12-28 22:15:52Z joseph $ +%% File: l3seq.dtx Copyright (C) 1990-2017 The LaTeX3 Project +\GetIdInfo$Id: l3seq.dtx 6842 2017-02-06 21:51:22Z joseph $ {L3 Sequences and stacks} \cs_new:Npn \__seq_item:n { @@ -5800,8 +5801,8 @@ \int_new:N \g__prg_map_int %% File: l3clist.dtx Copyright (C) 2004-2011 Frank Mittelbach, %% The LaTeX3 project -%% (C) 2012-2016 The LaTeX3 Project -\GetIdInfo$Id: l3clist.dtx 6805 2016-12-28 22:15:52Z joseph $ +%% (C) 2012-2017 The LaTeX3 Project +\GetIdInfo$Id: l3clist.dtx 6842 2017-02-06 21:51:22Z joseph $ {L3 Comma separated lists} \cs_new_eq:NN \c_empty_clist \c_empty_tl \tl_new:N \l__clist_internal_clist @@ -15488,6 +15489,405 @@ \fp_new:N \l_tmpb_fp \fp_new:N \g_tmpa_fp \fp_new:N \g_tmpb_fp +%% File l3sort.dtx (C) Copyright 2012,2014-2017 The LaTeX3 Project +\GetIdInfo$Id: l3sort.dtx 6842 2017-02-06 21:51:22Z joseph $ + {L3 Sorting functions} +\int_new:N \l__sort_length_int +\int_new:N \l__sort_min_int +\int_new:N \l__sort_top_int +\int_new:N \l__sort_max_int +\int_new:N \l__sort_true_max_int +\int_new:N \l__sort_block_int +\int_new:N \l__sort_begin_int +\int_new:N \l__sort_end_int +\int_new:N \l__sort_A_int +\int_new:N \l__sort_B_int +\int_new:N \l__sort_C_int +\cs_new_protected:Npn \__sort_shrink_range: + { + \int_set:Nn \l__sort_A_int + { \l__sort_true_max_int - \l__sort_min_int + \c_one } + \int_set:Nn \l__sort_block_int { \c_max_register_int / \c_two } + \__sort_shrink_range_loop: + \int_set:Nn \l__sort_max_int + { + \int_compare:nNnTF + { \l__sort_block_int * \c_three / \c_two } > \l__sort_A_int + { + \l__sort_min_int + + ( \l__sort_A_int - \c_one ) / \c_two + + \l__sort_block_int / \c_four + - \c_one + } + { \l__sort_true_max_int - \l__sort_block_int / \c_two } + } + } +\cs_new_protected:Npn \__sort_shrink_range_loop: + { + \if_int_compare:w \l__sort_A_int < \l__sort_block_int + \tex_divide:D \l__sort_block_int \c_two + \exp_after:wN \__sort_shrink_range_loop: + \fi: + } +\cs_new_protected:Npn \__sort_compute_range: + { + \int_set:Nn \l__sort_min_int { \tex_count:D 15 + \c_one } + \int_set:Nn \l__sort_true_max_int { \c_max_register_int + \c_one } + \__sort_shrink_range: + \if_meaning:w \loctoks \tex_undefined:D \else: + \if_meaning:w \loctoks \scan_stop: \else: + \__sort_redefine_compute_range: + \__sort_compute_range: + \fi: + \fi: + } +\cs_new_protected:Npn \__sort_redefine_compute_range: + { + \cs_if_exist:cTF { ver@elocalloc.sty } + { + \cs_gset_protected:Npn \__sort_compute_range: + { + \int_set:Nn \l__sort_min_int { \tex_count:D 265 } + \int_set_eq:NN \l__sort_true_max_int \e@alloc@top + \__sort_shrink_range: + } + } + { + \cs_gset_protected:Npn \__sort_compute_range: + { + \int_set:Nn \l__sort_min_int { \tex_count:D 265 } + \int_set:Nn \l__sort_true_max_int { \tex_count:D 275 } + \__sort_shrink_range: + } + } + } +\cs_if_exist:NT \loctoks { \__sort_redefine_compute_range: } +\tl_map_inline:nn { \lastallocatedtoks \c_syst_last_allocated_toks } + { + \cs_if_exist:NT #1 + { + \cs_gset_protected:Npn \__sort_compute_range: + { + \int_set:Nn \l__sort_min_int { #1 + \c_one } + \int_set:Nn \l__sort_true_max_int { \c_max_register_int + \c_one } + \__sort_shrink_range: + } + } + } +\cs_new_protected:Npn \__sort_main:NNNnNn #1#2#3#4#5#6 + { + \group_begin: + \__sort_disable_toksdef: + \__sort_compute_range: + \int_set_eq:NN \l__sort_top_int \l__sort_min_int + #2 #5 + { + \if_int_compare:w \l__sort_top_int = \l__sort_max_int + \__sort_too_long_error:NNw #3 #5 + \fi: + \tex_toks:D \l__sort_top_int {##1} + \tex_advance:D \l__sort_top_int \c_one + } + \int_set:Nn \l__sort_length_int + { \l__sort_top_int - \l__sort_min_int } + \cs_set:Npn \__sort_compare:nn ##1 ##2 { #6 } + \int_set_eq:NN \l__sort_block_int \c_one + \__sort_level: + \use:x + { + \group_end: + #1 \exp_not:N #5 {#4} + } + } +\cs_new_protected:Npn \seq_sort:Nn + { + \__sort_main:NNNnNn \tl_set:Nn + \seq_map_inline:Nn \seq_map_break:n + { \s__seq \__sort_toks:NN \exp_not:N \__seq_item:n } + } +\cs_generate_variant:Nn \seq_sort:Nn { c } +\cs_new_protected:Npn \seq_gsort:Nn + { + \__sort_main:NNNnNn \tl_gset:Nn + \seq_map_inline:Nn \seq_map_break:n + { \s__seq \__sort_toks:NN \exp_not:N \__seq_item:n } + } +\cs_generate_variant:Nn \seq_gsort:Nn { c } +\cs_new_protected:Npn \tl_sort:Nn + { + \__sort_main:NNNnNn \tl_set:Nn + \tl_map_inline:Nn \tl_map_break:n + { \__sort_toks:NN \prg_do_nothing: \prg_do_nothing: } + } +\cs_generate_variant:Nn \tl_sort:Nn { c } +\cs_new_protected:Npn \tl_gsort:Nn + { + \__sort_main:NNNnNn \tl_gset:Nn + \tl_map_inline:Nn \tl_map_break:n + { \__sort_toks:NN \prg_do_nothing: \prg_do_nothing: } + } +\cs_generate_variant:Nn \tl_gsort:Nn { c } +\cs_new_protected:Npn \clist_sort:Nn + { \__sort_clist:NNn \tl_set:Nn } +\cs_new_protected:Npn \clist_gsort:Nn + { \__sort_clist:NNn \tl_gset:Nn } +\cs_generate_variant:Nn \clist_sort:Nn { c } +\cs_generate_variant:Nn \clist_gsort:Nn { c } +\cs_new_protected:Npn \__sort_clist:NNn #1#2#3 + { + \clist_if_empty:NF #2 + { + \__sort_main:NNNnNn #1 + \clist_map_inline:Nn \clist_map_break:n + { + \exp_last_unbraced:Nf \use_none:n + { \__sort_toks:NN \exp_args:No \__clist_wrap_item:n } + } + #2 {#3} + } + } +\cs_new:Npn \__sort_toks:NN #1#2 + { \__sort_toks:NNw #1 #2 \l__sort_min_int ; } +\cs_new:Npn \__sort_toks:NNw #1#2#3 ; + { + \if_int_compare:w #3 < \l__sort_top_int + #1 #2 { \tex_the:D \tex_toks:D #3 } + \exp_after:wN \__sort_toks:NNw \exp_after:wN #1 \exp_after:wN #2 + \__int_value:w \__int_eval:w #3 + \c_one \exp_after:wN ; + \fi: + } +\cs_new_protected:Npn \__sort_level: + { + \if_int_compare:w \l__sort_block_int < \l__sort_length_int + \l__sort_end_int \l__sort_min_int + \__sort_merge_blocks: + \tex_advance:D \l__sort_block_int \l__sort_block_int + \exp_after:wN \__sort_level: + \fi: + } +\cs_new_protected:Npn \__sort_merge_blocks: + { + \l__sort_begin_int \l__sort_end_int + \tex_advance:D \l__sort_end_int \l__sort_block_int + \if_int_compare:w \l__sort_end_int < \l__sort_top_int + \l__sort_A_int \l__sort_end_int + \tex_advance:D \l__sort_end_int \l__sort_block_int + \if_int_compare:w \l__sort_end_int > \l__sort_top_int + \l__sort_end_int \l__sort_top_int + \fi: + \l__sort_B_int \l__sort_A_int + \l__sort_C_int \l__sort_top_int + \__sort_copy_block: + \tex_advance:D \l__sort_A_int - \c_one + \tex_advance:D \l__sort_B_int - \c_one + \tex_advance:D \l__sort_C_int - \c_one + \exp_after:wN \__sort_merge_blocks_aux: + \exp_after:wN \__sort_merge_blocks: + \fi: + } +\cs_new_protected:Npn \__sort_copy_block: + { + \tex_toks:D \l__sort_C_int \tex_toks:D \l__sort_B_int + \tex_advance:D \l__sort_C_int \c_one + \tex_advance:D \l__sort_B_int \c_one + \if_int_compare:w \l__sort_B_int = \l__sort_end_int + \use_i:nn + \fi: + \__sort_copy_block: + } +\cs_new_protected:Npn \__sort_merge_blocks_aux: + { + \exp_after:wN \__sort_compare:nn \exp_after:wN + { \tex_the:D \tex_toks:D \exp_after:wN \l__sort_A_int \exp_after:wN } + \exp_after:wN { \tex_the:D \tex_toks:D \l__sort_C_int } + \prg_do_nothing: + \__sort_return_mark:N + \__sort_return_mark:N + \__sort_return_none_error: + } +\cs_new_protected:Npn \sort_return_same: #1 \__sort_return_mark:N + { #1 \__sort_return_mark:N \__sort_return_two_error:w \__sort_return_same: } +\cs_new_protected:Npn \sort_return_swapped: #1 \__sort_return_mark:N + { #1 \__sort_return_mark:N \__sort_return_two_error:w \__sort_return_swapped: } +\cs_new_protected:Npn \__sort_return_mark:N #1 { } +\cs_new_protected:Npn \__sort_return_none_error: + { + \__msg_kernel_error:nnxx { sort } { return-none } + { \tex_the:D \tex_toks:D \l__sort_A_int } + { \tex_the:D \tex_toks:D \l__sort_C_int } + \__sort_return_same: + } +\cs_new_protected:Npn \__sort_return_two_error:w + #1 \__sort_return_none_error: + { \__msg_kernel_error:nn { sort } { return-two } } +\cs_new_protected:Npn \__sort_return_same: + { + \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_C_int + \tex_advance:D \l__sort_B_int - \c_one + \tex_advance:D \l__sort_C_int - \c_one + \if_int_compare:w \l__sort_C_int < \l__sort_top_int + \use_i:nn + \fi: + \__sort_merge_blocks_aux: + } +\cs_new_protected:Npn \__sort_return_swapped: + { + \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_A_int + \tex_advance:D \l__sort_B_int - \c_one + \tex_advance:D \l__sort_A_int - \c_one + \if_int_compare:w \l__sort_A_int < \l__sort_begin_int + \__sort_merge_blocks_end: \use_i:nn + \fi: + \__sort_merge_blocks_aux: + } +\cs_new_protected:Npn \__sort_merge_blocks_end: + { + \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_C_int + \tex_advance:D \l__sort_B_int - \c_one + \tex_advance:D \l__sort_C_int - \c_one + \if_int_compare:w \l__sort_B_int < \l__sort_begin_int + \use_i:nn + \fi: + \__sort_merge_blocks_end: + } +\cs_new:Npn \tl_sort:nN #1#2 + { + \exp_not:f + { + \tl_if_blank:nF {#1} + { + \__sort_quick_prepare:Nnnn #2 { } { } + #1 + { \__prg_break_point: \__sort_quick_prepare_end:NNNnw } + \q_stop + } + } + } +\cs_new:Npn \__sort_quick_prepare:Nnnn #1#2#3#4 + { + \__prg_break: #4 \__prg_break_point: + \__sort_quick_prepare:Nnnn #1 { #2 #3 } { #1 {#4} } + } +\cs_new:Npn \__sort_quick_prepare_end:NNNnw #1#2#3#4#5 \q_stop + { + \__sort_quick_split:NnNn #4 \__sort_quick_end:nnTFNn { } + \q_mark { \__sort_quick_cleanup:w \exp_stop_f: } + \s__stop \q_stop + } +\cs_new:Npn \__sort_quick_cleanup:w #1 \s__stop \q_stop {#1} +\cs_new:Npn \__sort_quick_split:NnNn #1#2#3#4 + { + #3 {#2} {#4} \__sort_quick_only_ii:NnnnnNn \__sort_quick_only_i:NnnnnNn + \__sort_quick_single_end:nnnwnw + { #3 {#4} } { } { } {#2} + } +\cs_new:Npn \__sort_quick_only_i:NnnnnNn #1#2#3#4#5#6#7 + { + #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn \__sort_quick_only_i:NnnnnNn + \__sort_quick_only_i_end:nnnwnw + { #6 {#7} } { #3 #2 } { } {#5} + } +\cs_new:Npn \__sort_quick_only_ii:NnnnnNn #1#2#3#4#5#6#7 + { + #6 {#5} {#7} \__sort_quick_only_ii:NnnnnNn \__sort_quick_split_i:NnnnnNn + \__sort_quick_only_ii_end:nnnwnw + { #6 {#7} } { } { #4 #2 } {#5} + } +\cs_new:Npn \__sort_quick_split_i:NnnnnNn #1#2#3#4#5#6#7 + { + #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn \__sort_quick_split_i:NnnnnNn + \__sort_quick_split_end:nnnwnw + { #6 {#7} } { #3 #2 } {#4} {#5} + } +\cs_new:Npn \__sort_quick_split_ii:NnnnnNn #1#2#3#4#5#6#7 + { + #6 {#5} {#7} \__sort_quick_split_ii:NnnnnNn \__sort_quick_split_i:NnnnnNn + \__sort_quick_split_end:nnnwnw + { #6 {#7} } {#3} { #4 #2 } {#5} + } +\cs_new:Npn \__sort_quick_end:nnTFNn #1#2#3#4#5#6 {#5} +\cs_new:Npn \__sort_quick_single_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop + { #5 {#3} #6 \q_stop } +\cs_new:Npn \__sort_quick_only_i_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop + { + \__sort_quick_split:NnNn #1 + \__sort_quick_end:nnTFNn { } \q_mark {#5} + {#3} + #6 \q_stop + } +\cs_new:Npn \__sort_quick_only_ii_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop + { + \__sort_quick_split:NnNn #2 + \__sort_quick_end:nnTFNn { } \q_mark { #5 {#3} } + #6 \q_stop + } +\cs_new:Npn \__sort_quick_split_end:nnnwnw #1#2#3#4 \q_mark #5#6 \q_stop + { + \__sort_quick_split:NnNn #2 \__sort_quick_end:nnTFNn { } \q_mark + { + \__sort_quick_split:NnNn #1 + \__sort_quick_end:nnTFNn { } \q_mark {#5} + {#3} + } + #6 \q_stop + } +\cs_new_protected:Npn \__sort_error: + { + \cs_set_eq:NN \__sort_merge_blocks_aux: \prg_do_nothing: + \cs_set_eq:NN \__sort_merge_blocks: \prg_do_nothing: + \cs_set_protected:Npn \__sort_level: \use:x ##1 { \group_end: } + } +\cs_new_protected:Npn \__sort_disable_toksdef: + { \cs_set_eq:NN \toksdef \__sort_disabled_toksdef:n } +\cs_new_protected:Npn \__sort_disabled_toksdef:n #1 + { + \__msg_kernel_error:nnx { sort } { toksdef } + { \token_to_str:N #1 } + \__sort_error: + \tex_toksdef:D #1 + } +\__msg_kernel_new:nnnn { sort } { toksdef } + { Allocation~of~\iow_char:N\\toks~registers~impossible~while~sorting. } + { + The~comparison~code~used~for~sorting~a~list~has~attempted~to~ + define~#1~as~a~new~\iow_char:N\\toks~register~using~\iow_char:N\\newtoks~ + or~a~similar~command.~The~list~will~not~be~sorted. + } +\cs_new_protected:Npn \__sort_too_long_error:NNw #1#2 \fi: + { + \fi: + \__msg_kernel_error:nnxxx { sort } { too-large } + { \token_to_str:N #2 } + { \int_eval:n { \l__sort_true_max_int - \l__sort_min_int } } + { \int_eval:n { \l__sort_top_int - \l__sort_min_int } } + #1 \__sort_error: + } +\__msg_kernel_new:nnnn { sort } { too-large } + { The~list~#1~is~too~long~to~be~sorted~by~TeX. } + { + TeX~has~#2~toks~registers~still~available:~ + this~only~allows~to~sort~with~up~to~#3~ + items.~All~extra~items~will~be~deleted. + } +\__msg_kernel_new:nnnn { sort } { return-none } + { The~comparison~code~did~not~return. } + { + When~sorting~a~list,~the~code~to~compare~items~#1~and~#2~ + did~not~call~ + \iow_char:N\\sort_return_same: ~nor~ + \iow_char:N\\sort_return_swapped: .~ + Exactly~one~of~these~should~be~called. + } +\__msg_kernel_new:nnnn { sort } { return-two } + { The~comparison~code~returned~multiple~times. } + { + When~sorting~a~list,~the~code~to~compare~items~called~ + \iow_char:N\\sort_return_same: ~or~ + \iow_char:N\\sort_return_swapped: ~multiple~times.~ + Exactly~one~of~these~should~be~called. + } +\cs_new_eq:NN \sort_ordered: \sort_return_same: +\cs_new_eq:NN \sort_reversed: \sort_return_swapped: %% File: l3box.dtx Copyright (C) 2005-2016 The LaTeX3 Project \GetIdInfo$Id: l3box.dtx 6805 2016-12-28 22:15:52Z joseph $ {L3 Experimental boxes} @@ -16617,7 +17017,7 @@ \str_const:Nn \c_sys_output_str { dvi } } %% File: l3candidates.dtx Copyright (C) 2012-2016 The LaTeX3 Project -\GetIdInfo$Id: l3candidates.dtx 6809 2017-01-01 06:33:13Z bruno $ +\GetIdInfo$Id: l3candidates.dtx 6835 2017-01-30 21:25:17Z bruno $ {L3 Experimental additions to l3kernel} \cs_new_protected:Npn \cs_log:N { \__msg_log_next: \cs_show:N } @@ -17482,8 +17882,6 @@ \cs_new_protected:Npn \prop_log:N { \__msg_log_next: \prop_show:N } \cs_generate_variant:Nn \prop_log:N { c } -\cs_new:Npn \prop_rand_key:N { \__prop_rand:NN \use_i:nnn } -\cs_new:Npn \prop_rand_value:N { \__prop_rand:NN \use_none:n } \cs_new:Npn \prop_rand_key_value:N { \__prop_rand:NN \__prop_rand:nNn } \cs_new:Npn \__prop_rand:nNn #1#2#3 { \exp_not:n { {#1} {#3} } } \cs_new:Npn \__prop_rand:NN #1#2 @@ -17502,8 +17900,6 @@ \exp_after:wN \__prop_rand_item:Nw \exp_after:wN #1 \__int_value:w \int_eval:n { #2 - \c_one } \s__prop } -\cs_generate_variant:Nn \prop_rand_key:N { c } -\cs_generate_variant:Nn \prop_rand_value:N { c } \cs_generate_variant:Nn \prop_rand_key_value:N { c } \cs_new:Npn \seq_mapthread_function:NNN #1#2#3 { \exp_after:wN \__seq_mapthread_function:wNN #2 \q_stop #1 #3 } |