From 87f5bf9bf0a3ad0306a912db16a32beec711e94a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 12 Feb 2008 18:34:45 +0000 Subject: nag 0.61 (11feb08) git-svn-id: svn://tug.org/texlive/trunk@6612 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/nag/nag.dtx | 220 ++++++++++++++++++++++++++--- Master/texmf-dist/source/latex/nag/nag.ins | 4 +- 2 files changed, 199 insertions(+), 25 deletions(-) (limited to 'Master/texmf-dist/source/latex/nag') diff --git a/Master/texmf-dist/source/latex/nag/nag.dtx b/Master/texmf-dist/source/latex/nag/nag.dtx index ee9c988f834..11b1dee7cfe 100644 --- a/Master/texmf-dist/source/latex/nag/nag.dtx +++ b/Master/texmf-dist/source/latex/nag/nag.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2005-7 by Ulrich M. Schwarz +% Copyright (C) 2005-8 by Ulrich M. Schwarz % % This file may be distributed and/or modified under the conditions of % the LaTeX Project Public License, either version 1.3a or, at your @@ -30,7 +30,7 @@ %<*nagdemo> %% Test document: finding and complaining about obsolete macros. %% -\RequirePackage[l2tabu, orthodox, experimental]{nag}[2007/04/23] +\RequirePackage[l2tabu, orthodox, experimental]{nag}[2007/12/21] \documentclass{article} %% some usual culprits \usepackage{times, a4wide, epsfig, palatino} @@ -80,13 +80,16 @@ \typeout{Next: no-caption complaint} \begin{figure} No caption, even a fake one. + But too big, this should get bottom-of-page warning. + \rule{1pt}{0.4\textheight} \end{figure} \typeout{Next: no complaint about subfloat and topcapt} +\typeout{also: complaint about it in caption.} \begin{figure} \subfloat{\label{sf:1}Subfig number~\ref{sf:1} with label.} \subfloat[\label{sf:17}Strange subfig]{Subfig~\ref{sf:17} with label elsewhere.} - \caption{Figure} + \caption{Figure: \it's a sin!} \end{figure} \begin{figure} @@ -102,7 +105,7 @@ \typeout{Shouldn't cause trouble to have dollars in headings.} \section{Maths tests, like if $1+1=2$} -\typeout{Next: three complaints in total concerning $$ end eqnarray} +\typeout{Next: three complaints in total concerning $$ and eqnarray} A \TeX-style displayed equation: $$ 1+1=2 $$ @@ -155,7 +158,12 @@ Another endflushright, this is brace-mismatched and otherwise totally unsuited for closing the center command above. \endflushright -\AtEndDocument{\typeout{You should get 20 warnings.}} +\typeout{Next: a warning that is not uppercased.} +\MakeUppercase{\it's a sin!} + +\typeout{Next: another warning about it in a caption, in the LoF this time.} +\listoffigures +\AtEndDocument{\typeout{You should get 24 warnings and one info in the log.}} \end{document} % % @@ -184,6 +192,9 @@ unsuited for closing the center command above. %\DoNotIndex{\InputIfFileExists,\let,\lq,\rq,\MessageBreak,\protect} %\DoNotIndex{\space,\stepcounter,\the,\value,\relax,\ProcessOptions} %\DoNotIndex{\ifcsname,\@ifundefined,\flo,\begingroup,\endgroup} +%\DoNotIndex{\or,\vbox,\vskip,\z@,\wd,\vtop,\tmp@a,\tmp@b,\tw@} +%\DoNotIndex{\@nil,\@nx,\@ne,\@tempcnta,\@tempcntb,\@tempdima,\@tempskipb} +%\DoNotIndex{\foo,\endfoo,\ht,\dp,\wd,\hrule,\ifcase,\ifdim} % %\changes{0.1}{2005/03/29}{First official version.} %\changes{0.2}{2005/05/08}{Rephrased umlaut.sty warning, suggested by @@ -244,6 +255,9 @@ unsuited for closing the center command above. % Orthodox checks for pitfalls that are not technically incorrect. If % you know what you're doing, omit orthodox. % +% \subsection{Known bugs} +% currently none. +% % \subsection{\texttt{nag-l2tabu.cfg}} % % In a nutshell, \texttt{nag-l2tabu.cfg} detects the following: @@ -275,10 +289,12 @@ unsuited for closing the center command above. % legitimate use, and not find illegitimate use in all cases. It is a % tool, not a replacement for study of \pkg{l2tabu}.} % -% \begin{macrocode} +% \iffalse %<*l2tabunag> +% \fi +% \begin{macrocode} \ProvidesFile{nag-l2tabu.cfg} - [2007/06/10 v2.0 l2tabu rules for nag.sty (ulmi)] + [2008/01/27 v2.1alpha1 l2tabu rules for nag.sty (ulmi)] %% %% The sins. %% @@ -370,6 +386,39 @@ unsuited for closing the center command above. % \$ as well will silently disable us. This is a feature. \global\let$\nag@maybedispmath%$ \egroup +% \end{macrocode} +% \changes{0.61alpha6}{2008/01/27}{Compatibility w/ VCS packages, pgf} +%% new in 2.1alpha1: more compat testing. Version control keywords are dollar-delimited. +%% all five implementations get it wrong. +% \begin{macrocode} +\AtBeginDocument{% + \@ifpackageloaded{rcs}{% + % this redefinition is functionally equivalent, + % but does not share actual code. + \renewcommand\RCS{\bgroup% + \catcode`\_ =\active + \catcode`\$=3 % this line added for compatibility. + \csname RCS_get_argument\endcsname + } + \PackageInfo{nag}{rcs.sty hack applied}% + }{}% + \@ifpackageloaded{svninfo}{% + \g@addto@macro\@svnBeginRead{\catcode`\$ 3 }% + \PackageInfo{nag}{svninfo.sty hack applied}% + }{}% + \@ifpackageloaded{svn}{% + \PackageInfo{nag}{svn.sty is broken: disabling dollar check}% + \catcode`\$ 3 + }{}% + \@ifpackageloaded{rcsinfo}{% + \PackageInfo{nag}{rcsinfo.sty is broken: disabling dollar check}% + \catcode`\$ 3 + }{}% + \@ifpackageloaded{pgf}{% + \PackageInfo{nag}{pgf.sty is broken: disabling dollar check}% + \catcode`\$ 3 + }{}% +} %% \S 1.7 cannot reasonably be checked programmatically @@ -461,8 +510,10 @@ unsuited for closing the center command above. %% align*, since it passes through align. \ObsoleteEnv{eqnarray}{amsmath's align} %% \S 3.4 -- nothing to be done -- -% % \end{macrocode} +% \iffalse +% +% \fi % % \subsection{\texttt{nag-orthodox.cfg}} % \texttt{nag-orthodox.cfg} warns about usage that is not technically @@ -473,8 +524,10 @@ unsuited for closing the center command above. % switches don't \string\ignorespaces), and, conversely, the usage of % center etc. environments as unclosed switches. (Detection of the % latter might still be somewhat brittle.) -% \begin{macrocode} +% \iffalse %<*orthodoxnag> +% \fi +% \begin{macrocode} \ProvidesFile{nag-orthodox.cfg} [2006/04/19 v1.8 strict rules for nag.sty (ulmi)] \@for\fontcmd:=tiny,small,footnotesize,normalsize,large,Large,% @@ -493,36 +546,122 @@ unsuited for closing the center command above. \@for\justenv:=center,flushleft,flushright\do{% \expandafter\NotASwitch\expandafter{\justenv}% } -% % \end{macrocode} +%\iffalse +% +%\fi % % \subsection{\texttt{nag-abort.cfg}} % Requesting this nag file will turn all complaints into errors. % -% \begin{macrocode} +% \iffalse %<*abortnag> +%\fi +% \begin{macrocode} \ProvidesFile{nag-abort.cfg} - [2005/05/08 v0.1 treat complaints as errors (ulmi)] -\renewcommand\nag@warn[1]{% + [2007/11/10 v0.2 treat complaints as errors (ulmi)] +\DeclareRobustCommand\nag@warn[1]{% \addtocounter{nag@sins}{1}% \PackageError{nag}{#1}{#1}% } -\renewcommand\nag@warnNoLine[1]{% +\DeclareRobustCommand\nag@warnNoLine[1]{% \addtocounter{nag@sins}{1}% \PackageError{nag}{#1}{#1}% } -% % \end{macrocode} +%\iffalse +% %<*experimentalnag> +%\fi %\subsection{\texttt{nag-experimental.cfg}} % Functionality that needs more testing. % \begin{macrocode} \ProvidesFile{nag-experimental.cfg} - [2007/06/10 v0.1b experimental additions to nag (ulmi)] + [2008/02/02 v0.1d experimental additions to nag (ulmi)] +% \end{macrocode} +% Check if a float that may be positioned b is actually small +% enough for bottomfraction etc. +% \begin{macrocode} +\let\@xa\expandafter +\newif\ifnag@dofloatsizecheck +\newcommand\nag@allfloatsizechecks{}% +\newcommand\nag@onefloatsizecheck[2]{% + % #1 is size fraction of textheight, + % #2 is position to say in warning. + \ifdim \ht\@currbox>#1\textheight + \@tempdima -#1\textheight + \advance \@tempdima \ht\@currbox + \PackageInfo{nag}{Float too large for #2 by \the\@tempdima}% + % note we do not truncate. + % also, it's too late to add "p" now. + \fi +} +% \@currbox is current float box, +% \@fps is the current list of float specifiers. +\renewcommand\@largefloatcheck{% + \ifdim \ht\@currbox>\textheight + \@tempdima -\textheight + \advance \@tempdima \ht\@currbox + \@latex@warning {Float too large for page by \the\@tempdima}% + \ht\@currbox \textheight + \fi + %% the preceding is the original check. + \nag@dofloatsizechecktrue + \def\nag@allfloatsizechecks{}% + \@xa\@tfor\@xa\nag@fltsz@tmp\@xa:\@xa=\@fps\do{% + \if\nag@fltsz@tmp ! + \nag@dofloatsizecheckfalse + \else + \if\nag@fltsz@tmp t + \g@addto@macro\nag@allfloatsizechecks + {\nag@onefloatsizecheck{\topfraction}{top of page}}% + \else + \if\nag@fltsz@tmp b + \g@addto@macro\nag@allfloatsizechecks + {\nag@onefloatsizecheck{\bottomfraction}{bottom of page}}% + \fi + \fi + \fi + }% + \ifnag@dofloatsizecheck\nag@allfloatsizechecks\fi +}% +% \end{macrocode} +% More experimental code: warning about files that were +% requested but not there. The really important one would +% be a check for include (this is just a typeout in the kernel?!). +% But as it is, we get warnings that point out missing ToC, LoF etc. +% \begin{macrocode} +\def\@input#1{% + \IfFileExists{#1}{\@@input\@filef@und}{% + \typeout{No file #1.} + \@latex@warning{File `#1' not found} + %{The file `#1' was requested but not found } + \protected@edef\nag@nofile{File `#1' requested, but not found}% + \@xa\AtEndDocument\@xa{% + \@xa\@latex@info@no@line\@xa{% + \nag@nofile + }% + }% +}}% +% +\def\@input@#1{\InputIfFileExists{#1}{}{% + \typeout{No file #1.} + \@latex@warning{File `#1' not found} + {The file `#1' was requested but not found } + \edef\nag@nofile{File `#1' requested, but not found}% + \@xa\AtEndDocument\@xa{% + \@xa\@latex@info@no@line\@xa{% + \nag@nofile + }% + }% +}}% +% % \end{macrocode} +%\iffalse % % %<*nag> +%\fi % \section{Author-side considerations and implementation.} % If you are a package or class author and want to extend the range % of \pkg{nag} (or prevent \pkg{nag} from criticizing @@ -536,7 +675,7 @@ unsuited for closing the center command above. % Identify ourselves. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{nag}[2007/06/10 0.60 warning about old commands (ulmi)] +\ProvidesPackage{nag}[2008/02/10 0.61 warning about old commands (ulmi)] \let\@xa\expandafter \let\@nx\noexpand % \end{macrocode} @@ -544,9 +683,16 @@ unsuited for closing the center command above. % generate running numbers for replacement macros, the latter is % stepped for each complaint we have, so that the user gets a % frighteningly high number, showing how sinful he or she is. +% \changes{0.61alpha1}{2007/11/10}{roman counter (external file issue)} +% \changes{0.61alpha4}{2008/01/01}{sin counter should not be saved by include} % \begin{macrocode} \newcounter{nag@c} -\newcounter{nag@sins} +\renewcommand\thenag@c{\roman{nag@c}}% +\setcounter{nag@c}{1}% +\begingroup + \let\@addtoreset\@gobbletwo + \newcounter{nag@sins}% +\endgroup % \end{macrocode} % % \begin{macro}{\nag@prepend} @@ -574,6 +720,9 @@ unsuited for closing the center command above. % \changes{0.60alpha2}{2007/04/08}{don't even relax unknown % commands (J.Sommer)} % \dots but \emph{do} log a message. +% \changes{0.61alpha1}{2007/11/10}{Extra indirection of warnings +% for robustness (uppercasing/LoF issues)} +% \changes{0.61alpha2}{2007/11/26}{Creep under existing robust cover} % \begin{macrocode} \newcommand\nag@prepend[2]{% \nag@ifundefined{#1}{% @@ -582,11 +731,24 @@ unsuited for closing the center command above. Command \@backslashchar#1\space not defined, skipping amendment% }% }{% + \nag@ifundefined{#1 }{% + \let\nag@maybespace\@empty + }{% + \let\nag@maybespace\space + %\PackageInfo{nag}{% + % Command \@backslashchar#1\space appears robust\MessageBreak + % Modifying `\@backslashchar#1\space' instead. + %}% + }% \@xa\let \csname nag@@#1@\thenag@c\@xa\endcsname - \csname #1\endcsname - \@xa\nag@pr@p@nd\csname #1\@xa\endcsname - \csname nag@@#1@\thenag@c\endcsname{#2}% + \csname #1\nag@maybespace\endcsname + \@xa\DeclareRobustCommand\csname nag@@warning@\thenag@c\@xa\endcsname{% + #2% + }% + \@xa\nag@pr@p@nd\csname #1\nag@maybespace\@xa\endcsname + \csname nag@@#1@\thenag@c\@xa\endcsname + \csname nag@@warning@\thenag@c\@xa\endcsname % \end{macrocode} % Fun with scoping: one might think we can get away with a (non-local) % |\advance\c@nag@c 1\relax| here. This would lead to less hashtable @@ -605,12 +767,13 @@ unsuited for closing the center command above. % \begin{macro}{\nag@warn} % All complaints to the user run through one of these two macros, % with or without source line. +% \changes{0.61alpha1}{2007/11/10}{Made robust.} % \begin{macrocode} -\newcommand\nag@warn{% +\DeclareRobustCommand\nag@warn{% \addtocounter{nag@sins}{1}% \PackageWarning{nag}% } -\newcommand\nag@warnNoLine{% +\DeclareRobustCommand\nag@warnNoLine{% \addtocounter{nag@sins}{1}% \PackageWarningNoLine{nag}% } @@ -1265,6 +1428,15 @@ unsuited for closing the center command above. % of the figure may exceed \cmd{\textwidth} without warning.) If this % bothers you, go read the warning on p.~\pageref{disclaimer} again. % +% \subsection{Version control packages} +% Common version control systems like rcs, cvs, svn insert their keywords +% between dollar signs. Packages that parse these keywords define their +% commands and usually assume catcode 3, which is not true if either +% \pkg{onlyamsmath} or \pkg{nag} is loaded. Special handling is +% introduced for \pkg{rcs} and \pkg{svninfo}. In case of \pkg{rcsinfo}, +% \pkg{svn} and \pkg{pgf} (yes, it's got internal VC handling that fails +% when \cmd{\pgfuselibrary} is used outside the preamble -- thanks to +% Ralf Th\"ole for spotting this one), dollar checking is disabled. % % \section{Loading extensions} % Finally, we deal with package options. @@ -1290,7 +1462,9 @@ unsuited for closing the center command above. } \ProcessOptions* % \end{macrocode} +%\iffalse % +%\fi % \PrintChanges %\PrintIndex %\Finale diff --git a/Master/texmf-dist/source/latex/nag/nag.ins b/Master/texmf-dist/source/latex/nag/nag.ins index 28ecaab65a5..d317aa777c3 100644 --- a/Master/texmf-dist/source/latex/nag/nag.ins +++ b/Master/texmf-dist/source/latex/nag/nag.ins @@ -10,7 +10,7 @@ This file is part of the `nag' package. The `nag' package has the LPPL maintenance status: maintained. Current Maintainer is Ulrich M. Schwarz, ulmi@absatzen.de -Copyright (C) 2005-7 by Ulrich M. Schwarz. +Copyright (C) 2005-8 by Ulrich M. Schwarz. This file may be distributed and/or modified under the conditions of the LaTeX Project Public License, either @@ -47,4 +47,4 @@ http://www.latex-project.org/lppl.txt \Msg{latex nagdemo} \Msg{* Happy TeXing!} \Msg{*********************************************************} -\endbatchfile \ No newline at end of file +\endbatchfile -- cgit v1.2.3