(libxml2) LIBXML_AUTOMATA_ENABLED removed

This commit is contained in:
twinaphex 2012-11-17 23:56:00 +01:00
parent d73602e687
commit 2aeaf25e1f
5 changed files with 0 additions and 1103 deletions

View File

@ -286,210 +286,6 @@ extern __typeof (xmlAllocParserInputBuffer) xmlAllocParserInputBuffer__internal_
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataCompile
extern __typeof (xmlAutomataCompile) xmlAutomataCompile __attribute((alias("xmlAutomataCompile__internal_alias")));
#else
#ifndef xmlAutomataCompile
extern __typeof (xmlAutomataCompile) xmlAutomataCompile__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataCompile xmlAutomataCompile__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataGetInitState
extern __typeof (xmlAutomataGetInitState) xmlAutomataGetInitState __attribute((alias("xmlAutomataGetInitState__internal_alias")));
#else
#ifndef xmlAutomataGetInitState
extern __typeof (xmlAutomataGetInitState) xmlAutomataGetInitState__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataGetInitState xmlAutomataGetInitState__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataIsDeterminist
extern __typeof (xmlAutomataIsDeterminist) xmlAutomataIsDeterminist __attribute((alias("xmlAutomataIsDeterminist__internal_alias")));
#else
#ifndef xmlAutomataIsDeterminist
extern __typeof (xmlAutomataIsDeterminist) xmlAutomataIsDeterminist__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataIsDeterminist xmlAutomataIsDeterminist__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewAllTrans
extern __typeof (xmlAutomataNewAllTrans) xmlAutomataNewAllTrans __attribute((alias("xmlAutomataNewAllTrans__internal_alias")));
#else
#ifndef xmlAutomataNewAllTrans
extern __typeof (xmlAutomataNewAllTrans) xmlAutomataNewAllTrans__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewAllTrans xmlAutomataNewAllTrans__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewCountTrans
extern __typeof (xmlAutomataNewCountTrans) xmlAutomataNewCountTrans __attribute((alias("xmlAutomataNewCountTrans__internal_alias")));
#else
#ifndef xmlAutomataNewCountTrans
extern __typeof (xmlAutomataNewCountTrans) xmlAutomataNewCountTrans__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewCountTrans xmlAutomataNewCountTrans__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewCountTrans2
extern __typeof (xmlAutomataNewCountTrans2) xmlAutomataNewCountTrans2 __attribute((alias("xmlAutomataNewCountTrans2__internal_alias")));
#else
#ifndef xmlAutomataNewCountTrans2
extern __typeof (xmlAutomataNewCountTrans2) xmlAutomataNewCountTrans2__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewCountTrans2 xmlAutomataNewCountTrans2__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewCountedTrans
extern __typeof (xmlAutomataNewCountedTrans) xmlAutomataNewCountedTrans __attribute((alias("xmlAutomataNewCountedTrans__internal_alias")));
#else
#ifndef xmlAutomataNewCountedTrans
extern __typeof (xmlAutomataNewCountedTrans) xmlAutomataNewCountedTrans__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewCountedTrans xmlAutomataNewCountedTrans__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewCounter
extern __typeof (xmlAutomataNewCounter) xmlAutomataNewCounter __attribute((alias("xmlAutomataNewCounter__internal_alias")));
#else
#ifndef xmlAutomataNewCounter
extern __typeof (xmlAutomataNewCounter) xmlAutomataNewCounter__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewCounter xmlAutomataNewCounter__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewCounterTrans
extern __typeof (xmlAutomataNewCounterTrans) xmlAutomataNewCounterTrans __attribute((alias("xmlAutomataNewCounterTrans__internal_alias")));
#else
#ifndef xmlAutomataNewCounterTrans
extern __typeof (xmlAutomataNewCounterTrans) xmlAutomataNewCounterTrans__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewCounterTrans xmlAutomataNewCounterTrans__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewEpsilon
extern __typeof (xmlAutomataNewEpsilon) xmlAutomataNewEpsilon __attribute((alias("xmlAutomataNewEpsilon__internal_alias")));
#else
#ifndef xmlAutomataNewEpsilon
extern __typeof (xmlAutomataNewEpsilon) xmlAutomataNewEpsilon__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewEpsilon xmlAutomataNewEpsilon__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewNegTrans
extern __typeof (xmlAutomataNewNegTrans) xmlAutomataNewNegTrans __attribute((alias("xmlAutomataNewNegTrans__internal_alias")));
#else
#ifndef xmlAutomataNewNegTrans
extern __typeof (xmlAutomataNewNegTrans) xmlAutomataNewNegTrans__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewNegTrans xmlAutomataNewNegTrans__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewOnceTrans
extern __typeof (xmlAutomataNewOnceTrans) xmlAutomataNewOnceTrans __attribute((alias("xmlAutomataNewOnceTrans__internal_alias")));
#else
#ifndef xmlAutomataNewOnceTrans
extern __typeof (xmlAutomataNewOnceTrans) xmlAutomataNewOnceTrans__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewOnceTrans xmlAutomataNewOnceTrans__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewOnceTrans2
extern __typeof (xmlAutomataNewOnceTrans2) xmlAutomataNewOnceTrans2 __attribute((alias("xmlAutomataNewOnceTrans2__internal_alias")));
#else
#ifndef xmlAutomataNewOnceTrans2
extern __typeof (xmlAutomataNewOnceTrans2) xmlAutomataNewOnceTrans2__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewOnceTrans2 xmlAutomataNewOnceTrans2__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewState
extern __typeof (xmlAutomataNewState) xmlAutomataNewState __attribute((alias("xmlAutomataNewState__internal_alias")));
#else
#ifndef xmlAutomataNewState
extern __typeof (xmlAutomataNewState) xmlAutomataNewState__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewState xmlAutomataNewState__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewTransition
extern __typeof (xmlAutomataNewTransition) xmlAutomataNewTransition __attribute((alias("xmlAutomataNewTransition__internal_alias")));
#else
#ifndef xmlAutomataNewTransition
extern __typeof (xmlAutomataNewTransition) xmlAutomataNewTransition__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewTransition xmlAutomataNewTransition__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataNewTransition2
extern __typeof (xmlAutomataNewTransition2) xmlAutomataNewTransition2 __attribute((alias("xmlAutomataNewTransition2__internal_alias")));
#else
#ifndef xmlAutomataNewTransition2
extern __typeof (xmlAutomataNewTransition2) xmlAutomataNewTransition2__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataNewTransition2 xmlAutomataNewTransition2__internal_alias
#endif
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlAutomataSetFinalState
extern __typeof (xmlAutomataSetFinalState) xmlAutomataSetFinalState __attribute((alias("xmlAutomataSetFinalState__internal_alias")));
#else
#ifndef xmlAutomataSetFinalState
extern __typeof (xmlAutomataSetFinalState) xmlAutomataSetFinalState__internal_alias __attribute((visibility("hidden")));
#define xmlAutomataSetFinalState xmlAutomataSetFinalState__internal_alias
#endif
#endif
#endif
#ifdef bottom_tree
#undef xmlBufferAdd
extern __typeof (xmlBufferAdd) xmlBufferAdd __attribute((alias("xmlBufferAdd__internal_alias")));
@ -1943,18 +1739,6 @@ extern __typeof (xmlFreeAttributeTable) xmlFreeAttributeTable__internal_alias __
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlFreeAutomata
extern __typeof (xmlFreeAutomata) xmlFreeAutomata __attribute((alias("xmlFreeAutomata__internal_alias")));
#else
#ifndef xmlFreeAutomata
extern __typeof (xmlFreeAutomata) xmlFreeAutomata__internal_alias __attribute((visibility("hidden")));
#define xmlFreeAutomata xmlFreeAutomata__internal_alias
#endif
#endif
#endif
#ifdef bottom_tree
#undef xmlFreeDoc
extern __typeof (xmlFreeDoc) xmlFreeDoc __attribute((alias("xmlFreeDoc__internal_alias")));
@ -3518,18 +3302,6 @@ extern __typeof (xmlMutexUnlock) xmlMutexUnlock__internal_alias __attribute((vis
#endif
#endif
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
#ifdef bottom_xmlregexp
#undef xmlNewAutomata
extern __typeof (xmlNewAutomata) xmlNewAutomata __attribute((alias("xmlNewAutomata__internal_alias")));
#else
#ifndef xmlNewAutomata
extern __typeof (xmlNewAutomata) xmlNewAutomata__internal_alias __attribute((visibility("hidden")));
#define xmlNewAutomata xmlNewAutomata__internal_alias
#endif
#endif
#endif
#ifdef bottom_tree
#undef xmlNewCDataBlock
extern __typeof (xmlNewCDataBlock) xmlNewCDataBlock __attribute((alias("xmlNewCDataBlock__internal_alias")));

View File

@ -14,133 +14,6 @@
#include <libxml/tree.h>
#ifdef LIBXML_REGEXP_ENABLED
#ifdef LIBXML_AUTOMATA_ENABLED
#include <libxml/xmlregexp.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* xmlAutomataPtr:
*
* A libxml automata description, It can be compiled into a regexp
*/
typedef struct _xmlAutomata xmlAutomata;
typedef xmlAutomata *xmlAutomataPtr;
/**
* xmlAutomataStatePtr:
*
* A state int the automata description,
*/
typedef struct _xmlAutomataState xmlAutomataState;
typedef xmlAutomataState *xmlAutomataStatePtr;
/*
* Building API
*/
XMLPUBFUN xmlAutomataPtr XMLCALL
xmlNewAutomata (void);
XMLPUBFUN void XMLCALL
xmlFreeAutomata (xmlAutomataPtr am);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataGetInitState (xmlAutomataPtr am);
XMLPUBFUN int XMLCALL
xmlAutomataSetFinalState (xmlAutomataPtr am,
xmlAutomataStatePtr state);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewState (xmlAutomataPtr am);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewTransition (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
const xmlChar *token,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewTransition2 (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
const xmlChar *token,
const xmlChar *token2,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewNegTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
const xmlChar *token,
const xmlChar *token2,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewCountTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
const xmlChar *token,
int min,
int max,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewCountTrans2 (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
const xmlChar *token,
const xmlChar *token2,
int min,
int max,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewOnceTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
const xmlChar *token,
int min,
int max,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewOnceTrans2 (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
const xmlChar *token,
const xmlChar *token2,
int min,
int max,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewAllTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
int lax);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewEpsilon (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewCountedTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
int counter);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewCounterTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
int counter);
XMLPUBFUN int XMLCALL
xmlAutomataNewCounter (xmlAutomataPtr am,
int min,
int max);
XMLPUBFUN xmlRegexpPtr XMLCALL
xmlAutomataCompile (xmlAutomataPtr am);
XMLPUBFUN int XMLCALL
xmlAutomataIsDeterminist (xmlAutomataPtr am);
#ifdef __cplusplus
}
#endif
#endif /* LIBXML_AUTOMATA_ENABLED */
#endif /* LIBXML_REGEXP_ENABLED */
#endif /* __XML_AUTOMATA_H__ */

View File

@ -175,15 +175,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#define LIBXML_REGEXP_ENABLED
#endif
/**
* LIBXML_AUTOMATA_ENABLED:
*
* Whether the automata interfaces are compiled in
*/
#if 1
#define LIBXML_AUTOMATA_ENABLED
#endif
/**
* LIBXML_EXPR_ENABLED:
*

View File

@ -837,11 +837,7 @@ xmlHasFeature(xmlFeature feature)
return(0);
#endif
case XML_WITH_AUTOMATA:
#ifdef LIBXML_AUTOMATA_ENABLED
return(1);
#else
return(0);
#endif
case XML_WITH_EXPR:
#ifdef LIBXML_EXPR_ENABLED
return(1);

View File

@ -5568,741 +5568,6 @@ xmlRegFreeRegexp(xmlRegexpPtr regexp) {
xmlFree(regexp);
}
#ifdef LIBXML_AUTOMATA_ENABLED
/************************************************************************
* *
* The Automata interface *
* *
************************************************************************/
/**
* xmlNewAutomata:
*
* Create a new automata
*
* Returns the new object or NULL in case of failure
*/
xmlAutomataPtr
xmlNewAutomata(void) {
xmlAutomataPtr ctxt;
ctxt = xmlRegNewParserCtxt(NULL);
if (ctxt == NULL)
return(NULL);
/* initialize the parser */
ctxt->end = NULL;
ctxt->start = ctxt->state = xmlRegNewState(ctxt);
if (ctxt->start == NULL) {
xmlFreeAutomata(ctxt);
return(NULL);
}
ctxt->start->type = XML_REGEXP_START_STATE;
if (xmlRegStatePush(ctxt, ctxt->start) < 0) {
xmlRegFreeState(ctxt->start);
xmlFreeAutomata(ctxt);
return(NULL);
}
ctxt->flags = 0;
return(ctxt);
}
/**
* xmlFreeAutomata:
* @am: an automata
*
* Free an automata
*/
void
xmlFreeAutomata(xmlAutomataPtr am) {
if (am == NULL)
return;
xmlRegFreeParserCtxt(am);
}
/**
* xmlAutomataSetFlags:
* @am: an automata
* @flags: a set of internal flags
*
* Set some flags on the automata
*/
void
xmlAutomataSetFlags(xmlAutomataPtr am, int flags) {
if (am == NULL)
return;
am->flags |= flags;
}
/**
* xmlAutomataGetInitState:
* @am: an automata
*
* Initial state lookup
*
* Returns the initial state of the automata
*/
xmlAutomataStatePtr
xmlAutomataGetInitState(xmlAutomataPtr am) {
if (am == NULL)
return(NULL);
return(am->start);
}
/**
* xmlAutomataSetFinalState:
* @am: an automata
* @state: a state in this automata
*
* Makes that state a final state
*
* Returns 0 or -1 in case of error
*/
int
xmlAutomataSetFinalState(xmlAutomataPtr am, xmlAutomataStatePtr state) {
if ((am == NULL) || (state == NULL))
return(-1);
state->type = XML_REGEXP_FINAL_STATE;
return(0);
}
/**
* xmlAutomataNewTransition:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @token: the input string associated to that transition
* @data: data passed to the callback function if the transition is activated
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
* activated by the value of @token
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewTransition(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, const xmlChar *token,
void *data) {
xmlRegAtomPtr atom;
if ((am == NULL) || (from == NULL) || (token == NULL))
return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL)
return(NULL);
atom->data = data;
if (atom == NULL)
return(NULL);
atom->valuep = xmlStrdup(token);
if (xmlFAGenerateTransitions(am, from, to, atom) < 0) {
xmlRegFreeAtom(atom);
return(NULL);
}
if (to == NULL)
return(am->state);
return(to);
}
/**
* xmlAutomataNewTransition2:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @token: the first input string associated to that transition
* @token2: the second input string associated to that transition
* @data: data passed to the callback function if the transition is activated
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
* activated by the value of @token
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewTransition2(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, const xmlChar *token,
const xmlChar *token2, void *data) {
xmlRegAtomPtr atom;
if ((am == NULL) || (from == NULL) || (token == NULL))
return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL)
return(NULL);
atom->data = data;
if ((token2 == NULL) || (*token2 == 0)) {
atom->valuep = xmlStrdup(token);
} else {
int lenn, lenp;
xmlChar *str;
lenn = strlen((char *) token2);
lenp = strlen((char *) token);
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
if (str == NULL) {
xmlRegFreeAtom(atom);
return(NULL);
}
memcpy(&str[0], token, lenp);
str[lenp] = '|';
memcpy(&str[lenp + 1], token2, lenn);
str[lenn + lenp + 1] = 0;
atom->valuep = str;
}
if (xmlFAGenerateTransitions(am, from, to, atom) < 0) {
xmlRegFreeAtom(atom);
return(NULL);
}
if (to == NULL)
return(am->state);
return(to);
}
/**
* xmlAutomataNewNegTrans:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @token: the first input string associated to that transition
* @token2: the second input string associated to that transition
* @data: data passed to the callback function if the transition is activated
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
* activated by any value except (@token,@token2)
* Note that if @token2 is not NULL, then (X, NULL) won't match to follow
# the semantic of XSD ##other
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewNegTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, const xmlChar *token,
const xmlChar *token2, void *data) {
xmlRegAtomPtr atom;
xmlChar err_msg[200];
if ((am == NULL) || (from == NULL) || (token == NULL))
return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL)
return(NULL);
atom->data = data;
atom->neg = 1;
if ((token2 == NULL) || (*token2 == 0)) {
atom->valuep = xmlStrdup(token);
} else {
int lenn, lenp;
xmlChar *str;
lenn = strlen((char *) token2);
lenp = strlen((char *) token);
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
if (str == NULL) {
xmlRegFreeAtom(atom);
return(NULL);
}
memcpy(&str[0], token, lenp);
str[lenp] = '|';
memcpy(&str[lenp + 1], token2, lenn);
str[lenn + lenp + 1] = 0;
atom->valuep = str;
}
snprintf((char *) err_msg, 199, "not %s", (const char *) atom->valuep);
err_msg[199] = 0;
atom->valuep2 = xmlStrdup(err_msg);
if (xmlFAGenerateTransitions(am, from, to, atom) < 0) {
xmlRegFreeAtom(atom);
return(NULL);
}
am->negs++;
if (to == NULL)
return(am->state);
return(to);
}
/**
* xmlAutomataNewCountTrans2:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @token: the input string associated to that transition
* @token2: the second input string associated to that transition
* @min: the minimum successive occurences of token
* @max: the maximum successive occurences of token
* @data: data associated to the transition
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
* activated by a succession of input of value @token and @token2 and
* whose number is between @min and @max
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewCountTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, const xmlChar *token,
const xmlChar *token2,
int min, int max, void *data) {
xmlRegAtomPtr atom;
int counter;
if ((am == NULL) || (from == NULL) || (token == NULL))
return(NULL);
if (min < 0)
return(NULL);
if ((max < min) || (max < 1))
return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL)
return(NULL);
if ((token2 == NULL) || (*token2 == 0)) {
atom->valuep = xmlStrdup(token);
} else {
int lenn, lenp;
xmlChar *str;
lenn = strlen((char *) token2);
lenp = strlen((char *) token);
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
if (str == NULL) {
xmlRegFreeAtom(atom);
return(NULL);
}
memcpy(&str[0], token, lenp);
str[lenp] = '|';
memcpy(&str[lenp + 1], token2, lenn);
str[lenn + lenp + 1] = 0;
atom->valuep = str;
}
atom->data = data;
if (min == 0)
atom->min = 1;
else
atom->min = min;
atom->max = max;
/*
* associate a counter to the transition.
*/
counter = xmlRegGetCounter(am);
am->counters[counter].min = min;
am->counters[counter].max = max;
/* xmlFAGenerateTransitions(am, from, to, atom); */
if (to == NULL) {
to = xmlRegNewState(am);
xmlRegStatePush(am, to);
}
xmlRegStateAddTrans(am, from, atom, to, counter, -1);
xmlRegAtomPush(am, atom);
am->state = to;
if (to == NULL)
to = am->state;
if (to == NULL)
return(NULL);
if (min == 0)
xmlFAGenerateEpsilonTransition(am, from, to);
return(to);
}
/**
* xmlAutomataNewCountTrans:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @token: the input string associated to that transition
* @min: the minimum successive occurences of token
* @max: the maximum successive occurences of token
* @data: data associated to the transition
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
* activated by a succession of input of value @token and whose number
* is between @min and @max
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewCountTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, const xmlChar *token,
int min, int max, void *data) {
xmlRegAtomPtr atom;
int counter;
if ((am == NULL) || (from == NULL) || (token == NULL))
return(NULL);
if (min < 0)
return(NULL);
if ((max < min) || (max < 1))
return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL)
return(NULL);
atom->valuep = xmlStrdup(token);
atom->data = data;
if (min == 0)
atom->min = 1;
else
atom->min = min;
atom->max = max;
/*
* associate a counter to the transition.
*/
counter = xmlRegGetCounter(am);
am->counters[counter].min = min;
am->counters[counter].max = max;
/* xmlFAGenerateTransitions(am, from, to, atom); */
if (to == NULL) {
to = xmlRegNewState(am);
xmlRegStatePush(am, to);
}
xmlRegStateAddTrans(am, from, atom, to, counter, -1);
xmlRegAtomPush(am, atom);
am->state = to;
if (to == NULL)
to = am->state;
if (to == NULL)
return(NULL);
if (min == 0)
xmlFAGenerateEpsilonTransition(am, from, to);
return(to);
}
/**
* xmlAutomataNewOnceTrans2:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @token: the input string associated to that transition
* @token2: the second input string associated to that transition
* @min: the minimum successive occurences of token
* @max: the maximum successive occurences of token
* @data: data associated to the transition
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
* activated by a succession of input of value @token and @token2 and whose
* number is between @min and @max, moreover that transition can only be
* crossed once.
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, const xmlChar *token,
const xmlChar *token2,
int min, int max, void *data) {
xmlRegAtomPtr atom;
int counter;
if ((am == NULL) || (from == NULL) || (token == NULL))
return(NULL);
if (min < 1)
return(NULL);
if ((max < min) || (max < 1))
return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL)
return(NULL);
if ((token2 == NULL) || (*token2 == 0)) {
atom->valuep = xmlStrdup(token);
} else {
int lenn, lenp;
xmlChar *str;
lenn = strlen((char *) token2);
lenp = strlen((char *) token);
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
if (str == NULL) {
xmlRegFreeAtom(atom);
return(NULL);
}
memcpy(&str[0], token, lenp);
str[lenp] = '|';
memcpy(&str[lenp + 1], token2, lenn);
str[lenn + lenp + 1] = 0;
atom->valuep = str;
}
atom->data = data;
atom->quant = XML_REGEXP_QUANT_ONCEONLY;
atom->min = min;
atom->max = max;
/*
* associate a counter to the transition.
*/
counter = xmlRegGetCounter(am);
am->counters[counter].min = 1;
am->counters[counter].max = 1;
/* xmlFAGenerateTransitions(am, from, to, atom); */
if (to == NULL) {
to = xmlRegNewState(am);
xmlRegStatePush(am, to);
}
xmlRegStateAddTrans(am, from, atom, to, counter, -1);
xmlRegAtomPush(am, atom);
am->state = to;
return(to);
}
/**
* xmlAutomataNewOnceTrans:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @token: the input string associated to that transition
* @min: the minimum successive occurences of token
* @max: the maximum successive occurences of token
* @data: data associated to the transition
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
* activated by a succession of input of value @token and whose number
* is between @min and @max, moreover that transition can only be crossed
* once.
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, const xmlChar *token,
int min, int max, void *data) {
xmlRegAtomPtr atom;
int counter;
if ((am == NULL) || (from == NULL) || (token == NULL))
return(NULL);
if (min < 1)
return(NULL);
if ((max < min) || (max < 1))
return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL)
return(NULL);
atom->valuep = xmlStrdup(token);
atom->data = data;
atom->quant = XML_REGEXP_QUANT_ONCEONLY;
atom->min = min;
atom->max = max;
/*
* associate a counter to the transition.
*/
counter = xmlRegGetCounter(am);
am->counters[counter].min = 1;
am->counters[counter].max = 1;
/* xmlFAGenerateTransitions(am, from, to, atom); */
if (to == NULL) {
to = xmlRegNewState(am);
xmlRegStatePush(am, to);
}
xmlRegStateAddTrans(am, from, atom, to, counter, -1);
xmlRegAtomPush(am, atom);
am->state = to;
return(to);
}
/**
* xmlAutomataNewState:
* @am: an automata
*
* Create a new disconnected state in the automata
*
* Returns the new state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewState(xmlAutomataPtr am) {
xmlAutomataStatePtr to;
if (am == NULL)
return(NULL);
to = xmlRegNewState(am);
xmlRegStatePush(am, to);
return(to);
}
/**
* xmlAutomataNewEpsilon:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds an epsilon transition from the @from state to the
* target state
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewEpsilon(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to) {
if ((am == NULL) || (from == NULL))
return(NULL);
xmlFAGenerateEpsilonTransition(am, from, to);
if (to == NULL)
return(am->state);
return(to);
}
/**
* xmlAutomataNewAllTrans:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @lax: allow to transition if not all all transitions have been activated
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a an ALL transition from the @from state to the
* target state. That transition is an epsilon transition allowed only when
* all transitions from the @from node have been activated.
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewAllTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, int lax) {
if ((am == NULL) || (from == NULL))
return(NULL);
xmlFAGenerateAllTransition(am, from, to, lax);
if (to == NULL)
return(am->state);
return(to);
}
/**
* xmlAutomataNewCounter:
* @am: an automata
* @min: the minimal value on the counter
* @max: the maximal value on the counter
*
* Create a new counter
*
* Returns the counter number or -1 in case of error
*/
int
xmlAutomataNewCounter(xmlAutomataPtr am, int min, int max) {
int ret;
if (am == NULL)
return(-1);
ret = xmlRegGetCounter(am);
if (ret < 0)
return(-1);
am->counters[ret].min = min;
am->counters[ret].max = max;
return(ret);
}
/**
* xmlAutomataNewCountedTrans:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @counter: the counter associated to that transition
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds an epsilon transition from the @from state to the target state
* which will increment the counter provided
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewCountedTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, int counter) {
if ((am == NULL) || (from == NULL) || (counter < 0))
return(NULL);
xmlFAGenerateCountedEpsilonTransition(am, from, to, counter);
if (to == NULL)
return(am->state);
return(to);
}
/**
* xmlAutomataNewCounterTrans:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @counter: the counter associated to that transition
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds an epsilon transition from the @from state to the target state
* which will be allowed only if the counter is within the right range.
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewCounterTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, int counter) {
if ((am == NULL) || (from == NULL) || (counter < 0))
return(NULL);
xmlFAGenerateCountedTransition(am, from, to, counter);
if (to == NULL)
return(am->state);
return(to);
}
/**
* xmlAutomataCompile:
* @am: an automata
*
* Compile the automata into a Reg Exp ready for being executed.
* The automata should be free after this point.
*
* Returns the compiled regexp or NULL in case of error
*/
xmlRegexpPtr
xmlAutomataCompile(xmlAutomataPtr am) {
xmlRegexpPtr ret;
if ((am == NULL) || (am->error != 0)) return(NULL);
xmlFAEliminateEpsilonTransitions(am);
/* xmlFAComputesDeterminism(am); */
ret = xmlRegEpxFromParse(am);
return(ret);
}
/**
* xmlAutomataIsDeterminist:
* @am: an automata
*
* Checks if an automata is determinist.
*
* Returns 1 if true, 0 if not, and -1 in case of error
*/
int
xmlAutomataIsDeterminist(xmlAutomataPtr am) {
int ret;
if (am == NULL)
return(-1);
ret = xmlFAComputesDeterminism(am);
return(ret);
}
#endif /* LIBXML_AUTOMATA_ENABLED */
#ifdef LIBXML_EXPR_ENABLED
/************************************************************************
* *