1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-19 14:50:07 +03:00

error: Convert initGenericErrorDefaultFunc to macro

This commit is contained in:
Nick Wellnhofer 2025-03-04 13:15:42 +01:00
parent c42b32277d
commit 3250a01dc2
4 changed files with 9 additions and 63 deletions

View File

@ -1907,6 +1907,7 @@
<summary>error handling</summary>
<description>the API used to report errors </description>
<author>Daniel Veillard </author>
<exports symbol='initGenericErrorDefaultFunc' type='macro'/>
<exports symbol='XML_BUF_OVERFLOW' type='enum'/>
<exports symbol='XML_C14N_CREATE_CTXT' type='enum'/>
<exports symbol='XML_C14N_CREATE_STACK' type='enum'/>
@ -2691,7 +2692,6 @@
<exports symbol='xmlErrorPtr' type='typedef'/>
<exports symbol='xmlParserErrors' type='typedef'/>
<exports symbol='_xmlError' type='struct'/>
<exports symbol='initGenericErrorDefaultFunc' type='function'/>
<exports symbol='xmlCopyError' type='function'/>
<exports symbol='xmlCtxtGetLastError' type='function'/>
<exports symbol='xmlCtxtResetLastError' type='function'/>
@ -4315,6 +4315,8 @@
<info>Returns the attributes required for the specified element.</info>
<arg name='elt' info='HTML element'/>
</macro>
<macro name='initGenericErrorDefaultFunc' file='xmlerror'>
</macro>
<macro name='inputPop' file='parserInternals'>
</macro>
<macro name='inputPush' file='parserInternals'>
@ -7412,11 +7414,6 @@ crash if you try to modify the tree)'/>
<arg name='ch' type='const xmlChar *' info='a xmlChar string'/>
<arg name='len' type='int' info='the number of xmlChar'/>
</functype>
<function name='initGenericErrorDefaultFunc' file='xmlerror' module='error'>
<info>DEPRECATED: Use xmlSetGenericErrorFunc. Set or reset (if NULL) the default handler for generic errors to the builtin error function.</info>
<return type='void'/>
<arg name='handler' type='xmlGenericErrorFunc *' info='the handler'/>
</function>
<functype name='internalSubsetSAXFunc' file='parser' module='parser'>
<info>Callback on internal subset declaration.</info>
<return type='void'/>

18
error.c
View File

@ -234,24 +234,6 @@ xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
va_end(args);
}
/**
* initGenericErrorDefaultFunc:
* @handler: the handler
*
* DEPRECATED: Use xmlSetGenericErrorFunc.
*
* Set or reset (if NULL) the default handler for generic errors
* to the builtin error function.
*/
void
initGenericErrorDefaultFunc(xmlGenericErrorFunc * handler)
{
if (handler == NULL)
xmlGenericError = xmlGenericErrorDefaultFunc;
else
xmlGenericError = (*handler);
}
/**
* xmlSetGenericErrorFunc:
* @ctx: the new error handling context

View File

@ -16,6 +16,11 @@
extern "C" {
#endif
/*
* Backward compatibility
*/
#define initGenericErrorDefaultFunc(h) xmlSetGenericErrorFunc(NULL, h)
/**
* xmlErrorLevel:
*
@ -904,9 +909,6 @@ XML_DEPRECATED
XMLPUBFUN void
xmlThrDefSetGenericErrorFunc(void *ctx,
xmlGenericErrorFunc handler);
XML_DEPRECATED
XMLPUBFUN void
initGenericErrorDefaultFunc (xmlGenericErrorFunc *handler);
XMLPUBFUN void
xmlSetStructuredErrorFunc (void *ctx,

View File

@ -29885,40 +29885,6 @@ test_xmlautomata(void) {
return(test_ret);
}
#define gen_nb_xmlGenericErrorFunc_ptr 1
#define gen_xmlGenericErrorFunc_ptr(no, nr) NULL
#define des_xmlGenericErrorFunc_ptr(no, val, nr)
static int
test_initGenericErrorDefaultFunc(void) {
int test_ret = 0;
int mem_base;
xmlGenericErrorFunc * handler; /* the handler */
int n_handler;
for (n_handler = 0;n_handler < gen_nb_xmlGenericErrorFunc_ptr;n_handler++) {
mem_base = xmlMemBlocks();
handler = gen_xmlGenericErrorFunc_ptr(n_handler, 0);
initGenericErrorDefaultFunc(handler);
call_tests++;
des_xmlGenericErrorFunc_ptr(n_handler, handler, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in initGenericErrorDefaultFunc",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_handler);
printf("\n");
}
}
function_tests++;
return(test_ret);
}
#define gen_nb_const_xmlError_ptr 1
#define gen_const_xmlError_ptr(no, nr) NULL
#define des_const_xmlError_ptr(no, val, nr)
@ -30214,8 +30180,7 @@ static int
test_xmlerror(void) {
int test_ret = 0;
if (quiet == 0) printf("Testing xmlerror : 7 of 18 functions ...\n");
test_ret += test_initGenericErrorDefaultFunc();
if (quiet == 0) printf("Testing xmlerror : 6 of 17 functions ...\n");
test_ret += test_xmlCopyError();
test_ret += test_xmlCtxtGetLastError();
test_ret += test_xmlCtxtResetLastError();