Skip to content

Commit

Permalink
Deprecate rather than remove call to xmlGetLastError()
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarring committed Jun 1, 2024
1 parent 7ff8e5b commit 266f3bf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 0 additions & 1 deletion lib/LibXML/InputCallback.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ method activate {

method deactivate {
for @!callbacks {
note "-";
warn "unable to remove input callbacks"
if xmlInputCallbacks::Pop() < 0;
}
Expand Down
22 changes: 19 additions & 3 deletions src/xml6_gbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ DLLEXPORT void xml6_gbl_os_thread_xml_free(void* obj) {
xmlFree(obj);
}

#ifdef XML6_GBL_COMPAT_OLD_ERRORS
struct _xml6HandlerSave {
void* serror_ctxt;
xmlStructuredErrorFunc serror_handler;
Expand All @@ -90,7 +89,26 @@ typedef struct _xml6HandlerSave xml6HandlerSave;
typedef xml6HandlerSave *xml6HandlerSavePtr;

DLLEXPORT xmlError* xml6_gbl_os_thread_get_last_error(void) {
#ifdef XML6_GBL_COMPAT_OLD_ERRORS
return &xmlLastError;
#else
static xmlError e_deprecated = {
XML_FROM_NONE, /* domain */
XML_ERR_INTERNAL_ERROR, /* code */
"xmlLastError() is deprecated", /* message */
XML_ERR_FATAL, /* level */
NULL, /* file */
0, /* line */
NULL, /* str1 */
NULL, /* str2 */
NULL, /* str3 */
0, /* int1 */
0, /* int2 */
NULL, /* ctxt */
NULL /* node */
};
return &e_deprecated;
#endif
}
DLLEXPORT void* xml6_gbl_save_error_handlers(void) {
xml6HandlerSavePtr save = (xml6HandlerSavePtr)xmlMalloc(sizeof(struct _xml6HandlerSave));
Expand Down Expand Up @@ -138,8 +156,6 @@ DLLEXPORT void xml6_gbl_set_generic_error_handler(xml6_gbl_MessageCallback callb
setter(ctx, handler);
}

#endif

static xmlSAXLocator _default_sax_locator = {
xmlSAX2GetPublicId,
xmlSAX2GetSystemId,
Expand Down
4 changes: 1 addition & 3 deletions src/xml6_gbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <libxml/globals.h>
#include <libxml/xmlversion.h>

#if LIBXML_VERSION < 21301
#if LIBXML_VERSION < 21300
# define XML6_GBL_COMPAT_OLD_ERRORS 1
#endif

Expand All @@ -23,13 +23,11 @@ DLLEXPORT void xml6_gbl_os_thread_set_keep_blanks(int flag);

DLLEXPORT void xml6_gbl_os_thread_xml_free(void*);

#ifdef XML6_GBL_COMPAT_OLD_ERRORS
typedef void (*xml6_gbl_MessageCallback) (const char *msg);
DLLEXPORT xmlError* xml6_gbl_os_thread_get_last_error(void);
DLLEXPORT void* xml6_gbl_save_error_handlers(void);
DLLEXPORT void xml6_gbl_restore_error_handlers(void*);
DLLEXPORT void xml6_gbl_set_generic_error_handler(xml6_gbl_MessageCallback, void (*route)(void*, xmlGenericErrorFunc));
#endif

DLLEXPORT xmlSAXLocatorPtr xml6_gbl_os_thread_get_default_sax_locator(void);

Expand Down

0 comments on commit 266f3bf

Please sign in to comment.