Module Name: src Committed By: rillig Date: Sat Aug 12 18:05:52 UTC 2023
Modified Files: src/usr.bin/xlint/common: lint.h src/usr.bin/xlint/lint1: cgram.y check-msgs.lua Log Message: lint: clean up To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.470 -r1.471 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.19 -r1.20 src/usr.bin/xlint/lint1/check-msgs.lua 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/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.42 src/usr.bin/xlint/common/lint.h:1.43 --- src/usr.bin/xlint/common/lint.h:1.42 Thu Jul 13 08:40:38 2023 +++ src/usr.bin/xlint/common/lint.h Sat Aug 12 18:05:51 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lint.h,v 1.42 2023/07/13 08:40:38 rillig Exp $ */ +/* $NetBSD: lint.h,v 1.43 2023/08/12 18:05:51 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -142,14 +142,6 @@ typedef enum { DEF /* defined */ } def_t; -/* Some data used for the output buffer. */ -typedef struct ob { - char *o_buf; /* buffer */ - char *o_end; /* first byte after buffer */ - size_t o_len; /* length of buffer */ - char *o_next; /* next free byte in buffer */ -} ob_t; - #if defined(IS_LINT1) typedef struct lint1_type type_t; #else Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.470 src/usr.bin/xlint/lint1/cgram.y:1.471 --- src/usr.bin/xlint/lint1/cgram.y:1.470 Thu Aug 3 18:48:42 2023 +++ src/usr.bin/xlint/lint1/cgram.y Sat Aug 12 18:05:51 2023 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.470 2023/08/03 18:48:42 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.471 2023/08/12 18:05:51 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: cgram.y,v 1.470 2023/08/03 18:48:42 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.471 2023/08/12 18:05:51 rillig Exp $"); #endif #include <limits.h> @@ -358,7 +358,6 @@ is_either(const char *s, const char *a, %type <y_sym> direct_notype_param_declarator %type <y_parameter_list> param_list /* No type for id_list_lparen. */ -/* No type for abstract_decl_lparen. */ %type <y_array_size> array_size_opt %type <y_tnode> array_size %type <y_sym> identifier_list Index: src/usr.bin/xlint/lint1/check-msgs.lua diff -u src/usr.bin/xlint/lint1/check-msgs.lua:1.19 src/usr.bin/xlint/lint1/check-msgs.lua:1.20 --- src/usr.bin/xlint/lint1/check-msgs.lua:1.19 Mon Jul 10 11:46:14 2023 +++ src/usr.bin/xlint/lint1/check-msgs.lua Sat Aug 12 18:05:51 2023 @@ -1,5 +1,5 @@ #! /usr/bin/lua --- $NetBSD: check-msgs.lua,v 1.19 2023/07/10 11:46:14 rillig Exp $ +-- $NetBSD: check-msgs.lua,v 1.20 2023/08/12 18:05:51 rillig Exp $ --[[ @@ -130,6 +130,8 @@ end local function check_yacc_file(filename) local decl = {} + local decl_list = {} + local decl_list_index = 1 local f = assert(io.open(filename, "r")) local lineno = 0 for line in f:lines() do @@ -137,7 +139,12 @@ local function check_yacc_file(filename) local type = line:match("^%%type%s+<[%w_]+>%s+(%S+)$") or line:match("^/%* No type for ([%w_]+)%. %*/$") if type then + if decl[type] then + print_error("%s:%d: duplicate type declaration for rule %q", + filename, lineno, type) + end decl[type] = lineno + table.insert(decl_list, { lineno = lineno, rule = type }) end local rule = line:match("^([%w_]+):") if rule then @@ -147,6 +154,16 @@ local function check_yacc_file(filename) print_error("%s:%d: missing type declaration for rule %q", filename, lineno, rule) end + if decl_list_index > 0 then + local expected = decl_list[decl_list_index] + if expected.rule == rule then + decl_list_index = decl_list_index + 1 + else + print_error("%s:%d: expecting rule %q (from line %d), got %q", + filename, lineno, expected.rule, expected.lineno, rule) + decl_list_index = 0 + end + end end end for rule, decl_lineno in pairs(decl) do