From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/snapshot/snapshot.dtx | 807 +++++++++++++++++++++++++++++ macros/latex/contrib/snapshot/snapshot.ins | 12 + macros/latex/contrib/snapshot/snapshot.pdf | Bin 0 -> 118792 bytes macros/latex/contrib/snapshot/snapshot.sty | 341 ++++++++++++ 4 files changed, 1160 insertions(+) create mode 100644 macros/latex/contrib/snapshot/snapshot.dtx create mode 100644 macros/latex/contrib/snapshot/snapshot.ins create mode 100644 macros/latex/contrib/snapshot/snapshot.pdf create mode 100644 macros/latex/contrib/snapshot/snapshot.sty (limited to 'macros/latex/contrib/snapshot') diff --git a/macros/latex/contrib/snapshot/snapshot.dtx b/macros/latex/contrib/snapshot/snapshot.dtx new file mode 100644 index 0000000000..26a502b123 --- /dev/null +++ b/macros/latex/contrib/snapshot/snapshot.dtx @@ -0,0 +1,807 @@ +%%% ==================================================================== +%%% @LaTeX-doc-source-file{ +%%% filename = "snapshot.dtx", +%%% version = "1.14", +%%% date = "2002/03/05", +%%% time = "15:29:00 EST", +%%% checksum = "39090 807 3449 29761", +%%% author = "American Mathematical Society", +%%% copyright = "Copyright 2001 American Mathematical Society, +%%% all rights reserved. Copying of this file is +%%% authorized only if either: +%%% (1) you make absolutely no changes to your copy, +%%% including name; OR +%%% (2) if you do make changes, you first rename it +%%% to some other name.", +%%% address = "American Mathematical Society, +%%% Electronic Products and Services, +%%% PO Box 6248, +%%% Providence, RI 02940, +%%% USA", +%%% email = "tech-support@ams.org", +%%% URL = "http://www.ams.org/", +%%% supported = "yes", +%%% keywords = "version, compatibility, dependencies, LaTeX", +%%% abstract = "This package provides a way for a LaTeX +%%% document to specify, for each external file +%%% on which the document depends, which version +%%% is required to guarantee output fidelity.", +%%% docstring = "The checksum field above contains a CRC-16 +%%% checksum as the first value, followed by the +%%% equivalent of the standard UNIX wc (word +%%% count) utility output of lines, words, and +%%% characters. This is produced by Robert +%%% Solovay's checksum utility.", +%%% } +%%% ==================================================================== +% \iffalse +%<*driver> +\NeedsTeXFormat{LaTeX2e} +\documentclass{amsdtx} +\providecommand{\qq}[1]{\textquotedblleft#1\textquotedblright} +\providecommand{\mdash}{\textemdash} +\begin{document} +\title{The \pkg{snapshot} package} +\author{American Mathematical Society\\Michael Downes} +\date{Version \fileversion, \filedate} +\hDocInput{snapshot.dtx} +\end{document} +% +% \fi +% +% \MakeShortVerb{\|} +% +% \maketitle +% \section{Introduction} +% +% The \pkg{snapshot} package helps the owner of a \LaTeX{} document +% obtain a list of the external dependencies of the document, in a +% form that can be embedded at the top of the document. To put it +% another way, it provides a snapshot of the current processing +% context of the document, insofar as it can be determined from +% inside \LaTeX{}. +% +% If a document contains such a dependency list, then it becomes +% possible to arrange that the document be processed always with the +% same versions of everything, in order to ensure the same output. +% This could be useful for someone wanting to keep a \LaTeX{} +% document on hand and consistently reproduce an identical DVI file +% from it, on the fly; or for someone wanting to shield a document +% during the final stages of its production cycle from unexpected +% side effects of routine upgrades to the \TeX{} system. +% +% Normal usage of the \pkg{snapshot} package involves the following +% steps: +% \begin{enumerate} +% \item Add a \cn{RequirePackage} statement at the top of the +% document: +% \begin{verbatim} +% \RequirePackage{snapshot} +% \documentclass{article} +% ... +% \end{verbatim} +% +% \item Run \latex/ on the document. This will produce a dependency +% list in a file \verb'\jobname.dep'. +% +% \item Insert the \fn{.dep} file at the top of the document, before +% \cn{documentclass}. The following example shows what you would end +% up with for a document that used the article documentclass and the +% graphicx package: +% \begin{verbatim} +% \RequirePackage{snapshot}[1999/11/03] +% \RequireVersions{ +% *{application}{TeX} {1990/03/25 v3.x} +% *{format} {LaTeX2e} {1999/06/01 v2.e} +% *{package}{snapshot} {1999/11/03 v1.03} +% *{class} {article} {1999/01/07 v1.4a} +% *{file} {size10.clo} {1999/01/07 v1.4a} +% *{package}{graphicx} {1999/02/16 v1.0f} +% *{package}{keyval} {1999/03/16 v1.13} +% *{package}{graphics} {1999/02/16 v1.0l} +% *{package}{trig} {1999/03/16 v1.09} +% *{file} {graphics.cfg}{0000/00/00 v0.0} +% *{file} {dvips.def} {1999/02/16 v3.0i} +% } +% \documentclass{article} +% \usepackage{graphicx} +% ... +% \end{verbatim} +% \end{enumerate} +% +% The package option \opt{log} will cause the dependency list to +% appear in the \latex/ log file instead of in a separate \fn{.dep} +% file: +% \begin{verbatim} +% \RequirePackage[log]{snapshot} +% \end{verbatim} +% +% Making the necessary arrangements to ensure that future \latex/ +% runs of the document actually call in the specified versions is a +% separate problem. The \pkg{snapshot} package only provides a way to +% generate the dependency list. However, the \cn{RequireVersions} +% statement does record the given information in a form that can be +% accessed from within \latex/. (It is for this purpose that it is not +% simply a comment.) In principle a package could be set up so that a +% later version would automatically attempt to emulate an earlier +% version if an earlier version was specified\mdash much as \latex/ +% currently switches to 2.09 compatibility mode if it sees +% \cn{documentstyle} instead of \cn{documentclass}. +% +% For maximum reliability font checksums should also be reported in +% the dependency list, but standard \tex/ 3.x does not provide direct +% access to font checksums for macro programmers. This information +% could be added by a separate script that scans the DVI file. +% +% When a graphics file is read in by a \latex/ document using the +% standard \cn{includegraphics} command, it gets a dummy version +% number string of +%\begin{verbatim} +%Graphics file (type foo) +%\end{verbatim} +% where foo is typically \texttt{eps}. This is with the current +% version of the \pkg{graphics} package (at the time of this writing: +% 1999/02/16 v1.0l). What this means in practice is that all graphics +% files will have their snapshot date and version number recorded as +%\begin{verbatim} +%Graphics v0.0 +%\end{verbatim} +% and will always compare equal (the string ``Graphics'' will be used +% in place of a date, but since comparison is done with \cs{ifx} it +% doesn't make any real difference). +% +% It would be possible, for \fn{.eps} files at least, to read the +% CreationDate comment that is normally included in the file header +% and use that as the basis of comparison. Recording the bounding box +% numbers instead of a dummy version number would also be a possibly +% useful stratagem. But I have left these possibilities untouched for +% the time being [mjd,2001-05-14]. +% +% \DescribeMacro{\RequireVersions} The \cn{RequireVersions} command +% scans its argument for file names and associated version number +% information. The syntax of a version line for a particular file is +% \begin{quote} +% \verb'*{' \emph{file type} \verb'}{' \emph{file name} \verb'}{' +% \emph{version info} \verb'}' +% \end{quote} +% In other words, the \verb'*' character in this context is like a +% command that takes three arguments. The extension part of the +% file name should be omitted in the second argument, except when the +% file type is \fn{file} (following the conventions of \latex/'s +% \cn{ProvidesPackage} and \cn{ProvidesFile} commands). The most +% commonly used file types are as follows. +% \begin{description} +% \item[class] A \latex/ documentclass file. +% \item[package] A \latex/ package file. +% \item[tfm] A \tex/ font metric file. In this case the \qq{version +% number} is the checksum, and unless you are using an extended +% version of \tex/ this information is not accessible from inside +% \latex/, so it must be filled in by an outside process. +% By default, font metric files are not listed in the dependency list +% since the checksum info is not available. There is a package option +% \opt{tfm} to turn on the logging of metric files. (Not yet +% implemented [mjd,1999/09/23]) +% +% \item[format] This is almost always \fn{LaTeX2e}. Other possibilities +% would be \fn{elatex} or \fn{lambda}. The information comes from +% \cs{fmtname}. +% \item[application] This is usually \fn{TeX} with version number +% \fn{3.x}. From inside \latex/ there is no reliable way to get the +% exact version number (one could check to see if version 2.x is in +% use, but this is unlikely to be relevant, nowadays, so I have not +% bothered). +% \item[file] None of the above: some other file of miscellaneous type, +% e.g., \fn{.clo}, \fn{.cfg}, \fn{.tex}, or \fn{.def}. +% \end{description} +% +% The \cn{RequireVersions} command can be given an optional +% \qq{ident} argument, similar to the argument of a \cn{label} +% command. This is not used internally but it could be used to +% assign a label to particular groups of files in case that helps +% with external processing. +% +% \section{Warning and error options} +% +% If the \pkg{snapshot} package is invoked with the \opt{error} +% option \emph{and also} the document contains a \cn{RequireVersions} +% statement, then each subsequent \cn{ProvidesFile}, +% \cn{ProvidesPackage}, and \cn{ProvidesClass} statement will compare +% date and version number information with the corresponding +% information from the \cn{RequireVersions} statement and give an +% error message if a mismatch is detected. With the \opt{warning} +% option you get warnings instead of errors. By default both the date +% and the version number are compared; this behavior can be modified, +% however, by giving additional options: +% \begin{description} +% \item[date] compare only dates, +% \item[version] compare only version numbers, +% \item[major-version] use only the major version number when +% comparing. +% \end{description} +% +% \textbf{Note:} A file that doesn't have any sort of +% \cn{ProvidesFile} or \cn{ProvidesPackage} statement in it will show +% up in the dependency list, with a dummy date and version number of +% 0000/00/00 v0.0, but there is no way, of course, to give any +% meaningful warning or error message about version mismatches for +% such a file. +% +% \StopEventually{} +% +% \section{Implementation} +% Standard declaration of package name and date. +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}[1994/12/01] +\ProvidesPackage{snapshot}[2002/03/05 v1.14] +% \end{macrocode} +% +% \begin{macrocode} +\let\@xp\expandafter \let\@nx\noexpand +% \end{macrocode} +% +% Calling the \pkg{snapshot} package in a document causes \latex/ to +% list the file names and versions in the \tex/ log or in a \fn{.dep} +% file, so that the information may be easily copied into the +% document file. The list so generated is nothing more than a slight +% adaptation of the output from \latex/'s \cn{listfiles} command; it +% puts essentially the same information into a slightly more +% structured form so that it will be easier to use. +% +% For the standard mechanisms that are already built into \latex/ +% (e.g., the handling of the second optional argument of +% \cs{LoadClass}), the de facto \qq{version number} is the +% \emph{date} given in the optional argument of a \cn{ProvidesClass} +% or similar command. Even though most \cn{ProvidesWhatever} commands +% also give something that follows the usual form of version +% numbers\mdash a string of the form \verb'v2.3'\mdash this is only a +% convention, not used internally by \latex/, and the identification +% string of a random loaded file is not guaranteed to include it. The +% \pkg{snapshot} package copies both pieces of information if +% available; if the second piece is not present, a dummy number +% \verb'0.0' is supplied. Similarly, files that don't include any +% \cn{ProvidesWhatever} statement will get a dummy date of +% \verb'0000/00/00'; \tex/ system administrators who want to ensure +% maximal accuracy of the snapshot information should therefore make +% it a practice to use \cn{ProvidesFile} in \fn{.cfg} files and other +% local files that might have an impact on the output fidelity of +% their documents. +% +% \begin{macro}{\RequireVersions} +% +% Optional argument of \cn{RequireVersions} allows assigning a name to a +% particular collection of files. This might be useful for setting a +% \tex/ inputs path. +% \begin{macrocode} +\newcommand{\RequireVersions}[2][]{% + \let\snap@check\snap@compare@versions + \let\snap@selfcheck\snap@selfcheck@a + \@ifnextchar *\snap@store@version\snap@store@error#2*{end}{}{}% +} +\@onlypreamble\RequireVersions +% \end{macrocode} +% +% \begin{macrocode} +\def\snap@store@error#1{% + \PackageError{snapshot}{Expected '*' here, not '#1'}\@ehc +} +\@onlypreamble\snap@store@error +% \end{macrocode} +% +% \begin{macrocode} +\def\snap@store@version #1#2#3#4{% + \@xp\snap@store@b\csname snapx@#2\endcsname{#2}{#3}{#4}% +} +\@onlypreamble\snap@store@version +% \end{macrocode} +% +% \begin{macrocode} +\def\@fmtextension{fmt} +\def\@tfmextension{tfm} +\edef\snapx@package{.\@pkgextension} +\edef\snapx@class{.\@clsextension} +\edef\snapx@format{.\@fmtextension} +\edef\snapx@tfm{.\@tfmextension} +\long\def\snapx@application{} +\let\snap@file=\@empty +\let\snapx@end\@@end +% \end{macrocode} +% +% For a package named \fn{foo.sty}, this function defines +% \cs{rqv@foo.sty} to hold the date and version information. +% \begin{macrocode} +\def\snap@store@b#1#2#3#4{% + \ifx#1\snapx@end + \@xp\@gobblefour + \else + \ifx#1\relax \let#1\@empty\fi + \def\@tempa##1 ##2 ##3\@nil{##1 ##2}% +% \end{macrocode} +% +% \begin{macrocode} + \ifx#1\snapx@application + \else + \xdef\rqv@list{\rqv@list + \ifx\@empty\rqv@list\else,\fi + #3#1% + }% + \fi + \@xp\xdef\csname rqv@#3#1\endcsname{\@tempa#4 v?.? ? \relax\@nil}% + \ifx#1\snapx@format \snap@check{#3.fmt}% + \else \snap@selfcheck{#3.sty}% + \fi + \fi + \@ifnextchar *\snap@store@version\snap@store@error +} +\@onlypreamble\snap@store@b +% \end{macrocode} +% \end{macro} +% +% Default setup is geared to write the dependency list to a \fn{.dep} +% file. The option \opt{log} means write it to the \tex/ log instead. +% \begin{macrocode} +\def\snap@write{\immediate\write\snap@out} +\let\snap@out\sixt@@n % fallback, probably never used +% \end{macrocode} +% +% \begin{macrocode} +\DeclareOption{dep}{% + \def\snap@write{\immediate\write\snap@out}% +} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareOption{log}{% + \let\snap@write\typeout +} +% \end{macrocode} +% +% The purpose of the `test' option is to support a separate testing +% procedure that resolves file names. If the \cs{RequireVersions} +% data is extracted to a separate file, and +%\begin{verbatim} +%\RequirePackage[test]{snapshot} +%\end{verbatim} +% is added at the top, then the file can be run as a small separate +% \LaTeX{} job whose sole purpose is to produce in the log file a +% nice list of fully resolved file names. A limited, but +% system-independent variant of the \fn{kpsewhich} idea. +% +% \begin{macrocode} +\let\snap@fake@b\relax +\DeclareOption{test}{% + \def\snap@fake@b{\endinput \futurelet\@let@token\snap@ignoline}% +} +% \end{macrocode} +% +% For each font used by a document, we would like to list the +% \fn{.tfm} file name and checksum. If \tex/ provided a +% \cn{fontchecksum} primitive similar to \cn{fontname} that could be +% used to get the checksum of any font, it would just about be +% feasible to do this entirely from within \latex/. As a partial +% solution we could at least generate the list of font file names, to +% make it easier for an external utility to add the checksums. +% +% In practice, extracting font names and checksums from the \fn{.dvi} +% file will probably work well enough, leaving no work to be done by +% the \pkg{snapshot} package in this area. But theoretically speaking +% the output of a document could be affected by font metric files +% that are loaded during \latex/ processing but that do not show up +% in the \fn{.dvi} file. +% \begin{macrocode} +\DeclareOption{tfm}{% + \typeout{Option 'tfm' not implemented yet [1999/09/23]}% +} +% \end{macrocode} +% +% Warnings and errors. +% \begin{macrocode} +\def\snap@mismatch@warning#1#2#3{\PackageWarningNoLine{#1}{#2}} +\def\snap@mismatch{\snap@mismatch@warning} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareOption{error}{% + \def\snap@mismatch{\PackageError}% + \ifx\snap@select\@empty \let\snap@select\snap@select@all \fi +} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareOption{warning}{% + \def\snap@mismatch{\snap@mismatch@warning}% + \ifx\snap@select\@empty \let\snap@select\snap@select@all \fi +} +% \end{macrocode} +% +% Because the exact form of the version number is not mandated by +% LaTeX, just take the first two ``words'' delimited by spaces. And +% take a little extra care to properly handle multiple spaces between +% the words. +% \begin{macrocode} +\def\snap@select@all#1#2 #3#4 #5\@nil{#1#2 #3#4} +\let\snap@select\@empty +% \end{macrocode} +% +% \begin{macrocode} +\DeclareOption{date}{% + \def\snap@select#1#2 #3\@nil{#1#2}% +} +% \end{macrocode} +% +% \begin{macrocode} +\def\snap@select@version#1{% + \ifodd 0#11 \@xp\snap@sva\@xp#1\else\@xp\snap@select@version\fi +} +\def\snap@sva#1.#2 #3\@nil{#1.#2} +\def\snap@select@major#1{% + \ifodd 0#11 \@xp\snap@svm\@xp#1\else\@xp\snap@select@major\fi +} +\def\snap@svm#1.#2\@nil{#1} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareOption{version}{% + \def\snap@select#1#2 #3{\snap@select@version #3}% +} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareOption{major-version}{% + \def\snap@select#1#2 #3{\snap@select@major #3}% +} +% \end{macrocode} +% +% \begin{macrocode} +\ProcessOptions\par +% \end{macrocode} +% +% We need the following patch to make up for the fact that +% \cs{@pkgextension} and \cs{@clsextension} are marked in the \latex/ +% kernel as \qq{only preamble}. +% \begin{macrocode} +\edef\snap@restore@extensions{% + \def\@nx\@pkgextension{\@pkgextension}% + \def\@nx\@clsextension{\@clsextension}% +} +% \end{macrocode} +% +% Pad filename strings out to 8+3 length so that the list will look +% pretty. +% \begin{macrocode} +\def\snap@pad#1#2#3#4#5#6#7#8#9{\snap@pad@a{#1#2#3#4#5#6#7#8#9}} +\def\snap@pad@a#1#2#3#4#5\@nil{\snap@pad@b#1#2#3#4\space\@nil} +\def\snap@pad@b#1\space#2\@nil#3{\def#3{#2}} +% \end{macrocode} +% +% First stage: discard leading spaces before the first and second +% nonspace strings in the argument. Take the first nonspace string as +% the date. Since we only do equal/not-equal testing on dates, it +% does not seem essential to test if it is really a valid date string +% or not (yyyy/mm/dd). +% \begin{macrocode} +\def\snap@trim@version#1#2 #3{#1#2 \snap@trim@b #3} +% \end{macrocode} +% Second stage: Scan for a version number. In order to handle some +% idiosyncratic cases, such as url.sty version 1.4, we can't simply +% take the second nonspace string as the version number but need to +% look for a leading digit. +% \begin{macrocode} +\def\snap@trim@b#1{\ifodd 0#11 v#1\@xp\snap@trim@c\fi \snap@trim@b} +% \end{macrocode} +% Arg 1 here is \cs{snap@trim@b}, which we just need to discard. +% \begin{macrocode} +\def\snap@trim@c#1#2 #3\@nil{#2} +% \end{macrocode} +% +% \begin{macrocode} +\let\rqv@list=\@empty +% \end{macrocode} +% +% If \verb'\fmtname.fmt' is not already in the file list, add it. +% \begin{macrocode} +\edef\@tempc#1\fmtname{#1\fmtname}\@tempc +\def\@tempa#1,\fmtname.fmt,#2#3\@nil{#2} +\edef\@tempb{\@nx\@tempa,\@filelist,\fmtname.fmt,} +\if ?\@tempb?\@nil + \edef\@filelist{\fmtname.fmt,\@filelist}% + \def\@tempc{LaTeX2e}% + \@xp\edef\csname ver@\fmtname.fmt\endcsname{% + \fmtversion\space + v\ifx\@tempc\fmtname 2.e\else ?.?\fi + }% +\fi +\listfiles +\def\@dofilelist{% + \snap@restore@extensions + \ifx\rqv@list\@empty + \else \rqv@compare@lists + \fi + \ifx\snap@write\typeout + \else + \newwrite\snap@out + \immediate\openout\snap@out=\jobname.dep \relax + \fi + \snap@write{\string\RequireVersions\@charlb}% +% \end{macrocode} +% Since the exact version number of \TeX{} is not normally accessible +% from inside \latex/, we use a nominal date of 1990/03/25, which is +% when version 3.0 of \fn{tex.web} was released by Knuth. +% \begin{macrocode} + \snap@write{\space\space *{application}{TeX}% + \space\space\space\space\space{1990/03/25 v3.x}}% + \@for\@currname:=\@filelist\do{% + \filename@parse\@currname + \ifx\filename@ext\relax + \def\@tempa{file}\def\@tempd{.tex}\def\filename@ext{tex}% + \def\@tempb{~~~}% + \else\ifx\filename@ext\@pkgextension + \def\@tempa{package}\let\@tempd\@empty + \def\@tempb{}% + \else\ifx\filename@ext\@clsextension + \def\@tempa{class}\let\@tempd\@empty + \def\@tempb{~~}% + \else\ifx\filename@ext\@fmtextension + \def\@tempa{format}\let\@tempd\@empty + \def\@tempb{~}% + \else\ifx\filename@ext\@tfmextension + \def\@tempa{tfm}\let\@tempd\@empty + \def\@tempb{~~~~}% + \else + \def\@tempa{file}\edef\@tempd{.\filename@ext}% + \def\@tempb{~~~}% + \fi\fi\fi\fi\fi + \@xp\let\@xp\@tempe + \csname ver@\filename@base.\filename@ext\endcsname +% \end{macrocode} +% If a file contains just \verb'\ProvidesFoo{xyz}' without \emph{any} +% optional argument, then \cs{ver@xyz} ends up empty. Resetting it to +% \cs{relax} is the easiest way to get the fallback version +% number in that case also. +% \begin{macrocode} + \ifx\@tempe\@empty \let\@tempe\relax \fi + \edef\@tempe{% + \ifx\@tempe\relax 0000/00/00 v0.0% + \else + \@xp\@xp\@xp\snap@trim@version\@xp\@tempe\space v0.0 v0.0 \@nil + \fi + }% + \edef\@tempc{\filename@area\filename@base\@tempd}% full file name + \@xp\snap@pad\@tempc\space~~~~~~~~~~~~~~~~\@nil\@tempd + \begingroup \let~\space + \snap@write{\space\space *{\@tempa}\@tempb{\@tempc}\@tempd{\@tempe}}% + \endgroup + }% + \snap@write{\@charrb}% + \ifx\snap@write\typeout + \else \immediate\closeout\snap@out + \typeout{Dependency list written on \jobname.dep.}% + \fi +}% +% \end{macrocode} +% +% The \cs{rqv@compare@lists} function checks to see if any files +% are found only in the RequireVersions list or only in +% \cs{@filelist}. To see which files are only in \cs{@filelist}, we +% map the \cs{rqv@condense} function across both lists, reinitializing +% \cs{L} (used here as a scratch variable) in between. As a side +% effect this leaves the desired file names in \cs{L}. Then the same +% process with the order of the lists reversed tells us which ones +% are only in \cs{rqv@list}. +% \begin{macrocode} +\def\rqv@condense#1,{% + \if ,#1,% + \else + \@xp\ifx\csname ver@#1\endcsname\N + \else + \edef\L{\L,#1}% + \@xp\let\csname ver@#1\endcsname=\N + \fi + \fi + \rqv@condense +} +% \end{macrocode} +% +% \begin{macrocode} +\def\rqv@compare@lists{% + \begingroup + \def\N{1}\let\L=\@gobble + \@xp\rqv@condense \rqv@list,TeX,{,\relax\@xp\@gobbletwo\@xp},% + \ifx\L\@gobble\let\L\@empty\fi + \let\rqv@list=\L + \let\L=\@gobble + \@xp\rqv@condense \@filelist,{,\relax\@xp\@gobbletwo\@xp},% + \ifx\L\@gobble\let\L\@empty\fi + \@for\@currname:=\L\do{% + \snap@mismatch{snapshot}{^^J% + File \@currname\space loaded though not in + \noexpand\RequireVersions list% + }\@ehc + }% + \def\N{2}\let\L=\@gobble + \@xp\rqv@condense\@filelist,TeX,{,\relax\@xp\@gobbletwo\@xp},% + \let\L=\@gobble + \@xp\rqv@condense\rqv@list,{,\relax\@xp\@gobbletwo\@xp},% + \ifx\L\@gobble\let\L\@empty\fi + \@for\@currname:=\L\do{% + \snap@mismatch{snapshot}{^^J% + File \@currname\space [\csname rqv@\@currname\endcsname] + required but not loaded% + }\@ehc + }% + \endgroup +} +% \end{macrocode} +% +% See the documentation above for the `test' option. +% \begin{macrocode} +\begingroup \catcode\endlinechar=12\relax % +\long\gdef\snap@ignoline#1 +{}\endgroup % +% \end{macrocode} +% +% \begin{macrocode} +\def\snap@fake@input#1#2#3#4{% + \ifx#1\snapx@end + \aftergroup\@@end \@xp\@gobblefour + \else + \ifx#1\snapx@format + \else + \message{^^J}% + \@xp\snap@fake@b\@@input #3#1\relax + \fi + \fi + \@ifnextchar *\snap@store@version\snap@store@error +} +% \end{macrocode} +% +% \begin{macrocode} +\newcommand{\rqvTest}[2][]{% + \begingroup \catcode\endlinechar=12 + \catcode`\%=12 \catcode`\{=12 \catcode`\}=12\relax +% \end{macrocode} +% Since \cs{snap@fake@input} just compares \cs{snapx@foo} with +% \cs{ifx}, making \cs{snapx@application} +% and \cs{snapx@tfm} compare equal to \cs{snap@format} +% ensures that only one comparison is needed to tell if +% we shouldn't attempt to input the current file type. +% \begin{macrocode} + \let\snapx@application=\snapx@format \let\snapx@tfm=\snap@format + \@ifnextchar *\snap@store@version\snap@store@error#2*{end}{}{}% + \endgroup +} +% \end{macrocode} +% +% \begin{macrocode} +\@ifundefined{snap@fake@b}{}{% + \let\snap@store@b\snap@fake@input + \let\RequireVersions\rqvTest +} +% \end{macrocode} +% +% Compensate for a bug in old versions of \fn{amsgen.sty}. This is a +% little tricky. +% +% Old version: \cs{ver@amsgen}=1996/10/29 v1.2b +% +% New version: \cs{ver@amsgen.sty}=1999/11/30 v2.0 +% \begin{macrocode} +%\@namedef{ver@amsgen.sty}{1996/10/29 v1.2b} +\AtBeginDocument{% + \@ifundefined{ver@amsgen}{}{% + \@xp\let\csname ver@amsgen.sty\@xp\endcsname + \csname ver@amsgen\endcsname + }% +} +% \end{macrocode} +% +% Terminate here without touching \LaTeX{} internals, unless +% one of the relevant snapshot options was chosen. +% \begin{macrocode} +\let\snap@compare@versions\@gobble \let\snap@check\@gobble +\let\snap@selfcheck\@gobble \let\snap@selfcheck@a\@gobble +\ifx\snap@select\@empty \endinput \fi +% \end{macrocode} +% +% \begin{macrocode} +\begingroup \catcode`\.=11\relax +\gdef\snap@selfcheck@b#1\rqv@snapshot.sty#2#3\@nil{T#2} +\gdef\snap@selfcheck@a#1{% + \if\@xp\snap@selfcheck@b\csname rqv@#1\endcsname T% + \rqv@snapshot.sty F\@nil + \snap@check{#1}% + \fi +} +\endgroup +% \end{macrocode} +% +% \begin{macrocode} +\def\@nofmt#1.fmt.#2 {#1 } +% \end{macrocode} +% +% \begin{macrocode} +\def\snap@mismatch@a#1#2#3{% + \snap@mismatch{snapshot}{^^J% + \space\space Required version #2 of \@nofmt#1.fmt. and^^J% + \space\space provided version #3 do not match% + }\@ehc +} +% \end{macrocode} +% +% When comparing \cs{rqv@foo.sty} (information from a previous +% \latex/ run) with \cs{ver@foo.sty} (information from current run), +% we first call \cs{snap@trim@version} on the latter to clear away +% any idiosyncrasies in the contents. +% \begin{macrocode} +\def\snap@compare@versions#1{% + \begingroup + \@ifundefined{rqv@#1}{}{% + \edef\0{\csname rqv@#1\endcsname}% + \edef\1{\csname ver@#1\endcsname}% + \edef\1{\@xp\snap@trim@version\1 v0.0 v0.0 \@nil}% + \edef\@tempa{\@xp\snap@select\0 v0.0 v0.0 \@nil}% + \edef\@tempb{\@xp\snap@select\1 v0.0 v0.0 \@nil}% + \ifx\@tempa\@tempb + \else + \edef\@tempd{\@nx\snap@mismatch@a{#1}{\@tempa}{\@tempb}}% + \@xp\@tempd + \fi + }% + \endgroup +} +% \end{macrocode} +% +% Because \cs{ProvidesFile} is used in \fn{.fd} files which are +% normally read with special catcodes, there tend to +% be problems with whitespace characters being erroneously lost from +% the second argument. Since we have to put in a \cs{snap@check} call +% anyway, while we're at it let's fix a bug of this type that +% affected some older versions of \latex/. +% \begin{macrocode} +\def\ProvidesFile#1{% + \def\snap@checker{\snap@check{#1}}% + \begingroup + \aftergroup\snap@checker + \catcode`\ 10\catcode\endlinechar 10 % + \@makeother\/% + \@makeother\&% + \@ifnextchar[{\@providesfile{#1}}{\@providesfile{#1}[]}% +} +% \end{macrocode} +% +% \begin{macrocode} +\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 + \snap@check{\@currname.\@currext}% +} +% \end{macrocode} +% +% The usual \cs{endinput} to ensure that random garbage at the end of +% the file doesn't get copied by \fn{docstrip}. +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \section*{To Do} +% +% \begin{itemize} +% \item Provide a test to distinguish between shared-use files and +% document-specific files? Document-specific files would be things +% like graphics files loaded via \cs{includegraphics} or book +% chapters loaded via \cs{include}. But there might also be something +% like \verb'\input{my-book-macros}' in the preamble. Maybe authors +% should be encouraged to put this after \verb'\begin{document}'? Or, +% even, after \verb'\begin{abstract}' so that the abstract will +% contain only lowest-common-denominator \LaTeX{} commands? +% +% The non-document-specific files most commonly loaded after +% \verb'\begin{document}' would be \fn{.fd} files, but there is also +% the possibility of autoloaded stuff (\fn{alatex} format). +% \end{itemize} +% +% \CheckSum{777} +% \Finale diff --git a/macros/latex/contrib/snapshot/snapshot.ins b/macros/latex/contrib/snapshot/snapshot.ins new file mode 100644 index 0000000000..d30602c46e --- /dev/null +++ b/macros/latex/contrib/snapshot/snapshot.ins @@ -0,0 +1,12 @@ +% Normal installation of this package in a standard TDS texmf tree: +% Put snapshot.sty into the directory texmf/tex/latex/misc. +% Put snapshot.dvi (produced by running LaTeX on snapshot.dtx) into +% texmf/doc/latex/misc. + +\def\batchfile{snapshot.ins} +\input docstrip.tex +\preamble +\endpreamble +\keepsilent +\generateFile{snapshot.sty}{f}{\from{snapshot.dtx}{}} +\endinput diff --git a/macros/latex/contrib/snapshot/snapshot.pdf b/macros/latex/contrib/snapshot/snapshot.pdf new file mode 100644 index 0000000000..d1925581ff Binary files /dev/null and b/macros/latex/contrib/snapshot/snapshot.pdf differ diff --git a/macros/latex/contrib/snapshot/snapshot.sty b/macros/latex/contrib/snapshot/snapshot.sty new file mode 100644 index 0000000000..6646abaa2c --- /dev/null +++ b/macros/latex/contrib/snapshot/snapshot.sty @@ -0,0 +1,341 @@ +%% +%% This is file `snapshot.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% snapshot.dtx +%% +%%% ==================================================================== +%%% @LaTeX-doc-source-file{ +%%% filename = "snapshot.dtx", +%%% version = "1.14", +%%% date = "2002/03/05", +%%% time = "15:29:00 EST", +%%% checksum = "39090 807 3449 29761", +%%% author = "American Mathematical Society", +%%% copyright = "Copyright 2001 American Mathematical Society, +%%% all rights reserved. Copying of this file is +%%% authorized only if either: +%%% (1) you make absolutely no changes to your copy, +%%% including name; OR +%%% (2) if you do make changes, you first rename it +%%% to some other name.", +%%% address = "American Mathematical Society, +%%% Electronic Products and Services, +%%% PO Box 6248, +%%% Providence, RI 02940, +%%% USA", +%%% email = "tech-support@ams.org", +%%% URL = "http://www.ams.org/", +%%% supported = "yes", +%%% keywords = "version, compatibility, dependencies, LaTeX", +%%% abstract = "This package provides a way for a LaTeX +%%% document to specify, for each external file +%%% on which the document depends, which version +%%% is required to guarantee output fidelity.", +%%% docstring = "The checksum field above contains a CRC-16 +%%% checksum as the first value, followed by the +%%% equivalent of the standard UNIX wc (word +%%% count) utility output of lines, words, and +%%% characters. This is produced by Robert +%%% Solovay's checksum utility.", +%%% } +%%% ==================================================================== +\NeedsTeXFormat{LaTeX2e}[1994/12/01] +\ProvidesPackage{snapshot}[2002/03/05 v1.14] +\let\@xp\expandafter \let\@nx\noexpand +\newcommand{\RequireVersions}[2][]{% + \let\snap@check\snap@compare@versions + \let\snap@selfcheck\snap@selfcheck@a + \@ifnextchar *\snap@store@version\snap@store@error#2*{end}{}{}% +} +\@onlypreamble\RequireVersions +\def\snap@store@error#1{% + \PackageError{snapshot}{Expected '*' here, not '#1'}\@ehc +} +\@onlypreamble\snap@store@error +\def\snap@store@version #1#2#3#4{% + \@xp\snap@store@b\csname snapx@#2\endcsname{#2}{#3}{#4}% +} +\@onlypreamble\snap@store@version +\def\@fmtextension{fmt} +\def\@tfmextension{tfm} +\edef\snapx@package{.\@pkgextension} +\edef\snapx@class{.\@clsextension} +\edef\snapx@format{.\@fmtextension} +\edef\snapx@tfm{.\@tfmextension} +\long\def\snapx@application{} +\let\snap@file=\@empty +\let\snapx@end\@@end +\def\snap@store@b#1#2#3#4{% + \ifx#1\snapx@end + \@xp\@gobblefour + \else + \ifx#1\relax \let#1\@empty\fi + \def\@tempa##1 ##2 ##3\@nil{##1 ##2}% + \ifx#1\snapx@application + \else + \xdef\rqv@list{\rqv@list + \ifx\@empty\rqv@list\else,\fi + #3#1% + }% + \fi + \@xp\xdef\csname rqv@#3#1\endcsname{\@tempa#4 v?.? ? \relax\@nil}% + \ifx#1\snapx@format \snap@check{#3.fmt}% + \else \snap@selfcheck{#3.sty}% + \fi + \fi + \@ifnextchar *\snap@store@version\snap@store@error +} +\@onlypreamble\snap@store@b +\def\snap@write{\immediate\write\snap@out} +\let\snap@out\sixt@@n % fallback, probably never used +\DeclareOption{dep}{% + \def\snap@write{\immediate\write\snap@out}% +} +\DeclareOption{log}{% + \let\snap@write\typeout +} +\let\snap@fake@b\relax +\DeclareOption{test}{% + \def\snap@fake@b{\endinput \futurelet\@let@token\snap@ignoline}% +} +\DeclareOption{tfm}{% + \typeout{Option 'tfm' not implemented yet [1999/09/23]}% +} +\def\snap@mismatch@warning#1#2#3{\PackageWarningNoLine{#1}{#2}} +\def\snap@mismatch{\snap@mismatch@warning} +\DeclareOption{error}{% + \def\snap@mismatch{\PackageError}% + \ifx\snap@select\@empty \let\snap@select\snap@select@all \fi +} +\DeclareOption{warning}{% + \def\snap@mismatch{\snap@mismatch@warning}% + \ifx\snap@select\@empty \let\snap@select\snap@select@all \fi +} +\def\snap@select@all#1#2 #3#4 #5\@nil{#1#2 #3#4} +\let\snap@select\@empty +\DeclareOption{date}{% + \def\snap@select#1#2 #3\@nil{#1#2}% +} +\def\snap@select@version#1{% + \ifodd 0#11 \@xp\snap@sva\@xp#1\else\@xp\snap@select@version\fi +} +\def\snap@sva#1.#2 #3\@nil{#1.#2} +\def\snap@select@major#1{% + \ifodd 0#11 \@xp\snap@svm\@xp#1\else\@xp\snap@select@major\fi +} +\def\snap@svm#1.#2\@nil{#1} +\DeclareOption{version}{% + \def\snap@select#1#2 #3{\snap@select@version #3}% +} +\DeclareOption{major-version}{% + \def\snap@select#1#2 #3{\snap@select@major #3}% +} +\ProcessOptions\par +\edef\snap@restore@extensions{% + \def\@nx\@pkgextension{\@pkgextension}% + \def\@nx\@clsextension{\@clsextension}% +} +\def\snap@pad#1#2#3#4#5#6#7#8#9{\snap@pad@a{#1#2#3#4#5#6#7#8#9}} +\def\snap@pad@a#1#2#3#4#5\@nil{\snap@pad@b#1#2#3#4\space\@nil} +\def\snap@pad@b#1\space#2\@nil#3{\def#3{#2}} +\def\snap@trim@version#1#2 #3{#1#2 \snap@trim@b #3} +\def\snap@trim@b#1{\ifodd 0#11 v#1\@xp\snap@trim@c\fi \snap@trim@b} +\def\snap@trim@c#1#2 #3\@nil{#2} +\let\rqv@list=\@empty +\edef\@tempc#1\fmtname{#1\fmtname}\@tempc +\def\@tempa#1,\fmtname.fmt,#2#3\@nil{#2} +\edef\@tempb{\@nx\@tempa,\@filelist,\fmtname.fmt,} +\if ?\@tempb?\@nil + \edef\@filelist{\fmtname.fmt,\@filelist}% + \def\@tempc{LaTeX2e}% + \@xp\edef\csname ver@\fmtname.fmt\endcsname{% + \fmtversion\space + v\ifx\@tempc\fmtname 2.e\else ?.?\fi + }% +\fi +\listfiles +\def\@dofilelist{% + \snap@restore@extensions + \ifx\rqv@list\@empty + \else \rqv@compare@lists + \fi + \ifx\snap@write\typeout + \else + \newwrite\snap@out + \immediate\openout\snap@out=\jobname.dep \relax + \fi + \snap@write{\string\RequireVersions\@charlb}% + \snap@write{\space\space *{application}{TeX}% + \space\space\space\space\space{1990/03/25 v3.x}}% + \@for\@currname:=\@filelist\do{% + \filename@parse\@currname + \ifx\filename@ext\relax + \def\@tempa{file}\def\@tempd{.tex}\def\filename@ext{tex}% + \def\@tempb{~~~}% + \else\ifx\filename@ext\@pkgextension + \def\@tempa{package}\let\@tempd\@empty + \def\@tempb{}% + \else\ifx\filename@ext\@clsextension + \def\@tempa{class}\let\@tempd\@empty + \def\@tempb{~~}% + \else\ifx\filename@ext\@fmtextension + \def\@tempa{format}\let\@tempd\@empty + \def\@tempb{~}% + \else\ifx\filename@ext\@tfmextension + \def\@tempa{tfm}\let\@tempd\@empty + \def\@tempb{~~~~}% + \else + \def\@tempa{file}\edef\@tempd{.\filename@ext}% + \def\@tempb{~~~}% + \fi\fi\fi\fi\fi + \@xp\let\@xp\@tempe + \csname ver@\filename@base.\filename@ext\endcsname + \ifx\@tempe\@empty \let\@tempe\relax \fi + \edef\@tempe{% + \ifx\@tempe\relax 0000/00/00 v0.0% + \else + \@xp\@xp\@xp\snap@trim@version\@xp\@tempe\space v0.0 v0.0 \@nil + \fi + }% + \edef\@tempc{\filename@area\filename@base\@tempd}% full file name + \@xp\snap@pad\@tempc\space~~~~~~~~~~~~~~~~\@nil\@tempd + \begingroup \let~\space + \snap@write{\space\space *{\@tempa}\@tempb{\@tempc}\@tempd{\@tempe}}% + \endgroup + }% + \snap@write{\@charrb}% + \ifx\snap@write\typeout + \else \immediate\closeout\snap@out + \typeout{Dependency list written on \jobname.dep.}% + \fi +}% +\def\rqv@condense#1,{% + \if ,#1,% + \else + \@xp\ifx\csname ver@#1\endcsname\N + \else + \edef\L{\L,#1}% + \@xp\let\csname ver@#1\endcsname=\N + \fi + \fi + \rqv@condense +} +\def\rqv@compare@lists{% + \begingroup + \def\N{1}\let\L=\@gobble + \@xp\rqv@condense \rqv@list,TeX,{,\relax\@xp\@gobbletwo\@xp},% + \ifx\L\@gobble\let\L\@empty\fi + \let\rqv@list=\L + \let\L=\@gobble + \@xp\rqv@condense \@filelist,{,\relax\@xp\@gobbletwo\@xp},% + \ifx\L\@gobble\let\L\@empty\fi + \@for\@currname:=\L\do{% + \snap@mismatch{snapshot}{^^J% + File \@currname\space loaded though not in + \noexpand\RequireVersions list% + }\@ehc + }% + \def\N{2}\let\L=\@gobble + \@xp\rqv@condense\@filelist,TeX,{,\relax\@xp\@gobbletwo\@xp},% + \let\L=\@gobble + \@xp\rqv@condense\rqv@list,{,\relax\@xp\@gobbletwo\@xp},% + \ifx\L\@gobble\let\L\@empty\fi + \@for\@currname:=\L\do{% + \snap@mismatch{snapshot}{^^J% + File \@currname\space [\csname rqv@\@currname\endcsname] + required but not loaded% + }\@ehc + }% + \endgroup +} +\begingroup \catcode\endlinechar=12\relax % +\long\gdef\snap@ignoline#1 +{}\endgroup % +\def\snap@fake@input#1#2#3#4{% + \ifx#1\snapx@end + \aftergroup\@@end \@xp\@gobblefour + \else + \ifx#1\snapx@format + \else + \message{^^J}% + \@xp\snap@fake@b\@@input #3#1\relax + \fi + \fi + \@ifnextchar *\snap@store@version\snap@store@error +} +\newcommand{\rqvTest}[2][]{% + \begingroup \catcode\endlinechar=12 + \catcode`\%=12 \catcode`\{=12 \catcode`\}=12\relax + \let\snapx@application=\snapx@format \let\snapx@tfm=\snap@format + \@ifnextchar *\snap@store@version\snap@store@error#2*{end}{}{}% + \endgroup +} +\@ifundefined{snap@fake@b}{}{% + \let\snap@store@b\snap@fake@input + \let\RequireVersions\rqvTest +} +\AtBeginDocument{% + \@ifundefined{ver@amsgen}{}{% + \@xp\let\csname ver@amsgen.sty\@xp\endcsname + \csname ver@amsgen\endcsname + }% +} +\let\snap@compare@versions\@gobble \let\snap@check\@gobble +\let\snap@selfcheck\@gobble \let\snap@selfcheck@a\@gobble +\ifx\snap@select\@empty \endinput \fi +\begingroup \catcode`\.=11\relax +\gdef\snap@selfcheck@b#1\rqv@snapshot.sty#2#3\@nil{T#2} +\gdef\snap@selfcheck@a#1{% + \if\@xp\snap@selfcheck@b\csname rqv@#1\endcsname T% + \rqv@snapshot.sty F\@nil + \snap@check{#1}% + \fi +} +\endgroup +\def\@nofmt#1.fmt.#2 {#1 } +\def\snap@mismatch@a#1#2#3{% + \snap@mismatch{snapshot}{^^J% + \space\space Required version #2 of \@nofmt#1.fmt. and^^J% + \space\space provided version #3 do not match% + }\@ehc +} +\def\snap@compare@versions#1{% + \begingroup + \@ifundefined{rqv@#1}{}{% + \edef\0{\csname rqv@#1\endcsname}% + \edef\1{\csname ver@#1\endcsname}% + \edef\1{\@xp\snap@trim@version\1 v0.0 v0.0 \@nil}% + \edef\@tempa{\@xp\snap@select\0 v0.0 v0.0 \@nil}% + \edef\@tempb{\@xp\snap@select\1 v0.0 v0.0 \@nil}% + \ifx\@tempa\@tempb + \else + \edef\@tempd{\@nx\snap@mismatch@a{#1}{\@tempa}{\@tempb}}% + \@xp\@tempd + \fi + }% + \endgroup +} +\def\ProvidesFile#1{% + \def\snap@checker{\snap@check{#1}}% + \begingroup + \aftergroup\snap@checker + \catcode`\ 10\catcode\endlinechar 10 % + \@makeother\/% + \@makeother\&% + \@ifnextchar[{\@providesfile{#1}}{\@providesfile{#1}[]}% +} +\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 + \snap@check{\@currname.\@currext}% +} +\endinput +%% +%% End of file `snapshot.sty'. -- cgit v1.2.3