Release calc version 2.11.0t9.4.5

This commit is contained in:
Landon Curt Noll
1999-11-11 02:48:51 -08:00
parent 58d32c68f9
commit 86c8e6dcf1
25 changed files with 900 additions and 95 deletions

18
BUGS
View File

@@ -31,7 +31,9 @@ The calc web site is located at:
If you have tried all of the above and things still are not right,
then it may be time to send in a bug report. You can send bug reports to:
calc-tester@postofc.corp.sgi.com
calc-bugs at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
When you send your report, please include the following information:
@@ -62,7 +64,12 @@ Stack traces from core dumps are useful to send as well.
Send any comments, compiler warning messages, suggestions and most
importantly, fixes (in the form of a context diff patch) to:
calc-tester@postofc.corp.sgi.com
calc-tester at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
You should use the above calc-bugs address for bug reports, if you are
not currently a member of the calc-tester mailing list.
=-=
@@ -146,6 +153,7 @@ Other items of note:
DEBUG= -g
or set:
DEBUG=
* The sparcv9 support for 64 bit Solaris under gcc-2.96 is able
to compile calc, but calc dumps core very early on in startup.
It is said that sparcv9 support in gcc-2.96 is very unofficial.
There is no work-a-round for this compile problem.

View File

@@ -227,6 +227,13 @@ Following is the change from calc version 2.11.0t8.9.1 to date:
Fixed some insure code inspection tool issues that were discovered
and investigated by Michel van der List <vanderlistmj@sbphrd.com>.
Made an effort to ensure that the v_subtype of VALUES are initialized
to V_NOSUBTYPE thruout the source code.
Established a separate calc-bugs address from the calc-tester
maining list. Using anti-spam address forms in order to try and
stay under the radar of spammers as much as one can do so.
Following is the change from calc version 2.11.0t8 to 2.11.0t8.9:

12
README
View File

@@ -74,7 +74,9 @@ for a wish/todo list. Code contributions are welcome.
To join the calc-tester mailing list. Send a request to:
calc-tester-request@postofc.corp.sgi.com
calc-tester-request at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
Your message body (not the subject) should consist of:
@@ -85,6 +87,14 @@ Your message body (not the subject) should consist of:
where ``address'' is your EMail address and ``your_full_name'' is
your full name.
Calc bug reports, however should be sent to:
calc-bugs at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
but see the BUGS file first.
The calc web site is located at:
http://reality.sgi.com/chongo/tech/comp/calc/

View File

@@ -114,6 +114,7 @@ beginfunc(char *name, BOOL newflag)
fp->f_localcount = 0;
fp->f_opcodecount = 0;
fp->f_savedvalue.v_type = V_NULL;
fp->f_savedvalue.v_subtype = V_NOSUBTYPE;
fp->f_name = namestr(&funcnames, newindex);
curfunc = fp;
initlocals();

View File

@@ -80,6 +80,7 @@ associndex(ASSOC *ap, BOOL create, long dim, VALUE *indices)
*/
if (!create) {
val.v_type = V_NULL;
val.v_subtype = V_NOSUBTYPE;
return &val;
}
@@ -292,6 +293,7 @@ assoccopy(ASSOC *oldap)
ep->e_dim = oldep->e_dim;
ep->e_hash = oldep->e_hash;
ep->e_value.v_type = V_NULL;
ep->e_value.v_subtype = V_NOSUBTYPE;
for (i = 0; i < ep->e_dim; i++)
copyvalue(&oldep->e_indices[i], &ep->e_indices[i]);
copyvalue(&oldep->e_value, &ep->e_value);

View File

@@ -330,6 +330,7 @@ copyblk2mat(BLOCK *blk, long ssi, long num, MATRIX *dmat, long dsi)
i = num;
while (i-- > 0) {
vp->v_type = V_NUM;
vp->v_subtype = V_NOSUBTYPE;
vp->v_num = itoq((long) *op++);
vp++;
}

View File

@@ -570,7 +570,11 @@ The majority of
was written by David I. Bell.
.sp
.B Calc
archives and calc-tester mailing list maintained by Landon Curt Noll.
The Calc primary mirror, calc mailing list and calc bug report
processing is performed by Landon Curt Noll.
.sp
Landon Curt Noll maintains the master reference source, performs
release control functions as well as other calc maintenance functions.
.sp
Thanks for suggestions and encouragement from Peter Miller,
Neil Justusson, and Landon Noll.
@@ -610,9 +614,36 @@ scripts that you would like you see included
in future distributions to:
.sp
.in +0.5i
calc-tester@postofc.corp.sgi.com
.nf
calc-tester at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
.fi
.in -0.5i
.sp
Bug reports are sent to:
.in +0.5i
.nf
calc-bugs at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
.fi
.in -0.5i
.sp
See the
.I BUGS
source file or use the
.I calc
command:
.sp
.in +0.5i
.nf
help bugs
.fi
.in -0.5i
.sp
for more information about bug reporting.
.sp
Landon Noll maintains the the
.B calc
web site is located at:
@@ -626,7 +657,11 @@ One may join the
testing group by sending a request to:
.sp
.in +0.5i
calc-tester-request@postofc.corp.sgi.com
.nf
calc-tester-request at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
.fi
.in -0.5i
.sp
Your message body (not the subject) should consist of:

View File

@@ -1000,6 +1000,7 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
* convert element to value
*/
vp->v_type = V_NUM;
vp->v_subtype = V_NOSUBTYPE;
switch (type) {
case CONFIG_ALL:
vp->v_type = V_CONFIG;

9
file.c
View File

@@ -2228,15 +2228,16 @@ freadnum(FILE *fp, VALUE *valptr)
ch = fgetc(fp);
}
}
if (ch == 'i' || ch == 'I')
if (ch == 'i' || ch == 'I') {
imag = TRUE;
else {
} else {
ungetc(ch, fp);
}
if (ziszero(num)) {
zfree(num);
val.v_type = V_NUM;
val.v_subtype = V_NOSUBTYPE;
val.v_num = qlink(&_qzero_);
*valptr = val;
return;
@@ -2281,11 +2282,11 @@ freadnum(FILE *fp, VALUE *valptr)
c->imag = q;
val.v_type = V_COM;
val.v_com = c;
}
else {
} else {
val.v_type = V_NUM;
val.v_num = q;
}
val.v_subtype = V_NOSUBTYPE;
*valptr = val;
}

605
func.c

File diff suppressed because it is too large Load Diff

View File

@@ -36,17 +36,33 @@ gziped (or compressed) tar file).
You should send submissions to:
calc-tester@postofc.corp.sgi.com
calc-tester at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
Thanks for considering submitting code to calc. Calc is a collective
work by a number of people. It would not be what it is today without
your efforts and submissions!
Calc bug reports, however, should be sent to:
calc-bugs at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
See the BUGS file or try the help command:
help bugs
for details on bug reporting.
=-=
One may join the calc testing group by sending a request to:
calc-tester-request@postofc.corp.sgi.com
calc-tester-request at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
Your message body (not the subject) should consist of:

View File

@@ -2,7 +2,11 @@ Credits
The majority of calc was written by David I. Bell.
Calc archives and calc-tester mailing list maintained by Landon Curt Noll.
The Calc primary mirror, calc mailing list and calc bug report
processing is performed by Landon Curt Noll.
Landon Curt Noll maintains the master reference source, performs
release control functions as well as other calc maintenance functions.
Thanks for suggestions and encouragement from Peter Miller,
Neil Justusson, and Landon Noll.

View File

@@ -5,10 +5,22 @@ Calc Todo Items:
Code contributions are welcome. Send patches to:
calc-tester@postofc.corp.sgi.com
calc-tester at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
See also the 'wishlist' help files for the calc enhancement wish list.
Calc bug reports, however, should send to:
calc-tester at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
see the BUGS file or try the calc command:
help bugs
=-=
Very High priority items:

View File

@@ -4,11 +4,19 @@ Calc Enhancement Wish List:
interesting calc scripts that you would like you see included in
future distributions to:
calc-tester@postofc.corp.sgi.com
calc-tester at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
The following items are in the calc wish list. Programs like this
can be extended and improved forever.
Calc bug repoers, however, should be sent to:
calc-bugs at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
See the 'todo' help file for higher priority todo items.
=-=

View File

@@ -33,7 +33,9 @@ the calc language, and/or because the authors thought them to be useful!
If you write something that you think is useful, please send it to:
calc-tester@postofc.corp.sgi.com
calc-tester at postofc dot corp dot sgi dot com
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
By convention, a lib file only defines and/or initializes functions,
objects and variables. (The regress.cal and testxxx.cal regression test

View File

@@ -318,17 +318,16 @@ initenv(void)
char *c;
/* determine the $CALCPATH value */
c = getenv(CALCPATH);
calcpath = ((no_env || c == NULL) ? NULL : strdup(c));
c = (no_env ? NULL : getenv(CALCPATH));
calcpath = (c ? strdup(c) : NULL);
if (calcpath == NULL)
calcpath = DEFAULTCALCPATH;
/* determine the $CALCRC value */
c = getenv(CALCRC);
calcrc = ((no_env || c == NULL) ? NULL : strdup(c));
if (calcrc == NULL) {
c = (no_env ? NULL : getenv(CALCRC));
calcrc = (c ? strdup(c) : NULL);
if (calcrc == NULL)
calcrc = DEFAULTCALCRC;
}
if (strlen(calcrc) > MAX_CALCRC) {
math_error("The $CALCRC variable is longer than %d chars",
MAX_CALCRC);
@@ -336,15 +335,14 @@ initenv(void)
}
/* determine the $CALCBINDINGS value */
c = getenv(CALCBINDINGS);
calcbindings = ((no_env || c == NULL) ? NULL : strdup(c));
if (calcbindings == NULL) {
c = (no_env ? NULL : getenv(CALCBINDINGS));
calcbindings = (c ? strdup(c) : NULL);
if (calcbindings == NULL)
calcbindings = DEFAULTCALCBINDINGS;
}
/* determine the $HOME value */
c = getenv(HOME);
home = ((no_env || c == NULL) ? NULL : strdup(c));
c = (no_env ? NULL : getenv(HOME));
home = (c ? strdup(c) : NULL);
if (home == NULL || home[0] == '\0') {
ent = (struct passwd *)getpwuid(geteuid());
if (ent == NULL) {
@@ -356,16 +354,15 @@ initenv(void)
}
/* determine the $PAGER value */
c = getenv(PAGER);
pager = ((no_env || c == NULL) ? NULL : strdup(c));
if (pager == NULL || *pager == '\0') {
c = (no_env ? NULL : getenv(PAGER));
pager = (c ? strdup(c) : NULL);
if (pager == NULL || *pager == '\0')
pager = DEFAULTCALCPAGER;
}
/* determine the $SHELL value */
c = getenv(SHELL);
shell = ((no_env || c == NULL) ? NULL : strdup(c));
if (shell == NULL)
c = (no_env ? NULL : getenv(SHELL));
shell = (c ? strdup(c) : NULL);
if (shell == NULL || *shell == '\0')
shell = DEFAULTSHELL;
}

View File

@@ -130,10 +130,12 @@ removelistfirst(LIST *lp, VALUE *vp)
{
if (lp->l_count == 0) {
vp->v_type = V_NULL;
vp->v_subtype = V_NOSUBTYPE;
return;
}
*vp = lp->l_first->e_value;
lp->l_first->e_value.v_type = V_NULL;
lp->l_first->e_value.v_type = V_NOSUBTYPE;
removelistelement(lp, lp->l_first);
}
@@ -151,10 +153,12 @@ removelistlast(LIST *lp, VALUE *vp)
{
if (lp->l_count == 0) {
vp->v_type = V_NULL;
vp->v_subtype = V_NOSUBTYPE;
return;
}
*vp = lp->l_last->e_value;
lp->l_last->e_value.v_type = V_NULL;
lp->l_last->e_value.v_subtype = V_NOSUBTYPE;
removelistelement(lp, lp->l_last);
}
@@ -181,6 +185,7 @@ removelistmiddle(LIST *lp, long index, VALUE *vp)
}
*vp = ep->e_value;
ep->e_value.v_type = V_NULL;
ep->e_value.v_subtype = V_NOSUBTYPE;
removelistelement(lp, ep);
}

View File

@@ -154,6 +154,7 @@ matmul(MATRIX *m1, MATRIX *m2)
for (i1 = 0; i1 < max1; i1++) {
for (i2 = 0; i2 < max2; i2++) {
sum.v_type = V_NULL;
sum.v_subtype = V_NOSUBTYPE;
v1 = &m1->m_table[i1 * maxindex];
v2 = &m2->m_table[i2];
for (index = 0; index < maxindex; index++) {
@@ -202,6 +203,7 @@ matsquare(MATRIX *m)
for (i1 = 0; i1 < max; i1++) {
for (i2 = 0; i2 < max; i2++) {
sum.v_type = V_NULL;
sum.v_subtype = V_NOSUBTYPE;
v1 = &m->m_table[i1 * max];
v2 = &m->m_table[i2];
for (index = 0; index < max; index++) {
@@ -405,6 +407,7 @@ matscale(MATRIX *m, long n)
if (n == 0)
return matcopy(m);
temp.v_type = V_NUM;
temp.v_subtype = V_NOSUBTYPE;
temp.v_num = itoq(n);
res = matalloc(m->m_size);
*res = *m;
@@ -436,6 +439,7 @@ matshift(MATRIX *m, long n)
if (n == 0)
return matcopy(m);
temp.v_type = V_NUM;
temp.v_subtype = V_NOSUBTYPE;
temp.v_num = itoq(n);
res = matalloc(m->m_size);
*res = *m;
@@ -1062,6 +1066,7 @@ matdet(MATRIX *m)
while (!testvalue(val)) {
if (--i <= 0) {
tmp1.v_type = V_NUM;
tmp1.v_subtype = V_NOSUBTYPE;
tmp1.v_num = qlink(&_qzero_);
matfree(m);
return tmp1;

5
obj.c
View File

@@ -141,6 +141,10 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3)
VALUE tmp; /* temp value */
char name[SYMBOLSIZE+1]; /* full name of user routine to call */
/* initialize VALUEs */
val.v_subtype = V_NOSUBTYPE;
tmp.v_subtype = V_NOSUBTYPE;
if ((unsigned)action > OBJ_MAXFUNC) {
math_error("Illegal action for object call");
/*NOTREACHED*/
@@ -404,6 +408,7 @@ objpowi(VALUE *vp, NUMBER *q)
case 1:
res.v_obj = objcopy(vp->v_obj);
res.v_type = V_OBJ;
res.v_subtype = V_NOSUBTYPE;
return res;
case -1:
return objcall(OBJ_INV, vp, NULL_VALUE, NULL_VALUE);

107
opcodes.c
View File

@@ -230,6 +230,7 @@ o_argvalue(FUNC *fp, int argcount, VALUE *args)
qfree(stack->v_num);
stack->v_num = itoq((long) argcount);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
index = qtoi(vp->v_num) - 1;
@@ -292,6 +293,7 @@ o_string(FUNC *fp, long arg)
stack++;
stack->v_str = slink(findstring(arg));
stack->v_type = V_STR;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -300,6 +302,7 @@ o_undef(void)
{
stack++;
stack->v_type = V_NULL;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -940,6 +943,7 @@ o_swap(void)
/*NOTREACHED*/
}
stack->v_type = V_NULL;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -958,11 +962,13 @@ o_add(void)
v2 = v2->v_addr;
if (v1->v_type == V_OCTET) {
w1.v_type = V_NUM;
w1.v_subtype = V_NOSUBTYPE;
w1.v_num = itoq(*v1->v_octet);
v1 = &w1;
}
if (v2->v_type == V_OCTET) {
w2.v_type = V_NUM;
w2.v_subtype = V_NOSUBTYPE;
w2.v_num = itoq(*v2->v_octet);
v2 = &w2;
}
@@ -993,11 +999,13 @@ o_sub(void)
v2 = v2->v_addr;
if (v1->v_type == V_OCTET) {
w1.v_type = V_NUM;
w1.v_subtype = V_NOSUBTYPE;
w1.v_num = itoq((unsigned char) *v1->v_octet);
v1 = &w1;
}
if (v2->v_type == V_OCTET) {
w2.v_type = V_NUM;
w2.v_subtype = V_NOSUBTYPE;
w2.v_num = itoq((unsigned char) *v2->v_octet);
v2 = &w2;
}
@@ -1028,11 +1036,13 @@ o_mul(void)
v2 = v2->v_addr;
if (v1->v_type == V_OCTET) {
w1.v_type = V_NUM;
w1.v_subtype = V_NOSUBTYPE;
w1.v_num = itoq(*v1->v_octet);
v1 = &w1;
}
if (v2->v_type == V_OCTET) {
w2.v_type = V_NUM;
w2.v_subtype = V_NOSUBTYPE;
w2.v_num = itoq(*v2->v_octet);
v2 = &w2;
}
@@ -1081,11 +1091,13 @@ o_div(void)
v2 = v2->v_addr;
if (v1->v_type == V_OCTET) {
w1.v_type = V_NUM;
w1.v_subtype = V_NOSUBTYPE;
w1.v_num = itoq(*v1->v_octet);
v1 = &w1;
}
if (v2->v_type == V_OCTET) {
w2.v_type = V_NUM;
w2.v_subtype = V_NOSUBTYPE;
w2.v_num = itoq(*v2->v_octet);
v2 = &w2;
}
@@ -1113,6 +1125,7 @@ o_quo(void)
if (v2->v_type == V_ADDR)
v2 = v2->v_addr;
null.v_type = V_NULL;
null.v_subtype = V_NOSUBTYPE;
quovalue(v1, v2, &null, &tmp);
freevalue(stack--);
freevalue(stack);
@@ -1133,6 +1146,7 @@ o_mod(void)
if (v2->v_type == V_ADDR)
v2 = v2->v_addr;
null.v_type = V_NULL;
null.v_subtype = V_NOSUBTYPE;
modvalue(v1, v2, &null, &tmp);
freevalue(stack--);
freevalue(stack);
@@ -1175,7 +1189,9 @@ o_quomod(void)
}
valquo.v_type = V_NUM;
valquo.v_subtype = V_NOSUBTYPE;
valmod.v_type = V_NUM;
valmod.v_subtype = V_NOSUBTYPE;
res = qquomod(v1->v_num, v2->v_num, &valquo.v_num, &valmod.v_num);
stack -= 2;
if (stack->v_type == V_NUM)
@@ -1185,6 +1201,7 @@ o_quomod(void)
qfree(stack->v_num);
stack->v_num = (res ? qlink(&_qone_) : qlink(&_qzero_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
freevalue(v3);
freevalue(v4);
@@ -1289,6 +1306,7 @@ o_not(void)
freevalue(stack);
stack->v_num = (r ? qlink(&_qzero_) : qlink(&_qone_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1335,6 +1353,7 @@ o_negate(void)
qfree(stack->v_num);
stack->v_num = q;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
negvalue(vp, &tmp);
@@ -1440,6 +1459,7 @@ o_abs(void)
qfree(stack->v_num);
stack->v_num = q;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1459,6 +1479,7 @@ o_norm(void)
qfree(stack->v_num);
stack->v_num = q;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
normvalue(vp, &tmp);
@@ -1483,6 +1504,7 @@ o_square(void)
qfree(stack->v_num);
stack->v_num = q;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
squarevalue(vp, &tmp);
@@ -1503,6 +1525,7 @@ o_test(void)
i = testvalue(vp);
freevalue(stack);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
stack->v_num = i ? qlink(&_qone_) : qlink(&_qzero_);
}
@@ -1534,6 +1557,7 @@ o_links(void)
if (!haveaddress)
links--;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
stack->v_num = itoq(links);
}
@@ -1584,6 +1608,7 @@ o_bit (void)
stack->v_type = V_NUM;
stack->v_num = itoq(r);
}
stack->v_subtype = V_NOSUBTYPE;
}
static void
@@ -1628,6 +1653,7 @@ o_highbit (void)
return;
default:
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
stack->v_num = itoq(index);
}
}
@@ -1679,6 +1705,7 @@ o_lowbit (void)
return;
default:
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
stack->v_num = itoq(index);
}
}
@@ -1772,6 +1799,7 @@ o_istype(void)
freevalue(stack);
stack->v_num = itoq((long) r);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1788,6 +1816,7 @@ o_isint(void)
freevalue(stack);
stack->v_num = qlink(&_qzero_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
if (qisint(vp->v_num))
@@ -1798,6 +1827,7 @@ o_isint(void)
qfree(stack->v_num);
stack->v_num = q;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1822,10 +1852,12 @@ o_isnum(void)
freevalue(stack);
stack->v_num = qlink(&_qzero_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
stack->v_num = qlink(&_qone_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1841,10 +1873,12 @@ o_ismat(void)
freevalue(stack);
stack->v_num = qlink(&_qzero_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
freevalue(stack);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
stack->v_num = qlink(&_qone_);
}
@@ -1862,6 +1896,7 @@ o_islist(void)
freevalue(stack);
stack->v_num = (r ? qlink(&_qone_) : qlink(&_qzero_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1878,6 +1913,7 @@ o_isobj(void)
freevalue(stack);
stack->v_num = (r ? qlink(&_qone_) : qlink(&_qzero_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1894,6 +1930,7 @@ o_isstr(void)
freevalue(stack);
stack->v_num = (r ? qlink(&_qone_) : qlink(&_qzero_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1910,6 +1947,7 @@ o_isfile(void)
freevalue(stack);
stack->v_num = (r ? qlink(&_qone_) : qlink(&_qzero_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1926,6 +1964,7 @@ o_isrand(void)
freevalue(stack);
stack->v_num = (r ? qlink(&_qone_) : qlink(&_qzero_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1942,6 +1981,7 @@ o_israndom(void)
freevalue(stack);
stack->v_num = (r ? qlink(&_qone_) : qlink(&_qzero_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1958,6 +1998,7 @@ o_isconfig(void)
freevalue(stack);
stack->v_num = (r ? qlink(&_qone_) : qlink(&_qzero_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1976,6 +2017,7 @@ o_ishash(void)
freevalue(stack);
stack->v_num = itoq((long) r);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -1992,6 +2034,7 @@ o_isassoc(void)
freevalue(stack);
stack->v_num = (r ? qlink(&_qone_) : qlink(&_qzero_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2012,6 +2055,7 @@ o_isblock(void)
freevalue(stack);
stack->v_num = itoq(r);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2028,6 +2072,7 @@ o_isoctet(void)
freevalue(stack);
stack->v_num = itoq(r);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2050,6 +2095,7 @@ o_isptr(void)
freevalue(stack);
stack->v_num = itoq(r);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2079,6 +2125,7 @@ o_isdefined(void)
freevalue(stack);
stack->v_num = itoq(r);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2099,6 +2146,7 @@ o_isobjtype(void)
freevalue(stack);
stack->v_num = itoq(index >= 0);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2122,6 +2170,7 @@ o_issimple(void)
freevalue(stack);
stack->v_num = (r ? qlink(&_qone_) : qlink(&_qzero_));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2138,11 +2187,13 @@ o_isodd(void)
qfree(stack->v_num);
stack->v_num = qlink(&_qone_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
freevalue(stack);
stack->v_num = qlink(&_qzero_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2159,11 +2210,13 @@ o_iseven(void)
qfree(stack->v_num);
stack->v_num = qlink(&_qone_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
freevalue(stack);
stack->v_num = qlink(&_qzero_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2180,11 +2233,13 @@ o_isreal(void)
qfree(stack->v_num);
stack->v_num = qlink(&_qone_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
freevalue(stack);
stack->v_num = qlink(&_qzero_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2200,11 +2255,13 @@ o_isnull(void)
freevalue(stack);
stack->v_num = qlink(&_qzero_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
freevalue(stack);
stack->v_num = qlink(&_qone_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2221,6 +2278,7 @@ o_re(void)
if (stack->v_type == V_ADDR) {
stack->v_num = qlink(vp->v_num);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
return;
}
@@ -2233,6 +2291,7 @@ o_re(void)
comfree(stack->v_com);
stack->v_num = q;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2250,6 +2309,7 @@ o_im(void)
qfree(stack->v_num);
stack->v_num = qlink(&_qzero_);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
if (vp->v_type != V_COM) {
@@ -2261,6 +2321,7 @@ o_im(void)
comfree(stack->v_com);
stack->v_num = q;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2277,6 +2338,7 @@ o_conjugate(void)
if (stack->v_type == V_ADDR) {
stack->v_num = qlink(vp->v_num);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
return;
}
@@ -2382,6 +2444,7 @@ o_sgn(void)
qfree(vp->v_num);
stack->v_num = q;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
return;
}
sgnvalue(vp, &tmp);
@@ -2410,6 +2473,7 @@ o_numerator(void)
qfree(stack->v_num);
stack->v_num = q;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2431,6 +2495,7 @@ o_denominator(void)
qfree(stack->v_num);
stack->v_num = q;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2687,6 +2752,7 @@ o_eq(void)
freevalue(stack);
stack->v_num = itoq((long) (r == 0));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2707,6 +2773,7 @@ o_ne(void)
freevalue(stack);
stack->v_num = itoq((long) (r != 0));
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -2727,15 +2794,15 @@ o_le(void)
freevalue(stack);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
if (tmp.v_type == V_NUM) {
stack->v_num = !qispos(tmp.v_num) ? qlink(&_qone_):
qlink(&_qzero_);
}
else if (tmp.v_type == V_COM) {
} else if (tmp.v_type == V_COM) {
stack->v_num = qlink(&_qzero_);
}
else
} else {
stack->v_type = V_NULL;
}
freevalue(&tmp);
}
@@ -2756,14 +2823,13 @@ o_ge(void)
freevalue(stack--);
freevalue(stack);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
if (tmp.v_type == V_NUM) {
stack->v_num = !qisneg(tmp.v_num) ? qlink(&_qone_):
qlink(&_qzero_);
}
else if (tmp.v_type == V_COM) {
} else if (tmp.v_type == V_COM) {
stack->v_num = qlink(&_qzero_);
}
else {
} else {
stack->v_type = V_NULL;
}
freevalue(&tmp);
@@ -2786,15 +2852,15 @@ o_lt(void)
freevalue(stack--);
freevalue(stack);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
if (tmp.v_type == V_NUM) {
stack->v_num = qisneg(tmp.v_num) ? qlink(&_qone_):
qlink(&_qzero_);
}
else if (tmp.v_type == V_COM) {
} else if (tmp.v_type == V_COM) {
stack->v_num = qlink(&_qzero_);
}
else
} else {
stack->v_type = V_NULL;
}
freevalue(&tmp);
}
@@ -2815,15 +2881,15 @@ o_gt(void)
freevalue(stack--);
freevalue(stack);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
if (tmp.v_type == V_NUM) {
stack->v_num = qispos(tmp.v_num) ? qlink(&_qone_):
qlink(&_qzero_);
}
else if (tmp.v_type == V_COM) {
} else if (tmp.v_type == V_COM) {
stack->v_num = qlink(&_qzero_);
}
else
} else {
stack->v_type = V_NULL;
}
freevalue(&tmp);
}
@@ -2886,6 +2952,7 @@ o_postinc(void)
if (stack->v_type == V_OCTET) {
stack[1] = stack[0];
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
stack->v_num = itoq((long) stack->v_octet[0]);
stack++;
stack->v_octet[0]++;
@@ -2938,8 +3005,8 @@ o_postdec(void)
freevalue(vp);
*vp = tmp;
stack->v_type = V_ADDR;
stack->v_addr = vp;
stack->v_subtype = V_NOSUBTYPE;
stack->v_addr = vp;
}
@@ -3067,6 +3134,7 @@ o_zero(void)
{
stack++;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
stack->v_num = qlink(&_qzero_);
}
@@ -3076,6 +3144,7 @@ o_one(void)
{
stack++;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
stack->v_num = qlink(&_qone_);
}
@@ -3162,6 +3231,7 @@ o_getepsilon(void)
{
stack++;
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
stack->v_num = qlink(conf->epsilon);
}
@@ -3185,6 +3255,7 @@ o_setepsilon(void)
if (stack->v_type == V_NUM)
qfree(newep);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
}
@@ -3254,6 +3325,7 @@ updateoldvalue(FUNC *fp)
freevalue(&oldvalue);
oldvalue = fp->f_savedvalue;
fp->f_savedvalue.v_type = V_NULL;
fp->f_savedvalue.v_subtype = V_NOSUBTYPE;
}
@@ -3275,6 +3347,7 @@ error_value(int e)
/*NOTREACHED*/
}
res.v_type = (short) -e;
res.v_subtype = V_NOSUBTYPE;
return res;
}

10
value.c
View File

@@ -192,6 +192,7 @@ copyvalue(VALUE *oldvp, VALUE *newvp)
break;
case V_OCTET:
newvp->v_type = V_NUM;
newvp->v_subtype = V_NOSUBTYPE;
newvp->v_num = itoq((long) *oldvp->v_octet);
break;
case V_NBLOCK:
@@ -310,6 +311,7 @@ negvalue(VALUE *vp, VALUE *vres)
return;
case V_OCTET:
vres->v_type = V_NUM;
vres->v_subtype = V_NOSUBTYPE;
vres->v_num = itoq(- (long) *vp->v_octet);
return;
@@ -341,6 +343,7 @@ addnumeric(VALUE *v1, VALUE *v2, VALUE *vres)
/*
* add numeric values
*/
vres->v_subtype = V_NOSUBTYPE;
switch (TWOVAL(v1->v_type, v2->v_type)) {
case TWOVAL(V_NUM, V_NUM):
vres->v_num = qqadd(v1->v_num, v2->v_num);
@@ -2418,9 +2421,11 @@ acceptvalue(VALUE *v1, VALUE *v2)
if (fp) {
++stack;
stack->v_type = V_ADDR;
stack->v_subtype = V_NOSUBTYPE;
stack->v_addr = v1;
++stack;
stack->v_type = V_ADDR;
stack->v_subtype = V_NOSUBTYPE;
stack->v_addr = v2;
calculate(fp, 2);
ret = testvalue(stack);
@@ -2445,9 +2450,11 @@ precvalue(VALUE *v1, VALUE *v2)
if (fp) {
++stack;
stack->v_type = V_ADDR;
stack->v_subtype = V_NOSUBTYPE;
stack->v_addr = v1;
++stack;
stack->v_type = V_ADDR;
stack->v_subtype = V_NOSUBTYPE;
stack->v_addr = v2;
calculate(fp, 2);
ret = testvalue(stack);
@@ -2630,6 +2637,7 @@ sgnvalue(VALUE *vp, VALUE *vres)
switch (vp->v_type) {
case V_NUM:
vres->v_num = qsign(vp->v_num);
vres->v_subtype = vp->v_subtype;
return;
case V_COM:
c = comalloc();
@@ -2639,9 +2647,11 @@ sgnvalue(VALUE *vp, VALUE *vres)
c->imag = qsign(vp->v_com->imag);
vres->v_com = c;
vres->v_type = V_COM;
vres->v_subtype = V_NOSUBTYPE;
return;
case V_OCTET:
vres->v_type = V_NUM;
vres->v_subtype = V_NOSUBTYPE;
vres->v_num = itoq((long) (*vp->v_octet != 0));
return;
case V_OBJ:

View File

@@ -18,7 +18,7 @@ static char *program;
#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 "9.4.4" /* test number or empty string if no patch */
#define MINOR_PATCH "9.4.5" /* test number or empty string if no patch */
/*
* calc version constants

View File

@@ -733,18 +733,18 @@ done: while (m > 0 && A[m - 1] == 0)
f = g = 0;
t = -1;
if (s) {
while (--i > 0 ) {
while (--i > 0) {
g = (FULL) *--a + (*--b >> 1 | f);
if (g != BASE1)
break;
f = *b & 1 ? TOPHALF : 0;
}
if (g == BASE && f == 0) {
while (i-- && (*a-- | *b--) == 0);
while ((--i > 0) && ((*--a | *--b) == 0));
t = (i > 0);
}
else if (g >= BASE)
} else if (g >= BASE) {
t = 1;
}
} else {
while (--i > 0) {
g = (FULL) *--a - (*--b >> 1 | f);

64
zmul.c
View File

@@ -280,6 +280,8 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans)
baseA = v1 + shift;
baseB = v1;
/*
* XXX - is this still an issue?
*
* Saber-C Version 3.1 says:
*
* W#26, Storing a bad pointer into auto variable dmul`baseC.
@@ -296,11 +298,13 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans)
* config("mul2", 2);
* pmod(3,a-1,a);
*
* [[ NOTE: The above code no longer invokes this code. ]]
*
* When this code is executed, shift == 6 and v2 is 3 shorts
* long (size2 == 2). This baseC points 3 shorts beyond the
* allocated end of v2.
*
* The stack was as follows:
* The stack was as follows: [[NOTE: line numbers may have changed]]
*
* domul(v1=0x2d93d8, size1=12,
* v2=0x2ded30, size2=2, ans=0x2ee8a8) at "zmul.c":313
@@ -314,6 +318,64 @@ domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans)
* evaluate(...) at "codegen.c":170
* getcommands(...) at "codegen.c":109
* main(...) at "calc.c":167
*
* The final domul() call point is the next executable line below.
*
****
*
* The insure tool also reports a problem at this position:
*
* [zmul.c:319] **COPY_BAD_RANGE**
* >> baseC = v2 + shift;
*
* Copying pointer which is out-of-range: v2 + shift
*
* [[NOTE: line numbers may have changed]]
*
* Pointer : 0x1400919cc
* Actual block : 0x140090c80 thru 0x140090def (368 bytes,92 elements)
* hp, allocated at:
* malloc()
* alloc() zmath.c, 221
* zmul() zmul.c, 73
* ztenpow() zfunc.c, 441
* str2q() qio.c, 537
* addnumber() const.c, 52
* eatnumber() token.c, 594
* gettoken() token.c, 319
* getcallargs() codegen.c, 2358
*
* Stack trace where the error occurred:
* domul() zmul.c, 319
* zmul() zmul.c, 74
* ztenpow() zfunc.c, 441
* str2q() qio.c, 537
* addnumber() const.c, 52
* eatnumber() token.c, 594
* gettoken() token.c, 319
* getcallargs() codegen.c, 2358
* getidexpr() codegen.c, 1998
* getterm() codegen.c, 1936
* getincdecexpr() codegen.c, 1820
* getreference() codegen.c, 1804
* getshiftexpr() codegen.c, 1758
* getandexpr() codegen.c, 1704
* getorexpr() codegen.c, 1682
* getproduct() codegen.c, 1654
* getsum() codegen.c, 1626
* getrelation() codegen.c, 1585
* getandcond() codegen.c, 1556
* getorcond() codegen.c, 1532
* getaltcond() codegen.c, 1499
* getassignment() codegen.c, 1442
* getopassignment() codegen.c, 1352
* getexprlist() codegen.c, 1318
* getstatement() codegen.c, 921
* evaluate() codegen.c, 219
* getcommands() codegen.c, 165
* main() calc.c, 321
*
* The final domul() call point is the next executable line below.
*/
/* ok to ignore on name domul`baseC */
baseC = v2 + shift;

View File

@@ -2527,7 +2527,8 @@ random_libcalc_cleanup(void)
static void
zfree_random(ZVALUE z)
{
if (z.v != h_ndefvec && z.v != h_rdefvec && z.v != h_rdefvec_2 &&
if (z.v != NULL &&
z.v != h_ndefvec && z.v != h_rdefvec && z.v != h_rdefvec_2 &&
z.v != h_nvec01 && z.v != h_rvec01 &&
z.v != h_nvec02 && z.v != h_rvec02 &&
z.v != h_nvec03 && z.v != h_rvec03 &&