| 4423 | } |
| 4424 | |
| 4425 | static enum XML_Error PTRCALL |
| 4426 | entityValueInitProcessor(XML_Parser parser, const char *s, const char *end, |
| 4427 | const char **nextPtr) { |
| 4428 | int tok; |
| 4429 | const char *start = s; |
| 4430 | const char *next = start; |
| 4431 | parser->m_eventPtr = start; |
| 4432 | |
| 4433 | for (;;) { |
| 4434 | tok = XmlPrologTok(parser->m_encoding, start, end, &next); |
| 4435 | /* Note: Except for XML_TOK_BOM below, these bytes are accounted later in: |
| 4436 | - storeEntityValue |
| 4437 | - processXmlDecl |
| 4438 | */ |
| 4439 | parser->m_eventEndPtr = next; |
| 4440 | if (tok <= 0) { |
| 4441 | if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { |
| 4442 | *nextPtr = s; |
| 4443 | return XML_ERROR_NONE; |
| 4444 | } |
| 4445 | switch (tok) { |
| 4446 | case XML_TOK_INVALID: |
| 4447 | return XML_ERROR_INVALID_TOKEN; |
| 4448 | case XML_TOK_PARTIAL: |
| 4449 | return XML_ERROR_UNCLOSED_TOKEN; |
| 4450 | case XML_TOK_PARTIAL_CHAR: |
| 4451 | return XML_ERROR_PARTIAL_CHAR; |
| 4452 | case XML_TOK_NONE: /* start == end */ |
| 4453 | default: |
| 4454 | break; |
| 4455 | } |
| 4456 | /* found end of entity value - can store it now */ |
| 4457 | return storeEntityValue(parser, parser->m_encoding, s, end, |
| 4458 | XML_ACCOUNT_DIRECT); |
| 4459 | } else if (tok == XML_TOK_XML_DECL) { |
| 4460 | enum XML_Error result; |
| 4461 | result = processXmlDecl(parser, 0, start, next); |
| 4462 | if (result != XML_ERROR_NONE) |
| 4463 | return result; |
| 4464 | /* At this point, m_parsingStatus.parsing cannot be XML_SUSPENDED. For |
| 4465 | * that to happen, a parameter entity parsing handler must have attempted |
| 4466 | * to suspend the parser, which fails and raises an error. The parser can |
| 4467 | * be aborted, but can't be suspended. |
| 4468 | */ |
| 4469 | if (parser->m_parsingStatus.parsing == XML_FINISHED) |
| 4470 | return XML_ERROR_ABORTED; |
| 4471 | *nextPtr = next; |
| 4472 | /* stop scanning for text declaration - we found one */ |
| 4473 | parser->m_processor = entityValueProcessor; |
| 4474 | return entityValueProcessor(parser, next, end, nextPtr); |
| 4475 | } |
| 4476 | /* If we are at the end of the buffer, this would cause XmlPrologTok to |
| 4477 | return XML_TOK_NONE on the next call, which would then cause the |
| 4478 | function to exit with *nextPtr set to s - that is what we want for other |
| 4479 | tokens, but not for the BOM - we would rather like to skip it; |
| 4480 | then, when this routine is entered the next time, XmlPrologTok will |
| 4481 | return XML_TOK_INVALID, since the BOM is still in the buffer |
| 4482 | */ |
no test coverage detected