fixed sscanf bug
[swftools.git] / src / swfcombine.c
index d52aa71..f564793 100644 (file)
@@ -137,7 +137,7 @@ int args_callback_option(char*name,char*val) {
     {
 
        float rate = atof(val);
-       if ((rate < 1.0/256) ||(rate >= 256.0)) {
+       if ((rate < 0) ||(rate >= 256.0)) {
            fprintf(stderr, "Error: You must specify a valid framerate between 1/256 and 255.\n");
            exit(1);
        }
@@ -306,6 +306,7 @@ static void makestackmaster(SWF*swf)
            exit(1);
        }
        close(fi);
+       swf_RemoveJPEGTables(&head);
        msg("<verbose> File %s has bounding box %d:%d:%d:%d\n",
                slave_filename[t], 
                head.movieSize.xmin, head.movieSize.ymin,
@@ -1044,16 +1045,19 @@ void combine(SWF*master, char*slave_name, SWF*slave, SWF*newswf)
 
     if(config.isframe)
     {
-       int tmp;
-       if(slavename && slavename[0]!='#' && (sscanf(slavename, "%d", &tmp) ==
-               strlen(slavename))) {
-       /* if the name the slave should replace 
-          consists only of digits and the -f
-          option is given, it probably is not
-          a frame name but a frame number.
-        */
-           slaveid = tmp;
-           slavename = 0;
+       if(slavename && slavename[0]!='#') {
+           int tmp;
+           int len;
+           sscanf(slavename, "%d%n", &tmp, &len);
+           if(len == strlen(slavename)) {
+           /* if the name the slave should replace 
+              consists only of digits and the -f
+              option is given, it probably is not
+              a frame name but a frame number.
+            */
+               slaveid = tmp;
+               slavename = 0;
+           }
        }
 
        if(slaveid>=0) {
@@ -1124,6 +1128,11 @@ int main(int argn, char *argv[])
        msg("<error> Can't combine --cat and --merge");
        exit(1);
     }
+    
+    if(config.stack && config.cat) {
+       msg("<error> Can't combine --cat and --stack");
+       exit(1);
+    }
 
     if(config.stack) {
        if(config.overlay) {
@@ -1151,6 +1160,7 @@ int main(int argn, char *argv[])
            msg("<fatal> Failed to read from %s\n", master_filename);
            exit(1);
        }
+       swf_RemoveJPEGTables(&master);
        msg("<debug> Read %d bytes from masterfile\n", ret);
        close(fi);
     }
@@ -1218,6 +1228,7 @@ int main(int argn, char *argv[])
                }
                msg("<debug> Read %d bytes from slavefile\n", ret);
                close(fi);
+               swf_RemoveJPEGTables(&slave);
            }
            else
            {
@@ -1231,6 +1242,12 @@ int main(int argn, char *argv[])
            combine(&master, slave_name[t], &slave, &newswf);
            master = newswf;
        }
+       if(config.dummy && !config.hassizex && !config.hassizey && !config.mastermovex && !config.mastermovey) {
+           newswf.movieSize.xmin = newswf.movieSize.xmin*config.masterscalex;
+           newswf.movieSize.ymin = newswf.movieSize.ymin*config.masterscaley;
+           newswf.movieSize.xmax = newswf.movieSize.xmax*config.masterscalex;
+           newswf.movieSize.ymax = newswf.movieSize.ymax*config.masterscaley;
+       }
     }
 
     fi = open(outputname, O_BINARY|O_RDWR|O_TRUNC|O_CREAT, 0777);