The lib/strptime.c file uses K&R definitions. When built with a recent
GCC release one will see -Wold-style-definition warnings.

No big deal, but eventually compilers will most likely remove K&R
definition support due to C23 removing it.

Therefore, I have pushed the attached patch.

Collin

>From 2de660857831ef886138312ec6276382cc97207f Mon Sep 17 00:00:00 2001
Message-ID: <2de660857831ef886138312ec6276382cc97207f.1751769365.git.collin.fu...@gmail.com>
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 5 Jul 2025 19:34:51 -0700
Subject: [PATCH] strptime: Convert K&R definitions to ANSI C.

* lib/strptime.c (LOCALE_PARAM) [_LIBC]: Adjust to match glibc, not
relevant for Gnulib.
(LOCALE_PARAM_PROTO, LOCALE_PARAM_DECL): Remove definitions.
(__strptime_internal, strptime): Convert K&R definition to ANSI C.
---
 ChangeLog      |  8 ++++++++
 lib/strptime.c | 23 ++++++-----------------
 2 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 692fa95acd..c8d09b3dac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-07-05  Collin Funk  <collin.fu...@gmail.com>
+
+	strptime: Convert K&R definitions to ANSI C.
+	* lib/strptime.c (LOCALE_PARAM) [_LIBC]: Adjust to match glibc, not
+	relevant for Gnulib.
+	(LOCALE_PARAM_PROTO, LOCALE_PARAM_DECL): Remove definitions.
+	(__strptime_internal, strptime): Convert K&R definition to ANSI C.
+
 2025-07-04  Collin Funk  <collin.fu...@gmail.com>
 
 	strncasecmp_l: Fix previous change.
diff --git a/lib/strptime.c b/lib/strptime.c
index 2b6193a105..89388c11bc 100644
--- a/lib/strptime.c
+++ b/lib/strptime.c
@@ -170,17 +170,13 @@ static const unsigned short int __mon_yday[2][13] =
 # undef _NL_CURRENT_WORD
 # define _NL_CURRENT_WORD(category, item) \
   (current->values[_NL_ITEM_INDEX (item)].word)
-# define LOCALE_PARAM , locale
+# define LOCALE_PARAM , __locale_t locale
 # define LOCALE_ARG , locale
-# define LOCALE_PARAM_PROTO , __locale_t locale
-# define LOCALE_PARAM_DECL __locale_t locale;
 # define HELPER_LOCALE_ARG , current
 # define ISSPACE(Ch) __isspace_l (Ch, locale)
 #else
 # define LOCALE_PARAM
 # define LOCALE_ARG
-# define LOCALE_PARAM_DECL
-# define LOCALE_PARAM_PROTO
 # define HELPER_LOCALE_ARG
 # define ISSPACE(Ch) isspace (Ch)
 #endif
@@ -229,13 +225,9 @@ internal_function
 #else
 static char *
 #endif
-__strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
-     const char *rp;
-     const char *fmt;
-     struct tm *tm;
-     enum ptime_locale_status *decided;
-     int era_cnt;
-     LOCALE_PARAM_DECL
+__strptime_internal (const char *rp, const char *fmt, struct tm *tm,
+                     enum ptime_locale_status *decided,
+                     int era_cnt LOCALE_PARAM)
 {
 #ifdef _LIBC
   struct locale_data *const current = locale->__locales[LC_TIME];
@@ -1142,11 +1134,8 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
 
 
 char *
-strptime (buf, format, tm LOCALE_PARAM)
-     const char *restrict buf;
-     const char *restrict format;
-     struct tm *restrict tm;
-     LOCALE_PARAM_DECL
+strptime (const char *restrict buf, const char *restrict format,
+          struct tm *restrict tm LOCALE_PARAM)
 {
   enum ptime_locale_status decided;
 
-- 
2.50.0

Reply via email to