diff options
author | Karl Berry <karl@freefriends.org> | 2024-01-05 21:42:46 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-01-05 21:42:46 +0000 |
commit | 6aaa0d32d81bf1387c1f9c811889f09b6a4a7767 (patch) | |
tree | 6c240f6dd1b7aa9a949f1851bbf286ba798790ff /Master/texmf-dist/tex/latex | |
parent | 7e7d846832cfc0229d189eaa73eb7e131cbfd1d6 (diff) |
morewrites (5jan24)
git-svn-id: svn://tug.org/texlive/trunk@69306 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/morewrites/morewrites.sty | 174 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/morewrites/primargs.sty | 15 |
2 files changed, 140 insertions, 49 deletions
diff --git a/Master/texmf-dist/tex/latex/morewrites/morewrites.sty b/Master/texmf-dist/tex/latex/morewrites/morewrites.sty index 38b7b39f436..436f95b44e6 100644 --- a/Master/texmf-dist/tex/latex/morewrites/morewrites.sty +++ b/Master/texmf-dist/tex/latex/morewrites/morewrites.sty @@ -6,10 +6,10 @@ %% %% morewrites.dtx (with options: `package') %% -%% Communicate any suggestions for changing this package -%% to Bruno Le Floch (blflatex@gmail.com). +%% Suggestions/comments/bug reports welcome at +%% https://github.com/blefloch/latex-morewrites %% -%% File: morewrites.dtx Copyright (C) 2011-2018 Bruno Le Floch +%% File: morewrites.dtx Copyright (C) 2011-2024 Bruno Le Floch %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -21,10 +21,9 @@ %% This work has the LPPL maintenance status 'maintained' %% and the current maintainer is Bruno Le Floch. %% ----------------------------------------------------------------------- -\RequirePackage {expl3} [2018/02/21] -\RequirePackage {primargs} [2018/12/29] +\RequirePackage {primargs} [2024/01/05] \ProvidesExplPackage - {morewrites} {2018/12/29} {} {Always room for a new write} + {morewrites} {2024/01/05} {} {Always room for a new write} \sys_if_engine_luatex:T { \cs_new_protected:Npn \morewritessetup #1 { } @@ -43,7 +42,9 @@ \cs_generate_variant:Nn \prop_gput:Nnn { NVx } \cs_generate_variant:Nn \tl_gput_right:Nn { Nv } \tl_new:N \l__morewrites_internal_tl +\seq_new:N \l__morewrites_internal_seq \cs_new_eq:NN \__morewrites_tmp:w ? +\bool_new:N \l__morewrites_verbose_bool \int_new:N \g__morewrites_later_int \seq_new:N \g__morewrites_write_seq \prop_new:N \g__morewrites_write_prop @@ -60,6 +61,8 @@ \bool_gset_false:N \g__morewrites_tmp_file_bool \int_new:N \g__morewrites_group_level_int \box_new:N \g__morewrites_shipout_box +\cs_new_protected:Npn \__morewrites_verbose:n #1 + { \bool_if:NT \l__morewrites_verbose_bool { \iow_term:e { morewrites:~#1 } } } \cs_new_protected:Npn \__morewrites_set_file:n #1 { \bool_gset_false:N \g__morewrites_tmp_file_bool @@ -68,14 +71,14 @@ \cs_new_protected:Npn \__morewrites_empty_file:n #1 { \__morewrites_tex_immediate:w \__morewrites_tex_openout:w - \g__morewrites_iow = #1 \scan_stop: + \g__morewrites_iow = {#1} \scan_stop: \__morewrites_tex_immediate:w \__morewrites_tex_closeout:w \g__morewrites_iow } \prg_new_conditional:Npnn \__morewrites_if_file_trivial:n #1 { TF } { \group_begin: - \tex_openin:D \g__morewrites_ior = #1 \scan_stop: + \tex_openin:D \g__morewrites_ior = {#1} \if_eof:w \g__morewrites_ior \cs_gset_eq:NN \__morewrites_tmp:w \prg_return_true: \else: @@ -93,16 +96,32 @@ } \cs_new_protected:Npn \__morewrites_chk_file: { + \tl_gset:Ne \g__morewrites_tmp_file_tl + { \tl_to_str:e { \g__morewrites_tmp_file_tl } } \__morewrites_if_file_trivial:nTF { \g__morewrites_tmp_file_tl } { \bool_gset_true:N \g__morewrites_tmp_file_bool } { + \__morewrites_chk_file_aux: \msg_warning:nnxx { morewrites } { file-exists } - { \g__morewrites_tmp_file_tl } - { \g__morewrites_tmp_file_tl .mw } - \tl_gput_right:Nn \g__morewrites_tmp_file_tl { .mw } + { \g__morewrites_tmp_file_tl } { \l__morewrites_internal_tl } + \tl_gset_eq:NN \g__morewrites_tmp_file_tl \l__morewrites_internal_tl \__morewrites_chk_file: } } +\cs_new_protected:Npn \__morewrites_chk_file_aux: + { + \regex_extract_once:nVNTF + { \A (\D*) (\d*) .mw \Z } \g__morewrites_tmp_file_tl \l__morewrites_internal_seq + { + \tl_set:Ne \l__morewrites_internal_tl + { + \seq_item:Nn \l__morewrites_internal_seq { 2 } + \int_eval:n { \seq_item:Nn \l__morewrites_internal_seq { 3 } + 1 } + .mw + } + } + { \tl_set:Ne \l__morewrites_internal_tl { \g__morewrites_tmp_file_tl .mw } } + } \msg_new:nnnn { morewrites } { file-exists } { File~'#1'~exists,~using~'#2'~instead. } { @@ -117,7 +136,7 @@ \cs_new_protected:Npn \__morewrites_equals_file:N #1 { \group_begin: - \tex_aftergroup:D \primargs_get_file_name:N + \tex_aftergroup:D \primargs_get_input_file_name:N \tex_aftergroup:D #1 \primargs_remove_equals:N \group_end: } @@ -130,7 +149,7 @@ \cs_new_protected:Npn \__morewrites_user_to_tstr:NTF #1 { \tl_set:NV \l__morewrites_tstr_tl \l__morewrites_user_int - \int_compare:nNnTF { \l__morewrites_user_int } < { 19 } + \int_compare:nNnTF { \l__morewrites_user_int } < { 129 } { \use_i:nn } { \prop_get:NVNTF #1 \l__morewrites_user_int \l__morewrites_tstr_tl } } @@ -180,7 +199,11 @@ { \token_if_eq_meaning:NNTF \g_primargs_token \s__morewrites { \__morewrites_immediate_auxiii:N } - { \__morewrites_tex_immediate:w } + { + \__morewrites_verbose:n + { \tl_to_str:n { \immediate } \token_to_meaning:N \g_primargs_token } + \__morewrites_tex_immediate:w + } } \cs_new_protected:Npn \__morewrites_immediate_auxiii:N #1 { \str_if_eq:nnTF { #1 } { \s__morewrites } { \use_iii:nnn } { #1 } } @@ -193,6 +216,11 @@ } \cs_new_protected:Npn \__morewrites_closeout_now: { + \__morewrites_verbose:n { \tl_to_str:n { \immediate \closeout } \int_use:N \l__morewrites_user_int } + \__morewrites_closeout_now_silent: + } +\cs_new_protected:Npn \__morewrites_closeout_now_silent: + { \__morewrites_user_to_tstr:NTF \g__morewrites_write_prop { \__morewrites_tex_immediate:w \__morewrites_tex_closeout:w \l__morewrites_tstr_tl \exp_stop_f: @@ -209,7 +237,7 @@ } \cs_new_protected:Npn \__morewrites_closeout_now:nn #1#2 { - \__morewrites_tex_immediate:w \__morewrites_tex_openout:w \g__morewrites_iow = #2 \scan_stop: + \__morewrites_tex_immediate:w \__morewrites_tex_openout:w \g__morewrites_iow = {#2} \group_begin: \int_set:Nn \tex_newlinechar:D { -1 } \tl_use:c { \__morewrites_user_tl_name:n {#1} } @@ -226,18 +254,28 @@ } \cs_new_protected:Npn \__morewrites_openout_now:n #1 { - \__morewrites_closeout_now: - \int_compare:nNnTF { \l__morewrites_user_int } < { 19 } + \__morewrites_verbose:n + { + \tl_to_str:n { \immediate\openout } + \int_use:N \l__morewrites_user_int + \c_space_tl = ~ {#1} + } + \__morewrites_openout_now_silent:n {#1} + } +\cs_new_protected:Npn \__morewrites_openout_now_silent:n #1 + { + \__morewrites_closeout_now_silent: + \int_compare:nNnTF { \l__morewrites_user_int } < { 129 } { \__morewrites_tex_immediate:w \__morewrites_tex_openout:w \l__morewrites_user_int - = \tl_to_str:n {#1} \scan_stop: + = { \tl_to_str:n {#1} } } { \seq_gpop:NNTF \g__morewrites_write_seq \l__morewrites_tstr_tl { \prop_gput:NVV \g__morewrites_write_prop \l__morewrites_user_int \l__morewrites_tstr_tl \__morewrites_tex_immediate:w \__morewrites_tex_openout:w \l__morewrites_tstr_tl \exp_stop_f: - = \tl_to_str:n {#1} \scan_stop: + = { \tl_to_str:n {#1} } } { \__morewrites_empty_file:n {#1} @@ -257,27 +295,54 @@ \cs_new_protected:Npn \__morewrites_write_now:w { \__morewrites_user_to_tstr:NTF \g__morewrites_write_prop - { \__morewrites_tex_immediate:w \__morewrites_tex_write:w \l__morewrites_tstr_tl \exp_stop_f: } + { + \int_compare:nNnT \l__morewrites_user_int = { 18 } { \use_iii:nnn } + \int_compare:nT { -1 < \l__morewrites_user_int < 16 } + { + \__morewrites_verbose:n + { + \tl_to_str:n { \immediate \write } + \int_use:N \l__morewrites_user_int + } + } + \__morewrites_tex_immediate:w \__morewrites_tex_write:w \l__morewrites_tstr_tl \exp_stop_f: + } { \primargs_get_general_text:N \__morewrites_write_now:n } } -\cs_new_protected:Npn \__morewrites_write_now:n +\cs_new_protected:Npn \__morewrites_write_now:n #1 { \prop_get:NVNTF \g__morewrites_write_file_prop \l__morewrites_user_int \l__morewrites_internal_tl - { \__morewrites_write_now_open:n } - { \__morewrites_tex_immediate:w \__morewrites_tex_write:w 16 } + { + \__morewrites_verbose:n + { + \tl_to_str:n { \immediate \write } + \int_use:N \l__morewrites_user_int + \tl_to_str:n { ~ {#1} } + } + \__morewrites_write_now_open:n {#1} + } + { + \__morewrites_verbose:n + { + \tl_to_str:n { \immediate \write } + \int_use:N \l__morewrites_user_int + \tl_to_str:n { ~ (closed) ~ {#1} } + } + \__morewrites_tex_immediate:w \__morewrites_tex_write:w 16 {#1} + } } \cs_new_protected:Npn \__morewrites_write_now_open:n #1 { \bool_if:NF \g__morewrites_tmp_file_bool { \__morewrites_chk_file: } \__morewrites_tex_immediate:w \__morewrites_tex_openout:w - \g__morewrites_iow = \g__morewrites_tmp_file_tl \scan_stop: + \g__morewrites_iow = { \g__morewrites_tmp_file_tl } \__morewrites_tex_immediate:w \__morewrites_tex_write:w \g__morewrites_iow {#1} \__morewrites_tex_immediate:w \__morewrites_tex_closeout:w \g__morewrites_iow \group_begin: \int_set:Nn \tex_endlinechar:D { -1 } - \tex_openin:D \g__morewrites_ior = \g__morewrites_tmp_file_tl \scan_stop: + \tex_openin:D \g__morewrites_ior = { \g__morewrites_tmp_file_tl } \__morewrites_write_now_loop: \tex_closein:D \g__morewrites_ior \__morewrites_collect_gput_right:c @@ -319,37 +384,64 @@ { \tl_use:c { c__morewrites_later_ \int_eval:n {#1} _tl } } \cs_new_protected:Npn \__morewrites_closeout_later: { - \int_compare:nNnTF \l__morewrites_user_int < { 19 } + \__morewrites_verbose:n { \tl_to_str:n { \closeout (later) ~ } \int_use:N \l__morewrites_user_int } + \int_compare:nNnTF \l__morewrites_user_int < { 129 } { \__morewrites_tex_closeout:w \l__morewrites_user_int } - { \__morewrites_later:n { \__morewrites_closeout_now: } } + { \__morewrites_later:n { \__morewrites_closeout_now_silent: } } } \cs_new_protected:Npn \__morewrites_openout_later:w { - \int_compare:nNnTF \l__morewrites_user_int < { 19 } - { \__morewrites_tex_openout:w \l__morewrites_user_int } + \int_compare:nNnTF \l__morewrites_user_int < { 129 } + { + \__morewrites_verbose:n { \tl_to_str:n { \openout (later) ~ } \int_use:N \l__morewrites_user_int } + \__morewrites_tex_openout:w \l__morewrites_user_int + } { \__morewrites_equals_file:N \__morewrites_openout_later:n } } \cs_new_protected:Npn \__morewrites_openout_later:n #1 - { \__morewrites_later:n { \__morewrites_openout_now:n {#1} } } + { + \__morewrites_verbose:n + { + \tl_to_str:n { \openout (later)~ } + \int_use:N \l__morewrites_user_int + \c_space_tl = ~ {#1} + } + \__morewrites_later:n { \__morewrites_openout_now_silent:n {#1} } + } \cs_new_protected:Npn \__morewrites_write_later:w { - \int_compare:nNnTF \l__morewrites_user_int < { 19 } - { \__morewrites_tex_write:w \l__morewrites_user_int } + \int_compare:nNnTF \l__morewrites_user_int < { 129 } + { + \__morewrites_verbose:n { \tl_to_str:n { \write (later)~ } \int_use:N \l__morewrites_user_int } + \__morewrites_tex_write:w \l__morewrites_user_int + } { \primargs_get_general_text:N \__morewrites_write_later:n } } \cs_new_protected:Npn \__morewrites_write_later:n #1 - { \__morewrites_later:n { \__morewrites_write_later_aux:n {#1} } } + { + \__morewrites_verbose:n + { + \tl_to_str:n { \write (later)~ } + \int_use:N \l__morewrites_user_int + \tl_to_str:n { ~ {#1} } + } + \__morewrites_later:n { \__morewrites_write_later_aux:n {#1} } + } \cs_new_protected:Npn \__morewrites_write_later_aux:n { \__morewrites_user_to_tstr:NTF \g__morewrites_write_prop { \__morewrites_tex_immediate:w \__morewrites_tex_write:w \l__morewrites_tstr_tl \exp_stop_f: } - { \__morewrites_write_now:n } + { + \prop_get:NVNTF \g__morewrites_write_file_prop \l__morewrites_user_int \l__morewrites_internal_tl + { \__morewrites_write_now_open:n } + { \__morewrites_tex_immediate:w \__morewrites_tex_write:w 16 \exp_stop_f: } + } } \cs_new_protected:Npn \__morewrites_before_shipout: { \bool_if:NF \g__morewrites_tmp_file_bool { \__morewrites_chk_file: } \__morewrites_tex_immediate:w \__morewrites_tex_openout:w - \g__morewrites_iow = \g__morewrites_tmp_file_tl \scan_stop: + \g__morewrites_iow = { \g__morewrites_tmp_file_tl } } \cs_new_protected:Npn \__morewrites_after_shipout: { @@ -364,7 +456,7 @@ \tl_set:Nx \l__morewrites_internal_tl { \exp_after:wN \__morewrites_after_shipout_loop:ww - \tex_input:D \g__morewrites_tmp_file_tl \c_space_tl + \tex_input:D { \g__morewrites_tmp_file_tl } } \__morewrites_empty_file:n { \g__morewrites_tmp_file_tl } \exp_args:NNo @@ -436,7 +528,10 @@ \cs_new_protected:Npn \__morewrites_close_all: { \prop_map_inline:Nn \g__morewrites_write_prop - { \__morewrites_tex_immediate:w \__morewrites_tex_closeout:w ##2 \scan_stop: } + { + \__morewrites_verbose:n { \tl_to_str:n { \immediate \closeout } ##1 ~ (at~end) } + \__morewrites_tex_immediate:w \__morewrites_tex_closeout:w ##2 \scan_stop: + } \prop_gclear:N \g__morewrites_write_prop \prop_map_function:NN \g__morewrites_write_file_prop \__morewrites_closeout_now:nn @@ -451,7 +546,7 @@ } \AtEndDocument { \__morewrites_close_all_at_end:nw { 5 } } \int_new:N \g__morewrites_alloc_write_int -\int_gset:Nn \g__morewrites_alloc_write_int { 18 } +\int_gset:Nn \g__morewrites_alloc_write_int { 128 } \cs_new_protected:Npn \__morewrites_newwrite:N #1 { \int_gincr:N \g__morewrites_alloc_write_int @@ -485,7 +580,8 @@ { allocate .code:n = \__morewrites_allocate:n {#1} , file .code:n = \__morewrites_set_file:n {#1} , - file .initial:n = \c_sys_jobname_str .mw + file .initial:n = \c_sys_jobname_str .mw , + verbose .bool_set:N = \l__morewrites_verbose_bool } \cs_gset_eq:NN \immediate \__morewrites_immediate:w \cs_gset_eq:NN \openout \__morewrites_openout:w diff --git a/Master/texmf-dist/tex/latex/morewrites/primargs.sty b/Master/texmf-dist/tex/latex/morewrites/primargs.sty index 0211368429c..111b2f657f0 100644 --- a/Master/texmf-dist/tex/latex/morewrites/primargs.sty +++ b/Master/texmf-dist/tex/latex/morewrites/primargs.sty @@ -6,10 +6,10 @@ %% %% primargs.dtx (with options: `package') %% -%% Communicate any suggestions for changing this package -%% to Bruno Le Floch (blflatex@gmail.com). +%% Suggestions/comments/bug reports welcome at +%% https://github.com/blefloch/latex-morewrites %% -%% File: primargs.dtx Copyright (C) 2012-2018 Bruno Le Floch +%% File: primargs.dtx Copyright (C) 2012-2024 Bruno Le Floch %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -21,9 +21,8 @@ %% This work has the LPPL maintenance status 'maintained' %% and the current maintainer is Bruno Le Floch. %% ----------------------------------------------------------------------- -\RequirePackage {expl3} [2018/02/21] \ProvidesExplPackage - {primargs} {2018/12/29} {} {Parsing arguments of primitives} + {primargs} {2024/01/05} {} {Parsing arguments of primitives} \tl_new:N \g__primargs_code_tl \tl_new:N \g__primargs_file_name_tl \tl_new:N \g__primargs_file_name_level_tl @@ -259,7 +258,7 @@ } \cs_new_protected:Npn \__primargs_get_file_name_char: { - \token_if_eq_charcode:NNT " \g_primargs_token + \token_if_eq_charcode:NNT " \g_primargs_token % " { \tl_gset:Nx \g__primargs_file_name_level_tl { \int_eval:n { 1 - \g__primargs_file_name_level_tl } } @@ -275,8 +274,6 @@ \cs_new:Npn \__primargs_get_file_name_char_ii:w #1 ~ #2 ~ #3 \q_stop { \__primargs_get_file_name_char_iii:w #3 ~ #3 ~ \q_stop } \cs_new:Npn \__primargs_get_file_name_char_iii:w #1 ~ #2 ~ #3 \q_stop {#2} -\sys_if_engine_luatex:TF - { \cs_new_protected:Npn \primargs_get_input_file_name:N #1 { \group_begin: @@ -343,8 +340,6 @@ } \__primargs_get_input_file_name_loop: } - } - { \cs_new_eq:NN \primargs_get_input_file_name:N \primargs_get_file_name:N } %% %% %% End of file `primargs.sty'. |