[FFmpeg-devel] [PATCH] lavf/utils: fix ISO8601 date generation, after the switch to av_small_strptime()
Stefano Sabatini
stefasab at gmail.com
Mon Sep 17 01:04:03 CEST 2012
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().
--
FFmpeg = Fundamentalist and Foolish Mythic Prodigious Elected Gospel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavu-parseutils-fix-av_small_strptime-whitespace-dir.patch
Type: text/x-diff
Size: 1158 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120917/e47473cc/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-fate-add-av_small_strptime-test-to-fate-parseutils.patch
Type: text/x-diff
Size: 2550 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120917/e47473cc/attachment-0001.bin>
More information about the ffmpeg-devel
mailing list