lint: remove custom wrappers around <ctype.h> functions
This commit is contained in:
parent
0ec00ddcf5
commit
aa5782417b
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lint.h,v 1.48 2024/02/01 18:37:06 rillig Exp $ */
|
||||
/* $NetBSD: lint.h,v 1.49 2024/03/02 09:32:18 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
|
@ -161,33 +161,3 @@ typedef struct lint2_type type_t;
|
|||
#endif
|
||||
|
||||
#include "externs.h"
|
||||
|
||||
static inline bool
|
||||
ch_isalnum(char ch)
|
||||
{
|
||||
return isalnum((unsigned char)ch) != 0;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
ch_isdigit(char ch)
|
||||
{
|
||||
return isdigit((unsigned char)ch) != 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: decl.c,v 1.393 2024/02/08 20:59:19 rillig Exp $ */
|
||||
/* $NetBSD: decl.c,v 1.394 2024/03/02 09:32: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: decl.c,v 1.393 2024/02/08 20:59:19 rillig Exp $");
|
||||
__RCSID("$NetBSD: decl.c,v 1.394 2024/03/02 09:32:18 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -1776,7 +1776,7 @@ check_extern_declaration(const sym_t *sym)
|
|||
dcs->d_redeclared_symbol == NULL &&
|
||||
ends_with(curr_pos.p_file, ".c") &&
|
||||
allow_c90 &&
|
||||
!ch_isdigit(sym->s_name[0]) && /* see mktempsym */
|
||||
!isdigit((unsigned char)sym->s_name[0]) && /* see mktempsym */
|
||||
strcmp(sym->s_name, "main") != 0) {
|
||||
/* missing%s header declaration for '%s' */
|
||||
warning(351, sym->s_type->t_tspec == FUNC ? "" : " 'extern'",
|
||||
|
@ -2873,7 +2873,7 @@ check_variable_usage(bool novar, const sym_t *sym)
|
|||
lint_assert(block_level != 0);
|
||||
|
||||
/* example at file scope: int c = ({ return 3; }); */
|
||||
if (sym->s_block_level == 0 && ch_isdigit(sym->s_name[0]))
|
||||
if (sym->s_block_level == 0 && isdigit((unsigned char)sym->s_name[0]))
|
||||
return;
|
||||
|
||||
/* errors in expressions easily cause lots of these warnings */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: emit1.c,v 1.88 2024/03/01 21:52:48 rillig Exp $ */
|
||||
/* $NetBSD: emit1.c,v 1.89 2024/03/02 09:32: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: emit1.c,v 1.88 2024/03/01 21:52:48 rillig Exp $");
|
||||
__RCSID("$NetBSD: emit1.c,v 1.89 2024/03/02 09:32:18 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -185,7 +185,7 @@ outsym(const sym_t *sym, scl_t sc, def_t def)
|
|||
*/
|
||||
if (sc != EXTERN && !(sc == STATIC && sym->s_type->t_tspec == FUNC))
|
||||
return;
|
||||
if (ch_isdigit(sym->s_name[0])) /* 00000000_tmp */
|
||||
if (isdigit((unsigned char)sym->s_name[0])) /* 00000000_tmp */
|
||||
return;
|
||||
|
||||
outint(csrc_pos.p_line);
|
||||
|
@ -392,7 +392,7 @@ static void
|
|||
outqchar(char c)
|
||||
{
|
||||
|
||||
if (ch_isprint(c) && c != '\\' && c != '"' && c != '\'') {
|
||||
if (isprint((unsigned char)c) && c != '\\' && c != '"' && c != '\'') {
|
||||
outchar(c);
|
||||
return;
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ outfstrg(const char *cp)
|
|||
}
|
||||
|
||||
/* numeric field width */
|
||||
while (ch_isdigit(c)) {
|
||||
while (isdigit((unsigned char)c)) {
|
||||
outchar(c);
|
||||
c = *cp++;
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ outfstrg(const char *cp)
|
|||
outchar(c);
|
||||
c = *cp++;
|
||||
} else {
|
||||
while (ch_isdigit(c)) {
|
||||
while (isdigit((unsigned char)c)) {
|
||||
outchar(c);
|
||||
c = *cp++;
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ outfstrg(const char *cp)
|
|||
void
|
||||
outusg(const sym_t *sym)
|
||||
{
|
||||
if (ch_isdigit(sym->s_name[0])) /* 00000000_tmp, from mktempsym */
|
||||
if (isdigit((unsigned char)sym->s_name[0])) /* see mktempsym */
|
||||
return;
|
||||
|
||||
outint(csrc_pos.p_line);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: err.c,v 1.226 2024/03/01 19:39:28 rillig Exp $ */
|
||||
/* $NetBSD: err.c,v 1.227 2024/03/02 09:32:18 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID)
|
||||
__RCSID("$NetBSD: err.c,v 1.226 2024/03/01 19:39:28 rillig Exp $");
|
||||
__RCSID("$NetBSD: err.c,v 1.227 2024/03/02 09:32:18 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
@ -446,7 +446,7 @@ suppress_messages(const char *p)
|
|||
{
|
||||
char *end;
|
||||
|
||||
for (; ch_isdigit(*p); p = end + 1) {
|
||||
for (; isdigit((unsigned char)*p); p = end + 1) {
|
||||
unsigned long id = strtoul(p, &end, 10);
|
||||
if ((*end != '\0' && *end != ',') ||
|
||||
id >= sizeof(msgs) / sizeof(msgs[0]) ||
|
||||
|
@ -765,7 +765,7 @@ enable_queries(const char *p)
|
|||
{
|
||||
char *end;
|
||||
|
||||
for (; ch_isdigit(*p); p = end + 1) {
|
||||
for (; isdigit((unsigned char)*p); p = end + 1) {
|
||||
unsigned long id = strtoul(p, &end, 10);
|
||||
if ((*end != '\0' && *end != ',') ||
|
||||
id >= sizeof(queries) / sizeof(queries[0]) ||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lex.c,v 1.220 2024/03/01 21:52:48 rillig Exp $ */
|
||||
/* $NetBSD: lex.c,v 1.221 2024/03/02 09:32: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: lex.c,v 1.220 2024/03/01 21:52:48 rillig Exp $");
|
||||
__RCSID("$NetBSD: lex.c,v 1.221 2024/03/02 09:32:18 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -1034,11 +1034,11 @@ parse_line_directive_flags(const char *p,
|
|||
*is_system = false;
|
||||
|
||||
while (*p != '\0') {
|
||||
while (ch_isspace(*p))
|
||||
while (isspace((unsigned char)*p))
|
||||
p++;
|
||||
|
||||
const char *word = p;
|
||||
while (*p != '\0' && !ch_isspace(*p))
|
||||
while (*p != '\0' && !isspace((unsigned char)*p))
|
||||
p++;
|
||||
size_t len = (size_t)(p - word);
|
||||
|
||||
|
@ -1082,8 +1082,9 @@ lex_directive(const char *yytext)
|
|||
while (*p == ' ' || *p == '\t')
|
||||
p++;
|
||||
|
||||
if (!ch_isdigit(*p)) {
|
||||
if (strncmp(p, "pragma", 6) == 0 && ch_isspace(p[6]))
|
||||
if (!isdigit((unsigned char)*p)) {
|
||||
if (strncmp(p, "pragma", 6) == 0
|
||||
&& isspace((unsigned char)p[6]))
|
||||
return;
|
||||
goto error;
|
||||
}
|
||||
|
@ -1178,12 +1179,12 @@ lex_comment(void)
|
|||
l = 0;
|
||||
while (c != EOF && l < sizeof(keywd) - 1 &&
|
||||
(isalpha(c) || isspace(c))) {
|
||||
if (islower(c) && l > 0 && ch_isupper(keywd[0]))
|
||||
if (islower(c) && l > 0 && isupper((unsigned char)keywd[0]))
|
||||
break;
|
||||
keywd[l++] = (char)c;
|
||||
c = read_byte();
|
||||
}
|
||||
while (l > 0 && ch_isspace(keywd[l - 1]))
|
||||
while (l > 0 && isspace((unsigned char)keywd[l - 1]))
|
||||
l--;
|
||||
keywd[l] = '\0';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: chk.c,v 1.65 2023/12/03 18:17:41 rillig Exp $ */
|
||||
/* $NetBSD: chk.c,v 1.66 2024/03/02 09:32: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.65 2023/12/03 18:17:41 rillig Exp $");
|
||||
__RCSID("$NetBSD: chk.c,v 1.66 2024/03/02 09:32:18 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -642,9 +642,9 @@ printflike(const hte_t *hte, fcall_t *call, int n, const char *fmt, type_t **ap)
|
|||
}
|
||||
|
||||
/* field width */
|
||||
if (ch_isdigit(fc)) {
|
||||
if (isdigit((unsigned char)fc)) {
|
||||
fwidth = true;
|
||||
do { fc = *fp++; } while (ch_isdigit(fc));
|
||||
do { fc = *fp++; } while (isdigit((unsigned char)fc));
|
||||
} else if (fc == '*') {
|
||||
fwidth = true;
|
||||
fc = *fp++;
|
||||
|
@ -661,8 +661,10 @@ printflike(const hte_t *hte, fcall_t *call, int n, const char *fmt, type_t **ap)
|
|||
if (fc == '.') {
|
||||
fc = *fp++;
|
||||
prec = true;
|
||||
if (ch_isdigit(fc)) {
|
||||
do { fc = *fp++; } while (ch_isdigit(fc));
|
||||
if (isdigit((unsigned char)fc)) {
|
||||
do {
|
||||
fc = *fp++;
|
||||
} while (isdigit((unsigned char)fc));
|
||||
} else if (fc == '*') {
|
||||
fc = *fp++;
|
||||
if ((tp = *ap++) == NULL) {
|
||||
|
@ -844,9 +846,9 @@ scanflike(const hte_t *hte, fcall_t *call, int n, const char *fmt, type_t **ap)
|
|||
fc = *fp++;
|
||||
}
|
||||
|
||||
if (ch_isdigit(fc)) {
|
||||
if (isdigit((unsigned char)fc)) {
|
||||
fwidth = true;
|
||||
do { fc = *fp++; } while (ch_isdigit(fc));
|
||||
do { fc = *fp++; } while (isdigit((unsigned char)fc));
|
||||
}
|
||||
|
||||
if (fc == 'h') {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: emit2.c,v 1.37 2023/12/03 18:17:41 rillig Exp $ */
|
||||
/* $NetBSD: emit2.c,v 1.38 2024/03/02 09:32:19 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID)
|
||||
__RCSID("$NetBSD: emit2.c,v 1.37 2023/12/03 18:17:41 rillig Exp $");
|
||||
__RCSID("$NetBSD: emit2.c,v 1.38 2024/03/02 09:32:19 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include "lint2.h"
|
||||
|
@ -60,7 +60,7 @@ outtype(type_t *tp)
|
|||
tspec_t ts = tp->t_tspec;
|
||||
if (ts == INT && tp->t_is_enum)
|
||||
ts = ENUM;
|
||||
if (!ch_isupper(tt[ts]))
|
||||
if (!isupper((unsigned char)tt[ts]))
|
||||
errx(1, "internal error: outtype(%d)", ts);
|
||||
if (tp->t_const)
|
||||
outchar('c');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: read.c,v 1.90 2023/12/03 18:17:41 rillig Exp $ */
|
||||
/* $NetBSD: read.c,v 1.91 2024/03/02 09:32:19 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID)
|
||||
__RCSID("$NetBSD: read.c,v 1.90 2023/12/03 18:17:41 rillig Exp $");
|
||||
__RCSID("$NetBSD: read.c,v 1.91 2024/03/02 09:32:19 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -692,7 +692,7 @@ inptype(const char *cp, const char **epp)
|
|||
break;
|
||||
case FUNC:
|
||||
c = *cp;
|
||||
if (ch_isdigit(c)) {
|
||||
if (isdigit((unsigned char)c)) {
|
||||
if (!osdef)
|
||||
tp->t_proto = true;
|
||||
narg = parse_int(&cp);
|
||||
|
@ -881,7 +881,7 @@ gettlen(const char *cp, const char **epp)
|
|||
break;
|
||||
case FUNC:
|
||||
c = *cp;
|
||||
if (ch_isdigit(c)) {
|
||||
if (isdigit((unsigned char)c)) {
|
||||
narg = parse_int(&cp);
|
||||
for (i = 0; i < narg; i++) {
|
||||
if (i == narg - 1 && *cp == 'E')
|
||||
|
@ -1091,7 +1091,7 @@ inpname(const char *cp, const char **epp)
|
|||
buf = xrealloc(buf, blen = len + 1);
|
||||
for (i = 0; i < len; i++) {
|
||||
c = *cp++;
|
||||
if (!ch_isalnum(c) && c != '_')
|
||||
if (!isalnum((unsigned char)c) && c != '_')
|
||||
inperr("not alnum or _: %c", c);
|
||||
buf[i] = c;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: xlint.c,v 1.122 2024/01/20 12:02:10 rillig Exp $ */
|
||||
/* $NetBSD: xlint.c,v 1.123 2024/03/02 09:32:19 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID)
|
||||
__RCSID("$NetBSD: xlint.c,v 1.122 2024/01/20 12:02:10 rillig Exp $");
|
||||
__RCSID("$NetBSD: xlint.c,v 1.123 2024/03/02 09:32:19 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -257,9 +257,9 @@ static bool
|
|||
is_safe_shell(char ch)
|
||||
{
|
||||
|
||||
return ch_isalnum(ch) || ch == '%' || ch == '+' || ch == ',' ||
|
||||
ch == '-' || ch == '.' || ch == '/' || ch == ':' ||
|
||||
ch == '=' || ch == '@' || ch == '_';
|
||||
return isalnum((unsigned char)ch)
|
||||
|| ch == '%' || ch == '+' || ch == ',' || ch == '-' || ch == '.'
|
||||
|| ch == '/' || ch == ':' || ch == '=' || ch == '@' || ch == '_';
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue