From 20c6b50a0dfc423fd680944032094029757b6916 Mon Sep 17 00:00:00 2001 From: vsc Date: Fri, 1 Feb 2002 15:48:17 +0000 Subject: [PATCH] fix error after error and error within error git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@344 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/arrays.c | 9 +++++++-- C/errors.c | 23 ++++++++++++++++++++--- C/exec.c | 1 + C/init.c | 2 -- H/Regs.h | 4 ++-- changes4.3.html | 2 ++ 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/C/arrays.c b/C/arrays.c index 07079a642..10fd51115 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -160,7 +160,7 @@ AccessNamedArray(Atom a, Int indx) READ_LOCK(pp->ArRWLock); if (IsVarTerm(pp->ValueOfVE)) { READ_UNLOCK(pp->ArRWLock); - return(FALSE); + return(MkAtomTerm(AtomFoundVar)); } out = RepAppl(pp->ValueOfVE)[indx+1]; READ_UNLOCK(pp->ArRWLock); @@ -310,6 +310,9 @@ p_access_array(void) tf = (RepAppl(t))[indx + 1]; } else if (IsAtomTerm(t)) { tf = AccessNamedArray(AtomOfTerm(t), indx); + if (tf == MkAtomTerm(AtomFoundVar)) { + return(FALSE); + } } else { Error(TYPE_ERROR_ARRAY,t,"access_array"); return(FALSE); @@ -350,7 +353,9 @@ p_array_arg(void) } else if (IsAtomTerm(t)) { Term tf = AccessNamedArray(AtomOfTerm(t), indx); - + if (tf == MkAtomTerm(AtomFoundVar)) { + return(FALSE); + } return (unify(tf, ARG1)); } else diff --git a/C/errors.c b/C/errors.c index bce1891ef..633af2df9 100644 --- a/C/errors.c +++ b/C/errors.c @@ -313,9 +313,26 @@ Error (yap_error_number type, Term where, char *format,...) char *tp = p; int psize = 512; - /* disallow recursive error handling */ - if (PrologMode & InErrorMode) - return(P); + /* disallow recursive error handling */ + if (PrologMode & InErrorMode) { + /* error within error */ + va_start (ap, format); + /* now build the error string */ + if (format != NULL) { +#if HAVE_VSNPRINTF + (void) vsnprintf(p, 512, format, ap); +#else + (void) vsprintf(p, format, ap); +#endif + } else { + p[0] = '\0'; + } + va_end (ap); + fprintf(stderr,"[ ERROR WITHIN ERROR: %s ]\n", p); + exit(1); + } + if (P == FAILCODE) + return(P); /* PURE_ABORT may not have set where correctly */ if (type == PURE_ABORT) where = TermNil; diff --git a/C/exec.c b/C/exec.c index 15e6af8f8..ee68f2697 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1278,6 +1278,7 @@ JumpToEnv(Term t) { /* I could backtrack here, but it is easier to leave the unwinding to the emulator */ B->cp_a3 = t; + P = FAILCODE; return(FALSE); } diff --git a/C/init.c b/C/init.c index a6c8269d9..070bc71b0 100644 --- a/C/init.c +++ b/C/init.c @@ -1188,8 +1188,6 @@ InitStacks(int Heap, ReleaseAtom(AtomFoundVar); LookupAtomWithAddress("[]",&(SF_STORE->AtNil)); LookupAtomWithAddress(".",&(SF_STORE->AtDot)); - PutValue(LookupAtom("$catch_counter"), - MkIntTerm(0)); /* InitAbsmi must be done before InitCodes */ #ifdef MPW InitAbsmi(REGS, FunctorList); diff --git a/H/Regs.h b/H/Regs.h index 5e17c077b..285bf9004 100644 --- a/H/Regs.h +++ b/H/Regs.h @@ -10,7 +10,7 @@ * File: Regs.h * * mods: * * comments: YAP abstract machine registers * -* version: $Id: Regs.h,v 1.11 2002-01-14 22:26:51 vsc Exp $ * +* version: $Id: Regs.h,v 1.12 2002-02-01 15:48:17 vsc Exp $ * *************************************************************************/ @@ -336,7 +336,7 @@ EXTERN inline void restore_TR(void) { TR = REGS.TR_; } -#elif defined(__GNUC__) && defined(mips) +#elif defined(__GNUC__) && defined(mips) && defined(VSC_UNDEFINED) #define P REGS.P_ /* prolog machine program counter */ #define YENV REGS.YENV_ /* current environment (may differ from ENV) */ diff --git a/changes4.3.html b/changes4.3.html index 1ee2da8a5..402552488 100644 --- a/changes4.3.html +++ b/changes4.3.html @@ -16,6 +16,8 @@

Yap-4.3.21: