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

Function xmlRegCompactPushString

ThirdParty/libxml2/vtklibxml2/xmlregexp.c:3621–3675  ·  view source on GitHub ↗

* xmlRegCompactPushString: * @exec: a regexp execution context * @comp: the precompiled exec with a compact table * @value: a string token input * @data: data associated to the token to reuse in callbacks * * Push one input token in the execution context * * Returns: 1 if the regexp reached a final state, 0 if non-final, and * a negative value in case of error. */

Source from the content-addressed store, hash-verified

3619 * a negative value in case of error.
3620 */
3621static int
3622xmlRegCompactPushString(xmlRegExecCtxtPtr exec,
3623 xmlRegexpPtr comp,
3624 const xmlChar *value,
3625 void *data) {
3626 int state = exec->index;
3627 int i, target;
3628
3629 if ((comp == NULL) || (comp->compact == NULL) || (comp->stringMap == NULL))
3630 return(-1);
3631
3632 if (value == NULL) {
3633 /*
3634 * are we at a final state ?
3635 */
3636 if (comp->compact[state * (comp->nbstrings + 1)] ==
3637 XML_REGEXP_FINAL_STATE)
3638 return(1);
3639 return(0);
3640 }
3641
3642 /*
3643 * Examine all outside transitions from current state
3644 */
3645 for (i = 0;i < comp->nbstrings;i++) {
3646 target = comp->compact[state * (comp->nbstrings + 1) + i + 1];
3647 if ((target > 0) && (target <= comp->nbstates)) {
3648 target--; /* to avoid 0 */
3649 if (xmlRegStrEqualWildcard(comp->stringMap[i], value)) {
3650 exec->index = target;
3651 if ((exec->callback != NULL) && (comp->transdata != NULL)) {
3652 exec->callback(exec->data, value,
3653 comp->transdata[state * comp->nbstrings + i], data);
3654 }
3655 if (comp->compact[target * (comp->nbstrings + 1)] ==
3656 XML_REGEXP_SINK_STATE)
3657 goto error;
3658
3659 if (comp->compact[target * (comp->nbstrings + 1)] ==
3660 XML_REGEXP_FINAL_STATE)
3661 return(1);
3662 return(0);
3663 }
3664 }
3665 }
3666 /*
3667 * Failed to find an exit transition out from current state for the
3668 * current token
3669 */
3670error:
3671 exec->errStateNo = state;
3672 exec->status = XML_REGEXP_NOT_FOUND;
3673 xmlRegExecSetErrString(exec, value);
3674 return(exec->status);
3675}
3676
3677/**
3678 * xmlRegExecPushStringInternal:

Callers 2

xmlRegExecPushString2Function · 0.85

Calls 3

xmlRegStrEqualWildcardFunction · 0.85
xmlRegExecSetErrStringFunction · 0.85
callbackMethod · 0.80

Tested by

no test coverage detected