[libntl] 09/12: a callback for sage

Julien Puydt julien.puydt at laposte.net
Thu Aug 28 08:42:49 UTC 2014


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository libntl.

commit 55fce221fee2063e886e2a1c516842b0fc738053
Author: Felix Salfelder <salfelder at em.cs.uni-frankfurt.de>
Date:   Thu Jan 26 21:34:21 2012 +0100

    a callback for sage
    
    (from sage-4.7.tar/spkg/ntl/dist/debian)
    
     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)
---
 include/NTL/tools.h |  6 ++++++
 src/tools.c         | 27 +++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/include/NTL/tools.h b/include/NTL/tools.h
index d79ea43..ca41173 100644
--- a/include/NTL/tools.h
+++ b/include/NTL/tools.h
@@ -310,6 +310,12 @@ long CharToIntVal(long c);
 char IntValToChar(long a);
 
 
+/*
+  This function is not present in vanilla NTL 5.4.2.
+  See tools.c for documentation.
+ */
+void SetErrorCallbackFunction(void (*func)(const char *s, void *context), void *context);
+
 
 void Error(const char *s);
 
diff --git a/src/tools.c b/src/tools.c
index 36c956b..f05f557 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -18,8 +18,35 @@ NTL_START_IMPL
 NTL_THREAD_LOCAL 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();
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/libntl.git



More information about the debian-science-commits mailing list