[latex3-commits] [git/LaTeX3-latex3-latex3] master: Added \file_timestamp_compare:nNn(TF) (05d5bb3)
Joseph Wright
joseph.wright at morningstar2.co.uk
Fri May 10 16:31:34 CEST 2019
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/05d5bb39b338368aed5b0df87933538cda6f7269
>---------------------------------------------------------------
commit 05d5bb39b338368aed5b0df87933538cda6f7269
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Fri May 10 15:31:29 2019 +0100
Added \file_timestamp_compare:nNn(TF)
Needed for epstopdf support.
>---------------------------------------------------------------
05d5bb39b338368aed5b0df87933538cda6f7269
l3kernel/CHANGELOG.md | 4 ++
l3kernel/l3candidates.dtx | 99 +++++++++++++++++++++++++++++++
l3kernel/testfiles/m3expl001.luatex.tlg | 8 +++
l3kernel/testfiles/m3expl001.ptex.tlg | 7 +++
l3kernel/testfiles/m3expl001.tlg | 7 +++
l3kernel/testfiles/m3expl001.uptex.tlg | 7 +++
l3kernel/testfiles/m3expl001.xetex.tlg | 7 +++
l3kernel/testfiles/m3expl003.luatex.tlg | 8 +++
l3kernel/testfiles/m3expl003.ptex.tlg | 7 +++
l3kernel/testfiles/m3expl003.tlg | 7 +++
l3kernel/testfiles/m3expl003.uptex.tlg | 7 +++
l3kernel/testfiles/m3expl003.xetex.tlg | 7 +++
12 files changed, 175 insertions(+)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 63e8548..ac2b378 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,10 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]
+### Added
+
+- Experimental `\file_timestamp_compare:nNn(TF)`
+
## [2019-05-09]
### Added
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 04ed6e0..5394357 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -299,6 +299,15 @@
%
% \section{Additions to \pkg{l3file}}
%
+% \begin{function}[added = 2019-05-10, TF]{\file_timestamp_compare:nNn}
+% \begin{syntax}
+% \cs{file_timestamp_compare: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.
+% \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}
@@ -2346,6 +2355,96 @@
% \subsection{Additions to \pkg{l3file}}
%
% \begin{macrocode}
+%<@@=file>
+% \end{macrocode}
+%
+% \begin{macro}{\@@_str_cmp:nn}
+% \begin{macro}{\@@_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{variable}
+% \begin{macrocode}
+\tl_new:N \l_@@_first_tl
+\tl_new:N \l_@@_second_tl
+% \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}[TF]{\file_timestamp_compare:nNn}
+% \begin{macro}[TF]{\@@_timestamp:n}
+% Comparison of file date can be done by using the low-level nature of the
+% string comparison functions. This could be expandable but that would
+% skip any file look-up: to stay consistent we retain that at the cost of
+% expansion.
+% \begin{macrocode}
+\prg_new_protected_conditional:Npnn \file_timestamp_compare:nNn #1#2#3
+ { T , F , TF }
+ {
+ \group_begin:
+ \file_get_full_name:nNTF {#1} \l_@@_first_tl
+ {
+ \file_get_full_name:nNTF {#3} \l_@@_second_tl
+ {
+ \if_int_compare:w
+ \@@_str_cmp:nn
+ { \@@_timestamp:n \exp_after:wN { \l_@@_first_tl } }
+ { \@@_timestamp:n \exp_after:wN { \l_@@_second_tl } }
+ #2 0 \exp_stop_f:
+ \group_end:
+ \prg_return_true:
+ \else:
+ \group_end:
+ \prg_return_false:
+ \fi:
+ }
+ {
+ \group_end:
+ \prg_return_false:
+ }
+ }
+ {
+ \group_end:
+ \prg_return_false:
+ }
+ }
+\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 }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macrocode}
%<@@=ior>
% \end{macrocode}
%
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 6f8fa66..b18101a 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -6050,6 +6050,14 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
+Defining \__file_str_cmp:nn on line ...
+Defining \__file_str_escape:n on line ...
+Defining \l__file_first_tl on line ...
+Defining \l__file_second_tl on line ...
+Defining \file_timestamp_compare:nNnT on line ...
+Defining \file_timestamp_compare:nNnF on line ...
+Defining \file_timestamp_compare:nNnTF on line ...
+Defining \__file_timestamp:n on line ...
Defining \ior_shell_open:Nn on line ...
Defining \__ior_shell_open:nN on line ...
Defining message LaTeX/kernel/pipe-failed on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index d701abc..fb38a6a 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -6045,6 +6045,13 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
+Defining \__file_str_cmp:nn on line ...
+Defining \l__file_first_tl on line ...
+Defining \l__file_second_tl on line ...
+Defining \file_timestamp_compare:nNnT on line ...
+Defining \file_timestamp_compare:nNnF on line ...
+Defining \file_timestamp_compare:nNnTF on line ...
+Defining \__file_timestamp:n on line ...
Defining \ior_shell_open:Nn on line ...
Defining \__ior_shell_open:nN on line ...
Defining message LaTeX/kernel/pipe-failed on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 6a4a30d..f12b37d 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -6045,6 +6045,13 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
+Defining \__file_str_cmp:nn on line ...
+Defining \l__file_first_tl on line ...
+Defining \l__file_second_tl on line ...
+Defining \file_timestamp_compare:nNnT on line ...
+Defining \file_timestamp_compare:nNnF on line ...
+Defining \file_timestamp_compare:nNnTF on line ...
+Defining \__file_timestamp:n on line ...
Defining \ior_shell_open:Nn on line ...
Defining \__ior_shell_open:nN on line ...
Defining message LaTeX/kernel/pipe-failed on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index e1aa180..939b1de 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -6042,6 +6042,13 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
+Defining \__file_str_cmp:nn on line ...
+Defining \l__file_first_tl on line ...
+Defining \l__file_second_tl on line ...
+Defining \file_timestamp_compare:nNnT on line ...
+Defining \file_timestamp_compare:nNnF on line ...
+Defining \file_timestamp_compare:nNnTF on line ...
+Defining \__file_timestamp:n on line ...
Defining \ior_shell_open:Nn on line ...
Defining \__ior_shell_open:nN on line ...
Defining message LaTeX/kernel/pipe-failed on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 3821880..9f5ebc3 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -6049,6 +6049,13 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
+Defining \__file_str_cmp:nn on line ...
+Defining \l__file_first_tl on line ...
+Defining \l__file_second_tl on line ...
+Defining \file_timestamp_compare:nNnT on line ...
+Defining \file_timestamp_compare:nNnF on line ...
+Defining \file_timestamp_compare:nNnTF on line ...
+Defining \__file_timestamp:n on line ...
Defining \ior_shell_open:Nn on line ...
Defining \__ior_shell_open:nN on line ...
Defining message LaTeX/kernel/pipe-failed on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 6f8fa66..b18101a 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -6050,6 +6050,14 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
+Defining \__file_str_cmp:nn on line ...
+Defining \__file_str_escape:n on line ...
+Defining \l__file_first_tl on line ...
+Defining \l__file_second_tl on line ...
+Defining \file_timestamp_compare:nNnT on line ...
+Defining \file_timestamp_compare:nNnF on line ...
+Defining \file_timestamp_compare:nNnTF on line ...
+Defining \__file_timestamp:n on line ...
Defining \ior_shell_open:Nn on line ...
Defining \__ior_shell_open:nN on line ...
Defining message LaTeX/kernel/pipe-failed on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index d701abc..fb38a6a 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -6045,6 +6045,13 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
+Defining \__file_str_cmp:nn on line ...
+Defining \l__file_first_tl on line ...
+Defining \l__file_second_tl on line ...
+Defining \file_timestamp_compare:nNnT on line ...
+Defining \file_timestamp_compare:nNnF on line ...
+Defining \file_timestamp_compare:nNnTF on line ...
+Defining \__file_timestamp:n on line ...
Defining \ior_shell_open:Nn on line ...
Defining \__ior_shell_open:nN on line ...
Defining message LaTeX/kernel/pipe-failed on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 6a4a30d..f12b37d 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -6045,6 +6045,13 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
+Defining \__file_str_cmp:nn on line ...
+Defining \l__file_first_tl on line ...
+Defining \l__file_second_tl on line ...
+Defining \file_timestamp_compare:nNnT on line ...
+Defining \file_timestamp_compare:nNnF on line ...
+Defining \file_timestamp_compare:nNnTF on line ...
+Defining \__file_timestamp:n on line ...
Defining \ior_shell_open:Nn on line ...
Defining \__ior_shell_open:nN on line ...
Defining message LaTeX/kernel/pipe-failed on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index e1aa180..939b1de 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -6042,6 +6042,13 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
+Defining \__file_str_cmp:nn on line ...
+Defining \l__file_first_tl on line ...
+Defining \l__file_second_tl on line ...
+Defining \file_timestamp_compare:nNnT on line ...
+Defining \file_timestamp_compare:nNnF on line ...
+Defining \file_timestamp_compare:nNnTF on line ...
+Defining \__file_timestamp:n on line ...
Defining \ior_shell_open:Nn on line ...
Defining \__ior_shell_open:nN on line ...
Defining message LaTeX/kernel/pipe-failed on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 3821880..9f5ebc3 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -6049,6 +6049,13 @@ Defining \sys_shell_now:n on line ...
Defining \sys_shell_now:x on line ...
Defining \sys_shell_shipout:n on line ...
Defining \sys_shell_shipout:x on line ...
+Defining \__file_str_cmp:nn on line ...
+Defining \l__file_first_tl on line ...
+Defining \l__file_second_tl on line ...
+Defining \file_timestamp_compare:nNnT on line ...
+Defining \file_timestamp_compare:nNnF on line ...
+Defining \file_timestamp_compare:nNnTF on line ...
+Defining \__file_timestamp:n on line ...
Defining \ior_shell_open:Nn on line ...
Defining \__ior_shell_open:nN on line ...
Defining message LaTeX/kernel/pipe-failed on line ...
More information about the latex3-commits
mailing list