parseutils: Extend small_strptime to be used in avformat

The strptime implementation is supposed to support whitespace and %T.
This commit is contained in:
Luca Barbato 2015-04-06 01:25:52 +02:00
parent 249796e256
commit 108f2f381a

View File

@ -404,11 +404,16 @@ static const char *small_strptime(const char *p, const char *fmt, struct tm *dt)
{
int c, val;
for(;;) {
c = *fmt++;
if (c == '\0') {
return p;
} else if (c == '%') {
while((c = *fmt++)) {
if (c != '%') {
if (av_isspace(c))
for (; *p && av_isspace(*p); p++);
else if (*p != c)
return NULL;
else p++;
continue;
}
c = *fmt++;
switch(c) {
case 'H':
@ -447,18 +452,21 @@ static const char *small_strptime(const char *p, const char *fmt, struct tm *dt)
return NULL;
dt->tm_mday = val;
break;
case 'T':
p = small_strptime(p, "%H:%M:%S", dt);
if (!p)
return NULL;
break;
case '%':
goto match;
if (*p++ != '%')
return NULL;
break;
default:
return NULL;
}
} else {
match:
if (c != *p)
return NULL;
p++;
}
}
return p;
}
time_t av_timegm(struct tm *tm)