diff options
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3file.dtx')
-rw-r--r-- | macros/latex/contrib/l3kernel/l3file.dtx | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/macros/latex/contrib/l3kernel/l3file.dtx b/macros/latex/contrib/l3kernel/l3file.dtx index 4d1b0660b7..c5e7fc1df7 100644 --- a/macros/latex/contrib/l3kernel/l3file.dtx +++ b/macros/latex/contrib/l3kernel/l3file.dtx @@ -44,7 +44,7 @@ % }^^A % } % -% \date{Released 2023-05-05} +% \date{Released 2023-05-11} % % \maketitle % @@ -2815,8 +2815,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[EXP]{\file_full_name:n, \@@_full_name:n} -% \begin{macro}[EXP]{\@@_full_name_aux:nn} +% \begin{macro}[EXP]{\file_full_name:n, \@@_full_name:n, \@@_full_name_aux:n} +% \begin{macro}[EXP]{\@@_full_name_auxi:nn, \@@_full_name_auxii:nn} % \begin{macro}[EXP]{\@@_full_name_aux:Nnn} % \begin{macro}[EXP]{\@@_full_name_aux:nN} % \begin{macro}[EXP]{\@@_full_name_aux:nnN} @@ -2849,9 +2849,40 @@ \cs_new:Npn \@@_full_name:n #1 { \tl_if_blank:nF {#1} - { \exp_args:Nne \@@_full_name_aux:nn {#1} { \@@_size:n {#1} } } + { \exp_args:Nne \@@_full_name_auxii:nn {#1} { \@@_full_name_aux:n {#1} } } } -\cs_new:Npn \@@_full_name_aux:nn #1 #2 +% \end{macrocode} +% To avoid repeated reading of files we need to cache the loading: +% this is important as the code here is used by \emph{all} file checks. +% The same marker is used in the \LaTeXe{} kernel, meaning that we get a +% double-saving with for example \cs{IfFileExists}. As this is all about +% performance, we use the low-level approach for the conditionals. For +% a file already seen, the size is reported as $-1$ so it's distinct from +% any non-cached ones. +% \begin{macrocode} +\cs_new:Npn \@@_full_name_aux:n #1 + { + \if_cs_exist:w @@_seen_ \tl_to_str:n {#1} : \cs_end: + -1 + \else: + \exp_args:Ne \@@_full_name_auxi:nn { \@@_size:n {#1} } {#1} + \fi: + } +% \end{macrocode} +% We will need the size of files later, and we have to avoid the +% \cs{scan_stop:} causing issues if we are raising the flag. Thus there is +% a slightly odd gobble here. +% \begin{macrocode} +\cs_new:Npn \@@_full_name_auxi:nn #1#2 + { + \if:w \scan_stop: #1 \scan_stop: + \else: + \exp_after:wN \use_none:n + \cs:w @@_seen_ \tl_to_str:n {#2} : \cs_end: + #1 + \fi: + } +\cs_new:Npn \@@_full_name_auxii:nn #1 #2 { \tl_if_blank:nTF {#2} { @@ -2873,7 +2904,7 @@ \cs_new:Npn \@@_full_name_aux:Nnn #1#2#3 { \exp_args:Ne \@@_full_name_aux:nN { \tl_to_str:n {#3} / #2 } #1 } \cs_new:Npn \@@_full_name_aux:nN #1 - { \exp_args:Nne \@@_full_name_aux:nnN {#1} { \@@_size:n {#1} } } + { \exp_args:Nne \@@_full_name_aux:nnN {#1} { \@@_full_name_aux:n {#1} } } \cs_new:Npn \@@_full_name_aux:nnN #1 #2 #3 { \tl_if_blank:nF {#2} @@ -2913,14 +2944,15 @@ { #1 #3 } } \cs_new:Npn \@@_ext_check:nnn #1 - { \exp_args:Nne \@@_ext_check:nnnn {#1} { \@@_size:n {#1} } } + { \exp_args:Nne \@@_ext_check:nnnn {#1} { \@@_full_name_aux:n {#1} } } \cs_new:Npn \@@_ext_check:nnnn #1#2#3#4 { \tl_if_blank:nTF {#2} {#3} { - \int_compare:nNnTF - {#4} = {#2} + \bool_lazy_or:nnTF + { \int_compare_p:nNn {#4} = {#2} } + { \int_compare_p:nNn {#2} = { -1 } } {#1} {#3} } |