00697f6d21
Regen patches and switch to newer LIB_DEPENDS while here.
46 lines
1.1 KiB
Plaintext
46 lines
1.1 KiB
Plaintext
--- src/tools.c.orig Fri Aug 14 14:53:11 2009
|
|
+++ src/tools.c Sun Oct 24 10:56:43 2010
|
|
@@ -13,13 +13,42 @@ void _ntl_abort_cxx_callback(void)
|
|
}
|
|
|
|
|
|
+#include <cstdio>
|
|
+
|
|
NTL_START_IMPL
|
|
|
|
void (*ErrorCallback)() = 0;
|
|
|
|
|
|
+/*
|
|
+ The following code differs from vanilla NTL 5.4.2.
|
|
+
|
|
+ We add a SetErrorCallbackFunction(). This sets a global callback function _function_,
|
|
+ which gets called with parameter _context_ and an error message string whenever Error()
|
|
+ gets called.
|
|
+
|
|
+ Note that if the custom error handler *returns*, then NTL will dump the error message
|
|
+ back to stderr and abort() as it habitually does.
|
|
+
|
|
+ -- David Harvey (2008-04-12)
|
|
+*/
|
|
+
|
|
+void (*ErrorCallbackFunction)(const char*, void*) = NULL;
|
|
+void *ErrorCallbackContext = NULL;
|
|
+
|
|
+
|
|
+void SetErrorCallbackFunction(void (*function)(const char*, void*), void *context)
|
|
+{
|
|
+ ErrorCallbackFunction = function;
|
|
+ ErrorCallbackContext = context;
|
|
+}
|
|
+
|
|
+
|
|
void Error(const char *s)
|
|
{
|
|
+ if (ErrorCallbackFunction != NULL)
|
|
+ ErrorCallbackFunction(s, ErrorCallbackContext);
|
|
+
|
|
cerr << s << "\n";
|
|
_ntl_abort();
|
|
}
|