MCPcopy Create free account
hub / github.com/Kitware/VTK / htmlParsePI

Function htmlParsePI

ThirdParty/libxml2/vtklibxml2/HTMLparser.c:3242–3345  ·  view source on GitHub ↗

* htmlParsePI: * @ctxt: an HTML parser context * * Parse an XML Processing Instruction. HTML5 doesn't allow processing * instructions, so this will be removed at some point. */

Source from the content-addressed store, hash-verified

3240 * instructions, so this will be removed at some point.
3241 */
3242static void
3243htmlParsePI(htmlParserCtxtPtr ctxt) {
3244 xmlChar *buf = NULL;
3245 int len = 0;
3246 int size = HTML_PARSER_BUFFER_SIZE;
3247 int cur, l;
3248 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3249 XML_MAX_HUGE_LENGTH :
3250 XML_MAX_TEXT_LENGTH;
3251 const xmlChar *target;
3252 xmlParserInputState state;
3253
3254 if ((RAW == '<') && (NXT(1) == '?')) {
3255 state = ctxt->instate;
3256 ctxt->instate = XML_PARSER_PI;
3257 /*
3258 * this is a Processing Instruction.
3259 */
3260 SKIP(2);
3261
3262 /*
3263 * Parse the target name and check for special support like
3264 * namespace.
3265 */
3266 target = htmlParseName(ctxt);
3267 if (target != NULL) {
3268 if (RAW == '>') {
3269 SKIP(1);
3270
3271 /*
3272 * SAX: PI detected.
3273 */
3274 if ((ctxt->sax) && (!ctxt->disableSAX) &&
3275 (ctxt->sax->processingInstruction != NULL))
3276 ctxt->sax->processingInstruction(ctxt->userData,
3277 target, NULL);
3278 goto done;
3279 }
3280 buf = (xmlChar *) xmlMallocAtomic(size);
3281 if (buf == NULL) {
3282 htmlErrMemory(ctxt);
3283 return;
3284 }
3285 cur = CUR;
3286 if (!IS_BLANK(cur)) {
3287 htmlParseErr(ctxt, XML_ERR_SPACE_REQUIRED,
3288 "ParsePI: PI %s space expected\n", target, NULL);
3289 }
3290 SKIP_BLANKS;
3291 cur = CUR_CHAR(l);
3292 while ((cur != 0) && (cur != '>')) {
3293 if (len + 5 >= size) {
3294 xmlChar *tmp;
3295
3296 size *= 2;
3297 tmp = (xmlChar *) xmlRealloc(buf, size);
3298 if (tmp == NULL) {
3299 htmlErrMemory(ctxt);

Callers 4

htmlParseContentFunction · 0.85
htmlParseContentInternalFunction · 0.85
htmlParseDocumentFunction · 0.85
htmlParseTryOrFinishFunction · 0.85

Calls 2

htmlParseNameFunction · 0.85
htmlErrMemoryFunction · 0.85

Tested by

no test coverage detected