History

avstring: Add locale independent implementations of strcasecmp/strncasecmp

Reimar Döffinger committed 15 years ago

Commit ba04ecf1 parent 07b172f4 files · +37 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/avstring.c +21 −0
  3. libavutil/avstring.h +12 −0
  4. libavutil/avutil.h +1 −1
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2011-11-xx - xxxxxxx - lavu 51.14.0
17+ Add av_strcasecmp() and av_strncasecmp() to avstring.h.
18+
1619 2011-11-xx - xxxxxxx - lavu 51.13.0
1720 Add av_toupper()/av_tolower()
1821
libavutil/avstring.c+21−0
@@ -134,6 +134,27 @@ char *av_get_token(const char **buf, const char *term) · 133 unmodified lines
134134 return ret;
135135 }
136136
137+int av_strcasecmp(const char *a, const char *b)
138+{
139+ uint8_t c1, c2;
140+ do {
141+ c1 = av_tolower(*a++);
142+ c2 = av_tolower(*b++);
143+ } while (c1 && c1 == c2);
144+ return c1 - c2;
145+}
146+
147+int av_strncasecmp(const char *a, const char *b, size_t n)
148+{
149+ const char *end = a + n;
150+ uint8_t c1, c2;
151+ do {
152+ c1 = av_tolower(*a++);
153+ c2 = av_tolower(*b++);
154+ } while (a < end && c1 && c1 == c2);
155+ return c1 - c2;
156+}
157+
137158 #ifdef TEST
138159
139160 #undef printf
libavutil/avstring.h+12−0
@@ -151,4 +151,16 @@ static inline int av_tolower(int c) · 150 unmodified lines
151151 return c;
152152 }
153153
154+/*
155+ * Locale independent case-insensitive compare.
156+ * Note: This means only ASCII-range characters are case-insensitive
157+ */
158+int av_strcasecmp(const char *a, const char *b);
159+
160+/**
161+ * Locale independent case-insensitive compare.
162+ * Note: This means only ASCII-range characters are case-insensitive
163+ */
164+int av_strncasecmp(const char *a, const char *b, size_t n);
165+
154166 #endif /* AVUTIL_AVSTRING_H */
libavutil/avutil.h+1−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
4141
4242 #define LIBAVUTIL_VERSION_MAJOR 51
43−#define LIBAVUTIL_VERSION_MINOR 13
43+#define LIBAVUTIL_VERSION_MINOR 14
4444 #define LIBAVUTIL_VERSION_MICRO 0
4545
4646 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t