1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-23 17:33:50 +03:00

regexp: Hide experimental legacy code

This was never made public.
This commit is contained in:
Nick Wellnhofer 2024-06-16 00:11:41 +02:00
parent 10d60d15d6
commit fa01278dcd
4 changed files with 110 additions and 754 deletions

View File

@ -2952,42 +2952,10 @@
<summary>regular expressions handling</summary>
<description>basic API for libxml regular expressions handling used for XML Schemas and validation. </description>
<author>Daniel Veillard </author>
<exports symbol='XML_EXP_ATOM' type='enum'/>
<exports symbol='XML_EXP_COUNT' type='enum'/>
<exports symbol='XML_EXP_EMPTY' type='enum'/>
<exports symbol='XML_EXP_FORBID' type='enum'/>
<exports symbol='XML_EXP_OR' type='enum'/>
<exports symbol='XML_EXP_SEQ' type='enum'/>
<exports symbol='xmlExpCtxt' type='typedef'/>
<exports symbol='xmlExpCtxtPtr' type='typedef'/>
<exports symbol='xmlExpNode' type='typedef'/>
<exports symbol='xmlExpNodePtr' type='typedef'/>
<exports symbol='xmlExpNodeType' type='typedef'/>
<exports symbol='xmlRegExecCtxt' type='typedef'/>
<exports symbol='xmlRegExecCtxtPtr' type='typedef'/>
<exports symbol='xmlRegexp' type='typedef'/>
<exports symbol='xmlRegexpPtr' type='typedef'/>
<exports symbol='emptyExp' type='variable'/>
<exports symbol='forbiddenExp' type='variable'/>
<exports symbol='xmlExpCtxtNbCons' type='function'/>
<exports symbol='xmlExpCtxtNbNodes' type='function'/>
<exports symbol='xmlExpDump' type='function'/>
<exports symbol='xmlExpExpDerive' type='function'/>
<exports symbol='xmlExpFree' type='function'/>
<exports symbol='xmlExpFreeCtxt' type='function'/>
<exports symbol='xmlExpGetLanguage' type='function'/>
<exports symbol='xmlExpGetStart' type='function'/>
<exports symbol='xmlExpIsNillable' type='function'/>
<exports symbol='xmlExpMaxToken' type='function'/>
<exports symbol='xmlExpNewAtom' type='function'/>
<exports symbol='xmlExpNewCtxt' type='function'/>
<exports symbol='xmlExpNewOr' type='function'/>
<exports symbol='xmlExpNewRange' type='function'/>
<exports symbol='xmlExpNewSeq' type='function'/>
<exports symbol='xmlExpParse' type='function'/>
<exports symbol='xmlExpRef' type='function'/>
<exports symbol='xmlExpStringDerive' type='function'/>
<exports symbol='xmlExpSubsume' type='function'/>
<exports symbol='xmlRegExecCallbacks' type='function'/>
<exports symbol='xmlRegExecErrInfo' type='function'/>
<exports symbol='xmlRegExecNextValues' type='function'/>
@ -4870,12 +4838,6 @@ and not by parsing an instance'/>
<enum name='XML_ERR_WARNING' file='xmlerror' value='1' type='xmlErrorLevel' info='A simple warning'/>
<enum name='XML_ERR_XMLDECL_NOT_FINISHED' file='xmlerror' value='57' type='xmlParserErrors' info='57'/>
<enum name='XML_ERR_XMLDECL_NOT_STARTED' file='xmlerror' value='56' type='xmlParserErrors' info='56'/>
<enum name='XML_EXP_ATOM' file='xmlregexp' value='2' type='xmlExpNodeType'/>
<enum name='XML_EXP_COUNT' file='xmlregexp' value='5' type='xmlExpNodeType'/>
<enum name='XML_EXP_EMPTY' file='xmlregexp' value='0' type='xmlExpNodeType'/>
<enum name='XML_EXP_FORBID' file='xmlregexp' value='1' type='xmlExpNodeType'/>
<enum name='XML_EXP_OR' file='xmlregexp' value='4' type='xmlExpNodeType'/>
<enum name='XML_EXP_SEQ' file='xmlregexp' value='3' type='xmlExpNodeType'/>
<enum name='XML_EXTERNAL_GENERAL_PARSED_ENTITY' file='entities' value='2' type='xmlEntityType'/>
<enum name='XML_EXTERNAL_GENERAL_UNPARSED_ENTITY' file='entities' value='3' type='xmlEntityType'/>
<enum name='XML_EXTERNAL_PARAMETER_ENTITY' file='entities' value='5' type='xmlEntityType'/>
@ -6118,11 +6080,6 @@ set at the end of parsing'/>
<typedef name='xmlErrorDomain' file='xmlerror' type='enum'/>
<typedef name='xmlErrorLevel' file='xmlerror' type='enum'/>
<typedef name='xmlErrorPtr' file='xmlerror' type='xmlError *'/>
<struct name='xmlExpCtxt' file='xmlregexp' type='struct _xmlExpCtxt'/>
<typedef name='xmlExpCtxtPtr' file='xmlregexp' type='xmlExpCtxt *'/>
<struct name='xmlExpNode' file='xmlregexp' type='struct _xmlExpNode'/>
<typedef name='xmlExpNodePtr' file='xmlregexp' type='xmlExpNode *'/>
<typedef name='xmlExpNodeType' file='xmlregexp' type='enum'/>
<typedef name='xmlFeature' file='parser' type='enum'/>
<struct name='xmlGlobalState' file='globals' type='struct _xmlGlobalState'/>
<typedef name='xmlGlobalStatePtr' file='globals' type='xmlGlobalState *'/>
@ -6855,8 +6812,6 @@ Could we use @subtypes for this?'/>
<field name='value' type='xmlXPathObjectPtr' info=' the value'/>
</struct>
<typedef name='xmlXPathVariablePtr' file='xpath' type='xmlXPathVariable *'/>
<variable name='emptyExp' file='xmlregexp' type='xmlExpNodePtr'/>
<variable name='forbiddenExp' file='xmlregexp' type='xmlExpNodePtr'/>
<variable name='htmlDefaultSAXHandler' file='HTMLparser' type='const xmlSAXHandlerV1'>
<info>DEPRECATED: This handler is unused and will be removed from future versions. Default old SAX v1 handler for HTML, builds the DOM tree</info>
</variable>
@ -9573,146 +9528,6 @@ Could we use @subtypes for this?'/>
<arg name='firstNode' type='xmlNodePtr' info='the fist node in the chunk'/>
<arg name='lastNode' type='xmlNodePtr' info='the last nod in the chunk'/>
</functype>
<function name='xmlExpCtxtNbCons' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Debugging facility provides the number of allocated nodes over lifetime</info>
<return type='int' info='the number of nodes ever allocated or -1 in case of error'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='an expression context'/>
</function>
<function name='xmlExpCtxtNbNodes' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Debugging facility provides the number of allocated nodes at a that point</info>
<return type='int' info='the number of nodes in use or -1 in case of error'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='an expression context'/>
</function>
<function name='xmlExpDump' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Serialize the expression as compiled to the buffer</info>
<return type='void'/>
<arg name='buf' type='xmlBufferPtr' info='a buffer to receive the output'/>
<arg name='expr' type='xmlExpNodePtr' info='the compiled expression'/>
</function>
<function name='xmlExpExpDerive' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Evaluates the expression resulting from @exp consuming a sub expression @sub Based on algebraic derivation and sometimes direct Brzozowski derivation it usually takes less than linear time and can handle expressions generating infinite languages.</info>
<return type='xmlExpNodePtr' info='the resulting expression or NULL in case of internal error, the result must be freed'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expressions context'/>
<arg name='exp' type='xmlExpNodePtr' info='the englobing expression'/>
<arg name='sub' type='xmlExpNodePtr' info='the subexpression'/>
</function>
<function name='xmlExpFree' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Dereference the expression</info>
<return type='void'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expression context'/>
<arg name='exp' type='xmlExpNodePtr' info='the expression'/>
</function>
<function name='xmlExpFreeCtxt' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Free an expression context</info>
<return type='void'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='an expression context'/>
</function>
<function name='xmlExpGetLanguage' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Find all the strings used in @exp and store them in @list</info>
<return type='int' info='the number of unique strings found, -1 in case of errors and -2 if there is more than @len strings'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expression context'/>
<arg name='exp' type='xmlExpNodePtr' info='the expression'/>
<arg name='langList' type='const xmlChar **' info='where to store the tokens'/>
<arg name='len' type='int' info='the allocated length of @list'/>
</function>
<function name='xmlExpGetStart' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Find all the strings that appears at the start of the languages accepted by @exp and store them in @list. E.g. for (a, b) | c it will return the list [a, c]</info>
<return type='int' info='the number of unique strings found, -1 in case of errors and -2 if there is more than @len strings'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expression context'/>
<arg name='exp' type='xmlExpNodePtr' info='the expression'/>
<arg name='tokList' type='const xmlChar **' info='where to store the tokens'/>
<arg name='len' type='int' info='the allocated length of @list'/>
</function>
<function name='xmlExpIsNillable' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Finds if the expression is nillable, i.e. if it accepts the empty sequence</info>
<return type='int' info='1 if nillable, 0 if not and -1 in case of error'/>
<arg name='exp' type='xmlExpNodePtr' info='the expression'/>
</function>
<function name='xmlExpMaxToken' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Indicate the maximum number of input a expression can accept</info>
<return type='int' info='the maximum length or -1 in case of error'/>
<arg name='expr' type='xmlExpNodePtr' info='a compiled expression'/>
</function>
<function name='xmlExpNewAtom' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Get the atom associated to this name from that context</info>
<return type='xmlExpNodePtr' info='the node or NULL in case of error'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expression context'/>
<arg name='name' type='const xmlChar *' info='the atom name'/>
<arg name='len' type='int' info='the atom name length in byte (or -1);'/>
</function>
<function name='xmlExpNewCtxt' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Creates a new context for manipulating expressions</info>
<return type='xmlExpCtxtPtr' info='the context or NULL in case of error'/>
<arg name='maxNodes' type='int' info='the maximum number of nodes'/>
<arg name='dict' type='xmlDictPtr' info='optional dictionary to use internally'/>
</function>
<function name='xmlExpNewOr' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Get the atom associated to the choice @left | @right Note that @left and @right are consumed in the operation, to keep an handle on them use xmlExpRef() and use xmlExpFree() to release them, this is true even in case of failure (unless ctxt == NULL).</info>
<return type='xmlExpNodePtr' info='the node or NULL in case of error'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expression context'/>
<arg name='left' type='xmlExpNodePtr' info='left expression'/>
<arg name='right' type='xmlExpNodePtr' info='right expression'/>
</function>
<function name='xmlExpNewRange' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Get the atom associated to the range (@subset){@min, @max} Note that @subset is consumed in the operation, to keep an handle on it use xmlExpRef() and use xmlExpFree() to release it, this is true even in case of failure (unless ctxt == NULL).</info>
<return type='xmlExpNodePtr' info='the node or NULL in case of error'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expression context'/>
<arg name='subset' type='xmlExpNodePtr' info='the expression to be repeated'/>
<arg name='min' type='int' info='the lower bound for the repetition'/>
<arg name='max' type='int' info='the upper bound for the repetition, -1 means infinite'/>
</function>
<function name='xmlExpNewSeq' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Get the atom associated to the sequence @left , @right Note that @left and @right are consumed in the operation, to keep an handle on them use xmlExpRef() and use xmlExpFree() to release them, this is true even in case of failure (unless ctxt == NULL).</info>
<return type='xmlExpNodePtr' info='the node or NULL in case of error'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expression context'/>
<arg name='left' type='xmlExpNodePtr' info='left expression'/>
<arg name='right' type='xmlExpNodePtr' info='right expression'/>
</function>
<function name='xmlExpParse' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Minimal parser for regexps, it understand the following constructs - string terminals - choice operator | - sequence operator , - subexpressions (...) - usual cardinality operators + * and ? - finite sequences { min, max } - infinite sequences { min, * } There is minimal checkings made especially no checking on strings values</info>
<return type='xmlExpNodePtr' info='a new expression or NULL in case of failure'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expressions context'/>
<arg name='expr' type='const char *' info='the 0 terminated string'/>
</function>
<function name='xmlExpRef' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Increase the reference count of the expression</info>
<return type='void'/>
<arg name='exp' type='xmlExpNodePtr' info='the expression'/>
</function>
<function name='xmlExpStringDerive' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Do one step of Brzozowski derivation of the expression @exp with respect to the input string</info>
<return type='xmlExpNodePtr' info='the resulting expression or NULL in case of internal error'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expression context'/>
<arg name='exp' type='xmlExpNodePtr' info='the expression'/>
<arg name='str' type='const xmlChar *' info='the string'/>
<arg name='len' type='int' info='the string len in bytes if available'/>
</function>
<function name='xmlExpSubsume' file='xmlregexp' module='xmlregexp'>
<cond>defined(LIBXML_REGEXP_ENABLED) &amp;&amp; defined(LIBXML_EXPR_ENABLED)</cond>
<info>Check whether @exp accepts all the languages accepted by @sub the input being a subexpression.</info>
<return type='int' info='1 if true 0 if false and -1 in case of failure.'/>
<arg name='ctxt' type='xmlExpCtxtPtr' info='the expressions context'/>
<arg name='exp' type='xmlExpNodePtr' info='the englobing expression'/>
<arg name='sub' type='xmlExpNodePtr' info='the subexpression'/>
</function>
<functype name='xmlExternalEntityLoader' file='parser' module='parser'>
<info>External entity loaders types.</info>
<return type='xmlParserInputPtr' info='the entity input parser.'/>

View File

@ -99,113 +99,7 @@ XMLPUBFUN int
int *nbneg,
xmlChar **values,
int *terminal);
#ifdef LIBXML_EXPR_ENABLED
/*
* Formal regular expression handling
* Its goal is to do some formal work on content models
*/
/* expressions are used within a context */
typedef struct _xmlExpCtxt xmlExpCtxt;
typedef xmlExpCtxt *xmlExpCtxtPtr;
XMLPUBFUN void
xmlExpFreeCtxt (xmlExpCtxtPtr ctxt);
XMLPUBFUN xmlExpCtxtPtr
xmlExpNewCtxt (int maxNodes,
xmlDictPtr dict);
XMLPUBFUN int
xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);
XMLPUBFUN int
xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);
/* Expressions are trees but the tree is opaque */
typedef struct _xmlExpNode xmlExpNode;
typedef xmlExpNode *xmlExpNodePtr;
typedef enum {
XML_EXP_EMPTY = 0,
XML_EXP_FORBID = 1,
XML_EXP_ATOM = 2,
XML_EXP_SEQ = 3,
XML_EXP_OR = 4,
XML_EXP_COUNT = 5
} xmlExpNodeType;
/*
* 2 core expressions shared by all for the empty language set
* and for the set with just the empty token
*/
XMLPUBVAR xmlExpNodePtr forbiddenExp;
XMLPUBVAR xmlExpNodePtr emptyExp;
/*
* Expressions are reference counted internally
*/
XMLPUBFUN void
xmlExpFree (xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr);
XMLPUBFUN void
xmlExpRef (xmlExpNodePtr expr);
/*
* constructors can be either manual or from a string
*/
XMLPUBFUN xmlExpNodePtr
xmlExpParse (xmlExpCtxtPtr ctxt,
const char *expr);
XMLPUBFUN xmlExpNodePtr
xmlExpNewAtom (xmlExpCtxtPtr ctxt,
const xmlChar *name,
int len);
XMLPUBFUN xmlExpNodePtr
xmlExpNewOr (xmlExpCtxtPtr ctxt,
xmlExpNodePtr left,
xmlExpNodePtr right);
XMLPUBFUN xmlExpNodePtr
xmlExpNewSeq (xmlExpCtxtPtr ctxt,
xmlExpNodePtr left,
xmlExpNodePtr right);
XMLPUBFUN xmlExpNodePtr
xmlExpNewRange (xmlExpCtxtPtr ctxt,
xmlExpNodePtr subset,
int min,
int max);
/*
* The really interesting APIs
*/
XMLPUBFUN int
xmlExpIsNillable(xmlExpNodePtr expr);
XMLPUBFUN int
xmlExpMaxToken (xmlExpNodePtr expr);
XMLPUBFUN int
xmlExpGetLanguage(xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr,
const xmlChar**langList,
int len);
XMLPUBFUN int
xmlExpGetStart (xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr,
const xmlChar**tokList,
int len);
XMLPUBFUN xmlExpNodePtr
xmlExpStringDerive(xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr,
const xmlChar *str,
int len);
XMLPUBFUN xmlExpNodePtr
xmlExpExpDerive (xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr,
xmlExpNodePtr sub);
XMLPUBFUN int
xmlExpSubsume (xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr,
xmlExpNodePtr sub);
XMLPUBFUN void
xmlExpDump (xmlBufferPtr buf,
xmlExpNodePtr expr);
#endif /* LIBXML_EXPR_ENABLED */
#ifdef __cplusplus
}
#endif

464
testapi.c
View File

@ -33719,451 +33719,6 @@ test_xmlreader(void) {
printf("Module xmlreader: %d errors\n", test_ret);
return(test_ret);
}
static int
test_xmlExpCtxtNbCons(void) {
int test_ret = 0;
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
int mem_base;
int ret_val;
xmlExpCtxtPtr ctxt; /* an expression context */
int n_ctxt;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlExpCtxtPtr;n_ctxt++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlExpCtxtPtr(n_ctxt, 0);
ret_val = xmlExpCtxtNbCons(ctxt);
desret_int(ret_val);
call_tests++;
des_xmlExpCtxtPtr(n_ctxt, ctxt, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlExpCtxtNbCons",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlExpCtxtNbNodes(void) {
int test_ret = 0;
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
int mem_base;
int ret_val;
xmlExpCtxtPtr ctxt; /* an expression context */
int n_ctxt;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlExpCtxtPtr;n_ctxt++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlExpCtxtPtr(n_ctxt, 0);
ret_val = xmlExpCtxtNbNodes(ctxt);
desret_int(ret_val);
call_tests++;
des_xmlExpCtxtPtr(n_ctxt, ctxt, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlExpCtxtNbNodes",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlExpDump(void) {
int test_ret = 0;
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
int mem_base;
xmlBufferPtr buf; /* a buffer to receive the output */
int n_buf;
xmlExpNodePtr expr; /* the compiled expression */
int n_expr;
for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) {
for (n_expr = 0;n_expr < gen_nb_xmlExpNodePtr;n_expr++) {
mem_base = xmlMemBlocks();
buf = gen_xmlBufferPtr(n_buf, 0);
expr = gen_xmlExpNodePtr(n_expr, 1);
xmlExpDump(buf, expr);
call_tests++;
des_xmlBufferPtr(n_buf, buf, 0);
des_xmlExpNodePtr(n_expr, expr, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlExpDump",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_buf);
printf(" %d", n_expr);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlExpExpDerive(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlExpGetLanguage(void) {
int test_ret = 0;
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
int mem_base;
int ret_val;
xmlExpCtxtPtr ctxt; /* the expression context */
int n_ctxt;
xmlExpNodePtr exp; /* the expression */
int n_exp;
const xmlChar ** langList; /* where to store the tokens */
int n_langList;
int len; /* the allocated length of @list */
int n_len;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlExpCtxtPtr;n_ctxt++) {
for (n_exp = 0;n_exp < gen_nb_xmlExpNodePtr;n_exp++) {
for (n_langList = 0;n_langList < gen_nb_const_xmlChar_ptr_ptr;n_langList++) {
for (n_len = 0;n_len < gen_nb_int;n_len++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlExpCtxtPtr(n_ctxt, 0);
exp = gen_xmlExpNodePtr(n_exp, 1);
langList = gen_const_xmlChar_ptr_ptr(n_langList, 2);
len = gen_int(n_len, 3);
ret_val = xmlExpGetLanguage(ctxt, exp, langList, len);
desret_int(ret_val);
call_tests++;
des_xmlExpCtxtPtr(n_ctxt, ctxt, 0);
des_xmlExpNodePtr(n_exp, exp, 1);
des_const_xmlChar_ptr_ptr(n_langList, langList, 2);
des_int(n_len, len, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlExpGetLanguage",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_exp);
printf(" %d", n_langList);
printf(" %d", n_len);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlExpGetStart(void) {
int test_ret = 0;
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
int mem_base;
int ret_val;
xmlExpCtxtPtr ctxt; /* the expression context */
int n_ctxt;
xmlExpNodePtr exp; /* the expression */
int n_exp;
const xmlChar ** tokList; /* where to store the tokens */
int n_tokList;
int len; /* the allocated length of @list */
int n_len;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlExpCtxtPtr;n_ctxt++) {
for (n_exp = 0;n_exp < gen_nb_xmlExpNodePtr;n_exp++) {
for (n_tokList = 0;n_tokList < gen_nb_const_xmlChar_ptr_ptr;n_tokList++) {
for (n_len = 0;n_len < gen_nb_int;n_len++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlExpCtxtPtr(n_ctxt, 0);
exp = gen_xmlExpNodePtr(n_exp, 1);
tokList = gen_const_xmlChar_ptr_ptr(n_tokList, 2);
len = gen_int(n_len, 3);
ret_val = xmlExpGetStart(ctxt, exp, tokList, len);
desret_int(ret_val);
call_tests++;
des_xmlExpCtxtPtr(n_ctxt, ctxt, 0);
des_xmlExpNodePtr(n_exp, exp, 1);
des_const_xmlChar_ptr_ptr(n_tokList, tokList, 2);
des_int(n_len, len, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlExpGetStart",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_exp);
printf(" %d", n_tokList);
printf(" %d", n_len);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlExpIsNillable(void) {
int test_ret = 0;
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
int mem_base;
int ret_val;
xmlExpNodePtr exp; /* the expression */
int n_exp;
for (n_exp = 0;n_exp < gen_nb_xmlExpNodePtr;n_exp++) {
mem_base = xmlMemBlocks();
exp = gen_xmlExpNodePtr(n_exp, 0);
ret_val = xmlExpIsNillable(exp);
desret_int(ret_val);
call_tests++;
des_xmlExpNodePtr(n_exp, exp, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlExpIsNillable",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_exp);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlExpMaxToken(void) {
int test_ret = 0;
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
int mem_base;
int ret_val;
xmlExpNodePtr expr; /* a compiled expression */
int n_expr;
for (n_expr = 0;n_expr < gen_nb_xmlExpNodePtr;n_expr++) {
mem_base = xmlMemBlocks();
expr = gen_xmlExpNodePtr(n_expr, 0);
ret_val = xmlExpMaxToken(expr);
desret_int(ret_val);
call_tests++;
des_xmlExpNodePtr(n_expr, expr, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlExpMaxToken",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_expr);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlExpNewAtom(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlExpNewCtxt(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlExpNewOr(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlExpNewRange(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlExpNewSeq(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlExpParse(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlExpRef(void) {
int test_ret = 0;
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
int mem_base;
xmlExpNodePtr exp; /* the expression */
int n_exp;
for (n_exp = 0;n_exp < gen_nb_xmlExpNodePtr;n_exp++) {
mem_base = xmlMemBlocks();
exp = gen_xmlExpNodePtr(n_exp, 0);
xmlExpRef(exp);
call_tests++;
des_xmlExpNodePtr(n_exp, exp, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlExpRef",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_exp);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlExpStringDerive(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlExpSubsume(void) {
int test_ret = 0;
#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
int mem_base;
int ret_val;
xmlExpCtxtPtr ctxt; /* the expressions context */
int n_ctxt;
xmlExpNodePtr exp; /* the englobing expression */
int n_exp;
xmlExpNodePtr sub; /* the subexpression */
int n_sub;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlExpCtxtPtr;n_ctxt++) {
for (n_exp = 0;n_exp < gen_nb_xmlExpNodePtr;n_exp++) {
for (n_sub = 0;n_sub < gen_nb_xmlExpNodePtr;n_sub++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlExpCtxtPtr(n_ctxt, 0);
exp = gen_xmlExpNodePtr(n_exp, 1);
sub = gen_xmlExpNodePtr(n_sub, 2);
ret_val = xmlExpSubsume(ctxt, exp, sub);
desret_int(ret_val);
call_tests++;
des_xmlExpCtxtPtr(n_ctxt, ctxt, 0);
des_xmlExpNodePtr(n_exp, exp, 1);
des_xmlExpNodePtr(n_sub, sub, 2);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlExpSubsume",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_exp);
printf(" %d", n_sub);
printf("\n");
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
#ifdef LIBXML_REGEXP_ENABLED
#define gen_nb_xmlRegExecCtxtPtr 1
@ -34550,24 +34105,7 @@ static int
test_xmlregexp(void) {
int test_ret = 0;
if (quiet == 0) printf("Testing xmlregexp : 16 of 30 functions ...\n");
test_ret += test_xmlExpCtxtNbCons();
test_ret += test_xmlExpCtxtNbNodes();
test_ret += test_xmlExpDump();
test_ret += test_xmlExpExpDerive();
test_ret += test_xmlExpGetLanguage();
test_ret += test_xmlExpGetStart();
test_ret += test_xmlExpIsNillable();
test_ret += test_xmlExpMaxToken();
test_ret += test_xmlExpNewAtom();
test_ret += test_xmlExpNewCtxt();
test_ret += test_xmlExpNewOr();
test_ret += test_xmlExpNewRange();
test_ret += test_xmlExpNewSeq();
test_ret += test_xmlExpParse();
test_ret += test_xmlExpRef();
test_ret += test_xmlExpStringDerive();
test_ret += test_xmlExpSubsume();
if (quiet == 0) printf("Testing xmlregexp : 7 of 11 functions ...\n");
test_ret += test_xmlRegExecErrInfo();
test_ret += test_xmlRegExecNextValues();
test_ret += test_xmlRegExecPushString();

View File

@ -6316,11 +6316,119 @@ xmlAutomataIsDeterminist(xmlAutomataPtr am) {
}
#ifdef LIBXML_EXPR_ENABLED
/** DOC_DISABLE */
/************************************************************************
* *
* Formal Expression handling code *
* *
************************************************************************/
/*
* Formal regular expression handling
* Its goal is to do some formal work on content models
*/
/* expressions are used within a context */
typedef struct _xmlExpCtxt xmlExpCtxt;
typedef xmlExpCtxt *xmlExpCtxtPtr;
XMLPUBFUN void
xmlExpFreeCtxt (xmlExpCtxtPtr ctxt);
XMLPUBFUN xmlExpCtxtPtr
xmlExpNewCtxt (int maxNodes,
xmlDictPtr dict);
XMLPUBFUN int
xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);
XMLPUBFUN int
xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);
/* Expressions are trees but the tree is opaque */
typedef struct _xmlExpNode xmlExpNode;
typedef xmlExpNode *xmlExpNodePtr;
typedef enum {
XML_EXP_EMPTY = 0,
XML_EXP_FORBID = 1,
XML_EXP_ATOM = 2,
XML_EXP_SEQ = 3,
XML_EXP_OR = 4,
XML_EXP_COUNT = 5
} xmlExpNodeType;
/*
* 2 core expressions shared by all for the empty language set
* and for the set with just the empty token
*/
XMLPUBVAR xmlExpNodePtr forbiddenExp;
XMLPUBVAR xmlExpNodePtr emptyExp;
/*
* Expressions are reference counted internally
*/
XMLPUBFUN void
xmlExpFree (xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr);
XMLPUBFUN void
xmlExpRef (xmlExpNodePtr expr);
/*
* constructors can be either manual or from a string
*/
XMLPUBFUN xmlExpNodePtr
xmlExpParse (xmlExpCtxtPtr ctxt,
const char *expr);
XMLPUBFUN xmlExpNodePtr
xmlExpNewAtom (xmlExpCtxtPtr ctxt,
const xmlChar *name,
int len);
XMLPUBFUN xmlExpNodePtr
xmlExpNewOr (xmlExpCtxtPtr ctxt,
xmlExpNodePtr left,
xmlExpNodePtr right);
XMLPUBFUN xmlExpNodePtr
xmlExpNewSeq (xmlExpCtxtPtr ctxt,
xmlExpNodePtr left,
xmlExpNodePtr right);
XMLPUBFUN xmlExpNodePtr
xmlExpNewRange (xmlExpCtxtPtr ctxt,
xmlExpNodePtr subset,
int min,
int max);
/*
* The really interesting APIs
*/
XMLPUBFUN int
xmlExpIsNillable(xmlExpNodePtr expr);
XMLPUBFUN int
xmlExpMaxToken (xmlExpNodePtr expr);
XMLPUBFUN int
xmlExpGetLanguage(xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr,
const xmlChar**langList,
int len);
XMLPUBFUN int
xmlExpGetStart (xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr,
const xmlChar**tokList,
int len);
XMLPUBFUN xmlExpNodePtr
xmlExpStringDerive(xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr,
const xmlChar *str,
int len);
XMLPUBFUN xmlExpNodePtr
xmlExpExpDerive (xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr,
xmlExpNodePtr sub);
XMLPUBFUN int
xmlExpSubsume (xmlExpCtxtPtr ctxt,
xmlExpNodePtr expr,
xmlExpNodePtr sub);
XMLPUBFUN void
xmlExpDump (xmlBufferPtr buf,
xmlExpNodePtr expr);
/************************************************************************
* *
* Expression handling context *
@ -8008,6 +8116,7 @@ xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt) {
return(ctxt->nb_cons);
}
/** DOC_ENABLE */
#endif /* LIBXML_EXPR_ENABLED */
#endif /* LIBXML_REGEXP_ENABLED */