summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/string-util.c15
-rw-r--r--src/basic/string-util.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index dfcb29235..6f4593e6b 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -356,6 +356,21 @@ int ascii_strcasecmp_n(const char *a, const char *b, size_t n) {
return 0;
}
+int ascii_strcasecmp_nn(const char *a, size_t n, const char *b, size_t m) {
+ int r;
+
+ r = ascii_strcasecmp_n(a, b, MIN(n, m));
+ if (r != 0)
+ return r;
+
+ if (n < m)
+ return -1;
+ else if (n > m)
+ return 1;
+ else
+ return 0;
+}
+
bool chars_intersect(const char *a, const char *b) {
const char *p;
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index 48cdc736f..7ed649ae6 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -133,6 +133,7 @@ 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);
+int ascii_strcasecmp_nn(const char *a, size_t n, const char *b, size_t m);
bool chars_intersect(const char *a, const char *b) _pure_;