diff options
author | rse <rse> | 2007-06-14 07:21:45 +0000 |
---|---|---|
committer | rse <rse> | 2007-06-14 07:21:45 +0000 |
commit | be9e2dcf5d1378597aa702f6bd40fbfc1d914e95 (patch) | |
tree | a84d4a8f7c7e8d051e17dddf5f081a165925964a /poptint.c | |
parent | e7d14e4ae166cd040d5025a693c653d4d2b13bf2 (diff) | |
download | libpopt-be9e2dcf5d1378597aa702f6bd40fbfc1d914e95.tar.gz |
Fix iconv(3) usage.
POPT assumed that iconv(3) is available all the time. This is not
the case. It _might_ be available (and then indicated by the #define
HAVE_ICONV from gettext) if NLS is enabled. But if NLS is disabled
(--disable-nls) then the gettext NLS stuff not even _checks_ for an
available iconv(3) and hence it cannot even be used with an explicit
--with-libiconv-prefix, etc. Hence we POPT can use iconv(3) only for its
UTF-8 fiddling if HAVE_ICONV is defined.
Diffstat (limited to 'poptint.c')
-rw-r--r-- | poptint.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -5,7 +5,9 @@ #include <stdio.h> #include <stdarg.h> #include <errno.h> +#ifdef HAVE_ICONV #include <iconv.h> +#endif #ifdef HAVE_LANGINFO_H #include <langinfo.h> #endif @@ -18,6 +20,7 @@ (retval) = vfprintf ((stream), (format), (args)); \ va_end ((args)); +#ifdef HAVE_ICONV static char * strdup_locale_from_utf8 (char *buffer) { @@ -87,6 +90,7 @@ strdup_locale_from_utf8 (char *buffer) return dest_str; } +#endif static char * strdup_vprintf (const char *format, va_list ap) @@ -124,14 +128,18 @@ POPT_fprintf (FILE* stream, const char *format, ...) buffer = strdup_vprintf (format, args); va_end (args); +#ifdef HAVE_ICONV locale_str = strdup_locale_from_utf8 (buffer); if (locale_str) { retval = fprintf (stream, "%s", locale_str); free (locale_str); } else { fprintf (stderr, POPT_WARNING "%s\n", "Invalid UTF-8"); +#endif retval = fprintf (stream, "%s", buffer); +#ifdef HAVE_ICONV } +#endif free (buffer); return retval; |