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 --- .../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 ++++++++------------- 5 files changed, 141 insertions(+), 167 deletions(-) (limited to 'Master/texmf-dist/tex/latex/filehook') 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