* htmlAutoCloseOnClose: * @ctxt: an HTML parser context * @newtag: The new tag name * @force: force the tag closure * * The HTML DTD allows an ending tag to implicitly close other tags. */
| 1407 | * The HTML DTD allows an ending tag to implicitly close other tags. |
| 1408 | */ |
| 1409 | static void |
| 1410 | htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag) |
| 1411 | { |
| 1412 | const htmlElemDesc *info; |
| 1413 | int i, priority; |
| 1414 | |
| 1415 | priority = htmlGetEndPriority(newtag); |
| 1416 | |
| 1417 | for (i = (ctxt->nameNr - 1); i >= 0; i--) { |
| 1418 | |
| 1419 | if (xmlStrEqual(newtag, ctxt->nameTab[i])) |
| 1420 | break; |
| 1421 | /* |
| 1422 | * A misplaced endtag can only close elements with lower |
| 1423 | * or equal priority, so if we find an element with higher |
| 1424 | * priority before we find an element with |
| 1425 | * matching name, we just ignore this endtag |
| 1426 | */ |
| 1427 | if (htmlGetEndPriority(ctxt->nameTab[i]) > priority) |
| 1428 | return; |
| 1429 | } |
| 1430 | if (i < 0) |
| 1431 | return; |
| 1432 | |
| 1433 | while (!xmlStrEqual(newtag, ctxt->name)) { |
| 1434 | info = htmlTagLookup(ctxt->name); |
| 1435 | if ((info != NULL) && (info->endTag == 3)) { |
| 1436 | htmlParseErr(ctxt, XML_ERR_TAG_NAME_MISMATCH, |
| 1437 | "Opening and ending tag mismatch: %s and %s\n", |
| 1438 | newtag, ctxt->name); |
| 1439 | } |
| 1440 | if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) |
| 1441 | ctxt->sax->endElement(ctxt->userData, ctxt->name); |
| 1442 | htmlnamePop(ctxt); |
| 1443 | } |
| 1444 | } |
| 1445 | |
| 1446 | /** |
| 1447 | * htmlAutoCloseOnEnd: |
no test coverage detected