[latex3-commits] [latex3/latex3] main: Add V-type variants for l3file funcs (see #1257) (cb454a9e0)

github at latex-project.org github at latex-project.org
Fri Sep 8 21:54:38 CEST 2023


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/cb454a9e0348c96acb0fc38eda2ff831e990e89c

>---------------------------------------------------------------

commit cb454a9e0348c96acb0fc38eda2ff831e990e89c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Sep 8 20:54:38 2023 +0100

    Add V-type variants for l3file funcs (see #1257)


>---------------------------------------------------------------

cb454a9e0348c96acb0fc38eda2ff831e990e89c
 l3kernel/l3file.dtx | 134 ++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 103 insertions(+), 31 deletions(-)

diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index 1c1401e39..a1dbb2060 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -705,7 +705,8 @@
 %   \end{texnote}
 % \end{variable}
 %
-% \begin{function}[TF, updated = 2012-02-10]{\file_if_exist:n, \file_if_exist:V}
+% \begin{function}[TF, updated = 2012-02-10]
+%   {\file_if_exist:n, \file_if_exist:V}
 %   \begin{syntax}
 %     \cs{file_if_exist:nTF} \Arg{file name} \Arg{true code} \Arg{false code}
 %   \end{syntax}
@@ -714,7 +715,8 @@
 %   \cs{l_file_search_path_seq}.
 % \end{function}
 %
-% \begin{function}[noTF, added = 2019-01-16, updated = 2019-02-16]{\file_get:nnN}
+% \begin{function}[noTF, added = 2019-01-16, updated = 2019-02-16]
+%   {\file_get:nnN, \file_get:VnN}
 %   \begin{syntax}
 %     \cs{file_get:nnN} \Arg{filename} \Arg{setup} \meta{tl}
 %     \cs{file_get:nnNTF} \Arg{filename} \Arg{setup} \meta{tl} \Arg{true code} \Arg{false code}
@@ -782,7 +784,8 @@
 %   Quotes (|"|) are invalid in file names and are discarded from the input.
 % \end{function}
 %
-% \begin{function}[EXP, added = 2020-06-24]{\file_parse_full_name:n}
+% \begin{function}[EXP, added = 2020-06-24]
+%   {\file_parse_full_name:n, \file_parse_full_name:V}
 %   \begin{syntax}
 %     \cs{file_parse_full_name:n} \Arg{full name}
 %   \end{syntax}
@@ -791,7 +794,8 @@
 %   each inside a pair of braces.
 % \end{function}
 %
-% \begin{function}[EXP, added = 2020-06-24]{\file_parse_full_name_apply:nN}
+% \begin{function}[EXP, added = 2020-06-24]
+%   {\file_parse_full_name_apply:nN, \file_parse_full_name_apply:VN}
 %   \begin{syntax}
 %     \cs{file_parse_full_name_apply:nN} \Arg{full name} \meta{function}
 %   \end{syntax}
@@ -801,7 +805,10 @@
 % \end{function}
 %
 % \begin{function}[rEXP, added = 2019-11-19]
-%   {\file_hex_dump:n, \file_hex_dump:nnn}
+%   {
+%     \file_hex_dump:n,   \file_hex_dump:V,
+%     \file_hex_dump:nnn, \file_hex_dump:Vnn
+%   }
 %   \begin{syntax}
 %     \cs{file_hex_dump:n} \Arg{file name}
 %     \cs{file_hex_dump:nnn} \Arg{file name} \Arg{start index} \Arg{end index}
@@ -819,7 +826,10 @@
 % \end{function}
 %
 % \begin{function}[noTF, added = 2019-11-19]
-%   {\file_get_hex_dump:nN, \file_get_hex_dump:nnnN}
+%   {
+%     \file_get_hex_dump:nN, \file_get_hex_dump:VN,
+%     \file_get_hex_dump:nnnN, \file_get_hex_dump:VnnN
+%   }
 %   \begin{syntax}
 %     \cs{file_get_hex_dump:nN} \Arg{file name} \meta{tl var}
 %     \cs{file_get_hex_dump:nnnN} \Arg{file name} \Arg{start index} \Arg{end index} \meta{tl var}
@@ -829,7 +839,8 @@
 %   If the file is not found, the \meta{tl var} will be set to \cs{q_no_value}.
 % \end{function}
 %
-% \begin{function}[rEXP, added = 2019-09-03]{\file_mdfive_hash:n}
+% \begin{function}[rEXP, added = 2019-09-03]
+%   {\file_mdfive_hash:n, \file_mdfive_hash:V}
 %   \begin{syntax}
 %     \cs{file_mdfive_hash:n} \Arg{file name}
 %   \end{syntax}
@@ -845,7 +856,7 @@
 % \end{function}
 %
 % \begin{function}[noTF, added = 2017-07-11, updated = 2019-02-16]
-%   {\file_get_mdfive_hash:nN}
+%   {\file_get_mdfive_hash:nN, \file_get_mdfive_hash:VN}
 %   \begin{syntax}
 %     \cs{file_get_mdfive_hash:nN} \Arg{file name} \meta{tl var}
 %   \end{syntax}
@@ -854,7 +865,7 @@
 %   the \meta{tl var} will be set to \cs{q_no_value}.
 % \end{function}
 %
-% \begin{function}[rEXP, added = 2019-09-03]{\file_size:n}
+% \begin{function}[rEXP, added = 2019-09-03]{\file_size:n, \file_size:V}
 %   \begin{syntax}
 %     \cs{file_size:n} \Arg{file name}
 %   \end{syntax}
@@ -865,7 +876,7 @@
 % \end{function}
 %
 % \begin{function}[noTF, added = 2017-07-09, updated = 2019-02-16]
-%   {\file_get_size:nN}
+%   {\file_get_size:nN, \file_get_size:VN}
 %   \begin{syntax}
 %     \cs{file_get_size:nN} \Arg{file name} \meta{tl var}
 %   \end{syntax}
@@ -875,7 +886,8 @@
 %   This is not available in older versions of \XeTeX{}.
 % \end{function}
 %
-% \begin{function}[rEXP, added = 2019-09-03]{\file_timestamp:n}
+% \begin{function}[rEXP, added = 2019-09-03]
+%   {\file_timestamp:n, \file_timestamp:V}
 %   \begin{syntax}
 %     \cs{file_timestamp:n} \Arg{file name}
 %   \end{syntax}
@@ -891,7 +903,7 @@
 % \end{function}
 %
 % \begin{function}[noTF, added = 2017-07-09, updated = 2019-02-16]
-%   {\file_get_timestamp:nN}
+%   {\file_get_timestamp:nN, \file_get_timestamp:VN}
 %   \begin{syntax}
 %     \cs{file_get_timestamp:nN} \Arg{file name} \meta{tl var}
 %   \end{syntax}
@@ -902,7 +914,12 @@
 % \end{function}
 %
 % \begin{function}[added = 2019-05-13, updated = 2019-09-20, pTF, EXP]
-%   {\file_compare_timestamp:nNn}
+%   {
+%     \file_compare_timestamp:nNn,
+%     \file_compare_timestamp:nNV,
+%     \file_compare_timestamp:VNn,
+%     \file_compare_timestamp:VNV
+%   }
 %   \begin{syntax}
 %     \cs{file_compare_timestamp_p:nNn} \Arg{file-1} \meta{comparator} \Arg{file-2}
 %     \cs{file_compare_timestamp:nNnTF} \Arg{file-1} \meta{comparator} \Arg{file-2} \Arg{true code} \Arg{false code}
@@ -935,7 +952,8 @@
 %   function. An error is raised if the file is not found.
 % \end{function}
 %
-% \begin{function}[added = 2023-05-18, EXP]{\file_input_raw:n}
+% \begin{function}[added = 2023-05-18, EXP]
+%   {\file_input_raw:n, \file_input_raw:V}
 %   \begin{syntax}
 %     \cs{file_input_raw:n} \Arg{file name}
 %   \end{syntax}
@@ -950,7 +968,13 @@
 %   \end{texnote}
 % \end{function}
 %
-% \begin{function}[added = 2014-07-02]{\file_if_exist_input:n, \file_if_exist_input:nF}
+% \begin{function}[added = 2014-07-02]
+%   {
+%     \file_if_exist_input:n,
+%     \file_if_exist_input:V,
+%     \file_if_exist_input:nF,
+%     \file_if_exist_input:VF
+%   }
 %   \begin{syntax}
 %     \cs{file_if_exist_input:n} \Arg{file name}
 %     \cs{file_if_exist_input:nF} \Arg{file name} \Arg{false code}
@@ -2815,7 +2839,7 @@
 %    \end{macrocode}
 % \end{variable}
 %
-% \begin{macro}[TF]{\file_get:nnN}
+% \begin{macro}[TF]{\file_get:nnN, \file_get:VnN}
 % \begin{macro}{\file_get:nnN,\@@_get_aux:nnN,\@@_get_do:Nw}
 %   The approach here is similar to that for \cs{tl_set_rescan:Nnn}.
 %   The file contents are grabbed as an argument delimited by
@@ -2830,6 +2854,7 @@
     \file_get:nnNF {#1} {#2} #3
       { \tl_set:Nn #3 { \q_no_value } }
   }
+\cs_generate_variant:Nn \file_get:nnN { V }
 \prg_new_protected_conditional:Npnn \file_get:nnN #1#2#3 { T , F , TF }
   {
     \file_get_full_name:nNTF {#1} \l_@@_full_name_tl
@@ -2841,6 +2866,7 @@
       }
       { \prg_return_false: }
   }
+\prg_generate_conditional_variant:Nnn \file_get:nnN { V } { T , F , TF }
 \cs_new_protected:Npx \@@_get_aux:nnN #1#2#3
   {
     \exp_not:N \if_false: { \exp_not:N \fi:
@@ -2901,6 +2927,7 @@
     \exp_args:Ne \@@_full_name:n
       { \__kernel_file_name_sanitize:n {#1} }
   }
+\cs_generate_variant:Nn \file_full_name:n { V }
 %    \end{macrocode}
 %   First, we check of the file is just here: no mapping so we do not
 %   need the break part of the broader auxiliary. We are using the fact
@@ -3071,9 +3098,8 @@
       { \prg_return_false: }
       { \prg_return_true: }
   }
-\cs_generate_variant:Nn \file_get_full_name:nNT  { V }
-\cs_generate_variant:Nn \file_get_full_name:nNF  { V }
-\cs_generate_variant:Nn \file_get_full_name:nNTF { V }
+\prg_generate_conditional_variant:Nnn \file_get_full_name:nN
+  { V } { T , F ,  TF }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -3086,7 +3112,12 @@
 %    \end{macrocode}
 % \end{variable}
 %
-% \begin{macro}[rEXP]{\file_mdfive_hash:n, \file_size:n, \file_timestamp:n}
+% \begin{macro}[rEXP]
+%   {
+%     \file_mdfive_hash:n, \file_mdfive_hash:V,
+%     \file_size:n, \file_size:V,
+%     \file_timestamp:n, \file_timestamp:V
+%   }
 % \begin{macro}[rEXP]{\@@_details:nn, \@@_details_aux:nn}
 % \begin{macro}[rEXP]{\@@_mdfive_hash:n}
 %   Getting file details by expansion is relatively easy if a bit repetitive.
@@ -3095,8 +3126,10 @@
 %    \begin{macrocode}
 \cs_new:Npn \file_size:n #1
   { \@@_details:nn {#1} { size } }
+\cs_generate_variant:Nn \file_size:n { V }
 \cs_new:Npn \file_timestamp:n #1
   { \@@_details:nn {#1} { moddate } }
+\cs_generate_variant:Nn \file_timestamp:n { V }
 \cs_new:Npn \@@_details:nn #1#2
   {
     \exp_args:Ne \@@_details_aux:nn
@@ -3109,6 +3142,7 @@
   }
 \cs_new:Npn \file_mdfive_hash:n #1
   { \exp_args:Ne \@@_mdfive_hash:n { \file_full_name:n {#1} } }
+\cs_generate_variant:Nn \file_mdfive_hash:n { V }
 \cs_new:Npn \@@_mdfive_hash:n #1
   { \tex_mdfivesum:D file {#1} }
 %    \end{macrocode}
@@ -3116,10 +3150,10 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}[rEXP]{\file_hex_dump:nnn, \@@_hex_dump_auxi:nnn}
+% \begin{macro}[rEXP]{\file_hex_dump:nnn, \file_hex_dump:Vnn, \@@_hex_dump_auxi:nnn}
 % \begin{macro}[rEXP]{\@@_hex_dump_auxii:nnnn, \@@_hex_dump_auxiii:nnnn}
 % \begin{macro}[rEXP]{\@@_hex_dump_auxiiv:nnn}
-% \begin{macro}[rEXP]{\file_hex_dump:n, \@@_hex_dump:n}
+% \begin{macro}[rEXP]{\file_hex_dump:n, \file_hex_dump:V, \@@_hex_dump:n}
 %   These are separate as they need multiple arguments \emph{or} the
 %   file size. For \LuaTeX{}, the emulation does not need the file
 %   size so we save a little on expansion.
@@ -3131,6 +3165,7 @@
       { \int_eval:n {#2} }
       { \int_eval:n {#3} }
   }
+\cs_generate_variant:Nn \file_hex_dump:nnn { V }
 \cs_new:Npn \@@_hex_dump_auxi:nnn #1#2#3
   {
     \bool_lazy_any:nF
@@ -3174,6 +3209,7 @@
   }
 \cs_new:Npn \file_hex_dump:n #1
   { \exp_args:Ne \@@_hex_dump:n { \file_full_name:n {#1} } }
+\cs_generate_variant:Nn \file_hex_dump:n { V }
 \sys_if_engine_luatex:TF
   {
     \cs_new:Npn \@@_hex_dump:n #1
@@ -3197,10 +3233,10 @@
 %
 % \begin{macro}[noTF]
 %   {
-%     \file_get_hex_dump:nN,
-%     \file_get_mdfive_hash:nN
-%     \file_get_size:nN,
-%     \file_get_timestamp:nN
+%     \file_get_hex_dump:nN, \file_get_hex_dump:VN,
+%     \file_get_mdfive_hash:nN, \file_get_mdfive_hash:VN,
+%     \file_get_size:nN, \file_get_size:VN,
+%     \file_get_timestamp:nN, \file_get_timestamp:VN
 %   }
 % \begin{macro}{\@@_get_details:nnN}
 %   Non-expandable wrappers around the above in the case where appropriate
@@ -3208,20 +3244,32 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \file_get_hex_dump:nN #1#2
   { \file_get_hex_dump:nNF {#1} #2 { \tl_set:Nn #2 { \q_no_value } } }
+\cs_generate_variant:Nn \file_get_hex_dump:nN { V }
 \cs_new_protected:Npn \file_get_mdfive_hash:nN #1#2
   { \file_get_mdfive_hash:nNF {#1} #2 { \tl_set:Nn #2 { \q_no_value } } }
+\cs_generate_variant:Nn \file_get_mdfive_hash:nN { V }
 \cs_new_protected:Npn \file_get_size:nN #1#2
   { \file_get_size:nNF {#1} #2 { \tl_set:Nn #2 { \q_no_value } } }
+\cs_generate_variant:Nn \file_get_size:nN { V }
 \cs_new_protected:Npn \file_get_timestamp:nN #1#2
   { \file_get_timestamp:nNF {#1} #2 { \tl_set:Nn #2 { \q_no_value } } }
+\cs_generate_variant:Nn \file_get_timestamp:nN { V }
 \prg_new_protected_conditional:Npnn \file_get_hex_dump:nN #1#2 { T , F , TF }
   { \@@_get_details:nnN {#1} { hex_dump } #2 }
+\prg_generate_conditional_variant:Nnn \file_get_hex_dump:nN
+  { V } { T , F , TF }
 \prg_new_protected_conditional:Npnn \file_get_mdfive_hash:nN #1#2 { T , F , TF }
   { \@@_get_details:nnN {#1} { mdfive_hash } #2 }
+\prg_generate_conditional_variant:Nnn \file_get_mdfive_hash:nN
+  { V } { T , F , TF }
 \prg_new_protected_conditional:Npnn \file_get_size:nN #1#2 { T , F , TF }
   { \@@_get_details:nnN {#1} { size } #2 }
+\prg_generate_conditional_variant:Nnn \file_get_size:nN
+  { V } { T , F , TF }
 \prg_new_protected_conditional:Npnn \file_get_timestamp:nN #1#2 { T , F , TF }
   { \@@_get_details:nnN {#1} { timestamp } #2 }
+\prg_generate_conditional_variant:Nnn \file_get_timestamp:nN
+  { V } { T , F , TF }
 \cs_new_protected:Npn \@@_get_details:nnN #1#2#3
   {
     \__kernel_tl_set:Nx #3
@@ -3234,7 +3282,7 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}[noTF]{\file_get_hex_dump:nnnN}
+% \begin{macro}[noTF]{\file_get_hex_dump:nnnN, \file_get_hex_dump:VnnN}
 %   Custom code due to the additional arguments.
 %    \begin{macrocode}
 \cs_new_protected:Npn \file_get_hex_dump:nnnN #1#2#3#4
@@ -3242,6 +3290,7 @@
     \file_get_hex_dump:nnnNF {#1} {#2} {#3} #4
       { \tl_set:Nn #4 { \q_no_value } }
   }
+\cs_generate_variant:Nn \file_get_hex_dump:nnnN { V }
 \prg_new_protected_conditional:Npnn \file_get_hex_dump:nnnN #1#2#3#4
   { T , F , TF }
   {
@@ -3251,6 +3300,8 @@
       { \prg_return_false: }
       { \prg_return_true: }
   }
+\prg_generate_conditional_variant:Nnn \file_get_hex_dump:nnnN
+  { V } { T , F , TF }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3262,7 +3313,13 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[EXP, pTF]{\file_compare_timestamp:nNn}
+% \begin{macro}[EXP, pTF]
+%   {
+%     \file_compare_timestamp:nNn,
+%     \file_compare_timestamp:nNV,
+%     \file_compare_timestamp:VNn
+%     \file_compare_timestamp:VNV
+%   }
 % \begin{macro}[EXP]{\@@_compare_timestamp:nnN}
 % \begin{macro}[EXP]{\@@_timestamp:n}
 %   Comparison of file date can be done by using the low-level nature of the
@@ -3276,6 +3333,8 @@
       { \file_full_name:n {#3} }
       #2
    }
+\prg_generate_conditional_variant:Nnn \file_compare_timestamp:nNn
+  { nNV , V , VNV } { p , T , F , TF }
 \cs_new:Npn \@@_compare_timestamp:nnN #1#2#3
   {
     \tl_if_blank:nTF {#1}
@@ -3330,7 +3389,13 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\file_if_exist_input:n, \file_if_exist_input:nF}
+% \begin{macro}
+%   {
+%     \file_if_exist_input:n,
+%     \file_if_exist_input:V,
+%     \file_if_exist_input:nF,
+%     \file_if_exist_input:VF
+%   }
 %   Input of a file with a test for existence.  We do not define the |T|
 %   or |TF| variants because the most useful place to place the
 %   \meta{true code} would be inconsistent with other conditionals.
@@ -3340,12 +3405,14 @@
     \file_get_full_name:nNT {#1} \l_@@_full_name_tl
       { \@@_input:V \l_@@_full_name_tl }
   }
+\cs_generate_variant:Nn \file_if_exist_input:n { V }
 \cs_new_protected:Npn \file_if_exist_input:nF #1#2
   {
     \file_get_full_name:nNTF {#1} \l_@@_full_name_tl
       { \@@_input:V \l_@@_full_name_tl }
       {#2}
   }
+\cs_generate_variant:Nn \file_if_exist_input:nF { V }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3435,11 +3502,12 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\file_input_raw:n, \@@_input_raw:nn}
+% \begin{macro}{\file_input_raw:n, \file_input_raw:V, \@@_input_raw:nn}
 %   No error checking, no tracking.
 %    \begin{macrocode}
 \cs_new:Npn \file_input_raw:n #1
   { \exp_args:Ne \@@_input_raw:nn { \file_full_name:n {#1} } {#1} }
+\cs_generate_variant:Nn \file_input_raw:n { V }
 \cs_new:Npx \@@_input_raw:nn #1#2
   {
     \exp_not:N \tl_if_blank:nTF {#1}
@@ -3459,7 +3527,8 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\file_parse_full_name:n, \file_parse_full_name_apply:nN}
+% \begin{macro}{\file_parse_full_name:n, \file_parse_full_name:nV}
+% \begin{macro}{\file_parse_full_name_apply:nN \file_parse_full_name_apply:VN}
 %   The main parsing macro \cs{file_parse_full_name_apply:nN} passes the
 %   file name |#1| through \cs{__kernel_file_name_sanitize:n} so that we
 %   have a single normalised way to treat files internally.
@@ -3472,11 +3541,13 @@
     \file_parse_full_name_apply:nN {#1}
       \prg_do_nothing:
   }
+\cs_generate_variant:Nn \file_parse_full_name:n { V }
 \cs_new:Npn \file_parse_full_name_apply:nN #1
   {
     \exp_args:Ne \@@_parse_full_name_auxi:nN
       { \__kernel_file_name_sanitize:n {#1} }
   }
+\cs_generate_variant:Nn \file_parse_full_name_apply:nN { V }
 %    \end{macrocode}
 %
 % \begin{macro}{\@@_parse_full_name_auxi:nN}
@@ -3549,6 +3620,7 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\file_parse_full_name:nNNN, \file_parse_full_name:VNNN}
 %    \begin{macrocode}





More information about the latex3-commits mailing list.