\
size = 150; \
\
- while (1) { \
+ while (size < 64000) { \
va_start(ap, msg); \
- chars = vsnprintf(str, size, msg, ap); \
+ chars = vsnprintf(str, size, msg, ap); \
va_end(ap); \
if ((chars > -1) && (chars < size)) { \
if (prev_size == chars) { \
}
/************************************************************************
- * *
- * Handling of out of context errors *
- * *
+ * *
+ * Handling of out of context errors *
+ * *
************************************************************************/
/**
* @ctx: an error context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Default handler for out of context error messages.
*/
void XMLCDECL
/**
* initGenericErrorDefaultFunc:
* @handler: the handler
- *
+ *
* Set or reset (if NULL) the default handler for generic errors
* to the builtin error function.
*/
*/
void
xmlSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
- xmlGenericErrorContext = ctx;
+ xmlStructuredErrorContext = ctx;
xmlStructuredError = handler;
}
/************************************************************************
- * *
- * Handling of parsing errors *
- * *
+ * *
+ * Handling of parsing errors *
+ * *
************************************************************************/
/**
* xmlParserPrintFileInfo:
* @input: an xmlParserInputPtr input
- *
+ *
* Displays the associated file and line informations for the current input
*/
/**
* xmlParserPrintFileContext:
* @input: an xmlParserInputPtr input
- *
+ *
* Displays current context within the input content for error tracking
*/
static void
-xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
+xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
xmlGenericErrorFunc channel, void *data ) {
const xmlChar *cur, *base;
unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */
xmlChar content[81]; /* space for 80 chars + line terminator */
xmlChar *ctnt;
- if (input == NULL) return;
+ if ((input == NULL) || (input->cur == NULL) ||
+ (*input->cur == 0)) return;
+
cur = input->cur;
base = input->base;
/* skip backwards over any end-of-lines */
}
n = 0;
/* search backwards for beginning-of-line (to max buff size) */
- while ((n++ < (sizeof(content)-1)) && (cur > base) &&
- (*(cur) != '\n') && (*(cur) != '\r'))
+ while ((n++ < (sizeof(content)-1)) && (cur > base) &&
+ (*(cur) != '\n') && (*(cur) != '\r'))
cur--;
if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
/* calculate the error position in terms of the current position */
n = 0;
ctnt = content;
/* copy selected text to our buffer */
- while ((*cur != 0) && (*(cur) != '\n') &&
- (*(cur) != '\r') && (n < sizeof(content)-1)) {
+ while ((*cur != 0) && (*(cur) != '\n') &&
+ (*(cur) != '\r') && (n < sizeof(content)-1)) {
*ctnt++ = *cur++;
n++;
}
/**
* xmlParserPrintFileContext:
* @input: an xmlParserInputPtr input
- *
+ *
* Displays current context within the input content for error tracking
*/
void
} else {
if (file != NULL)
channel(data, "%s:%d: ", file, line);
- else if ((line != 0) && (domain == XML_FROM_PARSER))
+ else if ((line != 0) &&
+ ((domain == XML_FROM_PARSER) || (domain == XML_FROM_SCHEMASV)||
+ (domain == XML_FROM_SCHEMASP)||(domain == XML_FROM_DTD) ||
+ (domain == XML_FROM_RELAXNGP)||(domain == XML_FROM_RELAXNGV)))
channel(data, "Entity: line %d: ", line);
}
if (name != NULL) {
case XML_FROM_I18N:
channel(data, "encoding ");
break;
+ case XML_FROM_SCHEMATRONV:
+ channel(data, "schematron ");
+ break;
+ case XML_FROM_BUFFER:
+ channel(data, "internal buffer ");
+ break;
+ case XML_FROM_URI:
+ channel(data, "URI ");
+ break;
default:
break;
}
* @str2: extra string info
* @str3: extra string info
* @int1: extra int info
- * @col: column number of the error or 0 if N/A
+ * @col: column number of the error or 0 if N/A
* @msg: the message to display/transmit
* @...: extra parameters for the message display
*
xmlErrorPtr to = &xmlLastError;
xmlNodePtr baseptr = NULL;
+ if (code == XML_ERR_OK)
+ return;
if ((xmlGetWarningsDefaultValue == 0) && (level == XML_ERR_WARNING))
return;
if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) ||
(domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) {
ctxt = (xmlParserCtxtPtr) ctx;
if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
- (ctxt->sax->initialized == XML_SAX2_MAGIC))
+ (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
+ (ctxt->sax->serror != NULL)) {
schannel = ctxt->sax->serror;
+ data = ctxt->userData;
+ }
}
/*
* Check if structured error handler set
* 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) ||
- (channel == xmlParserValidityWarning))) {
- ctxt = (xmlParserCtxtPtr) ctx;
- if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
- (ctxt->sax->initialized == XML_SAX2_MAGIC))
- schannel = ctxt->sax->serror;
- }
- if (code == XML_ERR_OK)
- return;
/*
* Formatting the message
*/
if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
line = node->line;
+ if ((line == 0) || (line == 65535))
+ line = xmlGetLineNo(node);
}
/*
if ((to->file == NULL) && (node != NULL) && (node->doc != NULL)) {
to->file = (char *) xmlStrdup(node->doc->URL);
}
- file = to->file;
}
to->line = line;
if (str1 != NULL)
if (to != &xmlLastError)
xmlCopyError(to,&xmlLastError);
+ if (schannel != NULL) {
+ schannel(data, to);
+ return;
+ }
+
/*
* 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 (xmlStructuredError != NULL)
- schannel = xmlStructuredError;
- else
- channel = xmlGenericError;
- if (!data) {
- data = xmlGenericErrorContext;
- }
- }
- if (schannel != NULL) {
- schannel(data, to);
- return;
+ channel = xmlGenericError;
+ if (ctxt != NULL) {
+ data = ctxt;
+ } else {
+ data = xmlGenericErrorContext;
+ }
}
if (channel == NULL)
return;
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format an error messages, gives file, line, position and
* extra parameters.
*/
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format a warning messages, gives file, line, position and
* extra parameters.
*/
}
xmlParserPrintFileInfo(input);
}
-
+
xmlGenericError(xmlGenericErrorContext, "warning: ");
XML_GET_VAR_STR(msg, str);
xmlGenericError(xmlGenericErrorContext, "%s", str);
}
/************************************************************************
- * *
- * Handling of validation errors *
- * *
+ * *
+ * Handling of validation errors *
+ * *
************************************************************************/
/**
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format an validity error messages, gives file,
* line, position and extra parameters.
*/
input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2];
-
+
if (had_info == 0) {
xmlParserPrintFileInfo(input);
}
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format a validity warning messages, gives file, line,
* position and extra parameters.
*/
xmlParserPrintFileInfo(input);
}
-
+
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
XML_GET_VAR_STR(msg, str);
xmlGenericError(xmlGenericErrorContext, "%s", str);
if (ctxt == NULL)
return;
+ ctxt->errNo = XML_ERR_OK;
if (ctxt->lastError.code == XML_ERR_OK)
return;
xmlResetError(&ctxt->lastError);