summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2000-06-09 13:50:39 +0000
committerAndrei Zmievski <andrei@php.net>2000-06-09 13:50:39 +0000
commite52889acd9ae6c110774588e21f10737d0116d56 (patch)
treeb4b02e90b6829804ba45541f9134059f44b99af6
parent99b4051eca3d6b3f737769120d8e9da815621097 (diff)
downloadphp-git-e52889acd9ae6c110774588e21f10737d0116d56.tar.gz
@- Changed WDDX to always serialize arrays as structs. (Andrei)
Changed WDDX to always serialize arrays as structs. PR #4924
-rw-r--r--ext/wddx/wddx.c45
-rw-r--r--main/fopen_wrappers.c2
2 files changed, 13 insertions, 34 deletions
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index bcc07eef11..a0a1e5d62b 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -385,60 +385,39 @@ static void php_wddx_serialize_hash(wddx_packet *packet, zval *var)
{
zval **ent;
char *key;
- int hash_type, ent_type;
ulong idx;
HashTable *target_hash;
char tmp_buf[WDDX_BUF_LEN];
target_hash = HASH_OF(var);
+ php_wddx_add_chunk_static(packet, WDDX_STRUCT_S);
/* If variable is an object, always use struct and serialize its classname */
if (var->type == IS_OBJECT) {
- php_wddx_add_chunk_static(packet, WDDX_STRUCT_S);
sprintf(tmp_buf, WDDX_VAR_S, PHP_CLASS_NAME_VAR);
php_wddx_add_chunk(packet, tmp_buf);
php_wddx_add_chunk_static(packet, WDDX_STRING_S);
php_wddx_add_chunk_ex(packet, var->value.obj.ce->name, var->value.obj.ce->name_length);
php_wddx_add_chunk_static(packet, WDDX_STRING_E);
php_wddx_add_chunk_static(packet, WDDX_VAR_E);
- } else {
- zend_hash_internal_pointer_reset(target_hash);
-
- hash_type = zend_hash_get_current_key(target_hash, &key, &idx);
-
- if (hash_type == HASH_KEY_IS_STRING) {
- php_wddx_add_chunk_static(packet, WDDX_STRUCT_S);
- efree(key);
- } else {
- sprintf(tmp_buf, WDDX_ARRAY_S, zend_hash_num_elements(target_hash));
- php_wddx_add_chunk(packet, tmp_buf);
- }
}
- for (;zend_hash_get_current_data(target_hash, (void**)&ent) == SUCCESS;
- zend_hash_move_forward(target_hash)) {
+ for (zend_hash_internal_pointer_reset(target_hash);
+ zend_hash_get_current_data(target_hash, (void**)&ent) == SUCCESS;
+ zend_hash_move_forward(target_hash)) {
if (*ent == var)
continue;
- if (var->type == IS_OBJECT || hash_type == HASH_KEY_IS_STRING) {
- ent_type = zend_hash_get_current_key(target_hash, &key, &idx);
-
- if (ent_type == HASH_KEY_IS_STRING) {
- php_wddx_serialize_var(packet, *ent, key);
- efree(key);
- } else {
- sprintf(tmp_buf, "%ld", idx);
- php_wddx_serialize_var(packet, *ent, tmp_buf);
- }
- } else
- php_wddx_serialize_var(packet, *ent, NULL);
+ if (zend_hash_get_current_key(target_hash, &key, &idx) == HASH_KEY_IS_STRING) {
+ php_wddx_serialize_var(packet, *ent, key);
+ efree(key);
+ } else {
+ sprintf(tmp_buf, "%ld", idx);
+ php_wddx_serialize_var(packet, *ent, tmp_buf);
+ }
}
- if (var->type == IS_OBJECT || hash_type == HASH_KEY_IS_STRING) {
- php_wddx_add_chunk_static(packet, WDDX_STRUCT_E);
- } else {
- php_wddx_add_chunk_static(packet, WDDX_ARRAY_E);
- }
+ php_wddx_add_chunk_static(packet, WDDX_STRUCT_E);
}
/* }}} */
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index ae8801ee36..1fad046d10 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -987,7 +987,7 @@ static FILE *php_fopen_url_wrapper(const char *path, char *mode, int options, in
const char *protocol=NULL;
int n=0;
- for(p=path;isalnum(*p);p++)
+ for(p=path;isalnum((int)*p);p++)
n++;
if((*p==':')&&(n>1)) {
protocol=path;