[2/2] lavu/parseutils: fix av_small_strptime() whitespace directive parsing

Message ID 1428255648-27529-2-git-send-email-stebbins@jetheaddev.com
State New
Headers show

Commit Message

John Stebbins April 5, 2015, 5:40 p.m.
From: Stefano Sabatini <stefasab@gmail.com>

According to POSIX, strptime() should consume whitespaces in the date
string everytime a whitespace conversion specification is found in the
date format specification. Make av_small_strptime() conform with this
behavior.

In particular, should fix trac ticket #1739.

(cherry picked from commit 85c93d90dfae17d2ccff21aec5a55ca3029be83c)

Conflicts:
	libavutil/version.h
---
 libavutil/parseutils.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch

diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index c03f1a2..fd3ffd1 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -405,6 +405,12 @@  const char *av_small_strptime(const char *p, const char *fmt, struct tm *dt)
     int c, val;
 
     for(;;) {
+        /* consume time string until a non whitespace char is found */
+        while (av_isspace(*fmt)) {
+            while (av_isspace(*p))
+                p++;
+            fmt++;
+        }
         c = *fmt++;
         if (c == '\0') {
             return p;