summaryrefslogtreecommitdiff
path: root/Build/source/utils/lacheck/lacheck.l
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-04-30 22:15:57 +0000
committerKarl Berry <karl@freefriends.org>2022-04-30 22:15:57 +0000
commitcc0e78841ae3591c7722907be141237b32066d20 (patch)
treeb9ec103c2667c98773a4f3ce93f195c3db744fd1 /Build/source/utils/lacheck/lacheck.l
parentc672bfbc647851808b23bd991236f0eb93f2b404 (diff)
count initial { of definitions; more \newcommand features
git-svn-id: svn://tug.org/texlive/trunk@63190 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/lacheck/lacheck.l')
-rw-r--r--Build/source/utils/lacheck/lacheck.l44
1 files changed, 32 insertions, 12 deletions
diff --git a/Build/source/utils/lacheck/lacheck.l b/Build/source/utils/lacheck/lacheck.l
index 1ef06376e3e..3d698040875 100644
--- a/Build/source/utils/lacheck/lacheck.l
+++ b/Build/source/utils/lacheck/lacheck.l
@@ -4,7 +4,7 @@
*
* Copyright (C) 1991, 1992 Kresten Krab Thorup.
* Copyright (C) 1993 --- 1998 Per Abrahamsen.
- * Copyright (C) 2019 Karl Berry.
+ * Copyright (C) 2019 --- 2022 Karl Berry.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,6 +24,11 @@
* Created On : Sun May 26 18:11:58 1991
*
* HISTORY
+ * 01-May-2022 Karl Berry
+ * Count initial { of definitions, and more \newcommand features.
+ * Report from Michael Clark,
+ * https://tug.org/pipermail/tex-live/2022-April/048096.html.
+ * Version number now 1.30.
* 08-Jul-2019 Karl Berry
* Separate patterns for \def vs. \newcommand. Report from Zayd Hammoudeh,
* https://tug.org/pipermail/tex-live/2019-January/043083.html.
@@ -373,24 +378,31 @@ symbol ("$"("\\"{atoz}+|.)"$"|"\\#"|"\\$"|"\\%"|"\\ref")
BEGIN(INITIAL);
}}
- /* \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);
+ /* \def (or \edef etc.) 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{]+\{ { ++def_count; BEGIN(DEF); }
/* \newcommand{\foo}{...} or \newcommand\foo{...}
- (or \renewcommand or \providecommand).
+ or \renewcommand or \providecommand;
+ and/or with \...command*;
+ and/or with \...command[N] argument count;
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
+ We assume the control sequence name is either a single character or
+ one or more English letters, a-zA-Z, as usual with TeX.
+ We assume the optional argument default does not contain a ].
+ We don't do anything with the definition; the only purpose is to
count braces. */
-"\\"(provide|(re)?newcommand)[ \t\n]*(\{\\[^}]+\}|\\)[^{]*\{ BEGIN(DEF);
+"\\"(provide|(re)?newcommand)[ \t\n]*(\*[ \t\n]*)?(\{\\[^}]+\}|\\([a-zA-Z]+|.))[ \t\n]*(\[[0-9]\](\[[^]]*\])?)?[ \t\n]*[^{]*\{ { ++def_count; BEGIN(DEF); }
- /* Pre-2019 rule was (see test-def.tex):
+ /* ws optional* ({\cs} |\cs) [N]? [dflt]? .* {defn}
+
+ Pre-2019 rule was (see test-def.tex):
"\\"[exg]?(def|newcommand)[^\n\{]+ BEGIN(DEF);
*/
@@ -760,6 +772,14 @@ symbol ("$"("\\"{atoz}+|.)"$"|"\\#"|"\\$"|"\\%"|"\\ref")
\\endinput/[^A-Za-z] |
<<EOF>> {
+ if (def_count != 0)
+ {
+ printf("\"%s\", line %d: %d missing right brace(s).\n",
+ file_name,
+ line_count,
+ def_count);
+ }
+
if (--istackp < 0)
yyterminate();
@@ -782,7 +802,7 @@ symbol ("$"("\\"{atoz}+|.)"$"|"\\#"|"\\$"|"\\%"|"\\ref")
%%
static void print_version (void)
{
- printf("%s (TeX Live) %s\n", PROGNAME, "1.29");
+ printf("%s (TeX Live) %s\n", PROGNAME, "1.30");
puts("$Id$");
printf("License GPLv1+: GNU GPL version 1 or later");
puts(" <https://gnu.org/licenses/gpl.html>.");