[xml] (no subject)

Error processing is the stepchild of program design, so I can see why I am
having trouble dealing with this.

I am finding that libxml does not cooperate nicely in my transactional
environment where all errors need to be logged to managed location.

xmlGenericErrorDefaultFunc can be easily overridden but it is not the only
one doing printf's to stderr (as pointed out by Matt Sergeant) _plus_
xmlParserPrintFileContext sends one character at a time making a mess if
xmlGenericErrorDefaultFunc is turned into a logging facility.

I suggest taking xmlParserPrintFileContext (2.3.4) and doing the following:
[provided printf("%.*s", n, string) is widely portable]

xmlParserPrintFileContext(xmlParserInputPtr input) {
    const xmlChar *cur, *base;
    int n;

    if (input == NULL) return;
    cur = input->cur;
    base = input->base;
    while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
    n = 0;
    while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
    if ((*cur == '\n') || (*cur == '\r')) cur++;
    base = cur;
    n = 0;
    while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
/*         xmlGenericError(xmlGenericErrorContext, */
/*              "%c", (unsigned char) *cur++); */
        xmlGenericError(xmlGenericErrorContext,"%.*s\n", n, base);
/*     xmlGenericError(xmlGenericErrorContext, "\n"); */
    cur = input->cur;
    while ((*cur == '\n') || (*cur == '\r'))
    n = 0;
    while ((cur != base) && (n++ < 80)) {
/*         xmlGenericError(xmlGenericErrorContext, " "); */
    xmlGenericError(xmlGenericErrorContext,"%*s^\n", n, "");

Also, it would be nice if xmlGenericError were the final arbiter for
new-lines but in the mean time I can just clean them out before logging the

Sorry I didn't provide the change format that Matt supplied but I'm too new
to this process to know what tool creates that. I tried diff but it sure
looked ugly.

thanks for the xml work Daniel!

chuck griffith nwa com
ovid = cgriffi

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]