diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3file.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3file.sty | 180 |
1 files changed, 43 insertions, 137 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3file.sty b/Master/texmf-dist/tex/latex/l3kernel/l3file.sty index b1a119b7fd3..f86225c08d8 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3file.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3file.sty @@ -13,7 +13,7 @@ %% %% Do not distribute a modified version of this file. %% -%% File: l3file.dtx Copyright (C) 1990-2012 The LaTeX3 Project +%% File: l3file.dtx Copyright (C) 1990-2013 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 @@ -46,7 +46,7 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{l3bootstrap} -\GetIdInfo$Id: l3file.dtx 4377 2012-12-20 11:13:29Z bruno $ +\GetIdInfo$Id: l3file.dtx 4446 2013-01-14 00:03:17Z bruno $ {L3 File and I/O operations} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -182,33 +182,12 @@ { \seq_gput_right:No \g__file_record_seq { \tl_to_str:n {#1} } } } \cs_new_eq:NN \c_term_ior \c_sixteen -\tl_const:Nn \c__ior_streams_tl - { - \c_zero - \c_one - \c_two - \c_three - \c_four - \c_five - \c_six - \c_seven - \c_eight - \c_nine - \c_ten - \c_eleven - \c_twelve - \c_thirteen - \c_fourteen - \c_fifteen - } +\seq_new:N \g__ior_streams_seq +\tl_new:N \l__ior_stream_tl \prop_new:N \g__ior_streams_prop -\prop_put:Nnn \g__ior_streams_prop { 0 } { LaTeX2e~reserved } -\int_new:N \l__ior_stream_int -\cs_set_eq:NN \__ior_new:N \newread -\cs_generate_variant:Nn \__ior_new:N { c } +\prop_gput:Nnn \g__ior_streams_prop { 0 } { LaTeX2e~reserved } \cs_new_protected:Npn \ior_new:N #1 { \cs_new_eq:NN #1 \c_term_ior } \cs_generate_variant:Nn \ior_new:N { c } -\ior_new:N \g__file_internal_ior \cs_new_protected:Npn \ior_open:Nn #1#2 { \__file_name_sanitize:nn {#2} { \__ior_open_aux:Nn #1 } } \cs_generate_variant:Nn \ior_open:Nn { c } @@ -220,7 +199,10 @@ { \__ior_open:No #1 \l__file_internal_name_tl } } \prg_new_protected_conditional:Npnn \ior_open:Nn #1#2 { T , F , TF } - { \__file_name_sanitize:nn {#2} { \__ior_open_aux:NnTF #1 } } + { \__file_name_sanitize:nn {#2} { \__ior_open:NnTF #1 } } +\cs_generate_variant:Nn \ior_open:NnT { c } +\cs_generate_variant:Nn \ior_open:NnF { c } +\cs_generate_variant:Nn \ior_open:NnTF { c } \cs_new_protected:Npn \__ior_open_aux:NnTF #1#2 { \file_add_path:nN {#2} \l__file_internal_name_tl @@ -231,71 +213,33 @@ \prg_return_true: } } -\cs_generate_variant:Nn \ior_open:NnT { c } -\cs_generate_variant:Nn \ior_open:NnF { c } -\cs_generate_variant:Nn \ior_open:NnTF { c } \cs_new_protected:Npn \__ior_open:Nn #1#2 { \ior_close:N #1 - \int_set_eq:NN \l__ior_stream_int \c_sixteen - \tl_map_function:NN \c__ior_streams_tl \__ior_alloc:n - \int_compare:nNnTF \l__ior_stream_int = \c_sixteen - { \__msg_kernel_fatal:nn { kernel } { input-streams-exhausted } } + \seq_gpop:NNTF \g__ior_streams_seq \l__ior_stream_tl + { \__ior_open_stream:Nn #1 {#2} } { - \__ior_alloc:N #1 - \prop_gput:NVn \g__ior_streams_prop \l__ior_stream_int {#2} - \tex_openin:D #1#2 \scan_stop: + \newread #1 + \tl_set:Nx \l__ior_stream_tl { \int_eval:n {#1} } + \__ior_open_stream:Nn #1 {#2} } } \cs_generate_variant:Nn \__ior_open:Nn { No } -\cs_new_protected:Npn \__ior_alloc:n #1 +\cs_new_protected:Npn \__ior_open_stream:Nn #1#2 { - \prop_if_in:NnF \g__ior_streams_prop {#1} - { - \int_set:Nn \l__ior_stream_int {#1} - \tl_map_break: - } - } -\ior_new:N \g__ior_internal_ior -\cs_new_protected:Npn \__ior_alloc:N #1 - { - \cs_if_exist:cF { g_ior_ \int_use:N \l__ior_stream_int _ior } - { - \__ior_alloc: - \int_compare:nNnT \l__ior_stream_int = \c_sixteen - { - \__ior_new:N \g__ior_internal_ior - \int_set:Nn \l__ior_stream_int { \g__ior_internal_ior } - \cs_gset_eq:cN - { g_ior_ \int_use:N \l__ior_stream_int _ior } \g__ior_internal_ior - } - } - \cs_gset_eq:Nc #1 { g_ior_ \int_use:N \l__ior_stream_int _ior } - } -\cs_new_protected_nopar:Npn \__ior_alloc: - { - \int_incr:N \l__ior_stream_int - \int_compare:nNnT \l__ior_stream_int < \c_sixteen - { - \cs_if_exist:cTF { g_ior_ \int_use:N \l__ior_stream_int _ior } - { - \prop_if_in:NVT \g__ior_streams_prop \l__ior_stream_int - { \__ior_alloc: } - } - { \__ior_alloc: } - } + \tex_global:D \tex_chardef:D #1 = \l__ior_stream_tl \scan_stop: + \prop_gput:NVn \g__ior_streams_prop #1 {#2} + \tex_openin:D #1 #2 \scan_stop: } \cs_new_protected:Npn \ior_close:N #1 { - \__chk_if_exist_cs:N #1 - \int_compare:nNnF #1 < \c_zero + \int_compare:nT { \c_minus_one < #1 < \c_sixteen } { - \int_compare:nNnF #1 > \c_fifteen - { - \tex_closein:D #1 - \prop_gremove:NV \g__ior_streams_prop #1 - \cs_gset_eq:NN #1 \c_term_ior - } + \tex_closein:D #1 + \prop_gremove:NV \g__ior_streams_prop #1 + \seq_if_in:NVF \g__ior_streams_seq #1 + { \seq_gpush:NV \g__ior_streams_seq #1 } + \cs_gset_eq:NN #1 \c_term_ior } } \cs_generate_variant:Nn \ior_close:N { c } @@ -337,16 +281,15 @@ \int_set:Nn \tex_endlinechar:D { \int_use:N \tex_endlinechar:D } } } +\ior_new:N \g__file_internal_ior \cs_new_eq:NN \c_log_iow \c_minus_one \cs_new_eq:NN \c_term_iow \c_sixteen -\cs_new_eq:NN \c__iow_streams_tl \c__ior_streams_tl +\seq_new:N \g__iow_streams_seq +\tl_new:N \l__iow_stream_tl \prop_new:N \g__iow_streams_prop \prop_put:Nnn \g__iow_streams_prop { 0 } { LaTeX2e~reserved } \prop_put:Nnn \g__iow_streams_prop { 1 } { LaTeX2e~reserved } \prop_put:Nnn \g__iow_streams_prop { 2 } { LaTeX2e~reserved } -\cs_new_eq:NN \l__iow_stream_int \l__ior_stream_int -\cs_set_eq:NN \__iow_new:N \newwrite -\cs_generate_variant:Nn \__iow_new:N { c } \cs_new_protected:Npn \iow_new:N #1 { \cs_new_eq:NN #1 \c_term_iow } \cs_generate_variant:Nn \iow_new:N { c } \cs_new_protected:Npn \iow_open:Nn #1#2 @@ -355,64 +298,30 @@ \cs_new_protected:Npn \__iow_open:Nn #1#2 { \iow_close:N #1 - \int_set_eq:NN \l__iow_stream_int \c_sixteen - \tl_map_function:NN \c__iow_streams_tl \__iow_alloc:n - \int_compare:nNnTF \l__iow_stream_int = \c_sixteen - { \__msg_kernel_fatal:nn { kernel } { output-streams-exhausted } } - { - \__iow_alloc:N #1 - \prop_gput:NVn \g__iow_streams_prop \l__iow_stream_int {#2} - \tex_immediate:D \tex_openout:D #1#2 \scan_stop: - } - } -\cs_new_protected:Npn \__iow_alloc:n #1 - { - \prop_if_in:NnF \g__iow_streams_prop {#1} - { - \int_set:Nn \l__iow_stream_int {#1} - \tl_map_break: - } - } -\iow_new:N \g__iow_internal_iow -\cs_new_protected:Npn \__iow_alloc:N #1 - { - \cs_if_exist:cF { g_iow_ \int_use:N \l__iow_stream_int _iow } + \seq_gpop:NNTF \g__iow_streams_seq \l__iow_stream_tl + { \__iow_open_stream:Nn #1 {#2} } { - \__iow_alloc: - \int_compare:nNnT \l__iow_stream_int = \c_sixteen - { - \__iow_new:N \g__iow_internal_iow - \int_set:Nn \l__iow_stream_int { \g__iow_internal_iow } - \cs_gset_eq:cN - { g_iow_ \int_use:N \l__iow_stream_int _iow } \g__iow_internal_iow - } + \newwrite #1 + \tl_set:Nx \l__iow_stream_tl { \int_eval:n {#1} } + \__iow_open_stream:Nn #1 {#2} } - \cs_gset_eq:Nc #1 { g_iow_ \int_use:N \l__iow_stream_int _iow } } -\cs_new_protected_nopar:Npn \__iow_alloc: +\cs_generate_variant:Nn \__iow_open:Nn { No } +\cs_new_protected:Npn \__iow_open_stream:Nn #1#2 { - \int_incr:N \l__iow_stream_int - \int_compare:nNnT \l__iow_stream_int < \c_sixteen - { - \cs_if_exist:cTF { g_iow_ \int_use:N \l__iow_stream_int _iow } - { - \prop_if_in:NVT \g__iow_streams_prop \l__iow_stream_int - { \__iow_alloc: } - } - { \__iow_alloc: } - } + \tex_global:D \tex_chardef:D #1 = \l__iow_stream_tl \scan_stop: + \prop_gput:NVn \g__iow_streams_prop #1 {#2} + \tex_immediate:D \tex_openout:D #1 #2 \scan_stop: } \cs_new_protected:Npn \iow_close:N #1 { - \__chk_if_exist_cs:N #1 - \int_compare:nNnF #1 < \c_zero + \int_compare:nT { \c_minus_one < #1 < \c_sixteen } { - \int_compare:nNnF #1 > \c_fifteen - { - \tex_immediate:D \tex_closeout:D #1 - \prop_gremove:NV \g__iow_streams_prop #1 - \cs_gset_eq:NN #1 \c_term_iow - } + \tex_immediate:D \tex_closeout:D #1 + \prop_gremove:NV \g__iow_streams_prop #1 + \seq_if_in:NVF \g__iow_streams_seq #1 + { \seq_gpush:NV \g__iow_streams_seq #1 } + \cs_gset_eq:NN #1 \c_term_ior } } \cs_generate_variant:Nn \iow_close:N { c } @@ -634,9 +543,6 @@ Spaces~are~not~permitted~in~files~loaded~by~LaTeX: \\ Further~errors~may~follow! } -\cs_new_protected:Npn \iow_wrap:xnnnN #1#2#3#4#5 - { \iow_wrap:nnnN {#1} {#2} {#4} #5 } -\cs_new_eq:NN \l_iow_line_length_int \l_iow_line_count_int \cs_new_eq:NN \ior_to:NN \ior_get:NN \cs_new_protected_nopar:Npn \ior_gto:NN { \tex_global:D \ior_to:NN } \cs_new_eq:NN \ior_str_to:NN \ior_get_str:NN |