Lines Matching +full:- +full:exec
7 * - XML-1.0 DTD validation
8 * - XML Schemas structure part 1
9 * - XML Schemas Datatypes part 2 especially Appendix F
10 * - RELAX-NG/TREX i.e. the counter proposal
36 #define SIZE_MAX ((size_t) -1)
45 ctxt->error = XML_REGEXP_COMPILE_ERROR; \
47 #define NEXT ctxt->cur++
48 #define CUR (*(ctxt->cur))
49 #define NXT(index) (ctxt->cur[index])
51 #define NEXTL(l) ctxt->cur += l;
54 * Need PREV to check on a '-' within a Character Group. May only be used
55 * when it's guaranteed that cur is not at the beginning of ctxt->string!
57 #define PREV (ctxt->cur[-1])
364 ctxt->error = XML_ERR_NO_MEMORY; in xmlRegexpErrMemory()
383 regexp = (const char *) ctxt->string; in xmlRegexpErrCompile()
384 idx = ctxt->cur - ctxt->string; in xmlRegexpErrCompile()
385 ctxt->error = XML_REGEXP_COMPILE_ERROR; in xmlRegexpErrCompile()
410 * Allocate a two-dimensional array and set all elements to zero.
448 ret->string = ctxt->string; in xmlRegEpxFromParse()
449 ret->nbStates = ctxt->nbStates; in xmlRegEpxFromParse()
450 ret->states = ctxt->states; in xmlRegEpxFromParse()
451 ret->nbAtoms = ctxt->nbAtoms; in xmlRegEpxFromParse()
452 ret->atoms = ctxt->atoms; in xmlRegEpxFromParse()
453 ret->nbCounters = ctxt->nbCounters; in xmlRegEpxFromParse()
454 ret->counters = ctxt->counters; in xmlRegEpxFromParse()
455 ret->determinist = ctxt->determinist; in xmlRegEpxFromParse()
456 ret->flags = ctxt->flags; in xmlRegEpxFromParse()
457 if (ret->determinist == -1) { in xmlRegEpxFromParse()
465 if ((ret->determinist != 0) && in xmlRegEpxFromParse()
466 (ret->nbCounters == 0) && in xmlRegEpxFromParse()
467 (ctxt->negs == 0) && in xmlRegEpxFromParse()
468 (ret->atoms != NULL) && in xmlRegEpxFromParse()
469 (ret->atoms[0] != NULL) && in xmlRegEpxFromParse()
470 (ret->atoms[0]->type == XML_REGEXP_STRING)) { in xmlRegEpxFromParse()
487 stateRemap = xmlMalloc(ret->nbStates * sizeof(int)); in xmlRegEpxFromParse()
493 for (i = 0;i < ret->nbStates;i++) { in xmlRegEpxFromParse()
494 if (ret->states[i] != NULL) { in xmlRegEpxFromParse()
498 stateRemap[i] = -1; in xmlRegEpxFromParse()
501 stringMap = xmlMalloc(ret->nbAtoms * sizeof(char *)); in xmlRegEpxFromParse()
508 stringRemap = xmlMalloc(ret->nbAtoms * sizeof(int)); in xmlRegEpxFromParse()
516 for (i = 0;i < ret->nbAtoms;i++) { in xmlRegEpxFromParse()
517 if ((ret->atoms[i]->type == XML_REGEXP_STRING) && in xmlRegEpxFromParse()
518 (ret->atoms[i]->quant == XML_REGEXP_QUANT_ONCE)) { in xmlRegEpxFromParse()
519 value = ret->atoms[i]->valuep; in xmlRegEpxFromParse()
568 for (i = 0;i < ret->nbStates;i++) { in xmlRegEpxFromParse()
574 if (stateno == -1) in xmlRegEpxFromParse()
576 state = ret->states[i]; in xmlRegEpxFromParse()
578 transitions[stateno * (nbatoms + 1)] = state->type; in xmlRegEpxFromParse()
580 for (j = 0;j < state->nbTrans;j++) { in xmlRegEpxFromParse()
581 trans = &(state->trans[j]); in xmlRegEpxFromParse()
582 if ((trans->to < 0) || (trans->atom == NULL)) in xmlRegEpxFromParse()
584 atomno = stringRemap[trans->atom->no]; in xmlRegEpxFromParse()
585 if ((trans->atom->data != NULL) && (transdata == NULL)) { in xmlRegEpxFromParse()
593 targetno = stateRemap[trans->to]; in xmlRegEpxFromParse()
602 ret->determinist = 0; in xmlRegEpxFromParse()
618 trans->atom->data; in xmlRegEpxFromParse()
622 ret->determinist = 1; in xmlRegEpxFromParse()
626 if (ret->states != NULL) { in xmlRegEpxFromParse()
627 for (i = 0;i < ret->nbStates;i++) in xmlRegEpxFromParse()
628 xmlRegFreeState(ret->states[i]); in xmlRegEpxFromParse()
629 xmlFree(ret->states); in xmlRegEpxFromParse()
631 ret->states = NULL; in xmlRegEpxFromParse()
632 ret->nbStates = 0; in xmlRegEpxFromParse()
633 if (ret->atoms != NULL) { in xmlRegEpxFromParse()
634 for (i = 0;i < ret->nbAtoms;i++) in xmlRegEpxFromParse()
635 xmlRegFreeAtom(ret->atoms[i]); in xmlRegEpxFromParse()
636 xmlFree(ret->atoms); in xmlRegEpxFromParse()
638 ret->atoms = NULL; in xmlRegEpxFromParse()
639 ret->nbAtoms = 0; in xmlRegEpxFromParse()
641 ret->compact = transitions; in xmlRegEpxFromParse()
642 ret->transdata = transdata; in xmlRegEpxFromParse()
643 ret->stringMap = stringMap; in xmlRegEpxFromParse()
644 ret->nbstrings = nbatoms; in xmlRegEpxFromParse()
645 ret->nbstates = nbstates; in xmlRegEpxFromParse()
650 ctxt->string = NULL; in xmlRegEpxFromParse()
651 ctxt->nbStates = 0; in xmlRegEpxFromParse()
652 ctxt->states = NULL; in xmlRegEpxFromParse()
653 ctxt->nbAtoms = 0; in xmlRegEpxFromParse()
654 ctxt->atoms = NULL; in xmlRegEpxFromParse()
655 ctxt->nbCounters = 0; in xmlRegEpxFromParse()
656 ctxt->counters = NULL; in xmlRegEpxFromParse()
677 ret->string = xmlStrdup(string); in xmlRegNewParserCtxt()
678 if (ret->string == NULL) { in xmlRegNewParserCtxt()
683 ret->cur = ret->string; in xmlRegNewParserCtxt()
684 ret->neg = 0; in xmlRegNewParserCtxt()
685 ret->negs = 0; in xmlRegNewParserCtxt()
686 ret->error = 0; in xmlRegNewParserCtxt()
687 ret->determinist = -1; in xmlRegNewParserCtxt()
713 ret->neg = neg; in xmlRegNewRange()
714 ret->type = type; in xmlRegNewRange()
715 ret->start = start; in xmlRegNewRange()
716 ret->end = end; in xmlRegNewRange()
731 if (range->blockName != NULL) in xmlRegFreeRange()
732 xmlFree(range->blockName); in xmlRegFreeRange()
751 ret = xmlRegNewRange(ctxt, range->neg, range->type, range->start, in xmlRegCopyRange()
752 range->end); in xmlRegCopyRange()
755 if (range->blockName != NULL) { in xmlRegCopyRange()
756 ret->blockName = xmlStrdup(range->blockName); in xmlRegCopyRange()
757 if (ret->blockName == NULL) { in xmlRegCopyRange()
785 ret->type = type; in xmlRegNewAtom()
786 ret->quant = XML_REGEXP_QUANT_ONCE; in xmlRegNewAtom()
787 ret->min = 0; in xmlRegNewAtom()
788 ret->max = 0; in xmlRegNewAtom()
805 for (i = 0;i < atom->nbRanges;i++) in xmlRegFreeAtom()
806 xmlRegFreeRange(atom->ranges[i]); in xmlRegFreeAtom()
807 if (atom->ranges != NULL) in xmlRegFreeAtom()
808 xmlFree(atom->ranges); in xmlRegFreeAtom()
809 if ((atom->type == XML_REGEXP_STRING) && (atom->valuep != NULL)) in xmlRegFreeAtom()
810 xmlFree(atom->valuep); in xmlRegFreeAtom()
811 if ((atom->type == XML_REGEXP_STRING) && (atom->valuep2 != NULL)) in xmlRegFreeAtom()
812 xmlFree(atom->valuep2); in xmlRegFreeAtom()
813 if ((atom->type == XML_REGEXP_BLOCK_NAME) && (atom->valuep != NULL)) in xmlRegFreeAtom()
814 xmlFree(atom->valuep); in xmlRegFreeAtom()
837 ret->type = atom->type; in xmlRegCopyAtom()
838 ret->quant = atom->quant; in xmlRegCopyAtom()
839 ret->min = atom->min; in xmlRegCopyAtom()
840 ret->max = atom->max; in xmlRegCopyAtom()
841 if (atom->nbRanges > 0) { in xmlRegCopyAtom()
844 ret->ranges = (xmlRegRangePtr *) xmlMalloc(sizeof(xmlRegRangePtr) * in xmlRegCopyAtom()
845 atom->nbRanges); in xmlRegCopyAtom()
846 if (ret->ranges == NULL) { in xmlRegCopyAtom()
850 for (i = 0;i < atom->nbRanges;i++) { in xmlRegCopyAtom()
851 ret->ranges[i] = xmlRegCopyRange(ctxt, atom->ranges[i]); in xmlRegCopyAtom()
852 if (ret->ranges[i] == NULL) in xmlRegCopyAtom()
854 ret->nbRanges = i + 1; in xmlRegCopyAtom()
874 ret->type = XML_REGEXP_TRANS_STATE; in xmlRegNewState()
875 ret->mark = XML_REGEXP_MARK_NORMAL; in xmlRegNewState()
890 if (state->trans != NULL) in xmlRegFreeState()
891 xmlFree(state->trans); in xmlRegFreeState()
892 if (state->transTo != NULL) in xmlRegFreeState()
893 xmlFree(state->transTo); in xmlRegFreeState()
909 if (ctxt->string != NULL) in xmlRegFreeParserCtxt()
910 xmlFree(ctxt->string); in xmlRegFreeParserCtxt()
911 if (ctxt->states != NULL) { in xmlRegFreeParserCtxt()
912 for (i = 0;i < ctxt->nbStates;i++) in xmlRegFreeParserCtxt()
913 xmlRegFreeState(ctxt->states[i]); in xmlRegFreeParserCtxt()
914 xmlFree(ctxt->states); in xmlRegFreeParserCtxt()
916 if (ctxt->atoms != NULL) { in xmlRegFreeParserCtxt()
917 for (i = 0;i < ctxt->nbAtoms;i++) in xmlRegFreeParserCtxt()
918 xmlRegFreeAtom(ctxt->atoms[i]); in xmlRegFreeParserCtxt()
919 xmlFree(ctxt->atoms); in xmlRegFreeParserCtxt()
921 if (ctxt->counters != NULL) in xmlRegFreeParserCtxt()
922 xmlFree(ctxt->counters); in xmlRegFreeParserCtxt()
1068 if (range->neg) in xmlRegPrintRange()
1070 xmlRegPrintAtomType(output, range->type); in xmlRegPrintRange()
1071 fprintf(output, "%c - %c\n", range->start, range->end); in xmlRegPrintRange()
1081 if (atom->neg) in xmlRegPrintAtom()
1083 xmlRegPrintAtomType(output, atom->type); in xmlRegPrintAtom()
1084 xmlRegPrintQuantType(output, atom->quant); in xmlRegPrintAtom()
1085 if (atom->quant == XML_REGEXP_QUANT_RANGE) in xmlRegPrintAtom()
1086 fprintf(output, "%d-%d ", atom->min, atom->max); in xmlRegPrintAtom()
1087 if (atom->type == XML_REGEXP_STRING) in xmlRegPrintAtom()
1088 fprintf(output, "'%s' ", (char *) atom->valuep); in xmlRegPrintAtom()
1089 if (atom->type == XML_REGEXP_CHARVAL) in xmlRegPrintAtom()
1090 fprintf(output, "char %c\n", atom->codepoint); in xmlRegPrintAtom()
1091 else if (atom->type == XML_REGEXP_RANGES) { in xmlRegPrintAtom()
1093 fprintf(output, "%d entries\n", atom->nbRanges); in xmlRegPrintAtom()
1094 for (i = 0; i < atom->nbRanges;i++) in xmlRegPrintAtom()
1095 xmlRegPrintRange(output, atom->ranges[i]); in xmlRegPrintAtom()
1096 } else if (atom->type == XML_REGEXP_SUBREG) { in xmlRegPrintAtom()
1097 fprintf(output, "start %d end %d\n", atom->start->no, atom->stop->no); in xmlRegPrintAtom()
1110 if (trans->to < 0) { in xmlRegPrintTrans()
1114 if (trans->nd != 0) { in xmlRegPrintTrans()
1115 if (trans->nd == 2) in xmlRegPrintTrans()
1120 if (trans->counter >= 0) { in xmlRegPrintTrans()
1121 fprintf(output, "counted %d, ", trans->counter); in xmlRegPrintTrans()
1123 if (trans->count == REGEXP_ALL_COUNTER) { in xmlRegPrintTrans()
1125 } else if (trans->count >= 0) { in xmlRegPrintTrans()
1126 fprintf(output, "count based %d, ", trans->count); in xmlRegPrintTrans()
1128 if (trans->atom == NULL) { in xmlRegPrintTrans()
1129 fprintf(output, "epsilon to %d\n", trans->to); in xmlRegPrintTrans()
1132 if (trans->atom->type == XML_REGEXP_CHARVAL) in xmlRegPrintTrans()
1133 fprintf(output, "char %c ", trans->atom->codepoint); in xmlRegPrintTrans()
1134 fprintf(output, "atom %d, to %d\n", trans->atom->no, trans->to); in xmlRegPrintTrans()
1146 if (state->type == XML_REGEXP_START_STATE) in xmlRegPrintState()
1148 if (state->type == XML_REGEXP_FINAL_STATE) in xmlRegPrintState()
1151 fprintf(output, "%d, %d transitions:\n", state->no, state->nbTrans); in xmlRegPrintState()
1152 for (i = 0;i < state->nbTrans; i++) { in xmlRegPrintState()
1153 xmlRegPrintTrans(output, &(state->trans[i])); in xmlRegPrintState()
1173 if (atom->type != XML_REGEXP_RANGES) { in xmlRegAtomAddRange()
1177 if (atom->maxRanges == 0) { in xmlRegAtomAddRange()
1178 atom->maxRanges = 4; in xmlRegAtomAddRange()
1179 atom->ranges = (xmlRegRangePtr *) xmlMalloc(atom->maxRanges * in xmlRegAtomAddRange()
1181 if (atom->ranges == NULL) { in xmlRegAtomAddRange()
1183 atom->maxRanges = 0; in xmlRegAtomAddRange()
1186 } else if (atom->nbRanges >= atom->maxRanges) { in xmlRegAtomAddRange()
1188 atom->maxRanges *= 2; in xmlRegAtomAddRange()
1189 tmp = (xmlRegRangePtr *) xmlRealloc(atom->ranges, atom->maxRanges * in xmlRegAtomAddRange()
1193 atom->maxRanges /= 2; in xmlRegAtomAddRange()
1196 atom->ranges = tmp; in xmlRegAtomAddRange()
1201 range->blockName = blockName; in xmlRegAtomAddRange()
1202 atom->ranges[atom->nbRanges++] = range; in xmlRegAtomAddRange()
1209 if (ctxt->maxCounters == 0) { in xmlRegGetCounter()
1210 ctxt->maxCounters = 4; in xmlRegGetCounter()
1211 ctxt->counters = (xmlRegCounter *) xmlMalloc(ctxt->maxCounters * in xmlRegGetCounter()
1213 if (ctxt->counters == NULL) { in xmlRegGetCounter()
1215 ctxt->maxCounters = 0; in xmlRegGetCounter()
1216 return(-1); in xmlRegGetCounter()
1218 } else if (ctxt->nbCounters >= ctxt->maxCounters) { in xmlRegGetCounter()
1220 ctxt->maxCounters *= 2; in xmlRegGetCounter()
1221 tmp = (xmlRegCounter *) xmlRealloc(ctxt->counters, ctxt->maxCounters * in xmlRegGetCounter()
1225 ctxt->maxCounters /= 2; in xmlRegGetCounter()
1226 return(-1); in xmlRegGetCounter()
1228 ctxt->counters = tmp; in xmlRegGetCounter()
1230 ctxt->counters[ctxt->nbCounters].min = -1; in xmlRegGetCounter()
1231 ctxt->counters[ctxt->nbCounters].max = -1; in xmlRegGetCounter()
1232 return(ctxt->nbCounters++); in xmlRegGetCounter()
1239 return(-1); in xmlRegAtomPush()
1241 if (ctxt->nbAtoms >= ctxt->maxAtoms) { in xmlRegAtomPush()
1242 size_t newSize = ctxt->maxAtoms ? ctxt->maxAtoms * 2 : 4; in xmlRegAtomPush()
1245 tmp = xmlRealloc(ctxt->atoms, newSize * sizeof(xmlRegAtomPtr)); in xmlRegAtomPush()
1248 return(-1); in xmlRegAtomPush()
1250 ctxt->atoms = tmp; in xmlRegAtomPush()
1251 ctxt->maxAtoms = newSize; in xmlRegAtomPush()
1253 atom->no = ctxt->nbAtoms; in xmlRegAtomPush()
1254 ctxt->atoms[ctxt->nbAtoms++] = atom; in xmlRegAtomPush()
1261 if (target->maxTransTo == 0) { in xmlRegStateAddTransTo()
1262 target->maxTransTo = 8; in xmlRegStateAddTransTo()
1263 target->transTo = (int *) xmlMalloc(target->maxTransTo * in xmlRegStateAddTransTo()
1265 if (target->transTo == NULL) { in xmlRegStateAddTransTo()
1267 target->maxTransTo = 0; in xmlRegStateAddTransTo()
1270 } else if (target->nbTransTo >= target->maxTransTo) { in xmlRegStateAddTransTo()
1272 target->maxTransTo *= 2; in xmlRegStateAddTransTo()
1273 tmp = (int *) xmlRealloc(target->transTo, target->maxTransTo * in xmlRegStateAddTransTo()
1277 target->maxTransTo /= 2; in xmlRegStateAddTransTo()
1280 target->transTo = tmp; in xmlRegStateAddTransTo()
1282 target->transTo[target->nbTransTo] = from; in xmlRegStateAddTransTo()
1283 target->nbTransTo++; in xmlRegStateAddTransTo()
1307 for (nrtrans = state->nbTrans - 1; nrtrans >= 0; nrtrans--) { in xmlRegStateAddTrans()
1308 xmlRegTransPtr trans = &(state->trans[nrtrans]); in xmlRegStateAddTrans()
1309 if ((trans->atom == atom) && in xmlRegStateAddTrans()
1310 (trans->to == target->no) && in xmlRegStateAddTrans()
1311 (trans->counter == counter) && in xmlRegStateAddTrans()
1312 (trans->count == count)) { in xmlRegStateAddTrans()
1317 if (state->maxTrans == 0) { in xmlRegStateAddTrans()
1318 state->maxTrans = 8; in xmlRegStateAddTrans()
1319 state->trans = (xmlRegTrans *) xmlMalloc(state->maxTrans * in xmlRegStateAddTrans()
1321 if (state->trans == NULL) { in xmlRegStateAddTrans()
1323 state->maxTrans = 0; in xmlRegStateAddTrans()
1326 } else if (state->nbTrans >= state->maxTrans) { in xmlRegStateAddTrans()
1328 state->maxTrans *= 2; in xmlRegStateAddTrans()
1329 tmp = (xmlRegTrans *) xmlRealloc(state->trans, state->maxTrans * in xmlRegStateAddTrans()
1333 state->maxTrans /= 2; in xmlRegStateAddTrans()
1336 state->trans = tmp; in xmlRegStateAddTrans()
1339 state->trans[state->nbTrans].atom = atom; in xmlRegStateAddTrans()
1340 state->trans[state->nbTrans].to = target->no; in xmlRegStateAddTrans()
1341 state->trans[state->nbTrans].counter = counter; in xmlRegStateAddTrans()
1342 state->trans[state->nbTrans].count = count; in xmlRegStateAddTrans()
1343 state->trans[state->nbTrans].nd = 0; in xmlRegStateAddTrans()
1344 state->nbTrans++; in xmlRegStateAddTrans()
1345 xmlRegStateAddTransTo(ctxt, target, state->no); in xmlRegStateAddTrans()
1352 if (ctxt->nbStates >= ctxt->maxStates) { in xmlRegStatePush()
1353 size_t newSize = ctxt->maxStates ? ctxt->maxStates * 2 : 4; in xmlRegStatePush()
1356 tmp = xmlRealloc(ctxt->states, newSize * sizeof(tmp[0])); in xmlRegStatePush()
1361 ctxt->states = tmp; in xmlRegStatePush()
1362 ctxt->maxStates = newSize; in xmlRegStatePush()
1369 state->no = ctxt->nbStates; in xmlRegStatePush()
1370 ctxt->states[ctxt->nbStates++] = state; in xmlRegStatePush()
1390 return(-1); in xmlFAGenerateAllTransition()
1391 ctxt->state = to; in xmlFAGenerateAllTransition()
1394 xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_LAX_COUNTER); in xmlFAGenerateAllTransition()
1396 xmlRegStateAddTrans(ctxt, from, NULL, to, -1, REGEXP_ALL_COUNTER); in xmlFAGenerateAllTransition()
1413 return(-1); in xmlFAGenerateEpsilonTransition()
1414 ctxt->state = to; in xmlFAGenerateEpsilonTransition()
1416 xmlRegStateAddTrans(ctxt, from, NULL, to, -1, -1); in xmlFAGenerateEpsilonTransition()
1434 return(-1); in xmlFAGenerateCountedEpsilonTransition()
1435 ctxt->state = to; in xmlFAGenerateCountedEpsilonTransition()
1437 xmlRegStateAddTrans(ctxt, from, NULL, to, counter, -1); in xmlFAGenerateCountedEpsilonTransition()
1455 return(-1); in xmlFAGenerateCountedTransition()
1456 ctxt->state = to; in xmlFAGenerateCountedTransition()
1458 xmlRegStateAddTrans(ctxt, from, NULL, to, -1, counter); in xmlFAGenerateCountedTransition()
1469 * Returns 0 if success and -1 in case of error.
1479 return(-1); in xmlFAGenerateTransitions()
1481 if (atom->type == XML_REGEXP_SUBREG) { in xmlFAGenerateTransitions()
1486 if ((to != NULL) && (atom->stop != to) && in xmlFAGenerateTransitions()
1487 (atom->quant != XML_REGEXP_QUANT_RANGE)) { in xmlFAGenerateTransitions()
1491 xmlFAGenerateEpsilonTransition(ctxt, atom->stop, to); in xmlFAGenerateTransitions()
1493 } else if ((to == NULL) && (atom->quant != XML_REGEXP_QUANT_RANGE) && in xmlFAGenerateTransitions()
1494 (atom->quant != XML_REGEXP_QUANT_ONCE)) { in xmlFAGenerateTransitions()
1497 return(-1); in xmlFAGenerateTransitions()
1498 ctxt->state = to; in xmlFAGenerateTransitions()
1499 xmlFAGenerateEpsilonTransition(ctxt, atom->stop, to); in xmlFAGenerateTransitions()
1502 switch (atom->quant) { in xmlFAGenerateTransitions()
1504 atom->quant = XML_REGEXP_QUANT_ONCE; in xmlFAGenerateTransitions()
1511 xmlFAGenerateEpsilonTransition(ctxt, atom->start, 0); in xmlFAGenerateTransitions()
1512 xmlFAGenerateEpsilonTransition(ctxt, atom->stop, in xmlFAGenerateTransitions()
1513 ctxt->state); in xmlFAGenerateTransitions()
1515 xmlFAGenerateEpsilonTransition(ctxt, atom->start, to); in xmlFAGenerateTransitions()
1519 atom->quant = XML_REGEXP_QUANT_ONCE; in xmlFAGenerateTransitions()
1520 xmlFAGenerateEpsilonTransition(ctxt, atom->start, atom->stop); in xmlFAGenerateTransitions()
1521 xmlFAGenerateEpsilonTransition(ctxt, atom->stop, atom->start); in xmlFAGenerateTransitions()
1524 atom->quant = XML_REGEXP_QUANT_ONCE; in xmlFAGenerateTransitions()
1525 xmlFAGenerateEpsilonTransition(ctxt, atom->stop, atom->start); in xmlFAGenerateTransitions()
1539 return(-1); in xmlFAGenerateTransitions()
1548 if ((atom->min == 0) && (atom->start0 == NULL)) { in xmlFAGenerateTransitions()
1552 * occurrences after 1. We cannot loop to atom->start in xmlFAGenerateTransitions()
1561 return(-1); in xmlFAGenerateTransitions()
1562 copy->quant = XML_REGEXP_QUANT_ONCE; in xmlFAGenerateTransitions()
1563 copy->min = 0; in xmlFAGenerateTransitions()
1564 copy->max = 0; in xmlFAGenerateTransitions()
1566 if (xmlFAGenerateTransitions(ctxt, atom->start, NULL, copy) in xmlFAGenerateTransitions()
1569 return(-1); in xmlFAGenerateTransitions()
1571 inter = ctxt->state; in xmlFAGenerateTransitions()
1574 return(-1); in xmlFAGenerateTransitions()
1575 ctxt->counters[counter].min = atom->min - 1; in xmlFAGenerateTransitions()
1576 ctxt->counters[counter].max = atom->max - 1; in xmlFAGenerateTransitions()
1579 atom->stop, counter); in xmlFAGenerateTransitions()
1584 xmlFAGenerateEpsilonTransition(ctxt, atom->start, in xmlFAGenerateTransitions()
1589 * is an atom->start0 allowing to easily plug the in xmlFAGenerateTransitions()
1594 return(-1); in xmlFAGenerateTransitions()
1595 ctxt->counters[counter].min = atom->min - 1; in xmlFAGenerateTransitions()
1596 ctxt->counters[counter].max = atom->max - 1; in xmlFAGenerateTransitions()
1598 xmlFAGenerateCountedTransition(ctxt, atom->stop, in xmlFAGenerateTransitions()
1601 xmlFAGenerateCountedEpsilonTransition(ctxt, atom->stop, in xmlFAGenerateTransitions()
1602 atom->start, counter); in xmlFAGenerateTransitions()
1604 if (atom->min == 0) in xmlFAGenerateTransitions()
1605 xmlFAGenerateEpsilonTransition(ctxt, atom->start0, in xmlFAGenerateTransitions()
1609 atom->min = 0; in xmlFAGenerateTransitions()
1610 atom->max = 0; in xmlFAGenerateTransitions()
1611 atom->quant = XML_REGEXP_QUANT_ONCE; in xmlFAGenerateTransitions()
1612 ctxt->state = newstate; in xmlFAGenerateTransitions()
1618 return(-1); in xmlFAGenerateTransitions()
1621 if ((atom->min == 0) && (atom->max == 0) && in xmlFAGenerateTransitions()
1622 (atom->quant == XML_REGEXP_QUANT_RANGE)) { in xmlFAGenerateTransitions()
1629 return(-1); in xmlFAGenerateTransitions()
1632 ctxt->state = to; in xmlFAGenerateTransitions()
1639 return(-1); in xmlFAGenerateTransitions()
1642 if ((atom->quant == XML_REGEXP_QUANT_MULT) || in xmlFAGenerateTransitions()
1643 (atom->quant == XML_REGEXP_QUANT_PLUS)) { in xmlFAGenerateTransitions()
1653 return(-1); in xmlFAGenerateTransitions()
1657 if ((atom->quant == XML_REGEXP_QUANT_RANGE) && in xmlFAGenerateTransitions()
1658 (atom->min == 0) && (atom->max > 0)) { in xmlFAGenerateTransitions()
1660 atom->min = 1; in xmlFAGenerateTransitions()
1661 if (atom->max == 1) in xmlFAGenerateTransitions()
1662 atom->quant = XML_REGEXP_QUANT_OPT; in xmlFAGenerateTransitions()
1664 xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1); in xmlFAGenerateTransitions()
1665 ctxt->state = end; in xmlFAGenerateTransitions()
1666 switch (atom->quant) { in xmlFAGenerateTransitions()
1668 atom->quant = XML_REGEXP_QUANT_ONCE; in xmlFAGenerateTransitions()
1672 atom->quant = XML_REGEXP_QUANT_ONCE; in xmlFAGenerateTransitions()
1674 xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1); in xmlFAGenerateTransitions()
1677 atom->quant = XML_REGEXP_QUANT_ONCE; in xmlFAGenerateTransitions()
1678 xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1); in xmlFAGenerateTransitions()
1688 return(-1); in xmlFAGenerateTransitions()
1707 from = ctxt->states[fromnr]; in xmlFAReduceEpsilonTransitions()
1710 to = ctxt->states[tonr]; in xmlFAReduceEpsilonTransitions()
1713 if ((to->mark == XML_REGEXP_MARK_START) || in xmlFAReduceEpsilonTransitions()
1714 (to->mark == XML_REGEXP_MARK_VISITED)) in xmlFAReduceEpsilonTransitions()
1717 to->mark = XML_REGEXP_MARK_VISITED; in xmlFAReduceEpsilonTransitions()
1718 if (to->type == XML_REGEXP_FINAL_STATE) { in xmlFAReduceEpsilonTransitions()
1719 from->type = XML_REGEXP_FINAL_STATE; in xmlFAReduceEpsilonTransitions()
1721 for (transnr = 0;transnr < to->nbTrans;transnr++) { in xmlFAReduceEpsilonTransitions()
1722 xmlRegTransPtr t1 = &to->trans[transnr]; in xmlFAReduceEpsilonTransitions()
1725 if (t1->to < 0) in xmlFAReduceEpsilonTransitions()
1727 if (t1->counter >= 0) { in xmlFAReduceEpsilonTransitions()
1729 tcounter = t1->counter; in xmlFAReduceEpsilonTransitions()
1733 if (t1->atom == NULL) { in xmlFAReduceEpsilonTransitions()
1738 if (t1->to != fromnr) { in xmlFAReduceEpsilonTransitions()
1739 if (t1->count >= 0) { in xmlFAReduceEpsilonTransitions()
1740 xmlRegStateAddTrans(ctxt, from, NULL, ctxt->states[t1->to], in xmlFAReduceEpsilonTransitions()
1741 -1, t1->count); in xmlFAReduceEpsilonTransitions()
1743 xmlFAReduceEpsilonTransitions(ctxt, fromnr, t1->to, in xmlFAReduceEpsilonTransitions()
1748 xmlRegStateAddTrans(ctxt, from, t1->atom, in xmlFAReduceEpsilonTransitions()
1749 ctxt->states[t1->to], tcounter, -1); in xmlFAReduceEpsilonTransitions()
1767 to = ctxt->states[tonr]; in xmlFAFinishReduceEpsilonTransitions()
1770 if ((to->mark == XML_REGEXP_MARK_START) || in xmlFAFinishReduceEpsilonTransitions()
1771 (to->mark == XML_REGEXP_MARK_NORMAL)) in xmlFAFinishReduceEpsilonTransitions()
1774 to->mark = XML_REGEXP_MARK_NORMAL; in xmlFAFinishReduceEpsilonTransitions()
1775 for (transnr = 0;transnr < to->nbTrans;transnr++) { in xmlFAFinishReduceEpsilonTransitions()
1776 xmlRegTransPtr t1 = &to->trans[transnr]; in xmlFAFinishReduceEpsilonTransitions()
1777 if ((t1->to >= 0) && (t1->atom == NULL)) in xmlFAFinishReduceEpsilonTransitions()
1778 xmlFAFinishReduceEpsilonTransitions(ctxt, t1->to); in xmlFAFinishReduceEpsilonTransitions()
1791 * - if there exists an epsilon from X to Y
1792 * - if there is no other transition from X
1808 for (statenr = 0;statenr < ctxt->nbStates;statenr++) { in xmlFAEliminateSimpleEpsilonTransitions()
1809 state = ctxt->states[statenr]; in xmlFAEliminateSimpleEpsilonTransitions()
1812 if (state->nbTrans != 1) in xmlFAEliminateSimpleEpsilonTransitions()
1814 if (state->type == XML_REGEXP_UNREACH_STATE || in xmlFAEliminateSimpleEpsilonTransitions()
1815 state->type == XML_REGEXP_FINAL_STATE) in xmlFAEliminateSimpleEpsilonTransitions()
1818 if ((state->trans[0].atom == NULL) && in xmlFAEliminateSimpleEpsilonTransitions()
1819 (state->trans[0].to >= 0) && in xmlFAEliminateSimpleEpsilonTransitions()
1820 (state->trans[0].to != statenr) && in xmlFAEliminateSimpleEpsilonTransitions()
1821 (state->trans[0].counter < 0) && in xmlFAEliminateSimpleEpsilonTransitions()
1822 (state->trans[0].count < 0)) { in xmlFAEliminateSimpleEpsilonTransitions()
1823 newto = state->trans[0].to; in xmlFAEliminateSimpleEpsilonTransitions()
1825 if (state->type == XML_REGEXP_START_STATE) { in xmlFAEliminateSimpleEpsilonTransitions()
1827 for (i = 0;i < state->nbTransTo;i++) { in xmlFAEliminateSimpleEpsilonTransitions()
1828 tmp = ctxt->states[state->transTo[i]]; in xmlFAEliminateSimpleEpsilonTransitions()
1829 for (j = 0;j < tmp->nbTrans;j++) { in xmlFAEliminateSimpleEpsilonTransitions()
1830 if (tmp->trans[j].to == statenr) { in xmlFAEliminateSimpleEpsilonTransitions()
1831 tmp->trans[j].to = -1; in xmlFAEliminateSimpleEpsilonTransitions()
1832 xmlRegStateAddTrans(ctxt, tmp, tmp->trans[j].atom, in xmlFAEliminateSimpleEpsilonTransitions()
1833 ctxt->states[newto], in xmlFAEliminateSimpleEpsilonTransitions()
1834 tmp->trans[j].counter, in xmlFAEliminateSimpleEpsilonTransitions()
1835 tmp->trans[j].count); in xmlFAEliminateSimpleEpsilonTransitions()
1839 if (state->type == XML_REGEXP_FINAL_STATE) in xmlFAEliminateSimpleEpsilonTransitions()
1840 ctxt->states[newto]->type = XML_REGEXP_FINAL_STATE; in xmlFAEliminateSimpleEpsilonTransitions()
1842 state->nbTrans = 0; in xmlFAEliminateSimpleEpsilonTransitions()
1844 state->type = XML_REGEXP_UNREACH_STATE; in xmlFAEliminateSimpleEpsilonTransitions()
1862 if (ctxt->states == NULL) return; in xmlFAEliminateEpsilonTransitions()
1869 for (statenr = 0;statenr < ctxt->nbStates;statenr++) { in xmlFAEliminateEpsilonTransitions()
1870 state = ctxt->states[statenr]; in xmlFAEliminateEpsilonTransitions()
1871 if ((state != NULL) && (state->type == XML_REGEXP_UNREACH_STATE)) { in xmlFAEliminateEpsilonTransitions()
1873 ctxt->states[statenr] = NULL; in xmlFAEliminateEpsilonTransitions()
1887 for (statenr = ctxt->nbStates - 1;statenr >= 0;statenr--) { in xmlFAEliminateEpsilonTransitions()
1888 state = ctxt->states[statenr]; in xmlFAEliminateEpsilonTransitions()
1891 if ((state->nbTrans == 0) && in xmlFAEliminateEpsilonTransitions()
1892 (state->type != XML_REGEXP_FINAL_STATE)) { in xmlFAEliminateEpsilonTransitions()
1893 state->type = XML_REGEXP_SINK_STATE; in xmlFAEliminateEpsilonTransitions()
1895 for (transnr = 0;transnr < state->nbTrans;transnr++) { in xmlFAEliminateEpsilonTransitions()
1896 if ((state->trans[transnr].atom == NULL) && in xmlFAEliminateEpsilonTransitions()
1897 (state->trans[transnr].to >= 0)) { in xmlFAEliminateEpsilonTransitions()
1898 if (state->trans[transnr].to == statenr) { in xmlFAEliminateEpsilonTransitions()
1899 state->trans[transnr].to = -1; in xmlFAEliminateEpsilonTransitions()
1900 } else if (state->trans[transnr].count < 0) { in xmlFAEliminateEpsilonTransitions()
1901 int newto = state->trans[transnr].to; in xmlFAEliminateEpsilonTransitions()
1904 state->trans[transnr].to = -2; in xmlFAEliminateEpsilonTransitions()
1905 state->mark = XML_REGEXP_MARK_START; in xmlFAEliminateEpsilonTransitions()
1907 newto, state->trans[transnr].counter); in xmlFAEliminateEpsilonTransitions()
1909 state->mark = XML_REGEXP_MARK_NORMAL; in xmlFAEliminateEpsilonTransitions()
1918 for (statenr = 0;statenr < ctxt->nbStates;statenr++) { in xmlFAEliminateEpsilonTransitions()
1919 state = ctxt->states[statenr]; in xmlFAEliminateEpsilonTransitions()
1922 for (transnr = 0;transnr < state->nbTrans;transnr++) { in xmlFAEliminateEpsilonTransitions()
1923 xmlRegTransPtr trans = &(state->trans[transnr]); in xmlFAEliminateEpsilonTransitions()
1924 if ((trans->atom == NULL) && in xmlFAEliminateEpsilonTransitions()
1925 (trans->count < 0) && in xmlFAEliminateEpsilonTransitions()
1926 (trans->to >= 0)) { in xmlFAEliminateEpsilonTransitions()
1927 trans->to = -1; in xmlFAEliminateEpsilonTransitions()
1936 for (statenr = 0;statenr < ctxt->nbStates;statenr++) { in xmlFAEliminateEpsilonTransitions()
1937 state = ctxt->states[statenr]; in xmlFAEliminateEpsilonTransitions()
1939 state->reached = XML_REGEXP_MARK_NORMAL; in xmlFAEliminateEpsilonTransitions()
1941 state = ctxt->states[0]; in xmlFAEliminateEpsilonTransitions()
1943 state->reached = XML_REGEXP_MARK_START; in xmlFAEliminateEpsilonTransitions()
1946 state->reached = XML_REGEXP_MARK_VISITED; in xmlFAEliminateEpsilonTransitions()
1950 for (transnr = 0;transnr < state->nbTrans;transnr++) { in xmlFAEliminateEpsilonTransitions()
1951 if ((state->trans[transnr].to >= 0) && in xmlFAEliminateEpsilonTransitions()
1952 ((state->trans[transnr].atom != NULL) || in xmlFAEliminateEpsilonTransitions()
1953 (state->trans[transnr].count >= 0))) { in xmlFAEliminateEpsilonTransitions()
1954 int newto = state->trans[transnr].to; in xmlFAEliminateEpsilonTransitions()
1956 if (ctxt->states[newto] == NULL) in xmlFAEliminateEpsilonTransitions()
1958 if (ctxt->states[newto]->reached == XML_REGEXP_MARK_NORMAL) { in xmlFAEliminateEpsilonTransitions()
1959 ctxt->states[newto]->reached = XML_REGEXP_MARK_START; in xmlFAEliminateEpsilonTransitions()
1960 target = ctxt->states[newto]; in xmlFAEliminateEpsilonTransitions()
1969 for (statenr = 1;statenr < ctxt->nbStates;statenr++) { in xmlFAEliminateEpsilonTransitions()
1970 state = ctxt->states[statenr]; in xmlFAEliminateEpsilonTransitions()
1971 if ((state != NULL) && (state->reached == in xmlFAEliminateEpsilonTransitions()
1980 for (statenr = 0;statenr < ctxt->nbStates;statenr++) { in xmlFAEliminateEpsilonTransitions()
1981 state = ctxt->states[statenr]; in xmlFAEliminateEpsilonTransitions()
1982 if ((state != NULL) && (state->reached == XML_REGEXP_MARK_NORMAL)) { in xmlFAEliminateEpsilonTransitions()
1984 ctxt->states[statenr] = NULL; in xmlFAEliminateEpsilonTransitions()
1994 if ((range1->type == XML_REGEXP_RANGES) || in xmlFACompareRanges()
1995 (range2->type == XML_REGEXP_RANGES) || in xmlFACompareRanges()
1996 (range2->type == XML_REGEXP_SUBREG) || in xmlFACompareRanges()
1997 (range1->type == XML_REGEXP_SUBREG) || in xmlFACompareRanges()
1998 (range1->type == XML_REGEXP_STRING) || in xmlFACompareRanges()
1999 (range2->type == XML_REGEXP_STRING)) in xmlFACompareRanges()
2000 return(-1); in xmlFACompareRanges()
2003 if (range1->type > range2->type) { in xmlFACompareRanges()
2010 if ((range1->type == XML_REGEXP_ANYCHAR) || in xmlFACompareRanges()
2011 (range2->type == XML_REGEXP_ANYCHAR)) { in xmlFACompareRanges()
2013 } else if ((range1->type == XML_REGEXP_EPSILON) || in xmlFACompareRanges()
2014 (range2->type == XML_REGEXP_EPSILON)) { in xmlFACompareRanges()
2016 } else if (range1->type == range2->type) { in xmlFACompareRanges()
2017 if (range1->type != XML_REGEXP_CHARVAL) in xmlFACompareRanges()
2019 else if ((range1->end < range2->start) || in xmlFACompareRanges()
2020 (range2->end < range1->start)) in xmlFACompareRanges()
2024 } else if (range1->type == XML_REGEXP_CHARVAL) { in xmlFACompareRanges()
2034 if (((range1->neg == 0) && (range2->neg != 0)) || in xmlFACompareRanges()
2035 ((range1->neg != 0) && (range2->neg == 0))) in xmlFACompareRanges()
2038 for (codepoint = range1->start;codepoint <= range1->end ;codepoint++) { in xmlFACompareRanges()
2039 ret = xmlRegCheckCharacterRange(range2->type, codepoint, in xmlFACompareRanges()
2040 0, range2->start, range2->end, in xmlFACompareRanges()
2041 range2->blockName); in xmlFACompareRanges()
2043 return(-1); in xmlFACompareRanges()
2049 } else if ((range1->type == XML_REGEXP_BLOCK_NAME) || in xmlFACompareRanges()
2050 (range2->type == XML_REGEXP_BLOCK_NAME)) { in xmlFACompareRanges()
2051 if (range1->type == range2->type) { in xmlFACompareRanges()
2052 ret = xmlStrEqual(range1->blockName, range2->blockName); in xmlFACompareRanges()
2062 } else if ((range1->type < XML_REGEXP_LETTER) || in xmlFACompareRanges()
2063 (range2->type < XML_REGEXP_LETTER)) { in xmlFACompareRanges()
2064 if ((range1->type == XML_REGEXP_ANYSPACE) && in xmlFACompareRanges()
2065 (range2->type == XML_REGEXP_NOTSPACE)) in xmlFACompareRanges()
2067 else if ((range1->type == XML_REGEXP_INITNAME) && in xmlFACompareRanges()
2068 (range2->type == XML_REGEXP_NOTINITNAME)) in xmlFACompareRanges()
2070 else if ((range1->type == XML_REGEXP_NAMECHAR) && in xmlFACompareRanges()
2071 (range2->type == XML_REGEXP_NOTNAMECHAR)) in xmlFACompareRanges()
2073 else if ((range1->type == XML_REGEXP_DECIMAL) && in xmlFACompareRanges()
2074 (range2->type == XML_REGEXP_NOTDECIMAL)) in xmlFACompareRanges()
2076 else if ((range1->type == XML_REGEXP_REALCHAR) && in xmlFACompareRanges()
2077 (range2->type == XML_REGEXP_NOTREALCHAR)) in xmlFACompareRanges()
2085 /* range1->type < range2->type here */ in xmlFACompareRanges()
2086 switch (range1->type) { in xmlFACompareRanges()
2089 if ((range2->type == XML_REGEXP_LETTER_UPPERCASE) || in xmlFACompareRanges()
2090 (range2->type == XML_REGEXP_LETTER_LOWERCASE) || in xmlFACompareRanges()
2091 (range2->type == XML_REGEXP_LETTER_TITLECASE) || in xmlFACompareRanges()
2092 (range2->type == XML_REGEXP_LETTER_MODIFIER) || in xmlFACompareRanges()
2093 (range2->type == XML_REGEXP_LETTER_OTHERS)) in xmlFACompareRanges()
2097 if ((range2->type == XML_REGEXP_MARK_NONSPACING) || in xmlFACompareRanges()
2098 (range2->type == XML_REGEXP_MARK_SPACECOMBINING) || in xmlFACompareRanges()
2099 (range2->type == XML_REGEXP_MARK_ENCLOSING)) in xmlFACompareRanges()
2103 if ((range2->type == XML_REGEXP_NUMBER_DECIMAL) || in xmlFACompareRanges()
2104 (range2->type == XML_REGEXP_NUMBER_LETTER) || in xmlFACompareRanges()
2105 (range2->type == XML_REGEXP_NUMBER_OTHERS)) in xmlFACompareRanges()
2109 if ((range2->type == XML_REGEXP_PUNCT_CONNECTOR) || in xmlFACompareRanges()
2110 (range2->type == XML_REGEXP_PUNCT_DASH) || in xmlFACompareRanges()
2111 (range2->type == XML_REGEXP_PUNCT_OPEN) || in xmlFACompareRanges()
2112 (range2->type == XML_REGEXP_PUNCT_CLOSE) || in xmlFACompareRanges()
2113 (range2->type == XML_REGEXP_PUNCT_INITQUOTE) || in xmlFACompareRanges()
2114 (range2->type == XML_REGEXP_PUNCT_FINQUOTE) || in xmlFACompareRanges()
2115 (range2->type == XML_REGEXP_PUNCT_OTHERS)) in xmlFACompareRanges()
2119 if ((range2->type == XML_REGEXP_SEPAR_SPACE) || in xmlFACompareRanges()
2120 (range2->type == XML_REGEXP_SEPAR_LINE) || in xmlFACompareRanges()
2121 (range2->type == XML_REGEXP_SEPAR_PARA)) in xmlFACompareRanges()
2125 if ((range2->type == XML_REGEXP_SYMBOL_MATH) || in xmlFACompareRanges()
2126 (range2->type == XML_REGEXP_SYMBOL_CURRENCY) || in xmlFACompareRanges()
2127 (range2->type == XML_REGEXP_SYMBOL_MODIFIER) || in xmlFACompareRanges()
2128 (range2->type == XML_REGEXP_SYMBOL_OTHERS)) in xmlFACompareRanges()
2132 if ((range2->type == XML_REGEXP_OTHER_CONTROL) || in xmlFACompareRanges()
2133 (range2->type == XML_REGEXP_OTHER_FORMAT) || in xmlFACompareRanges()
2134 (range2->type == XML_REGEXP_OTHER_PRIVATE)) in xmlFACompareRanges()
2138 if ((range2->type >= XML_REGEXP_LETTER) && in xmlFACompareRanges()
2139 (range2->type < XML_REGEXP_BLOCK_NAME)) in xmlFACompareRanges()
2147 if (((range1->neg == 0) && (range2->neg != 0)) || in xmlFACompareRanges()
2148 ((range1->neg != 0) && (range2->neg == 0))) in xmlFACompareRanges()
2374 if (atom1->type != atom2->type) in xmlFAEqualAtoms()
2376 switch (atom1->type) { in xmlFAEqualAtoms()
2382 ret = (atom1->valuep == atom2->valuep); in xmlFAEqualAtoms()
2384 ret = xmlStrEqual((xmlChar *)atom1->valuep, in xmlFAEqualAtoms()
2385 (xmlChar *)atom2->valuep); in xmlFAEqualAtoms()
2388 ret = (atom1->codepoint == atom2->codepoint); in xmlFAEqualAtoms()
2419 if ((atom1->type == XML_REGEXP_ANYCHAR) || in xmlFACompareAtoms()
2420 (atom2->type == XML_REGEXP_ANYCHAR)) in xmlFACompareAtoms()
2423 if (atom1->type > atom2->type) { in xmlFACompareAtoms()
2429 if (atom1->type != atom2->type) { in xmlFACompareAtoms()
2430 ret = xmlFACompareAtomTypes(atom1->type, atom2->type); in xmlFACompareAtoms()
2435 switch (atom1->type) { in xmlFACompareAtoms()
2438 ret = (atom1->valuep != atom2->valuep); in xmlFACompareAtoms()
2440 xmlChar *val1 = (xmlChar *)atom1->valuep; in xmlFACompareAtoms()
2441 xmlChar *val2 = (xmlChar *)atom2->valuep; in xmlFACompareAtoms()
2455 if (atom2->type == XML_REGEXP_CHARVAL) { in xmlFACompareAtoms()
2456 ret = (atom1->codepoint == atom2->codepoint); in xmlFACompareAtoms()
2458 ret = xmlRegCheckCharacter(atom2, atom1->codepoint); in xmlFACompareAtoms()
2464 if (atom2->type == XML_REGEXP_RANGES) { in xmlFACompareAtoms()
2471 for (i = 0;i < atom1->nbRanges;i++) { in xmlFACompareAtoms()
2472 for (j = 0;j < atom2->nbRanges;j++) { in xmlFACompareAtoms()
2473 r1 = atom1->ranges[i]; in xmlFACompareAtoms()
2474 r2 = atom2->ranges[j]; in xmlFACompareAtoms()
2489 if (atom1->neg != atom2->neg) { in xmlFACompareAtoms()
2517 if (state->markd == XML_REGEXP_MARK_VISITED) in xmlFARecurseDeterminism()
2520 if (ctxt->flags & AM_AUTOMATA_RNG) in xmlFARecurseDeterminism()
2527 nbTrans = state->nbTrans; in xmlFARecurseDeterminism()
2529 t1 = &(state->trans[transnr]); in xmlFARecurseDeterminism()
2533 if ((t1->to < 0) || (t1->to == fromnr)) in xmlFARecurseDeterminism()
2535 if (t1->atom == NULL) { in xmlFARecurseDeterminism()
2536 state->markd = XML_REGEXP_MARK_VISITED; in xmlFARecurseDeterminism()
2537 res = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to], in xmlFARecurseDeterminism()
2541 /* t1->nd = 1; */ in xmlFARecurseDeterminism()
2545 if (xmlFACompareAtoms(t1->atom, atom, deep)) { in xmlFARecurseDeterminism()
2547 if ((t1->to != tonr) || in xmlFARecurseDeterminism()
2548 (!xmlFAEqualAtoms(t1->atom, atom, deep))) in xmlFARecurseDeterminism()
2550 /* mark the transition as non-deterministic */ in xmlFARecurseDeterminism()
2551 t1->nd = 1; in xmlFARecurseDeterminism()
2569 if (state->markd != XML_REGEXP_MARK_VISITED) in xmlFAFinishRecurseDeterminism()
2571 state->markd = 0; in xmlFAFinishRecurseDeterminism()
2573 nbTrans = state->nbTrans; in xmlFAFinishRecurseDeterminism()
2575 xmlRegTransPtr t1 = &state->trans[transnr]; in xmlFAFinishRecurseDeterminism()
2576 if ((t1->atom == NULL) && (t1->to >= 0)) in xmlFAFinishRecurseDeterminism()
2577 xmlFAFinishRecurseDeterminism(ctxt, ctxt->states[t1->to]); in xmlFAFinishRecurseDeterminism()
2598 if (ctxt->determinist != -1) in xmlFAComputesDeterminism()
2599 return(ctxt->determinist); in xmlFAComputesDeterminism()
2601 if (ctxt->flags & AM_AUTOMATA_RNG) in xmlFAComputesDeterminism()
2607 for (statenr = 0;statenr < ctxt->nbStates;statenr++) { in xmlFAComputesDeterminism()
2608 state = ctxt->states[statenr]; in xmlFAComputesDeterminism()
2611 if (state->nbTrans < 2) in xmlFAComputesDeterminism()
2613 for (transnr = 0;transnr < state->nbTrans;transnr++) { in xmlFAComputesDeterminism()
2614 t1 = &(state->trans[transnr]); in xmlFAComputesDeterminism()
2619 if (t1->atom == NULL) { in xmlFAComputesDeterminism()
2620 /* t1->nd = 1; */ in xmlFAComputesDeterminism()
2623 if (t1->to < 0) /* eliminated */ in xmlFAComputesDeterminism()
2626 t2 = &(state->trans[i]); in xmlFAComputesDeterminism()
2627 if (t2->to < 0) /* eliminated */ in xmlFAComputesDeterminism()
2629 if (t2->atom != NULL) { in xmlFAComputesDeterminism()
2630 if (t1->to == t2->to) { in xmlFAComputesDeterminism()
2635 if (xmlFAEqualAtoms(t1->atom, t2->atom, deep) && in xmlFAComputesDeterminism()
2636 (t1->counter == t2->counter) && in xmlFAComputesDeterminism()
2637 (t1->count == t2->count)) in xmlFAComputesDeterminism()
2638 t2->to = -1; /* eliminated */ in xmlFAComputesDeterminism()
2649 for (statenr = 0;statenr < ctxt->nbStates;statenr++) { in xmlFAComputesDeterminism()
2650 state = ctxt->states[statenr]; in xmlFAComputesDeterminism()
2653 if (state->nbTrans < 2) in xmlFAComputesDeterminism()
2656 for (transnr = 0;transnr < state->nbTrans;transnr++) { in xmlFAComputesDeterminism()
2657 t1 = &(state->trans[transnr]); in xmlFAComputesDeterminism()
2662 if (t1->atom == NULL) { in xmlFAComputesDeterminism()
2665 if (t1->to < 0) /* eliminated */ in xmlFAComputesDeterminism()
2668 t2 = &(state->trans[i]); in xmlFAComputesDeterminism()
2669 if (t2->to < 0) /* eliminated */ in xmlFAComputesDeterminism()
2671 if (t2->atom != NULL) { in xmlFAComputesDeterminism()
2676 if (xmlFACompareAtoms(t1->atom, t2->atom, 1)) { in xmlFAComputesDeterminism()
2681 if ((t1->to != t2->to) || in xmlFAComputesDeterminism()
2682 (t1->counter == t2->counter) || in xmlFAComputesDeterminism()
2683 (!xmlFAEqualAtoms(t1->atom, t2->atom, deep))) in xmlFAComputesDeterminism()
2685 /* mark the transitions as non-deterministic ones */ in xmlFAComputesDeterminism()
2686 t1->nd = 1; in xmlFAComputesDeterminism()
2687 t2->nd = 1; in xmlFAComputesDeterminism()
2697 res = xmlFARecurseDeterminism(ctxt, ctxt->states[t2->to], in xmlFAComputesDeterminism()
2698 statenr, t1->to, t1->atom); in xmlFAComputesDeterminism()
2699 xmlFAFinishRecurseDeterminism(ctxt, ctxt->states[t2->to]); in xmlFAComputesDeterminism()
2706 t1->nd = 1; in xmlFAComputesDeterminism()
2707 /* t2->nd = 1; */ in xmlFAComputesDeterminism()
2720 * mark specifically the last non-deterministic transition in xmlFAComputesDeterminism()
2721 * from a state since there is no need to set-up rollback in xmlFAComputesDeterminism()
2725 last->nd = 2; in xmlFAComputesDeterminism()
2734 ctxt->determinist = ret; in xmlFAComputesDeterminism()
2754 return(-1); in xmlRegCheckCharacterRange()
2780 (codepoint == '.') || (codepoint == '-') || in xmlRegCheckCharacterRange()
2925 return(-1); in xmlRegCheckCharacter()
2927 switch (atom->type) { in xmlRegCheckCharacter()
2930 return(-1); in xmlRegCheckCharacter()
2932 return(codepoint == atom->codepoint); in xmlRegCheckCharacter()
2936 for (i = 0;i < atom->nbRanges;i++) { in xmlRegCheckCharacter()
2937 range = atom->ranges[i]; in xmlRegCheckCharacter()
2938 if (range->neg == 2) { in xmlRegCheckCharacter()
2939 ret = xmlRegCheckCharacterRange(range->type, codepoint, in xmlRegCheckCharacter()
2940 0, range->start, range->end, in xmlRegCheckCharacter()
2941 range->blockName); in xmlRegCheckCharacter()
2944 } else if (range->neg) { in xmlRegCheckCharacter()
2945 ret = xmlRegCheckCharacterRange(range->type, codepoint, in xmlRegCheckCharacter()
2946 0, range->start, range->end, in xmlRegCheckCharacter()
2947 range->blockName); in xmlRegCheckCharacter()
2953 ret = xmlRegCheckCharacterRange(range->type, codepoint, in xmlRegCheckCharacter()
2954 0, range->start, range->end, in xmlRegCheckCharacter()
2955 range->blockName); in xmlRegCheckCharacter()
2963 return(-1); in xmlRegCheckCharacter()
3012 ret = xmlRegCheckCharacterRange(atom->type, codepoint, 0, 0, 0, in xmlRegCheckCharacter()
3013 (const xmlChar *)atom->valuep); in xmlRegCheckCharacter()
3014 if (atom->neg) in xmlRegCheckCharacter()
3028 xmlFARegExecSave(xmlRegExecCtxtPtr exec) { in xmlFARegExecSave() argument
3030 if (exec->nbPush > MAX_PUSH) { in xmlFARegExecSave()
3031 exec->status = XML_REGEXP_INTERNAL_LIMIT; in xmlFARegExecSave()
3034 exec->nbPush++; in xmlFARegExecSave()
3037 if (exec->maxRollbacks == 0) { in xmlFARegExecSave()
3038 exec->maxRollbacks = 4; in xmlFARegExecSave()
3039 exec->rollbacks = (xmlRegExecRollback *) xmlMalloc(exec->maxRollbacks * in xmlFARegExecSave()
3041 if (exec->rollbacks == NULL) { in xmlFARegExecSave()
3042 exec->maxRollbacks = 0; in xmlFARegExecSave()
3043 exec->status = XML_REGEXP_OUT_OF_MEMORY; in xmlFARegExecSave()
3046 memset(exec->rollbacks, 0, in xmlFARegExecSave()
3047 exec->maxRollbacks * sizeof(xmlRegExecRollback)); in xmlFARegExecSave()
3048 } else if (exec->nbRollbacks >= exec->maxRollbacks) { in xmlFARegExecSave()
3050 int len = exec->maxRollbacks; in xmlFARegExecSave()
3052 exec->maxRollbacks *= 2; in xmlFARegExecSave()
3053 tmp = (xmlRegExecRollback *) xmlRealloc(exec->rollbacks, in xmlFARegExecSave()
3054 exec->maxRollbacks * sizeof(xmlRegExecRollback)); in xmlFARegExecSave()
3056 exec->maxRollbacks /= 2; in xmlFARegExecSave()
3057 exec->status = XML_REGEXP_OUT_OF_MEMORY; in xmlFARegExecSave()
3060 exec->rollbacks = tmp; in xmlFARegExecSave()
3061 tmp = &exec->rollbacks[len]; in xmlFARegExecSave()
3062 memset(tmp, 0, (exec->maxRollbacks - len) * sizeof(xmlRegExecRollback)); in xmlFARegExecSave()
3064 exec->rollbacks[exec->nbRollbacks].state = exec->state; in xmlFARegExecSave()
3065 exec->rollbacks[exec->nbRollbacks].index = exec->index; in xmlFARegExecSave()
3066 exec->rollbacks[exec->nbRollbacks].nextbranch = exec->transno + 1; in xmlFARegExecSave()
3067 if (exec->comp->nbCounters > 0) { in xmlFARegExecSave()
3068 if (exec->rollbacks[exec->nbRollbacks].counts == NULL) { in xmlFARegExecSave()
3069 exec->rollbacks[exec->nbRollbacks].counts = (int *) in xmlFARegExecSave()
3070 xmlMalloc(exec->comp->nbCounters * sizeof(int)); in xmlFARegExecSave()
3071 if (exec->rollbacks[exec->nbRollbacks].counts == NULL) { in xmlFARegExecSave()
3072 exec->status = XML_REGEXP_OUT_OF_MEMORY; in xmlFARegExecSave()
3076 memcpy(exec->rollbacks[exec->nbRollbacks].counts, exec->counts, in xmlFARegExecSave()
3077 exec->comp->nbCounters * sizeof(int)); in xmlFARegExecSave()
3079 exec->nbRollbacks++; in xmlFARegExecSave()
3083 xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) { in xmlFARegExecRollBack() argument
3084 if (exec->status != XML_REGEXP_OK) in xmlFARegExecRollBack()
3086 if (exec->nbRollbacks <= 0) { in xmlFARegExecRollBack()
3087 exec->status = XML_REGEXP_NOT_FOUND; in xmlFARegExecRollBack()
3090 exec->nbRollbacks--; in xmlFARegExecRollBack()
3091 exec->state = exec->rollbacks[exec->nbRollbacks].state; in xmlFARegExecRollBack()
3092 exec->index = exec->rollbacks[exec->nbRollbacks].index; in xmlFARegExecRollBack()
3093 exec->transno = exec->rollbacks[exec->nbRollbacks].nextbranch; in xmlFARegExecRollBack()
3094 if (exec->comp->nbCounters > 0) { in xmlFARegExecRollBack()
3095 if (exec->rollbacks[exec->nbRollbacks].counts == NULL) { in xmlFARegExecRollBack()
3096 exec->status = XML_REGEXP_INTERNAL_ERROR; in xmlFARegExecRollBack()
3099 if (exec->counts) { in xmlFARegExecRollBack()
3100 memcpy(exec->counts, exec->rollbacks[exec->nbRollbacks].counts, in xmlFARegExecRollBack()
3101 exec->comp->nbCounters * sizeof(int)); in xmlFARegExecRollBack()
3115 xmlRegExecCtxtPtr exec = &execval; in xmlFARegExec() local
3118 exec->inputString = content; in xmlFARegExec()
3119 exec->index = 0; in xmlFARegExec()
3120 exec->nbPush = 0; in xmlFARegExec()
3121 exec->determinist = 1; in xmlFARegExec()
3122 exec->maxRollbacks = 0; in xmlFARegExec()
3123 exec->nbRollbacks = 0; in xmlFARegExec()
3124 exec->rollbacks = NULL; in xmlFARegExec()
3125 exec->status = XML_REGEXP_OK; in xmlFARegExec()
3126 exec->comp = comp; in xmlFARegExec()
3127 exec->state = comp->states[0]; in xmlFARegExec()
3128 exec->transno = 0; in xmlFARegExec()
3129 exec->transcount = 0; in xmlFARegExec()
3130 exec->inputStack = NULL; in xmlFARegExec()
3131 exec->inputStackMax = 0; in xmlFARegExec()
3132 if (comp->nbCounters > 0) { in xmlFARegExec()
3133 exec->counts = (int *) xmlMalloc(comp->nbCounters * sizeof(int)); in xmlFARegExec()
3134 if (exec->counts == NULL) { in xmlFARegExec()
3137 memset(exec->counts, 0, comp->nbCounters * sizeof(int)); in xmlFARegExec()
3139 exec->counts = NULL; in xmlFARegExec()
3140 while ((exec->status == XML_REGEXP_OK) && (exec->state != NULL) && in xmlFARegExec()
3141 ((exec->inputString[exec->index] != 0) || in xmlFARegExec()
3142 ((exec->state != NULL) && in xmlFARegExec()
3143 (exec->state->type != XML_REGEXP_FINAL_STATE)))) { in xmlFARegExec()
3148 * If end of input on non-terminal state, rollback, however we may in xmlFARegExec()
3155 if ((exec->inputString[exec->index] == 0) && (exec->counts == NULL)) { in xmlFARegExec()
3160 if (exec->transno < exec->state->nbTrans) { in xmlFARegExec()
3161 trans = &exec->state->trans[exec->transno]; in xmlFARegExec()
3162 if (trans->to >=0) { in xmlFARegExec()
3163 atom = trans->atom; in xmlFARegExec()
3164 if (!((atom->min == 0) && (atom->max > 0))) in xmlFARegExec()
3171 exec->transcount = 0; in xmlFARegExec()
3172 for (;exec->transno < exec->state->nbTrans;exec->transno++) { in xmlFARegExec()
3173 trans = &exec->state->trans[exec->transno]; in xmlFARegExec()
3174 if (trans->to < 0) in xmlFARegExec()
3176 atom = trans->atom; in xmlFARegExec()
3179 if (trans->count >= 0) { in xmlFARegExec()
3183 if (exec->counts == NULL) { in xmlFARegExec()
3184 exec->status = XML_REGEXP_INTERNAL_ERROR; in xmlFARegExec()
3191 count = exec->counts[trans->count]; in xmlFARegExec()
3192 counter = &exec->comp->counters[trans->count]; in xmlFARegExec()
3193 ret = ((count >= counter->min) && (count <= counter->max)); in xmlFARegExec()
3194 if ((ret) && (counter->min != counter->max)) in xmlFARegExec()
3197 exec->status = XML_REGEXP_INTERNAL_ERROR; in xmlFARegExec()
3199 } else if (exec->inputString[exec->index] != 0) { in xmlFARegExec()
3201 codepoint = xmlGetUTF8Char(&exec->inputString[exec->index], in xmlFARegExec()
3204 exec->status = XML_REGEXP_INVALID_UTF8; in xmlFARegExec()
3208 if ((ret == 1) && (atom->min >= 0) && (atom->max > 0)) { in xmlFARegExec()
3209 xmlRegStatePtr to = comp->states[trans->to]; in xmlFARegExec()
3217 if (trans->counter >= 0) { in xmlFARegExec()
3220 if ((exec->counts == NULL) || in xmlFARegExec()
3221 (exec->comp == NULL) || in xmlFARegExec()
3222 (exec->comp->counters == NULL)) { in xmlFARegExec()
3223 exec->status = XML_REGEXP_INTERNAL_ERROR; in xmlFARegExec()
3226 counter = &exec->comp->counters[trans->counter]; in xmlFARegExec()
3227 if (exec->counts[trans->counter] >= counter->max) in xmlFARegExec()
3231 if (exec->state->nbTrans > exec->transno + 1) { in xmlFARegExec()
3232 xmlFARegExecSave(exec); in xmlFARegExec()
3233 if (exec->status != XML_REGEXP_OK) in xmlFARegExec()
3236 if (trans->counter >= 0) { in xmlFARegExec()
3237 exec->counts[trans->counter]++; in xmlFARegExec()
3239 exec->transcount = 1; in xmlFARegExec()
3244 if (exec->transcount == atom->max) { in xmlFARegExec()
3247 exec->index += len; in xmlFARegExec()
3251 if (exec->inputString[exec->index] == 0) { in xmlFARegExec()
3252 exec->index -= len; in xmlFARegExec()
3255 if (exec->transcount >= atom->min) { in xmlFARegExec()
3256 int transno = exec->transno; in xmlFARegExec()
3257 xmlRegStatePtr state = exec->state; in xmlFARegExec()
3262 exec->transno = -1; /* trick */ in xmlFARegExec()
3263 exec->state = to; in xmlFARegExec()
3264 xmlFARegExecSave(exec); in xmlFARegExec()
3265 if (exec->status != XML_REGEXP_OK) in xmlFARegExec()
3267 exec->transno = transno; in xmlFARegExec()
3268 exec->state = state; in xmlFARegExec()
3272 &exec->inputString[exec->index], &len); in xmlFARegExec()
3274 exec->status = XML_REGEXP_INVALID_UTF8; in xmlFARegExec()
3278 exec->transcount++; in xmlFARegExec()
3280 if (exec->transcount < atom->min) in xmlFARegExec()
3292 if (trans->counter >= 0) { in xmlFARegExec()
3293 if (exec->counts == NULL) { in xmlFARegExec()
3294 exec->status = XML_REGEXP_INTERNAL_ERROR; in xmlFARegExec()
3297 exec->counts[trans->counter]--; in xmlFARegExec()
3299 } else if ((ret == 0) && (atom->min == 0) && (atom->max > 0)) { in xmlFARegExec()
3305 exec->transcount = 1; in xmlFARegExec()
3309 } else if ((atom->min == 0) && (atom->max > 0)) { in xmlFARegExec()
3311 exec->transcount = 1; in xmlFARegExec()
3316 if ((trans->nd == 1) || in xmlFARegExec()
3317 ((trans->count >= 0) && (deter == 0) && in xmlFARegExec()
3318 (exec->state->nbTrans > exec->transno + 1))) { in xmlFARegExec()
3319 xmlFARegExecSave(exec); in xmlFARegExec()
3320 if (exec->status != XML_REGEXP_OK) in xmlFARegExec()
3323 if (trans->counter >= 0) { in xmlFARegExec()
3327 if ((exec->counts == NULL) || in xmlFARegExec()
3328 (exec->comp == NULL) || in xmlFARegExec()
3329 (exec->comp->counters == NULL)) { in xmlFARegExec()
3330 exec->status = XML_REGEXP_INTERNAL_ERROR; in xmlFARegExec()
3333 counter = &exec->comp->counters[trans->counter]; in xmlFARegExec()
3334 if (exec->counts[trans->counter] >= counter->max) in xmlFARegExec()
3336 exec->counts[trans->counter]++; in xmlFARegExec()
3338 if ((trans->count >= 0) && in xmlFARegExec()
3339 (trans->count < REGEXP_ALL_COUNTER)) { in xmlFARegExec()
3340 if (exec->counts == NULL) { in xmlFARegExec()
3341 exec->status = XML_REGEXP_INTERNAL_ERROR; in xmlFARegExec()
3344 exec->counts[trans->count] = 0; in xmlFARegExec()
3346 exec->state = comp->states[trans->to]; in xmlFARegExec()
3347 exec->transno = 0; in xmlFARegExec()
3348 if (trans->atom != NULL) { in xmlFARegExec()
3349 exec->index += len; in xmlFARegExec()
3353 exec->status = XML_REGEXP_INTERNAL_ERROR; in xmlFARegExec()
3357 if ((exec->transno != 0) || (exec->state->nbTrans == 0)) { in xmlFARegExec()
3362 exec->determinist = 0; in xmlFARegExec()
3363 xmlFARegExecRollBack(exec); in xmlFARegExec()
3369 if (exec->rollbacks != NULL) { in xmlFARegExec()
3370 if (exec->counts != NULL) { in xmlFARegExec()
3373 for (i = 0;i < exec->maxRollbacks;i++) in xmlFARegExec()
3374 if (exec->rollbacks[i].counts != NULL) in xmlFARegExec()
3375 xmlFree(exec->rollbacks[i].counts); in xmlFARegExec()
3377 xmlFree(exec->rollbacks); in xmlFARegExec()
3379 if (exec->state == NULL) in xmlFARegExec()
3381 if (exec->counts != NULL) in xmlFARegExec()
3382 xmlFree(exec->counts); in xmlFARegExec()
3383 if (exec->status == XML_REGEXP_OK) in xmlFARegExec()
3385 if (exec->status == XML_REGEXP_NOT_FOUND) in xmlFARegExec()
3387 return(exec->status); in xmlFARegExec()
3409 xmlRegExecCtxtPtr exec; in xmlRegNewExecCtxt() local
3413 if ((comp->compact == NULL) && (comp->states == NULL)) in xmlRegNewExecCtxt()
3415 exec = (xmlRegExecCtxtPtr) xmlMalloc(sizeof(xmlRegExecCtxt)); in xmlRegNewExecCtxt()
3416 if (exec == NULL) in xmlRegNewExecCtxt()
3418 memset(exec, 0, sizeof(xmlRegExecCtxt)); in xmlRegNewExecCtxt()
3419 exec->inputString = NULL; in xmlRegNewExecCtxt()
3420 exec->index = 0; in xmlRegNewExecCtxt()
3421 exec->determinist = 1; in xmlRegNewExecCtxt()
3422 exec->maxRollbacks = 0; in xmlRegNewExecCtxt()
3423 exec->nbRollbacks = 0; in xmlRegNewExecCtxt()
3424 exec->rollbacks = NULL; in xmlRegNewExecCtxt()
3425 exec->status = XML_REGEXP_OK; in xmlRegNewExecCtxt()
3426 exec->comp = comp; in xmlRegNewExecCtxt()
3427 if (comp->compact == NULL) in xmlRegNewExecCtxt()
3428 exec->state = comp->states[0]; in xmlRegNewExecCtxt()
3429 exec->transno = 0; in xmlRegNewExecCtxt()
3430 exec->transcount = 0; in xmlRegNewExecCtxt()
3431 exec->callback = callback; in xmlRegNewExecCtxt()
3432 exec->data = data; in xmlRegNewExecCtxt()
3433 if (comp->nbCounters > 0) { in xmlRegNewExecCtxt()
3435 * For error handling, exec->counts is allocated twice the size in xmlRegNewExecCtxt()
3438 exec->counts = (int *) xmlMalloc(comp->nbCounters * sizeof(int) in xmlRegNewExecCtxt()
3440 if (exec->counts == NULL) { in xmlRegNewExecCtxt()
3441 xmlFree(exec); in xmlRegNewExecCtxt()
3444 memset(exec->counts, 0, comp->nbCounters * sizeof(int) * 2); in xmlRegNewExecCtxt()
3445 exec->errCounts = &exec->counts[comp->nbCounters]; in xmlRegNewExecCtxt()
3447 exec->counts = NULL; in xmlRegNewExecCtxt()
3448 exec->errCounts = NULL; in xmlRegNewExecCtxt()
3450 exec->inputStackMax = 0; in xmlRegNewExecCtxt()
3451 exec->inputStackNr = 0; in xmlRegNewExecCtxt()
3452 exec->inputStack = NULL; in xmlRegNewExecCtxt()
3453 exec->errStateNo = -1; in xmlRegNewExecCtxt()
3454 exec->errString = NULL; in xmlRegNewExecCtxt()
3455 exec->nbPush = 0; in xmlRegNewExecCtxt()
3456 return(exec); in xmlRegNewExecCtxt()
3461 * @exec: a regular expression evaluation context
3466 xmlRegFreeExecCtxt(xmlRegExecCtxtPtr exec) { in xmlRegFreeExecCtxt() argument
3467 if (exec == NULL) in xmlRegFreeExecCtxt()
3470 if (exec->rollbacks != NULL) { in xmlRegFreeExecCtxt()
3471 if (exec->counts != NULL) { in xmlRegFreeExecCtxt()
3474 for (i = 0;i < exec->maxRollbacks;i++) in xmlRegFreeExecCtxt()
3475 if (exec->rollbacks[i].counts != NULL) in xmlRegFreeExecCtxt()
3476 xmlFree(exec->rollbacks[i].counts); in xmlRegFreeExecCtxt()
3478 xmlFree(exec->rollbacks); in xmlRegFreeExecCtxt()
3480 if (exec->counts != NULL) in xmlRegFreeExecCtxt()
3481 xmlFree(exec->counts); in xmlRegFreeExecCtxt()
3482 if (exec->inputStack != NULL) { in xmlRegFreeExecCtxt()
3485 for (i = 0;i < exec->inputStackNr;i++) { in xmlRegFreeExecCtxt()
3486 if (exec->inputStack[i].value != NULL) in xmlRegFreeExecCtxt()
3487 xmlFree(exec->inputStack[i].value); in xmlRegFreeExecCtxt()
3489 xmlFree(exec->inputStack); in xmlRegFreeExecCtxt()
3491 if (exec->errString != NULL) in xmlRegFreeExecCtxt()
3492 xmlFree(exec->errString); in xmlRegFreeExecCtxt()
3493 xmlFree(exec); in xmlRegFreeExecCtxt()
3497 xmlRegExecSetErrString(xmlRegExecCtxtPtr exec, const xmlChar *value) { in xmlRegExecSetErrString() argument
3498 if (exec->errString != NULL) in xmlRegExecSetErrString()
3499 xmlFree(exec->errString); in xmlRegExecSetErrString()
3501 exec->errString = NULL; in xmlRegExecSetErrString()
3503 exec->errString = xmlStrdup(value); in xmlRegExecSetErrString()
3504 if (exec->errString == NULL) { in xmlRegExecSetErrString()
3505 exec->status = XML_REGEXP_OUT_OF_MEMORY; in xmlRegExecSetErrString()
3506 return(-1); in xmlRegExecSetErrString()
3513 xmlFARegExecSaveInputString(xmlRegExecCtxtPtr exec, const xmlChar *value, in xmlFARegExecSaveInputString() argument
3515 if (exec->inputStackMax == 0) { in xmlFARegExecSaveInputString()
3516 exec->inputStackMax = 4; in xmlFARegExecSaveInputString()
3517 exec->inputStack = (xmlRegInputTokenPtr) in xmlFARegExecSaveInputString()
3518 xmlMalloc(exec->inputStackMax * sizeof(xmlRegInputToken)); in xmlFARegExecSaveInputString()
3519 if (exec->inputStack == NULL) { in xmlFARegExecSaveInputString()
3520 exec->inputStackMax = 0; in xmlFARegExecSaveInputString()
3521 exec->status = XML_REGEXP_OUT_OF_MEMORY; in xmlFARegExecSaveInputString()
3524 } else if (exec->inputStackNr + 1 >= exec->inputStackMax) { in xmlFARegExecSaveInputString()
3527 exec->inputStackMax *= 2; in xmlFARegExecSaveInputString()
3528 tmp = (xmlRegInputTokenPtr) xmlRealloc(exec->inputStack, in xmlFARegExecSaveInputString()
3529 exec->inputStackMax * sizeof(xmlRegInputToken)); in xmlFARegExecSaveInputString()
3531 exec->inputStackMax /= 2; in xmlFARegExecSaveInputString()
3532 exec->status = XML_REGEXP_OUT_OF_MEMORY; in xmlFARegExecSaveInputString()
3535 exec->inputStack = tmp; in xmlFARegExecSaveInputString()
3538 exec->inputStack[exec->inputStackNr].value = NULL; in xmlFARegExecSaveInputString()
3540 exec->inputStack[exec->inputStackNr].value = xmlStrdup(value); in xmlFARegExecSaveInputString()
3541 if (exec->inputStack[exec->inputStackNr].value == NULL) { in xmlFARegExecSaveInputString()
3542 exec->status = XML_REGEXP_OUT_OF_MEMORY; in xmlFARegExecSaveInputString()
3546 exec->inputStack[exec->inputStackNr].data = data; in xmlFARegExecSaveInputString()
3547 exec->inputStackNr++; in xmlFARegExecSaveInputString()
3548 exec->inputStack[exec->inputStackNr].value = NULL; in xmlFARegExecSaveInputString()
3549 exec->inputStack[exec->inputStackNr].data = NULL; in xmlFARegExecSaveInputString()
3604 * @exec: a regexp execution context
3605 * @comp: the precompiled exec with a compact table
3611 * Returns: 1 if the regexp reached a final state, 0 if non-final, and
3615 xmlRegCompactPushString(xmlRegExecCtxtPtr exec, in xmlRegCompactPushString() argument
3619 int state = exec->index; in xmlRegCompactPushString()
3622 if ((comp == NULL) || (comp->compact == NULL) || (comp->stringMap == NULL)) in xmlRegCompactPushString()
3623 return(-1); in xmlRegCompactPushString()
3629 if (comp->compact[state * (comp->nbstrings + 1)] == in xmlRegCompactPushString()
3638 for (i = 0;i < comp->nbstrings;i++) { in xmlRegCompactPushString()
3639 target = comp->compact[state * (comp->nbstrings + 1) + i + 1]; in xmlRegCompactPushString()
3640 if ((target > 0) && (target <= comp->nbstates)) { in xmlRegCompactPushString()
3641 target--; /* to avoid 0 */ in xmlRegCompactPushString()
3642 if (xmlRegStrEqualWildcard(comp->stringMap[i], value)) { in xmlRegCompactPushString()
3643 exec->index = target; in xmlRegCompactPushString()
3644 if ((exec->callback != NULL) && (comp->transdata != NULL)) { in xmlRegCompactPushString()
3645 exec->callback(exec->data, value, in xmlRegCompactPushString()
3646 comp->transdata[state * comp->nbstrings + i], data); in xmlRegCompactPushString()
3648 if (comp->compact[target * (comp->nbstrings + 1)] == in xmlRegCompactPushString()
3652 if (comp->compact[target * (comp->nbstrings + 1)] == in xmlRegCompactPushString()
3664 exec->errStateNo = state; in xmlRegCompactPushString()
3665 exec->status = XML_REGEXP_NOT_FOUND; in xmlRegCompactPushString()
3666 xmlRegExecSetErrString(exec, value); in xmlRegCompactPushString()
3667 return(exec->status); in xmlRegCompactPushString()
3672 * @exec: a regexp execution context or NULL to indicate the end
3679 * Returns: 1 if the regexp reached a final state, 0 if non-final, and
3683 xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value, in xmlRegExecPushStringInternal() argument
3691 if (exec == NULL) in xmlRegExecPushStringInternal()
3692 return(-1); in xmlRegExecPushStringInternal()
3693 if (exec->comp == NULL) in xmlRegExecPushStringInternal()
3694 return(-1); in xmlRegExecPushStringInternal()
3695 if (exec->status != XML_REGEXP_OK) in xmlRegExecPushStringInternal()
3696 return(exec->status); in xmlRegExecPushStringInternal()
3698 if (exec->comp->compact != NULL) in xmlRegExecPushStringInternal()
3699 return(xmlRegCompactPushString(exec, exec->comp, value, data)); in xmlRegExecPushStringInternal()
3702 if (exec->state->type == XML_REGEXP_FINAL_STATE) in xmlRegExecPushStringInternal()
3711 if ((value != NULL) && (exec->inputStackNr > 0)) { in xmlRegExecPushStringInternal()
3712 xmlFARegExecSaveInputString(exec, value, data); in xmlRegExecPushStringInternal()
3713 value = exec->inputStack[exec->index].value; in xmlRegExecPushStringInternal()
3714 data = exec->inputStack[exec->index].data; in xmlRegExecPushStringInternal()
3717 while ((exec->status == XML_REGEXP_OK) && in xmlRegExecPushStringInternal()
3720 (exec->state->type != XML_REGEXP_FINAL_STATE)))) { in xmlRegExecPushStringInternal()
3723 * End of input on non-terminal state, rollback, however we may in xmlRegExecPushStringInternal()
3727 if ((value == NULL) && (exec->counts == NULL)) in xmlRegExecPushStringInternal()
3730 exec->transcount = 0; in xmlRegExecPushStringInternal()
3731 for (;exec->transno < exec->state->nbTrans;exec->transno++) { in xmlRegExecPushStringInternal()
3732 trans = &exec->state->trans[exec->transno]; in xmlRegExecPushStringInternal()
3733 if (trans->to < 0) in xmlRegExecPushStringInternal()
3735 atom = trans->atom; in xmlRegExecPushStringInternal()
3737 if (trans->count == REGEXP_ALL_LAX_COUNTER) { in xmlRegExecPushStringInternal()
3751 for (i = 0;i < exec->state->nbTrans;i++) { in xmlRegExecPushStringInternal()
3752 t = &exec->state->trans[i]; in xmlRegExecPushStringInternal()
3753 if ((t->counter < 0) || (t == trans)) in xmlRegExecPushStringInternal()
3755 counter = &exec->comp->counters[t->counter]; in xmlRegExecPushStringInternal()
3756 count = exec->counts[t->counter]; in xmlRegExecPushStringInternal()
3757 if ((count < counter->max) && in xmlRegExecPushStringInternal()
3758 (t->atom != NULL) && in xmlRegExecPushStringInternal()
3759 (xmlStrEqual(value, t->atom->valuep))) { in xmlRegExecPushStringInternal()
3763 if ((count >= counter->min) && in xmlRegExecPushStringInternal()
3764 (count < counter->max) && in xmlRegExecPushStringInternal()
3765 (t->atom != NULL) && in xmlRegExecPushStringInternal()
3766 (xmlStrEqual(value, t->atom->valuep))) { in xmlRegExecPushStringInternal()
3772 } else if (trans->count == REGEXP_ALL_COUNTER) { in xmlRegExecPushStringInternal()
3783 for (i = 0;i < exec->state->nbTrans;i++) { in xmlRegExecPushStringInternal()
3784 t = &exec->state->trans[i]; in xmlRegExecPushStringInternal()
3785 if ((t->counter < 0) || (t == trans)) in xmlRegExecPushStringInternal()
3787 counter = &exec->comp->counters[t->counter]; in xmlRegExecPushStringInternal()
3788 count = exec->counts[t->counter]; in xmlRegExecPushStringInternal()
3789 if ((count < counter->min) || (count > counter->max)) { in xmlRegExecPushStringInternal()
3794 } else if (trans->count >= 0) { in xmlRegExecPushStringInternal()
3802 count = exec->counts[trans->count]; in xmlRegExecPushStringInternal()
3803 counter = &exec->comp->counters[trans->count]; in xmlRegExecPushStringInternal()
3804 ret = ((count >= counter->min) && (count <= counter->max)); in xmlRegExecPushStringInternal()
3806 exec->status = XML_REGEXP_INTERNAL_ERROR; in xmlRegExecPushStringInternal()
3809 ret = xmlRegStrEqualWildcard(atom->valuep, value); in xmlRegExecPushStringInternal()
3810 if (atom->neg) { in xmlRegExecPushStringInternal()
3815 if ((ret == 1) && (trans->counter >= 0)) { in xmlRegExecPushStringInternal()
3819 count = exec->counts[trans->counter]; in xmlRegExecPushStringInternal()
3820 counter = &exec->comp->counters[trans->counter]; in xmlRegExecPushStringInternal()
3821 if (count >= counter->max) in xmlRegExecPushStringInternal()
3825 if ((ret == 1) && (atom->min > 0) && (atom->max > 0)) { in xmlRegExecPushStringInternal()
3826 xmlRegStatePtr to = exec->comp->states[trans->to]; in xmlRegExecPushStringInternal()
3831 if (exec->state->nbTrans > exec->transno + 1) { in xmlRegExecPushStringInternal()
3832 if (exec->inputStackNr <= 0) { in xmlRegExecPushStringInternal()
3833 xmlFARegExecSaveInputString(exec, value, data); in xmlRegExecPushStringInternal()
3835 xmlFARegExecSave(exec); in xmlRegExecPushStringInternal()
3837 exec->transcount = 1; in xmlRegExecPushStringInternal()
3842 if (exec->transcount == atom->max) { in xmlRegExecPushStringInternal()
3845 exec->index++; in xmlRegExecPushStringInternal()
3846 value = exec->inputStack[exec->index].value; in xmlRegExecPushStringInternal()
3847 data = exec->inputStack[exec->index].data; in xmlRegExecPushStringInternal()
3853 exec->index --; in xmlRegExecPushStringInternal()
3856 if (exec->transcount >= atom->min) { in xmlRegExecPushStringInternal()
3857 int transno = exec->transno; in xmlRegExecPushStringInternal()
3858 xmlRegStatePtr state = exec->state; in xmlRegExecPushStringInternal()
3863 exec->transno = -1; /* trick */ in xmlRegExecPushStringInternal()
3864 exec->state = to; in xmlRegExecPushStringInternal()
3865 if (exec->inputStackNr <= 0) { in xmlRegExecPushStringInternal()
3866 xmlFARegExecSaveInputString(exec, value, data); in xmlRegExecPushStringInternal()
3868 xmlFARegExecSave(exec); in xmlRegExecPushStringInternal()
3869 exec->transno = transno; in xmlRegExecPushStringInternal()
3870 exec->state = state; in xmlRegExecPushStringInternal()
3872 ret = xmlStrEqual(value, atom->valuep); in xmlRegExecPushStringInternal()
3873 exec->transcount++; in xmlRegExecPushStringInternal()
3875 if (exec->transcount < atom->min) in xmlRegExecPushStringInternal()
3890 if ((exec->callback != NULL) && (atom != NULL) && in xmlRegExecPushStringInternal()
3892 exec->callback(exec->data, atom->valuep, in xmlRegExecPushStringInternal()
3893 atom->data, data); in xmlRegExecPushStringInternal()
3895 if (exec->state->nbTrans > exec->transno + 1) { in xmlRegExecPushStringInternal()
3896 if (exec->inputStackNr <= 0) { in xmlRegExecPushStringInternal()
3897 xmlFARegExecSaveInputString(exec, value, data); in xmlRegExecPushStringInternal()
3899 xmlFARegExecSave(exec); in xmlRegExecPushStringInternal()
3901 if (trans->counter >= 0) { in xmlRegExecPushStringInternal()
3902 exec->counts[trans->counter]++; in xmlRegExecPushStringInternal()
3904 if ((trans->count >= 0) && in xmlRegExecPushStringInternal()
3905 (trans->count < REGEXP_ALL_COUNTER)) { in xmlRegExecPushStringInternal()
3906 exec->counts[trans->count] = 0; in xmlRegExecPushStringInternal()
3908 if ((exec->comp->states[trans->to] != NULL) && in xmlRegExecPushStringInternal()
3909 (exec->comp->states[trans->to]->type == in xmlRegExecPushStringInternal()
3915 if (xmlRegExecSetErrString(exec, value) < 0) in xmlRegExecPushStringInternal()
3917 exec->errState = exec->state; in xmlRegExecPushStringInternal()
3918 memcpy(exec->errCounts, exec->counts, in xmlRegExecPushStringInternal()
3919 exec->comp->nbCounters * sizeof(int)); in xmlRegExecPushStringInternal()
3921 exec->state = exec->comp->states[trans->to]; in xmlRegExecPushStringInternal()
3922 exec->transno = 0; in xmlRegExecPushStringInternal()
3923 if (trans->atom != NULL) { in xmlRegExecPushStringInternal()
3924 if (exec->inputStack != NULL) { in xmlRegExecPushStringInternal()
3925 exec->index++; in xmlRegExecPushStringInternal()
3926 if (exec->index < exec->inputStackNr) { in xmlRegExecPushStringInternal()
3927 value = exec->inputStack[exec->index].value; in xmlRegExecPushStringInternal()
3928 data = exec->inputStack[exec->index].data; in xmlRegExecPushStringInternal()
3940 exec->status = XML_REGEXP_INTERNAL_ERROR; in xmlRegExecPushStringInternal()
3944 if ((exec->transno != 0) || (exec->state->nbTrans == 0)) { in xmlRegExecPushStringInternal()
3950 if ((progress) && (exec->state != NULL) && in xmlRegExecPushStringInternal()
3951 (exec->state->type != XML_REGEXP_SINK_STATE)) { in xmlRegExecPushStringInternal()
3953 if (xmlRegExecSetErrString(exec, value) < 0) in xmlRegExecPushStringInternal()
3955 exec->errState = exec->state; in xmlRegExecPushStringInternal()
3956 if (exec->comp->nbCounters) in xmlRegExecPushStringInternal()
3957 memcpy(exec->errCounts, exec->counts, in xmlRegExecPushStringInternal()
3958 exec->comp->nbCounters * sizeof(int)); in xmlRegExecPushStringInternal()
3964 exec->determinist = 0; in xmlRegExecPushStringInternal()
3965 xmlFARegExecRollBack(exec); in xmlRegExecPushStringInternal()
3966 if ((exec->inputStack != NULL ) && in xmlRegExecPushStringInternal()
3967 (exec->status == XML_REGEXP_OK)) { in xmlRegExecPushStringInternal()
3968 value = exec->inputStack[exec->index].value; in xmlRegExecPushStringInternal()
3969 data = exec->inputStack[exec->index].data; in xmlRegExecPushStringInternal()
3976 if (exec->status == XML_REGEXP_OK) { in xmlRegExecPushStringInternal()
3977 return(exec->state->type == XML_REGEXP_FINAL_STATE); in xmlRegExecPushStringInternal()
3979 return(exec->status); in xmlRegExecPushStringInternal()
3984 * @exec: a regexp execution context or NULL to indicate the end
3990 * Returns: 1 if the regexp reached a final state, 0 if non-final, and
3994 xmlRegExecPushString(xmlRegExecCtxtPtr exec, const xmlChar *value, in xmlRegExecPushString() argument
3996 return(xmlRegExecPushStringInternal(exec, value, data, 0)); in xmlRegExecPushString()
4001 * @exec: a regexp execution context or NULL to indicate the end
4008 * Returns: 1 if the regexp reached a final state, 0 if non-final, and
4012 xmlRegExecPushString2(xmlRegExecCtxtPtr exec, const xmlChar *value, in xmlRegExecPushString2() argument
4018 if (exec == NULL) in xmlRegExecPushString2()
4019 return(-1); in xmlRegExecPushString2()
4020 if (exec->comp == NULL) in xmlRegExecPushString2()
4021 return(-1); in xmlRegExecPushString2()
4022 if (exec->status != XML_REGEXP_OK) in xmlRegExecPushString2()
4023 return(exec->status); in xmlRegExecPushString2()
4026 return(xmlRegExecPushString(exec, value, data)); in xmlRegExecPushString2()
4034 exec->status = XML_REGEXP_OUT_OF_MEMORY; in xmlRegExecPushString2()
4035 return(-1); in xmlRegExecPushString2()
4045 if (exec->comp->compact != NULL) in xmlRegExecPushString2()
4046 ret = xmlRegCompactPushString(exec, exec->comp, str, data); in xmlRegExecPushString2()
4048 ret = xmlRegExecPushStringInternal(exec, str, data, 1); in xmlRegExecPushString2()
4057 * @exec: a regexp execution context
4067 * Returns: 0 in case of success or -1 in case of error.
4070 xmlRegExecGetValues(xmlRegExecCtxtPtr exec, int err, in xmlRegExecGetValues() argument
4076 if ((exec == NULL) || (nbval == NULL) || (nbneg == NULL) || in xmlRegExecGetValues()
4078 return(-1); in xmlRegExecGetValues()
4083 if ((exec->comp != NULL) && (exec->comp->compact != NULL)) { in xmlRegExecGetValues()
4087 comp = exec->comp; in xmlRegExecGetValues()
4090 if (exec->errStateNo == -1) return(-1); in xmlRegExecGetValues()
4091 state = exec->errStateNo; in xmlRegExecGetValues()
4093 state = exec->index; in xmlRegExecGetValues()
4096 if (comp->compact[state * (comp->nbstrings + 1)] == in xmlRegExecGetValues()
4102 for (i = 0;(i < comp->nbstrings) && (nb < maxval);i++) { in xmlRegExecGetValues()
4103 target = comp->compact[state * (comp->nbstrings + 1) + i + 1]; in xmlRegExecGetValues()
4104 if ((target > 0) && (target <= comp->nbstates) && in xmlRegExecGetValues()
4105 (comp->compact[(target - 1) * (comp->nbstrings + 1)] != in xmlRegExecGetValues()
4107 values[nb++] = comp->stringMap[i]; in xmlRegExecGetValues()
4111 for (i = 0;(i < comp->nbstrings) && (nb < maxval);i++) { in xmlRegExecGetValues()
4112 target = comp->compact[state * (comp->nbstrings + 1) + i + 1]; in xmlRegExecGetValues()
4113 if ((target > 0) && (target <= comp->nbstates) && in xmlRegExecGetValues()
4114 (comp->compact[(target - 1) * (comp->nbstrings + 1)] == in xmlRegExecGetValues()
4116 values[nb++] = comp->stringMap[i]; in xmlRegExecGetValues()
4127 if (exec->state->type == XML_REGEXP_FINAL_STATE) in xmlRegExecGetValues()
4134 if (exec->errState == NULL) return(-1); in xmlRegExecGetValues()
4135 state = exec->errState; in xmlRegExecGetValues()
4137 if (exec->state == NULL) return(-1); in xmlRegExecGetValues()
4138 state = exec->state; in xmlRegExecGetValues()
4141 (transno < state->nbTrans) && (nb < maxval); in xmlRegExecGetValues()
4143 trans = &state->trans[transno]; in xmlRegExecGetValues()
4144 if (trans->to < 0) in xmlRegExecGetValues()
4146 atom = trans->atom; in xmlRegExecGetValues()
4147 if ((atom == NULL) || (atom->valuep == NULL)) in xmlRegExecGetValues()
4149 if (trans->count == REGEXP_ALL_LAX_COUNTER) { in xmlRegExecGetValues()
4151 } else if (trans->count == REGEXP_ALL_COUNTER) { in xmlRegExecGetValues()
4153 } else if (trans->counter >= 0) { in xmlRegExecGetValues()
4158 count = exec->errCounts[trans->counter]; in xmlRegExecGetValues()
4160 count = exec->counts[trans->counter]; in xmlRegExecGetValues()
4161 if (exec->comp != NULL) in xmlRegExecGetValues()
4162 counter = &exec->comp->counters[trans->counter]; in xmlRegExecGetValues()
4163 if ((counter == NULL) || (count < counter->max)) { in xmlRegExecGetValues()
4164 if (atom->neg) in xmlRegExecGetValues()
4165 values[nb++] = (xmlChar *) atom->valuep2; in xmlRegExecGetValues()
4167 values[nb++] = (xmlChar *) atom->valuep; in xmlRegExecGetValues()
4171 if ((exec->comp != NULL) && (exec->comp->states[trans->to] != NULL) && in xmlRegExecGetValues()
4172 (exec->comp->states[trans->to]->type != in xmlRegExecGetValues()
4174 if (atom->neg) in xmlRegExecGetValues()
4175 values[nb++] = (xmlChar *) atom->valuep2; in xmlRegExecGetValues()
4177 values[nb++] = (xmlChar *) atom->valuep; in xmlRegExecGetValues()
4183 (transno < state->nbTrans) && (nb < maxval); in xmlRegExecGetValues()
4185 trans = &state->trans[transno]; in xmlRegExecGetValues()
4186 if (trans->to < 0) in xmlRegExecGetValues()
4188 atom = trans->atom; in xmlRegExecGetValues()
4189 if ((atom == NULL) || (atom->valuep == NULL)) in xmlRegExecGetValues()
4191 if (trans->count == REGEXP_ALL_LAX_COUNTER) { in xmlRegExecGetValues()
4193 } else if (trans->count == REGEXP_ALL_COUNTER) { in xmlRegExecGetValues()
4195 } else if (trans->counter >= 0) { in xmlRegExecGetValues()
4198 if ((exec->comp->states[trans->to] != NULL) && in xmlRegExecGetValues()
4199 (exec->comp->states[trans->to]->type == in xmlRegExecGetValues()
4201 if (atom->neg) in xmlRegExecGetValues()
4202 values[nb++] = (xmlChar *) atom->valuep2; in xmlRegExecGetValues()
4204 values[nb++] = (xmlChar *) atom->valuep; in xmlRegExecGetValues()
4215 * @exec: a regexp execution context
4225 * returned will be freed with the @exec context and don't need to be
4228 * Returns: 0 in case of success or -1 in case of error.
4231 xmlRegExecNextValues(xmlRegExecCtxtPtr exec, int *nbval, int *nbneg, in xmlRegExecNextValues() argument
4233 return(xmlRegExecGetValues(exec, 0, nbval, nbneg, values, terminal)); in xmlRegExecNextValues()
4238 * @exec: a regexp execution context generating an error
4250 * returned will be freed with the @exec context and don't need to be
4253 * Returns: 0 in case of success or -1 in case of error.
4256 xmlRegExecErrInfo(xmlRegExecCtxtPtr exec, const xmlChar **string, in xmlRegExecErrInfo() argument
4258 if (exec == NULL) in xmlRegExecErrInfo()
4259 return(-1); in xmlRegExecErrInfo()
4261 if (exec->status != XML_REGEXP_OK) in xmlRegExecErrInfo()
4262 *string = exec->errString; in xmlRegExecErrInfo()
4266 return(xmlRegExecGetValues(exec, 1, nbval, nbneg, values, terminal)); in xmlRegExecErrInfo()
4272 * http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#regexs *
4288 cur = xmlGetUTF8Char(ctxt->cur, &len); in xmlFAIsChar()
4290 ERROR("Invalid UTF-8"); in xmlFAIsChar()
4297 return(-1); in xmlFAIsChar()
4315 * [36] IsBlock ::= 'Is' [a-zA-Z0-9#x2D]+
4492 start = ctxt->cur; in xmlFAParseCharProp()
4509 blockName = xmlStrndup(start, ctxt->cur - start); in xmlFAParseCharProp()
4516 if (ctxt->atom == NULL) { in xmlFAParseCharProp()
4517 ctxt->atom = xmlRegNewAtom(ctxt, type); in xmlFAParseCharProp()
4518 if (ctxt->atom == NULL) { in xmlFAParseCharProp()
4522 ctxt->atom->valuep = blockName; in xmlFAParseCharProp()
4523 } else if (ctxt->atom->type == XML_REGEXP_RANGES) { in xmlFAParseCharProp()
4524 if (xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, in xmlFAParseCharProp()
4539 val += cur - '0'; in parse_escaped_codeunit()
4541 val += cur - 'A' + 10; in parse_escaped_codeunit()
4543 val += cur - 'a' + 10; in parse_escaped_codeunit()
4546 return -1; in parse_escaped_codeunit()
4562 return (val - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000; in parse_escaped_codepoint()
4567 val = -1; in parse_escaped_codepoint()
4587 if (ctxt->atom == NULL) { in xmlFAParseCharClassEsc()
4588 ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_ANYCHAR); in xmlFAParseCharClassEsc()
4589 } else if (ctxt->atom->type == XML_REGEXP_RANGES) { in xmlFAParseCharClassEsc()
4590 xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, in xmlFAParseCharClassEsc()
4623 if (ctxt->atom != NULL) in xmlFAParseCharClassEsc()
4624 ctxt->atom->neg = 1; in xmlFAParseCharClassEsc()
4636 /* Non-standard escape sequences: in xmlFAParseCharClassEsc()
4653 if (ctxt->atom == NULL) { in xmlFAParseCharClassEsc()
4654 ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_CHARVAL); in xmlFAParseCharClassEsc()
4655 if (ctxt->atom != NULL) { in xmlFAParseCharClassEsc()
4658 ctxt->atom->codepoint = '\n'; in xmlFAParseCharClassEsc()
4661 ctxt->atom->codepoint = '\r'; in xmlFAParseCharClassEsc()
4664 ctxt->atom->codepoint = '\t'; in xmlFAParseCharClassEsc()
4671 ctxt->atom->codepoint = cur; in xmlFAParseCharClassEsc()
4674 ctxt->atom->codepoint = cur; in xmlFAParseCharClassEsc()
4677 } else if (ctxt->atom->type == XML_REGEXP_RANGES) { in xmlFAParseCharClassEsc()
4689 xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, in xmlFAParseCharClassEsc()
4731 if (ctxt->atom == NULL) { in xmlFAParseCharClassEsc()
4732 ctxt->atom = xmlRegNewAtom(ctxt, type); in xmlFAParseCharClassEsc()
4733 } else if (ctxt->atom->type == XML_REGEXP_RANGES) { in xmlFAParseCharClassEsc()
4734 xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, in xmlFAParseCharClassEsc()
4747 * [18] seRange ::= charOrEsc '-' charOrEsc
4755 int start = -1; in xmlFAParseCharRange()
4756 int end = -1; in xmlFAParseCharRange()
4771 case '\\': case '|': case '.': case '-': case '^': case '?': in xmlFAParseCharRange()
4783 end = start = xmlGetUTF8Char(ctxt->cur, &len); in xmlFAParseCharRange()
4785 ERROR("Invalid UTF-8"); in xmlFAParseCharRange()
4793 * Since we are "inside" a range, we can assume ctxt->cur is past in xmlFAParseCharRange()
4794 * the start of ctxt->string, and PREV should be safe in xmlFAParseCharRange()
4796 if ((start == '-') && (NXT(1) != ']') && (PREV != '[') && (PREV != '^')) { in xmlFAParseCharRange()
4802 if ((cur != '-') || (NXT(1) == '[') || (NXT(1) == ']')) { in xmlFAParseCharRange()
4803 xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, in xmlFAParseCharRange()
4816 case '\\': case '|': case '.': case '-': case '^': case '?': in xmlFAParseCharRange()
4827 end = xmlGetUTF8Char(ctxt->cur, &len); in xmlFAParseCharRange()
4829 ERROR("Invalid UTF-8"); in xmlFAParseCharRange()
4842 xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, in xmlFAParseCharRange()
4861 } while ((CUR != ']') && (CUR != '-') && in xmlFAParsePosCharGroup()
4862 (CUR != 0) && (ctxt->error == 0)); in xmlFAParsePosCharGroup()
4871 * [16] charClassSub ::= ( posCharGroup | negCharGroup ) '-' charClassExpr
4876 int neg = ctxt->neg; in xmlFAParseCharGroup()
4880 ctxt->neg = !ctxt->neg; in xmlFAParseCharGroup()
4882 ctxt->neg = neg; in xmlFAParseCharGroup()
4884 while ((CUR != ']') && (ctxt->error == 0)) { in xmlFAParseCharGroup()
4885 if ((CUR == '-') && (NXT(1) == '[')) { in xmlFAParseCharGroup()
4886 NEXT; /* eat the '-' */ in xmlFAParseCharGroup()
4888 ctxt->neg = 2; in xmlFAParseCharGroup()
4890 ctxt->neg = neg; in xmlFAParseCharGroup()
4914 ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_RANGES); in xmlFAParseCharClass()
4915 if (ctxt->atom == NULL) in xmlFAParseCharClass()
4932 * [8] QuantExact ::= [0-9]+
4934 * Returns 0 if success or -1 in case of error
4946 int digit = CUR - '0'; in xmlFAParseQuantExact()
4949 if (ret > INT_MAX - digit) in xmlFAParseQuantExact()
4958 return(-1); in xmlFAParseQuantExact()
4971 * [8] QuantExact ::= [0-9]+
4979 if (ctxt->atom != NULL) { in xmlFAParseQuantifier()
4981 ctxt->atom->quant = XML_REGEXP_QUANT_OPT; in xmlFAParseQuantifier()
4983 ctxt->atom->quant = XML_REGEXP_QUANT_MULT; in xmlFAParseQuantifier()
4985 ctxt->atom->quant = XML_REGEXP_QUANT_PLUS; in xmlFAParseQuantifier()
5020 if (ctxt->atom != NULL) { in xmlFAParseQuantifier()
5021 ctxt->atom->quant = XML_REGEXP_QUANT_RANGE; in xmlFAParseQuantifier()
5022 ctxt->atom->min = min; in xmlFAParseQuantifier()
5023 ctxt->atom->max = max; in xmlFAParseQuantifier()
5042 ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_CHARVAL); in xmlFAParseAtom()
5043 if (ctxt->atom == NULL) in xmlFAParseAtom()
5044 return(-1); in xmlFAParseAtom()
5046 codepoint = xmlGetUTF8Char(ctxt->cur, &len); in xmlFAParseAtom()
5048 ERROR("Invalid UTF-8"); in xmlFAParseAtom()
5049 return(-1); in xmlFAParseAtom()
5051 ctxt->atom->codepoint = codepoint; in xmlFAParseAtom()
5064 if (ctxt->depth >= 50) { in xmlFAParseAtom()
5066 return(-1); in xmlFAParseAtom()
5072 xmlFAGenerateEpsilonTransition(ctxt, ctxt->state, NULL); in xmlFAParseAtom()
5073 start0 = ctxt->state; in xmlFAParseAtom()
5074 xmlFAGenerateEpsilonTransition(ctxt, ctxt->state, NULL); in xmlFAParseAtom()
5075 start = ctxt->state; in xmlFAParseAtom()
5076 oldend = ctxt->end; in xmlFAParseAtom()
5077 ctxt->end = NULL; in xmlFAParseAtom()
5078 ctxt->atom = NULL; in xmlFAParseAtom()
5079 ctxt->depth++; in xmlFAParseAtom()
5081 ctxt->depth--; in xmlFAParseAtom()
5087 ctxt->atom = xmlRegNewAtom(ctxt, XML_REGEXP_SUBREG); in xmlFAParseAtom()
5088 if (ctxt->atom == NULL) in xmlFAParseAtom()
5089 return(-1); in xmlFAParseAtom()
5090 ctxt->atom->start = start; in xmlFAParseAtom()
5091 ctxt->atom->start0 = start0; in xmlFAParseAtom()
5092 ctxt->atom->stop = ctxt->state; in xmlFAParseAtom()
5093 ctxt->end = oldend; in xmlFAParseAtom()
5112 ctxt->atom = NULL; in xmlFAParsePiece()
5116 if (ctxt->atom == NULL) { in xmlFAParsePiece()
5138 previous = ctxt->state; in xmlFAParseBranch()
5146 ctxt->atom) < 0) { in xmlFAParseBranch()
5147 xmlRegFreeAtom(ctxt->atom); in xmlFAParseBranch()
5148 ctxt->atom = NULL; in xmlFAParseBranch()
5149 return(-1); in xmlFAParseBranch()
5151 previous = ctxt->state; in xmlFAParseBranch()
5152 ctxt->atom = NULL; in xmlFAParseBranch()
5154 while ((ret != 0) && (ctxt->error == 0)) { in xmlFAParseBranch()
5159 ctxt->atom) < 0) { in xmlFAParseBranch()
5160 xmlRegFreeAtom(ctxt->atom); in xmlFAParseBranch()
5161 ctxt->atom = NULL; in xmlFAParseBranch()
5162 return(-1); in xmlFAParseBranch()
5164 previous = ctxt->state; in xmlFAParseBranch()
5165 ctxt->atom = NULL; in xmlFAParseBranch()
5174 * @top: is this the top-level expression ?
5183 start = ctxt->state; in xmlFAParseRegExp()
5184 ctxt->end = NULL; in xmlFAParseRegExp()
5187 ctxt->state->type = XML_REGEXP_FINAL_STATE; in xmlFAParseRegExp()
5190 ctxt->end = ctxt->state; in xmlFAParseRegExp()
5193 end = ctxt->state; in xmlFAParseRegExp()
5194 while ((CUR == '|') && (ctxt->error == 0)) { in xmlFAParseRegExp()
5196 ctxt->state = start; in xmlFAParseRegExp()
5197 ctxt->end = NULL; in xmlFAParseRegExp()
5201 ctxt->state = end; in xmlFAParseRegExp()
5202 ctxt->end = end; in xmlFAParseRegExp()
5230 fprintf(output, "'%s' ", regexp->string); in xmlRegexpPrint()
5232 fprintf(output, "%d atoms:\n", regexp->nbAtoms); in xmlRegexpPrint()
5233 for (i = 0;i < regexp->nbAtoms; i++) { in xmlRegexpPrint()
5235 xmlRegPrintAtom(output, regexp->atoms[i]); in xmlRegexpPrint()
5237 fprintf(output, "%d states:", regexp->nbStates); in xmlRegexpPrint()
5239 for (i = 0;i < regexp->nbStates; i++) { in xmlRegexpPrint()
5240 xmlRegPrintState(output, regexp->states[i]); in xmlRegexpPrint()
5242 fprintf(output, "%d counters:\n", regexp->nbCounters); in xmlRegexpPrint()
5243 for (i = 0;i < regexp->nbCounters; i++) { in xmlRegexpPrint()
5244 fprintf(output, " %d: min %d max %d\n", i, regexp->counters[i].min, in xmlRegexpPrint()
5245 regexp->counters[i].max); in xmlRegexpPrint()
5272 ctxt->state = xmlRegStatePush(ctxt); in xmlRegexpCompile()
5273 if (ctxt->state == NULL) in xmlRegexpCompile()
5275 ctxt->start = ctxt->state; in xmlRegexpCompile()
5276 ctxt->end = NULL; in xmlRegexpCompile()
5283 if (ctxt->error != 0) in xmlRegexpCompile()
5285 ctxt->end = ctxt->state; in xmlRegexpCompile()
5286 ctxt->start->type = XML_REGEXP_START_STATE; in xmlRegexpCompile()
5287 ctxt->end->type = XML_REGEXP_FINAL_STATE; in xmlRegexpCompile()
5293 if (ctxt->error != 0) in xmlRegexpCompile()
5314 return(-1); in xmlRegexpExec()
5332 return(-1); in xmlRegexpIsDeterminist()
5333 if (comp->determinist != -1) in xmlRegexpIsDeterminist()
5334 return(comp->determinist); in xmlRegexpIsDeterminist()
5338 return(-1); in xmlRegexpIsDeterminist()
5339 if (am->states != NULL) { in xmlRegexpIsDeterminist()
5342 for (i = 0;i < am->nbStates;i++) in xmlRegexpIsDeterminist()
5343 xmlRegFreeState(am->states[i]); in xmlRegexpIsDeterminist()
5344 xmlFree(am->states); in xmlRegexpIsDeterminist()
5346 am->nbAtoms = comp->nbAtoms; in xmlRegexpIsDeterminist()
5347 am->atoms = comp->atoms; in xmlRegexpIsDeterminist()
5348 am->nbStates = comp->nbStates; in xmlRegexpIsDeterminist()
5349 am->states = comp->states; in xmlRegexpIsDeterminist()
5350 am->determinist = -1; in xmlRegexpIsDeterminist()
5351 am->flags = comp->flags; in xmlRegexpIsDeterminist()
5353 am->atoms = NULL; in xmlRegexpIsDeterminist()
5354 am->states = NULL; in xmlRegexpIsDeterminist()
5356 comp->determinist = ret; in xmlRegexpIsDeterminist()
5372 if (regexp->string != NULL) in xmlRegFreeRegexp()
5373 xmlFree(regexp->string); in xmlRegFreeRegexp()
5374 if (regexp->states != NULL) { in xmlRegFreeRegexp()
5375 for (i = 0;i < regexp->nbStates;i++) in xmlRegFreeRegexp()
5376 xmlRegFreeState(regexp->states[i]); in xmlRegFreeRegexp()
5377 xmlFree(regexp->states); in xmlRegFreeRegexp()
5379 if (regexp->atoms != NULL) { in xmlRegFreeRegexp()
5380 for (i = 0;i < regexp->nbAtoms;i++) in xmlRegFreeRegexp()
5381 xmlRegFreeAtom(regexp->atoms[i]); in xmlRegFreeRegexp()
5382 xmlFree(regexp->atoms); in xmlRegFreeRegexp()
5384 if (regexp->counters != NULL) in xmlRegFreeRegexp()
5385 xmlFree(regexp->counters); in xmlRegFreeRegexp()
5386 if (regexp->compact != NULL) in xmlRegFreeRegexp()
5387 xmlFree(regexp->compact); in xmlRegFreeRegexp()
5388 if (regexp->transdata != NULL) in xmlRegFreeRegexp()
5389 xmlFree(regexp->transdata); in xmlRegFreeRegexp()
5390 if (regexp->stringMap != NULL) { in xmlRegFreeRegexp()
5391 for (i = 0; i < regexp->nbstrings;i++) in xmlRegFreeRegexp()
5392 xmlFree(regexp->stringMap[i]); in xmlRegFreeRegexp()
5393 xmlFree(regexp->stringMap); in xmlRegFreeRegexp()
5421 ctxt->state = xmlRegStatePush(ctxt); in xmlNewAutomata()
5422 if (ctxt->state == NULL) { in xmlNewAutomata()
5426 ctxt->start = ctxt->state; in xmlNewAutomata()
5427 ctxt->end = NULL; in xmlNewAutomata()
5429 ctxt->start->type = XML_REGEXP_START_STATE; in xmlNewAutomata()
5430 ctxt->flags = 0; in xmlNewAutomata()
5459 am->flags |= flags; in xmlAutomataSetFlags()
5474 return(am->start); in xmlAutomataGetInitState()
5484 * Returns 0 or -1 in case of error
5489 return(-1); in xmlAutomataSetFinalState()
5490 state->type = XML_REGEXP_FINAL_STATE; in xmlAutomataSetFinalState()
5519 atom->data = data; in xmlAutomataNewTransition()
5520 atom->valuep = xmlStrdup(token); in xmlAutomataNewTransition()
5521 if (atom->valuep == NULL) { in xmlAutomataNewTransition()
5532 return(am->state); in xmlAutomataNewTransition()
5562 atom->data = data; in xmlAutomataNewTransition2()
5564 atom->valuep = xmlStrdup(token); in xmlAutomataNewTransition2()
5582 atom->valuep = str; in xmlAutomataNewTransition2()
5590 return(am->state); in xmlAutomataNewTransition2()
5623 atom->data = data; in xmlAutomataNewNegTrans()
5624 atom->neg = 1; in xmlAutomataNewNegTrans()
5626 atom->valuep = xmlStrdup(token); in xmlAutomataNewNegTrans()
5644 atom->valuep = str; in xmlAutomataNewNegTrans()
5646 snprintf((char *) err_msg, 199, "not %s", (const char *) atom->valuep); in xmlAutomataNewNegTrans()
5648 atom->valuep2 = xmlStrdup(err_msg); in xmlAutomataNewNegTrans()
5654 am->negs++; in xmlAutomataNewNegTrans()
5656 return(am->state); in xmlAutomataNewNegTrans()
5696 atom->valuep = xmlStrdup(token); in xmlAutomataNewCountTrans2()
5697 if (atom->valuep == NULL) in xmlAutomataNewCountTrans2()
5714 atom->valuep = str; in xmlAutomataNewCountTrans2()
5716 atom->data = data; in xmlAutomataNewCountTrans2()
5718 atom->min = 1; in xmlAutomataNewCountTrans2()
5720 atom->min = min; in xmlAutomataNewCountTrans2()
5721 atom->max = max; in xmlAutomataNewCountTrans2()
5729 am->counters[counter].min = min; in xmlAutomataNewCountTrans2()
5730 am->counters[counter].max = max; in xmlAutomataNewCountTrans2()
5738 xmlRegStateAddTrans(am, from, atom, to, counter, -1); in xmlAutomataNewCountTrans2()
5741 am->state = to; in xmlAutomataNewCountTrans2()
5744 to = am->state; in xmlAutomataNewCountTrans2()
5789 atom->valuep = xmlStrdup(token); in xmlAutomataNewCountTrans()
5790 if (atom->valuep == NULL) in xmlAutomataNewCountTrans()
5792 atom->data = data; in xmlAutomataNewCountTrans()
5794 atom->min = 1; in xmlAutomataNewCountTrans()
5796 atom->min = min; in xmlAutomataNewCountTrans()
5797 atom->max = max; in xmlAutomataNewCountTrans()
5805 am->counters[counter].min = min; in xmlAutomataNewCountTrans()
5806 am->counters[counter].max = max; in xmlAutomataNewCountTrans()
5814 xmlRegStateAddTrans(am, from, atom, to, counter, -1); in xmlAutomataNewCountTrans()
5817 am->state = to; in xmlAutomataNewCountTrans()
5820 to = am->state; in xmlAutomataNewCountTrans()
5869 atom->valuep = xmlStrdup(token); in xmlAutomataNewOnceTrans2()
5870 if (atom->valuep == NULL) in xmlAutomataNewOnceTrans2()
5887 atom->valuep = str; in xmlAutomataNewOnceTrans2()
5889 atom->data = data; in xmlAutomataNewOnceTrans2()
5890 atom->quant = XML_REGEXP_QUANT_ONCEONLY; in xmlAutomataNewOnceTrans2()
5891 atom->min = min; in xmlAutomataNewOnceTrans2()
5892 atom->max = max; in xmlAutomataNewOnceTrans2()
5899 am->counters[counter].min = 1; in xmlAutomataNewOnceTrans2()
5900 am->counters[counter].max = 1; in xmlAutomataNewOnceTrans2()
5908 xmlRegStateAddTrans(am, from, atom, to, counter, -1); in xmlAutomataNewOnceTrans2()
5911 am->state = to; in xmlAutomataNewOnceTrans2()
5955 atom->valuep = xmlStrdup(token); in xmlAutomataNewOnceTrans()
5956 atom->data = data; in xmlAutomataNewOnceTrans()
5957 atom->quant = XML_REGEXP_QUANT_ONCEONLY; in xmlAutomataNewOnceTrans()
5958 atom->min = min; in xmlAutomataNewOnceTrans()
5959 atom->max = max; in xmlAutomataNewOnceTrans()
5966 am->counters[counter].min = 1; in xmlAutomataNewOnceTrans()
5967 am->counters[counter].max = 1; in xmlAutomataNewOnceTrans()
5975 xmlRegStateAddTrans(am, from, atom, to, counter, -1); in xmlAutomataNewOnceTrans()
5978 am->state = to; in xmlAutomataNewOnceTrans()
6020 return(am->state); in xmlAutomataNewEpsilon()
6045 return(am->state); in xmlAutomataNewAllTrans()
6057 * Returns the counter number or -1 in case of error
6064 return(-1); in xmlAutomataNewCounter()
6068 return(-1); in xmlAutomataNewCounter()
6069 am->counters[ret].min = min; in xmlAutomataNewCounter()
6070 am->counters[ret].max = max; in xmlAutomataNewCounter()
6094 return(am->state); in xmlAutomataNewCountedTrans()
6118 return(am->state); in xmlAutomataNewCounterTrans()
6135 if ((am == NULL) || (am->error != 0)) return(NULL); in xmlAutomataCompile()
6137 if (am->error != 0) in xmlAutomataCompile()
6151 * Returns 1 if true, 0 if not, and -1 in case of error
6158 return(-1); in xmlAutomataIsDeterminist()
6318 ret->size = size; in xmlExpNewCtxt()
6319 ret->nbElems = 0; in xmlExpNewCtxt()
6320 ret->maxNodes = maxNodes; in xmlExpNewCtxt()
6321 ret->table = xmlMalloc(size * sizeof(xmlExpNodePtr)); in xmlExpNewCtxt()
6322 if (ret->table == NULL) { in xmlExpNewCtxt()
6326 memset(ret->table, 0, size * sizeof(xmlExpNodePtr)); in xmlExpNewCtxt()
6328 ret->dict = xmlDictCreate(); in xmlExpNewCtxt()
6329 if (ret->dict == NULL) { in xmlExpNewCtxt()
6330 xmlFree(ret->table); in xmlExpNewCtxt()
6335 ret->dict = dict; in xmlExpNewCtxt()
6336 xmlDictReference(ret->dict); in xmlExpNewCtxt()
6351 xmlDictFree(ctxt->dict); in xmlExpFreeCtxt()
6352 if (ctxt->table != NULL) in xmlExpFreeCtxt()
6353 xmlFree(ctxt->table); in xmlExpFreeCtxt()
6366 * - Wildcards
6367 * - public API for creation
6370 * - regression testing
6373 * - split into module and test tool
6374 * - memleaks
6381 #define IS_NILLABLE(node) ((node)->info & XML_EXP_NILABLE)
6422 * of sub-expressions pointers *
6455 value = left->key; in xmlExpHashComputeKey()
6456 value += right->key; in xmlExpHashComputeKey()
6461 value = left->key; in xmlExpHashComputeKey()
6462 value += right->key; in xmlExpHashComputeKey()
6467 value = left->key; in xmlExpHashComputeKey()
6468 value += right->key; in xmlExpHashComputeKey()
6482 if (ctxt->nb_nodes >= MAX_NODES) in xmlExpNewNode()
6488 ret->type = type; in xmlExpNewNode()
6489 ret->next = NULL; in xmlExpNewNode()
6490 ctxt->nb_nodes++; in xmlExpNewNode()
6491 ctxt->nb_cons++; in xmlExpNewNode()
6523 /* a{1} -> a */ in xmlExpHashGetEntry()
6537 if (max == -1) in xmlExpHashGetEntry()
6540 kbase = max - min; in xmlExpHashGetEntry()
6541 kbase += left->key; in xmlExpHashGetEntry()
6544 if (left->type == XML_EXP_FORBID) { in xmlExpHashGetEntry()
6548 if (right->type == XML_EXP_FORBID) { in xmlExpHashGetEntry()
6561 if ((left->type == XML_EXP_OR) && (right->type != XML_EXP_OR)) { in xmlExpHashGetEntry()
6568 if (right->type == XML_EXP_OR) { in xmlExpHashGetEntry()
6569 if ((left == right->exp_left) || in xmlExpHashGetEntry()
6570 (left == right->exp_right)) { in xmlExpHashGetEntry()
6577 if (left->type == XML_EXP_OR) { in xmlExpHashGetEntry()
6581 if ((left->exp_right->type != XML_EXP_OR) && in xmlExpHashGetEntry()
6582 (left->exp_right->key < left->exp_left->key)) { in xmlExpHashGetEntry()
6583 tmp = left->exp_right; in xmlExpHashGetEntry()
6584 left->exp_right = left->exp_left; in xmlExpHashGetEntry()
6585 left->exp_left = tmp; in xmlExpHashGetEntry()
6587 left->exp_right->ref++; in xmlExpHashGetEntry()
6588 tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, left->exp_right, right, in xmlExpHashGetEntry()
6590 left->exp_left->ref++; in xmlExpHashGetEntry()
6591 tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, left->exp_left, tmp, in xmlExpHashGetEntry()
6597 if (right->type == XML_EXP_OR) { in xmlExpHashGetEntry()
6599 /* C | (A | B) -> A | (B | C) */ in xmlExpHashGetEntry()
6600 if (left->key > right->exp_right->key) { in xmlExpHashGetEntry()
6602 right->exp_right->ref++; in xmlExpHashGetEntry()
6603 tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, right->exp_right, in xmlExpHashGetEntry()
6605 right->exp_left->ref++; in xmlExpHashGetEntry()
6606 tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, right->exp_left, in xmlExpHashGetEntry()
6612 /* B | (A | C) -> A | (B | C) */ in xmlExpHashGetEntry()
6613 if (left->key > right->exp_left->key) { in xmlExpHashGetEntry()
6615 right->exp_right->ref++; in xmlExpHashGetEntry()
6617 right->exp_right, NULL, 0, 0); in xmlExpHashGetEntry()
6618 right->exp_left->ref++; in xmlExpHashGetEntry()
6619 tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, right->exp_left, in xmlExpHashGetEntry()
6626 else if (left->key > right->key) { in xmlExpHashGetEntry()
6634 if (left->type == XML_EXP_FORBID) { in xmlExpHashGetEntry()
6638 if (right->type == XML_EXP_FORBID) { in xmlExpHashGetEntry()
6643 if (right->type == XML_EXP_EMPTY) { in xmlExpHashGetEntry()
6646 if (left->type == XML_EXP_EMPTY) { in xmlExpHashGetEntry()
6653 key = kbase % ctxt->size; in xmlExpHashGetEntry()
6654 if (ctxt->table[key] != NULL) { in xmlExpHashGetEntry()
6655 for (insert = ctxt->table[key]; insert != NULL; in xmlExpHashGetEntry()
6656 insert = insert->next) { in xmlExpHashGetEntry()
6657 if ((insert->key == kbase) && in xmlExpHashGetEntry()
6658 (insert->type == type)) { in xmlExpHashGetEntry()
6660 if (name == insert->exp_str) { in xmlExpHashGetEntry()
6661 insert->ref++; in xmlExpHashGetEntry()
6665 if ((insert->exp_min == min) && (insert->exp_max == max) && in xmlExpHashGetEntry()
6666 (insert->exp_left == left)) { in xmlExpHashGetEntry()
6667 insert->ref++; in xmlExpHashGetEntry()
6668 left->ref--; in xmlExpHashGetEntry()
6671 } else if ((insert->exp_left == left) && in xmlExpHashGetEntry()
6672 (insert->exp_right == right)) { in xmlExpHashGetEntry()
6673 insert->ref++; in xmlExpHashGetEntry()
6674 left->ref--; in xmlExpHashGetEntry()
6675 right->ref--; in xmlExpHashGetEntry()
6685 entry->key = kbase; in xmlExpHashGetEntry()
6687 entry->exp_str = name; in xmlExpHashGetEntry()
6688 entry->c_max = 1; in xmlExpHashGetEntry()
6690 entry->exp_min = min; in xmlExpHashGetEntry()
6691 entry->exp_max = max; in xmlExpHashGetEntry()
6692 entry->exp_left = left; in xmlExpHashGetEntry()
6694 entry->info |= XML_EXP_NILABLE; in xmlExpHashGetEntry()
6696 entry->c_max = -1; in xmlExpHashGetEntry()
6698 entry->c_max = max * entry->exp_left->c_max; in xmlExpHashGetEntry()
6700 entry->exp_left = left; in xmlExpHashGetEntry()
6701 entry->exp_right = right; in xmlExpHashGetEntry()
6704 entry->info |= XML_EXP_NILABLE; in xmlExpHashGetEntry()
6705 if ((entry->exp_left->c_max == -1) || in xmlExpHashGetEntry()
6706 (entry->exp_right->c_max == -1)) in xmlExpHashGetEntry()
6707 entry->c_max = -1; in xmlExpHashGetEntry()
6708 else if (entry->exp_left->c_max > entry->exp_right->c_max) in xmlExpHashGetEntry()
6709 entry->c_max = entry->exp_left->c_max; in xmlExpHashGetEntry()
6711 entry->c_max = entry->exp_right->c_max; in xmlExpHashGetEntry()
6714 entry->info |= XML_EXP_NILABLE; in xmlExpHashGetEntry()
6715 if ((entry->exp_left->c_max == -1) || in xmlExpHashGetEntry()
6716 (entry->exp_right->c_max == -1)) in xmlExpHashGetEntry()
6717 entry->c_max = -1; in xmlExpHashGetEntry()
6719 entry->c_max = entry->exp_left->c_max + entry->exp_right->c_max; in xmlExpHashGetEntry()
6722 entry->ref = 1; in xmlExpHashGetEntry()
6723 if (ctxt->table[key] != NULL) in xmlExpHashGetEntry()
6724 entry->next = ctxt->table[key]; in xmlExpHashGetEntry()
6726 ctxt->table[key] = entry; in xmlExpHashGetEntry()
6727 ctxt->nbElems++; in xmlExpHashGetEntry()
6743 exp->ref--; in xmlExpFree()
6744 if (exp->ref == 0) { in xmlExpFree()
6748 key = exp->key % ctxt->size; in xmlExpFree()
6749 if (ctxt->table[key] == exp) { in xmlExpFree()
6750 ctxt->table[key] = exp->next; in xmlExpFree()
6754 tmp = ctxt->table[key]; in xmlExpFree()
6756 if (tmp->next == exp) { in xmlExpFree()
6757 tmp->next = exp->next; in xmlExpFree()
6760 tmp = tmp->next; in xmlExpFree()
6764 if ((exp->type == XML_EXP_SEQ) || (exp->type == XML_EXP_OR)) { in xmlExpFree()
6765 xmlExpFree(ctxt, exp->exp_left); in xmlExpFree()
6766 xmlExpFree(ctxt, exp->exp_right); in xmlExpFree()
6767 } else if (exp->type == XML_EXP_COUNT) { in xmlExpFree()
6768 xmlExpFree(ctxt, exp->exp_left); in xmlExpFree()
6771 ctxt->nb_nodes--; in xmlExpFree()
6784 exp->ref++; in xmlExpRef()
6791 * @len: the atom name length in byte (or -1);
6801 name = xmlDictLookup(ctxt->dict, name, len); in xmlExpNewAtom()
6862 * @max: the upper bound for the repetition, -1 means infinite
6875 if ((subset == NULL) || (min < 0) || (max < -1) || in xmlExpNewRange()
6895 switch (exp->type) { in xmlExpGetLanguageInt()
6900 if (list[tmp] == exp->exp_str) in xmlExpGetLanguageInt()
6903 return(-2); in xmlExpGetLanguageInt()
6904 list[nb] = exp->exp_str; in xmlExpGetLanguageInt()
6907 exp = exp->exp_left; in xmlExpGetLanguageInt()
6911 tmp = xmlExpGetLanguageInt(ctxt, exp->exp_left, list, len, nb); in xmlExpGetLanguageInt()
6914 tmp2 = xmlExpGetLanguageInt(ctxt, exp->exp_right, list, len, in xmlExpGetLanguageInt()
6920 return(-1); in xmlExpGetLanguageInt()
6932 * Returns the number of unique strings found, -1 in case of errors and
6933 * -2 if there is more than @len strings
6939 return(-1); in xmlExpGetLanguage()
6948 switch (exp->type) { in xmlExpGetStartInt()
6955 if (list[tmp] == exp->exp_str) in xmlExpGetStartInt()
6958 return(-2); in xmlExpGetStartInt()
6959 list[nb] = exp->exp_str; in xmlExpGetStartInt()
6962 exp = exp->exp_left; in xmlExpGetStartInt()
6965 tmp = xmlExpGetStartInt(ctxt, exp->exp_left, list, len, nb); in xmlExpGetStartInt()
6968 if (IS_NILLABLE(exp->exp_left)) { in xmlExpGetStartInt()
6969 tmp2 = xmlExpGetStartInt(ctxt, exp->exp_right, list, len, in xmlExpGetStartInt()
6977 tmp = xmlExpGetStartInt(ctxt, exp->exp_left, list, len, nb); in xmlExpGetStartInt()
6980 tmp2 = xmlExpGetStartInt(ctxt, exp->exp_right, list, len, in xmlExpGetStartInt()
6986 return(-1); in xmlExpGetStartInt()
7000 * Returns the number of unique strings found, -1 in case of errors and
7001 * -2 if there is more than @len strings
7007 return(-1); in xmlExpGetStart()
7017 * Returns 1 if nillable, 0 if not and -1 in case of error
7022 return(-1); in xmlExpIsNillable()
7031 switch (exp->type) { in xmlExpStringDeriveInt()
7037 if (exp->exp_str == str) { in xmlExpStringDeriveInt()
7047 tmp = xmlExpStringDeriveInt(ctxt, exp->exp_left, str); in xmlExpStringDeriveInt()
7051 ret = xmlExpStringDeriveInt(ctxt, exp->exp_right, str); in xmlExpStringDeriveInt()
7061 ret = xmlExpStringDeriveInt(ctxt, exp->exp_left, str); in xmlExpStringDeriveInt()
7065 if (IS_NILLABLE(exp->exp_left)) { in xmlExpStringDeriveInt()
7066 ret = xmlExpStringDeriveInt(ctxt, exp->exp_right, str); in xmlExpStringDeriveInt()
7069 exp->exp_right->ref++; in xmlExpStringDeriveInt()
7070 ret = xmlExpHashGetEntry(ctxt, XML_EXP_SEQ, ret, exp->exp_right, in xmlExpStringDeriveInt()
7078 if (exp->exp_max == 0) in xmlExpStringDeriveInt()
7080 ret = xmlExpStringDeriveInt(ctxt, exp->exp_left, str); in xmlExpStringDeriveInt()
7086 if (exp->exp_max == 1) in xmlExpStringDeriveInt()
7088 if (exp->exp_max < 0) /* unbounded */ in xmlExpStringDeriveInt()
7089 max = -1; in xmlExpStringDeriveInt()
7091 max = exp->exp_max - 1; in xmlExpStringDeriveInt()
7092 if (exp->exp_min > 0) in xmlExpStringDeriveInt()
7093 min = exp->exp_min - 1; in xmlExpStringDeriveInt()
7096 exp->exp_left->ref++; in xmlExpStringDeriveInt()
7097 tmp = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left, NULL, in xmlExpStringDeriveInt()
7133 input = xmlDictExists(ctxt->dict, str, len); in xmlExpStringDerive()
7144 if (sub->c_max == -1) { in xmlExpCheckCard()
7145 if (exp->c_max != -1) in xmlExpCheckCard()
7147 } else if ((exp->c_max >= 0) && (exp->c_max < sub->c_max)) { in xmlExpCheckCard()
7167 * and -1 in case of internal error.
7178 if (exp->c_max == -1) return(0); in xmlExpDivide()
7181 for (i = 1;i <= exp->c_max;i++) { in xmlExpDivide()
7182 sub->ref++; in xmlExpDivide()
7186 return(-1); in xmlExpDivide()
7195 return(-1); in xmlExpDivide()
7235 if ((exp == sub) && (exp->c_max >= 0)) { in xmlExpExpDeriveInt()
7241 if (sub->type == XML_EXP_EMPTY) { in xmlExpExpDeriveInt()
7242 exp->ref++; in xmlExpExpDeriveInt()
7245 if (sub->type == XML_EXP_SEQ) { in xmlExpExpDeriveInt()
7246 tmp = xmlExpExpDeriveInt(ctxt, exp, sub->exp_left); in xmlExpExpDeriveInt()
7251 ret = xmlExpExpDeriveInt(ctxt, tmp, sub->exp_right); in xmlExpExpDeriveInt()
7255 if (sub->type == XML_EXP_OR) { in xmlExpExpDeriveInt()
7256 tmp = xmlExpExpDeriveInt(ctxt, exp, sub->exp_left); in xmlExpExpDeriveInt()
7261 ret = xmlExpExpDeriveInt(ctxt, exp, sub->exp_right); in xmlExpExpDeriveInt()
7271 switch (exp->type) { in xmlExpExpDeriveInt()
7279 if (sub->type == XML_EXP_ATOM) { in xmlExpExpDeriveInt()
7281 if (exp->exp_str == sub->exp_str) { in xmlExpExpDeriveInt()
7286 if ((sub->type == XML_EXP_COUNT) && in xmlExpExpDeriveInt()
7287 (sub->exp_max == 1) && in xmlExpExpDeriveInt()
7288 (sub->exp_left->type == XML_EXP_ATOM)) { in xmlExpExpDeriveInt()
7290 if (exp->exp_str == sub->exp_left->exp_str) { in xmlExpExpDeriveInt()
7298 if (xmlExpCheckCard(exp->exp_left, sub)) { in xmlExpExpDeriveInt()
7300 ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub); in xmlExpExpDeriveInt()
7309 exp->exp_right->ref++; in xmlExpExpDeriveInt()
7311 exp->exp_right, NULL, 0, 0)); in xmlExpExpDeriveInt()
7315 if (sub->type == XML_EXP_COUNT) { in xmlExpExpDeriveInt()
7318 ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub->exp_left); in xmlExpExpDeriveInt()
7322 if (sub->exp_max < 0) in xmlExpExpDeriveInt()
7323 max = -1; in xmlExpExpDeriveInt()
7325 max = sub->exp_max -1; in xmlExpExpDeriveInt()
7326 if (sub->exp_min > 0) in xmlExpExpDeriveInt()
7327 min = sub->exp_min -1; in xmlExpExpDeriveInt()
7330 exp->exp_right->ref++; in xmlExpExpDeriveInt()
7332 exp->exp_right, NULL, 0, 0); in xmlExpExpDeriveInt()
7336 sub->exp_left->ref++; in xmlExpExpDeriveInt()
7338 sub->exp_left, NULL, NULL, min, max); in xmlExpExpDeriveInt()
7352 ret = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub); in xmlExpExpDeriveInt()
7355 tmp = xmlExpExpDeriveInt(ctxt, exp->exp_right, sub); in xmlExpExpDeriveInt()
7364 if (sub->type == XML_EXP_COUNT) { in xmlExpExpDeriveInt()
7368 tmp = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub->exp_left); in xmlExpExpDeriveInt()
7374 mult = xmlExpDivide(ctxt, sub->exp_left, exp->exp_left, in xmlExpExpDeriveInt()
7379 if (sub->exp_max == -1) { in xmlExpExpDeriveInt()
7380 max = -1; in xmlExpExpDeriveInt()
7381 if (exp->exp_max == -1) { in xmlExpExpDeriveInt()
7382 if (exp->exp_min <= sub->exp_min * mult) in xmlExpExpDeriveInt()
7385 min = exp->exp_min - sub->exp_min * mult; in xmlExpExpDeriveInt()
7391 if (exp->exp_max == -1) { in xmlExpExpDeriveInt()
7392 if (exp->exp_min > sub->exp_min * mult) { in xmlExpExpDeriveInt()
7393 max = -1; in xmlExpExpDeriveInt()
7394 min = exp->exp_min - sub->exp_min * mult; in xmlExpExpDeriveInt()
7396 max = -1; in xmlExpExpDeriveInt()
7400 if (exp->exp_max < sub->exp_max * mult) { in xmlExpExpDeriveInt()
7404 if (sub->exp_max * mult > exp->exp_min) in xmlExpExpDeriveInt()
7407 min = exp->exp_min - sub->exp_max * mult; in xmlExpExpDeriveInt()
7408 max = exp->exp_max - sub->exp_max * mult; in xmlExpExpDeriveInt()
7418 } else if (sub->exp_max == -1) { in xmlExpExpDeriveInt()
7419 if (exp->exp_max == -1) { in xmlExpExpDeriveInt()
7420 if (exp->exp_min <= sub->exp_min) { in xmlExpExpDeriveInt()
7421 max = -1; in xmlExpExpDeriveInt()
7424 max = -1; in xmlExpExpDeriveInt()
7425 min = exp->exp_min - sub->exp_min; in xmlExpExpDeriveInt()
7427 } else if (exp->exp_min > sub->exp_min) { in xmlExpExpDeriveInt()
7431 max = -1; in xmlExpExpDeriveInt()
7435 if (exp->exp_max == -1) { in xmlExpExpDeriveInt()
7436 if (exp->exp_min > sub->exp_min) { in xmlExpExpDeriveInt()
7437 max = -1; in xmlExpExpDeriveInt()
7438 min = exp->exp_min - sub->exp_min; in xmlExpExpDeriveInt()
7440 max = -1; in xmlExpExpDeriveInt()
7444 if (exp->exp_max < sub->exp_max) { in xmlExpExpDeriveInt()
7448 if (sub->exp_max > exp->exp_min) in xmlExpExpDeriveInt()
7451 min = exp->exp_min - sub->exp_max; in xmlExpExpDeriveInt()
7452 max = exp->exp_max - sub->exp_max; in xmlExpExpDeriveInt()
7455 exp->exp_left->ref++; in xmlExpExpDeriveInt()
7456 tmp2 = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left, in xmlExpExpDeriveInt()
7465 tmp = xmlExpExpDeriveInt(ctxt, exp->exp_left, sub); in xmlExpExpDeriveInt()
7471 if (exp->exp_min > 0) in xmlExpExpDeriveInt()
7472 min = exp->exp_min - 1; in xmlExpExpDeriveInt()
7475 if (exp->exp_max < 0) in xmlExpExpDeriveInt()
7476 max = -1; in xmlExpExpDeriveInt()
7478 max = exp->exp_max - 1; in xmlExpExpDeriveInt()
7480 exp->exp_left->ref++; in xmlExpExpDeriveInt()
7481 tmp2 = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, exp->exp_left, in xmlExpExpDeriveInt()
7502 if (ctxt->tabSize == 0) in xmlExpExpDeriveInt()
7503 ctxt->tabSize = 40; in xmlExpExpDeriveInt()
7505 tab = (const xmlChar **) xmlMalloc(ctxt->tabSize * in xmlExpExpDeriveInt()
7514 len = xmlExpGetStartInt(ctxt, sub, tab, ctxt->tabSize, 0); in xmlExpExpDeriveInt()
7517 temp = (const xmlChar **) xmlRealloc((xmlChar **) tab, ctxt->tabSize * 2 * in xmlExpExpDeriveInt()
7524 ctxt->tabSize *= 2; in xmlExpExpDeriveInt()
7525 len = xmlExpGetStartInt(ctxt, sub, tab, ctxt->tabSize, 0); in xmlExpExpDeriveInt()
7605 * Returns 1 if true 0 if false and -1 in case of failure.
7612 return(-1); in xmlExpSubsume()
7629 return(-1); in xmlExpSubsume()
7651 #define CUR (*ctxt->cur)
7653 #define NEXT ctxt->cur++;
7656 #define SKIP_BLANKS while (IS_BLANK(*ctxt->cur)) ctxt->cur++;
7665 return(-1); in xmlExpParseNumber()
7668 return(-1); in xmlExpParseNumber()
7670 ret = ret * 10 + (CUR - '0'); in xmlExpParseNumber()
7683 base = ctxt->cur; in xmlExpParseOr()
7684 if (*ctxt->cur == '(') { in xmlExpParseOr()
7688 if (*ctxt->cur != ')') { in xmlExpParseOr()
7700 val = xmlDictLookup(ctxt->dict, BAD_CAST base, ctxt->cur - base); in xmlExpParseOr()
7740 1, -1); in xmlExpParseOr()
7745 0, -1); in xmlExpParseOr()
7798 * - string terminals
7799 * - choice operator |
7800 * - sequence operator ,
7801 * - subexpressions (...)
7802 * - usual cardinality operators + * and ?
7803 * - finite sequences { min, max }
7804 * - infinite sequences { min, * }
7813 ctxt->expr = expr; in xmlExpParse()
7814 ctxt->cur = expr; in xmlExpParse()
7818 if (*ctxt->cur != 0) { in xmlExpParse()
7831 switch (expr->type) { in xmlExpDumpInt()
7839 xmlBufferWriteCHAR(buf, expr->exp_str); in xmlExpDumpInt()
7842 c = expr->exp_left; in xmlExpDumpInt()
7843 if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR)) in xmlExpDumpInt()
7848 c = expr->exp_right; in xmlExpDumpInt()
7849 if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR)) in xmlExpDumpInt()
7855 c = expr->exp_left; in xmlExpDumpInt()
7856 if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR)) in xmlExpDumpInt()
7861 c = expr->exp_right; in xmlExpDumpInt()
7862 if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR)) in xmlExpDumpInt()
7870 c = expr->exp_left; in xmlExpDumpInt()
7871 if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR)) in xmlExpDumpInt()
7875 if ((expr->exp_min == 0) && (expr->exp_max == 1)) { in xmlExpDumpInt()
7878 } else if ((expr->exp_min == 0) && (expr->exp_max == -1)) { in xmlExpDumpInt()
7881 } else if ((expr->exp_min == 1) && (expr->exp_max == -1)) { in xmlExpDumpInt()
7884 } else if (expr->exp_max == expr->exp_min) { in xmlExpDumpInt()
7885 snprintf(rep, 39, "{%d}", expr->exp_min); in xmlExpDumpInt()
7886 } else if (expr->exp_max < 0) { in xmlExpDumpInt()
7887 snprintf(rep, 39, "{%d,inf}", expr->exp_min); in xmlExpDumpInt()
7889 snprintf(rep, 39, "{%d,%d}", expr->exp_min, expr->exp_max); in xmlExpDumpInt()
7921 * Returns the maximum length or -1 in case of error
7926 return(-1); in xmlExpMaxToken()
7927 return(expr->c_max); in xmlExpMaxToken()
7936 * Returns the number of nodes in use or -1 in case of error
7941 return(-1); in xmlExpCtxtNbNodes()
7942 return(ctxt->nb_nodes); in xmlExpCtxtNbNodes()
7951 * Returns the number of nodes ever allocated or -1 in case of error
7956 return(-1); in xmlExpCtxtNbCons()
7957 return(ctxt->nb_cons); in xmlExpCtxtNbCons()