Skip to content

Commit 1334b50

Browse files
lib/string/ctype/strchrisascii.h: Use stpcspn() to simplify
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 <[email protected]>
1 parent 1e98c87 commit 1334b50

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

lib/string/ctype/strchrisascii.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@
55
#include "config.h"
66

77
#include "string/ctype/strchrisascii.h"
8-
9-
#include <stdbool.h>
10-
11-
12-
extern inline bool strchriscntrl(const char *s);

lib/string/ctype/strchrisascii.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,13 @@
88

99
#include "config.h"
1010

11-
#include <stdbool.h>
12-
1311
#include "string/ctype/isascii.h"
1412
#include "string/strcmp/streq.h"
15-
16-
17-
inline bool strchriscntrl_c(const char *s);
13+
#include "string/strspn/stpcspn.h"
1814

1915

2016
// strchriscntrl_c - string character is [:cntrl:] C-locale
21-
inline bool
22-
strchriscntrl_c(const char *s)
23-
{
24-
for (; !streq(s, ""); s++) {
25-
if (iscntrl_c(*s))
26-
return true;
27-
}
28-
29-
return false;
30-
}
17+
#define strchriscntrl_c(s) (!streq(stpcspn(s, CTYPE_CNTRL_C), ""))
3118

3219

3320
#endif // include guard

0 commit comments

Comments
 (0)