Changeset 210 for libyaml/trunk
- Timestamp:
- 07/21/06 14:29:00 (6 years ago)
- Location:
- libyaml/trunk
- Files:
-
- 6 modified
-
src/api.c (modified) (2 diffs)
-
src/parser.c (modified) (3 diffs)
-
src/reader.c (modified) (3 diffs)
-
src/scanner.c (modified) (1 diff)
-
tests/run-parser.c (modified) (1 diff)
-
tests/run-scanner.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libyaml/trunk/src/api.c
r208 r210 368 368 case YAML_SCALAR_TOKEN: 369 369 yaml_free(token->data.scalar.value); 370 break; 371 372 default: 370 373 break; 371 374 } … … 417 420 yaml_free(event->data.mapping_start.tag); 418 421 break; 422 423 default: 424 break; 419 425 } 420 426 -
libyaml/trunk/src/parser.c
r208 r210 364 364 assert(1); /* Invalid state. */ 365 365 } 366 367 return 0; 366 368 } 367 369 … … 1359 1361 if (STACK_EMPTY(parser, tag_directives)) { 1360 1362 *tag_directives_start_ref = *tag_directives_end_ref = NULL; 1363 STACK_DEL(parser, tag_directives); 1361 1364 } 1362 1365 else { 1363 1366 *tag_directives_start_ref = tag_directives.start; 1364 *tag_directives_end_ref = tag_directives.end; 1365 } 1367 *tag_directives_end_ref = tag_directives.top; 1368 } 1369 } 1370 else { 1371 STACK_DEL(parser, tag_directives); 1366 1372 } 1367 1373 … … 1385 1391 yaml_tag_directive_t *tag_directive; 1386 1392 yaml_tag_directive_t copy = { NULL, NULL }; 1387 int length;1388 1393 1389 1394 for (tag_directive = parser->tag_directives.start; -
libyaml/trunk/src/reader.c
r208 r210 187 187 while (parser->raw_buffer.pointer != parser->raw_buffer.last) 188 188 { 189 unsigned int value , value2;189 unsigned int value = 0, value2 = 0; 190 190 int incomplete = 0; 191 191 unsigned char octet; 192 unsigned int width ;192 unsigned int width = 0; 193 193 int k, low, high; 194 194 int raw_unread = parser->raw_buffer.last - parser->raw_buffer.pointer; … … 367 367 /* Get the next character. */ 368 368 369 unsigned intvalue2 = parser->raw_buffer.pointer[low+2]369 value2 = parser->raw_buffer.pointer[low+2] 370 370 + (parser->raw_buffer.pointer[high+2] << 8); 371 371 … … 387 387 388 388 break; 389 390 default: 391 assert(1); /* Impossible. */ 389 392 } 390 393 -
libyaml/trunk/src/scanner.c
r208 r210 3602 3602 if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error; 3603 3603 3604 start_mark = parser->mark;3604 start_mark = end_mark = parser->mark; 3605 3605 3606 3606 /* Consume the content of the plain scalar. */ -
libyaml/trunk/tests/run-parser.c
r208 r210 8 8 main(int argc, char *argv[]) 9 9 { 10 FILE *file; 11 yaml_parser_t parser; 12 yaml_event_t event; 13 int done = 0; 14 int count = 0; 10 int number; 15 11 16 if (argc !=2) {17 printf("Usage: %s file .yaml\n", argv[0]);12 if (argc < 2) { 13 printf("Usage: %s file1.yaml ...\n", argv[0]); 18 14 return 0; 19 15 } 20 file = fopen(argv[1], "rb");21 assert(file);22 16 23 assert(yaml_parser_initialize(&parser)); 17 for (number = 1; number < argc; number ++) 18 { 19 FILE *file; 20 yaml_parser_t parser; 21 yaml_event_t event; 22 int done = 0; 23 int count = 0; 24 int error = 0; 24 25 25 yaml_parser_set_input_file(&parser, file); 26 printf("[%d] Parsing '%s': ", number, argv[number]); 27 fflush(stdout); 26 28 27 while (!done) 28 { 29 assert(yaml_parser_parse(&parser, &event)); 29 file = fopen(argv[number], "rb"); 30 assert(file); 30 31 31 done = (event.type == YAML_STREAM_END_EVENT);32 assert(yaml_parser_initialize(&parser)); 32 33 33 yaml_ event_delete(&event);34 yaml_parser_set_input_file(&parser, file); 34 35 35 count ++; 36 while (!done) 37 { 38 if (!yaml_parser_parse(&parser, &event)) { 39 error = 1; 40 break; 41 } 42 43 done = (event.type == YAML_STREAM_END_EVENT); 44 45 yaml_event_delete(&event); 46 47 count ++; 48 } 49 50 yaml_parser_delete(&parser); 51 52 assert(!fclose(file)); 53 54 printf("%s (%d events)\n", (error ? "FAILURE" : "SUCCESS"), count); 36 55 } 37 38 yaml_parser_delete(&parser);39 40 fclose(file);41 42 printf("Parsing the file '%s': %d events\n", argv[1], count);43 56 44 57 return 0; -
libyaml/trunk/tests/run-scanner.c
r208 r210 8 8 main(int argc, char *argv[]) 9 9 { 10 FILE *file; 11 yaml_parser_t parser; 12 yaml_token_t token; 13 int done = 0; 14 int count = 0; 10 int number; 15 11 16 if (argc !=2) {17 printf("Usage: %s file .yaml\n", argv[0]);12 if (argc < 2) { 13 printf("Usage: %s file1.yaml ...\n", argv[0]); 18 14 return 0; 19 15 } 20 file = fopen(argv[1], "rb");21 assert(file);22 16 23 assert(yaml_parser_initialize(&parser)); 17 for (number = 1; number < argc; number ++) 18 { 19 FILE *file; 20 yaml_parser_t parser; 21 yaml_token_t token; 22 int done = 0; 23 int count = 0; 24 int error = 0; 24 25 25 yaml_parser_set_input_file(&parser, file); 26 printf("[%d] Scanning '%s': ", number, argv[number]); 27 fflush(stdout); 26 28 27 while (!done) 28 { 29 assert(yaml_parser_scan(&parser, &token)); 29 file = fopen(argv[number], "rb"); 30 assert(file); 30 31 31 done = (token.type == YAML_STREAM_END_TOKEN);32 assert(yaml_parser_initialize(&parser)); 32 33 33 yaml_ token_delete(&token);34 yaml_parser_set_input_file(&parser, file); 34 35 35 count ++; 36 while (!done) 37 { 38 if (!yaml_parser_scan(&parser, &token)) { 39 error = 1; 40 break; 41 } 42 43 done = (token.type == YAML_STREAM_END_TOKEN); 44 45 yaml_token_delete(&token); 46 47 count ++; 48 } 49 50 yaml_parser_delete(&parser); 51 52 assert(!fclose(file)); 53 54 printf("%s (%d tokens)\n", (error ? "FAILURE" : "SUCCESS"), count); 36 55 } 37 38 yaml_parser_delete(&parser);39 40 fclose(file);41 42 printf("Parsing the file '%s': %d tokens\n", argv[1], count);43 56 44 57 return 0;
