From 949a85bb8707bf1aaa2b23b018e24d5001d38e52 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 6 Jan 2024 03:01:33 +0000 Subject: CTAN sync 202401060301 --- macros/latex/contrib/morewrites/README.md | 18 +- macros/latex/contrib/morewrites/morewrites.dtx | 272 ++++++++++++++++++------- macros/latex/contrib/morewrites/morewrites.ins | 6 +- macros/latex/contrib/morewrites/morewrites.pdf | Bin 715831 -> 748706 bytes macros/latex/contrib/morewrites/primargs.dtx | 32 +-- macros/latex/contrib/morewrites/primargs.pdf | Bin 601061 -> 635774 bytes 6 files changed, 231 insertions(+), 97 deletions(-) (limited to 'macros/latex/contrib/morewrites') diff --git a/macros/latex/contrib/morewrites/README.md b/macros/latex/contrib/morewrites/README.md index aa31c5370a..eca82dee12 100644 --- a/macros/latex/contrib/morewrites/README.md +++ b/macros/latex/contrib/morewrites/README.md @@ -1,16 +1,16 @@ -Provide more writing streams in LaTeX +Always room for a new write stream ===================================== -* E-mail: blflatex+morewrites@gmail.com +* E-mail: blflatex@gmail.com * Released under the LaTeX Project Public License v1.3c or later See http://www.latex-project.org/lppl.txt -The morewrites LaTeX package should be used when encountering the -`No room for a new \write ` error. This is done by redefining a -few TeX primitives related to output. +The morewrites package silently hooks into the TeX primitives +responsible for writing to files to lift the restriction on +the number of files open at the same time (16). Load the package +with `\usepackage{morewrites}` as early as possible to avoid the +`No room for a new \write ` error. -This package uses the `l3kernel` bundle. - -This is work in progress, all suggestions/comments/bug reports -are welcome! See https://github.com/blefloch/latex-morewrites +Suggestions/comments/bug reports welcome at +https://github.com/blefloch/latex-morewrites diff --git a/macros/latex/contrib/morewrites/morewrites.dtx b/macros/latex/contrib/morewrites/morewrites.dtx index 6e52eff394..1bd5e0f6b3 100644 --- a/macros/latex/contrib/morewrites/morewrites.dtx +++ b/macros/latex/contrib/morewrites/morewrites.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% 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 @@ -28,7 +28,7 @@ % \title{The \textsf{morewrites} package: \\ % Always room for a new \tn{write}} % \author{Bruno Le Floch} -% \date{2018/12/29} +% \date{2024/01/05} % % \maketitle % \tableofcontents @@ -60,11 +60,13 @@ % \item This package loads the \pkg{expl3} package, hence the % \pkg{l3kernel} bundle needs to be up to date. % \item This package uses an auxiliary file, \meta{job~name}|.mw|, -% which can safely be deleted. Versions from 2015 and later will only -% use the auxiliary file if it is originally empty, to avoid -% destroying data (such as |.mw| files used by Maple). This means -% that |.mw| files generated by versions before 2015 should be -% deleted by hand. +% which can safely be deleted. The package only overwrites this +% auxiliary file if it is empty, and otherwise uses a modified +% file name, obtained by adding an integer to the name (previously +% it was obtained by appending additional copies of |.mw| to the +% name). Such files can be safely deleted. Be careful though to +% not delete a Maple worksheet by accident when cleaning up your +% files. % \item \LuaTeX{} allows $128$ \tn{write} streams, so this package does % nothing (with a warning) when used with \LuaTeX{}. % \end{itemize} @@ -88,7 +90,7 @@ % \pkg{morewrites}. % \end{function} % -% \begin{function}[added = 2014-07-26, updated = 2015-08-01]{file} +% \begin{function}[added = 2014-07-26, updated = 2024-01-05]{file} % \begin{syntax} % \cs{morewritessetup} |{| |file| |=| \meta{file name} |}| % \end{syntax} @@ -100,13 +102,23 @@ % remaining. % \end{function} % +% \begin{function}[added = 2024-01-05]{verbose} +% \begin{syntax} +% \cs{morewritessetup} |{| |verbose| |}| +% \end{syntax} +% This boolean option (\texttt{false} by default) makes the package +% write to the terminal all of the operations that it performs. This +% can render \pkg{morewrites} useful for debugging some file-writing +% operations. +% \end{function} +% % \begin{function}[updated = 2015-08-01]{\newwrite} % This macro is redefined by \pkg{morewrites}. Since \pkg{morewrites} % allows more than~$16$ write streams, it removes the corresponding % restrictions in \tn{newwrite}. % \begin{texnote} % The revised \tn{newwrite} allocate stream numbers starting at -% $19$. This might break some code that expects stream numbers to +% $129$. This might break some code that expects stream numbers to % be less than $16$. % \end{texnote} % \end{function} @@ -153,10 +165,9 @@ % %<*package> % \begin{macrocode} -\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} % \end{macrocode} % % Quit early under \LuaTeX{}. @@ -195,15 +206,18 @@ % % Henceforth, ``\TeX{} stream'' will refer to stream numbers in the % range $[0,15]$ provided to \TeX{}'s write primitives, while -% ``user stream'' will denote stream numbers in $[0,15]\cup[19,\infty)$ +% ``user stream'' will denote stream numbers in $[0,15]\cup[129,\infty)$ % manipulated by the redefined \tn{openout}, \tn{write}, \tn{closeout}, % and \tn{newwrite}. A user stream in $[0,15]$ (reserved by \LaTeXe{} % or allocated by \pkg{expl3}) is mapped to the same \TeX{} stream -% number, while a user stream in $[19,\infty)$ is mapped to a \TeX{} +% number, while a user stream in $[129,\infty)$ is mapped to a \TeX{} % stream according to the property list (with integer keys and values) % \cs{l_@@_write_prop}. Stream numbers $16$, % $17$ and $18$ are unused because \tn{write}16 is often used to write % to the terminal, and \tn{write}18 sends its argument to a shell. +% The stream number $128$ is also often used like $16$ to avoid +% distinguishing \LuaTeX{}. Rather than special-casing it we skip +% directly to larger stream numbers. % % The primitives \tn{openout}, \tn{write}, and \tn{closeout} expect to % be followed by an \meta{integer}, normally in the range $[0,15]$, then @@ -313,21 +327,20 @@ % % \subsubsection{Variants} % -% \begin{macro}{\prop_gpop:NVNT, \prop_gput:NVx, \tl_gput_right:Nv} % We need these variants. % \begin{macrocode} \cs_generate_variant:Nn \prop_gpop:NnNT { NV } \cs_generate_variant:Nn \prop_gput:Nnn { NVx } \cs_generate_variant:Nn \tl_gput_right:Nn { Nv } % \end{macrocode} -% \end{macro} % % \subsubsection{Variables} % -% \begin{variable}{\l_@@_internal_tl} +% \begin{variable}{\l_@@_internal_tl, \l_@@_internal_seq} % Used for temporary scratch purposes. % \begin{macrocode} \tl_new:N \l_@@_internal_tl +\seq_new:N \l_@@_internal_seq % \end{macrocode} % \end{variable} % @@ -338,6 +351,13 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\l_@@_verbose_bool} +% When this boolean is set true, \pkg{morewrites} will print to the terminal all of the operations that it does. +% \begin{macrocode} +\bool_new:N \l_@@_verbose_bool +% \end{macrocode} +% \end{variable} +% % \begin{variable}{\g_@@_later_int} % The integer \cs{g_@@_later_int} labels the various % non-immediate operations in the order in which they appear in the @@ -458,12 +478,25 @@ % \end{macrocode} % \end{variable} % +% \subsubsection{Verbosity} +% +% \begin{macro}{\@@_verbose:n} +% Messages to put in the terminal if the \texttt{verbose} option is +% selected. +% \begin{macrocode} +\cs_new_protected:Npn \@@_verbose:n #1 + { \bool_if:NT \l_@@_verbose_bool { \iow_term:e { morewrites:~#1 } } } +% \end{macrocode} +% \end{macro} +% % \subsubsection{Helpers for auxiliary file} % % \begin{macro}{\@@_set_file:n} % Sets \cs{g_@@_tmp_file_tl} to the given value (initially -% \cs{c_sys_jobname_str}|.mw|). Mark that the file has not been -% checked. +% \cs{c_sys_jobname_str}|.mw|). We do not yet expand, delaying that +% to the time where we start opening/closing the file, in case |#1| +% contains something that has not yet been fixed. Mark that the file +% has not been checked. % \begin{macrocode} \cs_new_protected:Npn \@@_set_file:n #1 { @@ -474,7 +507,7 @@ % \end{macro} % % \begin{macro}{\@@_empty_file:n} -% Empties the file \cs{g_@@_tmp_file_tl} by opening it and closing it +% Empties a file by opening it and closing it % right away. This is used when performing \tn{immediate} % \tn{openout}. It is also used to ensure the file used by % \pkg{morewrites} is left empty. We do this every time the auxiliary @@ -483,7 +516,7 @@ \cs_new_protected:Npn \@@_empty_file:n #1 { \@@_tex_immediate:w \@@_tex_openout:w - \g_@@_iow = #1 \scan_stop: + \g_@@_iow = {#1} \scan_stop: \@@_tex_immediate:w \@@_tex_closeout:w \g_@@_iow } @@ -503,7 +536,7 @@ \prg_new_conditional:Npnn \@@_if_file_trivial:n #1 { TF } { \group_begin: - \tex_openin:D \g_@@_ior = #1 \scan_stop: + \tex_openin:D \g_@@_ior = {#1} \if_eof:w \g_@@_ior \cs_gset_eq:NN \@@_tmp:w \prg_return_true: \else: @@ -523,22 +556,41 @@ % \end{macro} % % \begin{macro}{\@@_chk_file:} -% Check that the file \cs{g_@@_tmp_file_tl} does not exist or is blank. -% If not, try the file name obtained by adding |.mw|. +% Expand the file name in \cs{g_@@_tmp_file_tl} once and for all. +% Check that the file does not exist or is +% blank. If not, try another file name obtained as follows: if it +% ends with |.mw| pick up any number that lies just before |.mw| and +% increment it, and otherwise just add |.mw| at the end of the file. % This avoids clobbering files that the user would not want to lose. % \begin{macrocode} \cs_new_protected:Npn \@@_chk_file: { + \tl_gset:Ne \g_@@_tmp_file_tl + { \tl_to_str:e { \g_@@_tmp_file_tl } } \@@_if_file_trivial:nTF { \g_@@_tmp_file_tl } { \bool_gset_true:N \g_@@_tmp_file_bool } { + \@@_chk_file_aux: \msg_warning:nnxx { morewrites } { file-exists } - { \g_@@_tmp_file_tl } - { \g_@@_tmp_file_tl .mw } - \tl_gput_right:Nn \g_@@_tmp_file_tl { .mw } + { \g_@@_tmp_file_tl } { \l_@@_internal_tl } + \tl_gset_eq:NN \g_@@_tmp_file_tl \l_@@_internal_tl \@@_chk_file: } } +\cs_new_protected:Npn \@@_chk_file_aux: + { + \regex_extract_once:nVNTF + { \A (\D*) (\d*) .mw \Z } \g_@@_tmp_file_tl \l_@@_internal_seq + { + \tl_set:Ne \l_@@_internal_tl + { + \seq_item:Nn \l_@@_internal_seq { 2 } + \int_eval:n { \seq_item:Nn \l_@@_internal_seq { 3 } + 1 } + .mw + } + } + { \tl_set:Ne \l_@@_internal_tl { \g_@@_tmp_file_tl .mw } } + } \msg_new:nnnn { morewrites } { file-exists } { File~'#1'~exists,~using~'#2'~instead. } { @@ -564,7 +616,7 @@ \cs_new_protected:Npn \@@_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: } @@ -588,9 +640,9 @@ % \begin{macro}{\@@_user_to_tstr:NTF} % The goal is to go from a user stream \cs{l_@@_user_int} to a \TeX{} % stream \cs{l_@@_tstr_tl} (it defaults to the user stream). Streams -% less than $19$ are not managed by \pkg{morewrites}: actual \TeX{} +% less than $129$ are not managed by \pkg{morewrites}: actual \TeX{} % streams in $[0,15]$; negative for writing to \texttt{log}; $16$, -% $17$ for writing to terminal; $18$ for shell escape. Larger stream +% $17$, $128$ for writing to terminal; $18$ for shell escape. Larger stream % numbers are looked up in the property list |#1|, namely % \cs{g_@@_write_prop}. If present, use the corresponding value as % the \TeX{} stream, otherwise run the \texttt{false} branch. @@ -598,7 +650,7 @@ \cs_new_protected:Npn \@@_user_to_tstr:NTF #1 { \tl_set:NV \l_@@_tstr_tl \l_@@_user_int - \int_compare:nNnTF { \l_@@_user_int } < { 19 } + \int_compare:nNnTF { \l_@@_user_int } < { 129 } { \use_i:nn } { \prop_get:NVNTF #1 \l_@@_user_int \l_@@_tstr_tl } } @@ -724,9 +776,10 @@ % then test for \tn{openout}, \tn{write}, and \tn{closeout}. More % precisely we test for the marker \cs{s_@@} and run the appropriate % code as described above. Otherwise we call the primitive, for cases -% where the next token is \tn{pdfobj} or similar. This code performs -% too much expansion for some nonsensical uses of \tn{noexpand} after -% \tn{immediate}. +% where the next token is \tn{pdfobj} or similar. In contrived +% situations involving nonsensical uses of \tn{noexpand} after +% \tn{immediate}, this code does not perfectly match how \TeX{} +% expands. % \begin{macrocode} \cs_new_protected:Npn \@@_immediate:w { \primargs_read_x_token:N \@@_immediate_auxii: } @@ -734,7 +787,11 @@ { \token_if_eq_meaning:NNTF \g_primargs_token \s_@@ { \@@_immediate_auxiii:N } - { \@@_tex_immediate:w } + { + \@@_verbose:n + { \tl_to_str:n { \immediate } \token_to_meaning:N \g_primargs_token } + \@@_tex_immediate:w + } } \cs_new_protected:Npn \@@_immediate_auxiii:N #1 { \str_if_eq:nnTF { #1 } { \s_@@ } { \use_iii:nnn } { #1 } } @@ -746,9 +803,10 @@ % % The \tn{openout}, \tn{write}, and \tn{closeout} primitive can be % either delayed or immediate. In all cases they begin by looking for a -% user stream. Here, we implement the immediate versions only. +% user stream. In this subsubsection we implement the immediate versions +% only. % -% \begin{macro}{\@@_closeout:w, \@@_closeout_now:, \@@_closeout_now:nn} +% \begin{macro}{\@@_closeout:w, \@@_closeout_now:, \@@_closeout_now_silent:, \@@_closeout_now:nn} % In the immediate case \cs{@@_closeout_now:}, there are three cases. % The stream may point to a \TeX{} stream, in which case it is closed, % removed from \cs{g_@@_write_prop}, and put back in the list of @@ -770,6 +828,11 @@ { \@@_get_user:n { \@@_closeout_now: } } } \cs_new_protected:Npn \@@_closeout_now: + { + \@@_verbose:n { \tl_to_str:n { \immediate \closeout } \int_use:N \l_@@_user_int } + \@@_closeout_now_silent: + } +\cs_new_protected:Npn \@@_closeout_now_silent: { \@@_user_to_tstr:NTF \g_@@_write_prop { @@ -787,7 +850,7 @@ } \cs_new_protected:Npn \@@_closeout_now:nn #1#2 { - \@@_tex_immediate:w \@@_tex_openout:w \g_@@_iow = #2 \scan_stop: + \@@_tex_immediate:w \@@_tex_openout:w \g_@@_iow = {#2} \group_begin: \int_set:Nn \tex_newlinechar:D { -1 } \tl_use:c { \@@_user_tl_name:n {#1} } @@ -798,7 +861,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\@@_openout:w, \@@_openout_now:n} +% \begin{macro}{\@@_openout:w, \@@_openout_now:n, \@@_openout_now_silent:n} % In the immediate case find a file name, then allocate a \TeX{} % stream if possible, and otherwise point the user stream to a token % list. In all cases, close the stream to avoid losing any material @@ -814,18 +877,28 @@ } \cs_new_protected:Npn \@@_openout_now:n #1 { - \@@_closeout_now: - \int_compare:nNnTF { \l_@@_user_int } < { 19 } + \@@_verbose:n + { + \tl_to_str:n { \immediate\openout } + \int_use:N \l_@@_user_int + \c_space_tl = ~ {#1} + } + \@@_openout_now_silent:n {#1} + } +\cs_new_protected:Npn \@@_openout_now_silent:n #1 + { + \@@_closeout_now_silent: + \int_compare:nNnTF { \l_@@_user_int } < { 129 } { \@@_tex_immediate:w \@@_tex_openout:w \l_@@_user_int - = \tl_to_str:n {#1} \scan_stop: + = { \tl_to_str:n {#1} } } { \seq_gpop:NNTF \g_@@_write_seq \l_@@_tstr_tl { \prop_gput:NVV \g_@@_write_prop \l_@@_user_int \l_@@_tstr_tl \@@_tex_immediate:w \@@_tex_openout:w \l_@@_tstr_tl \exp_stop_f: - = \tl_to_str:n {#1} \scan_stop: + = { \tl_to_str:n {#1} } } { \@@_empty_file:n {#1} @@ -854,14 +927,41 @@ \cs_new_protected:Npn \@@_write_now:w { \@@_user_to_tstr:NTF \g_@@_write_prop - { \@@_tex_immediate:w \@@_tex_write:w \l_@@_tstr_tl \exp_stop_f: } + { + \int_compare:nNnT \l_@@_user_int = { 18 } { \use_iii:nnn } + \int_compare:nT { -1 < \l_@@_user_int < 16 } + { + \@@_verbose:n + { + \tl_to_str:n { \immediate \write } + \int_use:N \l_@@_user_int + } + } + \@@_tex_immediate:w \@@_tex_write:w \l_@@_tstr_tl \exp_stop_f: + } { \primargs_get_general_text:N \@@_write_now:n } } -\cs_new_protected:Npn \@@_write_now:n +\cs_new_protected:Npn \@@_write_now:n #1 { \prop_get:NVNTF \g_@@_write_file_prop \l_@@_user_int \l_@@_internal_tl - { \@@_write_now_open:n } - { \@@_tex_immediate:w \@@_tex_write:w 16 } + { + \@@_verbose:n + { + \tl_to_str:n { \immediate \write } + \int_use:N \l_@@_user_int + \tl_to_str:n { ~ {#1} } + } + \@@_write_now_open:n {#1} + } + { + \@@_verbose:n + { + \tl_to_str:n { \immediate \write } + \int_use:N \l_@@_user_int + \tl_to_str:n { ~ (closed) ~ {#1} } + } + \@@_tex_immediate:w \@@_tex_write:w 16 {#1} + } } % \end{macrocode} % \end{macro} @@ -885,14 +985,14 @@ { \bool_if:NF \g_@@_tmp_file_bool { \@@_chk_file: } \@@_tex_immediate:w \@@_tex_openout:w - \g_@@_iow = \g_@@_tmp_file_tl \scan_stop: + \g_@@_iow = { \g_@@_tmp_file_tl } \@@_tex_immediate:w \@@_tex_write:w \g_@@_iow {#1} \@@_tex_immediate:w \@@_tex_closeout:w \g_@@_iow \group_begin: \int_set:Nn \tex_endlinechar:D { -1 } - \tex_openin:D \g_@@_ior = \g_@@_tmp_file_tl \scan_stop: + \tex_openin:D \g_@@_ior = { \g_@@_tmp_file_tl } \@@_write_now_loop: \tex_closein:D \g_@@_ior \@@_collect_gput_right:c @@ -949,29 +1049,41 @@ % % \begin{macro}{\@@_closeout_later:} % If the user stream is a \TeX{} stream, use the primitive, otherwise -% save \cs{@@_closeout_now:} for later. +% save \cs{@@_closeout_now_silent:} for later. % \begin{macrocode} \cs_new_protected:Npn \@@_closeout_later: { - \int_compare:nNnTF \l_@@_user_int < { 19 } + \@@_verbose:n { \tl_to_str:n { \closeout (later) ~ } \int_use:N \l_@@_user_int } + \int_compare:nNnTF \l_@@_user_int < { 129 } { \@@_tex_closeout:w \l_@@_user_int } - { \@@_later:n { \@@_closeout_now: } } + { \@@_later:n { \@@_closeout_now_silent: } } } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_openout_later:w, \@@_openout_later:n} % If the user stream is a \TeX{} stream use the primitive, otherwise -% find a file name and call \cs{@@_openout_now:n} later. +% find a file name and call \cs{@@_openout_now_silent:n} later. % \begin{macrocode} \cs_new_protected:Npn \@@_openout_later:w { - \int_compare:nNnTF \l_@@_user_int < { 19 } - { \@@_tex_openout:w \l_@@_user_int } + \int_compare:nNnTF \l_@@_user_int < { 129 } + { + \@@_verbose:n { \tl_to_str:n { \openout (later) ~ } \int_use:N \l_@@_user_int } + \@@_tex_openout:w \l_@@_user_int + } { \@@_equals_file:N \@@_openout_later:n } } \cs_new_protected:Npn \@@_openout_later:n #1 - { \@@_later:n { \@@_openout_now:n {#1} } } + { + \@@_verbose:n + { + \tl_to_str:n { \openout (later)~ } + \int_use:N \l_@@_user_int + \c_space_tl = ~ {#1} + } + \@@_later:n { \@@_openout_now_silent:n {#1} } + } % \end{macrocode} % \end{macro} % @@ -982,17 +1094,32 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_write_later:w { - \int_compare:nNnTF \l_@@_user_int < { 19 } - { \@@_tex_write:w \l_@@_user_int } + \int_compare:nNnTF \l_@@_user_int < { 129 } + { + \@@_verbose:n { \tl_to_str:n { \write (later)~ } \int_use:N \l_@@_user_int } + \@@_tex_write:w \l_@@_user_int + } { \primargs_get_general_text:N \@@_write_later:n } } \cs_new_protected:Npn \@@_write_later:n #1 - { \@@_later:n { \@@_write_later_aux:n {#1} } } + { + \@@_verbose:n + { + \tl_to_str:n { \write (later)~ } + \int_use:N \l_@@_user_int + \tl_to_str:n { ~ {#1} } + } + \@@_later:n { \@@_write_later_aux:n {#1} } + } \cs_new_protected:Npn \@@_write_later_aux:n { \@@_user_to_tstr:NTF \g_@@_write_prop { \@@_tex_immediate:w \@@_tex_write:w \l_@@_tstr_tl \exp_stop_f: } - { \@@_write_now:n } + { + \prop_get:NVNTF \g_@@_write_file_prop \l_@@_user_int \l_@@_internal_tl + { \@@_write_now_open:n } + { \@@_tex_immediate:w \@@_tex_write:w 16 \exp_stop_f: } + } } % \end{macrocode} % \end{macro} @@ -1022,7 +1149,7 @@ { \bool_if:NF \g_@@_tmp_file_bool { \@@_chk_file: } \@@_tex_immediate:w \@@_tex_openout:w - \g_@@_iow = \g_@@_tmp_file_tl \scan_stop: + \g_@@_iow = { \g_@@_tmp_file_tl } } % \end{macrocode} % \end{macro} @@ -1059,7 +1186,7 @@ \tl_set:Nx \l_@@_internal_tl { \exp_after:wN \@@_after_shipout_loop:ww - \tex_input:D \g_@@_tmp_file_tl \c_space_tl + \tex_input:D { \g_@@_tmp_file_tl } } \@@_empty_file:n { \g_@@_tmp_file_tl } \exp_args:NNo @@ -1165,7 +1292,10 @@ \cs_new_protected:Npn \@@_close_all: { \prop_map_inline:Nn \g_@@_write_prop - { \@@_tex_immediate:w \@@_tex_closeout:w ##2 \scan_stop: } + { + \@@_verbose:n { \tl_to_str:n { \immediate \closeout } ##1 ~ (at~end) } + \@@_tex_immediate:w \@@_tex_closeout:w ##2 \scan_stop: + } \prop_gclear:N \g_@@_write_prop \prop_map_function:NN \g_@@_write_file_prop \@@_closeout_now:nn @@ -1197,13 +1327,16 @@ % \subsubsection{Modified \tn{newwrite}} % % \begin{variable}{\g_@@_alloc_write_int} -% Counter to allocate user streams. Initialized to $18$ so that the -% first user stream allocated by \pkg{morewrites} is $19$. Indeed, -% $18$ is reserved for shell commands and packages may expect $16$ or -% $17$ to write to the terminal. +% Counter to allocate user streams. We used to initialize it to $18$ +% so that the first user stream allocated by \pkg{morewrites} was +% $19$. Indeed, $18$ is reserved for shell commands and packages may +% expect $16$ or $17$ to write to the terminal. This is now changed +% to start allocation at $129$, since some packages that do not want +% to distinguish \LuaTeX{} from other engines simply use $128$ as a +% never-open stream. % \begin{macrocode} \int_new:N \g_@@_alloc_write_int -\int_gset:Nn \g_@@_alloc_write_int { 18 } +\int_gset:Nn \g_@@_alloc_write_int { 128 } % \end{macrocode} % \end{variable} % @@ -1265,7 +1398,8 @@ { allocate .code:n = \@@_allocate:n {#1} , file .code:n = \@@_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_@@_verbose_bool } % \end{macrocode} % \end{macro} diff --git a/macros/latex/contrib/morewrites/morewrites.ins b/macros/latex/contrib/morewrites/morewrites.ins index d9e17d55e0..6cb78787a2 100644 --- a/macros/latex/contrib/morewrites/morewrites.ins +++ b/macros/latex/contrib/morewrites/morewrites.ins @@ -1,6 +1,6 @@ \iffalse meta-comment -File morewrites.ins Copyright (C) 2012 Bruno Le Floch +File morewrites.ins 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 @@ -22,8 +22,8 @@ The released version of this bundle is available from CTAN. \preamble -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 \endpreamble % stop docstrip adding \endinput diff --git a/macros/latex/contrib/morewrites/morewrites.pdf b/macros/latex/contrib/morewrites/morewrites.pdf index 4b838b6779..20632fc76d 100644 Binary files a/macros/latex/contrib/morewrites/morewrites.pdf and b/macros/latex/contrib/morewrites/morewrites.pdf differ diff --git a/macros/latex/contrib/morewrites/primargs.dtx b/macros/latex/contrib/morewrites/primargs.dtx index 5ba63d5e85..132b01e6b6 100644 --- a/macros/latex/contrib/morewrites/primargs.dtx +++ b/macros/latex/contrib/morewrites/primargs.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% 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 @@ -25,7 +25,7 @@ % \title{The \textsf{primargs} package: \\ % Parsing arguments of primitives} % \author{Bruno Le Floch} -% \date{2018/12/29} +% \date{2024/01/05} % % \maketitle % \tableofcontents @@ -167,17 +167,19 @@ % argument. % \end{function} % -% \begin{function}[updated = 2017-04-10, tested = primargs004]{\primargs_get_file_name:N, \primargs_get_input_file_name:N} +% \begin{function}[updated = 2024-01-05, tested = primargs004]{\primargs_get_file_name:N, \primargs_get_input_file_name:N} % \begin{syntax} % \cs{primargs_get_file_name:N} \meta{function} % \cs{primargs_get_input_file_name:N} \meta{function} % \end{syntax} % Reads a \meta{file name} following the \meta{function} and calls the % \meta{function} with this \meta{file name} as a braced argument. -% The two functions are identical except in the \LuaTeX{} engine where -% \cs{primargs_get_input_file_name:N} allows braced file names: -% \LuaTeX{} allows such braced file names for some primitives (\tn{input} -% and \tn{openin}) but not others (\tn{openout}). +% The first function only allows for the historical unbraced file +% names that plain \TeX{} supports. The second one also allows braced +% file names. Historically this was first supported in \LuaTeX{} for +% \tn{input} and related primitives, hence the name. Now all main +% engines (in \TeX{}Live at least) support both syntaxes for all +% primitives that take file names. % \begin{texnote} % When braced file names are disallowed, the file name is obtained % by discarding \meta{optional spaces} then repeatedly doing the @@ -250,9 +252,8 @@ % %<*package> % \begin{macrocode} -\RequirePackage {expl3} [2018/02/21] \ProvidesExplPackage - {primargs} {2018/12/29} {} {Parsing arguments of primitives} + {primargs} {2024/01/05} {} {Parsing arguments of primitives} % \end{macrocode} % % \begin{macrocode} @@ -801,7 +802,7 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_get_file_name_char: { - \token_if_eq_charcode:NNT " \g_primargs_token + \token_if_eq_charcode:NNT " \g_primargs_token % " { \tl_gset:Nx \g_@@_file_name_level_tl { \int_eval:n { 1 - \g_@@_file_name_level_tl } } @@ -828,8 +829,11 @@ % \@@_get_input_file_name_loop:, \@@_get_input_file_name_test:, % \@@_get_input_file_name_brace:, \@@_get_input_file_name_aux:N % } -% For most engines this is an alias of \cs{primargs_get_file_name:N}. -% In \LuaTeX{} we test for a catcode $1$ token (after a filler) then +% In addition to file names detected by \cs{primargs_get_file_name:N} +% this allows for braced file names. The weird indentation is because +% historically we had to distinguish \LuaTeX{}, allowing braced file +% names, from other engines. +% We test for a catcode $1$ token (after a filler) then % expand and collect tokens (turned to strings) one by one, counting % begin-group and end-group tokens in \cs{g_@@_file_name_level_tl}. % The control sequence \tn{par} is ignored. After removing a filler @@ -837,8 +841,6 @@ % the tests are safe. We use primitives to cope with outer macro % hidden by \tn{noexpand} upon first expansion. % \begin{macrocode} -\sys_if_engine_luatex:TF - { \cs_new_protected:Npn \primargs_get_input_file_name:N #1 { \group_begin: @@ -905,8 +907,6 @@ } \@@_get_input_file_name_loop: } - } - { \cs_new_eq:NN \primargs_get_input_file_name:N \primargs_get_file_name:N } % \end{macrocode} % \end{macro} % \end{macro} diff --git a/macros/latex/contrib/morewrites/primargs.pdf b/macros/latex/contrib/morewrites/primargs.pdf index d63d7f97a2..0c3a84562a 100644 Binary files a/macros/latex/contrib/morewrites/primargs.pdf and b/macros/latex/contrib/morewrites/primargs.pdf differ -- cgit v1.2.3