* htmlParseLookupSequence: * @ctxt: an HTML parser context * @first: the first char to lookup * @next: the next char to lookup or zero * @third: the next char to lookup or zero * @ignoreattrval: skip over attribute values * * Try to find if a sequence (first, next, third) or just (first next) or * (first) is available in the input stream. * This function has a side effect of (possibl
| 5122 | * is available, -1 otherwise. |
| 5123 | */ |
| 5124 | static int |
| 5125 | htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first, |
| 5126 | xmlChar next, xmlChar third, int ignoreattrval) |
| 5127 | { |
| 5128 | size_t base, len; |
| 5129 | htmlParserInputPtr in; |
| 5130 | const xmlChar *buf; |
| 5131 | int quote; |
| 5132 | |
| 5133 | in = ctxt->input; |
| 5134 | if (in == NULL) |
| 5135 | return (-1); |
| 5136 | |
| 5137 | base = ctxt->checkIndex; |
| 5138 | quote = ctxt->endCheckState; |
| 5139 | |
| 5140 | buf = in->cur; |
| 5141 | len = in->end - in->cur; |
| 5142 | |
| 5143 | /* take into account the sequence length */ |
| 5144 | if (third) |
| 5145 | len -= 2; |
| 5146 | else if (next) |
| 5147 | len--; |
| 5148 | for (; base < len; base++) { |
| 5149 | if (base >= INT_MAX / 2) { |
| 5150 | ctxt->checkIndex = 0; |
| 5151 | ctxt->endCheckState = 0; |
| 5152 | return (base - 2); |
| 5153 | } |
| 5154 | if (ignoreattrval) { |
| 5155 | if (quote) { |
| 5156 | if (buf[base] == quote) |
| 5157 | quote = 0; |
| 5158 | continue; |
| 5159 | } |
| 5160 | if (buf[base] == '"' || buf[base] == '\'') { |
| 5161 | quote = buf[base]; |
| 5162 | continue; |
| 5163 | } |
| 5164 | } |
| 5165 | if (buf[base] == first) { |
| 5166 | if (third != 0) { |
| 5167 | if ((buf[base + 1] != next) || (buf[base + 2] != third)) |
| 5168 | continue; |
| 5169 | } else if (next != 0) { |
| 5170 | if (buf[base + 1] != next) |
| 5171 | continue; |
| 5172 | } |
| 5173 | ctxt->checkIndex = 0; |
| 5174 | ctxt->endCheckState = 0; |
| 5175 | return (base); |
| 5176 | } |
| 5177 | } |
| 5178 | ctxt->checkIndex = base; |
| 5179 | ctxt->endCheckState = quote; |
| 5180 | return (-1); |
| 5181 | } |
no outgoing calls
no test coverage detected