Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: align comments with actual message...



details:   https://anonhg.NetBSD.org/src/rev/ec672faaef84
branches:  trunk
changeset: 1017575:ec672faaef84
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jan 01 01:26:02 2021 +0000

description:
lint: align comments with actual message, in the lexer and parser

diffstat:

 usr.bin/xlint/lint1/cgram.y        |  26 +++++++++++++-------------
 usr.bin/xlint/lint1/check-msgs.lua |  12 ++++++------
 usr.bin/xlint/lint1/decl.c         |   8 ++++----
 usr.bin/xlint/lint1/scan.l         |   8 ++++----
 4 files changed, 27 insertions(+), 27 deletions(-)

diffs (205 lines):

diff -r ebbd8d4d4a51 -r ec672faaef84 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Fri Jan 01 01:07:07 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Fri Jan 01 01:26:02 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.122 2020/12/30 13:17:42 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.123 2021/01/01 01:26:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.122 2020/12/30 13:17:42 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.123 2021/01/01 01:26:02 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -365,19 +365,19 @@
 data_def:
          T_SEMI {
                if (sflag) {
-                       /* syntax error: empty declaration */
+                       /* empty declaration */
                        error(0);
                } else if (!tflag) {
-                       /* syntax error: empty declaration */
+                       /* empty declaration */
                        warning(0);
                }
          }
        | clrtyp deftyp notype_init_decls T_SEMI {
                if (sflag) {
-                       /* old style declaration; add "int" */
+                       /* old style declaration; add int */
                        error(1);
                } else if (!tflag) {
-                       /* old style declaration; add "int" */
+                       /* old style declaration; add int */
                        warning(1);
                }
          }
@@ -412,7 +412,7 @@
 func_def:
          func_decl {
                if ($1->s_type->t_tspec != FUNC) {
-                       /* syntax error */
+                       /* syntax error '%s' */
                        error(249, yytext);
                        YYERROR;
                }
@@ -756,10 +756,10 @@
          }
        | member_declaration_list T_RBRACE {
                if (sflag) {
-                       /* syntax req. ";" after last struct/union member */
+                       /* syntax req. ';' after last struct/union member */
                        error(66);
                } else {
-                       /* syntax req. ";" after last struct/union member */
+                       /* syntax req. ';' after last struct/union member */
                        warning(66);
                }
                $$ = $1;
@@ -949,10 +949,10 @@
          }
        | enums T_COMMA {
                if (sflag) {
-                       /* trailing "," prohibited in enum declaration */
+                       /* trailing ',' prohibited in enum declaration */
                        error(54);
                } else {
-                       /* trailing "," prohibited in enum declaration */
+                       /* trailing ',' prohibited in enum declaration */
                        c99ism(54);
                }
                $$ = $1;
@@ -1256,10 +1256,10 @@
          }
        | T_ELLIPSE {
                if (sflag) {
-                       /* ANSI C requires formal parameter before "..." */
+                       /* ANSI C requires formal parameter before '...' */
                        error(84);
                } else if (!tflag) {
-                       /* ANSI C requires formal parameter before "..." */
+                       /* ANSI C requires formal parameter before '...' */
                        warning(84);
                }
                dcs->d_vararg = 1;
diff -r ebbd8d4d4a51 -r ec672faaef84 usr.bin/xlint/lint1/check-msgs.lua
--- a/usr.bin/xlint/lint1/check-msgs.lua        Fri Jan 01 01:07:07 2021 +0000
+++ b/usr.bin/xlint/lint1/check-msgs.lua        Fri Jan 01 01:26:02 2021 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/lua
--- $NetBSD: check-msgs.lua,v 1.2 2021/01/01 00:00:24 rillig Exp $
+-- $NetBSD: check-msgs.lua,v 1.3 2021/01/01 01:26:02 rillig Exp $
 
 --[[
 
@@ -38,6 +38,7 @@
 
   msg = string.gsub(msg, "/%*", "**")
   msg = string.gsub(msg, "%*/", "**")
+  msg = string.gsub(msg, "\\(.)", "%1")
   comment = string.gsub(comment, "arg%.", "argument")
   comment = string.gsub(comment, "bitop%.", "bitwise operation")
   comment = string.gsub(comment, "comb%.", "combination")
@@ -49,6 +50,7 @@
   comment = string.gsub(comment, "incomp%.", "incompatible")
   comment = string.gsub(comment, "init%.", "initialize")
   comment = string.gsub(comment, "param%.", "parameter")
+  comment = string.gsub(comment, "req%.", "requires")
   comment = string.gsub(comment, "poss%.", "possibly")
   comment = string.gsub(comment, "trad%.", "traditional")
 
@@ -77,11 +79,9 @@
   for line in f:lines() do
     lineno = lineno + 1
 
-    local id = line:match("^%s+warning%((%d+)[),]")
-    if id == nil then
-      id = line:match("^%s+error%((%d+)[),]")
-    end
-    if id ~= nil then
+    local func, id = line:match("^%s+(%w+)%((%d+)[),]")
+    if func == "error" or func == "warning" or func == "c99ism" or
+       func == "gnuism" or func == "message" then
       local comment = prev:match("^%s+/%* (.+) %*/$")
       if comment ~= nil then
         check_message(fname, lineno, tonumber(id), comment, msgs, errors)
diff -r ebbd8d4d4a51 -r ec672faaef84 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Fri Jan 01 01:07:07 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Fri Jan 01 01:26:02 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.88 2021/01/01 00:00:24 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.89 2021/01/01 01:26:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.88 2021/01/01 00:00:24 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.89 2021/01/01 01:26:02 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1176,7 +1176,7 @@
         */
        if ((sz = length(dsym->s_type, dsym->s_name)) == 0) {
                if (t == ARRAY && dsym->s_type->t_dim == 0) {
-                       /* illegal zero sized structure member: %s */
+                       /* zero sized array in struct is a C99 extension: %s */
                        c99ism(39, dsym->s_name);
                }
        }
@@ -1351,7 +1351,7 @@
                error(20, n);
                n = 0;
        } else if (n == 0 && dim) {
-               /* zero array dimension */
+               /* zero sized array is a C99 extension */
                c99ism(322, dim);
        } else if (n == 0 && !dim) {
                setcomplete(tp, 0);
diff -r ebbd8d4d4a51 -r ec672faaef84 usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Fri Jan 01 01:07:07 2021 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Fri Jan 01 01:26:02 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.105 2020/12/30 11:56:10 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.106 2021/01/01 01:26:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.105 2020/12/30 11:56:10 rillig Exp $");
+__RCSID("$NetBSD: scan.l,v 1.106 2021/01/01 01:26:02 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -1018,7 +1018,7 @@
                switch (c = inpc()) {
                case '"':
                        if (tflag && d == '\'')
-                               /* \" inside character constant undef. ... */
+                               /* \" inside character constants undef... */
                                warning(262);
                        return '"';
                case '\'':
@@ -1067,7 +1067,7 @@
                                warning(77, c);
                        pbc = c;
                        if (v > TARG_UCHAR_MAX) {
-                               /* character escape does not fit in char. */
+                               /* character escape does not fit in character */
                                warning(76);
                                v &= CHAR_MASK;
                        }



Home | Main Index | Thread Index | Old Index