| 2667 | } |
| 2668 | |
| 2669 | char_t* parse(char_t* s, xml_node_struct* xmldoc, unsigned int optmsk, char_t endch) |
| 2670 | { |
| 2671 | strconv_attribute_t strconv_attribute = get_strconv_attribute(optmsk); |
| 2672 | strconv_pcdata_t strconv_pcdata = get_strconv_pcdata(optmsk); |
| 2673 | |
| 2674 | char_t ch = 0; |
| 2675 | xml_node_struct* cursor = xmldoc; |
| 2676 | char_t* mark = s; |
| 2677 | |
| 2678 | while (*s != 0) |
| 2679 | { |
| 2680 | if (*s == '<') |
| 2681 | { |
| 2682 | ++s; |
| 2683 | |
| 2684 | LOC_TAG: |
| 2685 | if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // '<#...' |
| 2686 | { |
| 2687 | PUGI__PUSHNODE(node_element); // Append a new node to the tree. |
| 2688 | |
| 2689 | cursor->name = s; |
| 2690 | |
| 2691 | PUGI__SCANWHILE(PUGI__IS_CHARTYPE(*s, ct_symbol)); // Scan for a terminator. |
| 2692 | PUGI__ENDSEG(); // Save char in 'ch', terminate & step over. |
| 2693 | |
| 2694 | if (ch == '>') |
| 2695 | { |
| 2696 | // end of tag |
| 2697 | } |
| 2698 | else if (PUGI__IS_CHARTYPE(ch, ct_space)) |
| 2699 | { |
| 2700 | LOC_ATTRIBUTES: |
| 2701 | while (true) |
| 2702 | { |
| 2703 | PUGI__SKIPWS(); // Eat any whitespace. |
| 2704 | |
| 2705 | if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // <... #... |
| 2706 | { |
| 2707 | xml_attribute_struct* a = |
| 2708 | append_attribute_ll(cursor, alloc); // Make space for this attribute. |
| 2709 | if (!a) |
| 2710 | PUGI__THROW_ERROR(status_out_of_memory, s); |
| 2711 | |
| 2712 | a->name = s; // Save the offset. |
| 2713 | |
| 2714 | PUGI__SCANWHILE(PUGI__IS_CHARTYPE(*s, ct_symbol)); // Scan for a terminator. |
| 2715 | PUGI__CHECK_ERROR(status_bad_attribute, s); //$ redundant, left for performance |
| 2716 | |
| 2717 | PUGI__ENDSEG(); // Save char in 'ch', terminate & step over. |
| 2718 | PUGI__CHECK_ERROR(status_bad_attribute, s); //$ redundant, left for performance |
| 2719 | |
| 2720 | if (PUGI__IS_CHARTYPE(ch, ct_space)) |
| 2721 | { |
| 2722 | PUGI__SKIPWS(); // Eat any whitespace. |
| 2723 | PUGI__CHECK_ERROR(status_bad_attribute, s); //$ redundant, left for performance |
| 2724 | |
| 2725 | ch = *s; |
| 2726 | ++s; |
no test coverage detected