[FFmpeg-cvslog] r25225 - in trunk: libavfilter/avfilter.h libavfilter/graphparser.c libavfilter/parseutils.c libavfilter/parseutils.h libavfilter/vf_frei0r.c libavutil/avstring.c libavutil/avstring.h libavutil/avu...

stefano subversion
Mon Sep 27 18:23:44 CEST 2010


Author: stefano
Date: Mon Sep 27 18:23:43 2010
New Revision: 25225

Log:
Move av_get_token() from libavfilter to libavutil.

Modified:
   trunk/libavfilter/avfilter.h
   trunk/libavfilter/graphparser.c
   trunk/libavfilter/parseutils.c
   trunk/libavfilter/parseutils.h
   trunk/libavfilter/vf_frei0r.c
   trunk/libavutil/avstring.c
   trunk/libavutil/avstring.h
   trunk/libavutil/avutil.h

Modified: trunk/libavfilter/avfilter.h
==============================================================================
--- trunk/libavfilter/avfilter.h	Mon Sep 27 18:10:23 2010	(r25224)
+++ trunk/libavfilter/avfilter.h	Mon Sep 27 18:23:43 2010	(r25225)
@@ -26,7 +26,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR  1
 #define LIBAVFILTER_VERSION_MINOR 46
-#define LIBAVFILTER_VERSION_MICRO  0
+#define LIBAVFILTER_VERSION_MICRO  1
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \

Modified: trunk/libavfilter/graphparser.c
==============================================================================
--- trunk/libavfilter/graphparser.c	Mon Sep 27 18:10:23 2010	(r25224)
+++ trunk/libavfilter/graphparser.c	Mon Sep 27 18:23:43 2010	(r25225)
@@ -23,6 +23,7 @@
 #include <ctype.h>
 #include <string.h>
 
+#include "libavutil/avstring.h"
 #include "graphparser.h"
 #include "avfilter.h"
 #include "avfiltergraph.h"

Modified: trunk/libavfilter/parseutils.c
==============================================================================
--- trunk/libavfilter/parseutils.c	Mon Sep 27 18:10:23 2010	(r25224)
+++ trunk/libavfilter/parseutils.c	Mon Sep 27 18:23:43 2010	(r25225)
@@ -28,42 +28,6 @@
 #include "libavutil/random_seed.h"
 #include "parseutils.h"
 
-#define WHITESPACES " \n\t"
-
-char *av_get_token(const char **buf, const char *term)
-{
-    char *out = av_malloc(strlen(*buf) + 1);
-    char *ret= out, *end= out;
-    const char *p = *buf;
-    if (!out) return NULL;
-    p += strspn(p, WHITESPACES);
-
-    while(*p && !strspn(p, term)) {
-        char c = *p++;
-        if(c == '\\' && *p){
-            *out++ = *p++;
-            end= out;
-        }else if(c == '\''){
-            while(*p && *p != '\'')
-                *out++ = *p++;
-            if(*p){
-                p++;
-                end= out;
-            }
-        }else{
-            *out++ = c;
-        }
-    }
-
-    do{
-        *out-- = 0;
-    }while(out >= end && strspn(out, WHITESPACES));
-
-    *buf = p;
-
-    return ret;
-}
-
 typedef struct {
     const char *name;            ///< a string representing the name of the color
     uint8_t     rgb_color[3];    ///< RGB values for the color
@@ -395,41 +359,6 @@ int main(void)
 {
     int i;
 
-    const char *strings[] = {
-        "''",
-        "",
-        ":",
-        "\\",
-        "'",
-        "    ''    :",
-        "    ''  ''  :",
-        "foo   '' :",
-        "'foo'",
-        "foo     ",
-        "foo\\",
-        "foo':  blah:blah",
-        "foo\\:  blah:blah",
-        "foo\'",
-        "'foo :  '  :blahblah",
-        "\\ :blah",
-        "     foo",
-        "      foo       ",
-        "      foo     \\ ",
-        "foo ':blah",
-        " foo   bar    :   blahblah",
-        "\\f\\o\\o",
-        "'foo : \\ \\  '   : blahblah",
-        "'\\fo\\o:': blahblah",
-        "\\'fo\\o\\:':  foo  '  :blahblah"
-    };
-
-    for (i=0; i < FF_ARRAY_ELEMS(strings); i++) {
-        const char *p= strings[i];
-        printf("|%s|", p);
-        printf(" -> |%s|", av_get_token(&p, ":"));
-        printf(" + |%s|\n", p);
-    }
-
     printf("\nTesting av_parse_color()\n");
     {
         uint8_t rgba[4];

Modified: trunk/libavfilter/parseutils.h
==============================================================================
--- trunk/libavfilter/parseutils.h	Mon Sep 27 18:10:23 2010	(r25224)
+++ trunk/libavfilter/parseutils.h	Mon Sep 27 18:23:43 2010	(r25225)
@@ -28,21 +28,6 @@
 #include "libavutil/opt.h"
 
 /**
- * Unescape the given string until a non escaped terminating char,
- * and return the token corresponding to the unescaped string.
- *
- * The normal \ and ' escaping is supported. Leading and trailing
- * whitespaces are removed.
- *
- * @param buf the buffer to parse, buf will be updated to point to the
- * terminating char
- * @param term a 0-terminated list of terminating chars
- * @return the malloced unescaped string, which must be av_freed by
- * the user, NULL in case of allocation failure
- */
-char *av_get_token(const char **buf, const char *term);
-
-/**
  * Put the RGBA values that correspond to color_string in rgba_color.
  *
  * @param color_string a string specifying a color. It can be the name of

Modified: trunk/libavfilter/vf_frei0r.c
==============================================================================
--- trunk/libavfilter/vf_frei0r.c	Mon Sep 27 18:10:23 2010	(r25224)
+++ trunk/libavfilter/vf_frei0r.c	Mon Sep 27 18:23:43 2010	(r25225)
@@ -26,6 +26,7 @@
 
 #include <dlfcn.h>
 #include <frei0r.h>
+#include "libavutil/avstring.h"
 #include "avfilter.h"
 #include "parseutils.h"
 

Modified: trunk/libavutil/avstring.c
==============================================================================
--- trunk/libavutil/avstring.c	Mon Sep 27 18:10:23 2010	(r25224)
+++ trunk/libavutil/avstring.c	Mon Sep 27 18:23:43 2010	(r25225)
@@ -97,3 +97,91 @@ char *av_d2str(double d)
     if(str) snprintf(str, 16, "%f", d);
     return str;
 }
+
+#define WHITESPACES " \n\t"
+
+char *av_get_token(const char **buf, const char *term)
+{
+    char *out = av_malloc(strlen(*buf) + 1);
+    char *ret= out, *end= out;
+    const char *p = *buf;
+    if (!out) return NULL;
+    p += strspn(p, WHITESPACES);
+
+    while(*p && !strspn(p, term)) {
+        char c = *p++;
+        if(c == '\\' && *p){
+            *out++ = *p++;
+            end= out;
+        }else if(c == '\''){
+            while(*p && *p != '\'')
+                *out++ = *p++;
+            if(*p){
+                p++;
+                end= out;
+            }
+        }else{
+            *out++ = c;
+        }
+    }
+
+    do{
+        *out-- = 0;
+    }while(out >= end && strspn(out, WHITESPACES));
+
+    *buf = p;
+
+    return ret;
+}
+
+#ifdef TEST
+
+#undef printf
+
+int main(void)
+{
+    int i;
+
+    printf("Testing av_get_token()\n");
+    {
+        const char *strings[] = {
+            "''",
+            "",
+            ":",
+            "\\",
+            "'",
+            "    ''    :",
+            "    ''  ''  :",
+            "foo   '' :",
+            "'foo'",
+            "foo     ",
+            "  '  foo  '  ",
+            "foo\\",
+            "foo':  blah:blah",
+            "foo\\:  blah:blah",
+            "foo\'",
+            "'foo :  '  :blahblah",
+            "\\ :blah",
+            "     foo",
+            "      foo       ",
+            "      foo     \\ ",
+            "foo ':blah",
+            " foo   bar    :   blahblah",
+            "\\f\\o\\o",
+            "'foo : \\ \\  '   : blahblah",
+            "'\\fo\\o:': blahblah",
+            "\\'fo\\o\\:':  foo  '  :blahblah"
+        };
+
+        for (i=0; i < FF_ARRAY_ELEMS(strings); i++) {
+            const char *p= strings[i];
+            printf("|%s|", p);
+            printf(" -> |%s|", av_get_token(&p, ":"));
+            printf(" + |%s|\n", p);
+        }
+    }
+
+    return 0;
+}
+
+#endif /* TEST */

Modified: trunk/libavutil/avstring.h
==============================================================================
--- trunk/libavutil/avstring.h	Mon Sep 27 18:10:23 2010	(r25224)
+++ trunk/libavutil/avstring.h	Mon Sep 27 18:23:43 2010	(r25225)
@@ -114,4 +114,20 @@ size_t av_strlcatf(char *dst, size_t siz
  */
 char *av_d2str(double d);
 
+/**
+ * Unescape the given string until a non escaped terminating char,
+ * and return the token corresponding to the unescaped string.
+ *
+ * The normal \ and ' escaping is supported. Leading and trailing
+ * whitespaces are removed, unless they are escaped with '\' or are
+ * enclosed between ''.
+ *
+ * @param buf the buffer to parse, buf will be updated to point to the
+ * terminating char
+ * @param term a 0-terminated list of terminating chars
+ * @return the malloced unescaped string, which must be av_freed by
+ * the user, NULL in case of allocation failure
+ */
+char *av_get_token(const char **buf, const char *term);
+
 #endif /* AVUTIL_AVSTRING_H */

Modified: trunk/libavutil/avutil.h
==============================================================================
--- trunk/libavutil/avutil.h	Mon Sep 27 18:10:23 2010	(r25224)
+++ trunk/libavutil/avutil.h	Mon Sep 27 18:23:43 2010	(r25225)
@@ -40,7 +40,7 @@
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
 
 #define LIBAVUTIL_VERSION_MAJOR 50
-#define LIBAVUTIL_VERSION_MINOR 29
+#define LIBAVUTIL_VERSION_MINOR 30
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list