[FFmpeg-devel] [PATCH] lavf/utils: fix ISO8601 date generation, after the switch to av_small_strptime()

Michael Niedermayer michaelni at gmx.at
Sun Sep 16 22:50:25 CEST 2012


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

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange
-------------- 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/20120916/8c03b672/attachment.asc>


More information about the ffmpeg-devel mailing list