[xiph-commits] r16145 - trunk/ffmpeg2theora/src

j at svn.xiph.org j at svn.xiph.org
Wed Jun 17 22:45:18 PDT 2009


Author: j
Date: 2009-06-17 22:45:17 -0700 (Wed, 17 Jun 2009)
New Revision: 16145

Modified:
   trunk/ffmpeg2theora/src/avinfo.c
Log:
backslash in windows path

Modified: trunk/ffmpeg2theora/src/avinfo.c
===================================================================
--- trunk/ffmpeg2theora/src/avinfo.c	2009-06-17 23:04:03 UTC (rev 16144)
+++ trunk/ffmpeg2theora/src/avinfo.c	2009-06-18 05:45:17 UTC (rev 16145)
@@ -98,6 +98,20 @@
    return codec_name;
 }
 
+char *replace_str(char *str, char *orig, char *rep) {
+  char buffer[4096];
+  char *p, *p2, *rest;
+
+  if(!(p = strstr(str, orig)))
+    return str;
+
+  strncpy(buffer, str, p-str);
+  buffer[p-str] = '\0';
+  rest = replace_str(p+strlen(orig), orig, rep);
+  sprintf(buffer+(p-str), "%s%s", rep, rest);
+  return buffer;
+}
+
 enum {
     JSON_STRING,
     JSON_INT,
@@ -110,13 +124,9 @@
     switch(type) {
         case JSON_STRING:
             p = (char *)value;
-            fprintf(output, "  \"%s\": \"", key);
-            while(pp = strchr(p, 34)) {
-                *pp = '\0';
-                fprintf(output, "%s\\\"", p);
-                p = pp + 1;
-            }
-            fprintf(output, "%s\"", p);
+            p = replace_str(p, "\\", "\\\\");
+            p = replace_str(p, "\"", "\\\"");
+            fprintf(output, "  \"%s\": \"%s\"", key, p);
             break;
         case JSON_INT:
             fprintf(output, "  \"%s\": %d", key, *(int *)value);



More information about the commits mailing list