summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3file.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3file.dtx202
1 files changed, 201 insertions, 1 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
index c40f61acbdf..cea19957dfa 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
@@ -44,7 +44,7 @@
% }^^A
% }
%
-% \date{Released 2019-09-19}
+% \date{Released 2019-09-28}
%
% \maketitle
%
@@ -271,6 +271,40 @@
% ignores any trailing new-line marker from the file it reads.
% \end{function}
%
+% \begin{function}[added = 2019-01-13]{\ior_map_variable:NNn}
+% \begin{syntax}
+% \cs{ior_map_variable:NNn} \meta{stream} \meta{tl~var} \Arg{code}
+% \end{syntax}
+% For each set of \meta{lines} obtained by calling \cs{ior_get:NN}
+% until reaching the end of the file, stores the \meta{lines} in the
+% \meta{tl~var} then applies the \meta{code}. The \meta{code} will
+% usually make use of the \meta{variable}, but this is not enforced.
+% The assignments to the \meta{variable} are local.
+% Its value after the loop is the last set of \meta{lines}, or its
+% original value if the \meta{stream} is empty. \TeX{} ignores
+% any trailing new-line marker from the file it reads.
+% This function is typically faster than \cs{ior_map_inline:Nn}.
+% \end{function}
+%
+% \begin{function}[added = 2019-01-13]{\ior_str_map_variable:NNn}
+% \begin{syntax}
+% \cs{ior_str_map_variable:NNn} \meta{stream} \meta{variable} \Arg{code}
+% \end{syntax}
+% For each \meta{line} in the \meta{stream}, stores the \meta{line} in
+% the \meta{variable} then applies the \meta{code}. The material is
+% read from the \meta{stream} as a series of tokens with category code
+% $12$ (other), with the exception of space characters which are given
+% category code $10$ (space). The \meta{code} will usually make use
+% of the \meta{variable}, but this is not enforced. The assignments
+% to the \meta{variable} are local. Its value after the loop is the
+% last \meta{line}, or its original value if the \meta{stream} is
+% empty. Note that \TeX{} removes trailing
+% space and tab characters (character codes 32 and 9) from every line
+% upon input. \TeX{} also ignores any trailing new-line marker from
+% the file it reads.
+% This function is typically faster than \cs{ior_str_map_inline:Nn}.
+% \end{function}
+%
% \begin{function}[added = 2012-06-29]{\ior_map_break:}
% \begin{syntax}
% \cs{ior_map_break:}
@@ -735,6 +769,28 @@
% This is not available in older versions of \XeTeX{}.
% \end{function}
%
+% \begin{function}[added = 2019-05-13, updated = 2019-09-20, pTF, EXP]
+% {\file_compare_timestamp:nNn}
+% \begin{syntax}
+% \cs{file_compare_timestamp:nNn} \Arg{file-1} \meta{comparator} \Arg{file-2} \Arg{true code} \Arg{false code}
+% \end{syntax}
+% Compares the file stamps on the two \meta{files} as indicated by
+% the \meta{comparator}, and inserts either the \meta{true code}
+% or \meta{false case} as required. A file which is not found
+% is treated as older than any file which is found. This allows for
+% example the construct
+% \begin{verbatim}
+% \file_compare_timestamp:nNnT { source-file } > { derived-file }
+% {
+% % Code to regenerate derived file
+% }
+% \end{verbatim}
+% to work when the derived file is entirely absent. The timestamp
+% of two absent files is regarded as different.
+% This is not available in older versions of \XeTeX{}.
+% \end{function}
+%
+%
% \begin{function}[updated = 2017-06-26]{\file_input:n}
% \begin{syntax}
% \cs{file_input:n} \Arg{file name}
@@ -2815,6 +2871,106 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}[EXP]{\@@_str_cmp:nn}
+% \begin{macro}[EXP]{\@@_str_escape:n}
+% As we are doing a fixed-length \enquote{big} integer comparison, it
+% is easiest to use the low-level behavior of string comparisons.
+% \begin{macrocode}
+\cs_new:Npn \@@_str_cmp:nn #1#2 { \tex_strcmp:D {#1} {#2} }
+\sys_if_engine_luatex:T
+ {
+ \cs_set:Npn \@@_str_cmp:nn #1#2
+ {
+ \lua_now:e
+ {
+ l3kernel.strcmp
+ (
+ " \@@_str_escape:n {#1}",
+ " \@@_str_escape:n {#2}"
+ )
+ }
+ }
+ \cs_new:Npn \@@_str_escape:n #1
+ {
+ \lua_escape:e
+ { \__kernel_tl_to_str:w \use:e { {#1} } }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}[EXP, pTF]{\file_compare_timestamp:nNn}
+% \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
+% string comparison functions.
+% \begin{macrocode}
+\prg_new_conditional:Npnn \file_compare_timestamp:nNn #1#2#3
+ { p , T , F , TF }
+ {
+ \exp_args:Nee \@@_compare_timestamp:nnN
+ { \file_full_name:n {#1} }
+ { \file_full_name:n {#3} }
+ #2
+ }
+\cs_new:Npn \@@_compare_timestamp:nnN #1#2#3
+ {
+ \tl_if_blank:nTF {#1}
+ {
+ \if_charcode:w #3 <
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+ {
+ \tl_if_blank:nTF {#2}
+ {
+ \if_charcode:w #3 >
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+ {
+ \if_int_compare:w
+ \@@_str_cmp:nn
+ { \@@_timestamp:n {#1} }
+ { \@@_timestamp:n {#2} }
+ #3 0 \exp_stop_f:
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+ }
+ }
+\sys_if_engine_luatex:TF
+ {
+ \cs_new:Npn \@@_timestamp:n #1
+ {
+ \lua_now:e
+ { l3kernel.filemoddate ( " \lua_escape:e {#1} " ) }
+ }
+ }
+ { \cs_new_eq:NN \@@_timestamp:n \tex_filemoddate:D }
+\cs_if_exist:NF \tex_filemoddate:D
+ {
+ \prg_set_conditional:Npnn \file_compare_timestamp:nNn #1#2#3
+ { p , T , F , TF }
+ {
+ \__kernel_msg_expandable_error:nnn
+ { kernel } { primitive-not-available }
+ { \(pdf)filemoddate }
+ \prg_return_false:
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}[TF]{\file_if_exist:n}
% The test for the existence of a file is a wrapper around the function to
% add a path to a file. If the file was found, the path contains
@@ -3164,6 +3320,50 @@
}
% \end{macrocode}
%
+% \subsection{Functions delayed from earlier modules}
+%
+%<@@=sys>
+%
+% \begin{variable}{\c_sys_platform_str}
+% Detecting the platform on \LuaTeX{} is easy: for other engines, we use
+% the fact that the two common cases have special null files. It is possible
+% to probe further (see package \pkg{platform}), but that requires shell
+% escape and seems unlikely to be useful. This is set up here as it requires
+% file searching.
+% \begin{macrocode}
+\sys_if_engine_luatex:TF
+ {
+ \str_const:Nx \c_sys_platform_str
+ { \tex_directlua:D { tex.print(os.type) } }
+ }
+ {
+ \file_if_exist:nTF { nul: }
+ {
+ \file_if_exist:nF { /dev/null }
+ { \str_const:Nn \c_sys_platform_str { windows } }
+ }
+ {
+ \file_if_exist:nT { /dev/null }
+ { \str_const:Nn \c_sys_platform_str { unix } }
+ }
+ }
+\cs_if_exist:NF \c_sys_platform_str
+ { \str_const:Nn \c_sys_platform_str { unknown } }
+% \end{macrocode}
+% \end{variable}
+% \begin{macro}[pTF]{\sys_if_platform_unix:}
+% \begin{macro}[pTF]{\sys_if_platform_windows:}
+% We can now set up the tests.
+% \begin{macrocode}
+\clist_map_inline:nn { unix , windows }
+ {
+ \@@_const:nn { sys_if_platform_ #1 }
+ { \str_if_eq_p:Vn \c_sys_platform_str { #1 } }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}