projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix segfault in lutimes when tv argument is NULL
[musl]
/
src
/
time
/
strptime.c
diff --git
a/src/time/strptime.c
b/src/time/strptime.c
index
55c7ed1
..
c54a0d8
100644
(file)
--- a/
src/time/strptime.c
+++ b/
src/time/strptime.c
@@
-11,7
+11,7
@@
char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
int i, w, neg, adj, min, range, *dest, dummy;
const char *ex;
size_t len;
int i, w, neg, adj, min, range, *dest, dummy;
const char *ex;
size_t len;
- int want_century = 0, century = 0;
+ int want_century = 0, century = 0
, relyear = 0
;
while (*f) {
if (*f != '%') {
if (isspace(*f)) for (; *s && isspace(*s); s++);
while (*f) {
if (*f != '%') {
if (isspace(*f)) for (; *s && isspace(*s); s++);
@@
-73,6
+73,7
@@
char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
dest = &tm->tm_yday;
min = 1;
range = 366;
dest = &tm->tm_yday;
min = 1;
range = 366;
+ adj = 1;
goto numeric_range;
case 'm':
dest = &tm->tm_mon;
goto numeric_range;
case 'm':
dest = &tm->tm_mon;
@@
-93,6
+94,7
@@
char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
len = strlen(ex);
if (!strncasecmp(s, ex, len)) {
tm->tm_hour %= 12;
len = strlen(ex);
if (!strncasecmp(s, ex, len)) {
tm->tm_hour %= 12;
+ s += len;
break;
}
ex = nl_langinfo(PM_STR);
break;
}
ex = nl_langinfo(PM_STR);
@@
-100,6
+102,7
@@
char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
if (!strncasecmp(s, ex, len)) {
tm->tm_hour %= 12;
tm->tm_hour += 12;
if (!strncasecmp(s, ex, len)) {
tm->tm_hour %= 12;
tm->tm_hour += 12;
+ s += len;
break;
}
return 0;
break;
}
return 0;
@@
-141,7
+144,7
@@
char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
if (!s) return 0;
break;
case 'y':
if (!s) return 0;
break;
case 'y':
- dest = &
tm->tm_
year;
+ dest = &
rel
year;
w = 2;
want_century |= 1;
goto numeric_digits;
w = 2;
want_century |= 1;
goto numeric_digits;
@@
-195,6
+198,7
@@
char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
}
}
if (want_century) {
}
}
if (want_century) {
+ tm->tm_year = relyear;
if (want_century & 2) tm->tm_year += century * 100 - 1900;
else if (tm->tm_year <= 68) tm->tm_year += 100;
}
if (want_century & 2) tm->tm_year += century * 100 - 1900;
else if (tm->tm_year <= 68) tm->tm_year += 100;
}