summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/koma-script/scrdocstrip.tex
blob: 6d923e8c5af3bd8fdc890645f9c39d25851353c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
% ======================================================================
% scrdocstrip.tex
% Copyright (c) Markus Kohm, 2013-2022
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
%   http://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 and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in MANIFEST.md.
% ======================================================================
% $Id: scrdocstrip.tex 3915 2022-06-29 07:09:48Z kohm $

\expandafter\ifx\csname scrdocstripversion\endcsname\relax
  \let\KOMAbatchfile\batchfile
  \let\batchfile\undefined
\fi

\input docstrip.tex

\ifx\generate\undefined
  \errhelp{| This installation requires docstrip version 2.3c or * later,^^J%
    | but an old version of docstrip has been input.^^J%
    | This error is fatal, because You have to update docstrip and maybe LaTeX
    fist!}
  \errmessage{| Fatal error: Old docstrip in input path}
  \batchmode
  \csname @@end\endcsname
\fi

\expandafter\ifx\csname scrdocstripversion\endcsname\relax
\else \expandafter\endinput
\fi
\Msg{| Using KOMA-Script's docstrip extensions.}%|
% Support for variables:
\def\KOMAdefVariable#1#2{%
  \expandafter\def\csname KOMAvar@#1\endcsname{#2}%
}
\def\KOMAifVariable#1{%
  \expandafter\ifx\csname KOMAvar@#1\endcsname\relax
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi
}
\def\KOMAuseVariable#1{%
  \KOMAifVariable{#1}{%
    \csname KOMAvar@#1\endcsname
  }{%
    variable #1\undefined
  }%
}
\KOMAdefVariable{AUTHOR}{Markus Kohm}
\KOMAdefVariable{COPYRIGHT}{%
  Copyright (c) 
  \KOMAifVariable{COPYRIGHTFROM}{\KOMAuseVariable{COPYRIGHTFROM}-}{}%
  \KOMAifVariable{COPYRIGHTTILL}{\KOMAuseVariable{COPYRIGHTTILL}}{}
  \KOMAuseVariable{AUTHOR}%
  \KOMAifVariable{EMAIL}{ \KOMAuseVariable{EMAIL}}{}%
}
\KOMAdefVariable{COPYRIGHTCOMMENT}{%
  \MetaPrefix\space\KOMAuseVariable{COPYRIGHT}%
}
% Extend line scanner by:
% - %!VARIABLE       : to write variable into files
% - %?VARIABLE=VALUE : to setup a new variable
\begingroup
\catcode`\%=12 \catcode`\*=14
\gdef\processLineX%#1{*
  \ifcase\ifx%#10\else
         \ifx<#11\else
         \ifx!#12\else 3\fi\fi\fi\relax
    \expandafter\putMetaComment\or
    \expandafter\checkOption\or
    \expandafter\KOMAexpandVariable\or
    \expandafter\removeComment\fi
  #1}
\gdef\KprocessLineX%#1{*
  \ifcase\ifx%#10\else
         \ifx<#11\else
         \ifx!#12\else
         \ifx?#13\else 4\fi\fi\fi\fi\relax
    \expandafter\putMetaComment\or
    \expandafter\checkOption\or
    \expandafter\KOMAexpandVariable\or
    \expandafter\KOMAsetVariable\or
    \expandafter\removeComment\fi
  #1}
\endgroup
\def\KOMAexpandVariable!#1\endLine{%
  \advance\codeLinesPassed\@ne
  \maybeMsg{x}%
  \edef\inLine{\KOMAuseVariable{#1}}%
  \let\do\putline@do
  \activefiles
}
\def\KOMAsetVariable?#1=#2\endLine{%
  \expandafter\gdef\csname KOMAvar@#1\endcsname{#2}%
}
% Extend heading
\def\ds@heading{%
  \expandafter\ifx\csname ifbeta\expandafter\endcsname
                  \csname iftrue\endcsname
    \use@Warning{\outFileName}{%
      YOU SHOULD NOTE, THAT THIS IS NOT AN OFFICIAL RELEASE!^^J%
      THIS VERSION IS INTENDED TO BE USED FOR TESTING ONLY!^^J%
      USAGE FOR PURPOSES OTHER THAN INTENDED IS DANGEROUS!^^J%
      DON'T EXPECT ANY SUPPORT FOR THIS VERSION!%
    }%
  \fi
  \MetaPrefix ^^J%
  \MetaPrefix\space This is file `\outFileName',^^J%
  \MetaPrefix\space generated with the docstrip utility, extended by
  scrdocstrip.^^J%
}
\def\commentWarning#1#2{%
  \MetaPrefix\space 
  -------------------------------------------------------------------------^^J%
  \@commentWarning#2^^J\@nil
  \MetaPrefix\space 
  -------------------------------------------------------------------------^^J%
}
\def\@commentWarning#1^^J#2\@nil{%
  \MetaPrefix\space #1^^J%
  \ifx\relax#2\relax\else\@commentWarning#2\@nil\fi
}
\def\KNL{^\empty^J\perCent^^J}
\def\XKNL{^\empty^J\perCent|^^J}
\def\genericWarning#1#2{%
  \string\expandafter\string\ifx\string\csname\space scrWMSG\string\endcsname\string\relax^^J%
  \space\space\string\def\string\scrWMSG{\string\immediate\string\write17}^^J%
  \string\fi^^J%
  \string\scrWMSG{\KNL
    +----------------------------------------------------------------------\KNL
    | WARNING (`#1'):\XKNL
    +----------------------------------------------------------------------\KNL
    \@genericWarning#2^^J\@nil
    +----------------------------------------------------------------------\KNL
  }^^J%
}
\def\@genericWarning#1^^J#2\@nil{%
  | #1\XKNL
  \ifx\relax#2\relax\else\@genericWarning#2\@nil\fi
}%|
\def\useWarning#1{\let\use@Warning#1}
\useWarning\genericWarning

% Now, we need some code from docstrip to start old docstrip-processing
\ifx\undefined\KOMAbatchfile\else 
  \Defaultfalse
  \let\batchfile\KOMAbatchfile
  \def\process@first@batchfile{%
    \processbatchFile
    \ifnum\NumberOfFiles=\z@
      \interactive
    \fi
    \endbatchfile
  }
\fi

\chardef\scrdocstripversion 1\relax

\def\fromoptional#1{%
  \immediate\openin\inputcheck\uptospace#1 \qStop\relax
  \ifeof\inputcheck
    \Msg{Ignorring not existing optional file `#1'.}%
    \expandafter\@gobbletwo
  \else
    \immediate\closein\inputcheck
    \expandafter\from
  \fi
  {#1}%
}

\process@first@batchfile
\endinput
%
% end of file `scrdocstrip.tex'