Compare commits

..

4 Commits

Author SHA1 Message Date
Landon Curt Noll
160f4102ab Release calc version 2.11.0t10.2 2017-05-21 15:38:34 -07:00
Landon Curt Noll
306e031f03 Release calc version 2.11.0t10.1.4 2017-05-21 15:38:34 -07:00
Landon Curt Noll
6cfe9696ce Release calc version 2.11.0t10.1.3 2017-05-21 15:38:34 -07:00
Landon Curt Noll
97ed812cb9 Release calc version 2.11.0t10.1.2 2017-05-21 15:38:34 -07:00
12 changed files with 312 additions and 129 deletions

28
BUGS
View File

@@ -38,18 +38,12 @@ then it may be time to send in a bug report. You can send bug reports to:
When you send your report, please include the following information:
* a description of the problem
* the version of calc you are using (if you cannot get calc
it to run, then send us the 4 #define lines from version.c)
* if you modified calc from an official patch, send me the mods you made
* the type of system you were using
* the type of compiler you were using
* any compiler warnings or errors that you saw
* cd to the calc source directory, and type:
make debug > debug.out 2>&1 (sh, ksh, bash users)
@@ -112,12 +106,30 @@ Known bugs:
=-=
Other items of note:
Problems with known work-a-rounds:
* There is a bug in gcc-2.95 that causes calc, when compiled with -O2,
to fail the regression test. The work-a-round is to compile with -O
or to use gcc-2.96 or later.
* Solaris cc somtimes barfs while compiling zrand.c. In particular, calc
barfs on on the SVAL macro. The work-a-round is to use the Solaric cc
Makefile set sets -DFORCE_STDC. I.e,:
CCWARN=
CCOPT= ${DEBUG} ${NO_SHARED}
CCMISC= -DFORCE_STDC
#
CFLAGS= ${CCWARN} ${CCOPT} ${CCMISC}
ICFLAGS= ${CCWARN} ${CCMISC}
#
LCFLAGS=
LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED}
ILDFLAGS=
#
LCC= cc
CC= ${PURIFY} ${LCC}
* There is a bug in some versions of the Dec/Compaq cc for the Alpha
where the following:
@@ -156,4 +168,4 @@ Other items of note:
* 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.
There is no work-a-round for this compiler problem.

15
CHANGES
View File

@@ -11,6 +11,21 @@ The following are the changes from calc version 2.11.0t10 to date:
used in combination with the GNU-readline facility, will prevent
it from saving empty lines.
Minor typos fixed in regress.cal
Added 8500 test serise and test8500.cal to perform more extensive
tests on // and % with various rounding modes.
The 'unused value ignored' messages now start with Line 999: instead
of just 999:.
Fixed some typos in the help files as reported by Klaus Alexander
Seistrup <klaus@seistrup.dk>.
Fixed the long standing issue first reported by Saber-C in the
domul() function in zmil.c thanks to a patch by Ernest Bowen
<ernie@turing.une.edu.au>.
The following are the changes from calc version 2.11.0t8.9.1 to 2.11.0t9.4.5:

View File

@@ -1114,8 +1114,7 @@ custom.o: custom.c ${MAKE_FILE}
${CC} ${CFLAGS} ${ALLOW_CUSTOM} -c custom.c
hist.o: hist.c ${MAKE_FILE}
${CC} ${CFLAGS} ${TERMCONTROL} ${USE_READLINE} ${READLINE_INCLUDE} \
-c hist.c
${CC} ${CFLAGS} ${TERMCONTROL} ${USE_READLINE} ${READLINE_INCLUDE} -c hist.c
func.o: func.c ${MAKE_FILE}
${CC} ${CFLAGS} ${ALLOW_CUSTOM} -c func.c

View File

@@ -462,7 +462,8 @@ addop(long op)
fp->f_opcodecount -= diff;
oldop = OP_NOP;
oldoldop = OP_NOP;
fprintf(stderr, "%ld: unused value ignored\n",
fprintf(stderr,
"Line %ld: unused value ignored\n",
linenumber());
return;
}

View File

@@ -22,7 +22,7 @@ EXAMPLE
"chongo was here"
LIMITS
fd must be associaed with an open file
fd must be associated with an open file
LIBRARY
none

View File

@@ -44,7 +44,8 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
test2700.cal test3100.cal test3300.cal test3400.cal prompt.cal \
test3500.cal seedrandom.cal test4000.cal test4100.cal test4600.cal \
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
randomrun.cal xx_print.cal natnumset.cal qtime.cal test8400.cal
randomrun.cal xx_print.cal natnumset.cal qtime.cal test8400.cal \
test8500.cal
# These files are found (but not built) in the distribution
#

View File

@@ -159,9 +159,9 @@ define mod_inv(a)
define mod_div(a, b)
{
local c, x, y;
obj mod x, y;
local c;
local obj mod x;
local obj mod y;
if (isnum(a))
a = lmod(a);
if (isnum(b))

View File

@@ -471,8 +471,9 @@ define plist(s) {
define deg(a) = size(a.p) - 1;
define polydiv(a,b) {
local q, r, d, u, i, m, n, sa, sb, sq;
obj poly q, r;
local d, u, i, m, n, sa, sb, sq;
local obj poly q;
local obj poly r;
sa=findlist(a); sb = findlist(b); sq = list();
m=size(sa)-1; n=size(sb)-1;
if (n<0) quit "Zero divisor";

View File

@@ -3048,8 +3048,8 @@ define test_error()
print '3712: e9999 = error(9999)';
vrfy(errno() == 9999, '3713: errno() == 9999');
vrfy(error() == e9999, '3714: error() == e9999');
vrfy(substr(strerror(), strlen(strerror())-3, 4) == "9999",
'3715: substr(strerror(), strlen(strerror())-3, 4) == "9999"');
vrfy(substr(strerror(), strpos(strerror(),"9999"), 4) == "9999",
'3715: substr(strerror(), strpos(strerror(),"9999"), 4) == "9999"');
x = newerror("Alpha");
print '3716: x = newerror("Alpha")';
n = iserror(x);
@@ -3060,19 +3060,21 @@ define test_error()
vrfy(errno(9999) == n, '3721: errno() == n');
vrfy(errno() == 9999, '3722: errno() == 9999');
vrfy(error() == e9999, '3723: error() == e9999');
vrfy(substr(strerror(), strlen(strerror())-3, 4) == "9999",
'3724: substr(strerror(), strlen(strerror())-3, 4) == "9999"');
vrfy(substr(strerror(), strpos(strerror(),"9999"), 4) == "9999",
'3724: substr(strerror(), strpos(strerror(),"9999"), 4) == "9999"');
a = 1/0;
print '3725: a = 1/0';
vrfy(strerror() == "Division by zero",
'3726: strerror() == "Division by zero"');
vrfy(substr(strerror(9941), strlen(strerror(9941))-3, 4) == "9941",
'3728: substr(strerror(9941), strlen(strerror(9941))-3, 4) == "9941"');
n = 8191;
print '3727: n = 8191';
vrfy(substr(strerror(8191),strpos(strerror(n),"8191"), 4) == "8191",
'3728: substr(strerror(n),strpos(strerror(n),"8191"),4) == "8191"');
/* errmax and errcount should be bumped up the 148 errors above */
vrfy(errcount() == ecnt, '3728: errcount() == ecnt');
vrfy(errcount() == ecnt, '3729: errcount() == ecnt');
print '3729: Ending test_error';
print '3730: Ending test_error';
}
print '054: parsed test_error()';
@@ -7389,8 +7391,8 @@ X5800 = obj xy5800 = {1,2};
print '5864: X5800 = obj xy5800 = {1,2}';
vrfy(X5800 == (obj xy5800 = {1,2}),
'5865: X5800 == (obj xy5800 = {1,2})');
define f5800(a8500 = mat[2] = {3,4}) = 5 * a8500;
print '5866: define f5800(a8500 = mat[2] = {3,4}) = 5 * a8500;'
define f5800(a5800 = mat[2] = {3,4}) = 5 * a5800;
print '5866: define f5800(a5800 = mat[2] = {3,4}) = 5 * a5800;'
vrfy(f5800() == (mat[] = {15,20}),'5867: f5800() == (mat[] = {15,20})');
print '5868: End of 5800 sequence';
@@ -7493,6 +7495,15 @@ vrfy(test8400() == 64434, '8405: test8400() == 64434');
print '8406: Ending test_quit';
/*
* test_divmod - psuedo-random tests on the // and % with various rounding modes
*/
print;
print '8500: Starting test_divmod'
read -once "test8500";
/* 85xx: Ending test_divmod is printed by test8500.cal */
/*
* read various calc libs
*

242
lib/test8500.cal Normal file
View File

@@ -0,0 +1,242 @@
/*
* Copyright (c) 1996 Ernest Bowen and Landon Curt Noll
* Permission is granted to use, distribute, or modify this source,
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 8500 series of the regress.cal test suite.
*/
/*
* Tests of // and % operators
*/
global err_8500; /* divmod_8500 error count */
global L_8500; /* list of problem values */
global ver_8500; /* test verbosity - see setting comment near bottom */
global old_seed_8500; /* old srand() seed */
/*
* save the config state so that we can change it and restore later
*/
global cfg_8500 = config("all");
/*
* onetest_8500 - perform one division / remainder test
*
* Returns:
* 0 = test was successful
* >0 = test error indicator
*/
define onetest_8500(a,b,rnd) {
local q, r, s, S;
/*
* set a random rounding mode
*/
config("quo", rnd), config("mod", rnd);
/*
* perform the division and mod
*/
q = a // b;
r = a % b;
/*
* verify the fundamental math
*/
if (a != q * b + r)
return 1;
/*
* determine if the rounding worked
*/
if (b) {
if (rnd & 16)
s = sgn(abs(r) - abs(b)/2);
else
s = sgn(abs(r) - abs(b));
if (s < 0 || r == 0)
return 0;
if (s > 0)
return 2;
if (((rnd & 16) && s == 0) || !(rnd & 16)) {
S = sgn(r) * sgn(b); /* This is sgn(a/b) - a//b */
switch (rnd & 15) {
case 0: return (S < 0) ? 3 : 0;
case 1: return (S > 0) ? 4 : 0;
case 2: return (S != sgn(a)*sgn(b)) ? 5 : 0;
case 3: return (S != -sgn(a)*sgn(b)) ? 6 : 0;
break;
case 4: return (S != sgn(b)) ? 7 : 0;
case 5: return (S != -sgn(b)) ? 8 : 0;
case 6: return (S != sgn(a)) ? 9 : 0;
case 7: return (S != -sgn(a)) ? 10 : 0;
case 8: return (isodd(q)) ? 11 : 0;
case 9: return (iseven(q)) ? 12 : 0;
case 10: return (iseven(q) != (a/b > 0)) ? 13:0;
case 11: return (isodd(q) != (a/b > 0)) ? 14:0;
case 12: return (iseven(q) != (b > 0)) ? 15 : 0;
case 13: return (isodd(q) != (b > 0)) ? 16 : 0;
case 14: return (iseven(q) != (a > 0)) ? 17 : 0;
case 15: return (isodd(q) != (a > 0)) ? 18 : 0;
}
}
}
/*
* all is well
*/
return 0;
}
/*
* divmod_8500 - perform a bunch of pseudo-random // and % test
*
* divmod_8500(N, M1, M2) will perform N tests with randomly chosen integers
* a, b with abs(a) < M1, abs(b) < M2, which with 50% probability are
* converted to a = (2 * a + 1) * b, b = 2 * b (to give case where
* a / b is an integer + 1/2).
*
* N defaults to 10, M1 to 2^128, M2 to 2^64
*
* The testnum, if > 0, is used while printing a failure or success.
*
* The rounding parameter is randomly chosen.
*
* After a run of divmod_8500 the a, b, rnd values which gave failure are
* stored in the list L_8500. L_8500[0], L_8500[1], L_8500[2] are a, b, rnd for the first
* test, etc.
*/
define divmod_8500(N = 10, M1 = 2^128, M2 = 2^64, testnum = 0)
{
local a, b, i, v, rnd;
local errmsg; /* error message to display */
/*
* firewall
*/
if (!isint(M1) || M1 < 2)
quit "Bad second arg for dtest";
if (!isint(M2) || M2 < 2)
quit "Bad third arg for dtest";
/*
* test setup
*/
err_8500 = 0;
L_8500 = list();
/*
* perform the random results
*/
for (i = 0; i < N; i++) {
/*
* randomly select two values in the range controlled by M1,M2
*/
a = rand(-M1+1, M1);
b = rand(-M2+1, M2);
if (rand(2)) {
a = (2 * a + 1) * b;
b *= 2;
}
/*
* seelect one of the 32 rounding modes at random
*/
rnd = rand(32);
/*
* ver_8500 pre-test reporting
*/
if (ver_8500 > 1)
printf("Test %d: a = %d, b = %d, rnd = %d\n",
i, a, b, rnd);
/*
* perform the actual test
*/
v = onetest_8500(a, b, rnd);
/*
* individual test analysis
*/
if (v != 0) {
err_8500++;
if (ver_8500 != 0) {
if (testnum > 0) {
errmsg = strprintf(
"Failure %d on test %d", v, i);
prob(errmsg);
} else {
printf("Failure %d on test %d", v, i);
}
}
append(L_8500, a, b, rnd);
}
}
/*
* report in the results
*/
if (err_8500) {
if (testnum > 0) {
errmsg = strprintf(
"%d: divmod_8500(%d,,,%d): %d failures",
testnum, N, testnum, err_8500);
prob(errmsg);
} else {
printf("%s failure%s", err_8500,
(err_8500 > 1) ? "s" : "");
}
} else {
if (testnum > 0) {
errmsg = strprintf("%d: divmod_8500(%d,,,%d)",
testnum, N, testnum);
vrfy(err_8500 == 0, errmsg);
} else {
print "No failure";
}
}
}
/*
* ver_8500 != 0 displays failures; ver_8500 > 1 displays all numbers tested
*/
ver_8500 = 0;
print '8501: ver_8500 = 0';
old_seed_8500 = srand(31^61);
print '8502: old_seed_8500 = srand(31^61)';
/*
* do the tests
*/
divmod_8500(250, 2^128, 2^1, 8503);
divmod_8500(250, 2^128, 2^64, 8504);
divmod_8500(250, 2^256, 2^64, 8505);
divmod_8500(250, 2^1024, 2^64, 8506);
divmod_8500(250, 2^1024, 2^128, 8507);
divmod_8500(250, 2^16384, 2^1024, 8508);
divmod_8500(1000, 2^128, 2^64, 8509);
/*
* restore state
*/
config("all", cfg_8500),;
print '8510: config("all", cfg_8500),';
srand(old_seed_8500),;
print '8511: srand(old_seed_8500),';
/*
* finished with 8500 tests
*/
print '8512: Ending test_divmod';

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 "10.1.1" /* test number or empty string if no patch */
#define MINOR_PATCH "10.2" /* test number or empty string if no patch */
/*
* calc version constants

101
zmul.c
View File

@@ -279,106 +279,7 @@ 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.
*
* This warning is issued during the regression test #026
* (read cryrand).
*
* Saver-C claims that v2+shift is past the end of allocated
* memory for v2.
*
* This warning may be triggered by executing the following code:
*
* a = 0xffff0000ffffffff00000000ffff0000000000000000ffff;
* 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: [[NOTE: line numbers may have changed]]
*
* domul(v1=0x2d93d8, size1=12,
* v2=0x2ded30, size2=2, ans=0x2ee8a8) at "zmul.c":313
* zmul(z1=0x2ee928, z2=0x2ee92c, res=0x16d8c0) at "zmul.c":73
* zpowermod(z1=0x2ee828, z2=0x2ee82c,
* z3=0x2ee830, res=0x57bfe4) at "zmod.c":666
* qpowermod(q1=0x57bf90, q2=0x57bfc8, q3=0x57bf3c) at "qfunc.c":78
* builtinfunc(...) at "func.c":400
* o_call(...) at "opcodes.c":2094
* calculate(...) at "opcodes.c":288
* 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;
baseC = v2 + ((shift <= size2) ? shift : size2);
baseD = v2;
baseAB = ans;
baseDC = ans + shift;