* [PATCH] nstrftime: merge glibc strftime changes @ 2019-02-22 4:08 Paul Eggert 2019-02-23 5:59 ` TAMUKI Shoichi 0 siblings, 1 reply; 4+ messages in thread From: Paul Eggert @ 2019-02-22 4:08 UTC (permalink / raw) To: bug-gnulib; +Cc: Paul Eggert This incorporates: 2019-02-11 Fix a few whitespace arrangement inconsistencies 2019-01-24 strftime: Pass flags from "%EY" to "%Ey" [BZ #24096] 2019-01-24 Set the default width of "%Ey" to 2 [BZ #23758] 2019-01-11 strftime: use the "L_" macro with character literals * lib/nstrftime.c (__strftime_internal): New arg yr_spec. All callers changed. Default width of %Ey is now 2. This is needed for proper handling of Japanese dates starting on 2019-05-01. --- ChangeLog | 12 ++++++++++++ lib/nstrftime.c | 27 ++++++++++++++++----------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index bdc298994..a736765ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2019-02-21 Paul Eggert <eggert@cs.ucla.edu> + + nstrftime: merge glibc strftime changes + This incorporates: + 2019-02-11 Fix a few whitespace arrangement inconsistencies + 2019-01-24 strftime: Pass flags from "%EY" to "%Ey" [BZ #24096] + 2019-01-24 Set the default width of "%Ey" to 2 [BZ #23758] + 2019-01-11 strftime: use the "L_" macro with character literals + * lib/nstrftime.c (__strftime_internal): New arg yr_spec. All + callers changed. Default width of %Ey is now 2. This is needed + for proper handling of Japanese dates starting on 2019-05-01. + 2019-02-19 Bruno Haible <bruno@clisp.org> relocatable-prog: Use $ORIGIN trick on more platforms. diff --git a/lib/nstrftime.c b/lib/nstrftime.c index fd731e1c4..a45d809b2 100644 --- a/lib/nstrftime.c +++ b/lib/nstrftime.c @@ -418,7 +418,7 @@ iso_week_days (int yday, int wday) static size_t __strftime_internal (STREAM_OR_CHAR_T *, STRFTIME_ARG (size_t) const CHAR_T *, const struct tm *, - bool, bool * + int, bool, bool * extra_args_spec LOCALE_PARAM); /* Write information from TP into S according to the format @@ -433,7 +433,7 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) const struct tm *tp extra_args_spec LOCALE_PARAM) { bool tzset_called = false; - return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, + return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, 0, false, &tzset_called extra_args LOCALE_ARG); } #if defined _LIBC && ! FPRINTFTIME @@ -446,7 +446,8 @@ libc_hidden_def (my_strftime) static size_t __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) const CHAR_T *format, - const struct tm *tp, bool upcase, bool *tzset_called + const struct tm *tp, int yr_spec, + bool upcase, bool *tzset_called extra_args_spec LOCALE_PARAM) { #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL @@ -850,7 +851,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) if (modifier == L_('O')) goto bad_format; #ifdef _NL_CURRENT - if (! (modifier == 'E' + if (! (modifier == L_('E') && (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_D_T_FMT))) @@ -863,13 +864,13 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) subformat: { size_t len = __strftime_internal (NULL, STRFTIME_ARG ((size_t) -1) - subfmt, - tp, to_uppcase, tzset_called + subfmt, tp, yr_spec, + to_uppcase, tzset_called extra_args LOCALE_ARG); add (len, __strftime_internal (p, STRFTIME_ARG (maxsize - i) - subfmt, - tp, to_uppcase, tzset_called + subfmt, tp, yr_spec, + to_uppcase, tzset_called extra_args LOCALE_ARG)); } break; @@ -939,7 +940,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) #ifdef _NL_CURRENT if (! (modifier == L_('E') && (*(subfmt = - (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) + (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) != L_('\0')))) subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); goto subformat; @@ -1327,7 +1328,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) DO_NUMBER (1, tp->tm_wday); case L_('Y'): - if (modifier == 'E') + if (modifier == L_('E')) { #if HAVE_STRUCT_ERA_ENTRY struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); @@ -1338,6 +1339,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) # else subfmt = era->era_format; # endif + if (pad != 0) + yr_spec = pad; goto subformat; } #else @@ -1358,7 +1361,9 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) if (era) { int delta = tp->tm_year - era->start_date[0]; - DO_NUMBER (1, (era->offset + if (yr_spec != 0) + pad = yr_spec; + DO_NUMBER (2, (era->offset + delta * era->absolute_direction)); } #else -- 2.17.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nstrftime: merge glibc strftime changes 2019-02-22 4:08 [PATCH] nstrftime: merge glibc strftime changes Paul Eggert @ 2019-02-23 5:59 ` TAMUKI Shoichi 2019-02-23 23:10 ` Paul Eggert 0 siblings, 1 reply; 4+ messages in thread From: TAMUKI Shoichi @ 2019-02-23 5:59 UTC (permalink / raw) To: Paul Eggert, bug-gnulib Hello Paul-san, Thank you for your porting Glibc strftime changes to the implementation in Gnulib. Let me just make a few comments to make it better code. From: Paul Eggert <eggert@cs.ucla.edu> Subject: [PATCH] nstrftime: merge glibc strftime changes Date: Thu, 21 Feb 2019 20:08:46 -0800 > [...] > diff --git a/lib/nstrftime.c b/lib/nstrftime.c > index fd731e1c4..a45d809b2 100644 > --- a/lib/nstrftime.c > +++ b/lib/nstrftime.c > @@ -418,7 +418,7 @@ iso_week_days (int yday, int wday) > > static size_t __strftime_internal (STREAM_OR_CHAR_T *, STRFTIME_ARG (size_t) > const CHAR_T *, const struct tm *, > - bool, bool * > + int, bool, bool * For the implementation of nstrftime.c in Gnulib, upcase is added as an argument of __strftime_internal function compared to strftime_l.c in Glibc. This (upcase) argument is used mainly for the process described in the beginning of format_char, such as %a, %A, %[bh], %B, etc. On the other hand, tzset_called argument is used in the process described at the end of format_char, i.e. %z. Therefore, I think these arguments are in this order. Since yr_spec argument to be added this time is used in %EY and %Ey of format_char, it is better to make the argument order the same. Recommend instead: | @@ -418,7 +418,7 @@ iso_week_days (int yday, int wday) | | static size_t __strftime_internal (STREAM_OR_CHAR_T *, STRFTIME_ARG (size_t) | const CHAR_T *, const struct tm *, | - bool, bool * | + bool, int, bool * | extra_args_spec LOCALE_PARAM); | | /* Write information from TP into S according to the format > [...] > @@ -433,7 +433,7 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) > const struct tm *tp extra_args_spec LOCALE_PARAM) > { > bool tzset_called = false; > - return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, > + return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, 0, Ditto. Recommend instead: | @@ -434,7 +434,7 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | { | bool tzset_called = false; | return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, | - false, &tzset_called extra_args LOCALE_ARG); | + false, 0, &tzset_called extra_args LOCALE_ARG); | } | #if defined _LIBC && ! FPRINTFTIME | libc_hidden_def (my_strftime) > [...] > @@ -446,7 +446,8 @@ libc_hidden_def (my_strftime) > static size_t > __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) > const CHAR_T *format, > - const struct tm *tp, bool upcase, bool *tzset_called > + const struct tm *tp, int yr_spec, > + bool upcase, bool *tzset_called Ditto. Recommend instead: | @@ -446,8 +446,8 @@ libc_hidden_def (my_strftime) | static size_t | __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | const CHAR_T *format, | - const struct tm *tp, bool upcase, bool *tzset_called | - extra_args_spec LOCALE_PARAM) | + const struct tm *tp, bool upcase, int yr_spec, | + bool *tzset_called extra_args_spec LOCALE_PARAM) | { | #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL | struct __locale_data *const current = loc->__locales[LC_TIME]; > [...] > @@ -863,13 +864,13 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) > subformat: > { > size_t len = __strftime_internal (NULL, STRFTIME_ARG ((size_t) -1) > - subfmt, > - tp, to_uppcase, tzset_called > + subfmt, tp, yr_spec, > + to_uppcase, tzset_called > extra_args LOCALE_ARG); > add (len, __strftime_internal (p, > STRFTIME_ARG (maxsize - i) > - subfmt, > - tp, to_uppcase, tzset_called > + subfmt, tp, yr_spec, > + to_uppcase, tzset_called Ditto. Recommend instead: | @@ -864,13 +864,15 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | { | size_t len = __strftime_internal (NULL, STRFTIME_ARG ((size_t) -1) | subfmt, | - tp, to_uppcase, tzset_called | - extra_args LOCALE_ARG); | + tp, to_uppcase, yr_spec, | + tzset_called extra_args | + LOCALE_ARG); | add (len, __strftime_internal (p, | STRFTIME_ARG (maxsize - i) | subfmt, | - tp, to_uppcase, tzset_called | - extra_args LOCALE_ARG)); | + tp, to_uppcase, yr_spec, | + tzset_called extra_args | + LOCALE_ARG)); | } | break; | Thank you for your consideration. Regards, TAMUKI Shoichi ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nstrftime: merge glibc strftime changes 2019-02-23 5:59 ` TAMUKI Shoichi @ 2019-02-23 23:10 ` Paul Eggert 2019-02-24 11:39 ` TAMUKI Shoichi 0 siblings, 1 reply; 4+ messages in thread From: Paul Eggert @ 2019-02-23 23:10 UTC (permalink / raw) To: TAMUKI Shoichi; +Cc: bug-gnulib [-- Attachment #1: Type: text/plain, Size: 52 bytes --] Sure, that's easy enough. I installed the attached. [-- Attachment #2: 0001-nstrftime-tweak-arg-order.patch --] [-- Type: text/x-patch, Size: 3677 bytes --] From 240c92d99b26c67ce3a5799f3e83258501595dc3 Mon Sep 17 00:00:00 2001 From: Paul Eggert <eggert@cs.ucla.edu> Date: Sat, 23 Feb 2019 15:07:47 -0800 Subject: [PATCH] nstrftime: tweak arg order * lib/nstrftime.c (__strftime_internal): Interchange arg order. All callers changed. Suggested by TAMUKI Shoichi in: https://lists.gnu.org/r/bug-gnulib/2019-02/msg00052.html --- ChangeLog | 7 +++++++ lib/nstrftime.c | 18 +++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17f41bfd1..5a85496ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-02-23 Paul Eggert <eggert@cs.ucla.edu> + + nstrftime: tweak arg order + * lib/nstrftime.c (__strftime_internal): Interchange arg order. + All callers changed. Suggested by TAMUKI Shoichi in: + https://lists.gnu.org/r/bug-gnulib/2019-02/msg00052.html + 2019-02-23 Bruno Haible <bruno@clisp.org> relocatable-prog: Use wrapper-free installation also on Mac OS X. diff --git a/lib/nstrftime.c b/lib/nstrftime.c index a45d809b2..424fb6069 100644 --- a/lib/nstrftime.c +++ b/lib/nstrftime.c @@ -418,7 +418,7 @@ iso_week_days (int yday, int wday) static size_t __strftime_internal (STREAM_OR_CHAR_T *, STRFTIME_ARG (size_t) const CHAR_T *, const struct tm *, - int, bool, bool * + bool, int, bool * extra_args_spec LOCALE_PARAM); /* Write information from TP into S according to the format @@ -433,8 +433,8 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) const struct tm *tp extra_args_spec LOCALE_PARAM) { bool tzset_called = false; - return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, 0, - false, &tzset_called extra_args LOCALE_ARG); + return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, false, + 0, &tzset_called extra_args LOCALE_ARG); } #if defined _LIBC && ! FPRINTFTIME libc_hidden_def (my_strftime) @@ -446,8 +446,8 @@ libc_hidden_def (my_strftime) static size_t __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) const CHAR_T *format, - const struct tm *tp, int yr_spec, - bool upcase, bool *tzset_called + const struct tm *tp, bool upcase, + int yr_spec, bool *tzset_called extra_args_spec LOCALE_PARAM) { #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL @@ -864,13 +864,13 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) subformat: { size_t len = __strftime_internal (NULL, STRFTIME_ARG ((size_t) -1) - subfmt, tp, yr_spec, - to_uppcase, tzset_called + subfmt, tp, to_uppcase, + yr_spec, tzset_called extra_args LOCALE_ARG); add (len, __strftime_internal (p, STRFTIME_ARG (maxsize - i) - subfmt, tp, yr_spec, - to_uppcase, tzset_called + subfmt, tp, to_uppcase, + yr_spec, tzset_called extra_args LOCALE_ARG)); } break; -- 2.17.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nstrftime: merge glibc strftime changes 2019-02-23 23:10 ` Paul Eggert @ 2019-02-24 11:39 ` TAMUKI Shoichi 0 siblings, 0 replies; 4+ messages in thread From: TAMUKI Shoichi @ 2019-02-24 11:39 UTC (permalink / raw) To: Paul Eggert; +Cc: bug-gnulib Hello Paul-san, From: Paul Eggert <eggert@cs.ucla.edu> Subject: Re: [PATCH] nstrftime: merge glibc strftime changes Date: Sat, 23 Feb 2019 15:10:38 -0800 > Sure, that's easy enough. I installed the attached. Thank you for working on this. Regards, TAMUKI Shoichi ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-02-24 11:40 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-02-22 4:08 [PATCH] nstrftime: merge glibc strftime changes Paul Eggert 2019-02-23 5:59 ` TAMUKI Shoichi 2019-02-23 23:10 ` Paul Eggert 2019-02-24 11:39 ` TAMUKI Shoichi
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).