[tex-live] Possible lacheck Bug Report

Karl Berry karl at freefriends.org
Tue Jul 9 00:24:26 CEST 2019


Hi Zayd,

Thanks again for this report:

    \documentclass{report}

    \newcommand{\defaultleftmargin}{0.25in}

    \begin{document}
    \end{document}

    I get the following errors with lacheck:
    "hw01.tex", line 5: <- unmatched "end of file hw01.tex"
    "hw01.tex", line 2: -> unmatched "{"
    
    ... The issue only seems to arise when \newcommand is followed by
    {\def*}
    https://tug.org/pipermail/tex-live/2019-January/043083.html

I just committed the following change to lacheck.l (r51585). Although
lex can't come to parsing all valid TeX definitions, at least it doesn't
gratuitiously fail on your example any more.

I will also change the version number, etc. The new version will be
released with TL'20, although perhaps some distros will pick it up
sooner. --best, karl.

--- lacheck.l	(revision 51577)
+++ lacheck.l	(working copy)
@@ -371,8 +375,27 @@
     BEGIN(INITIAL); 
   }}
 
-"\\"[exg]?(def|newcommand)[^\n\{]+ 	BEGIN(DEF);
+  /* \def can be followed by whitespace, then the \ to start the control
+     sequence, then more or less anything up to the { starting the
+     replacement text, which we assume is on the same line. (All this
+     could be changed in TeX, with catcodes etc., but we can't try to
+     handle that.) */
+"\\"[exg]?def[ \t\n]*"\\"[^\n{]+\{	BEGIN(DEF);
 
+  /* \newcommand{\foo}{...} or \newcommand\foo{...}
+       (or \renewcommand or \providecommand).
+     To allow for arbitrary control sequence names, we match
+       the braced name as anything not containing a }.
+     To handle optional argument specifications, we assume the { is on
+       the same line as the csname.
+     We don't do anything with the definitions; the only purpose is to
+       count braces. */
+"\\"(provide|(re)?newcommand)[ \t\n]*(\{\\[^}]+\}|\\)[^{]*\{	BEGIN(DEF);
+
+  /* Pre-2019 rule was (see test-def.tex):
+     "\\"[exg]?(def|newcommand)[^\n\{]+ 	BEGIN(DEF);
+  */
+
 <DEF>{b_group} { ++def_count; }
 


More information about the tex-live mailing list