| 2639 | } |
| 2640 | |
| 2641 | char_t* parse_tree(char_t* s, xml_node_struct* root, unsigned int optmsk, char_t endch) |
| 2642 | { |
| 2643 | strconv_attribute_t strconv_attribute = get_strconv_attribute(optmsk); |
| 2644 | strconv_pcdata_t strconv_pcdata = get_strconv_pcdata(optmsk); |
| 2645 | |
| 2646 | char_t ch = 0; |
| 2647 | xml_node_struct* cursor = root; |
| 2648 | char_t* mark = s; |
| 2649 | |
| 2650 | while (*s != 0) |
| 2651 | { |
| 2652 | if (*s == '<') |
| 2653 | { |
| 2654 | ++s; |
| 2655 | |
| 2656 | LOC_TAG: |
| 2657 | if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // '<#...' |
| 2658 | { |
| 2659 | PUGI__PUSHNODE(node_element); // Append a new node to the tree. |
| 2660 | |
| 2661 | cursor->name = s; |
| 2662 | |
| 2663 | PUGI__SCANWHILE_UNROLL(PUGI__IS_CHARTYPE(ss, ct_symbol)); // Scan for a terminator. |
| 2664 | PUGI__ENDSEG(); // Save char in 'ch', terminate & step over. |
| 2665 | |
| 2666 | if (ch == '>') |
| 2667 | { |
| 2668 | // end of tag |
| 2669 | } |
| 2670 | else if (PUGI__IS_CHARTYPE(ch, ct_space)) |
| 2671 | { |
| 2672 | LOC_ATTRIBUTES: |
| 2673 | while (true) |
| 2674 | { |
| 2675 | PUGI__SKIPWS(); // Eat any whitespace. |
| 2676 | |
| 2677 | if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // <... #... |
| 2678 | { |
| 2679 | xml_attribute_struct* a = append_new_attribute(cursor, alloc); // Make space for this attribute. |
| 2680 | if (!a) PUGI__THROW_ERROR(status_out_of_memory, s); |
| 2681 | |
| 2682 | a->name = s; // Save the offset. |
| 2683 | |
| 2684 | PUGI__SCANWHILE_UNROLL(PUGI__IS_CHARTYPE(ss, ct_symbol)); // Scan for a terminator. |
| 2685 | PUGI__ENDSEG(); // Save char in 'ch', terminate & step over. |
| 2686 | |
| 2687 | if (PUGI__IS_CHARTYPE(ch, ct_space)) |
| 2688 | { |
| 2689 | PUGI__SKIPWS(); // Eat any whitespace. |
| 2690 | |
| 2691 | ch = *s; |
| 2692 | ++s; |
| 2693 | } |
| 2694 | |
| 2695 | if (ch == '=') // '<... #=...' |
| 2696 | { |
| 2697 | PUGI__SKIPWS(); // Eat any whitespace. |
| 2698 | |