diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:35:13 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:35:13 -0400 |
| commit | 0a36161e13484a99ccf69bb38f206462d27cc6d6 (patch) | |
| tree | d5107db4b7369603ac7c753829e8972ee74949f7 /ext/mbstring | |
| parent | ce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (diff) | |
| download | php-upstream/5.1.2.tar.gz | |
Imported Upstream version 5.1.2upstream/5.1.2
Diffstat (limited to 'ext/mbstring')
| -rw-r--r-- | ext/mbstring/config.m4 | 3 | ||||
| -rw-r--r-- | ext/mbstring/config.w32 | 4 | ||||
| -rw-r--r-- | ext/mbstring/libmbfl/mbfl/mbfilter.c | 37 | ||||
| -rw-r--r-- | ext/mbstring/libmbfl/mbfl/mbfilter.h | 5 | ||||
| -rw-r--r-- | ext/mbstring/libmbfl/mbfl/mbfl_language.c | 2 | ||||
| -rw-r--r-- | ext/mbstring/libmbfl/mbfl/mbfl_language.h | 1 | ||||
| -rw-r--r-- | ext/mbstring/libmbfl/nls/nls_tr.c | 21 | ||||
| -rw-r--r-- | ext/mbstring/libmbfl/nls/nls_tr.h | 8 | ||||
| -rw-r--r-- | ext/mbstring/mb_gpc.c | 10 | ||||
| -rw-r--r-- | ext/mbstring/mb_gpc.h | 6 | ||||
| -rw-r--r-- | ext/mbstring/mbstring.c | 77 | ||||
| -rw-r--r-- | ext/mbstring/mbstring.h | 9 | ||||
| -rw-r--r-- | ext/mbstring/php_mbregex.c | 8 | ||||
| -rw-r--r-- | ext/mbstring/php_mbregex.h | 8 | ||||
| -rw-r--r-- | ext/mbstring/php_unicode.c | 53 | ||||
| -rw-r--r-- | ext/mbstring/php_unicode.h | 6 | ||||
| -rw-r--r-- | ext/mbstring/tests/bug28220.phpt | 2 | ||||
| -rw-r--r-- | ext/mbstring/tests/bug30549.phpt | 2 | ||||
| -rw-r--r-- | ext/mbstring/tests/bug31911.phpt | 2 | ||||
| -rw-r--r-- | ext/mbstring/tests/mb_strcut.phpt | 2 |
20 files changed, 199 insertions, 67 deletions
diff --git a/ext/mbstring/config.m4 b/ext/mbstring/config.m4 index b9980ed9c..98df11f48 100644 --- a/ext/mbstring/config.m4 +++ b/ext/mbstring/config.m4 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4,v 1.58.2.2 2005/10/28 07:52:58 hyanantha Exp $ +dnl $Id: config.m4,v 1.58.2.3 2005/12/23 15:18:52 hirokawa Exp $ dnl AC_DEFUN([PHP_MBSTRING_ADD_SOURCES], [ @@ -237,6 +237,7 @@ AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [ libmbfl/nls/nls_uni.c libmbfl/nls/nls_zh.c libmbfl/nls/nls_hy.c + libmbfl/nls/nls_tr.c ]) PHP_MBSTRING_ADD_CFLAG([-DHAVE_CONFIG_H]) else diff --git a/ext/mbstring/config.w32 b/ext/mbstring/config.w32 index 6fc28084c..c4976a9c9 100644 --- a/ext/mbstring/config.w32 +++ b/ext/mbstring/config.w32 @@ -1,4 +1,4 @@ -// $Id: config.w32,v 1.10 2005/03/22 22:22:08 moriyoshi Exp $ +// $Id: config.w32,v 1.10.2.1 2005/12/23 15:18:52 hirokawa Exp $ // vim:ft=javascript ARG_ENABLE("mbstring", "multibyte string functions", "no"); @@ -40,7 +40,7 @@ if (PHP_MBSTRING == "yes") { ADD_SOURCES("ext/mbstring/libmbfl/nls", "nls_de.c nls_en.c nls_ja.c \ nls_kr.c nls_neutral.c nls_ru.c nls_uni.c nls_zh.c nls_hy.c \ - ", "mbstring"); + nls_tr.c", "mbstring"); AC_DEFINE('HAVE_MBSTRING', 1, 'Have mbstring support'); AC_DEFINE('HAVE_MBSTR_CN', 1, 'CN'); diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c index 0e7072fda..ec3409d8e 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfilter.c +++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c @@ -336,7 +336,7 @@ mbfl_buffer_converter_feed_result(mbfl_buffer_converter *convd, mbfl_string *str * encoding detector */ mbfl_encoding_detector * -mbfl_encoding_detector_new(enum mbfl_no_encoding *elist, int elistsz) +mbfl_encoding_detector_new(enum mbfl_no_encoding *elist, int elistsz, int strict) { mbfl_encoding_detector *identd; @@ -371,6 +371,9 @@ mbfl_encoding_detector_new(enum mbfl_no_encoding *elist, int elistsz) } identd->filter_list_size = num; + /* set strict flag */ + identd->strict = strict; + return identd; } @@ -441,10 +444,24 @@ enum mbfl_no_encoding mbfl_encoding_detector_judge(mbfl_encoding_detector *ident while (n >= 0) { filter = identd->filter_list[n]; if (!filter->flag) { + if (identd->strict && filter->status) { + continue; + } encoding = filter->encoding->no_encoding; } n--; } + + if (encoding == mbfl_no_encoding_invalid) { + n = identd->filter_list_size - 1; + while (n >= 0) { + filter = identd->filter_list[n]; + if (!filter->flag) { + encoding = filter->encoding->no_encoding; + } + n--; + } + } } return encoding; @@ -576,11 +593,25 @@ mbfl_identify_encoding(mbfl_string *string, enum mbfl_no_encoding *elist, int el for (i = 0; i < num; i++) { filter = &flist[i]; if (!filter->flag) { + if (strict && filter->status) { + continue; + } encoding = filter->encoding; break; } } + /* fall-back judge */ + if (!encoding) { + for (i = 0; i < num; i++) { + filter = &flist[i]; + if (!filter->flag) { + encoding = filter->encoding; + break; + } + } + } + /* cleanup */ /* dtors should be called in reverse order */ i = num; while (--i >= 0) { @@ -608,11 +639,11 @@ mbfl_identify_encoding_name(mbfl_string *string, enum mbfl_no_encoding *elist, i } enum mbfl_no_encoding -mbfl_identify_encoding_no(mbfl_string *string, enum mbfl_no_encoding *elist, int elistsz) +mbfl_identify_encoding_no(mbfl_string *string, enum mbfl_no_encoding *elist, int elistsz, int strict) { const mbfl_encoding *encoding; - encoding = mbfl_identify_encoding(string, elist, elistsz, 0); + encoding = mbfl_identify_encoding(string, elist, elistsz, strict); if (encoding != NULL && encoding->no_encoding > mbfl_no_encoding_charset_min && encoding->no_encoding < mbfl_no_encoding_charset_max) { diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.h b/ext/mbstring/libmbfl/mbfl/mbfilter.h index d0965251a..702079ac4 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfilter.h +++ b/ext/mbstring/libmbfl/mbfl/mbfilter.h @@ -138,9 +138,10 @@ typedef struct _mbfl_encoding_detector mbfl_encoding_detector; struct _mbfl_encoding_detector { mbfl_identify_filter **filter_list; int filter_list_size; + int strict; }; -MBFLAPI extern mbfl_encoding_detector * mbfl_encoding_detector_new(enum mbfl_no_encoding *elist, int elistsz); +MBFLAPI extern mbfl_encoding_detector * mbfl_encoding_detector_new(enum mbfl_no_encoding *elist, int elistsz, int strict); MBFLAPI extern void mbfl_encoding_detector_delete(mbfl_encoding_detector *identd); MBFLAPI extern int mbfl_encoding_detector_feed(mbfl_encoding_detector *identd, mbfl_string *string); MBFLAPI extern enum mbfl_no_encoding mbfl_encoding_detector_judge(mbfl_encoding_detector *identd); @@ -163,7 +164,7 @@ MBFLAPI extern const char * mbfl_identify_encoding_name(mbfl_string *string, enum mbfl_no_encoding *elist, int elistsz, int strict); MBFLAPI extern enum mbfl_no_encoding -mbfl_identify_encoding_no(mbfl_string *string, enum mbfl_no_encoding *elist, int elistsz); +mbfl_identify_encoding_no(mbfl_string *string, enum mbfl_no_encoding *elist, int elistsz, int strict); /* * strlen diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_language.c b/ext/mbstring/libmbfl/mbfl/mbfl_language.c index c5dab6550..aaeebbc8e 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfl_language.c +++ b/ext/mbstring/libmbfl/mbfl/mbfl_language.c @@ -59,6 +59,7 @@ #include "nls/nls_ru.h" #include "nls/nls_en.h" #include "nls/nls_hy.h" +#include "nls/nls_tr.h" #include "nls/nls_neutral.h" #ifndef HAVE_STRCASECMP @@ -77,6 +78,7 @@ static const mbfl_language *mbfl_language_ptr_table[] = { &mbfl_language_german, &mbfl_language_russian, &mbfl_language_armenian, + &mbfl_language_turkish, &mbfl_language_neutral, NULL }; diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_language.h b/ext/mbstring/libmbfl/mbfl/mbfl_language.h index f6b9ec208..caf1d8094 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfl_language.h +++ b/ext/mbstring/libmbfl/mbfl/mbfl_language.h @@ -58,6 +58,7 @@ enum mbfl_no_language { mbfl_no_language_traditional_chinese, /* zh-tw */ mbfl_no_language_russian, /* ru */ mbfl_no_language_armenian, /* hy */ + mbfl_no_language_turkish, /* tr */ mbfl_no_language_max }; diff --git a/ext/mbstring/libmbfl/nls/nls_tr.c b/ext/mbstring/libmbfl/nls/nls_tr.c new file mode 100644 index 000000000..c7044ff29 --- /dev/null +++ b/ext/mbstring/libmbfl/nls/nls_tr.c @@ -0,0 +1,21 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_STDDEF_H +#include <stddef.h> +#endif + +#include "mbfilter.h" +#include "nls_tr.h" + +const mbfl_language mbfl_language_turkish = { + mbfl_no_language_turkish, + "Turkish", + "tr", + NULL, + mbfl_no_encoding_8859_9, + mbfl_no_encoding_qprint, + mbfl_no_encoding_8bit +}; + diff --git a/ext/mbstring/libmbfl/nls/nls_tr.h b/ext/mbstring/libmbfl/nls/nls_tr.h new file mode 100644 index 000000000..5c17f7daa --- /dev/null +++ b/ext/mbstring/libmbfl/nls/nls_tr.h @@ -0,0 +1,8 @@ +#ifndef MBFL_NLS_TR_H +#define MBFL_NLS_TR_H + +#include "mbfilter.h" + +extern const mbfl_language mbfl_language_turkish; + +#endif /* MBFL_NLS_TR_H */ diff --git a/ext/mbstring/mb_gpc.c b/ext/mbstring/mb_gpc.c index 781da2c2f..2cf57b7fc 100644 --- a/ext/mbstring/mb_gpc.c +++ b/ext/mbstring/mb_gpc.c @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mb_gpc.c,v 1.17 2005/08/03 14:07:24 sniper Exp $ */ +/* $Id: mb_gpc.c,v 1.17.2.2 2006/01/01 12:50:08 sniper Exp $ */ /* {{{ includes */ #ifdef HAVE_CONFIG_H @@ -266,7 +266,7 @@ enum mbfl_no_encoding _php_mb_encoding_handler_ex(const php_mb_encoding_handler_ } else { /* auto detect */ from_encoding = mbfl_no_encoding_invalid; - identd = mbfl_encoding_detector_new((enum mbfl_no_encoding *)info->from_encodings, info->num_from_encodings); + identd = mbfl_encoding_detector_new((enum mbfl_no_encoding *)info->from_encodings, info->num_from_encodings, MBSTRG(strict_detection)); if (identd) { n = 0; while (n < num) { diff --git a/ext/mbstring/mb_gpc.h b/ext/mbstring/mb_gpc.h index 32bb3b551..fdeb595d0 100644 --- a/ext/mbstring/mb_gpc.h +++ b/ext/mbstring/mb_gpc.h @@ -4,10 +4,10 @@ +----------------------------------------------------------------------+ | Copyright (c) 2001 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mb_gpc.h,v 1.5 2005/01/16 15:55:17 moriyoshi Exp $ */ +/* $Id: mb_gpc.h,v 1.5.2.1 2006/01/01 12:50:08 sniper Exp $ */ /* {{{ includes */ #ifdef HAVE_CONFIG_H diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 6169888ee..8adce024f 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.224.2.5 2005/11/25 21:55:25 hirokawa Exp $ */ +/* $Id: mbstring.c,v 1.224.2.12 2006/01/01 12:50:08 sniper Exp $ */ /* * PHP 4 Multibyte String module "mbstring" @@ -135,6 +135,12 @@ static const enum mbfl_no_encoding php_mb_default_identify_list_hy[] = { mbfl_no_encoding_armscii8 }; +static const enum mbfl_no_encoding php_mb_default_identify_list_tr[] = { + mbfl_no_encoding_ascii, + mbfl_no_encoding_utf8, + mbfl_no_encoding_8859_9 +}; + static const enum mbfl_no_encoding php_mb_default_identify_list_neut[] = { mbfl_no_encoding_ascii, mbfl_no_encoding_utf8 @@ -148,6 +154,7 @@ static const php_mb_nls_ident_list php_mb_default_identify_list[] = { { mbfl_no_language_simplified_chinese, php_mb_default_identify_list_cn, sizeof(php_mb_default_identify_list_cn) / sizeof(php_mb_default_identify_list_cn[0]) }, { mbfl_no_language_russian, php_mb_default_identify_list_ru, sizeof(php_mb_default_identify_list_ru) / sizeof(php_mb_default_identify_list_ru[0]) }, { mbfl_no_language_armenian, php_mb_default_identify_list_hy, sizeof(php_mb_default_identify_list_hy) / sizeof(php_mb_default_identify_list_hy[0]) }, + { mbfl_no_language_turkish, php_mb_default_identify_list_tr, sizeof(php_mb_default_identify_list_tr) / sizeof(php_mb_default_identify_list_tr[0]) }, { mbfl_no_language_neutral, php_mb_default_identify_list_neut, sizeof(php_mb_default_identify_list_neut) / sizeof(php_mb_default_identify_list_neut[0]) } }; @@ -180,8 +187,8 @@ static const struct mb_overload_def mb_ovld[] = { }; /* }}} */ -/* {{{ function_entry mbstring_functions[] */ -function_entry mbstring_functions[] = { +/* {{{ zend_function_entry mbstring_functions[] */ +zend_function_entry mbstring_functions[] = { PHP_FE(mb_convert_case, NULL) PHP_FE(mb_strtoupper, NULL) PHP_FE(mb_strtolower, NULL) @@ -734,6 +741,9 @@ PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN("mbstring.encoding_translation", "0", PHP_INI_SYSTEM | PHP_INI_PERDIR, OnUpdate_mbstring_encoding_translation, encoding_translation, zend_mbstring_globals, mbstring_globals) + + STD_PHP_INI_BOOLEAN("mbstring.strict_detection", "0", + PHP_INI_ALL, OnUpdateLong, strict_detection, zend_mbstring_globals, mbstring_globals) PHP_INI_END() /* }}} */ @@ -769,6 +779,7 @@ static void _php_mb_globals_ctor(zend_mbstring_globals *pglobals TSRMLS_DC) MBSTRG(current_filter_illegal_substchar) = 0x3f; /* '?' */ MBSTRG(func_overload) = 0; MBSTRG(encoding_translation) = 0; + MBSTRG(strict_detection) = 0; pglobals->outconv = NULL; #if HAVE_MBREGEX _php_mb_regex_globals_ctor(pglobals TSRMLS_CC); @@ -888,6 +899,9 @@ PHP_RINIT_FUNCTION(mbstring) case mbfl_no_language_armenian: default_enc = "ArmSCII-8"; break; + case mbfl_no_language_turkish: + default_enc = "ISO-8859-9"; + break; case mbfl_no_language_english: default: default_enc = "ISO-8859-1"; @@ -1763,6 +1777,11 @@ PHP_FUNCTION(mb_substr) } } + if (((MBSTRG(func_overload) & MB_OVERLOAD_STRING) == MB_OVERLOAD_STRING) + && (from >= mbfl_strlen(&string))) { + RETURN_FALSE; + } + ret = mbfl_substr(&string, &result, from, len); if (ret != NULL) { RETVAL_STRINGL((char *)ret->val, ret->len, 0); /* the string is already strdup()'ed */ @@ -1776,7 +1795,7 @@ PHP_FUNCTION(mb_substr) Returns part of a string */ PHP_FUNCTION(mb_strcut) { - pval **arg1, **arg2, **arg3, **arg4; + zval **arg1, **arg2, **arg3, **arg4; int argc, from, len; mbfl_string string, result, *ret; @@ -1844,6 +1863,13 @@ PHP_FUNCTION(mb_strcut) } } + if (from > Z_STRLEN_PP(arg1)) { + RETURN_FALSE; + } + if (((unsigned) from + (unsigned) len) > Z_STRLEN_PP(arg1)) { + len = Z_STRLEN_PP(arg1) - from; + } + ret = mbfl_strcut(&string, &result, from, len); if (ret != NULL) { RETVAL_STRINGL(ret->val, ret->len, 0); /* the string is already strdup()'ed */ @@ -1892,7 +1918,7 @@ PHP_FUNCTION(mb_strwidth) Trim the string in terminal width */ PHP_FUNCTION(mb_strimwidth) { - pval **arg1, **arg2, **arg3, **arg4, **arg5; + zval **arg1, **arg2, **arg3, **arg4, **arg5; int from, width; mbfl_string string, result, marker, *ret; @@ -2010,7 +2036,7 @@ MBSTRING_API char * php_mb_convert_encoding(char *input, size_t length, char *_t string.no_encoding = from_encoding; } else if (size > 1) { /* auto detect */ - from_encoding = mbfl_identify_encoding_no(&string, list, size); + from_encoding = mbfl_identify_encoding_no(&string, list, size, MBSTRG(strict_detection)); if (from_encoding != mbfl_no_encoding_invalid) { string.no_encoding = from_encoding; } else { @@ -2054,7 +2080,7 @@ MBSTRING_API char * php_mb_convert_encoding(char *input, size_t length, char *_t Returns converted string in desired encoding */ PHP_FUNCTION(mb_convert_encoding) { - pval **arg_str, **arg_new, **arg_old; + zval **arg_str, **arg_new, **arg_old; int i; size_t size, l, n; char *_from_encodings, *ret, *s_free = NULL; @@ -2198,7 +2224,7 @@ PHP_FUNCTION(mb_strtolower) Encodings of the given string is returned (as a string) */ PHP_FUNCTION(mb_detect_encoding) { - pval **arg_str, **arg_list, **arg_strict; + zval **arg_str, **arg_list, **arg_strict; mbfl_string string; const char *ret; enum mbfl_no_encoding *elist; @@ -2252,6 +2278,9 @@ PHP_FUNCTION(mb_detect_encoding) convert_to_long_ex(arg_strict); strict = Z_LVAL_PP(arg_strict); } + else { + strict = MBSTRG(strict_detection); + } if (size > 0 && list != NULL) { elist = list; @@ -2484,7 +2513,7 @@ PHP_FUNCTION(mb_convert_kana) Converts the string resource in variables to desired encoding */ PHP_FUNCTION(mb_convert_variables) { - pval ***args, ***stack, **var, **hash_entry; + zval ***args, ***stack, **var, **hash_entry; HashTable *target_hash; mbfl_string string, result, *ret; enum mbfl_no_encoding from_encoding, to_encoding; @@ -2499,7 +2528,7 @@ PHP_FUNCTION(mb_convert_variables) if (argc < 3) { WRONG_PARAM_COUNT; } - args = (pval ***)ecalloc(argc, sizeof(pval **)); + args = (zval ***)ecalloc(argc, sizeof(zval **)); if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree((void *)args); WRONG_PARAM_COUNT; @@ -2541,9 +2570,9 @@ PHP_FUNCTION(mb_convert_variables) /* auto detect */ from_encoding = mbfl_no_encoding_invalid; stack_max = PHP_MBSTR_STACK_BLOCK_SIZE; - stack = (pval ***)safe_emalloc(stack_max, sizeof(pval **), 0); + stack = (zval ***)safe_emalloc(stack_max, sizeof(zval **), 0); stack_level = 0; - identd = mbfl_encoding_detector_new(elist, elistsz); + identd = mbfl_encoding_detector_new(elist, elistsz, MBSTRG(strict_detection)); if (identd != NULL) { n = 2; while (n < argc || stack_level > 0) { @@ -2567,8 +2596,8 @@ PHP_FUNCTION(mb_convert_variables) if (Z_TYPE_PP(hash_entry) == IS_ARRAY || Z_TYPE_PP(hash_entry) == IS_OBJECT) { if (stack_level >= stack_max) { stack_max += PHP_MBSTR_STACK_BLOCK_SIZE; - ptmp = erealloc(stack, sizeof(pval **)*stack_max); - stack = (pval ***)ptmp; + ptmp = erealloc(stack, sizeof(zval **)*stack_max); + stack = (zval ***)ptmp; } stack[stack_level] = var; stack_level++; @@ -2624,7 +2653,7 @@ detect_end: /* convert */ if (convd != NULL) { stack_max = PHP_MBSTR_STACK_BLOCK_SIZE; - stack = (pval ***)safe_emalloc(stack_max, sizeof(pval **), 0); + stack = (zval ***)safe_emalloc(stack_max, sizeof(zval **), 0); stack_level = 0; n = 2; while (n < argc || stack_level > 0) { @@ -2648,8 +2677,8 @@ detect_end: if (Z_TYPE_PP(hash_entry) == IS_ARRAY || Z_TYPE_PP(hash_entry) == IS_OBJECT) { if (stack_level >= stack_max) { stack_max += PHP_MBSTR_STACK_BLOCK_SIZE; - ptmp = erealloc(stack, sizeof(pval **)*stack_max); - stack = (pval ***)ptmp; + ptmp = erealloc(stack, sizeof(zval **)*stack_max); + stack = (zval ***)ptmp; } stack[stack_level] = var; stack_level++; @@ -2707,7 +2736,7 @@ detect_end: static void php_mb_numericentity_exec(INTERNAL_FUNCTION_PARAMETERS, int type) { - pval **arg1, **arg2, **arg3, **hash_entry; + zval **arg1, **arg2, **arg3, **hash_entry; HashTable *target_hash; int argc, i, *convmap, *mapelm, mapsize=0; mbfl_string string, result, *ret; @@ -3162,7 +3191,7 @@ PHP_FUNCTION(mb_send_mail) orig_str.no_encoding = MBSTRG(current_internal_encoding); if (orig_str.no_encoding == mbfl_no_encoding_invalid || orig_str.no_encoding == mbfl_no_encoding_pass) { - orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size)); + orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size), MBSTRG(strict_detection)); } pstr = mbfl_mime_header_encode(&orig_str, &conv_str, tran_cs, head_enc, "\n", sizeof("Subject: [PHP-jp nnnnnnnn]")); if (pstr != NULL) { @@ -3182,7 +3211,7 @@ PHP_FUNCTION(mb_send_mail) if (orig_str.no_encoding == mbfl_no_encoding_invalid || orig_str.no_encoding == mbfl_no_encoding_pass) { - orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size)); + orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size), MBSTRG(strict_detection)); } pstr = NULL; @@ -3559,7 +3588,7 @@ MBSTRING_API int php_mb_gpc_encoding_detector(char **arg_string, int *arg_length mbfl_string_init(&string); string.no_language = MBSTRG(current_language); - identd = mbfl_encoding_detector_new(elist, size); + identd = mbfl_encoding_detector_new(elist, size, MBSTRG(strict_detection)); if (identd) { int n = 0; diff --git a/ext/mbstring/mbstring.h b/ext/mbstring/mbstring.h index f0eab49dc..2abcfe47f 100644 --- a/ext/mbstring/mbstring.h +++ b/ext/mbstring/mbstring.h @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.h,v 1.66 2005/08/03 14:07:24 sniper Exp $ */ +/* $Id: mbstring.h,v 1.66.2.2 2006/01/01 12:50:08 sniper Exp $ */ /* * PHP 4 Multibyte String module "mbstring" (currently only for Japanese) @@ -180,6 +180,7 @@ ZEND_BEGIN_MODULE_GLOBALS(mbstring) int current_filter_illegal_substchar; long func_overload; zend_bool encoding_translation; + long strict_detection; mbfl_buffer_converter *outconv; #if HAVE_MBREGEX && defined(PHP_MBREGEX_GLOBALS) PHP_MBREGEX_GLOBALS diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index c67d77b0c..4a27aef48 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mbregex.c,v 1.53 2005/08/03 14:07:24 sniper Exp $ */ +/* $Id: php_mbregex.c,v 1.53.2.1 2006/01/01 12:50:08 sniper Exp $ */ #ifdef HAVE_CONFIG_H diff --git a/ext/mbstring/php_mbregex.h b/ext/mbstring/php_mbregex.h index 8c523b831..70460676f 100644 --- a/ext/mbstring/php_mbregex.h +++ b/ext/mbstring/php_mbregex.h @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mbregex.h,v 1.12 2005/08/03 14:07:24 sniper Exp $ */ +/* $Id: php_mbregex.h,v 1.12.2.1 2006/01/01 12:50:08 sniper Exp $ */ #ifndef _PHP_MBREGEX_H #define _PHP_MBREGEX_H diff --git a/ext/mbstring/php_unicode.c b/ext/mbstring/php_unicode.c index 99eed1d8d..e65b4b4e2 100644 --- a/ext/mbstring/php_unicode.c +++ b/ext/mbstring/php_unicode.c @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -44,6 +44,8 @@ #include "php_unicode.h" #include "unicode_data.h" +ZEND_EXTERN_MODULE_GLOBALS(mbstring) + /* * A simple array of 32-bit masks for lookup. */ @@ -142,7 +144,23 @@ static unsigned long case_lookup(unsigned long code, long l, long r, int field) return code; } -MBSTRING_API unsigned long php_unicode_toupper(unsigned long code) +MBSTRING_API unsigned long php_turkish_toupper(unsigned long code, long l, long r, int field) +{ + if (code == 0x0069L) { + return 0x0130L; + } + return case_lookup(code, l, r, field); +} + +MBSTRING_API unsigned long php_turkish_tolower(unsigned long code, long l, long r, int field) +{ + if (code == 0x0049L) { + return 0x0131L; + } + return case_lookup(code, l, r, field); +} + +MBSTRING_API unsigned long php_unicode_toupper(unsigned long code, enum mbfl_no_encoding enc TSRMLS_DC) { int field; long l, r; @@ -157,6 +175,12 @@ MBSTRING_API unsigned long php_unicode_toupper(unsigned long code) field = 2; l = _uccase_len[0]; r = (l + _uccase_len[1]) - 3; + + if (MBSTRG(current_language) == mbfl_no_language_turkish && + enc == mbfl_no_encoding_8859_9) { + return php_turkish_toupper(code, l, r, field); + } + } else { /* * The character is title case. @@ -168,7 +192,7 @@ MBSTRING_API unsigned long php_unicode_toupper(unsigned long code) return case_lookup(code, l, r, field); } -MBSTRING_API unsigned long php_unicode_tolower(unsigned long code) +MBSTRING_API unsigned long php_unicode_tolower(unsigned long code, enum mbfl_no_encoding enc TSRMLS_DC) { int field; long l, r; @@ -183,6 +207,12 @@ MBSTRING_API unsigned long php_unicode_tolower(unsigned long code) field = 1; l = 0; r = _uccase_len[0] - 3; + + if (MBSTRG(current_language) == mbfl_no_language_turkish && + enc == mbfl_no_encoding_8859_9) { + return php_turkish_tolower(code, l, r, field); + } + } else { /* * The character is title case. @@ -194,7 +224,7 @@ MBSTRING_API unsigned long php_unicode_tolower(unsigned long code) return case_lookup(code, l, r, field); } -MBSTRING_API unsigned long php_unicode_totitle(unsigned long code) +MBSTRING_API unsigned long php_unicode_totitle(unsigned long code, enum mbfl_no_encoding enc TSRMLS_DC) { int field; long l, r; @@ -246,25 +276,26 @@ MBSTRING_API char *php_unicode_convert_case(int case_mode, char *srcstr, size_t size_t unicode_len; unsigned char *unicode_ptr; size_t i; + enum mbfl_no_encoding _src_encoding = mbfl_name2no_encoding(src_encoding); unicode = php_mb_convert_encoding(srcstr, srclen, "UCS-4BE", src_encoding, &unicode_len TSRMLS_CC); if (unicode == NULL) return NULL; - unicode_ptr = unicode; + unicode_ptr = (unsigned char *)unicode; switch(case_mode) { case PHP_UNICODE_CASE_UPPER: for (i = 0; i < unicode_len; i+=4) { UINT32_TO_BE_ARY(&unicode_ptr[i], - php_unicode_toupper(BE_ARY_TO_UINT32(&unicode_ptr[i]))); + php_unicode_toupper(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding TSRMLS_CC)); } break; case PHP_UNICODE_CASE_LOWER: for (i = 0; i < unicode_len; i+=4) { UINT32_TO_BE_ARY(&unicode_ptr[i], - php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i]))); + php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding TSRMLS_CC)); } break; @@ -278,7 +309,7 @@ MBSTRING_API char *php_unicode_convert_case(int case_mode, char *srcstr, size_t if (mode) { if (res) { UINT32_TO_BE_ARY(&unicode_ptr[i], - php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i]))); + php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding TSRMLS_CC)); } else { mode = 0; } @@ -286,7 +317,7 @@ MBSTRING_API char *php_unicode_convert_case(int case_mode, char *srcstr, size_t if (res) { mode = 1; UINT32_TO_BE_ARY(&unicode_ptr[i], - php_unicode_totitle(BE_ARY_TO_UINT32(&unicode_ptr[i]))); + php_unicode_totitle(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding TSRMLS_CC)); } } } diff --git a/ext/mbstring/php_unicode.h b/ext/mbstring/php_unicode.h index 6e3c5c1f7..6ed23e23b 100644 --- a/ext/mbstring/php_unicode.h +++ b/ext/mbstring/php_unicode.h @@ -2,12 +2,12 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2005 The PHP Group | + | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/ext/mbstring/tests/bug28220.phpt b/ext/mbstring/tests/bug28220.phpt index 563e2da74..f195606a1 100644 --- a/ext/mbstring/tests/bug28220.phpt +++ b/ext/mbstring/tests/bug28220.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #28220 (mb_strwidth() returns wrong width values for some Hangul characters) +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> --FILE-- <?php $coderange = array( diff --git a/ext/mbstring/tests/bug30549.phpt b/ext/mbstring/tests/bug30549.phpt index dbd8e0bd1..a6007e0b3 100644 --- a/ext/mbstring/tests/bug30549.phpt +++ b/ext/mbstring/tests/bug30549.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #30549 (incorrect character translations for some ISO8859 charsets) +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> --FILE-- <?php test('ISO-8859-7', array(0xa4 => 0x20ac, 0xa5 => 0x20af, 0xaa => 0x037a)); diff --git a/ext/mbstring/tests/bug31911.phpt b/ext/mbstring/tests/bug31911.phpt index eb6438d4e..48d497175 100644 --- a/ext/mbstring/tests/bug31911.phpt +++ b/ext/mbstring/tests/bug31911.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #31911 (mb_decode_mimeheader() is case-sensitive to hex escapes) +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> --FILE-- <?php echo mb_decode_mimeheader("Works: =?iso-8859-1?q?=3F=3F=3F?="); diff --git a/ext/mbstring/tests/mb_strcut.phpt b/ext/mbstring/tests/mb_strcut.phpt index 8ea074a3c..6a90d87d2 100644 --- a/ext/mbstring/tests/mb_strcut.phpt +++ b/ext/mbstring/tests/mb_strcut.phpt @@ -17,7 +17,7 @@ print mb_strcut($euc_jp, 6, 5,'EUC-JP') . "\n"; print mb_strcut($euc_jp, 0, 100,'EUC-JP') . "\n"; $str = mb_strcut($euc_jp, 100, 10,'EUC-JP'); -($str === "") ? print "OK\n" : print "NG: $str\n"; +($str === false) ? print "OK\n" : print "NG: $str\n"; $str = mb_strcut($euc_jp, -100, 10,'EUC-JP'); ($str !== "") ? print "OK: $str\n" : print "NG:\n"; |
