[FFmpeg-cvslog] r22251 - in trunk/libavutil: avstring.c avstring.h

mru subversion
Sat Mar 6 20:41:22 CET 2010


Author: mru
Date: Sat Mar  6 20:41:22 2010
New Revision: 22251

Log:
Add av_stristr() function

This is a case-insensitive version of strstr().

Modified:
   trunk/libavutil/avstring.c
   trunk/libavutil/avstring.h

Modified: trunk/libavutil/avstring.c
==============================================================================
--- trunk/libavutil/avstring.c	Sat Mar  6 20:40:37 2010	(r22250)
+++ trunk/libavutil/avstring.c	Sat Mar  6 20:41:22 2010	(r22251)
@@ -48,6 +48,19 @@ int av_stristart(const char *str, const 
     return !*pfx;
 }
 
+char *av_stristr(const char *s1, const char *s2)
+{
+    if (!*s2)
+        return s1;
+
+    do {
+        if (av_stristart(s1, s2, NULL))
+            return s1;
+    } while (*s1++);
+
+    return NULL;
+}
+
 size_t av_strlcpy(char *dst, const char *src, size_t size)
 {
     size_t len = 0;

Modified: trunk/libavutil/avstring.h
==============================================================================
--- trunk/libavutil/avstring.h	Sat Mar  6 20:40:37 2010	(r22250)
+++ trunk/libavutil/avstring.h	Sat Mar  6 20:41:22 2010	(r22251)
@@ -47,6 +47,19 @@ int av_strstart(const char *str, const c
 int av_stristart(const char *str, const char *pfx, const char **ptr);
 
 /**
+ * Locate the first case-independent occurrence in the string s1 of
+ * the string s2.  A zero-length string s2 is considered to match at
+ * the start of s1.
+ *
+ * This function is a case-insensitive version of the standard strstr().
+ *
+ * @param s1 string to search in
+ * @param s2 string to search for
+ * @return pointer to the located match within s1 or a null pointer if no match
+ */
+char *av_stristr(const char *s1, const char *s2);
+
+/**
  * Copy the string src to dst, but no more than size - 1 bytes, and
  * null-terminate dst.
  *



More information about the ffmpeg-cvslog mailing list