[MPlayer-dev-eng] [PATCH] -force-key-frames option

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Oct 17 11:47:05 CEST 2010


On Sun, Oct 17, 2010 at 11:22:31AM +0200, Reimar Döffinger wrote:
> On Sun, Oct 10, 2010 at 12:24:01PM +0200, Nicolas George wrote:
> > +  if (sscanf(str, "%d:%d:%lf%n", &a, &b, &d, &end) == 3)
> > +    *rts = 3600*a + 60*b + d;
> > +  else if (sscanf(str, "%d:%lf%n", &a, &d, &end) == 2)
> > +    *rts = 60*a + d;
> > +  else if (sscanf(str, "%lf%n", &d, &end) == 1)
> > +    *rts = d;
> 
> According to the documentation it is wrong to assume whether %n increases
> the sscanf value or not.
> You'd probably have to rewrite this using strtol or strtod.
> 
> > +  return end ? (char *)str + end : NULL;
> 
> Returning the parsed length would avoid the cast.
> Also I'd suggest to consider making this the extra argument,
> and if it is 0 also check that the end is the terminating 0
> or otherwise return an error.
> Currently our parsing code seems to accept e.g. "2 centuries" as 2 seconds.

Actually you could just make the parsing function check that there were
no extra characters (e.g. by adding a %c at the end to the parse string
and check nothing gets assigned to it), and then use strsep to parse
the string.


More information about the MPlayer-dev-eng mailing list