| 1 |
% \def\filename{snapshot.dtx} |
| 2 |
% \def\fileversion{2.14} |
| 3 |
% \def\filedate{2020/06/17} |
| 4 |
% |
| 5 |
% \iffalse meta-comment |
| 6 |
% |
| 7 |
% American Mathematical Society |
| 8 |
% Technical Support |
| 9 |
% Publications Technical Group |
| 10 |
% 201 Charles Street |
| 11 |
% Providence, RI 02904 |
| 12 |
% USA |
| 13 |
% tel: (401) 455-4080 |
| 14 |
% (800) 321-4267 (USA and Canada only) |
| 15 |
% fax: (401) 331-3842 |
| 16 |
% email: [email protected] |
| 17 |
% |
| 18 |
% Copyright 1999-2003, 2004, 2010, 2012, 2020 American Mathematical Society. |
| 19 |
% |
| 20 |
% This work may be distributed and/or modified under the |
| 21 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 22 |
% of this license or (at your option) any later version. |
| 23 |
% The latest version of this license is in |
| 24 |
% http://www.latex-project.org/lppl.txt |
| 25 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 26 |
% version 2005/12/01 or later. |
| 27 |
% |
| 28 |
% This work has the LPPL maintenance status `maintained'. |
| 29 |
% |
| 30 |
% The Current Maintainer of this work is the American Mathematical |
| 31 |
% Society. |
| 32 |
% |
| 33 |
% \fi |
| 34 |
% |
| 35 |
% \iffalse |
| 36 |
%<*driver> |
| 37 |
\NeedsTeXFormat{LaTeX2e} |
| 38 |
\documentclass{amsdtx} |
| 39 |
|
| 40 |
\usepackage{hyperref} |
| 41 |
|
| 42 |
\providecommand{\qq}[1]{\textquotedblleft#1\textquotedblright} |
| 43 |
\providecommand{\mdash}{\textemdash\penalty\exhyphenpenalty} |
| 44 |
\providecommand{\lat}[1]{\protect\LaTeX{}} |
| 45 |
\providecommand{\strong}[1]{\textbf{#1}} |
| 46 |
\providecommand{\secref}[1]{Section~\ref{#1}} |
| 47 |
|
| 48 |
\CodelineIndex |
| 49 |
|
| 50 |
\title{The \pkg{snapshot} package} |
| 51 |
|
| 52 |
\author{American Mathematical Society} |
| 53 |
|
| 54 |
\date{Version \fileversion, \filedate} |
| 55 |
|
| 56 |
\begin{document} |
| 57 |
|
| 58 |
\DocInput{snapshot.dtx} |
| 59 |
|
| 60 |
\PrintIndex |
| 61 |
|
| 62 |
\end{document} |
| 63 |
%</driver> |
| 64 |
% \fi |
| 65 |
% |
| 66 |
% \MakeShortVerb{\|} |
| 67 |
% |
| 68 |
% \maketitle |
| 69 |
% |
| 70 |
% \tableofcontents |
| 71 |
% |
| 72 |
% \section{Introduction} |
| 73 |
% |
| 74 |
% The \pkg{snapshot} package helps the owner of a \LaTeX{} document |
| 75 |
% obtain a list of the external dependencies of the document, in a |
| 76 |
% form that can be embedded at the top of the document. To put it |
| 77 |
% another way, it provides a snapshot of the current processing |
| 78 |
% context of the document, insofar as it can be determined from |
| 79 |
% inside \LaTeX{}. |
| 80 |
% |
| 81 |
% If a document contains such a dependency list, then it becomes |
| 82 |
% possible to arrange that the document be processed always with the |
| 83 |
% same versions of everything, in order to ensure the same output. |
| 84 |
% This could be useful for someone wanting to keep a \LaTeX{} |
| 85 |
% document on hand and consistently reproduce an identical DVI file |
| 86 |
% from it, on the fly; or for someone wanting to shield a document |
| 87 |
% during the final stages of its production cycle from unexpected |
| 88 |
% side effects of routine upgrades to the \TeX{} system. |
| 89 |
% |
| 90 |
% Normal usage of the \pkg{snapshot} package involves the following |
| 91 |
% steps: |
| 92 |
% \begin{enumerate} |
| 93 |
% \item Add a \cn{RequirePackage} statement at the top of the |
| 94 |
% document: |
| 95 |
% \begin{verbatim} |
| 96 |
% \RequirePackage{snapshot} |
| 97 |
% \documentclass{article} |
| 98 |
% ... |
| 99 |
% \end{verbatim} |
| 100 |
% |
| 101 |
% \item Run \latex/ on the document. This will produce a dependency |
| 102 |
% list in a file \verb'\jobname.dep'. (I.e., if the document name is |
| 103 |
% \fn{vermont.ltx}, the dependency list will be named |
| 104 |
% \fn{vermont.dep}.) |
| 105 |
% |
| 106 |
% \item Insert the \fn{.dep} file at the top of the document, before |
| 107 |
% \cn{documentclass}. The following example shows what you would end |
| 108 |
% up with for a document that used the article documentclass and the |
| 109 |
% graphicx package: |
| 110 |
% \begin{verbatim} |
| 111 |
% \RequirePackage{snapshot}[1999/11/03] |
| 112 |
% \RequireVersions{ |
| 113 |
% *{application}{TeX} {1990/03/25 v3.x} |
| 114 |
% *{format} {LaTeX2e} {1999/06/01 v2.e} |
| 115 |
% *{package}{snapshot} {1999/11/03 v1.03} |
| 116 |
% *{class} {article} {1999/01/07 v1.4a} |
| 117 |
% *{file} {size10.clo} {1999/01/07 v1.4a} |
| 118 |
% *{package}{graphicx} {1999/02/16 v1.0f} |
| 119 |
% *{package}{keyval} {1999/03/16 v1.13} |
| 120 |
% *{package}{graphics} {1999/02/16 v1.0l} |
| 121 |
% *{package}{trig} {1999/03/16 v1.09} |
| 122 |
% *{file} {graphics.cfg}{0000/00/00 v0.0} |
| 123 |
% *{file} {dvips.def} {1999/02/16 v3.0i} |
| 124 |
% } |
| 125 |
% \documentclass{article} |
| 126 |
% \usepackage{graphicx} |
| 127 |
% ... |
| 128 |
% \end{verbatim} |
| 129 |
% \end{enumerate} |
| 130 |
% |
| 131 |
% The package option \opt{log} will cause the dependency list to |
| 132 |
% appear in the \latex/ log file instead of in a separate \fn{.dep} |
| 133 |
% file: |
| 134 |
% \begin{verbatim} |
| 135 |
% \RequirePackage[log]{snapshot} |
| 136 |
% \end{verbatim} |
| 137 |
% Making the necessary arrangements to ensure that future \latex/ |
| 138 |
% runs of the document actually call in the specified versions is a |
| 139 |
% separate problem. The \pkg{snapshot} package only provides a way to |
| 140 |
% generate the dependency list. However, the \cn{RequireVersions} |
| 141 |
% statement does record the given information in a form that can be |
| 142 |
% accessed from within \latex/. (It is for this purpose that it is not |
| 143 |
% simply a comment.) In principle a package could be set up so that a |
| 144 |
% later version would automatically attempt to emulate an earlier |
| 145 |
% version if an earlier version was specified\mdash much as \latex/ |
| 146 |
% currently switches to 2.09 compatibility mode if it sees |
| 147 |
% \cn{documentstyle} instead of \cn{documentclass}. |
| 148 |
% |
| 149 |
% For maximum reliability font checksums should also be reported in |
| 150 |
% the dependency list, but standard \tex/ 3.x does not provide direct |
| 151 |
% access to font checksums for macro programmers. This information |
| 152 |
% could be added by a separate script that scans the DVI file. |
| 153 |
% (Certain nontrivial complications are possible, however.) |
| 154 |
% |
| 155 |
% \section{Graphics files} |
| 156 |
% When a graphics file is read in by a \latex/ document using the |
| 157 |
% standard \cn{includegraphics} command, it gets a dummy version |
| 158 |
% number string of |
| 159 |
%\begin{verbatim} |
| 160 |
%Graphics file (type foo) |
| 161 |
%\end{verbatim} |
| 162 |
% where foo is typically \texttt{eps}. This is with the current |
| 163 |
% version of the \pkg{graphics} package (at the time of this writing: |
| 164 |
% 1999/02/16 v1.0l). What this means in practice is that all graphics |
| 165 |
% files will have their snapshot date and version number recorded as |
| 166 |
%\begin{verbatim} |
| 167 |
%Graphics v0.0 |
| 168 |
%\end{verbatim} |
| 169 |
% and will always compare equal (the string ``Graphics'' will be used |
| 170 |
% in place of a date, but since comparison is done with \cs{ifx} it |
| 171 |
% doesn't make any real difference). |
| 172 |
% |
| 173 |
% It would be possible, for \fn{.eps} files at least, to read the |
| 174 |
% CreationDate comment that is normally included in the file header |
| 175 |
% and use that as the basis of comparison. Recording the bounding box |
| 176 |
% numbers instead of a dummy version number is another possibility, |
| 177 |
% which you can get with the |
| 178 |
% \opt{bbinfo} option (as of \pkg{snapshot} version 2.05). |
| 179 |
% |
| 180 |
% \section{Formalities} |
| 181 |
% |
| 182 |
% \DescribeMacro{\RequireVersions} The \cn{RequireVersions} command |
| 183 |
% scans its argument for file names and associated version number |
| 184 |
% information. The syntax of a version line for a particular file is |
| 185 |
% \begin{quote} |
| 186 |
% \verb'*{' \emph{file type} \verb'}{' \emph{file name} \verb'}{' |
| 187 |
% \emph{version info} \verb'}' |
| 188 |
% \end{quote} |
| 189 |
% In other words, the \verb'*' character in this context is like a |
| 190 |
% command that takes three arguments. The extension part of the |
| 191 |
% file name should be omitted in the second argument, except when the |
| 192 |
% file type is \fn{file} (following the conventions of \latex/'s |
| 193 |
% \cn{ProvidesPackage} and \cn{ProvidesFile} commands). The most |
| 194 |
% commonly used file types are as follows. |
| 195 |
% \begin{description} |
| 196 |
% \item[class] A \latex/ documentclass file. |
| 197 |
% \item[package] A \latex/ package file. |
| 198 |
% \item[tfm] A \tex/ font metric file. In this case the \qq{version |
| 199 |
% number} is the checksum, and unless you are using an extended |
| 200 |
% version of \tex/ this information is not accessible from inside |
| 201 |
% \latex/, so it must be filled in by an outside process. |
| 202 |
% By default, font metric files are not listed in the dependency list |
| 203 |
% since the checksum info is not available. There is a package option |
| 204 |
% \opt{tfm} to turn on the logging of metric files. (Not yet |
| 205 |
% implemented [mjd,1999/09/23]) |
| 206 |
% |
| 207 |
% \item[format] This is almost always \fn{LaTeX2e}. The information |
| 208 |
% comes from \cs{fmtname}. Lambda, e\LaTeX{}, and pdf\LaTeX{} leave |
| 209 |
% \cs{fmtname} unchanged, and although this may seem dubious at first |
| 210 |
% sight, I guess they have little choice: the widespread use of |
| 211 |
% \cs{NeedsTeXFormat} in existing package files makes them produce an |
| 212 |
% error message if \cs{fmtname} is changed. (Maybe the thing to do |
| 213 |
% would be to modify the definition of \cs{NeedsTeXFormat} as well.) |
| 214 |
% |
| 215 |
% For a \LaTeX{} format that uses the Babel mechanism for preloading |
| 216 |
% hyphenation patterns, the version number of \fn{babel.def} that was |
| 217 |
% used in building the format might be of interest. But at first |
| 218 |
% glance there does not seem to be any easy way of dealing with that, |
| 219 |
% and in the normal course of things, a document that relies on Babel |
| 220 |
% features will also have a \verb'\usepackage{babel}' statement at |
| 221 |
% the top, and that will yield adequate (I think) information for the |
| 222 |
% snapshot dependency list. |
| 223 |
% |
| 224 |
% \item[application] With standard \fn{TeX} there is no reliable way to |
| 225 |
% get the exact version number from inside \LaTeX{}. If a document is |
| 226 |
% processed with one of the recent variants that address this |
| 227 |
% deficiency (such as e-\TeX{}, pdf\TeX{} and Omega) the available |
| 228 |
% version info is used, but otherwise a presumptive value of |
| 229 |
% \verb'1990/03/25 v3.x' is used (the official release date of \TeX{} |
| 230 |
% 3.0). |
| 231 |
% |
| 232 |
% \item[file] None of the above: some other file of miscellaneous type, |
| 233 |
% e.g., \fn{.clo}, \fn{.cfg}, \fn{.tex}, or \fn{.def}. |
| 234 |
% \end{description} |
| 235 |
% |
| 236 |
% The \cn{RequireVersions} command can be given an optional |
| 237 |
% \qq{ident} argument, similar to the argument of a \cn{label} |
| 238 |
% command. This is not used internally but it could be used to |
| 239 |
% assign a label to particular groups of files in case that helps |
| 240 |
% with external processing. |
| 241 |
% |
| 242 |
% \section{Package options} |
| 243 |
% |
| 244 |
% The list of options supported by the \pkg{snapshot} package is as |
| 245 |
% follows: |
| 246 |
% \begin{center}\begin{tabular}{lll} |
| 247 |
% dep & date\\ |
| 248 |
% log & version\\ |
| 249 |
% tfm & major-version\\ |
| 250 |
% warning & bbinfo \\ |
| 251 |
% error & test \\ |
| 252 |
% self-warning |
| 253 |
% \end{tabular} |
| 254 |
% \end{center} |
| 255 |
% |
| 256 |
% \begin{description} |
| 257 |
% \item[dep, log] Write file date and version information to |
| 258 |
% \textit{jobname}\fn{.dep} or to the \LaTeX{} log file, respectively. |
| 259 |
% |
| 260 |
% \item[error, warning, self-warning] |
| 261 |
% If the \pkg{snapshot} package is invoked with the \opt{error} |
| 262 |
% option \emph{and also} the document contains a \cn{RequireVersions} |
| 263 |
% statement, then each subsequent \cn{ProvidesFile}, |
| 264 |
% \cn{ProvidesPackage}, and \cn{ProvidesClass} statement will compare |
| 265 |
% date and version number information with the corresponding |
| 266 |
% information from the \cn{RequireVersions} statement and give an |
| 267 |
% error message if a mismatch is detected. With the \opt{warning} |
| 268 |
% option you get warnings instead of errors. By default both the date |
| 269 |
% and the version number are compared; this behavior can be modified, |
| 270 |
% however, by giving additional options: |
| 271 |
% \begin{description} |
| 272 |
% \item[date] compare only dates, |
| 273 |
% \item[version] compare only version numbers, |
| 274 |
% \item[major-version] use only the major version number when |
| 275 |
% comparing. |
| 276 |
% \end{description} |
| 277 |
% |
| 278 |
% The \opt{self-warning} causes a warning to be given, instead of an |
| 279 |
% error, if the \pkg{snapshot} package itself has a date or |
| 280 |
% version mismatch. |
| 281 |
% |
| 282 |
% \textbf{Note:} A file that doesn't have any sort of |
| 283 |
% \cn{ProvidesFile} or \cn{ProvidesPackage} statement in it will show |
| 284 |
% up in the dependency list, with a dummy date and version number of |
| 285 |
% 0000/00/00 v0.0, but testing for a version mismatch with such a |
| 286 |
% file is then infeasible. |
| 287 |
% |
| 288 |
% \item[bbinfo] For files of type ``graphic'', include bounding-box info |
| 289 |
% as the ``version number''. A normal date and version number are |
| 290 |
% seldom available for such files, and \LaTeX{} does not attempt |
| 291 |
% to read them, which means that the \pkg{snapshot} package could not |
| 292 |
% obtain the information except by drastically modifying the |
| 293 |
% low-level \LaTeX{} operations that read graphics file |
| 294 |
% information\mdash which seems overly risky. |
| 295 |
% |
| 296 |
% \item[tfm] \emph{Not implemented yet!} Include information about which |
| 297 |
% \TeX{} font metric files are called by \LaTeX{}. This list is |
| 298 |
% usually somewhat different from the list of fonts that are actually |
| 299 |
% used in the output file (\fn{.dvi} or \fn{.pdf}), primarily because |
| 300 |
% the setup for math formulas will normally preload font metric |
| 301 |
% information for all the fonts from which \LaTeX{}'s basic math |
| 302 |
% symbols are drawn (the symbols documented in the \LaTeX{} book), |
| 303 |
% even if the document does not use symbols from all of those fonts. |
| 304 |
% |
| 305 |
% \item[test] This option is for a special purpose. It drastically |
| 306 |
% changes the action of the \cs{RequireVersions} command so that it |
| 307 |
% does not merely record the information for later reference, but |
| 308 |
% does a \qq{trial load attempt} for each file in the list, and then |
| 309 |
% stops the \LaTeX{} job as soon as the list is finished, without |
| 310 |
% continuing any further. |
| 311 |
% |
| 312 |
% By \qq{trial load attempt} I mean that the \cs{RequireVersions} |
| 313 |
% command will actually input each file, but with various bits |
| 314 |
% redefined so that \cs{ProvidesPackage} and variants will execute |
| 315 |
% \cs{endinput}\mdash in other words, only the first few lines of |
| 316 |
% each file will be read. |
| 317 |
% |
| 318 |
% What this means, practically speaking, is that if you run such a |
| 319 |
% test on a document, it gives a relatively quick check on two useful |
| 320 |
% pieces of information without having to retypeset the entire |
| 321 |
% document (which for some documents might be very tedious) |
| 322 |
% \begin{enumerate} |
| 323 |
% \item The actual location on your system from which the file will be |
| 324 |
% loaded. |
| 325 |
% |
| 326 |
% \item The date and version info from \cs{Provides...} line, if present. |
| 327 |
% \end{enumerate} |
| 328 |
% |
| 329 |
% Similar results could be obtained by a combination of |
| 330 |
% \fn{kpsewhich} and \fn{grep}, but because the \pkg{snapshot} \opt{test} |
| 331 |
% option works through \LaTeX{}, it is a system-independent method. |
| 332 |
% |
| 333 |
% Caveat: If a file does not contain any \cs{ProvidesSomething} line, |
| 334 |
% it will be read in its entirety, which might lead to errors. Or if |
| 335 |
% there is any weird stuff preceding the \cs{ProvidesWhatever} line. |
| 336 |
% But for well-behaved files the option seemed useful enough to be |
| 337 |
% worth implementing. |
| 338 |
% |
| 339 |
% \end{description} |
| 340 |
% |
| 341 |
% \StopEventually{} |
| 342 |
% |
| 343 |
% \section{Implementation} |
| 344 |
% Standard declaration of package name and date. |
| 345 |
% \begin{macrocode} |
| 346 |
\NeedsTeXFormat{LaTeX2e}[1994/12/01] |
| 347 |
\ProvidesPackage{snapshot}[2020/06/17 v2.14] |
| 348 |
% \end{macrocode} |
| 349 |
% |
| 350 |
% Calling the \pkg{snapshot} package in a document causes \latex/ to |
| 351 |
% list the file names and versions in the \tex/ log or in a \fn{.dep} |
| 352 |
% file, so that the information may be easily copied into the |
| 353 |
% document file. The list so generated is nothing more than a slight |
| 354 |
% adaptation of the output from \latex/'s \cn{listfiles} command; it |
| 355 |
% puts essentially the same information into a slightly more |
| 356 |
% structured form so that it will be easier to use. |
| 357 |
% |
| 358 |
% For the standard mechanisms that are already built into \latex/ |
| 359 |
% (e.g., the handling of the second optional argument of |
| 360 |
% \cs{LoadClass}), the de facto \qq{version number} is the |
| 361 |
% \emph{date} given in the optional argument of a \cn{ProvidesClass} |
| 362 |
% or similar command. Even though most \cn{ProvidesWhatever} commands |
| 363 |
% also give something that follows the usual form of version |
| 364 |
% numbers\mdash a string of the form \verb'v2.3'\mdash this is only a |
| 365 |
% convention, not used internally by \latex/, and the identification |
| 366 |
% string of a random loaded file is not guaranteed to include it. The |
| 367 |
% \pkg{snapshot} package copies both pieces of information if |
| 368 |
% available; if the second piece is not present, a dummy number |
| 369 |
% \verb'0.0' is supplied. Similarly, files that don't include any |
| 370 |
% \cn{ProvidesWhatever} statement will get a dummy date of |
| 371 |
% \verb'0000/00/00'; |
| 372 |
% \begin{center}\begin{minipage}{.9\columnwidth}\bfseries |
| 373 |
% \medskip |
| 374 |
% \tex/ system administrators who want to ensure |
| 375 |
% maximal accuracy of the snapshot information should therefore make |
| 376 |
% it a practice to use \cn{ProvidesFile} in \fn{.cfg} files and other |
| 377 |
% local files that might have an impact on the output fidelity of |
| 378 |
% their documents. |
| 379 |
% \end{minipage}\end{center} |
| 380 |
% |
| 381 |
% \begin{macro}{\@xp} |
| 382 |
% \begin{macro}{\@nx} |
| 383 |
% A couple of shorthand forms. |
| 384 |
% \begin{macrocode} |
| 385 |
\let\@xp=\expandafter \let\@nx=\noexpand |
| 386 |
% \end{macrocode} |
| 387 |
% \end{macro} |
| 388 |
% \end{macro} |
| 389 |
% |
| 390 |
% \begin{macro}{\str@cmp} |
| 391 |
% \begin{macro}{\str@equal} |
| 392 |
% A function to compare two strings and return FT or TT (for use with |
| 393 |
% \cs{if}). |
| 394 |
% \begin{macrocode} |
| 395 |
\def\str@cmp#1#2\str@cmp#3{% |
| 396 |
\if #1#3\else F\@car\fi \str@cmp#2\str@cmp |
| 397 |
} |
| 398 |
\def\string@equal#1#2{% |
| 399 |
\str@cmp#1\relax\str@cmp#2{\relax\@gobbletwo}\@nil TT% |
| 400 |
} |
| 401 |
% \end{macrocode} |
| 402 |
% \end{macro} |
| 403 |
% \end{macro} |
| 404 |
% |
| 405 |
% \begin{macro}{\RequireVersions} |
| 406 |
% |
| 407 |
% Optional argument of \cn{RequireVersions} allows assigning a name to a |
| 408 |
% particular collection of files. This might be useful for setting a |
| 409 |
% \tex/ inputs path. |
| 410 |
% \begin{macrocode} |
| 411 |
\newcommand{\RequireVersions}[2][]{}% |
| 412 |
|
| 413 |
\renewcommand{\RequireVersions}[1][]{% |
| 414 |
\def\snap@check{\snap@compare@versions}% |
| 415 |
\toks@{#1}% |
| 416 |
\afterassignment\snap@storem |
| 417 |
\let\@let@token= |
| 418 |
} |
| 419 |
|
| 420 |
\@onlypreamble\RequireVersions |
| 421 |
% \end{macrocode} |
| 422 |
% \end{macro} |
| 423 |
% |
| 424 |
% \begin{macro}{\snap@storem} |
| 425 |
% \begin{macrocode} |
| 426 |
\def\snap@storem{% |
| 427 |
\ifx\@let@token\bgroup \else |
| 428 |
\PackageError{snapshot}{Expected a `\@charlb' character here}\@ehc |
| 429 |
\@xp\@gobblefour |
| 430 |
\fi |
| 431 |
\futurelet\@let@token\snap@branch |
| 432 |
} |
| 433 |
% \end{macrocode} |
| 434 |
% \end{macro} |
| 435 |
% |
| 436 |
% \begin{macro}{\snap@check} |
| 437 |
% \begin{macrocode} |
| 438 |
\let\snap@check\@gobble |
| 439 |
% \end{macrocode} |
| 440 |
% \end{macro} |
| 441 |
% |
| 442 |
% \begin{macro}{\snap@finish} |
| 443 |
% \begin{macrocode} |
| 444 |
\def\snap@finish{\toks@\bgroup} |
| 445 |
% \end{macrocode} |
| 446 |
% \end{macro} |
| 447 |
% |
| 448 |
% \begin{macro}{\snap@branch} |
| 449 |
% \begin{macrocode} |
| 450 |
\def\snap@branch{% |
| 451 |
\ifx\@let@token\egroup |
| 452 |
\@xp\snap@finish |
| 453 |
\else\ifx\@let@token *% |
| 454 |
\let\reserved@c\snap@store@version |
| 455 |
\else\ifx\@let@token\@sptoken |
| 456 |
\lowercase{\def\reserved@c} {\futurelet\@let@token\snap@branch}% |
| 457 |
\else |
| 458 |
\let\reserved@c\snap@store@error |
| 459 |
\fi\fi\fi |
| 460 |
\reserved@c |
| 461 |
} |
| 462 |
% \end{macrocode} |
| 463 |
% \end{macro} |
| 464 |
% |
| 465 |
% \begin{macro}{\snap@store@error} |
| 466 |
% \begin{macrocode} |
| 467 |
\def\snap@store@error#1{% |
| 468 |
\PackageError{snapshot}{Expected '*' here, not '#1'}\@ehc |
| 469 |
} |
| 470 |
|
| 471 |
\@onlypreamble\snap@store@error |
| 472 |
% \end{macrocode} |
| 473 |
% \end{macro} |
| 474 |
% |
| 475 |
% \begin{macro}{\snap@store@version} |
| 476 |
% \begin{macrocode} |
| 477 |
\def\snap@store@version #1#2#3#4{% |
| 478 |
\@xp\snap@store@b\csname snapx@#2\endcsname{#2}{#3}{#4}% |
| 479 |
} |
| 480 |
|
| 481 |
\@onlypreamble\snap@store@version |
| 482 |
% \end{macrocode} |
| 483 |
% \end{macro} |
| 484 |
% |
| 485 |
% \subsection{Determining the engine} |
| 486 |
% |
| 487 |
% \begin{macro}{\snapshotApplication} |
| 488 |
|
| 489 |
% Check for the engines that are active in \TeX Live 2020. Note |
| 490 |
% that in in modern versions of \TeX Live, there is no distinction |
| 491 |
% between \fn{etex}, \fn{pdfetex}, and \fn{pdftex}. I believe this |
| 492 |
% code will distinguish between distinct legacy binaries, but I |
| 493 |
% have not tested this thoroughly. Similar remarks apply to the |
| 494 |
% p\TeX\ family. |
| 495 |
% |
| 496 |
% \begin{macrocode} |
| 497 |
\let\snapshotApplication\@empty |
| 498 |
|
| 499 |
\ifx\OmegaVersion\@@undefined \else |
| 500 |
\edef\snapshotApplication{% |
| 501 |
\ifx\AlephVersion\@@undefined |
| 502 |
{Omega}\space\space\space |
| 503 |
{0000/00/00 v\OmegaVersion}% |
| 504 |
\else |
| 505 |
{Aleph}\space\space\space |
| 506 |
% \end{macrocode} |
| 507 |
% \cs{AlephVersion} appears to be incorrectly set to 0.0, so |
| 508 |
% include the Omega version as well. |
| 509 |
% \begin{macrocode} |
| 510 |
{0000/00/00 v\OmegaVersion-\AlephVersion}% |
| 511 |
\fi |
| 512 |
}% |
| 513 |
\fi |
| 514 |
|
| 515 |
\ifx\ptexversion\@@undefined\else |
| 516 |
\edef\snapshotApplication{% |
| 517 |
{pTeX}\space\space\space\space |
| 518 |
{0000/00/00 v\number\ptexversion |
| 519 |
\ifx\ptexminorversion\undefined \u \else.\number\ptexminorversion\fi |
| 520 |
\ifx\ptexrevision\undefined \u \else\ptexrevision\fi}% |
| 521 |
}% |
| 522 |
\ifx\uptexversion\@@undefined |
| 523 |
\ifx\epTeXversion\@@undefined\else |
| 524 |
\edef\snapshotApplication{% |
| 525 |
{epTeX}\space\space\space |
| 526 |
{0000/00/00 v\number\epTeXversion}% |
| 527 |
}% |
| 528 |
\fi |
| 529 |
\else |
| 530 |
\ifx\epTeXversion\@@undefined |
| 531 |
\edef\snapshotApplication{% |
| 532 |
{upTeX}\space\space\space |
| 533 |
{0000/00/00 v\number\uptexversion |
| 534 |
\ifx\uptexrevision\undefined \u \else\uptexrevision\fi}% |
| 535 |
}% |
| 536 |
\else |
| 537 |
% \end{macrocode} |
| 538 |
% There is no separate \cs{euptexversion}, so use a combination of |
| 539 |
% the underlying up\TeX\ and ep\TeX\ versions. |
| 540 |
% \begin{macrocode} |
| 541 |
\edef\snapshotApplication{% |
| 542 |
{eupTeX}\space\space |
| 543 |
{0000/00/00 v\number\uptexversion |
| 544 |
\ifx\uptexrevision\undefined \u \else\uptexrevision\fi |
| 545 |
--\number\epTeXversion}% |
| 546 |
}% |
| 547 |
\fi |
| 548 |
\fi |
| 549 |
\fi |
| 550 |
|
| 551 |
\ifx\snapshotApplication\@empty |
| 552 |
\ifx\XeTeXversion\@@undefined\else |
| 553 |
\edef\snapshotApplication{% |
| 554 |
{XeTeX}\space\space\space |
| 555 |
{0000/00/00 v\number\XeTeXversion |
| 556 |
\ifx\XeTeXrevision\undefined\else\XeTeXrevision\fi}% |
| 557 |
}% |
| 558 |
\fi |
| 559 |
\fi |
| 560 |
|
| 561 |
\ifx\snapshotApplication\@empty |
| 562 |
\ifx\luatexversion\@@undefined\else |
| 563 |
\begingroup |
| 564 |
\@tempcnta\luatexversion |
| 565 |
\divide\@tempcnta by 100 |
| 566 |
\edef\@tempa{\the\@tempcnta}% |
| 567 |
\multiply\@tempcnta by 100 |
| 568 |
\@tempcntb\luatexversion |
| 569 |
\advance\@tempcntb by -\@tempcnta |
| 570 |
\edef\@tempa{\@tempa.\the\@tempcntb.\luatexrevision}% |
| 571 |
\xdef\snapshotApplication{% |
| 572 |
{luaTeX}\space\space |
| 573 |
{0000/00/00 v\@tempa}% |
| 574 |
}% |
| 575 |
\endgroup |
| 576 |
\fi |
| 577 |
\fi |
| 578 |
|
| 579 |
\ifx\snapshotApplication\@empty |
| 580 |
\ifx\pdftexversion\@@undefined \else |
| 581 |
\begingroup |
| 582 |
\ifx\eTeXversion\@@undefined |
| 583 |
\@tempswafalse |
| 584 |
\else |
| 585 |
\@tempswatrue |
| 586 |
\fi |
| 587 |
\@tempcnta\pdftexversion |
| 588 |
\divide\@tempcnta by 100 |
| 589 |
\edef\@tempa{\the\@tempcnta}% |
| 590 |
\multiply\@tempcnta by 100 |
| 591 |
\@tempcntb\pdftexversion |
| 592 |
\advance\@tempcntb by -\@tempcnta |
| 593 |
% \end{macrocode} |
| 594 |
% e\TeX\ was folded into pdf\TeX\ as of version 1.40. |
| 595 |
% \begin{macrocode} |
| 596 |
\ifnum\@tempcntb > 39 |
| 597 |
\@tempswafalse |
| 598 |
\fi |
| 599 |
\edef\@tempa{\@tempa.\the\@tempcntb.\pdftexrevision}% |
| 600 |
\xdef\snapshotApplication{% |
| 601 |
\if@tempswa |
| 602 |
{pdfeTeX}\space |
| 603 |
\else |
| 604 |
{pdfTeX}\space\space |
| 605 |
\fi |
| 606 |
{0000/00/00 v\@tempa}% |
| 607 |
}% |
| 608 |
\endgroup |
| 609 |
\fi |
| 610 |
\fi |
| 611 |
|
| 612 |
\ifx\snapshotApplication\@empty |
| 613 |
\ifx\eTeXversion\@@undefined \else |
| 614 |
\edef\snapshotApplication{% |
| 615 |
{eTeX}\space\space\space\space |
| 616 |
{0000/00/00 v\number\eTeXversion |
| 617 |
\ifx\eTeXrevision\undefined |
| 618 |
\ifx\eTeXminorversion\undefined\else.\number\eTeXminorversion\fi |
| 619 |
\else |
| 620 |
\eTeXrevision |
| 621 |
\fi |
| 622 |
}% |
| 623 |
}% |
| 624 |
\fi |
| 625 |
\fi |
| 626 |
% \end{macrocode} |
| 627 |
% If none of the above information is available, the exact version |
| 628 |
% number of \TeX{} is not accessible from inside \latex/. We then |
| 629 |
% fall back to using a nominal date of 1990/03/25, which is when |
| 630 |
% version 3.0 of \fn{tex.web} was released by Knuth. |
| 631 |
% \begin{macrocode} |
| 632 |
\ifx\snapshotApplication\@empty |
| 633 |
\edef\snapshotApplication{% |
| 634 |
{TeX}\space\space\space\space\space |
| 635 |
{1990/03/25 v3.x}% |
| 636 |
}% |
| 637 |
\fi |
| 638 |
% \end{macrocode} |
| 639 |
% \end{macro} |
| 640 |
% |
| 641 |
% \begin{macrocode} |
| 642 |
\def\@fmtextension{fmt} |
| 643 |
\def\@tfmextension{tfm} |
| 644 |
\edef\snapx@package{.\@pkgextension} |
| 645 |
\edef\snapx@class{.\@clsextension} |
| 646 |
\edef\snapx@format{.\@fmtextension} |
| 647 |
\edef\snapx@tfm{.\@tfmextension} |
| 648 |
\long\def\snapx@ignore{} |
| 649 |
\let\snapx@application=\snapx@ignore |
| 650 |
\let\snapx@file=\@empty |
| 651 |
\let\snapx@end\@@end |
| 652 |
\expandafter\let\csname snapx@-------\endcsname\snapx@end |
| 653 |
% \end{macrocode} |
| 654 |
% |
| 655 |
% \begin{macro}{\snap@store@b} |
| 656 |
% For a package named \fn{foo.sty}, this function defines |
| 657 |
% \cs{[email protected]} to hold the date and version information. |
| 658 |
% \begin{macrocode} |
| 659 |
\def\snap@store@b#1#2#3#4{% |
| 660 |
\ifx#1\snapx@end |
| 661 |
\@xp\snap@finish |
| 662 |
\else |
| 663 |
\ifx#1\relax \let#1\@empty\fi |
| 664 |
\def\@tempa##1 ##2 ##3\@nil{##1 ##2}% |
| 665 |
% \end{macrocode} |
| 666 |
% |
| 667 |
% \begin{macrocode} |
| 668 |
\ifx#1\snapx@application |
| 669 |
\@xp\xdef\csname rqv@#3#1\endcsname{\@tempa#4 v?.? ? \relax\@nil}% |
| 670 |
\else |
| 671 |
\xdef\rqv@list{\rqv@list{#3#1}}% |
| 672 |
\@xp\xdef\csname rqv@#3#1\endcsname{\@tempa#4 v?.? ? \relax\@nil}% |
| 673 |
\snap@intest{#3}{#1}% |
| 674 |
\ifx#1\snapx@format \snap@check{#3.fmt}\else |
| 675 |
% \end{macrocode} |
| 676 |
% Test if current file is \fn{snapshot.sty}. Need to pre-expand the |
| 677 |
% extension part to ensure the test is correct. |
| 678 |
% \begin{macrocode} |
| 679 |
\edef\@tempa{\@nx\string@equal{snapshot.sty}{#3#1}}% |
| 680 |
\if\@tempa \snap@selfcheck \fi |
| 681 |
\fi |
| 682 |
\fi |
| 683 |
\fi |
| 684 |
\futurelet\@let@token\snap@branch |
| 685 |
} |
| 686 |
|
| 687 |
\@onlypreamble\snap@store@b |
| 688 |
% \end{macrocode} |
| 689 |
% \end{macro} |
| 690 |
% |
| 691 |
% \begin{macro}{\snap@write} |
| 692 |
% Default setup is geared to write the dependency list to a \fn{.dep} |
| 693 |
% file. The option \opt{log} means write it to the \tex/ log instead. |
| 694 |
% \begin{macrocode} |
| 695 |
\def\snap@write{\immediate\write\snap@out} |
| 696 |
\let\snap@out\sixt@@n % fallback, probably never used |
| 697 |
% \end{macrocode} |
| 698 |
% \end{macro} |
| 699 |
% |
| 700 |
% \subsection{Package options} |
| 701 |
% |
| 702 |
% \begin{macrocode} |
| 703 |
\DeclareOption{dep}{% |
| 704 |
\def\snap@write{\immediate\write\snap@out}% |
| 705 |
} |
| 706 |
% \end{macrocode} |
| 707 |
% |
| 708 |
% \begin{macrocode} |
| 709 |
\DeclareOption{log}{% |
| 710 |
\let\snap@write\typeout |
| 711 |
} |
| 712 |
% \end{macrocode} |
| 713 |
% |
| 714 |
% The purpose of the `test' option is to support a separate testing |
| 715 |
% procedure for resolving file names and pre-checking version |
| 716 |
% numbers. See \secref{test} for more information. |
| 717 |
% \begin{macrocode} |
| 718 |
\let\snap@intest=\@gobbletwo |
| 719 |
\DeclareOption{test}{\def\snap@intest{True}} |
| 720 |
% \end{macrocode} |
| 721 |
% |
| 722 |
% For each font used by a document, we would like to list the |
| 723 |
% \fn{.tfm} file name and checksum. If \tex/ provided a |
| 724 |
% \cn{fontchecksum} primitive similar to \cn{fontname} that could be |
| 725 |
% used to get the checksum of any font, it would just about be |
| 726 |
% feasible to do this entirely from within \latex/. As a partial |
| 727 |
% solution we could at least generate the list of font file names, to |
| 728 |
% make it easier for an external utility to add the checksums. |
| 729 |
% |
| 730 |
% In practice, extracting font names and checksums from the \fn{.dvi} |
| 731 |
% file will probably work well enough, leaving no work to be done by |
| 732 |
% the \pkg{snapshot} package in this area. But theoretically speaking |
| 733 |
% the output of a document could be affected by font metric files |
| 734 |
% that are loaded during \latex/ processing but that do not show up |
| 735 |
% in the \fn{.dvi} file. |
| 736 |
% \begin{macrocode} |
| 737 |
\DeclareOption{tfm}{% |
| 738 |
\typeout{Option 'tfm' not implemented yet [1999/09/23]}% |
| 739 |
} |
| 740 |
% \end{macrocode} |
| 741 |
% |
| 742 |
% \subsubsection{Warnings and errors} |
| 743 |
% \begin{macro}{\snap@mismatch@warning} |
| 744 |
% \begin{macro}{\snap@mismatch} |
| 745 |
% \begin{macrocode} |
| 746 |
\def\snap@mismatch@warning#1#2#3{\PackageWarningNoLine{#1}{#2}} |
| 747 |
\def\snap@mismatch{\snap@mismatch@warning} |
| 748 |
% \end{macrocode} |
| 749 |
% \end{macro} |
| 750 |
% \end{macro} |
| 751 |
% |
| 752 |
% \begin{macrocode} |
| 753 |
\DeclareOption{error}{% |
| 754 |
\def\snap@mismatch{\PackageError}% |
| 755 |
\def\snap@selfcheck{\snap@selfcheck@a}% |
| 756 |
\ifx\snap@select\@empty \let\snap@select\snap@select@all \fi |
| 757 |
} |
| 758 |
% \end{macrocode} |
| 759 |
% |
| 760 |
% \begin{macrocode} |
| 761 |
\DeclareOption{warning}{% |
| 762 |
\def\snap@mismatch{\snap@mismatch@warning}% |
| 763 |
\def\snap@selfcheck{\snap@selfcheck@a}% |
| 764 |
\ifx\snap@select\@empty \let\snap@select\snap@select@all \fi |
| 765 |
} |
| 766 |
% \end{macrocode} |
| 767 |
% |
| 768 |
% |
| 769 |
% \begin{macro}{\snap@select@all} |
| 770 |
% \begin{macro}{\snap@select} |
| 771 |
% Because the exact form of the version number is not mandated by |
| 772 |
% \LaTeX{}, just take the first two ``words'' delimited by spaces. |
| 773 |
% And take a little extra care to properly handle multiple spaces |
| 774 |
% between the words. |
| 775 |
% \begin{macrocode} |
| 776 |
\def\snap@select@all#1#2 #3#4 #5\@nil{#1#2 #3#4} |
| 777 |
\let\snap@select\@empty |
| 778 |
% \end{macrocode} |
| 779 |
% \end{macro} |
| 780 |
% \end{macro} |
| 781 |
% |
| 782 |
% \begin{macro}{\snap@seldate} |
| 783 |
% \begin{macro}{\snap@selversion} |
| 784 |
% \begin{macro}{\snap@selmajor} |
| 785 |
% If the naming conventions seem a little peculiar here, it's because |
| 786 |
% I had to add some pieces later that I didn't think of initially, |
| 787 |
% and I wanted to minimize the chances of compatibility problems for |
| 788 |
% client packages [mjd,2002-11-04]. |
| 789 |
% \begin{macrocode} |
| 790 |
\def\snap@seldate#1#2 #3\@nil{#1#2}% |
| 791 |
\def\snap@selversion#1#2 #3{\snap@select@version #3}% |
| 792 |
\def\snap@selmajor#1#2 #3{\snap@select@major #3}% |
| 793 |
% \end{macrocode} |
| 794 |
% \end{macro} |
| 795 |
% \end{macro} |
| 796 |
% \end{macro} |
| 797 |
% |
| 798 |
% \begin{macrocode} |
| 799 |
\DeclareOption{date}{\let\snap@select=\snap@seldate} |
| 800 |
% \end{macrocode} |
| 801 |
% |
| 802 |
% \begin{macro}{\snap@select@version} |
| 803 |
% \begin{macrocode} |
| 804 |
\def\snap@select@version#1{% |
| 805 |
\ifodd 0#11 \@xp\snap@sva\@xp#1\else\@xp\snap@select@version\fi |
| 806 |
} |
| 807 |
\def\snap@sva#1.#2 #3\@nil{#1.#2} |
| 808 |
% \end{macrocode} |
| 809 |
% \end{macro} |
| 810 |
% |
| 811 |
% \begin{macro}{\snap@select@major} |
| 812 |
% \begin{macrocode} |
| 813 |
\def\snap@select@major#1{% |
| 814 |
\ifodd 0#11 \@xp\snap@svm\@xp#1\else\@xp\snap@select@major\fi |
| 815 |
} |
| 816 |
\def\snap@svm#1.#2\@nil{#1} |
| 817 |
% \end{macrocode} |
| 818 |
% \end{macro} |
| 819 |
% |
| 820 |
% \begin{macrocode} |
| 821 |
\DeclareOption{version}{\let\snap@select\snap@selversion} |
| 822 |
\DeclareOption{major-version}{\let\snap@select\snap@selmajor} |
| 823 |
% \end{macrocode} |
| 824 |
% |
| 825 |
% \begin{macrocode} |
| 826 |
\def\snap@bbinfo{01} |
| 827 |
\DeclareOption{bbinfo}{\def\snap@bbinfo{00}} |
| 828 |
% \end{macrocode} |
| 829 |
% |
| 830 |
% \begin{macro}{\snap@splitter} |
| 831 |
% Give this an inert definition, for the time being, until we are |
| 832 |
% ready to do the split. |
| 833 |
% \begin{macrocode} |
| 834 |
\let\snap@splitter=? |
| 835 |
\AtBeginDocument{% |
| 836 |
\xdef\@filelist{\@filelist\snap@splitter}% |
| 837 |
} |
| 838 |
% \end{macrocode} |
| 839 |
% \end{macro} |
| 840 |
% |
| 841 |
% \begin{macro}{\snap@selfcheck} |
| 842 |
% \begin{macrocode} |
| 843 |
\let\snap@selfcheck\@empty |
| 844 |
\let\snap@selfcheck@a\@empty |
| 845 |
% \end{macrocode} |
| 846 |
% \end{macro} |
| 847 |
% |
| 848 |
% The \opt{self-warning} option would normally be used in conjunction |
| 849 |
% with the \opt{error} option. |
| 850 |
% \begin{macrocode} |
| 851 |
\DeclareOption{self-warning}{% |
| 852 |
\def\snap@selfcheck{% |
| 853 |
\begingroup |
| 854 |
\def\snap@mismatch{\snap@mismatch@warning}% |
| 855 |
\snap@selfcheck@a |
| 856 |
\endgroup |
| 857 |
} |
| 858 |
} |
| 859 |
% \end{macrocode} |
| 860 |
% |
| 861 |
% \begin{macrocode} |
| 862 |
\ExecuteOptions{warning} |
| 863 |
\ProcessOptions\relax |
| 864 |
% \end{macrocode} |
| 865 |
% |
| 866 |
% \begin{macro}{\snap@restore@extensions} |
| 867 |
% We need the following patch to make up for the fact that |
| 868 |
% \cs{@pkgextension} and \cs{@clsextension} are marked in the \latex/ |
| 869 |
% kernel as \qq{only preamble}. |
| 870 |
% \begin{macrocode} |
| 871 |
\edef\snap@restore@extensions{% |
| 872 |
\def\@nx\@pkgextension{\@pkgextension}% |
| 873 |
\def\@nx\@clsextension{\@clsextension}% |
| 874 |
} |
| 875 |
% \end{macrocode} |
| 876 |
% \end{macro} |
| 877 |
% |
| 878 |
% \begin{macro}{\snap@pad} |
| 879 |
% Pad filename strings out to 8+3 length so that the list will look |
| 880 |
% pretty. |
| 881 |
% \begin{macrocode} |
| 882 |
\def\snap@pad#1#2#3#4#5#6#7#8#9{\snap@pad@a{#1#2#3#4#5#6#7#8#9}} |
| 883 |
\def\snap@pad@a#1#2#3#4#5\@nil{\snap@pad@b#1#2#3#4\space\@nil} |
| 884 |
\def\snap@pad@b#1\space#2\@nil#3{\def#3{#2}} |
| 885 |
% \end{macrocode} |
| 886 |
% \end{macro} |
| 887 |
% |
| 888 |
% \begin{macro}{\snap@trim@version} |
| 889 |
% First stage: discard leading spaces before the first and second |
| 890 |
% nonspace strings in the argument. Take the first nonspace string as |
| 891 |
% the date. Since we only do equal/not-equal testing on dates, it |
| 892 |
% does not seem essential to test if it is really a valid date string |
| 893 |
% or not (yyyy/mm/dd). |
| 894 |
% \begin{macrocode} |
| 895 |
\def\snap@trim@version#1#2 #3{#1#2 \snap@trim@b #3} |
| 896 |
% \end{macrocode} |
| 897 |
% Second stage: Scan for a version number. In order to handle some |
| 898 |
% idiosyncratic cases, such as url.sty version 1.4, we can't simply |
| 899 |
% take the second nonspace string as the version number but need to |
| 900 |
% look for a leading digit. |
| 901 |
% \begin{macrocode} |
| 902 |
\def\snap@trim@b#1{\ifodd 0#11 v#1\@xp\snap@trim@c\fi \snap@trim@b} |
| 903 |
% \end{macrocode} |
| 904 |
% Arg 1 here is \cs{snap@trim@b}, which we just need to discard. |
| 905 |
% \begin{macrocode} |
| 906 |
\def\snap@trim@c#1#2 #3\@nil{#2} |
| 907 |
% \end{macrocode} |
| 908 |
% \end{macro} |
| 909 |
% |
| 910 |
% \begin{macrocode} |
| 911 |
\let\rqv@list=\@empty |
| 912 |
% \end{macrocode} |
| 913 |
% |
| 914 |
% If \verb'\fmtname.fmt' is not already in the file list, add it. |
| 915 |
% \begin{macrocode} |
| 916 |
\edef\@tempc#1\fmtname{#1\fmtname}\@tempc |
| 917 |
\def\@tempa#1,\fmtname.fmt,#2#3\@nil{#2} |
| 918 |
\edef\@tempb{\@nx\@tempa,\@filelist,\fmtname.fmt,} |
| 919 |
|
| 920 |
\if ?\@tempb?\@nil |
| 921 |
\edef\@filelist{\fmtname.fmt,\@filelist}% |
| 922 |
\def\@tempc{LaTeX2e}% |
| 923 |
\@xp\edef\csname ver@\fmtname.fmt\endcsname{% |
| 924 |
\fmtversion\space |
| 925 |
v\ifx\@tempc\fmtname 2.e\else ?.?\fi |
| 926 |
}% |
| 927 |
\fi |
| 928 |
% \end{macrocode} |
| 929 |
% Ensure that files get recorded. |
| 930 |
% \begin{macrocode} |
| 931 |
\listfiles |
| 932 |
% \end{macrocode} |
| 933 |
% |
| 934 |
% \begin{macro}{\snap@doit} |
| 935 |
% \begin{macrocode} |
| 936 |
\def\snap@doit#1{% |
| 937 |
\begingroup |
| 938 |
\ifx\delimiter#1\delimiter \else |
| 939 |
\filename@parse{#1}% |
| 940 |
\let\@tempd\@empty |
| 941 |
\ifx\filename@ext\relax |
| 942 |
\def\@tempa{file}\def\@tempb{~~~}% |
| 943 |
\else\ifx\filename@ext\@pkgextension |
| 944 |
\def\@tempa{package}\let\@tempb\@empty |
| 945 |
\else\ifx\filename@ext\@clsextension |
| 946 |
\def\@tempa{class}\def\@tempb{~~}% |
| 947 |
\else\ifx\filename@ext\@fmtextension |
| 948 |
\def\@tempa{format}\def\@tempb{~}% |
| 949 |
\else\ifx\filename@ext\@tfmextension |
| 950 |
\def\@tempa{tfm}\def\@tempb{~~~~}% |
| 951 |
\else |
| 952 |
\def\@tempa{file}% |
| 953 |
\edef\@tempd{.\filename@ext}% |
| 954 |
\def\@tempb{~~~}% |
| 955 |
\fi\fi\fi\fi\fi |
| 956 |
\@xp\let\@xp\@tempe |
| 957 |
\csname ver@\filename@base % |
| 958 |
\ifx\filename@ext\relax\else.\filename@ext\fi\endcsname |
| 959 |
\ifx\@tempe\@empty \let\@tempe\relax \fi |
| 960 |
\edef\@tempe{% |
| 961 |
\ifx\@tempe\relax 0000/00/00 v0.0% |
| 962 |
\else |
| 963 |
\@xp\@xp\@xp\snap@trim@version\@xp\@tempe\space v0.0 v0.0 \@nil |
| 964 |
\fi |
| 965 |
}% |
| 966 |
\edef\@tempc{\filename@area\filename@base\@tempd}% full file name |
| 967 |
\@xp\snap@pad\@tempc\space~~~~~~~~~~~~~~~~\@nil\@tempd |
| 968 |
\let~\space |
| 969 |
\snap@write{\space\space *{\@tempa}\@tempb{\@tempc}\@tempd{\@tempe}}% |
| 970 |
\fi |
| 971 |
\aftergroup\snap@doit |
| 972 |
\endgroup |
| 973 |
} |
| 974 |
% \end{macrocode} |
| 975 |
% \end{macro} |
| 976 |
% |
| 977 |
% \begin{macro}{\snap@bracify} |
| 978 |
% \begin{macrocode} |
| 979 |
\def\snap@bracify#1#2,{% |
| 980 |
\ifx\@empty#1\expandafter\@gobble\else {#1#2}\fi \snap@bracify |
| 981 |
} |
| 982 |
% \end{macrocode} |
| 983 |
% \end{macro} |
| 984 |
% |
| 985 |
% \begin{macro}{\snap@splitter@a} |
| 986 |
% \begin{macrocode} |
| 987 |
\def\snap@splitter@a{% |
| 988 |
\iffalse{{\fi }}% close current file name, end definition |
| 989 |
\xdef\specific@files{% |
| 990 |
\iffalse}\fi |
| 991 |
\specific@files |
| 992 |
\expandafter\@gobble\string % discard one closing brace |
| 993 |
} |
| 994 |
% \end{macrocode} |
| 995 |
% \end{macro} |
| 996 |
% |
| 997 |
% \begin{macro}{\snap@fdcheck} |
| 998 |
% \begin{macrocode} |
| 999 |
\def\snap@fdcheck#1{% |
| 1000 |
\ifx\delimiter#1% |
| 1001 |
\@xp\@gobble |
| 1002 |
\else |
| 1003 |
\snap@fda#1\@empty.fd\@empty ?\@nil |
| 1004 |
\fi |
| 1005 |
\snap@fdcheck |
| 1006 |
} |
| 1007 |
|
| 1008 |
\def\snap@fda#1.fd\@empty#2#3\@nil{% |
| 1009 |
\if ?#2% |
| 1010 |
\xdef\specific@files{\specific@files {#1}}% |
| 1011 |
\else |
| 1012 |
\xdef\general@files{\general@files {#1.fd}}% |
| 1013 |
\fi |
| 1014 |
} |
| 1015 |
% \end{macrocode} |
| 1016 |
% \end{macro} |
| 1017 |
% |
| 1018 |
% \begin{macro}{\general@files} |
| 1019 |
% \begin{macro}{\specific@files} |
| 1020 |
% \begin{macrocode} |
| 1021 |
\let\general@files\@empty |
| 1022 |
\let\specific@files\@empty |
| 1023 |
% \end{macrocode} |
| 1024 |
% \end{macro} |
| 1025 |
% \end{macro} |
| 1026 |
% |
| 1027 |
% \begin{macro}{\SpecialInput} |
| 1028 |
% The \cn{SpecialInput} command is related to the \opt{packages-only} |
| 1029 |
% option. Apart from some ad hoc handling for \fn{.fd} files that get |
| 1030 |
% loaded on demand, all files that are input after |
| 1031 |
% \verb'\begin{document}' are put into the specific-files list, and |
| 1032 |
% all files before \verb'\begin{document}' go into the general-files |
| 1033 |
% (packages-only) list. If there is a macro file for a book (say), |
| 1034 |
% that contains definitions specific to that book, and that is loaded |
| 1035 |
% in the preamble, loading it with \cs{SpecialInput} will cause it to |
| 1036 |
% go in the specific-files list. |
| 1037 |
% \begin{macrocode} |
| 1038 |
\newcommand{\SpecialInput}[1]{% |
| 1039 |
\xdef\specific@files{\specific@files{#1}}% |
| 1040 |
\@@input#1\relax |
| 1041 |
} |
| 1042 |
% \end{macrocode} |
| 1043 |
% \end{macro} |
| 1044 |
% |
| 1045 |
% \begin{macro}{\@dofilelist} |
| 1046 |
% Our definition of \cs{@dofilelist} does not retain much resemblance |
| 1047 |
% to the original in the \LaTeX{} kernel. |
| 1048 |
% \begin{macrocode} |
| 1049 |
\def\@dofilelist{% |
| 1050 |
\snap@restore@extensions |
| 1051 |
\xdef\general@files{\@xp\snap@bracify \@filelist \@empty,\@empty,}% |
| 1052 |
\let\snap@splitter\snap@splitter@a |
| 1053 |
\xdef\general@files{\general@files}% |
| 1054 |
\let\@tempa\specific@files |
| 1055 |
\global\let\specific@files\@empty |
| 1056 |
\@xp\snap@fdcheck\@tempa{\delimiter}% |
| 1057 |
\ifx\rqv@list\@empty \else |
| 1058 |
\rqv@compare@lists |
| 1059 |
\fi |
| 1060 |
\ifx\snap@write\typeout \else |
| 1061 |
\newwrite\snap@out |
| 1062 |
\immediate\openout\snap@out=\jobname.dep \relax |
| 1063 |
\fi |
| 1064 |
\snap@write{\string\RequireVersions\@charlb}% |
| 1065 |
\snap@write{\space\space *{application}% |
| 1066 |
\snapshotApplication |
| 1067 |
}% |
| 1068 |
\@xp\snap@doit\general@files{\delimiter\aftergroup\@gobble\@gobble}% |
| 1069 |
\ifx\specific@files\@empty \else |
| 1070 |
\snap@specific |
| 1071 |
\fi |
| 1072 |
\snap@write{\@charrb}% |
| 1073 |
\ifx\snap@write\typeout \else |
| 1074 |
\immediate\closeout\snap@out |
| 1075 |
\typeout{Dependency list written on \jobname.dep.}% |
| 1076 |
\fi |
| 1077 |
} |
| 1078 |
% \end{macrocode} |
| 1079 |
% \end{macro} |
| 1080 |
% |
| 1081 |
% \begin{macro}{\snap@specific} |
| 1082 |
% \begin{macrocode} |
| 1083 |
\def\snap@specific{% |
| 1084 |
\snap@write{ \space *{-------}{Document-specific files:}{----}}% |
| 1085 |
\@xp\snap@doit\specific@files{\delimiter\aftergroup\@gobble\@gobble}% |
| 1086 |
} |
| 1087 |
% \end{macrocode} |
| 1088 |
% \end{macro} |
| 1089 |
% |
| 1090 |
% \begin{macro}{\rqv@condense} |
| 1091 |
% The \cs{rqv@compare@lists} function checks to see if any files |
| 1092 |
% are found only in the RequireVersions list or only in the |
| 1093 |
% \cs{general@files} list. |
| 1094 |
% \begin{macrocode} |
| 1095 |
\def\rqv@condense#1{% |
| 1096 |
\@xp\ifx\csname ver@#1\endcsname\N \else |
| 1097 |
\edef\L{\L{#1}}% |
| 1098 |
\@xp\let\csname ver@#1\endcsname=\N |
| 1099 |
\fi |
| 1100 |
\rqv@condense |
| 1101 |
} |
| 1102 |
|
| 1103 |
\def\rqv@condend{\endcsname ?\fi |
| 1104 |
\@xp\@xp\@xp\@gobbletwo\csname @xp\iftrue} |
| 1105 |
% \end{macrocode} |
| 1106 |
% \end{macro} |
| 1107 |
% |
| 1108 |
% \begin{macro}{\rqv@overloaded} |
| 1109 |
% \begin{macrocode} |
| 1110 |
\def\rqv@overloaded#1{% |
| 1111 |
\snap@mismatch{snapshot}{^^J% |
| 1112 |
File #1 loaded though not in \noexpand\RequireVersions list% |
| 1113 |
}\@ehc |
| 1114 |
} |
| 1115 |
% \end{macrocode} |
| 1116 |
% \end{macro} |
| 1117 |
% |
| 1118 |
% \begin{macro}{\rqv@notloaded} |
| 1119 |
% \begin{macrocode} |
| 1120 |
\def\rqv@notloaded#1{% |
| 1121 |
\snap@mismatch{snapshot}{^^J% |
| 1122 |
File #1 [\csname rqv@#1\endcsname] required but not loaded% |
| 1123 |
}\@ehc |
| 1124 |
} |
| 1125 |
% \end{macrocode} |
| 1126 |
% \end{macro} |
| 1127 |
% |
| 1128 |
% \begin{macro}{\rqv@set} |
| 1129 |
% \begin{macro}{\rqv@test} |
| 1130 |
% \begin{macrocode} |
| 1131 |
\def\rqv@set#1{\@xp\let\csname ver@#1\endcsname\N \rqv@set} |
| 1132 |
\def\rqv@test#1{\csname ver@#1\endcsname{#1}\rqv@test} |
| 1133 |
% \end{macrocode} |
| 1134 |
% \end{macro} |
| 1135 |
% \end{macro} |
| 1136 |
% |
| 1137 |
% \begin{macro}{\rqv@compare@lists} |
| 1138 |
% \begin{macrocode} |
| 1139 |
\def\rqv@compare@lists{% |
| 1140 |
\begingroup |
| 1141 |
% \end{macrocode} |
| 1142 |
% Clear up duplicate file names (just in case) to avoid redundant |
| 1143 |
% warning messages. This should seldom be necessary in practice. |
| 1144 |
% \begin{macrocode} |
| 1145 |
\def\N{1}% |
| 1146 |
\let\L\@empty |
| 1147 |
\@xp\rqv@condense\rqv@list\rqv@condend |
| 1148 |
\global\let\rqv@list=\L |
| 1149 |
\def\N{2}% |
| 1150 |
\let\L\@empty |
| 1151 |
\@xp\rqv@condense\general@files\rqv@condend |
| 1152 |
\global\let\general@files=\L |
| 1153 |
% \end{macrocode} |
| 1154 |
% Let's make a shorthand for the code that terminates our recursion. |
| 1155 |
% \begin{macrocode} |
| 1156 |
\def\T{\@firstoftwo{\endcsname\@empty\@gobbletwo}}% |
| 1157 |
% \end{macrocode} |
| 1158 |
% Set all the loaded general files to an error function. |
| 1159 |
% \begin{macrocode} |
| 1160 |
\let\N\rqv@overloaded \@xp\rqv@set\general@files \T |
| 1161 |
% \end{macrocode} |
| 1162 |
% Set all the required files to an ignore function. |
| 1163 |
% \begin{macrocode} |
| 1164 |
\let\N\@gobble |
| 1165 |
\@xp\rqv@set\rqv@list \T |
| 1166 |
% \end{macrocode} |
| 1167 |
% Execute all the general files. |
| 1168 |
% \begin{macrocode} |
| 1169 |
\@xp\rqv@test\general@files{\endcsname\csname @gobbletwo}% |
| 1170 |
% \end{macrocode} |
| 1171 |
% And now do essentially the same thing in the reverse direction. |
| 1172 |
% \begin{macrocode} |
| 1173 |
\let\N\rqv@notloaded |
| 1174 |
\@xp\rqv@set\rqv@list \T |
| 1175 |
\let\N\@gobble |
| 1176 |
\@xp\rqv@set\general@files \T |
| 1177 |
\@xp\rqv@test\rqv@list{\endcsname\csname @gobbletwo}% |
| 1178 |
\endgroup |
| 1179 |
} |
| 1180 |
% \end{macrocode} |
| 1181 |
% \end{macro} |
| 1182 |
% |
| 1183 |
% Compensate for a bug in old versions of \fn{amsgen.sty}. This is a |
| 1184 |
% little tricky. |
| 1185 |
% |
| 1186 |
% Old version: \cs{ver@amsgen}=1996/10/29 v1.2b |
| 1187 |
% |
| 1188 |
% New version: \cs{[email protected]}=1999/11/30 v2.0 |
| 1189 |
% \begin{macrocode} |
| 1190 |
%\@namedef{[email protected]}{1996/10/29 v1.2b} |
| 1191 |
\AtBeginDocument{% |
| 1192 |
\@ifundefined{ver@amsgen}{}{% |
| 1193 |
\@xp\let\csname [email protected]\@xp\endcsname |
| 1194 |
\csname ver@amsgen\endcsname |
| 1195 |
}% |
| 1196 |
} |
| 1197 |
% \end{macrocode} |
| 1198 |
% |
| 1199 |
% \begin{macro}{\ProvidesFile} |
| 1200 |
% Because \cs{ProvidesFile} is used in \fn{.fd} files which are |
| 1201 |
% normally read with special catcodes, there tend to |
| 1202 |
% be problems with whitespace characters being erroneously lost from |
| 1203 |
% the second argument. Since we have to put in a \cs{snap@check} call |
| 1204 |
% anyway, while we're at it let's fix a bug of this type that |
| 1205 |
% affected some older versions of \latex/. |
| 1206 |
% \begin{macrocode} |
| 1207 |
\def\ProvidesFile#1{% |
| 1208 |
\def\snap@checker{\snap@check{#1}}% |
| 1209 |
\begingroup |
| 1210 |
\aftergroup\snap@checker |
| 1211 |
\catcode`\ 10 |
| 1212 |
% \end{macrocode} |
| 1213 |
% Added guards from 2001/06/01 version of \latex/. These are |
| 1214 |
% necessary because, for example, \pkg{inputenc} sets |
| 1215 |
% \cs{endlinechar} to a large (nonvalid character) value when |
| 1216 |
% reading input encoding files. The guards prevent an ``invalid |
| 1217 |
% character'' error. |
| 1218 |
% \begin{macrocode} |
| 1219 |
\ifnum\endlinechar < 256 |
| 1220 |
\ifnum \endlinechar>\m@ne |
| 1221 |
\catcode\endlinechar 10 |
| 1222 |
\fi |
| 1223 |
\fi |
| 1224 |
\@makeother\/% |
| 1225 |
\@makeother\&% |
| 1226 |
\kernel@ifnextchar[{\snap@providesfile{#1}}{\snap@providesfile{#1}[]}% |
| 1227 |
} |
| 1228 |
% \end{macrocode} |
| 1229 |
% \end{macro} |
| 1230 |
% |
| 1231 |
% \begin{macro}{\snap@graphic@test} |
| 1232 |
% Normally the string found in the second arg of \cs{ProvidesFile} |
| 1233 |
% (for a nongraphics file) would begin with the usual date string. |
| 1234 |
% The \cs{includegraphics} command, however, begins the second arg |
| 1235 |
% with \texttt{Graphic file} instead. This test therefore just checks |
| 1236 |
% if the first two letters are \texttt{Gr}; this is enough, |
| 1237 |
% ordinarily, for us to conclude that we are dealing with a graphic |
| 1238 |
% file. |
| 1239 |
% \begin{macrocode} |
| 1240 |
\def\snap@graphic@test#1#2#3\@nil{r\if G#1#2\else X\fi} |
| 1241 |
% \end{macrocode} |
| 1242 |
% \end{macro} |
| 1243 |
% |
| 1244 |
% \begin{macro}{\snap@providesfile} |
| 1245 |
% \begin{macrocode} |
| 1246 |
\def\snap@providesfile#1[#2]{% |
| 1247 |
\wlog{File: #1 #2}% |
| 1248 |
% \end{macrocode} |
| 1249 |
% Adopt a suggestion made by user egrep on the \TeX\ stack exchange |
| 1250 |
% (\url{https://tex.stackexchange.com/questions/508985}) but |
| 1251 |
% without the use of the \cs{expanded} extension. This makes it |
| 1252 |
% more likely that \pkg{snapshot} can deal with macros inside the |
| 1253 |
% optional arguments of \cs{Provides...} commands. |
| 1254 |
% \begin{macrocode} |
| 1255 |
\edef\@tempa{#2}% |
| 1256 |
\if\@xp\snap@graphic@test\@tempa @@\@nil |
| 1257 |
\snap@record@graphic#1\relax #2 (type ??)\@nil |
| 1258 |
\else |
| 1259 |
\@xp\xdef\csname ver@#1\endcsname{#2}% |
| 1260 |
\fi |
| 1261 |
\endgroup |
| 1262 |
} |
| 1263 |
% \end{macrocode} |
| 1264 |
% \end{macro} |
| 1265 |
% |
| 1266 |
% This is what \cn{includegraphics} does to record graphic file |
| 1267 |
% information. |
| 1268 |
%\begin{verbatim} |
| 1269 |
%\@providesfile #1[#2]-> |
| 1270 |
%\wlog {File: #1 #2}\expandafter \xdef \csname ver@#1\endcsname {#2} |
| 1271 |
%\endgroup |
| 1272 |
%#1<-\Gin@base \Gin@ext |
| 1273 |
%#2<-Graphic file (type eps) |
| 1274 |
%\end{verbatim} |
| 1275 |
% |
| 1276 |
% \begin{macro}{\snap@record@graphic} |
| 1277 |
% Check the graphics info. |
| 1278 |
% \begin{macrocode} |
| 1279 |
\def\snap@record@graphic#1\relax #2(type #3)#4\@nil{% |
| 1280 |
\expandafter\xdef\csname ver@#1\endcsname{% |
| 1281 |
Graphic% |
| 1282 |
\if\snap@bbinfo :bb=\Gin@llx/\Gin@lly/\Gin@urx/\Gin@ury\fi |
| 1283 |
\space v0.0% |
| 1284 |
}% |
| 1285 |
} |
| 1286 |
% \end{macrocode} |
| 1287 |
% \end{macro} |
| 1288 |
% |
| 1289 |
% \begin{macro}{\@pr@videpackage} |
| 1290 |
% \begin{macrocode} |
| 1291 |
\def\@pr@videpackage [#1]{% |
| 1292 |
\expandafter\xdef\csname ver@\@currname.\@currext\endcsname{#1}% |
| 1293 |
\ifx\@currext\@clsextension |
| 1294 |
\typeout{Document Class: \@gtempa\space#1}% |
| 1295 |
\else |
| 1296 |
\wlog{Package: \@gtempa\space#1}% |
| 1297 |
\fi |
| 1298 |
\snap@check{\@currname.\@currext}% |
| 1299 |
} |
| 1300 |
% \end{macrocode} |
| 1301 |
% \end{macro} |
| 1302 |
% |
| 1303 |
% \begin{macro}{\snap@selfcheck@a} |
| 1304 |
% \begin{macrocode} |
| 1305 |
\def\snap@selfcheck@a{\snap@check{snapshot.sty}} |
| 1306 |
% \end{macrocode} |
| 1307 |
% \end{macro} |
| 1308 |
% |
| 1309 |
% \begin{macro}{\@nofmt} |
| 1310 |
% \begin{macrocode} |
| 1311 |
\def\@nofmt#1.fmt.#2 {#1 } |
| 1312 |
% \end{macrocode} |
| 1313 |
% \end{macro} |
| 1314 |
% |
| 1315 |
% \begin{macro}{\snap@mismatch@a} |
| 1316 |
% \begin{macrocode} |
| 1317 |
\def\snap@mismatch@a#1#2#3{% |
| 1318 |
\snap@mismatch{snapshot}{^^J% |
| 1319 |
\space\space Required version #2 of \@nofmt#1.fmt. and^^J% |
| 1320 |
\space\space provided version #3 do not match% |
| 1321 |
}\@ehc |
| 1322 |
} |
| 1323 |
% \end{macrocode} |
| 1324 |
% \end{macro} |
| 1325 |
% |
| 1326 |
% \begin{macro}{\snap@compare@versions} |
| 1327 |
% When comparing \cs{[email protected]} (information from a previous |
| 1328 |
% \latex/ run) with \cs{[email protected]} (information from current run), |
| 1329 |
% we first call \cs{snap@trim@version} on the latter to clear away |
| 1330 |
% any idiosyncrasies in the contents. |
| 1331 |
% \begin{macrocode} |
| 1332 |
\def\snap@compare@versions#1{% |
| 1333 |
\begingroup |
| 1334 |
\@ifundefined{rqv@#1}{}{% |
| 1335 |
\edef\0{\csname rqv@#1\endcsname}% |
| 1336 |
\edef\1{\csname ver@#1\endcsname}% |
| 1337 |
\edef\1{\@xp\snap@trim@version\1 v0.0 v0.0 \@nil}% |
| 1338 |
\edef\@tempa{\@xp\snap@select\0 v0.0 v0.0 \@nil}% |
| 1339 |
\edef\@tempb{\@xp\snap@select\1 v0.0 v0.0 \@nil}% |
| 1340 |
\ifx\@tempa\@tempb \else |
| 1341 |
\edef\@tempd{\@nx\snap@mismatch@a{#1}{\@tempa}{\@tempb}}% |
| 1342 |
\@xp\@tempd |
| 1343 |
\fi |
| 1344 |
}% |
| 1345 |
\endgroup |
| 1346 |
% \end{macrocode} |
| 1347 |
% When the \opt{test} option is in effect, jump out of the current |
| 1348 |
% file instead of continuing. |
| 1349 |
% \begin{macrocode} |
| 1350 |
\snap@test@abort |
| 1351 |
} |
| 1352 |
% \end{macrocode} |
| 1353 |
% \end{macro} |
| 1354 |
% |
| 1355 |
% \begin{macro}{\snap@test@abort} |
| 1356 |
% \begin{macrocode} |
| 1357 |
\let\snap@test@abort=\@empty |
| 1358 |
% \end{macrocode} |
| 1359 |
% \end{macro} |
| 1360 |
% |
| 1361 |
% \section{Compatibility} |
| 1362 |
% |
| 1363 |
% Suppose that I have a \lat/ document containing a |
| 1364 |
% \cs{RequireVersions} statement generated by \pkg{snapshot} and I |
| 1365 |
% send this to my colleague who, we believe, has a \lat/ setup that |
| 1366 |
% is for our purposes identical. Suppose that our belief is erroneous |
| 1367 |
% in the following way: My colleague has a newer version of |
| 1368 |
% \pkg{snapshot} and a newer version of one of the affected files. |
| 1369 |
% |
| 1370 |
% Here is what we \strong{don't} want to happen: That the differing |
| 1371 |
% version of snapshot would cause the other differing file to be |
| 1372 |
% accepted without demur. |
| 1373 |
% |
| 1374 |
% Conversely, if it is I who have the newer version of |
| 1375 |
% \pkg{snapshot}, the main concern is that some difference in the |
| 1376 |
% contents of the \cs{RequireVersions} statement would lead to an |
| 1377 |
% error when my colleague attempts to process the document. |
| 1378 |
% |
| 1379 |
% \section{In conclusion} |
| 1380 |
% |
| 1381 |
% \begin{macrocode} |
| 1382 |
\ifx\snap@select\@empty |
| 1383 |
\let\snap@compare@versions\@gobble |
| 1384 |
\let\snap@check\@gobble |
| 1385 |
\fi |
| 1386 |
% \end{macrocode} |
| 1387 |
% |
| 1388 |
% Fallback for a command that is sometimes used in AMS journal |
| 1389 |
% production. |
| 1390 |
% \begin{macrocode} |
| 1391 |
\providecommand{\controldates}[1]{} |
| 1392 |
% \end{macrocode} |
| 1393 |
% |
| 1394 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1395 |
% \section{And finally \dots}\label{test} |
| 1396 |
% |
| 1397 |
% If the embedded \cs{RequireVersions} |
| 1398 |
% data in a \lat/ document is extracted to a separate file, and |
| 1399 |
%\begin{verbatim} |
| 1400 |
%\RequirePackage[test]{snapshot} |
| 1401 |
%\end{verbatim} |
| 1402 |
% is added at the top, then the file can be run as a small separate |
| 1403 |
% \LaTeX{} job that will, among other things, produce in the log file |
| 1404 |
% a nice list of fully resolved file names\mdash sort of a limited, |
| 1405 |
% but system-independent variant of the \fn{kpsewhich} idea. |
| 1406 |
% \begin{macrocode} |
| 1407 |
\ifx\snap@intest\@gobbletwo \endinput \fi |
| 1408 |
% \end{macrocode} |
| 1409 |
% |
| 1410 |
% Some old, ill-behaved packages might throw in a \cs{makeatother} at |
| 1411 |
% the end which can cause problems for the next file that comes along |
| 1412 |
% when testing. |
| 1413 |
% \begin{macrocode} |
| 1414 |
\def\restore@some@catcodes{} |
| 1415 |
\def\save@some@catcodes{% |
| 1416 |
\edef\restore@some@catcodes{% |
| 1417 |
\catcode\number`\@=\number\catcode`\@ |
| 1418 |
\catcode\number`\"=\number\catcode`\" |
| 1419 |
\catcode\number`\^=\number\catcode`\^ |
| 1420 |
\catcode\number`\_=\number\catcode`\_ |
| 1421 |
\relax |
| 1422 |
}% |
| 1423 |
} |
| 1424 |
% \end{macrocode} |
| 1425 |
% |
| 1426 |
% Some typical calls of \cs{snap@intest}: |
| 1427 |
%\begin{verbatim} |
| 1428 |
% \snap@intest{LaTeX2e}{\snapx@format} |
| 1429 |
% \snap@intest{snapshot}{\snapx@package} |
| 1430 |
% \snap@intest{mcom-l}{\snapx@class} |
| 1431 |
% \snap@intest{amsmath}{\snapx@package} |
| 1432 |
% \snap@intest{umsa.fd}{\snapx@file} |
| 1433 |
% \snap@intest{pictex}{\snapx@file} |
| 1434 |
%\end{verbatim} |
| 1435 |
% |
| 1436 |
% The extant public versions of the following files (in the teTeX |
| 1437 |
% distribution, at least) are known to be problematic when we are |
| 1438 |
% trying to read a \cs{ProvidesWhatever} line from the top of the |
| 1439 |
% file: psfig.sty, pictex.sty, pictex.tex, epic.sty, amstex.sty, |
| 1440 |
% xy.tex. Either (a) they don't have a \cs{ProvidesWhatever} line at |
| 1441 |
% all, or (b) they include some code before the \cs{ProvidesWhatever} |
| 1442 |
% line that makes some assumption true in normal processing but false |
| 1443 |
% in snapshot-test processing. E.g., there is code in \fn{amstex.sty} |
| 1444 |
% that assumes \cs{documentstyle} or \cs{documentclass} was already |
| 1445 |
% executed and that the \cs{if@compatibility} switch got set |
| 1446 |
% accordingly. |
| 1447 |
% |
| 1448 |
% \begin{macro}{\snap@intest} |
| 1449 |
% \begin{macrocode} |
| 1450 |
\def\snap@intest#1#2{% |
| 1451 |
\message{^^J}% |
| 1452 |
\begingroup |
| 1453 |
\edef\0{#1#2}% |
| 1454 |
\def\9{latex209.def}% |
| 1455 |
\ifx\0\9\global\@compatibilitytrue \fi |
| 1456 |
\ifx#2\snapx@format |
| 1457 |
% \end{macrocode} |
| 1458 |
% If arg1 + arg2 = ``LaTeX2e.fmt'', the calling function |
| 1459 |
% \cs{snap@storeb} will run \cs{snap@check} separately. |
| 1460 |
% This is a crude way of making things work in that case without |
| 1461 |
% much extra trouble. |
| 1462 |
% \begin{macrocode} |
| 1463 |
\def\snap@test@abort{\endgroup}% |
| 1464 |
\else |
| 1465 |
\edef\N{% |
| 1466 |
\noexpand\snap@intest@b{#1#2}% |
| 1467 |
{#1}{\@xp\@gobble#2\@empty}% |
| 1468 |
{\csname rqv@#1#2\endcsname}}% |
| 1469 |
\expandafter\endgroup\N |
| 1470 |
\fi |
| 1471 |
} |
| 1472 |
% \end{macrocode} |
| 1473 |
% \end{macro} |
| 1474 |
% |
| 1475 |
% \begin{macro}{\snap@intest@b} |
| 1476 |
% \begin{macrocode} |
| 1477 |
\def\snap@intest@b#1#2#3#4{% |
| 1478 |
\def\@currname{#2}% |
| 1479 |
\def\@currext{#3}% |
| 1480 |
\begingroup |
| 1481 |
\lccode`\/=`\0\relax\lowercase{\endgroup |
| 1482 |
\ifnum\snap@seldate#4 00 0\@nil>\z@ |
| 1483 |
}% matches \lowercase |
| 1484 |
\save@some@catcodes |
| 1485 |
\@@input #1 \relax |
| 1486 |
\restore@some@catcodes |
| 1487 |
\else |
| 1488 |
\snap@specialtest{#1}{#4}% |
| 1489 |
\fi |
| 1490 |
} |
| 1491 |
% \end{macrocode} |
| 1492 |
% \end{macro} |
| 1493 |
% |
| 1494 |
% \begin{macro}{\snap@specialtest} |
| 1495 |
% \begin{macrocode} |
| 1496 |
\def\snap@specialtest#1#2{% |
| 1497 |
\fake@input{#1}% |
| 1498 |
} |
| 1499 |
% \end{macrocode} |
| 1500 |
% \end{macro} |
| 1501 |
% |
| 1502 |
% \begin{macro}{\fake@input} |
| 1503 |
% \begin{macrocode} |
| 1504 |
\def\fake@input#1{% |
| 1505 |
\begingroup |
| 1506 |
% Ensure that outer \foo or unmatched braces don't trip us up |
| 1507 |
\catcode`\\=12 |
| 1508 |
\catcode`\{=12 |
| 1509 |
\catcode`\}=12 |
| 1510 |
\endinput |
| 1511 |
% \end{macrocode} |
| 1512 |
% Note that these definitions of \cs{G} and \cs{?} are local, and |
| 1513 |
% recall that one-letter cs names don't use up hash table entries. |
| 1514 |
% \begin{macrocode} |
| 1515 |
\def\G{\@car\endgroup}% |
| 1516 |
\expandafter\futurelet\expandafter\?\expandafter\G\@@input#1 \relax\@nil |
| 1517 |
} |
| 1518 |
% \end{macrocode} |
| 1519 |
% \end{macro} |
| 1520 |
% |
| 1521 |
% \begin{macrocode} |
| 1522 |
\let\snap@test@abort=\endinput |
| 1523 |
\let\snap@selfcheck=\@empty |
| 1524 |
% \end{macrocode} |
| 1525 |
% |
| 1526 |
% \begin{macro}{\snap@finish} |
| 1527 |
% There's an extra close-brace left hanging around at the end, but I |
| 1528 |
% guess we don't care. |
| 1529 |
% \begin{macrocode} |
| 1530 |
\def\snap@finish{%% |
| 1531 |
\endgroup |
| 1532 |
\message{^^J}% |
| 1533 |
\def\X##1{##1,\X}% |
| 1534 |
\edef\@filelist{\@xp\X\rqv@list{\@gobbletwo}}% |
| 1535 |
\def\X##1,?{##1}\edef\@filelist{\@xp\X\@filelist ?}% |
| 1536 |
\@dofilelist |
| 1537 |
\@@end |
| 1538 |
} |
| 1539 |
% \end{macrocode} |
| 1540 |
% \end{macro} |
| 1541 |
% |
| 1542 |
% \begin{macrocode} |
| 1543 |
\def\snap@mismatch#1#2#3{} |
| 1544 |
% \end{macrocode} |
| 1545 |
% |
| 1546 |
% Problematic: xy.sty, because it calls xy.tex before it calls |
| 1547 |
% \cs{ProvidesPackage}. And pictex.tex because it doesnt use |
| 1548 |
% \cs{ProvidesFile} at all. |
| 1549 |
% \begin{macrocode} |
| 1550 |
\renewcommand{\RequireVersions}[2][]{% |
| 1551 |
\begingroup |
| 1552 |
\makeatletter |
| 1553 |
\def\snap@check{\snap@compare@versions}%% |
| 1554 |
\let\snapx@tfm=\snap@ignore |
| 1555 |
% \end{macrocode} |
| 1556 |
% This seems to help, with english.ldf for example, to prevent an |
| 1557 |
% endless loop when attempting to load babel.def. |
| 1558 |
% \begin{macrocode} |
| 1559 |
\def\ProvidesLanguage##1{\ProvidesFile{##1.ldf}}% |
| 1560 |
\iffalse{\fi \futurelet\@let@token\snap@branch #2}% |
| 1561 |
\endgroup |
| 1562 |
} |
| 1563 |
% \end{macrocode} |
| 1564 |
% |
| 1565 |
% \section{Finale} |
| 1566 |
% |
| 1567 |
% The usual \cs{endinput} to ensure that random garbage at the end of |
| 1568 |
% the file doesn't get copied by \fn{docstrip}. |
| 1569 |
% \begin{macrocode} |
| 1570 |
\endinput |
| 1571 |
% \end{macrocode} |