andrei Thu Jul 13 21:08:43 2006 UTC
Modified files:
/php-src unicode-progress.txt
/php-src/ext/standard array.c
Log:
- Make compact() normalize variablem name before checking symtable.
- Mark tested/upgraded functions with 'U' flag.
http://cvs.php.net/viewvc.cgi/php-src/unicode-progress.txt?r1=1.12&r2=1.13&diff_format=u
Index: php-src/unicode-progress.txt
diff -u php-src/unicode-progress.txt:1.12 php-src/unicode-progress.txt:1.13
--- php-src/unicode-progress.txt:1.12 Wed Jul 12 23:17:07 2006
+++ php-src/unicode-progress.txt Thu Jul 13 21:08:43 2006
@@ -13,9 +13,6 @@
array_change_key_case()
Params API, test
- array_chunk()
- Test
-
array_combine()
Handle IS_UNICODE/IS_STRING keys via add_u_assoc_zval()
@@ -106,12 +103,6 @@
extract()
Params API, fix php_valid_var_name(), test
- compact()
- Test
-
- min(), max()
- Test
-
natsort(), natcasesort()
Params API
Either port strnatcmp() to support Unicode or maybe use ICU's numeric
collation
@@ -134,7 +125,11 @@
array.c
-------
+ array_chunk()
+ compact()
count()
+ min()
+ max()
string.c
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.350&r2=1.351&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.350 php-src/ext/standard/array.c:1.351
--- php-src/ext/standard/array.c:1.350 Sun Jun 25 19:19:31 2006
+++ php-src/ext/standard/array.c Thu Jul 13 21:08:43 2006
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.350 2006/06/25 19:19:31 bjori Exp $ */
+/* $Id: array.c,v 1.351 2006/07/13 21:08:43 andrei Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -291,14 +291,14 @@
return cnt;
}
-/* {{{ proto int count(mixed var [, int mode])
+/* {{{ proto int count(mixed var [, int mode]) U
Count the number of elements in a variable (usually an array) */
PHP_FUNCTION(count)
{
zval *array;
long mode = COUNT_NORMAL;
- if (zend_parse_parameters (ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &array,
&mode) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &array,
&mode) == FAILURE)
return;
switch (Z_TYPE_P(array)) {
@@ -955,7 +955,7 @@
}
/* }}} */
-/* {{{ proto mixed min(mixed arg1 [, mixed arg2 [, mixed ...]])
+/* {{{ proto mixed min(mixed arg1 [, mixed arg2 [, mixed ...]]) U
Return the lowest value in an array or a series of arguments */
PHP_FUNCTION(min)
{
@@ -1005,7 +1005,7 @@
}
/* }}} */
-/* {{{ proto mixed max(mixed arg1 [, mixed arg2 [, mixed ...]])
+/* {{{ proto mixed max(mixed arg1 [, mixed arg2 [, mixed ...]]) U
Return the highest value in an array or a series of arguments */
PHP_FUNCTION(max)
{
@@ -1567,20 +1567,41 @@
static void php_compact_var(HashTable *eg_active_symbol_table, zval
*return_value, zval *entry)
{
+ zstr key;
+ int key_len;
+ zend_bool free_key = 0;
zval **value_ptr, *value, *data;
-
- if (Z_TYPE_P(entry) == IS_STRING ||
- Z_TYPE_P(entry) == IS_UNICODE) {
- if (zend_u_hash_find(eg_active_symbol_table, Z_TYPE_P(entry),
Z_UNIVAL_P(entry),
- Z_UNILEN_P(entry)+1, (void
**)&value_ptr) != FAILURE) {
+
+ if (Z_TYPE_P(entry) == IS_STRING || Z_TYPE_P(entry) == IS_UNICODE) {
+ key = Z_UNIVAL_P(entry);
+ key_len = Z_UNILEN_P(entry);
+
+ if (Z_TYPE_P(entry) == IS_UNICODE) {
+ /* Identifier normalization */
+ UChar *norm;
+ int norm_len;
+
+ if (!zend_normalize_identifier(&norm, &norm_len, key.u,
key_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize
variable name: %r", key);
+ } else if (norm != key.u) {
+ key.u = norm;
+ key_len = norm_len;
+ free_key = 1;
+ }
+ }
+ if (zend_u_hash_find(eg_active_symbol_table, Z_TYPE_P(entry),
key,
+ key_len+1, (void
**)&value_ptr) != FAILURE) {
value = *value_ptr;
ALLOC_ZVAL(data);
*data = *value;
zval_copy_ctor(data);
INIT_PZVAL(data);
- zend_u_hash_update(Z_ARRVAL_P(return_value),
Z_TYPE_P(entry), Z_UNIVAL_P(entry),
- Z_UNILEN_P(entry)+1,
&data, sizeof(zval *), NULL);
+ zend_u_hash_update(Z_ARRVAL_P(return_value),
Z_TYPE_P(entry), key,
+ key_len+1, &data,
sizeof(zval *), NULL);
+ }
+ if (free_key) {
+ efree(key.v);
}
}
else if (Z_TYPE_P(entry) == IS_ARRAY) {
@@ -1597,7 +1618,7 @@
}
-/* {{{ proto array compact(mixed var_names [, mixed ...])
+/* {{{ proto array compact(mixed var_names [, mixed ...]) U
Creates a hash containing variables and their values */
PHP_FUNCTION(compact)
{
@@ -4624,7 +4645,7 @@
/* }}} */
-/* {{{ proto array array_chunk(array input, int size [, bool preserve_keys])
+/* {{{ proto array array_chunk(array input, int size [, bool preserve_keys]) U
Split array into chunks */
PHP_FUNCTION(array_chunk)
{
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php