This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] strftime: Allow use of both 'E' and 'O' like "%OEy", "%OEY" [BZ #24453]
- From: Andreas Schwab <schwab at suse dot de>
- To: TAMUKI Shoichi <tamuki at linet dot gr dot jp>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 17 Apr 2019 11:10:04 +0200
- Subject: Re: [PATCH] strftime: Allow use of both 'E' and 'O' like "%OEy", "%OEY" [BZ #24453]
- References: <201904170830.AA04338@tamuki.linet.gr.jp>
On Apr 17 2019, TAMUKI Shoichi <tamuki@linet.gr.jp> wrote:
> diff --git a/manual/time.texi b/manual/time.texi
> index bfa46dd45b..a5ff92dabc 100644
> --- a/manual/time.texi
> +++ b/manual/time.texi
> @@ -1579,6 +1579,13 @@ However, by default it is zero-padded to a minimum of two digits (this
> can be overridden by an explicit field width or by the @code{_} and
> @code{-} flags).
>
> +As a GNU extension, if both the @code{E} and @code{O} modifiers are
> +specified (@code{%OEy}), instead produces the year number according to
> +locale-specific alternative calendar with alternative numeric symbols.
> +Generally, since the alternative numeric symbols are defined from 0 to
> +99, when the calendar year number is more than 100, produces the
> +ordinary number as a fallback.
The last sentence also applies to %OEY, doesn't it? According to the
testcase, the limit is actually locale dependent.
This should document both %EOy and %OEy.
> diff --git a/time/strftime_l.c b/time/strftime_l.c
> index 98c35d58a2..abdcf90789 100644
> --- a/time/strftime_l.c
> +++ b/time/strftime_l.c
> @@ -710,17 +710,11 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
> }
>
> /* Check for modifiers. */
> - switch (*f)
> - {
> - case L_('E'):
> - case L_('O'):
> - modifier = *f++;
> - break;
> -
> - default:
> - modifier = 0;
> - break;
> - }
> + modifier = 0;
> + while (*f == L_('E') || *f == L_('O'))
> + modifier |= (*f++ == L_('E')) ? L_('E') : L_('O') << 8;
I think we should support only the spellings %EO and %OE, without
repetition.
> +#define MODIFIER_E (modifier & 0xff)
> +#define MODIFIER_O (modifier >> 8 & 0xff)
These macros should evaluate to true iff the modifier is present.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."