cvs: php-src /ext/standard string.c
| From: | Rolland Santimano | Date: | Fri, 09 Sep 2005 19:07:19 +0000 |
| Subject: | cvs: php-src /ext/standard string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-33877@lists.php.net to get a copy of this message | ||
rolland Fri Sep 9 15:07:19 2005 EDT
Modified files:
/php-src/ext/standard string.c
Log:
- str_pad(): Use u_countChar32() for codepoint counting, eumalloc/eurealloc() for Unicode mallocs.
http://cvs.php.net/diff.php/php-src/ext/standard/string.c?r1=1.481&r2=1.482&ty=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.481 php-src/ext/standard/string.c:1.482
--- php-src/ext/standard/string.c:1.481 Thu Sep 8 10:07:40 2005
+++ php-src/ext/standard/string.c Fri Sep 9 15:07:18 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.481 2005/09/08 14:07:40 derick Exp $ */
+/* $Id: string.c,v 1.482 2005/09/09 19:07:18 rolland Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -5394,10 +5394,7 @@
if (input_type == IS_UNICODE) {
/* For Unicode, num_pad_chars/pad_length is number of codepoints */
i = 0; input_codepts = 0;
- while (i < input_len) {
- U16_FWD_1((UChar *)input, i, input_len);
- input_codepts++;
- }
+ input_codepts = u_countChar32((UChar *)input, input_len);
num_pad_chars = pad_length - input_codepts;
} else {
num_pad_chars = pad_length - input_len;
@@ -5439,7 +5436,7 @@
}
if (input_type == IS_UNICODE) {
- result = emalloc(UBYTES(input_len + num_pad_chars*2 + 1));
+ result = eumalloc(input_len + num_pad_chars*2 + 1);
} else {
result = emalloc(input_len + num_pad_chars + 1);
}
@@ -5481,7 +5478,7 @@
result_len += zend_codepoint_to_uchar(ch, (UChar *)result + result_len);
}
*((UChar *)result + result_len) = 0;
- result = erealloc(result, UBYTES(result_len+1));
+ result = eurealloc(result, result_len+1);
} else {
for (i = 0; i < left_pad; i++)
*((char *)result + result_len++) = *((char *)padstr + (i % padstr_len));