[FFmpeg-devel] [PATCH] lavf/utils: fix ISO8601 date generation, after the switch to av_small_strptime()
Michael Niedermayer
michaelni at gmx.at
Mon Sep 17 06:41:34 CEST 2012
On Mon, Sep 17, 2012 at 01:04:03AM +0200, Stefano Sabatini wrote:
> On date Sunday 2012-09-16 22:50:25 +0200, Michael Niedermayer encoded:
> > On Sun, Sep 16, 2012 at 03:39:43PM +0200, Michael Niedermayer wrote:
> > > On Sun, Sep 16, 2012 at 03:24:37PM +0200, Stefano Sabatini wrote:
> > > > strptime() seems to be more robust to incorrect specification containing
> > > > spaces.
> > > >
> > > > Should fix trac ticket #1739.
> > > > ---
> > > > libavformat/utils.c | 4 ++--
> > > > 1 files changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > > > index c6a9e58..4b6eba8 100644
> > > > --- a/libavformat/utils.c
> > > > +++ b/libavformat/utils.c
> > > > @@ -4486,8 +4486,8 @@ int64_t ff_iso8601_to_unix_time(const char *datestr)
> > > > {
> > > > struct tm time1 = {0}, time2 = {0};
> > > > char *ret1, *ret2;
> > > > - ret1 = av_small_strptime(datestr, "%Y - %m - %d %H:%M:%S", &time1);
> > > > - ret2 = av_small_strptime(datestr, "%Y - %m - %dT%H:%M:%S", &time2);
> > > > + ret1 = av_small_strptime(datestr, "%Y-%m-%d %H:%M:%S", &time1);
> > > > + ret2 = av_small_strptime(datestr, "%Y-%m-%dT%H:%M:%S", &time2);
> > > > if (ret2 && !ret1)
> > > > return av_timegm(&time2);
> > > > else
> > >
> > > av_small_strptime() should be fixed otherwise i think we should use
> > > strptime() as av_small_strptime() is not even compliant for a subset
> > > of the format specifers
> > >
> > > POSIX about strptime:
> > > A conversion specification composed of white-space characters is executed by scanning input up to the first character that is not white-space (which remains unscanned), or until no more characters can be scanned.
> >
> > To elaborate on my point ...
> > the way i interpret the posix spec is that spaces in
> > the format specification must match 0+ spaces, while av_small_strptime
> > seems to treat it as =1
>
> Yes, I interpret it the same way, thanks for noticing.
>
> Patch updated, now I don't know if we should let av_small_strptime()
> rely on locale-specific isspace().
i dunno either, avoiding it might be better
otherwise patches LGTM
thanks
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120917/7fcec771/attachment.asc>
More information about the ffmpeg-devel
mailing list