| 2206 | } |
| 2207 | |
| 2208 | void parse(char_t* s, xml_node_struct* xmldoc, unsigned int optmsk, char_t endch) |
| 2209 | { |
| 2210 | strconv_attribute_t strconv_attribute = get_strconv_attribute(optmsk); |
| 2211 | strconv_pcdata_t strconv_pcdata = get_strconv_pcdata(optmsk); |
| 2212 | |
| 2213 | char_t ch = 0; |
| 2214 | xml_node_struct* cursor = xmldoc; |
| 2215 | char_t* mark = s; |
| 2216 | |
| 2217 | while (*s != 0) |
| 2218 | { |
| 2219 | if (*s == '<') |
| 2220 | { |
| 2221 | ++s; |
| 2222 | |
| 2223 | LOC_TAG: |
| 2224 | if (IS_CHARTYPE(*s, ct_start_symbol)) // '<#...' |
| 2225 | { |
| 2226 | PUSHNODE(node_element); // Append a new node to the tree. |
| 2227 | |
| 2228 | cursor->name = s; |
| 2229 | |
| 2230 | SCANWHILE(IS_CHARTYPE(*s, ct_symbol)); // Scan for a terminator. |
| 2231 | ENDSEG(); // Save char in 'ch', terminate & step over. |
| 2232 | |
| 2233 | if (ch == '>') |
| 2234 | { |
| 2235 | // end of tag |
| 2236 | } |
| 2237 | else if (IS_CHARTYPE(ch, ct_space)) |
| 2238 | { |
| 2239 | LOC_ATTRIBUTES: |
| 2240 | while (true) |
| 2241 | { |
| 2242 | SKIPWS(); // Eat any whitespace. |
| 2243 | |
| 2244 | if (IS_CHARTYPE(*s, ct_start_symbol)) // <... #... |
| 2245 | { |
| 2246 | xml_attribute_struct* a = append_attribute_ll(cursor, alloc); // Make space for this attribute. |
| 2247 | if (!a) THROW_ERROR(status_out_of_memory, s); |
| 2248 | |
| 2249 | a->name = s; // Save the offset. |
| 2250 | |
| 2251 | SCANWHILE(IS_CHARTYPE(*s, ct_symbol)); // Scan for a terminator. |
| 2252 | CHECK_ERROR(status_bad_attribute, s); //$ redundant, left for performance |
| 2253 | |
| 2254 | ENDSEG(); // Save char in 'ch', terminate & step over. |
| 2255 | CHECK_ERROR(status_bad_attribute, s); //$ redundant, left for performance |
| 2256 | |
| 2257 | if (IS_CHARTYPE(ch, ct_space)) |
| 2258 | { |
| 2259 | SKIPWS(); // Eat any whitespace. |
| 2260 | CHECK_ERROR(status_bad_attribute, s); //$ redundant, left for performance |
| 2261 | |
| 2262 | ch = *s; |
| 2263 | ++s; |
| 2264 | } |
| 2265 |
no test coverage detected