]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/string-util: split out helper function
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 3 Mar 2021 13:35:55 +0000 (14:35 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 May 2021 10:12:42 +0000 (12:12 +0200)
src/basic/string-util.c
src/basic/string-util.h

index 058eec54ff932d6e3dc32903b4adcf85a1fc015f..c8ed87765f5f087c0be35b2edcc5af77b78252fa 100644 (file)
@@ -277,10 +277,7 @@ bool string_has_cc(const char *p, const char *ok) {
                 if (ok && strchr(ok, *t))
                         continue;
 
-                if (*t > 0 && *t < ' ')
-                        return true;
-
-                if (*t == 127)
+                if (char_is_cc(*t))
                         return true;
         }
 
index cb2881b64d1bfbe8ed7031f93790dcd236ef3ae3..0dafe049ad131b862d063d63e0c9a56cb2372789 100644 (file)
@@ -129,6 +129,9 @@ static inline bool _pure_ in_charset(const char *s, const char* charset) {
         return s[strspn(s, charset)] == '\0';
 }
 
+static inline bool char_is_cc(char p) {
+        return (p >= 0 && p < ' ') || p == 127;
+}
 bool string_has_cc(const char *p, const char *ok) _pure_;
 
 char *ellipsize_mem(const char *s, size_t old_length_bytes, size_t new_length_columns, unsigned percent);