mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
69 Commits
prod-2.14.
...
v2.14.3.5
Author | SHA1 | Date | |
---|---|---|---|
|
28449fd187 | ||
|
d88b128b2d | ||
|
bc048bc029 | ||
|
4d32b138ed | ||
|
3cd8fd7053 | ||
|
b0f19c1011 | ||
|
fe520975cf | ||
|
f097dd7dc1 | ||
|
3a7e763b28 | ||
|
661e99829e | ||
|
faf3a4fab6 | ||
|
7d8d4cb5ea | ||
|
af9b052fe9 | ||
|
40f8654aa4 | ||
|
92c8d89ed1 | ||
|
1e2d02e449 | ||
|
e0df1646fc | ||
|
ee900ec6ec | ||
|
6ee34e709d | ||
|
f81d67b322 | ||
|
21ab25d1c9 | ||
|
06dcb3e51e | ||
|
6e0e48e17e | ||
|
f416973a31 | ||
|
b408b59d8d | ||
|
77405e1d84 | ||
|
da623e13cb | ||
|
f025dcf0d8 | ||
|
3bfcaae767 | ||
|
bf5b56d263 | ||
|
0b044ce972 | ||
|
e2686911ae | ||
|
544b873914 | ||
|
948d9e807b | ||
|
6d020b7fbe | ||
|
9fcdd80549 | ||
|
3148ce06a0 | ||
|
945977f1f4 | ||
|
b03e71f0ce | ||
|
db799aac10 | ||
|
adecf7d76e | ||
|
94bf264088 | ||
|
80e841eded | ||
|
3f78fc20d7 | ||
|
c26460b255 | ||
|
3ec7b39366 | ||
|
49c599aec9 | ||
|
a582511002 | ||
|
e05d904821 | ||
|
ccd579ecda | ||
|
15be1dec4d | ||
|
f34c659877 | ||
|
2ad27e7909 | ||
|
a4d3c8ff9d | ||
|
bd64a6cc36 | ||
|
e2b2976d18 | ||
|
3ea51ea937 | ||
|
5fa732b869 | ||
|
6a54caf1c2 | ||
|
cce930987b | ||
|
7c806f13ea | ||
|
616bcd8d46 | ||
|
36a1a042f3 | ||
|
75159fcbc2 | ||
|
8ef7b5311e | ||
|
d5a11b3df4 | ||
|
74c299ad4e | ||
|
d89ea78104 | ||
|
644b348bcb |
21
.gitignore
vendored
21
.gitignore
vendored
@@ -6,25 +6,27 @@
|
||||
#
|
||||
.dynamic
|
||||
.hsrc
|
||||
NOTES
|
||||
.static
|
||||
align32.h
|
||||
args.h
|
||||
cal/.all
|
||||
calc
|
||||
calc.1
|
||||
calc.usage
|
||||
calcerr.c
|
||||
calcerr.h
|
||||
calc.spec
|
||||
calc-static
|
||||
calc.usage
|
||||
charbit.h
|
||||
conf.h
|
||||
cscript/.all
|
||||
cscript/4dsphere
|
||||
cscript/README
|
||||
cscript/.all
|
||||
cscript/fproduct
|
||||
cscript/mersenne
|
||||
cscript/piforever
|
||||
cscript/plus
|
||||
cscript/powerterm
|
||||
cscript/README
|
||||
cscript/simple
|
||||
cscript/square
|
||||
custom/.all
|
||||
@@ -49,12 +51,16 @@ have_newstr.h
|
||||
have_offscl.h
|
||||
have_posscl.h
|
||||
have_rusage.h
|
||||
have_statfs.h
|
||||
have_stdlib.h
|
||||
have_stdvs
|
||||
have_strdup.h
|
||||
have_string.h
|
||||
have_strlcat.h
|
||||
have_strlcpy.h
|
||||
have_sys_mount.h
|
||||
have_sys_param.h
|
||||
have_sys_vfs.h
|
||||
have_times.h
|
||||
have_uid_t.h
|
||||
have_unistd.h
|
||||
@@ -62,8 +68,6 @@ have_unused.h
|
||||
have_urandom.h
|
||||
have_ustat.h
|
||||
help/.all
|
||||
help/COPYING
|
||||
help/COPYING-LGPL
|
||||
help/binding
|
||||
help/bindings
|
||||
help/bug
|
||||
@@ -73,6 +77,8 @@ help/change
|
||||
help/changes
|
||||
help/contrib
|
||||
help/copy
|
||||
help/COPYING
|
||||
help/COPYING-LGPL
|
||||
help/cscript
|
||||
help/custom_cal
|
||||
help/errorcode
|
||||
@@ -94,8 +100,11 @@ libcustcalc*
|
||||
longbits
|
||||
longbits.h
|
||||
Makefile.our
|
||||
NOTES
|
||||
sample_many
|
||||
sample_many-static
|
||||
sample_rand
|
||||
sample_rand-static
|
||||
tags
|
||||
terminal.h
|
||||
ver_calc
|
||||
|
61
BUGS
61
BUGS
@@ -28,7 +28,7 @@ Click in the triangle to open up the Assets then click on
|
||||
the approptiate package to download.
|
||||
|
||||
If you made and modifications to calc beyond the simple Makefile
|
||||
configuration, try backing those changges out and see if things get
|
||||
configuration, try backing those changes out and see if things get
|
||||
better.
|
||||
|
||||
If you have tried all of the above and things still are not right,
|
||||
@@ -60,44 +60,7 @@ GitHub web page, click on this button:
|
||||
|
||||
((New Issue))
|
||||
|
||||
=-=
|
||||
|
||||
If you prefer to not use GitHub, then you
|
||||
may send bug and bug fixes reports to:
|
||||
|
||||
calc-bugrept-mail at asthe dot com
|
||||
|
||||
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
|
||||
|
||||
NOTE: This replaces the old calc-bugs at asthe dot com address.
|
||||
|
||||
PLEASE put following the SPECIAL PHRASE somewhere in your Email Subject line:
|
||||
|
||||
calc bug report
|
||||
|
||||
You may add additional words to your subject line.
|
||||
|
||||
Suggestion:
|
||||
|
||||
From time to time, the Email address and Subject SPECIAL PHRASE
|
||||
may change so verify you have the current info by visiting:
|
||||
|
||||
http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html
|
||||
|
||||
IMPORTANT:
|
||||
|
||||
PLEASE use the above SPECIAL PHRASE somewhere in the Subject line or
|
||||
the mail system won't deliver your Email message.
|
||||
|
||||
Keep in mind that the best way to report on a calc bug is
|
||||
via the above mentioned calc GitHub issue URL.
|
||||
|
||||
Please be patient as we cannot always respond to Email messages quickly.
|
||||
|
||||
=-=
|
||||
|
||||
When you send your report, via the calc GitHub issue URL or Email,
|
||||
please include the following information:
|
||||
Please include the following information in the new issue:
|
||||
|
||||
* A description of the problem
|
||||
|
||||
@@ -123,12 +86,13 @@ please include the following information:
|
||||
* If calc dumped core, try to send us a core dump stack trace
|
||||
|
||||
* cd to the calc source directory, and send the contents
|
||||
of debug.out produced by this command:
|
||||
of debug.out.txt produced by this command:
|
||||
|
||||
make debug > debug.out 2>&1
|
||||
make debug
|
||||
|
||||
Fell free to use the above address to send in bug fixes (in the form
|
||||
of a context diff patch).
|
||||
PLEASE attach the debug.out.txt file to your GitHub issue (bug report)!!
|
||||
|
||||
Please be patient as we cannot always respond to pull requests quickly.
|
||||
|
||||
=-=
|
||||
|
||||
@@ -192,9 +156,18 @@ mis-features in calc:
|
||||
|
||||
will not.
|
||||
|
||||
* The numerator is assumed
|
||||
|
||||
The numerator value of 1 appears to be assumed. In calc:
|
||||
|
||||
/ 2
|
||||
|
||||
will produce a value of 0.5 as if the numerator 1 was given.
|
||||
|
||||
|
||||
=-=
|
||||
|
||||
## Copyright (C) 1999-2014,2021 Landon Curt Noll
|
||||
## Copyright (C) 1999-2014,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
|
||||
|
309
CHANGES
309
CHANGES
@@ -1,4 +1,226 @@
|
||||
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.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 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.
|
||||
|
||||
@@ -6,8 +228,79 @@ The following are the changes from calc version 2.14.2.3 to date:
|
||||
build calc RPMs on a reference RHEL8.7 platform (formerly a RHEL7.9
|
||||
platform).
|
||||
|
||||
Changes #! lines in Makefiles to "#!/usr/bin/env make".
|
||||
|
||||
The following are the changes from calc version 2.14.2.0 to 2.14.1.2:
|
||||
Set SHELL in Makefiles to the basename of the shell.
|
||||
|
||||
Updated COPYING file to indicate that these files are now
|
||||
covered under "The Unlicense" (see https://unlicense.org):
|
||||
|
||||
sha1.c
|
||||
sha1.h
|
||||
cal/dotest.cal
|
||||
cal/screen.cal
|
||||
|
||||
Updated help/credit to match the above changes to COPYING.
|
||||
|
||||
Updated CONTRIB-CODE and calc.man to refer to using GitHub pull requests
|
||||
for contributing to calc (instead of using Email).
|
||||
|
||||
Updated BUGS and calc.man to refer to using GitHub issues
|
||||
for reporting calc bugs (instead of using Email).
|
||||
|
||||
Updated QUESTIONS and calc.man to refer to using GitHub issues
|
||||
for asking calc questions (instead of using Email).
|
||||
|
||||
Fixed Makefile.local command example to refer to overriding the
|
||||
Makefile variable DEBUG (instead of CDEBUG).
|
||||
|
||||
Fixed all make chk ASAN warnings under macOS 13.2.1 when calc is compiled
|
||||
with the following uncommented lines in Makefile.local:
|
||||
|
||||
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
|
||||
|
||||
Improved how pointers to functions are declared for the builtins
|
||||
array in func.c to avoid function declarations without a prototype
|
||||
that is now deprecated in C.
|
||||
|
||||
Improved how pointers to functions are declared for the opcodes
|
||||
array in opcodes.c to avoid function declarations without a prototype
|
||||
|
||||
Replaced use of egrep with grep -E in Makefiles.
|
||||
|
||||
Fixed cases where variables were set but not used in symbol.c, calc.c,
|
||||
and the main function in func.c as used by funclist.c.
|
||||
|
||||
Added rule name to "DO NOT EDIT -- generated by the Makefile" lines
|
||||
in constructed files.
|
||||
|
||||
Test if <sys/vfs.h> exists and set HAVE_SYS_VFS_H accordingly
|
||||
in have_sys_vfs.h. Added HAVE_SYS_VFS_H to allow one to force
|
||||
this value.
|
||||
|
||||
Test if <sys/param.h> exists and set HAVE_SYS_PARAM_H accordingly
|
||||
in have_sys_param.h. Added HAVE_SYS_PARAM_H to allow one to force
|
||||
this value.
|
||||
|
||||
Test if <sys/mount.h> exists and set HAVE_SYS_MOUNT_H accordingly
|
||||
in have_sys_mount.h. Added HAVE_SYS_MOUNT_H to allow one to force
|
||||
this value.
|
||||
|
||||
Test if the system as the statfs() system call and set HAVE_STATFS
|
||||
accordingly in have_statfs.h. Added HAVE_STATFS to allow one
|
||||
to force this value.
|
||||
|
||||
The pseudo_seed() function will also try to call statfs() if
|
||||
possible and permitted by the HAVE_STATFS value.
|
||||
|
||||
Test if makedepend command is available before trying to build
|
||||
the Makefile dependency list via "make depend".
|
||||
|
||||
|
||||
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
|
||||
@@ -1465,9 +1758,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:
|
||||
@@ -2061,7 +2354,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
|
||||
@@ -3784,9 +4077,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
|
||||
|
72
CONTRIB-CODE
72
CONTRIB-CODE
@@ -1,73 +1,37 @@
|
||||
Calc is open source. Contributions of code are welcome.
|
||||
|
||||
We welcome and encourage you to send us:
|
||||
In order to consider integrating your contributions, we need:
|
||||
|
||||
* calc resource files (cal/*.cal files)
|
||||
* calc shell scripts (cscript/*.calc files)
|
||||
* builtin functions that you have modified or written, i.e.:
|
||||
assocfunc.c comfunc.c func.c func.h
|
||||
listfunc.c matfunc.c qfunc.c zfunc.c
|
||||
* custom functions that you have modified or written
|
||||
* help files modified or written (help/*)
|
||||
* Makefile improvements (Makefile, */Makefile)
|
||||
* other source code modifications (*.c, *.h)
|
||||
* etc. (* */* :) )
|
||||
* your changes applied agsinst the top of the calc master branch:
|
||||
|
||||
In order to consider integrating your code, we need:
|
||||
https://github.com/lcn2/calc/
|
||||
|
||||
* calc version you are working with (please try use the latest version)
|
||||
* new help files or help file patches, if applicable (documentation)
|
||||
* proposed text for the CHANGES file (brief description of what it does)
|
||||
* regress.cal test patch as needed
|
||||
* your source code and/or source code changes (:-))
|
||||
|
||||
If you add functionality to calc, please be sure to modify/patch/add
|
||||
* Update CHANGES file (brief description of what it does)
|
||||
|
||||
* regress.cal test patch as needed
|
||||
|
||||
If you add functionality to calc, please be sure to modify
|
||||
Makefiles, help files, cal/regress.cal test code as well.
|
||||
Regression test cases are vital to maintaining calc's level
|
||||
of correctness and helps us avoid code bug regression.
|
||||
|
||||
Please try to generate a patch against the most recent
|
||||
version of calc, and if you use GitHub, the top of the
|
||||
master branch:
|
||||
|
||||
https://github.com/lcn2/calc
|
||||
|
||||
The best way contribute to calc bug is to generate calc
|
||||
GitHub pull request:
|
||||
GitHub pull request against the calc GitHub repo:
|
||||
|
||||
https://github.com/lcn2/calc/pulls
|
||||
|
||||
Please be patient as we cannot always respond pull requests quickly.
|
||||
|
||||
=-=
|
||||
|
||||
IMPORTANT:
|
||||
|
||||
Your code needs to be contributed under either the 2.1 of the GNU
|
||||
Lesser General Public License (LGPL 2.1) or in the public domain.
|
||||
Lesser General Public License (LGPL 2.1) or under "The Unlicense":
|
||||
|
||||
If you do not want to use calc GitHub, then send Email to:
|
||||
|
||||
calc-contrib-mail at asthe dot com
|
||||
|
||||
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
|
||||
|
||||
You MUST use following SPECIAL PHRASE in your Email Subject line:
|
||||
|
||||
calc contribution
|
||||
|
||||
You may add additional words to your subject line.
|
||||
|
||||
Suggestion:
|
||||
|
||||
From time to time, the Email address and Subject SPECIAL PHRASE
|
||||
may change so verify you have the current info by visiting:
|
||||
|
||||
http://www.isthe.com/chongo/tech/comp/calc/calc-contrib.html
|
||||
|
||||
IMPORTANT: If your Email doesn't contain the above phrase,
|
||||
then we WILL NOT SEE your Email.
|
||||
|
||||
PLEASE BE SURE you have that SPECIAL PHRASE somewhere in the subject line!
|
||||
|
||||
Keep in mind that the best way to report on a calc bug is to use
|
||||
the above mentioned calc GitHub procedure.
|
||||
|
||||
Please be patient as we cannot always respond to Email messages quickly.
|
||||
https://unlicense.org
|
||||
|
||||
=-=
|
||||
|
||||
@@ -77,7 +41,7 @@ See also the calc wishlist by running the calc command:
|
||||
|
||||
=-=
|
||||
|
||||
## Copyright (C) 1999,2014,2021 Landon Curt Noll
|
||||
## Copyright (C) 1999,2014,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
|
||||
|
54
COPYING
54
COPYING
@@ -1,12 +1,12 @@
|
||||
calc - arbitrary precision calculator
|
||||
|
||||
|
||||
This file is Copyrighted
|
||||
------------------------
|
||||
|
||||
This file is not covered under version 2.1 of the GNU LGPL.
|
||||
This file is covered under the following Copyright:
|
||||
|
||||
Copyright (C) 1999-2022 Landon Curt Noll
|
||||
Copyright (C) 1999-2023 Landon Curt Noll
|
||||
All rights reserved.
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
@@ -75,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
|
||||
@@ -84,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
|
||||
@@ -99,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.
|
||||
|
||||
-=-
|
||||
|
||||
@@ -121,11 +121,12 @@ Calc copyrights and exception files
|
||||
Copyright (C) year Petteri Kettunen and Landon Curt Noll
|
||||
Copyright (C) year Christoph Zurnieden
|
||||
Copyright (C) year Landon Curt Noll and Thomas Jones-Low
|
||||
Copyright (C) year Klaus Alexander Seistrup and Landon Curt Noll
|
||||
|
||||
These files are not covered under one of the Copyrights listed above:
|
||||
|
||||
sha1.c sha1.h COPYING
|
||||
COPYING-LGPL cal/qtime.cal cal/screen.cal
|
||||
COPYING-LGPL cal/screen.cal
|
||||
|
||||
The file COPYING-LGPL, which contains a copy of the version 2.1
|
||||
GNU Lesser General Public License, is itself Copyrighted by the
|
||||
@@ -137,8 +138,39 @@ Calc copyrights and exception files
|
||||
top of this file. It is important to note that you may distribute
|
||||
verbatim copies of this file but you may not modify this file.
|
||||
|
||||
Some of these exception files are in the public domain. Other files
|
||||
are under the LGPL but have different authors that those listed above.
|
||||
These files are covered under "The Unlicense":
|
||||
|
||||
sha1.c
|
||||
sha1.h
|
||||
cal/dotest.cal
|
||||
cal/screen.cal
|
||||
|
||||
"The Unlicense" is as follows:
|
||||
|
||||
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
|
||||
|
763
HOWTO.INSTALL
763
HOWTO.INSTALL
@@ -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
|
||||
- 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
|
||||
|
16
LIBRARY
16
LIBRARY
@@ -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);
|
||||
@@ -446,10 +446,10 @@ 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:
|
||||
|
||||
@@ -457,7 +457,7 @@ numbers are:
|
||||
|
||||
q1 = itoq(66L);
|
||||
q2 = iitoq(2L, 3L);
|
||||
q3 = atoq("456.78");
|
||||
q3 = str2q("456.78");
|
||||
|
||||
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
|
||||
@@ -504,8 +504,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
|
||||
|
1410
Makefile.config
Normal file
1410
Makefile.config
Normal file
File diff suppressed because it is too large
Load Diff
110
Makefile.local
110
Makefile.local
@@ -1,13 +1,44 @@
|
||||
#!/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
|
||||
#
|
||||
# You can append to an existing Makefile variable using '+=' symbols.
|
||||
# For example:
|
||||
#
|
||||
# CFLAGS+= -Ofast
|
||||
####
|
||||
|
||||
###################################################################
|
||||
# NOTE: For this and other commended out examples in this file, #
|
||||
@@ -16,24 +47,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:
|
||||
#
|
||||
# DEBUG:= -O0 -g
|
||||
# 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
|
||||
####
|
||||
|
||||
# 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 4.8.5 with libasan-4.8.5-4 you might try:
|
||||
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
|
||||
#
|
||||
# CDEBUG:= -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 12.1 with clang version 13.0.0 (clang-1300.0.29.30) you might try:
|
||||
# macOS 13.5 with clang version 14.0.3 (clang-1403.0.22.14.1)
|
||||
#
|
||||
# CDEBUG:= -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:
|
||||
#
|
||||
# DEBUG:= -O0 -g
|
||||
# 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
|
||||
####
|
||||
|
6623
Makefile.simple
6623
Makefile.simple
File diff suppressed because it is too large
Load Diff
432
Makefile.target
Normal file
432
Makefile.target
Normal 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 -=-=-=-=-=-#
|
||||
#######################################################################
|
33
QUESTIONS
33
QUESTIONS
@@ -1,37 +1,28 @@
|
||||
If you have a simple general question about calc, send Email to:
|
||||
If you have a general question about calc, consider opening
|
||||
a new Github discussion under:
|
||||
|
||||
calc-quest-mail at asthe dot com
|
||||
https://github.com/lcn2/calc/discussions
|
||||
|
||||
NOTE: Remove spaces and replace 'at' with @, and 'dot' with .
|
||||
Look over the existing discussions to see of your question fits
|
||||
under one of those exiting discussions.
|
||||
|
||||
PLEASE put following the SPECIAL PHRASE somewhere in your Email Subject line:
|
||||
You may wish to add your question as a comment to an existing discussion.
|
||||
Otherwise click on:
|
||||
|
||||
calc question
|
||||
((New discussion))
|
||||
|
||||
You may add additional words to your subject line.
|
||||
|
||||
IMPORTANT: If your Email doesn't contain the above phrase,
|
||||
then we WILL NOT SEE your Email.
|
||||
|
||||
PLEASE BE SURE you have that SPECIAL PHRASE somewhere in the subject line!
|
||||
|
||||
Suggestion:
|
||||
|
||||
From time to time, the Email address and Subject SPECIAL PHRASE
|
||||
may change so verify you have the current info by visiting:
|
||||
|
||||
http://www.isthe.com/chongo/tech/comp/calc/calc-question.html
|
||||
and ask your question in that new discussion.
|
||||
|
||||
Please limit your questions to general questions about calc. We
|
||||
cannot go into great detail in our answers, nor can we do your
|
||||
homework, nor can we do much more than answer short general questions
|
||||
homework, nor can we do much more than answer general questions
|
||||
about calc.
|
||||
|
||||
Please be patient as we cannot always respond to Email messages quickly.
|
||||
Please be patient as we cannot always respond to discussion messages quickly.
|
||||
|
||||
=-=
|
||||
|
||||
## 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
|
||||
|
@@ -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
|
||||
|
||||
|
22
README.md
22
README.md
@@ -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
|
||||
|
262
cal/Makefile
262
cal/Makefile
@@ -1,16 +1,10 @@
|
||||
#!/bin/make
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# cal - makefile for calc standard resource files
|
||||
#
|
||||
# Copyright (C) 1999-2006,2017,2021,2022 Landon Curt Noll
|
||||
# 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,183 +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= /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
|
||||
#
|
||||
SHELL= /bin/bash
|
||||
#SHELL= /bin/sh
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
ifeq ($(target),Darwin)
|
||||
SHELL:= /bin/zsh
|
||||
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
|
||||
#
|
||||
@@ -239,22 +114,6 @@ 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.
|
||||
@@ -268,19 +127,20 @@ TRUE= true
|
||||
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.cal set8700.line \
|
||||
smallfactors.cal solve.cal specialfunctions.cal splitbits.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
|
||||
|
||||
# These calc files are now obsolete and are removed by the install rule.
|
||||
#
|
||||
@@ -298,8 +158,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:
|
||||
|
120
cal/README
120
cal/README
@@ -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
|
||||
|
||||
@@ -1433,6 +1493,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)
|
||||
|
@@ -4,19 +4,37 @@
|
||||
* This file was created by Ernest Bowen <ebowen at une dot edu dot au>
|
||||
* and modified by Landon Curt Noll.
|
||||
*
|
||||
* This dotest_code has been placed in the public domain. Please do not
|
||||
* copyright this dotest_code.
|
||||
*
|
||||
* ERNEST BOWEN AND LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY 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.
|
||||
*
|
||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||
* This file is covered under "The unlicense":
|
||||
*
|
||||
* https://unlicense.org
|
||||
*
|
||||
* In particular:
|
||||
*
|
||||
* 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/>
|
||||
*
|
||||
* Under source dotest_code control: 2006/03/08 05:54:09
|
||||
* File existed as early as: 2006
|
||||
|
473
cal/fnv_tool.cal
Normal file
473
cal/fnv_tool.cal
Normal 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;
|
||||
}
|
@@ -3,19 +3,37 @@
|
||||
*
|
||||
* This file was created by Ernest Bowen <ebowen at une dot edu dot au>.
|
||||
*
|
||||
* This code has been placed in the public domain. Please do not
|
||||
* copyright this code.
|
||||
*
|
||||
* ERNEST BOWEN DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY 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.
|
||||
*
|
||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||
* This file is covered under "The unlicense":
|
||||
*
|
||||
* https://unlicense.org
|
||||
*
|
||||
* In particular:
|
||||
*
|
||||
* 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/>
|
||||
*
|
||||
* Under source code control: 2006/03/08 05:54:09
|
||||
* File existed as early as: 2006
|
||||
|
83
cal/splitbits.cal
Normal file
83
cal/splitbits.cal
Normal 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;
|
||||
}
|
37
calc.c
37
calc.c
@@ -108,8 +108,6 @@ main(int argc, char **argv)
|
||||
int c; /* option */
|
||||
int index;
|
||||
int maxindex;
|
||||
/* fix gcc warning bug */
|
||||
int unusedint = 0;
|
||||
char *cp;
|
||||
char *endcp;
|
||||
char *bp;
|
||||
@@ -166,9 +164,31 @@ main(int argc, char **argv)
|
||||
switch (c) {
|
||||
case 'C':
|
||||
#if defined(CUSTOM)
|
||||
|
||||
/*
|
||||
* error if libcustcalc was compiled with CUSTOM undefined
|
||||
*/
|
||||
if (custom_compiled() == 0) {
|
||||
fprintf(stderr, "%s: calc was built with custom functions enabled, "
|
||||
"however custom_compiled() retuned 0", program);
|
||||
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() == 1) {
|
||||
fprintf(stderr, "%s: calc was built with custom functions disabled, "
|
||||
"however custom_compiled() retuned 1", program);
|
||||
}
|
||||
|
||||
/*
|
||||
* we are too early in processing to
|
||||
* call libcalc_call_me_last() -
|
||||
@@ -289,9 +309,7 @@ main(int argc, char **argv)
|
||||
exit(6);
|
||||
}
|
||||
calc_debug = cp;
|
||||
/* fix gcc warning bug */
|
||||
unusedint =
|
||||
strtol(cp, &endcp, 10);
|
||||
(void) strtol(cp, &endcp, 10);
|
||||
cp = endcp;
|
||||
if (*cp != '\0' &&
|
||||
*cp != ' ' && *cp != ':') {
|
||||
@@ -323,9 +341,7 @@ main(int argc, char **argv)
|
||||
exit(9);
|
||||
}
|
||||
resource_debug = cp;
|
||||
/* fix gcc warning bug */
|
||||
unusedint =
|
||||
strtol(cp, &endcp, 10);
|
||||
(void) strtol(cp, &endcp, 10);
|
||||
cp = endcp;
|
||||
if (*cp != '\0' &&
|
||||
*cp != ' ' && *cp != ':') {
|
||||
@@ -355,8 +371,7 @@ main(int argc, char **argv)
|
||||
exit(12);
|
||||
}
|
||||
user_debug = cp;
|
||||
/* unusedint avoids gcc warning bug */
|
||||
unusedint = strtol(cp, &endcp, 10);
|
||||
(void) strtol(cp, &endcp, 10);
|
||||
cp = endcp;
|
||||
if (*cp != '\0' && *cp != ' ') {
|
||||
fprintf(stderr, "Bad syntax in"
|
||||
@@ -765,8 +780,6 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* All done! - Jessica Noll, Age 2
|
||||
*/
|
||||
/* fix gcc warning bug */
|
||||
unusedint++;
|
||||
libcalc_call_me_last();
|
||||
return (run_state == RUN_EXIT_WITH_ERROR ||
|
||||
run_state == RUN_ZERO) ? 1 : 0;
|
||||
|
303
calc.man
303
calc.man
@@ -1225,6 +1225,7 @@ The calc commands:
|
||||
help copyright
|
||||
help copying
|
||||
help copying-lgpl
|
||||
help credit
|
||||
.fi
|
||||
.in -0.5i
|
||||
.sp
|
||||
@@ -1259,6 +1260,10 @@ Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
Copyright (C) year Landon Curt Noll
|
||||
Copyright (C) year Ernest Bowen and Landon Curt Noll
|
||||
Copyright (C) year Ernest Bowen
|
||||
Copyright (C) year Petteri Kettunen and Landon Curt Noll
|
||||
Copyright (C) year Christoph Zurnieden
|
||||
Copyright (C) year Landon Curt Noll and Thomas Jones-Low
|
||||
Copyright (C) year Klaus Alexander Seistrup and Landon Curt Noll
|
||||
.fi
|
||||
.in -0.5i
|
||||
.sp
|
||||
@@ -1266,12 +1271,22 @@ This man page is:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
Copyright (C) 1999-2021 Landon Curt Noll
|
||||
Copyright (C) 1999-2023 Landon Curt Noll
|
||||
.fi
|
||||
.in -0.5i
|
||||
.sp
|
||||
and is covered under version 2.1 GNU Lesser General
|
||||
Public License.
|
||||
.sp
|
||||
A few files in calc are covered under "The Unlicense".
|
||||
For more information on this license, see:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
https://unlicense.org
|
||||
.fi
|
||||
.in -0.5i
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
@@ -1279,61 +1294,38 @@ Public License.
|
||||
|
||||
.PP
|
||||
|
||||
If you have a simple general question about calc, send Email to:
|
||||
.sp
|
||||
.in +0.5i
|
||||
calc-quest-mail at asthe dot com
|
||||
.sp
|
||||
NOTE: Remove spaces and replace 'at' with @, and 'dot' with .
|
||||
.in -0.5i
|
||||
.sp
|
||||
.in +0.5i
|
||||
NOTE: Yes, the Email address uses 'asthe',
|
||||
while the web site uses 'isthe'.
|
||||
.in -0.5i
|
||||
.sp
|
||||
.B PLEASE
|
||||
put following the
|
||||
.B SPECIAL PHRASE
|
||||
somewhere in your Email Subject line:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.B calc question
|
||||
.in -0.5i
|
||||
.sp
|
||||
You may add additional words to your subject line.
|
||||
.sp
|
||||
.B IMPORTANT:
|
||||
If your Email doesn't contain the above phrase,
|
||||
then we
|
||||
.B WILL NOT SEE
|
||||
your Email.
|
||||
.sp
|
||||
.B PLEASE BE SURE
|
||||
you have that
|
||||
.B SPECIAL PHRASE
|
||||
somewhere in the subject line!
|
||||
.sp
|
||||
.B Suggestion:
|
||||
.sp
|
||||
.in +0.5i
|
||||
From time to time, the Email address and Subject
|
||||
.B SPECIAL PHRASE
|
||||
may change so verify you have the current info by visiting:
|
||||
To ask the calc maintainers a general question about calc,
|
||||
see the output of the following calc command:
|
||||
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
http://www.isthe.com/chongo/tech/comp/calc/calc-question.html
|
||||
; help question
|
||||
.fi
|
||||
.in -0.5i
|
||||
.in -0.5i
|
||||
.in +0.5i
|
||||
.sp
|
||||
Please limit your questions to general questions about calc.
|
||||
We cannot go into great detail in our answers,
|
||||
nor can we do your homework, nor can
|
||||
we do much more than answer short general questions about calc.
|
||||
.PP
|
||||
|
||||
or read the source file:
|
||||
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
QUESTIONS
|
||||
.fi
|
||||
.in +0.5i
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
or visit the following URL:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
https://github.com/lcn2/calc/blob/master/QUESTIONS
|
||||
.fi
|
||||
.in +0.5i
|
||||
.sp
|
||||
Please be patient as we cannot always respond to Email messages quickly.
|
||||
|
||||
.PP
|
||||
|
||||
@@ -1341,71 +1333,37 @@ Please be patient as we cannot always respond to Email messages quickly.
|
||||
|
||||
.PP
|
||||
|
||||
Send bug reports and bug fixes to:
|
||||
To inform the calc maintainers about a bug, or to submit a bug fix,
|
||||
see the output of the following calc command:
|
||||
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
calc-bugrept at asthe dot com
|
||||
; help bugs
|
||||
.fi
|
||||
.sp
|
||||
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
|
||||
.sp
|
||||
NOTE: Yes, the Email address uses 'asthe',
|
||||
while the web site uses 'isthe'.
|
||||
.in -0.5i
|
||||
.sp
|
||||
You
|
||||
.B MUST
|
||||
use following
|
||||
.B SPECIAL PHRASE
|
||||
in your Email Subject line:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.B calc bug report
|
||||
.in -0.5i
|
||||
.sp
|
||||
You may add additional words to your subject line.
|
||||
.sp
|
||||
.B Suggestion:
|
||||
.sp
|
||||
.in +0.5i
|
||||
From time to time, the Email address and Subject
|
||||
.B SPECIAL PHRASE
|
||||
may change so verify you have the current info by visiting:
|
||||
.PP
|
||||
|
||||
or read the source file:
|
||||
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html
|
||||
BUGS
|
||||
.fi
|
||||
.in -0.5i
|
||||
.in -0.5i
|
||||
.in +0.5i
|
||||
.sp
|
||||
.B IMPORTANT:
|
||||
If your Email doesn't contain the above phrase,
|
||||
then we
|
||||
.B WILL NOT SEE
|
||||
your Email.
|
||||
.sp
|
||||
.B PLEASE BE SURE
|
||||
you have that
|
||||
.B SPECIAL PHRASE
|
||||
somewhere in the subject line!
|
||||
.sp
|
||||
See the
|
||||
.I BUGS
|
||||
source file or use the
|
||||
.I calc
|
||||
command:
|
||||
.PP
|
||||
|
||||
or visit the following URL:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
help bugs
|
||||
https://github.com/lcn2/calc/blob/master/BUGS
|
||||
.fi
|
||||
.in -0.5i
|
||||
.in +0.5i
|
||||
.sp
|
||||
for more information about bug reporting.
|
||||
.sp
|
||||
Please be patient as we cannot always respond to Email messages quickly.
|
||||
|
||||
.PP
|
||||
|
||||
@@ -1415,126 +1373,40 @@ Please be patient as we cannot always respond to Email messages quickly.
|
||||
|
||||
.I Calc
|
||||
is open source.
|
||||
Contributions of code are welcome.
|
||||
.sp
|
||||
We welcome and encourage you to send us:
|
||||
You are welcome to contribute code to calc, or submit bug fixes to to calc.
|
||||
.sp
|
||||
To contribute code to calc, please see see the output of
|
||||
the following calc command:
|
||||
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
* calc resource files (cal/*.cal)
|
||||
* calc shell scripts (cscript/*.calc)
|
||||
* builtin functions that you have modified or written, i.e.:
|
||||
assocfunc.c comfunc.c func.c func.h
|
||||
listfunc.c matfunc.c qfunc.c zfunc.c
|
||||
* custom functions that you have modified or written (custom/*)
|
||||
* help files modified or written (help/*)
|
||||
* brief description of you added, fixed, improved in CHANGES
|
||||
* regression test cases (cal/regress.cal)
|
||||
* Makefile improvements (Makefile, */Makefile)
|
||||
* other source code modifications (*.c, *.h)
|
||||
* etc. (* */* :) )
|
||||
; help contrib
|
||||
.fi
|
||||
.in -0.5i
|
||||
.sp
|
||||
If you add functionality to calc, please be sure to modify/patch/add
|
||||
Makefiles, help files, cal/regress.cal test code as well.
|
||||
Regression test cases are vital to maintaining calc's level
|
||||
of correctness and helps us avoid code bug regression.
|
||||
.sp
|
||||
In order to consider integrating your code, we need:
|
||||
.sp
|
||||
.nf
|
||||
.in +0.5i
|
||||
* calc version you are working with (please try use the latest version)
|
||||
* new help files or help file patches, if applicable (documentation)
|
||||
* proposed text for the CHANGES file (brief description of what it does)
|
||||
* regress.cal test patch as needed
|
||||
* your source code and/or source code changes (:-))
|
||||
.in -0.5i
|
||||
.fi
|
||||
.sp
|
||||
The best way to send us new code, if your changes are small, is
|
||||
via a patch (diff -c from the latest alpha code to your code).
|
||||
If your change is large, you should send entire files (either
|
||||
as a diff -c /dev/null your-file patch, or as a uuencoded and
|
||||
gziped (or compressed) tar file).
|
||||
.sp
|
||||
Please try to generate a patch against the most recent
|
||||
version of calc, and if you use GitHub, the top of the
|
||||
master branch:
|
||||
.sp
|
||||
.nf
|
||||
.in +0.5i
|
||||
https://github.com/lcn2/calc
|
||||
.in -0.5i
|
||||
.fi
|
||||
.sp
|
||||
.sp
|
||||
The best way contribute to calc bug is to generate calc
|
||||
GitHub pull request:
|
||||
.sp
|
||||
.nf
|
||||
.in +0.5i
|
||||
https://github.com/lcn2/calc/pulls
|
||||
.in -0.5i
|
||||
.fi
|
||||
.sp
|
||||
Your code needs to be contributed under either the 2.1 of the
|
||||
.B GNU Lesser General Public License (LGPL 2.1)
|
||||
or be in the public domain.
|
||||
.sp
|
||||
If you do not want to use calc GitHub, then send Email to:
|
||||
|
||||
.PP
|
||||
|
||||
or read the source file:
|
||||
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
calc-contrib at asthe dot com
|
||||
CONTRIB-CODE
|
||||
.fi
|
||||
.sp
|
||||
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
|
||||
.sp
|
||||
NOTE: Yes, the Email address uses 'asthe',
|
||||
while the web site uses 'isthe'.
|
||||
.in -0.5i
|
||||
.sp
|
||||
You
|
||||
.B MUST
|
||||
use following
|
||||
.B SPECIAL PHRASE
|
||||
in your Email Subject line:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.B calc contribution
|
||||
.in -0.5i
|
||||
.sp
|
||||
You may add additional words to your subject line.
|
||||
.sp
|
||||
.B Suggestion:
|
||||
.sp
|
||||
.in +0.5i
|
||||
From time to time, the Email address and Subject
|
||||
.B SPECIAL PHRASE
|
||||
may change so verify you have the current info by visiting:
|
||||
|
||||
.PP
|
||||
|
||||
or visit the following URL:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
http://www.isthe.com/chongo/tech/comp/calc/calc-contrib.html
|
||||
https://github.com/lcn2/calc/blob/master/CONTRIB-CODE
|
||||
.fi
|
||||
.in -0.5i
|
||||
.in -0.5i
|
||||
.in +0.5i
|
||||
.sp
|
||||
.B IMPORTANT:
|
||||
If your Email doesn't contain the above phrase,
|
||||
then we
|
||||
.B WILL NOT SEE
|
||||
your Email.
|
||||
.sp
|
||||
.B PLEASE BE SURE
|
||||
you have that
|
||||
.B SPECIAL PHRASE
|
||||
somewhere in the subject line!
|
||||
.sp
|
||||
Please be patient as we cannot always respond to Email messages quickly.
|
||||
|
||||
.PP
|
||||
|
||||
@@ -1549,5 +1421,30 @@ web site is located at:
|
||||
.in +0.5i
|
||||
www.isthe.com/chongo/tech/comp/calc/
|
||||
.in -0.5i
|
||||
|
||||
.SH "CALC SOURCE CODE"
|
||||
|
||||
The latest version of calc source code may be obtained at
|
||||
the following GitHub repo:
|
||||
.sp
|
||||
Share and Enjoy! :\-)
|
||||
.in +0.5i
|
||||
https://github.com/lcn2/calc
|
||||
.in -0.5i
|
||||
.sp
|
||||
The very latest calc souece is found at the top master branch.
|
||||
|
||||
.PP
|
||||
|
||||
You may download the calc releases from:
|
||||
.sp
|
||||
.in +0.5i
|
||||
https://github.com/lcn2/calc/releases
|
||||
.in -0.5i
|
||||
.sp
|
||||
The releases marked
|
||||
.B ((Pre-release))
|
||||
are beta releases.
|
||||
.sp
|
||||
The most recent release that is NOT marked
|
||||
.B ((Pre-release))
|
||||
is the recommended stable release.
|
||||
|
35
calc.spec.in
35
calc.spec.in
@@ -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
|
||||
|
240
cscript/Makefile
240
cscript/Makefile
@@ -1,15 +1,10 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# cscript - makefile for calc shell script files
|
||||
#
|
||||
# Copyright (C) 1999-2006,2014,2017,2021,2022 Landon Curt Noll
|
||||
# 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
|
||||
@@ -28,183 +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= /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
|
||||
#
|
||||
SHELL= /bin/bash
|
||||
#SHELL= /bin/sh
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
ifeq ($(target),Darwin)
|
||||
SHELL:= /bin/zsh
|
||||
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
|
||||
#
|
||||
@@ -238,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.
|
||||
#
|
||||
@@ -302,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
|
||||
|
18
custom.c
18
custom.c
@@ -41,6 +41,8 @@
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
EXTERN CONST struct custom cust[]; /* custom interface table */
|
||||
|
||||
#else /* CUSTOM */
|
||||
|
||||
#include "config.h"
|
||||
@@ -66,6 +68,14 @@ custom(char *name, int count, VALUE **vals)
|
||||
|
||||
CONST struct custom *p; /* current function */
|
||||
|
||||
/*
|
||||
* error if libcustcalc was compiled with CUSTOM undefined
|
||||
*/
|
||||
if (custom_compiled() == 0) {
|
||||
math_error("libcustcalc was compiled CUSTOM undefined");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* search the custom interface table for a function
|
||||
*/
|
||||
@@ -98,6 +108,14 @@ custom(char *name, int count, VALUE **vals)
|
||||
|
||||
#else /* CUSTOM */
|
||||
|
||||
/*
|
||||
* error if libcustcalc was compiled with CUSTOM defined
|
||||
*/
|
||||
if (custom_compiled() == 1) {
|
||||
math_error("libcustcalc was compiled with CUSTOM defined");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"%sCalc was built with custom functions disabled\n",
|
||||
(conf->tab_ok ? "\t" : ""));
|
||||
|
6
custom.h
6
custom.h
@@ -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 int custom_compiled(void); /* return 1 ==> libcustcalc compiled w/CUSTOM defined, else return 0 */
|
||||
E_FUNC VALUE custom(char*, int, VALUE**); /* master custom interface */
|
||||
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 */
|
||||
|
@@ -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
|
||||
|
@@ -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:
|
||||
|
||||
|
627
custom/Makefile
627
custom/Makefile
@@ -1,16 +1,10 @@
|
||||
#!/bin/make
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# custom - makefile for calc custom routines
|
||||
#
|
||||
# Copyright (C) 1999-2006,2014,2017-2018,2021 Landon Curt Noll
|
||||
# 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,130 +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= /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 zsh may be a much better alternative
|
||||
# shell for this Makefile to use:
|
||||
#
|
||||
# SHELL= /bin/zsh
|
||||
#
|
||||
SHELL= /bin/bash
|
||||
#SHELL= /bin/sh
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
ifeq ($(target),Darwin)
|
||||
SHELL:= /bin/zsh
|
||||
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
|
||||
#
|
||||
@@ -197,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
|
||||
#
|
||||
@@ -240,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.3
|
||||
|
||||
# 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= egrep
|
||||
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}.
|
||||
#
|
||||
@@ -620,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
|
||||
#
|
||||
@@ -636,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}
|
||||
@@ -666,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:
|
||||
@@ -720,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.
|
||||
|
||||
##
|
||||
#
|
||||
@@ -801,11 +322,17 @@ Makefile.simple: Makefile ../Makefile
|
||||
|
||||
depend:
|
||||
${Q} if [ -f ${MAKE_FILE}.bak ]; then \
|
||||
echo "custom/${MAKE_FILE}.bak exists, remove or move it"; \
|
||||
echo "custom/${MAKE_FILE}.bak exists, remove or move it" 1>&2; \
|
||||
exit 1; \
|
||||
else \
|
||||
${TRUE}; \
|
||||
fi
|
||||
${Q} if type -f ${MAKEDEPEND}; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
echo "make depend failed: cannot find makedepend command: ${MAKEDEPEND}" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
${Q} echo forming custom/skel
|
||||
${Q} ${RM} -rf skel
|
||||
${Q} ${MKDIR} -p skel
|
||||
@@ -826,7 +353,7 @@ depend:
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/custom/$$i"; \
|
||||
done
|
||||
${Q} (cd ..; ${MAKE} -f ${MAKE_FILE} hsrc)
|
||||
${MAKE} -f ../${MAKE_FILE} h_list 2>/dev/null | \
|
||||
(cd ..; ${MAKE} -f ${MAKE_FILE} h_list 2>/dev/null) | \
|
||||
while read i; do \
|
||||
if [ ! -f "../$$i" ]; then continue; fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
@@ -840,13 +367,13 @@ depend:
|
||||
${Q} echo custom/skel formed
|
||||
${Q} echo forming custom dependency list
|
||||
${Q} :> skel/custom/makedep.out
|
||||
${Q} cd skel/custom; ${MAKEDEPEND} \
|
||||
-${Q} cd skel/custom; ${MAKEDEPEND} \
|
||||
-I../../.. -w 1 -f makedep.out -- \
|
||||
${CFLAGS} -- \
|
||||
${C_SRC} 2>/dev/null
|
||||
${Q} ${CP} -f skel/custom/makedep.out skel/custom/makedep.in
|
||||
${Q} ${SED} -e 's|: ../../|: |' -E < skel/custom/makedep.in | \
|
||||
${GREP} -v /usr/include > skel/custom/makedep.out
|
||||
${GREP} -E -v /usr/include > skel/custom/makedep.out
|
||||
-${Q} for i in ${C_SRC} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo "$$i" | ${SED} 's/^\(.*\)\.c/\1.o: \1.c/'; \
|
||||
@@ -860,7 +387,7 @@ depend:
|
||||
${Q} ${MV} ${MAKE_FILE} ${MAKE_FILE}.bak
|
||||
${Q} ${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' \
|
||||
${MAKE_FILE}.bak > ${MAKE_FILE}
|
||||
${Q} ${GREP} -v '^#' skel/custom/makedep.out >> ${MAKE_FILE}
|
||||
${Q} ${GREP} -E -v '^#' skel/custom/makedep.out >> ${MAKE_FILE}
|
||||
${Q} echo removing skel
|
||||
${Q} ${RM} -rf skel
|
||||
-${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \
|
||||
@@ -1072,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}; \
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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 */
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -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 */
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -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 "../attribute.h"
|
||||
#include "../banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -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 "../attribute.h"
|
||||
#include "../banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/* 2^255 */
|
||||
|
@@ -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 "../attribute.h"
|
||||
#include "../banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -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 "../attribute.h"
|
||||
#include "../banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -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,51 @@
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* 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 "../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 "have_unused.h"
|
||||
#include "../have_unused.h"
|
||||
|
||||
|
||||
#include "attribute.h"
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
#include "../attribute.h"
|
||||
#include "../banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -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,37 @@
|
||||
* 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 "../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* 1 ==> libcustcalc was compiled with CUSTOM defined
|
||||
* 0 ==> libcustcalc was compiled with CUSTOM undefined
|
||||
*/
|
||||
E_FUNC int
|
||||
custom_compiled(void)
|
||||
{
|
||||
#if defined(CUSTOM)
|
||||
return 1;
|
||||
#else /* CUSTOM */
|
||||
return 0;
|
||||
#endif /* CUSTOM */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NOTE: See the file HOW_TO_ADD for instructions on how to add custom functions.
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -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 */
|
||||
|
82
have_statfs.c
Normal file
82
have_statfs.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* have_statfs - Determine if we have statfs()
|
||||
*
|
||||
* 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/03/06 00:51:53
|
||||
* 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/
|
||||
*/
|
||||
|
||||
/*
|
||||
* usage:
|
||||
* have_statfs
|
||||
*
|
||||
* Not all systems have the statfs() function, so this may not
|
||||
* compile on your system.
|
||||
*
|
||||
* This prog outputs several defines:
|
||||
*
|
||||
* HAVE_STATFS
|
||||
* defined ==> use statfs()
|
||||
* undefined ==> do not call or cannot call statfs()
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "have_sys_vfs.h"
|
||||
#if defined(HAVE_SYS_VFS_H)
|
||||
# include <sys/vfs.h>
|
||||
#endif /* HAVE_SYS_VFS_H */
|
||||
|
||||
#include "have_sys_param.h"
|
||||
#if defined(HAVE_SYS_PARAM_H)
|
||||
# include <sys/param.h>
|
||||
#endif /* HAVE_SYS_PARAM_H */
|
||||
|
||||
#include "have_sys_mount.h"
|
||||
#if defined(HAVE_SYS_MOUNT_H)
|
||||
# include <sys/mount.h>
|
||||
#endif /* HAVE_SYS_MOUNT_H */
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#if defined(HAVE_NO_STATFS)
|
||||
|
||||
printf("#undef HAVE_STATFS /* no */\n");
|
||||
|
||||
#else /* HAVE_NO_STATFS */
|
||||
|
||||
struct statfs statfs_dot; /* usage stat of "." */
|
||||
|
||||
(void) statfs(".", &statfs_dot);
|
||||
|
||||
printf("#define HAVE_STATFS /* yes */\n");
|
||||
|
||||
#endif /* HAVE_NO_STATFS */
|
||||
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
256
help/Makefile
256
help/Makefile
@@ -1,16 +1,10 @@
|
||||
#!/bin/make
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# help - makefile for calc help files
|
||||
#
|
||||
# Copyright (C) 1999-2006,2017,2021,2022 Landon Curt Noll
|
||||
# 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,183 +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= /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
|
||||
#
|
||||
SHELL= /bin/bash
|
||||
#SHELL= /bin/sh
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
ifeq ($(target),Darwin)
|
||||
SHELL:= /bin/zsh
|
||||
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
|
||||
#
|
||||
@@ -239,41 +113,11 @@ H=@
|
||||
V=@:
|
||||
#V=@
|
||||
|
||||
# standard tools
|
||||
#
|
||||
CAT= cat
|
||||
CHMOD= chmod
|
||||
CMP= cmp
|
||||
CP= cp
|
||||
FMT= fmt
|
||||
GREP= egrep
|
||||
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
|
||||
|
||||
@@ -413,9 +257,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
|
||||
@@ -716,7 +576,7 @@ builtin: builtin.top builtin.end ../func.c funclist.sed
|
||||
-I.. funclist.c -c ${S}
|
||||
${Q} ${LCC} ${ILDFLAGS} funclist.o -o funclist${EXT} ${S}
|
||||
${Q} ${RM} -f builtin
|
||||
${Q} ${GREP} -v '^#' builtin.top > builtin
|
||||
${Q} ${GREP} -E -v '^#' builtin.top > builtin
|
||||
${Q} ./funclist${EXT} | \
|
||||
${SED} -e 's/^/ /' -e 's/[ ][ ]*$$//' >> builtin
|
||||
${Q} ${CAT} builtin.end >> builtin
|
||||
|
@@ -832,7 +832,7 @@ DESCRIPTION
|
||||
Returns TRUE if you calc was compiled with -DCUSTOM. By default,
|
||||
the calc Makefile uses ALLOW_CUSTOM= -DCUSTOM so by default
|
||||
config("compile_custom") is TRUE. If, however, calc is compiled
|
||||
without -DCUSTOM, then config("compile_custom") will be FALSE.
|
||||
with ALLOW_CUSTOM="-UCUSTOM", then config("compile_custom") will be FALSE.
|
||||
|
||||
The config("compile_custom") value is only affected by compile
|
||||
flags. The calc -D runtime command line option does not change
|
||||
@@ -1042,7 +1042,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
custom, custom_cal, display, epsilon, fprintf, printf, strprintf, usage
|
||||
|
||||
## Copyright (C) 1999-2007,2018,2021 Landon Curt Noll
|
||||
## Copyright (C) 1999-2007,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
|
||||
|
31
help/credit
31
help/credit
@@ -26,13 +26,22 @@ Credits
|
||||
|
||||
Most of this source and binary has one of the following copyrights:
|
||||
|
||||
Copyright (C) year David I. Bell
|
||||
Copyright (C) year David I. Bell and Landon Curt Noll
|
||||
Copyright (C) year David I. Bell and Ernest Bowen
|
||||
Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
Copyright (C) year Landon Curt Noll
|
||||
Copyright (C) year Ernest Bowen and Landon Curt Noll
|
||||
Copyright (C) year Ernest Bowen
|
||||
Copyright (C) year David I. Bell
|
||||
Copyright (C) year David I. Bell and Landon Curt Noll
|
||||
Copyright (C) year David I. Bell and Ernest Bowen
|
||||
Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
Copyright (C) year Landon Curt Noll
|
||||
Copyright (C) year Ernest Bowen and Landon Curt Noll
|
||||
Copyright (C) year Ernest Bowen
|
||||
Copyright (C) year Petteri Kettunen and Landon Curt Noll
|
||||
Copyright (C) year Christoph Zurnieden
|
||||
Copyright (C) year Landon Curt Noll and Thomas Jones-Low
|
||||
Copyright (C) year Klaus Alexander Seistrup and Landon Curt Noll
|
||||
|
||||
A few files in calc are covered under "The Unlicense". For more
|
||||
information on this license, see:
|
||||
|
||||
https://unlicense.org
|
||||
|
||||
|
||||
Copying / Calc GNU Lesser General Public License
|
||||
@@ -61,11 +70,11 @@ Copying / Calc GNU Lesser General Public License
|
||||
|
||||
See also:
|
||||
|
||||
help copyright
|
||||
help copying
|
||||
help copying-lgpl
|
||||
help copyright
|
||||
help copying
|
||||
help copying-lgpl
|
||||
|
||||
## 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
|
||||
|
@@ -68,7 +68,8 @@ DESCRIPTION
|
||||
help contrib
|
||||
|
||||
EXAMPLE
|
||||
If calc compiled with ALLOW_CUSTOM= (custom disabled):
|
||||
If calc compiled with ALLOW_CUSTOM="-UCUSTOM", the custom system
|
||||
is disabled, even when -C is used on the command line:
|
||||
|
||||
; print custom("sysinfo", "baseb")
|
||||
Calc was built with custom functions disabled
|
||||
@@ -94,7 +95,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
custom_cal, new_custom, contrib
|
||||
|
||||
## 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
|
||||
|
@@ -2,11 +2,11 @@ s/VALUE/int/
|
||||
s/NUMBER[ ]*\*/int /
|
||||
s/NUMBER/int/
|
||||
s/STRINGHEAD/int/
|
||||
s/\(".*",.*,.*\),.*,.*,.*,.*,/\1, 0, 0, 0, 0,/
|
||||
s/\(".*",.*,.*\),.*,.*,.*,.*,/\1, 0, 0, {.null = NULL}, {.null = NULL},/
|
||||
s/[ ][ ]*$//
|
||||
p
|
||||
|
||||
## 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
|
||||
|
@@ -101,11 +101,11 @@ Low priority items:
|
||||
|
||||
Calc bug reports and calc bug fixes should be sent to:
|
||||
|
||||
calc-bug-report at asthe dot com
|
||||
NOTE: calc-bug-report Email address no longer in use
|
||||
|
||||
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
|
||||
|
||||
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:
|
||||
|
@@ -556,8 +556,14 @@ Unexpected
|
||||
; print sin(d2r(30))
|
||||
0.5
|
||||
|
||||
* operator has has a higher precedence than <<
|
||||
==============================================
|
||||
|
||||
## Copyright (C) 1999-2007,2014,2017,2021 Landon Curt Noll
|
||||
The * operator has has a higher precedence than <<, which differs from the C language.
|
||||
So 3 << 2*5 evaluates to 3072 in C, whereas 3 << 2*5 evaluates to 60 in calc.
|
||||
|
||||
|
||||
## Copyright (C) 1999-2007,2014,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
|
||||
|
@@ -187,11 +187,11 @@ Please read CONTRIB-CODE or run the following calc command:
|
||||
|
||||
Calc bug reports and calc bug fixes should be sent to:
|
||||
|
||||
calc-bug-report at asthe dot com
|
||||
NOTE: calc-bug-report Email address no longer in use
|
||||
|
||||
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
|
||||
|
||||
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:
|
||||
|
165
hist.c
165
hist.c
@@ -98,7 +98,7 @@ STATIC struct {
|
||||
} HS;
|
||||
|
||||
|
||||
typedef void (*FUNCPTR)();
|
||||
typedef void (*FUNCPTR)(int);
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
@@ -106,38 +106,38 @@ typedef struct {
|
||||
} FUNC;
|
||||
|
||||
/* declare binding functions */
|
||||
S_FUNC void flush_input(void);
|
||||
S_FUNC void start_of_line(void);
|
||||
S_FUNC void end_of_line(void);
|
||||
S_FUNC void forward_char(void);
|
||||
S_FUNC void backward_char(void);
|
||||
S_FUNC void forward_word(void);
|
||||
S_FUNC void backward_word(void);
|
||||
S_FUNC void delete_char(void);
|
||||
S_FUNC void forward_kill_char(void);
|
||||
S_FUNC void backward_kill_char(void);
|
||||
S_FUNC void forward_kill_word(void);
|
||||
S_FUNC void kill_line(void);
|
||||
S_FUNC void new_line(void);
|
||||
S_FUNC void save_line(void);
|
||||
S_FUNC void forward_history(void);
|
||||
S_FUNC void backward_history(void);
|
||||
S_FUNC void flush_input(int key);
|
||||
S_FUNC void start_of_line(int key);
|
||||
S_FUNC void end_of_line(int key);
|
||||
S_FUNC void forward_char(int key);
|
||||
S_FUNC void backward_char(int key);
|
||||
S_FUNC void forward_word(int key);
|
||||
S_FUNC void backward_word(int key);
|
||||
S_FUNC void delete_char(int key);
|
||||
S_FUNC void forward_kill_char(int key);
|
||||
S_FUNC void backward_kill_char(int key);
|
||||
S_FUNC void forward_kill_word(int key);
|
||||
S_FUNC void kill_line(int key);
|
||||
S_FUNC void new_line(int key);
|
||||
S_FUNC void save_line(int key);
|
||||
S_FUNC void forward_history(int key);
|
||||
S_FUNC void backward_history(int key);
|
||||
S_FUNC void insert_char(int key);
|
||||
S_FUNC void goto_line(void);
|
||||
S_FUNC void list_history(void);
|
||||
S_FUNC void refresh_line(void);
|
||||
S_FUNC void swap_chars(void);
|
||||
S_FUNC void set_mark(void);
|
||||
S_FUNC void yank(void);
|
||||
S_FUNC void save_region(void);
|
||||
S_FUNC void kill_region(void);
|
||||
S_FUNC void reverse_search(void);
|
||||
S_FUNC void quote_char(void);
|
||||
S_FUNC void uppercase_word(void);
|
||||
S_FUNC void lowercase_word(void);
|
||||
S_FUNC void ignore_char(void);
|
||||
S_FUNC void arrow_key(void);
|
||||
S_FUNC void quit_calc(void) __attribute__((noreturn));
|
||||
S_FUNC void goto_line(int key);
|
||||
S_FUNC void list_history(int key);
|
||||
S_FUNC void refresh_line(int key);
|
||||
S_FUNC void swap_chars(int key);
|
||||
S_FUNC void set_mark(int key);
|
||||
S_FUNC void yank(int key);
|
||||
S_FUNC void save_region(int key);
|
||||
S_FUNC void kill_region(int key);
|
||||
S_FUNC void reverse_search(int key);
|
||||
S_FUNC void quote_char(int key);
|
||||
S_FUNC void uppercase_word(int key);
|
||||
S_FUNC void lowercase_word(int key);
|
||||
S_FUNC void ignore_char(int key);
|
||||
S_FUNC void arrow_key(int key);
|
||||
S_FUNC void quit_calc(int key) __attribute__((noreturn));
|
||||
|
||||
|
||||
STATIC FUNC funcs[] =
|
||||
@@ -217,8 +217,8 @@ STATIC int save_len;
|
||||
STATIC KEY_MAP *cur_map;
|
||||
STATIC KEY_MAP *base_map;
|
||||
STATIC KEY_ENT key_table[MAX_KEYS];
|
||||
STATIC HIST* hist_first = NULL;
|
||||
STATIC HIST* hist_last = NULL;
|
||||
STATIC HIST* hist_first = NULL;
|
||||
STATIC HIST* hist_last = NULL;
|
||||
STATIC char save_buffer[SAVE_SIZE];
|
||||
|
||||
/* declare other static functions */
|
||||
@@ -650,12 +650,11 @@ read_key(void)
|
||||
ent = &cur_map->default_ent;
|
||||
if (ent->next)
|
||||
cur_map = ent->next;
|
||||
if (ent->func)
|
||||
/* ignore Saber-C warning #65 - has 1 arg, expecting 0 */
|
||||
/* OK to ignore in proc read_key */
|
||||
if (ent->func != NULL) {
|
||||
(*ent->func)(key);
|
||||
else
|
||||
} else {
|
||||
insert_char(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -797,20 +796,20 @@ find_func(char *name)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
arrow_key(void)
|
||||
arrow_key(int UNUSED(key))
|
||||
{
|
||||
switch (fgetc(stdin)) {
|
||||
case 'A':
|
||||
backward_history();
|
||||
backward_history(0);
|
||||
break;
|
||||
case 'B':
|
||||
forward_history();
|
||||
forward_history(0);
|
||||
break;
|
||||
case 'C':
|
||||
forward_char();
|
||||
forward_char(0);
|
||||
break;
|
||||
case 'D':
|
||||
backward_char();
|
||||
backward_char(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -867,13 +866,13 @@ decrement_end(int n)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
ignore_char(void)
|
||||
ignore_char(int UNUSED(key))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
S_FUNC void
|
||||
flush_input(void)
|
||||
flush_input(int UNUSED(key))
|
||||
{
|
||||
echo_rest_of_line();
|
||||
while (HS.end > HS.buf)
|
||||
@@ -884,21 +883,21 @@ flush_input(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
start_of_line(void)
|
||||
start_of_line(int UNUSED(key))
|
||||
{
|
||||
goto_start_of_line();
|
||||
}
|
||||
|
||||
|
||||
S_FUNC void
|
||||
end_of_line(void)
|
||||
end_of_line(int UNUSED(key))
|
||||
{
|
||||
goto_end_of_line();
|
||||
}
|
||||
|
||||
|
||||
S_FUNC void
|
||||
forward_char(void)
|
||||
forward_char(int UNUSED(key))
|
||||
{
|
||||
if (HS.pos < HS.end)
|
||||
echo_char(*HS.pos++);
|
||||
@@ -906,7 +905,7 @@ forward_char(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
backward_char(void)
|
||||
backward_char(int UNUSED(key))
|
||||
{
|
||||
if (HS.pos > HS.buf)
|
||||
back_over_char((int)(*--HS.pos));
|
||||
@@ -914,7 +913,7 @@ backward_char(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
uppercase_word(void)
|
||||
uppercase_word(int UNUSED(key))
|
||||
{
|
||||
while ((HS.pos < HS.end) && !in_word((int)(*HS.pos)))
|
||||
echo_char(*HS.pos++);
|
||||
@@ -927,7 +926,7 @@ uppercase_word(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
lowercase_word(void)
|
||||
lowercase_word(int UNUSED(key))
|
||||
{
|
||||
while ((HS.pos < HS.end) && !in_word((int)(*HS.pos)))
|
||||
echo_char(*HS.pos++);
|
||||
@@ -940,7 +939,7 @@ lowercase_word(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
forward_word(void)
|
||||
forward_word(int UNUSED(key))
|
||||
{
|
||||
while ((HS.pos < HS.end) && !in_word((int)(*HS.pos)))
|
||||
echo_char(*HS.pos++);
|
||||
@@ -950,7 +949,7 @@ forward_word(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
backward_word(void)
|
||||
backward_word(int UNUSED(key))
|
||||
{
|
||||
if ((HS.pos > HS.buf) && in_word((int)(*HS.pos)))
|
||||
back_over_char((int)(*--HS.pos));
|
||||
@@ -964,7 +963,7 @@ backward_word(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
forward_kill_char(void)
|
||||
forward_kill_char(int UNUSED(key))
|
||||
{
|
||||
int rest;
|
||||
char ch;
|
||||
@@ -986,7 +985,7 @@ forward_kill_char(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
delete_char(void)
|
||||
delete_char(int UNUSED(key))
|
||||
{
|
||||
/*
|
||||
* quit delete_char (usually ^D) is at start of line and we are allowed
|
||||
@@ -997,30 +996,30 @@ delete_char(void)
|
||||
if ((HS.end == HS.buf) &&
|
||||
(conf->ctrl_d == CTRL_D_EMPTY_EOF ||
|
||||
(conf->ctrl_d == CTRL_D_VIRGIN_EOF && HS.virgin_line == TRUE))) {
|
||||
quit_calc();
|
||||
quit_calc(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* normal case: just forward_kill_char
|
||||
*/
|
||||
if (HS.end > HS.buf)
|
||||
forward_kill_char();
|
||||
forward_kill_char(0);
|
||||
}
|
||||
|
||||
|
||||
S_FUNC void
|
||||
backward_kill_char(void)
|
||||
backward_kill_char(int UNUSED(key))
|
||||
{
|
||||
if (HS.pos > HS.buf) {
|
||||
HS.pos--;
|
||||
back_over_char((int)(*HS.pos));
|
||||
forward_kill_char();
|
||||
forward_kill_char(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
S_FUNC void
|
||||
forward_kill_word(void)
|
||||
forward_kill_word(int UNUSED(key))
|
||||
{
|
||||
char *cp;
|
||||
|
||||
@@ -1044,7 +1043,7 @@ forward_kill_word(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
kill_line(void)
|
||||
kill_line(int UNUSED(key))
|
||||
{
|
||||
if (HS.end <= HS.pos)
|
||||
return;
|
||||
@@ -1063,7 +1062,7 @@ kill_line(void)
|
||||
* decide whether or not this should be done.
|
||||
*/
|
||||
S_FUNC void
|
||||
new_line(void)
|
||||
new_line(int UNUSED(key))
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -1087,21 +1086,21 @@ new_line(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
save_line(void)
|
||||
save_line(int UNUSED(key))
|
||||
{
|
||||
int len;
|
||||
|
||||
len = HS.end - HS.buf;
|
||||
if (len > 0) {
|
||||
hist_saveline(HS.buf, len);
|
||||
flush_input();
|
||||
flush_input(0);
|
||||
}
|
||||
HS.curhist = HS.histcount;
|
||||
}
|
||||
|
||||
|
||||
S_FUNC void
|
||||
goto_line(void)
|
||||
goto_line(int UNUSED(key))
|
||||
{
|
||||
int num;
|
||||
char *cp;
|
||||
@@ -1115,7 +1114,7 @@ goto_line(void)
|
||||
beep();
|
||||
return;
|
||||
}
|
||||
flush_input();
|
||||
flush_input(0);
|
||||
HS.curhist = HS.histcount - num;
|
||||
hp = get_event(HS.curhist);
|
||||
memcpy(HS.buf, hp->data, hp->len);
|
||||
@@ -1125,11 +1124,11 @@ goto_line(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
forward_history(void)
|
||||
forward_history(int UNUSED(key))
|
||||
{
|
||||
HIST *hp;
|
||||
|
||||
flush_input();
|
||||
flush_input(0);
|
||||
if (++HS.curhist >= HS.histcount)
|
||||
HS.curhist = 0;
|
||||
hp = get_event(HS.curhist);
|
||||
@@ -1142,11 +1141,11 @@ forward_history(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
backward_history(void)
|
||||
backward_history(int UNUSED(key))
|
||||
{
|
||||
HIST *hp;
|
||||
|
||||
flush_input();
|
||||
flush_input(0);
|
||||
if (--HS.curhist < 0)
|
||||
HS.curhist = HS.histcount - 1;
|
||||
hp = get_event(HS.curhist);
|
||||
@@ -1208,7 +1207,7 @@ insert_string(char *str, int len)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
list_history(void)
|
||||
list_history(int UNUSED(key))
|
||||
{
|
||||
HIST *hp;
|
||||
int hnum;
|
||||
@@ -1218,12 +1217,12 @@ list_history(void)
|
||||
printf("\n%3d: ", HS.histcount - hnum);
|
||||
echo_string(hp->data, hp->len);
|
||||
}
|
||||
refresh_line();
|
||||
refresh_line(0);
|
||||
}
|
||||
|
||||
|
||||
S_FUNC void
|
||||
refresh_line(void)
|
||||
refresh_line(int UNUSED(key))
|
||||
{
|
||||
char *cp;
|
||||
|
||||
@@ -1239,7 +1238,7 @@ refresh_line(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
swap_chars(void)
|
||||
swap_chars(int UNUSED(key))
|
||||
{
|
||||
char ch1;
|
||||
char ch2;
|
||||
@@ -1258,14 +1257,14 @@ swap_chars(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
set_mark(void)
|
||||
set_mark(int UNUSED(key))
|
||||
{
|
||||
HS.mark = HS.pos;
|
||||
}
|
||||
|
||||
|
||||
S_FUNC void
|
||||
save_region(void)
|
||||
save_region(int UNUSED(key))
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -1280,7 +1279,7 @@ save_region(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
kill_region(void)
|
||||
kill_region(int UNUSED(key))
|
||||
{
|
||||
char *cp;
|
||||
char *left;
|
||||
@@ -1312,14 +1311,14 @@ kill_region(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
yank(void)
|
||||
yank(int UNUSED(key))
|
||||
{
|
||||
insert_string(save_buffer, save_len);
|
||||
}
|
||||
|
||||
|
||||
S_FUNC void
|
||||
reverse_search(void)
|
||||
reverse_search(int UNUSED(key))
|
||||
{
|
||||
int len;
|
||||
int count;
|
||||
@@ -1345,7 +1344,7 @@ reverse_search(void)
|
||||
|
||||
HS.curhist = testhist;
|
||||
save_pos = HS.pos;
|
||||
flush_input();
|
||||
flush_input(0);
|
||||
memcpy(HS.buf, hp->data, hp->len);
|
||||
HS.end = &HS.buf[hp->len];
|
||||
goto_end_of_line();
|
||||
@@ -1355,7 +1354,7 @@ reverse_search(void)
|
||||
|
||||
|
||||
S_FUNC void
|
||||
quote_char(void)
|
||||
quote_char(int UNUSED(key))
|
||||
{
|
||||
int ch;
|
||||
|
||||
@@ -1451,7 +1450,7 @@ memrcpy(char *dest, char *src, int len)
|
||||
#endif /* !USE_READLINE */
|
||||
|
||||
S_FUNC void
|
||||
quit_calc(void)
|
||||
quit_calc(int UNUSED(ch))
|
||||
{
|
||||
hist_term();
|
||||
putchar('\n');
|
||||
@@ -1493,7 +1492,7 @@ hist_getline(char *prompt, char *buf, size_t len)
|
||||
case CTRL_D_VIRGIN_EOF:
|
||||
case CTRL_D_EMPTY_EOF:
|
||||
default:
|
||||
quit_calc();
|
||||
quit_calc(0);
|
||||
not_reached();
|
||||
}
|
||||
}
|
||||
|
27
rpm.mk
27
rpm.mk
@@ -1,9 +1,8 @@
|
||||
#!/bin/make
|
||||
#****h* calc/rpm.mk
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# rpm.mk - Makefile for building rpm packages 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
|
||||
@@ -63,7 +62,7 @@
|
||||
|
||||
# setup
|
||||
#
|
||||
SHELL= /bin/sh
|
||||
SHELL= bash
|
||||
RPMBUILD_TOOL= rpmbuild
|
||||
TARCH= x86_64
|
||||
RPMBUILD_OPTION= -ba --target=$(TARCH) --buildroot=${RPM_BUILD_ROOT}
|
||||
@@ -76,7 +75,6 @@ RM= rm
|
||||
LS= ls
|
||||
CPIO= cpio
|
||||
CP= cp
|
||||
EGREP= egrep
|
||||
MKDIR= mkdir
|
||||
GREP= grep
|
||||
SORT= sort
|
||||
@@ -136,10 +134,12 @@ V=@:
|
||||
all: ver_calc calc.spec
|
||||
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
|
||||
PROJECT_VERSION="`./ver_calc`"; \
|
||||
PROJECT_VER="`./ver_calc -V`"; \
|
||||
PROJECT_RELEASE="`${SED} -n \
|
||||
-e '/^Release:/s/^Release: *//p' calc.spec.in`"; \
|
||||
$(MAKE) -f rpm.mk rpm \
|
||||
PROJECT_VERSION="$$PROJECT_VERSION" \
|
||||
PROJECT_VER="$$PROJECT_VER" \
|
||||
PROJECT_RELEASE="$$PROJECT_RELEASE" Q= S= E=
|
||||
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
|
||||
|
||||
@@ -160,6 +160,7 @@ calc.spec: calc.spec.in ver_calc
|
||||
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
|
||||
${RM} -f calc.spec
|
||||
${SED} -e 's/<<<PROJECT_VERSION>>>/'"`./ver_calc`"/g \
|
||||
-e 's/<<<PROJECT_VER>>>/'"`./ver_calc -V`"/g \
|
||||
calc.spec.in > calc.spec
|
||||
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
|
||||
|
||||
@@ -169,11 +170,12 @@ srcpkg: make_rhdir
|
||||
${V} echo RPM_TOP="${RPM_TOP}"
|
||||
${V} echo RPM_BUILD_ROOT="${RPM_BUILD_ROOT}"
|
||||
${V} echo PROJECT_VERSION="${PROJECT_VERSION}"
|
||||
${V} echo PROJECT_VER="${PROJECT_VER}"
|
||||
${V} echo PROJECT_RELEASE="${PROJECT_RELEASE}"
|
||||
${RM} -rf "$(TMPDIR)/$(PROJECT)"
|
||||
${FIND} . -depth -print | \
|
||||
${EGREP} -v '/RCS|/CVS|/NOTES|/\.|\.out$$|\.safe$$\.tar\.bz2$$' | \
|
||||
${EGREP} -v '/old[._-]|\.old$$|\.tar\.gz$$|/ver_calc$$' | \
|
||||
${GREP} -E -v '/RCS|/CVS|/NOTES|/\.|\.out$$|\.safe$$\.tar\.bz2$$' | \
|
||||
${GREP} -E -v '/old[._-]|\.old$$|\.tar\.gz$$|/ver_calc$$' | \
|
||||
LANG=C ${SORT} | \
|
||||
${CPIO} -dumpv "$(TMPDIR)/$(PROJECT)"
|
||||
${RM} -f "$(TMPDIR)/$(PROJECT)/Makefile"
|
||||
@@ -192,6 +194,7 @@ rpm: srcpkg calc.spec
|
||||
${V} echo RPM_TOP="${RPM_TOP}"
|
||||
${V} echo RPM_BUILD_ROOT="${RPM_BUILD_ROOT}"
|
||||
${V} echo PROJECT_VERSION="${PROJECT_VERSION}"
|
||||
${V} echo PROJECT_VER="${PROJECT_VER}"
|
||||
${V} echo PROJECT_RELEASE="${PROJECT_RELEASE}"
|
||||
$(MAKE) -f Makefile clean Q= S= E=
|
||||
${CP} "$(SPECFILE)" "$(RPM_TOP)/SPECS/$(SPECFILE)"
|
||||
@@ -212,6 +215,7 @@ make_rhdir:
|
||||
${V} echo RPM_TOP="${RPM_TOP}"
|
||||
${V} echo RPM_BUILD_ROOT="${RPM_BUILD_ROOT}"
|
||||
${V} echo PROJECT_VERSION="${PROJECT_VERSION}"
|
||||
${V} echo PROJECT_VER="${PROJECT_VER}"
|
||||
${V} echo PROJECT_RELEASE="${PROJECT_RELEASE}"
|
||||
for subdir in "" BUILD RPMS SOURCES SPECS SRPMS tmp; do \
|
||||
i="$(RPM_TOP)/$$subdir"; \
|
||||
@@ -278,8 +282,8 @@ chkpkg:
|
||||
.PHONY: chksys
|
||||
chksys:
|
||||
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
|
||||
${RPM_TOOL} -qa | ${GREP} "$(PROJECT_NAME)"
|
||||
${RPM_TOOL} -qa | ${GREP} "$(PROJECT_NAME)-devel"
|
||||
${RPM_TOOL} -qa | ${GREP} -E "$(PROJECT_NAME)"
|
||||
${RPM_TOOL} -qa | ${GREP} -E "$(PROJECT_NAME)-devel"
|
||||
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
|
||||
|
||||
.PHONY: test
|
||||
@@ -289,7 +293,10 @@ test: ver_calc
|
||||
echo "test needs to install, must be root to test" 1>&2; \
|
||||
exit 6; \
|
||||
fi
|
||||
$(MAKE) -f rpm.mk PROJECT_VERSION="`./ver_calc`" installrpm \
|
||||
$(MAKE) -f rpm.mk \
|
||||
PROJECT_VERSION="`./ver_calc`" \
|
||||
PROJECT_VER="`./ver_calc -V`" \
|
||||
installrpm \
|
||||
chksys Q= S= E=
|
||||
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
|
||||
|
||||
|
72
seed.c
72
seed.c
@@ -66,24 +66,30 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "have_times.h"
|
||||
|
||||
#if defined(HAVE_TIME_H)
|
||||
#include <time.h>
|
||||
#endif
|
||||
#endif /* HAVE_TIME_H */
|
||||
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#endif /* HAVE_SYS_TIME_H */
|
||||
|
||||
#if defined(HAVE_SYS_TIMES_H)
|
||||
#include <sys/times.h>
|
||||
#endif
|
||||
#endif /* HAVE_SYS_TIMES_H */
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
/* NOTE: RANDOM_CNT should remain 32 to circular shift 31-bit returns */
|
||||
# define RANDOM_CNT (32) /* random() call repeat and circular shift */
|
||||
# define INITSTATE_SIZE (256) /* initstate pool size */
|
||||
#endif
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <setjmp.h>
|
||||
#include "alloc.h"
|
||||
#include "qmath.h"
|
||||
@@ -98,15 +104,33 @@
|
||||
#include "have_uid_t.h"
|
||||
#include "have_environ.h"
|
||||
#include "have_arc4random.h"
|
||||
|
||||
#if defined(HAVE_USTAT)
|
||||
# include <ustat.h>
|
||||
#endif
|
||||
#endif /* HAVE_USTAT */
|
||||
|
||||
#if defined(HAVE_URANDOM)
|
||||
# include <fcntl.h>
|
||||
# define DEV_URANDOM "/dev/urandom"
|
||||
# define DEV_URANDOM_POOL (16)
|
||||
#endif
|
||||
#endif /* HAVE_URANDOM */
|
||||
|
||||
#include "have_sys_vfs.h"
|
||||
#if defined(HAVE_SYS_VFS_H)
|
||||
# include <sys/vfs.h>
|
||||
#endif /* HAVE_SYS_VFS_H */
|
||||
|
||||
#include "have_sys_param.h"
|
||||
#if defined(HAVE_SYS_PARAM_H)
|
||||
# include <sys/param.h>
|
||||
#endif /* HAVE_SYS_PARAM_H */
|
||||
|
||||
#include "have_sys_mount.h"
|
||||
#if defined(HAVE_SYS_MOUNT_H)
|
||||
# include <sys/mount.h>
|
||||
#endif /* HAVE_SYS_MOUNT_H */
|
||||
|
||||
#include "have_statfs.h"
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
@@ -417,6 +441,25 @@ pseudo_seed(void)
|
||||
/* usage stat of "/var/log/messages" */
|
||||
struct ustat ustat_messages;
|
||||
#endif
|
||||
#if defined(HAVE_STATFS)
|
||||
struct statfs statfs_dot; /* filesystem stat of "." */
|
||||
struct statfs statfs_dotdot; /* filesystem stat of ".." */
|
||||
struct statfs statfs_tmp; /* filesystem stat of "/tmp" */
|
||||
struct statfs statfs_root; /* filesystem stat of "/" */
|
||||
struct statfs statfs_tty; /* filesystem stat of "/dev/tty" */
|
||||
struct statfs statfs_console; /* filesystem stat of "/dev/console" */
|
||||
struct statfs statfs_stdin; /* filesystem stat of stdin */
|
||||
struct statfs statfs_stdout; /* filesystem stat of stdout */
|
||||
struct statfs statfs_stderr; /* filesystem stat of stderr */
|
||||
struct statfs statfs_zero; /* filesystem stat of "/dev/zero" */
|
||||
struct statfs statfs_null; /* filesystem stat of "/dev/null" */
|
||||
struct statfs statfs_sh; /* filesystem stat of "/bin/sh" */
|
||||
struct statfs statfs_ls; /* filesystem stat of "/bin/ls" */
|
||||
/* filesystem stat of "/var/log/system.log" */
|
||||
struct statfs statfs_system;
|
||||
/* filesystem stat of "/var/log/messages" */
|
||||
struct statfs statfs_messages;
|
||||
#endif
|
||||
#if defined(HAVE_GETSID)
|
||||
pid_t getsid; /* session ID */
|
||||
#endif
|
||||
@@ -559,6 +602,23 @@ pseudo_seed(void)
|
||||
(void) ustat(sdata.stat_system.st_dev, &sdata.ustat_system);
|
||||
(void) ustat(sdata.stat_messages.st_dev, &sdata.ustat_messages);
|
||||
#endif
|
||||
#if defined(HAVE_STATFS)
|
||||
(void) statfs("..", &sdata.statfs_dot);
|
||||
(void) statfs(".", &sdata.statfs_dotdot);
|
||||
(void) statfs("/tmp", &sdata.statfs_tmp);
|
||||
(void) statfs("/", &sdata.statfs_root);
|
||||
(void) statfs("/dev/tty", &sdata.statfs_tty);
|
||||
(void) statfs("/dev/console", &sdata.statfs_console);
|
||||
(void) statfs(".dev/stdin", &sdata.statfs_stdin);
|
||||
(void) statfs("/dev/stdout", &sdata.statfs_stdout);
|
||||
(void) statfs("/dev/stderr", &sdata.statfs_stderr);
|
||||
(void) statfs("/dev/zero", &sdata.statfs_zero);
|
||||
(void) statfs("/dev/null", &sdata.statfs_null);
|
||||
(void) statfs("/bin/sh", &sdata.statfs_sh);
|
||||
(void) statfs("/dev/ls", &sdata.statfs_ls);
|
||||
(void) statfs("/var/log/system.log", &sdata.statfs_system);
|
||||
(void) statfs("/var/log/messages", &sdata.statfs_messages);
|
||||
#endif
|
||||
#if defined(HAVE_GETSID)
|
||||
sdata.getsid = getsid((pid_t)0);
|
||||
#endif
|
||||
|
49
sha1.c
49
sha1.c
@@ -3,26 +3,37 @@
|
||||
*
|
||||
* Written 2 September 1992, Peter C. Gutmann.
|
||||
*
|
||||
* This file has been extensively modified by:
|
||||
*
|
||||
* Landon Curt Noll
|
||||
* http://www.isthe.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
*
|
||||
* This code has been placed in the public domain. Please do not
|
||||
* copyright this code.
|
||||
*
|
||||
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY 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.
|
||||
*
|
||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||
* This file is covered under "The unlicense":
|
||||
*
|
||||
* https://unlicense.org
|
||||
*
|
||||
* In particular:
|
||||
*
|
||||
* 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/>
|
||||
*/
|
||||
|
||||
|
||||
|
49
sha1.h
49
sha1.h
@@ -3,26 +3,37 @@
|
||||
*
|
||||
* Written 2 September 1992, Peter C. Gutmann.
|
||||
*
|
||||
* This file and been extensively modified by:
|
||||
*
|
||||
* Landon Curt Noll
|
||||
* http://www.isthe.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
*
|
||||
* This code has been placed in the public domain. Please do not
|
||||
* copyright this code.
|
||||
*
|
||||
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY 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.
|
||||
*
|
||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||
* This file is covered under "The unlicense":
|
||||
*
|
||||
* https://unlicense.org
|
||||
*
|
||||
* In particular:
|
||||
*
|
||||
* 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/>
|
||||
*/
|
||||
|
||||
|
||||
|
4
symbol.c
4
symbol.c
@@ -373,7 +373,6 @@ freeglobals(void)
|
||||
{
|
||||
GLOBAL **hp; /* hash table head address */
|
||||
GLOBAL *sp; /* current global symbol pointer */
|
||||
long count; /* number of global variables freed */
|
||||
|
||||
/*
|
||||
* We prevent the hp pointer from walking behind globalhash
|
||||
@@ -384,12 +383,10 @@ freeglobals(void)
|
||||
* short and running the loop one last time manually helps make
|
||||
* code checkers such as insure happy.
|
||||
*/
|
||||
count = 0;
|
||||
for (hp = &globalhash[HASHSIZE-1]; hp > globalhash; hp--) {
|
||||
for (sp = *hp; sp; sp = sp->g_next) {
|
||||
if (sp->g_value.v_type != V_NULL) {
|
||||
freevalue(&sp->g_value);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -397,7 +394,6 @@ freeglobals(void)
|
||||
for (sp = *hp; sp; sp = sp->g_next) {
|
||||
if (sp->g_value.v_type != V_NULL) {
|
||||
freevalue(&sp->g_value);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
44
value.c
44
value.c
@@ -377,6 +377,7 @@ negvalue(VALUE *vp, VALUE *vres)
|
||||
void
|
||||
addvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
{
|
||||
unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */
|
||||
COMPLEX *c;
|
||||
VALUE tmp;
|
||||
NUMBER *q;
|
||||
@@ -403,7 +404,8 @@ addvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
return;
|
||||
}
|
||||
vres->v_type = v1->v_type;
|
||||
switch (TWOVAL(v1->v_type, v2->v_type)) {
|
||||
twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type);
|
||||
switch (twoval_as_uint) {
|
||||
case TWOVAL(V_NUM, V_NUM):
|
||||
vres->v_num = qqadd(v1->v_num, v2->v_num);
|
||||
return;
|
||||
@@ -474,13 +476,15 @@ addvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
void
|
||||
subvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
{
|
||||
unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */
|
||||
COMPLEX *c;
|
||||
NUMBER *q;
|
||||
int i;
|
||||
|
||||
vres->v_type = v1->v_type;
|
||||
vres->v_subtype = V_NOSUBTYPE;
|
||||
switch (TWOVAL(v1->v_type, v2->v_type)) {
|
||||
twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type);
|
||||
switch (twoval_as_uint) {
|
||||
case TWOVAL(V_NUM, V_NUM):
|
||||
vres->v_num = qsub(v1->v_num, v2->v_num);
|
||||
return;
|
||||
@@ -562,11 +566,13 @@ subvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
void
|
||||
mulvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
{
|
||||
unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */
|
||||
COMPLEX *c;
|
||||
|
||||
vres->v_type = v1->v_type;
|
||||
vres->v_subtype = V_NOSUBTYPE;
|
||||
switch (TWOVAL(v1->v_type, v2->v_type)) {
|
||||
twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type);
|
||||
switch (twoval_as_uint) {
|
||||
case TWOVAL(V_NUM, V_NUM):
|
||||
vres->v_num = qmul(v1->v_num, v2->v_num);
|
||||
return;
|
||||
@@ -727,6 +733,8 @@ invertvalue(VALUE *vp, VALUE *vres)
|
||||
void
|
||||
andvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
{
|
||||
unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */
|
||||
|
||||
vres->v_subtype = V_NOSUBTYPE;
|
||||
if (v1->v_type == V_NULL) {
|
||||
copyvalue(v2, vres);
|
||||
@@ -737,7 +745,8 @@ andvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
return;
|
||||
}
|
||||
vres->v_type = v1->v_type;
|
||||
switch (TWOVAL(v1->v_type, v2->v_type)) {
|
||||
twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type);
|
||||
switch (twoval_as_uint) {
|
||||
case TWOVAL(V_NUM, V_NUM):
|
||||
vres->v_num = qand(v1->v_num, v2->v_num);
|
||||
return;
|
||||
@@ -783,6 +792,8 @@ andvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
void
|
||||
orvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
{
|
||||
unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */
|
||||
|
||||
if (v1->v_type == V_NULL) {
|
||||
copyvalue(v2, vres);
|
||||
return;
|
||||
@@ -793,7 +804,8 @@ orvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
}
|
||||
vres->v_type = v1->v_type;
|
||||
vres->v_subtype = V_NOSUBTYPE;
|
||||
switch (TWOVAL(v1->v_type, v2->v_type)) {
|
||||
twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type);
|
||||
switch (twoval_as_uint) {
|
||||
case TWOVAL(V_NUM, V_NUM):
|
||||
vres->v_num = qor(v1->v_num, v2->v_num);
|
||||
return;
|
||||
@@ -840,9 +852,12 @@ orvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
void
|
||||
xorvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
{
|
||||
unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */
|
||||
|
||||
vres->v_type = v1->v_type;
|
||||
vres->v_subtype = V_NOSUBTYPE;
|
||||
switch (TWOVAL(v1->v_type, v2->v_type)) {
|
||||
twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type);
|
||||
switch (twoval_as_uint) {
|
||||
case (TWOVAL(V_NUM, V_NUM)):
|
||||
vres->v_num = qxor(v1->v_num, v2->v_num);
|
||||
return;
|
||||
@@ -886,11 +901,13 @@ xorvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
void
|
||||
hashopvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
{
|
||||
unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */
|
||||
NUMBER *q;
|
||||
|
||||
vres->v_type = v1->v_type;
|
||||
vres->v_subtype = V_NOSUBTYPE;
|
||||
switch (TWOVAL(v1->v_type, v2->v_type)) {
|
||||
twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type);
|
||||
switch (twoval_as_uint) {
|
||||
case TWOVAL(V_NUM, V_NUM):
|
||||
q = qsub(v1->v_num, v2->v_num);
|
||||
vres->v_num = qqabs(q);
|
||||
@@ -952,9 +969,12 @@ backslashvalue(VALUE *vp, VALUE *vres)
|
||||
void
|
||||
setminusvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
{
|
||||
unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */
|
||||
|
||||
vres->v_type = v1->v_type;
|
||||
vres->v_subtype = V_NOSUBTYPE;
|
||||
switch (TWOVAL(v1->v_type, v2->v_type)) {
|
||||
twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type);
|
||||
switch (twoval_as_uint) {
|
||||
case TWOVAL(V_NUM, V_NUM):
|
||||
vres->v_num = qandnot(v1->v_num, v2->v_num);
|
||||
return;
|
||||
@@ -2010,6 +2030,7 @@ powvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
void
|
||||
powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres)
|
||||
{
|
||||
unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */
|
||||
NUMBER *epsilon;
|
||||
COMPLEX *c, ctmp1, ctmp2;
|
||||
|
||||
@@ -2042,7 +2063,8 @@ powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres)
|
||||
return;
|
||||
}
|
||||
|
||||
switch (TWOVAL(v1->v_type, v2->v_type)) {
|
||||
twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type);
|
||||
switch (twoval_as_uint) {
|
||||
case TWOVAL(V_NUM, V_NUM):
|
||||
if (qisneg(v1->v_num)) {
|
||||
ctmp1.real = v1->v_num;
|
||||
@@ -2098,6 +2120,7 @@ powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres)
|
||||
void
|
||||
divvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
{
|
||||
unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */
|
||||
COMPLEX *c;
|
||||
COMPLEX ctmp;
|
||||
NUMBER *q;
|
||||
@@ -2124,7 +2147,8 @@ divvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
return;
|
||||
}
|
||||
vres->v_type = v1->v_type;
|
||||
switch (TWOVAL(v1->v_type, v2->v_type)) {
|
||||
twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type);
|
||||
switch (twoval_as_uint) {
|
||||
case TWOVAL(V_NUM, V_NUM):
|
||||
vres->v_num = qqdiv(v1->v_num, v2->v_num);
|
||||
return;
|
||||
|
44
value.h
44
value.h
@@ -167,7 +167,8 @@ struct value {
|
||||
#define V_OPTR 19 /* octet address as pointer */
|
||||
#define V_SPTR 20 /* string address as pointer */
|
||||
#define V_NPTR 21 /* number address as pointer */
|
||||
#define V_MAX 21 /* highest legal value */
|
||||
|
||||
#define V_MAX V_NPTR /* highest legal value - must be last and match highest V_something value */
|
||||
|
||||
#define V_NOSUBTYPE 0 /* subtype has no meaning */
|
||||
#define V_NOASSIGNTO 1 /* protection status 1 */
|
||||
@@ -189,7 +190,46 @@ struct value {
|
||||
*/
|
||||
|
||||
|
||||
#define TWOVAL(a,b) ((a) << 5 | (b)) /* for switch of two values */
|
||||
/*
|
||||
* NOTE: The shift of 8 in TWOVAL() macro below assumes V_MAX < 1<<8
|
||||
*
|
||||
* The macro TWOVAL_ARGS_OK(a,b) will return true if both a and b are in range,
|
||||
* otherwise it will return false.
|
||||
*
|
||||
* The TWOVAL_INVALID is a value that TWOVAL_ARGS_OK(a,b) is true,
|
||||
* will never match a TWOVAL(a,b) value (i.e., using V_something defined values).
|
||||
*
|
||||
* The TWOVAL_AS_UINT(a,b) may be assigned to a unsigned int value so that
|
||||
* with one switches on that unsigned int, cases with a and/or b being
|
||||
* out of range will fall into the default (non-matching) case.
|
||||
*
|
||||
* unsigned int twoval_as_uint;
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* twoval_as_uint = TWOVAL_AS_UINT(a,b);
|
||||
* switch (twoval_as_uint) {
|
||||
* case TWOVAL(V_INT,V_INT):
|
||||
* ...
|
||||
* break;
|
||||
* case TWOVAL(V_INT,V_NUM):
|
||||
* ...
|
||||
* break;
|
||||
* default:
|
||||
* ...
|
||||
* break;
|
||||
* }
|
||||
*
|
||||
* If a is NOT 0 <= a <= V_MAX or if b is NOT 0 <= b <= V_MAX,
|
||||
* when () macro returns -1 (all bits set) in order to
|
||||
* not match and true TWOVAL() macro combination that uses
|
||||
* uses a V_something defined value above.
|
||||
*/
|
||||
|
||||
#define TWOVAL(a,b) ((unsigned int)(((a) << 8) | (b))) /* logical OR for switch of two V_something values */
|
||||
#define TWOVAL_ARGS_OK(a,b) (((a) >= 0) && ((a) <= V_MAX) && ((b) >= 0) && ((b) <= V_MAX))
|
||||
#define TWOVAL_INVALID ((unsigned int)(-1)) /* never a valid TWOVAL(a,b) value when a and b are in range */
|
||||
#define TWOVAL_AS_UINT(a,b) (TWOVAL_ARGS_OK(a,b) ? TWOVAL(a,b) : TWOVAL_INVALID)
|
||||
|
||||
#define NULL_VALUE ((VALUE *) 0)
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* version - determine the version of calc
|
||||
*
|
||||
* Copyright (C) 1999-2021 David I. Bell and Landon Curt Noll
|
||||
* Copyright (C) 1999-2023 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -83,8 +83,8 @@ static char *program;
|
||||
*/
|
||||
#define MAJOR_VER 2 /* major library version */
|
||||
#define MINOR_VER 14 /* minor library version */
|
||||
#define MAJOR_PATCH 1 /* major software version level */
|
||||
#define MINOR_PATCH 3 /* minor software version level */
|
||||
#define MAJOR_PATCH 3 /* major software version level */
|
||||
#define MINOR_PATCH 5 /* minor software version level */
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -36,6 +36,9 @@ HAVE_UNISTD_H=NO
|
||||
HAVE_LIMITS_H=YES
|
||||
HAVE_ENVIRON=-DHAVE_NO_ENVIRON
|
||||
HAVE_ARC4RANDOM=-DHAVE_NO_ARC4RANDOM
|
||||
HAVE_SYS_VFS_H=NO
|
||||
HAVE_SYS_PARAM_H=NO
|
||||
HAVE_SYS_MOUNT_H=NO
|
||||
|
||||
BINDIR=/usr/bin/calc
|
||||
LIBDIR=/lib/calc
|
||||
|
6
zfunc.c
6
zfunc.c
@@ -1036,7 +1036,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res)
|
||||
}
|
||||
g = (FULL) (*a0 * w);
|
||||
if (h < BASEB) {
|
||||
g &= (1 << h) - 1;
|
||||
g &= (FULL)lowhalf[h];
|
||||
} else {
|
||||
g &= BASE1;
|
||||
}
|
||||
@@ -1354,14 +1354,14 @@ zlog10(ZVALUE z, BOOL *was_10_power)
|
||||
}
|
||||
|
||||
/* create power10 table */
|
||||
power10 = malloc(sizeof(long) * (max_power10_exp+1));
|
||||
power10 = calloc(max_power10_exp+1, sizeof(long));
|
||||
if (power10 == NULL) {
|
||||
math_error("cannot malloc power10 table");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/* load power10 table */
|
||||
for (i=0, v = 1L; i <= max_power10_exp; ++i, v *= 10L) {
|
||||
for (i=0, v = 1L; i < max_power10_exp; ++i, v *= 10L) {
|
||||
power10[i] = v;
|
||||
}
|
||||
}
|
||||
|
6
zmath.c
6
zmath.c
@@ -88,9 +88,11 @@ HALF *half_tbl[] = {
|
||||
/*
|
||||
* highhalf[i] - masks off the upper i bits of a HALF
|
||||
* rhighhalf[i] - masks off the upper BASEB-i bits of a HALF
|
||||
* lowhalf[i] - masks off the upper i bits of a HALF
|
||||
* rlowhalf[i] - masks off the upper BASEB-i bits of a HALF
|
||||
* lowhalf[i] - masks off the lower i bits of a HALF
|
||||
* rlowhalf[i] - masks off the lower BASEB-i bits of a HALF
|
||||
* bitmask[i] - (1 << i) for 0 <= i <= BASEB*2
|
||||
*
|
||||
* NOTE: In all cases 0 <= i <= BASEB
|
||||
*/
|
||||
HALF highhalf[BASEB+1] = {
|
||||
#if BASEB == 32
|
||||
|
2
zmath.h
2
zmath.h
@@ -606,7 +606,7 @@ E_FUNC void zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
#define MODE2_OFF (MODE_MAX+1)
|
||||
|
||||
/* XXX - perhaps we need the MODE_REAL_AUTO vs MODE_REAL as a config mode? */
|
||||
#if 0 /* XXX - can we safely set MODE_INITIAL to MODE_REAL_AUTO ?? */
|
||||
#if 0 /* XXX - can we safely set MODE_INITIAL to MODE_REAL_AUTO ?? */
|
||||
#define MODE_INITIAL MODE_REAL_AUTO
|
||||
#else
|
||||
#define MODE_INITIAL MODE_REAL
|
||||
|
@@ -2861,7 +2861,7 @@ zrandom(long cnt, ZVALUE *res)
|
||||
t = blum.bits-(dest.bit+1);
|
||||
*dest.loc-- = (blum.buffer >> t);
|
||||
dest.bit = BASEB-t-1;
|
||||
*dest.loc = ((blum.buffer&lowhalf[t]) << (dest.bit+1));
|
||||
*dest.loc = (HALF)(((unsigned long)(blum.buffer&lowhalf[t])) << (dest.bit+1));
|
||||
}
|
||||
dest.len -= blum.bits;
|
||||
}
|
||||
@@ -2896,7 +2896,7 @@ zrandom(long cnt, ZVALUE *res)
|
||||
t = loglogn-(dest.bit+1);
|
||||
*dest.loc-- |= (blum.buffer >> t);
|
||||
dest.bit = BASEB-t-1;
|
||||
*dest.loc = ((blum.buffer&lowhalf[t]) << (dest.bit+1));
|
||||
*dest.loc = (HALF)(((unsigned long)(blum.buffer&lowhalf[t])) << (dest.bit+1));
|
||||
}
|
||||
dest.len -= loglogn;
|
||||
}
|
||||
|
Reference in New Issue
Block a user