Release calc version 2.11.0t8.2

This commit is contained in:
Landon Curt Noll
1999-10-21 00:25:24 -07:00
parent 5cc680fe42
commit a7d401cd65
22 changed files with 122 additions and 132 deletions

View File

@@ -34,10 +34,16 @@ Following is the change from calc version 2.11.0t8 to date:
are used by pseudo_seed() in seed.c to determine what types of
system services can be used to form a pseudo-random seed.
Fixed the way calc -c will continue processing $CALCRC when errors
are encountered. Unless -d is also given, calc -c will report
when calc is unable to open a $CALCRC file.
Fixed the lower level make depend rules.
Misc cleanup on the have_*.c support source files.
Misc source file cleanup for things such as } else { style consistency.
Following is the change from calc version 2.11.0t7 to 2.11.0t7.5:

12
calc.c
View File

@@ -249,9 +249,13 @@ main(int argc, char **argv)
fprintf(stderr, "Error in rcfiles\n");
if ((c_flag && !stoponerror) || stoponerror < 0) {
getcommands(FALSE);
if (inputlevel() == 0) {
closeinput();
if (inputisterminal())
runrcfiles();
run_state = RUN_PRE_CMD_ARGS;
} else {
closeinput();
}
} else {
if ((havecommands && !i_flag) || !stdin_tty)
run_state = RUN_EXIT_WITH_ERROR;
@@ -274,11 +278,9 @@ main(int argc, char **argv)
fprintf(stderr, "Error in commands\n");
if ((c_flag && !stoponerror) || stoponerror < 0) {
getcommands(FALSE);
closeinput();
if (inputlevel() == 0) {
getcommands(FALSE);
if (inputlevel() == 0)
run_state = RUN_PRE_TOP_LEVEL;
}
closeinput();
} else {
closeinput();
if (!stdin_tty || !i_flag || p_flag)

View File

@@ -1001,8 +1001,7 @@ getoneobj(long index, int symtype)
if (symtype == SYM_UNDEFINED) {
rescantoken();
(void) getidexpr(TRUE, TRUE);
}
else {
} else {
symname = tokensymbol();
definesymbol(symname, symtype);
usesymbol(symname, FALSE);
@@ -1086,8 +1085,7 @@ getonematrix(int symtype)
if (symtype == SYM_UNDEFINED) {
rescantoken();
(void) getidexpr(FALSE, TRUE);
}
else {
} else {
name = tokensymbol();
definesymbol(name, symtype);
usesymbol(name, FALSE);
@@ -1172,9 +1170,9 @@ creatematrix(void)
switch (gettoken()) {
case T_RIGHTBRACKET:
addopone(OP_MATCREATE, dim);
if (gettoken() == T_LEFTBRACKET)
if (gettoken() == T_LEFTBRACKET) {
creatematrix();
else {
} else {
rescantoken();
addop(OP_ZERO);
}
@@ -1350,8 +1348,7 @@ getopassignment(void)
while (gettoken() == T_ASSIGN)
getinitlist();
rescantoken();
}
else {
} else {
rescantoken();
(void) getassignment();
}

View File

@@ -231,8 +231,7 @@ csqrt(COMPLEX *c, NUMBER *epsilon, long R)
return r;
}
s3 = zquo(tmp3, d, &tmp1, s2 < 0);
}
else {
} else {
s2 = zquo(tmp1, d, &tmp3, s1 ? (s1 < 0) : 16);
zfree(tmp1);
s3 = zsqrt(tmp3,&tmp1,(s1||s2) ? (s1<0 || s2<0) : 16);
@@ -288,8 +287,7 @@ csqrt(COMPLEX *c, NUMBER *epsilon, long R)
return r;
}
s3 = zquo(tmp3, d, &mul1, 0);
}
else {
} else {
s2 = zquo(tmp1, d, &tmp3, 0);
zfree(tmp1);
s3 = zsqrt(tmp3, &mul1, 0);

17
file.c
View File

@@ -115,15 +115,14 @@ file_init(void)
*/
if (fstat(i, &sbuf) >= 0) {
fp = (FILE *) fdopen(i,"r+"); /*guess mode*/
if (fp)
if (fp) {
strcpy(files[idnum].mode, "r+");
else {
} else {
fp = (FILE *) fdopen(i, "r");
if (fp) {
strcpy(files[idnum].mode, "r");
files[idnum].writing = FALSE;
}
else {
} else {
fp = (FILE *) fdopen(i, "w");
if (fp) {
strcpy(files[idnum].mode, "w?");
@@ -890,8 +889,9 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
NULL)
math_chr(*vp->v_nblock->
blk->data);
} else
} else {
printvalue(vp, PRINT_NORMAL);
}
break;
default:
printvalue(vp, PRINT_NORMAL);
@@ -1770,8 +1770,7 @@ showfiles(void)
if (fstat(fileno(fp), &sbuf) < 0) {
printf("Bad fstat for file %d\n", (int) fiop->id);
sizes[i] = -1;
}
else {
} else {
inodes[i] = sbuf.st_ino;
sizes[i] = (long) sbuf.st_size;
}
@@ -2471,9 +2470,9 @@ fsearch(FILEID id, char *str, ZVALUE start, ZVALUE end, ZVALUE *res)
}
(void) f_seek_set(fiop->fp, &cur);
}
if (*tmp.v)
if (*tmp.v) {
(*tmp.v)--;
else {
} else {
if (tmp.len == 1)
break;
k = 0;

49
func.c
View File

@@ -1640,8 +1640,7 @@ f_avg(int count, VALUE **vals)
if ((*vals)->v_type == V_LIST) {
addlistitems((*vals)->v_list, &sum);
n += countlistitems((*vals++)->v_list);
}
else {
} else {
addvalue(&sum, *vals++, &tmp);
freevalue(&sum);
sum = tmp;
@@ -1690,8 +1689,7 @@ f_hmean(int count, VALUE **vals)
if ((*vals)->v_type == V_LIST) {
addlistinv((*vals)->v_list, &sum);
n += countlistitems((*vals++)->v_list);
}
else {
} else {
invertvalue(*vals++, &tmp1);
addvalue(&sum, &tmp1, &tmp2);
freevalue(&tmp1);
@@ -3842,9 +3840,9 @@ f_search(int count, VALUE **vals)
start = qlink(start);
}
if (end) {
if (!qispos(end))
if (!qispos(end)) {
end = qqadd(size, end);
else {
} else {
if (qrel(end, size) > 0)
end = qlink(size);
else
@@ -3866,8 +3864,7 @@ f_search(int count, VALUE **vals)
if (count == 2 || (count == 4 && end != NULL)) {
start = qalloc();
start->num = pos;
}
else {
} else {
end = qalloc();
end->num = pos;
}
@@ -4005,9 +4002,9 @@ f_rsearch(int count, VALUE **vals)
start = qlink(start);
}
if (end) {
if (!qispos(end))
if (!qispos(end)) {
end = qqadd(size, end);
else {
} else {
if (qrel(end, size) > 0)
end = qlink(size);
else
@@ -4029,8 +4026,7 @@ f_rsearch(int count, VALUE **vals)
if (count == 2 || (count == 4 && end != NULL)) {
start = qalloc();
start->num = pos;
}
else {
} else {
end = qalloc();
end->num = pos;
}
@@ -4042,8 +4038,7 @@ f_rsearch(int count, VALUE **vals)
if (count < 4) {
end = start;
start = NULL;
}
else {
} else {
qtmp = qsub(end, qlen);
qfree(end);
end = qtmp;
@@ -4634,9 +4629,9 @@ f_strerror(int count, VALUE **vals)
if (count > 0) {
vp = vals[0];
if (vp->v_type < 0)
if (vp->v_type < 0) {
i = (long) -vp->v_type;
else {
} else {
if (vp->v_type != V_NUM || qisfrac(vp->v_num))
return error_value(E_STRERROR1);
i = qtoi(vp->v_num);
@@ -4747,12 +4742,12 @@ f_error(int count, VALUE **vals)
if (count > 0) {
vp = vals[0];
if (vp->v_type <= 0)
if (vp->v_type <= 0) {
r = (long) -vp->v_type;
else {
if (vp->v_type != V_NUM || qisfrac(vp->v_num))
} else {
if (vp->v_type != V_NUM || qisfrac(vp->v_num)) {
r = E_ERROR1;
else {
} else {
r = qtoi(vp->v_num);
if (r < 0 || r >= 32768)
r = E_ERROR2;
@@ -5542,28 +5537,26 @@ f_tail(VALUE *v1, VALUE *v2)
res.v_type = v1->v_type;
switch (v1->v_type) {
case V_LIST:
if (n == 0)
if (n == 0) {
res.v_list = listalloc();
else if (n > 0) {
} else if (n > 0) {
res.v_list = listsegment(v1->v_list,
v1->v_list->l_count - n,
v1->v_list->l_count - 1);
}
else {
} else {
res.v_list = listsegment(v1->v_list,
v1->v_list->l_count - 1,
v1->v_list->l_count + n);
}
return res;
case V_STR:
if (n == 0)
if (n == 0) {
res.v_str = slink(&_nullstring_);
else if (n > 0) {
} else if (n > 0) {
res.v_str = stringsegment(v1->v_str,
v1->v_str->s_len - n,
v1->v_str->s_len - 1);
}
else {
} else {
res.v_str = stringsegment(v1->v_str,
v1->v_str->s_len - 1,
v1->v_str->s_len + n);

3
hist.c
View File

@@ -455,9 +455,10 @@ do_bind_line(KEY_MAP *map, char *line)
if (*cp == '?') {
key = 0177;
cp++;
} else
} else {
key = CONTROL(*cp++);
}
}
else if (key == '\\')
key = *cp++;

23
input.c
View File

@@ -719,22 +719,19 @@ runrcfiles(void)
{
char path[MAX_CALCRC+1+1]; /* name being searched for */
char *cp;
char *newcp;
char *p;
int i;
/* execute each file in the list */
for (cp=calcrc, newcp=(char *)strchr(calcrc, LISTCHAR);
cp != NULL && *cp;
cp = newcp,
newcp=(newcp) ? (char *)strchr(newcp+1, LISTCHAR) : NULL) {
while (calcrc != NULL && *calcrc) {
cp = calcrc;
calcrc = (char *) strchr(calcrc + 1, LISTCHAR);
/* load file name into the path */
if (newcp == NULL) {
if (calcrc == NULL) {
strcpy(path, cp);
} else {
strncpy(path, cp, newcp-cp);
path[newcp-cp] = '\0';
strncpy(path, cp, calcrc - cp);
path[calcrc - cp] = '\0';
}
/* find the start of the path */
@@ -744,9 +741,13 @@ runrcfiles(void)
}
/* process the current file in the list */
i = openfile(p);
if (i < 0)
if (openfile(p) < 0) {
/* Unable to open rcfile */
if (c_flag && !d_flag)
fprintf(stderr,
"Unable to open rcfile \"%s\"\n", p);
continue;
}
getcommands(FALSE);
closeinput();
}

View File

@@ -1213,8 +1213,9 @@ matcopy(MATRIX *m)
if (v1->v_type == V_NUM) {
v2->v_type = V_NUM;
v2->v_num = qlink(v1->v_num);
} else
} else {
copyvalue(v1, v2);
}
v1++;
v2++;
}

6
obj.c
View File

@@ -640,9 +640,10 @@ objfree(OBJECT *op)
for (i = op->o_actions->count; i-- > 0; vp++) {
if (vp->v_type == V_NUM) {
qfree(vp->v_num);
} else
} else {
freevalue(vp);
}
}
if (op->o_actions->count <= USUAL_ELEMENTS)
free(op);
else
@@ -678,8 +679,9 @@ objcopy(OBJECT *op)
if (v1->v_type == V_NUM) {
v2->v_num = qlink(v1->v_num);
v2->v_type = V_NUM;
} else
} else {
copyvalue(v1, v2);
}
v2->v_subtype = V_NOSUBTYPE;
}
return np;

View File

@@ -2065,9 +2065,9 @@ o_isdefined(void)
}
r = 0;
index = getbuiltinfunc(vp->v_str->s_str);
if (index >= 0)
if (index >= 0) {
r = 1;
else {
} else {
index = getuserfunc(vp->v_str->s_str);
if (index >= 0)
r = 2;

13
poly.c
View File

@@ -31,20 +31,17 @@ evp(LISTELEM *cp, LISTELEM *x, VALUE *vres)
freevalue(&tmp1);
freevalue(vres);
*vres = tmp2;
}
else {
} else {
s = TRUE;
*vres = tmp1;
}
}
}
else {
} else {
if (s) {
addvalue(&v, vres, &tmp1);
freevalue(vres);
*vres = tmp1;
}
else {
} else {
s = TRUE;
copyvalue(&v, vres);
}
@@ -126,9 +123,9 @@ addlistinv(LIST *lp, VALUE *vres)
VALUE tmp1, tmp2;
for (ep = lp->l_first; ep; ep = ep->e_next) {
if (ep->e_value.v_type == V_LIST)
if (ep->e_value.v_type == V_LIST) {
addlistinv(ep->e_value.v_list, vres);
else {
} else {
invertvalue(&ep->e_value, &tmp1);
addvalue(vres, &tmp1, &tmp2);
freevalue(&tmp1);

View File

@@ -1156,9 +1156,9 @@ qcfappr(NUMBER *q, NUMBER *epsilon, long rnd)
s = -s;
}
if (bnddencase) {
if (s > 0)
if (s > 0) {
useold = TRUE;
else {
} else {
zsub(zden, denbnd, &tmp1);
zquo(tmp1, oldden, &k, 1);
zfree(tmp1);

3
qio.c
View File

@@ -413,9 +413,10 @@ qprintfd(NUMBER *q, long width)
zquo(q->num, q->den, &z, conf->outround);
zprintval(z, 0L, width);
zfree(z);
} else
} else {
zprintval(q->num, 0L, width);
}
}
/*

12
qmod.c
View File

@@ -116,15 +116,13 @@ qquomod(NUMBER *q1, NUMBER *q2, NUMBER **retqdiv, NUMBER **retqmod)
zfree(tmp2);
qq = qlink(&_qzero_);
qm = qlink(q1);
}
else {
} else {
qq = qalloc();
qq->num = tmp1;
if (ziszero(tmp2)) {
zfree(tmp2);
qm = qlink(&_qzero_);
}
else {
} else {
qm = qalloc();
qm->num = tmp2;
}
@@ -141,15 +139,13 @@ qquomod(NUMBER *q1, NUMBER *q2, NUMBER **retqdiv, NUMBER **retqmod)
zfree(tmp4);
qq = qlink(&_qzero_);
qm = qlink(q1);
}
else {
} else {
qq = qalloc();
qq->num = tmp3;
if (ziszero(tmp4)) {
zfree(tmp4);
qm = qlink(&_qzero_);
}
else {
} else {
qm = qalloc();
zmul(q1->den, q2->den, &tmp1);
zreduce(tmp4, tmp1, &qm->num, &qm->den);

View File

@@ -1022,8 +1022,7 @@ qpower(NUMBER *q1, NUMBER *q2, NUMBER *epsilon)
tmp1 = itoq(m);
tmp2 = qmul(tmp1, q2tmp);
m = qtoi(tmp2);
}
else {
} else {
tmp1 = qdec(q1tmp);
tmp2 = qqdiv(tmp1, q1tmp);
qfree(tmp1);
@@ -1038,8 +1037,7 @@ qpower(NUMBER *q1, NUMBER *q2, NUMBER *epsilon)
tmp1 = itoq(m + 1);
tmp2 = qmul(tmp1, q2tmp);
m = qtoi(tmp2);
}
else {
} else {
tmp1 = qdec(q1tmp);
tmp2 = qmul(tmp1, q2tmp);
qfree(tmp1);

View File

@@ -1157,8 +1157,7 @@ addstring(char *str, long len)
if (stringconstavail <= 0) {
if (stringconsttable == NULL) {
initstrings();
}
else {
} else {
sp = (STRING **) realloc((char *) stringconsttable,
sizeof(STRING *) * (stringconstcount + STRCONSTALLOC));
if (sp == NULL) {

View File

@@ -894,15 +894,17 @@ xorvalue(VALUE *v1, VALUE *v2, VALUE *vres)
if (v1->v_str->s_len) {
vres->v_str = stringcopy(v1->v_str);
*vres->v_str->s_str ^= *v2->v_octet;
} else
} else {
vres->v_str = charstring(*v2->v_octet);
}
return;
case (TWOVAL(V_OCTET, V_STR)):
if (v2->v_str->s_len) {
vres->v_str = stringcopy(v2->v_str);
*vres->v_str->s_str ^= *v1->v_octet;
} else
} else {
vres->v_str = charstring(*v1->v_octet);
}
return;
case (TWOVAL(V_OCTET, V_OCTET)):
vres->v_type = V_STR;

View File

@@ -12,7 +12,7 @@
#define MAJOR_VER 2 /* major version */
#define MINOR_VER 11 /* minor version */
#define MAJOR_PATCH 0 /* patch level or 0 if no patch */
#define MINOR_PATCH "8.1" /* test number or empty string if no patch */
#define MINOR_PATCH "8.2" /* test number or empty string if no patch */
/*
* calc version constants

33
zfunc.c
View File

@@ -269,8 +269,9 @@ zfib(ZVALUE z, ZVALUE *res)
fnm1 = fn;
fn = fnp1;
zadd(fnm1, fn, &fnp1);
} else
} else {
zsub(fnp1, fn, &fnm1);
}
i >>= (FULL)1;
}
zfree(fnm1);
@@ -889,8 +890,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res)
*a = ~*a;
}
}
}
else { /* abs(a - b) case */
} else { /* abs(a - b) case */
while (i && *a++ == *b++) i--;
q = n - i;
if (m == n) { /* a and b same length */
@@ -914,8 +914,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res)
f = -f & BASE1;
}
}
}
else { /* a has more digits than b */
} else { /* a has more digits than b */
a = a0 + q;
b = b0 + q;
i = n - q;
@@ -1117,9 +1116,10 @@ zlog(ZVALUE z1, ZVALUE z2)
zfree(val);
val = temp;
power += worth;
} else
} else {
zfree(temp);
}
}
if (zp != squares)
zfree(*zp);
}
@@ -1170,10 +1170,11 @@ zlog10(ZVALUE z)
zfree(val);
val = temp;
power += worth;
} else
} else {
zfree(temp);
}
}
}
zfree(val);
return power;
}
@@ -1574,8 +1575,7 @@ zsqrt(ZVALUE z, ZVALUE *dest, long rnd)
x = ~x + !u;
if (!(x & TOPHALF))
a[1] -= 1;
}
else {
} else {
f = *a - x * x;
*a++ = (HALF)f;
u = -(HALF)(f >> BASEB);
@@ -1623,9 +1623,9 @@ done: if (s == 0) {
}
if (rnd & 16) {
if (s == 0) {
if (m != n)
if (m != n) {
up = (m > n);
else {
} else {
i = n;
b = a0 + n;
a = A + n;
@@ -1633,13 +1633,12 @@ done: if (s == 0) {
i--;
up = (i > 0 && *a > *b);
}
}
else {
} else {
while (m > 1 && A[m - 1] == BASE1)
m--;
if (m != n)
if (m != n) {
up = (m < n);
else {
} else {
i = n;
b = a0 + n;
a = A + n;
@@ -1660,9 +1659,9 @@ done: if (s == 0) {
a = a0;
while (i-- && *a == BASE1)
*a++ = 0;
if (i >= 0)
if (i >= 0) {
(*a)++;
else {
} else {
n++;
*a = 1;
}

17
zmath.c
View File

@@ -687,8 +687,7 @@ zdiv(ZVALUE z1, ZVALUE z2, ZVALUE *quo, ZVALUE *rem, long rnd)
}
s = *a + u;
A[m] = (HALF) (~x + !s);
}
else {
} else {
while (i--) {
f = (FULL) *a - u - x * *b++;
*a++ = (HALF) f;
@@ -708,9 +707,9 @@ done: while (m > 0 && A[m - 1] == 0)
val = 0;
if (a1[len - 1] == 0)
len--;
if (len == 0)
if (len == 0) {
*quo = _zero_;
else {
} else {
quo->len = len;
quo->v = alloc(len);
memcpy(quo->v, a1, len * sizeof(HALF));
@@ -746,8 +745,7 @@ done: while (m > 0 && A[m - 1] == 0)
}
else if (g >= BASE)
t = 1;
}
else {
} else {
while (--i > 0) {
g = (FULL) *--a - (*--b >> 1 | f);
if (g != 0)
@@ -973,9 +971,9 @@ zequo(ZVALUE z1, ZVALUE z2, ZVALUE *res)
*a0++ = x;
p--;
}
if (k == 0)
if (k == 0) {
*a0 = w * *a0;
else {
} else {
u = (HALF)(w * *a0) >> k;
x = (HALF)(((FULL) z1.v[z1.len - 1] << BASEB
| z1.v[z1.len - 2])
@@ -1890,8 +1888,9 @@ zshiftl(ZVALUE z, long n)
if (i > BASE1) {
mask = i >> BASEB;
i &= BASE1;
} else
} else {
mask = 0;
}
*h = (HALF) i;
++h;
}

3
zmod.c
View File

@@ -1746,8 +1746,7 @@ zredcsquare(REDC *rp, ZVALUE z1, ZVALUE *res)
carry.ivalue = (FULL) sival1.sihigh
+ (FULL) sival2.sihigh;
hd++;
}
else {
} else {
muln = (HALF) (*hd * Ninv);
f = (muln * ((FULL) *h3++) + (FULL) *hd++) >> BASEB;
j = i;