Module Name:    src
Committed By:   rillig
Date:           Sun Jul  3 07:33:09 UTC 2022

Modified Files:
        src/usr.bin/xlint/lint1: check-msgs.lua func.c

Log Message:
lint: verify that comment above warning_at matches the message

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint1/check-msgs.lua
cvs rdiff -u -r1.142 -r1.143 src/usr.bin/xlint/lint1/func.c

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/check-msgs.lua
diff -u src/usr.bin/xlint/lint1/check-msgs.lua:1.13 src/usr.bin/xlint/lint1/check-msgs.lua:1.14
--- src/usr.bin/xlint/lint1/check-msgs.lua:1.13	Thu Dec 16 21:14:58 2021
+++ src/usr.bin/xlint/lint1/check-msgs.lua	Sun Jul  3 07:33:08 2022
@@ -1,5 +1,5 @@
 #! /usr/bin/lua
--- $NetBSD: check-msgs.lua,v 1.13 2021/12/16 21:14:58 rillig Exp $
+-- $NetBSD: check-msgs.lua,v 1.14 2022/07/03 07:33:08 rillig Exp $
 
 --[[
 
@@ -61,6 +61,15 @@ local function check_message(fname, line
     fname, lineno, id, msg, comment)
 end
 
+local is_message_function = {
+  error = true,
+  error_at = true,
+  warning = true,
+  warning_at = true,
+  c99ism = true,
+  c11ism = true,
+  gnuism = true,
+}
 
 local function check_file(fname, msgs)
   local f = assert(io.open(fname, "r"))
@@ -69,11 +78,9 @@ local function check_file(fname, msgs)
   for line in f:lines() do
     lineno = lineno + 1
 
-    local func, id = line:match("^%s+(%w+)%((%d+)[),]")
-    id = tonumber(id)
-    if func == "error" or func == "warning" or
-       func == "c99ism" or func == "c11ism" or
-       func == "gnuism" or func == "message" then
+    local func, id = line:match("^%s+([%w_]+)%((%d+)[),]")
+    if is_message_function[func] then
+      id = tonumber(id)
       local comment = prev:match("^%s+/%* (.+) %*/$")
       if comment ~= nil then
         check_message(fname, lineno, id, comment, msgs)

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.142 src/usr.bin/xlint/lint1/func.c:1.143
--- src/usr.bin/xlint/lint1/func.c:1.142	Wed Jun 22 19:23:17 2022
+++ src/usr.bin/xlint/lint1/func.c	Sun Jul  3 07:33:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.142 2022/06/22 19:23:17 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.143 2022/07/03 07:33:08 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: func.c,v 1.142 2022/06/22 19:23:17 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.143 2022/07/03 07:33:08 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1152,7 +1152,7 @@ global_clean_up_decl(bool silent)
 	}
 	if (scanflike_argnum != -1) {
 		if (!silent) {
-			/* must precede function definition: ** %s ** */
+			/* comment ** %s ** must precede function definition */
 			warning_at(282, &scanflike_pos, "SCANFLIKE");
 		}
 		scanflike_argnum = -1;

Reply via email to