From: Alejandro Colomar Date: Fri, 2 Jan 2026 20:29:27 +0000 (+0100) Subject: lib/, src/: Use isascii_c() functions instead of isascii(3) X-Git-Tag: 4.20.0-rc1~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2563a7242ffc6f2d4f46427c0d0f1c8ddc856d52;p=thirdparty%2Fshadow.git lib/, src/: Use isascii_c() functions instead of isascii(3) We want to use the C locale. Reported-by: Tobias Stoeckmann Signed-off-by: Alejandro Colomar --- diff --git a/lib/getrange.c b/lib/getrange.c index a7f8f0596..a7dd844f6 100644 --- a/lib/getrange.c +++ b/lib/getrange.c @@ -13,6 +13,7 @@ #include "atoi/a2i.h" #include "defines.h" #include "prototypes.h" +#include "string/ctype/isascii.h" #include "string/strcmp/streq.h" @@ -57,7 +58,7 @@ getrange(const char *range, if (streq(end, "")) return 0; /* - */ parse_max: - if (!isdigit((unsigned char) *end)) + if (!isdigit_c(*end)) return -1; if (a2ul(max, end, NULL, 10, *min, ULONG_MAX) == -1) diff --git a/lib/port.c b/lib/port.c index 8cf6f39fb..cde50b27e 100644 --- a/lib/port.c +++ b/lib/port.c @@ -20,6 +20,7 @@ #include "io/fgets/fgets.h" #include "port.h" #include "prototypes.h" +#include "string/ctype/isascii.h" #include "string/strcmp/streq.h" #include "string/strcmp/strprefix.h" #include "string/strtok/stpsep.h" @@ -212,7 +213,7 @@ next: * week or the other two values. */ - for (i = 0; isalpha(cp[i]) && ('\0' != cp[i + 1]); i += 2) { + for (i = 0; isalpha_c(cp[i]) && ('\0' != cp[i + 1]); i += 2) { switch ((cp[i] << 8) | (cp[i + 1])) { case ('S' << 8) | 'u': port.pt_times[j].t_days |= 01; @@ -261,7 +262,7 @@ next: * representing the times of day. */ - for (dtime = 0; isdigit (cp[i]); i++) { + for (dtime = 0; isdigit_c(cp[i]); i++) { dtime = dtime * 10 + cp[i] - '0'; } @@ -271,7 +272,7 @@ next: port.pt_times[j].t_start = dtime; cp = cp + i + 1; - for (dtime = 0, i = 0; isdigit (cp[i]); i++) { + for (dtime = 0, i = 0; isdigit_c(cp[i]); i++) { dtime = dtime * 10 + cp[i] - '0'; } diff --git a/lib/string/ctype/strchrisascii/strchriscntrl.h b/lib/string/ctype/strchrisascii/strchriscntrl.h index a1eaca371..8fe6e0575 100644 --- a/lib/string/ctype/strchrisascii/strchriscntrl.h +++ b/lib/string/ctype/strchrisascii/strchriscntrl.h @@ -8,24 +8,23 @@ #include "config.h" -#include #include +#include "string/ctype/isascii.h" #include "string/strcmp/streq.h" inline bool strchriscntrl(const char *s); -// string character is [:cntrl:] -// Return true if any iscntrl(3) character is found in the string. +// strchriscntrl - string character is [:cntrl:] inline bool strchriscntrl(const char *s) { for (; !streq(s, ""); s++) { unsigned char c = *s; - if (iscntrl(c)) + if (iscntrl_c(c)) return true; } diff --git a/lib/string/ctype/strisascii/strisdigit.h b/lib/string/ctype/strisascii/strisdigit.h index 0c5175fc8..1e4f69d2c 100644 --- a/lib/string/ctype/strisascii/strisdigit.h +++ b/lib/string/ctype/strisascii/strisdigit.h @@ -10,6 +10,7 @@ #include +#include "string/ctype/isascii.h" #include "string/strcmp/streq.h" #include "string/strspn/stpspn.h" @@ -17,15 +18,14 @@ inline bool strisdigit(const char *s); -// string is [:digit:] -// Like isdigit(3), but check all characters in the string. +// strisdigit - string is [:digit:] inline bool strisdigit(const char *s) { if (streq(s, "")) return false; - return streq(stpspn(s, "0123456789"), ""); + return streq(stpspn(s, CTYPE_DIGIT_C), ""); } diff --git a/lib/string/ctype/strisascii/strisprint.h b/lib/string/ctype/strisascii/strisprint.h index 566dbf886..652c6544d 100644 --- a/lib/string/ctype/strisascii/strisprint.h +++ b/lib/string/ctype/strisascii/strisprint.h @@ -8,17 +8,16 @@ #include "config.h" -#include #include +#include "string/ctype/isascii.h" #include "string/strcmp/streq.h" inline bool strisprint(const char *s); -// string is [:print:] -// Like isprint(3), but check all characters in the string. +// strisprint - string is [:print:] inline bool strisprint(const char *s) { @@ -26,9 +25,7 @@ strisprint(const char *s) return false; for (; !streq(s, ""); s++) { - unsigned char c = *s; - - if (!isprint(c)) + if (!isprint_c(*s)) return false; } diff --git a/src/newusers.c b/src/newusers.c index 6bae4b343..a8df7c1b7 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -52,6 +52,7 @@ #include "shadow/gshadow/sgrp.h" #include "shadowlog.h" #include "sssd.h" +#include "string/ctype/isascii.h" #include "string/sprintf/stprintf.h" #include "string/strcmp/streq.h" #include "string/strdup/strdup.h" @@ -235,7 +236,7 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid) return 0; } - if (isdigit (gid[0])) { + if (isdigit_c(gid[0])) { /* * The GID is a number, which means either this is a brand * new group, or an existing group. @@ -279,7 +280,7 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid) /* * Now I have all of the fields required to create the new group. */ - if (!streq(gid, "") && (!isdigit(gid[0]))) { + if (!streq(gid, "") && (!isdigit_c(gid[0]))) { grent.gr_name = xstrdup (gid); } else { grent.gr_name = xstrdup (name); @@ -344,7 +345,7 @@ static int get_user_id (const char *uid, uid_t *nuid) { * The first guess for the UID is either the numerical UID that the * caller provided, or the next available UID. */ - if (isdigit (uid[0])) { + if (isdigit_c(uid[0])) { if ((get_uid(uid, nuid) == -1) || (*nuid == (uid_t)-1)) { fprintf (stderr, _("%s: invalid user ID '%s'\n"),