From ec37366cecf0d00520cd925a8c9db8519edc27ed Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Thu, 31 Dec 2020 21:53:19 +0000
Subject: latex (31dec20)

git-svn-id: svn://tug.org/texlive/trunk@57276 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/latex/base/ltexpl.dtx | 123 ++++++++++++++++++++-----
 1 file changed, 102 insertions(+), 21 deletions(-)

(limited to 'Master/texmf-dist/source/latex/base/ltexpl.dtx')

diff --git a/Master/texmf-dist/source/latex/base/ltexpl.dtx b/Master/texmf-dist/source/latex/base/ltexpl.dtx
index 4100da79c28..7f9019ede31 100644
--- a/Master/texmf-dist/source/latex/base/ltexpl.dtx
+++ b/Master/texmf-dist/source/latex/base/ltexpl.dtx
@@ -33,7 +33,7 @@
 %<*driver>
 % \fi
 \ProvidesFile{ltexpl.dtx}
-             [2020/09/06 v1.2f LaTeX Kernel (expl3-dependent code)]
+             [2020/12/18 v1.2h LaTeX Kernel (expl3-dependent code)]
 % \iffalse
 \documentclass{ltxdoc}
 \GetFileInfo{ltexpl.dtx}
@@ -72,16 +72,45 @@
 %         {Define a local version of some \LaTeXe{} basic macros to support
 %          package loading}
 %
+% \begin{macro}{\@kernel@after@enddocument,
+%                \@kernel@after@enddocument@afterlastpage}
+%   These two kernel hooks are used by the shipout code.  They are
+%   defined earlier here because the \pkg{lthooks} code adds material
+%   to them.
+% \changes{v1.2h}{2020/12/18}
+%         {Define kernel \cs{enddocument} hooks early}
+%    \begin{macrocode}
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease>  {kernel@enddocument hooks}{Define kernel enddocument Hooks}%
+\let\@kernel@after@enddocument\@empty
+\let\@kernel@after@enddocument@afterlastpage\@empty
+%<latexrelease>\EndIncludeInRelease
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease>  {kernel@enddocument hooks}{Define kernel enddocument Hooks}%
+%<latexrelease>\let\@kernel@after@enddocument\@undefined
+%<latexrelease>\let\@kernel@after@enddocument@afterlastpage\@undefined
+%<latexrelease>\EndIncludeInRelease
+%</2ekernel|latexrelease>
+%    \end{macrocode}
+% \end{macro}
+%
 % First define some blank commands, so that in case something goes wrong while
 % loading \textsf{expl3}, we won't get strange \texttt{Undefined control
 % sequence} errors.
 %    \begin{macrocode}
-%<*2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease>            {\@expl@sys@load@backend@@}{Roll forward support}%
 \def\@expl@sys@load@backend@@{}
 \def\@expl@push@filename@@{}
 \def\@expl@push@filename@aux@@{}
 \def\@expl@pop@filename@@{}
-%</2ekernel>
+%<latexrelease>\EndIncludeInRelease
+%</2ekernel|latexrelease>
 %    \end{macrocode}
 %
 % \changes{v1.2d}{2020/07/08}
@@ -183,9 +212,20 @@
         \errmessage{LaTeX requires expl3}%
         \batchmode \read -1 to \reserved@a
 %</2ekernel>
+%    \end{macrocode}
+%    We do not support a roll forward across 2019. You need to start
+%    with 2019 if you want to get to 2020 or beyond. 
+% \changes{v1.2g}{2020/11/24}{Support for roll forward (gh/434)}
+%    \begin{macrocode}
 %<*latexrelease>
-        \@latex@error{LaTeX requires expl3}\@ehd
-        \@gobble
+        \@latex@warning@no@line
+          {You need a format that already contains a recent\MessageBreak
+           expl3 as part of the kernel, e.g. at least a kernel\MessageBreak
+           from 2019 to roll forward to that date!\MessageBreak
+           --- I'm giving up!\MessageBreak\MessageBreak
+           Note that manually loading the expl3 package\MessageBreak
+           from your distribution is not enough}%
+        \@@end  % die
 %</latexrelease>
       }%
       {%
@@ -222,6 +262,36 @@
 %<latexrelease>\EndIncludeInRelease
 %    \end{macrocode}
 %
+%
+%    Starting with 2020-10 the kernel contains most of the
+%    \texttt{xparse} interfaces loaded above. These interfaces are
+%    later used to define various user command. However, if somebody
+%    with an earlier installation tries to roll forward (using a
+%    \texttt{latexrelease} package from a newer release) this will not
+%    work as the earlier kernel doesn't contain commands such as
+%    \cs{NewDocumentCommand}.
+%
+%    We therefore add code into \texttt{latexrelease.sty} to load the
+%    \texttt{xparse} package of the current installation instead. this
+%    may not work if the installation is really old, but roll forward
+%    can't do miracles.
+%
+%    If the kernel is 2020-10 or later \cs{NewDocumentCommand} is
+%    already known (whether or not you roll forward or back) so
+%    nothing happens, but if you start from am earlier kernel the
+%    \texttt{xparse} package gets loaded by \texttt{latexrelease}.
+% \changes{v1.2g}{2020/11/24}{Load xparse in latexrelease if needed (gh/434)}
+%    \begin{macrocode}
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease>                 {\NewDocumentCommand}{Emergency loading xparse}%
+%<latexrelease>
+%<latexrelease>\ifdefined\NewDocumentCommand \else
+%<latexrelease>  \RequirePackage{xparse}
+%<latexrelease>\fi
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%    \end{macrocode}
+%
 %    \subsection{Using expl3 code}
 %
 %    In order to ease the implemantation of some new features in
@@ -242,9 +312,6 @@
 %    if that \pkg{expl3} command is needed in places that are others
 %    coded in \LaTeXe{} conventions.
 %
-%    \begin{macrocode}
-\ExplSyntaxOn
-%    \end{macrocode}
 %
 %    In this file, each release of LaTeX adds an \cs{IncludeInRelease}
 %    block, in which the macros copied for that release were defined.
@@ -259,8 +326,16 @@
 %    redefinitions.
 %
 %    \begin{macrocode}
-%<latexrelease>\IncludeInRelease{2020/10/01}{expl3~2020-10-01}%
-%<latexrelease>        {expl3~macros~added~for~the~2020-10-01~release}%
+%<latexrelease>\IncludeInRelease{2020/10/01}{\@expl@cs@to@str@@N}%
+%<latexrelease>        {expl3 macros added for the 2020-10-01 release}%
+%    \end{macrocode}
+%
+%    The expl3 activation needs to be inside the release guards as
+%    otherwise rolling forward is broken in old kernels that do not
+%    have expl3 loaded.
+% \changes{v1.2g}{2020/11/24}{Support for roll forward (gh/434)}
+%    \begin{macrocode}
+\ExplSyntaxOn
 %    \end{macrocode}
 %
 % \changes{v1.2e}{2020/08/19}
@@ -290,21 +365,27 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
+\ExplSyntaxOff
+%    \end{macrocode}
+%
+%
+%    Here we can't assume that expl3 is available. It will be if we
+%    roll back but if this code is executed rolling forward it needs
+%    to be pure 2e.
+% \changes{v1.2g}{2020/11/24}{Support for roll forward (gh/434)}
+%    \begin{macrocode}
 %<latexrelease>\EndIncludeInRelease
-%<latexrelease>\IncludeInRelease{0000/00/00}{expl3~2020-10-01}%
-%<latexrelease>        {expl3~macros~added~for~the~2020-10-01~release}%
-%<latexrelease>\cs_undefine:N \@expl@cs@to@str@@N
-%<latexrelease>\cs_undefine:N \@expl@str@if@eq@@nnTF
-%<latexrelease>\cs_undefine:N \@expl@cs@prefix@spec@@N
-%<latexrelease>\cs_undefine:N \@expl@cs@argument@spec@@N
-%<latexrelease>\cs_undefine:N \@expl@cs@replacement@spec@@N
-%<latexrelease>\cs_undefine:N \@expl@str@map@function@@NN
+%<latexrelease>\IncludeInRelease{0000/00/00}{\@expl@cs@to@str@@N}%
+%<latexrelease>        {expl3 macros added for the 2020-10-01 release}%
+%<latexrelease>\let \@expl@cs@to@str@@N \@undefined
+%<latexrelease>\let \@expl@str@if@eq@@nnTF \@undefined
+%<latexrelease>\let \@expl@cs@prefix@spec@@N \@undefined
+%<latexrelease>\let \@expl@cs@argument@spec@@N \@undefined
+%<latexrelease>\let \@expl@cs@replacement@spec@@N \@undefined
+%<latexrelease>\let \@expl@str@map@function@@NN \@undefined
 %<latexrelease>\EndIncludeInRelease
 %</2ekernel|latexrelease>
 %    \end{macrocode}
 %
-%    \begin{macrocode}
-\ExplSyntaxOff
-%    \end{macrocode}
 %
 % \Finale
-- 
cgit v1.2.3

