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

Function xmlAutomataNewOnceTrans

ThirdParty/libxml2/vtklibxml2/xmlregexp.c:6094–6139  ·  view source on GitHub ↗

* xmlAutomataNewOnceTrans: * @am: an automata * @from: the starting point of the transition * @to: the target point of the transition or NULL * @token: the input string associated to that transition * @min: the minimum successive occurrences of token * @max: the maximum successive occurrences of token * @data: data associated to the transition * * If @to is NULL, this creates first a n

Source from the content-addressed store, hash-verified

6092 * Returns the target state or NULL in case of error
6093 */
6094xmlAutomataStatePtr
6095xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
6096 xmlAutomataStatePtr to, const xmlChar *token,
6097 int min, int max, void *data) {
6098 xmlRegAtomPtr atom;
6099 int counter;
6100
6101 if ((am == NULL) || (from == NULL) || (token == NULL))
6102 return(NULL);
6103 if (min < 1)
6104 return(NULL);
6105 if (max < min)
6106 return(NULL);
6107 atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
6108 if (atom == NULL)
6109 return(NULL);
6110 atom->valuep = xmlStrdup(token);
6111 atom->data = data;
6112 atom->quant = XML_REGEXP_QUANT_ONCEONLY;
6113 atom->min = min;
6114 atom->max = max;
6115 /*
6116 * associate a counter to the transition.
6117 */
6118 counter = xmlRegGetCounter(am);
6119 if (counter < 0)
6120 goto error;
6121 am->counters[counter].min = 1;
6122 am->counters[counter].max = 1;
6123
6124 /* xmlFAGenerateTransitions(am, from, to, atom); */
6125 if (to == NULL) {
6126 to = xmlRegStatePush(am);
6127 if (to == NULL)
6128 goto error;
6129 }
6130 xmlRegStateAddTrans(am, from, atom, to, counter, -1);
6131 if (xmlRegAtomPush(am, atom) < 0)
6132 goto error;
6133 am->state = to;
6134 return(to);
6135
6136error:
6137 xmlRegFreeAtom(atom);
6138 return(NULL);
6139}
6140
6141/**
6142 * xmlAutomataNewState:

Callers

nothing calls this directly

Calls 7

xmlRegNewAtomFunction · 0.85
xmlStrdupFunction · 0.85
xmlRegGetCounterFunction · 0.85
xmlRegStatePushFunction · 0.85
xmlRegStateAddTransFunction · 0.85
xmlRegAtomPushFunction · 0.85
xmlRegFreeAtomFunction · 0.85

Tested by

no test coverage detected