From 5b537ef7e2309859bccf7e8ad0cb3146bfcd6d59 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 9 May 2009 23:30:08 -0400 Subject: [PATCH] fix error handling. --- C/arith1.c | 10 ++++++++-- C/arith2.c | 14 +++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/C/arith1.c b/C/arith1.c index 97c577b32..3d7879a02 100644 --- a/C/arith1.c +++ b/C/arith1.c @@ -757,11 +757,15 @@ p_unary_is(void) if (top == 0L) return FALSE; if (IsIntTerm(t)) { - return Yap_unify_constant(ARG1,eval1(IntOfTerm(t), top)); + Term tout = eval1(IntegerOfTerm(t), top); + if (!tout) + return FALSE; + return Yap_unify_constant(ARG1,tout); } if (IsAtomTerm(t)) { Atom name = AtomOfTerm(t); ExpEntry *p; + Term out; if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 1)))) { Term ti[2]; @@ -776,7 +780,9 @@ p_unary_is(void) P = (yamop *)FAILCODE; return(FALSE); } - return Yap_unify_constant(ARG1,eval1(p->FOfEE, top)); + if (!(out=eval1(p->FOfEE, top))) + return FALSE; + return Yap_unify_constant(ARG1,out); } return(FALSE); } diff --git a/C/arith2.c b/C/arith2.c index 47d30327f..6b70195bb 100644 --- a/C/arith2.c +++ b/C/arith2.c @@ -636,6 +636,8 @@ p_exp(Term t1, Term t2) if (i2 < 0) { Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t2, "%d ^ %d", i1, i2); + P = (yamop *)FAILCODE; + RERROR(); } #ifdef USE_GMP /* two integers */ @@ -1227,11 +1229,15 @@ p_binary_is(void) if (t2 == 0L) return FALSE; if (IsIntTerm(t)) { - return Yap_unify_constant(ARG1,eval2(IntegerOfTerm(t), t1, t2)); + Term tout = eval2(IntegerOfTerm(t), t1, t2); + if (!tout) + return FALSE; + return Yap_unify_constant(ARG1,tout); } if (IsAtomTerm(t)) { Atom name = AtomOfTerm(t); ExpEntry *p; + Term out; if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 2)))) { Term ti[2]; @@ -1246,9 +1252,11 @@ p_binary_is(void) P = (yamop *)FAILCODE; return(FALSE); } - return Yap_unify_constant(ARG1,eval2(p->FOfEE, t1, t2)); + if (!(out=eval2(p->FOfEE, t1, t2))) + return FALSE; + return Yap_unify_constant(ARG1,out); } - return(FALSE); + return FALSE; } static Int