aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2024-09-11 04:55:48 +0200
committerPřemysl Eric Janouch <p@janouch.name>2024-09-11 04:55:59 +0200
commitb87fbc93a64d9b5dd219396fc5c98e8779c55810 (patch)
treebb202a699a61733dcef0c3152fa5824137171917
parentac1a21eac8b5dfaa479ee3b552a49a9f172296e0 (diff)
downloadjson-rpc-shell-b87fbc93a64d9b5dd219396fc5c98e8779c55810.tar.gz
json-rpc-shell-b87fbc93a64d9b5dd219396fc5c98e8779c55810.tar.xz
json-rpc-shell-b87fbc93a64d9b5dd219396fc5c98e8779c55810.zip
Support musl libcorigin/master
-rw-r--r--CMakeLists.txt20
-rw-r--r--config.h.in2
-rw-r--r--json-rpc-shell.c5
3 files changed, 18 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6afeaa4..501ea3a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,12 +29,6 @@ set (project_libraries ${dependencies_LIBRARIES} ${LibEV_LIBRARIES})
include_directories (${dependencies_INCLUDE_DIRS} ${LibEV_INCLUDE_DIRS})
link_directories (${dependencies_LIBRARY_DIRS})
-# -liconv may or may not be a part of libc
-find_library (iconv_LIBRARIES iconv)
-if (iconv_LIBRARIES)
- list (APPEND project_libraries ${iconv_LIBRARIES})
-endif ()
-
if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
# Need this for SIGWINCH in FreeBSD and OpenBSD respectively;
# our POSIX version macros make it undefined
@@ -43,6 +37,20 @@ elseif (APPLE)
add_definitions (-D_DARWIN_C_SOURCE)
endif ()
+# -liconv may or may not be a part of libc
+find_library (iconv_LIBRARIES iconv)
+if (iconv_LIBRARIES)
+ list (APPEND project_libraries ${iconv_LIBRARIES})
+endif ()
+
+include (CheckCSourceRuns)
+set (CMAKE_REQUIRED_LIBRARIES ${project_libraries})
+get_property (CMAKE_REQUIRED_INCLUDES
+ DIRECTORY "${PROJECT_SOURCE_DIR}" PROPERTY INCLUDE_DIRECTORIES)
+CHECK_C_SOURCE_RUNS ("#include <iconv.h>
+ int main () { return iconv_open (\"UTF-8//TRANSLIT\", \"ISO-8859-1\")
+ == (iconv_t) -1; }" ICONV_ACCEPTS_TRANSLIT)
+
if (Ncursesw_FOUND)
list (APPEND project_libraries ${Ncursesw_LIBRARIES})
include_directories (${Ncursesw_INCLUDE_DIRS})
diff --git a/config.h.in b/config.h.in
index 87e075c..644d58a 100644
--- a/config.h.in
+++ b/config.h.in
@@ -7,5 +7,7 @@
#cmakedefine HAVE_READLINE
#cmakedefine HAVE_EDITLINE
+#cmakedefine01 ICONV_ACCEPTS_TRANSLIT
+
#endif // ! CONFIG_H
diff --git a/json-rpc-shell.c b/json-rpc-shell.c
index 86e291d..a80be5d 100644
--- a/json-rpc-shell.c
+++ b/json-rpc-shell.c
@@ -4076,11 +4076,10 @@ main (int argc, char *argv[])
setlocale (LC_CTYPE, "");
char *encoding = nl_langinfo (CODESET);
-#ifdef __linux__
// XXX: not quite sure if this is actually desirable
// TODO: instead retry with JSON_ENSURE_ASCII
- encoding = xstrdup_printf ("%s//TRANSLIT", encoding);
-#endif // __linux__
+ if (ICONV_ACCEPTS_TRANSLIT)
+ encoding = xstrdup_printf ("%s//TRANSLIT", encoding);
if ((g_ctx.term_from_utf8 = iconv_open (encoding, "UTF-8"))
== (iconv_t) -1