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: rename parameter to diagnostic fun...
details: https://anonhg.NetBSD.org/src/rev/9bdd782715aa
branches: trunk
changeset: 378611:9bdd782715aa
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Apr 18 10:09:49 2021 +0000
description:
lint: rename parameter to diagnostic functions and macros
The first parameter is not just an arbitrary number, it's a message ID.
diffstat:
usr.bin/xlint/lint1/err.c | 84 ++++++++++++++++++++++----------------------
usr.bin/xlint/lint1/lint1.h | 38 ++++++++++----------
2 files changed, 61 insertions(+), 61 deletions(-)
diffs (281 lines):
diff -r b96f3f3851a2 -r 9bdd782715aa usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Apr 18 10:04:23 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Apr 18 10:09:49 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.114 2021/04/18 10:02:16 rillig Exp $ */
+/* $NetBSD: err.c,v 1.115 2021/04/18 10:09:49 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.114 2021/04/18 10:02:16 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.115 2021/04/18 10:09:49 rillig Exp $");
#endif
#include <sys/types.h>
@@ -484,77 +484,77 @@ lbasename(const char *path)
}
static void
-verror_at(int n, pos_t pos, va_list ap)
+verror_at(int msgid, pos_t pos, va_list ap)
{
const char *fn;
- if (ERR_ISSET(n, &msgset))
+ if (ERR_ISSET(msgid, &msgset))
return;
fn = lbasename(pos.p_file);
(void)printf("%s(%d): error: ", fn, pos.p_line);
- (void)vprintf(msgs[n], ap);
- (void)printf(" [%d]\n", n);
+ (void)vprintf(msgs[msgid], ap);
+ (void)printf(" [%d]\n", msgid);
nerr++;
print_stack_trace();
}
static void
-vwarning_at(int n, pos_t pos, va_list ap)
+vwarning_at(int msgid, pos_t pos, va_list ap)
{
const char *fn;
- if (ERR_ISSET(n, &msgset))
+ if (ERR_ISSET(msgid, &msgset))
return;
#ifdef DEBUG
- printf("%s: lwarn=%d n=%d\n", __func__, lwarn, n);
+ printf("%s: lwarn=%d msgid=%d\n", __func__, lwarn, msgid);
#endif
- if (lwarn == LWARN_NONE || lwarn == n)
+ if (lwarn == LWARN_NONE || lwarn == msgid)
/* this warning is suppressed by a LINTED comment */
return;
fn = lbasename(pos.p_file);
(void)printf("%s(%d): warning: ", fn, pos.p_line);
- (void)vprintf(msgs[n], ap);
- (void)printf(" [%d]\n", n);
+ (void)vprintf(msgs[msgid], ap);
+ (void)printf(" [%d]\n", msgid);
if (wflag)
nerr++;
print_stack_trace();
}
static void
-vmessage_at(int n, pos_t pos, va_list ap)
+vmessage_at(int msgid, pos_t pos, va_list ap)
{
const char *fn;
- if (ERR_ISSET(n, &msgset))
+ if (ERR_ISSET(msgid, &msgset))
return;
fn = lbasename(pos.p_file);
(void)printf("%s(%d): ", fn, pos.p_line);
- (void)vprintf(msgs[n], ap);
- (void)printf(" [%d]\n", n);
+ (void)vprintf(msgs[msgid], ap);
+ (void)printf(" [%d]\n", msgid);
print_stack_trace();
}
void
-(error_at)(int n, pos_t pos, ...)
+(error_at)(int msgid, pos_t pos, ...)
{
va_list ap;
va_start(ap, pos);
- verror_at(n, pos, ap);
+ verror_at(msgid, pos, ap);
va_end(ap);
}
void
-(error)(int n, ...)
+(error)(int msgid, ...)
{
va_list ap;
- va_start(ap, n);
- verror_at(n, curr_pos, ap);
+ va_start(ap, msgid);
+ verror_at(msgid, curr_pos, ap);
va_end(ap);
}
@@ -589,42 +589,42 @@ assert_failed(const char *file, int line
}
void
-(warning_at)(int n, pos_t pos, ...)
+(warning_at)(int msgid, pos_t pos, ...)
{
va_list ap;
va_start(ap, pos);
- vwarning_at(n, pos, ap);
+ vwarning_at(msgid, pos, ap);
va_end(ap);
}
void
-(warning)(int n, ...)
+(warning)(int msgid, ...)
{
va_list ap;
- va_start(ap, n);
- vwarning_at(n, curr_pos, ap);
+ va_start(ap, msgid);
+ vwarning_at(msgid, curr_pos, ap);
va_end(ap);
}
void
-(message_at)(int n, pos_t pos, ...)
+(message_at)(int msgid, pos_t pos, ...)
{
va_list ap;
va_start(ap, pos);
- vmessage_at(n, pos, ap);
+ vmessage_at(msgid, pos, ap);
va_end(ap);
}
void
-(message)(int n, ...)
+(message)(int msgid, ...)
{
va_list ap;
- va_start(ap, n);
- vmessage_at(n, curr_pos, ap);
+ va_start(ap, msgid);
+ vmessage_at(msgid, curr_pos, ap);
va_end(ap);
}
@@ -635,42 +635,42 @@ void
* "right"... [perry, 2 Nov 2002]
*/
void
-(c99ism)(int n, ...)
+(c99ism)(int msgid, ...)
{
va_list ap;
bool extensions_ok = Sflag || gflag;
- va_start(ap, n);
+ va_start(ap, msgid);
if (sflag && !extensions_ok) {
- verror_at(n, curr_pos, ap);
+ verror_at(msgid, curr_pos, ap);
} else if (sflag || !extensions_ok) {
- vwarning_at(n, curr_pos, ap);
+ vwarning_at(msgid, curr_pos, ap);
}
va_end(ap);
}
void
-(c11ism)(int n, ...)
+(c11ism)(int msgid, ...)
{
va_list ap;
if (c11flag || gflag)
return;
- va_start(ap, n);
- verror_at(n, curr_pos, ap);
+ va_start(ap, msgid);
+ verror_at(msgid, curr_pos, ap);
va_end(ap);
}
void
-(gnuism)(int n, ...)
+(gnuism)(int msgid, ...)
{
va_list ap;
- va_start(ap, n);
+ va_start(ap, msgid);
if (sflag && !gflag) {
- verror_at(n, curr_pos, ap);
+ verror_at(msgid, curr_pos, ap);
} else if (sflag || !gflag) {
- vwarning_at(n, curr_pos, ap);
+ vwarning_at(msgid, curr_pos, ap);
}
va_end(ap);
}
diff -r b96f3f3851a2 -r 9bdd782715aa usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h Sun Apr 18 10:04:23 2021 +0000
+++ b/usr.bin/xlint/lint1/lint1.h Sun Apr 18 10:09:49 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.98 2021/04/18 10:04:23 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.99 2021/04/18 10:09:49 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -476,31 +476,31 @@ check_printf(const char *fmt, ...)
{
}
-# define wrap_check_printf_at(func, id, pos, args...) \
+# define wrap_check_printf_at(func, msgid, pos, args...) \
do { \
- check_printf(__CONCAT(MSG_, id), ##args); \
- (func)(id, pos, ##args); \
+ check_printf(__CONCAT(MSG_, msgid), ##args); \
+ (func)(msgid, pos, ##args); \
} while (/*CONSTCOND*/false)
-# define error_at(id, pos, args...) \
- wrap_check_printf_at(error_at, id, pos, ##args)
-# define warning_at(id, pos, args...) \
- wrap_check_printf_at(warning_at, id, pos, ##args)
-# define message_at(id, pos, args...) \
- wrap_check_printf_at(message_at, id, pos, ##args)
+# define error_at(msgid, pos, args...) \
+ wrap_check_printf_at(error_at, msgid, pos, ##args)
+# define warning_at(msgid, pos, args...) \
+ wrap_check_printf_at(warning_at, msgid, pos, ##args)
+# define message_at(msgid, pos, args...) \
+ wrap_check_printf_at(message_at, msgid, pos, ##args)
-# define wrap_check_printf(func, id, args...) \
+# define wrap_check_printf(func, msgid, args...) \
do { \
- check_printf(__CONCAT(MSG_, id), ##args); \
- (func)(id, ##args); \
+ check_printf(__CONCAT(MSG_, msgid), ##args); \
+ (func)(msgid, ##args); \
} while (/*CONSTCOND*/false)
-# define error(id, args...) wrap_check_printf(error, id, ##args)
-# define warning(id, args...) wrap_check_printf(warning, id, ##args)
-# define message(id, args...) wrap_check_printf(message, id, ##args)
-# define gnuism(id, args...) wrap_check_printf(gnuism, id, ##args)
-# define c99ism(id, args...) wrap_check_printf(c99ism, id, ##args)
-# define c11ism(id, args...) wrap_check_printf(c11ism, id, ##args)
+# define error(msgid, args...) wrap_check_printf(error, msgid, ##args)
+# define warning(msgid, args...) wrap_check_printf(warning, msgid, ##args)
+# define message(msgid, args...) wrap_check_printf(message, msgid, ##args)
+# define gnuism(msgid, args...) wrap_check_printf(gnuism, msgid, ##args)
+# define c99ism(msgid, args...) wrap_check_printf(c99ism, msgid, ##args)
+# define c11ism(msgid, args...) wrap_check_printf(c11ism, msgid, ##args)
#endif
static inline bool
Home |
Main Index |
Thread Index |
Old Index