1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

fixing behaviour for xmlRegExecErrInfo in case of rollback Daniel

* xmlregexp.c: fixing behaviour for xmlRegExecErrInfo in case of
  rollback
Daniel
This commit is contained in:
Daniel Veillard
2005-01-08 22:05:09 +00:00
parent 7bd8b4b817
commit 9070015b40
2 changed files with 27 additions and 8 deletions

View File

@ -1,3 +1,8 @@
Sat Jan 8 23:04:10 CET 2005 Daniel Veillard <daniel@veillard.com>
* xmlregexp.c: fixing behaviour for xmlRegExecErrInfo in case of
rollback
Fri Jan 7 14:54:51 CET 2005 Daniel Veillard <daniel@veillard.com> Fri Jan 7 14:54:51 CET 2005 Daniel Veillard <daniel@veillard.com>
* TODO: small update * TODO: small update

View File

@ -2738,6 +2738,7 @@ xmlRegExecPushString(xmlRegExecCtxtPtr exec, const xmlChar *value,
xmlRegAtomPtr atom; xmlRegAtomPtr atom;
int ret; int ret;
int final = 0; int final = 0;
int progress = 1;
if (exec == NULL) if (exec == NULL)
return(-1); return(-1);
@ -3006,6 +3007,20 @@ xmlRegExecPushString(xmlRegExecCtxtPtr exec, const xmlChar *value,
} }
if ((exec->transno != 0) || (exec->state->nbTrans == 0)) { if ((exec->transno != 0) || (exec->state->nbTrans == 0)) {
rollback: rollback:
/*
* if we didn't yet rollback on the current input store
* the current state as the error state.
*/
if (progress) {
progress = 0;
if (exec->errString != NULL)
xmlFree(exec->errString);
exec->errString = xmlStrdup(value);
exec->errState = exec->state;
memcpy(exec->errCounts, exec->counts,
exec->comp->nbCounters * sizeof(int));
}
/* /*
* Failed to find a way out * Failed to find a way out
*/ */
@ -3019,21 +3034,19 @@ rollback:
#endif #endif
} }
} }
continue;
progress: progress:
progress = 1;
continue; continue;
} }
if (exec->status == 0) { if (exec->status == 0) {
return(exec->state->type == XML_REGEXP_FINAL_STATE); return(exec->state->type == XML_REGEXP_FINAL_STATE);
} }
if (exec->status < 0) {
if (exec->errString != NULL)
xmlFree(exec->errString);
exec->errString = xmlStrdup(value);
exec->errState = exec->state;
#ifdef DEBUG_ERR #ifdef DEBUG_ERR
if (exec->status < 0) {
testerr(exec); testerr(exec);
#endif
} }
#endif
return(exec->status); return(exec->status);
} }
@ -3105,7 +3118,8 @@ xmlRegExecPushString2(xmlRegExecCtxtPtr exec, const xmlChar *value,
* the parameter @values must point to an array of @nbval string pointers * the parameter @values must point to an array of @nbval string pointers
* on return nbval will contain the number of possible strings in that * on return nbval will contain the number of possible strings in that
* state and the @values array will be updated with them. The string values * state and the @values array will be updated with them. The string values
* returned will be freed with the @exec context. * returned will be freed with the @exec context and don't need to be
* deallocated.
* *
* Returns: 0 in case of success or -1 in case of error. * Returns: 0 in case of success or -1 in case of error.
*/ */
@ -3163,7 +3177,7 @@ xmlRegExecErrInfo(xmlRegExecCtxtPtr exec, const xmlChar **string,
xmlRegCounterPtr counter; xmlRegCounterPtr counter;
int count; int count;
count = exec->counts[trans->counter]; count = exec->errCounts[trans->counter];
counter = &exec->comp->counters[trans->counter]; counter = &exec->comp->counters[trans->counter];
if (count < counter->max) { if (count < counter->max) {
values[*nbval] = (const xmlChar *) atom->valuep; values[*nbval] = (const xmlChar *) atom->valuep;