Skip to content

Commit 079398e

Browse files
author
t68
committed
The version as released on 27-aug-2010 as open source
1 parent 3f0382b commit 079398e

File tree

17 files changed

+386
-226
lines changed

17 files changed

+386
-226
lines changed

sources/argument.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "form3.h"
1111

1212
/*
13-
#] include :
13+
#] include :
1414
#[ execarg :
1515
1616
Executes the subset of statements in an argument environment.
@@ -147,6 +147,7 @@ WORD execarg(PHEAD WORD *term, WORD level)
147147
If we come here we have to do the argument i (first is 1).
148148
*/
149149
sign = 1;
150+
action = 1;
150151
v[2] |= DIRTYFLAG;
151152
r = t + FUNHEAD;
152153
j = i;
@@ -244,6 +245,7 @@ WORD execarg(PHEAD WORD *term, WORD level)
244245
Now we must multiply the general coefficient by r[1]
245246
*/
246247
if ( scale && ( factor == 0 || *factor ) ) {
248+
action = 1;
247249
v[2] |= DIRTYFLAG;
248250
if ( r[1] < 0 ) {
249251
if ( type == TYPENORM3 ) k = 1;
@@ -437,6 +439,7 @@ WORD execarg(PHEAD WORD *term, WORD level)
437439
if ( r2[-1] == 3 ) continue;
438440
if ( r2[-1] == -3 && type == TYPENORM3 ) continue;
439441
}
442+
action = 1;
440443
v[2] |= DIRTYFLAG;
441444
j = r2[-1];
442445
k = REDLENG(j);
@@ -546,6 +549,7 @@ ScaledVariety:;
546549
else j = k - 2;
547550

548551
t[1] += j;
552+
action = 1;
549553
v[2] |= DIRTYFLAG;
550554
if ( j > 0 ) {
551555
r = m + j;
@@ -1267,6 +1271,7 @@ nextterm: mm = mnext;
12671271
*t = DUMMYTEN;
12681272
else
12691273
*t = DUMMYFUN;
1274+
action = 1;
12701275
v[2] = DIRTYFLAG;
12711276
t += t[1];
12721277
}
@@ -1365,6 +1370,7 @@ oneterm:;
13651370
TermFree(EAscrat,"execarg");
13661371
}
13671372
r2[1] = r1 - r2;
1373+
action = 1;
13681374
v[2] = DIRTYFLAG;
13691375
}
13701376
else {
@@ -1455,7 +1461,7 @@ WORD execterm(PHEAD WORD *term, WORD level)
14551461
}
14561462

14571463
/*
1458-
#] execterm :
1464+
#] execterm :
14591465
#[ ArgumentImplode :
14601466
*/
14611467

@@ -1559,7 +1565,7 @@ int ArgumentImplode(PHEAD WORD *term, WORD *thelist)
15591565
}
15601566

15611567
/*
1562-
#] ArgumentImplode :
1568+
#] ArgumentImplode :
15631569
#[ ArgumentExplode :
15641570
*/
15651571

@@ -1654,7 +1660,7 @@ TooMany: old = AN.currentTerm;
16541660
}
16551661

16561662
/*
1657-
#] ArgumentExplode :
1663+
#] ArgumentExplode :
16581664
#[ DoRepArg :
16591665
16601666
Too be filled in.
@@ -1669,6 +1675,6 @@ int DoRepArg(PHEAD WORD *term,int level)
16691675
}
16701676

16711677
/*
1672-
#] DoRepArg :
1678+
#] DoRepArg :
16731679
*/
16741680

sources/checkpoint.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,12 +1098,12 @@ size_t fwrite_cached(const void *ptr, size_t size, size_t nmemb, FILE *fd)
10981098
if ( fullsize+cache_fill >= CACHE_SIZE ) {
10991099
size_t overlap = CACHE_SIZE-cache_fill;
11001100
memcpy(cache_buffer+cache_fill, (unsigned char*)ptr, overlap);
1101-
if ( fwrite(cache_buffer, CACHE_SIZE, 1, fd) != 1 ) return 0;
1101+
if ( fwrite(cache_buffer, 1, CACHE_SIZE, fd) != CACHE_SIZE ) return 0;
11021102
fullsize -= overlap;
11031103
if ( fullsize >= CACHE_SIZE ) {
11041104
cache_fill = fullsize % CACHE_SIZE;
11051105
if ( cache_fill ) memcpy(cache_buffer, (unsigned char*)ptr+overlap+fullsize-cache_fill, cache_fill);
1106-
if ( fwrite((unsigned char*)ptr+overlap, fullsize-cache_fill, 1, fd) != 1 ) return 0;
1106+
if ( fwrite((unsigned char*)ptr+overlap, 1, fullsize-cache_fill, fd) != fullsize-cache_fill ) return 0;
11071107
}
11081108
else {
11091109
memcpy(cache_buffer, (unsigned char*)ptr+overlap, fullsize);
@@ -1120,9 +1120,12 @@ size_t fwrite_cached(const void *ptr, size_t size, size_t nmemb, FILE *fd)
11201120
size_t flush_cache(FILE *fd)
11211121
{
11221122
if ( cache_fill ) {
1123-
size_t retval = fwrite(cache_buffer, cache_fill, 1, fd);
1123+
size_t retval = fwrite(cache_buffer, 1, cache_fill, fd);
1124+
if ( retval != cache_fill ) {
1125+
cache_fill = 0;
1126+
return 0;
1127+
}
11241128
cache_fill = 0;
1125-
return retval;
11261129
}
11271130
return 1;
11281131
}
@@ -1173,7 +1176,7 @@ size_t flush_cache(FILE *fd)
11731176
memcpy(VAR, p, SIZE); p = (unsigned char*)p + SIZE;
11741177

11751178
#define S_WRITE_B(BUF,LEN) \
1176-
if ( fwrite_cached(BUF, LEN, 1, fd) != 1 ) return(__LINE__);
1179+
if ( fwrite_cached(BUF, 1, LEN, fd) != LEN ) return(__LINE__);
11771180

11781181
#define S_FLUSH_B \
11791182
if ( flush_cache(fd) != 1 ) return(__LINE__);
@@ -1189,7 +1192,7 @@ size_t flush_cache(FILE *fd)
11891192
#define S_WRITE_S(STR) \
11901193
if ( STR ) { \
11911194
l = strlen((char*)STR) + 1; \
1192-
if ( fwrite_cached(STR, l, 1, fd) != 1 ) return(__LINE__); \
1195+
if ( fwrite_cached(STR, 1, l, fd) != l ) return(__LINE__); \
11931196
}
11941197

11951198
/* LIST */
@@ -2273,10 +2276,10 @@ static int DoSnapshot(int moduletype)
22732276
if ( !(fd = fopen(intermedfile, "wb")) ) return(__LINE__);
22742277

22752278
/* reserve space in the file for a length field */
2276-
if ( fwrite(&pos, sizeof(POSITION), 1, fd) != 1 ) return(__LINE__);
2279+
if ( fwrite(&pos, 1, sizeof(POSITION), fd) != sizeof(POSITION) ) return(__LINE__);
22772280

22782281
/* write moduletype */
2279-
if ( fwrite(&moduletype, sizeof(int), 1, fd) != 1 ) return(__LINE__);
2282+
if ( fwrite(&moduletype, 1, sizeof(int), fd) != sizeof(int) ) return(__LINE__);
22802283

22812284
/* #[ AM */
22822285

@@ -2723,7 +2726,7 @@ static int DoSnapshot(int moduletype)
27232726
ANNOUNCE(file length)
27242727
SETBASEPOSITION(pos, (ftell(fd)));
27252728
fseek(fd, 0, SEEK_SET);
2726-
if ( fwrite(&pos, sizeof(POSITION), 1, fd) != 1 ) return(__LINE__);
2729+
if ( fwrite(&pos, 1, sizeof(POSITION), fd) != sizeof(POSITION) ) return(__LINE__);
27272730
fseek(fd, BASEPOSITION(pos), SEEK_SET);
27282731

27292732
ANNOUNCE(file close)

sources/compcomm.c

Lines changed: 117 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static KEYWORD onoffoptions[] = {
9797
static WORD one = 1;
9898

9999
/*
100-
#] includes :
100+
#] includes :
101101
#[ CoCollect :
102102
103103
Collect,functionname
@@ -531,7 +531,7 @@ int CoOn(UBYTE *s)
531531
}
532532

533533
/*
534-
#] CoOn :
534+
#] CoOn :
535535
#[ CoInsideFirst :
536536
*/
537537

@@ -3516,6 +3516,119 @@ int CoAntiBracket(UBYTE *inp)
35163516

35173517
/*
35183518
#] CoAntiBracket :
3519+
#[ CoMultiBracket :
3520+
3521+
Syntax:
3522+
MultiBracket:{A|B} bracketinfo:...:{A|B} bracketinfo;
3523+
*/
3524+
3525+
int CoMultiBracket(UBYTE *inp)
3526+
{
3527+
GETIDENTITY
3528+
int i, error = 0, error1, type, num;
3529+
UBYTE *s, c;
3530+
WORD *to, *from;
3531+
3532+
if ( *inp != ':' ) {
3533+
MesPrint("&Illegal Multiple Bracket separator: %s",inp);
3534+
return(1);
3535+
}
3536+
inp++;
3537+
if ( AC.MultiBracketBuf == 0 ) {
3538+
AC.MultiBracketBuf = (WORD **)Malloc1(sizeof(WORD *)*MAXMULTIBRACKETLEVELS,"multi bracket buffer");
3539+
for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3540+
AC.MultiBracketBuf[i] = 0;
3541+
}
3542+
}
3543+
else {
3544+
for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3545+
if ( AC.MultiBracketBuf[i] ) {
3546+
M_free(AC.MultiBracketBuf[i],"bracket buffer i");
3547+
AC.MultiBracketBuf[i] = 0;
3548+
}
3549+
}
3550+
AC.MultiBracketLevels = 0;
3551+
}
3552+
AC.MultiBracketLevels = 0;
3553+
/*
3554+
Start with disabling the regular brackets.
3555+
*/
3556+
if ( AT.BrackBuf == 0 ) {
3557+
AR.MaxBracket = 100;
3558+
AT.BrackBuf = (WORD *)Malloc1(sizeof(WORD)*(AR.MaxBracket+1),"bracket buffer");
3559+
}
3560+
*AT.BrackBuf = 0;
3561+
AR.BracketOn = 0;
3562+
AC.bracketindexflag = 0;
3563+
/*
3564+
Now loop through the various levels, separated by the colons.
3565+
*/
3566+
for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3567+
if ( *inp == 0 ) goto RegEnd;
3568+
/*
3569+
1: skip to ':', determine bracket or antibracket
3570+
*/
3571+
s = inp;
3572+
while ( *s && *s != ':' ) {
3573+
if ( *s == '[' ) { SKIPBRA1(s) s++; }
3574+
else if ( *s == '{' ) { SKIPBRA2(s) s++; }
3575+
else s++;
3576+
}
3577+
c = *s; *s = 0;
3578+
if ( StrICont(inp,(UBYTE *)"antibrackets") == 0 ) { type = 1; }
3579+
else if ( StrICont(inp,(UBYTE *)"brackets") == 0 ) { type = 0; }
3580+
else {
3581+
MesPrint("&Illegal (anti)bracket specification in MultiBracket statement");
3582+
if ( error == 0 ) error = 1;
3583+
goto NextLevel;
3584+
}
3585+
while ( FG.cTable[*inp] == 0 ) inp++;
3586+
if ( *inp != ',' ) {
3587+
MesPrint("&Illegal separator after (anti)bracket specification in MultiBracket statement");
3588+
if ( error == 0 ) error = 1;
3589+
goto NextLevel;
3590+
}
3591+
inp++;
3592+
/*
3593+
2: call DoBrackets.
3594+
*/
3595+
error1 = DoBrackets(inp, type);
3596+
if ( error < 0 ) return(error1);
3597+
if ( error1 > error ) error = error1;
3598+
/*
3599+
3: copy bracket information to the multi bracket arrays
3600+
*/
3601+
if ( AR.BracketOn ) {
3602+
num = AT.BrackBuf[0];
3603+
to = AC.MultiBracketBuf[i] = (WORD *)Malloc1((num+2)*sizeof(WORD),"bracket buffer i");
3604+
from = AT.BrackBuf;
3605+
*to++ = AR.BracketOn;
3606+
NCOPY(to,from,num);
3607+
*to = 0;
3608+
}
3609+
/*
3610+
4: set ready for the next level
3611+
*/
3612+
NextLevel:
3613+
*s = c; if ( c == ':' ) s++;
3614+
inp = s;
3615+
*AT.BrackBuf = 0;
3616+
AR.BracketOn = 0;
3617+
}
3618+
if ( *inp != 0 ) {
3619+
MesPrint("&More than %d levels in MultiBracket statement",(WORD)MAXMULTIBRACKETLEVELS);
3620+
if ( error == 0 ) error = 1;
3621+
}
3622+
RegEnd:
3623+
AC.MultiBracketLevels = i;
3624+
*AT.BrackBuf = 0;
3625+
AR.BracketOn = 0;
3626+
AC.bracketindexflag = 0;
3627+
return(error);
3628+
}
3629+
3630+
/*
3631+
#] CoMultiBracket :
35193632
#[ CountComp :
35203633
35213634
This routine reads the count statement. The syntax is:
@@ -5139,7 +5252,7 @@ int CoDropCoefficient(UBYTE *s)
51395252
return(1);
51405253
}
51415254
/*
5142-
#] CoDropCoefficient :
5255+
#] CoDropCoefficient :
51435256
#[ CoToPolynomial :
51445257
*/
51455258

@@ -5159,6 +5272,6 @@ int CoToPolynomial(UBYTE *inp)
51595272
#endif
51605273

51615274
/*
5162-
#] CoToPolynomial :
5275+
#] CoToPolynomial :
51635276
*/
51645277
/* temporary commentary for forcing cvs merge */

sources/compiler.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static KEYWORD com2commands[] = {
124124
,{"moduleoption", (TFUN)CoModuleOption, ATENDOFMODULE,PARTEST}
125125
,{"modulusgcd", (TFUN)CoModulusGCD, STATEMENT, PARTEST}
126126
,{"multi", (TFUN)CoMulti, STATEMENT, PARTEST}
127+
,{"multibracket", (TFUN)CoMultiBracket, STATEMENT, PARTEST}
127128
,{"ndrop", (TFUN)CoNoDrop, SPECIFICATION,PARTEST}
128129
,{"nhide", (TFUN)CoNoHide, SPECIFICATION,PARTEST}
129130
,{"normalize", (TFUN)CoNormalize, STATEMENT, PARTEST}
@@ -694,8 +695,8 @@ int CompileSubExpressions(SBYTE *tokens)
694695
hard to find errors, years from now.
695696
*/
696697
#ifdef MULBUF
697-
if ( insubexpbuffers >= 0x1FFFFFL ) {
698-
MesPrint("&More than 2^21 subexpressions inside one expression");
698+
if ( insubexpbuffers >= 0x3FFFFFL ) {
699+
MesPrint("&More than 2^22 subexpressions inside one expression");
699700
Terminate(-1);
700701
}
701702
if ( subexpbuffers+insubexpbuffers >= topsubexpbuffers ) {
@@ -1783,7 +1784,7 @@ dofunction: firstsumarg = 1;
17831784
}
17841785

17851786
/*
1786-
#] CodeGenerator :
1787+
#] CodeGenerator :
17871788
#[ CompleteTerm :
17881789
17891790
Completes the term

sources/declare.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ extern WORD AccumGCD(UWORD *,WORD *,UWORD *,WORD);
318318
extern VOID AddArgs(PHEAD WORD *,WORD *,WORD *);
319319
extern WORD AddCoef(PHEAD WORD **,WORD **);
320320
extern WORD AddLong(UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
321-
extern WORD AddPLon(UWORD *,WORD,UWORD *,WORD,UWORD *,UWORD *);
321+
extern WORD AddPLon(UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
322322
extern WORD AddPoly(PHEAD WORD **,WORD **);
323323
extern WORD AddRat(PHEAD UWORD *,WORD,UWORD *,WORD,UWORD *,WORD *);
324324
extern VOID AddToLine(UBYTE *);
@@ -856,6 +856,7 @@ extern int CoNotInParallel(UBYTE *);
856856
extern int DoInParallel(UBYTE *,int);
857857
extern int CoEndInExpression(UBYTE *);
858858
extern int CoBracket(UBYTE *);
859+
extern int CoMultiBracket(UBYTE *);
859860
extern int CoCFunction(UBYTE *);
860861
extern int CoCTensor(UBYTE *);
861862
extern int CoCollect(UBYTE *);

0 commit comments

Comments
 (0)