[latex3-commits] [git/LaTeX3-latex3-latex3] master: Defensive code against \time/\day/\month\/year issues (d2e8cba)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Feb 11 19:24:56 CET 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/d2e8cbac25d1377baeaf9bfdddf19f989f9bc6b2

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

commit d2e8cbac25d1377baeaf9bfdddf19f989f9bc6b2
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon Feb 11 18:24:56 2019 +0000

    Defensive code against \time/\day/\month\/year issues


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

d2e8cbac25d1377baeaf9bfdddf19f989f9bc6b2
 l3kernel/CHANGELOG.md |    4 ++++
 l3kernel/l3names.dtx  |   29 +++++++++++++++++++++++++++++
 l3kernel/l3sys.dtx    |   13 ++++++++++++-
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index feb0de2..003efdc 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,10 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Changed
+
+- Defensive code for redefinition of `\time`, `\day`, `\month` and `\year`
+
 ## [2019-02-03]
 
 ### Added
diff --git a/l3kernel/l3names.dtx b/l3kernel/l3names.dtx
index 0d6f5c5..f0f80f7 100644
--- a/l3kernel/l3names.dtx
+++ b/l3kernel/l3names.dtx
@@ -1326,6 +1326,35 @@
 \tex_fi:D
 %</package>
 %    \end{macrocode}
+% A few packages do unfortunate things to date-related primitives.
+%    \begin{macrocode}
+\tex_begingroup:D
+  \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_time:D }
+  \tex_edef:D \l_tmpb_tl { \tex_string:D \time }
+  \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+  \tex_else:D
+    \tex_global:D \tex_let:D \tex_time:D \tex_undefined:D
+  \tex_fi:D
+  \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_day:D }
+  \tex_edef:D \l_tmpb_tl { \tex_string:D \day }
+  \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+  \tex_else:D
+    \tex_global:D \tex_let:D \tex_day:D \tex_undefined:D
+  \tex_fi:D
+  \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_month:D }
+  \tex_edef:D \l_tmpb_tl { \tex_string:D \month }
+  \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+  \tex_else:D
+    \tex_global:D \tex_let:D \tex_month:D \tex_undefined:D
+  \tex_fi:D
+  \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_year:D }
+  \tex_edef:D \l_tmpb_tl { \tex_string:D \year }
+  \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+  \tex_else:D
+    \tex_global:D \tex_let:D \tex_year:D \tex_undefined:D
+  \tex_fi:D
+\tex_endgroup:D
+%    \end{macrocode}
 % Up to v0.80, \LuaTeX{} defines the \pdfTeX{} version data: rather
 % confusing. Removing them means that \cs{tex_pdftexversion:D} is
 % a marker for \pdfTeX{} alone: useful in engine-dependent code later.
diff --git a/l3kernel/l3sys.dtx b/l3kernel/l3sys.dtx
index c9958b6..daf493e 100644
--- a/l3kernel/l3sys.dtx
+++ b/l3kernel/l3sys.dtx
@@ -170,8 +170,9 @@
 %     \c_sys_month_int,
 %     \c_sys_year_int,
 %   }
-%   Copies of the information provided by \TeX{}
+%   Copies of the information provided by \TeX{}.
 %    \begin{macrocode}
+%<*initex>
 \int_const:Nn \c_sys_minute_int
   { \int_mod:nn { \tex_time:D } { 60 } }
 \int_const:Nn \c_sys_hour_int
@@ -179,6 +180,16 @@
 \int_const:Nn \c_sys_day_int   { \tex_day:D }
 \int_const:Nn \c_sys_month_int { \tex_month:D }
 \int_const:Nn \c_sys_year_int  { \tex_year:D }
+%</initex>
+%<*package>
+\int_const:Nn \c_sys_minute_int
+  { \int_mod:nn { \tex_primitive:D \time } { 60 } }
+\int_const:Nn \c_sys_hour_int
+  { \int_div_truncate:nn { \tex_primitive:D \time } { 60 } }
+\int_const:Nn \c_sys_day_int   { \tex_primitive:D \day }
+\int_const:Nn \c_sys_month_int { \tex_primitive:D \month }
+\int_const:Nn \c_sys_year_int  { \tex_primitive:D \year }
+%</package>
 %    \end{macrocode}
 % \end{variable}
 %





More information about the latex3-commits mailing list