From aab00778035c28a028f94e501e3c13f6b4081f87 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Mon, 30 Dec 2019 22:17:03 +0000
Subject: koma-script (30dec19)

git-svn-id: svn://tug.org/texlive/trunk@53270 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/tex/latex/koma-script/scrlfile.sty  | 203 +++++++++++++--------
 1 file changed, 126 insertions(+), 77 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/koma-script/scrlfile.sty')

diff --git a/Master/texmf-dist/tex/latex/koma-script/scrlfile.sty b/Master/texmf-dist/tex/latex/koma-script/scrlfile.sty
index 8f21ce83202..e6d221f3fcb 100644
--- a/Master/texmf-dist/tex/latex/koma-script/scrlfile.sty
+++ b/Master/texmf-dist/tex/latex/koma-script/scrlfile.sty
@@ -39,28 +39,37 @@
 %% find a complete unmodified copy of LaTeX2e at
 %% <http://mirror.ctan.org/tex-archive/macros/latex/base/>.
 %% 
-%%% From File: $Id: scrlfile.dtx 3243 2019-10-07 13:32:53Z kohm $
+%%% From File: $Id: scrlfile.dtx 3399 2019-11-21 09:01:49Z kohm $
 \ProvidesPackage{scrlfile}[%
-  2019/10/12 v3.27 KOMA-Script
+  2019/12/23 v3.28 KOMA-Script
   package
   (loading files)]
 \ExecuteOptions{}
 \ProcessOptions\relax
-\long\def\reserved@a#1#2{%
-  \IfFileExists{#1}%
-    {#2\@addtofilelist{#1}\@@input \@filef@und}}%
-\ifx\reserved@a\InputIfFileExists\else
-  \expandafter\CheckCommand\expandafter*\expandafter\InputIfFileExists
-  \expandafter{%
-    \expandafter\protect\csname InputIfFileExists \endcsname
+\@ifclassloaded{memoir}{%
+  \PackageInfo{scrlfile}{class `memoir' detected.\MessageBreak
+    Using a compatible redefinition of \string\InputIfFileExists,\MessageBreak
+    but always robust and with the fix of the\MessageBreak
+    argument order bug even for old versions of the\MessageBreak
+    LaTeX kernel%
   }%
-  \expandafter\CheckCommand \csname InputIfFileExists \endcsname[2]{%
-    \IfFileExists {#1}{%
-      \expandafter \@swaptwoargs \expandafter {\@filef@und }%
-      {#2\@addtofilelist {#1}\@@input }%
+}{%
+  \long\def\reserved@a#1#2{%
+    \IfFileExists{#1}%
+      {#2\@addtofilelist{#1}\@@input \@filef@und}}%
+  \ifx\reserved@a\InputIfFileExists\else
+    \expandafter\CheckCommand\expandafter*\expandafter\InputIfFileExists
+    \expandafter{%
+      \expandafter\protect\csname InputIfFileExists \endcsname
     }%
-  }%
-\fi
+    \expandafter\CheckCommand \csname InputIfFileExists \endcsname[2]{%
+      \IfFileExists {#1}{%
+        \expandafter \@swaptwoargs \expandafter {\@filef@und }%
+        {#2\@addtofilelist {#1}\@@input }%
+      }%
+    }%
+  \fi
+}
 \expandafter\renewcommand\expandafter*\expandafter\InputIfFileExists
 \expandafter{\expandafter
   \protect\csname InputIfFileExists \endcsname}%
@@ -80,12 +89,24 @@
       \expandafter\scr@input@withhook\expandafter{\@filef@und}{#1}{#2}%
     }}%
 }
-\newcommand{\scr@input@withhook}[3]{%
-  \scr@load@hook{before}{#2}%
-  #3\@addtofilelist{#2}%
-  \@@input #1%
-  \scr@load@hook{after}{#2}%
-}%
+\@ifclassloaded{memoir}{%
+  \newcommand{\scr@input@withhook}[3]{%
+    \scr@load@hook{before}{#2}%
+    #3\@addtofilelist{#2}%
+    \@ifundefined{m@matbeginf}{}{\m@matbeginf{#2}}%
+    \@@input #1%
+    \@ifundefined{m@matendf}{}{\m@matendf{#2}}%
+    \@ifundefined{killm@matf}{}{\killm@matf{#2}}%
+    \scr@load@hook{after}{#2}%
+  }%
+}{%
+  \newcommand{\scr@input@withhook}[3]{%
+    \scr@load@hook{before}{#2}%
+    #3\@addtofilelist{#2}%
+    \@@input #1%
+    \scr@load@hook{after}{#2}%
+  }%
+}
 \newcommand*{\scr@@loadwithoptions}{}
 \newcommand*{\scr@loadwithoptions}{}
 \let\scr@loadwithoptions\@loadwithoptions
@@ -160,9 +181,24 @@
   \PackageInfo{scrlfile}{inputing `#1' instead of `#2'}%
 }
 \newcommand*{\scr@load@hook}[2]{%
+  \edef\scrlfile@hookname{#1}%
+  \def\scrlfile@cmp@hook{before}%
+  \ifx\scrlfile@hookname\scrlfile@cmp@hook
+    \expandafter\def\csname #2-l@ading\endcsname{#2}%
+  \fi
+  \let\scrlfile@cmp@hook\@undefined
   \@ifundefined{#2-@#1}{}{%
     \@nameuse{#2-@#1}%
-    \expandafter\let\csname #2-@#1\endcsname=\relax}}
+    \expandafter\let\csname #2-@#1\endcsname\relax
+  }%
+  \edef\scrlfile@hookname{#1}%
+  \def\scrlfile@cmp@hook{after}%
+  \ifx\scrlfile@hookname\scrlfile@cmp@hook
+    \expandafter\let\csname #2-l@ading\endcsname\@undefined
+  \fi
+  \let\scrlfile@cmp@hook\@undefined
+  \let\scrlfile@hookname\@undefined
+}
 \newcommand*{\scr@set@load@hook}[2]{%
   \@ifundefined{#2-@#1}{\@namedef{#2-@#1}{}}{}%
   \expandafter\g@addto@macro\csname #2-@#1\endcsname}
@@ -172,84 +208,97 @@
   \scr@set@load@hook{before}{#1.\@clsextension}}
 \newcommand*{\AfterClass}{%
   \kernel@ifstar {\@sAfterClass}{%
-    \kernel@ifnextchar +\@@AfterClass{%
-      \kernel@ifnextchar !\@@@AfterClass\@AfterClass
+    \kernel@ifnextchar +\@pAfterClass{%
+      \kernel@ifnextchar !\@xAfterClass\@AfterClass
     }%
   }%
 }
-\newcommand*{\@@@AfterClass}[2]{%
-  \begingroup
-    \expandafter\ifx\csname #2.\@clsextension-h@@k\endcsname\relax
-      \aftergroup\@sAfterClass
-    \else
-      \aftergroup\AfterAtEndOfClass
-    \fi
-  \endgroup{#2}%
-}
-\newcommand*{\AfterAtEndOfClass}[1]{%
-  \scr@set@load@hook{lateafter}{#1.\@clsextension}}
-\newcommand*{\@@AfterClass}[2]{%
-  \begingroup
-    \expandafter\ifx\csname #2.\@clsextension-h@@k\endcsname\relax
-      \aftergroup\@sAfterClass
-    \else
-      \aftergroup\@AfterClass
-    \fi
-  \endgroup{#2}%
-}
 \newcommand*{\@AfterClass}[1]{%
   \scr@set@load@hook{after}{#1.\@clsextension}}
 \newcommand*{\@sAfterClass}[1]{%
-  \begingroup
-    \@ifclassloaded{#1}{%
-      \aftergroup\@secondoftwo
+  \@ifclassloaded{#1}{%
+    \@secondoftwo
+  }{%
+    \@AfterClass
+  }%
+  {#1}%
+}
+\newcommand*{\@pAfterClass}[2]{%
+  \@ifundefined{#2.\@clsextension-l@ading}{%
+    \@sAfterClass
+  }{%
+    \@AfterClass
+  }%
+  {#2}%
+}
+\newcommand*{\@xAfterClass}[2]{%
+  \@ifundefined{#2.\@clsextension-l@ading}{%
+    \@ifclassloaded{#2}{%
+      \@sAfterClass
     }{%
-      \aftergroup\@AfterClass
+      \AfterAtEndOfClass
     }%
-  \endgroup
-  {#1}%
+  }{%
+    \AfterAtEndOfClass
+  }%
+  {#2}%
 }
+\newcommand*{\AfterAtEndOfClass}[1]{%
+  \scr@set@load@hook{lateafter}{#1.\@clsextension}}
 \newcommand*{\BeforePackage}[1]{%
   \scr@set@load@hook{before}{#1.\@pkgextension}}
 \newcommand*{\AfterPackage}{%
   \kernel@ifstar {\@sAfterPackage}{%
-    \kernel@ifnextchar +\@@AfterPackage{%
-      \kernel@ifnextchar !\@@@AfterPackage\@AfterPackage
+    \kernel@ifnextchar +\@pAfterPackage{%
+      \kernel@ifnextchar !\@xAfterPackage\@AfterPackage
     }%
   }%
 }
-\newcommand*{\@@@AfterPackage}[2]{%
-  \begingroup
-    \expandafter\ifx\csname #2.\@pkgextension-h@@k\endcsname\relax
-      \aftergroup\@sAfterPackage
-    \else
-      \aftergroup\AfterAtEndOfPackage
-    \fi
-  \endgroup{#2}%
-}
-\newcommand*{\AfterAtEndOfPackage}[1]{%
-  \scr@set@load@hook{lateafter}{#1.\@pkgextension}}
-\newcommand*{\@@AfterPackage}[2]{%
-  \begingroup
-    \expandafter\ifx\csname #2.\@pkgextension-h@@k\endcsname\relax
-      \aftergroup\@sAfterPackage
-    \else
-      \aftergroup\@AfterPackage
-    \fi
-  \endgroup{#2}%
-}
 \newcommand*{\@AfterPackage}[1]{%
   \scr@set@load@hook{after}{#1.\@pkgextension}}
 \newcommand*{\@sAfterPackage}[1]{%
-  \begingroup
-    \@ifpackageloaded{#1}{%
-      \aftergroup\@secondoftwo
+  \@ifpackageloaded{#1}{%
+    \@secondoftwo
+  }{%
+    \@AfterPackage
+  }%
+  {#1}%
+}
+\newcommand*{\@pAfterPackage}[2]{%
+  \@ifundefined{#2.\@pkgextension-l@ading}{%
+    \@sAfterPackage
+  }{%
+    \@AfterPackage
+  }%
+  {#2}%
+}
+\newcommand*{\@xAfterPackage}[2]{%
+  \@ifundefined{#2.\@pkgextension-l@ading}{%
+    \@ifpackageloaded{#2}{%
+      \@sAfterPackage
     }{%
-      \aftergroup\@AfterPackage
+      \@AfterAtEndOfPackage
     }%
-  \endgroup
+  }{%
+    \@AfterAtEndOfPackage
+  }%
+  {#2}%
+}
+\newcommand*{\AfterAtEndOfPackage}[1]{%
+  \@ifpackageloaded{#1}{%
+    \@ifundefined{#1.\@pkgextension-l@ading}{%
+      \@gobbletwo
+    }{%
+      \@AfterAtEndOfPackage
+    }%
+  }{%
+    \@AfterAtEndOfPackage
+  }%
   {#1}%
 }
+\newcommand*{\@AfterAtEndOfPackage}[1]{%
+  \scr@set@load@hook{lateafter}{#1.\@pkgextension}%
+}
 \newcommand*{\scrlfile@excludedpackages}{}
 \let\scrlfile@excludedpackages\@empty
 \newcommand*{\scrlfile@saved@RequirePackage}{}
-- 
cgit v1.2.3

