Module Name: src Committed By: rillig Date: Sun Aug 29 09:29:32 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_220.c msg_220.exp src/usr.bin/xlint/common: lint.h src/usr.bin/xlint/lint1: lex.c Log Message: lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH Seen in unbound/lookup3.c. No change to the documentation since the canonical spelling is still the same. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_220.c cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_220.exp cvs rdiff -u -r1.30 -r1.31 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.79 -r1.80 src/usr.bin/xlint/lint1/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_220.c diff -u src/tests/usr.bin/xlint/lint1/msg_220.c:1.6 src/tests/usr.bin/xlint/lint1/msg_220.c:1.7 --- src/tests/usr.bin/xlint/lint1/msg_220.c:1.6 Sun Aug 29 09:09:53 2021 +++ src/tests/usr.bin/xlint/lint1/msg_220.c Sun Aug 29 09:29:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_220.c,v 1.6 2021/08/29 09:09:53 rillig Exp $ */ +/* $NetBSD: msg_220.c,v 1.7 2021/08/29 09:29:32 rillig Exp $ */ # 3 "msg_220.c" // Test for message: fallthrough on case statement [220] @@ -52,8 +52,9 @@ annotation_comment_variations(int n) /* FALLTHROUGH */ case 1: println("1"); + /* Seen in libarchive/archive_string.c, macro WRITE_UC. */ /* FALL THROUGH */ - /* Lint warned before 2021-08-29. */ + /* Lint warned before lex.c 1.79 from 2021-08-29. */ case 2: println("2"); /* FALLS THROUGH */ @@ -64,12 +65,14 @@ annotation_comment_variations(int n) /* expect+1: warning: fallthrough on case statement [220] */ case 4: println("4"); + /* This is the Splint variant, which is seldom used. */ /* @fallthrough@ */ /* expect+1: warning: fallthrough on case statement [220] */ case 5: println("5"); + /* Seen in unbound/lookup3.c, function hashlittle. */ + /* Lint warned before lex.c 1.80 from 2021-08-29. */ /* fallthrough */ - /* expect+1: warning: fallthrough on case statement [220] */ case 6: println("6"); } Index: src/tests/usr.bin/xlint/lint1/msg_220.exp diff -u src/tests/usr.bin/xlint/lint1/msg_220.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_220.exp:1.6 --- src/tests/usr.bin/xlint/lint1/msg_220.exp:1.5 Sun Aug 29 09:09:53 2021 +++ src/tests/usr.bin/xlint/lint1/msg_220.exp Sun Aug 29 09:29:32 2021 @@ -1,6 +1,5 @@ msg_220.c(19): warning: fallthrough on case statement [220] msg_220.c(22): warning: fallthrough on default statement [284] -msg_220.c(61): warning: fallthrough on case statement [220] -msg_220.c(65): warning: fallthrough on case statement [220] -msg_220.c(69): warning: fallthrough on case statement [220] -msg_220.c(73): warning: fallthrough on case statement [220] +msg_220.c(62): warning: fallthrough on case statement [220] +msg_220.c(66): warning: fallthrough on case statement [220] +msg_220.c(71): warning: fallthrough on case statement [220] Index: src/usr.bin/xlint/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.30 src/usr.bin/xlint/common/lint.h:1.31 --- src/usr.bin/xlint/common/lint.h:1.30 Sat Aug 28 12:59:25 2021 +++ src/usr.bin/xlint/common/lint.h Sun Aug 29 09:29:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint.h,v 1.30 2021/08/28 12:59:25 rillig Exp $ */ +/* $NetBSD: lint.h,v 1.31 2021/08/29 09:29:32 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -153,3 +153,5 @@ static inline bool ch_isprint(char ch) { return isprint((unsigned char)ch) != 0; } static inline bool ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; } +static inline bool +ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; } Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.79 src/usr.bin/xlint/lint1/lex.c:1.80 --- src/usr.bin/xlint/lint1/lex.c:1.79 Sun Aug 29 09:05:35 2021 +++ src/usr.bin/xlint/lint1/lex.c Sun Aug 29 09:29:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.79 2021/08/29 09:05:35 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.80 2021/08/29 09:29:32 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: lex.c,v 1.79 2021/08/29 09:05:35 rillig Exp $"); +__RCSID("$NetBSD: lex.c,v 1.80 2021/08/29 09:29:32 rillig Exp $"); #endif #include <ctype.h> @@ -1121,6 +1121,7 @@ lex_comment(void) { "FALLTHRU", false, fallthru }, { "FALLTHROUGH", false, fallthru }, { "FALL THROUGH", false, fallthru }, + { "fallthrough", false, fallthru }, { "LINTLIBRARY", false, lintlib }, { "LINTED", true, linted }, { "LONGLONG", false, longlong }, @@ -1146,7 +1147,9 @@ lex_comment(void) /* Read the potential keyword to keywd */ l = 0; while (c != EOF && l < sizeof(keywd) - 1 && - (isupper(c) || isspace(c))) { + (isalpha(c) || isspace(c))) { + if (islower(c) && l > 0 && ch_isupper(keywd[0])) + break; keywd[l++] = (char)c; c = inpc(); }