1 The following are the changes from calc version 2.12.4.6 to date:
3 Updated RPM build process to remove use of deprecated flags.
5 Applied a number of fixes to calc.spec and rpm.mk file.
6 See calc.spec.in for details. Changed rpm release to 2.1.
8 Set MACOSX_DEPLOYMENT_TARGET=10.8 as we upgraded all of
9 our development Mac OS X to 10.8.
11 Libraries are chmodded as 0644 to allow for building rpms
14 Silenced annoying warning about unused variable 'intp'
15 while compiline endian.c under some circumstances.
17 Fixed typo in redeclaration warnings. Thanks to
18 Christoph Zurnieden <czurnieden at gmx dot de> for this report.
20 Added a number of calc resource files by
21 Christoph Zurnieden <czurnieden at gmx dot de> including:
23 bernpoly.cal - Computes the nth Bernoulli polynomial at z for any n,z
24 brentsolve.cal - root-finder implementwed with the Brent-Dekker trick
25 factorial.cal - product of the positive integers
26 factorial2.cal - variety of integer functions quasi-related to factoral
27 lambertw.cal - Computes Lambert's W-function at "z" at branch "branch"
28 lnseries.cal - Calculates a series of natural logarithms at 1,2,3,4...n
29 specialfunctions.cal - Calculates the value of the beta function
30 statistics.cal - a wide vareity of stastical functions
31 toomcook.cal - Multiply by way of the Toom-Cook algorithm
32 zeta2.cal - Calculate the value of the Hurwitz Zeta function
34 Fixed a makefile bug that prevented the those new calc resource
35 files from being installed.
37 Improved the formatting of the output from:
41 We replaced COPYING-LGPL with the version that is found at
42 http://www.gnu.org/licenses/lgpl-2.1.txt because that version
43 contans some whitespace formatting cleanup. Otherwise the
46 We fixed a number of places where "the the" was used
47 when just "the" should be used.
49 NOTE: Fixes to grammar, spelling and minor formatting
50 problems are welcome. Please send us your patches!
52 With the exception of 3 source files, we became "picky" about
53 line lengths and other issues reported by the picky tool:
59 The above 3 files now pass picky -w (OK except for line length).
60 For more information about the picky tool, see:
62 http://cis.csuohio.edu/~somos/picky.html
65 The following are the changes from calc version 2.12.4.3 to 2.12.4.5:
67 Added gvec.cal resource script.
69 Added calc-symlink make rule to setup symlinks from stardard locations
70 into a tree specified by a non-empty ${T} makefile variable. Added
71 calc-unsymlink to remove any symlinks that may have been created by
72 the calc-symlink rule.
74 If is OK for the calc-symlink make rule to pre-remove a symlink.
76 Fixed bug was uncovered in calc that caused script failures when calc
77 is called within a while loop in BASH if the while loop is fed from
78 stdin due to calc's redirection/inheritance of stdin and no option
79 to change this behavior. Thanks gores to David C. Rankin
80 <drankinatty at gmail dot com> for the bug fix and to David Haller
81 <dnh at opensuse dot org> for helping debug this problem.
84 The following are the changes from calc version 2.12.4.0 to 2.12.4.2:
86 Fixed a documentation bug for the sgn() builtin.
88 Added the 1<<8/2 evaluation example to "help unexpected". That
89 expression evalutes to 128, not 16 as some C programmers might expect.
91 Fixed a bug in solve.cal where high was not returned in some situations.
93 Fixed a bug reported by Paul & Karen Tomlinson (paulnkaz at pktomlinson
94 dot fsnet dot co dot uk) where calling log multiple times with different
95 values of epsilon resulted in an incorrect value.
97 Removed cvd rule from Makefiles.
99 The Makefile used in the source rpm (calc-*.src.rpm) no longer uses
100 the -Werror compile flag. This is to help those distributions with
101 compilers that make produce (hopefully) complination warnings.
102 NOTE: For testing and calc build purposes will recommend and will
103 continue to use the -Werror flag.
105 Fixed a typo in the Makefile where the make variable ${SAMPLE_OBJ}
106 was misspelled as ${SAMPLE_OBJS}.
108 Added prep makefile rule to make is easier to compile calc without
109 an optimizer. By doing:
113 one may build a calc binary that is easier to debug.
115 Fixed a bug where an certains typos (e.g., calling an unknown
116 function) would previously cause calc to exit.
118 Updated the COPYING file to reflect the new filenames associated
119 with the SHA1 hash function, and removed mention of files related
120 to the SHA (SHA0, not SHA1) and the MD5 hash functions (which is
121 no longer supported in calc).
123 Fixed a bug where a calling vsnprintf() twice created problems.
124 The thanks for this fix goes to Matthew Miller (mattdm at mattdm
125 dot org) for this patch.
127 Michael Penk (mpenk at wuska dot com) reported success in installs
128 under windoz via Cygwin by making a change to the Cygwin target.
129 These changes have been folded into the main calc Makefile.
130 The old recommendation of using 'make win32_hsrc' is no longer
131 required for Cygwin. See the README.WINDOWS file for details.
133 Added dms.cal and hms.cal resource files. The dms.cal is a more
134 functional version of deg.cal. It is a superset except that increment
135 and decrement is on the arc second level. The hms.cal is for
136 24-hour cycle instread of the 360 degree cycle of dms.cal.
138 Changed deg.cal object name from dms to deg so that the more functional
139 dms.cal can own the dms object name.
141 Updated 'help obj' to reflect changes to 'show objfunctions' and
142 resource file example list since 1999.
144 Fixed problem where CALC_BYTE_ORDER refering to CALC_BIG_ENDIAN
145 and CALC_LITTLE_ENDIAN instead of BIG_ENDIAN and LITTLE_ENDIAN.
148 The following are the changes from calc version 2.12.3.0 to 2.12.3.3:
150 Fixed the Jacobi function where it returned 1 when it should have
151 returned 0. Thanks goes to Kevin Sopp (baraclese at googlemail dot com)
152 for discovering the problem and suggesting the nature if the fix.
154 Calc versions will always be of the form x.y.z.w even when the
155 MINOR_PATCH (w) is 0. Thus, 2.12.3.0 will be printed as 2.12.3.0
156 instread of just 2.12.3.
158 Added MINGW32_NT-5.0 compile target based on a patch from
159 Brian L. Angus (angus at eng dot utah dot edu).
161 Removed the use of rpm.release in the Makefile.
163 Mac OS Darwin targets no longer attempt to use ldconfig. Under the
164 Darwin target, the LDCONFIG make variable is redefined to be
165 an empty value. Thanks goes to Ralf Trinler (art at infra dot de)
166 for reporting this problem.
168 The ${CALC_INCDIR}/custom is no longer being removed at install time
169 if it is empty. Now when ${ALLOW_CUSTOM} make variable is empty,
170 an empty ${CALC_INCDIR}/custom may be left hehind.
172 Fixed a problem where a "make clobber" would remove custom/Makefile
173 and fail to rebuilt it.
176 The following are the changes from calc version 2.12.2.3 to 2.12.2.4:
178 Added OpenBSD target.
180 Using the -r test instead of the -e test in Makefiles because some
181 out of date shells still do not have the -e test.
183 The Makefile now avoids the use of if ! command because some out of
184 date shells to not support the ! construct.
187 The following are the changes from calc version 2.12.1.1 to 2.12.2.2:
189 Added an explicit Solaris target.
191 Fixed confusion in Makefile where some uses of ${EXT} were misnamed ${EXE}.
193 Added a "make strip" rule, per suggestion from Igor Furlan <primorec
194 at sbcglobal dot net>, to allow one to strip previously built binary
195 executables and libraries.
197 Under the Darwin / OS X target, ${DARWIN_ARCH} is left empty meaning
198 that calc is compiled for the native CPU type instead of Universal
199 Binary (Intel and PPC).
201 By default, the calc binary that is built for the rpm forces
202 ${LD_SHARE} to be empty. An empty ${LD_SHARE} means that the calc
203 from the rpm does not set rpath. This in turn causes the default
204 system path to be searched when looking for libcalc and libcustcalc.
206 The Makefile shipped with calc still sets ${LD_SHARE} for host targets.
207 By default, the dynamic shared library search path for all targets
208 starts with the source directory. Starting the search in the source
209 directory is convenient for testing and debugging but is not appropriate
210 for installation on a production system. To get the same effect
211 as the calc binary in the calc rpm, try:
214 make calc-dynamic-only BLD_TYPE=calc-dynamic-only LD_SHARE=
217 The libcalc and libcustcalc shared libraries are now tied to
218 the 4 level calc version instead of just 3 levels. For example,
219 under Linux calc version 2.12.2.1 uses /usr/lib/libcalc.so.2.12.2.1
220 instead of just the /usr/lib/libcalc.so.2.12.2 file. This change
221 was made so that calc produced by 'make clobber; make all install'
222 is consistent with the calc rpm.
224 Calc is now releasing the calc-debuginfo rpm for those RPM users who
225 which to use non-stripped libraries and binaries for debugging
226 purposes. By default, the calc rpm installed stripped binaries
229 Added this high priority item to the calc help/todo list:
231 It is overkill to have nearly everything wind up in libcalc.
232 Form a libcalcmath and a libcalclang so that an application
233 that just wants to link with the calc math libs can use them
234 without dragging in all of the other calc language, I/O,
235 and builtin functions.
237 Fixed the wording for the -i flag in the calc man page.
239 Added some notes to the help/unexpected file regarding calc
240 and interactice shells.
242 Fixed bug where a FILEPOS was copied FPOS_POS_BITS octets instead of
245 Split out ${READLINE_EXTRAS} Makefile variables from ${READLINE_LIB}
246 to better deal with Fedora rpm requirements.
248 Bit 8 (0x80) of calc_debug is reserved for custom debugging.
249 See help/config and custom/HOW_TO_ADD for details.
251 When the Makefile variable ${ALLOW_CUSTOM} is not defined or empty,
252 the libcustcalc library is not built or linked against, certain make
253 rules skip going into the custom sub-directory, the install
254 rule skips certain custom installation actions, and the common
255 C flags (${COMMON_CFLAGS}) is given -UCUSTOM. Other make rules such
256 as "make clean" and "make clobber" still work as before. Also
257 the Makefile.simple assumes that the Makefile variable ${ALLOW_CUSTOM}
260 Clarified that the calc builtin functions rand() and random()
261 operate over a half closed interval. The help/rand and help/random
262 refer to the top of the interval as "beyond" instead of "max".
264 Releaseing source tar balls using bzip2 instead of with gzip. So
265 what was calc-something.tar.gz is now calc-something.tar.bz2.
268 bunzip2 calc-something.tar.bz2
270 On some systems, one may untar directly by:
272 tar -jxvf calc-something.tar.bz2
274 The Makefile variable ${BYTE_ORDER} was replaced by ${CALC_BYTE_ORDER}.
276 Changed the way the Makefile can force the calc byte order. If you set
277 the Makefile variable ${CALC_BYTE_ORDER} to be -DCALC_BIG_ENDIAN then
278 endian.h will force the CPP symbol CALC_BYTE_ORDER to be BIG_ENDIAN.
279 If you set ${CALC_BYTE_ORDER} to be -DCALC_LITTLE_ENDIAN then endian.h
280 will force the CPP symbol CALC_BYTE_ORDER to be LITTLE_ENDIAN.
281 If the Makefile variable ${CALC_BYTE_ORDER} is empty, then the CPP
282 symbol CALC_BYTE_ORDER will set to the CPP symbol BYTE_ORDER as
283 defined by some system include file (if the Makefile can find such
284 an include file), or the Makefile compiling endian.c and hopefully
285 using that result to set CPP symbol CALC_BYTE_ORDER. Regardless of
286 how it happens, the CPP symbol CALC_BYTE_ORDER should end up set in
287 endian_calc.h include file.
290 The following are the changes from calc version 2.12.1.10 to 2.12.2:
292 Put back the missing -s flags on the cscripts: mersenne, 4dsphere,
293 fprodcut, plus, and powerterm. Thanks goes to Bradley Reed
294 <bradreed1 at gmail dot com> for discovering this problem.
296 All static variables are now declared with the symbol STATIC.
297 All extern variables are now declared with the symbol EXTERN.
298 All static functions are now declared with the symbol S_FUNC.
299 All extern functions are now declared with the symbol E_FUNC.
300 The include file decl.h defines these 4 symbols by default
301 to static, extern, static, and extern respectively. Under
302 Windoz, DLL is also defined according to the _EXPORTING symbol
303 and is prepended to the EXTERN and E_FUNC symbols. The decl.h
304 file has replaced the win32dll.h file.
306 When WITH_TLS is defined, calc attempts to compile with Thread Local
307 Storage. As of version 2.12.1.12 this mode is extremely experimental.
308 Calc may not compile when WITH_TLS defined.
310 Fixed E_FUNC vs EXTERN issues discovered by Mirko Viviani
311 <mirko at objectlab dot org>.
313 Removed include of <malloc.h>. The building of the include file
314 "have_malloc.h" has been removed from the Makefile. One some
315 systems such as FreeBSD, the file /usr/include/malloc.h exists
316 and contains an forced error saying that stdlib.h should be used
317 instead. The Makefile symbol HAVE_MALLOC has been removed.
319 Moved the sample code in the sample sub-directory up into the
320 main source level. The sample/many_random.c source file is
321 now sample_many.c. The sample/test_random.c source file is now
322 sample_rand.c. The sample Makefile and the sub-directory is no more.
324 Renamed the following source files:
326 math_error.h ==> lib_calc.h
330 Renamed the following variables related to calc error processing:
332 int calc_jmp ==> int calc_use_matherr_jmpbuf
333 jmp_buf calc_jmp_buf ==> jmp_buf calc_matherr_jmpbuf
335 int post_init ==> int calc_use_scanerr_jmpbuf
336 jmp_buf jmpbuf ==> jmpbuf calc_scanerr_jmpbuf
338 char *calc_error ==> char calc_err_msg[MAXERROR+1]
340 These values are now declared in the lib_calc.h include file.
341 The value MAXERROR is now defined in lib_calc.h instead of calc.h.
342 The calc_err_msg[] buffer is now used for math errors as well
343 as scan and parse errors.
345 Parse/scan errors will not be printed if calc_print_scanerr_msg
348 int calc_print_scanerr_msg = 1;
350 This variable is declared in the lib_calc.h include file. Storage
353 Parse/scan warnings will not be printed if calc_print_scanwarn_msg
356 int calc_print_scanwarn_msg = 1;
358 This variable is declared in the lib_calc.h include file. Storage
361 The last parse/scan error message is stored in the calc_err_msg[]
362 buffer. This happens even when calc_print_scanerr_msg is zero.
364 The last parse/scan warning message is stored in the calc_warn_msg[]
365 buffer. After each parse/scan warning condition is detected,
366 the value calc_warn_cnt is incremented. This happens even when
367 calc_print_scanwarn_msg is zero.
369 The calc_warn_msg[] buffer and calc_warn_cnt variables are declared
370 in the lib_calc.h include file. Storage comes from libcalc.
372 See the file, LIBRARY or use the calc command "help libcalc" for
373 more information on calc error processing. This file has been
374 updated to reflect the changes noted above in this section.
376 The make install rule removes std_arg.h, have_malloc.h, math_error.h,
377 string.h, and win32dll.h from ${INCDIR} if they exist. These calc
378 include files are no longer supported.
380 Do reduce the number of special case .o build rules, the
381 ${ALLOW_CUSTOM} make flag is added to ${CFLAGS} by default. This means
382 that if ALLOW_CUSTOM= -DCUSTOM, then -DCUSTOM is given to the compile
383 line of most .c files.
385 Calc -v reports "w/custom functions" or "w/o custom functions" on
386 the version string depending on if calc was compiled with the
387 ALLOW_CUSTOM= -DCUSTOM or not.
389 Replaced the concept of compiler sets in the Makefile with
390 host target section in the Makefile. Initial host targets are:
395 (default) <<== Target does not match any previous target name
398 NOTE: If your target is not supported below and the default target
399 is not suitable for your needs, please send to the:
401 calc-contrib at asthe dot com
403 EMail address an "ifeq ($(target),YOUR_TARGET_NAME)"
404 ... "endif" set of lines from the Makefile so that
405 we can consider them for the next release.
407 The custom/Makefile is now constructed from 3 parts: custom/Makefile.head,
408 the host target section in Makefile, and the custom/Makefile.tail.
410 The top level Makefile and the custom/Makefile require a GNU Make
411 (such as gmake) or an equivalently advanced make. On many targets,
412 the default make is sufficient. On FreeBSD for example, one must
413 use gmake instead of make.
415 If your target system does not have GNU Make (or equivalent), then
416 you should try using the Makefile.simple and custom/Makefile.simple
419 mv Makefile Makefile.gmake
420 cp Makefile.simple Makefile
421 mv custom/Makefile custom/Makefile.gmake
422 cp custom/Makefile.simple custom/Makefile
425 Added the ability to build calc with dynamic libraries, static
426 libraries or both. Many thanks goes to Matthew Miller (mattdm
427 at mattdm dot org) and Mirko Viviani (mirko at objectlab dot
428 org) for this help, encouragement, and testing of this major change!
430 Added BLD_TYPE Makefile variable to control how calc is
431 built. The BLD_TYPE value may be one of:
433 BLD_TYPE= calc-dynamic-only
434 BLD_TYPE= calc-static-only
436 Each host target establishes a default BLD_TYPE value. Of course
437 one can override the host target BLD_TYPE on the make command line:
440 make calc-dynamic-only BLD_TYPE=calc-dynamic-only
443 make calc-static-only BLD_TYPE=calc-static-only
445 NOTE: It is a very good idea to first clobber (remove) any previously
446 built .o, libs and executables before switching the build
447 between static and dynamic.
449 which have the same effect as make all with a given build phase set.
451 For Linux and Darwin, the default BLD_TYPE is calc-dynamic-only.
452 For the simple case, BLD_TYPE is calc-static-only. For the
453 default target (the target does not match any of the previous
454 defined targets), BLD_TYPE is calc-static-only.
456 Added ${CSFLAGS} make variable to hold the {$CC} flags for compiling
457 without shared library. By default, ${CFLAGS} is ${CSFLAGS} with
458 ${CC_SHARE} added to it.
460 Added ${CC_SHARE}, ${LIBCALC_SHLIB}, ${LIBCUSTCALC_SHLIB}, and
461 ${LD_SHARE} to the remaining compiler sets.
463 Fixed make depend and make uninstall rules. Performed various
464 makefile syntax cleanups.
466 Removed ${PROGS} and ${STATIC_PROGS} Makefile variables due to
467 the new BLD_TYPE system (see above).
469 Added missing help for cp, calcpath, and stoponerror.
471 Noted that calc fails the regression test (and will crash at
472 various times) when compiled with gcc v4.1.0. This problem was
473 first reported under Fedora Core 5 by Christian Siebert.
475 Set the LESSCHARSET to iso8859 so that less will not confuse or
476 upset the col utility with Invalid or incomplete multi-byte or wide
479 Updated the Free Software Foundation postal address and updated
480 the COPYING-LGPL from http://www.fsf.org/licensing/licenses/lgpl.txt
481 on 2007-Mar-14. Calc is using the same Version 2.1 of the LGPL,
482 only the postal address of the Free Software Foundation has
483 been updated. All source files were updated to RCS level 30.
484 Thanks goes to Martin Buck (m at rtin-buck dor de) for this patch.
486 Added printf arg checking for GNU C compilers that helps check
487 printf-style functions in calc. Thanks goes to Martin Buck (m at
488 rtin-buck dor de) for this patch.
490 Fixed issues where the argument of a printf-like did not match the
493 Removed build function md5(). The MD5 hash has been compromised to
494 such a degree that is it no longer advisable to use this function.
496 Removed build function sha(). The SHA hash has been compromised to
497 such a degree that is it no longer advisable to use this function.
498 Note that the SHA-1 hash has not been compromised to the same degree
499 and so this hash function remains.
501 Renamed shs1.c to sha1.c. Renamed shs1.h to sha1.h.
503 Added custom registers. The custom register function:
505 custom("register", 3)
507 returns the value of custom register 3. Custom registers, initialized
508 with 0, may take on any calc value:
510 custom("register", regnum, value)
512 Added REGNUM_MAX to the sysinfo custom function to return the maximum
515 custom("sysinfo", "REGNUM_MAX")
517 which defaults to 31. The first custom register is 0 and thus the
518 default number of custom registers is 32.
520 Added E_OK #define in calc.h to indicate no error (0).
522 Renamed C function powivalue() in value.c to powvalue() because it
523 now handles raising NUMBER or COMPLEX to a NUMBER or COMPLEX power.
525 The powervalue() function in value.c may be given a NULL epsilon
526 which will cause to the builtin epsilon value to be used.
528 Calc supports both real and complex exponentiation bases and exponents.
529 For a ^ b and a ** b, "a" and "b" can be a real value or a complex value:
532 2.5 ^ 3.5 0.5i ^ 0.25
533 2.5 ^ 2.718i 3.13145i ^ 0.30103i
535 Fixed typos in the calc man page thanks to a Debian bug report
536 by A. Costa <agcosta at gis dot .net> that wsa kindly forwarded
537 to us by Martin Buck <m at rtin-buck dot de>.
540 The following are the changes from calc version 2.12.1.8 to 2.12.1.9:
542 Fixed calc cscripts that contained comments that were not valid calc
543 comments. Improved calc comment documentation in "help unexpected"
544 to help other avoid similar mistakes. Calc comments are of the form:
546 /* c style comments */
551 ## two or more #-signs
553 ### Note that # along is a calc unary and binary operator
555 Added "help pound" or "help #' to document the # operator, comments,
556 and the first line of cscript files.
558 Documented these help commands in "help help":
567 The usage help file is now formed from the contents of the calc man page.
568 So "help usage" prints the version of the calc man page. Added ${COL}
569 makefile symbol to support the formation of the calc.usage file from
570 calc.1 via the CALCPAGER (less) or NROFF (if NROFF is non-empty).
572 The "help calc" command is now equivalent to "help help".
574 The "help define" command is now equivalent to "help command".
576 Fixed calc command line usage message.
578 Fixed missing README.src file in RPM src and tgz src tarball.
580 Removed HAVE_SNPRINTF test in version.c. We now assume that
581 all systems come with the standard snprintf() library function.
583 Make does not assume that DONT_HAVE_VSPRINTF must be defined in
584 order to test for varargs (via have_varvs.c). Instead it uses the
585 ${HAVE_VSPRINTF} to determine if the vsprintf() and vsnprintf()
586 should be tested to assumed to exist or not exist.
588 Tests for the existence of vsprintf() now also require the existence
589 of vsnprintf(). Test for the existence of vsnprintf() now also
590 require the existence of vsprintf().
592 The #define CALC_SIZE_T was never used except when memmove() was
593 not found. This symbol was renamed to MEMMOVE_SIZE_T. Calc
594 requires that size_t must be a known type.
596 Calc and cscripts are installed mode 0755 instead of 0555 to
599 Make clobber cleanup as suggested by Martin Buck <m at rtin-buck dot de>.
600 The clobber rule now depends on the clean rule.
603 The following are the changes from calc version 2.12.1.6 to 2.12.1.7:
605 Added the calc builtin function, usertime(), to return the amount of
606 user CPU time used by the current process. Unlike the old runtime()
607 builtin, the CPU time reported for long running processes will not
608 wrap around to 0 after only a few months.
610 Added the calc built0in function, systime(), to return the amount of
611 kernel CPU time used by the current process.
613 The runtime() builtin function now returns the total amount of CPU
614 time used by the current process. This time includes both user mode
615 and kernel mode time. Unlike the old runtime() builtin, the builtin
616 includes time spent executing operating system code on behalf of
619 Fixed runtime() so that the CPU time reported for long running
620 processes will wrap around to 0 for a long time.
622 Added config("hz") to return the clock tick rate. This is
623 a read-only configuration value.
625 Added regression tests for recently added config() parameters.
627 Fixed the #define symbols that were created in have_strdup.h.
628 Previously this file looked as if have_rusage.h has been
631 Restored the function of "help" (without any args) printing the
632 default help file. Thanks for this fix goes to Silvan Minghetti
633 <bullet at users dot sourceforge dot net>.
635 Fixed a problem where some old MS environments failed some of the
636 regression tests because "read -once foo.cal" was not behaving
637 correctly due to how the _fullpath() was being called. Thanks for
638 this fix goes to Anatoly <notexistent-anb at yandex dot ru>.
640 Documented the mis-feature about how calc parses if, for, while
641 and do statements in an unexpected way. For example:
643 This works as expected:
649 However this WILL NOT WORK AS EXPECTED:
656 because calc will parse the if being terminated by
657 an empty statement followed by a
664 See also "help statement", "help unexpected", "help todo", and
668 The following are the changes from calc version 2.12.1 to 2.12.1.5:
670 Fixed minor typos in the 'version 2.12.0 to 2.12.0.8' section below.
671 Made minor formatting changes as well.
673 Changed use of ${Q} in the Makefile to avoid an make "feature"
674 related to OpenBSD. Added ${RM} make variable for make tools that
675 do not have builtin defined terms.
677 Removed the ECHO_PROG Makefile variable. Also removed it from
678 the sysinfo() custom function.
680 Improved the support for cross-compiled environments by using
681 make symbols for all non-shell commands executed by Makefiles.
683 Fixed a problem with the make chk awk script which failed under
686 Fixed a few minor variables that were not set to default values in
687 lower level Makefiles.
689 Fixed a reference to a non-existent make variable in HOWTO.INSTALL.
692 The following are the changes from calc version 2.12.0 to 2.12.0.8:
694 Fixed ellip.cal to deal with a calc syntax change that happened
695 many ages ago but was never applied to this file until now.
696 This bug was fixed by Ernest Bowen <ebowen at une dot edu dot au>.
698 Fixed a problem where comments using # followed by a !, newline or
699 another # works. This bug was fixed by Ernest Bowen <ebowen at une
702 The show builtins display for functions with long descriptions
703 is now broken into multi-line descriptions.
705 The str functions, such as strcpy(s1, s2), will now copy as many
706 characters as possible from s2 to s1, treating '\0' like any other
707 character until the end of s2 is reached. If s2 is shorter than s1,
710 The strcmp(s1, s2) builtin, for strings s1, s2: strcmp(s1, s2) == 0 now
711 means the same as s1 == s2.
713 The str(s) builtin has been changed so that it will return only the
714 string formed by the characters of 's' up to the first '\0'.
716 The substr(s, start, num) builtin has been changed so that '\0' characters
717 are treated like any other.
719 Fixed a bug where strcpy("", "a") used to cause a segmentation fault.
720 This bug was fixed by Ernest Bowen <ebowen at une dot edu dot au>.
722 Make minor change to natnumset.cal in how the tail variable is initialized.
724 Fixed bugs in the strcmp, strncmp, strcpy, and strncpy help files.
725 This bug was fixed by Ernest Bowen <ebowen at une dot edu dot au>.
727 Added cal/screen.cal which Defines ANSI control sequences providing
728 (i.e., cursor movement, changing foreground or background color,
729 etc.) for VT100 terminals and terminal window emulators (i.e., xterm,
730 Apple OS/X Terminal, etc.) that support them. For example:
733 ; print green:"This is green. ":red:"This is red.":black
735 Fixed a bug where too many open files returned E_FOPEN3. Now
736 a new error symbol F_MANYOPEN is used for too many open files.
738 Added the builtin function fpathopen() to open a file while
739 searching along a path:
741 ; fd2 = fpathopen("tmp/date", "r", ".:~:~sc:/tmp:/var/tmp:/var")
745 By default, fpathopen() searches along CALCPATH.
747 Added the calcpath() builtin function to return the current value
750 Fixed prompt characters in the EXAMPLE section of help files.
752 Fixed problems related to the protect function and its documentation.
753 This bug was reported by David Gilham <davidgilham at gmail dot com>.
754 This bug was fixed by Ernest Bowen <ebowen at une dot edu dot au>.
756 Raised the limit of exponent in exponential notation. It was set to
757 arbitrary 1000000 (making 1e1000001 in invalid exponential notation
758 value). The exponent for exponential notation is now int(MAXLONG/10).
759 On 32 bit machines, this means a limit of 214748364. On 64 bit
760 machines, this means 922337203685477580. Of course, you may not
761 have enough memory to hold such huge values, but if you did you can
762 now express such values in exponential notation.
764 Added log() builtin for base 10 logarithm.
766 Fixed problems where internal use of libc strcpy() might have caused
767 a buffer overflow. Calc now only uses libc strcpy() when the source
768 string is a constant.
770 The calc STRING and STRINGHEAD now use the standard size_t (an unsigned
771 type) length. Calc mostly uses size_t in dealing with string lengths
772 and object sizes when possible.
774 Added ${CCWERR} make variable to allow one to force compiler warnings
775 to be treated as errors. The ${CC} make variable now uses ${CCWERR}
776 however the ${LCC} (used by the Makefile test code for building hsrc
777 files) does not use ${CCWERR}. By default, ${CCWERR} is empty.
778 In development Makefiles, we set CCWERR= -Werror to force us to
779 address compiler warnings before the next release.
781 The calc make variable, CALCPAGER, now defaults to CALCPAGER= less
782 because the less utility is now very common. Set CALCPAGER= more
783 if you do not have less.
785 Calc source had two styles of switch indentation. Converted the
786 style where case statements were indented with respect to the switch
787 statement into the style where the case statements are at the same
788 level. When comparing with older source, one may use the -b argument
789 of the diff command to ignore changes in amount of white space:
791 diff -b -r -u calc-2.11.11 calc-2.12.0
793 The read, write, and help commands use the value of global string
794 variable if the symbol name starts with a $. For example:
796 global x = "lucas.cal";
797 read $x; /* same as read lucas.cal or read "lucas.cal" */
799 Added dotest.cal resource. Based on a design by Ernest Bowen
800 <ebowen at une dot edu dot au>, the dotest evaluates individual
801 lines from a file. The dotest() function takes 1 to 3 arguments:
803 dotest(dotest_file [,dotest_code [,dotest_maxcond]])
807 Search along CALCPATH for dotest_file, which contains lines that
808 should evaluate to 1. Comment lines and empty lines are ignored.
809 Comment lines should use ## instead of the multi like /* ... */
810 because lines are evaluated one line at a time.
814 Assign the code number that is to be printed at the start of
815 each non-error line and after **** in each error line.
816 The default code number is 999.
820 The maximum number of error conditions that may be detected.
821 An error condition is not a sign of a problem, in some cases
822 a line deliberately forces an error condition. A value of -1,
823 the default, implies a maximum of 2147483647.
825 Global variables and functions must be declared ahead of time because
826 the dotest scope of evaluation is a line at a time. For example:
830 ; dotest("set8700.line");
832 Updated the todo / wish list items. The top priority now is to
833 convert calc to GNU autoconf / configure to build the calc.
837 Added missing help file for the stoponerror() builtin.
839 Corrected and improved the help documentation for factor and lfactor.
841 Fixed a problem where some error messages that should have been
842 written to a file or string, went to stderr instead. This bug was
843 fixed by Ernest Bowen <ebowen at une dot edu dot au>.
845 Corrected the documentation relating to the calc -c command line option.
846 The -c relates to scan/parse errors only, not execution errors.
848 Corrected a stack overflow problem where the math_fmt() in zio.c
849 could be induced to overflow the stack. This problem was independently
850 reported by Chew Keong Tan of Secunia Research <vuln at secunia dot com>.
852 Corrected a stack overflow problem where the scanerror() in token.c
853 could be induced to overflow the stack by a malformed token.
855 Made math_error() in math_error.c more robust against a error
856 message constant that is too long.
858 Made read_bindings() in hist.c more robust against very long bindings
861 Made listsort() in listfunc.c and matsort() matfunc.c more robust
862 against sorting of impossibly huge lists and matrices.
864 Warnings about an undefining a builtin or undefined function, a
865 constant before the comma operator, and an unterminated comment is
866 now processed by scanerrors (not simply written directly to stderr).
867 These warnings file and line number in which the "error" occurred
868 as well as a more precise message than before. If using -c on the
869 calc command line or if stoponerror(-1), then assuming there are
870 no other compile errors, only the unterminated comment will stop
871 completion of the function being defined.
873 The cal/regress.cal now reads most of the calc resource files.
875 The issq() test had a slight performance boost. A minor note
876 was added to the help/issq file.
878 Improved the documentation of the mul2, sq2, pow2, and redc2 config
879 parameters in help/config.
881 Added config("baseb"), a read-only configuration value to return
882 the number of bits in the fundamental base in which calculations
883 are performed. This is a read-only configuration value.
885 Calc now will allow syntax such as ++*p-- and ++*----*++p----
886 where p is an lvalue; successful evaluation of course require the
887 successive operations to be performed to have operands of appropriate
888 types; e.g. in *A, A is usually an lvalue whose current value is a
889 pointer. ++ and -- act on lvalues. In the above examples there are
890 implied parentheses from the beginning to immediately after p. If
891 there are no pre ++ or -- operations, as in **p++. The implied
892 parentheses are from immediately before p to the end.
894 Improved the error message when && is used as a prefix operator.
896 Changed the help/config file to read like a builtin function help file.
898 One can no longer set to 1, or to a value < 0, the config()
899 parameters: "mul2", "sq2", "pow2", and "redc2". These values
900 in the past would result in improper configuration of internal
901 calc algorithms. Changed cal/test4100.cal to use the minimal
902 value of 2 for "pow2", and "redc2".
904 Changed the default values for the following config() parameters:
906 config("mul2") == 1780
907 config("sq2") == 3388
908 config("pow2") == 176
910 These values were determined established on a 1.8GHz AMD 32-bit
911 CPU of ~3406 BogoMIPS by the new resource file:
915 Regarding the alg_config.cal resource file:
917 The best_mul2() function returns the optimal value of config("mul2").
918 The best_sq2() function returns the optimal value of config("sq2").
919 The best_pow2() function returns the optimal value of config("pow2").
920 The other functions are just support functions.
922 By design, best_mul2(), best_sq2(), and best_pow2() take a few
923 minutes to run. These functions increase the number of times a
924 given computational loop is executed until a minimum amount of CPU
925 time is consumed. To watch these functions progress, one can set
926 the config("user_debug") value.
928 Here is a suggested way to use the alg_config.cal resource file:
931 ; config("user_debug",2),;
932 ; best_mul2(); best_sq2(); best_pow2();
933 ; best_mul2(); best_sq2(); best_pow2();
934 ; best_mul2(); best_sq2(); best_pow2();
936 NOTE: It is perfectly normal for the optimal value returned
937 to differ slightly from run to run. Slight variations due to
938 inaccuracy in CPU timings will cause the best value returned to
939 differ slightly from run to run.
941 See "help resource" for more information on alg_config.cal.
943 Updated the "help variable" text to reflect the current calc
944 use of ` (backquote), * (star), and & (ampersand).
946 Removal of some restrictions on the use of the same identifier
947 for more than one of parameter, local, static or global variable.
949 For example, at command level, one could use:
951 for (local x = 0; x < 10; x++) print sqrt(x);
953 At the beginning of a statement, "(global A)" is a way of
954 indicating a reference to the variable A, whereas "global A"
955 would be taken as a declaration. Parentheses are not required in
956 "++global A" or "global A++" when "global" is used in this way.
958 The patch extends this "specifier" (or "qualifier") feature
959 to static variables, but such that "static A" refers only
960 to a static variable at the current file and function scope
961 levels. (If there is already a static variable A at the current
962 file and function levels, a declaration statement "static A"
963 would end the scope of that variable and define a new static
964 variable with identifier A. A "global A" declaration is more
965 drastic in that it ends the scope of any static variable A at
966 the same or higher scope levels.)
968 Unlike a static declaration in which an "initialization" occurs at
969 most once, in the specifier case, "static A = expr" is simply an
970 assignment which may be repeated any number of times. An example
973 define np() = static a = nextprime(a);
975 For n not too large, the n-th call to this function will
976 return the n-th prime. The variable a here will be private to
979 Because one can use "global", "local" or "static" to specify a
980 type of variable, there seems little point in restricting the
981 ways identifiers that can be used in more than one of these
982 or as parameters. Obviously, introducing A as a local variable
983 when it is being used as a parameter can lead to confusion and a
984 warning is appropriate, but if it is to be used only occasionally,
985 it might be convenient to be able to refer to it as "local A"
986 rather than introducing another identifier. While it may be
987 silly to use the same identifier for both a parameter and local
988 variable, it should not be illegal.
990 Added warnings for possibly questionable code in function definitions.
992 Added config("redecl_warn", boolean) to control if calc issues
993 warnings about variables being declared. The config("redecl_warn")
994 value is TRUE by default.
996 Added config("dupvar_warn", boolean) to control if calc issues
997 warnings about when variable names collide. The config("dupvar_warn")
998 value is TRUE by default. Examples of variable name collisions
1001 * both local and static variables have the same name
1002 * both local and global variables have the same name
1003 * both function parameter and local variables have the same name
1004 * both function parameter and global variables have the same name
1006 Fix of a bug which causes some static variables not to be correctly
1007 unscoped when their identifiers are used in a global declaration.
1009 Change of "undefine" from a command-level keyword to statement level and
1010 introduction of an "undefine static A" statement to end the scope of a
1011 static variable A at the current file/function levels.
1013 Change/restored the syntax rules for "for" and "while" loops to
1014 recognize an unescaped newline in top-level command-level statements.
1016 Updated help/avg, help/define, help/fprintf, help/gcd, help/hash,
1017 help/hmean, help/lcm, help/max, help/min, help/null, help/poly,
1018 help/printf, help/ssq, help/strcat, help/strprintf, help/sum,
1021 Changed the definition of the function ssq() to enable list arguments
1022 to be processed in the same way as in sum(). For example:
1024 ssq(1,2, list(3,4,list(5,6)), list(), 7, 8)
1026 returns the value of 1^2 + 2^2 + ... + 8^2 == 204.
1028 Added the calc resource sumtimes.cal, to give the runtimes for
1029 various ways of evaluating sums, sums of squares, etc, for large
1030 lists and matrices. For example:
1035 Calc now ignores carriage returns (\r), vertical tabs (\v), and
1036 form feeds (\f) when token parsing. Thus users on Windoz systems
1037 can write files using their \r\n format and users on non-Windoz
1038 systems can read them without errors.
1040 The quomod() builtin function now takes an optional 5th argument
1041 which controls the rounding mode like config("quomod") does, but
1042 only for that call. Now quomod() is in line with quo() and mod()
1043 in that the final argument is an optional rounding mode.
1045 Added a "make uninstall" rule which will attempt to remove everything
1046 that was installed by a "make install".
1048 Changed the "Copyright" line in the rpm spec file to a "License" line
1049 as per new rpm v4.4 syntax.
1051 The quomod() builtin function does not allow constants for its 3rd
1052 and 4th arguments. Updated the "help quomod" file and added more
1053 quomod regression tests.
1055 Added patch from Ernest Bowen <ebowen at une dot edu dot au> to
1056 add the builtin: estr(). The estr(x) will return a representation
1057 of a null, string, real number, complex number, list, matrix,
1058 object. block, named block, error as a string.
1060 Added patch from Ernest Bowen <ebowen at une dot edu dot au> to
1061 add the builtin: fgetfile(). The fgetfile(x) will return the rest
1062 of an open file as a string.
1064 Improved help files for fgetfield, fputs, name, or quomod.
1067 The following are the changes from calc version 2.11.10.1 to 2.11.11:
1069 Fixed a bug reported by the sourceforge user: cedars where:
1071 ln(exp(6)) == 3 /* WRONG!!! */
1073 incorrectly returned 1. This bug was fixed by Ernest Bowen
1074 <ebowen at une dot edu dot au>. The regression test
1075 was expanded to cover this issue.
1077 Added minor improvements to hash regression testing of pi().
1079 Fixed "help script" and the calc man page regarding the requirement
1080 of -f to be the last -flag in shell script mode. Further clarified
1081 the meaning and placement of the -f flag.
1083 Moved issues with chi.cal intfile.cal into a "mis-features" section
1084 of the BUGS file. See "help bugs" or the BUGS source file for details.
1086 Added the bug about:
1088 calc 'read ellip; efactor(13*17*19)'
1090 to the BUGS file. See "help bugs" or the BUGS source file for details.
1091 Anyone want to track down and fix this bug?
1093 Fixed typo in the "help mat" example and improved the mat_print example.
1095 Renamed most COMPLEX C function names to start with c_ to avoid
1096 conflicts with new C standard functions. Note that the calc
1097 builtin function names remain the same. The C function names
1098 inside the C source that calc is written in changed. This means
1099 that code that linked to libcalc.a will need to change in order
1100 to call calc's functions instead of the C standard functions.
1101 See cmath.h, comfunc.c, and commath.c for details. See also
1102 http://www.opengroup.org/onlinepubs/009695399/basedefs/complex.h.html
1103 for names of the new C standard functions.
1105 Changed the calc man page to note that using -- in the command will
1106 separate calc options from arguments as in:
1110 Noted how Apple OS X can make use of readline in the Makefile.
1113 # For Apple OS X: install fink from http://fink.sourceforge.net
1114 # and then do a 'fink install readline' and then use:
1116 READLINE_LIB= -L/sw/lib -lreadline -lhistory -lncurses
1118 Added linear.cal as a calc standard resource file.
1121 The following are the changes from calc version 2.11.10 to 2.11.10:
1123 The cygwin config value is correctly tested while doing comparisons
1124 between config states.
1126 Added config("compile_custom") to determine if calc was compiled
1127 with -DCUSTOM. By default, the Makefile uses ALLOW_CUSTOM= -DCUSTOM
1128 so by default, config("compile_custom") is TRUE. If, however,
1129 calc is compiled without -DCUSTOM, then config("compile_custom")
1130 will be FALSE. NOTE: The config("compile_custom") value is only
1131 affected by compile flags. The calc -D runtime command line option
1132 does not change the config("compile_custom") value. This is a
1133 read-only configuration value.
1135 Added config("allow_custom") to determine if the use of custom
1136 functions are allowed. To allow the use of custom functions, calc
1137 must be compiled with -DCUSTOM (which it is by default) AND calc run
1138 be run with the -D runtime command line option (which it is not by
1139 default). If config("allow_custom") is TRUE, then custom functions
1140 are allowed. If config("allow_custom") is FALSE, then custom
1141 functions are not allowed. This is a read-only configuration value.
1143 Correctly hash config state for windows and cygwin values. The value
1144 of config("compile_custom") and config("allow_custom") also affect
1145 the hash of the config state.
1147 Fixed the custom/argv.cal test code to avoid use of a reserved
1148 builtin function name.
1150 Fixed custom/*.cal scripts to conform better with the cal/*.cal
1153 Removed the Makefile variables ${LONGLONG_BITS}, ${HAVE_LONGLONG},
1154 and ${L64_FORMAT}. Removed longlong.c and longlong.h. The use
1155 of HAVE_LONGLONG=0 was problematic. The lack of complaints about
1156 the HAVE_LONGLONG=0 shows that the 'long long' type is wide spread
1157 enough warrent not trying to support compilers without 'long long'.
1159 Removed the SVAL and SHVAL macros from zrand.c, zrand.h, and zmath.h
1160 as they were causing too many broken C pre-processors and C checkers
1163 Added a 'make splint' rule to use the splint statically checking
1164 tool on the calc source.
1166 Removed support of the BSDI platform. The BSDI platform is no longer
1167 directly supported and we lost our last BSDI machine on which we
1168 could test calc. Best wishes to the former BSDI folk and thanks
1169 for breaking important ground in the Open Source Movement!
1171 Fixed several typos found in the documentation and buildin
1172 function output by C Smith <smichr at hotmail dot com>.
1178 will print 0.66666666666666666667 without the leading tilde as
1179 advertised in the man page.
1181 Added a missing help file for the display builtin function as
1182 requested by Igor Furlan <primorec at sbcglobal dot net>.
1184 Changed the "help environment" file to reflect modern default
1185 values of CALCPATH and CALCRC.
1187 Added missing variables for printing by the "make env" rule.
1189 Added EXT Makefile variable so that Cygwin can install calc as
1190 calc.exe. By default, EXT is empty so that calc is calc on most
1191 modern operating systems. Thanks goes to Ullal Devappa Kini <wmbfqj
1192 at vsnl dot net> for helping identify this problem and testing our fix.
1194 Added custom function:
1196 custom("pmodm127", q)
1198 to compute 2^(2^127-1) mod q. While currently slower than just
1199 doing pmod(2,2^127-1,q), it is added to give an example of a
1200 more complex custom function. Call calc with the -C flag to
1201 use custom functions.
1203 Made slight changes to the custom/HOW_TO_ADD documentation.
1205 Fixed some \ formatting man page problems as reported by Keh-Cheng
1206 Chu <kehcheng at quake dot Stanford dot edu>.
1208 Fixed some comparison between signed and unsigned in md5.c
1209 that was reported for the PowerMac G5 2GHz MacOS 10.3 by
1210 Guillaume VERGNAUD <vergnaud at via dot ecp dot fr>.
1212 Fixed a number of pending issues with help files filling in
1213 missing LIMITS, LINK LIBRARY, and SEE ALSO information,
1216 The following are the changes from calc version 2.11.9 to 2.11.9.3:
1218 Fixed calc man page examples to move -f to the end of the line.
1219 Thanks goes to Michael Somos <somos at grail dot cba dot csuohio
1220 dot edu> for pointing this out.
1222 Linux and gcc now compiled with -Wall -W -Wno-comment.
1224 Fixed a post increment that was reported by R. Trinler <trinler at
1225 web dot de> and fixed by Ernest Bowen <ernie at turing dot une dot
1228 Fixed pi.cal to not depend on the buggy pre-2.11.9 post increment
1231 Added config("cygwin") to determine if calc was compiled under Cygwin.
1232 The config("cygwin") is a read-only configuration value that is 1
1233 when calc was compiled under Cygwin and 0 otherwise. Regression
1234 tests 949 and 950 are skipped when config("cygwin") is true.
1236 The Makefile variable HAVE_NO_IMPLICIT is empty by default so that
1237 the Makefile will test if the compiler has a -Wno-implicit flag.
1239 Added HAVE_UNUSED Makefile variable. If HAVE_UNUSED is empty,
1240 then the Makefile will run the have_unused program to determine
1241 if the unused attribute is supported. If HAVE_UNUSED is set to
1242 -DHAVE_NO_UNUSED, then the unused attribute will not be used.
1244 The Makefile builds have_unused.h which defines, if the unused
1245 attribute is supported:
1247 #define HAVE_UNUSED /* yes */
1248 #define UNUSED __attribute__((unused)) /* yes */
1250 or defines, if the unused is not supported (or if the Makefile
1251 variable is HAVE_UNUSED= -DHAVE_NO_UNUSED):
1253 #undef HAVE_UNUSED /* no */
1254 #define UNUSED /* no */
1256 Fixed numerous warnings about comparison between signed and unsigned
1257 value warnings and unused parameter warnings in version.c, zrand.c,
1258 string.c, shs1.c, shs.c, qtrans.c, qmath.c, qfunc.c, md5.c, matfunc.c,
1259 hist.c, file.c, const.c, blkcpy.c, seed.c, opcodes.c, func.c, qio.c,
1260 zrandom.c, custom/c_argv.c, custom/c_devnull.c, custom/c_help.c,
1261 custom/c_sysinfo.c, addop.c and calc.c.
1263 Fixed some typos in this file.
1265 By default, compile with -O3 -g3. The Makefile comments on how some
1266 distributions might need to use -O2 -g or -O -g.
1269 The following are the changes from calc version 2.11.8.0 to 2.11.8.1:
1271 Updated HOWTO.INSTALL to reflect the new RPM files.
1273 Clarify that the internal hash as well as the hash builtin
1274 function used by calc, while based on the Fowler/Noll/Vo
1275 hash is NOT an FNV hash.
1277 Made slight performance improvements to calc by an optimization of how
1278 calc's internal hash is computed. The "make chk" regression test
1279 runs about 1.5% faster (when compiled with -O3 on an AMD Athlon)
1280 NO_HASH_CPU_OPTIMIZATION is not defined. Calc's internal hash values
1281 have not changed. By default, NO_HASH_CPU_OPTIMIZATION is NOT defined
1282 and the slightly faster expression is used.
1284 A slight modification of what was known as the "calc new standard"
1285 configuration (calc -n or config("all", "newstd")) is now the default
1286 calc configuration. The flag:
1290 was added to get the old classic calc configuration. The flag command
1291 line flag, -n, now does nothing. Use of -n is deprecated and may go
1292 away / be used for something else in the future.
1294 The following table gives the summary of these changes:
1297 default pre v2.11.8 -O & oldstd v2.11.8
1298 and oldstd -n & newstd classic cfg default
1299 --------------------------------------------------------
1300 epsilon 1e-20 1e-10 1e-20 1e-20
1308 With the exception of epsilon being 1e-20, and fullzero being unset,
1309 the new default calc config is like it was (pre-2.11.8) with calc -n /
1310 config("all", "newstd").
1312 The new default config is the old classic config with outround being
1313 24, leadzero being set, and the prompts being ;'s.
1315 Fixed a bug in the evaluation of tanh(1e-23) with an epsilon(1e-100).
1316 Thanks goes to Dmitry G. Baksheyev <bd at nbsp dot nsk dot su>
1317 for reporting the problem, and thanks goes to Ernest Bowen
1318 <ernie at turing dot une dot edu dot au> for the fix.
1321 The following are the changes from calc version 2.11.7.0 to 2.11.7.1:
1323 Added support to build calc RPMs thanks to Petteri Kettunen
1324 <petterik at users dot sourceforge dot net>.
1326 Added rpm rule to Makefile to build rpm set. The rpm rule
1327 uses the rpm.mk Makefile and the calc.spec.in spec template.
1329 The default Makefile is now the Makefile used during rpm
1330 creation. This Makefile assumes that system has readline,
1331 ncurses (-lreadline -lhistory -lncurses), and less.
1332 It compiled with a high gcc optimization level (-O3 -g3).
1333 The Makefile used during rpm creation is the Makefile
1334 that appears in the calc-src rpm as well.
1336 The Makefile shipped with the old style gziped tarball
1337 is still the same generic Makefile.
1339 The Makefile now uses ${MKDIR} ${MKDIR_ARG} when creating
1340 directories during installation. By default, it does
1341 a mkdir -p when forming directories.
1343 Fixed attributes on include and lib calc-devel files.
1345 Adjusted the interaction between rpm.mk, and the calc.spec.in.
1346 Release number now comes from calc.spec.in only.
1348 Renamed calc and calc-devel RPMs to use .i686 instead of .i386.
1351 The following are the changes from calc version 2.11.6.3 to date:
1353 Fixed a bug in deg.cal where fixdms() was being called with
1354 the wrong type of argument.
1356 Changed the value of digits(1) and digits(0) to be 1. Now digits()
1357 returns number of digits in the standard base-b representation
1358 when x is truncated to an integer and the sign is ignored.
1359 To be more precise: when abs(int(x)) > 0, this function returns
1360 the value 1 + ilog(x, b). When abs(int(x)) == 0, then this
1361 function returns the value 1.
1363 As the result of the above digits() change, the repeat.cal
1364 resource file script was modified to remove the special
1365 case for repeating a value of 1. Also the regress tests
1366 #715, #977 and #978 were changed.
1368 Made a minor improvement to the "help places" documentation.
1370 Fixed dms_neg(a) in deg.cal thanks to a bug report by kaa
1371 <kaa76 at pochtamt dot ru>.
1374 The following are the changes from calc version 2.11.6.0 to 2.11.6.2:
1376 Clarified remark in lucas.cal about use of n mod 2^n == 0.
1378 Fixed help typos reported by Marc Mezzarobba <mm at mm dot ovh dot org>.
1380 Forced system("") to return 0 under windoz.
1382 The direct.h include file is not used when compiling under Cygwin.
1384 Fixed bug where random(10,11) caused calc to dump core when issued
1387 Moved the setting of the Makefile variable ${CALC_INCDIR} to
1388 the section where things like ${BINDIR} and ${LIBDIR} are set.
1389 Idea from Clifford Kite <kite_public1 at ev1 dot net>.
1391 The Makefile is shipped mode 0644 since a number of folks
1392 edit it (to build and check calc) as a non-root user and later
1393 on su to root to install. Idea from Clifford Kite <kite_public1
1396 Added base2() builtin function to calc. Normally calc prints
1397 values according to base(). Frequently some users want to see
1398 a value in two bases. Flipping back and forth between to bases
1399 is a bit of a pain. With base2(), calc will output a value twice:
1405 234567 /* 0x39447 */
1407 131072 /* 0x20000 */
1412 By default, base2() is disabled. Calling base2(0) will also turn
1413 off the double base mode. Thanks goes to Erik Anggard
1414 <erik dot anggard at packetfront dot com> for his idea and
1417 Added repeat.cal as a calc resource file script:
1419 repeat(digit_set, repeat_count)
1421 Return the value of the digit_set repeated repeat_count times.
1422 Both digit_set and repeat_count must be integers > 0.
1424 For example repeat(423,5) returns the value 423423423423423,
1425 which is the digit_set 423 repeated 5 times.
1427 Makefile no longer makes a direct reference to Red Hat 6.0.
1429 Added missing math_setmode2() prototype to zmath.h.
1431 Fixed some implicit declarations of functions by either making
1432 them explicit or by including the proper system .h files.
1434 Makefile no longer uses -Wno-implicit flag, by default, for
1435 gcc based compiles on calc source. Makefile now attempts to
1436 compile no_implicit.c with an explicit -Wno-implicit arg in an
1437 effort to determine of -Wno-implicit is a valid compiler flag.
1438 If no_implicit.c is compiled with -Wno-implicit, then
1439 the file no_implicit.arg is created with the contents
1440 of the -Wno-implicit flag. Otherwise no_implicit.arg
1441 is created as an empty file.
1443 Added the Makefile variable ${HAVE_NO_IMPLICIT}, which if
1444 not set to YES will prevent no_implicit.c from being
1445 compiled and prevent the -Wno-implicit flag from being used.
1446 If ${HAVE_NO_IMPLICIT} is not YES, then an empty no_implicit.arg
1447 file is created and no_implicit.c is not compiled.
1449 The seed.c file, because the pseudo_seed() function contains
1450 calls to a number of various system functions, attempts to
1451 compile with the -Wno-implicit flag (if allowed by the
1452 formation of the no_implicit.arg file).
1454 Misc make depend fixes and cleanup.
1456 Fixed formation of the custom/.all file.
1458 Fixed repeat(1, repeat_count) bug.
1461 The following are the changes from calc version 2.11.5.5 to 2.11.5.9:
1463 Now using version numbers of one of these forms:
1469 Changed the READLINE_LIB Makefile variable to not link with -lreadline
1470 by default. If you do have readline, we recommend that you use it.
1471 If you can install the GNU readline:
1473 http://freshmeat.net/projects/gnureadline/
1474 http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
1476 we recommend it. But if not, you should set the USE_READLINE,
1477 READLINE_LIB, and READLINE_INCLUDE Makefile variables to empty.
1478 NOTE: See the BUGS file for a Linux issue when compiling calc
1479 with -O (or -O2 or -O3) AND with -g (or -g3) AND with readline.
1481 Removed an obsolete reference to TOPDIR. This was fixed thanks to
1482 a bug report by Clifford Kite <kite_public1 at ev1 dot net>.
1483 Fixed other inconsistencies related to things like BINDIR.
1485 Fixed calc man page so that is refers to -f instead of the old -S flag.
1486 Fixed thanks to Clifford Kite <kite_public1 at ev1 dot net> for
1489 All for loops end with /dev/null to avoid any problems related
1490 to systems that cannot grok empty for loops.
1492 Changed the libcalc functions creal and cimag to c_real and c_imag
1493 to about conflicts with new libc such as those used by gcc v3.
1494 Thanks Eli Zaretskii <eliz at is dot elta dot co dot il> and
1495 Martin Buck <m at rtin-buck dot de> for alerting us to this conflict.
1497 The Makefile no longer hard code's /usr/include. Instead it uses
1498 the ${INCDIR} Makefile variable. Thanks goes to Eli Zaretskii
1499 <eliz at is dot elta dot co dot il> for pointing out this inconsistency.
1501 Added mods to support compilation under DJGPP. DJGPP runs on 386
1502 and newer PCs running DOS or dos-compatible operating systems.
1503 See http://www.delorie.com/djgpp/. Thanks goes to Eli Zaretskii
1504 <eliz at is dot elta dot co dot il> for sending in these mods.
1506 Updated README.WINDOWS to include information on building with DJGPP.
1508 The pld folks are building RPMs based on our calc distributions.
1509 See: ftp://ftp.pld.org.pl/dists/ra/PLD/i686/PLD/RPMS or
1510 http://ftp.pld.org.pl/dists/ra/PLD/i686/PLD/RPMS more information.
1511 We appreciate their work in this regard. In the next release, we
1512 plan to also build and release our own RPMs based on their efforts.
1514 Changed the Makefile variable CUSTOMLIBDIR to CUSTOMCALDIR.
1515 Changed the Makefile variable CSHAREDIR to CALC_SHAREDIR.
1516 Changed the Makefile variable INCDIRCALC to CALC_INCDIR.
1517 Removed the Makefile variable SHAREDIR.
1519 Updated the HOWTO.INSTALL and README.WINDOWS files.
1521 Fixed definition of MAXUFULL. Thanks to a bus report from
1522 Jill Poland <jpoland at cadence dot com>.
1524 The following are the changes from calc version 2.11.5t4.1 to 2.11.5t4.4:
1526 Updated dependency rules in Makefiles.
1528 NOTE: -DSRC, as used in 2.11.5t4.1 was renamed -DCALC_SRC
1531 Calc include files use #include "foo.h" to include other calc
1532 header files if -DCALC_SRC. Otherwise they use <calc/foo.h>.
1533 The -DCALC_SRC symbol is defined by default in calc's Makefile
1534 and so it uses the header files from within the calc src tree.
1535 If an external non-calc program includes an installed calc
1536 header file (from under /usr/include), and it does NOT define
1537 CALC_SRC, then it will obtain the calc header files from the
1538 correct system location (such as /usr/include/calc/foo.h).
1540 Added calc builtin function: version() which returns the calc
1543 Added subject requirements for the calc-tester-request and
1544 calc-bugs-mail EMail aliases. See:
1546 http://www.isthe.com/chongo/tech/comp/calc/email.html
1550 Corrected a bug that incorrectly set the default calc path
1551 back in version 2.11.5t4. The default CALCPATH is now:
1553 .:./cal:~/.cal:/usr/share/calc:/usr/share/calc/custom
1555 and the default CALCRC is now:
1557 /usr/share/calc/startup:~/.calcrc:./.calcinit
1559 This fixes the missing bindings error and it places the calc
1560 resource files into the default path.
1562 If you are using the GNU readline then the Makefile recommends that
1563 you link with the ncurses library.
1565 Applied Makefile, cscript/Makefile and custom/Makefile patches to
1566 fix install mode problems, to deal with sorting and dates in I18n
1567 environments (such as Japanese), to fix some problems with calc.spec
1568 and to fix the cscript #! header lines. Thanks goes to KAWAMURA Masao
1569 (kawamura at mlb.co.jp) for the bug report and patch!
1571 Fixed headers on fproduct.calc powerterm.calc 4dsphere.calc so
1572 that they are correcly changed on installation.
1574 Added ${GREP} Makefile variable.
1576 The top level Makefile now sets LANG=C and passes it down to
1577 lower level Makefiles.
1579 Updated URLs in cal/lucas.cal comments.
1581 Now shipping calc.spec, inst_files, spec-template and Makefile.linux
1582 with the standard calc source distribution. Note that the standard
1583 Makefile has not changed. The Makefile.linux only in minor ways
1584 needed to build calc rpms.
1586 Added $T Makefile variable. $T is the top level directory under
1587 which calc will be installed. The calc install is performed under $T,
1588 the calc build is performed under /. The purpose for $T is to allow
1589 someone to install calc somewhere other than into the system area.
1590 For example when forming the calc rpm, the Makefile is called with
1591 T=$RPM_BUILD_ROOT. If $T is empty, calc is installed under /.
1593 Removed all echo_XYZ rules except for echo_inst_files from lower
1594 level makefile. The calc.spec will use a make install rule
1595 with T=$RPM_BUILD_ROOT.
1597 Updated LIBRARY file with instructions related to -DCALC_SRC,
1598 the new default include file location and -lcustcalc.
1601 The following are the changes from calc version 2.11.5t3 to 2.11.5t4:
1603 The Makefile will now send both stdout and stderr to /dev/null
1604 when compiling hsrc intermediates.
1606 The config("verbose_quit") value was restored to a default
1611 powerterm [base_limit] value
1613 to write the value as the sum (or difference) of powers <= base_limit
1614 where base_limit by default is 10000.
1616 Applied a bug fix by Dr.D.J.Picton <dave at aps5.ph.bham.ac.uk>
1617 to have help with no args print the default help file.
1619 Renamed lavarand to LavaRnd.
1621 Added rules to build a calc rpm.
1623 All installed files are first formed as foo.new, and then moved
1624 into place as foo via a atomic rename.
1626 During installation, only files that are different are installed.
1627 If the built file and the installed file are the same, no
1628 installation is performed.
1630 Calc has new default installation locations:
1632 Makefile var old location new location
1633 ------------ ------------ ------------
1634 TOPDIR /usr/local/lib <<no longer used>>
1635 BINDIR /usr/local/bin /usr/bin
1636 SHAREDIR <<not set>> /usr/share
1637 INCDIR /usr/local/include /usr/include
1638 LIBDIR /usr/local/lib/calc /usr/lib
1639 CSHAREDIR <<not set>> /usr/share/calc
1640 HELPDIR /usr/local/lib/calc/help /usr/share/calc/help
1641 INCDIRCALC /usr/local/include/calc /usr/include/calc
1642 CUSTOMLIBDIR /usr/local/lib/calc/custom /usr/share/calc/custom
1643 CUSTOMHELPDIR /usr/local/lib/calc/help/custhelp /usr/share/calc/custhelp
1644 CUSTOMINCDIR <<not set>> /usr/include/calc/custom
1645 SCRIPTDIR /usr/local/bin/cscript /usr/bin/cscript
1646 MANDIR <<not set>> /usr/share/man/man1
1647 CATDIR <<not set>> <<not set>>
1649 The Makefile variable ${TOPDIR} is no longer used. In some places
1650 it has been replaced by a new Makefile variable ${SHAREDIR}. Some
1651 of the old TOPDIR functionality has been replaced by ${CSHAREDIR}.
1653 The install rules no longer remove old obsolete files. We assume
1654 that these old files have long since vanished! :-)
1656 Reduced the amount of output when doing a make all where nothing
1659 Reduced the amount of output when doing a make install where nothing
1660 needs to be installed.
1662 If you install using the new default locations, you can remove
1663 old calc files installed in the old default location by doing:
1668 The following are the changes from calc version 2.11.5t2 to 2.11.5t2.1:
1670 Fixed a bug, reported by Ernest Bowen <ernie at turing dot
1671 une dot edu dot au> that caused command lines to be echoed in
1672 interactive mode. Fixed a bug that sometimes left the terminal
1673 in a non-echoing state when calc exited.
1675 Renamed error codes E_FGETWORD1 and E_FGETWORD2 symbols to
1676 E_FGETFIELD1 and E_FGETFIELD2.
1678 Made a minor format change to the top of the calc man page.
1680 The findid() function in file.c 2nd argument changed. The argument
1681 is now mostly a writable flag. This function now finds the file
1682 I/O structure for the specified file id, and verifies that
1683 it is opened in the required manner (0 for reading or 1 for writing).
1684 If the 2nd argument is -1, then no open checks are made at all and
1685 NULL is then returned if the id represents a closed file.
1687 The calc builtin function, fopen(), now allows one to specify
1688 opening files in binary modes. On POSIX / Linux / Un*x-like systems,
1689 text file is the same as a binary file and so 'b' to an fopen has
1690 no effect and is ignored. However on systems such as MS Windoz
1691 the 'b' / binary mode has meaning. See 'help fopen' for details.
1693 On systems (such as MS Windoz), calc will produce a different error
1694 message when it attempts to open /dev/tty. This will condition
1695 will occur in things like calc scripts when they switch from ``batch
1696 processing'' commands from and want to start interactive mode.
1698 Regression tests fopen in binary mode in a few places where a
1699 difference between text and binary string lengths matter.
1700 The intfile calc resource file also uses binary mode.
1702 Changed the rand() builtin and its related functions srand() and
1703 randbit() to use the Subtractive 100 generator instead of the
1704 additive 55 generator. This generator as improved random properties.
1705 As a result, of this change, the values produced by rand(),
1706 rand() and randbit() are now different.
1708 Updated regression tests for new rand() and randbit() output.
1710 Applied a bug fix from Ernest Bowen <ernie at turing dot une dot
1711 edu dot au> dealing with one-line "static" declaration like:
1715 Added regression test 8310 to test for the static bug fix.
1718 The following are the changes from calc version 2.11.5t0 to 2.11.5t1.1:
1720 Fixed a compile problem with Linux 2.4 / Debian. Thanks goes
1721 to Martin Buck <m at rtin-buck dot de> for help with this issue.
1723 Fixed a bug in how L64_FORMAT (it determined if "%ld" or "%lld"
1724 is appropriate for printing of 64 bit long longs) was determined.
1725 Thanks goes to Martin Buck <m at rtin-buck dot de> for reporting
1726 this bug and testing the fix.
1728 An effort was made to make calc easier to build under Windoz
1729 using the Cygwin project (http://sources.redhat.com/cygwin/).
1730 Thanks to the work of Thomas Jones-Low (tjoneslo at softstart
1731 dot com), a number of #if defined(_WIN32)'s have been added
1732 to calc source. These changes should not effect Windoz
1733 free system such as GNU/Linux, Solaris, POSIX-like, etc ...
1735 Added windll.h to deal with Windoz related DLL issues.
1736 Using the convention of 'extern DLL' instead of 'DLL extern'
1737 to deal with symbols that export to or import from a DLL.
1739 Added HAVE_MALLOC_H, HAVE_STDLIB_H, HAVE_STRING_H, HAVE_TIMES_H,
1740 HAVE_SYS_TIMES_H, HAVE_TIME_H, HAVE_SYS_TIME_H, HAVE_UNISTD_H
1741 and HAVE_URANDOM to the Makefile. If these symbols are empty,
1742 then the Makefile looks for the appropriate system include file.
1743 If they are YES, then the Makefile will assume they exist.
1744 If they are NO, then the Makefile will assume they do not exist.
1746 Changed HAVE_URANDOM to match the empty, YES, NO values.
1747 If HAVE_URANDOM is empty, then the Makefile will look for /dev/urandom.
1748 If HAVE_URANDOM is YES, then the Makefile will assume /dev/urandom exists.
1749 If HAVE_URANDOM is NO, then the Makefile will assume /dev/urandom does
1752 If TERMCONTROL is -DUSE_WIN32, then the Windoz terminal control
1753 (no TERMIOS, no TERMIO, no SGTTY) will be assumed.
1755 Added a win32_hsrc Makefile rule to create hsrc files appropriate
1756 for a Windoz system using Cygwin gcc environment. Added win32.mkdef
1757 which is used by the win32_hsrc rule to set the Windoz specific
1758 Makefile values to build hsrc files. The hsrc files are built
1759 under the win32 directory.
1761 Added FPOS_POS_BITS, OFF_T_BITS, DEV_BITS and INODE_BITS Makefile
1762 symbols to allow one to force the size of a file position, file
1763 offset, dev and inode value. Leaving these values blank will
1764 Makefile to determine their size.
1766 Fixed a bug in the way file offsets, device and inode values are copied.
1768 Added chi.cal for a initial stab as a Chi^2 function. The chi_prob()
1769 function does not work well with odd degrees of freedom, however.
1771 Added big 3 to config("resource_debug"). Calc resource file scripts
1772 check for config("resource_debug") & 8 prior to printing internal debug
1773 statements. Thus by default they do not print them.
1775 Added intfile.cal as a calc resource file script:
1779 Read filename and return an integer that is built from the
1780 octets in that file in Big Endian order. The first octets
1781 of the file become the most significant bits of the integer.
1785 Read filename and return an integer that is built from the
1786 octets in that file in Little Endian order. The first octets
1787 of the file become the most significant bits of the integer.
1789 be2file(v, filename)
1791 Write the absolute value of v into filename in Big Endian order.
1792 The v argument must be on integer. The most significant bits
1793 of the integer become the first octets of the file.
1795 le2file(v, filename)
1797 Write the absolute value of v into filename in Little Endian order.
1798 The v argument must be on integer. The least significant bits
1799 of the integer become the last octets of the file.
1801 Added the following help aliases:
1814 fproduct filename term ...
1816 to write the big Endian product of terms to a filename. Use - for stdout.
1818 Fixed calc path in help/script.
1820 Added read-only parameter, config("windows") to indicate if the system
1821 is MS windowz WIN32 like system.
1823 Configuration values that used to return "true" or "false" now return
1824 1 (a true value) or 0 (a false value). Thus one can do:
1826 if (config("tab")) { ... } else { ... }
1828 The configuration values that now return 1 or 0 are:
1833 config("blkverbose")
1834 config("verbose_quit")
1837 Now shipping a win32 sub-directory that contains hsrc .h files
1838 that have been attempted to be built for windoz.
1841 The following are the changes from calc version 2.11.4t1 to 2.11.4t2:
1843 Added missing test8600.cal test file.
1845 Fixes cscript files to deal with the -S flag being replaced by
1846 -f and possibly other flags.
1848 Added regression tests for builtin functions bernoulli, catalan,
1849 euler, freeeuler, and sleep. Added non-base 10 regression tests
1850 for digit, digits and places.
1852 The bernoulli.cal script now just calls the bernoulli() builtin
1853 function. It remains for backward compatibility.
1855 The Makefile now builds have_fpos_pos.h to determine if the
1856 a non-scalar FILEPOS has a __pos stucture element. If it does,
1857 the FILEPOS_BITS is taken to be the size of just the __pos element.
1859 Misc fixes related to non-scalar (e.g., structure) FILEPOS. Fixed
1860 a compile problems where non-scalar FILEPOS were incorrectly assigned.
1862 Fixed make depend rule.
1864 Return an error on malloc / realloc failures for bernoulli and
1867 Added MAKEFILE_REV make variable to help determine Makefile version.
1868 Fixed the way the env rule reports Makefile values.
1871 The following are the changes from calc version 2.11.3t0 to 2.11.4:
1873 Increased the maximum number of args for functions from 100 to 1024.
1874 Increased calc's internal evaluation stack from 1024 to 2048 args.
1875 Added test8600.cal to the regression suite to test these new limits.
1877 Updated and fixed misc typos in calc/README.
1879 Clarified in the COPYING file that ALL calc source files, both
1880 LGPL covered and exceptions to the LGPL files may be freely used
1883 Added help files or updated for: bernoulli, calc_tty, catalan,
1884 digit, digits, euler, freeeuler, places and sleep.
1886 A collection of 18 patches from Ernest Bowen
1887 <ernie at turing dot une dot edu dot au>:
1889 (1) A new flag -f has been defined which has the effect of a read
1890 command without the need to terminate the file name with a semicolon
1893 calc "read alpha; read beta;"
1897 calc -f alpha -f beta
1899 Quotations marks are recognized in a command like
1901 calc -f 'alpha beta'
1903 in which the name of the file to be read includes a space.
1905 (2) Flags are interpreted even if they are in a string, as in:
1907 calc "-q -i define f(x) = x^2;"
1909 which has the effect of:
1911 calc -q -i "define f(x) = x^2;"
1913 To achieve this, the use of getopts() in calc.c has been dropped in
1914 favor of direct reading of the arguments produced by the shell.
1915 In effect, until a "--" or "-s" or a calc command (recognized
1916 by not starting with '-') is encountered, the quotation signs in
1917 command lines like the above example are ignored. Dropping getopts()
1918 permits calc to specify completely the syntax rules calc will apply
1919 to whatever it is given by the shell being used.
1921 (3) For executable script (also called interpreter) files with first
1922 line starting with "#!", the starting of options with -S has been
1923 replaced by ending the options with -f. For example, the first line:
1925 #! full_pathname_for_calc -S -q -i
1927 is to be replaced by:
1929 #! full_pathname_for_calc -q -i -f
1931 Thus, if the pathname is /usr/bin/calc and myfile contains:
1933 #!/usr/bin/calc -q -i -f
1934 global deg = pi()/180;
1935 define Sin(x) = sin(x * deg);
1937 and has been made executable by:
1941 myfile would be like a version of calc that ignored any startup
1942 files and had an already defined global variable deg and a function
1943 Sin(x) which will return an approximation to the sine of x degrees.
1944 The invocation of myfile may be followed by other options (since
1945 the first line in the script has only flagged options) and/or calc
1948 ./myfile -c read alpha '; define f(x) = Sin(x)^2'
1950 (The quotation marks avoid shell interpretation of the semicolon and
1953 (4) The old -S syntax for executable scripts implied the -s flag so that
1954 arguments in an invocation like
1958 are passed to calc; in this example argv(0) = 'alpha', argv(1) =
1959 'beta'. This has been changed in two ways: an explicit -s is required
1960 in the first line of the script and then the arguments passed in the
1961 above example are argv(0) = 'myfile', argv(1) = 'alpha', argv(1) = 'beta'.
1963 In an ordinary command line, "-s" indicates that the shell words
1964 after the one in which "-s" occurred are to be passed as arguments
1965 rather than commands or options. For example:
1967 calc "-q -s A = 27;" alpha beta
1969 invokes calc with the q-flag set, one command "A = 27;", and two arguments.
1971 (5) Piping to calc may be followed by calc becoming interactive.
1972 This should occur if there is no -p flag but -i is specified, e.g.:
1974 cat beta | calc -i -f alpha
1976 which will do essentially the same as:
1978 calc -i -f alpha -f beta
1980 (6) The read and help commands have been changed so that several
1981 files may be referred to in succession by separating their names
1982 by whitespace. For example:
1984 ; read alpha beta gamma;
1986 does essentially the same as:
1988 ; read alpha; read beta; read gamma;
1990 This is convenient for commands like:
1994 when file?.cal expands to something like file1.cal file2.cal file3.cal:
1996 myfiles='alpha beta gamma'
1999 or for C-shell users:
2001 set myfiles=(alpha beta gamma)
2005 (7) The -once option for read has been extended to -f. For example,
2009 will ignore alpha if alpha has been read in the startup files. In a
2010 multiple read statement, -once applies only to the next named file.
2013 ; read -once alpha beta -once gamma;
2015 will read alpha and gamma only if they have not already been read,
2016 but in any case, will read beta.
2018 (8) A fault in the programming for the cd command has been corrected
2019 so that specifying a directory by a string constant will work. E.g:
2023 should work if the current directory has a directory with name "my work".
2025 (9) new functions bernoulli(n) and euler(n) have been defined to
2026 return the Bernoulli number and the Euler number with index n.
2027 After evaluation for an even positive n, this value and these for
2028 smaller positive even n are stored in a table from which the values
2029 can be reread when required. The memory used for the stored values
2030 can be freed by calling the function freebernoulli() or freeeuler().
2032 The function catalan(n) returns the catalan number with index n.
2033 This is evaluated using essentially comb(2*n, n)/(n+1).
2035 (10) A function sleep(n) has been defined which for positive n calls
2036 the system function sleep(n) if n is an integer, usleep(n) for other
2037 real n. This suspends operation for n seconds and returns the null
2038 value except when n is integral and the sleep is interrupted by a
2039 SIGINT, in which case the remaining number of seconds is returned.
2041 (11) The effect of config("trace", 8) which displays opcodes of
2042 functions as they are successfully defined has been restricted to
2043 functions defined with explicit use of "define". Thus, it has been
2044 deactivated for the ephemeral functions used for evaluation of calc
2045 command lines or eval() functions.
2047 (12) The functions digit(), digits(), places() have been extended to
2048 admit an optional additional argument for an integral greater-than-one
2049 base which defaults to 10. There is now no builtin limit on the
2050 size of n in digit(x, n, b), for example, digit(1/7, -1e100) which
2051 would not work before can now be handled.
2053 (13) The function, digits(x), which returns the number of decimal
2054 digits in the integer part of x has been changed so that if abs(x) <
2055 1, it returns 0 rather than 1. This also now applies to digits(x,b).
2057 (14) Some programming in value.c has been improved. In particular,
2058 several occurrences of:
2060 vres->v_type = v1->v_type;
2062 if (v1->v_type < 0) {
2063 copyvalue(v1, vres);
2067 have been replaced by code that achieves exactly the same result:
2069 vres->v_type = v1->v_type;
2074 (15) Some operations and functions involving null-valued arguments
2075 have been changed so that they return null-value rather than "bad
2076 argument-type" error-value. E.g. null() << 2 is now null-valued
2077 rather than a "bad argument for <<" error-value.
2079 (16) "global" and "local" may now be used in expressions. For example:
2081 ; for (local i = 0; i < 5; i++) print i^2;
2083 is now acceptable, as is:
2085 ; define f(x = global x) = (global x = x)^2;
2087 which breaks wise programming rules and would probably better be handled
2091 ; define f(t = x) = (x = t)^2;
2093 Both definitions produce the same code for f. For non-null t, f(t)
2094 returns t^2 and assigns the value of t to x; f() and f(t) with null t
2097 Within expressions, "global" and "local" are to be followed by just one
2098 identifier. In "(global a = 2, b)" the comma is a comma-operator; the
2099 global variable a is created if necessary and assigned the value 2, the
2100 variable b has to already exist. The statement "global a = 2, b" is
2101 a declaration of global variables and creates both a and b if they
2102 don't already exist.
2104 (18) In a config object, several components have been changed from
2105 long to LEN so that they will now be 32 bit integers for machines with
2106 either 32 or 64-bit longs. In setting such components, the arguments
2107 are now to less than 2^31. Before this change:
2109 ; config("mul2", 2^32 + 3)
2111 would be accepted on a 64-bit machine but result in the same as:
2116 The following are the changes from calc version 2.11.2t0 to 2.11.2t1.0:
2118 Fixed a bug whereby help files are not displayed correctly on
2119 systems such as NetBSD 1.4.1. Thanks to a fix from Jakob Naumann.
2121 Changed EMail addresses to use asthe.com. Changed URLs to use
2122 www.isthe.com. NOTE: The EMail address uses 'asthe' and the web
2123 site URL uses 'isthe'.
2125 Using calc-bugs at asthe dot com for calc bug reports,
2126 calc-contrib at asthe dot com for calc contributions,
2127 calc-tester-request at asthe dot com for requests to join calc-tester and
2128 calc-tester at asthe dot com for the calc tester mailing list.
2130 Replaced explicit EMail addresses found this file with the <user at
2131 site dot domain> notation to reduce the potential for those folks
2134 The Makefile attempts to detect the existence of /dev/urandom with -e
2135 instead of the less portable -c.
2137 Misc Makefile fixes.
2140 The following are the changes from calc version 2.11.1t3 to 2.11.1t4:
2142 Removed non-portable strerror() tests (3715, 3724 and 3728) from
2145 Fixed missing strdup() from func.c problem.
2147 Fixed a problem that would have come up on a very long #! command line
2148 if the system permitted it.
2151 The following are the changes from calc version 2.11.1 to 2.11.1t2.2:
2153 Placed calc under version 2.1 of the GNU Lesser General Public License.
2161 should display the generic calc copyright as well as the contents
2162 of the COPYING and COPYING-LGPL files.
2164 Those files contain information about the calc's GNU Lesser General
2165 Public License, and in particular the conditions under which you
2166 are allowed to change it and/or distribute copies of it.
2168 Removed the lint facility from the Makefile. Eliminated Makefile
2169 variables: ${LCFLAGS}, ${LINT}, ${LINTLIB} and ${LINTFLAGS}.
2170 Removed the lint.sed file.
2172 Cleaned up help display system. Help file lines that begin with
2173 '##' are not displayed.
2175 Calc source and documentation now uses these terms:
2177 *.cal files calc resource file
2178 *.a files calc binary link library
2179 #! files calc shell script
2181 Renamed 'help stdlib' to 'help resource'. The 'help stdlib' is
2182 aliased to 'help resource' for arg compatibility.
2184 Renamed config("lib_debug") to config("resource_debug").
2185 The config("lib_debug") will have the same effect as
2186 config("resource_debug") for backward compatibility.
2188 Renamed the source sub-directory lib to cal. The default $CALCPATH
2189 now uses ./cal:~/cal (instead of ./lib:~/lib). Changed LIB_PASSDOWN
2190 Makefile variable to CAL_PASSDOWN.
2192 Fixed misc compile warnings and bugs.
2194 Fixed problem of incorrect paths in the formation of installed
2197 Changed the recommended Comqaq cc compile to be -std0 -fast -O4 -static.
2199 Fixed a problem related to asking for help for a non-existent file.
2201 Added ./.calcinit to the default calcrc.
2203 Added cscript/README and help cscript to document the calc shell
2204 script supplied with calc.
2207 The following are the changes from calc version 2.11.0t10 to 2.11.0t11:
2209 Misc code cleanup. Removed dead code. Removed trailing whitespace.
2210 Fixed whitespace to make the best use of 8 character tabs.
2212 Fixed some bugs relating to '// and %' in combination with some
2213 of the rounding modes based on a patch from Ernest Bowen
2214 <ernie at turing dot une dot edu dot au>.
2216 A patch from Klaus Alexander Seistrup <klaus at seistrup dot dk>, when
2217 used in combination with the GNU-readline facility, will prevent
2218 it from saving empty lines.
2220 Minor typos fixed in regress.cal
2222 Added 8500 test series and test8500.cal to perform more extensive
2223 tests on // and % with various rounding modes.
2225 The 'unused value ignored' messages now start with Line 999: instead
2228 Fixed the long standing issue first reported by Saber-C in the
2229 domul() function in zmil.c thanks to a patch by Ernest Bowen
2230 <ernie at turing dot une dot edu dot au>.
2232 Added zero dimensional matrices. A zero dimensional matrix is defined as:
2234 mat A[] or A = mat[]
2236 Updated the help/mat file to reflect the current status of matrices
2237 including zero dimensional matrices.
2239 Added indices() builtin function as written by Ernest Bowen <ernie
2240 at turing dot une dot edu dot au> developed from an idea of Klaus
2241 Seistrup <klaus at seistrup dot dk>. See help/indices for details.
2243 Fixed a number of insure warnings as reported by Michel van der List
2244 <vanderlistmj at sbphrd dot com>.
2246 Fixed a number of help file typos discovered by Klaus Alexander
2247 Seistrup <klaus at seistrup dot .dk>.
2249 Removed REGRESS_CAL as a Makefile variable.
2251 Added calcliblist and calcliblistfmt utility Makefile rules to allow
2252 one to print the list of distribution files that are used (but not
2253 built) to form either the libcalc.a or the libcustcalc.a library.
2255 Added a patch from <Randall.Gray at marine dot csiro dot au> to make
2256 ^D terminate, but *only* if the line it is on is completely empty.
2257 Removed lib/altbind and removed the CALCBINDINGS Makefile variable.
2259 A new config("ctrl_d") value controls how the ``delete_char'', which
2260 by default is bound to ^D (Control D), will or will not exit calc:
2262 config("ctrl_d", "virgin_eof")
2264 If ^D is the only character that has been typed on a line,
2265 then calc will exit. Otherwise ^D will act according to the
2266 calc binding, which by default is a Emacs-style delete-char.
2268 This is the default mode.
2270 config("ctrl_d", "never_eof")
2272 The ^D never exits calc and only acts according calc binding,
2273 which by default is a Emacs-style delete-char.
2275 Emacs purists may want to set this in their ~/.calcrc startup file.
2277 config("ctrl_d", "empty_eof")
2279 The ^D always exits calc if typed on an empty line. This
2280 condition occurs when ^D either the first character typed,
2281 or when all other characters on the line have been removed
2282 (say by deleting them).
2284 Users who always want to exit when ^D is typed at the beginning
2285 of a line may want to set this in their ~/.calcrc startup file.
2287 Note that config("ctrl_d") apples to the character bound to each
2288 and every ``delete_char''. So if an alternate binding it setup,
2289 then those char(s) will have this functionality.
2291 Updated help/config and help/mode, improved the readability and
2292 fixed a few typos. Documented modes, block formats and block bases
2293 ("mode", "blkfmt" & "blkbase") that were previously left off out of
2296 The config("blkbase") and config("blkfmt") values return strings
2297 instead of returning integers. One cannot use integers to set
2298 these values, so returning integers was useless.
2300 Applied the dangling name fix from Ernest Bowen
2301 <ernie at turing dot une dot edu dot au>.
2303 Show func prints function on order of their indices, and with
2304 config("lib_debug") & 4 == 4 some more details about the functions
2307 Fixed another ``dangling name'' bug for when the object types list
2310 Fixed a bug related to opening to a calc session:
2312 define res_add(a,b) = obj res {r} = {a.r + b.r};
2314 obj res A = {1,2}. obj res B = {3,4}
2316 A hash of an object takes into account the object type. If X and Y
2317 are different kinds of objects but have the same component values,
2318 they will probably return different rather than the same values for
2319 hash(X) and hash(Y).
2321 Added support for config("ctrl_d") to the GNU-readline interface
2322 as written by Klaus Alexander Seistrup <klaus at seistrup dot dk>.
2324 Currently, the config("ctrl_d", "virgin_eof") is not fully
2325 supported. Under GNU-readline, it acts the same way as
2326 config("ctrl_d", "empty_eof"). Emacs users may find this
2327 objectionable as ``hi^A^D^D^D'' will cause calc to exit due to
2328 the issuing of one too many ^D's.
2330 Emacs users may want to put:
2332 config("ctrl_d", "never_eof"),;
2334 into their ~/.calcrc startup files to avoid this problem.
2336 Made misc documentation fixes.
2338 Fixed the make depend rule.
2340 Applied Ernest Bowen's <ernie at turing dot une dot edu dot au>
2341 complex function power(), exp() and transcendental function patch:
2343 Calc will return a "too-large argument" error-value for exp(x,
2344 epsilon) if re(x) >= 2^30 or if an estimate indicates that the
2345 result will have absolute value greater than 2^2^30 * epsilon.
2346 Otherwise the evaluation will be attempted but may fail due to
2347 shortage of memory or may require a long runtime if the result
2350 The power(a, b, epsilon) builtin will return a "too-large result"
2351 if an estimate indicates that the result will have absolute value
2352 that is > 2^2^30 * epsilon. Otherwise the evaluation will be
2353 attempted but may fail due to shortage of memory or may require
2354 a long runtime if the result will be very large.
2356 Changes have been made to the algorithms used for some special
2357 functions sinh(), cosh(), tanh(), sin(), cos(), etc., that make
2358 use of exp(). In particular tanh(x) is now much faster and
2359 doesn't run out of memory when x is very large - the value to
2360 be returned is then 1 to a high degree of accuracy.
2362 When the true value of a transcendental function is 1, as is
2363 cos(x) for x == 0, calc's version of the function will now return
2364 1 rather than the nearest multiple of epsilon. E.g. cos(0, 3/8)
2365 no longer returns 9/8.
2367 The restriction of abs(n) < 1000000 on scale(x, n) has been
2368 removed. The only condition n now has to satisfy for calc to
2369 attempt the operation is n < 2^31, the same as for calc to
2370 attempt x << n and x^n.
2372 Changed root(x,n) so that when x is negative and n is odd it
2373 returns the principal complex n-th root of x rather than -1, e.g.
2374 root(-1,3) now returns -.5+.8660...i.
2376 Changed power(a,b) to permit a to be negative when b is real.
2377 E.g. power(-2,3) will now return 8 rather than cause a "negative
2380 Fixed several improper free and link problems in the comfunc.c code.
2382 Removed BOOL_B64 symbol from Makefile.
2384 The following config values return "true" or "false" strings:
2386 tilde tab leadzero fullzero blkverbose verbose_quit
2388 These config values can still be set with same boolean strings
2389 ("on", "off", "true", "false", "t", ...) as well as via the
2390 numerical values 0 (for "false") and non-0 (for "true"), however.
2392 Added -s to the calc command line. The -s flag will cause unused
2393 args (args after all of the -options on the command line) to remain
2394 as unevaluated strings.
2396 If calc is called with -s, then the new function argv() will return
2397 the number of strings on the command line. Also argv(n) will return
2398 the n-th such string or null is no such string exists.
2400 Calc now handles calc shell scripts. A calc shell script is an
2401 executable file that starts with:
2403 #!/usr/local/bin/calc -S
2405 Where ``/usr/local/bin/calc'' is the path to the calc binary.
2406 Additional -options may be added to the line, but it MUST
2407 start with -S. For example, the executable file ``plus''
2408 contain the following:
2410 #!/usr/local/bin/calc -S -e
2412 * This is a simple calc shell script to add two values
2414 print eval(argv(0)) + eval(argv(1));
2416 then the following command:
2418 ./plus 23 'pi(1e-5)'
2424 If calc is called with -S as the first arg, then calc will assume that
2425 it is being called from a #! calc shell script file. The -S implies
2426 the -s flag. If -i is not given, -S also implies -d and -p.
2428 Fixed the problem with non-literal string type checking for the
2429 C printf-like functions. Able to determine if "%ld" or "%lld"
2430 is appropriate for printing of 64 bit long longs by way of the C
2431 symbol L64_FORMAT in the longlong.h header file.
2433 The following lines are treated as comments by calc:
2435 #! this is a comment
2439 # The lone # above was also a comment
2440 ## is also a comment
2442 Improved how calc makes changes to file descriptor interactive state.
2443 Moved state changing code to calc_tty() and orig_tty() in lib_calc.c.
2444 The libcalc_call_me_last() function will restore all changed descriptor
2445 states that have not already been restored.
2447 Added the following read-only config values:
2449 config("program") path to calc program or calc shell script
2450 config("basename") basename of config("program")
2451 config("version") calc version string
2454 The following are the changes from calc version 2.11.0t8.9.1 to 2.11.0t9.4.5:
2456 The config("verbose_quit") will control the printing of the message:
2458 Quit or abort executed
2460 when a non-interactive ABORT, QUIT or EXIT is encountered. By default,
2461 config("verbose_quit") is TRUE and the message is printed. If one does:
2463 config("verbose_quit", 0)
2465 the message is disabled.
2467 Added 8400 regression test set and test8400.cal to test the new
2468 quit and config("verbose_quit") functionality.
2470 Fixed the BigEndian BASEB==16 regression bugs by correctly swapping
2471 16 bit HALFs in a 64 bit value (such as a 64 bit file pointer).
2473 Added calclevel() builtin to calculation level at which it is called.
2475 Added help/calclevel and help/inputlevel help files.
2477 Removed regression tests 951 and 5984 so that the regress test will
2478 run in non-interactively / without a TTY such as under Debian's
2481 The eval(str) builtin will return an error-value rather than cause
2482 an execution error str has a scan-error.
2484 Declarations are permitted to end with EOF as well as a newline or ';'.
2486 When prompt() occurs while reading a file, it will take input from
2487 the terminal rather than taking it from a file. For example:
2489 /* This demonstrates the use of prompt() and some other things */
2490 config("verbose_quit", 0);
2491 define getnumber() {
2494 x = eval(prompt(">>> "));
2497 print "Not a number! Try again";
2500 print "This will display the sqrt of each number you enter";
2501 print "Enter quit to stop";
2503 print sqrt(getnumber());
2507 Comments entered at input terminal level may be spread over several
2511 * Assume that this calc script is called: comment.cal
2512 * Then these commands now work:
2513 * cat comment.cal | calc
2514 * calc < comment.cal
2520 -D calc_debug[:lib_debug:[user_debug]]
2522 to set the initial value of config("calc_debug"), config("lib_debug")
2523 and config("user_debug").
2525 The : separated strings of -D are interpreted as signed 32 bit values.
2526 After an optional leading sign a leading zero indicates octal
2527 conversion, and a leading ``0x'' or ``0X'' hexadecimal conversion.
2528 Otherwise, decimal conversion is assumed.
2530 Reordered the config structure moving calc_debug ahead of lib_debug.
2532 Added bits 4 and 5 to config("calc_debug"):
2534 4 Report on changes to the state of stdin as well as changes
2535 to internal variables that control the setting and restoring
2538 5 Report on changes to the run state of calc.
2540 Fixed portability issue in seed.c relating to /dev/urandom and ustat.
2542 Added a fix from Martin Buck <mb at netwings dot ch> to detect when
2543 calc aborts early instead of completing the regression test.
2544 Now 'make chk' will require the last line of calc output to
2545 end in the string ``Ending regression tests''.
2547 Added a patch from Martin Buck <mb at netwings dot ch> to allow use of
2548 GNU-readline. Note that GNU-readline is not shipped with calc.
2549 His patch only provides the hooks to use it. One must comment out:
2557 USE_READLINE= -DUSE_READLINE
2558 READLINE_LIB= -lreadline -lhistory
2559 READLINE_INCLUDE= -I/usr/include/readline
2561 in addition to pre-installing GNU-readline in your system to use
2564 Changed the "object already defined" math_error to a scanerror message.
2566 Removed the limit on the number of object types.
2568 Calc tarballs are now named calc-version.tar.gz and untar into
2569 a sub-directory called calc-version.
2571 Made a small change to declarations of static variables to reduce
2572 the internal opcodes needed to declare them.
2574 Fixed a permission problem on ranlib-ed *.a files that was reported
2575 by Michael Somos <somos at grail dot cba dot csuohio dot edu>.
2577 Added patch by Klaus Alexander Seistrup <klaus at seistrup dot dk>
2578 related to GNU-readline:
2580 + enable calc specific bindings in ~/.inputrc
2581 + save a copy of your session to disk and reload them next
2582 time you're using calc
2583 + only add a line to the history if it is different from
2586 Added the Makefile symbol HAVE_GETRUSAGE to determine if the
2587 system supports the getrusage() system call.
2589 Fixed the make depend code in the custom and sample Makefiles.
2591 Fixed how the help/builtin file is formed. The help/Makefile is
2592 now given the name of the native C compiler by the top level Makefile.
2594 The include files are installed under INCDIRCALC (a new Makefile variable)
2595 which by default is ${INCDIR}/calc. The INCDIR (also a new Makefile var)
2596 by default is /usr/local/include. Include files previously installed
2597 directly under ${LIBDIR} will be removed.
2599 Added the piforever() function to lib/pi.cal. It was written by
2600 Klaus Alexander Seistrup <klaus at seistrup dot dk> and was inspired by
2601 an algorithm conceived by Lambert Meertens. (See also the ABC
2602 Programmer's Handbook, by Geurts, Meertens & Pemberton, published
2603 by Prentice-Hall (UK) Ltd., 1990.) The piforever() function prints
2604 digits of pi for as long as your memory and system uptime allows. :-)
2606 Fixed the URLs found thruout the source and documentation which did
2607 not and in /, but should for performance and server load reasons.
2609 Cleaned up and improved handling of "mat" and "obj". The comma in:
2613 is changed to whatever is appropriate in the context:
2616 + separator of arguments in a function call
2617 + separator of arguments in a definition
2620 The expression (mat A[2]), B[3] returns B[3], assuming B already
2621 exists as something created by a statement like: global mat B[4].
2623 What used to be done by the expression:
2627 will now require something like:
2629 mat A[2], mat B[3] or A = mat[2], B = mat[3]
2631 For example, if obj point and obj pair are known types, the
2632 following is now allowed:
2634 L = list(mat[2], mat[3], obj point, obj pair)
2636 As another example, the following is allowed:
2638 define f(a = mat[2] = {3,4}) = 5 * a;
2640 as well as the following:
2642 obj point {x,y}, PP = obj pair {A,B} = {obj point, obj point}
2644 which creates two object types at compile time and when executed,
2645 assigns a pair-object value to a variable PP.
2647 Fixed a bug whereby a for loop would behave incorrectly. For example:
2651 define f() {for ( ; x > 0; x--) {print x;}}
2654 will stop after printing 1 instead of looping forever.
2656 Added values l_format, which when CHECK_L_FORMAT is defined ahead
2657 of including longlong.h will help detect when a system can deal with
2658 'long long' but not '%lld' in printf. If a system with 'long long'
2659 uses '%ld' to print a 64 bit value, then l_format will be > 0;
2660 otherwise if "%lld" is required, l_format will be < 0.
2662 Added HAVE_STRDUP Makefile variable as well as the have_strdup.c
2663 program that forms the have_strdup.h file. The have_strdup.h file
2664 will define HAVE_STRDUP is the system has strdup(). If HAVE_STRDUP
2665 is not defined, then calc will use calc_strdup() to simulate
2666 the real strdup() function.
2668 Calc no longer makes use of sys_errlist and sys_nerr. Some systems
2669 no longer support these values (even though they should from a
2670 legacy prospective). Calc now relies on the fact that strerror()
2671 will return NULL of no such system error exists. System errors >=
2672 10000 will be considered calc errors instead. The Makefile symbol
2673 ERRNO_DECL has gone away as well as calc_errno.c and calc_errno.h.
2675 System errors that are are not known to to the libc strerror()
2676 function, will now print (via the strerror() calc builtin function)
2681 Fixed some insure code inspection tool issues that were discovered
2682 and investigated by Michel van der List <vanderlistmj at sbphrd dot com>.
2684 Made an effort to ensure that the v_subtype of VALUES are initialized
2685 to V_NOSUBTYPE thruout the source code.
2687 Established a separate calc-bugs address from the calc-tester
2688 mailing list. Using anti-spam address forms in order to try and
2689 stay under the radar of spammers as much as one can do so.
2692 The following are the changes from calc version 2.11.0t8 to 2.11.0t8.9:
2694 Moved 'wishlist' enhancements from the help/todo file to a new
2695 help/wishlist file. Ordered, by priority, help/todo items into
2696 Very High, High and Medium priority items.
2698 The BUGS file now has a 'bugs' section as well as a 'mis-features'
2701 Improved how calc internally dealt with reading EOF or '\0' characters.
2703 Calc now allows multiple defines to occur on the same line:
2704 (Thanks goes to Ernest Bowen <ernie at turing dot une dot edu dot au>)
2706 define f8300(x) = x^2; define g8300(x) = 1 - x;
2708 Improved calc's ability to deal with and recover from errors.
2710 Added inputlevel() builtin to return the input processing level.
2711 In an interact mode, inputlevel() returns 0. When directly reading
2712 a calc script, inputlevel() returns 1. When reading a script which
2713 in turn reads another script, inputlevel() returns 2. etc...
2715 If $CALCRC has more than one file as in file1:file2 and an error
2716 occurs in file1, then calc -c will not read file2.
2718 Fixed some of the old EMail addresses found in calc documentation.
2720 Added HAVE_USTAT, HAVE_GETSID, HAVE_GETPGID, HAVE_GETTIME, HAVE_GETPRID
2721 and HAVE_URANDOM symbols to the Makefile. These symbols, along with
2722 have_ustat.c, have_getsid.c, have_getpgid.c, have_gettime.c and
2723 have_getprid.c form: have_ustat.h, have_getsid.h, have_getpgid.h,
2724 have_gettime.h, have_getprid.h and have_urandom.h which in turn
2725 are used by pseudo_seed() in seed.c to determine what types of
2726 system services can be used to form a pseudo-random seed.
2728 Fixed the way calc -c will continue processing $CALCRC when errors
2729 are encountered. Unless -d is also given, calc -c will report
2730 when calc is unable to open a $CALCRC file.
2732 Fixed the lower level make depend rules.
2734 Misc cleanup on the have_*.c support source files.
2736 Misc source file cleanup for things such as } else { style consistency.
2738 Fixed the basis for FNV-1 hashes. Prior to this fix, the hash()
2739 builtin produced FNV hash values that did not match the FNV-1
2740 algorithm as specified in:
2742 http://www.isthe.com/chongo/tech/comp/fnv/index.html
2744 Removed an unused argument in the function getbody() in codegen.c.
2746 Encountering of EOF in getbody() will cause a scanerror rather then
2747 stop activity. This will now result in a scanerror:
2749 echo 'define f(x) { ' > myfile
2752 A '{' at the start of a command and a later matching '}' surrounding zero
2753 or more statements (and possibly newlines) results in a function body to
2754 be "evaluated". This permits another command to follow on the same
2755 line as the '}' as in:
2757 {display(5)} read something;
2759 {static a = 5} define f(x) = a + x;
2761 String constants can now be concatenated. For example:
2763 s = "curds" ' and ' "whey";
2765 Added FNV hash to the regression test suite.
2767 Added Ernest Bowen's <ernie at turing dot une dot edu dot au> fix for the
2768 FNV regression test of the hash() builtin function.
2770 Added Ernest Bowen's <ernie at turing dot une dot edu dot au> patch to
2771 improve the way config("calc_debug"). Now the lower 4 bits of the
2772 config("calc_debug") parameter have the following meaning:
2774 n Meaning of bit n of config("calc_debug")
2776 0 Outputs shell commands prior to execution.
2778 1 Outputs currently active functions when a quit instruction
2781 2 Some details of shs, shs1 and md5 hash states are included
2782 in the output when these are printed.
2784 3 When a function constructs a block value, tests are
2785 made that the result has the properties required for use of
2786 that block, e.g. that the pointer to the start of the
2787 block is not NULL, and that its "length" is not negative.
2788 A failure will result in a runtime error.
2790 Changed the meaning of (config("calc_debug") & 1) from only printing
2791 the shell commands (and pausing) while displaying help files into
2792 the printing of any shell command prior to execution.
2794 Documented the meaning of config("lib_debug"):
2796 n Meaning of bit n of config("lib_debug")
2798 0 When a function is defined, redefined or undefined at
2799 interactive level, a message saying what has been done
2802 1 When a function is defined, redefined or undefined during
2803 the reading of a file, a message saying what has been done
2806 The value for config("lib_debug") in both oldstd and newstd is
2807 3, but if calc is invoked with the -d flag, its initial value
2808 is zero. Thus, if calc is started without the -d flag, until
2809 config("lib_debug") is changed, a message will be output when a
2810 function is defined either interactively or during the reading
2813 Changed the calc lib files to reflect the new config("lib_debug")
2814 bit field meaning. Calc lib files that need to print extra information
2815 should now do something such as:
2817 if (config("lib_debug") & 3) {
2818 print "obj xyz defined";
2819 print "funcA([val1 [, val2]]) defined";
2820 print "funcB(size, mass, ...) defined";
2823 Fixed the help/custom_cal, help/new_custom, and help/copy files so
2824 that they contain the correct contents instead of the 'usage' file.
2826 Fixed problem with loss of bindings when calc -i args runs into
2827 an error while processing 'args' and drops into interactive mode
2828 without the terminal bindings being set.
2830 Added patch from Ernest Bowen to establish the abort command as
2831 well as to clarify the roles of quit and exit. See the help/command
2834 Updated to some extend, the help/statement and help/command help
2835 files with new information about SHOW, QUIT, EXIT and ABORT.
2837 Added show sizes to pzasusb8.cal.
2839 Updated calc man page and help/usage file to reflect recent
2840 command line changes.
2842 Fixed a bug, reported by Michael Somos <somos at grail dot cba dot
2843 csuohio dot edu>, which prevented calc -m from being used.
2845 Fixed misc compiler warnings.
2848 The following are the changes from calc version 2.11.0t7 to 2.11.0t7.5:
2850 Calc has some new command line flags / command line meaning:
2851 (Thanks goes to Ernest Bowen <ernie at turing dot une dot edu dot au>)
2853 -i Go into interactive mode if possible.
2855 -c Continue reading command lines even after an execution
2856 error has caused the abandonment of a line
2858 To understand the -i and -c effects, consider the following
2859 file (call it myfile.cal) which has deliberate errors in it:
2869 Reports an error on the 2nd line and exits; prints 1 only.
2873 Report errors on the 2nd and 4th lines and exits; prints 1,2 and 3.
2877 Report errors on the 2nd and gives you a prompt; prints 1 only.
2879 calc -i -c read myfile
2881 Report errors on the 2nd and 4th and gives you a prompt;
2886 Reports an error on the 2nd line and exits; prints 1 only.
2888 cat myfile | calc -c
2890 Report errors on the 2nd and 4th lines and exits; prints 1,2 and 3.
2892 Note that continuation refers to command lines, not to statements. So:
2894 calc -c 'print "start"; mat A[1] = {2,3}; print "end";'
2896 since it contains no newline, the whole string is compiled,
2897 but execution is abandoned when the error is encountered and
2898 the string ``end'' is not printed.
2900 You can use your shell to supply newlines in your command line
2901 arguments. For example in sh, ksh, bash:
2903 calc -c 'print "start";
2907 will print both ``start'' and ``end''. C-shell users can do:
2909 calc -c 'print "start"; \
2913 however sh, ksh, bash will not see ``end'' printed because their
2914 shell will remove the internal newlines.
2916 Added display(n) builtin which does almost the same as config("display",n)
2917 except that rather than causing an execution with an out-of-range or
2918 bad-type argument type, it simply writes a message to stderr. This
2919 also now happens to the errmax() builtin.
2921 Added qtime.cal to the standard calc library.
2923 Added another command line flag to calc:
2925 -d Disable display of the opening title and config("lib_debug",0)
2929 calc 'read qtime; qtime(2)'
2931 will output something like:
2933 qtime(utc_hr_offset) defined
2934 It's nearly ten past six.
2938 calc -d 'read qtime; qtime(2)'
2942 It's nearly ten past six.
2944 A call of errmax(-1) will prevent errcount from aborting calc.
2946 Add the function stoponerror(n) which, as the name implies, controls
2947 if calc stop on an error based on the value of n:
2949 n > 0 stop on error even if -c was given on the command line
2950 n == 0 if -c, continue, without -c, stop
2951 n < 0 continue on error, even if -c was given on the command line
2953 Calc compilation now stops at the first scanerror.
2955 Restored the feature where -p disables the printing of leading tabs
2956 as of config("tab",0) had been executed. So using calc in a pipe:
2960 will write '19' instead of '\t19' to the whey command.
2962 Updated calc man page and help/usage file to reflect recent
2963 command line changes.
2965 Converted start_done into a general calc run state enum called
2966 run_state within the calc source.
2970 Added the Makefile variable ${LCC} to invoke the local c compiler.
2971 By default, ${CC} also run the ${LCC} compiler. The distinction is
2972 useful when using something such as purify. In the case of ${LCC},
2973 only the local C compiler is invoked. In the case of ${CC} a purify
2974 compile is invoked. Only the source that must be compiled and run
2975 on the local machine use ${LCC}; everything else uses ${CC}.
2977 Fixed memory buffer related problem in eatstring() in token.c.
2979 Fixed memory leaks related to putenv().
2981 Fixed memory leaks related to srandom().
2983 Fixed compilation warnings and problems on BSDI.
2985 Removed ${CCMAIN} as a variable from the Makefile. Now files
2986 use either ${CFLAGS} for general C source and ${ICFLAGS} for
2987 intermediate C source (e.g., special code for building hsrc files).
2989 The main calc URL is now:
2991 http://www.isthe.com/chongo/tech/comp/calc/
2993 Misc calc man page fixes.
2996 The following are the changes from calc version 2.11.0t1 to 2.11.0t6.3:
2998 Removed the makefile symbol MAIN. Now forcing all functions to correctly
2999 be declared main. To satisfy some old broken compilers, a return 0;
3000 (instead of an exit(0);) is used at the end of main().
3002 A few of files that were added to calc used 4 character indentation
3003 whereas most of calc uses 8 character indentation. These imported
3004 sources have been changed to conform better with the calc style.
3006 Added the program calc_errno.c and the Makefile symbol ERRNO_DECL.
3007 If ERRNO_DECL is empty, calc_errno.c will try various ways to
3008 declare errno, sys_errlist and sys_nerr. On success or when
3009 it gives up, calc_errno will output the middle of the calc_errno.h
3010 header file. If ERRNO_DECL is -DERRNO_NO_DECL, or -DERRNO_STD_DECL
3011 or -DERRNO_OLD_DECL then the Makefile will build the middle
3012 of the calc_errno.h header file without calc_errno.c's help.
3014 The func.c file now includes the constructed header file calc_errno.h
3015 to ensure that errno, sys_errlist and sys_nerr are declared correctly.
3017 Changed check.awk to be more 'old awk' friendly.
3019 Made some of the source a little more ++ friendly. We are NOT
3020 porting calc to C++! We will NOT support C++ compilation of calc.
3021 Calc will written ANSI C. We just compiled with a suggestion from
3022 Love-Jensen, John <jlove-jensen at globalmt dot com> to make calc's version
3023 of C a little more to C++ compilers. We are simply avoiding symbols
3024 such as new or try for example.
3026 Renamed README to README.OLD. Renamed README.FIRST to README.
3027 Updated README, lib/README and BUGS to reflect new URLs and addresses.
3029 Added a HOWTO.INSTALL file.
3031 Reordered cc Makefile variable sets in the main Makefile.
3033 Fixed a bug in hnrmod() and applied a fix that was reported by Ernest
3034 Bowen <ernie at turing dot une dot edu dot au>. Added regression tests
3035 1103 to 1112 to confirm the fix.
3037 Fixed a bug in version.c related to MINOR_PATCHs in both the
3038 empty and non-empty MINOR_PATCH cases.
3040 Fixed malloc and bad storage issues reported by Michel van der List
3041 <vanderlistmj at sbphrd dot com>.
3043 Fixed some problems related to path processing while opening files.
3044 Under extreme cases, an excessively long filename or CALCPATH value
3045 could create problems. Placed guards in opensearchfile() function
3046 in input.c to catch these cases.
3048 Fixed cases were malloc failures were silently ignored in input.c.
3050 Eliminated the PATHSIZE limit and the PATHSIZE symbol.
3052 Added MAX_CALCRC to limit the length of the $CALCRC environment
3053 variable to 1024 chars.
3055 Fixed the magic number relating to the initial number of constants
3056 declared by initconstants(). It is now related to the length
3057 of the initnumbs[] NUMBER array.
3059 Added a 'Dec Alpha / Compaq Tru64 cc (non-gnu) compiler set'
3060 section to the main Makefile.
3062 Fixed a string handling bug discovered by Dr.D.J.Picton
3063 <dave at aps5 dot ph dot bham dot ac dot uk> in the custom demo code.
3065 Fixed a bug in the hnrmod() builtin that was discovered by
3066 Ernest Bowen <ernie at turing dot une dot edu dot au>.
3068 Added FORCE_STDC symbol. When defined it will force __STDC__ like
3069 conditions. Thus for compilers with as the Solaris cc compiler
3070 that are ANSI-like but still define __STDC__ as 0, one can use
3071 -DFORCE_STDC and make use of ANSI-like features.
3073 Removed the CCSHS symbol from the Makefile. The shs.c and shs1.c
3074 files are now compiled with full ${CFLAGS}.
3076 The custom.c file is now compiled with full ${CFLAGS}.
3078 Rewrote command line / argument processing code. Calc is now
3079 using getopt(3) argument processing.
3081 Fixed a memory leak related to converting strings to numbers
3082 in the str2q() function in qio.c.
3084 Fixed a problem with reading uninitialized memory in the
3085 v_subtype of a VALUE in the copyvalue() function in value.c.
3087 Fixed problems in func.c where temporary VALUEs were not
3088 having their v_type elements initialized.
3090 Fixed a memory leak in qpi() in qtrans.c.
3092 Fixed a memory leak in math_getdivertedio() in zio.c.
3094 Fixed a problem with points going beyond the end of allocated
3095 memory in addstring() in string.c.
3097 Fixed a memory leak in zgcdrem(), f_putenv(), zlog() and
3098 zlog10() in zfunc.c.
3100 Fixed a memory leak in zdiv() and zshift() in zmath.c.
3102 Fixed memory leaks in zsrand() in zrand.c.
3104 Fixed a memory leak in zsrandom1() in zrandom.c. Fixed memory
3105 leaks associated with replacing the internal random state with
3106 another random state.
3108 Added seed() builtin to return a 64 bit seed for a
3109 pseudo-random generator.
3111 Added functionality from Ernest Bowen <ernie at turing dot une dot
3112 edu dot au> to permit nested "= {...}" assignments for lists as well
3113 as matrices and objects. Now one can have a list, matrix or object,
3114 some of whose elements are lists, matrices or objects, to any depth
3115 of recursion, and assign values to any number of particular elements
3116 by an appropriate "initialization" expression. For example:
3118 A = mat[2] = {list(1,2), list(3,4,list(5,6))};
3120 and then assign values to the 6 number elements by:
3122 A = {{7,8}, {9,10,{11,12}}};
3124 Closed files that were previously left open from test4600.cal
3125 as executed by regress.cal and from opening /dev/null by
3128 Fixed memory leaks from f_strprintf() and f_putenv() in func.c.
3130 The regress.cal test suite calls freeredc(), freestatics() and
3131 freeglobals() at the end of the test suite to free storage
3132 consumed during the regression.
3134 Added custom function custom("pzasusb8", n) and lib/pzasusb8.cal based on
3135 Ernest Bowen's diagnostic patch.
3137 Thanks to the efforts of Ernest Bowen <ernie at turing dot une dot
3138 edu dot au> and Dr.D.J.Picton <dave at aps5 dot ph dot bham dot ac
3139 dot uk>, a nasty endian-ness bug in the sha and sha1 hash functions
3140 that showed up on machines such as the Sparc was fixed.
3142 Added functionality from Ernest Bowen <ernie at turing dot une
3143 dot edu dot au> to give arguments as well as function names after
3144 definitions when config("lib_debug") >= 0.
3146 Removed if (config("lib_debug") >= 0) { ... } the ends of most
3147 of the calc library scripts because it was redundant with the
3148 new config("lib_debug") >= 0 functionality. Some of the calc
3149 library still has a partial section because some useful
3150 additional information was being printed:
3152 chrem.cal deg.cal lucas_tbl.cal randrun.cal
3153 mfactor.cal mod.cal poly.cal seedrandom.cal
3154 surd.cal varargs.cal
3156 Fixed ellip.cal so that its defined function does not conflict with
3157 the factor() builtin function.
3159 Fixed mod.cal so that a defined function does not conflict with
3160 the mod() builtin function.
3162 The regression test suite now reads in most calc libs. A few
3163 libs are not read because they, by design, produce output
3164 when read even when config("lib_debug") is set to -1.
3166 Increased the maximum number of object types that one can define
3169 Added a patch from Ernest Bowen <ernie at turing dot une dot edu
3170 dot au> to correctly hash a V_STR value-type that has an \0 byte
3173 A patch from Ernest Bowen <ernie at turing dot une dot edu dot au> now
3174 defines special meaning to the first 2 bits of config("lib_debug"):
3176 bit 0 set => messages printed when inputisterminal
3177 bit 1 set => messages printed when reading from a file
3179 The lib/regress.cal regression suite does:
3181 config("lib_debug", -4);
3183 to eliminate lib messages (both bit 0 and bit 1 are not set).
3185 Fixed misc compile warnings and notices.
3188 The following are the changes from calc version 2.10.3t5.38 to 2.11.0t0:
3190 Fixed a few compile problems found under Red Hat 6.0 Linux.
3193 The following are the changes from calc version 2.10.3t5.38 to 2.11.3t5.46:
3195 Fixed a bug discovered by Ernest Bowen related to matrix-to-matrix copies.
3197 Bitwise operations on integers have been extended so that negative
3198 integers are treated in the same way as the integer types in C.
3200 Some changes have been made to lib/regress.cal and lib/natnumset.cal.
3202 Removed V_STRLITERAL and V_STRALLOC string type constants and
3203 renumbered the V_protection types.
3205 Added popcnt(x, bitval) builtin which counts the number of
3206 bits in x that match bitval.
3208 Misc compiler warning fixes.
3210 Fixed improper use of putchar() and printf() when printing rationals
3213 Fixed previously reported bug in popcnt() in relation to . values.
3215 Calc man page changes per suggestion from Martin Buck
3216 <Martin-2.Buck at student dot uni-ulm dot de>. The calc man page is
3217 edited with a few more parameters from the Makefile.
3219 Misc Makefile changes per Martin Buck <Martin-2.Buck at student dot
3222 Removed trailing blanks from files.
3224 Consolidated in the Makefile, where the debug and check rules are found.
3225 Fixed the regress.cal dependency list.
3227 Make chk and check will exit with an error if check.awk detects
3228 a problem in the regression output. (Martin Buck)
3230 Fixed print line for test #4404.
3232 Moved custom.c and custom.h to the upper level to fix unresolved symbols.
3234 Moved help function processing into help.c.
3236 Moved nearly everything into libcalc.a to allow programs access to
3237 higher level calc objects (e.g., list, assoc, matrix, block, ...).
3239 Renamed PATCH_LEVEL to MAJOR_PATCH and SUB_PATCH_LEVEL to MINOR_PATCH.
3240 Added integers calc_major_ver, calc_minor_ver, calc_major_patch
3241 and string calc_minor_patch to libcalc.a. Added CALC_TITLE to hold
3242 the "C-style arbitrary precision calculator" string.
3244 The function version(), now returns a malloced version string
3247 Consolidated multiple SGI IRIX -n32 sections (for r4k, r5k and r10k)
3248 into a single section.
3251 The following are the changes from calc version 2.10.3t5.34 to 2.10.3t5.37:
3253 Per request from David I Bell, the README line:
3255 I am allowing this calculator to be freely distributed for personal uses
3259 I am allowing this calculator to be freely distributed for your enjoyment
3261 Added help files for:
3263 address agd arrow dereference free freeglobals freeredc freestatics
3264 gd isptr mattrace oldvalue saveval & * -> and .
3266 Fixed blkcpy() and copy() arg order and processing. Now:
3268 A = blk() = {1,2,3,4}
3273 will result in B being twice as long as A.
3275 Since "make chk" pipes the regression output to awk, we cannot
3276 assume that stdout and stderr are ttys. Tests #5985 and #5986
3277 have been removed for this reason. (thanks to Martin Buck
3278 <Martin-2.Buck at student dot uni-ulm dot de> for this report)
3280 Fixed the order of prints in regress.cal. By convention, a print
3281 of a test line happens after the test. This is because function
3282 parsed messages occur after the function is parsed. Also the
3283 boolean test will verify before any print statements. Therefore
3284 a non-test line is tested and printed as follows:
3287 print '7125: y = sha()';
3289 The perm(a,b) and comb(a,b) have been extended to arbitrary real a and
3292 Fixed a bug in minv().
3294 Moved string.c into libcalc.a.
3296 The NUMBER union was converted back into a flat structure. Changes
3297 where 'num' and 'next' symbols were changed to avoid #define conflicts
3298 were reverse since the #define's needed to support the union went away.
3300 Removed trailing blanks from files.
3302 Ernest Bowen <ernie at turing dot une dot edu dot au> sent in the
3303 following patch which is described in the next 34 points:
3307 A = B = strcat("abc", "def");
3309 would store "abc" and "def" as literal strings never to be freed, and
3310 store "abcdef" once each for both A and B. Now the "abc" and "bcd"
3311 are freed immediately after they are concatenated and "abcdef" is stored
3312 only once, just as the number 47 would be stored only once for
3316 The new STRING structure that achieves this stores not only the
3317 address of the first character in the string, but also the "length"
3318 with which the string was created, the current "links" count, and
3319 when links == 0 (which indicates the string has been freed) the
3320 address of the next freed STRING. Except for the null string "",
3321 all string values are "allocated"; the concept of literal string
3322 remains for names of variables, object types and elements, etc.
3324 (1) strings may now include '\0', as in A = "abc\0def". In normal printing
3325 this prints as "abc" and strlen(A) returns 3, but its "real" length
3326 of 7 is given by size(A). (As before there is an 8th zero character
3327 and sizeof(A) returns 8.)
3329 (2) If A is an lvalue whose current value is a string of size n, then
3330 for 0 <= i < n, A[i] returns the character with index i as an addressed
3331 octet using the same structure as for blocks, i.e. there is no
3332 distinction between a string-octet and a block-octet. The same
3333 operations and functions can be used for both, and as before, an octet
3334 is in some respects a number in [0,256) and in others a one-character
3335 string. For example, for A = "abc\0def" one will have both A[0] == "a"
3336 and A[0] == 97. Assignments to octets can be used to change
3337 characters in the string, e.g. A[0] = "A", A[1] = 0, A[2] -= 32,
3338 A[3] = " " will change the above A to "A\0C def".
3340 (3) "show strings" now displays the indices, links, length, and some or all
3341 of the early and late characters in all unfreed strings which are values
3342 of lvalues or occur as "constants" in function definitions,
3343 using "\n", "\t", "\0", "\252", etc. when appropriate. For example,
3344 the string A in (1) would be displayed as in the definition there.
3345 Only one line is used for each string. I've also changed the
3346 analogous "show numbers" so that only some digits of numbers that
3347 would require more than one line are displayed.
3349 (4) "show literals" is analogous to "show constants" for number "constants"
3350 in that it displays only the strings that have been introduced by
3351 literal strings as in A = "abc". There is a major difference between
3352 strings and numbers in that there are operations by which characters
3353 in any string may be changed. For example, after A = "abc",
3354 A[0] = "X" changes A to "Xbc". It follows that if a literal string
3355 is to be constant in the sense of never changing, such a character-
3356 changing operation should never be applied to that string.
3358 In this connection, it should be noted that if B is string-valued, then
3362 results in A referring to exactly the same string as B rather than to
3363 a copy of what is in B. This is like the use of character-pointers in
3370 To achieve the effect of
3372 s2 = (char *) malloc(4);
3375 I have extended the str() function to accept a string as argument. Then
3379 will create a new string at a different location from that of B but
3380 with the same length and characters. One will then have A == B,
3381 *A == *B, but &*A != &*B, &A[0] != &B[0].
3383 To assist in analyzing this sort of thing, I have defined a links()
3384 function which for number or string valued argument returns the number
3385 of links to the occurrence of that argument that is being referred to.
3386 For example, supposing "abc" has not been used earlier:
3394 The two links in the first call are to A and the current "oldvalue";
3395 in the second call, the only link is to A, the oldvalue now being 2.
3398 (5) strcat(S1, S2, ...) works as before; contribution of a string stops when
3399 '\0' is encountered. E.g.
3401 strcat("abc\0def", "ghi")
3403 will return "abcghi".
3405 (6) For concatenation of full strings I have chosen to follow
3406 some other languages (like Java, but not Mathematica which uses "<>")
3407 and use "+" so that, e.g.
3411 returns the string "abc\0defghi". This immediately gives obvious
3412 meanings to multiplication by positive integers as in
3414 2 * "abc" = "abc" + "abc" = "abcabc",
3416 to negation to reverse as string as in
3420 to multiplication by fractions as in
3422 0.5 * "abcd" = "ab",
3424 (where the length is int(0.5 * size("abcd")), and finally, by combining
3429 for any real number k and any string A. In the case of k == 1, these
3430 return a new string rather than A itself. (This differs from
3431 "" + A and A + "" which return A.)
3433 (7) char(x) has been changed so that it will accept any integer x or octet
3434 as argument and return a string of size one with character value
3435 x % 256. In the past calc has required 0 <= x < 256; now negative
3436 x is acceptable; for example, 1000 * char(-1) will now produce the
3437 same as 1000 * "\377" or 1000 * "\xff".
3439 (8) For a string s, test(s) now returns zero not only for the null string
3440 "" but also for a string all of whose characters are '\0'.
3442 (9) Similarly <, <=, etc. now compare all characters including occurrences
3443 of '\0' until a difference is encountered or the end of a string is
3444 reached. If no difference is encountered but one string is longer than
3445 the other, the longer string is considered as greater even if the
3446 remaining characters are all '\0'.
3448 (10) To retain the C sense of comparison of null-terminated strings I have
3449 defined strcmp(S1, S2), and then, for completeness, strncmp(S1, S2, n).
3450 For similar reasons, strcpy(S1, S2) and strncpy(S1, S2, n) have been
3453 (11) For strings, I have defined | and & as bitwise "or" and "and"
3454 functions, with S1 | S2 having the size of the larger of S1 and S2,
3455 S1 & S2 having the size of the smaller of S1 and S2. By using, say,
3456 4-character strings, one can simulate a C integral type so far as the
3457 | and & operations are concerned. It then seemed appropriate to
3458 use the operator ~ for a "bitwise complement" as in C. Thus I have
3459 defined ~s for a string s to be the string of the same size as s
3460 with each character being complemented by the C ~ operation.
3462 (12) For boolean algebra work on strings it is convenient also to have
3463 the bitwise xor and setminus binary operations. Using C's '^' for xor
3464 would be confusing when this is used elsewhere for powers, so I
3465 decided to use ~. For setminus, I adopted the commonly used '\'.
3466 Strings of fixed size n can now be used for a boolean algebra
3467 structure with 8 * n elements. The zero element is n * char(0),
3468 the unity is n * char(-1), and one have all of the usual laws like
3469 A & (B | C) == A & B | A * C, A \ B = A & ~B, etc.
3471 (13) Having extended the bitwise operations for strings, it was appropriate
3472 to do the same for integers. Definitions of the binary ~ and \
3473 operations for non-negative integers are straightforward. For
3474 the unary ~ operation, I decided to do what C does with integer
3475 types, and defined ~N to be -N - 1. With the appropriate extensions of
3476 |, &, \ and the binary ~, one gets in effect the boolean algebra of
3477 finite sets of natural numbers and their complements, by identifying
3478 the set with distinct integer elements i_1, i_2, ... with the integer
3482 For ~N for non-integer real N, I have simply used -N. There is some
3483 logic in this and it is certainly better than an error value.
3484 I have not defined the binary operations |, &, ~, \ for non-integral
3487 The use of ~N in this way conflicts with calc's method of displaying
3488 a number when it has to be rounded to config("display") decimals.
3489 To resolve this, my preference would be to replace the printing of
3490 "~" as a prefix by a trailing ellipsis "...", the rounding always
3491 being towards zero. E.g. with config("display", 5), 1/7 would print
3492 as ".14285..." rather than "~.14285". The config("outround")
3493 parameter would determine the type of rounding only for the
3494 equivalent of config("tilde", 0).
3496 (14) For objects, users may create their own definitions for binary |,
3497 &, ~ and \ with xx_or, xx_and, xx_xor, xx_setminus functions.
3498 For unary ~ and \ operations, I have used the names xx_comp and
3501 (15) For the obviously useful feature corresponding to cardinality of a
3502 set, I have defined #S for a string S to be the number of nonzero bits
3503 in S. For a degree of consistency, it was then appropriate to
3504 define #N for a nonnegative integer N to be the number of nonzero bits
3505 in the binary representation of N. I've extended this to arbitrary
3506 real N by using in effect #(abs(num(N))). I feel it is better to make
3507 this available to users rather than having #N invoke an error message
3508 or return an error value. For defining #X for an xx-object X, I
3509 have used the name xx_content to suggest that it is appropriate for
3510 something which has the sense of a content (like number of members of,
3513 (16) Having recognized # as a token, it seemed appropriate to permit its
3514 use for a binary operation. For real numbers x and y I have defined
3515 x # y to be abs(x - y). (This is often symbolized by x ~ y, but it
3516 would be confusing to have x ~ y meaning xor(x,y) for strings and
3517 abs(x-y) for numbers.) Because '#' is commonly called the hash symbol,
3518 I have used xx_hashop to permit definition of x # y for xx-objects.
3520 (17) For a similar reason I've added one line of code to codegen.c so that
3521 /A returns the inverse of A.
3523 (18) Also for a list L, +L now returns the sum of the elements of L. For
3524 an xx object A, +A requires and uses the definition of xx_plus.
3526 (19) I have given the unary operators ~, #, /, \, and except at the
3527 beginning of an expression + and -, the same precedence with
3528 right-to-left associativity. This precedence is now weaker than
3529 unary * and &, but stronger than binary & and the shift and power
3530 operators. One difference from before is that now
3534 evaluates as a ^ (- (b ^ c)) rather than a ^ ((- b) ^ c).
3537 (20) For octets o1, o2, I've defined o1 | o2, o1 & o2, o1 ~ o2, ~o1 so
3538 that they return 1-character strings. #o for an octet o returns the
3539 number of nonzero bits in o.
3541 (21) For substrings I've left substr() essentially as before, but
3542 for consistency with the normal block/matrix indexing, I've extended
3543 the segment function to accept a string as first argument. Then
3547 returns essentially the string formed from the character with index m
3548 to the character with index n, ignoring indices < 0 and indices >=
3549 len(A); thus, if m and n are both in [0, size(A))
3550 the string is of length abs(m - n) + 1, the order of the characters
3551 being reversed if n < m. Here the indices for a list of size len are
3552 0, 1, ..., len - 1. As it makes some sense, if 0 <= n < size(A),
3556 now returns the one-character string with its character being that with
3557 index n in A. (I've made a corresponding modification to the segment
3558 function for lists.) Some examples, if A = "abcdef",
3560 segment(A,2,4) = "cde",
3562 segment(A,4,2) = "edc",
3566 segment(A, -2, 8) = "abcdef",
3568 segment(A,7,8) = "".
3570 (22) As essentially particular cases of segment(), I've defined
3571 head(A, n) and tail(A, n) to be the strings formed by the first
3572 or last abs(n) characters of A, the strings being4]5O~? reversed '
3573 if n is negative. I've changed the definitions of head and tail for
3574 lists to be consistent with this interpretation of negative n.
3576 (23) Similarly I've left strpos essentially as at present, but search
3577 and rsearch have been extended to strings. For example,
3581 returns the index i of the first occurrence of the string B in A
3582 if m <= i < n, or the null value if there is no such occurrence.
3583 As for other uses of search, negative m is interpreted as
3584 size(A) + m, negative n as size(A) + n. For a match in this
3585 search, all size(B) characters, including occurrences of '\0',
3586 in B must match successive characters in A.
3588 The function rsearch() behaves similarly but searches in reverse order
3591 (24) A string A of length N determines in obvious ways arrays of M = 8 * N
3592 bits. If the characters in increasing index order are c_0, c_1, ...
3593 and the bits in increasing order in c_i are b_j, b_j+1, ..., b_j+7
3594 where j = 8 * i, I've taken the array of bits determined by A to be
3596 b_0, b_1, ..., b_M-1
3598 For example, since "a" = char(97) and 97 = 0b01100001, and
3599 "b" = char(98) = 0b01100010, the string "ab" determines the 16-bit
3604 in which the bits in the binary representations of "a" and "b" have
3607 bit with index n in this array. This is consistent with the use of
3608 bit for a number ch in [0,256), i.e. bit(char(ch), n) = bit(ch, n).
3609 For n < 0 or n >= size(A), bit(A,n) returns the null value.
3611 (25) For assigning values to specified bits in a string, I've defined
3612 setbit(A, n) and setbit(A, n, v). The first assigns the value 1 to
3613 bit(A, n), the second assigns test(v) to bit(A, n).
3615 (26) For consistency with the corresponding number operations, the shift
3616 operations A << n and A >> n have been defined to give what look
3617 like right- and left-shifts, respectively. For example, "ab" << 2
3618 returns the 16-bit array
3622 in which the array for "ab" has been moved 2 bits to the right.
3624 (27) To achieve much the same as the C strcpy and strncpy functions for
3625 null-terminated strings, strcpy(S1, S2) and strncpy(S1, S2, n) have
3626 been defined. Unlike the blkcpy() and copy() functions, the copying
3627 for these is only from the beginning of the strings. Also, unlike C,
3628 no memory overflow can occur as the copying ceases when size(S1) is
3629 reached. Note that these overwrite the content of S1 (which affects
3630 all strings linked to it) as well as returning S1. Examples:
3632 S = strcpy(6 * "x", "abc") <=> S = "abc\0xx"
3634 S = strcpy(3 * "x", "abcdef") <=> S = "abc"
3636 S = strncpy(6 * "x", "abcd", 2) <=> S = "ab\0xxx"
3638 S = strncpy(6 * "x", "ab", 4) <=> S = "ab\0\0xx"
3640 S = strncpy(6 * "x", "ab", 20) <=> S = "ab\0\0\0\0"
3642 If a new string S not linked to S1 is to be created, this can be
3643 achieved by using str(S1) in place of S1. For example, the strcpy in
3646 S = strcpy(str("xxxxxx"), "abc")
3648 would not change the value of A.
3650 (28) I've extended the definitions of copy(A, B, ssi, num, dsi) and
3651 blkcpy(B, A, num, ssi, dsi) to allow for string-to-string copying
3652 and block-to-string copying, but num is now an upper bound for the
3653 number of characters to be copied - copying will cease before num
3654 characters are copied if the end of the data in the source A or the
3655 end of the destination B is reached. As with other character-changing
3656 operations, copying to a string B will not change the locations of
3657 B[0], B[1], ... or the size of B.
3659 In the case of copying a string to itself, characters are copied in
3660 order of increasing index, which is different from block-to-block
3661 copying where a memmove is used. This affects only copy from a
3662 string to itself. For example,
3667 will result in A == "abababa". If the overwriting that occurs here
3668 is not wanted, one may use
3671 copy(str(A), A, , , 2);
3673 which results in A == "ababcde".
3675 (29) perm(a,b) and comb(a,b) have been extended to accept any real a and
3676 any integer b except for perm(a, b) with integer a such that b <= a < 0
3677 which gives a "division by zero" error. For positive b, both functions
3678 are polynomials in a of degree b; for negative b, perm(a,b) is a
3679 rational function (1/((a + 1) * (a+2) ...) with abs(b) factors in the
3680 denominator), and comb(a,b) = 0. (An obvious "todo" is to extend this
3681 to complex or other types of a.)
3683 (30) Although it is not illegal, it seems pointless to use a comma operator
3684 with a constant or simple variable as in
3693 I have added a few lines to addop.c so that when this occurs a
3694 "unused value ignored" message and the relevant line number are
3695 displayed. I have found this useful as I occasionally type ','
3698 There may be one or two other changes resulting from the way I have
3699 rewritten the optimization code in addop.c. I think there was a bug
3700 that assumed that PTR_SIZE would be the same as sizeof(long). By
3701 the way, the new OP_STRING is now of index rather than pointer type.
3702 It follows that pointers are now used in opcodes only for global
3703 variables. By introducing a table of addresses of global variables
3704 like those used for "constants" and "literal strings", the use of
3705 pointers in opcodes could be eliminated.
3707 (31) When calc has executed a quit (or exit) statement in a function or
3708 eval evaluation, it has invoked a call to math_error() which causes
3709 a long jump to an initial state without freeing any data on the
3710 stack, etc. Maybe more detail should be added to math_error(), but
3711 to achieve the freeing of memory for a quit statement and at the same
3712 time give more information about its occurrence I have changed the
3713 way opcodes.c handles OP_QUIT. Now it should free the local variables
3714 and whatever is on the stack, and display the name and line-number,
3715 for each of the functions currently being evaluated. The last
3716 function listed should be the "top-level" one with name "*".
3717 Strings being eval-ed will have name "**".
3723 ; define f(x) {local i = x^2; a++;
3724 ;; if (x > 5) quit "Too large!"; return i;}
3726 ; define g(x) = f(x) + f(2*x);
3744 (32) I've made several small changes like removing
3746 if (vp->v_type == V_NUM) {
3747 q = qinv(vp->v_num);
3748 if (stack->v_type == V_NUM)
3749 qfree(stack->v_num);
3751 stack->v_type = V_NUM;
3755 from the definition of o_invert. Presumably these lines were intended
3756 to speed up execution for the common case of numerical argument.
3757 Comparing the runtimes with and without these lines for inverting
3758 thousands of large random numbers in a matrix suggest that execution
3759 for real numbers is slightly faster without these lines.
3761 Maybe this and other similar treatment of "special cases" should be
3762 looked at more closely.
3764 (33) The new lib script lib/natnumset.cal demonstrates how the new
3765 string operators and functions may be used for defining and
3766 working with sets of natural numbers not exceeding a
3767 user-specified bound.
3770 The following are the changes from calc version 2.10.3t5.28 to 2.10.3t5.33:
3772 Added hnrmod(v, h, n, r) builtin to compute:
3774 v % (h * 2^n + r), h>0, n>0, r = -1, 0 or 1
3776 Changed lucas.cal and mersenne.cal to make use of hnrmod().
3778 A number of changes from Ernest Bowen:
3780 (1) introduction of unary & and * analogous to those in C;
3782 For an lvalue var, &var returns what I call a
3783 value-pointer; this is a constant which may be assigned to
3784 a variable as in p = &var, and then *p in expressions has
3785 the same effect as var. Here is a simple example of their use:
3787 ; define s(L) {local v=0; while (size(L)) v+= *pop(L);return v;}
3789 ; global a = 1, b = 2;
3797 Octet-pointers, number-pointers, and string-pointers in
3798 much the same way, but have not attempted to do much with
3801 To print a pointer, use the "%p" specifier.
3803 Some arithmetic operations has been defined for corresponding
3804 C operations. For example:
3812 There is at present no protection against "illegal" use of &
3813 and *, e.g. if one attempts here to assign a value to *(p+5),
3814 or to use p after assigning another value to A.
3816 NOTE: Unlike C, in calc &A[0] and A are quite different things.
3818 NOTE: If the current value of a variable X is an octet,
3819 number or string, *X may be used to to return the value of
3820 X; in effect X is an address and *X is the value at X.
3822 Added isptr(p) builtin to return 0 is p is not a pointer,
3823 and >0 if it is a pointer. The value of isptr(p) comes from
3824 the V_XYZ #define (see the top of value.h) of the value to
3827 To allow & to be used as a C-like address operator, use of it
3828 has been dropped in calls to user-defined functions. For the
3829 time being I have replaced it by the back-quote `. For example:
3832 ; define f(a,b) = a = b
3840 However, one may use & in a similar way as in:
3842 ; define g(a,b) = *a = b
3847 There is no hashvalue for pointers. Thus, like error values,
3848 they cannot be used as indices in an association.
3850 The -> also works in calc. For example:
3855 ; obj uvw B = {3,4,5}
3867 obj xy {1, v-ptr: 1400474c0}
3875 obj xy {1, v-ptr: 140047490}
3884 obj xy {8, v-ptr: 140047490}
3887 (2) a method of "protecting" variables;
3889 For the various kinds of "protection", of an l_value var,
3890 bits of var->v_subtype, of which only bits 0 and 1 have been
3891 used in the past to indicate literal and allocated strings.
3892 This has meant initialization of var->v_subtype when a new var
3893 is introduced, and for assignments, etc., examination of the
3894 appropriate bits to confirm that the operation is to be permitted.
3896 See help/protect for details.
3898 (3) automatic "freeing" of constants that are no longer required.
3900 For the "freeing" of constants, the definition of a NUMBER
3901 structure so that a NUMBER * q could be regarded as a
3902 pointing to a "freed number" if q->links = 0.
3904 The old q->num was changed to a union q->nu which had a pointer
3905 to the old q->num if q->links > 0 and to the next freed number
3906 if q->links = 0. The old "num" is #defined to "nu->n_num".
3908 The prior method calc has used for handling "constants" amounted
3911 ; define f(x) = 27 + x;
3914 It is of course necessary for the constant 27 to be stored, but
3915 if one now redefines f and a by:
3917 ; define f(x) = 45 + x;
3920 There seems little point in retaining 27 as a constant and
3921 therefore using up memory. If this example seems trivial,
3922 replace 27 with a few larger numbers like 2e12345, or better,
3923 -2e12345, for which calc needs memory for both 2e12345 and
3926 Constants are automatically freed a definition when a
3927 function is re- or un-defined.
3929 The qalloc(q) and qfree(q) functions have been changed so
3930 that that q->links = 0 is permitted and indicates that q
3931 has been freed. If a number has been introduced as a
3932 constant, i.e. by a literal numeral as in the above
3933 examples, its links becoming zero indicates that it is no
3934 longer required and its position in the table of constants
3935 becomes available for a later new constant.
3937 (4) extension of transcendental functions like tan, tanh, etc.
3938 to complex arguments
3940 (5) definition of gd(z) and agd(z), i.e. the gudermannian and
3941 inverse gudermannian
3943 (6) introduction of show options for displaying information about
3944 current constants, global variables, static variables, and cached
3947 To help you follow what is going on, the following show
3948 items have been introduced:
3950 show constants ==> display the currently stored constants
3951 show numbers ==> display the currently stored numbers
3952 show redcdata ==> display the currently stored redc moduli
3953 show statics ==> display info about static variables
3954 show real ==> display only real-valued variables
3956 The constants are automatically initialized as constants and
3957 should always appear, with links >= 1, in in the list of constants.
3963 has been redefined so that it gives information about all
3964 current global and still active static variables.
3966 (7) definition of functions for freeing globals, statics, redc values
3968 To free memory used by different kinds of variable, the following
3969 builtins have been added:
3971 freeglobals(); /* free all globals */
3972 freestatics(); /* free all statics */
3973 freeredc(); /* free redc moduli */
3974 free(a, b, ...); /* free specific variables */
3976 NOTE: These functions do not "undefine" the variables, but
3977 have the effect of assigning the null value to them, and so
3978 frees the memory used for elements of a list, matrix or object.
3980 See 10) below for info about "undefine *".
3982 (8) enhancement of handling of "old value": having it return an
3983 lvalue and giving option of disabling updating.
3985 Now, by default, "." return an lvalue with the appropriate
3986 value instead of copying the old value.
3988 So that a string of commands may be given without changing
3989 the "oldvalue", the new builtin:
3993 function simply disables the updating of the "." value.
3994 The default updating can be resumed by calling:
4005 can now be treated as an unnamed variable. For example:
4007 ; mat x[3,3]={1,2,3,4,5,6,7,8,9}
4012 (9) for a list L defining L[i] to be same as L[[i]]
4014 (10) extending undefine to permit its application to all user-defined
4015 functions by using "undefine *".
4021 undefines all current user-defined functions. After
4022 executing all the above freeing functions (and if
4023 necessary free(.) to free the current "old value"), the
4024 only remaining numbers as displayed by:
4028 should be those associated with epsilon(), and if it has been
4031 (11) storing the most recently calculated value of qpi(epsilon)i and
4032 epsilon so that when called again with the same epsilon it
4033 is copied rather than recalculated.
4035 (12) defining trace() for square matrices
4037 (13) expression in parentheses may now be followed by a qualifier
4038 computable with its type
4040 When an expression in parentheses evaluates to an lvalue
4041 whose current value is a matrix, list or object, it may
4042 now be followed by a qualifier compatible with its type.
4047 ; B = mat[2,2] = {5,6,7,8};
4048 ; define f(x) = (x ? A : B)[[1]];
4053 ; C = obj xy = {4,5}
4056 Not indexing matrix or object
4060 (14) swap(a,b) now permits swapping of octets in the same or different
4065 ; A = blk() = {1,2,3}
4066 ; B = blk() = {4,5,6}
4069 chunksize = 256, maxsize = 256, datalen = 3
4072 A few bug fixes from Ernest Bowen:
4074 B1: qcmpi(q, n) in qmath.c sometimes gave the wrong result if
4075 LONG_BITS > BASEB, len = 1 and nf = 0, since it then
4076 reduces to the value of (nf != q->num.v[1]) in which
4077 q->num.v[1] is not part of the size-1 array of HALFs for
4078 q->num. At present this is used only for changing opcodes
4079 for ^2 and ^4 from sequences involving OP_POWER to
4080 sequences using OP_SQUARE, which has no effect on the
4081 results of calculations.
4083 B2: in matdet(m) in matfunc.c, a copy of the matrix m was not freed
4084 when the determinant turned out have zero value.
4086 B3: in f_search() in func.c, a qlinking of the NUMBER * storing the
4087 the size of a file was not qfreed.
4089 B4: in comalloc() in commath.c the initial zero values for real and
4090 imag parts are qlinked but not qfreed when nonzero values are
4091 assigned to them. Rather than changing
4092 the definition of comalloc(), I have included any relevant
4093 qfrees with the calls to comalloc() as in
4098 B5: in calls to matsum(), zeros are qlinked but not qfreed. Rather
4099 than changing addnumeric(), I have changed the definition
4100 of matsum(m) so that it simply adds the components of m,
4101 which requires only that the relevant additions be defined,
4102 not that all components of m be numbers.
4105 Simple arithmetic expressions with literal numbers are evaluated
4106 during compilation rather than execution. So:
4108 define f(x) = 2 + 3 + x;
4110 will be stored as if defined by:
4112 define f(x) = 5 + x;
4114 Fixed bug with lowhex2bin conversation in lib_util.c. It did not
4115 correctly convert from hex ASCII to binary values due to a table
4118 Fixed porting problem for NetBSD and FreeBSD by renaming the
4119 qdiv() function in qmath.c to qqdiv().
4121 Improved the speed of mfactor (from mfactor.cal library) for
4122 long Mersenne factorizations. The default reporting loop
4123 is now 10000 cycles.
4125 SGI Mips r10k compile set is speced for IRIX6.5 with v7.2
4126 compilers. A note for pre-IRIX6.5 and/or pre-v7.2 compilers
4127 is given in the compile set.
4129 Added regression tests related to saveval(), dot and pointers.
4132 The following are the changes from calc version 2.10.3t5.11 to 2.10.3t5.27:
4134 The todo help file as been updated with the in-progress items:
4136 xxx - block print function is not written yet ...
4138 Expanded the role of blk() to produce unnamed blocks as in:
4142 and named blocks as in:
4144 B = blk(str, len, chunk)
4146 A block may be changed (with possible loss of data only if len is less
4147 than the old len) by:
4149 C = blk(B, len, chunk)
4151 For an unnamed block B, this creates a new block C and copies
4152 min(len, oldlen) octets to it, B remaining unchanged. For a named
4153 block, the block B is changed and C refers to the same block as B,
4154 so that for example, C[i] = x will result in B[i] == x. Thus, for a
4155 named block, "B = " does nothing (other than B = B) in:
4157 B = blk(B, len, chunk)
4159 but is necessary for changing an unnamed block.
4161 Renamed rmblk() to blkfree().
4163 The builtin function blkfree(val) will free memory allocated to block.
4164 If val is a named block, or the name of a named block, or the
4165 identifying index for a named block, blkfree(val) frees the
4166 memory block allocated to this named block. The block remains
4167 in existence with the same name, identifying index, and chunksize,
4168 but its size and maxsize becomes zero and the pointer for the start
4169 of its data block null.
4171 The builtin function blocks() returns the number of blocks that
4172 have been created but not freed by the blkfree() function. When called
4173 as blocks(id) and the argument id less than the number of named
4174 blocks that have been created, blocks(id) returns the named block
4175 with identifying index id.
4177 Removed the artificial limit of 20 named blocks.
4179 Added name() builtin to return the name of a type of value
4182 Added isdefined() to determine of a value is defined.
4184 Added isobjtype() to determine the type of an object.
4186 The isatty(v) builtin will return 1 if v is a file that associated
4187 with a tty (terminal, xterm, etc.) and 0 otherwise. The isatty(v)
4188 builtin will no longer return an error if v is not a file or
4191 The isident(m) builtin will return 1 if m is a identity matrix
4192 and 0 otherwise. The isident(m) builtin will no longer return an
4193 error if m is not a matrix.
4195 Added extensive testing of isxxx() builtins and their operations
4198 Added md5() builtin to perform the MD5 Message-Digest Algorithm.
4200 Renamed isset() to bit().
4202 Blocks will expand when required by the copy() builtin function:
4204 ; f = fopen("help/full", "r")
4207 chunksize = 256, maxsize = 256, datalen = 0
4210 chunksize = 256, maxsize = 310272, datalen = 310084
4211 2a2a2a2a2a2a2a2a2a2a2a2a2a0a2a20696e74726f0a2a2a2a2a2a2a2a2a...
4213 NOTE: Your results will differ because changes to help/full.
4215 The blkcpy() builtin args now more closely match that
4216 of memcpy(), strncpy:
4218 blkcpy(dst, src [, num [, dsi [, ssi]]])
4220 The copy() builtin args now more closely match that the cp command:
4222 copy(src, dst [, num [, ssi [, dsi]]])
4224 but otherwise does the same thing as blkcpy.
4226 Fixed lint problems for SunOS.
4228 Added have_memmv.c and HAVE_MEMMOVE Makefile variable to control
4229 use of memmove(). If empty, then memmove() is tested for and if
4230 not found, or if HAVE_MEMMOVE= -DHAVE_NO_MEMMOVE then an internal
4231 version of memmove() is used instead.
4233 Added regression tests for sha, sha1 and md5 builtin hash functions.
4235 Added xx_print to to the list of object routines are definable.
4236 Added xx_print.cal to the library to demo this feature.
4238 Moved blkcpy() routines have been moved to blkcpy.[ch].
4240 The blkcpy() & copy() builtins can not copy to/from numbers.
4241 For purposes of the copy, only the numerator is ignored.
4243 Resolved a number of missing symbols for libcalc users.
4245 Added lib_util.{c,h} to the calc source to support users of
4246 libcalc.a. These utility routines are not directly used by
4247 calc but are otherwise have utility to those programmers who
4248 directly use libcalc.a instead.
4250 Added sample sub-directory. This sub-directory contains a few
4251 sample programs that use libcalc.a. These sample programs are
4252 built via the all rule because they will help check to see that
4253 libcalc.a library does not contain external references that
4254 cannot be resolved. At the current time none of these sample
4255 programs are installed.
4257 Added a libcalc_call_me_last() call to return storage created
4258 by the libcalc_call_me_first() call. This allows users of libcalc.a
4259 to free up a small amount of storage.
4261 Fixed some memory leaks associated with the random() Blum generator.
4263 Fixed fseek() file operations for SunOS.
4265 Fixed convz2hex() fencepost error. It also removes leading 0's.
4267 Plugged a memory leak relating to pmod. The following calculation:
4269 pmod(2, x, something)
4271 where x was not 2^n-1 would leak memory. This has been fixed.
4274 The following are the changes from calc version 2.10.3t5.1 to 2.10.3t5.10:
4276 Misc printf warning bug fixes.
4278 Calc now permits chains of initializations as in:
4280 obj point {x,y} P = {1,2} = {3,4} = {5,6}
4282 Here the initializations are applied from left to right. It may
4283 look silly, but the 1, 2, ... could be replaced by expressions with
4284 side effects. As an example of its use suppose A and B are
4285 expressions with side effects:
4289 has the effect of P.x = A; P.y = B. Sometimes one might want these in
4290 the reverse order: P.y = B; P.x = A. This is achieved by:
4294 Another example of its use:
4296 obj point Q = {P, P} = {{1, 2}, {3, 4}}
4298 which results in Q having Q.x.x = 1, Q.x.y = 2, etc.
4300 The role of the comma in has been changed. Expressions such as:
4306 (mat A[2]), (mat B[3])
4308 Now, expr1, expr2 returns type of expr2 rather than EXPR_RVALUE. This
4309 permits expressions such as:
4313 Also, expr1 ? expr2 : expr3 returns type(expr2) | type(expr3).
4314 This will make the result an lvalue (i.e. EXPR_RVALUE bit not set)
4315 For example, if both expr2 and expr3 are lvalues. Then:
4319 has the effect of b = d if a is "nonzero", otherwise c = d.
4321 This may be compared with
4325 which does d = b if a is "nonzero", otherwise d = c.
4327 And now, expr1 || expr2 and expr1 && expr2 each return
4328 htype(expr1)| type(expr2). So for example:
4332 has the effect of a = c if a is "nonzero", otherwise b = c.
4337 has the effect of a = c if a is "zero", otherwise b = c.
4339 At top level, newlines are neglected between '(' and the matching
4340 ')' in expressions and function calls. For example, if f() has been
4341 already defined, then:
4361 will be accepted, and in interactive mode the continue-line prompt
4364 When calc sees a "for", "while", "do", or "switch", newlines will be
4365 ignored (and the line-continuation prompt displayed in interactive mode)
4366 until the expected conditions and statements are completed.
4370 for (i = 0; i < 5; i++)
4376 Now 's' will print '10' instead of '5'.
4378 Added more regression tests to regress.cal. Changed the error
4379 counter from 'err' to 'prob'. The errmax() is set very high and
4380 the expected value of errcount() is kept in ecnt.
4382 Added the 'unexpected' help file which gives some unexpected
4383 surprises that C programmers may encounter.
4385 Updated the 'help', 'intro' and 'overview' to reflect the
4386 full list of non-builtin function help files. Reorered the
4389 The blkalloc() builtin has been renamed blk().
4391 Only a "fixed" type of BLOCK will be used. Other types of
4392 blocks in the future will be different VALUE types.
4394 Introduced an undefine command so that
4398 frees the memory used to store code for user-defined functions f,
4399 g, ..., effectively removing them from the list of defined
4402 When working from a terminal or when config("lib_debug") > 0 advice
4403 that a function has been defined, undefined, or redefined is
4404 displayed in format "f() defined".
4406 Some experimental changes to block and octet handling, so that after:
4410 B[i] for 0 <= i < N behaves for some operations like an lvalue for
4413 xx_assign added to object functions to permit the possibility of
4414 specifying what A = B will do if A is an xx-object. Normal
4415 assignment use of = is restored by the command: undefine
4418 For error-value err, errno(err) returns the error-code for err and
4419 stores this in calc_errno; error(err) returns err as if
4420 error(errno(err)) were called.
4422 Anticipating probable future use, names have been introduced for
4423 the four characters @, #, $, `. This completes the coverage of
4424 printable characters on a standard keyboard.
4426 Added sha() builtin to perform the old Secure Hash Algorithm
4429 Added sha1() builtin to perform the new Secure Hash Standard-1
4430 (SHS-1 FIPS Pub 180-1).
4432 Added ${LD_DEBUG} Makefile variable to allow for additional
4433 libraries to be compiled into calc ... for debugging purposes.
4434 In most cases, LD_DEBUG= is sufficient.
4436 Added ${CALC_ENV} makefile variable to allow for particular
4437 environment variables to be supplied for make {check,chk,debug}.
4438 In most cases, CALC_ENV= CALCPATH=./lib is sufficient.
4440 Added ${CALC_LIBS} to list the libraries created and used to
4441 build calc. The CALC_LIBS= custom/libcustcalc.a libcalc.a
4442 is standard for everyone.
4444 Improved how 'make calc' and 'make all' rules work with respect
4445 to building .h files.
4447 Added 'make run' to only run calc interactively with the
4448 ${CALC_ENV} calc environment. Added 'make cvd', 'make dbx'
4449 and 'make gdb' rules to run debug calc with the respective
4450 debugger with the ${CALC_ENV} calc environment.
4452 Added cvmalloc_error() function to lib_calc.c as a hook for
4453 users of the SGI Workshop malloc debugging library.
4455 Cut down on places where *.h files include system files.
4456 The *.c should do that instead where it is reasonable.
4458 To avoid symbol conflicts, *.h files produced and shipped
4459 with calc are enclosed that as similar to the following:
4461 #if !defined(__CALC_H__)
4464 #endif /* !__CALC_H__ */
4466 Added memsize(x) builtin to print the best approximation of the
4467 size of 'x' including overhead. The sizeof(x) builtin attempts
4468 to cover just the storage of the value and not the overhead.
4469 Because -1, 0 and 1 ZVALUES are static common values, sizeof(x)
4470 ignores their storage. Also sizeof(x) ignores the denominator of
4471 integers, and the imaginary parts of pure real numbers. Added
4472 regression tests for memsize(), sizeof() and size().
4475 The following are the changes from calc version 2.10.3t4.16 to 2.10.3t5.0:
4477 The calc source now comes with a custom sub-directory which
4478 contains the custom interface code. The main Makefile now
4479 drives the building and installing of this code in a similar
4480 way that it drives the lib and help sub-directories. (see below)
4482 Made minor edits to most help files beginning with a thru e.
4484 The errno(n) sets a C-like errno to the value n; errno() returns
4485 the current errno value. The argument for strerror() and error()
4486 defaults to this errno.
4488 Added more error() and errno() regression tests.
4490 The convention of using the global variable lib_debug at the
4491 end of calc library scripts has been replaced with config("lib_debug").
4492 The "lib_debug" is reserved by convention for calc library scripts.
4493 This config parameter takes the place of the lib_debug global variable.
4494 By convention, "lib_debug" has the following meanings:
4496 <-1 no debug messages are printed though some internal
4497 debug actions and information may be collected
4499 -1 no debug messages are printed, no debug actions will be taken
4501 0 only usage message regarding each important object are
4502 printed at the time of the read (default)
4504 >0 messages regarding each important object are
4505 printed at the time of the read in addition
4506 to other debug messages
4508 The "calc_debug" is reserved by convention for internal calc routines.
4509 The output of "calc_debug" will change from release to release.
4510 Generally this value is used by calc wizards and by the regress.cal
4511 routine (make check). By convention, "calc_debug" has the following
4514 <-1 reserved for future use
4516 -1 no debug messages are printed, no debug actions will be taken
4518 0 very little, if any debugging is performed (and then mostly
4519 in alpha test code). The only output is as a result of
4520 internal fatal errors (typically either math_error() or
4521 exit() will be called). (default)
4523 >0 a greater degree of debugging is performed and more
4524 verbose messages are printed (regress.cal uses 1).
4526 The "user_debug" is provided for use by users. Calc ignores this value
4527 other than to set it to 0 by default (for both "oldstd" and "newstd").
4528 No calc code or shipped library will change this value other than
4529 during startup or during a config("all", xyz) call.
4531 The following is suggested as a convention for use of "user_debug".
4532 These are only suggestions: feel free to use it as you like:
4534 <-1 no debug messages are printed though some internal
4535 debug actions and information may be collected
4537 -1 no debug messages are printed, no debug actions will be taken
4539 0 very little, if any debugging is performed. The only output
4540 are from fatal errors. (default)
4542 >0 a greater degree of debugging is performed and more
4543 verbose messages are printed
4545 Added more code related to the BLOCK type.
4547 Added blkalloc() builtin.
4549 Split NAMETYPE definition out into nametype.h.
4551 Added OCTET type for use in processing block[i].
4553 Added free, copy, cmp, quickhash and print functions for
4554 HASH, BLOCK and OCTET.
4556 Added notes to config.h about what needs to be looked at when
4557 new configuration items are added.
4559 The null() builtin now takes arguments.
4561 Given the following:
4566 will will now create P and Q as obj point objects.
4568 Added xx_or, xx_and, xx_not and xx_fact objfuncs.
4570 Added the custom() builtin function. The custom() builtin
4571 interface is designed to make it easier for local custom
4572 modification to be added to calc. Custom functions are
4573 non-standard or non-portable code. For these reasons, one must can
4574 only execute custom() code by way of an explicit action.
4576 By default, custom() returns an error. A new calc command line
4577 option of '-C' is required (as well as ALLOW_CUSTOM= -DCUSTOM
4578 Makefile variable set) to enable it.
4580 Added -C as a calc command line option. This permits the
4581 custom() interface to be used.
4583 Added ALLOW_CUSTOM Makefile variable to permanently disable
4584 or selective enable the custom builtin interface.
4586 The rm() builtin now takes multiple filenames. If the first
4587 arg is "-f", then 'no-such-file' errors are ignored.
4589 Added errcount([count]) builtin to return or set the error
4590 counter. Added errmax([limit]) to return or set the error
4593 Added -n as a calc command line option. This has the effect
4594 of calling config("all", "newstd") at startup time.
4596 Added -e as a calc command line option to ignore all environment
4597 variables at startup time. The getenv() builtin function will
4598 still return values, however.
4600 Added -i as a calc command line option. This has the effect
4601 ignoring when errcount() exceeds errmax().
4603 Changed the config("maxerr") name to config("maxscan"). The
4604 old name of "maxerr" is kept for backward compatibility.
4606 Using an unknown -flag on the calc command like will
4607 generate a short usage message.
4609 Doing a 'help calc' displays the same info as 'help usage'.
4611 The 'make check' rule now uses the -i calc command line flag
4612 so that regress.cal can continue beyond when errcount exceeds
4613 errmax. In regress.cal, vrfy() reports when errcount exceeds
4614 errmax and resets errmax to match errcount. This check
4615 and report is independent of the test success of failure.
4617 Fixed missing or out of order tests in regress.cal.
4619 Misc Makefile cleanup in lib/Makefile and help/Makefile.
4621 The default errmax() value on startup is now 20.
4623 The custom() interface is now complete. See help/custom and
4624 custom/HOW_TO_ADD files, which show up as the custom and new_custom
4625 help files, for more information.
4627 The help command will search ${LIBDIR}/custhelp if it fails to find
4628 a file in ${LIBDIR}. This allows the help command to also print
4629 help for a custom function. However if a standard help file and a
4630 custom help file share the same name, help will only print the
4631 standard help file. One can skip the standard help file and print
4632 the custom help file by:
4638 custom("help", "name")
4640 Added minor sanity checks the help command's filename.
4642 Added show custom to display custom function information.
4644 Added the contrib help page to give information on how
4645 and where to submit new calc code, modes or custom functions.
4647 Added comment information to value.h about what needs to be
4648 checked or modified when a new value type is added.
4650 Both size(x) and sizeof(x) return information on all value types.
4651 Moved size and sizeof information from func.c and into new file: size.c.
4653 Added custom("devnull") to serve as a do-nothing interface tester.
4655 Added custom("argv" [,arg ...]) to print information about args.
4657 Added custom("sysinfo", "item") to print an internal calc #define
4660 The make depend rule also processes the custom/Makefile.
4662 Added xx_max and xx_min for objfuncs.
4664 The max(), min() builtins work for lists.
4667 The following are the changes from calc version 2.10.3t3 to 2.10.3t4.15:
4669 The priority of unary + and - to that of binary + and - when they are
4670 applied to a first or only term. Thus:
4676 Running ranlib is no longer the default. Systems that need RANLIB
4677 should edit the Makefile and comment back in:
4681 Dropped support of SGI r8k.
4683 Added support for the SGI r5k.
4685 Added support for SGI Mips compiler version 7.1 or later.
4687 Removed "random" as a config() option.
4689 Removed CCZPRIME Makefile variable.
4691 Added zsquaremod() back into zmod.c to be used by the Blum-Blum-Shub
4692 generator for the special case of needing x^2 mod y.
4694 Moved the Blum-Blum-Shub code and defines from zrand.c and zrand.h
4695 into zrandom.c and zrandom.h. Now only the a55 generator resides
4696 in zrand.c and zrand.h.
4698 Added random, srandom and randombit help files.
4700 Added random(), srandom() and randombit() builtin functions. The
4701 cryptographically strong random number generator is code complete!
4703 Removed cryrand.cal now that a Blum-Blum-Shub generator is builtin.
4705 Improved the speed of seedrandom.cal. It now uses the 13th
4706 builtin Blum-Blum-Shub seed.
4708 The randmprime.cal script makes use of the Blum-Blum-Shub generator.
4710 Added randombitrun.cal and randomrun.cal calc library files.
4711 These are the Blum-Blum-Shub analogs to the randbitrun.cal
4712 and randrun.cal a55 tests.
4714 Improved hash.c interface to lower level hash functions. The hash
4715 interface does not yet have a func.c interface ... it is still
4718 Added randombitrun.cal to test the Blum-Blum-Shub generator.
4720 Added calc.h, hash.h, shs.h and value.h to LIB_H_SRC because some
4721 of the libcalc.a files need them.
4723 In the original version, each call to newerror(str) created a new
4724 error-value. Now a new value will be created only if str has not
4725 been used in a previous call to newerror(). In effect, the string
4726 serves to identify the error-value; for example:
4728 return newerror("Non-integer argument");
4730 can be used in one or more functions, some of which may be
4731 repeatedly called, but after it has been called once, it will
4732 always return the same value as if one had initially used the
4735 non_integer_argument_error = newerror("Non-integer argument")
4737 and then in each function used:
4739 return non_integer_argument_error;
4741 The new definition of newerror() permits its freer use in cases like:
4746 return newerror("Non-integer argument");
4750 One might say that "new" in "newerror" used to mean being different
4751 from any earlier error-value. Now it means being not one of the
4752 "original" or "old" error-values defined internally by calc.
4754 As newerror() and newerror("") specify no non-null string, it has
4755 been arranged that they return the same as newerror("???").
4757 Added "show errors" command analogous to "show functions" for
4758 user-defined functions. One difference is that whereas the
4759 functions are created by explicit definitions, a new described
4760 error is created only when a newerror(...) is executed.
4762 Fixed macro symbol substitution problem uncovered by HPUX cpp bug in
4763 HVAL and related zrand.h macros.
4765 Added +e to CCMISC for HP-UX users.
4767 Fixed the prompt bug.
4769 Eliminated the hash_init() initialization function.
4771 The 'struct block' has been moved from value.c to a new file: block.h.
4773 Added "blkmaxprint" config value, which limits the octets to print
4774 for a block. A "blkmaxprint" of 0 means to print all octets of a
4775 block, regardless of size. The default is to print only the first
4778 The "blkverbose" determines if all lines, including duplicates
4779 should be printed. If TRUE, then all lines are printed. If false,
4780 duplicate lines are skipped and only a "*" is printed in a style
4781 similar to od. This config value has not meaning if "blkfmt" is
4782 "str". The default value for "blkverbose" is FALSE: duplicate
4783 lines are not printed.
4785 The "blkbase" determines the base in which octets of a block
4786 are printed. Possible values are:
4788 "hexadecimal" Octets printed in 2 digit hex
4791 "octal" Octets printed in 3 digit octal
4794 "character" Octets printed as chars with non-printing
4795 "char" chars as \123 or \n, \t, \r
4797 "binary" Octets printed as 0 or 1 chars
4800 "raw" Octets printed as is, i.e. raw binary
4803 The default "blkbase" is "hex".
4805 The "blkfmt" determines for format of how block are printed:
4807 "line" print in lines of up to 79 chars + newline
4810 "str" print as one long string
4814 "od" print in od-like format, with leading offset,
4815 "odstyle" followed by octets in the given base
4818 "hd" print in hex dump format, with leading offset,
4819 "hdstyle" followed by octets in the given base, followed
4820 "hd_style" by chars or '.' if no-printable or blank
4822 The default "blkfmt" is "hd".
4824 Fixed a bug in coth() when testing acoth using coth(acoth(x)) == x
4825 within the rounding error.
4827 Assignments to matrices and objects has been changed. The assignments in:
4830 B = makelist(4) = {1,2,3,4};
4832 will result in A == B. Then:
4836 will result in A == list(1,2,5,4).
4838 Made minor edits to most help files beginning with a thru d.
4840 Fixed error in using cmdbuf("").
4843 The following are the changes from calc version 2.10.3t0 to 2.10.3t2:
4845 Bumped to version 2.10.3 due to the amount of changes.
4847 Renamed qabs() to qqabs() to avoid conflicts with stdlib.h.
4849 Fixed a casting problem in label.c.
4851 A lot of work was performed on the code generation by Ernest Bowen
4852 <ernie at turing dot une dot edu dot au>. Declarations no longer
4853 need to precede code:
4862 The scope of a variable extends from the end of the declaration (including
4863 initialization code for the variable) at which it is first created
4864 to the limit given by the following rules:
4866 local variable: to the end of the function being defined
4868 global variable: to the end of the session with calc
4870 static within a function definition: to the first of:
4872 an end of a global, static or local declaration (including
4873 initialization code) with the same identifier
4875 the end of the definition
4877 static at top level within a file: to the first of:
4879 the next static declaration of the identifier at top level
4882 the next global declaration of the identifier at top level
4883 in the file or in any function definition in the file,
4885 the next global declaration of the identifier at any level
4886 in a file being read as a result of a "read" command,
4888 the end of the file.
4890 The scope of a top-level global or static variable may be
4891 interrupted by the use of the identifier as a parameter or local or
4892 static variable within a function definition in the file being
4893 read; it is restored (without change of value) after the definition.
4895 For example, The two static variables a and b are created,
4896 with zero value, when the definition is read; a is initialized
4897 with the value x if and when f(x) is first called with a positive
4898 even x, b is similarly initialized if and when f(x) is first called
4899 positive odd x. Each time f(x) is called with positive integer x,
4900 a or b is incremented. Finally the values of the static variables
4901 are assigned to the global variables a and b, and the resulting
4902 values displayed. Immediately after the last of several calls to
4903 f(x), a = 0 if none of the x's have been positive even, otherwise
4904 a = the first positive even x + the number of positive even x's,
4905 and b = 0 if none of the x's have been positive odd, otherwise
4906 b = the first positive odd x + the number of positive odd x's:
4909 if (isint(x) && x > 0) {
4918 global a = a, b = b;
4919 print "a =",a,"b =",b;
4922 Fixed some faults in the handling of syntax errors for the matrix
4923 and object creation operators mat and obj. In previous versions of calc:
4925 mat; <- Bad dimension 0 for matrix
4926 mat A; <- Bad dimension 0 for matrix
4927 global mat A; <- Bad dimension 0 for matrix
4928 mat A[2], mat B[3] <- Semicolon expected
4929 global mat A[2], mat B[3] <- Bad syntax in declaration statement
4933 this statement has the same effect as
4934 -------------- ----------------------
4935 mat A[2], B[3] (A = mat[2]), B[3]
4937 global mat A[2], B[3] global A, B; A = mat[2]; B = mat[3];
4939 Initialization remains essentially as before except that for objects,
4940 spaces between identifiers indicate assignments as in simple variable
4941 declarations. Thus, after:
4944 obj point P, Q R = {1,2}
4946 P has {0,0}, Q and R have {1,2}. In the corresponding expression with
4947 matrices commas between identifiers before the initialization are ignored.
4950 this statement has the same effect as
4951 -------------- ----------------------
4952 mat A, B C [2] = {1,2} A = B = C = (mat[2] = {1,2})
4954 One can also do things like:
4956 L = list(mat[2] = {1,2}, obj point = {3,4}, mat[2] = {5,6})
4957 A = mat[2,2] = {1,2,3,4}^2
4958 B = mat[2,2] = {1,2,3,4} * mat[2,2] = {5,6,7,8}
4960 where the initialization = has stronger binding than the assignment = and
4963 Matrices and objects can be mixed in declarations after any simple
4966 global a, b, mat A, B[2] = {3,4}, C[2] = {4,5}, obj point P = {5,6}, Q
4968 Fixed some bugs related to global and static scoping. See the
4969 5200 regress test and lib/test5200.cal for details.
4971 Optimized opcode generator so that functions defined using '=' do not
4972 have two unreached opcodes. I.e.,:
4977 Also unreachable opcodes UNDEF and RETURN are now not included at
4978 the end of any user-defined function.
4980 Changed the "no offset" indicator in label.c from 0 to -1; this
4981 permits goto jumps to the zero opcode position.
4983 Changed the opcode generation for "if (...)" followed by
4984 "break", "continue", or "goto", so that only one jump opcode is
4987 A label can now be immediately by a right-brace. For example:
4989 define test_newop3(x) {if (x < 0) goto l132; ++x; l132: return x;}
4991 The LONG_BITS make variable, if set, will force the size of a long
4992 as well as forcing the USB8, SB8, USB16, SB16, USB32, SB32,
4993 HAVE_B64, USB64, SB64, U(x) and L(x) types. If the longbits
4994 program is given an arg (of 32 or 64), then it will output
4995 based on a generic 32 or 64 bit machine where the long is
4996 the same size as the wordsize.
4998 Fixed how the SVAL and HVAL macros were formed for BASEB==16 machines.
5000 Dropped explicit Makefile support for MIPS r8k since these processors
5001 no longer need special compiler flags.
5003 SGI 6.2 and later uses -xansi.
5006 The following are the changes from calc version 2.10.2t33 to 2.10.2t34:
5008 Fixed a bug related to fact().
5010 Thanks to Ernest Bowen <ernie at turing dot une dot edu dot au>,
5011 for two or three arguments,
5013 search(x, val, start);
5014 rsearch(x, val, start);
5016 and for matrix, list or association x:
5018 search(f, str, start);
5019 rsearch(f, str, start);
5021 for a file stream f open for reading, behave as before except for a few
5024 (1) there are no limits on the integer-valued start.
5026 (2) negative values of start are interpreted as offsets from the size of
5027 x and f. For example,
5029 search(x, val, -100)
5031 searches the last 100 elements of x for the first i for which
5034 (3) for a file f, when start + strlen(str) >= size(f) and
5035 search(f, str, start) returns null, i.e. str is
5036 not found, the file position after the search will be
5038 size(f) - strlen(str) + 1
5040 rather than size(f).
5045 rsearch(a, b, c, d),
5047 a has the role of x or f, and b the role of val or str as described
5048 above for the three-argument case, and for search(), c is
5049 essentially "start" as before, but for rsearch() is better for c
5050 and d to be the same as for search(). For a non-file case, if:
5052 0 <= c < d <= size(a),
5054 the index-interval over which the search is to take place is:
5058 If the user has defined a function accept(v,b), this is used rather
5059 than the test v == b to decide for matrix, list, or association
5060 searches when a "match" of v = a[[i]] with b occurs. E.g. after:
5062 define accept(v,b) = (v >= b);
5066 search(a, 5, 100, 200)
5068 will return, if it exists, the smallest index i for which
5069 100 <= i < 200 and a[[i]] >= 5. To restore the effect of
5070 the original "match" function, one would then have to:
5072 define accept(v,b) == (v == b).
5074 Renamed the calc symbol BYTE_ORDER to CALC_BYTE_ORDER in order
5077 Added beer.cal and hello.cal lib progs in support of: :-)
5079 http://www.ionet.net/~timtroyr/funhouse/beer.html
5080 http://www.latech.edu/~acm/HelloWorld.shtml
5083 The following are the changes from calc version 2.10.2t25 to 2.10.2t32:
5085 Eliminated use of VARARG and <varargs.h>. Calc supports only
5086 <stdarg.h>. The VARARGS Makefile variable has been eliminated.
5088 Source is converted to ANSI C. In particular, functions
5089 will now have ANSI C style args. Any comments from old K&R
5090 style args have been moved to function comment section.
5092 Removed prototype.h. The PROTO() macro is no longer needed
5095 Added mfactor.cal to find the smallest factor of a Mersenne number.
5097 The built .h file: have_times.h, determines if the system has
5098 <time.h>, <times.h>, <sys/time.h> and <sys/times.h>.
5100 Because shs.c depends on HASHFUNC, which in turn depends on
5101 VALUE, shs.o has been moved out of libcalc.a. For the same
5102 reasons, hash.h and shs.h are not being installed into
5103 the ${LIBDIR} for now.
5105 A number of the regression tests that need random numbers now
5106 use different seeds.
5108 Fixes for compiling under BSDI's BSD/OS 2.0. Added a Makefile
5111 Added a Makefile compile section for Dec Alpha without gcc ...
5112 provides a hack-a-round for Dec Alpha cc bug.
5114 Minor comment changes to lucas.cal.
5116 Added pix.cal, a slow painful but interesting way to compute pix(x).
5118 Confusion over the scope of static and global values has been reduced
5119 by a patch from Ernest Bowen <ernie at turing dot une dot edu dot au>.
5121 The change introduced by the following patch terminates the
5122 scope of a static variable at any static declaration with the
5123 same name at the same level, or at any global declaration with
5124 the same name at any level. With the example above, the scope
5125 of the static "a" introduced in the third line ends when the
5126 "global a" is read in the last line. Thus one may now use the
5127 same name in several "static" areas as in:
5130 ; define f(x) = a + x;
5132 ; define g(x) = a + x;
5135 The first "a" exists only for the definition of f(); the second
5136 "a" only for the definition of g(). At the end one has only
5139 Ending the scope of a static variable in this way is consistent
5140 with the normal use of static variables as in:
5143 ; define f(x) {static a = 20; return a++ + x;}
5144 ; define g(x) = a + x;
5147 The scope of the first "a" is temporarily interrupted by the
5148 "static a" in the second line; the second "a" remains active
5149 until its scope ends with the ending of the definition of f().
5150 Thus one ends with g(x) = 10 + x and on successive calls to
5151 f(), f(x) returns 20 + x, 21 + x, etc. With successive "static
5152 a" declarations at the same level, the active one at any stage
5153 is the most recent; if the instructions are being read from a
5154 file, the scope of the last "static a" ends at the end-of-file.
5156 Here I have assumed that no "global a" is encountered. As
5157 there can be only one global variable with name "a", it seems
5158 to me that its use must end the scope of any static "a". Thus
5159 the changes I introduce are such that after:
5162 ; define f(x) = a + x;
5164 ; define g(x) = a + x;
5165 ; define h(x) {global a = 30; return a + x;}
5166 ; define i(x) = a + x;
5168 g(x) will always return 20 + x, and until h(x) has been called,
5169 f(x) and i(x) will return 10 + x; when h(x) is called, it
5170 returns 30 + x and any later call to f(x) or i(x) will return
5171 30 + x. It is the reading of "global a" in the definition of
5172 h() that terminates the scope of the static a = 20, so that the
5173 "a" for the last line is the global variable defined in the
5174 first line. The "a = 30" is executed only when h() is called.
5176 Users who find this confusing might be well advised to use
5177 different names for different variables at the same scope level.
5179 The other changes produced by the patch are more straightforward,
5180 but some tricky programming was needed to get the possibility of
5181 multiple assignments and what seems to be the appropriate order
5182 of executions and assignments. For example, the order for the
5185 global a, b = expr1, c, d = expr2, e, f
5189 evaluation of expr1;
5191 evaluation of expr2;
5194 Thus the effect is the same as for:
5196 a = 0; b = expr1; c = 0; d = expr2; e = 0; f = 0;
5198 The order is important when the same name is used for different
5199 variables in the same context. E.g. one may have:
5211 Every time this is called, the global "a" is assigned the value
5212 10. The first time it is called, the value 10 is passed on to
5213 the static "a" and then to the local "a". In each later call
5214 the "static a = a" is ignored and the static "a" is one less than
5215 it was in the preceding call. I'm not recommending this style of
5216 programming but it is good that calc will be able to handle it.
5218 I've also changed dumpop to do something recent versions do not do:
5219 distinguish between static and global variables with the same name.
5221 Other changes: commas may be replaced by spaces in a sequence of
5222 identifiers in a declaration. so one may now write:
5224 global a b c = 10, d e = 20
5226 The comma after the 10 is still required. Multiple occurrences
5227 of an identifier in a local declaration are now acceptable as
5228 they are for global or static declarations:
5230 local a b c = 10, a = 20;
5238 The static case is different in that:
5240 static a b c = 10, a = 20;
5242 creates four static variables, the first "a" having a very short and
5245 Added new tests to verify the new assignments above.
5247 Added the builtin test(x) which returns 1 or 0 according as x tests
5248 as true or false for conditions.
5250 Added have_posscl.c which attempts to determine if FILEPOS is
5251 a scalar and defines HAVE_FILEPOS_SCALAR in have_posscl.h
5252 accordingly. The Makefile variable HAVE_POSSCL determines
5253 if have_posscl.c will test this condition or assume non-scalar.
5255 Added have_offscl.c which attempts to determine if off_t is
5256 a scalar and defines HAVE_OFF_T_SCALAR in have_posscl.h
5257 accordingly. The Makefile variable HAVE_OFFSCL determines
5258 if have_offscl.c will test this condition or assume non-scalar.
5260 Reading to EOF leaves you positioned one character beyond
5261 the last character in the file, just like Un*x read behavior.
5263 Calc supports files and offsets up to 2^64 bytes, if the OS
5264 and file system permits.
5267 The following are the changes from calc version 2.10.2t4 to 2.10.2t24:
5269 Added makefile debugging rules:
5271 make chk like a 'make check' (run the regression tests)
5272 except that only a few lines around interesting
5273 (and presumable error messages) are printed.
5274 No output if no errors are found.
5276 make env print important makefile values
5278 make mkdebug 'make env' + version information and a
5279 make with verbose output and printing of
5282 make debug 'make mkdebug' with a 'make clobber'
5283 so that the entire make is verbose and
5284 a constructed files are printed
5286 Improved instructions in 'BUGS' section on reporting problems.
5287 In particular we made it easy for people to send in a full
5288 diagnostic output by sending 'debug.out' which is made as follows:
5290 make debug > debug.out
5292 Added -v to calc command line to print the version and exit.
5294 Fixed declarations of memcpy(), strcpy() and memset() in the
5295 case of them HAVE_NEWSTR is false.
5297 Fixed some compile time warnings.
5299 Attempting to rewind a file this is not open generates an error.
5301 Noted conversion problems in file.c in triple X comments.
5303 Some extremely brain dead shells cannot correctly deal with if
5304 clauses that do not have a non-empty else statement. Their
5305 exit bogosity results in make problems. As a work-a-round,
5306 Makefile if clauses have 'else true;' clauses for if statements
5307 that previously did not have an else clause.
5309 Fixed problems where the input stack depth reached the 10 levels.
5311 The show keyword is now a statement instead of a command:
5313 ; define demo() {local f = open("foo", "w"); show files; fclose(f);}
5316 Added a new trace option for display of links to real and complex
5317 numbers. This is activated by config("trace", 4). The printing of
5318 a real number is immediately followed by "#" and the number of links
5319 to that number; complex numbers are printed in the same except for
5320 having "##" instead of "#". <ernie at turing dot une dot edu dot au>
5322 The number of links for a number value is essentially the number of value
5323 locations at which it is either stored or deemed to be stored. Here a
5324 number value is the result of a reading or evaluation; when the result
5325 is assigned to lvalues, "linking" rather than copying occurs. Different
5326 sets of mutually linked values may contain the same number. For example:
5328 a = b = 2 + 3; x, y = 2 + 3;
5330 a and b are linked, and x and y are linked, but a and x are not linked.
5332 Revised the credits help file and man page. Added archive help
5333 file to indicate where recent versions of calc are available.
5335 The regression test suite output has been changed so that it will
5336 output the same information regardless of CPU performance. In
5337 particular, cpu times of certain tests are not printed. This allows
5338 one to compare the regression output of two different systems easier.
5340 A matrix or object declaration is now considered an expression
5341 and returns a matrix or object of the specified type. Thus one may
5342 use assignments like:
5344 A = mat[2]; /* same as: mat A[2]; */
5345 P = obj point; /* same as: obj point P; */
5347 The obj and mat keywords may be with "local", "global", "static" as in:
5351 Several matrices or objects may be assigned or declared in the one
5354 mat A, B[2], C[3]; /* same as: mat A[2], B[2], C[3] */
5356 except that only one matrix creation occurs and is copied as in:
5360 Initialization of matrices and objects now occur before assignments:
5362 mat A, B [2] = {1,2}; /* same as: A = B = (mat[2] = {1,2}); */
5364 Missing arguments are considered as "no change" rather than
5365 "assign null values". As in recent versions of calc, the default
5366 value assigned to matrix elements is zero and the default for object
5367 elements is a null value). Thus:
5372 will change the value of A to {1,3}.
5374 If the relevant operation exists for matrices or has been defined for
5375 the type of object A is, the assignment = may be combined with +, -, *,
5378 A += {3, 4}; /* same as: A[0] += 3; A[1] += 4; */
5379 A += { }; /* same as: A += A; */
5381 In (non-local) declarations, the earlier value of a variable may be
5382 used in the initialization list:
5384 mat A[3]={1,2,3}; mat A[3]={A[2],A[1],A[0]}; /* same as: A={3,2,1} */
5389 mat A[3] = {A, A, A};
5391 produces a 3-element matrix, each of whose elements is a 3-element matrix.
5393 The notation A[i][j] requires A[i] to be a matrix, whereas B[i,j]
5394 accesses an element in a 2-dimensional matrix. Thus:
5396 B == A[i] implies A[i][j] = B[j]
5398 There is requirement in the use of A[i][j] that the matrices A[i]
5399 for i = 0, 1, ... all be of the same size. Thus:
5401 mat A[3] = {(mat[2]), (mat[3]), (mat[2])};
5403 produces a matrix with a 7-element structure:
5405 A[0][0], A[0][1], A[1][0], A[1][1], A[1][2], A[2][0], A[2][1]
5407 One can initialize matrices and objects whose elements are matrices
5412 obj point A = {P,P};
5421 The config("trace", 8) causes opcodes of newly defined functions
5422 are displayed. Also show can now show the opcodes for a function.
5428 define g(x,y) {static mat A[2]; A += {x,y}; return A;}
5434 The two sequences displayed for f should show the different ways
5435 the parameter is displayed. The third sequence for g should also
5436 show the effects of the static declaration of A.
5438 Fixed a number of compiler warning and type cast problems.
5440 Added a number of new error codes.
5442 Misc bug fixes for gcc2 based Sparc systems.
5444 Fixed a bug in the SVAL() macro on systems with 'long long'
5445 type and on systems with 16 bit HALFs.
5447 Reduced the Makefile CC set:
5449 CCOPT are flags given to ${CC} for optimization
5450 CCWARN are flags given to ${CC} for warning message control
5451 CCMISC are misc flags given to ${CC}
5453 CFLAGS are all flags given to ${CC}
5454 [[often includes CCOPT, CCWARN, CCMISC]]
5455 ICFLAGS are given to ${CC} for intermediate progs
5457 CCMAIN are flags for ${CC} when files with main() instead of CFLAGS
5458 CCSHS are flags given to ${CC} for compiling shs.c instead of CFLAGS
5460 LCFLAGS are CC-style flags for ${LINT}
5461 LDFLAGS are flags given to ${CC} for linking .o files
5462 ILDFLAGS are flags given to ${CC} for linking .o files
5463 for intermediate progs
5465 CC is how the C compiler is invoked
5467 Added more tests to regress.cal.
5471 Moved config_print() from config.c to value.c so prevent printvalue()
5472 and freevalue() from being unresolved symbols for libcalc.a users.
5474 Calc will generate "maximum depth reached" messages or errors when
5475 reading or eval() is attempted at maximum input depth.
5477 Now each invocation of make is done via ${MAKE} and includes:
5479 MAKE_FILE=${MAKE_FILE}
5484 Setting MAKE_FILE= will cause make to not re-make if the Makefile
5487 Added libinit.c which contains the function libcalc_call_me_first().
5488 Users of libcalc.a MUST CALL libcalc_call_me_first BEFORE THEY USE
5489 ANY OTHER libcalc.a functions!
5491 Added support for the SGI IRIX6.2 (or later) Mongoose 7.0 (or later)
5492 C Compiler for the r4k, r8k and r10k. Added LD_NO_SHARED for
5493 non-shared linker support.
5495 Re-ordered and expanded options for the DEBUG make variable.
5497 Make a few minor cosmetic comment changes/fixes in the main Makefile.
5508 To initialize such an A one can use a statement like
5510 A = {{1,2,3}, {4,5,6}};
5512 or combine initialization with creation by:
5514 mat A[2][3] = {{1,2,3}, {4,5,6}};
5516 One would then have, for example, A[1][0] = 4. Also, the inner braces
5517 cannot be removed from the initialization for A:
5519 mat A[2][3] = {1,2};
5521 results in exactly the same as:
5525 Added rm("file") builtin to remove a file.
5527 The regress test sections that create files also use rm() to remove
5528 them before and afterward.
5530 Added 4400-4500 set to test new mat and obj initialization rules.
5532 Added 4600 to test version file operations.
5534 Added CCZPRIME Makefile variable to the set for the short term
5535 to work around a CC -O2 bug on some SGI machines.
5537 Added regression test of _ variables and function names.
5539 Added read of read and write, including read and write test for
5542 Fixed bug associated with read of a long string variable.
5544 Renumbered some of the early regress.cal test numbers to make room
5545 for more tests. Fixed all out of sequence test numbers. Fixed some
5546 malformed regression reports.
5548 Renamed STSIZE_BITS to OFF_T_BITS. Renamed SWAP_HALF_IN_STSIZE to
5552 The following are the changes from calc version 2.10.2t1 to 2.10.2t3:
5554 Fixed bug in the regression suite that made test3400 and test4100
5555 fail on correct computations.
5557 The randbit() builtin, when given to argument, returns 1 random bit.
5559 Fixed a bug in longlong.c which made is generate a syntax error
5560 on systems such as the PowerPC where the make variable LONGLONG
5563 By default, the Makefile leaves LONGLONG_BITS empty to allow for
5564 testing of 64 bit data types. A few hosts may have problems with
5565 this, but hopefully not. Such hosts can revert back to LONGLONG_BITS=0.
5567 Improved SGI support. Understands SGI IRIX6.2 performance issues
5568 for multiple architectures.
5570 Fixed a number of implicit conversion from unsigned long to long to avoid
5571 unexpected rounding, sign extension, or loss of accuracy side effects.
5573 Added SHSCC because shs.c contains a large expression that some
5574 systems need help in optimizing.
5576 Added "show files" to display information about all currently open files.
5578 Calc now prevents user-defined function having the same name as a
5581 A number of new error codes (more than 100) have been added.
5583 Added ctime() builtin for date and time as string value.
5584 Added time() builtin for seconds since 00:00:00 1 Jan 1970 UTC.
5585 Added strerror() builtin for string describing error type.
5586 Added freopen() builtin to reopen a file.
5587 Added frewind() builtin to rewind a file.
5588 Added fputstr() builtin to write a null-terminated string to a file.
5589 Added fgetstr() builtin to read a null-terminated string from a file.
5590 Added fgetfield() builtin to read next field from file.
5591 Added strscan() builtin to scan a string.
5592 Added scan() builtin to scan of a file.
5593 Added fscan() builtin to scan of a file.
5594 Added fscanf() builtin to do a formatted scan of a file.
5595 Added scanf() builtin to do a formatted scan of stdin.
5596 Added strscanf() builtin to do a formatted scan of a string.
5597 Added ungetc() builtin to unget character read from a file.
5599 As before, files opened with fopen() will have an id different from
5600 earlier files. But instead of returning the id to the FILEIO slot
5601 used to store information about it, calc simply uses consecutive
5602 numbers starting with 3. A calc file retains its id, even when the
5603 file has been closed.
5605 The builtin files(i) now returns the file opened with id == i
5606 rather than the file with slot number i. For any i <= lastid,
5607 files(i) has at some time been opened. Whether open or closed, it
5608 may be "reopened" with the freopen() command. This write to a file
5609 and then read it, use:
5611 f = fopen("junk", "w")
5614 To use the same stream f for a new file, one may use:
5616 freopen(f, mode, newfilename)
5618 which closes f (assuming it is open) and then opens newfilename on f.
5622 f = fopen("curds", "r")
5623 g = fopen("curds", "r")
5625 results in two file ids (f and g) that refer to the same file
5626 name but with different pointers.
5628 Calc now understands "w+", "a+" and "r+" file modes.
5630 If calc opens a file without a mode there is a "guess" that mode
5631 "r+" will work for any files with small descriptors found to be
5632 open. In case it doesn't (as apparently happens if the file had
5633 not been opened for both reading and reading) the function now also
5634 tries "w" and "r", and if none work, gives up. This avoids having
5635 "open" files with null fp.
5637 The builtin rewind() calls the C rewind() function, but one may
5638 now rewind several files at once by a call like rewind(f1, f2).
5639 With no argument, rewind() rewinds all open files with id >= 3.
5641 The functions fputstr(), fgetstr() have been defined to include the
5642 terminating '\0' when writing a string to a file. This can be done
5643 at present with a sequence of instructions like:
5645 fputs(f, "Landon"); fputc(f, 0);
5646 fputs(f, "Curt"); fputc(f, 0);
5647 fputs(f, "Noll"); fputc(f, 0);
5651 fputstr(f, "Landon", "Curt", "Noll");
5653 and read them back by:
5656 x = fgetstr(f); /* returns "Landon" */
5657 y = fgetstr(f); /* returns "Curt" */
5658 z = fgetstr(f); /* returns "Noll" */
5660 The builtin fgetfield() returns the next field of non-whitepsace
5663 The builtins scan(), fscan(), strscan() read tokens (fields of
5664 non-whitepsace characters) and evaluates them. Thus:
5667 strscan("2+3 4^2\n c=a+b", a, b, 0);
5669 results in a = 5, b = 16, c = 21
5671 The functions scanf, fscanf, strscanf behave like the C functions
5672 scanf, fscanf, sscanf. The conversion specifiers recognized are "%c",
5673 "%s", "%[...]" as in C, with the options of *, width-specification,
5674 and complementation (as in [^abc]), and "%n" for file-position, and
5675 "%f", "%r", "%e", "%i" for numbers or simple number-expressions - any
5676 width-specification is ignored; the expressions are not to include any
5677 white space or characters other than decimal digits, +, -, *, /, e, and i.
5678 E.g. expressions like 2e4i+7/8 are acceptable.
5680 The builtin size(x) now returns the size of x if x is an open file
5681 or -1 if x is a file but not open. If s is a string, size(s) returns
5684 Added builtin access("foo", "w") returns the null value if a file
5685 "foo" exists and is writable.
5687 Some systems has a libc symbolic qadd() that conflicted with calc's
5688 qadd function. To avoid this, qadd() has been renamed to qqadd().
5690 The calc error codes are produced from the calcerr.tbl file.
5691 Instead of changing #defines in value.h, one can not edit calcerr.tbl.
5692 The Makefile builds calcerr.h from this file.
5694 Calc error codes are now as follows:
5697 0 .. sys_nerr-1 system error ala C's errno values
5698 sys_nerr .. E__BASE-1 reserved for future system errors
5699 E__BASE .. E__HIGHEST calc internal errors
5700 E__HIGHEST+1 .. E_USERDEF-1 invalid
5701 E_USERDEF .. user defined errors
5703 Currently, E__BASE == 10000 and E_USERDEF == 20000. Of course,
5704 sys_nerr is system defined however is likely to be < E__BASE.
5706 Renamed CONST_TYPE (as defined in have_const.h) to just CONST.
5707 This symbol will either be 'const' or an empty string depending
5708 on if your compiler understands const.
5710 CONST is beginning to be used with read-only tables and some
5711 function arguments. This allows certain compilers to better
5712 optimize the code as well as alerts one to when some value
5713 is being changed inappropriately. Use of CONST as in:
5715 int foo(CONST int curds, char *CONST whey)
5717 while legal C is not as useful because the caller is protected
5718 by the fact that args are passed by value. However, the
5721 int bar(CONST char *fizbin, CONST HALF *data)
5723 is useful because it calls the compiler that the string pointed
5724 at by 'fizbin' and the HALF array pointer at by 'data' should be
5725 treated as read-only.
5728 The following are the changes from calc version 2.10.1t21 to 2.10.2t0:
5730 Bumped patch level 2.10.2t0 in honor of having help files for
5731 all builtin functions. Beta release will happen at the end of
5734 Fewer items listed in BUGS due to a number of bug fixes.
5736 Less todo in the help/todo file because more has already been done. :-)
5738 All builtin functions have help files! While a number need cleanup
5739 and some of the LIMITS, LIBRARY and SEE ALSO sections need fixing
5740 (or are missing), most of it is there. A Big round of thanks goes to
5741 <ernie at turing dot une dot edu dot au> for his efforts in initial
5742 write-ups for many of these files!
5744 The recognition of '\' as an escape character in the format argument
5745 of printf() has been dropped. Thus:
5749 will print the two-character string "\n" rather than the a
5750 one-character carriage return. <ernie at turing dot une dot edu dot au>
5752 Missing args to printf-like functions will be treated as null values.
5754 The scope of of config("fullzero") has been extended to integers,
5755 so that for example, after config("mode","real"), config("display", 5),
5756 config("fullzero", 1), both:
5759 printf("%d %d %d\n", 0, 1, 2);
5763 .00000 1.00000, 2.00000
5765 The bug which caused calc to exit on:
5770 has been fixed. <ernie at turing dot une dot edu dot au>
5772 Fixed bugs in zio.c which caused eval(str(x)) == x to fail
5773 in non-real modes such as "oct". <ernie at turing dot une dot edu dot au>
5777 for (i = 1; i < 10; i++) print i^2,;
5779 now prints the same as:
5781 for (i = 1; i < 10; i++) print i^2,;
5783 The show globals will print '...' in the middle of large values.
5784 <ernie at turing dot une dot edu dot au>
5786 The param(n) builtin, then n > 0, returns the address rather than
5787 the value of the n-th argument to save time and memory usage. This
5788 is useful when a matrix with big number entries is passed as an arg.
5789 <ernie at turing dot une dot edu dot au>
5791 The param(n) builtin, then n > 0, may be used as an lvalue:
5793 ; define g() = (param(2) = param(1));
5794 ; define h() = (param(1)++, param(2)--);
5797 ; print g(u, &v), u, v;
5799 ; print h(&u, &v), u, v;
5802 Missing args now evaluate to null as in:
5810 The following are the changes from calc version 2.10.1t20 to 2.10.1t20:
5812 Changes made in preparation for Blum Blum Shub random number generator.
5814 REDC bug fixes: <ernie at turing dot une dot edu dot au>
5816 Fixed yet another bug in zdiv which occasionally caused the "top digit"
5817 of a nonzero quotient to be zero.
5819 Fixed a bug in zredcmul() where a rarely required "topdigit" is
5820 sometimes lost rather than added to the appropriate carry.
5822 A new function zredcmodinv(ZVALUE z, ZVALUE *res) has been defined
5823 for evaluating rp->inv in zredcalloc(). <ernie at turing dot une
5826 New functions zmod5(ZVALUE *zp) and zmod6(ZVALUE z, ZVALUE *res)
5827 have been defined to give O(N^1.585)-runtime evaluation of z % m
5828 for large N-word m. These require m and BASE^(2*N) // m to have
5829 been stored at named locations lastmod, lastmodinv. zmod5() is
5830 essentially for internal use by zmod6() and zpowermod(). <ernie at
5831 turing dot une dot edu dot au>
5833 Changes to rcmul(x,y,m) so that the result is always in [0, m-1].
5834 <ernie at turing dot une dot edu dot au>
5836 Changes to some of the detail of zredcmul() so that it should run slightly
5837 faster. Also changes to zredcsq() in the hope that it might achieve
5838 something like the improvement in speed of x^2 compared with x * x.
5839 <ernie at turing dot une dot edu dot au>
5841 A new "bignum" algorithm for evaluating pmod(x,k,m) when
5842 N >= config("pow2"). For the multiplications and squaring
5843 modulo m, or their equivalent, when N >= config("redc2"),
5844 calc has used evaluations corresponding to rcout(x * y, m),
5845 for which the runtime is essentially that of three multiplications.
5846 <ernie at turing dot une dot edu dot au>
5848 Yet more additions to the regress.cal test suite.
5850 Fixed some ANSI-C compile nits in shs.c and quickhash.c.
5852 Plugs some potential memory leaks in definitions in func.c.
5853 Expressions such as qlink(vals[2]) in some circumstances are
5854 neither qfreed nor returned as function values.
5855 <ernie at turing dot une dot edu dot au>
5857 The nextcand() and prevcand() functions handle modval, modulus
5858 and skip by using ZVALUE rather than ZVALUE * and dropping
5859 the long modulus, etc. <ernie at turing dot une dot edu dot au>
5861 Changed a couple of occurrences of itoq(1) or itoq(0) to &_qone_
5862 and &_qzero_. <ernie at turing dot une dot edu dot au>
5864 In definition of f_primetest, changed ztolong(q2->num) to ztoi(q2->num)
5865 so that the sign of count in ptest(n, count, skip) is not lost; and
5866 ztolong(q3->num) to q3->num so that skip can be any integer.
5867 <ernie at turing dot une dot edu dot au>
5869 In zprime.c, in definition of small_factor(), adds "&& *tp != 1" to
5870 the exit condition in the for loop so that searching for a factor
5871 will continue beyond the table of primes, as required for e.g.
5872 factor(2^59 - 1). <ernie at turing dot une dot edu dot au>
5874 Changed zprimetest() so that skip in ptest(n, count, skip)
5875 determines the way bases for the tests are selected. Neg values of
5876 n are treated differently. When considering factorization,
5877 primeness, etc. one is concerned with equivalence classes which for
5878 the rational integers are {0}, {-1, 1}, {-2, 2}, etc. To refer to
5879 an equivalence class users may use any of its elements but when
5880 returning a value for a factor the computer normally gives the
5881 non-negative member. The same sort of thing happens with integers
5882 modulo an integer, with fractions, etc., etc. E.g. users may refer
5883 to 3/4 as 6/8 or 9/12, etc. A simple summary of the way negative n
5884 is treated is "the sign is ignored". E.g. isprime(-97) and
5885 nextprime(-97) now return the same as isprime(97) and nextprime(97).
5886 <ernie at turing dot une dot edu dot au>
5889 The following are the changes from calc version 2.10.1t11 to 2.10.1t19:
5891 Added many more regression tests to lib/regress.cal. Some
5892 due to <ernie at turing dot une dot edu dot au>.
5894 Added many help files, most due to <ernie at turing dot une dot edu dot au>.
5896 Fixed exp() and ln() so that when they return a complex value with
5897 a zero imaginary component, isreal() is true. <ernie at turing dot
5900 Fixed cast problem in byteswap.c. <ernie at turing dot une dot edu dot au>
5902 Fixed memory leak problem where repeated assignments did not
5903 free the previous value. <ernie at turing dot une dot edu dot au>
5905 Complex number ordering/comparison has been changed such that:
5907 a < b implies a + c < b + c
5908 a < b and c > 0 implies a * c < b * c
5909 a < b implies -a > -b
5911 To achieve a "natural" partial ordering of the complex numbers
5912 with the above properties, cmp(a,b) for real or complex numbers
5913 may be considered as follows:
5915 cmp(a,b) = sgn(re(a) - re(b)) + sgn(im(a) - im(b)) * 1i
5917 The cmp help file has been updated.
5919 Change HASH type to QCKHASH. The HASH type is a name better suited
5920 for the upcoming one-way hash interface.
5922 Added the CONFIG type; a structure containing all of the configuration
5923 values under the control of config(). Added V_CONFIG data type.
5924 The call config("all") returns a V_CONFIG. One may now save/restore
5925 the configuration state as follows:
5931 Added two configuration aliases, "oldstd" (for old backward compatible
5932 standard configuration) and "newstd" (for new style configuration).
5933 One may set the historic configuration state by:
5935 config("all", "oldstd")
5937 One may use what some people consider to be a better but not backward
5938 compatible configuration state by:
5940 config("all", "newstd")
5942 Renamed config.h (configuration file built during the make) to conf.h.
5943 Added a new config.h to contain info on thw V_CONFIG type.
5945 Fixed some ANSI C compile warnings.
5947 The show config output is not indented by only one tab, unless
5948 config("tab",0) in which case it is not indented.
5950 The order of show config has been changed to reflect the config
5953 Changed declaration of sys_errlst in func.c to be char *.
5955 Added quo(x,y,rnd) and mod(x,y,rnd) to give function interfaces
5956 to // and % with rounding mode arguments. Extended these functions
5957 to work for list-values, complex numbers and matrices.
5958 <ernie at turing dot une dot edu dot au>
5960 For integer x, cfsim(x,8) returns 0.
5961 <ernie at turing dot une dot edu dot au>
5963 Fixed config("leadzero"). <ernie at turing dot une dot edu dot au>
5965 Set config("cfsim",8) by default (in "oldstd"). Setup initial idea for
5966 config("all", "newstd") to be the default with the following changes:
5974 prompt "; " (allows full line cut/paste)
5975 more ";; " (allows full line cut/paste)
5977 The "newstd" is a (hopefully) more preferred configuration than the
5980 The fposval.h file defines DEV_BITS and INODE_BITS giving the
5981 bit size of the st_dev and st_ino stat elements. Also added
5982 SWAP_HALF_IN_DEV and SWAP_HALF_IN_STSIZE.
5984 Added sec(), csc(), cot(), sech(), csch(), coth(), asec(), acsc(),
5985 acot(), asech(), acsch() and acoth() builtins. <ernie at turing dot
5988 The initmasks() call is no longer needed. The bitmask[] array
5989 is a compiled into zmath.c directly.
5991 Added isconfig(), ishash(), isrand() and israndom() builtins to
5992 test is something is a configuration state, hash state, RAND
5993 state or RANDOM state.
5995 The lib/cryrand.cal library now no longer keeps the Blum prime
5996 factors used to form he Blum modulus. The default modulus has
5997 been expanded to 1062 bits product of two Blum primes.
5999 The function hash_init() is called to initialize the hash function
6002 Misc calc man page fixes and new command line updates.
6004 Fixed bug related to srand(1).
6006 Cleaned up some warning messages.
6008 All calls to math_error() now have a /*NOTREACHED*/ comment after
6009 them. This allows lint and compiler flow progs to note the jumpjmp
6010 nature of math_error(). Unfortunately some due to some systems
6011 not dealing with /*NOTREACHED*/ comments correctly, calls of the form:
6016 must be turned into:
6023 The ploy() function can take a list of coefficients. See the
6024 help/poly file. Added poly.c. <ernie at turing dot une dot edu
6027 Fixes and performance improvements to det(). <ernie at turing dot
6030 Renamed atoq() and atoz() to str2q() and str2z() to avoid conflicts
6031 with libc function names.
6033 Fixed use of ${NROFF_ARG} when ${CATDIR} and ${NROFF} are set.
6035 Fixed SWAP_HALF_IN_B64 macro use for Big Endian machines without
6036 long long or with LONGLONG_BITS=0.
6038 Added error() and iserror() to generate a value of a given error type.
6039 See help/error for details. <ernie at turing dot une dot edu dot au>
6041 Added singular forms of help files. For example one can now get
6042 help for binding, bug, change, errorcode and type.
6044 The builtin mmin(x, md) has been changed to return the same as
6045 mod(x, md, 16). The old mmin(x, md) required md to be a positive
6046 integer and x to be an integer. Now md can be any real number; x
6047 can be real, complex, or a matrix or list with real elements, etc.
6048 <ernie at turing dot une dot edu dot au>
6050 The builtin avg(x_1, x_2, ...) has been changed to accept list-valued
6051 arguments: a list x_i contributes its elements to the list of
6052 items to be averaged. E.g. avg(list(1,2,list(3,4)),5) is treated
6053 as if it were avg(1,2,3,4,5). If an error value is encountered in
6054 the items to be averaged, the first such value is returned. If the
6055 number of items to be averaged is zero, the null value is returned.
6056 <ernie at turing dot une dot edu dot au>
6058 The builtin hmean(x_1, x_2, ...) has been changed to admit types
6059 other than real for x_1, x_2, ...; list arguments are treated in
6060 the same way as in avg(). <ernie at turing dot une dot edu dot au>
6062 The builtin eval(str) has been changed so that when str has a
6063 syntax error, instead of call to math_error(), an error value is
6064 returned. <ernie at turing dot une dot edu dot au>
6066 The old frem(x,y) builtin returned the wrong value when y was a power of
6067 2 greater than 2, e.g. f(8,4) is returned as 4 when its value should be 2.
6068 This has been fixed by a small change to the definition of zfacrem().
6069 Calc used to accept with no warning or error message, gcdrem(0,2) or
6070 generally gcdrem(0,y) for any y with abs(y) > 1, but then went into an
6071 infinite loop. This has been fixed by never calling zfacrem() with zero x.
6072 Both frem(x,y) and gcdrem(x,y) now reject y = -1, 0 or 1 as errors. For
6073 nonzero x, and y == -1 or 1, defining frem(x,y) and gcdrem(x,y) to equal
6074 abs(x) is almost as natural as defining x^0 to be 1. Similarly, if x is
6075 not zero then gcdrem(x,0) == 1. <ernie at turing dot une dot edu dot au>
6077 Plugged some more memory leaks.
6079 Fixed bug related randbit(x) skip (where x < 0).
6081 Added seedrandom.cal to help users use the raw random() interface well.
6083 Made extensive additions and changes to the rand() and random() generator
6084 comments in zrand.c.
6086 Fixed a bug in fposval.c that prevented calc from compiling on systems
6087 with 16 bit device and/or inodes. Fixed error messages in fposval.c.
6089 Fixed bug that would put calc into an infinite loop if it is ran
6090 with errors in startup files (calc/startup, .calcrc).
6091 Ha Lam <hl at kuhep5 dot phsx dot ukans dot edu>
6094 The following are the changes from calc version 2.10.0t13 to 2.10.1t10:
6096 Added SB8, USB8, SB16, USB16, SB32, USB32 typedefs, determined by
6097 longbits and declared in longbits.h, to deal with 8, 16 and 32 bit
6098 signed and unsigned values.
6100 The longbits.h will define HAVE_B64 with a 64 bit type (long or
6101 longlong) is available. If one is, then SB64 and US64 typedefs
6104 The U(x) and L(x) macros only used to define 33 to 64 bit signed
6105 and unsigned constants. Without HAVE_B64, these macros cannot
6108 Changed the way zmath.h declares types such as HALF and FULL.
6110 Changed the PRINT typedef.
6112 The only place where the long long type might be used is in longlong.c
6113 and if HAVE_LONGLONG, in longbits.h if it is needed. The only place
6114 were a long long constant might be used is in longlong.c. Any
6115 long long constants, if HAVE_LONGLONG, are hidden under the U(x) and
6116 L(x) macros on longbits.h. And of course, if you don't have long long,
6117 then HAVE_LONGLONG will NOT be defined and long long's will not be used.
6119 The longlong.h file is no longer directly used by the main calc source.
6120 It only comes into play when compiling the longbits tool.
6122 Added config("prompt") to change the default interactive prompt ("> ")
6123 and config("more") to change the default continuation prompt (">> ").
6125 Makefile builds align32.h with determines if 32 bit values must always
6126 be aligned on 32 bit boundaries.
6128 The CALCBINDINGS file is searched for along the CALCPATH. The Makefile
6129 defines the default CALCBINDINGS is "bindings" (or "altbind") which
6130 is now usually found in ./lib or ${LIBDIR}.
6132 Per Ernest Bowen <ernie at turing dot une dot edu dot au>, an optional
6133 third argument was added sqrt() so that in sqrt(x,y,z), y and z have
6134 essentially the same role as in appr(x,y,z) except that of course
6135 what is being approximated is the sqrt of x. Another difference is
6136 that two more bits of z are used in sqrt: bit 5 gives the option of
6137 exact results when they exist (the value of y is then ignored) and
6138 bit 6 returns the non-principal root rather than the principal value.
6140 If commands are given on the command line, leading tabs are not
6141 printed in output. Giving a command on the command line implies
6142 that config("tab",0) was given.
6144 Pipe processing is enabled by use of -p. For example:
6146 echo "print 2^21701-1, 2^23209-1" | calc -p | fizzbin
6148 In pipe mode, calc does not prompt, does not print leading tabs
6149 and does not print the initial version header.
6151 Calc will now form FILE objects for any open file descriptor > 2
6152 and < MAXFILES. Calc assumes they are available for reading
6153 and writing. For example:
6155 $ echo "A line of text in the file on descriptor 5" > datafile
6157 C-style arbitrary precision calculator (version 2.10.1t3)
6158 [Type "exit" to exit, or "help" for help.]
6161 FILE 5 "descriptor[5]" (unknown_mode, pos 0)
6162 ; fgetline(files(5))
6163 "A line of text in the file on descriptor 5"
6165 The -m mode flag now controls calc's ability to open files
6166 and execute programs. This mode flag is a single digit that
6167 is processed in a similar way as the octal chmod values:
6169 0 do not open any file, do not execute progs
6170 1 do not open any file
6171 2 do not open files for reading, do not execute progs
6172 3 do not open files for reading
6173 4 do not open files for writing, do not execute progs
6174 5 do not open files for writing
6175 6 do not execute any program
6176 7 allow everything (default mode)
6178 Thus if one wished to run calc from a privileged user, one might
6179 want to use -m 0 in an effort to make calc more secure.
6181 The -m flags for reading and writing apply on open.
6182 Files already open are not effected. Thus if one wanted to use
6183 the -m 0 in an effort to make calc more secure, but still be
6184 able to read and write a specific file, one might do:
6186 calc -m 0 3<a.file 4>b.file
6188 NOTE: Files presented to calc in this way are opened in an unknown
6189 mode. Calc will try to read or write them if directed.
6191 The maximum command line size it MAXCMD (16384) bytes. Calc objects to
6192 command lines that are longer.
6194 The -u flag cause calc to un-buffer stdin and stdout.
6196 Added more help files. Improved other help files.
6198 Removed trailing blanks from files.
6200 Removed or rewrite the formally gross and disgusting hacks for
6201 dealing with various sizes and byte sex FILEPOS and off_t types.
6203 Defined ilog2(x), ilog10(x), ilog(x,y) so that sign of x is ignored,
6204 e.g. ilog2(x) = ilog2(abs(x)).
6206 The sixth bit of rnd in config("round", rnd) and config("bround", rnd)
6207 is used to specify rounding to the given number of significant
6208 digits or bits rather than places, e.g. round(.00238, 2, 32)
6209 returns .0023, round(.00238, 2, 56) returns .0024.
6212 The following are the changes from calc version 2.9.3t11 to 2.10.0t12:
6214 The default ${LIBDIR}/bindings CALCBINDINGS uses ^D for editing.
6215 The alternate CALCBINDINGS ${LIBDIR}/altbind uses ^D for EOF.
6217 The Makefile CC flag system has been changed. The new CC flag system
6220 CCMAIN are flags for ${CC} when compiling only files with main()
6221 CCOPT are flags given to ${CC} for optimization
6222 CCWARN are flags given to ${CC} for warning message control
6223 CCMISC are misc flags given to ${CC}
6225 CNOWARN are all flags given to ${CC} except ${CCWARN} flags
6226 CFLAGS are all flags given to ${CC}
6227 ICFLAGS are given to ${CC} for intermediate progs
6229 LCFLAGS are CC-style flags for ${LINT}
6230 LDFLAGS are flags given to ${CC} for linking .o files
6231 ILDFLAGS are given to ${CC} for linking .o's for intermediate progs
6233 CC is how the C compiler is invoked
6239 used to send calc into a loop printing 'missing expression'. This
6242 Added config("maxerr") and config("maxerr",val) to control the
6243 maximum number of errors before a computation is aborted.
6245 Removed regress.cal test #952 and #953 in case calc's stdout or
6246 stderr is re-directed to a non-file by some test suite.
6248 Changed how <stdarg.h>, <varags.h> or simulate stdarg is determined.
6249 Changed how vsprintf() vs sprintf() is determined. The args.h file
6250 is created by Makefile to test which combination works. Setting
6251 VARARG and/or HAVE_VSPRINTF in the Makefile will alter these tests
6252 and direct a specific combination to be used. Removed have_vs.c,
6253 std_arg.h and try_stdarg.c. Added have_stdvs.c and have_varvs.c.
6255 Added 3rd optional arg to round(), bround(), appr() to specify the type of
6256 rounding to be used.
6258 Moved fnvhash.c to quickhash.c.
6260 Fixed a bug in appr rounding mode when >= 16.
6262 Added test2600.cal and test2700.cal. They are used by the regress.cal
6263 to provide a more extensive test suite for some builtin numeric
6267 The following are the changes from calc version 2.9.3t9.2+ to 2.9.3t10:
6269 Added many help files for builtin functions and some symbols.
6270 More help files are needed, see help/todo.
6272 Removed the calc malloc code. Calc now uses malloc and free to
6273 manage storage since these implementations are often written to
6274 work best for the local system. Removed CALC_MALLOC code and
6275 Makefile symbol. Removed alloc.c.
6277 Added getenv("name"), putenv("name=val") and putenv("name, "val")
6278 builds for environment variable support thanks to "Dr." "D.J." Picton
6279 <dave at aps2 dot ph dot bham dot ac dot uk>.
6281 Added system("shell command") builtin to execute shell commands,
6282 thanks to "Dr." "D.J." Picton <dave at aps2 dot ph dot bham dot ac dot uk>.
6284 Added isatty(fd) builtin to determine if fd is attached to a tty
6285 thanks to "Dr." "D.J." Picton <dave at aps2 dot ph dot bham dot ac dot uk>.
6287 Added cmdbuf() builtin to return the command line executed by calc's
6288 command line args thanks to "Dr." "D.J." Picton <dave at aps2 dot
6289 ph dot bham dot ac dot uk>.
6291 Added strpos(str1,str2) builtin to determine the first position where
6292 str2 is found in str1 thanks to "Dr." "D.J." Picton
6293 <dave at aps2 dot ph dot bham dot ac dot uk>.
6295 Fixed bug that caused:
6297 global a,b,c (newline with no semicolon)
6300 the read command to not be recognized.
6302 The show command looks at only the first 4 chars of the argument so
6311 Added show config to print the config values and parameters thanks
6312 to Ernest Bowen <ernie at turing dot une dot edu dot au>.
6314 Added show objtypes to print the defined objects thanks to Ernest Bowen
6315 <ernie at turing dot une dot edu dot au>.
6317 Added more builtin function help files.
6319 Fixed the 3rd arg usage of the root builtin.
6321 Expanded the regress.cal regression test suite.
6323 Fixed -- and ++ with respect to objects and assignment (see the 2300
6324 series in regress.cal).
6326 Added isident(m) to determine if m is an identity matrix.
6328 The append(), insert() and push() builtins can now append between
6329 1 to 100 values to a list.
6331 Added reverse() and join() builtins to reverse and join lists
6332 thanks to Ernest Bowen <ernie at turing dot une dot edu dot au>.
6334 Added sort() builtin to sort lists thanks to Ernest Bowen
6335 <ernie at turing dot une dot edu dot au>.
6337 Added head(), segment() and tail() builtins to return the head,
6338 middle or tail of lists thanks to Ernest Bowen <ernie at turing dot
6339 une dot edu dot au>.
6341 Added more and fixed some help files.
6343 The builtin help file is generated by the help makefile. Thus it will
6344 reflect the actual calc builtin list instead of the last time someone
6345 tried to update it correctly. :-)
6347 Fixed non-standard void pointer usage.
6349 Fixed base() bug with regards to the default base.
6351 Renamed MATH_PROTO() and HIST_PROTO() to PROTO(). Moved PROTO()
6354 Fixed many function prototypes. Calc does not declare functions
6355 as static in one place and extern in another. Where reasonable
6356 function prototypes were added. Several arg mismatch problems
6359 Added support for SGI MIPSpro C compiler.
6361 Changes the order that args are declared to match the order
6362 of the function. Some source tools got confused when:
6363 arg order did not match as in:
6367 int bar; /* this caused a problem */
6368 char *foo; /* even though it should not! */
6373 The following are the changes from calc version 2.9.3t8 to 2.9.3t9.2:
6375 Use of the macro zisleone(z) has been clarified. The zisleone(z) macro
6376 tests if z <= 1. The macro zisabsleone(z) tests of z is 1, 0 or -1.
6377 Added zislezero(z) macro. Bugs are related to this confusion have
6380 Added zge64b(z) macro to zmath.h.
6382 Added the macro zgtmaxufull(z) to determine if z will fit into a FULL.
6383 Added the macro zgtmaxlong(z) to determine if z will fit into a long.
6384 Added the macro zgtmaxulong(z) to determine if z will fit into a unsigned
6387 Added the macro ztoulong(z) to convert an absolute value of a ZVALUE to
6388 an unsigned long, or to convert the low order bits of a ZVALUE.
6389 Added the macro ztolong(z) to convert an absolute value of a ZVALUE to
6390 an long, or to convert the low order bits of a ZVALUE.
6392 Some non-ANSI C compilers define __STDC__ to be 0, whereas all ANSI
6393 C compiles define it as non-zero. Code that depends on ANSI C now
6394 uses #if defined(__STDC__) && __STDC__ != 0.
6396 Fixed ptest(a,b) bug where (a mod 2^32) < b. Previously ptest()
6397 incorrectly returned 1 in certain cases.
6399 The second ptest() argument, which is now optional, defaults to 1.
6400 This ptest(x) is the same as ptest(x,1).
6402 Added an optional 3rd argument to ptest(). The 3rd arg tells how many
6403 tests to skip. Thus ptest(a,10) performs the same probabilistic
6404 tests as ptest(a,3) and ptest(a,7,3).
6406 The ptest() builtin by default will determine if a value is divisible
6407 by a trivial prime. Thus, ptest(a,0) will only perform a quick trivial
6408 factor check. If the test count is < 0, then this trivial factor check
6409 is omitted. Thus ptest(a,10) performs the same amount of work as
6410 ptest(a,3) and ptest(a,-7,3) and the same amount of work as
6411 ptest(a,-3) and ptest(a,7,3).
6413 Added nextcand(a[,b[,c]]) and prevcand(a[,b[,c]]) to search for the
6414 next/previous value v > a (or v < a) that passes ptest(v[,b[,c]]).
6415 The nextcand() and prevcand() builtins take the same arguments
6418 Added nextprime(x) and and prevprime(x) return the next and
6419 previous primes with respect to x respectively. As of this
6420 release, x must be < 2^32. With one argument, they will return
6421 an error if x is out of range. With two arguments, they will
6422 not generate an error but instead will return y.
6424 Fixed some memory leaks, particularly those related with pmod().
6426 Fixed some of the array bounds reference problems in domult().
6428 Added a hack-a-round fix for the uninitialized memory reference
6429 problems in zsquare/dosquare.
6431 The LIBRARY file has been updated to include a note about calling
6432 zio_init() first. Also some additional useful macros have been noted.
6434 The lfactor() function returns -1 when given a negative value.
6435 It will not search for factors beyond 2^32 or 203280221 primes.
6436 Performance of lfactor() has been improved.
6438 Added factor(x,y) to look for the smallest factor < min(sqrt(x),y).
6440 Added libcalcerr.a for a math_error() routine for the convince of
6441 progs that make use of libcalc.a. This routine by default will
6442 print an message on stderr and exit. It can also be made to
6443 longjump instead. See the file LIBRARY under ERROR HANDING.
6445 Added isprime() to test if a value is prime. As of this release,
6446 isprime() is limited to values < 2^32. With one argument,
6447 isprime(x) will return an error if x is out of range. With
6448 two arguments, isprime(x,y) will not generate an error but
6449 instead will return y.
6451 Added pix(x) to return the number of primes <= x. As of this
6452 release, x must be < 2^32. With one argument, pix(x) will
6453 return an error if x is out of range. With two arguments,
6454 pix(x,y) will not generate an error but instead will return y.
6456 Fixed the way *.h files are formed. Each file guards against
6459 Fixed numeric I/O on 64 bit systems. Previously the print and
6460 constant conversion routines assumed a base of 2^16.
6462 Added support for 'long long' type. If the Makefile is setup
6463 with 'LONGLONG_BITS=', then it will attempt to detect support
6464 for the 'long long' type. If the Makefile is setup with
6465 'LONGLONG_BITS=64', then a 64 bit 'long long' is assumed.
6466 Currently, only 64 bit 'long long' type is supported.
6467 Use of 'long long' allows one to double the size of the
6468 internal base, making a number of computations much faster.
6469 If the Makefile is setup with 'LONGLONG_BITS=0', then the
6470 'long long' type will not be used, even if the compiler
6473 Fixed avg() so that it will correctly handle matrix arguments.
6475 Fixed btrunc() limit.
6477 The ord("string") function can now take a string of multiple
6478 characters. However it still will only operate on the first
6481 Renamed stdarg.h to std_arg.h and endian.h endian_calc.h to
6482 avoid name conflicts with /usr/include on some systems that
6483 have make utilities that are too smart for their own good.
6485 Added additive 55 shuffle generator functions rand(), randbits()
6486 and its seed function srand(). Calling rand(a,b) produces a
6487 random value over the open half interval [a,b). With one arg,
6488 rand(a) is equivalent to rand(0,a). Calling rand() produces
6489 64 random bits and is equivalent to rand(0,2^64).
6491 Calling randbit(x>0) produces x random bits. Calling randbit(skip<0)
6492 skips -skip bits and returns -skip.
6494 The srand() function will return the current state. The call
6495 srand(0) returns the initial state. Calling srand(x), where
6496 x > 0 will seed the generator to a different state. Calling
6497 srand(mat55) (mat55 is a matrix of integers at least 55 elements long)
6498 will seed the internal table with the matrix elements mod 2^64.
6499 Finally calling srand(state) where state is a generator state
6500 also sets/seeds the generator.
6502 The cryrand.cal library has been modified to use the builtin
6503 rand() number generator. The output of this generator is
6504 different from previous versions of this generator because
6505 the rand() builtin does not match the additive 55 / shuffle
6506 generators from the old cryrand.cal file.
6508 Added Makfile support for building BSD/386 releases.
6510 The cmp() builtin can now compare complex values.
6512 Added the errno() builtin to return the meaning of errno numbers.
6514 Added fputc(), fputs(), fgets(), ftell(), fseek() builtins.
6516 Added fsize() builtin to determine the size of an open file.
6518 Supports systems where file positions and offsets are longer than 2^32
6519 byte, longer than long and/or are not a simple type.
6521 When a file file is printed, the file number is also printed:
6523 FILE 3 "/etc/motd" (reading, pos 127)
6525 Added matsum() to sum all numeric values in a matrix.
6527 The following code now works, thanks to a fix by <ernie at turing
6528 dot une dot edu dot au> (Ernest Bowen):
6530 mat A[3] = {1, 2, 3};
6534 Also thanks to ernie, calc can process compound expressions
6535 such as 1 ? 2 ? 3 : 4 : 5.
6537 Also^2 thanks to ernie, the = operator is more general:
6539 (a = 3) = 4 (same as a = 3; a = 4)
6540 (a += 3) *= 4 (same as a += 3; a *= 4)
6541 matfill(B = A, 4) (same as B = A; matfill(B, 4);)
6543 Also^3 thanks to ernie, the ++ and -- operators are more general.
6546 ++(b = a) (a == 3, b == 4)
6548 (++a)++ == 6 (a == 7)
6549 (++a) *= b (a == 32, b == 4)
6551 Fixed a bug related to calling epsilon(variable) thanks to ernie.
6553 Removed trailing whitespace from source and help files.
6555 Some compilers do not support the const type. The file have_const.h,
6556 which is built from have_const.c will determine if we can or should
6557 use const. See the Makefile for details.
6559 Some systems do not have uid_t. The file have_uid_t.h, which is
6560 built from have_uid_t.c will determine if we can or should depend
6561 on uid_t being typefed by the system include files. See the Makefile
6564 Some systems do not have memcpy(), memset() and strchr(). The
6565 file have_newstr.h, which is built from have_newstr.c will
6566 determine if we can or should depend libc providing these
6567 functions. See the Makefile for details.
6569 The Makefile symbol DONT_HAVE_VSPRINTF is now called HAVE_VSPRINTF.
6570 The file have_vs.h, which is built from have_vs.c will determine if
6571 we can or should depend libc providing vsprintf(). See the Makefile
6574 Removed UID_T and OLD_BSD symbols from the Makefile.
6576 A make all of the upper level Makefile will cause the all rule
6577 of the lib and help subdirs to be made as well.
6579 Fixed bug where reserved keyword used as symbol name caused a core dump.
6582 The following are the changes from calc version 2.9.3t7 to 2.9.3t7:
6584 The 'show' command by itself will issue an error message
6585 that will remind one of the possible show arguments.
6586 (thanks to Ha S. Lam <hl at kuhep4 dot phsx dot ukans dot edu>)
6588 Fixed an ANSI-C related problem with the use of stringindex()
6589 by the show command. ANSI-C interprets "bar\0foo..." as if
6590 it were "bar\017oo...".
6592 Added a cd command to change the current directory.
6593 (thanks to Ha S. Lam <hl at kuhep4 dot phsx dot ukans dot edu>)
6595 Calc will not output the initial version string, startup
6596 message and command prompt if stdin is not a tty. Thus
6599 echo "fact(100)" | calc
6601 only prints the result. (thanks to Ha S. Lam <hl at kuhep4 dot phsx
6604 The zmath.h macro zisbig() macro was replaced with zlt16b(),
6605 zge24b(), zge31b(), zge32b() and zgtmaxfull() which are
6606 independent of word size.
6608 The 'too large' limit for factorial operations (e.g., fact, pfact,
6609 lcmfact, perm and comb) is now 2^24. Previously it depended on the
6610 word size which in the case of 64 bit systems was way too large.
6612 The 'too large' limit for exponentiation, bit position (isset,
6613 digit, ), matrix operations (size, index, creation), scaling,
6614 shifting, rounding and computing a Fibonacci number is 2^31.
6615 For example, one cannot raise a number by a power >= 2^31.
6616 One cannot test for a bit position >= 2^31. One cannot round
6617 a value to 2^31 decimal digit places. One cannot compute
6618 the Fibonacci number F(2^31).
6620 Andy Fingerhut <jaf at dworkin dot wustl dot edu> (thanks!) supplied
6621 a fix to a subtle bug in the code generation routines. The basic
6622 problem was that addop() is sometimes used to add a label to
6623 the opcode table of a function. The addop() function did some
6624 optimization tricks, and if one of these labels happens to be an
6625 opcode that triggers optimization, incorrect opcodes were generated.
6627 Added utoz(), ztou() to zmath.c, and utoq(), qtou() to qmath.c
6628 in preparation for 2.9.3t9 mods.
6631 The following are the changes from calc version 2.9.2 to 2.9.3t7:
6633 Calc can now compile on OSF/1, SGI and IBM RS6000 systems.
6635 A number of systems that have both <varargs.h> and <stdarg.h> do
6636 not correctly implement both types. On some System V, MIPS and DEC
6637 systems, vsprintf() and <stdarg.h> do not mix. While calc will
6638 pass the regression test, use of undefined variables will cause
6639 problems. The Makefile has been modified to look for this problem
6642 Added randmprime.cal which find a prime of the form h*2^n-1 >= 2^x
6643 for some given x. The initial search points for 'h' and 'n'
6644 are selected by a cryptographic pseudo-random generator.
6646 The library script nextprim.cal is now a link to nextprime.cal.
6647 The lib/Makefile will take care of this link and install.
6649 The show command now takes singular forms. For example, the
6650 command 'show builtin' does the same as 'show builtins'. This
6651 allows show to match the historic singular names used in
6654 Synced 'show builtin' output with 'help builtin' output.
6656 Fixed the ilog2() builtin. Previously ilog2(2^-20) returned
6659 The internal function qprecision() has been fixed. The changes
6660 ensure that for any e for which 0 < e <= 1:
6662 1/4 < sup(abs(appr(x,e) - x))/e <= 1/2.
6664 Here 'sup' denotes the least upper bound over values of x (supremum).
6665 Previously calc did: 1/4 <= sup(abs(appr(x,e) - x))/e < 1.
6667 Certain 64 bit processors such as the Alpha are now supported.
6669 Added -once to the READ command. The command:
6673 like the regular READ expect that it will ignore filename if
6674 is has been previously read.
6676 Improved the makefile. One now can select the compiler type. The
6677 make dependency lines are now simple foo.o: bar.h lines. While
6678 this makes for a longer list, it is easier to maintain and will
6679 make future Makefile patches smaller. Added special options for
6680 gcc version 1 & 2, and for cc on RS6000 systems.
6682 Calc compiles cleanly under the watchful eye of gcc version 2.4.5
6683 with the exception of warnings about 'aggregate has a partly
6684 bracketed initializer'. (gcc v2 should allow you to disable
6685 this type of warning with using -Wall)
6687 Fixed a longjmp bug that clobbered a local variable in main().
6689 Fixed a number of cases where local variables or malloced storage was
6690 being used before being set.
6692 Fixed a number of fence post errors resulting in reads or writes
6693 just outside of malloced storage.
6695 A certain parallel processor optimizer would give up on
6696 code in cases where math_error() was called. The obscure
6697 work-a-rounds involved initializing or making static, certain
6700 The cryrand.cal library has been improved. Due to the way
6701 the initial quadratic residues are selected, the random numbers
6702 produced differ from previous versions.
6704 The printing of a leading '~' on rounded values is now a config
6705 option. By default, tilde is still printed. See help/config for
6708 The builtin function base() may be used to set the output mode or
6709 base. Calling base(16) is a convenient shorthand for typing
6710 config("mode","hex"). See help/builtin.
6712 The printing of a leading tab is now a config option. This does not
6713 alter the format of functions such as print or printf. By default,
6714 a tab is printed. See help/config for details.
6716 The value atan2(0,0) now returns 0 value in conformance with
6717 the 4.3BSD ANSI/IEEE 754-1985 math library.
6719 For all values of x, x^0 yields 1. The major change here is
6720 that 0^0 yields 1 instead of an error.
6722 Fixed gcd() bug that caused gcd(2,3,1/2) to ignore the 1/2 arg.
6724 Fixed ltol() rounding so that exact results are returned, similar
6725 to the way sqrt() and hypot() round, when they exist.
6727 Fixed a bug involving ilog2().
6729 Fixed quomod(a,b,c,d) to give correct value for d when a is between
6732 Fixed hmean() to perform the necessary multiplication by the number of
6735 The file help/full is now being built.
6737 The man page is not installed by default. One may install either
6738 the man page source or the cat (formatted man) page. See the
6739 Makefile for details.
6741 Added a quit binding. The file lib/bindings2 shows how this new
6742 binding may be used.
6744 One can now do a 'make check' to run the calc regression test
6745 within in the source tree.
6747 The regression test code is now more extensive.
6749 Updated the help/todo list. A BUGS file was added. Volunteers are
6750 welcome to send in patches!
6753 The following are the changes from calc version 2.9.1 to 2.9.1:
6755 Fixed floor() for values -1 < x < 0.
6757 Fixed ceil() for values -1 < x < 0.
6759 Fixed frac() for values < 0 so that int(x) + frac(x) == x.
6761 Fixed wild fetch bug in zdiv, zquo and zmod code.
6763 Fixed bug which caused regression test #719 to fail on some machines.
6765 Added more regression test code.
6768 The following are the changes from calc version 2.9.0 to 2.9.0:
6770 A major bug was fixed in subtracting two numbers when the first
6771 number was zero. The problem caused wrong answers and core dumps.
6774 The following are the changes from calc version 1.27.0 to 2.8.0:
6776 Full prototypes have been provided for all C functions, and are used
6777 if calc is compiled with an ANSI compiler.
6779 Newly defined variables are now initialized to the value of zero instead
6780 of to the null value. The elements of new objects are also initialized
6781 to the value of zero instead of null.
6783 The gcd, lcm, and ismult functions now work for fractional values.
6785 A major bug in the // division for fractions with a negative divisor
6788 A major bug in the calculation of ln for small values was fixed.
6790 A major bug in the calculation of the ln and power functions for complex
6793 A major lack of precision for sin and tan for small values was fixed.
6795 A major lack of precision for complex square roots was fixed.
6797 The "static" keyword has been implemented for variables. So permanent
6798 variables can be defined to have either file scope or function scope.
6800 Initialization of variables during their declaration are now allowed.
6801 This is most convenient for the initialization of static variables.
6803 The matrix definition statement can now be used within a declaration
6804 statement, to immediately define a variable as a matrix.
6806 Initializations of the elements of matrices are now allowed. One-
6807 dimensional matrices may have implicit bounds when initialization is
6810 The obj definition statement can now be used within a declaration
6811 statement, to immediately define a variable as an object.
6813 Object definitions can be repeated as long as they are exactly the same
6814 as the previous definition. This allows the rereading of files which
6815 happen to define objects.
6817 The integer, rational, and complex routines have been made into a
6818 'libcalc.a' library so that they can be used in other programs besides
6819 the calculator. The "math.h" include file has been split into three
6820 include files: "zmath.h", "qmath.h", and "cmath.h".
6822 Following is a list of visible changes to calc from version 1.26.4 to 1.26.4:
6824 Added an assoc function to return a new type of value called an
6825 association. Such values are indexed by one or more arbitrary values.
6826 They are stored in a hash table for quick access.
6828 Added a hash() function which accepts one or more values and returns
6829 a quickly calculated small non-negative hash value for those values.
6831 Following is a list of visible changes to calc from version 1.26.2 to 1.26.4:
6833 Misc fixes to Makefiles.
6837 Misc portability fixes.
6839 Misc typo and working fixes to comments, help files and the man page.
6841 Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
6843 There is a new emacs-like command line editing and edit history
6844 feature. The old history mechanism has been removed. The key
6845 bindings for the new editing commands are slightly configurable
6846 since they are read in from an initialization file. This file is
6847 usually called /usr/lib/calc/bindings, but can be changed by the
6848 CALCBINDINGS environment variable. All editing code is
6849 self-contained in the new files hist.c and hist.h, which can be
6850 easily extracted and used in other programs.
6852 Two new library files have been added: chrem.cal and cryrand.cal.
6853 The first of these solves the Chinese remainder problem for a set
6854 of modulo's and remainders. The second of these implements several
6855 very good random number generators for large numbers.
6857 A small bug which allowed division by zero was fixed.
6859 A major bug in the mattrans function was fixed.
6861 A major bug in the acos function for negative arguments was fixed.
6863 A major bug in the strprintf function when objects were being printed
6866 A small bug in the library file regress.cal was fixed.
6868 ## Copyright (C) 2001 Landon Curt Noll
6870 ## Calc is open software; you can redistribute it and/or modify it under
6871 ## the terms of the version 2.1 of the GNU Lesser General Public License
6872 ## as published by the Free Software Foundation.
6874 ## Calc is distributed in the hope that it will be useful, but WITHOUT
6875 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
6876 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
6877 ## Public License for more details.
6879 ## A copy of version 2.1 of the GNU Lesser General Public License is
6880 ## distributed with calc under the filename COPYING-LGPL. You should have
6881 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
6882 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6884 ## @(#) $Revision: 30.32 $
6885 ## @(#) $Id: CHANGES,v 30.32 2013/08/11 09:10:11 chongo Exp $
6886 ## @(#) $Source: /usr/local/src/bin/calc/RCS/CHANGES,v $
6888 ## Under source code control: 1993/06/02 18:12:57
6889 ## File existed as early as: 1989
6891 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
6892 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/