Skip to content

Commit fc74755

Browse files
author
t68
committed
Repaired an old bug concerning repeated use of special functions. Made Valgrind happy.
1 parent 76a32ab commit fc74755

3 files changed

Lines changed: 41 additions & 16 deletions

File tree

sources/proces.c

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,7 +2864,6 @@ WORD Generator(PHEAD WORD *term, WORD level)
28642864
#endif
28652865
oldtoprhs = CC->numrhs;
28662866
oldcpointer = CC->Pointer - CC->Buffer;
2867-
28682867
ReStart:
28692868
if ( ( replac = TestSub(BHEAD term,level) ) == 0 ) {
28702869
if ( applyflag ) { TableReset(); applyflag = 0; }
@@ -3458,18 +3457,40 @@ AutoGen: i = *AT.TMout;
34583457
if ( AN.TeInFun < 0 && !AN.TeSuOut ) {
34593458

34603459
if ( AR.TePos >= 0 ) goto AutoGen;
3461-
if ( AN.TeInFun == -1 && DoDistrib(BHEAD term,level) ) goto GenCall;
3462-
else if ( AN.TeInFun == -2 && DoDelta3(BHEAD term,level) ) goto GenCall;
3463-
else if ( AN.TeInFun == -3 && DoTableExpansion(term,level) ) goto GenCall;
3464-
else if ( AN.TeInFun == -4 && FactorIn(BHEAD term,level) ) goto GenCall;
3465-
else if ( AN.TeInFun == -5 && FactorInExpr(BHEAD term,level) ) goto GenCall;
3466-
else if ( AN.TeInFun == -6 && TermsInBracket(BHEAD term,level) < 0 ) goto GenCall;
3467-
else if ( AN.TeInFun == -7 && ExtraSymFun(BHEAD term,level) < 0 ) goto GenCall;
3468-
else if ( AN.TeInFun == -8 && GCDfunction(BHEAD term,level) < 0 ) goto GenCall;
3469-
else if ( AN.TeInFun == -9 && DIVfunction(BHEAD term,level,0) < 0 ) goto GenCall;
3470-
else if ( AN.TeInFun == -10 && DIVfunction(BHEAD term,level,1) < 0 ) goto GenCall;
3471-
else if ( AN.TeInFun == -11 ) {
3472-
if ( DIVfunction(BHEAD term,level,2) < 0 ) goto GenCall;
3460+
switch ( AN.TeInFun ) {
3461+
case -1:
3462+
if ( DoDistrib(BHEAD term,level) ) goto GenCall;
3463+
break;
3464+
case -2:
3465+
if ( DoDelta3(BHEAD term,level) ) goto GenCall;
3466+
break;
3467+
case -3:
3468+
if ( DoTableExpansion(term,level) ) goto GenCall;
3469+
break;
3470+
case -4:
3471+
if ( FactorIn(BHEAD term,level) ) goto GenCall;
3472+
break;
3473+
case -5:
3474+
if ( FactorInExpr(BHEAD term,level) ) goto GenCall;
3475+
break;
3476+
case -6:
3477+
if ( TermsInBracket(BHEAD term,level) < 0 ) goto GenCall;
3478+
break;
3479+
case -7:
3480+
if ( ExtraSymFun(BHEAD term,level) < 0 ) goto GenCall;
3481+
break;
3482+
case -8:
3483+
if ( GCDfunction(BHEAD term,level) < 0 ) goto GenCall;
3484+
break;
3485+
case -9:
3486+
if ( DIVfunction(BHEAD term,level,0) < 0 ) goto GenCall;
3487+
break;
3488+
case -10:
3489+
if ( DIVfunction(BHEAD term,level,1) < 0 ) goto GenCall;
3490+
break;
3491+
case -11:
3492+
if ( DIVfunction(BHEAD term,level,2) < 0 ) goto GenCall;
3493+
break;
34733494
}
34743495
}
34753496
else {

sources/reken.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ WORD DivLong(UWORD *a, WORD na, UWORD *b, WORD nb, UWORD *c,
11351135
}
11361136
else {
11371137
w2 = f+ni+ne; nh = ne+1;
1138-
while ( !*w2 && ( nh > 0 ) ) { nh--; w2--; }
1138+
while ( ( nh > 0 ) && !*w2 ) { nh--; w2--; }
11391139
}
11401140
if ( BigLong(f+ni,nh,e,ne) >= 0 ) {
11411141
estim++;
@@ -1207,7 +1207,7 @@ WORD DivLong(UWORD *a, WORD na, UWORD *b, WORD nb, UWORD *c,
12071207
}
12081208

12091209
/*
1210-
#] DivLong :
1210+
#] DivLong :
12111211
#[ RaisPow : WORD RaisPow(a,na,b)
12121212
12131213
Raises a to the power b. a is a Long integer and b >= 0.
@@ -2997,7 +2997,7 @@ int ChineseRemainder(PHEAD MODNUM *a1, MODNUM *a2, MODNUM *a)
29972997

29982998
/*
29992999
#] ChineseRemainder:
3000-
#] RekenLong :
3000+
#] RekenLong :
30013001
#[ RekenTerms :
30023002
#[ CompCoef : WORD CompCoef(term1,term2)
30033003

sources/sch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,16 +2153,20 @@ WORD WriteAll()
21532153
}
21542154
AO.PrintType = prtf;
21552155
if ( AC.OutputMode == VORTRANMODE ) {
2156+
UBYTE *oldOutFill = AO.OutFill, *oldOutputLine = AO.OutputLine;
21562157
AO.OutSkip = 6;
21572158
if ( Optimize(AO.termbuf[3]) ) goto AboWrite;
21582159
AO.OutSkip = 3;
2160+
AO.OutFill = oldOutFill; AO.OutputLine = oldOutputLine;
21592161
FiniLine();
21602162
continue;
21612163
}
21622164
else if ( AO.OptimizationLevel > 0 ) {
2165+
UBYTE *oldOutFill = AO.OutFill, *oldOutputLine = AO.OutputLine;
21632166
AO.OutSkip = 6;
21642167
if ( Optimize(AO.termbuf[3]) ) goto AboWrite;
21652168
AO.OutSkip = 3;
2169+
AO.OutFill = oldOutFill; AO.OutputLine = oldOutputLine;
21662170
FiniLine();
21672171
continue;
21682172
}

0 commit comments

Comments
 (0)