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

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Oct 17 13:59:30 CEST 2010


On Sun, Oct 17, 2010 at 01:41:36PM +0200, Nicolas George wrote:
> Le sextidi 26 vendémiaire, an CCXIX, Reimar Döffinger a écrit :
> > According to the documentation it is wrong to assume whether %n increases
> > the sscanf value or not.
> 
> AFAIK, both C99 and Single Unix agree that "Execution of a %n directive
> does not increment the assignment count returned at the completion of
> execution of the fscanf function."
> 
> If there are known broken systems that need to be worked around, I can just
> rewrite it with ">= 3" instead of "== 3".

If even the linux man page tells you not to rely on it I'd say
it must be very common.
Note that not even Windows (using msvcrt) claims to comply to either
of the standards you quote.

> > 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.
> 
> Done a slightly different way: a third "endchar" argument, and return an
> error if the end of the string is neither 0 nor endchar. This is not the
> most generic API, but it is simple and it works for all the current cases;
> we can not predict what the next use will actually do.

For the current use cause even that is overkill.
For that you just need to check that the following char is either 0 or ','.
You do not need to return a length or change the function in any other way,
and just need to add a strchr - in the current usage (if you want to fix them)
to check that there is no ',', in the new usages to advance to the next time.

> > 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.
> 
> strsep is not standard, and I do not like the idea of changing the input
> string unnecessarily.

MPlayer already provides a fallback implementation of strsep.


More information about the MPlayer-dev-eng mailing list