Skip to content

Commit cd9093f

Browse files
Gh1150 docstrip (#1595)
* fix for #1150 * try again * Apply suggestions from code review Co-authored-by: Yukai Chou <[email protected]> * Update base/docstrip.dtx Co-authored-by: Yukai Chou <[email protected]> --------- Co-authored-by: Yukai Chou <[email protected]>
1 parent 17df2c8 commit cd9093f

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

base/changes.txt

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ not part of the distribution.
1313
\index entries that are used directly in the document and aren't hidden
1414
inside other macros (because then no expansion happens) gh/1418
1515

16+
2024-12-23 Frank Mittelbach <[email protected]>
17+
18+
* docstrip.dtx (subsection{Batchfile commands}):
19+
Check that the stream macro (with the name of a file to generate) is not
20+
already used, e.g., as a declared preamble (gh/1150)
21+
1622
2024-12-22 Frank Mittelbach <[email protected]>
1723

1824
* ltcmdhooks.dtx (subsection{Patching or delaying}):

base/doc/ltnews41.tex

+12
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,18 @@ \subsection{Fix the use of \texttt{localmathalpabets}}
370370
%
371371
\githubissue[s]{1101 1028}
372372

373+
\subsection{\pkg{docstrip}:\ Error if \texttt{.ins} file is problematical}
374+
375+
If a file to generate had the same name as a preamble declared with
376+
\cs{declarepreamble} the preamble definition was overwritten because
377+
the macro used to store it was reused for denoting the output
378+
stream. The same problem happened with postambles declared with
379+
\cs{declarepostamble}. This is now detected and an error message is
380+
issued. To circumvent the issue in that case, simply use a different
381+
macro name for the preamble or postamble.
382+
%
383+
\githubissue{1150}
384+
373385

374386
\subsection{Prevent \texttt{cmd} hook from defining an undefined command}
375387

base/docstrip.dtx

+32-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
\catcode`\{=1
3030
\catcode`\}=2
3131
\def\filename{docstrip.dtx}
32-
\def\fileversion{v2.6b}
33-
\def\filedate{2022-09-03}
34-
\def\docdate {2024-02-08}
32+
\def\fileversion{v2.6c}
33+
\def\filedate{2024-12-23}
34+
\def\docdate {2024-12-23}
3535
%%
3636
%
3737
%\iffalse
@@ -3027,8 +3027,37 @@ Z
30273027
% defining preamble for the current file.
30283028
% \begin{macrocode}
30293029
\def\@fileX#1#2{%
3030+
% \end{macrocode}
3031+
% If the csname used for the stream has already been defined, e.g.,
3032+
% as a preamble or postamble or for some other purposes, chances are
3033+
% that turning it into a stream number will break something. We
3034+
% therefore generate an error and show the current definition.
3035+
% \changes{v2.6c}{2024-12-23}{Check that stream macro is not already
3036+
% used (gh/1150)}
3037+
% \begin{macrocode}
3038+
\ifx#1\relax \else
3039+
\errmessage{Command \string#1 for denoting the output \noexpand
3040+
\file stream already defined!^^J
3041+
\space Current meaning is:^^J^^J\meaning#1^^J^^J
3042+
\space Extraction will probably fail - check result}%
3043+
\fi
30303044
\chardef#1=\stream@closed
30313045
\def\curout{#1}%
3046+
% \end{macrocode}
3047+
% If it matches the name of the current preamble or postamble then
3048+
% it definitely can't work, so we call that out explicitly:
3049+
% \begin{macrocode}
3050+
\ifx\curout\currentpreamble
3051+
\errmessage{Declared preamble name \string#1 not allowed if
3052+
\string\file{\@stripstring#1} is used}%
3053+
\fi
3054+
\ifx\curout\currentpostamble
3055+
\errmessage{Declared postamble name \string#1 not allowed if
3056+
\string\file{\@stripstring#1} is used}%
3057+
\fi
3058+
% \end{macrocode}
3059+
%
3060+
% \begin{macrocode}
30323061
\let\curinfiles\empty
30333062
\let\curinnames\empty
30343063
\def\curref{\MetaPrefix ^^J%

0 commit comments

Comments
 (0)