]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/string/ctype/strchrisascii.h: Use strpbrk(3) to simplify
authorAlejandro Colomar <alx@kernel.org>
Fri, 2 Jan 2026 23:37:18 +0000 (00:37 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Thu, 11 Jun 2026 07:33:53 +0000 (09:33 +0200)
This compacts it into a one-liner, more similar to the strisascii_c()
functions.

Since we only use the argument once, we can even turn this into a macro.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/string/ctype/strchrisascii.c
lib/string/ctype/strchrisascii.h

index 5e25b23fa920c8b09090beec5d058c7133d0ca90..905430628a3ff30705073f6b61e7562cc69c841c 100644 (file)
@@ -5,8 +5,3 @@
 #include "config.h"
 
 #include "string/ctype/strchrisascii.h"
-
-#include <stdbool.h>
-
-
-extern inline bool strchriscntrl_c(const char *s);
index 04da16e9d361a087f3ae012a6ef26b113bab1be6..8fc775a8c0caff57dade18ba9b5b68ec8c800680 100644 (file)
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org>
+// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
 // SPDX-License-Identifier: BSD-3-Clause
 
 
@@ -8,28 +8,13 @@
 
 #include "config.h"
 
-#include <stdbool.h>
+#include <string.h>
 
 #include "string/ctype/isascii.h"
-#include "string/strcmp/streq.h"
-
-
-inline bool strchriscntrl_c(const char *s);
 
 
 // strchriscntrl_c - string character is [:cntrl:] C-locale
-inline bool
-strchriscntrl_c(const char *s)
-{
-       for (; !streq(s, ""); s++) {
-               unsigned char  c = *s;
-
-               if (iscntrl_c(c))
-                       return true;
-       }
-
-       return false;
-}
+#define strchriscntrl_c(s)  (!!strpbrk(s, CTYPE_CNTRL_C))
 
 
 #endif  // include guard