diff options
author | Karl Berry <karl@freefriends.org> | 2018-08-22 21:30:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-08-22 21:30:14 +0000 |
commit | be3509525c1dff73357ecd5c3037598ebaaa2268 (patch) | |
tree | e156bb2de2f9df8a7a8ce6cdda5868c4053c8140 /Master/texmf-dist/tex/latex/plautopatch | |
parent | d73c922e3d1cc0085aab0488d1b8d2c7ff4f09d9 (diff) |
plautopatch (22aug18)
git-svn-id: svn://tug.org/texlive/trunk@48454 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/plautopatch')
-rw-r--r-- | Master/texmf-dist/tex/latex/plautopatch/plautopatch.sty | 84 |
1 files changed, 57 insertions, 27 deletions
diff --git a/Master/texmf-dist/tex/latex/plautopatch/plautopatch.sty b/Master/texmf-dist/tex/latex/plautopatch/plautopatch.sty index dbc40429c32..483b77f67c8 100644 --- a/Master/texmf-dist/tex/latex/plautopatch/plautopatch.sty +++ b/Master/texmf-dist/tex/latex/plautopatch/plautopatch.sty @@ -8,8 +8,9 @@ \NeedsTeXFormat{pLaTeX2e} \ProvidesPackage{plautopatch} - [2018/08/21 v0.2 Automated patches for pLaTeX/upLaTeX] + [2018/08/22 v0.3 Automated patches for pLaTeX/upLaTeX] \def\platpc@pkgname{plautopatch} +\def\platpc@err{\PackageError\platpc@pkgname} \def\platpc@warn{\PackageWarningNoLine\platpc@pkgname} \def\platpc@info{\PackageInfo\platpc@pkgname} @@ -17,11 +18,13 @@ % low-level helpers -%% \platpc@req@add{<package>} +%% \platpc@ifreq@add{<package>} % = if not loaded yet, \RequirePackage{<package>} % and add to list. -\def\platpc@req@add#1{% - \@ifpackageloaded{#1}{}{\RequirePackage{#1}\platpc@addtolist{#1}}% +\def\platpc@ifreq@add#1{% + \@ifpackageloaded{#1}{}{% + \RequirePackage{#1}\platpc@addtolist{#1}% + }% } %% \platpc@addtolist{<package>} @@ -29,41 +32,65 @@ \def\platpc@addtolist#1{\xdef\platpc@list{\platpc@list, #1}} \def\platpc@list{}% initialize +%% \platpc@ifnotdisabled{<package>}{<code>} +% = execute <code> if <package> is not disabled. +\def\platpc@ifnotdisabled#1{% + \expandafter\ifx\csname platpc@disable@#1\endcsname\relax + \expandafter\@firstofone + \fi +} + +%% \platpc@ifloadederr{<package>} +% = throw an error if <package> is already loaded. +\def\platpc@ifloadederr#1{% + \@ifpackageloaded{#1}{% + \platpc@err{Package `#1' already loaded!\MessageBreak + Use \string\RequirePackage{\platpc@pkgname} earlier}\@ehc + }% +} + % high-level helpers %% \platpc@patch@after{<orig>}{<patch>} % = Load <patch> after <orig>. \def\platpc@patch@after#1#2{% \expandafter\def\csname platpc@end@#1\endcsname{% - \expandafter\ifx\csname platpc@disable@#1\endcsname\relax - \platpc@req@add{#2}% - \fi + \platpc@ifnotdisabled{#1}{\platpc@ifreq@add{#2}}% + }% + \@ifpackageloaded{#1}{% + \csname platpc@end@#1\endcsname + }{% + \AtEndOfPackageFile{#1}{\csname platpc@end@#1\endcsname}% }% - \AtEndOfPackageFile{#1}{\csname platpc@end@#1\endcsname}% } \@onlypreamble\platpc@patch@after %% \platpc@patch@after@both{<orig 1>}{<orig 2>}{<patch>} % = Load <patch> after both <orig 1> & <orig 2>. \def\platpc@patch@after@both#1#2#3{% - % for order #2 => #1 \expandafter\def\csname platpc@end@#1+#2\endcsname{% - \expandafter\ifx\csname platpc@disable@#1\endcsname\relax - \expandafter\ifx\csname platpc@disable@#2\endcsname\relax - \@ifpackageloaded{#2}{\platpc@req@add{#3}}{}% - \fi - \fi + \platpc@ifnotdisabled{#1}{\platpc@ifnotdisabled{#2}{% + \platpc@ifreq@add{#3}% + }}% }% - \AtEndOfPackageFile{#1}{\csname platpc@end@#1+#2\endcsname}% - % for order #1 => #2 - \expandafter\def\csname platpc@end@#2+#1\endcsname{% - \expandafter\ifx\csname platpc@disable@#2\endcsname\relax - \expandafter\ifx\csname platpc@disable@#1\endcsname\relax - \@ifpackageloaded{#1}{\platpc@req@add{#3}}{}% - \fi - \fi + \@ifpackageloaded{#1}{% + \@ifpackageloaded{#2}{% + \csname platpc@end@#1+#2\endcsname + }{% + \AtEndOfPackageFile{#2}{\csname platpc@end@#1+#2\endcsname}% + }% + }{% + \@ifpackageloaded{#2}{% + \AtEndOfPackageFile{#1}{\csname platpc@end@#1+#2\endcsname}% + }{% + \AtEndOfPackageFile{#1}{% + \@ifpackageloaded{#2}{\csname platpc@end@#1+#2\endcsname}{}% + }% + \AtEndOfPackageFile{#2}{% + \@ifpackageloaded{#1}{\csname platpc@end@#1+#2\endcsname}{}% + }% + }% }% - \AtEndOfPackageFile{#2}{\csname platpc@end@#2+#1\endcsname}% } \@onlypreamble\platpc@patch@after@both @@ -74,9 +101,9 @@ % - <patch> contains \RequirePackage{<orig>} \def\platpc@patch@before#1#2{% \expandafter\def\csname platpc@begin@#1\endcsname{% - % if <patch> is already loaded, nothing to do - \@ifpackageloaded{#2}{}{% else - \expandafter\ifx\csname platpc@disable@#1\endcsname\relax + \platpc@ifnotdisabled{#1}{% + % if <patch> is already loaded, nothing to do + \@ifpackageloaded{#2}{}{% else % the code (*!) should be used only once, % remove it immediately when this macro is executed \expandafter\let\csname platpc@begin@#1\endcsname\relax @@ -93,9 +120,12 @@ \filehook@@atbegin \filehook@atend}% % all done - \fi + }% }% }% + % if <orig> is already loaded at this point, too late! + \platpc@ifloadederr{#1}% + % do it \AtBeginOfPackageFile{#1}{\csname platpc@begin@#1\endcsname}% } \@onlypreamble\platpc@patch@before |