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

Function htmlParseReference

ThirdParty/libxml2/vtklibxml2/HTMLparser.c:4066–4133  ·  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

4064 * CharRef, or a predefined entity.
4065 */
4066static void
4067htmlParseReference(htmlParserCtxtPtr ctxt) {
4068 const htmlEntityDesc * ent;
4069 xmlChar out[6];
4070 const xmlChar *name;
4071 if (CUR != '&') return;
4072
4073 if (NXT(1) == '#') {
4074 unsigned int c;
4075 int bits, i = 0;
4076
4077 c = htmlParseCharRef(ctxt);
4078 if (c == 0)
4079 return;
4080
4081 if (c < 0x80) { out[i++]= c; bits= -6; }
4082 else if (c < 0x800) { out[i++]=((c >> 6) & 0x1F) | 0xC0; bits= 0; }
4083 else if (c < 0x10000) { out[i++]=((c >> 12) & 0x0F) | 0xE0; bits= 6; }
4084 else { out[i++]=((c >> 18) & 0x07) | 0xF0; bits= 12; }
4085
4086 for ( ; bits >= 0; bits-= 6) {
4087 out[i++]= ((c >> bits) & 0x3F) | 0x80;
4088 }
4089 out[i] = 0;
4090
4091 htmlCheckParagraph(ctxt);
4092 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
4093 ctxt->sax->characters(ctxt->userData, out, i);
4094 } else {
4095 ent = htmlParseEntityRef(ctxt, &name);
4096 if (name == NULL) {
4097 htmlCheckParagraph(ctxt);
4098 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
4099 ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
4100 return;
4101 }
4102 if ((ent == NULL) || !(ent->value > 0)) {
4103 htmlCheckParagraph(ctxt);
4104 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL)) {
4105 ctxt->sax->characters(ctxt->userData, BAD_CAST "&", 1);
4106 ctxt->sax->characters(ctxt->userData, name, xmlStrlen(name));
4107 /* ctxt->sax->characters(ctxt->userData, BAD_CAST ";", 1); */
4108 }
4109 } else {
4110 unsigned int c;
4111 int bits, i = 0;
4112
4113 c = ent->value;
4114 if (c < 0x80)
4115 { out[i++]= c; bits= -6; }
4116 else if (c < 0x800)
4117 { out[i++]=((c >> 6) & 0x1F) | 0xC0; bits= 0; }
4118 else if (c < 0x10000)
4119 { out[i++]=((c >> 12) & 0x0F) | 0xE0; bits= 6; }
4120 else
4121 { out[i++]=((c >> 18) & 0x07) | 0xF0; bits= 12; }
4122
4123 for ( ; bits >= 0; bits-= 6) {

Callers 3

htmlParseContentFunction · 0.85
htmlParseContentInternalFunction · 0.85
htmlParseTryOrFinishFunction · 0.85

Calls 4

htmlParseCharRefFunction · 0.85
htmlCheckParagraphFunction · 0.85
htmlParseEntityRefFunction · 0.85
xmlStrlenFunction · 0.85

Tested by

no test coverage detected