void-packages/srcpkgs/man-db/patches/guard-glibc-iconv-ext.patch

61 lines
2.2 KiB
Diff

src/convert.c | 4 ++++
src/manconv.c | 7 ++++++-
src/manconv_client.c | 4 ++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/convert.c b/src/convert.c
index 447240c6..231f5c14 100644
--- a/src/convert.c
+++ b/src/convert.c
@@ -55,10 +55,14 @@ static void close_conv_to_locale (void *ignored MAYBE_UNUSED)
char * ATTRIBUTE_MALLOC convert_to_locale (char *string)
{
if (!conv_to_locale_initialized) {
+#ifdef __GLIBC__
char *locale_charset = xasprintf
("%s//IGNORE", get_locale_charset ());
conv_to_locale = iconv_open (locale_charset, "UTF-8");
free (locale_charset);
+#else /* __GLIBC__ */
+ conv_to_locale = iconv_open (get_locale_charset (), "UTF-8");
+#endif /* ! __GLIBC__ */
if (conv_to_locale != (iconv_t) -1)
push_cleanup (close_conv_to_locale, NULL, 0);
conv_to_locale_initialized = true;
diff --git a/src/manconv.c b/src/manconv.c
index 18ae307a..e2e6aa33 100644
--- a/src/manconv.c
+++ b/src/manconv.c
@@ -301,9 +301,14 @@ static tried_iconv try_iconv (decompress *decomp, const char *try_from_code,
iconv_t cd_utf8, cd = NULL;
bool to_utf8 = STREQ (try_to_code, "UTF-8") ||
STRNEQ (try_to_code, "UTF-8//", 7);
- const char *utf8_target = last ? "UTF-8//IGNORE" : "UTF-8";
bool ignore_errors = (strstr (try_to_code, "//IGNORE") != NULL);
tried_iconv ret = TRIED_ICONV_OK;
+#ifdef __GLIBC__
+ const char *utf8_target = last ? "UTF-8//IGNORE" : "UTF-8";
+#else /* __GLIBC__ */
+ const char *utf8_target = "UTF-8";
+ last = false;
+#endif /* ! __GLIBC__ */
debug ("trying encoding %s -> %s\n", try_from_code, try_to_code);
diff --git a/src/manconv_client.c b/src/manconv_client.c
index 55289ff4..6e7861f5 100644
--- a/src/manconv_client.c
+++ b/src/manconv_client.c
@@ -111,7 +111,11 @@ void add_manconv (pipeline *p,
gl_list_add_last (codes->from, xstrdup (source_encoding));
name = appendstr (name, "UTF-8:", source_encoding, (void *) 0);
}
+#ifdef __GBLIBC__
codes->to = xasprintf ("%s//IGNORE", target_encoding);
+#else /* __GLIBC__ */
+ codes->to = xasprintf ("%s", target_encoding);
+#endif /* ! __GLIBC__ */
/* informational only; no shell quoting concerns */
name = appendstr (name, " -t ", codes->to, (void *) 0);
if (quiet >= 2)