This pacifies a warning from default clang 21, and saves a byte. Problem reported by Badli Al Rashid <https://bugs.gnu.org/80514>. * lib/strftime.c (c_ampm_letters): New static constant, if !defined _NL_CURRENT && (HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)). (ampm): Use it if needed. --- ChangeLog | 10 ++++++++++ lib/strftime.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog index d27f189866..d98641cadf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2026-03-01 Paul Eggert <[email protected]> + + strftime: pacify clang -Wstring-plus-int + This pacifies a warning from default clang 21, and saves a byte. + Problem reported by Badli Al Rashid <https://bugs.gnu.org/80514>. + * lib/strftime.c (c_ampm_letters): New static constant, if + !defined _NL_CURRENT && (HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && + !HAVE_STRFTIME_L)). + (ampm): Use it if needed. + 2026-03-01 Bruno Haible <[email protected]> tests: Use strnul. diff --git a/lib/strftime.c b/lib/strftime.c index 33fa2e017b..f7cf65d541 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -888,6 +888,7 @@ static CHAR_T const c_month_names[][sizeof "September"] = L_("June"), L_("July"), L_("August"), L_("September"), L_("October"), L_("November"), L_("December") }; +static CHAR_T const c_ampm_letters[] = { L_('A'), L_('M'), L_('P'), L_('M') }; #endif @@ -1274,7 +1275,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) # define f_month \ (tp->tm_mon < 0 || tp->tm_mon > 11 ? L_("?") : c_month_names[tp->tm_mon]) /* The English AM/PM strings happen to have the same length, namely 2. */ -# define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11)) +# define ampm (c_ampm_letters + 2 * (12 <= tp->tm_hour)) # define ap_len 2 #endif retval_t i = 0; -- 2.51.0
