diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/base/ltfiles.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/base/ltfiles.dtx | 224 |
1 files changed, 210 insertions, 14 deletions
diff --git a/Master/texmf-dist/source/latex/base/ltfiles.dtx b/Master/texmf-dist/source/latex/base/ltfiles.dtx index 6960fd44a3f..afb085a4174 100644 --- a/Master/texmf-dist/source/latex/base/ltfiles.dtx +++ b/Master/texmf-dist/source/latex/base/ltfiles.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright 1993-2017 +% Copyright (C) 1993-2019 % The LaTeX3 Project and any individual authors listed elsewhere % in this file. % @@ -13,7 +13,7 @@ % The latest version of this license is in % https://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX -% version 2005/12/01 or later. +% version 2008 or later. % % This file has the LPPL maintenance status "maintained". % @@ -32,7 +32,7 @@ %<*driver> % \fi \ProvidesFile{ltfiles.dtx} - [2018/01/08 v1.1m LaTeX Kernel (File Handling)] + [2019/08/27 v1.2b LaTeX Kernel (File Handling)] % \iffalse \documentclass{ltxdoc} \GetFileInfo{ltfiles.dtx} @@ -280,7 +280,7 @@ % the math fonts. % \begin{macrocode} \process@table - \let\glb@currsize\@empty %% Force math initialization. + \let\glb@currsize\@empty % Force math initialization. % \end{macrocode} % \changes{v0.9t}{1994/01/31} % {set \cs{@normalsize} or \cs{normalsize} if necessary} @@ -541,10 +541,17 @@ % % \begin{macro}{\includeonly} % \changes{v1.0p}{1995/04/22}{Allow blanks in argument} +% \changes{v1.2a}{2019/07/01}{Support UTF-8} % \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2019/10/01}% +%<latexrelease> {\includeonly}{Spaces in file names}% \def\includeonly#1{% \@partswtrue - \edef\@partlist{\zap@space#1 \@empty}} + \set@curr@file{\zap@space#1 \@empty}% + \let\@partlist\@curr@file + } \@onlypreamble\includeonly % \end{macrocode} % \end{macro} @@ -569,10 +576,33 @@ \def\include#1{\relax \ifnum\@auxout=\@partaux \@latex@error{\string\include\space cannot be nested}\@eha - \else \@include#1 \fi} + \else + \set@curr@file{#1 }% + \expandafter\@include\@curr@file + \fi} % \end{macrocode} % \end{macro} % +% +% \begin{macrocode} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\includeonly}{Spaces in file names}% +%<latexrelease>\def\includeonly#1{% +%<latexrelease> \@partswtrue +%<latexrelease> \edef\@partlist{\zap@space#1 \@empty}} +%<latexrelease> +%<latexrelease>\def\include#1{\relax +%<latexrelease> \ifnum\@auxout=\@partaux +%<latexrelease> \@latex@error{\string\include\space cannot be nested}\@eha +%<latexrelease> \else \@include#1 \fi} +%<latexrelease> +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} + +% % \begin{macro}{\@include} % \begin{macrocode} \def\@include#1 {% @@ -656,14 +686,86 @@ % % \subsection{Safe Input Macros} % -% \begin{macro}{\IfFileExists} +% +% + +% \begin{macro}{\@curr@file} +% \begin{macro}{\set@curr@file} +% +% File name handling is done by generating a csname from the +% provided file name (which means that UTF-8 octets gets turned into +% strings as this is what happens if they appear in a csname due to +% the code in \texttt{utf8.def}). By setting \cs{escapchar} to +% \texttt{-1} we ensure that we don't get a backslash in front. As a +% result we end up with all characters as catcode 12 (plus +% spaces). We then sometimes add quotes around the contruct +% (removing any existing inner quotes. Somes we only remove the +% quotes if they have been supplied by the user. There is clearly +% some room for improvement. +% +% A side effect of the new code is that we will see quotes around +% file name displays where there haven't been any before. +% +% \changes{v1.2a}{2019/07/01}{Support UTF-8} +% \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2019/10/01}% +%<latexrelease> {\set@curr@file}{Quote file names}% +\def\set@curr@file#1{% + \begingroup + \escapechar\m@ne + \xdef\@curr@file{\expandafter\string\csname #1\endcsname}% + \endgroup +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\quote@name} +% \begin{macro}{\quote@@name} +% \begin{macro}{\unquote@name} +% Quoting spaces +%\begin{verbatim} +% a b c -> "a b c" +% "a b c" -> "a b c" +% a" "b" "c -> "a b c" +% -> "" +%\end{verbatim} +% \begin{macrocode} +\def\quote@name#1{"\quote@@name#1\@gobble""} +\def\quote@@name#1"{#1\quote@@name} +% \end{macrocode} +% and removing quotes \ldots +% \begin{macrocode} +\def\unquote@name#1{\quote@@name#1\@gobble"} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% +% \begin{macro}{\IfFileExists} +% +% \changes{v1.2a}{2019/07/01}{Support UTF-8} +% \changes{v1.2b}{2019/08/27}{Make command robust} +% \begin{macrocode} +\DeclareRobustCommand\IfFileExists[1]{% + \set@curr@file{#1}% + \edef\q@curr@file{\expandafter\quote@name\expandafter{\@curr@file}}% + \expandafter\IfFileExists@\expandafter{\q@curr@file}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\IfFileExists@} % \changes{v0.9b}{1993/12/04}{Macro added} % \changes{v0.9p}{1994/01/18}{New Definition} -% \changes{v1.0t}{1995/05/25} -% {(CAR) added \cs{long}} +% \changes{v1.0t}{1995/05/25}{(CAR) added \cs{long}} % % \begin{macrocode} -\long\def \IfFileExists#1#2#3{% +\long\def \IfFileExists@#1#2#3{% \openin\@inputcheck#1 % \ifeof\@inputcheck \ifx\input@path\@undefined @@ -678,6 +780,42 @@ \fi \reserved@a} % \end{macrocode} +% \end{macro} +% +% +% \begin{macrocode} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\set@curr@file}{Quote file names}% +%<latexrelease> +%<latexrelease>\let\quote@name\@undefined +%<latexrelease>\let\quote@@name\@undefined +%<latexrelease>\let\unquote@name\@undefined +%<latexrelease>\let\set@curr@file\@undefined +%<latexrelease> +%<latexrelease>\let\IfFileExists@\@undefined +%<latexrelease> +%<latexrelease>\long\def \IfFileExists#1#2#3{% +%<latexrelease> \openin\@inputcheck#1 % +%<latexrelease> \ifeof\@inputcheck +%<latexrelease> \ifx\input@path\@undefined +%<latexrelease> \def\reserved@a{#3}% +%<latexrelease> \else +%<latexrelease> \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}% +%<latexrelease> \fi +%<latexrelease> \else +%<latexrelease> \closein\@inputcheck +%<latexrelease> \edef\@filef@und{#1 }% +%<latexrelease> \def\reserved@a{#2}% +%<latexrelease> \fi +%<latexrelease> \reserved@a} +%<latexrelease> +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} +% +% % % \begin{macro}{\@iffileonpath} % If the file is not found by |\openin|, and |\input@path| is defined, @@ -704,7 +842,6 @@ \reserved@a} % \end{macrocode} % \end{macro} -% \end{macro} % % \begin{macro}{\InputIfFileExists} % \changes{v0.9b} @@ -718,13 +855,51 @@ % If the file |#1| does not exist, execute `|#3|'. % \changes{v1.0t}{1995/05/25} % {(CAR) added \cs{long}} +% \changes{v1.1o}{2019/02/07}{Expand \cs{@filef@und} before executing +% second argument (github/109)} +% \changes{v1.2b}{2019/08/27}{Make command robust} % \begin{macrocode} -\long\def \InputIfFileExists#1#2{% +%</2ekernel> +%<latexrelease>\IncludeInRelease{2019/10/01}% +%<latexrelease> {\InputIfFileExists}{Don't lose the file name}% +%<*2ekernel|latexrelease> +% \begin{macrocode} +\DeclareRobustCommand \InputIfFileExists[2]{% \IfFileExists{#1}% - {#2\@addtofilelist{#1}\@@input \@filef@und}} + {% + \expandafter\@swaptwoargs\expandafter + {\@filef@und}{#2\@addtofilelist{#1}\@@input}}} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@swaptwoargs} +% +% \changes{v1.1o}{2019/02/07}{Helper macro added} +% Swap two arguments and return them unbraced (like +% \cs{@firstoftwo} etc). +% \begin{macrocode} +\long\def\@swaptwoargs#1#2{#2#1} % \end{macrocode} % \end{macro} % +% +% \begin{macrocode} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\InputIfFileExists}{Don't lose the file name}% +%<latexrelease>\long\def \InputIfFileExists#1#2{% +%<latexrelease> \IfFileExists{#1}% +%<latexrelease> {#2\@addtofilelist{#1}\@@input \@filef@und}} +%<latexrelease> +%<latexrelease>\let\@swaptwoargs\@undefined +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} +% +% +% % \begin{macro}{\input} % Input a file: if the argument is given in braces use safe input % macros, otherwise use \TeX's primitive |\input| command (which is @@ -740,15 +915,36 @@ % |\InputIfIfileExists|. % \changes{v0.9b}{1993/12/04}{Macro reimplemented} % \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2019/10/01}% +%<latexrelease> {\@iinput}{Quote file names}% \def\@iinput#1{% \InputIfFileExists{#1}{}% - {\filename@parse{#1}% + {\filename@parse\@curr@file \edef\reserved@a{\noexpand\@missingfileerror {\filename@area\filename@base}% {\ifx\filename@ext\relax tex\else\filename@ext\fi}}% \reserved@a}} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\@iinput}{Quote file names}% +%<latexrelease>\def\@iinput#1{% +%<latexrelease> \InputIfFileExists{#1}{}% +%<latexrelease> {\filename@parse{#1}% +%<latexrelease> \edef\reserved@a{\noexpand\@missingfileerror +%<latexrelease> {\filename@area\filename@base}% +%<latexrelease> {\ifx\filename@ext\relax tex\else\filename@ext\fi}}% +%<latexrelease> \reserved@a}} +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> % \end{macrocode} % \end{macro} + + + + % % \begin{macro}{\@input} % \changes{v0.9b}{1993/12/04}{Macro reimplemented} |