mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
69 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e11d159c81 | ||
|
dfd66be871 | ||
|
27f977b545 | ||
|
2ca6e789ca | ||
|
ff8f921ebc | ||
|
005b78227a | ||
|
b7a42a9d3d | ||
|
3d1e938cb6 | ||
|
8b98a7c1f6 | ||
|
dbf5acf5e8 | ||
|
5fe5ab1c4b | ||
|
e0cd9bb3db | ||
|
f0f6171354 | ||
|
94861cc6d2 | ||
|
286233e28f | ||
|
99ac7836aa | ||
|
6c0c8e0ef6 | ||
|
8aa5f140bf | ||
|
2fcb9a5995 | ||
|
8b018b697d | ||
|
0e269ecd67 | ||
|
a640bc4656 | ||
|
62a95499ef | ||
|
9e92d4a35a | ||
|
459c07b121 | ||
|
ada15fdabc | ||
|
d5de36841a | ||
|
cf419fb329 | ||
|
abf39b34b6 | ||
|
552252371f | ||
|
7570010a04 | ||
|
a9ee753dc6 | ||
|
ca5a81122a | ||
|
554cd97145 | ||
|
806606f284 | ||
|
7c0ebc5887 | ||
|
45665f94a7 | ||
|
cd736fdbd4 | ||
|
f753884008 | ||
|
1d9a4941ce | ||
|
5bde797ba4 | ||
|
ecba35fc26 | ||
|
a4f8f367c3 | ||
|
41b11ab785 | ||
|
3d33c6c6f4 | ||
|
dbd8926022 | ||
|
f7f110b686 | ||
|
ebf065dcb8 | ||
|
6bc0747a71 | ||
|
04861939fc | ||
|
ca0aaa0c3a | ||
|
f5d5319a51 | ||
|
263b8a78ef | ||
|
3c866367c6 | ||
|
09d7080547 | ||
|
f480c8c5df | ||
|
a230431a3b | ||
|
eaec46982d | ||
|
a86d629982 | ||
|
bcbc0cb766 | ||
|
ac0d84eef8 | ||
|
9b4580d861 | ||
|
2085361df1 | ||
|
bf4657c138 | ||
|
1b5636afed | ||
|
7eba99ac29 | ||
|
de6474bf28 | ||
|
55bc690cd1 | ||
|
6dc62c1ab7 |
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '41 1 * * 6'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
5
.gitignore
vendored
5
.gitignore
vendored
@@ -33,6 +33,7 @@ custom/libcustcalc*
|
||||
endian
|
||||
endian_calc.h
|
||||
fposval.h
|
||||
have_ban_pragma.h
|
||||
have_const.h
|
||||
have_fpos.h
|
||||
have_fpos_pos.h
|
||||
@@ -49,6 +50,8 @@ have_stdlib.h
|
||||
have_stdvs
|
||||
have_strdup.h
|
||||
have_string.h
|
||||
have_strlcat.h
|
||||
have_strlcpy.h
|
||||
have_times.h
|
||||
have_uid_t.h
|
||||
have_unistd.h
|
||||
@@ -88,8 +91,10 @@ longbits
|
||||
longbits.h
|
||||
sample_many
|
||||
sample_rand
|
||||
tags
|
||||
terminal.h
|
||||
ver_calc
|
||||
win32/
|
||||
|
||||
# other commonly excluded patterns
|
||||
#
|
||||
|
50
BUGS
50
BUGS
@@ -116,59 +116,9 @@ of a context diff patch).
|
||||
|
||||
Known bugs in calc:
|
||||
|
||||
Under macOS, the installation of the calc man page fails.
|
||||
|
||||
The output of the alg_config.cal resource file is bogus.
|
||||
We would welcome a replacement for this code.
|
||||
|
||||
Calc shell scripts do not read from stdin properly,
|
||||
we all as a number of the cscript examples.
|
||||
|
||||
The argv() function is behaving differently
|
||||
when run in calc shell script mode:
|
||||
|
||||
When calc is run as:
|
||||
|
||||
calc -s a bb ccc
|
||||
|
||||
and given this input on the command prompt:
|
||||
|
||||
print "config(\"program\")=", config("program");
|
||||
print "argv()=", argv();
|
||||
argc = argv();
|
||||
for (i=0; i < argc; ++i) {
|
||||
print "argv(":i:")=", argv(i);
|
||||
}
|
||||
|
||||
calc prints:
|
||||
|
||||
config("program")= calc
|
||||
argv()= 3
|
||||
argv(0)= a
|
||||
argv(1)= bb
|
||||
argv(2)= ccc
|
||||
|
||||
but when it is run as a script called ./simple:
|
||||
|
||||
#!/usr/local/bin/calc -q -s -f
|
||||
print "config(\"program\")=", config("program");
|
||||
print "argv()=", argv();
|
||||
argc = argv();
|
||||
for (i=0; i < argc; ++i) {
|
||||
print "argv(":i:")=", argv(i);
|
||||
}
|
||||
|
||||
under Linux prints:
|
||||
|
||||
config("program")= /usr/bin/calc
|
||||
argv()= 4
|
||||
argv(0)= ./simple
|
||||
argv(1)= a
|
||||
argv(2)= bb
|
||||
argv(3)= ccc
|
||||
|
||||
and under macOS simply enters into interactive mode.
|
||||
|
||||
We are sure some more bugs exist. When you find them, please let
|
||||
us know! See the above for details on how to report and were to
|
||||
Email your bug reports and hopefully patches to fix them.
|
||||
|
538
CHANGES
538
CHANGES
@@ -1,4 +1,459 @@
|
||||
The following are the changes from calc version 2.12.8.1 to date:
|
||||
The following are the changes from calc version 2.14.0.7 to date:
|
||||
|
||||
Fizzbin is a better word. :-)
|
||||
|
||||
The help and man builtin commands now return an error when a
|
||||
help file cannot be opened, such as when there is no help file.
|
||||
|
||||
Added palindrome.cal resource file. For example, to find the
|
||||
largest (highly probable) prime palindrome under 280 decimal
|
||||
digits (text tweet limit):
|
||||
|
||||
prevprimepal(1e280)
|
||||
|
||||
|
||||
The following are the changes from calc version 2.14.0.0 to 2.14.0.6:
|
||||
|
||||
The :-separated default CALCRC value has been reversed.
|
||||
The default CALCRC was:
|
||||
|
||||
${CALC_SHAREDIR}/startup:~/.calcrc:./.calcinit
|
||||
|
||||
The default CALCRC is now:
|
||||
|
||||
./.calcinit:~/.calcrc:${CALC_SHAREDIR}/startup
|
||||
|
||||
See "help environment" for details.
|
||||
|
||||
Added engineering mode as per a GitHub pull request from
|
||||
<GitHub user heitzmann>. Thank you! For example:
|
||||
|
||||
; config("mode","eng"),
|
||||
; 10^41
|
||||
100e39
|
||||
|
||||
or for example:
|
||||
|
||||
; base(1000),
|
||||
; 2^23209-1
|
||||
~402.87411577898877818187e6984
|
||||
|
||||
For more information see:
|
||||
|
||||
help base
|
||||
|
||||
Added regression test code for engineering mode. Improved and
|
||||
expanded regression test code related to the base() and base2()
|
||||
builtin functions.
|
||||
|
||||
Fixed a critical bug in the above mentioned pull request where
|
||||
a call to base2(1000) would make calc unstable and likely to
|
||||
dump core.
|
||||
|
||||
Added builtin functions to convert between degrees, radians
|
||||
and gradians:
|
||||
|
||||
d2r(deg) - given degrees returns radians
|
||||
g2r(grad) - given gradians returns radians
|
||||
|
||||
r2d(rad) - given radians returns degrees
|
||||
g2d(grad) - given gradians returns degrees
|
||||
|
||||
r2g(rad) - given radians returns gradians
|
||||
d2g(deg) - given degrees returns gradians
|
||||
|
||||
Add 6 functions take a 2nd optional epsilon argument.
|
||||
For d2r(deg, ep), r2d(rad, ep), the optional 2nd epsilon argument controls
|
||||
the precision of the internal constant pi/180.
|
||||
For g2r(grad, ep), r2g(rad, ep), the optional 2nd epsilon argument controls
|
||||
the precision of the internal constant pi/200.
|
||||
The optional 2nd argument is ignored by g2d(grad, ep) and d2g(deg, ep).
|
||||
|
||||
The clean and clobber makefile rules no longer list custom/Makefile
|
||||
as a dependecy.
|
||||
|
||||
Unfortunately due to the complex dependency issues between
|
||||
Makefile, Makefile.ship and custom/Makefile, parallel GNU make
|
||||
is NOT recommended. Sorry (tm Canada) :)
|
||||
|
||||
The clean and clobber makefile rules no longer list custom/Makefile
|
||||
as a dependency.
|
||||
|
||||
Unfortunately due to the complex dependency issues between
|
||||
Makefile, Makefile.ship and custom/Makefile, parallel GNU make
|
||||
is NOT recommended. Sorry (tm Canada) :)
|
||||
|
||||
Fixed a few typos in CHANGES.
|
||||
|
||||
As a side note: We stayed v2.13.x was kept for only a short time.
|
||||
The move to 2.14.x was motivated by non-compatible changes due to
|
||||
the default order of CALCRC, plus some new builtin functions.
|
||||
|
||||
More changes are likely, so we might see another v2.14.0.x release
|
||||
before things are declared "recommended stable".
|
||||
|
||||
Not that we want to discourage people from trying v2.14.0, you should
|
||||
try it. We just want things to become stable and well field tested
|
||||
before we reach the "recommended stable" release state.
|
||||
|
||||
Added builtin functions to convert between degrees and
|
||||
degrees, minutes and seconds under the config("mod")
|
||||
round rules:
|
||||
|
||||
d2dms(degs, d, m, s [,rnd]) - given degs, compute d, m, s
|
||||
d2dm(degs, d, m [,rnd]) - given degs, compute d, m
|
||||
|
||||
See help/d2dms and help/d2dm.
|
||||
|
||||
Example:
|
||||
|
||||
; print d2dms(360.321,deg=,min=,sec=), deg, min, sec;
|
||||
0.321 0 19 15.6
|
||||
|
||||
; print d2dm(360.321,deg=,min=), deg, min;
|
||||
0.321 0 19.26
|
||||
|
||||
Added builtin functions to convert between gradians and
|
||||
gradians, minutes and seconds under the config("mod")
|
||||
round rules:
|
||||
|
||||
g2gms(grads, g, m, s [,rnd]) - given grads, compute g, m, s
|
||||
g2gm(grads, g, m [,rnd]) - given grads, compute g, m
|
||||
|
||||
See help/g2gms and help/g2gm.
|
||||
|
||||
Example:
|
||||
|
||||
; print g2gms(400.321,grad=,min=,sec=), grad, min, sec;
|
||||
0.321 0 19 15.6
|
||||
|
||||
; print g2gm(400.321,grad=,min=), grad, min;
|
||||
0.321 0 19.26
|
||||
|
||||
Added builtin functions to convert between hours and
|
||||
hours, minutes and seconds under the config("mod")
|
||||
round rules:
|
||||
|
||||
h2hms(hours, h, m, s [,rnd]) - given hours, compute h, m, s
|
||||
h2hm(hours, h, m [,rnd]) - given hours, compute h, m
|
||||
|
||||
See help/h2hms and help/h2hm.
|
||||
|
||||
Example:
|
||||
|
||||
; print h2hms(24.321,hour=,min=,sec=), hour, min, sec;
|
||||
0.321 0 19 15.6
|
||||
|
||||
; print h2hm(24.321,hour=,min=), hour, min;
|
||||
0.321 0 19.26
|
||||
|
||||
Renumbered regression tests 3408 thru 3437, to 9102 thru 9131.
|
||||
|
||||
Updated Added hms.cal resource file to use h2hms() builtin.
|
||||
Updated Added dms.cal resource file to use d2dms() builtin.
|
||||
|
||||
Fix minor typo in help/mod SYNOPSIS.
|
||||
Fix minor typo in help/quo SYNOPSIS.
|
||||
|
||||
Added a few more examples to help/strcmp.
|
||||
|
||||
Added builtin functions to convert between degrees, minutes and
|
||||
seconds and degrees under the config("mod") round rules:
|
||||
|
||||
dms2d(d, m, s [,rnd]) - convert deg, min, and secs to deg
|
||||
dm2d(d, m [,rnd]) - convert deg, min to deg
|
||||
|
||||
See help/dms2d and help/dm2d.
|
||||
|
||||
Example:
|
||||
|
||||
; print dms2d(12, 20, 44.16);
|
||||
12.3456
|
||||
|
||||
; print dm2d(3601, -25.5594);
|
||||
0.57401
|
||||
|
||||
Added builtin functions to convert between gradians, minutes and
|
||||
seconds and gradians under the config("mod") round rules:
|
||||
|
||||
gms2g(g, m, s [,rnd]) - convert grad, min, and secs to grad
|
||||
gm2g(g, m [,rnd]) - convert grad and min to grad
|
||||
|
||||
See help/g2gms and help/g2gm.
|
||||
|
||||
Example:
|
||||
|
||||
; print gms2g(12, 20, 44.16);
|
||||
12.3456
|
||||
|
||||
; print gm2g(4001, -25.5594);
|
||||
0.57401
|
||||
|
||||
Added builtin functions to convert between hours, minutes and
|
||||
seconds and hours under the config("mod") round rules:
|
||||
|
||||
hms2h(h, m, s [,rnd]) - convert hours, min, and secs to hours
|
||||
hm2h(h, m [,rnd]) - convert hours, min to hours
|
||||
|
||||
See help/hms2h and help/hm2h.
|
||||
|
||||
Example:
|
||||
|
||||
; print hms2h(12, 20, 44.16);
|
||||
12.3456
|
||||
|
||||
; print hm2h(241, -25.5594);
|
||||
0.57401
|
||||
|
||||
Fixed typo in cal/statistics.cal thanks to a report by <GitHub user
|
||||
dennisaldea>.
|
||||
|
||||
Fixed an old Windoz pun in README.WINDOWS as requested by <GitHub
|
||||
user marcodegio>.
|
||||
|
||||
Fixed a really obscure bug in the internal initconstants()
|
||||
function of const.c that has been sitting for over 31 years!
|
||||
|
||||
We are amazed that nobody has encountered this bug before
|
||||
now. Nevertheless, our very extensive regression and
|
||||
multi-architecture testing found the bug. Now, after all
|
||||
those years, it is fixed.
|
||||
|
||||
Fixed issues identied by the default CodeUL GitHub security code scan:
|
||||
|
||||
Wrong type of arguments to printf in have_fpos_pos.c
|
||||
Multiplication result converted to larger type in zfunc.c
|
||||
|
||||
|
||||
The following are the changes from calc version 2.13.0.1 to 2.13.0.1:
|
||||
|
||||
Replaced /usr/local with the use of ${PREFIX} in calc Makefiles.
|
||||
|
||||
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.
|
||||
|
||||
Corrected a few more typos in Makefile comments.
|
||||
|
||||
Added Makefile.local, a file with a single comment. The main
|
||||
Makefile includes Makefile.local just before the first all rule.
|
||||
One may override any Makefile setting by modifying Makefile.local.
|
||||
For example, Makefile.local could force BLD_TYPE:
|
||||
|
||||
HAVE_STRING_H:= YES
|
||||
HAVE_TIMES_H:= YES
|
||||
SED:= /usr/local/bin/nsed
|
||||
|
||||
Added ${LOC_MKF} to specify the make of the file that is
|
||||
included just before the all file. So one could place
|
||||
the above override lines into a different file and call
|
||||
make changing the ${LOC_MKF} value. For example:
|
||||
|
||||
make LOC_MKF=Makefile.private clobber all chk
|
||||
|
||||
Updated HOWTO.INSTALL to mention Makefile.local.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.13.0.0 to 2.13.0.0:
|
||||
|
||||
Fixed typo (missing quotes) in the env rule.
|
||||
|
||||
Fixed indentation problem in CHANGES.
|
||||
|
||||
Combined 2.12.9.1 changes into the 2.12.8.2 to 2.12.9.0
|
||||
range, and thus renamed the range to 2.12.8.2 to 2.12.9.1.
|
||||
|
||||
Fixed issues related to building Makefile.simple.
|
||||
|
||||
Fixed how the Makefile variable MANPATH is set for macOS.
|
||||
|
||||
Added a bunch of information to the near bottom of HOWTO.INSTALL
|
||||
on calc Makefiles. This information discusses the various
|
||||
Makefiles found in the calc source.
|
||||
|
||||
Added comments in various calc Makefiles about their origin.
|
||||
In particular, for Makefiles that are constructed such as
|
||||
Makefile.simple, custom/Makefile and custom/Makefile.simple
|
||||
there are comments about how they were made.
|
||||
|
||||
For all calc Makefiles, including those in sub-directories,
|
||||
near the top there is now a line of the form:
|
||||
|
||||
# SRC: ... some message about the origin ...
|
||||
|
||||
Fixed how the calc(1) man page is installed under macOS.
|
||||
|
||||
Fixed how calc man page in ${CATDIR} is formed.
|
||||
|
||||
Fixed how Makefile.simple is formed.
|
||||
|
||||
Fixed the #! calc script argument processing. The initial #!
|
||||
line must end in a -f. For example, if calc is in /usr/local/bin/calc,
|
||||
then the following would be the first line of a calc script:
|
||||
|
||||
#!/usr/local/bin/calc -f
|
||||
...
|
||||
|
||||
It is common that -q be used with a calc script, so assuming the
|
||||
same /usr/local/bin/calc path:
|
||||
|
||||
#!/usr/local/bin/calc -q -f
|
||||
...
|
||||
|
||||
Use of -s in the #! first line of a calc script is not needed
|
||||
since -f implies -f.
|
||||
|
||||
The argv() will now return values more typical of C's main().
|
||||
Before it returned one less than the number of arguments. Now,
|
||||
for example, when calc is given 2 args, argv() will return 3.
|
||||
|
||||
The value of argv(0) will be the path to calc, or in the
|
||||
case of a #! calc cscript, it will return the name of the script.
|
||||
|
||||
Updated the calc man page and help/argv to reflect the
|
||||
above changes.
|
||||
|
||||
Improved the formatting of the calc man page.
|
||||
|
||||
Fixed the formation of the win32 sub-directory via the win32_hsrc
|
||||
Makefile rule.
|
||||
|
||||
Due to incompatible changes to the argv() function, and #! calc
|
||||
scripts, we are setting the version to the next minor number:
|
||||
|
||||
2.13.0.x
|
||||
|
||||
Updated BUGS file as per v2.13.0 fixes.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.12.8.2 to 2.12.9.1:
|
||||
|
||||
Added notes to help/unexpected about:
|
||||
|
||||
display() will limit the number of digits printed after decimal point
|
||||
|
||||
%d will format after the decimal point for non-integer numeric values
|
||||
|
||||
%x will format as fractions for non-integer numeric values
|
||||
|
||||
fprintf(fd, "%d\n", huge_value) may need fflush(fd) to finish
|
||||
|
||||
Fixed Makefile dependencies for the args.h rule.
|
||||
|
||||
Fixed Makefile cases where echo with -n is used. On some systems,
|
||||
/bin/sh does not use -n, so we must call /bin/echo -n instead
|
||||
via the ${ECHON} Makefile variable.
|
||||
|
||||
Add missing standard tools to sub-Makefiles to make them
|
||||
easier to invoke directly.
|
||||
|
||||
Sort lists of standard tool Makefile variables and remove duplicates.
|
||||
|
||||
Declare the SHELL at the top of Makefiles.
|
||||
|
||||
Fixed the depend rule in the custom Makefile.
|
||||
|
||||
Improved the messages produced by the depend in the Makefiles.
|
||||
|
||||
Changed the UNUSED define in have_unused.h to be a macro with
|
||||
a parameter. Changed all use of UNUSED in *.c to be UNUSED(x).
|
||||
|
||||
Removed the need for HAVE_UNUSED in building the have_unused.h file.
|
||||
|
||||
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.
|
||||
|
||||
Added the building of have_ban_pragma.h, which will determine
|
||||
if "#pragma GCC poison func_name" is supported. If it is not,
|
||||
or of HAVE_PRAGMA_GCC_POSION=-DHAVE_NO_PRAGMA_GCC_POSION, then
|
||||
banned.h will have no effect.
|
||||
|
||||
Fixed building of the have_getpgid.h file.
|
||||
Fixed building of the have_getprid.h file.
|
||||
Fixed building of the have_getsid.h file.
|
||||
Fixed building of the have_gettime.h file.
|
||||
Fixed building of the have_strdup.h file.
|
||||
Fixed building of the have_ustat.h file.
|
||||
Fixed building of the have_rusage.h file.
|
||||
|
||||
Added HAVE_NO_STRLCPY to control if we want to test if
|
||||
the system has a strlcpy() function. This in turn produces
|
||||
the have_strlcpy.h file wherein the symbol HAVE_STRLCPY will
|
||||
be defined, or not depending if the system comes with a
|
||||
strlcpy() function.
|
||||
|
||||
If the system does not have a strlcpy() function, we
|
||||
compile our own strlcpy() function. See strl.c for details.
|
||||
|
||||
Added HAVE_NO_STRLCAT to control if we want to test if
|
||||
the system has a strlcat() function. This in turn produces
|
||||
the have_strlcat.h file wherein the symbol HAVE_STRLCAT will
|
||||
be defined, or not depending if the system comes with a
|
||||
strlcat() function.
|
||||
|
||||
If the system does not have a strlcat() function, we
|
||||
compile our own strlcat() function. See strl.c for details.
|
||||
|
||||
Fixed places were <string.h>, using #ifdef HAVE_STRING_H
|
||||
for legacy systems that do not have that include file.
|
||||
|
||||
Added ${H} Makefile symbol to control the announcement
|
||||
of forming and having formed hsrc related files. By default
|
||||
H=@ (announce hsrc file formation) vs. H=@: to silence hsrc
|
||||
related file formation.
|
||||
|
||||
Explicitly turn off quiet mode (set Makefile variable ${Q} to
|
||||
be empty) when building rpms.
|
||||
|
||||
Improved and fixed the hsrc build process.
|
||||
|
||||
Forming rpms is performed in verbose mode to assist debugging
|
||||
to the rpm build process.
|
||||
|
||||
Compile custom code, if needed, after main code is compiled.
|
||||
|
||||
Fixed a typo typo in help/Makefile that caused the build of
|
||||
2.12.9.0 to fail in a number of cases. Thanks to a report by
|
||||
<GitHub user balducci>.
|
||||
|
||||
Pass form Makefile variables ${Q}, ${S}, ${E}, ${H} and ${V} down
|
||||
to all sub-directory Makefiles from the top level Makefile.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.12.8.1 to 2.12.8.2:
|
||||
|
||||
Fixed how the *.tar.bz2 are formed. The calc-2.12.8.0.tar.bz2 file
|
||||
that was formed for calc version 2.12.8.0 was missing most files.
|
||||
@@ -13,6 +468,7 @@ The following are the changes from calc version 2.12.8.1 to date:
|
||||
thanks to a report by <GitHub user barsnick>.
|
||||
|
||||
|
||||
|
||||
The following are the changes from calc version 2.12.7.5 to 2.12.8.0:
|
||||
|
||||
Fixed a mistake in "help intro" where some inserted text changed
|
||||
@@ -386,7 +842,7 @@ The following are the changes from calc version 2.12.5.4 to 2.12.5.6:
|
||||
Rewrote gen_v1() in the lucas.cal resource file using the method
|
||||
based on a paper:
|
||||
|
||||
"A note on primality tests for N = h*2^n-1", by Oystein J. Rodseth,
|
||||
"A note on primality tests for N = h*2^n-1", by Oystein J. Rodseth,
|
||||
Department of Mathematics, University of Bergen, BIT Numerical
|
||||
Mathematics. 34 (3): pp 451-454.
|
||||
|
||||
@@ -445,13 +901,13 @@ The following are the changes from calc version 2.12.5.3 to 2.12.5.3:
|
||||
macOS (Darwin) users who installed calc version 2.12.5.2
|
||||
should, after installing version 2.12.5.3:
|
||||
|
||||
rm -rf /opt/calc
|
||||
rm -rf /opt/calc
|
||||
|
||||
|
||||
The following are the changes from calc version 2.12.5.1 to 2.12.5.2:
|
||||
|
||||
NOTE: calc version 2.12.5.2, for macOS (Darwin) users,
|
||||
installed under /opt/calc. We neglected to mention this
|
||||
installed under /opt/calc. We neglected to mention this
|
||||
AND /usr/local would have been a better choice. Sorry!
|
||||
Fixed in calc version 2.12.5.3.
|
||||
|
||||
@@ -524,7 +980,7 @@ The following are the changes from calc version 2.12.4.14 to 2.12.5.0:
|
||||
|
||||
For Apple OS X / Darwin target:
|
||||
|
||||
MACOSX_DEPLOYMENT_TARGET is no longer defined
|
||||
MACOSX_DEPLOYMENT_TARGET is no longer defined
|
||||
using clang compiler
|
||||
|
||||
By default, -install-name is used when forming shared libs.
|
||||
@@ -568,9 +1024,9 @@ The following are the changes from calc version 2.12.4.14 to 2.12.5.0:
|
||||
for mul2, sq2, and pow2. However, it has been shown that this
|
||||
code is not correct. Suggestions for a replacement are welcome!
|
||||
|
||||
calc -u 'read alg_config; config("user_debug", 2),; best_mul2();'
|
||||
calc -u 'read alg_config; config("user_debug", 2),; best_sq2();'
|
||||
calc -u 'read alg_config; config("user_debug", 2),; best_pow2();'
|
||||
calc -u 'read alg_config; config("user_debug", 2),; best_mul2();'
|
||||
calc -u 'read alg_config; config("user_debug", 2),; best_sq2();'
|
||||
calc -u 'read alg_config; config("user_debug", 2),; best_pow2();'
|
||||
|
||||
Fixed a number of pedantic compiler warnings.
|
||||
|
||||
@@ -737,7 +1193,7 @@ The following are the changes from calc version 2.12.4.6 to version 2.12.4.10:
|
||||
With the exception of 3 source files, we became "picky" about
|
||||
line lengths and other issues reported by the picky tool:
|
||||
|
||||
cal/test8900.cal
|
||||
cal/test8900.cal
|
||||
cal/set8700.line
|
||||
help/errorcodes.sed
|
||||
|
||||
@@ -793,7 +1249,7 @@ The following are the changes from calc version 2.12.4.0 to 2.12.4.2:
|
||||
Added prep makefile rule to make is easier to compile calc without
|
||||
an optimizer. By doing:
|
||||
|
||||
make clobber prep
|
||||
make clobber prep
|
||||
|
||||
one may build a calc binary that is easier to debug.
|
||||
|
||||
@@ -950,7 +1406,7 @@ The following are the changes from calc version 2.12.1.1 to 2.12.2.2:
|
||||
what was calc-something.tar.gz is now calc-something.tar.bz2.
|
||||
To "uncompress" use:
|
||||
|
||||
bunzip2 calc-something.tar.bz2
|
||||
bunzip2 calc-something.tar.bz2
|
||||
|
||||
On some systems, one may untar directly by:
|
||||
|
||||
@@ -1015,7 +1471,7 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
|
||||
Renamed the following variables related to calc error processing:
|
||||
|
||||
int calc_jmp ==> int calc_use_matherr_jmpbuf
|
||||
jmp_buf calc_jmp_buf ==> jmp_buf calc_matherr_jmpbuf
|
||||
jmp_buf calc_jmp_buf ==> jmp_buf calc_matherr_jmpbuf
|
||||
|
||||
int post_init ==> int calc_use_scanerr_jmpbuf
|
||||
jmp_buf jmpbuf ==> jmpbuf calc_scanerr_jmpbuf
|
||||
@@ -1030,7 +1486,7 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
|
||||
Parse/scan errors will not be printed if calc_print_scanerr_msg
|
||||
is zero. By default:
|
||||
|
||||
int calc_print_scanerr_msg = 1;
|
||||
int calc_print_scanerr_msg = 1;
|
||||
|
||||
This variable is declared in the lib_calc.h include file. Storage
|
||||
comes from libcalc.
|
||||
@@ -1038,7 +1494,7 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
|
||||
Parse/scan warnings will not be printed if calc_print_scanwarn_msg
|
||||
is zero. By default:
|
||||
|
||||
int calc_print_scanwarn_msg = 1;
|
||||
int calc_print_scanwarn_msg = 1;
|
||||
|
||||
This variable is declared in the lib_calc.h include file. Storage
|
||||
comes from libcalc.
|
||||
@@ -1074,13 +1530,13 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
|
||||
Replaced the concept of compiler sets in the Makefile with
|
||||
host target section in the Makefile. Initial host targets are:
|
||||
|
||||
Linux
|
||||
Linux
|
||||
Darwin
|
||||
FreeBSD
|
||||
(default) <<== Target does not match any previous target name
|
||||
Simple
|
||||
|
||||
NOTE: If your target is not supported below and the default target
|
||||
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
|
||||
@@ -1092,12 +1548,12 @@ The following are the changes from calc version 2.12.1.10 to 2.12.2:
|
||||
The custom/Makefile is now constructed from 3 parts: custom/Makefile.head,
|
||||
the host target section in Makefile, and the custom/Makefile.tail.
|
||||
|
||||
The top level Makefile and the custom/Makefile require a GNU Make
|
||||
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.
|
||||
|
||||
If your target system does not have GNU Make (or equivalent), then
|
||||
If your target system does not have GNU make (or equivalent), then
|
||||
you should try using the Makefile.simple and custom/Makefile.simple
|
||||
files:
|
||||
|
||||
@@ -1228,7 +1684,7 @@ The following are the changes from calc version 2.12.1.8 to 2.12.1.9:
|
||||
comments. Improved calc comment documentation in "help unexpected"
|
||||
to help other avoid similar mistakes. Calc comments are of the form:
|
||||
|
||||
/* c style comments */
|
||||
/* c style comments */
|
||||
/*
|
||||
* multi-line
|
||||
* comments
|
||||
@@ -1242,7 +1698,7 @@ The following are the changes from calc version 2.12.1.8 to 2.12.1.9:
|
||||
|
||||
Documented these help commands in "help help":
|
||||
|
||||
help ->
|
||||
help ->
|
||||
help *
|
||||
help .
|
||||
help %
|
||||
@@ -1423,7 +1879,7 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
|
||||
Added the builtin function fpathopen() to open a file while
|
||||
searching along a path:
|
||||
|
||||
; fd2 = fpathopen("tmp/date", "r", ".:~:~sc:/tmp:/var/tmp:/var")
|
||||
; fd2 = fpathopen("tmp/date", "r", ".:~:~sc:/tmp:/var/tmp:/var")
|
||||
; print fd2
|
||||
"/var/tmp/date"
|
||||
|
||||
@@ -1473,12 +1929,12 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
|
||||
level. When comparing with older source, one may use the -b argument
|
||||
of the diff command to ignore changes in amount of white space:
|
||||
|
||||
diff -b -r -u calc-2.11.11 calc-2.12.0
|
||||
diff -b -r -u calc-2.11.11 calc-2.12.0
|
||||
|
||||
The read, write, and help commands use the value of global string
|
||||
variable if the symbol name starts with a $. For example:
|
||||
|
||||
global x = "lucas.cal";
|
||||
global x = "lucas.cal";
|
||||
read $x; /* same as read lucas.cal or read "lucas.cal" */
|
||||
|
||||
Added dotest.cal resource. Based on a design by Ernest Bowen
|
||||
@@ -1588,7 +2044,7 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
|
||||
|
||||
Changed the default values for the following config() parameters:
|
||||
|
||||
config("mul2") == 1780
|
||||
config("mul2") == 1780
|
||||
config("sq2") == 3388
|
||||
config("pow2") == 176
|
||||
|
||||
@@ -1683,10 +2139,10 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
|
||||
value is TRUE by default. Examples of variable name collisions
|
||||
include when:
|
||||
|
||||
* both local and static variables have the same name
|
||||
* both local and global variables have the same name
|
||||
* both function parameter and local variables have the same name
|
||||
* both function parameter and global variables have the same name
|
||||
* both local and static variables have the same name
|
||||
* both local and global variables have the same name
|
||||
* both function parameter and local variables have the same name
|
||||
* both function parameter and global variables have the same name
|
||||
|
||||
Fix of a bug which causes some static variables not to be correctly
|
||||
unscoped when their identifiers are used in a global declaration.
|
||||
@@ -1706,7 +2162,7 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
|
||||
Changed the definition of the function ssq() to enable list arguments
|
||||
to be processed in the same way as in sum(). For example:
|
||||
|
||||
ssq(1,2, list(3,4,list(5,6)), list(), 7, 8)
|
||||
ssq(1,2, list(3,4,list(5,6)), list(), 7, 8)
|
||||
|
||||
returns the value of 1^2 + 2^2 + ... + 8^2 == 204.
|
||||
|
||||
@@ -1714,7 +2170,7 @@ The following are the changes from calc version 2.12.0 to 2.12.0.8:
|
||||
various ways of evaluating sums, sums of squares, etc, for large
|
||||
lists and matrices. For example:
|
||||
|
||||
read sumtimes
|
||||
read sumtimes
|
||||
doalltimes(1e6)
|
||||
|
||||
Calc now ignores carriage returns (\r), vertical tabs (\v), and
|
||||
@@ -1753,7 +2209,7 @@ The following are the changes from calc version 2.11.10.1 to 2.11.11:
|
||||
|
||||
Fixed a bug reported by the sourceforge user: cedars where:
|
||||
|
||||
ln(exp(6)) == 3 /* WRONG!!! */
|
||||
ln(exp(6)) == 3 /* WRONG!!! */
|
||||
|
||||
incorrectly returned 1. This bug was fixed by Ernest Bowen
|
||||
<ebowen at une dot edu dot au>. The regression test
|
||||
@@ -1858,7 +2314,7 @@ The following are the changes from calc version 2.11.10 to 2.11.10:
|
||||
|
||||
Fixed -d so that:
|
||||
|
||||
calc -d 2/3
|
||||
calc -d 2/3
|
||||
|
||||
will print 0.66666666666666666667 without the leading tilde as
|
||||
advertised in the man page.
|
||||
@@ -1878,7 +2334,7 @@ The following are the changes from calc version 2.11.10 to 2.11.10:
|
||||
|
||||
Added custom function:
|
||||
|
||||
custom("pmodm127", q)
|
||||
custom("pmodm127", q)
|
||||
|
||||
to compute 2^(2^127-1) mod q. While currently slower than just
|
||||
doing pmod(2,2^127-1,q), it is added to give an example of a
|
||||
@@ -1969,7 +2425,7 @@ The following are the changes from calc version 2.11.8.0 to 2.11.8.1:
|
||||
configuration (calc -n or config("all", "newstd")) is now the default
|
||||
calc configuration. The flag:
|
||||
|
||||
calc -O
|
||||
calc -O
|
||||
|
||||
was added to get the old classic calc configuration. The flag command
|
||||
line flag, -n, now does nothing. Use of -n is deprecated and may go
|
||||
@@ -2146,16 +2602,16 @@ The following are the changes from calc version 2.11.5.5 to 2.11.5.9:
|
||||
|
||||
Now using version numbers of one of these forms:
|
||||
|
||||
x.y.z.w
|
||||
x.y.z
|
||||
x.y
|
||||
x.y.z.w
|
||||
x.y.z
|
||||
x.y
|
||||
|
||||
Changed the READLINE_LIB Makefile variable to not link with -lreadline
|
||||
by default. If you do have readline, we recommend that you use it.
|
||||
If you can install the GNU readline:
|
||||
|
||||
http://freshmeat.net/projects/gnureadline/
|
||||
http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
|
||||
http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
|
||||
|
||||
we recommend it. But if not, you should set the USE_READLINE,
|
||||
READLINE_LIB, and READLINE_INCLUDE Makefile variables to empty.
|
||||
@@ -2227,7 +2683,7 @@ The following are the changes from calc version 2.11.5t4.1 to 2.11.5t4.4:
|
||||
Added subject requirements for the calc-tester-request and
|
||||
calc-bugs-mail Email aliases. See:
|
||||
|
||||
http://www.isthe.com/chongo/tech/comp/calc/email.html
|
||||
http://www.isthe.com/chongo/tech/comp/calc/email.html
|
||||
|
||||
for details.
|
||||
|
||||
@@ -2394,7 +2850,7 @@ The following are the changes from calc version 2.11.5t2 to 2.11.5t2.1:
|
||||
Applied a bug fix from Ernest Bowen <ernie at turing dot une dot
|
||||
edu dot au> dealing with one-line "static" declaration like:
|
||||
|
||||
static a = 1, b;
|
||||
static a = 1, b;
|
||||
|
||||
Added regression test 8310 to test for the static bug fix.
|
||||
|
||||
@@ -2507,7 +2963,7 @@ The following are the changes from calc version 2.11.5t0 to 2.11.5t1.1:
|
||||
Configuration values that used to return "true" or "false" now return
|
||||
1 (a true value) or 0 (a false value). Thus one can do:
|
||||
|
||||
if (config("tab")) { ... } else { ... }
|
||||
if (config("tab")) { ... } else { ... }
|
||||
|
||||
The configuration values that now return 1 or 0 are:
|
||||
|
||||
|
251
HOWTO.INSTALL
251
HOWTO.INSTALL
@@ -1,6 +1,18 @@
|
||||
|
||||
IMPORTANT: Please see the section at the bottom of this file for
|
||||
some important information on Makefiles used in calc.
|
||||
|
||||
###################################################################
|
||||
# IMPORTANT: DO NOT run GNU make in parallel mode!!! #
|
||||
###################################################################
|
||||
# Unfortunately due to the complex dependency issues between #
|
||||
# Makefile, Makefile.ship and custom/Makefile, parallel GNU make #
|
||||
# is NOT recommended. Sorry (tm Canada) :) #
|
||||
###################################################################
|
||||
|
||||
Installing calc from the bzip2-ed tarball in 4 easy steps:
|
||||
|
||||
0) If your platform supports i686 RPMs, you may want to go to:
|
||||
(0) If your platform supports i686 RPMs, you may want to go to:
|
||||
|
||||
http://www.isthe.com/chongo/src/calc/
|
||||
|
||||
@@ -25,25 +37,25 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
||||
cd /var/tmp
|
||||
bunzip2 -c /usr/src/redhat/SOURCES/calc-*.tar.bz2 | tar -xvf -
|
||||
|
||||
1) Look at the makefile, and adjust it to suit your needs.
|
||||
(1) Look at the makefile, and adjust it to suit your needs.
|
||||
|
||||
The top level Makefile and the custom/Makefile require a GNU
|
||||
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,
|
||||
one must use gmake instead of make.
|
||||
probably want to use gmake instead of make.
|
||||
|
||||
Some report that under macOS, one has to declare the target
|
||||
to be darwin. So for macOS, one might have to do:
|
||||
to be Darwin. So for macOS, one might have to do:
|
||||
|
||||
# for macOS users only, force the target to be darwin
|
||||
# for macOS users only, force the target to be Darwin
|
||||
#
|
||||
make target=Darwin clobber
|
||||
make target=Darwin all
|
||||
make target=Darwin chk
|
||||
make target=Darwin install
|
||||
|
||||
If your target system does not have GNU Make (or equivalent), then
|
||||
you should try using the Makefile.simple and custom/Makefile.simple
|
||||
If your target system does not have a moderm Makefile (such as gmake),
|
||||
then you should try using the Makefile.simple and custom/Makefile.simple
|
||||
files:
|
||||
|
||||
mv Makefile Makefile.gmake
|
||||
@@ -56,6 +68,14 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
||||
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 Mkefile 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 Windoz or a Windoz-like environment !
|
||||
! (such as Cygwin or DJGPP), read the README.WINDOWS file. !
|
||||
@@ -148,7 +168,7 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
||||
|
||||
Adjust other Makefile variables as needed.
|
||||
|
||||
2) build calc:
|
||||
(2) build calc:
|
||||
|
||||
The top level Makefile and the custom/Makefile require a GNU
|
||||
Make (such as gmake) or an equivalently advanced make. On many
|
||||
@@ -180,7 +200,7 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
||||
make clobber
|
||||
make calc-dynamic-only BLD_TYPE=calc-dynamic-only
|
||||
|
||||
3) test calc:
|
||||
(3) test calc:
|
||||
|
||||
make check
|
||||
|
||||
@@ -191,13 +211,222 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
||||
|
||||
make chk
|
||||
|
||||
4) install calc:
|
||||
(4) install calc:
|
||||
|
||||
make install
|
||||
|
||||
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.
|
||||
|
||||
=-=
|
||||
|
||||
On calc Makefiles:
|
||||
|
||||
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 zsh may be a much better alternative
|
||||
shell for this Makefile to use:
|
||||
|
||||
SHELL= /bin/zsh
|
||||
|
||||
Makefile
|
||||
|
||||
# SRC: Makefile - Our calc build environment
|
||||
|
||||
This is our internal Makefile that drives how we build calc.
|
||||
For critical rules in Makefile.ship, there is a corresponding
|
||||
rule in Makefile that calls ${MAKE} -f Makefile.ship with,
|
||||
additional commands, args and Makefile variables. The ${XVAR}
|
||||
Makefile variable, for example, is passed on each call to
|
||||
${MAKE} -f Makefile.ship so that the environment and parameters of
|
||||
Makefile.ship may be managed for our build environment.
|
||||
|
||||
This Makefile is used to make the calc rpm. In addition to these
|
||||
comments, this Makefile differs from the non-rpm bzip2-ed tarball
|
||||
source Makefile in at least the the following ways:
|
||||
|
||||
CCWERR= -Werror
|
||||
USE_READLINE= -DUSE_READLINE
|
||||
READLINE_LIB= -lreadline -lhistory -lncurses
|
||||
|
||||
If the Makefile is not suitable for you, then
|
||||
you may wish to replace it with Makefile.ship:
|
||||
|
||||
mv -f -v Makefile.ship Makefile
|
||||
|
||||
This Makefile 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 packages such as RPMs, and the tar.bz2 source tarball,
|
||||
Makefile contains the contents of Makefile.ship. If Makefile.ship
|
||||
is missing it has likely moved to replace 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
|
||||
|
||||
Makefile.ship
|
||||
|
||||
# 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 */
|
||||
|
||||
The custom/Makefile rule of Makefile.ship is used to form
|
||||
the custom/Makefile. In particular the Makefile.ship lines:
|
||||
|
||||
# start of host target cut
|
||||
... these go in between custom/Makefile.head and custom/Makefile.tail
|
||||
# end of host target cut
|
||||
|
||||
Makefile.simple
|
||||
|
||||
# SRC: non-GNU Makefile via make -f Makefile.ship Makefile.simple
|
||||
|
||||
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.head
|
||||
|
||||
# SRC: custom/Makefile.head
|
||||
|
||||
This file forms the top part of the custom/Makefile.
|
||||
|
||||
custom/Makefile.tail
|
||||
|
||||
# SRC: custom/Makefile.tail
|
||||
|
||||
This file forms the bottom part of the custom/Makefile.
|
||||
|
||||
custom/Makefile
|
||||
|
||||
# SRC: Makefile via make -f Makefile custom/Makefile
|
||||
|
||||
This is the custom directory Makefile.
|
||||
|
||||
The custom/Makefile rule of Makefile.ship is used to form
|
||||
the custom/Makefile. In particular the Makefile.ship lines:
|
||||
|
||||
# start of host target cut
|
||||
... these go in between custom/Makefile.head and custom/Makefile.tail
|
||||
# end of host target cut
|
||||
|
||||
NOTE: The clobber rule does not remove this file. - XXX
|
||||
|
||||
custom/Makefile.simple
|
||||
|
||||
# SRC: non-GNU Makefile via make -f Makefile custom/Makefile.simple
|
||||
|
||||
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
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
221
Makefile
221
Makefile
@@ -2,33 +2,15 @@
|
||||
#
|
||||
# calc - arbitrary precision calculator
|
||||
#
|
||||
# (Linux calc rpm building makefile)
|
||||
#
|
||||
# NOTE: This Makefile is used to make the calc rpm. In addition to these
|
||||
# comments, this Makefile differs from the non-rpm bzip2-ed tarball
|
||||
# source Makefile in the following ways:
|
||||
#
|
||||
# CCWERR= -Werror
|
||||
# USE_READLINE= -DUSE_READLINE
|
||||
# READLINE_LIB= -lreadline -lhistory -lncurses
|
||||
#
|
||||
# Copyright (C) 1999-2018,2021 Landon Curt Noll
|
||||
#
|
||||
# The Makefile.ship makefile becomes the Makefile found in the
|
||||
# calc-*.tar.bz2 bzip2 source tarball.
|
||||
# SRC: Makefile - Our calc build environment
|
||||
#
|
||||
# This Makefile drives the makefile: Makefile.ship.
|
||||
# The "# SRC: ... - ..." comment line above indicates
|
||||
# the origin of this file.
|
||||
#
|
||||
# This makefile mostly contains critical variables (such as SHELL, MAKE, etc.)
|
||||
# as well as those which we choose to override defaults found in
|
||||
# Makefile.ship. Make variables unique to this Makefile start with X.
|
||||
#
|
||||
# This makefile contains only those critical rules (such as all, clean, etc.)
|
||||
# and the common rules needed in development (such as chk, check, etc.).
|
||||
# This makefile has a few special rules that are used to set the version
|
||||
# string in the shipped makefiles (such as Makefile.ship).
|
||||
|
||||
# Copyright (C) 1999-2008,2014 Landon Curt Noll
|
||||
# IMPORTANT: Please see the section on Makefiles near the
|
||||
# bottom of 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
|
||||
@@ -53,16 +35,96 @@
|
||||
# calculator by David I. Bell with help/mods from others
|
||||
# Makefile by Landon Curt Noll
|
||||
|
||||
# Unfortunately due to the complex dependency issues between
|
||||
# Makefile, Makefile.ship and custom/Makefile, parallel GNU make
|
||||
# is NOT recommended. Sorry.
|
||||
#
|
||||
.NOTPARALLEL:
|
||||
|
||||
# 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
|
||||
|
||||
# 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 wehre 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
|
||||
#
|
||||
ifeq ($(target),Darwin)
|
||||
SHELL= /bin/zsh
|
||||
else
|
||||
SHELL= /bin/bash
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
#-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-#
|
||||
##############################################################################
|
||||
|
||||
# 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. :-)
|
||||
#
|
||||
# When in doubt, try:
|
||||
#
|
||||
# PREFIX= /usr/local
|
||||
#
|
||||
PREFIX= /usr/local
|
||||
#PREFIX= /usr
|
||||
#PREFIX= /usr/global
|
||||
|
||||
# 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 durings 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
|
||||
|
||||
# Determine of the GNU-readline facility will be used instead of the
|
||||
# built-in calc binding method.
|
||||
#
|
||||
@@ -71,28 +133,22 @@ USE_READLINE= -DUSE_READLINE
|
||||
#
|
||||
#READLINE_LIB=
|
||||
#READLINE_LIB= -L/usr/gnu/lib -lreadline -lhistory -lncurses
|
||||
#READLINE_LIB= -L/usr/local/lib -lreadline -lhistory -lncurses
|
||||
#READLINE_LIB= -L${PREFIX}/lib -lreadline -lhistory -lncurses
|
||||
ifeq ($(target),Darwin)
|
||||
# homebrew installs readline & history libs in /usr/local/opt/readline/lib
|
||||
READLINE_LIB= -L/usr/local/opt/readline/lib -lreadline -lhistory -lncurses
|
||||
# homebrew installs readline & history libs in ${PREFIX}/opt/readline/lib
|
||||
READLINE_LIB= -L${PREFIX}/opt/readline/lib -lreadline -lhistory -lncurses
|
||||
else
|
||||
READLINE_LIB= -lreadline -lhistory -lncurses
|
||||
endif
|
||||
#
|
||||
ifeq ($(target),Darwin)
|
||||
# homebrew installs readline & history *.h under /usr/local/opt/readline/include
|
||||
READLINE_INCLUDE= -I/usr/local/opt/readline/include
|
||||
# homebrew installs readline & history *.h under ${PREFIX}/opt/readline/include
|
||||
READLINE_INCLUDE= -I${PREFIX}/opt/readline/include
|
||||
else
|
||||
READLINE_INCLUDE=
|
||||
endif
|
||||
#READLINE_INCLUDE= -I/usr/gnu/include
|
||||
#READLINE_INCLUDE= -I/usr/local/include
|
||||
|
||||
# Where man pages are installed
|
||||
#
|
||||
# Under macOS, we cannot modify /usr/share/man.
|
||||
#
|
||||
MANDIR= /usr/local/man/man1
|
||||
#READLINE_INCLUDE= -I${PREFIX}/include
|
||||
|
||||
# Normally certain files depend on the Makefile. If the Makefile is
|
||||
# changed, then certain steps should be redone. If MAKE_FILE is
|
||||
@@ -142,7 +198,6 @@ endif
|
||||
|
||||
# standard utilities used during make
|
||||
#
|
||||
SHELL= /bin/sh
|
||||
MAKE= make
|
||||
SED= sed
|
||||
GREP= egrep
|
||||
@@ -160,11 +215,30 @@ CI= ci
|
||||
# Q=@ do not echo internal Makefile actions (quiet mode)
|
||||
# Q= echo internal Makefile actions (debug / verbose mode)
|
||||
#
|
||||
# H=@: do not report hsrc file formation progress
|
||||
# H=@ do echo hsrc file formation progress
|
||||
#
|
||||
# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation
|
||||
# S= full ${CC} output during hsrc file formation
|
||||
#
|
||||
# E= 2>/dev/null slience command stderr during hsrc file formation
|
||||
# E= full command stderr during hsrc file formation
|
||||
#
|
||||
# V=@: do not echo debug statements (quiet mode)
|
||||
# V=@ do echo debug statements (debug / verbose mode)
|
||||
#
|
||||
#Q=
|
||||
Q=@
|
||||
#
|
||||
S= >/dev/null 2>&1
|
||||
#S=
|
||||
#
|
||||
E= 2>/dev/null
|
||||
#E=
|
||||
#
|
||||
#H=@:
|
||||
H=@
|
||||
#
|
||||
V=@:
|
||||
#V=@
|
||||
|
||||
@@ -180,20 +254,24 @@ XARG=
|
||||
# that invokes the ${MAKE_FILE}.
|
||||
#
|
||||
XVAR= \
|
||||
target=${target} \
|
||||
USE_READLINE='${USE_READLINE}' \
|
||||
READLINE_LIB='${READLINE_LIB}' \
|
||||
READLINE_INCLUDE='${READLINE_INCLUDE}' \
|
||||
RPM_TOP='${RPM_TOP}' \
|
||||
MAKE_FILE='${MAKE_FILE}' \
|
||||
EXT='${EXT}' \
|
||||
DARWIN_ARCH='${DARWIN_ARCH}' \
|
||||
CCBAN='${CCBAN}' \
|
||||
CCWERR='${CCWERR}' \
|
||||
NROFF='${NROFF}' \
|
||||
COMMON_ADD='${COMMON_ADD}' \
|
||||
MANDIR='${MANDIR}' \
|
||||
DARWIN_ARCH='${DARWIN_ARCH}' \
|
||||
E='${E}' \
|
||||
EXT='${EXT}' \
|
||||
H='${H}' \
|
||||
MAKE_FILE='${MAKE_FILE}' \
|
||||
NROFF='${NROFF}' \
|
||||
Q='${Q}' \
|
||||
V='${V}'
|
||||
PREFIX='${PREFIX}' \
|
||||
READLINE_INCLUDE='${READLINE_INCLUDE}' \
|
||||
READLINE_LIB='${READLINE_LIB}' \
|
||||
RPM_TOP='${RPM_TOP}' \
|
||||
S='${S}' \
|
||||
USE_READLINE='${USE_READLINE}' \
|
||||
V='${V}' \
|
||||
target=${target}
|
||||
|
||||
# We update the calc version string in these makefiles
|
||||
#
|
||||
@@ -209,7 +287,7 @@ XMKVER= ${MAKE_FILE} custom/Makefile.head
|
||||
#
|
||||
###
|
||||
|
||||
all: fix_version check_include
|
||||
all: fix_version
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-='
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
@@ -504,6 +582,20 @@ have_unused.h:
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
have_ban_pragma.h:
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-='
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
have_strlcpy.h:
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-='
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
have_strlcat.h:
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-='
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
##
|
||||
#
|
||||
@@ -519,34 +611,6 @@ win32_hsrc:
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
# These rules are used in the process of building the BUILD_H_SRC.
|
||||
#
|
||||
##
|
||||
|
||||
endian.o:
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-='
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
endian${EXT}:
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-='
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
longbits.o:
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-='
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
longbits${EXT}:
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-='
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
# These two .all rules are used to determine of the lower level
|
||||
@@ -690,6 +754,11 @@ Makefile.simple:
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
custom/Makefile.simple:
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-='
|
||||
${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR}
|
||||
${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-='
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
|
1
Makefile.local
Normal file
1
Makefile.local
Normal file
@@ -0,0 +1 @@
|
||||
# Add below to override Makefile values (using :=) as in: HAVE_STRING_H:= YES
|
2525
Makefile.ship
2525
Makefile.ship
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
Dear calc user on a Windoz based system,
|
||||
Dear calc user on a Windows based system,
|
||||
|
||||
See the HOWTO.INSTALL file for information on how to build and install calc.
|
||||
See also the README file.
|
||||
@@ -126,7 +126,7 @@ recommends the following settings:
|
||||
CATDIR= /dev/env/DJDIR/man/cat1
|
||||
NROFF= groff
|
||||
CALCPATH= .;./cal;~/.cal;${CALC_SHAREDIR};${CUSTOMCALDIR}
|
||||
CALCRC= ${CALC_SHAREDIR}/startup;~/.calcrc;./.calcinit
|
||||
CALCRC= ./.calcinit;~/.calcrc;${CALC_SHAREDIR}/startup
|
||||
CALCPAGER= less.exe -ci
|
||||
DEBUG= -O2 -gstabs+ -DWINDOZ
|
||||
|
||||
|
21
SECURITY.md
Normal file
21
SECURITY.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Use this section to tell people about which versions of your project are
|
||||
currently being supported with security updates.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 5.1.x | :white_check_mark: |
|
||||
| 5.0.x | :x: |
|
||||
| 4.0.x | :white_check_mark: |
|
||||
| < 4.0 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Use this section to tell people how to report a vulnerability.
|
||||
|
||||
Tell them where to go, how often they can expect to get an update on a
|
||||
reported vulnerability, what to expect if the vulnerability is accepted or
|
||||
declined, etc.
|
6
addop.c
6
addop.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* addop - add opcodes to a function being compiled
|
||||
*
|
||||
* Copyright (C) 1999-2007 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "calc.h"
|
||||
#include "alloc.h"
|
||||
#include "opcodes.h"
|
||||
#include "str.h"
|
||||
#include "func.h"
|
||||
@@ -36,6 +37,9 @@
|
||||
#include "symbol.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define FUNCALLOCSIZE 20 /* reallocate size for functions */
|
||||
#define OPCODEALLOCSIZE 100 /* reallocate size for opcodes in functions */
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* align32 - determine if 32 bit accesses must be aligned
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2021 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
|
||||
@@ -34,6 +34,10 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
static void buserr(void); /* catch alignment errors */
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* assocfunc - association table routines
|
||||
*
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
* Copyright (C) 1999-2007,2021 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -36,6 +36,9 @@
|
||||
#include "value.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define MINHASHSIZE 31 /* minimum size of hash tables */
|
||||
#define GROWHASHSIZE 50 /* approximate growth for hash tables */
|
||||
#define CHAINLENGTH 10 /* desired number of elements on a hash chain */
|
||||
|
180
banned.h
Normal file
180
banned.h
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* banned - optionally ban dqngerious functions
|
||||
*
|
||||
* Unless UNBAN is defined, this file will turn the use
|
||||
* of certain dangerous functions into syntax errors.
|
||||
*
|
||||
* In the case of calc, we are motivated in part by the desire for
|
||||
* calc to correctly calculate: even durings extremely long calculations.
|
||||
*
|
||||
* If UNBAN is NOT defined, then calling certain functions
|
||||
* will result in a syntaxc error.
|
||||
*
|
||||
* If we define UNBAN, then the effect of this file is disabled.
|
||||
*
|
||||
* 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 durings 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.
|
||||
*
|
||||
* Copyright (C) 2021 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: 2021/03/06 21:07:31
|
||||
* File existed as early as: 2021
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(PRE_HAVE_BAN_PRAGMA_H)
|
||||
#include "have_ban_pragma.h"
|
||||
#endif /* ! PRE_HAVE_BAN_PRAGMA_H */
|
||||
|
||||
|
||||
#if !defined(INCLUDE_BANNED_H)
|
||||
#define INCLUDE_BANNED_H
|
||||
|
||||
/*
|
||||
* If we define UNBAN, then the effect of this file is disabled.
|
||||
*/
|
||||
#if !defined(UNBAN)
|
||||
|
||||
/*
|
||||
* In the spirit of:
|
||||
*
|
||||
* https://github.com/git/git/blob/master/banned.h
|
||||
*
|
||||
* we will ban the use of certain unsafe functions by turning
|
||||
* then into function calls that do not exist.
|
||||
*
|
||||
* In the case of calc, we are motivated in part by the desire
|
||||
* for calc to correctly calculate: even durings extremely long
|
||||
* calculations.
|
||||
*
|
||||
* If UNBAN is NOT defined, then calling certain functions
|
||||
* will result in a syntaxc error.
|
||||
*
|
||||
* Unlike the above URL, we suggest an alternative function.
|
||||
* In many cases, additional logic is required to use the
|
||||
* alternative function, we cannot simply replace one function
|
||||
* with another.
|
||||
*/
|
||||
|
||||
/*
|
||||
* If one is not careful, strcpy() can lead to buffer overflows.
|
||||
* Use strlcpy() instead.
|
||||
*/
|
||||
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||
#undef strcpy
|
||||
#pragma GCC poison strcpy
|
||||
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||
|
||||
/*
|
||||
* If one is not careful, strcat() can lead to buffer overflows.
|
||||
* Use strlcat() instead.
|
||||
*/
|
||||
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||
#undef strcat
|
||||
#pragma GCC poison strcat
|
||||
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||
|
||||
/*
|
||||
* If one is not careful, strncpy() can lead to buffer overflows.
|
||||
* Use memccpy() instead.
|
||||
*/
|
||||
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||
#undef strncpy
|
||||
#pragma GCC poison strncpy
|
||||
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||
|
||||
/*
|
||||
* If one is not careful, strncat() can lead to buffer overflows.
|
||||
* Use memccpy() instead.
|
||||
*/
|
||||
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||
#undef strncat
|
||||
#pragma GCC poison strncat
|
||||
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||
|
||||
/*
|
||||
* If one is not careful, sprintf() can lead to buffer overflows.
|
||||
* Use snprintf() instead.
|
||||
*/
|
||||
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||
#undef sprintf
|
||||
#pragma GCC poison sprintf
|
||||
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||
|
||||
/*
|
||||
* If one is not careful, vsprintf() can lead to buffer overflows.
|
||||
* Use vsnprintf() instead.
|
||||
*/
|
||||
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||
#undef vsprintf
|
||||
#pragma GCC poison vsprintf
|
||||
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||
|
||||
/*
|
||||
* XXX - As of 2021, functions such as:
|
||||
*
|
||||
* gmtime_s
|
||||
* localtime_s
|
||||
* ctime_s
|
||||
* asctime_s
|
||||
*
|
||||
* are not universal. We cannot yet ban the following
|
||||
* functions because we do not have a portable AND
|
||||
* widely available alternative. Therefore we just
|
||||
* have to be extra careful when using:
|
||||
*
|
||||
* gmtime
|
||||
* localtime
|
||||
* ctime
|
||||
* ctime_r
|
||||
* asctime
|
||||
* asctime_r
|
||||
*/
|
||||
|
||||
#endif /* !UNBAN */
|
||||
|
||||
#endif /* !INCLUDE_BANNED_H */
|
4
blkcpy.c
4
blkcpy.c
@@ -29,12 +29,16 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "calc.h"
|
||||
#include "alloc.h"
|
||||
#include "value.h"
|
||||
#include "file.h"
|
||||
#include "blkcpy.h"
|
||||
#include "str.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* copystod - copy num indexed items from source value to destination value
|
||||
*
|
||||
|
9
block.c
9
block.c
@@ -28,6 +28,11 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "have_string.h"
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#include "alloc.h"
|
||||
#include "value.h"
|
||||
#include "zmath.h"
|
||||
#include "config.h"
|
||||
@@ -36,6 +41,10 @@
|
||||
#include "str.h"
|
||||
#include "calcerr.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define NBLOCKCHUNK 16
|
||||
|
||||
STATIC long nblockcount = 0;
|
||||
|
27
byteswap.c
27
byteswap.c
@@ -29,6 +29,9 @@
|
||||
#include "byteswap.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* swap_b8_in_HALFs - swap 8 and if needed, 16 bits in an array of HALFs
|
||||
*
|
||||
@@ -123,8 +126,8 @@ swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
|
||||
* swap or copy the rest of the ZVALUE elements
|
||||
*/
|
||||
if (all) {
|
||||
dest->len = (LEN)SWAP_B8_IN_LEN(&dest->len, &src->len);
|
||||
dest->sign = (BOOL)SWAP_B8_IN_BOOL(&dest->sign, &src->sign);
|
||||
SWAP_B8_IN_LEN(&dest->len, &src->len);
|
||||
SWAP_B8_IN_BOOL(&dest->sign, &src->sign);
|
||||
} else {
|
||||
dest->len = src->len;
|
||||
dest->sign = src->sign;
|
||||
@@ -189,7 +192,7 @@ swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
|
||||
* swap or copy the rest of the NUMBER elements
|
||||
*/
|
||||
if (all) {
|
||||
dest->links = (long)SWAP_B8_IN_LONG(&dest->links, &src->links);
|
||||
SWAP_B8_IN_LONG(&dest->links, &src->links);
|
||||
} else {
|
||||
dest->links = src->links;
|
||||
}
|
||||
@@ -253,7 +256,7 @@ swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
|
||||
* swap or copy the rest of the NUMBER elements
|
||||
*/
|
||||
if (all) {
|
||||
dest->links = (long)SWAP_B8_IN_LONG(&dest->links, &src->links);
|
||||
SWAP_B8_IN_LONG(&dest->links, &src->links);
|
||||
} else {
|
||||
dest->links = src->links;
|
||||
}
|
||||
@@ -358,8 +361,8 @@ swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
|
||||
* swap or copy the rest of the ZVALUE elements
|
||||
*/
|
||||
if (all) {
|
||||
dest->len = (LEN)SWAP_B16_IN_LEN(&dest->len, &src->len);
|
||||
dest->sign = (BOOL)SWAP_B16_IN_BOOL(&dest->sign, &src->sign);
|
||||
SWAP_B16_IN_LEN(&dest->len, &src->len);
|
||||
SWAP_B16_IN_BOOL(&dest->sign, &src->sign);
|
||||
} else {
|
||||
dest->len = src->len;
|
||||
dest->sign = src->sign;
|
||||
@@ -424,7 +427,7 @@ swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
|
||||
* swap or copy the rest of the NUMBER elements
|
||||
*/
|
||||
if (all) {
|
||||
dest->links = (long)SWAP_B16_IN_LONG(&dest->links, &src->links);
|
||||
SWAP_B16_IN_LONG(&dest->links, &src->links);
|
||||
} else {
|
||||
dest->links = src->links;
|
||||
}
|
||||
@@ -488,7 +491,7 @@ swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
|
||||
* swap or copy the rest of the NUMBER elements
|
||||
*/
|
||||
if (all) {
|
||||
dest->links = (long)SWAP_B16_IN_LONG(&dest->links, &src->links);
|
||||
SWAP_B16_IN_LONG(&dest->links, &src->links);
|
||||
} else {
|
||||
dest->links = src->links;
|
||||
}
|
||||
@@ -554,8 +557,8 @@ swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
|
||||
* swap or copy the rest of the ZVALUE elements
|
||||
*/
|
||||
if (all) {
|
||||
dest->len = (LEN)SWAP_HALF_IN_LEN(&dest->len, &src->len);
|
||||
dest->sign = (BOOL)SWAP_HALF_IN_BOOL(&dest->sign, &src->sign);
|
||||
SWAP_HALF_IN_LEN(&dest->len, &src->len);
|
||||
SWAP_HALF_IN_BOOL(&dest->sign, &src->sign);
|
||||
} else {
|
||||
dest->len = src->len;
|
||||
dest->sign = src->sign;
|
||||
@@ -620,7 +623,7 @@ swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
|
||||
* swap or copy the rest of the NUMBER elements
|
||||
*/
|
||||
if (all) {
|
||||
dest->links = (long)SWAP_HALF_IN_LONG(&dest->links,&src->links);
|
||||
SWAP_HALF_IN_LONG(&dest->links, &src->links);
|
||||
} else {
|
||||
dest->links = src->links;
|
||||
}
|
||||
@@ -684,7 +687,7 @@ swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
|
||||
* swap or copy the rest of the NUMBER elements
|
||||
*/
|
||||
if (all) {
|
||||
dest->links = (long)SWAP_HALF_IN_LONG(&dest->links,&src->links);
|
||||
SWAP_HALF_IN_LONG(&dest->links, &src->links);
|
||||
} else {
|
||||
dest->links = src->links;
|
||||
}
|
||||
|
146
cal/Makefile
146
cal/Makefile
@@ -4,6 +4,14 @@
|
||||
#
|
||||
# Copyright (C) 1999-2006,2017,2021 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.
|
||||
#
|
||||
# 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.
|
||||
@@ -27,15 +35,64 @@
|
||||
# calculator by David I. Bell with help/mods from others
|
||||
# Makefile by Landon Curt Noll
|
||||
|
||||
# required vars
|
||||
|
||||
# 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/sh
|
||||
#SHELL= /bin/bash
|
||||
#SHELL= /bin/zsh
|
||||
|
||||
|
||||
####
|
||||
# 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
|
||||
|
||||
# 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
|
||||
@@ -65,11 +122,11 @@ TOP_MAKE_FILE= Makefile
|
||||
# INCDIR= /usr/include
|
||||
#
|
||||
|
||||
#INCDIR= /usr/local/include
|
||||
#INCDIR= ${PREFIX}/include
|
||||
#INCDIR= /dev/env/DJDIR/include
|
||||
INCDIR= /usr/include
|
||||
|
||||
# where to install calc realted things
|
||||
# where to install calc related things
|
||||
#
|
||||
# ${BINDIR} where to install calc binary files
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
@@ -91,15 +148,15 @@ INCDIR= /usr/include
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
#BINDIR= /usr/local/bin
|
||||
#BINDIR= ${PREFIX}/bin
|
||||
#BINDIR= /dev/env/DJDIR/bin
|
||||
BINDIR= /usr/bin
|
||||
|
||||
#LIBDIR= /usr/local/lib
|
||||
#LIBDIR= ${PREFIX}/lib
|
||||
#LIBDIR= /dev/env/DJDIR/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
||||
#CALC_SHAREDIR= ${PREFIX}/lib/calc
|
||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
@@ -157,27 +214,51 @@ T=
|
||||
|
||||
# Makefile debug
|
||||
#
|
||||
# Q=@ do not echo internal makefile actions (quiet mode)
|
||||
# Q= echo internal makefile actions (debug / verbose mode)
|
||||
# Q=@ do not echo internal Makefile actions (quiet mode)
|
||||
# Q= echo internal Makefile actions (debug / verbose mode)
|
||||
#
|
||||
# H=@: do not report hsrc file formation progress
|
||||
# H=@ do echo hsrc file formation progress
|
||||
#
|
||||
# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation
|
||||
# S= full ${CC} output during hsrc file formation
|
||||
#
|
||||
# E= 2>/dev/null slience command stderr during hsrc file formation
|
||||
# E= full command stderr during hsrc file formation
|
||||
#
|
||||
# V=@: do not echo debug statements (quiet mode)
|
||||
# V=@ do echo debug statements (debug / verbose mode)
|
||||
#
|
||||
#Q=
|
||||
Q=@
|
||||
#
|
||||
S= >/dev/null 2>&1
|
||||
#S=
|
||||
#
|
||||
E= 2>/dev/null
|
||||
#E=
|
||||
#
|
||||
#H=@:
|
||||
H=@
|
||||
#
|
||||
V=@:
|
||||
#V=@
|
||||
|
||||
# standard tools
|
||||
#
|
||||
CHMOD= chmod
|
||||
CMP= cmp
|
||||
RM= rm
|
||||
MKDIR= mkdir
|
||||
RMDIR= rmdir
|
||||
CP= cp
|
||||
MV= mv
|
||||
CO= co
|
||||
TRUE= true
|
||||
TOUCH= touch
|
||||
CP= cp
|
||||
FMT= fmt
|
||||
MKDIR= mkdir
|
||||
MV= mv
|
||||
RM= rm
|
||||
RMDIR= rmdir
|
||||
SED= sed
|
||||
SORT= sort
|
||||
FMT= fmt
|
||||
TOUCH= touch
|
||||
TRUE= true
|
||||
|
||||
# The calc files to install
|
||||
#
|
||||
@@ -187,17 +268,16 @@ FMT= fmt
|
||||
#
|
||||
# make calc_files_list
|
||||
#
|
||||
# to keep this list in nice sorted order and to check that these
|
||||
# detailed help files are under RCS control.
|
||||
# to keep this list in nice sorted order.
|
||||
#
|
||||
CALC_FILES= README alg_config.cal beer.cal bernoulli.cal \
|
||||
bernpoly.cal bigprime.cal bindings brentsolve.cal chi.cal chrem.cal \
|
||||
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 pell.cal pi.cal pix.cal pollard.cal poly.cal \
|
||||
prompt.cal psqrt.cal qtime.cal quat.cal randbitrun.cal randmprime.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 \
|
||||
@@ -261,19 +341,13 @@ calcliblist:
|
||||
#
|
||||
calc_files_list:
|
||||
${Q} -(find . -mindepth 1 -maxdepth 1 -type f -name '*.cal' -print | \
|
||||
while read i; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
if [ ! -f RCS/$$i,v ]; then \
|
||||
echo "WARNING: $$i not under RCS control" 1>&2; \
|
||||
else \
|
||||
echo $$i; \
|
||||
fi; \
|
||||
fi; \
|
||||
done; \
|
||||
echo '--first_line--'; \
|
||||
echo README; \
|
||||
echo set8700.line; \
|
||||
echo bindings) | \
|
||||
while read i; do \
|
||||
echo $$i; \
|
||||
done; \
|
||||
echo '--first_line--'; \
|
||||
echo README; \
|
||||
echo set8700.line; \
|
||||
echo bindings) | \
|
||||
${SED} -e 's:^\./::' | LANG=C ${SORT} | ${FMT} -70 | \
|
||||
${SED} -e '1s/--first_line--/CALC_FILES=/' -e '2,$$s/^/ /' \
|
||||
-e 's/$$/ \\/' -e '$$s/ \\$$//'
|
||||
|
38
cal/README
38
cal/README
@@ -186,7 +186,7 @@ bernoulli.cal
|
||||
Calculate the nth Bernoulli number.
|
||||
|
||||
NOTE: There is now a bernoulli() builtin function. This file is
|
||||
left here for backward compatibility and now simply returns
|
||||
left here for backward compatibility and now simply returns
|
||||
the builtin function.
|
||||
|
||||
|
||||
@@ -767,7 +767,7 @@ lucas.cal
|
||||
prove that h*2^n-1 is prime or not prime.
|
||||
|
||||
NOTE: Some call this term u(0). The function gen_u0(h, n, v1)
|
||||
simply calls gen_u2(h, n, v1) for such people. :-)
|
||||
simply calls gen_u2(h, n, v1) for such people. :-)
|
||||
|
||||
gen_v1(h, v)
|
||||
|
||||
@@ -879,6 +879,38 @@ natnumset.cal
|
||||
user-specified bound.
|
||||
|
||||
|
||||
palindrome.cal
|
||||
|
||||
digitof(val,place)
|
||||
copalplace(d,place)
|
||||
upperhalf(val)
|
||||
mkpal(val)
|
||||
mkpalmiddigit(val,digit)
|
||||
ispal(val)
|
||||
nextpal(val)
|
||||
prevpal(val)
|
||||
nextprimepal(val)
|
||||
prevprimepal(val)
|
||||
|
||||
Functions to form and manipulate palendromes in base 10.
|
||||
|
||||
Important functions are:
|
||||
|
||||
Find the next / previous palindrome:
|
||||
|
||||
nextpal(val)
|
||||
prevpal(val)
|
||||
|
||||
Test if a value is a palindrome:
|
||||
|
||||
ispal(val)
|
||||
|
||||
Find the next / previous palindrome that is a (highly probable) prime:
|
||||
|
||||
nextprimepal(val)
|
||||
prevprimepal(val)
|
||||
|
||||
|
||||
pell.cal
|
||||
|
||||
pellx(D)
|
||||
@@ -1435,7 +1467,7 @@ sumtimes.cal
|
||||
the list or matrix to use. The doalltimes() function will run
|
||||
all of the sumtimes tests. For example:
|
||||
|
||||
doalltimes(1e6);
|
||||
doalltimes(1e6);
|
||||
|
||||
|
||||
surd.cal
|
||||
|
@@ -474,7 +474,7 @@ define best_mul2()
|
||||
*/
|
||||
while (low+1 < high) {
|
||||
|
||||
/* try the mid-point */
|
||||
/* try the mid-point */
|
||||
mid = int((low+high)/2);
|
||||
if (config("user_debug") > 0) {
|
||||
printf("testing multiply alg1/alg2 ratio for len = %d\n", mid);
|
||||
@@ -956,7 +956,7 @@ define best_sq2()
|
||||
*/
|
||||
while (low+1 < high) {
|
||||
|
||||
/* try the mid-point */
|
||||
/* try the mid-point */
|
||||
mid = int((low+high)/2);
|
||||
if (config("user_debug") > 0) {
|
||||
printf("testing square alg1/alg2 ratio for len = %d\n", mid);
|
||||
@@ -1455,7 +1455,7 @@ define best_pow2()
|
||||
*/
|
||||
while (low+1 < high) {
|
||||
|
||||
/* try the mid-point */
|
||||
/* try the mid-point */
|
||||
mid = int((low+high)/2);
|
||||
if (config("user_debug") > 0) {
|
||||
printf("testing pow2 alg1/alg2 ratio for len = %d\n", mid);
|
||||
|
@@ -40,7 +40,7 @@ define Z(x, eps_term)
|
||||
|
||||
/* obtain the error term */
|
||||
if (isnull(eps_term)) {
|
||||
eps = epsilon();
|
||||
eps = epsilon();
|
||||
} else {
|
||||
eps = eps_term;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ define P(x, eps_term)
|
||||
|
||||
/* obtain the error term */
|
||||
if (isnull(eps_term)) {
|
||||
eps = epsilon();
|
||||
eps = epsilon();
|
||||
} else {
|
||||
eps = eps_term;
|
||||
}
|
||||
|
22
cal/dms.cal
22
cal/dms.cal
@@ -188,7 +188,7 @@ define dms_abs(a)
|
||||
|
||||
/* firewall - just absolute value non dms objects */
|
||||
if (! istype(a, ans)) {
|
||||
return abs(a);
|
||||
return abs(a);
|
||||
}
|
||||
|
||||
/* compute degrees */
|
||||
@@ -352,24 +352,8 @@ define fixdms(a)
|
||||
quit "attempt to fix a non dms object";
|
||||
}
|
||||
|
||||
/* force minutes to be integral */
|
||||
a.min += frac(a.deg) * 60;
|
||||
a.deg = int(a.deg);
|
||||
|
||||
/* force degrees to be integral */
|
||||
a.sec += frac(a.min) * 60;
|
||||
a.min = int(a.min);
|
||||
|
||||
/* carry excess seconds into minutes */
|
||||
a.min += a.sec // 60;
|
||||
a.sec %= 60;
|
||||
|
||||
/* carry excess minutes into degrees */
|
||||
a.deg += a.min // 60;
|
||||
a.min %= 60;
|
||||
|
||||
/* round degrees :-) */
|
||||
a.deg %= 360;
|
||||
/* use builtin d2dms function */
|
||||
d2dms(a.deg + a.min/60 + a.sec/3600, a.deg, a.min, a.sec),;
|
||||
|
||||
/* return normalized result */
|
||||
return a;
|
||||
|
@@ -157,7 +157,7 @@ define dotest(dotest_file, dotest_code = 0, dotest_maxcond = -1)
|
||||
* test the close of the line file
|
||||
*/
|
||||
printf("%d-: detected %d error condition(s), many of which may be OK\n",
|
||||
dotest_code, dotest_old_errcount-dotest_errcnt);
|
||||
dotest_code, dotest_old_errcount-dotest_errcnt);
|
||||
printf("%d-: closing line file: %d\n", dotest_code, dotest_file);
|
||||
fclose(dotest_f_file);
|
||||
|
||||
|
@@ -56,7 +56,7 @@ define __CZ__factor_factorial(n,start){
|
||||
if(start){
|
||||
if(!isint(start) && start < 0 && start > n)
|
||||
return newerror("__CZ__factor_factorial(n,start): value of "
|
||||
"parameter 'start' out of range");
|
||||
"parameter 'start' out of range");
|
||||
if(start == n && isprime(n)){
|
||||
prime_list = mat[1 , 2];
|
||||
prime_list[0,0] = n;
|
||||
@@ -64,7 +64,7 @@ define __CZ__factor_factorial(n,start){
|
||||
}
|
||||
else if(!isprime(start) && nextprime(start) >n)
|
||||
return newerror("__CZ__factor_factorial(n,start): value of parameter "
|
||||
"'start' out of range");
|
||||
"'start' out of range");
|
||||
else{
|
||||
if(!isprime(start)) prime = nextprime(start);
|
||||
else prime = start;
|
||||
@@ -225,11 +225,11 @@ define __CZ__multiply_factored_factorial(matrix,stop){
|
||||
|
||||
if(!ismat(matrix))
|
||||
return newerror("__CZ__multiply_factored_factorial(matrix): "
|
||||
"argument matrix not a matrix ");
|
||||
"argument matrix not a matrix ");
|
||||
if(!matrix[0,0])
|
||||
return
|
||||
newerror("__CZ__multiply_factored_factorial(matrix): "
|
||||
"matrix[0,0] is null/0");
|
||||
"matrix[0,0] is null/0");
|
||||
|
||||
if(!isnull(stop))
|
||||
pix = stop;
|
||||
@@ -376,7 +376,7 @@ define bigcatalan(n){
|
||||
|
||||
/*
|
||||
df(-111) = -1/3472059605858239446587523014902616804783337112829102414124928
|
||||
7753332469144201839599609375
|
||||
7753332469144201839599609375
|
||||
|
||||
df(-3+1i) = 0.12532538977287649201-0.0502372106177184607i
|
||||
df(2n + 1) = (2*n)!/(n!*2^n)
|
||||
@@ -427,7 +427,7 @@ define doublefactorial(n){
|
||||
*/
|
||||
eps=epsilon(epsilon()*1e-2);
|
||||
ret = 2^(n/2-1/4 * cos(pi()* n)+1/4) * pi()^(1/4 *
|
||||
cos(pi()* n)-1/4)* gamma(n/2+1);
|
||||
cos(pi()* n)-1/4)* gamma(n/2+1);
|
||||
epsilon(eps);
|
||||
return ret;
|
||||
}
|
||||
|
22
cal/hms.cal
22
cal/hms.cal
@@ -188,7 +188,7 @@ define hms_abs(a)
|
||||
|
||||
/* firewall - just absolute value non hms objects */
|
||||
if (! istype(a, ans)) {
|
||||
return abs(a);
|
||||
return abs(a);
|
||||
}
|
||||
|
||||
/* compute hours */
|
||||
@@ -352,24 +352,8 @@ define fixhms(a)
|
||||
quit "attempt to fix a non hms object";
|
||||
}
|
||||
|
||||
/* force minutes to be integral */
|
||||
a.min += frac(a.hour) * 60;
|
||||
a.hour = int(a.hour);
|
||||
|
||||
/* force hours to be integral */
|
||||
a.sec += frac(a.min) * 60;
|
||||
a.min = int(a.min);
|
||||
|
||||
/* carry excess seconds into minutes */
|
||||
a.min += a.sec // 60;
|
||||
a.sec %= 60;
|
||||
|
||||
/* carry excess minutes into hours */
|
||||
a.hour += a.min // 60;
|
||||
a.min %= 60;
|
||||
|
||||
/* round hours by day */
|
||||
a.hour %= 24;
|
||||
/* use builtin h2hms function */
|
||||
h2hms(a.hour + a.min/60 + a.sec/3600, a.hour, a.min, a.sec),;
|
||||
|
||||
/* return normalized result */
|
||||
return a;
|
||||
|
@@ -156,7 +156,7 @@ define be2file(v, filename)
|
||||
*/
|
||||
octlen = int((highbit(v)+8) / 8);
|
||||
for (i=octlen-1; i >= 0; --i) {
|
||||
fputc(fd, char(v >> (i*8)));
|
||||
fputc(fd, char(v >> (i*8)));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -731,7 +731,7 @@ rodseth_xhn(x, h, n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Check for jacobi(x-2, h*2^n-1) == 1 (Ref4, condition 1) part 1
|
||||
*/
|
||||
testval = h*2^n-1;
|
||||
@@ -739,7 +739,7 @@ rodseth_xhn(x, h, n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Check for jacobi(x+2, h*2^n-1) == -1 (Ref4, condition 1) part 2
|
||||
*/
|
||||
if (jacobi(x+2, testval) != -1) {
|
||||
|
641
cal/palindrome.cal
Normal file
641
cal/palindrome.cal
Normal file
@@ -0,0 +1,641 @@
|
||||
/*
|
||||
* palindrome - palindrome utilities
|
||||
*
|
||||
* Copyright (C) 2021 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: 2021/11/06 14:35:37
|
||||
* File existed as early as: 2021
|
||||
*
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* digitof - return the a digit of a value
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* val value to find a digit of
|
||||
* place digit place
|
||||
*
|
||||
* returns:
|
||||
* value (>= 0 and < 10) that is the place-th digit of val
|
||||
* or 0 if place is not a digit of val
|
||||
*/
|
||||
define digitof(val, place)
|
||||
{
|
||||
local d; /* length of val in digits */
|
||||
|
||||
/* determine length */
|
||||
d = digits(val);
|
||||
|
||||
/* firewall - return 0 if digit place doesn't exist */
|
||||
if (place < 1 || place > d) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return the place-th digit of val as a single digit */
|
||||
return (val // (10^(place-1))) % 10;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* copalplace - determine the other place in a palindrome
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* d digits of a value
|
||||
* place digit place
|
||||
*
|
||||
* returns:
|
||||
* given palindrome val, the other digit paired with place
|
||||
* or 0 if place is not a digit of val
|
||||
*/
|
||||
define copalplace(d, place)
|
||||
{
|
||||
/* firewall - return 0 if digit place doesn't exist */
|
||||
if (d < 1 || place < 1 || place > d) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return digit coplace */
|
||||
return d+1 - place;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* upperhalf - return the upper half of a palindrome
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* NOTE: When the value has an odd number of digits, the upper half
|
||||
* includes the middle digit.
|
||||
*
|
||||
* given:
|
||||
* val a value
|
||||
*
|
||||
* returns:
|
||||
* the upper half digits of a value
|
||||
*/
|
||||
define upperhalf(val)
|
||||
{
|
||||
local d; /* length of val in digits */
|
||||
local halfd; /* length of upper hand of val */
|
||||
|
||||
/* determine length */
|
||||
d = digits(val);
|
||||
halfd = d // 2;
|
||||
|
||||
/* return upper half */
|
||||
return (val // 10^halfd);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* mkpal - make a value into a palindrome
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* val a value
|
||||
*
|
||||
* returns:
|
||||
* val as a palindrome with lower half being reverse digits of val
|
||||
*/
|
||||
define mkpal(val)
|
||||
{
|
||||
local d; /* length of val in digits */
|
||||
local i; /* counter */
|
||||
local ret; /* palindrome being formed */
|
||||
|
||||
/* determine length */
|
||||
d = digits(val);
|
||||
|
||||
/* insert digits in reverse order at the bottom */
|
||||
ret = val;
|
||||
for (i=0; i < d; ++i) {
|
||||
ret = ret*10 + digit(val, i);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* mkpalmiddigit - make a value into a palindrome with a middle digit
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* val a value
|
||||
* digit the digit to put into the middle of the palindrome
|
||||
*
|
||||
* returns:
|
||||
* val as a palindrome with lower half being reverse digits of val
|
||||
* and digit as a middle digit
|
||||
*/
|
||||
define mkpalmiddigit(val, digit)
|
||||
{
|
||||
local d; /* length of val in digits */
|
||||
local i; /* counter */
|
||||
local ret; /* palindrome being formed */
|
||||
|
||||
/* determine length */
|
||||
d = digits(val);
|
||||
|
||||
/* insert digits in reverse order at the bottom */
|
||||
ret = val*10 + digit;
|
||||
for (i=0; i < d; ++i) {
|
||||
ret = ret*10 + digit(val, i);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ispal - determine if a value is a palindrome
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* val a value
|
||||
*
|
||||
* returns:
|
||||
* 1 ==> val is a palindrome
|
||||
* 0 ==> val is NOT a palindrome
|
||||
*/
|
||||
define ispal(val)
|
||||
{
|
||||
local half; /* upper half of digits of val */
|
||||
local digit; /* middle digit */
|
||||
|
||||
/* case: val has an even number of digits */
|
||||
if (iseven(digits(val))) {
|
||||
|
||||
/* test palindrome-ness */
|
||||
return (val == mkpal(upperhalf(val)));
|
||||
|
||||
/* case: val can an odd number of digits */
|
||||
} else {
|
||||
|
||||
/* test palindrome-ness */
|
||||
half = upperhalf(val);
|
||||
digit = half % 10;
|
||||
half //= 10;
|
||||
return (val == mkpalmiddigit(half, digit));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* palnextpal - return next palindrome from a known palindrome
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* pal a palindrome
|
||||
*
|
||||
* returns:
|
||||
* next palindrome > pal
|
||||
*/
|
||||
define palnextpal(pal)
|
||||
{
|
||||
local paldigits; /* digits in pal */
|
||||
local half; /* upper half of newval */
|
||||
local newhalf; /* half+1 */
|
||||
local newpal; /* new palindrome */
|
||||
|
||||
/* case: negative palindrome */
|
||||
if (pal < 0) {
|
||||
return -(palprevpal(-pal));
|
||||
}
|
||||
|
||||
/*
|
||||
* start with upper half
|
||||
*/
|
||||
half = upperhalf(pal);
|
||||
|
||||
/*
|
||||
* prep to find a larger palindrome
|
||||
*/
|
||||
newhalf = half+1;
|
||||
|
||||
/*
|
||||
* form palindrome from new upper half
|
||||
*
|
||||
* We need to watch for the corner case where changing the
|
||||
* half changes the number of digits as this will impact
|
||||
* or even/odd number of digits processing.
|
||||
*/
|
||||
paldigits = digits(pal);
|
||||
if (digits(newhalf) == digits(half)) {
|
||||
/* no change in half digits: process as normal */
|
||||
if (iseven(paldigits)) {
|
||||
newpal = mkpal(newhalf);
|
||||
} else {
|
||||
newpal = mkpalmiddigit(newhalf // 10, newhalf % 10);
|
||||
}
|
||||
} else {
|
||||
/* change in half digits: process as opposite */
|
||||
if (iseven(paldigits)) {
|
||||
newpal = mkpalmiddigit(newhalf // 10, newhalf % 10);
|
||||
} else {
|
||||
newpal = mkpal(newhalf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* return the new palindrome
|
||||
*/
|
||||
return newpal;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nextpal - return next palindrome from a value
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* val a value
|
||||
*
|
||||
* returns:
|
||||
* next palindrome > val
|
||||
*/
|
||||
define nextpal(val)
|
||||
{
|
||||
local newval; /* val+1 */
|
||||
local newvaldigits; /* digits in newval */
|
||||
local half; /* upper half of newval */
|
||||
local pal; /* palindrome test value */
|
||||
local newpal; /* new palindrome */
|
||||
|
||||
/* case: negative value */
|
||||
if (val < 0) {
|
||||
return -(prevpal(-val));
|
||||
}
|
||||
|
||||
/*
|
||||
* start looking from a larger value
|
||||
*/
|
||||
newval = val+1;
|
||||
newvaldigits = digits(newval);
|
||||
|
||||
/* case: single digit palindrome */
|
||||
if (newvaldigits < 2) {
|
||||
return newval;
|
||||
}
|
||||
|
||||
/*
|
||||
* start with next upper half
|
||||
*/
|
||||
half = upperhalf(newval);
|
||||
|
||||
/*
|
||||
* form palindrome from upper half
|
||||
*
|
||||
* We need to deal with even vs. odd digit counts
|
||||
* when forming a palindrome from a half as the
|
||||
* half may not or may include the middle digit.
|
||||
*/
|
||||
if (iseven(newvaldigits)) {
|
||||
pal = mkpal(half);
|
||||
} else {
|
||||
pal = mkpalmiddigit(half // 10, half % 10);
|
||||
}
|
||||
|
||||
/*
|
||||
* case: we found a larger palindrome, we are done
|
||||
*/
|
||||
if (pal > val) {
|
||||
return pal;
|
||||
}
|
||||
|
||||
/*
|
||||
* we need to find an even larger palindrome
|
||||
*/
|
||||
newpal = palnextpal(pal);
|
||||
|
||||
/*
|
||||
* return the new palindrome
|
||||
*/
|
||||
return newpal;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* palprevpal - return previous palindrome from a palindrome
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* pal a palindrome
|
||||
*
|
||||
* returns:
|
||||
* previous palindrome < pal
|
||||
*/
|
||||
define palprevpal(pal)
|
||||
{
|
||||
local paldigits; /* digits in pal */
|
||||
local half; /* upper half of newval */
|
||||
local newhalf; /* half+1 */
|
||||
local newpal; /* new palindrome */
|
||||
|
||||
/* case: negative value */
|
||||
if (pal < 0) {
|
||||
return -(palnextpal(-pal));
|
||||
}
|
||||
|
||||
/* case: single digit palindrome */
|
||||
if (pal < 10) {
|
||||
newpal = pal-1;
|
||||
return newpal;
|
||||
}
|
||||
|
||||
/* case: 10 or 11 */
|
||||
if (pal < 12) {
|
||||
newpal = 9;
|
||||
return newpal;
|
||||
}
|
||||
|
||||
/*
|
||||
* start with upper half
|
||||
*/
|
||||
half = upperhalf(pal);
|
||||
|
||||
/*
|
||||
* prep to find a smaller palindrome
|
||||
*/
|
||||
newhalf = half-1;
|
||||
|
||||
/*
|
||||
* form palindrome from new upper half
|
||||
*
|
||||
* We need to watch for the corner case where changing the
|
||||
* half changes the number of digits as this will impact
|
||||
* or even/odd number of digits processing.
|
||||
*/
|
||||
paldigits = digits(pal);
|
||||
if (digits(newhalf) == digits(half)) {
|
||||
/* no change in half digits: process as normal */
|
||||
if (iseven(paldigits)) {
|
||||
newpal = mkpal(newhalf);
|
||||
} else {
|
||||
newpal = mkpalmiddigit(newhalf // 10, newhalf % 10);
|
||||
}
|
||||
} else {
|
||||
/* change in half digits: process as opposite */
|
||||
if (iseven(paldigits)) {
|
||||
newpal = mkpalmiddigit(newhalf // 10, newhalf % 10);
|
||||
} else {
|
||||
newpal = mkpal(newhalf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* return the new palindrome
|
||||
*/
|
||||
return newpal;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* prevpal - return previous palindrome from a value
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* val a value
|
||||
*
|
||||
* returns:
|
||||
* previous palindrome < val
|
||||
*/
|
||||
define prevpal(val)
|
||||
{
|
||||
local newval; /* val-1 */
|
||||
local newvaldigits; /* digits in newval */
|
||||
local half; /* upper half of newval */
|
||||
local pal; /* palindrome test value */
|
||||
local newpal; /* new palindrome */
|
||||
|
||||
/* case: negative value */
|
||||
if (val < 0) {
|
||||
return -(nextpal(-val));
|
||||
}
|
||||
|
||||
/*
|
||||
* start looking from a smaller value
|
||||
*/
|
||||
newval = val-1;
|
||||
newvaldigits = digits(newval);
|
||||
|
||||
/* case: single digit palindrome */
|
||||
if (newvaldigits < 2) {
|
||||
return newval;
|
||||
}
|
||||
|
||||
/*
|
||||
* start with previous upper half
|
||||
*/
|
||||
half = upperhalf(newval);
|
||||
|
||||
/*
|
||||
* form palindrome from upper half
|
||||
*
|
||||
* We need to deal with even vs. odd digit counts
|
||||
* when forming a palindrome from a half as the
|
||||
* half may not or may include the middle digit.
|
||||
*/
|
||||
if (iseven(newvaldigits)) {
|
||||
pal = mkpal(half);
|
||||
} else {
|
||||
pal = mkpalmiddigit(half // 10, half % 10);
|
||||
}
|
||||
|
||||
/*
|
||||
* case: we found a smaller palindrome, we are done
|
||||
*/
|
||||
if (pal < val) {
|
||||
return pal;
|
||||
}
|
||||
|
||||
/*
|
||||
* we need to find an even smaller palindrome
|
||||
*/
|
||||
newpal = palprevpal(pal);
|
||||
|
||||
/*
|
||||
* return the new palindrome
|
||||
*/
|
||||
return newpal;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nextprimepal - return next palindrome that is a (highly probable) prime
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* val a value
|
||||
*
|
||||
* returns:
|
||||
* next palindrome (highly probable) prime > val
|
||||
*/
|
||||
define nextprimepal(val)
|
||||
{
|
||||
local pal; /* palindrome test value */
|
||||
local dpal; /* digits in pal */
|
||||
|
||||
/*
|
||||
* pre-start under the next palindrome
|
||||
*/
|
||||
pal = nextpal(val-1);
|
||||
|
||||
/*
|
||||
* loop until we find a (highly probable) prime or 0
|
||||
*/
|
||||
do {
|
||||
|
||||
/* case: negative values and tiny values */
|
||||
if (pal < 2) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute the next palindrome
|
||||
*/
|
||||
pal = palnextpal(pal);
|
||||
dpal = digits(pal);
|
||||
|
||||
/* case: 11 is the only prime palindrome with even digit count */
|
||||
if (pal == 11) {
|
||||
return 11;
|
||||
}
|
||||
|
||||
/* case: even number of digits and not 11 */
|
||||
if (iseven(dpal)) {
|
||||
|
||||
/*
|
||||
* Except for 11 (which is handled above already), there are
|
||||
* no prime palindrome with even digits. So we need to
|
||||
* increase the digit count and work with that larger palindrome.
|
||||
*/
|
||||
pal = nextpal(10^dpal);
|
||||
}
|
||||
|
||||
/* case: palindrome is even or ends in 5 */
|
||||
if (iseven(pal % 10) || (pal%10 == 10/2)) {
|
||||
|
||||
/*
|
||||
* we need to increase the bottom and top digits
|
||||
* so that we have a chance to be prime
|
||||
*/
|
||||
pal += (1 + 10^(dpal-1));
|
||||
}
|
||||
if (config("resource_debug") & 0x8) {
|
||||
print "DEBUG: nextprimepal:", pal;
|
||||
}
|
||||
} while (ptest(pal) == 0 && pal > 0);
|
||||
|
||||
/* return palindrome that his (highly probable) prime or 0 */
|
||||
return pal;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* prevprimepal - return prev palindrome that is a (highly probable) prime
|
||||
*
|
||||
* NOTE: We assume base 10 digits and place 1 is the units digit.
|
||||
*
|
||||
* given:
|
||||
* val a value
|
||||
*
|
||||
* returns:
|
||||
* prev palindrome (highly probable) prime < val or 0
|
||||
*/
|
||||
define prevprimepal(val)
|
||||
{
|
||||
local pal; /* palindrome test value */
|
||||
local dpal; /* digits in pal */
|
||||
|
||||
/*
|
||||
* pre-start over the previous palindrome
|
||||
*/
|
||||
pal = prevpal(val+1);
|
||||
|
||||
/*
|
||||
* loop until we find a (highly probable) prime or 0
|
||||
*/
|
||||
do {
|
||||
|
||||
/*
|
||||
* case: single digit values are always palindromes
|
||||
*/
|
||||
if (val < 10) {
|
||||
/*
|
||||
* The prevcand() call will return 0 if there is no previous prime
|
||||
* such as the case when val < 2.
|
||||
*/
|
||||
return prevcand(pal);
|
||||
}
|
||||
|
||||
/*
|
||||
* compute the previous palindrome
|
||||
*/
|
||||
pal = palprevpal(pal);
|
||||
dpal = digits(pal);
|
||||
|
||||
/* case: 11 is the only prime palindrome with even digit count */
|
||||
if (pal == 11) {
|
||||
return 11;
|
||||
}
|
||||
|
||||
/* case: 2 digit palindrome and not 11 */
|
||||
if (dpal == 2) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
/* case: even number of digits */
|
||||
if (iseven(dpal)) {
|
||||
|
||||
/*
|
||||
* Except for 11 (which is handled above already), there are
|
||||
* no prime palindrome with even digits. So we need to
|
||||
* decrease the digit count and work with that smaller palindrome.
|
||||
*/
|
||||
pal = prevpal(10^(dpal-1));
|
||||
}
|
||||
|
||||
/* case: palindrome is even or ends in 5 */
|
||||
if (iseven(pal % 10) || (pal%10 == 10/2)) {
|
||||
|
||||
/*
|
||||
* we need to decrease the bottom and top digits
|
||||
* so that we have a chance to be prime
|
||||
*/
|
||||
pal -= (1 + 10^(dpal-1));
|
||||
}
|
||||
if (config("resource_debug") & 0x8) {
|
||||
print "DEBUG: prevprimepal:", pal;
|
||||
}
|
||||
} while (ptest(pal) == 0 && pal > 0);
|
||||
|
||||
/* return palindrome that his (highly probable) prime or 0 */
|
||||
return pal;
|
||||
}
|
739
cal/regress.cal
739
cal/regress.cal
@@ -775,7 +775,9 @@ print '016: parsed test_bignums()';
|
||||
/*
|
||||
* Test many of the built-in functions.
|
||||
*
|
||||
* See test_functionss() starting at test 9000 for more built-in function tests.
|
||||
* See test_functions() (test 700 - 1238) for other built-in function tests.
|
||||
* See test_functions2() (test 9000 - 9063) for other built-in function tests.
|
||||
* See test_functions3() (test 9100 - 9214) for other built-in function tests.
|
||||
*/
|
||||
define test_functions()
|
||||
{
|
||||
@@ -1881,96 +1883,298 @@ define test_mode()
|
||||
vrfy(tmp == "octal", '1620: tmp == "octal"');
|
||||
vrfy(base() == 2, '1621: base() == 2');
|
||||
|
||||
tmp = config("mode", "real");
|
||||
print '1622: tmp = config("mode", "real")';
|
||||
tmp = config("mode", "eng");
|
||||
print '1622: tmp = config("mode", "eng")';
|
||||
vrfy(tmp == "binary", '1623: tmp == "binary"');
|
||||
vrfy(base() == 1000, '1624: base() == 1000');
|
||||
|
||||
tmp = config("mode", "real");
|
||||
print '1625: tmp = config("mode", "real")';
|
||||
vrfy(tmp == "engineering", '1626: tmp == "engineering"');
|
||||
|
||||
tmp = base(1/3);
|
||||
print '1624: tmp = base(1/3)';
|
||||
print '1627: tmp = base(1/3)';
|
||||
vrfy(config("mode") == "fraction",
|
||||
'1625: config("mode") == "fraction"');
|
||||
'1628: config("mode") == "fraction"');
|
||||
|
||||
tmp = base(-10);
|
||||
print '1626: tmp = base(-10)';
|
||||
print '1629: tmp = base(-10)';
|
||||
vrfy(config("mode") == "integer",
|
||||
'1627: config("mode") == "integer"');
|
||||
'1630: config("mode") == "integer"');
|
||||
|
||||
tmp = base(10);
|
||||
print '1628: tmp = base(10)';
|
||||
vrfy(config("mode") == "real", '1629: config("mode") == "real"');
|
||||
print '1631: tmp = base(10)';
|
||||
vrfy(config("mode") == "real", '1632: config("mode") == "real"');
|
||||
|
||||
tmp = base(1e20);
|
||||
print '1630: tmp = base(1e20)';
|
||||
print '1633: tmp = base(1e20)';
|
||||
vrfy(config("mode") == "scientific",
|
||||
'1631: config("mode") == "scientific"');
|
||||
'1634: config("mode") == "scientific"');
|
||||
|
||||
tmp = base(16);
|
||||
print '1632: tmp = base(16)';
|
||||
print '1635: tmp = base(16)';
|
||||
vrfy(config("mode") == "hexadecimal", \
|
||||
'1633: config("mode") == "hexadecimal"');
|
||||
'1636: config("mode") == "hexadecimal"');
|
||||
|
||||
tmp = base(8);
|
||||
print '1634: tmp = base(8)';
|
||||
vrfy(config("mode") == "octal", '1635: config("mode") == "octal"');
|
||||
print '1637: tmp = base(8)';
|
||||
vrfy(config("mode") == "octal", '1638: config("mode") == "octal"');
|
||||
|
||||
tmp = base(2);
|
||||
print '1636: tmp = base(2)';
|
||||
vrfy(config("mode") == "binary",'1637: config("mode") == "binary"');
|
||||
print '1639: tmp = base(2)';
|
||||
vrfy(config("mode") == "binary",'1640: config("mode") == "binary"');
|
||||
|
||||
tmp = base(1000);
|
||||
print '1641: tmp = base(1000)';
|
||||
vrfy(config("mode") == "engineering",
|
||||
'1642: config("mode") == "engineering"');
|
||||
|
||||
tmp = base(1/3);
|
||||
print '1643: tmp = base(1/3)';
|
||||
vrfy(str(0x80000000) == "2147483648", \
|
||||
'1644: str(0x8000000) == \"2147483648\"');
|
||||
vrfy(str(0xffffffff) == "4294967295", \
|
||||
'1645: str(0xffffffff) == \"4294967295\"');
|
||||
vrfy(str(3e9) == "3000000000", \
|
||||
'1646: str(3e9) == \"3000000000\"');
|
||||
vrfy(str(1/3) == "1/3", \
|
||||
'1647: str(1/3) == \"1/3\"');
|
||||
vrfy(str(2e8) == "200000000", \
|
||||
'1648: str(2e8) == \"200000000"');
|
||||
vrfy(str(200e6) == "200000000", \
|
||||
'1649: str(200e6) == \"200000000"');
|
||||
vrfy(str(0b100111) == "39", \
|
||||
'1650: str(0b100111) == \"39"');
|
||||
vrfy(str(07543) == "3939", \
|
||||
'1651: str(07543) == \"3939"');
|
||||
vrfy(str(7543) == "7543", \
|
||||
'1652: str(7543) == \"7543"');
|
||||
|
||||
tmp = base(8);
|
||||
print '1638: tmp = base(8)';
|
||||
print '1653: tmp = base(8)';
|
||||
vrfy(str(0x80000000) == "020000000000", \
|
||||
'1639: str(0x8000000) == \"020000000000\"');
|
||||
'1654: str(0x8000000) == \"020000000000\"');
|
||||
vrfy(str(0xffffffff) == "037777777777", \
|
||||
'1640: str(0xffffffff) == \"037777777777\"');
|
||||
'1655: str(0xffffffff) == \"037777777777\"');
|
||||
vrfy(str(3e9) == "026264057000", \
|
||||
'1641: str(3e9) == \"026264057000\"');
|
||||
'1656: str(3e9) == \"026264057000\"');
|
||||
vrfy(str(1/3) == "1/3", \
|
||||
'1657: str(1/3) == \"1/3\"');
|
||||
vrfy(str(2e8) == "01372741000", \
|
||||
'1658: str(2e8) == \"01372741000"');
|
||||
vrfy(str(200e6) == "01372741000", \
|
||||
'1659: str(200e6) == \"01372741000"');
|
||||
vrfy(str(0b100111) == "047", \
|
||||
'1660: str(0b100111) == \"047"');
|
||||
vrfy(str(07543) == "07543", \
|
||||
'1661: str(07543) == \"07543"');
|
||||
vrfy(str(7543) == "016567", \
|
||||
'1662: str(7543) == \"016567"');
|
||||
|
||||
tmp = base(16);
|
||||
print '1642: tmp = base(16)';
|
||||
print '1663: tmp = base(16)';
|
||||
vrfy(str(0x80000000) == "0x80000000", \
|
||||
'1643: str(0x8000000) == \"0x80000000\"');
|
||||
'1664: str(0x8000000) == \"0x80000000\"');
|
||||
vrfy(str(0xffffffff) == "0xffffffff", \
|
||||
'1644: str(0xffffffff) == \"0xffffffff\"');
|
||||
'1665: str(0xffffffff) == \"0xffffffff\"');
|
||||
vrfy(str(3e9) == "0xb2d05e00", \
|
||||
'1645: str(3e9) == \"0xb2d05e00\"');
|
||||
'1666: str(3e9) == \"0xb2d05e00\"');
|
||||
vrfy(str(1/3) == "1/3", \
|
||||
'1667: str(1/3) == \"1/3\"');
|
||||
vrfy(str(2e8) == "0xbebc200", \
|
||||
'1668: str(2e8) == \"0xbebc200"');
|
||||
vrfy(str(200e6) == "0xbebc200", \
|
||||
'1669: str(200e6) == \"0xbebc200"');
|
||||
vrfy(str(0b100111) == "0x27", \
|
||||
'1670: str(0b100111) == \"0x27"');
|
||||
vrfy(str(07543) == "0xf63", \
|
||||
'1671: str(07543) == \"0xf63"');
|
||||
vrfy(str(7543) == "0x1d77", \
|
||||
'1672: str(7543) == \"0x1d77"');
|
||||
|
||||
tmp = base(2);
|
||||
print '1673: tmp = base(2)';
|
||||
vrfy(str(0x80000000) == "0b10000000000000000000000000000000", \
|
||||
'1674: str(0x8000000) == \"0b10000000000000000000000000000000\"');
|
||||
vrfy(str(0xffffffff) == "0b11111111111111111111111111111111", \
|
||||
'1675: str(0xffffffff) == \"0b11111111111111111111111111111111\"');
|
||||
vrfy(str(3e9) == "0b10110010110100000101111000000000", \
|
||||
'1676: str(3e9) == \"0b10110010110100000101111000000000\"');
|
||||
vrfy(str(1/3) == "1/0b11", \
|
||||
'1677: str(1/3) == \"1/0b11\"');
|
||||
vrfy(str(2e8) == "0b1011111010111100001000000000", \
|
||||
'1678: str(2e8) == \"0b1011111010111100001000000000"');
|
||||
vrfy(str(200e6) == "0b1011111010111100001000000000", \
|
||||
'1679: str(200e6) == \"0b1011111010111100001000000000"');
|
||||
vrfy(str(0b100111) == "0b100111", \
|
||||
'1680: str(0b100111) == \"0b100111"');
|
||||
vrfy(str(07543) == "0b111101100011", \
|
||||
'1681: str(07543) == \"0b111101100011"');
|
||||
vrfy(str(7543) == "0b1110101110111", \
|
||||
'1682: str(7543) == \"0b1110101110111"');
|
||||
|
||||
tmp = base(1e20);
|
||||
print '1683: tmp = base(1e20)';
|
||||
vrfy(str(0x80000000) == "2.147483648e9", \
|
||||
'1684: str(0x8000000) == \"2.147483648e9\"');
|
||||
vrfy(str(0xffffffff) == "4.294967295e9", \
|
||||
'1685: str(0xffffffff) == \"4.294967295e9\"');
|
||||
vrfy(str(3e9) == "3e9", \
|
||||
'1686: str(3e9) == \"3e9\"');
|
||||
vrfy(str(1/3) == "~3.33333333333333333333e-1", \
|
||||
'1687: str(1/3) == \"~3.33333333333333333333e-1\"');
|
||||
vrfy(str(2e8) == "2e8", \
|
||||
'1688: str(2e8) == \"2e8"');
|
||||
vrfy(str(200e6) == "2e8", \
|
||||
'1689: str(200e6) == \"2e8"');
|
||||
vrfy(str(0b100111) == "3.9e1", \
|
||||
'1690: str(0b100111) == \"3.9e1"');
|
||||
vrfy(str(07543) == "3.939e3", \
|
||||
'1691: str(07543) == \"3.939e3"');
|
||||
vrfy(str(7543) == "7.543e3", \
|
||||
'1692: str(7543) == \"7.543e3"');
|
||||
|
||||
tmp = base(1000);
|
||||
print '1693: tmp = base(1000)';
|
||||
vrfy(str(0x80000000) == "2.147483648e9", \
|
||||
'1694: str(0x8000000) == \"2.147483648e9"');
|
||||
vrfy(str(0xffffffff) == "4.294967295e9", \
|
||||
'1695: str(0xffffffff) == \"4.294967295e9\"');
|
||||
vrfy(str(3e9) == "3e9", \
|
||||
'1696: str(3e9) == \"3e9\"');
|
||||
vrfy(str(1/3) == "~333.33333333333333333333e-3", \
|
||||
'1697: str(1/3) == \"~333.33333333333333333333e-3\"');
|
||||
vrfy(str(2e8) == "200e6", \
|
||||
'1698: str(2e8) == \"200e6"');
|
||||
vrfy(str(200e6) == "200e6", \
|
||||
'1699: str(200e6) == \"200e6"');
|
||||
vrfy(str(0b100111) == "39", \
|
||||
'1700: str(0b100111) == \"39"');
|
||||
vrfy(str(07543) == "3.939e3", \
|
||||
'1701: str(07543) == \"3.939e3"');
|
||||
vrfy(str(7543) == "7.543e3", \
|
||||
'1702: str(7543) == \"7.543e3"');
|
||||
|
||||
tmp = base(-10);
|
||||
print '1703: tmp = base(-10)';
|
||||
vrfy(str(0x80000000) == "2147483648", \
|
||||
'1704: str(0x8000000) == \"2147483648\"');
|
||||
vrfy(str(0xffffffff) == "4294967295", \
|
||||
'1705: str(0xffffffff) == \"4294967295\"');
|
||||
vrfy(str(3e9) == "3000000000", \
|
||||
'1706: str(3e9) == \"3000000000\"');
|
||||
vrfy(str(1/3) == "~0", \
|
||||
'1707: str(1/3) == \"~0\"');
|
||||
vrfy(str(2e8) == "200000000", \
|
||||
'1708: str(2e8) == \"200000000"');
|
||||
vrfy(str(200e6) == "200000000", \
|
||||
'1709: str(200e6) == \"200000000"');
|
||||
vrfy(str(0b100111) == "39", \
|
||||
'1710: str(0b100111) == \"39"');
|
||||
vrfy(str(07543) == "3939", \
|
||||
'1711: str(07543) == \"3939"');
|
||||
vrfy(str(7543) == "7543", \
|
||||
'1712: str(7543) == \"7543"');
|
||||
|
||||
tmp = base(10);
|
||||
print '1646: tmp = base(10)';
|
||||
vrfy(config("mode") == "real", \
|
||||
'1647: config("mode") == "real"');
|
||||
|
||||
print '1713: tmp = base(10)';
|
||||
vrfy(str(0x80000000) == "2147483648", \
|
||||
'1648: str(0x80000000) == \"2147483648\"');
|
||||
'1714: str(0x8000000) == \"2147483648\"');
|
||||
vrfy(str(0xffffffff) == "4294967295", \
|
||||
'1649: str(0xffffffff) == \"4294967295\"');
|
||||
'1715: str(0xffffffff) == \"4294967295\"');
|
||||
vrfy(str(3e9) == "3000000000", \
|
||||
'1650: str(3e9) == \"3000000000\"');
|
||||
'1716: str(3e9) == \"3000000000\"');
|
||||
vrfy(str(1/3) == "~0.33333333333333333333", \
|
||||
'1717: str(1/3) == \"~0.33333333333333333333"');
|
||||
vrfy(str(2e8) == "200000000", \
|
||||
'1718: str(2e8) == \"200000000"');
|
||||
vrfy(str(200e6) == "200000000", \
|
||||
'1719: str(200e6) == \"200000000"');
|
||||
vrfy(str(0b100111) == "39", \
|
||||
'1720: str(0b100111) == \"39"');
|
||||
vrfy(str(07543) == "3939", \
|
||||
'1721: str(07543) == \"3939"');
|
||||
vrfy(str(7543) == "7543", \
|
||||
'1722: str(7543) == \"7543"');
|
||||
|
||||
/* test base2() functionality */
|
||||
vrfy(base2() == 0, '1651: base2() == 0');
|
||||
vrfy(base2(0) == 0, '1652: base2(0) == 0');
|
||||
vrfy(base2() == 0, '1653: base2() == 0');
|
||||
vrfy(base2(16) == 0, '1654: base2(16) == 0');
|
||||
vrfy(base2() == 16, '1655: base2() == 16');
|
||||
vrfy(str(3e9) == "3000000000 /* 0xb2d05e00 */",
|
||||
'1656: str(3e9) == "3000000000 /* 0xb2d05e00 */"');
|
||||
vrfy(base2(1/3) == 16, '1657: base2(16) == 16');
|
||||
vrfy(str(23209) == "23209 /* 23209 */",
|
||||
'1658: str(23209) == "23209 /* 23209 */"');
|
||||
vrfy(str(3/2) == "1.5 /* 3/2 */",
|
||||
'1659: str(3/2) == "1.5 /* 3/2 */"');
|
||||
vrfy(base() == 10, '1660: base() == 10');
|
||||
vrfy(base2(0) == 1/3, '1661: base2(0) == 1/3');
|
||||
vrfy(base2() == 0, '1723: base2() == 0');
|
||||
vrfy(base2(0) == 0, '1724: base2(0) == 0');
|
||||
vrfy(base2() == 0, '1725: base2() == 0');
|
||||
|
||||
print '1662: Ending mode/base test';
|
||||
vrfy(base2(16) == 0, '1726: base2(16) == 0');
|
||||
vrfy(base2() == 16, '1727: base2() == 16');
|
||||
vrfy(str(3e9) == "3000000000 /* 0xb2d05e00 */",
|
||||
'1728: str(3e9) == "3000000000 /* 0xb2d05e00 */"');
|
||||
|
||||
vrfy(base2(1/3) == 16, '1728: base2(16) == 16');
|
||||
vrfy(base2() == 1/3, '1729: base2() == 1/3');
|
||||
vrfy(str(23209) == "23209 /* 23209 */",
|
||||
'1730: str(23209) == "23209 /* 23209 */"');
|
||||
vrfy(str(3/2) == "1.5 /* 3/2 */",
|
||||
'1731: str(3/2) == "1.5 /* 3/2 */"');
|
||||
|
||||
vrfy(base2(8) == 1/3, '1732: base2(8) == 1/3');
|
||||
vrfy(base2() == 8, '1733: base2() == 8');
|
||||
vrfy(str(23209) == "23209 /* 055251 */",
|
||||
'1734: str(23209) == "23209 /* 055251 */"');
|
||||
vrfy(str(3/2) == "1.5 /* 3/2 */",
|
||||
'1735: str(3/2) == "1.5 /* 3/2 */"');
|
||||
|
||||
vrfy(base2(2) == 8, '1736: base2(2) == 8');
|
||||
vrfy(base2() == 2, '1737: base2() == 2');
|
||||
vrfy(str(23209) == "23209 /* 0b101101010101001 */",
|
||||
'1738: str(23209) == "23209 /* 0b101101010101001 */"');
|
||||
vrfy(str(3/2) == "1.5 /* 0b11/0b10 */",
|
||||
'1739: str(3/2) == "1.5 /* 0b11/0b10 */"');
|
||||
|
||||
vrfy(base2(1e20) == 2, '1740: base2(1e20) == 2');
|
||||
vrfy(base2() == 1e20, '1741: base2() == 1e20');
|
||||
vrfy(str(23209) == "23209 /* 2.3209e4 */",
|
||||
'1742: str(23209) == "23209 /* 2.3209e4 */"');
|
||||
vrfy(str(3/2) == "1.5 /* 1.5 */",
|
||||
'1743: str(3/2) == "1.5 /* 1.5 */"');
|
||||
|
||||
vrfy(base2(-10) == 1e20, '1744: base2(-10) == 1e20');
|
||||
vrfy(base2() == -10, '1745: base2() == -10');
|
||||
vrfy(str(23209) == "23209 /* 23209 */",
|
||||
'1746: str(23209) == "23209 /* 23209 */"');
|
||||
vrfy(str(3/2) == "1.5 /* ~2 */",
|
||||
'1747: str(3/2) == "1.5 /* ~2 */"');
|
||||
|
||||
vrfy(base2(1000) == -10, '1748: base2(1000) == -1000');
|
||||
vrfy(base2() == 1000, '1749: base2() == 1000');
|
||||
vrfy(str(23209) == "23209 /* 23.209e3 */",
|
||||
'1750: str(23209) == "23209 /* 23.209e3 */"');
|
||||
vrfy(str(3/2) == "1.5 /* 1.5 */",
|
||||
'1751: str(3/2) == "1.5 /* 1.5 */"');
|
||||
|
||||
vrfy(base2(10) == 1000, '1752: base2(10) == 1000');
|
||||
vrfy(base2() == 10, '1753: base2() == 10');
|
||||
vrfy(str(23209) == "23209 /* 23209 */",
|
||||
'1754: str(23209) == "23209 /* 23209 */"');
|
||||
vrfy(str(3/2) == "1.5 /* 1.5 */",
|
||||
'1755: str(3/2) == "1.5 /* 1.5 */"');
|
||||
|
||||
vrfy(base2(0) == 10, '1756: base2(0) == 10');
|
||||
vrfy(base2() == 0, '1757: base2() == 0');
|
||||
vrfy(str(23209) == "23209",
|
||||
'1758: str(23209) == "23209"');
|
||||
vrfy(str(3/2) == "1.5",
|
||||
'1759: str(3/2) == "1.5"');
|
||||
|
||||
vrfy(base() == 10, '1760: base() == 10');
|
||||
vrfy(base2() == 0, '1761: base2() == 0');
|
||||
|
||||
print '1762: Ending mode/base test';
|
||||
}
|
||||
print '026: parsed test_mode()';
|
||||
|
||||
|
||||
/*
|
||||
* The 1700's contain tests for reading resource files. These tests are
|
||||
* done inline near the bottom.
|
||||
* The 1780's and 1790's contain tests for reading resource files.
|
||||
*
|
||||
* These tests are done inline near the bottom.
|
||||
*/
|
||||
|
||||
|
||||
@@ -3198,9 +3402,11 @@ define test_trig()
|
||||
|
||||
print '3400: Beginning test_trig';
|
||||
|
||||
/* test 3401-3407 */
|
||||
tnum = test3400(1, 3401);
|
||||
vrfy(tnum == 3407, '3407: tnum == 3407');
|
||||
|
||||
print tnum: ': Ending test_trig';
|
||||
print '3438: Ending test_trig';
|
||||
}
|
||||
print '051: parsed test_trig()';
|
||||
|
||||
@@ -7635,31 +7841,31 @@ print;
|
||||
return test_mode();
|
||||
print;
|
||||
|
||||
print '1700: Beginning read test';
|
||||
print '1780: Beginning read test';
|
||||
value = 0;
|
||||
vrfy(value == 0, '1701: value == 0');
|
||||
vrfy(value == 0, '1781: value == 0');
|
||||
read "test1700";
|
||||
print '1702: read "test1700";';
|
||||
vrfy(value == 1, '1703: value == 1');
|
||||
print '1782: read "test1700";';
|
||||
vrfy(value == 1, '1783: value == 1');
|
||||
read -once "test1700";
|
||||
print '1704: read -once "test1700";';
|
||||
vrfy(value == 1, '1705: value == 1');
|
||||
print '1784: read -once "test1700";';
|
||||
vrfy(value == 1, '1785: value == 1');
|
||||
read "test1700.cal";
|
||||
print '1706: read "test1700.cal";';
|
||||
vrfy(value == 2, '1707: value == 2');
|
||||
read -once "test1700.cal";
|
||||
print '1708: read -once "test1700.cal";';
|
||||
vrfy(value == 2, '1709: value == 2');
|
||||
print '1786: read "test1700.cal";';
|
||||
vrfy(value == 2, '1787: value == 2');
|
||||
read -once "test1700.cal"
|
||||
print '1788: read -once "test1700.cal";';
|
||||
vrfy(value == 2, '1789: value == 2');
|
||||
read "test1700.cal";
|
||||
print '1710: read "test1700.cal";';
|
||||
vrfy(value == 3, '1711: value == 3');
|
||||
print '1790: read "test1700.cal";';
|
||||
vrfy(value == 3, '1791: value == 3');
|
||||
{++value;} read "test1700.cal";
|
||||
print '1712: {++value;} read "test1700.cal";';
|
||||
vrfy(value == 5, '1713: value == 5');
|
||||
print '1792: {++value;} read "test1700.cal";';
|
||||
vrfy(value == 5, '1793: value == 5');
|
||||
{++value;} read -once "test1700.cal";
|
||||
print '1714: {++value;} read -once "test1700.cal";';
|
||||
vrfy(value == 6, '1715: value == 6');
|
||||
print '1716: Ending read test';
|
||||
print '1794: {++value;} read -once "test1700.cal";';
|
||||
vrfy(value == 6, '1795: value == 6');
|
||||
print '1796: Ending read test';
|
||||
|
||||
print;
|
||||
return test_obj();
|
||||
@@ -7963,6 +8169,8 @@ ecnt = 211;
|
||||
* Test more of the built-in functions.
|
||||
*
|
||||
* See test_functions() (test 700 - 1238) for other built-in function tests.
|
||||
* See test_functions2() (test 9000 - 9063) for other built-in function tests.
|
||||
* See test_functions3() (test 9100 - 9214) for other built-in function tests.
|
||||
*/
|
||||
define test_functions2()
|
||||
{
|
||||
@@ -8076,6 +8284,401 @@ print;
|
||||
return test_functions2();
|
||||
|
||||
|
||||
/*
|
||||
* Test even more of the built-in functions.
|
||||
*
|
||||
* See test_functions() (test 700 - 1238) for other built-in function tests.
|
||||
* See test_functions2() (test 9000 - 9063) for other built-in function tests.
|
||||
* See test_functions3() (test 9100 - 9214) for other built-in function tests.
|
||||
*/
|
||||
define test_functions3()
|
||||
{
|
||||
local d, m, s, g, h;
|
||||
|
||||
print '9101: Beginning test_functions3';
|
||||
|
||||
/* d2r & r2d */
|
||||
vrfy(d2r(180) == pi(),
|
||||
'9102: d2r(180) == pi()');
|
||||
vrfy(d2r(180, 1e-100) == pi(1e-100),
|
||||
'9103: d2r(180, 1e-100) == pi(1e-100)');
|
||||
vrfy(r2d(pi()/2) == 90,
|
||||
'9104: r2d(pi()/2) == 90');
|
||||
vrfy(r2d(pi(1e-15)/2) == 14137166941154068500000/157079632679489661923,
|
||||
'9105: r2d(pi(1e-15)/2) == ' +
|
||||
'14137166941154068500000/157079632679489661923');
|
||||
vrfy(r2d(d2r(40)) == 40,
|
||||
'9106: r2d(d2r(40)) == 40');
|
||||
vrfy(r2d(d2r(40,1e-90),1e-90) == 40,
|
||||
'9107: r2d(d2r(40,1e-90),1e-90) == 40');
|
||||
vrfy(d2r(180i) == 1i*pi(),
|
||||
'9108: d2r(1808) == 1i*pi()');
|
||||
vrfy(d2r(180i+90) == 1i*pi() + pi()/2,
|
||||
'9109: d2r(180i+90) == 1i*pi() + pi()/2');
|
||||
vrfy(r2d(d2r(40+40i)) == 40+40i,
|
||||
'9110: r2d(d2r(40+40i)) == 40+40i');
|
||||
vrfy(r2d(d2r(40+40i,1e-60),1e-60) == 40+40i,
|
||||
'9111: r2d(d2r(40+40i,1e-60),1e-60) == 40+40i');
|
||||
|
||||
/* g2r & r2g */
|
||||
vrfy(g2r(200) == pi(),
|
||||
'9112: g2r(200) == pi()');
|
||||
vrfy(g2r(200, 1e-100) == pi(1e-100),
|
||||
'9113: g2r(180, 1e-100) == pi(1e-100)');
|
||||
vrfy(r2g(pi()/2) == 100,
|
||||
'9114: r2g(pi()/2) == 100');
|
||||
vrfy(r2g(pi(1e-15)/2) == 15707963267948965000000/157079632679489661923,
|
||||
'9115: r2g(pi(1e-15)/2) == ' +
|
||||
'15707963267948965000000/157079632679489661923');
|
||||
vrfy(r2g(g2r(40)) == 40,
|
||||
'9116: r2g(g2r(40)) == 40');
|
||||
vrfy(r2g(g2r(40,1e-90),1e-90) == 40,
|
||||
'9117: r2g(g2r(40,1e-90),1e-90) == 40');
|
||||
vrfy(g2r(200i) == 1i*pi(),
|
||||
'9118: g2r(200i) == 1i*pi()');
|
||||
vrfy(g2r(200i+150) == pi()*0.75 + 1i*pi(),
|
||||
'9119: g2r(200i+150) == pi()*0.75 + 1i*pi()');
|
||||
vrfy(r2g(g2r(40+40i)) == 40+40i,
|
||||
'9120: r2g(g2r(40+40i)) == 40+40i');
|
||||
vrfy(r2g(g2r(40+40i,1e-60),1e-60) == 40+40i,
|
||||
'9121: r2g(g2r(40+40i,1e-60),1e-60) == 40+40i');
|
||||
|
||||
/* g2d & d2g */
|
||||
vrfy(g2d(200) == 180,
|
||||
'9122: g2d(200) == 180');
|
||||
vrfy(g2d(200, 1e-100) == 180,
|
||||
'9123: g2d(180, 1e-100) == 180');
|
||||
vrfy(d2g(81) == 90,
|
||||
'9124: d2g(81) == 90');
|
||||
vrfy(d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000,
|
||||
'9125: d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000');
|
||||
vrfy(d2g(g2d(40)) == 40,
|
||||
'9126: d2g(g2d(40)) == 40');
|
||||
vrfy(d2g(g2d(40,1e-90),1e-90) == 40,
|
||||
'9127: d2g(g2d(40,1e-90),1e-90) == 40');
|
||||
vrfy(g2d(200i) == 180i,
|
||||
'9128: g2d(200i) == 180i');
|
||||
vrfy(g2d(200i+47) == 42.3 + 180i,
|
||||
'9129: g2d(200i+47) == 42.3 + 180i');
|
||||
vrfy(d2g(g2d(40+40i)) == 40+40i,
|
||||
'9130: d2g(g2d(40+40i)) == 40+40i');
|
||||
vrfy(d2g(g2d(40+40i,1e-90),1e-90) == 40+40i,
|
||||
'9131: d2g(g2d(40+40i,1e-90),1e-90) == 40+40i');
|
||||
|
||||
/* d2dms */
|
||||
vrfy(d2dms(12.3456,d,m,s) == 12.3456,
|
||||
'9132: d2dms(12.3456,d,m,s) == 12.3456');
|
||||
vrfy(d == 12,
|
||||
'9133: d == 12');
|
||||
vrfy(m == 20,
|
||||
'9133: m == 20');
|
||||
vrfy(s == 44.16,
|
||||
'9134: s == 44.16');
|
||||
|
||||
vrfy(d2dms(1234.5678,d,m,s) == 154.5678,
|
||||
'9135: d2dms(1234.5678,d,m,s) == 154.5678');
|
||||
vrfy(d == 154,
|
||||
'9136: d == 154');
|
||||
vrfy(m == 34,
|
||||
'9137: m == 34');
|
||||
vrfy(s == 4.08,
|
||||
'9138: s == 4.08');
|
||||
|
||||
vrfy(d2dms(-1234.5678,d,m,s) == 205.4322,
|
||||
'9139: d2dms(-1234.5678,d,m,s) == 205.4322');
|
||||
vrfy(d == 205,
|
||||
'9140: d == 205');
|
||||
vrfy(m == 25,
|
||||
'9141: m == 25');
|
||||
vrfy(s == 55.92,
|
||||
'9142: s == 55.92');
|
||||
|
||||
vrfy(d2dms(360.321,d,m,s,1) == -359.679,
|
||||
'9143: d2dms(360.321,d,m,s,1) == -359.679');
|
||||
vrfy(d == -359,
|
||||
'9144: d == -359');
|
||||
vrfy(m == -40,
|
||||
'9145: m == -40');
|
||||
vrfy(s == -44.4,
|
||||
'9146: s == -44.4');
|
||||
|
||||
/* d2dm */
|
||||
vrfy(d2dm(12.3456,d,m) == 12.3456,
|
||||
'9147: d2dm(12.3456,d,m) == 12.3456');
|
||||
vrfy(d == 12,
|
||||
'9148: d == 12');
|
||||
vrfy(m == 20.736,
|
||||
'9149: m == 20.736');
|
||||
|
||||
vrfy(d2dm(1234.5678,d,m) == 154.5678,
|
||||
'9150: d2dm(1234.5678,d,m) == 154.5678');
|
||||
vrfy(d == 154,
|
||||
'9151: d == 154');
|
||||
vrfy(m == 34.068,
|
||||
'9152: m == 34.068');
|
||||
|
||||
vrfy(d2dm(-1234.5678,d,m) == 205.4322,
|
||||
'9153: d2dm(-1234.5678,d,m) == 205.4322');
|
||||
vrfy(d == 205,
|
||||
'9154: d == 205');
|
||||
vrfy(m == 25.932,
|
||||
'9155: m == 25.932');
|
||||
|
||||
vrfy(d2dm(360.321,d,m,1) == -359.679,
|
||||
'9156: d2dm(360.321,d,m,1) == -359.679');
|
||||
vrfy(d == -359,
|
||||
'9167: d == -359');
|
||||
vrfy(m == -40.74,
|
||||
'9158: m == -40.74');
|
||||
|
||||
/* g2gms */
|
||||
vrfy(g2gms(12.3456,g,m,s) == 12.3456,
|
||||
'9159: g2gms(12.3456,g,m,s) == 12.3456');
|
||||
vrfy(g == 12,
|
||||
'9133: g == 12');
|
||||
vrfy(m == 20,
|
||||
'9160: m == 20');
|
||||
vrfy(s == 44.16,
|
||||
'9161: s == 44.16');
|
||||
|
||||
vrfy(g2gms(1234.5678,g,m,s) == 34.5678,
|
||||
'9162: g2gms(1234.5678,g,m,s) == 34.5678');
|
||||
vrfy(g == 34,
|
||||
'9163: g == 34');
|
||||
vrfy(m == 34,
|
||||
'9164: m == 34');
|
||||
vrfy(s == 4.08,
|
||||
'9165: s == 4.08');
|
||||
|
||||
vrfy(g2gms(-1234.5678,g,m,s) == 365.4322,
|
||||
'9166: g2gms(-1234.5678,g,m,s) == 365.4322');
|
||||
vrfy(g == 365,
|
||||
'9167: g == 365');
|
||||
vrfy(m == 25,
|
||||
'9168: m == 25');
|
||||
vrfy(s == 55.92,
|
||||
'9169: s == 55.92');
|
||||
|
||||
vrfy(g2gms(400.321,g,m,s,1) == -399.679,
|
||||
'9170: g2gms(400.321,g,m,s,1) == -399.679');
|
||||
vrfy(g == -399,
|
||||
'9171: g == -399');
|
||||
vrfy(m == -40,
|
||||
'9172: m == -40');
|
||||
vrfy(s == -44.4,
|
||||
'9173: s == -44.4');
|
||||
|
||||
/* g2gm */
|
||||
vrfy(g2gm(12.3456,g,m) == 12.3456,
|
||||
'9174: g2gm(12.3456,g,m) == 12.3456');
|
||||
vrfy(g == 12,
|
||||
'9175: g == 12');
|
||||
vrfy(m == 20.736,
|
||||
'9176: m == 20.736');
|
||||
|
||||
vrfy(g2gm(1234.5678,g,m) == 34.5678,
|
||||
'9177: g2gm(1234.5678,g,m) == 34.5678');
|
||||
vrfy(g == 34,
|
||||
'9178: g == 34');
|
||||
vrfy(m == 34.068,
|
||||
'9179: m == 34.068');
|
||||
|
||||
vrfy(g2gm(-1234.5678,g,m) == 365.4322,
|
||||
'9180: g2gm(-1234.5678,g,m) == 365.4322');
|
||||
vrfy(g == 365,
|
||||
'9181: g == 365');
|
||||
vrfy(m == 25.932,
|
||||
'9182: m == 25.932');
|
||||
|
||||
vrfy(g2gm(400.321,g,m,1) == -399.679,
|
||||
'9183: g2gm(400.321,g,m,1) == -399.679');
|
||||
vrfy(g == -399,
|
||||
'9184: g == -399');
|
||||
vrfy(m == -40.74,
|
||||
'9185: m == -40.74');
|
||||
|
||||
/* h2hms */
|
||||
vrfy(h2hms(12.3456,h,m,s) == 12.3456,
|
||||
'9186: h2hms(12.3456,h,m,s) == 12.3456');
|
||||
vrfy(h == 12,
|
||||
'9187: h == 12');
|
||||
vrfy(m == 20,
|
||||
'9188: m == 20');
|
||||
vrfy(s == 44.16,
|
||||
'9189: s == 44.16');
|
||||
|
||||
vrfy(h2hms(1234.5678,h,m,s) == 10.5678,
|
||||
'9190: h2hms(1234.5678,h,m,s) == 10.5678');
|
||||
vrfy(h == 10,
|
||||
'9191: h == 10');
|
||||
vrfy(m == 34,
|
||||
'9192: m == 34');
|
||||
vrfy(s == 4.08,
|
||||
'9193: s == 4.08');
|
||||
|
||||
vrfy(h2hms(-1234.5678,h,m,s) == 13.4322,
|
||||
'9194: h2hms(-1234.5678,h,m,s) == 13.4322');
|
||||
vrfy(h == 13,
|
||||
'9195: h == 13');
|
||||
vrfy(m == 25,
|
||||
'9196: m == 25');
|
||||
vrfy(s == 55.92,
|
||||
'9197: s == 55.92');
|
||||
|
||||
vrfy(h2hms(24.321,h,m,s,1) == -23.679,
|
||||
'9198: h2hms(24.321,h,m,s,1) == -23.679');
|
||||
vrfy(h == -23,
|
||||
'9199: h == -23');
|
||||
vrfy(m == -40,
|
||||
'9200: m == -40');
|
||||
vrfy(s == -44.4,
|
||||
'9201: s == -44.4');
|
||||
|
||||
/* h2hm */
|
||||
vrfy(h2hm(12.3456,h,m) == 12.3456,
|
||||
'9202: h2hm(12.3456,h,m) == 12.3456');
|
||||
vrfy(h == 12,
|
||||
'9203: h == 12');
|
||||
vrfy(m == 20.736,
|
||||
'9204: m == 20.736');
|
||||
|
||||
vrfy(h2hm(1234.5678,h,m) == 10.5678,
|
||||
'9205: h2hm(1234.5678,h,m) == 10.5678');
|
||||
vrfy(h == 10,
|
||||
'9206: h == 10');
|
||||
vrfy(m == 34.068,
|
||||
'9207: m == 34.068');
|
||||
|
||||
vrfy(h2hm(-1234.5678,h,m) == 13.4322,
|
||||
'9208: h2hm(-1234.5678,h,m) == 13.4322');
|
||||
vrfy(h == 13,
|
||||
'9209: h == 13');
|
||||
vrfy(m == 25.932,
|
||||
'9210: m == 25.932');
|
||||
|
||||
vrfy(h2hm(24.321,h,m,1) == -23.679,
|
||||
'9211: h2hm(24.321,h,m,1) == -23.679');
|
||||
vrfy(h == -23,
|
||||
'9212: h == -23');
|
||||
vrfy(m == -40.74,
|
||||
'9213: m == -40.74');
|
||||
|
||||
/* dm2d */
|
||||
vrfy(dm2d(203, 325.5594) == 208.42599,
|
||||
'9214: dm2d(203, 325.5594) == 208.42599');
|
||||
vrfy(dm2d(3601, -25.5594) == 0.57401,
|
||||
'9215: dm2d(3601, -25.5594) == 0.57401');
|
||||
vrfy(dm2d(-923, -25.5594) == 156.57401,
|
||||
'9216: dm2d(-923, -25.5594) == 156.57401');
|
||||
vrfy(dm2d(203, 325.5594, 1) == -151.57401,
|
||||
'9217: dm2d(203, 325.5594, 1) == -151.57401');
|
||||
|
||||
vrfy(d2dm(dm2d(12, 20.16),d,m) == 12.336,
|
||||
'9218: d2dm(dm2d(12, 20.16),d,m) == 12.336');
|
||||
vrfy(d == 12,
|
||||
'9219: d == 12');
|
||||
vrfy(m == 20.16,
|
||||
'9220: m == 20.16');
|
||||
|
||||
/* dms2d */
|
||||
vrfy(dms2d(12, 20, 44.16) == 12.3456,
|
||||
'9221: dms2d(12, 20, 44.16) == 12.3456');
|
||||
vrfy(dms2d(123.456, -345.68, 4.08) == 117.6958,
|
||||
'9222: dms2d(123.456, -345.68, 4.08) == 117.6958');
|
||||
vrfy(dms2d(-65, -40, -44.4) == 294.321,
|
||||
'9223: dms2d(-65, -40, -44.4) == 294.321');
|
||||
vrfy(dms2d(12, 20, 44.16, 1) == -347.6544,
|
||||
'9224: dms2d(12, 20, 44.16, 1) == -347.6544');
|
||||
|
||||
vrfy(d2dms(dms2d(13, 20, 44.16),d,m,s) == 13.3456,
|
||||
'9225: d2dms(dms2d(13, 20, 44.16),d,m,s) == 13.3456');
|
||||
vrfy(d == 13,
|
||||
'9226: d == 13');
|
||||
vrfy(m == 20,
|
||||
'9227: m == 20');
|
||||
vrfy(s == 44.16,
|
||||
'9228: s == 44.16');
|
||||
|
||||
/* gm2g */
|
||||
vrfy(gm2g(203, 325.5594) == 208.42599,
|
||||
'9229: gm2g(203, 325.5594) == 208.42599');
|
||||
vrfy(gm2g(3601, -25.5594) == 0.57401,
|
||||
'9230: gm2g(3601, -25.5594) == 0.57401');
|
||||
vrfy(gm2g(-923, -25.5594) == 276.57401,
|
||||
'9231: gm2g(-923, -25.5594) == 276.57401');
|
||||
vrfy(gm2g(203, 325.5594, 1) == -191.57401,
|
||||
'9232: gm2g(203, 325.5594, 1) == -191.57401');
|
||||
|
||||
vrfy(g2gm(gm2g(12, 20.16),g,m) == 12.336,
|
||||
'9233: g2gm(gm2g(12, 20.16),g,m) == 12.336');
|
||||
vrfy(g == 12,
|
||||
'9234: g == 12');
|
||||
vrfy(m == 20.16,
|
||||
'9235: m == 20.16');
|
||||
|
||||
/* gms2g */
|
||||
vrfy(gms2g(12, 20, 44.16) == 12.3456,
|
||||
'9236: gms2g(12, 20, 44.16) == 12.3456');
|
||||
vrfy(gms2g(123.456, -345.68, 4.08) == 117.6958,
|
||||
'9237: gms2g(123.456, -345.68, 4.08) == 117.6958');
|
||||
vrfy(gms2g(-65, -40, -44.4) == 334.321,
|
||||
'9238: gms2g(-65, -40, -44.4) == 334.321');
|
||||
vrfy(gms2g(12, 20, 44.16, 1) == -387.6544,
|
||||
'9239: gms2g(12, 20, 44.16, 1) == -387.6544');
|
||||
|
||||
vrfy(g2gms(gms2g(14, 20, 44.16),g,m,s) == 14.3456,
|
||||
'9240: g2gms(gms2g(14, 20, 44.16),g,m,s) == 14.3456');
|
||||
vrfy(g == 14,
|
||||
'9241: g == 14');
|
||||
vrfy(m == 20,
|
||||
'9242: m == 20');
|
||||
vrfy(s == 44.16,
|
||||
'9243: s == 44.16');
|
||||
|
||||
/* hm2h */
|
||||
vrfy(hm2h(203, 325.5594) == 16.42599,
|
||||
'9244: hm2h(203, 325.5594) == 16.42599');
|
||||
vrfy(hm2h(241, -25.5594) == 0.57401,
|
||||
'9245: hm2h(241, -25.5594) == 0.57401');
|
||||
vrfy(hm2h(-923, -25.5594) == 12.57401,
|
||||
'9246: hm2h(-923, -25.5594) == 12.57401');
|
||||
vrfy(hm2h(203, 325.5594, 1) == -7.57401,
|
||||
'9247: hm2h(203, 325.5594, 1) == -7.57401');
|
||||
|
||||
vrfy(h2hm(hm2h(12, 20.16),h,m) == 12.336,
|
||||
'9248: h2hm(hm2h(12, 20.16),h,m) == 12.336');
|
||||
vrfy(h == 12,
|
||||
'9249: h == 12');
|
||||
vrfy(m == 20.16,
|
||||
'9250: m == 20.16');
|
||||
|
||||
/* hms2h */
|
||||
vrfy(hms2h(12, 20, 44.16) == 12.3456,
|
||||
'9251: hms2h(12, 20, 44.16) == 12.3456');
|
||||
vrfy(hms2h(123.456, -345.68, 4.08) == 21.6958,
|
||||
'9252: hms2h(123.456, -345.68, 4.08) == 21.6958');
|
||||
vrfy(hms2h(-65, -40, -44.4) == 6.321,
|
||||
'9253: hms2h(-65, -40, -44.4) == 6.321');
|
||||
vrfy(hms2h(12, 20, 44.16, 1) == -11.6544,
|
||||
'9254: hms2h(12, 20, 44.16, 1) == -11.6544');
|
||||
|
||||
vrfy(h2hms(hms2h(15, 20, 44.16),h,m,s) == 15.3456,
|
||||
'9255: h2hms(hms2h(15, 20, 44.16),h,m,s) == 15.3456');
|
||||
vrfy(h == 15,
|
||||
'9256: h == 15');
|
||||
vrfy(m == 20,
|
||||
'9257: m == 20');
|
||||
vrfy(s == 44.16,
|
||||
'9258: s == 44.16');
|
||||
|
||||
print '9259: Ending test_functions3';
|
||||
}
|
||||
print;
|
||||
print '9100: parsed test_functions3()';
|
||||
print;
|
||||
return test_functions3();
|
||||
|
||||
|
||||
/*
|
||||
* read various calc resource files
|
||||
*
|
||||
|
@@ -371,7 +371,7 @@ define normalcdf(x,mu,sigma){
|
||||
|
||||
define probit(p){
|
||||
if(p<0 || p > 1) return newerror("probit: p out of domain 0<=p<=1");
|
||||
return sqrt(2)*ervinv(2*p-1);
|
||||
return sqrt(2)*erfinv(2*p-1);
|
||||
}
|
||||
|
||||
define normalcdfinv(p,mu,sigma){
|
||||
|
@@ -336,7 +336,7 @@ define __CZ__produce_long_random_number(n)
|
||||
ret = 1;
|
||||
if(!isint(n) || n<1)
|
||||
return newerror("__CZ__produce_long_random_number(n): "
|
||||
"n is not an integer >=1");
|
||||
"n is not an integer >=1");
|
||||
for(k=0;k<n;k++){
|
||||
ret += random();
|
||||
ret = toomcook4square(ret);
|
||||
|
@@ -72,7 +72,7 @@ define hurwitzzeta(s,a){
|
||||
limit=(precision*ln(10)-re((s-.5)*result)+(1.*realpart_a)*ln(2.*pi()))/2;
|
||||
limit=max(2,ceil(max(limit,abs(s*1.)/2)));
|
||||
limit_function=ceil(sqrt((limit+realpart_a/2-.25)^2+(imagpart_s*1.)^2/4)/
|
||||
pi());
|
||||
pi());
|
||||
if (config("user_debug") > 0) {
|
||||
print "limit_function = " limit_function;
|
||||
print "limit = " limit;
|
||||
|
96
calc.c
96
calc.c
@@ -26,7 +26,6 @@
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
@@ -66,6 +65,7 @@
|
||||
#include "lib_calc.h"
|
||||
#include "args.h"
|
||||
#include "zmath.h"
|
||||
#include "strl.h"
|
||||
|
||||
#include "have_unistd.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
@@ -85,6 +85,9 @@
|
||||
#include "have_unused.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* S_FUNC definitions and functions
|
||||
*/
|
||||
@@ -120,6 +123,11 @@ main(int argc, char **argv)
|
||||
* parse args
|
||||
*/
|
||||
program = argv[0];
|
||||
script_name = strdup(argv[0]);
|
||||
if (script_name == NULL) {
|
||||
fprintf(stderr, "%s: failed to strdup(argv[0])\n", program);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cmdbuf[0] = '\0';
|
||||
cmdlen = 0;
|
||||
@@ -373,14 +381,20 @@ main(int argc, char **argv)
|
||||
havearg = TRUE;
|
||||
if (cmdlen > 0)
|
||||
cmdbuf[cmdlen++] = ' ';
|
||||
strcpy(cmdbuf + cmdlen, "read ");
|
||||
cmdlen += 5;
|
||||
if (strncmp(cp, "-once", 5) == 0 &&
|
||||
(cp[5] == '\0' || cp[5] == ' ')) {
|
||||
cp += 5;
|
||||
strlcpy(cmdbuf + cmdlen, "read ",
|
||||
sizeof("read "));
|
||||
cmdlen += sizeof("read ")-1;
|
||||
cmdbuf[cmdlen] = '\0';
|
||||
if (strncmp(cp, "-once",
|
||||
sizeof("-once")) == 0 &&
|
||||
(cp[sizeof("-once")-1] == '\0' ||
|
||||
cp[sizeof("-once")-1] == ' ')) {
|
||||
cp += sizeof("-once")-1;
|
||||
haveendstr = (*cp == '\0');
|
||||
strcpy(cmdbuf+cmdlen, "-once ");
|
||||
cmdlen += 6;
|
||||
strlcpy(cmdbuf+cmdlen, "-once ",
|
||||
sizeof("-once "));
|
||||
cmdlen += sizeof("-once ")-1;
|
||||
cmdbuf[cmdlen] = '\0';
|
||||
if (nextcp(&cp, &index, argc,
|
||||
argv, haveendstr)) {
|
||||
fprintf(stderr, "-f -once"
|
||||
@@ -390,23 +404,39 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
bp = cmdbuf + cmdlen;
|
||||
/*
|
||||
* duplicate -f filename arg
|
||||
* as a new script_name value
|
||||
*/
|
||||
if (script_name != NULL) {
|
||||
free(script_name);
|
||||
}
|
||||
script_name = NULL;
|
||||
script_name = strdup(cp);
|
||||
if (script_name == NULL) {
|
||||
fprintf(stderr,
|
||||
"strdup(-f argument)"
|
||||
"failed\n");
|
||||
exit(17);
|
||||
}
|
||||
/* process -f filename arg */
|
||||
if (haveendstr) {
|
||||
len = strlen(cp);
|
||||
if (len == 0) {
|
||||
fprintf(stderr,
|
||||
"Null"
|
||||
" filename!");
|
||||
exit(17);
|
||||
" filename!\n");
|
||||
exit(18);
|
||||
}
|
||||
if (cmdlen + len + 2 > MAXCMD) {
|
||||
fprintf(stderr,
|
||||
"Commands too"
|
||||
" long");
|
||||
exit(18);
|
||||
" long\n");
|
||||
exit(19);
|
||||
}
|
||||
/* XXX - what if *cp = '\''? */
|
||||
*bp++ = '\'';
|
||||
strncpy(bp, cp, len+1);
|
||||
strlcpy(bp, cp, len+1);
|
||||
bp += len;
|
||||
*bp++ = '\'';
|
||||
cp += len;
|
||||
@@ -414,10 +444,10 @@ main(int argc, char **argv)
|
||||
} else {
|
||||
do {
|
||||
if (cmdlen > MAXCMD) {
|
||||
fprintf(stderr,
|
||||
"Commands"
|
||||
" too long");
|
||||
exit(19);
|
||||
fprintf(stderr,
|
||||
"Commands"
|
||||
" too long\n");
|
||||
exit(20);
|
||||
}
|
||||
*bp++ = *cp++;
|
||||
cmdlen++;
|
||||
@@ -428,8 +458,12 @@ main(int argc, char **argv)
|
||||
if (*cp == ';')
|
||||
cp++;
|
||||
*bp++ = ';';
|
||||
*bp = '\0';
|
||||
cmdlen++;
|
||||
s_flag = TRUE; /* -f implies -s */
|
||||
|
||||
/* -f implies -s */
|
||||
s_flag = TRUE;
|
||||
maxindex = index + 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
@@ -452,7 +486,7 @@ main(int argc, char **argv)
|
||||
"usage: %s ... -f filename\n"
|
||||
"1st cscript line: #/path/to/calc ... -s -f\n",
|
||||
program, program);
|
||||
exit(20);
|
||||
exit(21);
|
||||
}
|
||||
if (havearg)
|
||||
break;
|
||||
@@ -478,23 +512,9 @@ main(int argc, char **argv)
|
||||
fprintf(stderr,
|
||||
"%s: commands too long\n",
|
||||
program);
|
||||
exit(21);
|
||||
exit(22);
|
||||
}
|
||||
/*
|
||||
* The next statement could be:
|
||||
*
|
||||
* strncpy(cmdbuf + cmdlen, cp, cplen);
|
||||
*
|
||||
* however compilers like gcc would issue warnings such as:
|
||||
*
|
||||
* specified bound depends on the length of the
|
||||
* source argument
|
||||
*
|
||||
* even though we terminate the string by setting a NUL
|
||||
* byte following the copy. Therefore we call memcpy()
|
||||
* instead to avoid such warnings.
|
||||
*/
|
||||
memcpy(cmdbuf + cmdlen, cp, cplen);
|
||||
strlcpy(cmdbuf + cmdlen, cp, cplen+1);
|
||||
cmdbuf[newcmdlen] = '\0';
|
||||
cmdlen = newcmdlen;
|
||||
index++;
|
||||
@@ -515,7 +535,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
argc_value = argc - maxindex;
|
||||
argc_value = argc - maxindex + 1;
|
||||
argv_value = argv + maxindex;
|
||||
|
||||
/*
|
||||
@@ -762,7 +782,7 @@ main(int argc, char **argv)
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
S_FUNC void
|
||||
intint(int UNUSED arg)
|
||||
intint(int UNUSED(arg))
|
||||
{
|
||||
(void) signal(SIGINT, intint);
|
||||
if (inputwait || (++abortlevel >= ABORT_NOW)) {
|
||||
@@ -803,7 +823,7 @@ calc_interrupt(char *fmt, ...)
|
||||
* don't call libcalc_call_me_last() -- we might loop
|
||||
* and besides ... this is an unusual internal error case
|
||||
*/
|
||||
exit(22);
|
||||
exit(24);
|
||||
}
|
||||
}
|
||||
|
||||
|
1
calc.h
1
calc.h
@@ -216,6 +216,7 @@ EXTERN int havecommands; /* TRUE if have cmd args) */
|
||||
EXTERN char *program; /* our name */
|
||||
EXTERN char *base_name; /* basename of our name */
|
||||
EXTERN char cmdbuf[]; /* command line expression */
|
||||
EXTERN char *script_name; /* program name or -f filename arg or NULL */
|
||||
|
||||
EXTERN int abortlevel; /* current level of aborts */
|
||||
EXTERN BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||
|
226
calc.man
226
calc.man
@@ -37,6 +37,7 @@ calc \- arbitrary precision calculator
|
||||
.RB [ -D\ \&calc_debug[:resource_debug[:user_debug]] ]
|
||||
.br
|
||||
.RB [ \-e ]
|
||||
.RB [ \-f\ \&filename ]
|
||||
.RB [ \-h ]
|
||||
.RB [ \-i ]
|
||||
.RB [ \-m\ \&mode ]
|
||||
@@ -50,11 +51,12 @@ calc \- arbitrary precision calculator
|
||||
.RB [ [\-\-]\ calc_cmd\ \&.\|.\|. ]
|
||||
.in -5n
|
||||
.sp
|
||||
\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-s\fP \fB\-f\fP
|
||||
\fI#!${BINDIR}/calc\fP\ [optional_other_flags\ \&...] \fB\-f\fP
|
||||
|
||||
.PP
|
||||
|
||||
.SH DESCRIPTION
|
||||
\&
|
||||
.br
|
||||
CALC OPTIONS
|
||||
|
||||
.PP
|
||||
|
||||
.TP
|
||||
@@ -218,48 +220,55 @@ Ignore any environment variables on startup.
|
||||
The getenv() builtin will still return values, however.
|
||||
|
||||
.TP
|
||||
.B \-f
|
||||
.BR \-f " filename"
|
||||
This flag is normally only with calc shell scripts.
|
||||
.sp 1
|
||||
This flag is required when using calc in
|
||||
.BR "shell script mode" .
|
||||
It must be at the end of the initial
|
||||
.B #!
|
||||
line of the script
|
||||
and must be immediately preceded by the
|
||||
.B \-s
|
||||
flag.
|
||||
.sp 1
|
||||
If the first line of an executable file begins
|
||||
.B #!
|
||||
followed by the absolute pathname of the
|
||||
.B calc
|
||||
program and if the first line ends with the two flags
|
||||
.B \-s
|
||||
.B \-f
|
||||
as in:
|
||||
line of the script, as in:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-s\fP \fB\-f\fP
|
||||
\fI#!${BINDIR}/calc\fP\ [optional_other_flags\ \&...] \fB\-f\fP
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
the rest of the file will be processed in
|
||||
.BR "shell script mode" .
|
||||
|
||||
.sp 1
|
||||
A common flag to use, prior to the
|
||||
.B \-f
|
||||
on the #! line is the
|
||||
.B \-q
|
||||
flag.
|
||||
For example:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
\fI#!${BINDIR}/calc\fP \fB\-q\fP \fB\-f\fP
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
This allows the script to run independely of
|
||||
startup scripts.
|
||||
|
||||
.sp 1
|
||||
See
|
||||
.B "SHELL SCRIPT MODE"
|
||||
section of this man page
|
||||
below for details.
|
||||
.sp 1
|
||||
The actual form of this flag is:
|
||||
While the actual form of this flag is:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.B \-f
|
||||
.BR \-f
|
||||
filename
|
||||
.in -5n
|
||||
.sp 1
|
||||
On systems that treat an executable that begins with
|
||||
for systems that treat an executable that begins with
|
||||
.B #!
|
||||
as a script, the path of the executable is appended by the kernel
|
||||
as the final argument to the exec() system call.
|
||||
@@ -270,12 +279,13 @@ flag at the very end of the
|
||||
line.
|
||||
.sp 1
|
||||
It is possible use
|
||||
.B \-f\ filename
|
||||
.B \-f
|
||||
filename
|
||||
on the command line:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
\fIcalc\fP\ [other_flags\ \&...] \fB\-s\fP \fB\-f\fP filename
|
||||
\fIcalc\fP\ [optional_other_flags\ \&...] \fB\-f\fP filename
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
@@ -283,28 +293,14 @@ This will cause calc to process lines in
|
||||
.B filename
|
||||
in
|
||||
.BR "shell script mode" .
|
||||
.sp 1
|
||||
Use of
|
||||
.B \-f
|
||||
implies
|
||||
.BR \-s .
|
||||
However in a calc shell script,
|
||||
one must include
|
||||
.B \-f
|
||||
before
|
||||
.B \-s
|
||||
on the initial
|
||||
.B #!
|
||||
line.
|
||||
|
||||
.sp 1
|
||||
In addition,
|
||||
.B \-d
|
||||
and
|
||||
.B \-p
|
||||
are implied if
|
||||
.B \-i
|
||||
is not given.
|
||||
The use of
|
||||
.B \-f
|
||||
filename
|
||||
implies the
|
||||
.B \-s
|
||||
flag.
|
||||
|
||||
.TP
|
||||
.B \-h
|
||||
@@ -491,16 +487,16 @@ This is useful when entering negative values on the command line as in:
|
||||
.in +5n
|
||||
.nf
|
||||
calc \-p \-\- \-1 - -7
|
||||
.sp 1
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
|
||||
.PP
|
||||
|
||||
\&
|
||||
.br
|
||||
CALC COMMAND LINE
|
||||
.SH CALC COMMAND LINE
|
||||
|
||||
.PP
|
||||
|
||||
With no
|
||||
.I calc_cmd
|
||||
arguments,
|
||||
@@ -638,10 +634,10 @@ to parse interactive commands, flushes data on standard input.
|
||||
|
||||
.PP
|
||||
|
||||
\&
|
||||
.br
|
||||
CALC STARTUP FILES
|
||||
.SH CALC STARTUP FILES
|
||||
|
||||
.PP
|
||||
|
||||
Normally on startup,
|
||||
if the environment variable
|
||||
.B $CALCRC
|
||||
@@ -678,10 +674,12 @@ files is also disabled as if
|
||||
.B \-q
|
||||
was given.
|
||||
|
||||
\&
|
||||
.br
|
||||
CALC FILE SEARCH PATH
|
||||
.PP
|
||||
|
||||
.SH CALC FILE SEARCH PATH
|
||||
|
||||
.PP
|
||||
|
||||
If the environment variable
|
||||
.B $CALCPATH
|
||||
is undefined, or if it
|
||||
@@ -758,24 +756,24 @@ help config
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
|
||||
.PP
|
||||
|
||||
\&
|
||||
.br
|
||||
SHELL SCRIPT MODE
|
||||
.SH SHELL SCRIPT MODE
|
||||
|
||||
.PP
|
||||
|
||||
If the first line of an executable file begins
|
||||
.B #!
|
||||
followed by the absolute pathname of the
|
||||
.B calc
|
||||
program and the first line ends with the two flags
|
||||
.B \-s
|
||||
program and the first line ends with the flag
|
||||
.B \-f
|
||||
as in:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-s\fP \fB\-f\fP
|
||||
\fI#!${BINDIR}/calc\fP\ [optional_other_flags\ \&...] \fB\-f\fP
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
@@ -786,11 +784,11 @@ Note that
|
||||
.B \-f
|
||||
must at the end of the initial ``#!'' line.
|
||||
Any other optional
|
||||
.B "other_flags"
|
||||
.B "optional_other_flags"
|
||||
must come before
|
||||
the
|
||||
.B \-s
|
||||
.BR \-f .
|
||||
.B \-f
|
||||
flag.
|
||||
.sp 1
|
||||
In
|
||||
.B "shell script mode"
|
||||
@@ -799,7 +797,7 @@ executed as if they were in a file being processed by a read
|
||||
command, except that a "command" beginning with '#' followed by
|
||||
whitespace and ending at the next newline is treated as a comment.
|
||||
Any optional
|
||||
.B "other_flags"
|
||||
.B "optional_other_flags"
|
||||
will be parsed first followed by
|
||||
the later lines within the script itself.
|
||||
.sp 1
|
||||
@@ -821,7 +819,7 @@ the file
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
\fI#!${BINDIR}/calc\fP\ \&\fB\-q\fP \&\fB\-s\fP \fB\-f\fP
|
||||
\fI#!${BINDIR}/calc\fP\ \&\fB\-q\fP \fB\-f\fP
|
||||
|
||||
/* setup */
|
||||
argc = argv();
|
||||
@@ -894,12 +892,13 @@ whereas
|
||||
.in -5n
|
||||
.sp 1
|
||||
will not.
|
||||
|
||||
.PP
|
||||
|
||||
\&
|
||||
.br
|
||||
DATA TYPES
|
||||
.SH DATA TYPES
|
||||
|
||||
.PP
|
||||
|
||||
Fundamental builtin data types include integers, real numbers,
|
||||
rational numbers, complex numbers and strings.
|
||||
.PP
|
||||
@@ -922,12 +921,13 @@ help obj
|
||||
.br
|
||||
show objfuncs
|
||||
.in -1.0i
|
||||
|
||||
.PP
|
||||
|
||||
\&
|
||||
.br
|
||||
VARIABLES
|
||||
.SH VARIABLES
|
||||
|
||||
.PP
|
||||
|
||||
Variables in \fIcalc\fP are typeless.
|
||||
In other words, the fundamental type of a variable is determined by its content.
|
||||
Before a variable is assigned a value it has the value of zero.
|
||||
@@ -950,12 +950,13 @@ help list
|
||||
.br
|
||||
show globals
|
||||
.in -1.0i
|
||||
|
||||
.PP
|
||||
|
||||
\&
|
||||
.br
|
||||
INPUT/OUTPUT
|
||||
.SH INPUT/OUTPUT
|
||||
|
||||
.PP
|
||||
|
||||
A leading ``0x'' implies a hexadecimal value,
|
||||
a leading ``0b'' implies a binary value,
|
||||
and a ``0'' followed by a digit implies an octal value.
|
||||
@@ -985,12 +986,13 @@ command:
|
||||
.in 1.0i
|
||||
help file
|
||||
.in -1.0i
|
||||
|
||||
.PP
|
||||
|
||||
\&
|
||||
.br
|
||||
CALC LANGUAGE
|
||||
.SH CALC LANGUAGE
|
||||
|
||||
.PP
|
||||
|
||||
The \fIcalc\fP language is a C-like language.
|
||||
The language includes commands such as variable declarations,
|
||||
expressions, tests, labels, loops, file operations, function calls.
|
||||
@@ -1017,10 +1019,13 @@ help operator
|
||||
.br
|
||||
help config
|
||||
.in -1.0i
|
||||
|
||||
.PP
|
||||
|
||||
.SH FILES
|
||||
\&
|
||||
.br
|
||||
|
||||
.PP
|
||||
|
||||
.PD 0
|
||||
.TP 5
|
||||
${BINDIR}/calc
|
||||
@@ -1062,9 +1067,13 @@ custom resource files
|
||||
${CUSTOMHELPDIR}/*
|
||||
custom help files
|
||||
.sp 1
|
||||
|
||||
.PP
|
||||
|
||||
.SH ENVIRONMENT
|
||||
\&
|
||||
.br
|
||||
|
||||
.PP
|
||||
|
||||
.PD 0
|
||||
.TP 5
|
||||
CALCPATH
|
||||
@@ -1123,9 +1132,13 @@ Location of the calc custom help directory.
|
||||
.sp
|
||||
Default value: ${CUSTOMHELPDIR}
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
.SH CREDIT
|
||||
\&
|
||||
.br
|
||||
|
||||
.PP
|
||||
|
||||
The main chunk of
|
||||
.B calc
|
||||
was written by David I. Bell.
|
||||
@@ -1154,10 +1167,13 @@ public domain arbitrarily precision routines which was posted
|
||||
to the net around 1984.
|
||||
By now, there is almost no recognizable
|
||||
code left from that original source.
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
.SH "COPYING / CALC GNU LESSER GENERAL PUBLIC LICENSE"
|
||||
\&
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
Calc is open software, and is
|
||||
covered under version 2.1 of the GNU Lesser General Public License.
|
||||
You are
|
||||
@@ -1217,10 +1233,13 @@ Copyright (C) 1999-2021 Landon Curt Noll
|
||||
.sp
|
||||
and is covered under version 2.1 GNU Lesser General
|
||||
Public License.
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
.SH "CALC QUESTIONS"
|
||||
\&
|
||||
.br
|
||||
|
||||
.PP
|
||||
|
||||
If you have a simple general question about calc, send Email to:
|
||||
.sp
|
||||
.in +0.5i
|
||||
@@ -1276,11 +1295,13 @@ nor can we do your homework, nor can
|
||||
we do much more than answer short general questions about calc.
|
||||
.sp
|
||||
Please be patient as we cannot always respond to Email messages quickly.
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
.SH "BUG REPORTS / BUG FIXES"
|
||||
\&
|
||||
.br
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
Send bug reports and bug fixes to:
|
||||
.sp
|
||||
.in +0.5i
|
||||
@@ -1346,11 +1367,13 @@ help bugs
|
||||
for more information about bug reporting.
|
||||
.sp
|
||||
Please be patient as we cannot always respond to Email messages quickly.
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
.SH "CONTRIBUTING CODE TO CALC"
|
||||
\&
|
||||
.br
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
.I Calc
|
||||
is open source.
|
||||
Contributions of code are welcome.
|
||||
@@ -1473,10 +1496,13 @@ you have that
|
||||
somewhere in the subject line!
|
||||
.sp
|
||||
Please be patient as we cannot always respond to Email messages quickly.
|
||||
.sp
|
||||
|
||||
.PP
|
||||
|
||||
.SH "CALC WEB SITE"
|
||||
\&
|
||||
.br
|
||||
|
||||
.PP
|
||||
|
||||
Landon Noll maintains the
|
||||
.B calc
|
||||
web site is located at:
|
||||
|
48
calcerr.tbl
48
calcerr.tbl
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# calcerr - error codes and messages
|
||||
#
|
||||
# Copyright (C) 1999-2006 Ernest Bowen
|
||||
# Copyright (C) 1999-2006,2021 Ernest Bowen
|
||||
#
|
||||
# Calc is open software; you can redistribute it and/or modify it under
|
||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -496,3 +496,49 @@ E_ATANH3 Invalid value for calculating atan
|
||||
E_ACOTH3 Invalid value for calculating acot
|
||||
E_ASECH3 Invalid value for calculating asec
|
||||
E_ACSCH3 Invalid value for calculating acsc
|
||||
E_D2R1 Bad epsilon for converting degrees to radians
|
||||
E_D2R2 Bad first argument converting degrees to radians
|
||||
E_R2D1 Bad epsilon for converting radians to degrees
|
||||
E_R2D2 Bad first argument converting radians to degrees
|
||||
E_G2R1 Bad epsilon for converting gradians to radians
|
||||
E_G2R2 Bad first argument converting gradians to radians
|
||||
E_R2G1 Bad epsilon for converting radians to gradians
|
||||
E_R2G2 Bad first argument converting radians to gradians
|
||||
E_D2G1 Bad first argument converting degrees to gradians
|
||||
E_G2D1 Bad first argument converting gradians to degrees
|
||||
E_D2DMS1 Non-lvalue arguments 2, 3 or 4 for d2dms
|
||||
E_D2DMS2 Non-real-number arg 1 for d2dms
|
||||
E_D2DMS3 No-assign-to argument 2, 3 or 4 for d2dms
|
||||
E_D2DMS4 Invalid rounding arg 5 for d2dms
|
||||
E_D2DM1 Non-lvalue arguments 2 or 3 for d2dm
|
||||
E_D2DM2 Non-real-number arg 1 for d2dm
|
||||
E_D2DM3 No-assign-to argument 2 or 3 for d2dm
|
||||
E_D2DM4 Invalid rounding arg 4 for d2dm
|
||||
E_G2GMS1 Non-lvalue arguments 2, 3 or 4 for g2gms
|
||||
E_G2GMS2 Non-real-number arg 1 for g2gms
|
||||
E_G2GMS3 No-assign-to argument 2 or 3 for g2gms
|
||||
E_G2GMS4 Invalid rounding arg 5 for g2gms
|
||||
E_G2GM1 Non-lvalue arguments 2 or 3 for g2gm
|
||||
E_G2GM2 Non-real-number arg 1 for g2gm
|
||||
E_G2GM3 No-assign-to argument 2, 3 or 4 for g2gm
|
||||
E_G2GM4 Invalid rounding arg 4 for g2gm
|
||||
E_H2HMS1 Non-lvalue arguments 2, 3 or 4 for h2hms
|
||||
E_H2HMS2 Non-real-number arg 1 for h2hms
|
||||
E_H2HMS3 No-assign-to argument 2, 3 or 4 for h2hms
|
||||
E_H2HMS4 Invalid rounding arg 5 for h2hms
|
||||
E_H2HM1 Non-lvalue arguments 2 or 3 for h2hm
|
||||
E_H2HM2 Non-real-number arg 1 for h2hm
|
||||
E_H2HM3 No-assign-to argument 2 or 3 for h2hm
|
||||
E_H2HM4 Invalid rounding arg 4 for h2hm
|
||||
E_DMS2D1 Non-real-number aarguments 1, 2 or 3 for dms2d
|
||||
E_DMS2D2 Invalid rounding arg 4 for dms2d
|
||||
E_DM2D1 Non-real-number aarguments 1 or 2 for dm2d
|
||||
E_DM2D2 Invalid rounding arg 4 for dm2d
|
||||
E_GMS2G1 Non-real-number aarguments 1, 2 or 3 for gms2g
|
||||
E_GMS2G2 Invalid rounding arg 4 for gms2g
|
||||
E_GM2G1 Non-real-number aarguments 1 or 2 for gm2g
|
||||
E_GM2G2 Invalid rounding arg 4 for gm2g
|
||||
E_HMS2H1 Non-real-number aarguments 1, 2 or 3 for hms2h
|
||||
E_HMS2H2 Invalid rounding arg 4 for hms2h
|
||||
E_HM2H1 Non-real-number aarguments 1 or 2 for hm2h
|
||||
E_HM2H2 Invalid rounding arg 4 for hm2h
|
||||
|
@@ -28,6 +28,8 @@ BEGIN {
|
||||
printf("#include <stdio.h>\n");
|
||||
printf("#include \"calcerr.h\"\n\n");
|
||||
printf("#include \"have_const.h\"\n\n");
|
||||
printf("#include \"banned.h\"\t");
|
||||
printf("/* include after system header <> includes */\n\n");
|
||||
printf("/*\n");
|
||||
printf(" * names of calc error values\n");
|
||||
printf(" */\n");
|
||||
|
23
codegen.c
23
codegen.c
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "lib_calc.h"
|
||||
#include "calc.h"
|
||||
#include "alloc.h"
|
||||
#include "token.h"
|
||||
#include "symbol.h"
|
||||
#include "label.h"
|
||||
@@ -41,11 +42,16 @@
|
||||
#include "str.h"
|
||||
#include "func.h"
|
||||
#include "conf.h"
|
||||
#include "strl.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
# include <direct.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
STATIC BOOL rdonce; /* TRUE => do not reread this file */
|
||||
|
||||
FUNC *curfunc;
|
||||
@@ -144,11 +150,9 @@ getcommands(BOOL toplevel)
|
||||
case 1:
|
||||
case -1:
|
||||
if(i == 1) {
|
||||
strncpy(name,
|
||||
strlcpy(name,
|
||||
DEFAULTCALCHELP,
|
||||
MAXCMD);
|
||||
/* paranoia */
|
||||
name[MAXCMD] = '\0';
|
||||
MAXCMD+1);
|
||||
givehelp(name);
|
||||
}
|
||||
break;
|
||||
@@ -2354,8 +2358,7 @@ getfilename(char *name, size_t namelen, BOOL *once)
|
||||
|
||||
/* use the value of the literal string */
|
||||
s = findstring(tokenstring());
|
||||
strncpy(name, s->s_str, namelen-1);
|
||||
name[namelen-1] = '\0';
|
||||
strlcpy(name, s->s_str, namelen);
|
||||
sfree(s);
|
||||
break;
|
||||
|
||||
@@ -2392,8 +2395,7 @@ getfilename(char *name, size_t namelen, BOOL *once)
|
||||
}
|
||||
|
||||
/* return symbol name or value of global var string */
|
||||
strncpy(name, symstr, namelen-1);
|
||||
name[namelen-1] = '\0';
|
||||
strlcpy(name, symstr, namelen);
|
||||
break;
|
||||
|
||||
case T_NEWLINE:
|
||||
@@ -2431,7 +2433,7 @@ getshowstatement(void)
|
||||
|
||||
switch (gettoken()) {
|
||||
case T_SYMBOL:
|
||||
strncpy(name, tokensymbol(), 4);
|
||||
strlcpy(name, tokensymbol(), sizeof(name));
|
||||
name[4] = '\0';
|
||||
/* Yuck! */
|
||||
arg = stringindex("buil\000"
|
||||
@@ -2595,8 +2597,7 @@ getid(char *buf)
|
||||
*buf = '\0';
|
||||
return FALSE;
|
||||
}
|
||||
strncpy(buf, tokensymbol(), SYMBOLSIZE);
|
||||
buf[SYMBOLSIZE] = '\0';
|
||||
strlcpy(buf, tokensymbol(), SYMBOLSIZE+1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,10 @@
|
||||
#include "config.h"
|
||||
#include "cmath.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* cache the natural logarithm of 10
|
||||
*/
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* commath - extended precision complex arithmetic primitive routines
|
||||
*
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
* Copyright (C) 1999-2007,2021 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -27,6 +27,9 @@
|
||||
#include "cmath.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
COMPLEX _czero_ = { &_qzero_, &_qzero_, 1 };
|
||||
COMPLEX _cone_ = { &_qone_, &_qzero_, 1 };
|
||||
COMPLEX _conei_ = { &_qzero_, &_qone_, 1 };
|
||||
|
14
config.c
14
config.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* config - configuration routines
|
||||
*
|
||||
* Copyright (C) 1999-2007 David I. Bell and Landon Curt Noll
|
||||
* Copyright (C) 1999-2007,2021 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -46,6 +46,7 @@
|
||||
#endif
|
||||
|
||||
#include "calc.h"
|
||||
#include "alloc.h"
|
||||
#include "token.h"
|
||||
#include "zrand.h"
|
||||
#include "block.h"
|
||||
@@ -53,12 +54,17 @@
|
||||
#include "config.h"
|
||||
#include "str.h"
|
||||
#include "custom.h"
|
||||
#include "strl.h"
|
||||
|
||||
#include "have_strdup.h"
|
||||
#if !defined(HAVE_STRDUP)
|
||||
# define strdup(x) calc_strdup((CONST char *)(x))
|
||||
#endif /* HAVE_STRDUP */
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* deal with systems that lack a defined CLK_TCK
|
||||
*/
|
||||
@@ -268,6 +274,8 @@ STATIC NAMETYPE modes[] = {
|
||||
{"scientific", MODE_EXP},
|
||||
{"sci", MODE_EXP},
|
||||
{"exp", MODE_EXP},
|
||||
{"engineering", MODE_ENG},
|
||||
{"eng", MODE_ENG},
|
||||
{"hexadecimal", MODE_HEX},
|
||||
{"hex", MODE_HEX},
|
||||
{"octal", MODE_OCTAL},
|
||||
@@ -757,7 +765,7 @@ setconfig(int type, VALUE *vp)
|
||||
math_error("Cannot duplicate new prompt");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
strncpy(p, vp->v_str->s_str, vp->v_str->s_len + 1);
|
||||
strlcpy(p, vp->v_str->s_str, vp->v_str->s_len + 1);
|
||||
free(conf->prompt1);
|
||||
conf->prompt1 = p;
|
||||
break;
|
||||
@@ -772,7 +780,7 @@ setconfig(int type, VALUE *vp)
|
||||
math_error("Cannot duplicate new more prompt");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
strncpy(p, vp->v_str->s_str, vp->v_str->s_len + 1);
|
||||
strlcpy(p, vp->v_str->s_str, vp->v_str->s_len + 1);
|
||||
free(conf->prompt2);
|
||||
conf->prompt2 = p;
|
||||
break;
|
||||
|
19
const.c
19
const.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* const - constant number storage module
|
||||
*
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
* Copyright (C) 1999-2007,2021 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -28,6 +28,10 @@
|
||||
#include "calc.h"
|
||||
#include "qmath.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define CONSTALLOCSIZE 400 /* number of constants to allocate */
|
||||
|
||||
STATIC unsigned long constcount;/* number of constants defined */
|
||||
@@ -40,16 +44,16 @@ initconstants(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
consttable = (NUMBER **) malloc(sizeof(NUMBER *) * CONSTALLOCSIZE);
|
||||
consttable = (NUMBER **) calloc(sizeof(NUMBER *), CONSTALLOCSIZE);
|
||||
if (consttable == NULL) {
|
||||
math_error("Unable to allocate constant table");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
for (i = 0; i < INITCONSTCOUNT; i++)
|
||||
for (i = 0; initnumbs[i] != NULL; i++) {
|
||||
consttable[i] = initnumbs[i];
|
||||
consttable[INITCONSTCOUNT] = NULL; /* firewall */
|
||||
constcount = INITCONSTCOUNT;
|
||||
constavail = CONSTALLOCSIZE - INITCONSTCOUNT;
|
||||
}
|
||||
constcount = i-1;
|
||||
constavail = CONSTALLOCSIZE - constcount;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +123,9 @@ addqconstant(NUMBER *q)
|
||||
tp = consttable;
|
||||
for (index = 0; index < constcount; index++, tp++) {
|
||||
t = *tp;
|
||||
if (t == NULL) { /* paranoia */
|
||||
break;
|
||||
}
|
||||
if (t->links == 0) {
|
||||
if (!havefirst) {
|
||||
havefirst = TRUE;
|
||||
|
@@ -1,7 +1,9 @@
|
||||
#!/usr/local/src/bin/calc/calc -q -s -f
|
||||
#!/usr/local/src/bin/calc/calc -q -f
|
||||
/*
|
||||
* 4dsphere - determine if 6 points lie on the surface of a sphere in R^4
|
||||
*
|
||||
* Copyright (C) 2001,2014,2019,2021 Landon Curt Noll
|
||||
*
|
||||
* usage:
|
||||
* 4dsphere x0 y0 z0 w0 x1 y1 z1 w1 ... x5 y5 z5 w5
|
||||
*
|
||||
@@ -10,8 +12,6 @@
|
||||
* ... ...
|
||||
* x5 y5 z5 w5 point 5 in R^4
|
||||
*
|
||||
* Copyright (C) 2001,2014,2019 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.
|
||||
|
168
cscript/Makefile
168
cscript/Makefile
@@ -3,6 +3,14 @@
|
||||
#
|
||||
# Copyright (C) 1999-2006,2014,2017,2021 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.
|
||||
#
|
||||
# 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.
|
||||
@@ -27,15 +35,63 @@
|
||||
# Makefile by Landon Curt Noll
|
||||
|
||||
|
||||
# required vars
|
||||
# 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/sh
|
||||
#SHELL= /bin/bash
|
||||
#SHELL= /bin/zsh
|
||||
|
||||
|
||||
####
|
||||
# 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
|
||||
|
||||
# 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
|
||||
@@ -65,11 +121,11 @@ TOP_MAKE_FILE= Makefile
|
||||
# INCDIR= /usr/include
|
||||
#
|
||||
|
||||
#INCDIR= /usr/local/include
|
||||
#INCDIR= ${PREFIX}/include
|
||||
#INCDIR= /dev/env/DJDIR/include
|
||||
INCDIR= /usr/include
|
||||
|
||||
# where to install calc realted things
|
||||
# where to install calc related things
|
||||
#
|
||||
# ${BINDIR} where to install calc binary files
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
@@ -91,15 +147,15 @@ INCDIR= /usr/include
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
#BINDIR= /usr/local/bin
|
||||
#BINDIR= ${PREFIX}/bin
|
||||
#BINDIR= /dev/env/DJDIR/bin
|
||||
BINDIR= /usr/bin
|
||||
|
||||
#LIBDIR= /usr/local/lib
|
||||
#LIBDIR= ${PREFIX}/lib
|
||||
#LIBDIR= /dev/env/DJDIR/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
||||
#CALC_SHAREDIR= ${PREFIX}/lib/calc
|
||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
@@ -157,28 +213,59 @@ T=
|
||||
|
||||
# Makefile debug
|
||||
#
|
||||
# Q=@ do not echo internal makefile actions (quiet mode)
|
||||
# Q= echo internal makefile actions (debug / verbose mode)
|
||||
# Q=@ do not echo internal Makefile actions (quiet mode)
|
||||
# Q= echo internal Makefile actions (debug / verbose mode)
|
||||
#
|
||||
# H=@: do not report hsrc file formation progress
|
||||
# H=@ do echo hsrc file formation progress
|
||||
#
|
||||
# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation
|
||||
# S= full ${CC} output during hsrc file formation
|
||||
#
|
||||
# E= 2>/dev/null slience command stderr during hsrc file formation
|
||||
# E= full command stderr during hsrc file formation
|
||||
#
|
||||
# V=@: do not echo debug statements (quiet mode)
|
||||
# V=@ do echo debug statements (debug / verbose mode)
|
||||
#
|
||||
#Q=
|
||||
Q=@
|
||||
#
|
||||
S= >/dev/null 2>&1
|
||||
#S=
|
||||
#
|
||||
E= 2>/dev/null
|
||||
#E=
|
||||
#
|
||||
#H=@:
|
||||
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
|
||||
FMT= fmt
|
||||
CMP= cmp
|
||||
MKDIR= mkdir
|
||||
RMDIR= rmdir
|
||||
RM= rm
|
||||
TOUCH= touch
|
||||
MV= mv
|
||||
CP= cp
|
||||
CO= co
|
||||
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.
|
||||
#
|
||||
@@ -188,19 +275,17 @@ TRUE= true
|
||||
# To add a script:
|
||||
#
|
||||
# 1) Name the file with a .calc filename extension
|
||||
# 2) Place that file under RCS control
|
||||
# 3) Add the name, without the .calc extension to the ${SCRIPT} below
|
||||
# 4) Write out this Makefile
|
||||
# 5) Replace the ${SCRIPT} and ${SCRIPT_SRC} lines with the output of:
|
||||
# 2) Add the name, without the .calc extension to the ${SCRIPT} below
|
||||
# 3) Write out this Makefile
|
||||
# 4) Replace the SCRIPT= and SCRIPT_SRC= lines with the output of:
|
||||
#
|
||||
# make detaillist
|
||||
#
|
||||
SCRIPT= 4dsphere fproduct mersenne piforever plus powerterm \
|
||||
simple square
|
||||
SCRIPT= 4dsphere fproduct mersenne piforever plus powerterm simple \
|
||||
square
|
||||
|
||||
SCRIPT_SRC= 4dsphere.calc fproduct.calc mersenne.calc \
|
||||
piforever.calc plus.calc powerterm.calc simple.calc \
|
||||
square.calc
|
||||
SCRIPT_SRC= 4dsphere.calc fproduct.calc mersenne.calc piforever.calc \
|
||||
plus.calc powerterm.calc simple.calc square.calc
|
||||
|
||||
# These files are found (but not built) in the distribution
|
||||
#
|
||||
@@ -264,11 +349,7 @@ detaillist:
|
||||
${Q} -(echo "xxxxxxx"; \
|
||||
for i in ${SCRIPT} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
if [ ! -f RCS/$$i.calc,v ]; then \
|
||||
echo "WARNING: $$i.calc not under RCS control" 1>&2; \
|
||||
else \
|
||||
echo $$i; \
|
||||
fi; \
|
||||
echo $$i; \
|
||||
fi; \
|
||||
done | LANG=C ${SORT}) | ${FMT} -70 | \
|
||||
${SED} -e '1s/xxxxxxx/SCRIPT=/' -e '2,$$s/^/ /' \
|
||||
@@ -277,11 +358,7 @@ detaillist:
|
||||
${Q} -(echo "xxxxxxxxxxx"; \
|
||||
for i in ${SCRIPT} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
if [ ! -f RCS/$$i.calc,v ]; then \
|
||||
echo "WARNING: $$i.calc not under RCS control" 1>&2; \
|
||||
else \
|
||||
echo $$i.calc; \
|
||||
fi; \
|
||||
echo $$i.calc; \
|
||||
fi; \
|
||||
done | LANG=C ${SORT}) | ${FMT} -70 | \
|
||||
${SED} -e '1s/xxxxxxxxxxx/SCRIPT_SRC=/' -e '2,$$s/^/ /' \
|
||||
@@ -292,7 +369,7 @@ detaillist:
|
||||
# Home grown make dependency rules. Your system make not support
|
||||
# or have the needed tools. You can ignore this section.
|
||||
#
|
||||
# We will form a skelaton tree of *.c files containing only #include "foo.h"
|
||||
# We will form a skeleton tree of *.c files containing only #include "foo.h"
|
||||
# lines and .h files containing the same lines surrounded by multiple include
|
||||
# prevention lines. This allows us to build a static depend list that will
|
||||
# satisfy all possible cpp symbol definition combinations.
|
||||
@@ -312,7 +389,7 @@ depend:
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo "$$i: $$i.calc"; \
|
||||
echo ' @$${RM} -f $$@'; \
|
||||
echo -n ' @$${SED} -e "1s:^#!/usr/local/src/bin/'; \
|
||||
${ECHON} ' @$${SED} -e "1s:^#!/usr/local/src/bin/'; \
|
||||
echo 'calc/calc:#!$${BINDIR}/calc:" $$?>$$@'; \
|
||||
echo ' @$${CHMOD} +x $$@'; \
|
||||
fi; \
|
||||
@@ -327,20 +404,13 @@ depend:
|
||||
${Q} ${CAT} makedep.out >> ${MAKE_FILE}
|
||||
${Q} ${RM} -f makedep.out
|
||||
-${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \
|
||||
echo 'sample ${MAKE_FILE} was already up to date'; \
|
||||
echo 'cscript/${MAKE_FILE} was already up to date'; \
|
||||
echo 'restoring original cscript/${MAKE_FILE}'; \
|
||||
${MV} -f ${MAKE_FILE}.bak ${MAKE_FILE}; \
|
||||
else \
|
||||
${RM} -f ${MAKE_FILE}.tmp; \
|
||||
${MV} ${MAKE_FILE} ${MAKE_FILE}.tmp; \
|
||||
if [ -d RCS -a ! -w "${MAKE_FILE}" ]; then \
|
||||
${CO} -l ${MAKE_FILE}; \
|
||||
fi; \
|
||||
${MV} ${MAKE_FILE}.tmp ${MAKE_FILE}; \
|
||||
if [ -d RCS ]; then \
|
||||
echo '******************************************************'; \
|
||||
echo 'new cscript ${MAKE_FILE} formed -- need to check it in'; \
|
||||
echo '******************************************************'; \
|
||||
fi; \
|
||||
echo 'old cscript/${MAKE_FILE} is now cscript/${MAKE_FILE}.bak'; \
|
||||
echo 'new cscript/${MAKE_FILE} formed'; \
|
||||
echo 'try: diff -u cscript/${MAKE_FILE}.bak cscript/${MAKE_FILE}'; \
|
||||
fi
|
||||
|
||||
##
|
||||
|
@@ -1,15 +1,15 @@
|
||||
#!/usr/local/src/bin/calc/calc -q -s -f
|
||||
#!/usr/local/src/bin/calc/calc -q -f
|
||||
/*
|
||||
* fproduct - write the big Endian product of terms to a file
|
||||
*
|
||||
* Copyright (C) 2001,2014,2019,2021 Landon Curt Noll
|
||||
*
|
||||
* usage:
|
||||
* fproduct filename term [term ...]
|
||||
*
|
||||
* filename where to write the product, use - for stdout
|
||||
* term ... terms to multiply
|
||||
*
|
||||
* Copyright (C) 2001,2014,2019 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.
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#!/usr/local/src/bin/calc/calc -q -s -f
|
||||
#!/usr/local/src/bin/calc/calc -q -f
|
||||
/*
|
||||
* mersenne - print the value of a mersenne number
|
||||
*
|
||||
* Copyright (C) 1999-2007,2014,2019 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007,2014,2019,2021 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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/local/src/bin/calc/calc -q -s -f
|
||||
#!/usr/local/src/bin/calc/calc -q -f
|
||||
/*
|
||||
* piforever - print digits of pi forever (or as long as your mem/CPU allow)
|
||||
*
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#!/usr/local/src/bin/calc/calc -q -s -f
|
||||
#!/usr/local/src/bin/calc/calc -q -f
|
||||
/*
|
||||
* plus - add two or more arguments together
|
||||
*
|
||||
* Copyright (C) 1999-2007,2014,2019 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007,2014,2019,2021 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
|
||||
@@ -47,7 +47,7 @@ if (argc < 2) {
|
||||
* Since args are strings, we must eval them before using them numerically.
|
||||
*/
|
||||
sum = 0;
|
||||
for (i=1; i < argv(); ++i) {
|
||||
for (i=1; i < argc; ++i) {
|
||||
sum += eval(argv(i));
|
||||
}
|
||||
print sum;
|
||||
|
@@ -1,14 +1,22 @@
|
||||
#!/usr/local/src/bin/calc/calc -q -s -f
|
||||
#!/usr/local/src/bin/calc/calc -q -f
|
||||
/*
|
||||
* powerterm - print the argument as a sum of powers of integers
|
||||
*
|
||||
* Copyright (C) 2001,2014,2019,2021 Landon Curt Noll
|
||||
*
|
||||
* usage:
|
||||
* powerterm [base_limit] value
|
||||
*
|
||||
* base_limit largest base we will consider (def: 10000)
|
||||
* value value to convert into sums of powers of integers
|
||||
*
|
||||
* Copyright (C) 2001,2014,2019 Landon Curt Noll
|
||||
* Example:
|
||||
*
|
||||
* powerterm 5 1000000
|
||||
*
|
||||
* prints:
|
||||
*
|
||||
* 4^10 - 3^10 + 5^6 - 4^6 - 4^5 - 2^5
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the powerterm of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#!/usr/local/src/bin/calc/calc -q -s -f
|
||||
#!/usr/local/src/bin/calc/calc -q -f
|
||||
/*
|
||||
* simple - an example of a simple calc shell script
|
||||
*
|
||||
* Copyright (C) 1999-2007,2014,2019 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007,2014,2019,2021 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
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#!/usr/local/src/bin/calc/calc -q -s -f
|
||||
#!/usr/local/src/bin/calc/calc -q -p -f
|
||||
/*
|
||||
* sqaure - print the squares of input values
|
||||
*
|
||||
* Copyright (C) 2000-2007,2014,2019 Ernest Bowen
|
||||
* Copyright (C) 2000-2007,2014,2019,2021 Ernest Bowen
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -48,6 +48,8 @@
|
||||
* 1522756
|
||||
* ln(2)
|
||||
* ~.48045301391820142467
|
||||
* 2i
|
||||
* -4
|
||||
* config("mode","frac"), bernoulli(10)
|
||||
* 25/4356
|
||||
* config("mode", "hex"), 0xff
|
||||
|
4
custom.c
4
custom.c
@@ -47,6 +47,10 @@
|
||||
|
||||
#endif /* CUSTOM */
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
BOOL allow_custom = FALSE; /* TRUE => custom builtins allowed */
|
||||
|
||||
|
||||
|
@@ -374,12 +374,12 @@ Step 5: Write your custom function
|
||||
|
||||
One is able to set bit 8 by way of the calc command line:
|
||||
|
||||
calc -D 128
|
||||
calc -D 128
|
||||
|
||||
See the calc man page for details. One may also set that bit
|
||||
while running calc by way of the config() builtin function:
|
||||
|
||||
config("calc_debug", 128);
|
||||
config("calc_debug", 128);
|
||||
|
||||
See the help/config file for details on calc_debug.
|
||||
|
||||
|
373
custom/Makefile
373
custom/Makefile
@@ -4,6 +4,14 @@
|
||||
#
|
||||
# Copyright (C) 1999-2006,2014,2017-2018,2021 Landon Curt Noll
|
||||
#
|
||||
# SRC: Makefile via make -f Makefile.ship 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.
|
||||
#
|
||||
# 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.
|
||||
@@ -27,7 +35,123 @@
|
||||
# calculator by David I. Bell with help/mods from others
|
||||
# Makefile by Landon Curt Noll
|
||||
|
||||
####################################################
|
||||
# NOTE: Start of section from custom/Makefile.head #
|
||||
####################################################
|
||||
|
||||
#.###############################################################.#
|
||||
#.# #.#
|
||||
#.# WARNING: This Makefile is generated from a combination of #.#
|
||||
#.# custom/Makefile.head, Makefile.ship, and #.#
|
||||
#.# custom/Makefile.tail. We recommend that you NOT #.#
|
||||
#.# edit this file, but instead edit the proper source #.#
|
||||
#.# file and then make custom/Makefile: #.#
|
||||
#.# #.#
|
||||
#.# make custom/Makefile #.#
|
||||
#.# #.#
|
||||
#.# See the '# NOTE .. section from ..' lines for #.#
|
||||
#.# where the source file for the lines are from. #.#
|
||||
#.# #.#
|
||||
#.###############################################################.#
|
||||
|
||||
|
||||
# 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/sh
|
||||
#SHELL= /bin/bash
|
||||
#SHELL= /bin/zsh
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
|
||||
# Unfortunately due to the complex dependency issues between
|
||||
# Makefile, Makefile.ship and custom/Makefile, parallel GNU make
|
||||
# is NOT recommended. Sorry.
|
||||
#
|
||||
.NOTPARALLEL:
|
||||
|
||||
##############################################################################
|
||||
#-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-#
|
||||
##############################################################################
|
||||
@@ -96,14 +220,38 @@ CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o c_pzasusb8.o \
|
||||
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
#
|
||||
|
||||
# Makefile debug
|
||||
#
|
||||
# Q=@ do not echo internal makefile actions (quiet mode)
|
||||
# Q= echo internal makefile actions (debug / verbose mode)
|
||||
# Q=@ do not echo internal Makefile actions (quiet mode)
|
||||
# Q= echo internal Makefile actions (debug / verbose mode)
|
||||
#
|
||||
# H=@: do not report hsrc file formation progress
|
||||
# H=@ do echo hsrc file formation progress
|
||||
#
|
||||
# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation
|
||||
# S= full ${CC} output during hsrc file formation
|
||||
#
|
||||
# E= 2>/dev/null slience command stderr during hsrc file formation
|
||||
# E= full command stderr during hsrc file formation
|
||||
#
|
||||
# V=@: do not echo debug statements (quiet mode)
|
||||
# V=@ do echo debug statements (debug / verbose mode)
|
||||
#
|
||||
#Q=
|
||||
Q=@
|
||||
#
|
||||
S= >/dev/null 2>&1
|
||||
#S=
|
||||
#
|
||||
E= 2>/dev/null
|
||||
#E=
|
||||
#
|
||||
#H=@:
|
||||
H=@
|
||||
#
|
||||
V=@:
|
||||
#V=@
|
||||
|
||||
####
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
@@ -121,7 +269,7 @@ Q=@
|
||||
# INCDIR= /usr/include
|
||||
#
|
||||
|
||||
#INCDIR= /usr/local/include
|
||||
#INCDIR= ${PREFIX}/include
|
||||
#INCDIR= /dev/env/DJDIR/include
|
||||
INCDIR= /usr/include
|
||||
|
||||
@@ -147,15 +295,15 @@ INCDIR= /usr/include
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
#BINDIR= /usr/local/bin
|
||||
#BINDIR= ${PREFIX}/bin
|
||||
#BINDIR= /dev/env/DJDIR/bin
|
||||
BINDIR= /usr/bin
|
||||
|
||||
#LIBDIR= /usr/local/lib
|
||||
#LIBDIR= ${PREFIX}/lib
|
||||
#LIBDIR= /dev/env/DJDIR/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
||||
#CALC_SHAREDIR= ${PREFIX}/lib/calc
|
||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
@@ -348,7 +496,7 @@ EXT=
|
||||
|
||||
# The default calc versions
|
||||
#
|
||||
VERSION= 2.12.8.2
|
||||
VERSION= 2.14.0.7
|
||||
|
||||
# Names of shared libraries with versions
|
||||
#
|
||||
@@ -357,26 +505,25 @@ LIB_EXT_VERSION= ${LIB_EXT}.${VERSION}
|
||||
|
||||
# standard tools
|
||||
#
|
||||
SHELL= /bin/sh
|
||||
SED= sed
|
||||
MAKEDEPEND= makedepend
|
||||
GREP= egrep
|
||||
CHMOD= chmod
|
||||
FMT= fmt
|
||||
SORT= sort
|
||||
CMP= cmp
|
||||
AR= ar
|
||||
RM= rm
|
||||
TOUCH= touch
|
||||
MKDIR= mkdir
|
||||
RMDIR= rmdir
|
||||
MV= mv
|
||||
CP= cp
|
||||
CO= co
|
||||
TRUE= true
|
||||
MAKE= make
|
||||
LN= ln
|
||||
AWK= awk
|
||||
CHMOD= chmod
|
||||
CMP= cmp
|
||||
CO= co
|
||||
CP= cp
|
||||
FMT= fmt
|
||||
GREP= egrep
|
||||
LN= ln
|
||||
MAKE= make
|
||||
MAKEDEPEND= makedepend
|
||||
MKDIR= mkdir
|
||||
MV= mv
|
||||
RM= rm
|
||||
RMDIR= rmdir
|
||||
SED= sed
|
||||
SORT= sort
|
||||
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
|
||||
@@ -420,9 +567,9 @@ COMMON_LDFLAGS= ${EXTRA_LDFLAGS}
|
||||
# NOTE: This does not work for: make-XYZ-only and BLD_TYPE != make-XYZ-only
|
||||
#
|
||||
ifeq ($(BLD_TYPE),calc-static-only)
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC}
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC}
|
||||
else
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CC_SHARE}
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_SHARE}
|
||||
endif
|
||||
CFLAGS= ${ICFLAGS} ${CCOPT}
|
||||
|
||||
@@ -435,7 +582,16 @@ ILDFLAGS= ${COMMON_LDFLAGS}
|
||||
LDFLAGS= ${LD_DEBUG} ${ILDFLAGS}
|
||||
|
||||
#endif /* end of skip for non-Gnu makefiles */
|
||||
|
||||
##################################################
|
||||
# NOTE: End of section from custom/Makefile.head #
|
||||
##################################################
|
||||
# start of host target cut - Do not remove this line
|
||||
|
||||
###########################################################
|
||||
# NOTE: Start of section from the middle of Makefile.ship #
|
||||
###########################################################
|
||||
|
||||
##############################################################################
|
||||
#-=-=-=-=-=- host target section - targets that override defaults -=-=-=-=-=-#
|
||||
##############################################################################
|
||||
@@ -466,12 +622,20 @@ LDFLAGS= ${LD_DEBUG} ${ILDFLAGS}
|
||||
# CCOPT are flags given to ${CC} for optimization
|
||||
# CCWARN are flags given to ${CC} for warning message control
|
||||
#
|
||||
# WNO_IMPLICT, WNO_ERROR_LONG_LONG and WNO_LONG_LONG are given to ${CC}
|
||||
# when compiling special .o files that may need special compile options
|
||||
# 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=
|
||||
@@ -482,6 +646,9 @@ LDFLAGS= ${LD_DEBUG} ${ILDFLAGS}
|
||||
# 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)
|
||||
#
|
||||
@@ -507,7 +674,7 @@ ifeq ($(target),Linux)
|
||||
BLD_TYPE= calc-dynamic-only
|
||||
#
|
||||
CC_SHARE= -fPIC
|
||||
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:/usr/local/lib
|
||||
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}"
|
||||
@@ -534,10 +701,8 @@ LIBCUSTCALC_STATIC=
|
||||
# This facility requires a Gnu Makefile, or a make command
|
||||
# that understands the += make operand.
|
||||
#
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
COMMON_CFLAGS+= ${COMMON_ADD}
|
||||
COMMON_LDFLAGS+= ${COMMON_ADD}
|
||||
#endif /* end of skip for non-Gnu makefiles */
|
||||
#
|
||||
CCWARN= -Wall
|
||||
WNO_IMPLICT= -Wno-implicit
|
||||
@@ -552,16 +717,16 @@ CC= ${PURIFY} ${LCC} ${CCWERR}
|
||||
#
|
||||
endif
|
||||
|
||||
##############################
|
||||
# Apple OS X / Darwin target #
|
||||
##############################
|
||||
###############################
|
||||
# Apple macOS / Darwin target #
|
||||
###############################
|
||||
|
||||
ifeq ($(target),Darwin)
|
||||
#
|
||||
BLD_TYPE= calc-dynamic-only
|
||||
#
|
||||
CC_SHARE= -fPIC
|
||||
DEFAULT_LIB_INSTALL_PATH= ${PWD}:${LIBDIR}:/usr/local/lib
|
||||
DEFAULT_LIB_INSTALL_PATH= ${PWD}:${LIBDIR}:${PREFIX}/lib
|
||||
LD_SHARE= ${DARWIN_ARCH}
|
||||
#SET_INSTALL_NAME= no
|
||||
SET_INSTALL_NAME= yes
|
||||
@@ -602,10 +767,8 @@ LIBCUSTCALC_STATIC=
|
||||
# This facility requires a Gnu Makefile, or a make command
|
||||
# that understands the += make operand.
|
||||
#
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
COMMON_CFLAGS+= ${COMMON_ADD}
|
||||
COMMON_LDFLAGS+= ${COMMON_ADD}
|
||||
#endif /* end of skip for non-Gnu makefiles */
|
||||
#
|
||||
CCWARN= -Wall
|
||||
WNO_IMPLICT= -Wno-implicit
|
||||
@@ -645,7 +808,7 @@ ifeq ($(target),FreeBSD)
|
||||
BLD_TYPE= calc-dynamic-only
|
||||
#
|
||||
CC_SHARE= -fPIC
|
||||
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:/usr/local/lib
|
||||
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}"
|
||||
@@ -672,10 +835,8 @@ LIBCUSTCALC_STATIC=
|
||||
# This facility requires a Gnu Makefile, or a make command
|
||||
# that understands the += make operand.
|
||||
#
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
COMMON_CFLAGS+= ${COMMON_ADD}
|
||||
COMMON_LDFLAGS+= ${COMMON_ADD}
|
||||
#endif /* end of skip for non-Gnu makefiles */
|
||||
#
|
||||
CCWARN= -Wall
|
||||
WNO_IMPLICT= -Wno-implicit
|
||||
@@ -707,7 +868,7 @@ ifeq ($(target),OpenBSD)
|
||||
BLD_TYPE= calc-dynamic-only
|
||||
#
|
||||
CC_SHARE= -fPIC
|
||||
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:/usr/local/lib
|
||||
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}"
|
||||
@@ -734,10 +895,8 @@ LIBCUSTCALC_STATIC=
|
||||
# This facility requires a Gnu Makefile, or a make command
|
||||
# that understands the += make operand.
|
||||
#
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
COMMON_CFLAGS+= ${COMMON_ADD}
|
||||
COMMON_LDFLAGS+= ${COMMON_ADD}
|
||||
#endif /* end of skip for non-Gnu makefiles */
|
||||
#
|
||||
CCWARN= -Wall
|
||||
WNO_IMPLICT= -Wno-implicit
|
||||
@@ -763,7 +922,7 @@ ifeq ($(target),SunOS)
|
||||
BLD_TYPE= calc-dynamic-only
|
||||
#
|
||||
CC_SHARE= -fPIC
|
||||
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:/usr/local/lib
|
||||
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}"
|
||||
@@ -790,10 +949,8 @@ LD_STATIC=
|
||||
# This facility requires a Gnu Makefile, or a make command
|
||||
# that understands the += make operand.
|
||||
#
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
COMMON_CFLAGS+= ${COMMON_ADD}
|
||||
COMMON_LDFLAGS+= ${COMMON_ADD}
|
||||
#endif /* end of skip for non-Gnu makefiles */
|
||||
#
|
||||
CCWARN= -Wall
|
||||
WNO_IMPLICT= -Wno-implicit
|
||||
@@ -817,7 +974,7 @@ ifeq ($(target),Cygwin)
|
||||
BLD_TYPE= calc-static-only
|
||||
#
|
||||
CC_SHARE= -fPIC
|
||||
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:/usr/local/lib
|
||||
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}"
|
||||
@@ -844,10 +1001,8 @@ LD_STATIC=
|
||||
# This facility requires a Gnu Makefile, or a make command
|
||||
# that understands the += make operand.
|
||||
#
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
COMMON_CFLAGS+= ${COMMON_ADD}
|
||||
COMMON_LDFLAGS+= ${COMMON_ADD}
|
||||
#endif /* end of skip for non-Gnu makefiles */
|
||||
#
|
||||
CCWARN= -Wall
|
||||
WNO_IMPLICT= -Wno-implicit
|
||||
@@ -875,7 +1030,7 @@ ifeq ($(target),simple)
|
||||
BLD_TYPE= calc-static-only
|
||||
#
|
||||
CC_SHARE= -fPIC
|
||||
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:/usr/local/lib
|
||||
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}"
|
||||
@@ -904,7 +1059,7 @@ CC= ${PURIFY} ${LCC} ${CCWERR}
|
||||
# ILDFLAGS for ${CC} in linking intermediate programs used to help compile calc
|
||||
# LDFLAGS for ${CC} in linking calc programs other than intermediate programs
|
||||
#
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC}
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC}
|
||||
CFLAGS= ${ICFLAGS} ${CCOPT}
|
||||
#
|
||||
ILDFLAGS= ${COMMON_LDFLAGS} ${LD_STATIC}
|
||||
@@ -929,12 +1084,12 @@ CALCPATH= .;./cal;~/.cal;${T}${CALC_SHAREDIR};${T}${CUSTOMCALDIR}
|
||||
else
|
||||
CALCPATH= .;./cal;~/.cal;${T}${CALC_SHAREDIR}
|
||||
endif
|
||||
CALCRC= ${CALC_SHAREDIR}/startup;~/.calcrc;./.calcinit
|
||||
CALCRC= ./.calcinit;~/.calcrc;${CALC_SHAREDIR}/startup
|
||||
#
|
||||
BLD_TYPE= calc-static-only
|
||||
#
|
||||
CC_SHARE= -fPIC
|
||||
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:/usr/local/lib
|
||||
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}"
|
||||
@@ -974,7 +1129,7 @@ ifeq ($(target),)
|
||||
BLD_TYPE= calc-static-only
|
||||
#
|
||||
CC_SHARE= -fPIC
|
||||
DEFAULT_LIB_INSTALL_PATH= ${PWD}:/lib:/usr/lib:${LIBDIR}:/usr/local/lib
|
||||
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}"
|
||||
@@ -1001,10 +1156,8 @@ LD_STATIC=
|
||||
# This facility requires a Gnu Makefile, or a make command
|
||||
# that understands the += make operand.
|
||||
#
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
COMMON_CFLAGS+= ${COMMON_ADD}
|
||||
COMMON_LDFLAGS+= ${COMMON_ADD}
|
||||
#endif /* end of skip for non-Gnu makefiles */
|
||||
#
|
||||
CCWARN= -Wall
|
||||
WNO_IMPLICT= -Wno-implicit
|
||||
@@ -1031,9 +1184,9 @@ endif
|
||||
# NOTE: This does not work for: make-XYZ-only and BLD_TYPE != make-XYZ-only
|
||||
#
|
||||
ifeq ($(BLD_TYPE),calc-static-only)
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC}
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC}
|
||||
else
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CC_SHARE}
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_SHARE}
|
||||
endif
|
||||
CFLAGS= ${ICFLAGS} ${CCOPT}
|
||||
|
||||
@@ -1049,7 +1202,27 @@ LDFLAGS= ${LD_DEBUG} ${ILDFLAGS}
|
||||
#######################################################################
|
||||
#-=-=-=-=-=- end of target section - only make rules below -=-=-=-=-=-#
|
||||
#######################################################################
|
||||
|
||||
#########################################################
|
||||
# NOTE: End of section from the middle of Makefile.ship #
|
||||
#########################################################
|
||||
|
||||
# end of host target cut - Do not remove this line
|
||||
#
|
||||
# Copyright (C) 1999-2006,2014,2017-2018,2021 Landon Curt Noll
|
||||
#
|
||||
# SRC: Makefile via make -f Makefile.ship 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.
|
||||
|
||||
####################################################
|
||||
# NOTE: Start of section from custom/Makefile.tail #
|
||||
####################################################
|
||||
|
||||
##############################################################################
|
||||
#-=-=-=-=-=-=-=-=- Be careful if you change something below -=-=-=-=-=-=-=-=-#
|
||||
##############################################################################
|
||||
@@ -1200,7 +1373,10 @@ Makefile.simple: ${MAKE_FILE}
|
||||
${V} echo '=-=-=-=-= custom/${MAKE_FILE} start of $@ rule =-=-=-=-='
|
||||
${Q} ${RM} -f $@
|
||||
${Q} ${AWK} '/^#if 0/{skp=1} {if(!skp){print $$0}} /^#endif/{skp=0}' \
|
||||
${MAKE_FILE} > $@
|
||||
${MAKE_FILE} | \
|
||||
${GREP} -v '#\.#' | \
|
||||
${SED} -e 's;^# SRC:.*;# SRC: non-GNU Makefile via;' \
|
||||
-e 's;via$$;via ${MAKE} -f ${MAKE_FILE} custom/$@;' > $@
|
||||
${Q} echo >> $@
|
||||
${Q} echo 'Makefile.simple:' >> $@
|
||||
${Q} echo ' $${Q} if [ ! -f Makefile.simple ]; then '"\\" >> $@
|
||||
@@ -1222,7 +1398,7 @@ Makefile.simple: ${MAKE_FILE}
|
||||
|
||||
depend:
|
||||
${Q} if [ -f ${MAKE_FILE}.bak ]; then \
|
||||
echo "${MAKE_FILE}.bak exists, remove or move it"; \
|
||||
echo "custom/${MAKE_FILE}.bak exists, remove or move it"; \
|
||||
exit 1; \
|
||||
else \
|
||||
${TRUE}; \
|
||||
@@ -1238,9 +1414,7 @@ depend:
|
||||
fi; \
|
||||
done
|
||||
-${Q} for i in ${H_SRC} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if [ "$$i" = "/dev/null" ]; then continue; fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/custom/$$i"; \
|
||||
echo "#define $$tag" >> "skel/custom/$$i"; \
|
||||
@@ -1249,25 +1423,25 @@ depend:
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/custom/$$i"; \
|
||||
done
|
||||
${Q} (cd ..; ${MAKE} -f ${TOP_MAKE_FILE} hsrc)
|
||||
${Q} for i in `cd ..; ${MAKE} -f ${TOP_MAKE_FILE} h_list 2>&1 | \
|
||||
${SED} -e '/Entering directory/d' \
|
||||
-e '/Nothing to be done/d' \
|
||||
-e '/Leaving directory/d'` /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/$$i"; \
|
||||
echo "#define $$tag" >> "skel/$$i"; \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' "../$$i" \
|
||||
>> "skel/$$i"; \
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/$$i"; \
|
||||
done
|
||||
${MAKE} -f ../${TOP_MAKE_FILE} h_list 2>/dev/null | \
|
||||
while read i; do \
|
||||
if [ ! -f "../$$i" ]; then continue; fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/$$i"; \
|
||||
echo "#define $$tag" >> "skel/$$i"; \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' "../$$i" \
|
||||
>> "skel/$$i"; \
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/$$i"; \
|
||||
done
|
||||
${Q} ${RM} -f skel/custom/makedep.out
|
||||
${Q} echo custom/skel formed
|
||||
${Q} echo forming custom dependency list
|
||||
${Q} :> skel/custom/makedep.out
|
||||
${Q} cd skel/custom; ${MAKEDEPEND} -I.. -w 1 -f makedep.out ${C_SRC}
|
||||
${Q} cd skel/custom; ${MAKEDEPEND} \
|
||||
-I../../.. -w 1 -f makedep.out -- \
|
||||
${CFLAGS} -- \
|
||||
${C_SRC} 2>/dev/null
|
||||
${Q} ${SED} -e 's|: ../../|: |' -E -i '' -l 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/'; \
|
||||
@@ -1282,22 +1456,16 @@ depend:
|
||||
${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} echo removing skel
|
||||
${Q} ${RM} -rf skel
|
||||
-${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \
|
||||
echo 'custom ${MAKE_FILE} was already up to date'; \
|
||||
echo 'custom/${MAKE_FILE} was already up to date'; \
|
||||
echo 'restoring original custom/${MAKE_FILE}'; \
|
||||
${MV} -f ${MAKE_FILE}.bak ${MAKE_FILE}; \
|
||||
else \
|
||||
${RM} -f ${MAKE_FILE}.tmp; \
|
||||
${MV} ${MAKE_FILE} ${MAKE_FILE}.tmp; \
|
||||
if [ -d RCS -a ! -w "${MAKE_FILE}" ]; then \
|
||||
${CO} -l ${MAKE_FILE}; \
|
||||
fi ;\
|
||||
${MV} ${MAKE_FILE}.tmp ${MAKE_FILE}; \
|
||||
if [ -d RCS ]; then \
|
||||
echo '****************************************************'; \
|
||||
echo 'new custom ${MAKE_FILE} formed -- you to check it in'; \
|
||||
echo '****************************************************'; \
|
||||
fi; \
|
||||
echo 'old custom/${MAKE_FILE} is now custom/${MAKE_FILE}.bak'; \
|
||||
echo 'new custom/${MAKE_FILE} formed'; \
|
||||
echo 'try: diff -u custom/${MAKE_FILE}.bak custom/${MAKE_FILE}'; \
|
||||
fi
|
||||
|
||||
##
|
||||
@@ -1344,6 +1512,7 @@ clobber: clean
|
||||
${RM} -f libcustcalc${LIB_EXT}
|
||||
${RM} -f libcustcalc.a
|
||||
${RM} -f libcustcalc*
|
||||
${RM} -rf skel
|
||||
${V} echo remove files that are obsolete
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
${RM} -f Makefile.simple
|
||||
@@ -1590,6 +1759,7 @@ uninstall:
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
c_argv.o: ../alloc.h
|
||||
c_argv.o: ../banned.h
|
||||
c_argv.o: ../block.h
|
||||
c_argv.o: ../byteswap.h
|
||||
c_argv.o: ../calc.h
|
||||
@@ -1600,6 +1770,7 @@ c_argv.o: ../custom.h
|
||||
c_argv.o: ../decl.h
|
||||
c_argv.o: ../endian_calc.h
|
||||
c_argv.o: ../hash.h
|
||||
c_argv.o: ../have_ban_pragma.h
|
||||
c_argv.o: ../have_const.h
|
||||
c_argv.o: ../have_memmv.h
|
||||
c_argv.o: ../have_newstr.h
|
||||
@@ -1615,6 +1786,7 @@ c_argv.o: ../value.h
|
||||
c_argv.o: ../zmath.h
|
||||
c_argv.o: c_argv.c
|
||||
c_devnull.o: ../alloc.h
|
||||
c_devnull.o: ../banned.h
|
||||
c_devnull.o: ../block.h
|
||||
c_devnull.o: ../byteswap.h
|
||||
c_devnull.o: ../calcerr.h
|
||||
@@ -1624,6 +1796,7 @@ c_devnull.o: ../custom.h
|
||||
c_devnull.o: ../decl.h
|
||||
c_devnull.o: ../endian_calc.h
|
||||
c_devnull.o: ../hash.h
|
||||
c_devnull.o: ../have_ban_pragma.h
|
||||
c_devnull.o: ../have_const.h
|
||||
c_devnull.o: ../have_memmv.h
|
||||
c_devnull.o: ../have_newstr.h
|
||||
@@ -1640,6 +1813,7 @@ c_devnull.o: ../value.h
|
||||
c_devnull.o: ../zmath.h
|
||||
c_devnull.o: c_devnull.c
|
||||
c_help.o: ../alloc.h
|
||||
c_help.o: ../banned.h
|
||||
c_help.o: ../block.h
|
||||
c_help.o: ../byteswap.h
|
||||
c_help.o: ../calcerr.h
|
||||
@@ -1649,6 +1823,7 @@ c_help.o: ../custom.h
|
||||
c_help.o: ../decl.h
|
||||
c_help.o: ../endian_calc.h
|
||||
c_help.o: ../hash.h
|
||||
c_help.o: ../have_ban_pragma.h
|
||||
c_help.o: ../have_const.h
|
||||
c_help.o: ../have_memmv.h
|
||||
c_help.o: ../have_newstr.h
|
||||
@@ -1665,6 +1840,7 @@ c_help.o: ../value.h
|
||||
c_help.o: ../zmath.h
|
||||
c_help.o: c_help.c
|
||||
c_pmodm127.o: ../alloc.h
|
||||
c_pmodm127.o: ../banned.h
|
||||
c_pmodm127.o: ../block.h
|
||||
c_pmodm127.o: ../byteswap.h
|
||||
c_pmodm127.o: ../calcerr.h
|
||||
@@ -1674,6 +1850,7 @@ c_pmodm127.o: ../custom.h
|
||||
c_pmodm127.o: ../decl.h
|
||||
c_pmodm127.o: ../endian_calc.h
|
||||
c_pmodm127.o: ../hash.h
|
||||
c_pmodm127.o: ../have_ban_pragma.h
|
||||
c_pmodm127.o: ../have_const.h
|
||||
c_pmodm127.o: ../have_memmv.h
|
||||
c_pmodm127.o: ../have_newstr.h
|
||||
@@ -1689,6 +1866,7 @@ c_pmodm127.o: ../value.h
|
||||
c_pmodm127.o: ../zmath.h
|
||||
c_pmodm127.o: c_pmodm127.c
|
||||
c_pzasusb8.o: ../alloc.h
|
||||
c_pzasusb8.o: ../banned.h
|
||||
c_pzasusb8.o: ../block.h
|
||||
c_pzasusb8.o: ../byteswap.h
|
||||
c_pzasusb8.o: ../calcerr.h
|
||||
@@ -1698,6 +1876,7 @@ c_pzasusb8.o: ../custom.h
|
||||
c_pzasusb8.o: ../decl.h
|
||||
c_pzasusb8.o: ../endian_calc.h
|
||||
c_pzasusb8.o: ../hash.h
|
||||
c_pzasusb8.o: ../have_ban_pragma.h
|
||||
c_pzasusb8.o: ../have_const.h
|
||||
c_pzasusb8.o: ../have_memmv.h
|
||||
c_pzasusb8.o: ../have_newstr.h
|
||||
@@ -1713,6 +1892,7 @@ c_pzasusb8.o: ../value.h
|
||||
c_pzasusb8.o: ../zmath.h
|
||||
c_pzasusb8.o: c_pzasusb8.c
|
||||
c_register.o: ../alloc.h
|
||||
c_register.o: ../banned.h
|
||||
c_register.o: ../block.h
|
||||
c_register.o: ../byteswap.h
|
||||
c_register.o: ../calc.h
|
||||
@@ -1723,6 +1903,7 @@ c_register.o: ../custom.h
|
||||
c_register.o: ../decl.h
|
||||
c_register.o: ../endian_calc.h
|
||||
c_register.o: ../hash.h
|
||||
c_register.o: ../have_ban_pragma.h
|
||||
c_register.o: ../have_const.h
|
||||
c_register.o: ../have_memmv.h
|
||||
c_register.o: ../have_newstr.h
|
||||
@@ -1738,6 +1919,7 @@ c_register.o: ../value.h
|
||||
c_register.o: ../zmath.h
|
||||
c_register.o: c_register.c
|
||||
c_sysinfo.o: ../alloc.h
|
||||
c_sysinfo.o: ../banned.h
|
||||
c_sysinfo.o: ../block.h
|
||||
c_sysinfo.o: ../byteswap.h
|
||||
c_sysinfo.o: ../calc.h
|
||||
@@ -1750,6 +1932,7 @@ c_sysinfo.o: ../decl.h
|
||||
c_sysinfo.o: ../endian_calc.h
|
||||
c_sysinfo.o: ../fposval.h
|
||||
c_sysinfo.o: ../hash.h
|
||||
c_sysinfo.o: ../have_ban_pragma.h
|
||||
c_sysinfo.o: ../have_const.h
|
||||
c_sysinfo.o: ../have_memmv.h
|
||||
c_sysinfo.o: ../have_newstr.h
|
||||
@@ -1770,6 +1953,7 @@ c_sysinfo.o: ../zrand.h
|
||||
c_sysinfo.o: ../zrandom.h
|
||||
c_sysinfo.o: c_sysinfo.c
|
||||
custtbl.o: ../alloc.h
|
||||
custtbl.o: ../banned.h
|
||||
custtbl.o: ../block.h
|
||||
custtbl.o: ../byteswap.h
|
||||
custtbl.o: ../calcerr.h
|
||||
@@ -1779,6 +1963,7 @@ custtbl.o: ../custom.h
|
||||
custtbl.o: ../decl.h
|
||||
custtbl.o: ../endian_calc.h
|
||||
custtbl.o: ../hash.h
|
||||
custtbl.o: ../have_ban_pragma.h
|
||||
custtbl.o: ../have_const.h
|
||||
custtbl.o: ../have_memmv.h
|
||||
custtbl.o: ../have_newstr.h
|
||||
@@ -1792,3 +1977,7 @@ custtbl.o: ../str.h
|
||||
custtbl.o: ../value.h
|
||||
custtbl.o: ../zmath.h
|
||||
custtbl.o: custtbl.c
|
||||
|
||||
##################################################
|
||||
# NOTE: End of section from custom/Makefile.tail #
|
||||
##################################################
|
||||
|
@@ -4,6 +4,14 @@
|
||||
#
|
||||
# Copyright (C) 1999-2006,2014,2017-2018,2021 Landon Curt Noll
|
||||
#
|
||||
# SRC: custom/Makefile.head
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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.
|
||||
@@ -27,7 +35,123 @@
|
||||
# calculator by David I. Bell with help/mods from others
|
||||
# Makefile by Landon Curt Noll
|
||||
|
||||
####################################################
|
||||
# NOTE: Start of section from custom/Makefile.head #
|
||||
####################################################
|
||||
|
||||
#.###############################################################.#
|
||||
#.# #.#
|
||||
#.# WARNING: This Makefile is generated from a combination of #.#
|
||||
#.# custom/Makefile.head, Makefile.ship, and #.#
|
||||
#.# custom/Makefile.tail. We recommend that you NOT #.#
|
||||
#.# edit this file, but instead edit the proper source #.#
|
||||
#.# file and then make custom/Makefile: #.#
|
||||
#.# #.#
|
||||
#.# make custom/Makefile #.#
|
||||
#.# #.#
|
||||
#.# See the '# NOTE .. section from ..' lines for #.#
|
||||
#.# where the source file for the lines are from. #.#
|
||||
#.# #.#
|
||||
#.###############################################################.#
|
||||
|
||||
|
||||
# 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/sh
|
||||
#SHELL= /bin/bash
|
||||
#SHELL= /bin/zsh
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
|
||||
# Unfortunately due to the complex dependency issues between
|
||||
# Makefile, Makefile.ship and custom/Makefile, parallel GNU make
|
||||
# is NOT recommended. Sorry.
|
||||
#
|
||||
.NOTPARALLEL:
|
||||
|
||||
##############################################################################
|
||||
#-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-#
|
||||
##############################################################################
|
||||
@@ -96,14 +220,38 @@ CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o c_pzasusb8.o \
|
||||
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
#
|
||||
|
||||
# Makefile debug
|
||||
#
|
||||
# Q=@ do not echo internal makefile actions (quiet mode)
|
||||
# Q= echo internal makefile actions (debug / verbose mode)
|
||||
# Q=@ do not echo internal Makefile actions (quiet mode)
|
||||
# Q= echo internal Makefile actions (debug / verbose mode)
|
||||
#
|
||||
# H=@: do not report hsrc file formation progress
|
||||
# H=@ do echo hsrc file formation progress
|
||||
#
|
||||
# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation
|
||||
# S= full ${CC} output during hsrc file formation
|
||||
#
|
||||
# E= 2>/dev/null slience command stderr during hsrc file formation
|
||||
# E= full command stderr during hsrc file formation
|
||||
#
|
||||
# V=@: do not echo debug statements (quiet mode)
|
||||
# V=@ do echo debug statements (debug / verbose mode)
|
||||
#
|
||||
#Q=
|
||||
Q=@
|
||||
#
|
||||
S= >/dev/null 2>&1
|
||||
#S=
|
||||
#
|
||||
E= 2>/dev/null
|
||||
#E=
|
||||
#
|
||||
#H=@:
|
||||
H=@
|
||||
#
|
||||
V=@:
|
||||
#V=@
|
||||
|
||||
####
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
@@ -121,7 +269,7 @@ Q=@
|
||||
# INCDIR= /usr/include
|
||||
#
|
||||
|
||||
#INCDIR= /usr/local/include
|
||||
#INCDIR= ${PREFIX}/include
|
||||
#INCDIR= /dev/env/DJDIR/include
|
||||
INCDIR= /usr/include
|
||||
|
||||
@@ -147,15 +295,15 @@ INCDIR= /usr/include
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
#BINDIR= /usr/local/bin
|
||||
#BINDIR= ${PREFIX}/bin
|
||||
#BINDIR= /dev/env/DJDIR/bin
|
||||
BINDIR= /usr/bin
|
||||
|
||||
#LIBDIR= /usr/local/lib
|
||||
#LIBDIR= ${PREFIX}/lib
|
||||
#LIBDIR= /dev/env/DJDIR/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
||||
#CALC_SHAREDIR= ${PREFIX}/lib/calc
|
||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
@@ -348,7 +496,7 @@ EXT=
|
||||
|
||||
# The default calc versions
|
||||
#
|
||||
VERSION= 2.12.8.2
|
||||
VERSION= 2.14.0.7
|
||||
|
||||
# Names of shared libraries with versions
|
||||
#
|
||||
@@ -357,26 +505,25 @@ LIB_EXT_VERSION= ${LIB_EXT}.${VERSION}
|
||||
|
||||
# standard tools
|
||||
#
|
||||
SHELL= /bin/sh
|
||||
SED= sed
|
||||
MAKEDEPEND= makedepend
|
||||
GREP= egrep
|
||||
CHMOD= chmod
|
||||
FMT= fmt
|
||||
SORT= sort
|
||||
CMP= cmp
|
||||
AR= ar
|
||||
RM= rm
|
||||
TOUCH= touch
|
||||
MKDIR= mkdir
|
||||
RMDIR= rmdir
|
||||
MV= mv
|
||||
CP= cp
|
||||
CO= co
|
||||
TRUE= true
|
||||
MAKE= make
|
||||
LN= ln
|
||||
AWK= awk
|
||||
CHMOD= chmod
|
||||
CMP= cmp
|
||||
CO= co
|
||||
CP= cp
|
||||
FMT= fmt
|
||||
GREP= egrep
|
||||
LN= ln
|
||||
MAKE= make
|
||||
MAKEDEPEND= makedepend
|
||||
MKDIR= mkdir
|
||||
MV= mv
|
||||
RM= rm
|
||||
RMDIR= rmdir
|
||||
SED= sed
|
||||
SORT= sort
|
||||
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
|
||||
@@ -420,9 +567,9 @@ COMMON_LDFLAGS= ${EXTRA_LDFLAGS}
|
||||
# NOTE: This does not work for: make-XYZ-only and BLD_TYPE != make-XYZ-only
|
||||
#
|
||||
ifeq ($(BLD_TYPE),calc-static-only)
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC}
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC}
|
||||
else
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CC_SHARE}
|
||||
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_SHARE}
|
||||
endif
|
||||
CFLAGS= ${ICFLAGS} ${CCOPT}
|
||||
|
||||
@@ -435,3 +582,7 @@ ILDFLAGS= ${COMMON_LDFLAGS}
|
||||
LDFLAGS= ${LD_DEBUG} ${ILDFLAGS}
|
||||
|
||||
#endif /* end of skip for non-Gnu makefiles */
|
||||
|
||||
##################################################
|
||||
# NOTE: End of section from custom/Makefile.head #
|
||||
##################################################
|
||||
|
@@ -1,3 +1,18 @@
|
||||
#
|
||||
# Copyright (C) 1999-2006,2014,2017-2018,2021 Landon Curt Noll
|
||||
#
|
||||
# SRC: custom/Makefile.tail
|
||||
#
|
||||
# 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.
|
||||
|
||||
####################################################
|
||||
# NOTE: Start of section from custom/Makefile.tail #
|
||||
####################################################
|
||||
|
||||
##############################################################################
|
||||
#-=-=-=-=-=-=-=-=- Be careful if you change something below -=-=-=-=-=-=-=-=-#
|
||||
##############################################################################
|
||||
@@ -148,7 +163,10 @@ Makefile.simple: ${MAKE_FILE}
|
||||
${V} echo '=-=-=-=-= custom/${MAKE_FILE} start of $@ rule =-=-=-=-='
|
||||
${Q} ${RM} -f $@
|
||||
${Q} ${AWK} '/^#if 0/{skp=1} {if(!skp){print $$0}} /^#endif/{skp=0}' \
|
||||
${MAKE_FILE} > $@
|
||||
${MAKE_FILE} | \
|
||||
${GREP} -v '#\.#' | \
|
||||
${SED} -e 's;^# SRC:.*;# SRC: non-GNU Makefile via;' \
|
||||
-e 's;via$$;via ${MAKE} -f ${MAKE_FILE} custom/$@;' > $@
|
||||
${Q} echo >> $@
|
||||
${Q} echo 'Makefile.simple:' >> $@
|
||||
${Q} echo ' $${Q} if [ ! -f Makefile.simple ]; then '"\\" >> $@
|
||||
@@ -170,7 +188,7 @@ Makefile.simple: ${MAKE_FILE}
|
||||
|
||||
depend:
|
||||
${Q} if [ -f ${MAKE_FILE}.bak ]; then \
|
||||
echo "${MAKE_FILE}.bak exists, remove or move it"; \
|
||||
echo "custom/${MAKE_FILE}.bak exists, remove or move it"; \
|
||||
exit 1; \
|
||||
else \
|
||||
${TRUE}; \
|
||||
@@ -186,9 +204,7 @@ depend:
|
||||
fi; \
|
||||
done
|
||||
-${Q} for i in ${H_SRC} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if [ "$$i" = "/dev/null" ]; then continue; fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/custom/$$i"; \
|
||||
echo "#define $$tag" >> "skel/custom/$$i"; \
|
||||
@@ -197,25 +213,25 @@ depend:
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/custom/$$i"; \
|
||||
done
|
||||
${Q} (cd ..; ${MAKE} -f ${TOP_MAKE_FILE} hsrc)
|
||||
${Q} for i in `cd ..; ${MAKE} -f ${TOP_MAKE_FILE} h_list 2>&1 | \
|
||||
${SED} -e '/Entering directory/d' \
|
||||
-e '/Nothing to be done/d' \
|
||||
-e '/Leaving directory/d'` /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/$$i"; \
|
||||
echo "#define $$tag" >> "skel/$$i"; \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' "../$$i" \
|
||||
>> "skel/$$i"; \
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/$$i"; \
|
||||
done
|
||||
${MAKE} -f ../${TOP_MAKE_FILE} h_list 2>/dev/null | \
|
||||
while read i; do \
|
||||
if [ ! -f "../$$i" ]; then continue; fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/$$i"; \
|
||||
echo "#define $$tag" >> "skel/$$i"; \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' "../$$i" \
|
||||
>> "skel/$$i"; \
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/$$i"; \
|
||||
done
|
||||
${Q} ${RM} -f skel/custom/makedep.out
|
||||
${Q} echo custom/skel formed
|
||||
${Q} echo forming custom dependency list
|
||||
${Q} :> skel/custom/makedep.out
|
||||
${Q} cd skel/custom; ${MAKEDEPEND} -I.. -w 1 -f makedep.out ${C_SRC}
|
||||
${Q} cd skel/custom; ${MAKEDEPEND} \
|
||||
-I../../.. -w 1 -f makedep.out -- \
|
||||
${CFLAGS} -- \
|
||||
${C_SRC} 2>/dev/null
|
||||
${Q} ${SED} -e 's|: ../../|: |' -E -i '' -l 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/'; \
|
||||
@@ -230,22 +246,16 @@ depend:
|
||||
${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} echo removing skel
|
||||
${Q} ${RM} -rf skel
|
||||
-${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \
|
||||
echo 'custom ${MAKE_FILE} was already up to date'; \
|
||||
echo 'custom/${MAKE_FILE} was already up to date'; \
|
||||
echo 'restoring original custom/${MAKE_FILE}'; \
|
||||
${MV} -f ${MAKE_FILE}.bak ${MAKE_FILE}; \
|
||||
else \
|
||||
${RM} -f ${MAKE_FILE}.tmp; \
|
||||
${MV} ${MAKE_FILE} ${MAKE_FILE}.tmp; \
|
||||
if [ -d RCS -a ! -w "${MAKE_FILE}" ]; then \
|
||||
${CO} -l ${MAKE_FILE}; \
|
||||
fi ;\
|
||||
${MV} ${MAKE_FILE}.tmp ${MAKE_FILE}; \
|
||||
if [ -d RCS ]; then \
|
||||
echo '****************************************************'; \
|
||||
echo 'new custom ${MAKE_FILE} formed -- you to check it in'; \
|
||||
echo '****************************************************'; \
|
||||
fi; \
|
||||
echo 'old custom/${MAKE_FILE} is now custom/${MAKE_FILE}.bak'; \
|
||||
echo 'new custom/${MAKE_FILE} formed'; \
|
||||
echo 'try: diff -u custom/${MAKE_FILE}.bak custom/${MAKE_FILE}'; \
|
||||
fi
|
||||
|
||||
##
|
||||
@@ -292,6 +302,7 @@ clobber: clean
|
||||
${RM} -f libcustcalc${LIB_EXT}
|
||||
${RM} -f libcustcalc.a
|
||||
${RM} -f libcustcalc*
|
||||
${RM} -rf skel
|
||||
${V} echo remove files that are obsolete
|
||||
#if 0 /* start of skip for non-Gnu makefiles */
|
||||
${RM} -f Makefile.simple
|
||||
@@ -538,6 +549,7 @@ uninstall:
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
c_argv.o: ../alloc.h
|
||||
c_argv.o: ../banned.h
|
||||
c_argv.o: ../block.h
|
||||
c_argv.o: ../byteswap.h
|
||||
c_argv.o: ../calc.h
|
||||
@@ -548,6 +560,7 @@ c_argv.o: ../custom.h
|
||||
c_argv.o: ../decl.h
|
||||
c_argv.o: ../endian_calc.h
|
||||
c_argv.o: ../hash.h
|
||||
c_argv.o: ../have_ban_pragma.h
|
||||
c_argv.o: ../have_const.h
|
||||
c_argv.o: ../have_memmv.h
|
||||
c_argv.o: ../have_newstr.h
|
||||
@@ -563,6 +576,7 @@ c_argv.o: ../value.h
|
||||
c_argv.o: ../zmath.h
|
||||
c_argv.o: c_argv.c
|
||||
c_devnull.o: ../alloc.h
|
||||
c_devnull.o: ../banned.h
|
||||
c_devnull.o: ../block.h
|
||||
c_devnull.o: ../byteswap.h
|
||||
c_devnull.o: ../calcerr.h
|
||||
@@ -572,6 +586,7 @@ c_devnull.o: ../custom.h
|
||||
c_devnull.o: ../decl.h
|
||||
c_devnull.o: ../endian_calc.h
|
||||
c_devnull.o: ../hash.h
|
||||
c_devnull.o: ../have_ban_pragma.h
|
||||
c_devnull.o: ../have_const.h
|
||||
c_devnull.o: ../have_memmv.h
|
||||
c_devnull.o: ../have_newstr.h
|
||||
@@ -588,6 +603,7 @@ c_devnull.o: ../value.h
|
||||
c_devnull.o: ../zmath.h
|
||||
c_devnull.o: c_devnull.c
|
||||
c_help.o: ../alloc.h
|
||||
c_help.o: ../banned.h
|
||||
c_help.o: ../block.h
|
||||
c_help.o: ../byteswap.h
|
||||
c_help.o: ../calcerr.h
|
||||
@@ -597,6 +613,7 @@ c_help.o: ../custom.h
|
||||
c_help.o: ../decl.h
|
||||
c_help.o: ../endian_calc.h
|
||||
c_help.o: ../hash.h
|
||||
c_help.o: ../have_ban_pragma.h
|
||||
c_help.o: ../have_const.h
|
||||
c_help.o: ../have_memmv.h
|
||||
c_help.o: ../have_newstr.h
|
||||
@@ -613,6 +630,7 @@ c_help.o: ../value.h
|
||||
c_help.o: ../zmath.h
|
||||
c_help.o: c_help.c
|
||||
c_pmodm127.o: ../alloc.h
|
||||
c_pmodm127.o: ../banned.h
|
||||
c_pmodm127.o: ../block.h
|
||||
c_pmodm127.o: ../byteswap.h
|
||||
c_pmodm127.o: ../calcerr.h
|
||||
@@ -622,6 +640,7 @@ c_pmodm127.o: ../custom.h
|
||||
c_pmodm127.o: ../decl.h
|
||||
c_pmodm127.o: ../endian_calc.h
|
||||
c_pmodm127.o: ../hash.h
|
||||
c_pmodm127.o: ../have_ban_pragma.h
|
||||
c_pmodm127.o: ../have_const.h
|
||||
c_pmodm127.o: ../have_memmv.h
|
||||
c_pmodm127.o: ../have_newstr.h
|
||||
@@ -637,6 +656,7 @@ c_pmodm127.o: ../value.h
|
||||
c_pmodm127.o: ../zmath.h
|
||||
c_pmodm127.o: c_pmodm127.c
|
||||
c_pzasusb8.o: ../alloc.h
|
||||
c_pzasusb8.o: ../banned.h
|
||||
c_pzasusb8.o: ../block.h
|
||||
c_pzasusb8.o: ../byteswap.h
|
||||
c_pzasusb8.o: ../calcerr.h
|
||||
@@ -646,6 +666,7 @@ c_pzasusb8.o: ../custom.h
|
||||
c_pzasusb8.o: ../decl.h
|
||||
c_pzasusb8.o: ../endian_calc.h
|
||||
c_pzasusb8.o: ../hash.h
|
||||
c_pzasusb8.o: ../have_ban_pragma.h
|
||||
c_pzasusb8.o: ../have_const.h
|
||||
c_pzasusb8.o: ../have_memmv.h
|
||||
c_pzasusb8.o: ../have_newstr.h
|
||||
@@ -661,6 +682,7 @@ c_pzasusb8.o: ../value.h
|
||||
c_pzasusb8.o: ../zmath.h
|
||||
c_pzasusb8.o: c_pzasusb8.c
|
||||
c_register.o: ../alloc.h
|
||||
c_register.o: ../banned.h
|
||||
c_register.o: ../block.h
|
||||
c_register.o: ../byteswap.h
|
||||
c_register.o: ../calc.h
|
||||
@@ -671,6 +693,7 @@ c_register.o: ../custom.h
|
||||
c_register.o: ../decl.h
|
||||
c_register.o: ../endian_calc.h
|
||||
c_register.o: ../hash.h
|
||||
c_register.o: ../have_ban_pragma.h
|
||||
c_register.o: ../have_const.h
|
||||
c_register.o: ../have_memmv.h
|
||||
c_register.o: ../have_newstr.h
|
||||
@@ -686,6 +709,7 @@ c_register.o: ../value.h
|
||||
c_register.o: ../zmath.h
|
||||
c_register.o: c_register.c
|
||||
c_sysinfo.o: ../alloc.h
|
||||
c_sysinfo.o: ../banned.h
|
||||
c_sysinfo.o: ../block.h
|
||||
c_sysinfo.o: ../byteswap.h
|
||||
c_sysinfo.o: ../calc.h
|
||||
@@ -698,6 +722,7 @@ c_sysinfo.o: ../decl.h
|
||||
c_sysinfo.o: ../endian_calc.h
|
||||
c_sysinfo.o: ../fposval.h
|
||||
c_sysinfo.o: ../hash.h
|
||||
c_sysinfo.o: ../have_ban_pragma.h
|
||||
c_sysinfo.o: ../have_const.h
|
||||
c_sysinfo.o: ../have_memmv.h
|
||||
c_sysinfo.o: ../have_newstr.h
|
||||
@@ -718,6 +743,7 @@ c_sysinfo.o: ../zrand.h
|
||||
c_sysinfo.o: ../zrandom.h
|
||||
c_sysinfo.o: c_sysinfo.c
|
||||
custtbl.o: ../alloc.h
|
||||
custtbl.o: ../banned.h
|
||||
custtbl.o: ../block.h
|
||||
custtbl.o: ../byteswap.h
|
||||
custtbl.o: ../calcerr.h
|
||||
@@ -727,6 +753,7 @@ custtbl.o: ../custom.h
|
||||
custtbl.o: ../decl.h
|
||||
custtbl.o: ../endian_calc.h
|
||||
custtbl.o: ../hash.h
|
||||
custtbl.o: ../have_ban_pragma.h
|
||||
custtbl.o: ../have_const.h
|
||||
custtbl.o: ../have_memmv.h
|
||||
custtbl.o: ../have_newstr.h
|
||||
@@ -740,3 +767,7 @@ custtbl.o: ../str.h
|
||||
custtbl.o: ../value.h
|
||||
custtbl.o: ../zmath.h
|
||||
custtbl.o: custtbl.c
|
||||
|
||||
##################################################
|
||||
# NOTE: End of section from custom/Makefile.tail #
|
||||
##################################################
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_argv - a custom function display info about its args
|
||||
*
|
||||
* Copyright (C) 1999-2006 Landon Curt Noll
|
||||
* Copyright (C) 1999-2006,2021 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
|
||||
@@ -38,6 +38,10 @@
|
||||
|
||||
#include "have_unused.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* c_argv - a custom function display info about its args
|
||||
*
|
||||
@@ -49,7 +53,7 @@
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_argv(char UNUSED *name, int count, VALUE **vals)
|
||||
c_argv(char *UNUSED(name), int count, VALUE **vals)
|
||||
{
|
||||
VALUE result; /* what we will return */
|
||||
ZVALUE zfilelen; /* length of a file as a ZVALUE */
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_devnull - a custom function that does nothing
|
||||
*
|
||||
* Copyright (C) 1999-2004 Landon Curt Noll
|
||||
* Copyright (C) 1999-2004,2021 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
|
||||
@@ -39,6 +39,9 @@
|
||||
#include "have_unused.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* c_devnull - a custom function that does nothing
|
||||
*
|
||||
@@ -47,7 +50,7 @@
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_devnull(char UNUSED *name, int UNUSED count, VALUE UNUSED **vals)
|
||||
c_devnull(char *UNUSED(name), int UNUSED(count), VALUE **UNUSED(vals))
|
||||
{
|
||||
VALUE result; /* what we will return */
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_help - custom help function
|
||||
*
|
||||
* Copyright (C) 1999-2004 Landon Curt Noll
|
||||
* Copyright (C) 1999-2004,2021 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
|
||||
@@ -39,6 +39,9 @@
|
||||
#include "have_unused.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* c_help - custom help function
|
||||
*
|
||||
@@ -58,7 +61,7 @@
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_help(char UNUSED *name, int UNUSED count, VALUE **vals)
|
||||
c_help(char *UNUSED(name), int UNUSED(count), VALUE **vals)
|
||||
{
|
||||
VALUE result; /* what we will return */
|
||||
|
||||
|
@@ -35,6 +35,10 @@
|
||||
|
||||
#include "have_unused.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/* 2^255 */
|
||||
STATIC HALF h255[] = {
|
||||
#if BASEB == 32
|
||||
@@ -71,7 +75,7 @@ STATIC ZVALUE lastmodinv[1];
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_pmodm127(char UNUSED *name, int UNUSED count, VALUE **vals)
|
||||
c_pmodm127(char *UNUSED(name), int UNUSED(count), VALUE **vals)
|
||||
{
|
||||
VALUE result; /* what we will return */
|
||||
ZVALUE q; /* test factor */
|
||||
|
@@ -35,6 +35,10 @@
|
||||
|
||||
#include "have_unused.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* c_pzasusb8 - print numerator as a string of USB8s
|
||||
*
|
||||
@@ -47,7 +51,7 @@
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_pzasusb8(char UNUSED *name, int UNUSED count, VALUE **vals)
|
||||
c_pzasusb8(char *UNUSED(name), int UNUSED(count), VALUE **vals)
|
||||
{
|
||||
VALUE result; /* what we will return */
|
||||
ZVALUE z; /* numerator of the value */
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_register - set or print a custom register value
|
||||
*
|
||||
* Copyright (C) 2007 Landon Curt Noll
|
||||
* Copyright (C) 2007,2021 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
|
||||
@@ -39,6 +39,9 @@
|
||||
#include "have_unused.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* registers
|
||||
*/
|
||||
@@ -76,7 +79,7 @@ init_custreg(void)
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_register(char UNUSED *name, int count, VALUE **vals)
|
||||
c_register(char *UNUSED(name), int count, VALUE **vals)
|
||||
{
|
||||
VALUE result; /* what we will return */
|
||||
long reg; /* register number */
|
||||
|
@@ -57,6 +57,9 @@
|
||||
#include "have_unused.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* sys_info - names and values of selected #defines
|
||||
*/
|
||||
@@ -266,7 +269,7 @@ S_FUNC void dump_mening_value(void); /* custom("sysinfo", 2) */
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_sysinfo(char UNUSED *name, int count, VALUE **vals)
|
||||
c_sysinfo(char *UNUSED(name), int count, VALUE **vals)
|
||||
{
|
||||
VALUE result; /* what we will return */
|
||||
struct infoname *p; /* current infoname */
|
||||
|
@@ -30,6 +30,10 @@
|
||||
#include "value.h"
|
||||
#include "custom.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* NOTE: See the file CUSTOM for instructions on how to add
|
||||
* custom functions.
|
||||
|
@@ -13,7 +13,7 @@ DESCRIPTION
|
||||
|
||||
This custom function will return the value:
|
||||
|
||||
q mod 2^(2^127-1)
|
||||
q mod 2^(2^127-1)
|
||||
|
||||
This custom function serves as a demonstration of how to write
|
||||
a custom function. It performs the equivalent of:
|
||||
|
2
decl.h
2
decl.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* decl - variable and function declaration macros
|
||||
*
|
||||
* Copyright (C) 2007,2014 Landon Curt Noll
|
||||
* Copyright (C) 2007,2014,2021 Landon Curt Noll
|
||||
*
|
||||
* Primary author: Landon Curt Noll
|
||||
*
|
||||
|
4
endian.c
4
endian.c
@@ -42,6 +42,10 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/* byte order array */
|
||||
char byte[8] = { (char)0x12, (char)0x36, (char)0x48, (char)0x59,
|
||||
(char)0x01, (char)0x23, (char)0x45, (char)0x67 };
|
||||
|
53
file.c
53
file.c
@@ -37,17 +37,23 @@
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#include <ctype.h>
|
||||
#include "calc.h"
|
||||
#include "alloc.h"
|
||||
#include "longbits.h"
|
||||
#include "have_fpos.h"
|
||||
#include "have_fpos_pos.h"
|
||||
#include "fposval.h"
|
||||
#include "file.h"
|
||||
#include "calcerr.h"
|
||||
#include "strl.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define READSIZE 1024 /* buffer size for reading */
|
||||
|
||||
#define MIN(a,b) (((a) <= (b)) ? (a) : (b))
|
||||
@@ -141,6 +147,7 @@ file_init(void)
|
||||
files[idnum].reading = TRUE;
|
||||
files[idnum].writing = TRUE;
|
||||
files[idnum].action = 0;
|
||||
memset(files[idnum].mode, 0, MODE_LEN+1);
|
||||
/*
|
||||
* stat the descriptor to see what we have
|
||||
*/
|
||||
@@ -148,16 +155,19 @@ file_init(void)
|
||||
size_t snprintf_len; /* malloced snprintf length */
|
||||
fp = (FILE *) fdopen(i,"r+"); /*guess mode*/
|
||||
if (fp) {
|
||||
strcpy(files[idnum].mode, "r+");
|
||||
strlcpy(files[idnum].mode, "r+",
|
||||
sizeof(files[idnum].mode));
|
||||
} else {
|
||||
fp = (FILE *) fdopen(i, "r");
|
||||
if (fp) {
|
||||
strcpy(files[idnum].mode, "r");
|
||||
strlcpy(files[idnum].mode, "r",
|
||||
sizeof(files[idnum].mode));
|
||||
files[idnum].writing = FALSE;
|
||||
} else {
|
||||
fp = (FILE *) fdopen(i, "w");
|
||||
if (fp) {
|
||||
strcpy(files[idnum].mode, "w");
|
||||
strlcpy(files[idnum].mode, "w",
|
||||
sizeof(files[idnum].mode));
|
||||
files[idnum].reading = FALSE;
|
||||
}
|
||||
else
|
||||
@@ -208,10 +218,14 @@ S_FUNC void
|
||||
init_fileio(FILEIO *fiop, char *name, char *mode,
|
||||
struct stat *sbufp, FILEID id, FILE *fp)
|
||||
{
|
||||
char modestr[sizeof(fiop->mode)]; /* mode [rwa]b?\+? */
|
||||
size_t namelen; /* length of name */
|
||||
char modestr[MODE_LEN+1]; /* mode [rwa]b?\+? */
|
||||
size_t namelen; /* length of name */
|
||||
|
||||
/* clear modestr */
|
||||
memset(modestr, 0, sizeof(modestr));
|
||||
|
||||
/* allocate filename if requested */
|
||||
namelen = 0;
|
||||
if (name != NULL) {
|
||||
namelen = strlen(name);
|
||||
fiop->name = (char *)malloc(namelen + 1);
|
||||
@@ -223,7 +237,7 @@ init_fileio(FILEIO *fiop, char *name, char *mode,
|
||||
|
||||
/* initialize FILEIO structure */
|
||||
if (name != NULL) {
|
||||
strncpy(fiop->name, name, namelen+1);
|
||||
strlcpy(fiop->name, name, namelen+1);
|
||||
}
|
||||
fiop->id = id;
|
||||
fiop->fp = fp;
|
||||
@@ -234,7 +248,7 @@ init_fileio(FILEIO *fiop, char *name, char *mode,
|
||||
fiop->appending = FALSE;
|
||||
fiop->binary = FALSE;
|
||||
fiop->action = 0;
|
||||
fiop->mode[0] = '\0';
|
||||
memset(fiop->mode, 0, sizeof(fiop->mode));
|
||||
|
||||
/*
|
||||
* determine file open mode
|
||||
@@ -248,65 +262,65 @@ init_fileio(FILEIO *fiop, char *name, char *mode,
|
||||
if (mode[0] == 'r') {
|
||||
|
||||
/* note read mode */
|
||||
strcpy(modestr, "r");
|
||||
strlcpy(modestr, "r", sizeof(modestr));
|
||||
fiop->reading = TRUE;
|
||||
|
||||
/* note binary mode even though mode is not used / ignored */
|
||||
if (strchr(mode, 'b') != NULL) {
|
||||
strcat(modestr, "b");
|
||||
strlcat(modestr, "b", sizeof(modestr));
|
||||
}
|
||||
|
||||
/* note if reading and writing */
|
||||
if (strchr(mode, '+') != NULL) {
|
||||
fiop->writing = TRUE;
|
||||
strcat(modestr, "+");
|
||||
strlcat(modestr, "+", sizeof(modestr));
|
||||
}
|
||||
|
||||
/* canonicalize write modes */
|
||||
} else if (mode[0] == 'w') {
|
||||
|
||||
/* note write mode */
|
||||
strcpy(modestr, "w");
|
||||
strlcpy(modestr, "w", sizeof(modestr));
|
||||
fiop->writing = TRUE;
|
||||
|
||||
/* note binary mode even though mode is not used / ignored */
|
||||
if (strchr(mode, 'b') != NULL) {
|
||||
strcat(modestr, "b");
|
||||
strlcat(modestr, "b", sizeof(modestr));
|
||||
}
|
||||
|
||||
/* note if reading and writing */
|
||||
if (strchr(mode, '+') != NULL) {
|
||||
fiop->reading = TRUE;
|
||||
strcat(modestr, "+");
|
||||
strlcat(modestr, "+", sizeof(modestr));
|
||||
}
|
||||
|
||||
/* canonicalize append modes */
|
||||
} else if (mode[0] == 'a') {
|
||||
|
||||
/* note append mode */
|
||||
strcpy(modestr, "a");
|
||||
strlcpy(modestr, "a", sizeof(modestr));
|
||||
fiop->writing = TRUE;
|
||||
fiop->appending = TRUE;
|
||||
|
||||
/* note binary mode even though mode is not used / ignored */
|
||||
if (strchr(mode, 'b') != NULL) {
|
||||
strcat(modestr, "b");
|
||||
strlcat(modestr, "b", sizeof(modestr));
|
||||
}
|
||||
|
||||
/* note if reading and writing */
|
||||
if (strchr(mode, '+') != NULL) {
|
||||
fiop->reading = TRUE;
|
||||
strcat(modestr, "+");
|
||||
strlcat(modestr, "+", sizeof(modestr));
|
||||
}
|
||||
|
||||
/* canonicalize no I/O modes */
|
||||
} else {
|
||||
modestr[0] = '\0';
|
||||
}
|
||||
modestr[sizeof(modestr)-1] = '\0'; /* firewall */
|
||||
modestr[MODE_LEN] = '\0'; /* firewall */
|
||||
|
||||
/* record canonical open mode string */
|
||||
strncpy(fiop->mode, modestr, sizeof(fiop->mode));
|
||||
strlcpy(fiop->mode, modestr, sizeof(fiop->mode));
|
||||
}
|
||||
|
||||
|
||||
@@ -1034,6 +1048,9 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
|
||||
case 'e':
|
||||
newmode = MODE_EXP;
|
||||
break;
|
||||
case 'n':
|
||||
newmode = MODE_ENG;
|
||||
break;
|
||||
case 'g':
|
||||
newmode = MODE_REAL_AUTO;
|
||||
break;
|
||||
|
3
file.h
3
file.h
@@ -41,6 +41,7 @@
|
||||
/*
|
||||
* Definition of opened files.
|
||||
*/
|
||||
#define MODE_LEN (sizeof("rb+")-1)
|
||||
typedef struct {
|
||||
FILEID id; /* id to identify this file */
|
||||
FILE *fp; /* real file structure for I/O */
|
||||
@@ -52,7 +53,7 @@ typedef struct {
|
||||
BOOL appending; /* TRUE if also opened for appending */
|
||||
BOOL binary; /* TRUE if binary mode - mode ignored/unused */
|
||||
char action; /* most recent use for 'r', 'w' or 0 */
|
||||
char mode[sizeof("rb+")+1];/* open mode */
|
||||
char mode[MODE_LEN+1]; /* open mode */
|
||||
} FILEIO;
|
||||
|
||||
|
||||
|
@@ -64,6 +64,11 @@
|
||||
#include "have_offscl.h"
|
||||
#include "have_posscl.h"
|
||||
#include "have_fpos_pos.h"
|
||||
#include "alloc.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
char *program; /* our name */
|
||||
|
||||
|
54
fposval.h.def
Normal file
54
fposval.h.def
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* fposval.h.def - fposval.h default macros
|
||||
*
|
||||
* Copyright (C) 2021 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: 2021/03/10 22;14:26
|
||||
* File existed as early as: 2021
|
||||
*
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* WARNING: For some reason fposval failed to generate values
|
||||
* so we choose these values that are hopefully OK
|
||||
*/
|
||||
|
||||
/* what are our file position & size types? */
|
||||
#undef FILEPOS_BITS
|
||||
#define FILEPOS_BITS 64
|
||||
#undef FILEPOS_LEN
|
||||
#define FILEPOS_LEN 8
|
||||
#define SWAP_HALF_IN_FILEPOS(dest, src) (*(dest) = *(src))
|
||||
|
||||
#undef OFF_T_BITS
|
||||
#define OFF_T_BITS 64
|
||||
#undef OFF_T_LEN
|
||||
#define OFF_T_LEN 8
|
||||
#define SWAP_HALF_IN_OFF_T(dest, src) (*(dest) = *(src))
|
||||
|
||||
#undef DEV_BITS
|
||||
#define DEV_BITS 32
|
||||
#undef DEV_LEN
|
||||
#define DEV_LEN 4
|
||||
#define SWAP_HALF_IN_DEV(dest, src) memcpy((void *)(dest), (void *)(src), 4)
|
||||
|
||||
#undef INODE_BITS
|
||||
#define INODE_BITS 64
|
||||
#undef INODE_LEN
|
||||
#define INODE_LEN 8
|
||||
#define SWAP_HALF_IN_INODE(dest, src) memcpy((void *)(dest), (void *)(src), 8)
|
9
hash.c
9
hash.c
@@ -26,16 +26,23 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "have_string.h"
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "calc.h"
|
||||
#include "alloc.h"
|
||||
#include "value.h"
|
||||
#include "zrand.h"
|
||||
#include "zrandom.h"
|
||||
#include "hash.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* external hash_setup functions
|
||||
*/
|
||||
|
71
have_ban_pragma.c
Normal file
71
have_ban_pragma.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* have_ban_pragma.c - Determine if we have #pragma GCC poison func_name
|
||||
*
|
||||
* Copyright (C) 2021 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: 2021/03/08 01:02:34
|
||||
* File existed as early as: 2021
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* usage:
|
||||
* have_ban_pragma
|
||||
*
|
||||
* Not all systems have #pragma GCC poison func_name, so this may not
|
||||
* compile on your system.
|
||||
*
|
||||
* This prog outputs several defines:
|
||||
*
|
||||
* HAVE_PRAGMA_GCC_POSION
|
||||
* defined ==> use #pragma GCC poison func_name
|
||||
* undefined ==> do not use #pragma GCC poison func_name
|
||||
*
|
||||
* NOTE: Modern clang compilers allow for 'pragma GCC poison func_name'.
|
||||
* This is NOT simply a GCC feature.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/* undef UNBAN to be undefined to force use of banned.h */
|
||||
#undef UNBAN
|
||||
|
||||
/* prevent banned.h from including have_ban_pragma.h */
|
||||
#define PRE_HAVE_BAN_PRAGMA_H
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#if defined(HAVE_NO_PRAGMA_GCC_POSION)
|
||||
|
||||
printf("#undef HAVE_PRAGMA_GCC_POSION /* no */\n");
|
||||
|
||||
#else /* HAVE_NO_PRAGMA_GCC_POSION */
|
||||
|
||||
printf("#define HAVE_PRAGMA_GCC_POSION /* yes */\n");
|
||||
|
||||
#endif /* HAVE_NO_PRAGMA_GCC_POSION */
|
||||
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
@@ -41,9 +41,12 @@
|
||||
* (nothing) ==> const not used
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_fpos - Determine if have fgetpos and fsetpos functions
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2021 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,9 +31,12 @@
|
||||
* appropriate have_fpos.h file body.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_fpos_pos - Determine if a __pos element in FILEPOS
|
||||
*
|
||||
* Copyright (C) 2000 Landon Curt Noll
|
||||
* Copyright (C) 2000,2021 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,11 +31,14 @@
|
||||
* __pos element in a non-scalar FILEPOS.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "have_fpos.h"
|
||||
#include "have_posscl.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
@@ -53,8 +56,8 @@ main(void)
|
||||
printf("#define FPOS_POS_BITS %d\n", FPOS_POS_BITS);
|
||||
printf("#define FPOS_POS_LEN %d\n", int(FPOS_POS_BITS/8));
|
||||
# else
|
||||
printf("#define FPOS_POS_BITS %d\n", sizeof(pos.__pos)*8);
|
||||
printf("#define FPOS_POS_LEN %d\n", sizeof(pos.__pos));
|
||||
printf("#define FPOS_POS_BITS %lu\n", sizeof(pos.__pos)*8);
|
||||
printf("#define FPOS_POS_LEN %lu\n", sizeof(pos.__pos));
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
@@ -38,12 +38,17 @@
|
||||
* undefined ==> do not or cannot call getpgid()
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "have_unistd.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@@ -38,13 +38,17 @@
|
||||
* undefined ==> do not or cannot call getprid()
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "have_unistd.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@@ -38,13 +38,17 @@
|
||||
* undefined ==> do not call or cannot call getsid()
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "have_unistd.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_gettime - determine if we have clock_gettime()
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2021 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -40,9 +40,13 @@
|
||||
* CLOCK_SGI_CYCLE and CLOCK_REALTIME
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
10
have_memmv.c
10
have_memmv.c
@@ -38,9 +38,15 @@
|
||||
* undefined ==> use internal slow memmove() instead
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "have_string.h"
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define MOVELEN 3
|
||||
|
||||
|
@@ -40,9 +40,15 @@
|
||||
* use index() instead of strchr()
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "have_string.h"
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define MOVELEN 3
|
||||
|
||||
|
@@ -42,7 +42,6 @@
|
||||
* undefined ==> convert to ZVALUE first
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -51,6 +50,10 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@@ -41,7 +41,6 @@
|
||||
* undefined ==> convert to ZVALUE first
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -51,6 +50,10 @@
|
||||
#endif
|
||||
#include "have_fpos.h"
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_rusage - Determine if we have getrusage()
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2021 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
|
||||
@@ -38,10 +38,14 @@
|
||||
* undefined ==> do not call or cannot call getrusage()
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_stdvs - try <stdarg.h> to see if it really works with vsnprintf()
|
||||
*
|
||||
* Copyright (C) 1999,2014,2018 Landon Curt Noll
|
||||
* Copyright (C) 1999,2014,2018,2021 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
|
||||
@@ -38,7 +38,6 @@
|
||||
* include file.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "have_unistd.h"
|
||||
@@ -65,6 +64,10 @@
|
||||
# define VSNPRINTF_SIZE_T long
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
char buf[BUFSIZ+1];
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_strdup - determine if we have strdup()
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2021 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
|
||||
@@ -38,8 +38,15 @@
|
||||
* undefined ==> do not call or cannot call strdup()
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "have_string.h"
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
|
76
have_strlcat.c
Normal file
76
have_strlcat.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* have_strlcat - determine if we have strlcat()
|
||||
*
|
||||
* Copyright (C) 2021 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: 2021/03/08 20:34:13
|
||||
* File existed as early as: 2021
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* usage:
|
||||
* have_strlcat
|
||||
*
|
||||
* Not all systems have the strlcat() function, so this may not
|
||||
* compile on your system.
|
||||
*
|
||||
* This prog outputs several defines:
|
||||
*
|
||||
* HAVE_STRLCAT
|
||||
* defined ==> use strlcat()
|
||||
* undefined ==> do not or cannot call strlcat()
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "have_string.h"
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define BUF_SIZ 5
|
||||
|
||||
char src[BUF_SIZ+1] = "abcde";
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#if defined(HAVE_NO_STRLCAT)
|
||||
|
||||
printf("#undef HAVE_STRLCAT /* no */\n");
|
||||
|
||||
#else /* HAVE_NO_STRLCAT */
|
||||
char dst[BUF_SIZ+1+1];
|
||||
|
||||
dst[0] = 'S';
|
||||
dst[1] = '\0';
|
||||
(void) strlcat(dst, src, sizeof(dst));
|
||||
|
||||
printf("#define HAVE_STRLCAT /* yes */\n");
|
||||
|
||||
#endif /* HAVE_NO_STRLCAT */
|
||||
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
74
have_strlcpy.c
Normal file
74
have_strlcpy.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* have_strlcpy - determine if we have strlcpy()
|
||||
*
|
||||
* Copyright (C) 2021 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: 2021/03/08 20:34:13
|
||||
* File existed as early as: 2021
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* usage:
|
||||
* have_strlcpy
|
||||
*
|
||||
* Not all systems have the strlcpy() function, so this may not
|
||||
* compile on your system.
|
||||
*
|
||||
* This prog outputs several defines:
|
||||
*
|
||||
* HAVE_STRLCPY
|
||||
* defined ==> use strlcpy()
|
||||
* undefined ==> do not or cannot call strlcpy()
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "have_string.h"
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define BUF_SIZ (sizeof("abcde")-1)
|
||||
|
||||
char src[BUF_SIZ+1] = "abcde";
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#if defined(HAVE_NO_STRLCPY)
|
||||
|
||||
printf("#undef HAVE_STRLCPY /* no */\n");
|
||||
|
||||
#else /* HAVE_NO_STRLCPY */
|
||||
char dst[BUF_SIZ+1];
|
||||
|
||||
(void) strlcpy(dst, src, sizeof(dst));
|
||||
|
||||
printf("#define HAVE_STRLCPY /* yes */\n");
|
||||
|
||||
#endif /* HAVE_NO_STRLCPY */
|
||||
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_uid_t - Determine if we want or can support uid_t
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2021 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
|
||||
@@ -37,7 +37,6 @@
|
||||
* undefined ==> do not use uid_t
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(HAVE_NO_UID_T)
|
||||
@@ -49,6 +48,10 @@
|
||||
#include <sys/types.h>
|
||||
#endif /* ! HAVE_NO_UID_T */
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_unused - Determine if we want or can support the unused attribute
|
||||
*
|
||||
* Copyright (C) 2004 Landon Curt Noll
|
||||
* Copyright (C) 2004,2021 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
|
||||
@@ -42,22 +42,25 @@
|
||||
* (nothing) ==> unused not used
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#if !defined(HAVE_NO_UNUSED)
|
||||
|
||||
/* make sure that we can use the __attribute__((unused)) in #define's */
|
||||
/* make sure that we can use the __attribute__((x)) in #define's */
|
||||
#undef UNUSED
|
||||
#define UNUSED __attribute__((unused))
|
||||
#define UNUSED(x) UNUSED_ ## x __attribute__((unused))
|
||||
|
||||
/*
|
||||
* unused_str - a function with an unused argument
|
||||
*/
|
||||
static char *
|
||||
unused_str(char UNUSED *str)
|
||||
unused_str(char *UNUSED(str))
|
||||
{
|
||||
return "__attribute__((unused))";
|
||||
return "UNUSED_ ## x __attribute__((unused))";
|
||||
}
|
||||
|
||||
#endif /* !HAVE_NO_UNUSED */
|
||||
@@ -68,15 +71,17 @@ main(void)
|
||||
{
|
||||
#if defined(HAVE_NO_UNUSED)
|
||||
|
||||
printf("#undef HAVE_UNUSED /* no */\n");
|
||||
printf("#undef UNUSED\n");
|
||||
printf("#define UNUSED /* no */\n");
|
||||
printf("#if defined(__LCLINT__)\n");
|
||||
printf("# define UNUSED(x) /*@unused@*/ x\n");
|
||||
printf("#else\n");
|
||||
printf("# define UNUSED(x) x\n");
|
||||
printf("#endif\n");
|
||||
|
||||
#else /* HAVE_NO_UNUSED */
|
||||
|
||||
printf("#define HAVE_UNUSED /* yes */\n");
|
||||
printf("#undef UNUSED\n");
|
||||
printf("#define UNUSED %s /* yes */\n", unused_str(NULL));
|
||||
printf("#define UNUSED(x) %s\n", unused_str(NULL));
|
||||
|
||||
#endif /* HAVE_NO_UNUSED */
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_ustat - Determine if we have ustat()
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2021 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
|
||||
@@ -38,11 +38,15 @@
|
||||
* undefined ==> do not call or cannot call ustat()
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ustat.h>
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
12
have_varvs.c
12
have_varvs.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_varvs - try <varargs.h> to see if it really works with vsnprintf()
|
||||
*
|
||||
* Copyright (C) 1999,2018 Landon Curt Noll
|
||||
* Copyright (C) 1999,2018,2021 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
|
||||
@@ -35,7 +35,6 @@
|
||||
* include file.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "have_unistd.h"
|
||||
@@ -56,10 +55,17 @@
|
||||
# define VSNPRINTF_SIZE_T long
|
||||
#endif
|
||||
|
||||
#if !defined(STDARG) && !defined(SIMULATE_STDARG)
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
char buf[BUFSIZ+1];
|
||||
|
||||
#if !defined(STDARG) && !defined(SIMULATE_STDARG)
|
||||
#include <varargs.h>
|
||||
|
||||
void
|
||||
try_nthis(char *fmt, VSNPRINTF_SIZE_T size, ...)
|
||||
|
62
help.c
62
help.c
@@ -29,6 +29,7 @@
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include "calc.h"
|
||||
#include "conf.h"
|
||||
@@ -45,6 +46,9 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
/*
|
||||
* some help topics are symbols, so we alias them to nice filenames
|
||||
*/
|
||||
@@ -80,6 +84,9 @@ STATIC struct help_alias {
|
||||
{"show", "command"},
|
||||
{"stdlib", "resource"},
|
||||
{"question", "questions"},
|
||||
{"dm2d", "dms2d"},
|
||||
{"gm2g", "gms2g"},
|
||||
{"hm2d", "hms2d"},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -256,6 +263,7 @@ givehelp(char *type)
|
||||
}
|
||||
snprintf(helppath, snprintf_len, "%s/%s", calc_helpdir, type);
|
||||
helppath[snprintf_len] = '\0'; /* paranoia */
|
||||
errno = 0;
|
||||
stream = fopen(helppath, "r");
|
||||
if (stream != NULL) {
|
||||
|
||||
@@ -270,30 +278,42 @@ givehelp(char *type)
|
||||
* open the helpfile (looking in CUSTOMHELPDIR last)
|
||||
*/
|
||||
} else {
|
||||
char *cust_helppath; /* path to the custom help file */
|
||||
size_t cust_snprintf_len; /* malloced custom snprintf buf len */
|
||||
char *cust_helppath; /* path to the custom help file */
|
||||
size_t cust_snprintf_len; /* malloced custom snprintf buf len */
|
||||
|
||||
cust_snprintf_len = strlen(calc_customhelpdir)+1+strlen(type) + 1;
|
||||
cust_helppath = (char *)malloc(cust_snprintf_len+1);
|
||||
if (cust_helppath == NULL) {
|
||||
fprintf(stderr, "malloc failure for givehelp #1\n");
|
||||
return;
|
||||
}
|
||||
snprintf(cust_helppath, cust_snprintf_len,
|
||||
"%s/%s", calc_customhelpdir, type);
|
||||
cust_helppath[cust_snprintf_len] = '\0'; /* paranoia */
|
||||
stream = fopen(cust_helppath, "r");
|
||||
if (stream != NULL) {
|
||||
cust_snprintf_len =
|
||||
strlen(calc_customhelpdir)+1+strlen(type) + 1;
|
||||
cust_helppath = (char *)malloc(cust_snprintf_len+1);
|
||||
if (cust_helppath == NULL) {
|
||||
fprintf(stderr, "malloc failure for givehelp #1\n");
|
||||
return;
|
||||
}
|
||||
snprintf(cust_helppath, cust_snprintf_len,
|
||||
"%s/%s", calc_customhelpdir, type);
|
||||
cust_helppath[cust_snprintf_len] = '\0'; /* paranoia */
|
||||
errno = 0;
|
||||
stream = fopen(cust_helppath, "r");
|
||||
if (stream != NULL) {
|
||||
|
||||
/*
|
||||
* we have the help file open, now display it
|
||||
*/
|
||||
page_file(stream);
|
||||
(void) fclose(stream);
|
||||
}
|
||||
free(cust_helppath);
|
||||
cust_helppath = NULL;
|
||||
/*
|
||||
* we have the help file open, now display it
|
||||
*/
|
||||
page_file(stream);
|
||||
(void) fclose(stream);
|
||||
|
||||
/* unable to open help file */
|
||||
} else {
|
||||
fprintf(stderr, "unable to open help file: %s - %s\n",
|
||||
type, strerror(errno));
|
||||
}
|
||||
free(cust_helppath);
|
||||
cust_helppath = NULL;
|
||||
|
||||
#else /* CUSTOM */
|
||||
/* unable to open help file */
|
||||
} else {
|
||||
fprintf(stderr, "unable to open help file: %s - %s\n",
|
||||
type, strerror(errno));
|
||||
#endif /* CUSTOM */
|
||||
}
|
||||
|
||||
|
172
help/Makefile
172
help/Makefile
@@ -4,6 +4,14 @@
|
||||
#
|
||||
# Copyright (C) 1999-2006,2017,2021 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.
|
||||
#
|
||||
# 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.
|
||||
@@ -27,15 +35,64 @@
|
||||
# calculator by David I. Bell with help/mods from others
|
||||
# Makefile by Landon Curt Noll
|
||||
|
||||
# required vars
|
||||
|
||||
# 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/sh
|
||||
#SHELL= /bin/bash
|
||||
#SHELL= /bin/zsh
|
||||
|
||||
|
||||
####
|
||||
# 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
|
||||
|
||||
# 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
|
||||
@@ -91,15 +148,15 @@ INCDIR= /usr/include
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
#BINDIR= /usr/local/bin
|
||||
#BINDIR= ${PREFIX}/bin
|
||||
#BINDIR= /dev/env/DJDIR/bin
|
||||
BINDIR= /usr/bin
|
||||
|
||||
#LIBDIR= /usr/local/lib
|
||||
#LIBDIR= ${PREFIX}/lib
|
||||
#LIBDIR= /dev/env/DJDIR/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
||||
#CALC_SHAREDIR= ${PREFIX}/lib/calc
|
||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
@@ -157,31 +214,55 @@ T=
|
||||
|
||||
# Makefile debug
|
||||
#
|
||||
# Q=@ do not echo internal makefile actions (quiet mode)
|
||||
# Q= echo internal makefile actions (debug / verbose mode)
|
||||
# Q=@ do not echo internal Makefile actions (quiet mode)
|
||||
# Q= echo internal Makefile actions (debug / verbose mode)
|
||||
#
|
||||
# H=@: do not report hsrc file formation progress
|
||||
# H=@ do echo hsrc file formation progress
|
||||
#
|
||||
# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation
|
||||
# S= full ${CC} output during hsrc file formation
|
||||
#
|
||||
# E= 2>/dev/null slience command stderr during hsrc file formation
|
||||
# E= full command stderr during hsrc file formation
|
||||
#
|
||||
# V=@: do not echo debug statements (quiet mode)
|
||||
# V=@ do echo debug statements (debug / verbose mode)
|
||||
#
|
||||
#Q=
|
||||
Q=@
|
||||
#
|
||||
S= >/dev/null 2>&1
|
||||
#S=
|
||||
#
|
||||
E= 2>/dev/null
|
||||
#E=
|
||||
#
|
||||
#H=@:
|
||||
H=@
|
||||
#
|
||||
V=@:
|
||||
#V=@
|
||||
|
||||
# standard tools
|
||||
#
|
||||
LCC= cc
|
||||
ICFLAGS=
|
||||
ILDFLAGS=
|
||||
GREP= egrep
|
||||
CAT= cat
|
||||
CHMOD= chmod
|
||||
SED= sed
|
||||
SORT= sort
|
||||
FMT= fmt
|
||||
CMP= cmp
|
||||
CP= cp
|
||||
MV= mv
|
||||
TRUE= true
|
||||
RM= rm
|
||||
FMT= fmt
|
||||
GREP= egrep
|
||||
ICFLAGS=
|
||||
ILDFLAGS=
|
||||
LCC= cc
|
||||
MKDIR= mkdir
|
||||
MV= mv
|
||||
RM= rm
|
||||
RMDIR= rmdir
|
||||
SED= sed
|
||||
SORT= sort
|
||||
TOUCH= touch
|
||||
CAT= cat
|
||||
TRUE= true
|
||||
|
||||
# Some out of date operating systems require / want an executable to
|
||||
# end with a certain file extension. Some compile systems such as
|
||||
@@ -233,7 +314,7 @@ BLT_HELP_FILES_13= bugs changes
|
||||
|
||||
STD_HELP_FILES_14= credit
|
||||
|
||||
BLT_HELP_FILES_14= contrib COPYING COPYING-LGPL question
|
||||
BLT_HELP_FILES_14= contrib COPYING COPYING-LGPL questions
|
||||
|
||||
STD_HELP_FILES_15= wishlist todo
|
||||
|
||||
@@ -275,23 +356,23 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
|
||||
#
|
||||
# Please use:
|
||||
#
|
||||
# make detail_help_list
|
||||
# make clobber >/dev/null && make detail_help_list
|
||||
#
|
||||
# to keep this list in nice sorted order and to check that these
|
||||
# non-special help files are under RCS control.
|
||||
# to keep this list in nice sorted order.
|
||||
#
|
||||
DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \
|
||||
append appr arg argv arrow asec asech asin asinh assign atan atan2 \
|
||||
atanh avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
|
||||
btrunc calc_tty calclevel calcpath catalan ceil cfappr cfsim char \
|
||||
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime delete \
|
||||
den dereference det digit digits display dp epsilon errcount errmax \
|
||||
errno error estr euler eval exp fact factor fclose fcnt feof ferror \
|
||||
fflush fgetc fgetfield fgetfile fgetline fgets fgetstr fib files floor \
|
||||
fopen forall fpathopen fprintf fputc fputs fputstr frac free \
|
||||
freebernoulli freeeuler freeglobals freeredc freestatics frem freopen \
|
||||
fscan fscanf fseek fsize ftell gcd gcdrem gd getenv hash head highbit \
|
||||
hmean hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert int \
|
||||
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime d2dm \
|
||||
d2dms d2g d2r delete den dereference det digit digits display dms2d dp \
|
||||
epsilon errcount errmax errno error estr euler eval exp fact factor \
|
||||
fclose fcnt feof ferror fflush fgetc fgetfield fgetfile fgetline fgets \
|
||||
fgetstr fib files floor fopen forall fpathopen fprintf fputc fputs \
|
||||
fputstr frac free freebernoulli freeeuler freeglobals freeredc \
|
||||
freestatics frem freopen fscan fscanf fseek fsize ftell g2d g2gm g2gms \
|
||||
g2r gcd gcdrem gd getenv gms2g h2hm h2hms hash head highbit hmean \
|
||||
hms2h hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert int \
|
||||
inverse iroot isalnum isalpha isassoc isatty isblk iscntrl isconfig \
|
||||
isdefined isdigit iserror iseven isfile isgraph ishash isident isint \
|
||||
islist islower ismat ismult isnull isnum isobj isobjtype isodd isprime \
|
||||
@@ -302,13 +383,14 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \
|
||||
name near newerror nextcand nextprime norm null num oldvalue ord param \
|
||||
perm pfact pi pix places pmod polar poly pop popcnt pound power \
|
||||
prevcand prevprime printf prompt protect ptest push putenv quo quomod \
|
||||
rand randbit random randombit randperm rcin rcmul rcout rcpow rcsq re \
|
||||
remove reverse rewind rm root round rsearch runtime saveval scale scan \
|
||||
scanf search sec sech seed segment select sgn sha1 sin sinh size \
|
||||
sizeof sleep sort sqrt srand srandom ssq stoponerror str strcasecmp \
|
||||
strcat strcmp strcpy strerror strlen strncasecmp strncmp strncpy \
|
||||
strpos strprintf strscan strscanf strtolower strtoupper substr sum \
|
||||
swap system systime tail tan tanh test time trunc usertime version xor
|
||||
r2d r2g rand randbit random randombit randperm rcin rcmul rcout rcpow \
|
||||
rcsq re remove reverse rewind rm root round rsearch runtime saveval \
|
||||
scale scan scanf search sec sech seed segment select sgn sha1 sin sinh \
|
||||
size sizeof sleep sort sqrt srand srandom ssq stoponerror str \
|
||||
strcasecmp strcat strcmp strcpy strerror strlen strncasecmp strncmp \
|
||||
strncpy strpos strprintf strscan strscanf strtolower strtoupper substr \
|
||||
sum swap system systime tail tan tanh test time trunc usertime version \
|
||||
xor
|
||||
|
||||
# This list is of files that are clones of DETAIL_HELP files. They are
|
||||
# built from DETAIL_HELP files.
|
||||
@@ -517,7 +599,7 @@ COPYING-LGPL: ../COPYING-LGPL
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
question: ../QUESTIONS
|
||||
questions: ../QUESTIONS
|
||||
${RM} -f $@
|
||||
${CP} ../QUESTIONS $@
|
||||
${CHMOD} 0444 $@
|
||||
@@ -618,8 +700,8 @@ builtin: builtin.top builtin.end ../func.c funclist.sed
|
||||
${Q} ${SED} -n -f funclist.sed ../func.c > funclist.c
|
||||
${Q} ${RM} -f funclist.o funclist${EXT}
|
||||
${Q} ${LCC} ${ICFLAGS} -DFUNCLIST -I/usr/include \
|
||||
-I.. funclist.c -c 2>/dev/null
|
||||
${Q} ${LCC} ${ILDFLAGS} funclist.o -o funclist${EXT}
|
||||
-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} ./funclist${EXT} | \
|
||||
@@ -649,7 +731,7 @@ distlist: ${DISTLIST}
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo help/$$i; \
|
||||
fi; \
|
||||
done | LANG=C ${SORT}
|
||||
done | fgrep -v '.bak' | LANG=C ${SORT}
|
||||
|
||||
distdir:
|
||||
${Q} echo help
|
||||
@@ -686,15 +768,11 @@ detail_help_list:
|
||||
! -name mat ! -name obj.file ! -name operator \
|
||||
! -name overview ! -name script ! -name statement \
|
||||
! -name todo ! -name types ! -name unexpected \
|
||||
! -name variable ! -name wishlist ! -name question \
|
||||
! -name variable ! -name wishlist ! -name questions \
|
||||
-print | \
|
||||
while read i; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
if [ ! -f RCS/$$i,v ]; then \
|
||||
echo "WARNING: $$i not under RCS control" 1>&2; \
|
||||
else \
|
||||
echo $$i; \
|
||||
fi; \
|
||||
echo $$i; \
|
||||
fi; \
|
||||
done; \
|
||||
echo '--first_line--') | \
|
||||
@@ -725,7 +803,7 @@ echo_inst_files:
|
||||
|
||||
clean:
|
||||
${RM} -f obj mkbuiltin funclist.c funclist.o funclist${EXT}
|
||||
${RM} -f COPYING COPYING-LGPL question
|
||||
${RM} -f COPYING COPYING-LGPL questions
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${BLT_HELP_FILES} full .all calc
|
||||
|
45
help/argv
45
help/argv
@@ -11,14 +11,33 @@ TYPES
|
||||
|
||||
DESCRIPTION
|
||||
Without args, this builtin returns the number of calc command line
|
||||
strings available.
|
||||
strings available, including the program or script name.
|
||||
|
||||
If the numeric arg is supplied, then the corresponding command line
|
||||
string is return, if it exists. Otherwise a nul() value is returned.
|
||||
|
||||
In keeping with the argc/argv convention of C, argv(0) will refer
|
||||
to the 1st argv string, and argv(argv()-1) will refer to the last.
|
||||
This differs from the way the param() builtin works.
|
||||
to the name of the program. If the -f filename argument is used,
|
||||
then argv(0) will refer to the filename. In the case of a #! script,
|
||||
assuming the calc is located in /usr/local/bin/calc, the first
|
||||
line of a calc script would be:
|
||||
|
||||
#!/usr/local/bin/calc -f
|
||||
...
|
||||
|
||||
then argv(0) will refer to the filename of the script.
|
||||
|
||||
As it is common to use -q in a calc script, and using that same
|
||||
/usr/local/bin/calc location:
|
||||
|
||||
#!/usr/local/bin/calc -q -f
|
||||
...
|
||||
|
||||
and again, argv(0) will refer to the filename of the script.
|
||||
|
||||
The 1st argument to calc will be argv(1), and argv(argv()-1)
|
||||
will refer to the last. This differs from the way the param()
|
||||
builtin works.
|
||||
|
||||
By default, calc will evaluate all of its command line arguments.
|
||||
However, if calc is invoked with -s, all non-dashed options will
|
||||
@@ -27,22 +46,26 @@ DESCRIPTION
|
||||
calc -i 2+2
|
||||
|
||||
will cause calc to print 4 and enter interactive mode. In this case
|
||||
argv() will return 0.
|
||||
argv() will return 1.
|
||||
|
||||
On the other hand:
|
||||
|
||||
calc -i -s 2+2
|
||||
|
||||
will cause calc to interactive mode. The argv() builtin will return 1
|
||||
and argv(0) will return the string "2+2".
|
||||
will cause calc to interactive mode. The argv() builtin will return 2
|
||||
and argv(1) will return the string "2+2".
|
||||
|
||||
EXAMPLE
|
||||
$ calc -s a bb ccc
|
||||
; argc = argv();
|
||||
; for (i = 0; i < argc; i++) print "argv[": i : '] = "': argv(i) : '"';
|
||||
argv[0] = "a"
|
||||
argv[1] = "bb"
|
||||
argv[2] = "ccc"
|
||||
; print "argc =", argc;
|
||||
argc = 4
|
||||
; print 'argv[0] = "': argv(0) : '"';
|
||||
argv[0] = "calc"
|
||||
; for (i = 1; i < argc; i++) print "argv[": i : '] = "': argv(i) : '"';
|
||||
argv[1] = "a"
|
||||
argv[2] = "bb"
|
||||
argv[3] = "ccc"
|
||||
|
||||
LIMITS
|
||||
0 <= n < 2^31
|
||||
@@ -53,7 +76,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
param, system, usage
|
||||
|
||||
## Copyright (C) 1999-2006 Landon Curt Noll
|
||||
## Copyright (C) 1999-2006,2021 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
|
||||
|
@@ -44,6 +44,9 @@ DESCRIPTION
|
||||
"sci"
|
||||
"exp"
|
||||
|
||||
1000 "engineering" base 10 notation with exponent
|
||||
"eng" multiple of 3
|
||||
|
||||
For convenience, any non-integer value is assumed to mean base 10
|
||||
fractions and any integer >= 2^64 is assumed to mean base 10
|
||||
scientific notation.
|
||||
@@ -76,7 +79,7 @@ LINK LIBRARY
|
||||
int math_setmode(int newmode)
|
||||
|
||||
NOTE: newmode must be one of MODE_DEFAULT, MODE_FRAC, MODE_INT,
|
||||
MODE_REAL, MODE_EXP, MODE_HEX, MODE_OCTAL, MODE_BINARY
|
||||
MODE_REAL, MODE_EXP, MODE_ENG, MODE_HEX, MODE_OCTAL, MODE_BINARY
|
||||
|
||||
SEE ALSO
|
||||
base2, config, str
|
||||
|
@@ -50,6 +50,9 @@ DESCRIPTION
|
||||
"sci"
|
||||
"exp"
|
||||
|
||||
1000 "engineering" base 10 notation with exponent
|
||||
"eng" multiple of 3
|
||||
|
||||
0 "off" disable double base output
|
||||
|
||||
For convenience, any non-integer non-zero value is assumed to mean
|
||||
@@ -76,7 +79,7 @@ EXAMPLE
|
||||
10 /* 012 */
|
||||
; base2(16),
|
||||
; 131072
|
||||
131072 /* 0x20000 */
|
||||
131072 /* 0x20000 */
|
||||
; 2345
|
||||
2345 /* 0x929 */
|
||||
|
||||
@@ -87,13 +90,13 @@ LINK LIBRARY
|
||||
int math_setmode2(int newmode)
|
||||
|
||||
NOTE: newmode must be one of MODE_DEFAULT, MODE_FRAC, MODE_INT,
|
||||
MODE_REAL, MODE_EXP, MODE_HEX, MODE_OCTAL, MODE_BINARY,
|
||||
MODE_REAL, MODE_EXP, MODE_ENG, MODE_HEX, MODE_OCTAL, MODE_BINARY,
|
||||
MODE2_OFF
|
||||
|
||||
SEE ALSO
|
||||
base, config, str
|
||||
|
||||
## Copyright (C) 2002 Landon Curt Noll
|
||||
## Copyright (C) 2002,2021 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
|
||||
|
17
help/config
17
help/config
@@ -165,8 +165,8 @@ DESCRIPTION
|
||||
config("display", int)
|
||||
|
||||
The "display" parameter specifies the maximum number of digits after
|
||||
the decimal point to be printed in real or exponential mode in
|
||||
normal unformatted printing (print, strprint, fprint) or in
|
||||
the decimal point to be printed in real, exponential or engineering
|
||||
mode in normal unformatted printing (print, strprint, fprint) or in
|
||||
formatted printing (printf, strprintf, fprintf) when precision is not
|
||||
specified. The initial value for oldstd is 20, for newstd 10.
|
||||
The parameter may be changed to the value d by either
|
||||
@@ -234,6 +234,9 @@ DESCRIPTION
|
||||
"sci"
|
||||
"exp"
|
||||
|
||||
"engineering" base 10 notation with exponent base(10e6)
|
||||
"eng" multiple of 3
|
||||
|
||||
Where multiple strings are given, the first string listed is what
|
||||
config("mode") will return.
|
||||
|
||||
@@ -863,10 +866,10 @@ DESCRIPTION
|
||||
when a variable name collides with an exist name of a higher scope.
|
||||
Examples of collisions are when:
|
||||
|
||||
* both local and static variables have the same name
|
||||
* both local and global variables have the same name
|
||||
* both function parameter and local variables have the same name
|
||||
* both function parameter and global variables have the same name
|
||||
* both local and static variables have the same name
|
||||
* both local and global variables have the same name
|
||||
* both function parameter and local variables have the same name
|
||||
* both function parameter and global variables have the same name
|
||||
|
||||
The initial "redecl_warn" value is 1.
|
||||
|
||||
@@ -892,7 +895,7 @@ EXAMPLE
|
||||
1
|
||||
|
||||
; config("version")
|
||||
"2.12.0"
|
||||
"2.12.0"
|
||||
|
||||
; config("all")
|
||||
mode "real"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user