diff options
author | Oliver Kiddle <opk@users.sourceforge.net> | 2005-02-24 16:53:07 +0000 |
---|---|---|
committer | Oliver Kiddle <opk@users.sourceforge.net> | 2005-02-24 16:53:07 +0000 |
commit | ebe071866d8098f1975e3b90dc4f6d81a6b38b31 (patch) | |
tree | 964a0ad5c689652b40133a8c364d838292d074d7 | |
parent | 691dd7e5294d232a7ab8327e2038f9779732fa3c (diff) | |
download | zsh-ebe071866d8098f1975e3b90dc4f6d81a6b38b31.tar.gz zsh-ebe071866d8098f1975e3b90dc4f6d81a6b38b31.tar.xz zsh-ebe071866d8098f1975e3b90dc4f6d81a6b38b31.zip |
20862: attempt to fix configure scripts to detect iconv properly
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Src/system.h | 2 | ||||
-rw-r--r-- | Src/utils.c | 12 | ||||
-rw-r--r-- | configure.ac | 44 |
4 files changed, 51 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog index b754c96ce..358013907 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-02-24 Oliver Kiddle <opk@zsh.org> + + * 20862: configure.ac, Src/system.h, Src/utils.c: attempt to + fix configure scripts to detect iconv properly + 2005-02-24 Peter Stephenson <pws@csr.com> * 20861: Src/Zle/complist.c, Src/Zle/zle.h, Src/Zle/zle_hist.c, @@ -60,6 +65,7 @@ release. 2005-02-19 Motoi Washida <a66@h8.dion.ne.jp> + * users/8522: Completion/Darwin/Command/_defaults: fixed the number of spaces broken while sending the patch by email. diff --git a/Src/system.h b/Src/system.h index f434b586e..7fc4a7e65 100644 --- a/Src/system.h +++ b/Src/system.h @@ -701,7 +701,7 @@ extern short ospeed; #else # ifdef HAVE_LANGINFO_H # include <langinfo.h> -# if defined(HAVE_ICONV_H) || defined(HAVE_ICONV) || defined(HAVE_LIBICONV) +# ifdef HAVE_ICONV # include <iconv.h> # endif # endif diff --git a/Src/utils.c b/Src/utils.c index 0f4e0be8c..236b898f5 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -3456,6 +3456,7 @@ dquotedzputs(char const *s, FILE *stream) # if defined(HAVE_NL_LANGINFO) && defined(CODESET) && !defined(__STDC_ISO_10646__) /* Convert a character from UCS4 encoding to UTF-8 */ +/**/ size_t ucs4toutf8(char *dest, unsigned int wval) { @@ -3480,7 +3481,7 @@ ucs4toutf8(char *dest, unsigned int wval) case 4: dest[3] = (wval & 0x3f) | 0x80; wval >>= 6; case 3: dest[2] = (wval & 0x3f) | 0x80; wval >>= 6; case 2: dest[1] = (wval & 0x3f) | 0x80; wval >>= 6; - *dest = wval | (0xfc << (6 - len)) & 0xfc; + *dest = wval | ((0xfc << (6 - len)) & 0xfc); break; case 1: *dest = wval; } @@ -3522,11 +3523,10 @@ getkeystring(char *s, int *len, int fromwhere, int *misc) size_t count; #else unsigned int wval; -# if defined(HAVE_NL_LANGINFO) && defined(CODESET) && (defined(HAVE_ICONV_H) || defined(HAVE_ICONV) || defined(HAVE_LIBICONV)) +# if defined(HAVE_NL_LANGINFO) && defined(CODESET) && defined(HAVE_ICONV) iconv_t cd; char inbuf[4]; size_t inbytes, outbytes; - char *inptr; size_t count; # endif #endif @@ -3643,10 +3643,10 @@ getkeystring(char *s, int *len, int fromwhere, int *misc) t += ucs4toutf8(t, wval); continue; } else { -# if defined(HAVE_ICONV_H) || defined(HAVE_ICONV) || defined(HAVE_LIBICONV) +# ifdef HAVE_ICONV + ICONV_CONST char *inptr = inbuf; inbytes = 4; outbytes = 6; - inptr = inbuf; /* assume big endian convention for UCS-4 */ for (i=3;i>=0;i--) { inbuf[i] = wval & 0xff; @@ -3664,7 +3664,7 @@ getkeystring(char *s, int *len, int fromwhere, int *misc) *len = t - buf; return buf; } - count = iconv(cd, (char **)&inptr, &inbytes, &t, &outbytes); + count = iconv(cd, &inptr, &inbytes, &t, &outbytes); iconv_close(cd); if (count == (size_t)-1) { zerr("cannot do charset conversion", NULL, 0); diff --git a/configure.ac b/configure.ac index f7a731b08..471b8893d 100644 --- a/configure.ac +++ b/configure.ac @@ -728,13 +728,45 @@ fi AC_CHECK_LIB(socket, socket) -AC_CHECK_LIB(iconv, iconv) +dnl --------------- +dnl CHECK FOR ICONV +dnl --------------- -case "$host_os" in - cygwin | darwin*) - dnl cygwin iconv() is really libiconv() - AC_CHECK_LIB(iconv, libiconv) ;; -esac +dnl Find iconv. It may be in libiconv and may be iconv() or libiconv() +if test "x$ac_cv_header_iconv_h" = "xyes"; then + AC_CHECK_FUNC(iconv, ac_found_iconv=yes, ac_found_iconv=no) + if test "x$ac_found_iconv" = "xno"; then + AC_CHECK_LIB(iconv, iconv, ac_found_iconv=yes) + if test "x$ac_found_iconv" = "xno"; then + AC_CHECK_LIB(iconv, libiconv, ac_found_iconv=yes) + fi + if test "x$ac_found_iconv" != "xno"; then + LIBS="-liconv $LIBS" + fi + fi +fi +if test "x$ac_found_iconv" = xyes; then + AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) +fi + +dnl Check if iconv uses const in prototype declaration +if test "x$ac_found_iconv" = "xyes"; then + AC_CACHE_CHECK(for iconv declaration, ac_cv_iconv_const, + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h> + #include <iconv.h>]], + [[#ifdef __cplusplus + "C" + #endif + #if defined(__STDC__) || defined(__cplusplus) + size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); + #else + size_t iconv(); + #endif]])], + [ac_cv_iconv_const=], + [ac_cv_iconv_const=const])]) + AC_DEFINE_UNQUOTED([ICONV_CONST], $ac_cv_iconv_const, + [Define as const if the declaration of iconv() needs const.]) +fi if test x$enable_pcre = xyes; then dnl pcre-config should probably be employed here |