xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
xmlRegStatePtr to, xmlRegAtomPtr atom) {
xmlRegStatePtr end;
+ int nullable = 0;
if (atom == NULL) {
ERROR("genrate transition: atom == NULL");
if (xmlRegAtomPush(ctxt, atom) < 0) {
return(-1);
}
+ if ((atom->quant == XML_REGEXP_QUANT_RANGE) &&
+ (atom->min == 0) && (atom->max > 0)) {
+ nullable = 1;
+ atom->min = 1;
+ if (atom->max == 1)
+ atom->quant = XML_REGEXP_QUANT_OPT;
+ }
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1);
ctxt->state = end;
switch (atom->quant) {
xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1);
break;
case XML_REGEXP_QUANT_RANGE:
-#if DV_test
- if (atom->min == 0) {
+ if (nullable)
xmlFAGenerateEpsilonTransition(ctxt, from, to);
- }
-#endif
break;
default:
break;
exec->status = -6;
return;
}
- memcpy(exec->counts, exec->rollbacks[exec->nbRollbacks].counts,
+ if (exec->counts) {
+ memcpy(exec->counts, exec->rollbacks[exec->nbRollbacks].counts,
exec->comp->nbCounters * sizeof(int));
+ }
}
#ifdef DEBUG_REGEXP_EXEC
*/
exec->determinist = 0;
xmlFARegExecRollBack(exec);
- if (exec->status == 0) {
+ if ((exec->inputStack != NULL ) && (exec->status == 0)) {
value = exec->inputStack[exec->index].value;
data = exec->inputStack[exec->index].data;
#ifdef DEBUG_PUSH
(*nbval)++;
}
} else {
- if ((exec->comp->states[trans->to] != NULL) &&
+ if ((exec->comp != NULL) && (exec->comp->states[trans->to] != NULL) &&
(exec->comp->states[trans->to]->type !=
XML_REGEXP_SINK_STATE)) {
if (atom->neg)
ERROR("Expecting the end of a char range");
return;
}
- NEXTL(len);
+
/* TODO check that the values are acceptable character ranges for XML */
if (end < start) {
ERROR("End of range is before start of range");
} else {
+ NEXTL(len);
xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg,
XML_REGEXP_CHARVAL, start, end, NULL);
}
if (atom == NULL)
return(NULL);
atom->data = data;
- if (atom == NULL)
- return(NULL);
atom->valuep = xmlStrdup(token);
if (xmlFAGenerateTransitions(am, from, to, atom) < 0) {
/**
* xmlExpNewCtxt:
* @maxNodes: the maximum number of nodes
- * @dict: optional dictionnary to use internally
+ * @dict: optional dictionary to use internally
*
* Creates a new context for manipulating expressions
*
return(NULL);
}
/*
- * check the string is in the dictionnary, if yes use an interned
+ * check the string is in the dictionary, if yes use an interned
* copy, otherwise we know it's not an acceptable input
*/
input = xmlDictExists(ctxt->dict, str, len);