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

j at svn.xiph.org j at svn.xiph.org
Mon May 4 16:07:59 PDT 2009


Author: j
Date: 2009-05-04 16:07:59 -0700 (Mon, 04 May 2009)
New Revision: 15980

Modified:
   trunk/ffmpeg2theora/src/avinfo.c
Log:
output valid json, escape "

Modified: trunk/ffmpeg2theora/src/avinfo.c
===================================================================
--- trunk/ffmpeg2theora/src/avinfo.c	2009-05-04 22:23:09 UTC (rev 15979)
+++ trunk/ffmpeg2theora/src/avinfo.c	2009-05-04 23:07:59 UTC (rev 15980)
@@ -34,7 +34,7 @@
 
 long get_filesize(char const *filename) {
     struct stat file;
-    if(!stat(filename,&file)) {
+    if(!stat(filename, &file)) {
         return file.st_size;
     }
     return 0;
@@ -66,9 +66,17 @@
 } JSON_TYPES;
 
 void json_add_key_value(FILE *output, char *key, void *value, int type, int last) {
+    char *p, *pp;
     switch(type) {
         case JSON_STRING:
-            fprintf(output, "  \"%s\": \"%s\"", key, (char *)value);
+            p = (char *)value;
+            fprintf(output, "  \"%s\": \"", key);
+            while(pp = index(p, 34)) {
+                *pp = '\0';
+                fprintf(output, "%s\\\"", p);
+                p = pp + 1;
+            }
+            fprintf(output, "%s\"", p);
             break;
         case JSON_INT:
             fprintf(output, "  \"%s\": %d", key, *(int *)value);



More information about the commits mailing list