[latex3-commits] [git/LaTeX3-latex3-latex3] version-check: Use dependency check in expl3.dtx (51dcd1a9f)
PhelypeOleinik
tex.phelype at gmail.com
Sat Aug 1 03:32:39 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : version-check
Link : https://github.com/latex3/latex3/commit/51dcd1a9f060902c628de6e43b077dd8d75ba05e
>---------------------------------------------------------------
commit 51dcd1a9f060902c628de6e43b077dd8d75ba05e
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date: Fri Jul 31 22:32:39 2020 -0300
Use dependency check in expl3.dtx
>---------------------------------------------------------------
51dcd1a9f060902c628de6e43b077dd8d75ba05e
l3kernel/expl3.dtx | 97 ++++++++++++++++--------------------------------------
1 file changed, 29 insertions(+), 68 deletions(-)
diff --git a/l3kernel/expl3.dtx b/l3kernel/expl3.dtx
index 1f6bd55bb..906faf50d 100644
--- a/l3kernel/expl3.dtx
+++ b/l3kernel/expl3.dtx
@@ -1244,86 +1244,47 @@
%<@@=expl>
% \end{macrocode}
%
-% Several times users reported this error when loading \pkg{expl3}:
-% \begin{verbatim}
-% ! Undefined control sequence.
-% l.67 \bool
-% _new:N \g__expl_reload_bool
-% \end{verbatim}
-% raised in the reload block below. This happens because the reload
-% check below assumes that if the boolean \cs{g_@@_reload_bool} doesn't
-% exist, this file is being loaded for the first time, and \pkg{expl3}
-% syntax is on. This is a bit of a stretch for assumptions, but it's
-% valid as long as everything's in sync. However the problem reported
-% happened because of a stray format file in the user tree which didn't
-% have the reload code defined here (commit \texttt{1d16336}), so the
-% \cs{g_@@_reload_bool} doesn't exist, but \pkg{expl3} syntax is off,
-% thus the error.
-%
-% At this point, if we have \cs{c__kernel_expl_date_tl} defined, the
-% situation is straightforward: if it matches \cs{ExplLoaderFileDate},
-% then everything's as expected, so no need to worry. If it doesn't,
-% then the current version of \pkg{expl3} differs from the one in the
-% format, so raise a fatal error: the bahaviour is too unpredictable to
-% continue safely. Also, if the error is to be raised, then we're
-% reloading, which means that \pkg{expl3} syntax is off, so we turn it
-% on for the message.
+% At this point, if we have \cs{c__kernel_expl_date_tl} defined, just
+% call the \cs{__kernel_dependency_version_check:Nn} auxiliary to check
+% if it matches \cs{ExplLoaderFileDate}. Here the test is performed
+% only if \cs{c__kernel_expl_date_tl} exists because this file can be
+% loaded in a \LaTeXe{} format without \pkg{expl3} preloaded, where that
+% token list doesn't exist.
+%
+% This is all done in the \texttt{package} \pkg{docstrip} guard because
+% it doesn't apply to \pkg{expl3.ltx}.
% \begin{macrocode}
+%<*package>
\ifcsname\detokenize{c__kernel_expl_date_tl}\endcsname
- \expandafter\ifx\csname\detokenize
- {c__kernel_expl_date_tl}\endcsname\ExplLoaderFileDate
- \else
- \ExplSyntaxOn
- \__kernel_msg_set:nnn { kernel } { mismatched-expl3 }
- {
- Mismatched~expl3~detected!~Loading~expl3~will~abort.
- \\ \\
- The~version~of~expl3~preloaded~in~LaTeX~is~
- \c__kernel_expl_date_tl,~but~the~version~of~expl3~you~are~
- trying~to~load~is~dated~\ExplLoaderFileDate.~This~is~most~
- likely~due~to~a~stray~format~file~in~the~user~tree.~Please~
- make~sure~that~your~LaTeX~format~is~updated.
- }
- \exp_after:wN \ExplSyntaxOff \use:n
- {
- \__kernel_msg_critical:nn { kernel } { mismatched-expl3 }
- \use:c { fi: } \use:c { fi: }
- }
- \fi
+ \expandafter\@firstofone
+\else
% \end{macrocode}
-% If \cs{c__kernel_expl_date_tl} does \emph{not} exist, then we're on
-% uncharted lands (that is, any time prior to the version that
-% introduced this token list :-). Two cases might be here, depending
-% whether \pkg{expl3} is loaded into the kernel or not. If we're loading
-% \pkg{expl3} \enquote{normally} as a package, \pkg{expl3} syntax is on.
-% Otherwise it's already loaded in the kernel and we're reloading
-% \file{expl3.sty} so (\file{expl3-code.tex} doesn't load again and)
-% \pkg{expl3} syntax is off.
+% If \cs{c__kernel_expl_date_tl} does \emph{not} exist we may be loading
+% in a format without \pkg{expl3} preloaded or in the earlier (although
+% still compatible) version in which the error mentioned above showed
+% up. If loading as a package, \file{expl3-code.tex} got read and here
+% the \pkg{expl3} syntax is on. Otherwise it was already loaded in a
+% sligtly older kernel, so we fire the incompatibility error message and
+% abort loading.
% \begin{macrocode}
-\else
\ifodd\csname\detokenize{l__kernel_expl_bool}\endcsname
% \end{macrocode}
-% Package mode; all should be fine, since \file{expl3.sty} and
-% \file{expl3-code.tex} are both loaded in one go, so versions should
-% match (if they don't, it's detected above).
-% Also, we've just tested that \pkg{expl3} syntax is on, so the reload
-% test below will return false and \cs{bool_new:N} will run correctly.
+% In package mode all files are loaded in one go, so versions will
+% match, so nothing has to be done.
% \begin{macrocode}
+ \expandafter\expandafter
+ \expandafter\@gobble
\else
% \end{macrocode}
-% In this branch we're reloading, but there are still two cases to
-% consider (sigh\ldots); whether the version preloaded in the format
-% is recent enough to have \cs{g_@@_reload_bool} (2020-06-18 and
-% later) or not. If the boolean is there, we have to do nothing
-% because right ahead we deal with this case.
-% If it is not, we just have to create it:
+% And reloading in an incompatible version is an error:
% \begin{macrocode}
- \ExplSyntaxOn
- \bool_if_exist:NF \g_@@_reload_bool
- { \bool_new:N \g_@@_reload_bool }
- \ExplSyntaxOff
+ \expandafter\expandafter
+ \expandafter\@firstofone
\fi
\fi
+ {\csname\detokenize{__kernel_dependency_version_check:Nn}\endcsname
+ \ExplLoaderFileDate{expl3.sty}}%
+%</package>
% \end{macrocode}
%
% Here we can also detect whether we're reloading. This code goes into
More information about the latex3-commits
mailing list.