| 2288 | } |
| 2289 | |
| 2290 | char_t* parse_question(char_t* s, xml_node_struct*& ref_cursor, unsigned int optmsk, char_t endch) |
| 2291 | { |
| 2292 | // load into registers |
| 2293 | xml_node_struct* cursor = ref_cursor; |
| 2294 | char_t ch = 0; |
| 2295 | |
| 2296 | // parse node contents, starting with question mark |
| 2297 | ++s; |
| 2298 | |
| 2299 | // read PI target |
| 2300 | char_t* target = s; |
| 2301 | |
| 2302 | if (!PUGI__IS_CHARTYPE(*s, ct_start_symbol)) PUGI__THROW_ERROR(status_bad_pi, s); |
| 2303 | |
| 2304 | PUGI__SCANWHILE(PUGI__IS_CHARTYPE(*s, ct_symbol)); |
| 2305 | PUGI__CHECK_ERROR(status_bad_pi, s); |
| 2306 | |
| 2307 | // determine node type; stricmp / strcasecmp is not portable |
| 2308 | bool declaration = (target[0] | ' ') == 'x' && (target[1] | ' ') == 'm' && (target[2] | ' ') == 'l' && target + 3 == s; |
| 2309 | |
| 2310 | if (declaration ? PUGI__OPTSET(parse_declaration) : PUGI__OPTSET(parse_pi)) |
| 2311 | { |
| 2312 | if (declaration) |
| 2313 | { |
| 2314 | // disallow non top-level declarations |
| 2315 | if (cursor->parent) PUGI__THROW_ERROR(status_bad_pi, s); |
| 2316 | |
| 2317 | PUGI__PUSHNODE(node_declaration); |
| 2318 | } |
| 2319 | else |
| 2320 | { |
| 2321 | PUGI__PUSHNODE(node_pi); |
| 2322 | } |
| 2323 | |
| 2324 | cursor->name = target; |
| 2325 | |
| 2326 | PUGI__ENDSEG(); |
| 2327 | |
| 2328 | // parse value/attributes |
| 2329 | if (ch == '?') |
| 2330 | { |
| 2331 | // empty node |
| 2332 | if (!ENDSWITH(*s, '>')) PUGI__THROW_ERROR(status_bad_pi, s); |
| 2333 | s += (*s == '>'); |
| 2334 | |
| 2335 | PUGI__POPNODE(); |
| 2336 | } |
| 2337 | else if (PUGI__IS_CHARTYPE(ch, ct_space)) |
| 2338 | { |
| 2339 | PUGI__SKIPWS(); |
| 2340 | |
| 2341 | // scan for tag end |
| 2342 | char_t* value = s; |
| 2343 | |
| 2344 | PUGI__SCANFOR(s[0] == '?' && ENDSWITH(s[1], '>')); |
| 2345 | PUGI__CHECK_ERROR(status_bad_pi, s); |
| 2346 | |
| 2347 | if (declaration) |
nothing calls this directly
no outgoing calls
no test coverage detected