1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

working on better error reporting of validity errors, especially providing

* error.c valid.c: working on better error reporting of validity
  errors, especially providing an accurate context.
* result/valid/xlink.xml.err result/valid/rss.xml.err: better
  error reports in those cases.
Daniel
This commit is contained in:
Daniel Veillard
2002-09-05 14:21:15 +00:00
parent 3487c8d9bb
commit 76575769f3
5 changed files with 51 additions and 22 deletions

31
error.c
View File

@ -350,22 +350,34 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserInputPtr input = NULL;
char * str;
int len = xmlStrlen((const xmlChar *) msg);
static int had_info = 0;
int need_context = 0;
int need_info = 0;
if (ctxt != NULL) {
input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2];
xmlParserPrintFileInfo(input);
if ((len > 1) && (msg[len - 2] != ':')) {
if (ctxt != NULL) {
input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2];
if (had_info == 0) {
xmlParserPrintFileInfo(input);
}
}
xmlGenericError(xmlGenericErrorContext, "validity error: ");
need_context = 1;
had_info = 0;
} else {
had_info = 1;
}
xmlGenericError(xmlGenericErrorContext, "validity error: ");
XML_GET_VAR_STR(msg, str);
xmlGenericError(xmlGenericErrorContext, "%s", str);
if (str != NULL)
xmlFree(str);
if (ctxt != NULL) {
if ((ctxt != NULL) && (input != NULL)) {
xmlParserPrintFileContext(input);
}
}
@ -385,8 +397,9 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserInputPtr input = NULL;
char * str;
int len = xmlStrlen((const xmlChar *) msg);
if (ctxt != NULL) {
if ((ctxt != NULL) && (len != 0) && (msg[len - 1] != ':')) {
input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2];