Compare commits

..

151 Commits

Author SHA1 Message Date
Landon Curt Noll
d2025c5f24 fix make ver_calc in Makefile 2023-10-03 23:03:19 -07:00
Landon Curt Noll
801dad8f57 fix make clobber for cal/Makefile 2023-10-03 23:00:44 -07:00
Landon Curt Noll
5a227873e5 Release v2.15.0.0
The following are the changes in this release:

    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.
2023-10-03 22:39:35 -07:00
Landon Curt Noll
915054391e changed a few CHANGES notes to use changed instead of change 2023-10-03 22:28:42 -07:00
Landon Curt Noll
4b7ba942ee prep CHANGES for the next release of calc 2023-10-03 22:25:23 -07:00
Landon Curt Noll
42129a3672 change error printing from errnum to errsym
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).
2023-10-03 22:12:14 -07:00
Landon Curt Noll
db582d6e34 add config("triground") to trigonometric function rounding
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")

Improved "SEE ALSO" for the hyperbolic function help files.
2023-10-03 20:31:13 -07:00
Landon Curt Noll
fec9712b9a improve half trig help file equivalent to lines 2023-10-03 02:10:45 -07:00
Landon Curt Noll
68e1914ee7 document in LIBRARY, q_to_c() that was previously added
Added q_to_c(NUMBER *q) to make it easier to convert a NUMBER
into an allocated COMPLEX value.
2023-10-03 01:59:00 -07:00
Landon Curt Noll
2c4abcd2b7 add cas and cis trigonometric functions
Added the following new trigonometric functions:

    cas(x [,eps])		trigonometric cosine plus sine
    cis(x [,eps])		Euler's formula
2023-10-03 01:41:42 -07:00
Landon Curt Noll
26fc394089 add trigonometric chord of a unit circle functions
Improve builtin function strings, as printed by help builtin,
that use an optional accuracy (epsilon) arg by adding a comma.

Added the following new trigonometric functions:

    crd(x [,eps])		trigonometric chord of a unit circle
    acrd(x [,eps])		inverse trigonometric chord of a unit circle
2023-10-02 22:43:33 -07:00
Landon Curt Noll
c78a893862 add exterior trigonometric functions
Added the following new trigonometric functions:

    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

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.
2023-10-01 23:12:21 -07:00
Landon Curt Noll
5d62e58704 add half trigonometric functions
Fixed SEE ALSO typo in help randperm.

Added the following new trigonometric functions:

    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

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

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

Fix and improve recently comments and variable names added new
trigonometric functions in comfunc.c, func.c, qtrans.c.
2023-09-28 23:46:53 -07:00
Landon Curt Noll
ab95e47c0a fix and improve trigonometric help files
The trigonometric file files have had several bug fixed.

The EXAMPLE sections of trigonometric file have
been made consistent.

Added these new help files in anticipation of
the code for these new (i.e., to be written) builtin functions:

    hacovercos hacoversin havercos haversin
    ahacovercos ahacoversin ahavercos ahaversin
2023-09-24 12:52:14 -07:00
Landon Curt Noll
db80afb843 expand on error testing in calc regression suite
Rename E_BROUND to E_BROUND_1 as per an earlier change
on the E_STRING formats.

    E_BROUND ==> E_BROUND_1

Improve the ciarify of calc regression suite (regress.cal) to mostly
use E_STRING errsym instead of numeric errnum values for error()
and errno() related tests.
2023-09-21 12:35:50 -07:00
Landon Curt Noll
70a8225c0b restore error return for invalid args in error(), errno(), strerror(), errsym()
Passing an invalid argument to error(), errno() or strerror() will
again return an error value.
2023-09-20 23:26:46 -07:00
Landon Curt Noll
5fbb0ad2ea add test 10ddd to verify E_STRING values for calc computation error codes
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.
2023-09-20 23:10:32 -07:00
Landon Curt Noll
b741e98b13 restore optimized compiling of calc
We forgot to disable debug mode after
our debugging session was over.
Sorry (tm Canada :-))!
2023-09-20 22:39:11 -07:00
Landon Curt Noll
066bb78f0e fix error detection in logn 2023-09-20 22:37:31 -07:00
Landon Curt Noll
1a898caf3f add errsym builtin function
NOTE: errstr was renamed to errsym.

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.
2023-09-20 22:22:49 -07:00
Landon Curt Noll
120527d375 fix gcc v12.2.0 warnings when compiling errtbl.c 2023-09-19 22:13:10 -07:00
Landon Curt Noll
39429e370c fix errtbl.c to compile under gcc
When errtbl.c is being compiled for the errcode executable,
(when ERRCODE_SRC is defined), skip functions that make
called to math_error() and name_newerrorstr() from libcalc.
2023-09-19 18:42:34 -07:00
Landon Curt Noll
ff90bc0e3a add E_STRING to error, errno, strerror, change multiple E_STRING's
While help/errstr has been added, the errstr builtin function is
not yet written.  In anticipation of the new errstr builtin the
rest of the calc error system has been updated to associated errsym
E_STRING's with errnum error codes and errmsg error messages.

Minor improvements to help/rand.

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.

Group calc error related builtin support functions together in func.c.

Make switch indenting in func.c consistent.

Passing an invalid argument to error(), errno() or strerror() will
set errno AND throw a math error.  Before errno would be set and
an error value was returned.  Before there was no way to tell if
the error value was a result of the arg or if an error detected.

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.

The following is the list of E_STRING strings changes:

    E_APPR ==> E_APPR_1
    E_ROUND ==> E_ROUND_1
    E_SQRT ==> E_SQRT_1
    E_ROOT ==> E_ROOT_1
    E_SHIFT ==> E_SHIFT_1
    E_SCALE ==> E_SCALE_1
    E_POWI ==> E_POWI_1
    E_POWER ==> E_POWER_1
    E_QUO ==> E_QUO_1
    E_MOD ==> E_MOD_1
    E_ABS ==> E_ABS_1
    E_APPR2 ==> E_APPR_2
    E_APPR3 ==> E_APPR_3
    E_ROUND2 ==> E_ROUND_2
    E_ROUND3 ==> E_ROUND_3
    E_BROUND2 ==> E_BROUND_2
    E_BROUND3 ==> E_BROUND_3
    E_SQRT2 ==> E_SQRT_2
    E_SQRT3 ==> E_SQRT_3
    E_ROOT2 ==> E_ROOT_2
    E_ROOT3 ==> E_ROOT_3
    E_SHIFT2 ==> E_SHIFT_2
    E_SCALE2 ==> E_SCALE_2
    E_POWI2 ==> E_POWI_2
    E_POWER2 ==> E_POWER_2
    E_POWER3 ==> E_POWER_3
    E_QUO2 ==> E_QUO_2
    E_QUO3 ==> E_QUO_3
    E_MOD2 ==> E_MOD_2
    E_MOD3 ==> E_MOD_3
    E_ABS2 ==> E_ABS_2
    E_EXP1 ==> E_EXP_1
    E_EXP2 ==> E_EXP_2
    E_FPUTC1 ==> E_FPUTC_1
    E_FPUTC2 ==> E_FPUTC_2
    E_FPUTC3 ==> E_FPUTC_3
    E_FGETC1 ==> E_FGETC_1
    E_FGETC2 ==> E_FGETC_2
    E_FOPEN1 ==> E_FOPEN_1
    E_FOPEN2 ==> E_FOPEN_2
    E_FREOPEN1 ==> E_FREOPEN_1
    E_FREOPEN2 ==> E_FREOPEN_2
    E_FREOPEN3 ==> E_FREOPEN_3
    E_FCLOSE1 ==> E_FCLOSE_1
    E_FPUTS1 ==> E_FPUTS_1
    E_FPUTS2 ==> E_FPUTS_2
    E_FPUTS3 ==> E_FPUTS_3
    E_FGETS1 ==> E_FGETS_1
    E_FGETS2 ==> E_FGETS_2
    E_FPUTSTR1 ==> E_FPUTSTR_1
    E_FPUTSTR2 ==> E_FPUTSTR_2
    E_FPUTSTR3 ==> E_FPUTSTR_3
    E_FGETSTR1 ==> E_FGETSTR_1
    E_FGETSTR2 ==> E_FGETSTR_2
    E_FGETLINE1 ==> E_FGETLINE_1
    E_FGETLINE2 ==> E_FGETLINE_2
    E_FGETFIELD1 ==> E_FGETFIELD_1
    E_FGETFIELD2 ==> E_FGETFIELD_2
    E_REWIND1 ==> E_REWIND_1
    E_PRINTF1 ==> E_PRINTF_1
    E_PRINTF2 ==> E_PRINTF_2
    E_FPRINTF1 ==> E_FPRINTF_1
    E_FPRINTF2 ==> E_FPRINTF_2
    E_FPRINTF3 ==> E_FPRINTF_3
    E_STRPRINTF1 ==> E_STRPRINTF_1
    E_STRPRINTF2 ==> E_STRPRINTF_2
    E_FSCAN1 ==> E_FSCAN_1
    E_FSCAN2 ==> E_FSCAN_2
    E_FSCANF1 ==> E_FSCANF_1
    E_FSCANF2 ==> E_FSCANF_2
    E_FSCANF3 ==> E_FSCANF_3
    E_FSCANF4 ==> E_FSCANF_4
    E_STRSCANF1 ==> E_STRSCANF_1
    E_STRSCANF2 ==> E_STRSCANF_2
    E_STRSCANF3 ==> E_STRSCANF_3
    E_STRSCANF4 ==> E_STRSCANF_4
    E_SCANF1 ==> E_SCANF_1
    E_SCANF2 ==> E_SCANF_2
    E_SCANF3 ==> E_SCANF_3
    E_FTELL1 ==> E_FTELL_1
    E_FTELL2 ==> E_FTELL_2
    E_FSEEK1 ==> E_FSEEK_1
    E_FSEEK2 ==> E_FSEEK_2
    E_FSEEK3 ==> E_FSEEK_3
    E_FSIZE1 ==> E_FSIZE_1
    E_FSIZE2 ==> E_FSIZE_2
    E_FEOF1 ==> E_FEOF_1
    E_FEOF2 ==> E_FEOF_2
    E_FERROR1 ==> E_FERROR_1
    E_FERROR2 ==> E_FERROR_2
    E_UNGETC1 ==> E_UNGETC_1
    E_UNGETC2 ==> E_UNGETC_2
    E_UNGETC3 ==> E_UNGETC_3
    E_ISATTY1 ==> E_ISATTY_1
    E_ISATTY2 ==> E_ISATTY_2
    E_ACCESS1 ==> E_ACCESS_1
    E_ACCESS2 ==> E_ACCESS_2
    E_SEARCH1 ==> E_SEARCH_1
    E_SEARCH2 ==> E_SEARCH_2
    E_SEARCH3 ==> E_SEARCH_3
    E_SEARCH4 ==> E_SEARCH_4
    E_SEARCH5 ==> E_SEARCH_5
    E_SEARCH6 ==> E_SEARCH_6
    E_RSEARCH1 ==> E_RSEARCH_1
    E_RSEARCH2 ==> E_RSEARCH_2
    E_RSEARCH3 ==> E_RSEARCH_3
    E_RSEARCH4 ==> E_RSEARCH_4
    E_RSEARCH5 ==> E_RSEARCH_5
    E_RSEARCH6 ==> E_RSEARCH_6
    E_REWIND2 ==> E_REWIND_2
    E_STRERROR1 ==> E_STRERROR_1
    E_STRERROR2 ==> E_STRERROR_2
    E_COS1 ==> E_COS_1
    E_COS2 ==> E_COS_2
    E_SIN1 ==> E_SIN_1
    E_SIN2 ==> E_SIN_2
    E_EVAL2 ==> E_EVAL_2
    E_ARG1 ==> E_ARG_1
    E_ARG2 ==> E_ARG_2
    E_POLAR1 ==> E_POLAR_1
    E_POLAR2 ==> E_POLAR_2
    E_MATFILL1 ==> E_MATFILL_1
    E_MATFILL2 ==> E_MATFILL_2
    E_MATTRANS1 ==> E_MATTRANS_1
    E_MATTRANS2 ==> E_MATTRANS_2
    E_DET1 ==> E_DET_1
    E_DET2 ==> E_DET_2
    E_DET3 ==> E_DET_3
    E_MATMIN1 ==> E_MATMIN_1
    E_MATMIN2 ==> E_MATMIN_2
    E_MATMIN3 ==> E_MATMIN_3
    E_MATMAX1 ==> E_MATMAX_1
    E_MATMAX2 ==> E_MATMAX_2
    E_MATMAX3 ==> E_MATMAX_3
    E_CP1 ==> E_CP_1
    E_CP2 ==> E_CP_2
    E_CP3 ==> E_CP_3
    E_DP1 ==> E_DP_1
    E_DP2 ==> E_DP_2
    E_DP3 ==> E_DP_3
    E_SUBSTR1 ==> E_SUBSTR_1
    E_SUBSTR2 ==> E_SUBSTR_2
    E_INSERT1 ==> E_INSERT_1
    E_INSERT2 ==> E_INSERT_2
    E_DELETE1 ==> E_DELETE_1
    E_DELETE2 ==> E_DELETE_2
    E_LN1 ==> E_LN_1
    E_LN2 ==> E_LN_2
    E_ERROR1 ==> E_ERROR_1
    E_ERROR2 ==> E_ERROR_2
    E_EVAL3 ==> E_EVAL_3
    E_EVAL4 ==> E_EVAL_4
    E_RM1 ==> E_RM_1
    E_RM2 ==> E_RM_2
    E_BLK1 ==> E_BLK_1
    E_BLK2 ==> E_BLK_2
    E_BLK3 ==> E_BLK_3
    E_BLK4 ==> E_BLK_4
    E_BLKFREE1 ==> E_BLKFREE_1
    E_BLKFREE2 ==> E_BLKFREE_2
    E_BLKFREE3 ==> E_BLKFREE_3
    E_BLKFREE4 ==> E_BLKFREE_4
    E_BLKFREE5 ==> E_BLKFREE_5
    E_BLOCKS1 ==> E_BLOCKS_1
    E_BLOCKS2 ==> E_BLOCKS_2
    E_COPY1 ==> E_COPY_01
    E_COPY2 ==> E_COPY_02
    E_COPY3 ==> E_COPY_03
    E_COPY4 ==> E_COPY_04
    E_COPY5 ==> E_COPY_05
    E_COPY6 ==> E_COPY_06
    E_COPY7 ==> E_COPY_07
    E_COPY8 ==> E_COPY_08
    E_COPY9 ==> E_COPY_09
    E_COPY10 ==> E_COPY_10
    E_COPY11 ==> E_COPY_11
    E_COPY12 ==> E_COPY_12
    E_COPY13 ==> E_COPY_13
    E_COPY14 ==> E_COPY_14
    E_COPY15 ==> E_COPY_15
    E_COPY16 ==> E_COPY_16
    E_COPY17 ==> E_COPY_17
    E_COPYF1 ==> E_COPYF_1
    E_COPYF2 ==> E_COPYF_2
    E_COPYF3 ==> E_COPYF_3
    E_COPYF4 ==> E_COPYF_4
    E_PROTECT1 ==> E_PROTECT_1
    E_PROTECT2 ==> E_PROTECT_2
    E_PROTECT3 ==> E_PROTECT_3
    E_MATFILL3 ==> E_MATFILL_3
    E_MATFILL4 ==> E_MATFILL_4
    E_MATTRACE1 ==> E_MATTRACE_1
    E_MATTRACE2 ==> E_MATTRACE_2
    E_MATTRACE3 ==> E_MATTRACE_3
    E_TAN1 ==> E_TAN_1
    E_TAN2 ==> E_TAN_2
    E_COT1 ==> E_COT_1
    E_COT2 ==> E_COT_2
    E_SEC1 ==> E_SEC_1
    E_SEC2 ==> E_SEC_2
    E_CSC1 ==> E_CSC_1
    E_CSC2 ==> E_CSC_2
    E_SINH1 ==> E_SINH_1
    E_SINH2 ==> E_SINH_2
    E_COSH1 ==> E_COSH_1
    E_COSH2 ==> E_COSH_2
    E_TANH1 ==> E_TANH_1
    E_TANH2 ==> E_TANH_2
    E_COTH1 ==> E_COTH_1
    E_COTH2 ==> E_COTH_2
    E_SECH1 ==> E_SECH_1
    E_SECH2 ==> E_SECH_2
    E_CSCH1 ==> E_CSCH_1
    E_CSCH2 ==> E_CSCH_2
    E_ASIN1 ==> E_ASIN_1
    E_ASIN2 ==> E_ASIN_2
    E_ACOS1 ==> E_ACOS_1
    E_ACOS2 ==> E_ACOS_2
    E_ATAN1 ==> E_ATAN_1
    E_ATAN2 ==> E_ATAN_2
    E_ACOT1 ==> E_ACOT_1
    E_ACOT2 ==> E_ACOT_2
    E_ASEC1 ==> E_ASEC_1
    E_ASEC2 ==> E_ASEC_2
    E_ACSC1 ==> E_ACSC_1
    E_ACSC2 ==> E_ACSC_2
    E_ASINH1 ==> E_ASINH_1
    E_ASINH2 ==> E_ASINH_2
    E_ACOSH1 ==> E_ACOSH_1
    E_ACOSH2 ==> E_ACOSH_2
    E_ATANH1 ==> E_ATANH_1
    E_ATANH2 ==> E_ATANH_2
    E_ACOTH1 ==> E_ACOTH_1
    E_ACOTH2 ==> E_ACOTH_2
    E_ASECH1 ==> E_ASECH_1
    E_ASECH2 ==> E_ASECH_2
    E_ACSCH1 ==> E_ACSCH_1
    E_ACSCH2 ==> E_ACSCH_2
    E_GD1 ==> E_GD_1
    E_GD2 ==> E_GD_2
    E_AGD1 ==> E_AGD_1
    E_AGD2 ==> E_AGD_2
    E_BIT1 ==> E_BIT_1
    E_BIT2 ==> E_BIT_2
    E_SETBIT1 ==> E_SETBIT_1
    E_SETBIT2 ==> E_SETBIT_2
    E_SETBIT3 ==> E_SETBIT_3
    E_SEG1 ==> E_SEG_1
    E_SEG2 ==> E_SEG_2
    E_SEG3 ==> E_SEG_3
    E_HIGHBIT1 ==> E_HIGHBIT_1
    E_HIGHBIT2 ==> E_HIGHBIT_2
    E_LOWBIT1 ==> E_LOWBIT_1
    E_LOWBIT2 ==> E_LOWBIT_2
    E_HEAD1 ==> E_HEAD_1
    E_HEAD2 ==> E_HEAD_2
    E_TAIL1 ==> E_TAIL_1
    E_TAIL2 ==> E_TAIL_2
    E_XOR1 ==> E_XOR_1
    E_XOR2 ==> E_XOR_2
    E_INDICES1 ==> E_INDICES_1
    E_INDICES2 ==> E_INDICES_2
    E_EXP3 ==> E_EXP_3
    E_SINH3 ==> E_SINH_3
    E_COSH3 ==> E_COSH_3
    E_SIN3 ==> E_SIN_3
    E_COS3 ==> E_COS_3
    E_GD3 ==> E_GD_3
    E_AGD3 ==> E_AGD_3
    E_POWER4 ==> E_POWER_4
    E_ROOT4 ==> E_ROOT_4
    E_DGT1 ==> E_DGT_1
    E_DGT2 ==> E_DGT_2
    E_DGT3 ==> E_DGT_3
    E_PLCS1 ==> E_PLCS_1
    E_PLCS2 ==> E_PLCS_2
    E_DGTS1 ==> E_DGTS_1
    E_DGTS2 ==> E_DGTS_2
    E_ILOG10 ==> E_IBASE10_LOG
    E_ILOG2 ==> E_IBASE2_LOG
    E_COMB1 ==> E_COMB_1
    E_COMB2 ==> E_COMB_2
    E_ASSIGN1 ==> E_ASSIGN_1
    E_ASSIGN2 ==> E_ASSIGN_2
    E_ASSIGN3 ==> E_ASSIGN_3
    E_ASSIGN4 ==> E_ASSIGN_4
    E_ASSIGN5 ==> E_ASSIGN_5
    E_ASSIGN6 ==> E_ASSIGN_6
    E_ASSIGN7 ==> E_ASSIGN_7
    E_ASSIGN8 ==> E_ASSIGN_8
    E_ASSIGN9 ==> E_ASSIGN_9
    E_SWAP1 ==> E_SWAP_1
    E_SWAP2 ==> E_SWAP_2
    E_SWAP3 ==> E_SWAP_3
    E_QUOMOD1 ==> E_QUOMOD_1
    E_QUOMOD2 ==> E_QUOMOD_2
    E_QUOMOD3 ==> E_QUOMOD_3
    E_PREINC1 ==> E_PREINC_1
    E_PREINC2 ==> E_PREINC_2
    E_PREINC3 ==> E_PREINC_3
    E_PREDEC1 ==> E_PREDEC_1
    E_PREDEC2 ==> E_PREDEC_2
    E_PREDEC3 ==> E_PREDEC_3
    E_POSTINC1 ==> E_POSTINC_1
    E_POSTINC2 ==> E_POSTINC_2
    E_POSTINC3 ==> E_POSTINC_3
    E_POSTDEC1 ==> E_POSTDEC_1
    E_POSTDEC2 ==> E_POSTDEC_2
    E_POSTDEC3 ==> E_POSTDEC_3
    E_INIT1 ==> E_INIT_01
    E_INIT2 ==> E_INIT_02
    E_INIT3 ==> E_INIT_03
    E_INIT4 ==> E_INIT_04
    E_INIT5 ==> E_INIT_05
    E_INIT6 ==> E_INIT_06
    E_INIT7 ==> E_INIT_07
    E_INIT8 ==> E_INIT_08
    E_INIT9 ==> E_INIT_09
    E_INIT10 ==> E_INIT_10
    E_LIST1 ==> E_LIST_1
    E_LIST2 ==> E_LIST_2
    E_LIST3 ==> E_LIST_3
    E_LIST4 ==> E_LIST_4
    E_LIST5 ==> E_LIST_5
    E_LIST6 ==> E_LIST_6
    E_MODIFY1 ==> E_MODIFY_1
    E_MODIFY2 ==> E_MODIFY_2
    E_MODIFY3 ==> E_MODIFY_3
    E_MODIFY4 ==> E_MODIFY_4
    E_MODIFY5 ==> E_MODIFY_5
    E_FPATHOPEN1 ==> E_FPATHOPEN_1
    E_FPATHOPEN2 ==> E_FPATHOPEN_2
    E_LOG1 ==> E_LOG_1
    E_LOG2 ==> E_LOG_2
    E_LOG3 ==> E_LOG_3
    E_FGETFILE1 ==> E_FGETFILE_1
    E_FGETFILE2 ==> E_FGETFILE_2
    E_FGETFILE3 ==> E_FGETFILE_3
    E_TAN3 ==> E_TAN_3
    E_TAN4 ==> E_TAN_4
    E_COT3 ==> E_COT_3
    E_COT4 ==> E_COT_4
    E_SEC3 ==> E_SEC_3
    E_CSC3 ==> E_CSC_3
    E_TANH3 ==> E_TANH_3
    E_TANH4 ==> E_TANH_4
    E_COTH3 ==> E_COTH_3
    E_COTH4 ==> E_COTH_4
    E_SECH3 ==> E_SECH_3
    E_CSCH3 ==> E_CSCH_3
    E_ASIN3 ==> E_ASIN_3
    E_ACOS3 ==> E_ACOS_3
    E_ASINH3 ==> E_ASINH_3
    E_ACOSH3 ==> E_ACOSH_3
    E_ATAN3 ==> E_ATAN_3
    E_ACOT3 ==> E_ACOT_3
    E_ASEC3 ==> E_ASEC_3
    E_ACSC3 ==> E_ACSC_3
    E_ATANH3 ==> E_ATANH_3
    E_ACOTH3 ==> E_ACOTH_3
    E_ASECH3 ==> E_ASECH_3
    E_ACSCH3 ==> E_ACSCH_3
    E_D2R1 ==> E_D2R_1
    E_D2R2 ==> E_D2R_2
    E_R2D1 ==> E_R2D_1
    E_R2D2 ==> E_R2D_2
    E_G2R1 ==> E_G2R_1
    E_G2R2 ==> E_G2R_2
    E_R2G1 ==> E_R2G_1
    E_R2G2 ==> E_R2G_2
    E_D2G1 ==> E_D2G_1
    E_G2D1 ==> E_G2D_1
    E_D2DMS1 ==> E_D2DMS_1
    E_D2DMS2 ==> E_D2DMS_2
    E_D2DMS3 ==> E_D2DMS_3
    E_D2DMS4 ==> E_D2DMS_4
    E_D2DM1 ==> E_D2DM_1
    E_D2DM2 ==> E_D2DM_2
    E_D2DM3 ==> E_D2DM_3
    E_D2DM4 ==> E_D2DM_4
    E_G2GMS1 ==> E_G2GMS_1
    E_G2GMS2 ==> E_G2GMS_2
    E_G2GMS3 ==> E_G2GMS_3
    E_G2GMS4 ==> E_G2GMS_4
    E_G2GM1 ==> E_G2GM_1
    E_G2GM2 ==> E_G2GM_2
    E_G2GM3 ==> E_G2GM_3
    E_G2GM4 ==> E_G2GM_4
    E_H2HMS1 ==> E_H2HMS_1
    E_H2HMS2 ==> E_H2HMS_2
    E_H2HMS3 ==> E_H2HMS_3
    E_H2HMS4 ==> E_H2HMS_4
    E_H2HM1 ==> E_H2HM_1
    E_H2HM2 ==> E_H2HM_2
    E_H2HM3 ==> E_H2HM_3
    E_H2HM4 ==> E_H2HM_4
    E_DMS2D1 ==> E_DMS2D_1
    E_DMS2D2 ==> E_DMS2D_2
    E_DM2D1 ==> E_DM2D_1
    E_DM2D2 ==> E_DM2D_2
    E_GMS2G1 ==> E_GMS2G_1
    E_GMS2G2 ==> E_GMS2G_2
    E_GM2G1 ==> E_GM2G_1
    E_GM2G2 ==> E_GM2G_2
    E_HMS2H1 ==> E_HMS2H_1
    E_HMS2H2 ==> E_HMS2H_2
    E_HM2H1 ==> E_HM2H_1
    E_HM2H2 ==> E_HM2H_2
    E_VERSIN1 ==> E_VERSIN_1
    E_VERSIN2 ==> E_VERSIN_2
    E_VERSIN3 ==> E_VERSIN_3
    E_AVERSIN1 ==> E_AVERSIN_1
    E_AVERSIN2 ==> E_AVERSIN_2
    E_AVERSIN3 ==> E_AVERSIN_3
    E_COVERSIN1 ==> E_COVERSIN_1
    E_COVERSIN2 ==> E_COVERSIN_2
    E_COVERSIN3 ==> E_COVERSIN_3
    E_ACOVERSIN1 ==> E_ACOVERSIN_1
    E_ACOVERSIN2 ==> E_ACOVERSIN_2
    E_ACOVERSIN3 ==> E_ACOVERSIN_3
    E_VERCOS1 ==> E_VERCOS_1
    E_VERCOS2 ==> E_VERCOS_2
    E_VERCOS3 ==> E_VERCOS_3
    E_AVERCOS1 ==> E_AVERCOS_1
    E_AVERCOS2 ==> E_AVERCOS_2
    E_AVERCOS3 ==> E_AVERCOS_3
    E_COVERCOS1 ==> E_COVERCOS_1
    E_COVERCOS2 ==> E_COVERCOS_2
    E_COVERCOS3 ==> E_COVERCOS_3
    E_ACOVERCOS1 ==> E_ACOVERCOS_1
    E_ACOVERCOS2 ==> E_ACOVERCOS_2
    E_ACOVERCOS3 ==> E_ACOVERCOS_3
    E_TAN5 ==> E_TAN_5
    E_COT5 ==> E_COT_5
    E_COT6 ==> E_COT_6
    E_SEC5 ==> E_SEC_5
    E_CSC5 ==> E_CSC_5
    E_CSC6 ==> E_CSC_6
2023-09-19 18:34:21 -07:00
Landon Curt Noll
5e5656652f update error_table[] E_STRING symbols
Now the "E_STRING" errsym strings in error_table[], with exception
to the 1st E__BASE entry, all other errsym strings must match the
following regular expression:

	^E_[A-Z][A-Z0-9_]+$

Renamed "E_1OVER0" to "E_DIVBYZERO".
Renamed "E_0OVER0" to "E_ZERODIVZERO".
2023-09-13 21:38:07 -07:00
Landon Curt Noll
3b9393a8ac fix redundant #defines
Removed from errsym.h (as built by errcode -d via the Makefile),
E__NONE, E__BASE, E__USERDEF, and E__USERMAX.  These symbols were
also defined in errtbl.h, which is NOW the place of the #define.

Update .gitigore with another temporary file.
2023-09-13 20:55:22 -07:00
Landon Curt Noll
40c8f875c1 rename E__COUNT to ECOUNT
Rename the #define E__COUNT to ECOUNT to avoid confusion
with "E_STRING" error symbols.

Improve formatting of help/error, help/errno, and help/strerror.

Update .gitignore.
2023-09-13 20:20:46 -07:00
Landon Curt Noll
d943fda3eb clarify how old code may use the new error_table[] array
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;
2023-09-13 03:16:20 -07:00
Landon Curt Noll
a6824debbc improved calc computation error codes message array
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.

Updated .gitignore and trailblank to support the above changes.
2023-09-13 02:45:33 -07:00
Landon Curt Noll
1507adb261 improve more of the calc error code system
Even Further improve help files for help/errno, help/error,
and help/newerror.
2023-09-12 16:09:28 -07:00
Landon Curt Noll
229a60e4d5 improve calc error code system
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.
2023-09-12 16:06:27 -07:00
Landon Curt Noll
19819340ff improve calc error code system
Added help/errorcodes rule to the top level Makefile.

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

Improve help/error.  Added text about error code ranges and
range symbols.
2023-09-12 14:08:49 -07:00
Landon Curt Noll
4c65986502 improve inverse trigonometric help files 2023-09-11 15:34:12 -07:00
Landon Curt Noll
81eb6eac11 update which calc error codes are unused
In calcerr.tbl, error codes that are no longer
used start their error message with "UNUSED ERROR:".
2023-09-10 23:20:39 -07:00
Landon Curt Noll
bf730f5518 add cmappr() and missing complex tan, cot, sec, csc in liblcac
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
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);
2023-09-10 22:54:50 -07:00
Landon Curt Noll
a722b5cca7 update major trigonometric help files and regression tests
Improved help files for sin, cos, tan, cot, sec, csc.  In case
of tan, cot, sec, csc corrected help file was corrected to
indicate that complex arguments are allowed.  This was a help
file oversight from long ago when those trigonometric functions

Expanded the calc regression test suite test 34dd to test various
real and complex values for sin, cos, tan, cot, sec, csc.
2023-09-10 16:33:31 -07:00
Landon Curt Noll
78d536140f fix rand pseudo-random number generator
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.
2023-09-10 15:10:40 -07:00
Landon Curt Noll
8caa8d8635 update cal/README and cal/Makefile
Updated the cal/README to reflect the new names
of the calc regression test suite files.

Updated cal/Makefile to remove, when installing,
old names for calc regression test suite files.

Added missing getpgid_tmp to .gitignore.
2023-09-08 12:33:50 -07:00
Landon Curt Noll
d8603d3980 rename regression test calc resource files
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.
2023-09-08 12:15:04 -07:00
Landon Curt Noll
3fd55f0431 improve the cal/regress.cal regress test suite structure
Improve 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.
2023-09-07 22:11:36 -07:00
Landon Curt Noll
b67e20881a fix historical trigonometric functions for values of 0
Fixed how the historical trigonometric functions call
the underlying trigonometric functions.  This fixes a
number of issues where the function for values of 0.

Updated cal/regress.cal to test historical trigonometric functions
at the  0 value.
2023-09-06 18:02:46 -07:00
Landon Curt Noll
c153ac08b9 add covercos, acovercos, haversin, ahaversin to help Makefile 2023-09-06 01:01:36 -07:00
Landon Curt Noll
fdbf53d7e8 add vercos(), avercos(), covercos(), acovercos()
Improved trig help files.

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.
2023-09-06 00:52:37 -07:00
Landon Curt Noll
ea5b5e0b53 fix aversin() and acoversin() to not modify args 2023-09-05 22:27:14 -07:00
Landon Curt Noll
3abedd6713 fix aversin() and acoversin()
In cases where the real value to the inverse versed sine and the
inverse coversed sine function produces a complex value, the
conversion from real to complex was incorrect.

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().

NOTE: There is a XXX bug marked in the f_aversin() and f_acoversin()
that still needs to be fixed.
2023-09-05 16:09:22 -07:00
Landon Curt Noll
ed112997a7 improve output of make prep and the #! line of update_ver 2023-09-03 23:50:23 -07:00
Landon Curt Noll
86f1d9e029 add new aversin and acoversin builtin functions.
Added new aversin(x, [,eps]) for inverse versed sine and acoversin(x, [,eps])
for inverse coversed sine.

Improved trig function help files to reference use of complex arguments
that while supported were not documented.

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 Makefile testing rule 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".
2023-09-03 23:37:09 -07:00
Landon Curt Noll
8edff80826 improve comments for versed sine and coversed sine functions 2023-09-02 23:10:24 -07:00
Landon Curt Noll
b55d41c221 change cal/wf2.cal to cal/write2file.cal
Also fixed Makefile typo.
2023-09-02 21:14:54 -07:00
Landon Curt Noll
df11a211c9 add write2file.cal for an example of how to do file I/O 2023-09-02 21:13:36 -07:00
Landon Curt Noll
20ce75a06d move versin() and coversin() code
Moved versin() and coversin() to bottom of functions in func.c
(however the builtin function list remains sorted).

Created a historical trig functions section for cmath.h and qmath.h.

Moved cal/test3500.cal to cal/test9300.cal to make room
for future trip tests going from test 3427 thru 3599.
2023-09-01 23:53:30 -07:00
Landon Curt Noll
7398fbb2e9 rename vercos to coversin
The code to compute 1 - sin(x) belongs to coversin, not vercos.
2023-09-01 23:26:26 -07:00
Landon Curt Noll
b0a48a2b70 add new versin and vercos builtin functions
Added new versin(x, [,eps]) for versed sine and vercos(x, [,eps])
for versed cosine.

Updated trig help files.
2023-09-01 17:38:14 -07:00
Landon Curt Noll
1c839dfede add logn and error checking for invalue eps and epsilon values
Add 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.
2023-08-31 22:33:41 -07:00
Landon Curt Noll
4787199462 improve check for invalid epsilon
We added check_epsilon(NUMBER *q) so that later, builtin
functions can check the eps value as well.
2023-08-31 03:32:49 -07:00
Landon Curt Noll
b95a62c14e fix setting an invalid epsilon
Setting an invalid epsilon via the epsilon(value) or confiv("epsilon",
value) triggers an error.  The epsilon value must be: 0 < epsilon < 1.
2023-08-31 03:20:38 -07:00
Landon Curt Noll
e021e2130f add calv 3 wish to value.h 2023-08-31 02:15:51 -07:00
Landon Curt Noll
94d4c1ad64 fix Makefile use of ${EXT} for hsrc intermediates
Also improve .gitignore sort comment.  Sort generic excluded patterns
and added *.exe plus library exclusions.
2023-08-31 02:14:56 -07:00
Landon Curt Noll
5659ddbc4e remove CALC2_COMPAT symbol in source code
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.

Noted version.h symbols in README.RELEASE instead of CALC2_COMPAT.

Improve .gitignore.  Add excludes of hsrc temporary and test
programs.  Added note about how the list is sorted.
Moved the generic excludes to the top.
2023-08-31 02:02:40 -07:00
Landon Curt Noll
faa93bf085 add calc v3 wishlist for v_type to become an enum 2023-08-31 01:06:55 -07:00
Landon Curt Noll
0d2d5e3df3 add comment about turning off optimizer in .lldbinit 2023-08-31 01:02:21 -07:00
Landon Curt Noll
969e72b5c6 add .lldbinit improve debug comment in Makefile.local 2023-08-31 00:05:49 -07:00
Landon Curt Noll
4dbc4dfe9a add qispowerof2() to qfunc.c, improve log2() code
Change zispowerof2() interaface to take a FULL ptr as the 2nd arg:
zispowerof2(ZVALUE z, FULL *log2).

Added qispowerof2(NUMBER *q, NUMBER **qlog2) to qfunc.c.

Change log2() builtin to use the new qispowerof2() internal interface.

Update LIBRARY to reflect the new zispowerof2() internal interface
and the new qispowerof2() internal interface.
2023-08-27 23:50:44 -07:00
Landon Curt Noll
4e5fcc8812 add log2(x [,eps]) builtin function
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).
2023-08-27 19:02:37 -07:00
Landon Curt Noll
56c568060a updated ver_calc command line
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".
2023-08-27 16:18:12 -07:00
Landon Curt Noll
61206172f1 add NULL pre firewall to ZVALUE code
The z*.c functions that take pointers that cannot be NULL are checked
for NULL pointers at the beginning of the function.

While calc is not known to pass bogus NULL pointers to ZVALUE related
code, libcalc could be called by external code that might do so by
mistake.  If that happens, math_error() is called with the name of
the function and the name of the arg that was NULL.
2023-08-23 15:46:46 -07:00
Landon Curt Noll
0bb66cff74 change int.h to check MAJOR_VER < 3 when CHK_C is undefined
The int.h will trigger an error when CHK_C is undefined and MAJOR_VER
>= 3.  Improved the int.h error message in this case.

Added some comments and C integers to int.h.
2023-08-23 14:53:15 -07:00
Landon Curt Noll
0353aba275 add int.h
Added int.h as a centeral place for calc integer types and integer macros.

Currently zmath.c includes int.h but does not yet use it.

Added missing ptr type checks to chk_c.c.
2023-08-22 22:37:08 -07:00
Landon Curt Noll
2d5339fc51 update make chk_c rule to form status.chk_c.h
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.
2023-08-21 20:18:30 -07:00
Landon Curt Noll
6abdd8ef3f restore old fake boolean typedef when no <stdbool.h> 2023-08-21 04:05:24 -07:00
Landon Curt Noll
8c6d2b2e07 improve comment about use of += in Makefile.local 2023-08-21 03:59:03 -07:00
Landon Curt Noll
999ad61a78 fix bool.h dependency on have_stdbool.h, make depend 2023-08-21 03:51:28 -07:00
Landon Curt Noll
1cf05b660c add missing min and max checks to chk_c.c 2023-08-21 03:30:31 -07:00
Landon Curt Noll
4fddf82106 add C compiler and C include checks for calc
Fixed have_statfs optional executable file extension ${EXT{ in
the ${UTIL_PROGS} make variable.

Prevented the "fake boolean value" when <stdbool.h> is missing,
from complicating C compilers post c17 standard.

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.
2023-08-21 03:10:39 -07:00
Landon Curt Noll
b0aa949ad5 simplify booleans when <stdbool.h> header file is missing 2023-08-19 22:02:16 -07:00
Landon Curt Noll
3c18e6e25b changed C source to use C booleans with backward compatibility
Fix "Under source code control" date for new version.h file.

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.

The sign in a ZVALUE is now of type SIGN, whcih is either
SB32 when CALC2_COMPAT is defined, or a bool.

Replaced in C source, TRUE with true, FALSE with false, and
BOOL with bool.
2023-08-19 19:20:32 -07:00
Landon Curt Noll
e18b715f3f fix function decls for stringrel() and stringcaserel() 2023-08-19 18:20:15 -07:00
Landon Curt Noll
a0687079f4 fix MAXDATA for non-CALC2_COMPAT small pointer case 2023-08-19 17:34:55 -07:00
Landon Curt Noll
91c0c99a2c add CALC2_COMPAT and version.h
Moved calc version definition from version.c to version.h.
Added CALC2_COMPAT, that when defined attempts to maintain calc
version 2 compatibility.  When MAJOR_VER <= 2, CALC2_COMPAT is
defined.  This is anticipation for a future calc version 3 code.
2023-08-19 17:32:42 -07:00
Landon Curt Noll
a7597cdf6f improve use of fposval.h.def warning in Makefile
When `./fposval` fails to form `fposval.h` and
the fallback file `fposval.h.def` is used, issue
a suggestion for how to see the `./fposval` failure.
2023-08-19 16:22:07 -07:00
Landon Curt Noll
4b5c0e7574 fix format of examples in help/log2 and help/logn 2023-08-19 14:14:52 -07:00
Landon Curt Noll
f60a1d6bc5 add PTR_LEN and PTR_BITS to longbits.h
Added PTR_LEN (length of a pointer) and PTR_BITS (bit length
of a pointer) to longbits.h.
2023-08-19 12:53:31 -07:00
Landon Curt Noll
f2e4f638f6 change custom_compiled() to return BOOL
Also make slight improvements on error messages produced
when custom_compiled() returns an unexpected value.
2023-08-19 11:56:10 -07:00
Landon Curt Noll
c705b74e67 ignore built file: help/ilogn in .gitignore 2023-08-19 11:42:17 -07:00
Landon Curt Noll
5a117d542a add help in advance for new log2 and logn builtins
NOTE: The `log2(x [,eps])` and `logn(x, n [,eps])`
builtin functions are NOT yet implemented.
2023-08-19 11:23:02 -07:00
Landon Curt Noll
ea57d2f24f drop support for DJGPP and drop support for win32
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.
2023-08-18 17:05:49 -07:00
Landon Curt Noll
7ad1448a1a further clarify that Msys2 is a fork of Cygwin 2023-08-18 16:28:31 -07:00
Landon Curt Noll
96f925bede Merge pull request #96 from iahung2/master 2023-08-18 14:38:42 -07:00
iahung2
8055bf07c2 Update Makefile.config
Fix build on MSYS2 (MSYS)
2023-08-18 12:38:31 +07:00
Landon Curt Noll
28449fd187 Release v2.14.3.5
The following are the changes in this release:

    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.
2023-08-17 14:37:50 -07:00
Landon Curt Noll
d88b128b2d remove excess empty line from CHANGES 2023-08-17 14:30:30 -07:00
Landon Curt Noll
bc048bc029 prep CHANGES for the next release of calc 2023-08-17 14:28:52 -07:00
Landon Curt Noll
4d32b138ed change libcalc dynamic library to link with libcustcalc
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.
2023-08-17 14:23:29 -07:00
Landon Curt Noll
3cd8fd7053 Release v2.14.3.4
Fixed rpm spec file.

The following are the changes in this release:

    Fix typo in the `make debug` Makefile rule.

    Improved .gitignore to ignore .static, calc-static,
    sample_many-static and sample_rand-static.

    Improved error messages when trying to compile with
    with one calc type (when BLD_TYPE=calc-dynamic-only or
    BLD_TYPE=calc-static-only) and install with the other.

    When installing with BLD_TYPE=calc-static-only, the
    installed calc and calc-static are links to each other.
    Thanks to GitHub user @TurtleWilly for this suggestion.

    The dynamic shared libraries are not installed if they are not
    built.  So when installing with BLD_TYPE=calc-static-only, the
    install rule will not attempt to install dynamic shared libraries.
    Thanks to GitHub user @TurtleWilly for bringing to our attention,
    problems related to building a statically linked calc under macOS.

    Updated comments in Makefile.local for how to Diagnosing memory,
    thread, and crash issues under RHEL and macOS.

    We no longer support the Makefile variable ${ALLOW_CUSTOM} to be empty.
    Normally ${ALLOW_CUSTOM} is:

	ALLOW_CUSTOM= -DCUSTOM

    Now, to disable custom disable custom even if -C is given, use:

	ALLOW_CUSTOM="-UCUSTOM"

    Dropped support of Makefile.simple and custom/Makefile.simple.
    The calc version 2.14.3.0 is the last release that supported
    the Makefile.simple and custom/Makefile.simple files.
    Now, a make that supports makefile conditional syntax is required.
    The simple target, a target that only was used for Makefile.simple
    was removed.

    Moved makefile variables that configure calc and configure how to
    compile calc from Makefile into a new Makefile.config file.

    The Makeifle includes the Makefile.config file.
    The cal/Makeifle includes the Makefile.config file.
    The cscript/Makeifle includes the Makefile.config file.
    The custom/Makeifle includes the Makefile.config file.
    The help/Makeifle includes the Makefile.config file.

    Now, the Makefile.config file will consistently configure
    calc and how calc is compiled and built by all calc Makefiles.
    The custom/Makefile no longer includes Makefile.

    The platform target section from the old Makefile has been moved
    to a new file, Makefile.target.  Improved the format and comments
    in target information.

    The Makeifle includes the Makefile.target file.
    The cal/Makeifle includes the Makefile.target file.
    The cscript/Makeifle includes the Makefile.target file.
    The custom/Makeifle includes the Makefile.target file.
    The help/Makeifle includes the Makefile.target file.

    Now, the Makefile.target file will consistently set
    target information for all calc Makefiles.

    The cal/Makeifle includes the Makefile.local file.
    The cscript/Makeifle includes the Makefile.local file.
    The custom/Makeifle includes the Makefile.local file.
    The help/Makeifle includes the Makefile.local file.

    Thus, one may modify or append many Makefile variables
    in all calc Makefiles.

    Removed the ${CAL_PASSDOWN}, ${HELP_PASSDOWN}, ${HELP_PASSDOWN},
    ${CSCRIPT_PASSDOWN} Makefile variables as the new Makefile
    include files keep Makefile variables in sync.

    Fixed the ability of calc to compile when CUSTOM is undefined
    (i.e., -UCUSTOM).  The libcustcalc is always built, regardless
    of the $(ALLOW_CUSTOM} Makefile variable.  However when CUSTOM
    is undefined, the bulk of custom functions are not defined.

    Dropped the use of Makefile variable ${SET_INSTALL_NAME}.
    Under macOS it was always needed, elsewhere it was not.

    Added Makefile variable ${VER} to hold the calc major release version.
    The calc major release version is a 3 level version (x.y.z).

    Under macOS, the current version of both libcalc and libcustcalc
    shared libraries are set to the current calc major release version.

    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 "-dead_strip" by default.

    While calc on macOS will execute if linker used with "-dead_strip_dylibs"
    and CUSTOM is defined, other applications that use libcalc but not
    libcustcalc (such as sample_many and sample_rand) will fail to execute
    due to missile symbols.  Therefore "-dead_strip_dylibs" is not used
    by default when ALLOW_CUSTOM is "-DCUSTOM" under macOS.
    Thanks to GitHub user @TurtleWilly for bringing to our attention,
    problems related to use of  "-dead_strip_dylibs".

    When installing shared libraries, libcalc.x.y.z will be a link
    to the libcalc shared library and libcustcalc.x.y.z will be a link
    to the libcustcal shared library.
2023-08-14 23:09:46 -07:00
Landon Curt Noll
b0f19c1011 Release v2.14.3.4
Fixed rpm spec file.

The following are the changes in this release:

    Fix typo in the `make debug` Makefile rule.

    Improved .gitignore to ignore .static, calc-static,
    sample_many-static and sample_rand-static.

    Improved error messages when trying to compile with
    with one calc type (when BLD_TYPE=calc-dynamic-only or
    BLD_TYPE=calc-static-only) and install with the other.

    When installing with BLD_TYPE=calc-static-only, the
    installed calc and calc-static are links to each other.
    Thanks to GitHub user @TurtleWilly for this suggestion.

    The dynamic shared libraries are not installed if they are not
    built.  So when installing with BLD_TYPE=calc-static-only, the
    install rule will not attempt to install dynamic shared libraries.
    Thanks to GitHub user @TurtleWilly for bringing to our attention,
    problems related to building a statically linked calc under macOS.

    Updated comments in Makefile.local for how to Diagnosing memory,
    thread, and crash issues under RHEL and macOS.

    We no longer support the Makefile variable ${ALLOW_CUSTOM} to be empty.
    Normally ${ALLOW_CUSTOM} is:

	ALLOW_CUSTOM= -DCUSTOM

    Now, to disable custom disable custom even if -C is given, use:

	ALLOW_CUSTOM="-UCUSTOM"

    Dropped support of Makefile.simple and custom/Makefile.simple.
    The calc version 2.14.3.0 is the last release that supported
    the Makefile.simple and custom/Makefile.simple files.
    Now, a make that supports makefile conditional syntax is required.
    The simple target, a target that only was used for Makefile.simple
    was removed.

    Moved makefile variables that configure calc and configure how to
    compile calc from Makefile into a new Makefile.config file.

    The Makeifle includes the Makefile.config file.
    The cal/Makeifle includes the Makefile.config file.
    The cscript/Makeifle includes the Makefile.config file.
    The custom/Makeifle includes the Makefile.config file.
    The help/Makeifle includes the Makefile.config file.

    Now, the Makefile.config file will consistently configure
    calc and how calc is compiled and built by all calc Makefiles.
    The custom/Makefile no longer includes Makefile.

    The platform target section from the old Makefile has been moved
    to a new file, Makefile.target.  Improved the format and comments
    in target information.

    The Makeifle includes the Makefile.target file.
    The cal/Makeifle includes the Makefile.target file.
    The cscript/Makeifle includes the Makefile.target file.
    The custom/Makeifle includes the Makefile.target file.
    The help/Makeifle includes the Makefile.target file.

    Now, the Makefile.target file will consistently set
    target information for all calc Makefiles.

    The cal/Makeifle includes the Makefile.local file.
    The cscript/Makeifle includes the Makefile.local file.
    The custom/Makeifle includes the Makefile.local file.
    The help/Makeifle includes the Makefile.local file.

    Thus, one may modify or append many Makefile variables
    in all calc Makefiles.

    Removed the ${CAL_PASSDOWN}, ${HELP_PASSDOWN}, ${HELP_PASSDOWN},
    ${CSCRIPT_PASSDOWN} Makefile variables as the new Makefile
    include files keep Makefile variables in sync.

    Fixed the ability of calc to compile when CUSTOM is undefined
    (i.e., -UCUSTOM).  The libcustcalc is always built, regardless
    of the $(ALLOW_CUSTOM} Makefile variable.  However when CUSTOM
    is undefined, the bulk of custom functions are not defined.

    Dropped the use of Makefile variable ${SET_INSTALL_NAME}.
    Under macOS it was always needed, elsewhere it was not.

    Added Makefile variable ${VER} to hold the calc major release version.
    The calc major release version is a 3 level version (x.y.z).

    Under macOS, the current version of both libcalc and libcustcalc
    shared libraries are set to the current calc major release version.

    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 "-dead_strip" by default.

    While calc on macOS will execute if linker used with "-dead_strip_dylibs"
    and CUSTOM is defined, other applications that use libcalc but not
    libcustcalc (such as sample_many and sample_rand) will fail to execute
    due to missile symbols.  Therefore "-dead_strip_dylibs" is not used
    by default when ALLOW_CUSTOM is "-DCUSTOM" under macOS.
    Thanks to GitHub user @TurtleWilly for bringing to our attention,
    problems related to use of  "-dead_strip_dylibs".

    When installing shared libraries, libcalc.x.y.z will be a link
    to the libcalc shared library and libcustcalc.x.y.z will be a link
    to the libcustcal shared library.
2023-08-14 23:07:51 -07:00
Landon Curt Noll
fe520975cf Release v2.14.3.3
The following are the changes in this release:

    Fix typo in the `make debug` Makefile rule.

    Improved .gitignore to ignore .static, calc-static,
    sample_many-static and sample_rand-static.

    Improved error messages when trying to compile with
    with one calc type (when BLD_TYPE=calc-dynamic-only or
    BLD_TYPE=calc-static-only) and install with the other.

    When installing with BLD_TYPE=calc-static-only, the
    installed calc and calc-static are links to each other.
    Thanks to GitHub user @TurtleWilly for this suggestion.

    The dynamic shared libraries are not installed if they are not
    built.  So when installing with BLD_TYPE=calc-static-only, the
    install rule will not attempt to install dynamic shared libraries.
    Thanks to GitHub user @TurtleWilly for bringing to our attention,
    problems related to building a statically linked calc under macOS.

    Updated comments in Makefile.local for how to Diagnosing memory,
    thread, and crash issues under RHEL and macOS.

    We no longer support the Makefile variable ${ALLOW_CUSTOM} to be empty.
    Normally ${ALLOW_CUSTOM} is:

	ALLOW_CUSTOM= -DCUSTOM

    Now, to disable custom disable custom even if -C is given, use:

	ALLOW_CUSTOM="-UCUSTOM"

    Dropped support of Makefile.simple and custom/Makefile.simple.
    The calc version 2.14.3.0 is the last release that supported
    the Makefile.simple and custom/Makefile.simple files.
    Now, a make that supports makefile conditional syntax is required.
    The simple target, a target that only was used for Makefile.simple
    was removed.

    Moved makefile variables that configure calc and configure how to
    compile calc from Makefile into a new Makefile.config file.

    The Makeifle includes the Makefile.config file.
    The cal/Makeifle includes the Makefile.config file.
    The cscript/Makeifle includes the Makefile.config file.
    The custom/Makeifle includes the Makefile.config file.
    The help/Makeifle includes the Makefile.config file.

    Now, the Makefile.config file will consistently configure
    calc and how calc is compiled and built by all calc Makefiles.
    The custom/Makefile no longer includes Makefile.

    The platform target section from the old Makefile has been moved
    to a new file, Makefile.target.  Improved the format and comments
    in target information.

    The Makeifle includes the Makefile.target file.
    The cal/Makeifle includes the Makefile.target file.
    The cscript/Makeifle includes the Makefile.target file.
    The custom/Makeifle includes the Makefile.target file.
    The help/Makeifle includes the Makefile.target file.

    Now, the Makefile.target file will consistently set
    target information for all calc Makefiles.

    The cal/Makeifle includes the Makefile.local file.
    The cscript/Makeifle includes the Makefile.local file.
    The custom/Makeifle includes the Makefile.local file.
    The help/Makeifle includes the Makefile.local file.

    Thus, one may modify or append many Makefile variables
    in all calc Makefiles.

    Removed the ${CAL_PASSDOWN}, ${HELP_PASSDOWN}, ${HELP_PASSDOWN},
    ${CSCRIPT_PASSDOWN} Makefile variables as the new Makefile
    include files keep Makefile variables in sync.

    Fixed the ability of calc to compile when CUSTOM is undefined
    (i.e., -UCUSTOM).  The libcustcalc is always built, regardless
    of the $(ALLOW_CUSTOM} Makefile variable.  However when CUSTOM
    is undefined, the bulk of custom functions are not defined.

    Dropped the use of Makefile variable ${SET_INSTALL_NAME}.
    Under macOS it was always needed, elsewhere it was not.

    Added Makefile variable ${VER} to hold the calc major release version.
    The calc major release version is a 3 level version (x.y.z).

    Under macOS, the current version of both libcalc and libcustcalc
    shared libraries are set to the current calc major release version.

    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 "-dead_strip" by default.

    While calc on macOS will execute if linker used with "-dead_strip_dylibs"
    and CUSTOM is defined, other applications that use libcalc but not
    libcustcalc (such as sample_many and sample_rand) will fail to execute
    due to missile symbols.  Therefore "-dead_strip_dylibs" is not used
    by default when ALLOW_CUSTOM is "-DCUSTOM" under macOS.
    Thanks to GitHub user @TurtleWilly for bringing to our attention,
    problems related to use of  "-dead_strip_dylibs".

    When installing shared libraries, libcalc.x.y.z will be a link
    to the libcalc shared library and libcustcalc.x.y.z will be a link
    to the libcustcal shared library.
2023-08-14 22:45:24 -07:00
Landon Curt Noll
f097dd7dc1 update calc rpm to relase 14
Sort .gitignore.  Add calc.spec to .gitignore.

Update format of header part of Makefiles.

Modify calc.spec.in to handle dynamic shared libraries with 3-digit
version numbers.
2023-08-14 22:39:40 -07:00
Landon Curt Noll
3a7e763b28 Release v2.14.3.2
The following are the changes in this release:

    Fix typo in the `make debug` Makefile rule.

    Improved .gitignore to ignore .static, calc-static,
    sample_many-static and sample_rand-static.

    Improved error messages when trying to compile with
    with one calc type (when BLD_TYPE=calc-dynamic-only or
    BLD_TYPE=calc-static-only) and install with the other.

    When installing with BLD_TYPE=calc-static-only, the
    installed calc and calc-static are links to each other.
    Thanks to GitHub user @TurtleWilly for this suggestion.

    The dynamic shared libraries are not installed if they are not
    built.  So when installing with BLD_TYPE=calc-static-only, the
    install rule will not attempt to install dynamic shared libraries.
    Thanks to GitHub user @TurtleWilly for bringing to our attention,
    problems related to building a statically linked calc under macOS.

    Updated comments in Makefile.local for how to Diagnosing memory,
    thread, and crash issues under RHEL and macOS.

    We no longer support the Makefile variable ${ALLOW_CUSTOM} to be empty.
    Normally ${ALLOW_CUSTOM} is:

	ALLOW_CUSTOM= -DCUSTOM

    Now, to disable custom disable custom even if -C is given, use:

	ALLOW_CUSTOM="-UCUSTOM"

    Dropped support of Makefile.simple and custom/Makefile.simple.
    The calc version 2.14.3.0 is the last release that supported
    the Makefile.simple and custom/Makefile.simple files.
    Now, a make that supports makefile conditional syntax is required.
    The simple target, a target that only was used for Makefile.simple
    was removed.

    Moved makefile variables that configure calc and configure how to
    compile calc from Makefile into a new Makefile.config file.

    The Makeifle includes the Makefile.config file.
    The cal/Makeifle includes the Makefile.config file.
    The cscript/Makeifle includes the Makefile.config file.
    The custom/Makeifle includes the Makefile.config file.
    The help/Makeifle includes the Makefile.config file.

    Now, the Makefile.config file will consistently configure
    calc and how calc is compiled and built by all calc Makefiles.
    The custom/Makefile no longer includes Makefile.

    The platform target section from the old Makefile has been moved
    to a new file, Makefile.target.  Improved the format and comments
    in target information.

    The Makeifle includes the Makefile.target file.
    The cal/Makeifle includes the Makefile.target file.
    The cscript/Makeifle includes the Makefile.target file.
    The custom/Makeifle includes the Makefile.target file.
    The help/Makeifle includes the Makefile.target file.

    Now, the Makefile.target file will consistently set
    target information for all calc Makefiles.

    The cal/Makeifle includes the Makefile.local file.
    The cscript/Makeifle includes the Makefile.local file.
    The custom/Makeifle includes the Makefile.local file.
    The help/Makeifle includes the Makefile.local file.

    Thus, one may modify or append many Makefile variables
    in all calc Makefiles.

    Removed the ${CAL_PASSDOWN}, ${HELP_PASSDOWN}, ${HELP_PASSDOWN},
    ${CSCRIPT_PASSDOWN} Makefile variables as the new Makefile
    include files keep Makefile variables in sync.

    Fixed the ability of calc to compile when CUSTOM is undefined
    (i.e., -UCUSTOM).  The libcustcalc is always built, regardless
    of the $(ALLOW_CUSTOM} Makefile variable.  However when CUSTOM
    is undefined, the bulk of custom functions are not defined.

    Dropped the use of Makefile variable ${SET_INSTALL_NAME}.
    Under macOS it was always needed, elsewhere it was not.

    Added Makefile variable ${VER} to hold the calc major release version.
    The calc major release version is a 3 level version (x.y.z).

    Under macOS, the current version of both libcalc and libcustcalc
    shared libraries are set to the current calc major release version.

    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 "-dead_strip" by default.

    While calc on macOS will execute if linker used with "-dead_strip_dylibs"
    and CUSTOM is defined, other applications that use libcalc but not
    libcustcalc (such as sample_many and sample_rand) will fail to execute
    due to missile symbols.  Therefore "-dead_strip_dylibs" is not used
    by default when ALLOW_CUSTOM is "-DCUSTOM" under macOS.
    Thanks to GitHub user @TurtleWilly for bringing to our attention,
    problems related to use of  "-dead_strip_dylibs".

    When installing shared libraries, libcalc.x.y.z will be a link
    to the libcalc shared library and libcustcalc.x.y.z will be a link
    to the libcustcal shared library.
2023-08-14 18:32:28 -07:00
Landon Curt Noll
661e99829e prep CHANGES for the next release of calc 2023-08-14 18:25:46 -07:00
Landon Curt Noll
faf3a4fab6 fix macOS use of -dead_strip_dylibs, install major version lib symlinks.
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 "-dead_strip" by default.

While calc on macOS will execute if linker used with "-dead_strip_dylibs"
and CUSTOM is defined, other applications that use libcalc but not
libcustcalc (such as sample_many and sample_rand) will fail to execute
due to missile symbols.  Therefore "-dead_strip_dylibs" is not used
by default when ALLOW_CUSTOM is "-DCUSTOM" under macOS.
Thanks to GitHub user @TurtleWilly for bringing to our attention,
problems related to use of  "-dead_strip_dylibs".

When installing shared libraries, libcalc.x.y.z will be a link
to the libcalc shared library and libcustcalc.x.y.z will be a link
to the libcustcal shared library.
2023-08-14 17:40:29 -07:00
Landon Curt Noll
7d8d4cb5ea change macOS to not use "-dead_strip_dylibs" when CUSTOM is defined
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 "-dead_strip".

While calc on macOS will execute if linker used with "-dead_strip_dylibs"
and CUSTOM is defined, other applications that use libcalc but not
libcustcalc (such as sample_many and sample_rand) will fail to execute
due to missile symbols.  Therefore "-dead_strip_dylibs" is not used
by default when ALLOW_CUSTOM is "-DCUSTOM" under macOS.
2023-08-14 17:08:28 -07:00
Landon Curt Noll
af9b052fe9 fixed -dead_strip_dylibs for macOS, fixed macOS lib version numbers
Added Makefile variable ${VER} to holdthe calc major release version.
The calc major release version is a 3 level version (x.y.z).

Under macOS, the current version of both libcalc and
libcustcalc are set to the current calc major release version.

Under macOS, to reduce dependency chains, we remove functions and
data that are unreachable by the entry point or exported symbols.
In particular, the linker is run with "-dead_strip" and with
"-dead_strip_dylibs".
2023-08-14 15:27:22 -07:00
Landon Curt Noll
40f8654aa4 fix use of -dead_strip_dylibs for macOS linker 2023-08-14 14:58:22 -07:00
Landon Curt Noll
92c8d89ed1 cleanup Makefile comments 2023-08-14 05:02:48 -07:00
Landon Curt Noll
1e2d02e449 changed macOS to not use "-dead_strip_dylibs"
The macOS ld documentation states that option should not be used
when linking against a dylib which is required at runtime for some
indirect reason such as the dylib has an important initializer.
The libcustcalc appears to have such an initializer.
2023-08-14 04:28:59 -07:00
Landon Curt Noll
e0df1646fc add -dead_strip_dylibs by default to the macOS linker
Under macOS, to reduce dependency chains, we remove functions and
data that are unreachable by the entry point or exported symbols.
In particular, the linker is run with "-dead_strip" and with
"-dead_strip_dylibs".
2023-08-14 04:11:33 -07:00
Landon Curt Noll
ee900ec6ec improve macOS shared library building and use by calc
Dropped the use of Makefile variable ${SET_INSTALL_NAME}.
Under macOS it was always needed, elsewhere it was not.

Under macOS, the current version of both libcalc and
libcustcalc are set to the current calc release version.

Under macOS, to reduce dependency chains, we remove functions and
data that are unreachable by the entry point or exported symbols.
In particular, the linker is run with "-dead_strip".
2023-08-14 03:27:17 -07:00
Landon Curt Noll
6ee34e709d fix calc when CUSTOM is undefined, remove PASSDOWN values
Removed the ${CAL_PASSDOWN}, ${HELP_PASSDOWN}, ${HELP_PASSDOWN},
${CSCRIPT_PASSDOWN} Makefile variables as the new Makefile
include files keep Makefile variables in sync.

Fixed the ability of calc to compile when CUSTOM is undefined
(i.e., -UCUSTOM).  The libcustcalc is always built, regardless
of the $(ALLOW_CUSTOM} Makefile variable.  However when CUSTOM
is undefined, the bulk of custom functions are not defined.
2023-08-14 01:26:52 -07:00
Landon Curt Noll
f81d67b322 add missing edits to cscript/Makefile 2023-08-13 23:48:50 -07:00
Landon Curt Noll
21ab25d1c9 add Makefile.config, change all Makefile includes
Moved makefile variables that configure calc and configure how to
compile calc from Makefile into a new Makefile.config file.

The Makeifle includes the Makefile.config file.
The cal/Makeifle includes the Makefile.config file.
The cscript/Makeifle includes the Makefile.config file.
The custom/Makeifle includes the Makefile.config file.
The help/Makeifle includes the Makefile.config file.

Now, the Makefile.config file will consistently configure
calc and how calc is compiled and built by all calc Makefiles.

The platform target section from the old Makefile has been moved to
a new file, Makefile.target.  The custom/Makefile no longer includes
Makefile.

The Makeifle includes the Makefile.target file.
The cal/Makeifle includes the Makefile.target file.
The cscript/Makeifle includes the Makefile.target file.
The custom/Makeifle includes the Makefile.target file.
The help/Makeifle includes the Makefile.target file.

Now, the Makefile.target file will consistently set
target information for all calc Makefiles.

The cal/Makeifle includes the Makefile.local file.
The cscript/Makeifle includes the Makefile.local file.
The custom/Makeifle includes the Makefile.local file.
The help/Makeifle includes the Makefile.local file.

Thus, one may modify or append many Makefile variables
in all calc Makefiles.
2023-08-13 23:40:33 -07:00
Landon Curt Noll
06dcb3e51e Release v2.14.3.1
IMPORTANT: This is just a test release.  Please do not use.
2023-08-13 21:09:51 -07:00
Landon Curt Noll
6e0e48e17e fixed trailing blank in HOWTO.INSTALL 2023-08-13 21:04:28 -07:00
Landon Curt Noll
f416973a31 remove Makefile.simple and add Makefile.target
Dropped support of Makefile.simple and custom/Makefile.simple.
The calc version 2.14.3.0 is the last release that supported
the Makefile.simple and custom/Makefile.simple files.
Now, a make that supports makefile conditional syntax is required.

The platform target section from the old Makefile has been moved
to a new file, Makefile.target.  The Makefile.target is shared
by both Makefile and custom/Makefile.  The custom/Makefile no
longer includes Makefile (instead it includes ../Makefile.target).
2023-08-13 20:48:06 -07:00
Landon Curt Noll
b408b59d8d checkpoint on ALLOW_CUSTOM use
Updated comments in Makefile.local for how to Diagnosing memory,
thread, and crash issues under RHEL and macOS.

We no longer support the Makefile variable ${ALLOW_CUSTOM} to be empty.
Normally ${ALLOW_CUSTOM} is:

    ALLOW_CUSTOM= -DCUSTOM

Now, to disable custom disable custom even if -C is given, use:

    ALLOW_CUSTOM="-UCUSTOM"

Added comments in Makefile.local for how to reduce dependency chains
under macOS.  XXX - this doesn't yet work so don't uncomment - XXX.
2023-08-13 16:17:10 -07:00
Landon Curt Noll
77405e1d84 fix macOS comment to reduce dependency chains under macOS 2023-08-12 16:18:15 -07:00
Landon Curt Noll
da623e13cb add Makefile.local comments for macOS reduce dependency chains 2023-08-12 16:14:11 -07:00
Landon Curt Noll
f025dcf0d8 update comments in Makefile.local about using -fsanitize 2023-08-12 16:02:31 -07:00
Landon Curt Noll
3bfcaae767 fix typo in CHANGES 2023-08-12 00:41:21 -07:00
Landon Curt Noll
bf5b56d263 fixed install of statically linked calc under macOS
Improved .gitignore to ignore .static, calc-static,
sample_many-static and sample_rand-static.

Improved error messages when trying to compile with
with one calc type (when BLD_TYPE=calc-dynamic-only or
BLD_TYPE=calc-static-only) and install with the other.

When installing with BLD_TYPE=calc-static-only, the
installed calc and calc-static are links to each other.
Thanks to GitHub user @urtleWilly for this suggestion.

The dynamic shared libraries are not installed if they are not
built.  So when installing with BLD_TYPE=calc-static-only, the
install rule will not attempt to install dynamic shared libraries.
Thanks to GitHub user @urtleWilly for bringing to our attention,
problems related to building a statically linked calc under macOS.
2023-08-12 00:28:53 -07:00
Landon Curt Noll
0b044ce972 Fix typo in the make debug Makefile rule. 2023-08-03 14:11:35 -07:00
Landon Curt Noll
e2686911ae Release v2.14.3.0
The following are the changes in this release:

    Updated COPYING to include the actual text of "The Unlicense".
    Made minor formatting changes to the file.

    The Darwin specific ${DARWIN_ARCH}, thay by default was unset,
    is now the ${ARCH_CFLAGS} Makefile variable.  Comments about
    various "-arch name" have been moved to the ${ARCH_CFLAGS} area.

    For old Apple Power PC systems, the following is added:

	COMMON_CFLAGS+= -std=gnu99
	COMMON_LDFLAGS+= -std=gnu99
	ARCH_CFLAGS+= -arch ppc

    Old Apple Power PC systems should be detected by the
    "uname -p" command returning "powerpc".  One may force the
    Power PC mode by adding to the end of any make command:

	make ...make_args... target=Darwin arch=powerpc

    or by adding the following in the Makefile.local file:

	target= Darwin
	arch= powerpc

    Improved the output of the calcinfo rule by adding echos
    of various uname values as well as some top Makefile variables.

    Fixed the BUGS file with respect to using `make debug`.

    Added a final ls of `debug.out` for `make debug`.
2023-08-02 16:09:00 -07:00
Landon Curt Noll
544b873914 document changes to make debug 2023-08-02 15:29:23 -07:00
Landon Curt Noll
948d9e807b minor wording change about make debug 2023-08-02 01:12:11 -07:00
Landon Curt Noll
6d020b7fbe fix PowerPC detection under Darwin
Test if the arch value (`uname -p`) is "powerpc".

PowerPC based systems no longer try to use xcrun to determine where
things like INCDIR (include files) are located.
2023-08-02 00:40:53 -07:00
Landon Curt Noll
9fcdd80549 update fnv_tool.cal about no FNV primes for some sizes.
FNV primes for bit size powers of 2  > 1024 are extremely rare.
There are no FNV primes for bit size powers of 2 >= 2048 and <= 1048576.
2023-07-31 13:35:50 -07:00
Landon Curt Noll
3148ce06a0 improve how Apple Power PC systems compile, improve make calcinfo 2023-07-30 02:57:48 -07:00
Landon Curt Noll
945977f1f4 Updated COPYING to include the "The Unlicense" text. 2023-07-30 00:24:52 -07:00
Landon Curt Noll
b03e71f0ce Release v2.14.2.2
The following are the changes in this release:

    Removed references to obsolete Email addresses.

    macOS Darwin defaults LCC to "cc".
2023-07-28 21:33:59 -07:00
Landon Curt Noll
db799aac10 changed macOS Darwin to default LCC to "cc" 2023-07-28 21:19:02 -07:00
Landon Curt Noll
adecf7d76e Remove references to obsolete Email addresses. 2023-07-28 10:08:40 -07:00
Landon Curt Noll
94bf264088 minor speed change to fnv_tool.cal
Also note that 2^19 bits does not have a FNV prime.
2023-07-26 15:47:19 -07:00
Landon Curt Noll
80e841eded Release v2.14.2.1
The following are the changes in this release:

    Added cal/fnv_tool.cal, a calc resource file defining:

	find_fnv_prime(bits)
	deprecated_fnv0(bits,fnv_prime,string)
	fnv_offset_basis(bits,fnv_prime)
	fnv1a_style_hash(bits,fnv_prime,prev_hash,string)

    Fixed sorted order of cal/README.
2023-07-25 23:09:39 -07:00
Landon Curt Noll
3f78fc20d7 fix make picky errors found in cal/fnv_tool.cal 2023-07-25 23:06:11 -07:00
Landon Curt Noll
c26460b255 add cal/fnv_tool.cal
Added cal/fnv_tool.cal, a calc resource file defining:

    find_fnv_prime(bits)
    deprecated_fnv0(bits,fnv_prime,string)
    fnv_offset_basis(bits,fnv_prime)
    fnv1a_style_hash(bits,fnv_prime,prev_hash,string)

Fixed sorted order of cal/README.
2023-07-25 22:58:58 -07:00
Landon Curt Noll
3ec7b39366 Release v2.14.2.0
The following are the changes in this release:

    Ported calc to the s390x IBM Mainframe running RHEL9.1.

    Added cal/splitbits.cal:

	splitbits(x, b)

	Given an integer x, split the value into a list of integers,
	each of which is at most b bits long.

	The value b must be an integer > 0.

	The number of elements in the returned list is:

	    ceil((highbit(x) + 1) / b)

	If x == 0, then a list of 1 element containing 0 is returned.

	If x < 0, then the two's compliment of abs(x) is returned.
	Even though calc represents negative integers as positive values
	with sign bit, the bits returned by this function are as if
	the integer converted as if the integer was a two's compliment value.

	See also the help command:

	    ; help resource
2023-07-21 23:22:20 -07:00
Landon Curt Noll
49c599aec9 updated via git commit 2023-07-21 23:05:23 -07:00
Landon Curt Noll
a582511002 updated with make depend 2023-07-21 23:04:09 -07:00
Landon Curt Noll
e05d904821 add cal/splitbits.cal 2023-07-21 23:02:51 -07:00
Landon Curt Noll
ccd579ecda ported calc to the s390x IBM Mainframe running RHEL9.1 2023-07-21 22:38:17 -07:00
Landon Curt Noll
15be1dec4d fix typos from previous commit
TL;DR :-)
2023-07-20 16:48:06 -07:00
Landon Curt Noll
f34c659877 expand on top section of README.md
Added TL;DR section at the top along the lines of pull request #80.
We expanded it to include a number of other common systems.
2023-07-20 16:44:39 -07:00
Landon Curt Noll
2ad27e7909 Merge pull request #80 from john-peterson/patch-1
Print usage on top
2023-07-20 16:33:56 -07:00
John Sebastian Peterson
a4d3c8ff9d Print usage on top
It's common practice nowadays to out this on the very top

A text that can be copied to the terminal an "it just works"

Will bring many back to the roots of computers after over commercialisation of the over hyped "desktop experience" of the 90s
2023-07-20 06:35:10 +02:00
Landon Curt Noll
bd64a6cc36 Release v2.14.1.6
The following are the changes in this release:

    Fixed version numbers in two cases in CHANGES that referred
    to the 2.14.2.x instead of 2.14.1.x.

    Rename MINGW Makefile variable (a holdover from MINGW32_NT-5.0)
    to OSNAME.

    Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings.

    Fixed when USE_READLINE, READLINE_LIB, READLINE_EXTRAS, and
    READLINE_INCLUDE are set to empty (disable use of the GNU-readline
    facility).

    Fix cases of spaces before tabs in Makefile and Makefile.simple.

    Fixed obsolete references to the atoz() in LIBRARY to use the
    correct internal function name of str2z().

    Fixed obsolete references to the atoq() in LIBRARY to use the
    correct internal function name of str2q().

    Document in help/unexpected that * operator has has a higher
    precedence than << in calc, which differs from C.  Thanks
    goes to GitHub user @inguin for pointing put this difference.
2023-05-31 18:55:56 -07:00
Landon Curt Noll
e2b2976d18 document that * operator has has a higher precedence than << 2023-05-31 18:30:26 -07:00
Landon Curt Noll
3ea51ea937 Corrected LIBRARY to refer to str2z() and str2()
Fixed obsolete references to the atoz() in LIBRARY to use the
correct internal function name of str2z().

Fixed obsolete references to the atoq() in LIBRARY to use the
correct internal function name of str2q().
2023-05-31 18:22:09 -07:00
Landon Curt Noll
5fa732b869 Release v2.14.1.5
The following are the changes in this release:

    Fixed version numbers in two cases in CHANGES that referred
    to the 2.14.2.x instead of 2.14.1.x.

    Rename MINGW Makefile variable (a holdover from MINGW32_NT-5.0)
    to OSNAME.

    Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings.

    Fixed when USE_READLINE, READLINE_LIB, READLINE_EXTRAS, and
    READLINE_INCLUDE are set to empty (disable use of the GNU-readline
    facility).

    Fix cases of spaces before tabs in Makefile and Makefile.simple.
2023-03-12 20:52:45 -07:00
Landon Curt Noll
6a54caf1c2 Fixed when disabling use of the GNU-readline facility
Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings.

Fixed when USE_READLINE, READLINE_LIB, READLINE_EXTRAS, and
READLINE_INCLUDE are set to empty (disable use of the GNU-readline
facility).

Fix cases of spaces before tabs in Makefile and Makefile.simple.
2023-03-12 19:27:11 -07:00
Landon Curt Noll
cce930987b improve hist.c FUNCPTR type to use in arg 2023-03-12 18:16:36 -07:00
Landon Curt Noll
7c806f13ea Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings 2023-03-12 18:10:38 -07:00
Landon Curt Noll
616bcd8d46 rename MINGW to OSNAME in Makefile
Rename MINGW Makefile variable (a holdover from MINGW32_NT-5.0)
to OSNAME.

Fixed some incorrect version number comments in CHANGES.
2023-03-11 01:05:01 -08:00
Landon Curt Noll
36a1a042f3 fix warnings while forming builtin list 2023-03-06 04:17:31 -08:00
240 changed files with 27385 additions and 18044 deletions

109
.gitignore vendored
View File

@@ -1,31 +1,54 @@
# generic excluded patterns
#
# We sort the list below via: sort -u -f
#
*,v
*.BAK
*.dSYM/
*.exe
*.o.tmp
*.[oa]
*~
.*.swp
.DS_Store
core*
# files and directories created during the building of calc and other Makefile actions
#
# NOTE: While many of these might be part of a released calc tarball, they are
# not consider development source. Some other file(s) and/or programs
# generate these files.
#
# We sort the list below via: sort -u -f
#
.dynamic
.hsrc
Makefile.our
NOTES
.static
align32
align32.h
align32_tmp
arc4random_tmp
args.h
cal/.all
cal/test082.cal
calc
calc-static
calc.1
calc.spec
calc.usage
calcerr.c
calcerr.h
charbit.h
chatbit
chk_c
conf.h
const_tmp
cscript/.all
cscript/4dsphere
cscript/README
cscript/fproduct
cscript/mersenne
cscript/piforever
cscript/plus
cscript/powerterm
cscript/README
cscript/simple
cscript/square
custom/.all
@@ -33,42 +56,78 @@ custom/libcustcalc*
debug.out
endian
endian_calc.h
environ_tmp
errcode
errsym.h
fposval
fposval.h
fposval_tmp
fpos_tmp
func.show
func.sort
getpgid_tmp
getprid_tmp
getsid_tmp
gettime_tmp
have_arc4random
have_arc4random.h
have_ban_pragma
have_ban_pragma.h
have_const
have_const.h
have_environ
have_environ.h
have_fgetsetpos.h
have_fpos
have_fpos_pos
have_fpos_pos.h
have_getpgid
have_getpgid.h
have_getprid
have_getprid.h
have_getsid
have_getsid.h
have_gettime
have_gettime.h
have_inttypes.h
have_limits.h
have_memmv
have_memmv.h
have_newstr
have_newstr.h
have_offscl
have_offscl.h
have_posscl
have_posscl.h
have_rusage
have_rusage.h
have_statfs
have_statfs.h
have_stdbool.h
have_stdint.h
have_stdlib.h
have_stdvs
have_strdup
have_strdup.h
have_string.h
have_strlcat
have_strlcat.h
have_strlcpy
have_strlcpy.h
have_sys_mount.h
have_sys_param.h
have_sys_vfs.h
have_times.h
have_uid_t
have_uid_t.h
have_unistd.h
have_unused
have_unused.h
have_urandom.h
have_ustat
have_ustat.h
have_varvs
help/.all
help/COPYING
help/COPYING-LGPL
help/binding
help/bindings
help/bug
@@ -78,6 +137,8 @@ help/change
help/changes
help/contrib
help/copy
help/COPYING
help/COPYING-LGPL
help/cscript
help/custom_cal
help/errorcode
@@ -85,6 +146,7 @@ help/errorcodes
help/full
help/funclist
help/funclist.c
help/ilogn
help/libcalc
help/man
help/new_custom
@@ -94,24 +156,31 @@ help/releases
help/resource
help/type
help/usage
libcalc*
libcustcalc*
libcalc.*
libcustcalc.*
ll_tmp
longbits
longbits.h
Makefile.our
memmv_tmp
newstr_tmp
NOTES
offscl_tmp
outfile
posscl_tmp
rusage_tmp
sample_many
sample_many-static
sample_rand
sample_rand-static
statfs_tmp
status.chk_c.h
strdup_tmp
tags
terminal.h
uid_tmp
unused_tmp
ustat_tmp
ver_calc
vs_tmp
win32/
# other commonly excluded patterns
#
*~
*.BAK
core*
.DS_Store
*.dSYM/
*.[oa]
.*.swp
*,v

23
.lldbinit Normal file
View File

@@ -0,0 +1,23 @@
#
# lldb calc
#
# IMPORTANT: Under macOS, use this local ./lldbinit file, your home directory file:
#
# ~/.lldbinit
#
# must contain this line (w/o the leading # and whitespace):
#
# settings set target.load-cwd-lldbinit true
#
# Optimizing calc may make it harder to trace what calc is doing,
# To turn off optimization while debugging, try:
#
# make clobber all DEBUG="-g3"
#
# To debug calc with lldb from this directory, just run:
#
# lldb
#
target create "./calc"
process launch -tty --environment CALCPATH=./cal --environment LD_LIBRARY_PATH=. --environment DYLD_LIBRARY_PATH=. --environment CALCHELP=./help --environment CALCCUSTOMHELP=./custom -- -q -d
b main

2
BUGS
View File

@@ -88,7 +88,7 @@ Please include the following information in the new issue:
* cd to the calc source directory, and send the contents
of debug.out.txt produced by this command:
make debug > debug.out.txt 2>&1
make debug
PLEASE attach the debug.out.txt file to your GitHub issue (bug report)!!

671
CHANGES
View File

@@ -1,4 +1,653 @@
The following are the changes from calc version 2.14.2.3 to date:
The following are the changes from calc version 2.14.3.5 to 2.15.0.0:
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).
The following are the changes from calc version 2.14.3.0 to 2.14.3.4:
Fix typo in the `make debug` Makefile rule.
Improved .gitignore to ignore .static, calc-static,
sample_many-static and sample_rand-static.
Improved error messages when trying to compile with
with one calc type (when BLD_TYPE=calc-dynamic-only or
BLD_TYPE=calc-static-only) and install with the other.
When installing with BLD_TYPE=calc-static-only, the
installed calc and calc-static are links to each other.
Thanks to GitHub user @TurtleWilly for this suggestion.
The dynamic shared libraries are not installed if they are not
built. So when installing with BLD_TYPE=calc-static-only, the
install rule will not attempt to install dynamic shared libraries.
Thanks to GitHub user @TurtleWilly for bringing to our attention,
problems related to building a statically linked calc under macOS.
Updated comments in Makefile.local for how to Diagnosing memory,
thread, and crash issues under RHEL and macOS.
We no longer support the Makefile variable ${ALLOW_CUSTOM} to be empty.
Normally ${ALLOW_CUSTOM} is:
ALLOW_CUSTOM= -DCUSTOM
Now, to disable custom disable custom even if -C is given, use:
ALLOW_CUSTOM="-UCUSTOM"
Dropped support of Makefile.simple and custom/Makefile.simple.
The calc version 2.14.3.0 is the last release that supported
the Makefile.simple and custom/Makefile.simple files.
Now, a make that supports makefile conditional syntax is required.
The simple target, a target that only was used for Makefile.simple
was removed.
Moved makefile variables that configure calc and configure how to
compile calc from Makefile into a new Makefile.config file.
The Makeifle includes the Makefile.config file.
The cal/Makeifle includes the Makefile.config file.
The cscript/Makeifle includes the Makefile.config file.
The custom/Makeifle includes the Makefile.config file.
The help/Makeifle includes the Makefile.config file.
Now, the Makefile.config file will consistently configure
calc and how calc is compiled and built by all calc Makefiles.
The custom/Makefile no longer includes Makefile.
The platform target section from the old Makefile has been moved
to a new file, Makefile.target. Improved the format and comments
in target information.
The Makeifle includes the Makefile.target file.
The cal/Makeifle includes the Makefile.target file.
The cscript/Makeifle includes the Makefile.target file.
The custom/Makeifle includes the Makefile.target file.
The help/Makeifle includes the Makefile.target file.
Now, the Makefile.target file will consistently set
target information for all calc Makefiles.
The cal/Makeifle includes the Makefile.local file.
The cscript/Makeifle includes the Makefile.local file.
The custom/Makeifle includes the Makefile.local file.
The help/Makeifle includes the Makefile.local file.
Thus, one may modify or append many Makefile variables
in all calc Makefiles.
Removed the ${CAL_PASSDOWN}, ${HELP_PASSDOWN}, ${HELP_PASSDOWN},
${CSCRIPT_PASSDOWN} Makefile variables as the new Makefile
include files keep Makefile variables in sync.
Fixed the ability of calc to compile when CUSTOM is undefined
(i.e., -UCUSTOM). The libcustcalc is always built, regardless
of the $(ALLOW_CUSTOM} Makefile variable. However when CUSTOM
is undefined, the bulk of custom functions are not defined.
Dropped the use of Makefile variable ${SET_INSTALL_NAME}.
Under macOS it was always needed, elsewhere it was not.
Added Makefile variable ${VER} to hold the calc major release version.
The calc major release version is a 3 level version (x.y.z).
Under macOS, the current version of both libcalc and libcustcalc
shared libraries are set to the current calc major release version.
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 "-dead_strip" by default.
While calc on macOS will execute if linker used with "-dead_strip_dylibs"
and CUSTOM is defined, other applications that use libcalc but not
libcustcalc (such as sample_many and sample_rand) will fail to execute
due to missile symbols. Therefore "-dead_strip_dylibs" is not used
by default when ALLOW_CUSTOM is "-DCUSTOM" under macOS.
Thanks to GitHub user @TurtleWilly for bringing to our attention,
problems related to use of "-dead_strip_dylibs".
When installing shared libraries, libcalc.x.y.z will be a link
to the libcalc shared library and libcustcalc.x.y.z will be a link
to the libcustcal shared library.
The following are the changes from calc version 2.14.2.1 to 2.14.3.0:
Added cal/fnv_tool.cal, a calc resource file defining:
find_fnv_prime(bits)
deprecated_fnv0(bits,fnv_prime,string)
fnv_offset_basis(bits,fnv_prime)
fnv1a_style_hash(bits,fnv_prime,prev_hash,string)
Fixed sorted order of cal/README.
Removed references to obsolete Email addresses.
macOS Darwin defaults LCC to "cc".
Updated COPYING to include the actual text of "The Unlicense".
Made minor formatting changes to the file.
The Darwin specific ${DARWIN_ARCH}, thay by default was unset,
is now the ${ARCH_CFLAGS} Makefile variable. Comments about
various "-arch name" have been moved to the ${ARCH_CFLAGS} area.
For old Apple Power PC systems, the following is added:
COMMON_CFLAGS+= -std=gnu99
COMMON_LDFLAGS+= -std=gnu99
ARCH_CFLAGS+= -arch ppc
Old Apple Power PC systems should be detected by the
"uname -p" command returning "powerpc". One may force the
Power PC mode by adding to the end of any make command:
make ...make_args... target=Darwin arch=powerpc
or by adding the following in the Makefile.local file:
target= Darwin
arch= powerpc
Improved the output of the calcinfo rule by adding echos
of various uname values as well as some top Makefile variables.
Fixed the BUGS file with respect to using `make debug`.
Added a final ls of `debug.out` for `make debug`.
The following are the changes from calc version 2.14.2.0 to 2.14.2.0:
Ported calc to the s390x IBM Mainframe running RHEL9.1.
Added cal/splitbits.cal:
splitbits(x, b)
Given an integer x, split the value into a list of integers,
each of which is at most b bits long.
The value b must be an integer > 0.
The number of elements in the returned list is:
ceil((highbit(x) + 1) / b)
If x == 0, then a list of 1 element containing 0 is returned.
If x < 0, then the two's compliment of abs(x) is returned.
Even though calc represents negative integers as positive values
with sign bit, the bits returned by this function are as if
the integer converted as if the integer was a two's compliment value.
See also the help command:
; help resource
The following are the changes from calc version 2.14.1.5 to 2.14.1.6:
Fixed version numbers in two cases in CHANGES that referred
to the 2.14.2.x instead of 2.14.1.x.
Rename MINGW Makefile variable (a holdover from MINGW32_NT-5.0)
to OSNAME.
Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings.
Fixed when USE_READLINE, READLINE_LIB, READLINE_EXTRAS, and
READLINE_INCLUDE are set to empty (disable use of the GNU-readline
facility).
Fix cases of spaces before tabs in Makefile and Makefile.simple.
Fixed obsolete references to the atoz() in LIBRARY to use the
correct internal function name of str2z().
Fixed obsolete references to the atoq() in LIBRARY to use the
correct internal function name of str2q().
Document in help/unexpected that * operator has has a higher
precedence than << in calc, which differs from C. Thanks
goes to GitHub user @inguin for pointing put this difference.
The following are the changes from calc version 2.14.1.3 to 2.14.1.4:
Fixed missing <string.h include in have_fpos_pos.c.
@@ -78,7 +727,7 @@ The following are the changes from calc version 2.14.2.3 to date:
the Makefile dependency list via "make depend".
The following are the changes from calc version 2.14.2.0 to 2.14.1.2:
The following are the changes from calc version 2.14.1.0 to 2.14.1.2:
Attempted to address a paranoid compiler warning -Wmaybe-uninitialized
in swap_HALF_in_ZVALUE() where the gcc compiler seems to ignore the
@@ -588,7 +1237,7 @@ The following are the changes from calc version 2.14.0.9 to 2.14.0.10:
Remove unnecessary spaces in-between or next to tabs.
Update Copyright dates to account for 2021 modifications.
Update copyright dates to account for 2021 modifications.
The following are the changes from calc version 2.14.0.7 to 2.14.0.8:
@@ -1536,9 +2185,9 @@ The following are the changes from calc version 2.12.5.0 to 2.12.5.1:
There is a new calc bug report Email address:
calc-bug-report at asthe dot com
NOTE: calc-bug-report Email address no longer in use
This replaces the old calc-bugs at asthe dot com address.
This replaces the old calc-bugs Email address.
To be sure we see your Email reporting a calc bug, please use the
following phase in your Email Subject line:
@@ -2132,7 +2781,7 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
NOTE: If your target is not supported below and the default target
is not suitable for your needs, please send to the:
calc-contrib at asthe dot com
NOTE: calc-contrib Email address no longer in use
Email address an "ifeq ($(target),YOUR_TARGET_NAME)"
... "endif" set of lines from the Makefile so that
@@ -2779,7 +3428,7 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
Added a "make uninstall" rule which will attempt to remove everything
that was installed by a "make install".
Changed the "Copyright" line in the rpm spec file to a "License" line
Changed the copyright line in the rpm spec file to a "License" line
as per new rpm v4.4 syntax.
The quomod() builtin function does not allow constants for its 3rd
@@ -3855,9 +4504,9 @@ The following are the changes from calc version 2.11.2t0 to 2.11.2t1.0:
www.isthe.com. NOTE: The Email address uses 'asthe' and the web
site URL uses 'isthe'.
Using calc-bugs at asthe dot com for calc bug reports,
calc-contrib at asthe dot com for calc contributions,
calc-tester-request at asthe dot com for requests to join calc-tester and
NOTE: calc-bugs Email address no longer in use
NOTE: calc-contrib Email address no longer in use
NOTE: calc-tester-request Email address no longer in use
Replaced explicit Email addresses found this file with the <user at
site dot domain> notation to reduce the potential for those folks
@@ -8597,7 +9246,7 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
A small bug in the library file regress.cal was fixed.
## Copyright (C) 2001-2017,2021,2022 Landon Curt Noll
## Copyright (C) 2001-2017,2021-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

40
COPYING
View File

@@ -1,6 +1,5 @@
calc - arbitrary precision calculator
This file is Copyrighted
------------------------
@@ -76,8 +75,8 @@ Calc's relationship to the GNU Lesser General Public License
Clearly all files that go into the creation of those binary link
libraries are covered under the License.
The ``scripts used to control compilation and installation of the
of the library'' include:
The "scripts used to control compilation and installation of the
of the library" include:
* Makefiles
* source files created by the Makefiles
@@ -85,7 +84,7 @@ Calc's relationship to the GNU Lesser General Public License
All of those files are covered under the License.
The ``associated interface definition files'' are those files that:
The "associated interface definition files" are those files that:
* show how the calc binary link libraries are used
* test the validity of the binary link libraries
@@ -100,9 +99,9 @@ Calc's relationship to the GNU Lesser General Public License
* files under the lib sub-directory
* the main calc.c file
The ``complete source code'' includes ALL files shipped with calc,
except for the exception files explicitly listed in the ``Calc
copyrights and exception files'' section below.
The "complete source code" includes ALL files shipped with calc,
except for the exception files explicitly listed in the "Calc
copyrights and exception files" section below.
-=-
@@ -146,9 +145,32 @@ Calc copyrights and exception files
cal/dotest.cal
cal/screen.cal
For more information on this license, see:
"The Unlicense" is as follows:
https://unlicense.org
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
In all cases one may use and distribute these exception files freely.
And because one may freely distribute the LGPL covered files, the

View File

@@ -1,495 +1,390 @@
# Installing a pre-compiled calc from an RPM
IMPORTANT: Please see the section at the bottom of this file for
some important information on Makefiles used in calc.
If your platform supports RPMs, you may want to go to:
###################################################################
# IMPORTANT: DO NOT use make in parallel mode!!! #
###################################################################
# Unfortunately due to the complex dependency issues between #
# Makefile, Makefile.ship and custom/Makefile, parallel make #
# is NOT recommended. Sorry (tm Canada) :) #
###################################################################
https://github.com/lcn2/calc/releases
Installing calc from the bzip2-ed tarball: 4 easy steps:
and see if there is a pre-compiled version of calc that you may install.
(0) If your platform supports i686 RPMs, you may want to go to:
Open up the 'Assets' tag below a given release and download these RPMs:
https://github.com/lcn2/calc/releases
* calc*.rpm
Open up the 'Assets' tag below a given release and
download these RPMs:
- all that is needed if you just want to use calc
* calc*.i686.rpm
- all that is needed if you just want to use calc
If your platform supports rpm and matches one of the "calc*.rpm" files, you
may just install that "calc*.rpm". For exammple on an x86_64 system:
* calc-devel-*.i686.rpm
- calc *.h header and *.a lib files for use in other programs
dnf install calc-x.y.z.cv-ww.x86_64.rpm
* calc.*.src.rpm
- calc source via a SRPM package
where "calc-x.y.z.cv-ww.x86_64.rpm" is the name of the calc RPM.
Alternately to the above github link, you might try looking at
the RPMs under:
In addition, if your platform supports rpm and matches one of the
"calc*.rpm" files, you may also install the calc *.h header and *.a lib
files for use in other programs:
http://www.isthe.com/chongo/src/calc/
* calc-devel-*.rpm
=-=
- calc *.h header and *.a lib files for use in other programs
The following 4 steps apply to calc source tree that comes from either:
Alternately to the above github link, you might try looking at the RPMs under:
bunzip2 -c calc-*.tar.bz2 | tar -xvf -
http://www.isthe.com/chongo/src/calc/
or from:
rpm -ivh calc-*.src.rpm
cd /var/tmp
bunzip2 -c /usr/src/redhat/SOURCES/calc-*.tar.bz2 | tar -xvf -
4 steps:
(1) Look at the makefile, and adjust it to suit your needs.
The top level Makefile and the custom/Makefile require a modern
Make (such as gmake) or an equivalently advanced make. On many
targets, the default make is sufficient. On FreeBSD for example,
probably want to use gmake instead of make.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! By default, calc assumes you have the readline package installed !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! macOS does not have readline, so mac users need to make a choice !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
The readline package (-lreadline, -lhistory, -lncurses) used by and
linked into calc by default. If your system does NOT have those
libaraies, then you have two options:
(1-with readline) Install the readline package <- Recommended
Install the readline package first, then compile calc.
For information on the readline package, see:
https://tiswww.case.edu/php/chet/readline/rltop.html
MacOS users can use MacPorts or HomeBrew to install readline:
https://www.macports.org
https://brew.sh
Or compile from the readline.git repo:
http://git.savannah.gnu.org/cgit/readline.git/
(1-w/o readline) Compile calc without readline (not recommended)
Why do we not recommend (1b)? Because using calc with readline
provides a beter user experience.
If you feel you must use calc without the readline package, then you
will need to change your calc Makefile with this patch:
--- Makefile.old 2021-12-29 14:57:56.000000000 -0800
+++ Makefile 2021-12-29 14:59:13.000000000 -0800
@@ -1140,14 +1140,14 @@
#
# If in doubt, set USE_READLINE, READLINE_LIB and READLINE_INCLUDE to nothing.
#
-#USE_READLINE=
-USE_READLINE= -DUSE_READLINE
+USE_READLINE=
+#USE_READLINE= -DUSE_READLINE
#
-#READLINE_LIB=
-#READLINE_EXTRAS=
+READLINE_LIB=
+READLINE_EXTRAS=
#
-READLINE_LIB= -lreadline
-READLINE_EXTRAS= -lhistory -lncurses
+#READLINE_LIB= -lreadline
+#READLINE_EXTRAS= -lhistory -lncurses
#
#READLINE_LIB= -L/usr/gnu/lib -lreadline
#READLINE_EXTRAS= -lhistory -lncurses
@@ -1181,8 +1181,8 @@
# # and using the readline, history, and ncurses libraries.
# #
ifneq ($(HOMEBREW_PREFIX),)
-READLINE_LIB:= -L${HOMEBREW_PREFIX}/opt/readline/lib -lreadline
-READLINE_INCLUDE:= -I${HOMEBREW_PREFIX}/opt/readline/include
+#READLINE_LIB:= -L${HOMEBREW_PREFIX}/opt/readline/lib -lreadline
+#READLINE_INCLUDE:= -I${HOMEBREW_PREFIX}/opt/readline/include
endif
#
#endif /* end of skip for non-Gnu makefiles */
If your target system does not have a modern Makefile
(such as gmake), then you will need to change your
Makefile.simple with this patch:
--- Makefile.simple.orig 2021-12-29 15:00:53.000000000 -0800
+++ Makefile.simple 2021-12-29 15:01:00.000000000 -0800
@@ -1005,14 +1005,14 @@
#
# If in doubt, set USE_READLINE, READLINE_LIB and READLINE_INCLUDE to nothing.
#
-#USE_READLINE=
-USE_READLINE= -DUSE_READLINE
+USE_READLINE=
+#USE_READLINE= -DUSE_READLINE
#
-#READLINE_LIB=
-#READLINE_EXTRAS=
+READLINE_LIB=
+READLINE_EXTRAS=
#
-READLINE_LIB= -lreadline
-READLINE_EXTRAS= -lhistory -lncurses
+#READLINE_LIB= -lreadline
+#READLINE_EXTRAS= -lhistory -lncurses
#
#READLINE_LIB= -L/usr/gnu/lib -lreadline
#READLINE_EXTRAS= -lhistory -lncurses
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! By default, calc assumes you are using a modern gnu-like make tool !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
If your target system does not have a modern Makefile (such as gmake),
then you should try using the Makefile.simple and custom/Makefile.simple
files:
mv Makefile Makefile.gmake
cp Makefile.simple Makefile
mv custom/Makefile custom/Makefile.gmake
cp custom/Makefile.simple custom/Makefile
The Makefile, as shipped, is suitable for installation under
Linux and Un*x-like environments. For the most part, the default
values should work. If in doubt, follow the 'When in doubt'
suggestion.
If you are using a modern make (such as gmake), you may override
any values set in the Makefile by adding them to Makefile.local
using the := directive. For example:
HAVE_STRING_H:= YES
HAVE_TIMES_H:= YES
SED:= /usr/local/bin/nsed
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! If you are building under Windows or a Windows-like environment !
! (such as Cygwin or DJGPP), read the README.WINDOWS file. !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
You should determine if these Makefile variables are reasonable:
INCDIR Where the system include (.h) files are kept.
BINDIR Where to install calc binary files.
LIBDIR Where to install calc link library (*.a) files.
CALC_SHAREDIR Where to install calc help, .cal, startup, and
config files.
You may want to change the default installation locations for
these values, which are based on the 4 values listed above:
HELPDIR where the help directory is installed
CALC_INCDIR where the calc include files are installed
CUSTOMCALDIR where custom *.cal files are installed
CUSTOMHELPDIR where custom help files are installed
CUSTOMINCDIR where custom .h files are installed
SCRIPTDIR where calc shell scripts are installed
If you want to install calc files under a top level directory,
then set the T value:
The calc install is performed under ${T}, the calc build is
performed under /. The purpose for ${T} is to allow someone
to install calc somewhere other than into the system area.
For example, if:
BINDIR= /usr/bin
LIBDIR= /usr/lib
CALC_SHAREDIR= /usr/share/calc
and if:
# Building calc from a source tree
T= /var/tmp/testing
Then the installation locations will be:
calc binary files: /var/tmp/testing/usr/bin
calc link library: /var/tmp/testing/usr/lib
calc help, .cal ...: /var/tmp/testing/usr/share/calc
... etc ... /var/tmp/testing/...
## Step 0: Obtain the calc source tree
If ${T} is empty, calc is installed under /, which is the same
top of tree for which it was built. If ${T} is non-empty, then
calc is installed under ${T}, as if one had to chroot under
${T} for calc to operate.
Go to the site:
Look for the section that starts:
https://github.com/lcn2/calc/releases
################
# compiler set #
################
Look for release with a file of the form:
Select a compiler set by commenting in the appropriate set
of cc options. As shipped the Makefile assumes a gcc-like
environment such as Linux. If a more appropriate cc set if
found below, comment out the Linux set and comment in that
set or edit the gcc set or the common cc set as needed.
calc-x.y.z.v.tar.bz2
You may want to change these Makefile variables from their defaults:
A release marked with a green "(Latest)" is a production release
that as undergone a fair amount of testing.
RANLIB
A release marked with an orange "(Pre-release)" is likly to be
more stable than the top of the master branch, as they do undergo
thru a reasonable level of regression testing, just not to
the level of a "(Latest)" production release.
You may or may not need RANLIB when building libraries.
As shipped the Makefile assumes RANLIB is needed.
Comment the in/out the RANLIB value if ranlib does
not work or does not exist.
Use the followig command to uncompress the bzip2 compressed tarball:
CALCPAGER
bunzip2 -c calc-*.tar.bz2 | tar -xvf -
You may want to change the default pager used by calc.
As shipped the Makefile assumes 'more'. On your system
you may find 'less' to be a better pager.
NOTE: An alternate location for calc bzip2 compressed tarballs is:
DEBUG
http://www.isthe.com/chongo/src/calc/
Some compilers (to put it mildly) have bugs. Sometimes the
DEBUG Makefile variable causes the compiler / optimizer to
produce bad code. Other compilers do just fine.
If possible try to use DEBUG=-O3 -g3 (maximum optimization
and debug symbols). If the calc test fails (see step 3),
try lowering either the -O value and/or the -g3. Also try
using -Osomething without -g.
Adjust other Makefile variables as needed.
### Obtaining the experimental top of the master branch calc source
(2) build calc:
You may also fetch the top of the master branch of the GitHub repo
if you wish to see what the latest source code looks like:
The top level Makefile and the custom/Makefile require a GNU
Make (such as gmake) or an equivalently advanced make. On many
targets, the default make is sufficient. On FreeBSD for example,
one must use gmake instead of make.
git clone https://github.com/lcn2/calc.git
If your target system does not have GNU Make (or equivalent), then
you should try using the Makefile.simple and custom/Makefile.simple
files:
IMPORTANT:
mv Makefile Makefile.gmake
cp Makefile.simple Makefile
mv custom/Makefile custom/Makefile.gmake
cp custom/Makefile.simple custom/Makefile
The latest source code may be "experimental in nature". You may be
better off using a released bzip2 compressed tarball instead.
Released bzip2 compressed tarballs tend to be more well tested
than the top of the master branch.
make all
==> We are interested in any compiler warnings (and errors) that
you may find. See the BUGS file if you find any compiler
warning or errors.
NOTE: You can force calc to build with only static libs:
## Step 1: Makefile considerations
make clobber
make calc-static-only BLD_TYPE=calc-static-only
or force calc to build with only dynamic libs:
### IMPORTANT: Make support of conditional syntax required:
make clobber
make calc-dynamic-only BLD_TYPE=calc-dynamic-only
To compile calc, you must use a make that supports the use of
"Conditional syntax". As nearly all modern make tools
support "Conditional syntax", thus should not be a problem
for you. If for some reason your make tool does not support
"Conditional syntax", consider upgraded to a make that does,
such as the Gnu Make tool:
(3) test calc:
https://www.gnu.org/software/make/
make check
The Gnu Make is not required per-se, just a modern make tool
that supports "Conditional syntax".
NOTE: For a quiet check which only prints if something goes wrong:
make chk
### Review Makefiles
(4) install calc:
Review Makefile.config and Makefile.target.
make install
If you are curious, review Makefile as well, although
there may be little in the main Makefile that you may
want to change.
Consider modifying Makefile.local by replace values or
appending values found in Makefile.config and Makefile.target.
If you are adding custom functions, review custom/Makefile
and modify custom/Makefile as needed.
### Suggestion: Modify Makefile.local
All Makefiles include Makefile.local just before the
first and default all rule. So Makefile.local may be
used to modify, replace or append values to Makefile variables.
In most cases, to change the way that calc is made, consider
adding lines to Makefile.local instead of modifying other Makefiles.
A recommended way to adjust it is to add lines to: Makefile.local
using the := syntax to replace values such as:
DEBUG:= -O0 -g
or by using the += syntax to append to values such as:
DEBUG+= -ipa
You can, of course, modify other Makefiles. We only
suggest using Makefile.local to minimize the number
of source files you modify.
And finally, you can always just add arguments to your
make command line instead of modifying a Makefile. For example:
make clobber all DEBUG="-O0 -g"
## readline package assumed by default:
By "readline package" we refer to the combination of the
readline library, the history library, and the ncurses library.
By default, calc assumes you have the readline package installed.
The readline package (-lreadline, -lhistory, -lncurses) used by and
linked into calc by default.
If your system (such as macOS) does NOT have those libaraies, then
you have two options:
### Install the readline package:
We recommend that you install the readline package first, then compile calc.
For information on the readline package, see:
https://tiswww.case.edu/php/chet/readline/rltop.html
MacOS users can use MacPorts or HomeBrew to install readline:
https://www.macports.org
https://brew.sh
Or compile from the readline.git repo:
http://git.savannah.gnu.org/cgit/readline.git/
### Compile calc without readline:
Why do we not recommend this option because using calc with readline
provides a beter user experience.
If you feel you must use calc without the readline package, then you
will need to compile with:
make clobber all USE_READLINE= READLINE_EXTRAS= READLINE_INCLUDE= READLINE_LIB=
or add to Makefile.local, these lines:
USE_READLINE=
READLINE_EXTRAS=
READLINE_INCLUDE=
READLINE_LIB=
See the "Suggestion: Modify Makefile.local" section above for
information on the Makefile.local file.
### Windows or a Windows-like environments:
Currently Windows is not a well supported platform for calc. There are
people within Microsoft who plan to assist us in being able to allow
the standard Microsoft Windows developor environment to compile calc.
### Makefile variables to consider:
You should determine if these Makefile variables are reasonable:
INCDIR Where the system include (.h) files are kept.
BINDIR Where to install calc binary files.
LIBDIR Where to install calc link library (*.a) files.
CALC_SHAREDIR Where to install calc help, .cal, startup, and config files.
You may want to change the default installation locations for
these values, which are based on the 4 values listed above:
HELPDIR where the help directory is installed
CALC_INCDIR where the calc include files are installed
CUSTOMCALDIR where custom *.cal files are installed
CUSTOMHELPDIR where custom help files are installed
CUSTOMINCDIR where custom .h files are installed
SCRIPTDIR where calc shell scripts are installed
If you want to install calc files under a top level directory, then set the T value:
The calc install is performed under ${T}, the calc build is
performed under /. The purpose for ${T} is to allow someone
to install calc somewhere other than into the system area.
For example, if:
BINDIR= /usr/bin
LIBDIR= /usr/lib
CALC_SHAREDIR= /usr/share/calc
and if:
T= /var/tmp/testing
Then the installation locations will be:
calc binary files: /var/tmp/testing/usr/bin
calc link library: /var/tmp/testing/usr/lib
calc help, .cal ...: /var/tmp/testing/usr/share/calc
... etc ... /var/tmp/testing/...
If ${T} is empty, calc is installed under /, which is the same
top of tree for which it was built. If ${T} is non-empty, then
calc is installed under ${T}, as if one had to chroot under
${T} for calc to operate.
Again, consider adding replacement lines or append linbes to
the Makefile.local file. See "Suggestion Modify Makefile.local
instead of Makefile" above. For example:
T:= /var/tmp/testing
See the "Suggestion: Modify Makefile.local" section above for
information on the Makefile.local file.
### platform target section
The file, Makefile.target, contains information about various platforms.
The current list of targets in Makefile.target are:
- Linux target
- Apple macOS / Darwin target
- FreeBSD target
- OpenBSD target
- Cygwin target (as well as Msys2 / Msys OSNAME)
- simple target
- default target (when target is empty)
If you wish to modiy your target platform, consider doing
so via the Makefile.local file. See "Suggestion Modify Makefile.local
instead of Makefile" above.
## Step 2: compile calc
Remove any previous compile attempts and compile by default:
make clobber all
### Force calc to build with only static libs:
You may force calc to build with only static libs:
make clobber calc-static-only BLD_TYPE=calc-static-only
### Force calc to build with only dynamic shared libs:
You may force calc to build with only dynamic libs:
make clobber calc-dynamic-only BLD_TYPE=calc-dynamic-only
### Reports of compiler warnings (and errors) as welcome
We are interested learning about any compiler warnings (and errors) that you may find.
See the BUGS file if you find any compiler warning or errors.
### Step 3: test calc
You may run the calc regression test suite, after successfully compiling, by:
make check
For a more quiet check which only prints if something goes wrong, use:
make chk
### Step 4: install calc
Depending on permissions, you may need to become the super-user:
sudo -s
before you install:
make install
### Step n: calc help - getting started
Calc is distributed with an extensive collection of help files that
are accessible from the command line. The following assume that you
are running calc from the distribution directory or that you have
installed calc. In these examples, the "; " is the calc prompt, not
something that you type.
For list of help topics:
; help
For overview of calc overview:
; help intro
; help overview
; help command
; help define
; help statement
; help variable
; help usage
For list of builtin functions:
; help builtin
C programmers should note some unexpected differences with the calc syntax:
; help unexpected
Calc is shipped with a standard collection of calc resource files.
For a list of calc standard resource files see:
; help resource
We suggest that you might want to read the README.FIRST file and look at
the calc help subsystem. See also the README.md file.
In general, if you run into problems, read the BUGS file and follow
the instructions.
In general, if you run into problems, read the BUGS file and follow the instructions.
=-=
# IMPORTANT: parallel make not supported
On calc Makefiles:
We do not support making calc using a parallel make as most parallel
make systems fail to understand the depedency relationships between
a numner of important make rules and thus fail to properly compile calc.
How to tell the origin of of a Makefile:
The "# SRC: ... - ..." comment line near the top
of the file indicates the origin of this file.
In each segment below, we indicate what the SRC
comment like will read.
SHELL= ...
On some systems, /bin/sh is a rather reduced shell with
deprecated behavior.
If your system has a up to date, bash shell, then
you may wish to edit the Makefile to use:
SHELL= /bin/bash
On some systems such as macOS, the bash shell is very
far behind to the point where is cannot be depended on.
On such systems, the sh may be a much better alternative
shell for this Makefile to use:
SHELL= /bin/sh
Makefile.local
# SRC: Makefile.local - tweaks to the top level Makefile
Between releases, Makefile.local at the top of the master branch
will contain how we typically build calc and test calc (FYI: we
normally enable things such as -Werror -Wextra -pedantic). When we
push out a release, Makefile.local will be stripped of non-comment
lines. Thus, releases of calc, and, released "calc*.src.rpm"
files and the source tarballs, will have a Makefile.local with
only comments.
If the Makefile is not suitable for you (say because you fetch it
from the top of the master branch between releases), then you may
wish to remove all non-comment lines. I.e., lines that do not start
with the # character.
This Makefile.local assumes you have a modern make command such as
the GNU make. See Makefile.simple comment below if you do not
have such a modern make command.
In the calc GitHub repo, Makefile is the calc build environment
and Makefile.ship is the top level Makefile:
https://github.com/lcn2/calc
Makefile
# SRC: Makefile.ship - top level Makefile
This is the main top level Makefile.
In calc packages such as RPMs, and the tar.bz2 source tarball,
Makefile.ship has been moved into Makefile.
In the calc GitHub repo, Makefile is the calc build environment
and Makefile.ship is the top level Makefile:
https://github.com/lcn2/calc
The Makefile.simple rule of Makefile.ship, when forming the
Makefile.simple file, removes lines from Makefile.ship between
pairs of '#if 0' AND '#endif':
#if 0
lines removed when forming Makefile.simple
...
lines removed when forming Makefile.simple
#endif
The '#if 0' AND '#endif' MUST be at the start of the line.
Any text after the '#if 0' OR '#endif' is ignored.
While they may look like a CPP directives, they are not. The
inline awk script of the Makefile.simple rule does NOT allow
them to nest:
#if 0 /* DO NOT DO THIS */
lines removed when forming Makefile.simple
...
#if 0 /* DO NOT DO THIS */
...
#endif /* DO NOT DO THIS */
...
#endif /* DO NOT DO THIS */
Makefile.simple
# SRC: Makefile.simple - non-GNU version
This is a non-GNU or simple Makefile designed for environments
that do not have a modern make command.
If you have a Makefile.simple file, use these commands to
form a Makefile:
if [ -f Makefile ]; then mv -f Makefile Makefile.orig; fi
cp Makefile.simple Makefile
The Makefile.simple rule from Makefile.ship is used to construct
this file from the contents of Makefile.ship.
In calc packages such as RPMs, and the tar.bz2 source the
Makefile.simple exists. In the calc GitHub repo:
https://github.com/lcn2/calc
this file does NOT exist and must be made via the Makefile.simple
make rule. Therefore, non-GNU and simple make commands are NOT
supported by the calc GitHub repo master branch. Instead, you
need to extract Makefile.simple from one of the calc tar.bz2
source tarball source from a calc source mirror:
http://www.isthe.com/chongo/tech/comp/calc/calc-mirror.html
custom/Makefile
# SRC: Makefile via make -f Makefile custom/Makefile
This is the custom directory Makefile.
custom/Makefile.simple
# SRC: custom/Makefile.simple - non-GNU version
This is a non-GNU or simple Makefile for the custom directory
that is designed for environments that do not have a modern make
command.
In calc packages such as RPMs, and the tar.bz2 source the
Makefile.simple exists. In the calc GitHub repo:
https://github.com/lcn2/calc
this file does NOT exist and must be made via the
custom/Makefile.simple make rule. Therefore, non-GNU and simple
make commands are NOT supported by the calc GitHub repo master
branch. Instead, you need to extract custom/Makefile.simple
from one of the calc tar.bz2 source tarball source from a calc
source mirror:
http://www.isthe.com/chongo/tech/comp/calc/calc-mirror.html
cal/Makefile
# SRC: cal/Makefile
The Makefile for the cal sub-directory.
cscript/Makefile
# SRC: cscript/Makefile
The Makefile for the cscript sub-directory.
help/Makefile
# SRC: help/Makefile
The Makefile for the help sub-directory.
## Copyright (C) 1999-2007,2021 Landon Curt Noll
## Copyright (C) 1999-2007,2021,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

105
LIBRARY
View File

@@ -1,4 +1,4 @@
USING THE ARBITRARY PRECISION ROUTINES IN A C PROGRAM
USING THE ARBITRARY PRECISION ROUTINES IN A C PROGRAM
Part of the calc release consists of an arbitrary precision math link library.
This link library is used by the calc program to perform its own calculations.
@@ -344,7 +344,7 @@ values of 0 and 1 are so common that special checks are made for them.
For initial values besides 0 or 1, you need to call itoz to convert a long
value into a ZVALUE, as shown in the above example. Or alternatively,
for larger numbers you can use the atoz routine to convert a string which
for larger numbers you can use the str2z routine to convert a string which
represents a number into a ZVALUE. The string can be in decimal, octal,
hex, or binary according to the leading digits.
@@ -357,7 +357,7 @@ over a long sequence of operations.
ZVALUE z1, z2, z3;
z1 = _one_;
atoz("12345678987654321", &z2);
str2z("12345678987654321", &z2);
zadd(z1, z2, &z3);
zfree(z1);
zfree(z2);
@@ -415,11 +415,23 @@ the low order bits converted.
There are two types of comparisons you can make on ZVALUEs. This is whether
or not they are equal, or the ordering on size of the numbers. The zcmp
function tests whether two ZVALUEs are equal, returning TRUE if they differ.
function tests whether two ZVALUEs are equal, returning true if they differ.
The zrel function tests the relative sizes of two ZVALUEs, returning -1 if
the first one is smaller, 0 if they are the same, and 1 if the first one
is larger.
To determine if z is an integer power of 2, use zispowerof2:
ZVALUE z; /* value to check if it is a power of */
FULL log2; /* set to log base 2 of z when is_power_of_2 is true */
bool is_power_of_2;
is_power_of_2 = zispowerof2(z, &log2)
Returns true if z an integer power of 2: set log2 to log base 2 of z.
Returns false if z is NOT integer power of 2 and leave log2 untouched.
The log2 arg must be a non-NULL pointer to a ZVALUE.
---------------
USING FRACTIONS
---------------
@@ -446,18 +458,19 @@ to free them first. The following illustrates this:
itoz(55L, &q->num);
A better way to create NUMBERs with particular values is to use the itoq,
iitoq, or atoq functions. Using itoq makes a long value into a NUMBER,
iitoq, or str2q functions. Using itoq makes a long value into a NUMBER,
using iitoq makes a pair of longs into the numerator and denominator of a
NUMBER (reducing them first if needed), and atoq converts a string representing
a number into the corresponding NUMBER. The atoq function accepts input in
NUMBER (reducing them first if needed), and str2q converts a string representing
a number into the corresponding NUMBER. The str2q function accepts input in
integral, fractional, real, or exponential formats. Examples of allocating
numbers are:
NUMBER *q1, *q2, *q3;
NUMBER *q1, *q2, *q3, *q4;
q1 = itoq(66L);
q2 = iitoq(2L, 3L);
q3 = atoq("456.78");
q3 = str2q("456.78");
q4 = utoq((FULL) 1234567890L);
Also unlike ZVALUEs, NUMBERs are quickly copied. This is because they contain
a link count, which is the number of pointers there are to the NUMBER. The
@@ -473,11 +486,13 @@ the ZVALUEs contained within the NUMBER, and then puts the NUMBER structure
onto a free list for quick reuse. The following is an example of allocating
NUMBERs, copying them, adding them, and finally deleting them again.
NUMBER *q1, *q2, *q3;
NUMBER *q1, *q2, *q3, *q4;
q1 = itoq(111L);
q2 = qlink(q1);
q3 = qqadd(q1, q2);
q4 = qnum(q2, q3);
qfree(q1);
qfree(q2);
qfree(q3);
@@ -504,8 +519,8 @@ For example, to calculate sin(0.5) to 100 decimal places, you could do:
NUMBER *q, *ans, *epsilon;
q = atoq("0.5");
epsilon = atoq("1e-100");
q = str2q("0.5");
epsilon = str2q("1e-100");
ans = qsin(q, epsilon);
There are many convenience macros similar to the ones for ZVALUEs which can
@@ -513,18 +528,18 @@ give quick information about NUMBERs. In addition, there are some new ones
applicable to fractions. These are all defined in qmath.h. Some of these
macros are:
qiszero(q) (number is zero)
qisneg(q) (number is negative)
qispos(q) (number is positive)
qisint(q) (number is an integer)
qisfrac(q) (number is fractional)
qisunit(q) (number is 1 or -1)
qisone(q) (number is 1)
qisnegone(q) (number is -1)
qistwo(q) (number is 2)
qiseven(q) (number is an even integer)
qisodd(q) (number is an odd integer)
qistwopower(q) (number is a power of 2 >= 1)
qiszero(q) (number is zero)
qisneg(q) (number is negative)
qispos(q) (number is positive)
qisint(q) (number is an integer)
qisfrac(q) (number is fractional)
qisunit(q) (number is 1 or -1)
qisone(q) (number is 1)
qisnegone(q) (number is -1)
qistwo(q) (number is 2)
qiseven(q) (number is an even integer)
qisodd(q) (number is an odd integer)
qisreciprocal(q) (number is 1 / an integer and q != 0)
The comparisons for NUMBERs are similar to the ones for ZVALUEs. You use the
qcmp and qrel functions.
@@ -538,6 +553,20 @@ These have the values 0, 1, -1, and 1/2. An example of using them is:
q1 = qlink(&_qonehalf_);
q2 = qlink(&_qone_);
To determine if q is an integer power of 2, use qispowerof2:
NUMBER *q; /* value to check if it is a power of */
NUMBER *qlog2; /* set to log base 2 of q when is_power_of_2 is true */
bool is_power_of_2;
q = utoq((FULL) 1234567890L);
qlog2 = qalloc();
is_power_of_2 = qispowerof2(q, &qlog2);
Returns true if q an integer power of 2: set *qlog2 to log base 2 of q.
Returns false if q is NOT integer power of 2 and leave *qlog2 untouched.
Use qalloc() to setup the qlog2 arg before calling.
---------------------
USING COMPLEX NUMBERS
---------------------
@@ -605,7 +634,31 @@ only used for complex numbers. Examples of macros are:
cisodd(c) (number is has odd real and imaginary parts)
There is only one comparison you can make for COMPLEX values, and that is
for equality. The ccmp function returns TRUE if two complex numbers differ.
for equality. The ccmp function returns true if two complex numbers differ.
Sometimes to results of a COMPLEX based calculation is a real number.
That is, the imaginary part of the COMPLEX is 0. You may convert the
COMPLEX into a new allocated NUMBER that is real part of the COMPLEX value.
For example:
COMPLEX *c;
NUMBER *q;
bool ok_to_free; /* true ==> free COMPLEX value, false ==> do not */
if (cisreal(c)) {
q = c_to_q(c, ok_to_free);
}
The 2nd argument to c_to_q() determines if the complex argument should be freed
or not. Pass a false value as the 2nd arg if you wish to continue to use the
COMPLEX value.
To convert a NUMBER into a COMPLEX value, use:
COMPLEX *c;
NUMBER *q;
c = q_to_c(q);
There are three predefined values for complex numbers. You should clink
them when you want to use them. They are _czero_, _cone_, and _conei_.
@@ -622,7 +675,7 @@ call. This is not required, but is does bring things to a closure.
The function libcalc_call_me_last() takes no args and returns void. You
need call libcalc_call_me_last() only once.
## Copyright (C) 1999,2021 David I. Bell and Landon Curt Noll
## Copyright (C) 1999,2021,2023 David I. Bell and 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

3806
Makefile

File diff suppressed because it is too large Load Diff

1375
Makefile.config Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,46 @@
#!/usr/bin/env make
#
# Makefile.local - local Makefile variables
# Makefile.local - modify, replace or append calc Makefile variables
#
# This file is included by Makefile after the last Makefile is set and
# before the first make rule. This makes this file suitable to override
# Makefile variables.
# Copyright (C) 2023 Landon Curt Noll
#
# Suggestion: Read the HOWTO.INSTALL file.
#
# 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.
#
# This calculator first developed by David I. Bell with help/mods from others.
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
####
# This file is included all calc Makefiles after the last Makefile variable
# is set and before the first make rule. This makes this file suitable to
# modify, replace or append Makefile variables.
#
# To replace a Makefile variable, use := symbols. For example:
#
# CCWERR:= -Werror
# DEBUG:= -O0 -g
#
# You can append to an existing Makefile variable using '+=' symbols.
# For example:
#
# CCOPT+= -Ofast
# COMMON_CFLAGS+= -std=gnu2x
####
###################################################################
# NOTE: For this and other commended out examples in this file, #
@@ -17,24 +49,65 @@
# Comments start with a #-character. #
###################################################################
# You can append to an existing Makefile variable using '+=' symbols.
# For example:
####
# RHEL Diagnosing memory, thread, and crash issues:
#
# CFLAGS+= -Ofast
# 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
####
# For example, a AddressSanitizer. You do NOT want to do this by
# by default! Do this only if you are debugging with libasan:
####
# macOS Diagnosing memory, thread, and crash issues:
#
# For Linux gcc version 11.3.1 with libasan-11.3.1-2.1 you might try:
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
#
# DEBUG:= -O0 -g
# CFLAGS+= -fsanitize=address -fno-omit-frame-pointer
# LDFLAGS+= -fsanitize=address -fno-omit-frame-pointer
# CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1
# This comment block was tested under:
#
# For macOS 13.2.1 with clang version 14.0.0 (clang-1400.0.29.202) you might try:
# macOS 13.5 with clang version 14.0.3 (clang-1403.0.22.14.1)
#
# DEBUG:= -O0 -g
# CFLAGS+= -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined
# LDFLAGS+= -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined
# CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1
# For more info for clang to Diagnosing memory, thread, and crash issues early, see:
#
# https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early
#
# 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
# DEBUG:= -O0 -g3
####

File diff suppressed because it is too large Load Diff

432
Makefile.target Normal file
View File

@@ -0,0 +1,432 @@
#!/usr/bin/env make
#
# Makefile.target - platform target section
#
# Copyright (C) 2023 Landon Curt Noll
#
# Suggestion: Read the HOWTO.INSTALL file.
#
# 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.
#
# This calculator first developed by David I. Bell with help/mods from others.
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# SUGGESTION: Instead of modifying this file, consider adding
# statements to modify, replace or append Makefile
# variables in the Makefile.local file.
#######################################################################
# NOTE: These lines are included by both Makefile and custom/Makefile #
#######################################################################
##################################################################################
#-=-=-=-=-=- platform target section - targets that override defaults -=-=-=-=-=-#
##################################################################################
# Common values set in targets
#
# BLD_TYPE determines if calc is built with static and/or dynamic libs.
# Set this value to one of:
#
# BLD_TYPE= calc-dynamic-only
# BLD_TYPE= calc-static-only
#
# CC_SHARE are flags given to ${CC} to build .o files suitable for shared libs
# DEFAULT_LIB_INSTALL_PATH is where calc programs look for calc shared libs
# LD_SHARE are common flags given to ${CC} to link with shared libraries
# LIBCALC_SHLIB are flags given to ${CC} to build libcalc shared libraries
# LIBCUSTCALC_SHLIB are flags given to ${CC} to build libcustcalc shared lib
#
# NOTE: The above 5 values are unused if BLD_TYPE= calc-static-only
#
# CC_STATIC are flags given to ${CC} to build .o files suitable for static libs
# LD_STATIC are common flags given to ${CC} to link with static libraries
# LIBCALC_STATIC are flags given to ${CC} to build libcalc static libraries
# LIBCUSTCALC_STATIC are flags given to ${CC} to build libcustcalc static lib
#
# NOTE: The above 4 values are unused if BLD_TYPE= calc-dynamic-only
#
# CCOPT are flags given to ${CC} for optimization
# CCWARN are flags given to ${CC} for warning message control
#
# The following are given to ${CC}:
#
# WNO_IMPLICT
# WNO_ERROR_LONG_LONG
# WNO_LONG_LONG
#
# when compiling special .o files that may need special compile options:
#
# NOTE: These flags simply turn off certain compiler warnings,
# which is useful only when CCWERR is set to -Werror.
#
# NOTE: If your compiler does not have these -Wno files, just
# set these variables to nothing as in:
#
# WNO_IMPLICT=
# WNO_ERROR_LONG_LONG=
# WNO_LONG_LONG=
#
# CCWERR are flags given to ${CC} to make warnings fatal errors
# NOTE: CCWERR is only set in development Makefiles and must only be
# used with ${CC}, not ${LCC}. If you do not want the compiler
# to abort on warnings, then leave CCWERR blank.
# CCMISC are misc flags given to ${CC}
#
# CCBAN is given to ${CC} in order to control if banned.h is in effect.
# NOTE: See where CCBAN is defined above for details.
#
# LCC is how the C compiler is invoked on locally executed intermediate programs
# CC is how the C compiler is invoked (with an optional Purify)
#
# Specific target overrides or modifications to default values
################
# Linux target #
################
ifeq ($(target),Linux)
# default build type for this target
#
BLD_TYPE= calc-dynamic-only
# target specific library parameters
#
CC_SHARE= -fPIC
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:${PREFIX}/lib
LD_SHARE= "-Wl,-rpath,${DEFAULT_LIB_INSTALL_PATH}" \
"-Wl,-rpath-link,${DEFAULT_LIB_INSTALL_PATH}"
LIBCALC_SHLIB= -shared "-Wl,-soname,libcalc${LIB_EXT_VERSION}"
LIBCUSTCALC_SHLIB= -shared "-Wl,-soname,libcustcalc${LIB_EXT_VERSION}"
# static library option
#
CC_STATIC=
LD_STATIC=
LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
# common values set for this target
#
#CCWARN= -Wall
CCWARN= -Wall -Wextra -pedantic
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
WNO_LONG_LONG= -Wno-long-long
CCWERR=
CCOPT= ${DEBUG}
CCMISC=
LCC= gcc
CC= ${PURIFY} ${LCC} ${CCWERR}
endif # ($(target),Linux)
###############################
# Apple macOS / Darwin target #
###############################
ifeq ($(target),Darwin)
# default build type for this target
#
BLD_TYPE= calc-dynamic-only
# For old Apple Power PC systems, we need to add:
#
# -std=gnu99 -arch ppc
#
ifeq ($(arch),powerpc)
COMMON_ADD+= -std=gnu99
ARCH_CFLAGS+= -arch ppc
endif # ($(arch),powerpc)
# target specific library parameters
#
CC_SHARE= -fPIC
DEFAULT_LIB_INSTALL_PATH= ${PWD}:${LIBDIR}:${PREFIX}/lib
LD_SHARE= ${ARCH_CFLAGS}
LIBCALC_SHLIB= -dynamiclib -undefined dynamic_lookup \
-install_name ${LIBDIR}/libcalc${LIB_EXT_VERSION} \
-current_version ${VER} \
${ARCH_CFLAGS}
LIBCUSTCALC_SHLIB= -dynamiclib -undefined dynamic_lookup \
-install_name ${LIBDIR}/libcustcalc${LIB_EXT_VERSION} \
-current_version ${VER} \
${ARCH_CFLAGS}
# To reduce dependency chains under macOS, we remove functions and
# data that are unreachable by the entry point or exported symbols.
#
COMMON_LDFLAGS+= -Wl,-dead_strip
COMMON_LDFLAGS+= -Wl,-dead_strip_dylibs
# static library option
#
CC_STATIC=
LD_STATIC= ${ARCH_CFLAGS}
LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
# common values set for this target
#
#CCWARN= -Wall
CCWARN= -Wall -Wextra -pedantic
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
WNO_LONG_LONG= -Wno-long-long
CCWERR=
CCOPT= ${DEBUG}
CCMISC= ${ARCH_CFLAGS}
LCC= cc
CC= ${PURIFY} ${LCC} ${CCWERR}
# Darwin dynamic shared lib filenames
#
LIB_EXT:= .dylib
LIB_EXT_VERSION:= .${VERSION}${LIB_EXT}
# LDCONFIG not required on this platform, so we redefine it to an empty string
#
LDCONFIG:=
endif # ($(target),Darwin)
##################
# FreeBSD target #
##################
ifeq ($(target),FreeBSD)
# default build type for this target
#
BLD_TYPE= calc-dynamic-only
# target specific library parameters
#
CC_SHARE= -fPIC
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:${PREFIX}/lib
LD_SHARE= "-Wl,-rpath,${DEFAULT_LIB_INSTALL_PATH}" \
"-Wl,-rpath-link,${DEFAULT_LIB_INSTALL_PATH}"
LIBCALC_SHLIB= -shared "-Wl,-soname,libcalc${LIB_EXT_VERSION}"
LIBCUSTCALC_SHLIB= -shared "-Wl,-soname,libcustcalc${LIB_EXT_VERSION}"
CC_STATIC=
LD_STATIC=
LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
# common values set for this target
#
#CCWARN= -Wall
CCWARN= -Wall -Wextra -pedantic
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
WNO_LONG_LONG= -Wno-long-long
CCWERR=
CCOPT= ${DEBUG}
CCMISC=
LCC= gcc
CC= ${PURIFY} ${LCC} ${CCWERR}
# We must use gmake as the FreeBSD target because under some older
# releases of FreeBSD, make not support conditional syntax.
#
MAKE= gmake
endif # ($(target),FreeBSD)
##################
# OpenBSD target #
##################
ifeq ($(target),OpenBSD)
# default build type for this target
#
BLD_TYPE= calc-dynamic-only
# default build type for this target
#
CC_SHARE= -fPIC
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:${PREFIX}/lib
LD_SHARE= "-Wl,-rpath,${DEFAULT_LIB_INSTALL_PATH}" \
"-Wl,-rpath-link,${DEFAULT_LIB_INSTALL_PATH}"
LIBCALC_SHLIB= -shared "-Wl,-soname,libcalc${LIB_EXT_VERSION}"
LIBCUSTCALC_SHLIB= -shared "-Wl,-soname,libcustcalc${LIB_EXT_VERSION}"
# static library option
#
CC_STATIC=
LD_STATIC=
LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
# common values set for this target
#
#CCWARN= -Wall
CCWARN= -Wall -Wextra -pedantic
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
WNO_LONG_LONG= -Wno-long-long
CCWERR=
CCOPT= ${DEBUG}
CCMISC=
#
LCC= gcc
CC= ${PURIFY} ${LCC} ${CCWERR}
#
MAKE= gmake
#
endif # ($(target),OpenBSD)
#################
# Cygwin target #
#################
ifeq ($(target),Cygwin)
BLD_TYPE= calc-static-only
# target specific library parameters
#
CC_SHARE= -fPIC
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:${PREFIX}/lib
LD_SHARE= "-Wl,-rpath,${DEFAULT_LIB_INSTALL_PATH}" \
"-Wl,-rpath-link,${DEFAULT_LIB_INSTALL_PATH}"
LIBCALC_SHLIB= -shared "-Wl,-soname,libcalc${LIB_EXT_VERSION}"
LIBCUSTCALC_SHLIB= -shared "-Wl,-soname,libcustcalc${LIB_EXT_VERSION}"
# static library option
#
CC_STATIC=
LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
LD_STATIC=
# common values set for this target
#
#CCWARN= -Wall
CCWARN= -Wall -Wextra -pedantic
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
WNO_LONG_LONG= -Wno-long-long
CCWERR=
CCOPT= ${DEBUG}
CCMISC=
LCC= cc
CC= ${PURIFY} ${LCC} ${CCWERR}
endif # ($(target),Cygwin)
###########################################
# default target - (when target is empty) #
###########################################
# NOTE: This is the default generic host target. Used when no other
# host target matches.
ifeq ($(target),)
# default build type for this target
#
BLD_TYPE= calc-static-only
# target specific library parameters
#
CC_SHARE= -fPIC
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:${PREFIX}/lib
LD_SHARE= "-Wl,-rpath,${DEFAULT_LIB_INSTALL_PATH}" \
"-Wl,-rpath-link,${DEFAULT_LIB_INSTALL_PATH}"
LIBCALC_SHLIB= -shared "-Wl,-soname,libcalc${LIB_EXT_VERSION}"
LIBCUSTCALC_SHLIB= -shared "-Wl,-soname,libcustcalc${LIB_EXT_VERSION}"
# static library option
#
CC_STATIC=
LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
LD_STATIC=
# common values set for this target
#
#CCWARN= -Wall
CCWARN= -Wall -Wextra -pedantic
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
WNO_LONG_LONG= -Wno-long-long
CCWERR=
CCOPT= ${DEBUG}
CCMISC=
LCC= gcc
CC= ${PURIFY} ${LCC} ${CCWERR}
endif # ($(target),)
###########################################
# Set the default compile flags for ${CC} #
###########################################
# If you want to add flags to all compiler and linker
# run (via ${COMMON_CFLAGS} and ${COMMON_LDFLAGS}),
# set ${COMMON_ADD}.
#
# For example to use gcc's -Werror to force warnings
# to become errors, call make with:
#
# make .. COMMON_ADD='-Werror'
#
# This facility requires a Gnu Makefile, or a make command
# that understands the += make operand.
#
COMMON_CFLAGS+= ${COMMON_ADD}
COMMON_LDFLAGS+= ${COMMON_ADD}
# Required flags to compile C files for calc
#
# ICFLAGS are given to ${CC} for intermediate programs used to help compile calc
# CFLAGS are given to ${CC} for calc programs other than intermediate programs
#
# NOTE: This does not work for: make-XYZ-only and BLD_TYPE != make-XYZ-only
#
ifeq ($(BLD_TYPE),calc-static-only)
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC}
else # ($(BLD_TYPE),calc-static-only)
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_SHARE}
endif # ($(BLD_TYPE),calc-static-only)
CFLAGS= ${ICFLAGS} ${CCOPT}
# Required flags to link files for calc
#
# ILDFLAGS for ${CC} in linking intermediate programs used to help compile calc
# LDFLAGS for ${CC} in linking calc programs other than intermediate programs
#
ILDFLAGS= ${COMMON_LDFLAGS}
LDFLAGS= ${LD_DEBUG} ${ILDFLAGS}
#######################################################################
#-=-=-=-=-=- end of target section - only make rules below -=-=-=-=-=-#
#######################################################################

View File

@@ -27,7 +27,7 @@ If you run into problems, see the BUGS file.
Calc is distributed with an extensive collection of help files that
are accessible from the command line. The following assume that you
are running calc from the distribution directory or that you have
installed calc. In these examples, the ">" is the calc prompt, not
installed calc. In these examples, the "; " is the calc prompt, not
something that you type in.
For list of help topics:
@@ -48,7 +48,7 @@ For list of builtin functions:
; help builtin
C programmers should note some unexpected differences in the calc syntax:
C programmers should note some unexpected differences with the calc syntax:
; help unexpected

View File

@@ -32,9 +32,40 @@ neither a change to the internal representation format (a top level
version change), nor were there new calc builtins introduced in such
a top 3 level release.
There are 3 classes of changes to the calc source tree:
alpha => untagged GitHub commit
The file, "version.h" defines the 4 version levels:
MAJOR_VER /* level 1: major library version */
MINOR_VER /* level 2: minor library version */
MAJOR_PATCH /* level 3: major software version level */
MINOR_PATCH /* level 4: minor software version level */
The program "ver_calc" will print information about the compiled
calc version as defined "version.h" when "ver_calc" was compiled:
usage: ./ver_calc [-h] [-V]
-h print this message and exit non-zero
-V print 3-level version (def: print 4-level version)
Also "calc -v" will print the calc version as defined "version.h" when
"calc" was compiled.
The master branch:
The public repository of calc source code is:
http://github.com/lcn2/calc
On that GitHub site you may find released version of calc,
"production", "tested" and "alpha". All commits on the master
branch that are not associated with a release are "alpha".
Any "alpha" commit is likely future code for a future
"tested" or "production" version of calc.
alpha ==> untagged GitHub commit
Any untagged commit to the GitHub master branch should be
considered as alpha code that may make calc unstable.
@@ -43,7 +74,17 @@ alpha => untagged GitHub commit
there is a risk that picking up such a change could
negatively impact the code.
tested => tagged GitHub pre-release commit
NOTE: The calc version found in "version.h", and printed
by both "ver_calc [-V]" and "calc -v" for an untagged
commit is the previous "tested" or "production" version
of calc. Any "alpha" changes that remain are code
for some future version of calc.
At the last stage of the release process, "version.h"
will be updated as well as the top level version range
listed in "CHANGES".
tested ==> tagged GitHub pre-release commit
A new version of calc has been released and has recently passed
regression testing on at least to different platforms and chip
@@ -63,7 +104,7 @@ tested => tagged GitHub pre-release commit
At the bottom of a given release is a "> Assets" that may
be opened to reveal down-loadable files.
production => tagged GitHub release commit
production ==> tagged GitHub release commit
A new version of calc has been released and has undergone
extensive testing over time over a number of platforms.
@@ -87,14 +128,14 @@ production => tagged GitHub release commit
A historical note and apology:
In the past, some version number changes were made that did not fully
reflect the above version number or change class. Moreover older terms
such as "stable" and "unstable" were misleading and did not properly
reflect the nature of the change. Sorry! The purpose of this document
is to try and bring a better level of conformity to source code updates,
tagged releases and version numbers.
In the past, some version number changes were made that did not
fully reflect the above version number or change class. Moreover
older terms such as "stable" and "unstable" were misleading and
did not properly reflect the nature of the change. Sorry! The
purpose of this document is to try and bring a better level of
conformity to source code updates, tagged releases and version numbers.
## Copyright (C) 2021 Landon Curt Noll
## Copyright (C) 2021,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

@@ -40,6 +40,27 @@ NOTE: Compiling calc under Windows 11 is work in progress. If you run into
problems, consider the "Compiling with Cygwin" section below.
=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= Compiling with Msys =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=
The MSYS2 Software Distribution and Building Platform for Windows:
https://www.msys2.org
is a fork of Cygwin. In `Makefile.config`, when the OSNAME is "Msys",
the Cygwin target it set. MSYS2 Software Distribution users should be
sure that the following command prints "Msys".
uname -o
Or call make with OSNAME set as in:
make ... OSNAME=Msys
Follow the "Compiling with Cygwin" instructions below.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= Compiling with Cygwin =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -107,97 +128,6 @@ compilation steps that GitHub user @Leoongithub recommends:
of calc, installing calc may be of benefit so you can use calc elsewhere on your system.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= If all else fails, for Cygwin =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Much earlier (2001?) Thomas Jones-Low (tjoneslo at softstart dot com)
recommended that you generate by hand all of the header files that
by the Makefile. This has been done for you via the makefile rule:
make win32_hsrc
which uses the Makefile variables in win32.mkdef to form these header
files under win32 directory.
You will find generated versions of these files located in the win32
sub-directory. These files may be appropriate for your Cygwin building
needs.
In particular:
Just copy the win32/*.[ch] files up into the top level calc
source directory, edit them (if needed) and build using the
Cygwin GCC compiler and Cygwin build environment.
NOTE: The use of win32_hsrc and this method has been deprecated.
It may go away once the Windows 11 methods are stable.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= compiling under DJGPP =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
You might want to try using the DJGPP system to compile calc. See:
http://www.delorie.com/djgpp/
for DJGPP details and availability.
To compile with DJGPP, one needs to select a number of Makefile
variable changes. Eli Zaretskii <eliz at is dot elta dot co dot il>
recommends the following settings:
TERMCONTROL= -DUSE_TERMIOS
BYTE_ORDER= -DLITTLE_ENDIAN
LONG_BITS= 32
HAVE_FPOS_POS= -DHAVE_NO_FPOS_POS
FPOS_BITS= 32
OFF_T_BITS= 32
DEV_BITS= 32
INODE_BITS= 32
HAVE_USTAT= -DHAVE_NO_USTAT
HAVE_GETSID= -DHAVE_NO_GETSID
HAVE_GETPGID= -DHAVE_NO_GETPGID
HAVE_GETTIME= -DHAVE_NO_GETTIME
HAVE_GETPRID= -DHAVE_NO_GETPRID
HAVE_URANDOM_H= NO
ALIGN32= -UMUST_ALIGN32
HAVE_MALLOC_H= YES
HAVE_STDLIB_H= YES
HAVE_STRING_H= YES
HAVE_TIMES_H= NO
HAVE_SYS_TIMES_H= YES
HAVE_TIME_H= YES
HAVE_SYS_TIME_H= YES
HAVE_UNISTD_H= YES
BINDIR= /dev/env/DJDIR/bin
INCDIR= /dev/env/DJDIR/include
LIBDIR= /dev/env/DJDIR/lib
MANDIR= /dev/env/DJDIR/man/man1
CATDIR= /dev/env/DJDIR/man/cat1
NROFF= groff
CALCPATH= .;./cal;~/.cal;${CALC_SHAREDIR};${CUSTOMCALDIR}
CALCRC= ./.calcinit;~/.calcrc;${CALC_SHAREDIR}/startup
CALCPAGER= less.exe -ci
DEBUG= -O2 -gstabs+ -D_WIN32
HAVE_ENVIRON=-DHAVE_NO_ENVIRON
HAVE_ARC4RANDOM=-DHAVE_NO_ARC4RANDOM
The 'Linux set' or 'gcc set' (see the Select your compiler type section)
should work for DJGPP systems if you set the above Makefile variables.
Look for Makefile comments of the form:
# Select ...something... for DJGPP.
Follow those recommendations. In cases where they conflict with
the above Makefile list, follow the recommendation in the Makefile.
NOTE: The use of DJGPP and this method has been deprecated.
It may go away once the Windows 11 methods are stable.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= Compiling calc via virtual machine under Windows 11 =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -230,7 +160,7 @@ NOTE: The use of calc under Windows 10 has been deprecated in favor of one
of the Windows 11 methods above.
## Copyright (C) 2002-2009,2021,2022 Landon Curt Noll and Thomas Jones-Low
## Copyright (C) 2002-2009,2021-2023 Landon Curt Noll and Thomas Jones-Low
##
## 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,3 +1,25 @@
# TL;DR Try calc
## TL;DR Install calc
```
misc linux: sudo yum install calc
on Debian: sudo apt install calc
on RHEL: sudo dnf install calc
on Ubuntu: sudo apt install calc
via Termux: apt install calc
via src: sudo make clobber all chk instsll
```
## TL;DR Run calc
```
misc shell: calc
via bash: calc
via misc app: launch calc via Termux
via zsh: calc
```
# What is calc?
Calc is an interactive calculator which provides for easy large

30
addop.c
View File

@@ -1,7 +1,7 @@
/*
* addop - add opcodes to a function being compiled
*
* Copyright (C) 1999-2007,2021,2022 David I. Bell and Ernest Bowen
* Copyright (C) 1999-2007,2021-2023 David I. Bell and Ernest Bowen
*
* Primary author: David I. Bell
*
@@ -37,7 +37,7 @@
#include "symbol.h"
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -136,16 +136,16 @@ showfunctions(void)
/*
* Initialize a function for definition.
* Newflag is TRUE if we should allocate a new function structure,
* Newflag is true if we should allocate a new function structure,
* instead of the usual overwriting of the template function structure.
* The new structure is returned in the global curfunc variable.
*
* given:
* name name of function
* newflag TRUE if need new structure
* newflag true if need new structure
*/
void
beginfunc(char *name, BOOL newflag)
beginfunc(char *name, bool newflag)
{
register FUNC *fp; /* current function */
@@ -210,7 +210,7 @@ endfunc(void)
if (curfunc != functemplate)
free(curfunc);
if (newname[0] != '*' && (conf->traceflags & TRACE_FNCODES)) {
dumpnames = TRUE;
dumpnames = true;
for (size = 0; size < fp->f_opcodecount; ) {
printf("%ld: ", (unsigned long)size);
size += dumpop(&fp->f_opcodes[size]);
@@ -322,7 +322,7 @@ freefunc(FUNC *fp)
}
if (newname[0] != '*' && (conf->traceflags & TRACE_FNCODES)) {
printf("Freeing function \"%s\"\n",namestr(&funcnames,index));
dumpnames = FALSE;
dumpnames = false;
for (i = 0; i < fp->f_opcodecount; ) {
printf("%ld: ", i);
i += dumpop(&fp->f_opcodes[i]);
@@ -411,7 +411,7 @@ void
writeindexop(void)
{
if (oldop == OP_INDEXADDR)
curfunc->f_opcodes[curfunc->f_opcodecount - 1] = TRUE;
curfunc->f_opcodes[curfunc->f_opcodecount - 1] = true;
}
@@ -426,12 +426,12 @@ addop(long op)
register FUNC *fp; /* current function */
NUMBER *q, *q1, *q2;
unsigned long count;
BOOL cut;
bool cut;
int diff;
fp = curfunc;
count = fp->f_opcodecount;
cut = TRUE;
cut = true;
diff = 2;
q = NULL;
if ((count + 5) >= maxopcodes) {
@@ -488,7 +488,7 @@ addop(long op)
oldop = OP_ELEMVALUE;
break;
default:
cut = FALSE;
cut = false;
}
if (cut) {
@@ -522,7 +522,7 @@ addop(long op)
oldoldop = OP_NOP;
return;
default:
cut = FALSE;
cut = false;
}
if (cut) {
fp->f_opcodecount -= diff;
@@ -547,7 +547,7 @@ addop(long op)
switch (op) {
case OP_DIV:
if (qiszero(q2)) {
cut = FALSE;
cut = false;
break;
}
q = qqdiv(q1,q2);
@@ -563,12 +563,12 @@ addop(long op)
break;
case OP_POWER:
if (qisfrac(q2) || qisneg(q2))
cut = FALSE;
cut = false;
else
q = qpowi(q1,q2);
break;
default:
cut = FALSE;
cut = false;
}
if (cut) {
qfree(q1);

View File

@@ -1,7 +1,7 @@
/*
* assocfunc - association table routines
*
* Copyright (C) 1999-2007,2021,2022 David I. Bell
* Copyright (C) 1999-2007,2021-2023 David I. Bell
*
* 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
@@ -36,7 +36,7 @@
#include "value.h"
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -47,15 +47,15 @@
S_FUNC ASSOCELEM *elemindex(ASSOC *ap, long index);
S_FUNC BOOL compareindices(VALUE *v1, VALUE *v2, long dim);
S_FUNC bool compareindices(VALUE *v1, VALUE *v2, long dim);
S_FUNC void resize(ASSOC *ap, long newsize);
S_FUNC void assoc_elemfree(ASSOCELEM *ep);
/*
* Return the address of the value specified by normal indexing of
* an association. The create flag is TRUE if a value is going to be
* assigned into the specified indexing location. If create is FALSE and
* an association. The create flag is true if a value is going to be
* assigned into the specified indexing location. If create is false and
* the index value doesn't exist, a pointer to a NULL value is returned.
*
* given:
@@ -65,7 +65,7 @@ S_FUNC void assoc_elemfree(ASSOCELEM *ep);
* indices table of values being indexed by
*/
VALUE *
associndex(ASSOC *ap, BOOL create, long dim, VALUE *indices)
associndex(ASSOC *ap, bool create, long dim, VALUE *indices)
{
ASSOCELEM **listhead;
ASSOCELEM *ep;
@@ -266,9 +266,9 @@ associndices(ASSOC *ap, long index)
/*
* Compare two associations to see if they are identical.
* Returns TRUE if they are different.
* Returns true if they are different.
*/
BOOL
bool
assoccmp(ASSOC *ap1, ASSOC *ap2)
{
ASSOCELEM **table1;
@@ -280,9 +280,9 @@ assoccmp(ASSOC *ap1, ASSOC *ap2)
long dim;
if (ap1 == ap2)
return FALSE;
return false;
if (ap1->a_count != ap2->a_count)
return TRUE;
return true;
table1 = ap1->a_table;
size1 = ap1->a_size;
@@ -294,7 +294,7 @@ assoccmp(ASSOC *ap1, ASSOC *ap2)
for (ep2 = ap2->a_table[hash % size2]; ;
ep2 = ep2->e_next) {
if (ep2 == NULL)
return TRUE;
return true;
if (ep2->e_hash != hash)
continue;
if (ep2->e_dim != dim)
@@ -304,10 +304,10 @@ assoccmp(ASSOC *ap1, ASSOC *ap2)
break;
}
if (comparevalue(&ep1->e_value, &ep2->e_value))
return TRUE;
return true;
}
}
return FALSE;
return false;
}
@@ -520,20 +520,20 @@ assocprint(ASSOC *ap, long max_print)
/*
* Compare two lists of index values to see if they are identical.
* Returns TRUE if they are the same.
* Returns true if they are the same.
*/
S_FUNC BOOL
S_FUNC bool
compareindices(VALUE *v1, VALUE *v2, long dim)
{
int i;
for (i = 0; i < dim; i++)
if (v1[i].v_type != v2[i].v_type)
return FALSE;
return false;
while (dim-- > 0)
if (comparevalue(v1++, v2++))
return FALSE;
return false;
return TRUE;
return true;
}

168
blkcpy.c
View File

@@ -1,7 +1,7 @@
/*
* blkcpy - general values and related routines used by the calculator
*
* Copyright (C) 1999-2007,2021,2022 Landon Curt Noll and Ernest Bowen
* Copyright (C) 1999-2007,2021-2023 Landon Curt Noll and Ernest Bowen
*
* Primary author: Landon Curt Noll
*
@@ -36,7 +36,7 @@
#include "str.h"
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -56,7 +56,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
{
BLOCK *sblk;
BLOCK *dblk;
BOOL noreloc;
bool noreloc;
sblk = NULL;
dblk = NULL;
@@ -65,9 +65,9 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
* check protections
*/
if (svp->v_subtype & V_NOCOPYFROM)
return E_COPY13;
return E_COPY_13;
if (dvp->v_subtype & V_NOCOPYTO)
return E_COPY14;
return E_COPY_14;
noreloc = ((dvp->v_subtype & V_NOREALLOC) != 0);
/*
@@ -76,10 +76,10 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
switch(svp->v_type) {
case V_NBLOCK:
if (svp->v_nblock->subtype & V_NOCOPYFROM)
return E_COPY15;
return E_COPY_15;
sblk = svp->v_nblock->blk;
if (sblk->data == NULL)
return E_COPY8;
return E_COPY_08;
break;
case V_BLOCK:
sblk = svp->v_block;
@@ -92,7 +92,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
case V_LIST:
break;
default:
return E_COPY9;
return E_COPY_09;
}
/*
@@ -101,11 +101,11 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
switch(dvp->v_type) {
case V_NBLOCK:
if (dvp->v_nblock->subtype & V_NOCOPYTO)
return E_COPY16;
return E_COPY_16;
noreloc |=((dvp->v_nblock->subtype & V_NOREALLOC) != 0);
dblk = dvp->v_nblock->blk;
if (dblk->data == NULL)
return E_COPY10;
return E_COPY_10;
break;
case V_BLOCK:
noreloc = ((dvp->v_subtype & V_NOREALLOC) != 0);
@@ -118,7 +118,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
case V_LIST:
break;
default:
return E_COPY11;
return E_COPY_11;
}
/*
@@ -154,7 +154,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
case V_STR:
return copyblk2str(sblk, ssi, num, dvp->v_str, dsi);
}
return E_COPY12;
return E_COPY_12;
case V_STR:
switch(dvp->v_type) {
@@ -170,7 +170,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
return copystr2str(svp->v_str, ssi, num, dvp->v_str,
dsi);
}
return E_COPY12;
return E_COPY_12;
case V_OCTET:
switch(dvp->v_type) {
@@ -182,7 +182,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
return copyostr2str((char *) svp->v_octet, ssi, num,
dvp->v_str, dsi);
}
return E_COPY12;
return E_COPY_12;
case V_NUM:
@@ -197,10 +197,10 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
switch (dvp->v_type) {
case V_MAT:
/* copy to a matrix */
return E_COPY12; /* not yet - XXX */
return E_COPY_12; /* not yet - XXX */
case V_LIST:
/* copy to a list */
return E_COPY12; /* not yet - XXX */
return E_COPY_12; /* not yet - XXX */
}
break;
case V_FILE:
@@ -216,7 +216,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
switch (dvp->v_type) {
case V_NUM:
/* copy to a number */
return E_COPY12; /* not yet - XXX */
return E_COPY_12; /* not yet - XXX */
}
break;
@@ -249,7 +249,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
*/
if (dblk != NULL) {
/* copy to a block */
return E_COPY12; /* not yet - XXX */
return E_COPY_12; /* not yet - XXX */
}
switch (dvp->v_type) {
case V_MAT:
@@ -267,7 +267,7 @@ copystod(VALUE *svp, long ssi, long num, VALUE *dvp, long dsi)
/*
* unsupported copy combination
*/
return E_COPY12;
return E_COPY_12;
}
@@ -284,18 +284,18 @@ copymat2mat(MATRIX *smat, long ssi, long num, MATRIX *dmat, long dsi)
unsigned short subtype;
if (ssi > smat->m_size)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = smat->m_size - ssi;
if (ssi + num > smat->m_size)
return E_COPY5;
return E_COPY_05;
if (num == 0)
return 0;
if (dsi < 0)
dsi = 0;
if (dsi + num > dmat->m_size)
return E_COPY7;
return E_COPY_07;
vtemp = (VALUE *) malloc(num * sizeof(VALUE));
if (vtemp == NULL) {
math_error("Out of memory for mat-to-mat copy");
@@ -333,17 +333,17 @@ copyblk2mat(BLOCK *blk, long ssi, long num, MATRIX *dmat, long dsi)
unsigned short subtype;
if (ssi > blk->datalen)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = blk->datalen - ssi;
if (ssi + num > blk->datalen)
return E_COPY5;
return E_COPY_05;
if (num == 0)
return 0;
if (dsi < 0)
dsi = 0;
if (dsi + num > dmat->m_size)
return E_COPY7;
return E_COPY_07;
op = blk->data + ssi;
vtemp = (VALUE *) malloc(num * sizeof(VALUE));
if (vtemp == NULL) {
@@ -376,7 +376,7 @@ copyblk2mat(BLOCK *blk, long ssi, long num, MATRIX *dmat, long dsi)
*/
int
copymat2blk(MATRIX *smat, long ssi, long num, BLOCK *dblk, long dsi,
BOOL noreloc)
bool noreloc)
{
long i;
long newlen;
@@ -386,21 +386,21 @@ copymat2blk(MATRIX *smat, long ssi, long num, BLOCK *dblk, long dsi,
OCTET *op;
if (ssi > smat->m_size)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = smat->m_size - ssi;
if (num == 0)
return 0;
if (ssi + num > smat->m_size)
return E_COPY5;
return E_COPY_05;
if (dsi < 0)
dsi = dblk->datalen;
newlen = dsi + num;
if (newlen <= 0)
return E_COPY7;
return E_COPY_07;
if (newlen >= dblk->maxsize) {
if (noreloc)
return E_COPY17;
return E_COPY_17;
newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk;
newdata = (USB8*) realloc(dblk->data, newsize);
if (newdata == NULL) {
@@ -434,17 +434,17 @@ copymat2list(MATRIX *smat, long ssi, long num, LIST *lp, long dsi)
unsigned short subtype;
if (ssi > smat->m_size)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = smat->m_size - ssi;
if (num == 0)
return 0;
if (ssi + num > smat->m_size)
return E_COPY5;
return E_COPY_05;
if (dsi < 0)
dsi = 0;
if (dsi + num > lp->l_count)
return E_COPY7;
return E_COPY_07;
vtemp = (VALUE *) malloc(num * sizeof(VALUE));
if (vtemp == NULL) {
math_error("Out of memory for matrix-to-list copy");
@@ -484,17 +484,17 @@ copylist2mat(LIST *lp, long ssi, long num, MATRIX *dmat, long dsi)
unsigned short subtype;
if (ssi > lp->l_count)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = lp->l_count - ssi;
if (num == 0)
return 0;
if (ssi + num > lp->l_count)
return E_COPY5;
return E_COPY_05;
if (dsi < 0)
dsi = 0;
if (dsi + num > dmat->m_size)
return E_COPY7;
return E_COPY_07;
vtemp = (VALUE *) malloc(num * sizeof(VALUE));
if (vtemp == NULL) {
math_error("Out of memory for list-to-matrix copy");
@@ -534,17 +534,17 @@ copylist2list(LIST *slp, long ssi, long num, LIST *dlp, long dsi)
unsigned short subtype;
if (ssi > slp->l_count)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = slp->l_count - ssi;
if (num == 0)
return 0;
if (ssi + num > slp->l_count)
return E_COPY5;
return E_COPY_05;
if (dsi < 0)
dsi = 0;
if (dsi + num > dlp->l_count)
return E_COPY7;
return E_COPY_07;
vtemp = (VALUE *) malloc(num * sizeof(VALUE));
if (vtemp == NULL) {
math_error("Out of memory for list-to-list copy");
@@ -583,15 +583,15 @@ copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi)
long numw;
if (ssi > sblk->datalen)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = sblk->datalen - ssi;
if (num == 0)
return 0;
fiop = findid(id, TRUE);
fiop = findid(id, true);
if (fiop == NULL)
return E_COPYF1;
return E_COPYF_1;
fp = fiop->fp;
if (id == 1 || id == 2) {
numw = idfputstr(id, (char *)sblk->data + ssi); /* XXX */
@@ -599,11 +599,11 @@ copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi)
}
if (dsi >= 0) {
if (fseek(fp, dsi, 0))
return E_COPYF2;
return E_COPYF_2;
}
numw = fwrite(sblk->data + ssi, 1, num, fp);
if (numw < num)
return E_COPYF3;
return E_COPYF_3;
fflush(fp);
return 0;
}
@@ -613,7 +613,7 @@ copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi)
* copyfile2blk - copy file to block
*/
int
copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, BOOL noreloc)
copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, bool noreloc)
{
FILEIO *fiop;
FILE *fp;
@@ -625,40 +625,40 @@ copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, BOOL noreloc)
OCTET *newdata;
if (id < 3) /* excludes copying from stdin */
return E_COPYF1;
fiop = findid(id, FALSE);
return E_COPYF_1;
fiop = findid(id, false);
if (fiop == NULL)
return E_COPYF1;
return E_COPYF_1;
fp = fiop->fp;
if (get_open_siz(fp, &fsize))
return E_COPYF2;
return E_COPYF_2;
if (zge31b(fsize)) {
zfree(fsize);
return E_COPY5;
return E_COPY_05;
}
filelen = ztoi(fsize);
zfree(fsize);
if (ssi > filelen)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = filelen - ssi;
if (num == 0)
return 0;
if (ssi + num > filelen)
return E_COPY5;
return E_COPY_05;
if (fseek(fp, ssi, 0)) /* using system fseek XXX */
return E_COPYF2;
return E_COPYF_2;
if (dsi < 0)
dsi = dblk->datalen;
newlen = dsi + num;
if (newlen <= 0)
return E_COPY7;
return E_COPY_07;
if (newlen >= dblk->maxsize) {
if (noreloc)
return E_COPY17;
return E_COPY_17;
newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk;
newdata = (USB8*) realloc(dblk->data, newsize);
if (newdata == NULL) {
@@ -670,7 +670,7 @@ copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, BOOL noreloc)
}
numw = fread(dblk->data + dsi, 1, num, fp);
if (numw < num)
return E_COPYF4;
return E_COPYF_4;
if (newlen > dblk->datalen)
dblk->datalen = newlen;
return 0;
@@ -691,16 +691,16 @@ copystr2file(STRING *str, long ssi, long num, FILEID id, long dsi)
len = str->s_len;
if (ssi >= len)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = len - ssi;
if (num <= 0) /* Nothing to be copied */
return 0;
if (ssi + num > len)
return E_COPY5; /* Insufficient memory in str */
fiop = findid(id, TRUE);
return E_COPY_05; /* Insufficient memory in str */
fiop = findid(id, true);
if (fiop == NULL)
return E_COPYF1;
return E_COPYF_1;
fp = fiop->fp;
if (id == 1 || id == 2) {
numw = idfputstr(id, str->s_str + ssi); /* XXX */
@@ -708,11 +708,11 @@ copystr2file(STRING *str, long ssi, long num, FILEID id, long dsi)
}
if (dsi >= 0) {
if (fseek(fp, dsi, 0))
return E_COPYF2;
return E_COPYF_2;
}
numw = fwrite(str->s_str + ssi, 1, num, fp);
if (numw < num)
return E_COPYF3;
return E_COPYF_3;
fflush(fp);
return 0;
}
@@ -723,28 +723,28 @@ copystr2file(STRING *str, long ssi, long num, FILEID id, long dsi)
*/
int
copyblk2blk(BLOCK *sblk, long ssi, long num, BLOCK *dblk, long dsi,
BOOL noreloc)
bool noreloc)
{
long newlen;
long newsize;
USB8 *newdata;
if (ssi > sblk->datalen)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = sblk->datalen - ssi;
if (num == 0) /* Nothing to be copied */
return 0;
if (ssi + num > sblk->datalen)
return E_COPY5;
return E_COPY_05;
if (dsi < 0)
dsi = dblk->datalen;
newlen = dsi + num;
if (newlen <= 0)
return E_COPY7;
return E_COPY_07;
if (newlen >= dblk->maxsize) {
if (noreloc)
return E_COPY17;
return E_COPY_17;
newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk;
newdata = (USB8*) realloc(dblk->data, newsize);
if (newdata == NULL) {
@@ -766,7 +766,7 @@ copyblk2blk(BLOCK *sblk, long ssi, long num, BLOCK *dblk, long dsi,
*/
int
copystr2blk(STRING *str, long ssi, long num, BLOCK *dblk, long dsi,
BOOL noreloc)
bool noreloc)
{
long len;
long newlen;
@@ -776,7 +776,7 @@ copystr2blk(STRING *str, long ssi, long num, BLOCK *dblk, long dsi,
len = str->s_len;
if (ssi >= len)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = len - ssi;
if (num <= 0) /* Nothing to be copied */
@@ -785,10 +785,10 @@ copystr2blk(STRING *str, long ssi, long num, BLOCK *dblk, long dsi,
dsi = dblk->datalen;
newlen = dsi + num + 1;
if (newlen <= 0)
return E_COPY7;
return E_COPY_07;
if (newlen >= dblk->maxsize) {
if (noreloc)
return E_COPY17;
return E_COPY_17;
newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk;
newdata = (USB8*) realloc(dblk->data, newsize);
if (newdata == NULL) {
@@ -887,7 +887,7 @@ copyostr2str(char *sstr, long ssi, long num, STRING *dstr, long dsi)
* copyostr2blk - copy octet-specified string to block
*/
int
copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,BOOL noreloc)
copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,bool noreloc)
{
size_t len;
size_t newlen;
@@ -897,7 +897,7 @@ copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,BOOL noreloc)
len = strlen(str) + 1;
if (ssi > 0 && (size_t)ssi > len)
return E_COPY2;
return E_COPY_02;
if (num < 0 || (size_t)(ssi + num) > len)
num = len - ssi;
if (num <= 0) /* Nothing to be copied */
@@ -906,10 +906,10 @@ copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,BOOL noreloc)
dsi = dblk->datalen; /* Default destination index */
newlen = dsi + num;
if (newlen <= 0)
return E_COPY7;
return E_COPY_07;
if (newlen >= (size_t)dblk->maxsize) {
if (noreloc)
return E_COPY17;
return E_COPY_17;
newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk;
newdata = (USB8*) realloc(dblk->data, newsize);
if (newdata == NULL) {
@@ -987,7 +987,7 @@ memmove(void *s1, CONST void *s2, MEMMOVE_SIZE_T n)
*/
int
copynum2blk(NUMBER *snum, long ssi, long num, BLOCK *dblk, long dsi,
BOOL noreloc)
bool noreloc)
{
size_t newlen;
size_t newsize;
@@ -997,21 +997,21 @@ copynum2blk(NUMBER *snum, long ssi, long num, BLOCK *dblk, long dsi,
#endif
if (ssi > snum->num.len)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = snum->num.len - ssi;
if (num == 0) /* Nothing to be copied */
return 0;
if (ssi + num > snum->num.len)
return E_COPY5;
return E_COPY_05;
if (dsi < 0)
dsi = dblk->datalen;
newlen = dsi + (num*sizeof(HALF));
if (newlen <= 0)
return E_COPY7;
return E_COPY_07;
if (newlen >= (size_t)dblk->maxsize) {
if (noreloc)
return E_COPY17;
return E_COPY_17;
newsize = (1 + newlen/dblk->blkchunk) * dblk->blkchunk;
newdata = (USB8*) realloc(dblk->data, newsize);
if (newdata == NULL) {
@@ -1024,7 +1024,7 @@ copynum2blk(NUMBER *snum, long ssi, long num, BLOCK *dblk, long dsi,
#if CALC_BYTE_ORDER == LITTLE_ENDIAN
memmove(dblk->data+dsi, (char *)(snum->num.v+ssi), num*sizeof(HALF));
#else
swnum = swap_b8_in_ZVALUE(NULL, &(snum->num), FALSE);
swnum = swap_b8_in_ZVALUE(NULL, &(snum->num), false);
memmove(dblk->data+dsi, (char *)(swnum->v+ssi), num*sizeof(HALF));
zfree(*swnum);
#endif
@@ -1051,18 +1051,18 @@ copyblk2num(BLOCK *sblk, long ssi, long num, NUMBER *dnum, long dsi,
#endif
if (ssi > sblk->datalen)
return E_COPY2;
return E_COPY_02;
if (num < 0)
num = sblk->datalen - ssi;
if (num == 0) /* Nothing to be copied */
return 0;
if (ssi + num > sblk->datalen)
return E_COPY5;
return E_COPY_05;
if (dsi < 0)
dsi = dnum->num.len;
newlen = dsi + ((num+sizeof(HALF)-1)/sizeof(HALF));
if (newlen <= 0)
return E_COPY7;
return E_COPY_07;
/* quasi-clone the numerator to the new size */
ret = qalloc();

View File

@@ -37,21 +37,21 @@ E_FUNC int copystod(VALUE *, long, long, VALUE *, long);
/*
* specific copy functions
*/
E_FUNC int copyblk2blk(BLOCK *, long, long, BLOCK *, long, BOOL);
E_FUNC int copyblk2blk(BLOCK *, long, long, BLOCK *, long, bool);
E_FUNC int copyblk2file(BLOCK *, long, long, FILEID, long);
E_FUNC int copyblk2mat(BLOCK *, long, long, MATRIX *, long);
E_FUNC int copyblk2num(BLOCK *, long, long, NUMBER *, long, NUMBER **);
E_FUNC int copyblk2str(BLOCK *, long, long, STRING *, long);
E_FUNC int copyfile2blk(FILEID, long, long, BLOCK *, long, BOOL);
E_FUNC int copyfile2blk(FILEID, long, long, BLOCK *, long, bool);
E_FUNC int copylist2list(LIST *, long, long, LIST *, long);
E_FUNC int copylist2mat(LIST *, long, long, MATRIX *, long);
E_FUNC int copymat2blk(MATRIX *, long, long, BLOCK *, long, BOOL);
E_FUNC int copymat2blk(MATRIX *, long, long, BLOCK *, long, bool);
E_FUNC int copymat2list(MATRIX *, long, long, LIST *, long);
E_FUNC int copymat2mat(MATRIX *, long, long, MATRIX *, long);
E_FUNC int copynum2blk(NUMBER *, long, long, BLOCK *, long, BOOL);
E_FUNC int copyostr2blk(char *, long, long, BLOCK *, long, BOOL);
E_FUNC int copynum2blk(NUMBER *, long, long, BLOCK *, long, bool);
E_FUNC int copyostr2blk(char *, long, long, BLOCK *, long, bool);
E_FUNC int copyostr2str(char *, long, long, STRING *, long);
E_FUNC int copystr2blk(STRING *, long, long, BLOCK *, long, BOOL);
E_FUNC int copystr2blk(STRING *, long, long, BLOCK *, long, bool);
E_FUNC int copystr2file(STRING *, long, long, FILEID, long);
E_FUNC int copystr2str(STRING *, long, long, STRING *, long);

25
block.c
View File

@@ -1,7 +1,7 @@
/*
* block - fixed, dynamic, fifo and circular memory blocks
*
* Copyright (C) 1999-2007,2021,2022 Landon Curt Noll and Ernest Bowen
* Copyright (C) 1999-2007,2021-2023 Landon Curt Noll and Ernest Bowen
*
* Primary author: Landon Curt Noll
*
@@ -39,10 +39,9 @@
#include "block.h"
#include "nametype.h"
#include "str.h"
#include "calcerr.h"
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -427,8 +426,8 @@ blk_copy(BLOCK *blk)
* b second BLOCK
*
* returns:
* TRUE => BLOCKs are different
* FALSE => BLOCKs are the same
* true => BLOCKs are different
* false => BLOCKs are the same
*/
int
blk_cmp(BLOCK *a, BLOCK *b)
@@ -438,11 +437,11 @@ blk_cmp(BLOCK *a, BLOCK *b)
*/
if (a == b) {
/* pointers to the same object */
return FALSE;
return false;
}
if (a == NULL || b == NULL) {
/* one pointer is NULL, so they differ */
return TRUE;
return true;
}
/*
@@ -450,7 +449,7 @@ blk_cmp(BLOCK *a, BLOCK *b)
*/
if (a->datalen != b->datalen) {
/* different lengths are different */
return TRUE;
return true;
}
/*
@@ -460,13 +459,13 @@ blk_cmp(BLOCK *a, BLOCK *b)
*/
if (memcmp(a->data, b->data, a->datalen) != 0) {
/* different sections are different */
return TRUE;
return true;
}
/*
* the blocks are the same
*/
return FALSE;
return false;
}
@@ -479,7 +478,7 @@ void
blk_print(BLOCK *blk)
{
long i;
BOOL havetail;
bool havetail;
USB8 *ptr;
/* XXX - should use the config parameters for better print control */
@@ -653,12 +652,12 @@ removenblock(int id)
NBLOCK *nblk;
if (id < 0 || id >= nblockcount)
return E_BLKFREE3;
return E_BLKFREE_3;
nblk = nblocks[id];
if (nblk->blk->data == NULL)
return 0;
if (nblk->subtype & V_NOREALLOC)
return E_BLKFREE5;
return E_BLKFREE_5;
free(nblk->blk->data);
nblk->blk->data = NULL;
nblk->blk->maxsize = 0;

View File

@@ -1,7 +1,7 @@
/*
* block - fixed, dynamic, fifo and circular memory blocks
*
* Copyright (C) 1999-2007,2014,2021 Landon Curt Noll and Ernest Bowen
* Copyright (C) 1999-2007,2014,2021,2023 Landon Curt Noll and Ernest Bowen
*
* Primary author: Landon Curt Noll
*
@@ -122,7 +122,7 @@
* number of octets of a block to print, 0 means all
*
* config("blkverbose", boolean)
* TRUE => print all lines, FALSE => skip dup lines
* true => print all lines, false => skip dup lines
*
* config("blkbase", "base")
* output block base = { "hex", "octal", "char", "binary", "raw" }

65
bool.h Normal file
View File

@@ -0,0 +1,65 @@
/*
* bool - calc standard truth :-)
*
* Copyright (C) 2023 David I. Bell and Landon Curt Noll
*
* Primary author: David I. Bell
*
* 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
* 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.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Under source code control: 2023/07/19 17:58:42
* 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/
*/
#if !defined(INCLUDE_BOOL_H)
#define INCLUDE_BOOL_H
#include "have_stdbool.h"
#if defined(HAVE_STDBOOL_H)
#include <stdbool.h>
#endif /* HAVE_STDBOOL_H */
/*
* standard truth :-)
*/
#if !defined(HAVE_STDBOOL_H)
/* fake a <stdbool.h> header file */
typedef unsigned char bool; /* fake boolean typedef */
#undef true
#define true ((bool)(1))
#undef false
#define false ((bool)(0))
#endif /* !HAVE_STDBOOL_H */
/*
* calc historic booleans
*/
#undef TRUE
#define TRUE (true)
#undef FALSE
#define FALSE (false)
#undef BOOL
#define BOOL bool
#endif /* !INCLUDE_BOOL_H*/

View File

@@ -1,7 +1,7 @@
/*
* byteswap - byte swapping routines
*
* Copyright (C) 1999,2021,2022 Landon Curt Noll
* Copyright (C) 1999,2021-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
@@ -29,7 +29,7 @@
#include "byteswap.h"
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -80,7 +80,7 @@ swap_b8_in_HALFs(HALF *dest, HALF *src, LEN len)
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a ZVALUE to swap
* all - TRUE => swap every element, FALSE => swap only the
* all - true => swap every element, false => swap only the
* multi-precision storage
*
* returns:
@@ -90,7 +90,7 @@ swap_b8_in_HALFs(HALF *dest, HALF *src, LEN len)
* Little Endian) the elements of a ZVALUE.
*/
ZVALUE *
swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, bool all)
{
/*
* allocate storage if needed
@@ -128,7 +128,7 @@ swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
*/
if (all) {
SWAP_B8_IN_LEN(&dest->len, &src->len);
SWAP_B8_IN_BOOL(&dest->sign, &src->sign);
SWAP_B8_IN_bool(&dest->sign, &src->sign);
} else {
dest->len = src->len;
dest->sign = src->sign;
@@ -148,7 +148,7 @@ swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a NUMBER to swap
* all - TRUE => swap every element, FALSE => swap only the
* all - true => swap every element, false => swap only the
* multi-precision storage
*
* returns:
@@ -158,7 +158,7 @@ swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
* Little Endian) the elements of a NUMBER.
*/
NUMBER *
swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, bool all)
{
/*
* allocate storage if needed
@@ -212,7 +212,7 @@ swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a COMPLEX to swap
* all - TRUE => swap every element, FALSE => swap only the
* all - true => swap every element, false => swap only the
* multi-precision storage
*
* returns:
@@ -222,7 +222,7 @@ swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
* Little Endian) the elements of a COMPLEX.
*/
COMPLEX *
swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, bool all)
{
/*
* allocate storage if needed
@@ -360,7 +360,7 @@ swap_HALFs(HALF *dest, HALF *src, LEN len)
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a ZVALUE to swap
* all - TRUE => swap every element, FALSE => swap only the
* all - true => swap every element, false => swap only the
* multi-precision storage
*
* returns:
@@ -370,7 +370,7 @@ swap_HALFs(HALF *dest, HALF *src, LEN len)
* Little Endian) the elements of a ZVALUE.
*/
ZVALUE *
swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, bool all)
{
/*
* allocate storage if needed
@@ -407,7 +407,7 @@ swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
*/
if (all) {
SWAP_B16_IN_LEN(&dest->len, &src->len);
SWAP_B16_IN_BOOL(&dest->sign, &src->sign);
SWAP_B16_IN_bool(&dest->sign, &src->sign);
} else {
dest->len = src->len;
dest->sign = src->sign;
@@ -427,7 +427,7 @@ swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a NUMBER to swap
* all - TRUE => swap every element, FALSE => swap only the
* all - true => swap every element, false => swap only the
* multi-precision storage
*
* returns:
@@ -437,7 +437,7 @@ swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
* Little Endian) the elements of a NUMBER.
*/
NUMBER *
swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, bool all)
{
/*
* allocate storage if needed
@@ -491,7 +491,7 @@ swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a COMPLEX to swap
* all - TRUE => swap every element, FALSE => swap only the
* all - true => swap every element, false => swap only the
* multi-precision storage
*
* returns:
@@ -501,7 +501,7 @@ swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
* Little Endian) the elements of a COMPLEX.
*/
COMPLEX *
swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, bool all)
{
/*
* allocate storage if needed
@@ -555,7 +555,7 @@ swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a ZVALUE to swap
* all - TRUE => swap every element, FALSE => swap only the
* all - true => swap every element, false => swap only the
* multi-precision storage
*
* returns:
@@ -565,7 +565,7 @@ swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
* Little Endian) the elements of a ZVALUE.
*/
ZVALUE *
swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, bool all)
{
/*
* allocate storage if needed
@@ -603,7 +603,7 @@ swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
*/
if (all) {
SWAP_HALF_IN_LEN(&dest->len, &src->len);
SWAP_HALF_IN_BOOL(&dest->sign, &src->sign);
SWAP_HALF_IN_bool(&dest->sign, &src->sign);
} else {
dest->len = src->len;
dest->sign = src->sign;
@@ -623,7 +623,7 @@ swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a NUMBER to swap
* all - TRUE => swap every element, FALSE => swap only the
* all - true => swap every element, false => swap only the
* multi-precision storage
*
* returns:
@@ -633,7 +633,7 @@ swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
* Little Endian) the elements of a NUMBER.
*/
NUMBER *
swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, bool all)
{
/*
* allocate storage if needed
@@ -687,7 +687,7 @@ swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a COMPLEX to swap
* all - TRUE => swap every element, FALSE => swap only the
* all - true => swap every element, false => swap only the
* multi-precision storage
*
* returns:
@@ -697,7 +697,7 @@ swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
* Little Endian) the elements of a COMPLEX.
*/
COMPLEX *
swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, bool all)
{
/*
* allocate storage if needed

View File

@@ -4,13 +4,7 @@
#
# Copyright (C) 1999-2006,2017,2021-2023 Landon Curt Noll
#
# SRC: cal/Makefile
#
# The "# SRC: ... - ..." comment line above indicates
# the origin of this file.
#
# IMPORTANT: Please see the section on Makefiles near the
# bottom of the HOWTO.INSTALL file.
# Suggestion: Read the ../HOWTO.INSTALL file.
#
# 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
@@ -29,184 +23,64 @@
# Under source code control: 1991/07/21 05:00:54
# File existed as early as: 1991
#
# This calculator first developed by David I. Bell with help/mods from others.
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
#
# calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# The shell used by this Makefile
#
# On some systems, /bin/sh is a rather reduced shell with
# deprecated behavior.
#
# If your system has a up to date, bash shell, then
# you may wish to use:
#
# SHELL= bash
#
# On some systems such as macOS, the bash shell is very
# far behind to the point where is cannot be depended on.
# On such systems, the sh may be a much better alternative
# shell for this Makefile to use:
#
# SHELL= sh
#
SHELL= bash
#SHELL= sh
#if 0 /* start of skip for non-Gnu makefiles */
#
ifeq ($(target),Darwin)
SHELL:= /bin/sh
endif
#endif /* end of skip for non-Gnu makefiles */
# SUGGESTION: Instead of modifying this file, consider adding
# statements to modify, replace or append Makefile
# variables in the ../Makefile.local file.
####
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
####
# PREFIX - Top level location for calc
#
# The PREFIX is often prepended to paths within calc and calc Makefiles.
#
# Starting with calc v2.13.0.1, nearly all Makefile places that used
# /usr/local now use ${PREFIX}. An exception is the olduninstall rule
# and, of course, this section. :-)
#
# NOTE: The ${PREFIX} is not the same as ${T}. The ${T} specifies
# a top level directory under which calc installs things.
# While usually ${T} is empty, it can be specific path
# as if calc where "chrooted" during an install.
# The ${PREFIX} value, during install, is a path between
# the top level ${T} install directory and the object
# such as an include file.
#
# NOTE: See also, ${T}, below.
#
# There are some paths that do NOT call under ${PREFIX}, such as
# ${CALCPATH}, that include paths not under ${PREFIX}, but those
# too are exceptions to this general rule.
#
# When in doubt, try:
#
# PREFIX= /usr/local
#
PREFIX= /usr/local
#PREFIX= /usr
#PREFIX= /usr/global
###########################################
# Files used or included by this Makefile #
###########################################
# Normally certain files depend on the Makefile. If the Makefile is
# changed, then certain steps should be redone. If MAKE_FILE is
# set to Makefile, then these files will depend on Makefile. If
# MAKE_FILE is empty, then they wont.
# MAKE_FILE is empty, then they won't.
#
# If in doubt, set MAKE_FILE to Makefile
#
MAKE_FILE= Makefile
# Where the system include (.h) files are kept
#
# For DJGPP, select:
#
# INCDIR= /dev/env/DJDIR/include
#
# If in doubt, set:
#
# INCDIR= /usr/include
# Calc configuration and compile configuration values
#
CONFIG_MKF= ../Makefile.config
#INCDIR= ${PREFIX}/include
#INCDIR= /dev/env/DJDIR/include
INCDIR= /usr/include
# Host target information.
#
TARGET_MKF= ../Makefile.target
# where to install calc related things
# Local file that is included just prior to the first rule,
# that allows one to override any values set in this Makefile.
#
# ${BINDIR} where to install calc binary files
# ${LIBDIR} where calc link library (*.a) files are installed
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
#
# NOTE: The install rule prepends installation paths with ${T}, which
# by default is empty. If ${T} is non-empty, then installation
# locations will be relative to the ${T} directory.
#
# For DJGPP, select:
#
# BINDIR= /dev/env/DJDIR/bin
# LIBDIR= /dev/env/DJDIR/lib
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
#
# If in doubt, set:
#
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
#
#BINDIR= ${PREFIX}/bin
#BINDIR= /dev/env/DJDIR/bin
BINDIR= /usr/bin
LOCAL_MKF= ../Makefile.local
#LIBDIR= ${PREFIX}/lib
#LIBDIR= /dev/env/DJDIR/lib
LIBDIR= /usr/lib
# The set of Makefiles
#
MK_SET= ${MAKE_FILE} ${CONFIG_MKF} ${TARGET_MKF} ${LOCAL_MKF}
#CALC_SHAREDIR= ${PREFIX}/lib/calc
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
CALC_SHAREDIR= /usr/share/calc
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
# ---------------------------------------------------------------
# ${HELPDIR} where the help directory is installed
# ${CALC_INCDIR} where the calc include files are installed
# ${SCRIPTDIR} where calc shell scripts are installed
#
# NOTE: The install rule prepends installation paths with ${T}, which
# by default is empty. If ${T} is non-empty, then installation
# locations will be relative to the ${T} directory.
#
# If in doubt, set:
#
# HELPDIR= ${CALC_SHAREDIR}/help
# CALC_INCDIR= ${INCDIR}/calc
# SCRIPTDIR= ${BINDIR}/cscript
#
HELPDIR= ${CALC_SHAREDIR}/help
CALC_INCDIR= ${INCDIR}/calc
SCRIPTDIR= ${BINDIR}/cscript
#######################################################
# Calc configuration and compile configuration values #
#######################################################
include ${CONFIG_MKF}
###############################
# host target section include #
###############################
include ${TARGET_MKF}
##########################################################################
#=-=-=-=-=- Be careful if you change something below this line -=-=-=-=-=#
##########################################################################
# T - top level directory under which calc will be installed
#
# The calc install is performed under ${T}, the calc build is
# performed under /. The purpose for ${T} is to allow someone
# to install calc somewhere other than into the system area.
#
# For example, if:
#
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
#
# and if:
#
# T= /var/tmp/testing
#
# Then the installation locations will be:
#
# calc binary files: /var/tmp/testing/usr/bin
# calc link library: /var/tmp/testing/usr/lib
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
# ... etc ... /var/tmp/testing/...
#
# If ${T} is empty, calc is installed under /, which is the same
# top of tree for which it was built. If ${T} is non-empty, then
# calc is installed under ${T}, as if one had to chroot under
# ${T} for calc to operate.
#
# If in doubt, use T=
#
T=
# Makefile debug
#
@@ -240,52 +114,43 @@ H=@
V=@:
#V=@
# standard tools
#
CHMOD= chmod
CMP= cmp
CO= co
CP= cp
FMT= fmt
MKDIR= mkdir
MV= mv
RM= rm
RMDIR= rmdir
SED= sed
SORT= sort
TOUCH= touch
TRUE= true
# The calc files to install
#
# This list is produced by the detaillist rule when no WARNINGS are detected.
#
# Please use:
#
# make calc_files_list
# make clobber >/dev/null && make calc_files_list
#
# to keep this list in nice sorted order.
#
CALC_FILES= README alg_config.cal beer.cal bernoulli.cal \
bernpoly.cal bigprime.cal bindings brentsolve.cal chi.cal chrem.cal \
comma.cal constants.cal deg.cal dms.cal dotest.cal ellip.cal \
factorial.cal factorial2.cal gvec.cal hello.cal hms.cal infinities.cal \
intfile.cal intnum.cal lambertw.cal linear.cal lnseries.cal lucas.cal \
lucas_chk.cal mersenne.cal mfactor.cal mod.cal natnumset.cal \
palindrome.cal pell.cal pi.cal pix.cal pollard.cal poly.cal prompt.cal \
psqrt.cal qtime.cal quat.cal randbitrun.cal randmprime.cal \
randombitrun.cal randomrun.cal randrun.cal regress.cal repeat.cal \
screen.cal seedrandom.cal set8700.cal set8700.line smallfactors.cal \
solve.cal specialfunctions.cal statistics.cal strings.cal sumsq.cal \
sumtimes.cal surd.cal test1700.cal test2300.cal test2600.cal \
test2700.cal test3100.cal test3300.cal test3400.cal test3500.cal \
test4000.cal test4100.cal test4600.cal test5100.cal test5200.cal \
test8400.cal test8500.cal test8600.cal test8900.cal toomcook.cal \
unitfrac.cal varargs.cal xx_print.cal zeta2.cal
factorial.cal factorial2.cal fnv_tool.cal gvec.cal hello.cal hms.cal \
infinities.cal intfile.cal intnum.cal lambertw.cal linear.cal \
lnseries.cal lucas.cal lucas_chk.cal mersenne.cal mfactor.cal mod.cal \
natnumset.cal palindrome.cal pell.cal pi.cal pix.cal pollard.cal \
poly.cal prompt.cal psqrt.cal qtime.cal quat.cal randbitrun.cal \
randmprime.cal randombitrun.cal randomrun.cal randrun.cal regress.cal \
repeat.cal screen.cal seedrandom.cal set8700.line smallfactors.cal \
solve.cal specialfunctions.cal splitbits.cal statistics.cal \
strings.cal sumsq.cal sumtimes.cal surd.cal test2300.obj_incdec.cal \
test2600.numfunc.cal test2700.isqrt.cal test3100.matobj.cal \
test3300.det.cal test3400.trig.cal test4000.ptest.cal \
test4100.redc.cal test4600.fileop.cal test5100.newdecl.cal \
test5200.globstat.cal test8000.read.cal test8400.quit.cal \
test8500.divmod.cal test8600.maxargs.cal test8700.dotest.cal \
test8900.special.cal test9300.frem.cal test9500.trigeq.cal \
toomcook.cal unitfrac.cal varargs.cal write2file.cal xx_print.cal \
zeta2.cal
# These calc files are now obsolete and are removed by the install rule.
#
DEAD_CALC_FILES= lucas_tbl.cal
DEAD_CALC_FILES= lucas_tbl.cal set8700.cal test1700.cal test2300.cal test2600.cal \
test2700.cal test3100.cal test3300.cal test3400.cal test3500.cal test4000.cal \
test4100.cal test4600.cal test5100.cal test5200.cal test8400.cal test8500.cal \
test8600.cal test8900.cal
# These files are found (but not built) in the distribution
#
@@ -299,8 +164,24 @@ CALCLIBLIST=
#
PHONY= all clobber distlist install
############################################################
# Allow Makefile.local to change any of the above settings #
############################################################
include ${LOCAL_MKF}
###########################################
# all - First and default Makefile target #
###########################################
all: ${CALC_FILES} ${MAKE_FILE} .all
###############################
# additional Makefile targets #
###############################
# used by the upper level Makefile to determine of we have done all
#
.all:
@@ -381,14 +262,10 @@ clobber: clean
echo ${RM} -rf .DS_Store; \
${RM} -rf .DS_Store; \
fi
-${Q} for i in ${DEAD_CALC_FILES} /dev/null; do \
-${Q} for i in ${DEAD_CALC_FILES} test082.cal outfile /dev/null; do \
if [ "$$i" = "/dev/null" ]; then \
continue; \
fi; \
if [ -e "${T}${CALC_SHAREDIR}/$$i" ]; then \
echo "${RM} -f ${T}${CALC_SHAREDIR}/$$i"; \
${RM} -f ${T}${CALC_SHAREDIR}/$$i; \
fi; \
if [ -e "./$$i" ]; then \
echo "${RM} -f ./$$i"; \
${RM} -f ./$$i; \

View File

@@ -388,6 +388,13 @@ dotest.cal
dotest("set8700.line");
ellip.cal
efactor(iN, ia, B, force)
Attempt to factor using the elliptic functions: y^2 = x^3 + a*x + b.
factorial.cal
factorial(n)
@@ -548,12 +555,65 @@ factorial2.cal
for information on falling factorials.
ellip.cal
fnv_util.cal
efactor(iN, ia, B, force)
Utility tools for FNV hash and "FNV-style" hash operations.
Attempt to factor using the elliptic functions: y^2 = x^3 + a*x + b.
These functions, if given non-standard values, will produce bogus results.
In some cases, such as specifying the number of bits in the hash,
using a non-power of 2 bit will produce a result that may work,
but the hash will be only an "FNV-style" hash and not a true FNV hash.
find_fnv_prime(bits)
If bits == null(), this function will attempt to prompt stdin
for a value and provide commends on the value of bits.
given:
bits number of bits in the hash, null() ==> prompt for value
returns:
0 ==> no FNV prime found
>0 ==> FNV prime
deprecated_fnv0(bits, fnv_prime, string)
If fnv_prime == null(), this function will try to compute the FNV prime
for a hash of size bits.
given:
bits number of bits in FNV hash
fnv_prime FNV prime, null() ==> generate suitable FNV prime if possible
string string to hash
returns:
FNV-0 hash, for size bytes, of string
NOTE: This function does NOT attempt to determine that fnv_prime is prime.
fnv_offset_basis(bits, fnv_prime)
given:
bits number of bits in FNV hash
fnv_prime FNV prime, null() ==> generate suitable FNV prime if possible
returns:
FNV offset basis for a hash size of bits and an FNV prime of fnv_prime
NOTE: This function does NOT attempt to determine that fnv_prime is prime.
fnv1a_style_hash(bits, fnv_prime, prev_hash, string)
given:
bits number of bits in FNV hash
fnv_prime FNV prime, null() ==> generate suitable FNV prime if possible
prev_hash previous hash value, null() ==> generate FNV offset basis
string string to hash
returns:
"FNV-style" hash of bits
NOTE: This function does NOT attempt to determine that fnv_prime is prime.
gvec.cal
@@ -1070,7 +1130,7 @@ randbitrun.cal
the number and length of identical bits runs match what is expected.
By default, run_cnt is to test the next 65536 random values.
This tests the a55 generator.
This tests the subtractive 100 shuffle pseudo-random number generator.
randmprime.cal
@@ -1117,7 +1177,7 @@ randrun.cal
64 bit values. By default, run_cnt is to test the next 65536
random values.
This tests the a55 generator.
This tests the subtractive 100 shuffle pseudo-random number generator.
repeat.cal
@@ -1208,18 +1268,6 @@ seedrandom.cal
Blum primes for the modulus.
set8700.cal
set8700_getA1() defined
set8700_getA2() defined
set8700_getvar() defined
set8700_f(set8700_x) defined
set8700_g(set8700_x) defined
Declare globals and define functions needed by dotest() (see
dotest.cal) to evaluate set8700.line a line at a time.
set8700.line
A line-by-line evaluation file for dotest() (see dotest.cal).
@@ -1433,6 +1481,60 @@ specialfunctions.cal
on the script zeta2.cal.
splitbits.cal
splitbits(x, b)
Given an integer x, split the value into a list of integers,
each of which is at most b bits long.
The value b must be an integer > 0.
The number of elements in the returned list is:
ceil((highbit(x) + 1) / b)
If x == 0, then a list of 1 element containing 0 is returned.
If x < 0, then the two's compliment of abs(x) is returned.
Even though calc represents negative integers as positive values
with sign bit, the bits returned by this function are as if
the integer converted as if the integer was a two's compliment
value. For example:
; L = splitbits(-1, 8);
; print L[[0]]
255
; L = splitbits(-2, 8);
; print L[[0]]
254
; L = splitbits(-3, 8);
; print L[[0]]
253
The first element of the list contains the lowest order bits
of x. The last element of the list contains the highest number
bits of x.
For example:
; x = 2^23209-1
; L = splitbits(x, 16);
; print size(L), L[[0]]
; print istype(2, 3i), istype(2, "2"), istype(2, null())
0 0 0
; mat a[2]
; b = list(1,2,3)
; c = assoc()
; obj chongo {was, here} d;
; print istype(a,b), istype(b,c), istype(c,d)
0 0 0
statistics.cal
gammaincoctave(z,a)
@@ -1553,15 +1655,7 @@ surd.cal
Calculate using quadratic surds of the form: a + b * sqrt(D).
test1700.cal
value
This resource files is used by regress.cal to test the read and
use keywords.
test2600.cal
test2600.numfunc.cal
global defaultverbose
global err
@@ -1587,7 +1681,7 @@ test2600.cal
functions in terms of accuracy and roundoff.
test2700.cal
test2700.isqrt.cal
global defaultverbose
mknonnegreal()
@@ -1610,7 +1704,7 @@ test2700.cal
complex values.
test3100.cal
test3100.matobj.cal
obj res
global md
@@ -1625,7 +1719,7 @@ test3100.cal
a matrix.
test3300.cal
test3300.det.cal
global defaultverbose
global err
@@ -1637,7 +1731,7 @@ test3300.cal
determinant tests.
test3400.cal
test3400.trig.cal
global defaultverbose
global err
@@ -1652,22 +1746,8 @@ test3400.cal
This resource file is used by regress.cal to test trig functions.
containing objects.
test3500.cal
global defaultverbose
global err
testfrem(x, y, verbose)
testgcdrem(x, y, verbose)
testf(str, n, verbose)
testg(str, n, verbose)
testh(str, n, N, verbose)
test3500(verbose, n, N)
This resource file is used by regress.cal to test the functions frem,
fcnt, gcdrem.
test4000.cal
test4000.ptest.cal
global defaultverbose
global err
@@ -1700,7 +1780,7 @@ test4000.cal
prevcand builtins.
test4100.cal
test4100.redc.cal
global defaultverbose
global err
@@ -1720,7 +1800,7 @@ test4100.cal
This resource file is used by regress.cal to test REDC operations.
test4600.cal
test4600.fileop.cal
stest(str [, verbose]) defined
ttest([m, [n [,verbose]]]) defined
@@ -1732,7 +1812,7 @@ test4600.cal
This resource file is used by regress.cal to test searching in files.
test5100.cal
test5100.newdecl.cal
global a5100
global b5100
@@ -1742,7 +1822,7 @@ test5100.cal
declaration scope and order.
test5200.cal
test5200.globstat.cal
global a5200
static a5200
@@ -1754,7 +1834,7 @@ test5200.cal
global/static bug.
test8400.cal
test8400.quit.cal
test8400() defined
@@ -1762,7 +1842,7 @@ test8400.cal
memory leaks.
test8500.cal
test8500.divmod.cal
global err_8500
global L_8500
@@ -1775,7 +1855,7 @@ test8500.cal
This resource file is used by regress.cal to the // and % operators.
test8600.cal
test8600.maxargs.cal
global min_8600
global max_8600
@@ -1786,7 +1866,19 @@ test8600.cal
allowing up to 1024 args to be passed to a builtin function.
test8900.cal
test8700.dotest.cal
set8700_getA1() defined
set8700_getA2() defined
set8700_getvar() defined
set8700_f(set8700_x) defined
set8700_g(set8700_x) defined
Declare globals and define functions needed by dotest() (see
dotest.cal) to evaluate set8700.line a line at a time.
test8900.special.cal
This function tests a number of calc resource functions contributed
by Christoph Zurnieden. These include:
@@ -1804,11 +1896,19 @@ test8900.cal
zeta2.cal
unitfrac.cal
test9300.frem.cal
unitfrac(x)
global defaultverbose
global err
testfrem(x, y, verbose)
testgcdrem(x, y, verbose)
testf(str, n, verbose)
testg(str, n, verbose)
testh(str, n, N, verbose)
test3500(verbose, n, N)
Represent a fraction as sum of distinct unit fractions.
This resource file is used by regress.cal to test the functions frem,
fcnt, gcdrem.
toomcook.cal
@@ -1834,6 +1934,13 @@ toomcook.cal
squaring functions act in the same way.
unitfrac.cal
unitfrac(x)
Represent a fraction as sum of distinct unit fractions.
varargs.cal
sc(a, b, ...)
@@ -1841,6 +1948,17 @@ varargs.cal
Example program to use 'varargs'. Program to sum the cubes of all
the specified numbers.
write2file.cal
w2f(filename,stream,fmt,value) defined
wd2f(value) defined
wx2f(value) defined
write results to file
This resource file serves as an example of how to perform file
I/O. This write2file hows how to perform file I/O and is provided
as an illustrative example.
xx_print.cal
@@ -1869,7 +1987,7 @@ zeta2.cal
for information on this special zeta function.
## Copyright (C) 2000,2014,2017,2021 David I. Bell and Landon Curt Noll
## Copyright (C) 2000,2014,2017,2021,2023 David I. Bell and Landon Curt Noll
##
## Primary author: Landon Curt Noll
##

View File

@@ -1,7 +1,7 @@
/*
* ellip - attempt to factor numbers using elliptic functions
*
* Copyright (C) 1999 David I. Bell
* Copyright (C) 1999,2023 David I. Bell
*
* 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
@@ -53,7 +53,7 @@
* B is the limit of the primes that make up the high power that the
* point is raised to for each factoring attempt (default 100).
* force is a flag to attempt to factor numbers even if they are
* thought to already be prime (default FALSE).
* thought to already be prime (default false).
*
* Making B larger makes the power the point being raised to contain more
* prime factors, thus increasing the chance that the order of the point

473
cal/fnv_tool.cal Normal file
View File

@@ -0,0 +1,473 @@
/*
* fnv_util - utility tools for FNV hash and "FNV-style" hash operations
*
* This file provides the following functions:
*
* find_fnv_prime(bits)
* deprecated_fnv0(bits, fnv_prime, string)
* fnv_offset_basis(bits, fnv_prime)
* fnv1a_style_hash(bits, fnv_prime, prev_hash, string)
*
* See the individual function for details on args and return value.
*
* If no args are given to find_fnv_prime() and stdin is associated
* with a tty (i.e., an interactive terminal), then bits will be
* prompted for and commentary will be printed to stdout as well.
*
* If fnv_prime == null(), then an attempt to compute the FNV prime
* for a hash if size bits is attempted..
*
* If prev_hash == null(), then the FNV offset basis for
* for a hash if size bits is computed.
*
* For more information on the FNV hash see:
*
* https://en.wikipedia.org/wiki/Fowler-Noll-Vo_hash_function
* http://www.isthe.com/chongo/tech/comp/fnv/index.html
*
* IMPORTANT NOTE:
*
* These functions, if given non-standard values, will produce bogus results.
* In some cases, such as specifying the number of bits in the hash,
* using a non-power of 2 bit will produce a result that may work,
* but the hash will be only an "FNV-style" hash and not a true FNV hash.
*
* We say "FNV-style" because the result hash is not a "true FNV-like" hash.
*
* Let integer n > 0 be the number if bits in the FNV hash. Then:
*
* t = floor((5+n)/12)
*
* The FNV prime, for the given n bits is the smallest prime of the form:
*
* p = 256^t + 2^8 + b
*
* such that:
*
* 0 < b < 2^8
* The number of one-bits in b must be 4 or 5
* p mod (2^40 - 2^24 - 1) > (2^24 + 2^8 + 2^7)
*
* If you force n to not be a power of 2, for example:
*
* n = 44
*
* you will find that the FNV prime for 44 bits is:
*
* p44 = 4294967597
* = 0x10000012d
* = 0b100000000000000000000000100101101
* = 2^32 + 301 = 2^32 + 2^8 + 2^5 + 2^3 + 2^2 + 2^0
*
* However a hash size of 44 bits is not a true FNV hash, it is only a "FNV-style" hash.
*
* NOTE: We disallow n <= 31 because there are no FNV primes that small.
*
* NOTE: For n that is a power of 2 and n > 1024, you will find that
* that FNV primes become so rare that that one may not find a suitable
* FNV prime. For n = powers of 2 >= 2048 and <= 1048576,
* there is NO FNV primes.
*
* As for as hashing goes, large values of n, even if an
* FNV hash may be found, are unlikely to be truly useful. :-)
*/
/*
* Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright, this permission notice and text
* this comment, and the disclaimer below appear in all of the following:
*
* supporting documentation
* source copies
* source works derived from this source
* binaries derived from this source or from derived source
*
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* chongo (Landon Curt Noll, http://www.isthe.com/chongo/index.html) /\oo/\
*
* Share and enjoy! :-)
*/
/*
* find_fnv_prime - try to find a FNV prime given the number of bits
*
* If bits == null(), this function will attempt to prompt stdin
* for a value and provide commends on the value of bits.
*
* given:
* bits number of bits in the hash, null() ==> prompt for value
*
* returns:
* 0 ==> no FNV prime found
* >0 ==> FNV prime
*/
define find_fnv_prime(bits)
{
local b; /* lower octet of the potential FNV prime: [1,255] */
local p; /* value to test as an FNV prime */
local t; /* power of 256 part of the FNV prime */
local one_bits; /* number of 1 bits in b */
local p_minus_b; /* potential FNV prime less b */
local interactive; /* true ==> interactive mode and print commentary */
/*
* case: no arg, prompt for bits and print commentary
*/
interactive = 0; /* assume non-interactive mode */
if (isnull(bits)) {
/*
* must be attached to an interactive terminal
*/
if (!isatty(files(0))) {
print "# FATAL: stdin is not a tty: not attached to an interactive terminal";
return 0;
}
interactive = 1; /* set interactive mode */
/*
* prompt for the number of bits
*/
do {
local strscanf_ret; /* return from strscanf_ret */
local input; /* value read after prompt */
/*
* prompt and obtain the input
*/
input = prompt("Enter hash size in bits: ");
strscanf_ret = strscanf(input, "%i", bits);
print "input =", input;
print "bits =", bits;
if (!isint(bits) || bits <= 0) {
print;
print "# NOTE: must enter a integer > 0, try again";
print;
}
} while (!isint(bits) || bits <= 0);
}
/*
* firewall - bits must be non-negative integer
*/
if (!isint(bits) || bits < 0) {
if (interactive) {
print "# FATAL: bits must be non-negative integer";
}
return 0;
}
/*
* provide commentary on the choice of bits if we are interactive
*/
if (interactive) {
if (popcnt(bits) == 1) {
if (bits > 1024) {
print "# WARNING: FNV primes for bit size powers of 2 > 1024 are extremely rare.";
print "# WARNING: There are no FNV primes for bit size powers of 2 >= 2048 and <= 1048576.";
}
print "n =", bits;
} else {
if (bits < 32) {
print "# WARNING: bits < 32 is not recommended because there isn't enough bits to be worth hashing";
}
print "# WARNING: because bits is not a power of 2, we can only form an \"FNV-style hash\": not a true FNV hash.";
print "# WARNING: A \"FNV-style hash\" may not have the desired hash properties of a true FNV hash.";
print "n =", bits;
}
}
/*
* search setup
*/
t = floor((5+bits)/12);
p_minus_b = 256^t + 2^8;
/*
* search for a b that forms a suitable FNV prime
*/
for (b=1; b < 256; ++b) {
/*
* reject b unless the of one-bits in bottom octet of p is 4 or 5
*/
one_bits = popcnt(b);
if (one_bits != 4 && one_bits != 5) {
continue;
}
/*
* reject p if p mod (2^40 - 2^24 - 1) <= (2^24 + 2^8 + 2^7)
*/
p = p_minus_b + b;
if ((p % (2^40 - 2^24 - 1)) <= (2^24 + 2^8 + 2^7)) {
continue;
}
/*
* accept potential p value that is prime
*/
if (ptest(p) == 1) {
return p;
}
}
/*
* case: did not find an FNV prime
*/
if (b >= 256) {
/*
* examine results if interactive
*/
if (interactive) {
print "# FATAL: There is no a suitable FNV prime for bits =", bits;
quit "find_fnv_prime: FATAL: FNV prime search failed";
}
/*
* return 0 to indicate no FNV prime found
*/
return 0;
}
/*
* provide FNV commentary if interactive
*/
if (interactive) {
print "t =", t;
print "b =", b;
print "# NOTE: p = 256^":t, "+ 2^8 +", b;
print;
print "p =", p;
}
/*
* return FNV prime
*/
return p;
}
/*
* deprecated_fnv0 - FNV-0 hash that should only be used to generate an FNV offset basis
*
* If fnv_prime == null(), this function will try to compute the FNV prime
* for a hash of size bits.
*
* given:
* bits number of bits in FNV hash
* fnv_prime FNV prime, null() ==> generate suitable FNV prime if possible
* string string to hash
*
* returns:
* FNV-0 hash, for size bytes, of string
*
* NOTE: This function does NOT attempt to determine that fnv_prime is prime.
*/
define deprecated_fnv0(bits, fnv_prime, string)
{
local hash; /* FNV hash value */
local len; /* length of string */
local base; /* base of FNV hash: 2^bits */
local i;
/*
* firewall
*/
if (!isint(bits) || bits <= 0) {
quit "deprecated_fnv0: FATAL: bits arg must be an integer > 0";
}
if (!isstr(string)) {
quit "deprecated_fnv0: FATAL: string arg must be a string";
}
/*
* fnv_prime == null() means to try and generate the FNV prime
*/
if (isnull(fnv_prime)) {
/* try to generate an FNV prime */
fnv_prime = find_fnv_prime(bits);
if (fnv_prime == 0) {
quit "deprecated_fnv0: FATAL: no FNV prime exists for the given hash size in bits";
}
}
if (!isint(fnv_prime) || fnv_prime <= 0) {
quit "deprecated_fnv0: FATAL: fnv_prime arg must be an integer > 0 and should be prime";
}
/*
* FNV-0 hash each character
*/
len = strlen(string);
base = 2^bits;
hash = 0;
for (i=0; i < len; ++i) {
hash = xor((hash * fnv_prime) % base, ord(string[i]));
}
return hash;
}
/*
* fnv_offset_basis - generate and FNV offset basis
*
* given:
* bits number of bits in FNV hash
* fnv_prime FNV prime, null() ==> generate suitable FNV prime if possible
*
* returns:
* FNV offset basis for a hash size of bits and an FNV prime of fnv_prime
*
* NOTE: This function does NOT attempt to determine that fnv_prime is prime.
*/
define
fnv_offset_basis(bits, fnv_prime)
{
local fnv0_hash = 0; /* FNV-0 hash value */
/* string to generate a FNV offset basis - do not change this value */
static chongo_was_here = "chongo <Landon Curt Noll> /\\../\\";
/*
* firewall
*/
if (!isint(bits) || bits <= 0) {
quit "fnv_offset_basis: FATAL: bits arg must be an integer > 0";
}
/*
* fnv_prime == null() means to try and generate the FNV prime
*/
if (isnull(fnv_prime)) {
/* try to generate an FNV prime */
fnv_prime = find_fnv_prime(bits);
if (fnv_prime == 0) {
quit "fnv_offset_basis: FATAL: no FNV prime exists for the given hash size in bits";
}
}
if (!isint(fnv_prime) || fnv_prime <= 0) {
quit "fnv_offset_basis: FATAL: fnv_prime arg must be an integer > 0 and should be prime";
}
/*
* return the FNV-0 hash of fnv_offset_basis as the FNV offset basis
*/
fnv0_hash = deprecated_fnv0(bits, fnv_prime, chongo_was_here);
return fnv0_hash;
}
/*
* fnv_style_hash - compute an "FNV-1a-style" hash
*
* These functions, if given non-standard values, will produce bogus results.
* To produce a true FNV-1a hash:
*
* bits must be a power of 2
* 32 <= bits
* fnv_prime == find_fnv_prime(bits) OR fnv_prime == null()
* prev_hash == previous FNV hash OR prev_hash == null()
*
* If fnv_prime == null(), this function will try to compute the FNV prime
* for a hash of size bits.
*
* If prev_hash == null(), this function will try to compute the FNV offset basis
* for a hash of size bits.
*
* One may chain "FNV-style" hashes by replacing the offset_basis with
* the hash state of the previous hash. For the first hash:
*
* fnv_prime = find_fnv_prime(bits)
* hash_val = fnv_style_hash(bits, fnv_prime, null(), string_a);
*
* then:
*
* hash_val = fnv_style_hash(bits, fnv_prime, hash_val, string_b);
*
* This will produce the same as the string_a concatenated with string_b:
*
* hash_val = fnv_style_hash(bits, null(), null(), string_a + string_b);
*
* NOTE: Because string_a and string_b are strings, the expression:
*
* string_a + string_b
*
* is string_a concatenated with string_b.
*
* given:
* bits number of bits in FNV hash
* fnv_prime FNV prime, null() ==> generate suitable FNV prime if possible
* prev_hash previous hash value, null() ==> generate FNV offset basis
* string string to hash
*
* returns:
* "FNV-style" hash of bits
*
* NOTE: This function does NOT attempt to determine that fnv_prime is prime.
*/
define
fnv1a_style_hash(bits, fnv_prime, prev_hash, string)
{
local hash = 0; /* FNV hash value */
local len; /* length of string */
local base; /* base of FNV hash: 2^bits */
local i;
/*
* firewall
*/
if (!isint(bits) || bits <= 0) {
quit "fnv1a_style_hash: FATAL: bits arg must be an integer > 0";
}
if (!isstr(string)) {
quit "fnv1a_style_hash: FATAL: string arg must be a string";
}
/*
* fnv_prime == null() means to try and generate the FNV prime
*/
if (isnull(fnv_prime)) {
/* try to generate an FNV prime */
fnv_prime = find_fnv_prime(bits);
if (fnv_prime == 0) {
quit "fnv1a_style_hash: FATAL: no FNV prime exists for the given hash size in bits";
}
}
if (!isint(fnv_prime) || fnv_prime <= 0) {
quit "fnv1a_style_hash: FATAL: fnv_prime arg must be an integer > 0 and should be prime";
}
/*
* prev_hash == null() means to generate the FNV offset basis
*/
if (isnull(prev_hash)) {
/* generate the FNV offset basis for a hash of size bits */
prev_hash = fnv_offset_basis(bits, fnv_prime);
}
if (!isint(prev_hash) || prev_hash < 0) {
quit "fnv1a_style_hash: FATAL: prev_hash arg must be an integer => 0";
}
/*
* FNV-1a hash each character
*/
len = strlen(string);
base = 2^bits;
hash = prev_hash;
for (i=0; i < len; ++i) {
hash = xor((hash * fnv_prime) % base, ord(string[i]));
}
return hash;
}

View File

@@ -1,7 +1,7 @@
/*
* randbitrun - check rand bit run lengths of the a55 generator
* randbitrun - check rand bit run lengths of the subtractive 100 shuffle generator
*
* Copyright (C) 1999 Landon Curt Noll
* Copyright (C) 1999,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

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/*
* specialfunctions - special functions (e.g.: gamma, zeta, psi)
*
* Copyright (C) 2013,2021 Christoph Zurnieden
* Copyright (C) 2013,2021,2023 Christoph Zurnieden
*
* 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
@@ -802,8 +802,8 @@ define NUMBER_NEGATIVE_INFINITY()
return -(1 / epsilon());
}
static TRUE = 1;
static FALSE = 0;
static true = 1;
static false = 0;
define g(prec)
{
@@ -827,9 +827,9 @@ define __CZ__series_converged(new, old, max)
}
if (abs(re(new - old)) <= eps * abs(re(new))
&& abs(im(new - old)) <= eps * abs(im(new))) {
return TRUE;
return true;
}
return FALSE;
return false;
}
define __CZ__ei_power(z)

83
cal/splitbits.cal Normal file
View File

@@ -0,0 +1,83 @@
/*
* splitbits - split an integer into list on bit boundardies of a fixed size
*
* Copyright (C) 2018,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
* 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.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Under source code control: 2006/06/07 14:10:11
* File existed as early as: 2006
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
/*
* setup splitbits errors
*/
static E_SPLITBITS_1, E_SPLITBITS_2, E_SPLITBITS_3;
if (! iserror(E_SPLITBITS_1)) E_SPLITBITS_1 = newerror("1st argument to splitbits must be an integer");
if (! iserror(E_SPLITBITS_2)) E_SPLITBITS_2 = newerror("2nd argument to splitbits must be an integer");
if (! iserror(E_SPLITBITS_3)) E_SPLITBITS_3 = newerror("2nd argument must be an integer > 0");
/*
* define splitbits function
*/
define splitbits(x, b)
{
local ret; /* list to return */
local mask; /* 2^b-1 */
local x_is_reg = 0; /* true if x < 0 */
/* firewall */
if (! isint(x)) {
return error(E_SPLITBITS_1);
}
if (! isint(b)) {
return error(E_SPLITBITS_2);
}
if (b <= 0) {
return error(E_SPLITBITS_3);
}
/* special case: x == 0 */
if (x == 0) {
return list(0);
}
/* setup for splitting x */
ret = list();
mask = 2^b-1;
if (x < 0) {
x_is_reg = 1;
x = abs(x);
}
/* split x */
while (x > 0) {
printf("%d %x\n", size(ret), x);
if (x_is_reg) {
append(ret, xor(x & mask, mask));
} else {
append(ret, x & mask);
}
x >>= b;
}
/* return list */
return ret;
}

View File

@@ -1,7 +1,7 @@
/*
* test2300 - 2300 series of the regress.cal test suite
* test_obj_incdec.2300 - test object increment/decrement for test 23dd
*
* Copyright (C) 1999 Landon Curt Noll
* Copyright (C) 1999,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,7 +1,7 @@
/*
* test2600 - 2600 series of the regress.cal test suite
* test2600.builtin0 - test numeric functions extensively for test 26dd
*
* Copyright (C) 1999,2021 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2021,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,7 +1,7 @@
/*
* test2700 - 2700 series of the regress.cal test suite
* test2700.isqrt - test complex sqrt for test 27dd
*
* Copyright (C) 1999,2021 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2021,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,7 +1,7 @@
/*
* test3100 - 3100 series of the regress.cal test suite
* test3100.matobj - test matrix containing objects for test 31dd
*
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,7 +1,7 @@
/*
* test3300 - 3300 series of the regress.cal test suite
* test3300.det - test determinants of a matrix containing objects for test 31dd
*
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,7 +1,7 @@
/*
* test3400 - 3400 series of the regress.cal test suite
* test3400.trig - test common trig functions for test 34dd
*
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,7 +1,7 @@
/*
* test4000 - 4000 series of the regress.cal test suite
* test4000.ptest - test ptest, nextcand, prevcand for test 40dd
*
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,7 +1,7 @@
/*
* test4100 - 4100 series of the regress.cal test suite
* test4100.redc - test REDC operations for test 41dd
*
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,7 +1,7 @@
/*
* test4600 - 4600 series of the regress.cal test suite
* test4600.fileop - 4600 series of the regress.cal test suite
*
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,7 +1,7 @@
/*
* test5100 - 5100 series of the regress.cal test suite
* test5100.newdecl - test code generator declaration scope and order for test 51dd
*
* Copyright (C) 1999,2021 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2021,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,7 +1,7 @@
/*
* test5200 - 5200 series of the regress.cal test suite
* test5200.globstat - test the fix of an old global/static bug for test 52dd
*
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,7 +1,7 @@
/*
* test1700 - 1700 series of the regress.cal test suite
* test8000.read - test read operation for test 80dd
*
* Copyright (C) 1999 Landon Curt Noll
* Copyright (C) 1999,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,7 +1,7 @@
/*
* test8400 - 8400 series of the regress.cal test suite
* test8400.quit - test quit for test 84dd
*
* Copyright (C) 1999 Landon Curt Noll
* Copyright (C) 1999,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,7 +1,7 @@
/*
* test8500 - 8500 series of the regress.cal test suite
* test8500.divmod - test // and % with various rounding mode for test 85dd
*
* Copyright (C) 1999,2021 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2021,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*

View File

@@ -1,5 +1,5 @@
/*
* test8600 - 8600 series of the regress.cal test suite
* test8600.maxargs - test up to 1024 args being passed to a builtin function for test 86dd
*
* Copyright (C) 2000 Landon Curt Noll
*

View File

@@ -1,7 +1,7 @@
/*
* set8700 - environment for dotest line tests for the 8700 set of regress.cal
* test8700.dotest - environment for dotest line tests for test 87dd
*
* Copyright (C) 2006 Ernest Bowen and Landon Curt Noll
* Copyright (C) 2006,2023 Ernest Bowen and 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,7 +1,7 @@
/*
* test8900 - 8900 series of the regress.cal test suite
* test8900.special - test calc resource functions by Christoph Zurnieden for test 89dd
*
* Copyright (C) 2013,2021 Christoph Zurnieden
* Copyright (C) 2013,2021,2023 Christoph Zurnieden
*
* 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,7 +1,7 @@
/*
* test3500 - 3500 series of the regress.cal test suite
* test9300.frem - test of functions frem, fcnt, gcdrem for test 93dd
*
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
* Copyright (C) 1999,2023 Ernest Bowen and Landon Curt Noll
*
* Primary author: Ernest Bowen
*
@@ -255,16 +255,16 @@ define testh(str,n,N,verbose)
}
/*
* test3500 - perform all of the above tests a bunch of times
* test9300 - perform all of the above tests a bunch of times
*/
define test3500(verbose, tnum, n, N)
define test9300(verbose, tnum, n, N)
{
/* set test parameters */
if (isnull(verbose)) {
verbose = defaultverbose;
}
if (isnull(tnum)) {
tnum = 3501; /* default test number */
tnum = 9301; /* default test number */
}
if (isnull(n)) {
n = 200;
@@ -276,7 +276,7 @@ define test3500(verbose, tnum, n, N)
/*
* test a lot of stuff
*/
srand(3500e3500);
srand(9300e9300);
err += testf(strcat(str(tnum++), ": frem/fcnt"), n, verbose);
err += testg(strcat(str(tnum++), ": gcdrem"), n, verbose);
err += testh(strcat(str(tnum++),": gcdrem #2"), n, N, verbose);

1433
cal/test9500.trigeq.cal Normal file

File diff suppressed because it is too large Load Diff

121
cal/write2file.cal Normal file
View File

@@ -0,0 +1,121 @@
/*
* write2file - write results to file
*
* This resource file serves as an example of how to perform file I/O.
* This write2file hows how to perform file I/O and is provided as
* an illustrative example.
*
* Copyright (C) 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
* 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.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Under source code control: 2023/08/20 13:13:11
* 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/
*/
static outfilename; /* where to write stuff */
static outfile; /* open file stream on which to write */
static stderr; /* write errors to standard error */
/*
* setup
*/
if (!isstr(outfilename)) {
outfilename = "./outfile";
}
if (!isfile(stderr)) {
stderr = files(2);
if (!isfile(stderr)) {
printf("Warning: stderr as files(2) is not a file!\n");
}
}
/*
* try to create or open and truncate the outfile
*/
if (!isfile(outfile)) {
/* open outfilename for writing at the beginning */
outfile = fopen(outfilename, "w");
/* firewall - check for failing to open */
if (!isfile(outfile)) {
fprintf(stderr, "failed to open: %s error(%d): %s\n", outfilename, errno(outfile), strerror(outfile));
}
}
/*
* write a value to a file given a format
*/
define w2f(filename, stream, fmt, value) {
/* firewall */
if (!isfile(stderr)) {
printf("stderr is not an open file\n");
return;
}
if (!isstr(filename)) {
fprintf(stderr, "filename argument is not a string\n");
return;
}
if (!isfile(stream)) {
fprintf(stderr, "stream argument is not an open file\n");
return;
}
if (!isstr(fmt)) {
fprintf(stderr, "fmt argument is not a string\n");
return;
}
if (!isnum(value)) {
fprintf(stderr, "value argument is not a numeric value\n");
return;
}
/* write value in decimal */
fprintf(stream, fmt, value);
if (ferror(stream)) {
fprintf(stderr, "error in writing to file: %s error(%d): %s\n", filename, errno(stream), strerror(stream));
return;
}
/* flush to be sure it is completely written */
fflush(outfile);
if (ferror(outfile)) {
fprintf(stderr, "error in flushing to file: %s error(%d): %s\n", filename, errno(stream), strerror(stream));
}
return;
}
/*
* wd2f - write a value to an open file in decimal
*/
define wd2f(value) {
return w2f(outfilename, outfile, "%d\n", value);
}
/*
* wx2f - write a value to an open file in hexadecimal
*/
define wx2f(value) {
return w2f(outfilename, outfile, "%x\n", value);
}

114
calc.c
View File

@@ -1,9 +1,7 @@
/*
* calc - arbitrary precision calculator
*
* Copyright (C) 1999-2013,2021,2022 David I. Bell, Landon Curt Noll and Ernest Bowen
*
* Primary author: David I. Bell
* Copyright (C) 1999-2013,2021-2023 David I. Bell, Landon Curt Noll and Ernest Bowen
*
* 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
@@ -84,7 +82,7 @@
#include "have_unused.h"
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -93,7 +91,7 @@
*/
S_FUNC void intint(int arg); /* interrupt routine */
S_FUNC void calc_interrupt(char *fmt, ...);
S_FUNC int nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr);
S_FUNC int nextcp(char **cpp, int *ip, int argc, char **argv, bool haveendstr);
S_FUNC void set_run_state(run state);
/*
@@ -111,10 +109,10 @@ main(int argc, char **argv)
char *cp;
char *endcp;
char *bp;
BOOL done = FALSE;
BOOL havearg;
BOOL haveendstr;
BOOL stdin_closed = FALSE;
bool done = false;
bool havearg;
bool haveendstr;
bool stdin_closed = false;
size_t len;
/*
@@ -135,7 +133,7 @@ main(int argc, char **argv)
index = 1;
cp = endcp = NULL;
maxindex = argc;
havecommands = FALSE;
havecommands = false;
while (index < maxindex && !done) {
cp = argv[index];
if (*cp == '\0') {
@@ -143,9 +141,9 @@ main(int argc, char **argv)
continue;
}
for (;;) {
havearg = FALSE;
havearg = false;
if (*cp != '-') {
done = TRUE;
done = true;
break;
}
++cp;
@@ -153,7 +151,7 @@ main(int argc, char **argv)
cp++;
while (*cp == ' ')
++cp;
done = TRUE;
done = true;
break;
}
@@ -164,9 +162,33 @@ main(int argc, char **argv)
switch (c) {
case 'C':
#if defined(CUSTOM)
allow_custom = TRUE;
/*
* error if libcustcalc was compiled with CUSTOM undefined
*/
if (custom_compiled() != true) {
math_error("%s: calc was built with custom functions enabled, "
"custom_compiled() returned: %d != %d",
program, custom_compiled(), true);
exit(1);
}
/*
* indicate that custom functions are now allowed
*/
allow_custom = true;
break;
#else /* CUSTOM */
/*
* error if libcustcalc was compiled with CUSTOM defined
*/
if (custom_compiled() != false) {
math_error("%s: calc was built with custom functions disabled, "
"custom_compiled() returned: %d != %d",
program, custom_compiled(), false);
}
/*
* we are too early in processing to
* call libcalc_call_me_last() -
@@ -179,13 +201,13 @@ main(int argc, char **argv)
exit(1);
#endif /* CUSTOM */
case 'e':
no_env = TRUE;
no_env = true;
break;
case 'h':
want_defhelp = 1;
break;
case 'i':
i_flag = TRUE;
i_flag = true;
break;
case 'm':
cp++;
@@ -222,7 +244,7 @@ main(int argc, char **argv)
fprintf(stderr, "??? m-arg");
exit(4);
}
havearg = TRUE;
havearg = true;
break;
case 'n':
/*
@@ -231,22 +253,22 @@ main(int argc, char **argv)
*/
break;
case 'O':
use_old_std = TRUE;
use_old_std = true;
break;
case 'p':
p_flag = TRUE;
p_flag = true;
break;
case 'q':
q_flag = TRUE;
q_flag = true;
break;
case 'u':
u_flag = TRUE;
u_flag = true;
break;
case 'c':
c_flag = TRUE;
c_flag = true;
break;
case 'd':
d_flag = TRUE;
d_flag = true;
break;
case 'v':
/*
@@ -273,12 +295,12 @@ main(int argc, char **argv)
* calc_debug:resource_debug:user_debug
*/
if (nextcp(&cp, &index, argc, argv,
FALSE)) {
false)) {
fprintf(stderr,
"-D expects argument\n");
exit(5);
}
havearg = TRUE;
havearg = true;
if (*cp != ':') {
if (*cp < '0' || *cp > '9') {
fprintf(stderr,
@@ -299,13 +321,13 @@ main(int argc, char **argv)
if (*cp != ':') {
if (nextcp(&cp, &index,
argc, argv,
FALSE)
false)
|| *cp != ':')
break;
}
}
if (nextcp(&cp, &index, argc, argv,
FALSE)) {
false)) {
fprintf(stderr,
"-D : expects"
" argument\n");
@@ -331,14 +353,14 @@ main(int argc, char **argv)
if (*cp != ':') {
if (nextcp(&cp, &index,
argc, argv,
FALSE)
false)
|| *cp != ':') {
break;
}
}
}
if (nextcp(&cp, &index, argc, argv,
FALSE)) {
false)) {
fprintf(stderr, "-D : : expects"
" argument\n");
exit(11);
@@ -371,7 +393,7 @@ main(int argc, char **argv)
" filename\n");
exit(15);
}
havearg = TRUE;
havearg = true;
if (cmdlen > 0)
cmdbuf[cmdlen++] = ' ';
strlcpy(cmdbuf + cmdlen, "read ",
@@ -455,12 +477,12 @@ main(int argc, char **argv)
cmdlen++;
/* -f implies -s */
s_flag = TRUE;
s_flag = true;
maxindex = index + 1;
break;
case 's':
s_flag = TRUE;
s_flag = true;
maxindex = index + 1;
break;
default:
@@ -520,11 +542,11 @@ main(int argc, char **argv)
if (havecommands) {
cmdbuf[cmdlen++] = '\n';
cmdbuf[cmdlen] = '\0';
if (p_flag != TRUE) {
if (p_flag != true) {
if (fclose(stdin)) {
perror("main(): fclose(stdin) failed:");
}
stdin_closed = TRUE;
stdin_closed = true;
}
}
@@ -535,7 +557,7 @@ main(int argc, char **argv)
* unbuffered mode
*/
if (u_flag) {
if (stdin_closed == FALSE) {
if (stdin_closed == false) {
setbuf(stdin, NULL);
}
setbuf(stdout, NULL);
@@ -547,7 +569,7 @@ main(int argc, char **argv)
libcalc_call_me_first();
if (u_flag) {
if (conf->calc_debug & CALCDBG_TTY) {
if (stdin_closed == FALSE) {
if (stdin_closed == false) {
printf("main: stdin set to unbuffered before "
"calling libcalc_call_me_first()\n");
} else {
@@ -623,7 +645,7 @@ main(int argc, char **argv)
while (run_state == RUN_RCFILES) {
fprintf(stderr, "Error in rcfiles\n");
if ((c_flag && !stoponerror) || stoponerror < 0) {
getcommands(FALSE);
getcommands(false);
if (inputlevel() == 0) {
closeinput();
runrcfiles();
@@ -644,7 +666,7 @@ main(int argc, char **argv)
if (havecommands) {
set_run_state(RUN_CMD_ARGS);
(void) openstring(cmdbuf, strlen(cmdbuf));
getcommands(FALSE);
getcommands(false);
closeinput();
}
set_run_state(RUN_PRE_TOP_LEVEL);
@@ -653,7 +675,7 @@ main(int argc, char **argv)
while (run_state == RUN_CMD_ARGS) {
fprintf(stderr, "Error in commands\n");
if ((c_flag && !stoponerror) || stoponerror < 0) {
getcommands(FALSE);
getcommands(false);
if (inputlevel() == 0)
set_run_state(RUN_PRE_TOP_LEVEL);
closeinput();
@@ -679,7 +701,7 @@ main(int argc, char **argv)
openterminal();
}
set_run_state(RUN_TOP_LEVEL);
getcommands(TRUE);
getcommands(true);
}
if (p_flag || (!i_flag && havecommands))
set_run_state(RUN_EXIT);
@@ -689,7 +711,7 @@ main(int argc, char **argv)
if (conf->calc_debug & CALCDBG_RUNSTATE)
printf("main: run_state = TOP_LEVEL\n");
if ((c_flag && !stoponerror) || stoponerror < 0) {
getcommands(TRUE);
getcommands(true);
if (!inputisterminal()) {
closeinput();
continue;
@@ -713,7 +735,7 @@ main(int argc, char **argv)
break;
}
stdin_tty = TRUE;
stdin_tty = true;
if (conf->calc_debug & CALCDBG_TTY)
printf("main: stdin_tty is %d\n",
stdin_tty);
@@ -722,7 +744,7 @@ main(int argc, char **argv)
} else {
if (stdin_tty) {
reinitialize();
getcommands(TRUE);
getcommands(true);
} else if (inputisterminal() &&
!p_flag && (!havecommands||i_flag)) {
closeinput();
@@ -742,7 +764,7 @@ main(int argc, char **argv)
set_run_state(RUN_EXIT_WITH_ERROR);
break;
}
stdin_tty = TRUE;
stdin_tty = true;
if (conf->calc_debug & CALCDBG_TTY)
printf("main: stdin_tty is %d\n",
stdin_tty);
@@ -780,7 +802,7 @@ intint(int UNUSED(arg))
not_reached();
}
if (abortlevel >= ABORT_MATH)
_math_abort_ = TRUE;
_math_abort_ = true;
printf("\n[Abort level %d]\n", abortlevel);
}
@@ -818,7 +840,7 @@ calc_interrupt(char *fmt, ...)
}
S_FUNC int
nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr)
nextcp(char **cpp, int *ip, int argc, char **argv, bool haveendstr)
{
char *cp;
int index;

55
calc.h
View File

@@ -1,7 +1,7 @@
/*
* calc - definitions for calculator program
*
* Copyright (C) 1999-2007,2014,2021 David I. Bell
* Copyright (C) 1999-2007,2014,2021,2023 David I. Bell
*
* 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
@@ -104,9 +104,9 @@
E_FUNC FILEID openid(char *name, char *mode);
E_FUNC FILEID openpathid(char *name, char *mode, char *pathlist);
E_FUNC FILEID indexid(long index);
E_FUNC BOOL validid(FILEID id);
E_FUNC BOOL errorid(FILEID id);
E_FUNC BOOL eofid(FILEID id);
E_FUNC bool validid(FILEID id);
E_FUNC bool errorid(FILEID id);
E_FUNC bool eofid(FILEID id);
E_FUNC int closeid(FILEID id);
E_FUNC int getcharid(FILEID id);
E_FUNC int idprintf(FILEID id, char *fmt, int count, VALUE **vals);
@@ -157,7 +157,7 @@ E_FUNC int nextchar(void);
E_FUNC void reread(void);
E_FUNC void resetinput(void);
E_FUNC void setprompt(char *);
E_FUNC BOOL inputisterminal(void);
E_FUNC bool inputisterminal(void);
E_FUNC int inputlevel(void);
E_FUNC long calclevel(void);
E_FUNC char *inputname(void);
@@ -172,12 +172,12 @@ E_FUNC NUMBER *constvalue(unsigned long index);
E_FUNC long addnumber(char *str);
E_FUNC long addqconstant(NUMBER *q);
E_FUNC void initstack(void);
E_FUNC void getcommands(BOOL toplevel);
E_FUNC void getcommands(bool toplevel);
E_FUNC void givehelp(char *type);
E_FUNC void libcalc_call_me_first(void);
E_FUNC void libcalc_call_me_last(void);
E_FUNC BOOL calc_tty(int fd);
E_FUNC BOOL orig_tty(int fd);
E_FUNC bool calc_tty(int fd);
E_FUNC bool orig_tty(int fd);
E_FUNC void showerrors(void);
E_FUNC char *calc_strdup(CONST char *);
@@ -187,7 +187,7 @@ E_FUNC char *calc_strdup(CONST char *);
E_FUNC void initialize(void);
E_FUNC void reinitialize(void);
#if !defined(_WIN32) && !defined(_WIN64)
E_FUNC int isatty(int tty); /* TRUE if fd is a tty */
E_FUNC int isatty(int tty); /* true if fd is a tty */
#endif
E_FUNC char *version(void); /* return version string */
@@ -195,33 +195,34 @@ E_FUNC char *version(void); /* return version string */
* global flags and definitions
*/
EXTERN int abortlevel; /* current level of aborts */
EXTERN BOOL inputwait; /* TRUE if in a terminal input wait */
EXTERN bool inputwait; /* true if in a terminal input wait */
EXTERN int p_flag; /* TRUE => pipe mode */
EXTERN int q_flag; /* TRUE => don't execute rc files */
EXTERN int u_flag; /* TRUE => unbuffer stdin and stdout */
EXTERN int d_flag; /* TRUE => disable heading, resource_debug */
EXTERN int c_flag; /* TRUE => continue after error if permitted */
EXTERN int i_flag; /* TRUE => try to go interactive after error */
E_FUNC int s_flag; /* TRUE => keep args as strings for argv() */
EXTERN int p_flag; /* true => pipe mode */
EXTERN int q_flag; /* true => don't execute rc files */
EXTERN int u_flag; /* true => unbuffer stdin and stdout */
EXTERN int d_flag; /* true => disable heading, resource_debug */
EXTERN int c_flag; /* true => continue after error if permitted */
EXTERN int i_flag; /* true => try to go interactive after error */
E_FUNC int s_flag; /* true => keep args as strings for argv() */
EXTERN long stoponerror; /* >0 => stop, <0 => continue, ==0 => use -c */
EXTERN BOOL abort_now; /* TRUE => try to go interactive */
EXTERN bool abort_now; /* true => try to go interactive */
E_FUNC int argc_value; /* count of argv[] strings for argv() builtin */
E_FUNC char **argv_value; /* argv[] strings for argv() builtin */
EXTERN char *pager; /* $PAGER or default */
EXTERN int stdin_tty; /* TRUE if stdin is a tty */
EXTERN int havecommands; /* TRUE if have cmd args) */
EXTERN int stdin_tty; /* true if stdin is a tty */
EXTERN int havecommands; /* true if have cmd args) */
EXTERN char *program; /* our name */
EXTERN char *base_name; /* basename of our name */
EXTERN char cmdbuf[]; /* command line expression */
EXTERN char *script_name; /* program name or -f filename arg or NULL */
EXTERN int abortlevel; /* current level of aborts */
EXTERN BOOL inputwait; /* TRUE if in a terminal input wait */
EXTERN bool inputwait; /* true if in a terminal input wait */
EXTERN VALUE *stack; /* execution stack */
EXTERN int dumpnames; /* TRUE => dump names rather than indices */
EXTERN int dumpnames; /* true => dump names rather than indices */
EXTERN int calc_errno; /* global calc_errno value */
EXTERN char *calcpath; /* $CALCPATH or default */
EXTERN char *calcrc; /* $CALCRC or default */
@@ -229,13 +230,13 @@ EXTERN char *calcbindings; /* $CALCBINDINGS or default */
EXTERN char *home; /* $HOME or default */
EXTERN char *shell; /* $SHELL or default */
EXTERN int no_env; /* TRUE (-e) => ignore env vars on startup */
EXTERN int no_env; /* true (-e) => ignore env vars on startup */
EXTERN long errmax; /* if >= 0, error when errcount exceeds errmax */
EXTERN int use_old_std; /* TRUE (-O) => use classic configuration */
EXTERN int use_old_std; /* true (-O) => use classic configuration */
EXTERN int allow_read; /* FALSE => don't open any files for reading */
EXTERN int allow_write; /* FALSE => don't open any files for writing */
EXTERN int allow_exec; /* FALSE => may not execute any commands */
EXTERN int allow_read; /* false => don't open any files for reading */
EXTERN int allow_write; /* false => don't open any files for writing */
EXTERN int allow_exec; /* false => may not execute any commands */
/*
* calc startup and run state

View File

@@ -1,7 +1,7 @@
#
# calc.spec.in - template specfile for calc
#
# Copyright (C) 2003-2014,2021 Petteri Kettunen and Landon Curt Noll
# Copyright (C) 2003-2014,2021,2023 Petteri Kettunen and 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
@@ -20,23 +20,25 @@
# Under source code control: 2003/02/16 20:21:39
# File existed as early as: 2003
#
# calculator by David I. Bell with help/mods from others
# Makefile by Petteri Kettunen with modifications from Landon Curt Noll
# This calculator first developed by David I. Bell with help/mods from others.
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# BUGS
# - Uninstalling calc and calc-devel leaves empty dirs /usr/include/calc
# and /usr/share/calc and its subdirs. In case e.g. %{_includedir}/calc
# and /usr/share/calc and its subdirs. In case e.g., _includedir/calc
# is defined in `files devel' section, then rpmbuild complains that
# header files are defined twice - rpmbuild bug or bug in specfile conf???
Summary: Arbitrary precision calculator.
Name: calc
Version: <<<PROJECT_VERSION>>>
Release: 13
Release: 14
License: LGPL
Group: Applications/Engineering
Source: http://www.isthe.com/chongo/src/calc/%{name}-%{version}.tar.bz2
URL: http://www.isthe.com/chongo/tech/comp/calc/index.html
Source: https://github.com/lcn2/calc/releases/download/v<<<PROJECT_VERSION>>>/%{name}-%{version}.tar.bz2
URL: https://github.com/lcn2/calc
Vendor: Landon Noll and Associates
Packager: Landon Noll and Associates (http://www.isthe.com/chongo/index.html)
Requires: ncurses >= 5.5-24, readline >= 5.1-3, less >= 358
@@ -51,7 +53,11 @@ calculator, an algorithm prototype and mathematical research
tool. Calc comes with a rich set of builtin mathematical and
programming functions.
For the latest calc release, see the calc project home page:
For the latest calc release, see the calc GitHub repo:
https://github.com/lcn2/calc
or the calc home page:
http://www.isthe.com/chongo/tech/comp/calc/index.html
@@ -67,7 +73,11 @@ Requires: ncurses >= 5.5-24, readline >= 5.1-3, less >= 358
This package contains the header files and static libraries for developing
calc (arbitrary precision calculator).
For the latest calc release, see the project home page:
For the latest calc release, see the calc GitHub repo:
https://github.com/lcn2/calc
or the calc home page:
http://www.isthe.com/chongo/tech/comp/calc/index.html
@@ -152,8 +162,10 @@ echo '-=- calc.spec beginning make clean -=-'
%attr(644, root, root) %{_datadir}/%{name}/*.cal
%attr(644, root, root) %{_datadir}/%{name}/set8700.line
%attr(644, root, root) %{_libdir}/libcalc.so
%attr(644, root, root) %{_libdir}/libcalc.so.<<<PROJECT_VER>>>
%attr(644, root, root) %{_libdir}/libcalc.so.%{version}
%attr(644, root, root) %{_libdir}/libcustcalc.so
%attr(644, root, root) %{_libdir}/libcustcalc.so.<<<PROJECT_VER>>>
%attr(644, root, root) %{_libdir}/libcustcalc.so.%{version}
%files devel
@@ -165,6 +177,11 @@ echo '-=- calc.spec beginning make clean -=-'
%attr(644, root, root) %{_libdir}/libcustcalc.a
%changelog
* Mon Aug 14 2023 Landon Curt Noll http://www.isthe.com/chongo
- Release: 14
- Use Source and URL based on calc GitHub repo URLs.
- Install dynamic shared libraries with 3-digit version numbers.
* Sun Mar 24 2019 Landon Curt Noll http://www.isthe.com/chongo
- Release: 13
- Disable compiling with the default ARCH_CFLAGS= -march=native

View File

@@ -1,544 +0,0 @@
#
# calcerr - error codes and messages
#
# Copyright (C) 1999-2006,2021 Ernest Bowen
#
# 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
# 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.
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Under source code control: 1996/05/23 17:38:44
# File existed as early as: 1996
#
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# This file is used to build calcerr.h include file.
#
# Lines should be of the form:
#
# SYMBOL meaning
######################################################################
# WARNING: The order of the lines below is critical! If you change #
# the order, you will break code that depends on the return #
# value of the errno() builtin function. #
# #
# If you need to add values to this table, ONLY add then #
# to the bottom of the file! #
######################################################################
E_1OVER0 Division by zero
E_0OVER0 Indeterminate (0/0)
E_ADD Bad arguments for +
E_SUB Bad arguments for binary -
E_MUL Bad arguments for *
E_DIV Bad arguments for /
E_NEG Bad argument for unary -
E_SQUARE Bad argument for squaring
E_INV Bad argument for inverse
E_INCV Bad argument for ++
E_DECV Bad argument for --
E_INT Bad argument for int
E_FRAC Bad argument for frac
E_CONJ Bad argument for conj
E_APPR Bad first argument for appr
E_APPR2 Bad second argument for appr
E_APPR3 Bad third argument for appr
E_ROUND Bad first argument for round
E_ROUND2 Bad second argument for round
E_ROUND3 Bad third argument for round
E_BROUND Bad first argument for bround
E_BROUND2 Bad second argument for bround
E_BROUND3 Bad third argument for bround
E_SQRT Bad first argument for sqrt
E_SQRT2 Bad second argument for sqrt
E_SQRT3 Bad third argument for sqrt
E_ROOT Bad first argument for root
E_ROOT2 Bad second argument for root
E_ROOT3 Bad third argument for root
E_NORM Bad argument for norm
E_SHIFT Bad first argument for << or >>
E_SHIFT2 Bad second argument for << or >>
E_SCALE Bad first argument for scale
E_SCALE2 Bad second argument for scale
E_POWI Bad first argument for ^
E_POWI2 Bad second argument for ^
E_POWER Bad first argument for power
E_POWER2 Bad second argument for power
E_POWER3 Bad third argument for power
E_QUO Bad first argument for quo or //
E_QUO2 Bad second argument for quo or //
E_QUO3 Bad third argument for quo
E_MOD Bad first argument for mod or %
E_MOD2 Bad second argument for mod or %
E_MOD3 Bad third argument for mod
E_SGN Bad argument for sgn
E_ABS Bad first argument for abs
E_ABS2 Bad second argument for abs
E_EVAL Scan error in argument for eval
E_STR Non-simple type for str
E_EXP1 Non-real epsilon for exp
E_EXP2 Bad first argument for exp
E_FPUTC1 Non-file first argument for fputc
E_FPUTC2 Bad second argument for fputc
E_FPUTC3 File not open for writing for fputc
E_FGETC1 Non-file first argument for fgetc
E_FGETC2 File not open for reading for fgetc
E_FOPEN1 Non-string arguments for fopen
E_FOPEN2 Unrecognized mode for fopen
E_FREOPEN1 Non-file first argument for freopen
E_FREOPEN2 Non-string or unrecognized mode for freopen
E_FREOPEN3 Non-string third argument for freopen
E_FCLOSE1 Non-file argument for fclose
E_FFLUSH Non-file argument for fflush
E_FPUTS1 Non-file first argument for fputs
E_FPUTS2 Non-string argument after first for fputs
E_FPUTS3 File not open for writing for fputs
E_FGETS1 Non-file argument for fgets
E_FGETS2 File not open for reading for fgets
E_FPUTSTR1 Non-file first argument for fputstr
E_FPUTSTR2 Non-string argument after first for fputstr
E_FPUTSTR3 File not open for writing for fputstr
E_FGETSTR1 Non-file first argument for fgetstr
E_FGETSTR2 File not open for reading for fgetstr
E_FGETLINE1 Non-file argument for fgetline
E_FGETLINE2 File not open for reading for fgetline
E_FGETFIELD1 Non-file argument for fgetfield
E_FGETFIELD2 File not open for reading for fgetfield
E_REWIND1 Non-file argument for rewind
E_FILES Non-integer argument for files
E_PRINTF1 Non-string fmt argument for fprint
E_PRINTF2 Stdout not open for writing to ???
E_FPRINTF1 Non-file first argument for fprintf
E_FPRINTF2 Non-string second (fmt) argument for fprintf
E_FPRINTF3 File not open for writing for fprintf
E_STRPRINTF1 Non-string first (fmt) argument for strprintf
E_STRPRINTF2 Error in attempting strprintf ???
E_FSCAN1 Non-file first argument for fscan
E_FSCAN2 File not open for reading for fscan
E_STRSCAN Non-string first argument for strscan
E_FSCANF1 Non-file first argument for fscanf
E_FSCANF2 Non-string second (fmt) argument for fscanf
E_FSCANF3 Non-lvalue argument after second for fscanf
E_FSCANF4 File not open for reading or other error for fscanf
E_STRSCANF1 Non-string first argument for strscanf
E_STRSCANF2 Non-string second (fmt) argument for strscanf
E_STRSCANF3 Non-lvalue argument after second for strscanf
E_STRSCANF4 Some error in attempting strscanf ???
E_SCANF1 Non-string first (fmt) argument for scanf
E_SCANF2 Non-lvalue argument after first for scanf
E_SCANF3 Some error in attempting scanf ???
E_FTELL1 Non-file argument for ftell
E_FTELL2 File not open or other error for ftell
E_FSEEK1 Non-file first argument for fseek
E_FSEEK2 Non-integer or negative second argument for fseek
E_FSEEK3 File not open or other error for fseek
E_FSIZE1 Non-file argument for fsize
E_FSIZE2 File not open or other error for fsize
E_FEOF1 Non-file argument for feof
E_FEOF2 File not open or other error for feof
E_FERROR1 Non-file argument for ferror
E_FERROR2 File not open or other error for ferror
E_UNGETC1 Non-file argument for ungetc
E_UNGETC2 File not open for reading for ungetc
E_UNGETC3 Bad second argument or other error for ungetc
E_BIGEXP Exponent too big in scanning
E_ISATTY1 E_ISATTY1 is no longer used
E_ISATTY2 E_ISATTY2 is no longer used
E_ACCESS1 Non-string first argument for access
E_ACCESS2 Bad second argument for access
E_SEARCH1 Bad first argument for search
E_SEARCH2 Bad second argument for search
E_SEARCH3 Bad third argument for search
E_SEARCH4 Bad fourth argument for search
E_SEARCH5 Cannot find fsize or fpos for search
E_SEARCH6 File not readable for search
E_RSEARCH1 Bad first argument for rsearch
E_RSEARCH2 Bad second argument for rsearch
E_RSEARCH3 Bad third argument for rsearch
E_RSEARCH4 Bad fourth argument for rsearch
E_RSEARCH5 Cannot find fsize or fpos for rsearch
E_RSEARCH6 File not readable for rsearch
E_MANYOPEN Too many open files
E_REWIND2 Attempt to rewind a file that is not open
E_STRERROR1 Bad argument type for strerror
E_STRERROR2 Index out of range for strerror
E_COS1 Bad epsilon for cos
E_COS2 Bad first argument for cos
E_SIN1 Bad epsilon for sin
E_SIN2 Bad first argument for sin
E_EVAL2 Non-string argument for eval
E_ARG1 Bad epsilon for arg
E_ARG2 Bad first argument for arg
E_POLAR1 Non-real argument for polar
E_POLAR2 Bad epsilon for polar
E_FCNT Non-integral argument for fcnt
E_MATFILL1 Non-variable first argument for matfill
E_MATFILL2 Non-matrix first argument-value for matfill
E_MATDIM Non-matrix argument for matdim
E_MATSUM Non-matrix argument for matsum
E_ISIDENT E_ISIDENT is no longer used
E_MATTRANS1 Non-matrix argument for mattrans
E_MATTRANS2 Non-two-dimensional matrix for mattrans
E_DET1 Non-matrix argument for det
E_DET2 Matrix for det not of dimension 2
E_DET3 Non-square matrix for det
E_MATMIN1 Non-matrix first argument for matmin
E_MATMIN2 Non-positive-integer second argument for matmin
E_MATMIN3 Second argument for matmin exceeds dimension
E_MATMAX1 Non-matrix first argument for matmin
E_MATMAX2 Second argument for matmax not positive integer
E_MATMAX3 Second argument for matmax exceeds dimension
E_CP1 Non-matrix argument for cp
E_CP2 Non-one-dimensional matrix for cp
E_CP3 Matrix size not 3 for cp
E_DP1 Non-matrix argument for dp
E_DP2 Non-one-dimensional matrix for dp
E_DP3 Different-size matrices for dp
E_STRLEN Non-string argument for strlen
E_STRCAT Non-string argument for strcat
E_SUBSTR1 Non-string first argument for strcat
E_SUBSTR2 Non-non-negative integer second argument for strcat
E_CHAR Bad argument for char
E_ORD Non-string argument for ord
E_INSERT1 Non-list-variable first argument for insert
E_INSERT2 Non-integral second argument for insert
E_PUSH Non-list-variable first argument for push
E_APPEND Non-list-variable first argument for append
E_DELETE1 Non-list-variable first argument for delete
E_DELETE2 Non-integral second argument for delete
E_POP Non-list-variable argument for pop
E_REMOVE Non-list-variable argument for remove
E_LN1 Bad epsilon argument for ln
E_LN2 Non-numeric first argument for ln
E_ERROR1 Non-integer argument for error
E_ERROR2 Argument outside range for error
E_EVAL3 Attempt to eval at maximum input depth
E_EVAL4 Unable to open string for reading
E_RM1 First argument for rm is not a non-empty string
E_RM2 Unable to remove a file
E_RDPERM Operation allowed because calc mode disallows read operations
E_WRPERM Operation allowed because calc mode disallows write operations
E_EXPERM Operation allowed because calc mode disallows exec operations
E_MIN Unordered arguments for min
E_MAX Unordered arguments for max
E_LISTMIN Unordered items for minimum of list
E_LISTMAX Unordered items for maximum of list
E_SIZE Size undefined for argument type
E_NO_C_ARG Calc must be run with a -C argument to use custom function
E_NO_CUSTOM Calc was built with custom functions disabled
E_UNK_CUSTOM Custom function unknown, try: show custom
E_BLK1 Non-integral length for block
E_BLK2 Negative or too-large length for block
E_BLK3 Non-integral chunksize for block
E_BLK4 Negative or too-large chunksize for block
E_BLKFREE1 Named block does not exist for blkfree
E_BLKFREE2 Non-integral id specification for blkfree
E_BLKFREE3 Block with specified id does not exist
E_BLKFREE4 Block already freed
E_BLKFREE5 No-realloc protection prevents blkfree
E_BLOCKS1 Non-integer argument for blocks
E_BLOCKS2 Non-allocated index number for blocks
E_COPY1 Non-integer or negative source index for copy
E_COPY2 Source index too large for copy
E_COPY3 E_COPY3 is no longer used
E_COPY4 Non-integer or negative number for copy
E_COPY5 Number too large for copy
E_COPY6 Non-integer or negative destination index for copy
E_COPY7 Destination index too large for copy
E_COPY8 Freed block source for copy
E_COPY9 Unsuitable source type for copy
E_COPY10 Freed block destination for copy
E_COPY11 Unsuitable destination type for copy
E_COPY12 Incompatible source and destination for copy
E_COPY13 No-copy-from source variable
E_COPY14 No-copy-to destination variable
E_COPY15 No-copy-from source named block
E_COPY16 No-copy-to destination named block
E_COPY17 No-relocate destination for copy
E_COPYF1 File not open for copy
E_COPYF2 fseek or fsize failure for copy
E_COPYF3 fwrite error for copy
E_COPYF4 fread error for copy
E_PROTECT1 Non-variable first argument for protect
E_PROTECT2 Bad second argument for protect
E_PROTECT3 Bad third argument for protect
E_MATFILL3 No-copy-to destination for matfill
E_MATFILL4 No-assign-from source for matfill
E_MATTRACE1 Non-matrix argument for mattrace
E_MATTRACE2 Non-two-dimensional argument for mattrace
E_MATTRACE3 Non-square argument for mattrace
E_TAN1 Bad epsilon for tan
E_TAN2 Bad argument for tan
E_COT1 Bad epsilon for cot
E_COT2 Bad argument for cot
E_SEC1 Bad epsilon for sec
E_SEC2 Bad argument for sec
E_CSC1 Bad epsilon for csc
E_CSC2 Bad argument for csc
E_SINH1 Bad epsilon for sinh
E_SINH2 Bad argument for sinh
E_COSH1 Bad epsilon for cosh
E_COSH2 Bad argument for cosh
E_TANH1 Bad epsilon for tanh
E_TANH2 Bad argument for tanh
E_COTH1 Bad epsilon for coth
E_COTH2 Bad argument for coth
E_SECH1 Bad epsilon for sech
E_SECH2 Bad argument for sech
E_CSCH1 Bad epsilon for csch
E_CSCH2 Bad argument for csch
E_ASIN1 Bad epsilon for asin
E_ASIN2 Bad argument for asin
E_ACOS1 Bad epsilon for acos
E_ACOS2 Bad argument for acos
E_ATAN1 Bad epsilon for atan
E_ATAN2 Bad argument for atan
E_ACOT1 Bad epsilon for acot
E_ACOT2 Bad argument for acot
E_ASEC1 Bad epsilon for asec
E_ASEC2 Bad argument for asec
E_ACSC1 Bad epsilon for acsc
E_ACSC2 Bad argument for acsc
E_ASINH1 Bad epsilon for asin
E_ASINH2 Bad argument for asinh
E_ACOSH1 Bad epsilon for acosh
E_ACOSH2 Bad argument for acosh
E_ATANH1 Bad epsilon for atanh
E_ATANH2 Bad argument for atanh
E_ACOTH1 Bad epsilon for acoth
E_ACOTH2 Bad argument for acoth
E_ASECH1 Bad epsilon for asech
E_ASECH2 Bad argument for asech
E_ACSCH1 Bad epsilon for acsch
E_ACSCH2 Bad argument for acsch
E_GD1 Bad epsilon for gd
E_GD2 Bad argument for gd
E_AGD1 Bad epsilon for agd
E_AGD2 Bad argument for agd
E_LOGINF Log of zero or infinity
E_STRADD String addition failure
E_STRMUL String multiplication failure
E_STRNEG String reversal failure
E_STRSUB String subtraction failure
E_BIT1 Bad argument type for bit
E_BIT2 Index too large for bit
E_SETBIT1 Non-integer second argument for setbit
E_SETBIT2 Out-of-range index for setbit
E_SETBIT3 Non-string first argument for setbit
E_OR Bad argument for or
E_AND Bad argument for and
E_STROR Allocation failure for string or
E_STRAND Allocation failure for string and
E_XOR Bad argument for xorvalue
E_COMP Bad argument for comp
E_STRDIFF Allocation failure for string diff
E_STRCOMP Allocation failure for string comp
E_SEG1 Bad first argument for segment
E_SEG2 Bad second argument for segment
E_SEG3 Bad third argument for segment
E_STRSEG Failure for string segment
E_HIGHBIT1 Bad argument type for highbit
E_HIGHBIT2 Non-integer argument for highbit
E_LOWBIT1 Bad argument type for lowbit
E_LOWBIT2 Non-integer argument for lowbit
E_CONTENT Bad argument type for unary hash op
E_HASHOP Bad argument type for binary hash op
E_HEAD1 Bad first argument for head
E_HEAD2 Bad second argument for head
E_STRHEAD Failure for strhead
E_TAIL1 Bad first argument for tail
E_TAIL2 Bad second argument for tail
E_STRTAIL Failure for strtail
E_STRSHIFT Failure for strshift
E_STRCMP Non-string argument for strcmp
E_STRNCMP Bad argument type for strncmp
E_XOR1 Varying types of argument for xor
E_XOR2 Bad argument type for xor
E_STRCPY Bad argument type for strcpy
E_STRNCPY Bad argument type for strncpy
E_BACKSLASH Bad argument type for unary backslash
E_SETMINUS Bad argument type for setminus
E_INDICES1 Bad first argument type for indices
E_INDICES2 Bad second argument for indices
E_EXP3 Too-large re(argument) for exp
E_SINH3 Too-large re(argument) for sinh
E_COSH3 Too-large re(argument) for cosh
E_SIN3 Too-large im(argument) for sin
E_COS3 Too-large im(argument) for cos
E_GD3 Infinite or too-large result for gd
E_AGD3 Infinite or too-large result for agd
E_POWER4 Too-large value for power
E_ROOT4 Too-large value for root
E_DGT1 Non-real first arg for digit
E_DGT2 Non-integral second arg for digit
E_DGT3 Bad third arg for digit
E_PLCS1 Bad first argument for places
E_PLCS2 Bad second argument for places
E_DGTS1 Bad first argument for digits
E_DGTS2 Bad second argument for digits
E_ILOG Bad first argument for ilog
E_ILOGB Bad second argument for ilog
E_ILOG10 Bad argument for ilog10
E_ILOG2 Bad argument for ilog2
E_COMB1 Non-integer second arg for comb
E_COMB2 Too-large second arg for comb
E_CTLN Bad argument for catalan
E_BERN Bad argument for bern
E_EULER Bad argument for euler
E_SLEEP Bad argument for sleep
E_TTY calc_tty failure
E_ASSIGN1 No-copy-to destination for octet assign
E_ASSIGN2 No-copy-from source for octet assign
E_ASSIGN3 No-change destination for octet assign
E_ASSIGN4 Non-variable destination for assign
E_ASSIGN5 No-assign-to destination for assign
E_ASSIGN6 No-assign-from source for assign
E_ASSIGN7 No-change destination for assign
E_ASSIGN8 No-type-change destination for assign
E_ASSIGN9 No-error-value destination for assign
E_SWAP1 No-copy argument for octet swap
E_SWAP2 No-assign-to-or-from argument for swap
E_SWAP3 Non-lvalue argument for swap
E_QUOMOD1 Non-lvalue argument 3 or 4 for quomod
E_QUOMOD2 Non-real-number arg 1 or 2 or bad arg 5 for quomod
E_QUOMOD3 No-assign-to argument 3 or 4 for quomod
E_PREINC1 No-copy-to or no-change argument for octet preinc
E_PREINC2 Non-variable argument for preinc
E_PREINC3 No-assign-to or no-change argument for preinc
E_PREDEC1 No-copy-to or no-change argument for octet predec
E_PREDEC2 Non-variable argument for predec
E_PREDEC3 No-assign-to or no-change argument for predec
E_POSTINC1 No-copy-to or no-change argument for octet postinc
E_POSTINC2 Non-variable argument for postinc
E_POSTINC3 No-assign-to or no-change argument for postinc
E_POSTDEC1 No-copy-to or no-change argument for octet postdec
E_POSTDEC2 Non-variable argument for postdec
E_POSTDEC3 No-assign-to or no-change argument for postdec
E_INIT1 Error-type structure for initialization
E_INIT2 No-copy-to structure for initialization
E_INIT3 Too many initializer values
E_INIT4 Attempt to initialize freed named block
E_INIT5 Bad structure type for initialization
E_INIT6 No-assign-to element for initialization
E_INIT7 No-change element for initialization
E_INIT8 No-type-change element for initialization
E_INIT9 No-error-value element for initialization
E_INIT10 No-assign-or-copy-from source for initialization
E_LIST1 No-relocate for list insert
E_LIST2 No-relocate for list delete
E_LIST3 No-relocate for list push
E_LIST4 No-relocate for list append
E_LIST5 No-relocate for list pop
E_LIST6 No-relocate for list remove
E_MODIFY1 Non-variable first argument for modify
E_MODIFY2 Non-string second argument for modify
E_MODIFY3 No-change first argument for modify
E_MODIFY4 Undefined function for modify
E_MODIFY5 Unacceptable type first argument for modify
E_FPATHOPEN1 Non-string arguments for fpathopen
E_FPATHOPEN2 Unrecognized mode for fpathopen
E_LOG1 Bad epsilon argument for log
E_LOG2 Non-numeric first argument for log
E_LOG3 Cannot calculate log for this value
E_FGETFILE1 Non-file argument for fgetfile
E_FGETFILE2 File argument for fgetfile not open for reading
E_FGETFILE3 Unable to set file position in fgetfile
E_ESTR Non-representable type for estr
E_STRCASECMP Non-string argument for strcasecmp
E_STRNCASECMP Bad argument type for strncasecmp
E_ISUPPER Bad argument for isupper
E_ISLOWER Bad argument for islower
E_ISALNUM Bad argument for isalnum
E_ISALPHA Bad argument for isalpha
E_ISASCII Bad argument for isascii
E_ISCNTRL Bad argument for iscntrl
E_ISDIGIT Bad argument for isdigit
E_ISGRAPH Bad argument for isgraph
E_ISPRINT Bad argument for isprint
E_ISPUNCT Bad argument for ispunct
E_ISSPACE Bad argument for isspace
E_ISXDIGIT Bad argument for isxdigit
E_STRTOUPPER Bad argument type for strtoupper
E_STRTOLOWER Bad argument type for strtolower
E_TAN3 Invalid value for calculating the sin numerator for tan
E_TAN4 Invalid value for calculating the cos denominator for tan
E_COT3 Invalid value for calculating the sin numerator for cot
E_COT4 Invalid value for calculating the cos denominator for cot
E_SEC3 Invalid value for calculating the cos reciprocal for sec
E_CSC3 Invalid value for calculating the sin reciprocal for csc
E_TANH3 Invalid value for calculating the sinh numerator for tanh
E_TANH4 Invalid value for calculating the cosh denominator for tanh
E_COTH3 Invalid value for calculating the sinh numerator for coth
E_COTH4 Invalid value for calculating the cosh denominator for coth
E_SECH3 Invalid value for calculating the cosh reciprocal for sech
E_CSCH3 Invalid value for calculating the sinh reciprocal for csch
E_ASIN3 Invalid value for calculating asin
E_ACOS3 Invalid value for calculating acos
E_ASINH3 Invalid value for calculating asinh
E_ACOSH3 Invalid value for calculating acosn
E_ATAN3 Invalid value for calculating atan
E_ACOT3 Invalid value for calculating acot
E_ASEC3 Invalid value for calculating asec
E_ACSC3 Invalid value for calculating acsc
E_ATANH3 Invalid value for calculating atan
E_ACOTH3 Invalid value for calculating acot
E_ASECH3 Invalid value for calculating asec
E_ACSCH3 Invalid value for calculating acsc
E_D2R1 Bad epsilon for converting degrees to radians
E_D2R2 Bad first argument converting degrees to radians
E_R2D1 Bad epsilon for converting radians to degrees
E_R2D2 Bad first argument converting radians to degrees
E_G2R1 Bad epsilon for converting gradians to radians
E_G2R2 Bad first argument converting gradians to radians
E_R2G1 Bad epsilon for converting radians to gradians
E_R2G2 Bad first argument converting radians to gradians
E_D2G1 Bad first argument converting degrees to gradians
E_G2D1 Bad first argument converting gradians to degrees
E_D2DMS1 Non-lvalue arguments 2, 3 or 4 for d2dms
E_D2DMS2 Non-real-number arg 1 for d2dms
E_D2DMS3 No-assign-to argument 2, 3 or 4 for d2dms
E_D2DMS4 Invalid rounding arg 5 for d2dms
E_D2DM1 Non-lvalue arguments 2 or 3 for d2dm
E_D2DM2 Non-real-number arg 1 for d2dm
E_D2DM3 No-assign-to argument 2 or 3 for d2dm
E_D2DM4 Invalid rounding arg 4 for d2dm
E_G2GMS1 Non-lvalue arguments 2, 3 or 4 for g2gms
E_G2GMS2 Non-real-number arg 1 for g2gms
E_G2GMS3 No-assign-to argument 2 or 3 for g2gms
E_G2GMS4 Invalid rounding arg 5 for g2gms
E_G2GM1 Non-lvalue arguments 2 or 3 for g2gm
E_G2GM2 Non-real-number arg 1 for g2gm
E_G2GM3 No-assign-to argument 2, 3 or 4 for g2gm
E_G2GM4 Invalid rounding arg 4 for g2gm
E_H2HMS1 Non-lvalue arguments 2, 3 or 4 for h2hms
E_H2HMS2 Non-real-number arg 1 for h2hms
E_H2HMS3 No-assign-to argument 2, 3 or 4 for h2hms
E_H2HMS4 Invalid rounding arg 5 for h2hms
E_H2HM1 Non-lvalue arguments 2 or 3 for h2hm
E_H2HM2 Non-real-number arg 1 for h2hm
E_H2HM3 No-assign-to argument 2 or 3 for h2hm
E_H2HM4 Invalid rounding arg 4 for h2hm
E_DMS2D1 Non-real-number arguments 1, 2 or 3 for dms2d
E_DMS2D2 Invalid rounding arg 4 for dms2d
E_DM2D1 Non-real-number arguments 1 or 2 for dm2d
E_DM2D2 Invalid rounding arg 4 for dm2d
E_GMS2G1 Non-real-number arguments 1, 2 or 3 for gms2g
E_GMS2G2 Invalid rounding arg 4 for gms2g
E_GM2G1 Non-real-number arguments 1 or 2 for gm2g
E_GM2G2 Invalid rounding arg 4 for gm2g
E_HMS2H1 Non-real-number arguments 1, 2 or 3 for hms2h
E_HMS2H2 Invalid rounding arg 4 for hms2h
E_HM2H1 Non-real-number arguments 1 or 2 for hm2h
E_HM2H2 Invalid rounding arg 4 for hm2h

View File

@@ -1,45 +0,0 @@
#!/usr/bin/sed
#
# calcerr_c - help produce calcerr.c from calcerr.tbl
#
# Copyright (C) 1999 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
# 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.
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Under source code control: 1996/05/24 03:15:35
# File existed as early as: 1996
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
#
BEGIN {
printf("#include <stdio.h>\n");
printf("#include \"calcerr.h\"\n\n");
printf("#include \"have_const.h\"\n\n");
printf("#include \"banned.h\"\t");
printf("/* include after system header <> includes */\n\n");
printf("/*\n");
printf(" * names of calc error values\n");
printf(" */\n");
printf("CONST char *error_table[E__COUNT+2] = {\n");
printf(" \"No error\",\n");
}
{
print $0;
}
END {
printf(" NULL\n");
printf("};\n");
}

View File

@@ -1,30 +0,0 @@
#!/usr/bin/sed
#
# calcerr_c - help produce calcerr.c from calcerr.tbl
#
# Copyright (C) 1999 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
# 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.
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Under source code control: 1996/05/24 03:15:35
# File existed as early as: 1996
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
#
s/#.*//
s/[ ][ ]*$//
/^$/d
s/[^ ][^ ]*[ ][ ]*\(.*\)$/ "\1",/

View File

@@ -1,48 +0,0 @@
#!/usr/bin/awk
#
# calcerr_h - help produce calcerr.h from calcerr.tbl
#
# Copyright (C) 1999 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
# 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.
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Under source code control: 1996/05/23 17:38:44
# File existed as early as: 1996
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
#
BEGIN {
ebase = 10000;
printf("#define E__BASE %d\t/* calc errors start above here */\n\n", ebase);
}
NF > 1 {
if (length($1) > 7) {
printf("#define %s\t", $1, NR);
} else {
printf("#define %s\t\t", $1, NR);
}
printf("%d\t/* ", ebase+NR);
for (i=2; i < NF; ++i) {
printf("%s ", $i);
}
printf("%s */\n", $NF);
}
END {
printf("\n#define E__HIGHEST\t%d\t/* highest calc error */\n", NR+ebase);
printf("#define E__COUNT\t\t%d\t/* number of calc errors */\n", NR);
printf("#define E_USERDEF\t20000\t/* base of user defined errors */\n\n");
printf("/* names of calc error values */\n");
}

View File

@@ -1,30 +0,0 @@
#!/usr/bin/sed
#
# calcerr_h - help produce calcerr.h from calcerr.tbl
#
# Copyright (C) 1999 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
# 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.
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Under source code control: 1996/05/23 17:38:44
# File existed as early as: 1996
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
#
s/#.*//
s/[ ][ ]*$//
/^$/d
s/\([^ ][^ ]*\)[ ][ ]*\(.*\)$/\1 \2/

351
chk_c.c Normal file
View File

@@ -0,0 +1,351 @@
/*
* chk_c - chk C compiler and C include for calc requirements
*
* This program, to successfully compile, must include:
*
* #include <stdint.h>
* #include <inttypes.h>
*
* and must be able to compile all of these types:
*
* int8_t uint8_t
* int16_t uint16_t
* int32_t uint32_t
* int64_t uint64_t
* intptr_t uintptr_t
* intmax_t uintmax_t
*
* be able to sum values from all of those files,
* plus the INTX_C(val) and UINTX_C(val) composing macros,
* and be able to print for signed and unsigned values.
*
* 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.
*
* Copyright (C) 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
* 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.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Under source code control: 2023/08/20 23:57:50
* 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/
*/
#include <stdio.h>
#include <unistd.h>
#include "have_stdint.h"
#if defined(HAVE_STDINT_H)
#include <stdint.h>
#endif /* HAVE_STDINT_H */
#include "have_inttypes.h"
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
#endif /* HAVE_INTTYPES_H */
#include "have_stdlib.h"
#if defined(HAVE_STDLIB_H)
#include <stdlib.h>
#endif /* HAVE_STDLIB_H */
#include "bool.h"
/*
* our version
*/
#define CHK_C_VERSION "1.0 2023-08-20"
/*
* usage:
*/
static char const *usage =
"usage: %s [-h] [-c] [-V]\n"
"\n"
"\t-h\t\toutput this message and exit\n"
"\t-c\t\toutput C compiler and C include info (def: no stdout output)\n"
"\t-V\t\tprint version string and exit\n"
"\n"
"Exit codes:\n"
" 0 all OK\n"
" 1 C compiler and C include is insufficient for calc\n"
" 2 -h and help string printed or -V and version string printed\n"
" 3 invalid command line, invalid option or option missing an argument\n"
" >= 10 internal error\n"
"\n"
"chk_c version: %s\n";
#include "banned.h" /* include after system header <> includes */
int
main(int argc, char *argv[])
{
char *program = "((NULL))"; /* our name */
int opt; /* the -option found or -1 */
bool c_flag = false; /* if -h was found */
#if defined(HAVE_STDINT_H) && defined(HAVE_INTTYPES_H)
int i = -1; /* signed int test value */
unsigned int ui = 1; /* unsigned int test value */
long l = -2L; /* signed long test value */
unsigned long ul = 2UL; /* unsigned long test value */
long long ll = -4LL; /* signed long long test value */
unsigned long long ull = 4ULL; /* unsigned long long test value */
int8_t i8 = INT8_C(-8); /* signed 8-bit test value */
uint8_t ui8 = UINT8_C(8); /* unsigned 8-bit test value */
int16_t i16 = INT16_C(-16); /* signed 16-bit test value */
uint16_t ui16 = UINT16_C(16); /* unsigned 16-bit test value */
int32_t i32 = INT32_C(-32); /* signed 32-bit test value */
uint32_t ui32 = UINT32_C(32); /* unsigned 32-bit test value */
int64_t i64 = INT64_C(-64); /* signed 64-bit test value */
uint64_t ui64 = UINT64_C(64); /* unsigned 64-bit test value */
intptr_t iptr = -128; /* integer type capable of holding a pointer */
intptr_t uiptr = 128; /* unsigned integer type capable of holding a pointer */
intmax_t imax = INTMAX_C(-256); /* maximum sized signed int test value */
uintmax_t uimax = UINTMAX_C(256); /* maximum sized unsigned int test value */
uintmax_t isum = 0; /* sum of all test values as signed value */
uintmax_t uisum = 0; /* sum of all test values as unsigned value */
#endif /* HAVE_STDINT_H && HAVE_INTTYPES_H */
/*
* parse args
*/
program = argv[0];
while ((opt = getopt(argc, argv, "hcV")) != -1) {
switch (opt) {
case 'h':
fprintf(stderr, usage, program, CHK_C_VERSION);
exit(2);
break;
case 'c':
c_flag = true;
break;
case 'V':
printf("%s\n", CHK_C_VERSION);
exit(2);
break;
default:
fprintf(stderr, usage, program, CHK_C_VERSION);
exit(3);
}
}
if (optind != argc) {
fprintf(stderr, usage, program, CHK_C_VERSION);
exit(3);
}
/*
* must have <stdint.h>
*/
#if !defined(HAVE_STDINT_H)
if (c_flag == true) {
printf("HAVE_STDINT_H is undefined\n");
}
fprintf(stderr, "calc requires <stdint.h> include file\n");
exit(1);
#else /* HAVE_STDINT_H */
if (c_flag == true) {
printf("HAVE_STDINT_H is defined\n");
printf("<stdint.h> successfully included\n");
}
/*
* must have <inttypes.h>
*/
#if !defined(HAVE_INTTYPES_H)
if (c_flag == true) {
printf("HAVE_INTTYPES_H is undefined\n");
}
fprintf(stderr, "calc requires <inttypes.h> include file\n");
exit(1);
#else /* HAVE_INTTYPES_H */
if (c_flag == true) {
printf("\nHAVE_INTTYPES_H is defined\n");
printf("<inttypes.h> successfully included\n");
}
/*
* check for __STDC__ defined
*/
#if !defined(__STDC__)
fprintf(stderr, "__STDC__ is not defined\n");
exit(1);
#endif /* __STDC__ */
if (c_flag == true) {
printf("\n__STDC__ is defined\n");
}
/*
* check for __STDC_VERSION__ defined
*/
#if !defined(__STDC_VERSION__)
fprintf(stderr, "__STDC_VERSION__ is not defined\n");
exit(1);
#endif /* __STDC_VERSION__ */
if (c_flag == true) {
printf("__STDC_VERSION__: %ld is defined\n", __STDC_VERSION__);
}
/*
* check for __STDC_VERSION__ >= 199901L for c99 or later
*/
#if __STDC_VERSION__ < 199901L
fprintf(stderr, "__STDC_VERSION__: %ld < 199901L\n", __STDC_VERSION__);
exit(1);
#endif /* __STDC_VERSION__ >= 199901L */
if (c_flag == true) {
printf("__STDC_VERSION__: %ld >= 199901L\n", __STDC_VERSION__);
}
/*
* calculate sum of all test values as signed value
*/
isum = i + ui + l + ul + ll + ull + i8 + ui8 + i16 + ui16 + i32 + ui32 + i64 + ui64 + iptr + uiptr + imax + uimax;
if (c_flag == true) {
printf("\nzero valued isum: %jd\n", isum);
}
if (isum != 0) {
fprintf(stderr, "failed to add all required integer types into a signed value\n");
exit(1);
}
/*
* calculate sum of all test values as unsigned value
*/
uisum = i + ui + l + ul + ll + ull + i8 + ui8 + i16 + ui16 + i32 + ui32 + i64 + ui64 + iptr + uiptr + imax + uimax;
if (c_flag == true) {
printf("zero valued uisum: %ju\n", uisum);
}
if (uisum != 0) {
fprintf(stderr, "failed to add all required integer types into an unsigned value\n");
exit(1);
}
/*
* verify various 32, 64 and max PRI macros as well as MIN and MAX constants
*/
if (c_flag == true) {
printf("\nsigned integer MIN and MAX\n");
printf("INT8_MIN: %+"PRId8"\n", (int8_t)INT8_MIN);
printf("INT8_MAX: %+"PRId8"\n", (int8_t)INT8_MAX);
printf("INT16_MIN: %+"PRId16"\n", (int16_t)INT16_MIN);
printf("INT16_MAX: %+"PRId16"\n", (int16_t)INT16_MAX);
printf("INT32_MIN: %+"PRId32"\n", (int32_t)INT32_MIN);
printf("INT32_MAX: %+"PRId32"\n", (int32_t)INT32_MAX);
printf("INT64_MIN: %+"PRId64"\n", (int64_t)INT64_MIN);
printf("INT64_MAX: %+"PRId64"\n", (int64_t)INT64_MAX);
printf("INTPTR_MIN: %+"PRIdMAX"\n", (intptr_t)INTPTR_MIN);
printf("INTPTR_MAX: %+"PRIdMAX"\n", (intptr_t)INTPTR_MAX);
printf("INTMAX_MIN: %+"PRIdMAX"\n", (intmax_t)INTMAX_MIN);
printf("INTMAX_MAX: %+"PRIdMAX"\n", (intmax_t)INTMAX_MAX);
printf("\nunsigned integer MAX\n");
printf("UINT8_MAX: %"PRIu8"\n", (uint8_t)UINT8_MAX);
printf("UINT16_MAX: %"PRIu16"\n", (uint16_t)UINT16_MAX);
printf("UINT32_MAX: %"PRIu32"\n", (uint32_t)UINT32_MAX);
printf("UINT64_MAX: %"PRIu64"\n", (uint64_t)UINT64_MAX);
printf("UINTPTR_MAX: %"PRIuMAX"\n", (uintptr_t)UINTPTR_MAX);
printf("UINTMAX_MAX: %"PRIuMAX"\n", (uintmax_t)UINTMAX_MAX);
printf("\ninteger MIN and MAX\n");
printf("INT8_MIN: %"PRIi8"\n", (int8_t)INT8_MIN);
printf("INT8_MAX: %"PRIi8"\n", (int8_t)INT8_MAX);
printf("INT16_MIN: %"PRIi16"\n", (int16_t)INT16_MIN);
printf("INT16_MAX: %"PRIi16"\n", (int16_t)INT16_MAX);
printf("INT32_MIN: %"PRIi32"\n", (int32_t)INT32_MIN);
printf("INT32_MAX: %"PRIi32"\n", (int32_t)INT32_MAX);
printf("INT64_MIN: %"PRIi64"\n", (int64_t)INT64_MIN);
printf("INT64_MAX: %"PRIi64"\n", (int64_t)INT64_MAX);
printf("INTPTR_MIN: %"PRIiMAX"\n", (intptr_t)INTPTR_MIN);
printf("INTPTR_MAX: %"PRIiMAX"\n", (intptr_t)INTPTR_MAX);
printf("INTMAX_MIN: %"PRIiMAX"\n", (intmax_t)INTMAX_MIN);
printf("INTMAX_MAX: %"PRIiMAX"\n", (intmax_t)INTMAX_MAX);
printf("\noctal MIN and MAX\n");
printf("INT8_MIN: %"PRIo8"\n", (int8_t)INT8_MIN);
printf("INT8_MAX: %"PRIo8"\n", (int8_t)INT8_MAX);
printf("INT16_MIN: %"PRIo16"\n", (int16_t)INT16_MIN);
printf("INT16_MAX: %"PRIo16"\n", (int16_t)INT16_MAX);
printf("INT32_MIN: %"PRIo32"\n", (int32_t)INT32_MIN);
printf("INT32_MAX: %"PRIo32"\n", (int32_t)INT32_MAX);
printf("INT64_MIN: %"PRIo64"\n", (int64_t)INT64_MIN);
printf("INT64_MAX: %"PRIo64"\n", (int64_t)INT64_MAX);
printf("INTPTR_MIN: %"PRIoMAX"\n", (intptr_t)INTPTR_MIN);
printf("INTPTR_MAX: %"PRIoMAX"\n", (intptr_t)INTPTR_MAX);
printf("INTMAX_MIN: %"PRIoMAX"\n", (intmax_t)INTMAX_MIN);
printf("INTMAX_MAX: %"PRIoMAX"\n", (intmax_t)INTMAX_MAX);
printf("\nhex MIN and MAX\n");
printf("INT8_MIN: %"PRIx8"\n", (int8_t)INT8_MIN);
printf("INT8_MAX: %"PRIx8"\n", (int8_t)INT8_MAX);
printf("INT16_MIN: %"PRIx16"\n", (int16_t)INT16_MIN);
printf("INT16_MAX: %"PRIx16"\n", (int16_t)INT16_MAX);
printf("INT32_MIN: %"PRIx32"\n", (int32_t)INT32_MIN);
printf("INT32_MAX: %"PRIx32"\n", (int32_t)INT32_MAX);
printf("INT64_MIN: %"PRIx64"\n", (int64_t)INT64_MIN);
printf("INT64_MAX: %"PRIx64"\n", (int64_t)INT64_MAX);
printf("INTPTR_MIN: %"PRIxMAX"\n", (intptr_t)INTPTR_MIN);
printf("INTPTR_MAX: %"PRIxMAX"\n", (intptr_t)INTPTR_MAX);
printf("INTMAX_MIN: %"PRIxMAX"\n", (intmax_t)INTMAX_MIN);
printf("INTMAX_MAX: %"PRIxMAX"\n", (intmax_t)INTMAX_MAX);
printf("\nHEX MIN and MAX\n");
printf("INT8_MIN: %"PRIX8"\n", (int8_t)INT8_MIN);
printf("INT8_MAX: %"PRIX8"\n", (int8_t)INT8_MAX);
printf("INT16_MIN: %"PRIX16"\n", (int16_t)INT16_MIN);
printf("INT16_MAX: %"PRIX16"\n", (int16_t)INT16_MAX);
printf("INT32_MIN: %"PRIX32"\n", (int32_t)INT32_MIN);
printf("INT32_MAX: %"PRIX32"\n", (int32_t)INT32_MAX);
printf("INT64_MIN: %"PRIX64"\n", (int64_t)INT64_MIN);
printf("INT64_MAX: %"PRIX64"\n", (int64_t)INT64_MAX);
printf("INTPTR_MIN: %"PRIXMAX"\n", (intptr_t)INTPTR_MIN);
printf("INTPTR_MAX: %"PRIXMAX"\n", (intptr_t)INTPTR_MAX);
printf("INTMAX_MIN: %"PRIXMAX"\n", (intmax_t)INTMAX_MIN);
printf("INTMAX_MAX: %"PRIXMAX"\n", (intmax_t)INTMAX_MAX);
printf("\nsizes\n");
printf("sizeof(int8_t): %lu\n", sizeof(int8_t));
printf("sizeof(uint8_t): %lu\n", sizeof(uint8_t));
printf("sizeof(int16_t): %lu\n", sizeof(int16_t));
printf("sizeof(uint16_t): %lu\n", sizeof(uint16_t));
printf("sizeof(int32_t): %lu\n", sizeof(int32_t));
printf("sizeof(uint32_t): %lu\n", sizeof(uint32_t));
printf("sizeof(int64_t): %lu\n", sizeof(int64_t));
printf("sizeof(uint64_t): %lu\n", sizeof(uint64_t));
printf("sizeof(intptr_t): %lu\n", sizeof(intptr_t));
printf("sizeof(uintptr_t): %lu\n", sizeof(uintptr_t));
printf("sizeof(intmax_t): %lu\n", sizeof(intmax_t));
printf("sizeof(uintmax_t): %lu\n", sizeof(uintmax_t));
}
/*
* All Done!! -- Jessica Noll, age 2
*/
if (c_flag == true) {
printf("\nC compiler and select include files appear to support calc.\n");
}
exit(0);
#endif /* HAVE_INTTYPES_H */
#endif /* HAVE_STDINT_H */
}

46
cmath.h
View File

@@ -1,7 +1,7 @@
/*
* cmath - data structures for extended precision complex arithmetic
*
* Copyright (C) 1999-2007,2014 David I. Bell
* Copyright (C) 1999-2007,2014,2023 David I. Bell and 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
@@ -48,6 +48,7 @@ typedef struct {
/*
* Input, output, and conversion routines.
*/
E_FUNC COMPLEX *cmappr(COMPLEX *c, NUMBER *e, long rnd, bool cfree);
E_FUNC COMPLEX *comalloc(void);
E_FUNC COMPLEX *qqtoc(NUMBER *q1, NUMBER *q2);
E_FUNC void comfree(COMPLEX *c);
@@ -72,12 +73,14 @@ E_FUNC COMPLEX *c_shift(COMPLEX *c, long i);
E_FUNC COMPLEX *c_square(COMPLEX *c);
E_FUNC COMPLEX *c_conj(COMPLEX *c);
E_FUNC COMPLEX *c_real(COMPLEX *c);
E_FUNC NUMBER *c_to_q(COMPLEX *c, bool cfree);
E_FUNC COMPLEX *q_to_c(NUMBER *q);
E_FUNC COMPLEX *c_imag(COMPLEX *c);
E_FUNC COMPLEX *c_neg(COMPLEX *c);
E_FUNC COMPLEX *c_inv(COMPLEX *c);
E_FUNC COMPLEX *c_int(COMPLEX *c);
E_FUNC COMPLEX *c_frac(COMPLEX *c);
E_FUNC BOOL c_cmp(COMPLEX *c1, COMPLEX *c2);
E_FUNC bool c_cmp(COMPLEX *c1, COMPLEX *c2);
/*
@@ -97,6 +100,7 @@ E_FUNC COMPLEX *c_root(COMPLEX *c, NUMBER *q, NUMBER *epsilon);
E_FUNC COMPLEX *c_exp(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_ln(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_log(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_log2(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_cos(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_sin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_cosh(COMPLEX *c, NUMBER *epsilon);
@@ -105,9 +109,13 @@ E_FUNC COMPLEX *c_polar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
E_FUNC COMPLEX *c_rel(COMPLEX *c1, COMPLEX *c2);
E_FUNC COMPLEX *c_asin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_acos(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_tan(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_atan(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_cot(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_acot(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_sec(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_asec(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_csc(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_acsc(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_asinh(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_acosh(COMPLEX *c, NUMBER *epsilon);
@@ -118,14 +126,42 @@ E_FUNC COMPLEX *c_acsch(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_gd(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_agd(COMPLEX *c, NUMBER *epsilon);
/*
* historical trig functions
*/
E_FUNC COMPLEX *c_versin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_aversin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_coversin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_acoversin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_vercos(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_avercos(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_covercos(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_acovercos(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_haversin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_ahaversin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_hacoversin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_ahacoversin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_havercos(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_ahavercos(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_hacovercos(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_ahacovercos(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_exsec(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_aexsec(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_excsc(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_aexcsc(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_crd(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_acrd(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_cas(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_cis(COMPLEX *c, NUMBER *epsilon);
/*
* external functions
*/
E_FUNC COMPLEX *swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
E_FUNC COMPLEX *swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
E_FUNC COMPLEX *swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
E_FUNC COMPLEX *swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, bool all);
E_FUNC COMPLEX *swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, bool all);
E_FUNC COMPLEX *swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, bool all);
/*

View File

@@ -1,7 +1,7 @@
/*
* codegen - module to generate opcodes from the input tokens
*
* Copyright (C) 1999-2007,2017,2021,2022 David I. Bell and Ernest Bowen
* Copyright (C) 1999-2007,2017,2021-2023 David I. Bell and Ernest Bowen
*
* Primary author: David I. Bell
*
@@ -51,17 +51,17 @@
#endif
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
STATIC BOOL rdonce; /* TRUE => do not reread this file */
STATIC bool rdonce; /* true => do not reread this file */
FUNC *curfunc;
S_FUNC int getsymvalue(char *name, VALUE *v_p);
S_FUNC int getfilename(char *name, size_t namelen, BOOL *once);
S_FUNC BOOL getid(char *buf);
S_FUNC int getfilename(char *name, size_t namelen, bool *once);
S_FUNC bool getid(char *buf);
S_FUNC void getshowstatement(void);
S_FUNC void getfunction(void);
S_FUNC void ungetfunction(void);
@@ -101,7 +101,7 @@ S_FUNC int getshiftexpr(void);
S_FUNC int getreference(void);
S_FUNC int getincdecexpr(void);
S_FUNC int getterm(void);
S_FUNC int getidexpr(BOOL okmat, int autodef);
S_FUNC int getidexpr(bool okmat, int autodef);
S_FUNC long getinitlist(void);
#define INDICALLOC 8
@@ -121,14 +121,14 @@ STATIC int maxindices;
* The toplevel flag indicates whether we are at the top interactive level.
*/
void
getcommands(BOOL toplevel)
getcommands(bool toplevel)
{
char name[MAXCMD+1+1]; /* program name */
/* firewall */
name[0] = '\0';
name[MAXCMD+1] = '\0';
abort_now = FALSE;
abort_now = false;
/* getcommands */
if (!toplevel)
@@ -184,7 +184,7 @@ getcommands(BOOL toplevel)
CALCEXT,rdonce);
switch (open_ret) {
case 0:
getcommands(FALSE);
getcommands(false);
closeinput();
continue;
case 1:
@@ -227,7 +227,7 @@ getcommands(BOOL toplevel)
default:
rescantoken();
initstack();
if (evaluate(FALSE))
if (evaluate(false))
updateoldvalue(curfunc);
freefunc(curfunc);
if (abort_now) {
@@ -252,18 +252,18 @@ getcommands(BOOL toplevel)
/*
* Evaluate a line of statements.
* This is done by treating the current line as a function body,
* compiling it, and then executing it. Returns TRUE if the line
* compiling it, and then executing it. Returns true if the line
* successfully compiled and executed. The last expression result
* is saved in the f_savedvalue element of the current function.
* The nestflag variable should be FALSE for the outermost evaluation
* level, and TRUE for all other calls (such as the 'eval' function).
* The nestflag variable should be false for the outermost evaluation
* level, and true for all other calls (such as the 'eval' function).
* The function name begins with an asterisk to indicate specialness.
*
* given:
* nestflag TRUE if this is a nested evaluation
* nestflag true if this is a nested evaluation
*/
BOOL
evaluate(BOOL nestflag)
bool
evaluate(bool nestflag)
{
char *funcname;
int loop = 1; /* 0 => end the main while loop */
@@ -296,9 +296,9 @@ evaluate(BOOL nestflag)
addop(OP_RETURN);
checklabels();
if (errorcount)
return FALSE;
return false;
calculate(curfunc, 0);
return TRUE;
return true;
}
/*
@@ -334,7 +334,7 @@ ungetfunction(void)
return;
}
name = tokensymbol();
endscope(name, FALSE);
endscope(name, false);
continue;
case T_NEWLINE:
@@ -374,7 +374,7 @@ getfunction(void)
scanerror(T_SEMICOLON, "Using builtin function name");
return;
}
beginfunc(name, FALSE);
beginfunc(name, false);
enterfuncscope();
if (gettoken() != T_LEFTPAREN) {
scanerror(T_SEMICOLON,
@@ -466,7 +466,7 @@ getbody(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel,
int oldmode;
oldmode = tokenmode(TM_DEFAULT);
while (TRUE) {
while (true) {
switch (gettoken()) {
case T_RIGHTBRACE:
(void) tokenmode(oldmode);
@@ -495,7 +495,7 @@ getdeclarations(int symtype)
{
int res = 0;
while (TRUE) {
while (true) {
switch (gettoken()) {
case T_COMMA:
continue;
@@ -631,7 +631,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel,
LABEL label;
LABEL label1, label2, label3, label4; /* locations for jumps */
int type;
BOOL printeol;
bool printeol;
int oldmode;
addopone(OP_DEBUG, linenumber());
@@ -960,7 +960,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel,
break;
case T_PRINT:
printeol = TRUE;
printeol = true;
for (;;) {
switch (gettoken()) {
case T_RIGHTPAREN:
@@ -979,14 +979,14 @@ getstatement(LABEL *contlabel, LABEL *breaklabel,
addop(OP_PRINTSPACE);
/*FALLTHRU*/
case T_COLON:
printeol = FALSE;
printeol = false;
break;
case T_STRING:
printeol = TRUE;
printeol = true;
addopone(OP_PRINTSTRING, tokenstring());
break;
default:
printeol = TRUE;
printeol = true;
rescantoken();
(void) getopassignment();
addopone(OP_PRINT, (long) PRINT_NORMAL);
@@ -1195,7 +1195,7 @@ getoneobj(long index, int symtype)
if (gettoken() == T_SYMBOL) {
if (symtype == SYM_UNDEFINED) {
rescantoken();
(void) getidexpr(TRUE, 1);
(void) getidexpr(true, 1);
} else {
symname = tokensymbol();
definesymbol(symname, symtype);
@@ -1278,7 +1278,7 @@ getonematrix(int symtype)
if (gettoken() == T_SYMBOL) {
if (symtype == SYM_UNDEFINED) {
rescantoken();
(void) getidexpr(FALSE, 1);
(void) getidexpr(false, 1);
} else {
name = tokensymbol();
definesymbol(name, symtype);
@@ -2141,7 +2141,7 @@ getterm(void)
case T_SYMBOL:
rescantoken();
type = getidexpr(TRUE, 0);
type = getidexpr(true, 0);
break;
case T_MULT:
@@ -2164,7 +2164,7 @@ getterm(void)
break;
}
rescantoken();
type = getidexpr(TRUE, T_GLOBAL);
type = getidexpr(true, T_GLOBAL);
break;
case T_LOCAL:
@@ -2174,7 +2174,7 @@ getterm(void)
break;
}
rescantoken();
type = getidexpr(TRUE, T_LOCAL);
type = getidexpr(true, T_LOCAL);
break;
case T_STATIC:
@@ -2184,7 +2184,7 @@ getterm(void)
break;
}
rescantoken();
type = getidexpr(TRUE, T_STATIC);
type = getidexpr(true, T_STATIC);
break;
case T_LEFTBRACKET:
@@ -2238,7 +2238,7 @@ getterm(void)
* Returns the type of expression found.
*/
S_FUNC int
getidexpr(BOOL okmat, int autodef)
getidexpr(bool okmat, int autodef)
{
int type;
char name[SYMBOLSIZE+1]; /* symbol name */
@@ -2339,15 +2339,15 @@ getsymvalue(char *name, VALUE *v_p)
* Read in a filename for a read or write command.
* Both quoted and unquoted filenames are handled here.
* The name must be terminated by an end of line or semicolon.
* Returns TRUE if the filename was successfully parsed.
* Returns true if the filename was successfully parsed.
*
* given:
* name filename to read
* namelen length of filename buffer including NUL byte
* once non-NULL => set to TRUE of -once read
* once non-NULL => set to true of -once read
*/
S_FUNC int
getfilename(char *name, size_t namelen, BOOL *once)
getfilename(char *name, size_t namelen, bool *once)
{
STRING *s;
char *symstr; /* symbol string */
@@ -2532,7 +2532,7 @@ getmatargs(void)
*/
dim = 0;
if (gettoken() == T_RIGHTBRACKET) {
addoptwo(OP_INDEXADDR, (long) dim, (long) FALSE);
addoptwo(OP_INDEXADDR, (long) dim, (long) false);
return;
}
rescantoken();
@@ -2542,7 +2542,7 @@ getmatargs(void)
switch (gettoken()) {
case T_RIGHTBRACKET:
addoptwo(OP_INDEXADDR, (long) dim,
(long) FALSE);
(long) false);
return;
case T_COMMA:
break;
@@ -2580,9 +2580,9 @@ getelement(void)
/*
* Read in a single symbol name and copy its value into the given buffer.
* Returns TRUE if a valid symbol id was found.
* Returns true if a valid symbol id was found.
*/
S_FUNC BOOL
S_FUNC bool
getid(char *buf)
{
int type;
@@ -2592,16 +2592,16 @@ getid(char *buf)
scanerror(T_NULL, "Reserved keyword used as symbol name");
type = T_SYMBOL;
*buf = '\0';
return FALSE;
return false;
}
if (type != T_SYMBOL) {
rescantoken();
scanerror(T_NULL, "Symbol name expected");
*buf = '\0';
return FALSE;
return false;
}
strlcpy(buf, tokensymbol(), SYMBOLSIZE+1);
return TRUE;
return true;
}
@@ -2687,11 +2687,11 @@ usesymbol(char *name, int autodef)
if (type == SYM_GLOBAL) {
warning("Unnecessary global specifier");
}
addopptr(OP_GLOBALADDR, (char *) addglobal(name, FALSE));
addopptr(OP_GLOBALADDR, (char *) addglobal(name, false));
return;
}
if (autodef == T_STATIC) {
addopptr(OP_GLOBALADDR, (char *) addglobal(name, TRUE));
addopptr(OP_GLOBALADDR, (char *) addglobal(name, true));
return;
}
if (autodef == T_LOCAL) {
@@ -2721,7 +2721,7 @@ usesymbol(char *name, int autodef)
scanerror(T_NULL, "\"%s\" is undefined", name);
return;
}
(void) addglobal(name, FALSE);
(void) addglobal(name, false);
addopptr(OP_GLOBALADDR, (char *) findglobal(name));
}
@@ -2740,7 +2740,7 @@ getcallargs(char *name)
long index; /* function index */
long op; /* opcode to add */
int argcount; /* number of arguments */
BOOL addrflag;
bool addrflag;
op = OP_CALL;
index = getbuiltinfunc(name);

1643
comfunc.c

File diff suppressed because it is too large Load Diff

174
commath.c
View File

@@ -1,7 +1,7 @@
/*
* commath - extended precision complex arithmetic primitive routines
*
* Copyright (C) 1999-2007,2021,2022 David I. Bell
* Copyright (C) 1999-2007,2021-2023 David I. Bell
*
* 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
@@ -27,7 +27,7 @@
#include "cmath.h"
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -38,6 +38,77 @@ COMPLEX _conei_ = { &_qzero_, &_qone_, 1 };
STATIC COMPLEX _cnegone_ = { &_qnegone_, &_qzero_, 1 };
/*
* cmappr - complex multiple approximation
*
* Approximate a number to nearest multiple of a given real number. Whether
* rounding is down, up, etc. is determined by rnd.
*
* This function is useful to round a result to the nearest epsilon:
*
* 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);
*
* given:
* c pointer to COMPLEX value to round
* e pointer to NUMBER multiple
* rnd rounding mode
* cfree true ==> free c, false ==> do not free c
*
* returns:
* allocated pointer to COMPLEX multiple of e approximation of c
*/
COMPLEX *
cmappr(COMPLEX *c, NUMBER *e, long rnd, bool cfree)
{
COMPLEX *r; /* COMPLEX multiple of e approximation of c */
/*
* firewall
*/
if (c == NULL) {
math_error("%s: c is NULL", __func__);
not_reached();
}
if (e == NULL) {
math_error("%s: e is NULL", __func__);
not_reached();
}
/*
* allocate return result
*/
r = comalloc();
/*
* round c to multiple of e
*/
qfree(r->real);
r->real = qmappr(c->real, e, rnd);
qfree(r->imag);
r->imag = qmappr(c->imag, e, rnd);
/*
* free c if requested
*/
if (cfree == true) {
comfree(c);
}
/*
* return the allocated multiple of e approximation of c
*/
return r;
}
/*
* Add two complex numbers.
*/
@@ -396,6 +467,97 @@ c_real(COMPLEX *c)
}
/*
* c_to_q - convert a real part of a COMPLEX to a NUMBER
*
* given:
* c complex number for which the real part will be used
* cfree true ==> free c, false ==> do not free c
*
* returns:
* allocated NUMBER that the equivalent of the real part of a complex number
*
* NOTE: Any imaginary part of the COMPLEX value is ignored.
*
* NOTE: To avoid a loss of value, test with cisreal(c) first:
*
* COMPLEX *c;
* NUMBER *q;
* bool ok_to_free;
*
* if (cisreal(c)) {
* q = c_to_q(c, ok_to_free);
* }
*/
NUMBER *
c_to_q(COMPLEX *c, bool cfree)
{
NUMBER *r; /* allocated NUMBER equivalent to return */
/*
* firewall
*/
if (c == NULL) {
math_error("%s: c is NULL", __func__);
not_reached();
}
/*
* allocate a new NUMBER
*/
r = qalloc();
/*
* link in the real part of the COMPLEX value
*/
r = qlink(c->real);
/*
* free c if requested
*/
if (cfree == true) {
comfree(c);
}
/*
* return the allocated equivalent NUMBER
*/
return r;
}
/*
* q_to_c - convert a NUMBER into an allocated COMPLEX
*
* given:
* q NUMBER to be converted
*
* returns:
* allocated COMPLEX number whose real part is NUMBER and imag part is 0
*/
COMPLEX *
q_to_c(NUMBER *q)
{
COMPLEX *res; /* COMPLEX number to return */
/*
* allocate complex number
*/
res = comalloc();
/*
* assign NUMBER to real part
*/
qfree(res->real);
res->real = qlink(q);
/*
* return the allocated equivalent COMPLEX
*/
return res;
}
/*
* Return the imaginary part of a complex number as a real.
*/
@@ -560,13 +722,13 @@ qqtoc(NUMBER *q1, NUMBER *q2)
/*
* Compare two complex numbers for equality, returning FALSE if they are equal,
* and TRUE if they differ.
* Compare two complex numbers for equality, returning false if they are equal,
* and true if they differ.
*/
BOOL
bool
c_cmp(COMPLEX *c1, COMPLEX *c2)
{
BOOL i;
bool i;
i = qcmp(c1->real, c2->real);
if (!i)

132
config.c
View File

@@ -1,7 +1,7 @@
/*
* config - configuration routines
*
* Copyright (C) 1999-2007,2021,2022 David I. Bell and Landon Curt Noll
* Copyright (C) 1999-2007,2021-2023 David I. Bell and Landon Curt Noll
*
* Primary author: David I. Bell
*
@@ -62,7 +62,7 @@
#endif /* HAVE_STRDUP */
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -106,6 +106,7 @@ NAMETYPE configs[] = {
{"cfsim", CONFIG_CFSIM},
{"outround", CONFIG_OUTROUND},
{"round", CONFIG_ROUND},
{"triground", CONFIG_TRIGROUND},
{"leadzero", CONFIG_LEADZERO},
{"fullzero", CONFIG_FULLZERO},
{"maxscan", CONFIG_MAXSCAN},
@@ -147,17 +148,17 @@ CONFIG oldstd = { /* backward compatible standard configuration */
20, /* current output digits for float or exp */
NULL, /* loaded in at startup - default error for real functions */
EPSILONPREC_DEFAULT, /* binary precision of epsilon */
FALSE, /* tracing flags */
false, /* tracing flags */
MAXPRINT_DEFAULT, /* number of elements to print */
MUL_ALG2, /* size of number to use multiply alg 2 */
SQ_ALG2, /* size of number to use square alg 2 */
POW_ALG2, /* size of modulus to use REDC for powers */
REDC_ALG2, /* size of modulus to use REDC algorithm 2 */
TRUE, /* TRUE ==> print a tilde on approximations */
FALSE, /* TRUE ==> print a space after tilde on approximations */
FALSE, /* TRUE ==> print spaces around / in fractions */
FALSE, /* TRUE ==> print spaces around + or - in complex values */
TRUE, /* TRUE ==> print tab before numeric values */
true, /* true ==> print a tilde on approximations */
false, /* true ==> print a space after tilde on approximations */
false, /* true ==> print spaces around / in fractions */
false, /* true ==> print spaces around + or - in complex values */
true, /* true ==> print tab before numeric values */
0, /* quomod() default rounding mode */
2, /* quotient // default rounding mode */
0, /* mod % default rounding mode */
@@ -167,42 +168,43 @@ CONFIG oldstd = { /* backward compatible standard configuration */
8, /* cfsim() default rounding mode */
2, /* output default rounding mode */
24, /* round()/bround() default rounding mode */
FALSE, /* TRUE ==> print leading 0 before decimal pt */
0, /* TRUE ==> print trailing 0's */
24, /* trigonometric and hyperbolic function rounding mode */
false, /* true ==> print leading 0 before decimal pt */
0, /* true ==> print trailing 0's */
MAXSCANCOUNT, /* max scan errors before abort */
PROMPT1, /* normal prompt */
PROMPT2, /* prompt when inside multi-line input */
BLK_DEF_MAXPRINT, /* number of octets of a block to print */
FALSE, /* skip duplicate block output lines */
false, /* skip duplicate block output lines */
BLK_BASE_HEX, /* block octet print base */
BLK_FMT_HD_STYLE, /* block output format */
0, /* internal calc debug level */
3, /* calc resource file debug level */
0, /* user defined debug level */
FALSE, /* TRUE ==> print Quit or abort executed messages */
false, /* true ==> print Quit or abort executed messages */
CTRL_D_VIRGIN_EOF, /* ^D only exits on virgin lines */
NULL, /* our name */
NULL, /* basename of our name */
#if defined(_WIN32) || defined(_WIN64)
TRUE, /* TRUE ==> running under windows */
true, /* true ==> running under windows */
#else
FALSE, /* FALSE ==> not using windows */
false, /* false ==> not using windows */
#endif
#if defined(__CYGWIN__)
TRUE, /* TRUE ==> compiled under cygwin */
true, /* true ==> compiled under cygwin */
#else
FALSE, /* FALSE ==> not compiled with cygwin */
false, /* false ==> not compiled with cygwin */
#endif
#if defined(CUSTOM)
TRUE, /* TRUE ==> compiled with -DCUSTOM */
true, /* true ==> compiled with -DCUSTOM */
#else
FALSE, /* FALSE ==> compiled without -DCUSTOM */
false, /* false ==> compiled without -DCUSTOM */
#endif
&allow_custom, /* *TRUE=> custom functions are enabled */
&allow_custom, /* *true=> custom functions are enabled */
NULL, /* version */
BASEB, /* base for calculations */
TRUE, /* TRUE ==> warn when redeclaring */
TRUE, /* TRUE ==> warn when variable names collide */
true, /* true ==> warn when redeclaring */
true, /* true ==> warn when variable names collide */
};
CONFIG newstd = { /* new non-backward compatible configuration */
MODE_INITIAL, /* current output mode */
@@ -210,17 +212,17 @@ CONFIG newstd = { /* new non-backward compatible configuration */
20, /* current output digits for float or exp */
NULL, /* loaded in at startup - default error for real functions */
EPSILONPREC_DEFAULT, /* binary precision of epsilon */
FALSE, /* tracing flags */
false, /* tracing flags */
MAXPRINT_DEFAULT, /* number of elements to print */
MUL_ALG2, /* size of number to use multiply alg 2 */
SQ_ALG2, /* size of number to use square alg 2 */
POW_ALG2, /* size of modulus to use REDC for powers */
REDC_ALG2, /* size of modulus to use REDC algorithm 2 */
TRUE, /* TRUE ==> print a tilde on approximations */
FALSE, /* TRUE ==> print spaces around / in fractions */
FALSE, /* TRUE ==> print a space after tilde on approximations */
FALSE, /* TRUE ==> print spaces around + or - in complex values */
TRUE, /* TRUE ==> print tab before numeric values */
true, /* true ==> print a tilde on approximations */
false, /* true ==> print spaces around / in fractions */
false, /* true ==> print a space after tilde on approximations */
false, /* true ==> print spaces around + or - in complex values */
true, /* true ==> print tab before numeric values */
0, /* quomod() default rounding mode */
2, /* quotient // default rounding mode */
0, /* mod % default rounding mode */
@@ -230,42 +232,43 @@ CONFIG newstd = { /* new non-backward compatible configuration */
8, /* cfsim() default rounding mode */
24, /* output default rounding mode */
24, /* round()/bround() default rounding mode */
TRUE, /* TRUE ==> print leading 0 before decimal pt */
0, /* TRUE ==> print trailing 0's */
24, /* trigonometric and hyperbolic function rounding mode */
true, /* true ==> print leading 0 before decimal pt */
0, /* true ==> print trailing 0's */
MAXSCANCOUNT, /* max scan errors before abort */
"; ", /* normal prompt */
";; ", /* prompt when inside multi-line input */
BLK_DEF_MAXPRINT, /* number of octets of a block to print */
FALSE, /* skip duplicate block output lines */
false, /* skip duplicate block output lines */
BLK_BASE_HEX, /* block octet print base */
BLK_FMT_HD_STYLE, /* block output format */
0, /* internal calc debug level */
3, /* calc resource file debug level */
0, /* user defined debug level */
FALSE, /* TRUE ==> print Quit or abort executed messages */
false, /* true ==> print Quit or abort executed messages */
CTRL_D_VIRGIN_EOF, /* ^D only exits on virgin lines */
NULL, /* our name */
NULL, /* basename of our name */
#if defined(_WIN32) || defined(_WIN64)
TRUE, /* TRUE ==> running under windows */
true, /* true ==> running under windows */
#else
FALSE, /* FALSE ==> not using windows */
false, /* false ==> not using windows */
#endif
#if defined(__CYGWIN__)
TRUE, /* TRUE ==> compiled under cygwin */
true, /* true ==> compiled under cygwin */
#else
FALSE, /* FALSE ==> not compiled with cygwin */
false, /* false ==> not compiled with cygwin */
#endif
#if defined(CUSTOM)
TRUE, /* TRUE ==> compiled with -DCUSTOM */
true, /* true ==> compiled with -DCUSTOM */
#else
FALSE, /* FALSE ==> compiled without -DCUSTOM */
false, /* false ==> compiled without -DCUSTOM */
#endif
&allow_custom, /* *TRUE ==> custom functions are enabled */
&allow_custom, /* *true ==> custom functions are enabled */
NULL, /* version */
BASEB, /* base for calculations */
TRUE, /* TRUE ==> warn when redeclaring */
TRUE, /* TRUE ==> warn when variable names collide */
true, /* true ==> warn when redeclaring */
true, /* true ==> warn when variable names collide */
};
CONFIG *conf = NULL; /* loaded in at startup - current configuration */
@@ -358,23 +361,23 @@ STATIC NAMETYPE ctrl_d[] = {
/*
* Possible binary config state values
*/
#define TRUE_STRING "true"
#define FALSE_STRING "false"
#define true_STRING "true"
#define false_STRING "false"
STATIC NAMETYPE truth[] = {
{TRUE_STRING, TRUE},
{"t", TRUE},
{"on", TRUE},
{"yes", TRUE},
{"y", TRUE},
{"set", TRUE},
{"1", TRUE},
{FALSE_STRING, FALSE},
{"f", FALSE},
{"off", FALSE},
{"no", FALSE},
{"n", FALSE},
{"unset", FALSE},
{"0", FALSE},
{true_STRING, true},
{"t", true},
{"on", true},
{"yes", true},
{"y", true},
{"set", true},
{"1", true},
{false_STRING, false},
{"f", false},
{"off", false},
{"no", false},
{"n", false},
{"unset", false},
{"0", false},
{NULL, 0}
};
@@ -761,6 +764,14 @@ setconfig(int type, VALUE *vp)
conf->round = len;
break;
case CONFIG_TRIGROUND:
if (getlen(vp, &len)) {
math_error("Illegal value for triground");
not_reached();
}
conf->triground = len;
break;
case CONFIG_LEADZERO:
if (vp->v_type == V_NUM) {
q = vp->v_num;
@@ -1308,6 +1319,10 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
i = cfg->round;
break;
case CONFIG_TRIGROUND:
i = cfg->triground;
break;
case CONFIG_LEADZERO:
i = (cfg->leadzero ? 1 : 0);
break;
@@ -1468,9 +1483,9 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
* cfg2 - 2nd CONFIG to compare
*
* return:
* TRUE if configurations differ
* true if configurations differ
*/
BOOL
bool
config_cmp(CONFIG *cfg1, CONFIG *cfg2)
{
/*
@@ -1512,6 +1527,7 @@ config_cmp(CONFIG *cfg1, CONFIG *cfg2)
cfg1->cfsim != cfg2->cfsim ||
cfg1->outround != cfg2->outround ||
cfg1->round != cfg2->round ||
cfg1->triground != cfg2->triground ||
cfg1->leadzero != cfg2->leadzero ||
cfg1->fullzero != cfg2->fullzero ||
cfg1->maxscancount != cfg2->maxscancount ||

View File

@@ -1,7 +1,7 @@
/*
* config - configuration routines
*
* Copyright (C) 1999-2007,2014,2021 Landon Curt Noll and David I. Bell
* Copyright (C) 1999-2007,2014,2021,2023 Landon Curt Noll and David I. Bell
*
* Primary author: Landon Curt Noll
*
@@ -97,6 +97,7 @@
#define CONFIG_TILDE_SPACE 47
#define CONFIG_FRACTION_SPACE 48
#define CONFIG_COMPLEX_SPACE 49
#define CONFIG_TRIGROUND 50
/*
@@ -120,6 +121,7 @@
* config_value(), config_cmp(),
* and perhaps config_copy(), config_free()
* config.h - CONFIG_XYZ_SYMBOL (see above)
* help/config - document new config option
*/
struct config {
int outmode; /* current output mode */
@@ -133,11 +135,11 @@ struct config {
LEN sq2; /* size of number to use square algorithm 2 */
LEN pow2; /* size of modulus to use REDC for powers */
LEN redc2; /* size of modulus to use REDC algorithm 2 */
BOOL tilde_ok; /* OK to print a tilde on approximations */
BOOL tilde_space; /* print space after tilde on approximations */
BOOL fraction_space; /* TRUE => print spaces around / in fractions */
BOOL complex_space; /* TRUE => print spaces around + or - in complex values */
BOOL tab_ok; /* OK to print tab before numeric values */
bool tilde_ok; /* OK to print a tilde on approximations */
bool tilde_space; /* print space after tilde on approximations */
bool fraction_space; /* true => print spaces around / in fractions */
bool complex_space; /* true => print spaces around + or - in complex values */
bool tab_ok; /* OK to print tab before numeric values */
LEN quomod; /* quomod() default rounding mode */
LEN quo; /* quotient // default rounding mode */
LEN mod; /* mod % default rounding mode */
@@ -147,30 +149,31 @@ struct config {
LEN cfsim; /* cfsim() default rounding mode */
LEN outround; /* output default rounding mode */
LEN round; /* round()/bround() default rounding mode */
BOOL leadzero; /* OK to print leading 0 before decimal pt */
BOOL fullzero; /* OK to print trailing 0's */
LEN triground; /* trigonometric and hyperbolic function rounding mode */
bool leadzero; /* OK to print leading 0 before decimal pt */
bool fullzero; /* OK to print trailing 0's */
long maxscancount; /* max scan errors before abort */
char *prompt1; /* normal prompt */
char *prompt2; /* prompt when inside multi-line input */
int blkmaxprint; /* octets of a block to print, 0 => all */
BOOL blkverbose; /* TRUE => print all lines if a block */
bool blkverbose; /* true => print all lines if a block */
int blkbase; /* block output base */
int blkfmt; /* block output style */
long calc_debug; /* internal debug, see CALC_DEBUG_XYZ below */
long resource_debug; /* resource debug, see RSCDBG_XYZ below */
long user_debug; /* user defined debug value: 0 default */
BOOL verbose_quit; /* TRUE => print Quit or abort executed msg */
bool verbose_quit; /* true => print Quit or abort executed msg */
int ctrl_d; /* see CTRL_D_xyz below */
char *program; /* our name */
char *base_name; /* basename of our name */
BOOL windows; /* TRUE => running under MS windows */
BOOL cygwin; /* TRUE => compiled with cygwin */
BOOL compile_custom; /* TRUE => compiled with -DCUSTOM */
BOOL *allow_custom; /* ptr to if custom functions are allowed */
bool windows; /* true => running under MS windows */
bool cygwin; /* true => compiled with cygwin */
bool compile_custom; /* true => compiled with -DCUSTOM */
bool *allow_custom; /* ptr to if custom functions are allowed */
char *version; /* calc version string */
int baseb; /* base for calculations */
BOOL redecl_warn; /* TRUE => warn of redeclaring variables */
BOOL dupvar_warn; /* TRUE => warn of var name collisions */
bool redecl_warn; /* true => warn of redeclaring variables */
bool dupvar_warn; /* true => warn of var name collisions */
};
typedef struct config CONFIG;
@@ -225,7 +228,7 @@ E_FUNC void config_free(CONFIG *cfg);
E_FUNC void config_print(CONFIG *cfg);
E_FUNC int configtype(char*);
E_FUNC void config_print(CONFIG*);
E_FUNC BOOL config_cmp(CONFIG*, CONFIG*);
E_FUNC bool config_cmp(CONFIG*, CONFIG*);
#endif /* !INCLUDE_CONFIG_H */

12
const.c
View File

@@ -1,7 +1,7 @@
/*
* const - constant number storage module
*
* Copyright (C) 1999-2007,2021,2022 David I. Bell
* Copyright (C) 1999-2007,2021-2023 David I. Bell
*
* 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
@@ -29,7 +29,7 @@
#include "qmath.h"
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -99,7 +99,7 @@ addqconstant(NUMBER *q)
HALF numlow; /* bottom value of numerator */
HALF denlow; /* bottom value of denominator */
long first; /* first non-null position found */
BOOL havefirst;
bool havefirst;
if (constavail <= 0) {
if (consttable == NULL) {
@@ -120,7 +120,7 @@ addqconstant(NUMBER *q)
numlow = q->num.v[0];
denlow = q->den.v[0];
first = 0;
havefirst = FALSE;
havefirst = false;
tp = consttable;
for (index = 0; index < constcount; index++, tp++) {
t = *tp;
@@ -129,7 +129,7 @@ addqconstant(NUMBER *q)
}
if (t->links == 0) {
if (!havefirst) {
havefirst = TRUE;
havefirst = true;
first = index;
}
continue;
@@ -140,7 +140,7 @@ addqconstant(NUMBER *q)
*tp = consttable[first];
consttable[first] = q;
} else {
havefirst = TRUE;
havefirst = true;
first = index;
}
continue;

View File

@@ -4,13 +4,7 @@
#
# Copyright (C) 1999-2006,2014,2017,2021-2023 Landon Curt Noll
#
# SRC: cscript/Makefile
#
# The "# SRC: ... - ..." comment line above indicates
# the origin of this file.
#
# IMPORTANT: Please see the section on Makefiles near the
# bottom of the HOWTO.INSTALL file.
# Suggestion: Read the ../HOWTO.INSTALL file.
#
# 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
@@ -29,184 +23,63 @@
# Under source code control: 1999/11/29 11:10:26
# File existed as early as: 1999
#
# This calculator first developed by David I. Bell with help/mods from others.
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
#
# calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# The shell used by this Makefile
#
# On some systems, /bin/sh is a rather reduced shell with
# deprecated behavior.
#
# If your system has a up to date, bash shell, then
# you may wish to use:
#
# SHELL= bash
#
# On some systems such as macOS, the bash shell is very
# far behind to the point where is cannot be depended on.
# On such systems, the sh may be a much better alternative
# shell for this Makefile to use:
#
# SHELL= sh
#
SHELL= bash
#SHELL= sh
#if 0 /* start of skip for non-Gnu makefiles */
#
ifeq ($(target),Darwin)
SHELL:= /bin/sh
endif
#endif /* end of skip for non-Gnu makefiles */
# SUGGESTION: Instead of modifying this file, consider adding
# statements to modify, replace or append Makefile
# variables in the ../Makefile.local file.
####
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
####
# PREFIX - Top level location for calc
#
# The PREFIX is often prepended to paths within calc and calc Makefiles.
#
# Starting with calc v2.13.0.1, nearly all Makefile places that used
# /usr/local now use ${PREFIX}. An exception is the olduninstall rule
# and, of course, this section. :-)
#
# NOTE: The ${PREFIX} is not the same as ${T}. The ${T} specifies
# a top level directory under which calc installs things.
# While usually ${T} is empty, it can be specific path
# as if calc where "chrooted" during an install.
# The ${PREFIX} value, during install, is a path between
# the top level ${T} install directory and the object
# such as an include file.
#
# NOTE: See also, ${T}, below.
#
# There are some paths that do NOT call under ${PREFIX}, such as
# ${CALCPATH}, that include paths not under ${PREFIX}, but those
# too are exceptions to this general rule.
#
# When in doubt, try:
#
# PREFIX= /usr/local
#
PREFIX= /usr/local
#PREFIX= /usr
#PREFIX= /usr/global
###########################################
# Files used or included by this Makefile #
###########################################
# Normally certain files depend on the Makefile. If the Makefile is
# changed, then certain steps should be redone. If MAKE_FILE is
# set to Makefile, then these files will depend on Makefile. If
# MAKE_FILE is empty, then they wont.
# MAKE_FILE is empty, then they won't.
#
# If in doubt, set MAKE_FILE to Makefile
#
MAKE_FILE= Makefile
# Where the system include (.h) files are kept
#
# For DJGPP, select:
#
# INCDIR= /dev/env/DJDIR/include
#
# If in doubt, set:
#
# INCDIR= /usr/include
# Calc configuration and compile configuration values
#
CONFIG_MKF= ../Makefile.config
#INCDIR= ${PREFIX}/include
#INCDIR= /dev/env/DJDIR/include
INCDIR= /usr/include
# Host targets that are shared in common with both Makefile
# and custom/Makefile.
#
TARGET_MKF= ../Makefile.target
# where to install calc related things
# Host target information.
#
# ${BINDIR} where to install calc binary files
# ${LIBDIR} where calc link library (*.a) files are installed
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
#
# NOTE: The install rule prepends installation paths with ${T}, which
# by default is empty. If ${T} is non-empty, then installation
# locations will be relative to the ${T} directory.
#
# For DJGPP, select:
#
# BINDIR= /dev/env/DJDIR/bin
# LIBDIR= /dev/env/DJDIR/lib
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
#
# If in doubt, set:
#
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
#
#BINDIR= ${PREFIX}/bin
#BINDIR= /dev/env/DJDIR/bin
BINDIR= /usr/bin
LOCAL_MKF= ../Makefile.local
#LIBDIR= ${PREFIX}/lib
#LIBDIR= /dev/env/DJDIR/lib
LIBDIR= /usr/lib
# The set of Makefiles
#
MK_SET= ${MAKE_FILE} ${CONFIG_MKF} ${TARGET_MKF} ${LOCAL_MKF}
#CALC_SHAREDIR= ${PREFIX}/lib/calc
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
CALC_SHAREDIR= /usr/share/calc
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
# ---------------------------------------------------------------
# ${HELPDIR} where the help directory is installed
# ${CALC_INCDIR} where the calc include files are installed
# ${SCRIPTDIR} where calc shell scripts are installed
#
# NOTE: The install rule prepends installation paths with ${T}, which
# by default is empty. If ${T} is non-empty, then installation
# locations will be relative to the ${T} directory.
#
# If in doubt, set:
#
# HELPDIR= ${CALC_SHAREDIR}/help
# CALC_INCDIR= ${INCDIR}/calc
# SCRIPTDIR= ${BINDIR}/cscript
#
HELPDIR= ${CALC_SHAREDIR}/help
CALC_INCDIR= ${INCDIR}/calc
SCRIPTDIR= ${BINDIR}/cscript
#######################################################
# Calc configuration and compile configuration values #
#######################################################
include ${CONFIG_MKF}
# T - top level directory under which calc will be installed
#
# The calc install is performed under ${T}, the calc build is
# performed under /. The purpose for ${T} is to allow someone
# to install calc somewhere other than into the system area.
#
# For example, if:
#
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
#
# and if:
#
# T= /var/tmp/testing
#
# Then the installation locations will be:
#
# calc binary files: /var/tmp/testing/usr/bin
# calc link library: /var/tmp/testing/usr/lib
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
# ... etc ... /var/tmp/testing/...
#
# If ${T} is empty, calc is installed under /, which is the same
# top of tree for which it was built. If ${T} is non-empty, then
# calc is installed under ${T}, as if one had to chroot under
# ${T} for calc to operate.
#
# If in doubt, use T=
#
T=
###############################
# host target section include #
###############################
include ${TARGET_MKF}
##########################################################################
#=-=-=-=-=- Be careful if you change something below this line -=-=-=-=-=#
##########################################################################
# Makefile debug
#
@@ -240,29 +113,6 @@ H=@
V=@:
#V=@
# standard tools
#
CAT= cat
CHMOD= chmod
CMP= cmp
CO= co
CP= cp
FMT= fmt
MKDIR= mkdir
MV= mv
RM= rm
RMDIR= rmdir
SED= sed
SORT= sort
TOUCH= touch
TRUE= true
# NOTE: On some shells, echo is a builtin that does
# not understand -n, so we call /bin/echo -n
# directly to get around such shells.
#
ECHON= /bin/echo -n
# The ${SCRIPT} list is the list of calc shell script files (without the .calc
# extension) which will be installed.
#
@@ -304,10 +154,26 @@ TARGETS= ${CSCRIPT_TARGETS} README
#
PHONY= all clobber distlist install
############################################################
# Allow Makefile.local to change any of the above settings #
############################################################
include ${LOCAL_MKF}
###########################################
# all - First and default Makefile target #
###########################################
# The reason for this Makefile
#
all: ${TARGETS} .all
###############################
# additional Makefile targets #
###############################
.PHONY: ${PHONY}
README: README.src

View File

@@ -1,7 +1,7 @@
/*
* custom - interface for custom software and hardware interfaces
*
* Copyright (C) 1999-2006,2018,2021,2022 Landon Curt Noll
* Copyright (C) 1999-2006,2018,2021-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
@@ -41,6 +41,8 @@
# include <string.h>
#endif
EXTERN CONST struct custom cust[]; /* custom interface table */
#else /* CUSTOM */
#include "config.h"
@@ -48,11 +50,11 @@
#endif /* CUSTOM */
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
BOOL allow_custom = FALSE; /* TRUE => custom builtins allowed */
bool allow_custom = false; /* true => custom builtins allowed */
/*
@@ -66,6 +68,16 @@ custom(char *name, int count, VALUE **vals)
CONST struct custom *p; /* current function */
/*
* error if libcustcalc was compiled with CUSTOM undefined
*/
if (custom_compiled() != true) {
math_error("libcustcalc was compiled with CUSTOM undefined "
"custom_compiled() returned: %d != %d",
custom_compiled(), true);
not_reached();
}
/*
* search the custom interface table for a function
*/
@@ -98,6 +110,16 @@ custom(char *name, int count, VALUE **vals)
#else /* CUSTOM */
/*
* error if libcustcalc was compiled with CUSTOM defined
*/
if (custom_compiled() != false) {
math_error("libcustcalc was compiled with CUSTOM defined "
"custom_compiled() returned: %d != %d",
custom_compiled(), false);
not_reached();
}
fprintf(stderr,
"%sCalc was built with custom functions disabled\n",
(conf->tab_ok ? "\t" : ""));

View File

@@ -1,7 +1,7 @@
/*
* custom - interface for custom software and hardware interfaces
*
* Copyright (C) 1999-2007,2021 Landon Curt Noll
* Copyright (C) 1999-2007,2021,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
@@ -26,7 +26,7 @@
/*
* Be careful what you put in this file, upper .c files include
* this file even when CUSTOM is not defined (ALLOW_CUSTOM is empty).
* this file even when CUSTOM is not defined (ALLOW_CUSTOM="-UCUSTOM").
*
* Don't include anything, let the including .c file bring in:
*
@@ -73,11 +73,11 @@ struct custom {
*
* These are the required interfaces. The dummy.c stubs these interfaces too.
*/
E_FUNC bool custom_compiled(void); /* return true if libcustcalc compiled CUSTOM defined, false otherwise */
E_FUNC VALUE custom(char*, int, VALUE**); /* master custom interface */
EXTERN BOOL allow_custom; /* TRUE => custom builtins allowed */
EXTERN bool allow_custom; /* true => custom builtins allowed */
E_FUNC void showcustom(void); /* print custom functions */
E_FUNC void customhelp(char *); /* direct custom help */
EXTERN CONST struct custom cust[]; /* custom interface table */
E_FUNC void init_custreg(void); /* initialize custom registers */
#endif /* !CUSTOM_H */

View File

@@ -19,6 +19,10 @@ must be invoked with a -C argument:
when it is run.
To disable custom even if -C is given, calc must be built with:
ALLOW_CUSTOM="-UCUSTOM"
See the ../cal/README or "help resource" for information about
calc resource standards and guidelines.
@@ -41,7 +45,7 @@ pzasusb8.cal
Run custom("pzasusb8") on a standard set of data, print Endian
related information and print value size information.
## Copyright (C) 1999,2021 Landon Curt Noll
## Copyright (C) 1999,2021,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

@@ -168,8 +168,7 @@ Step 5: Write your custom function
#endif /* CUSTOM */
This allows this code to 'go away' when the upper Makefile
disables the custom code (because ALLOW_CUSTOM no longer
has the -DCUSTOM define).
disables the custom code when CUSTOM is not defined.
b) The function type must be:
@@ -571,10 +570,10 @@ Step 9: Add the Make dependency tools
u_curds.o: ../alloc.h
u_curds.o: ../block.h
u_curds.o: ../byteswap.h
u_curds.o: ../calcerr.h
u_curds.o: ../cmath.h
u_curds.o: ../config.h
u_curds.o: ../endian_calc.h
u_curds.o: ../errsym.h
u_curds.o: ../hash.h
u_curds.o: ../have_const.h
u_curds.o: ../have_malloc.h

View File

@@ -4,13 +4,7 @@
#
# Copyright (C) 1999-2006,2014,2017-2018,2021,2023 Landon Curt Noll
#
# SRC: custom/Makefile
#
# The "# SRC: ... - ..." comment line above indicates
# the origin of this file.
#
# IMPORTANT: Please see the section on Makefiles near the
# bottom of the HOWTO.INSTALL file.
# Suggestion: Read the ../HOWTO.INSTALL file.
#
# 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
@@ -29,131 +23,63 @@
# Under source code control: 1997/03/09 02:28:54
# File existed as early as: 1997
#
# This calculator first developed by David I. Bell with help/mods from others.
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
#
# calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# The shell used by this Makefile
#
# On some systems, /bin/sh is a rather reduced shell with
# deprecated behavior.
#
# If your system has a up to date, bash shell, then
# you may wish to use:
#
# SHELL= bash
#
# On some systems such as macOS, the bash shell is very
# far behind to the point where is cannot be depended on.
# On such systems, the sh may be a much better alternative
# shell for this Makefile to use:
#
# SHELL= sh
#
SHELL= bash
#SHELL= sh
#if 0 /* start of skip for non-Gnu makefiles */
#
ifeq ($(target),Darwin)
SHELL:= /bin/sh
endif
#endif /* end of skip for non-Gnu makefiles */
# SUGGESTION: Instead of modifying this file, consider adding
# statements to modify, replace or append Makefile
# variables in the ../Makefile.local file.
# PREFIX - Top level location for calc
###########################################
# Files used or included by this Makefile #
###########################################
# Normally certain files depend on the Makefile. If the Makefile is
# changed, then certain steps should be redone. If MAKE_FILE is
# set to Makefile, then these files will depend on Makefile. If
# MAKE_FILE is empty, then they won't.
#
# The PREFIX is often prepended to paths within calc and calc Makefiles.
# If in doubt, set MAKE_FILE to Makefile
#
# Starting with calc v2.13.0.1, nearly all Makefile places that used
# /usr/local now use ${PREFIX}. An exception is the olduninstall rule
# and, of course, this section. :-)
MAKE_FILE= Makefile
# Calc configuration and compile configuration values
#
# NOTE: The ${PREFIX} is not the same as ${T}. The ${T} specifies
# a top level directory under which calc installs things.
# While usually ${T} is empty, it can be specific path
# as if calc where "chrooted" during an install.
# The ${PREFIX} value, during install, is a path between
# the top level ${T} install directory and the object
# such as an include file.
CONFIG_MKF= ../Makefile.config
# Host targets that are shared in common with both Makefile
# and custom/Makefile.
#
# NOTE: See also, ${T}, below.
TARGET_MKF= ../Makefile.target
# Host target information.
#
# There are some paths that do NOT call under ${PREFIX}, such as
# ${CALCPATH}, that include paths not under ${PREFIX}, but those
# too are exceptions to this general rule.
LOCAL_MKF= ../Makefile.local
# The set of Makefiles
#
# When in doubt, try:
#
# PREFIX= /usr/local
#
PREFIX= /usr/local
#PREFIX= /usr
#PREFIX= /usr/global
MK_SET= ${MAKE_FILE} ${CONFIG_MKF} ${TARGET_MKF} ${LOCAL_MKF}
# CCBAN is given to ${CC} in order to control if banned.h is in effect.
#
# The banned.h attempts to ban the use of certain dangerous functions
# that, if improperly used, could compromise the computational integrity
# if calculations.
#
# In the case of calc, we are motivated in part by the desire for calc
# to correctly calculate: even during extremely long calculations.
#
# If UNBAN is NOT defined, then calling certain functions
# will result in a call to a non-existent function (link error).
#
# While we do NOT encourage defining UNBAN, there may be
# a system / compiler environment where re-defining a
# function may lead to a fatal compiler complication.
# If that happens, consider compiling as:
#
# make clobber all chk CCBAN=-DUNBAN
#
# as see if this is a work-a-round.
#
# If YOU discover a need for the -DUNBAN work-a-round, PLEASE tell us!
# Please send us a bug report. See the file:
#
# BUGS
#
# or the URL:
#
# http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html
#
# for how to send us such a bug report.
#
CCBAN= -UUNBAN
#CCBAN= -DUNBAN
#######################################################
# Calc configuration and compile configuration values #
#######################################################
include ${CONFIG_MKF}
#if 0 /* start of skip for non-Gnu makefiles */
###############################
# host target section include #
###############################
include ${TARGET_MKF}
# Unfortunately due to the complex dependency issues between
# Makefile, and custom/Makefile, parallel GNU make
# is NOT recommended.
#
# XXX - fix this - XXX
#
.NOTPARALLEL:
##############################################################################
#-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-#
##############################################################################
# NOTE: You can force a target value by defining target as in:
#
# make ...__optional_arguments_... target=value
# Try uname -s if the target was not already set on the make command line
#
ifeq ($(target),)
target=$(shell uname -s 2>/dev/null)
endif
#endif /* end of skip for non-Gnu makefiles */
##################################
# Files managed by this Makefile #
##################################
# The custom calc resource files to install
#
@@ -198,16 +124,10 @@ CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c c_pzasusb8.c \
CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o c_pzasusb8.o \
c_pmodm127.o c_register.o
##############################################################################
#-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-#
##############################################################################
##############################################################################
#-=-=-=-=-=-=- Defaults in case you want to build from this dir -=-=-=-=-=-=-#
##############################################################################
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
##########################################################################
#=-=-=-=-=- Be careful if you change something below this line -=-=-=-=-=#
##########################################################################
# Makefile debug
#
@@ -241,346 +161,6 @@ H=@
V=@:
#V=@
####
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
####
# Where the system include (.h) files are kept
#
# For DJGPP, select:
#
# INCDIR= /dev/env/DJDIR/include
#
# If in doubt, set:
#
# INCDIR= /usr/include
#
#INCDIR= ${PREFIX}/include
#INCDIR= /dev/env/DJDIR/include
INCDIR= /usr/include
# where to install calc related things
#
# ${BINDIR} where to install calc binary files
# ${LIBDIR} where calc link library (*.a) files are installed
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
#
# NOTE: The install rule prepends installation paths with ${T}, which
# by default is empty. If ${T} is non-empty, then installation
# locations will be relative to the ${T} directory.
#
# For DJGPP, select:
#
# BINDIR= /dev/env/DJDIR/bin
# LIBDIR= /dev/env/DJDIR/lib
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
#
# If in doubt, set:
#
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
#
#BINDIR= ${PREFIX}/bin
#BINDIR= /dev/env/DJDIR/bin
BINDIR= /usr/bin
#LIBDIR= ${PREFIX}/lib
#LIBDIR= /dev/env/DJDIR/lib
LIBDIR= /usr/lib
#CALC_SHAREDIR= ${PREFIX}/lib/calc
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
CALC_SHAREDIR= /usr/share/calc
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
# ---------------------------------------------------------------
# ${HELPDIR} where the help directory is installed
# ${CALC_INCDIR} where the calc include files are installed
# ${CUSTOMCALDIR} where custom *.cal files are installed
# ${CUSTOMHELPDIR} where custom help files are installed
# ${CUSTOMINCDIR} where custom .h files are installed
# ${SCRIPTDIR} where calc shell scripts are installed
#
# NOTE: The install rule prepends installation paths with ${T}, which
# by default is empty. If ${T} is non-empty, then installation
# locations will be relative to the ${T} directory.
#
# If in doubt, set:
#
# HELPDIR= ${CALC_SHAREDIR}/help
# CALC_INCDIR= ${INCDIR}/calc
# CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
# CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
# CUSTOMINCDIR= ${CALC_INCDIR}/custom
# SCRIPTDIR= ${BINDIR}/cscript
#
HELPDIR= ${CALC_SHAREDIR}/help
CALC_INCDIR= ${INCDIR}/calc
CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
CUSTOMINCDIR= ${CALC_INCDIR}/custom
SCRIPTDIR= ${BINDIR}/cscript
# T - top level directory under which calc will be installed
#
# The calc install is performed under ${T}, the calc build is
# performed under /. The purpose for ${T} is to allow someone
# to install calc somewhere other than into the system area.
#
# For example, if:
#
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
#
# and if:
#
# T= /var/tmp/testing
#
# Then the installation locations will be:
#
# calc binary files: /var/tmp/testing/usr/bin
# calc link library: /var/tmp/testing/usr/lib
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
# ... etc ... /var/tmp/testing/...
#
# If ${T} is empty, calc is installed under /, which is the same
# top of tree for which it was built. If ${T} is non-empty, then
# calc is installed under ${T}, as if one had to chroot under
# ${T} for calc to operate.
#
# If in doubt, use T=
#
T=
# Debug/Optimize options for ${CC} and ${LCC}
#
# Select DEBUG= -O2 -gstabs+ -D_WIN32 for DJGPP.
#
#DEBUG=
#
#DEBUG= -O
#DEBUG= -O -g
#DEBUG= -O -g3
#
#DEBUG= -O1
#DEBUG= -O1 -g
#DEBUG= -O1 -g3
#
#DEBUG= -O2
#DEBUG= -O2 -g
#DEBUG= -O2 -g3
#DEBUG= -O2 -ipa
#DEBUG= -O2 -g3 -ipa
#
#DEBUG= -O3
#DEBUG= -O3 -g
DEBUG= -O3 -g3
#DEBUG= -O3 -ipa
#DEBUG= -O3 -g3 -ipa
#
#DEBUG= -g
#DEBUG= -g3
#DEBUG= -gx
#DEBUG= -WM,-g
#
#DEBUG= -O2 -gstabs+ -D_WIN32
# Some systems require one to use ranlib to add a symbol table to
# a *.a link library. Set RANLIB to the utility that performs this
# action. Set RANLIB to : if your system does not need such a utility.
#
RANLIB=ranlib
#RANLIB=:
# Normally certain files depend on the Makefile. If the Makefile is
# changed, then certain steps should be redone. If MAKE_FILE is
# set to Makefile, then these files will depend on Makefile. If
# MAKE_FILE is empty, then they wont.
#
# If in doubt, set MAKE_FILE to Makefile
#
MAKE_FILE= Makefile
#MAKE_FILE=
# If you do not wish to use purify, set PURIFY to an empty string.
#
# If in doubt, use PURIFY=
#
#PURIFY= purify
#PURIFY= purify -m71-engine
#PURIFY= purify -logfile=pure.out
#PURIFY= purify -m71-engine -logfile=pure.out
PURIFY=
# If you want to use a debugging link library such as a malloc debug link
# library, or need to add special ld flags after the calc link libraries
# are included, set ${LD_DEBUG} below.
#
# If in doubt, set LD_DEBUG to empty.
#
#LD_DEBUG= -lmalloc_cv
LD_DEBUG=
# When doing a:
#
# make check
# make chk
# make debug
#
# the ${CALC_ENV} is used to supply the proper environment variables
# to calc. Most people will simply need 'CALCPATH=./cal' to ensure
# that these debug rules will only use calc resource files under the
# local source directory. The longer lines (with MALLOC_VERBOSE=1 ...)
# are useful for SGI IRIX people who have 'WorkShop Performance Tools'
# and who also set 'LD_DEBUG= -lmalloc_cv' above.
#
# If in doubt, use CALC_ENV= CALCPATH=./cal.
#
CALC_ENV= CALCPATH=./cal
#CALC_ENV= CALCPATH=./cal MALLOC_VERBOSE=1 MALLOC_TRACING=1 \
# MALLOC_FASTCHK=1 MALLOC_FULLWARN=1
#CALC_ENV= CALCPATH=./cal MALLOC_VERBOSE=1 MALLOC_TRACING=1 \
# MALLOC_FASTCHK=1 MALLOC_FULLWARN=1 MALLOC_CLEAR_FREE=1 \
# MALLOC_CLEAR_MALLOC=1
# By default, custom builtin functions may only be executed if calc
# is given the -C option. This is because custom builtin functions
# may invoke non-standard or non-portable code. One may completely
# disable custom builtin functions by not compiling any of code
#
# ALLOW_CUSTOM= -DCUSTOM # allow custom only if -C is given
# ALLOW_CUSTOM= # disable custom even if -C is given
#
# If in doubt, use ALLOW_CUSTOM= -DCUSTOM
#
ALLOW_CUSTOM= -DCUSTOM
#ALLOW_CUSTOM=
# Some out of date operating systems require / want an executable to
# end with a certain file extension. Some compile systems such as
# Cygwin build calc as calc.exe. The EXT variable is used to denote
# the extension required by such.
#
# EXT= # normal Un*x / Linux / GNU/Linux systems
# EXT=.exe # Windows / Cygwin
#
# If in doubt, use EXT=
#
EXT=
#EXT=.exe
# The default calc versions
#
VERSION= 2.14.1.4
# Names of shared libraries with versions
#
LIB_EXT= .so
LIB_EXT_VERSION= ${LIB_EXT}.${VERSION}
# standard tools
#
AR= ar
AWK= awk
CHMOD= chmod
CMP= cmp
CO= co
CP= cp
DIFF= diff
FMT= fmt
GREP= grep
LN= ln
LS= ls
MAKE= make
MAKEDEPEND= makedepend
MKDIR= mkdir
MV= mv
RM= rm
RMDIR= rmdir
SED= sed
SORT= sort
TAIL= tail
TOUCH= touch
TRUE= true
# EXTRA_CFLAGS are flags given to ${CC} when compiling C files
# EXTRA_LDFLAGS are flags given to ${CC} when linking progs
#
# Both CFLAGS and LDFLAGS are left blank in this Makefile by
# default so that users may use them on the make command line
# to always the way that C is compiled and files are linked
# respectively. For example:
#
# make all EXTRA_CFLAGS="-DMAGIC" EXTRA_LDFLAGS="-lmagic"
#
# NOTE: These should be left blank in this Makefile to make it
# easier to add stuff on the command line. If you want to
# to change the way calc is compiled by this Makefile, change
# the appropriate host target section below or a flag above.
#
EXTRA_CFLAGS=
EXTRA_LDFLAGS=
# COMMON_CFLAGS are the common ${CC} flags used for all progs, both
# intermediate and final calc and calc related progs
#
COMMON_CFLAGS= -DCALC_SRC ${ALLOW_CUSTOM} ${CCWARN} ${CCMISC} ${EXTRA_CFLAGS}
# COMMON_LDFLAGS are the common flags used for linking all progs, both
# intermediate and final calc and calc related progs
#
COMMON_LDFLAGS= ${EXTRA_LDFLAGS}
###########################################
# Set the default compile flags for ${CC} #
###########################################
#if 0 /* start of skip for non-Gnu makefiles */
# Required flags to compile C files for calc
#
# ICFLAGS are given to ${CC} for intermediate progs used to help compile calc
# CFLAGS are given to ${CC} for calc progs other than intermediate progs
#
# NOTE: This does not work for: make-XYZ-only and BLD_TYPE != make-XYZ-only
#
ifeq ($(BLD_TYPE),calc-static-only)
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC}
else
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_SHARE}
endif
CFLAGS= ${ICFLAGS} ${CCOPT}
# Required flags to link files for calc
#
# ILDFLAGS for ${CC} in linking intermediate progs used to help compile calc
# LDFLAGS for ${CC} in linking calc progs other than intermediate progs
#
ILDFLAGS= ${COMMON_LDFLAGS}
LDFLAGS= ${LD_DEBUG} ${ILDFLAGS}
#endif /* end of skip for non-Gnu makefiles */
##########################################################################
#=-=-=-=-=- Be careful if you change something below this line -=-=-=-=-=#
##########################################################################
# include start from top Makefile - keep this line
#if 0 /* start of skip for non-Gnu makefiles */
###
#
# Allow Makefile.local to override any of the above settings
#
###
EXCLUDE_FROM_CUSTOM_MAKEFILE=true # include only middle of ../Makefile
include ../Makefile
#endif /* end of skip for non-Gnu makefiles */
# include end from top Makefile - keep this line
# These .c files are required for the main custom interface and
# for the custom support functions for libcustcalc${LIB_EXT_VERSION}.
#
@@ -621,7 +201,7 @@ H_SRC= ${CUSTOM_H_SRC}
# directory but are installed as help files from the help/Makefile.
#
DISTLIST= ${CUSTCALC_SRC} ${CUSTOM_CALC_FILES} ${CUSTOM_HELP} \
${INSTALL_H_SRC} CUSTOM_CAL HOW_TO_ADD Makefile Makefile.simple
${INSTALL_H_SRC} CUSTOM_CAL HOW_TO_ADD Makefile
# These files are used to make (but not built) a calc .a link library
#
@@ -637,17 +217,27 @@ CALC_STATIC_LIBCUSTCALC= libcustcalc.a
# complete list of targets
#
TARGETS= ${BLD_TYPE} Makefile.simple
TARGETS= ${BLD_TYPE}
###
#
# The main reason for this Makefile :-)
#
###
############################################################
# Allow Makefile.local to change any of the above settings #
############################################################
include ${LOCAL_MKF}
###########################################
# all - First and default Makefile target #
###########################################
all: ${TARGETS} ${INSTALL_H_SRC} ${CUSTOM_CALC_FILES} \
${CUSTOM_HELP} ${MAKE_FILE} .all
###############################
# additional Makefile targets #
###############################
calc-dynamic-only: ${CUSTCALC_OBJ} ${CALC_DYNAMIC_LIBCUSTCALC}
calc-static-only: ${CUSTCALC_OBJ} ${CALC_STATIC_LIBCUSTCALC}
@@ -667,12 +257,6 @@ libcustcalc${LIB_EXT_VERSION}: ${CUSTCALC_OBJ} ${MAKE_FILE}
c_sysinfo.o: c_sysinfo.c ${MAKE_FILE}
${CC} ${CFLAGS} c_sysinfo.c -c
##
#
# used by the upper level Makefile
#
##
# to determine of we have done all
#
.all:
@@ -721,72 +305,8 @@ calcliblist: ${CALCLIBLIST}
fi; \
done
#if 0 /* start of skip for non-Gnu makefiles */
Makefile.simple: Makefile ../Makefile
${V} echo '=-=-=-=-= custom/${MAKE_FILE} start of $@ rule =-=-=-=-='
${Q} if [ -f $@.bak ]; then \
echo "custom/$@.bak exists, remove or move it"; \
exit 1; \
else \
${TRUE}; \
fi
-${Q} if [ -f $@ ]; then \
${MV} -f $@ $@.bak; \
fi
${Q} ${AWK} '/^#if 0/{skp=1} {if(!skp){print $$0}} /^#endif/{skp=0}' \
Makefile | \
${SED} -e '/^# include start from top Makefile - keep /,$$d' \
-e 's;^# SRC:.*;# SRC: custom/$@ - non-GNU version;' \
-e '/^ifeq /d' \
-e '/^ifneq /d' \
-e '/^ifdef /d' \
-e '/^ifndef /d' \
-e '/^else/d' \
-e '/^endif/d' \
> $@
${Q} echo '# include start from top Makefile - keep this line' \
>> $@
${Q} ${AWK} '/^#if 0/{skp=1} {if(!skp){print $$0}} /^#endif/{skp=0}' \
../Makefile | \
${SED} -e '1,/^# include start from top Makefile - keep /d' \
-e '/^# include end from top Makefile - keep /,$$d' \
-e '/^ifeq /d' \
-e '/^ifneq /d' \
-e '/^ifdef /d' \
-e '/^ifndef /d' \
-e '/^else/d' \
-e '/^endif/d' \
>> $@
${Q} echo '# include end from top Makefile - keep this line' \
>> $@
${Q} ${AWK} '/^#if 0/{skp=1} {if(!skp){print $$0}} /^#endif/{skp=0}' \
Makefile | \
${SED} -e '1,/^# include end from top Makefile - keep /d' \
-e '/^ifeq /d' \
-e '/^ifneq /d' \
-e '/^ifdef /d' \
-e '/^ifndef /d' \
-e '/^else/d' \
-e '/^endif/d' \
>> $@
-${Q} if [ -s $@.bak ]; then \
if ${CMP} -s $@.bak $@; then \
echo 'custom/$@ was already up to date'; \
echo 'restoring original custom/$@'; \
${MV} -f $@.bak $@; \
else \
echo 'old custom/$@ is now custom/$@.bak'; \
echo 'updated custom/$@ formed'; \
(cd .. ; ${DIFF} -u custom/$@.bak custom/$@); \
fi; \
else \
echo 'new custom/$@ formed'; \
echo; \
(cd .. ; ${LS} -l custom/$@); \
echo; \
fi
${V} echo '=-=-=-=-= custom/${MAKE_FILE} end of $@ rule =-=-=-=-='
#endif /* end of skip for non-Gnu makefiles */
Makefile.simple:
${Q} echo Support for custom/$@ was dropped after the the release of calc v2.14.3.0.
##
#
@@ -1079,7 +599,7 @@ install: all
${RM} -f ${T}${CUSTOMCALDIR}/libcustcalc.a; \
echo "removed old ${T}${CUSTOMCALDIR}/libcustcalc.a"; \
fi
-${Q} if [ ! -z ${ALLOW_CUSTOM} ]; then \
-${Q} if [ X"${ALLOW_CUSTOM}" = "X-DCUSTOM" ]; then \
if [ -f libcustcalc.a ]; then \
if ${CMP} -s libcustcalc.a ${T}${LIBDIR}/libcustcalc.a; then \
${TRUE}; \
@@ -1171,19 +691,24 @@ c_argv.o: ../alloc.h
c_argv.o: ../attribute.h
c_argv.o: ../banned.h
c_argv.o: ../block.h
c_argv.o: ../bool.h
c_argv.o: ../byteswap.h
c_argv.o: ../calc.h
c_argv.o: ../calcerr.h
c_argv.o: ../charbit.h
c_argv.o: ../cmath.h
c_argv.o: ../config.h
c_argv.o: ../custom.h
c_argv.o: ../decl.h
c_argv.o: ../endian_calc.h
c_argv.o: ../errsym.h
c_argv.o: ../errtbl.h
c_argv.o: ../hash.h
c_argv.o: ../have_ban_pragma.h
c_argv.o: ../have_const.h
c_argv.o: ../have_limits.h
c_argv.o: ../have_memmv.h
c_argv.o: ../have_newstr.h
c_argv.o: ../have_stdbool.h
c_argv.o: ../have_stdlib.h
c_argv.o: ../have_string.h
c_argv.o: ../have_unused.h
@@ -1193,24 +718,30 @@ c_argv.o: ../qmath.h
c_argv.o: ../sha1.h
c_argv.o: ../str.h
c_argv.o: ../value.h
c_argv.o: ../version.h
c_argv.o: ../zmath.h
c_argv.o: c_argv.c
c_devnull.o: ../alloc.h
c_devnull.o: ../attribute.h
c_devnull.o: ../banned.h
c_devnull.o: ../block.h
c_devnull.o: ../bool.h
c_devnull.o: ../byteswap.h
c_devnull.o: ../calcerr.h
c_devnull.o: ../charbit.h
c_devnull.o: ../cmath.h
c_devnull.o: ../config.h
c_devnull.o: ../custom.h
c_devnull.o: ../decl.h
c_devnull.o: ../endian_calc.h
c_devnull.o: ../errsym.h
c_devnull.o: ../errtbl.h
c_devnull.o: ../hash.h
c_devnull.o: ../have_ban_pragma.h
c_devnull.o: ../have_const.h
c_devnull.o: ../have_limits.h
c_devnull.o: ../have_memmv.h
c_devnull.o: ../have_newstr.h
c_devnull.o: ../have_stdbool.h
c_devnull.o: ../have_stdlib.h
c_devnull.o: ../have_string.h
c_devnull.o: ../have_unistd.h
@@ -1221,24 +752,30 @@ c_devnull.o: ../qmath.h
c_devnull.o: ../sha1.h
c_devnull.o: ../str.h
c_devnull.o: ../value.h
c_devnull.o: ../version.h
c_devnull.o: ../zmath.h
c_devnull.o: c_devnull.c
c_help.o: ../alloc.h
c_help.o: ../attribute.h
c_help.o: ../banned.h
c_help.o: ../block.h
c_help.o: ../bool.h
c_help.o: ../byteswap.h
c_help.o: ../calcerr.h
c_help.o: ../charbit.h
c_help.o: ../cmath.h
c_help.o: ../config.h
c_help.o: ../custom.h
c_help.o: ../decl.h
c_help.o: ../endian_calc.h
c_help.o: ../errsym.h
c_help.o: ../errtbl.h
c_help.o: ../hash.h
c_help.o: ../have_ban_pragma.h
c_help.o: ../have_const.h
c_help.o: ../have_limits.h
c_help.o: ../have_memmv.h
c_help.o: ../have_newstr.h
c_help.o: ../have_stdbool.h
c_help.o: ../have_stdlib.h
c_help.o: ../have_string.h
c_help.o: ../have_unistd.h
@@ -1249,24 +786,30 @@ c_help.o: ../qmath.h
c_help.o: ../sha1.h
c_help.o: ../str.h
c_help.o: ../value.h
c_help.o: ../version.h
c_help.o: ../zmath.h
c_help.o: c_help.c
c_pmodm127.o: ../alloc.h
c_pmodm127.o: ../attribute.h
c_pmodm127.o: ../banned.h
c_pmodm127.o: ../block.h
c_pmodm127.o: ../bool.h
c_pmodm127.o: ../byteswap.h
c_pmodm127.o: ../calcerr.h
c_pmodm127.o: ../charbit.h
c_pmodm127.o: ../cmath.h
c_pmodm127.o: ../config.h
c_pmodm127.o: ../custom.h
c_pmodm127.o: ../decl.h
c_pmodm127.o: ../endian_calc.h
c_pmodm127.o: ../errsym.h
c_pmodm127.o: ../errtbl.h
c_pmodm127.o: ../hash.h
c_pmodm127.o: ../have_ban_pragma.h
c_pmodm127.o: ../have_const.h
c_pmodm127.o: ../have_limits.h
c_pmodm127.o: ../have_memmv.h
c_pmodm127.o: ../have_newstr.h
c_pmodm127.o: ../have_stdbool.h
c_pmodm127.o: ../have_stdlib.h
c_pmodm127.o: ../have_string.h
c_pmodm127.o: ../have_unused.h
@@ -1276,24 +819,30 @@ c_pmodm127.o: ../qmath.h
c_pmodm127.o: ../sha1.h
c_pmodm127.o: ../str.h
c_pmodm127.o: ../value.h
c_pmodm127.o: ../version.h
c_pmodm127.o: ../zmath.h
c_pmodm127.o: c_pmodm127.c
c_pzasusb8.o: ../alloc.h
c_pzasusb8.o: ../attribute.h
c_pzasusb8.o: ../banned.h
c_pzasusb8.o: ../block.h
c_pzasusb8.o: ../bool.h
c_pzasusb8.o: ../byteswap.h
c_pzasusb8.o: ../calcerr.h
c_pzasusb8.o: ../charbit.h
c_pzasusb8.o: ../cmath.h
c_pzasusb8.o: ../config.h
c_pzasusb8.o: ../custom.h
c_pzasusb8.o: ../decl.h
c_pzasusb8.o: ../endian_calc.h
c_pzasusb8.o: ../errsym.h
c_pzasusb8.o: ../errtbl.h
c_pzasusb8.o: ../hash.h
c_pzasusb8.o: ../have_ban_pragma.h
c_pzasusb8.o: ../have_const.h
c_pzasusb8.o: ../have_limits.h
c_pzasusb8.o: ../have_memmv.h
c_pzasusb8.o: ../have_newstr.h
c_pzasusb8.o: ../have_stdbool.h
c_pzasusb8.o: ../have_stdlib.h
c_pzasusb8.o: ../have_string.h
c_pzasusb8.o: ../have_unused.h
@@ -1303,25 +852,31 @@ c_pzasusb8.o: ../qmath.h
c_pzasusb8.o: ../sha1.h
c_pzasusb8.o: ../str.h
c_pzasusb8.o: ../value.h
c_pzasusb8.o: ../version.h
c_pzasusb8.o: ../zmath.h
c_pzasusb8.o: c_pzasusb8.c
c_register.o: ../alloc.h
c_register.o: ../attribute.h
c_register.o: ../banned.h
c_register.o: ../block.h
c_register.o: ../bool.h
c_register.o: ../byteswap.h
c_register.o: ../calc.h
c_register.o: ../calcerr.h
c_register.o: ../charbit.h
c_register.o: ../cmath.h
c_register.o: ../config.h
c_register.o: ../custom.h
c_register.o: ../decl.h
c_register.o: ../endian_calc.h
c_register.o: ../errsym.h
c_register.o: ../errtbl.h
c_register.o: ../hash.h
c_register.o: ../have_ban_pragma.h
c_register.o: ../have_const.h
c_register.o: ../have_limits.h
c_register.o: ../have_memmv.h
c_register.o: ../have_newstr.h
c_register.o: ../have_stdbool.h
c_register.o: ../have_stdlib.h
c_register.o: ../have_string.h
c_register.o: ../have_unused.h
@@ -1331,27 +886,33 @@ c_register.o: ../qmath.h
c_register.o: ../sha1.h
c_register.o: ../str.h
c_register.o: ../value.h
c_register.o: ../version.h
c_register.o: ../zmath.h
c_register.o: c_register.c
c_sysinfo.o: ../alloc.h
c_sysinfo.o: ../attribute.h
c_sysinfo.o: ../banned.h
c_sysinfo.o: ../block.h
c_sysinfo.o: ../bool.h
c_sysinfo.o: ../byteswap.h
c_sysinfo.o: ../calc.h
c_sysinfo.o: ../calcerr.h
c_sysinfo.o: ../charbit.h
c_sysinfo.o: ../cmath.h
c_sysinfo.o: ../conf.h
c_sysinfo.o: ../config.h
c_sysinfo.o: ../custom.h
c_sysinfo.o: ../decl.h
c_sysinfo.o: ../endian_calc.h
c_sysinfo.o: ../errsym.h
c_sysinfo.o: ../errtbl.h
c_sysinfo.o: ../fposval.h
c_sysinfo.o: ../hash.h
c_sysinfo.o: ../have_ban_pragma.h
c_sysinfo.o: ../have_const.h
c_sysinfo.o: ../have_limits.h
c_sysinfo.o: ../have_memmv.h
c_sysinfo.o: ../have_newstr.h
c_sysinfo.o: ../have_stdbool.h
c_sysinfo.o: ../have_stdlib.h
c_sysinfo.o: ../have_string.h
c_sysinfo.o: ../have_unused.h
@@ -1364,6 +925,7 @@ c_sysinfo.o: ../qmath.h
c_sysinfo.o: ../sha1.h
c_sysinfo.o: ../str.h
c_sysinfo.o: ../value.h
c_sysinfo.o: ../version.h
c_sysinfo.o: ../zmath.h
c_sysinfo.o: ../zrand.h
c_sysinfo.o: ../zrandom.h
@@ -1372,18 +934,23 @@ custtbl.o: ../alloc.h
custtbl.o: ../attribute.h
custtbl.o: ../banned.h
custtbl.o: ../block.h
custtbl.o: ../bool.h
custtbl.o: ../byteswap.h
custtbl.o: ../calcerr.h
custtbl.o: ../charbit.h
custtbl.o: ../cmath.h
custtbl.o: ../config.h
custtbl.o: ../custom.h
custtbl.o: ../decl.h
custtbl.o: ../endian_calc.h
custtbl.o: ../errsym.h
custtbl.o: ../errtbl.h
custtbl.o: ../hash.h
custtbl.o: ../have_ban_pragma.h
custtbl.o: ../have_const.h
custtbl.o: ../have_limits.h
custtbl.o: ../have_memmv.h
custtbl.o: ../have_newstr.h
custtbl.o: ../have_stdbool.h
custtbl.o: ../have_stdlib.h
custtbl.o: ../have_string.h
custtbl.o: ../longbits.h
@@ -1392,5 +959,6 @@ custtbl.o: ../qmath.h
custtbl.o: ../sha1.h
custtbl.o: ../str.h
custtbl.o: ../value.h
custtbl.o: ../version.h
custtbl.o: ../zmath.h
custtbl.o: custtbl.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/*
* c_argv - a custom function display info about its args
*
* Copyright (C) 1999-2006,2021 Landon Curt Noll
* Copyright (C) 1999-2006,2021,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
@@ -25,21 +25,32 @@
*/
/*
* ISO C requires a translation unit to contain at least one declaration,
* so we declare a global variable whose value is based on if CUSTOM is defined.
*/
#if defined(CUSTOM)
int c_argv_allowed = 1; /* CUSTOM defined */
#else /* CUSTOM */
int c_argv_allowed = 0; /* CUSTOM undefined */
#endif /* CUSTOM */
#if defined(CUSTOM)
#include <stdio.h>
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "config.h"
#include "calc.h"
#include "../config.h"
#include "../calc.h"
#include "have_unused.h"
#include "../have_unused.h"
#include "banned.h" /* include after system header <> includes */
#include "../banned.h" /* include after system header <> includes */
/*

View File

@@ -1,7 +1,7 @@
/*
* c_devnull - a custom function that does nothing
*
* Copyright (C) 1999-2004,2021 Landon Curt Noll
* Copyright (C) 1999-2004,2021,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
@@ -25,21 +25,32 @@
*/
/*
* ISO C requires a translation unit to contain at least one declaration,
* so we declare a global variable whose value is based on if CUSTOM is defined.
*/
#if defined(CUSTOM)
int c_devnull_allowed = 1; /* CUSTOM defined */
#else /* CUSTOM */
int c_devnull_allowed = 0; /* CUSTOM undefined */
#endif /* CUSTOM */
#if defined(CUSTOM)
#include "have_unistd.h"
#include "../have_unistd.h"
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "have_unused.h"
#include "../have_unused.h"
#include "banned.h" /* include after system header <> includes */
#include "../banned.h" /* include after system header <> includes */
/*

View File

@@ -1,7 +1,7 @@
/*
* c_help - custom help function
*
* Copyright (C) 1999-2004,2021,2022 Landon Curt Noll
* Copyright (C) 1999-2004,2021-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
@@ -25,22 +25,33 @@
*/
/*
* ISO C requires a translation unit to contain at least one declaration,
* so we declare a global variable whose value is based on if CUSTOM is defined.
*/
#if defined(CUSTOM)
int c_help_allowed = 1; /* CUSTOM defined */
#else /* CUSTOM */
int c_help_allowed = 0; /* CUSTOM undefined */
#endif /* CUSTOM */
#if defined(CUSTOM)
#include "have_unistd.h"
#include "../have_unistd.h"
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "have_unused.h"
#include "../have_unused.h"
#include "attribute.h"
#include "banned.h" /* include after system header <> includes */
#include "../errtbl.h"
#include "../banned.h" /* include after system header <> includes */
/*

View File

@@ -1,7 +1,7 @@
/*
* c_pmodm127 - calculate q mod 2^(2^127-1)
*
* Copyright (C) 2004-2007,2021,2022 Landon Curt Noll
* Copyright (C) 2004-2007,2021-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
@@ -24,20 +24,31 @@
*/
/*
* ISO C requires a translation unit to contain at least one declaration,
* so we declare a global variable whose value is based on if CUSTOM is defined.
*/
#if defined(CUSTOM)
int c_pmodm127_allowed = 1; /* CUSTOM defined */
#else /* CUSTOM */
int c_pmodm127_allowed = 0; /* CUSTOM undefined */
#endif /* CUSTOM */
#if defined(CUSTOM)
#include <stdio.h>
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "zmath.h"
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "../zmath.h"
#include "have_unused.h"
#include "../have_unused.h"
#include "attribute.h"
#include "banned.h" /* include after system header <> includes */
#include "../errtbl.h"
#include "../banned.h" /* include after system header <> includes */
/* 2^255 */
@@ -59,7 +70,7 @@ ZVALUE p255 = {
/* static declarations */
S_FUNC void zmod5_or_zmod(ZVALUE *zp);
STATIC BOOL havelastmod = FALSE;
STATIC bool havelastmod = false;
STATIC ZVALUE lastmod[1];
STATIC ZVALUE lastmodinv[1];
@@ -111,14 +122,14 @@ c_pmodm127(char *UNUSED(name), int UNUSED(count), VALUE **vals)
if (havelastmod && zcmp(q, *lastmod)) {
zfree(*lastmod);
zfree(*lastmodinv);
havelastmod = FALSE;
havelastmod = false;
}
if (!havelastmod) {
zcopy(q, lastmod);
zbitvalue(2 * q.len * BASEB, &temp);
zquo(temp, q, lastmodinv, 0);
zfree(temp);
havelastmod = TRUE;
havelastmod = true;
}
/*

View File

@@ -1,7 +1,7 @@
/*
* c_pzasusb8 - print numerator as a string of USB8s
*
* Copyright (C) 1999-2004,2021,2022 Ernest Bowen
* Copyright (C) 1999-2004,2021-2023 Ernest Bowen
*
* 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
@@ -24,20 +24,31 @@
*/
/*
* ISO C requires a translation unit to contain at least one declaration,
* so we declare a global variable whose value is based on if CUSTOM is defined.
*/
#if defined(CUSTOM)
int c_pzasusb8_allowed = 1; /* CUSTOM defined */
#else /* CUSTOM */
int c_pzasusb8_allowed = 0; /* CUSTOM undefined */
#endif /* CUSTOM */
#if defined(CUSTOM)
#include <stdio.h>
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "zmath.h"
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "../zmath.h"
#include "have_unused.h"
#include "../have_unused.h"
#include "attribute.h"
#include "banned.h" /* include after system header <> includes */
#include "../errtbl.h"
#include "../banned.h" /* include after system header <> includes */
/*

View File

@@ -1,7 +1,7 @@
/*
* c_register - set or print a custom register value
*
* Copyright (C) 2007,2021,2022 Landon Curt Noll
* Copyright (C) 2007,2021-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
@@ -25,22 +25,33 @@
*/
/*
* ISO C requires a translation unit to contain at least one declaration,
* so we declare a global variable whose value is based on if CUSTOM is defined.
*/
#if defined(CUSTOM)
int c_register_allowed = 1; /* CUSTOM defined */
#else /* CUSTOM */
int c_register_allowed = 0; /* CUSTOM undefined */
#endif /* CUSTOM */
#if defined(CUSTOM)
#include <stdio.h>
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "config.h"
#include "calc.h"
#include "../config.h"
#include "../calc.h"
#include "have_unused.h"
#include "../have_unused.h"
#include "attribute.h"
#include "banned.h" /* include after system header <> includes */
#include "../errtbl.h"
#include "../banned.h" /* include after system header <> includes */
/*

View File

@@ -1,7 +1,7 @@
/*
* c_sysinfo - names and values of selected #defines
*
* Copyright (C) 1999-2007,2021,2022 Landon Curt Noll
* Copyright (C) 1999-2007,2021-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
@@ -25,40 +25,50 @@
*/
/*
* ISO C requires a translation unit to contain at least one declaration,
* so we declare a global variable whose value is based on if CUSTOM is defined.
*/
#if defined(CUSTOM)
int c_sysinfo_allowed = 1; /* CUSTOM defined */
#else /* CUSTOM */
int c_sysinfo_allowed = 0; /* CUSTOM undefined */
#endif /* CUSTOM */
#if defined(CUSTOM)
#include <stdio.h>
#include <ctype.h>
#include "have_string.h"
#include "../have_string.h"
#if defined(HAVE_STRING_H)
#include <string.h>
#endif
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "config.h"
#include "lib_calc.h"
#include "calc.h"
#include "longbits.h"
#include "../config.h"
#include "../lib_calc.h"
#include "../calc.h"
#include "../longbits.h"
#define CHECK_L_FORMAT
#include "block.h"
#include "calcerr.h"
#include "conf.h"
#include "endian_calc.h"
#include "fposval.h"
#include "hist.h"
#include "prime.h"
#include "zrand.h"
#include "zrandom.h"
#include "../block.h"
#include "../conf.h"
#include "../endian_calc.h"
#include "../fposval.h"
#include "../hist.h"
#include "../prime.h"
#include "../zrand.h"
#include "../zrandom.h"
#include "have_unused.h"
#include "../have_unused.h"
#include "attribute.h"
#include "banned.h" /* include after system header <> includes */
#include "../errtbl.h"
#include "../banned.h" /* include after system header <> includes */
/*
@@ -117,16 +127,8 @@ STATIC struct infoname sys_info[] = {
EPSILON_DEFAULT, (FULL)0},
{"ERRMAX", "default errmax value", NULL,
(FULL)ERRMAX},
{"E_USERDEF", "base of user defined errors", NULL,
(FULL)E_USERDEF},
{"E__BASE", "calc errors start above here", NULL,
(FULL)E__BASE},
{"E__COUNT", "number of calc errors", NULL,
(FULL)E__COUNT},
{"E__HIGHEST", "highest calc error", NULL,
(FULL)E__HIGHEST},
{"FALSE", "boolean false", NULL,
(FULL)FALSE},
{"false", "boolean false", NULL,
(FULL)false},
{"FILEPOS_BITS", "file position size in bits", NULL,
(FULL)FILEPOS_BITS},
{"FULL_BITS", "bits in a FULL", NULL,
@@ -137,9 +139,9 @@ STATIC struct infoname sys_info[] = {
(FULL)0},
{"HIST_SIZE", "Default history size", NULL,
(FULL)HIST_SIZE},
{"INIT_J", "initial 1st walking a55 table index", NULL,
{"INIT_J", "initial 1st walking subtractive 100 shuffle table index", NULL,
(FULL)INIT_J},
{"INIT_K", "initial 2nd walking a55 table index", NULL,
{"INIT_K", "initial 2nd walking subtractive 100 shuffle table index", NULL,
(FULL)INIT_K},
{"INODE_BITS", "inode number size in bits", NULL,
(FULL)INODE_BITS},
@@ -211,7 +213,7 @@ STATIC struct infoname sys_info[] = {
(FULL)SBYTES},
{"SCNT", "length of subtractive 100 table in FULLs", NULL,
(FULL)SCNT},
{"SEEDXORBITS", "low bits of a55 seed devoted to xor", NULL,
{"SEEDXORBITS", "low bits of subtractive 100 shuffle pseudo-random number generator seed devoted to xor", NULL,
(FULL)SEEDXORBITS},
{"SHALFS", "size of additive or shuffle entry in HALFs", NULL,
(FULL)SHALFS},
@@ -237,8 +239,8 @@ STATIC struct infoname sys_info[] = {
(FULL)TOPHALF},
{"TOPLONG", "top long bit", NULL,
(FULL)TOPLONG},
{"TRUE", "boolean true", NULL,
(FULL)TRUE},
{"true", "boolean true", NULL,
(FULL)true},
{"USUAL_ELEMENTS", "usual number of elements for objects", NULL,
(FULL)USUAL_ELEMENTS},
{"REGNUM_MAX", "highest custom register number", NULL,

View File

@@ -1,7 +1,7 @@
/*
* custtbl - custom interface table
*
* Copyright (C) 1999-2007,2021 Landon Curt Noll
* Copyright (C) 1999-2007,2021,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
@@ -24,19 +24,38 @@
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
#include <unistd.h>
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "banned.h" /* include after system header <> includes */
#include "../errtbl.h"
#include "../banned.h" /* include after system header <> includes */
/*
* NOTE: See the file CUSTOM for instructions on how to add
* custom functions.
* custom_compiled - determine if custom functions are compiled into libcustcalc
*
* returns:
s* true ==> libcustcalc was compiled with CUSTOM defined
* false ==> libcustcalc was compiled with CUSTOM undefined
*/
E_FUNC bool
custom_compiled(void)
{
#if defined(CUSTOM)
return true;
#else /* CUSTOM */
return false;
#endif /* CUSTOM */
}
/*
* NOTE: See the file HOW_TO_ADD for instructions on how to add custom functions.
*/

2245
errtbl.c Normal file

File diff suppressed because it is too large Load Diff

113
errtbl.h Normal file
View File

@@ -0,0 +1,113 @@
/*
* errtbl - calc error code table entry
*
* Copyright (C) 2023 Ernest Bowen and 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
* 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.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Under source code control: 2023/09/12 20:55:14
* File existed as early as: 2023
*
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
#if !defined(INCLUDE_ERRTBL_H)
#define INCLUDE_ERRTBL_H
#include "attribute.h"
#include "have_const.h"
#include "bool.h"
#include "decl.h"
/*
* NOTE: See also errsym.h, the file that this code, via errcode -d, via the Makefile, creates
*
* We cannot use errsym.h when compiling for errcode (ERRCODE_SRC defined)
*/
#if !defined(ERRCODE_SRC)
#include "errsym.h"
#endif /* !ERRCODE_SRC */
/*
* primary error code defines
*/
#define E__NONE 0 /* calc_errno cleared: libc errno codes above here */
#define E__BASE 10000 /* calc computation error codes start above here */
#define E__USERDEF 20000 /* user defined error codes start here */
#define E__USERMAX 32767 /* maximum user defined error code */
#define USERMAX_DIGITS 5 /* number of decimal digits in E__USERMAX */
/*
* invalid errnum
*/
#define NULL_ERRNUM (-1) /* errnum for the final table terminating NULL entry */
/*
* The error routine.
*/
E_FUNC void math_error(char *, ...) \
__attribute__((format(printf, 1, 2))) __attribute__((noreturn));
/*
* calc error code, error symbol and error message
*/
struct errtbl {
int errnum; /* calc computation error codes or -1 */
char *errsym; /* E_STRING - must match regexp: ^E_[A-Z0-9_]+$ or NULL */
char *errmsg; /* calc error message or NULL */
};
/*
* The error_table[] array represents the calc computation error related
* error codes, symbols and messages.
*
* The errnum of the 1st entry error_table[0] must be E__BASE.
*
* All errnum for the following entries just be consecutive,
* except for the final NULL entry.
*
* The final entry must have an errnum of -1, errsym of NULL and errmsg of NULL.
*/
EXTERN CONST struct errtbl error_table[]; /* calc error codes, error symbols and error messages */
/*
* external functions
*/
E_FUNC bool is_e_digits(CONST char *errsym);
E_FUNC bool is_valid_errnum(int errnum);
E_FUNC bool is_errnum_in_error_table(int errnum);
E_FUNC int e_digits_2_errnum(CONST char *errsym);
E_FUNC bool is_e_1string(CONST char *errsym);
E_FUNC bool is_e_2string(CONST char *errsym);
E_FUNC struct errtbl *find_errsym_in_errtbl(CONST char *errsym, CONST struct errtbl *tbl);
E_FUNC struct errtbl *find_errnum_in_errtbl(int errnum, CONST struct errtbl *tbl);
E_FUNC CONST struct errtbl *lookup_errnum_in_error_table(int errnum);
E_FUNC void verify_error_table(void);
E_FUNC int errsym_2_errnum(CONST char *errsym);
E_FUNC char *errnum_2_errsym(int errnum, bool *palloced);
E_FUNC char *errnum_2_errmsg(int errnum, bool *palloced);
E_FUNC char *errsym_2_errmsg(CONST char *errsym, bool *palloced);
#endif /* !INCLUDE_ERRTBL_H */

137
file.c
View File

@@ -1,7 +1,7 @@
/*
* file - file I/O routines callable by users
*
* Copyright (C) 1999-2007,2018,2021,2022 David I. Bell and Landon Curt Noll
* Copyright (C) 1999-2007,2018,2021-2023 David I. Bell and Landon Curt Noll
*
* Primary author: David I. Bell
*
@@ -43,7 +43,6 @@
#include "have_fpos_pos.h"
#include "fposval.h"
#include "file.h"
#include "calcerr.h"
#include "strl.h"
#if defined(_WIN32) || defined(_WIN64)
@@ -51,7 +50,7 @@
#endif
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -73,11 +72,11 @@ E_FUNC FILE *f_open(char *name, char *mode);
*/
STATIC FILEIO files[MAXFILES] = {
{FILEID_STDIN, NULL, (dev_t)0, (ino_t)0,
"(stdin)", TRUE, FALSE, FALSE, FALSE, 'r', "r"},
"(stdin)", true, false, false, false, 'r', "r"},
{FILEID_STDOUT, NULL, (dev_t)0, (ino_t)0,
"(stdout)", FALSE, TRUE, FALSE, FALSE, 'w', "w"},
"(stdout)", false, true, false, false, 'w', "w"},
{FILEID_STDERR, NULL, (dev_t)0, (ino_t)0,
"(stderr)", FALSE, TRUE, FALSE, FALSE, 'w', "w"}
"(stderr)", false, true, false, false, 'w', "w"}
};
@@ -94,9 +93,9 @@ S_FUNC int get_open_pos(FILE *fp, ZVALUE *res);
S_FUNC ZVALUE off_t2z(off_t siz);
S_FUNC ZVALUE dev2z(dev_t dev);
S_FUNC ZVALUE inode2z(ino_t inode);
S_FUNC void getscanfield(FILE *fp, BOOL skip, unsigned int width,
S_FUNC void getscanfield(FILE *fp, bool skip, unsigned int width,
int scannum, char *scanptr, char **strptr);
S_FUNC void getscanwhite(FILE *fp, BOOL skip, unsigned int width,
S_FUNC void getscanwhite(FILE *fp, bool skip, unsigned int width,
int scannum, char **strptr);
S_FUNC int fscanfile(FILE *fp, char *fmt, int count, VALUE **vals);
S_FUNC void freadnum(FILE *fp, VALUE *valptr);
@@ -145,8 +144,8 @@ file_init(void)
char *tname;
fiop->name = NULL;
files[idnum].reading = TRUE;
files[idnum].writing = TRUE;
files[idnum].reading = true;
files[idnum].writing = true;
files[idnum].action = 0;
memset(files[idnum].mode, 0, MODE_LEN+1);
/*
@@ -163,13 +162,13 @@ file_init(void)
if (fp) {
strlcpy(files[idnum].mode, "r",
sizeof(files[idnum].mode));
files[idnum].writing = FALSE;
files[idnum].writing = false;
} else {
fp = (FILE *) fdopen(i, "w");
if (fp) {
strlcpy(files[idnum].mode, "w",
sizeof(files[idnum].mode));
files[idnum].reading = FALSE;
files[idnum].reading = false;
}
else
continue;
@@ -244,10 +243,10 @@ init_fileio(FILEIO *fiop, char *name, char *mode,
fiop->fp = fp;
fiop->dev = sbufp->st_dev;
fiop->inode = sbufp->st_ino;
fiop->reading = FALSE;
fiop->writing = FALSE;
fiop->appending = FALSE;
fiop->binary = FALSE;
fiop->reading = false;
fiop->writing = false;
fiop->appending = false;
fiop->binary = false;
fiop->action = 0;
memset(fiop->mode, 0, sizeof(fiop->mode));
@@ -264,7 +263,7 @@ init_fileio(FILEIO *fiop, char *name, char *mode,
/* note read mode */
strlcpy(modestr, "r", sizeof(modestr));
fiop->reading = TRUE;
fiop->reading = true;
/* note binary mode even though mode is not used / ignored */
if (strchr(mode, 'b') != NULL) {
@@ -273,7 +272,7 @@ init_fileio(FILEIO *fiop, char *name, char *mode,
/* note if reading and writing */
if (strchr(mode, '+') != NULL) {
fiop->writing = TRUE;
fiop->writing = true;
strlcat(modestr, "+", sizeof(modestr));
}
@@ -282,7 +281,7 @@ init_fileio(FILEIO *fiop, char *name, char *mode,
/* note write mode */
strlcpy(modestr, "w", sizeof(modestr));
fiop->writing = TRUE;
fiop->writing = true;
/* note binary mode even though mode is not used / ignored */
if (strchr(mode, 'b') != NULL) {
@@ -291,7 +290,7 @@ init_fileio(FILEIO *fiop, char *name, char *mode,
/* note if reading and writing */
if (strchr(mode, '+') != NULL) {
fiop->reading = TRUE;
fiop->reading = true;
strlcat(modestr, "+", sizeof(modestr));
}
@@ -300,8 +299,8 @@ init_fileio(FILEIO *fiop, char *name, char *mode,
/* note append mode */
strlcpy(modestr, "a", sizeof(modestr));
fiop->writing = TRUE;
fiop->appending = TRUE;
fiop->writing = true;
fiop->appending = true;
/* note binary mode even though mode is not used / ignored */
if (strchr(mode, 'b') != NULL) {
@@ -310,7 +309,7 @@ init_fileio(FILEIO *fiop, char *name, char *mode,
/* note if reading and writing */
if (strchr(mode, '+') != NULL) {
fiop->reading = TRUE;
fiop->reading = true;
strlcat(modestr, "+", sizeof(modestr));
}
@@ -591,7 +590,7 @@ findid(FILEID id, int writable)
/*
* Return whether or not a file id is valid. This is used for if tests.
*/
BOOL
bool
validid(FILEID id)
{
return (findid(id, -1) != NULL);
@@ -616,7 +615,7 @@ indexid(long index)
/*
* Close the specified file id. Returns TRUE if there was an error.
* Close the specified file id. Returns true if there was an error.
* Closing of stdin, stdout, or stderr is illegal, but closing of already
* closed files is allowed.
*/
@@ -685,7 +684,7 @@ closeall(void)
/*
* Return whether or not an error occurred to a file.
*/
BOOL
bool
errorid(FILEID id)
{
FILEIO *fiop; /* file structure */
@@ -700,7 +699,7 @@ errorid(FILEID id)
/*
* Return whether or not end of file occurred to a file.
*/
BOOL
bool
eofid(FILEID id)
{
FILEIO *fiop; /* file structure */
@@ -777,14 +776,14 @@ readid(FILEID id, int flags, STRING **retstr)
char buf[READSIZE]; /* temporary buffer */
char *b;
int c;
BOOL nlstop, nullstop, wsstop, rmstop, done;
bool nlstop, nullstop, wsstop, rmstop, done;
FILEPOS fpos;
STRING *newstr;
totlen = 0;
str = NULL;
fiop = findid(id, FALSE);
fiop = findid(id, false);
if (fiop == NULL)
return 1;
nlstop = (flags & 1);
@@ -868,7 +867,7 @@ getcharid(FILEID id)
FILEIO *fiop;
FILEPOS fpos;
fiop = findid(id, FALSE);
fiop = findid(id, false);
if (fiop == NULL)
return -2;
if (fiop->action == 'w') {
@@ -973,12 +972,12 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
int oldmode, newmode;
long olddigits, newdigits;
long width, precision;
BOOL didneg, didprecision;
bool didneg, didprecision;
FILEPOS fpos;
BOOL printstring;
BOOL printchar;
bool printstring;
bool printchar;
fiop = findid(id, TRUE);
fiop = findid(id, true);
if (fiop == NULL)
return 1;
if (fiop->action == 'r') {
@@ -989,8 +988,8 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
fiop->action = 'w';
printstring = FALSE;
printchar = FALSE;
printstring = false;
printchar = false;
math_setfp(fiop->fp);
@@ -1003,14 +1002,14 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
/*
* Here to handle formats.
*/
didneg = FALSE;
didprecision = FALSE;
didneg = false;
didprecision = false;
width = 0;
precision = 0;
ch = *fmt++;
if (ch == '-') {
didneg = TRUE;
didneg = true;
ch = *fmt++;
}
while ((ch >= '0') && (ch <= '9')) {
@@ -1018,7 +1017,7 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
ch = *fmt++;
}
if (ch == '.') {
didprecision = TRUE;
didprecision = true;
ch = *fmt++;
while ((ch >= '0') && (ch <= '9')) {
precision = precision * 10 + (ch - '0');
@@ -1037,10 +1036,10 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
switch (ch) {
case 's':
printstring = TRUE;
printstring = true;
/*FALLTHRU*/
case 'c':
printchar = TRUE;
printchar = true;
case 'd':
break;
case 'f':
@@ -1212,7 +1211,7 @@ idfputc(FILEID id, int ch)
FILEPOS fpos;
/* get the file info pointer */
fiop = findid(id, TRUE);
fiop = findid(id, true);
if (fiop == NULL)
return 1;
if (fiop->action == 'r') {
@@ -1247,7 +1246,7 @@ idungetc(FILEID id, int ch)
{
FILEIO *fiop;
fiop = findid(id, FALSE);
fiop = findid(id, false);
if (fiop == NULL)
return -2;
if (fiop->action != 'r')
@@ -1273,7 +1272,7 @@ idfputs(FILEID id, STRING *str)
long len;
/* get the file info pointer */
fiop = findid(id, TRUE);
fiop = findid(id, true);
if (fiop == NULL)
return 1;
@@ -1310,7 +1309,7 @@ idfputstr(FILEID id, char *str)
FILEPOS fpos;
/* get the file info pointer */
fiop = findid(id, TRUE);
fiop = findid(id, true);
if (fiop == NULL)
return 1;
@@ -1992,7 +1991,7 @@ zfilesize(FILEID id)
void
showfiles(void)
{
BOOL listed[MAXFILES];
bool listed[MAXFILES];
FILEIO *fiop;
FILE *fp;
struct stat sbuf;
@@ -2001,7 +2000,7 @@ showfiles(void)
int i, j;
for (i = 0; i < idnum; i++) {
listed[i] = FALSE;
listed[i] = false;
fiop = &files[ioindex[i]];
fp = fiop->fp;
if (fstat(fileno(fp), &sbuf) < 0) {
@@ -2027,7 +2026,7 @@ showfiles(void)
if (listed[j] || sizes[j] == -1)
continue;
if (inodes[j] == inodes[i]) {
listed[j] = TRUE;
listed[j] = true;
fiop = &files[ioindex[j]];
printf("\t = ");
printid(fiop->id, PRINT_UNAMBIG);
@@ -2052,7 +2051,7 @@ showfiles(void)
* strptr pointer to where the new field pointer may be found
*/
S_FUNC void
getscanfield(FILE *fp, BOOL skip, unsigned int width, int scannum,
getscanfield(FILE *fp, bool skip, unsigned int width, int scannum,
char *scanptr, char **strptr)
{
char *str; /* current string */
@@ -2061,7 +2060,7 @@ getscanfield(FILE *fp, BOOL skip, unsigned int width, int scannum,
char buf[READSIZE]; /* temporary buffer */
int c;
char *b;
BOOL comp; /* Use complement of scanset */
bool comp; /* Use complement of scanset */
unsigned int chnum;
totlen = 0;
@@ -2131,7 +2130,7 @@ getscanfield(FILE *fp, BOOL skip, unsigned int width, int scannum,
* strptr pointer to where the new field pointer may be found
*/
S_FUNC void
getscanwhite(FILE *fp, BOOL skip, unsigned int width, int scannum,
getscanwhite(FILE *fp, bool skip, unsigned int width, int scannum,
char **strptr)
{
char *str; /* current string */
@@ -2140,7 +2139,7 @@ getscanwhite(FILE *fp, BOOL skip, unsigned int width, int scannum,
char buf[READSIZE]; /* temporary buffer */
int c;
char *b;
BOOL comp; /* Use complement of scanset */
bool comp; /* Use complement of scanset */
unsigned int chnum;
totlen = 0;
@@ -2207,8 +2206,8 @@ fscanfile(FILE *fp, char *fmt, int count, VALUE **vals)
int scannum; /* Number of characters in scanlist */
char *scanptr; /* Start of scanlist */
char *str;
BOOL comp; /* True scanset is complementary */
BOOL skip; /* True if string to be skipped rather than read */
bool comp; /* True scanset is complementary */
bool skip; /* True if string to be skipped rather than read */
int width;
VALUE *var; /* lvalue to be assigned to */
unsigned short subtype; /* for var->v_subtype */
@@ -2347,7 +2346,7 @@ fscanfid(FILEID id, char *fmt, int count, VALUE **vals)
FILE *fp;
FILEPOS fpos;
fiop = findid(id, FALSE);
fiop = findid(id, false);
if (fiop == NULL)
return -2;
@@ -2404,20 +2403,20 @@ freadnum(FILE *fp, VALUE *valptr)
HALF *a;
FULL f;
long decimals, exp;
BOOL sign, negexp, havedp, imag, exptoobig;
bool sign, negexp, havedp, imag, exptoobig;
decimals = 0;
exp = 0;
sign = FALSE;
negexp = FALSE;
havedp = FALSE;
imag = FALSE;
exptoobig = FALSE;
sign = false;
negexp = false;
havedp = false;
imag = false;
exptoobig = false;
ch = fgetc(fp);
if (ch == '+' || ch == '-') {
if (ch == '-')
sign = TRUE;
sign = true;
ch = fgetc(fp);
}
num.v = alloc(1);
@@ -2446,7 +2445,7 @@ freadnum(FILE *fp, VALUE *valptr)
decimals++;
}
else if (ch == '.')
havedp = TRUE;
havedp = true;
else
break;
ch = fgetc(fp);
@@ -2455,20 +2454,20 @@ freadnum(FILE *fp, VALUE *valptr)
ch = fgetc(fp);
if (ch == '+' || ch == '-') {
if (ch == '-')
negexp = TRUE;
negexp = true;
ch = fgetc(fp);
}
while (ch >= '0' && ch <= '9') {
if (!exptoobig) {
exp = (exp * 10) + ch - '0';
if (exp > 1000000)
exptoobig = TRUE;
exptoobig = true;
}
ch = fgetc(fp);
}
}
if (ch == 'i' || ch == 'I') {
imag = TRUE;
imag = true;
} else {
ungetc(ch, fp);
}
@@ -2648,7 +2647,7 @@ fsearch(FILEID id, char *str, ZVALUE start, ZVALUE end, ZVALUE *res)
long k = 0;
/* get FILEIO */
fiop = findid(id, FALSE);
fiop = findid(id, false);
if (fiop == NULL)
return -2;
@@ -2767,7 +2766,7 @@ frsearch(FILEID id, char *str, ZVALUE first, ZVALUE last, ZVALUE *res)
char *s; /* str comparison pointer */
/* get FILEIO */
fiop = findid(id, FALSE);
fiop = findid(id, false);
if (fiop == NULL)
return -2;

10
file.h
View File

@@ -1,7 +1,7 @@
/*
* file - file I/O routines callable by users
*
* Copyright (C) 1999-2007,2014,2021 David I. Bell and Landon Curt Noll
* Copyright (C) 1999-2007,2014,2021,2023 David I. Bell and Landon Curt Noll
*
* Primary author: David I. Bell
*
@@ -48,10 +48,10 @@ typedef struct {
dev_t dev; /* file device */
ino_t inode; /* file inode */
char *name; /* file name */
BOOL reading; /* TRUE if opened for reading */
BOOL writing; /* TRUE if opened for writing */
BOOL appending; /* TRUE if also opened for appending */
BOOL binary; /* TRUE if binary mode - mode ignored/unused */
bool reading; /* true if opened for reading */
bool writing; /* true if opened for writing */
bool appending; /* true if also opened for appending */
bool binary; /* true if binary mode - mode ignored/unused */
char action; /* most recent use for 'r', 'w' or 0 */
char mode[MODE_LEN+1]; /* open mode */
} FILEIO;

View File

@@ -1,7 +1,7 @@
/*
* fposval - Determine information about the file position type
*
* Copyright (C) 1999,2021 Landon Curt Noll
* Copyright (C) 1999,2021,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
@@ -72,6 +72,7 @@
#include "alloc.h"
#include "have_unused.h"
#include "have_memmv.h"
#include "zmath.h"
#include "banned.h" /* include after system header <> includes */

5903
func.c

File diff suppressed because it is too large Load Diff

5
func.h
View File

@@ -74,14 +74,15 @@ E_FUNC FUNC *curfunc; /* NOTE: This is a function pointer, we need E_FUNC */
/*
* Functions to handle functions.
*/
E_FUNC char *name_newerrorstr(int errnum);
E_FUNC FUNC *findfunc(long index);
E_FUNC char *namefunc(long index);
E_FUNC BOOL evaluate(BOOL nestflag);
E_FUNC bool evaluate(bool nestflag);
E_FUNC long adduserfunc(char *name);
E_FUNC void rmuserfunc(char *name);
E_FUNC void rmalluserfunc(void);
E_FUNC long getuserfunc(char *name);
E_FUNC void beginfunc(char *name, BOOL newflag);
E_FUNC void beginfunc(char *name, bool newflag);
E_FUNC int builtinopcode(long index);
E_FUNC char *builtinname(long index);
E_FUNC int dumpop(unsigned long *pc);

69
hash.c
View File

@@ -1,7 +1,7 @@
/*
* hash - one-way hash routines
*
* Copyright (C) 1999-2007,2021,2022 Landon Curt Noll
* Copyright (C) 1999-2007,2021-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
@@ -40,7 +40,7 @@
#include "hash.h"
#include "attribute.h"
#include "errtbl.h"
#include "banned.h" /* include after system header <> includes */
@@ -53,7 +53,7 @@ E_FUNC void MD5_init_state(HASH*);
/*
* hash_long can deal with BOOL's, int's, FLAGS's and LEN's
* hash_long can deal with bool's, int's, FLAGS's and LEN's
*/
#define hash_bool(type, val, state) (hash_long((type), (long)(val), (state)))
#define hash_int(type, val, state) (hash_long((type), (long)(val), (state)))
@@ -103,7 +103,7 @@ hash_init(int type, HASH *state)
* clear hash value
*/
memset((void*)state, 0, sizeof(HASH));
state->bytes = TRUE;
state->bytes = true;
/*
* search for the hash_setup function
@@ -194,8 +194,8 @@ hash_copy(HASH *state)
* b second hash state
*
* returns:
* TRUE => hash states are different
* FALSE => hash states are the same
* true => hash states are different
* false => hash states are the same
*/
int
hash_cmp(HASH *a, HASH *b)
@@ -205,15 +205,15 @@ hash_cmp(HASH *a, HASH *b)
*/
if (a == b) {
/* pointers to the same object */
return FALSE;
return false;
}
if (a == NULL || b == NULL) {
/* one pointer is NULL, so they differ */
return TRUE;
return true;
}
if (a->cmp == NULL || b->cmp == NULL) {
/* one cmp function is NULL, so they differ */
return TRUE;
return true;
}
/*
@@ -221,7 +221,7 @@ hash_cmp(HASH *a, HASH *b)
*/
if (a->hashtype != b->hashtype) {
/* different hash types are different */
return TRUE;
return true;
}
/*
@@ -278,7 +278,7 @@ hash_final(HASH *state)
* The input is a long. If a long is smaller than 64 bits, we will
* hash a final 32 bits of zeros.
*
* This function is OK to hash BOOL's, unsigned long's, unsigned int's
* This function is OK to hash bool's, unsigned long's, unsigned int's
* signed int's as well as FLAG's and LEN's.
*/
HASH *
@@ -297,7 +297,7 @@ hash_long(int type, long longval, HASH *state)
* setup for the hash_long
*/
(state->chkpt)(state);
state->bytes = FALSE; /* data to be read as words */
state->bytes = false; /* data to be read as words */
/*
* catch the zero numeric value special case
@@ -363,7 +363,7 @@ hash_zvalue(int type, ZVALUE zval, HASH *state)
* setup for the ZVALUE hash
*/
(state->chkpt)(state);
state->bytes = FALSE; /* data to be read as words */
state->bytes = false; /* data to be read as words */
/*
* catch the zero numeric value special case
@@ -470,7 +470,7 @@ HASH *
hash_number(int type, void *n, HASH *state)
{
NUMBER *number = (NUMBER *)n; /* n as a NUMBER pointer */
BOOL sign; /* sign of the denominator */
bool sign; /* sign of the denominator */
/*
* initialize if state is NULL
@@ -483,7 +483,7 @@ hash_number(int type, void *n, HASH *state)
* setup for the NUMBER hash
*/
(state->chkpt)(state);
state->bytes = FALSE;
state->bytes = false;
/*
* process the numerator
@@ -543,7 +543,7 @@ hash_complex(int type, void *c, HASH *state)
* setup for the COMPLEX hash
*/
(state->chkpt)(state);
state->bytes = FALSE;
state->bytes = false;
/*
* catch the zero special case
@@ -612,7 +612,7 @@ hash_str(int type, char *str, HASH *state)
*/
if (!state->bytes) {
(state->chkpt)(state);
state->bytes = TRUE;
state->bytes = true;
}
len = strlen(str);
@@ -655,7 +655,7 @@ hash_STR(int type, STRING *str, HASH *state)
*/
if (!state->bytes) {
(state->chkpt)(state);
state->bytes = TRUE;
state->bytes = true;
}
/*
@@ -697,7 +697,7 @@ hash_usb8(int type, USB8 *byte, int len, HASH *state)
*/
if (!state->bytes) {
(state->chkpt)(state);
state->bytes = TRUE;
state->bytes = true;
}
/*
@@ -748,7 +748,7 @@ hash_value(int type, void *v, HASH *state)
switch (value->v_type) {
case V_NULL:
(state->chkpt)(state);
state->bytes = TRUE;
state->bytes = true;
break;
case V_INT:
@@ -790,7 +790,7 @@ hash_value(int type, void *v, HASH *state)
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
state->bytes = TRUE;
state->bytes = true;
/* hash all the elements of the matrix */
for (i=0; i < value->v_mat->m_size; ++i) {
@@ -798,7 +798,7 @@ hash_value(int type, void *v, HASH *state)
/* hash the next matrix value */
state = hash_value(type,
value->v_mat->m_table+i, state);
state->bytes = FALSE; /* as if reading words */
state->bytes = false; /* as if reading words */
}
break;
@@ -814,7 +814,7 @@ hash_value(int type, void *v, HASH *state)
/* hash the next list value */
state = hash_value(type, &ep->e_value, state);
state->bytes = FALSE; /* as if reading words */
state->bytes = false; /* as if reading words */
}
break;
@@ -822,7 +822,7 @@ hash_value(int type, void *v, HASH *state)
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
state->bytes = TRUE;
state->bytes = true;
/* hash the association */
assochead = value->v_assoc->a_table;
@@ -834,7 +834,7 @@ hash_value(int type, void *v, HASH *state)
/* hash the next association value */
state = hash_value(type, &aep->e_value, state);
state->bytes = FALSE; /* as if reading words */
state->bytes = false; /* as if reading words */
}
assochead++;
}
@@ -844,7 +844,7 @@ hash_value(int type, void *v, HASH *state)
/* setup for the this value type */
(state->chkpt)(state);
(state->type)(value->v_type, state);
state->bytes = TRUE; /* reading bytes */
state->bytes = true; /* reading bytes */
/* hash the object name and then the element values */
@@ -859,7 +859,7 @@ hash_value(int type, void *v, HASH *state)
/* hash the next object value */
state = hash_value(type, vp, state);
state->bytes = FALSE; /* as if reading words */
state->bytes = false; /* as if reading words */
}
break;
@@ -919,7 +919,7 @@ hash_value(int type, void *v, HASH *state)
(USB8 *)value->v_rand->slot, SCNT*FULL_BITS/8);
(state->update)(state,
(USB8*)value->v_rand->shuf, SHUFLEN*FULL_BITS/8);
state->bytes = FALSE; /* as if reading words */
state->bytes = false; /* as if reading words */
break;
case V_RANDOM:
@@ -934,7 +934,7 @@ hash_value(int type, void *v, HASH *state)
(USB8 *)&(value->v_random->buffer), BASEB/8);
state = hash_zvalue(type, value->v_random->r, state);
state = hash_zvalue(type, value->v_random->n, state);
state->bytes = FALSE; /* as if reading words */
state->bytes = false; /* as if reading words */
break;
case V_CONFIG:
@@ -967,14 +967,15 @@ hash_value(int type, void *v, HASH *state)
state = hash_long(type, (long)value->v_config->cfsim, state);
state = hash_long(type, (long)value->v_config->outround, state);
state = hash_long(type, (long)value->v_config->round, state);
state = hash_long(type, (long)value->v_config->triground, state);
state = hash_bool(type, value->v_config->leadzero, state);
state = hash_bool(type, value->v_config->fullzero, state);
state = hash_long(type,
(long)value->v_config->maxscancount, state);
state = hash_str(type, value->v_config->prompt1, state);
state->bytes = FALSE; /* as if just read words */
state->bytes = false; /* as if just read words */
state = hash_str(type, value->v_config->prompt2, state);
state->bytes = FALSE; /* as if just read words */
state->bytes = false; /* as if just read words */
state = hash_int(type, value->v_config->blkmaxprint, state);
state = hash_bool(type, value->v_config->blkverbose, state);
state = hash_int(type, value->v_config->blkbase, state);
@@ -994,9 +995,9 @@ hash_value(int type, void *v, HASH *state)
state = hash_bool(type, value->v_config->compile_custom, state);
if (value->v_config->allow_custom != NULL &&
*(value->v_config->allow_custom)) {
state = hash_bool(type, TRUE, state);
state = hash_bool(type, true, state);
} else {
state = hash_bool(type, FALSE, state);
state = hash_bool(type, false, state);
}
state = hash_str(type, value->v_config->version, state);
state = hash_int(type, value->v_config->baseb, state);
@@ -1018,7 +1019,7 @@ hash_value(int type, void *v, HASH *state)
state = hash_int(type, value->v_hash->unionsize, state);
(state->update)(state,
value->v_hash->h_union.data, state->unionsize);
state->bytes = FALSE; /* as if reading words */
state->bytes = false; /* as if reading words */
break;
case V_BLOCK:

6
hash.h
View File

@@ -1,7 +1,7 @@
/*
* hash - one-way hash routines
*
* Copyright (C) 1999-2007,2014 Landon Curt Noll
* Copyright (C) 1999-2007,2014,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
@@ -60,13 +60,13 @@
typedef struct hashstate HASH;
struct hashstate {
int hashtype; /* XYZ_HASH_TYPE debug value */
BOOL bytes; /* TRUE => reading bytes rather than words */
bool bytes; /* true => reading bytes rather than words */
void (*update)(HASH*, USB8*, USB32); /* update arbitrary length */
void (*chkpt)(HASH*); /* checkpoint a state */
void (*note)(int, HASH*); /* note a special value */
void (*type)(int, HASH*); /* note a VALUE type */
ZVALUE (*final)(HASH*); /* complete hash state */
int (*cmp)(HASH*,HASH*); /* compare to states, TRUE => a!=b */
int (*cmp)(HASH*,HASH*); /* compare to states, true => a!=b */
void (*print)(HASH*); /* print the value of a hash */
int base; /* XYZ_BASE special hash value */
int chunksize; /* XYZ_CHUNKSIZE input chunk size */

View File

@@ -4,13 +4,7 @@
#
# Copyright (C) 1999-2006,2017,2021-2023 Landon Curt Noll
#
# SRC: help/Makefile
#
# The "# SRC: ... - ..." comment line above indicates
# the origin of this file.
#
# IMPORTANT: Please see the section on Makefiles near the
# bottom of the HOWTO.INSTALL file.
# Suggestion: Read the ../HOWTO.INSTALL file.
#
# 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
@@ -29,184 +23,63 @@
# Under source code control: 1991/07/23 06:47:57
# File existed as early as: 1991
#
# This calculator first developed by David I. Bell with help/mods from others.
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
#
# calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# The shell used by this Makefile
#
# On some systems, /bin/sh is a rather reduced shell with
# deprecated behavior.
#
# If your system has a up to date, bash shell, then
# you may wish to use:
#
# SHELL= bash
#
# On some systems such as macOS, the bash shell is very
# far behind to the point where is cannot be depended on.
# On such systems, the sh may be a much better alternative
# shell for this Makefile to use:
#
# SHELL= sh
#
SHELL= bash
#SHELL= sh
#if 0 /* start of skip for non-Gnu makefiles */
#
ifeq ($(target),Darwin)
SHELL:= /bin/sh
endif
#endif /* end of skip for non-Gnu makefiles */
# SUGGESTION: Instead of modifying this file, consider adding
# statements to modify, replace or append Makefile
# variables in the ../Makefile.local file.
####
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
####
# PREFIX - Top level location for calc
#
# The PREFIX is often prepended to paths within calc and calc Makefiles.
#
# Starting with calc v2.13.0.1, nearly all Makefile places that used
# /usr/local now use ${PREFIX}. An exception is the olduninstall rule
# and, of course, this section. :-)
#
# NOTE: The ${PREFIX} is not the same as ${T}. The ${T} specifies
# a top level directory under which calc installs things.
# While usually ${T} is empty, it can be specific path
# as if calc where "chrooted" during an install.
# The ${PREFIX} value, during install, is a path between
# the top level ${T} install directory and the object
# such as an include file.
#
# NOTE: See also, ${T}, below.
#
# There are some paths that do NOT call under ${PREFIX}, such as
# ${CALCPATH}, that include paths not under ${PREFIX}, but those
# too are exceptions to this general rule.
#
# When in doubt, try:
#
# PREFIX= /usr/local
#
PREFIX= /usr/local
#PREFIX= /usr
#PREFIX= /usr/global
###########################################
# Files used or included by this Makefile #
###########################################
# Normally certain files depend on the Makefile. If the Makefile is
# changed, then certain steps should be redone. If MAKE_FILE is
# set to Makefile, then these files will depend on Makefile. If
# MAKE_FILE is empty, then they wont.
# MAKE_FILE is empty, then they won't.
#
# If in doubt, set MAKE_FILE to Makefile
#
MAKE_FILE= Makefile
# Where the system include (.h) files are kept
#
# For DJGPP, select:
#
# INCDIR= /dev/env/DJDIR/include
#
# If in doubt, set:
#
# INCDIR= /usr/include
# Calc configuration and compile configuration values
#
CONFIG_MKF= ../Makefile.config
#INCDIR= /usr/local/include
#INCDIR= /dev/env/DJDIR/include
INCDIR= /usr/include
# Host targets that are shared in common with both Makefile
# and custom/Makefile.
#
TARGET_MKF= ../Makefile.target
# where to install calc related things
# Host target information.
#
# ${BINDIR} where to install calc binary files
# ${LIBDIR} where calc link library (*.a) files are installed
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
#
# NOTE: The install rule prepends installation paths with ${T}, which
# by default is empty. If ${T} is non-empty, then installation
# locations will be relative to the ${T} directory.
#
# For DJGPP, select:
#
# BINDIR= /dev/env/DJDIR/bin
# LIBDIR= /dev/env/DJDIR/lib
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
#
# If in doubt, set:
#
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
#
#BINDIR= ${PREFIX}/bin
#BINDIR= /dev/env/DJDIR/bin
BINDIR= /usr/bin
LOCAL_MKF= ../Makefile.local
#LIBDIR= ${PREFIX}/lib
#LIBDIR= /dev/env/DJDIR/lib
LIBDIR= /usr/lib
# The set of Makefiles
#
MK_SET= ${MAKE_FILE} ${CONFIG_MKF} ${TARGET_MKF} ${LOCAL_MKF}
#CALC_SHAREDIR= ${PREFIX}/lib/calc
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
CALC_SHAREDIR= /usr/share/calc
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
# ---------------------------------------------------------------
# ${HELPDIR} where the help directory is installed
# ${CALC_INCDIR} where the calc include files are installed
# ${SCRIPTDIR} where calc shell scripts are installed
#
# NOTE: The install rule prepends installation paths with ${T}, which
# by default is empty. If ${T} is non-empty, then installation
# locations will be relative to the ${T} directory.
#
# If in doubt, set:
#
# HELPDIR= ${CALC_SHAREDIR}/help
# CALC_INCDIR= ${INCDIR}/calc
# SCRIPTDIR= ${BINDIR}/cscript
#
HELPDIR= ${CALC_SHAREDIR}/help
CALC_INCDIR= ${INCDIR}/calc
SCRIPTDIR= ${BINDIR}/cscript
#######################################################
# Calc configuration and compile configuration values #
#######################################################
include ${CONFIG_MKF}
# T - top level directory under which calc will be installed
#
# The calc install is performed under ${T}, the calc build is
# performed under /. The purpose for ${T} is to allow someone
# to install calc somewhere other than into the system area.
#
# For example, if:
#
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
#
# and if:
#
# T= /var/tmp/testing
#
# Then the installation locations will be:
#
# calc binary files: /var/tmp/testing/usr/bin
# calc link library: /var/tmp/testing/usr/lib
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
# ... etc ... /var/tmp/testing/...
#
# If ${T} is empty, calc is installed under /, which is the same
# top of tree for which it was built. If ${T} is non-empty, then
# calc is installed under ${T}, as if one had to chroot under
# ${T} for calc to operate.
#
# If in doubt, use T=
#
T=
###############################
# host target section include #
###############################
include ${TARGET_MKF}
##########################################################################
#=-=-=-=-=- Be careful if you change something below this line -=-=-=-=-=#
##########################################################################
# Makefile debug
#
@@ -240,41 +113,11 @@ H=@
V=@:
#V=@
# standard tools
#
CAT= cat
CHMOD= chmod
CMP= cmp
CP= cp
FMT= fmt
GREP= grep
ICFLAGS=
ILDFLAGS=
LCC= cc
MKDIR= mkdir
MV= mv
RM= rm
RMDIR= rmdir
SED= sed
SORT= sort
TOUCH= touch
TRUE= true
# Some out of date operating systems require / want an executable to
# end with a certain file extension. Some compile systems such as
# Cygwin build calc as calc.exe. The EXT variable is used to denote
# the extension required by such.
#
# EXT= # normal Un*x / Linux / GNU/Linux systems
# EXT=.exe # Windows / Cygwin
#
# If in doubt, use EXT=
#
EXT=
#EXT=.exe
##################################
# Files managed by this Makefile #
##################################
# Standard and Builtin help files
#
STD_HELP_FILES_1= intro overview help
STD_HELP_FILES_2= assoc
@@ -356,42 +199,45 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
#
# to keep this list in nice sorted order.
#
DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \
append appr arg argv arrow asec asech asin asinh assign atan atan2 \
atanh avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
btrunc calc_tty calclevel calcpath catalan ceil cfappr cfsim char \
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime d2dm \
d2dms d2g d2r delete den dereference det digit digits display dms2d dp \
epsilon errcount errmax errno error estr euler eval exp fact factor \
fclose fcnt feof ferror fflush fgetc fgetfield fgetfile fgetline fgets \
fgetstr fib files floor fopen forall fpathopen fprintf fputc fputs \
fputstr frac free freebernoulli freeeuler freeglobals freeredc \
freestatics frem freopen fscan fscanf fseek fsize ftell g2d g2gm g2gms \
g2r gcd gcdrem gd getenv gms2g h2hm h2hms hash head highbit hmean \
hms2h hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert int \
inverse iroot isalnum isalpha isassoc isatty isblk iscntrl isconfig \
isdefined isdigit iserror iseven isfile isgraph ishash isident isint \
islist islower ismat ismult isnull isnum isobj isobjtype isodd isprime \
DETAIL_HELP= abs access acos acosh acot acoth acovercos acoversin \
acrd acsc acsch address aexcsc aexsec agd ahacovercos ahacoversin \
ahavercos ahaversin append appr arg argv arrow asec asech asin asinh \
assign atan atan2 atanh avercos aversin avg base base2 bernoulli bit \
blk blkcpy blkfree blocks bround btrunc calc_tty calclevel calcpath \
cas catalan ceil cfappr cfsim char cis cmdbuf cmp comb conj cos cosh \
cot coth count covercos coversin cp crd csc csch ctime d2dm d2dms d2g \
d2r delete den dereference det digit digits display dms2d dp epsilon \
errcount errmax errno error errsym estr euler eval excsc exp exsec \
fact factor fclose fcnt feof ferror fflush fgetc fgetfield fgetfile \
fgetline fgets fgetstr fib files floor fopen forall fpathopen fprintf \
fputc fputs fputstr frac free freebernoulli freeeuler freeglobals \
freeredc freestatics frem freopen fscan fscanf fseek fsize ftell g2d \
g2gm g2gms g2r gcd gcdrem gd getenv gms2g h2hm h2hms hacovercos \
hacoversin hash havercos haversin head highbit hmean hms2h hnrmod \
hypot ilog ilog10 ilog2 im indices inputlevel insert int inverse iroot \
isalnum isalpha isassoc isatty isblk iscntrl isconfig isdefined \
isdigit iserror iseven isfile isgraph ishash isident isint islist \
islower ismat ismult isnull isnum isobj isobjtype isodd isprime \
isprint isptr ispunct isqrt isrand israndom isreal isrel issimple \
isspace issq isstr istype isupper isxdigit jacobi join lcm lcmfact \
lfactor ln log lowbit ltol makelist matdim matfill matmax matmin \
matsum mattrace mattrans max memsize meq min minv mmin mne mod modify \
name near newerror nextcand nextprime norm null num oldvalue ord param \
perm pfact pi pix places pmod polar poly pop popcnt pound power \
prevcand prevprime printf prompt protect ptest push putenv quo quomod \
r2d r2g rand randbit random randombit randperm rcin rcmul rcout rcpow \
rcsq re remove reverse rewind rm root round rsearch runtime saveval \
scale scan scanf search sec sech seed segment select sgn sha1 sin sinh \
size sizeof sleep sort sqrt srand srandom ssq stoponerror str \
lfactor ln log log2 logn lowbit ltol makelist matdim matfill matmax \
matmin matsum mattrace mattrans max memsize meq min minv mmin mne mod \
modify name near newerror nextcand nextprime norm null num oldvalue \
ord param perm pfact pi pix places pmod polar poly pop popcnt pound \
power prevcand prevprime printf prompt protect ptest push putenv quo \
quomod r2d r2g rand randbit random randombit randperm rcin rcmul rcout \
rcpow rcsq re remove reverse rewind rm root round rsearch runtime \
saveval scale scan scanf search sec sech seed segment select sgn sha1 \
sin sinh size sizeof sleep sort sqrt srand srandom ssq stoponerror str \
strcasecmp strcat strcmp strcpy strerror strlen strncasecmp strncmp \
strncpy strpos strprintf strscan strscanf strtolower strtoupper substr \
sum swap system systime tail tan tanh test time trunc usertime version \
xor
sum swap system systime tail tan tanh test time trunc usertime vercos \
versin version xor
# This list is of files that are clones of DETAIL_HELP files. They are
# built from DETAIL_HELP files.
#
DETAIL_CLONE= copy
DETAIL_CLONE= copy ilogn
# Singular files
#
@@ -403,8 +249,7 @@ SINGULAR_FILES= binding bug change errorcode type
# These files are found (but not built) in the distribution
#
DISTLIST= ${STD_HELP_FILES} ${DETAIL_HELP} ${MAKE_FILE} \
obj.file builtin.top builtin.end funclist.sed \
errorcodes.hdr errorcodes.sed
obj.file builtin.top builtin.end funclist.sed
# These files are used to make (but not built) a calc .a link library
#
@@ -414,9 +259,25 @@ CALCLIBLIST=
#
PHONY= all clobber distlist install
############################################################
# Allow Makefile.local to change any of the above settings #
############################################################
include ${LOCAL_MKF}
###########################################
# all - First and default Makefile target #
###########################################
all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \
${SINGULAR_FILES} .all
###############################
# additional Makefile targets #
###############################
# 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
@@ -501,10 +362,9 @@ contrib: ../CONTRIB-CODE
${TRUE}; \
fi
errorcodes: ../calcerr.h errorcodes.hdr errorcodes.sed
errorcodes: ../errcode${EXT}
${RM} -f $@
${CAT} errorcodes.hdr > $@
${SED} -n -f errorcodes.sed < ../calcerr.h >> $@
../errcode${EXT} -e > $@
${CHMOD} 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
@@ -642,6 +502,18 @@ releases: ../README.RELEASE
${TRUE}; \
fi
ilogn: ilog
${RM} -f $@
${CP} ilog $@
${CHMOD} 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
echo ''; \
else \
${TRUE}; \
fi
full: ${FULL_HELP_FILES} ${MAKE_FILE}
${Q} echo "forming full"
${Q} ${RM} -f $@
@@ -767,8 +639,7 @@ detail_help_list:
! -name archive ! -name assoc ! -name builtin.end \
! -name builtin.top ! -name command ! -name config \
! -name contrib ! -name credit ! -name custom ! -name define \
! -name environment ! -name errorcodes.hdr \
! -name errorcodes.sed ! -name expression ! -name file \
! -name environment ! -name expression ! -name file \
! -name funclist.c ! -name funclist.sed ! -name help \
! -name history ! -name interrupt ! -name intro ! -name list \
! -name mat ! -name obj.file ! -name operator \

View File

@@ -36,7 +36,7 @@ EXAMPLE
5 6.40312 6.4031242374
LIMITS
none
when x is complex, eps != 0
LINK LIBRARY
NUMBER *qqabs(NUMBER *x)
@@ -44,7 +44,7 @@ LINK LIBRARY
SEE ALSO
cmp, epsilon, hypot, norm, near, obj
## Copyright (C) 1999,2021 Landon Curt Noll
## Copyright (C) 1999,2021,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

@@ -5,31 +5,72 @@ SYNOPSIS
acos(x [,eps])
TYPES
x real, -1 <= x <= 1
eps nonzero real, defaults to epsilon()
x number (real or complex)
eps 0 < real < 1, defaults to epsilon()
return real
DESCRIPTION
Returns the acos of x to a multiple of eps with error less in
Returns the inverse trigonometric cosine of x to a multiple of eps with error less in
absolute value than .75 * eps.
v = acos(x) is the number in [0, pi] for which cos(v) = x.
This function is sometimes called arccos.
EXAMPLE
; print acos(0), acos(0.5), acos(1)
1.57079632679489661923 1.04719755119659774615 0
; print acos(-0.5), acos(-1)
2.09439510239319549231 3.14159265358979323846
; print acos(.5, 1e-5), acos(.5, 1e-10), acos(.5, 1e-15), acos(.5, 1e-20)
1.0472 1.0471975512 1.047197551196598 1.04719755119659774615
; print acos(5), acos(5i)
2.29243166956117768776i 1.57079632679489661923-2.31243834127275262025i
; print acos(5+5i)
0.79039774680951249644-2.64919617780647114961i
; pi = pi(1e-20)
; print acos(pi/6), acos(pi/3)
1.01972674369545025075 0.30604210861326573755i
; print acos(4*pi/3)
2.11099630859669864896i
LIMITS
none
0 < eps < 1
LINK LIBRARY
NUMBER *qacos(NUMBER *x, NUMBER *eps)
COMPLEX *c_acos(COMPLEX *c, NUMBER *epsilon)
SEE ALSO
asin, atan, asec, acsc, acot, epsilon
sin, cos, tan, cot, sec, csc
asin, 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
epsilon
## Copyright (C) 1999 Landon Curt Noll
EXTERNAL RESOURCES
For general information on trigonometric functions, see:
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
https://en.wikipedia.org/wiki/Versine
https://en.wikipedia.org/wiki/Exsecant
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
https://en.wikipedia.org/wiki/Chord_(geometry)
https://en.wikipedia.org/wiki/Secant_line
https://en.wikipedia.org/wiki/Hartley_transform#cas
https://en.wikipedia.org/wiki/Cis_(mathematics)
## Copyright (C) 1999,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

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES
x real, x >= 1
eps nonzero real, defaults to epsilon()
eps 0 < real < 1, defaults to epsilon()
return nonnegative real
@@ -24,15 +24,17 @@ EXAMPLE
1.31696 1.3169578969 1.316957896924817 1.31695789692481670862
LIMITS
none
0 < eps < 1
LINK LIBRARY
NUMBER *qacosh(NUMBER *x, NUMBER *eps)
SEE ALSO
asinh, atanh, asech, acsch, acoth, epsilon
sinh, cosh, tanh, coth, sech, csch
asinh, atanh, acoth, asech, acsch
epsilon
## Copyright (C) 1999 Landon Curt Noll
## Copyright (C) 1999,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

@@ -5,31 +5,72 @@ SYNOPSIS
acot(x [,eps])
TYPES
x real
eps nonzero real, defaults to epsilon()
x number (real or complex)
eps 0 < real < 1, defaults to epsilon()
return real
DESCRIPTION
Returns the acot of x to a multiple of eps with error less in
Returns the inverse trigonometric cotangent of x to a multiple of eps with error less in
absolute value than .75 * eps.
v = acot(x) is the number in (0, pi) for which cot(v) = x.
This function is sometimes called arccot.
EXAMPLE
; print acot(2, 1e-5), acot(2, 1e-10), acot(2, 1e-15), acot(2, 1e-20)
0.46365 0.463647609 0.463647609000806 0.46364760900080611621
; print acot(0), acot(0.5), acot(1)
1.57079632679489661923 1.10714871779409050302 0.78539816339744830962
; print acot(-0.5), acot(-1)
2.03444393579570273544 2.35619449019234492885
; print acot(.5, 1e-5), acot(.5, 1e-10), acot(.5, 1e-15), acot(.5, 1e-20)
1.10715 1.1071487178 1.107148717794091 1.10714871779409050302
; print acot(5), acot(5i)
0.19739555984988075837 -0.20273255405408219099i
; print acot(5+5i)
0.10065855418732038003-0.09932544936725086122i
; pi = pi(1e-20)
; print acot(pi/6), acot(pi/3)
1.08844841969387164375 0.76234753416487458792
; print acot(4*pi/3)
0.23434608748833616077
LIMITS
none
0 < eps < 1
LINK LIBRARY
NUMBER *qacot(NUMBER *x, NUMBER *eps)
COMPLEX *c_acot(COMPLEX *c, NUMBER *epsilon)
SEE ALSO
asin, acos, atan, asec, acsc, epsilon
sin, cos, tan, cot, sec, csc
asin, acos, atan, 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
epsilon
## Copyright (C) 1999,2021 Landon Curt Noll
EXTERNAL RESOURCES
For general information on trigonometric functions, see:
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
https://en.wikipedia.org/wiki/Versine
https://en.wikipedia.org/wiki/Exsecant
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
https://en.wikipedia.org/wiki/Chord_(geometry)
https://en.wikipedia.org/wiki/Secant_line
https://en.wikipedia.org/wiki/Hartley_transform#cas
https://en.wikipedia.org/wiki/Cis_(mathematics)
## Copyright (C) 1999,2021,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

@@ -6,7 +6,7 @@ SYNOPSIS
TYPES
x real, with abs(x) > 1
eps nonzero real, defaults to epsilon()
eps 0 < real < 1, defaults to epsilon()
return real
@@ -23,15 +23,17 @@ EXAMPLE
0.54931 0.5493061443 0.549306144334055 0.5493061443340548457
LIMITS
none
0 < eps < 1
LINK LIBRARY
NUMBER *qacoth(NUMBER *x, NUMBER *eps)
SEE ALSO
asinh, acosh, atanh, asech, acsch, epsilon
sinh, cosh, tanh, coth, sech, csch
asinh, acosh, atanh, asech, acsch
epsilon
## Copyright (C) 1999,2021 Landon Curt Noll
## Copyright (C) 1999,2021,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

92
help/acovercos Normal file
View File

@@ -0,0 +1,92 @@
NAME
acovercos - inverse coversed trigonometric cosine
SYNOPSIS
acovercos(x [,eps])
TYPES
x number (real or complex)
eps 0 < real < 1, defaults to epsilon()
return number
DESCRIPTION
Calculate the inverse coversed trigonometric cosine of x to a multiple of eps with error less in
absolute value than .75 * eps.
This function is sometimes called acvc, or arccovercos, is equivalent to:
acovercos(x) = asin(x - 1)
EXAMPLE
; print acovercos(0), acovercos(0.5), acovercos(1)
1.57079632679489661923 0.52359877559829887308 0
; print acovercos(-0.5), acovercos(-1)
-1.57079632679489661923+0.96242365011920689498i -1.57079632679489661923+1.31695789692481670863i
; print acovercos(.5, 1e-5), acovercos(.5, 1e-10), acovercos(.5, 1e-15), acovercos(.5, 1e-20)
0.5236 0.5235987756 0.523598775598299 0.52359877559829887308
; print acovercos(5), acovercos(5i)
1.57079632679489661923-2.06343706889556054673i -0.19379313655493218978+2.33097465304931241744i
; print acovercos(5+5i)
0.66881657532592728975+2.5513216254756988588i
; pi = pi(1e-20)
; print acovercos(pi/6), acovercos(pi/3), acovercos(4*pi/3)
0.49655704344777825545 -0.04721509173238348552 1.57079632679489661923-1.82724307729474887791i
LIMITS
0 < eps < 1
LINK LIBRARY
NUMBER *qacovercos(NUMBER *x, NUMBER *eps)
COMPLEX *c_acovercos(COMPLEX *x, NUMBER *eps)
SEE ALSO
sin, cos, tan, cot, sec, csc
asin, acos, atan, acot, asec, acsc
versin, coversin, vercos, covercos
aversin, acoversin, avercos
haversin, hacoversin, havercos, hacovercos
ahaversin, hacoversin, havercos, ahacovercos
exsec, aexsec, excsc, aexcsc
crd, acrd
cas, cis
epsilon
EXTERNAL RESOURCES
For general information on trigonometric functions, see:
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
https://en.wikipedia.org/wiki/Versine
https://en.wikipedia.org/wiki/Exsecant
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
https://en.wikipedia.org/wiki/Chord_(geometry)
https://en.wikipedia.org/wiki/Secant_line
https://en.wikipedia.org/wiki/Hartley_transform#cas
https://en.wikipedia.org/wiki/Cis_(mathematics)
## Copyright (C) 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
## 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.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## Under source code control: 2023/09/05 23:30:08
## 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/

92
help/acoversin Normal file
View File

@@ -0,0 +1,92 @@
NAME
acoversin - inverse coversed trigonometric sine
SYNOPSIS
acoversin(x [,eps])
TYPES
x number (real or complex)
eps 0 < real < 1, defaults to epsilon()
return number
DESCRIPTION
Calculate the inverse coversed trigonometric sine of x to a multiple of eps with error less in
absolute value than .75 * eps.
This function is sometimes called acovers, or acvs, or arccoversin, is equivalent to:
acoversin(x) = asin(1 - x)
EXAMPLE
; print acoversin(0), acoversin(0.5), acoversin(1)
1.57079632679489661923 0.52359877559829887308 0
; print acoversin(-0.5), acoversin(-1)
1.57079632679489661923-0.96242365011920689499i 1.57079632679489661923-1.31695789692481670863i
; print acoversin(.5, 1e-5), acoversin(.5, 1e-10), acoversin(.5, 1e-15), acoversin(.5, 1e-20)
0.5236 0.5235987756 0.523598775598299 0.52359877559829887308
; print acoversin(5), acoversin(5i)
-1.57079632679489661923+2.06343706889556054673i 0.19379313655493218978-2.33097465304931241744i
; print acoversin(5+5i)
-0.66881657532592728975-2.5513216254756988588i
; pi = pi(1e-20)
; print acoversin(pi/6), acoversin(pi/3), acoversin(4*pi/3)
0.49655704344777825545 -0.04721509173238348552 -1.57079632679489661923+1.82724307729474887792i
LIMITS
0 < eps < 1
LINK LIBRARY
NUMBER *qacoversin(NUMBER *x, NUMBER *eps)
COMPLEX *c_acoversin(COMPLEX *x, NUMBER *eps)
SEE ALSO
sin, cos, tan, cot, sec, csc
asin, acos, atan, acot, asec, acsc
versin, coversin, vercos, covercos
aversin, avercos, acovercos
haversin, hacoversin, havercos, hacovercos
ahaversin, hacoversin, havercos, ahacovercos
exsec, aexsec, excsc, aexcsc
crd, acrd
cas, cis
epsilon
EXTERNAL RESOURCES
For general information on trigonometric functions, see:
https://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions
https://en.wikipedia.org/wiki/Versine
https://en.wikipedia.org/wiki/Exsecant
https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
https://en.wikipedia.org/wiki/Chord_(geometry)
https://en.wikipedia.org/wiki/Secant_line
https://en.wikipedia.org/wiki/Hartley_transform#cas
https://en.wikipedia.org/wiki/Cis_(mathematics)
## Copyright (C) 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
## 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.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## Under source code control: 2023/08/31 23:07:08
## 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/

Some files were not shown because too many files have changed in this diff Show More