Changeset 264 for libyaml/trunk/src/scanner.c
- Timestamp:
- 12/27/07 12:14:01 (5 years ago)
- File:
-
- 1 edited
-
libyaml/trunk/src/scanner.c (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libyaml/trunk/src/scanner.c
r263 r264 516 516 */ 517 517 518 #define READ(parser, string)\519 ( STRING_EXTEND(parser,string) ?\520 (COPY(string, parser->input),\518 #define READ(parser, string) \ 519 (OSTRING_EXTEND(parser, string) ? \ 520 (COPY(string, parser->input), \ 521 521 parser->mark.index ++, \ 522 522 parser->mark.column ++, \ … … 528 528 */ 529 529 530 #define READ_LINE(parser, string)\531 ( STRING_EXTEND(parser,string) ?\532 (((CHECK_AT(parser->input, '\r',0)\533 && CHECK_AT(parser->input, '\n',1)) ?/* CR LF -> LF */ \530 #define READ_LINE(parser, string) \ 531 (OSTRING_EXTEND(parser, string) ? \ 532 (((CHECK_AT(parser->input, '\r', 0) \ 533 && CHECK_AT(parser->input, '\n', 1)) ? /* CR LF -> LF */ \ 534 534 (JOIN_OCTET(string, (yaml_char_t) '\n'), \ 535 535 parser->input.pointer += 2, \ … … 538 538 parser->mark.line ++, \ 539 539 parser->unread -= 2) : \ 540 (CHECK_AT(parser->input, '\r',0)\541 || CHECK_AT(parser->input, '\n',0)) ?/* CR|LF -> LF */ \542 (JOIN_OCTET(string, (yaml_char_t) '\n'),\540 (CHECK_AT(parser->input, '\r', 0) \ 541 || CHECK_AT(parser->input, '\n', 0)) ? /* CR|LF -> LF */ \ 542 (JOIN_OCTET(string, (yaml_char_t) '\n'), \ 543 543 parser->input.pointer ++, \ 544 544 parser->mark.index ++, \ … … 546 546 parser->mark.line ++, \ 547 547 parser->unread --) : \ 548 (CHECK_AT(parser->input, '\xC2',0)\549 && CHECK_AT(parser->input, '\x85',1)) ?/* NEL -> LF */ \550 (JOIN_OCTET(string, (yaml_char_t) '\n'),\548 (CHECK_AT(parser->input, '\xC2', 0) \ 549 && CHECK_AT(parser->input, '\x85', 1)) ? /* NEL -> LF */ \ 550 (JOIN_OCTET(string, (yaml_char_t) '\n'), \ 551 551 parser->input.pointer += 2, \ 552 552 parser->mark.index ++, \ … … 554 554 parser->mark.line ++, \ 555 555 parser->unread --) : \ 556 (CHECK_AT(parser->input, '\xE2',0) &&\557 CHECK_AT(parser->input, '\x80',1) &&\558 (CHECK_AT(parser->input, '\xA8',2) ||\559 CHECK_AT(parser->input, '\xA9',2))) ?/* LS|PS -> LS|PS */ \560 (COPY_OCTET(string, parser->input),\561 COPY_OCTET(string, parser->input),\562 COPY_OCTET(string, parser->input),\556 (CHECK_AT(parser->input, '\xE2', 0) && \ 557 CHECK_AT(parser->input, '\x80', 1) && \ 558 (CHECK_AT(parser->input, '\xA8', 2) || \ 559 CHECK_AT(parser->input, '\xA9', 2))) ? /* LS|PS -> LS|PS */ \ 560 (COPY_OCTET(string, parser->input), \ 561 COPY_OCTET(string, parser->input), \ 562 COPY_OCTET(string, parser->input), \ 563 563 parser->mark.index ++, \ 564 564 parser->mark.column = 0, \ … … 572 572 573 573 YAML_DECLARE(int) 574 yaml_parser_ scan(yaml_parser_t *parser, yaml_token_t *token);574 yaml_parser_parse_token(yaml_parser_t *parser, yaml_token_t *token); 575 575 576 576 /* … … 709 709 static int 710 710 yaml_parser_scan_uri_escapes(yaml_parser_t *parser, int directive, 711 yaml_mark_t start_mark, yaml_ string_t *string);711 yaml_mark_t start_mark, yaml_ostring_t *string); 712 712 713 713 static int … … 717 717 static int 718 718 yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, 719 int *indent, yaml_ string_t *breaks,719 int *indent, yaml_ostring_t *breaks, 720 720 yaml_mark_t start_mark, yaml_mark_t *end_mark); 721 721 … … 732 732 733 733 YAML_DECLARE(int) 734 yaml_parser_ scan(yaml_parser_t *parser, yaml_token_t *token)734 yaml_parser_parse_token(yaml_parser_t *parser, yaml_token_t *token) 735 735 { 736 736 assert(parser); /* Non-NULL parser object is expected. */ … … 2093 2093 yaml_mark_t start_mark, yaml_char_t **name) 2094 2094 { 2095 yaml_ string_t string = NULL_STRING;2096 2097 if (! STRING_INIT(parser, string, INITIAL_STRING_CAPACITY))2095 yaml_ostring_t string = NULL_OSTRING; 2096 2097 if (!OSTRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 2098 2098 goto error; 2099 2099 … … 2131 2131 2132 2132 error: 2133 STRING_DEL(parser, string);2133 OSTRING_DEL(parser, string); 2134 2134 return 0; 2135 2135 } … … 2312 2312 int length = 0; 2313 2313 yaml_mark_t start_mark, end_mark; 2314 yaml_ string_t string = NULL_STRING;2315 2316 if (! STRING_INIT(parser, string, INITIAL_STRING_CAPACITY))2314 yaml_ostring_t string = NULL_OSTRING; 2315 2316 if (!OSTRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 2317 2317 goto error; 2318 2318 … … 2367 2367 2368 2368 error: 2369 STRING_DEL(parser, string);2369 OSTRING_DEL(parser, string); 2370 2370 return 0; 2371 2371 } … … 2496 2496 yaml_mark_t start_mark, yaml_char_t **handle) 2497 2497 { 2498 yaml_ string_t string = NULL_STRING;2499 2500 if (! STRING_INIT(parser, string, INITIAL_STRING_CAPACITY))2498 yaml_ostring_t string = NULL_OSTRING; 2499 2500 if (!OSTRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 2501 2501 goto error; 2502 2502 … … 2554 2554 2555 2555 error: 2556 STRING_DEL(parser, string);2556 OSTRING_DEL(parser, string); 2557 2557 return 0; 2558 2558 } … … 2567 2567 { 2568 2568 size_t length = head ? strlen((char *)head) : 0; 2569 yaml_ string_t string = NULL_STRING;2570 2571 if (! STRING_INIT(parser, string, INITIAL_STRING_CAPACITY))2569 yaml_ostring_t string = NULL_OSTRING; 2570 2571 if (!OSTRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 2572 2572 goto error; 2573 2573 … … 2575 2575 2576 2576 while (string.capacity <= length) { 2577 if (!yaml_ string_extend(&string.buffer, &string.capacity)) {2577 if (!yaml_ostring_extend(&string.buffer, &string.capacity)) { 2578 2578 MEMORY_ERROR_INIT(parser); 2579 2579 goto error; … … 2633 2633 2634 2634 if (!length) { 2635 if (! STRING_EXTEND(parser, string))2635 if (!OSTRING_EXTEND(parser, string)) 2636 2636 goto error; 2637 2637 … … 2647 2647 2648 2648 error: 2649 STRING_DEL(parser, string);2649 OSTRING_DEL(parser, string); 2650 2650 return 0; 2651 2651 } … … 2657 2657 static int 2658 2658 yaml_parser_scan_uri_escapes(yaml_parser_t *parser, int directive, 2659 yaml_mark_t start_mark, yaml_ string_t *string)2659 yaml_mark_t start_mark, yaml_ostring_t *string) 2660 2660 { 2661 2661 int width = 0; … … 2731 2731 yaml_mark_t start_mark; 2732 2732 yaml_mark_t end_mark; 2733 yaml_ string_t string = NULL_STRING;2734 yaml_ string_t leading_break = NULL_STRING;2735 yaml_ string_t trailing_breaks = NULL_STRING;2733 yaml_ostring_t string = NULL_OSTRING; 2734 yaml_ostring_t leading_break = NULL_OSTRING; 2735 yaml_ostring_t trailing_breaks = NULL_OSTRING; 2736 2736 int chomping = 0; 2737 2737 int increment = 0; … … 2740 2740 int trailing_blank = 0; 2741 2741 2742 if (! STRING_INIT(parser, string, INITIAL_STRING_CAPACITY))2742 if (!OSTRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 2743 2743 goto error; 2744 if (! STRING_INIT(parser, leading_break, INITIAL_STRING_CAPACITY))2744 if (!OSTRING_INIT(parser, leading_break, INITIAL_STRING_CAPACITY)) 2745 2745 goto error; 2746 if (! STRING_INIT(parser, trailing_breaks, INITIAL_STRING_CAPACITY))2746 if (!OSTRING_INIT(parser, trailing_breaks, INITIAL_STRING_CAPACITY)) 2747 2747 goto error; 2748 2748 … … 2881 2881 2882 2882 if (*trailing_breaks.buffer == '\0') { 2883 if (! STRING_EXTEND(parser, string)) goto error;2883 if (!OSTRING_EXTEND(parser, string)) goto error; 2884 2884 JOIN_OCTET(string, ' '); 2885 2885 } … … 2935 2935 start_mark, end_mark); 2936 2936 2937 STRING_DEL(parser, leading_break);2938 STRING_DEL(parser, trailing_breaks);2937 OSTRING_DEL(parser, leading_break); 2938 OSTRING_DEL(parser, trailing_breaks); 2939 2939 2940 2940 return 1; 2941 2941 2942 2942 error: 2943 STRING_DEL(parser, string);2944 STRING_DEL(parser, leading_break);2945 STRING_DEL(parser, trailing_breaks);2943 OSTRING_DEL(parser, string); 2944 OSTRING_DEL(parser, leading_break); 2945 OSTRING_DEL(parser, trailing_breaks); 2946 2946 2947 2947 return 0; … … 2955 2955 static int 2956 2956 yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser, 2957 int *indent, yaml_ string_t *breaks,2957 int *indent, yaml_ostring_t *breaks, 2958 2958 yaml_mark_t start_mark, yaml_mark_t *end_mark) 2959 2959 { … … 3023 3023 yaml_mark_t start_mark; 3024 3024 yaml_mark_t end_mark; 3025 yaml_ string_t string = NULL_STRING;3026 yaml_ string_t leading_break = NULL_STRING;3027 yaml_ string_t trailing_breaks = NULL_STRING;3028 yaml_ string_t whitespaces = NULL_STRING;3025 yaml_ostring_t string = NULL_OSTRING; 3026 yaml_ostring_t leading_break = NULL_OSTRING; 3027 yaml_ostring_t trailing_breaks = NULL_OSTRING; 3028 yaml_ostring_t whitespaces = NULL_OSTRING; 3029 3029 int leading_blanks; 3030 3030 3031 if (! STRING_INIT(parser, string, INITIAL_STRING_CAPACITY))3031 if (!OSTRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 3032 3032 goto error; 3033 if (! STRING_INIT(parser, leading_break, INITIAL_STRING_CAPACITY))3033 if (!OSTRING_INIT(parser, leading_break, INITIAL_STRING_CAPACITY)) 3034 3034 goto error; 3035 if (! STRING_INIT(parser, trailing_breaks, INITIAL_STRING_CAPACITY))3035 if (!OSTRING_INIT(parser, trailing_breaks, INITIAL_STRING_CAPACITY)) 3036 3036 goto error; 3037 if (! STRING_INIT(parser, whitespaces, INITIAL_STRING_CAPACITY))3037 if (!OSTRING_INIT(parser, whitespaces, INITIAL_STRING_CAPACITY)) 3038 3038 goto error; 3039 3039 … … 3089 3089 && CHECK_AT(parser->input, '\'', 1)) 3090 3090 { 3091 if (! STRING_EXTEND(parser, string)) goto error;3091 if (!OSTRING_EXTEND(parser, string)) goto error; 3092 3092 JOIN_OCTET(string, '\''); 3093 3093 SKIP(parser); … … 3120 3120 size_t code_length = 0; 3121 3121 3122 if (! STRING_EXTEND(parser, string)) goto error;3122 if (!OSTRING_EXTEND(parser, string)) goto error; 3123 3123 3124 3124 /* Check the escape character. */ … … 3342 3342 if (leading_break.buffer[0] == '\n') { 3343 3343 if (trailing_breaks.buffer[0] == '\0') { 3344 if (! STRING_EXTEND(parser, string)) goto error;3344 if (!OSTRING_EXTEND(parser, string)) goto error; 3345 3345 JOIN_OCTET(string, ' '); 3346 3346 } … … 3377 3377 start_mark, end_mark); 3378 3378 3379 STRING_DEL(parser, leading_break);3380 STRING_DEL(parser, trailing_breaks);3381 STRING_DEL(parser, whitespaces);3379 OSTRING_DEL(parser, leading_break); 3380 OSTRING_DEL(parser, trailing_breaks); 3381 OSTRING_DEL(parser, whitespaces); 3382 3382 3383 3383 return 1; 3384 3384 3385 3385 error: 3386 STRING_DEL(parser, string);3387 STRING_DEL(parser, leading_break);3388 STRING_DEL(parser, trailing_breaks);3389 STRING_DEL(parser, whitespaces);3386 OSTRING_DEL(parser, string); 3387 OSTRING_DEL(parser, leading_break); 3388 OSTRING_DEL(parser, trailing_breaks); 3389 OSTRING_DEL(parser, whitespaces); 3390 3390 3391 3391 return 0; … … 3401 3401 yaml_mark_t start_mark; 3402 3402 yaml_mark_t end_mark; 3403 yaml_ string_t string = NULL_STRING;3404 yaml_ string_t leading_break = NULL_STRING;3405 yaml_ string_t trailing_breaks = NULL_STRING;3406 yaml_ string_t whitespaces = NULL_STRING;3403 yaml_ostring_t string = NULL_OSTRING; 3404 yaml_ostring_t leading_break = NULL_OSTRING; 3405 yaml_ostring_t trailing_breaks = NULL_OSTRING; 3406 yaml_ostring_t whitespaces = NULL_OSTRING; 3407 3407 int leading_blanks = 0; 3408 3408 int indent = parser->indent+1; 3409 3409 3410 if (! STRING_INIT(parser, string, INITIAL_STRING_CAPACITY))3410 if (!OSTRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 3411 3411 goto error; 3412 if (! STRING_INIT(parser, leading_break, INITIAL_STRING_CAPACITY))3412 if (!OSTRING_INIT(parser, leading_break, INITIAL_STRING_CAPACITY)) 3413 3413 goto error; 3414 if (! STRING_INIT(parser, trailing_breaks, INITIAL_STRING_CAPACITY))3414 if (!OSTRING_INIT(parser, trailing_breaks, INITIAL_STRING_CAPACITY)) 3415 3415 goto error; 3416 if (! STRING_INIT(parser, whitespaces, INITIAL_STRING_CAPACITY))3416 if (!OSTRING_INIT(parser, whitespaces, INITIAL_STRING_CAPACITY)) 3417 3417 goto error; 3418 3418 … … 3476 3476 if (leading_break.buffer[0] == '\n') { 3477 3477 if (trailing_breaks.buffer[0] == '\0') { 3478 if (! STRING_EXTEND(parser, string)) goto error;3478 if (!OSTRING_EXTEND(parser, string)) goto error; 3479 3479 JOIN_OCTET(string, ' '); 3480 3480 } … … 3580 3580 } 3581 3581 3582 STRING_DEL(parser, leading_break);3583 STRING_DEL(parser, trailing_breaks);3584 STRING_DEL(parser, whitespaces);3582 OSTRING_DEL(parser, leading_break); 3583 OSTRING_DEL(parser, trailing_breaks); 3584 OSTRING_DEL(parser, whitespaces); 3585 3585 3586 3586 return 1; 3587 3587 3588 3588 error: 3589 STRING_DEL(parser, string);3590 STRING_DEL(parser, leading_break);3591 STRING_DEL(parser, trailing_breaks);3592 STRING_DEL(parser, whitespaces);3589 OSTRING_DEL(parser, string); 3590 OSTRING_DEL(parser, leading_break); 3591 OSTRING_DEL(parser, trailing_breaks); 3592 OSTRING_DEL(parser, whitespaces); 3593 3593 3594 3594 return 0;
Note: See TracChangeset
for help on using the changeset viewer.
