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

Function xmlParseReference

ThirdParty/libxml2/vtklibxml2/parser.c:7318–7552  ·  view source on GitHub ↗

* xmlParseReference: * @ctxt: an XML parser context * * DEPRECATED: Internal function, don't use. * * parse and handle entity references in content, depending on the SAX * interface, this may end-up in a call to character() if this is a * CharRef, a predefined entity, if there is no reference() callback. * or if the parser was asked to switch to that mode. * * Always consumes '&'. * *

Source from the content-addressed store, hash-verified

7316 * [67] Reference ::= EntityRef | CharRef
7317 */
7318void
7319xmlParseReference(xmlParserCtxtPtr ctxt) {
7320 xmlEntityPtr ent = NULL;
7321 const xmlChar *name;
7322 xmlChar *val;
7323
7324 if (RAW != '&')
7325 return;
7326
7327 /*
7328 * Simple case of a CharRef
7329 */
7330 if (NXT(1) == '#') {
7331 int i = 0;
7332 xmlChar out[16];
7333 int value = xmlParseCharRef(ctxt);
7334
7335 if (value == 0)
7336 return;
7337
7338 /*
7339 * Just encode the value in UTF-8
7340 */
7341 COPY_BUF(out, i, value);
7342 out[i] = 0;
7343 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
7344 (!ctxt->disableSAX))
7345 ctxt->sax->characters(ctxt->userData, out, i);
7346 return;
7347 }
7348
7349 /*
7350 * We are seeing an entity reference
7351 */
7352 name = xmlParseEntityRefInternal(ctxt);
7353 if (name == NULL)
7354 return;
7355 ent = xmlLookupGeneralEntity(ctxt, name, /* isAttr */ 0);
7356 if (ent == NULL) {
7357 /*
7358 * Create a reference for undeclared entities.
7359 */
7360 if ((ctxt->replaceEntities == 0) &&
7361 (ctxt->sax != NULL) &&
7362 (ctxt->disableSAX == 0) &&
7363 (ctxt->sax->reference != NULL)) {
7364 ctxt->sax->reference(ctxt->userData, name);
7365 }
7366 return;
7367 }
7368 if (!ctxt->wellFormed)
7369 return;
7370
7371 /* special case of predefined entities */
7372 if ((ent->name == NULL) ||
7373 (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
7374 val = ent->content;
7375 if (val == NULL) return;

Callers 2

xmlParseContentInternalFunction · 0.85
parser.cFile · 0.85

Calls 9

xmlParseCharRefFunction · 0.85
xmlLookupGeneralEntityFunction · 0.85
xmlStrlenFunction · 0.85
xmlCtxtParseEntityFunction · 0.85
xmlParserEntityCheckFunction · 0.85
xmlDocCopyNodeFunction · 0.85
xmlErrMemoryFunction · 0.85
referenceMethod · 0.80

Tested by

no test coverage detected