- Timestamp:
- 07/08/2007 13:30:54 (17 months ago)
- Location:
- trunk/ext/php
- Files:
-
- 1 added
- 2 modified
-
TODO (modified) (2 diffs)
-
phpext.c (modified) (2 diffs)
-
phpunit-tests/TestLoad.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/php/TODO
r262 r263 2 2 General: 3 3 - "switch requirements to php 5.2 and remove redundant code" 4 - "write phpunit tests"4 - "write more phpunit tests" 5 5 - "syck_load_from_file(string $url[, resource $context])" 6 6 - "syck_dump_to_file(string $url, mixed $data[, int $flags[, resource $context]])" … … 10 10 - "Add support for datatypes": 11 11 - "float#base60" 12 - "float#exp"13 - "float#fix"14 - "int#base60"15 12 - merge 16 13 - "timestamp#iso8601" 17 14 - "timestamp#spaced" 18 15 - "timestamp#ymd" 16 - timestamp 19 17 - objects: 20 18 - "!php/hash:YAML::ClassName" -
trunk/ext/php/phpext.c
r259 r263 195 195 } else if (strcmp(n->type_id, "bool#no") == 0) { 196 196 ZVAL_BOOL(o, 0); 197 } else if (strcmp(n->type_id, "bool") == 0) { 198 /* implicit boolean */ 199 char *ptr = n->data.str->ptr; 200 size_t len = n->data.str->len; 201 202 if (len == 1) { 203 if (ptr[0] == 'y' || ptr[0] == 'Y') { 204 ZVAL_BOOL(o, 1); 205 } else if (ptr[0] == 'n' || ptr[0] == 'N') { 206 ZVAL_BOOL(o, 0); 207 } 208 } else if (len == 2) { 209 if (strncmp(ptr, "on", len) == 0 || strncmp(ptr, "On", len) == 0 || strncmp(ptr, "ON", len) == 0) { 210 ZVAL_BOOL(o, 1); 211 } else if (strncmp(ptr, "no", len) == 0 || strncmp(ptr, "No", len) == 0 || strncmp(ptr, "NO", len) == 0) { 212 ZVAL_BOOL(o, 0); 213 } 214 } else if (len == 3) { 215 if (strncmp(ptr, "yes", len) == 0 || strncmp(ptr, "Yes", len) == 0 || strncmp(ptr, "YES", len) == 0) { 216 ZVAL_BOOL(o, 1); 217 } else if (strncmp(ptr, "off", len) == 0 || strncmp(ptr, "Off", len) == 0 || strncmp(ptr, "OFF", len) == 0) { 218 ZVAL_BOOL(o, 0); 219 } 220 } else if (len == 4) { 221 if (strncmp(ptr, "true", len) == 0 || strncmp(ptr, "True", len) == 0 || strncmp(ptr, "TRUE", len) == 0) { 222 ZVAL_BOOL(o, 1); 223 } 224 } else if (len == 3) { 225 if (strncmp(ptr, "false", len) == 0 || strncmp(ptr, "False", len) == 0 || strncmp(ptr, "FALSE", len) == 0) { 226 ZVAL_BOOL(o, 1); 227 } 228 } 229 230 if (Z_TYPE_P(o) != IS_BOOL) { 231 zend_throw_exception_ex(syck_exception_entry, 0 TSRMLS_CC, "!bool specified, but value \"%s\" (len=%d) is incorrect on line %d, col %d: '%s'", ptr, len, p->linect, p->cursor - p->lineptr, p->lineptr); 232 } 197 233 } else if (strcmp(n->type_id, "int#hex") == 0) { 234 syck_str_blow_away_commas(n); 198 235 long intVal = strtol(n->data.str->ptr, NULL, 16); 199 236 ZVAL_LONG(o, intVal); 237 } else if (strcmp(n->type_id, "int#base60") == 0) { 238 char *ptr, *end; 239 long sixty = 1; 240 long total = 0; 241 242 syck_str_blow_away_commas(n); 243 ptr = n->data.str->ptr; 244 end = n->data.str->ptr + n->data.str->len; 245 246 while (end > ptr) { 247 long bnum = 0; 248 char *colon = end - 1; 249 while (colon >= ptr && *colon != ':') { 250 colon--; 251 } 252 253 if (colon >= ptr && *colon == ':') 254 *colon = '\0'; 255 256 bnum = strtol(colon + 1, NULL, 10); 257 total += bnum * sixty; 258 sixty *= 60; 259 end = colon; 260 } 261 262 ZVAL_LONG(o, total); 200 263 } else if (strcmp(n->type_id, "int#oct") == 0) { 264 syck_str_blow_away_commas(n); 201 265 long intVal = strtol(n->data.str->ptr, NULL, 8); 202 266 ZVAL_LONG(o, intVal); 203 267 } else if (strcmp(n->type_id, "int") == 0) { 268 syck_str_blow_away_commas(n); 204 269 long intVal = strtol(n->data.str->ptr, NULL, 10); 205 270 ZVAL_LONG(o, intVal); 206 } else if (strcmp(n->type_id, "float") == 0 ) {271 } else if (strcmp(n->type_id, "float") == 0 || strcmp(n->type_id, "float#fix") == 0 || strcmp(n->type_id, "float#exp") == 0) { 207 272 double f; 208 273 syck_str_blow_away_commas(n); 209 274 f = strtod(n->data.str->ptr, NULL); 275 276 ZVAL_DOUBLE(o, f); 277 } else if (strcmp(n->type_id, "float#sixty") == 0) { 278 double f; 279 syck_str_blow_away_commas(n); 280 f = strtod(n->data.str->ptr, NULL); 281 210 282 ZVAL_DOUBLE(o, f); 211 283 } else if (strcmp(n->type_id, "float#nan") == 0) { … … 448 520 zval *ptr; 449 521 450 if (ZEND_NUM_ARGS() != 1) {451 WRONG_PARAM_COUNT;452 }453 454 522 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &ptr) == FAILURE) { 455 523 return;