From b54d8fc510e92517117327a4ddf5b789315023cd Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Thu, 7 Oct 1999 08:44:34 -0700 Subject: [PATCH] Release calc version 2.11.0t6 --- BUGS | 36 ------------------ CHANGES | 62 +++++++++++++++++++++--------- Makefile | 2 +- README | 91 ++++++++++++++++++-------------------------- README.FIRST | 54 -------------------------- README.OLD | 73 +++++++++++++++++++++++++++++++++++ addop.c | 2 +- calc.h | 2 +- custom/c_pzasusb8.c | 2 - hash.c | 49 ++++++++++++++++++++++-- lib/README | 50 ++++++++++++++++-------- lib/beer.cal | 4 -- lib/bernoulli.cal | 4 -- lib/bigprime.cal | 4 -- lib/deg.cal | 7 ---- lib/ellip.cal | 8 +--- lib/hello.cal | 4 -- lib/lucas.cal | 4 -- lib/lucas_chk.cal | 4 -- lib/mersenne.cal | 4 -- lib/mod.cal | 28 ++++---------- lib/natnumset.cal | 38 ------------------ lib/pell.cal | 5 --- lib/pi.cal | 4 -- lib/pix.cal | 4 -- lib/pollard.cal | 6 +-- lib/poly.cal | 35 ----------------- lib/prompt.cal | 5 --- lib/psqrt.cal | 5 --- lib/quat.cal | 15 -------- lib/randbitrun.cal | 4 -- lib/randmprime.cal | 4 -- lib/randombitrun.cal | 4 -- lib/randomrun.cal | 4 -- lib/regress.cal | 91 +++++++++++++++++++++++++++++++++++++++++--- lib/solve.cal | 4 -- lib/sumsq.cal | 4 -- lib/surd.cal | 19 --------- lib/test1700.cal | 4 -- lib/test2300.cal | 4 -- lib/test2600.cal | 22 ----------- lib/test2700.cal | 20 ---------- lib/test3100.cal | 11 ------ lib/test3300.cal | 8 ---- lib/test3400.cal | 12 ------ lib/test3500.cal | 11 ------ lib/test4000.cal | 29 -------------- lib/test4100.cal | 17 --------- lib/test4600.cal | 9 ----- lib/test5100.cal | 6 --- lib/test5200.cal | 8 ---- lib/unitfrac.cal | 5 --- lib/xx_print.cal | 16 +------- version.c | 2 +- zrandom.c | 22 ++++++++--- 55 files changed, 351 insertions(+), 600 deletions(-) delete mode 100644 README.FIRST create mode 100644 README.OLD diff --git a/BUGS b/BUGS index 40ff5c1..0ef8e99 100644 --- a/BUGS +++ b/BUGS @@ -78,42 +78,6 @@ Known problems or mis-features: and not much in the way of comments. We need some major cleanup 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" - 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 version 2.11.0t5.1 fails in the regression test: diff --git a/CHANGES b/CHANGES index b3d7b02..49742d3 100644 --- a/CHANGES +++ b/CHANGES @@ -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. Calc will written ANSI C. We just compiled with a suggestion from Love-Jensen, John to make calc's version - of C a little more to C++ compilers. Avoiding symbols such as new - or try for example. + of C a little more to C++ compilers. We are simply avoiding symbols + 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. @@ -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}. - ### XXX - this change has been backed out: - # - # Thanks to the efforts of Ernest Bowen and - # Dr.D.J.Picton , 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 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 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 - psuedo-random generator. - - Added functionality from Ernest Bowen - to give arguments as well as function names after definitions when - calc_debug >= 0. + pseudo-random generator. Added functionality from Ernest Bowen to 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 Ernest Bowen's diagnostic patch. + Thanks to the efforts of Ernest Bowen and + Dr.D.J.Picton , 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 + 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 + to correctly hash a V_STR value-type that has an \0 byte + inside it. + Fixed misc compile warnings and notices. diff --git a/Makefile b/Makefile index 1a26548..bd3c680 100644 --- a/Makefile +++ b/Makefile @@ -931,7 +931,7 @@ C_SRC= ${LIBSRC} ${CALCSRC} ${UTIL_C_SRC} # These files are found (but not built) in the distribution # 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 # diff --git a/README b/README index bcc296a..8f0d8ce 100644 --- a/README +++ b/README @@ -1,73 +1,54 @@ -# 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. +Dear calc user, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - NOTE: This is an old historic README. We recommend that you - read README.FIRST and HOWTO.INSTALL for more info. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +See the HOWTO.INSTALL file for information on how to build and install calc. -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. +To be sure that your version of calc is up to date, check out: --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: - - 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<<<== +If you run into problems, see the BUGS file. =-= -For further reading: - - LIBRARY - explains how programs can use libcalc.a to take advantage - of the calc multi-precision routines. +See the file: help/todo - current wish list for calc - CHANGES - recent changes to calc +or run: - BUGS - known bugs, mis-features and how to report problems + calc 'help todo' - help/full - full set of calc documentation +for a wish/todo list. Code contributions are welcome. =-= -David I. Bell dbell@auug.org.au -chongo@toad.com /\../\ +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 diff --git a/README.FIRST b/README.FIRST deleted file mode 100644 index 8f0d8ce..0000000 --- a/README.FIRST +++ /dev/null @@ -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 diff --git a/README.OLD b/README.OLD new file mode 100644 index 0000000..0c2fb3b --- /dev/null +++ b/README.OLD @@ -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 /\../\ diff --git a/addop.c b/addop.c index 19f0e0e..76fe5d1 100644 --- a/addop.c +++ b/addop.c @@ -237,7 +237,7 @@ rmuserfunc(char *name) return; freenumbers(functions[index]); free(functions[index]); - if (!inputisterminal() && conf->lib_debug >= 0) + if (inputisterminal() && conf->lib_debug >= 0) printf("%s() undefined\n", name); functions[index] = NULL; } diff --git a/calc.h b/calc.h index e22034e..23c81dc 100644 --- a/calc.h +++ b/calc.h @@ -37,7 +37,7 @@ #define SYMBOLSIZE 256 /* maximum symbol name size */ #define MAXINDICES 20 /* maximum number of indices for objects */ #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 MAXSTACK 1000 /* maximum depth of evaluation stack */ #define MAXFILES 20 /* maximum number of opened files */ diff --git a/custom/c_pzasusb8.c b/custom/c_pzasusb8.c index 23647d3..9c9bbf0 100644 --- a/custom/c_pzasusb8.c +++ b/custom/c_pzasusb8.c @@ -31,7 +31,6 @@ c_pzasusb8(char *name, int count, VALUE **vals) { VALUE result; /* what we will return */ ZVALUE z; /* numerator of the value */ - long octet_cnt; /* number of octets in the numerator */ long half_cnt; /* number of HALFs in the numerator */ USB8 *h; /* octet pointer */ 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; half_len = sizeof(HALF); - octet_cnt = z.len * half_len; half_cnt = z.len; /* diff --git a/hash.c b/hash.c index c08ff32..33b99ae 100644 --- a/hash.c +++ b/hash.c @@ -391,8 +391,8 @@ hash_zvalue(int type, ZVALUE zval, HASH *state) */ if (zval.len > full_lim) { for (j=0; j < zval.len-full_lim-1; j += 2) { - half[j] = zval.v[full_lim+i+1]; - half[j+1] = zval.v[full_lim+i]; + half[j] = zval.v[full_lim+j+1]; + half[j+1] = zval.v[full_lim+j]; } if (j < zval.len-full_lim) { 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: * type - hash type (see hash.h) @@ -604,6 +604,47 @@ hash_str(int type, char *str, HASH *state) */ return 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; +} /* @@ -720,7 +761,7 @@ hash_value(int type, void *v, HASH *state) /* strings have no setup */ /* hash this type */ - state = hash_str(type, value->v_str->s_str, state); + state = hash_STR(type, value->v_str, state); break; case V_MAT: diff --git a/lib/README b/lib/README index afd66c1..92b8921 100644 --- a/lib/README +++ b/lib/README @@ -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, # 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: - dbell@auug.org.au - chongo@toad.com {uunet,pyramid,sun}!hoptoad!chongo + calc-tester@postofc.corp.sgi.com By convention, a lib file only defines and/or initializes functions, -objects and variables. (The regression test is an exception.) Also by -convention, the a usage message regarding each important object and -function is printed at the time of the read. +objects and variables. (The regress.cal and testxxx.cal regression test +suite is an exception.) Also by convention, an additional usage message +regarding important object and functions is printed. If a lib file needs to load another lib file, it should use the -once 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 to other debug messages -To conform to the above convention, your lib files should end with -lines of the form: +When config("lib_debug") >= 0, function names and their arg are +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) { print "obj xyz defined"; - print "funcA(side_a, side_b, side_c) defined"; - print "funcB(size, mass) defined"; + print "funcA([val1 [, val2]]) defined"; + print "funcB(size, mass, ...) defined"; } - =-= beer.cal @@ -100,7 +106,7 @@ deg.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. @@ -160,7 +166,7 @@ mfactor.cal mod.cal - mod(a) + lmod(a) mod_print(a) mod_one() mod_cmp(a, b) @@ -250,7 +256,7 @@ pix.cal pollard.cal - factor(N, N, ai, af) + pfactor(N, N, ai, af) Factor using Pollard's p-1 method. @@ -520,6 +526,20 @@ test3400.cal This script is used by regress.cal to test trig functions. 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 global defaultverbose @@ -617,7 +637,7 @@ varargs.cal xx_print.cal - isoctet(a) defined + is_octet(a) defined list_print(a) defined mat_print (a) defined octet_print(a) defined diff --git a/lib/beer.cal b/lib/beer.cal index 81f8343..ec5c120 100644 --- a/lib/beer.cal +++ b/lib/beer.cal @@ -20,7 +20,3 @@ for (i=99; i > 0;) { bottles = (i!=1) ? "bottles" : "bottle"; print less, bottles, "of beer on the wall!\n"; } - -if (config("lib_debug") >= 0) { - /* nothing to do! */ -} diff --git a/lib/bernoulli.cal b/lib/bernoulli.cal index fcf7dad..8a2fabf 100644 --- a/lib/bernoulli.cal +++ b/lib/bernoulli.cal @@ -60,7 +60,3 @@ define B(n) Bnmax = n; return Bn[n]; } - -if (config("lib_debug") >= 0) { - print "B(n) defined"; -} diff --git a/lib/bigprime.cal b/lib/bigprime.cal index 0a1e9d6..29c4458 100644 --- a/lib/bigprime.cal +++ b/lib/bigprime.cal @@ -25,7 +25,3 @@ define bigprime(a, m, p) print " " : n; } } - -if (config("lib_debug") >= 0) { - print "bigprime(a, m, p) defined"; -} diff --git a/lib/deg.cal b/lib/deg.cal index c28daac..80313ff 100644 --- a/lib/deg.cal +++ b/lib/deg.cal @@ -113,11 +113,4 @@ define fixdms(a) if (config("lib_debug") >= 0) { 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"; } diff --git a/lib/ellip.cal b/lib/ellip.cal index b5f6a4c..a83e157 100644 --- a/lib/ellip.cal +++ b/lib/ellip.cal @@ -24,7 +24,7 @@ * only an approximation, read "A Course in Number Theory and Cryptography" * by Neal Koblitz for a good explanation. * - * factor(iN, ia, B, force) + * efactor(iN, ia, B, force) * iN is the number to be factored. * ia is the initial value of a in the equation, and each successive * value of a is an independent attempt at factoring (default 1). @@ -66,7 +66,7 @@ global b; /* second coefficient */ global f; /* found factor */ -define factor(iN, ia, B, force) +define efactor(iN, ia, B, force) { local C, x, p; @@ -165,7 +165,3 @@ define point_pow(p, pow) } return r; } - -if (config("lib_debug") >= 0) { - print "factor(N, I, B, force) defined"; -} diff --git a/lib/hello.cal b/lib/hello.cal index de998b3..c208bed 100644 --- a/lib/hello.cal +++ b/lib/hello.cal @@ -6,7 +6,3 @@ */ while(1) print "Hello World!"; - -if (config("lib_debug") >= 0) { - /* nothing to do */ -} diff --git a/lib/lucas.cal b/lib/lucas.cal index 7577141..812f069 100644 --- a/lib/lucas.cal +++ b/lib/lucas.cal @@ -1029,7 +1029,3 @@ ldebug(funct, str) } return; } - -if (config("lib_debug") >= 0) { - print "lucas(h, n) defined"; -} diff --git a/lib/lucas_chk.cal b/lib/lucas_chk.cal index 9f4e2d8..b5cb9b8 100644 --- a/lib/lucas_chk.cal +++ b/lib/lucas_chk.cal @@ -374,7 +374,3 @@ lucas_chk(high_n, quiet) return 0; } } - -if (config("lib_debug") >= 0) { - print "lucas_chk(high_n) defined"; -} diff --git a/lib/mersenne.cal b/lib/mersenne.cal index 105464b..9d480d3 100644 --- a/lib/mersenne.cal +++ b/lib/mersenne.cal @@ -31,7 +31,3 @@ define mersenne(p) /* 2^p-1 is prime iff u(p) = 0 mod 2^p-1 */ return (u == 0); } - -if (config("lib_debug") >= 0) { - print "mersenne(p) defined"; -} diff --git a/lib/mod.cal b/lib/mod.cal index 5a3d18e..4d0cddb 100644 --- a/lib/mod.cal +++ b/lib/mod.cal @@ -12,12 +12,12 @@ obj mod {a}; /* definition of the object */ global mod_value = 100; /* modulus value (value of N) */ -define mod(a) +define lmod(a) { local obj mod x; if (!isreal(a) || !isint(a)) - quit "Bad argument for mod function"; + quit "Bad argument for lmod function"; x.a = a % mod_value; return x; } @@ -34,7 +34,7 @@ define mod_print(a) define mod_one() { - return mod(1); + return lmod(1); } @@ -51,9 +51,9 @@ define mod_cmp(a, b) define mod_rel(a, b) { if (isnum(a)) - a = mod(a); + a = lmod(a); if (isnum(b)) - b = mod(b); + b = lmod(b); if (a.a < b.a) return -1; return a.a != b.a; @@ -163,9 +163,9 @@ define mod_div(a, b) obj mod x, y; if (isnum(a)) - a = mod(a); + a = lmod(a); if (isnum(b)) - b = mod(b); + b = lmod(b); c = gcd(a.a, b.a); x.a = a.a / c; y.a = b.a / c; @@ -191,20 +191,6 @@ define mod_pow(a, b) if (config("lib_debug") >= 0) { 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 "set mod_value as needed"; } diff --git a/lib/natnumset.cal b/lib/natnumset.cal index 415e7d1..795ff1b 100644 --- a/lib/natnumset.cal +++ b/lib/natnumset.cal @@ -592,41 +592,3 @@ define set_print(a) } 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"; -} diff --git a/lib/pell.cal b/lib/pell.cal index 1dbb106..56ad7c3 100644 --- a/lib/pell.cal +++ b/lib/pell.cal @@ -66,8 +66,3 @@ define pellx(D) } return Q1; } - -if (config("lib_debug") >= 0) { - print "pell(D) defined"; - print "pellx(D) defined"; -} diff --git a/lib/pi.cal b/lib/pi.cal index d2a1ba5..0831c82 100644 --- a/lib/pi.cal +++ b/lib/pi.cal @@ -47,7 +47,3 @@ define qpi(epsilon) } return (bround(1/an, bits)); } - -if (config("lib_debug") >= 0) { - print "qpi(epsilon) defined"; -} diff --git a/lib/pix.cal b/lib/pix.cal index 967d4f8..6131f0c 100644 --- a/lib/pix.cal +++ b/lib/pix.cal @@ -38,7 +38,3 @@ define pi_of_x(x) } return primes; } - -if (config("lib_debug") >= 0) { - print "pi_of_x(x) defined"; -} diff --git a/lib/pollard.cal b/lib/pollard.cal index 8c4e172..3159264 100644 --- a/lib/pollard.cal +++ b/lib/pollard.cal @@ -6,7 +6,7 @@ * Factor using Pollard's p-1 method. */ -define factor(N, B, ai, af) +define pfactor(N, B, ai, af) { local a, k, i, d; @@ -28,7 +28,3 @@ define factor(N, B, ai, af) } return 1; } - -if (config("lib_debug") >= 0) { - print "factor(N, B, ai, af) defined"; -} diff --git a/lib/poly.cal b/lib/poly.cal index 4569e9a..cf30e06 100644 --- a/lib/poly.cal +++ b/lib/poly.cal @@ -689,39 +689,4 @@ c=pol(1+2i,3+4i,5+6i); if (config("lib_debug") >= 0) { 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"; } diff --git a/lib/prompt.cal b/lib/prompt.cal index 71e3110..8a602db 100644 --- a/lib/prompt.cal +++ b/lib/prompt.cal @@ -94,8 +94,3 @@ define showvalues(str) { print "\t":eval(str); } } - -if (config("lib_debug") >= 0) { - print "adder() defined"; - print "showvalues(str) defined"; -} diff --git a/lib/psqrt.cal b/lib/psqrt.cal index 10ce7be..e77dc94 100644 --- a/lib/psqrt.cal +++ b/lib/psqrt.cal @@ -48,8 +48,3 @@ define psqrt(u, p) } return min(v, p - v); } - - -if (config("lib_debug") >= 0) { - print "psqrt(u, p) defined"; -} diff --git a/lib/quat.cal b/lib/quat.cal index a8ca6b6..88c96c4 100644 --- a/lib/quat.cal +++ b/lib/quat.cal @@ -197,19 +197,4 @@ define quat_shift(a, b) if (config("lib_debug") >= 0) { 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"; } diff --git a/lib/randbitrun.cal b/lib/randbitrun.cal index 1d72139..d3ec206 100644 --- a/lib/randbitrun.cal +++ b/lib/randbitrun.cal @@ -112,7 +112,3 @@ define randbitrun(run_cnt) printf("length>%d\t\t\t\t\tcount=%d\n", MAX_RUN, long_run_cnt); printf("max length=%d\n", max_run); } - -if (config("lib_debug") >= 0) { - print "randbitrun([run_length]) defined"; -} diff --git a/lib/randmprime.cal b/lib/randmprime.cal index 8679106..438036d 100644 --- a/lib/randmprime.cal +++ b/lib/randmprime.cal @@ -129,7 +129,3 @@ randmprime(bits, seed, dbg) } return ret; } - -if (config("lib_debug") >= 0) { - print "randmprime(bits, seed [,dbg]) defined"; -} diff --git a/lib/randombitrun.cal b/lib/randombitrun.cal index a51ac7e..acc8526 100644 --- a/lib/randombitrun.cal +++ b/lib/randombitrun.cal @@ -112,7 +112,3 @@ define randombitrun(run_cnt) printf("length>%d\t\t\t\t\tcount=%d\n", MAX_RUN, long_run_cnt); printf("max length=%d\n", max_run); } - -if (config("lib_debug") >= 0) { - print "randombitrun([run_length]) defined"; -} diff --git a/lib/randomrun.cal b/lib/randomrun.cal index a091c6b..5232613 100644 --- a/lib/randomrun.cal +++ b/lib/randomrun.cal @@ -121,7 +121,3 @@ define randomrun(run_cnt) printf("length>%d\t\t\t\t\tcount=%d\n", MAX_RUN, long_run_cnt); printf("max length=%d\n", max_run); } - -if (config("lib_debug") >= 0) { - print "randomrun([run_length]) defined"; -} diff --git a/lib/regress.cal b/lib/regress.cal index b8ff3a1..dcac0be 100644 --- a/lib/regress.cal +++ b/lib/regress.cal @@ -7010,7 +7010,7 @@ define test_bigcomb() { local a, b, n, i, v1, v2; - print '7900: Starting test_bigcomb()'; + print '7900: Starting test_bigcomb'; a = 1234/4321; print '7901: a = 1234/4321'; b = 3456/6543; @@ -7033,7 +7033,7 @@ define test_bigcomb() 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)'); - print '7914: Ending test_bigcomb()'; + print '7914: Ending test_bigcomb'; } print '186: parsed test_bigcomb()'; @@ -7048,7 +7048,7 @@ define test_natnumset() { 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); 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), '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()'; @@ -7115,7 +7115,7 @@ print '188: parsed test_natnumset()'; */ 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(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(inverse(1/0) == 0, '8216: inverse(1/0) == 0'); - print '8217: Ending test_somenew()'; + print '8217: Ending test_somenew'; } print '189: parsed test_somenew()'; @@ -7392,6 +7392,85 @@ return test_natnumset(); print; 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 */ diff --git a/lib/solve.cal b/lib/solve.cal index f6469bf..8da05af 100644 --- a/lib/solve.cal +++ b/lib/solve.cal @@ -41,7 +41,3 @@ define solve(low, high, epsilon) } } } - -if (config("lib_debug") >= 0) { - print "solve(low, high, epsilon) defined"; -} diff --git a/lib/sumsq.cal b/lib/sumsq.cal index ffc1374..d755654 100644 --- a/lib/sumsq.cal +++ b/lib/sumsq.cal @@ -37,7 +37,3 @@ define ss(p) } print a : "^2 +" , b : "^2 =" , a^2 + b^2; } - -if (config("lib_debug") >= 0) { - print "ss(p) defined"; -} diff --git a/lib/surd.cal b/lib/surd.cal index 6d55b82..b41f5a3 100644 --- a/lib/surd.cal +++ b/lib/surd.cal @@ -263,25 +263,6 @@ define surd_rel(a, b) if (config("lib_debug") >= 0) { 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 "set surd_type as needed"; } diff --git a/lib/test1700.cal b/lib/test1700.cal index 47f9324..081d8b3 100644 --- a/lib/test1700.cal +++ b/lib/test1700.cal @@ -10,7 +10,3 @@ */ ++value; - -if (config("lib_debug") >= 0) { - /* nothing to do */ -} diff --git a/lib/test2300.cal b/lib/test2300.cal index a1a7956..d288339 100644 --- a/lib/test2300.cal +++ b/lib/test2300.cal @@ -95,7 +95,3 @@ define ckmat() /* args match the matrix in the object */ return 1; } - -if (config("lib_debug") >= 0) { - /* nothing to do */ -} diff --git a/lib/test2600.cal b/lib/test2600.cal index ef54564..ddd39b0 100644 --- a/lib/test2600.cal +++ b/lib/test2600.cal @@ -491,25 +491,3 @@ define test2600(verbose, 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"; -} diff --git a/lib/test2700.cal b/lib/test2700.cal index 42b8be2..28a1848 100644 --- a/lib/test2700.cal +++ b/lib/test2700.cal @@ -308,23 +308,3 @@ define test2700(verbose, 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"; -} diff --git a/lib/test3100.cal b/lib/test3100.cal index 45bad43..e75c3a6 100644 --- a/lib/test3100.cal +++ b/lib/test3100.cal @@ -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_inv(a) {local obj res v = {minv(a.r, 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"; -} diff --git a/lib/test3300.cal b/lib/test3300.cal index ef74f7c..5178636 100644 --- a/lib/test3300.cal +++ b/lib/test3300.cal @@ -122,11 +122,3 @@ define test3300(verbose, 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"; -} diff --git a/lib/test3400.cal b/lib/test3400.cal index 0005059..6273040 100644 --- a/lib/test3400.cal +++ b/lib/test3400.cal @@ -299,15 +299,3 @@ define test3400(verbose, 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"; -} diff --git a/lib/test3500.cal b/lib/test3500.cal index 7eca70b..ba2acd6 100644 --- a/lib/test3500.cal +++ b/lib/test3500.cal @@ -272,14 +272,3 @@ define test3500(verbose, tnum, n, N) } 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"; -} diff --git a/lib/test4000.cal b/lib/test4000.cal index f2ae7c6..8c94fcd 100644 --- a/lib/test4000.cal +++ b/lib/test4000.cal @@ -452,32 +452,3 @@ define test4000(v, 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"; -} diff --git a/lib/test4100.cal b/lib/test4100.cal index 3ccacc4..c05cadc 100644 --- a/lib/test4100.cal +++ b/lib/test4100.cal @@ -472,20 +472,3 @@ define test4100(v, 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"; -} diff --git a/lib/test4600.cal b/lib/test4600.cal index 98892d3..2b075fc 100644 --- a/lib/test4600.cal +++ b/lib/test4600.cal @@ -304,12 +304,3 @@ define test4600(v, 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"; -} diff --git a/lib/test5100.cal b/lib/test5100.cal index 140cb68..25dec81 100644 --- a/lib/test5100.cal +++ b/lib/test5100.cal @@ -48,9 +48,3 @@ define test5100(x) } global a5100 = a5100, b5100 = b5100; } - -if (config("lib_debug") >= 0) { - print "global a5100"; - print "global b5100"; - print "test5100(x) defined"; -} diff --git a/lib/test5200.cal b/lib/test5200.cal index 4e2d2cc..49c4c22 100644 --- a/lib/test5200.cal +++ b/lib/test5200.cal @@ -30,11 +30,3 @@ static a5200 = 20; define f5200(x) = a5200 + x; define g5200(x) {global a5200 = 30; return 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"; -} diff --git a/lib/unitfrac.cal b/lib/unitfrac.cal index dad7f17..8f2416f 100644 --- a/lib/unitfrac.cal +++ b/lib/unitfrac.cal @@ -27,8 +27,3 @@ define unitfrac(x) } while ((num(x) > 1) || (x == di) || (x == 1)); print ' [1/1]',, x; } - - -if (config("lib_debug") >= 0) { - print "unitfrac(x) defined"; -} diff --git a/lib/xx_print.cal b/lib/xx_print.cal index e660e5f..b687f7a 100644 --- a/lib/xx_print.cal +++ b/lib/xx_print.cal @@ -21,7 +21,7 @@ print "global blkmax defined, assigned value 8"; print; B = blk(); -define isoctet(a) = istype(a, B[0]); +define is_octet(a) = istype(a, B[0]); define list_print(a) { local i; @@ -131,7 +131,7 @@ define strchar(a) { if (isstr(a)) a = ord(a); - else if (isoctet(a)) + else if (is_octet(a)) a = a; /* This converts octet to number */ 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 B1; 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"; -} diff --git a/version.c b/version.c index 95a431a..9ee0316 100644 --- a/version.c +++ b/version.c @@ -12,7 +12,7 @@ #define MAJOR_VER 2 /* major version */ #define MINOR_VER 11 /* minor version */ #define MAJOR_PATCH 0 /* patch level or 0 if no patch */ -#define MINOR_PATCH "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 diff --git a/zrandom.c b/zrandom.c index 3205112..3249b55 100644 --- a/zrandom.c +++ b/zrandom.c @@ -1598,6 +1598,7 @@ zsrandom1(CONST ZVALUE seed, BOOL need_ret) */ if (!blum.seeded) { p_blum = randomcopy(&init_blum); + randomfree(&blum); blum = *p_blum; free(p_blum); } @@ -1621,9 +1622,8 @@ zsrandom1(CONST ZVALUE seed, BOOL need_ret) if (ziszero(seed)) { /* set to the default generator state */ - zfree(blum.n); - zfree(blum.r); p_blum = randomcopy(&init_blum); + randomfree(&blum); blum = *p_blum; free(p_blum); @@ -1710,6 +1710,7 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn) */ if (!blum.seeded) { p_blum = randomcopy(&init_blum); + randomfree(&blum); blum = *p_blum; free(p_blum); } @@ -1868,6 +1869,7 @@ zsrandom4(CONST ZVALUE seed, CONST ZVALUE ip, CONST ZVALUE iq, long trials) */ if (!blum.seeded) { p_blum = randomcopy(&init_blum); + randomfree(&blum); blum = *p_blum; free(p_blum); } @@ -1962,6 +1964,7 @@ zsetrandom(CONST RANDOM *state) */ if (!blum.seeded) { p_blum = randomcopy(&init_blum); + randomfree(&blum); blum = *p_blum; free(p_blum); } @@ -2005,6 +2008,7 @@ zrandomskip(long cnt) */ if (!blum.seeded) { p_blum = randomcopy(&init_blum); + randomfree(&blum); blum = *p_blum; free(p_blum); } @@ -2109,6 +2113,7 @@ zrandom(long cnt, ZVALUE *res) */ if (!blum.seeded) { p_blum = randomcopy(&init_blum); + randomfree(&blum); blum = *p_blum; free(p_blum); } @@ -2390,6 +2395,9 @@ randomcopy(CONST RANDOM *state) /* * randomfree - free a Blum state * + * We avoid freeing the pre-compiled states as they were + * never malloced in the first place. + * * given: * state - the state to free */ @@ -2406,11 +2414,15 @@ randomfree(RANDOM *state) } /* free the values */ - state->seeded = 0; - zfree(state->n); - zfree(state->r); + if (state->n.v != h_ndefvec) { + zfree(state->n); + } + if (state->r.v != h_rdefvec) { + zfree(state->r); + } /* free it if it is not pre-defined */ + state->seeded = 0; if (state != &blum) { free(state); }