From 34897eebd22c3de968b64f09bb4a371d96cb0b89 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 3 Feb 2020 03:02:01 +0000 Subject: CTAN sync 202002030302 --- macros/latex/base/ltclass.dtx | 176 +++++++++++++++++++++++++++--------------- 1 file changed, 114 insertions(+), 62 deletions(-) (limited to 'macros/latex/base/ltclass.dtx') diff --git a/macros/latex/base/ltclass.dtx b/macros/latex/base/ltclass.dtx index 83aacf8ddb..9e7668e88e 100644 --- a/macros/latex/base/ltclass.dtx +++ b/macros/latex/base/ltclass.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 1993-2019 +% Copyright (C) 1993-2020 % The LaTeX3 Project and any individual authors listed elsewhere % in this file. % @@ -33,7 +33,7 @@ %<*driver> % \fi \ProvidesFile{ltclass.dtx} - [2019/10/07 v1.3c LaTeX Kernel (Class & Package Interface)] + [2020/01/28 v1.3h LaTeX Kernel (Class & Package Interface)] % \iffalse \documentclass{ltxdoc} \GetFileInfo{ltclass.dtx} @@ -156,7 +156,7 @@ % some comments about how it was produced. % % The environment can also be called with an optional argument which is -% used to alter some of its behavior: option \texttt{force} or +% used to alter some of its behavior: option \texttt{force} or % \texttt{overwrite} will allow for overwriting existing files, % option \texttt{nosearch} will only check the current directory % when looking if the file exists. This can be useful if you want to @@ -172,10 +172,10 @@ % A possible use case for using it inside the document body is if you % want to reuse some text several times in the document you could then % write it and later use \cs{input} to retrieve it where needed. -% +% % % The begin and end tags should each be on a -% line by itself. +% line by itself. % % \subsection{Option processing} % @@ -362,7 +362,7 @@ % % |\DeclareOption*{\PassOptionsToPackage{\CurrentOption}|^^A % |{|\meta{pkg-name}|}|\\ -% Handle the the current option by passing it on to the package +% Handle the current option by passing it on to the package % \meta{pkg-name}, which will presumably be loaded via % |\RequirePackage| later in the file. This is useful for building % `extension' packages, that perhaps handle a couple of new options, @@ -671,7 +671,7 @@ %\EndIncludeInRelease %<*2ekernel> % \end{macrocode} -% +% % \begin{macrocode} \@onlypreamble\@ifl@t@r % \end{macrocode} @@ -791,19 +791,69 @@ \@ifnextchar[\@pr@videpackage{\@pr@videpackage[]}}%] \@onlypreamble\ProvidesPackage % \end{macrocode} +% \end{macro} +% % +% +% \begin{macro}{\@pr@videpackage} +% This is the helper command for \cs{ProvidesPackage}. It tries to +% be cautious when handling the identification string in case it +% contains UTF-8 characters. +% \changes{v1.3e}{2019/11/29}{Protect package info text (gh/52)} % \begin{macrocode} +% +%<*2ekernel|latexrelease> +%\IncludeInRelease{2020/02/02}% +% {\@pr@videpackage}{Protection for package info}% \def\@pr@videpackage[#1]{% - \expandafter\xdef\csname ver@\@currname.\@currext\endcsname{#1}% + \expandafter\protected@xdef % <-- protected... + \csname ver@\@currname.\@currext\endcsname{#1}% \ifx\@currext\@clsextension \typeout{Document Class: \@gtempa\space#1}% \else - \wlog{Package: \@gtempa\space#1}% + \protected@wlog{Package: \@gtempa\space#1}% <--- protected \fi} -\@onlypreamble\@pr@videpackage % \end{macrocode} % \end{macro} % +% +% +% \begin{macro}{\protected@wlog} +% This is like plain \TeX's \cs{wlog} but gracefully handles +% protected commands. +% \begin{macrocode} +\long\def\protected@wlog#1{\begingroup + \set@display@protect + \immediate \write \m@ne {#1}\endgroup } +% \end{macrocode} +% \end{macro} +% +% +% \begin{macrocode} +% +%\EndIncludeInRelease +%\IncludeInRelease{0000/00/00}% +% {\@pr@videpackage}{Protection for package info}% +% +%\def\@pr@videpackage[#1]{% +% \expandafter\xdef\csname ver@\@currname.\@currext\endcsname{#1}% +% \ifx\@currext\@clsextension +% \typeout{Document Class: \@gtempa\space#1}% +% \else +% \wlog{Package: \@gtempa\space#1}% +% \fi} +%\let\protected@wlog\@undefined +% +%\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} +% +% \begin{macrocode} +\@onlypreamble\@pr@videpackage +% \end{macrocode} +% +% +% % \begin{macro}{\ProvidesClass} % Like |\ProvidesPackage|, but for classes. % \begin{macrocode} @@ -925,7 +975,7 @@ % \end{macro} % % \begin{macro}{\default@ds} -% The default default option code. +% The default option code. % Set by |\@onefilewithoptions| to either |\OptionNotUsed| for % classes, or |\@unknownoptionerror| for packages. This may be reset % in either case with |\DeclareOption*|. @@ -1356,8 +1406,8 @@ % \begin{macrocode} \def\reserved@b##1,{% % \end{macrocode} -% If |#1| is |\@nnil| we have reached the end of the list -% (older version used |\@nil| here but |\@nil| is undefined so |\ifx| +% If |#1| is |\@nnil| we have reached the end of the list +% (older version used |\@nil| here but |\@nil| is undefined so |\ifx| % equal to all undefined commands) % \begin{macrocode} \ifx\@nnil##1\relax\else @@ -1429,12 +1479,13 @@ % {Made the initial version [] not [\cs{@unknownversion}]} % \changes{v0.2m}{1993/12/07} % {Reset \cs{CurrentOption}} +% \changes{v1.3d}{2019/10/18}{Initialize \cs{...-h@@k} only when loading +% the package or class (gh/198)} % \begin{macrocode} \def\@onefilewithoptions#1[#2][#3]#4{% \@pushfilename \xdef\@currname{#1}% \global\let\@currext#4% - \expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty \let\CurrentOption\@empty \@reset@ptions \makeatletter @@ -1470,6 +1521,11 @@ % \begin{macrocode} \global\expandafter \let\csname ver@\@currname.\@currext\endcsname\@empty +% \end{macrocode} +% We initialize \cs{...-h@@k} here and only if we load the file so that it +% remains undefined otherwise. +% \begin{macrocode} + \expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty \InputIfFileExists {\@currname.\@currext}% {}% @@ -1725,14 +1781,13 @@ % filecontents environment file name} % \changes{v1.3b}{2019/08/27}{Make various commands robust} % \changes{v1.3c}{2019/09/11}{Support optional argument for filecontents} +% \changes{v1.3f}{2020/01/05}{Support more write streams in LuaTeX gh/238} % % %<*2ekernel|latexrelease> %\IncludeInRelease{2019/10/01}% % {\filec@ntents}{Spaces in file names + optional arg}% % - - % \end{macrocode} % We use |@tempswa| to mean no preamble writing and reuse |@filesw| % to indicate no overwriting: @@ -1747,13 +1802,16 @@ % To handle the optional argument we execute for each option the % command \cs{filec@ntents@OPTION} if it exist or complain about % unknown option. +% \changes{v1.3h}{2020/01/28}{Allow spaces in option string and display +% only unknown options not the whole option list (gh/256)} % \begin{macrocode} \def\filec@ntents@opt[#1]{% - \@for\@tempa:=#1\do{% - \ifcsname filec@ntents@\@tempa\endcsname - \csname filec@ntents@\@tempa\endcsname + \edef\@fortmp{\zap@space#1 \@empty}% + \@for\@reserveda:=\@fortmp\do{% + \ifcsname filec@ntents@\@reserveda\endcsname + \csname filec@ntents@\@reserveda\endcsname \else - \@latex@error{Unknown filecontents option #1}% + \@latex@error{Unknown filecontents option \@reserveda}% {Valid options are force (or overwrite), nosearch, noheader}% \fi}% \filec@ntents @@ -1782,7 +1840,7 @@ \let\filec@ntents@checkdir\@empty \def\filec@ntents@where{exists on the system} % \end{macrocode} -% +% % \begin{macrocode} \begingroup% \@tempcnta=1 @@ -1801,6 +1859,11 @@ \gdef\filec@ntents#1{% \set@curr@file{\filec@ntents@checkdir#1}% \edef\q@curr@file{\expandafter\quote@name\expandafter{\@curr@file}}% +% \end{macrocode} +% +% Lua\TeX\ has more writes (and 18 is safe here). +% \begin{macrocode} + \chardef\reserved@c\ifx\directlua\@undefined 15 \else 127 \fi% \openin\@inputcheck\q@curr@file \space % \ifeof\@inputcheck% \@latex@warning@no@line% @@ -1810,8 +1873,7 @@ % \changes{v1.0y}{1997/10/10} % {\cs{reserved@c} not \cs{verbatim@out} to save a csname} % \begin{macrocode} - \chardef\reserved@c15 % - \ch@ck7\reserved@c\write% + \ch@ck7\reserved@c\write\relax% \immediate\openout\reserved@c\q@curr@file\relax% \else% % \end{macrocode} @@ -1831,7 +1893,7 @@ % by mistake overwriting the input file (\cs{jobname}). Of course, % this only works for input files ending in \texttt{.tex}. If a % different extension is used there is no way to see that we are -% overwriting outselves! +% overwriting ourselves! % \begin{macrocode} \edef\reserved@a{#1}% \edef\reserved@a{\detokenize\expandafter{\reserved@a}}% @@ -1847,13 +1909,13 @@ % \end{macrocode} % We allocate a write channel but we open it only if it is % (hopefully) safe. If not opened that means we are going to write -% on the terminal. +% on the terminal. +% \changes{v1.3g}{2020/01/27}{Fix typo in error message} % \begin{macrocode} - \chardef\reserved@c15 % - \ch@ck7\reserved@c\write% + \ch@ck7\reserved@c\write\relax% \if@filesw% % Foul ... trying to overwrite \jobname! \@latex@error{Trying to overwrite `\jobname.tex'}{You can't % - write to the file you a reading from!\MessageBreak% + write to the file you are reading from!\MessageBreak% Data is written to screen instead.}% \else% \@latex@warning@no@line% @@ -1863,7 +1925,7 @@ \fi% \fi% % \end{macrocode} -% Closing the \cs{@inputcheck} is done here ot avoid having to do +% Closing the \cs{@inputcheck} is done here to avoid having to do % this in each branch. % \begin{macrocode} \closein\@inputcheck% @@ -2087,7 +2149,7 @@ % \section{Package/class rollback mechanism} % % -% +% % \begin{macrocode} % %<*2ekernel|latexreleasefirst> @@ -2111,7 +2173,7 @@ % \begin{macro}{\requestedLaTeXdate} % The macro (!) |\requestedLaTeXdate| holds the globally requested % rollback date (via \texttt{latexrelease}) or zero if no such -% request was made. +% request was made. % \begin{macrocode} \def\requestedLaTeXdate{0} % \end{macrocode} @@ -2153,7 +2215,7 @@ % \end{macro} % \end{macro} % \end{macro} - +% % \begin{macro}{\pkgcls@candidate} % \begin{macro}{\pkgcls@releasedate} % When looping through the |\DeclareRelease| declarations we @@ -2186,7 +2248,7 @@ \ifx\load@onefilewithoptions\@undefined \let\load@onefilewithoptions\@onefilewithoptions % \end{macrocode} -% +% % \begin{macrocode} \def\@onefilewithoptions#1[#2][#3]#4{% % \end{macrocode} @@ -2237,7 +2299,7 @@ % \end{macrocode} % \end{macro} % \end{macro} -% +% % % \begin{macro}{\pkgcls@parse@date@arg} % The |\pkgcls@parse@date@arg| command parses the second optional @@ -2271,8 +2333,8 @@ % So in summary we have: % \begin{flushleft} % \hspace*{-1in}\begin{tabular}{ccccc@{}} -% Input & & \cs{pkgcls@targetdate} -% & \cs{pkgcls@targetlabel} +% Input & & \cs{pkgcls@targetdate} +% & \cs{pkgcls@targetlabel} % & \cs{pkgcls@mindate}\\[3pt] % \meta{empty} & $\to$ & \meta{global-rollbackdate-as-number} % & \meta{empty} & \meta{empty} @@ -2283,7 +2345,7 @@ % \texttt{=}\meta{date} & $\to$ & \meta{date-as-number} % & \meta{empty} & \meta{empty} % \\ -% \texttt{=}\meta{version}& $\to$ & \texttt{1} +% \texttt{=}\meta{version}& $\to$ & \texttt{1} % & \meta{version} & \meta{empty} % \\ % \meta{other} & $\to$ & \meta{global-rollbackdate-as-number} @@ -2293,7 +2355,7 @@ % \end{flushleft} % where \meta{global-rollbackdate-as-number} is a date request given % via \texttt{latexrelease} or if there wasn't one \texttt{0}. -% +% % \begin{macrocode} \def\pkgcls@parse@date@arg #1{% % \end{macrocode} @@ -2315,7 +2377,7 @@ \fi } % \end{macrocode} -% The actual parsing work then happens in |\pkgcls@parse@date@arg@|: +% The actual parsing work then happens in |\pkgcls@parse@date@arg@|: % \begin{macrocode} \def\pkgcls@parse@date@arg@#1=#2\@nil{% % \end{macrocode} @@ -2353,7 +2415,7 @@ \else % \end{macrocode} % If |#1| was not empty then there wasn't a \texttt{=} character in -% first position so we we are dealing either with a ``minimum +% first position so we are dealing either with a ``minimum % date'' or with some incorrect data. We assume the former and make % the following assignments (the first one finishing the assignment % of |\pkgcls@targetdate|): @@ -2371,9 +2433,9 @@ % \begin{macrocode} \ifnum \pkgcls@targetdate > \z@ \ifnum \@parse@version0#1//00\@nil > \pkgcls@targetdate - \@latex@warning@no@line{Suspicious rollback/min-date date given\MessageBreak + \@latex@warning@no@line{Suspicious rollback/min-date date given\MessageBreak A minimal date of #1 has been specified for - \@cls@pkg\MessageBreak '\pkgcls@name'.\MessageBreak + \@cls@pkg\MessageBreak '\pkgcls@name'.\MessageBreak But this is in conflict with a rollback request to \requestedpatchdate} \fi @@ -2381,17 +2443,14 @@ \fi } % \end{macrocode} -% Strip off te trailing \texttt{=} and assign the version name to +% Strip off the trailing \texttt{=} and assign the version name to % |\pkgcls@targetlabel|. % \begin{macrocode} \def\pkgcls@parse@date@arg@version#1={% \def\pkgcls@targetlabel{#1}} % \end{macrocode} % \end{macro} - - - - +% % \begin{macro}{\DeclareRelease} % First argument is the ``name'' of the release and it can be left empty % if one doesn't like to give a name to the release. @@ -2476,7 +2535,7 @@ \pkgcls@debug{New candidate: #3}% % \fi - \else + \else % \end{macrocode} % If we end up in this branch we have a named version request. So % we check if |\pkgcls@targetlabel| matches the current name and if @@ -2497,10 +2556,7 @@ } % \end{macrocode} % \end{macro} - - - - +% % \begin{macro}{\pkgcls@use@this@release} % If a certain release has been selected (stored in the external % file given in \verb=#1=) we need to input it and afterwards stop @@ -2535,8 +2591,7 @@ } % \end{macrocode} % \end{macro} - - +% % \begin{macro}{\pkgcls@show@selection} % This command records what selection was made. As that is needed % in two places (and it is rather lengthly) it was placed in a @@ -2556,7 +2611,7 @@ date \ifnum\requestedLaTeXdate=\pkgcls@targetdate \requestedpatchdate - \else + \else \expandafter\@gobble\pkgcls@arg \fi.\MessageBreak % \end{macrocode} @@ -2566,7 +2621,7 @@ % \begin{macrocode} Best approximation is \else - version '\pkgcls@targetlabel'.\MessageBreak + version '\pkgcls@targetlabel'.\MessageBreak This corresponds to \fi \ifx\@nil#2\@nil @@ -2578,19 +2633,18 @@ } % \end{macrocode} % \end{macro} - - +% % \begin{macro}{\pkgcls@rollbackdate@error} % This is called if the requested rollback date is earlier than the % earliest known release of a package or class. % % A similar error is given if global rollback date and min-date on % a specific package conflict with each other, but that case is -% happens only once so it is is inlined. +% happens only once so it is inlined. % \begin{macrocode} \def\pkgcls@rollbackdate@error#1{% \@latex@error{Suspicious rollback date given}% - {The \@cls@pkg\space'\@currname' claims that it + {The \@cls@pkg\space'\@currname' claims that it came into existence on #1 which\MessageBreak is after your requested rollback date --- so something is wrong here.\MessageBreak @@ -2635,7 +2689,6 @@ % |\DeclareCurrentRelease| but no declared older releases (so % basically the use of the declaration is a bit dubious). % \begin{macrocode} - \ifx\pkgcls@candidate\@empty \pkgcls@rollbackdate@error{#2}% \else @@ -2669,7 +2722,6 @@ % \end{macro} % % - % \begin{macro}{\IfTargetDateBefore} % This enables a simple form of conditional code inside a class or % package file. If there is a date request and the request date is -- cgit v1.2.3