From: TAMUKI Shoichi <tamuki@linet.gr.jp>
To: libc-alpha@sourceware.org
Subject: [PATCH v5 3/5] strftime: Pass the additional flags from "%EY" to "%Ey" [BZ #23758]
Date: Sun, 06 Jan 2019 06:36:00 -0000 [thread overview]
Message-ID: <201901060634.AA04159@tamuki.linet.gr.jp> (raw)
In-Reply-To: <201901060628.AA04156@tamuki.linet.gr.jp>
For the output string of the conversion specifier "%EY", an optional
flag is given to the conversion specifier so that it can be also used
the current non-padding format, and the padding format can be
controlled. To achieve this, when an optional flag is given to the
conversion specifier "%EY", the "%Ey" included in the combined
conversion specifier is interpreted as if decorated with the
appropriate flag.
ChangeLog:
[BZ #23758]
* time/strftime_l.c (__strftime_internal): Add argument yr_spec to
override padding for "%Ey".
If an optional flag ('_' or '-') is specified to "%EY", the "%Ey" in
subformat is interpreted as if decorated with the appropriate flag.
---
time/strftime_l.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/time/strftime_l.c b/time/strftime_l.c
index cbe08e7afb4..12d7c0e8744 100644
--- a/time/strftime_l.c
+++ b/time/strftime_l.c
@@ -434,7 +434,7 @@ static CHAR_T const month_name[][10] =
#endif
static size_t __strftime_internal (CHAR_T *, size_t, const CHAR_T *,
- const struct tm *, bool *
+ const struct tm *, int *, bool *
ut_argument_spec
LOCALE_PARAM) __THROW;
@@ -456,8 +456,9 @@ my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format,
tmcopy = *tp;
tp = &tmcopy;
#endif
+ int yr_spec = 0; /* Override padding for "%Ey". */
bool tzset_called = false;
- return __strftime_internal (s, maxsize, format, tp, &tzset_called
+ return __strftime_internal (s, maxsize, format, tp, &yr_spec, &tzset_called
ut_argument LOCALE_ARG);
}
#ifdef _LIBC
@@ -466,7 +467,7 @@ libc_hidden_def (my_strftime)
static size_t
__strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
- const struct tm *tp, bool *tzset_called
+ const struct tm *tp, int *yr_spec, bool *tzset_called
ut_argument_spec LOCALE_PARAM)
{
#if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL
@@ -838,11 +839,12 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
{
CHAR_T *old_start = p;
size_t len = __strftime_internal (NULL, (size_t) -1, subfmt,
- tp, tzset_called ut_argument
- LOCALE_ARG);
+ tp, yr_spec, tzset_called
+ ut_argument LOCALE_ARG);
add (len, __strftime_internal (p, maxsize - i, subfmt,
- tp, tzset_called ut_argument
- LOCALE_ARG));
+ tp, yr_spec, tzset_called
+ ut_argument LOCALE_ARG));
+ *yr_spec = 0;
if (to_uppcase)
while (old_start < p)
@@ -1273,6 +1275,8 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
# else
subfmt = era->era_format;
# endif
+ if (pad != 0)
+ *yr_spec = pad;
goto subformat;
}
#else
@@ -1294,6 +1298,8 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
if (era)
{
int delta = tp->tm_year - era->start_date[0];
+ if (*yr_spec != 0)
+ pad = *yr_spec;
DO_NUMBER (2, (era->offset
+ delta * era->absolute_direction));
}
--
2.12.2
next prev parent reply other threads:[~2019-01-06 6:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-06 6:30 [PATCH v5 0/5] strftime: Improve the width of alternate representation for year " TAMUKI Shoichi
2019-01-06 6:36 ` [PATCH v5 1/5] strftime: Add missing uses of L_ macro, etc. " TAMUKI Shoichi
2019-01-09 10:08 ` Rafal Luzynski
2019-01-09 10:21 ` Siddhesh Poyarekar
2019-01-09 22:58 ` Rafal Luzynski
2019-01-11 4:54 ` TAMUKI Shoichi
2019-01-11 12:07 ` Rafal Luzynski
2019-01-11 14:21 ` Siddhesh Poyarekar
2019-01-10 0:46 ` TAMUKI Shoichi
2019-01-06 6:36 ` [PATCH v5 2/5] strftime: Set the default width of "%Ey" to 2 " TAMUKI Shoichi
2019-01-09 10:13 ` Rafal Luzynski
2019-01-09 10:25 ` Siddhesh Poyarekar
2019-01-09 23:02 ` Rafal Luzynski
2019-01-10 0:46 ` TAMUKI Shoichi
2019-01-06 6:36 ` TAMUKI Shoichi [this message]
2019-01-06 6:36 ` [PATCH v5 4/5] strftime: Add tst-strfitme2 " TAMUKI Shoichi
2019-01-06 6:54 ` [PATCH v5 5/5] strftime: Document the description for "%EC", "%Ey", and "%EY" " TAMUKI Shoichi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201901060634.AA04159@tamuki.linet.gr.jp \
--to=tamuki@linet.gr.jp \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).