diff --git a/newrpl/lib-64-arithmetic.c b/newrpl/lib-64-arithmetic.c index 875bb91..79c07e7 100644 --- a/newrpl/lib-64-arithmetic.c +++ b/newrpl/lib-64-arithmetic.c @@ -1850,6 +1850,9 @@ void LIB_HANDLER() } rplDropData(1); + + WORDPTR *savestk=DSTop; // Drop arguments in case of error + if (n == 0) { rplPushData((WORDPTR)(one_bint)); int elements = 1; @@ -1858,6 +1861,9 @@ void LIB_HANDLER() rplDropData(elements); rplPushData(newmat); } + if(!newmat || Exceptions) { + if(DSTop>savestk) DSTop=savestk; + } return; } else if (n == 1) { @@ -1871,8 +1877,6 @@ void LIB_HANDLER() rplPushData((WORDPTR)(two_bint)); rplPushData((WORDPTR)(zero_bint)); break; -// default: -// break; } int elements = 2; WORDPTR newmat=rplMatrixCompose(0,elements); @@ -1880,6 +1884,9 @@ void LIB_HANDLER() rplDropData(elements); rplPushData(newmat); } + if(!newmat || Exceptions) { + if(DSTop>savestk) DSTop=savestk; + } return; } else { @@ -1908,11 +1915,7 @@ void LIB_HANDLER() rplOverwriteData(cur*(n+1)+1,(WORDPTR)(one_bint)); rplOverwriteData(oth*(n+1)+2,(WORDPTR)(two_bint)); break; -// default: -// break; } -// rplOverwriteData(cur*(n+1)+1,(WORDPTR)(one_bint)); // [ ... 0 0 1] -// rplOverwriteData(oth*(n+1)+2,(WORDPTR)(one_bint)); // [ ... 0 1 0] // recrsive formula rplNumberToRReg(2, (WORDPTR)(two_bint)); @@ -1953,7 +1956,10 @@ void LIB_HANDLER() rplCheckResultAndError(&RReg[4]); // next WORDPTR newnumber=rplNewReal(&RReg[4]); - if(!newnumber) return; + if(!newnumber || Exceptions) { + if(DSTop>savestk) DSTop=savestk; + return; + } rplOverwriteData(cur*(n+1)+j+1,newnumber); } @@ -1966,6 +1972,10 @@ void LIB_HANDLER() rplDropData(elements); rplPushData(newmat); } + else { + if(DSTop>savestk) DSTop=savestk; + return; + } } return;