aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>2015-04-29 10:41:42 +0200
committerGravatar Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>2015-04-29 10:41:42 +0200
commit9a1e4d650edcefc4eff9aa1a6e58949f91cdc80d (patch)
tree770a69ee90aba4634b74c14954d828eb6f087496
parent3010966c6dc170425452d0dda4922aaf1585b6b5 (diff)
downloaduClibc-9a1e4d650edcefc4eff9aa1a6e58949f91cdc80d.tar.gz
uClibc-9a1e4d650edcefc4eff9aa1a6e58949f91cdc80d.tar.bz2
strftime: comment on %0xY %+nY %-nY
Would fix: date -u +%4Y%2m%2d%2H%2M%2S Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
-rw-r--r--libc/misc/time/time.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index a3fccb251..03635d86d 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -1084,7 +1084,25 @@ LOOP:
o_count = 1;
if ((*(o = (CHAR_T *)p) == '%') && (*++p != '%')) {
+#if 0 /* TODO, same for strptime */
+ /* POSIX.1-2008 allows %0xY %+nY %-nY etc. for certain formats.
+ * Just accept these for all (for now) */
+ const int plus = *p == '+';
+ CHAR_T *q = (CHAR_T *)p;
+ long int o_width = __XL_NPP(strtol)(p, &q, 0 __LOCALE_ARG);
+ if (o_width > 0 && o_width < 256) { /* arbitrary upper limit */
+ o_count = o_width;
+ if (plus) {
+ *s++ = '+';
+ --count;
+ }
+ p = q;
+ } else {
+ o_count = 2;
+ }
+#else
o_count = 2;
+#endif
mod = ILLEGAL_SPEC;
if ((*p == 'O') || (*p == 'E')) { /* modifier */
mod |= ((*p == 'O') ? NO_O_MOD : NO_E_MOD);
@@ -1317,7 +1335,13 @@ ISO_LOOP:
ccp = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME, field_val) __LOCALE_ARG);
fmt_to_wc(o, ccp);
} else {
+#if 0 /* TODO, same for strptime */
+ size_t min_count = ((i >> 1) & 3) + 1;
+ if (o_count < min_count)
+ o_count = min_count;
+#else
o_count = ((i >> 1) & 3) + 1;
+#endif
ccp = buf + o_count;
do {
*(char *)(--ccp) = '0' + (field_val % 10);