X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=gacela_misc.lisp;h=d9f38daa5ef4aedafbc7c3f8dfc1498db1efb560;hb=978e906d4f01dcc3dd386e4b0d2fa32564ecc83c;hp=8a7c2e433242b551ee3fbc6c2c229d142aaf436a;hpb=6b5631c92ca29a80af99d228b3fe346c5b5e8eee;p=gacela.git diff --git a/gacela_misc.lisp b/gacela_misc.lisp index 8a7c2e4..d9f38da 100755 --- a/gacela_misc.lisp +++ b/gacela_misc.lisp @@ -14,7 +14,6 @@ ;;; You should have received a copy of the GNU General Public License ;;; along with this program. If not, see . - (in-package :gacela) (defconstant INFINITY MOST-POSITIVE-LONG-FLOAT) @@ -69,6 +68,18 @@ (t (power (* p 2) n))))) (power 1 n))) +(defmacro secured-eval (form &optional output-stream) + (let ((error-handler #'si::universal-error-handler)) + `(block secure + (defun si::universal-error-handler (error-name correctable function-name continue-format-string error-format-string &rest args) + ,(when output-stream `(format ,output-stream error-format-string)) + (setf (symbol-function 'si::universal-error-handler) ,error-handler) + (return-from secure)) + (let (result-eval) + (setq result-eval (eval ,form)) + (setf (symbol-function 'si::universal-error-handler) ,error-handler) + result-eval)))) + ;Geometry (defun dotp (dot) (match-pattern dot '(0 0)))