Lines Matching refs:exec

3002 xmlFARegDebugExec(xmlRegExecCtxtPtr exec) {
3003 printf("state: %d:%d:idx %d", exec->state->no, exec->transno, exec->index);
3004 if (exec->inputStack != NULL) {
3007 for (i = 0;(i < 3) && (i < exec->inputStackNr);i++)
3009 exec->inputStack[exec->inputStackNr - (i + 1)].value);
3011 printf(": %s", &(exec->inputString[exec->index]));
3018 xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
3021 exec->transno++;
3022 xmlFARegDebugExec(exec);
3023 exec->transno--;
3026 if (exec->nbPush > MAX_PUSH) {
3029 exec->nbPush++;
3032 if (exec->maxRollbacks == 0) {
3033 exec->maxRollbacks = 4;
3034 exec->rollbacks = (xmlRegExecRollback *) xmlMalloc(exec->maxRollbacks *
3036 if (exec->rollbacks == NULL) {
3038 exec->maxRollbacks = 0;
3041 memset(exec->rollbacks, 0,
3042 exec->maxRollbacks * sizeof(xmlRegExecRollback));
3043 } else if (exec->nbRollbacks >= exec->maxRollbacks) {
3045 int len = exec->maxRollbacks;
3047 exec->maxRollbacks *= 2;
3048 tmp = (xmlRegExecRollback *) xmlRealloc(exec->rollbacks,
3049 exec->maxRollbacks * sizeof(xmlRegExecRollback));
3052 exec->maxRollbacks /= 2;
3055 exec->rollbacks = tmp;
3056 tmp = &exec->rollbacks[len];
3057 memset(tmp, 0, (exec->maxRollbacks - len) * sizeof(xmlRegExecRollback));
3059 exec->rollbacks[exec->nbRollbacks].state = exec->state;
3060 exec->rollbacks[exec->nbRollbacks].index = exec->index;
3061 exec->rollbacks[exec->nbRollbacks].nextbranch = exec->transno + 1;
3062 if (exec->comp->nbCounters > 0) {
3063 if (exec->rollbacks[exec->nbRollbacks].counts == NULL) {
3064 exec->rollbacks[exec->nbRollbacks].counts = (int *)
3065 xmlMalloc(exec->comp->nbCounters * sizeof(int));
3066 if (exec->rollbacks[exec->nbRollbacks].counts == NULL) {
3068 exec->status = -5;
3072 memcpy(exec->rollbacks[exec->nbRollbacks].counts, exec->counts,
3073 exec->comp->nbCounters * sizeof(int));
3075 exec->nbRollbacks++;
3079 xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) {
3080 if (exec->nbRollbacks <= 0) {
3081 exec->status = -1;
3087 exec->nbRollbacks--;
3088 exec->state = exec->rollbacks[exec->nbRollbacks].state;
3089 exec->index = exec->rollbacks[exec->nbRollbacks].index;
3090 exec->transno = exec->rollbacks[exec->nbRollbacks].nextbranch;
3091 if (exec->comp->nbCounters > 0) {
3092 if (exec->rollbacks[exec->nbRollbacks].counts == NULL) {
3093 fprintf(stderr, "exec save: allocation failed");
3094 exec->status = -6;
3097 memcpy(exec->counts, exec->rollbacks[exec->nbRollbacks].counts,
3098 exec->comp->nbCounters * sizeof(int));
3103 xmlFARegDebugExec(exec);
3116 xmlRegExecCtxtPtr exec = &execval;
3119 exec->inputString = content;
3120 exec->index = 0;
3121 exec->nbPush = 0;
3122 exec->determinist = 1;
3123 exec->maxRollbacks = 0;
3124 exec->nbRollbacks = 0;
3125 exec->rollbacks = NULL;
3126 exec->status = 0;
3127 exec->comp = comp;
3128 exec->state = comp->states[0];
3129 exec->transno = 0;
3130 exec->transcount = 0;
3131 exec->inputStack = NULL;
3132 exec->inputStackMax = 0;
3134 exec->counts = (int *) xmlMalloc(comp->nbCounters * sizeof(int));
3135 if (exec->counts == NULL) {
3139 memset(exec->counts, 0, comp->nbCounters * sizeof(int));
3141 exec->counts = NULL;
3142 while ((exec->status == 0) &&
3143 ((exec->inputString[exec->index] != 0) ||
3144 (exec->state->type != XML_REGEXP_FINAL_STATE))) {
3156 if ((exec->inputString[exec->index] == 0) && (exec->counts == NULL)) {
3161 if (exec->transno < exec->state->nbTrans) {
3162 trans = &exec->state->trans[exec->transno];
3172 exec->transcount = 0;
3173 for (;exec->transno < exec->state->nbTrans;exec->transno++) {
3174 trans = &exec->state->trans[exec->transno];
3184 if (exec->counts == NULL) {
3185 exec->status = -1;
3192 count = exec->counts[trans->count];
3193 counter = &exec->comp->counters[trans->count];
3203 exec->status = -2;
3205 } else if (exec->inputString[exec->index] != 0) {
3206 codepoint = CUR_SCHAR(&(exec->inputString[exec->index]), len);
3221 if ((exec->counts == NULL) ||
3222 (exec->comp == NULL) ||
3223 (exec->comp->counters == NULL)) {
3224 exec->status = -1;
3227 counter = &exec->comp->counters[trans->counter];
3228 if (exec->counts[trans->counter] >= counter->max)
3234 exec->counts[trans->counter]++;
3236 if (exec->state->nbTrans > exec->transno + 1) {
3237 xmlFARegExecSave(exec);
3239 exec->transcount = 1;
3244 if (exec->transcount == atom->max) {
3247 exec->index += len;
3251 if (exec->inputString[exec->index] == 0) {
3252 exec->index -= len;
3255 if (exec->transcount >= atom->min) {
3256 int transno = exec->transno;
3257 xmlRegStatePtr state = exec->state;
3262 exec->transno = -1; /* trick */
3263 exec->state = to;
3264 xmlFARegExecSave(exec);
3265 exec->transno = transno;
3266 exec->state = state;
3268 codepoint = CUR_SCHAR(&(exec->inputString[exec->index]),
3271 exec->transcount++;
3273 if (exec->transcount < atom->min)
3286 if (exec->counts == NULL) {
3287 exec->status = -1;
3293 exec->counts[trans->counter]--;
3301 exec->transcount = 1;
3307 exec->transcount = 1;
3314 (exec->state->nbTrans > exec->transno + 1))) {
3318 trans->atom->no, codepoint, exec->index);
3321 trans->count, codepoint, exec->index);
3323 xmlFARegExecSave(exec);
3329 if ((exec->counts == NULL) ||
3330 (exec->comp == NULL) ||
3331 (exec->comp->counters == NULL)) {
3332 exec->status = -1;
3335 counter = &exec->comp->counters[trans->counter];
3336 if (exec->counts[trans->counter] >= counter->max)
3341 exec->counts[trans->counter]++;
3345 if (exec->counts == NULL) {
3346 exec->status = -1;
3353 exec->counts[trans->count] = 0;
3358 exec->state = comp->states[trans->to];
3359 exec->transno = 0;
3361 exec->index += len;
3365 exec->status = -4;
3369 if ((exec->transno != 0) || (exec->state->nbTrans == 0)) {
3374 exec->determinist = 0;
3376 printf("rollback from state %d on %d:%c\n", exec->state->no,
3379 xmlFARegExecRollBack(exec);
3385 if (exec->rollbacks != NULL) {
3386 if (exec->counts != NULL) {
3389 for (i = 0;i < exec->maxRollbacks;i++)
3390 if (exec->rollbacks[i].counts != NULL)
3391 xmlFree(exec->rollbacks[i].counts);
3393 xmlFree(exec->rollbacks);
3395 if (exec->counts != NULL)
3396 xmlFree(exec->counts);
3397 if (exec->status == 0)
3399 if (exec->status == -1) {
3400 if (exec->nbPush > MAX_PUSH)
3404 return(exec->status);
3413 static void testerr(xmlRegExecCtxtPtr exec);
3429 xmlRegExecCtxtPtr exec;
3435 exec = (xmlRegExecCtxtPtr) xmlMalloc(sizeof(xmlRegExecCtxt));
3436 if (exec == NULL) {
3440 memset(exec, 0, sizeof(xmlRegExecCtxt));
3441 exec->inputString = NULL;
3442 exec->index = 0;
3443 exec->determinist = 1;
3444 exec->maxRollbacks = 0;
3445 exec->nbRollbacks = 0;
3446 exec->rollbacks = NULL;
3447 exec->status = 0;
3448 exec->comp = comp;
3450 exec->state = comp->states[0];
3451 exec->transno = 0;
3452 exec->transcount = 0;
3453 exec->callback = callback;
3454 exec->data = data;
3457 * For error handling, exec->counts is allocated twice the size
3460 exec->counts = (int *) xmlMalloc(comp->nbCounters * sizeof(int)
3462 if (exec->counts == NULL) {
3464 xmlFree(exec);
3467 memset(exec->counts, 0, comp->nbCounters * sizeof(int) * 2);
3468 exec->errCounts = &exec->counts[comp->nbCounters];
3470 exec->counts = NULL;
3471 exec->errCounts = NULL;
3473 exec->inputStackMax = 0;
3474 exec->inputStackNr = 0;
3475 exec->inputStack = NULL;
3476 exec->errStateNo = -1;
3477 exec->errString = NULL;
3478 exec->nbPush = 0;
3479 return(exec);
3484 * @exec: a regular expression evaulation context
3489 xmlRegFreeExecCtxt(xmlRegExecCtxtPtr exec) {
3490 if (exec == NULL)
3493 if (exec->rollbacks != NULL) {
3494 if (exec->counts != NULL) {
3497 for (i = 0;i < exec->maxRollbacks;i++)
3498 if (exec->rollbacks[i].counts != NULL)
3499 xmlFree(exec->rollbacks[i].counts);
3501 xmlFree(exec->rollbacks);
3503 if (exec->counts != NULL)
3504 xmlFree(exec->counts);
3505 if (exec->inputStack != NULL) {
3508 for (i = 0;i < exec->inputStackNr;i++) {
3509 if (exec->inputStack[i].value != NULL)
3510 xmlFree(exec->inputStack[i].value);
3512 xmlFree(exec->inputStack);
3514 if (exec->errString != NULL)
3515 xmlFree(exec->errString);
3516 xmlFree(exec);
3520 xmlFARegExecSaveInputString(xmlRegExecCtxtPtr exec, const xmlChar *value,
3523 printf("saving value: %d:%s\n", exec->inputStackNr, value);
3525 if (exec->inputStackMax == 0) {
3526 exec->inputStackMax = 4;
3527 exec->inputStack = (xmlRegInputTokenPtr)
3528 xmlMalloc(exec->inputStackMax * sizeof(xmlRegInputToken));
3529 if (exec->inputStack == NULL) {
3531 exec->inputStackMax = 0;
3534 } else if (exec->inputStackNr + 1 >= exec->inputStackMax) {
3537 exec->inputStackMax *= 2;
3538 tmp = (xmlRegInputTokenPtr) xmlRealloc(exec->inputStack,
3539 exec->inputStackMax * sizeof(xmlRegInputToken));
3542 exec->inputStackMax /= 2;
3545 exec->inputStack = tmp;
3547 exec->inputStack[exec->inputStackNr].value = xmlStrdup(value);
3548 exec->inputStack[exec->inputStackNr].data = data;
3549 exec->inputStackNr++;
3550 exec->inputStack[exec->inputStackNr].value = NULL;
3551 exec->inputStack[exec->inputStackNr].data = NULL;
3606 * @exec: a regexp execution context
3607 * @comp: the precompiled exec with a compact table
3617 xmlRegCompactPushString(xmlRegExecCtxtPtr exec,
3621 int state = exec->index;
3649 exec->index = target;
3650 if ((exec->callback != NULL) && (comp->transdata != NULL)) {
3651 exec->callback(exec->data, value,
3676 if (exec->errString != NULL)
3677 xmlFree(exec->errString);
3678 exec->errString = xmlStrdup(value);
3679 exec->errStateNo = state;
3680 exec->status = -1;
3682 testerr(exec);
3689 * @exec: a regexp execution context or NULL to indicate the end
3700 xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
3708 if (exec == NULL)
3710 if (exec->comp == NULL)
3712 if (exec->status != 0)
3713 return(exec->status);
3715 if (exec->comp->compact != NULL)
3716 return(xmlRegCompactPushString(exec, exec->comp, value, data));
3719 if (exec->state->type == XML_REGEXP_FINAL_STATE)
3731 if ((value != NULL) && (exec->inputStackNr > 0)) {
3732 xmlFARegExecSaveInputString(exec, value, data);
3733 value = exec->inputStack[exec->index].value;
3734 data = exec->inputStack[exec->index].data;
3740 while ((exec->status == 0) &&
3743 (exec->state->type != XML_REGEXP_FINAL_STATE)))) {
3750 if ((value == NULL) && (exec->counts == NULL))
3753 exec->transcount = 0;
3754 for (;exec->transno < exec->state->nbTrans;exec->transno++) {
3755 trans = &exec->state->trans[exec->transno];
3777 for (i = 0;i < exec->state->nbTrans;i++) {
3778 t = &exec->state->trans[i];
3781 counter = &exec->comp->counters[t->counter];
3782 count = exec->counts[t->counter];
3812 for (i = 0;i < exec->state->nbTrans;i++) {
3813 t = &exec->state->trans[i];
3816 counter = &exec->comp->counters[t->counter];
3817 count = exec->counts[t->counter];
3831 count = exec->counts[trans->count];
3832 counter = &exec->comp->counters[trans->count];
3840 exec->status = -2;
3853 count = exec->counts[trans->counter];
3854 counter = &exec->comp->counters[trans->counter];
3860 xmlRegStatePtr to = exec->comp->states[trans->to];
3865 if (exec->state->nbTrans > exec->transno + 1) {
3866 if (exec->inputStackNr <= 0) {
3867 xmlFARegExecSaveInputString(exec, value, data);
3869 xmlFARegExecSave(exec);
3871 exec->transcount = 1;
3876 if (exec->transcount == atom->max) {
3879 exec->index++;
3880 value = exec->inputStack[exec->index].value;
3881 data = exec->inputStack[exec->index].data;
3890 exec->index --;
3893 if (exec->transcount >= atom->min) {
3894 int transno = exec->transno;
3895 xmlRegStatePtr state = exec->state;
3900 exec->transno = -1; /* trick */
3901 exec->state = to;
3902 if (exec->inputStackNr <= 0) {
3903 xmlFARegExecSaveInputString(exec, value, data);
3905 xmlFARegExecSave(exec);
3906 exec->transno = transno;
3907 exec->state = state;
3910 exec->transcount++;
3912 if (exec->transcount < atom->min)
3927 if ((exec->callback != NULL) && (atom != NULL) &&
3929 exec->callback(exec->data, atom->valuep,
3932 if (exec->state->nbTrans > exec->transno + 1) {
3933 if (exec->inputStackNr <= 0) {
3934 xmlFARegExecSaveInputString(exec, value, data);
3936 xmlFARegExecSave(exec);
3942 exec->counts[trans->counter]++;
3950 exec->counts[trans->count] = 0;
3955 if ((exec->comp->states[trans->to] != NULL) &&
3956 (exec->comp->states[trans->to]->type ==
3962 if (exec->errString != NULL)
3963 xmlFree(exec->errString);
3964 exec->errString = xmlStrdup(value);
3965 exec->errState = exec->state;
3966 memcpy(exec->errCounts, exec->counts,
3967 exec->comp->nbCounters * sizeof(int));
3969 exec->state = exec->comp->states[trans->to];
3970 exec->transno = 0;
3972 if (exec->inputStack != NULL) {
3973 exec->index++;
3974 if (exec->index < exec->inputStackNr) {
3975 value = exec->inputStack[exec->index].value;
3976 data = exec->inputStack[exec->index].data;
3997 exec->status = -4;
4001 if ((exec->transno != 0) || (exec->state->nbTrans == 0)) {
4007 if ((progress) && (exec->state != NULL) &&
4008 (exec->state->type != XML_REGEXP_SINK_STATE)) {
4010 if (exec->errString != NULL)
4011 xmlFree(exec->errString);
4012 exec->errString = xmlStrdup(value);
4013 exec->errState = exec->state;
4014 memcpy(exec->errCounts, exec->counts,
4015 exec->comp->nbCounters * sizeof(int));
4021 exec->determinist = 0;
4022 xmlFARegExecRollBack(exec);
4023 if (exec->status == 0) {
4024 value = exec->inputStack[exec->index].value;
4025 data = exec->inputStack[exec->index].data;
4036 if (exec->status == 0) {
4037 return(exec->state->type == XML_REGEXP_FINAL_STATE);
4040 if (exec->status < 0) {
4041 testerr(exec);
4044 return(exec->status);
4049 * @exec: a regexp execution context or NULL to indicate the end
4059 xmlRegExecPushString(xmlRegExecCtxtPtr exec, const xmlChar *value,
4061 return(xmlRegExecPushStringInternal(exec, value, data, 0));
4066 * @exec: a regexp execution context or NULL to indicate the end
4077 xmlRegExecPushString2(xmlRegExecCtxtPtr exec, const xmlChar *value,
4083 if (exec == NULL)
4085 if (exec->comp == NULL)
4087 if (exec->status != 0)
4088 return(exec->status);
4091 return(xmlRegExecPushString(exec, value, data));
4099 exec->status = -1;
4110 if (exec->comp->compact != NULL)
4111 ret = xmlRegCompactPushString(exec, exec->comp, str, data);
4113 ret = xmlRegExecPushStringInternal(exec, str, data, 1);
4122 * @exec: a regexp execution context
4135 xmlRegExecGetValues(xmlRegExecCtxtPtr exec, int err,
4141 if ((exec == NULL) || (nbval == NULL) || (nbneg == NULL) ||
4148 if ((exec->comp != NULL) && (exec->comp->compact != NULL)) {
4152 comp = exec->comp;
4155 if (exec->errStateNo == -1) return(-1);
4156 state = exec->errStateNo;
4158 state = exec->index;
4192 if (exec->state->type == XML_REGEXP_FINAL_STATE)
4199 if (exec->errState == NULL) return(-1);
4200 state = exec->errState;
4202 if (exec->state == NULL) return(-1);
4203 state = exec->state;
4225 count = exec->errCounts[trans->counter];
4227 count = exec->counts[trans->counter];
4228 if (exec->comp != NULL)
4229 counter = &exec->comp->counters[trans->counter];
4238 if ((exec->comp->states[trans->to] != NULL) &&
4239 (exec->comp->states[trans->to]->type !=
4265 if ((exec->comp->states[trans->to] != NULL) &&
4266 (exec->comp->states[trans->to]->type ==
4282 * @exec: a regexp execution context
4292 * returned will be freed with the @exec context and don't need to be
4298 xmlRegExecNextValues(xmlRegExecCtxtPtr exec, int *nbval, int *nbneg,
4300 return(xmlRegExecGetValues(exec, 0, nbval, nbneg, values, terminal));
4305 * @exec: a regexp execution context generating an error
4317 * returned will be freed with the @exec context and don't need to be
4323 xmlRegExecErrInfo(xmlRegExecCtxtPtr exec, const xmlChar **string,
4325 if (exec == NULL)
4328 if (exec->status != 0)
4329 *string = exec->errString;
4333 return(xmlRegExecGetValues(exec, 1, nbval, nbneg, values, terminal));
4337 static void testerr(xmlRegExecCtxtPtr exec) {
4343 xmlRegExecErrInfo(exec, &string, &nb, &nbneg, &values[0], &terminal);
4349 xmlRegExecPushChar(xmlRegExecCtxtPtr exec, int UCS) {
4355 if (exec == NULL)
4357 if (exec->status != 0)
4358 return(exec->status);
4360 while ((exec->status == 0) &&
4361 ((exec->inputString[exec->index] != 0) ||
4362 (exec->state->type != XML_REGEXP_FINAL_STATE))) {
4369 if ((exec->inputString[exec->index] == 0) && (exec->counts == NULL))
4372 exec->transcount = 0;
4373 for (;exec->transno < exec->state->nbTrans;exec->transno++) {
4374 trans = &exec->state->trans[exec->transno];
4387 count = exec->counts[trans->count];
4388 counter = &exec->comp->counters[trans->count];
4396 exec->status = -2;
4398 } else if (exec->inputString[exec->index] != 0) {
4399 codepoint = CUR_SCHAR(&(exec->inputString[exec->index]), len);
4402 xmlRegStatePtr to = exec->comp->states[trans->to];
4407 if (exec->state->nbTrans > exec->transno + 1) {
4408 xmlFARegExecSave(exec);
4410 exec->transcount = 1;
4415 if (exec->transcount == atom->max) {
4418 exec->index += len;
4422 if (exec->inputString[exec->index] == 0) {
4423 exec->index -= len;
4426 if (exec->transcount >= atom->min) {
4427 int transno = exec->transno;
4428 xmlRegStatePtr state = exec->state;
4433 exec->transno = -1; /* trick */
4434 exec->state = to;
4435 xmlFARegExecSave(exec);
4436 exec->transno = transno;
4437 exec->state = state;
4439 codepoint = CUR_SCHAR(&(exec->inputString[exec->index]),
4442 exec->transcount++;
4444 if (exec->transcount < atom->min)
4459 if (exec->state->nbTrans > exec->transno + 1) {
4460 xmlFARegExecSave(exec);
4469 exec->counts[trans->count] = 0;
4475 exec->counts[trans->counter]++;
4480 exec->state = exec->comp->states[trans->to];
4481 exec->transno = 0;
4483 exec->index += len;
4487 exec->status = -4;
4491 if ((exec->transno != 0) || (exec->state->nbTrans == 0)) {
4496 exec->determinist = 0;
4497 xmlFARegExecRollBack(exec);