1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00

parser: implement xmlCtxtGetOptions

In 712a31ab, the `options` struct member was deprecated. To allow
callers to check the status of options bits, introduce
xmlCtxtGetOptions.
This commit is contained in:
Mike Dalessio 2024-06-20 03:19:48 -04:00 committed by Nick Wellnhofer
parent a4517bfeaf
commit bbbbbb4649
4 changed files with 61 additions and 1 deletions

View File

@ -665,6 +665,7 @@
<exports symbol='xmlCreateDocParserCtxt' type='function'/> <exports symbol='xmlCreateDocParserCtxt' type='function'/>
<exports symbol='xmlCreateIOParserCtxt' type='function'/> <exports symbol='xmlCreateIOParserCtxt' type='function'/>
<exports symbol='xmlCreatePushParserCtxt' type='function'/> <exports symbol='xmlCreatePushParserCtxt' type='function'/>
<exports symbol='xmlCtxtGetOptions' type='function'/>
<exports symbol='xmlCtxtParseDocument' type='function'/> <exports symbol='xmlCtxtParseDocument' type='function'/>
<exports symbol='xmlCtxtReadDoc' type='function'/> <exports symbol='xmlCtxtReadDoc' type='function'/>
<exports symbol='xmlCtxtReadFd' type='function'/> <exports symbol='xmlCtxtReadFd' type='function'/>
@ -8586,6 +8587,11 @@ crash if you try to modify the tree)'/>
<return type='const xmlError *' info='NULL if no error occurred or a pointer to the error'/> <return type='const xmlError *' info='NULL if no error occurred or a pointer to the error'/>
<arg name='ctx' type='void *' info='an XML parser context'/> <arg name='ctx' type='void *' info='an XML parser context'/>
</function> </function>
<function name='xmlCtxtGetOptions' file='parser' module='parser'>
<info>Get the current options of the parser context. Available since 2.14.0.</info>
<return type='int' info='the current options set in the parser context.'/>
<arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
</function>
<function name='xmlCtxtParseDocument' file='parser' module='parser'> <function name='xmlCtxtParseDocument' file='parser' module='parser'>
<info>Parse an XML document and return the resulting document tree. Takes ownership of the input object. Available since 2.13.0.</info> <info>Parse an XML document and return the resulting document tree. Takes ownership of the input object. Available since 2.13.0.</info>
<return type='xmlDocPtr' info='the resulting document tree or NULL'/> <return type='xmlDocPtr' info='the resulting document tree or NULL'/>

View File

@ -1402,6 +1402,8 @@ XMLPUBFUN int
XMLPUBFUN int XMLPUBFUN int
xmlCtxtSetOptions (xmlParserCtxtPtr ctxt, xmlCtxtSetOptions (xmlParserCtxtPtr ctxt,
int options); int options);
XMLPUBFUN int
xmlCtxtGetOptions (xmlParserCtxtPtr ctxt);
XMLPUBFUN int XMLPUBFUN int
xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
int options); int options);

View File

@ -13594,6 +13594,25 @@ xmlCtxtSetOptions(xmlParserCtxtPtr ctxt, int options)
return(xmlCtxtSetOptionsInternal(ctxt, options, 0)); return(xmlCtxtSetOptionsInternal(ctxt, options, 0));
} }
/**
* xmlCtxtGetOptions:
* @ctxt: an XML parser context
*
* Get the current options of the parser context.
*
* Available since 2.14.0.
*
* Returns the current options set in the parser context, or -1 if ctxt is NULL.
*/
int
xmlCtxtGetOptions(xmlParserCtxtPtr ctxt)
{
if (ctxt == NULL)
return(-1);
return(ctxt->options);
}
/** /**
* xmlCtxtUseOptions: * xmlCtxtUseOptions:
* @ctxt: an XML parser context * @ctxt: an XML parser context

View File

@ -11820,6 +11820,38 @@ test_xmlCreatePushParserCtxt(void) {
} }
static int
test_xmlCtxtGetOptions(void) {
int test_ret = 0;
int mem_base;
int ret_val;
xmlParserCtxtPtr ctxt; /* an XML parser context */
int n_ctxt;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
ret_val = xmlCtxtGetOptions(ctxt);
desret_int(ret_val);
call_tests++;
des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlCtxtGetOptions",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf("\n");
}
}
function_tests++;
return(test_ret);
}
static int static int
test_xmlCtxtParseDocument(void) { test_xmlCtxtParseDocument(void) {
int test_ret = 0; int test_ret = 0;
@ -14721,13 +14753,14 @@ static int
test_parser(void) { test_parser(void) {
int test_ret = 0; int test_ret = 0;
if (quiet == 0) printf("Testing parser : 71 of 83 functions ...\n"); if (quiet == 0) printf("Testing parser : 72 of 84 functions ...\n");
test_ret += test_xmlByteConsumed(); test_ret += test_xmlByteConsumed();
test_ret += test_xmlCleanupGlobals(); test_ret += test_xmlCleanupGlobals();
test_ret += test_xmlClearNodeInfoSeq(); test_ret += test_xmlClearNodeInfoSeq();
test_ret += test_xmlClearParserCtxt(); test_ret += test_xmlClearParserCtxt();
test_ret += test_xmlCreateDocParserCtxt(); test_ret += test_xmlCreateDocParserCtxt();
test_ret += test_xmlCreatePushParserCtxt(); test_ret += test_xmlCreatePushParserCtxt();
test_ret += test_xmlCtxtGetOptions();
test_ret += test_xmlCtxtParseDocument(); test_ret += test_xmlCtxtParseDocument();
test_ret += test_xmlCtxtReadDoc(); test_ret += test_xmlCtxtReadDoc();
test_ret += test_xmlCtxtReadFile(); test_ret += test_xmlCtxtReadFile();