Skip to content

Commit

Permalink
Resolved crashesin issue #122, but does not generate everything.
Browse files Browse the repository at this point in the history
  • Loading branch information
vermaseren committed Oct 15, 2016
1 parent b67536f commit 4ccfeba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion sources/function.c
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,7 @@ WORD ScanFunctions(PHEAD WORD *inpat, WORD *inter, WORD par)
int ntwa = AN.NumTotWildArgs;
LONG oldcpointer = C->Pointer - C->Buffer;
WORD oldSignCheck = AN.SignCheck;
AT.FunDepth++;
instart = inter;
/*
Only active for the last function in the pattern.
Expand Down Expand Up @@ -1885,13 +1886,15 @@ trythis:;
Failure:
AN.SignCheck = oldSignCheck;
AT.WorkPointer = OldWork;
AT.FunDepth--;
return(0);
OnSuccess:
if ( AT.idallflag ) {
if ( AT.idallflag && AT.FunDepth <= 1 ) {
if ( AT.idallmaxnum > 0 && AT.idallnum >= AT.idallmaxnum ) {
AN.terfirstcomm = Oterfirstcomm;
AN.SignCheck = oldSignCheck;
AT.WorkPointer = OldWork;
AT.FunDepth--;
return(0);
}
SubsInAll(BHEAD0);
Expand Down Expand Up @@ -1941,6 +1944,7 @@ NextFor:;
}
doesmatch:
AT.WorkPointer = OldWork;
AT.FunDepth--;
return(1);
}

Expand Down
8 changes: 7 additions & 1 deletion sources/pattern.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ WORD TestMatch(PHEAD WORD *term, WORD *level)
GETBIDENTITY
WORD *ll, *m, *w, *llf, *OldWork, *StartWork, *ww, *mm, *t, *OldTermBuffer = 0;
WORD power = 0, match = 0, i, msign = 0, ll2;
int numdollars = 0, protosize, oldallnumrhs;
int numdollars = 0, protosize, oldallnumrhs, oldFunDepth;
CBUF *C = cbuf+AM.rbufnum, *CC;
AT.idallflag = 0;
do {
Expand Down Expand Up @@ -330,6 +330,7 @@ WORD TestMatch(PHEAD WORD *term, WORD *level)
}
AN.DisOrderFlag = ll2 & SUBDISORDER;
AN.nogroundlevel = 0;
oldFunDepth = AT.FunDepth;
switch ( ll2 & SUBMASK ) {
case SUBONLY :
/* Must be an exact match */
Expand Down Expand Up @@ -364,6 +365,7 @@ WORD TestMatch(PHEAD WORD *term, WORD *level)
MLOCK(ErrorMessageLock);
MesWork();
MUNLOCK(ErrorMessageLock);
AT.FunDepth = oldFunDepth;
return(-1);
}
/*
Expand Down Expand Up @@ -397,6 +399,7 @@ WORD TestMatch(PHEAD WORD *term, WORD *level)
MLOCK(ErrorMessageLock);
MesWork();
MUNLOCK(ErrorMessageLock);
AT.FunDepth = oldFunDepth;
return(-1);
}
/*
Expand Down Expand Up @@ -430,6 +433,7 @@ WORD TestMatch(PHEAD WORD *term, WORD *level)
MLOCK(ErrorMessageLock);
MesWork();
MUNLOCK(ErrorMessageLock);
AT.FunDepth = oldFunDepth;
return(-1);
}
/*
Expand Down Expand Up @@ -597,6 +601,7 @@ WORD TestMatch(PHEAD WORD *term, WORD *level)
AT.idallflag = 0;
CC->Pointer[0] = 0;
TransferBuffer(AT.aebufnum,AT.ebufnum,AT.allbufnum);
AT.FunDepth = oldFunDepth;
return(1);
}
AT.idallflag = 0;
Expand Down Expand Up @@ -629,6 +634,7 @@ nextlevel:;
} while ( (*level)++ < AR.Cnumlhs && C->lhs[*level][0] == TYPEIDOLD );
(*level)--;
AT.WorkPointer = AN.RepFunList;
AT.FunDepth = oldFunDepth;
return(match);
}

Expand Down
7 changes: 4 additions & 3 deletions sources/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1978,6 +1978,7 @@ struct T_const {
int numpoly;
int LeaveNegative;
int TrimPower; /* Indicates trimming in polyratfun expansion */
int FunDepth; /* Depth in pattern matching */
WORD small_power_maxx; /* size of the cache for small powers */
WORD small_power_maxn; /* size of the cache for small powers */
WORD dummysubexp[SUBEXPSIZE+4]; /* () used in normal.c */
Expand Down Expand Up @@ -2005,12 +2006,12 @@ struct T_const {
WORD fromindex; /* Tells the compare routine whether call from index */
#ifdef WITHPTHREADS
#ifdef WITHSORTBOTS
PADPOINTER(4,25,100+SUBEXPSIZE*4+FUNHEAD*2+ARGHEAD*2,0);
PADPOINTER(4,26,100+SUBEXPSIZE*4+FUNHEAD*2+ARGHEAD*2,0);
#else
PADPOINTER(4,23,100+SUBEXPSIZE*4+FUNHEAD*2+ARGHEAD*2,0);
PADPOINTER(4,24,100+SUBEXPSIZE*4+FUNHEAD*2+ARGHEAD*2,0);
#endif
#else
PADPOINTER(4,21,100+SUBEXPSIZE*4+FUNHEAD*2+ARGHEAD*2,0);
PADPOINTER(4,22,100+SUBEXPSIZE*4+FUNHEAD*2+ARGHEAD*2,0);
#endif
};
/*
Expand Down

0 comments on commit 4ccfeba

Please sign in to comment.