[FFmpeg-devel] [PATCH] Make parse_date return INT64_MIN in case of unparsable input
Michael Niedermayer
michaelni
Wed Sep 19 12:28:08 CEST 2007
Hi
On Wed, Sep 19, 2007 at 11:27:39AM +0200, Stefano Sabatini wrote:
> On date Wednesday 2007-09-19 10:41:49 +0200, Benoit Fouet encoded:
> > Hi,
> >
> > Stefano Sabatini wrote:
> > > Index: ffmpeg.c
> > > ===================================================================
> > > --- ffmpeg.c (revision 10526)
> > > +++ ffmpeg.c (working copy)
> > > static void opt_rec_timestamp(const char *arg)
> > > {
> > > - rec_timestamp = parse_date(arg, 0) / 1000000;
> > > + int64_t rec_timestamp_us;
> > > + parse_time_or_die(&rec_timestamp_us, arg, 0);
> > > + rec_timestamp = rec_timestamp_us / 1000000;
> > >
> >
> > one last thing: why not use rec_timestamp directly ?
>
> Yes, you're right again.
>
> Regards.
> --
> Stefano Sabatini
> Linux user number 337176 (see http://counter.li.org)
> Index: libavformat/utils.c
> ===================================================================
> --- libavformat/utils.c (revision 10526)
> +++ libavformat/utils.c (working copy)
> @@ -2621,17 +2621,19 @@
> if (!q) {
> /* parse datestr as S+ */
> dt.tm_sec = strtol(p, (char **)&q, 10);
> + if (q == p) {
> + /* set q to NULL to signal that the parsing didn't succeed */
> + q = NULL;
> + } else {
> dt.tm_min = 0;
> dt.tm_hour = 0;
> + }
> }
> }
instead of the if/else blah a simple
if(q == p)
return INT64_MIN;
seems to be simpler
[...]
> +static void parse_time_or_die(int64_t *us, const char *timestr, int is_duration)
> +{
> + *us = parse_date(timestr, is_duration);
> + if (*us == INT64_MIN) {
> + fprintf(stderr, "Invalid %s specification: %s\n",
> + is_duration ? "duration" : "date", timestr);
> + exit(1);
> + }
> +}
return us; would be cleaner IMHO
and iam fine with the patch except these
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070919/b5517858/attachment.pgp>
More information about the ffmpeg-devel
mailing list