%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /data/old/usr/share/texlive/texmf-dist/tex/latex/l3experimental/l3sort/
Upload File :
Create Path :
Current File : //data/old/usr/share/texlive/texmf-dist/tex/latex/l3experimental/l3sort/l3sort.sty

%%
%% This is file `l3sort.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3sort.dtx  (with options: `package')
%% 
%% EXPERIMENTAL CODE
%% 
%% Do not distribute this file without also distributing the
%% source files specified above.
%% 
%% Do not distribute a modified version of this file.
%% 
%% File l3sort.dtx (C) Copyright 2012 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
%% license or (at your option) any later version.  The latest version
%% of this license is in the file
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the "l3experimental bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
%% -----------------------------------------------------------------------
%%
%% The development version of the bundle can be found at
%%
%%    http://www.latex-project.org/svnroot/experimental/trunk/
%%
%% for those people who are interested.
%%
%%%%%%%%%%%
%% NOTE: %%
%%%%%%%%%%%
%%
%%   Snapshots taken from the repository represent work in progress and may
%%   not work or may contain conflicting material!  We therefore ask
%%   people _not_ to put them into distributions, archives, etc. without
%%   prior consultation with the LaTeX Project Team.
%%
%% -----------------------------------------------------------------------
%%
\RequirePackage{expl3}
\GetIdInfo$Id: l3sort.dtx 4339 2012-11-24 19:16:43Z joseph $
  {L3 Experimental sorting functions}
\ProvidesExplPackage
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\int_const:Nn \c__sort_max_length_int
  { \luatex_if_engine:TF { 49152 } { 24576 } }
\int_new:N \l__sort_length_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:Npn \tl_sort:nN #1#2 { \__sort_quick:nNn {#1} #2 { } }
\cs_new:Npn \__sort_quick:nNn #1#2
  {
    \exp_after:wN \__sort_quick:wn
      \use_none:n #1 \__prg_break_point:
    \__sort_quick:nnNnn { } { } #2
      #1
      { \__prg_break_point: }
      \__prg_break_point:
  }
\cs_new:Npn \__sort_quick:wn #1 \__prg_break_point: #2 {#2}
\cs_new:Npn \__sort_quick:nnNnn #1#2#3#4#5
  {
    \__prg_break: #5
      \__sort_quick:nnNnwn {#1} {#2}
      \__prg_break_point:
    #3 {#4} {#5}
      { \__sort_quick:nnNnn {#1} { #2 {#5} } }
      { \__sort_quick:nnNnn { #1 {#5} } {#2} }
          #3 {#4}
  }
\cs_new:Npn \__sort_quick:nnNnwn
    #1#2 \__prg_break_point: #3#4 #5 \__prg_break_point: #6
  {
    \__sort_quick:nNn {#2} #3
      { \__sort_quick:nNn {#1} #3 {#6} {#4} }
  }
\cs_new_protected:Npn \__sort_main:NNNnNn #1#2#3#4#5#6
  {
    \group_begin:
      \l__sort_length_int \c_zero
      #2 #5
        {
          \if_int_compare:w \l__sort_length_int = \c__sort_max_length_int
            \__sort_too_long_error:NNw #3 #5
          \fi:
          \tex_toks:D \l__sort_length_int {##1}
          \tex_advance:D \l__sort_length_int \c_one
        }
      \cs_set:Npn \sort_compare:nn ##1 ##2 { #6 }
      \l__sort_block_int \c_one
      \__sort_level:
      \use:x
        {
          \group_end:
          #1 \exp_not:N #5 {#4}
        }
  }
\cs_new_protected_nopar:Npn \seq_sort:Nn
  {
    \__sort_main:NNNnNn \tl_set:Nn
      \seq_map_inline:Nn \seq_map_break:
      { \__sort_toks:NNw \exp_not:N \__seq_item:n 0 ; }
  }
\cs_new_protected_nopar:Npn \seq_gsort:Nn
  {
    \__sort_main:NNNnNn \tl_gset:Nn
      \seq_map_inline:Nn \seq_map_break:
      { \__sort_toks:NNw \exp_not:N \__seq_item:n 0 ; }
  }
\cs_new_protected_nopar:Npn \tl_sort:Nn
  {
    \__sort_main:NNNnNn \tl_set:Nn
      \tl_map_inline:Nn \tl_map_break:
      { \__sort_toks:NNw \prg_do_nothing: \prg_do_nothing: 0 ; }
  }
\cs_new_protected_nopar:Npn \tl_gsort:Nn
  {
    \__sort_main:NNNnNn \tl_gset:Nn
      \tl_map_inline:Nn \tl_map_break:
      { \__sort_toks:NNw \prg_do_nothing: \prg_do_nothing: 0 ; }
  }
\cs_new_protected_nopar:Npn \clist_sort:Nn
  { \__sort_sort:NNn \tl_set:Nn }
\cs_new_protected_nopar:Npn \clist_gsort:Nn
  { \__sort_sort:NNn \tl_gset:Nn }
\cs_new_protected:Npn \__sort_sort:NNn #1#2#3
  {
    \clist_if_empty:NF #2
      {
        \__sort_main:NNNnNn #1
          \clist_map_inline:Nn \clist_map_break:
          {
            \exp_last_unbraced:Nf \use_none:n
              { \__sort_toks:NNw \exp_args:No \__clist_wrap_item:n 0 ; }
          }
          #2 {#3}
      }
  }
\cs_new:Npn \__sort_toks:NNw #1#2#3 ;
  {
    \if_int_compare:w #3 < \l__sort_length_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_use:N \__int_eval:w #3 + \c_one \exp_after:wN ;
    \fi:
  }
\cs_new_protected_nopar:Npn \__sort_level:
  {
    \if_int_compare:w \l__sort_block_int < \l__sort_length_int
      \l__sort_end_int \c_zero
      \__sort_merge_blocks:
      \tex_multiply:D \l__sort_block_int \c_two
      \exp_after:wN \__sort_level:
    \fi:
  }
\cs_new_protected_nopar: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 \__int_eval:w \l__sort_end_int < \l__sort_length_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_length_int
        \l__sort_end_int \l__sort_length_int
      \fi:
      \l__sort_B_int \l__sort_A_int
      \l__sort_C_int \l__sort_length_int
      \sort_copy_block:
      \tex_advance:D \l__sort_A_int \c_minus_one
      \tex_advance:D \l__sort_B_int \c_minus_one
      \tex_advance:D \l__sort_C_int \c_minus_one
      \__sort_merge_blocks_aux:
      \exp_after:wN \__sort_merge_blocks:
    \fi:
  }
\cs_new_protected_nopar: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_nopar: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 }
  }
\cs_new_protected_nopar:Npn \sort_ordered:
  {
    \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_C_int
    \tex_advance:D \l__sort_B_int \c_minus_one
    \tex_advance:D \l__sort_C_int \c_minus_one
    \if_int_compare:w \l__sort_C_int < \l__sort_length_int
      \use_i:nn
    \fi:
    \__sort_merge_blocks_aux:
  }
\cs_new_protected_nopar:Npn \sort_reversed:
  {
    \tex_toks:D \l__sort_B_int \tex_toks:D \l__sort_A_int
    \tex_advance:D \l__sort_B_int \c_minus_one
    \tex_advance:D \l__sort_A_int \c_minus_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_nopar: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_minus_one
    \tex_advance:D \l__sort_C_int \c_minus_one
    \if_int_compare:w \l__sort_B_int < \l__sort_begin_int
      \use_i:nn
    \fi:
    \__sort_merge_blocks_end:
  }
\cs_new_protected:Npn \__sort_too_long_error:NNw #1#2 \fi:
  {
    \fi:
    \__msg_kernel_error:nnx { sort } { too-large } { \token_to_str:N #2 }
    #1
  }
\__msg_kernel_new:nnnn { sort } { too-large }
  { The~list~#1~is~too~long~to~be~sorted~by~TeX. }
  {
    TeX~has~\int_eval:n { \c_max_register_int + 1 }~registers~available:~
    this~only~allows~to~sorts~with~up~to~\int_use:N \c__sort_max_length_int
    \ items.~All~extra~items~will~be~ignored.
  }
%% 
%%
%% End of file `l3sort.sty'.

Zerion Mini Shell 1.0