]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Merge directories "lib/string/ctype/*" into unified files
authorAlejandro Colomar <alx@kernel.org>
Fri, 2 Jan 2026 12:57:19 +0000 (13:57 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Thu, 11 Jun 2026 07:33:53 +0000 (09:33 +0200)
The APIs defined under each of those subdirs are too similar and related
that it makes more sense to define them in the same files.  (BTW, we
only had one API per subdir, except in one subdir that had two APIs, so
in the end, we have almost the same separation.)

Signed-off-by: Alejandro Colomar <alx@kernel.org>
14 files changed:
lib/Makefile.am
lib/chkname.c
lib/fields.c
lib/obscure.c
lib/string/README
lib/string/ctype/strchrisascii.c [moved from lib/string/ctype/strchrisascii/strchriscntrl.c with 79% similarity]
lib/string/ctype/strchrisascii.h [moved from lib/string/ctype/strchrisascii/strchriscntrl.h with 78% similarity]
lib/string/ctype/strisascii.c [moved from lib/string/ctype/strisascii/strisprint.c with 70% similarity]
lib/string/ctype/strisascii.h [moved from lib/string/ctype/strisascii/strisdigit.h with 58% similarity]
lib/string/ctype/strisascii/strisdigit.c [deleted file]
lib/string/ctype/strisascii/strisprint.h [deleted file]
lib/string/ctype/strtoascii.c [moved from lib/string/ctype/strtoascii/strtolower.c with 78% similarity]
lib/string/ctype/strtoascii.h [moved from lib/string/ctype/strtoascii/strtolower.h with 61% similarity]
lib/subordinateio.c

index f65e25622a1d45caf37b4175a4d7a32406d6b739..69bbd14db076ac6efd83f91231b455227ea2d1aa 100644 (file)
@@ -193,14 +193,12 @@ libshadow_la_SOURCES = \
        sssd.h \
        string/ctype/isascii.c \
        string/ctype/isascii.h \
-       string/ctype/strchrisascii/strchriscntrl.c \
-       string/ctype/strchrisascii/strchriscntrl.h \
-       string/ctype/strisascii/strisdigit.c \
-       string/ctype/strisascii/strisdigit.h \
-       string/ctype/strisascii/strisprint.c \
-       string/ctype/strisascii/strisprint.h \
-       string/ctype/strtoascii/strtolower.c \
-       string/ctype/strtoascii/strtolower.h \
+       string/ctype/strchrisascii.c \
+       string/ctype/strchrisascii.h \
+       string/ctype/strisascii.c \
+       string/ctype/strisascii.h \
+       string/ctype/strtoascii.c \
+       string/ctype/strtoascii.h \
        string/memset/memzero.c \
        string/memset/memzero.h \
        string/sprintf/aprintf.c \
index 853c3d7f50293739703be4a5ba0c5d363aedcedc..ad5d70db09cae66a388d012ccbffe8dcc45d8ab5 100644 (file)
@@ -33,8 +33,8 @@
 
 #include "defines.h"
 #include "chkname.h"
-#include "string/ctype/strchrisascii/strchriscntrl.h"
-#include "string/ctype/strisascii/strisdigit.h"
+#include "string/ctype/strchrisascii.h"
+#include "string/ctype/strisascii.h"
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strcaseeq.h"
 #include "sysconf.h"
index 759dea755f981c6ec46eb02d8b3fd77e370352da..77eb8c2d4f5fc08609c1bc40f9f88cb4417574bb 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "io/fgets/fgets.h"
 #include "prototypes.h"
-#include "string/ctype/strisascii/strisprint.h"
-#include "string/ctype/strchrisascii/strchriscntrl.h"
+#include "string/ctype/strisascii.h"
+#include "string/ctype/strchrisascii.h"
 #include "string/strcmp/streq.h"
 #include "string/strspn/stpspn.h"
 #include "string/strspn/stprspn.h"
index 9a53df85e346376fa669ed71b9cf4b8bcb6d374b..3f0a4ca668c375060d1fd82c100afd702067c109 100644 (file)
@@ -19,7 +19,7 @@
 #include "prototypes.h"
 #include "defines.h"
 #include "getdef.h"
-#include "string/ctype/strtoascii/strtolower.h"
+#include "string/ctype/strtoascii.h"
 #include "string/memset/memzero.h"
 #include "string/sprintf/aprintf.h"
 #include "string/strcmp/streq.h"
index 4ef415cbe4f67233911540fd8b92064d5ec40273..77b8b93162701ed44b35ffa07a2337f342fd1e89 100644 (file)
@@ -75,21 +75,21 @@ ctype/ - Character classification and conversion functions
        if the character
        belongs to the category specified in the function name.
 
-    strchrisascii/
-       The functions defined under this directory
+    strchrisascii.h
+       The functions defined in this file
        return true
        if the string has any characters that
        belong to the category specified in the function name.
 
-    strisascii/
-       The functions defined under this directory
+    strisascii.h
+       The functions defined in this file
        return true
        if all of the characters of the string
        belong to the category specified in the function name
        and the string is not an empty string.
 
-    strtoascii/
-       The functions defined under this directory
+    strtoascii.h
+       The functions defined in this file
        translate all characters in a string.
 
 memset/ - Memory zeroing
similarity index 79%
rename from lib/string/ctype/strchrisascii/strchriscntrl.c
rename to lib/string/ctype/strchrisascii.c
index ca77b4cfbaf028645c2a3cf554f5396594f45fa2..b9b7e919a9fda1db5cc8000eef54cf294014312b 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "config.h"
 
-#include "string/ctype/strchrisascii/strchriscntrl.h"
+#include "string/ctype/strchrisascii.h"
 
 #include <stdbool.h>
 
similarity index 78%
rename from lib/string/ctype/strchrisascii/strchriscntrl.h
rename to lib/string/ctype/strchrisascii.h
index 8fe6e0575255b57291480659a4afd90e2f0715ee..a2be4e321a81c54eb78a783f9220923e37fc1dc2 100644 (file)
@@ -2,8 +2,8 @@
 // SPDX-License-Identifier: BSD-3-Clause
 
 
-#ifndef SHADOW_INCLUDE_LIB_STRING_CTYPE_STRCHRISASCII_STRCHRISCNTRL_H_
-#define SHADOW_INCLUDE_LIB_STRING_CTYPE_STRCHRISASCII_STRCHRISCNTRL_H_
+#ifndef SHADOW_INCLUDE_LIB_STRING_CTYPE_STRCHRISASCII_H_
+#define SHADOW_INCLUDE_LIB_STRING_CTYPE_STRCHRISASCII_H_
 
 
 #include "config.h"
similarity index 70%
rename from lib/string/ctype/strisascii/strisprint.c
rename to lib/string/ctype/strisascii.c
index 47fb2a3bfe7fbab8c1e5cd3badd429f3935824ba..564dac25043fadb28e5c9b95e1f054d628688b95 100644 (file)
@@ -4,9 +4,10 @@
 
 #include "config.h"
 
-#include "string/ctype/strisascii/strisprint.h"
+#include "string/ctype/strisascii.h"
 
 #include <stdbool.h>
 
 
+extern inline bool strisdigit(const char *s);
 extern inline bool strisprint(const char *s);
similarity index 58%
rename from lib/string/ctype/strisascii/strisdigit.h
rename to lib/string/ctype/strisascii.h
index 1e4f69d2cd64150bcf7a7a30cadf151b26d65387..1ee66c2fe3a9df5bf00fd43ae9bc6097949a7169 100644 (file)
@@ -2,8 +2,8 @@
 // SPDX-License-Identifier: BSD-3-Clause
 
 
-#ifndef SHADOW_INCLUDE_LIB_STRING_CTYPE_STRISASCII_STRISDIGIT_H_
-#define SHADOW_INCLUDE_LIB_STRING_CTYPE_STRISASCII_STRISDIGIT_H_
+#ifndef SHADOW_INCLUDE_LIB_STRING_CTYPE_STRISASCII_H_
+#define SHADOW_INCLUDE_LIB_STRING_CTYPE_STRISASCII_H_
 
 
 #include "config.h"
@@ -16,6 +16,7 @@
 
 
 inline bool strisdigit(const char *s);
+inline bool strisprint(const char *s);
 
 
 // strisdigit - string is [:digit:]
@@ -29,4 +30,20 @@ strisdigit(const char *s)
 }
 
 
+// strisprint - string is [:print:]
+inline bool
+strisprint(const char *s)
+{
+       if (streq(s, ""))
+               return false;
+
+       for (; !streq(s, ""); s++) {
+               if (!isprint_c(*s))
+                       return false;
+       }
+
+       return true;
+}
+
+
 #endif  // include guard
diff --git a/lib/string/ctype/strisascii/strisdigit.c b/lib/string/ctype/strisascii/strisdigit.c
deleted file mode 100644 (file)
index acd4522..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
-// SPDX-License-Identifier: BSD-3-Clause
-
-
-#include "config.h"
-
-#include "string/ctype/strisascii/strisdigit.h"
-
-#include <stdbool.h>
-
-
-extern inline bool strisdigit(const char *s);
diff --git a/lib/string/ctype/strisascii/strisprint.h b/lib/string/ctype/strisascii/strisprint.h
deleted file mode 100644 (file)
index 652c654..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org>
-// SPDX-License-Identifier: BSD-3-Clause
-
-
-#ifndef SHADOW_INCLUDE_LIB_STRING_CTYPE_STRISASCII_STRISPRINT_H_
-#define SHADOW_INCLUDE_LIB_STRING_CTYPE_STRISASCII_STRISPRINT_H_
-
-
-#include "config.h"
-
-#include <stdbool.h>
-
-#include "string/ctype/isascii.h"
-#include "string/strcmp/streq.h"
-
-
-inline bool strisprint(const char *s);
-
-
-// strisprint - string is [:print:]
-inline bool
-strisprint(const char *s)
-{
-       if (streq(s, ""))
-               return false;
-
-       for (; !streq(s, ""); s++) {
-               if (!isprint_c(*s))
-                       return false;
-       }
-
-       return true;
-}
-
-
-#endif  // include guard
similarity index 78%
rename from lib/string/ctype/strtoascii/strtolower.c
rename to lib/string/ctype/strtoascii.c
index 99ea4097ca8e9bd582c0da9d28097a4c71708070..1e89acaaf5c913e6192e068450d2b4d024166afb 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "config.h"
 
-#include "string/ctype/strtoascii/strtolower.h"
+#include "string/ctype/strtoascii.h"
 
 
 extern inline char *strtolower(char *str);
similarity index 61%
rename from lib/string/ctype/strtoascii/strtolower.h
rename to lib/string/ctype/strtoascii.h
index d283fe1e870358fd91bf9927a7a58c30bcc3bc31..c0c3be7177ea80e3731ddbea6cce388b4f8cc5fa 100644 (file)
@@ -2,8 +2,8 @@
 // SPDX-License-Identifier: BSD-3-Clause
 
 
-#ifndef SHADOW_INCLUDE_LIB_STRING_CTYPE_STRTOASCII_STRTOLOWER_H_
-#define SHADOW_INCLUDE_LIB_STRING_CTYPE_STRTOASCII_STRTOLOWER_H_
+#ifndef SHADOW_INCLUDE_LIB_STRING_CTYPE_STRTOASCII_H_
+#define SHADOW_INCLUDE_LIB_STRING_CTYPE_STRTOASCII_H_
 
 
 #include "config.h"
@@ -16,9 +16,7 @@
 inline char *strtolower(char *str);
 
 
-// string convert-to lower-case
-// Like tolower(3), but convert all characters in the string.
-// Returns the input pointer.
+// strtolower - string convert-to lower-case
 inline char *
 strtolower(char *str)
 {
index 357ec5462124718a57a7401a6e765938b8fc66f4..7f6db7e421c0633c8dfc4d290102dd06732851e8 100644 (file)
@@ -24,7 +24,7 @@
 #include "atoi/a2i.h"
 #include "atoi/getnum.h"
 #include "shadow/passwd/getpw.h"
-#include "string/ctype/strisascii/strisdigit.h"
+#include "string/ctype/strisascii.h"
 #include "string/sprintf/stprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strtok/strsep2arr.h"