summaryrefslogtreecommitdiff
path: root/ext/iconv
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 19:39:21 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 19:39:21 -0400
commit6821b67124604da690c5e9276d5370d679c63ac8 (patch)
treebefb4ca2520eb577950cef6cb76d10b914cbf67a /ext/iconv
parentcd0b49c72aee33b3e44a9c589fcd93b9e1c7a64f (diff)
downloadphp-6821b67124604da690c5e9276d5370d679c63ac8.tar.gz
Imported Upstream version 5.3.0RC1upstream/5.3.0_RC1upstream/5.3.0RC1
Diffstat (limited to 'ext/iconv')
-rw-r--r--ext/iconv/config.m423
-rw-r--r--ext/iconv/config.w3211
-rw-r--r--ext/iconv/iconv.c57
-rw-r--r--ext/iconv/php_iconv.h33
4 files changed, 69 insertions, 55 deletions
diff --git a/ext/iconv/config.m4 b/ext/iconv/config.m4
index 2934eb751..bdf0e9bc3 100644
--- a/ext/iconv/config.m4
+++ b/ext/iconv/config.m4
@@ -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 @@ int main() {
])
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 @@ int main() {
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])
diff --git a/ext/iconv/config.w32 b/ext/iconv/config.w32
index 8822ffd29..45574a72e 100644
--- a/ext/iconv/config.w32
+++ b/ext/iconv/config.w32
@@ -1,11 +1,13 @@
-// $Id: config.w32,v 1.6 2004/11/23 12:04:07 edink Exp $
+// $Id: config.w32,v 1.6.6.1 2008/07/06 16:59:13 pajoye Exp $
// vim: ft=javascript
ARG_WITH("iconv", "iconv support", "yes");
if (PHP_ICONV != "no") {
- if (/*CHECK_LIB("iconv.lib", "iconv", PHP_ICONV) &&*/
- CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_ICONV", PHP_ICONV)) {
+ if ((CHECK_LIB("libiconv_a.lib", "iconv", PHP_ICONV) || CHECK_LIB("libiconv.lib", "iconv", PHP_ICONV) ||
+ CHECK_LIB("iconv_a.lib", "iconv", PHP_ICONV) || CHECK_LIB("iconv.lib", "iconv", PHP_ICONV)) &&
+ CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_ICONV", PHP_ICONV)) {
+
EXTENSION("iconv", "iconv.c");
AC_DEFINE("HAVE_ICONV", 1, "Define if iconv extension is enabled");
@@ -16,6 +18,9 @@ if (PHP_ICONV != "no") {
if (!PHP_ICONV_SHARED) {
ADD_DEF_FILE("ext\\iconv\\php_iconv.def");
}
+ } else {
+ WARNING("iconv support can't be enabled, libraries or headers are missing")
+ PHP_ICONV = "no";
}
}
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index a88c3ed5d..8f8da5df9 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: iconv.c,v 1.124.2.8.2.24 2008/12/31 11:17:38 sebastian Exp $ */
+/* $Id: iconv.c,v 1.124.2.8.2.20.2.14 2009/03/17 05:31:04 moriyoshi Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -63,13 +63,11 @@
((c) == sizeof(unsigned long) ? *((unsigned long *)(a)) == *((unsigned long *)(b)) : ((c) == sizeof(unsigned int) ? *((unsigned int *)(a)) == *((unsigned int *)(b)) : memcmp(a, b, c) == 0))
/* {{{ arginfo */
-static
ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_strlen, 0, 0, 1)
ZEND_ARG_INFO(0, str)
ZEND_ARG_INFO(0, charset)
ZEND_END_ARG_INFO()
-static
ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_substr, 0, 0, 2)
ZEND_ARG_INFO(0, str)
ZEND_ARG_INFO(0, offset)
@@ -77,7 +75,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_substr, 0, 0, 2)
ZEND_ARG_INFO(0, charset)
ZEND_END_ARG_INFO()
-static
ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_strpos, 0, 0, 2)
ZEND_ARG_INFO(0, haystack)
ZEND_ARG_INFO(0, needle)
@@ -85,54 +82,46 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_strpos, 0, 0, 2)
ZEND_ARG_INFO(0, charset)
ZEND_END_ARG_INFO()
-static
ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_strrpos, 0, 0, 2)
ZEND_ARG_INFO(0, haystack)
ZEND_ARG_INFO(0, needle)
ZEND_ARG_INFO(0, charset)
ZEND_END_ARG_INFO()
-static
ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_mime_encode, 0, 0, 2)
ZEND_ARG_INFO(0, field_name)
ZEND_ARG_INFO(0, field_value)
ZEND_ARG_INFO(0, preference) /* ZEND_ARG_ARRAY_INFO(0, preference, 1) */
ZEND_END_ARG_INFO()
-static
ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_mime_decode, 0, 0, 1)
ZEND_ARG_INFO(0, encoded_string)
ZEND_ARG_INFO(0, mode)
ZEND_ARG_INFO(0, charset)
ZEND_END_ARG_INFO()
-static
ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_mime_decode_headers, 0, 0, 1)
ZEND_ARG_INFO(0, headers)
ZEND_ARG_INFO(0, mode)
ZEND_ARG_INFO(0, charset)
ZEND_END_ARG_INFO()
-static
ZEND_BEGIN_ARG_INFO(arginfo_iconv, 0)
ZEND_ARG_INFO(0, in_charset)
ZEND_ARG_INFO(0, out_charset)
ZEND_ARG_INFO(0, str)
ZEND_END_ARG_INFO()
-static
ZEND_BEGIN_ARG_INFO(arginfo_ob_iconv_handler, 0)
ZEND_ARG_INFO(0, contents)
ZEND_ARG_INFO(0, status)
ZEND_END_ARG_INFO()
-static
ZEND_BEGIN_ARG_INFO(arginfo_iconv_set_encoding, 0)
ZEND_ARG_INFO(0, type)
ZEND_ARG_INFO(0, charset)
ZEND_END_ARG_INFO()
-static
ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_get_encoding, 0, 0, 0)
ZEND_ARG_INFO(0, type)
ZEND_END_ARG_INFO()
@@ -141,7 +130,7 @@ ZEND_END_ARG_INFO()
/* {{{ iconv_functions[]
*/
-zend_function_entry iconv_functions[] = {
+const zend_function_entry iconv_functions[] = {
PHP_RAW_NAMED_FE(iconv,php_if_iconv, arginfo_iconv)
PHP_FE(ob_iconv_handler, arginfo_ob_iconv_handler)
PHP_FE(iconv_get_encoding, arginfo_iconv_get_encoding)
@@ -228,7 +217,7 @@ static php_iconv_err_t php_iconv_stream_filter_unregister_factory(TSRMLS_D);
/* }}} */
/* {{{ static globals */
-static char _generic_superset_name[] = "UCS-4LE";
+static char _generic_superset_name[] = ICONV_UCS4_ENCODING;
#define GENERIC_SUPERSET_NAME _generic_superset_name
#define GENERIC_SUPERSET_NBYTES 4
/* }}} */
@@ -1040,7 +1029,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn
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) {
@@ -1295,7 +1284,6 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn
char_cnt -= 3;
}
}
- prev_in_left = in_left;
smart_str_appendl(pretval, "?=", sizeof("?=") - 1);
char_cnt -= 2;
@@ -1351,7 +1339,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
*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
@@ -1874,7 +1862,7 @@ static void _php_iconv_show_error(php_iconv_err_t err, const char *out_charset,
Returns the character count of str */
PHP_FUNCTION(iconv_strlen)
{
- char *charset;
+ char *charset = ICONVG(internal_encoding);
int charset_len = 0;
char *str;
int str_len;
@@ -1883,8 +1871,6 @@ PHP_FUNCTION(iconv_strlen)
unsigned int retval;
- charset = ICONVG(internal_encoding);
-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
&str, &str_len, &charset, &charset_len) == FAILURE) {
RETURN_FALSE;
@@ -1909,18 +1895,16 @@ PHP_FUNCTION(iconv_strlen)
Returns specified part of a string */
PHP_FUNCTION(iconv_substr)
{
- char *charset;
+ char *charset = ICONVG(internal_encoding);
int charset_len = 0;
char *str;
int str_len;
- long offset, length;
+ long offset, length = 0;
php_iconv_err_t err;
smart_str retval = {0};
- charset = ICONVG(internal_encoding);
-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|ls",
&str, &str_len, &offset, &length,
&charset, &charset_len) == FAILURE) {
@@ -1951,21 +1935,18 @@ PHP_FUNCTION(iconv_substr)
Finds position of first occurrence of needle within part of haystack beginning with offset */
PHP_FUNCTION(iconv_strpos)
{
- char *charset;
+ char *charset = ICONVG(internal_encoding);
int charset_len = 0;
char *haystk;
int haystk_len;
char *ndl;
int ndl_len;
- long offset;
+ long offset = 0;
php_iconv_err_t err;
unsigned int retval;
- offset = 0;
- charset = ICONVG(internal_encoding);
-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ls",
&haystk, &haystk_len, &ndl, &ndl_len,
&offset, &charset, &charset_len) == FAILURE) {
@@ -2002,7 +1983,7 @@ PHP_FUNCTION(iconv_strpos)
Finds position of last occurrence of needle within part of haystack beginning with offset */
PHP_FUNCTION(iconv_strrpos)
{
- char *charset;
+ char *charset = ICONVG(internal_encoding);
int charset_len = 0;
char *haystk;
int haystk_len;
@@ -2013,8 +1994,6 @@ PHP_FUNCTION(iconv_strrpos)
unsigned int retval;
- charset = ICONVG(internal_encoding);
-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s",
&haystk, &haystk_len, &ndl, &ndl_len,
&charset, &charset_len) == FAILURE) {
@@ -2168,7 +2147,7 @@ PHP_FUNCTION(iconv_mime_decode)
{
char *encoded_str;
int encoded_str_len;
- char *charset;
+ char *charset = ICONVG(internal_encoding);
int charset_len = 0;
long mode = 0;
@@ -2176,8 +2155,6 @@ PHP_FUNCTION(iconv_mime_decode)
php_iconv_err_t err;
- charset = ICONVG(internal_encoding);
-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
&encoded_str, &encoded_str_len, &mode, &charset, &charset_len) == FAILURE) {
@@ -2211,14 +2188,12 @@ PHP_FUNCTION(iconv_mime_decode_headers)
{
const char *encoded_str;
int encoded_str_len;
- char *charset;
+ char *charset = ICONVG(internal_encoding);
int charset_len = 0;
long mode = 0;
php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;
- charset = ICONVG(internal_encoding);
-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
&encoded_str, &encoded_str_len, &mode, &charset, &charset_len) == FAILURE) {
@@ -2278,7 +2253,7 @@ PHP_FUNCTION(iconv_mime_decode_headers)
MAKE_STD_ZVAL(new_elem);
array_init(new_elem);
- ZVAL_ADDREF(*elem);
+ Z_ADDREF_PP(elem);
add_next_index_zval(new_elem, *elem);
zend_hash_update(Z_ARRVAL_P(return_value), header_name, header_name_len, (void *)&new_elem, sizeof(new_elem), NULL);
@@ -2423,7 +2398,7 @@ PHP_FUNCTION(iconv_set_encoding)
PHP_FUNCTION(iconv_get_encoding)
{
char *type = "all";
- int type_len;
+ int type_len = sizeof("all")-1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, &type_len) == FAILURE)
return;
@@ -2784,7 +2759,7 @@ static php_stream_filter *php_iconv_stream_filter_factory_create(const char *nam
return NULL;
}
++from_charset;
- if ((to_charset = strchr(from_charset, '/')) == NULL) {
+ if ((to_charset = strpbrk(from_charset, "/.")) == NULL) {
return NULL;
}
from_charset_len = to_charset - from_charset;
diff --git a/ext/iconv/php_iconv.h b/ext/iconv/php_iconv.h
index ff140fbe3..8e7cd2fd9 100644
--- a/ext/iconv/php_iconv.h
+++ b/ext/iconv/php_iconv.h
@@ -17,19 +17,21 @@
+----------------------------------------------------------------------+
*/
-/* $Revision: 1.28.2.2.2.4 $ */
+/* $Revision: 1.28.2.2.2.2.2.5 $ */
#ifndef PHP_ICONV_H
#define PHP_ICONV_H
#ifdef PHP_WIN32
-#ifdef PHP_ICONV_EXPORTS
-#define PHP_ICONV_API __declspec(dllexport)
+# ifdef PHP_ICONV_EXPORTS
+# define PHP_ICONV_API __declspec(dllexport)
+# else
+# define PHP_ICONV_API __declspec(dllimport)
+# endif
+#elif defined(__GNUC__) && __GNUC__ >= 4
+# define PHP_ICONV_API __attribute__ ((visibility("default")))
#else
-#define PHP_ICONV_API __declspec(dllimport)
-#endif
-#else
-#define PHP_ICONV_API
+# define PHP_ICONV_API
#endif
#ifdef PHP_ATOM_INC
@@ -37,6 +39,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 +78,19 @@ ZEND_END_MODULE_GLOBALS(iconv)
#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"
+# define ICONV_UCS4_ENCODING "UCS-4"
+#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"
+# define ICONV_UCS4_ENCODING "UCS-4LE"
+#endif
#ifndef ICONV_CSNMAXLEN
#define ICONV_CSNMAXLEN 64