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: allow 'fallthrough' as alternative...



details:   https://anonhg.NetBSD.org/src/rev/a5a960edb658
branches:  trunk
changeset: 1023199:a5a960edb658
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 29 09:29:32 2021 +0000

description:
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.

diffstat:

 tests/usr.bin/xlint/lint1/msg_220.c   |  9 ++++++---
 tests/usr.bin/xlint/lint1/msg_220.exp |  7 +++----
 usr.bin/xlint/common/lint.h           |  4 +++-
 usr.bin/xlint/lint1/lex.c             |  9 ++++++---
 4 files changed, 18 insertions(+), 11 deletions(-)

diffs (101 lines):

diff -r 55fe9f1a475c -r a5a960edb658 tests/usr.bin/xlint/lint1/msg_220.c
--- a/tests/usr.bin/xlint/lint1/msg_220.c       Sun Aug 29 09:17:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_220.c       Sun Aug 29 09:29:32 2021 +0000
@@ -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 @@
                /* 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 @@
                /* 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");
        }
diff -r 55fe9f1a475c -r a5a960edb658 tests/usr.bin/xlint/lint1/msg_220.exp
--- a/tests/usr.bin/xlint/lint1/msg_220.exp     Sun Aug 29 09:17:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_220.exp     Sun Aug 29 09:29:32 2021 +0000
@@ -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]
diff -r 55fe9f1a475c -r a5a960edb658 usr.bin/xlint/common/lint.h
--- a/usr.bin/xlint/common/lint.h       Sun Aug 29 09:17:58 2021 +0000
+++ b/usr.bin/xlint/common/lint.h       Sun Aug 29 09:29:32 2021 +0000
@@ -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 @@
 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; }
diff -r 55fe9f1a475c -r a5a960edb658 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sun Aug 29 09:17:58 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sun Aug 29 09:29:32 2021 +0000
@@ -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 @@
                { "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 @@
        /* 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();
        }



Home | Main Index | Thread Index | Old Index