mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
3957 lines
140 KiB
Plaintext
3957 lines
140 KiB
Plaintext
Following is the change from calc version 2.11.0t7 to date:
|
|
|
|
Calc has some new command line flags / command line meaning:
|
|
(Thanks goes to Ernest Bowen <ernie@turing.une.edu.au>)
|
|
|
|
-i Go into interactive mode if possible.
|
|
|
|
-c Continue reading command lines even after an execution
|
|
error has caused the abandonment of a line
|
|
|
|
To understand the -i and -c effects, consider the following
|
|
file (call it myfile.cal) which has deliberate errors in it:
|
|
|
|
print 1;
|
|
mat A[1] = {2,3};
|
|
print 2;
|
|
epsilon(-1);
|
|
print 3;
|
|
|
|
calc read myfile
|
|
|
|
Reports an error on the 2nd line and exits; prints 1 only.
|
|
|
|
calc -c read myfile
|
|
|
|
Report errors on the 2nd and 4th lines and exits; prints 1,2 and 3.
|
|
|
|
calc -i read myfile
|
|
|
|
Report errors on the 2nd and gives you a prompt; prints 1 only.
|
|
|
|
calc -i -c read myfile
|
|
|
|
Report errors on the 2nd and 4th and gives you a prompt;
|
|
prints 1, 2 and 3.
|
|
|
|
cat myfile | calc
|
|
|
|
Reports an error on the 2nd line and exits; prints 1 only.
|
|
|
|
cat myfile | calc -c
|
|
|
|
Report errors on the 2nd and 4th lines and exits; prints 1,2 and 3.
|
|
|
|
Note that continuation refers to command lines, not to statements. So:
|
|
|
|
calc -c 'print "start"; mat A[1] = {2,3}; print "end";'
|
|
|
|
since it contains no newline, the whole string is compiled,
|
|
but execution is abandoned when the error is encountered and
|
|
the string ``end'' is not printed.
|
|
|
|
You can use your shell to supply newlines in your command line
|
|
arguments. For example in sh, ksh, bash:
|
|
|
|
calc -c 'print "start";
|
|
mat A[1] = {2,3};
|
|
print "end";'
|
|
|
|
will print both ``start'' and ``end''. C-shell users can do:
|
|
|
|
calc -c 'print "start"; \
|
|
mat A[1] = {2,3}; \
|
|
print "end";'
|
|
|
|
however sh, ksh, bash will not see ``end'' printed because their
|
|
shell will remove the internal newlines.
|
|
|
|
Added display(n) builtin which does almost the same as config("display",n)
|
|
except that rather than causing an execution with an out-of-range or
|
|
bad-type argument type, it simply writes a message to stderr. This
|
|
also now happens to the errmax() builtin.
|
|
|
|
Added qtime.cal to the standard calc library.
|
|
|
|
Added another command line flag to calc:
|
|
|
|
-d Disable display of the opening title and config("lib_debug",0)
|
|
|
|
The command:
|
|
|
|
calc 'read qtime; qtime(2)'
|
|
|
|
will output something like:
|
|
|
|
qtime(utc_hr_offset) defined
|
|
It's nearly ten past six.
|
|
|
|
whereas:
|
|
|
|
calc -d 'read qtime; qtime(2)'
|
|
|
|
will just say:
|
|
|
|
It's nearly ten past six.
|
|
|
|
A call of errmax(-1) will prevent errcount from aborting calc.
|
|
|
|
|
|
Following is the change from calc version 2.11.0t1 to 2.11.0t6.3:
|
|
|
|
Removed the makefile symbol MAIN. Now forcing all functions to correctly
|
|
be declared main. To satisfy some old broken compilers, a return 0;
|
|
(instead of an exit(0);) is used at the end of main().
|
|
|
|
A few of files that were added to calc used 4 character indentation
|
|
whereas most of calc uses 8 character indentation. These imported
|
|
sources have been changed to conform better with the calc style.
|
|
|
|
Added the program calc_errno.c and the Makefile symbol ERRNO_DECL.
|
|
If ERRNO_DECL is empty, calc_errno.c will try various ways to
|
|
declare errno, sys_errlist and sys_nerr. On success or when
|
|
it gives up, calc_errno will output the middle of the calc_errno.h
|
|
header file. If ERRNO_DECL is -DERRNO_NO_DECL, or -DERRNO_STD_DECL
|
|
or -DERRNO_OLD_DECL then the Makefile will build the middle
|
|
of the calc_errno.h header file without calc_errno.c's help.
|
|
|
|
The func.c file now includes the constructed header file calc_errno.h
|
|
to ensure that errno, sys_errlist and sys_nerr are declared correctly.
|
|
|
|
Changed check.awk to be more 'old awk' friendly.
|
|
|
|
Made some of the source a little more ++ friendly. We are NOT
|
|
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 <jlove-jensen@globalmt.com> to make calc's version
|
|
of C a little more to C++ compilers. We are simply avoiding symbols
|
|
such as new or try for example.
|
|
|
|
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.
|
|
|
|
Reordered cc Makefile variable sets in the main Makefile.
|
|
|
|
Fixed a bug in hnrmod() and applied a fix that was reported by Ernest
|
|
Bowen <ernie@turing.une.edu.au>. Added regression tests 1103 to
|
|
1112 to confirm the fix.
|
|
|
|
Fixed a bug in version.c related to MINOR_PATCHs in both the
|
|
empty and non-empty MINOR_PATCH cases.
|
|
|
|
Fixed malloc and bad storage issues reported by Michel van der List
|
|
<vanderlistmj@sbphrd.com>.
|
|
|
|
Fixed some problems related to path processing while opening files.
|
|
Under extreme cases, an excessively long filename or CALCPATH value
|
|
could create problems. Placed guards in opensearchfile() function
|
|
in input.c to catch these cases.
|
|
|
|
Fixed cases were malloc failures were silently ignored in input.c.
|
|
|
|
Eliminated the PATHSIZE limit and the PATHSIZE symbol.
|
|
|
|
Added MAX_CALCRC to limit the length of the $CALCRC environment
|
|
variable to 1024 chars.
|
|
|
|
Fixed the magic number relating to the initial number of constants
|
|
declared by initconstants(). It is now related to the length
|
|
of the initnumbs[] NUMBER array.
|
|
|
|
Added a 'Dec Alpha / Compaq Tru64 cc (non-gnu) compiler set'
|
|
section to the main Makefile.
|
|
|
|
Fixed a string handling bug discovered by Dr.D.J.Picton
|
|
<dave@aps5.ph.bham.ac.uk> in the custom demo code.
|
|
|
|
Fixed a bug in the hnrmod() builtin that was discovered by
|
|
Ernest Bowen <ernie@neumann.une.edu.au>.
|
|
|
|
Added FORCE_STDC symbol. When defined it will force __STDC__ like
|
|
conditions. Thus for compilers with as the Solaris cc compiler
|
|
that are ANSI-like but still define __STDC__ as 0, one can use
|
|
-DFORCE_STDC and make use of ANSI-like features.
|
|
|
|
Removed the CCSHS symbol from the Makefile. The shs.c and shs1.c
|
|
files are now compiled with full ${CFLAGS}.
|
|
|
|
The custom.c file is now compiled with full ${CFLAGS}.
|
|
|
|
Rewrote command line / argument processing code. Calc is now
|
|
using getopt(3) argument processing.
|
|
|
|
Fixed a memory leak related to converting strings to numbers
|
|
in the str2q() function in qio.c.
|
|
|
|
Fixed a problem with reading uninitialized memory in the
|
|
v_subtype of a VALUE in the copyvalue() function in value.c.
|
|
|
|
Fixed problems in func.c where temporary VALUEs were not
|
|
having their v_type elements initialized.
|
|
|
|
Fixed a memory leak in qpi() in qtrans.c.
|
|
|
|
Fixed a memory leak in math_getdivertedio() in zio.c.
|
|
|
|
Fixed a problem with points going beyond the end of allocated
|
|
memory in addstring() in string.c.
|
|
|
|
Fixed a memory leak in zgcdrem(), f_putenv(), zlog() and
|
|
zlog10() in zfunc.c.
|
|
|
|
Fixed a memory leak in zdiv() and zshift() in zmath.c.
|
|
|
|
Fixed memory leaks in zsrand() in zrand.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
|
|
pseudo-random generator.
|
|
|
|
Added functionality from Ernest Bowen <ernie@turing.une.edu.au> to
|
|
permit nested "= {...}" assignments for lists as well as matrices
|
|
and objects. Now one can have a list, matrix or object, some of
|
|
whose elements are lists, matrices or objects, to any depth of
|
|
recursion, and assign values to any number of particular elements
|
|
by an appropriate "initialization" expression. For example:
|
|
|
|
A = mat[2] = {list(1,2), list(3,4,list(5,6))};
|
|
|
|
and then assign values to the 6 number elements by:
|
|
|
|
A = {{7,8}, {9,10,{11,12}}};
|
|
|
|
Closed files that were previously left open from test4600.cal
|
|
as executed by regress.cal and from opening /dev/null by
|
|
regress.cal itself.
|
|
|
|
Fixed memory leaks from f_strprintf() and f_putenv() in func.c.
|
|
|
|
The regress.cal test suite calls freeredc(), freestatics() and
|
|
freeglobals() at the end of the test suite to free storage
|
|
consumed during the regression.
|
|
|
|
Added custom function custom("pzasusb8", n) and lib/pzasusb8.cal based on
|
|
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.
|
|
|
|
A patch from Ernest Bowen <ernie@turing.une.edu.au> now defines
|
|
special meaning to the first 2 bits of config("lib_debug"):
|
|
|
|
bit 0 set => messages printed when inputisterminal
|
|
bit 1 set => messages printed when reading from a file
|
|
|
|
The lib/regress.cal regression suite does:
|
|
|
|
config("lib_debug", -4);
|
|
|
|
to eliminate lib messages (both bit 0 and bit 1 are not set).
|
|
|
|
Fixed misc compile warnings and notices.
|
|
|
|
|
|
Following is the change from calc version 2.10.3t5.38 to 2.11.0t0:
|
|
|
|
Fixed a few compile problems found under Red Hat 6.0 Linux.
|
|
|
|
|
|
Following is the change from calc version 2.10.3t5.38 to 2.11.3t5.46:
|
|
|
|
Fixed a bug discovered by Ernest Bowen related to matrix-to-matrix copies.
|
|
|
|
Bitwise operations on integers have been extended so that negative
|
|
integers are treated in the same way as the integer types in C.
|
|
|
|
Some changes have been made to lib/regress.cal and lib/natnumset.cal.
|
|
|
|
Removed V_STRLITERAL and V_STRALLOC string type constants and
|
|
renumbered the V_protection types.
|
|
|
|
Added popcnt(x, bitval) builtin which counts the number of
|
|
bits in x that match bitval.
|
|
|
|
Misc compiler warning fixes.
|
|
|
|
Fixed improper use of putchar() and printf() when printing rationals
|
|
(inside qio.c).
|
|
|
|
Fixed previously reported bug in popcnt() in relation to . values.
|
|
|
|
Calc man page changes per suggestion from Martin Buck
|
|
<Martin-2.Buck@student.uni-ulm.de>. The calc man page is
|
|
edited with a few more parameters from the Makefile.
|
|
|
|
Misc Makefile changes per Martin Buck <Martin-2.Buck@student.uni-ulm.de>.
|
|
|
|
Removed trailing blanks from files.
|
|
|
|
Consolidated in the Makefile, where the debug and check rules are found.
|
|
Fixed the regress.cal dependency list.
|
|
|
|
Make chk and check will exit with an error if check.awk detects
|
|
a problem in the regression output. (Martin Buck)
|
|
|
|
Fixed print line for test #4404.
|
|
|
|
Moved custom.c and custom.h to the upper level to fix unresolved symbols.
|
|
|
|
Moved help function processing into help.c.
|
|
|
|
Moved nearly everything into libcalc.a to allow programs access to
|
|
higher level calc objects (e.g., list, assoc, matrix, block, ...).
|
|
|
|
Renamed PATCH_LEVEL to MAJOR_PATCH and SUB_PATCH_LEVEL to MINOR_PATCH.
|
|
Added integers calc_major_ver, calc_minor_ver, calc_major_patch
|
|
and string calc_minor_patch to libcalc.a. Added CALC_TITLE to hold
|
|
the "C-style arbitrary precision calculator" string.
|
|
|
|
The function version(), now returns a malloced version string
|
|
without the title.
|
|
|
|
Consolidated multiple SGI IRIX -n32 sections (for r4k, r5k and r10k)
|
|
into a single section.
|
|
|
|
|
|
Following is the change from calc version 2.10.3t5.34 to 2.10.3t5.37:
|
|
|
|
Per request from David I Bell, the README line:
|
|
|
|
I am allowing this calculator to be freely distributed for personal uses
|
|
|
|
to:
|
|
|
|
I am allowing this calculator to be freely distributed for your enjoyment
|
|
|
|
Added help files for:
|
|
|
|
address agd arrow dereference free freeglobals freeredc freestatics
|
|
gd isptr mattrace oldvalue saveval & * -> and .
|
|
|
|
Fixed blkcpy() and copy() arg order and processing. Now:
|
|
|
|
A = blk() = {1,2,3,4}
|
|
B = blk()
|
|
blkcpy(B,A)
|
|
blkcpy(B,A)
|
|
|
|
will result in B being twice as long as A.
|
|
|
|
Since "make chk" pipes the regression output to awk, we cannot
|
|
assume that stdout and stderr are ttys. Tests #5985 and #5986
|
|
have been removed for this reason. (thanks to Martin Buck
|
|
<Martin-2.Buck@student.uni-ulm.de> for this report)
|
|
|
|
Fixed the order of prints in regress.cal. By convention, a print
|
|
of a test line happens after the test. This is because function
|
|
parsed messages occur after the function is parsed. Also the
|
|
boolean tesrt of vrfy happens before any print statement.
|
|
Therefore a non-test line is tested and printed as follows:
|
|
|
|
y = sha();
|
|
print '7125: y = sha()';
|
|
|
|
The perm(a,b) and comb(a,b) have been extented to arbitrary real a and
|
|
integer b.
|
|
|
|
Fixed a bug in minv().
|
|
|
|
Moved string.c into libcalc.a.
|
|
|
|
The NUMBER union was converted back into a flat structure. Changes
|
|
where 'num' and 'next' symbols were changed to avoid #define conflicts
|
|
were reverse since the #define's needed to support the union went away.
|
|
|
|
Removed trailing blanks from files.
|
|
|
|
Ernest Bowen <ernie@turing.une.edu.au> sent in the following patch
|
|
which is described in the next 34 points:
|
|
|
|
(0) In the past:
|
|
|
|
A = B = strcat("abc", "def");
|
|
|
|
would store "abc" and "def" as literal strings never to be freed, and
|
|
store "abcdef" once each for both A and B. Now the "abc" and "bcd"
|
|
are freed immediately after they are concatenated and "abcdef" is stored
|
|
only once, just as the number 47 would be stored only once for
|
|
|
|
A = B = 47;
|
|
|
|
The new STRING structure that achieves this stores not only the
|
|
address of the first character in the string, but also the "length"
|
|
with which the string was created, the current "links" count, and
|
|
when links == 0 (which indicates the string has been freed) the
|
|
address of the next freed STRING. Except for the null string "",
|
|
all string values are "allocated"; the concept of literal string
|
|
remains for names of variables, object types and elements, etc.
|
|
|
|
(1) strings may now include '\0', as in A = "abc\0def". In normal printing
|
|
this prints as "abc" and strlen(A) returns 3, but its "real" length
|
|
of 7 is given by size(A). (As before there is an 8th zero character
|
|
and sizeof(A) returns 8.)
|
|
|
|
(2) If A is an lvalue whose current value is a string of size n, then
|
|
for 0 <= i < n, A[i] returns the character with index i as an addressed
|
|
octet using the same structure as for blocks, i.e. there is no
|
|
distinction between a string-octet and a block-octet. The same
|
|
operations and functions can be used for both, and as before, an octet
|
|
is in some respects a number in [0,256) and in others a one-character
|
|
string. For example, for A = "abc\0def" one will have both A[0] == "a"
|
|
and A[0] == 97. Assignments to octets can be used to change
|
|
characters in the string, e.g. A[0] = "A", A[1] = 0, A[2] -= 32,
|
|
A[3] = " " will change the above A to "A\0C def".
|
|
|
|
(3) "show strings" now displays the indices, links, length, and some or all
|
|
of the early and late characters in all unfreed strings which are values
|
|
of lvalues or occur as "constants" in function definitions,
|
|
using "\n", "\t", "\0", "\252", etc. when appropriate. For example,
|
|
the string A in (1) would be displayed as in the definition there.
|
|
Only one line is used for each string. I've also changed the
|
|
analogous "show numbers" so that only some digits of numbers that
|
|
would require more than one line are displayed.
|
|
|
|
(4) "show literals" is analogous to "show constants" for number "constants"
|
|
in that it displays only the strings that have been introduced by
|
|
literal strings as in A = "abc". There is a major difference between
|
|
strings and numbers in that there are operations by which characters
|
|
in any string may be changed. For example, after A = "abc",
|
|
A[0] = "X" changes A to "Xbc". It follows that if a literal string
|
|
is to be constant in the sense of never changing, such a character-
|
|
changing operation should never be applied to that string.
|
|
|
|
In this connection, it should be noted that if B is string-valued, then
|
|
|
|
A = B
|
|
|
|
results in A referring to exactly the same string as B rather than to
|
|
a copy of what is in B. Thie is like the use of character-pointers in
|
|
C, as in
|
|
|
|
char *s1, *s2;
|
|
s1 = "abc";
|
|
s2 = s1;
|
|
|
|
To achieve the effect of
|
|
|
|
s2 = (char *) malloc(4);
|
|
strcpy(s2, s1);
|
|
|
|
I have extended the str() function to accept a string as argument. Then
|
|
|
|
A = str(B);
|
|
|
|
will create a new string at a different location from that of B but
|
|
with the same length and characters. One will then have A == B,
|
|
*A == *B, but &*A != &*B, &A[0] != &B[0].
|
|
|
|
To assist in analyzing this sort of thing, I have defined a links()
|
|
function which for number or string valued argument returns the number
|
|
of links to the occurrence of that argument that is being referred to.
|
|
For example, supposing "abc" has not been used earlier:
|
|
|
|
> A = "abc"
|
|
> links(A)
|
|
2
|
|
> links(A)
|
|
1
|
|
|
|
The two links in the first call are to A and the current "oldvalue";
|
|
in the second call, the only link is to A, the oldvalue now being 2.
|
|
|
|
|
|
(5) strcat(S1, S2, ...) works as before; contribution of a string stops when
|
|
'\0' is encountered. E.g.
|
|
|
|
strcat("abc\0def", "ghi")
|
|
|
|
will return "abcghi".
|
|
|
|
(6) For concatenation of full strings I have chosen to follow
|
|
some other languages (like Java, but not Mathematica which uses "<>")
|
|
and use "+" so that, e.g.
|
|
|
|
"abc\0def" + "ghi"
|
|
|
|
returns the string "abc\0defghi". This immediately gives obvious
|
|
meanings to multiplication by positive integers as in
|
|
|
|
2 * "abc" = "abc" + "abc" = "abcabc",
|
|
|
|
to negation to reverse as string as in
|
|
|
|
- "abc" = "cba",
|
|
|
|
to multiplication by fractions as in
|
|
|
|
0.5 * "abcd" = "ab",
|
|
|
|
(where the length is int(0.5 * size("abcd")), and finally, by combining
|
|
these to
|
|
|
|
k * A and A * k
|
|
|
|
for any real number k and any string A. In the case of k == 1, these
|
|
return a new string rather than A itself. (This differs from
|
|
"" + A and A + "" which return A.)
|
|
|
|
(7) char(x) has been changed so that it will accept any integer x or octet
|
|
as argument and return a string of size one with character value
|
|
x % 256. In the past calc has required 0 <= x < 256; now negative
|
|
x is acceptable; for example, 1000 * char(-1) will now produce the
|
|
same as 1000 * "\377" or 1000 * "\xff".
|
|
|
|
(8) For a string s, test(s) now returns zero not only for the null string
|
|
"" but also for a string all of whose characters are '\0'.
|
|
|
|
(9) Similarly <, <=, etc. now compare all characters including occurrences
|
|
of '\0' until a difference is encountered or the end of a string is
|
|
reached. If no difference is encountered but one string is longer than
|
|
the other, the longer string is considered as greater even if the
|
|
remaining characters are all '\0'.
|
|
|
|
(10) To retain the C sense of comparison of null-terminated strings I have
|
|
defined strcmp(S1, S2), and then, for completeness, strncmp(S1, S2, n).
|
|
For similar reasons, strcpy(S1, S2) and strncpy(S1, S2, n) have been
|
|
defined.
|
|
|
|
(11) For strings, I have defined | and & as bitwise "or" and "and"
|
|
functions, with S1 | S2 having the size of the larger of S1 and S2,
|
|
S1 & S2 having the size of the smaller of S1 and S2. By using, say,
|
|
4-character strings, one can simulate a C integral type so far as the
|
|
| and & operations are concerned. It then seemed appropriate to
|
|
use the operator ~ for a "bitwise complement" as in C. Thus I have
|
|
defined ~s for a string s to be the string of the same size as s
|
|
with each character being complemented by the C ~ operation.
|
|
|
|
(12) For boolean algebra work on strings it is convenient also to have
|
|
the bitwise xor and setminus binary operations. Using C's '^' for xor
|
|
would be confusing when this is used elsewhere for powers, so I
|
|
decided to use ~. For setminus, I adopted the commonly used '\'.
|
|
Strings of fixed size n can now be used for a boolean algebra
|
|
structure with 8 * n elements. The zero element is n * char(0),
|
|
the unity is n * char(-1), and one have all of the usual laws like
|
|
A & (B | C) == A & B | A * C, A \ B = A & ~B, etc.
|
|
|
|
(13) Having extended the bitwise operations for strings, it was appropriate
|
|
to do the same for integers. Definitions of the binary ~ and \
|
|
operations for non-negative integers are straightforward. For
|
|
the unary ~ operation, I decided to do what C does with integer
|
|
types, and defined ~N to be -N - 1. With the appropriate extensions of
|
|
|, &, \ and the binary ~, one gets in effect the boolean algebra of
|
|
finite sets of natural numbers and their complements, by identifying
|
|
the set with distinct integer elements i_1, i_2, ... with the integer
|
|
|
|
2^i_1 + 2^i_2 + ...
|
|
|
|
For ~N for non-integer real N, I have simply used -N. There is some
|
|
logic in this and it is certainly better than an error value.
|
|
I have not defined the binary operations |, &, ~, \ for non-integral
|
|
arguments.
|
|
|
|
The use of ~N in this way conflicts with calc's method of displaying
|
|
a number when it has to be rounded to config("display") decimals.
|
|
To resolve this, my preference would be to replace the printing of
|
|
"~" as a prefix by a trailing ellipsis "...", the rounding always
|
|
being towards zero. E.g. with config("display", 5), 1/7 would print
|
|
as ".14285..." rather than "~.14285". The config("outround")
|
|
parameter would determine the type of rounding only for the
|
|
equivalent of config("tilde", 0).
|
|
|
|
(14) For objects, users may create their own definitions for binary |,
|
|
&, ~ and \ with xx_or, xx_and, xx_xor, xx_setminus functions.
|
|
For unary ~ and \ operations, I have used the names xx_comp and
|
|
xx_backslash.
|
|
|
|
(15) For the obviously useful feature corresponding to cardinality of a
|
|
set, I have defined #S for a string S to be the number of nonzero bits
|
|
in S. For a degree of consistency, it was then appropriate to
|
|
define #N for a nonnegative integer N to be the number of nonzero bits
|
|
in the binary representation of N. I've extended this to arbitrary
|
|
real N by using in effect #(abs(num(N))). I feel it is better to make
|
|
this available to users rather than having #N invoke an error message
|
|
or return an error value. For defining #X for an xx-object X, I
|
|
have used the name xx_content to suggest that it is appropriate for
|
|
something which has the sense of a content (like number of members of,
|
|
area, etc.).
|
|
|
|
(16) Having recognized # as a token, it seemed appropriate to permit its
|
|
use for a binary operation. For real numbers x and y I have defined
|
|
x # y to be abs(x - y). (This is often symbolized by x ~ y, but it
|
|
would be confusing to have x ~ y meaning xor(x,y) for strings and
|
|
abs(x-y) for numbers.) Because '#' is commonly called the hash symbol,
|
|
I have used xx_hashop to permit definition of x # y for xx-objects.
|
|
|
|
(17) For a similar reason I've added one line of code to codegen.c so that
|
|
/A returns the inverse of A.
|
|
|
|
(18) Also for a list L, +L now returns the sum of the elements of L. For
|
|
an xx object A, +A requires and uses the definition of xx_plus.
|
|
|
|
(19) I have given the unary operators ~, #, /, \, and except at the
|
|
beginning of an expression + and -, the same precedence with
|
|
right-to-left associativity. This precedence is now weaker than
|
|
unary * and &, but stronger than binary & and the shift and power
|
|
operators. One difference from before is that now
|
|
|
|
a ^ - b ^ c
|
|
|
|
evaluates as a ^ (- (b ^ c)) rather than a ^ ((- b) ^ c).
|
|
|
|
|
|
(20) For octets o1, o2, I've defined o1 | o2, o1 & o2, o1 ~ o2, ~o1 so
|
|
that they return 1-character strings. #o for an octet o returns the
|
|
number of nonzero bits in o.
|
|
|
|
(21) For substrings I've left substr() essentially as before, but
|
|
for consistency with the normal block/matrix indexing, I've extended
|
|
the segment function to accept a string as first argument. Then
|
|
|
|
segment(A, m, n)
|
|
|
|
returns essentially the string formed from the character with index m
|
|
to the character with index n, ignoring indices < 0 and indices >=
|
|
len(A); thus, if m and n are both in [0, size(A))
|
|
the string is of length abs(m - n) + 1, the order of the characters
|
|
being reversed if n < m. Here the indices for a list of size len are
|
|
0, 1, ..., len - 1. As it makes some sense, if 0 <= n < size(A),
|
|
|
|
segment(A, n)
|
|
|
|
now returns the one-character string with its character being that with
|
|
index n in A. (I've made a corresponding modification to the segment
|
|
function for lists.) Some examples, if A = "abcdef",
|
|
|
|
segment(A,2,4) = "cde",
|
|
|
|
segment(A,4,2) = "edc",
|
|
|
|
segment(A,3) = "d",
|
|
|
|
segment(A, -2, 8) = "abcdef",
|
|
|
|
segment(A,7,8) = "".
|
|
|
|
(22) As essentially particular cases of segment(), I've defined
|
|
head(A, n) and tail(A, n) to be the strings formed by the first
|
|
or last abs(n) characters of A, the strings being4]5O~? reversed '
|
|
if n is negative. I've changed the definitions of head and tail for
|
|
lists to be consistent with this interpretation of negative n.
|
|
|
|
(23) Similarly I've left strpos ezsentially as at present, but search
|
|
and rsearch have been extended to strings. For example,
|
|
|
|
search(A, B, m, n)
|
|
|
|
returns the index i of the first occurrence of the string B in A
|
|
if m <= i < n, or the null value if there is no such occurrence.
|
|
As for other uses of search, negative m is interpreted as
|
|
size(A) + m, negative n as size(A) + n. For a match in this
|
|
search, all size(B) characters, including occurrences of '\0',
|
|
in B must match successive characters in A.
|
|
|
|
The function rsearch() behaves similarly but searches in reverse order
|
|
of the indices.
|
|
|
|
(24) A string A of length N determines in obvious ways arrays of M = 8 * N
|
|
bits. If the characters in increasing index order are c_0, c_1, ...
|
|
and the bits in increasing order in c_i are b_j, b_j+1, ..., b_j+7
|
|
where j = 8 * i, I've taken the array of bits determined by A to be
|
|
|
|
b_0, b_1, ..., b_M-1
|
|
|
|
For example, since "a" = char(97) and 97 = 0b01100001, and
|
|
"b" = char(98) = 0b01100010, the string "ab" determines the 16-bit
|
|
array
|
|
|
|
1000011001000110
|
|
|
|
in which the bits in the binary representations of "a" and "b" have
|
|
been reversed.
|
|
|
|
bit with index n in this array. This is consistent with the use of
|
|
bit for a number ch in [0,256), i.e. bit(char(ch), n) = bit(ch, n).
|
|
For n < 0 or n >= size(A), bit(A,n) returns the null value.
|
|
|
|
(25) For assigning values to specified bits in a string, I've defined
|
|
setbit(A, n) and setbit(A, n, v). The first assigns the value 1 to
|
|
bit(A, n), the second assigns test(v) to bit(A, n).
|
|
|
|
(26) For consistency with the corresponding number operations, the shift
|
|
operations A << n and A >> n have been defined to give what look
|
|
like right- and left-shifts, respectively. For example, "ab" << 2
|
|
returns the 16-bit array
|
|
|
|
0010000110010001
|
|
|
|
in which the array for "ab" has been moved 2 bits to the right.
|
|
|
|
(27) To achieve much the same as the C strcpy and strncpy functions for
|
|
null-terminated strings, strcpy(S1, S2) and strncpy(S1, S2, n) have
|
|
been defined. Unlike the blkcpy() and copy() functions, the copying
|
|
for these is only from the beginning of the strings. Also, unlike C,
|
|
no memory overflow can occur as the copying ceases when size(S1) is
|
|
reached. Note that these overwrite the content of S1 (which affects
|
|
all strings linked to it) as well as returning S1. Examples:
|
|
|
|
S = strcpy(6 * "x", "abc") <=> S = "abc\0xx"
|
|
|
|
S = strcpy(3 * "x", "abcdef") <=> S = "abc"
|
|
|
|
S = strncpy(6 * "x", "abcd", 2) <=> S = "ab\0xxx"
|
|
|
|
S = strncpy(6 * "x", "ab", 4) <=> S = "ab\0\0xx"
|
|
|
|
S = strncpy(6 * "x", "ab", 20) <=> S = "ab\0\0\0\0"
|
|
|
|
If a new string S not linked to S1 is to be created, this can be
|
|
achieved by using str(S1) in place of S1. For example, the strcpy in
|
|
|
|
A = "xxxxxx"
|
|
S = strcpy(str("xxxxxx"), "abc")
|
|
|
|
would not change the value of A.
|
|
|
|
(28) I've extended the definitions of copy(A, B, ssi, num, dsi) and
|
|
blkcpy(B, A, num, ssi, dsi) to allow for string-to-string copying
|
|
and block-to-string copying, but num is now an upper bound for the
|
|
number of characters to be copied - copying will cease before num
|
|
characters are copied if the end of the data in the source A or the
|
|
end of the destination B is reached. As with other character-changing
|
|
operations, copying to a string B will not change the locations of
|
|
B[0], B[1], ... or the size of B.
|
|
|
|
In the case of copying a string to itself, characters are copied in
|
|
order of increasing index, which is different from block-to-block
|
|
copying where a memmove is used. This affects only copy from a
|
|
string to itself. For example,
|
|
|
|
A = "abcdefg";
|
|
copy(A, A, , , 2);
|
|
|
|
will result in A == "abababa". If the overwriting that occurs here
|
|
is not wanted, one may use
|
|
|
|
A = "abcdefg";
|
|
copy(str(A), A, , , 2);
|
|
|
|
which results in A == "ababcde".
|
|
|
|
(29) perm(a,b) and comb(a,b) have been extended to accept any real a and
|
|
any integer b except for perm(a, b) with integer a such that b <= a < 0
|
|
which gives a "division by zero" error. For positive b, both functions
|
|
are polynomials in a of degree b; for negative b, perm(a,b) is a
|
|
rational function (1/((a + 1) * (a+2) ...) with abs(b) factors in the
|
|
denominator), and comb(a,b) = 0. (An obvious "todo" is to extend this
|
|
to complex or other types of a.)
|
|
|
|
(30) Although it is not illegal, it seems pointless to use a comma operator
|
|
with a constant or simple variable as in
|
|
|
|
> 2 * 3,14159
|
|
14159
|
|
> a = 4; b = 5;
|
|
> A = (a , b + 2);
|
|
> A
|
|
7
|
|
|
|
I have added a few lines to addop.c so that when this occurs a
|
|
"unused value ignored" message and the relevant line number are
|
|
displayed. I have found this useful as I occasionally type ','
|
|
when I mean '.'.
|
|
|
|
There may be one or two other changes resulting from the way I have
|
|
rewritten the optimization code in addop.c. I think there was a bug
|
|
that assumed that PTR_SIZE would be the same as sizeof(long). By
|
|
the way, the new OP_STRING is now of index rather than pointer type.
|
|
It follows that pointers are now used in opcodes only for global
|
|
variables. By introducing a table of addresses of global variables
|
|
like those used for "constants" and "literal strings", the use of
|
|
pointers in opcodes could be eliminated.
|
|
|
|
(31) When calc has executed a quit (or exit) statement in a function or
|
|
eval evaluation, it has invoked a call to math_error() which causes
|
|
a long jump to an initial state without freeing any data on the
|
|
stack, etc. Maybe more detail should be added to math_error(), but
|
|
to achieve the freeing of memory for a quit statement and at the same
|
|
time give more information about its occurrence I have changed the
|
|
way opcodes.c handles OP_QUIT. Now it should free the local variables
|
|
and whatever is on the stack, and display the name and line-number,
|
|
for each of the functions currently being evaluated. The last
|
|
function listed should be the "top-level" one with name "*".
|
|
Strings being eval-ed will have name "**".
|
|
|
|
Here is a demo:
|
|
|
|
> global a;
|
|
>
|
|
> define f(x) {local i = x^2; a++;
|
|
>> if (x > 5) quit "Too large!"; return i;}
|
|
f() defined
|
|
> define g(x) = f(x) + f(2*x);
|
|
g() defined
|
|
> g(2)
|
|
20
|
|
> g(3)
|
|
Too large!
|
|
"f": line 3
|
|
"g": line 0
|
|
"*": line 6
|
|
> eval("g(3)")
|
|
Too large!
|
|
"f": line 3
|
|
"g": line 0
|
|
"**": line 1
|
|
"*": line 7
|
|
> a
|
|
6
|
|
|
|
(32) I've made several small changes like removing
|
|
|
|
if (vp->v_type == V_NUM) {
|
|
q = qinv(vp->v_num);
|
|
if (stack->v_type == V_NUM)
|
|
qfree(stack->v_num);
|
|
stack->v_num = q;
|
|
stack->v_type = V_NUM;
|
|
return;
|
|
}
|
|
|
|
from the definition of o_invert. Presumably these lines were intended
|
|
to speed up execution for the common case of numerical argument.
|
|
Comparing the runtimes with and without these lines for inverting
|
|
thousands of large random numbers in a matrix suggest that execution
|
|
for real numbers is slightly faster without these lines.
|
|
|
|
Maybe this and other similar treatment of "special cases" should be
|
|
looked at more closely.
|
|
|
|
(33) The new lib script lib/natnumset.cal demonstrates how the new
|
|
string operators and functions may be used for defining and
|
|
working with sets of natural numbers not exceeding a
|
|
user-specified bound.
|
|
|
|
|
|
Following is the change from calc version 2.10.3t5.28 to 2.10.3t5.33:
|
|
|
|
Added hnrmod(v, h, n, r) builtin to compute:
|
|
|
|
v % (h * 2^n + r), h>0, n>0, r = -1, 0 or 1
|
|
|
|
Changed lucas.cal and mersenne.cal to make use of hnrmod().
|
|
|
|
A number of changes from Ernest Bowen:
|
|
|
|
(1) introduction of unary & and * analogous to those in C;
|
|
|
|
For an lvalue var, &var returns what I call a
|
|
value-pointer; this is a constant which may be assigned to
|
|
a variable as in p = &var, and then *p in expressions has
|
|
the same effect as var. Here is a simple example of their use:
|
|
|
|
> define s(L) {local v=0; while (size(L)) v+= *pop(L);return v;}
|
|
s() defined
|
|
> global a = 1, b = 2;
|
|
> L = list(&a, &b);
|
|
> print s(L)
|
|
3
|
|
> b = 3;
|
|
> print s(L)
|
|
4
|
|
|
|
Octet-pointers, number-pointers, and string-pointers in
|
|
much the same way, but have not attempted to do much with
|
|
the latter two.
|
|
|
|
To print a pointer, use the "%p" specifier.
|
|
|
|
Some arithmetic operations has been defined for corresponding
|
|
C operations. For example:
|
|
|
|
> A = mat[4];
|
|
> p = &A[0];
|
|
> *(p+2) == A[2]
|
|
> ++p
|
|
> *p == A[1]
|
|
|
|
There is at present no protection against "illegal" use of &
|
|
and *, e.g. if one attempts here to assign a value to *(p+5),
|
|
or to use p after assigning another value to A.
|
|
|
|
NOTE: Unlike C, in calc &A[0] and A are quite different things.
|
|
|
|
NOTE: If the current value of a variable X is an octet,
|
|
number or string, *X may be used to to return the value of
|
|
X; in effect X is an address and *X is the value at X.
|
|
|
|
Added isptr(p) builtin to return 0 is p is not a pointer,
|
|
>0 if it is a pointer. The value of isptr(p) comes from the
|
|
V_XYZ #define (see the top of value.h) of the value to which
|
|
p points.
|
|
|
|
To allow & to be used as a C-like address operator, use of it
|
|
has been dropped in calls to user-defined functions. For the
|
|
time being I have replaced it by the back-quote `. For example:
|
|
|
|
> global a
|
|
> define f(a,b) = a = b
|
|
> f(&a,5)
|
|
> print a
|
|
0
|
|
> f(`a,5)
|
|
> print a
|
|
5
|
|
|
|
However, one may use & in a similar way as in:
|
|
|
|
> define g(a,b) = *a = b
|
|
> g(&a, 7)
|
|
> print a
|
|
7
|
|
|
|
There is no hashvalue for pointers. Thus, like error values,
|
|
they cannot be used as indices in an association.
|
|
|
|
The -> also works in calc. For example:
|
|
|
|
> obj xy {x,y}
|
|
> obj uvw {u, v, w}
|
|
> obj xy A = {1,2}
|
|
> obj uvw B = {3,4,5}
|
|
> p = &A
|
|
> q = &B
|
|
> p->x
|
|
1
|
|
> p->y = 6
|
|
> A
|
|
obj xy {1, 6}
|
|
> q -> u
|
|
3
|
|
> p->y = q
|
|
> A
|
|
obj xy {1, v-ptr: 1400474c0}
|
|
> p->y->u
|
|
3
|
|
> p->y->u = 7
|
|
> B
|
|
obj uvw {7, 4, 5}
|
|
> p -> y = p
|
|
> A
|
|
obj xy {1, v-ptr: 140047490}
|
|
> p -> y -> x
|
|
1
|
|
> p->y->y
|
|
v-ptr: 140047490
|
|
> p->y->y-> x
|
|
1
|
|
> p->y->y->x = 8
|
|
> A
|
|
obj xy {8, v-ptr: 140047490}
|
|
|
|
|
|
(2) a method of "protecting" variables;
|
|
|
|
For the various kinds of "protection", of an l_value var,
|
|
bits of var->v_subtype, of which only bits 0 and 1 have been
|
|
used in the past to indicate literal and allocated strings.
|
|
This has meant initialization of var->v_subtype when a new var
|
|
is introduced, and for assignments, etc., examination of the
|
|
appropriate bits to confirm that the operation is to be permitted.
|
|
|
|
See help/protect for details.
|
|
|
|
(3) automatic "freeing" of constants that are no longer required.
|
|
|
|
For the "freeing" of constants, the definition of a NUMBER
|
|
structure so that a NUMBER * q could be regarded as a
|
|
pointing to a "freed number" if q->links = 0.
|
|
|
|
The old q->num was changed to a union q->nu which had a pointer
|
|
to the old q->num if q->links > 0 and to the next freed number
|
|
if q->links = 0. The old "num" is #defined to "nu->n_num".
|
|
|
|
The prior method calc has used for handling "constants" amounted
|
|
to leakage. After:
|
|
|
|
> define f(x) = 27 + x;
|
|
> a = 27;
|
|
|
|
It is of course necessary for the constant 27 to be stored, but
|
|
if one now redefines f and a by:
|
|
|
|
> define f(x) = 45 + x;
|
|
> a = 45;
|
|
|
|
There seems little point in retaining 27 as a constant and
|
|
therefore using up memory. If this example seems trivial,
|
|
replace 27 with a few larger numbers like 2e12345, or better,
|
|
-2e12345, for which calc needs memory for both 2e12345 and
|
|
-2e12345!
|
|
|
|
Constants are automatically freed a definition when a
|
|
function is re- or un-defined.
|
|
|
|
The qalloc(q) and qfree(q) functions have been changed so
|
|
that that q->links = 0 is permitted and indicates that q
|
|
has been freed. If a number has been introduced as a
|
|
constant, i.e. by a literal numeral as in the above
|
|
examples, its links becoming zero indicates that it is no
|
|
longer required and its position in the table of constants
|
|
becomes available for a later new constant.
|
|
|
|
(4) extension of transcendental functions like tan, tanh, etc.
|
|
to complex arguments
|
|
|
|
(5) definition of gd(z) and agd(z), i.e. the gudermannian and
|
|
inverse gudermannian
|
|
|
|
(6) introduction of show options for displaying information about
|
|
current constants, global variables, static variables, and cached
|
|
redc moduli.
|
|
|
|
To help you follow what is going on, the following show
|
|
items have been introduced:
|
|
|
|
show constants ==> display the currently stored constants
|
|
show numbers ==> display the currently stored numbers
|
|
show redcdata ==> display the currently stored redc moduli
|
|
show statics ==> display info about static variables
|
|
show real ==> display only real-valued variables
|
|
|
|
The constants are automatically initialized as constants and
|
|
should always appear, with links >= 1, in in the list of constants.
|
|
|
|
The show command:
|
|
|
|
show globals
|
|
|
|
has been redefined so that it gives information about all
|
|
current global and still active static variables.
|
|
|
|
(7) definition of functions for freeing globals, statics, redc values
|
|
|
|
To free memory used by different kinds of variable, the following
|
|
builtins have been added:
|
|
|
|
freeglobals(); /* free all globals */
|
|
freestatics(); /* free all statics */
|
|
freeredc(); /* free redc moduli */
|
|
free(a, b, ...); /* free specific variables */
|
|
|
|
NOTE: These functions do not "undefine" the variables, but
|
|
have the effect of assigning the null value to them, and so
|
|
frees the memory used for elements of a list, matrix or object.
|
|
|
|
See 10) below for info about "undefine *".
|
|
|
|
(8) enhancement of handling of "old value": having it return an
|
|
lvalue and giving option of disabling updating.
|
|
|
|
Now, by default, "." return an lvalue with the appropriate
|
|
value instead of copying the old value.
|
|
|
|
So that a string of commands may be given without changing
|
|
the "oldvalue", the new builtin:
|
|
|
|
saveval(0)
|
|
|
|
function simply disables the updating of the "." value.
|
|
The default updating can be resumed by calling:
|
|
|
|
saveval(1)
|
|
|
|
The "." value:
|
|
|
|
> 2 + 2
|
|
4
|
|
> .
|
|
4
|
|
|
|
can now be treated as an unnamed variable. For example:
|
|
|
|
> mat x[3,3]={1,2,3,4,5,6,7,8,9}
|
|
> x
|
|
> print .[1,2]
|
|
6
|
|
|
|
(9) for a list L defining L[i] to be same as L[[i]]
|
|
|
|
(10) extending undefine to permit its application to all user-defined
|
|
functions by using "undefine *".
|
|
|
|
The command:
|
|
|
|
undefine *
|
|
|
|
undefines all current user-defined functions. After
|
|
executing all the above freeing functions (and if
|
|
necessary free(.) to free the current "old value"), the
|
|
only remaining numbers as displayed by:
|
|
|
|
show numbers
|
|
|
|
should be those associated with epsilon(), and if it has been
|
|
called, qpi().
|
|
|
|
(11) storing the most recently calculated value of qpi(epsilon)i and
|
|
epsilon so that when called again with the same epsilon it
|
|
is copied rather than recalculateed.
|
|
|
|
(12) defining trace() for square matrices
|
|
|
|
(13) expression in parentheses may now be followed by a qualifier
|
|
computible with its type
|
|
|
|
When an expression in parentheses evaluates to an lvalue
|
|
whose current value is a matrix, list or object, it may
|
|
now be followed by a qualifier computible with its type.
|
|
|
|
For example:
|
|
|
|
> A = list(1,2,4);
|
|
> B = mat[2,2] = {5,6,7,8};
|
|
> define f(x) = (x ? A : B)[[1]];
|
|
> print f(1), f(0)
|
|
2 6
|
|
|
|
> obj xy {x,y}
|
|
> C = obj xy = {4,5}
|
|
> p = &C
|
|
> *p.x
|
|
Not indexing matrix or object
|
|
> (*p).x
|
|
4
|
|
|
|
(14) swap(a,b) now permits swapping of octets in the same or different
|
|
blocks.
|
|
|
|
For example:
|
|
|
|
> A = blk() = {1,2,3}
|
|
> B = blk() = {4,5,6}
|
|
> swap(A[0], B[2])
|
|
> A
|
|
chunksize = 256, maxsize = 256, datalen = 3
|
|
060203
|
|
|
|
A few bug fixes from Ernest Bowen:
|
|
|
|
B1: qcmpi(q, n) in qmath.c sometimes gave the wrong result if
|
|
LONG_BITS > BASEB, len = 1 and nf = 0, since it then
|
|
reduces to the value of (nf != q->num.v[1]) in which
|
|
q->num.v[1] is not part of the size-1 array of HALFs for
|
|
q->num. At present this is used only for changing opcodes
|
|
for ^2 and ^4 from sequences involving OP_POWER to
|
|
sequences using OP_SQUARE, which has no effect on the
|
|
results of calculations.
|
|
|
|
B2: in matdet(m) in matfunc.c, a copy of the matrix m was not freed
|
|
when the determinant turned out have zero value.
|
|
|
|
B3: in f_search() in func.c, a qlinking of the NUMBER * storing the
|
|
the size of a file was not qfreed.
|
|
|
|
B4: in comalloc() in commath.c the initial zero values for real and
|
|
imag parts are qlinked but not qfreed when nonzero values are
|
|
assigned to them. Rather than changing
|
|
the definition of comalloc(), I have included any relevant
|
|
qfrees with the calls to comalloc() as in
|
|
c = comalloc();
|
|
qfree(c->real);
|
|
c->real = ...
|
|
|
|
B5: in calls to matsum(), zeros are qlinked but not qfreed. Rather
|
|
than changing addnumeric(), I have changed the definition
|
|
of matsum(m) so that it simply adds the components of m,
|
|
which requires only that the relevant additions be defined,
|
|
not that all components of m be numbers.
|
|
|
|
|
|
Simple arithmetic expressions with literal numbers are evaluated
|
|
during compilation rather than execution. So:
|
|
|
|
define f(x) = 2 + 3 + x;
|
|
|
|
will be stored as if defined by:
|
|
|
|
define f(x) = 5 + x;
|
|
|
|
Fixed bug with lowhex2bin converstion in lib_util.c. It did not
|
|
correctly convert from hex ASCII to binary values due to a table
|
|
loading error.
|
|
|
|
Fixed porting problem for NetBSD and FreeBSD by renaming the
|
|
qdiv() function in qmath.c to qqdiv().
|
|
|
|
Improved the speed of mfactor (from mfactor.cal library) for
|
|
long Mersenne factorizations. The default reporting loop
|
|
is now 10000 cycles.
|
|
|
|
SGI Mips r10k compile set is speced for IRIX6.5 with v7.2
|
|
compilers. A note for pre-IRIX6.5 and/or pre-v7.2 compilers
|
|
is given in the compile set.
|
|
|
|
Added regression tests related to saveval(), dot and pointers.
|
|
|
|
|
|
Following is the change from calc version 2.10.3t5.11 to 2.10.3t5.27:
|
|
|
|
The todo help file as been updated with the in-progress items:
|
|
|
|
XXX - block print function is not written yet ...
|
|
|
|
Expanded the role of blk() to produce unnamed blocks as in:
|
|
|
|
B = blk(len, chunk)
|
|
|
|
and named blocks as in:
|
|
|
|
B = blk(str, len, chunk)
|
|
|
|
A block may be changed (with possible loss of data only if len is less
|
|
than the old len) by:
|
|
|
|
C = blk(B, len, chunk)
|
|
|
|
For an unnamed block B, this creates a new block C and copies
|
|
min(len, oldlen) octets to it, B remaining unchanged. For a named
|
|
block, the block B is changed and C refers to the same block as B,
|
|
so that for example, C[i] = x will result in B[i] == x. Thus, for a
|
|
named block, "B = " does nothing (other than B = B) in:
|
|
|
|
B = blk(B, len, chunk)
|
|
|
|
but is necessary for changing an unnamed block.
|
|
|
|
Renamed rmblk() to blkfree().
|
|
|
|
The builtin function blkfree(val) will free memory allocated to block.
|
|
If val is a named block, or the name of a named block, or the
|
|
identifying index for a named block, blkfree(val) frees the
|
|
memory block allocated to this named block. The block remains
|
|
in existence with the same name, identifying index, and chunksize,
|
|
but its size and maxsize becomes zero and the pointer for the start
|
|
of its data block null.
|
|
|
|
The builtin function blocks() returns the number of blocks that
|
|
have been created but not freed by the blkfree() function. When called
|
|
as blocks(id) and the argument id less than the number of named
|
|
blocks that have been created, blocks(id) returns the named block
|
|
with identifying index id.
|
|
|
|
Removed the artifical limit of 20 named blocks.
|
|
|
|
Added name() builtin to return the name of a type of value
|
|
as a string.
|
|
|
|
Added isdefined() to determine of a value is defined.
|
|
|
|
Added isobjtype() to determine the type of an object.
|
|
|
|
The isatty(v) builtin will return 1 if v is a file that associated
|
|
with a tty (terminal, xterm, etc.) and 0 otherwise. The isatty(v)
|
|
builtin will no longer return an error if v is not a file or
|
|
is a closed file.
|
|
|
|
The isident(m) builtin will return 1 if m is a identity matrix
|
|
and 0 otherwise. The isident(m) builtin will no longer return an
|
|
error if m is not a matrix.
|
|
|
|
Added extensive testing of isxxx() builtins and their operations
|
|
on various types.
|
|
|
|
Added md5() builtin to perform the MD5 Message-Digest Algorithm.
|
|
|
|
Renamed isset() to bit().
|
|
|
|
Blocks will expand when required by the copy() builtin function:
|
|
|
|
> f = fopen("help/full", "r")
|
|
> B = blk()
|
|
> B
|
|
chunksize = 256, maxsize = 256, datalen = 0
|
|
> copy(B, f)
|
|
> B
|
|
chunksize = 256, maxsize = 310272, datalen = 310084
|
|
2a2a2a2a2a2a2a2a2a2a2a2a2a0a2a20696e74726f0a2a2a2a2a2a2a2a2a...
|
|
|
|
NOTE: Your results will differ because changes to help/full.
|
|
|
|
The blkcpy() builtin args now more closely match that
|
|
of memcpy(), strncpy:
|
|
|
|
blkcpy(dst, src [, num [, dsi [, ssi]]])
|
|
|
|
The copy() builtin args now more closely match that the cp command:
|
|
|
|
copy(src, dst [, num [, ssi [, dsi]]])
|
|
|
|
but otherwise does the same thing as blkcpy.
|
|
|
|
Fixed lint problems for SunOS.
|
|
|
|
Added have_memmv.c and HAVE_MEMMOVE Makefile variable to control
|
|
use of memmove(). If empty, then memmove() is tested for and if
|
|
not found, or if HAVE_MEMMOVE= -DHAVE_NO_MEMMOVE then an internal
|
|
version of memmove() is used instead.
|
|
|
|
Added regression tests for sha, sha1 and md5 builtin hash functions.
|
|
|
|
Added xx_print to to the list of object routines are definable.
|
|
Added xx_print.cal to the library to demo this feature.
|
|
|
|
Moved blkcpy() routines have been moved to blkcpy.[ch].
|
|
|
|
The blkcpy() & copy() builtings can not copy to/from numbers.
|
|
For purposes of the copy, only the numerator is ignored.
|
|
|
|
Resolved a number of missing symbols for libcalc users.
|
|
|
|
Added lib_util.{c,h} to the calc source to support users of
|
|
libcalc.a. These utility routines are not directly used by
|
|
calc but are otherwise have utility to those programmers who
|
|
directly use libcalc.a instead.
|
|
|
|
Added sample sub-directory. This sub-directory contains a few
|
|
sample programs that use libcalc.a. These sample programs are
|
|
built via the all rule because they will help check to see that
|
|
libcalc.a library does not contain external references that
|
|
cannot be resolved. At the current time none of these sample
|
|
programs are installed.
|
|
|
|
Added a libcalc_call_me_last() call to return storage created
|
|
by the libcalc_call_me_first() call. This allows users of libcalc.a
|
|
to free up a small amount of storage.
|
|
|
|
Fixed some memory leaks associated with the random() Blum generator.
|
|
|
|
Fixed fseek() file operations for SunOS.
|
|
|
|
Fixed convz2hex() fencepost error. It also removes leading 0's.
|
|
|
|
Plugged a memory leak relating to pmod. The following calculation:
|
|
|
|
pmod(2, x, something)
|
|
|
|
where x was not 2^n-1 would leak memory. This has been fixed.
|
|
|
|
|
|
Following is the change from calc version 2.10.3t5.1 to 2.10.3t5.10:
|
|
|
|
Misc printf warning bug fixes.
|
|
|
|
Calc now permits chains of initializations as in:
|
|
|
|
obj point {x,y} P = {1,2} = {3,4} = {5,6}
|
|
|
|
Here the initializations are applied from left to right. It may
|
|
look silly, but the 1, 2, ... could be replaced by expressions with
|
|
side effects. As an example of its use suppose A and B are
|
|
expressions with side effects:
|
|
|
|
P = {A, B}
|
|
|
|
has the effect of P.x = A; P.y = B. Sometimes one might want these in
|
|
the reverse order: P.y = B; P.x = A. This is achieved by:
|
|
|
|
P = { , B} = {A}
|
|
|
|
Another example of its use:
|
|
|
|
obj point Q = {P, P} = {{1, 2}, {3, 4}}
|
|
|
|
which results in Q having Q.x.x = 1, Q.x.y = 2, etc.
|
|
|
|
The role of the comma in has been changed. Expressions such as:
|
|
|
|
mat A[2], B[3]
|
|
|
|
are equivalent to:
|
|
|
|
(mat A[2]), (mat B[3])
|
|
|
|
Now, expr1, expr2 returns type of expr2 rather than EXPR_RVALUE. This
|
|
permits expressions such as:
|
|
|
|
(a = 2, b) = 3
|
|
|
|
Also, expr1 ? expr2 : expr3 returns type(expr2) | type(expr3).
|
|
This will make the result an lvalue (i.e. EXPR_RVALUE bit not set)
|
|
For example, if both expr2 and expr3 are lvalues. Then:
|
|
|
|
a ? b : c = d
|
|
|
|
has the effect of b = d if a is "nonzero", otherwise c = d.
|
|
|
|
This may be compared with
|
|
|
|
d = a ? b : c
|
|
|
|
which does d = b if a is "nonzero", otherwise d = c.
|
|
|
|
And now, expr1 || expr2 and expr1 && expr2 each return
|
|
htype(expr1)| type(expr2). So for example:
|
|
|
|
a || b = c
|
|
|
|
has the effect of a = c if a is "nonzero", otherwise b = c.
|
|
And for example:
|
|
|
|
a && b = c
|
|
|
|
has the effect of a = c if a is "zero", otherwise b = c.
|
|
|
|
At top level, newlines are neglected between '(' and the matching
|
|
')' in expressions and function calls. For example, if f() has been
|
|
already defined, then:
|
|
|
|
|
|
a = (
|
|
2
|
|
+
|
|
f
|
|
(
|
|
3
|
|
)
|
|
)
|
|
|
|
and
|
|
|
|
b = sqrt (
|
|
20
|
|
,
|
|
1
|
|
)
|
|
|
|
will be accepted, and in interactive mode the continue-line prompt
|
|
will be displayed.
|
|
|
|
When calc sees a "for", "while", "do", or "switch", newlines will be
|
|
ignored (and the line-continuation prompt displayed in interactive mode)
|
|
until the expected conditions and statements are completed.
|
|
For example:
|
|
|
|
s = 0;
|
|
for (i = 0; i < 5; i++)
|
|
{
|
|
s += i;
|
|
}
|
|
print s;
|
|
|
|
Now 's' will print '10' instead of '5'.
|
|
|
|
Added more regression tests to regress.cal. Changed the error
|
|
counter from 'err' to 'prob'. The errmax() is set very high and
|
|
the expected value of errcount() is kept in ecnt.
|
|
|
|
Added the 'unexpected' help file which gives some unexpected
|
|
surprises that C programmers may encounter.
|
|
|
|
Updated the 'help', 'intro' and 'overview' to reflect the
|
|
full ilst of non-builtin function help files. Reorered the
|
|
'full' help file.
|
|
|
|
The blkalloc() builtin has been renamed blk().
|
|
|
|
Only a "fixed" type of BLOCK will be used. Other types of
|
|
blocks in the future will be different VALUE types.
|
|
|
|
Introduced an undefine command so that
|
|
|
|
undefine f, g, ...
|
|
|
|
frees the memory used to store code for user-defined functions f,
|
|
g, ..., effectively removing them from the list of defined
|
|
functions.
|
|
|
|
When working from a terminal or when config("lib_debug") > 0 advice
|
|
that a function has been defined, undefined, or redefined is
|
|
displayed in format "f() defined".
|
|
|
|
Some experimental changes to block and octet handling, so that after:
|
|
|
|
B = blk(N)
|
|
|
|
B[i] for 0 <= i < N behaves for some operations like an lvalue for
|
|
a USB8 in B.
|
|
|
|
xx_assign added to object functions to permit the possibility of
|
|
specifying what A = B will do if A is an xx-object. Normal
|
|
assignment use of = is restored by the command: undefine
|
|
xx_assign.
|
|
|
|
For error-value err, errno(err) returns the error-code for err and
|
|
stores this in calc_errno; error(err) returns err as if
|
|
error(errno(err)) were called.
|
|
|
|
Anticipating probable future use, names have been introduced for
|
|
the four characters @, #, $, `. This completes the coverage of
|
|
printable characters on a standard keyboard.
|
|
|
|
Added sha() builtin to perform the old Secure Hash Algorithm
|
|
(SHS FIPS Pub 180).
|
|
|
|
Added sha1() builtin to perform the new Secure Hash Standard-1
|
|
(SHS-1 FIPS Pub 180-1).
|
|
|
|
Added ${LD_DEBUG} Makefile variable to allow for additional
|
|
libraries to be compiled into calc ... for debugging purposes.
|
|
In most cases, LD_DEBUG= is sufficent.
|
|
|
|
Added ${CALC_ENV} makefile variable to allow for particular
|
|
environment variables to be supplied for make {check,chk,debug}.
|
|
In most cases, CALC_ENV= CALCPATH=./lib is sufficent.
|
|
|
|
Added ${CALC_LIBS} to list the libaraies created and used to
|
|
build calc. The CALC_LIBS= custom/libcustcalc.a libcalc.a
|
|
is standard for everyone.
|
|
|
|
Improved how 'make calc' and 'make all' rules work with respect
|
|
to building .h files.
|
|
|
|
Added 'make run' to only run calc interactively with the
|
|
${CALC_ENV} calc environment. Added 'make cvd', 'make dbx'
|
|
and 'make gdb' rules to run debug calc with the respective
|
|
debugger with the ${CALC_ENV} calc environment.
|
|
|
|
Added cvmalloc_error() function to lib_calc.c as a hook for
|
|
users of the SGI Workshop malloc debugging library.
|
|
|
|
Cut down on places where *.h files include system files.
|
|
The *.c should do that instead where it is reasonable.
|
|
|
|
To avoid symbol conflicts, *.h files produced and shipped
|
|
with calc are inclosed that as similar to the following:
|
|
|
|
#if !defined(__CALC_H__)
|
|
#define __CALC_H__
|
|
..
|
|
#endif /* !__CALC_H__ */
|
|
|
|
Added memsize(x) builtin to print the best aproximation of the
|
|
size of 'x' including overhead. The sizeof(x) builtin attempts
|
|
to cover just the storage of the value and not the overhead.
|
|
Because -1, 0 and 1 ZVALUES are static common values, sizeof(x)
|
|
ignores their storage. Also sizeof(x) ignores the denominator of
|
|
integers, and the imaginary parts of pure real numbers. Added
|
|
regression tests for memsize(), sizeof() and size().
|
|
|
|
|
|
Following is the change from calc version 2.10.3t4.16 to 2.10.3t5.0:
|
|
|
|
The calc source now comes with a custom sub-directory which
|
|
contains the custom interface code. The main Makefile now
|
|
drives the building and installing of this code in a similar
|
|
way that it drives the lib and help sub-directories. (see below)
|
|
|
|
Made minor edits to most help files beginning with a thru e.
|
|
|
|
The errno(n) sets a C-like errno to the value n; errno() returns
|
|
the current errno value. The argument for strerror() and error()
|
|
defaults to this errno.
|
|
|
|
Added more error() and errno() regression tests.
|
|
|
|
The convention of using the global variable lib_debug at the
|
|
end of calc librar scripts has been replaced with config("lib_debug").
|
|
The "lib_debug" is reserved by convention for calc library scripts.
|
|
This config parameter takes the place of the lib_debug global variable.
|
|
By convention, "lib_debug" has the following meanings:
|
|
|
|
<-1 no debug messages are printed though some internal
|
|
debug actions and information may be collected
|
|
|
|
-1 no debug messages are printed, no debug actions will be taken
|
|
|
|
0 only usage message regarding each important object are
|
|
printed at the time of the read (default)
|
|
|
|
>0 messages regarding each important object are
|
|
printed at the time of the read in addition
|
|
to other debug messages
|
|
|
|
The "calc_debug" is reserved by convention for internal calc routines.
|
|
The output of "calc_debug" will change from release to release.
|
|
Generally this value is used by calc wizards and by the regress.cal
|
|
routine (make check). By convention, "calc_debug" has the following
|
|
meanings:
|
|
|
|
<-1 reserved for future use
|
|
|
|
-1 no debug messages are printed, no debug actions will be taken
|
|
|
|
0 very little, if any debugging is performed (and then mostly
|
|
in alpha test code). The only output is as a result of
|
|
internal fatal errors (typically either math_error() or
|
|
exit() will be called). (default)
|
|
|
|
>0 a greater degree of debugging is performed and more
|
|
verbose messages are printed (regress.cal uses 1).
|
|
|
|
The "user_debug" is provided for use by users. Calc ignores this value
|
|
other than to set it to 0 by default (for both "oldstd" and "newstd").
|
|
No calc code or shipped library will change this value other than
|
|
during startup or during a config("all", xyz) call.
|
|
|
|
The following is suggested as a convention for use of "user_debug".
|
|
These are only suggestions: feel free to use it as you like:
|
|
|
|
<-1 no debug messages are printed though some internal
|
|
debug actions and information may be collected
|
|
|
|
-1 no debug messages are printed, no debug actions will be taken
|
|
|
|
0 very little, if any debugging is performed. The only output
|
|
are from fatal errors. (default)
|
|
|
|
>0 a greater degree of debugging is performed and more
|
|
verbose messages are printed
|
|
|
|
Added more code that is deading with the BLOCK type.
|
|
|
|
Added blkalloc() builtin.
|
|
|
|
Split NAMETYPE definition out into nametype.h.
|
|
|
|
Added OCTET type for use in processing block[i].
|
|
|
|
Added free, copy, cmp, quickhash and print functions for
|
|
HASH, BLOCK and OCTET.
|
|
|
|
Added notes to config.h about what needs to be looked at when
|
|
new configuration items are added.
|
|
|
|
The null() builtin now takes arguments.
|
|
|
|
Given the following:
|
|
|
|
obj point {x,y}
|
|
obj point P, Q
|
|
|
|
will will now create P and Q as obj point objects.
|
|
|
|
Added xx_or, xx_and, xx_not and xx_fact objfuncs.
|
|
|
|
Added the custom() builtin function. The custom() builtin
|
|
interface is designed to make it easier for local custom
|
|
modification to be added to calc. Custom functions are
|
|
non-standard or non-portable code. For these reasons, one must can
|
|
only execute custom() code by way of an explicit action.
|
|
|
|
By default, custom() returns an error. A new calc command line
|
|
option of '-C' is required (as well as ALLOW_CUSTOM= -DCUSTOM
|
|
Makefile variable set) to enable it.
|
|
|
|
Added -C as a calc command line option. This permits the
|
|
custom() interface to be used.
|
|
|
|
Added ALLOW_CUSTOM Makefile variable to permanently disable
|
|
or selective enable the custom builtin interface.
|
|
|
|
The rm() builtin now takes multiple filenames. If the first
|
|
arg is "-f", then 'no-such-file' errors are ignored.
|
|
|
|
Added errcount([count]) builtin to return or set the error
|
|
counter. Added errmax([limit]) to rturn or set the error
|
|
count limiter.
|
|
|
|
Added -n as a calc command line option. This has the effect
|
|
of calling config("all", "newstd") at startup time.
|
|
|
|
Added -e as a calc command line option to ignore all environment
|
|
varialbes at startup time. The getenv() builtin function will
|
|
still return values, however.
|
|
|
|
Added -i as a calc command line option. This has the effect
|
|
ignoring when errcount() exceeds errmax().
|
|
|
|
Changed the config("maxerr") name to config("maxscan"). The
|
|
old name of "maxerr" is kept for backward compatibility.
|
|
|
|
Using an unknown -flag on the calc command like will
|
|
generate a short usage message.
|
|
|
|
Doing a 'help calc' displays the same info as 'help usage'.
|
|
|
|
The 'make check' rule now uses the -i calc command line flag
|
|
so that regress.cal can continue beyond when errcount exceeds
|
|
errmax. In regress.cal, vrfy() reports when errcount exceeds
|
|
errmax and resets errmax to match errcount. This check
|
|
and report is independent of the test success of failure.
|
|
|
|
Fixed missing or out of order tests in regress.cal.
|
|
|
|
Misc Makefile cleanup in lib/Makefile and help/Makefile.
|
|
|
|
The default errmax() value on startup is now 20.
|
|
|
|
The custom() interface is now complete. See help/custom and
|
|
custom/HOW_TO_ADD files, which show up as the custom and new_custom
|
|
help files, for more information.
|
|
|
|
The help command will search ${LIBDIR}/custhelp if it fails to find
|
|
a file in ${LIBDIR}. This allows the help command to also print
|
|
help for a custom function. However if a standard help file and a
|
|
custom help file share the same name, help will only print the
|
|
standard help file. One can skip the standard help file and print
|
|
the custom help file by:
|
|
|
|
help custhelp/name
|
|
|
|
or by:
|
|
|
|
custom("help", "name")
|
|
|
|
Added minor sanity checks the help command's filename.
|
|
|
|
Added show custom to display custom function information.
|
|
|
|
Added the contrib help page to give information on how
|
|
and where to submit new calc code, modes or custom functions.
|
|
|
|
Added comment information to value.h about what needs to be
|
|
checked or modified when a new value type is added.
|
|
|
|
Both size(x) and sizeof(x) return information on all value types.
|
|
Moved size and sizeof information from func.c and into new file: size.c.
|
|
|
|
Added custom("devnull") to serve as a do-nothing interface tester.
|
|
|
|
Added custom("argv" [,arg ...]) to print information about args.
|
|
|
|
Added custom("sysinfo", "item") to print an internal calc #define
|
|
parameter.
|
|
|
|
The make depend rule also processes the custom/Makefile.
|
|
|
|
Added xx_max and xx_min for objfuncs.
|
|
|
|
The max(), min() builtins work for lists.
|
|
|
|
|
|
Following is the change from calc version 2.10.3t3 to 2.10.3t4.15:
|
|
|
|
The priority of unary + and - to that of binary + and - when they are
|
|
applied to a first or only term. Thus:
|
|
|
|
-16^-2 == -1/256
|
|
-7^2 == -49
|
|
-3! == -6
|
|
|
|
Running ranlib is no longer the default. Systems that need RANLIB
|
|
should edit the Makefile and comment back in:
|
|
|
|
RANLIB=ranlib
|
|
|
|
Dropped support of SGI r8k.
|
|
|
|
Added support for the SGI r5k.
|
|
|
|
Added support for SGI Mips compiler version 7.1 or later.
|
|
|
|
Removed "random" as a config() option.
|
|
|
|
Removed CCZPRIME Makefile variable.
|
|
|
|
Added zsquaremod() back into zmod.c to be used by the Blum-Blum-Shub
|
|
generator for the special case of needing x^2 mod y.
|
|
|
|
Moved the Blum-Blum-Shub code and defines from zrand.c and zrand.h
|
|
into zrandom.c and zrandom.h. Now only the a55 generator resides
|
|
in zrand.c and zrand.h.
|
|
|
|
Added random, srandom and randombit help files.
|
|
|
|
Added random(), srandom() and randombit() builtin functions. The
|
|
cryptographically strong random number generator is code complete!
|
|
|
|
Removed cryrand.cal now that a Blum-Blum-Shub generator is builtin.
|
|
|
|
Improved the speed of seedrandom.cal. It now uses the 13th
|
|
builtin Blum-Blum-Shub seed.
|
|
|
|
The randmprime.cal script makes use of the Blum-Blum-Shub generator.
|
|
|
|
Added randombitrun.cal and randomrun.cal calc library files.
|
|
These are the Blum-Blum-Shub analogs to the randbitrun.cal
|
|
and randrun.cal a55 tests.
|
|
|
|
Improved hash.c interface to lower level hash functions. The hash
|
|
interface does not yet have a func.c interface ... it is still
|
|
under test.
|
|
|
|
Added randombitrun.cal to test the Blum-Blum-Shub generator.
|
|
|
|
Added calc.h, hash.h, shs.h and value.h to LIB_H_SRC because some
|
|
of the libcalc.a files need them.
|
|
|
|
In the original version, each call to newerror(str) created a new
|
|
error-value. Now a new value will be created only if str has not
|
|
been used in a previous call to newerror(). In effect, the string
|
|
serves to identify the error-value; for example:
|
|
|
|
return newerror("Non-integer argument");
|
|
|
|
can be used in one or more functions, some of which may be
|
|
repeatedly called, but after it has been called once, it will
|
|
always return the same value as if one had initially used the
|
|
assignment:
|
|
|
|
non_integer_argument_error = newerror("Non-integer argument")
|
|
|
|
and then in each function used:
|
|
|
|
return non_integer_argument_error;
|
|
|
|
The new definition of newerror() permits its freer use in cases like:
|
|
|
|
define foo(a) {
|
|
|
|
if (!isint(a))
|
|
return newerror("Non-integer argument");
|
|
...
|
|
}
|
|
|
|
One might say that "new" in "newerror" used to mean being different
|
|
from any earlier error-value. Now it means being not one of the
|
|
"original" or "old" error-values defined internally by calc.
|
|
|
|
As newerror() and newerror("") specify no non-null string, it has
|
|
been arranged that they return the same as newerror("???").
|
|
|
|
Added "show errors" command analogous to "show functions" for
|
|
user-defined functions. One difference is that whereas the
|
|
functions are created by explicit definitions, a new described
|
|
error is created only when a newerror(...) is executed.
|
|
|
|
Fixed macro symbol substitution problem uncovered by HPUX cpp bug in
|
|
HVAL and related zrand.h macros.
|
|
|
|
Added +e to CCMISC for HP-UX users.
|
|
|
|
Fixed the prompt bug.
|
|
|
|
Eliminated the hash_init() initialization function.
|
|
|
|
The 'struct block' has been moved from value.c to a new file: block.h.
|
|
|
|
Added "blkmaxprint" config value, which limits the octets to print
|
|
for a block. A "blkmaxprint" of 0 means to print all octets of a
|
|
block, regardless of size. The default is to print only the first
|
|
256 octets.
|
|
|
|
The "blkverbose" determines if all lines, including duplicates
|
|
should be printed. If TRUE, then all lines are printed. If false,
|
|
duplicate lines are skipped and only a "*" is printed in a sytle
|
|
similar to od. This config value has not meaning if "blkfmt" is
|
|
"str". The default value for "blkverbose" is FALSE: duplicate
|
|
lines are not printed.
|
|
|
|
The "blkbase" determines the base in which octets of a block
|
|
are printed. Possible values are:
|
|
|
|
"hexadecimal" Octets printed in 2 digit hex
|
|
"hex"
|
|
|
|
"octal" Octets printed in 3 digit octal
|
|
"oct"
|
|
|
|
"character" Octets printed as chars with non-printing
|
|
"char" chars as \123 or \n, \t, \r
|
|
|
|
"binary" Octets printed as 0 or 1 chars
|
|
"bin"
|
|
|
|
"raw" Octets printed as is, i.e. raw binary
|
|
"none"
|
|
|
|
The default "blkbase" is "hex".
|
|
|
|
The "blkfmt" determines for format of how block are printed:
|
|
|
|
"line" print in lines of up to 79 chars + newline
|
|
"lines"
|
|
|
|
"str" print as one long string
|
|
"string"
|
|
"strings"
|
|
|
|
"od" print in od-like format, with leading offset,
|
|
"odstyle" followed by octets in the given base
|
|
"od_style"
|
|
|
|
"hd" print in hex dump format, with leading offset,
|
|
"hdstyle" followed by octets in the given base, followed
|
|
"hd_style" by chars or '.' if no-printable or blank
|
|
|
|
The default "blkfmt" is "hd".
|
|
|
|
Fixed a bug in coth() when testing acoth using coth(acoth(x)) == x
|
|
within the rounding error.
|
|
|
|
Assignments to matrices and objects has been changed. The assignments in:
|
|
|
|
A = list(1,2,3,4);
|
|
B = makelist(4) = {1,2,3,4};
|
|
|
|
will result in A == B. Then:
|
|
|
|
A = {,,5}
|
|
|
|
will result in A == list(1,2,5,4).
|
|
|
|
Made minor edits to most help files beginning with a thru d.
|
|
|
|
Fixed error in using cmdbuf("").
|
|
|
|
|
|
Following is the change from calc version 2.10.3t0 to 2.10.3t2:
|
|
|
|
Bumped to version 2.10.3 due to the amount of changes.
|
|
|
|
Renamed qabs() to qqabs() to avoid conflicts with stdlib.h.
|
|
|
|
Fixed a casting problem in label.c.
|
|
|
|
A lot of work was performed on the code generation by Ernest Bowen
|
|
<ernie@neumann.une.edu.au>. Declarations no longer need to precese code:
|
|
|
|
define f(x) {
|
|
local i = x^2;
|
|
print "i = ":i;
|
|
local j = i;
|
|
...
|
|
}
|
|
|
|
The scope of a variable extends from the end of the declaration (including
|
|
initialization code for the variable) at which it is first created
|
|
to the limit given by the following rules:
|
|
|
|
local variable: to the end of the function being defined
|
|
|
|
global variable: to the end of the session with calc
|
|
|
|
static within a function definition: to the the first of:
|
|
|
|
an end of a global, static or local declaration (including
|
|
initialization code) with the same identifier
|
|
|
|
the end of the definition
|
|
|
|
static at top level within a file: to the first of:
|
|
|
|
the next static declaration of the identifier at top level
|
|
in the file,
|
|
|
|
the next global declaration of the identifier at top level
|
|
in the file or in any function definition in the file,
|
|
|
|
the next global declaration of the identifier at any level
|
|
in a file being read as a result of a "read" command,
|
|
|
|
the end of the file.
|
|
|
|
The scope of a top-level global or static variable may be
|
|
interrupted by the use of the identifier as a parameter or local or
|
|
static variable within a function definition in the file being
|
|
read; it is restored (without change of value) after the definition.
|
|
|
|
For example, The two static variables a and b are created,
|
|
with zero value, when the definition is read; a is initialized
|
|
with the value x if and when f(x) is first called with a positive
|
|
even x, b is similarly initialized if and when f(x) is first called
|
|
positive odd x. Each time f(x) is called with positive integer x,
|
|
a or b is incremented. Finally the values of the static variables
|
|
are assigned to the global variables a and b, and the resulting
|
|
values displayed. Immediately after the last of several calls to
|
|
f(x), a = 0 if none of the x's have been positive even, otherwise
|
|
a = the first positive even x + the number of positive even x's,
|
|
and b = 0 if none of the x's have been positive odd, otherwise
|
|
b = the first positive odd x + the number of positive odd x's:
|
|
|
|
define f(x) {
|
|
if (isint(x) && x > 0) {
|
|
if (iseven(x)) {
|
|
static a = x;
|
|
a++;
|
|
} else {
|
|
static b = x;
|
|
b++;
|
|
}
|
|
}
|
|
global a = a, b = b;
|
|
print "a =",a,"b =",b;
|
|
}
|
|
|
|
Fixed some faults in the handling of syntax errors for the matrix
|
|
and object creation operators mat and obj. In previous versions of calc:
|
|
|
|
mat; <- Bad dimension 0 for matrix
|
|
mat A; <- Bad dimension 0 for matrix
|
|
global mat A; <- Bad dimension 0 for matrix
|
|
mat A[2], mat B[3] <- Semicolon expected
|
|
global mat A[2], mat B[3] <- Bad syntax in declaration statement
|
|
|
|
Now:
|
|
|
|
this statement has the same effect as
|
|
-------------- ----------------------
|
|
mat A[2], B[3] (A = mat[2]), B[3]
|
|
|
|
global mat A[2], B[3] global A, B; A = mat[2]; B = mat[3];
|
|
|
|
Initialization remains essentially as before except that for objects,
|
|
spaces between identifiers indicate assignments as in simple variable
|
|
declarations. Thus, after:
|
|
|
|
obj point {x,y};
|
|
obj point P, Q R = {1,2}
|
|
|
|
P has {0,0}, Q and R have {1,2}. In the corresponding expression with
|
|
matrices commas between identifiers before the initialization are ignored.
|
|
For example:
|
|
|
|
this statement has the same effect as
|
|
-------------- ----------------------
|
|
mat A, B C [2] = {1,2} A = B = C = (mat[2] = {1,2})
|
|
|
|
One can also do things like:
|
|
|
|
L = list(mat[2] = {1,2}, obj point = {3,4}, mat[2] = {5,6})
|
|
A = mat[2,2] = {1,2,3,4}^2
|
|
B = mat[2,2] = {1,2,3,4} * mat[2,2] = {5,6,7,8}
|
|
|
|
where the initialization = has stronger binding than the assignment = and
|
|
the * sign.
|
|
|
|
Matrices and objects can be mixed in declarations after any simple
|
|
variables as in:
|
|
|
|
global a, b, mat A, B[2] = {3,4}, C[2] = {4,5}, obj point P = {5,6}, Q
|
|
|
|
Fixed some bugs related to global and static scoping. See the the
|
|
5200 regress test and lib/test5200.cal for details.
|
|
|
|
Optimized opcode generator so that functions defined using '=' do not
|
|
have two unreached opcodes. I.e.,:
|
|
|
|
define f(x) = x^2
|
|
show opcodes f
|
|
|
|
Also unreachable opcodes UNDEF and RETURN are now not included at
|
|
the end of any user-defined function.
|
|
|
|
Changed the "no offset" indicator in label.c from 0 to -1; this
|
|
permits goto jumps to the zero opcode position.
|
|
|
|
Changed the opcode generation for "if (...)" followed by
|
|
"break", "continue", or "goto", so that only one jump opcode is
|
|
required.
|
|
|
|
A label can now be immediately by a rightbrace. For example:
|
|
|
|
define test_newop3(x) {if (x < 0) goto l132; ++x; l132: return x;}
|
|
|
|
The LONG_BITS make variable, if set, will force the size of a long
|
|
as well as forcing the USB8, SB8, USB16, SB16, USB32, SB32,
|
|
HAVE_B64, USB64, SB64, U(x) and L(x) types. If the longbits
|
|
program is given an arg (of 32 or 64), then it will output
|
|
based on a generic 32 or 64 bit machine where the long is
|
|
the same size as the wordsize.
|
|
|
|
Fixed how the SVAL and HVAL macros were formed for BASEB==16 machines.
|
|
|
|
Dropped explicit Makefile support for MIPS r8k since these processors
|
|
no longer need special compiler flags.
|
|
|
|
SGI 6.2 and later uses -xansi.
|
|
|
|
|
|
Following is the change from calc version 2.10.2t33 to 2.10.2t34:
|
|
|
|
Fixed a bug related to fact().
|
|
|
|
Thanks to Ernest Bowen <ernie@neumann.une.edu.au>, for two or three
|
|
arguments,
|
|
|
|
search(x, val, start);
|
|
rsearch(x, val, start);
|
|
|
|
and for matrix, list or association x:
|
|
|
|
search(f, str, start);
|
|
rsearch(f, str, start);
|
|
|
|
for a file stream f open for reading, behave as before except for a few
|
|
differences:
|
|
|
|
(1) there are no limits on the integer-valued start.
|
|
|
|
(2) negative values of start are interpreted as offsets from the size of
|
|
x and f. For example,
|
|
|
|
search(x, val, -100)
|
|
|
|
searches the last 100 elements of x for the first i for which
|
|
x[[i]] = val.
|
|
|
|
(3) for a file f, when start + strlen(str) >= size(f) and
|
|
search(f, str, start) returns null, i.e. str is
|
|
not found, the file position after the search will be
|
|
|
|
size(f) - strlen(str) + 1
|
|
|
|
rather than size(f).
|
|
|
|
For four arguments:
|
|
|
|
search(a, b, c, d)
|
|
rsearch(a, b, c, d),
|
|
|
|
a has the role of x or f, and b the role of val or str as described
|
|
above for the three-argument case, and for search(), c is
|
|
essentially "start" as before, but for rsearch() is better for c
|
|
and d to be the same as for search(). For a non-file case, if:
|
|
|
|
0 <= c < d <= size(a),
|
|
|
|
the index-interval over which the search is to take place is:
|
|
|
|
c <= i < d.
|
|
|
|
If the user has defined a function accept(v,b), this is used rather
|
|
than the test v == b to decide for matrix, list, or association
|
|
searches when a "match" of v = a[[i]] with b occurs. E.g. after:
|
|
|
|
define accept(v,b) = (v >= b);
|
|
|
|
then calling:
|
|
|
|
search(a, 5, 100, 200)
|
|
|
|
will return, if it exists, the smallest index i for which
|
|
100 <= i < 200 and a[[i]] >= 5. To restore the effect of
|
|
the original "match" function, one would then have to:
|
|
|
|
define accept(v,b) == (v == b).
|
|
|
|
Renamed the calc symbol BYTE_ORDER to CALC_BYTE_ORDER in order
|
|
to avoid conflict.
|
|
|
|
Added beer.cal and hello.cal lib progs in support of: :-)
|
|
|
|
http://www.ionet.net/~timtroyr/funhouse/beer.html
|
|
http://www.latech.edu/~acm/HelloWorld.shtml
|
|
|
|
|
|
Following is the change from calc version 2.10.2t25 to 2.10.2t32:
|
|
|
|
Eliminated use of VARARG and <varargs.h>. Calc supports only
|
|
<stdarg.h>. The VARARGS Makefile variable has been eliminated.
|
|
|
|
Source is converted to ANSI C. In particular, functions
|
|
will now have ANSI C style args. Any comments from old K&R
|
|
style args have been moved to function comment section.
|
|
|
|
Removed prototype.h. The PROTO() macro is no longer needed
|
|
or supported.
|
|
|
|
Added mfactor.cal to find the smallest factor of a Mersenne number.
|
|
|
|
The built .h file: have_times.h, determines if the system has
|
|
<time.h>, <times.h>, <sys/time.h> and <sys/times.h>.
|
|
|
|
Because shs.c depends on HASHFUNC, which in turn depends on
|
|
VALUE, shs.o has been moved out of libcalc.a. For the same
|
|
reasons, hash.h and shs.h are not being installed into
|
|
the ${LIBDIR} for now.
|
|
|
|
A number of the regression tests that need random numbers now
|
|
use different seeds.
|
|
|
|
Fixes for compiling under BSDI's BSD/OS 2.0. Added a Makefile
|
|
section for BSD/OS.
|
|
|
|
Added a Makefile compile section for Dec Alpha without gcc ...
|
|
provides a hack-a-round for Dec Alpha cc bug.
|
|
|
|
Minor comment changes to lucas.cal.
|
|
|
|
Added pix.cal, a slow painful but interesting way to compute pix(x).
|
|
|
|
Confusion over the scope of static and global values has been reduced
|
|
by a patch from Ernest Bowen <ernie@neumann.une.edu.au>.
|
|
|
|
The change introduced by the following patch terminates the
|
|
scope of a static variable at any static declaration with the
|
|
same name at the same level, or at any global declaration with
|
|
the same name at any level. With the example above, the scope
|
|
of the static "a" introduced in the third line ends when the
|
|
"global a" is read in the last line. Thus one may now use the
|
|
same name in several "static" areas as in:
|
|
|
|
> static a = 10;
|
|
> define f(x) = a + x;
|
|
> static a = 20;
|
|
> define g(x) = a + x;
|
|
> global a;
|
|
|
|
The first "a" exists only for the definition of f(); the second
|
|
"a" only for the definition of g(). At the end one has only
|
|
the global "a".
|
|
|
|
Ending the scope of a static variable in this way is consistent
|
|
with the normal use of static variables as in:
|
|
|
|
> static a = 10;
|
|
> define f(x) {static a = 20; return a++ + x;}
|
|
> define g(x) = a + x;
|
|
> global a;
|
|
|
|
The scope of the first "a" is temporarily interrupted by the
|
|
"static a" in the second line; the second "a" remains active
|
|
until its scope ends with the ending of the definition of f().
|
|
Thus one ends with g(x) = 10 + x and on successive calls to
|
|
f(), f(x) returns 20 + x, 21 + x, etc. With successive "static
|
|
a" declarations at the same level, the active one at any stage
|
|
is the most recent; if the instructions are being read from a
|
|
file, the scope of the last "static a" ends at the end-of-file.
|
|
|
|
Here I have assumed that no "global a" is encountered. As
|
|
there can be only one global variable with name "a", it seems
|
|
to me that its use must end the scope of any static "a". Thus
|
|
the changes I introduce are such that after:
|
|
|
|
> global a = 10;
|
|
> define f(x) = a + x;
|
|
> static a = 20;
|
|
> define g(x) = a + x;
|
|
> define h(x) {global a = 30; return a + x;}
|
|
> define i(x) = a + x;
|
|
|
|
g(x) will always return 20 + x, and until h(x) has been called,
|
|
f(x) and i(x) will return 10 + x; when h(x) is called, it
|
|
returns 30 + x and any later call to f(x) or i(x) will return
|
|
30 + x. It is the reading of "global a" in the definition of
|
|
h() that terminates the scope of the static a = 20, so that the
|
|
"a" for the last line is the global variable defined in the
|
|
first line. The "a = 30" is executed only when h() is called.
|
|
|
|
Users who find this confusing might be well advised to use
|
|
different names for different variables at the same scope level.
|
|
|
|
The other changes produced by the patch are more straightforward,
|
|
but some tricky programming was needed to get the possibility of
|
|
multiple assignments and what seems to be the appropriate order
|
|
of executions and assignments. For example, the order for the
|
|
declaration:
|
|
|
|
global a, b = expr1, c, d = expr2, e, f
|
|
|
|
will be:
|
|
|
|
evaluation of expr1;
|
|
assignment to b;
|
|
evaluation of expr2;
|
|
assignment to d;
|
|
|
|
Thus the effect is the same as for:
|
|
|
|
a = 0; b = expr1; c = 0; d = expr2; e = 0; f = 0;
|
|
|
|
The order is important when the same name is used for different
|
|
variables in the same context. E.g. one may have:
|
|
|
|
define f(x) {
|
|
global a = 10;
|
|
static a = a;
|
|
local a = a--;
|
|
|
|
while (--a > 0)
|
|
x++;
|
|
return x;
|
|
}
|
|
|
|
Every time this is called, the global "a" is assigned the value
|
|
10. The first time it is called, the value 10 is passed on to
|
|
the static "a" and then to the local "a". In each later call
|
|
the "static a = a" is ignored and the static "a" is one less than
|
|
it was in the preceding call. I'm not recommending this style of
|
|
programming but it is good that calc will be able to handle it.
|
|
|
|
I've also changed dumpop to do something recent versions do not do:
|
|
distinguish between static and global variables with the same name.
|
|
|
|
Other changes: commas may be replaced by spaces in a sequence of
|
|
identifiers in a declaration. so one may now write:
|
|
|
|
global a b c = 10, d e = 20
|
|
|
|
The comma after the 10 is still required. Multiple occurrences
|
|
of an identifier in a local declaration are now acceptable as
|
|
they are for global or static declarations:
|
|
|
|
local a b c = 10, a = 20;
|
|
|
|
does the same as:
|
|
|
|
local a b c;
|
|
a = b = c = 10;
|
|
a = 20;
|
|
|
|
The static case is different in that:
|
|
|
|
static a b c = 10, a = 20;
|
|
|
|
creates four static variables, the first "a" having a very short and
|
|
useless life.
|
|
|
|
Added new tests to verify the new assugnments above.
|
|
|
|
Added the builtin test(x) which returns 1 or 0 according as x tests
|
|
as true or false for conditions.
|
|
|
|
Added have_posscl.c which attempts to determine if FILEPOS is
|
|
a scalar and defines HAVE_FILEPOS_SCALAR in have_posscl.h
|
|
accordingly. The Makefile variable HAVE_POSSCL determines
|
|
if have_posscl.c will test this condition or assume non-scalar.
|
|
|
|
Added have_offscl.c which attempts to determine if off_t is
|
|
a scalar and defines HAVE_OFF_T_SCALAR in have_posscl.h
|
|
accordingly. The Makefile variable HAVE_OFFSCL determines
|
|
if have_offscl.c will test this condition or assume non-scalar.
|
|
|
|
Reading to EOF leaves you positioned one character beyond
|
|
the last character in the file, just like Un*x read behavior.
|
|
|
|
Calc supports files and offsets up to 2^64 bytes, if the OS
|
|
and file system permits.
|
|
|
|
|
|
Following is the change from calc version 2.10.2t4 to 2.10.2t24:
|
|
|
|
Added makefile debugging rules:
|
|
|
|
make chk like a 'make check' (run the regression tests)
|
|
except that only a few lines around interesting
|
|
(and presumable error messages) are printed.
|
|
No output if no errors are found.
|
|
|
|
make env print important makefile values
|
|
|
|
make mkdebug 'make env' + version information and a
|
|
make with verbose output and printing of
|
|
constructed files
|
|
|
|
make debug 'make mkdebug' with a 'make clobber'
|
|
so that the entire make is verbose and
|
|
a constructed files are printed
|
|
|
|
Improved instuctions in 'BUGS' section on reporting problems.
|
|
In particular we made it easy for people to send in a full
|
|
diagnostic output by sending 'debug.out' which is made as follows:
|
|
|
|
make debug > debug.out
|
|
|
|
Added -v to calc command line to print the version and exit.
|
|
|
|
Fixed declarations of memcpy(), strcpy() and memset() in the
|
|
case of them HAVE_NEWSTR is false.
|
|
|
|
Fixed some compile time warnings.
|
|
|
|
Attempting to rewind a file this is not open generates an error.
|
|
|
|
Noted conversion problems in file.c in tripple X comments.
|
|
|
|
Some extremely braindead shells cannot correctly deal with if
|
|
cluases that do not have a non-empty else statement. Their
|
|
exit bogosity results in make problems. As a work-a-round,
|
|
Makefile if clauses have 'else true;' clauses for if statements
|
|
that previously did not have an else cluause.
|
|
|
|
Fixed problems where the input stack depth reached the 10 levels.
|
|
|
|
The show keyword is now a statement instead of a command:
|
|
|
|
> define demo() {local f = open("foo", "w"); show files; fclose(f);}
|
|
> demo()
|
|
|
|
Added a new trace option for display of links to real and complex
|
|
numbers. This is activated by config("trace", 4). The printing
|
|
of a real number is immediately followed by "#" and the number of
|
|
links to that number; complex numbers are printed in the same
|
|
except for having "##" instead of "#". <ernie@neumann.une.edu.au>
|
|
|
|
The number of links for a number value is essentially the number of value
|
|
locations at which it is either stored or deemed to be stored. Here a
|
|
number value is the result of a reading or evaluation; when the result
|
|
is assigned to lvalues, "linking" rather than copying occurs. Different
|
|
sets of mutually linked values may contain the same number. For example:
|
|
|
|
a = b = 2 + 3; x, y = 2 + 3;
|
|
|
|
a and b are linked, and x and y are linked, but a and x are not linked.
|
|
|
|
Revised the credits help file and man page. Added archive help
|
|
file to indicate where recent versions of calc are available.
|
|
|
|
The regression test suite output has been changed so that it will
|
|
output the same information regardless of CPU performance. In
|
|
particular, cpu times of certain tests are not printed. This allows
|
|
one to compare the regression output of two different systems easier.
|
|
|
|
A matrix or object declaration is now considered an expression
|
|
and returns a matrix or object of the specified type. Thus one may
|
|
use assignments like:
|
|
|
|
A = mat[2]; /* same as: mat A[2]; */
|
|
P = obj point; /* same as: obj point P; */
|
|
|
|
The obj and mat keywords may be with "local", "global", "static" as in:
|
|
|
|
local mat A[2];
|
|
|
|
Several matrices or objects may be assigned or declared in the one
|
|
statement, as in:
|
|
|
|
mat A, B[2], C[3]; /* same as: mat A[2], B[2], C[3] */
|
|
|
|
except that only one matrix creation occurs and is copied as in:
|
|
|
|
A = B = mat[2];
|
|
|
|
Initialization of matrices and objects now occur before assignments:
|
|
|
|
mat A, B [2] = {1,2}; /* same as: A = B = (mat[2] = {1,2}); */
|
|
|
|
Missing arguments are considered as "no change" rather than
|
|
"assign null values". As in recent versions of calc, the default
|
|
value assigned to matrix elements is zero and the default for object
|
|
elements is a null value). Thus:
|
|
|
|
mat A[2] = {1,2};
|
|
A = { , 3};
|
|
|
|
will change the value of A to {1,3}.
|
|
|
|
If the relevant operation exists for matrices or has been defined for
|
|
the type of object A is, the assignment = may be combined with +, -, *,
|
|
etc. as in:
|
|
|
|
A += {3, 4}; /* same as: A[0] += 3; A[1] += 4; */
|
|
A += { }; /* same as: A += A; */
|
|
|
|
In (non-local) declarations, the earlier value of a variable may be
|
|
used in the initialization list:
|
|
|
|
mat A[3]={1,2,3}; mat A[3]={A[2],A[1],A[0]}; /* same as: A={3,2,1} */
|
|
|
|
Also:
|
|
|
|
mat A[3] = {1,2,3};
|
|
mat A[3] = {A, A, A};
|
|
|
|
produces a 3-element matrix, each of whose elements is a 3-element matrix.
|
|
|
|
The notation A[i][j] requires A[i] to be a matrix, whereas B[i,j]
|
|
accesses an element in a 2-dimensional matrix. Thus:
|
|
|
|
B == A[i] implies A[i][j] = B[j]
|
|
|
|
There is requirement in the use of A[i][j] that the matrices A[i]
|
|
for i = 0, 1, ... all be of the same size. Thus:
|
|
|
|
mat A[3] = {(mat[2]), (mat[3]), (mat[2])};
|
|
|
|
produces a matrix with a 7-element structure:
|
|
|
|
A[0][0], A[0][1], A[1][0], A[1][1], A[1][2], A[2][0], A[2][1]
|
|
|
|
One can initialize matrices and objects whose elements are matrices
|
|
and/or objects:
|
|
|
|
obj point {x,y}
|
|
obj point P;
|
|
obj point A = {P,P};
|
|
|
|
or:
|
|
|
|
obj point {x,y};
|
|
obj point P;
|
|
mat A[2] = {P,P};
|
|
A = {{1,2}, {3,4}};
|
|
|
|
The config("trace", 8) causes opcodes of newly defined functions
|
|
are displayed. Also show can now show the opcides for a function.
|
|
For example:
|
|
|
|
config("trace", 8);
|
|
define f(x) = x^2;
|
|
show opcodes f;
|
|
define g(x,y) {static mat A[2]; A += {x,y}; return A;}
|
|
show opcodes g
|
|
g(2,3);
|
|
show opcodes g;
|
|
g(3,4);
|
|
|
|
The two sequences displayed for f should show the different ways
|
|
the parameter is displayed. The third sequence for g should also
|
|
show the effects of the static declaration of A.
|
|
|
|
Fixed a number of compiler warning and type cast problems.
|
|
|
|
Added a number of new error codes.
|
|
|
|
Misc bug fixes for gcc2 based Sparc systems.
|
|
|
|
Fixed a bug in the SVAL() macro on systems with 'long long'
|
|
type and on systems with 16 bit HALFs.
|
|
|
|
Reduced the Makefile CC set:
|
|
|
|
CCOPT are flags given to ${CC} for optimization
|
|
CCWARN are flags given to ${CC} for warning message control
|
|
CCMISC are misc flags given to ${CC}
|
|
|
|
CFLAGS are all flags given to ${CC}
|
|
[[often includes CCOPT, CCWARN, CCMISC]]
|
|
ICFLAGS are given to ${CC} for intermediate progs
|
|
|
|
CCMAIN are flags for ${CC} when files with main() instead of CFLAGS
|
|
CCSHS are flags given to ${CC} for compiling shs.c instead of CFLAGS
|
|
|
|
LCFLAGS are CC-style flags for ${LINT}
|
|
LDFLAGS are flags given to ${CC} for linking .o files
|
|
ILDFLAGS are flags given to ${CC} for linking .o files
|
|
for intermediate progs
|
|
|
|
CC is how the the C compiler is invoked
|
|
|
|
Added more tests to regress.cal.
|
|
|
|
Port to HP-UX.
|
|
|
|
Moved config_print() from config.c to value.c so prevent printvalue()
|
|
and freevalue() from being unresolved symbols for libcalc.a users.
|
|
|
|
Calc will generate "maximum depth reached" messages or errors when
|
|
reading or eval() is attempted at maximum input depth.
|
|
|
|
Now each invocation of make is done via ${MAKE} and includes:
|
|
|
|
MAKE_FILE=${MAKE_FILE}
|
|
TOPDIR=${TOPDIR}
|
|
LIBDIR=${LIBDIR}
|
|
HELPDIR=${HELPDIR}
|
|
|
|
Setting MAKE_FILE= will cause make to not re-make if the Makefile
|
|
is edited.
|
|
|
|
Added libinit.c which contains the function libcalc_call_me_first().
|
|
Users of libcalc.a MUST CALL libcalc_call_me_first BEFORE THEY USE
|
|
ANY OTHER libcalc.a functions!
|
|
|
|
Added support for the SGI IRIX6.2 (or later) Mongoose 7.0 (or later)
|
|
C Compiler for the r4k, r8k and r10k. Added LD_NO_SHARED for
|
|
non-shared linker support.
|
|
|
|
Re-ordered and expanded options for the DEBUG make variable.
|
|
|
|
Make a few minor cosmetic comment changes/fixes in the main Makefile.
|
|
|
|
Statements such as:
|
|
|
|
mat A[2][3];
|
|
|
|
now to the same as:
|
|
|
|
mat M[3];
|
|
mat A[2] = {M, M};
|
|
|
|
To initialize such an A one can use a statement like
|
|
|
|
A = {{1,2,3}, {4,5,6}};
|
|
|
|
or combine initialization with creation by:
|
|
|
|
mat A[2][3] = {{1,2,3}, {4,5,6}};
|
|
|
|
One would then have, for example, A[1][0] = 4. Also, the inner braces
|
|
cannot be removed from the initialization for A:
|
|
|
|
mat A[2][3] = {1,2};
|
|
|
|
results in exactly the same as:
|
|
|
|
mat A[2] = {1,2};
|
|
|
|
Added rm("file") builtin to remove a file.
|
|
|
|
The regress test sections that create files also use rm() to remove
|
|
them before and afterwards.
|
|
|
|
Added 4400-4500 set to test new mat and obj initializaion rules.
|
|
|
|
Added 4600 to test version file operations.
|
|
|
|
Added CCZPRIME Makefile variable to the set for the short term
|
|
to work around a CC -O2 bug on some SGI machines.
|
|
|
|
Added regression test of _ variables and function names.
|
|
|
|
Added read of read and write, including read and write test for
|
|
long strings.
|
|
|
|
Fixed bug associated with read of a long string variable.
|
|
|
|
Renumbered some of the early regress.cal test numbers to make room
|
|
for more tests. Fixed all out of sequence test numbers. Fixed some
|
|
malformatted regression reports.
|
|
|
|
Renamed STSIZE_BITS to OFF_T_BITS. Renamed SWAP_HALF_IN_STSIZE to
|
|
SWAP_HALF_IN_OFF_T.
|
|
|
|
|
|
Following is the change from calc version 2.10.2t1 to 2.10.2t3:
|
|
|
|
Fixed bug in the regression suite that made test3400 and test4100
|
|
fail on correct computations.
|
|
|
|
The randbit() builtin, when given to argument, returns 1 random bit.
|
|
|
|
Fixed a bug in longlong.c which made is generate a syntax error
|
|
on systems such as the PowerPC where the make variable LONGLONG
|
|
was left empty.
|
|
|
|
By default, the Makefile leaves LONGLONG_BITS empty to allow for
|
|
testing of 64 bit data types. A few hosts may have problems with
|
|
this, but hopefully not. Such hosts can revert back to LONGLONG_BITS=0.
|
|
|
|
Improved SGI support. Understands SGI IRIX6.2 performance issues
|
|
for multiple architectures.
|
|
|
|
Fixed a number of implicit conversion from unsigned long to long to avoid
|
|
unexpected rounding, sign extension, or loss of accuracy side effects.
|
|
|
|
Added SHSCC because shs.c contains a large expression that some
|
|
systems need help in optimizing.
|
|
|
|
Added "show files" to display information about all currently open files.
|
|
|
|
Calc now prevents user-defined function having the same name as a
|
|
builtin function.
|
|
|
|
A number of new error codes (more than 100) have been added.
|
|
|
|
Added ctime() builtin for date and time as string value.
|
|
Added time() builtin for seconds since 00:00:00 1 Jan 1970 UTC.
|
|
Added strerror() builtin for string describing error type.
|
|
Added freopen() builtin to reopen a file.
|
|
Added frewind() builtin to rewind a file.
|
|
Added fputstr() builtin to write a null-terminated string to a file.
|
|
Added fgetstr() builtin to read a null-terminated string from a file.
|
|
Added fgetfield() builtin to read next field from file.
|
|
Added strscan() builtin to scan a string.
|
|
Added scan() builtin to scan of a file.
|
|
Added fscan() builtin to scan of a file.
|
|
Added fscanf() builtin to do a formatted scan of a file.
|
|
Added scanf() builtin to do a formatted scan of stdin.
|
|
Added strscanf() builtin to do a formatted scan of a string.
|
|
Added ungetc() builtin to unget character read from a file.
|
|
|
|
As before, files opened with fopen() will have an id different from
|
|
earlier files. But instead of returning the id to the FILEIO slot
|
|
used to store information about it, calc simply uses consecutive
|
|
numbers starting with 3. A calc file retains its id, even when the
|
|
file has been closed.
|
|
|
|
The builtin files(i) now returns the file opened with id == i
|
|
rather than the file with slot number i. For any i <= lastid,
|
|
files(i) has at some time been opened. Whether open or closed, it
|
|
may be "reopened" with the freopen() command. This write to a file
|
|
and then read it, use:
|
|
|
|
f = fopen("junk", "w")
|
|
freopen(f, "r")
|
|
|
|
To use the same stream f for a new file, one may use:
|
|
|
|
freopen(f, mode, newfilename)
|
|
|
|
which closes f (assuming it is open) and then opens newfilename on f.
|
|
|
|
And as before:
|
|
|
|
f = fopen("curds", "r")
|
|
g = fopen("curds", "r")
|
|
|
|
results in two file ids (f and g) that refer to the same file
|
|
name but with different pointers.
|
|
|
|
Calc now understands "w+", "a+" and "r+" file modes.
|
|
|
|
If calc opens a file without a mode there is a "guess" that mode
|
|
"r+" will work for any files with small descriptors found to be
|
|
open. In case it doesn't (as apparently happens if the file had
|
|
not been opened for both reading and reading) the function now also
|
|
tries "w" and "r", and if none work, gives up. This avoids having
|
|
"open" files with null fp.
|
|
|
|
The buildin rewind() calls the C rewind() function, but one may
|
|
now rewind several files at once by a call like rewind(f1, f2).
|
|
With no argument, rewind() rewinds all open files with id >= 3.
|
|
|
|
The functions fputstr(), fgetstr() have been defined to include the
|
|
terminating '\0' when writing a string to a file. This can be done
|
|
at present with a sequence of instructions like:
|
|
|
|
fputs(f, "Landon"); fputc(f, 0);
|
|
fputs(f, "Curt"); fputc(f, 0);
|
|
fputs(f, "Noll"); fputc(f, 0);
|
|
|
|
One may now do:
|
|
|
|
fputstr(f, "Landon", "Curt", "Noll");
|
|
|
|
and read them back by:
|
|
|
|
rewind(f);
|
|
x = fgetstr(f); /* returns "Landon" */
|
|
y = fgetstr(f); /* returns "Curt" */
|
|
z = fgetstr(f); /* returns "Noll" */
|
|
|
|
The buildin fgetfield() returns the next field of non-whitepsace
|
|
characters.
|
|
|
|
The builtins scan(), fscan(), strscan() read tokens (fields of
|
|
non-whitepsace characters) and evaluates them. Thus:
|
|
|
|
global a,b,c;
|
|
strscan("2+3 4^2\n c=a+b", a, b, 0);
|
|
|
|
results in a = 5, b = 16, c = 21
|
|
|
|
The functions scanf, fscanf, strscanf behave like the C functions
|
|
scanf, fscanf, sscanf. The conversion specifiers recognized are "%c",
|
|
"%s", "%[...]" as in C, with the options of *, width-specification,
|
|
and complementation (as in [^abc]), and "%n" for file-position, and
|
|
"%f", "%r", "%e", "%i" for numbers or simple number-expressions - any
|
|
width-specification is ignored; the expressions are not to include any
|
|
white space or characters other than decimal digits, +, -, *, /, e, and i.
|
|
E.g. expressions like 2e4i+7/8 are acceptable.
|
|
|
|
The builtin size(x) now returns the size of x if x is an open file
|
|
or -1 if x is a file but not open. If s is a string, size(s) returns
|
|
characters in s.
|
|
|
|
Added buildin access("foo", "w") returns the null value if a file
|
|
"foo" exists and is writeable.
|
|
|
|
Some systems has a libc symbolc qadd() that conflicted with calc's
|
|
qadd function. To avoid this, qadd() has been renamed to qqadd().
|
|
|
|
The calc error codes are produced from the the calcerr.tbl file.
|
|
Instead of changing #defines in value.h, one can not edit calcerr.tbl.
|
|
The Makefile builds calcerr.h from this file.
|
|
|
|
Calc error codes are now as follows:
|
|
|
|
<0 invalid
|
|
0 .. sys_nerr-1 system error ala C's errno values
|
|
sys_nerr .. E__BASE-1 reserved for future system errors
|
|
E__BASE .. E__HIGHEST calc internal errors
|
|
E__HIGHEST+1 .. E_USERDEF-1 invalid
|
|
E_USERDEF .. user defined errors
|
|
|
|
Currently, E__BASE == 10000 and E_USERDEF == 20000. Of course,
|
|
sys_nerr is system defined however is likely to be < E__BASE.
|
|
|
|
Renamed CONST_TYPE (as defined in have_const.h) to just CONST.
|
|
This symbol will either be 'const' or an empty string depending
|
|
on if your compiler understands const.
|
|
|
|
CONST is beginning to be used with read-only tables and some
|
|
function arguments. This allows certain compilers to better
|
|
optimize the code as well as alerts one to when some value
|
|
is being changed inappropriately. Use of CONST as in:
|
|
|
|
int foo(CONST int curds, char *CONST whey)
|
|
|
|
while legal C is not as useful because the caller is protected
|
|
by the fact that args are passed by value. However, the
|
|
in the following:
|
|
|
|
int bar(CONST char *fizbin, CONST HALF *data)
|
|
|
|
is useful because it calls the compiler that the string pointed
|
|
at by 'fizbin' and the HALF array pointer at by 'data' should be
|
|
treated as read-only.
|
|
|
|
|
|
Following is the change from calc version 2.10.1t21 to 2.10.2t0:
|
|
|
|
Bumped patch level 2.10.2t0 in honor of having help files for
|
|
all builtin functions. Beta release will happen at the end of
|
|
the 2.10.2 cycle!!!
|
|
|
|
Fewer items listed in BUGS due to a number of bug fixes.
|
|
|
|
Less todo in the help/todo file because more has already been done. :-)
|
|
|
|
All builtin functions have help files! While a number need cleanup
|
|
and some of the LIMITS, LIBRARY and SEE ALSO sections need fixing
|
|
(or are missing), most of it is there. A Big round of thanks goes
|
|
to <ernie@neumann.une.edu.au> for his efforts in initial write-ups
|
|
for many of these files!
|
|
|
|
The recognition of '\' as an escape character in the format argument
|
|
of printf() has been dropped. Thus:
|
|
|
|
printf("\\n");
|
|
|
|
will print the two-character string "\n" rather than the a
|
|
one-character carriage return. <ernie@neumann.une.edu.au>
|
|
|
|
Missing args to printf-like functions will be treated as null values.
|
|
|
|
The scope of of config("fullzero") has been extended to integers,
|
|
so that for example, after config("mode","real"), config("display", 5),
|
|
config("fullzero", 1), both:
|
|
|
|
print 0, 1, 2;
|
|
printf("%d %d %d\n", 0, 1, 2);
|
|
|
|
print:
|
|
|
|
.00000 1.00000, 2.00000
|
|
|
|
The bug which caused calc to exit on:
|
|
|
|
b = "print 27+"
|
|
eval(b)
|
|
|
|
has been fixed. <ernie@neumann.une.edu.au>
|
|
|
|
Fixed bugs in zio.c which caused eval(str(x)) == x to fail
|
|
in non-real modes such as "oct". <ernie@neumann.une.edu.au>
|
|
|
|
The following:
|
|
|
|
for (i = 1; i < 10; i++) print i^2,;
|
|
|
|
now prints the same as:
|
|
|
|
for (i = 1; i < 10; i++) print i^2,;
|
|
|
|
The show globals will print '...' in the middle of large values.
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
The param(n) builtin, then n > 0, returns the address rather than
|
|
the value of the n-th argument to save time and memory usage. This
|
|
is useful when a matrix with big number entries is passed as an arg.
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
The param(n) builtin, then n > 0, may be used as an lvalue:
|
|
|
|
> define g() = (param(2) = param(1));
|
|
> define h() = (param(1)++, param(2)--);
|
|
> u = 5
|
|
> v = 10
|
|
> print g(u, &v), u, v;
|
|
5 5 5
|
|
> print h(&u, &v), u, v;
|
|
5 6 4
|
|
|
|
Missing args now evaluate to null as in:
|
|
|
|
A = list(1,,3)
|
|
B = list(,,)
|
|
mat C[] = {,,}
|
|
mat D[] = { }
|
|
|
|
|
|
Following is the change from calc version 2.10.1t20 to 2.10.1t20:
|
|
|
|
Changes made in preparation for Blum Blum Shub random number generator.
|
|
|
|
REDC bug fixes: <ernie@neumann.une.edu.au>
|
|
|
|
Fixed yet another bug in zdiv which occasionally caused the "top digit"
|
|
of a nonzero quotient to be zero.
|
|
|
|
Fixed a bug in zredcmul() where a rarely required "topdigit" is
|
|
sometimes lost rather than added to the appropriate carry.
|
|
|
|
A new function zredcmodinv(ZVALUE z, ZVALUE *res) has been defined for
|
|
evaluating rp->inv in zredcalloc(). <ernie@neumann.une.edu.au>
|
|
|
|
New functions zmod5(ZVALUE *zp) and zmod6(ZVALUE z, ZVALUE *res) have
|
|
been defined to give O(N^1.585)-runtime evaluation of z % m for
|
|
large N-word m. These require m and BASE^(2*N) // m to have been
|
|
stored at named locations lastmod, lastmodinv. zmod5() is essentially
|
|
for internal use by zmod6() and zpowermod(). <ernie@neumann.une.edu.au>
|
|
|
|
Changes to rcmul(x,y,m) so that the result is always in [0, m-1].
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
Changes to some of the detail of zredcmul() so that it should run slightly
|
|
faster. Also changes to zredcsq() in the hope that it might achieve
|
|
something like the improvement in speed of x^2 compared with x * x.
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
A new "bignum" algorithm for evaluating pmod(x,k,m) when
|
|
N >= config("pow2"). For the multiplications and squarings
|
|
modulo m, or their equivalent, when N >= config("redc2"),
|
|
calc has used evaluations correponding to rcout(x * y, m),
|
|
for which the runtime is essentially that of three multiplications.
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
Yet more additions to the regress.cal test suite.
|
|
|
|
Fixed some ANSI-C compile nits in shs.c and quickhash.c.
|
|
|
|
Plugs some potential memory leaks in definitions in func.c.
|
|
Expressions such as qlink(vals[2]) in some circumstances are
|
|
neither qfreed nor returned as function values.
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
The nextcand() and prevcand() functions handle modval, modulus
|
|
and skip by using ZVALUE rather than ZVALUE * and dropping
|
|
the long modulus, etc. <ernie@neumann.une.edu.au>
|
|
|
|
Changed a couple of occurrences of itoq(1) or itoq(0) to &_qone_
|
|
and &_qzero_. <ernie@neumann.une.edu.au>
|
|
|
|
In definition of f_primetest, changed ztolong(q2->num) to ztoi(q2->num)
|
|
so that the sign of count in ptest(n, count, skip) is not lost; and
|
|
ztolong(q3->num) to q3->num so that skip can be any integer.
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
In zprime.c, in definition of small_factor(), adds "&& *tp != 1" to
|
|
the exit condition in the for loop so that searching for a factor
|
|
will continue beyond the table of primes, as required for e.g.
|
|
factor(2^59 - 1). <ernie@neumann.une.edu.au>
|
|
|
|
Changed zprimetest() so that skip in ptest(n, count, skip)
|
|
determines the way bases for the tests are selected. Neg values of
|
|
n are treated differently. When considering factorization,
|
|
primeness, etc. one is concerned with equivalence classes which for
|
|
the rational integers are {0}, {-1, 1}, {-2, 2}, etc. To refer to
|
|
an equivalence class users may use any of its elements but when
|
|
returning a value for a factor the computer normally gives the
|
|
non-negative member. The same sort of thing happens with integers
|
|
modulo an integer, with fractions, etc., etc. E.g. users may refer
|
|
to 3/4 as 6/8 or 9/12, etc. A simple summary of the way negative n
|
|
is treated is "the sign is ignored". E.g. isprime(-97) and
|
|
nextprime(-97) now return the same as isprime(97) and nextprime(97).
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
|
|
Following is the change from calc version 2.10.1t11 to 2.10.1t19:
|
|
|
|
Added many more regression tests to lib/regress.cal. Some
|
|
due to <ernie@neumann.une.edu.au>.
|
|
|
|
Added many help files, most due to <ernie@neumann.une.edu.au>.
|
|
|
|
Fixed exp() and ln() so that when they return a complex value with a
|
|
zero imaginary component, isreal() is true. <ernie@neumann.une.edu.au>
|
|
|
|
Fixed cast problem in byteswap.c. <ernie@neumann.une.edu.au>
|
|
|
|
Fixed memory leak problem where repeated assignments did not
|
|
free the previous value. <ernie@neumann.une.edu.au>
|
|
|
|
Complex number ordering/comparison has been changed such that:
|
|
|
|
a < b implies a + c < b + c
|
|
a < b and c > 0 implies a * c < b * c
|
|
a < b implies -a > -b
|
|
|
|
To achieve a "natural" partial ordering of the complex numbers
|
|
with the above properties, cmp(a,b) for real or complex numbers
|
|
may be considered as follows:
|
|
|
|
cmp(a,b) = sgn(re(a) - re(b)) + sgn(im(a) - im(b)) * 1i
|
|
|
|
The cmp help file has been uptdated.
|
|
|
|
Change HASH type to QCKHASH. The HASH type is a name better suited
|
|
for the upcoming one-way hash interface.
|
|
|
|
Added the CONFIG type; a structure containing all of the configuration
|
|
values under the control of config(). Added V_CONFIG data type.
|
|
The call config("all") returns a V_CONFIG. One may now save/restore
|
|
the configuration state as follows:
|
|
|
|
x = config("all")
|
|
...
|
|
config("all",x)
|
|
|
|
Added two configuration aliases, "oldstd" (for old backward compatible
|
|
standard configuration) and "newstd" (for new style configuration).
|
|
One may set the historic configuration state by:
|
|
|
|
config("all", "oldstd")
|
|
|
|
One may use what some people consider to be a better but not backward
|
|
compatible configuration state by:
|
|
|
|
config("all", "newstd")
|
|
|
|
Renamed config.h (configuration file built during the make) to conf.h.
|
|
Added a new config.h to contain info on thw V_CONFIG type.
|
|
|
|
Fixed some ANSI C compile warnings.
|
|
|
|
The show config output is not indented by only one tab, unless
|
|
config("tab",0) in which case it is not indented.
|
|
|
|
The order of show config has been changed to reflect the config
|
|
type values.
|
|
|
|
Changed declaration of sys_errlst in func.c to be char *.
|
|
|
|
Added quo(x,y,rnd) and mod(x,y,rnd) to give function interfaces
|
|
to // and % with rounding mode arguments. Extended these functions
|
|
to work for list-values, complex numbers and matrices.
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
For integer x, cfsim(x,8) returns 0. <ernie@neumann.une.edu.au>
|
|
|
|
Fixed config("leadzero"). <ernie@neumann.une.edu.au>
|
|
|
|
Set config("cfsim",8) by default (in "oldstd"). Setup initial idea for
|
|
config("all", "newstd") to be the default with the following changes:
|
|
|
|
display 10
|
|
epsilon 1e-10
|
|
quo 0
|
|
outround 24
|
|
leadzero 1
|
|
fullzero 1
|
|
prompt "; " (allows full line cut/paste)
|
|
more ";; " (allows full line cut/paste)
|
|
|
|
The "newstd" is a (hopefully) more perferred configuration than the
|
|
historic default.
|
|
|
|
The fposval.h file defines DEV_BITS and INODE_BITS giving the
|
|
bit size of the st_dev and st_ino stat elements. Also added
|
|
SWAP_HALF_IN_DEV and SWAP_HALF_IN_STSIZE.
|
|
|
|
Added sec(), csc(), cot(), sech(), csch(), coth(), asec(), acsc(),
|
|
acot(), asech(), acsch() and acoth() builtins. <ernie@neumann.une.edu.au>
|
|
|
|
The initmasks() call is no longer needed. The bitmask[] array
|
|
is a compiled into zmath.c directly.
|
|
|
|
Added isconfig(), ishash(), isrand() and israndom() builtins to
|
|
test is something is a configuration state, hash state, RAND
|
|
state or RANDOM state.
|
|
|
|
The lib/cryrand.cal library now no longer keeps the Blum prime
|
|
factors used to formt he Blum modulus. The default modulus has
|
|
been expanded to 1062 bits product of two Blum primes.
|
|
|
|
The function hash_init() is called to initialize the hash function
|
|
interface.
|
|
|
|
Misc calc man page fixes and new command line updates.
|
|
|
|
Fixed bug related to srand(1).
|
|
|
|
Cleaned up some warning messages.
|
|
|
|
All calls to math_error() now have a /*NOTREACHED*/ comment after
|
|
them. This allows lint and compiler flow progs to note the jumpjmp
|
|
nature of math_error(). Unfortunately some due to some systems
|
|
not dealing with /*NOTREACHED*/ comments correctly, calls of the form:
|
|
|
|
if (foo)
|
|
math_error("bar");
|
|
|
|
must be turned into:
|
|
|
|
if (foo) {
|
|
math_error("bar");
|
|
/*NOTREACHED*/
|
|
}
|
|
|
|
The ploy() function can take a list of coefficients. See
|
|
the help/poly file. Added poly.c. <ernie@neumann.une.edu.au>
|
|
|
|
Fixes and performance improvemtns to det(). <ernie@neumann.une.edu.au>
|
|
|
|
Renamed atoq() and atoz() to str2q() and str2z() to avoid conflicts
|
|
with libc function names.
|
|
|
|
Fixed use of ${NROFF_ARG} when ${CATDIR} and ${NROFF} are set.
|
|
|
|
Fixed SWAP_HALF_IN_B64 macro use for Big Endian machines without
|
|
long long or with LONGLONG_BITS=0.
|
|
|
|
Added error() and iserror() to generate a value of a given error type.
|
|
See help/error for details. <ernie@neumann.une.edu.au>
|
|
|
|
Added singular forms of help files. For example one can now get
|
|
help for binding, bug, change, errorcode and type.
|
|
|
|
The builtin mmin(x, md) has been changed to return the same as
|
|
mod(x, md, 16). The old mmin(x, md) required md to be a positive
|
|
integer and x to be an integer. Now md can be any real number; x
|
|
can be real, complex, or a matrix or list with real elements, etc.
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
The builtin avg(x_1, x_2, ...) has been changed to accept list-valued
|
|
arguments: a list x_i contributes its elements to the list of items to
|
|
be averaged. E.g. avg(list(1,2,list(3,4)),5) is treated as if it were
|
|
avg(1,2,3,4,5). If an error value is encountered in the items to be
|
|
averaged, the first such value is returned. If the number of items to be
|
|
averaged is zero, the null value is returned. <ernie@neumann.une.edu.au>
|
|
|
|
The builtin hmean(x_1, x_2, ...) has been changed to admit types
|
|
other than real for x_1, x_2, ...; list arguments are treated in
|
|
the same way as in avg(). <ernie@neumann.une.edu.au>
|
|
|
|
The builtin eval(str) has been changed so that when str has a
|
|
syntax error, instead of call to math_error(), an error value is
|
|
returned. <ernie@neumann.une.edu.au>
|
|
|
|
The old frem(x,y) builtin returned the wrong value when y was a power of
|
|
2 greater than 2, e.g. f(8,4) is returned as 4 when its value should be 2.
|
|
This has been fixed by a small change to the definition of zfacrem().
|
|
Calc used to accept with no warning or error message, gcdrem(0,2) or
|
|
generally gcdrem(0,y) for any y with abs(y) > 1, but then went into an
|
|
infinite loop. This has been fixed by never calling zfacrem() with zero x.
|
|
Both frem(x,y) and gcdrem(x,y) now reject y = -1, 0 or 1 as errors. For
|
|
nonzero x, and y == -1 or 1, defining frem(x,y) and gcdrem(x,y) to equal
|
|
abs(x) is almost as natural as defining x^0 to be 1. Similarly, if x is
|
|
not zero then gcdrem(x,0) == 1.
|
|
<ernie@neumann.une.edu.au>
|
|
|
|
Plugged some more memory leaks.
|
|
|
|
Fixed bug related randbit(x) skip (where x < 0).
|
|
|
|
Added seedrandom.cal to help users use the raw random() interface well.
|
|
|
|
Made extensive additions and changes to the rand() and random() generator
|
|
comments in zrand.c.
|
|
|
|
Fixed a bug in fposval.c that prevented calc from compiling on systems
|
|
with 16 bit device and/or inodes. Fixed error messages in fposval.c.
|
|
|
|
Fixed bug that would put calc into an infinite loop if it is ran
|
|
with errors in startup files (calc/startup, .calcrc).
|
|
Ha Lam <hl@kuhep5.phsx.ukans.edu>
|
|
|
|
|
|
Following is the change from calc version 2.10.0t13 to 2.10.1t10:
|
|
|
|
Added SB8, USB8, SB16, USB16, SB32, USB32 typedefs, determined by
|
|
longbits and declared in longbits.h, to deal with 8, 16 and 32 bit
|
|
signed and unsigned values.
|
|
|
|
The longbits.h will define HAVE_B64 with a 64 bit type (long or
|
|
longlong) is available. If one is, then SB64 abd US64 typedefs
|
|
are declared.
|
|
|
|
The U(x) and L(x) macros only used to define 33 to 64 bit signed
|
|
and unsigned constants. Without HAVE_B64, these macros cannot
|
|
be used.
|
|
|
|
Changed the way zmath.h declares types such as HALF and FULL.
|
|
|
|
Changed the PRINT typedef.
|
|
|
|
The only place where the long long type might be used is in longlong.c
|
|
and if HAVE_LONGLONG, in longbits.h if it is needed. The only place
|
|
were a long long constant might be used is in longlong.c. Any
|
|
long long constants, if HAVE_LONGLONG, are hidden under the U(x) and
|
|
L(x) macros on longbits.h. And of course, if you don't have long long,
|
|
then HAVE_LONGLONG will NOT be defined and long long's will not be used.
|
|
|
|
The longlong.h file is no longer directly used by the main calc source.
|
|
It only comes into play when compiling the longbits tool.
|
|
|
|
Added config("prompt") to change the default interactive prompt ("> ")
|
|
and config("more") to change the default continuation prompt (">> ").
|
|
|
|
Makefile builds align32.h with determines if 32 bit values must always
|
|
be aligned on 32 bit boundaries.
|
|
|
|
The CALCBINDINGS file is searched for along the CALCPATH. The Makefile
|
|
defines the default CALCBINDINGS is "bindings" (or "altbind") which
|
|
is now usualy found in ./lib or ${LIBDIR}.
|
|
|
|
Per Ernest Bowen <ernie@neumann.une.edu.au>, an optional third argument
|
|
was added sqrt() so that in sqrt(x,y,z), y and z have essentially the
|
|
same role as in appr(x,y,z) except that of course what is being
|
|
approximated is the sqrt of x. Another difference is that two more
|
|
bits of z are used in sqrt: bit 5 gives the option of exact results
|
|
when they exist (the value of y is then ignored) and bit 6 returns
|
|
the nonprincipal root rather than the principal value.
|
|
|
|
If commands are given on the command line, leading tabs are not
|
|
printed in output. Giving a command on the command line implies
|
|
that config("tab",0) was given.
|
|
|
|
Pipe processing is enabled by use of -p. For example:
|
|
|
|
echo "print 2^21701-1, 2^23209-1" | calc -p | fizzbin
|
|
|
|
In pipe mode, calc does not prompt, does not print leading tabs
|
|
and does not print the initial version header.
|
|
|
|
Calc will now form FILE objects for any open file descriptor > 2
|
|
and < MAXFILES. Calc assumes they are available for reading
|
|
and writing. For example:
|
|
|
|
$ echo "A line of text in the file on descriptor 5" > datafile
|
|
$ calc 5<datafile
|
|
C-style arbitrary precision calculator (version 2.10.1t3)
|
|
[Type "exit" to exit, or "help" for help.]
|
|
|
|
> files(5)
|
|
FILE 5 "descriptor[5]" (unknown_mode, pos 0)
|
|
> fgetline(files(5))
|
|
"A line of text in the file on descriptor 5"
|
|
|
|
The -m mode flag now controls calc's ability to open files
|
|
and execute programs. This mode flag is a single digit that
|
|
is processed in a similar way as the octal chmod values:
|
|
|
|
0 do not open any file, do not execute progs
|
|
1 do not open any file
|
|
2 do not open files for reading, do not execute progs
|
|
3 do not open files for reading
|
|
4 do not open files for writing, do not execute progs
|
|
5 do not open files for writing
|
|
6 do not execute any program
|
|
7 allow everything (default mode)
|
|
|
|
Thus if one wished to run calc from a privledged user, one might
|
|
want to use -m 0 in an effort to make calc more secure.
|
|
|
|
The -m flags for reading and writing apply on open.
|
|
Files already open are not effected. Thus if one wanted to use
|
|
the -m 0 in an effort to make calc more secure, but still be
|
|
able to read and write a specific file, one might do:
|
|
|
|
calc -m 0 3<a.file 4>b.file
|
|
|
|
NOTE: Files presented to calc in this way are opened in an unknown
|
|
mode. Calc will try to read or write them if directed.
|
|
|
|
The maximum command line size it MAXCMD (16384) bytes. Calc objects to
|
|
command lines that are longer.
|
|
|
|
The -u flag cause calc to unbuffer stdin and stdout.
|
|
|
|
Added more help files. Improved other help files.
|
|
|
|
Removed trailing blanks from files.
|
|
|
|
Removed or rewrite the formally gross and disgusting hacks for
|
|
dealing with various sizes and byte sex FILEPOS and off_t types.
|
|
|
|
Defined ilog2(x), ilog10(x), ilog(x,y) so that sign of x is ignored,
|
|
e.g. ilog2(x) = ilog2(abs(x)).
|
|
|
|
The sixth bit of rnd in config("round", rnd) and config("bround", rnd)
|
|
is used to specify rounding to the given number of significant
|
|
digits or bits rather than places, e.g. round(.00238, 2, 32)
|
|
returns .0023, round(.00238, 2, 56) returns .0024.
|
|
|
|
Following is the change from calc version 2.9.3t11 to 2.10.0t12:
|
|
|
|
The default ${LIBDIR}/bindings CALCBINDINGS uses ^D for editing.
|
|
The alternate CALCBINDINGS ${LIBDIR}/altbind uses ^D for EOF.
|
|
|
|
The Makefile CC flag system has been changed. The new CC flag system
|
|
includes:
|
|
|
|
CCMAIN are flags for ${CC} when compiling only files with main()
|
|
CCOPT are flags given to ${CC} for optimization
|
|
CCWARN are flags given to ${CC} for warning message control
|
|
CCMISC are misc flags given to ${CC}
|
|
|
|
CNOWARN are all flags given to ${CC} except ${CCWARN} flags
|
|
CFLAGS are all flags given to ${CC}
|
|
ICFLAGS are given to ${CC} for intermediate progs
|
|
|
|
LCFLAGS are CC-style flags for ${LINT}
|
|
LDFLAGS are flags given to ${CC} for linking .o files
|
|
ILDFLAGS are given to ${CC} for linking .o's for intermediate progs
|
|
|
|
CC is how the the C compiler is invoked
|
|
|
|
The syntax error:
|
|
|
|
print a[3][[4]]
|
|
|
|
used to send calc into a loop printing 'missing expression'. This
|
|
has been fixed.
|
|
|
|
Added config("maxerr") and config("maxerr",val) to control the
|
|
maximum number of errors before a computation is aborted.
|
|
|
|
Removed regress.cal test #952 and #953 in case calc's stdout or
|
|
stderr is re-directed to a non-file by some test suite.
|
|
|
|
Changed how <stdarg.h>, <varags.h> or simulate stdarg is determined.
|
|
Changed how vsprintf() vs sprintf() is determined. The args.h file
|
|
is created by Makefile to test which combination works. Setting
|
|
VARARG and/or HAVE_VSPRINTF in the Makefile will alter these tests
|
|
and direct a specific combination to be used. Removed have_vs.c,
|
|
std_arg.h and try_stdarg.c. Added have_stdvs.c and have_varvs.c.
|
|
|
|
Added 3rd optional arg to round(), bround(), appr() to specify the type of
|
|
rounding to be used.
|
|
|
|
Moved fnvhash.c to quickhash.c.
|
|
|
|
Fixed a bug in appr rounding mode when >= 16.
|
|
|
|
Added test2600.cal and test2700.cal. They are used by the regress.cal
|
|
to provide a more extensive test suite for some builtin numeric
|
|
functions.
|
|
|
|
Following is the change from calc version 2.9.3t9.2+ to 2.9.3t10:
|
|
|
|
Added many help files for builtin functions and some symbols.
|
|
More help files are needed, see help/todo.
|
|
|
|
Removed the calc malloc code. Calc now uses malloc and free to
|
|
manage storage since these implementations are often written to
|
|
work best for the local system. Removed CALC_MALLOC code and
|
|
Makefile symbol. Removed alloc.c.
|
|
|
|
Added getenv("name"), putenv("name=val") and putenv("name, "val")
|
|
builts for environment variable support thanks to "Dr." "D.J." Picton
|
|
<dave@aps2.ph.bham.ac.uk>.
|
|
|
|
Added system("shell command") builtin to execute shell commands,
|
|
thanks to "Dr." "D.J." Picton <dave@aps2.ph.bham.ac.uk>.
|
|
|
|
Added isatty(fd) builtin to determine if fd is attached to a tty
|
|
thanks to "Dr." "D.J." Picton <dave@aps2.ph.bham.ac.uk>.
|
|
|
|
Added cmdbuf() builtin to return the command line executed by calc's
|
|
command line args thanks to "Dr." "D.J." Picton <dave@aps2.ph.bham.ac.uk>.
|
|
|
|
Added strpos(str1,str2) builtin to determine the first position where
|
|
str2 is found in str1 thanks to "Dr." "D.J." Picton
|
|
<dave@aps2.ph.bham.ac.uk>.
|
|
|
|
Fixed bug that caused:
|
|
|
|
global a,b,c (newline with no semicolon)
|
|
read test.cal
|
|
|
|
the read command to not be recognized.
|
|
|
|
The show command looks at only the first 4 chars of the argument so
|
|
that:
|
|
|
|
show globals
|
|
show global
|
|
show glob
|
|
|
|
do the same thing.
|
|
|
|
Added show config to print the config values and parameters thanks
|
|
to Ernest Bowen <ernie@neumann.une.edu.au>.
|
|
|
|
Added show objtypes to print the defined objects thanks to Ernest Bowen
|
|
<ernie@neumann.une.edu.au>.
|
|
|
|
Added more builtin function help files.
|
|
|
|
Fixed the 3rd arg usage of the root builtin.
|
|
|
|
Expanded the regress.cal regression test suite.
|
|
|
|
Fixed -- and ++ with respect to objects and asignment (see the 2300
|
|
series in regress.cal).
|
|
|
|
Added isident(m) to determine if m is an identity matrix.
|
|
|
|
The append(), insert() and push() builtins can now append between
|
|
1 to 100 values to a list.
|
|
|
|
Added reverse() and join() builtins to reverse and join lists
|
|
thanks to Ernest Bowen <ernie@neumann.une.edu.au>.
|
|
|
|
Added sort() builtin to sort lists thanks to Ernest Bowen
|
|
<ernie@neumann.une.edu.au>.
|
|
|
|
Added head(), segment() and tail() builtins to return the head, middle or
|
|
tail of lists thanks to Ernest Bowen <ernie@neumann.une.edu.au>.
|
|
|
|
Added more and fixed some help files.
|
|
|
|
The builtin help file is generated by the help makefile. Thus it will
|
|
reflect the actual calc builtin list instead of the last time someone
|
|
tried to update it correctly. :-)
|
|
|
|
Fixed non-standard void pointer usage.
|
|
|
|
Fixed base() bug with regards to the default base.
|
|
|
|
Renamed MATH_PROTO() and HIST_PROTO() to PROTO(). Moved PROTO()
|
|
into prototype.h.
|
|
|
|
Fixed many function prototypes. Calc does not declare functions
|
|
as static in one place and extern in another. Where reasonable
|
|
function prototypes were added. Several arg mismatch problems
|
|
were fixed.
|
|
|
|
Added support for SGI MIPSpro C compiler.
|
|
|
|
Changes the order that args are declared to match the order
|
|
of the function. Some source tools got confused when:
|
|
arg order did not match as in:
|
|
|
|
void
|
|
funct(foo,bar)
|
|
int bar; /* this caused a problem */
|
|
char *foo; /* even though it should not! */
|
|
{
|
|
}
|
|
|
|
Following is the change from calc version 2.9.3t8 to 2.9.3t9.2:
|
|
|
|
Use of the macro zisleone(z) has been clarified. The zisleone(z) macro
|
|
tests if z <= 1. The macro zisabsleone(z) tests of z is 1, 0 or -1.
|
|
Added zislezero(z) macro. Bugs are related to this confusion have
|
|
been fixed.
|
|
|
|
Added zge64b(z) macro to zmath.h.
|
|
|
|
Added the macro zgtmaxufull(z) to determine if z will fit into a FULL.
|
|
Added the macro zgtmaxlong(z) to determine if z will fit into a long.
|
|
Added the macro zgtmaxulong(z) to determine if z will fit into a unsigned
|
|
long.
|
|
|
|
Added the macro ztoulong(z) to convert an absolute value of a ZVALUE to
|
|
an unsigned long, or to convert the low order bits of a ZVALUE.
|
|
Added the macro ztolong(z) to convert an absolute value of a ZVALUE to
|
|
an long, or to convert the low order bits of a ZVALUE.
|
|
|
|
Some non-ANSI C compilers define __STDC__ to be 0, whereas all ANSI
|
|
C compiles define it as non-zero. Code that depends on ANSI C now
|
|
uses #if defined(__STDC__) && __STDC__ != 0.
|
|
|
|
Fixed ptest(a,b) bug where (a mod 2^32) < b. Previously ptest()
|
|
incorrectly returned 1 in certain cases.
|
|
|
|
The second ptest() argument, which is now optional, defaults to 1.
|
|
This ptest(x) is the same as ptest(x,1).
|
|
|
|
Added an optional 3rd argument to ptest(). The 3rd arg tells how many
|
|
tests to skip. Thus ptest(a,10) performs the same probabilistic
|
|
tests as ptest(a,3) and ptest(a,7,3).
|
|
|
|
The ptest() builtin by default will determine if a value is divisible
|
|
by a trivial prime. Thus, ptest(a,0) will only perform a quick trivial
|
|
factor check. If the test count is < 0, then this trivial factor check
|
|
is omitted. Thus ptest(a,10) performs the same amount of work as
|
|
ptest(a,3) and ptest(a,-7,3) and the same amount of work as
|
|
ptest(a,-3) and ptest(a,7,3).
|
|
|
|
Added nextcand(a[,b[,c]]) and prevcand(a[,b[,c]]) to search for the
|
|
next/previous value v > a (or v < a) that passes ptest(v[,b[,c]]).
|
|
The nextcand() and prevcand() builtins take the same arguments
|
|
as ptest().
|
|
|
|
Added nextprime(x) and and prevprime(x) return the next and
|
|
previous primes with respect to x respectively. As of this
|
|
release, x must be < 2^32. With one argument, they will return
|
|
an error if x is out of range. With two arguments, they will
|
|
not generate an error but instead will return y.
|
|
|
|
Fixed some memory leaks, particularly those related with pmod().
|
|
|
|
Fixed some of the array bounds reference problems in domult().
|
|
|
|
Added a hack-a-round fix for the uninitialized memory reference
|
|
problems in zsquare/dosquare.
|
|
|
|
The LIBRARY file has been updated to include a note about calling
|
|
zio_init() first. Also some additional useful macros have been noted.
|
|
|
|
The lfactor() function returns -1 when given a negative value.
|
|
It will not search for factors beyond 2^32 or 203280221 primes.
|
|
Performance of lfactor() has been improved.
|
|
|
|
Added factor(x,y) to look for the smallest factor < min(sqrt(x),y).
|
|
|
|
Added libcalcerr.a for a math_error() routine for the convince of
|
|
progs that make use of libcalc.a. This routine by default will
|
|
print an message on stderr and exit. It can also be made to
|
|
longjump instead. See the file LIBRARY under ERROR HANDING.
|
|
|
|
Added isprime() to test if a value is prime. As of this release,
|
|
isprime() is limited to values < 2^32. With one argument,
|
|
isprime(x) will return an error if x is out of range. With
|
|
two arguments, isprime(x,y) will not generate an error but
|
|
instead will return y.
|
|
|
|
Added pix(x) to return the number of primes <= x. As of this
|
|
release, x must be < 2^32. With one argument, pix(x) will
|
|
return an error if x is out of range. With two arguments,
|
|
pix(x,y) will not generate an error but instead will return y.
|
|
|
|
Fixed the way *.h files are formed. Each file guards against
|
|
multiple inclusion.
|
|
|
|
Fixed numeric I/O on 64 bit systems. Previously the print and
|
|
constant conversion routines assumed a base of 2^16.
|
|
|
|
Added support for 'long long' type. If the Makefile is setup
|
|
with 'LONGLONG_BITS=', then it will attempt to detect support
|
|
for the 'long long' type. If the Makefile is setup with
|
|
'LONGLONG_BITS=64', then a 64 bit 'long long' is assumed.
|
|
Currently, only 64 bit 'long long' type is supported.
|
|
Use of 'long long' allows one to double the size of the
|
|
internal base, making a number of computations much faster.
|
|
If the Makefile is setup with 'LONGLONG_BITS=0', then the
|
|
'long long' type will not be used, even if the compiler
|
|
supports it.
|
|
|
|
Fixed avg() so that it will correctly handle matrix arguments.
|
|
|
|
Fixed btrunc() limit.
|
|
|
|
The ord("string") function can now take a string of multiple
|
|
characters. However it still will only operate on the first
|
|
character.
|
|
|
|
Renamed stdarg.h to std_arg.h and endian.h endian_calc.h to
|
|
avoid name conflicts with /usr/include on some systems that
|
|
have make utilities that are too smart for their own good.
|
|
|
|
Added additive 55 shuffle generator functions rand(), randbits()
|
|
and its seed function srand(). Calling rand(a,b) produces a
|
|
random value over the open half interval [a,b). With one arg,
|
|
rand(a) is equivalent to rand(0,a). Calling rand() produces
|
|
64 random bits and is equivalent to rand(0,2^64).
|
|
|
|
Calling randbit(x>0) produces x random bits. Calling randbit(skip<0)
|
|
skips -skip bits and returns -skip.
|
|
|
|
The srand() function will return the current state. The call
|
|
srand(0) returns the initial state. Calling srand(x), where
|
|
x > 0 will seed the generator to a different state. Calling
|
|
srand(mat55) (mat55 is a matrix of integers at least 55 elements long)
|
|
will seed the internal table with the matrix elements mod 2^64.
|
|
Finally calling srand(state) where state is a generator state
|
|
also sets/seeds the generator.
|
|
|
|
The cryrand.cal library has been modified to use the builtin
|
|
rand() number generator. The output of this generator is
|
|
different from pervious versions of this generator because
|
|
the rand() builtin does not match the additive 55 / shuffle
|
|
generators from the old cryrand.cal file.
|
|
|
|
Added Makfile support for building BSD/386 releases.
|
|
|
|
The cmp() builtin can now compare complex values.
|
|
|
|
Added the errno() builtin to return the meaning of errno numbers.
|
|
|
|
Added fputc(), fputs(), fgets(), ftell(), fseek() builtins.
|
|
|
|
Added fsize() builtin to determine the size of an open file.
|
|
|
|
Supports systems where file positions and offsets are longer than 2^32
|
|
byte, longer than long and/or are not a simple type.
|
|
|
|
When a file file is printed, the file number is also printed:
|
|
|
|
FILE 3 "/etc/motd" (reading, pos 127)
|
|
|
|
Added matsum() to sum all numeric values in a matrix.
|
|
|
|
The following code now works, thanks to a fix by ernie@neumann.une.edu.au
|
|
(Ernest Bowen):
|
|
|
|
mat A[3] = {1, 2, 3};
|
|
A[0] = A;
|
|
print A[0];
|
|
|
|
Also thanks to ernie, calc can process compound expressions
|
|
such as 1 ? 2 ? 3 : 4 : 5.
|
|
|
|
Also^2 thanks to ernie, the = operator is more general:
|
|
|
|
(a = 3) = 4 (same as a = 3; a = 4)
|
|
(a += 3) *= 4 (same as a += 3; a *= 4)
|
|
matfill(B = A, 4) (same as B = A; matfill(B, 4);)
|
|
|
|
Also^3 thanks to ernie, the ++ and -- operators are more general.
|
|
|
|
a = 3
|
|
++(b = a) (a == 3, b == 4)
|
|
++++a (a == 5)
|
|
(++a)++ == 6 (a == 7)
|
|
(++a) *= b (a == 32, b == 4)
|
|
|
|
Fixed a bug related to calling epsilon(variable) thanks to ernie.
|
|
|
|
Removed trailing whitespace from source and help files.
|
|
|
|
Some compilers do not support the const type. The file have_const.h,
|
|
which is built from have_const.c will determine if we can or should
|
|
use const. See the Makefile for details.
|
|
|
|
Some systems do not have uid_t. The file have_uid_t.h, which is
|
|
built from have_uid_t.c will determine if we can or should depend
|
|
on uid_t being typefed by the system include files. See the Makefile
|
|
for details.
|
|
|
|
Some systems do not have memcpy(), memset() and strchr(). The
|
|
file have_newstr.h, which is built from have_newstr.c will
|
|
determine if we can or should depend libc providing these
|
|
functions. See the Makefile for details.
|
|
|
|
The Makefile symbol DONT_HAVE_VSPRINTF is now called HAVE_VSPRINTF.
|
|
The file have_vs.h, which is built from have_vs.c will determine if
|
|
we can or should depend libc providing vsprintf(). See the Makefile
|
|
for details.
|
|
|
|
Removed UID_T and OLD_BSD symbols from the Makefile.
|
|
|
|
A make all of the upper level Makefile will cause the all rule
|
|
of the lib and help subdirs to be made as well.
|
|
|
|
Fixed bug where reserved keyword used as symbol name caused a core dump.
|
|
|
|
Following is the change from calc version 2.9.3t7 to 2.9.3t7:
|
|
|
|
WARNING: This patch is an beta test patch by chongo@toad.com
|
|
(Landon Curt Noll).
|
|
|
|
The 'show' command by itself will issue an error message
|
|
that will remind one of the possible show arguments.
|
|
(thanks to Ha S. Lam <hl@kuhep4.phsx.ukans.edu>)
|
|
|
|
Fixed an ANSI-C related problem with the use of stringindex()
|
|
by the show command. ANSI-C interprets "bar\0foo..." as if
|
|
it were "bar\017oo...".
|
|
|
|
Added a cd command to change the current directory.
|
|
(thanks to Ha S. Lam <hl@kuhep4.phsx.ukans.edu>)
|
|
|
|
Calc will not output the initial version string, startup
|
|
message and command prompt if stdin is not a tty. Thus
|
|
the shell command:
|
|
|
|
echo "fact(100)" | calc
|
|
|
|
only prints the result. (thanks to Ha S. Lam <hl@kuhep4.phsx.ukans.edu>)
|
|
|
|
The zmath.h macro zisbig() macro was replaced with zlt16b(),
|
|
zge24b(), zge31b(), zge32b() and zgtmaxfull() which are
|
|
independent of word size.
|
|
|
|
The 'too large' limit for factorial operations (e.g., fact, pfact,
|
|
lcmfact, perm and comb) is now 2^24. Previously it depended on the
|
|
word size which in the case of 64 bit systems was way too large.
|
|
|
|
The 'too large' limit for exponentiation, bit position (isset,
|
|
digit, ), matrix operations (size, index, creation), scaling,
|
|
shifting, rounding and computing a Fibonacci number is 2^31.
|
|
For example, one cannot raise a number by a power >= 2^31.
|
|
One cannot test for a bit position >= 2^31. One cannot round
|
|
a value to 2^31 decimal digit places. One cannot compute
|
|
the Fibonacci number F(2^31).
|
|
|
|
Andy Fingerhut <jaf@dworkin.wustl.edu> (thanks!) supplied a fix to
|
|
a subtle bug in the code generation routines. The basic problem was
|
|
that addop() is sometimes used to add a label to the opcode table
|
|
of a function. The addop() function did some optimization tricks,
|
|
and if one of these labels happens to be an opcode that triggers
|
|
optimization, incorrect opcodes were generated.
|
|
|
|
Added utoz(), ztou() to zmath.c, and utoq(), qtou() to qmath.c
|
|
in preparation for 2.9.3t9 mods.
|
|
|
|
Following is the change from calc version 2.9.2 to 2.9.3t7:
|
|
|
|
WARNING: This patch is an beta test patch by chongo@toad.com
|
|
(Landon Curt Noll).
|
|
|
|
Calc can now compile on OSF/1, SGI and IBM RS6000 systems.
|
|
|
|
A number of systems that have both <varargs.h> and <stdarg.h> do
|
|
not correctly implement both types. On some System V, MIPS and DEC
|
|
systems, vsprintf() and <stdarg.h> do not mix. While calc will
|
|
pass the regression test, use of undefined variables will cause
|
|
problems. The Makefile has been modified to look for this problem
|
|
and work around it.
|
|
|
|
Added randmprime.cal which find a prime of the form h*2^n-1 >= 2^x
|
|
for some given x. The initial search points for 'h' and 'n'
|
|
are selected by a cryptographic pseudo-random generator.
|
|
|
|
The library script nextprim.cal is now a link to nextprime.cal.
|
|
The lib/Makefile will take care of this link and install.
|
|
|
|
The show command now takes singular forms. For example, the
|
|
command 'show builtin' does the same as 'show builtins'. This
|
|
allows show to match the historic singular names used in
|
|
the help system.
|
|
|
|
Synced 'show builtin' output with 'help builtin' output.
|
|
|
|
Fixed the ilog2() builtin. Previously ilog2(2^-20) returned
|
|
-21 instead of -20.
|
|
|
|
The internal function qprecision() has been fixed. The changes
|
|
ensure that for any e for which 0 < e <= 1:
|
|
|
|
1/4 < sup(abs(appr(x,e) - x))/e <= 1/2.
|
|
|
|
Here 'sup' denotes the supremum or least upper bound over values of x.
|
|
Previousld calc did: 1/4 <= sup(abs(appr(x,e) - x))/e < 1.
|
|
|
|
Certain 64 bit processors such as the Alpha are now supported.
|
|
|
|
Added -once to the READ command. The command:
|
|
|
|
read -once filename
|
|
|
|
like the regular READ expect that it will ignore filename if
|
|
is has been previously read.
|
|
|
|
Improved the makefile. One now can select the compiler type. The
|
|
make dependency lines are now simple foo.o: bar.h lines. While
|
|
this makes for a longer list, it is easier to maintain and will
|
|
make future Makefile patches smaller. Added special options for
|
|
gcc version 1 & 2, and for cc on RS6000 systems.
|
|
|
|
Calc compiles cleanly under the watchful eye of gcc version 2.4.5
|
|
with the exception of warnings about 'aggregate has a partly
|
|
bracketed initializer'. (gcc v2 should allow you to disable
|
|
this type of warning with using -Wall)
|
|
|
|
Fixed a longjmp bug that clobbered a local variable in main().
|
|
|
|
Fixed a number of cases where local variables or malloced storage was
|
|
being used before being set.
|
|
|
|
Fixed a number of fence post errors resulting in reads or writes
|
|
just outside of malloced storage.
|
|
|
|
A certain parallel processor optimizer would give up on
|
|
code in cases where math_error() was called. The obscure
|
|
work-a-rounds involved initializing or making static, certain
|
|
local variables.
|
|
|
|
The cryrand.cal library has been improved. Due to the way
|
|
the initial quadratic residues are selected, the random numbers
|
|
produced differ from previous versions.
|
|
|
|
The printing of a leading '~' on rounded values is now a config
|
|
option. By default, tilde is still printed. See help/config for
|
|
details.
|
|
|
|
The builtin function base() may be used to set the output mode or
|
|
base. Calling base(16) is a convenient shorthand for typing
|
|
config("mode","hex"). See help/builtin.
|
|
|
|
The printing of a leading tab is now a config option. This does not
|
|
alter the format of functions such as print or printf. By default,
|
|
a tab is printed. See help/config for details.
|
|
|
|
The value atan2(0,0) now returns 0 value in conformance with
|
|
the 4.3BSD ANSI/IEEE 754-1985 math library.
|
|
|
|
For all values of x, x^0 yields 1. The major change here is
|
|
that 0^0 yields 1 instead of an error.
|
|
|
|
Fixed gcd() bug that caused gcd(2,3,1/2) to ignore the 1/2 arg.
|
|
|
|
Fixed ltol() rounding so that exact results are returned, similar
|
|
to the way sqrt() and hypot() round, when they exist.
|
|
|
|
Fixed a bug involving ilog2().
|
|
|
|
Fixed quomod(a,b,c,d) to give correct value for d when a is between
|
|
0 and -b.
|
|
|
|
Fixed hmean() to perform the necessary multiplication by the number of
|
|
arguments.
|
|
|
|
The file help/full is now being built.
|
|
|
|
The man page is not installed by default. One may install either
|
|
the man page source or the cat (formatted man) page. See the
|
|
Makefile for details.
|
|
|
|
Added a quit binding. The file lib/bindings2 shows how this new
|
|
binding may be used.
|
|
|
|
One can now do a 'make check' to run the calc regression test
|
|
within in the source tree.
|
|
|
|
The regression test code is now more extensive.
|
|
|
|
Updated the help/todo list. A BUGS file was added. Volunteers are
|
|
welcome to send in patches!
|
|
|
|
Following is the change from calc version 2.9.1 to 2.9.1:
|
|
|
|
Fixed floor() for values -1 < x < 0.
|
|
|
|
Fixed ceil() for values -1 < x < 0.
|
|
|
|
Fixed frac() for values < 0 so that int(x) + frac(x) == x.
|
|
|
|
Fixed wild fetch bug in zdiv, zquo and zmod code.
|
|
|
|
Fixed bug which caused regression test #719 to fail on some machines.
|
|
|
|
Added more regression test code.
|
|
|
|
Following is the change from calc version 2.9.0 to 2.9.0:
|
|
|
|
A major bug was fixed in subtracting two numbers when the first
|
|
number was zero. The problem caused wrong answers and core dumps.
|
|
|
|
Following is a list of visible changes to calc from version 1.27.0 to 2.8.0:
|
|
|
|
Full prototypes have been provided for all C functions, and are used
|
|
if calc is compiled with an ANSI compiler.
|
|
|
|
Newly defined variables are now initialized to the value of zero instead
|
|
of to the null value. The elements of new objects are also initialized
|
|
to the value of zero instead of null.
|
|
|
|
The gcd, lcm, and ismult functions now work for fractional values.
|
|
|
|
A major bug in the // division for fractions with a negative divisor
|
|
was fixed.
|
|
|
|
A major bug in the calculation of ln for small values was fixed.
|
|
|
|
A major bug in the calculation of the ln and power functions for complex
|
|
numbers was fixed.
|
|
|
|
A major lack of precision for sin and tan for small values was fixed.
|
|
|
|
A major lack of precision for complex square roots was fixed.
|
|
|
|
The "static" keyword has been implemented for variables. So permanent
|
|
variables can be defined to have either file scope or function scope.
|
|
|
|
Initialization of variables during their declaration are now allowed.
|
|
This is most convenient for the initialization of static variables.
|
|
|
|
The matrix definition statement can now be used within a declaration
|
|
statement, to immediately define a variable as a matrix.
|
|
|
|
Initializations of the elements of matrices are now allowed. One-
|
|
dimensional matrices may have implicit bounds when initialization is
|
|
used.
|
|
|
|
The obj definition statement can now be used within a declaration
|
|
statement, to immediately define a variable as an object.
|
|
|
|
Object definitions can be repeated as long as they are exactly the same
|
|
as the previous definition. This allows the rereading of files which
|
|
happen to define objects.
|
|
|
|
The integer, rational, and complex routines have been made into a
|
|
'libcalc.a' library so that they can be used in other programs besides
|
|
the calculator. The "math.h" include file has been split into three
|
|
include files: "zmath.h", "qmath.h", and "cmath.h".
|
|
|
|
Following is a list of visible changes to calc from version 1.26.4 to 1.26.4:
|
|
|
|
Added an assoc function to return a new type of value called an
|
|
association. Such values are indexed by one or more arbitrary values.
|
|
They are stored in a hash table for quick access.
|
|
|
|
Added a hash() function which accepts one or more values and returns
|
|
a quickly calculated small non-negative hash value for those values.
|
|
|
|
Following is a list of visible changes to calc from version 1.26.2 to 1.26.4:
|
|
|
|
Misc fixes to Makefiles.
|
|
|
|
Misc lint fixes.
|
|
|
|
Misc portability fixes.
|
|
|
|
Misc typo and working fixes to comments, help files and the man page.
|
|
|
|
Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
|
|
|
|
There is a new emacs-like command line editing and edit history
|
|
feature. The old history mechanism has been removed. The key
|
|
bindings for the new editing commands are slightly configurable
|
|
since they are read in from an initialization file. This file is
|
|
usually called /usr/lib/calc/bindings, but can be changed by the
|
|
CALCBINDINGS environment variable. All editing code is
|
|
self-contained in the new files hist.c and hist.h, which can be
|
|
easily extracted and used in other programs.
|
|
|
|
Two new library files have been added: chrem.cal and cryrand.cal.
|
|
The first of these solves the chinese remainder problem for a set
|
|
of modulos and remainders. The second of these implements several
|
|
very good random number generators for large numbers.
|
|
|
|
A small bug which allowed division by zero was fixed.
|
|
|
|
A major bug in the mattrans function was fixed.
|
|
|
|
A major bug in the acos function for negative arguments was fixed.
|
|
|
|
A major bug in the strprintf function when objects were being printed
|
|
was fixed.
|
|
|
|
A small bug in the library file regress.cal was fixed.
|