[FFmpeg-devel] [PATCH] Make parse_date return INT64_MIN in case of unparsable input

Stefano Sabatini stefano.sabatini-lala
Wed Sep 12 16:49:16 CEST 2007


On date Wednesday 2007-09-12 13:24:10 +0200, Michael Niedermayer encoded:
> Hi
> 
> On Wed, Sep 12, 2007 at 12:32:12PM +0200, Stefano Sabatini wrote:
> > On date Wednesday 2007-09-12 12:00:50 +0200, Michael Niedermayer encoded:
> > > Hi
> > > 
> > > On Wed, Sep 12, 2007 at 11:13:24AM +0200, Stefano Sabatini wrote:
> > > [...]
> > > > + * Returns the number of microseconds since 1st of January, 1970 up
> > > > + * to the time of the parsed date or up to the current time if \p
> > > > + * datestr cannot be successfully parsed.
> > > 
> > > i do not think that this is the intended behavior but rather a "bug"
> > > in the implementation thus you change the API by hardcoding the bug in
> > > it and would need to bump the respective versions but i wont accept that
> > 
> > Got the point.
> >  
> > > using the current date in case a string cannot be parsed is a very odd
> > > way to handle an error
> > 
> > Completely agree. 
> > 
> > Possible solutions:
> > 
> > 1. make parse_date return a negative number in case of error (what
> > happens if the date parsed is before 1970-01-01?)
> 
> return INT64_MIN for an error, that wont collide with pre 1970 dates

Here it is.

Suggested log: $subject.

If you're OK I can also eventually apply the second proposed solution,
that is to deprecate parse_date in favour of a function like:
int av_parse_date (int64_t *us, char *timestr, int is_duration) 

which is imho cleaner (yes I know, I'm risking to be flamed here ;-)).

Regards.
-- 
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make-parse-date-return-int64min-if-unparsable-input-00.patch
Type: text/x-diff
Size: 1988 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070912/e4466a0b/attachment.patch>



More information about the ffmpeg-devel mailing list