Hi Bruno,

Bruno Haible via Gnulib discussion list <bug-gnulib@gnu.org> writes:

>       newlocale: Work around macOS, NetBSD, Solaris 11 OpenIndiana bug.
>       * m4/newlocale.m4 (gl_FUNC_NEWLOCALE): Test for the "null base" bug.
>       Set REPLACE_NEWLOCALE to 1 if it has the bug.
>       * lib/newlocale.c (newlocale): Add alternative implementation that uses
>       the system's newlocale().
>       * modules/newlocale (configure.ac): Consider REPLACE_NEWLOCALE.
>       * tests/test-newlocale.c: Include <langinfo.h>.
>       (main): Verify fix for the "null base" bug.
>       * modules/newlocale-tests (configure.ac): Test for nl_langinfo_l.
>       * doc/posix-functions/newlocale.texi: Mention the "null base" bug.

One very minor issue with this change. NetBSD will complain about
implicit function declarations since some headers are not included.

I have pushed the attached patch to fix them.

Collin

>From 7d0d2480143d46dc9ee8dfd17d4149b84d5eab2e Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sun, 23 Mar 2025 14:33:49 -0700
Subject: [PATCH] newlocale: Fix implicit function declarations.

* lib/newlocale.c [HAVE_NEWLOCALE]: Include string.h for strlen and
strcmp, stdio.h for sprintf, and stdlib.h for free.
---
 ChangeLog       | 6 ++++++
 lib/newlocale.c | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 12aa0404b6..10c428e81f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-03-23  Collin Funk  <collin.fu...@gmail.com>
+
+	newlocale: Fix implicit function declarations.
+	* lib/newlocale.c [HAVE_NEWLOCALE]: Include string.h for strlen and
+	strcmp, stdio.h for sprintf, and stdlib.h for free.
+
 2025-03-22  Bruno Haible  <br...@clisp.org>
 
 	getlocalename_l-unsafe: Add Android workaround, like on OpenBSD.
diff --git a/lib/newlocale.c b/lib/newlocale.c
index ccce715852..7635fb691f 100644
--- a/lib/newlocale.c
+++ b/lib/newlocale.c
@@ -28,6 +28,9 @@
 
 # include <sys/types.h>
 # include <sys/stat.h>
+# include <stdlib.h>
+# include <stdio.h>
+# include <string.h>
 
 locale_t
 newlocale (int category_mask, const char *name, locale_t base)
-- 
2.49.0

Reply via email to