]> granicus.if.org Git - php/commitdiff
make concatenating two binary strings a special case
authorAntony Dovgal <tony2001@php.net>
Mon, 30 Apr 2007 15:59:12 +0000 (15:59 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 30 Apr 2007 15:59:12 +0000 (15:59 +0000)
Zend/tests/concat_002.phpt [new file with mode: 0644]
Zend/zend_operators.c

diff --git a/Zend/tests/concat_002.phpt b/Zend/tests/concat_002.phpt
new file mode 100644 (file)
index 0000000..fd28dfb
--- /dev/null
@@ -0,0 +1,37 @@
+--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
index d6fdb01246e9ddc27eef2e56beee83f7e398c261..be3ccf97a3de2a408e5d8a2a3fd057dcba29b898 100644 (file)
@@ -1694,10 +1694,12 @@ ZEND_API int add_string_to_string(zval *result, zval *op1, zval *op2)
 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;