Re: cvs: php-src(PHP_4_4) /ext/mbstring mbstring.c mbstring.h /ext/mbstring/libmbfl/mbfl mbfilter.c
| From: | Derick Rethans | Date: | Tue, 21 Mar 2006 08:44:52 +0000 |
| Subject: | Re: cvs: php-src(PHP_4_4) /ext/mbstring mbstring.c mbstring.h /ext/mbstring/libmbfl/mbfl mbfilter.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-37387@lists.php.net to get a copy of this message | ||
On Tue, 21 Mar 2006, Rui Hirokawa wrote:
> hirokawa Tue Mar 21 08:00:55 2006 UTC
>
> Modified files: (Branch: PHP_4_4)
> /php-src/ext/mbstring mbstring.c mbstring.h
> /php-src/ext/mbstring/libmbfl/mbfl mbfilter.c
> Log:
> MFH
Please revert this. You can not add new functions to PHP 4.4.x.
regards,
Derick
>
>
> http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.142.2.47.2.14&r2=1.142.2.47.2.15&diff_format=u
> Index: php-src/ext/mbstring/mbstring.c
> diff -u php-src/ext/mbstring/mbstring.c:1.142.2.47.2.14
> php-src/ext/mbstring/mbstring.c:1.142.2.47.2.15
> --- php-src/ext/mbstring/mbstring.c:1.142.2.47.2.14 Tue Mar 21 02:49:09 2006
> +++ php-src/ext/mbstring/mbstring.c Tue Mar 21 08:00:55 2006
> @@ -17,7 +17,7 @@
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: mbstring.c,v 1.142.2.47.2.14 2006/03/21 02:49:09 hirokawa Exp $ */
> +/* $Id: mbstring.c,v 1.142.2.47.2.15 2006/03/21 08:00:55 hirokawa Exp $ */
>
> /*
> * PHP4 Multibyte String module "mbstring"
> @@ -253,6 +253,7 @@
> PHP_FE(mb_decode_numericentity, NULL)
> PHP_FE(mb_send_mail, NULL)
> PHP_FE(mb_get_info, NULL)
> + PHP_FE(mb_check_encoding, NULL)
> PHP_FALIAS(mbstrlen, mb_strlen, NULL)
> PHP_FALIAS(mbstrpos, mb_strpos, NULL)
> PHP_FALIAS(mbstrrpos, mb_strrpos, NULL)
> @@ -3812,6 +3813,67 @@
> }
> /* }}} */
>
> +/* {{{ proto bool mb_check_encoding([string var[, string encoding]])
> + Check if the string is valid for the specified encoding */
> +PHP_FUNCTION(mb_check_encoding)
> +{
> + char *var = NULL;
> + int var_len;
> + char *enc = NULL;
> + int enc_len;
> + char *name;
> + mbfl_buffer_converter *convd;
> + enum mbfl_no_encoding no_encoding = MBSTRG(current_internal_encoding);
> + zval *row;
> + mbfl_string string, result, *ret = NULL;
> + long illegalchars = 0;
> +
> + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ss", &var, &var_len,
> &enc, &enc_len) == FAILURE) {
> + RETURN_FALSE;
> + }
> +
> + if (var == NULL) {
> + RETURN_BOOL(MBSTRG(illegalchars) == 0);
> + }
> +
> + if (enc != NULL) {
> + no_encoding = mbfl_name2no_encoding(enc);
> + if (no_encoding == mbfl_no_encoding_invalid || no_encoding == mbfl_no_encoding_pass) {
> + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid encoding \"%s\"",
> enc);
> + RETURN_FALSE;
> + }
> + }
> +
> + convd = mbfl_buffer_converter_new(no_encoding, no_encoding, 0);
> + if (convd == NULL) {
> + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create converter");
> + RETURN_FALSE;
> + }
> + mbfl_buffer_converter_illegal_mode(convd, MBSTRG(current_filter_illegal_mode));
> + mbfl_buffer_converter_illegal_substchar(convd, MBSTRG(current_filter_illegal_substchar));
> +
> + /* initialize string */
> + mbfl_string_init(&string);
> + mbfl_string_init(&result);
> + string.no_encoding = no_encoding;
> + string.no_language = MBSTRG(current_language);
> +
> + string.val = (unsigned char *)var;
> + string.len = var_len;
> + ret = mbfl_buffer_converter_feed_result(convd, &string, &result);
> + illegalchars = mbfl_buffer_illegalchars(convd);
> + mbfl_buffer_converter_delete(convd);
> +
> + if (ret != NULL) {
> + MBSTRG(illegalchars) += illegalchars;
> + efree(ret->val);
> + RETURN_BOOL(illegalchars == 0);
> + } else {
> + RETURN_FALSE;
> + }
> +}
> +/* }}} */
> +
> /* {{{ MBSTRING_API int php_mb_encoding_translation() */
> MBSTRING_API int php_mb_encoding_translation(TSRMLS_D)
> {
>
> http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.h?r1=1.40.2.12.4.2&r2=1.40.2.12.4.3&diff_format=u
> Index: php-src/ext/mbstring/mbstring.h
> diff -u php-src/ext/mbstring/mbstring.h:1.40.2.12.4.2
> php-src/ext/mbstring/mbstring.h:1.40.2.12.4.3
> --- php-src/ext/mbstring/mbstring.h:1.40.2.12.4.2 Tue Mar 21 02:49:09 2006
> +++ php-src/ext/mbstring/mbstring.h Tue Mar 21 08:00:55 2006
> @@ -16,7 +16,7 @@
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: mbstring.h,v 1.40.2.12.4.2 2006/03/21 02:49:09 hirokawa Exp $ */
> +/* $Id: mbstring.h,v 1.40.2.12.4.3 2006/03/21 08:00:55 hirokawa Exp $ */
>
> /*
> * PHP4 Multibyte String module "mbstring" (currently only for Japanese)
> @@ -117,6 +117,7 @@
> PHP_FUNCTION(mb_decode_numericentity);
> PHP_FUNCTION(mb_send_mail);
> PHP_FUNCTION(mb_get_info);
> +PHP_FUNCTION(mb_check_encoding);
>
> MBSTRING_API int php_mb_encoding_translation(TSRMLS_D);
>
>
> http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c?r1=1.1.2.7.2.3&r2=1.1.2.7.2.4&diff_format=u
> Index: php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c
> diff -u php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c:1.1.2.7.2.3
> php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c:1.1.2.7.2.4
> --- php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c:1.1.2.7.2.3 Tue Mar 21 02:49:09 2006
> +++ php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c Tue Mar 21 08:00:55 2006
> @@ -335,6 +335,10 @@
> {
> int num_illegalchars = 0;
>
> + if (convd == NULL) {
> + return 0;
> + }
> +
> if (convd->filter1 != NULL) {
> num_illegalchars += convd->filter1->num_illegalchar;
> }
>
>
--
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org