- Timestamp:
- 07/15/2007 07:24:00 (17 months ago)
- Location:
- trunk/ext/php
- Files:
-
- 5 modified
-
CHANGELOG (modified) (1 diff)
-
TODO (modified) (3 diffs)
-
package.xml (modified) (3 diffs)
-
phpext.c (modified) (15 diffs)
-
phpunit-tests/TestLoad.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/php/CHANGELOG
r266 r268 1 1 --- %YAML:1.0 2 - version: 0.9.1 3 date: 2007-07-15 4 status: beta 5 changes: 6 - fixed handling of invalid merge-references [pecl#11585] 7 - fixed tsrm-incompatibility introduced in 0.9 8 - added support for timestamps in syck_load 9 - added support for DateTime in syck_dump 10 - fixed dumping of associative-arrays 11 2 12 - version: 0.9 3 13 date: 2007-07-11 -
trunk/ext/php/TODO
r264 r268 1 1 --- 2 2 General: 3 - "switch requirements to php 5.2 and remove redundant code"4 3 - "write more phpunit tests" 5 4 - "syck_load_from_file(string $url[, resource $context])" … … 8 7 - "add PHP6 (unicode strings) support" 9 8 load: 10 - "Add support for datatypes":11 - merge12 - "timestamp#iso8601"13 - "timestamp#spaced"14 - "timestamp#ymd"15 - timestamp16 9 - objects: 17 10 - "!php/hash:YAML::ClassName" … … 22 15 - merge 23 16 - objects: 24 - "Datetime": {as: "timestamp#iso8601"}25 17 - Iterator: 26 18 as: map -
trunk/ext/php/package.xml
r267 r268 13 13 <active>yes</active> 14 14 </lead> 15 <date>2007-07-1 1</date>15 <date>2007-07-15</date> 16 16 <version> 17 <release>0.9 </release>17 <release>0.9.1</release> 18 18 <api>1.0</api> 19 19 </version> … … 24 24 <license uri="http://www.php.net/license">PHP License</license> 25 25 <notes> 26 - this is the first release in PECL 27 - added several unit-tests 28 - fixed a bunch of vartype-errors 29 - added support for sexagesimal numbers 26 - fixed handling of invalid merge-references [pecl#11585] 27 - fixed tsrm-incompatibility introduced in 0.9 28 - added support for timestamps in syck_load 29 - added support for DateTime in syck_dump 30 - fixed dumping of associative-arrays 30 31 </notes> 31 32 <contents> … … 55 56 <providesextension>syck</providesextension> 56 57 <extsrcrelease></extsrcrelease> 58 <changelog> 59 <release> 60 <date>2007-07-11</date> 61 <version> 62 <release>0.9.0</release> 63 <api>1.0</api> 64 </version> 65 <stability> 66 <release>beta</release> 67 <api>beta</api> 68 </stability> 69 <license uri="http://www.php.net/license">PHP License</license> 70 <notes> 71 - this is the first release in PECL 72 - added several unit-tests 73 - fixed a bunch of vartype-errors 74 - added support for sexagesimal numbers 75 </notes> 76 </release> 77 </changelog> 57 78 </package> -
trunk/ext/php/phpext.c
r266 r268 27 27 #include "php.h" 28 28 #include "zend_exceptions.h" 29 #include "zend_interfaces.h" 29 30 #include "php_ini.h" 30 31 #include "ext/standard/info.h" … … 71 72 size_t output_size; 72 73 size_t output_alloc; 74 unsigned char level; 73 75 zval **stack; 74 unsigned char level;75 76 } php_syck_emitter_xtra; 76 77 … … 104 105 { 105 106 while (ptr->output_size + len > ptr->output_alloc) { 106 ptr->output_alloc += 8192; 107 ptr->output = erealloc(ptr->output, ptr->output_alloc); 107 if (ptr->output_alloc == 0) { 108 ptr->output_alloc = 8192; 109 ptr->output = emalloc(ptr->output_alloc); 110 } else { 111 ptr->output_alloc += 8192; 112 ptr->output = erealloc(ptr->output, ptr->output_alloc); 113 } 108 114 } 109 115 … … 196 202 } else if (strcmp(n->type_id, "bool") == 0) { 197 203 /* implicit boolean */ 204 TSRMLS_FETCH(); 198 205 char *ptr = n->data.str->ptr; 199 206 size_t len = n->data.str->len; … … 306 313 } else if (strcmp(n->type_id, "float#neginf") == 0) { 307 314 ZVAL_DOUBLE(o, -inf()); 308 } else if (strcmp(n->type_id, "merge") == 0) { 309 /* This thing doesn't work, anyway */ 310 /* 315 } else if (strncmp(n->type_id, "timestamp", 9) == 0) { 311 316 TSRMLS_FETCH(); 312 object_init_ex(o, merge_key_entry); 313 */ 317 zval fname, param, *params[1]; 318 319 ZVAL_STRING(&fname, "date_create", 1); 320 INIT_ZVAL(param); 321 params[0] = ¶m; 322 ZVAL_STRINGL(params[0], n->data.str->ptr, n->data.str->len, 1); 323 324 call_user_function(EG(function_table), NULL, &fname, o, 1, params TSRMLS_CC); 325 326 zval_dtor(&fname); 327 zval_dtor(params[0]); 314 328 } else { 329 php_error(E_NOTICE, "syck extension didn't handle %s type => treating as a string", n->type_id); 315 330 ZVAL_STRINGL(o, n->data.str->ptr, n->data.str->len, 1); 316 331 } … … 319 334 case syck_seq_kind: 320 335 { 321 SYMID oid;322 336 size_t i; 323 zval *o2;324 337 325 338 array_init(o); 326 339 327 340 for (i = 0; i < n->data.list->idx; i++) { 328 oid = syck_seq_read(n, i); 341 SYMID oid = syck_seq_read(n, i); 342 zval *o2; 343 329 344 syck_lookup_sym(p, oid, (char **) &o2); /* retrieving child-node */ 330 345 … … 339 354 size_t i; 340 355 zval *o2, *o3; 356 zval *res; 341 357 342 358 array_init(o); … … 360 376 361 377 return syck_add_sym(p, (char *)o); /* storing node */ 378 } 379 380 SyckNode * php_syck_badanchor_handler(SyckParser *p, char *str) 381 { 382 TSRMLS_FETCH(); 383 SyckNode *res; 384 char *endl = p->cursor; 385 386 while (*endl != '\0' && *endl != '\n') 387 endl++; 388 389 endl[0] = '\0'; 390 391 res = syck_alloc_str(); 392 393 zend_throw_exception_ex(syck_exception_entry, 0 TSRMLS_CC, "bad anchor \"%s\" on line %d, col %d", str, p->linect, p->cursor - p->lineptr - strlen(str)); 394 395 return res; 362 396 } 363 397 … … 421 455 422 456 case IS_STRING: 423 syck_emit_scalar(e, "str ing", scalar_none, 0, 0, 0, Z_STRVAL_P(data), Z_STRLEN_P(data));457 syck_emit_scalar(e, "str", scalar_none, 0, 0, 0, Z_STRVAL_P(data), Z_STRLEN_P(data)); 424 458 break; 425 459 … … 448 482 449 483 for (zend_hash_internal_pointer_reset(tbl); zend_hash_has_more_elements(tbl) == SUCCESS; zend_hash_move_forward(tbl)) { 450 zval **ppzval, *kzval;484 zval **ppzval, kzval; 451 485 char *key; 452 486 size_t key_len, idx; … … 455 489 zend_hash_get_current_data(tbl, (void **)&ppzval); 456 490 457 ZVAL_STRINGL(kzval, key, key_len - 1, 0); 458 if (psex_push_obj(bonus, kzval)) { 491 ZVAL_STRINGL(&kzval, key, key_len - 1, 1); 492 493 if (psex_push_obj(bonus, &kzval)) { 459 494 syck_emit_item(e, bonus->level); 460 495 psex_pop_obj(bonus); … … 466 501 } 467 502 503 zval_dtor(&kzval); 468 504 } 469 505 … … 474 510 475 511 case IS_OBJECT: 512 { 513 TSRMLS_FETCH(); 514 char *name; 515 zend_uint name_len; 516 zend_class_entry *ce = Z_OBJCE_P(data); 517 518 zend_get_object_classname(data, &name, &name_len TSRMLS_CC); 519 520 if (strncmp(name, "DateTime", name_len) == 0) { 521 zval *retval; 522 zval constant; 523 524 zend_get_constant("DateTime::ISO8601", 17, &constant TSRMLS_CC); 525 zend_call_method_with_1_params(&data, ce, NULL, "format", &retval, &constant); 526 527 zval_dtor(&constant); 528 529 syck_emit_scalar(e, "tag:yaml.org,2002:timestamp#iso8601", scalar_none, 0, 0, 0, Z_STRVAL_P(retval), Z_STRLEN_P(retval)); 530 zval_dtor(retval); 531 efree(retval); 532 } 533 534 efree(name); 535 } 476 536 break; 477 537 … … 510 570 511 571 syck_parser_handler(parser, php_syck_handler); 572 syck_parser_bad_anchor_handler(parser, php_syck_badanchor_handler); 512 573 syck_parser_error_handler(parser, php_syck_ehandler); 513 574 … … 522 583 *return_value = *obj; 523 584 zval_copy_ctor(return_value); 524 525 585 zval_ptr_dtor(&obj); 526 586 } -
trunk/ext/php/phpunit-tests/TestLoad.php
r266 r268 5 5 6 6 require_once "PHPUnit/Framework/TestCase.php"; 7 8 error_reporting(E_ALL); 7 9 8 10 class TestLoad extends PHPUnit_Framework_TestCase … … 124 126 } 125 127 126 public function test Default()128 public function testTimestamps() 127 129 { 130 // canonical 131 $this->assertType('DateTime', syck_load("2001-12-15T02:59:43.1Z")); 132 // iso8601 133 $this->assertType('DateTime', syck_load("2001-12-14t21:59:43.10-05:00")); 134 // spaced 135 $this->assertType('DateTime', syck_load("2001-12-14 21:59:43.10 -05")); 136 // date 137 $this->assertType('DateTime', syck_load("2002-12-14")); 128 138 } 129 139 }