1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

Fix SetGenericErrorFunc and SetStructured clash

* include/libxml/globals.h globals.c global.data: define a new global
  variable (per thread) for structured error reporting, to not conflict
  with generic one
* error.c: when defined use the structured error report over any generic
  one
This commit is contained in:
Wang Lam
2009-08-24 17:34:25 +02:00
committed by Daniel Veillard
parent c78988acb7
commit 1de382eb06
4 changed files with 47 additions and 11 deletions

19
error.c
View File

@@ -132,7 +132,7 @@ xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
*/
void
xmlSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
xmlGenericErrorContext = ctx;
xmlStructuredErrorContext = ctx;
xmlStructuredError = handler;
}
@@ -471,7 +471,7 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
* if user has defined handler, change data ptr to user's choice
*/
if (schannel != NULL)
data = xmlGenericErrorContext;
data = xmlStructuredErrorContext;
}
if ((domain == XML_FROM_VALID) &&
((channel == xmlParserValidityError) ||
@@ -593,20 +593,23 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
/*
* Find the callback channel if channel param is NULL
*/
if ((ctxt != NULL) && (channel == NULL) && (xmlStructuredError == NULL) && (ctxt->sax != NULL)) {
if ((ctxt != NULL) && (channel == NULL) &&
(xmlStructuredError == NULL) && (ctxt->sax != NULL)) {
if (level == XML_ERR_WARNING)
channel = ctxt->sax->warning;
else
channel = ctxt->sax->error;
data = ctxt->userData;
} else if (channel == NULL) {
if ((schannel == NULL) && (xmlStructuredError != NULL))
if ((schannel == NULL) && (xmlStructuredError != NULL)) {
schannel = xmlStructuredError;
else
data = xmlStructuredErrorContext;
} else {
channel = xmlGenericError;
if (!data) {
data = xmlGenericErrorContext;
}
if (!data) {
data = xmlGenericErrorContext;
}
}
}
if (schannel != NULL) {
schannel(data, to);