Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint2 lint: rename lint2 functions to be more ...
details: https://anonhg.NetBSD.org/src/rev/a6335267fe7d
branches: trunk
changeset: 373030:a6335267fe7d
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jan 14 08:48:18 2023 +0000
description:
lint: rename lint2 functions to be more expressive
diffstat:
tests/usr.bin/xlint/lint2/msg_001.ln | 4 +-
usr.bin/xlint/lint2/chk.c | 184 +++++++++++++++++-----------------
usr.bin/xlint/lint2/externs2.h | 6 +-
usr.bin/xlint/lint2/main2.c | 12 +-
4 files changed, 103 insertions(+), 103 deletions(-)
diffs (truncated from 631 to 300 lines):
diff -r e41184a5433e -r a6335267fe7d tests/usr.bin/xlint/lint2/msg_001.ln
--- a/tests/usr.bin/xlint/lint2/msg_001.ln Fri Jan 13 21:47:48 2023 +0000
+++ b/tests/usr.bin/xlint/lint2/msg_001.ln Sat Jan 14 08:48:18 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: msg_001.ln,v 1.5 2022/10/01 10:04:06 rillig Exp $
+# $NetBSD: msg_001.ln,v 1.6 2023/01/14 08:48:18 rillig Exp $
#
# Test data for message 1 of lint2:
# %s defined( %s ), but never used
@@ -17,7 +17,7 @@
12 d 0.12 e 4main F I
# If a function is declared once in old-style and once with prototype,
-# the prototype definition is preferred; see chkname.
+# the prototype definition is preferred; see check_name.
#
# extern merge_old_style_and_prototype();
20 d 0.20 e 29merge_old_style_and_prototype F I
diff -r e41184a5433e -r a6335267fe7d usr.bin/xlint/lint2/chk.c
--- a/usr.bin/xlint/lint2/chk.c Fri Jan 13 21:47:48 2023 +0000
+++ b/usr.bin/xlint/lint2/chk.c Sat Jan 14 08:48:18 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: chk.c,v 1.52 2022/10/01 09:42:40 rillig Exp $ */
+/* $NetBSD: chk.c,v 1.53 2023/01/14 08:48:18 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: chk.c,v 1.52 2022/10/01 09:42:40 rillig Exp $");
+__RCSID("$NetBSD: chk.c,v 1.53 2023/01/14 08:48:18 rillig Exp $");
#endif
#include <ctype.h>
@@ -48,23 +48,23 @@
#include "lint2.h"
-static void chkund(const hte_t *);
-static void chkdnu(const hte_t *);
-static void chkdnud(const hte_t *);
-static void chkmd(const hte_t *);
+static void check_used_not_defined(const hte_t *);
+static void check_defined_not_used(const hte_t *);
+static void check_declared_not_used_or_defined(const hte_t *);
+static void check_multiple_definitions(const hte_t *);
static void chkvtui(const hte_t *, sym_t *, sym_t *);
static void chkvtdi(const hte_t *, sym_t *, sym_t *);
static void chkfaui(const hte_t *, sym_t *, sym_t *);
static void chkau(const hte_t *, int, sym_t *, sym_t *, pos_t *,
fcall_t *, fcall_t *, type_t *, type_t *);
-static void chkrvu(const hte_t *, sym_t *);
-static void chkadecl(const hte_t *, sym_t *, sym_t *);
+static void check_return_values(const hte_t *, sym_t *);
+static void check_argument_declarations(const hte_t *, sym_t *, sym_t *);
static void printflike(const hte_t *, fcall_t *, int, const char *, type_t **);
static void scanflike(const hte_t *, fcall_t *, int, const char *, type_t **);
-static void badfmt(const hte_t *, fcall_t *);
-static void inconarg(const hte_t *, fcall_t *, int);
-static void tofewarg(const hte_t *, fcall_t *);
-static void tomanyarg(const hte_t *, fcall_t *);
+static void bad_format_string(const hte_t *, fcall_t *);
+static void inconsistent_arguments(const hte_t *, fcall_t *, int);
+static void too_few_arguments(const hte_t *, fcall_t *);
+static void too_many_arguments(const hte_t *, fcall_t *);
static bool types_compatible(type_t *, type_t *, bool, bool, bool, bool *);
static bool prototypes_compatible(type_t *, type_t *, bool *);
static bool matches_no_arg_function(type_t *, bool *);
@@ -74,7 +74,7 @@
* If there is a symbol named "main", mark it as used.
*/
void
-mainused(void)
+mark_main_as_used(void)
{
hte_t *hte;
@@ -86,17 +86,17 @@
* Performs all tests for a single name
*/
void
-chkname(const hte_t *hte)
+check_name(const hte_t *hte)
{
sym_t *sym, *def, *pdecl, *decl;
if (uflag) {
- chkund(hte);
- chkdnu(hte);
+ check_used_not_defined(hte);
+ check_defined_not_used(hte);
if (xflag)
- chkdnud(hte);
+ check_declared_not_used_or_defined(hte);
}
- chkmd(hte);
+ check_multiple_definitions(hte);
/* Get definition, prototype declaration and declaration */
def = pdecl = decl = NULL;
@@ -122,16 +122,16 @@
chkfaui(hte, def, decl);
- chkrvu(hte, def);
+ check_return_values(hte, def);
- chkadecl(hte, def, decl);
+ check_argument_declarations(hte, def, decl);
}
/*
* Print a warning if the name has been used, but not defined.
*/
static void
-chkund(const hte_t *hte)
+check_used_not_defined(const hte_t *hte)
{
fcall_t *fcall;
usym_t *usym;
@@ -152,7 +152,7 @@
* Print a warning if the name has been defined, but never used.
*/
static void
-chkdnu(const hte_t *hte)
+check_defined_not_used(const hte_t *hte)
{
sym_t *sym;
@@ -173,7 +173,7 @@
* or defined.
*/
static void
-chkdnud(const hte_t *hte)
+check_declared_not_used_or_defined(const hte_t *hte)
{
sym_t *sym;
@@ -185,7 +185,7 @@
return;
if (sym->s_def != DECL)
- errx(1, "internal error: chkdnud() 1");
+ errx(1, "internal error: check_declared_not_used_or_defined");
/* %s declared( %s ), but never used or defined */
msg(2, hte->h_name, mkpos(&sym->s_pos));
}
@@ -195,7 +195,7 @@
* this name.
*/
static void
-chkmd(const hte_t *hte)
+check_multiple_definitions(const hte_t *hte)
{
sym_t *sym, *def1;
char *pos1;
@@ -619,11 +619,11 @@
for (;;) {
if (fc == '\0') {
if (*ap != NULL)
- tomanyarg(hte, call);
+ too_many_arguments(hte, call);
break;
}
if (fc != '%') {
- badfmt(hte, call);
+ bad_format_string(hte, call);
break;
}
fc = *fp++;
@@ -666,12 +666,12 @@
fwidth = true;
fc = *fp++;
if ((tp = *ap++) == NULL) {
- tofewarg(hte, call);
+ too_few_arguments(hte, call);
break;
}
n++;
if ((t1 = tp->t_tspec) != INT && (hflag || t1 != UINT))
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
}
/* precision */
@@ -683,14 +683,14 @@
} else if (fc == '*') {
fc = *fp++;
if ((tp = *ap++) == NULL) {
- tofewarg(hte, call);
+ too_few_arguments(hte, call);
break;
}
n++;
if (tp->t_tspec != INT)
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
} else {
- badfmt(hte, call);
+ bad_format_string(hte, call);
break;
}
}
@@ -710,19 +710,19 @@
if (fc == '%') {
if (sz != NOTSPEC || left || sign || space ||
alt || zero || prec || fwidth) {
- badfmt(hte, call);
+ bad_format_string(hte, call);
}
fc = *fp++;
continue;
}
if (fc == '\0') {
- badfmt(hte, call);
+ bad_format_string(hte, call);
break;
}
if ((tp = *ap++) == NULL) {
- tofewarg(hte, call);
+ too_few_arguments(hte, call);
break;
}
n++;
@@ -731,45 +731,45 @@
if (fc == 'd' || fc == 'i') {
if (alt || sz == LDOUBLE) {
- badfmt(hte, call);
+ bad_format_string(hte, call);
break;
}
int_conv:
if (sz == LONG) {
if (t1 != LONG && (hflag || t1 != ULONG))
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
} else if (sz == QUAD) {
if (t1 != QUAD && (hflag || t1 != UQUAD))
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
} else {
/*
* SHORT is always promoted to INT, USHORT
* to INT or UINT.
*/
if (t1 != INT && (hflag || t1 != UINT))
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
}
} else if (fc == 'o' || fc == 'u' || fc == 'x' || fc == 'X') {
if ((alt && fc == 'u') || sz == LDOUBLE)
- badfmt(hte, call);
+ bad_format_string(hte, call);
uint_conv:
if (sz == LONG) {
if (t1 != ULONG && (hflag || t1 != LONG))
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
} else if (sz == QUAD) {
if (t1 != UQUAD && (hflag || t1 != QUAD))
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
} else if (sz == SHORT) {
/* USHORT was promoted to INT or UINT */
if (t1 != UINT && t1 != INT)
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
} else {
if (t1 != UINT && (hflag || t1 != INT))
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
}
} else if (fc == 'D' || fc == 'O' || fc == 'U') {
if ((alt && fc != 'O') || sz != NOTSPEC || !tflag)
- badfmt(hte, call);
+ bad_format_string(hte, call);
sz = LONG;
if (fc == 'D') {
goto int_conv;
@@ -781,43 +781,43 @@
if (sz == NOTSPEC)
sz = DOUBLE;
if (sz != DOUBLE && sz != LDOUBLE)
- badfmt(hte, call);
+ bad_format_string(hte, call);
if (t1 != sz)
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
} else if (fc == 'c') {
if (sz != NOTSPEC || alt || zero)
- badfmt(hte, call);
+ bad_format_string(hte, call);
if (t1 != INT)
- inconarg(hte, call, n);
+ inconsistent_arguments(hte, call, n);
Home |
Main Index |
Thread Index |
Old Index