diff --git a/BUGS b/BUGS index a2fdbf7..fc52714 100644 --- a/BUGS +++ b/BUGS @@ -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. diff --git a/CHANGES b/CHANGES index 8489510..ee1045f 100644 --- a/CHANGES +++ b/CHANGES @@ -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 . + 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: diff --git a/README b/README index edebaf6..d01e01d 100644 --- a/README +++ b/README @@ -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/ diff --git a/addop.c b/addop.c index 6379312..61af125 100644 --- a/addop.c +++ b/addop.c @@ -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(); diff --git a/assocfunc.c b/assocfunc.c index 5cc2300..380567c 100644 --- a/assocfunc.c +++ b/assocfunc.c @@ -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); diff --git a/blkcpy.c b/blkcpy.c index 78246b2..283932b 100644 --- a/blkcpy.c +++ b/blkcpy.c @@ -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++; } diff --git a/calc.man b/calc.man index 51a3e9f..1c3124f 100644 --- a/calc.man +++ b/calc.man @@ -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: diff --git a/config.c b/config.c index 77a0751..5d1981d 100644 --- a/config.c +++ b/config.c @@ -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; diff --git a/file.c b/file.c index 970060f..c60fa90 100644 --- a/file.c +++ b/file.c @@ -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; } diff --git a/func.c b/func.c index bf3d896..d84067b 100644 --- a/func.c +++ b/func.c @@ -187,6 +187,7 @@ f_eval(VALUE *vp) curfunc = oldfunc; result = newfunc->f_savedvalue; newfunc->f_savedvalue.v_type = V_NULL; + newfunc->f_savedvalue.v_subtype = V_NOSUBTYPE; freenumbers(newfunc); if (newfunc != oldfunc) free(newfunc); @@ -199,6 +200,7 @@ f_eval(VALUE *vp) curfunc = oldfunc; freevalue(&newfunc->f_savedvalue); newfunc->f_savedvalue.v_type = V_NULL; + newfunc->f_savedvalue.v_subtype = V_NOSUBTYPE; freenumbers(newfunc); if (newfunc != oldfunc) free(newfunc); @@ -214,7 +216,10 @@ f_prompt(VALUE *vp) char *newcp; unsigned int len; + /* initialize VALUE */ result.v_type = V_STR; + result.v_subtype = V_NOSUBTYPE; + openterminal(); printvalue(vp, PRINT_SHORT); math_flush(); @@ -236,7 +241,6 @@ f_prompt(VALUE *vp) } strcpy(newcp, cp); result.v_str = makestring(newcp); - result.v_type = V_STR; return result; } @@ -247,6 +251,10 @@ f_display(int count, VALUE **vals) long oldvalue; VALUE res; + /* initialize VALUE */ + res.v_type = V_NUM; + res.v_subtype = V_NOSUBTYPE; + oldvalue = conf->outdigits; if (count > 0) { @@ -257,7 +265,6 @@ f_display(int count, VALUE **vals) else conf->outdigits = qtoi(vals[0]->v_num); } - res.v_type = V_NUM; res.v_num = itoq(oldvalue); return res; } @@ -269,7 +276,10 @@ f_null(int count, VALUE **vals) { VALUE res; - res.v_type = 0; + /* initialize VALUE */ + res.v_type = V_NULL; + res.v_subtype = V_NOSUBTYPE; + return res; } @@ -280,7 +290,10 @@ f_str(VALUE *vp) VALUE result; char *cp; + /* initialize VALUE */ result.v_type = V_STR; + result.v_subtype = V_NOSUBTYPE; + switch (vp->v_type) { case V_STR: result.v_str = stringcopy(vp->v_str); @@ -317,7 +330,10 @@ f_name(VALUE *vp) char *cp; char *name; + /* initialize VALUE */ result.v_type = V_STR; + result.v_subtype = V_NOSUBTYPE; + switch (vp->v_type) { case V_NBLOCK: result.v_type = V_STR; @@ -338,7 +354,6 @@ f_name(VALUE *vp) return result; } result.v_str = makestring(cp); - result.v_type = V_STR; return result; } @@ -351,6 +366,10 @@ f_poly(int count, VALUE **vals) VALUE result, tmp; LIST *clist, *lp; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp.v_subtype = V_NOSUBTYPE; + if (vals[0]->v_type == V_LIST) { clist = vals[0]->v_list; lp = listalloc(); @@ -929,6 +948,10 @@ f_srand(int count, VALUE **vals) { VALUE result; + /* initialize VALUE */ + result.v_type = V_RAND; + result.v_subtype = V_NOSUBTYPE; + /* parse args */ switch (count) { case 0: @@ -972,7 +995,6 @@ f_srand(int count, VALUE **vals) } /* return the current state */ - result.v_type = V_RAND; return result; } @@ -1077,6 +1099,10 @@ f_srandom(int count, VALUE **vals) { VALUE result; + /* initialize VALUE */ + result.v_type = V_RANDOM; + result.v_subtype = V_NOSUBTYPE; + /* parse args */ switch (count) { case 0: /* srandom() */ @@ -1155,7 +1181,6 @@ f_srandom(int count, VALUE **vals) } /* return the current state */ - result.v_type = V_RANDOM; return result; } @@ -1179,6 +1204,10 @@ f_setbit(int count, VALUE **vals) long index; VALUE result; + /* initialize VALUE */ + result.v_type = V_NULL; + result.v_subtype = V_NOSUBTYPE; + r = (count == 3) ? testvalue(vals[2]) : 1; if (vals[1]->v_type != V_NUM || qisfrac(vals[1]->v_num)) @@ -1190,7 +1219,6 @@ f_setbit(int count, VALUE **vals) index = qtoi(vals[1]->v_num); if (stringsetbit(vals[0]->v_str, index, r)) return error_value(E_SETBIT2); - result.v_type = V_NULL; return result; } @@ -1264,6 +1292,7 @@ f_xor(int count, VALUE **vals) type = vals[0]->v_type; result.v_type = type; + result.v_subtype = vals[0]->v_subtype; for (i = 1; i < count; i++) { if (vals[i]->v_type != type) return error_value(E_XOR1); @@ -1303,8 +1332,11 @@ minlistitems(LIST *lp) VALUE rel; VALUE min; + /* initialize VALUEs */ min.v_type = V_NULL; + min.v_subtype = V_NOSUBTYPE; term.v_type = V_NULL; + term.v_subtype = V_NOSUBTYPE; for (ep = lp->l_first; ep; ep = ep->e_next) { vp = &ep->e_value; @@ -1353,8 +1385,11 @@ maxlistitems(LIST *lp) VALUE rel; VALUE max; + /* initialize VALUEs */ max.v_type = V_NULL; + max.v_subtype = V_NOSUBTYPE; term.v_type = V_NULL; + term.v_subtype = V_NOSUBTYPE; for (ep = lp->l_first; ep; ep = ep->e_next) { vp = &ep->e_value; @@ -1402,8 +1437,11 @@ f_min(int count, VALUE **vals) VALUE *vp; VALUE rel; + /* initialize VALUEs */ min.v_type = V_NULL; + min.v_subtype = V_NOSUBTYPE; term.v_type = V_NULL; + term.v_subtype = V_NOSUBTYPE; while (count-- > 0) { vp = *vals++; @@ -1455,8 +1493,11 @@ f_max(int count, VALUE **vals) VALUE *vp; VALUE rel; + /* initialize VALUEs */ max.v_type = V_NULL; + max.v_subtype = V_NOSUBTYPE; term.v_type = V_NULL; + term.v_subtype = V_NOSUBTYPE; while (count-- > 0) { vp = *vals++; @@ -1538,11 +1579,14 @@ f_hash(int count, VALUE **vals) QCKHASH hash; VALUE result; + /* initialize VALUE */ + result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; + hash = FNV1_32_BASIS; while (count-- > 0) hash = hashvalue(*vals++, hash); result.v_num = utoq((FULL) hash); - result.v_type = V_NUM; return result; } @@ -1556,8 +1600,13 @@ sumlistitems(LIST *lp) VALUE tmp; VALUE sum; - sum.v_type = V_NULL; + /* initialize VALUEs */ term.v_type = V_NULL; + term.v_subtype = V_NOSUBTYPE; + tmp.v_type = V_NULL; + tmp.v_subtype = V_NOSUBTYPE; + sum.v_type = V_NULL; + sum.v_subtype = V_NOSUBTYPE; for (ep = lp->l_first; ep; ep = ep->e_next) { vp = &ep->e_value; @@ -1597,8 +1646,13 @@ f_sum(int count, VALUE **vals) VALUE term; VALUE *vp; + /* initialize VALUEs */ + tmp.v_type = V_NULL; + tmp.v_subtype = V_NOSUBTYPE; sum.v_type = V_NULL; + sum.v_subtype = V_NOSUBTYPE; term.v_type = V_NULL; + term.v_subtype = V_NOSUBTYPE; while (count-- > 0) { vp = *vals++; @@ -1642,7 +1696,14 @@ f_avg(int count, VALUE **vals) VALUE div; long n; + /* initialize VALUEs */ + tmp.v_type = V_NULL; + tmp.v_subtype = V_NOSUBTYPE; sum.v_type = V_NULL; + sum.v_subtype = V_NOSUBTYPE; + div.v_type = V_NULL; + div.v_subtype = V_NOSUBTYPE; + n = 0; while (count-- > 0) { if ((*vals)->v_type == V_LIST) { @@ -1661,6 +1722,7 @@ f_avg(int count, VALUE **vals) return sum; div.v_num = itoq(n); div.v_type = V_NUM; + div.v_subtype = V_NOSUBTYPE; divvalue(&sum, &div, &tmp); freevalue(&sum); qfree(div.v_num); @@ -1673,6 +1735,10 @@ f_fact(VALUE *vp) { VALUE res; + /* initialize VALUE */ + res.v_type = V_NUM; + res.v_subtype = V_NOSUBTYPE; + if (vp->v_type == V_OBJ) { return objcall(OBJ_FACT, vp, NULL_VALUE, NULL_VALUE); } @@ -1680,7 +1746,6 @@ f_fact(VALUE *vp) math_error("Non-real argument for fact()"); /*NOTREACHED*/ } - res.v_type = V_NUM; res.v_num = qfact(vp->v_num); return res; } @@ -1692,7 +1757,14 @@ f_hmean(int count, VALUE **vals) VALUE sum, tmp1, tmp2; long n = 0; + /* initialize VALUEs */ sum.v_type = V_NULL; + sum.v_subtype = V_NOSUBTYPE; + tmp1.v_type = V_NULL; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_type = V_NULL; + tmp2.v_subtype = V_NOSUBTYPE; + while (count-- > 0) { if ((*vals)->v_type == V_LIST) { addlistinv((*vals)->v_list, &sum); @@ -1709,6 +1781,7 @@ f_hmean(int count, VALUE **vals) if (n == 0) return sum; tmp1.v_type = V_NUM; + tmp1.v_subtype = V_NOSUBTYPE; tmp1.v_num = itoq(n); divvalue(&tmp1, &sum, &tmp2); qfree(tmp1.v_num); @@ -1762,6 +1835,11 @@ f_ssq(int count, VALUE **vals) { VALUE result, tmp1, tmp2; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_subtype = V_NOSUBTYPE; + squarevalue(*vals++, &result); while (--count > 0) { squarevalue(*vals++, &tmp1); @@ -1800,6 +1878,9 @@ f_exp(int count, VALUE **vals) NUMBER *err; COMPLEX *c; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -1835,6 +1916,9 @@ f_ln(int count, VALUE **vals) COMPLEX ctmp, *c; NUMBER *err; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM) @@ -1877,6 +1961,9 @@ f_cos(int count, VALUE **vals) COMPLEX *c; NUMBER *err; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -1912,6 +1999,9 @@ f_sin(int count, VALUE **vals) COMPLEX *c; NUMBER *err; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -1947,6 +2037,11 @@ f_tan(int count, VALUE **vals) VALUE tmp1, tmp2; NUMBER *err; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -1980,6 +2075,10 @@ f_sec(int count, VALUE **vals) VALUE tmp; NUMBER *err; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2011,6 +2110,11 @@ f_cot(int count, VALUE **vals) VALUE tmp1, tmp2; NUMBER *err; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2047,6 +2151,10 @@ f_csc(int count, VALUE **vals) VALUE tmp; NUMBER *err; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2079,6 +2187,9 @@ f_sinh(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2113,6 +2224,9 @@ f_cosh(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2148,6 +2262,11 @@ f_tanh(int count, VALUE **vals) VALUE tmp1, tmp2; NUMBER *err; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2182,6 +2301,11 @@ f_coth(int count, VALUE **vals) VALUE tmp1, tmp2; NUMBER *err; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2218,6 +2342,10 @@ f_sech(int count, VALUE **vals) VALUE tmp; NUMBER *err; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2249,6 +2377,10 @@ f_csch(int count, VALUE **vals) VALUE tmp; NUMBER *err; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2282,6 +2414,9 @@ f_atan(int count, VALUE **vals) COMPLEX *tmp; NUMBER *err; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2319,6 +2454,9 @@ f_acot(int count, VALUE **vals) COMPLEX *tmp; NUMBER *err; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2356,6 +2494,9 @@ f_asin(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2399,6 +2540,9 @@ f_acos(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2443,6 +2587,9 @@ f_asec(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2493,6 +2640,9 @@ f_acsc(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2542,6 +2692,9 @@ f_asinh(int count, VALUE **vals) COMPLEX *tmp; NUMBER *err; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2578,6 +2731,9 @@ f_acosh(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2622,6 +2778,9 @@ f_atanh(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2670,6 +2829,9 @@ f_acoth(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2718,6 +2880,9 @@ f_asech(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2768,6 +2933,9 @@ f_acsch(int count, VALUE **vals) NUMBER *err; NUMBER *q; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2818,6 +2986,9 @@ f_gd(int count, VALUE **vals) NUMBER *q; COMPLEX *tmp; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2864,6 +3035,9 @@ f_agd(int count, VALUE **vals) NUMBER *q; COMPLEX *tmp; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2909,6 +3083,9 @@ f_arg(int count, VALUE **vals) COMPLEX *c; NUMBER *err; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + err = conf->epsilon; if (count == 2) { if (vals[1]->v_type != V_NUM || qiszero(vals[1]->v_num)) @@ -2961,6 +3138,11 @@ f_bround(int count, VALUE **vals) { VALUE tmp1, tmp2, res; + /* initialize VALUEs */ + res.v_subtype = V_NOSUBTYPE; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_subtype = V_NOSUBTYPE; + if (count > 2) tmp2 = *vals[2]; else @@ -2979,6 +3161,11 @@ f_appr(int count, VALUE **vals) { VALUE tmp1, tmp2, res; + /* initialize VALUEs */ + res.v_subtype = V_NOSUBTYPE; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_subtype = V_NOSUBTYPE; + if (count > 2) copyvalue(vals[2], &tmp2); else @@ -2998,6 +3185,11 @@ f_round(int count, VALUE **vals) { VALUE tmp1, tmp2, res; + /* initialize VALUEs */ + res.v_subtype = V_NOSUBTYPE; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_subtype = V_NOSUBTYPE; + if (count > 2) tmp2 = *vals[2]; else @@ -3028,6 +3220,10 @@ f_quo(int count, VALUE **vals) { VALUE tmp, res; + /* initialize VALUEs */ + res.v_subtype = V_NOSUBTYPE; + tmp.v_subtype = V_NOSUBTYPE; + if (count > 2) tmp = *vals[2]; else @@ -3042,6 +3238,10 @@ f_mod(int count, VALUE **vals) { VALUE tmp, res; + /* initialize VALUEs */ + res.v_subtype = V_NOSUBTYPE; + tmp.v_subtype = V_NOSUBTYPE; + if (count > 2) tmp = *vals[2]; else @@ -3056,6 +3256,10 @@ f_mmin(VALUE *v1, VALUE *v2) { VALUE sixteen, res; + /* initialize VALUEs */ + sixteen.v_subtype = V_NOSUBTYPE; + res.v_subtype = V_NOSUBTYPE; + sixteen.v_type = V_NUM; sixteen.v_num = itoq(16); modvalue(v1, v2, &sixteen, &res); @@ -3104,6 +3308,10 @@ f_ceil(VALUE *val) { VALUE tmp, res; + /* initialize VALUEs */ + res.v_subtype = V_NOSUBTYPE; + tmp.v_subtype = V_NOSUBTYPE; + tmp.v_type = V_NUM; tmp.v_num = &_qone_; apprvalue(val, &tmp, &tmp, &res); @@ -3116,6 +3324,11 @@ f_floor(VALUE *val) { VALUE tmp1, tmp2, res; + /* initialize VALUEs */ + res.v_subtype = V_NOSUBTYPE; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_subtype = V_NOSUBTYPE; + tmp1.v_type = V_NUM; tmp1.v_num = &_qone_; tmp2.v_type = V_NUM; @@ -3130,6 +3343,11 @@ f_sqrt(int count, VALUE **vals) { VALUE tmp1, tmp2, result; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + tmp1.v_subtype = V_NOSUBTYPE; + tmp2.v_subtype = V_NOSUBTYPE; + if (count > 2) tmp2 = *vals[2]; else @@ -3148,6 +3366,10 @@ f_root(int count, VALUE **vals) { VALUE *vp, err, result; + /* initialize VALUEs */ + err.v_subtype = V_NOSUBTYPE; + result.v_subtype = V_NOSUBTYPE; + if (count > 2) vp = vals[2]; else { @@ -3165,6 +3387,10 @@ f_power(int count, VALUE **vals) { VALUE *vp, err, result; + /* initialize VALUEs */ + err.v_subtype = V_NOSUBTYPE; + result.v_subtype = V_NOSUBTYPE; + if (count > 2) vp = vals[2]; else { @@ -3183,6 +3409,10 @@ f_polar(int count, VALUE **vals) VALUE *vp, err, result; COMPLEX *c; + /* initialize VALUEs */ + err.v_subtype = V_NOSUBTYPE; + result.v_subtype = V_NOSUBTYPE; + if (count > 2) vp = vals[2]; else { @@ -3242,6 +3472,9 @@ f_matfill(int count, VALUE **vals) VALUE *v1, *v2, *v3; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + v1 = vals[0]; v2 = vals[1]; if (v1->v_type != V_ADDR) @@ -3275,6 +3508,9 @@ f_matsum(VALUE *vp) { VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + /* firewall */ if (vp->v_type != V_MAT) return error_value(E_MATSUM); @@ -3290,7 +3526,10 @@ f_isident(VALUE *vp) { VALUE result; + /* initialize VALUEs */ result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type == V_MAT) { result.v_num = itoq((long) matisident(vp->v_mat)); } else { @@ -3314,6 +3553,9 @@ f_mattrans(VALUE *vp) { VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_MAT) return error_value(E_MATTRANS1); if (vp->v_mat->m_dim != 2) @@ -3346,7 +3588,9 @@ f_matdim(VALUE *vp) { VALUE result; + /* initialize VALUEs */ result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; switch(vp->v_type) { case V_OBJ: @@ -3369,6 +3613,9 @@ f_matmin(VALUE *v1, VALUE *v2) NUMBER *q; long i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_MAT) return error_value(E_MATMIN1); if (v2->v_type != V_NUM) @@ -3392,6 +3639,9 @@ f_matmax(VALUE *v1, VALUE *v2) NUMBER *q; long i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_MAT) return error_value(E_MATMAX1); if (v2->v_type != V_NUM) @@ -3414,6 +3664,9 @@ f_cp(VALUE *v1, VALUE *v2) MATRIX *m1, *m2; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if ((v1->v_type != V_MAT) || (v2->v_type != V_MAT)) return error_value(E_CP1); m1 = v1->v_mat; @@ -3452,6 +3705,9 @@ f_strlen(VALUE *vp) long len = 0; char *c; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_STR) return error_value(E_STRLEN); c = vp->v_str->s_str; @@ -3469,6 +3725,9 @@ f_strcmp(VALUE *v1, VALUE *v2) unsigned char *c1, *c2; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_STR || v2->v_type != V_STR) return error_value(E_STRCMP); @@ -3494,6 +3753,9 @@ f_strncmp(VALUE *v1, VALUE *v2, VALUE *v3) long i; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_STR || v2->v_type != V_STR || v3->v_type != V_NUM || qisneg(v3->v_num) || qisfrac(v3->v_num) || zge31b(v3->v_num->num)) @@ -3523,6 +3785,9 @@ f_strcat(int count, VALUE **vals) long len; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + len = 0; result.v_type = V_STR; vp = vals; @@ -3560,6 +3825,9 @@ f_strcpy(VALUE *v1, VALUE *v2) { VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_STR || v2->v_type != V_STR) return error_value(E_STRCPY); result.v_str = stringcpy(v1->v_str, v2->v_str); @@ -3574,6 +3842,9 @@ f_strncpy(VALUE *v1, VALUE *v2, VALUE *v3) VALUE result; long num; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_STR || v2->v_type != V_STR || v3->v_type != V_NUM || qisfrac(v3->v_num) || qisneg(v3->v_num)) return error_value(E_STRNCPY); @@ -3596,6 +3867,9 @@ f_substr(VALUE *v1, VALUE *v2, VALUE *v3) char *ccp; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_STR) return error_value(E_SUBSTR1); if ((v2->v_type != V_NUM) || (v3->v_type != V_NUM)) @@ -3637,6 +3911,9 @@ f_char(VALUE *vp) char ch; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + switch(vp->v_type) { case V_NUM: if (qisfrac(vp->v_num)) @@ -3666,6 +3943,9 @@ f_ord(VALUE *vp) OCTET *c; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + switch(vp->v_type) { case V_STR: c = (OCTET *)vp->v_str->s_str; @@ -3691,8 +3971,10 @@ f_protect(int count, VALUE **vals) VALUE result; BOOL have_nblock; - result.v_subtype = V_NOSUBTYPE; + /* initialize VALUE */ result.v_type = V_NULL; + result.v_subtype = V_NOSUBTYPE; + v1 = vals[0]; have_nblock = (v1->v_type == V_NBLOCK); if (!have_nblock) { @@ -3736,6 +4018,9 @@ f_size(VALUE *vp) { VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + /* * return information about the number of elements * @@ -3761,13 +4046,16 @@ f_sizeof(VALUE *vp) { VALUE result; + /* initialize VALUE */ + result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; + /* * return information about memory footprint * * This is not the number of elements, see f_size() for that info. * This is not the memsize, see f_memsize() for that information. */ - result.v_type = V_NUM; result.v_num = itoq(lsizeof(vp)); return result; } @@ -3778,13 +4066,16 @@ f_memsize(VALUE *vp) { VALUE result; + /* initialize VALUE */ + result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; + /* * return information about memory footprint * * This is not the number of elements, see f_size() for that info. * This is not the sizeof, see f_sizeof() for that information. */ - result.v_type = V_NUM; result.v_num = itoq(memsize(vp)); return result; } @@ -3805,6 +4096,10 @@ f_search(int count, VALUE **vals) long l_start = 0, l_end = 0; int i = 0; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + vsize.v_subtype = V_NOSUBTYPE; + v1 = *vals++; v2 = *vals++; if ((v1->v_type == V_FILE || v1->v_type == V_STR) && @@ -3967,6 +4262,10 @@ f_rsearch(int count, VALUE **vals) long l_start = 0, l_end = 0; int i; + /* initialize VALUEs */ + vsize.v_subtype = V_NOSUBTYPE; + result.v_subtype = V_NOSUBTYPE; + v1 = *vals++; v2 = *vals++; if ((v1->v_type == V_FILE || v1->v_type == V_STR) && @@ -4140,7 +4439,10 @@ f_list(int count, VALUE **vals) { VALUE result; + /* initialize VALUE */ result.v_type = V_LIST; + result.v_subtype = V_NOSUBTYPE; + result.v_list = listalloc(); while (count-- > 0) insertlistlast(result.v_list, *vals++); @@ -4154,8 +4456,10 @@ f_assoc(int count, VALUE **vals) { VALUE result; + /* initialize VALUE */ result.v_type = V_ASSOC; result.v_subtype = V_NOSUBTYPE; + result.v_assoc = assocalloc(0L); return result; } @@ -4168,6 +4472,9 @@ f_listinsert(int count, VALUE **vals) VALUE result; long pos; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + v1 = *vals++; if ((v1->v_type != V_ADDR) || (v1->v_addr->v_type != V_LIST)) return error_value(E_INSERT1); @@ -4199,6 +4506,9 @@ f_listpush(int count, VALUE **vals) VALUE result; VALUE *v1, *v2; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + v1 = *vals++; if ((v1->v_type != V_ADDR) || (v1->v_addr->v_type != V_LIST)) return error_value(E_PUSH); @@ -4223,6 +4533,9 @@ f_listappend(int count, VALUE **vals) VALUE *v1, *v2; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + v1 = *vals++; if ((v1->v_type != V_ADDR) || (v1->v_addr->v_type != V_LIST)) return error_value(E_APPEND); @@ -4246,6 +4559,9 @@ f_listdelete(VALUE *v1, VALUE *v2) { VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if ((v1->v_type != V_ADDR) || (v1->v_addr->v_type != V_LIST)) return error_value(E_DELETE1); if (v1->v_addr->v_subtype & V_NOREALLOC) { @@ -4266,6 +4582,9 @@ f_listpop(VALUE *vp) { VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if ((vp->v_type != V_ADDR) || (vp->v_addr->v_type != V_LIST)) return error_value(E_POP); if (vp->v_addr->v_subtype & V_NOREALLOC) { @@ -4282,6 +4601,9 @@ f_listremove(VALUE *vp) { VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if ((vp->v_type != V_ADDR) || (vp->v_addr->v_type != V_LIST)) return error_value(E_REMOVE); if (vp->v_addr->v_subtype & V_NOREALLOC) { @@ -4327,6 +4649,9 @@ f_ctime(void) char *str; VALUE res; + /* initialize VALUE */ + res.v_subtype = V_NOSUBTYPE; + str = (char *) malloc(26); if (str == NULL) { math_error("No memory for ctime()"); @@ -4348,6 +4673,9 @@ f_fopen(VALUE *v1, VALUE *v2) FILEID id; char *mode; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_STR || v2->v_type != V_STR) return error_value(E_FOPEN1); mode = v2->v_str->s_str; @@ -4379,6 +4707,9 @@ f_freopen(int count, VALUE **vals) FILEID id; char *mode; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vals[0]->v_type != V_FILE) return error_value(E_FREOPEN1); if (vals[1]->v_type != V_STR) @@ -4418,9 +4749,11 @@ f_errno(int count, VALUE **vals) VALUE *vp; VALUE result; - newerr = -1; + /* initialize VALUE */ result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; + newerr = -1; if (count > 0) { vp = vals[0]; @@ -4454,6 +4787,9 @@ f_errcount(int count, VALUE **vals) VALUE *vp; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + newcount = -1; if (count > 0) { vp = vals[0]; @@ -4481,6 +4817,9 @@ f_errmax(int count, VALUE **vals) VALUE *vp; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + oldmax = errmax; if (count > 0) { vp = vals[0]; @@ -4506,6 +4845,9 @@ f_stoponerror(int count, VALUE **vals) VALUE *vp; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + oldval = stoponerror; if (count > 0) { vp = vals[0]; @@ -4530,6 +4872,9 @@ f_fclose(int count, VALUE **vals) VALUE *vp; int n, i=0; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + errno = 0; if (count == 0) { i = closeall(); @@ -4561,6 +4906,9 @@ f_rm(int count, VALUE **vals) int i; int j; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + /* * firewall */ @@ -4635,6 +4983,9 @@ f_strerror(int count, VALUE **vals) long i; char *cp; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + /* parse args */ if (count > 0) { vp = vals[0]; @@ -4696,6 +5047,9 @@ f_ferror(VALUE *vp) VALUE result; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_FILE) return error_value(E_FERROR1); i = errorid(vp->v_file); @@ -4713,6 +5067,9 @@ f_feof(VALUE *vp) VALUE result; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_FILE) return error_value(E_FEOF1); i = eofid(vp->v_file); @@ -4730,6 +5087,9 @@ f_fflush(int count, VALUE **vals) VALUE result; int i, n; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + i = 0; errno = 0; if (count == 0) @@ -4783,6 +5143,9 @@ f_iserror(VALUE *vp) { VALUE res; + /* initialize VALUE */ + res.v_subtype = V_NOSUBTYPE; + res.v_type = V_NUM; res.v_num = itoq((long)((vp->v_type < 0) ? - vp->v_type : 0)); return res; @@ -4796,6 +5159,9 @@ f_fsize(VALUE *vp) ZVALUE len; /* file length */ int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_FILE) return error_value(E_FSIZE1); i = getsize(vp->v_file, &len); @@ -4817,6 +5183,9 @@ f_fseek(int count, VALUE **vals) int whence; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + /* firewalls */ errno = 0; if (vals[0]->v_type != V_FILE) @@ -4853,6 +5222,9 @@ f_ftell(VALUE *vp) ZVALUE pos; /* current file position */ int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + errno = 0; if (vp->v_type != V_FILE) return error_value(E_FTELL1); @@ -4873,6 +5245,9 @@ f_rewind(int count, VALUE **vals) VALUE result; int n; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (count == 0) rewindall(); @@ -4898,6 +5273,9 @@ f_fprintf(int count, VALUE **vals) VALUE result; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vals[0]->v_type != V_FILE) return error_value(E_FPRINTF1); if (vals[1]->v_type != V_STR) @@ -4920,6 +5298,10 @@ strscan(char *s, int count, VALUE **vals) VALUE val, result; VALUE *var; + /* initialize VALUEs */ + val.v_subtype = V_NOSUBTYPE; + result.v_subtype = V_NOSUBTYPE; + val.v_type = V_STR; while (*s != '\0') { s--; @@ -4961,7 +5343,10 @@ filescan(FILEID id, int count, VALUE **vals) VALUE result; VALUE *var; + /* initialize VALUEs */ val.v_type = V_STR; + val.v_subtype = V_NOSUBTYPE; + result.v_subtype = V_NOSUBTYPE; while (count-- > 0) { @@ -4992,6 +5377,9 @@ f_scan(int count, VALUE **vals) VALUE result; int i; + /* initialize VALUEs */ + result.v_subtype = V_NOSUBTYPE; + cp = nextline(); if (cp == NULL) { result.v_type = V_NULL; @@ -4999,7 +5387,6 @@ f_scan(int count, VALUE **vals) } i = strscan(cp, count, vals); - result.v_type = V_NUM; result.v_num = itoq((long) i); return result; @@ -5013,6 +5400,9 @@ f_strscan(int count, VALUE **vals) VALUE result; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + vp = *vals; if (vp->v_type == V_ADDR) vp = vp->v_addr; @@ -5034,6 +5424,9 @@ f_fscan(int count, VALUE **vals) VALUE result; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + errno = 0; vp = *vals; if (vp->v_type == V_ADDR) @@ -5061,6 +5454,9 @@ f_scanf(int count, VALUE **vals) VALUE result; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + vp = *vals; if (vp->v_type == V_ADDR) vp = vp->v_addr; @@ -5086,6 +5482,9 @@ f_strscanf(int count, VALUE **vals) VALUE result; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + errno = 0; vp = vals[0]; if (vp->v_type == V_ADDR) @@ -5120,6 +5519,9 @@ f_fscanf(int count, VALUE **vals) VALUE result; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + vp = *vals++; if (vp->v_type == V_ADDR) vp = vp->v_addr; @@ -5155,6 +5557,9 @@ f_fputc(VALUE *v1, VALUE *v2) int ch; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_FILE) return error_value(E_FPUTC1); switch (v2->v_type) { @@ -5189,6 +5594,9 @@ f_fputs(int count, VALUE **vals) VALUE result; int i, err; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vals[0]->v_type != V_FILE) return error_value(E_FPUTS1); for (i = 1; i < count; i++) { @@ -5211,6 +5619,9 @@ f_fputstr(int count, VALUE **vals) VALUE result; int i, err; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vals[0]->v_type != V_FILE) return error_value(E_FPUTSTR1); for (i = 1; i < count; i++) { @@ -5234,6 +5645,9 @@ f_printf(int count, VALUE **vals) VALUE result; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vals[0]->v_type != V_STR) return error_value(E_PRINTF1); i = idprintf(FILEID_STDOUT, vals[0]->v_str->s_str, @@ -5252,6 +5666,9 @@ f_strprintf(int count, VALUE **vals) int i; char *cp; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vals[0]->v_type != V_STR) return error_value(E_STRPRINTF1); math_divertio(); @@ -5275,6 +5692,9 @@ f_fgetc(VALUE *vp) VALUE result; int ch; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_FILE) return error_value(E_FGETC1); ch = getcharid(vp->v_file); @@ -5297,6 +5717,9 @@ f_ungetc(VALUE *v1, VALUE *v2) int ch; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + errno = 0; if (v1->v_type != V_FILE) return error_value(E_UNGETC1); @@ -5331,6 +5754,9 @@ f_fgetline(VALUE *vp) char *str; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_FILE) return error_value(E_FGETLINE1); i = readid(vp->v_file, 9, &str); @@ -5352,6 +5778,9 @@ f_fgets(VALUE *vp) char *str; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_FILE) return error_value(E_FGETS1); i = readid(vp->v_file, 1, &str); @@ -5373,6 +5802,9 @@ f_fgetstr(VALUE *vp) char *str; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_FILE) return error_value(E_FGETSTR1); i = readid(vp->v_file, 10, &str); @@ -5394,6 +5826,9 @@ f_fgetfield(VALUE *vp) char *str; int i; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_FILE) return error_value(E_FGETWORD1); i = readid(vp->v_file, 14, &str); @@ -5413,6 +5848,9 @@ f_files(int count, VALUE **vals) { VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (count == 0) { result.v_type = V_NUM; result.v_num = itoq((long) MAXFILES); @@ -5433,6 +5871,9 @@ f_reverse(VALUE *val) { VALUE res; + /* initialize VALUE */ + res.v_subtype = V_NOSUBTYPE; + res.v_type = val->v_type; switch(val->v_type) { case V_MAT: @@ -5461,6 +5902,9 @@ f_sort(VALUE *val) { VALUE res; + /* initialize VALUE */ + res.v_subtype = V_NOSUBTYPE; + res.v_type = val->v_type; switch (val->v_type) { case V_MAT: @@ -5486,6 +5930,9 @@ f_join(int count, VALUE **vals) LISTELEM *ep; VALUE res; + /* initialize VALUE */ + res.v_subtype = V_NOSUBTYPE; + lp = listalloc(); while (count-- > 0) { if (vals[0]->v_type != V_LIST) { @@ -5510,6 +5957,9 @@ f_head(VALUE *v1, VALUE *v2) VALUE res; long n; + /* initialize VALUE */ + res.v_subtype = V_NOSUBTYPE; + if (v2->v_type != V_NUM || qisfrac(v2->v_num) || zge31b(v2->v_num->num)) return error_value(E_HEAD2); @@ -5547,6 +5997,9 @@ f_tail(VALUE *v1, VALUE *v2) long n; VALUE res; + /* initialize VALUE */ + res.v_subtype = V_NOSUBTYPE; + if (v2->v_type != V_NUM || qisfrac(v2->v_num) || zge31b(v2->v_num->num)) return error_value(E_TAIL1); @@ -5594,6 +6047,9 @@ f_segment(int count, VALUE **vals) long n1, n2; VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + vp = vals[1]; if (vp->v_type != V_NUM || qisfrac(vp->v_num) || zge31b(vp->v_num->num)) @@ -5633,6 +6089,9 @@ f_modify(VALUE *v1, VALUE *v2) VALUE res; VALUE *vp; + /* initialize VALUE */ + res.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_ADDR) { math_error("Non-variable first argument for modify"); /*NOTREACHED*/ @@ -5684,6 +6143,10 @@ f_forall(VALUE *v1, VALUE *v2) VALUE res; VALUE *vp; + /* initialize VALUE */ + res.v_type = V_NULL; + res.v_subtype = V_NOSUBTYPE; + if (v2->v_type != V_STR) { math_error("Non-string second argument for forall"); /*NOTREACHED*/ @@ -5714,7 +6177,6 @@ f_forall(VALUE *v1, VALUE *v2) math_error("Non list or matrix first argument for forall"); /*NOTREACHED*/ } - res.v_type = V_NULL; return res; } @@ -5727,6 +6189,10 @@ f_select(VALUE *v1, VALUE *v2) FUNC *fp; VALUE res; + /* initialize VALUE */ + res.v_type = V_LIST; + res.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_LIST) { math_error("Non-list first argument for select"); /*NOTREACHED*/ @@ -5748,7 +6214,6 @@ f_select(VALUE *v1, VALUE *v2) insertlistlast(lp, &ep->e_value); freevalue(stack--); } - res.v_type = V_LIST; res.v_list = lp; return res; } @@ -5764,6 +6229,10 @@ f_count(VALUE *v1, VALUE *v2) VALUE res; VALUE *vp; + /* initialize VALUE */ + res.v_type = V_NUM; + res.v_subtype = V_NOSUBTYPE; + if (v2->v_type != V_STR) { math_error("Non-string second argument for select"); /*NOTREACHED*/ @@ -5798,7 +6267,6 @@ f_count(VALUE *v1, VALUE *v2) math_error("Bad argument type for count"); /*NOTREACHED*/ } - res.v_type = V_NUM; res.v_num = itoq(n); return res; } @@ -5811,6 +6279,10 @@ f_makelist(VALUE *v1) VALUE res; long n; + /* initialize VALUE */ + res.v_type = V_NULL; + res.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_NUM || qisfrac(v1->v_num) || qisneg(v1->v_num)) { math_error("Bad argument for makelist"); /*NOTREACHED*/ @@ -5821,8 +6293,6 @@ f_makelist(VALUE *v1) } n = qtoi(v1->v_num); lp = listalloc(); - res.v_type = V_NULL; - res.v_subtype = V_NOSUBTYPE; while (n-- > 0) insertlistlast(lp, &res); res.v_type = V_LIST; @@ -5836,6 +6306,9 @@ f_randperm(VALUE *val) { VALUE res; + /* initialize VALUE */ + res.v_subtype = V_NOSUBTYPE; + res.v_type = val->v_type; switch (val->v_type) { case V_MAT: @@ -5860,9 +6333,12 @@ f_cmdbuf(void) VALUE result; char *newcp; + /* initialize VALUE */ + result.v_type = V_STR; + result.v_subtype = V_NOSUBTYPE; + newcp = (char *)malloc(strlen(cmdbuf) + 1); strcpy(newcp, cmdbuf); - result.v_type = V_STR; result.v_str = makestring(newcp); return result; } @@ -5874,6 +6350,9 @@ f_getenv(VALUE *v1) VALUE result; char *str; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (v1->v_type != V_STR) { math_error("Non-string argument for getenv"); /*NOTREACHED*/ @@ -5893,6 +6372,9 @@ f_isatty(VALUE *vp) { VALUE result; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + result.v_type = V_NUM; if (vp->v_type == V_FILE && isattyid(vp->v_file) == 1) { result.v_num = itoq(1); @@ -5908,7 +6390,10 @@ f_inputlevel (void) { VALUE result; + /* initialize VALUE */ result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; + result.v_num = itoq((long) inputlevel()); return result; } @@ -5919,7 +6404,10 @@ f_calclevel (void) { VALUE result; + /* initialize VALUE */ result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; + result.v_num = itoq(calclevel()); return result; } @@ -5934,6 +6422,10 @@ f_access(int count, VALUE **vals) VALUE result; long i; + /* initialize VALUE */ + result.v_type = V_NULL; + result.v_subtype = V_NOSUBTYPE; + errno = 0; if (vals[0]->v_type != V_STR) return error_value(E_ACCESS1); @@ -5968,7 +6460,6 @@ f_access(int count, VALUE **vals) i = access(fname, m); if (i) return error_value(errno); - result.v_type = V_NULL; return result; } @@ -5979,6 +6470,10 @@ f_putenv(int count, VALUE **vals) VALUE result; char *putenv_str; + /* initialize VALUE */ + result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; + /* * parse args */ @@ -6026,7 +6521,6 @@ f_putenv(int count, VALUE **vals) } /* return putenv result */ - result.v_type = V_NUM; result.v_num = itoq((long) malloced_putenv(putenv_str)); return result; } @@ -6039,11 +6533,14 @@ f_strpos(VALUE *haystack, VALUE *needle) char *cpointer; int cindex; + /* initialize VALUE */ + result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; + if (haystack->v_type != V_STR || needle->v_type != V_STR) { math_error("Non-string argument for index"); /*NOTREACHED*/ } - result.v_type = V_NUM; cpointer = strstr(haystack->v_str->s_str, needle->v_str->s_str); if (cpointer == NULL) @@ -6060,6 +6557,10 @@ f_system(VALUE *vp) { VALUE result; + /* initialize VALUE */ + result.v_type = V_NUM; + result.v_subtype = V_NOSUBTYPE; + if (vp->v_type != V_STR) { math_error("Non-string argument for system"); /*NOTREACHED*/ @@ -6068,7 +6569,6 @@ f_system(VALUE *vp) math_error("execution disallowed by -m"); /*NOTREACHED*/ } - result.v_type = V_NUM; if (conf->calc_debug & CALCDBG_SYSTEM) { printf("%s\n", vp->v_str->s_str); } @@ -6205,9 +6705,12 @@ base_value(long mode) static VALUE f_custom(int count, VALUE **vals) { - VALUE result; + /* initialize VALUE */ + result.v_type = V_NULL; + result.v_subtype = V_NOSUBTYPE; + /* * disable custom functions unless -C was given */ @@ -6229,7 +6732,6 @@ f_custom(int count, VALUE **vals) if (count <= 0) { /* perform the usage function function */ showcustom(); - result.v_type = V_NULL; } else { /* firewall */ if (vals[0]->v_type != V_STR) { @@ -6258,6 +6760,10 @@ f_blk(int count, VALUE **vals) VALUE *vp; int type; + /* initialize VALUE */ + result.v_type = V_BLOCK; + result.v_subtype = V_NOSUBTYPE; + vp = *vals; type = 0; result.v_subtype = V_NOSUBTYPE; @@ -6318,7 +6824,6 @@ f_blk(int count, VALUE **vals) /* allocate block */ result.v_block = blkalloc(len, chunk); - result.v_type = V_BLOCK; return result; } @@ -6329,6 +6834,10 @@ f_blkfree(VALUE *vp) int id; VALUE result; + /* initialize VALUE */ + result.v_type = V_NULL; + result.v_subtype = V_NOSUBTYPE; + id = 0; switch (vp->v_type) { case V_NBLOCK: @@ -6352,7 +6861,6 @@ f_blkfree(VALUE *vp) id = removenblock(id); if (id) return error_value(id); - result.v_type = V_NULL; return result; } @@ -6364,6 +6872,9 @@ f_blocks(int count, VALUE **vals) VALUE result; int id; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + if (count == 0) { result.v_type = V_NUM; result.v_num = itoq((long) countnblocks()); @@ -6391,6 +6902,9 @@ f_free(int count, VALUE **vals) VALUE result; VALUE *val; + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + result.v_type = V_NULL; while (count-- > 0) { val = *vals++; @@ -6405,8 +6919,11 @@ f_freeglobals(void) { VALUE result; - freeglobals(); + /* initialize VALUE */ result.v_type = V_NULL; + result.v_subtype = V_NOSUBTYPE; + + freeglobals(); return result; } @@ -6414,8 +6931,12 @@ static VALUE f_freeredc(void) { VALUE result; - freeredcdata(); + + /* initialize VALUE */ result.v_type = V_NULL; + result.v_subtype = V_NOSUBTYPE; + + freeredcdata(); return result; } @@ -6425,8 +6946,11 @@ f_freestatics(void) { VALUE result; - freestatics(); + /* initialize VALUE */ result.v_type = V_NULL; + result.v_subtype = V_NOSUBTYPE; + + freestatics(); return result; } @@ -6448,6 +6972,10 @@ f_copy(int count, VALUE **vals) int errtype; /* error type if unable to perform copy */ VALUE result; /* null if successful */ + /* initialize VALUE */ + result.v_type = V_NULL; + result.v_subtype = V_NOSUBTYPE; + /* * parse args */ @@ -6504,7 +7032,6 @@ f_copy(int count, VALUE **vals) errtype = copystod(vals[0], ssi, num, vals[1], dsi); if (errtype > 0) return error_value(errtype); - result.v_type = V_NULL; return result; } @@ -6523,6 +7050,9 @@ f_blkcpy(int count, VALUE **vals) VALUE *args[5]; /* args to re-order */ VALUE null_value; /* dummy argument */ + /* initialize VALUE */ + null_value.v_subtype = V_NOSUBTYPE; + /* * parse args into f_copy order */ @@ -6563,6 +7093,9 @@ f_sha(int count, VALUE **vals) HASH *state; /* pointer to hash state to use */ int i; /* vals[i] to hash */ + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + state = NULL; /* @@ -6629,6 +7162,9 @@ f_sha1(int count, VALUE **vals) HASH *state; /* pointer to hash state to use */ int i; /* vals[i] to hash */ + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + /* * arg check */ @@ -6693,6 +7229,9 @@ f_md5(int count, VALUE **vals) HASH *state; /* pointer to hash state to use */ int i; /* vals[i] to hash */ + /* initialize VALUE */ + result.v_subtype = V_NOSUBTYPE; + state = NULL; /* diff --git a/help/contrib b/help/contrib index 80a431b..50dd8f8 100644 --- a/help/contrib +++ b/help/contrib @@ -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: diff --git a/help/credit b/help/credit index a8c1d61..e213b1a 100644 --- a/help/credit +++ b/help/credit @@ -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. diff --git a/help/todo b/help/todo index c7ddb0e..da23788 100644 --- a/help/todo +++ b/help/todo @@ -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: diff --git a/help/wishlist b/help/wishlist index dfc9fb6..a4121ee 100644 --- a/help/wishlist +++ b/help/wishlist @@ -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. =-= diff --git a/lib/README b/lib/README index 31c2da1..82446bf 100644 --- a/lib/README +++ b/lib/README @@ -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 diff --git a/lib_calc.c b/lib_calc.c index 32899c8..6a9e7a0 100644 --- a/lib_calc.c +++ b/lib_calc.c @@ -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; } diff --git a/listfunc.c b/listfunc.c index c38aabb..064c09c 100644 --- a/listfunc.c +++ b/listfunc.c @@ -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); } diff --git a/matfunc.c b/matfunc.c index c2db811..10a9233 100644 --- a/matfunc.c +++ b/matfunc.c @@ -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; diff --git a/obj.c b/obj.c index 9ab39dd..8085dcb 100644 --- a/obj.c +++ b/obj.c @@ -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); diff --git a/opcodes.c b/opcodes.c index 79d368f..19ce30d 100644 --- a/opcodes.c +++ b/opcodes.c @@ -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; } diff --git a/value.c b/value.c index 1042265..1aa0a8b 100644 --- a/value.c +++ b/value.c @@ -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: diff --git a/version.c b/version.c index 7abf7d7..8da6309 100644 --- a/version.c +++ b/version.c @@ -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 diff --git a/zmath.c b/zmath.c index b41770c..058232c 100644 --- a/zmath.c +++ b/zmath.c @@ -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); diff --git a/zmul.c b/zmul.c index fa3fd3c..67897c1 100644 --- a/zmul.c +++ b/zmul.c @@ -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; diff --git a/zrandom.c b/zrandom.c index 8abc2ec..21fc3ec 100644 --- a/zrandom.c +++ b/zrandom.c @@ -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 &&