[FFmpeg-cvslog] avutil/avstring: Reimplement av_match_list()

Michael Niedermayer git at videolan.org
Thu Oct 23 04:58:59 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Oct 23 04:33:57 2014 +0200| [3c0b98dced394da30d96b94b61faa07574d97e33] | committer: Michael Niedermayer

avutil/avstring: Reimplement av_match_list()

av_match_list() is only used for whitelists, fix it so it works with
multi-named formats like "mov,mp4,m4a,3gp,3g2,mj2"

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3c0b98dced394da30d96b94b61faa07574d97e33
---

 libavutil/avstring.c |   29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index ac7f98a..413e140 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -404,22 +404,21 @@ end:
 
 int av_match_list(const char *name, const char *list, char separator)
 {
-    const char *p;
-    char ext1[128], *q;
-    int i;
-
-    p = list;
-    for (i = 1;; i++) {
-        q = ext1;
-        while (*p != '\0' && *p != separator  && q - ext1 < sizeof(ext1) - 1)
-            *q++ = *p++;
-        *q = '\0';
-        if (!av_strcasecmp(ext1, name))
-            return i;
-        if (*p == '\0')
-            break;
-        p++;
+    const char *p, *q;
+
+    for (p = name; p && *p; ) {
+        for (q = list; q && *q; ) {
+            int k;
+            for (k = 0; p[k] == q[k] || (p[k]*q[k] == 0 && p[k]+q[k] == ','); k++)
+                if (k && (!p[k] || p[k] == ','))
+                    return 1;
+            q = strchr(q, ',');
+            q += !!q;
+        }
+        p = strchr(p, ',');
+        p += !!p;
     }
+
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list