]> granicus.if.org Git - php/commitdiff
MFH(r-1.22, r-1.90, r-1.18): avoid miscellaneous conflicts between glibc's
authorMoriyoshi Koizumi <moriyoshi@php.net>
Sun, 6 Jul 2003 21:11:51 +0000 (21:11 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Sun, 6 Jul 2003 21:11:51 +0000 (21:11 +0000)
iconv and libiconv.

ext/iconv/config.m4
ext/iconv/iconv.c
ext/iconv/php_iconv.h

index 37f82eb4796e915ab813b5c2fa01b559ae0e0969..5700cc91adc2d5396e94957acef6782263b1f206 100644 (file)
@@ -15,44 +15,22 @@ if test "$PHP_ICONV" != "no"; then
 
   if test "$iconv_avail" != "no"; then
     iconv_cflags_save="$CFLAGS"
-    CFLAGS="$CFLAGS $INCLUDES"
-    AC_MSG_CHECKING([if iconv supports errno])
-    AC_TRY_RUN([
-#define LIBICONV_PLUG
-#include <iconv.h>
-#include <errno.h>
-#if defined(_LIBICONV_H)
-#define icv_open(a, b) libiconv_open(a, b)
-#define icv_close(a) libiconv_close(a)
-#define icv(a, b, c, d, e) libiconv(a, b, c, d, e)
-#else
-#define icv_open(a, b) iconv_open(a, b)
-#define icv_close(a) iconv_close(a)
-#define icv(a, b, c, d, e) iconv(a, b, c, d, e)
-#endif
+    iconv_ldflags_save="$LDFLAGS"
 
-int main() {
-       iconv_t cd;
-       cd = icv_open( "*blahblah*", "*blahblah*" );
-       if( cd == (iconv_t)(-1) ) {
-               if( errno == EINVAL ) {
-                       return 0;
-               } else {
-                       return 1;
-               }
-       }
-       icv_close( cd );
-       return 2;
-}
-    ],[
-      AC_MSG_RESULT(yes)
-      PHP_DEFINE([ICONV_SUPPORTS_ERRNO],1)
-      AC_DEFINE([ICONV_SUPPORTS_ERRNO],1,[Whether iconv supports error no or not])
-    ],[
-      AC_MSG_RESULT(no)
-      PHP_DEFINE([ICONV_SUPPORTS_ERRNO],0)
-      AC_DEFINE([ICONV_SUPPORTS_ERRNO],0,[Whether iconv supports error no or not])
-    ])
+    if test -z "$ICONV_DIR"; then
+      PHP_ICONV_PREFIX="/usr"
+    else
+      PHP_ICONV_PREFIX="$ICONV_DIR"
+    fi
+
+    CFLAGS="-I$PHP_ICONV_PREFIX/include $CFLAGS"
+    LDFLAGS="-L$PHP_ICONV_PREFIX/lib $LDFLAGS"
+
+    if test -r $PHP_ICONV_PREFIX/include/giconv.h; then
+      PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/giconv.h"
+    else
+      PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/iconv.h"
+    fi 
 
     if test -z "$iconv_lib_name"; then
       AC_MSG_CHECKING([if iconv is glibc's])
@@ -108,7 +86,39 @@ int main() {
         ;;
     esac
 
+    AC_MSG_CHECKING([if iconv supports errno])
+    AC_TRY_RUN([
+#include <$PHP_ICONV_H_PATH>
+#include <errno.h>
+
+int main() {
+  iconv_t cd;
+  cd = iconv_open( "*blahblah*", "*blahblah*" );
+  if (cd == (iconv_t)(-1)) {
+    if (errno == EINVAL) {
+      return 0;
+       } else {
+      return 1;
+    }
+  }
+  iconv_close( cd );
+  return 2;
+}
+    ],[
+      AC_MSG_RESULT(yes)
+      PHP_DEFINE([ICONV_SUPPORTS_ERRNO],1)
+      AC_DEFINE([ICONV_SUPPORTS_ERRNO],1,[Whether iconv supports error no or not])
+    ],[
+      AC_MSG_RESULT(no)
+      PHP_DEFINE([ICONV_SUPPORTS_ERRNO],0)
+      AC_DEFINE([ICONV_SUPPORTS_ERRNO],0,[Whether iconv supports error no or not])
+    ])
+
     CFLAGS="$iconv_cflags_save"
+    LDFLAGS="$iconv_ldflags_save"
+
+    PHP_DEFINE([PHP_ICONV_H_PATH], [<$PHP_ICONV_H_PATH>])
+    AC_DEFINE_UNQUOTED([PHP_ICONV_H_PATH], [<$PHP_ICONV_H_PATH>], [Path to iconv.h])
 
     PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared)
     PHP_SUBST(ICONV_SHARED_LIBADD)
index 284239c95d21bf1bc2e8070d6193b151e45d5c4f..815cfe0de803112edb2b3d8a26d042f9dcd10e95 100644 (file)
 
 #ifdef HAVE_ICONV
 
-#ifdef HAVE_GICONV_H
-#include <giconv.h>
-#else
-#include <iconv.h>
+#ifndef PHP_ICONV_H_PATH
+#define PHP_ICONV_H_PATH <iconv.h>
 #endif
 
+#include PHP_ICONV_H_PATH
+
 #ifdef HAVE_GLIBC_ICONV
 #include <gnu/libc-version.h>
 #endif
 
-#ifdef HAVE_LIBICONV
-#define LIBICONV_PLUG
-#define icv_open(a, b) libiconv_open(a, b)
-#define icv_close(a) libiconv_close(a)
-#define icv(a, b, c, d, e) libiconv(a, b, c, d, e)
-#else
-#define icv_open(a, b) iconv_open(a, b)
-#define icv_close(a) iconv_close(a)
-#define icv(a, b, c, d, e) iconv(a, (char **) b, c, d, e)
-#endif
-
 /* {{{ iconv_functions[]
  */
 function_entry iconv_functions[] = {
@@ -213,7 +202,7 @@ php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
 
        in_size = in_len;
 
-       cd = icv_open(out_charset, in_charset);
+       cd = icov_open(out_charset, in_charset);
        
        if (cd == (iconv_t)(-1)) {
                return PHP_ICONV_ERR_UNKNOWN;
@@ -222,7 +211,7 @@ php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
        out_buffer = (char *) emalloc(out_size + 1);
        out_p = out_buffer;
        
-       result = icv(cd, (const char **) &in_p, &in_size, (char **)
+       result = iconv(cd, (const char **) &in_p, &in_size, (char **)
                                &out_p, &out_left);
        
        if (result == (size_t)(-1)) {
@@ -235,7 +224,7 @@ php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
        }
 
        /* flush the shift-out sequences */ 
-       result = icv(cd, NULL, NULL, &out_p, &out_left);
+       result = iconv(cd, NULL, NULL, &out_p, &out_left);
 
        if (result == (size_t)(-1)) {
                efree(out_buffer);
@@ -246,7 +235,7 @@ php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
        out_buffer[*out_len] = '\0';
        *out = out_buffer;
 
-       icv_close(cd);
+       iconv_close(cd);
 
        return PHP_ICONV_ERR_SUCCESS;
 
@@ -263,7 +252,7 @@ php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
        *out = NULL;
        *out_len = 0;
 
-       cd = icv_open(out_charset, in_charset);
+       cd = iconv_open(out_charset, in_charset);
 
        if (cd == (iconv_t)(-1)) {
                if (errno == EINVAL) {
@@ -280,7 +269,7 @@ php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
        out_p = out_buf;
 
        while (in_left > 0) {
-               result = icv(cd, (const char **) &in_p, &in_left, (char **) &out_p, &out_left);
+               result = iconv(cd, (const char **) &in_p, &in_left, (char **) &out_p, &out_left);
                out_size = bsz - out_left;
                if (result == (size_t)(-1)) {
                        if (errno == E2BIG && in_left > 0) {
@@ -303,7 +292,7 @@ php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
        if (result != (size_t)(-1)) {
                /* flush the shift-out sequences */ 
                for (;;) {
-                       result = icv(cd, NULL, NULL, (char **) &out_p, &out_left);
+                       result = iconv(cd, NULL, NULL, (char **) &out_p, &out_left);
                        out_size = bsz - out_left;
 
                        if (result != (size_t)(-1)) {
@@ -327,7 +316,7 @@ php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
                }
        }
 
-       icv_close(cd);
+       iconv_close(cd);
 
        if (result == (size_t)(-1)) {
                switch (errno) {
index db8c9d65bd8d473123cd983192bd5203f790ee9b..cd6fe83a2577bc482015e54d93dbf53a03e3528c 100644 (file)
@@ -35,6 +35,7 @@
 #include "php_have_bsd_iconv.h"
 #include "php_iconv_supports_errno.h"
 #include "php_php_iconv_impl.h"
+#include "php_php_iconv_h_path.h"
 #endif