* xmlParseLookupString: * @ctxt: an XML parser context * @startDelta: delta to apply at the start * @str: string * @strLen: length of string * * Check whether the input buffer contains a string. */
| 10816 | * Check whether the input buffer contains a string. |
| 10817 | */ |
| 10818 | static const xmlChar * |
| 10819 | xmlParseLookupString(xmlParserCtxtPtr ctxt, size_t startDelta, |
| 10820 | const char *str, size_t strLen) { |
| 10821 | const xmlChar *cur, *term; |
| 10822 | |
| 10823 | if (ctxt->checkIndex == 0) { |
| 10824 | cur = ctxt->input->cur + startDelta; |
| 10825 | } else { |
| 10826 | cur = ctxt->input->cur + ctxt->checkIndex; |
| 10827 | } |
| 10828 | |
| 10829 | term = BAD_CAST strstr((const char *) cur, str); |
| 10830 | if (term == NULL) { |
| 10831 | const xmlChar *end = ctxt->input->end; |
| 10832 | size_t index; |
| 10833 | |
| 10834 | /* Rescan (strLen - 1) characters. */ |
| 10835 | if ((size_t) (end - cur) < strLen) |
| 10836 | end = cur; |
| 10837 | else |
| 10838 | end -= strLen - 1; |
| 10839 | index = end - ctxt->input->cur; |
| 10840 | if (index > LONG_MAX) { |
| 10841 | ctxt->checkIndex = 0; |
| 10842 | return(ctxt->input->end - strLen); |
| 10843 | } |
| 10844 | ctxt->checkIndex = index; |
| 10845 | } else { |
| 10846 | ctxt->checkIndex = 0; |
| 10847 | } |
| 10848 | |
| 10849 | return(term); |
| 10850 | } |
| 10851 | |
| 10852 | /** |
| 10853 | * xmlParseLookupCharData: |