From 3de5b2c2def8d91c4613f48be23ab594c53266ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Sun, 31 Jan 2016 11:54:45 +0000 Subject: [PATCH] error_handling --- C/ *Minibuf-7* | 1 - C/atomic.c | 2 +- C/errors.c | 22 +++++++++++----------- H/Yapproto.h | 3 ++- 4 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 C/ *Minibuf-7* diff --git a/C/ *Minibuf-7* b/C/ *Minibuf-7* deleted file mode 100644 index d8eacd145..000000000 --- a/C/ *Minibuf-7* +++ /dev/null @@ -1 +0,0 @@ -M-x \ No newline at end of file diff --git a/C/atomic.c b/C/atomic.c index 1897b79b9..429939f83 100644 --- a/C/atomic.c +++ b/C/atomic.c @@ -1100,7 +1100,7 @@ atom_concat2( USES_REGS1 ) error: /* Error handling */ if (LOCAL_Error_TYPE) { - if (Yap_HandleError( "string_code/3" )) { + if (Yap_HandleError( "atom_concat/2" )) { goto restart_aux; } else { return FALSE; diff --git a/C/errors.c b/C/errors.c index 01ff957c9..63ec1424e 100755 --- a/C/errors.c +++ b/C/errors.c @@ -163,7 +163,7 @@ bool Yap_PrintWarning(Term twarning) { return rc; } -int Yap_HandleError(const char *s, ...) { +bool Yap_HandleError__(const char *file, const char *function, int lineno, const char *s, ...) { CACHE_REGS yap_error_number err = LOCAL_Error_TYPE; const char *serr; @@ -177,28 +177,28 @@ int Yap_HandleError(const char *s, ...) { switch (err) { case RESOURCE_ERROR_STACK: if (!Yap_gc(2, ENV, gc_P(P, CP))) { - Yap_Error(RESOURCE_ERROR_STACK, ARG1, serr); - return (FALSE); + Yap_Error__(file, function, lineno, RESOURCE_ERROR_STACK, ARG1, serr); + return false; } - return TRUE; + return true; case RESOURCE_ERROR_AUXILIARY_STACK: if (LOCAL_MAX_SIZE < (char *)AuxSp - AuxBase) { LOCAL_MAX_SIZE += 1024; } if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { /* crash in flames */ - Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, serr); - return FALSE; + Yap_Error__(file, function, lineno, RESOURCE_ERROR_AUXILIARY_STACK, ARG1, serr); + return false; } - return TRUE; + return true; case RESOURCE_ERROR_HEAP: if (!Yap_growheap(FALSE, 0, NULL)) { - Yap_Error(RESOURCE_ERROR_HEAP, ARG2, serr); - return FALSE; + Yap_Error__(file, function, lineno, RESOURCE_ERROR_HEAP, ARG2, serr); + return false; } default: - Yap_Error(err, LOCAL_Error_Term, serr); - return (FALSE); + Yap_Error__(file, function, lineno, err, LOCAL_Error_Term, serr); + return false; } } diff --git a/H/Yapproto.h b/H/Yapproto.h index 773d7c78b..6a6175ba3 100755 --- a/H/Yapproto.h +++ b/H/Yapproto.h @@ -176,7 +176,8 @@ void Yap_RestartYap(int); void Yap_exit(int); bool Yap_Warning(const char *s, ...); bool Yap_PrintWarning(Term t); -int Yap_HandleError(const char *msg, ...); +bool Yap_HandleError__(const char *file, const char *function, int lineno, const char *s, ...); +#define Yap_HandleError(...) Yap_HandleError__(__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) int Yap_SWIHandleError(const char *, ...); void Yap_InitErrorPreds(void);