Module Name: src Committed By: rillig Date: Fri Jan 1 01:26:02 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: cgram.y check-msgs.lua decl.c scan.l Log Message: lint: align comments with actual message, in the lexer and parser To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.2 -r1.3 src/usr.bin/xlint/lint1/check-msgs.lua cvs rdiff -u -r1.88 -r1.89 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.105 -r1.106 src/usr.bin/xlint/lint1/scan.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.122 src/usr.bin/xlint/lint1/cgram.y:1.123 --- src/usr.bin/xlint/lint1/cgram.y:1.122 Wed Dec 30 13:17:42 2020 +++ src/usr.bin/xlint/lint1/cgram.y Fri Jan 1 01:26:02 2021 @@ -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 @@ ext_decl: 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 @@ data_def: 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_with_rbrace: } | 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_with_opt_comma: } | 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 @@ vararg_parameter_type_list: } | 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; Index: src/usr.bin/xlint/lint1/check-msgs.lua diff -u src/usr.bin/xlint/lint1/check-msgs.lua:1.2 src/usr.bin/xlint/lint1/check-msgs.lua:1.3 --- src/usr.bin/xlint/lint1/check-msgs.lua:1.2 Fri Jan 1 00:00:24 2021 +++ src/usr.bin/xlint/lint1/check-msgs.lua Fri Jan 1 01:26:02 2021 @@ -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 @@ local function check_message(fname, line 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 @@ local function check_message(fname, line 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 @@ local function collect_errors(fname, msg 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) Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.88 src/usr.bin/xlint/lint1/decl.c:1.89 --- src/usr.bin/xlint/lint1/decl.c:1.88 Fri Jan 1 00:00:24 2021 +++ src/usr.bin/xlint/lint1/decl.c Fri Jan 1 01:26:02 2021 @@ -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 @@ declarator_1_struct_union(sym_t *dsym) */ 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 @@ add_array(sym_t *decl, int dim, int n) 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); Index: src/usr.bin/xlint/lint1/scan.l diff -u src/usr.bin/xlint/lint1/scan.l:1.105 src/usr.bin/xlint/lint1/scan.l:1.106 --- src/usr.bin/xlint/lint1/scan.l:1.105 Wed Dec 30 11:56:10 2020 +++ src/usr.bin/xlint/lint1/scan.l Fri Jan 1 01:26:02 2021 @@ -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 @@ getescc(int d) switch (c = inpc()) { case '"': if (tflag && d == '\'') - /* \" inside character constant undef. ... */ + /* \" inside character constants undef... */ warning(262); return '"'; case '\'': @@ -1067,7 +1067,7 @@ getescc(int d) 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; }