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: extract suppress_messages from main
details: https://anonhg.NetBSD.org/src/rev/36fad1648e8f
branches: trunk
changeset: 985302:36fad1648e8f
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Aug 17 22:29:11 2021 +0000
description:
lint: extract suppress_messages from main
No functional change.
diffstat:
usr.bin/xlint/lint1/main1.c | 43 ++++++++++++++++++++++---------------------
1 files changed, 22 insertions(+), 21 deletions(-)
diffs (74 lines):
diff -r b463bdc0ce36 -r 36fad1648e8f usr.bin/xlint/lint1/main1.c
--- a/usr.bin/xlint/lint1/main1.c Tue Aug 17 22:00:26 2021 +0000
+++ b/usr.bin/xlint/lint1/main1.c Tue Aug 17 22:29:11 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main1.c,v 1.55 2021/08/17 21:19:02 rillig Exp $ */
+/* $NetBSD: main1.c,v 1.56 2021/08/17 22:29:11 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.55 2021/08/17 21:19:02 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.56 2021/08/17 22:29:11 rillig Exp $");
#endif
#include <sys/types.h>
@@ -168,11 +168,28 @@
fpe = 1;
}
+static void
+suppress_messages(char *ids)
+{
+ char *ptr, *end;
+ long id;
+
+ for (ptr = strtok(ids, ","); ptr != NULL; ptr = strtok(NULL, ",")) {
+ errno = 0;
+ id = strtol(ptr, &end, 0);
+ if ((id == TARG_LONG_MIN || id == TARG_LONG_MAX) &&
+ errno == ERANGE)
+ err(1, "invalid error message id '%s'", ptr);
+ if (*end != '\0' || ptr == end || id < 0 || id >= ERR_SETSIZE)
+ errx(1, "invalid error message id '%s'", ptr);
+ ERR_SET(id, &msgset);
+ }
+}
+
int
main(int argc, char *argv[])
{
- int c;
- char *ptr;
+ int c;
setprogname(argv[0]);
@@ -217,23 +234,7 @@
break;
case 'X':
- for (ptr = strtok(optarg, ","); ptr != NULL;
- ptr = strtok(NULL, ",")) {
- char *eptr;
- long msg;
-
- errno = 0;
- msg = strtol(ptr, &eptr, 0);
- if ((msg == TARG_LONG_MIN || msg == TARG_LONG_MAX) &&
- errno == ERANGE)
- err(1, "invalid error message id '%s'",
- ptr);
- if (*eptr != '\0' || ptr == eptr || msg < 0 ||
- msg >= ERR_SETSIZE)
- errx(1, "invalid error message id '%s'",
- ptr);
- ERR_SET(msg, &msgset);
- }
+ suppress_messages(optarg);
break;
default:
usage();
Home |
Main Index |
Thread Index |
Old Index