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

Function xmlFAParseAtom

ThirdParty/libxml2/vtklibxml2/xmlregexp.c:5190–5254  ·  view source on GitHub ↗

* xmlFAParseAtom: * @ctxt: a regexp parser context * * [9] atom ::= Char | charClass | ( '(' regExp ')' ) */

Source from the content-addressed store, hash-verified

5188 * [9] atom ::= Char | charClass | ( '(' regExp ')' )
5189 */
5190static int
5191xmlFAParseAtom(xmlRegParserCtxtPtr ctxt) {
5192 int codepoint, len;
5193
5194 codepoint = xmlFAIsChar(ctxt);
5195 if (codepoint > 0) {
5196 ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_CHARVAL);
5197 if (ctxt->atom == NULL)
5198 return(-1);
5199 len = 4;
5200 codepoint = xmlGetUTF8Char(ctxt->cur, &len);
5201 if (codepoint < 0) {
5202 ERROR("Invalid UTF-8");
5203 return(-1);
5204 }
5205 ctxt->atom->codepoint = codepoint;
5206 NEXTL(len);
5207 return(1);
5208 } else if (CUR == '|') {
5209 return(0);
5210 } else if (CUR == 0) {
5211 return(0);
5212 } else if (CUR == ')') {
5213 return(0);
5214 } else if (CUR == '(') {
5215 xmlRegStatePtr start, oldend, start0;
5216
5217 NEXT;
5218 if (ctxt->depth >= 50) {
5219 ERROR("xmlFAParseAtom: maximum nesting depth exceeded");
5220 return(-1);
5221 }
5222 /*
5223 * this extra Epsilon transition is needed if we count with 0 allowed
5224 * unfortunately this can't be known at that point
5225 */
5226 xmlFAGenerateEpsilonTransition(ctxt, ctxt->state, NULL);
5227 start0 = ctxt->state;
5228 xmlFAGenerateEpsilonTransition(ctxt, ctxt->state, NULL);
5229 start = ctxt->state;
5230 oldend = ctxt->end;
5231 ctxt->end = NULL;
5232 ctxt->atom = NULL;
5233 ctxt->depth++;
5234 xmlFAParseRegExp(ctxt, 0);
5235 ctxt->depth--;
5236 if (CUR == ')') {
5237 NEXT;
5238 } else {
5239 ERROR("xmlFAParseAtom: expecting ')'");
5240 }
5241 ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_SUBREG);
5242 if (ctxt->atom == NULL)
5243 return(-1);
5244 ctxt->atom->start = start;
5245 ctxt->atom->start0 = start0;
5246 ctxt->atom->stop = ctxt->state;
5247 ctxt->end = oldend;

Callers 1

xmlFAParsePieceFunction · 0.85

Calls 6

xmlFAIsCharFunction · 0.85
xmlRegNewAtomFunction · 0.85
xmlGetUTF8CharFunction · 0.85
xmlFAParseRegExpFunction · 0.85
xmlFAParseCharClassFunction · 0.85

Tested by

no test coverage detected