[Freeciv-Dev] Re: (PR#10002) compile fails without iconv
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10002 >
James Canete wrote:
> It's simple enough to remove the #ifdef HAVE_ICONV #endif around the
> declarations for these variables, but what should the accessor functions
> return if there's no iconv?
Of course the current fciconv.c is supposed to work without iconv.
Really we can probably do anything here: just make sure we return the
same string we're given on any convert() functions and don't do anything
for any of the other functions.
But this patch tries to be as accurate as possible.
jason
? diff
Index: utility/fciconv.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/fciconv.c,v
retrieving revision 1.2
diff -u -r1.2 fciconv.c
--- utility/fciconv.c 6 Sep 2004 17:13:07 -0000 1.2
+++ utility/fciconv.c 10 Sep 2004 00:53:15 -0000
@@ -39,6 +39,11 @@
#ifdef HAVE_ICONV
static char *local_encoding, *data_encoding, *internal_encoding;
+#else
+/* Hack to confuse the compiler into working. */
+# define local_encoding get_local_encoding()
+# define data_encoding get_local_encoding()
+# define internal_encoding get_local_encoding()
#endif
/***************************************************************************
@@ -112,18 +117,40 @@
is_init = TRUE;
}
+/***************************************************************************
+ Return the data encoding (usually UTF-8).
+***************************************************************************/
const char *get_data_encoding(void)
{
assert(is_init);
return data_encoding;
}
+/***************************************************************************
+ Return the local encoding (dependent on the system).
+***************************************************************************/
const char *get_local_encoding(void)
{
+#ifdef HAVE_ICONV
assert(is_init);
return local_encoding;
+#else
+# ifdef HAVE_LIBCHARSET
+ return locale_charset();
+# else
+# ifdef HAVE_LANGINFO_CODESET
+ return nl_langinfo(CODESET);
+# else
+ return "";
+# endif
+# endif
+#endif
}
+/***************************************************************************
+ Return the internal encoding. This depends on the server or GUI being
+ used.
+***************************************************************************/
const char *get_internal_encoding(void)
{
assert(is_init);
@@ -221,6 +248,7 @@
if (buf) {
strncpy(buf, text, bufsz);
buf[bufsz - 1] = '\0';
+ return buf;
} else {
return mystrdup(text);
}
|
|