Improve version test in chkconfig

This now only loads the package until it has the version information
and then ends the package input.

This way, we do not need to care about package peculiarities (having
to be loaded after \documentclass or internal dependencies which, if
not given, might break the whole configuration, see #13112)
This commit is contained in:
Juergen Spitzmueller 2024-10-17 09:55:31 +02:00
parent b9c8f2c3e2
commit 44f5fb3275

View File

@ -60,11 +60,6 @@
% the variable chk_<name>. % the variable chk_<name>.
%%% %%%
% we need to load the minmal class
% since some packages will error out
% on checking of no class is loaded
\documentclass{minimal}
\newcommand{\prefix}{+} % the character used by grep to filter 'good' output \newcommand{\prefix}{+} % the character used by grep to filter 'good' output
\newcommand{\AddLayout}[5][\default]{ \newcommand{\AddLayout}[5][\default]{
@ -125,12 +120,22 @@
#6 #6
\fi} \fi}
% For the version test below, we need to load the tested package.
% However, we are only interested in the version information, so
% we redefine an internal method of \ProvidesPackage to quit
% as soon as we have that information
\let\chk@pr@videpackage\@pr@videpackage
\def\@pr@videpackage[#1]{\chk@pr@videpackage[#1]\endinput}
% Tests whether an package is present and also adds the version to the package list % Tests whether an package is present and also adds the version to the package list
\newcommand{\TestPackageAddVersion}[2][\default]{ \newcommand{\TestPackageAddVersion}[2][\default]{
\def\default{#2} \def\default{#2}
\def\package@version{} \def\package@version{}
% The actual test only works after the package has been loaded
\IfFileExists{#1.sty}{% \IfFileExists{#1.sty}{%
% The actual test only works after the package has been loaded,
% but with the redefinition of \@pr@videpackage above, we quit
% as early as possible
\RequirePackage{#1}% \RequirePackage{#1}%
\protected@edef\package@@version{\csname ver@#1.sty\endcsname}% \protected@edef\package@@version{\csname ver@#1.sty\endcsname}%
\protected@edef\package@version{\expandafter\@parse@version\package@@version//00\@nil}% \protected@edef\package@version{\expandafter\@parse@version\package@@version//00\@nil}%