diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2011-11-05 19:20:41 +0400 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2011-11-06 13:52:56 +0400 |
commit | ba04ecfdacec4cf86e74b43fe8bcc09e06bb7a72 (patch) | |
tree | 374fbe08c811f62a5a9f3f4e0e36a417206a66e1 /libavutil | |
parent | 07b172fe8f6a5d567edc4dac3f813b210874d3b1 (diff) |
avstring: Add locale independent implementations of strcasecmp/strncasecmp
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/avstring.c | 21 | ||||
-rw-r--r-- | libavutil/avstring.h | 12 | ||||
-rw-r--r-- | libavutil/avutil.h | 2 |
3 files changed, 34 insertions, 1 deletions
diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 2b8c2d4a1d..11f3a7c321 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -134,6 +134,27 @@ char *av_get_token(const char **buf, const char *term) return ret; } +int av_strcasecmp(const char *a, const char *b) +{ + uint8_t c1, c2; + do { + c1 = av_tolower(*a++); + c2 = av_tolower(*b++); + } while (c1 && c1 == c2); + return c1 - c2; +} + +int av_strncasecmp(const char *a, const char *b, size_t n) +{ + const char *end = a + n; + uint8_t c1, c2; + do { + c1 = av_tolower(*a++); + c2 = av_tolower(*b++); + } while (a < end && c1 && c1 == c2); + return c1 - c2; +} + #ifdef TEST #undef printf diff --git a/libavutil/avstring.h b/libavutil/avstring.h index 8d97e1f768..6988f0e3e8 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -151,4 +151,16 @@ static inline int av_tolower(int c) return c; } +/* + * Locale independent case-insensitive compare. + * Note: This means only ASCII-range characters are case-insensitive + */ +int av_strcasecmp(const char *a, const char *b); + +/** + * Locale independent case-insensitive compare. + * Note: This means only ASCII-range characters are case-insensitive + */ +int av_strncasecmp(const char *a, const char *b, size_t n); + #endif /* AVUTIL_AVSTRING_H */ diff --git a/libavutil/avutil.h b/libavutil/avutil.h index b688321161..5ad7034fab 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -40,7 +40,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 13 +#define LIBAVUTIL_VERSION_MINOR 14 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |