cvs: ZendEngine2 / zend_operators.c /tests concat_002.phpt
| From: | Antony Dovgal | Date: | Mon, 30 Apr 2007 15:59:12 +0000 |
| Subject: | cvs: ZendEngine2 / zend_operators.c /tests concat_002.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-5761@lists.php.net to get a copy of this message | ||
tony2001 Mon Apr 30 15:59:12 2007 UTC
Added files:
/ZendEngine2/tests concat_002.phpt
Modified files:
/ZendEngine2 zend_operators.c
Log:
make concatenating two binary strings a special case
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.c?r1=1.271&r2=1.272&diff_format=u
Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.271 ZendEngine2/zend_operators.c:1.272
--- ZendEngine2/zend_operators.c:1.271 Sat Apr 28 12:04:43 2007
+++ ZendEngine2/zend_operators.c Mon Apr 30 15:59:12 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.c,v 1.271 2007/04/28 12:04:43 tony2001 Exp $ */
+/* $Id: zend_operators.c,v 1.272 2007/04/30 15:59:12 tony2001 Exp $ */
#include <ctype.h>
@@ -1694,10 +1694,12 @@
ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
{
zval op1_copy, op2_copy;
- int use_copy1, use_copy2;
+ int use_copy1 = 0, use_copy2 = 0;
zend_uchar result_type;
- if (Z_TYPE_P(op1) == IS_UNICODE || Z_TYPE_P(op2) == IS_UNICODE || UG(unicode)) {
+ if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) {
+ result_type = IS_STRING;
+ } else if (Z_TYPE_P(op1) == IS_UNICODE || Z_TYPE_P(op2) == IS_UNICODE || UG(unicode)) {
zend_make_unicode_zval(op1, &op1_copy, &use_copy1);
zend_make_unicode_zval(op2, &op2_copy, &use_copy2);
result_type = IS_UNICODE;
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/concat_002.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/concat_002.phpt
+++ ZendEngine2/tests/concat_002.phpt
--TEST--
concat strings
--FILE--
<?php
$bin_s = (binary)"binary string";
$bin_s1 = (binary)"one more bin string";
$uni_s = "test string";
$uni_s1 = "one more test";
$tmp = $bin_s.$bin_s1;
var_dump($tmp);
$tmp = $bin_s.$uni_s;
var_dump($tmp);
$tmp = $uni_s.$uni_s1;
var_dump($tmp);
$tmp = $uni_s.$bin_s1;
var_dump($tmp);
echo "Done\n";
?>
--EXPECTF--
string(32) "binary stringone more bin string"
string(24) "binary stringtest string"
string(24) "test stringone more test"
string(30) "test stringone more bin string"
Done
--UEXPECTF--
string(32) "binary stringone more bin string"
unicode(24) "binary stringtest string"
unicode(24) "test stringone more test"
unicode(30) "test stringone more bin string"
Done