]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Use isascii_c() functions instead of isascii(3)
authorAlejandro Colomar <alx@kernel.org>
Fri, 2 Jan 2026 20:29:27 +0000 (21:29 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Thu, 11 Jun 2026 07:33:53 +0000 (09:33 +0200)
We want to use the C locale.

Reported-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/getrange.c
lib/port.c
lib/string/ctype/strchrisascii/strchriscntrl.h
lib/string/ctype/strisascii/strisdigit.h
lib/string/ctype/strisascii/strisprint.h
src/newusers.c

index a7f8f0596379d75e5180ac4172a0fee46bad9bf6..a7dd844f6710671a042df939f55a51fcc26ebd62 100644 (file)
@@ -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;  /* <long>- */
 parse_max:
-               if (!isdigit((unsigned char) *end))
+               if (!isdigit_c(*end))
                        return -1;
 
                if (a2ul(max, end, NULL, 10, *min, ULONG_MAX) == -1)
index 8cf6f39fb9f87c395364f6ff9e4f4d8f66938bbd..cde50b27e23219d7763805912161c5c7904de5dc 100644 (file)
@@ -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';
                }
 
index a1eaca371e65738372d3ab44f1b4d64cee7ab23a..8fe6e0575255b57291480659a4afd90e2f0715ee 100644 (file)
@@ -8,24 +8,23 @@
 
 #include "config.h"
 
-#include <ctype.h>
 #include <stdbool.h>
 
+#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;
        }
 
index 0c5175fc8d509e61516a5873921f4e77e4579613..1e4f69d2cd64150bcf7a7a30cadf151b26d65387 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <stdbool.h>
 
+#include "string/ctype/isascii.h"
 #include "string/strcmp/streq.h"
 #include "string/strspn/stpspn.h"
 
 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), "");
 }
 
 
index 566dbf886d47dcd10ade8301982b8a318087cfe7..652c6544d3d83c95962256d99053909f91d34d9b 100644 (file)
@@ -8,17 +8,16 @@
 
 #include "config.h"
 
-#include <ctype.h>
 #include <stdbool.h>
 
+#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;
        }
 
index 6bae4b343399137360399125c64346f27db474df..a8df7c1b759dbf140db54fcdb2c817a6f432b13c 100644 (file)
@@ -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"),