Changeset 238
- Timestamp:
- 01/07/07 15:11:16 (5 years ago)
- Location:
- libyaml/trunk
- Files:
-
- 2 added
- 9 modified
- 4 copied
-
configure.ac (modified) (1 diff)
-
include/yaml.h (modified) (46 diffs)
-
src/Makefile.am (modified) (1 diff)
-
src/api.c (modified) (10 diffs)
-
src/dumper.c (added)
-
src/emitter.c (modified) (3 diffs)
-
src/loader.c (added)
-
src/yaml_private.h (modified) (4 diffs)
-
tests/Makefile.am (modified) (1 diff)
-
tests/example-deconstructor-alt.c (copied) (copied from libyaml/trunk/tests/example-deconstructor.c) (24 diffs)
-
tests/example-deconstructor.c (modified) (1 diff)
-
tests/example-reformatter-alt.c (copied) (copied from libyaml/trunk/tests/example-reformatter.c) (5 diffs)
-
tests/run-dumper.c (copied) (copied from libyaml/trunk/tests/run-emitter.c) (6 diffs)
-
tests/run-emitter.c (modified) (1 diff)
-
tests/run-loader.c (copied) (copied from libyaml/trunk/tests/run-parser.c) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libyaml/trunk/configure.ac
r172 r238 19 19 # YAML_AGE = 0 20 20 m4_define([YAML_RELEASE], 0) 21 m4_define([YAML_CURRENT], 0)21 m4_define([YAML_CURRENT], 1) 22 22 m4_define([YAML_REVISION], 0) 23 23 m4_define([YAML_AGE], 0) -
libyaml/trunk/include/yaml.h
r237 r238 60 60 * Get the library version numbers. 61 61 * 62 * @param[out] major Major version number.63 * @param[out] minor Minor version number.64 * @param[out] patch Patch version number.62 * @param[out] major Major version number. 63 * @param[out] minor Minor version number. 64 * @param[out] patch Patch version number. 65 65 */ 66 66 … … 79 79 80 80 /** The version directive data. */ 81 typedef struct {81 typedef struct yaml_version_directive_s { 82 82 /** The major version number. */ 83 83 int major; … … 87 87 88 88 /** The tag directive data. */ 89 typedef struct {89 typedef struct yaml_tag_directive_s { 90 90 /** The tag handle. */ 91 91 yaml_char_t *handle; … … 95 95 96 96 /** The stream encoding. */ 97 typedef enum {97 typedef enum yaml_encoding_e { 98 98 YAML_ANY_ENCODING, 99 99 YAML_UTF8_ENCODING, … … 104 104 /** Line break types. */ 105 105 106 typedef enum {106 typedef enum yaml_break_e { 107 107 YAML_ANY_BREAK, 108 108 YAML_CR_BREAK, … … 112 112 113 113 /** Many bad things could happen with the parser and emitter. */ 114 typedef enum {114 typedef enum yaml_error_type_e { 115 115 YAML_NO_ERROR, 116 116 … … 120 120 YAML_SCANNER_ERROR, 121 121 YAML_PARSER_ERROR, 122 YAML_COMPOSER_ERROR, 122 123 123 124 YAML_WRITER_ERROR, … … 126 127 127 128 /** The pointer position. */ 128 typedef struct {129 typedef struct yaml_mark_s { 129 130 /** The position index. */ 130 131 size_t index; … … 145 146 146 147 /** Scalar styles. */ 147 typedef enum {148 typedef enum yaml_scalar_style_e { 148 149 YAML_ANY_SCALAR_STYLE, 149 150 … … 158 159 159 160 /** Sequence styles. */ 160 typedef enum {161 typedef enum yaml_sequence_style_e { 161 162 YAML_ANY_SEQUENCE_STYLE, 162 163 … … 166 167 167 168 /** Mapping styles. */ 168 typedef enum {169 typedef enum yaml_mapping_style_e { 169 170 YAML_ANY_MAPPING_STYLE, 170 171 … … 182 183 183 184 /** Token types. */ 184 typedef enum {185 typedef enum yaml_token_type_e { 185 186 YAML_NO_TOKEN, 186 187 … … 214 215 215 216 /** The token structure. */ 216 typedef struct {217 typedef struct yaml_token_s { 217 218 218 219 /** The token type. */ … … 300 301 301 302 /** Event types. */ 302 typedef enum {303 typedef enum yaml_event_type_e { 303 304 YAML_NO_EVENT, 304 305 … … 320 321 321 322 /** The event structure. */ 322 typedef struct {323 typedef struct yaml_event_s { 323 324 324 325 /** The event type. */ … … 417 418 * Create the STREAM-START event. 418 419 * 419 * @param[out] event An empty event object.420 * @param[in] encoding The stream encoding.420 * @param[out] event An empty event object. 421 * @param[in] encoding The stream encoding. 421 422 * 422 423 * @returns @c 1 if the function succeeded, @c 0 on error. … … 430 431 * Create the STREAM-END event. 431 432 * 432 * @param[out] event An empty event object.433 * @param[out] event An empty event object. 433 434 * 434 435 * @returns @c 1 if the function succeeded, @c 0 on error. … … 444 445 * ignored by the emitter. 445 446 * 446 * @param[out] event An empty event object. 447 * @param[in] version_directive The %YAML directive value or @c NULL. 448 * @param[in] tag_directives_start The beginning of the %TAG directives list. 449 * @param[in] tag_directives_end The end of the %TAG directives list. 450 * @param[in] implicit If the document start indicator is implicit. 447 * @param[out] event An empty event object. 448 * @param[in] version_directive The %YAML directive value or 449 * @c NULL. 450 * @param[in] tag_directives_start The beginning of the %TAG 451 * directives list. 452 * @param[in] tag_directives_end The end of the %TAG directives 453 * list. 454 * @param[in] implicit If the document start indicator is 455 * implicit. 451 456 * 452 457 * @returns @c 1 if the function succeeded, @c 0 on error. … … 466 471 * ignored by the emitter. 467 472 * 468 * @param[out] event An empty event object.469 * @param[in] implicit If the document end indicator is implicit.473 * @param[out] event An empty event object. 474 * @param[in] implicit If the document end indicator is implicit. 470 475 * 471 476 * @returns @c 1 if the function succeeded, @c 0 on error. … … 478 483 * Create an ALIAS event. 479 484 * 480 * @param[out] event An empty event object.481 * @param[in] anchor The anchor value.485 * @param[out] event An empty event object. 486 * @param[in] anchor The anchor value. 482 487 * 483 488 * @returns @c 1 if the function succeeded, @c 0 on error. … … 495 500 * @a quoted_implicit flags must be set. 496 501 * 497 * @param[out] event An empty event object. 498 * @param[in] anchor The scalar anchor or @c NULL. 499 * @param[in] tag The scalar tag or @c NULL. 500 * @param[in] value The scalar value. 501 * @param[in] length The length of the scalar value. 502 * @param[in] plain_implicit If the tag may be omitted for the plain style. 503 * @param[in] quoted_implicit If the tag may be omitted for any non-plain style. 504 * @param[in] style The scalar style. 502 * @param[out] event An empty event object. 503 * @param[in] anchor The scalar anchor or @c NULL. 504 * @param[in] tag The scalar tag or @c NULL. 505 * @param[in] value The scalar value. 506 * @param[in] length The length of the scalar value. 507 * @param[in] plain_implicit If the tag may be omitted for the plain 508 * style. 509 * @param[in] quoted_implicit If the tag may be omitted for any 510 * non-plain style. 511 * @param[in] style The scalar style. 505 512 * 506 513 * @returns @c 1 if the function succeeded, @c 0 on error. … … 521 528 * Either the @a tag attribute or the @a implicit flag must be set. 522 529 * 523 * @param[out] event An empty event object.524 * @param[in] anchor The sequence anchor or @c NULL.525 * @param[in] tag The sequence tag or @c NULL.526 * @param[in] implicit If the tag may be omitted.527 * @param[in] style The sequence style.530 * @param[out] event An empty event object. 531 * @param[in] anchor The sequence anchor or @c NULL. 532 * @param[in] tag The sequence tag or @c NULL. 533 * @param[in] implicit If the tag may be omitted. 534 * @param[in] style The sequence style. 528 535 * 529 536 * @returns @c 1 if the function succeeded, @c 0 on error. … … 538 545 * Create a SEQUENCE-END event. 539 546 * 540 * @param[out] event An empty event object.547 * @param[out] event An empty event object. 541 548 * 542 549 * @returns @c 1 if the function succeeded, @c 0 on error. … … 553 560 * Either the @a tag attribute or the @a implicit flag must be set. 554 561 * 555 * @param[out] event An empty event object.556 * @param[in] anchor The mapping anchor or @c NULL.557 * @param[in] tag The mapping tag or @c NULL.558 * @param[in] implicit If the tag may be omitted.559 * @param[in] style The mapping style.562 * @param[out] event An empty event object. 563 * @param[in] anchor The mapping anchor or @c NULL. 564 * @param[in] tag The mapping tag or @c NULL. 565 * @param[in] implicit If the tag may be omitted. 566 * @param[in] style The mapping style. 560 567 * 561 568 * @returns @c 1 if the function succeeded, @c 0 on error. … … 570 577 * Create a MAPPING-END event. 571 578 * 572 * @param[out] event An empty event object.579 * @param[out] event An empty event object. 573 580 * 574 581 * @returns @c 1 if the function succeeded, @c 0 on error. … … 581 588 * Free any memory allocated for an event object. 582 589 * 583 * @param[ out]event An event object.590 * @param[in,out] event An event object. 584 591 */ 585 592 … … 604 611 #define YAML_DEFAULT_SCALAR_TAG YAML_STR_TAG 605 612 #define YAML_DEFAULT_SEQUENCE_TAG YAML_SEQ_TAG 606 #define YAML_DEFAULT_MAPPING_ STYLEYAML_MAP_TAG613 #define YAML_DEFAULT_MAPPING_TAG YAML_MAP_TAG 607 614 608 615 /** Node types. */ 609 typedef enum {616 typedef enum yaml_node_type_e { 610 617 YAML_NO_NODE, 611 618 … … 615 622 } yaml_node_type_t; 616 623 617 #if 0 618 619 typedef struct _yaml_node_t yaml_node_item_t; 620 621 typedef struct { 622 yaml_node_item_t key; 623 yaml_node_item_t value; 624 /** The forward definition of a document node structure. */ 625 typedef struct yaml_node_s yaml_node_t; 626 627 /** An element of a sequence node. */ 628 typedef int yaml_node_item_t; 629 630 /** An element of a mapping node. */ 631 typedef struct yaml_node_pair_s { 632 /** The key of the element. */ 633 int key; 634 /** The value of the element. */ 635 int value; 624 636 } yaml_node_pair_t; 625 637 626 638 /** The node structure. */ 627 typedef struct _yaml_node_t{639 struct yaml_node_s { 628 640 629 641 /** The node type. */ 630 642 yaml_node_type_t type; 631 643 632 /* The reference counter. */633 int references;644 /** The node tag. */ 645 yaml_char_t *tag; 634 646 635 647 /** The node data. */ … … 638 650 /** The scalar parameters (for @c YAML_SCALAR_NODE). */ 639 651 struct { 640 /** The tag. */641 yaml_char_t *tag;642 652 /** The scalar value. */ 643 653 yaml_char_t *value; … … 650 660 /** The sequence parameters (for @c YAML_SEQUENCE_NODE). */ 651 661 struct { 652 /** The tag. */653 yaml_char_t *tag;654 662 /** The stack of sequence items. */ 655 663 struct { 656 664 /** The beginning of the stack. */ 657 structyaml_node_item_t *start;665 yaml_node_item_t *start; 658 666 /** The end of the stack. */ 659 structyaml_node_item_t *end;667 yaml_node_item_t *end; 660 668 /** The top of the stack. */ 661 structyaml_node_item_t *top;669 yaml_node_item_t *top; 662 670 } items; 663 671 /** The sequence style. */ … … 667 675 /** The mapping parameters (for @c YAML_MAPPING_NODE). */ 668 676 struct { 669 /** The tag. */ 670 yaml_char_t *tag; 671 /** The stack of mapping pairs. */ 677 /** The stack of mapping pairs (key, value). */ 672 678 struct { 673 679 /** The beginning of the stack. */ 674 structyaml_node_pair_t *start;680 yaml_node_pair_t *start; 675 681 /** The end of the stack. */ 676 structyaml_node_pair_t *end;682 yaml_node_pair_t *end; 677 683 /** The top of the stack. */ 678 structyaml_node_pair_t *top;684 yaml_node_pair_t *top; 679 685 } pairs; 680 686 /** The mapping style. */ … … 689 695 yaml_mark_t end_mark; 690 696 691 } yaml_node_t; 692 693 /** 694 * Create a SCALAR node. 697 }; 698 699 /** The document structure. */ 700 typedef struct yaml_document_s { 701 702 /** The document nodes. */ 703 struct { 704 /** The beginning of the stack. */ 705 yaml_node_t *start; 706 /** The end of the stack. */ 707 yaml_node_t *end; 708 /** The top of the stack. */ 709 yaml_node_t *top; 710 } nodes; 711 712 /** The version directive. */ 713 yaml_version_directive_t *version_directive; 714 715 /** The list of tag directives. */ 716 struct { 717 /** The beginning of the tag directives list. */ 718 yaml_tag_directive_t *start; 719 /** The end of the tag directives list. */ 720 yaml_tag_directive_t *end; 721 } tag_directives; 722 723 /** Is the document start indicator implicit? */ 724 int start_implicit; 725 /** Is the document end indicator implicit? */ 726 int end_implicit; 727 728 /** The beginning of the document. */ 729 yaml_mark_t start_mark; 730 /** The end of the document. */ 731 yaml_mark_t end_mark; 732 733 } yaml_document_t; 734 735 /** 736 * Create a YAML document. 737 * 738 * @param[out] document An empty document object. 739 * @param[in] version_directive The %YAML directive value or 740 * @c NULL. 741 * @param[in] tag_directives_start The beginning of the %TAG 742 * directives list. 743 * @param[in] tag_directives_end The end of the %TAG directives 744 * list. 745 * @param[in] start_implicit If the document start indicator is 746 * implicit. 747 * @param[in] end_implicit If the document end indicator is 748 * implicit. 749 * 750 * @returns @c 1 if the function succeeded, @c 0 on error. 751 */ 752 753 YAML_DECLARE(int) 754 yaml_document_initialize(yaml_document_t *document, 755 yaml_version_directive_t *version_directive, 756 yaml_tag_directive_t *tag_directives_start, 757 yaml_tag_directive_t *tag_directives_end, 758 int start_implicit, int end_implicit); 759 760 /** 761 * Delete a YAML document and all its nodes. 762 * 763 * @param[in,out] document A document object. 764 */ 765 766 YAML_DECLARE(void) 767 yaml_document_delete(yaml_document_t *document); 768 769 /** 770 * Get a node of a YAML document. 771 * 772 * The pointer returned by this function is valid until any of the functions 773 * modifying the documents are called. 774 * 775 * @param[in] document A document object. 776 * @param[in] node The node id. 777 * 778 * @returns the node objct or @c NULL if @c node_id is out of range. 779 */ 780 781 YAML_DECLARE(yaml_node_t *) 782 yaml_document_get_node(yaml_document_t *document, int node_id); 783 784 /** 785 * Get the root of a YAML document node. 786 * 787 * The root object is the first object added to the document. 788 * 789 * The pointer returned by this function is valid until any of the functions 790 * modifying the documents are called. 791 * 792 * An empty document produced by the parser signifies the end of a YAML 793 * stream. 794 * 795 * @param[in] document A document object. 796 * 797 * @returns the node object or @c NULL if the document is empty. 798 */ 799 800 YAML_DECLARE(yaml_node_t *) 801 yaml_document_get_root_node(yaml_document_t *document); 802 803 /** 804 * Create a SCALAR node and attach it to the document. 695 805 * 696 806 * The @a style argument may be ignored by the emitter. 697 807 * 698 * @param[ out] node An empty nodeobject.699 * @param[in] tag The scalar tag.700 * @param[in] value The scalar value.701 * @param[in] length The length of the scalar value.702 * @param[in] style The scalar style.703 * 704 * @returns @c 1 if the function succeeded,@c 0 on error.705 */ 706 707 YAML_DECLARE(int) 708 yaml_ scalar_node_initialize(yaml_node_t *node,808 * @param[in,out] document A document object. 809 * @param[in] tag The scalar tag. 810 * @param[in] value The scalar value. 811 * @param[in] length The length of the scalar value. 812 * @param[in] style The scalar style. 813 * 814 * @returns the node id or @c 0 on error. 815 */ 816 817 YAML_DECLARE(int) 818 yaml_document_add_scalar(yaml_document_t *document, 709 819 yaml_char_t *tag, yaml_char_t *value, int length, 710 820 yaml_scalar_style_t style); 711 821 712 822 /** 713 * Create a SEQUENCE node .823 * Create a SEQUENCE node and attach it to the document. 714 824 * 715 825 * The @a style argument may be ignored by the emitter. 716 826 * 717 * @param[ out] node An empty nodeobject.718 * @param[in] tag The sequence tag.719 * @param[in] style The sequence style.720 * 721 * @returns @c 1 if the function succeeded,@c 0 on error.722 */ 723 724 YAML_DECLARE(int) 725 yaml_ sequence_node_initialize(yaml_node_t *node,827 * @param[in,out] document A document object. 828 * @param[in] tag The sequence tag. 829 * @param[in] style The sequence style. 830 * 831 * @returns the node id or @c 0 on error. 832 */ 833 834 YAML_DECLARE(int) 835 yaml_document_add_sequence(yaml_document_t *document, 726 836 yaml_char_t *tag, yaml_sequence_style_t style); 727 837 728 838 /** 729 * Add an item to a SEQUENCE node 730 * 731 * @param[out] node A sequence node. 732 * @param[in] item An item node. 839 * Create a MAPPING node and attach it to the document. 840 * 841 * The @a style argument may be ignored by the emitter. 842 * 843 * @param[in,out] document A document object. 844 * @param[in] tag The sequence tag. 845 * @param[in] style The sequence style. 846 * 847 * @returns the node id or @c 0 on error. 848 */ 849 850 YAML_DECLARE(int) 851 yaml_document_add_mapping(yaml_document_t *document, 852 yaml_char_t *tag, yaml_mapping_style_t style); 853 854 /** 855 * Add an item to a SEQUENCE node. 856 * 857 * @param[in,out] document A document object. 858 * @param[in] sequence The sequence node id. 859 * @param[in] item The item node id. 733 860 * 734 861 * @returns @c 1 if the function succeeded, @c 0 on error. … … 736 863 737 864 YAML_DECLARE(int) 738 yaml_sequence_node_add_item(yaml_node_t *node, yaml_node_t *item) 739 740 /** 741 * Create a SCALAR node and add it to a SEQUENCE node. 742 * 743 * @param[out] node A sequence node. 744 * @param[in] tag The scalar tag. 745 * @param[in] value The scalar value. 746 * @param[in] length The length of the scalar value. 747 * @param[in] style The scalar style. 748 * 749 * @returns @c 1 if the function succeeded, @c 0 on error. 750 */ 751 752 YAML_DECLARE(int) 753 yaml_sequence_node_add_scalar_item(yaml_node_t *node, 754 yaml_char_t *tag, yaml_char_t *value, int length, 755 yaml_scalar_style_t style); 756 757 /** 758 * Get the number of subnodes of a SEQUENCE node. 759 * 760 * @param[in] node A sequence node. 761 * 762 * @returns the number of subnodes. 763 */ 764 765 YAML_DECLARE(size_t) 766 yaml_sequence_node_get_length(yaml_node_t *node); 767 768 /** 769 * Get a subnode of a SEQUENCE node. 770 * 771 * @param[in] node A sequence node. 772 * @param[in] index The index of a subnode. 773 * @param[out] item A subnode. 774 */ 775 776 YAML_DECLARE(void) 777 yaml_sequence_node_get_item(yaml_node_t *node, size_t index, 778 yaml_node_t *item); 779 780 /** 781 * Create a MAPPING node. 782 * 783 * The @a style argument may be ignored by the emitter. 784 * 785 * @param[out] node An empty node object. 786 * @param[in] tag The mapping tag. 787 * @param[in] style The mapping style. 788 * 789 * @returns @c 1 if the function succeeded, @c 0 on error. 790 */ 791 792 YAML_DECLARE(int) 793 yaml_mapping_node_initialize(yaml_node_t *node, 794 yaml_char_t *tag, yaml_mapping_style_t style); 795 796 /** 797 * Add a key/value pair of nodes to a MAPPING node. 798 * 799 * @param[out] node A mapping node. 800 * @param[in] key A key node. 801 * @param[in] value A value node. 802 * 803 * @returns @c 1 if the function succeeded, @c 0 on error. 804 */ 805 806 YAML_DECLARE(int) 807 yaml_mapping_node_add_pair(yaml_node_t *node, 808 yaml_node_t *key, yaml_node_t *value) 809 810 /** 811 * Create a scalar key and add the key/value pair to a MAPPING node. 812 * 813 * @param[out] node A mapping node. 814 * @param[in] key_tag The key node tag. 815 * @param[in] key_value The key node value. 816 * @param[in] key_length The length of the key node value. 817 * @param[in] key_style The key node style. 818 * @param[in] value A value node. 819 * 820 * @returns @c 1 if the function succeeded, @c 0 on error. 821 */ 822 823 YAML_DECLARE(int) 824 yaml_sequence_node_add_scalar_key_pair(yaml_node_t *node, 825 yaml_char_t *key_tag, yaml_char_t *key_value, int key_length, 826 yaml_scalar_style_t key_style, 827 yaml_node_t *value); 828 829 /** 830 * Create a scalar key/value nodes and add the pair to a MAPPING node. 831 * 832 * @param[out] node A mapping node. 833 * @param[in] key_tag The key node tag. 834 * @param[in] key_value The key node value. 835 * @param[in] key_length The length of the key node value. 836 * @param[in] key_style The key node style. 837 * @param[in] value_tag The value node tag. 838 * @param[in] value_value The value node value. 839 * @param[in] value_length The length of the value node value. 840 * @param[in] value_style The value node style. 841 * 842 * @returns @c 1 if the function succeeded, @c 0 on error. 843 */ 844 845 YAML_DECLARE(int) 846 yaml_sequence_node_add_scalar_pair(yaml_node_t *node, 847 yaml_char_t *key_tag, yaml_char_t *key_value, int key_length, 848 yaml_scalar_style_t key_style, 849 yaml_char_t *value_tag, yaml_char_t *value_value, int value_length, 850 yaml_scalar_style_t value_style); 851 852 /** 853 * Get the number of subnode pairs of a MAPPING node. 854 * 855 * @param[in] node A mapping node. 856 * 857 * @returns the number of pairs. 858 */ 859 860 YAML_DECLARE(size_t) 861 yaml_mapping_node_get_length(yaml_node_t *node); 862 863 /** 864 * Get a subnode of a SEQUENCE node. 865 * 866 * @param[in] node A sequence node. 867 * @param[in] index The index of a subnode. 868 * @param[out] key The key subnode. 869 * @param[out] value The value subnode. 870 */ 871 872 YAML_DECLARE(void) 873 yaml_mapping_node_get_pair(yaml_node_t *node, size_t index, 874 yaml_node_t *key, yaml_node_t *value); 875 876 /** 877 * Delete a node and its subnodes. 878 * 879 * @param[out] node A node object. 880 */ 881 882 YAML_DECLARE(void) 883 yaml_node_delete(yaml_node_t *node); 884 885 #endif 865 yaml_document_append_sequence_item(yaml_document_t *document, 866 int sequence, int item); 867 868 /** 869 * Add a pair of a key and a value to a MAPPING node. 870 * 871 * @param[in,out] document A document object. 872 * @param[in] mapping The mapping node id. 873 * @param[in] key The key node id. 874 * @param[in] value The value node id. 875 * 876 * @returns @c 1 if the function succeeded, @c 0 on error. 877 */ 878 879 YAML_DECLARE(int) 880 yaml_document_append_mapping_pair(yaml_document_t *document, 881 int mapping, int key, int value); 886 882 887 883 /** @} */ … … 917 913 */ 918 914 919 typedef struct {915 typedef struct yaml_simple_key_s { 920 916 /** Is a simple key possible? */ 921 917 int possible; … … 934 930 * The states of the parser. 935 931 */ 936 typedef enum {932 typedef enum yaml_parser_state_e { 937 933 YAML_PARSE_STREAM_START_STATE, 938 934 YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE, … … 962 958 963 959 /** 960 * This structure holds aliases data. 961 */ 962 963 typedef struct yaml_alias_data_s { 964 /** The anchor. */ 965 yaml_char_t *anchor; 966 /** The node id. */ 967 int index; 968 /** The anchor mark. */ 969 yaml_mark_t mark; 970 } yaml_alias_data_t; 971 972 /** 964 973 * The parser structure. 965 974 * … … 968 977 */ 969 978 970 typedef struct {979 typedef struct yaml_parser_s { 971 980 972 981 /** … … 1168 1177 */ 1169 1178 1179 /** 1180 * @name Dumper stuff 1181 * @{ 1182 */ 1183 1184 /** The alias data. */ 1185 struct { 1186 /** The beginning of the list. */ 1187 yaml_alias_data_t *start; 1188 /** The end of the list. */ 1189 yaml_alias_data_t *end; 1190 /** The top of the list. */ 1191 yaml_alias_data_t *top; 1192 } aliases; 1193 1194 /** The currently parsed document. */ 1195 yaml_document_t *document; 1196 1197 /** 1198 * @} 1199 */ 1200 1170 1201 } yaml_parser_t; 1171 1202 … … 1176 1207 * for destroying the object using the yaml_parser_delete() function. 1177 1208 * 1178 * @param[out] parser An empty parser object.1209 * @param[out] parser An empty parser object. 1179 1210 * 1180 1211 * @returns @c 1 if the function succeeded, @c 0 on error. … … 1257 1288 * 1258 1289 * An application must not alternate the calls of yaml_parser_scan() with the 1259 * calls of yaml_parser_parse(). Doing this will break the parser. 1290 * calls of yaml_parser_parse() or yaml_parser_load(). Doing this will break 1291 * the parser. 1260 1292 * 1261 1293 * @param[in,out] parser A parser object. … … 1279 1311 * produced event object using the yaml_event_delete() function. 1280 1312 * 1281 * An application must not alternate the calls of yaml_parser_scan() with the 1282 * calls of yaml_parser_parse(). Doing this will break the parser. 1313 * An application must not alternate the calls of yaml_parser_parse() with the 1314 * calls of yaml_parser_scan() or yaml_parser_load(). Doing this will break the 1315 * parser. 1283 1316 * 1284 1317 * @param[in,out] parser A parser object. … … 1290 1323 YAML_DECLARE(int) 1291 1324 yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event); 1325 1326 /** 1327 * Parse the input stream and produce the next YAML document. 1328 * 1329 * Call this function subsequently to produce a sequence of documents 1330 * constituting the input stream. 1331 * 1332 * If the produced document has no root node, it means that the document 1333 * end has been reached. 1334 * 1335 * An application is responsible for freeing any data associated with the 1336 * produced document object using the yaml_document_delete() function. 1337 * 1338 * An application must not alternate the calls of yaml_parser_load() with the 1339 * calls of yaml_parser_scan() or yaml_parser_parse(). Doing this will break 1340 * the parser. 1341 * 1342 * @param[in,out] parser A parser object. 1343 * @param[out] document An empty document object. 1344 * 1345 * @return @c 1 if the function succeeded, @c 0 on error. 1346 */ 1347 1348 YAML_DECLARE(int) 1349 yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document); 1292 1350 1293 1351 /** @} */ … … 1317 1375 1318 1376 /** The emitter states. */ 1319 typedef enum {1377 typedef enum yaml_emitter_state_e { 1320 1378 YAML_EMIT_STREAM_START_STATE, 1321 1379 YAML_EMIT_FIRST_DOCUMENT_START_STATE, … … 1345 1403 */ 1346 1404 1347 typedef struct {1405 typedef struct yaml_emitter_s { 1348 1406 1349 1407 /** … … 1550 1608 */ 1551 1609 1610 /** 1611 * @name Dumper stuff 1612 * @{ 1613 */ 1614 1615 /** If the stream was already opened? */ 1616 int opened; 1617 /** If the stream was already closed? */ 1618 int closed; 1619 1620 /** The information associated with the document nodes. */ 1621 struct { 1622 /** The number of references. */ 1623 int references; 1624 /** The anchor id. */ 1625 int anchor; 1626 /** If the node has been emitted? */ 1627 int serialized; 1628 } *anchors; 1629 1630 /** The last assigned anchor id. */ 1631 int last_anchor_id; 1632 1633 /** The currently emitted document. */ 1634 yaml_document_t *document; 1635 1636 /** 1637 * @} 1638 */ 1639 1552 1640 } yaml_emitter_t; 1553 1641 … … 1698 1786 yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event); 1699 1787 1788 /* 1789 * Start a YAML stream. 1790 * 1791 * This function should be used before yaml_emitter_dump() is called. 1792 * 1793 * @param[in,out] emitter An emitter object. 1794 * 1795 * @returns @c 1 if the function succeeded, @c 0 on error. 1796 */ 1797 1798 YAML_DECLARE(int) 1799 yaml_emitter_open(yaml_emitter_t *emitter); 1800 1801 /* 1802 * Finish a YAML stream. 1803 * 1804 * This function should be used after yaml_emitter_dump() is called. 1805 * 1806 * @param[in,out] emitter An emitter object. 1807 * 1808 * @returns @c 1 if the function succeeded, @c 0 on error. 1809 */ 1810 1811 YAML_DECLARE(int) 1812 yaml_emitter_close(yaml_emitter_t *emitter); 1813 1814 /* 1815 * Emit a YAML document. 1816 * 1817 * The documen object may be generated using the yaml_parser_load() function 1818 * or the yaml_document_initialize() function. The emitter takes the 1819 * responsibility for the document object and destoys its content after 1820 * it is emitted. The document object is destroyedeven if the function fails. 1821 * 1822 * @param[in,out] emitter An emitter object. 1823 * @param[in,out] document A document object. 1824 * 1825 * @returns @c 1 if the function succeeded, @c 0 on error. 1826 */ 1827 1828 YAML_DECLARE(int) 1829 yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document); 1830 1700 1831 /** 1701 1832 * Flush the accumulated characters to the output. -
libyaml/trunk/src/Makefile.am
r219 r238 1 1 AM_CPPFLAGS = -I$(top_srcdir)/include 2 2 lib_LTLIBRARIES = libyaml.la 3 libyaml_la_SOURCES = yaml_private.h api.c reader.c scanner.c parser.c writer.c emitter.c3 libyaml_la_SOURCES = yaml_private.h api.c reader.c scanner.c parser.c loader.c writer.c emitter.c dumper.c 4 4 libyaml_la_LDFLAGS = -release $(YAML_LT_RELEASE) -version-info $(YAML_LT_CURRENT):$(YAML_LT_REVISION):$(YAML_LT_AGE) -
libyaml/trunk/src/api.c
r237 r238 400 400 } 401 401 STACK_DEL(emitter, emitter->tag_directives); 402 yaml_free(emitter->anchors); 402 403 403 404 memset(emitter, 0, sizeof(yaml_emitter_t)); … … 1020 1021 } 1021 1022 1022 #if 0 1023 1024 /* 1025 * Create a SCALAR node. 1026 */ 1027 1028 YAML_DECLARE(int) 1029 yaml_scalar_node_initialize(yaml_node_t *node, 1023 /* 1024 * Create a document object. 1025 */ 1026 1027 YAML_DECLARE(int) 1028 yaml_document_initialize(yaml_document_t *document, 1029 yaml_version_directive_t *version_directive, 1030 yaml_tag_directive_t *tag_directives_start, 1031 yaml_tag_directive_t *tag_directives_end, 1032 int start_implicit, int end_implicit) 1033 { 1034 struct { 1035 yaml_error_type_t error; 1036 } context; 1037 struct { 1038 yaml_node_t *start; 1039 yaml_node_t *end; 1040 yaml_node_t *top; 1041 } nodes = { NULL, NULL, NULL }; 1042 yaml_version_directive_t *version_directive_copy = NULL; 1043 struct { 1044 yaml_tag_directive_t *start; 1045 yaml_tag_directive_t *end; 1046 yaml_tag_directive_t *top; 1047 } tag_directives_copy = { NULL, NULL, NULL }; 1048 yaml_tag_directive_t value = { NULL, NULL }; 1049 yaml_mark_t mark = { 0, 0, 0 }; 1050 1051 assert(document); /* Non-NULL document object is expected. */ 1052 assert((tag_directives_start && tag_directives_end) || 1053 (tag_directives_start == tag_directives_end)); 1054 /* Valid tag directives are expected. */ 1055 1056 if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error; 1057 1058 if (version_directive) { 1059 version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t)); 1060 if (!version_directive_copy) goto error; 1061 version_directive_copy->major = version_directive->major; 1062 version_directive_copy->minor = version_directive->minor; 1063 } 1064 1065 if (tag_directives_start != tag_directives_end) { 1066 yaml_tag_directive_t *tag_directive; 1067 if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE)) 1068 goto error; 1069 for (tag_directive = tag_directives_start; 1070 tag_directive != tag_directives_end; tag_directive ++) { 1071 assert(tag_directive->handle); 1072 assert(tag_directive->prefix); 1073 if (!yaml_check_utf8(tag_directive->handle, 1074 strlen((char *)tag_directive->handle))) 1075 goto error; 1076 if (!yaml_check_utf8(tag_directive->prefix, 1077 strlen((char *)tag_directive->prefix))) 1078 goto error; 1079 value.handle = yaml_strdup(tag_directive->handle); 1080 value.prefix = yaml_strdup(tag_directive->prefix); 1081 if (!value.handle || !value.prefix) goto error; 1082 if (!PUSH(&context, tag_directives_copy, value)) 1083 goto error; 1084 value.handle = NULL; 1085 value.prefix = NULL; 1086 } 1087 } 1088 1089 DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy, 1090 tag_directives_copy.start, tag_directives_copy.top, 1091 start_implicit, end_implicit, mark, mark); 1092 1093 return 1; 1094 1095 error: 1096 STACK_DEL(&context, nodes); 1097 yaml_free(version_directive_copy); 1098 while (!STACK_EMPTY(&context, tag_directives_copy)) { 1099 yaml_tag_directive_t value = POP(&context, tag_directives_copy); 1100 yaml_free(value.handle); 1101 yaml_free(value.prefix); 1102 } 1103 STACK_DEL(&context, tag_directives_copy); 1104 yaml_free(value.handle); 1105 yaml_free(value.prefix); 1106 1107 return 0; 1108 } 1109 1110 /* 1111 * Destroy a document object. 1112 */ 1113 1114 YAML_DECLARE(void) 1115 yaml_document_delete(yaml_document_t *document) 1116 { 1117 struct { 1118 yaml_error_type_t error; 1119 } context; 1120 yaml_tag_directive_t *tag_directive; 1121 1122 assert(document); /* Non-NULL document object is expected. */ 1123 1124 while (!STACK_EMPTY(&context, document->nodes)) { 1125 yaml_node_t node = POP(&context, document->nodes); 1126 yaml_free(node.tag); 1127 switch (node.type) { 1128 case YAML_SCALAR_NODE: 1129 yaml_free(node.data.scalar.value); 1130 break; 1131 case YAML_SEQUENCE_NODE: 1132 STACK_DEL(&context, node.data.sequence.items); 1133 break; 1134 case YAML_MAPPING_NODE: 1135 STACK_DEL(&context, node.data.mapping.pairs); 1136 break; 1137 default: 1138 assert(0); /* Should not happen. */ 1139 } 1140 } 1141 STACK_DEL(&context, document->nodes); 1142 1143 yaml_free(document->version_directive); 1144 for (tag_directive = document->tag_directives.start; 1145 tag_directive != document->tag_directives.end; 1146 tag_directive++) { 1147 yaml_free(tag_directive->handle); 1148 yaml_free(tag_directive->prefix); 1149 } 1150 yaml_free(document->tag_directives.start); 1151 1152 memset(document, 0, sizeof(yaml_document_t)); 1153 } 1154 1155 /** 1156 * Get a document node. 1157 */ 1158 1159 YAML_DECLARE(yaml_node_t *) 1160 yaml_document_get_node(yaml_document_t *document, int node) 1161 { 1162 assert(document); /* Non-NULL document object is expected. */ 1163 1164 if (node > 0 && document->nodes.start + node <= document->nodes.top) { 1165 return document->nodes.start + node - 1; 1166 } 1167 return NULL; 1168 } 1169 1170 /** 1171 * Get the root object. 1172 */ 1173 1174 YAML_DECLARE(yaml_node_t *) 1175 yaml_document_get_root_node(yaml_document_t *document) 1176 { 1177 assert(document); /* Non-NULL document object is expected. */ 1178 1179 if (document->nodes.top != document->nodes.start) { 1180 return document->nodes.start; 1181 } 1182 return NULL; 1183 } 1184 1185 /* 1186 * Add a scalar node to a document. 1187 */ 1188 1189 YAML_DECLARE(int) 1190 yaml_document_add_scalar(yaml_document_t *document, 1030 1191 yaml_char_t *tag, yaml_char_t *value, int length, 1031 1192 yaml_scalar_style_t style) 1032 1193 { 1194 struct { 1195 yaml_error_type_t error; 1196 } context; 1033 1197 yaml_mark_t mark = { 0, 0, 0 }; 1034 1198 yaml_char_t *tag_copy = NULL; 1035 1199 yaml_char_t *value_copy = NULL; 1036 1037 assert(node); /* Non-NULL node object is expected. */ 1038 assert(value); /* Non-NULL anchor is expected. */ 1200 yaml_node_t node; 1201 1202 assert(document); /* Non-NULL document object is expected. */ 1203 assert(value); /* Non-NULL value is expected. */ 1039 1204 1040 1205 if (!tag) { … … 1056 1221 value_copy[length] = '\0'; 1057 1222 1058 SCALAR_NODE_INIT(*node, tag_copy, value_copy, length, style, mark, mark); 1059 1060 return 1; 1223 SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark); 1224 if (!PUSH(&context, document->nodes, node)) goto error; 1225 1226 return document->nodes.top - document->nodes.start; 1061 1227 1062 1228 error: … … 1068 1234 1069 1235 /* 1070 * Create a SEQUENCE node.1071 */ 1072 1073 YAML_DECLARE(int) 1074 yaml_ sequence_node_initialize(yaml_node_t *node,1236 * Add a sequence node to a document. 1237 */ 1238 1239 YAML_DECLARE(int) 1240 yaml_document_add_sequence(yaml_document_t *document, 1075 1241 yaml_char_t *tag, yaml_sequence_style_t style) 1076 1242 { … … 1085 1251 yaml_node_item_t *top; 1086 1252 } items = { NULL, NULL, NULL }; 1087 1088 assert(node); /* Non-NULL node object is expected. */ 1253 yaml_node_t node; 1254 1255 assert(document); /* Non-NULL document object is expected. */ 1089 1256 1090 1257 if (!tag) { … … 1092 1259 } 1093 1260 1094 if (tag) { 1095 if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error; 1096 tag_copy = yaml_strdup(tag); 1097 if (!tag_copy) goto error; 1098 } 1099 1100 if (!STACK_INIT(context, items, INITIAL_STACK_SIZE)) goto error; 1101 1102 SEQUENCE_NODE_INIT(*node, tag_copy, items.start, item.end, style, 1103 mark, mark); 1104 1105 return 1; 1261 if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error; 1262 tag_copy = yaml_strdup(tag); 1263 if (!tag_copy) goto error; 1264 1265 if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error; 1266 1267 SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end, 1268 style, mark, mark); 1269 if (!PUSH(&context, document->nodes, node)) goto error; 1270 1271 return document->nodes.top - document->nodes.start; 1106 1272 1107 1273 error: 1274 STACK_DEL(&context, items); 1108 1275 yaml_free(tag_copy); 1109 STACK_DEL(context, items);1110 1276 1111 1277 return 0; … … 1113 1279 1114 1280 /* 1115 * Create a MAPPING node.1116 */ 1117 1118 YAML_DECLARE(int) 1119 yaml_ mapping_node_initialize(yaml_node_t *node,1281 * Add a mapping node to a document. 1282 */ 1283 1284 YAML_DECLARE(int) 1285 yaml_document_add_mapping(yaml_document_t *document, 1120 1286 yaml_char_t *tag, yaml_mapping_style_t style) 1121 1287 { … … 1130 1296 yaml_node_pair_t *top; 1131 1297 } pairs = { NULL, NULL, NULL }; 1132 1133 assert(node); /* Non-NULL node object is expected. */ 1298 yaml_node_t node; 1299 1300 assert(document); /* Non-NULL document object is expected. */ 1134 1301 1135 1302 if (!tag) { … … 1137 1304 } 1138 1305 1139 if (tag) { 1140 if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error; 1141 tag_copy = yaml_strdup(tag); 1142 if (!tag_copy) goto error; 1143 } 1144 1145 if (!STACK_INIT(context, pairs, INITIAL_STACK_SIZE)) goto error; 1146 1147 MAPPING_NODE_INIT(*node, tag_copy, pairs.start, pairs.end, style, 1148 mark, mark); 1149 1150 return 1; 1306 if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error; 1307 tag_copy = yaml_strdup(tag); 1308 if (!tag_copy) goto error; 1309 1310 if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error; 1311 1312 MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end, 1313 style, mark, mark); 1314 if (!PUSH(&context, document->nodes, node)) goto error; 1315 1316 return document->nodes.top - document->nodes.start; 1151 1317 1152 1318 error: 1319 STACK_DEL(&context, pairs); 1153 1320 yaml_free(tag_copy); 1154 STACK_DEL(context, pairs);1155 1321 1156 1322 return 0; … … 1158 1324 1159 1325 /* 1160 * Delete a node and its subnodes. 1161 */ 1162 1163 YAML_DECLARE(void) 1164 yaml_node_delete(yaml_node_t *node) 1326 * Append an item to a sequence node. 1327 */ 1328 1329 YAML_DECLARE(int) 1330 yaml_document_append_sequence_item(yaml_document_t *document, 1331 int sequence, int item) 1165 1332 { 1166 1333 struct { 1167 1334 yaml_error_type_t error; 1168 1335 } context; 1336 1337 assert(document); /* Non-NULL document is required. */ 1338 assert(sequence > 0 1339 && document->nodes.start + sequence <= document->nodes.top); 1340 /* Valid sequence id is required. */ 1341 assert(document->nodes.start[sequence-1].type == YAML_SEQUENCE_NODE); 1342 /* A sequence node is required. */ 1343 assert(item > 0 && document->nodes.start + item <= document->nodes.top); 1344 /* Valid item id is required. */ 1345 1346 if (!PUSH(&context, 1347 document->nodes.start[sequence-1].data.sequence.items, item)) 1348 return 0; 1349 1350 return 1; 1351 } 1352 1353 /* 1354 * Append a pair of a key and a value to a mapping node. 1355 */ 1356 1357 YAML_DECLARE(int) 1358 yaml_document_append_mapping_pair(yaml_document_t *document, 1359 int mapping, int key, int value) 1360 { 1169 1361 struct { 1170 yaml_node_item_t *start; 1171 yaml_node_item_t *end; 1172 yaml_node_item_t *head; 1173 yaml_node_item_t *tail; 1174 } queue = { NULL, NULL, NULL, NULL }; 1175 1176 assert(node); /* Non-NULL node object is expected. */ 1177 1178 if (node->type == YAML_SCALAR_NODE) { 1179 yaml_free(node->data.scalar.tag); 1180 yaml_free(node->data.scalar.value); 1181 memset(node, 0, sizeof(yaml_node_t)); 1182 return; 1183 } 1184 1185 if (!QUEUE_INIT(context, queue, INITIAL_QUEUE_SIZE)) goto error; 1186 if (!ENQUEUE(context, queue, node)) goto error; 1187 1188 while (!QUEUE_EMPTY(context, queue)) { 1189 yaml_node_t node = DEQUEUE(context, queue); 1190 if (node.type == YAML_SCALAR_NODE) { 1191 if (!node->reference) 1192 } 1193 if (node->type == YAML_SEQUENCE_NODE) { 1194 while (!STACK_EMPTY(context, node->data.sequence.items)) { 1195 yaml_node_t *item = 1196 } 1197 } 1198 } 1199 } 1200 1201 #endif 1202 1362 yaml_error_type_t error; 1363 } context; 1364 yaml_node_pair_t pair = { key, value }; 1365 1366 assert(document); /* Non-NULL document is required. */ 1367 assert(mapping > 0 1368 && document->nodes.start + mapping <= document->nodes.top); 1369 /* Valid mapping id is required. */ 1370 assert(document->nodes.start[mapping-1].type == YAML_MAPPING_NODE); 1371 /* A mapping node is required. */ 1372 assert(key > 0 && document->nodes.start + key <= document->nodes.top); 1373 /* Valid key id is required. */ 1374 assert(value > 0 && document->nodes.start + value <= document->nodes.top); 1375 /* Valid value id is required. */ 1376 1377 if (!PUSH(&context, 1378 document->nodes.start[mapping-1].data.mapping.pairs, pair)) 1379 return 0; 1380 1381 return 1; 1382 } 1383 -
libyaml/trunk/src/emitter.c
r216 r238 1161 1161 { 1162 1162 yaml_scalar_style_t style = event->data.scalar.style; 1163 int no_tag = (!emitter->tag_data.handle && !emitter->tag_data.suffix); 1164 1165 if (no_tag && !event->data.scalar.plain_implicit 1166 && !event->data.scalar.quoted_implicit) { 1167 return yaml_emitter_set_emitter_error(emitter, 1168 "neither tag nor implicit flags are specified"); 1169 } 1163 1170 1164 1171 if (style == YAML_ANY_SCALAR_STYLE) … … 1179 1186 && (emitter->flow_level || emitter->simple_key_context)) 1180 1187 style = YAML_SINGLE_QUOTED_SCALAR_STYLE; 1181 if (!event->data.scalar.plain_implicit 1182 && !emitter->tag_data.handle && !emitter->tag_data.suffix) 1188 if (no_tag && !event->data.scalar.plain_implicit) 1183 1189 style = YAML_SINGLE_QUOTED_SCALAR_STYLE; 1184 1190 } … … 1197 1203 } 1198 1204 1199 if (!emitter->tag_data.handle && !emitter->tag_data.suffix) 1200 { 1201 if (!event->data.scalar.plain_implicit 1202 && !event->data.scalar.quoted_implicit) { 1203 return yaml_emitter_set_emitter_error(emitter, 1204 "neither tag nor implicit flags are specified"); 1205 } 1206 1207 if (event->data.scalar.plain_implicit 1208 && style != YAML_PLAIN_SCALAR_STYLE) { 1209 emitter->tag_data.handle = (yaml_char_t *)"!"; 1210 emitter->tag_data.handle_length = 1; 1211 } 1205 if (no_tag && !event->data.scalar.quoted_implicit 1206 && style != YAML_PLAIN_SCALAR_STYLE) 1207 { 1208 emitter->tag_data.handle = (yaml_char_t *)"!"; 1209 emitter->tag_data.handle_length = 1; 1212 1210 } 1213 1211 -
libyaml/trunk/src/yaml_private.h
r237 r238 581 581 582 582 /* 583 * Document initializer. 584 */ 585 586 #define DOCUMENT_INIT(document,document_nodes_start,document_nodes_end, \ 587 document_version_directive,document_tag_directives_start, \ 588 document_tag_directives_end,document_start_implicit, \ 589 document_end_implicit,start_mark,end_mark) \ 590 (memset(&(document), 0, sizeof(yaml_document_t)), \ 591 (document).nodes.start = (document_nodes_start), \ 592 (document).nodes.end = (document_nodes_end), \ 593 (document).nodes.top = (document_nodes_start), \ 594 (document).version_directive = (document_version_directive), \ 595 (document).tag_directives.start = (document_tag_directives_start), \ 596 (document).tag_directives.end = (document_tag_directives_end), \ 597 (document).start_implicit = (document_start_implicit), \ 598 (document).end_implicit = (document_end_implicit)) 599 600 /* 583 601 * Node initializers. 584 602 */ 585 603 586 #define NODE_INIT(node,node_type,node_ start_mark,node_end_mark)\604 #define NODE_INIT(node,node_type,node_tag,node_start_mark,node_end_mark) \ 587 605 (memset(&(node), 0, sizeof(yaml_node_t)), \ 588 606 (node).type = (node_type), \ 607 (node).tag = (node_tag), \ 589 608 (node).start_mark = (node_start_mark), \ 590 609 (node).end_mark = (node_end_mark)) … … 592 611 #define SCALAR_NODE_INIT(node,node_tag,node_value,node_length, \ 593 612 node_style,start_mark,end_mark) \ 594 (EVENT_INIT((node),YAML_SCALAR_NODE,(start_mark),(end_mark)), \ 595 (node).data.scalar.tag = (node_tag), \ 613 (NODE_INIT((node),YAML_SCALAR_NODE,(node_tag),(start_mark),(end_mark)), \ 596 614 (node).data.scalar.value = (node_value), \ 597 615 (node).data.scalar.length = (node_length), \ … … 600 618 #define SEQUENCE_NODE_INIT(node,node_tag,node_items_start,node_items_end, \ 601 619 node_style,start_mark,end_mark) \ 602 (NODE_INIT((node),YAML_SEQUENCE_NODE,(start_mark),(end_mark)), \ 603 (node).data.sequence.tag = (node_tag), \ 620 (NODE_INIT((node),YAML_SEQUENCE_NODE,(node_tag),(start_mark),(end_mark)), \ 604 621 (node).data.sequence.items.start = (node_items_start), \ 605 622 (node).data.sequence.items.end = (node_items_end), \ … … 609 626 #define MAPPING_NODE_INIT(node,node_tag,node_pairs_start,node_pairs_end, \ 610 627 node_style,start_mark,end_mark) \ 611 (NODE_INIT((node),YAML_MAPPING_NODE,(start_mark),(end_mark)), \ 612 (node).data.mapping.tag = (node_tag), \ 628 (NODE_INIT((node),YAML_MAPPING_NODE,(node_tag),(start_mark),(end_mark)), \ 613 629 (node).data.mapping.pairs.start = (node_pairs_start), \ 614 630 (node).data.mapping.pairs.end = (node_pairs_end), \ -
libyaml/trunk/tests/Makefile.am
r224 r238 4 4 TESTS = test-version test-reader 5 5 check_PROGRAMS = test-version test-reader 6 noinst_PROGRAMS = run-scanner run-parser run-emitter example-reformatter example-deconstructor 6 noinst_PROGRAMS = run-scanner run-parser run-loader run-emitter run-dumper \ 7 example-reformatter example-reformatter-alt \ 8 example-deconstructor example-deconstructor-alt -
libyaml/trunk/tests/example-deconstructor-alt.c
r220 r238 17 17 yaml_emitter_t emitter; 18 18 yaml_event_t input_event; 19 yaml_event_t output_event; 19 yaml_document_t output_document; 20 21 int root; 20 22 21 23 /* Clear the objects. */ … … 24 26 memset(&emitter, 0, sizeof(emitter)); 25 27 memset(&input_event, 0, sizeof(input_event)); 26 memset(&output_ event, 0, sizeof(output_event));28 memset(&output_document, 0, sizeof(output_document)); 27 29 28 30 /* Analyze command line options. */ … … 92 94 /* Create and emit the STREAM-START event. */ 93 95 94 if (!yaml_stream_start_event_initialize(&output_event, YAML_UTF8_ENCODING)) 95 goto event_error; 96 if (!yaml_emitter_emit(&emitter, &output_event)) 96 if (!yaml_emitter_open(&emitter)) 97 97 goto emitter_error; 98 98 99 /* Create and emit the DOCUMENT-START event. */ 100 101 if (!yaml_document_start_event_initialize(&output_event, 102 NULL, NULL, NULL, 0)) 103 goto event_error; 104 if (!yaml_emitter_emit(&emitter, &output_event)) 105 goto emitter_error; 106 107 /* Create and emit the SEQUENCE-START event. */ 108 109 if (!yaml_sequence_start_event_initialize(&output_event, 110 NULL, "tag:yaml.org,2002:seq", 1, 111 YAML_BLOCK_SEQUENCE_STYLE)) 112 goto event_error; 113 if (!yaml_emitter_emit(&emitter, &output_event)) 114 goto emitter_error; 99 /* Create a output_document object. */ 100 101 if (!yaml_document_initialize(&output_document, NULL, NULL, NULL, 0, 0)) 102 goto document_error; 103 104 /* Create the root sequence. */ 105 106 root = yaml_document_add_sequence(&output_document, NULL, 107 YAML_BLOCK_SEQUENCE_STYLE); 108 if (!root) goto document_error; 115 109 116 110 /* Loop through the input events. */ … … 118 112 while (!done) 119 113 { 114 int properties, key, value, map, seq; 115 120 116 /* Get the next event. */ 121 117 … … 129 125 } 130 126 131 /* Create and emit a MAPPING-START event. */ 132 133 if (!yaml_mapping_start_event_initialize(&output_event, 134 NULL, "tag:yaml.org,2002:map", 1, 135 YAML_BLOCK_MAPPING_STYLE)) 136 goto event_error; 137 if (!yaml_emitter_emit(&emitter, &output_event)) 138 goto emitter_error; 127 /* Create a mapping node and attach it to the root sequence. */ 128 129 properties = yaml_document_add_mapping(&output_document, NULL, 130 YAML_BLOCK_MAPPING_STYLE); 131 if (!properties) goto document_error; 132 if (!yaml_document_append_sequence_item(&output_document, 133 root, properties)) goto document_error; 139 134 140 135 /* Analyze the event. */ … … 144 139 case YAML_STREAM_START_EVENT: 145 140 146 /* Write 'type'. */ 147 148 if (!yaml_scalar_event_initialize(&output_event, 149 NULL, "tag:yaml.org,2002:str", "type", -1, 150 1, 1, YAML_PLAIN_SCALAR_STYLE)) 151 goto event_error; 152 if (!yaml_emitter_emit(&emitter, &output_event)) 153 goto emitter_error; 154 155 /* Write 'STREAM-START'. */ 156 157 if (!yaml_scalar_event_initialize(&output_event, 158 NULL, "tag:yaml.org,2002:str", "STREAM-START", -1, 159 1, 1, YAML_PLAIN_SCALAR_STYLE)) 160 goto event_error; 161 if (!yaml_emitter_emit(&emitter, &output_event)) 162 goto emitter_error; 163 164 /* Display encoding information. */ 141 /* Add 'type': 'STREAM-START'. */ 142 143 key = yaml_document_add_scalar(&output_document, NULL, 144 "type", -1, YAML_PLAIN_SCALAR_STYLE); 145 if (!key) goto document_error; 146 value = yaml_document_add_scalar(&output_document, NULL, 147 "STREAM-START", -1, YAML_PLAIN_SCALAR_STYLE); 148 if (!value) goto document_error; 149 if (!yaml_document_append_mapping_pair(&output_document, 150 properties, key, value)) goto document_error; 151 152 /* Add 'encoding': <encoding>. */ 165 153 166 154 if (input_event.data.stream_start.encoding) … … 169 157 = input_event.data.stream_start.encoding; 170 158 171 /* Write 'encoding'. */ 172 173 if (!yaml_scalar_event_initialize(&output_event, 174 NULL, "tag:yaml.org,2002:str", "encoding", -1, 175 1, 1, YAML_PLAIN_SCALAR_STYLE)) 176 goto event_error; 177 if (!yaml_emitter_emit(&emitter, &output_event)) 178 goto emitter_error; 179 180 /* Write the stream encoding. */ 181 182 if (!yaml_scalar_event_initialize(&output_event, 183 NULL, "tag:yaml.org,2002:str", 184 (encoding == YAML_UTF8_ENCODING ? "utf-8" : 185 encoding == YAML_UTF16LE_ENCODING ? "utf-16-le" : 186 encoding == YAML_UTF16BE_ENCODING ? "utf-16-be" : 187 "unknown"), -1, 188 1, 1, YAML_PLAIN_SCALAR_STYLE)) 189 goto event_error; 190 if (!yaml_emitter_emit(&emitter, &output_event)) 191 goto emitter_error; 192 } 193 159 key = yaml_document_add_scalar(&output_document, NULL, 160 "encoding", -1, YAML_PLAIN_SCALAR_STYLE); 161 if (!key) goto document_error; 162 value = yaml_document_add_scalar(&output_document, NULL, 163 (encoding == YAML_UTF8_ENCODING ? "utf-8" : 164 encoding == YAML_UTF16LE_ENCODING ? "utf-16-le" : 165 encoding == YAML_UTF16BE_ENCODING ? "utf-16-be" : 166 "unknown"), -1, YAML_PLAIN_SCALAR_STYLE); 167 if (!value) goto document_error; 168 if (!yaml_document_append_mapping_pair(&output_document, 169 properties, key, value)) goto document_error; 170 } 171 194 172 break; 195 173 196 174 case YAML_STREAM_END_EVENT: 197 175 198 /* Write 'type'. */ 199 200 if (!yaml_scalar_event_initialize(&output_event, 201 NULL, "tag:yaml.org,2002:str", "type", -1, 202 1, 1, YAML_PLAIN_SCALAR_STYLE)) 203 goto event_error; 204 if (!yaml_emitter_emit(&emitter, &output_event)) 205 goto emitter_error; 206 207 /* Write 'STREAM-END'. */ 208 209 if (!yaml_scalar_event_initialize(&output_event, 210 NULL, "tag:yaml.org,2002:str", "STREAM-END", -1, 211 1, 1, YAML_PLAIN_SCALAR_STYLE)) 212 goto event_error; 213 if (!yaml_emitter_emit(&emitter, &output_event)) 214 goto emitter_error; 176 /* Add 'type': 'STREAM-END'. */ 177 178 key = yaml_document_add_scalar(&output_document, NULL, 179 "type", -1, YAML_PLAIN_SCALAR_STYLE); 180 if (!key) goto document_error; 181 value = yaml_document_add_scalar(&output_document, NULL, 182 "STREAM-END", -1, YAML_PLAIN_SCALAR_STYLE); 183 if (!value) goto document_error; 184 if (!yaml_document_append_mapping_pair(&output_document, 185 properties, key, value)) goto document_error; 215 186 216 187 break; … … 218 189 case YAML_DOCUMENT_START_EVENT: 219 190 220 /* Write 'type'. */ 221 222 if (!yaml_scalar_event_initialize(&output_event, 223 NULL, "tag:yaml.org,2002:str", "type", -1, 224 1, 1, YAML_PLAIN_SCALAR_STYLE)) 225 goto event_error; 226 if (!yaml_emitter_emit(&emitter, &output_event)) 227 goto emitter_error; 228 229 /* Write 'DOCUMENT-START'. */ 230 231 if (!yaml_scalar_event_initialize(&output_event, 232 NULL, "tag:yaml.org,2002:str", "DOCUMENT-START", -1, 233 1, 1, YAML_PLAIN_SCALAR_STYLE)) 234 goto event_error; 235 if (!yaml_emitter_emit(&emitter, &output_event)) 236 goto emitter_error; 237 238 /* Display the document version numbers. */ 191 /* Add 'type': 'DOCUMENT-START'. */ 192 193 key = yaml_document_add_scalar(&output_document, NULL, 194 "type", -1, YAML_PLAIN_SCALAR_STYLE); 195 if (!key) goto document_error; 196 value = yaml_document_add_scalar(&output_document, NULL, 197 "DOCUMENT-START", -1, YAML_PLAIN_SCALAR_STYLE); 198 if (!value) goto document_error; 199 if (!yaml_document_append_mapping_pair(&output_document, 200 properties, key, value)) goto document_error; 201 202 /* Display the output_document version numbers. */ 239 203 240 204 if (input_event.data.document_start.version_directive) … … 244 208 char number[64]; 245 209 246 /* Write 'version'. */210 /* Add 'version': {}. */ 247 211 248 if (!yaml_scalar_event_initialize(&output_event, 249 NULL, "tag:yaml.org,2002:str", "version", -1, 250 1, 1, YAML_PLAIN_SCALAR_STYLE)) 251 goto event_error; 252 if (!yaml_emitter_emit(&emitter, &output_event)) 253 goto emitter_error; 254 255 /* Write '{'. */ 256 257 if (!yaml_mapping_start_event_initialize(&output_event, 258 NULL, "tag:yaml.org,2002:map", 1, 259 YAML_FLOW_MAPPING_STYLE)) 260 goto event_error; 261 if (!yaml_emitter_emit(&emitter, &output_event)) 262 goto emitter_error; 263 264 /* Write 'major'. */ 265 266 if (!yaml_scalar_event_initialize(&output_event, 267 NULL, "tag:yaml.org,2002:str", "major", -1, 268 1, 1, YAML_PLAIN_SCALAR_STYLE)) 269 goto event_error; 270 if (!yaml_emitter_emit(&emitter, &output_event)) 271 goto emitter_error; 272 273 /* Write a number. */ 274 212 key = yaml_document_add_scalar(&output_document, NULL, 213 "version", -1, YAML_PLAIN_SCALAR_STYLE); 214 if (!key) goto document_error; 215 map = yaml_document_add_mapping(&output_document, NULL, 216 YAML_FLOW_MAPPING_STYLE); 217 if (!map) goto document_error; 218 if (!yaml_document_append_mapping_pair(&output_document, 219 properties, key, map)) goto document_error; 220 221 /* Add 'major': <number>. */ 222 223 key = yaml_document_add_scalar(&output_document, NULL, 224 "major", -1, YAML_PLAIN_SCALAR_STYLE); 225 if (!key) goto document_error; 275 226 sprintf(number, "%d", version->major); 276 if (!yaml_scalar_event_initialize(&output_event, 277 NULL, "tag:yaml.org,2002:int", number, -1, 278 1, 1, YAML_PLAIN_SCALAR_STYLE)) 279 goto event_error; 280 if (!yaml_emitter_emit(&emitter, &output_event)) 281 goto emitter_error; 282 283 /* Write 'minor'. */ 284 285 if (!yaml_scalar_event_initialize(&output_event, 286 NULL, "tag:yaml.org,2002:str", "minor", -1, 287 1, 1, YAML_PLAIN_SCALAR_STYLE)) 288 goto event_error; 289 if (!yaml_emitter_emit(&emitter, &output_event)) 290 goto emitter_error; 291 292 /* Write a number. */ 293 227 value = yaml_document_add_scalar(&output_document, YAML_INT_TAG, 228 number, -1, YAML_PLAIN_SCALAR_STYLE); 229 if (!value) goto document_error; 230 if (!yaml_document_append_mapping_pair(&output_document, 231 map, key, value)) goto document_error; 232 233 /* Add 'minor': <number>. */ 234 235 key = yaml_document_add_scalar(&output_document, NULL, 236 "minor", -1, YAML_PLAIN_SCALAR_STYLE); 237 if (!key) goto document_error; 294 238 sprintf(number, "%d", version->minor); 295 if (!yaml_scalar_event_initialize(&output_event, 296 NULL, "tag:yaml.org,2002:int", number, -1, 297 1, 1, YAML_PLAIN_SCALAR_STYLE)) 298 goto event_error; 299 if (!yaml_emitter_emit(&emitter, &output_event)) 300 goto emitter_error; 301 302 /* Write '}'. */ 303 304 if (!yaml_mapping_end_event_initialize(&output_event)) 305 goto event_error; 306 if (!yaml_emitter_emit(&emitter, &output_event)) 307 goto emitter_error; 308 } 309 310 /* Display the document tag directives. */ 239 value = yaml_document_add_scalar(&output_document, YAML_INT_TAG, 240 number, -1, YAML_PLAIN_SCALAR_STYLE); 241 if (!value) goto document_error; 242 if (!yaml_document_append_mapping_pair(&output_document, 243 map, key, value)) goto document_error; 244 } 245 246 /* Display the output_document tag directives. */ 311 247 312 248 if (input_event.data.document_start.tag_directives.start … … 315 251 yaml_tag_directive_t *tag; 316 252 317 /* Write 'tags'. */253 /* Add 'tags': []. */ 318 254 319 if (!yaml_scalar_event_initialize(&output_event, 320 NULL, "tag:yaml.org,2002:str", "tags", -1, 321 1, 1, YAML_PLAIN_SCALAR_STYLE)) 322 goto event_error; 323 if (!yaml_emitter_emit(&emitter, &output_event)) 324 goto emitter_error; 325 326 /* Start a block sequence. */ 327 328 if (!yaml_sequence_start_event_initialize(&output_event, 329 NULL, "tag:yaml.org,2002:seq", 1, 330 YAML_BLOCK_SEQUENCE_STYLE)) 331 goto event_error; 332 if (!yaml_emitter_emit(&emitter, &output_event)) 333 goto emitter_error; 255 key = yaml_document_add_scalar(&output_document, NULL, 256 "tags", -1, YAML_PLAIN_SCALAR_STYLE); 257 if (!key) goto document_error; 258 seq = yaml_document_add_sequence(&output_document, NULL, 259 YAML_BLOCK_SEQUENCE_STYLE); 260 if (!seq) goto document_error; 261 if (!yaml_document_append_mapping_pair(&output_document, 262 properties, key, seq)) goto document_error; 334 263 335 264 for (tag = input_event.data.document_start.tag_directives.start; … … 337 266 tag ++) 338 267 { 339 /* Write '{'. */ 340 341 if (!yaml_mapping_start_event_initialize(&output_event, 342 NULL, "tag:yaml.org,2002:map", 1, 343 YAML_FLOW_MAPPING_STYLE)) 344 goto event_error; 345 if (!yaml_emitter_emit(&emitter, &output_event)) 346 goto emitter_error; 347 348 /* Write 'handle'. */ 349 350 if (!yaml_scalar_event_initialize(&output_event, 351 NULL, "tag:yaml.org,2002:str", "handle", -1, 352 1, 1, YAML_PLAIN_SCALAR_STYLE)) 353 goto event_error; 354 if (!yaml_emitter_emit(&emitter, &output_event)) 355 goto emitter_error; 356 357 /* Write the tag directive handle. */ 358 359 if (!yaml_scalar_event_initialize(&output_event, 360 NULL, "tag:yaml.org,2002:str", 361 tag->handle, -1, 362 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) 363 goto event_error; 364 if (!yaml_emitter_emit(&emitter, &output_event)) 365 goto emitter_error; 366 367 /* Write 'prefix'. */ 368 369 if (!yaml_scalar_event_initialize(&output_event, 370 NULL, "tag:yaml.org,2002:str", "prefix", -1, 371 1, 1, YAML_PLAIN_SCALAR_STYLE)) 372 goto event_error; 373 if (!yaml_emitter_emit(&emitter, &output_event)) 374 goto emitter_error; 375 376 /* Write the tag directive prefix. */ 377 378 if (!yaml_scalar_event_initialize(&output_event, 379 NULL, "tag:yaml.org,2002:str", 380 tag->prefix, -1, 381 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) 382 goto event_error; 383 if (!yaml_emitter_emit(&emitter, &output_event)) 384 goto emitter_error; 385 386 /* Write '}'. */ 387 388 if (!yaml_mapping_end_event_initialize(&output_event)) 389 goto event_error; 390 if (!yaml_emitter_emit(&emitter, &output_event)) 391 goto emitter_error; 392 } 393 394 /* End a block sequence. */ 395 396 if (!yaml_sequence_end_event_initialize(&output_event)) 397 goto event_error; 398 if (!yaml_emitter_emit(&emitter, &output_event)) 399 goto emitter_error; 400 } 401 402 /* Write 'implicit'. */ 403 404 if (!yaml_scalar_event_initialize(&output_event, 405 NULL, "tag:yaml.org,2002:str", "implicit", -1, 406 1, 1, YAML_PLAIN_SCALAR_STYLE)) 407 goto event_error; 408 if (!yaml_emitter_emit(&emitter, &output_event)) 409 goto emitter_error; 410 411 /* Write if the document is implicit. */ 412 413 if (!yaml_scalar_event_initialize(&output_event, 414 NULL, "tag:yaml.org,2002:bool", 415 (input_event.data.document_start.implicit ? 416 "true" : "false"), -1, 417 1, 0, YAML_PLAIN_SCALAR_STYLE)) 418 goto event_error; 419 if (!yaml_emitter_emit(&emitter, &output_event)) 420 goto emitter_error; 268 /* Add {}. */ 269 270 map = yaml_document_add_mapping(&output_document, NULL, 271 YAML_FLOW_MAPPING_STYLE); 272 if (!map) goto document_error; 273 if (!yaml_document_append_sequence_item(&output_document, 274 seq, map)) goto document_error; 275 276 /* Add 'handle': <handle>. */ 277 278 key = yaml_document_add_scalar(&output_document, NULL, 279 "handle", -1, YAML_PLAIN_SCALAR_STYLE); 280 if (!key) goto document_error; 281 value = yaml_document_add_scalar(&output_document, NULL, 282 tag->handle, -1, YAML_DOUBLE_QUOTED_SCALAR_STYLE); 283 if (!value) goto document_error; 284 if (!yaml_document_append_mapping_pair(&output_document, 285 map, key, value)) goto document_error; 286 287 /* Add 'prefix': <prefix>. */ 288 289 key = yaml_document_add_scalar(&output_document, NULL, 290 "prefix", -1, YAML_PLAIN_SCALAR_STYLE); 291 if (!key) goto document_error; 292 value = yaml_document_add_scalar(&output_document, NULL, 293 tag->prefix, -1, YAML_DOUBLE_QUOTED_SCALAR_STYLE); 294 if (!value) goto document_error; 295 if (!yaml_document_append_mapping_pair(&output_document, 296 map, key, value)) goto document_error; 297 } 298 } 299 300 /* Add 'implicit': <flag>. */ 301 302 key = yaml_document_add_scalar(&output_document, NULL, 303 "implicit", -1, YAML_PLAIN_SCALAR_STYLE); 304 if (!key) goto document_error; 305 value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, 306 (input_event.data.document_start.implicit ? 307 "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); 308 if (!value) goto document_error; 309 if (!yaml_document_append_mapping_pair(&output_document, 310 properties, key, value)) goto document_error; 421 311 422 312 break; … … 424 314 case YAML_DOCUMENT_END_EVENT: 425 315 426 /* Write 'type'. */ 427 428 if (!yaml_scalar_event_initialize(&output_event, 429 NULL, "tag:yaml.org,2002:str", "type", -1, 430 1, 1, YAML_PLAIN_SCALAR_STYLE)) 431 goto event_error; 432 if (!yaml_emitter_emit(&emitter, &output_event)) 433 goto emitter_error; 434 435 /* Write 'DOCUMENT-END'. */ 436 437 if (!yaml_scalar_event_initialize(&output_event, 438 NULL, "tag:yaml.org,2002:str", "DOCUMENT-END", -1, 439 1, 1, YAML_PLAIN_SCALAR_STYLE)) 440 goto event_error; 441 if (!yaml_emitter_emit(&emitter, &output_event)) 442 goto emitter_error; 443 444 /* Write 'implicit'. */ 445 446 if (!yaml_scalar_event_initialize(&output_event, 447 NULL, "tag:yaml.org,2002:str", "implicit", -1, 448 1, 1, YAML_PLAIN_SCALAR_STYLE)) 449 goto event_error; 450 if (!yaml_emitter_emit(&emitter, &output_event)) 451 goto emitter_error; 452 453 /* Write if the document is implicit. */ 454 455 if (!yaml_scalar_event_initialize(&output_event, 456 NULL, "tag:yaml.org,2002:bool", 457 (input_event.data.document_end.implicit ? 458 "true" : "false"), -1, 459 1, 0, YAML_PLAIN_SCALAR_STYLE)) 460 goto event_error; 461 if (!yaml_emitter_emit(&emitter, &output_event)) 462 goto emitter_error; 316 /* Add 'type': 'DOCUMENT-END'. */ 317 318 key = yaml_document_add_scalar(&output_document, NULL, 319 "type", -1, YAML_PLAIN_SCALAR_STYLE); 320 if (!key) goto document_error; 321 value = yaml_document_add_scalar(&output_document, NULL, 322 "DOCUMENT-END", -1, YAML_PLAIN_SCALAR_STYLE); 323 if (!value) goto document_error; 324 if (!yaml_document_append_mapping_pair(&output_document, 325 properties, key, value)) goto document_error; 326 327 /* Add 'implicit': <flag>. */ 328 329 key = yaml_document_add_scalar(&output_document, NULL, 330 "implicit", -1, YAML_PLAIN_SCALAR_STYLE); 331 if (!key) goto document_error; 332 value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, 333 (input_event.data.document_end.implicit ? 334 "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); 335 if (!value) goto document_error; 336 if (!yaml_document_append_mapping_pair(&output_document, 337 properties, key, value)) goto document_error; 463 338 464 339 break; … … 466 341 case YAML_ALIAS_EVENT: 467 342 468 /* Write 'type'. */ 469 470 if (!yaml_scalar_event_initialize(&output_event, 471 NULL, "tag:yaml.org,2002:str", "type", -1, 472 1, 1, YAML_PLAIN_SCALAR_STYLE)) 473 goto event_error; 474 if (!yaml_emitter_emit(&emitter, &output_event)) 475 goto emitter_error; 476 477 /* Write 'ALIAS'. */ 478 479 if (!yaml_scalar_event_initialize(&output_event, 480 NULL, "tag:yaml.org,2002:str", "ALIAS", -1, 481 1, 1, YAML_PLAIN_SCALAR_STYLE)) 482 goto event_error; 483 if (!yaml_emitter_emit(&emitter, &output_event)) 484 goto emitter_error; 485 486 /* Write 'anchor'. */ 487 488 if (!yaml_scalar_event_initialize(&output_event, 489 NULL, "tag:yaml.org,2002:str", "anchor", -1, 490 1, 1, YAML_PLAIN_SCALAR_STYLE)) 491 goto event_error; 492 if (!yaml_emitter_emit(&emitter, &output_event)) 493 goto emitter_error; 494 495 /* Write the alias anchor. */ 496 497 if (!yaml_scalar_event_initialize(&output_event, 498 NULL, "tag:yaml.org,2002:str", 499 input_event.data.alias.anchor, -1, 500 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) 501 goto event_error; 502 if (!yaml_emitter_emit(&emitter, &output_event)) 503 goto emitter_error; 343 /* Add 'type': 'ALIAS'. */ 344 345 key = yaml_document_add_scalar(&output_document, NULL, 346 "type", -1, YAML_PLAIN_SCALAR_STYLE); 347 if (!key) goto document_error; 348 value = yaml_document_add_scalar(&output_document, NULL, 349 "ALIAS", -1, YAML_PLAIN_SCALAR_STYLE); 350 if (!value) goto document_error; 351 if (!yaml_document_append_mapping_pair(&output_document, 352 properties, key, value)) goto document_error; 353 354 /* Add 'anchor': <anchor>. */ 355 356 key = yaml_document_add_scalar(&output_document, NULL, 357 "anchor", -1, YAML_PLAIN_SCALAR_STYLE); 358 if (!key) goto document_error; 359 value = yaml_document_add_scalar(&output_document, NULL, 360 input_event.data.alias.anchor, -1, 361 YAML_DOUBLE_QUOTED_SCALAR_STYLE); 362 if (!value) goto document_error; 363 if (!yaml_document_append_mapping_pair(&output_document, 364 properties, key, value)) goto document_error; 504 365 505 366 break; … … 507 368 case YAML_SCALAR_EVENT: 508 369 509 /* Write 'type'. */ 510 511 if (!yaml_scalar_event_initialize(&output_event, 512 NULL, "tag:yaml.org,2002:str", "type", -1, 513 1, 1, YAML_PLAIN_SCALAR_STYLE)) 514 goto event_error; 515 if (!yaml_emitter_emit(&emitter, &output_event)) 516 goto emitter_error; 517 518 /* Write 'SCALAR'. */ 519 520 if (!yaml_scalar_event_initialize(&output_event, 521 NULL, "tag:yaml.org,2002:str", "SCALAR", -1, 522 1, 1, YAML_PLAIN_SCALAR_STYLE)) 523 goto event_error; 524 if (!yaml_emitter_emit(&emitter, &output_event)) 525 goto emitter_error; 526 527 /* Display the scalar anchor. */ 370 /* Add 'type': 'SCALAR'. */ 371 372 key = yaml_document_add_scalar(&output_document, NULL, 373 "type", -1, YAML_PLAIN_SCALAR_STYLE); 374 if (!key) goto document_error; 375 value = yaml_document_add_scalar(&output_document, NULL, 376 "SCALAR", -1, YAML_PLAIN_SCALAR_STYLE); 377 if (!value) goto document_error; 378 if (!yaml_document_append_mapping_pair(&output_document, 379 properties, key, value)) goto document_error; 380 381 /* Add 'anchor': <anchor>. */ 528 382 529 383 if (input_event.data.scalar.anchor) 530 384 { 531 /* Write 'anchor'. */ 532 533 if (!yaml_scalar_event_initialize(&output_event, 534 NULL, "tag:yaml.org,2002:str", "anchor", -1, 535 1, 1, YAML_PLAIN_SCALAR_STYLE)) 536 goto event_error; 537 if (!yaml_emitter_emit(&emitter, &output_event)) 538 goto emitter_error; 539 540 /* Write the scalar anchor. */ 541 542 if (!yaml_scalar_event_initialize(&output_event, 543 NULL, "tag:yaml.org,2002:str", 544 input_event.data.scalar.anchor, -1, 545 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) 546 goto event_error; 547 if (!yaml_emitter_emit(&emitter, &output_event)) 548 goto emitter_error; 549 } 550 551 /* Display the scalar tag. */ 385 key = yaml_document_add_scalar(&output_document, NULL, 386 "anchor", -1, YAML_PLAIN_SCALAR_STYLE); 387 if (!key) goto document_error; 388 value = yaml_document_add_scalar(&output_document, NULL, 389 input_event.data.scalar.anchor, -1, 390 YAML_DOUBLE_QUOTED_SCALAR_STYLE); 391 if (!value) goto document_error; 392 if (!yaml_document_append_mapping_pair(&output_document, 393 properties, key, value)) goto document_error; 394 } 395 396 /* Add 'tag': <tag>. */ 552 397 553 398 if (input_event.data.scalar.tag) 554 399 { 555 /* Write 'tag'. */ 556 557 if (!yaml_scalar_event_initialize(&output_event, 558 NULL, "tag:yaml.org,2002:str", "tag", -1, 559 1, 1, YAML_PLAIN_SCALAR_STYLE)) 560 goto event_error; 561 if (!yaml_emitter_emit(&emitter, &output_event)) 562 goto emitter_error; 563 564 /* Write the scalar tag. */ 565 566 if (!yaml_scalar_event_initialize(&output_event, 567 NULL, "tag:yaml.org,2002:str", 568 input_event.data.scalar.tag, -1, 569 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) 570 goto event_error; 571 if (!yaml_emitter_emit(&emitter, &output_event)) 572 goto emitter_error; 573 } 574 575 /* Display the scalar value. */ 576 577 /* Write 'value'. */ 578 579 if (!yaml_scalar_event_initialize(&output_event, 580 NULL, "tag:yaml.org,2002:str", "value", -1, 581 1, 1, YAML_PLAIN_SCALAR_STYLE)) 582 goto event_error; 583 if (!yaml_emitter_emit(&emitter, &output_event)) 584 goto emitter_error; 585 586 /* Write the scalar value. */ 587 588 if (!yaml_scalar_event_initialize(&output_event, 589 NULL, "tag:yaml.org,2002:str", 590 input_event.data.scalar.value, 591 input_event.data.scalar.length, 592 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) 593 goto event_error; 594 if (!yaml_emitter_emit(&emitter, &output_event)) 595 goto emitter_error; 400 key = yaml_document_add_scalar(&output_document, NULL, 401 "tag", -1, YAML_PLAIN_SCALAR_STYLE); 402 if (!key) goto document_error; 403 value = yaml_document_add_scalar(&output_document, NULL, 404 input_event.data.scalar.tag, -1, 405 YAML_DOUBLE_QUOTED_SCALAR_STYLE); 406 if (!value) goto document_error; 407 if (!yaml_document_append_mapping_pair(&output_document, 408 properties, key, value)) goto document_error; 409 } 410 411 /* Add 'value': <value>. */ 412 413 key = yaml_document_add_scalar(&output_document, NULL, 414 "value", -1, YAML_PLAIN_SCALAR_STYLE); 415 if (!key) goto document_error; 416 value = yaml_document_add_scalar(&output_document, NULL, 417 input_event.data.scalar.value, 418 input_event.data.scalar.length, 419 YAML_DOUBLE_QUOTED_SCALAR_STYLE); 420 if (!value) goto document_error; 421 if (!yaml_document_append_mapping_pair(&output_document, 422 properties, key, value)) goto document_error; 596 423 597 424 /* Display if the scalar tag is implicit. */ 598 425 599 /* Write 'implicit'. */ 600 601 if (!yaml_scalar_event_initialize(&output_event, 602 NULL, "tag:yaml.org,2002:str", "implicit", -1, 603 1, 1, YAML_PLAIN_SCALAR_STYLE)) 604 goto event_error; 605 if (!yaml_emitter_emit(&emitter, &output_event)) 606 goto emitter_error; 607 608 /* Write '{'. */ 609 610 if (!yaml_mapping_start_event_initialize(&output_event, 611 NULL, "tag:yaml.org,2002:map", 1, 612 YAML_FLOW_MAPPING_STYLE)) 613 goto event_error; 614 if (!yaml_emitter_emit(&emitter, &output_event)) 615 goto emitter_error; 616 617 /* Write 'plain'. */ 618 619 if (!yaml_scalar_event_initialize(&output_event, 620 NULL, "tag:yaml.org,2002:str", "plain", -1, 621 1, 1, YAML_PLAIN_SCALAR_STYLE)) 622 goto event_error; 623 if (!yaml_emitter_emit(&emitter, &output_event)) 624 goto emitter_error; 625 626 /* Write if the scalar is implicit in the plain style. */ 627 628 if (!yaml_scalar_event_initialize(&output_event, 629 NULL, "tag:yaml.org,2002:bool", 630 (input_event.data.scalar.plain_implicit ? 631 "true" : "false"), -1, 632 1, 0, YAML_PLAIN_SCALAR_STYLE)) 633 goto event_error; 634 if (!yaml_emitter_emit(&emitter, &output_event)) 635 goto emitter_error; 636 637 /* Write 'quoted'. */ 638 639 if (!yaml_scalar_event_initialize(&output_event, 640 NULL, "tag:yaml.org,2002:str", "non-plain", -1, 641 1, 1, YAML_PLAIN_SCALAR_STYLE)) 642 goto event_error; 643 if (!yaml_emitter_emit(&emitter, &output_event)) 644 goto emitter_error; 645 646 /* Write if the scalar is implicit in a non-plain style. */ 647 648 if (!yaml_scalar_event_initialize(&output_event, 649 NULL, "tag:yaml.org,2002:bool", 650 (input_event.data.scalar.quoted_implicit ? 651 "true" : "false"), -1, 652 1, 0, YAML_PLAIN_SCALAR_STYLE)) 653 goto event_error; 654 if (!yaml_emitter_emit(&emitter, &output_event)) 655 goto emitter_error; 656 657 /* Write '}'. */ 658 659 if (!yaml_mapping_end_event_initialize(&output_event)) 660 goto event_error; 661 if (!yaml_emitter_emit(&emitter, &output_event)) 662 goto emitter_error; 426 /* Add 'implicit': {} */ 427 428 key = yaml_document_add_scalar(&output_document, NULL, 429 "version", -1, YAML_PLAIN_SCALAR_STYLE); 430 if (!key) goto document_error; 431 map = yaml_document_add_mapping(&output_document, NULL, 432 YAML_FLOW_MAPPING_STYLE); 433 if (!map) goto document_error; 434 if (!yaml_document_append_mapping_pair(&output_document, 435 properties, key, map)) goto document_error; 436 437 /* Add 'plain': <flag>. */ 438 439 key = yaml_document_add_scalar(&output_document, NULL, 440 "plain", -1, YAML_PLAIN_SCALAR_STYLE); 441 if (!key) goto document_error; 442 value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, 443 (input_event.data.scalar.plain_implicit ? 444 "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); 445 if (!value) goto document_error; 446 if (!yaml_document_append_mapping_pair(&output_document, 447 map, key, value)) goto document_error; 448 449 /* Add 'quoted': <flag>. */ 450 451 key = yaml_document_add_scalar(&output_document, NULL, 452 "quoted", -1, YAML_PLAIN_SCALAR_STYLE); 453 if (!key) goto document_error; 454 value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, 455 (input_event.data.scalar.quoted_implicit ? 456 "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); 457 if (!value) goto document_error; 458 if (!yaml_document_append_mapping_pair(&output_document, 459 map, key, value)) goto document_error; 663 460 664 461 /* Display the style information. */ … … 668 465 yaml_scalar_style_t style = input_event.data.scalar.style; 669 466 670 /* Write 'style'. */ 671 672 if (!yaml_scalar_event_initialize(&output_event, 673 NULL, "tag:yaml.org,2002:str", "style", -1, 674 1, 1, YAML_PLAIN_SCALAR_STYLE)) 675 goto event_error; 676 if (!yaml_emitter_emit(&emitter, &output_event)) 677 goto emitter_error; 678 679 /* Write the scalar style. */ 680 681 if (!yaml_scalar_event_initialize(&output_event, 682 NULL, "tag:yaml.org,2002:str", 683 (style == YAML_PLAIN_SCALAR_STYLE ? "plain" : 684 style == YAML_SINGLE_QUOTED_SCALAR_STYLE ? 685 "single-quoted" : 686 style == YAML_DOUBLE_QUOTED_SCALAR_STYLE ? 687 "double-quoted" : 688 style == YAML_LITERAL_SCALAR_STYLE ? "literal" : 689 style == YAML_FOLDED_SCALAR_STYLE ? "folded" : 690 "unknown"), -1, 691 1, 1, YAML_PLAIN_SCALAR_STYLE)) 692 goto event_error; 693 if (!yaml_emitter_emit(&emitter, &output_event)) 694 goto emitter_error; 467 /* Add 'style': <style>. */ 468 469 key = yaml_document_add_scalar(&output_document, NULL, 470 "style", -1, YAML_PLAIN_SCALAR_STYLE); 471 if (!key) goto document_error; 472 value = yaml_document_add_scalar(&output_document, NULL, 473 (style == YAML_PLAIN_SCALAR_STYLE ? "plain" : 474 style == YAML_SINGLE_QUOTED_SCALAR_STYLE ? 475 "single-quoted" : 476 style == YAML_DOUBLE_QUOTED_SCALAR_STYLE ? 477 "double-quoted" : 478 style == YAML_LITERAL_SCALAR_STYLE ? "literal" : 479 style == YAML_FOLDED_SCALAR_STYLE ? "folded" : 480 "unknown"), -1, YAML_PLAIN_SCALAR_STYLE); 481 if (!value) goto document_error; 482 if (!yaml_document_append_mapping_pair(&output_document, 483 properties, key, value)) goto document_error; 695 484 } 696 485 … … 699 488 case YAML_SEQUENCE_START_EVENT: 700 489 701 /* Write 'type'. */ 702 703 if (!yaml_scalar_event_initialize(&output_event, 704 NULL, "tag:yaml.org,2002:str", "type", -1, 705 1, 1, YAML_PLAIN_SCALAR_STYLE)) 706 goto event_error; 707 if (!yaml_emitter_emit(&emitter, &output_event)) 708 goto emitter_error; 709 710 /* Write 'SEQUENCE-START'. */ 711 712 if (!yaml_scalar_event_initialize(&output_event, 713 NULL, "tag:yaml.org,2002:str", "SEQUENCE-START", -1, 714 1, 1, YAML_PLAIN_SCALAR_STYLE)) 715 goto event_error; 716 if (!yaml_emitter_emit(&emitter, &output_event)) 717 goto emitter_error; 718 719 /* Display the sequence anchor. */ 490 /* Add 'type': 'SEQUENCE-START'. */ 491 492 key = yaml_document_add_scalar(&output_document, NULL, 493 "type", -1, YAML_PLAIN_SCALAR_STYLE); 494 if (!key) goto document_error; 495 value = yaml_document_add_scalar(&output_document, NULL, 496 "SEQUENCE-START", -1, YAML_PLAIN_SCALAR_STYLE); 497 if (!value) goto document_error; 498 if (!yaml_document_append_mapping_pair(&output_document, 499 properties, key, value)) goto document_error; 500 501 /* Add 'anchor': <anchor>. */ 720 502 721 503 if (input_event.data.sequence_start.anchor) 722 504 { 723 /* Write 'anchor'. */ 724 725 if (!yaml_scalar_event_initialize(&output_event, 726 NULL, "tag:yaml.org,2002:str", "anchor", -1, 727 1, 1, YAML_PLAIN_SCALAR_STYLE)) 728 goto event_error; 729 if (!yaml_emitter_emit(&emitter, &output_event)) 730 goto emitter_error; 731 732 /* Write the sequence anchor. */ 733 734 if (!yaml_scalar_event_initialize(&output_event, 735 NULL, "tag:yaml.org,2002:str", 736 input_event.data.sequence_start.anchor, -1, 737 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) 738 goto event_error; 739 if (!yaml_emitter_emit(&emitter, &output_event)) 740 goto emitter_error; 741 } 742 743 /* Display the sequence tag. */ 505 key = yaml_document_add_scalar(&output_document, NULL, 506 "anchor", -1, YAML_PLAIN_SCALAR_STYLE); 507 if (!key) goto document_error; 508 value = yaml_document_add_scalar(&output_document, NULL, 509 input_event.data.sequence_start.anchor, -1, 510 YAML_DOUBLE_QUOTED_SCALAR_STYLE); 511 if (!value) goto document_error; 512 if (!yaml_document_append_mapping_pair(&output_document, 513 properties, key, value)) goto document_error; 514 } 515 516 /* Add 'tag': <tag>. */ 744 517 745 518 if (input_event.data.sequence_start.tag) 746 519 { 747 /* Write 'tag'. */ 748 749 if (!yaml_scalar_event_initialize(&output_event, 750 NULL, "tag:yaml.org,2002:str", "tag", -1, 751 1, 1, YAML_PLAIN_SCALAR_STYLE)) 752 goto event_error; 753 if (!yaml_emitter_emit(&emitter, &output_event)) 754 goto emitter_error; 755 756 /* Write the sequence tag. */ 757 758 if (!yaml_scalar_event_initialize(&output_event, 759 NULL, "tag:yaml.org,2002:str", 760 input_event.data.sequence_start.tag, -1, 761 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE)) 762 goto event_error; 763 if (!yaml_emitter_emit(&emitter, &output_event)) 764 goto emitter_error; 765 } 766 767 /* Write 'implicit'. */ 768 769 if (!yaml_scalar_event_initialize(&output_event, 770 NULL, "tag:yaml.org,2002:str", "implicit", -1, 771 1, 1, YAML_PLAIN_SCALAR_STYLE)) 772 goto event_error; 773 if (!yaml_emitter_emit(&emitter, &output_event)) 774 goto emitter_error; 775 776 /* Write if the sequence tag is implicit. */ 777 778 if (!yaml_scalar_event_initialize(&output_event, 779 NULL, "tag:yaml.org,2002:bool", 780 (input_event.data.sequence_start.implicit ? 781 "true" : "false"), -1, 782 1, 0, YAML_PLAIN_SCALAR_STYLE)) 783 goto event_error; 784 if (!yaml_emitter_emit(&emitter, &output_event)) 785 goto emitter_error; 520 key = yaml_document_add_scalar(&output_document, NULL, 521 "tag", -1, YAML_PLAIN_SCALAR_STYLE); 522 if (!key) goto document_error; 523 value = yaml_document_add_scalar(&output_document, NULL, 524 input_event.data.sequence_start.tag, -1, 525 YAML_DOUBLE_QUOTED_SCALAR_STYLE); 526 if (!value) goto document_error; 527 if (!yaml_document_append_mapping_pair(&output_document, 528 properties, key, value)) goto document_error; 529 } 530 531 /* Add 'implicit': <flag>. */ 532 533 key = yaml_document_add_scalar(&output_document, NULL, 534 "implicit", -1, YAML_PLAIN_SCALAR_STYLE); 535 if (!key) goto document_error; 536 value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG, 537 (input_event.data.sequence_start.implicit ? 538 "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE); 539 if (!value) goto document_error; 540 if (!yaml_document_append_mapping_pair(&output_document, 541 properties, key, value)) goto document_error; 786 542 787 543 /* Display the style information. */ … … 792 548 = input_event.data.sequence_start.style; 793 549 794 /* Write 'style'. */ 795 796 if (!yaml_scalar_event_initialize(&output_event, 797 NULL, "tag:yaml.org,2002:str", "style", -1, 798 1, 1, YAML_PLAIN_SCALAR_STYLE)) 799 goto event_error; 800 if (!yaml_emitter_emit(&emitter, &output_event)) 801 goto emitter_error; 802 803 /* Write the scalar style. */ 804 805 if (!yaml_scalar_event_initialize(&output_event, 806 NULL, "tag:yaml.org,2002:str", 807 (style == YAML_BLOCK_SEQUENCE_STYLE ? "block" : 808 style == YAML_FLOW_SEQUENCE_STYLE ? "flow" : 809 "unknown"), -1, 810 1, 1, YAML_PLAIN_SCALAR_STYLE)) 811 goto event_error; 812 if (!yaml_emitter_emit(&emitter, &output_event)) 813 goto emitter_error; 550 /* Add 'style': <style>. */ 551 552 key = yaml_document_add_scalar(&output_document, NULL, 553 "style", -1, YAML_PLAIN_SCALAR_STYLE); 554 if (!key) goto document_error; 555 value = yaml_document_add_scalar(&output_document, NULL, 556 (style == YAML_BLOCK_SEQUENCE_STYLE ? "block" : 557 style == YAML_FLOW_SEQUENCE_STYLE ? "flow" : 558 "unknown"), -1, YAML_PLAIN_SCALAR_STYLE); 559 if (!value) goto document_error; 560 if (!yaml_document_append_mapping_pair(&output_document, 561 properties, key, value)) goto document_error; 814 562 } 815 563 … … 818 566 case YAML_SEQUENCE_END_EVENT: 819 567 820 /* Write 'type'. */ 821 822 if (!yaml_scalar_event_initialize(&output_event, 823 NULL, "tag:yaml.org,2002:str", "type", -1, 824 1, 1, YAML_PLAIN_SCALAR_STYLE)) 825 goto event_error; 826 if (!yaml_emitter_emit(&emitter, &output_event)) 827 goto emitter_error; 828 829 /* Write 'SEQUENCE-END'. */ 830 831 if (!yaml_scalar_event_initialize(&output_event, 832 NULL, "tag:yaml.org,2002:str", "SEQUENCE-END", -1, 833 1, 1, YAML_PLAIN_SCALAR_STYLE)) 834 goto event_error; 835 if (!yaml_emitter_emit(&emitter, &output_event)) 836 goto emitter_error; 568 /* Add 'type': 'SEQUENCE-END'. */ 569 570 key = yaml_document_add_scalar(&output_document, NULL, 571 "type", -1, YAML_PLAIN_SCALAR_STYLE); 572 if (!key) goto document_error; 573 value = yaml_document_add_scalar(&output_document, NULL, 574 "SEQUENCE-END", -1, YAML_PLAIN_SCALAR_STYLE); 575 if (!value) goto document_error; 576 if (!yaml_document_append_mapping_pair(&output_document, 577 properties, key, value)) goto document_error; 837 578 838 579 break; … … 840 581 case YAML_MAPPING_START_EVENT: 841 582 842 /* Write 'type'. */ 843 844 if (!yaml_scalar_event_initialize(&output_event, 845 NULL, "tag:yaml.org,2002:str", "type", -1, 846 1, 1, YAML_PLAIN_SCALAR_STYLE)) 847 goto event_error; 848 if (!yaml_emitter_emit(&emitter, &output_event)) 849 goto emitter_error; 850 851 /* Write 'MAPPING-START'. */ 852 853 if (!yaml_scalar_event_initialize(&output_event, 854 NULL, "tag:yaml.org,2002:str", "MAPPING-START", -1, 855 1, 1, YAML_PLAIN_SCALAR_STYLE)) 856 goto event_error; 857 if (!yaml_emitter_emit(&emitter, &output_event)) 858 goto emitter_error; 859 860 /* Display the mapping anchor. */ 583 /* Add 'type': 'MAPPING-START'. */ 584 585 key = yaml_document_add_scalar(&output_document, NULL, 586 "type", -1, YAML_PLAIN_SCALAR_STYLE); 587 if (!key) goto document_error; 588 value = yaml_document_add_scalar(&output_document, NULL, 589 "MAPPING-START", -1, YAML_PLAIN_SCALAR_STYLE); 590 if (!value) goto document_error;
