Changeset 273 for trunk/ext/php
- Timestamp:
- 10/04/2007 15:22:32 (14 months ago)
- Location:
- trunk/ext/php
- Files:
-
- 1 added
- 2 modified
-
CHANGELOG (modified) (1 diff)
-
phpext.c (modified) (6 diffs)
-
phpunit-tests/TestDump.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/php/CHANGELOG
r272 r273 1 1 --- %YAML:1.0 2 2 - version: 0.9.2 3 date: 2007-0 8-??3 date: 2007-09-?? 4 4 status: beta 5 5 changes: 6 6 - short-and-flat arrays are dumped using inline-mode now (for readability) 7 7 - gcc-2.95 compatibility (patch by Brian J. France) 8 - fixed dumping of mixed arrays and numeric-arrays starting from non-zero digit 8 9 9 10 - version: 0.9.1 -
trunk/ext/php/phpext.c
r272 r273 32 32 #include "php_syck.h" 33 33 34 #define PHP_SYCK_VERSION " @PACKAGE_VERSION@"34 #define PHP_SYCK_VERSION "0.9.2-dev" 35 35 36 36 /** … … 134 134 return ptr->stack[(ptr->level)--]; 135 135 } 136 137 138 139 140 /** 141 * returns 142 * 0 for sequential numeric arrays 143 * 1 for insequential or associative arrays 144 */ 145 static int psex_determine_array_type(HashTable *myht TSRMLS_DC) /* {{{ */ 146 { 147 int i = myht ? zend_hash_num_elements(myht) : 0; 148 149 if (i > 0) { 150 char *key; 151 uint key_len; 152 HashPosition pos; 153 ulong index, idx = 0; 154 155 zend_hash_internal_pointer_reset_ex(myht, &pos); 156 157 for (;; zend_hash_move_forward_ex(myht, &pos)) { 158 i = zend_hash_get_current_key_ex(myht, &key, &key_len, &index, 0, &pos); 159 160 if (i == HASH_KEY_NON_EXISTANT) 161 break; 162 163 if (i == HASH_KEY_IS_STRING) { 164 return 1; 165 } else { 166 if (index != idx) { 167 return 1; 168 } 169 } 170 171 idx++; 172 } 173 } 174 175 return 0; 176 } 177 178 179 136 180 137 181 function_entry syck_functions[] = { … … 416 460 php_syck_emitter_xtra *bonus = (php_syck_emitter_xtra *) e->bonus; 417 461 zval *data = bonus->stack[id]; 462 TSRMLS_FETCH(); 418 463 419 464 switch (Z_TYPE_P(data)) { … … 481 526 } 482 527 483 if ( zend_hash_index_exists(tbl, 0)) {528 if (0 == psex_determine_array_type(tbl TSRMLS_CC)) { 484 529 /* indexed array */ 485 530 if (flat_and_short) … … 509 554 zval **ppzval, kzval; 510 555 char *key; 511 size_t key_len, idx ;556 size_t key_len, idx, key_type; 512 557 513 558 zend_hash_get_current_key_ex(tbl, (char **)&key, (uint *)&key_len, &idx, 0, NULL); 514 559 zend_hash_get_current_data(tbl, (void **)&ppzval); 560 key_type = zend_hash_get_current_key_type_ex(tbl, NULL); 561 562 if (key_type == HASH_KEY_IS_LONG) { 563 key_len = 1 + snprintf(key, 0, "%ld", idx); /* getting size ("0" doesn't let output) */ 564 key = emalloc(key_len); 565 snprintf(key, key_len, "%ld", idx); 566 } 515 567 516 568 ZVAL_STRINGL(&kzval, key, key_len - 1, 1); … … 527 579 528 580 zval_dtor(&kzval); 581 582 if (key_type == HASH_KEY_IS_LONG) { 583 efree(key); 584 } 529 585 } 530 586