Compare commits

...

54 Commits

Author SHA1 Message Date
Landon Curt Noll
1d37930d22 Release v2.15.0.4
The following are the changes in this release:

    Fixed bug that caused calc to fail to compile filepos2z() in file.c
    on little endian machines for the Debian apcalc package.  Thanks to
    Martin Buck (m at rtin-buck dor de) for for fix.

    Removed unused macros from zmath.h:

	SWAP_B32_IN_HASH(dest, src)
	SWAP_B16_IN_HASH(dest, src)
	SWAP_B8_IN_HASH(dest, src)
	SWAP_B32_IN_FLAG(dest, src)
	SWAP_B16_IN_FLAG(dest, src)
	SWAP_B8_IN_FLAG(dest, src)

    When SWAP_HALF_IN_B32(dest, src), SWAP_B32_IN_FULL(dest, src),
    SWAP_B16_IN_HALF(dest, src), SWAP_B32_IN_bool(dest, src),
    or SWAP_B32_IN_LEN(dest, src), SWAP_HALF_IN_FILEPOS(dest, src)
    is an assignment such as:

	(*(dest) = *(src))

    We now case the dest and src pointers to the proper type before
    referencing and performing the assignment.

    Documented unexpected behavior when calc is running in
    "shell script mode" and the prompt builtin function is used
    without the -p flag.  Updated help/prompt, help/unexpected
    and the calc man page accordingly.

    Unless calc is given the -p command line option, calc will reopen
    stdin as /dev/null instead of just closing stdin.  This prevents
    subsequent opens grabbing the 1st file descriptor.

    Disable regress tests 4709, 4710, and 7763 because they print
    multi-byte sequences, which are just fine for calc, the awk
    used to evaluate the regression suite output in some legacy
    systems report a "multibyte conversion failure".

    Added a number of missing Makefile variables to the "make env" rule.

    The man command is used to format the calc.1 man page into calc.usage.

    The "help calc" command now prints the formatted calc man page (calc.usage).
    The "help man" command now prints the formatted calc man page (calc.usage).
    The "help usage" command now prints the formatted calc man page (calc.usage).

    The file, calc.cat1, is formed by gzipping the calc.usage
    formatted man page.  The calc.cat1 is installed as the calc
    cat section 1 man page.

    Updated the Copyright string in version.c to refer to
    the COPYING file and the "help copying" command.

    Added calc.cat1 to .gitignore.  Using "sort -d -u" to sort .gitignore content.

    Avoiding use of modern [[ and ]] in Makefile for those legacy systems
    whose shell do not support them.  Be sure to use ||'s between []'s
    to avoid problems with legacy shell such as the Bourne shell. *sigh*

    Fixed the order of "help full" to match the order of topics listed
    buy the "help help" command.

    Sorted the halias[] help topics table in help.c using sort -d -u.
2023-12-21 05:52:06 -08:00
Landon Curt Noll
60698d2130 fix Makefile for legacy shell
The top level Makefile needs to use multiple []'s between  ||'s
to not cause problems for legacy shells such as the Bourne shell.

For example:

```make
	-${Q} if [ -z "${MANDIR}" ] || [ ! -s calc.1 ]; then \
...
	-${Q} if [ -z "${CATDIR}" ] || [ ! -s calc.cat1 ]; then \
```
2023-12-21 05:44:19 -08:00
Landon Curt Noll
3e7ccfd31c Release v2.15.0.3
The following are the changes in this release:

    Fixed bug that caused calc to fail to compile filepos2z() in file.c
    on little endian machines for the Debian apcalc package.  Thanks to
    Martin Buck (m at rtin-buck dor de) for for fix.

    Removed unused macros from zmath.h:

	SWAP_B32_IN_HASH(dest, src)
	SWAP_B16_IN_HASH(dest, src)
	SWAP_B8_IN_HASH(dest, src)
	SWAP_B32_IN_FLAG(dest, src)
	SWAP_B16_IN_FLAG(dest, src)
	SWAP_B8_IN_FLAG(dest, src)

    When SWAP_HALF_IN_B32(dest, src), SWAP_B32_IN_FULL(dest, src),
    SWAP_B16_IN_HALF(dest, src), SWAP_B32_IN_bool(dest, src),
    or SWAP_B32_IN_LEN(dest, src), SWAP_HALF_IN_FILEPOS(dest, src)
    is an assignment such as:

	(*(dest) = *(src))

    We now case the dest and src pointers to the proper type before
    referencing and performing the assignment.

    Documented unexpected behavior when calc is running in
    "shell script mode" and the prompt builtin function is used
    without the -p flag.  Updated help/prompt, help/unexpected
    and the calc man page accordingly.

    Unless calc is given the -p command line option, calc will reopen
    stdin as /dev/null instead of just closing stdin.  This prevents
    subsequent opens grabbing the 1st file descriptor.

    Disable regress tests 4709, 4710, and 7763 because they print
    multi-byte sequences, which are just fine for calc, the awk
    used to evaluate the regression suite output in some legacy
    systems report a "multibyte conversion failure".

    Added a number of missing Makefile variables to the "make env" rule.

    The man command is used to format the calc.1 man page into calc.usage.

    The "help calc" command now prints the formatted calc man page (calc.usage).
    The "help man" command now prints the formatted calc man page (calc.usage).
    The "help usage" command now prints the formatted calc man page (calc.usage).

    The file, calc.cat1, is formed by gzipping the calc.usage
    formatted man page.  The calc.cat1 is installed as the calc
    cat section 1 man page.

    Updated the Copyright string in version.c to refer to
    the COPYING file and the "help copying" command.

    Added calc.cat1 to .gitignore.  Using "sort -d -u" to sort .gitignore content.

    Avoiding use of modern [[ and ]] in Makefile for those legacy systems
    whose shell do not support them.  *sigh*

    Fixed the order of "help full" to match the order of topics listed
    buy the "help help" command.

    Sorted the halias[] help topics table in help.c using sort -d -u.
2023-12-21 05:33:43 -08:00
Landon Curt Noll
488d81b809 prep CHANGES for the next release of calc 2023-12-21 05:29:01 -08:00
Landon Curt Noll
932d27053e update help/prompt copyright date
Put back 2006 date between 1999 and 2023.
2023-12-19 03:15:20 -08:00
Landon Curt Noll
8e8d6c852a fix distlist inventory and fix make clobber 2023-12-19 01:00:25 -08:00
Landon Curt Noll
54dd89dcf7 document prompt in shell script mode, fix man formatting, legacy awk
Documented unexpected behavior when calc is running in
"shell script mode" and the prompt builtin function is used
without the -p flag.  Updated help/prompt, help/unexpected
and the calc man page accordingly.

Unless calc is given the -p command line option, calc will reopen
stdin as /dev/null instead of just closing stdin.  This prevents
subsequent opens grabbing the 1st file descriptor.

Disable regress tests 4709, 4710, and 7763 because they print
multi-byte sequences, which are just fine for calc, the awk
used to evaluate the regression suite output in some legacy
systems report a "multibyte conversion failure".

Added a number of missing Makefile variables to the "make env" rule.

The man command is used to format the calc.1 man page into calc.usage.

The "help calc" command now prints the formatted calc man page (calc.usage).
The "help man" command now prints the formatted calc man page (calc.usage).
The "help usage" command now prints the formatted calc man page (calc.usage).

The file, calc.cat1, is formed by gzipping the calc.usage
formatted man page.  The calc.cat1 is installed as the calc
cat section 1 man page.

Updated the Copyright string in version.c to refer to
the COPYING file and the "help copying" command.

Added calc.cat1 to .gitignore.  Using "sort -d -u" to sort .gitignore content.

Avoiding use of modern [[ and ]] in Makefile for those legacy systems
whose shell do not support them.  *sigh*

Fixed the order of "help full" to match the order of topics listed
buy the "help help" command.

Sorted the halias[] help topics table in help.c using sort -d -u.
2023-12-19 00:40:10 -08:00
Landon Curt Noll
d91e966f19 improve how calc compiles on big endian machines
Fixed bug that caused calc to fail to compile filepos2z() in file.c
on little endian machines for the Debian apcalc package.  Thanks to
Martin Buck (m at rtin-buck dor de) for for fix.

Removed unused macros from zmath.h:

    SWAP_B32_IN_HASH(dest, src)
    SWAP_B16_IN_HASH(dest, src)
    SWAP_B8_IN_HASH(dest, src)
    SWAP_B32_IN_FLAG(dest, src)
    SWAP_B16_IN_FLAG(dest, src)
    SWAP_B8_IN_FLAG(dest, src)

When SWAP_HALF_IN_B32(dest, src), SWAP_B32_IN_FULL(dest, src),
SWAP_B16_IN_HALF(dest, src), SWAP_B32_IN_bool(dest, src),
or SWAP_B32_IN_LEN(dest, src), SWAP_HALF_IN_FILEPOS(dest, src)
is an assignment such as:

    (*(dest) = *(src))

We now case the dest and src pointers to the proper type before
referencing and performing the assignment.
2023-12-14 23:20:35 -08:00
Landon Curt Noll
8d6f83ad91 Release v2.15.0.2
The following are the changes in this release:

    Updated BUGS about MSYS2 on Windows compiling of calc.

    Added more git related checks and sanity checks to chk_tree.

    Added ${FSANITIZE} make variable to Makefile.config to hold
    common Address Sanitizer (ASAN) optins to modern Linux and macOS.
    The Address Sanitizer is NOT enabled not compiled in by default.
    Improved comments in Makefile.local for RHEL9.2 (Linux) and for
    macOS 14.0 that, when uncommented and calc is recompiled (i.e.,
    make clobber all) will enable the Address Sanitizer (ASAN) for calc.

    Fixed memory leaks in the logn, aversin, acoversin, avercos,
    acovercos, ahaversin, ahavercos, ahacovercos, aexsec,
    aexcsc, and acrd.

    Fixed a compile error in zmath.h that impacted legacy 32-bit Big
    Endian machines.  Thanks goes to GitHub user @gromit1811 for their
    pull request.

    Fixed the check for <sys/mount.h> when forming have_sys_mount.h.
    Thanks goes to GitHub user @gromit1811 for their pull request.

    Added "STATIC bool blum_initialized = false" to zrandom.c to improve
    how the code detects if the Blum-Blum-Shub pseudo-random number
    generator is seeded or not, and how to free the state correctly.

    NOTE: There is a very minor memory leak in zrandom.c that will be
    fixed in a later release.
2023-12-08 14:03:07 -08:00
Landon Curt Noll
8dd380a9f7 prep CHANGES for the next release of calc 2023-12-08 13:56:48 -08:00
Landon Curt Noll
fbaff69c92 improve how random seed state is determined
Added "STATIC bool blum_initialized = false" to zrandom.c to improve
how the code detects if the Blum-Blum-Shub pseudo-random number
generator is seeded or not, and how to free the state correctly.

NOTE: There is a very minor memory leak in zrandom.c that will be
fixed in a later release.
2023-12-08 13:51:14 -08:00
Landon Curt Noll
c724227ef9 thank GitHub user @gromit1811 for have_sys_mount.h fix 2023-11-02 17:25:51 -07:00
Landon Curt Noll
3fd64578a6 Merge pull request #132 from gromit1811/fix_have_sys_mount
Actually check for sys/mount.h when forming have_sys_mount.h
2023-11-02 17:24:25 -07:00
Martin Buck
c9c4105ddc Actually check for sys/mount.h when forming have_sys_mount.h
So far, the Makefile checked for sys/param.h instead and that suspiciously
looks like a copy & paste error.

Found by the Debian hurd-i386 build daemon because calc failed to compile
there and it seems to lack sys/mount.h. Not that this would be an extremely
relevant architecture these days, but nevertheless... ;-)
2023-11-02 21:43:10 +01:00
Landon Curt Noll
80b7cd34fe final tweak to the thanks in CHANGES .. promise :-)
We could collapse the last 3+ commits, but
then again why try to cover up the fun!  :-)
2023-11-01 16:17:59 -07:00
Landon Curt Noll
630947d35c improve thanks in CHANGES :-) 2023-11-01 16:15:15 -07:00
Landon Curt Noll
45f62fd7b4 fixed a typo in the previous commit :-) 2023-11-01 16:14:33 -07:00
Landon Curt Noll
8ca980b2bb Thank GitHub user @gromit1811 for zmath.h fix 2023-11-01 16:13:25 -07:00
Landon Curt Noll
2ace631d00 Merge branch 'master' of github.com:lcn2/calc 2023-11-01 16:05:56 -07:00
Landon Curt Noll
41d339c60e updated trigonometric function list in help/unexpected 2023-11-01 16:04:45 -07:00
Landon Curt Noll
cc3bb98fa0 Merge pull request #131 from gromit1811/fix-fposval-build-failure 2023-11-01 15:58:53 -07:00
Martin Buck
2b506a74e7 Fix file.c build failure on 32 bit big endian machines
On ancient 32 bit big endian machines (e.g. MIPS) file.c fails to build
when FILEPOS is a struct and not a scalar. This happens because the
SWAP_HALF_IN_FILEPOS macro essentially expands to a simple assignment in
this case but the types are incompatile (HALF and FILEPOS).

Detailed compile error (this is from an older version so line numbers might
be wrong but the error is the same):

gcc  -DCALC_SRC -DCUSTOM -Wall  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security   -O3 -g3 -Wno-error=long-long -Wno-long-long -c file.c
In file included from qmath.h:32,
                 from cmath.h:32,
                 from value.h:33,
                 from calc.h:33,
                 from file.c:39:
file.c: In function 'filepos2z':
zmath.h:85:46: error: incompatible types when assigning to type 'HALF' {aka 'long unsigned int'} from type 'FILEPOS' {aka 'struct _G_fpos_t'}
 #define SWAP_HALF_IN_B32(dest, src) (*(dest) = *(src))
                                              ^
fposval.h:15:42: note: in expansion of macro 'SWAP_HALF_IN_B32'
 #define SWAP_HALF_IN_FILEPOS(dest, src)  SWAP_HALF_IN_B32(dest, src)
                                          ^~~~~~~~~~~~~~~~
file.c:1370:2: note: in expansion of macro 'SWAP_HALF_IN_FILEPOS'
  SWAP_HALF_IN_FILEPOS(ret.v, &pos);
  ^~~~~~~~~~~~~~~~~~~~

Fix this by adding suitable casts to the definition of SWAP_HALF_IN_FILEPOS
on big endian machines. Strictly speaking, the casts only seem to be
necessary when using SWAP_HALF_IN_B32, but they can't hurt in the other
cases either.
2023-11-01 21:30:43 +01:00
Landon Curt Noll
826d2d8175 Merge pull request #129 from gromit1811/man-wrap-long-paths 2023-10-17 15:53:14 -07:00
Landon Curt Noll
af8ffb3098 Merge pull request #128 from gromit1811/master 2023-10-17 15:11:31 -07:00
Martin Buck
71dd30c4c6 Allow word-wrapping in long path names in man page 2023-10-18 00:09:37 +02:00
Martin Buck
8ca96a8c29 Fix minor man page spelling errors 2023-10-17 23:41:02 +02:00
Landon Curt Noll
0bba80c92b Merge pull request #118 from planet36/help-typos
Fix minor typos in help docs
2023-10-10 07:08:34 -07:00
Steven Ward
c1882e2ea0 Use full name of function to match help file 2023-10-09 21:29:56 -04:00
Steven Ward
79964338d1 Fix minor typos 2023-10-09 21:29:47 -04:00
Steven Ward
d809ce5cf0 Use null() instead of nul() 2023-10-09 21:24:47 -04:00
Steven Ward
daac7b35af ctime() does not remove the trailing newline 2023-10-09 21:23:53 -04:00
Steven Ward
40d6e22318 s/windowz/Windows/ 2023-10-09 21:23:36 -04:00
Landon Curt Noll
ab2038ecbc fix more memory leaks
Fixed more memory leaks in the aversin, acoversin, avercos,
acovercos, ahaversin, ahavercos, ahacovercos, aexsec,
aexcsc, and acrd.
2023-10-06 23:54:55 -07:00
Landon Curt Noll
0b57d6b605 fix memory leak in the logn builtin function 2023-10-06 23:27:42 -07:00
Landon Curt Noll
01f0605055 improve chk_tree and trailblank
The chk_tree will check for files in distlist that
would otherwise be ignored by trailblank or that
are used, by convention, as tempory / test files.

Fixed a shellcheck nit in trailblank.
2023-10-06 22:25:00 -07:00
Landon Curt Noll
0e6016f429 improve Address Sanitizer (ASAN) support and chk_tree
Updated BUGS about MSYS2 on Windows compiling of calc.

    Added more git related checks and sanity checks to chk_tree.

    Added ${FSANITIZE} make variable to Makefile.config to hold
    common Address Sanitizer (ASAN) optins to modern Linux and macOS.
    The Address Sanitizer is NOT enabled not compiled in by default.
    Improved comments in Makefile.local for RHEL9.2 (Linux) and for
    macOS 14.0 that, when uncommented and calc is recompiled (i.e.,
    make clobber all) will enable the Address Sanitizer (ASAN) for calc.
2023-10-06 21:59:06 -07:00
Landon Curt Noll
2d2e1c5894 change make prep to report on chk_tree failures
Before, make prep would show but not object to chk_tree failures.
Now, if all except chk_tree is OK, make prep will report:

    almost satifactory except for chk_tree
2023-10-06 18:39:04 -07:00
Landon Curt Noll
50ba5f9a3e improve and update FSANITIZE comments in Makefile.local 2023-10-06 18:38:06 -07:00
Landon Curt Noll
850cdbef1d fix chk_tree ahead / behind direction 2023-10-06 18:05:59 -07:00
Landon Curt Noll
21cedfcae4 improve branch check for chk_tree 2023-10-06 18:04:05 -07:00
Landon Curt Noll
4fa137a638 update BUGS about MSYS2 and Windows success 2023-10-06 18:00:06 -07:00
Landon Curt Noll
6ebe707670 fix git branch checks 2023-10-06 17:55:12 -07:00
Landon Curt Noll
885db22315 add git branch checks to chk_tree 2023-10-06 17:52:30 -07:00
Landon Curt Noll
06a9997da7 fix git diff and improve git diff detection 2023-10-06 17:38:01 -07:00
Landon Curt Noll
fae4b8e81b add git checks for staged and unstaged changes 2023-10-06 17:31:37 -07:00
Landon Curt Noll
ddf0c8f1f5 fixed some warnings for errtbl.c on Cygwin systems 2023-10-05 05:02:05 -07:00
Landon Curt Noll
d52cbcea14 avoid issues where funclist.sed forms help/funclist.c
The funclist.sed sed script, when transforming func.c
into help/funclist.c, was creating nested comments.
While those were hardless, a single change to func.c
avoids the naive funclist.sed processing and avoids
(harmless) warnings when compiling help/funclist.c
in the course of building the function list.
2023-10-05 04:59:13 -07:00
Landon Curt Noll
d14d525a6a Release v2.15.0.1
The following are the changes in this release:

    The tarball for calc version 2.15.0.0 was missing version.h.
    The version.h is now listed as part of the calc distribution.

    Added the following new trigonometric functions:

	versin(x [,eps])	versed trigonometric sine
	coversin(x [,eps])	coversed trigonometric sine
	vercos(x [,eps])	versed trigonometric cosine
	covercos(x [,eps])	coversed trigonometric cosine
	aversin(x [,eps])	inverse versed trigonometric sine
	acoversin(x [,eps])	inverse coversed trigonometric sine
	avercos(x [,eps])	inverse versed trigonometric cosine
	acovercos(x [,eps])	inverse coversed trigonometric cosine
	haversin(x [,eps])	half versed trigonometric sine
	hacoversin(x [,eps])	half coversed trigonometric sine
	havercos(x [,eps])	half versed trigonometric cosine
	hacovercos(x [,eps])	half coversed trigonometric cosine
	ahaversin(x [,eps])	inverse half versed trigonometric sine
	ahacoversin(x [,eps])	inverse half coversed trigonometric sine
	ahavercos(x [,eps])	inverse half versed trigonometric cosine
	ahacovercos(x [,eps])	inverse half coversed trigonometric cosine
	exsec(x [,eps])		exterior trigonometric secant
	aexsec(x [,eps])	inverse exterior trigonometric secant
	excsc(x [,eps])		exterior trigonometric cosecant
	aexcsc(x [,eps])	inverse exterior trigonometric cosecant
	crd(x [,eps])		trigonometric chord of a unit circle
	acrd(x [,eps])		inverse trigonometric chord of a unit circle
	cas(x [,eps])		trigonometric cosine plus sine
	cis(x [,eps])		Euler's formula

    As Msys2 is a fork of Cygwin, if the OSNAME is Msys, the Cygwin
    target will be used.  Thanks to GitHub user @iahung2 for the
    pull request.

    Support for win32 and DJGPP has been dropped.  Calc version
    2.14.3.5 was the last to make references to win32 and make
    references to DJGPP.  Future versions of calc may work under
    those systems, we just elected to remove the somewhat out of
    date and awkward `win32.mkdef` and related win32 references.

    If you are a win32 user, please feel free to create a win32
    target in Makefile.target and submit as a pull request.
    If you are a DJGPP user, please feel free to create a DJGPP
    target in Makefile.target and submit as a pull request.
    Until someone can test such systems, we prefer to wait
    until someone is able to test and supply a pull request.

    Added PTR_LEN (length of a pointer) and PTR_BITS (bit length
    of a pointer) to longbits.h.

    Moved calc version definition from version.c to version.h.

    Sorted the order of symbols printed by "make env".

    Test if <stdbool.h> exists and set HAVE_STDBOOL_H accordingly
    in have_stdbool.h.  Added HAVE_STDBOOL_H to allow one to force
    this value.

    Added "bool.h" include file to support use of boolean symbols,
    true and false for pre-c99 C compilers.  The "bool.h" include
    file defines TRUE as true, FALSE as false, and BOOL as bool:
    for backward compatibility.

    Replaced in C source, TRUE with true, FALSE with false, and
    BOOL with bool.

    Fixed have_statfs optional executable file extension ${EXT{ in
    the ${UTIL_PROGS} make variable.

    Test if <stdint.h> exists and set HAVE_STDINT_H accordingly
    in have_stdint.h.  Added HAVE_STDINT_H to allow one to force
    this value.

    Test if <inttypes.h> exists and set HAVE_INTTYPES_H accordingly
    in have_inttypes.h.  Added HAVE_INTTYPES_H to allow one to force
    this value.

    Added c_chk.c to check the compiler and C include for calc
    requirements.  If you are unable to compile this program, or
    if this program when compiles does not exit 0, then your C
    compiler and/or C include fails to meet calc requirements.
    Compilers that are at least c99 MUST be able to compile this
    program such that when run will exit 0.

    The "make hsrc" file will attempt to compile and run c_chk and
    will warn if the C compiler and/or C include fails to meet
    calc requirements.  The "make debug" system will run c_chk -c
    to print information about the C compiler and C include.
    Currently failure to compile cc_chk.c or c_chk exiting non-0
    will just print "WARNING!!" strings to stderr.

    The make chk_c file also forms status.chk_c.h which either
    defines CHK_C when the C compiler and select include files
    appear to meet calc requirements, or undefines CHK_C
    when it does not.

    Added int.h as a central place for calc integer types and
    integer macros.

    Removed `-R release_file` and `-r release_file` command
    line options from `ver_calc`.  Add `-h` option.  Updated
    comments in "README.RELEASE", which serves as the contents
    of the calc command "help release".

    Added log2(x [,eps]) builtin function.  When x is an integer
    power of 2, log2(x) will return an integer, otherwise it will
    return the equivalent of ln(x)/ln(2).

    Removed CALC2_COMPAT in favor of ckecking if MAJOR_VER < 3.

    The sign element in a ZVALUE is now of type SIGN, which is either
    SB32 when MAJOR_VER < 3, or a bool otherwise.

    The len element in a ZVALUE is of type LEN.  LEN type is SB32 when
    MAJOR_VER < 3, or a uintptr_t otherwise.

    Setting an invalid epsilon via the epsilon(value) or confiv("epsilon",
    value) triggers an error.  The epsilon value must be: 0 < epsilon < 1.

    Added new logn(x, n [,eps]) builtin to compute logarithms to base n.

    Verify that eps arguments (error tolerance arguments that override
    the default epsilon value) to builtin functions have proper values.
    Previously the eps argument had little to no value checks for
    many builtin functions.

    Document in help files for builtin functions that take eps arguments,
    the LIMIT range for such eps values.

    Removed old Makefile testing rules for make dbx and make gdb.

    Improved "make run" to execute calccalc using shared libraries
    from the local directory, and with reading of the startup scripts
    disabled.

    Changed "make prep" to perform various tests that are used to
    help verify that calc is ready for a release.  Added the
    update_ver tool, (formerly verupdate) and the trailblank tool
    that existed outside of the calc source base but neverthless
    used in the calc release process.  Both of these tools are used
    by "make prep".

    Added Makefile testing rule "make testfuncsort" to check for
    the sort of the builtin function list.  Changed the order that
    builtin functions are listed by "show builtin" and the help/builtin
    to match the sorting of "LANG=C LC_ALL=C sort -d -u".

    Added c_to_q(COMPLEX *c, bool cfree) to make is easier to convert
    a COMPLEX value that is real (imag part is 0) into a NUMBER and
    optionally free the COMPLEX value.  The func.c code now uses c_to_q().

    Added q_to_c(NUMBER *q) to make it easier to convert a NUMBER
    into an allocated COMPLEX value.

    Added new vercos(x, [,eps]) for versed cosine and covercos(x, [,eps])
    for inverse versed cosine.

    Added new avercos(x, [,eps]) for inverse versed cosine and acovercos(x, [,eps])
    for inverse coversed cosine.

    Improved comments about use of the ${CALC_ENV} Makefile variable.
    Noted in Makefile.cal where and how the ${CALC_ENV} is used.
    Use ${CALC_ENV} Makefile variable were needed.

    Modified regression test cal/regress.cal: in some cases test numbers
    were adjusted.  Add comments indicate which test numbers apply to
    which code.  Indicated where there is room for new tests.
    Expanded the end of test numbers from 9999 to  99999.

    To make the meaning a bit more clear in cal/regress.cal, we have
    renamed the following test calc resource files that are related to
    the calc regression test suite:

	cal/test1700.cal -> cal/test8000.read.cal
	cal/test2300.cal -> cal/test2300.obj_incdec.cal
	cal/test2600.cal -> cal/test2600.numfunc.cal
	cal/test2700.cal -> cal/test2700.isqrt.cal
	cal/test3100.cal -> cal/test3100.matobj.cal
	cal/test3400.cal -> cal/test3400.trig.cal
	cal/test4000.cal -> cal/test4000.ptest.cal
	cal/test4100.cal -> cal/test4100.redc.cal
	cal/test4600.cal -> cal/test4600.fileop.cal
	cal/test5100.cal -> cal/test5100.newdecl.cal
	cal/test5200.cal -> cal/test5200.globstat.cal
	cal/test8400.cal -> cal/test8400.quit.cal
	cal/test8500.cal -> cal/test8500.divmod.cal
	cal/test8600.cal -> cal/test8600.maxargs.cal
	cal/set8700.cal -> cal/test8700.dotest.cal
	cal/test8900.cal -> cal/test8900.special.cal
	cal/test9300.cal -> cal/test9300.frem.cal

    Added to test 94dd, read of a number of new calc resource files
    that are not already read as a result of the calc regression test suite.

    Fixed more documentation and code comments that referred to the
    old additive 55 (a55) shuffle pseudo-random number generator.
    We have been using the subtractive 100 shuffle pseudo-random
    number generator in place of the additive 55 generator for a
    while now.

    Improved help files trigonometric functions.  They were corrected
    to indicate that complex arguments are allowed: an oversight
    from long ago when those trigonometric functions were expanded
    to include complex arguments.  The EXAMPLE sections were expanded
    and made consistent, where applicable, across the trigonometric
    help files.  Documented libcalc functions in the SEE ALSO sections.

    Improved "SEE ALSO" for the hyperbolic function help files.

    Expanded the calc regression test suite test 34dd to test various
    real and complex values for trigonometric functions.

    Added complex multiple approximation function to commath.c so
    that users of libcalc may directly round complex number to
    nearest multiple of a given real number:

	E_FUNC COMPLEX *cmappr(COMPLEX *c, NUMBER *e, long rnd, bool cfree);

    For example:

	COMPLEX *c;             /* complex number to round to nearest epsilon */
	NUMBER *eps;            /* epsilon rounding precision */
	COMPLEX *res;           /* c rounded to nearest epsilon */
	long rnd = 24L;         /* a common rounding mode */
	bool ok_to_free;        /* true ==> free c, false ==> do not free c */

	...

	res = cmappr(c, eps, ok_to_free);

    The complex trigonometric functions tan, cot, sec, csc were
    implemented in func.c as calls to complex sin and complex cos.
    We added the following direct calls to comfunc.c so that users
    of libcalc may call them directly:

	E_FUNC COMPLEX *c_tan(COMPLEX *c, NUMBER *eps);
	E_FUNC COMPLEX *c_cot(COMPLEX *c, NUMBER *eps);
	E_FUNC COMPLEX *c_sec(COMPLEX *c, NUMBER *eps);
	E_FUNC COMPLEX *c_cot(COMPLEX *c, NUMBER *eps);

    Added help/errorcodes rule to the top level Makefile.

    Added E_USERMAX symbol (== 32767) to indicate the maximum value
    allowed for user error codes.

    Improved help/error.  Added text about error code ranges and
    range symbols.

    Changed calc_errno a global int variable so that is may be directly
    accessed by libcalc users.

    Further improve help files for help/errno, help/error, help/newerror,
    help/stoponerror and help/strerror by adding to documentation
    of the calc error code system as well as libcalc interface
    where applicable.

    Changed #define E_USERDEF to #define E__USERDEF.

    Removed use of E_USERDEF, E__BASE, E__COUNT, and E__HIGHEST
    from custom/c_sysinfo because the c_sysinfo is just a demo
    and this will simplify the custom/Makefile.

    The include file calcerr.h is now the errsym.h include file.
    The calcerr.tbl has been replaced by errtbl.c and errtbl.h.

    The calcerr_c.awk, calcerr_c.sed, calcerr_h.awk, and
    calcerr_h.sed files are now obsolete and have been removed.
    The calcerr.c and calcerr.h now obsolete and are no longer built.

    The calc computation error codes, symbols and messages are now in
    a error_table[] array of struct errtbl.

    An E_STRING is a string corresponds to an error code #define.
    For example, the E_STRING for the calc error E_STRCAT,
    is the string "E_STRING".  An E_STRING must now match
    the regular expression: "^E_[A-Z0-9_]+$".

    The old array error_table[] of error message strings has been
    replaced by a new error_table[] array of struct errtbl.  The struct
    errtbl array holds calc errnum error codes, the related E_STRING
    symbol as a string, and the original related error message.
    To add new computation error codes, add them near the bottom of the
    error_table[] array, just before the NULL entry.

    The ./errcode utility, when run, will verify the consistency of
    the error_table[] array.

    The Makefile uses ./errcode -e to generate the contents of
    help/errorcodes file.  The help errorcodes now prints
    information from the new cstruct errtbl error_table[] array.

    The help/errorcodes.hdr and help/errorcodes.sed files are
    now obsolete and have been removed.

    The Makefile uses ./errcode -d to generate the contents of the
    errsym.h include file.

    Code that used the old array error_table[] of error message strings
    such as:

	#include "calcerr.h"

	char *msg;	/* calc computation error message */

	msg = error_table[errnum - E__BASE];

    where errnum is the calc computation error code
    E__BASE <= errnum <= E__HIGHEST, may now use:

	#include "errtbl.h"
	#include "errsym.h"

	char *msg;	/* calc computation error message */

	msg = error_table[errnum - E__BASE].errmsg;

    Rename the #define E__COUNT to ECOUNT to avoid confusion
    with "E_STRING" error symbols.

    Renamed "E_1OVER0" to "E_DIVBYZERO".
    Renamed "E_0OVER0" to "E_ZERODIVZERO".

    The verify_error_table() function that does a verification
    the error_table[] array and setup private_error_alias[] array
    is now called by libcalc_call_me_first().

    Fix comment about wrong include file in have_sys_mount.h.

    Removed unused booltostr() and strtobool() macros from bool.h.

    Moved define of math_error(char *, ...) from zmath.h to errtbl.h.
    The errtbl.h include file, unless ERRCODE_SRC is defined
    also includes attribute.h and errsym.h.

    Added E_STRING to error([errnum | "E_STRING"]) builtin function.
    Added E_STRING to errno([errnum | "E_STRING"]) builtin function.
    Added E_STRING to strerror([errnum | "E_STRING"]) builtin function.
    Calling these functions with an E_STRING errsym is the same as calling
    them with the matching errnum code.

    Standardized on calc computation error related E_STRING strings
    where there are a set of related codes.  Changed "E_...digits" into
    "E_..._digits".  For example, E_FPUTC1 became E_FPUTC_1, E_FPUTC2
    became E_FPUTC_2, and E_FPUTC3 became E_FPUTC_3.  In a few cases
    such as E_APPR became E_APPR_1, because there was a E_APPR2 (which
    became E_APPR_2) and E_APPR3 (which became E_APPR_3).  To other
    special cases, E_ILOG10 became E_IBASE10_LOG and E_ILOG2 became
    E_IBASE2_LOG because E_ILOG10 and E_ILOG2 are both independent calc
    computation error related E_STRING strings.  Now related sets of
    E_STRING strings end in _ (underscore) followed by digits.

    Added errsym builtin function.  The errsym(errnum | "E_STRING")
    builtin, , when given a valid integer errnum that corresponds to a
    calc error condition, will return an E_STRING string, AND when given
    a valid E_STRING string that is associated with a calc error
    condition, will return errnum integer that corresponds to a calc
    error condition.

    Supplying a non-integer numeric errnum code to error(), errno(),
    strerror(), or errsym() will result in an error.

    Added tests to the calc regression test suite (cal/regress.cal) to
    verify that the errnum calc computation error codes and their
    E_STRING values have not changed.

    Improved the clarity of calc regression suite (regress.cal) to mostly
    use E_STRING errsym instead of numeric errnum values for error()
    and errno() related tests.

    Fixed SEE ALSO typo in help randperm.

    Fixed calc regression test 42dd to set the display value back to 20.

    Added to test 95dd and test9500.trigeq.cal to the calc regression test
    suite to perform extensive test of trigonometric functions.

    Added to test 34dd, some if the missing inverse trigonometric tests.

    Improved builtin function strings, as printed by help builtin,
    that use an optional accuracy (epsilon) arg by adding a comma.

The following are the changes from calc version 2.14.3.4 to 2.14.3.5:

    Under macOS, to reduce dependency chains, we remove functions
    and data that are unreachable by the entry point or exported
    symbols.  In particular, the macOS linker is used with both
    "-dead_strip" and "-dead_strip_dylibs".

    The libcalc shared library is now linked with libcustcalc.

    The config("triground") controls rounding for the following
    trigonometric and hyperbolic functions:

	sin, cos, tan, cot, sec, csc
	asin, acos, atan, acot, asec, acsc
	versin, coversin, vercos, covercos
	aversin, acoversin, avercos, acovercos
	haversin, hacoversin, havercos, hacovercos
	ahaversin, hacoversin, havercos, ahacovercos
	exsec, aexsec, excsc, aexcsc
	crd, acrd
	cas, cis
	sinh, cosh, tanh, coth, sech, csch
	asinh, acosh, atanh, acoth, asech, acsch

    In addition to taking a complex root (such as via the power
    function on a complex value), "triground" is used for:

	exp, polar

    For the above mentioned functions, the rounding mode used to
    round the result to the nearest epsilon value is controlled by,
    and defaults to:

	config("triground", 24)

    As with other config options, the call returns the previous mode,
    without a 2nd argument, returns the current mode without changing it:

	config("triground")

    When printing an error, calc used to print the errnum (error number):

	; 1/0
		Error 10001

    Calc now prints the errsym (errsym):

	; 1/0
		Error E_DIVBYZERO

    Added errsym E_LN_3 for ln(0).
    Added errsym E_LOG_5 for log(0).
    Added errsym E_LOG2_4 for log2(0).
    Added errsym E_LOGN_6 for logn(0,base).

    Added a chk_tree tool to help look for problems such as files that are
    result of building calc that are also part of the calc distribution,
    and files that are part of the calc source that are missing from the
    calc distribution, and files that are of unknown status that are either
    result of building calc nor missing from the calc distribution.

    Updated file lists in Makefile, sorting as needed.

    Updated Makefile PHONY rule to include Makefile rules that are NOT files.

    Reduced make chatter for rules that build lists.

    Added make verifydist to verify the existence of files that are part of
    the calc distribution.

    Added make verifydist to make prep.

    Added a chk_tree double check, one after make clobber, one before
    the final make chk, to make prep.  Added double pass of chk_tree to
    make full_debug (and thus to the make debug output).

    Improved notes for install locations in Makefile.config.

    Added printing of ${BUILD_ALL} to make env output.
2023-10-05 04:37:59 -07:00
Landon Curt Noll
698f73cd3e prep CHANGES for the next release of calc 2023-10-05 04:34:22 -07:00
Landon Curt Noll
e1888d9b9e note recent chk_tree changes in CHANGES 2023-10-05 04:33:30 -07:00
Landon Curt Noll
b54f68a797 Add comments to Makefile.local
Added comments to Makefile.local about how to force calc to install
under /usr/local.
2023-10-05 03:42:26 -07:00
Landon Curt Noll
77d7e665e0 Improve Makefile comments and tests
Improved notes for install locations in Makefile.config.

Added printing of ${BUILD_ALL} to make env output.

Added double pass of chk_tree to make full_debug (and thus to the make
debug output).
2023-10-05 03:27:14 -07:00
Landon Curt Noll
e96ef61718 fix missing version.h, add chk_tree tool
The tarball for calc version 2.15.0.0 was missing version.h.
The version.h is now listed as part of the calc distribution.

Added a chk_tree tool to help look for problems such as files that are
result of building calc that are also part of the calc distribution,
and files that are part of the calc source that are missing from the
calc distribution, and files that are of unknown status that are either
result of building calc nor missing from the calc distribution.

Updated file lists in Makefile, sorting as needed.

Updated Makefile PHONY rule to include Makefile rules that are NOT files.

Reduced make chatter for rules that build lists.

Added make verifydist to verify the existence of files that are part of
the calc distribution.

Added make verifydist to make prep.

Added a chk_tree double check, one after make clobber, one before the
final make chk, to make prep.
2023-10-05 02:50:45 -07:00
Landon Curt Noll
0eee1a615d add calc version regex on update_ver 2023-10-03 23:45:38 -07:00
36 changed files with 1407 additions and 496 deletions

43
.gitignore vendored
View File

@@ -1,17 +1,17 @@
# generic excluded patterns
#
# We sort the list below via: sort -u -f
# We sort the list below via: sort -d -u
#
*,v
*.BAK
*.dSYM/
*.exe
*.o.tmp
*.[oa]
*~
.*.swp
*.BAK
.DS_Store
core*
*.dSYM/
*.exe
*.[oa]
*.o.tmp
.*.swp
*,v
# files and directories created during the building of calc and other Makefile actions
#
@@ -19,50 +19,51 @@ core*
# not consider development source. Some other file(s) and/or programs
# generate these files.
#
# We sort the list below via: sort -u -f
# We sort the list below via: sort -d -u
#
.dynamic
.hsrc
.static
Makefile.our
NOTES
align32
align32.h
align32_tmp
arc4random_tmp
args.h
cal/.all
cal/test082.cal
calc
calc-static
calc.1
calc.cat1
calc.spec
calc-static
calc.usage
cal/test082.cal
charbit.h
chatbit
chk_c
conf.h
const_tmp
cscript/.all
cscript/4dsphere
cscript/README
cscript/.all
cscript/fproduct
cscript/mersenne
cscript/piforever
cscript/plus
cscript/powerterm
cscript/README
cscript/simple
cscript/square
custom/.all
custom/libcustcalc*
debug.out
.dynamic
endian
endian_calc.h
environ_tmp
errcode
errsym.h
fpos_tmp
fposval
fposval.h
fposval_tmp
fpos_tmp
func.show
func.sort
getpgid_tmp
@@ -127,6 +128,8 @@ have_urandom.h
have_ustat
have_ustat.h
have_varvs
help/COPYING
help/COPYING-LGPL
help/.all
help/binding
help/bindings
@@ -137,8 +140,6 @@ help/change
help/changes
help/contrib
help/copy
help/COPYING
help/COPYING-LGPL
help/cscript
help/custom_cal
help/errorcode
@@ -156,15 +157,14 @@ help/releases
help/resource
help/type
help/usage
.hsrc
libcalc.*
libcustcalc.*
ll_tmp
longbits
longbits.h
Makefile.our
memmv_tmp
newstr_tmp
NOTES
offscl_tmp
outfile
posscl_tmp
@@ -174,6 +174,7 @@ sample_many-static
sample_rand
sample_rand-static
statfs_tmp
.static
status.chk_c.h
strdup_tmp
tags

4
BUGS
View File

@@ -101,7 +101,9 @@ Known bugs in calc:
The output of the alg_config.cal resource file is bogus.
We would welcome a replacement for this code.
Calc may not compile natively under Windows 11. See README.WINDOWS.
Calc may not compile natively under Windows 11, however with
MSYS2 Software Distribution (a fork of Cygwin) people compile
calc under Windiws just fine. See README.WINDOWS.
We are sure some more bugs exist. When you find them, please let
us know! See the above for details on how to report and were to

130
CHANGES
View File

@@ -1,4 +1,105 @@
The following are the changes from calc version 2.14.3.5 to 2.15.0.0:
The following are the changes from calc version 2.15.0.3 to 2.15.0.4:
Fixed bug that caused calc to fail to compile filepos2z() in file.c
on little endian machines for the Debian apcalc package. Thanks to
Martin Buck (m at rtin-buck dor de) for for fix.
Removed unused macros from zmath.h:
SWAP_B32_IN_HASH(dest, src)
SWAP_B16_IN_HASH(dest, src)
SWAP_B8_IN_HASH(dest, src)
SWAP_B32_IN_FLAG(dest, src)
SWAP_B16_IN_FLAG(dest, src)
SWAP_B8_IN_FLAG(dest, src)
When SWAP_HALF_IN_B32(dest, src), SWAP_B32_IN_FULL(dest, src),
SWAP_B16_IN_HALF(dest, src), SWAP_B32_IN_bool(dest, src),
or SWAP_B32_IN_LEN(dest, src), SWAP_HALF_IN_FILEPOS(dest, src)
is an assignment such as:
(*(dest) = *(src))
We now case the dest and src pointers to the proper type before
referencing and performing the assignment.
Documented unexpected behavior when calc is running in
"shell script mode" and the prompt builtin function is used
without the -p flag. Updated help/prompt, help/unexpected
and the calc man page accordingly.
Unless calc is given the -p command line option, calc will reopen
stdin as /dev/null instead of just closing stdin. This prevents
subsequent opens grabbing the 1st file descriptor.
Disable regress tests 4709, 4710, and 7763 because they print
multi-byte sequences, which are just fine for calc, the awk
used to evaluate the regression suite output in some legacy
systems report a "multibyte conversion failure".
Added a number of missing Makefile variables to the "make env" rule.
The man command is used to format the calc.1 man page into calc.usage.
The "help calc" command now prints the formatted calc man page (calc.usage).
The "help man" command now prints the formatted calc man page (calc.usage).
The "help usage" command now prints the formatted calc man page (calc.usage).
The file, calc.cat1, is formed by gzipping the calc.usage
formatted man page. The calc.cat1 is installed as the calc
cat section 1 man page.
Updated the Copyright string in version.c to refer to
the COPYING file and the "help copying" command.
Added calc.cat1 to .gitignore. Using "sort -d -u" to sort .gitignore content.
Avoiding use of modern [[ and ]] in Makefile for those legacy systems
whose shell do not support them. Be sure to use ||'s between []'s
to avoid problems with legacy shell such as the Bourne shell. *sigh*
Fixed the order of "help full" to match the order of topics listed
buy the "help help" command.
Sorted the halias[] help topics table in help.c using sort -d -u.
The following are the changes from calc version 2.15.0.1 to 2.15.0.2:
Updated BUGS about MSYS2 on Windows compiling of calc.
Added more git related checks and sanity checks to chk_tree.
Added ${FSANITIZE} make variable to Makefile.config to hold
common Address Sanitizer (ASAN) optins to modern Linux and macOS.
The Address Sanitizer is NOT enabled not compiled in by default.
Improved comments in Makefile.local for RHEL9.2 (Linux) and for
macOS 14.0 that, when uncommented and calc is recompiled (i.e.,
make clobber all) will enable the Address Sanitizer (ASAN) for calc.
Fixed memory leaks in the logn, aversin, acoversin, avercos,
acovercos, ahaversin, ahavercos, ahacovercos, aexsec,
aexcsc, and acrd.
Fixed a compile error in zmath.h that impacted legacy 32-bit Big
Endian machines. Thanks goes to GitHub user @gromit1811 for their
pull request.
Fixed the check for <sys/mount.h> when forming have_sys_mount.h.
Thanks goes to GitHub user @gromit1811 for their pull request.
Added "STATIC bool blum_initialized = false" to zrandom.c to improve
how the code detects if the Blum-Blum-Shub pseudo-random number
generator is seeded or not, and how to free the state correctly.
NOTE: There is a very minor memory leak in zrandom.c that will be
fixed in a later release.
The following are the changes from calc version 2.14.3.5 to 2.15.0.1:
The tarball for calc version 2.15.0.0 was missing version.h.
The version.h is now listed as part of the calc distribution.
Added the following new trigonometric functions:
@@ -434,6 +535,31 @@ The following are the changes from calc version 2.14.3.4 to 2.14.3.5:
Added errsym E_LOG2_4 for log2(0).
Added errsym E_LOGN_6 for logn(0,base).
Added a chk_tree tool to help look for problems such as files that are
result of building calc that are also part of the calc distribution,
and files that are part of the calc source that are missing from the
calc distribution, and files that are of unknown status that are either
result of building calc nor missing from the calc distribution.
Updated file lists in Makefile, sorting as needed.
Updated Makefile PHONY rule to include Makefile rules that are NOT files.
Reduced make chatter for rules that build lists.
Added make verifydist to verify the existence of files that are part of
the calc distribution.
Added make verifydist to make prep.
Added a chk_tree double check, one after make clobber, one before
the final make chk, to make prep. Added double pass of chk_tree to
make full_debug (and thus to the make debug output).
Improved notes for install locations in Makefile.config.
Added printing of ${BUILD_ALL} to make env output.
The following are the changes from calc version 2.14.3.0 to 2.14.3.4:
@@ -4200,7 +4326,7 @@ The following are the changes from calc version 2.11.5t0 to 2.11.5t1.1:
Fixed calc path in help/script.
Added read-only parameter, config("windows") to indicate if the system
is MS windowz WIN32 like system.
is MS Windows WIN32 like system.
Configuration values that used to return "true" or "false" now return
1 (a true value) or 0 (a false value). Thus one can do:

358
Makefile

File diff suppressed because it is too large Load Diff

View File

@@ -852,12 +852,21 @@ endif # ($(target),Darwin)
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
# CALC_INCDIR= /usr/include/calc
#
# Or if you prefer everything under /usr/local:
#
# BINDIR= /usr/local/bin
# LIBDIR= /usr/local/lib
# CALC_SHAREDIR= /usr/local/share/calc
# CALC_INCDIR= /usr/local/include/calc
#
# However, if you are on macOS then set:
#
# BINDIR= ${PREFIX}/bin
# LIBDIR= ${PREFIX}/lib
# CALC_SHAREDIR= ${PREFIX}/share/calc
# CALC_INCDIR= ${PREFIX}/include/calc
#
# NOTE: Starting with macOS El Capitan OS X 10.11, root by default
# could not mkdir under system locations, so macOS must now
@@ -988,9 +997,6 @@ endif # ($(target),Darwin)
#
# Use CATDIR= to disable installation of the calc cat (formatted) page.
#
# NOTE: If CATDIR is non-empty, then one should have either the
# ${NROFF} executable and/or the ${MANMAKE} executable.
#
CATDIR=
#CATDIR= ${PREFIX}/man/cat1
#CATDIR= ${PREFIX}/catman/cat1
@@ -1017,36 +1023,6 @@ CATEXT= 1
#CATEXT= 0
#CATEXT= l
# how to format a man page
#
# If CATDIR is non-empty, then
#
# If NROFF is non-empty, then
#
# ${NROFF} ${NROFF_ARG} calc.1 > ${CATDIR}/calc.${CATEXT}
# is used to build and install the cat page
#
# else (NROFF is empty)
#
# ${MANMAKE} calc.1 ${CATDIR}
# is used to build and install the cat page
# else
#
# The cat page is not built or installed
#
# If in doubt and you don't want to fool with man pages, set MANDIR
# and CATDIR to empty and ignore the NROFF, NROFF_ARG and MANMAKE
# lines below.
#
#NROFF= nroff
NROFF=
#NROFF= groff
NROFF_ARG= -man
#NROFF_ARG= -mandoc
MANMAKE= ${PREFIX}/bin/manmake
#MANMAKE= manmake
MANMODE= 0444
CATMODE= 0444
# By default, custom builtin functions may only be executed if calc
# is given the -C option. This is because custom builtin functions
@@ -1267,7 +1243,7 @@ EXT=
# The calc version in the form of x.y.z.w
#
VERSION= 2.15.0.0
VERSION= 2.15.0.4
# The calc major version in the form of x.y.z
#
@@ -1287,13 +1263,13 @@ CAT= cat
CHMOD= chmod
CMP= cmp
CO= co
COL= col
CP= cp
CTAGS= ctags
DATE= date
DIFF= diff
FMT= fmt
GREP= grep
GZIP= gzip
HOSTNAME= hostname
LANG= C
LDCONFIG= ldconfig
@@ -1301,6 +1277,7 @@ LN= ln
LS= ls
MAKE= make
MAKEDEPEND= makedepend
MAN= man
MKDIR= mkdir
MV= mv
PWDCMD= pwd
@@ -1312,8 +1289,8 @@ SORT= sort
SPLINT= splint
SPLINT_OPTS=
STRIP= strip
TEE= tee
TAIL= tail
TEE= tee
TOUCH= touch
TRUE= true
UNAME= uname
@@ -1373,3 +1350,34 @@ endif # ($(ALLOW_CUSTOM),-DCUSTOM)
# intermediate and final calc and calc related programs
#
COMMON_LDFLAGS= ${EXTRA_LDFLAGS}
# Common Address Sanitizer (ASAN)
#
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
# See also: https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early
#
# The following Address Sanitizer (ASAN) are common to both REHL9.2 (Linux) and macOS 14.0.
#
# By default, the Address Sanitizer is NOT enabled, not compiled into calc.
# To enable the Address Sanitizer, uncomment the appropriate lines in Makefile.local !!!
#
FSANITIZE:= -Wno-invalid-command-line-argument
FSANITIZE+= -fsanitize=address
FSANITIZE+= -fsanitize=alignment
FSANITIZE+= -fsanitize=bool
FSANITIZE+= -fsanitize=enum
FSANITIZE+= -fsanitize=vptr
FSANITIZE+= -fsanitize=integer-divide-by-zero
FSANITIZE+= -fsanitize=float-divide-by-zero
FSANITIZE+= -fsanitize=float-cast-overflow
FSANITIZE+= -fsanitize=nonnull-attribute
FSANITIZE+= -fsanitize=returns-nonnull-attribute
FSANITIZE+= -fsanitize=null
FSANITIZE+= -fsanitize=object-size
FSANITIZE+= -fsanitize=shift
FSANITIZE+= -fsanitize=signed-integer-overflow
FSANITIZE+= -fsanitize=undefined
FSANITIZE+= -fsanitize=unreachable
FSANITIZE+= -fsanitize=vla-bound
FSANITIZE+= -fno-omit-frame-pointer
FSANITIZE+= -fno-common

View File

@@ -50,64 +50,51 @@
###################################################################
####
# RHEL Diagnosing memory, thread, and crash issues:
# Force calc to install under /usr/local
#
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
#
# This comment block was tested under:
#
# RHEL9 gcc version 11.3.1 20221121 (Red Hat 11.3.1-4) (GCC)
#
# with:
#
# libasan-11.3.1-4.3.el9.x86_64 libubsan-11.3.1-4.3.el9.x86_64
#
# NOTE: With the above version, these are NOT supported:
#
# UNSUPPORTED_FSANITIZE:= -fsanitize=nullability-arg -fsanitize=nullability-assign
#
# Uncomment these lines:
#
# FSANITIZE:= -fsanitize=undefined -fsanitize=address -fsanitize=bool -fsanitize=bounds
# FSANITIZE+= -fsanitize=enum -fsanitize=vptr -fsanitize=integer-divide-by-zero
# FSANITIZE+= -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow
# FSANITIZE+= -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute
# FSANITIZE+= -fsanitize=null -fsanitize=shift -fsanitize=signed-integer-overflow
# FSANITIZE+= -fsanitize=unreachable -fsanitize=vla-bound
# CFLAGS+= -Wno-invalid-command-line-argument ${FSANITIZE} -fno-omit-frame-pointer
# LDFLAGS+= -Wno-invalid-command-line-argument ${FSANITIZE} -fno-omit-frame-pointer
# CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1
# DEBUG:= -O0 -g
# PREFIX:= /usr/local
# BINDIR:= ${PREFIX}/bin
# LIBDIR:= ${PREFIX}/lib
# CALC_SHAREDIR:= ${PREFIX}/share/calc
# CALC_INCDIR:= ${PREFIX}/include/calc
####
####
# macOS Diagnosing memory, thread, and crash issues:
#
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
# macOS Address Sanitizer (ASAN)
#
# This comment block was tested under:
#
# macOS 13.5 with clang version 14.0.3 (clang-1403.0.22.14.1)
# macOS 14.0 with Apple clang version 15.0.0 (clang-1500.0.40.1) for arm64
#
# For more info for clang to Diagnosing memory, thread, and crash issues early, see:
# See the FSANITIZE comment block in Makefile.config for common FSANITIZE values and more info.
#
# https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early
# To use the Address Sanitizer, uncomment this set set of lines and recompile (make clobber all):
#
# NOTE: With the above version, these are NOT supported:
#
# UNSUPPORTED_FSANITIZE:= -fsanitize-nullability-return
#
# Uncomment these lines:
#
# FSANITIZE:= -fsanitize=undefined -fsanitize=address -fsanitize=bool -fsanitize=bounds
# FSANITIZE+= -fsanitize=enum -fsanitize=vptr -fsanitize=integer-divide-by-zero
# FSANITIZE+= -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow
# FSANITIZE+= -fsanitize=nonnull-attribute -fsanitize=nullability-arg
# FSANITIZE+= -fsanitize=nullability-assign -fsanitize=returns-nonnull-attribute
# FSANITIZE+= -fsanitize=null -fsanitize=object-size -fsanitize=shift
# FSANITIZE+= -fsanitize=signed-integer-overflow -fsanitize=unreachable -fsanitize=vla-bound
# CFLAGS+= -Wno-invalid-command-line-argument ${FSANITIZE} -fno-omit-frame-pointer
# LDFLAGS+= -Wno-invalid-command-line-argument ${FSANITIZE} -fno-omit-frame-pointer
# CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1
# FSANITIZE+= -fsanitize=nullability-arg
# FSANITIZE+= -fsanitize=nullability-assign
# FSANITIZE+= -fsanitize=nullability-return
# CFLAGS+= ${FSANITIZE}
# LDFLAGS+= ${FSANITIZE}
# DEBUG:= -O0 -g3
####
####
# RHEL (Linux) Address Sanitizer (ASAN)
#
# This comment block was tested under:
#
# RHEL9.2 with clang version 15.0.7 (Red Hat 15.0.7-2.el9) for x86_64
#
# with these RPMs installed:
#
# libasan-11.3.1-4.3.el9.x86_64 libubsan-11.3.1-4.3.el9.x86_64
#
# See the FSANITIZE comment block in Makefile.config for common FSANITIZE values and more info.
#
# To use the Address Sanitizer, uncomment this set set of lines and recompile (make clobber all):
#
# FSANITIZE+= -fsanitize=bounds
# CFLAGS+= ${FSANITIZE}
# LDFLAGS+= ${FSANITIZE}
# DEBUG:= -O0 -g3
###

View File

@@ -159,10 +159,11 @@ DISTLIST= ${CALC_FILES} ${MAKE_FILE}
# These files are used to make (but not built) a calc .a link library
#
CALCLIBLIST=
#
# rules that are not also names of files
#
PHONY= all clobber distlist install
PHONY= all distlist buildlist distdir calcliblist calc_files_list echo_inst_files \
clean clobber install uninstall
############################################################
@@ -182,14 +183,14 @@ all: ${CALC_FILES} ${MAKE_FILE} .all
# additional Makefile targets #
###############################
.PHONY: ${PHONY}
# used by the upper level Makefile to determine of we have done all
#
.all:
${RM} -f .all
${TOUCH} .all
.PHONY: ${PHONY}
##
#
# File list generation. You can ignore this section.
@@ -210,6 +211,13 @@ distlist: ${DISTLIST}
fi; \
done
buildlist:
${Q} for i in ${BUILD_ALL} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
echo cal/$$i; \
fi; \
done | fgrep -v '.bak' | LANG=C ${SORT}
distdir:
${Q} echo cal

View File

@@ -4879,8 +4879,9 @@ define test_charset()
vrfy("\123" == char(0123), '4706: "\\123" == char(0123)');
vrfy("\123\124" == "ST", '4707: "\\123\\124" == "ST"');
vrfy("\311" == char(201), '4708: "\\311" == char(201)');
vrfy("\119" == "\t9", '4709: "\\119" == "\t9"');
vrfy("\765" == "\365", '4710: "\\765" == "\365"');
/* NOTE: We skip non-ASCII to avoid problems with old awk that cannot handle them */
/* vrfy("\119" == "\t9", '4709: "\\119" == "\t9"'); */
/* vrfy("\765" == "\365", '4710: "\\765" == "\365"'); */
vrfy("\x61" == "a", '4711: "\\x61" == "a"');
vrfy("\x73" == "s", '4712: "\\x73" == "s"');
vrfy("\xea" == char(234), '4713: "\\xea" == char(234)');
@@ -8191,7 +8192,8 @@ define test_newstring()
vrfy(A == "A\255gdef", '7761: A == "A\\255gdef"');
setbit(A, 16, 0);
print '7762: setbit(A, 16, 0);';
vrfy(A == "A\255fdef", '7763: A == "A\255fdef"');
/* NOTE: We skip non-ASCII to avoid problems with old awk that cannot handle them */
/* vrfy(A == "A\255fdef", '7763: A == "A\255fdef"'); */
q = "curds" " and " "whey";
print '7764: q = "curds" " and " "whey"';

4
calc.c
View File

@@ -543,8 +543,8 @@ main(int argc, char **argv)
cmdbuf[cmdlen++] = '\n';
cmdbuf[cmdlen] = '\0';
if (p_flag != true) {
if (fclose(stdin)) {
perror("main(): fclose(stdin) failed:");
if (freopen("/dev/null", "r", stdin) == NULL) {
perror("in main: freopen(\"/dev/null\", \"r\", stdin) failed:");
}
stdin_closed = true;
}

View File

@@ -470,6 +470,24 @@ The
flag overrides
.BR \-i .
.sp 1
When running calc as a shell script (see
.B "SHELL SCRIPT MODE"
for details), calc will close standard input (stdin)
during startup
.B UNLESS
the
.B \-p
flag is given on the command line.
When calc is running in
.BR "shell script mode" ,
shell scripts that call the
.BR prompt (str)
builtin will not work properly (the prompt builtin
will always fail) unless the
.B \-p
flag is given on the command line.
.TP
.B \-q
Disable the reading of the startup scripts.
@@ -501,7 +519,7 @@ version number and exit.
.TP
.B \-\-
The double dash indicates to calc that no more option follow.
The double dash indicates to calc that no more options follow.
Thus calc will ignore a later argument on the command line
even if it starts with a dash.
This is useful when entering negative values on the command line as in:
@@ -543,7 +561,7 @@ will not evaluate any
arguments but instead make them available
as strings to the argv() builtin function.
Sufficiently simple commands with no no characters like
Sufficiently simple commands with no characters like
parentheses, brackets, semicolons, '*', which have special
interpretations in UNIX shells may be entered, possibly with
spaces, until the terminating newline.
@@ -651,7 +669,9 @@ echo chongo was here | calc \-i 'print fgetline(files(0));'
.fi
.in -5n
.sp 1
This is because without \-p, the interactive parser, in an effort
This is because without
.BR \-p ,
the interactive parser, in an effort
to parse interactive commands, flushes data on standard input.
.PP
@@ -804,7 +824,7 @@ the rest of the file will be processed in
Note that
.B \-s
.B \-f
must at the end of the initial ``#!'' line.
must be at the end of the initial ``#!'' line.
Any other optional
.B "optional_other_flags"
must come before
@@ -932,6 +952,67 @@ whereas
.sp 1
will not.
.sp 1
By default, using calc startup in
.BR "shell script mode" ,
calc will close standard input (stdin).
Thus builtin functions such as
.BR prompt (str)
will fail (return a null value).
Calc shell scripts that call the
.BR prompt (str)
builtin will not work properly (the prompt builtin
will always fail and return a null value) unless the
.B \-p
flag is given on the command line.
.sp 1
The following shell script will always print "got null" because
stdin will be closed by calc during startup:
.sp 1
.in +5n
.nf
#!/usr/bin/calc \-q \-f
# The prompt will ALWAYS FAIL and return a null value
n = prompt("Test> ");
if (isnull(n)) {
print("got null");
} else {
print("got " + n);
}
.fi
.in -5n
.sp 1
However the following shell script (note the
.B \-p
before the
.B \-f
in the 1st line) will be interactive, prompt with "Test> " and print
the "got" result as expected:
.sp 1
.in +5n
.nf
#!/usr/bin/calc \-q \-p \-f
n = prompt("Test> ");
if (isnull(n)) {
print("got null");
} else {
print("got " + n);
}
.fi
.in -5n
.sp 1
Note in the example above, the
.B \-p
flag must be given before the final
.B \-f
command line flag.
.PP
.SH DATA TYPES
@@ -973,7 +1054,7 @@ Before a variable is assigned a value it has the value of zero.
.PP
The scope of a variable may be global, local to a file, or local to a
procedure.
Values may be grouped together in a matrix, or into a
Values may be grouped together in a matrix, or into
a list that permits stack and queue style operations.
.PP
For more information use the following

350
chk_tree Executable file
View File

@@ -0,0 +1,350 @@
#!/usr/bin/env bash
#
# chk_tree - verify that the source tree and git and Makefiles are in sync
#
# This tools is used by "make prep".
#
# Copyright (C) 2023 Landon Curt Noll
#
# Calc is open software; you can redistribute it and/or modify it under
# the terms of version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# Calc is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
# Public License for more details.
#
# A copy of version 2.1 of the GNU Lesser General Public License is
# distributed with calc under the filename COPYING-LGPL. You should have
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# Under source code control: 2023/10/04 21:04:44
# File existed as early as: 2023
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# setup
#
EXIT_CODE=0
# firewall - verify that the "make distdir" directories exist
#
make distdir >/dev/null 2>&1
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: make distdir exit code: $status" 1>&2
EXIT_CODE=10
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# collect make distdir directory list
#
# We ignore make action lines.
#
declare -a DISTDIR
mapfile -t DISTDIR < <(make -s distdir | grep -v '^make\[[0-9]*\]: ' | sort -u)
if [[ ${#DISTDIR[@]} -le 0 ]]; then
echo "$0: ERROR: distdir is empty" 1>&2
EXIT_CODE=11
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# collect directories
#
# We ignore NOTES because it contains notes that are not part of calc source.
# We ignore .git and GitHub because they are not part of the calc source tarball.
#
declare -a FINDDIR
mapfile -t FINDDIR < <(find . -type d \
! -path './NOTES/*' ! -name NOTES \
! -path './.git/*' ! -name .git \
! -path './.github/*' ! -name .github | \
sed -e 's/^\.\///' | sort -u)
if [[ ${#FINDDIR[@]} -le 0 ]]; then
echo "$0: ERROR: find dir is empty" 1>&2
EXIT_CODE=12
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# compare DISTDIR and FINDDIR
#
declare -a DIFF_DISTDIR_FINDDIR
mapfile -t DIFF_DISTDIR_FINDDIR < <(printf '%s\n' "${DISTDIR[@]}" "${FINDDIR[@]}" |
tr ' ' '\n' | sort | uniq -u)
if [[ ${#DIFF_DISTDIR_FINDDIR[@]} -ne 0 ]]; then
# report that DISTDIR and FINDDIR differ
#
echo "$0: ERROR: distdir and find dir differ for critical directories" 1>&2
declare -a ONLY_FINDDIR
mapfile -t ONLY_FINDDIR < <(printf '%s\n' "${DISTDIR[@]}" "${DISTDIR[@]}" "${FINDDIR[@]}" |
tr ' ' '\n' | sort | uniq -u)
if [[ ${#ONLY_FINDDIR[@]} -ne 0 ]]; then
echo "$0: ERROR: found only in find dir: ${ONLY_FINDDIR[*]}" 1>&2
fi
declare -a ONLY_DISTDIR
mapfile -t ONLY_DISTDIR < <(printf '%s\n' "${FINDDIR[@]}" "${FINDDIR[@]}" "${DISTDIR[@]}" |
tr ' ' '\n' | sort | uniq -u)
if [[ ${#ONLY_DISTDIR[@]} -ne 0 ]]; then
echo "$0: ERROR: found only in distdir: ${ONLY_DISTDIR[*]}" 1>&2
fi
EXIT_CODE=13
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# firewall - verify that the "make distlist" files exist
#
make distlist >/dev/null 2>&1
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: make distlist exit code: $status" 1>&2
EXIT_CODE=14
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# collect make distlist file list
#
declare -a DISTLIST
mapfile -t DISTLIST < <(make -s distlist | grep -v '^make\[[0-9]*\]: ' | sort -u)
if [[ ${#DISTLIST[@]} -le 0 ]]; then
echo "$0: ERROR: distlist is empty" 1>&2
EXIT_CODE=15
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
declare -A DISTLIST_A
for i in "${DISTLIST[@]}"; do
DISTLIST_A["$i"]="$i"
done
# case: under git control
#
if [[ -d .git ]]; then
# obtain the list of files under git
#
# We ignore .git and GitHub related files because they are not part of the calc source tarball.
#
declare -a GITLS
mapfile -t GITLS < <(git ls |
grep -v -E '^\.github/|^\.gitignore$|^CODE_OF_CONDUCT\.md$|^CONTRIBUTING\.md$|^SECURITY\.md$' |
sort -u)
if [[ ${#GITLS[@]} -le 0 ]]; then
echo "$0: ERROR: git ls is empty" 1>&2
EXIT_CODE=16
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# compare DISTLIST and GITLS
#
declare -a DIFF_DISTLIST_GITLS
mapfile -t DIFF_DISTLIST_GITLS < <(printf '%s\n' "${DISTLIST[@]}" "${GITLS[@]}" |
tr ' ' '\n' | sort | uniq -u)
if [[ ${#DIFF_DISTLIST_GITLS[@]} -ne 0 ]]; then
# report that DISTLIST and GITLS differ
#
echo "$0: ERROR: distlist and git ls differ for critical files" 1>&2
declare -a ONLY_GITLS
mapfile -t ONLY_GITLS < <(printf '%s\n' "${DISTLIST[@]}" "${DISTLIST[@]}" "${GITLS[@]}" |
tr ' ' '\n' | sort | uniq -u)
if [[ ${#ONLY_GITLS[@]} -ne 0 ]]; then
echo "$0: ERROR: found only in git ls: ${ONLY_GITLS[*]}" 1>&2
fi
declare -a ONLY_DISTLIST
mapfile -t ONLY_DISTLIST < <(printf '%s\n' "${GITLS[@]}" "${GITLS[@]}" "${DISTLIST[@]}" |
tr ' ' '\n' | sort | uniq -u)
if [[ ${#ONLY_DISTLIST[@]} -ne 0 ]]; then
echo "$0: ERROR: found only in distlist: ${ONLY_DISTLIST[*]}" 1>&2
fi
EXIT_CODE=17
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# verify that there are no staged uncommitted changes under git
#
GIT_STATUS=$(git status --untracked-files=no --porcelain 2>&1)
if [[ -n $GIT_STATUS ]] || ! git diff --cached --quiet --exit-code; then
echo "$0: ERROR: there are staged uncommitted changes" 1>&2
git status --short
EXIT_CODE=18
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# verify that there are no uncommitted changes under git
#
if ! git diff --quiet --exit-code; then
echo "$0: ERROR: there are unstaged changes" 1>&2
git status --untracked-files=no --porcelain --short
EXIT_CODE=19
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# verify that master branch is not ahead of 'origin/master'
#
GIT_MASTER=$(git rev-list --count master)
GIT_ORIGIN_MASTER=$(git rev-list --count origin/master)
if [[ $GIT_MASTER -gt $GIT_ORIGIN_MASTER ]]; then
echo "$0: ERROR: master branch is behind of origin/master" 1>&2
git status master
EXIT_CODE=20
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
elif [[ $GIT_MASTER -lt $GIT_ORIGIN_MASTER ]]; then
echo "$0: ERROR: master branch is ahead of origin/master" 1>&2
git status master
EXIT_CODE=21
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# verify that branch is not ahead of 'origin/HEAD'
#
GIT_HEAD=$(git rev-list --count HEAD)
GIT_ORIGIN_HEAD=$(git rev-list --count origin/HEAD)
if [[ $GIT_HEAD -gt $GIT_ORIGIN_HEAD ]]; then
echo "$0: ERROR: HEAD is behind of origin/HEAD" 1>&2
git status HEAD
EXIT_CODE=22
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
elif [[ $GIT_HEAD -lt $GIT_ORIGIN_HEAD ]]; then
echo "$0: ERROR: HEAD is ahead of origin/HEAD" 1>&2
git status HEAD
EXIT_CODE=23
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
fi
# collect make buildlist file list
#
declare -a BUILDLIST
mapfile -t BUILDLIST < <(make -s buildlist | grep -v '^make\[[0-9]*\]: ' | sort -u)
if [[ ${#BUILDLIST[@]} -le 0 ]]; then
echo "$0: ERROR: buildlist is empty" 1>&2
EXIT_CODE=24
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
declare -A BUILDLIST_A
for i in "${BUILDLIST[@]}"; do
BUILDLIST_A["$i"]="$i"
done
# look for something in DISTLIST that is also in BUILDLIST
#
# The BUILDLIST are a set of files that are result of building calc
# and thus should NOT be part of the DISTLIST (list of files used
# to form the calc source distribtion).
#
declare -a DISTLIST_ALSO_IN_BUILDLIST
mapfile -t DISTLIST_ALSO_IN_BUILDLIST < <(
for i in "${DISTLIST_A[@]}"; do
if [[ -n "${BUILDLIST_A[$i]}" ]]; then
echo "$i";
fi
done
)
if [[ ${#DISTLIST_ALSO_IN_BUILDLIST[@]} -ne 0 ]]; then
# report that something in DISTLIST was found in BUILDLIST
#
echo "$0: ERROR: distlist files found in buildlist" 1>&2
echo "$0: ERROR: distlist files found in buildlist: ${DISTLIST_ALSO_IN_BUILDLIST[*]}" 1>&2
EXIT_CODE=25
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# collect list of files
#
# We ignore NOTES because it contains notes that are not part of calc source.
# We ignore .git and GitHub because they are not part of the calc source tarball.
# We ignore .*.swp files as they are a result of vim sessions.
# We ignore *.out files as they are used to collect information.
# We ignore single letter files as they are used for temporary files.
# We ignore files containing the any of the following in any letter case:
#
# foo bar baz curds whey rmme
#
declare -a FINDFILE
mapfile -t FINDFILE < <(find . -type f \
! -path './NOTES/*' ! -name NOTES \
! -path './.git/*' ! -name .git \
! -path './.github/*' ! -name .github \
! -name 'CODE_OF_CONDUCT.md' ! -name 'CONTRIBUTING.md' ! -name '.gitignore' ! -name 'SECURITY.md' \
! -name '*.swp' ! -name '?' ! -iname '*.out*' \
! -iname '*foo*' ! -iname '*bar*' ! -iname '*baz*' \
! -iname '*curds*' ! -iname '*whey*' ! -iname '*rmmee' -print |
sed -e 's/^\.\///' | sort -u)
if [[ ${#FINDFILE[@]} -le 0 ]]; then
echo "$0: ERROR: find file is empty" 1>&2
EXIT_CODE=26
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# look for something in FINDFILE that in neither DISTLIST nor BUILDLIST
#
# We look for a file that is neither a file that neither a result of building calc,
# nor part of the calc distribution list in a file list.
#
# NOTE that the file list has already excluded certain files (see previous section).
#
# We flag any file in the list that is neither a result of building calc,
# nor part of the calc distribution list in a file list.
#
declare -a UNKNOWN_FILE
mapfile -t UNKNOWN_FILE < <(
for i in "${FINDFILE[@]}"; do
# skip if this is a file that is result of building calc
#
if [[ -n ${BUILDLIST_A["$i"]} ]]; then
continue
fi
# skip if this is a file that is calc distribution list
#
if [[ -n ${DISTLIST_A["$i"]} ]]; then
continue
fi
# print the file of unknown status
#
echo "$i"
done
)
if [[ ${#UNKNOWN_FILE[@]} -ne 0 ]]; then
# report that something in DISTLIST was found in BUILDLIST
#
echo "$0: ERROR: files that are neither built nor distlist are found" 1>&2
echo "$0: ERROR: distlist files found in buildlist: ${UNKNOWN_FILE[*]}" 1>&2
EXIT_CODE=27
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# Look for a find in distlist that would otherwise be ignored
#
# We ignore for trailblank and FINDFILE, filenames with a single letter, and files
# that end in .out, and files containing the any of the following
# in any letter case:
#
# foo bar baz curds whey rmme
#
# So we will object is any distlist file is one of these ignored filenames.
#
INVALID_DISTLIST=$(printf '%s\n' "${DISTLIST[@]}" | \
tr '[:upper:]' '[:lower:]' | \
sed -n -e '/^.$/p' -e '/.*foo.*/p' -e '/.*bar.*/p' -e '/.*baz.*/p' \
-e '/.*curds.*/p' -e '/.*whey.*/p' -e '/.*rmme.*/p' |
tr '\n' ' ')
if [[ -n $INVALID_DISTLIST ]]; then
echo "$0: ERROR: distlist contains invalid filename(s): $INVALID_DISTLIST" 1>&2
EXIT_CODE=28
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
fi
# All Done!!! -- Jessica Noll, Age 2
#
if [[ $EXIT_CODE -ne 0 ]]; then
echo "$0: Warning: about to exit $EXIT_CODE" 1>&2
fi
exit "$EXIT_CODE"

View File

@@ -142,6 +142,12 @@ DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README.src
#
CALCLIBLIST=
# complete list of files that may be created as part of the build process
#
# Used by chk_tree via make prep
#
BUILD_ALL= ${SCRIPT} README
# complete list of targets
#
# NOTE: This list MUST be coordinated with the ${CSCRIPT_TARGETS} variable
@@ -149,10 +155,11 @@ CALCLIBLIST=
#
CSCRIPT_TARGETS= ${SCRIPT}
TARGETS= ${CSCRIPT_TARGETS} README
#
# rules that are not also names of files
#
PHONY= all clobber distlist install
PHONY= all distlist buildlist distdir calcliblist detaillist depend \
echo_inst_files clean clobber install uninstall
############################################################
@@ -206,6 +213,13 @@ distlist: ${DISTLIST}
fi; \
done | LANG=C ${SORT}
buildlist:
${Q} for i in ${BUILD_ALL} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
echo cscript/$$i; \
fi; \
done | fgrep -v '.bak' | LANG=C ${SORT}
distdir:
${Q} echo cscript

View File

@@ -215,10 +215,23 @@ CALC_DYNAMIC_LIBCUSTCALC= libcustcalc${LIB_EXT_VERSION}
#
CALC_STATIC_LIBCUSTCALC= libcustcalc.a
# complete list of files that may be created as part of the build process
#
# Used by chk_tree via make prep
#
BUILD_ALL= ${REQUIRED_OBJ} ${CUSTOM_OBJ} \
${CALC_DYNAMIC_LIBCUSTCALC} ${CALC_STATIC_LIBCUSTCALC} \
.all
# complete list of targets
#
TARGETS= ${BLD_TYPE}
# rules that are not also names of files
#
PHONY= all distlist buildlist distdir calcliblist depend echo_inst_files clean \
clobber install uninstall
############################################################
# Allow Makefile.local to change any of the above settings #
@@ -238,6 +251,8 @@ all: ${TARGETS} ${INSTALL_H_SRC} ${CUSTOM_CALC_FILES} \
# additional Makefile targets #
###############################
.PHONY: ${PHONY}
calc-dynamic-only: ${CUSTCALC_OBJ} ${CALC_DYNAMIC_LIBCUSTCALC}
calc-static-only: ${CUSTCALC_OBJ} ${CALC_STATIC_LIBCUSTCALC}
@@ -295,6 +310,13 @@ distlist: ${DISTLIST}
fi; \
done
buildlist:
${Q} for i in ${BUILD_ALL} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
echo custom/$$i; \
fi; \
done | fgrep -v '.bak' | LANG=C ${SORT}
distdir:
${Q} echo custom

View File

@@ -855,7 +855,7 @@ is_e_digits(CONST char *errsym)
* check for only digits remaining
*/
for (p = errsym+2; *p != '\0'; ++p) {
if (!isascii(*p) || !isdigit(*p)) {
if (!isascii((int)*p) || !isdigit((int)*p)) {
return false;
}
}
@@ -1090,7 +1090,7 @@ is_e_1string(CONST char *errsym)
* must match regular expression: ^E_[A-Z][A-Z0-9_]+$
*/
for (p = errsym+3; *p != '\0'; ++p) {
if (!isascii(*p) || !(isupper(*p) || isdigit(*p) || *p == '_')) {
if (!isascii((int)*p) || !(isupper((int)*p) || isdigit((int)*p) || *p == '_')) {
return false;
}
}
@@ -2183,8 +2183,8 @@ print_errsym(void)
int
main(int argc, char *argv[])
{
extern char *optarg; /* argv index of the next arg */
extern int optind; /* argv index of the next arg */
EXTERN char *optarg; /* argv index of the next arg */
EXTERN int optind; /* argv index of the next arg */
int e_flag = 0; /* 1 ==> -e flag was used */
int d_flag = 0; /* 1 ==> -s flag was used */
int i;

2
file.c
View File

@@ -1387,7 +1387,7 @@ filepos2z(FILEPOS pos)
ret.len = FILEPOS_BITS/BASEB;
ret.v = alloc(ret.len);
zclearval(ret);
SWAP_HALF_IN_FILEPOS(ret.v, &pos);
SWAP_HALF_IN_FILEPOS(ret.v, (HALF *)&pos);
ret.sign = 0;
ztrim(&ret);

View File

@@ -114,15 +114,20 @@ main(int UNUSED(argc), char **argv)
/*
* Big Endian
*/
/*
* Use casts to (HALF *) because SWAP_HALF_IN_B* might expand to
* a simple assignment and SWAP_HALF_IN_FILEPOS might get a
* (HALF *) and a (FILEPOS *) which are not assignment-compatible.
*/
if (fileposlen == 64) {
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
"\tSWAP_HALF_IN_B64(dest, src)\n");
"\tSWAP_HALF_IN_B64((HALF *)dest, (HALF *)src)\n");
} else if (fileposlen == 32) {
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
"\tSWAP_HALF_IN_B32(dest, src)\n");
"\tSWAP_HALF_IN_B32((HALF *)dest, (HALF *)src)\n");
} else if (fileposlen%BASEB == 0) {
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
"\tswap_HALFs(dest, src, %d)\n",
"\tswap_HALFs((HALF *)dest, (HALF *)src, %d)\n",
fileposlen/BASEB);
} else {
fprintf(stderr, "%s: unexpected BIG_ENDIAN FILEPOS bit size: %d\n",
@@ -135,7 +140,7 @@ main(int UNUSED(argc), char **argv)
*/
#if defined(HAVE_FILEPOS_SCALAR)
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
"\t(*(dest) = *(src))\n");
"\t(*((HALF *)(dest)) = *((HALF *)(src)))\n");
#else /* HAVE_FILEPOS_SCALAR */
/*
* Normally a "(*(dest) = *(src))" would do, but on some

244
func.c
View File

@@ -2479,6 +2479,7 @@ f_logn(int count, VALUE **vals)
ln_of_x_is_complex = true;
}
} else {
ln_x_c = NULL; /* avoid ln_x_c may be uninitialized warning later on */
ln_x_r = qln(vals[0]->v_num, err);
if (ln_x_r == NULL) {
return error_value(E_LOGN_3);
@@ -2512,6 +2513,11 @@ f_logn(int count, VALUE **vals)
switch (vals[1]->v_type) {
case V_NUM:
if (qiszero(vals[1]->v_num)) {
if (ln_of_x_is_complex == true) {
comfree(ln_x_c);
} else {
qfree(ln_x_r);
}
return error_value(E_LOGN_4);
}
if (qisneg(vals[1]->v_num)) {
@@ -2520,10 +2526,20 @@ f_logn(int count, VALUE **vals)
ctmp.links = 1;
ln_n_c = c_ln(&ctmp, err);
if (ln_n_c == NULL) {
if (ln_of_x_is_complex == true) {
comfree(ln_x_c);
} else {
qfree(ln_x_r);
}
return error_value(E_LOGN_4);
}
if (ciszero(ln_n_c)) {
comfree(ln_n_c);
if (ln_of_x_is_complex == true) {
comfree(ln_x_c);
} else {
qfree(ln_x_r);
}
return error_value(E_LOGN_4);
}
if (cisreal(ln_n_c)) {
@@ -2534,24 +2550,49 @@ f_logn(int count, VALUE **vals)
} else {
ln_n_r = qln(vals[1]->v_num, err);
if (ln_n_r == NULL) {
if (ln_of_x_is_complex == true) {
comfree(ln_x_c);
} else {
qfree(ln_x_r);
}
return error_value(E_LOGN_4);
}
if (qiszero(ln_n_r)) {
qfree(ln_n_r);
if (ln_of_x_is_complex == true) {
comfree(ln_x_c);
} else {
qfree(ln_x_r);
}
return error_value(E_LOGN_4);
}
}
break;
case V_COM:
if (ciszero(vals[1]->v_com)) {
if (ln_of_x_is_complex == true) {
comfree(ln_x_c);
} else {
qfree(ln_x_r);
}
return error_value(E_LOGN_4);
}
ln_n_c = c_ln(vals[1]->v_com, err);
if (ln_n_c == NULL) {
if (ln_of_x_is_complex == true) {
comfree(ln_x_c);
} else {
qfree(ln_x_r);
}
return error_value(E_LOGN_4);
}
if (ciszero(ln_n_c)) {
comfree(ln_n_c);
if (ln_of_x_is_complex == true) {
comfree(ln_x_c);
} else {
qfree(ln_x_r);
}
return error_value(E_LOGN_4);
}
if (cisreal(ln_n_c)) {
@@ -2561,6 +2602,11 @@ f_logn(int count, VALUE **vals)
}
break;
default:
if (ln_of_x_is_complex == true) {
comfree(ln_x_c);
} else {
qfree(ln_x_r);
}
return error_value(E_LOGN_5);
}
@@ -2574,10 +2620,12 @@ f_logn(int count, VALUE **vals)
* case: ln(x) is COMPLEX, ln(n) is COMPLEX
*/
p_cval = c_div(ln_x_c, ln_n_c);
comfree(ln_x_c);
comfree(ln_n_c);
if (p_cval == NULL) {
return error_value(E_LOGN_3);
}
/* check if division is COMPLEX or NUMBER */
/* check for COMPLEX or NUMBER division */
if (cisreal(p_cval)) {
/* ln(x) / ln(n) was NUMBER, not COMPLEX */
result.v_num = c_to_q(p_cval, true);
@@ -2594,10 +2642,12 @@ f_logn(int count, VALUE **vals)
* case: ln(x) is COMPLEX, ln(n) is NUMBER
*/
p_cval = c_divq(ln_x_c, ln_n_r);
comfree(ln_x_c);
qfree(ln_n_r);
if (p_cval == NULL) {
return error_value(E_LOGN_3);
}
/* check if division is COMPLEX or NUMBER */
/* check for COMPLEX or NUMBER division */
if (cisreal(p_cval)) {
/* ln(x) / ln(n) was NUMBER, not COMPLEX */
result.v_num = c_to_q(p_cval, true);
@@ -2620,16 +2670,18 @@ f_logn(int count, VALUE **vals)
ctmp.imag = qlink(&_qzero_);
ctmp.links = 1;
p_cval = c_div(&ctmp, ln_n_c);
comfree(&ctmp);
comfree(ln_n_c);
if (p_cval == NULL) {
return error_value(E_LOGN_3);
}
/* check if division is COMPLEX or NUMBER */
/* check for COMPLEX or NUMBER division */
if (cisreal(p_cval)) {
/* ln(x) / ln(n) was NUMBER, not COMPLEX */
result.v_num = c_to_q(p_cval, true);
result.v_type = V_NUM;
} else {
/* ln(x) / ln(n) is COMPLEX */
/* ln(x) / ln(n) is COMPLEX result */
result.v_type = V_COM;
result.v_com = p_cval;
}
@@ -2640,10 +2692,12 @@ f_logn(int count, VALUE **vals)
* case: ln(x) is NUMBER, ln(n) is NUMBER
*/
result.v_num = qqdiv(ln_x_r, ln_n_r);
qfree(ln_x_r);
qfree(ln_n_r);
if (result.v_com == NULL) {
return error_value(E_LOGN_3);
}
/* ln(x) / ln(n) is NUMBER */
/* ln(x) / ln(n) is NUMBER result */
result.v_type = V_NUM;
}
}
@@ -10900,7 +10954,6 @@ f_versin(int count, VALUE **vals)
S_FUNC VALUE
f_aversin(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -10924,11 +10977,10 @@ f_aversin(int count, VALUE **vals)
/*
* compute inverse versed trigonometric sine to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* try to compute result using real trig function */
result.v_num = qaversin_or_NULL(arg1.v_num, eps);
result.v_num = qaversin_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -10941,17 +10993,17 @@ f_aversin(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_aversin(arg1.v_com, eps);
c = c_aversin(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_AVERSIN_3);
}
@@ -10966,7 +11018,7 @@ f_aversin(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function
@@ -11040,7 +11092,6 @@ f_coversin(int count, VALUE **vals)
S_FUNC VALUE
f_acoversin(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -11064,11 +11115,10 @@ f_acoversin(int count, VALUE **vals)
/*
* compute inverse coversed trigonometric sine to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* try to compute result using real trig function */
result.v_num = qacoversin_or_NULL(arg1.v_num, eps);
result.v_num = qacoversin_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -11081,17 +11131,17 @@ f_acoversin(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_acoversin(arg1.v_com, eps);
c = c_acoversin(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_ACOVERSIN_3);
}
@@ -11106,7 +11156,7 @@ f_acoversin(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function
@@ -11180,7 +11230,6 @@ f_vercos(int count, VALUE **vals)
S_FUNC VALUE
f_avercos(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -11204,11 +11253,10 @@ f_avercos(int count, VALUE **vals)
/*
* compute inverse versed trigonometric cosine to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* try to compute result using real trig function */
result.v_num = qavercos_or_NULL(arg1.v_num, eps);
result.v_num = qavercos_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -11221,17 +11269,17 @@ f_avercos(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_avercos(arg1.v_com, eps);
c = c_avercos(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_AVERCOS_3);
}
@@ -11246,7 +11294,7 @@ f_avercos(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function
@@ -11320,7 +11368,6 @@ f_covercos(int count, VALUE **vals)
S_FUNC VALUE
f_acovercos(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -11344,11 +11391,10 @@ f_acovercos(int count, VALUE **vals)
/*
* compute inverse coversed trigonometric cosine to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* try to compute result using real trig function */
result.v_num = qacovercos_or_NULL(arg1.v_num, eps);
result.v_num = qacovercos_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -11361,17 +11407,17 @@ f_acovercos(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_acovercos(arg1.v_com, eps);
c = c_acovercos(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_ACOVERCOS_3);
}
@@ -11386,7 +11432,7 @@ f_acovercos(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function
@@ -11460,7 +11506,6 @@ f_haversin(int count, VALUE **vals)
S_FUNC VALUE
f_ahaversin(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -11484,11 +11529,10 @@ f_ahaversin(int count, VALUE **vals)
/*
* compute inverse half versed trigonometric sine to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* try to compute result using real trig function */
result.v_num = qahaversin_or_NULL(arg1.v_num, eps);
result.v_num = qahaversin_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -11501,17 +11545,17 @@ f_ahaversin(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_ahaversin(arg1.v_com, eps);
c = c_ahaversin(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_AHAVERSIN_3);
}
@@ -11526,7 +11570,7 @@ f_ahaversin(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function
@@ -11600,7 +11644,6 @@ f_hacoversin(int count, VALUE **vals)
S_FUNC VALUE
f_ahacoversin(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -11624,11 +11667,10 @@ f_ahacoversin(int count, VALUE **vals)
/*
* compute inverse half coversed trigonometric sine to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* try to compute result using real trig function */
result.v_num = qahacoversin_or_NULL(arg1.v_num, eps);
result.v_num = qahacoversin_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -11641,17 +11683,17 @@ f_ahacoversin(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_ahacoversin(arg1.v_com, eps);
c = c_ahacoversin(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_AHACOVERSIN_3);
}
@@ -11666,7 +11708,7 @@ f_ahacoversin(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function
@@ -11740,7 +11782,6 @@ f_havercos(int count, VALUE **vals)
S_FUNC VALUE
f_ahavercos(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -11764,11 +11805,10 @@ f_ahavercos(int count, VALUE **vals)
/*
* compute inverse half versed trigonometric cosine to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* try to compute result using real trig function */
result.v_num = qahavercos_or_NULL(arg1.v_num, eps);
result.v_num = qahavercos_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -11781,17 +11821,17 @@ f_ahavercos(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_ahavercos(arg1.v_com, eps);
c = c_ahavercos(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_AHAVERCOS_3);
}
@@ -11806,7 +11846,7 @@ f_ahavercos(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function
@@ -11880,7 +11920,6 @@ f_hacovercos(int count, VALUE **vals)
S_FUNC VALUE
f_ahacovercos(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -11904,11 +11943,10 @@ f_ahacovercos(int count, VALUE **vals)
/*
* compute inverse half coversed trigonometric cosine to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* try to compute result using real trig function */
result.v_num = qahacovercos_or_NULL(arg1.v_num, eps);
result.v_num = qahacovercos_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -11921,17 +11959,17 @@ f_ahacovercos(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_ahacovercos(arg1.v_com, eps);
c = c_ahacovercos(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_AHACOVERCOS_3);
}
@@ -11946,7 +11984,7 @@ f_ahacovercos(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function
@@ -12016,7 +12054,6 @@ f_exsec(int count, VALUE **vals)
S_FUNC VALUE
f_aexsec(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -12040,16 +12077,15 @@ f_aexsec(int count, VALUE **vals)
/*
* compute inverse exterior trigonometric secant to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* firewall */
if (qisnegone(arg1.v_num)) {
if (qisnegone(vals[0]->v_num)) {
return error_value(E_AEXSEC_3);
}
/* try to compute result using real trig function */
result.v_num = qaexsec_or_NULL(arg1.v_num, eps);
result.v_num = qaexsec_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -12062,17 +12098,17 @@ f_aexsec(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_aexsec(arg1.v_com, eps);
c = c_aexsec(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_AEXSEC_3);
}
@@ -12087,7 +12123,7 @@ f_aexsec(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function
@@ -12163,7 +12199,6 @@ f_excsc(int count, VALUE **vals)
S_FUNC VALUE
f_aexcsc(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -12187,16 +12222,15 @@ f_aexcsc(int count, VALUE **vals)
/*
* compute inverse exterior trigonometric cosecant to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* firewall */
if (qisnegone(arg1.v_num)) {
if (qisnegone(vals[0]->v_num)) {
return error_value(E_AEXCSC_3);
}
/* try to compute result using real trig function */
result.v_num = qaexcsc_or_NULL(arg1.v_num, eps);
result.v_num = qaexcsc_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -12209,17 +12243,17 @@ f_aexcsc(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_aexcsc(arg1.v_com, eps);
c = c_aexcsc(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_AEXCSC_3);
}
@@ -12234,7 +12268,7 @@ f_aexcsc(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function
@@ -12304,7 +12338,6 @@ f_crd(int count, VALUE **vals)
S_FUNC VALUE
f_acrd(int count, VALUE **vals)
{
VALUE arg1; /* 1st arg if it is a COMPLEX value */
VALUE result; /* value to return */
COMPLEX *c; /* COMPLEX trig result */
NUMBER *eps; /* epsilon error tolerance */
@@ -12328,11 +12361,10 @@ f_acrd(int count, VALUE **vals)
/*
* compute inverse trigonometric chord of a unit circle to a given error tolerance
*/
arg1 = *vals[0];
if (arg1.v_type == V_NUM) {
if (vals[0]->v_type == V_NUM) {
/* try to compute result using real trig function */
result.v_num = qacrd_or_NULL(arg1.v_num, eps);
result.v_num = qacrd_or_NULL(vals[0]->v_num, eps);
/*
* case: trig function returned a NUMBER
@@ -12345,17 +12377,17 @@ f_acrd(int count, VALUE **vals)
*/
} else {
/* convert NUMBER argument from NUMBER to COMPLEX */
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
arg1.v_type = V_COM;
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
vals[0]->v_type = V_COM;
}
}
if (arg1.v_type == V_COM) {
if (vals[0]->v_type == V_COM) {
/*
* case: argument was COMPLEX or
* trig function returned NULL and argument was converted to COMPLEX
*/
c = c_acrd(arg1.v_com, eps);
c = c_acrd(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_ACRD_3);
}
@@ -12370,7 +12402,7 @@ f_acrd(int count, VALUE **vals)
result.v_type = V_NUM;
}
}
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
/*
* case: argument type is not valid for this function

39
help.c
View File

@@ -56,38 +56,41 @@ STATIC struct help_alias {
char *topic;
char *filename;
} halias[] = {
/* We sort the list below via: sort -d -u */
{"=", "address"},
{"->", "arrow"},
{"=", "assign"},
{"*", "dereference"},
{".", "oldvalue"},
{"%", "mod"},
{"//", "quo"},
{".", "oldvalue"},
{"#", "pound"},
{"calc", "help"},
{"//", "quo"},
{"COPYING_LGPL", "COPYING-LGPL"},
{"COPYLEFT", "copyright"},
{"COPYRIGHT", "copyright"},
{"Copyleft", "copyright"},
{"Copyright", "copyright"},
{"abort", "command"},
{"cd", "command"},
{"copy", "blkcpy"},
{"copying", "COPYING"},
{"copying-lgpl", "COPYING-LGPL"},
{"copying_lgpl", "COPYING-LGPL"},
{"COPYING_LGPL", "COPYING-LGPL"},
{"Copyright", "copyright"},
{"COPYRIGHT", "copyright"},
{"Copyleft", "copyright"},
{"COPYLEFT", "copyright"},
{"define", "command"},
{"read", "command"},
{"write", "command"},
{"quit", "command"},
{"exit", "command"},
{"abort", "command"},
{"cd", "command"},
{"show", "command"},
{"stdlib", "resource"},
{"question", "questions"},
{"dm2d", "dms2d"},
{"exit", "command"},
{"gm2g", "gms2g"},
{"hm2d", "hms2d"},
{"man", "calc"},
{"question", "questions"},
{"quit", "command"},
{"read", "command"},
{"release", "releases"},
{"show", "command"},
{"stdlib", "resource"},
{"usage", "calc"},
{"write", "command"},
/* MUST BE LAST! */
{NULL, NULL}
};

View File

@@ -118,76 +118,65 @@ V=@:
# Files managed by this Makefile #
##################################
STD_HELP_FILES_1= intro overview help
STD_HELP_FILES_1= intro overview
BLT_HELP_FILES_1a= calc
STD_HELP_FILES_2= assoc
BLT_HELP_FILES_3= builtin man
STD_HELP_FILES_4= command config custom define environment expression
BLT_HELP_FILES_3= builtin
STD_HELP_FILES_4= command config custom define environment
BLT_HELP_FILES_5= errorcodes
STD_HELP_FILES_6= file history interrupt list mat
STD_HELP_FILES_6= expression file history interrupt list mat
# because obj is built special (due to confusion with it as
# a symlink for some built environments, we treat obj specially
# and call it obj.file
#
SPECIAL_HELP_7= obj.file
STD_HELP_FILES_8= operator statement
STD_HELP_FILES_8= operator
BLT_HELP_FILES_9= resource
STD_HELP_FILES_10= script statement types unexpected variable
STD_HELP_FILES_10= types script
BLT_HELP_FILES_10a= usage cscript
STD_HELP_FILES_10b= unexpected variable
BLT_HELP_FILES_11= bindings custom_cal libcalc new_custom resource
BLT_HELP_FILES_11= bindings custom_cal libcalc new_custom cscript
STD_HELP_FILES_12= archive
BLT_HELP_FILES_13= bugs changes contrib
STD_HELP_FILES_14= todo wishlist
BLT_HELP_FILES_13= bugs changes
STD_HELP_FILES_15= credit
# copyright is printed by help.c is from the Copyright string found in version.c
BLT_HELP_FILES_16= COPYING COPYING-LGPL questions releases
STD_HELP_FILES_14= credit
BLT_HELP_FILES_14= contrib COPYING COPYING-LGPL questions releases
STD_HELP_FILES_15= wishlist todo
STD_HELP_FILES_17= help
# These files are used in the following order to construct full
#
FULL_HELP_FILES= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
${BLT_HELP_FILES_3} ${STD_HELP_FILES_4} \
${BLT_HELP_FILES_5} ${STD_HELP_FILES_6} \
${SPECIAL_HELP_7} ${STD_HELP_FILES_8} \
${BLT_HELP_FILES_9} ${STD_HELP_FILES_10} \
${BLT_HELP_FILES_10a} ${STD_HELP_FILES_10b} \
${BLT_HELP_FILES_11} ${STD_HELP_FILES_12} \
${BLT_HELP_FILES_13} ${STD_HELP_FILES_14} \
${BLT_HELP_FILES_14} ${STD_HELP_FILES_15}
FULL_HELP_FILES= ${STD_HELP_FILES_1} ${BLT_HELP_FILES_1a} \
${STD_HELP_FILES_2} \
${BLT_HELP_FILES_3} ${STD_HELP_FILES_4} \
${BLT_HELP_FILES_5} ${STD_HELP_FILES_6} \
${SPECIAL_HELP_7} ${STD_HELP_FILES_8} \
${BLT_HELP_FILES_9} ${STD_HELP_FILES_10} \
${BLT_HELP_FILES_11} ${STD_HELP_FILES_12} \
${BLT_HELP_FILES_13} ${STD_HELP_FILES_14} \
${STD_HELP_FILES_15} ${BLT_HELP_FILES_16} \
${STD_HELP_FILES_17}
# These full files are those who are not built or constructed
#
STD_HELP_FILES= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
${STD_HELP_FILES_4} ${STD_HELP_FILES_6} \
${STD_HELP_FILES_8} ${STD_HELP_FILES_10} \
${STD_HELP_FILES_10b} \
STD_HELP_FILES= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
${STD_HELP_FILES_4} ${STD_HELP_FILES_6} \
${STD_HELP_FILES_8} ${STD_HELP_FILES_10} \
${STD_HELP_FILES_12} ${STD_HELP_FILES_14} \
${STD_HELP_FILES_15}
${STD_HELP_FILES_15} ${STD_HELP_FILES_17}
# These full files are those who are built by this Makefile
#
# Note that ${SPECIAL_HELP_7} is not included in this list
# because of problems with its name.
#
BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
${BLT_HELP_FILES_9} \
${BLT_HELP_FILES_10a} \
${BLT_HELP_FILES_11} ${BLT_HELP_FILES_13} \
${BLT_HELP_FILES_14}
BLT_HELP_FILES= ${BLT_HELP_FILES_1a} \
${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
${BLT_HELP_FILES_9} ${BLT_HELP_FILES_11} \
${BLT_HELP_FILES_13} ${BLT_HELP_FILES_16}
# The detailed list of help files to install
#
@@ -254,10 +243,18 @@ DISTLIST= ${STD_HELP_FILES} ${DETAIL_HELP} ${MAKE_FILE} \
# These files are used to make (but not built) a calc .a link library
#
CALCLIBLIST=
# complete list of files that may be created as part of the build process
#
# Used by chk_tree via make prep
#
BUILD_ALL= ${BLT_HELP_FILES} ${SINGULAR_FILES} ${DETAIL_CLONE} \
full funclist${EXT} funclist.c funclist.o
# rules that are not also names of files
#
PHONY= all clobber distlist install
PHONY= all distlist buildlist distdir calcliblist detail_help_list \
echo_inst_files clean clobber install uninstall
############################################################
@@ -278,6 +275,8 @@ all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \
# additional Makefile targets #
###############################
.PHONY: ${PHONY}
# used by the upper level Makefile to determine of we have done all
#
# NOTE: Due to bogus shells found on one common system we must have
@@ -287,8 +286,6 @@ all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \
${RM} -f .all
${TOUCH} .all
.PHONY: ${PHONY}
bindings: ../cal/bindings
${RM} -f $@
${CP} ../cal/bindings $@
@@ -374,7 +371,7 @@ errorcodes: ../errcode${EXT}
${TRUE}; \
fi
usage: ../calc.usage
calc: ../calc.usage
${RM} -f $@
${CP} ../calc.usage $@
${CHMOD} 0444 $@
@@ -425,18 +422,6 @@ copy: blkcpy
${TRUE}; \
fi
man: help
${RM} -f $@
${CP} help $@
${CHMOD} 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
echo ''; \
else \
${TRUE}; \
fi
COPYING: ../COPYING
${RM} -f $@
${CP} ../COPYING $@
@@ -619,6 +604,13 @@ distlist: ${DISTLIST}
fi; \
done | fgrep -v '.bak' | LANG=C ${SORT}
buildlist:
${Q} for i in ${BUILD_ALL} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
echo help/$$i; \
fi; \
done | fgrep -v '.bak' | LANG=C ${SORT}
distdir:
${Q} echo help

View File

@@ -14,7 +14,7 @@ DESCRIPTION
strings available, including the program or script name.
If the numeric arg is supplied, then the corresponding command line
string is return, if it exists. Otherwise a nul() value is returned.
string is return, if it exists. Otherwise a null() value is returned.
In keeping with the argc/argv convention of C, argv(0) will refer
to the name of the program. If the -f filename argument is used,

View File

@@ -152,7 +152,7 @@ Command sequence
exit string
The action of these commands depends on where they are used.
At the interactive level, they will cause calc it edit.
At the interactive level, they will cause calc to exit.
This is the normal way to leave the calculator. In any
other use, they will stop the current calculation as if
an error had occurred.

View File

@@ -8,18 +8,17 @@ TYPES
return string
DESCRIPTION
The ctime() builtin returns the string formed by the first 24
The ctime() builtin returns the string formed by the
characters returned by the C library function, ctime(): E.g.
"Mon Oct 28 00:47:00 1996"
The 25th ctime() character, '\n' is removed.
"Mon Oct 28 00:47:00 1996\n"
EXAMPLE
; ## NOTE: Your output will likely vary:
; printf("The time is now %s.\n", ctime())
The time is now Mon Apr 15 12:41:44 1996.
The time is now Mon Apr 15 12:41:44 1996
.
LIMITS
none

View File

@@ -46,7 +46,7 @@ DESCRIPTION
Some non-POSIX systems such as MS Windows treat text files
and binary files differently. In text mode MS Windows consider
"\r\n" and end-of-line character. On an Apple MAC, the
"\r\n" an end-of-line character. On an Apple MAC, the
text mode end-of-line character is "\r".
Names of files are subject to ~ expansion just like the C or

View File

@@ -100,7 +100,7 @@ DESCRIPTION
Some non-POSIX systems such as MS Windows treat text files
and binary files differently. In text mode MS Windows consider
"\r\n" and end-of-line character. On an Apple MAC, the
"\r\n" an end-of-line character. On an Apple MAC, the
text mode end-of-line character is "\r".
Names of files are subject to ~ expansion just like the C or

View File

@@ -5,7 +5,7 @@ following topics:
----- -----------
intro introduction to calc
overview overview of calc
help this file
calc calc man page, how to invoke the calc command
assoc using associations
builtin builtin functions
@@ -23,18 +23,17 @@ following topics:
mat using matrices
obj user defined data types
operator math, relational, logic and variable access operators
resource standard calc resource files
script using calc shell scripts
statement flow control and declaration statements
types builtin data types
unexpected unexpected syntax/usage surprises for C programmers
usage how to invoke the calc command
variable variables and variable declarations
bindings input & history character bindings
custom_cal information about custom calc resource files
libcalc using the arbitrary precision routines in a C program
new_custom information about how to add new custom functions
resource standard calc resource files
script using calc shell scripts
cscript info on the calc shell scripts supplied with calc
archive where to get the latest versions of calc
@@ -51,6 +50,7 @@ following topics:
questions how to ask simple general question about calc
release on calc versions and releases
help this file
full all of the above (in the above order)
For example:

View File

@@ -2,7 +2,7 @@ NAME
matfill - fill a matrix with specified value or values
SYNOPSIS
mat(m, x [, y])
matfill(m, x [, y])
TYPES
m matrix

View File

@@ -2,7 +2,7 @@ NAME
mattrans - matrix transpose
SYNOPSIS
matdim(m)
mattrans(m)
TYPES
m 2-dimensional matrix

View File

@@ -10,10 +10,43 @@ TYPES
return string
DESCRIPTION
When prompt(str) is called and input is from a terminal, the string
str is displayed and execution is halted until a newline ends a line
read from the input; the string formed by the characters in the line
(other than the newline) is returned as the value of prompt().
When prompt(str) is called and input is from a terminal, the string
str is displayed and execution is halted until a newline ends a line
read from the input; the string formed by the characters in the line
(other than the newline) is returned as the value of prompt().
Be careful when using prompt(str) while calc is being used as a
shell script. Unless calc is run with the -p command line option,
the prompt builtin will fail and return null. This is because when
calc is running as a shell script, calc will close stdin run in in
a non-interactive mode.
The following shell script will always print "got null" because
stdin will be closed by calc during startup:
#!/usr/bin/calc -q -f
# The prompt will ALWAYS FAIL and return a null value
n = prompt("Test> ");
if (isnull(n)) {
print("got null");
} else {
print("got " + n);
}
However the following shell script (note the -p before the -f in
the 1st line) will be interactive, prompt with "Test> " and print
the "got" result as expected:
#!/usr/bin/calc -q -p -f
n = prompt("Test> ");
if (isnull(n)) {
print("got null");
} else {
print("got " + n);
}
EXAMPLE
; x = prompt("? ");
@@ -35,9 +68,9 @@ LINK LIBRARY
none
SEE ALSO
fgetfield, fgetline, fgetstr
command, fgetfield, fgetline, fgetstr, unexpected
## Copyright (C) 1999-2006 Landon Curt Noll
## Copyright (C) 1999,2006,2023 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -1,5 +1,5 @@
NAME
randbit - Blum-Blum-Shub pseudo-random number generator
randombit - Blum-Blum-Shub pseudo-random number generator
SYNOPSIS
randombit([x])

View File

@@ -534,8 +534,15 @@ Unexpected
Some might be surprised to discover that all of the trigonometric in calc:
sin, cos, tan, sec, csc, cot
asin, acos, atan, asec, acsc, acot
sin, cos, tan, cot, sec, csc
asin, acos, atan, acot, asec, acsc
versin, coversin, vercos, covercos
aversin, acoversin, avercos, acovercos
haversin, hacoversin, havercos, hacovercos
ahaversin, hacoversin, havercos, ahacovercos
exsec, aexsec, excsc, aexcsc
crd, acrd
cas, cis
work in only radians.
@@ -556,6 +563,7 @@ Unexpected
; print sin(d2r(30))
0.5
* operator has has a higher precedence than <<
==============================================
@@ -563,6 +571,49 @@ Unexpected
So 3 << 2*5 evaluates to 3072 in C, whereas 3 << 2*5 evaluates to 60 in calc.
prompt builtin returns null in calc shell scripts unless -p is used
===================================================================
Be careful when using prompt(str) while calc is being used as a
shell script. Unless calc is run with the -p command line option,
the prompt builtin will fail and return null. This is because when
calc is running as a shell script, calc will close stdin run in in
a non-interactive mode.
The following shell script will always print "got null" because
stdin will be closed by calc during startup:
#!/usr/bin/calc -q -f
n = prompt("Test> ");
if (isnull(n)) {
print("got null");
} else {
print("got " + n);
}
However the following shell script (note the -p before the -f in
the 1st line) will be interactive, prompt with "Test> " and print
the "got" result as expected:
#!/usr/bin/calc -q -p -f
n = prompt("Test> ");
if (isnull(n)) {
print("got null");
} else {
print("got " + n);
}
Note in the example above, the -p flag must be given before the
final -f command line flag.
A similar problem will occur if the calc shell script attempts
to read from standard input (stdin), unless the -p flag is used.
See "SHELL SCRIPT MODE" in the calc man page for more information
about -p and about the "shell script mode".
## Copyright (C) 1999-2007,2014,2017,2021,2023 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under

View File

@@ -38,6 +38,14 @@ export EXIT_CODE=0
# We exclude binary files, RCS source code history, intermediate
# compiled files, patch droppings and compiled binary libraries.
#
# We also ignore filenames with a single letter, and files
# that end in .out, and files containing the any of the following
# in any letter case:
#
# foo bar baz curds whey rmme
#
# Such files are temporary/test files and are not part of calc.
#
# Last, we have two files that have long lines that, for now,
# we cannot be as picky about without significant work.
#
@@ -53,7 +61,9 @@ LEADING_SPACES_BEFORE_TAB=$(
-path './longbits' -o -name '.*.swp' -o -name 'conf.h' -o \
-name '.git' -o -path './custom/libcustcalc*' -o -path './libcustcalc*' -o \
-name 'sample_many-static' -o -name 'sample_rand-static' -o \
-name 'codeql-analysis.yml' -o -name tags -o -name debug.out \
-name 'codeql-analysis.yml' -o -name tags -o -name '*.out' -o \
-name '?' -o -iname '*foo*' -o -iname '*bar*' -o -iname '*baz*' -o \
-iname '*curds*' -o -iname '*whey*' -o -iname '*rmme*' \
\) -prune -o -type f -print0 | \
xargs -0 egrep -l '^ * * '
)
@@ -69,6 +79,14 @@ fi
# We exclude binary files, RCS source code history, intermediate
# compiled files, patch droppings and compiled binary libraries.
#
# We also ignore filenames with a single letter, and files
# that end in .out, and files containing the any of the following
# in any letter case:
#
# foo bar baz curds whey rmme
#
# Such files are temporary/test files and are not part of calc.
#
# Last, we have two files that have long lines that, for now,
# we cannot be as picky about without significant work.
#
@@ -84,7 +102,8 @@ TRAILING_WHITESPACE=$(
-path './longbits' -o -name '.*.swp' -o -name 'conf.h' -o \
-name '.git' -o -path './custom/libcustcalc*' -o -path './libcustcalc*' -o \
-name 'sample_many-static' -o -name 'sample_rand-static' -o \
-name 'codeql-analysis.yml' -o -name tags -o -name debug.out \
-name '?' -o -iname '*foo*' -o -iname '*bar*' -o -iname '*baz*' -o \
-iname '*curds*' -o -iname '*whey*' -o -iname '*rmme*' \
\) -prune -o -type f -print0 | \
xargs -0 egrep -l '[ ]$'
)
@@ -139,6 +158,14 @@ fi
# We exclude binary files, source code history, intermediate
# compiled files, patch droppings and compiled binary libraries.
#
# We also ignore filenames with a single letter, and files
# that end in .out, and files containing the any of the following
# in any letter case:
#
# foo bar baz curds whey rmme
#
# Such files are temporary/test files and are not part of calc.
#
# Last, we have files that have long lines that, for now,
# we cannot be as picky about without significant work.
#
@@ -154,8 +181,9 @@ PICKY_PHASE_1=$(
-path './longbits' -o -name '.*.swp' -o -name 'conf.h' -o \
-name '.git' -o -path './custom/libcustcalc*' -o -path './libcustcalc*' -o \
-name 'sample_many-static' -o -name 'sample_rand-static' -o \
-name 'codeql-analysis.yml' -o -name tags -o -name debug.out -o \
-name '.gitignore' -o -name 'README.md' -o -name '.lldbinit' \
-name 'codeql-analysis.yml' -o -name tags -o -name '*.out' -o \
-name '?' -o -iname '*foo*' -o -iname '*bar*' -o -iname '*baz*' -o \
-iname '*curds*' -o -iname '*whey*' -o -iname '*rmme*' \
\) -prune -o -type f -print0 | \
if [[ -x /usr/local/bin/picky ]]; then
xargs -0 /usr/local/bin/picky -s -v -w132
@@ -184,7 +212,7 @@ if [[ -n $BACKUP_MAKEILES ]]; then
echo
echo "# You need execute the following to remove backup Makefiles:"
echo
echo "$BACKUP_MAKEILES" | while read file; do
echo "$BACKUP_MAKEILES" | while read -r file; do
echo "rm -f $file"
done
EXIT_CODE=7

View File

@@ -180,6 +180,8 @@ fi
echo
echo "calc $(./ver_calc) release"
echo
echo 'calc-*'$(./ver_calc)'*'
echo
echo "Release v$(./ver_calc)"
# All Done!!! -- Jessica Noll, Age 2

View File

@@ -80,7 +80,13 @@ char *Copyright = "\n"
"\n"
"Calc is open software; you can redistribute it and/or modify it under\n"
"the terms of the version 2.1 of the GNU Lesser General Public License\n"
"as published by the Free Software Foundation.\n";
"as published by the Free Software Foundation.\n"
"\n"
"Please see the file COPYING, or use the calc command:\n"
"\n"
"\thelp copying\n"
"\n"
"for important copyright and license information!\n";
char *Usability = "\n"
"Calc is distributed in the hope that it will be useful, but WITHOUT\n"
"ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n"

View File

@@ -64,7 +64,7 @@
#define MAJOR_VER 2 /* level 1: major library version */
#define MINOR_VER 15 /* level 2: minor library version */
#define MAJOR_PATCH 0 /* level 3: major software version level */
#define MINOR_PATCH 0 /* level 4: minor software version level */
#define MINOR_PATCH 4 /* level 4: minor software version level */
#endif /* !INCLUDE_VERSION_H*/

18
zmath.h
View File

@@ -79,7 +79,7 @@ typedef USB64 FULL; /* double unit of number storage */
typedef SB64 SFULL; /* signed FULL */
#define SWAP_HALF_IN_B64(dest, src) SWAP_B32_IN_B64(dest, src)
#define SWAP_HALF_IN_B32(dest, src) (*(dest) = *(src))
#define SWAP_HALF_IN_B32(dest, src) (*((HALF *)(dest)) = *((HALF *)(src)))
#define SWAP_HALF_IN_FULL(dest, src) SWAP_B32_IN_B64(dest, src)
#define SWAP_HALF_IN_HASH(dest, src) SWAP_B16_IN_HASH(dest, src)
#define SWAP_HALF_IN_FLAG(dest, src) SWAP_B16_IN_FLAG(dest, src)
@@ -106,9 +106,9 @@ typedef SB32 SFULL; /* signed FULL */
#define SWAP_HALF_IN_FLAG(dest, src) SWAP_B16_IN_FLAG(dest, src)
#define SWAP_HALF_IN_bool(dest, src) SWAP_B16_IN_bool(dest, src)
#define SWAP_HALF_IN_LEN(dest, src) SWAP_B16_IN_LEN(dest, src)
#define SWAP_B32_IN_FULL(dest, src) (*(dest) = *(src))
#define SWAP_B32_IN_FULL(dest, src) (*((FULL *)(dest)) = *((FULL *)(src)))
#define SWAP_B16_IN_FULL(dest, src) SWAP_B16_IN_B32(dest, src)
#define SWAP_B16_IN_HALF(dest, src) (*(dest) = *(src))
#define SWAP_B16_IN_HALF(dest, src) (*((HALF *)(dest)) = *((HALF *)(src)))
#define SWAP_B8_IN_FULL(dest, src) SWAP_B8_IN_B32(dest, src)
#define SWAP_B8_IN_HALF(dest, src) SWAP_B8_IN_B16(dest, src)
@@ -171,19 +171,11 @@ typedef SB32 LEN; /* calc v2 compatible unit of length storage */
typedef uintptr_t LEN; /* unit of length storage */
#endif /* MAJOR_VER < 3 */
#define SWAP_B32_IN_HASH(dest, src) (*(dest) = *(src))
#define SWAP_B16_IN_HASH(dest, src) SWAP_B16_IN_B32(dest, src)
#define SWAP_B8_IN_HASH(dest, src) SWAP_B8_IN_B32(dest, src)
#define SWAP_B32_IN_FLAG(dest, src) (*(dest) = *(src))
#define SWAP_B16_IN_FLAG(dest, src) SWAP_B16_IN_B32(dest, src)
#define SWAP_B8_IN_FLAG(dest, src) SWAP_B8_IN_B32(dest, src)
#define SWAP_B32_IN_bool(dest, src) (*(dest) = *(src))
#define SWAP_B32_IN_bool(dest, src) (*((bool *)(dest)) = *((bool *)(src)))
#define SWAP_B16_IN_bool(dest, src) SWAP_B16_IN_B32(dest, src)
#define SWAP_B8_IN_bool(dest, src) SWAP_B8_IN_B32(dest, src)
#define SWAP_B32_IN_LEN(dest, src) (*(dest) = *(src))
#define SWAP_B32_IN_LEN(dest, src) (*((LEN *)(dest)) = *((LEN *)(src)))
#define SWAP_B16_IN_LEN(dest, src) SWAP_B16_IN_B32(dest, src)
#define SWAP_B8_IN_LEN(dest, src) SWAP_B8_IN_B32(dest, src)

View File

@@ -1107,6 +1107,7 @@
* current Blum generator state
*/
STATIC RANDOM blum;
STATIC bool blum_initialized = false; /* true ==> blum has a seeded and initialized state */
/*
@@ -2272,11 +2273,14 @@ zsrandom1(CONST ZVALUE seed, bool need_ret)
/*
* initialize state if first call
*/
if (!blum.seeded) {
if (blum_initialized == false || !blum.seeded) {
p_blum = randomcopy(&init_blum);
randomfree(&blum);
if (blum_initialized == true) {
randomfree(&blum);
}
blum = *p_blum;
free(p_blum);
blum_initialized = true;
}
/*
@@ -2342,6 +2346,9 @@ zsrandom1(CONST ZVALUE seed, bool need_ret)
* reserved seed
*/
} else {
if (ret != NULL) {
randomfree(ret);
}
math_error("srandom seed must be 0 or >= 2^32");
not_reached();
}
@@ -2384,11 +2391,14 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
/*
* initialize state if first call
*/
if (!blum.seeded) {
if (blum_initialized == false || !blum.seeded) {
p_blum = randomcopy(&init_blum);
randomfree(&blum);
if (blum_initialized == true) {
randomfree(&blum);
}
blum = *p_blum;
free(p_blum);
blum_initialized = true;
}
/*
@@ -2409,11 +2419,13 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
* preset moduli only if small newn
*/
if (ziszero(newn)) {
randomfree(ret);
math_error("srandom newn == 0 reserved for future use");
not_reached();
}
set = (HALF)z1tol(newn);
if (!zistiny(newn) || set > BLUM_PREGEN) {
randomfree(ret);
math_error("srandom small newn must be [1,20]");
not_reached();
}
@@ -2433,7 +2445,7 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
* Otherwise non-zero seeds are processed as 1 arg calls
*/
} else {
zsrandom1(seed, false);
(void) zsrandom1(seed, false);
}
/*
@@ -2452,6 +2464,7 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
* Blum modulus must be 1 mod 4
*/
if (newn.v[0] % 4 != 1) {
randomfree(ret);
math_error("srandom large newn must be 1 mod 4");
not_reached();
}
@@ -2498,6 +2511,7 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
* reserved newn
*/
} else {
randomfree(ret);
math_error("srandom newn must be [1,20] or >= 2^32");
not_reached();
}
@@ -2543,11 +2557,14 @@ zsrandom4(CONST ZVALUE seed, CONST ZVALUE ip, CONST ZVALUE iq, long trials)
/*
* initialize state if first call
*/
if (!blum.seeded) {
if (blum_initialized == false || !blum.seeded) {
p_blum = randomcopy(&init_blum);
randomfree(&blum);
if (blum_initialized == true) {
randomfree(&blum);
}
blum = *p_blum;
free(p_blum);
blum_initialized = true;
}
/*
@@ -2559,10 +2576,12 @@ zsrandom4(CONST ZVALUE seed, CONST ZVALUE ip, CONST ZVALUE iq, long trials)
* search the 'p' and 'q' Blum prime (3 mod 4) candidates
*/
if (!znextcand(ip, trials, _zero_, _three_, _four_, &p)) {
randomfree(ret);
math_error("failed to find 1st Blum prime");
not_reached();
}
if (!znextcand(iq, trials, _zero_, _three_, _four_, &q)) {
randomfree(ret);
math_error("failed to find 2nd Blum prime");
not_reached();
}
@@ -2640,11 +2659,14 @@ zsetrandom(CONST RANDOM *state)
/*
* initialize state if first call
*/
if (!blum.seeded) {
if (blum_initialized == false || !blum.seeded) {
p_blum = randomcopy(&init_blum);
randomfree(&blum);
if (blum_initialized == true) {
randomfree(&blum);
}
blum = *p_blum;
free(p_blum);
blum_initialized = true;
}
/*
@@ -2684,11 +2706,14 @@ zrandomskip(long cnt)
/*
* initialize state if first call
*/
if (!blum.seeded) {
if (blum_initialized == false || !blum.seeded) {
p_blum = randomcopy(&init_blum);
randomfree(&blum);
if (blum_initialized == true) {
randomfree(&blum);
}
blum = *p_blum;
free(p_blum);
blum_initialized = true;
}
loglogn = (long)blum.loglogn;
new_r.len = 0; /* paranoia */
@@ -2798,11 +2823,14 @@ zrandom(long cnt, ZVALUE *res)
/*
* initialize state if first call
*/
if (!blum.seeded) {
if (blum_initialized == false || !blum.seeded) {
p_blum = randomcopy(&init_blum);
randomfree(&blum);
if (blum_initialized == true) {
randomfree(&blum);
}
blum = *p_blum;
free(p_blum);
blum_initialized = true;
}
loglogn = blum.loglogn;
mask = blum.mask;
@@ -3120,16 +3148,18 @@ randomfree(RANDOM *state)
not_reached();
}
/* free the values */
/* clear the seed */
state->seeded = 0;
state->bits = 0; /* paranoia */
state->loglogn = 0; /* paranoia */
state->buffer = 0; /* paranoia */
state->mask = 0; /* paranoia */
/* free the values - unless they are one of the default states */
zfree_random(state->n);
zfree_random(state->r);
/* free it if it is not pre-defined */
state->seeded = 0;
state->bits = 0; /* paranoia */
state->buffer = 0;
/* free it if it is not pre-defined */
/* free the RANDOM structure if it is NOT our static blum value */
if (state != &blum) {
free(state);
}
@@ -3223,8 +3253,10 @@ randomprint(CONST RANDOM *UNUSED(state), int UNUSED(flags))
void
random_libcalc_cleanup(void)
{
/* free our state - let zfree_random protect the default state */
randomfree(&blum);
/* free our state if seed was initialized - zfree_random protect default states */
if (blum_initialized == true && blum.seeded) {
randomfree(&blum);
}
return;
}
@@ -3238,6 +3270,7 @@ random_libcalc_cleanup(void)
S_FUNC void
zfree_random(ZVALUE z)
{
/* do not free if NULL or one of the default states */
if (z.v != NULL &&
z.v != h_ndefvec && z.v != h_rdefvec && z.v != h_rdefvec_2 &&
z.v != h_nvec01 && z.v != h_rvec01 &&