cvs: php-src(PHP_5_2) /ext/iconv iconv.c /ext/iconv/tests iconv_substr.phpt

From: Date: Mon, 12 Mar 2007 19:34:27 +0000
Subject: cvs: php-src(PHP_5_2) /ext/iconv iconv.c /ext/iconv/tests iconv_substr.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-43503@lists.php.net to get a copy of this message
tony2001 Mon Mar 12 19:34:27 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/iconv iconv.c /php-src/ext/iconv/tests iconv_substr.phpt Log: synchronize iconv_substr() behavior with substr() no MFB so far, since substr() changes are not MFBed either http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.124.2.8.2.14&r2=1.124.2.8.2.15&diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.124.2.8.2.14 php-src/ext/iconv/iconv.c:1.124.2.8.2.15 --- php-src/ext/iconv/iconv.c:1.124.2.8.2.14 Thu Feb 1 14:02:35 2007 +++ php-src/ext/iconv/iconv.c Mon Mar 12 19:34:26 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: iconv.c,v 1.124.2.8.2.14 2007/02/01 14:02:35 tony2001 Exp $ */ +/* $Id: iconv.c,v 1.124.2.8.2.15 2007/03/12 19:34:26 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -679,28 +679,30 @@ return err; } - /* normalize the offset and the length */ - if (offset < 0) { - if ((offset += total_len) < 0) { - offset = 0; - } - } if (len < 0) { if ((len += (total_len - offset)) < 0) { - len = 0; + return PHP_ICONV_ERR_SUCCESS; + } + } + + if (offset < 0) { + if ((offset += total_len) < 0) { + return PHP_ICONV_ERR_SUCCESS; } } if (offset >= total_len) { return PHP_ICONV_ERR_SUCCESS; } - + if ((offset + len) > total_len) { /* trying to compute the length */ len = total_len - offset; } if (len == 0) { + smart_str_appendl(pretval, "", 0); + smart_str_0(pretval); return PHP_ICONV_ERR_SUCCESS; } @@ -1910,16 +1912,11 @@ err = _php_iconv_substr(&retval, str, str_len, offset, length, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); - if (err == PHP_ICONV_ERR_SUCCESS && str != NULL) { - if (retval.c != NULL) { - RETVAL_STRINGL(retval.c, retval.len, 0); - } else { - RETVAL_EMPTY_STRING(); - } - } else { - smart_str_free(&retval); - RETVAL_FALSE; + if (err == PHP_ICONV_ERR_SUCCESS && str != NULL && retval.c != NULL) { + RETURN_STRINGL(retval.c, retval.len, 0); } + smart_str_free(&retval); + RETURN_FALSE; } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_substr.phpt?r1=1.1.4.1&r2=1.1.4.1.2.1&diff_format=u Index: php-src/ext/iconv/tests/iconv_substr.phpt diff -u php-src/ext/iconv/tests/iconv_substr.phpt:1.1.4.1 php-src/ext/iconv/tests/iconv_substr.phpt:1.1.4.1.2.1 --- php-src/ext/iconv/tests/iconv_substr.phpt:1.1.4.1 Wed Nov 16 15:13:20 2005 +++ php-src/ext/iconv/tests/iconv_substr.phpt Mon Mar 12 19:34:26 2007 @@ -45,15 +45,15 @@ a6a4a8a4aaa4ab a4aba4ada4afa4b1a4b3a4b5a4b7 bool(false) -string(0) "" +bool(false) string(14) "This is a test" string(14) "This is a test" string(3) "est" string(3) "est" string(5) "This " string(5) "This " -string(0) "" -string(0) "" -string(0) "" -string(0) "" +bool(false) +bool(false) +bool(false) +bool(false) string(10) "¤Á¤Ï ISO-2"

« previous php.cvs (#43503) next »