Release calc version 2.11.0t6

This commit is contained in:
Landon Curt Noll
1999-10-07 08:44:34 -07:00
parent 8cabbd6fb4
commit b54d8fc510
55 changed files with 351 additions and 600 deletions

36
BUGS
View File

@@ -78,42 +78,6 @@ Known problems or mis-features:
and not much in the way of comments. We need some major cleanup and not much in the way of comments. We need some major cleanup
and documentation. and documentation.
* On Solaris cc when compile with -Xc (which results in BASEB=16
because it eliminates the long long type), some of the hash
functions fail.
NOTE: As a work-a-round, Solaris cc users should compile
with -DFORCE_STDC and without -Xc.
From: "Dr.D.J.Picton" <dave@aps5.ph.bham.ac.uk>
Subject: Re: calc version 2.11.0t4
Date: Fri, 1 Oct 1999 16:12:30 +0100 (BST)
**** Non-true result (0): 7120: sha(sha(isqrt(2e1000)==0x6db8d9cf0b018b8f9cbbf5aa1edb8066d19e1bb0
7120 result came out as 0x2f19f0baa7824cb8da5e9908044a3f648e992
**** Non-true result (0): 7122: sha(sha("this is", 7^19-8, ..., "hash")) == 0x21e4...
7122 result came out as 0xa050ece371eda88a461afcb807091f7613aa4488
7123: z = sha(list(1,2,3), "curds and whey", 2^21701-1, pi());
**** Non-true result (0): 7124: sha(z) == 0x36dcca3e51865c30a2cf738023cda446f1368340
7124 result came out as 0xccaff4f97187821018d983cc0ce51787fb96a73c
**** Non-true result (0): 7209: sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) == ...
7209 result came out as 0xb9631fea54a3e999521efa99745d2e2a5f65cd3b
7210: z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi());
**** Non-true result (0): 7211: sha1(z) == 0xc19e7317675dbf71e293b4c41e117169e9da5b6f
7211result came out as 0xb8e5c8fdbbe4539cf601b0f6eb874f9662edb50c
**** Non-true result (0): 7227: sha1(sha1(isqrt(2e1000)))==0x6852a1365c51050c3d039e3c5d9cf29c12283ef4
7227 result came out as 0x91018a59d87c7d945451538412cadd56b7ec4681
**** Non-true result (0): 7310: md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == ...
7310 result came out as 0x65c29173098713fdec0f319551355243
7311: z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi());
**** Non-true result (0): 7312: md5(z) == 0x63d2b2fccae2de265227c30b05abb6b5
7311 result came out as 0x1ba0c3eb5ba11dfe11394c0837f52d85
**** Non-true result (0): 7328: md5(md5(isqrt(2e1000))) == 0xe56ac4b8cad869e738a04fedc97058f3
7328 result came out as 0x5afae12a1db610da2846c35f2bf144b0
**** 9 error(s) found \/++\/
9999: Ending regression tests
* On a Dec Alpha, using the Dec Alpha cc (not gcc) make check for * On a Dec Alpha, using the Dec Alpha cc (not gcc) make check for
version 2.11.0t5.1 fails in the regression test: version 2.11.0t5.1 fails in the regression test:

62
CHANGES
View File

@@ -25,10 +25,11 @@ Following is the change from calc version 2.11.0t1 to date:
porting calc to C++! We will NOT support C++ compilation of calc. porting calc to C++! We will NOT support C++ compilation of calc.
Calc will written ANSI C. We just compiled with a suggestion from Calc will written ANSI C. We just compiled with a suggestion from
Love-Jensen, John <jlove-jensen@globalmt.com> to make calc's version Love-Jensen, John <jlove-jensen@globalmt.com> to make calc's version
of C a little more to C++ compilers. Avoiding symbols such as new of C a little more to C++ compilers. We are simply avoiding symbols
or try for example. such as new or try for example.
Updated README.FIRST and BUGS to reflect new URLs and addresses. Renamed README to README.OLD. Renamed README.FIRST to README.
Updated README, lib/README and BUGS to reflect new URLs and addresses.
Added a HOWTO.INSTALL file. Added a HOWTO.INSTALL file.
@@ -78,15 +79,6 @@ Following is the change from calc version 2.11.0t1 to date:
The custom.c file is now compiled with full ${CFLAGS}. The custom.c file is now compiled with full ${CFLAGS}.
### XXX - this change has been backed out:
#
# Thanks to the efforts of Ernest Bowen <ernie@neumann.une.edu.au> and
# Dr.D.J.Picton <dave@aps5.ph.bham.ac.uk>, a nasty endian-ness bug
# in the sha and sha1 hash functions that showed up on machines such
# as the Sparc was fixed.
#
###
Rewrote command line / argument processing code. Calc is now Rewrote command line / argument processing code. Calc is now
using getopt(3) argument processing. using getopt(3) argument processing.
@@ -113,14 +105,12 @@ Following is the change from calc version 2.11.0t1 to date:
Fixed memory leaks in zsrand() in zrand.c. Fixed memory leaks in zsrand() in zrand.c.
Fixed a memory leak in zsrandom1() in zrandom.c. Fixed a memory leak in zsrandom1() in zrandom.c. Fixed memory
leaks associated with replacing the internal random state with
another random state.
Added seed() builtin to return a 64 bit seed for a Added seed() builtin to return a 64 bit seed for a
psuedo-random generator. pseudo-random generator.
Added functionality from Ernest Bowen <ernie@turing.une.edu.au>
to give arguments as well as function names after definitions when
calc_debug >= 0.
Added functionality from Ernest Bowen <ernie@turing.une.edu.au> to Added functionality from Ernest Bowen <ernie@turing.une.edu.au> to
permit nested "= {...}" assignments for lists as well as matrices permit nested "= {...}" assignments for lists as well as matrices
@@ -148,6 +138,42 @@ Following is the change from calc version 2.11.0t1 to date:
Added custom function custom("pzasusb8", n) and lib/pzasusb8.cal based on Added custom function custom("pzasusb8", n) and lib/pzasusb8.cal based on
Ernest Bowen's diagnostic patch. Ernest Bowen's diagnostic patch.
Thanks to the efforts of Ernest Bowen <ernie@neumann.une.edu.au> and
Dr.D.J.Picton <dave@aps5.ph.bham.ac.uk>, a nasty endian-ness bug
in the sha and sha1 hash functions that showed up on machines such
as the Sparc was fixed.
Added functionality from Ernest Bowen <ernie@turing.une.edu.au>
to give arguments as well as function names after definitions when
config("lib_debug") >= 0.
Removed if (config("lib_debug") >= 0) { ... } the ends of most
of the calc library scripts because it was redundant with the
new config("lib_debug") >= 0 functionality. Some of the calc
library still has a partial section because some useful
additional information was being printed:
chrem.cal deg.cal lucas_tbl.cal randrun.cal
mfactor.cal mod.cal poly.cal seedrandom.cal
surd.cal varargs.cal
Fixed ellip.cal so that its defined function does not conflict with
the factor() builtin function.
Fixed mod.cal so that a defined function does not conflict with
the mod() builtin function.
The regression test suite now reads in most calc libs. A few
libs are not read because they, by design, produce output
when read even when config("lib_debug") is set to -1.
Increased the maximum number of object types that one can define
from 10 to 128.
Added a patch from Ernest Bowen <ernie@turing.une.edu.au>
to correctly hash a V_STR value-type that has an \0 byte
inside it.
Fixed misc compile warnings and notices. Fixed misc compile warnings and notices.

View File

@@ -931,7 +931,7 @@ C_SRC= ${LIBSRC} ${CALCSRC} ${UTIL_C_SRC}
# These files are found (but not built) in the distribution # These files are found (but not built) in the distribution
# #
DISTLIST= ${C_SRC} ${H_SRC} ${MAKE_FILE} BUGS CHANGES LIBRARY README \ DISTLIST= ${C_SRC} ${H_SRC} ${MAKE_FILE} BUGS CHANGES LIBRARY README \
calc.man lint.sed README.FIRST HOWTO.INSTALL ${UTIL_MISC_SRC} calc.man lint.sed README.OLD HOWTO.INSTALL ${UTIL_MISC_SRC}
# complete list of .o files # complete list of .o files
# #

91
README
View File

@@ -1,73 +1,54 @@
# Copyright (c) 1997 David I. Bell Dear calc user,
# Permission is granted to use, distribute, or modify this source,
# provided that this copyright notice remains intact.
#
# Arbitrary precision calculator.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See the HOWTO.INSTALL file for information on how to build and install calc.
NOTE: This is an old historic README. We recommend that you
read README.FIRST and HOWTO.INSTALL for more info.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am allowing this calculator to be freely distributed for your enjoyment. To be sure that your version of calc is up to date, check out:
Like all multi-precision programs, you should not depend absolutely on
its results, since bugs in such programs can be insidious and only rarely
show up.
-dbell- http://reality.sgi.com/chongo/calc/calc-download.html
p.s. By Landon Curt Noll: We are interested in any/all feedback on recent versions of calc.
In particular we would like to hear about:
Building calc in 3 easy steps: * compiler warnings
* compile problems
* regression test problems (try: make check)
* special compile flags/options that you needed
* Makefile problems
* help file problems
* misc nits and typos
1) Look at the makefile, and adjust it to suit your needs. We would like to offer a clean compile across a wide verity of platforms,
so if you can test on several, so much the better!
Here are some Makefile hints: If you run into problems, see the BUGS file.
In the past, some people have had to adjust the VARARG or
TERMCONTROL because the Makefile cannot always guess
correctly for certain systems. You may need to play with
these values if you experience problems.
The default compiler used is 'cc'. The default compiler flag
is '-O'. If you have gcc, or gcc v2 (or better) you should use
that instead. Some compilers allow for optimization beyond
just -O (gcc v2 has -O2, mips cc has -O3). You should select
the best flag for speed optimization. Calc can be cpu intensive
so selecting a quality compiler and good optimization level can
really pay off.
2) build calc:
make all
3) test calc:
make check
==>>>If you run into problems, follow the instructions in the BUGS file<<<==
=-= =-=
For further reading: See the file:
LIBRARY
explains how programs can use libcalc.a to take advantage
of the calc multi-precision routines.
help/todo help/todo
current wish list for calc
CHANGES or run:
recent changes to calc
BUGS calc 'help todo'
known bugs, mis-features and how to report problems
help/full for a wish/todo list. Code contributions are welcome.
full set of calc documentation
=-= =-=
David I. Bell dbell@auug.org.au To join the calc-tester mailing list. Send a request to:
chongo@toad.com <Landon Curt Noll -- chongo@toad.com> /\../\
calc-tester-request@postofc.corp.sgi.com
Your message body (not the subject) should consist of:
subscribe calc-tester address
end
name your_full_name
where ``address'' is your EMail address and ``your_full_name'' is
your full name.
The calc web site is located at:
http://reality.sgi.com/chongo/calc

View File

@@ -1,54 +0,0 @@
Dear calc user,
See the HOWTO.INSTALL file for information on how to build and install calc.
To be sure that your version of calc is up to date, check out:
http://reality.sgi.com/chongo/calc/calc-download.html
We are interested in any/all feedback on recent versions of calc.
In particular we would like to hear about:
* compiler warnings
* compile problems
* regression test problems (try: make check)
* special compile flags/options that you needed
* Makefile problems
* help file problems
* misc nits and typos
We would like to offer a clean compile across a wide verity of platforms,
so if you can test on several, so much the better!
If you run into problems, see the BUGS file.
=-=
See the file:
help/todo
or run:
calc 'help todo'
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
Your message body (not the subject) should consist of:
subscribe calc-tester address
end
name your_full_name
where ``address'' is your EMail address and ``your_full_name'' is
your full name.
The calc web site is located at:
http://reality.sgi.com/chongo/calc

73
README.OLD Normal file
View File

@@ -0,0 +1,73 @@
# Copyright (c) 1997 David I. Bell
# Permission is granted to use, distribute, or modify this source,
# provided that this copyright notice remains intact.
#
# Arbitrary precision calculator.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NOTE: This is an old historic README. We recommend that
you read README and HOWTO.INSTALL for more info.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am allowing this calculator to be freely distributed for your enjoyment.
Like all multi-precision programs, you should not depend absolutely on
its results, since bugs in such programs can be insidious and only rarely
show up.
-dbell-
p.s. By Landon Curt Noll:
Building calc in 3 easy steps:
1) Look at the makefile, and adjust it to suit your needs.
Here are some Makefile hints:
In the past, some people have had to adjust the VARARG or
TERMCONTROL because the Makefile cannot always guess
correctly for certain systems. You may need to play with
these values if you experience problems.
The default compiler used is 'cc'. The default compiler flag
is '-O'. If you have gcc, or gcc v2 (or better) you should use
that instead. Some compilers allow for optimization beyond
just -O (gcc v2 has -O2, mips cc has -O3). You should select
the best flag for speed optimization. Calc can be cpu intensive
so selecting a quality compiler and good optimization level can
really pay off.
2) build calc:
make all
3) test calc:
make check
==>>>If you run into problems, follow the instructions in the BUGS file<<<==
=-=
For further reading:
LIBRARY
explains how programs can use libcalc.a to take advantage
of the calc multi-precision routines.
help/todo
current wish list for calc
CHANGES
recent changes to calc
BUGS
known bugs, mis-features and how to report problems
help/full
full set of calc documentation
=-=
David I. Bell dbell@auug.org.au
chongo <Landon Curt Noll> /\../\

View File

@@ -237,7 +237,7 @@ rmuserfunc(char *name)
return; return;
freenumbers(functions[index]); freenumbers(functions[index]);
free(functions[index]); free(functions[index]);
if (!inputisterminal() && conf->lib_debug >= 0) if (inputisterminal() && conf->lib_debug >= 0)
printf("%s() undefined\n", name); printf("%s() undefined\n", name);
functions[index] = NULL; functions[index] = NULL;
} }

2
calc.h
View File

@@ -37,7 +37,7 @@
#define SYMBOLSIZE 256 /* maximum symbol name size */ #define SYMBOLSIZE 256 /* maximum symbol name size */
#define MAXINDICES 20 /* maximum number of indices for objects */ #define MAXINDICES 20 /* maximum number of indices for objects */
#define MAXLABELS 100 /* maximum number of user labels in function */ #define MAXLABELS 100 /* maximum number of user labels in function */
#define MAXOBJECTS 10 /* maximum number of object types */ #define MAXOBJECTS 128 /* maximum number of object types */
#define MAXSTRING 1024 /* maximum size of string constant */ #define MAXSTRING 1024 /* maximum size of string constant */
#define MAXSTACK 1000 /* maximum depth of evaluation stack */ #define MAXSTACK 1000 /* maximum depth of evaluation stack */
#define MAXFILES 20 /* maximum number of opened files */ #define MAXFILES 20 /* maximum number of opened files */

View File

@@ -31,7 +31,6 @@ c_pzasusb8(char *name, int count, VALUE **vals)
{ {
VALUE result; /* what we will return */ VALUE result; /* what we will return */
ZVALUE z; /* numerator of the value */ ZVALUE z; /* numerator of the value */
long octet_cnt; /* number of octets in the numerator */
long half_cnt; /* number of HALFs in the numerator */ long half_cnt; /* number of HALFs in the numerator */
USB8 *h; /* octet pointer */ USB8 *h; /* octet pointer */
long half_len; /* length of a half in octets */ long half_len; /* length of a half in octets */
@@ -52,7 +51,6 @@ c_pzasusb8(char *name, int count, VALUE **vals)
*/ */
z = vals[0]->v_num->num; z = vals[0]->v_num->num;
half_len = sizeof(HALF); half_len = sizeof(HALF);
octet_cnt = z.len * half_len;
half_cnt = z.len; half_cnt = z.len;
/* /*

49
hash.c
View File

@@ -391,8 +391,8 @@ hash_zvalue(int type, ZVALUE zval, HASH *state)
*/ */
if (zval.len > full_lim) { if (zval.len > full_lim) {
for (j=0; j < zval.len-full_lim-1; j += 2) { for (j=0; j < zval.len-full_lim-1; j += 2) {
half[j] = zval.v[full_lim+i+1]; half[j] = zval.v[full_lim+j+1];
half[j+1] = zval.v[full_lim+i]; half[j+1] = zval.v[full_lim+j];
} }
if (j < zval.len-full_lim) { if (j < zval.len-full_lim) {
half[j] = (HALF)0; half[j] = (HALF)0;
@@ -562,7 +562,7 @@ hash_complex(int type, void *c, HASH *state)
/* /*
* hash_str - hash a string * hash_str - hash a null-terminated string
* *
* given: * given:
* type - hash type (see hash.h) * type - hash type (see hash.h)
@@ -606,6 +606,47 @@ hash_str(int type, char *str, HASH *state)
} }
/*
* hash_STR - hash a STRING
*
* given:
* type - hash type (see hash.h)
* str - the STRING
* state - the state to hash or NULL
*
* returns:
* the new state
*/
HASH *
hash_STR(int type, STRING *str, HASH *state)
{
/*
* initialize if state is NULL
*/
if (state == NULL) {
state = hash_init(type, NULL);
}
/*
* setup for the string hash
*/
if (!state->bytes) {
(state->chkpt)(state);
state->bytes = TRUE;
}
/*
* hash the string
*/
(state->update)(state, (USB8*) str->s_str, (USB32) str->s_len);
/*
* all done
*/
return state;
}
/* /*
* hash_usb8 - hash an array of USB8s * hash_usb8 - hash an array of USB8s
* *
@@ -720,7 +761,7 @@ hash_value(int type, void *v, HASH *state)
/* strings have no setup */ /* strings have no setup */
/* hash this type */ /* hash this type */
state = hash_str(type, value->v_str->s_str, state); state = hash_STR(type, value->v_str, state);
break; break;
case V_MAT: case V_MAT:

View File

@@ -1,4 +1,4 @@
# Copyright (c) 1997 David I. Bell and Landon Curt Noll # Copyright (c) 1999 David I. Bell and Landon Curt Noll
# Permission is granted to use, distribute, or modify this source, # Permission is granted to use, distribute, or modify this source,
# provided that this copyright notice remains intact. # provided that this copyright notice remains intact.
@@ -8,13 +8,12 @@ them to be useful!
If you write something that you think is useful, please send it to: If you write something that you think is useful, please send it to:
dbell@auug.org.au calc-tester@postofc.corp.sgi.com
chongo@toad.com {uunet,pyramid,sun}!hoptoad!chongo
By convention, a lib file only defines and/or initializes functions, By convention, a lib file only defines and/or initializes functions,
objects and variables. (The regression test is an exception.) Also by objects and variables. (The regress.cal and testxxx.cal regression test
convention, the a usage message regarding each important object and suite is an exception.) Also by convention, an additional usage message
function is printed at the time of the read. regarding important object and functions is printed.
If a lib file needs to load another lib file, it should use the -once If a lib file needs to load another lib file, it should use the -once
version of read: version of read:
@@ -45,16 +44,23 @@ global variable. By convention, "lib_debug" has the following meanings:
printed at the time of the read in addition printed at the time of the read in addition
to other debug messages to other debug messages
To conform to the above convention, your lib files should end with When config("lib_debug") >= 0, function names and their arg are
lines of the form: printed as they are defined. Sometimes this printing is not enough
information. For example:
* useful obj definitions
* functions with optional args
* functions with optional args where the param() interface is used
For these cases we suggest that you place at the bottom of your code
something like:
if (config("lib_debug") >= 0) { if (config("lib_debug") >= 0) {
print "obj xyz defined"; print "obj xyz defined";
print "funcA(side_a, side_b, side_c) defined"; print "funcA([val1 [, val2]]) defined";
print "funcB(size, mass) defined"; print "funcB(size, mass, ...) defined";
} }
=-= =-=
beer.cal beer.cal
@@ -100,7 +106,7 @@ deg.cal
ellip.cal ellip.cal
factor(iN, ia, B, force) efactor(iN, ia, B, force)
Attempt to factor using the elliptic functions: y^2 = x^3 + a*x + b. Attempt to factor using the elliptic functions: y^2 = x^3 + a*x + b.
@@ -160,7 +166,7 @@ mfactor.cal
mod.cal mod.cal
mod(a) lmod(a)
mod_print(a) mod_print(a)
mod_one() mod_one()
mod_cmp(a, b) mod_cmp(a, b)
@@ -250,7 +256,7 @@ pix.cal
pollard.cal pollard.cal
factor(N, N, ai, af) pfactor(N, N, ai, af)
Factor using Pollard's p-1 method. Factor using Pollard's p-1 method.
@@ -520,6 +526,20 @@ test3400.cal
This script is used by regress.cal to test trig functions. This script is used by regress.cal to test trig functions.
containing objects. containing objects.
test3500.cal
global defaultverbose
global err
testfrem(x, y, verbose)
testgcdrem(x, y, verbose)
testf(str, n, verbose)
testg(str, n, verbose)
testh(str, n, N, verbose)
test3500(verbose, n, N)
This script is used by regress.cal to test the functions frem,
fcnt, gcdrem.
test4000.cal test4000.cal
global defaultverbose global defaultverbose
@@ -617,7 +637,7 @@ varargs.cal
xx_print.cal xx_print.cal
isoctet(a) defined is_octet(a) defined
list_print(a) defined list_print(a) defined
mat_print (a) defined mat_print (a) defined
octet_print(a) defined octet_print(a) defined

View File

@@ -20,7 +20,3 @@ for (i=99; i > 0;) {
bottles = (i!=1) ? "bottles" : "bottle"; bottles = (i!=1) ? "bottles" : "bottle";
print less, bottles, "of beer on the wall!\n"; print less, bottles, "of beer on the wall!\n";
} }
if (config("lib_debug") >= 0) {
/* nothing to do! */
}

View File

@@ -60,7 +60,3 @@ define B(n)
Bnmax = n; Bnmax = n;
return Bn[n]; return Bn[n];
} }
if (config("lib_debug") >= 0) {
print "B(n) defined";
}

View File

@@ -25,7 +25,3 @@ define bigprime(a, m, p)
print " " : n; print " " : n;
} }
} }
if (config("lib_debug") >= 0) {
print "bigprime(a, m, p) defined";
}

View File

@@ -113,11 +113,4 @@ define fixdms(a)
if (config("lib_debug") >= 0) { if (config("lib_debug") >= 0) {
print "obj dms {deg, min, sec} defined"; print "obj dms {deg, min, sec} defined";
print "dms(deg, min, sec) defined";
print "dms_add(a, b) defined";
print "dms_neg(a) defined";
print "dms_sub(a, b) defined";
print "dms_mul(a, b) defined";
print "dms_print(a) defined";
print "dms_abs(a) defined";
} }

View File

@@ -24,7 +24,7 @@
* only an approximation, read "A Course in Number Theory and Cryptography" * only an approximation, read "A Course in Number Theory and Cryptography"
* by Neal Koblitz for a good explanation. * by Neal Koblitz for a good explanation.
* *
* factor(iN, ia, B, force) * efactor(iN, ia, B, force)
* iN is the number to be factored. * iN is the number to be factored.
* ia is the initial value of a in the equation, and each successive * ia is the initial value of a in the equation, and each successive
* value of a is an independent attempt at factoring (default 1). * value of a is an independent attempt at factoring (default 1).
@@ -66,7 +66,7 @@ global b; /* second coefficient */
global f; /* found factor */ global f; /* found factor */
define factor(iN, ia, B, force) define efactor(iN, ia, B, force)
{ {
local C, x, p; local C, x, p;
@@ -165,7 +165,3 @@ define point_pow(p, pow)
} }
return r; return r;
} }
if (config("lib_debug") >= 0) {
print "factor(N, I, B, force) defined";
}

View File

@@ -6,7 +6,3 @@
*/ */
while(1) print "Hello World!"; while(1) print "Hello World!";
if (config("lib_debug") >= 0) {
/* nothing to do */
}

View File

@@ -1029,7 +1029,3 @@ ldebug(funct, str)
} }
return; return;
} }
if (config("lib_debug") >= 0) {
print "lucas(h, n) defined";
}

View File

@@ -374,7 +374,3 @@ lucas_chk(high_n, quiet)
return 0; return 0;
} }
} }
if (config("lib_debug") >= 0) {
print "lucas_chk(high_n) defined";
}

View File

@@ -31,7 +31,3 @@ define mersenne(p)
/* 2^p-1 is prime iff u(p) = 0 mod 2^p-1 */ /* 2^p-1 is prime iff u(p) = 0 mod 2^p-1 */
return (u == 0); return (u == 0);
} }
if (config("lib_debug") >= 0) {
print "mersenne(p) defined";
}

View File

@@ -12,12 +12,12 @@ obj mod {a}; /* definition of the object */
global mod_value = 100; /* modulus value (value of N) */ global mod_value = 100; /* modulus value (value of N) */
define mod(a) define lmod(a)
{ {
local obj mod x; local obj mod x;
if (!isreal(a) || !isint(a)) if (!isreal(a) || !isint(a))
quit "Bad argument for mod function"; quit "Bad argument for lmod function";
x.a = a % mod_value; x.a = a % mod_value;
return x; return x;
} }
@@ -34,7 +34,7 @@ define mod_print(a)
define mod_one() define mod_one()
{ {
return mod(1); return lmod(1);
} }
@@ -51,9 +51,9 @@ define mod_cmp(a, b)
define mod_rel(a, b) define mod_rel(a, b)
{ {
if (isnum(a)) if (isnum(a))
a = mod(a); a = lmod(a);
if (isnum(b)) if (isnum(b))
b = mod(b); b = lmod(b);
if (a.a < b.a) if (a.a < b.a)
return -1; return -1;
return a.a != b.a; return a.a != b.a;
@@ -163,9 +163,9 @@ define mod_div(a, b)
obj mod x, y; obj mod x, y;
if (isnum(a)) if (isnum(a))
a = mod(a); a = lmod(a);
if (isnum(b)) if (isnum(b))
b = mod(b); b = lmod(b);
c = gcd(a.a, b.a); c = gcd(a.a, b.a);
x.a = a.a / c; x.a = a.a / c;
y.a = b.a / c; y.a = b.a / c;
@@ -191,20 +191,6 @@ define mod_pow(a, b)
if (config("lib_debug") >= 0) { if (config("lib_debug") >= 0) {
print "obj mod {a} defined"; print "obj mod {a} defined";
print "mod(a) defined";
print "mod_print(a) defined";
print "mod_one(a) defined";
print "mod_cmp(a, b) defined";
print "mod_rel(a, b) defined";
print "mod_add(a, b) defined";
print "mod_sub(a, b) defined";
print "mod_mod(a, b) defined";
print "mod_square(a) defined";
print "mod_inc(a) defined";
print "mod_dec(a) defined";
print "mod_inv(a) defined";
print "mod_div(a, b) defined";
print "mod_pow(a, b) defined";
print "mod_value defined"; print "mod_value defined";
print "set mod_value as needed"; print "set mod_value as needed";
} }

View File

@@ -592,41 +592,3 @@ define set_print(a)
} }
local N, M; /* End scope of static variables N, M */ local N, M; /* End scope of static variables N, M */
if (config("lib_debug") >= 0) {
print "isset(a) defined";
print "setbound(n) defined";
print "empty() defined";
print "full() defined";
print "isin(a, b) defined";
print "addmember(a, n) defined";
print "rmmember(a, n) defined";
print "set() defined";
print "mkset(s) defined";
print "primes(a, b) defined";
print "set_max(a) defined";
print "set_min(a) defined";
print "set_not(a) defined";
print "set_cmp(a, b) defined";
print "set_rel(a, b) defined";
print "set_or(a, b) defined";
print "set_and(a, b) defined";
print "set_comp(a) defined";
print "set_setminus(a, b) defined";
print "set_xor(a,b) defined";
print "set_content(a) defined";
print "set_add(a, b) defined";
print "set_sub(a, b) defined";
print "set_mul(a, b) defined";
print "set_square(a) defined";
print "set_pow(a, n) defined";
print "set_sum(a) defined";
print "set_plus(a) defined";
print "interval(a, b) defined";
print "isinterval(a) defined";
print "set_mod(a, b) defined";
print "randset(n, a, b) defined";
print "polyvals(L, A) defined";
print "polyvals2(L, A, B) defined";
print "set_print(a) defined";
}

View File

@@ -66,8 +66,3 @@ define pellx(D)
} }
return Q1; return Q1;
} }
if (config("lib_debug") >= 0) {
print "pell(D) defined";
print "pellx(D) defined";
}

View File

@@ -47,7 +47,3 @@ define qpi(epsilon)
} }
return (bround(1/an, bits)); return (bround(1/an, bits));
} }
if (config("lib_debug") >= 0) {
print "qpi(epsilon) defined";
}

View File

@@ -38,7 +38,3 @@ define pi_of_x(x)
} }
return primes; return primes;
} }
if (config("lib_debug") >= 0) {
print "pi_of_x(x) defined";
}

View File

@@ -6,7 +6,7 @@
* Factor using Pollard's p-1 method. * Factor using Pollard's p-1 method.
*/ */
define factor(N, B, ai, af) define pfactor(N, B, ai, af)
{ {
local a, k, i, d; local a, k, i, d;
@@ -28,7 +28,3 @@ define factor(N, B, ai, af)
} }
return 1; return 1;
} }
if (config("lib_debug") >= 0) {
print "factor(N, B, ai, af) defined";
}

View File

@@ -689,39 +689,4 @@ c=pol(1+2i,3+4i,5+6i);
if (config("lib_debug") >= 0) { if (config("lib_debug") >= 0) {
print "obj poly {p} defined"; print "obj poly {p} defined";
print "pol() defined";
print "poly_print(a) defined";
print "poly_add(a, b) defined";
print "poly_sub(a, b) defined";
print "poly_mul(a, b) defined";
print "poly_div(a, b) defined";
print "poly_quo(a,b) defined";
print "poly_mod(a,b) defined";
print "poly_neg(a) defined";
print "poly_conj(a) defined";
print "poly_cmp(a,b) defined";
print "iszero(a) defined";
print "plist(a) defined";
print "listmul(a,b) defined";
print "ev(a,t) defined";
print "evp(s,t) defined";
print "ispoly(a) defined";
print "isstring(a) defined";
print "var(name) defined";
print "pcoeff(a) defined";
print "pterm(a,n) defined";
print "deg(a) defined";
print "polydiv(a,b) defined";
print "D(a,n) defined";
print "Dp(a,n) defined";
print "pgcd(a,b) defined";
print "plcm(a,b) defined";
print "monic(a) defined";
print "pfgcd(a,b) defined";
print "interp(X,Y,x) defined";
print "makediffs(X,Y) defined";
print "evalfd(T,x) defined";
print "mdet(A) defined";
print "M(A,n,I,J) defined";
print "mprint(A) defined";
} }

View File

@@ -94,8 +94,3 @@ define showvalues(str) {
print "\t":eval(str); print "\t":eval(str);
} }
} }
if (config("lib_debug") >= 0) {
print "adder() defined";
print "showvalues(str) defined";
}

View File

@@ -48,8 +48,3 @@ define psqrt(u, p)
} }
return min(v, p - v); return min(v, p - v);
} }
if (config("lib_debug") >= 0) {
print "psqrt(u, p) defined";
}

View File

@@ -197,19 +197,4 @@ define quat_shift(a, b)
if (config("lib_debug") >= 0) { if (config("lib_debug") >= 0) {
print "obj quat {s, v} defined"; print "obj quat {s, v} defined";
print "quat(a, b, c, d) defined";
print "quat_print(a) defined";
print "quat_norm(a) defined";
print "quat_abs(a, e) defined";
print "quat_conj(a) defined";
print "quat_add(a, e) defined";
print "quat_sub(a, e) defined";
print "quat_inc(a) defined";
print "quat_dec(a) defined";
print "quat_neg(a) defined";
print "quat_mul(a, b) defined";
print "quat_div(a, b) defined";
print "quat_inv(a) defined";
print "quat_scale(a, b) defined";
print "quat_shift(a, b) defined";
} }

View File

@@ -112,7 +112,3 @@ define randbitrun(run_cnt)
printf("length>%d\t\t\t\t\tcount=%d\n", MAX_RUN, long_run_cnt); printf("length>%d\t\t\t\t\tcount=%d\n", MAX_RUN, long_run_cnt);
printf("max length=%d\n", max_run); printf("max length=%d\n", max_run);
} }
if (config("lib_debug") >= 0) {
print "randbitrun([run_length]) defined";
}

View File

@@ -129,7 +129,3 @@ randmprime(bits, seed, dbg)
} }
return ret; return ret;
} }
if (config("lib_debug") >= 0) {
print "randmprime(bits, seed [,dbg]) defined";
}

View File

@@ -112,7 +112,3 @@ define randombitrun(run_cnt)
printf("length>%d\t\t\t\t\tcount=%d\n", MAX_RUN, long_run_cnt); printf("length>%d\t\t\t\t\tcount=%d\n", MAX_RUN, long_run_cnt);
printf("max length=%d\n", max_run); printf("max length=%d\n", max_run);
} }
if (config("lib_debug") >= 0) {
print "randombitrun([run_length]) defined";
}

View File

@@ -121,7 +121,3 @@ define randomrun(run_cnt)
printf("length>%d\t\t\t\t\tcount=%d\n", MAX_RUN, long_run_cnt); printf("length>%d\t\t\t\t\tcount=%d\n", MAX_RUN, long_run_cnt);
printf("max length=%d\n", max_run); printf("max length=%d\n", max_run);
} }
if (config("lib_debug") >= 0) {
print "randomrun([run_length]) defined";
}

View File

@@ -7010,7 +7010,7 @@ define test_bigcomb()
{ {
local a, b, n, i, v1, v2; local a, b, n, i, v1, v2;
print '7900: Starting test_bigcomb()'; print '7900: Starting test_bigcomb';
a = 1234/4321; a = 1234/4321;
print '7901: a = 1234/4321'; print '7901: a = 1234/4321';
b = 3456/6543; b = 3456/6543;
@@ -7033,7 +7033,7 @@ define test_bigcomb()
vrfy(f7900(-7/4,33/4,-2) == g7900(-7/4,33/4,-2), vrfy(f7900(-7/4,33/4,-2) == g7900(-7/4,33/4,-2),
'7913: f7900(-7/4,33/4,-2) == g7900(-7/4,33/4,-2)'); '7913: f7900(-7/4,33/4,-2) == g7900(-7/4,33/4,-2)');
print '7914: Ending test_bigcomb()'; print '7914: Ending test_bigcomb';
} }
print '186: parsed test_bigcomb()'; print '186: parsed test_bigcomb()';
@@ -7048,7 +7048,7 @@ define test_natnumset()
{ {
local A, B, C, D, P, P1, L1, L2; local A, B, C, D, P, P1, L1, L2;
print '8000: Starting test_natnumset()'; print '8000: Starting test_natnumset';
A = set(17, 2, 0, 24, 2); A = set(17, 2, 0, 24, 2);
print '8101: A = set(17, 2, 0, 24, 2);'; print '8101: A = set(17, 2, 0, 24, 2);';
@@ -7105,7 +7105,7 @@ define test_natnumset()
vrfy(polyvals2(L2,C,D) == set(12,16,21,27,45,55,77,91), vrfy(polyvals2(L2,C,D) == set(12,16,21,27,45,55,77,91),
'8135: polyvals(L2,C,D) == set(12,16,21,27,45,55,77,91)'); '8135: polyvals(L2,C,D) == set(12,16,21,27,45,55,77,91)');
print '8136: Ending test_natnumset()'; print '8136: Ending test_natnumset';
} }
print '188: parsed test_natnumset()'; print '188: parsed test_natnumset()';
@@ -7115,7 +7115,7 @@ print '188: parsed test_natnumset()';
*/ */
define test_somenew() define test_somenew()
{ {
print '8200: Starting test_somenew()'; print '8200: Starting test_somenew';
vrfy(char(-1) == char(255), '8201: char(-1) == char(255)'); vrfy(char(-1) == char(255), '8201: char(-1) == char(255)');
vrfy(char(258) == char(2), '8202: char(258) == char(2)'); vrfy(char(258) == char(2), '8202: char(258) == char(2)');
@@ -7139,7 +7139,7 @@ define test_somenew()
vrfy(1/(1/0) == 0, '8215: 1/(1/0) == 0'); vrfy(1/(1/0) == 0, '8215: 1/(1/0) == 0');
vrfy(inverse(1/0) == 0, '8216: inverse(1/0) == 0'); vrfy(inverse(1/0) == 0, '8216: inverse(1/0) == 0');
print '8217: Ending test_somenew()'; print '8217: Ending test_somenew';
} }
print '189: parsed test_somenew()'; print '189: parsed test_somenew()';
@@ -7392,6 +7392,85 @@ return test_natnumset();
print; print;
return test_somenew(); return test_somenew();
/*
* read various calc libs
*
* We read most of the calc libs shipped with the distribution.
* There are a few lib files that are not read:
*
* beer.cal - prints a bunch of things when loaded
* hello.cal - designed to go into an infinite loop
* lucal.cal - already read by this file
* lucas_chk.cal - already read by this file
* lucas_tbl.cal - duplicatres code already read by another file
* regress.cal - this file
* surd.cal - already read by this file
* testXXXX.cal - already read by this file
* xx_print.cal - prints a bunch of things when loaded
*
* We want to do this 2nd to last; ahead of any final cleanup and behind
* all of real actions of regress.cal.
*/
print;
print '9800: Starting read of selected calc libs';
read -once bernoulli;
print '9801: read -once bernoulli';
read -once bigprime;
print '9802: read -once bigprime';
read -once chrem;
print '9803: read -once chrem';
read -once deg;
print '9804: read -once deg';
read -once ellip;
print '9805: read -once ellip';
read -once mersenne;
print '9806: read -once mersenne';
read -once mfactor;
print '9807: read -once mfactor';
read -once mod;
print '9808: read -once mod';
read -once natnumset;
print '9809: read -once natnumset';
read -once pell;
print '9810: read -once pell';
read -once pi;
print '9811: read -once pi';
read -once pix;
print '9812: read -once pix';
read -once pollard;
print '9813: read -once pollard';
read -once poly;
print '9814: read -once poly';
read -once prompt;
print '9815: read -once prompt';
read -once psqrt;
print '9816: read -once psqrt';
read -once quat;
print '9817: read -once quat';
read -once randbitrun;
print '9818: read -once randbitrun';
read -once randmprime;
print '9819: read -once randmprime';
read -once randombitrun;
print '9820: read -once randombitrun';
read -once randomrun;
print '9821: read -once randomrun';
read -once randrun;
print '9822: read -once randrun';
read -once seedrandom;
print '9823: read -once seedrandom';
read -once solve;
print '9824: read -once solve';
read -once sumsq;
print '9825: read -once sumsq';
read -once unitfrac;
print '9826: read -once unitfrac';
read -once varargs;
print '9827: read -once varargs';
print '9828: Ending read of selected calc libs';
/* /*
* cleanup and report the results * cleanup and report the results
*/ */

View File

@@ -41,7 +41,3 @@ define solve(low, high, epsilon)
} }
} }
} }
if (config("lib_debug") >= 0) {
print "solve(low, high, epsilon) defined";
}

View File

@@ -37,7 +37,3 @@ define ss(p)
} }
print a : "^2 +" , b : "^2 =" , a^2 + b^2; print a : "^2 +" , b : "^2 =" , a^2 + b^2;
} }
if (config("lib_debug") >= 0) {
print "ss(p) defined";
}

View File

@@ -263,25 +263,6 @@ define surd_rel(a, b)
if (config("lib_debug") >= 0) { if (config("lib_debug") >= 0) {
print "obj surd {a, b} defined"; print "obj surd {a, b} defined";
print "surd(a, b) defined";
print "surd_print(a) defined";
print "surd_conj(a) defined";
print "surd_norm(a) defined";
print "surd_value(a, xepsilon) defined";
print "surd_add(a, b) defined";
print "surd_sub(a, b) defined";
print "surd_inc(a) defined";
print "surd_dec(a) defined";
print "surd_neg(a) defined";
print "surd_mul(a, b) defined";
print "surd_square(a) defined";
print "surd_scale(a, b) defined";
print "surd_shift(a, b) defined";
print "surd_div(a, b) defined";
print "surd_inv(a) defined";
print "surd_sgn(a) defined";
print "surd_cmp(a, b) defined";
print "surd_rel(a, b) defined";
print "surd_type defined"; print "surd_type defined";
print "set surd_type as needed"; print "set surd_type as needed";
} }

View File

@@ -10,7 +10,3 @@
*/ */
++value; ++value;
if (config("lib_debug") >= 0) {
/* nothing to do */
}

View File

@@ -95,7 +95,3 @@ define ckmat()
/* args match the matrix in the object */ /* args match the matrix in the object */
return 1; return 1;
} }
if (config("lib_debug") >= 0) {
/* nothing to do */
}

View File

@@ -491,25 +491,3 @@ define test2600(verbose, tnum)
} }
return tnum; return tnum;
} }
if (config("lib_debug") >= 0) {
print "global defaultverbose defined";
print "global err defined";
print "testismult(str,n,verbose) defined";
print "testsqrt(str,n,eps,verbose) defined";
print "testexp(str,n,eps,verbose) defined";
print "testln(str,n,eps,verbose) defined";
print "testpower(str,n,b,eps,verbose) defined";
print "testgcd(str,n,verbose) defined";
print "cpow(x,n,eps) defined";
print "cexp(x,eps) defined";
print "cln(x,eps) defined";
print "mkreal() defined";
print "mkcomplex() defined";
print "mkbigreal() defined";
print "mksmallreal() defined";
print "testappr(str,n,verbose) defined";
print "checkappr(x,y,z,verbose) defined";
print "checkresult(x,y,z,a) defined";
print "test2600(verbose,tnum) defined";
}

View File

@@ -308,23 +308,3 @@ define test2700(verbose, tnum)
} }
return tnum; return tnum;
} }
if (config("lib_debug") >= 0) {
print "global defaultverbose defined";
print "global err defined";
print "mknonnegreal() defined";
print "mkposreal() defined";
print "mkreal_2700() defined";
print "mknonzeroreal() defined";
print "mkposfrac() defined";
print "mkfrac() defined";
print "mksquarereal() defined";
print "mknonsquarereal() defined";
print "mkcomplex_2700() defined";
print "testcsqrt(str,n,verbose) defined";
print "checksqrt(x,y,z,v) defined";
print "checkavrem(A,B,X,eps) defined";
print "checkrounding(s,n,t,u,z) defined";
print "iscomsq(x) defined";
print "test2700(verbose,tnum) defined";
}

View File

@@ -17,14 +17,3 @@ define res_mul(a,b) {local obj res v = {(a.r * b.r) % md}; return v;};
define res_neg(a) {local obj res v = {(-a.r) % md}; return v;}; define res_neg(a) {local obj res v = {(-a.r) % md}; return v;};
define res_inv(a) {local obj res v = {minv(a.r, md)}; return v;}; define res_inv(a) {local obj res v = {minv(a.r, md)}; return v;};
define res(x) {local obj res v = {x % md}; return v;}; define res(x) {local obj res v = {x % md}; return v;};
if (config("lib_debug") >= 0) {
print "obj res defined";
print "global md defined";
print "res_test(a) defined";
print "res_sub(a, b) defined";
print "res_mul(a, b) defined";
print "res_neg(a) defined";
print "res_inv(a) defined";
print "res(x) defined";
}

View File

@@ -122,11 +122,3 @@ define test3300(verbose, tnum)
} }
return tnum; return tnum;
} }
if (config("lib_debug") >= 0) {
print "global defaultverbose defined";
print "global err defined";
print "testi(str, n, N, verbose) defined";
print "testr(str, n, N, verbose) defined";
print "test3300(verbose, tnum) defined";
}

View File

@@ -299,15 +299,3 @@ define test3400(verbose, tnum)
} }
return tnum; return tnum;
} }
if (config("lib_debug") >= 0) {
print "global defaultverbose defined";
print "global err defined";
print "test3401(str, n, eps, verbose) defined";
print "test3402(str, n, eps, verbose) defined";
print "test3403(str, n, eps, verbose) defined";
print "test3404(str, n, eps, verbose) defined";
print "test3405(str, n, eps, verbose) defined";
print "test3406(str, n, eps, verbose) defined";
print "test3400(verbose, tnum) defined";
}

View File

@@ -272,14 +272,3 @@ define test3500(verbose, tnum, n, N)
} }
return tnum; return tnum;
} }
if (config("lib_debug") >= 0) {
print "global defaultverbose defined";
print "global err defined";
print "testfrem(x, y, verbose) defined";
print "testgcdrem(x, y, verbose) defined";
print "testf(str, n, verbose) defined";
print "testg(str, n, verbose) defined";
print "testh(str, n, N, verbose) defined";
print "test3500(verbose, n, N) defined";
}

View File

@@ -452,32 +452,3 @@ define test4000(v, tnum)
} }
return tnum; return tnum;
} }
if (config("lib_debug") >= 0) {
print "global defaultverbose";
print "global err";
print "global BASEB";
print "global BASE";
print "global COUNT";
print "global SKIP";
print "global RESIDUE";
print "global MODULUS";
print "global K1";
print "global H1";
print "global K2";
print "global H2";
print "global K3";
print "global H3";
print "plen(N) defined";
print "clen(N) defined";
print "ptimes(str, N, n, count, skip, verbose) defined";
print "ctimes(str, N, n, count, skip, verbose) defined";
print "crtimes(str, a, b, n, count, skip, verbose) defined";
print "ntimes(str, N, n, count, skip, residue, mod, verbose) defined";
print "testnextcand(str, N, n, cnt, skip, res, mod, verbose) defined";
print "testnext1(x, y, count, skip, residue, modulus) defined";;
print "testprevcand(str, N, n, cnt, skip, res, mod, verbose) defined";
print "testprev1(x, y, count, skip, residue, modulus) defined";
print "test4000(verbose, tnum) defined";
}

View File

@@ -472,20 +472,3 @@ define test4100(v, tnum)
} }
return tnum; return tnum;
} }
if (config("lib_debug") >= 0) {
print "global defaultverbose";
print "global err";
print "global K1";
print "global K2";
print "global BASEB";
print "global BASE";
print "rlen_4100(N) defined";
print "olen(N) defined";
print "test4101(x, y, m, k, z1, z2) defined";
print "testall(str, n, N, M, verbose) defined";
print "times(str, N, n, verbose) defined";
print "powtimes(str, N1, N2, n, verbose) defined";
print "inittimes(str, N, n, verbose) defined";
print "test4100(verbose, tnum) defined";
}

View File

@@ -304,12 +304,3 @@ define test4600(v, tnum)
} }
return tnum; return tnum;
} }
if (config("lib_debug") >= 0) {
print "stest(str [, verbose]) defined";
print "ttest([m, [n [,verbose]]]) defined";
print "sprint(x) defined";
print "findline(f,s) defined";
print "findlineold(f,s) defined";
print "test4600(verbose, tnum) defined";
}

View File

@@ -48,9 +48,3 @@ define test5100(x)
} }
global a5100 = a5100, b5100 = b5100; global a5100 = a5100, b5100 = b5100;
} }
if (config("lib_debug") >= 0) {
print "global a5100";
print "global b5100";
print "test5100(x) defined";
}

View File

@@ -30,11 +30,3 @@ static a5200 = 20;
define f5200(x) = a5200 + x; define f5200(x) = a5200 + x;
define g5200(x) {global a5200 = 30; return a5200 + x;} define g5200(x) {global a5200 = 30; return a5200 + x;}
define h5200(x) = a5200 + x; define h5200(x) = a5200 + x;
if (config("lib_debug") >= 0) {
print "global a5200";
print "static a5200";
print "f5200(x) defined";
print "g5200(x) defined";
print "h5200(x) defined";
}

View File

@@ -27,8 +27,3 @@ define unitfrac(x)
} while ((num(x) > 1) || (x == di) || (x == 1)); } while ((num(x) > 1) || (x == di) || (x == 1));
print ' [1/1]',, x; print ' [1/1]',, x;
} }
if (config("lib_debug") >= 0) {
print "unitfrac(x) defined";
}

View File

@@ -21,7 +21,7 @@ print "global blkmax defined, assigned value 8";
print; print;
B = blk(); B = blk();
define isoctet(a) = istype(a, B[0]); define is_octet(a) = istype(a, B[0]);
define list_print(a) { define list_print(a) {
local i; local i;
@@ -131,7 +131,7 @@ define strchar(a) {
if (isstr(a)) if (isstr(a))
a = ord(a); a = ord(a);
else if (isoctet(a)) else if (is_octet(a))
a = a; /* This converts octet to number */ a = a; /* This converts octet to number */
else if (!isint(a) || a < 0 || a > 255) else if (!isint(a) || a < 0 || a > 255)
@@ -269,15 +269,3 @@ define octet_print(a) {
print "Here is the earlier block with a new octet_print()"; print "Here is the earlier block with a new octet_print()";
print B1; print B1;
print; print;
if (config("lib_debug") >= 0) {
print "isoctet(a) defined";
print "list_print(a) defined";
print "mat_print (a) defined";
print "octet_print(a) defined";
print "blk_print(a) defined";
print "nblk_print (a) defined";
print "strchar(a) defined";
print "file_print(a) defined";
print "error_print(a) defined";
}

View File

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

View File

@@ -1598,6 +1598,7 @@ zsrandom1(CONST ZVALUE seed, BOOL need_ret)
*/ */
if (!blum.seeded) { if (!blum.seeded) {
p_blum = randomcopy(&init_blum); p_blum = randomcopy(&init_blum);
randomfree(&blum);
blum = *p_blum; blum = *p_blum;
free(p_blum); free(p_blum);
} }
@@ -1621,9 +1622,8 @@ zsrandom1(CONST ZVALUE seed, BOOL need_ret)
if (ziszero(seed)) { if (ziszero(seed)) {
/* set to the default generator state */ /* set to the default generator state */
zfree(blum.n);
zfree(blum.r);
p_blum = randomcopy(&init_blum); p_blum = randomcopy(&init_blum);
randomfree(&blum);
blum = *p_blum; blum = *p_blum;
free(p_blum); free(p_blum);
@@ -1710,6 +1710,7 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
*/ */
if (!blum.seeded) { if (!blum.seeded) {
p_blum = randomcopy(&init_blum); p_blum = randomcopy(&init_blum);
randomfree(&blum);
blum = *p_blum; blum = *p_blum;
free(p_blum); free(p_blum);
} }
@@ -1868,6 +1869,7 @@ zsrandom4(CONST ZVALUE seed, CONST ZVALUE ip, CONST ZVALUE iq, long trials)
*/ */
if (!blum.seeded) { if (!blum.seeded) {
p_blum = randomcopy(&init_blum); p_blum = randomcopy(&init_blum);
randomfree(&blum);
blum = *p_blum; blum = *p_blum;
free(p_blum); free(p_blum);
} }
@@ -1962,6 +1964,7 @@ zsetrandom(CONST RANDOM *state)
*/ */
if (!blum.seeded) { if (!blum.seeded) {
p_blum = randomcopy(&init_blum); p_blum = randomcopy(&init_blum);
randomfree(&blum);
blum = *p_blum; blum = *p_blum;
free(p_blum); free(p_blum);
} }
@@ -2005,6 +2008,7 @@ zrandomskip(long cnt)
*/ */
if (!blum.seeded) { if (!blum.seeded) {
p_blum = randomcopy(&init_blum); p_blum = randomcopy(&init_blum);
randomfree(&blum);
blum = *p_blum; blum = *p_blum;
free(p_blum); free(p_blum);
} }
@@ -2109,6 +2113,7 @@ zrandom(long cnt, ZVALUE *res)
*/ */
if (!blum.seeded) { if (!blum.seeded) {
p_blum = randomcopy(&init_blum); p_blum = randomcopy(&init_blum);
randomfree(&blum);
blum = *p_blum; blum = *p_blum;
free(p_blum); free(p_blum);
} }
@@ -2390,6 +2395,9 @@ randomcopy(CONST RANDOM *state)
/* /*
* randomfree - free a Blum state * randomfree - free a Blum state
* *
* We avoid freeing the pre-compiled states as they were
* never malloced in the first place.
*
* given: * given:
* state - the state to free * state - the state to free
*/ */
@@ -2406,11 +2414,15 @@ randomfree(RANDOM *state)
} }
/* free the values */ /* free the values */
state->seeded = 0; if (state->n.v != h_ndefvec) {
zfree(state->n); zfree(state->n);
zfree(state->r); }
if (state->r.v != h_rdefvec) {
zfree(state->r);
}
/* free it if it is not pre-defined */ /* free it if it is not pre-defined */
state->seeded = 0;
if (state != &blum) { if (state != &blum) {
free(state); free(state);
} }