From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11615 invoked from network); 24 Feb 2005 16:39:45 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 24 Feb 2005 16:39:45 -0000 Received: (qmail 31424 invoked from network); 24 Feb 2005 16:39:39 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 24 Feb 2005 16:39:39 -0000 Received: (qmail 15925 invoked by alias); 24 Feb 2005 16:39:36 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20862 Received: (qmail 15911 invoked from network); 24 Feb 2005 16:39:35 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 24 Feb 2005 16:39:35 -0000 Received: (qmail 31124 invoked from network); 24 Feb 2005 16:39:35 -0000 Received: from mail36.messagelabs.com (193.109.254.211) by a.mx.sunsite.dk with SMTP; 24 Feb 2005 16:39:30 -0000 X-VirusChecked: Checked X-Env-Sender: okiddle@yahoo.co.uk X-Msg-Ref: server-3.tower-36.messagelabs.com!1109263168!14327195!1 X-StarScan-Version: 5.4.11; banners=-,-,- X-Originating-IP: [158.234.9.163] Received: (qmail 5552 invoked from network); 24 Feb 2005 16:39:28 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-3.tower-36.messagelabs.com with SMTP; 24 Feb 2005 16:39:28 -0000 Received: from trentino.logica.co.uk ([158.234.142.59]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id j1OGdS61018875 for ; Thu, 24 Feb 2005 16:39:28 GMT Received: from trentino.logica.co.uk (localhost [127.0.0.1]) by trentino.logica.co.uk (Postfix) with ESMTP id C3016343EE for ; Thu, 24 Feb 2005 17:39:07 +0100 (CET) X-VirusChecked: Checked X-StarScan-Version: 5.1.13; banners=.,-,- From: Oliver Kiddle To: Zsh workers Subject: configure tests for iconv Date: Thu, 24 Feb 2005 17:39:07 +0100 Message-ID: <5964.1109263147@trentino.logica.co.uk> X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 The following is an attempt to get the configure tests for iconv to work properly. I've not actually been able to test this on any of the critical systems such as Cygwin or Mac OS X (or any system that needs -liconv for that matter) so I don't know for sure that it works. I've also tried to clear up the compiler warnings. This includes a section of configure to find out if the iconv() prototype uses const. Bits of this was copied from various other configure scripts. Oliver Index: configure.ac =================================================================== RCS file: /cvsroot/zsh/zsh/configure.ac,v retrieving revision 1.28 diff -u -r1.28 configure.ac --- configure.ac 14 Feb 2005 13:56:21 -0000 1.28 +++ configure.ac 24 Feb 2005 16:25:26 -0000 @@ -728,13 +728,45 @@ 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 + #include ]], + [[#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 Index: Src/system.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/system.h,v retrieving revision 1.29 diff -u -r1.29 system.h --- Src/system.h 22 Feb 2005 13:12:55 -0000 1.29 +++ Src/system.h 24 Feb 2005 16:25:26 -0000 @@ -701,7 +701,7 @@ #else # ifdef HAVE_LANGINFO_H # include -# if defined(HAVE_ICONV_H) || defined(HAVE_ICONV) || defined(HAVE_LIBICONV) +# ifdef HAVE_ICONV # include # endif # endif Index: Src/utils.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/utils.c,v retrieving revision 1.73 diff -u -r1.73 utils.c --- Src/utils.c 22 Feb 2005 18:24:45 -0000 1.73 +++ Src/utils.c 24 Feb 2005 16:25:27 -0000 @@ -3456,6 +3456,7 @@ # 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 @@ 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 @@ 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 @@ 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 @@ *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);