Module Name: src Committed By: rillig Date: Sat Mar 2 09:32:19 UTC 2024
Modified Files: src/usr.bin/xlint/common: lint.h src/usr.bin/xlint/lint1: decl.c emit1.c err.c lex.c src/usr.bin/xlint/lint2: chk.c emit2.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: remove custom wrappers around <ctype.h> functions To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.393 -r1.394 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.88 -r1.89 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.226 -r1.227 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.220 -r1.221 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.65 -r1.66 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.37 -r1.38 src/usr.bin/xlint/lint2/emit2.c cvs rdiff -u -r1.90 -r1.91 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.122 -r1.123 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.48 src/usr.bin/xlint/common/lint.h:1.49 --- src/usr.bin/xlint/common/lint.h:1.48 Thu Feb 1 18:37:06 2024 +++ src/usr.bin/xlint/common/lint.h Sat Mar 2 09:32:18 2024 @@ -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; -} Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.393 src/usr.bin/xlint/lint1/decl.c:1.394 --- src/usr.bin/xlint/lint1/decl.c:1.393 Thu Feb 8 20:59:19 2024 +++ src/usr.bin/xlint/lint1/decl.c Sat Mar 2 09:32:18 2024 @@ -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 *sy 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 s 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 */ Index: src/usr.bin/xlint/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.88 src/usr.bin/xlint/lint1/emit1.c:1.89 --- src/usr.bin/xlint/lint1/emit1.c:1.88 Fri Mar 1 21:52:48 2024 +++ src/usr.bin/xlint/lint1/emit1.c Sat Mar 2 09:32:18 2024 @@ -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 */ 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); Index: src/usr.bin/xlint/lint1/err.c diff -u src/usr.bin/xlint/lint1/err.c:1.226 src/usr.bin/xlint/lint1/err.c:1.227 --- src/usr.bin/xlint/lint1/err.c:1.226 Fri Mar 1 19:39:28 2024 +++ src/usr.bin/xlint/lint1/err.c Sat Mar 2 09:32:18 2024 @@ -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]) || Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.220 src/usr.bin/xlint/lint1/lex.c:1.221 --- src/usr.bin/xlint/lint1/lex.c:1.220 Fri Mar 1 21:52:48 2024 +++ src/usr.bin/xlint/lint1/lex.c Sat Mar 2 09:32:18 2024 @@ -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'; Index: src/usr.bin/xlint/lint2/chk.c diff -u src/usr.bin/xlint/lint2/chk.c:1.65 src/usr.bin/xlint/lint2/chk.c:1.66 --- src/usr.bin/xlint/lint2/chk.c:1.65 Sun Dec 3 18:17:41 2023 +++ src/usr.bin/xlint/lint2/chk.c Sat Mar 2 09:32:18 2024 @@ -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 *ca } /* 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 *ca 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 *cal 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') { Index: src/usr.bin/xlint/lint2/emit2.c diff -u src/usr.bin/xlint/lint2/emit2.c:1.37 src/usr.bin/xlint/lint2/emit2.c:1.38 --- src/usr.bin/xlint/lint2/emit2.c:1.37 Sun Dec 3 18:17:41 2023 +++ src/usr.bin/xlint/lint2/emit2.c Sat Mar 2 09:32:19 2024 @@ -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'); Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.90 src/usr.bin/xlint/lint2/read.c:1.91 --- src/usr.bin/xlint/lint2/read.c:1.90 Sun Dec 3 18:17:41 2023 +++ src/usr.bin/xlint/lint2/read.c Sat Mar 2 09:32:19 2024 @@ -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; } Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.122 src/usr.bin/xlint/xlint/xlint.c:1.123 --- src/usr.bin/xlint/xlint/xlint.c:1.122 Sat Jan 20 12:02:10 2024 +++ src/usr.bin/xlint/xlint/xlint.c Sat Mar 2 09:32:19 2024 @@ -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