fixed panic mode

This commit is contained in:
ceriel 1988-06-22 18:47:48 +00:00
parent da943cec51
commit b72f2848dd

View file

@ -132,6 +132,7 @@ unsigned codegen(codep,ply,toplevel,costlimit,forced) byte *codep; unsigned cost
if (toplevel) paniced=0; if (toplevel) paniced=0;
savebp = nextem(toplevel); savebp = nextem(toplevel);
panic: panic:
if (toplevel) totalcost = 0;
bp = savebp; bp = savebp;
#endif #endif
if (bp == 0) { if (bp == 0) {
@ -168,18 +169,16 @@ unsigned codegen(codep,ply,toplevel,costlimit,forced) byte *codep; unsigned cost
if (Debug) if (Debug)
fprintf(stderr,"distance of pos %d is %u\n",i,dist); fprintf(stderr,"distance of pos %d is %u\n",i,dist);
#endif #endif
if (dist<=mindistance) { if (dist<=mindistance
#ifdef ALLOW_NEXTEM
|| paniced
#endif
) {
if (dist<mindistance) { if (dist<mindistance) {
if(dist==0) if(dist==0)
goto gotit; goto gotit;
#ifdef ALLOW_NEXTEM if (! paniced) npos=0;
if (! paniced) {
#endif
npos=0;
mindistance = dist; mindistance = dist;
#ifdef ALLOW_NEXTEM
}
#endif
} }
#ifdef ALLOW_NEXTEM #ifdef ALLOW_NEXTEM
if (dist < MAXINT) if (dist < MAXINT)
@ -261,7 +260,7 @@ if (Debug)
#ifdef MAXSPLIT #ifdef MAXSPLIT
int sret; int sret;
#endif #endif
int stackpad; int stackpad = 0;
struct perm *tup,*ntup,*besttup,*tuples(); struct perm *tup,*ntup,*besttup,*tuples();
DEBUG("MATCH"); DEBUG("MATCH");
@ -358,11 +357,16 @@ if(Debug>1) fprintf(stderr,"Pattern too long, %d with only %d items on stack\n",
myfree(regls[j]); myfree(regls[j]);
#ifndef ALLOW_NEXTEM #ifndef ALLOW_NEXTEM
assert(!toplevel); assert(!toplevel);
BROKE();
#else #else
assert(!(toplevel&&paniced)); assert(!(toplevel&&paniced));
if (paniced) goto normalfailed; if (paniced) goto normalfailed;
totalcost = INFINITY;
for (i=0;i<stackheight-stackpad;i++)
fakestack[i] = fakestack[i+stackpad];
stackheight -= stackpad;
goto doreturn;
#endif #endif
BROKE();
} }
if (cp->c3_prop<0) { if (cp->c3_prop<0) {
totalcost+=docoerc(tp,cp,ply,toplevel,0); totalcost+=docoerc(tp,cp,ply,toplevel,0);