diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-01-13 19:45:05 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-05-17 15:22:15 +0200 |
commit | 3b22b89bce6c5185e1db0a28390a0e6df138a27b (patch) | |
tree | 233c36edbb61688692d647b6a5013e049ceeedea /src/basic/string-util.c | |
parent | 7c1b422919819e9e7af4652b52d5f122a090ce53 (diff) |
basic: add ascii_strcasecmp_nn() call
In contrast to ascii_strcasecmp_nn() it takes two character buffers with their individual length. It will then compare
the buffers up the smaller size of the two buffers, and finally the length themselves.
Diffstat (limited to 'src/basic/string-util.c')
-rw-r--r-- | src/basic/string-util.c | 15 |
1 files changed, 15 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; |