From bcfd4067b66075dfbcba4221f9eb089e95e99e15 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Mon, 30 Apr 2007 15:59:12 +0000 Subject: [PATCH] make concatenating two binary strings a special case --- Zend/tests/concat_002.phpt | 37 +++++++++++++++++++++++++++++++++++++ Zend/zend_operators.c | 6 ++++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 Zend/tests/concat_002.phpt diff --git a/Zend/tests/concat_002.phpt b/Zend/tests/concat_002.phpt new file mode 100644 index 0000000000..fd28dfb46a --- /dev/null +++ b/Zend/tests/concat_002.phpt @@ -0,0 +1,37 @@ +--TEST-- +concat strings +--FILE-- + +--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 diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index d6fdb01246..be3ccf97a3 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -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; -- 2.50.1