diff options
author | Max Kellermann <max@duempel.org> | 2013-10-21 08:42:55 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-21 08:42:55 +0200 |
commit | 222dc8a239f7578cecdcb21523052140aa1192cf (patch) | |
tree | 3d5577e2d9092277e08de28f20766c01f87cc0ea /src/util/ASCII.hxx | |
parent | 0e4d2e7277bc2adf18dd1e719ec4ce684f86d72b (diff) | |
download | mpd-222dc8a239f7578cecdcb21523052140aa1192cf.tar.gz mpd-222dc8a239f7578cecdcb21523052140aa1192cf.tar.xz mpd-222dc8a239f7578cecdcb21523052140aa1192cf.zip |
Util/ASCII: add StringEqualsCaseASCII() overload with length
Replaces GLib's g_ascii_strncasecmp().
Diffstat (limited to 'src/util/ASCII.hxx')
-rw-r--r-- | src/util/ASCII.hxx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/ASCII.hxx b/src/util/ASCII.hxx index 0d4c8f35b..adea6dceb 100644 --- a/src/util/ASCII.hxx +++ b/src/util/ASCII.hxx @@ -51,4 +51,16 @@ StringEqualsCaseASCII(const char *a, const char *b) return strcasecmp(a, b) == 0; } +gcc_pure gcc_nonnull_all +static inline bool +StringEqualsCaseASCII(const char *a, const char *b, size_t n) +{ + assert(a != nullptr); + assert(b != nullptr); + + /* note: strcasecmp() depends on the locale, but for ASCII-only + strings, it's safe to use */ + return strncasecmp(a, b, n) == 0; +} + #endif |