tony2001                Tue Dec  4 11:27:26 2007 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/iconv  .cvsignore config.m4 iconv.c php_iconv.h 
  Log:
  MFH: detect IBM iconv implementation and use correct encoding names
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/.cvsignore?r1=1.8&r2=1.8.6.1&diff_format=u
Index: php-src/ext/iconv/.cvsignore
diff -u php-src/ext/iconv/.cvsignore:1.8 php-src/ext/iconv/.cvsignore:1.8.6.1
--- php-src/ext/iconv/.cvsignore:1.8    Wed Dec 15 02:29:40 2004
+++ php-src/ext/iconv/.cvsignore        Tue Dec  4 11:27:25 2007
@@ -48,6 +48,7 @@
 *.gcda
 *.gcno
 php_have_bsd_iconv.h
+php_have_ibm_iconv.h
 php_have_libiconv.h
 php_php_iconv_h_path.h
 php_have_glibc_iconv.h  
http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/config.m4?r1=1.33.2.4.2.1&r2=1.33.2.4.2.1.2.1&diff_format=u
Index: php-src/ext/iconv/config.m4
diff -u php-src/ext/iconv/config.m4:1.33.2.4.2.1 
php-src/ext/iconv/config.m4:1.33.2.4.2.1.2.1
--- php-src/ext/iconv/config.m4:1.33.2.4.2.1    Thu Mar  1 11:29:43 2007
+++ php-src/ext/iconv/config.m4 Tue Dec  4 11:27:25 2007
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4,v 1.33.2.4.2.1 2007/03/01 11:29:43 tony2001 Exp $
+dnl $Id: config.m4,v 1.33.2.4.2.1.2.1 2007/12/04 11:27:25 tony2001 Exp $
 dnl
 
 PHP_ARG_WITH(iconv, for iconv support,
@@ -79,9 +79,24 @@
       ])
     fi
 
+    if test -z "$iconv_impl_name"; then
+      AC_MSG_CHECKING([if using IBM iconv])
+      php_iconv_old_ld="$LDFLAGS"
+      LDFLAGS="-liconv $LDFLAGS"
+      AC_TRY_LINK([#include <iconv.h>],[cstoccsid("");],
+      [
+        AC_MSG_RESULT(yes)
+        iconv_impl_name="ibm"
+      ],[
+        AC_MSG_RESULT(no)
+        LDFLAGS="$php_iconv_old_ld"
+      ])
+    fi
+
     echo > ext/iconv/php_have_bsd_iconv.h
     echo > ext/iconv/php_have_glibc_iconv.h
     echo > ext/iconv/php_have_libiconv.h
+    echo > ext/iconv/php_have_ibm_iconv.h
 
     case "$iconv_impl_name" in
       gnu_libiconv [)]
@@ -104,6 +119,12 @@
         PHP_DEFINE([PHP_ICONV_IMPL],[\"glibc\"],[ext/iconv])
         AC_DEFINE([PHP_ICONV_IMPL],["glibc"],[Which iconv implementation to 
use])
         ;;
+      ibm [)]
+        PHP_DEFINE([HAVE_IBM_ICONV],1,[ext/iconv])
+        AC_DEFINE([HAVE_IBM_ICONV],1,[IBM iconv implementation])
+        PHP_DEFINE([PHP_ICONV_IMPL],[\"IBM iconv\"],[ext/iconv])
+        AC_DEFINE([PHP_ICONV_IMPL],["IBM iconv"],[Which iconv implementation 
to use])
+        ;;
     esac
 
     AC_MSG_CHECKING([if iconv supports errno])
http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.124.2.8.2.20.2.4&r2=1.124.2.8.2.20.2.5&diff_format=u
Index: php-src/ext/iconv/iconv.c
diff -u php-src/ext/iconv/iconv.c:1.124.2.8.2.20.2.4 
php-src/ext/iconv/iconv.c:1.124.2.8.2.20.2.5
--- php-src/ext/iconv/iconv.c:1.124.2.8.2.20.2.4        Thu Nov  1 19:13:39 2007
+++ php-src/ext/iconv/iconv.c   Tue Dec  4 11:27:25 2007
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: iconv.c,v 1.124.2.8.2.20.2.4 2007/11/01 19:13:39 tony2001 Exp $ */
+/* $Id: iconv.c,v 1.124.2.8.2.20.2.5 2007/12/04 11:27:25 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1040,7 +1040,7 @@
                goto out;
        }
 
-       cd_pl = iconv_open("ASCII", enc);
+       cd_pl = iconv_open(ICONV_ASCII_ENCODING, enc);
        if (cd_pl == (iconv_t)(-1)) {
 #if ICONV_SUPPORTS_ERRNO
                if (errno == EINVAL) {
@@ -1351,7 +1351,7 @@
                *next_pos = NULL;
        }
 
-       cd_pl = iconv_open(enc, "ASCII");
+       cd_pl = iconv_open(enc, ICONV_ASCII_ENCODING);
 
        if (cd_pl == (iconv_t)(-1)) {
 #if ICONV_SUPPORTS_ERRNO
http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/php_iconv.h?r1=1.28.2.2.2.2&r2=1.28.2.2.2.2.2.1&diff_format=u
Index: php-src/ext/iconv/php_iconv.h
diff -u php-src/ext/iconv/php_iconv.h:1.28.2.2.2.2 
php-src/ext/iconv/php_iconv.h:1.28.2.2.2.2.2.1
--- php-src/ext/iconv/php_iconv.h:1.28.2.2.2.2  Wed Sep 19 00:30:52 2007
+++ php-src/ext/iconv/php_iconv.h       Tue Dec  4 11:27:25 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Revision: 1.28.2.2.2.2 $ */
+/* $Revision: 1.28.2.2.2.2.2.1 $ */
 
 #ifndef PHP_ICONV_H
 #define PHP_ICONV_H
@@ -37,6 +37,7 @@
 #include "ext/iconv/php_have_libiconv.h"
 #include "ext/iconv/php_have_glibc_iconv.h"
 #include "ext/iconv/php_have_bsd_iconv.h"
+#include "ext/iconv/php_have_ibm_iconv.h"
 #include "ext/iconv/php_iconv_supports_errno.h"
 #include "ext/iconv/php_php_iconv_impl.h"
 #include "ext/iconv/php_php_iconv_h_path.h"
@@ -75,9 +76,17 @@
 #define ICONVG(v) (iconv_globals.v)
 #endif
 
-#define ICONV_INPUT_ENCODING "ISO-8859-1" 
-#define ICONV_OUTPUT_ENCODING "ISO-8859-1"
-#define ICONV_INTERNAL_ENCODING "ISO-8859-1" 
+#ifdef HAVE_IBM_ICONV
+# define ICONV_INPUT_ENCODING "ISO8859-1"
+# define ICONV_OUTPUT_ENCODING "ISO8859-1"
+# define ICONV_INTERNAL_ENCODING "ISO8859-1"
+# define ICONV_ASCII_ENCODING "IBM-850"
+#else
+# define ICONV_INPUT_ENCODING "ISO-8859-1"
+# define ICONV_OUTPUT_ENCODING "ISO-8859-1"
+# define ICONV_INTERNAL_ENCODING "ISO-8859-1"
+# define ICONV_ASCII_ENCODING "ASCII"
+#endif
 
 #ifndef ICONV_CSNMAXLEN
 #define ICONV_CSNMAXLEN 64

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to