[FFmpeg-devel] [PATCH] Implement number parsing functions in cmdutils.c
Stefano Sabatini
stefano.sabatini-lala
Thu Feb 21 09:34:51 CET 2008
On date Wednesday 2008-02-20 12:14:43 -0500, Rich Felker encoded:
> On Wed, Feb 20, 2008 at 02:09:12PM +0100, Michael Niedermayer wrote:
> > > | > Matter of taste: int64_t should only be used where the problem
> > > | > dictates it. long int or long long int are more abstract. Of course
> > > | > there is the problem that you don't know exactly what you are getting.
> > > | > The C language really isn't very good in this area. It is true that
> > > | > long long can hold any int64_t value but the reverse may not be the
> > > | > case.
> > > |
> > > | This parses command line options and the range of valid values is not
> > > | something which should depend on LLONG_MAX. Whatever the allowed range it
> > > | should be allowed independant of LLONG_MAX.
> > >
> > > Sure, but I claim that any values of type int or int64_t will of
> > > necessity (by way of guarantees in the C standard) be within the range
> > > [LLONG_MIN, LLONG_MAX].
> >
> > That is not true. Quoting the C spec:
> > --------
> > minimum value for an object of type long long int
> > -9223372036854775807 // -(2^63 - 1)
> > LLONG_MIN
> > --------
> > minimum values of exact-width signed integer types
> > exactly -(2^(N-1) )
> > INTN_MIN
> > --------
>
> Any ones-complement implementation is completely unusable by ffmpeg
> and utterly irrelevant. *_MIN is always a negated exact power of two
> on any usable machine.
>
> > > | the != '\0' is also useless
> > >
> > > I think that it makes the code a lot easier to read.
> >
> > Peoples opinions differ. Ours is != 0 has to be removed.
Fixed.
[...]
For what regards the ERANGE thing, there is a case where I think it
could be useful:
stefano at geppetto ~/s/ffmpeg> ffmpeg -aq 99999999... -i foo
The value for aq must be >= -inf and <= inf but you used: 9999999999999...
while it's OK to do for example ffmpeg -aq inf ...
If the ERANGE check is disabled then the value is set to inf by
strtod, and there is no chance for the user to notice this. Same
reasoning for the parse_integer_or_die function.
Regards.
--
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: implement-number-parsing-functions-03.patch
Type: text/x-diff
Size: 3075 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080221/a8a2c861/attachment.patch>
More information about the ffmpeg-devel
mailing list