diff options
Diffstat (limited to 'src/fundamental/string-util-fundamental.h')
-rw-r--r-- | src/fundamental/string-util-fundamental.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/fundamental/string-util-fundamental.h b/src/fundamental/string-util-fundamental.h index 8048a07f73..72fa0d7c90 100644 --- a/src/fundamental/string-util-fundamental.h +++ b/src/fundamental/string-util-fundamental.h @@ -18,8 +18,10 @@ # define strcasecmp strcasecmp16 # define strncasecmp strncasecmp16 # define STR_C(str) (L ## str) +typedef char16_t sd_char; #else # define STR_C(str) (str) +typedef char sd_char; #endif #define streq(a,b) (strcmp((a),(b)) == 0) @@ -27,25 +29,25 @@ #define strcaseeq(a,b) (strcasecmp((a),(b)) == 0) #define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0) -static inline sd_int strcmp_ptr(const sd_char *a, const sd_char *b) { +static inline int strcmp_ptr(const sd_char *a, const sd_char *b) { if (a && b) return strcmp(a, b); return CMP(a, b); } -static inline sd_int strcasecmp_ptr(const sd_char *a, const sd_char *b) { +static inline int strcasecmp_ptr(const sd_char *a, const sd_char *b) { if (a && b) return strcasecmp(a, b); return CMP(a, b); } -static inline sd_bool streq_ptr(const sd_char *a, const sd_char *b) { +static inline bool streq_ptr(const sd_char *a, const sd_char *b) { return strcmp_ptr(a, b) == 0; } -static inline sd_bool strcaseeq_ptr(const sd_char *a, const sd_char *b) { +static inline bool strcaseeq_ptr(const sd_char *a, const sd_char *b) { return strcasecmp_ptr(a, b) == 0; } @@ -63,7 +65,7 @@ sd_char *startswith_no_case(const sd_char *s, const sd_char *prefix) _pure_; sd_char *endswith(const sd_char *s, const sd_char *postfix) _pure_; sd_char *endswith_no_case(const sd_char *s, const sd_char *postfix) _pure_; -static inline sd_bool isempty(const sd_char *a) { +static inline bool isempty(const sd_char *a) { return !a || a[0] == '\0'; } @@ -71,7 +73,7 @@ static inline const sd_char *strempty(const sd_char *s) { return s ?: STR_C(""); } -static inline const sd_char *yes_no(sd_bool b) { +static inline const sd_char *yes_no(bool b) { return b ? STR_C("yes") : STR_C("no"); } @@ -79,7 +81,7 @@ static inline const sd_char* comparison_operator(int result) { return result < 0 ? STR_C("<") : result > 0 ? STR_C(">") : STR_C("=="); } -sd_int strverscmp_improved(const sd_char *a, const sd_char *b); +int strverscmp_improved(const sd_char *a, const sd_char *b); /* Like startswith(), but operates on arbitrary memory blocks */ static inline void *memory_startswith(const void *p, size_t sz, const sd_char *token) { |