Dear Devs,
I would like to propose a small patch that helps readline to compile with a modern C compiler on systems that don't have setlocale() function (so HAVE_SETLOCALE is undefined in config.h).
I'm using the current master branch (5263c0d). To reproduce this issue I manually faked not having setlocale() by commenting out the "#define HAVE_SETLOCALE 1" line in the generated config.h. My compiler version:
$ cc --version
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin21.3.0
Here is the error:
gcc -c -DHAVE_CONFIG_H -I. -I.. -DRL_LIBRARY_VERSION='"8.1"' -DBRACKETED_PASTE_DEFAULT=1 -g -O2 -Wno-parentheses -Wno-format-security ../nls.c
../nls.c:190:3: error: implicit declaration of function 'xfree' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
xfree (t);
^
1 error generated.
The patch is very simple:
From d26afdacfe548d979561cafd845ecf66240540ff Mon Sep 17 00:00:00 2001
From: Andras Kucsma <
andras.kucsma@gmail.com>
Date: Sat, 19 Mar 2022 12:57:33 +0100
Subject: [PATCH] Include xfree() declaration in nls.c
---
nls.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/nls.c b/nls.c
index d2f67e0..b024f9b 100644
--- a/nls.c
+++ b/nls.c
@@ -53,6 +53,7 @@
#include "readline.h"
#include "rlshell.h"
#include "rlprivate.h"
+#include "xmalloc.h"
static int utf8locale PARAMS((char *));
--
2.31.1
Thank you,
Andras