From 09db320caf1490e42da924b8386dcf8ef4a04af0 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 3 Feb 2020 22:31:24 +0000 Subject: filehook (3feb20) git-svn-id: svn://tug.org/texlive/trunk@53655 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/filehook/README | 3 +- Master/texmf-dist/doc/latex/filehook/filehook.pdf | Bin 267294 -> 266229 bytes .../texmf-dist/source/latex/filehook/filehook.dtx | 352 ++++++++++----------- .../tex/latex/filehook/filehook-fink.sty | 2 +- .../tex/latex/filehook/filehook-listings.sty | 2 +- .../tex/latex/filehook/filehook-memoir.sty | 47 ++- .../tex/latex/filehook/filehook-scrlfile.sty | 54 ++-- Master/texmf-dist/tex/latex/filehook/filehook.sty | 203 +++++------- 8 files changed, 312 insertions(+), 351 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/filehook/README b/Master/texmf-dist/doc/latex/filehook/README index a521e4f062b..25cc0e39b10 100644 --- a/Master/texmf-dist/doc/latex/filehook/README +++ b/Master/texmf-dist/doc/latex/filehook/README @@ -1,7 +1,6 @@ LaTeX package 'filehook' ~~~~~~~~~~~~~~~~~~~~~~~~ -Copyright (c) 2010-2019 by Martin Scharrer -WWW: http://latex.scharrer-online.de/ +Copyright (c) 2010-2020 by Martin Scharrer Code repository: https://bitbucket.org/martin_scharrer/filehook Provides several file hooks for files read by \input, \include and \InputIfFileExists. diff --git a/Master/texmf-dist/doc/latex/filehook/filehook.pdf b/Master/texmf-dist/doc/latex/filehook/filehook.pdf index ce6afd430f6..4d3462623b9 100644 Binary files a/Master/texmf-dist/doc/latex/filehook/filehook.pdf and b/Master/texmf-dist/doc/latex/filehook/filehook.pdf differ diff --git a/Master/texmf-dist/source/latex/filehook/filehook.dtx b/Master/texmf-dist/source/latex/filehook/filehook.dtx index efaeb3d5a87..0cd0f633541 100644 --- a/Master/texmf-dist/source/latex/filehook/filehook.dtx +++ b/Master/texmf-dist/source/latex/filehook/filehook.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment %<=*COPYRIGHT> -%% Copyright (C) 2011-2019 by Martin Scharrer +%% Copyright (C) 2011-2020 by Martin Scharrer %% ---------------------------------------------------------------------- %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -26,10 +26,10 @@ %<*driver> \ProvidesFile{filehook.dtx}[% %<=*DATE> - 2019/10/03 + 2020/02/03 %<=/DATE> %<=*VERSION> - v0.6 + v0.7 %<=/VERSION> Hooks for input files] \documentclass{ydoc} @@ -55,7 +55,7 @@ % % \fi % -% \CheckSum{1093} +% \CheckSum{1011} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -97,6 +97,7 @@ % \changes{v0.5d}{2011/10/12}{Fix for fall-back code.} % \changes{v0.5e}{2019/08/19}{Fix for new LaTeX format.} % \changes{v0.6}{2019/10/03}{Fix for InputIfFileExists for LaTeX format 2019/10/01.} +% \changes{v0.7}{2020/02/03}{Further fixes for InputIfFileExists for LaTeX format 2019/10/01.} % % \GetFileInfo{filehook.dtx} % @@ -530,11 +531,67 @@ \ProcessOptions\relax % \end{macrocode} % +% \subsection{General stuff} +% +% \begin{macro}{\iffilehook@newfmt} +% \begin{macrocode} +\newif\iffilehook@newfmt +\@ifl@t@r\fmtversion{2019/10/01}{\filehook@newfmttrue}{\filehook@newfmtfalse} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\filehook@let}[2]{}{} +% \begin{macrocode} +\def\filehook@let#1#2{% + \expandafter\ifx\csname #2\space\endcsname\relax + \expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname + \else + \expandafter\def\csname #1\expandafter\endcsname\expandafter{\expandafter\protect\csname #1\space\endcsname}% + \expandafter\let\csname #1\space\expandafter\endcsname\csname #2\space\endcsname + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\filehook@glet}[2]{}{} +% \begin{macrocode} +\def\filehook@glet#1#2{% + \expandafter\ifx\csname #2\space\endcsname\relax + \expandafter\global\expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname + \else + \expandafter\global\expandafter\def\csname #1\expandafter\endcsname\expandafter{\expandafter\protect\csname #1\space\endcsname}% + \expandafter\global\expandafter\let\csname #1\space\expandafter\endcsname\csname #2\space\endcsname + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\filehook@cmp}[2]{}{} +% Compare two macros definition including its space form in case of robust macros. +% \begin{macrocode} +\def\filehook@cmp#1#2{% + \expandafter\ifx\csname #2\space\endcsname\relax + \expandafter\ifx\csname #1\expandafter\endcsname\csname #2\endcsname + \expandafter\expandafter\expandafter\@firstoftwo + \else + \expandafter\expandafter\expandafter\@secondoftwo + \fi + \else + \expandafter\ifx\csname #1\space\expandafter\endcsname\csname #2\space\endcsname + \expandafter\expandafter\expandafter\@firstoftwo + \else + \expandafter\expandafter\expandafter\@secondoftwo + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% % % \subsection{Initialisation of Hooks} % The general hooks are initialised to call the file specific hooks. % -% % \begin{macro}{\filehook@csuse} % \begin{macrocode} \begingroup @@ -553,7 +610,7 @@ % \begin{macro}{\filehook@include@atbegin} % \begin{macrocode} \def\filehook@include@atbegin#1{% - \let\InputIfFileExists\filehook@@InputIfFileExists + \filehook@let{InputIfFileExists}{filehook@@InputIfFileExists}% \filehook@csuse{\filehook@include@atbegin@#1}% \filehook@include@@atbegin } @@ -599,7 +656,7 @@ % \begin{macro}{\filehook@input@atbegin} % \begin{macrocode} \def\filehook@input@atbegin#1{% - \let\InputIfFileExists\filehook@@InputIfFileExists + \filehook@let{InputIfFileExists}{filehook@@InputIfFileExists}% \filehook@csuse{\filehook@input@atbegin@\filehook@ensureext{#1}}% \filehook@input@@atbegin } @@ -1108,16 +1165,14 @@ % This is always done inside a group to keep them temporary only. % The token register is used to avoid doubling of macro argument characters. % -% \begin{macrocode} -\newif\iffilehook@newfmt -\@ifl@t@r\fmtversion{2019/10/01}{\filehook@newfmttrue}{\filehook@newfmtfalse} -% \end{macrocode} -% % \begin{macro}{\latex@InputIfFileExists} % Standard \LaTeX\ definition of \Macro\InputIfFileExists. % \begin{macrocode} \iffilehook@newfmt -\DeclareRobustCommand \latex@InputIfFileExists[2]{% +\expandafter\def\expandafter\latex@InputIfFileExists\expandafter{% + \expandafter\protect\csname InputIfFileExists\space\endcsname +} +\expandafter\long\expandafter\def\csname latex@InputIfFileExists\space\endcsname#1#2{% \IfFileExists{#1}% {% \expandafter\@swaptwoargs\expandafter @@ -1136,7 +1191,7 @@ % % \begin{macro}{\filehook@default@InputIfFileExists} % \begin{macrocode} -\long\gdef\filehook@default@InputIfFileExists#1#2{% +\DeclareRobustCommand\filehook@default@InputIfFileExists[2]{% \IfFileExists{#1}% {\expandafter\filehook@swap \expandafter{\@filef@und}% @@ -1149,12 +1204,16 @@ }% } % \end{macrocode} +% Make sure definition is global: +% \begin{macrocode} +\filehook@glet{filehook@default@InputIfFileExists}{filehook@default@InputIfFileExists}% +% \end{macrocode} % \end{macro} % % \begin{macro}{\filehook@@default@InputIfFileExists} % \begin{macrocode} -\long\gdef\filehook@@default@InputIfFileExists#1#2{% - \let\InputIfFileExists\filehook@InputIfFileExists +\DeclareRobustCommand\filehook@@default@InputIfFileExists[2]{% + \filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% \IfFileExists{#1}% {\expandafter\filehook@swap \expandafter{\@filef@und}% @@ -1165,88 +1224,9 @@ }% } % \end{macrocode} -% \end{macro} -% -% \begin{macro}{\scrlfile@InputIfFileExists} -% \begin{macrocode} -\long\def\scrlfile@InputIfFileExists#1#2{% - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname #1-@alias\endcsname\relax - \expandafter\@secondoftwo - \else - \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}% - \expandafter\@firstoftwo - \fi - {% - \expandafter\InputIfFileExists\expandafter{\csname - #1-@alias\endcsname}{#2}% - }% - {\IfFileExists{#1}{% - \scr@load@hook{before}{#1}% - #2\@addtofilelist{#1}% - \@@input \@filef@und - \scr@load@hook{after}{#1}% - }}% -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\filehook@scrlfile@InputIfFileExists} -% \begin{macrocode} -\long\def\filehook@scrlfile@InputIfFileExists#1#2{% - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname #1-@alias\endcsname\relax - \expandafter\@secondoftwo - \else - \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}% - \expandafter\@firstoftwo - \fi - {% - \expandafter\InputIfFileExists\expandafter{\csname - #1-@alias\endcsname}{#2}% - }% - {\IfFileExists{#1}{% - \expandafter\filehook@swap - \expandafter{\@filef@und}% - {\scr@load@hook{before}{#1}% - #2\@addtofilelist{#1}% - \filehook@every@atbegin{#1}% - \filehook@atbegin{#1}% - \@@input}% - \filehook@atend{#1}% - \filehook@every@atend{#1}% - \scr@load@hook{after}{#1}% - }}% -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\filehook@@scrlfile@InputIfFileExists} +% Make sure definition is global: % \begin{macrocode} -\long\def\filehook@@scrlfile@InputIfFileExists#1#2{% - \let\InputIfFileExists\filehook@InputIfFileExists - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname #1-@alias\endcsname\relax - \expandafter\@secondoftwo - \else - \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}% - \expandafter\@firstoftwo - \fi - {% - \expandafter\InputIfFileExists\expandafter{\csname - #1-@alias\endcsname}{#2}% - }% - {\IfFileExists{#1}{% - \expandafter\filehook@swap - \expandafter{\@filef@und}% - {\scr@load@hook{before}{#1}% - #2\@addtofilelist{#1}% - \filehook@atbegin{#1}% - \@@input}% - \filehook@atend{#1}% - \scr@load@hook{after}{#1}% - }}% -} +\filehook@glet{filehook@@default@InputIfFileExists}{filehook@@default@InputIfFileExists}% % \end{macrocode} % \end{macro} % @@ -1256,8 +1236,8 @@ % In order to also support it when it is loaded afterwards the two hooks below are used to revert the definition % before the package and patch it afterwards. % \begin{macrocode} -\AtBeginOfPackageFile*{scrlfile}{% - \let\InputIfFileExists\latex@InputIfFileExists +\AtBeginOfPackageFile{scrlfile}{% + \filehook@glet{InputIfFileExists}{latex@InputIfFileExists}% }% \AtEndOfPackageFile*{scrlfile}{% \RequirePackage{filehook-scrlfile}% @@ -1268,7 +1248,7 @@ \AtBeginOfPackageFile*{fink}{% \RequirePackage{kvoptions}% \begingroup - \let\InputIfFileExists\latex@InputIfFileExists + \filehook@let{InputIfFileExists}{latex@InputIfFileExists}% }% \AtEndOfPackageFile*{fink}{% \edef\@tempa{\noexpand\PassOptionsToPackage{mainext=\fnk@mainext,maindir=\fnk@maindir}{currfile}}% @@ -1281,9 +1261,8 @@ % exact same position. Please note that the case when |memoir| is used together with |scrlfile| is not explicitly covered. % In this case the |scrlfile| package will overwrite |memoir|s definition. % \begin{macrocode} -\AtBeginOfClassFile*{memoir}{% - \let\filehook@@InputIfFileExists\latex@InputIfFileExists - \let\InputIfFileExists\latex@InputIfFileExists +\AtBeginOfClassFile{memoir}{% + \filehook@let{InputIfFileExists}{latex@InputIfFileExists}% \let\@iinput\filehook@orig@@iinput }% \AtEndOfClassFile*{memoir}{% @@ -1295,45 +1274,28 @@ % error is given if any other unknown definition is detected. % The \opt{force} option will change the error into a warning and overwrite the macro with the default. % \begin{macrocode} -\def\@tempa{9}% -\ifx\InputIfFileExists\filehook@InputIfFileExists - \def\@tempa{0}% -\else - \iffilehook@force - \def\@tempa{1}% - \else - \iffilehook@newfmt - % check if both the robust \InputIfFileExist and its internal macro match the default LaTeX definition - \edef\@tempb{\noexpand\protect\expandafter\noexpand\csname InputIfFileExists\space\endcsname}% - \ifx\InputIfFileExists\@tempb - \expandafter\ifx\csname InputIfFileExists\space\expandafter\endcsname\csname latex@InputIfFileExists\space\endcsname - \def\@tempa{1}% - \fi - \fi - \else\ifx\InputIfFileExists\latex@InputIfFileExists - \def\@tempa{1}% - \fi\fi - \fi -\fi -% -\ifcase\@tempa -\relax% 0 -\or% 1 - \let\filehook@InputIfFileExists\filehook@default@InputIfFileExists - \let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists - \iffilehook@newfmt - \expandafter\let\csname InputIfFileExists\space\endcsname\filehook@InputIfFileExists - \else - \let\InputIfFileExists\filehook@InputIfFileExists - \fi - \iffilehook@force - \PackageWarning{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J% - The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% - \fi -\else - \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J% - Use the 'force' option of 'filehook' to overwrite it.}{}% -\fi +\filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}% + {}% already set up + {% + \filehook@cmp{InputIfFileExists}{latex@InputIfFileExists}% + {% + \filehook@let{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% + \filehook@let{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% + \filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% + }% + {% + \iffilehook@force + \filehook@let{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% + \filehook@let{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% + \filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% + \PackageWarning{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J% + The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% + \else + \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J% + Use the 'force' option of 'filehook' to overwrite it.}{}% + \fi + }% + }% % \end{macrocode} % \end{macro} % @@ -1341,10 +1303,10 @@ \AtBeginDocument{% % Check if definition got changed again. For the new LaTeX format we check again \InputIfFileExists, % for the old format to \InputIfFileExists directly. - \expandafter\ifx\csname InputIfFileExists\iffilehook@newfmt\space\fi\endcsname\filehook@InputIfFileExists\else + \filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}{}{% \PackageWarning{filehook}{Macro \string\InputIfFileExists\space got redefined after 'filehook' was loaded.^^J% - Certain file hooks might now be dysfunctional!} - \fi + Certain file hooks might now be dysfunctional!}% + }% } % \end{macrocode} % @@ -1358,7 +1320,7 @@ % \begin{macrocode} % \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\ProvidesPackage{filehook-memoir}[2011/01/03 v0.1 filehook patch for memoir class] +\ProvidesPackage{filehook-memoir}[2020/02/02 v0.2 filehook patch for memoir class] % \end{macrocode} % % \begin{macrocode} @@ -1367,35 +1329,53 @@ % \end{macrocode} % % \begin{macro}{\memoir@InputIfFileExists} +% The definition taken from memoir.cls. Copyright see there. % \begin{macrocode} -\long\def\memoir@InputIfFileExists#1#2{% +\ifcsname InputIfFileExists\space\endcsname + \DeclareRobustCommand \memoir@InputIfFileExists[2]{% + \IfFileExists{#1}% + {% + \expandafter\@swaptwoargs\expandafter + {\@filef@und\m@matendf{#1}\killm@matf{#1}}{% + #2\@addtofilelist{#1}\m@matbeginf{#1}\@@input% + }% + }% + } +\else + % Old definition +\renewcommand{\memoir@InputIfFileExists}[2]{% \IfFileExists{#1}% {#2\@addtofilelist{#1}\m@matbeginf{#1}% \@@input \@filef@und \m@matendf{#1}% \killm@matf{#1}}% } +\fi % \end{macrocode} % \end{macro} % % \begin{macrocode} -\ifcase - \ifx\InputIfFileExists\latex@InputIfFileExists 0\else - \ifx\InputIfFileExists\memoir@InputIfFileExists 0\else - 1% - \fi\fi -\relax - \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists - \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists - \global\let\InputIfFileExists\filehook@InputIfFileExists +\@tempswafalse +\filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}% + {\@tempswatrue}% + {% + \filehook@cmp{InputIfFileExists}{memoir@InputIfFileExists}% + {\@tempswatrue}% + {}% + }% + +\if@tempswa + \filehook@glet{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% + \filehook@glet{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% + \filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% \filehook@appendwarg\filehook@atbegin{\m@matbeginf{#1}}% \filehook@prefixwarg\filehook@atend{\m@matendf{#1}\killm@matf{#1}}% \PackageInfo{filehook}{Detected 'memoir' class: the memoir hooks will be moved to the `At...OfFiles' hooks} \else \iffilehook@force - \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists - \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists - \global\let\InputIfFileExists\filehook@InputIfFileExists + \filehook@glet{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% + \filehook@glet{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% + \filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% \PackageWarning{filehook}{Detected 'memoir' class with unknown definition of \string\InputIfFileExists.^^J% The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% \else @@ -1455,14 +1435,17 @@ % \begin{macrocode} % \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\ProvidesPackage{filehook-scrlfile}[2011/01/03 v0.1 filehook patch for scrlfile package] +\ProvidesPackage{filehook-scrlfile}[2020/02/02 v0.2 filehook patch for scrlfile package] \RequirePackage{filehook} \begingroup % \end{macrocode} % % \begin{macro}{\scrlfile@InputIfFileExists} % \begin{macrocode} -\long\def\scrlfile@InputIfFileExists#1#2{% +\expandafter\def\expandafter\sclrfile@InputIfFileExists\expandafter{% + \expandafter\protect\csname InputIfFileExists\space\endcsname +} +\expandafter\long\expandafter\def\csname scrlfile@InputIfFileExists\space\endcsname#1#2{% \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname #1-@alias\endcsname\relax \expandafter\@secondoftwo @@ -1472,21 +1455,19 @@ \fi {% \expandafter\InputIfFileExists\expandafter{\csname - #1-@alias\endcsname}{#2}% +#1-@alias\endcsname}{#2}% }% {\IfFileExists{#1}{% - \scr@load@hook{before}{#1}% - #2\@addtofilelist{#1}% - \@@input \@filef@und - \scr@load@hook{after}{#1}% - }}% + \expandafter\scr@input@withhook\expandafter{\@filef@und}{#1}{#2}}% + }% } % \end{macrocode} % \end{macro} % +% % \begin{macro}{\filehook@scrlfile@InputIfFileExists} % \begin{macrocode} -\long\def\filehook@scrlfile@InputIfFileExists#1#2{% +\DeclareRobustCommand\filehook@scrlfile@InputIfFileExists[2]{% \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname #1-@alias\endcsname\relax \expandafter\@secondoftwo @@ -1511,13 +1492,15 @@ \scr@load@hook{after}{#1}% }}% } +\filehook@glet{filehook@scrlfile@InputIfFileExists}{filehook@scrlfile@InputIfFileExists}% % \end{macrocode} % \end{macro} % +% % \begin{macro}{\filehook@@scrlfile@InputIfFileExists} % \begin{macrocode} -\long\def\filehook@@scrlfile@InputIfFileExists#1#2{% - \let\InputIfFileExists\filehook@InputIfFileExists +\DeclareRobustCommand\filehook@@scrlfile@InputIfFileExists[2]{% + \filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname #1-@alias\endcsname\relax \expandafter\@secondoftwo @@ -1540,6 +1523,7 @@ \scr@load@hook{after}{#1}% }}% } +\filehook@glet{filehook@@scrlfile@InputIfFileExists}{filehook@@scrlfile@InputIfFileExists}% % \end{macrocode} % \end{macro} % @@ -1548,21 +1532,25 @@ % not after the |#2\@addtofilelist{#1}| code. Otherwise the |filehook|s could simply be added to these hooks. % Note that this will stop working if |scrlfile| ever changes its definition of the \Macro\InputIfFileExists macro. % \begin{macrocode} -\ifcase - \ifx\InputIfFileExists\latex@InputIfFileExists 0\else - \ifx\InputIfFileExists\scrlfile@InputIfFileExists 0\else - 1% - \fi\fi -\relax - \global\let\filehook@InputIfFileExists\filehook@scrlfile@InputIfFileExists - \global\let\filehook@@InputIfFileExists\filehook@@scrlfile@InputIfFileExists - \global\let\InputIfFileExists\filehook@InputIfFileExists +\@tempswafalse +\filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}% + {\@tempswatrue}% + {% + \filehook@cmp{InputIfFileExists}{scrlfile@InputIfFileExists}% + {\@tempswatrue}% + {}% + }% + +\if@tempswa + \filehook@glet{filehook@InputIfFileExists}{filehook@scrlfile@InputIfFileExists}% + \filehook@glet{filehook@@InputIfFileExists}{filehook@@scrlfile@InputIfFileExists}% + \filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% \PackageInfo{filehook}{Package 'scrlfile' detected and compensated for}% \else \iffilehook@force - \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists - \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists - \global\let\InputIfFileExists\filehook@InputIfFileExists + \filehook@glet{filehook@InputIfFileExists}{filehook@scrlfile@InputIfFileExists}% + \filehook@glet{filehook@@InputIfFileExists}{filehook@@scrlfile@InputIfFileExists}% + \filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% \PackageWarning{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists.^^J% The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% \else diff --git a/Master/texmf-dist/tex/latex/filehook/filehook-fink.sty b/Master/texmf-dist/tex/latex/filehook/filehook-fink.sty index 0485e1bc74b..93605a2c9f0 100644 --- a/Master/texmf-dist/tex/latex/filehook/filehook-fink.sty +++ b/Master/texmf-dist/tex/latex/filehook/filehook-fink.sty @@ -1,4 +1,4 @@ -%% Copyright (C) 2011-2019 by Martin Scharrer +%% Copyright (C) 2011-2020 by Martin Scharrer %% ---------------------------------------------------------------------- %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 diff --git a/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty b/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty index e43aa1dd864..f5f94482a12 100644 --- a/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty +++ b/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty @@ -1,4 +1,4 @@ -%% Copyright (C) 2011-2019 by Martin Scharrer +%% Copyright (C) 2011-2020 by Martin Scharrer %% ---------------------------------------------------------------------- %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 diff --git a/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty b/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty index 24f9ffec076..fe1bf3a4773 100644 --- a/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty +++ b/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty @@ -1,4 +1,4 @@ -%% Copyright (C) 2011-2019 by Martin Scharrer +%% Copyright (C) 2011-2020 by Martin Scharrer %% ---------------------------------------------------------------------- %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -18,33 +18,50 @@ %% and pgf-filehook.sty %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\ProvidesPackage{filehook-memoir}[2011/01/03 v0.1 filehook patch for memoir class] +\ProvidesPackage{filehook-memoir}[2020/02/02 v0.2 filehook patch for memoir class] \RequirePackage{filehook} \begingroup -\long\def\memoir@InputIfFileExists#1#2{% +\ifcsname InputIfFileExists\space\endcsname + \DeclareRobustCommand \memoir@InputIfFileExists[2]{% + \IfFileExists{#1}% + {% + \expandafter\@swaptwoargs\expandafter + {\@filef@und\m@matendf{#1}\killm@matf{#1}}{% + #2\@addtofilelist{#1}\m@matbeginf{#1}\@@input% + }% + }% + } +\else + % Old definition +\renewcommand{\memoir@InputIfFileExists}[2]{% \IfFileExists{#1}% {#2\@addtofilelist{#1}\m@matbeginf{#1}% \@@input \@filef@und \m@matendf{#1}% \killm@matf{#1}}% } -\ifcase - \ifx\InputIfFileExists\latex@InputIfFileExists 0\else - \ifx\InputIfFileExists\memoir@InputIfFileExists 0\else - 1% - \fi\fi -\relax - \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists - \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists - \global\let\InputIfFileExists\filehook@InputIfFileExists +\fi +\@tempswafalse +\filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}% + {\@tempswatrue}% + {% + \filehook@cmp{InputIfFileExists}{memoir@InputIfFileExists}% + {\@tempswatrue}% + {}% + }% + +\if@tempswa + \filehook@glet{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% + \filehook@glet{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% + \filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% \filehook@appendwarg\filehook@atbegin{\m@matbeginf{#1}}% \filehook@prefixwarg\filehook@atend{\m@matendf{#1}\killm@matf{#1}}% \PackageInfo{filehook}{Detected 'memoir' class: the memoir hooks will be moved to the `At...OfFiles' hooks} \else \iffilehook@force - \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists - \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists - \global\let\InputIfFileExists\filehook@InputIfFileExists + \filehook@glet{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% + \filehook@glet{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% + \filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% \PackageWarning{filehook}{Detected 'memoir' class with unknown definition of \string\InputIfFileExists.^^J% The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% \else diff --git a/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty b/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty index 682ed649d7d..bb3d60279fc 100644 --- a/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty +++ b/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty @@ -1,4 +1,4 @@ -%% Copyright (C) 2011-2019 by Martin Scharrer +%% Copyright (C) 2011-2020 by Martin Scharrer %% ---------------------------------------------------------------------- %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -18,10 +18,13 @@ %% and pgf-filehook.sty %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\ProvidesPackage{filehook-scrlfile}[2011/01/03 v0.1 filehook patch for scrlfile package] +\ProvidesPackage{filehook-scrlfile}[2020/02/02 v0.2 filehook patch for scrlfile package] \RequirePackage{filehook} \begingroup -\long\def\scrlfile@InputIfFileExists#1#2{% +\expandafter\def\expandafter\sclrfile@InputIfFileExists\expandafter{% + \expandafter\protect\csname InputIfFileExists\space\endcsname +} +\expandafter\long\expandafter\def\csname scrlfile@InputIfFileExists\space\endcsname#1#2{% \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname #1-@alias\endcsname\relax \expandafter\@secondoftwo @@ -31,16 +34,13 @@ \fi {% \expandafter\InputIfFileExists\expandafter{\csname - #1-@alias\endcsname}{#2}% +#1-@alias\endcsname}{#2}% }% {\IfFileExists{#1}{% - \scr@load@hook{before}{#1}% - #2\@addtofilelist{#1}% - \@@input \@filef@und - \scr@load@hook{after}{#1}% - }}% + \expandafter\scr@input@withhook\expandafter{\@filef@und}{#1}{#2}}% + }% } -\long\def\filehook@scrlfile@InputIfFileExists#1#2{% +\DeclareRobustCommand\filehook@scrlfile@InputIfFileExists[2]{% \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname #1-@alias\endcsname\relax \expandafter\@secondoftwo @@ -65,8 +65,9 @@ \scr@load@hook{after}{#1}% }}% } -\long\def\filehook@@scrlfile@InputIfFileExists#1#2{% - \let\InputIfFileExists\filehook@InputIfFileExists +\filehook@glet{filehook@scrlfile@InputIfFileExists}{filehook@scrlfile@InputIfFileExists}% +\DeclareRobustCommand\filehook@@scrlfile@InputIfFileExists[2]{% + \filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname #1-@alias\endcsname\relax \expandafter\@secondoftwo @@ -89,21 +90,26 @@ \scr@load@hook{after}{#1}% }}% } -\ifcase - \ifx\InputIfFileExists\latex@InputIfFileExists 0\else - \ifx\InputIfFileExists\scrlfile@InputIfFileExists 0\else - 1% - \fi\fi -\relax - \global\let\filehook@InputIfFileExists\filehook@scrlfile@InputIfFileExists - \global\let\filehook@@InputIfFileExists\filehook@@scrlfile@InputIfFileExists - \global\let\InputIfFileExists\filehook@InputIfFileExists +\filehook@glet{filehook@@scrlfile@InputIfFileExists}{filehook@@scrlfile@InputIfFileExists}% +\@tempswafalse +\filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}% + {\@tempswatrue}% + {% + \filehook@cmp{InputIfFileExists}{scrlfile@InputIfFileExists}% + {\@tempswatrue}% + {}% + }% + +\if@tempswa + \filehook@glet{filehook@InputIfFileExists}{filehook@scrlfile@InputIfFileExists}% + \filehook@glet{filehook@@InputIfFileExists}{filehook@@scrlfile@InputIfFileExists}% + \filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% \PackageInfo{filehook}{Package 'scrlfile' detected and compensated for}% \else \iffilehook@force - \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists - \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists - \global\let\InputIfFileExists\filehook@InputIfFileExists + \filehook@glet{filehook@InputIfFileExists}{filehook@scrlfile@InputIfFileExists}% + \filehook@glet{filehook@@InputIfFileExists}{filehook@@scrlfile@InputIfFileExists}% + \filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% \PackageWarning{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists.^^J% The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% \else diff --git a/Master/texmf-dist/tex/latex/filehook/filehook.sty b/Master/texmf-dist/tex/latex/filehook/filehook.sty index 5f03b9827e9..d71145b6007 100644 --- a/Master/texmf-dist/tex/latex/filehook/filehook.sty +++ b/Master/texmf-dist/tex/latex/filehook/filehook.sty @@ -1,4 +1,4 @@ -%% Copyright (C) 2011-2019 by Martin Scharrer +%% Copyright (C) 2011-2020 by Martin Scharrer %% ---------------------------------------------------------------------- %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -19,12 +19,45 @@ %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{filehook}[% - 2019/10/03 - v0.6 + 2020/02/03 + v0.7 Hooks for input files] \newif\iffilehook@force \DeclareOption{force}{\filehook@forcetrue} \ProcessOptions\relax +\newif\iffilehook@newfmt +\@ifl@t@r\fmtversion{2019/10/01}{\filehook@newfmttrue}{\filehook@newfmtfalse} +\def\filehook@let#1#2{% + \expandafter\ifx\csname #2\space\endcsname\relax + \expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname + \else + \expandafter\def\csname #1\expandafter\endcsname\expandafter{\expandafter\protect\csname #1\space\endcsname}% + \expandafter\let\csname #1\space\expandafter\endcsname\csname #2\space\endcsname + \fi +} +\def\filehook@glet#1#2{% + \expandafter\ifx\csname #2\space\endcsname\relax + \expandafter\global\expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname + \else + \expandafter\global\expandafter\def\csname #1\expandafter\endcsname\expandafter{\expandafter\protect\csname #1\space\endcsname}% + \expandafter\global\expandafter\let\csname #1\space\expandafter\endcsname\csname #2\space\endcsname + \fi +} +\def\filehook@cmp#1#2{% + \expandafter\ifx\csname #2\space\endcsname\relax + \expandafter\ifx\csname #1\expandafter\endcsname\csname #2\endcsname + \expandafter\expandafter\expandafter\@firstoftwo + \else + \expandafter\expandafter\expandafter\@secondoftwo + \fi + \else + \expandafter\ifx\csname #1\space\expandafter\endcsname\csname #2\space\endcsname + \expandafter\expandafter\expandafter\@firstoftwo + \else + \expandafter\expandafter\expandafter\@secondoftwo + \fi + \fi +} \begingroup \gdef\filehook@csuse#1{\ifcsname #1\endcsname\csname #1\expandafter\endcsname\fi} \expandafter\ifx\csname csuse\endcsname\relax @@ -36,7 +69,7 @@ \fi \endgroup \def\filehook@include@atbegin#1{% - \let\InputIfFileExists\filehook@@InputIfFileExists + \filehook@let{InputIfFileExists}{filehook@@InputIfFileExists}% \filehook@csuse{\filehook@include@atbegin@#1}% \filehook@include@@atbegin } @@ -52,7 +85,7 @@ } \def\filehook@include@@after{} \def\filehook@input@atbegin#1{% - \let\InputIfFileExists\filehook@@InputIfFileExists + \filehook@let{InputIfFileExists}{filehook@@InputIfFileExists}% \filehook@csuse{\filehook@input@atbegin@\filehook@ensureext{#1}}% \filehook@input@@atbegin } @@ -245,10 +278,11 @@ \expandafter\filehook@@ensuretex#1\empty.tex\empty\empty } \def\filehook@@ensuretex#1.tex\empty#2\empty{#1.tex} -\newif\iffilehook@newfmt -\@ifl@t@r\fmtversion{2019/10/01}{\filehook@newfmttrue}{\filehook@newfmtfalse} \iffilehook@newfmt -\DeclareRobustCommand \latex@InputIfFileExists[2]{% +\expandafter\def\expandafter\latex@InputIfFileExists\expandafter{% + \expandafter\protect\csname InputIfFileExists\space\endcsname +} +\expandafter\long\expandafter\def\csname latex@InputIfFileExists\space\endcsname#1#2{% \IfFileExists{#1}% {% \expandafter\@swaptwoargs\expandafter @@ -261,7 +295,7 @@ }% } \fi -\long\gdef\filehook@default@InputIfFileExists#1#2{% +\DeclareRobustCommand\filehook@default@InputIfFileExists[2]{% \IfFileExists{#1}% {\expandafter\filehook@swap \expandafter{\@filef@und}% @@ -273,8 +307,9 @@ \filehook@every@atend{#1}% }% } -\long\gdef\filehook@@default@InputIfFileExists#1#2{% - \let\InputIfFileExists\filehook@InputIfFileExists +\filehook@glet{filehook@default@InputIfFileExists}{filehook@default@InputIfFileExists}% +\DeclareRobustCommand\filehook@@default@InputIfFileExists[2]{% + \filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% \IfFileExists{#1}% {\expandafter\filehook@swap \expandafter{\@filef@und}% @@ -284,76 +319,9 @@ \filehook@atend{#1}% }% } -\long\def\scrlfile@InputIfFileExists#1#2{% - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname #1-@alias\endcsname\relax - \expandafter\@secondoftwo - \else - \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}% - \expandafter\@firstoftwo - \fi - {% - \expandafter\InputIfFileExists\expandafter{\csname - #1-@alias\endcsname}{#2}% - }% - {\IfFileExists{#1}{% - \scr@load@hook{before}{#1}% - #2\@addtofilelist{#1}% - \@@input \@filef@und - \scr@load@hook{after}{#1}% - }}% -} -\long\def\filehook@scrlfile@InputIfFileExists#1#2{% - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname #1-@alias\endcsname\relax - \expandafter\@secondoftwo - \else - \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}% - \expandafter\@firstoftwo - \fi - {% - \expandafter\InputIfFileExists\expandafter{\csname - #1-@alias\endcsname}{#2}% - }% - {\IfFileExists{#1}{% - \expandafter\filehook@swap - \expandafter{\@filef@und}% - {\scr@load@hook{before}{#1}% - #2\@addtofilelist{#1}% - \filehook@every@atbegin{#1}% - \filehook@atbegin{#1}% - \@@input}% - \filehook@atend{#1}% - \filehook@every@atend{#1}% - \scr@load@hook{after}{#1}% - }}% -} -\long\def\filehook@@scrlfile@InputIfFileExists#1#2{% - \let\InputIfFileExists\filehook@InputIfFileExists - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname #1-@alias\endcsname\relax - \expandafter\@secondoftwo - \else - \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}% - \expandafter\@firstoftwo - \fi - {% - \expandafter\InputIfFileExists\expandafter{\csname - #1-@alias\endcsname}{#2}% - }% - {\IfFileExists{#1}{% - \expandafter\filehook@swap - \expandafter{\@filef@und}% - {\scr@load@hook{before}{#1}% - #2\@addtofilelist{#1}% - \filehook@atbegin{#1}% - \@@input}% - \filehook@atend{#1}% - \scr@load@hook{after}{#1}% - }}% -} -\AtBeginOfPackageFile*{scrlfile}{% - \let\InputIfFileExists\latex@InputIfFileExists +\filehook@glet{filehook@@default@InputIfFileExists}{filehook@@default@InputIfFileExists}% +\AtBeginOfPackageFile{scrlfile}{% + \filehook@glet{InputIfFileExists}{latex@InputIfFileExists}% }% \AtEndOfPackageFile*{scrlfile}{% \RequirePackage{filehook-scrlfile}% @@ -361,67 +329,50 @@ \AtBeginOfPackageFile*{fink}{% \RequirePackage{kvoptions}% \begingroup - \let\InputIfFileExists\latex@InputIfFileExists + \filehook@let{InputIfFileExists}{latex@InputIfFileExists}% }% \AtEndOfPackageFile*{fink}{% \edef\@tempa{\noexpand\PassOptionsToPackage{mainext=\fnk@mainext,maindir=\fnk@maindir}{currfile}}% \expandafter\endgroup\@tempa \RequirePackage{filehook-fink}% }% -\AtBeginOfClassFile*{memoir}{% - \let\filehook@@InputIfFileExists\latex@InputIfFileExists - \let\InputIfFileExists\latex@InputIfFileExists +\AtBeginOfClassFile{memoir}{% + \filehook@let{InputIfFileExists}{latex@InputIfFileExists}% \let\@iinput\filehook@orig@@iinput }% \AtEndOfClassFile*{memoir}{% \let\@iinput\filehook@@iinput \RequirePackage{filehook-memoir}% }% -\def\@tempa{9}% -\ifx\InputIfFileExists\filehook@InputIfFileExists - \def\@tempa{0}% -\else - \iffilehook@force - \def\@tempa{1}% - \else - \iffilehook@newfmt - % check if both the robust \InputIfFileExist and its internal macro match the default LaTeX definition - \edef\@tempb{\noexpand\protect\expandafter\noexpand\csname InputIfFileExists\space\endcsname}% - \ifx\InputIfFileExists\@tempb - \expandafter\ifx\csname InputIfFileExists\space\expandafter\endcsname\csname latex@InputIfFileExists\space\endcsname - \def\@tempa{1}% - \fi - \fi - \else\ifx\InputIfFileExists\latex@InputIfFileExists - \def\@tempa{1}% - \fi\fi - \fi -\fi -\ifcase\@tempa -\relax% 0 -\or% 1 - \let\filehook@InputIfFileExists\filehook@default@InputIfFileExists - \let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists - \iffilehook@newfmt - \expandafter\let\csname InputIfFileExists\space\endcsname\filehook@InputIfFileExists - \else - \let\InputIfFileExists\filehook@InputIfFileExists - \fi - \iffilehook@force - \PackageWarning{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J% - The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% - \fi -\else - \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J% - Use the 'force' option of 'filehook' to overwrite it.}{}% -\fi +\filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}% + {}% already set up + {% + \filehook@cmp{InputIfFileExists}{latex@InputIfFileExists}% + {% + \filehook@let{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% + \filehook@let{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% + \filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% + }% + {% + \iffilehook@force + \filehook@let{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% + \filehook@let{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% + \filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% + \PackageWarning{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J% + The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% + \else + \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J% + Use the 'force' option of 'filehook' to overwrite it.}{}% + \fi + }% + }% \AtBeginDocument{% % Check if definition got changed again. For the new LaTeX format we check again \InputIfFileExists, % for the old format to \InputIfFileExists directly. - \expandafter\ifx\csname InputIfFileExists\iffilehook@newfmt\space\fi\endcsname\filehook@InputIfFileExists\else + \filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}{}{% \PackageWarning{filehook}{Macro \string\InputIfFileExists\space got redefined after 'filehook' was loaded.^^J% - Certain file hooks might now be dysfunctional!} - \fi + Certain file hooks might now be dysfunctional!}% + }% } \endinput %% -- cgit v1.2.3