basic: add new ascii_strcasecmp_n() call

This commit is contained in:
Lennart Poettering
2016-01-13 20:21:56 +01:00
parent 4b2e9cfcf0
commit 522d85ae0a
3 changed files with 45 additions and 0 deletions
+15
View File
@@ -348,6 +348,21 @@ char *ascii_strlower_n(char *t, size_t n) {
return t;
}
int ascii_strcasecmp_n(const char *a, const char *b, size_t n) {
for (; n > 0; a++, b++, n--) {
int x, y;
x = (int) (uint8_t) ascii_tolower(*a);
y = (int) (uint8_t) ascii_tolower(*b);
if (x != y)
return x - y;
}
return 0;
}
bool chars_intersect(const char *a, const char *b) {
const char *p;
+2
View File
@@ -134,6 +134,8 @@ char ascii_tolower(char x);
char *ascii_strlower(char *s);
char *ascii_strlower_n(char *s, size_t n);
int ascii_strcasecmp_n(const char *a, const char *b, size_t n);
bool chars_intersect(const char *a, const char *b) _pure_;
static inline bool _pure_ in_charset(const char *s, const char* charset) {