diff options
Diffstat (limited to 'main/musl/1003-implement-y-and-C-specifiers-in-strptime.patch')
-rw-r--r-- | main/musl/1003-implement-y-and-C-specifiers-in-strptime.patch | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/main/musl/1003-implement-y-and-C-specifiers-in-strptime.patch b/main/musl/1003-implement-y-and-C-specifiers-in-strptime.patch new file mode 100644 index 0000000000..8bb18aa164 --- /dev/null +++ b/main/musl/1003-implement-y-and-C-specifiers-in-strptime.patch @@ -0,0 +1,69 @@ +From 0caec05b829d1a2db1b559305a41770d9015042d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi> +Date: Wed, 14 May 2014 10:53:56 +0300 +Subject: [PATCH] implement %y and %C specifiers in strptime + +also return error if encountering an unknown recognized specifier. +--- + src/time/strptime.c | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +diff --git a/src/time/strptime.c b/src/time/strptime.c +index d1d141e..5ed40ca 100644 +--- a/src/time/strptime.c ++++ b/src/time/strptime.c +@@ -11,6 +11,7 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri + int i, w, neg, adj, min, range, *dest; + const char *ex; + size_t len; ++ int century = -2; + while (*f) { + if (*f != '%') { + if (isspace(*f)) for (; *s && isspace(*s); s++); +@@ -40,6 +41,9 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri + if (!s) return 0; + break; + case 'C': ++ dest = ¢ury; ++ if (w<0) w=2; ++ goto numeric_digits; + case 'd': case 'e': + dest = &tm->tm_mday; + min = 1; +@@ -128,16 +132,21 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri + if (!s) return 0; + break; + case 'y': +- //FIXME +- return 0; ++ dest = &tm->tm_year; ++ if (w<0) w=2; ++ if (century==-2) century=-1; ++ goto numeric_digits; + case 'Y': + dest = &tm->tm_year; + if (w<0) w=4; + adj = 1900; ++ century = -2; + goto numeric_digits; + case '%': + if (*s++ != '%') return 0; + break; ++ default: ++ return 0; + numeric_range: + if (!isdigit(*s)) return 0; + *dest = 0; +@@ -176,5 +185,9 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri + ; + } + } ++ if (century >= -1) { ++ if (century >= 0) tm->tm_year += century * 100 - 1900; ++ else if (tm->tm_year <= 68) tm->tm_year += 100; ++ } + return (char *)s; + } +-- +1.9.2 + |