tony2001 Thu Nov 23 14:20:59 2006 UTC
Modified files:
/php-src/ext/oci8 oci8_statement.c
/php-src/ext/oci8/tests array_bind_006.phpt array_bind_str1.phpt
array_bind_str.phpt
Log:
fix oci_bind_array_by_name() in Unicode mode
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.35&r2=1.36&diff_format=u
Index: php-src/ext/oci8/oci8_statement.c
diff -u php-src/ext/oci8/oci8_statement.c:1.35
php-src/ext/oci8/oci8_statement.c:1.36
--- php-src/ext/oci8/oci8_statement.c:1.35 Fri Nov 10 21:55:05 2006
+++ php-src/ext/oci8/oci8_statement.c Thu Nov 23 14:20:59 2006
@@ -25,7 +25,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: oci8_statement.c,v 1.35 2006/11/10 21:55:05 tony2001 Exp $ */
+/* $Id: oci8_statement.c,v 1.36 2006/11/23 14:20:59 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
@@ -829,14 +829,19 @@
zstr tmp;
for (i = 0; i <
bind->array.current_length; i++) {
/* int curr_element_length =
strlen(((text *)bind->array.elements)+i*bind->array.max_length); */
- int curr_element_length =
bind->array.element_lengths[i];
+ ub2 curr_element_length =
TEXT_CHARS(bind->array.element_lengths[i]);
if ((i <
bind->array.old_length) && (zend_hash_get_current_data(hash, (void **) &entry)
!= FAILURE)) {
zval_dtor(*entry);
- tmp.s = ((text
*)bind->array.elements)+i*bind->array.max_length;
+ if (UG(unicode)) {
+ tmp.u = ((UChar
*)bind->array.elements)+TEXT_CHARS(i*bind->array.max_length);
+ } else {
+ tmp.s = ((text
*)bind->array.elements)+(i*bind->array.max_length);
+ }
+
ZVAL_TEXTL(*entry, tmp,
curr_element_length, 1);
zend_hash_move_forward(hash);
} else {
- tmp.s = ((text
*)bind->array.elements)+i*bind->array.max_length;
+ tmp.s = ((text
*)bind->array.elements)+(i*bind->array.max_length);
add_next_index_textl(bind->zval, tmp, curr_element_length, 1);
}
}
@@ -1328,7 +1333,7 @@
(text *)name.s,
USTR_BYTES(uni_type, name_len),
(dvoid *)
bindp->array.elements,
- (sb4)
USTR_BYTES(uni_type, bind->array.max_length),
+ (sb4)
bind->array.max_length,
type,
(dvoid *)0, /*
bindp->array.indicators, */
(ub2
*)bind->array.element_lengths,
@@ -1373,10 +1378,14 @@
}
bind = emalloc(sizeof(php_oci_bind));
- bind->array.elements = (text *)ecalloc(1, max_table_length *
sizeof(text) * (maxlength + 1));
+ if (UG(unicode)) {
+ bind->array.elements = (UChar *)ecalloc(1,
max_table_length * sizeof(UChar) * (maxlength + 1));
+ } else {
+ bind->array.elements = (text *)ecalloc(1,
max_table_length * sizeof(text) * (maxlength + 1));
+ }
bind->array.current_length =
zend_hash_num_elements(Z_ARRVAL_P(var));
bind->array.old_length = bind->array.current_length;
- bind->array.max_length = maxlength;
+ bind->array.max_length = TEXT_BYTES(maxlength);
bind->array.element_lengths = ecalloc(1, max_table_length *
sizeof(ub2));
zend_hash_internal_pointer_reset(hash);
@@ -1384,7 +1393,7 @@
for (i = 0; i < bind->array.current_length; i++) {
if (zend_hash_get_current_data(hash, (void **) &entry) !=
FAILURE) {
convert_to_text_ex(entry);
- bind->array.element_lengths[i] = Z_UNILEN_PP(entry);
+ bind->array.element_lengths[i] =
TEXT_BYTES(Z_UNILEN_PP(entry));
zend_hash_move_forward(hash);
} else {
break;
@@ -1399,12 +1408,16 @@
convert_to_text_ex(entry);
element_length = (maxlength > Z_UNILEN_PP(entry)) ?
Z_UNILEN_PP(entry) : maxlength;
- memcpy((text *)bind->array.elements + i*maxlength,
Z_UNIVAL_PP(entry).s, element_length);
- ((text *)bind->array.elements)[i*maxlength +
element_length] = '\0';
-
+ if (UG(unicode)) {
+ memcpy((UChar *)bind->array.elements +
i*maxlength, Z_UNIVAL_PP(entry).u, TEXT_BYTES(element_length));
+ ((UChar *)bind->array.elements)[i*maxlength +
element_length] = '\0';
+ } else {
+ memcpy((text *)bind->array.elements +
i*maxlength, Z_UNIVAL_PP(entry).s, element_length);
+ ((text *)bind->array.elements)[i*maxlength +
element_length] = '\0';
+ }
zend_hash_move_forward(hash);
} else {
- ((text *)bind->array.elements)[i*maxlength] = '\0';
+ break;
}
}
zend_hash_internal_pointer_reset(hash);
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/array_bind_006.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/oci8/tests/array_bind_006.phpt
diff -u php-src/ext/oci8/tests/array_bind_006.phpt:1.2
php-src/ext/oci8/tests/array_bind_006.phpt:1.3
--- php-src/ext/oci8/tests/array_bind_006.phpt:1.2 Thu Dec 8 22:31:55 2005
+++ php-src/ext/oci8/tests/array_bind_006.phpt Thu Nov 23 14:20:59 2006
@@ -72,3 +72,17 @@
string(3) "one"
}
Done
+--UEXPECT--
+array(5) {
+ [0]=>
+ unicode(4) "five"
+ [1]=>
+ unicode(4) "four"
+ [2]=>
+ unicode(5) "three"
+ [3]=>
+ unicode(3) "two"
+ [4]=>
+ unicode(3) "one"
+}
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/array_bind_str1.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/oci8/tests/array_bind_str1.phpt
diff -u php-src/ext/oci8/tests/array_bind_str1.phpt:1.2
php-src/ext/oci8/tests/array_bind_str1.phpt:1.3
--- php-src/ext/oci8/tests/array_bind_str1.phpt:1.2 Thu Dec 8 22:31:55 2005
+++ php-src/ext/oci8/tests/array_bind_str1.phpt Thu Nov 23 14:20:59 2006
@@ -72,3 +72,17 @@
string(3) "one"
}
Done
+--UEXPECT--
+array(5) {
+ [0]=>
+ unicode(4) "five"
+ [1]=>
+ unicode(4) "four"
+ [2]=>
+ unicode(5) "three"
+ [3]=>
+ unicode(3) "two"
+ [4]=>
+ unicode(3) "one"
+}
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/array_bind_str.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/oci8/tests/array_bind_str.phpt
diff -u php-src/ext/oci8/tests/array_bind_str.phpt:1.1
php-src/ext/oci8/tests/array_bind_str.phpt:1.2
--- php-src/ext/oci8/tests/array_bind_str.phpt:1.1 Tue Dec 6 19:15:02 2005
+++ php-src/ext/oci8/tests/array_bind_str.phpt Thu Nov 23 14:20:59 2006
@@ -72,3 +72,17 @@
string(3) "one"
}
Done
+--UEXPECT--
+array(5) {
+ [0]=>
+ unicode(4) "five"
+ [1]=>
+ unicode(4) "four"
+ [2]=>
+ unicode(5) "three"
+ [3]=>
+ unicode(3) "two"
+ [4]=>
+ unicode(3) "one"
+}
+Done
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php