Browse code

Support comments in preset files.

Originally committed as revision 15366 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2008/09/19 06:07:11
Showing 1 changed files
... ...
@@ -3718,7 +3718,7 @@ static int opt_bsf(const char *opt, const char *arg)
3718 3718
 static int opt_preset(const char *opt, const char *arg)
3719 3719
 {
3720 3720
     FILE *f=NULL;
3721
-    char tmp[1000], tmp2[1000];
3721
+    char tmp[1000], tmp2[1000], line[1000];
3722 3722
     int i;
3723 3723
     const char *base[3]= { getenv("HOME"),
3724 3724
                            "/usr/local/share",
... ...
@@ -3743,8 +3743,11 @@ static int opt_preset(const char *opt, const char *arg)
3743 3743
     }
3744 3744
 
3745 3745
     while(!feof(f)){
3746
-        int e= fscanf(f, "%999[^=]=%999[^\n]\n", tmp, tmp2);
3747
-        if(e!=2){
3746
+        int e= fscanf(f, "%999[^\n]\n", line) - 1;
3747
+        if(line[0] == '#' && !e)
3748
+            continue;
3749
+        e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2;
3750
+        if(e){
3748 3751
             fprintf(stderr, "Preset file invalid\n");
3749 3752
             av_exit(1);
3750 3753
         }