[latex3-commits] [git/LaTeX3-latex3-latex3] master: Add \__kernel_dependency_version_check:Nn (be8b214fa)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Aug 20 19:09:56 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/be8b214faccd65ab03d357fad91b8c8f9ea6e64c
>---------------------------------------------------------------
commit be8b214faccd65ab03d357fad91b8c8f9ea6e64c
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date: Fri Jul 31 22:30:41 2020 -0300
Add \__kernel_dependency_version_check:Nn
>---------------------------------------------------------------
be8b214faccd65ab03d357fad91b8c8f9ea6e64c
l3kernel/l3file.dtx | 112 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 107 insertions(+), 5 deletions(-)
diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index 47c2c5a49..06950fdd7 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -2868,12 +2868,10 @@
% \end{macro}
% \end{macro}
% \begin{variable}{\g_@@_internal_ior}
-% A reserved stream to test for file existence, if required.
+% A reserved stream to test for file existence (if required), and for
+% opening a shell.
% \begin{macrocode}
-\bool_lazy_or:nnF
- { \cs_if_exist_p:N \tex_filesize:D }
- { \sys_if_engine_luatex_p: }
- { \ior_new:N \g_@@_internal_ior }
+\ior_new:N \g_@@_internal_ior
% \end{macrocode}
% \end{variable}
%
@@ -3545,6 +3543,110 @@
% \end{macro}
% \end{macro}
%
+% \subsection{Checking the version of kernel dependencies}
+%
+% \begin{macro}{\__kernel_dependency_version_check:Nn}
+% This function is responsible for checking if dependencies of the
+% \LaTeX3 kernel match the version preloaded in the \LaTeXe{} kernel.
+% If versions don't match, the function attempts to tell why by
+% searching for a possible stray format file.
+%
+% The function starts by checking if it needs to do anything at all.
+% Usually it doesn't, so just quit silently.
+% \begin{macrocode}
+\cs_new_protected:Npn \__kernel_dependency_version_check:Nn #1 #2
+ {
+ \tl_if_eq:NNF #1 \c__kernel_expl_date_tl
+ { \@@_mismatched_dependency_error:Nn #1 {#2} }
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\@@_mismatched_dependency_error:Nn}
+% If the versions differ, then we try to give the user some guidance.
+% This function starts by taking the engine name \cs{c_sys_engine_str}
+% and replacing |tex| by |latex|, then building a command of the form:
+% \begin{texttt}
+% kpsewhich --all --engine=\meta{engine} \meta{format}[-dev].fmt
+% \end{texttt}
+% to query the format files available. A shell is opened and each
+% line is read into a sequence.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_mismatched_dependency_error:Nn #1 #2
+ {
+ \exp_args:NNx \ior_shell_open:Nn \g_@@_internal_ior
+ {
+ kpsewhich ~ --all ~
+ --engine = \c_sys_engine_exec_str
+ \c_space_tl \c_sys_engine_format_str
+ \tl_if_empty:NF \development at branch@name { -dev } .fmt
+ }
+ \seq_clear:N \l_@@_tmp_seq
+ \ior_map_inline:Nn \g_@@_internal_ior
+ { \seq_put_right:Nn \l_@@_tmp_seq {##1} }
+ \ior_close:N \g_@@_internal_ior
+% \end{macrocode}
+% Now define a some shorthands so that we can use \cs{@latex at error}
+% (almost) easily:
+% \begin{macrocode}
+ \group_begin:
+ \cs_set:Npn \\ { \MessageBreak }
+ \cs_set_eq:NN \ \c_space_tl
+ \@latex at error
+ {
+ Mismatched~LaTeX~support~files~detected. \\
+ Loading~'#2'~aborted!
+% \end{macrocode}
+% \cs{c__kernel_expl_date_tl} may not exist, due to an older format,
+% so only print the dates when the sentinel token list exists:
+% \begin{macrocode}
+ \tl_if_exist:NT \c__kernel_expl_date_tl
+ {
+ \\ \\
+ The~L3~programming~layer~inside~the~LaTeX~format \\
+ are~dated~\c__kernel_expl_date_tl,~but~in~your~TeX~
+ tree~the~files \\ are~dated~#1.
+ }
+ \use_none:n
+ }
+ {
+% \end{macrocode}
+% The sequence containing the format files should have exactly one
+% item: the format file currently being run. If that's the case, the
+% cause of the error is not that, so print a generic help with some
+% possible causes. If more than one format file was found, then print
+% the list to the user, with appropriate indications of what's in the
+% system and what's in the user tree.
+% \begin{macrocode}
+ \int_compare:nNnTF { \seq_count:N \l_@@_tmp_seq } > 1
+ {
+ The~cause~seems~to~be~an~old~format~file~in~the~user~tree. \\
+ LaTeX~found~these~files:
+ \seq_map_tokens:Nn \l_@@_tmp_seq { \\~-~\use:n } \\
+ Try~deleting~the~file~in~the~user~tree~then~run~LaTeX~again.
+ }
+ {
+ The~most~likely~causes~are:
+ \\~-~A~recent~format~generation~failed;
+ \\~-~A~stray~format~file~in~the~user~tree~which~needs~
+ to~be~removed~or~rebuilt;
+ \\~-~You~are~running~a~manually~installed~version~of~#2 \\
+ \ \ \ which~is~incompatible~with~the~version~in~LaTeX. \\
+ }
+ \\
+ LaTeX~will~abort~loading~the~incompatible~support~files~
+ but~this~may~lead~to \\ later~errors.~Please~ensure~that~
+ your~LaTeX~format~is~correctly~regenerated.
+ }
+ \group_end:
+% \end{macrocode}
+% And finish by ending the current file.
+% \begin{macrocode}
+ \tex_endinput:D
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Messages}
%
% \begin{macrocode}
More information about the latex3-commits
mailing list.