[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/ mbstring.c php_mbregex.c php_mbregex.h
hirokawa Sun, 25 Sep 2011 08:01:54 + Revision: http://svn.php.net/viewvc?view=revisionrevision=317262 Log: added mb_ereg_replace_callback(). Changed paths: U php/php-src/trunk/ext/mbstring/mbstring.c U php/php-src/trunk/ext/mbstring/php_mbregex.c U php/php-src/trunk/ext/mbstring/php_mbregex.h Modified: php/php-src/trunk/ext/mbstring/mbstring.c === --- php/php-src/trunk/ext/mbstring/mbstring.c 2011-09-25 07:23:54 UTC (rev 317261) +++ php/php-src/trunk/ext/mbstring/mbstring.c 2011-09-25 08:01:54 UTC (rev 317262) @@ -467,6 +467,13 @@ ZEND_ARG_INFO(0, string) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_ereg_replace_callback, 0, 0, 3) + ZEND_ARG_INFO(0, pattern) + ZEND_ARG_INFO(0, callback) + ZEND_ARG_INFO(0, string) + ZEND_ARG_INFO(0, option) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_split, 0, 0, 2) ZEND_ARG_INFO(0, pattern) ZEND_ARG_INFO(0, string) Modified: php/php-src/trunk/ext/mbstring/php_mbregex.c === --- php/php-src/trunk/ext/mbstring/php_mbregex.c2011-09-25 07:23:54 UTC (rev 317261) +++ php/php-src/trunk/ext/mbstring/php_mbregex.c2011-09-25 08:01:54 UTC (rev 317262) @@ -784,7 +784,7 @@ /* }}} */ /* {{{ _php_mb_regex_ereg_replace_exec */ -static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOptionType options) +static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOptionType options, int is_callable) { zval **arg_pattern_zval; @@ -793,9 +793,11 @@ char *replace; int replace_len; + zval **arg_replace_zval; char *string; int string_len; + zval **arg_string_zval; char *p; php_mb_regex_t *re; @@ -826,14 +828,20 @@ char *option_str = NULL; int option_str_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Zss|s, - arg_pattern_zval, - replace, replace_len, - string, string_len, - option_str, option_str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ZZZ|s, + arg_pattern_zval, + arg_replace_zval, + arg_string_zval, + option_str, option_str_len) == FAILURE) { RETURN_FALSE; } + replace = Z_STRVAL_PP(arg_replace_zval); + replace_len = Z_STRLEN_PP(arg_replace_zval); + + string = Z_STRVAL_PP(arg_string_zval); + string_len = Z_STRLEN_PP(arg_string_zval); + if (option_str != NULL) { _php_mb_regex_init_options(option_str, option_str_len, options, syntax, eval); } else { @@ -859,7 +867,7 @@ RETURN_FALSE; } - if (eval) { + if (eval || is_callable) { pbuf = eval_buf; description = zend_make_compiled_string_description(mbregex replace TSRMLS_CC); } else { @@ -867,6 +875,22 @@ description = NULL; } + if (is_callable) { + char *callback_name; + if (!zend_is_callable(*arg_replace_zval, 0, callback_name TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Requires argument 2, '%s', to be a valid callback, callback_name); + efree(callback_name); + MAKE_COPY_ZVAL(arg_string_zval, return_value); + RETURN_FALSE; + } + efree(callback_name); + + if (eval) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Option 'e' cannot be used with replacement callback); + RETURN_FALSE; + } + } + /* do the actual work */ err = 0; pos = (OnigUChar *)string; @@ -911,6 +935,8 @@ i += fwd; } } + + if (eval) { zval v; /* null terminate buffer */ @@ -928,7 +954,38 @@ /* Clean up */ eval_buf.len = 0; zval_dtor(v); +
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/ mbstring.c
hirokawa Mon, 12 Sep 2011 13:20:05 + Revision: http://svn.php.net/viewvc?view=revisionrevision=316534 Log: fixed optional argument. Changed paths: U php/php-src/trunk/ext/mbstring/mbstring.c Modified: php/php-src/trunk/ext/mbstring/mbstring.c === --- php/php-src/trunk/ext/mbstring/mbstring.c 2011-09-12 13:14:16 UTC (rev 316533) +++ php/php-src/trunk/ext/mbstring/mbstring.c 2011-09-12 13:20:05 UTC (rev 316534) @@ -245,7 +245,7 @@ ZEND_ARG_INFO(0, encoding) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_parse_str, 0, 0, 2) +ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_parse_str, 0, 0, 1) ZEND_ARG_INFO(0, encoded_string) ZEND_ARG_INFO(1, result) ZEND_END_ARG_INFO() -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/ mbstring.c
hirokawa Tue, 02 Aug 2011 03:18:53 + Revision: http://svn.php.net/viewvc?view=revisionrevision=314081 Log: added version number of libmbfl. Changed paths: U php/php-src/trunk/ext/mbstring/mbstring.c Modified: php/php-src/trunk/ext/mbstring/mbstring.c === --- php/php-src/trunk/ext/mbstring/mbstring.c 2011-08-02 02:50:11 UTC (rev 314080) +++ php/php-src/trunk/ext/mbstring/mbstring.c 2011-08-02 03:18:53 UTC (rev 314081) @@ -1682,6 +1682,11 @@ php_info_print_table_row(2, Multibyte Support, enabled); php_info_print_table_row(2, Multibyte string engine, libmbfl); php_info_print_table_row(2, HTTP input encoding translation, MBSTRG(encoding_translation) ? enabled: disabled); + { + char tmp[256]; + snprintf(tmp, sizeof(tmp), %d.%d.%d, MBFL_VERSION_MAJOR, MBFL_VERSION_MINOR, MBFL_VERSION_TEENY); + php_info_print_table_row(2, libmbfl version, tmp); + } php_info_print_table_end(); php_info_print_table_start(); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ ext/mbstring/mbstring.c main/rfc1867.c
moriyoshiSun, 06 Mar 2011 07:06:55 + Revision: http://svn.php.net/viewvc?view=revisionrevision=308951 Log: Fix ZTS build. Changed paths: U php/php-src/trunk/ext/mbstring/mbstring.c U php/php-src/trunk/main/rfc1867.c Modified: php/php-src/trunk/ext/mbstring/mbstring.c === --- php/php-src/trunk/ext/mbstring/mbstring.c 2011-03-06 07:00:30 UTC (rev 308950) +++ php/php-src/trunk/ext/mbstring/mbstring.c 2011-03-06 07:06:55 UTC (rev 308951) @@ -1132,14 +1132,14 @@ char quote = *str; str++; - return php_mb_rfc1867_substring_conf(encoding, str, strlen(str), quote); + return php_mb_rfc1867_substring_conf(encoding, str, strlen(str), quote TSRMLS_CC); } else { char *strend = str; while (*strend !isspace(*(unsigned char *)strend)) { ++strend; } - return php_mb_rfc1867_substring_conf(encoding, str, strend - str, 0); + return php_mb_rfc1867_substring_conf(encoding, str, strend - str, 0 TSRMLS_CC); } } /* }}} */ @@ -1154,8 +1154,8 @@ * the full path of the file on the user's filesystem, which means that unless * the user does basename() they get a bogus file name. Until IE's user base drops * to nill or problem is fixed this code must remain enabled for all systems. */ - s = php_mb_safe_strrchr_ex(filename, '\\', filename_len, (const mbfl_encoding *)encoding TSRMLS_CC); - if ((tmp = php_mb_safe_strrchr_ex(filename, '/', filename_len, (const mbfl_encoding *)encoding TSRMLS_CC)) s) { + s = php_mb_safe_strrchr_ex(filename, '\\', filename_len, (const mbfl_encoding *)encoding); + if ((tmp = php_mb_safe_strrchr_ex(filename, '/', filename_len, (const mbfl_encoding *)encoding)) s) { s = tmp; } if (s) { Modified: php/php-src/trunk/main/rfc1867.c === --- php/php-src/trunk/main/rfc1867.c2011-03-06 07:00:30 UTC (rev 308950) +++ php/php-src/trunk/main/rfc1867.c2011-03-06 07:06:55 UTC (rev 308951) @@ -743,7 +743,7 @@ } /* Initialize the buffer */ - if (!(mbuff = multipart_buffer_new(boundary, boundary_len))) { + if (!(mbuff = multipart_buffer_new(boundary, boundary_len TSRMLS_CC))) { sapi_module.sapi_error(E_WARNING, Unable to initialize the input buffer); return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/ mbstring.c
scottmac Thu, 27 Jan 2011 11:47:31 + Revision: http://svn.php.net/viewvc?view=revisionrevision=307779 Log: Fix crash with mbstring, this probably isn't the correct behaviour but 272/276 of the tests pass after this. When mbstring.language is unset, it ends up being mbfl_no_language_neutral and there is no default when setting the encoding. internal_encoding and current_internal_encoding then end up being null. Changed paths: U php/php-src/trunk/ext/mbstring/mbstring.c Modified: php/php-src/trunk/ext/mbstring/mbstring.c === --- php/php-src/trunk/ext/mbstring/mbstring.c 2011-01-27 11:47:24 UTC (rev 307778) +++ php/php-src/trunk/ext/mbstring/mbstring.c 2011-01-27 11:47:31 UTC (rev 307779) @@ -1252,7 +1252,7 @@ encoding = mbfl_no2encoding(mbfl_no_encoding_8859_9); break; default: - encoding = NULL; + encoding = mbfl_no2encoding(mbfl_no_encoding_8859_1); break; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/ mbstring.c
hirokawa Mon, 20 Dec 2010 14:38:08 + Revision: http://svn.php.net/viewvc?view=revisionrevision=306509 Log: fixed compile error with VS2008. Changed paths: U php/php-src/trunk/ext/mbstring/mbstring.c Modified: php/php-src/trunk/ext/mbstring/mbstring.c === --- php/php-src/trunk/ext/mbstring/mbstring.c 2010-12-20 14:29:40 UTC (rev 306508) +++ php/php-src/trunk/ext/mbstring/mbstring.c 2010-12-20 14:38:08 UTC (rev 306509) @@ -1733,10 +1733,10 @@ case 'I': case 'i': { - array_init(return_value); const mbfl_encoding **entry = MBSTRG(http_input_list); const size_t n = MBSTRG(http_input_list_size); size_t i; + array_init(return_value); for (i = 0; i n; i++) { add_next_index_string(return_value, (*entry)-name, 1); entry++; @@ -4468,9 +4468,9 @@ memcpy(entry, MBSTRG(detect_order_list), sizeof(mbfl_encoding*) * nentries); } else { const enum mbfl_no_encoding *src = MBSTRG(default_detect_order_list); + size_t i; nentries = MBSTRG(default_detect_order_list_size); entry = (const mbfl_encoding **)safe_emalloc(nentries, sizeof(mbfl_encoding*), 0); - size_t i; for (i = 0; i nentries; i++) { entry[i] = mbfl_no2encoding(src[i]); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/ mbstring.c
hirokawa Sun, 19 Sep 2010 01:28:32 + Revision: http://svn.php.net/viewvc?view=revisionrevision=303539 Log: fixed compilation error. Changed paths: U php/php-src/trunk/ext/mbstring/mbstring.c Modified: php/php-src/trunk/ext/mbstring/mbstring.c === --- php/php-src/trunk/ext/mbstring/mbstring.c 2010-09-19 00:14:26 UTC (rev 303538) +++ php/php-src/trunk/ext/mbstring/mbstring.c 2010-09-19 01:28:32 UTC (rev 303539) @@ -1344,7 +1344,7 @@ REGISTER_INI_ENTRIES(); /* This is a global handler. Should not be set in a per-request handler. */ - sapi_register_treat_data(mbstr_treat_data); + sapi_register_treat_data(mbstr_treat_data TSRMLS_CC); /* Post handlers are stored in the thread-local context. */ if (MBSTRG(encoding_translation)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/ mbstring.c php_mbregex.c
dmitry Mon, 05 Jul 2010 12:03:08 + Revision: http://svn.php.net/viewvc?view=revisionrevision=301001 Log: Reduced overhead of ext/mbstring initialization Changed paths: U php/php-src/trunk/ext/mbstring/mbstring.c U php/php-src/trunk/ext/mbstring/php_mbregex.c Modified: php/php-src/trunk/ext/mbstring/mbstring.c === --- php/php-src/trunk/ext/mbstring/mbstring.c 2010-07-05 12:00:09 UTC (rev 301000) +++ php/php-src/trunk/ext/mbstring/mbstring.c 2010-07-05 12:03:08 UTC (rev 301001) @@ -1051,58 +1051,42 @@ int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_value_length TSRMLS_DC) { enum mbfl_no_encoding no_encoding; - const char *enc_name = NULL; - uint enc_name_len = 0; - no_encoding = new_value ? mbfl_name2no_encoding(new_value): - mbfl_no_encoding_invalid; - if (no_encoding != mbfl_no_encoding_invalid) { - enc_name = new_value; - enc_name_len = new_value_length; - } else { + if (!new_value +|| !*new_value +|| (no_encoding = mbfl_name2no_encoding(new_value)) == mbfl_no_encoding_invalid) { switch (MBSTRG(language)) { case mbfl_no_language_uni: - enc_name = UTF-8; - enc_name_len = sizeof(UTF-8) - 1; + no_encoding = mbfl_no_encoding_utf8; break; case mbfl_no_language_japanese: - enc_name = EUC-JP; - enc_name_len = sizeof(EUC-JP) - 1; + no_encoding = mbfl_no_encoding_euc_jp; break; case mbfl_no_language_korean: - enc_name = EUC-KR; - enc_name_len = sizeof(EUC-KR) - 1; + no_encoding = mbfl_no_encoding_euc_kr; break; case mbfl_no_language_simplified_chinese: - enc_name = EUC-CN; - enc_name_len = sizeof(EUC-CN) - 1; + no_encoding = mbfl_no_encoding_euc_cn; break; case mbfl_no_language_traditional_chinese: - enc_name = EUC-TW; - enc_name_len = sizeof(EUC-TW) - 1; + no_encoding = mbfl_no_encoding_euc_tw; break; case mbfl_no_language_russian: - enc_name = KOI8-R; - enc_name_len = sizeof(KOI8-R) - 1; + no_encoding = mbfl_no_encoding_koi8r; break; case mbfl_no_language_german: - enc_name = ISO-8859-15; - enc_name_len = sizeof(ISO-8859-15) - 1; + no_encoding = mbfl_no_encoding_8859_15; break; case mbfl_no_language_armenian: - enc_name = ArmSCII-8; - enc_name_len = sizeof(ArmSCII-8) - 1; + no_encoding = mbfl_no_encoding_armscii8; break; case mbfl_no_language_turkish: - enc_name = ISO-8859-9; - enc_name_len = sizeof(ISO-8859-9) - 1; + no_encoding = mbfl_no_encoding_8859_9; break; default: - enc_name = ISO-8859-1; - enc_name_len = sizeof(ISO-8859-1) - 1; + no_encoding = mbfl_no_encoding_8859_1; break; } - no_encoding = mbfl_name2no_encoding(enc_name); } MBSTRG(internal_encoding) = no_encoding; MBSTRG(current_internal_encoding) = no_encoding; Modified: php/php-src/trunk/ext/mbstring/php_mbregex.c === --- php/php-src/trunk/ext/mbstring/php_mbregex.c2010-07-05 12:00:09 UTC (rev 301000) +++ php/php-src/trunk/ext/mbstring/php_mbregex.c2010-07-05 12:03:08 UTC (rev 301001) @@ -372,7 +372,7 @@ const char *p; php_mb_regex_enc_name_map_t *mapping; - if (pname == NULL) { + if (pname == NULL || !*pname) { return ONIG_ENCODING_UNDEF; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php