MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / htmlParseReference

Function htmlParseReference

Externals/LibXML/HTMLparser.c:3730–3797  ·  view source on GitHub ↗

* htmlParseReference: * @ctxt: an HTML parser context * * parse and handle entity references in content, * this will end-up in a call to character() since this is either a * CharRef, or a predefined entity. */

Source from the content-addressed store, hash-verified

3728 * CharRef, or a predefined entity.
3729 */
3730static void
3731htmlParseReference(htmlParserCtxtPtr ctxt) {
3732 const htmlEntityDesc * ent;
3733 xmlChar out[6];
3734 const xmlChar *name;
3735 if (CUR != '&') return;
3736
3737 if (NXT(1) == '#') {
3738 unsigned int c;
3739 int bits, i = 0;
3740
3741 c = htmlParseCharRef(ctxt);
3742 if (c == 0)
3743 return;
3744
3745 if (c < 0x80) { out[i++]= c; bits= -6; }
3746 else if (c < 0x800) { out[i++]=((c >> 6) & 0x1F) | 0xC0; bits= 0; }
3747 else if (c < 0x10000) { out[i++]=((c >> 12) & 0x0F) | 0xE0; bits= 6; }
3748 else { out[i++]=((c >> 18) & 0x07) | 0xF0; bits= 12; }
3749
3750 for ( ; bits >= 0; bits-= 6) {
3751 out[i++]= ((c >> bits) & 0x3F) | 0x80;
3752 }
3753 out[i] = 0;
3754
3755 htmlCheckParagraph(ctxt);
3756 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
3757 ctxt->sax->characters(ctxt->userData, out, i);
3758 } else {
3759 ent = htmlParseEntityRef(ctxt, &name);
3760 if (name == NULL) {
3761 htmlCheckParagraph(ctxt);
3762 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
3763 ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
3764 return;
3765 }
3766 if ((ent == NULL) || !(ent->value > 0)) {
3767 htmlCheckParagraph(ctxt);
3768 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL)) {
3769 ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
3770 ctxt->sax->characters(ctxt->userData, name, xmlStrlen(name));
3771 /* ctxt->sax->characters(ctxt->userData, BAD_CAST ";", 1); */
3772 }
3773 } else {
3774 unsigned int c;
3775 int bits, i = 0;
3776
3777 c = ent->value;
3778 if (c < 0x80)
3779 { out[i++]= c; bits= -6; }
3780 else if (c < 0x800)
3781 { out[i++]=((c >> 6) & 0x1F) | 0xC0; bits= 0; }
3782 else if (c < 0x10000)
3783 { out[i++]=((c >> 12) & 0x0F) | 0xE0; bits= 6; }
3784 else
3785 { out[i++]=((c >> 18) & 0x07) | 0xF0; bits= 12; }
3786
3787 for ( ; bits >= 0; bits-= 6) {

Callers 2

htmlParseContentFunction · 0.85
htmlParseTryOrFinishFunction · 0.85

Calls 5

htmlParseCharRefFunction · 0.85
htmlCheckParagraphFunction · 0.85
htmlParseEntityRefFunction · 0.85
xmlStrlenFunction · 0.85
charactersMethod · 0.45

Tested by

no test coverage detected