[xml] xmlSetGenericErrorFunc

Date view Thread view Subject view Author view

From: Leo Davidson (leo@ox.compsoc.net)
Date: Sun Nov 19 2000 - 14:40:21 EST


(Apologies if this has changed in 2.2.8 as I am still working with 2.2.7 at
the moment.)

Just a quick comment on xmlSetGenericErrorFunc: Since it ignores any NULL
arguments (ctx or handler), there's (a) no way to specify a NULL ctx if
that's what you really want and (b) no way to revert back to the default
handling.

(a) Could be important if your error handler optionally uses ctx but
requires it NULL at other times. (I guess you could have two separate
handler functions, one which ignores ctx... but why is setting ctx to NULL
bad or any different to setting it to any other value?)

(b) Can be worked around by calling
        xmlSetGenericErrorFunc(stderr, xmlGenericErrorDefaultFunc)
but that assumes that the default won't ever change.

Why not change xmlSetGenericErrorFunc to:

void
xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler)
{
        // Always set ctx as requested.
        xmlGenericErrorContext = ctx;

        // Set handler as requested, or restore default if NULL.
        if (handler != NULL)
                xmlGenericError = handler;
        else
                xmlGenericError = xmlGenericErrorDefaultFunc;
}

Of course, this assumes that if handler is NULL then either ctx is also NULL
or the caller has set ctx to a FILE*. If that assumption doesn't hold then
the default handler will crash.

Sorry if this is a stupid idea!

        Leo

--

---- Message from the list xml@rpmfind.net Archived at : http://xmlsoft.org/messages/ to unsubscribe: echo "unsubscribe xml" | mail majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sun Nov 19 2000 - 14:44:20 EST