mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
64a732b678 | ||
|
a6a37f9cad | ||
|
42b089a87c | ||
|
8c5e9e62fa | ||
|
29e956819c | ||
|
66c3d26611 | ||
|
b4952bd44f | ||
|
0d06d90751 | ||
|
e1a3dfda0b | ||
|
8db4e7af47 | ||
|
bb5c624382 | ||
|
8aedcf801a | ||
|
b60eec99bb | ||
|
383290a844 | ||
|
7e40db44e3 |
89
BUGS
89
BUGS
@@ -47,7 +47,7 @@ When you send your report, please include the following information:
|
||||
|
||||
* a description of the problem
|
||||
* the version of calc you are using (if you cannot get calc
|
||||
it to run, then send us the 4 #define lines from version.c)
|
||||
to run, then send us the 4 #define lines from version.c)
|
||||
* if you modified calc from an official patch, send me the mods you made
|
||||
* the type of system you were using
|
||||
* the type of compiler you were using
|
||||
@@ -72,7 +72,62 @@ Known bugs:
|
||||
us know! See the above for details on how to report and were to
|
||||
EMail your bug reports and hopefully patches to fix them.
|
||||
|
||||
Problems with known work-a-rounds:
|
||||
* The following command:
|
||||
|
||||
calc 'read ellip; efactor(13*17*19)'
|
||||
|
||||
will generate the following error:
|
||||
|
||||
efactor(iN,ia,B,force) defined
|
||||
point_print(p) defined
|
||||
point_mul(p1,p2) defined
|
||||
point_square(p) defined
|
||||
point_pow(p,pow) defined
|
||||
A = 1
|
||||
2 (1,1)
|
||||
"point_square": line 165: Not initializing matrix, object or list
|
||||
Error in commands
|
||||
|
||||
This is not an error in the ellip standard calc resource files.
|
||||
It is a bug inside calc. Versions going back as far as version
|
||||
2.11.4t2 in the year 2000 (and perhaps even further) alll have
|
||||
this bug.
|
||||
|
||||
Anyone want to track down and fix this bug?
|
||||
|
||||
=-=
|
||||
|
||||
mis-features in calc:
|
||||
|
||||
Some problems are not bugs but rarther mis-features / things that could
|
||||
work better. The following is a list of mis-features that should be
|
||||
addressed and improved someday.
|
||||
|
||||
* The chi.cal resource file does not work well with odd degrees
|
||||
of freedom. Can someone improve this algorithm?
|
||||
|
||||
* The intfile.cal resource file reads and writes big or little Endian
|
||||
integers to/from files the hard way. It does NOT use blkcpy. The
|
||||
following code:
|
||||
|
||||
i = (ord("\n") << 16) | (ord("i") << 8) | ord("H")
|
||||
b = blk()
|
||||
copy(i, b)
|
||||
fd = fopen("file", "w")
|
||||
copy(b, fd);
|
||||
fclose(fd)
|
||||
|
||||
will write an extra NUL octet to the file. Where as:
|
||||
|
||||
read intfile
|
||||
i = (ord("\n") << 16) | (ord("i") << 8) | ord("H")
|
||||
be2file(i, "file2")
|
||||
|
||||
will not.
|
||||
|
||||
=-=
|
||||
|
||||
Problems with old systems that have known work-a-rounds:
|
||||
|
||||
* The gcc as shipped with Redhat 7 perhaps other Linux distributions
|
||||
has a bug causes calc to dump core on startup when calc is:
|
||||
@@ -86,7 +141,9 @@ Problems with known work-a-rounds:
|
||||
AND
|
||||
|
||||
when calc is compiled with readline (see USE_READLINE,
|
||||
READLINE_LIB and READLINE_INCLUDE in the Makefile)
|
||||
READLINE_LIB and READLINE_INCLUDE in the Makefile)
|
||||
|
||||
This is known as the Redhat 7 readlne problem.
|
||||
|
||||
On Redhat, the gcc -v which has this problem is:
|
||||
|
||||
@@ -250,28 +307,6 @@ Problems with known work-a-rounds:
|
||||
or performance. The work-a-round is to ignore these warnings
|
||||
under BSDI.
|
||||
|
||||
* The chi.cal resource file does not work well with odd degrees
|
||||
of freedom. Can someone improve this algorithm?
|
||||
|
||||
* The intfile.cal resource file reads and writes big or little Endian
|
||||
integers to/from files the hard way. It does NOT use blkcpy. The
|
||||
following code:
|
||||
|
||||
i = (ord("\n") << 16) | (ord("i") << 8) | ord("H")
|
||||
b = blk()
|
||||
copy(i, b)
|
||||
fd = fopen("file", "w")
|
||||
copy(b, fd);
|
||||
fclose(fd)
|
||||
|
||||
will write an extra NUL octet to the file. Where as:
|
||||
|
||||
read intfile
|
||||
i = (ord("\n") << 16) | (ord("i") << 8) | ord("H")
|
||||
be2file(i, "file2")
|
||||
|
||||
will not.
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
@@ -288,8 +323,8 @@ Problems with known work-a-rounds:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.17 $
|
||||
## @(#) $Id: BUGS,v 29.17 2001/12/31 22:12:35 chongo Exp $
|
||||
## @(#) $Revision: 29.21 $
|
||||
## @(#) $Id: BUGS,v 29.21 2004/10/23 01:13:51 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/BUGS,v $
|
||||
##
|
||||
## Under source code control: 1994/03/18 14:06:13
|
||||
|
574
CHANGES
574
CHANGES
@@ -1,4 +1,368 @@
|
||||
The following are the changes from calc version 2.11.5.5 to date:
|
||||
The following are the changes from calc version 2.11.10.1 to date:
|
||||
|
||||
Fixed a bug reported by the sourceforge user: cedars where:
|
||||
|
||||
ln(exp(6)) == 3 /* WRONG!!! */
|
||||
|
||||
incorrectly returned 1. This bug was fixed by Ernest Bowen
|
||||
<ernie at turing dot une dot edu dot au>. The regression test
|
||||
was expanded to cover this issue.
|
||||
|
||||
Added minor improvements to hash regression testing of pi().
|
||||
|
||||
Fixed "help script" and the calc man page regarding the requirement
|
||||
of -f to be the last -flag in shell script mode. Further clarified
|
||||
the meaning and placement of the -f flag.
|
||||
|
||||
Moved issues with chi.cal intfile.cal into a "mis-features" section
|
||||
of the BUGS file. See "help bugs" or the BUGS source file for details.
|
||||
|
||||
Added the bug about:
|
||||
|
||||
calc 'read ellip; efactor(13*17*19)'
|
||||
|
||||
to the BUGS file. See "help bugs" or the BUGS source file for details.
|
||||
Anyone want to track down and fix this bug?
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.10 to 2.11.10:
|
||||
|
||||
The cygwin config value is correctly tested while doing comparisons
|
||||
between config states.
|
||||
|
||||
Added config("compile_custom") to determine if calc was compiled
|
||||
with -DCUSTOM. By default, the Makefile uses ALLOW_CUSTOM= -DCUSTOM
|
||||
so by default, config("compile_custom") is TRUE. If, however,
|
||||
calc is compiled without -DCUSTOM, then config("compile_custom")
|
||||
will be FALSE. NOTE: The config("compile_custom") value is only
|
||||
affected by compile flags. The calc -D runtime command line option
|
||||
does not change the config("compile_custom") value. This is a
|
||||
read-only configuration value.
|
||||
|
||||
Added config("allow_custom") to determine if the use of custom
|
||||
functions are allowed. To allow the use of custom functions, calc
|
||||
must be compiled with -DCUSTOM (which it is by default) AND calc run
|
||||
be run with the -D runtime command line option (which it is not by
|
||||
default). If config("allow_custom") is TRUE, then custom functions
|
||||
are allowed. If config("allow_custom") is FALSE, then custom
|
||||
functions are not allowed. This is a read-only configuration value.
|
||||
|
||||
Correctly hash config state for windows and cygwin values. The value
|
||||
of config("compile_custom") and config("allow_custom") also affect
|
||||
the hash of the config state.
|
||||
|
||||
Fixed the custom/argv.cal test code to avoid use of a reserved
|
||||
builtin function name.
|
||||
|
||||
Fixed custom/*.cal scripts to conform better with the cal/*.cal
|
||||
resource files.
|
||||
|
||||
Removed the Makefile variables ${LONGLONG_BITS}, ${HAVE_LONGLONG},
|
||||
and ${L64_FORMAT}. Removed longlong.c and longlong.h. The use
|
||||
of HAVE_LONGLONG=0 was problematic. The lack of complaints about
|
||||
the HAVE_LONGLONG=0 shows that the 'long long' type is wide spread
|
||||
enough warrent not trying to support compilers without 'long long'.
|
||||
|
||||
Removed the SVAL and SHVAL macros from zrand.c, zrand.h, and zmath.h
|
||||
as they were causing too many broken C pre-processors and C checkers
|
||||
to become confused.
|
||||
|
||||
Added a 'make splint' rule to use the splint statically checking
|
||||
tool on the calc source.
|
||||
|
||||
Removed support of the BSDI platform. The BSDI platform is no longer
|
||||
directly supported and we lost our last BSDI machine on which we
|
||||
could test calc. Best wishes to the former BSDI folk and thanks
|
||||
for breaking important ground in the Open Source Movement!
|
||||
|
||||
Fixed several typos found in the documentation and buildin
|
||||
function output by C Smith <smichr at hotmail dot com>.
|
||||
|
||||
Fixed -d so that:
|
||||
|
||||
calc -d 2/3
|
||||
|
||||
will print 0.66666666666666666667 without the leading tilde as
|
||||
advertised in the man page.
|
||||
|
||||
Added a missing help file for the display builtin function as
|
||||
requested by Igor Furlan <primorec at sbcglobal dot net>.
|
||||
|
||||
Changed the "help environment" file to reflect modern default
|
||||
values of CALCPATH and CALCRC.
|
||||
|
||||
Added missing variables for printing by the "make env" rule.
|
||||
|
||||
Added EXT Makefile variable so that Cygwin can install calc as
|
||||
calc.exe. By default, EXT is empty so that calc is calc on most
|
||||
modern operating systems. Thanks goes to Ullal Devappa Kini <wmbfqj
|
||||
at vsnl dot net> for helping identify this problem and testing our fix.
|
||||
|
||||
Added custom function:
|
||||
|
||||
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
|
||||
more complex custom function. Call calc with the -C flag to
|
||||
use custom functions.
|
||||
|
||||
Made slight changes to the custom/HOW_TO_ADD documentation.
|
||||
|
||||
Fixed some \ formatting man page problems as reported by Keh-Cheng
|
||||
Chu <kehcheng at quake dot Stanford dot edu>.
|
||||
|
||||
Fixed some comparison between signed and unsigned in md5.c
|
||||
that was reported for the PowerMac G5 2GHz MacOS 10.3 by
|
||||
Guillaume VERGNAUD <vergnaud at via dot ecp dot fr>.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.9 to 2.11.9.3:
|
||||
|
||||
Fixed calc man page examples to move -f to the end of the line.
|
||||
Thanks goes to Michael Somos <somos at grail dot cba dot csuohio
|
||||
dot edu> for pointing this out.
|
||||
|
||||
Linux and gcc now compiled with -Wall -W -Wno-comment.
|
||||
|
||||
Fixed a post increment that was reported by R. Trinler <trinler at
|
||||
web dot de> and fixed by Ernest Bowen <ernie at turing dot une dot
|
||||
edu dot au>.
|
||||
|
||||
Fixed pi.cal to not depend on the buggy pre-2.11.9 post increment
|
||||
behavior.
|
||||
|
||||
Added config("cygwin") to determine if calc was compiled under Cygwin.
|
||||
The config("cygwin") is a read-only configuration value that is 1
|
||||
when calc was compiled under Cygwin and 0 otherwise. Regression
|
||||
tests 949 and 950 are skipped when config("cygwin") is true.
|
||||
|
||||
The Makefile variable HAVE_NO_IMPLICIT is empty by default so that
|
||||
the Makefile will test if the compiler has a -Wno-implicit flag.
|
||||
|
||||
Added HAVE_UNUSED Makefile variable. If HAVE_UNUSED is empty,
|
||||
then the Makefile will run the have_unused program to determine
|
||||
if the unused attribute is supported. If HAVE_UNUSED is set to
|
||||
-DHAVE_NO_UNUSED, then the unused attribute will not be used.
|
||||
|
||||
The Makefile builds have_unused.h which defines, if the unused
|
||||
attribute is supported:
|
||||
|
||||
#define HAVE_UNUSED /* yes */
|
||||
#define UNUSED __attribute__((unused)) /* yes */
|
||||
|
||||
or defines, if the unused is not supported (or if the Makefile
|
||||
variable is HAVE_UNUSED= -DHAVE_NO_UNUSED):
|
||||
|
||||
#undef HAVE_UNUSED /* no */
|
||||
#define UNUSED /* no */
|
||||
|
||||
Fixed numerous warnings about comparison between signed and unsigned
|
||||
value warnings and unused parameter warnings in version.c, zrand.c,
|
||||
string.c, shs1.c, shs.c, qtrans.c, qmath.c, qfunc.c, md5.c, matfunc.c,
|
||||
hist.c, file.c, const.c, blkcpy.c, seed.c, opcodes.c, func.c, qio.c,
|
||||
zrandom.c, custom/c_argv.c, custom/c_devnull.c, custom/c_help.c,
|
||||
custom/c_sysinfo.c, addop.c and calc.c.
|
||||
|
||||
Fixed some typos in this file.
|
||||
|
||||
By default, compile with -O3 -g3. The Makefile comments on how some
|
||||
distributions might need to use -O2 -g or -O -g.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.8.0 to 2.11.8.1:
|
||||
|
||||
Updated HOWTO.INSTALL to reflect the new RPM files.
|
||||
|
||||
Clarify that the internal hash as well as the hash builtin
|
||||
function used by calc, while based on the Fowler/Noll/Vo
|
||||
hash is NOT an FNV hash.
|
||||
|
||||
Made slight performance improvements to calc by an optimization of how
|
||||
calc's internal hash is computed. The "make chk" regression test
|
||||
runs about 1.5% faster (when compiled with -O3 on an AMD Athlon)
|
||||
NO_HASH_CPU_OPTIMIZATION is not defined. Calc's internal hash values
|
||||
have not changed. By default, NO_HASH_CPU_OPTIMIZATION is NOT defined
|
||||
and the slightly faster expression is used.
|
||||
|
||||
A slight modification of what was known as the "calc new standard"
|
||||
configuration (calc -n or config("all", "newstd")) is now the default
|
||||
calc configuration. The flag:
|
||||
|
||||
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
|
||||
away / be used for something else in the future.
|
||||
|
||||
The following table gives the summary of these changes:
|
||||
|
||||
pre v2.11.8 v2.11.8
|
||||
default pre v2.11.8 -O & oldstd v2.11.8
|
||||
and oldstd -n & newstd classic cfg default
|
||||
--------------------------------------------------------
|
||||
epsilon 1e-20 1e-10 1e-20 1e-20
|
||||
quo 2 2 2 2
|
||||
outround 2 24 2 24
|
||||
leadzero 0 1 0 1
|
||||
fullzero 0 1 0 0
|
||||
prompt > ; > ;
|
||||
more >> ;; >> ;;
|
||||
|
||||
With the exception of epsilon being 1e-20, and fullzero being unset,
|
||||
the new default calc config is like it was (pre-2.11.8) with calc -n /
|
||||
config("all", "newstd").
|
||||
|
||||
The new default config is the old classic config with outround being
|
||||
24, leadzero being set, and the prompts being ;'s.
|
||||
|
||||
Fixed a bug in the evaluation of tanh(1e-23) with an epsilon(1e-100).
|
||||
Thanks goes to Dmitry G. Baksheyev <bd at nbsp dot nsk dot su>
|
||||
for reporting the problem, and thanks goes to Ernest Bowen
|
||||
<ernie at turing dot une dot edu dot au> for the fix.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.7.0 to 2.11.7.1:
|
||||
|
||||
Added support to build calc RPMs thanks to Petteri Kettunen
|
||||
<petterik at users dot sourceforge dot net>.
|
||||
|
||||
Added rpm rule to Makefile to build rpm set. The rpm rule
|
||||
uses the rpm.mk Makefile and the calc.spec.in spec template.
|
||||
|
||||
The default Makefile is now the Makefile used during rpm
|
||||
creation. This Makefile assumes that system has readline,
|
||||
ncurses (-lreadline -lhistory -lncurses), and less.
|
||||
It compiled with a high gcc optimization level (-O3 -g3).
|
||||
The Makefile used during rpm creation is the Makefile
|
||||
that appears in the calc-src rpm as well.
|
||||
|
||||
The Makefile shipped with the old style gziped tarball
|
||||
is still the same generic Makefile.
|
||||
|
||||
The Makefile now uses ${MKDIR} ${MKDIR_ARG} when creating
|
||||
directories during installation. By default, it does
|
||||
a mkdir -p when forming directories.
|
||||
|
||||
Fixed attributes on include and lib calc-devel files.
|
||||
|
||||
Adjusted the interaction between rpm.mk, and the calc.spec.in.
|
||||
Release number now comes from calc.spec.in only.
|
||||
|
||||
Renamed calc and calc-devel RPMs to use .i686 instead of .i386.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.6.3 to date:
|
||||
|
||||
Fixed a bug in deg.cal where fixdms() was being called with
|
||||
the wrong type of argument.
|
||||
|
||||
Changed the value of digits(1) and digits(0) to be 1. Now digits()
|
||||
returns number of digits in the standard base-b representation
|
||||
when x is truncated to an integer and the sign is ignored.
|
||||
To be more precise: when abs(int(x)) > 0, this function returns
|
||||
the value 1 + ilog(x, b). When abs(int(x)) == 0, then this
|
||||
function returns the value 1.
|
||||
|
||||
As the result of the above digits() change, the repeat.cal
|
||||
resource file script was modified to remove the special
|
||||
case for repeating a value of 1. Also the regress tests
|
||||
#715, #977 and #978 were changed.
|
||||
|
||||
Made a minor improvement to the "help places" documentation.
|
||||
|
||||
Fixed dms_neg(a) in deg.cal thanks to a bug report by kaa
|
||||
<kaa76 at pochtamt dot ru>.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.6.0 to 2.11.6.2:
|
||||
|
||||
Clarified remark in lucas.cal about use of n mod 2^n == 0.
|
||||
|
||||
Fixed help typos reported by Marc Mezzarobba <mm at mm dot ovh dot org>.
|
||||
|
||||
Forced system("") to return 0 under windoz.
|
||||
|
||||
The direct.h include file is not used when compiling under Cygwin.
|
||||
|
||||
Fixed bug where random(10,11) caused calc to dump core when issued
|
||||
the 2nd time.
|
||||
|
||||
Moved the setting of the Makefile variable ${CALC_INCDIR} to
|
||||
the section where things like ${BINDIR} and ${LIBDIR} are set.
|
||||
Idea from Clifford Kite <kite_public1 at ev1 dot net>.
|
||||
|
||||
The Makefile is shipped mode 0644 since a number of folks
|
||||
edit it (to build and check calc) as a non-root user and later
|
||||
on su to root to install. Idea from Clifford Kite <kite_public1
|
||||
at ev1 dot net>.
|
||||
|
||||
Added base2() builtin function to calc. Normally calc prints
|
||||
values according to base(). Frequently some users want to see
|
||||
a value in two bases. Flipping back and forth between to bases
|
||||
is a bit of a pain. With base2(), calc will output a value twice:
|
||||
|
||||
; 234567
|
||||
234567
|
||||
; base2(16),
|
||||
; 234567
|
||||
234567 /* 0x39447 */
|
||||
; 131072
|
||||
131072 /* 0x20000 */
|
||||
; base2(0),
|
||||
; 131072
|
||||
131072
|
||||
|
||||
By default, base2() is disabled. Calling base2(0) will also turn
|
||||
off the double base mode. Thanks goes to Erik Anggard
|
||||
<erik dot anggard at packetfront dot com> for his idea and
|
||||
his initial patch.
|
||||
|
||||
Added repeat.cal as a calc resource file script:
|
||||
|
||||
repeat(digit_set, repeat_count)
|
||||
|
||||
Return the value of the digit_set repeated repeat_count times.
|
||||
Both digit_set and repeat_count must be integers > 0.
|
||||
|
||||
For example repeat(423,5) returns the value 423423423423423,
|
||||
which is the digit_set 423 repeated 5 times.
|
||||
|
||||
Makefile no longer makes a direct reference to Red Hat 6.0.
|
||||
|
||||
Added missing math_setmode2() prototype to zmath.h.
|
||||
|
||||
Fixed some implicit declarations of functions by either making
|
||||
them explicit or by including the proper system .h files.
|
||||
|
||||
Makefile no longer uses -Wno-implicit flag, by default, for
|
||||
gcc based compiles on calc source. Makefile now attempts to
|
||||
compile no_implicit.c with an explicit -Wno-implicit arg in an
|
||||
effort to determine of -Wno-implicit is a valid compiler flag.
|
||||
If no_implicit.c is compiled with -Wno-implicit, then
|
||||
the file no_implicit.arg is created with the contents
|
||||
of the -Wno-implicit flag. Otherwise no_implicit.arg
|
||||
is created as an empty file.
|
||||
|
||||
Added the Makefile variable ${HAVE_NO_IMPLICIT}, which if
|
||||
not set to YES will prevent no_implicit.c from being
|
||||
compiled and prevent the -Wno-implicit flag from being used.
|
||||
If ${HAVE_NO_IMPLICIT} is not YES, then an empty no_implicit.arg
|
||||
file is created and no_implicit.c is not compiled.
|
||||
|
||||
The seed.c file, because the pseudo_seed() function contains
|
||||
calls to a number of various system functions, attempts to
|
||||
compile with the -Wno-implicit flag (if allowed by the
|
||||
formation of the no_implicit.arg file).
|
||||
|
||||
Misc make depend fixes and cleanup.
|
||||
|
||||
Fixed formation of the custom/.all file.
|
||||
|
||||
Fixed repeat(1, repeat_count) bug.
|
||||
|
||||
|
||||
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:
|
||||
|
||||
@@ -18,6 +382,48 @@ The following are the changes from calc version 2.11.5.5 to date:
|
||||
NOTE: See the BUGS file for a Linux issue when compiling calc
|
||||
with -O (or -O2 or -O3) AND with -g (or -g3) AND with readline.
|
||||
|
||||
Removed an obsolete reference to TOPDIR. This was fixed thanks to
|
||||
a bug report by Clifford Kite <kite_public1 at ev1 dot net>.
|
||||
Fixed other inconsistencies related to things like BINDIR.
|
||||
|
||||
Fixed calc man page so that is refers to -f instead of the old -S flag.
|
||||
Fixed thanks to Clifford Kite <kite_public1 at ev1 dot net> for
|
||||
point this out.
|
||||
|
||||
All for loops end with /dev/null to avoid any problems related
|
||||
to systems that cannot grok empty for loops.
|
||||
|
||||
Changed the libcalc functions creal and cimag to c_real and c_imag
|
||||
to about conflicts with new libc such as those used by gcc v3.
|
||||
Thanks Eli Zaretskii <eliz at is dot elta dot co dot il> and
|
||||
Martin Buck <m at rtin-buck dot de> for alerting us to this conflict.
|
||||
|
||||
The Makefile no longer hard code's /usr/include. Instead it uses
|
||||
the ${INCDIR} Makefile variable. Thanks goes to Eli Zaretskii
|
||||
<eliz at is dot elta dot co dot il> for pointing out this inconsistency.
|
||||
|
||||
Added mods to support compilation under DJGPP. DJGPP runs on 386
|
||||
and newer PCs running DOS or dos-compatible operating systems.
|
||||
See http://www.delorie.com/djgpp/. Thanks goes to Eli Zaretskii
|
||||
<eliz at is dot elta dot co dot il> for sending in these mods.
|
||||
|
||||
Updated README.WINDOWS to include information on building with DJGPP.
|
||||
|
||||
The pld folks are building RPMs based on our calc distributions.
|
||||
See: ftp://ftp.pld.org.pl/dists/ra/PLD/i686/PLD/RPMS or
|
||||
http://ftp.pld.org.pl/dists/ra/PLD/i686/PLD/RPMS more information.
|
||||
We appreciate their work in this regard. In the next release, we
|
||||
plan to also build and release our own RPMs based on their efforts.
|
||||
|
||||
Changed the Makefile variable CUSTOMLIBDIR to CUSTOMCALDIR.
|
||||
Changed the Makefile variable CSHAREDIR to CALC_SHAREDIR.
|
||||
Changed the Makefile variable INCDIRCALC to CALC_INCDIR.
|
||||
Removed the Makefile variable SHAREDIR.
|
||||
|
||||
Updated the HOWTO.INSTALL and README.WINDOWS files.
|
||||
|
||||
Fixed definition of MAXUFULL. Thanks to a bus report from
|
||||
Jill Poland <jpoland at cadence dot com>.
|
||||
|
||||
The following are the changes from calc version 2.11.5t4.1 to 2.11.5t4.4:
|
||||
|
||||
@@ -85,7 +491,7 @@ The following are the changes from calc version 2.11.5t4.1 to 2.11.5t4.4:
|
||||
which calc will be installed. The calc install is performed under $T,
|
||||
the calc build is performed under /. The purpose for $T is to allow
|
||||
someone to install calc somewhere other than into the system area.
|
||||
For examplewhen forming the calc rpm, the Makefile is called with
|
||||
For example when forming the calc rpm, the Makefile is called with
|
||||
T=$RPM_BUILD_ROOT. If $T is empty, calc is installed under /.
|
||||
|
||||
Removed all echo_XXX rules except for echo_inst_files from lower
|
||||
@@ -93,13 +499,13 @@ The following are the changes from calc version 2.11.5t4.1 to 2.11.5t4.4:
|
||||
with T=$RPM_BUILD_ROOT.
|
||||
|
||||
Updated LIBRARY file with instructions related to -DCALC_SRC,
|
||||
the new default include file locatin and -lcustcalc.
|
||||
the new default include file location and -lcustcalc.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.5t3 to 2.11.5t4:
|
||||
|
||||
The Makefile will now send both stdout and sterr to /dev/null
|
||||
when compiling hsrc intermeriates.
|
||||
The Makefile will now send both stdout and stderr to /dev/null
|
||||
when compiling hsrc intermediates.
|
||||
|
||||
The config("verbose_quit") value was restored to a default
|
||||
value of FALSE.
|
||||
@@ -146,7 +552,7 @@ The following are the changes from calc version 2.11.5t3 to 2.11.5t4:
|
||||
|
||||
The Makefile variable ${TOPDIR} is no longer used. In some places
|
||||
it has been replaced by a new Makefile variable ${SHAREDIR}. Some
|
||||
of the old TOPDIR functionality has beenn replaced by ${CSHAREDIR}.
|
||||
of the old TOPDIR functionality has been replaced by ${CSHAREDIR}.
|
||||
|
||||
The install rules no longer remove old obsolete files. We assume
|
||||
that these old files have long since vanished! :-)
|
||||
@@ -236,7 +642,7 @@ The following are the changes from calc version 2.11.5t0 to 2.11.5t1.1:
|
||||
|
||||
Added HAVE_MALLOC_H, HAVE_STDLIB_H, HAVE_STRING_H, HAVE_TIMES_H,
|
||||
HAVE_SYS_TIMES_H, HAVE_TIME_H, HAVE_SYS_TIME_H, HAVE_UNISTD_H
|
||||
and HAVE_URANDOM to the Makefile. If these symcols are empty,
|
||||
and HAVE_URANDOM to the Makefile. If these symbols are empty,
|
||||
then the Makefile looks for the appropriate system include file.
|
||||
If they are YES, then the Makefile will assume they exist.
|
||||
If they are NO, then the Makefile will assume they do not exist.
|
||||
@@ -257,7 +663,7 @@ The following are the changes from calc version 2.11.5t0 to 2.11.5t1.1:
|
||||
under the win32 directory.
|
||||
|
||||
Added FPOS_POS_BITS, OFF_T_BITS, DEV_BITS and INODE_BITS Makefile
|
||||
symbiols to allow one to force the size of a file position, file
|
||||
symbols to allow one to force the size of a file position, file
|
||||
offset, dev and inode value. Leaving these values blank will
|
||||
Makefile to determine their size.
|
||||
|
||||
@@ -409,7 +815,7 @@ The following are the changes from calc version 2.11.3t0 to 2.11.4:
|
||||
calc -q -i "define f(x) = x^2;"
|
||||
|
||||
To achieve this, the use of getopts() in calc.c has been dropped in
|
||||
favour of direct reading of the arguments produced by the shell.
|
||||
favor of direct reading of the arguments produced by the shell.
|
||||
In effect, until a "--" or "-s" or a calc command (recognized
|
||||
by not starting with '-') is encountered, the quotation signs in
|
||||
command lines like the above example are ignored. Dropping getopts()
|
||||
@@ -538,7 +944,7 @@ The following are the changes from calc version 2.11.3t0 to 2.11.4:
|
||||
|
||||
(11) The effect of config("trace", 8) which displays opcodes of
|
||||
functions as they are successfully defined has been restricted to
|
||||
functions defioed with explicit use of "define". Thus, it has been
|
||||
functions defined with explicit use of "define". Thus, it has been
|
||||
deactivated for the ephemeral functions used for evaluation of calc
|
||||
command lines or eval() functions.
|
||||
|
||||
@@ -677,7 +1083,7 @@ The following are the changes from calc version 2.11.1 to 2.11.1t2.2:
|
||||
#! files calc shell script
|
||||
|
||||
Renamed 'help stdlib' to 'help resource'. The 'help stdlib' is
|
||||
aliased to 'help resource' for ard compatibility.
|
||||
aliased to 'help resource' for arg compatibility.
|
||||
|
||||
Renamed config("lib_debug") to config("resource_debug").
|
||||
The config("lib_debug") will have the same effect as
|
||||
@@ -707,7 +1113,7 @@ The following are the changes from calc version 2.11.0t10 to 2.11.0t11:
|
||||
Misc code cleanup. Removed dead code. Removed trailing whitespace.
|
||||
Fixed whitespace to make the best use of 8 character tabs.
|
||||
|
||||
Fixed some bugs relaing to '// and %' in combination with some
|
||||
Fixed some bugs relating to '// and %' in combination with some
|
||||
of the the rounding modes based on a patch from Ernest Bowen
|
||||
<ernie at turing dot une dot edu dot au>.
|
||||
|
||||
@@ -717,7 +1123,7 @@ The following are the changes from calc version 2.11.0t10 to 2.11.0t11:
|
||||
|
||||
Minor typos fixed in regress.cal
|
||||
|
||||
Added 8500 test serise and test8500.cal to perform more extensive
|
||||
Added 8500 test series and test8500.cal to perform more extensive
|
||||
tests on // and % with various rounding modes.
|
||||
|
||||
The 'unused value ignored' messages now start with Line 999: instead
|
||||
@@ -955,7 +1361,7 @@ The following are the changes from calc version 2.11.0t8.9.1 to 2.11.0t9.4.5:
|
||||
|
||||
Quit or abort executed
|
||||
|
||||
when a non-interactive ABORT, QUIT or EXIT is encounted. By default,
|
||||
when a non-interactive ABORT, QUIT or EXIT is encountered. By default,
|
||||
config("verbose_quit") is TRUE and the message is printed. If one does:
|
||||
|
||||
config("verbose_quit", 0)
|
||||
@@ -1094,11 +1500,11 @@ The following are the changes from calc version 2.11.0t8.9.1 to 2.11.0t9.4.5:
|
||||
by default is /usr/local/include. Include files previously installed
|
||||
directly under ${LIBDIR} will be removed.
|
||||
|
||||
Added the piforever() funcion to lib/pi.cal. It was written by
|
||||
Added the piforever() function to lib/pi.cal. It was written by
|
||||
Klaus Alexander Seistrup <klaus at seistrup dot dk> and was inspired by
|
||||
an algorithm conceived by Lambert Meertens. (See also the ABC
|
||||
Programmer's Handbook, by Geurts, Meertens & Pemberton, published
|
||||
by Prentice-Hall (UK) Ltd., 1990.) The piforever() funcion prints
|
||||
by Prentice-Hall (UK) Ltd., 1990.) The piforever() function prints
|
||||
digits of pi for as long as your memory and system uptime allows. :-)
|
||||
|
||||
Fixed the URLs found thruout the source and documentation which did
|
||||
@@ -1112,7 +1518,7 @@ The following are the changes from calc version 2.11.0t8.9.1 to 2.11.0t9.4.5:
|
||||
|
||||
+ comma operator
|
||||
+ separator of arguments in a function call
|
||||
+ separator of arguments in a defintion
|
||||
+ separator of arguments in a definition
|
||||
etc.
|
||||
|
||||
The expression (mat A[2]), B[3] returns B[3], assuming B already
|
||||
@@ -1155,7 +1561,7 @@ The following are the changes from calc version 2.11.0t8.9.1 to 2.11.0t9.4.5:
|
||||
of including longlong.h will help detect when a system can deal with
|
||||
'long long' but not '%lld' in printf. If a system with 'long long'
|
||||
uses '%ld' to print a 64 bit value, then l_format will be > 0;
|
||||
othewise if "%lld" is required, l_format will be < 0.
|
||||
otherwise if "%lld" is required, l_format will be < 0.
|
||||
|
||||
Added HAVE_STRDUP Makefile variable as well as the have_strdup.c
|
||||
program that forms the have_strdup.h file. The have_strdup.h file
|
||||
@@ -1164,7 +1570,7 @@ The following are the changes from calc version 2.11.0t8.9.1 to 2.11.0t9.4.5:
|
||||
the real strdup() function.
|
||||
|
||||
Calc no longer makes use of sys_errlist and sys_nerr. Some systems
|
||||
no longer suppor these values (even though they should from a
|
||||
no longer support these values (even though they should from a
|
||||
legacy prospective). Calc now relies on the fact that strerror()
|
||||
will return NULL of no such system error exists. System errors >=
|
||||
10000 will be considered calc errors instead. The Makefile symbol
|
||||
@@ -1183,7 +1589,7 @@ The following are the changes from calc version 2.11.0t8.9.1 to 2.11.0t9.4.5:
|
||||
to V_NOSUBTYPE thruout the source code.
|
||||
|
||||
Established a separate calc-bugs address from the calc-tester
|
||||
maining list. Using anti-spam address forms in order to try and
|
||||
mailing list. Using anti-spam address forms in order to try and
|
||||
stay under the radar of spammers as much as one can do so.
|
||||
|
||||
|
||||
@@ -1233,7 +1639,7 @@ The following are the changes from calc version 2.11.0t8 to 2.11.0t8.9:
|
||||
|
||||
Misc source file cleanup for things such as } else { style consistency.
|
||||
|
||||
Fixed the basis for FNV-1 hashes. Piror to this fix, the hash()
|
||||
Fixed the basis for FNV-1 hashes. Prior to this fix, the hash()
|
||||
builtin produced FNV hash values that did not match the FNV-1
|
||||
algorithm as specified in:
|
||||
|
||||
@@ -1256,7 +1662,7 @@ The following are the changes from calc version 2.11.0t8 to 2.11.0t8.9:
|
||||
and:
|
||||
{static a = 5} define f(x) = a + x;
|
||||
|
||||
String constants can now be concatenated. For exmaple:
|
||||
String constants can now be concatenated. For example:
|
||||
|
||||
s = "curds" ' and ' "whey";
|
||||
|
||||
@@ -1325,7 +1731,7 @@ The following are the changes from calc version 2.11.0t8 to 2.11.0t8.9:
|
||||
an error while processing 'args' and drops into interactive mode
|
||||
without the terminal bindings being set.
|
||||
|
||||
Added patch from Ernest Bowen to extablish the abort command as
|
||||
Added patch from Ernest Bowen to establish the abort command as
|
||||
well as to clarify the roles of quit and exit. See the help/command
|
||||
file for details.
|
||||
|
||||
@@ -1472,11 +1878,11 @@ The following are the changes from calc version 2.11.0t7 to 2.11.0t7.5:
|
||||
compile is invoked. Only the source that must be compiled and run
|
||||
on the local machine use ${LCC}; everything else uses ${CC}.
|
||||
|
||||
Fixed memory buffer ovreread problem in eatstring() in token.c.
|
||||
Fixed memory buffer related problem in eatstring() in token.c.
|
||||
|
||||
Fixed memory leaks related to putenv().
|
||||
|
||||
Fixed memory leaks realted to srandom().
|
||||
Fixed memory leaks related to srandom().
|
||||
|
||||
Fixed compilation warnings and problems on BSDI.
|
||||
|
||||
@@ -1778,13 +2184,13 @@ The following are the changes from calc version 2.10.3t5.34 to 2.10.3t5.37:
|
||||
Fixed the order of prints in regress.cal. By convention, a print
|
||||
of a test line happens after the test. This is because function
|
||||
parsed messages occur after the function is parsed. Also the
|
||||
boolean tesrt of vrfy happens before any print statement.
|
||||
Therefore a non-test line is tested and printed as follows:
|
||||
boolean test will verify before any print statements. Therefore
|
||||
a non-test line is tested and printed as follows:
|
||||
|
||||
y = sha();
|
||||
print '7125: y = sha()';
|
||||
|
||||
The perm(a,b) and comb(a,b) have been extented to arbitrary real a and
|
||||
The perm(a,b) and comb(a,b) have been extended to arbitrary real a and
|
||||
integer b.
|
||||
|
||||
Fixed a bug in minv().
|
||||
@@ -1858,7 +2264,7 @@ The following are the changes from calc version 2.10.3t5.34 to 2.10.3t5.37:
|
||||
A = B
|
||||
|
||||
results in A referring to exactly the same string as B rather than to
|
||||
a copy of what is in B. Thie is like the use of character-pointers in
|
||||
a copy of what is in B. This is like the use of character-pointers in
|
||||
C, as in
|
||||
|
||||
char *s1, *s2;
|
||||
@@ -2071,7 +2477,7 @@ The following are the changes from calc version 2.10.3t5.34 to 2.10.3t5.37:
|
||||
if n is negative. I've changed the definitions of head and tail for
|
||||
lists to be consistent with this interpretation of negative n.
|
||||
|
||||
(23) Similarly I've left strpos ezsentially as at present, but search
|
||||
(23) Similarly I've left strpos essentially as at present, but search
|
||||
and rsearch have been extended to strings. For example,
|
||||
|
||||
search(A, B, m, n)
|
||||
@@ -2528,16 +2934,16 @@ The following are the changes from calc version 2.10.3t5.28 to 2.10.3t5.33:
|
||||
|
||||
(11) storing the most recently calculated value of qpi(epsilon)i and
|
||||
epsilon so that when called again with the same epsilon it
|
||||
is copied rather than recalculateed.
|
||||
is copied rather than recalculated.
|
||||
|
||||
(12) defining trace() for square matrices
|
||||
|
||||
(13) expression in parentheses may now be followed by a qualifier
|
||||
computible with its type
|
||||
computable with its type
|
||||
|
||||
When an expression in parentheses evaluates to an lvalue
|
||||
whose current value is a matrix, list or object, it may
|
||||
now be followed by a qualifier computible with its type.
|
||||
now be followed by a qualifier compatible with its type.
|
||||
|
||||
For example:
|
||||
|
||||
@@ -2609,7 +3015,7 @@ The following are the changes from calc version 2.10.3t5.28 to 2.10.3t5.33:
|
||||
|
||||
define f(x) = 5 + x;
|
||||
|
||||
Fixed bug with lowhex2bin converstion in lib_util.c. It did not
|
||||
Fixed bug with lowhex2bin conversation in lib_util.c. It did not
|
||||
correctly convert from hex ASCII to binary values due to a table
|
||||
loading error.
|
||||
|
||||
@@ -2672,7 +3078,7 @@ The following are the changes from calc version 2.10.3t5.11 to 2.10.3t5.27:
|
||||
blocks that have been created, blocks(id) returns the named block
|
||||
with identifying index id.
|
||||
|
||||
Removed the artifical limit of 20 named blocks.
|
||||
Removed the artificial limit of 20 named blocks.
|
||||
|
||||
Added name() builtin to return the name of a type of value
|
||||
as a string.
|
||||
@@ -2735,7 +3141,7 @@ The following are the changes from calc version 2.10.3t5.11 to 2.10.3t5.27:
|
||||
|
||||
Moved blkcpy() routines have been moved to blkcpy.[ch].
|
||||
|
||||
The blkcpy() & copy() builtings can not copy to/from numbers.
|
||||
The blkcpy() & copy() builtins can not copy to/from numbers.
|
||||
For purposes of the copy, only the numerator is ignored.
|
||||
|
||||
Resolved a number of missing symbols for libcalc users.
|
||||
@@ -2881,7 +3287,7 @@ The following are the changes from calc version 2.10.3t5.1 to 2.10.3t5.10:
|
||||
surprises that C programmers may encounter.
|
||||
|
||||
Updated the 'help', 'intro' and 'overview' to reflect the
|
||||
full ilst of non-builtin function help files. Reorered the
|
||||
full list of non-builtin function help files. Reorered the
|
||||
'full' help file.
|
||||
|
||||
The blkalloc() builtin has been renamed blk().
|
||||
@@ -2929,13 +3335,13 @@ The following are the changes from calc version 2.10.3t5.1 to 2.10.3t5.10:
|
||||
|
||||
Added ${LD_DEBUG} Makefile variable to allow for additional
|
||||
libraries to be compiled into calc ... for debugging purposes.
|
||||
In most cases, LD_DEBUG= is sufficent.
|
||||
In most cases, LD_DEBUG= is sufficient.
|
||||
|
||||
Added ${CALC_ENV} makefile variable to allow for particular
|
||||
environment variables to be supplied for make {check,chk,debug}.
|
||||
In most cases, CALC_ENV= CALCPATH=./lib is sufficent.
|
||||
In most cases, CALC_ENV= CALCPATH=./lib is sufficient.
|
||||
|
||||
Added ${CALC_LIBS} to list the libaraies created and used to
|
||||
Added ${CALC_LIBS} to list the libraries created and used to
|
||||
build calc. The CALC_LIBS= custom/libcustcalc.a libcalc.a
|
||||
is standard for everyone.
|
||||
|
||||
@@ -2954,14 +3360,14 @@ The following are the changes from calc version 2.10.3t5.1 to 2.10.3t5.10:
|
||||
The *.c should do that instead where it is reasonable.
|
||||
|
||||
To avoid symbol conflicts, *.h files produced and shipped
|
||||
with calc are inclosed that as similar to the following:
|
||||
with calc are enclosed that as similar to the following:
|
||||
|
||||
#if !defined(__CALC_H__)
|
||||
#define __CALC_H__
|
||||
..
|
||||
#endif /* !__CALC_H__ */
|
||||
|
||||
Added memsize(x) builtin to print the best aproximation of the
|
||||
Added memsize(x) builtin to print the best approximation of the
|
||||
size of 'x' including overhead. The sizeof(x) builtin attempts
|
||||
to cover just the storage of the value and not the overhead.
|
||||
Because -1, 0 and 1 ZVALUES are static common values, sizeof(x)
|
||||
@@ -2986,7 +3392,7 @@ The following are the changes from calc version 2.10.3t4.16 to 2.10.3t5.0:
|
||||
Added more error() and errno() regression tests.
|
||||
|
||||
The convention of using the global variable lib_debug at the
|
||||
end of calc librar scripts has been replaced with config("lib_debug").
|
||||
end of calc library scripts has been replaced with config("lib_debug").
|
||||
The "lib_debug" is reserved by convention for calc library scripts.
|
||||
This config parameter takes the place of the lib_debug global variable.
|
||||
By convention, "lib_debug" has the following meanings:
|
||||
@@ -3040,7 +3446,7 @@ The following are the changes from calc version 2.10.3t4.16 to 2.10.3t5.0:
|
||||
>0 a greater degree of debugging is performed and more
|
||||
verbose messages are printed
|
||||
|
||||
Added more code that is deading with the BLOCK type.
|
||||
Added more code related to the BLOCK type.
|
||||
|
||||
Added blkalloc() builtin.
|
||||
|
||||
@@ -3085,14 +3491,14 @@ The following are the changes from calc version 2.10.3t4.16 to 2.10.3t5.0:
|
||||
arg is "-f", then 'no-such-file' errors are ignored.
|
||||
|
||||
Added errcount([count]) builtin to return or set the error
|
||||
counter. Added errmax([limit]) to rturn or set the error
|
||||
counter. Added errmax([limit]) to return or set the error
|
||||
count limiter.
|
||||
|
||||
Added -n as a calc command line option. This has the effect
|
||||
of calling config("all", "newstd") at startup time.
|
||||
|
||||
Added -e as a calc command line option to ignore all environment
|
||||
varialbes at startup time. The getenv() builtin function will
|
||||
variables at startup time. The getenv() builtin function will
|
||||
still return values, however.
|
||||
|
||||
Added -i as a calc command line option. This has the effect
|
||||
@@ -3275,7 +3681,7 @@ The following are the changes from calc version 2.10.3t3 to 2.10.3t4.15:
|
||||
|
||||
The "blkverbose" determines if all lines, including duplicates
|
||||
should be printed. If TRUE, then all lines are printed. If false,
|
||||
duplicate lines are skipped and only a "*" is printed in a sytle
|
||||
duplicate lines are skipped and only a "*" is printed in a style
|
||||
similar to od. This config value has not meaning if "blkfmt" is
|
||||
"str". The default value for "blkverbose" is FALSE: duplicate
|
||||
lines are not printed.
|
||||
@@ -3348,7 +3754,7 @@ The following are the changes from calc version 2.10.3t0 to 2.10.3t2:
|
||||
|
||||
A lot of work was performed on the code generation by Ernest Bowen
|
||||
<ernie at turing dot une dot edu dot au>. Declarations no longer
|
||||
need to precese code:
|
||||
need to precede code:
|
||||
|
||||
define f(x) {
|
||||
local i = x^2;
|
||||
@@ -3482,7 +3888,7 @@ The following are the changes from calc version 2.10.3t0 to 2.10.3t2:
|
||||
"break", "continue", or "goto", so that only one jump opcode is
|
||||
required.
|
||||
|
||||
A label can now be immediately by a rightbrace. For example:
|
||||
A label can now be immediately by a right-brace. For example:
|
||||
|
||||
define test_newop3(x) {if (x < 0) goto l132; ++x; l132: return x;}
|
||||
|
||||
@@ -3740,7 +4146,7 @@ The following are the changes from calc version 2.10.2t25 to 2.10.2t32:
|
||||
creates four static variables, the first "a" having a very short and
|
||||
useless life.
|
||||
|
||||
Added new tests to verify the new assugnments above.
|
||||
Added new tests to verify the new assignments above.
|
||||
|
||||
Added the builtin test(x) which returns 1 or 0 according as x tests
|
||||
as true or false for conditions.
|
||||
@@ -3781,7 +4187,7 @@ The following are the changes from calc version 2.10.2t4 to 2.10.2t24:
|
||||
so that the entire make is verbose and
|
||||
a constructed files are printed
|
||||
|
||||
Improved instuctions in 'BUGS' section on reporting problems.
|
||||
Improved instructions in 'BUGS' section on reporting problems.
|
||||
In particular we made it easy for people to send in a full
|
||||
diagnostic output by sending 'debug.out' which is made as follows:
|
||||
|
||||
@@ -3796,13 +4202,13 @@ The following are the changes from calc version 2.10.2t4 to 2.10.2t24:
|
||||
|
||||
Attempting to rewind a file this is not open generates an error.
|
||||
|
||||
Noted conversion problems in file.c in tripple X comments.
|
||||
Noted conversion problems in file.c in triple X comments.
|
||||
|
||||
Some extremely braindead shells cannot correctly deal with if
|
||||
cluases that do not have a non-empty else statement. Their
|
||||
Some extremely brain dead shells cannot correctly deal with if
|
||||
clauses that do not have a non-empty else statement. Their
|
||||
exit bogosity results in make problems. As a work-a-round,
|
||||
Makefile if clauses have 'else true;' clauses for if statements
|
||||
that previously did not have an else cluause.
|
||||
that previously did not have an else clause.
|
||||
|
||||
Fixed problems where the input stack depth reached the 10 levels.
|
||||
|
||||
@@ -3917,7 +4323,7 @@ The following are the changes from calc version 2.10.2t4 to 2.10.2t24:
|
||||
A = {{1,2}, {3,4}};
|
||||
|
||||
The config("trace", 8) causes opcodes of newly defined functions
|
||||
are displayed. Also show can now show the opcides for a function.
|
||||
are displayed. Also show can now show the opcodes for a function.
|
||||
For example:
|
||||
|
||||
config("trace", 8);
|
||||
@@ -4023,9 +4429,9 @@ The following are the changes from calc version 2.10.2t4 to 2.10.2t24:
|
||||
Added rm("file") builtin to remove a file.
|
||||
|
||||
The regress test sections that create files also use rm() to remove
|
||||
them before and afterwards.
|
||||
them before and afterward.
|
||||
|
||||
Added 4400-4500 set to test new mat and obj initializaion rules.
|
||||
Added 4400-4500 set to test new mat and obj initialization rules.
|
||||
|
||||
Added 4600 to test version file operations.
|
||||
|
||||
@@ -4041,7 +4447,7 @@ The following are the changes from calc version 2.10.2t4 to 2.10.2t24:
|
||||
|
||||
Renumbered some of the early regress.cal test numbers to make room
|
||||
for more tests. Fixed all out of sequence test numbers. Fixed some
|
||||
malformatted regression reports.
|
||||
malformed regression reports.
|
||||
|
||||
Renamed STSIZE_BITS to OFF_T_BITS. Renamed SWAP_HALF_IN_STSIZE to
|
||||
SWAP_HALF_IN_OFF_T.
|
||||
@@ -4132,7 +4538,7 @@ The following are the changes from calc version 2.10.2t1 to 2.10.2t3:
|
||||
tries "w" and "r", and if none work, gives up. This avoids having
|
||||
"open" files with null fp.
|
||||
|
||||
The buildin rewind() calls the C rewind() function, but one may
|
||||
The builtin rewind() calls the C rewind() function, but one may
|
||||
now rewind several files at once by a call like rewind(f1, f2).
|
||||
With no argument, rewind() rewinds all open files with id >= 3.
|
||||
|
||||
@@ -4155,7 +4561,7 @@ The following are the changes from calc version 2.10.2t1 to 2.10.2t3:
|
||||
y = fgetstr(f); /* returns "Curt" */
|
||||
z = fgetstr(f); /* returns "Noll" */
|
||||
|
||||
The buildin fgetfield() returns the next field of non-whitepsace
|
||||
The builtin fgetfield() returns the next field of non-whitepsace
|
||||
characters.
|
||||
|
||||
The builtins scan(), fscan(), strscan() read tokens (fields of
|
||||
@@ -4179,10 +4585,10 @@ The following are the changes from calc version 2.10.2t1 to 2.10.2t3:
|
||||
or -1 if x is a file but not open. If s is a string, size(s) returns
|
||||
characters in s.
|
||||
|
||||
Added buildin access("foo", "w") returns the null value if a file
|
||||
"foo" exists and is writeable.
|
||||
Added builtin access("foo", "w") returns the null value if a file
|
||||
"foo" exists and is writable.
|
||||
|
||||
Some systems has a libc symbolc qadd() that conflicted with calc's
|
||||
Some systems has a libc symbolic qadd() that conflicted with calc's
|
||||
qadd function. To avoid this, qadd() has been renamed to qqadd().
|
||||
|
||||
The calc error codes are produced from the the calcerr.tbl file.
|
||||
@@ -4337,9 +4743,9 @@ The following are the changes from calc version 2.10.1t20 to 2.10.1t20:
|
||||
<ernie at turing dot une dot edu dot au>
|
||||
|
||||
A new "bignum" algorithm for evaluating pmod(x,k,m) when
|
||||
N >= config("pow2"). For the multiplications and squarings
|
||||
N >= config("pow2"). For the multiplications and squaring
|
||||
modulo m, or their equivalent, when N >= config("redc2"),
|
||||
calc has used evaluations correponding to rcout(x * y, m),
|
||||
calc has used evaluations corresponding to rcout(x * y, m),
|
||||
for which the runtime is essentially that of three multiplications.
|
||||
<ernie at turing dot une dot edu dot au>
|
||||
|
||||
@@ -4412,7 +4818,7 @@ The following are the changes from calc version 2.10.1t11 to 2.10.1t19:
|
||||
|
||||
cmp(a,b) = sgn(re(a) - re(b)) + sgn(im(a) - im(b)) * 1i
|
||||
|
||||
The cmp help file has been uptdated.
|
||||
The cmp help file has been updated.
|
||||
|
||||
Change HASH type to QCKHASH. The HASH type is a name better suited
|
||||
for the upcoming one-way hash interface.
|
||||
@@ -4472,7 +4878,7 @@ The following are the changes from calc version 2.10.1t11 to 2.10.1t19:
|
||||
prompt "; " (allows full line cut/paste)
|
||||
more ";; " (allows full line cut/paste)
|
||||
|
||||
The "newstd" is a (hopefully) more perferred configuration than the
|
||||
The "newstd" is a (hopefully) more preferred configuration than the
|
||||
historic default.
|
||||
|
||||
The fposval.h file defines DEV_BITS and INODE_BITS giving the
|
||||
@@ -4491,7 +4897,7 @@ The following are the changes from calc version 2.10.1t11 to 2.10.1t19:
|
||||
state or RANDOM state.
|
||||
|
||||
The lib/cryrand.cal library now no longer keeps the Blum prime
|
||||
factors used to formt he Blum modulus. The default modulus has
|
||||
factors used to form he Blum modulus. The default modulus has
|
||||
been expanded to 1062 bits product of two Blum primes.
|
||||
|
||||
The function hash_init() is called to initialize the hash function
|
||||
@@ -4522,7 +4928,7 @@ The following are the changes from calc version 2.10.1t11 to 2.10.1t19:
|
||||
help/poly file. Added poly.c. <ernie at turing dot une dot edu
|
||||
dot au>
|
||||
|
||||
Fixes and performance improvemtns to det(). <ernie at turing dot
|
||||
Fixes and performance improvements to det(). <ernie at turing dot
|
||||
une dot edu dot au>
|
||||
|
||||
Renamed atoq() and atoz() to str2q() and str2z() to avoid conflicts
|
||||
@@ -4596,7 +5002,7 @@ The following are the changes from calc version 2.10.0t13 to 2.10.1t10:
|
||||
signed and unsigned values.
|
||||
|
||||
The longbits.h will define HAVE_B64 with a 64 bit type (long or
|
||||
longlong) is available. If one is, then SB64 abd US64 typedefs
|
||||
longlong) is available. If one is, then SB64 and US64 typedefs
|
||||
are declared.
|
||||
|
||||
The U(x) and L(x) macros only used to define 33 to 64 bit signed
|
||||
@@ -4625,7 +5031,7 @@ The following are the changes from calc version 2.10.0t13 to 2.10.1t10:
|
||||
|
||||
The CALCBINDINGS file is searched for along the CALCPATH. The Makefile
|
||||
defines the default CALCBINDINGS is "bindings" (or "altbind") which
|
||||
is now usualy found in ./lib or ${LIBDIR}.
|
||||
is now usually found in ./lib or ${LIBDIR}.
|
||||
|
||||
Per Ernest Bowen <ernie at turing dot une dot edu dot au>, an optional
|
||||
third argument was added sqrt() so that in sqrt(x,y,z), y and z have
|
||||
@@ -4633,7 +5039,7 @@ The following are the changes from calc version 2.10.0t13 to 2.10.1t10:
|
||||
what is being approximated is the sqrt of x. Another difference is
|
||||
that two more bits of z are used in sqrt: bit 5 gives the option of
|
||||
exact results when they exist (the value of y is then ignored) and
|
||||
bit 6 returns the nonprincipal root rather than the principal value.
|
||||
bit 6 returns the non-principal root rather than the principal value.
|
||||
|
||||
If commands are given on the command line, leading tabs are not
|
||||
printed in output. Giving a command on the command line implies
|
||||
@@ -4673,7 +5079,7 @@ The following are the changes from calc version 2.10.0t13 to 2.10.1t10:
|
||||
6 do not execute any program
|
||||
7 allow everything (default mode)
|
||||
|
||||
Thus if one wished to run calc from a privledged user, one might
|
||||
Thus if one wished to run calc from a privileged user, one might
|
||||
want to use -m 0 in an effort to make calc more secure.
|
||||
|
||||
The -m flags for reading and writing apply on open.
|
||||
@@ -4689,7 +5095,7 @@ The following are the changes from calc version 2.10.0t13 to 2.10.1t10:
|
||||
The maximum command line size it MAXCMD (16384) bytes. Calc objects to
|
||||
command lines that are longer.
|
||||
|
||||
The -u flag cause calc to unbuffer stdin and stdout.
|
||||
The -u flag cause calc to un-buffer stdin and stdout.
|
||||
|
||||
Added more help files. Improved other help files.
|
||||
|
||||
@@ -4773,7 +5179,7 @@ The following are the changes from calc version 2.9.3t9.2+ to 2.9.3t10:
|
||||
Makefile symbol. Removed alloc.c.
|
||||
|
||||
Added getenv("name"), putenv("name=val") and putenv("name, "val")
|
||||
builts for environment variable support thanks to "Dr." "D.J." Picton
|
||||
builds for environment variable support thanks to "Dr." "D.J." Picton
|
||||
<dave at aps2 dot ph dot bham dot ac dot uk>.
|
||||
|
||||
Added system("shell command") builtin to execute shell commands,
|
||||
@@ -4818,7 +5224,7 @@ The following are the changes from calc version 2.9.3t9.2+ to 2.9.3t10:
|
||||
|
||||
Expanded the regress.cal regression test suite.
|
||||
|
||||
Fixed -- and ++ with respect to objects and asignment (see the 2300
|
||||
Fixed -- and ++ with respect to objects and assignment (see the 2300
|
||||
series in regress.cal).
|
||||
|
||||
Added isident(m) to determine if m is an identity matrix.
|
||||
@@ -4999,7 +5405,7 @@ The following are the changes from calc version 2.9.3t8 to 2.9.3t9.2:
|
||||
|
||||
The cryrand.cal library has been modified to use the builtin
|
||||
rand() number generator. The output of this generator is
|
||||
different from pervious versions of this generator because
|
||||
different from previous versions of this generator because
|
||||
the rand() builtin does not match the additive 55 / shuffle
|
||||
generators from the old cryrand.cal file.
|
||||
|
||||
@@ -5159,8 +5565,8 @@ The following are the changes from calc version 2.9.2 to 2.9.3t7:
|
||||
|
||||
1/4 < sup(abs(appr(x,e) - x))/e <= 1/2.
|
||||
|
||||
Here 'sup' denotes the supremum or least upper bound over values of x.
|
||||
Previousld calc did: 1/4 <= sup(abs(appr(x,e) - x))/e < 1.
|
||||
Here 'sup' denotes the least upper bound over values of x (supremum).
|
||||
Previously calc did: 1/4 <= sup(abs(appr(x,e) - x))/e < 1.
|
||||
|
||||
Certain 64 bit processors such as the Alpha are now supported.
|
||||
|
||||
@@ -5348,8 +5754,8 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
|
||||
easily extracted and used in other programs.
|
||||
|
||||
Two new library files have been added: chrem.cal and cryrand.cal.
|
||||
The first of these solves the chinese remainder problem for a set
|
||||
of modulos and remainders. The second of these implements several
|
||||
The first of these solves the Chinese remainder problem for a set
|
||||
of modulo's and remainders. The second of these implements several
|
||||
very good random number generators for large numbers.
|
||||
|
||||
A small bug which allowed division by zero was fixed.
|
||||
@@ -5379,8 +5785,8 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.45 $
|
||||
## @(#) $Id: CHANGES,v 29.45 2001/12/31 22:12:35 chongo Exp $
|
||||
## @(#) $Revision: 29.70 $
|
||||
## @(#) $Id: CHANGES,v 29.70 2004/10/23 01:16:23 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
|
||||
##
|
||||
## Under source code control: 1993/06/02 18:12:57
|
||||
|
5
COPYING
5
COPYING
@@ -12,8 +12,8 @@ This file is Copyrighted
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
# @(#) $Revision: 29.6 $
|
||||
# @(#) $Id: COPYING,v 29.6 2001/06/01 11:26:53 chongo Exp $
|
||||
# @(#) $Revision: 29.7 $
|
||||
# @(#) $Id: COPYING,v 29.7 2003/02/26 16:54:59 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/COPYING,v $
|
||||
|
||||
=-=
|
||||
@@ -164,6 +164,7 @@ Calc copyrights and exception files
|
||||
Copyright (C) year Landon Curt Noll
|
||||
Copyright (C) year Ernest Bowen and Landon Curt Noll
|
||||
Copyright (C) year Ernest Bowen
|
||||
Copyright (C) year Petteri Kettunen and Landon Curt Noll
|
||||
|
||||
These files are not covered under one of the Copyrights listed above:
|
||||
|
||||
|
154
HOWTO.INSTALL
154
HOWTO.INSTALL
@@ -1,41 +1,130 @@
|
||||
Installing calc in 4 easy steps:
|
||||
Installing calc from the gziped tarball in 4 easy steps:
|
||||
|
||||
1) Look at the makefile, and adjust it to suit your needs.
|
||||
0) If your platform supports i686 RPMs, you may want to go to:
|
||||
|
||||
Here are some Makefile hints:
|
||||
http://www.isthe.com/chongo/src/calc/
|
||||
|
||||
Select a compiler set by commenting in the appropriate set
|
||||
of cc options. As shipped the Makefile assumes a gcc-like
|
||||
environment such as Linux. If a more appropriate cc set if
|
||||
found below, comment out the Linux set and comment in that
|
||||
set or edit the gcc set or the common cc set as needed.
|
||||
and use these RPMs:
|
||||
|
||||
You may or may not need RANLIB when building libraries.
|
||||
As shipped the Makefile assumes RANLIB is needed.
|
||||
Comment the in/out the RANLIB value if ranlib does
|
||||
not work or does not exist.
|
||||
* calc*.i686.rpm
|
||||
- all that is needed if you just want to use calc
|
||||
|
||||
You may want to change the default pager used by calc.
|
||||
As shipped the Makefile assumes 'more'. On your system
|
||||
you may find 'less' to be a better pager.
|
||||
* calc-devel-*.i686.rpm
|
||||
- calc *.h header and *.a lib files for use in other programs
|
||||
|
||||
Set TOPDIR to be the place under which help files, calc,
|
||||
include files and calc libs are to be installed. As shipped
|
||||
the Makefile assumes a TOPDIR of /usr/local/lib.
|
||||
* calc.*.src.rpm
|
||||
- calc source in RPM package form
|
||||
|
||||
Set BINDIR to the place where calc is installed. As shipped
|
||||
the Makefile assumes a BINDIR /usr/local/bin.
|
||||
The following 4 steps apply to calc source tree that comes from either:
|
||||
|
||||
Some compilers (to put it mildly) have bugs. Sometimes the
|
||||
DEBUG Makefile variable causes the compiler / optimizer to
|
||||
produce bad code. Other compilers do just fine. If possible
|
||||
try to use DEBUG=-O3 -g3 (maximum optimization and debug symbols).
|
||||
If the calc test fails (see step 3), try lowering either the
|
||||
-O value and/or the -g3. Also try using -Osomething without -g.
|
||||
gunzip -c calc-*.tar.gz | tar -xvf -
|
||||
|
||||
or from:
|
||||
|
||||
rpm -ivh calc-*.src.rpm
|
||||
cd /var/tmp
|
||||
gunzip -c /usr/src/redhat/SOURCES/calc-*.tar.gz | tar -xvf -
|
||||
|
||||
1) Look at the makefile, and adjust it to suit your needs.
|
||||
|
||||
The Makefile, as shipped, is suitable for installation under
|
||||
Linux and Un*x-like environments. For the most part, the default
|
||||
values should work. If in doubt, follow the 'When in doubt'
|
||||
suggestion.
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
! If you are building under Windoz or a Windoz-like environment !
|
||||
! (such as Cygwin or DJGPP), read the README.WINDOWS file. !
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
You should determine if these Makefile variables are reasonable:
|
||||
|
||||
INCDIR Where the system include (.h) files are kept.
|
||||
BINDIR Where to install calc binary files.
|
||||
LIBDIR Where to install calc link library (*.a) files.
|
||||
CALC_SHAREDIR Where to install calc help, .cal, startup, and
|
||||
config files.
|
||||
|
||||
You may want to change the default installation locations for
|
||||
these values, which are based on the 4 values listed above:
|
||||
|
||||
HELPDIR where the help directory is installed
|
||||
CALC_INCDIR where the calc include files are installed
|
||||
CUSTOMCALDIR where custom *.cal files are installed
|
||||
CUSTOMHELPDIR where custom help files are installed
|
||||
CUSTOMINCPDIR where custom .h files are installed
|
||||
SCRIPTDIR where calc shell scripts are installed
|
||||
|
||||
If you want to install calc files under a top level directory,
|
||||
then set the T value:
|
||||
|
||||
The calc install is performed under $T, the calc build is
|
||||
performed under /. The purpose for $T is to allow someone
|
||||
to install calc somewhere other than into the system area.
|
||||
|
||||
For example, if:
|
||||
|
||||
BINDIR= /usr/bin
|
||||
LIBDIR= /usr/lib
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
and if:
|
||||
|
||||
T= /var/tmp/testing
|
||||
|
||||
Then the installation locations will be:
|
||||
|
||||
calc binary files: /var/tmp/testing/usr/bin
|
||||
calc link library: /var/tmp/testing/usr/lib
|
||||
calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
... etc ... /var/tmp/testing/...
|
||||
|
||||
If $T is empty, calc is installed under /, which is the same
|
||||
top of tree for which it was built. If $T is non-empty, then
|
||||
calc is installed under $T, as if one had to chroot under
|
||||
$T for calc to operate.
|
||||
|
||||
Look for the section that starts:
|
||||
|
||||
################
|
||||
# compiler set #
|
||||
################
|
||||
|
||||
Select a compiler set by commenting in the appropriate set
|
||||
of cc options. As shipped the Makefile assumes a gcc-like
|
||||
environment such as Linux. If a more appropriate cc set if
|
||||
found below, comment out the Linux set and comment in that
|
||||
set or edit the gcc set or the common cc set as needed.
|
||||
|
||||
You may want to change these Makrfile variables from their defaults:
|
||||
|
||||
RANLIB
|
||||
|
||||
You may or may not need RANLIB when building libraries.
|
||||
As shipped the Makefile assumes RANLIB is needed.
|
||||
Comment the in/out the RANLIB value if ranlib does
|
||||
not work or does not exist.
|
||||
|
||||
CALCPAGER
|
||||
|
||||
You may want to change the default pager used by calc.
|
||||
As shipped the Makefile assumes 'more'. On your system
|
||||
you may find 'less' to be a better pager.
|
||||
|
||||
DEBUG
|
||||
|
||||
Some compilers (to put it mildly) have bugs. Sometimes the
|
||||
DEBUG Makefile variable causes the compiler / optimizer to
|
||||
produce bad code. Other compilers do just fine.
|
||||
|
||||
If possible try to use DEBUG=-O3 -g3 (maximum optimization
|
||||
and debug symbols). If the calc test fails (see step 3),
|
||||
try lowering either the -O value and/or the -g3. Also try
|
||||
using -Osomething without -g.
|
||||
|
||||
Adjust other Makefile variables as needed.
|
||||
|
||||
2) build calc:
|
||||
2) build calc:
|
||||
|
||||
make all
|
||||
|
||||
@@ -43,13 +132,14 @@ Installing calc in 4 easy steps:
|
||||
you may find. See the BUGS file if you find any compiler
|
||||
warning or errors.
|
||||
|
||||
3) test calc:
|
||||
3) test calc:
|
||||
|
||||
make check
|
||||
|
||||
==> If you run into problems, follow the BUGS file instructions.
|
||||
==> If you run into problems, read the BUGS file and follow
|
||||
the instructions found in there.
|
||||
|
||||
4) install calc:
|
||||
4) install calc:
|
||||
|
||||
make install
|
||||
|
||||
@@ -72,8 +162,8 @@ the calc help subsystem. See the README file for details.
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: HOWTO.INSTALL,v 29.3 2001/12/11 02:51:00 chongo Exp $
|
||||
## @(#) $Revision: 29.7 $
|
||||
## @(#) $Id: HOWTO.INSTALL,v 29.7 2003/04/15 03:38:34 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/HOWTO.INSTALL,v $
|
||||
##
|
||||
## Under source code control: 1999/09/27 20:48:44
|
||||
|
109
README.WINDOWS
109
README.WINDOWS
@@ -3,15 +3,6 @@ Dear calc user on a Windoz based system,
|
||||
See the HOWTO.INSTALL file for information on how to build and install calc.
|
||||
See also the README file.
|
||||
|
||||
NOTE: The Windoz port is extremely experimental, untested and perhaps
|
||||
incomplete. We are in the process of making it easier. The
|
||||
following should help anyone who is trying to make a go of this
|
||||
under the current code conditions.
|
||||
|
||||
NOTE: We are currently ONLY making an effort to support building under
|
||||
Windoz using the Cygwin project (http://sources.redhat.com/cygwin/)
|
||||
with the GCC compiler and Un*x tools for Windows.
|
||||
|
||||
NOTE: The main developers do not have access to a Windoz based platform.
|
||||
While we will make an effort to not break calc Windoz based system,
|
||||
our lack of a Windoz test environment will mean we will make mistakes
|
||||
@@ -19,7 +10,67 @@ NOTE: The main developers do not have access to a Windoz based platform.
|
||||
Of course you are welcome to send us any patches that fix your
|
||||
Windoz build environment.
|
||||
|
||||
=-=
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
=-= compiling under DJGPP =-=
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
You might want to try using the DJGPP system to compile calc. See:
|
||||
|
||||
http://www.delorie.com/djgpp/
|
||||
|
||||
for DJGPP details and availability.
|
||||
|
||||
To compile with DJGPP, one needs to select a number of Makefile
|
||||
variable changes. Eli Zaretskii <eliz at is dot elta dot co dot il>
|
||||
recommends the following settings:
|
||||
|
||||
TERMCONTROL= -DUSE_TERMIOS
|
||||
BYTE_ORDER= -DLITTLE_ENDIAN
|
||||
LONG_BITS= 32
|
||||
HAVE_FPOS_POS= -DHAVE_NO_FPOS_POS
|
||||
FPOS_BITS= 32
|
||||
OFF_T_BITS= 32
|
||||
DEV_BITS= 32
|
||||
INODE_BITS= 32
|
||||
HAVE_USTAT= -DHAVE_NO_USTAT
|
||||
HAVE_GETSID= -DHAVE_NO_GETSID
|
||||
HAVE_GETPGID= -DHAVE_NO_GETPGID
|
||||
HAVE_GETTIME= -DHAVE_NO_GETTIME
|
||||
HAVE_GETPRID= -DHAVE_NO_GETPRID
|
||||
HAVE_URANDOM_H= NO
|
||||
ALIGN32= -UMUST_ALIGN32
|
||||
HAVE_MALLOC_H= YES
|
||||
HAVE_STDLIB_H= YES
|
||||
HAVE_STRING_H= YES
|
||||
HAVE_TIMES_H= NO
|
||||
HAVE_SYS_TIMES_H= YES
|
||||
HAVE_TIME_H= YES
|
||||
HAVE_SYS_TIME_H= YES
|
||||
HAVE_UNISTD_H= YES
|
||||
BINDIR= /dev/env/DJDIR/bin
|
||||
INCDIR= /dev/env/DJDIR/include
|
||||
LIBDIR= /dev/env/DJDIR/lib
|
||||
MANDIR= /dev/env/DJDIR/man/man1
|
||||
CATDIR= /dev/env/DJDIR/man/cat1
|
||||
NROFF= groff
|
||||
CALCPATH= .;./cal;~/.cal;${CALC_SHAREDIR};${CUSTOMCALDIR}
|
||||
CALCRC= ${CALC_SHAREDIR}/startup;~/.calcrc;./.calcinit
|
||||
CALCPAGER= less.exe -ci
|
||||
DEBUG= -O2 -gstabs+
|
||||
|
||||
The 'Linux set' or 'gcc set' (see the Select your compiler type section)
|
||||
should work for DJGPP systems if you set the above Makefile variables.
|
||||
|
||||
Look for Makefile comments of the form:
|
||||
|
||||
# Select ...something... for DJGPP.
|
||||
|
||||
Follow those recommendations. In cases where they conflict with
|
||||
the above Makefile list, follow the recommendation in the Makefile.
|
||||
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
=-= compiling with Cygwin =-=
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
An effort is being made to allow windows users to compile calc using the
|
||||
Cygwin project (http://sources.redhat.com/cygwin/) with the GCC compiler
|
||||
@@ -41,27 +92,29 @@ The major porting work was performed by Thomas Jones-Low
|
||||
tools. The make file provided with Calc is not compatible with
|
||||
NMAKE, so I used the Visual Studio tools to generate another one
|
||||
(not included). Calc is built in two parts, calc.dll, which is the
|
||||
library, and calcexe.exe which is the command line interface.
|
||||
library, and calc.exe which is the command line interface.
|
||||
|
||||
He recommends that you generate by hand all of the header files generated
|
||||
by the make file:
|
||||
He recommended that you generate by hand all of the header files that
|
||||
by the Makefile. This has been done for you via the makefile rule:
|
||||
|
||||
align32.h args.h calcerr.h conf.h endian_calc.h
|
||||
fposval.h have_const.h have_fpos.h have_fpos_pos.h have_malloc.h
|
||||
have_memmv.h have_newstr.h have_offscl.h have_posscl.h
|
||||
have_stdlib.h have_string.h have_times.h have_uid_t.h
|
||||
have_unistd.h longbits.h longlong.h terminal.h
|
||||
have_ustat.h have_getsid.h have_getpgid.h
|
||||
have_gettime.h have_getprid.h have_urandom.h have_rusage.h
|
||||
have_strdup.h
|
||||
make win32_hsrc
|
||||
|
||||
which uses the Makefile variables in win32.mkdef to form these header
|
||||
files under win32 directory.
|
||||
|
||||
You will find generated versions of these files located in the win32
|
||||
sub-directory. These files may be appropriate for your Cygwin building
|
||||
needs. Just copy the win32/*.[ch] files up into the top level calc
|
||||
source directory, edited (if needed) and build using the Cygwin GCC
|
||||
compiler.
|
||||
needs.
|
||||
|
||||
=-=
|
||||
In particular:
|
||||
|
||||
Just copy the win32/*.[ch] files up into the top level calc
|
||||
source directory, edit them (if needed) and build using the
|
||||
Cygwin GCC compiler and Cygwin build environment.
|
||||
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
=-=-= calc maintenance folk =-=-=
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
People who maintain calc need to keep in mind the following:
|
||||
|
||||
@@ -89,7 +142,7 @@ was changed to:
|
||||
DLL extern int configtype(char*);
|
||||
|
||||
|
||||
## Copyright (C) 2001 Landon Curt Noll and Thomas Jones-Low
|
||||
## Copyright (C) 2002 Landon Curt Noll and Thomas Jones-Low
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -105,8 +158,8 @@ was changed to:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.6 $
|
||||
## @(#) $Id: README.WINDOWS,v 29.6 2001/04/08 22:13:38 chongo Exp $
|
||||
## @(#) $Revision: 29.12 $
|
||||
## @(#) $Id: README.WINDOWS,v 29.12 2004/07/28 12:52:01 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/README.WINDOWS,v $
|
||||
##
|
||||
## Under source code control: 2001/02/25 14:00:05
|
||||
|
14
addop.c
14
addop.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* addop - add opcodes to a function being compiled
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2004 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: addop.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: addop.c,v 29.5 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/addop.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:10
|
||||
@@ -44,7 +44,7 @@
|
||||
#define OPCODEALLOCSIZE 100 /* reallocate size for opcodes in functions */
|
||||
|
||||
|
||||
static long maxopcodes; /* number of opcodes available */
|
||||
static unsigned long maxopcodes;/* number of opcodes available */
|
||||
static long newindex; /* index of new function */
|
||||
static char *newname; /* name of new function */
|
||||
static long oldop; /* previous opcode */
|
||||
@@ -185,7 +185,7 @@ endfunc(void)
|
||||
{
|
||||
register FUNC *fp; /* function just finished */
|
||||
unsigned long size; /* size of just created function */
|
||||
long index;
|
||||
unsigned long index;
|
||||
|
||||
if (oldop != OP_RETURN) {
|
||||
addop(OP_UNDEF);
|
||||
@@ -302,7 +302,7 @@ void
|
||||
freefunc(FUNC *fp)
|
||||
{
|
||||
long index;
|
||||
long i;
|
||||
unsigned long i;
|
||||
|
||||
if (fp == NULL)
|
||||
return;
|
||||
@@ -383,7 +383,7 @@ clearopt(void)
|
||||
FUNC *
|
||||
findfunc(long index)
|
||||
{
|
||||
if ((unsigned long) index >= funccount) {
|
||||
if (index >= funccount) {
|
||||
math_error("Undefined function");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
46
blkcpy.c
46
blkcpy.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* blkcpy - general values and related routines used by the calculator
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll and Ernest Bowen
|
||||
* Copyright (C) 1999-2004 Landon Curt Noll and Ernest Bowen
|
||||
*
|
||||
* Primary author: Landon Curt Noll
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: blkcpy.c,v 29.3 2001/04/10 22:06:46 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: blkcpy.c,v 29.5 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.c,v $
|
||||
*
|
||||
* Under source code control: 1997/04/18 20:41:26
|
||||
@@ -287,13 +287,13 @@ copymat2mat(MATRIX *smat, long ssi, long num, MATRIX *dmat, long dsi)
|
||||
|
||||
if (num < 0)
|
||||
num = smat->m_size - ssi;
|
||||
if ((USB32) ssi + num > smat->m_size)
|
||||
if (ssi + num > smat->m_size)
|
||||
return E_COPY5;
|
||||
if (num == 0)
|
||||
return 0;
|
||||
if (dsi < 0)
|
||||
dsi = 0;
|
||||
if ((USB32) dsi + num > dmat->m_size)
|
||||
if (dsi + num > dmat->m_size)
|
||||
return E_COPY7;
|
||||
vtemp = (VALUE *) malloc(num * sizeof(VALUE));
|
||||
if (vtemp == NULL) {
|
||||
@@ -335,13 +335,13 @@ copyblk2mat(BLOCK *blk, long ssi, long num, MATRIX *dmat, long dsi)
|
||||
return E_COPY2;
|
||||
if (num < 0)
|
||||
num = blk->datalen - ssi;
|
||||
if ((USB32) ssi + num > blk->datalen)
|
||||
if (ssi + num > blk->datalen)
|
||||
return E_COPY5;
|
||||
if (num == 0)
|
||||
return 0;
|
||||
if (dsi < 0)
|
||||
dsi = 0;
|
||||
if ((USB32) dsi + num > dmat->m_size)
|
||||
if (dsi + num > dmat->m_size)
|
||||
return E_COPY7;
|
||||
op = blk->data + ssi;
|
||||
vtemp = (VALUE *) malloc(num * sizeof(VALUE));
|
||||
@@ -389,7 +389,7 @@ copymat2blk(MATRIX *smat, long ssi, long num, BLOCK *dblk, long dsi, BOOL norelo
|
||||
num = smat->m_size - ssi;
|
||||
if (num == 0)
|
||||
return 0;
|
||||
if ((USB32) ssi + num > smat->m_size)
|
||||
if (ssi + num > smat->m_size)
|
||||
return E_COPY5;
|
||||
if (dsi < 0)
|
||||
dsi = dblk->datalen;
|
||||
@@ -436,11 +436,11 @@ copymat2list(MATRIX *smat, long ssi, long num, LIST *lp, long dsi)
|
||||
num = smat->m_size - ssi;
|
||||
if (num == 0)
|
||||
return 0;
|
||||
if ((USB32) ssi + num > smat->m_size)
|
||||
if (ssi + num > smat->m_size)
|
||||
return E_COPY5;
|
||||
if (dsi < 0)
|
||||
dsi = 0;
|
||||
if ((USB32) dsi + num > lp->l_count)
|
||||
if (dsi + num > lp->l_count)
|
||||
return E_COPY7;
|
||||
vtemp = (VALUE *) malloc(num * sizeof(VALUE));
|
||||
if (vtemp == NULL) {
|
||||
@@ -484,11 +484,11 @@ copylist2mat(LIST *lp, long ssi, long num, MATRIX *dmat, long dsi)
|
||||
num = lp->l_count - ssi;
|
||||
if (num == 0)
|
||||
return 0;
|
||||
if ((USB32) ssi + num > lp->l_count)
|
||||
if (ssi + num > lp->l_count)
|
||||
return E_COPY5;
|
||||
if (dsi < 0)
|
||||
dsi = 0;
|
||||
if ((USB32) dsi + num > dmat->m_size)
|
||||
if (dsi + num > dmat->m_size)
|
||||
return E_COPY7;
|
||||
vtemp = (VALUE *) malloc(num * sizeof(VALUE));
|
||||
if (vtemp == NULL) {
|
||||
@@ -533,11 +533,11 @@ copylist2list(LIST *slp, long ssi, long num, LIST *dlp, long dsi)
|
||||
num = slp->l_count - ssi;
|
||||
if (num == 0)
|
||||
return 0;
|
||||
if ((USB32) ssi + num > slp->l_count)
|
||||
if (ssi + num > slp->l_count)
|
||||
return E_COPY5;
|
||||
if (dsi < 0)
|
||||
dsi = 0;
|
||||
if ((USB32) dsi + num > dlp->l_count)
|
||||
if (dsi + num > dlp->l_count)
|
||||
return E_COPY7;
|
||||
vtemp = (VALUE *) malloc(num * sizeof(VALUE));
|
||||
if (vtemp == NULL) {
|
||||
@@ -572,7 +572,7 @@ copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi)
|
||||
{
|
||||
FILEIO *fiop;
|
||||
FILE *fp;
|
||||
unsigned int numw;
|
||||
long numw;
|
||||
|
||||
if (ssi > sblk->datalen)
|
||||
return E_COPY2;
|
||||
@@ -609,7 +609,7 @@ copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, BOOL noreloc)
|
||||
{
|
||||
FILEIO *fiop;
|
||||
FILE *fp;
|
||||
unsigned int numw;
|
||||
long numw;
|
||||
ZVALUE fsize;
|
||||
long filelen;
|
||||
long newlen;
|
||||
@@ -639,7 +639,7 @@ copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, BOOL noreloc)
|
||||
num = filelen - ssi;
|
||||
if (num == 0)
|
||||
return 0;
|
||||
if ((USB32) ssi + num > filelen)
|
||||
if (ssi + num > filelen)
|
||||
return E_COPY5;
|
||||
if (fseek(fp, ssi, 0)) /* using system fseek XXX */
|
||||
return E_COPYF2;
|
||||
@@ -677,7 +677,7 @@ copystr2file(STRING *str, long ssi, long num, FILEID id, long dsi)
|
||||
{
|
||||
long len;
|
||||
FILEIO *fiop;
|
||||
unsigned int numw;
|
||||
long numw;
|
||||
FILE *fp;
|
||||
|
||||
len = str->s_len;
|
||||
@@ -688,7 +688,7 @@ copystr2file(STRING *str, long ssi, long num, FILEID id, long dsi)
|
||||
num = len - ssi;
|
||||
if (num <= 0) /* Nothing to be copied */
|
||||
return 0;
|
||||
if ((USB32) ssi + num > len)
|
||||
if (ssi + num > len)
|
||||
return E_COPY5; /* Insufficient memory in str */
|
||||
fiop = findid(id, TRUE);
|
||||
if (fiop == NULL)
|
||||
@@ -726,7 +726,7 @@ copyblk2blk(BLOCK *sblk, long ssi, long num, BLOCK *dblk, long dsi, BOOL noreloc
|
||||
num = sblk->datalen - ssi;
|
||||
if (num == 0) /* Nothing to be copied */
|
||||
return 0;
|
||||
if ((unsigned int) ssi + num > sblk->datalen)
|
||||
if (ssi + num > sblk->datalen)
|
||||
return E_COPY5;
|
||||
if (dsi < 0)
|
||||
dsi = dblk->datalen;
|
||||
@@ -888,7 +888,7 @@ copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,BOOL noreloc)
|
||||
|
||||
if (ssi > len)
|
||||
return E_COPY2;
|
||||
if (num < 0 || (unsigned long) ssi + num > len)
|
||||
if (num < 0 || ssi + num > len)
|
||||
num = len - ssi;
|
||||
if (num <= 0) /* Nothing to be copied */
|
||||
return 0;
|
||||
@@ -991,7 +991,7 @@ copynum2blk(NUMBER *snum, long ssi, long num, BLOCK *dblk, long dsi, BOOL norelo
|
||||
num = snum->num.len - ssi;
|
||||
if (num == 0) /* Nothing to be copied */
|
||||
return 0;
|
||||
if ((unsigned long) ssi + num > snum->num.len)
|
||||
if (ssi + num > snum->num.len)
|
||||
return E_COPY5;
|
||||
if (dsi < 0)
|
||||
dsi = dblk->datalen;
|
||||
@@ -1044,7 +1044,7 @@ copyblk2num(BLOCK *sblk, long ssi, long num, NUMBER *dnum, long dsi, NUMBER **re
|
||||
num = sblk->datalen - ssi;
|
||||
if (num == 0) /* Nothing to be copied */
|
||||
return 0;
|
||||
if ((unsigned long) ssi + num > sblk->datalen)
|
||||
if (ssi + num > sblk->datalen)
|
||||
return E_COPY5;
|
||||
if (dsi < 0)
|
||||
dsi = dnum->num.len;
|
||||
|
169
cal/Makefile
169
cal/Makefile
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.12 $
|
||||
# @(#) $Id: Makefile,v 29.12 2001/06/08 22:38:53 chongo Exp $
|
||||
# @(#) $Revision: 29.15 $
|
||||
# @(#) $Id: Makefile,v 29.15 2003/01/05 08:10:56 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1991/07/21 05:00:54
|
||||
@@ -36,23 +36,111 @@
|
||||
SHELL = /bin/sh
|
||||
MAKE_FILE = Makefile
|
||||
|
||||
####
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
#
|
||||
# where to install things
|
||||
#SHAREDIR= /usr/local/lib
|
||||
#SHAREDIR= /usr/lib
|
||||
SHAREDIR= /usr/share
|
||||
#SHAREDIR= /usr/libdata
|
||||
####
|
||||
|
||||
CSHAREDIR= ${SHAREDIR}/calc
|
||||
# Where the system include (.h) files are kept
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
# INCDIR= /dev/env/DJDIR/include
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# INCDIR= /usr/include
|
||||
#
|
||||
|
||||
#INCDIR= /usr/local/include
|
||||
#INCDIR= /dev/env/DJDIR/include
|
||||
INCDIR= /usr/include
|
||||
|
||||
# where to install calc realted things
|
||||
#
|
||||
# ${BINDIR} where to install calc binary files
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
# BINDIR= /dev/env/DJDIR/bin
|
||||
# LIBDIR= /dev/env/DJDIR/lib
|
||||
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# BINDIR= /usr/bin
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
#BINDIR= /usr/local/bin
|
||||
#BINDIR= /dev/env/DJDIR/bin
|
||||
BINDIR= /usr/bin
|
||||
|
||||
#LIBDIR= /usr/local/lib
|
||||
#LIBDIR= /dev/env/DJDIR/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
|
||||
# ---------------------------------------------------------------
|
||||
# ${HELPDIR} where the help directory is installed
|
||||
# ${CALC_INCDIR} where the calc include files are installed
|
||||
# ${CUSTOMCALDIR} where custom *.cal files are installed
|
||||
# ${CUSTOMHELPDIR} where custom help files are installed
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed
|
||||
# ${SCRIPTDIR} where calc shell scripts are installed
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# HELPDIR= ${CALC_SHAREDIR}/help
|
||||
# CALC_INCDIR= ${INCDIR}/calc
|
||||
# CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
||||
# CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
||||
# CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
||||
# SCRIPTDIR= ${BINDIR}/cscript
|
||||
#
|
||||
HELPDIR= ${CALC_SHAREDIR}/help
|
||||
CALC_INCDIR= ${INCDIR}/calc
|
||||
CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
||||
CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
||||
CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
||||
SCRIPTDIR= ${BINDIR}/cscript
|
||||
|
||||
# T - top level directory under which calc will be installed
|
||||
#
|
||||
# The calc install is performed under $T, the calc build is
|
||||
# performed under /. The purpose for $T is to allow someone to
|
||||
# install calc somewhere other than into the system area. For example
|
||||
# when forming the calc rpm, the Makefile is called with T=$RPM_BUILD_ROOT.
|
||||
# performed under /. The purpose for $T is to allow someone
|
||||
# to install calc somewhere other than into the system area.
|
||||
#
|
||||
# For example, if:
|
||||
#
|
||||
# BINDIR= /usr/bin
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
# and if:
|
||||
#
|
||||
# T= /var/tmp/testing
|
||||
#
|
||||
# Then the installation locations will be:
|
||||
#
|
||||
# calc binary files: /var/tmp/testing/usr/bin
|
||||
# calc link library: /var/tmp/testing/usr/lib
|
||||
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
# ... etc ... /var/tmp/testing/...
|
||||
#
|
||||
# If $T is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If $T is non-empty, then
|
||||
@@ -87,8 +175,8 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
|
||||
test2700.cal test3100.cal test3300.cal test3400.cal prompt.cal \
|
||||
test3500.cal seedrandom.cal test4000.cal test4100.cal test4600.cal \
|
||||
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
|
||||
randomrun.cal xx_print.cal natnumset.cal qtime.cal test8400.cal \
|
||||
test8500.cal test8600.cal chi.cal intfile.cal
|
||||
randomrun.cal repeat.cal xx_print.cal natnumset.cal qtime.cal \
|
||||
test8400.cal test8500.cal test8600.cal chi.cal intfile.cal
|
||||
|
||||
# These files are found (but not built) in the distribution
|
||||
#
|
||||
@@ -120,8 +208,10 @@ all: ${CALC_FILES} ${MAKE_FILE} .all
|
||||
##
|
||||
|
||||
distlist: ${DISTLIST}
|
||||
${Q}for i in ${DISTLIST}; do \
|
||||
${Q}for i in ${DISTLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo cal/$$i; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
distdir:
|
||||
@@ -141,8 +231,10 @@ calcliblist:
|
||||
##
|
||||
|
||||
echo_inst_files:
|
||||
${Q}for i in ${CALC_FILES}; do \
|
||||
echo __file__ ${CSHAREDIR}/$$i; \
|
||||
${Q}for i in ${CALC_FILES} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${CALC_SHAREDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
##
|
||||
@@ -157,38 +249,29 @@ clobber:
|
||||
rm -f .all
|
||||
|
||||
install: all
|
||||
-${Q}if [ ! -d $T${SHAREDIR} ]; then \
|
||||
echo mkdir $T${SHAREDIR}; \
|
||||
mkdir $T${SHAREDIR}; \
|
||||
if [ ! -d "$T${SHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${SHAREDIR}"; \
|
||||
mkdir -p "$T${SHAREDIR}"; \
|
||||
-${Q}if [ ! -d $T${CALC_SHAREDIR} ]; then \
|
||||
echo mkdir $T${CALC_SHAREDIR}; \
|
||||
mkdir $T${CALC_SHAREDIR}; \
|
||||
if [ ! -d "$T${CALC_SHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${SHAREDIR}; \
|
||||
${CHMOD} 0755 $T${SHAREDIR}; \
|
||||
echo ${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${CSHAREDIR} ]; then \
|
||||
echo mkdir $T${CSHAREDIR}; \
|
||||
mkdir $T${CSHAREDIR}; \
|
||||
if [ ! -d "$T${CSHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${CSHAREDIR}"; \
|
||||
mkdir -p "$T${CSHAREDIR}"; \
|
||||
${Q}for i in ${CALC_FILES} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CSHAREDIR}; \
|
||||
${CHMOD} 0755 $T${CSHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
${Q}for i in ${CALC_FILES}; do \
|
||||
if ${CMP} -s $$i $T${CSHAREDIR}/$$i; then \
|
||||
if ${CMP} -s $$i $T${CALC_SHAREDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f $T${CSHAREDIR}/$$i.new; \
|
||||
cp -f $$i $T${CSHAREDIR}/$$i.new; \
|
||||
${CHMOD} 0444 $T${CSHAREDIR}/$$i.new; \
|
||||
mv -f $T${CSHAREDIR}/$$i.new $T${CSHAREDIR}/$$i; \
|
||||
echo "installed $T${CSHAREDIR}/$$i"; \
|
||||
rm -f $T${CALC_SHAREDIR}/$$i.new; \
|
||||
cp -f $$i $T${CALC_SHAREDIR}/$$i.new; \
|
||||
${CHMOD} 0444 $T${CALC_SHAREDIR}/$$i.new; \
|
||||
mv -f $T${CALC_SHAREDIR}/$$i.new $T${CALC_SHAREDIR}/$$i; \
|
||||
echo "installed $T${CALC_SHAREDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
|
14
cal/README
14
cal/README
@@ -480,6 +480,16 @@ randrun.cal
|
||||
|
||||
This tests the a55 generator.
|
||||
|
||||
repeat.cal
|
||||
|
||||
repeat(digit_set, repeat_count)
|
||||
|
||||
Return the value of the digit_set repeated repeat_count times.
|
||||
Both digit_set and repeat_count must be integers > 0.
|
||||
|
||||
For example repeat(423,5) returns the value 423423423423423,
|
||||
which is the digit_set 423 repeated 5 times.
|
||||
|
||||
|
||||
regress.cal
|
||||
|
||||
@@ -815,8 +825,8 @@ xx_print.cal
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.8 $
|
||||
## @(#) $Id: README,v 29.8 2001/03/31 16:26:23 chongo Exp $
|
||||
## @(#) $Revision: 29.9 $
|
||||
## @(#) $Id: README,v 29.9 2003/01/05 08:10:56 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
|
||||
##
|
||||
## Under source code control: 1990/02/15 01:50:32
|
||||
|
16
cal/deg.cal
16
cal/deg.cal
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: deg.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: deg.cal,v 29.4 2003/01/26 19:32:41 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/deg.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:33
|
||||
@@ -42,7 +42,7 @@ define dms(deg, min, sec)
|
||||
ans.deg = deg;
|
||||
ans.min = min;
|
||||
ans.sec = sec;
|
||||
fixdms(&ans);
|
||||
fixdms(ans);
|
||||
return ans;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ define dms_add(a, b)
|
||||
ans.sec += b.sec;
|
||||
} else
|
||||
ans.deg += b;
|
||||
fixdms(&ans);
|
||||
fixdms(ans);
|
||||
return ans;
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@ define dms_neg(a)
|
||||
{
|
||||
local obj dms ans;
|
||||
|
||||
ans.deg = -ans.deg;
|
||||
ans.min = -ans.min;
|
||||
ans.sec = -ans.sec;
|
||||
ans.deg = -a.deg;
|
||||
ans.min = -a.min;
|
||||
ans.sec = -a.sec;
|
||||
return ans;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ define dms_mul(a, b)
|
||||
ans.min = b.min * a;
|
||||
ans.sec = b.sec * a;
|
||||
}
|
||||
fixdms(&ans);
|
||||
fixdms(ans);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: lucas.cal,v 29.5 2001/06/08 20:07:29 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: lucas.cal,v 29.6 2002/07/10 09:43:46 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/05/03 16:49:51
|
||||
@@ -90,7 +90,7 @@
|
||||
*
|
||||
* test numbers of the form h*2^n-1
|
||||
* fix a value of n and vary the value h
|
||||
* n mod 128 == 0
|
||||
* n mod 2^x == 0 for some value of x, say > 7 or more
|
||||
* h*2^n-1 is not divisible by any small prime < 2^40
|
||||
* 0 < h < 2^39
|
||||
* h*2^n+1 is not divisible by any small prime < 2^40
|
||||
|
10
cal/pi.cal
10
cal/pi.cal
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* pi - various routines to calculate pi
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2004 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
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: pi.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: pi.cal,v 29.5 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pi.cal,v $
|
||||
*
|
||||
* Under source code control: 1991/05/22 21:56:37
|
||||
@@ -61,7 +61,7 @@ define qpi(epsilon)
|
||||
yn = sqrt2 - 1;
|
||||
an = 6 - 4 * sqrt2;
|
||||
tn = 2;
|
||||
for (count = 0; count < niter; count++) {
|
||||
for (count = 0; count < niter; ++count) {
|
||||
ym = yn;
|
||||
am = an;
|
||||
tn *= 4;
|
||||
@@ -104,7 +104,7 @@ define piforever()
|
||||
* Next approximation
|
||||
*/
|
||||
p = k * k;
|
||||
q = k + k++;
|
||||
q = k + ++k;
|
||||
|
||||
a2 = a;
|
||||
b2 = b;
|
||||
|
223
cal/regress.cal
223
cal/regress.cal
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* regress - calc regression and correctness test suite
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2004 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.10 $
|
||||
* @(#) $Id: regress.cal,v 29.10 2001/04/14 22:53:57 chongo Exp $
|
||||
* @(#) $Revision: 29.20 $
|
||||
* @(#) $Id: regress.cal,v 29.20 2004/10/22 23:51:26 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:36
|
||||
@@ -52,7 +52,8 @@ errmax(-1),; /* prevent errcount from abouting */
|
||||
global ecnt; /* expected value of errcount() */
|
||||
ecnt = 0; /* clear expected errcount() value */
|
||||
|
||||
initcfg = config("all", "oldstd"); /* set config to startup default */
|
||||
initcfg = config("all", "newstd"); /* set config to startup default */
|
||||
defcfg = config("all"); /* capture the default config */
|
||||
config("resource_debug", 0),; /* disable resource startup messages */
|
||||
config("calc_debug", 0),; /* disable internal debugging */
|
||||
config("verbose_quit", 0),; /* disable quit messages */
|
||||
@@ -380,19 +381,19 @@ define test_config()
|
||||
/* check the set and return of all config */
|
||||
callcfg = config("all");
|
||||
print '501: callcfg = config("all")';
|
||||
vrfy(callcfg == startcfg, '502: callcfg == startcfg');
|
||||
|
||||
callcfg = config("all", "oldstd");
|
||||
print '502: callcfg = config("all","oldstd")';
|
||||
oldcfg = config("all", "newstd");
|
||||
print '503: oldcfg = config("all","newstd")';
|
||||
print '503: callcfg = config("all","oldstd")';
|
||||
vrfy(callcfg == startcfg, '504: callcfg == startcfg');
|
||||
newcfg = config("all");
|
||||
print '505: newcfg = config("all")';
|
||||
vrfy(config("all") == newcfg, '506: config("all") == newcfg');
|
||||
vrfy(config("all", oldcfg) == newcfg,
|
||||
'507: config("all", oldcfg) == newcfg');
|
||||
oldcfg = config("all");
|
||||
print '505: oldcfg = config("all");';
|
||||
vrfy(config("all") == oldcfg, '506: config("all") == oldcfg');
|
||||
vrfy(oldcfg==config("all","newstd"),
|
||||
'507: oldcfg==config("all","newstd")');
|
||||
vrfy(defcfg == config("all"), '508: defcfg == config("all")');
|
||||
|
||||
/* vrfy the state of the default config */
|
||||
vrfy(config("all") == oldcfg, '508: config("all") == oldcfg');
|
||||
vrfy(config("mode") == "real",
|
||||
'509: config("mode") == "real"');
|
||||
vrfy(config("display") == 20,
|
||||
@@ -429,58 +430,59 @@ define test_config()
|
||||
'525: config("cfappr") == 0');
|
||||
vrfy(config("cfsim") == 8,
|
||||
'526: config("cfsim") == 8');
|
||||
vrfy(config("outround") == 2,
|
||||
'527: config("outround") == 2');
|
||||
vrfy(config("outround") == 24,
|
||||
'527: config("outround") == 24');
|
||||
vrfy(config("round") == 24,
|
||||
'528: config("round") == 24');
|
||||
vrfy(config("leadzero") == 0,
|
||||
'529: config("leadzero") == 0');
|
||||
vrfy(config("leadzero") == 1,
|
||||
'529: config("leadzero") == 1');
|
||||
vrfy(config("fullzero") == 0,
|
||||
'530: config("fullzero") == 0');
|
||||
vrfy(config("maxscan") == 20,
|
||||
'531: config("maxscan") == 20');
|
||||
vrfy(config("prompt") == "> ",
|
||||
'532: config("prompt") == "> "');
|
||||
vrfy(config("more") == ">> ",
|
||||
'533: config("more") == ">> "');
|
||||
vrfy(config("prompt") == "; ",
|
||||
'532: config("prompt") == "; "');
|
||||
vrfy(config("more") == ";; ",
|
||||
'533: config("more") == ";; "');
|
||||
|
||||
/* convert to "newstd" config by individual changes */
|
||||
vrfy(config("display", 10) == 20,
|
||||
'534: config("display") == 20');
|
||||
vrfy(config("epsilon",1e-10)==1e-20,
|
||||
'535: config("epsilon",1e-10)==1e-20');
|
||||
vrfy(config("quo", 0) == 2, '536: config("quo", 0) == 2');
|
||||
vrfy(config("outround", 24) == 2,
|
||||
'537: config("outround", 24) == 2');
|
||||
vrfy(config("leadzero","y") == 0,
|
||||
'538: config("leadzero","y") == 0');
|
||||
vrfy(config("fullzero", 1) == 0,
|
||||
'539: config("fullzero", 1) == 0');
|
||||
vrfy(config("prompt", "; ") == "> ",
|
||||
'540: config("prompt", "; ") == "> "');
|
||||
vrfy(config("more", ";; ") == ">> ",
|
||||
'541: config("more", ";; ") == ">> "');
|
||||
vrfy(config("all") == newcfg, '542: config("all") == newcfg');
|
||||
/* convert to "oldstd" config by individual changes */
|
||||
print '534: test unused';
|
||||
vrfy(config("outround", 2) == 24,
|
||||
'535: config("outround", 2) == 24');
|
||||
vrfy(config("leadzero","n") == 1,
|
||||
'536: config("leadzero","n") == 1');
|
||||
print '537: test unused';
|
||||
vrfy(config("prompt", "> ") == "; ",
|
||||
'538: config("prompt", "> ") == "; "');
|
||||
vrfy(config("more", ">> ") == ";; ",
|
||||
'539: config("more", ">> ") == ";; "');
|
||||
vrfy(config("all") == oldcfg, '540: config("all") == oldcfg');
|
||||
|
||||
/* check on the new config("fullzero") effect */
|
||||
vrfy(config("all","oldstd") == newcfg,
|
||||
'543: config("all",callcfg) == newcfg');
|
||||
/* restore the configation at the start of this function */
|
||||
vrfy(config("all",callcfg) == oldcfg,
|
||||
'541: config("all",callcfg) == oldcfg');
|
||||
|
||||
/* display and fullzero tests */
|
||||
vrfy(config("display",2) == 20,
|
||||
'544: config("display",2) == 20');
|
||||
'542: config("display",2) == 20');
|
||||
vrfy(config("leadzero",0) == 1,
|
||||
'543: config("leadzero",0) == 1');
|
||||
vrfy(config("fullzero",1) == 0,
|
||||
'545: config("fullzero",1) == 0');
|
||||
'544: config("fullzero",1) == 0');
|
||||
vrfy(strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00",
|
||||
'546: strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00"');
|
||||
'545: strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00"');
|
||||
vrfy(config("display",20) == 2,
|
||||
'547: config("display",20) == 2');
|
||||
vrfy(config("fullzero",0),
|
||||
'548: config("fullzero",0)');
|
||||
'546: config("display",20) == 2');
|
||||
vrfy(config("leadzero",1) == 0,
|
||||
'547: config("leadzero",1) == 0');
|
||||
vrfy(config("fullzero",0) == 1,
|
||||
'548: config("fullzero",0) == 1');
|
||||
vrfy(strprintf("%d %d %d", 0, 1, 2) == "0 1 2",
|
||||
'549: strprintf("%d %d %d", 0, 1, 2) == "0 1 2"');
|
||||
|
||||
/* restore calling config */
|
||||
vrfy(config("all",callcfg) == oldcfg,
|
||||
'550: config("all",callcfg) == oldcfg');
|
||||
vrfy(config("all",callcfg) == startcfg,
|
||||
'550: config("all",callcfg) == startcfg');
|
||||
vrfy(config("all") == callcfg, '551: config("all") == callcfg');
|
||||
vrfy(config("all") == startcfg, '552: config("all") == startcfg');
|
||||
|
||||
@@ -492,7 +494,11 @@ define test_config()
|
||||
vrfy(strlen(config("version")) > 0,
|
||||
'555: strlen(config("version")) > 0');
|
||||
|
||||
print '556: Ending test_config';
|
||||
/* mode2 is off by default */
|
||||
vrfy(config("mode2") == "off",
|
||||
'556: config("mode2") == "off"');
|
||||
|
||||
print '557: Ending test_config';
|
||||
}
|
||||
print '010: parsed test_config()';
|
||||
|
||||
@@ -755,7 +761,7 @@ define test_functions()
|
||||
vrfy(den(17) == 1, '712: den(17) == 1');
|
||||
vrfy(den(3/7) == 7, '713: den(3/7) == 7');
|
||||
vrfy(den(-2/3) == 3, '714: den(-2/3) == 3');
|
||||
vrfy(digits(0) == 0, '715: digits(0) == 0');
|
||||
vrfy(digits(0) == 1, '715: digits(0) == 1');
|
||||
vrfy(digits(9) == 1, '716: digits(9) == 1');
|
||||
vrfy(digits(10) == 2, '717: digits(10) == 2');
|
||||
vrfy(digits(-691) == 3, '718: digits(-691) == 3');
|
||||
@@ -996,9 +1002,9 @@ define test_functions()
|
||||
vrfy(strpos(a, "abc") == 1, '946: strpos(a, "abc") == 1');
|
||||
vrfy(strpos(a, "xyz") == 0, '947: strpos(a, "xyz") == 0');
|
||||
vrfy(strpos(a, a) == 1, '948: strpos(a, a) == 1');
|
||||
if (config("windows")) {
|
||||
print '949: test skipped for windows systems';
|
||||
print '950: test skipped for windows systems';
|
||||
if (config("windows") || config("cygwin")) {
|
||||
print '949: test skipped for windows or cygwin systems';
|
||||
print '950: test skipped for windows or cygwin systems';
|
||||
} else {
|
||||
vrfy(system("") == 0, '949: system("") == 0');
|
||||
vrfy(system("true") == 0, '950: system("true") == 0');
|
||||
@@ -1034,8 +1040,8 @@ define test_functions()
|
||||
vrfy(digit(a,-1) == 4, '974: digit(a,-1) == 4');
|
||||
vrfy(digit(a,-2) == 2, '975: digit(a,-2) == 2');
|
||||
vrfy(digit(a,-3) == 8, '976: digit(a,-3) == 8');
|
||||
vrfy(digits(0) == 0, '977: digits(0) == 0');
|
||||
vrfy(digits(0.0123) == 0, '978: digits(0.0123) == 0');
|
||||
vrfy(digits(0) == 1, '977: digits(0) == 1');
|
||||
vrfy(digits(0.0123) == 1, '978: digits(0.0123) == 1');
|
||||
vrfy(digits(3.7) == 1, '979: digits(3.7) == 1');
|
||||
vrfy(digits(-27) == 2, '980: digits(-27) == 2');
|
||||
vrfy(digits(-99.7) == 2, '981: digits(-99.7) == 2');
|
||||
@@ -1793,7 +1799,23 @@ define test_mode()
|
||||
vrfy(str(3e9) == "3000000000", \
|
||||
'1650: str(3e9) == \"3000000000\"');
|
||||
|
||||
print '1651: Ending mode/base test';
|
||||
/* 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');
|
||||
|
||||
print '1662: Ending mode/base test';
|
||||
}
|
||||
print '026: parsed test_mode()';
|
||||
|
||||
@@ -2188,6 +2210,7 @@ print '033: read -once test2300';
|
||||
define test_xx_incdec()
|
||||
{
|
||||
local A, B;
|
||||
local n;
|
||||
|
||||
print '2300: Beginning object increment/decrement test';
|
||||
|
||||
@@ -2220,6 +2243,20 @@ define test_xx_incdec()
|
||||
vrfy(ckmat(B,1,2,3) == 1,
|
||||
'2314: ckmat(B,1,2,3) == 1');
|
||||
|
||||
n = 1;
|
||||
print '2315: n = 1';
|
||||
vrfy(n + n + n + n++ == 4,
|
||||
'2316: n + n + n + n++ == 4');
|
||||
vrfy(n == 2, '2317: n == 2');
|
||||
n = 1;
|
||||
print '2318: n = 1';
|
||||
vrfy(n + n + n++ == 3, '2319: n + n + n++ == 3');
|
||||
vrfy(n == 2, '2320: n == 2');
|
||||
n = 1;
|
||||
print '2321: n = 1';
|
||||
vrfy(n + n++ == 2, '2322: n + n++ == 3');
|
||||
vrfy(n == 2, '2323: n == 2');
|
||||
|
||||
print '2315: Ending object increment/decrement test';
|
||||
}
|
||||
print '034: parsed test_xx_incdec()';
|
||||
@@ -2534,6 +2571,33 @@ define test_2600()
|
||||
i = config("sqrt", i);
|
||||
print tnum++: ': i = config("sqrt", i)';
|
||||
|
||||
i = epsilon(1e-100),;
|
||||
print tnum++: ': i = epsilon(1e-100),;';
|
||||
vrfy(ln(exp(6)) == 6,
|
||||
strcat(str(tnum++), ': ln(exp(6)) == 6'));
|
||||
vrfy(ln(exp(4)^4) == 16,
|
||||
strcat(str(tnum++), ': ln(exp(4)^4) == 16'));
|
||||
vrfy(ln(exp(6.5)^8) == 52,
|
||||
strcat(str(tnum++), ': ln(exp(6.5)^8) == 52'));
|
||||
vrfy(ln(exp(5)^16) == 80,
|
||||
strcat(str(tnum++), ': ln(exp(5)^16) == 80'));
|
||||
vrfy(ln(exp(4.5)^4) == 18,
|
||||
strcat(str(tnum++), ': ln(exp(4.5)^4) == 18'));
|
||||
vrfy(ln(exp(4)^8) == 32,
|
||||
strcat(str(tnum++), ': ln(exp(4)^8) == 32'));
|
||||
vrfy(ln(exp(60/11)^11) == 60,
|
||||
strcat(str(tnum++), ': ln(exp(60/11)^11) == 60'));
|
||||
vrfy(ln(exp(6)^15) == 90,
|
||||
strcat(str(tnum++), ': ln(exp(6)^11) == 90'));
|
||||
vrfy(ln(exp(80/17)^17) == 80,
|
||||
strcat(str(tnum++), ': ln(exp(80/17)^17) == 80'));
|
||||
vrfy(ln(exp(6)^15) == 90,
|
||||
strcat(str(tnum++), ': ln(exp(6)^15) == 90'));
|
||||
vrfy(ln(exp(5)^18) == 90,
|
||||
strcat(str(tnum++), ': ln(exp(5)^18) == 90'));
|
||||
epsilon(i),;
|
||||
print tnum++: ': epsilon(i),;';
|
||||
|
||||
print tnum: ': Ending extensive numeric function test';
|
||||
}
|
||||
print '037: parsed test_2600()';
|
||||
@@ -4547,7 +4611,14 @@ define test_random()
|
||||
vrfy(seed() < 2^64, '5465: seed() < 2^64');
|
||||
vrfy(israndom(srandom(seed())), '5466: israndom(srandom(seed()))');
|
||||
|
||||
print '5467: Ending test_random';
|
||||
/* verify random(10,11) double bug fix */
|
||||
vrfy(random(10,11) == 10, '5467: random(10,11) == 10');
|
||||
vrfy(random(10,11) == 10, '5468: random(10,11) == 10');
|
||||
vrfy(random(10,11) == 10, '5469: random(10,11) == 10');
|
||||
vrfy(random(0,1) == 0, '5470: random(0,1) == 0');
|
||||
vrfy(random(0,1) == 0, '5471: random(0,1) == 0');
|
||||
|
||||
print '5472: Ending test_random';
|
||||
}
|
||||
print '137: parsed test_random()';
|
||||
|
||||
@@ -6561,10 +6632,10 @@ define test_sha()
|
||||
0x21e42319a26787046c2b28b7ae70f1b54bf0ba2a,
|
||||
'7122: sha(sha("this is", 7^19-8, ..., "hash")) == 0x21e4...');
|
||||
|
||||
z = sha(list(1,2,3), "curds and whey", 2^21701-1, pi());
|
||||
print '7123: z = sha(list(1,2,3), "curds and whey", 2^21701-1, pi());';
|
||||
vrfy(sha(z) == 0x36dcca3e51865c30a2cf738023cda446f1368340,
|
||||
'7124: sha(z) == 0x36dcca3e51865c30a2cf738023cda446f1368340');
|
||||
z = sha(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));
|
||||
print '7123: z = sha(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));';
|
||||
vrfy(sha(z) == 257075527903934749824451356785709876382198951165,
|
||||
'7124: sha(z) == 257075527903934749824451356785709876382198951165');
|
||||
|
||||
y = sha();
|
||||
print '7125: y = sha()';
|
||||
@@ -6572,8 +6643,8 @@ define test_sha()
|
||||
print '7126: y = sha(y, list(1,2,3), "curds and whey")';
|
||||
y = sha(y, 2^21701-1);
|
||||
print '7127: y = sha(y, 2^21701-1)';
|
||||
y = sha(y, pi());
|
||||
print '7128: y = sha(y, pi())';
|
||||
y = sha(y, pi(1e-100));
|
||||
print '7128: y = sha(y, pi(1e-100))';
|
||||
vrfy(y == z, '7129: y == z');
|
||||
|
||||
B = blk() = {"a", "b", "c"};
|
||||
@@ -6632,10 +6703,10 @@ define test_sha1()
|
||||
'7209: sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) == ...');
|
||||
|
||||
|
||||
z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi());
|
||||
print '7210: z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi());';
|
||||
vrfy(sha1(z) == 0xc19e7317675dbf71e293b4c41e117169e9da5b6f,
|
||||
'7211: sha1(z) == 0xc19e7317675dbf71e293b4c41e117169e9da5b6f');
|
||||
z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));
|
||||
print '7210: z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));';
|
||||
vrfy(sha1(z) == 0x158cc87deeb9dd478ca14e3ab359205b0fb15b83,
|
||||
'7211: sha1(z) == 0x158cc87deeb9dd478ca14e3ab359205b0fb15b83');
|
||||
|
||||
y = sha1();
|
||||
print '7212: y = sha1();';
|
||||
@@ -6643,8 +6714,8 @@ define test_sha1()
|
||||
print '7213: y = sha1(y, list(1,2,3), "curds and whey");';
|
||||
y = sha1(y, 2^21701-1);
|
||||
print '7214: y = sha1(y, 2^21701-1);';
|
||||
y = sha1(y, pi());
|
||||
print '7215: y = sha1(y, pi());';
|
||||
y = sha1(y, pi(1e-100));
|
||||
print '7215: y = sha1(y, pi(1e-100));';
|
||||
vrfy(y == z, '7216: y == z');
|
||||
|
||||
vrfy(sha1(sha1("a"))==0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8,
|
||||
@@ -6720,18 +6791,18 @@ define test_md5()
|
||||
'7310: md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == ...');
|
||||
|
||||
|
||||
z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi());
|
||||
print '7311: z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi());';
|
||||
vrfy(md5(z) == 0x63d2b2fccae2de265227c30b05abb6b5,
|
||||
'7312: md5(z) == 0x63d2b2fccae2de265227c30b05abb6b5');
|
||||
z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));
|
||||
print '7311: z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));';
|
||||
vrfy(md5(z) == 0x487462e577eabef0302dd13af6632546,
|
||||
'7312: md5(z) == 0x487462e577eabef0302dd13af6632546');
|
||||
y = md5();
|
||||
print '7313: y = md5();';
|
||||
y = md5(y, list(1,2,3), "curds and whey");
|
||||
print '7314: y = md5(y, list(1,2,3), "curds and whey")';
|
||||
y = md5(y, 2^21701-1);
|
||||
print '7315: y = md5(y, 2^21701-1);';
|
||||
y = md5(y, pi());
|
||||
print '7316: y = md5(y, pi());';
|
||||
y = md5(y, pi(1e-100));
|
||||
print '7316: y = md5(y, pi(1e-100));';
|
||||
vrfy(y == z, '7317: y == z');
|
||||
|
||||
vrfy(md5(md5("a")) == 0x0cc175b9c0f1b6a831c399e269772661,
|
||||
|
53
cal/repeat.cal
Normal file
53
cal/repeat.cal
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* repeat - return the value of a repeated set of digits
|
||||
*
|
||||
* Copyright (C) 2003 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.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: repeat.cal,v 29.4 2003/01/26 19:42:03 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/repeat.cal,v $
|
||||
*
|
||||
* Under source code control: 2003/01/05 00:00:01
|
||||
* File existed as early as: 2003
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* repeat - return the value of a repeated set of digits
|
||||
*
|
||||
* usage:
|
||||
* repeat(digit_set, repeat_count)
|
||||
*/
|
||||
define repeat(digit_set, repeat_count)
|
||||
{
|
||||
local digit_count; /* digits in the digit_set */
|
||||
|
||||
/* firewall */
|
||||
if (!isint(digit_set) || digit_set <= 0) {
|
||||
quit "digit set must be an integer > 0";
|
||||
}
|
||||
if (!isint(repeat_count) || repeat_count <= 0) {
|
||||
quit "repeat count must be an integer > 0";
|
||||
}
|
||||
|
||||
/* return repeated set of digits */
|
||||
digit_count = digits(digit_set);
|
||||
return digit_set * (10^(digit_count*repeat_count)-1) / (10^digit_count-1);
|
||||
}
|
20
calc.c
20
calc.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* calc - arbitrary precision calculator
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
* Copyright (C) 1999-2004 David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: calc.c,v 29.8 2001/04/10 22:03:13 chongo Exp $
|
||||
* @(#) $Revision: 29.11 $
|
||||
* @(#) $Id: calc.c,v 29.11 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:11
|
||||
@@ -83,6 +83,8 @@
|
||||
# define strdup(x) calc_strdup((CONST char *)(x))
|
||||
#endif /* HAVE_STRDUP */
|
||||
|
||||
#include "have_unused.h"
|
||||
|
||||
|
||||
/*
|
||||
* static definitions and functions
|
||||
@@ -214,7 +216,13 @@ main(int argc, char **argv)
|
||||
havearg = TRUE;
|
||||
break;
|
||||
case 'n':
|
||||
new_std = TRUE;
|
||||
/*
|
||||
* -n is deprecated and may be reused
|
||||
* for another purpose in the future
|
||||
*/
|
||||
break;
|
||||
case 'O':
|
||||
use_old_std = TRUE;
|
||||
break;
|
||||
case 'p':
|
||||
p_flag = TRUE;
|
||||
@@ -425,7 +433,7 @@ main(int argc, char **argv)
|
||||
fprintf(stderr,
|
||||
"usage: %s [-a] [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
|
||||
"\t[-D calc_debug[:resource_debug[:user_debug]]]\n"
|
||||
"\t[-n] [-p] [-q] [-u] [-v] "
|
||||
"\t[-O] [-p] [-q] [-u] [-v] "
|
||||
"[--] [calc_cmd ...]\n",
|
||||
program);
|
||||
exit(1);
|
||||
@@ -700,7 +708,7 @@ main(int argc, char **argv)
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
intint(int arg)
|
||||
intint(int UNUSED arg)
|
||||
{
|
||||
(void) signal(SIGINT, intint);
|
||||
if (inputwait || (++abortlevel >= ABORT_NOW)) {
|
||||
|
10
calc.h
10
calc.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.9 $
|
||||
* @(#) $Id: calc.h,v 29.9 2001/12/11 02:28:47 chongo Exp $
|
||||
* @(#) $Revision: 29.11 $
|
||||
* @(#) $Id: calc.h,v 29.11 2003/08/26 04:36:10 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.h,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:31
|
||||
@@ -60,7 +60,11 @@
|
||||
#define HOMECHAR '~' /* char which indicates home directory */
|
||||
#define DOTCHAR '.' /* char which indicates current directory */
|
||||
#define PATHCHAR '/' /* char which separates path components */
|
||||
#if defined(__MSDOS__) || defined(__WIN32)
|
||||
#define LISTCHAR ';' /* char which separates paths in a list */
|
||||
#else
|
||||
#define LISTCHAR ':' /* char which separates paths in a list */
|
||||
#endif
|
||||
#define MAXCMD 16384 /* maximum length of command invocation */
|
||||
#define MAXERROR 512 /* maximum length of error message string */
|
||||
|
||||
@@ -228,7 +232,7 @@ extern DLL char *program; /* our name (argv[0]) */
|
||||
|
||||
extern DLL int no_env; /* TRUE (-e) => ignore env vars on startup */
|
||||
extern DLL int errmax; /* if >= 0, error when errcount exceeds errmax */
|
||||
extern DLL int new_std; /* TRUE (-n) => use newstd configuration */
|
||||
extern DLL int use_old_std; /* TRUE (-O) => use classic configuration */
|
||||
|
||||
extern DLL int allow_read; /* FALSE => dont open any files for reading */
|
||||
extern DLL int allow_write; /* FALSE => dont open any files for writing */
|
||||
|
143
calc.man
143
calc.man
@@ -1,5 +1,5 @@
|
||||
.\"
|
||||
.\" Copyright (C) 1999 Landon Curt Noll
|
||||
.\" Copyright (C) 1999-2004 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
|
||||
@@ -15,8 +15,8 @@
|
||||
.\" received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
.\" 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
.\"
|
||||
.\" @(#) $Revision: 29.7 $
|
||||
.\" @(#) $Id: calc.man,v 29.7 2001/06/01 11:26:53 chongo Exp $
|
||||
.\" @(#) $Revision: 29.17 $
|
||||
.\" @(#) $Id: calc.man,v 29.17 2004/10/23 00:58:33 chongo Exp $
|
||||
.\" @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.man,v $
|
||||
.\"
|
||||
.\" Under source code control: 1991/07/23 05:48:26
|
||||
@@ -44,7 +44,7 @@ calc \- arbitrary precision calculator
|
||||
.RB [ \-h ]
|
||||
.RB [ \-i ]
|
||||
.RB [ \-m\ \&mode ]
|
||||
.RB [ \-n ]
|
||||
.RB [ \-O ]
|
||||
.br
|
||||
.RB [ \-p ]
|
||||
.RB [ \-q ]
|
||||
@@ -54,7 +54,7 @@ calc \- arbitrary precision calculator
|
||||
.RB [ calc_cmd\ \&.\|.\|. ]
|
||||
.in -5n
|
||||
.sp
|
||||
\fI#!${BINDIR}/calc\fP\ \fB\-S\fP\ [other_flags\ \&...]
|
||||
\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-f\fP
|
||||
.SH DESCRIPTION
|
||||
\&
|
||||
.br
|
||||
@@ -119,7 +119,7 @@ as if \fBconfig("resource_debug", 0)\fP had been executed.
|
||||
For example:
|
||||
.sp 1
|
||||
.in +5n
|
||||
calc 'read qtime; qtime(2)'
|
||||
calc "read qtime; qtime(2)"
|
||||
.in -5n
|
||||
.sp 1
|
||||
will output something like:
|
||||
@@ -135,7 +135,7 @@ whereas:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
calc -d 'read qtime; qtime(2)'
|
||||
calc -d "read qtime; qtime(2)"
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
@@ -183,6 +183,80 @@ help config
|
||||
Ignore any environment variables on startup.
|
||||
The getenv() builtin will still return values, however.
|
||||
|
||||
.TP
|
||||
.B \-f
|
||||
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.
|
||||
.sp 1
|
||||
This flag is normally only at the end of a calc shell script.
|
||||
If the first line of an executable file begins
|
||||
.B #!
|
||||
followed by the absolute pathname of the
|
||||
.B calc
|
||||
program and the flag
|
||||
.B \-f
|
||||
as in:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-f\fP
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
the rest of the file will be processed in
|
||||
.BR "shell script mode" .
|
||||
See
|
||||
.B "SHELL SCRIPT MODE"
|
||||
section of this man page
|
||||
below for details.
|
||||
.sp 1
|
||||
The actual form of this flag is:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.B \-f
|
||||
filename
|
||||
.in -5n
|
||||
.sp 1
|
||||
On systems that treat an executable that begins with
|
||||
.B #!
|
||||
as a script, the path of the execurable is appended by the kernel
|
||||
as the final argument to the exec() system call.
|
||||
This is why the
|
||||
.B \-f
|
||||
flag at the very end of the
|
||||
.B #!
|
||||
line.
|
||||
.sp 1
|
||||
It is possible use
|
||||
.B \-f\ filename
|
||||
on the command line:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
\fIcalc\fP\ [other_flags\ \&...] \fB\-f\fP filename
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
This will cause calc to process lines in
|
||||
.B filename
|
||||
in
|
||||
.BR "shell script mode" .
|
||||
.sp 1
|
||||
Use of
|
||||
.B \-f
|
||||
implies
|
||||
.BR \-s .
|
||||
In addition,
|
||||
.B \-d
|
||||
and
|
||||
.B \-p
|
||||
are implied if
|
||||
.B \-i
|
||||
is not given.
|
||||
|
||||
.TP
|
||||
.B \-h
|
||||
Print a help message. This option implies
|
||||
@@ -302,11 +376,22 @@ The reading of key bindings is also disabled
|
||||
when the mode disables opening of files for reading.
|
||||
|
||||
.TP
|
||||
.B \-n
|
||||
Use the new configuration defaults instead of the old
|
||||
default classic defaults.
|
||||
.B \-O
|
||||
Use the old classic defaults instead of the
|
||||
default configuration.
|
||||
This flag as the same effect
|
||||
as executing \fBconfig("all", "newcfg")\fP at startup time.
|
||||
as executing \fBconfig("all", "oldcfg")\fP at startup time.
|
||||
.sp 1
|
||||
NOTE: Older versions of calc used
|
||||
.B \-n
|
||||
to setup a modified form of the default calc configuration.
|
||||
The
|
||||
.B \-n
|
||||
flag currently does nothing.
|
||||
Use of the
|
||||
.B \-n
|
||||
flag is now deprecated and may be used for
|
||||
something else in the future.
|
||||
|
||||
.TP
|
||||
.B \-p
|
||||
@@ -316,7 +401,7 @@ For example:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
calc -p '2^21701-1' | fizzbin
|
||||
calc -p "2^21701-1" | fizzbin
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
@@ -406,7 +491,7 @@ enclosing the command between single marks as in:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
calc '23 * 47'
|
||||
calc "23 * 47"
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
@@ -414,7 +499,7 @@ and
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
calc 'print sqrt(2), exp(1)'
|
||||
calc "print sqrt(2), exp(1)"
|
||||
.fi
|
||||
.in -5n
|
||||
.sp
|
||||
@@ -514,8 +599,8 @@ searches in succession:
|
||||
./myfile.cal
|
||||
${LIBDIR}/myfile
|
||||
${LIBDIR}/myfile.cal
|
||||
${CUSTOMLIBDIR}/myfile
|
||||
${CUSTOMLIBDIR}/myfile.cal
|
||||
${CUSTOMCALDIR}/myfile
|
||||
${CUSTOMCALDIR}/myfile.cal
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
@@ -567,32 +652,30 @@ help config
|
||||
.br
|
||||
SHELL SCRIPT MODE
|
||||
.PP
|
||||
If first line of an executable file begins
|
||||
If the first line of an executable file begins
|
||||
.B #!
|
||||
followed by the absolute pathname of the
|
||||
.B calc
|
||||
program and the flag
|
||||
.B \-S
|
||||
.B \-f
|
||||
as in:
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
\fI#!${BINDIR}/calc\fP\ \fB\-S\fP\ [other_flags\ \&...]
|
||||
\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-f\fP
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
the rest of the file will be processed in
|
||||
.BR "shell script mode" .
|
||||
Note that
|
||||
.B \-S
|
||||
(UPPER CASE
|
||||
.BR \-S )
|
||||
must be the first \-flag on the ``#!'' line.
|
||||
.B \-f
|
||||
must at the end of the intiial ``#!'' line.
|
||||
Any other optional
|
||||
.B "other_flags"
|
||||
must come after
|
||||
must come before
|
||||
the
|
||||
.BR \-S .
|
||||
.BR \-f .
|
||||
.sp 1
|
||||
In
|
||||
.B "shell script mode"
|
||||
@@ -608,8 +691,6 @@ the later lines within the script itself.
|
||||
In
|
||||
.BR "shell script mode" ,
|
||||
.B \-s
|
||||
(lower case
|
||||
.BR \-s )
|
||||
is always assumed.
|
||||
In addition,
|
||||
.B \-d
|
||||
@@ -625,7 +706,7 @@ the file
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
\fI#!${BINDIR}/calc\fP\ \fB\-S\fP\ \&\fB\-q\fP
|
||||
\fI#!${BINDIR}/calc\fP\ \&\fB\-q\fP \fB\-f\fP
|
||||
#
|
||||
# mersenne - an example of a calc \fBshell script file\fP
|
||||
|
||||
@@ -839,7 +920,7 @@ ${LIBDIR}/bindings
|
||||
non-GNU-readline command line editor bindings
|
||||
.sp 1
|
||||
.TP 5
|
||||
${INCDIRCALC}/*.h
|
||||
${CALC_INCDIR}/*.h
|
||||
include files for C interface use
|
||||
.sp 1
|
||||
.TP 5
|
||||
@@ -851,7 +932,7 @@ ${LIBDIR}/libcustcalc.a
|
||||
custom binary link library
|
||||
.sp 1
|
||||
.TP 5
|
||||
${CUSTOMLIBDIR}/*.cal
|
||||
${CUSTOMCALDIR}/*.cal
|
||||
custom resource files
|
||||
.sp 1
|
||||
.TP 5
|
||||
@@ -1088,7 +1169,7 @@ Landon Noll maintains the the
|
||||
web site is located at:
|
||||
.sp
|
||||
.in +0.5i
|
||||
http://www.isthe.com/chongo/tech/comp/calc/
|
||||
www.isthe.com/chongo/tech/comp/calc/
|
||||
.in -0.5i
|
||||
.sp
|
||||
Share and Enjoy! :\-)
|
||||
|
116
calc.spec.in
Normal file
116
calc.spec.in
Normal file
@@ -0,0 +1,116 @@
|
||||
#****h* calc/calc.spec.in
|
||||
#
|
||||
# calc.spec.in - template specfile for calc
|
||||
#
|
||||
# Copyright (C) 2003-2004 Petteri Kettunen and Landon Curt Noll
|
||||
#
|
||||
# Calc is open software; you can redistribute it and/or modify it under
|
||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
# Public License for more details.
|
||||
#
|
||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.13 $
|
||||
# @(#) $Id: calc.spec.in,v 29.13 2004/02/23 14:04:01 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.spec.in,v $
|
||||
#
|
||||
# Under source code control: 2003/02/16 20:21:39
|
||||
# File existed as early as: 2003
|
||||
#
|
||||
# calculator by David I. Bell with help/mods from others
|
||||
# Makefile by Petteri Kettunen with modifications from Landon Curt Noll
|
||||
|
||||
# BUGS
|
||||
# - Uninstalling calc and calc-devel leaves empty dirs /usr/include/calc
|
||||
# and /usr/share/calc and its subdird. In case e.g. %{_includedir}/calc
|
||||
# is defined in `%files devel' section, then rpmbuild complains that
|
||||
# header files are defined twice - rpmbuild bug or bug in specfile conf???
|
||||
|
||||
Summary: Arbitrary precision calculator.
|
||||
Name: calc
|
||||
Version: <<<PROJECT_VERSION>>>
|
||||
Release: 0
|
||||
Copyright: LGPL
|
||||
Group: Applications/Engineering
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
URL: http://www.isthe.com/chongo/tech/comp/calc/index.html
|
||||
Requires: ncurses >= 5.2-26, readline >= 4.2, less >= 358
|
||||
BuildRequires: ncurses-devel >= 5.2-26, readline-devel >= 4.2
|
||||
BuildRoot: %{_tmppath}/%{name}-root
|
||||
|
||||
%description
|
||||
Calc is arbitrary precision C-like arithmetic system that is a
|
||||
calculator, an algorithm prototyper and mathematical research
|
||||
tool. Calc comes with a rich set of builtin mathematical and
|
||||
programmatic functions.
|
||||
|
||||
For the latest calc release, see the project home page:
|
||||
|
||||
http://www.isthe.com/chongo/tech/comp/calc/index.html
|
||||
|
||||
%package devel
|
||||
Summary: Development files and documentation for calc.
|
||||
Group: Development/Libraries
|
||||
PreReq: %{name} = %{version}-%{release}
|
||||
|
||||
%description devel
|
||||
This package contains the header files and static libraries for developing
|
||||
calc (arbitrary precision calculator).
|
||||
|
||||
For the latest calc release, see the project home page:
|
||||
|
||||
http://www.isthe.com/chongo/tech/comp/calc/index.html
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 all chk
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
mkdir -p %{buildroot}
|
||||
make T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 install
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%files
|
||||
%defattr(-, root, root)
|
||||
%doc BUGS CHANGES COPYING COPYING-LGPL
|
||||
%{_bindir}/*
|
||||
%{_mandir}/man1/*
|
||||
%{_datadir}/%{name}/*/*
|
||||
%{_datadir}/%{name}/bindings
|
||||
%{_datadir}/%{name}/README
|
||||
%{_datadir}/%{name}/*.cal
|
||||
|
||||
%files devel
|
||||
%defattr(-, root, root)
|
||||
%doc BUGS COPYING COPYING-LGPL LIBRARY
|
||||
%attr(644, root, root) %{_includedir}/calc/*
|
||||
%attr(644, root, root) %{_libdir}/*.a
|
||||
|
||||
%changelog
|
||||
* Wed Feb 26 2003 Landon Curt Noll http://www.isthe.com/chongo
|
||||
- Release of calc-2.11.7-2
|
||||
- Fixed attributes on include and lib calc-devel files
|
||||
- Added BUGS to calc-devel as well as calc
|
||||
* Tue Feb 25 2003 Landon Curt Noll http://www.isthe.com/chongo
|
||||
- Release of calc-2.11.7-1
|
||||
- Require ncurses, readline and less to install.
|
||||
- Require ncurses-devel and readline-devel to build.
|
||||
* Tue Feb 18 2003 Landon Curt Noll http://www.isthe.com/chongo
|
||||
- Misc changes to fit local directory setup
|
||||
* Sun Feb 16 2003 Petteri Kettunen <petterik@users.sourceforge.net>
|
||||
- initial RPM build
|
||||
|
||||
#****
|
9
cmath.h
9
cmath.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: cmath.h,v 29.5 2001/06/08 21:00:58 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: cmath.h,v 29.6 2002/03/12 09:38:26 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/cmath.h,v $
|
||||
*
|
||||
* Under source code control: 1993/07/30 19:42:45
|
||||
@@ -62,6 +62,7 @@ extern void cprintfr(COMPLEX *c);
|
||||
/*
|
||||
* Basic numeric routines.
|
||||
*/
|
||||
|
||||
extern COMPLEX *cadd(COMPLEX *c1, COMPLEX *c2);
|
||||
extern COMPLEX *csub(COMPLEX *c1, COMPLEX *c2);
|
||||
extern COMPLEX *cmul(COMPLEX *c1, COMPLEX *c2);
|
||||
@@ -74,8 +75,8 @@ extern COMPLEX *cscale(COMPLEX *c, long i);
|
||||
extern COMPLEX *cshift(COMPLEX *c, long i);
|
||||
extern COMPLEX *csquare(COMPLEX *c);
|
||||
extern COMPLEX *cconj(COMPLEX *c);
|
||||
extern COMPLEX *creal(COMPLEX *c);
|
||||
extern COMPLEX *cimag(COMPLEX *c);
|
||||
extern COMPLEX *c_real(COMPLEX *c);
|
||||
extern COMPLEX *c_imag(COMPLEX *c);
|
||||
extern COMPLEX *cneg(COMPLEX *c);
|
||||
extern COMPLEX *cinv(COMPLEX *c);
|
||||
extern COMPLEX *cint(COMPLEX *c);
|
||||
|
20
codegen.c
20
codegen.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* codegen - module to generate opcodes from the input tokens
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2004 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: codegen.c,v 29.6 2001/05/08 06:29:24 chongo Exp $
|
||||
* @(#) $Revision: 29.9 $
|
||||
* @(#) $Id: codegen.c,v 29.9 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/codegen.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:13
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "func.h"
|
||||
#include "conf.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
# include <direct.h>
|
||||
#endif
|
||||
|
||||
@@ -1749,6 +1749,8 @@ getrelation(void)
|
||||
rescantoken();
|
||||
return type;
|
||||
}
|
||||
if (islvalue(type))
|
||||
addop(OP_GETVALUE);
|
||||
(void) getsum();
|
||||
addop(op);
|
||||
return EXPR_RVALUE;
|
||||
@@ -1788,6 +1790,8 @@ getsum(void)
|
||||
rescantoken();
|
||||
return type;
|
||||
}
|
||||
if (islvalue(type))
|
||||
addop(OP_GETVALUE);
|
||||
(void) getproduct();
|
||||
addop(op);
|
||||
type = EXPR_RVALUE;
|
||||
@@ -1817,6 +1821,8 @@ getproduct(void)
|
||||
rescantoken();
|
||||
return type;
|
||||
}
|
||||
if (islvalue(type))
|
||||
addop(OP_GETVALUE);
|
||||
(void) getorexpr();
|
||||
addop(op);
|
||||
type = EXPR_RVALUE;
|
||||
@@ -1836,6 +1842,8 @@ getorexpr(void)
|
||||
|
||||
type = getandexpr();
|
||||
while (gettoken() == T_OR) {
|
||||
if (islvalue(type))
|
||||
addop(OP_GETVALUE);
|
||||
(void) getandexpr();
|
||||
addop(OP_OR);
|
||||
type = EXPR_RVALUE;
|
||||
@@ -1867,6 +1875,8 @@ getandexpr(void)
|
||||
rescantoken();
|
||||
return type;
|
||||
}
|
||||
if (islvalue(type))
|
||||
addop(OP_GETVALUE);
|
||||
(void) getshiftexpr();
|
||||
addop(op);
|
||||
type = EXPR_RVALUE;
|
||||
@@ -1919,6 +1929,8 @@ getshiftexpr(void)
|
||||
rescantoken();
|
||||
return type;
|
||||
}
|
||||
if (islvalue(type))
|
||||
addop(OP_GETVALUE);
|
||||
(void) getshiftexpr();
|
||||
addop(op);
|
||||
return EXPR_RVALUE;
|
||||
|
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: commath.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: commath.c,v 29.3 2002/03/12 09:38:26 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/commath.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:10
|
||||
@@ -381,7 +381,7 @@ cconj(COMPLEX *c)
|
||||
* Return the real part of a complex number.
|
||||
*/
|
||||
COMPLEX *
|
||||
creal(COMPLEX *c)
|
||||
c_real(COMPLEX *c)
|
||||
{
|
||||
COMPLEX *r;
|
||||
|
||||
@@ -400,7 +400,7 @@ creal(COMPLEX *c)
|
||||
* Return the imaginary part of a complex number as a real.
|
||||
*/
|
||||
COMPLEX *
|
||||
cimag(COMPLEX *c)
|
||||
c_imag(COMPLEX *c)
|
||||
{
|
||||
COMPLEX *r;
|
||||
|
||||
|
122
config.c
122
config.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* config - configuration routines
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Landon Curt Noll
|
||||
* Copyright (C) 1999-2004 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: config.c,v 29.7 2001/04/25 07:15:22 chongo Exp $
|
||||
* @(#) $Revision: 29.14 $
|
||||
* @(#) $Id: config.c,v 29.14 2004/02/25 23:56:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
|
||||
*
|
||||
* Under source code control: 1991/07/20 00:21:56
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "nametype.h"
|
||||
#include "config.h"
|
||||
#include "string.h"
|
||||
#include "custom.h"
|
||||
|
||||
#include "have_strdup.h"
|
||||
#if !defined(HAVE_STRDUP)
|
||||
@@ -51,6 +52,7 @@
|
||||
NAMETYPE configs[] = {
|
||||
{"all", CONFIG_ALL},
|
||||
{"mode", CONFIG_MODE},
|
||||
{"mode2", CONFIG_MODE2},
|
||||
{"display", CONFIG_DISPLAY},
|
||||
{"epsilon", CONFIG_EPSILON},
|
||||
/*epsilonprec -- tied to epsilon not a configuration type*/
|
||||
@@ -91,6 +93,9 @@ NAMETYPE configs[] = {
|
||||
{"program", CONFIG_PROGRAM},
|
||||
{"basename", CONFIG_BASENAME},
|
||||
{"windows", CONFIG_WINDOWS},
|
||||
{"cygwin", CONFIG_CYGWIN},
|
||||
{"compile_custom", CONFIG_COMPILE_CUSTOM},
|
||||
{"allow_custom", CONFIG_ALLOW_CUSTOM},
|
||||
{"version", CONFIG_VERSION},
|
||||
{NULL, 0}
|
||||
};
|
||||
@@ -101,6 +106,7 @@ NAMETYPE configs[] = {
|
||||
*/
|
||||
CONFIG oldstd = { /* backward compatible standard configuration */
|
||||
MODE_INITIAL, /* current output mode */
|
||||
MODE2_INITIAL, /* current secondary output mode */
|
||||
20, /* current output digits for float or exp */
|
||||
NULL, /* loaded in at startup - default error for real functions */
|
||||
EPSILONPREC_DEFAULT, /* binary precision of epsilon */
|
||||
@@ -142,13 +148,25 @@ CONFIG oldstd = { /* backward compatible standard configuration */
|
||||
#else
|
||||
FALSE, /* congrats, you are not using windows */
|
||||
#endif
|
||||
#if defined(__CYGWIN__)
|
||||
TRUE, /* compiled under cygwin */
|
||||
#else
|
||||
FALSE, /* not compiled with cygwin */
|
||||
#endif
|
||||
#if defined(CUSTOM)
|
||||
TRUE, /* compiled with -DCUSTOM */
|
||||
#else
|
||||
FALSE, /* compiled without -DCUSTOM */
|
||||
#endif
|
||||
&allow_custom, /* *TRUE=> custom functions are enabled */
|
||||
NULL /* version */
|
||||
};
|
||||
CONFIG newstd = { /* new non-backward compatible configuration */
|
||||
MODE_INITIAL, /* current output mode */
|
||||
10, /* current output digits for float or exp */
|
||||
MODE2_INITIAL, /* current output mode */
|
||||
20, /* current output digits for float or exp */
|
||||
NULL, /* loaded in at startup - default error for real functions */
|
||||
NEW_EPSILONPREC_DEFAULT, /* binary precision of epsilon */
|
||||
EPSILONPREC_DEFAULT, /* binary precision of epsilon */
|
||||
FALSE, /* tracing flags */
|
||||
MAXPRINT_DEFAULT, /* number of elements to print */
|
||||
MUL_ALG2, /* size of number to use multiply alg 2 */
|
||||
@@ -158,7 +176,7 @@ CONFIG newstd = { /* new non-backward compatible configuration */
|
||||
TRUE, /* ok to print a tilde on approximations */
|
||||
TRUE, /* ok to print tab before numeric values */
|
||||
0, /* quomod() default rounding mode */
|
||||
0, /* quotient // default rounding mode */
|
||||
2, /* quotient // default rounding mode */
|
||||
0, /* mod % default rounding mode */
|
||||
24, /* sqrt() default rounding mode */
|
||||
24, /* appr() default rounding mode */
|
||||
@@ -167,7 +185,7 @@ CONFIG newstd = { /* new non-backward compatible configuration */
|
||||
24, /* output default rounding mode */
|
||||
24, /* round()/bround() default rounding mode */
|
||||
TRUE, /* ok to print leading 0 before decimal pt */
|
||||
1, /* ok to print trailing 0's */
|
||||
0, /* ok to print trailing 0's */
|
||||
MAXSCANCOUNT, /* max scan errors before abort */
|
||||
"; ", /* normal prompt */
|
||||
";; ", /* prompt when inside multi-line input */
|
||||
@@ -187,6 +205,17 @@ CONFIG newstd = { /* new non-backward compatible configuration */
|
||||
#else
|
||||
FALSE, /* congrats, you are not using windows */
|
||||
#endif
|
||||
#if defined(__CYGWIN__)
|
||||
TRUE, /* compiled under cygwin */
|
||||
#else
|
||||
FALSE, /* not compiled with cygwin */
|
||||
#endif
|
||||
#if defined(CUSTOM)
|
||||
TRUE, /* compiled with -DCUSTOM */
|
||||
#else
|
||||
FALSE, /* compiled without -DCUSTOM */
|
||||
#endif
|
||||
&allow_custom, /* *TRUE=> custom functions are enabled */
|
||||
NULL /* version */
|
||||
};
|
||||
CONFIG *conf = NULL; /* loaded in at startup - current configuration */
|
||||
@@ -212,6 +241,7 @@ static NAMETYPE modes[] = {
|
||||
{"oct", MODE_OCTAL},
|
||||
{"binary", MODE_BINARY},
|
||||
{"bin", MODE_BINARY},
|
||||
{"off", MODE2_OFF},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
@@ -467,6 +497,19 @@ setconfig(int type, VALUE *vp)
|
||||
math_setmode((int) temp);
|
||||
break;
|
||||
|
||||
case CONFIG_MODE2:
|
||||
if (vp->v_type != V_STR) {
|
||||
math_error("Non-string for mode");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
temp = lookup_long(modes, vp->v_str->s_str);
|
||||
if (temp < 0) {
|
||||
math_error("Unknown mode \"%s\"", vp->v_str);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
math_setmode2((int) temp);
|
||||
break;
|
||||
|
||||
case CONFIG_EPSILON:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non-numeric for epsilon");
|
||||
@@ -840,6 +883,18 @@ setconfig(int type, VALUE *vp)
|
||||
math_error("The windows config parameter is read-only");
|
||||
/*NOTREACHED*/
|
||||
|
||||
case CONFIG_CYGWIN:
|
||||
math_error("The cygwin config parameter is read-only");
|
||||
/*NOTREACHED*/
|
||||
|
||||
case CONFIG_COMPILE_CUSTOM:
|
||||
math_error("The custom config parameter is read-only");
|
||||
/*NOTREACHED*/
|
||||
|
||||
case CONFIG_ALLOW_CUSTOM:
|
||||
math_error("The allow_custom config parameter is read-only");
|
||||
/*NOTREACHED*/
|
||||
|
||||
case CONFIG_VERSION:
|
||||
math_error("The version config parameter is read-only");
|
||||
/*NOTREACHED*/
|
||||
@@ -904,6 +959,7 @@ config_copy(CONFIG *src)
|
||||
} else {
|
||||
dest->base_name = strdup(src->base_name);
|
||||
}
|
||||
/* NOTE: allow_custom points to a global variable, so do not clone it */
|
||||
if (src->version == NULL) {
|
||||
dest->version = strdup(version());
|
||||
} else {
|
||||
@@ -951,6 +1007,7 @@ config_free(CONFIG *cfg)
|
||||
if (cfg->base_name != NULL) {
|
||||
free(cfg->base_name);
|
||||
}
|
||||
/* NOTE: allow_custom points to a global variable, so do not free it */
|
||||
if (cfg->version != NULL) {
|
||||
free(cfg->version);
|
||||
}
|
||||
@@ -1018,6 +1075,16 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
||||
vp->v_str = makenewstring(p);
|
||||
return;
|
||||
|
||||
case CONFIG_MODE2:
|
||||
vp->v_type = V_STR;
|
||||
p = lookup_name(modes, cfg->outmode2);
|
||||
if (p == NULL) {
|
||||
math_error("invalid secondary output mode: %d", cfg->outmode2);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
vp->v_str = makenewstring(p);
|
||||
return;
|
||||
|
||||
case CONFIG_EPSILON:
|
||||
vp->v_num = qlink(cfg->epsilon);
|
||||
return;
|
||||
@@ -1212,6 +1279,34 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
||||
}
|
||||
return;
|
||||
|
||||
case CONFIG_CYGWIN:
|
||||
if (cfg->cygwin) {
|
||||
vp->v_num = itoq(1);
|
||||
} else {
|
||||
vp->v_num = itoq(0);
|
||||
}
|
||||
return;
|
||||
|
||||
case CONFIG_COMPILE_CUSTOM:
|
||||
if (cfg->compile_custom) {
|
||||
vp->v_num = itoq(1);
|
||||
} else {
|
||||
vp->v_num = itoq(0);
|
||||
}
|
||||
return;
|
||||
|
||||
case CONFIG_ALLOW_CUSTOM:
|
||||
/* firewall */
|
||||
if (cfg->allow_custom == NULL) {
|
||||
cfg->allow_custom = &allow_custom;
|
||||
}
|
||||
if (*(cfg->allow_custom)) {
|
||||
vp->v_num = itoq(1);
|
||||
} else {
|
||||
vp->v_num = itoq(0);
|
||||
}
|
||||
return;
|
||||
|
||||
case CONFIG_VERSION:
|
||||
vp->v_type = V_STR;
|
||||
if (cfg->version == NULL) {
|
||||
@@ -1267,6 +1362,7 @@ config_cmp(CONFIG *cfg1, CONFIG *cfg2)
|
||||
return cfg1->traceflags != cfg2->traceflags ||
|
||||
cfg1->outdigits != cfg2->outdigits ||
|
||||
cfg1->outmode != cfg2->outmode ||
|
||||
cfg1->outmode2 != cfg2->outmode2 ||
|
||||
qcmp(cfg1->epsilon, cfg2->epsilon) ||
|
||||
cfg1->epsilonprec != cfg2->epsilonprec ||
|
||||
cfg1->maxprint != cfg2->maxprint ||
|
||||
@@ -1310,9 +1406,19 @@ config_cmp(CONFIG *cfg1, CONFIG *cfg2)
|
||||
(cfg1->base_name != NULL && cfg2->base_name != NULL &&
|
||||
strcmp(cfg1->base_name, cfg2->base_name) != 0) ||
|
||||
|
||||
cfg1->windows != cfg2->windows ||
|
||||
|
||||
cfg1->cygwin != cfg2->cygwin ||
|
||||
|
||||
cfg1->compile_custom != cfg2->compile_custom ||
|
||||
|
||||
(cfg1->allow_custom == NULL && cfg2->allow_custom != NULL) ||
|
||||
(cfg1->allow_custom != NULL && cfg2->allow_custom == NULL) ||
|
||||
(cfg1->allow_custom != NULL && cfg2->allow_custom != NULL &&
|
||||
*(cfg1->allow_custom) != *(cfg2->allow_custom)) ||
|
||||
|
||||
(cfg1->version == NULL && cfg2->version != NULL) ||
|
||||
(cfg1->version != NULL && cfg2->version == NULL) ||
|
||||
cfg1->windows != cfg2->windows ||
|
||||
(cfg1->version != NULL && cfg2->version != NULL &&
|
||||
strcmp(cfg1->version, cfg2->version) != 0);
|
||||
}
|
||||
|
34
config.h
34
config.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* config - configuration routines
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll and David I. Bell
|
||||
* Copyright (C) 1999-2004 Landon Curt Noll and David I. Bell
|
||||
*
|
||||
* Primary author: Landon Curt Noll
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.11 $
|
||||
* @(#) $Id: config.h,v 29.11 2001/06/08 21:00:58 chongo Exp $
|
||||
* @(#) $Revision: 29.17 $
|
||||
* @(#) $Id: config.h,v 29.17 2004/02/25 23:56:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.h,v $
|
||||
*
|
||||
* Under source code control: 1995/11/01 22:20:17
|
||||
@@ -78,18 +78,22 @@
|
||||
#define CONFIG_MORE 25
|
||||
#define CONFIG_BLKMAXPRINT 26
|
||||
#define CONFIG_BLKVERBOSE 27
|
||||
#define CONFIG_BLKBASE 28
|
||||
#define CONFIG_BLKFMT 29
|
||||
#define CONFIG_BLKBASE 28
|
||||
#define CONFIG_BLKFMT 29
|
||||
#define CONFIG_RESOURCE_DEBUG 30
|
||||
#define CONFIG_LIB_DEBUG CONFIG_RESOURCE_DEBUG
|
||||
#define CONFIG_CALC_DEBUG 31
|
||||
#define CONFIG_USER_DEBUG 32
|
||||
#define CONFIG_VERBOSE_QUIT 33
|
||||
#define CONFIG_CTRL_D 34
|
||||
#define CONFIG_PROGRAM 35
|
||||
#define CONFIG_BASENAME 36
|
||||
#define CONFIG_VERSION 37
|
||||
#define CONFIG_WINDOWS 38
|
||||
#define CONFIG_CTRL_D 34
|
||||
#define CONFIG_PROGRAM 35
|
||||
#define CONFIG_BASENAME 36
|
||||
#define CONFIG_VERSION 37
|
||||
#define CONFIG_WINDOWS 38
|
||||
#define CONFIG_MODE2 39
|
||||
#define CONFIG_CYGWIN 40
|
||||
#define CONFIG_COMPILE_CUSTOM 41
|
||||
#define CONFIG_ALLOW_CUSTOM 42
|
||||
|
||||
|
||||
/*
|
||||
@@ -98,8 +102,6 @@
|
||||
#define DISPLAY_DEFAULT 20 /* default digits for float display */
|
||||
#define EPSILON_DEFAULT "1e-20" /* allowed error for float calculations */
|
||||
#define EPSILONPREC_DEFAULT 67 /* 67 ==> 2^-67 <= EPSILON_DEFAULT < 2^-66 */
|
||||
#define NEW_EPSILON_DEFAULT "1e-10" /* newstd EPSILON_DEFAULT */
|
||||
#define NEW_EPSILONPREC_DEFAULT 34 /* 34 ==> 2^-34 <= 1e-10 < 2^-33 */
|
||||
#define MAXPRINT_DEFAULT 16 /* default number of elements printed */
|
||||
#define MAXSCANCOUNT 20 /* default max scan errors before an abort */
|
||||
|
||||
@@ -118,6 +120,7 @@
|
||||
*/
|
||||
struct config {
|
||||
int outmode; /* current output mode */
|
||||
int outmode2; /* current secondary output mode */
|
||||
LEN outdigits; /* current output digits for float or exp */
|
||||
NUMBER *epsilon; /* default error for real functions */
|
||||
long epsilonprec; /* epsilon binary precision (tied to epsilon) */
|
||||
@@ -155,6 +158,9 @@ struct config {
|
||||
char *program; /* our name */
|
||||
char *base_name; /* basename of our name */
|
||||
BOOL windows; /* TRUE => running under MS windows */
|
||||
BOOL cygwin; /* TRUE => compiled with cygwin */
|
||||
BOOL compile_custom; /* TRUE => compiled with -DCUSTOM */
|
||||
BOOL *allow_custom; /* ptr to if custom functions are allowed */
|
||||
char *version; /* calc version string */
|
||||
};
|
||||
typedef struct config CONFIG;
|
||||
@@ -194,8 +200,8 @@ typedef struct config CONFIG;
|
||||
* global configuration states and aliases
|
||||
*/
|
||||
extern DLL CONFIG *conf; /* current configuration */
|
||||
extern DLL CONFIG oldstd; /* backward compatible standard configuration */
|
||||
extern DLL CONFIG newstd; /* new non-backward compatible configuration */
|
||||
extern DLL CONFIG oldstd; /* old classic standard configuration */
|
||||
extern DLL CONFIG newstd; /* default compatible configuration */
|
||||
extern DLL char *calc_debug; /* !=NULL => value of config("calc_debug") */
|
||||
extern DLL char *resource_debug; /* !=NULL => config("resource_debug") value */
|
||||
extern DLL char *user_debug; /* !=NULL => value of config("user_debug") */
|
||||
|
12
const.c
12
const.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* const - constant number storage module
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2004 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
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: const.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: const.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/const.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:14
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#define CONSTALLOCSIZE 400 /* number of constants to allocate */
|
||||
|
||||
static long constcount; /* number of constants defined */
|
||||
static unsigned long constcount;/* number of constants defined */
|
||||
static long constavail; /* number of constants available */
|
||||
static NUMBER **consttable; /* table of constants */
|
||||
|
||||
@@ -92,7 +92,7 @@ addqconstant(NUMBER *q)
|
||||
{
|
||||
register NUMBER **tp; /* pointer to current number */
|
||||
register NUMBER *t; /* number being tested */
|
||||
long index; /* index into constant table */
|
||||
unsigned long index; /* index into constant table */
|
||||
long numlen; /* numerator length */
|
||||
long denlen; /* denominator length */
|
||||
HALF numlow; /* bottom value of numerator */
|
||||
@@ -221,7 +221,7 @@ trimconstants(void)
|
||||
void
|
||||
showconstants(void)
|
||||
{
|
||||
long index;
|
||||
unsigned long index;
|
||||
NUMBER **qp;
|
||||
long count;
|
||||
|
||||
|
183
cscript/Makefile
183
cscript/Makefile
@@ -17,8 +17,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.20 $
|
||||
# @(#) $Id: Makefile,v 29.20 2001/06/10 19:35:02 chongo Exp $
|
||||
# @(#) $Revision: 29.23 $
|
||||
# @(#) $Id: Makefile,v 29.23 2003/01/14 01:58:18 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1999/11/29 11:10:26
|
||||
@@ -36,21 +36,111 @@
|
||||
SHELL= /bin/sh
|
||||
MAKE_FILE = Makefile
|
||||
|
||||
####
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
####
|
||||
|
||||
# Where the system include (.h) files are kept
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
# INCDIR= /dev/env/DJDIR/include
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# INCDIR= /usr/include
|
||||
#
|
||||
|
||||
#INCDIR= /usr/local/include
|
||||
#INCDIR= /dev/env/DJDIR/include
|
||||
INCDIR= /usr/include
|
||||
|
||||
# where to install calc realted things
|
||||
#
|
||||
# ${BINDIR} where to install calc binary files
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
# BINDIR= /dev/env/DJDIR/bin
|
||||
# LIBDIR= /dev/env/DJDIR/lib
|
||||
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# BINDIR= /usr/bin
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
#BINDIR= /usr/local/bin
|
||||
#BINDIR= /dev/env/DJDIR/bin
|
||||
BINDIR= /usr/bin
|
||||
#BINDIR= /usr/contrib/bin
|
||||
|
||||
#LIBDIR= /usr/local/lib
|
||||
#LIBDIR= /dev/env/DJDIR/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
|
||||
# ---------------------------------------------------------------
|
||||
# ${HELPDIR} where the help directory is installed
|
||||
# ${CALC_INCDIR} where the calc include files are installed
|
||||
# ${CUSTOMCALDIR} where custom *.cal files are installed
|
||||
# ${CUSTOMHELPDIR} where custom help files are installed
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed
|
||||
# ${SCRIPTDIR} where calc shell scripts are installed
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# HELPDIR= ${CALC_SHAREDIR}/help
|
||||
# CALC_INCDIR= ${INCDIR}/calc
|
||||
# CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
||||
# CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
||||
# CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
||||
# SCRIPTDIR= ${BINDIR}/cscript
|
||||
#
|
||||
HELPDIR= ${CALC_SHAREDIR}/help
|
||||
CALC_INCDIR= ${INCDIR}/calc
|
||||
CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
||||
CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
||||
CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
||||
SCRIPTDIR= ${BINDIR}/cscript
|
||||
|
||||
# T - top level directory under which calc will be installed
|
||||
#
|
||||
# The calc install is performed under $T, the calc build is
|
||||
# performed under /. The purpose for $T is to allow someone to
|
||||
# install calc somewhere other than into the system area. For example
|
||||
# when forming the calc rpm, the Makefile is called with T=$RPM_BUILD_ROOT.
|
||||
# performed under /. The purpose for $T is to allow someone
|
||||
# to install calc somewhere other than into the system area.
|
||||
#
|
||||
# For example, if:
|
||||
#
|
||||
# BINDIR= /usr/bin
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
# and if:
|
||||
#
|
||||
# T= /var/tmp/testing
|
||||
#
|
||||
# Then the installation locations will be:
|
||||
#
|
||||
# calc binary files: /var/tmp/testing/usr/bin
|
||||
# calc link library: /var/tmp/testing/usr/lib
|
||||
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
# ... etc ... /var/tmp/testing/...
|
||||
#
|
||||
# If $T is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If $T is non-empty, then
|
||||
@@ -139,8 +229,10 @@ all: ${TARGETS} .all
|
||||
##
|
||||
|
||||
distlist: ${DISTLIST}
|
||||
${Q}for i in ${DISTLIST}; do \
|
||||
${Q}for i in ${DISTLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo cscript/$$i; \
|
||||
fi; \
|
||||
done | LANG=C ${SORT}
|
||||
|
||||
distdir:
|
||||
@@ -152,23 +244,27 @@ calcliblist:
|
||||
#
|
||||
detaillist:
|
||||
${Q}-(echo "xxxxxxx"; \
|
||||
for i in ${SCRIPT}; do \
|
||||
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; \
|
||||
fi; \
|
||||
done | LANG=C ${SORT}) | ${FMT} -70 | \
|
||||
${SED} -e '1s/xxxxxxx/SCRIPT=/' -e '2,$$s/^/ /' \
|
||||
-e 's/$$/ \\/' -e '$$s/ \\$$//'
|
||||
${Q}echo
|
||||
${Q}-(echo "xxxxxxxxxxx"; \
|
||||
for i in ${SCRIPT}; do \
|
||||
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; \
|
||||
fi; \
|
||||
done | LANG=C ${SORT}) | ${FMT} -70 | \
|
||||
${SED} -e '1s/xxxxxxxxxxx/SCRIPT_SRC=/' -e '2,$$s/^/ /' \
|
||||
-e 's/$$/ \\/' -e '$$s/ \\$$//'
|
||||
@@ -197,11 +293,13 @@ depend:
|
||||
${Q}echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > \
|
||||
makedep.out
|
||||
${Q}echo "" >> makedep.out
|
||||
${Q}for i in ${SCRIPT}; do \
|
||||
${Q}for i in ${SCRIPT} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo "$$i: $$i.calc"; \
|
||||
echo ' rm -f $$@'; \
|
||||
echo ' $${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!$${BINDIR}/calc:" $$?>$$@'; \
|
||||
echo ' $${CHMOD} +x $$@'; \
|
||||
echo ' @rm -f $$@'; \
|
||||
echo ' @$${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!$${BINDIR}/calc:" $$?>$$@'; \
|
||||
echo ' @$${CHMOD} +x $$@'; \
|
||||
fi; \
|
||||
done >> makedep.out
|
||||
${Q}echo sample dependency list formed
|
||||
${Q}echo forming new cscript/Makefile
|
||||
@@ -233,8 +331,10 @@ depend:
|
||||
##
|
||||
|
||||
echo_inst_files:
|
||||
${Q}for i in ${SCRIPT}; do \
|
||||
echo __file__ ${SCRIPTDIR}/$$i; \
|
||||
${Q}for i in ${SCRIPT} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${SCRIPTDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
##
|
||||
@@ -274,7 +374,10 @@ install: all
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
${Q}for i in ${SCRIPT}; do \
|
||||
${Q}for i in ${SCRIPT} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s $$i $T${SCRIPTDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
@@ -289,34 +392,34 @@ install: all
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
4dsphere: 4dsphere.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
@rm -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
fproduct: fproduct.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
@rm -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
mersenne: mersenne.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
@rm -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
piforever: piforever.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
@rm -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
plus: plus.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
@rm -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
powerterm: powerterm.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
@rm -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
simple: simple.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
@rm -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
square: square.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
@rm -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
|
8
custom.c
8
custom.c
@@ -17,9 +17,9 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: custom.c,v 29.3 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/custom.c,v $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: custom.c,v 29.4 2004/02/25 23:54:40 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/../RCS/custom.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/03 04:53:08
|
||||
* File existed as early as: 1997
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
#endif /* CUSTOM */
|
||||
|
||||
int allow_custom = FALSE; /* TRUE => custom builtins allowed */
|
||||
BOOL allow_custom = FALSE; /* TRUE => custom builtins allowed */
|
||||
|
||||
|
||||
/*
|
||||
|
6
custom.h
6
custom.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: custom.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: custom.h,v 29.3 2004/02/25 23:54:40 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/custom.h,v $
|
||||
*
|
||||
* Under source code control: 1997/03/03 04:53:08
|
||||
@@ -72,7 +72,7 @@ struct custom {
|
||||
* These are the required interfaces. The dummy.c stubs these interfaces too.
|
||||
*/
|
||||
extern VALUE custom(char*, int, VALUE**); /* master custom interface */
|
||||
extern int allow_custom; /* TRUE => custom builtins allowed */
|
||||
extern BOOL allow_custom; /* TRUE => custom builtins allowed */
|
||||
extern void showcustom(void); /* print custom functions */
|
||||
extern void customhelp(char *); /* direct custom help */
|
||||
extern CONST struct custom cust[]; /* custom interface table */
|
||||
|
@@ -36,13 +36,15 @@ Step 1: Do some background work
|
||||
anything in Steps 2 and beyond!
|
||||
|
||||
If you are not familiar with calc internals, we recommend that
|
||||
you look at some examples of custom functions. Check out
|
||||
you look at some examples of custom functions. Look at the
|
||||
the following source files:
|
||||
|
||||
custom.c
|
||||
custom.h
|
||||
custom/custom.h
|
||||
custom/custtbl.c
|
||||
custom/c_*.[ch]
|
||||
custom/*.cal
|
||||
help/custom (or run: calc help custom)
|
||||
|
||||
You would be well advised to look at a more recent calc source
|
||||
@@ -83,14 +85,15 @@ Step 3: Document your custom function
|
||||
|
||||
Take a look at one of the example custom help files:
|
||||
|
||||
devnull
|
||||
argv
|
||||
help
|
||||
sysinfo
|
||||
custom/devnull
|
||||
custom/argv
|
||||
custom/help
|
||||
custom/sysinfo
|
||||
|
||||
You can save time by using one of the custom help files
|
||||
as a template. Copy one of these files to your own help file:
|
||||
|
||||
cd custom
|
||||
cp sysinfo curds
|
||||
|
||||
and edit it accordingly.
|
||||
@@ -107,15 +110,16 @@ Step 4: Write your test code
|
||||
test code will be an import part of your submission. Your test
|
||||
code will also service as additional for your custom function.
|
||||
|
||||
Coops ... we said we would stop preaching, sorry about that ...
|
||||
Oops ... we said we would stop preaching, sorry about that ...
|
||||
|
||||
You can use one of the following as a template:
|
||||
|
||||
argv.cal
|
||||
halflen.cal
|
||||
custom/argv.cal
|
||||
custom/halflen.cal
|
||||
|
||||
Copy one of these to your own file:
|
||||
|
||||
cd custom
|
||||
cp halflen.cal curds.cal
|
||||
|
||||
and exit it accordingly. In particular you will want to:
|
||||
@@ -152,6 +156,7 @@ Step 5: Write your custom function
|
||||
We recommend that you use one of the c_*.c files as a template.
|
||||
Copy an appropriate file to your file:
|
||||
|
||||
cd custom
|
||||
cp c_argv.c u_curds.c
|
||||
|
||||
Before you edit it, you should note that there are several important
|
||||
@@ -179,9 +184,6 @@ Step 5: Write your custom function
|
||||
VALUE
|
||||
u_curds(char *name, int count, VALUE **vals)
|
||||
|
||||
The /*ARGSUSED*/ may be needed if you do not make use
|
||||
of all 3 function parameters.
|
||||
|
||||
The 3 args are passed in by the custom interface
|
||||
and have the following meaning:
|
||||
|
||||
@@ -222,6 +224,15 @@ Step 5: Write your custom function
|
||||
vals[1] points to b
|
||||
vals[2] points to c
|
||||
|
||||
NOTE: If you do not use any of the 3 function parameters,
|
||||
then you should declare that function parameter to be UNUSED.
|
||||
For example, if the count and vals parameters were not used
|
||||
in your custom function, then your declaraction should be:
|
||||
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
u_curds(char *name, int UNUSED count, VALUE UNUSED **vals)
|
||||
|
||||
c) The return value is the function must be a VALUE.
|
||||
|
||||
The typical way to form a VALUE to return is by declaring
|
||||
@@ -239,6 +250,8 @@ Step 5: Write your custom function
|
||||
#include "../value.h"
|
||||
#include "custom.h"
|
||||
|
||||
#include "../have_unused.h"
|
||||
|
||||
Typically these will be included just below any system
|
||||
includes and just below the #if defined(CUSTOM) line.
|
||||
|
||||
@@ -362,7 +375,7 @@ Step 6: Register the function in the custom interface table
|
||||
|
||||
To allow the custom() builtin to transfer control to your function,
|
||||
you need to add an entry into the CONST struct custom cust table
|
||||
found in custtbl.c:
|
||||
found in custom/custtbl.c:
|
||||
|
||||
/*
|
||||
* custom interface table
|
||||
@@ -482,10 +495,10 @@ Step 6: Register the function in the custom interface table
|
||||
extern VALUE u_curds(char*, int, VALUE**);
|
||||
|
||||
|
||||
Step 7: Add the required information to the Makefile
|
||||
Step 7: Add the required information to the custom/Makefile
|
||||
|
||||
The calc test script, curds.cal, should be added to the
|
||||
CUSTOM_CALC_FILES Makefile variable:
|
||||
CUSTOM_CALC_FILES Makefile variable found in custom/Makefile:
|
||||
|
||||
CUSTOM_CALC_FILES= argv.cal halflen.cal curds.cal
|
||||
|
||||
@@ -619,7 +632,7 @@ Step 12: Contribute
|
||||
and consider submitting your custom function for possible
|
||||
inclusion in later versions of calc.
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
## Copyright (C) 1999-2004 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
|
||||
@@ -635,8 +648,8 @@ Step 12: Contribute
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: HOW_TO_ADD,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: HOW_TO_ADD,v 29.4 2004/07/29 08:38:05 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/HOW_TO_ADD,v $
|
||||
##
|
||||
## Under source code control: 1997/03/10 03:03:21
|
||||
|
307
custom/Makefile
307
custom/Makefile
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# custom - makefile for calc custom routines
|
||||
#
|
||||
# Copyright (C) 1999 Landon Curt Noll
|
||||
# Copyright (C) 1999,2004 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
|
||||
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.17 $
|
||||
# @(#) $Id: Makefile,v 29.17 2001/06/08 22:38:53 chongo Exp $
|
||||
# @(#) $Revision: 29.24 $
|
||||
# @(#) $Id: Makefile,v 29.24 2004/07/29 08:38:18 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/03/09 02:28:54
|
||||
@@ -40,13 +40,13 @@
|
||||
#
|
||||
# Put your custom calc resource files here.
|
||||
#
|
||||
CUSTOM_CALC_FILES= argv.cal halflen.cal pzasusb8.cal
|
||||
CUSTOM_CALC_FILES= argv.cal halflen.cal pzasusb8.cal pmodm127.cal
|
||||
|
||||
# The custom help files to install
|
||||
#
|
||||
# Put your custom help files here.
|
||||
#
|
||||
CUSTOM_HELP= argv devnull help sysinfo pzasusb8
|
||||
CUSTOM_HELP= argv devnull help sysinfo pzasusb8 pmodm127
|
||||
|
||||
# Any .h files that are needed by programs that use libcustcalc.a
|
||||
#
|
||||
@@ -62,7 +62,7 @@ CUSTOM_H_SRC=
|
||||
#
|
||||
# Put your custom .c files here.
|
||||
#
|
||||
CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c c_pzasusb8.c
|
||||
CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c c_pzasusb8.c c_pmodm127.c
|
||||
|
||||
# Any .o files that are needed by program that use libcustcalc.a.
|
||||
# Don't put ${REQUIRED_OBJ} files in this list.
|
||||
@@ -71,7 +71,7 @@ CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c c_pzasusb8.c
|
||||
#
|
||||
# Put your custom .o files here.
|
||||
#
|
||||
CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o c_pzasusb8.o
|
||||
CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o c_pzasusb8.o c_pmodm127.o
|
||||
|
||||
##############################################################################
|
||||
#-=-=-=-=-=-=- Defaults in case you want to build from this dir -=-=-=-=-=-=-#
|
||||
@@ -88,40 +88,111 @@ CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o c_pzasusb8.o
|
||||
#Q=
|
||||
Q=@
|
||||
|
||||
####
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
####
|
||||
|
||||
# Where the system include (.h) files are kept
|
||||
#
|
||||
# where to install things
|
||||
# For DJGPP, select:
|
||||
#
|
||||
# ${SHAREDIR} where most common shared files are kept
|
||||
# ${INCDIR} where most .h files are kept
|
||||
# INCDIR= /dev/env/DJDIR/include
|
||||
#
|
||||
# ${CSHAREDIR} where most common shared calc files are kept
|
||||
# ${HELPDIR} where the help directory is installed.
|
||||
# ${INCDIRCALC} where the calc include files are installed
|
||||
# ${CUSTOMLIBDIR} where custom *.cal files & libcustcalc.a are installed.
|
||||
# ${CUSTOMHELPDIR} where custom help files are installed.
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed.
|
||||
# If in doubt, set:
|
||||
#
|
||||
#SHAREDIR= /usr/local/lib
|
||||
SHAREDIR= /usr/share
|
||||
# INCDIR= /usr/include
|
||||
#
|
||||
|
||||
#INCDIR= /usr/local/include
|
||||
#INCDIR= /dev/env/DJDIR/include
|
||||
INCDIR= /usr/include
|
||||
|
||||
# where to install calc realted things
|
||||
#
|
||||
CSHAREDIR= ${SHAREDIR}/calc
|
||||
HELPDIR= ${CSHAREDIR}/help
|
||||
INCDIRCALC= ${INCDIR}/calc
|
||||
CUSTOMLIBDIR= ${CSHAREDIR}/custom
|
||||
CUSTOMHELPDIR= ${CSHAREDIR}/custhelp
|
||||
CUSTOMINCDIR= ${INCDIRCALC}/custom
|
||||
# ${BINDIR} where to install calc binary files
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
# BINDIR= /dev/env/DJDIR/bin
|
||||
# LIBDIR= /dev/env/DJDIR/lib
|
||||
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# BINDIR= /usr/bin
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
#BINDIR= /usr/local/bin
|
||||
#BINDIR= /dev/env/DJDIR/bin
|
||||
BINDIR= /usr/bin
|
||||
|
||||
#LIBDIR= /usr/local/lib
|
||||
#LIBDIR= /dev/env/DJDIR/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
|
||||
# ---------------------------------------------------------------
|
||||
# ${HELPDIR} where the help directory is installed
|
||||
# ${CALC_INCDIR} where the calc include files are installed
|
||||
# ${CUSTOMCALDIR} where custom *.cal files are installed
|
||||
# ${CUSTOMHELPDIR} where custom help files are installed
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed
|
||||
# ${SCRIPTDIR} where calc shell scripts are installed
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# HELPDIR= ${CALC_SHAREDIR}/help
|
||||
# CALC_INCDIR= ${INCDIR}/calc
|
||||
# CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
||||
# CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
||||
# CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
||||
# SCRIPTDIR= ${BINDIR}/cscript
|
||||
#
|
||||
HELPDIR= ${CALC_SHAREDIR}/help
|
||||
CALC_INCDIR= ${INCDIR}/calc
|
||||
CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
||||
CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
||||
CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
||||
SCRIPTDIR= ${BINDIR}/cscript
|
||||
|
||||
# T - top level directory under which calc will be installed
|
||||
#
|
||||
# The calc install is performed under $T, the calc build is
|
||||
# performed under /. The purpose for $T is to allow someone to
|
||||
# install calc somewhere other than into the system area. For example
|
||||
# when forming the calc rpm, the Makefile is called with T=$RPM_BUILD_ROOT.
|
||||
# performed under /. The purpose for $T is to allow someone
|
||||
# to install calc somewhere other than into the system area.
|
||||
#
|
||||
# For example, if:
|
||||
#
|
||||
# BINDIR= /usr/bin
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
# and if:
|
||||
#
|
||||
# T= /var/tmp/testing
|
||||
#
|
||||
# Then the installation locations will be:
|
||||
#
|
||||
# calc binary files: /var/tmp/testing/usr/bin
|
||||
# calc link library: /var/tmp/testing/usr/lib
|
||||
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
# ... etc ... /var/tmp/testing/...
|
||||
#
|
||||
# If $T is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If $T is non-empty, then
|
||||
@@ -279,7 +350,7 @@ REQUIRED_SRC= custtbl.c
|
||||
#
|
||||
REQUIRED_OBJ= custtbl.o
|
||||
|
||||
# These .h files are installed under ${CUSTOMLIBDIR} by the install rule.
|
||||
# These .h files are installed under ${CUSTOMCALDIR} by the install rule.
|
||||
#
|
||||
INSTALL_H_SRC= ${CUSTOM_H_SRC}
|
||||
|
||||
@@ -381,8 +452,10 @@ c_sysinfo.o: c_sysinfo.c ${MAKE_FILE}
|
||||
##
|
||||
|
||||
distlist: ${DISTLIST}
|
||||
${Q}for i in ${DISTLIST}; do \
|
||||
${Q}for i in ${DISTLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo custom/$$i; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
distdir:
|
||||
@@ -418,11 +491,13 @@ depend:
|
||||
-${Q}rm -rf skel
|
||||
${Q}mkdir skel
|
||||
${Q}mkdir skel/custom
|
||||
-${Q}for i in ${C_SRC}; do \
|
||||
-${Q}for i in ${C_SRC} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' \
|
||||
"$$i" > "skel/custom/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in /dev/null ${H_SRC}; do \
|
||||
-${Q}for i in ${H_SRC} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
@@ -437,7 +512,10 @@ depend:
|
||||
${Q}for i in `cd ..; ${MAKE} h_list 2>&1 | \
|
||||
${SED} -e '/Entering directory/d' \
|
||||
-e '/Nothing to be done/d' \
|
||||
-e '/Leaving directory/d'`; do \
|
||||
-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"; \
|
||||
@@ -451,8 +529,10 @@ depend:
|
||||
${Q}echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > \
|
||||
skel/custom/makedep.out
|
||||
${Q}cd skel/custom; ${MAKEDEPEND} -w 1 -f makedep.out ${C_SRC}
|
||||
-${Q}for i in ${C_SRC}; do \
|
||||
-${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/'; \
|
||||
fi; \
|
||||
done >> skel/custom/makedep.out
|
||||
${Q}echo custom dependency list formed
|
||||
${Q}echo forming new custom/Makefile
|
||||
@@ -485,17 +565,25 @@ depend:
|
||||
##
|
||||
|
||||
echo_inst_files:
|
||||
${Q}for i in ${INSTALL_H_SRC}; do \
|
||||
echo __file__ ${CUSTOMINCDIR}/$$i; \
|
||||
${Q}for i in ${INSTALL_H_SRC} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${CUSTOMINCDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
${Q}for i in ${CUSTOM_HELP}; do \
|
||||
echo __file__ ${CUSTOMHELPDIR}/$$i; \
|
||||
${Q}for i in ${CUSTOM_HELP} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${CUSTOMHELPDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
${Q}for i in ${CUSTOM_CALC_FILES}; do \
|
||||
echo __file__ ${CUSTOMLIBDIR}/$$i; \
|
||||
${Q}for i in ${CUSTOM_CALC_FILES} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${CUSTOMCALDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
${Q}for i in ${CALC_LIBCUSTOM}; do \
|
||||
echo __file__ ${CUSTOMLIBDIR}/$$i; \
|
||||
${Q}for i in ${CALC_LIBCUSTOM} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${CUSTOMCALDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
##
|
||||
@@ -512,18 +600,6 @@ clobber:
|
||||
rm -f .all Makefile.tmp Makefile.bak
|
||||
|
||||
install: all
|
||||
-${Q}if [ ! -d $T${SHAREDIR} ]; then \
|
||||
echo mkdir $T${SHAREDIR}; \
|
||||
mkdir $T${SHAREDIR}; \
|
||||
if [ ! -d "$T${SHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${SHAREDIR}"; \
|
||||
mkdir -p "$T${SHAREDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${SHAREDIR}; \
|
||||
${CHMOD} 0755 $T${SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${INCDIR} ]; then \
|
||||
echo mkdir $T${INCDIR}; \
|
||||
mkdir $T${INCDIR}; \
|
||||
@@ -536,27 +612,27 @@ install: all
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${CSHAREDIR} ]; then \
|
||||
echo mkdir $T${CSHAREDIR}; \
|
||||
mkdir $T${CSHAREDIR}; \
|
||||
if [ ! -d "$T${CSHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${CSHAREDIR}"; \
|
||||
mkdir -p "$T${CSHAREDIR}"; \
|
||||
-${Q}if [ ! -d $T${CALC_SHAREDIR} ]; then \
|
||||
echo mkdir $T${CALC_SHAREDIR}; \
|
||||
mkdir $T${CALC_SHAREDIR}; \
|
||||
if [ ! -d "$T${CALC_SHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CSHAREDIR}; \
|
||||
${CHMOD} 0755 $T${CSHAREDIR}; \
|
||||
echo ${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${INCDIRCALC} ]; then \
|
||||
echo mkdir $T${INCDIRCALC}; \
|
||||
mkdir $T${INCDIRCALC}; \
|
||||
if [ ! -d "$T${INCDIRCALC}" ]; then \
|
||||
echo mkdir -p "$T${INCDIRCALC}"; \
|
||||
mkdir -p "$T${INCDIRCALC}"; \
|
||||
-${Q}if [ ! -d $T${CALC_INCDIR} ]; then \
|
||||
echo mkdir $T${CALC_INCDIR}; \
|
||||
mkdir $T${CALC_INCDIR}; \
|
||||
if [ ! -d "$T${CALC_INCDIR}" ]; then \
|
||||
echo mkdir -p "$T${CALC_INCDIR}"; \
|
||||
mkdir -p "$T${CALC_INCDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${INCDIRCALC}; \
|
||||
${CHMOD} 0755 $T${INCDIRCALC}; \
|
||||
echo ${CHMOD} 0755 $T${CALC_INCDIR}; \
|
||||
${CHMOD} 0755 $T${CALC_INCDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@@ -572,15 +648,15 @@ install: all
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${CUSTOMLIBDIR} ]; then \
|
||||
echo mkdir $T${CUSTOMLIBDIR}; \
|
||||
mkdir $T${CUSTOMLIBDIR}; \
|
||||
if [ ! -d "$T${CUSTOMLIBDIR}" ]; then \
|
||||
echo mkdir -p "$T${CUSTOMLIBDIR}"; \
|
||||
mkdir -p "$T${CUSTOMLIBDIR}"; \
|
||||
-${Q}if [ ! -d $T${CUSTOMCALDIR} ]; then \
|
||||
echo mkdir $T${CUSTOMCALDIR}; \
|
||||
mkdir $T${CUSTOMCALDIR}; \
|
||||
if [ ! -d "$T${CUSTOMCALDIR}" ]; then \
|
||||
echo mkdir -p "$T${CUSTOMCALDIR}"; \
|
||||
mkdir -p "$T${CUSTOMCALDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CUSTOMLIBDIR}; \
|
||||
${CHMOD} 0755 $T${CUSTOMLIBDIR}; \
|
||||
echo ${CHMOD} 0755 $T${CUSTOMCALDIR}; \
|
||||
${CHMOD} 0755 $T${CUSTOMCALDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@@ -608,7 +684,10 @@ install: all
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}for i in ${INSTALL_H_SRC}; do \
|
||||
-${Q}for i in ${INSTALL_H_SRC} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s tmp $T${CUSTOMINCDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
@@ -620,18 +699,24 @@ install: all
|
||||
fi; \
|
||||
done
|
||||
-${Q}rm -f tmp
|
||||
-${Q}for i in ${CUSTOM_CALC_FILES}; do \
|
||||
if ${CMP} -s $$i $T${CUSTOMLIBDIR}/$$i; then \
|
||||
-${Q}for i in ${CUSTOM_CALC_FILES} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s $$i $T${CUSTOMCALDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f $T${CUSTOMLIBDIR}/$$i.new; \
|
||||
cp -f $$i $T${CUSTOMLIBDIR}/$$i.new; \
|
||||
${CHMOD} 0444 $T${CUSTOMLIBDIR}/$$i.new; \
|
||||
mv -f $T${CUSTOMLIBDIR}/$$i.new $T${CUSTOMLIBDIR}/$$i; \
|
||||
echo "installed $T${CUSTOMLIBDIR}/$$i"; \
|
||||
rm -f $T${CUSTOMCALDIR}/$$i.new; \
|
||||
cp -f $$i $T${CUSTOMCALDIR}/$$i.new; \
|
||||
${CHMOD} 0444 $T${CUSTOMCALDIR}/$$i.new; \
|
||||
mv -f $T${CUSTOMCALDIR}/$$i.new $T${CUSTOMCALDIR}/$$i; \
|
||||
echo "installed $T${CUSTOMCALDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${CUSTOM_HELP}; do \
|
||||
-${Q}for i in ${CUSTOM_HELP} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s $$i $T${CUSTOMHELPDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
@@ -643,16 +728,16 @@ install: all
|
||||
fi; \
|
||||
done
|
||||
-${Q}if [ ! -z ${ALLOW_CUSTOM} ]; then \
|
||||
if ${CMP} -s libcustcalc.a $T${CUSTOMLIBDIR}/libcustcalc.a; then \
|
||||
if ${CMP} -s libcustcalc.a $T${CUSTOMCALDIR}/libcustcalc.a; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f $T${CUSTOMLIBDIR}/libcustcalc.a.new; \
|
||||
cp -f libcustcalc.a $T${CUSTOMLIBDIR}/libcustcalc.a.new; \
|
||||
${CHMOD} 0644 $T${CUSTOMLIBDIR}/libcustcalc.a.new; \
|
||||
mv -f $T${CUSTOMLIBDIR}/libcustcalc.a.new \
|
||||
$T${CUSTOMLIBDIR}/libcustcalc.a; \
|
||||
${RANLIB} $T${CUSTOMLIBDIR}/libcustcalc.a; \
|
||||
echo "installed $T${CUSTOMLIBDIR}/libcustcalc.a"; \
|
||||
rm -f $T${CUSTOMCALDIR}/libcustcalc.a.new; \
|
||||
cp -f libcustcalc.a $T${CUSTOMCALDIR}/libcustcalc.a.new; \
|
||||
${CHMOD} 0644 $T${CUSTOMCALDIR}/libcustcalc.a.new; \
|
||||
mv -f $T${CUSTOMCALDIR}/libcustcalc.a.new \
|
||||
$T${CUSTOMCALDIR}/libcustcalc.a; \
|
||||
${RANLIB} $T${CUSTOMCALDIR}/libcustcalc.a; \
|
||||
echo "installed $T${CUSTOMCALDIR}/libcustcalc.a"; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
@@ -664,7 +749,6 @@ install: all
|
||||
|
||||
# DO NOT DELETE THIS LINE
|
||||
|
||||
|
||||
c_argv.o: ../alloc.h
|
||||
c_argv.o: ../block.h
|
||||
c_argv.o: ../byteswap.h
|
||||
@@ -681,6 +765,7 @@ c_argv.o: ../have_memmv.h
|
||||
c_argv.o: ../have_newstr.h
|
||||
c_argv.o: ../have_stdlib.h
|
||||
c_argv.o: ../have_string.h
|
||||
c_argv.o: ../have_unused.h
|
||||
c_argv.o: ../longbits.h
|
||||
c_argv.o: ../md5.h
|
||||
c_argv.o: ../nametype.h
|
||||
@@ -707,6 +792,7 @@ c_devnull.o: ../have_memmv.h
|
||||
c_devnull.o: ../have_newstr.h
|
||||
c_devnull.o: ../have_stdlib.h
|
||||
c_devnull.o: ../have_string.h
|
||||
c_devnull.o: ../have_unused.h
|
||||
c_devnull.o: ../longbits.h
|
||||
c_devnull.o: ../md5.h
|
||||
c_devnull.o: ../nametype.h
|
||||
@@ -733,6 +819,7 @@ c_help.o: ../have_memmv.h
|
||||
c_help.o: ../have_newstr.h
|
||||
c_help.o: ../have_stdlib.h
|
||||
c_help.o: ../have_string.h
|
||||
c_help.o: ../have_unused.h
|
||||
c_help.o: ../longbits.h
|
||||
c_help.o: ../md5.h
|
||||
c_help.o: ../nametype.h
|
||||
@@ -744,6 +831,33 @@ c_help.o: ../value.h
|
||||
c_help.o: ../win32dll.h
|
||||
c_help.o: ../zmath.h
|
||||
c_help.o: c_help.c
|
||||
c_pmodm127.o: ../alloc.h
|
||||
c_pmodm127.o: ../block.h
|
||||
c_pmodm127.o: ../byteswap.h
|
||||
c_pmodm127.o: ../calcerr.h
|
||||
c_pmodm127.o: ../cmath.h
|
||||
c_pmodm127.o: ../config.h
|
||||
c_pmodm127.o: ../custom.h
|
||||
c_pmodm127.o: ../endian_calc.h
|
||||
c_pmodm127.o: ../hash.h
|
||||
c_pmodm127.o: ../have_const.h
|
||||
c_pmodm127.o: ../have_malloc.h
|
||||
c_pmodm127.o: ../have_memmv.h
|
||||
c_pmodm127.o: ../have_newstr.h
|
||||
c_pmodm127.o: ../have_stdlib.h
|
||||
c_pmodm127.o: ../have_string.h
|
||||
c_pmodm127.o: ../have_unused.h
|
||||
c_pmodm127.o: ../longbits.h
|
||||
c_pmodm127.o: ../md5.h
|
||||
c_pmodm127.o: ../nametype.h
|
||||
c_pmodm127.o: ../qmath.h
|
||||
c_pmodm127.o: ../shs.h
|
||||
c_pmodm127.o: ../shs1.h
|
||||
c_pmodm127.o: ../string.h
|
||||
c_pmodm127.o: ../value.h
|
||||
c_pmodm127.o: ../win32dll.h
|
||||
c_pmodm127.o: ../zmath.h
|
||||
c_pmodm127.o: c_pmodm127.c
|
||||
c_pzasusb8.o: ../alloc.h
|
||||
c_pzasusb8.o: ../block.h
|
||||
c_pzasusb8.o: ../byteswap.h
|
||||
@@ -759,6 +873,7 @@ c_pzasusb8.o: ../have_memmv.h
|
||||
c_pzasusb8.o: ../have_newstr.h
|
||||
c_pzasusb8.o: ../have_stdlib.h
|
||||
c_pzasusb8.o: ../have_string.h
|
||||
c_pzasusb8.o: ../have_unused.h
|
||||
c_pzasusb8.o: ../longbits.h
|
||||
c_pzasusb8.o: ../md5.h
|
||||
c_pzasusb8.o: ../nametype.h
|
||||
@@ -788,9 +903,9 @@ c_sysinfo.o: ../have_memmv.h
|
||||
c_sysinfo.o: ../have_newstr.h
|
||||
c_sysinfo.o: ../have_stdlib.h
|
||||
c_sysinfo.o: ../have_string.h
|
||||
c_sysinfo.o: ../have_unused.h
|
||||
c_sysinfo.o: ../hist.h
|
||||
c_sysinfo.o: ../longbits.h
|
||||
c_sysinfo.o: ../longlong.h
|
||||
c_sysinfo.o: ../md5.h
|
||||
c_sysinfo.o: ../nametype.h
|
||||
c_sysinfo.o: ../prime.h
|
||||
|
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: argv.cal,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: argv.cal,v 29.3 2004/03/31 05:03:02 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/argv.cal,v $
|
||||
*
|
||||
* Under source code control: 1997/03/10 00:27:17
|
||||
@@ -34,9 +34,14 @@
|
||||
* NOTE: You must use a calc that was compiled with ALLOW_CUSTOM= -DCUSTOM
|
||||
* and run with a -C arg.
|
||||
*/
|
||||
if (config("compile_custom") == 0) {
|
||||
quit "calc compiled without -DCUSTOM";
|
||||
} else if (config("allow_custom") == 0) {
|
||||
quit "calc was run without the -D command line option";
|
||||
}
|
||||
|
||||
|
||||
define argv()
|
||||
define argv_test()
|
||||
{
|
||||
local i; /* arg number */
|
||||
local junk; /* throw away value */
|
||||
@@ -54,7 +59,3 @@ define argv()
|
||||
}
|
||||
return i-1;
|
||||
}
|
||||
|
||||
if (config("resource_debug") >= 0) {
|
||||
print "argv(var, ...) defined";
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_argv - a custom function display info about its args
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2004 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,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: c_argv.c,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: c_argv.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_argv.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 20:27:37
|
||||
@@ -40,6 +40,8 @@
|
||||
#include "../config.h"
|
||||
#include "../calc.h"
|
||||
|
||||
#include "../have_unused.h"
|
||||
|
||||
/*
|
||||
* c_argv - a custom function display info about its args
|
||||
*
|
||||
@@ -51,7 +53,7 @@
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_argv(char *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 Landon Curt Noll
|
||||
* Copyright (C) 1999-2004 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,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: c_devnull.c,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: c_devnull.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_devnull.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 17:49:12
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "../value.h"
|
||||
#include "../custom.h"
|
||||
|
||||
#include "../have_unused.h"
|
||||
|
||||
|
||||
/*
|
||||
* c_devnull - a custom function that does nothing
|
||||
@@ -45,7 +47,7 @@
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_devnull(char *name, int count, VALUE **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 Landon Curt Noll
|
||||
* Copyright (C) 1999-2004 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,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: c_help.c,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: c_help.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_help.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 05:25:41
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "../value.h"
|
||||
#include "../custom.h"
|
||||
|
||||
#include "../have_unused.h"
|
||||
|
||||
|
||||
/*
|
||||
* c_help - custom help function
|
||||
@@ -56,7 +58,7 @@
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_help(char *name, int count, VALUE **vals)
|
||||
c_help(char UNUSED *name, int UNUSED count, VALUE **vals)
|
||||
{
|
||||
VALUE result; /* what we will return */
|
||||
|
||||
|
272
custom/c_pmodm127.c
Normal file
272
custom/c_pmodm127.c
Normal file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* c_pmodm127 - calculate q mod 2^(2^127-1)
|
||||
*
|
||||
* Copyright (C) 2004 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.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: c_pmodm127.c,v 29.3 2004/07/29 09:48:31 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_pmodm127.c,v $
|
||||
*
|
||||
* Under source code control: 2004/07/28 22:12:25
|
||||
* File existed as early as: 2004
|
||||
*
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CUSTOM)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../have_const.h"
|
||||
#include "../value.h"
|
||||
#include "../custom.h"
|
||||
#include "../zmath.h"
|
||||
|
||||
#include "../have_unused.h"
|
||||
|
||||
/* 2^255 */
|
||||
static HALF h255[] = {
|
||||
#if BASEB == 32
|
||||
(HALF)0x00000000, (HALF)0x00000000, (HALF)0x00000000, (HALF)0x00000000,
|
||||
(HALF)0x00000000, (HALF)0x00000000, (HALF)0x00000000, (HALF)0x80000000
|
||||
#else /* BASEB == 32 */
|
||||
(HALF)0x0000, (HALF)0x0000, (HALF)0x0000, (HALF)0x0000,
|
||||
(HALF)0x0000, (HALF)0x0000, (HALF)0x0000, (HALF)0x0000,
|
||||
(HALF)0x0000, (HALF)0x0000, (HALF)0x0000, (HALF)0x0000,
|
||||
(HALF)0x0000, (HALF)0x0000, (HALF)0x0000, (HALF)0x8000
|
||||
#endif /* BASEB == 32 */
|
||||
};
|
||||
ZVALUE p255 = {
|
||||
h255, 8, 0
|
||||
};
|
||||
|
||||
|
||||
/* static declarations */
|
||||
static void zmod5_or_zmod(ZVALUE *zp);
|
||||
static BOOL havelastmod = FALSE;
|
||||
static ZVALUE lastmod[1];
|
||||
static ZVALUE lastmodinv[1];
|
||||
|
||||
|
||||
/*
|
||||
* c_pmodm127 - calculate q mod 2^(2^127-1)
|
||||
*
|
||||
* given:
|
||||
* count = 1;
|
||||
* vals[0] real number; (q - potential factor)
|
||||
*
|
||||
* returns:
|
||||
* result real number; (q mod 2^(2^127-1))
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_pmodm127(char UNUSED *name, int UNUSED count, VALUE **vals)
|
||||
{
|
||||
VALUE result; /* what we will return */
|
||||
ZVALUE q; /* test factor */
|
||||
ZVALUE temp; /* temp calculation value */
|
||||
int i; /* exponent value */
|
||||
|
||||
/*
|
||||
* arg check
|
||||
*/
|
||||
result.v_type = V_NULL;
|
||||
if (vals[0]->v_type != V_NUM) {
|
||||
math_error("Non-numeric argument for pmodm127");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (qisfrac(vals[0]->v_num)) {
|
||||
math_error("Non-integer argument for pmodm127");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (qisneg(vals[0]->v_num) || qiszero(vals[0]->v_num)) {
|
||||
math_error("argument for pmodm127 <= 0");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
/*
|
||||
* look at the numerator
|
||||
*/
|
||||
q = vals[0]->v_num->num;
|
||||
|
||||
/*
|
||||
* setup lastmod with q
|
||||
*/
|
||||
if (havelastmod && zcmp(q, *lastmod)) {
|
||||
zfree(*lastmod);
|
||||
zfree(*lastmodinv);
|
||||
havelastmod = FALSE;
|
||||
}
|
||||
if (!havelastmod) {
|
||||
zcopy(q, lastmod);
|
||||
zbitvalue(2 * q.len * BASEB, &temp);
|
||||
zquo(temp, q, lastmodinv, 0);
|
||||
zfree(temp);
|
||||
havelastmod = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* start with 2^255
|
||||
*/
|
||||
result.v_num = qalloc();
|
||||
zcopy(p255, &result.v_num->num);
|
||||
result.v_type = V_NUM;
|
||||
|
||||
/*
|
||||
* compute 2^(2^127-1) mod q by modular exponentation
|
||||
*
|
||||
* We implement the following calc code in C:
|
||||
*
|
||||
* (* given q, our test factor, as the arg to this function *)
|
||||
* result = 2^255;
|
||||
* for (i=8; i < 127; ++i) {
|
||||
* result %= q; (* mod *)
|
||||
* result *= result; (* square *)
|
||||
* result <<= 1; (* times 2 *)
|
||||
* }
|
||||
* result %= q; (* result is now 2^(2^127-1) % q *)
|
||||
*/
|
||||
for (i=8; i<127; ++i) {
|
||||
#if 0
|
||||
/* use of zmod is a bit slower than zmod5_or_zmod */
|
||||
(void) zmod(result.v_num->num, *lastmod, &temp, 0);
|
||||
zfree(result.v_num->num);
|
||||
result.v_num->num = temp;
|
||||
#else
|
||||
zmod5_or_zmod(&result.v_num->num); /* mod */
|
||||
#endif
|
||||
#if 0
|
||||
/* use of zmul is slightly slower than zsquare */
|
||||
zmul(result.v_num->num, result.v_num->num, &temp); /* square */
|
||||
#else
|
||||
zsquare(result.v_num->num, &temp); /* square */
|
||||
#endif
|
||||
/* XXX - we could manually shift to speed up a tiny bit */
|
||||
zfree(result.v_num->num);
|
||||
zshift(temp, 1, &result.v_num->num); /* times 2 */
|
||||
zfree(temp);
|
||||
}
|
||||
zmod5_or_zmod(&result.v_num->num); /* result = 2^(2^127-1) % q */
|
||||
|
||||
/*
|
||||
* cleanup and return result
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* zmod5_or_zmod - fast integer modulo the modulus computation
|
||||
*
|
||||
* "borrowed" from ../zmod.c
|
||||
*
|
||||
* Given the address of a positive integer whose word count does not
|
||||
* exceed twice that of the modulus stored at lastmod, to evaluate and store
|
||||
* at that address the value of the integer modulo the modulus.
|
||||
*
|
||||
* Unlike the static routine in ../zmod.c, we will call the zmod and return
|
||||
* the result of the zmod5_or_zmod conditions do not apply to the argument
|
||||
* and saved mod.
|
||||
*/
|
||||
static void
|
||||
zmod5_or_zmod(ZVALUE *zp)
|
||||
{
|
||||
LEN len, modlen, j;
|
||||
ZVALUE tmp1, tmp2;
|
||||
ZVALUE z1, z2, z3;
|
||||
HALF *a, *b;
|
||||
FULL f;
|
||||
HALF u;
|
||||
|
||||
int subcount = 0;
|
||||
|
||||
if (zrel(*zp, *lastmod) < 0)
|
||||
return;
|
||||
modlen = lastmod->len;
|
||||
len = zp->len;
|
||||
z1.v = zp->v + modlen - 1;
|
||||
z1.len = len - modlen + 1;
|
||||
z1.sign = z2.sign = z3.sign = 0;
|
||||
if (z1.len > modlen + 1) {
|
||||
/* in ../zmod.c we did a math_error("Bad call to zmod5!!!"); */
|
||||
/* here we just call the slower zmod and return the result */
|
||||
(void) zmod(*zp, *lastmod, &tmp1, 0);
|
||||
/* replace zp with tmp1 mod result */
|
||||
zfree(*zp);
|
||||
*zp = tmp1;
|
||||
return;
|
||||
}
|
||||
z2.v = lastmodinv->v + modlen + 1 - z1.len;
|
||||
z2.len = lastmodinv->len - modlen - 1 + z1.len;
|
||||
zmul(z1, z2, &tmp1);
|
||||
z3.v = tmp1.v + z1.len;
|
||||
z3.len = tmp1.len - z1.len;
|
||||
if (z3.len > 0) {
|
||||
zmul(z3, *lastmod, &tmp2);
|
||||
j = modlen;
|
||||
a = zp->v;
|
||||
b = tmp2.v;
|
||||
u = 0;
|
||||
len = modlen;
|
||||
while (j-- > 0) {
|
||||
f = (FULL) *a - (FULL) *b++ - (FULL) u;
|
||||
*a++ = (HALF) f;
|
||||
u = - (HALF) (f >> BASEB);
|
||||
}
|
||||
if (z1.len > 1) {
|
||||
len++;
|
||||
if (tmp2.len > modlen)
|
||||
f = (FULL) *a - (FULL) *b - (FULL) u;
|
||||
else
|
||||
f = (FULL) *a - (FULL) u;
|
||||
*a++ = (HALF) f;
|
||||
}
|
||||
while (len > 0 && *--a == 0)
|
||||
len--;
|
||||
zp->len = len;
|
||||
zfree(tmp2);
|
||||
}
|
||||
zfree(tmp1);
|
||||
while (len > 0 && zrel(*zp, *lastmod) >= 0) {
|
||||
subcount++;
|
||||
if (subcount > 2) {
|
||||
math_error("Too many subtractions in zmod5_or_zmod");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
j = modlen;
|
||||
a = zp->v;
|
||||
b = lastmod->v;
|
||||
u = 0;
|
||||
while (j-- > 0) {
|
||||
f = (FULL) *a - (FULL) *b++ - (FULL) u;
|
||||
*a++ = (HALF) f;
|
||||
u = - (HALF) (f >> BASEB);
|
||||
}
|
||||
if (len > modlen) {
|
||||
f = (FULL) *a - (FULL) u;
|
||||
*a++ = (HALF) f;
|
||||
}
|
||||
while (len > 0 && *--a == 0)
|
||||
len--;
|
||||
zp->len = len;
|
||||
}
|
||||
if (len == 0)
|
||||
zp->len = 1;
|
||||
}
|
||||
|
||||
#endif /* CUSTOM */
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_pzasusb8 - print numereator as a string of USB8s
|
||||
*
|
||||
* Copyright (C) 1999 Ernest Bowen
|
||||
* Copyright (C) 1999-2004 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
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: c_pzasusb8.c,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: c_pzasusb8.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_pzasusb8.c,v $
|
||||
*
|
||||
* Under source code control: 1999/10/06 03:12:25
|
||||
@@ -37,6 +37,8 @@
|
||||
#include "../custom.h"
|
||||
#include "../zmath.h"
|
||||
|
||||
#include "../have_unused.h"
|
||||
|
||||
/*
|
||||
* c_pzasusb8 - print numereator as a string of USB8s
|
||||
*
|
||||
@@ -49,7 +51,7 @@
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_pzasusb8(char *name, int 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_sysinfo - names and values of selected #defines
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2004 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,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: c_sysinfo.c,v 29.5 2001/04/14 23:04:17 chongo Exp $
|
||||
* @(#) $Revision: 29.10 $
|
||||
* @(#) $Id: c_sysinfo.c,v 29.10 2004/03/31 05:02:10 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_sysinfo.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 23:14:40
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "../calc.h"
|
||||
#include "../longbits.h"
|
||||
#define CHECK_L_FORMAT
|
||||
#include "../longlong.h"
|
||||
#include "../block.h"
|
||||
#include "../calcerr.h"
|
||||
#include "../conf.h"
|
||||
@@ -53,6 +52,8 @@
|
||||
#include "../zrand.h"
|
||||
#include "../zrandom.h"
|
||||
|
||||
#include "../have_unused.h"
|
||||
|
||||
|
||||
/*
|
||||
* sys_info - names and values of selected #defines
|
||||
@@ -102,7 +103,6 @@ static struct infoname sys_info[] = {
|
||||
{"INIT_K", "initial 2nd walking a55 table index", NULL, (FULL)INIT_K},
|
||||
{"INODE_BITS", "inode number size in bits", NULL, (FULL)INODE_BITS},
|
||||
{"LITTLE_ENDIAN", "Least Significant Byte first symbol", NULL, (FULL)LITTLE_ENDIAN},
|
||||
{"LONGLONG_BITS", "length of a long long, or 0", NULL, (FULL)LONGLONG_BITS},
|
||||
{"LONG_BITS", "bit length of a long", NULL, (FULL)LONG_BITS},
|
||||
{"MAP_POPCNT", "number of odd primes in pr_map", NULL, (FULL)MAP_POPCNT},
|
||||
{"MAX_CALCRC", "maximum allowed length of $CALCRC", NULL, (FULL)MAX_CALCRC},
|
||||
@@ -128,8 +128,6 @@ static struct infoname sys_info[] = {
|
||||
{"MAX_SM_PRIME", "larest 32 bit prime", NULL, (FULL)MAX_SM_PRIME},
|
||||
{"MAX_SM_VAL", "larest 32 bit value", NULL, (FULL)MAX_SM_VAL},
|
||||
{"MUL_ALG2", "default size for alternative multiply", NULL, (FULL)MUL_ALG2},
|
||||
{"NEW_EPSILONPREC_DEFAULT", "2^-EPSILON_DEFAULT <= EPSILON_DEFAULT", NULL, (FULL)NEW_EPSILONPREC_DEFAULT},
|
||||
{"NEW_EPSILON_DEFAULT", "newstd EPSILON_DEFAULT", NEW_EPSILON_DEFAULT, (FULL)0},
|
||||
{"NXT_MAP_PRIME", "smallest odd prime not in pr_map", NULL, (FULL)NXT_MAP_PRIME},
|
||||
{"NXT_PFACT_VAL", "next prime for higher pfact values", NULL, (FULL)NXT_PFACT_VAL},
|
||||
{"OFF_T_BITS", "file offset size in bits", NULL, (FULL)OFF_T_BITS},
|
||||
@@ -181,7 +179,7 @@ static void dump_mening_value(void); /* custom("sysinfo", 2) */
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_sysinfo(char *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 */
|
||||
@@ -317,30 +315,16 @@ dump_name_value(void)
|
||||
/* dump the entire table */
|
||||
for (p = sys_info; p->name != NULL; ++p) {
|
||||
if (p->str == NULL) {
|
||||
#if LONG_BITS == FULL_BITS || FULL_BITS == 32 || !defined(HAVE_LONGLONG)
|
||||
#if LONG_BITS == FULL_BITS || FULL_BITS == 32
|
||||
printf("%s%-23s\t%-8lu\t(0x%lx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->name,
|
||||
(unsigned long)p->nmbr,
|
||||
(unsigned long)p->nmbr);
|
||||
#else
|
||||
/*
|
||||
* Determine of %ld can print a 64 bit long long.
|
||||
*
|
||||
* Some systems that can make use of %ld to print a
|
||||
* a 64 bit value do not support the %lld type.
|
||||
* So we will only try %lld if %ld does not work.
|
||||
*/
|
||||
# if defined(L64_FORMAT)
|
||||
printf("%s%-23s\t%-8lu\t(0x%lx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->name,
|
||||
(unsigned long long)p->nmbr,
|
||||
(unsigned long long)p->nmbr);
|
||||
# else /* L64_FORMAT */
|
||||
printf("%s%-23s\t%-8llu\t(0x%llx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->name,
|
||||
(unsigned long long)p->nmbr,
|
||||
(unsigned long long)p->nmbr);
|
||||
# endif /* L64_FORMAT */
|
||||
#endif
|
||||
} else {
|
||||
printf("%s%-23s\t\"%s\"\n",
|
||||
@@ -362,25 +346,16 @@ dump_mening_value(void)
|
||||
/* dump the entire table */
|
||||
for (p = sys_info; p->name != NULL; ++p) {
|
||||
if (p->str == NULL) {
|
||||
#if LONG_BITS == FULL_BITS || FULL_BITS == 32 || !defined(HAVE_LONGLONG)
|
||||
#if LONG_BITS == FULL_BITS || FULL_BITS == 32
|
||||
printf("%s%-36.36s\t%-8lu\t(0x%lx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->meaning,
|
||||
(unsigned long)p->nmbr,
|
||||
(unsigned long)p->nmbr);
|
||||
#else
|
||||
# if defined(L64_FORMAT)
|
||||
/* %ld prints all 64 bits, use %ld */
|
||||
printf("%s%-36.36s\t%-8lu\t(0x%lx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->meaning,
|
||||
(unsigned long long)p->nmbr,
|
||||
(unsigned long long)p->nmbr);
|
||||
# else /* L64_FORMAT */
|
||||
/* %ld prints lower 32 bits only, use %lld */
|
||||
printf("%s%-36.36s\t%-8llu\t(0x%llx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->meaning,
|
||||
(unsigned long long)p->nmbr,
|
||||
(unsigned long long)p->nmbr);
|
||||
# endif /* L64_FORMAT */
|
||||
#endif
|
||||
} else {
|
||||
printf("%s%-36.36s\t\"%s\"\n",
|
||||
|
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: custtbl.c,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: custtbl.c,v 29.3 2004/07/29 08:37:53 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/custtbl.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 02:28:54
|
||||
@@ -56,6 +56,7 @@ extern VALUE c_devnull(char*, int, VALUE**);
|
||||
extern VALUE c_help(char*, int, VALUE**);
|
||||
extern VALUE c_sysinfo(char*, int, VALUE**);
|
||||
extern VALUE c_pzasusb8(char*, int, VALUE**);
|
||||
extern VALUE c_pmodm127(char*, int, VALUE**);
|
||||
|
||||
|
||||
#endif /* CUSTOM */
|
||||
@@ -108,6 +109,9 @@ CONST struct custom cust[] = {
|
||||
{ "pzasusb8", "print ZCALUE as USB8",
|
||||
0, 1, c_pzasusb8 },
|
||||
|
||||
{ "pmodm127", "calculate q mod 2^(2^127-1)",
|
||||
1, 1, c_pmodm127 },
|
||||
|
||||
|
||||
#endif /* CUSTOM */
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* halflen - determine the length of numeric value in HALFs
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2004 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,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: halflen.cal,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: halflen.cal,v 29.3 2004/03/31 05:03:02 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/halflen.cal,v $
|
||||
*
|
||||
* Under source code control: 1997/03/08 20:51:32
|
||||
@@ -34,11 +34,16 @@
|
||||
* NOTE: You must use a calc that was compiled with ALLOW_CUSTOM= -DCUSTOM
|
||||
* and run with a -C arg.
|
||||
*/
|
||||
if (config("compile_custom") == 0) {
|
||||
quit "calc compiled without -DCUSTOM";
|
||||
} else if (config("allow_custom") == 0) {
|
||||
quit "calc was run without the -D command line option";
|
||||
}
|
||||
|
||||
|
||||
define halflen(num)
|
||||
{
|
||||
local baseb = custom("sysinfo","BASEB"); /* bit len of a HALF */
|
||||
local baseb; /* bit len of a HALF */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -47,6 +52,11 @@ define halflen(num)
|
||||
return newerror("halflen only works on numeric values");
|
||||
}
|
||||
|
||||
/*
|
||||
* determine baseb
|
||||
*/
|
||||
baseb = custom("sysinfo","BASEB");
|
||||
|
||||
/*
|
||||
* determine the HALF length of a numeric value
|
||||
*/
|
||||
@@ -63,7 +73,3 @@ define halflen(num)
|
||||
return newerror("halflen only works on numeric values");
|
||||
}
|
||||
}
|
||||
|
||||
if (config("resource_debug") >= 0) {
|
||||
print "halflen(num) defined";
|
||||
}
|
||||
|
78
custom/pmodm127
Normal file
78
custom/pmodm127
Normal file
@@ -0,0 +1,78 @@
|
||||
NAME
|
||||
pmodm127 - calculate q mod 2^(2^127-1)
|
||||
|
||||
SYNOPSIS
|
||||
custom("pmodm127", q)
|
||||
|
||||
TYPES
|
||||
q int > 0
|
||||
|
||||
return int
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This custom function will return the value:
|
||||
|
||||
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:
|
||||
|
||||
pmod(2, 2^127-1, q)
|
||||
|
||||
The return value is integer in the half open range: [0, q).
|
||||
|
||||
SPECIAL NOTE:
|
||||
|
||||
Can you find a value, q, for which this custom function returns 1?
|
||||
If you do, send the value of q to chongo using the EMail address
|
||||
found at:
|
||||
|
||||
http://www.isthe.com/chongo/address.html
|
||||
|
||||
EXAMPLE
|
||||
> custom("pmodm127", 65537)
|
||||
32769
|
||||
|
||||
> custom("pmodm127", 2^31-1)
|
||||
8
|
||||
|
||||
> custom("pmodm127", 7^51+2)
|
||||
11228202966269457258557496419097462731193173
|
||||
|
||||
LIMITS
|
||||
calc must be built with ALLOW_CUSTOM= -DCUSTOM
|
||||
calc must be executed with a -C arg.
|
||||
q must be an integer > 0
|
||||
|
||||
LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
custom
|
||||
|
||||
## Copyright (C) 2004 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.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: pmodm127,v 29.2 2004/07/29 09:28:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/pmodm127,v $
|
||||
##
|
||||
## Under source code control: 2004/02/25 07:13:15
|
||||
## File existed as early as: 2004
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
137
custom/pmodm127.cal
Normal file
137
custom/pmodm127.cal
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* pmodm127 - test pmodm127's ability to calculate q mod 2^(2^127-1)
|
||||
*
|
||||
* Copyright (C) 2004 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.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: pmodm127.cal,v 29.2 2004/07/29 08:35:36 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/pmodm127.cal,v $
|
||||
*
|
||||
* Under source code control: 2004/02/25 14:25:32
|
||||
* File existed as early as: 2004
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the custom sample calc files.
|
||||
*
|
||||
* NOTE: You must use a calc that was compiled with ALLOW_CUSTOM= -DCUSTOM
|
||||
* and run with a -C arg.
|
||||
*/
|
||||
if (config("compile_custom") == 0) {
|
||||
quit "calc compiled without -DCUSTOM";
|
||||
} else if (config("allow_custom") == 0) {
|
||||
quit "calc was run without the -D command line option";
|
||||
}
|
||||
|
||||
|
||||
define pmodm127_test1(testcnt)
|
||||
{
|
||||
local q; /* test factor */
|
||||
local m127; /* 2^127-1 */
|
||||
local i;
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (!isint(testcnt) || testcnt <= 0) {
|
||||
return newerror("pmodm127_test1 must have an integer count>0");
|
||||
}
|
||||
|
||||
/*
|
||||
* perform testcnt divisor tests for primes of form 2*k*(2^127-1)+1
|
||||
*
|
||||
* NOTE: Since this is just a test, we do not need to be optimal.
|
||||
*/
|
||||
m127 = 2^127 - 1;
|
||||
q = 2*4949132165849*m127+1;
|
||||
for (i=0; i < testcnt; ++i) {
|
||||
|
||||
/*
|
||||
* determine next prime divisor
|
||||
*/
|
||||
q = nextcand(q, -1, 0, 1, 2*m127);
|
||||
|
||||
/* compare custom function with its pmod() equivalent */
|
||||
if (config("resource_debug") & 8) {
|
||||
print "testing", q;
|
||||
}
|
||||
if (pmod(2, m127, q) != custom("pmodm127", q)) {
|
||||
print "ERROR: pmodm127 failed for ", str(q);
|
||||
return newerror("pmodm127 failed for " + str(q));
|
||||
}
|
||||
}
|
||||
|
||||
/* return success count */
|
||||
if (config("resource_debug") & 8) {
|
||||
print "passed", testcnt, "tests";
|
||||
}
|
||||
return testcnt;
|
||||
}
|
||||
|
||||
define pmodm127_test2(testcnt, seed)
|
||||
{
|
||||
local q; /* test factor */
|
||||
local m127; /* 2^127-1 */
|
||||
local i;
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (!isint(testcnt) || testcnt <= 0) {
|
||||
return newerror("pmodm127_test2 must have an integer count>0");
|
||||
}
|
||||
if (!isint(seed)) {
|
||||
return newerror("pmodm127_test2 must an integer seed");
|
||||
}
|
||||
|
||||
/*
|
||||
* perform testcnt divisor tests random integers over [1e51, 1e52)
|
||||
*
|
||||
* NOTE: Since this is just a test, we do not need to be optimal.
|
||||
*/
|
||||
m127 = 2^127 - 1;
|
||||
for (i=0; i < testcnt; ++i) {
|
||||
|
||||
/*
|
||||
* determine next prime divisor
|
||||
*/
|
||||
q = rand(1e51, 1e52) | 0x1;
|
||||
if (config("resource_debug") & 8) {
|
||||
print "testing", q;
|
||||
}
|
||||
|
||||
/* compare custom function with its pmod() equivalent */
|
||||
if (pmod(2, m127, q) != custom("pmodm127", q)) {
|
||||
print "ERROR: pmodm127 failed for ", str(q);
|
||||
print "ERROR: ", pmod(2,m127,q), " != ", custom("pmodm127", q);
|
||||
return newerror("pmodm127 failed for " + str(q));
|
||||
}
|
||||
}
|
||||
|
||||
/* return success count */
|
||||
if (config("resource_debug") & 8) {
|
||||
print "passed", testcnt, "tests";
|
||||
}
|
||||
return testcnt;
|
||||
}
|
||||
|
||||
if ((config("resource_debug") & 3) && !(config("resource_debug") & 8)) {
|
||||
print "DEBUG: use config('resource_debug',", config("resource_debug")|8:") to enable more debugging";
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* pzasusb8 - print numereator as a string of USB8s
|
||||
*
|
||||
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
|
||||
* Copyright (C) 1999,2004 Ernest Bowen and Landon Curt Noll
|
||||
*
|
||||
* Primary author: Ernest Bowen
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: pzasusb8.cal,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: pzasusb8.cal,v 29.3 2004/03/31 05:03:02 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/pzasusb8.cal,v $
|
||||
*
|
||||
* Under source code control: 1999/10/06 03:11:12
|
||||
@@ -31,6 +31,15 @@
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (config("compile_custom") == 0) {
|
||||
quit "calc compiled without -DCUSTOM";
|
||||
} else if (config("allow_custom") == 0) {
|
||||
quit "calc was run without the -D command line option";
|
||||
}
|
||||
|
||||
print "p(n) prints array in which numerator of n is stored as a";
|
||||
print "sequence of 2-hex-digits representing unsigned characters.";
|
||||
print "h(n) printx n in hex notation. This should be the same as";
|
||||
@@ -52,6 +61,5 @@ print "CALC_BYTE_ORDER: ", custom("sysinfo", "CALC_BYTE_ORDER");
|
||||
print "BIG_ENDIAN: ", custom("sysinfo", "BIG_ENDIAN");
|
||||
print "LITTLE_ENDIAN: ", custom("sysinfo", "LITTLE_ENDIAN");
|
||||
print "LONG_BITS: ", custom("sysinfo", "LONG_BITS");
|
||||
print "LONGLONG_BITS: ", custom("sysinfo", "LONGLONG_BITS");
|
||||
print "Calc sizes:";
|
||||
show sizes;
|
||||
|
9
endian.c
9
endian.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: endian.c,v 29.3 2001/03/18 02:59:42 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: endian.c,v 29.4 2003/01/14 01:50:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/endian.c,v $
|
||||
*
|
||||
* Under source code control: 1993/11/15 04:32:58
|
||||
@@ -36,6 +36,11 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "have_stdlib.h"
|
||||
#if defined(HAVE_STDLIB_H)
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "have_unistd.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
|
8
file.c
8
file.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* file - file I/O routines callable by users
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Landon Curt Noll
|
||||
* Copyright (C) 1999-2004 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: file.c,v 29.7 2001/04/10 22:06:46 chongo Exp $
|
||||
* @(#) $Revision: 29.9 $
|
||||
* @(#) $Id: file.c,v 29.9 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/file.c,v $
|
||||
*
|
||||
* Under source code control: 1991/07/20 00:21:56
|
||||
@@ -810,7 +810,7 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
|
||||
VALUE *vp;
|
||||
char *str;
|
||||
int ch;
|
||||
unsigned long len;
|
||||
long len;
|
||||
int oldmode, newmode;
|
||||
long olddigits, newdigits;
|
||||
long width, precision;
|
||||
|
95
func.c
95
func.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* func - built-in functions implemented here
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
* Copyright (C) 1999-2004 David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.10 $
|
||||
* @(#) $Id: func.c,v 29.10 2001/05/29 00:41:22 chongo Exp $
|
||||
* @(#) $Revision: 29.15 $
|
||||
* @(#) $Id: func.c,v 29.15 2004/07/26 05:55:37 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/func.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:15
|
||||
@@ -84,6 +84,7 @@
|
||||
#endif
|
||||
|
||||
#include "have_const.h"
|
||||
#include "have_unused.h"
|
||||
#include "calc.h"
|
||||
#include "calcerr.h"
|
||||
#include "opcodes.h"
|
||||
@@ -107,7 +108,7 @@
|
||||
/*
|
||||
* forward declarations
|
||||
*/
|
||||
static NUMBER *base_value(long mode);
|
||||
static NUMBER *base_value(long mode, int defval);
|
||||
static int strscan(char *s, int count, VALUE **vals);
|
||||
static int filescan(FILEID id, int count, VALUE **vals);
|
||||
static VALUE f_eval(VALUE *vp);
|
||||
@@ -307,7 +308,7 @@ f_display(int count, VALUE **vals)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static VALUE
|
||||
f_null(int count, VALUE **vals)
|
||||
f_null(int UNUSED count, VALUE UNUSED **vals)
|
||||
{
|
||||
VALUE res;
|
||||
|
||||
@@ -4729,7 +4730,7 @@ f_list(int count, VALUE **vals)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static VALUE
|
||||
f_assoc(int count, VALUE **vals)
|
||||
f_assoc(int UNUSED count, VALUE UNUSED **vals)
|
||||
{
|
||||
VALUE result;
|
||||
|
||||
@@ -6910,9 +6911,9 @@ f_system(VALUE *vp)
|
||||
printf("%s\n", vp->v_str->s_str);
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
/* if the execute length is 0 then use NULL in system call */
|
||||
/* if the execute length is 0 then just return 0 */
|
||||
if (strlen(vp->v_str->s_str) == 0) {
|
||||
result.v_num = itoq((long)system(NULL));
|
||||
result.v_num = itoq((long)0);
|
||||
} else {
|
||||
result.v_num = itoq((long)system(vp->v_str->s_str));
|
||||
}
|
||||
@@ -6978,15 +6979,15 @@ f_base(int count, NUMBER **vals)
|
||||
|
||||
/* deal with just a query */
|
||||
if (count != 1) {
|
||||
return base_value(conf->outmode);
|
||||
return base_value(conf->outmode, conf->outmode);
|
||||
}
|
||||
|
||||
/* deal with the specal modes first */
|
||||
if (qisfrac(vals[0])) {
|
||||
return base_value(math_setmode(MODE_FRAC));
|
||||
return base_value(math_setmode(MODE_FRAC), conf->outmode);
|
||||
}
|
||||
if (vals[0]->num.len > 64/BASEB) {
|
||||
return base_value(math_setmode(MODE_EXP));
|
||||
return base_value(math_setmode(MODE_EXP), conf->outmode);
|
||||
}
|
||||
|
||||
/* set the base, if possible */
|
||||
@@ -7014,7 +7015,61 @@ f_base(int count, NUMBER **vals)
|
||||
}
|
||||
|
||||
/* return the old base */
|
||||
return base_value(oldbase);
|
||||
return base_value(oldbase, conf->outmode);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* set the default secondary output base/mode
|
||||
*/
|
||||
static NUMBER *
|
||||
f_base2(int count, NUMBER **vals)
|
||||
{
|
||||
long base; /* output base/mode */
|
||||
long oldbase=0; /* output base/mode */
|
||||
|
||||
/* deal with just a query */
|
||||
if (count != 1) {
|
||||
return base_value(conf->outmode2, conf->outmode2);
|
||||
}
|
||||
|
||||
/* deal with the specal modes first */
|
||||
if (qisfrac(vals[0])) {
|
||||
return base_value(math_setmode2(MODE_FRAC), conf->outmode2);
|
||||
}
|
||||
if (vals[0]->num.len > 64/BASEB) {
|
||||
return base_value(math_setmode2(MODE_EXP), conf->outmode2);
|
||||
}
|
||||
|
||||
/* set the base, if possible */
|
||||
base = qtoi(vals[0]);
|
||||
switch (base) {
|
||||
case 0:
|
||||
oldbase = math_setmode2(MODE2_OFF);
|
||||
break;
|
||||
case -10:
|
||||
oldbase = math_setmode2(MODE_INT);
|
||||
break;
|
||||
case 2:
|
||||
oldbase = math_setmode2(MODE_BINARY);
|
||||
break;
|
||||
case 8:
|
||||
oldbase = math_setmode2(MODE_OCTAL);
|
||||
break;
|
||||
case 10:
|
||||
oldbase = math_setmode2(MODE_REAL);
|
||||
break;
|
||||
case 16:
|
||||
oldbase = math_setmode2(MODE_HEX);
|
||||
break;
|
||||
default:
|
||||
math_error("Unsupported base");
|
||||
/*NOTREACHED*/
|
||||
break;
|
||||
}
|
||||
|
||||
/* return the old base */
|
||||
return base_value(oldbase, conf->outmode2);
|
||||
}
|
||||
|
||||
|
||||
@@ -7022,14 +7077,14 @@ f_base(int count, NUMBER **vals)
|
||||
* return a numerical 'value' of the mode/base
|
||||
*/
|
||||
static NUMBER *
|
||||
base_value(long mode)
|
||||
base_value(long mode, int defval)
|
||||
{
|
||||
NUMBER *result;
|
||||
|
||||
/* return the old base */
|
||||
switch (mode) {
|
||||
case MODE_DEFAULT:
|
||||
switch (conf->outmode) {
|
||||
switch (defval) {
|
||||
case MODE_DEFAULT:
|
||||
result = itoq(10);
|
||||
break;
|
||||
@@ -7056,6 +7111,9 @@ base_value(long mode)
|
||||
case MODE_BINARY:
|
||||
result = itoq(2);
|
||||
break;
|
||||
case MODE2_OFF:
|
||||
result = itoq(0);
|
||||
break;
|
||||
default:
|
||||
result = itoq(0);
|
||||
break;
|
||||
@@ -7084,6 +7142,9 @@ base_value(long mode)
|
||||
case MODE_BINARY:
|
||||
result = itoq(2);
|
||||
break;
|
||||
case MODE2_OFF:
|
||||
result = itoq(0);
|
||||
break;
|
||||
default:
|
||||
result = itoq(0);
|
||||
break;
|
||||
@@ -7825,6 +7886,8 @@ static CONST struct builtin builtins[] = {
|
||||
"arithmetic mean of values"},
|
||||
{"base", 0, 1, 0, OP_NOP, f_base, 0,
|
||||
"set default output base"},
|
||||
{"base2", 0, 1, 0, OP_NOP, f_base2, 0,
|
||||
"set default secondary output base"},
|
||||
{"bernoulli", 1, 1, 0, OP_NOP, 0, f_bern,
|
||||
"Bernoulli number for index a"},
|
||||
{"bit", 2, 2, 0, OP_BIT, 0, 0,
|
||||
@@ -7964,7 +8027,7 @@ static CONST struct builtin builtins[] = {
|
||||
{"free", 0, IN, FA, OP_NOP, 0, f_free,
|
||||
"free listed or all global variables"},
|
||||
{"freebernoulli", 0, 0, 0, OP_NOP, 0, f_freebern,
|
||||
"free stored Benoulli numbers"},
|
||||
"free stored Bernoulli numbers"},
|
||||
{"freeeuler", 0, 0, 0, OP_NOP, 0, f_freeeuler,
|
||||
"free stored Euler numbers"},
|
||||
{"freeglobals", 0, 0, 0, OP_NOP, 0, f_freeglobals,
|
||||
@@ -8282,7 +8345,7 @@ static CONST struct builtin builtins[] = {
|
||||
{"sizeof", 1, 1, 0, OP_NOP, 0, f_sizeof,
|
||||
"number of octets used to hold the value"},
|
||||
{"sleep", 0, 1, 0, OP_NOP, 0, f_sleep,
|
||||
"suspend operatioo for a seconds"},
|
||||
"suspend operation for a seconds"},
|
||||
{"sort", 1, 1, 0, OP_NOP, 0, f_sort,
|
||||
"sort a copy of a matrix or list"},
|
||||
{"sqrt", 1, 3, 0, OP_NOP, 0, f_sqrt,
|
||||
|
16
hash.c
16
hash.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* hash - one-way hash routines
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2002 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,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: hash.c,v 29.4 2001/04/14 22:47:21 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: hash.c,v 29.6 2004/02/25 23:55:38 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/hash.c,v $
|
||||
*
|
||||
* Under source code control: 1995/11/23 05:13:11
|
||||
@@ -941,6 +941,7 @@ hash_value(int type, void *v, HASH *state)
|
||||
|
||||
/* hash the CONFIG state */
|
||||
state = hash_int(type, value->v_config->outmode, state);
|
||||
state = hash_int(type, value->v_config->outmode2, state);
|
||||
state = hash_long(type,(long)value->v_config->outdigits, state);
|
||||
state = hash_number(type, value->v_config->epsilon, state);
|
||||
state = hash_long(type,
|
||||
@@ -984,6 +985,15 @@ hash_value(int type, void *v, HASH *state)
|
||||
state = hash_int(type, value->v_config->ctrl_d, state);
|
||||
state = hash_str(type, value->v_config->program, state);
|
||||
state = hash_str(type, value->v_config->base_name, state);
|
||||
state = hash_bool(type, value->v_config->windows, state);
|
||||
state = hash_bool(type, value->v_config->cygwin, state);
|
||||
state = hash_bool(type, value->v_config->compile_custom, state);
|
||||
if (value->v_config->allow_custom != NULL &&
|
||||
*(value->v_config->allow_custom)) {
|
||||
state = hash_bool(type, TRUE, state);
|
||||
} else {
|
||||
state = hash_bool(type, FALSE, state);
|
||||
}
|
||||
state = hash_str(type, value->v_config->version, state);
|
||||
break;
|
||||
|
||||
|
89
have_unused.c
Normal file
89
have_unused.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* have_unused - Determine if we want or can support the unused attribute
|
||||
*
|
||||
* Copyright (C) 2004 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.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: have_unused.c,v 29.2 2004/02/23 08:35:42 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/have_unused.c,v $
|
||||
*
|
||||
* Under source code control: 2004/02/22 22:36:10
|
||||
* File existed as early as: 2004
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* usage:
|
||||
* have_unused
|
||||
*
|
||||
* Not all compilers support the unused attribute, so this may not compile
|
||||
* on your system.
|
||||
*
|
||||
* This prog outputs several defines:
|
||||
*
|
||||
* HAVE_UNUSED
|
||||
* defined ==> ok to use unused
|
||||
* undefined ==> do not use unused
|
||||
*
|
||||
* UNUSED
|
||||
* unused ==> use unused
|
||||
* (nothing) ==> unused not used
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(HAVE_NO_UNUSED)
|
||||
|
||||
/* make sure that we can use the __attribute__((unused)) in #define's */
|
||||
#undef UNUSED
|
||||
#define UNUSED __attribute__((unused))
|
||||
|
||||
/*
|
||||
* unused_str - a function with an unused argument
|
||||
*/
|
||||
static char *
|
||||
unused_str(char UNUSED *str)
|
||||
{
|
||||
return "__attribute__((unused))";
|
||||
}
|
||||
|
||||
#endif /* !HAVE_NO_UNUSED */
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#if defined(HAVE_NO_UNUSED)
|
||||
|
||||
printf("#undef HAVE_UNUSED /* no */\n");
|
||||
printf("#undef UNUSED\n");
|
||||
printf("#define UNUSED /* no */\n");
|
||||
|
||||
#else /* HAVE_NO_UNUSED */
|
||||
|
||||
printf("#define HAVE_UNUSED /* yes */\n");
|
||||
printf("#undef UNUSED\n");
|
||||
printf("#define UNUSED %s /* yes */\n", unused_str(NULL));
|
||||
|
||||
#endif /* HAVE_NO_UNUSED */
|
||||
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
211
help/Makefile
211
help/Makefile
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# help - makefile for calc help files
|
||||
#
|
||||
# Copyright (C) 1999 Landon Curt Noll
|
||||
# Copyright (C) 1999-2002 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
|
||||
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.18 $
|
||||
# @(#) $Id: Makefile,v 29.18 2001/06/08 22:57:54 chongo Exp $
|
||||
# @(#) $Revision: 29.25 $
|
||||
# @(#) $Id: Makefile,v 29.25 2004/07/28 12:21:05 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1991/07/23 06:47:57
|
||||
@@ -36,33 +36,111 @@
|
||||
SHELL= /bin/sh
|
||||
MAKE_FILE = Makefile
|
||||
|
||||
# ${SHAREDIR} where most common shared files are kept
|
||||
# ${INCDIR} where most .h files are kept
|
||||
# ${LIBDIR} where *.a files are installed
|
||||
####
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
####
|
||||
|
||||
# Where the system include (.h) files are kept
|
||||
#
|
||||
# ${CSHAREDIR} where most common shared calc files are kept
|
||||
# ${HELPDIR} where the help directory is installed.
|
||||
# ${INCDIRCALC} where the calc include files are installed
|
||||
# For DJGPP, select:
|
||||
#
|
||||
# INCDIR= /dev/env/DJDIR/include
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# INCDIR= /usr/include
|
||||
#
|
||||
#SHAREDIR= /usr/local/lib
|
||||
SHAREDIR= /usr/share
|
||||
|
||||
#INCDIR= /usr/local/include
|
||||
#INCDIR= /dev/env/DJDIR/include
|
||||
INCDIR= /usr/include
|
||||
|
||||
# where to install calc realted things
|
||||
#
|
||||
# ${BINDIR} where to install calc binary files
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
# BINDIR= /dev/env/DJDIR/bin
|
||||
# LIBDIR= /dev/env/DJDIR/lib
|
||||
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# BINDIR= /usr/bin
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
#BINDIR= /usr/local/bin
|
||||
#BINDIR= /dev/env/DJDIR/bin
|
||||
BINDIR= /usr/bin
|
||||
|
||||
#LIBDIR= /usr/local/lib
|
||||
#LIBDIR= /dev/env/DJDIR/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
CSHAREDIR= ${SHAREDIR}/calc
|
||||
HELPDIR= ${CSHAREDIR}/help
|
||||
INCDIRCALC= ${INCDIR}/calc
|
||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
|
||||
# ---------------------------------------------------------------
|
||||
# ${HELPDIR} where the help directory is installed
|
||||
# ${CALC_INCDIR} where the calc include files are installed
|
||||
# ${CUSTOMCALDIR} where custom *.cal files are installed
|
||||
# ${CUSTOMHELPDIR} where custom help files are installed
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed
|
||||
# ${SCRIPTDIR} where calc shell scripts are installed
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# HELPDIR= ${CALC_SHAREDIR}/help
|
||||
# CALC_INCDIR= ${INCDIR}/calc
|
||||
# CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
||||
# CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
||||
# CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
||||
# SCRIPTDIR= ${BINDIR}/cscript
|
||||
#
|
||||
HELPDIR= ${CALC_SHAREDIR}/help
|
||||
CALC_INCDIR= ${INCDIR}/calc
|
||||
CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
||||
CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
||||
CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
||||
SCRIPTDIR= ${BINDIR}/cscript
|
||||
|
||||
# T - top level directory under which calc will be installed
|
||||
#
|
||||
# The calc install is performed under $T, the calc build is
|
||||
# performed under /. The purpose for $T is to allow someone to
|
||||
# install calc somewhere other than into the system area. For example
|
||||
# when forming the calc rpm, the Makefile is called with T=$RPM_BUILD_ROOT.
|
||||
# performed under /. The purpose for $T is to allow someone
|
||||
# to install calc somewhere other than into the system area.
|
||||
#
|
||||
# For example, if:
|
||||
#
|
||||
# BINDIR= /usr/bin
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
# and if:
|
||||
#
|
||||
# T= /var/tmp/testing
|
||||
#
|
||||
# Then the installation locations will be:
|
||||
#
|
||||
# calc binary files: /var/tmp/testing/usr/bin
|
||||
# calc link library: /var/tmp/testing/usr/lib
|
||||
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
# ... etc ... /var/tmp/testing/...
|
||||
#
|
||||
# If $T is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If $T is non-empty, then
|
||||
@@ -92,6 +170,19 @@ SORT= sort
|
||||
FMT= fmt
|
||||
CMP= cmp
|
||||
|
||||
# Some out of date operating systems require / want an executable to
|
||||
# end with a certain file extension. Some compile systems such as
|
||||
# Cygwin build calc as calc.exe. The EXT variable is used to denote
|
||||
# the extension required by such.
|
||||
#
|
||||
# EXT= # normal Un*x / Linux / GNU/Linux systems
|
||||
# EXT=.exe # windoz / Cygwin
|
||||
#
|
||||
# If in doubt, use EXT=
|
||||
#
|
||||
EXT=
|
||||
#EXT=.exe
|
||||
|
||||
# Standard and Builtin help files
|
||||
#
|
||||
STD_HELP_FILES_1= intro overview help
|
||||
@@ -168,12 +259,12 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
|
||||
# This list is prodiced by the detaillist rule when no WARNINGS are detected.
|
||||
#
|
||||
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 bernoulli bit blk blkcpy blkfree blocks bround btrunc calc_tty \
|
||||
calclevel catalan ceil cfappr cfsim char cmdbuf cmp comb conj cos \
|
||||
cosh cot coth count cp csc csch ctime delete den dereference det \
|
||||
digit digits dp epsilon errcount errmax errno error euler eval \
|
||||
exp fact factor fclose fcnt feof ferror fflush fgetc fgetfield \
|
||||
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 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 euler \
|
||||
eval exp fact factor fclose fcnt feof ferror fflush fgetc fgetfield \
|
||||
fgetline fgets fgetstr fib files floor fopen forall fprintf fputc \
|
||||
fputs fputstr frac free freebernoulli freeeuler freeglobals freeredc \
|
||||
freestatics frem freopen fscan fscanf fseek fsize ftell gcd gcdrem \
|
||||
@@ -267,7 +358,7 @@ changes: ../CHANGES
|
||||
libcalc: ../LIBRARY
|
||||
rm -f $@
|
||||
${SED} -e 's:$${LIBDIR}:${LIBDIR}:g' \
|
||||
-e 's:$${INCDIRCALC}:${INCDIRCALC}:g' < ../LIBRARY > $@
|
||||
-e 's:$${CALC_INCDIR}:${CALC_INCDIR}:g' < ../LIBRARY > $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
@@ -418,11 +509,13 @@ full: ${FULL_HELP_FILES} ${MAKE_FILE}
|
||||
# Singular files are the same files as their plural form.
|
||||
#
|
||||
${SINGULAR_FILES}: ${PLURAL_FILES}
|
||||
${Q}for i in ${SINGULAR_FILES}; do \
|
||||
echo "rm -f $${i}"; \
|
||||
rm -f $${i}; \
|
||||
echo "cp $${i}s $${i}"; \
|
||||
cp $${i}s $${i}; \
|
||||
${Q}for i in ${SINGULAR_FILES} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo "rm -f $${i}"; \
|
||||
rm -f $${i}; \
|
||||
echo "cp $${i}s $${i}"; \
|
||||
cp $${i}s $${i}; \
|
||||
fi; \
|
||||
done
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
@@ -454,12 +547,13 @@ builtin: builtin.top builtin.end ../func.c funclist.sed
|
||||
${Q}echo "forming builtin help file"
|
||||
-${Q}rm -f funclist.c
|
||||
${Q}${SED} -n -f funclist.sed ../func.c > funclist.c
|
||||
-${Q}rm -f funclist.o funclist
|
||||
${Q}${LCC} ${ICFLAGS} -DFUNCLIST -I/usr/include -I.. funclist.c -c
|
||||
${Q}${LCC} ${ILDFLAGS} funclist.o -o funclist
|
||||
-${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}
|
||||
-${Q}rm -f builtin
|
||||
${Q}cat builtin.top > builtin
|
||||
${Q}./funclist | \
|
||||
${Q}./funclist${EXT} | \
|
||||
${SED} -e 's/^/ /' -e 's/[ ][ ]*$$//' >> builtin
|
||||
${Q}cat builtin.end >> builtin
|
||||
${Q}echo "builtin help file formed"
|
||||
@@ -482,8 +576,10 @@ builtin: builtin.top builtin.end ../func.c funclist.sed
|
||||
##
|
||||
|
||||
distlist: ${DISTLIST}
|
||||
${Q}for i in ${DISTLIST}; do \
|
||||
${Q}for i in ${DISTLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo help/$$i; \
|
||||
fi; \
|
||||
done | LANG=C ${SORT}
|
||||
|
||||
distdir:
|
||||
@@ -508,12 +604,14 @@ bsdi: all
|
||||
#
|
||||
detaillist:
|
||||
${Q}-(echo "xxxxx"; \
|
||||
for i in ${DETAIL_HELP}; do \
|
||||
for i in ${DETAIL_HELP} /dev/null; 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 | LANG=C ${SORT}) | ${FMT} -70 | \
|
||||
${SED} -e '1s/xxxxx/DETAIL_HELP=/' -e '2,$$s/^/ /' \
|
||||
-e 's/$$/ \\/' -e '$$s/ \\$$//'
|
||||
@@ -526,8 +624,10 @@ detaillist:
|
||||
|
||||
echo_inst_files:
|
||||
${Q}for i in ${STD_HELP_FILES} full ${BLT_HELP_FILES} \
|
||||
builtin ${DETAIL_HELP} ${SINGULAR_FILES}; do \
|
||||
echo __file__ ${HELPDIR}/$$i; \
|
||||
builtin ${DETAIL_HELP} ${SINGULAR_FILES} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${HELPDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
${Q}echo __file__ ${HELPDIR}/obj
|
||||
|
||||
@@ -538,37 +638,25 @@ echo_inst_files:
|
||||
##
|
||||
|
||||
clean:
|
||||
rm -f obj mkbuiltin funclist.c funclist.o funclist
|
||||
rm -f obj mkbuiltin funclist.c funclist.o funclist${EXT}
|
||||
rm -f COPYING COPYING-LGPL
|
||||
|
||||
clobber:
|
||||
rm -f ${BLT_HELP_FILES} full .all calc
|
||||
rm -f obj mkbuiltin funclist.c funclist.o funclist
|
||||
rm -f obj mkbuiltin funclist.c funclist.o funclist${EXT}
|
||||
rm -f COPYING COPYING-LGPL
|
||||
rm -f ${SINGULAR_FILES} ${DETAIL_CLONE}
|
||||
|
||||
install: all
|
||||
-${Q}if [ ! -d ${SHAREDIR} ]; then \
|
||||
echo mkdir $T${SHAREDIR}; \
|
||||
mkdir $T${SHAREDIR}; \
|
||||
if [ ! -d "$T${SHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${SHAREDIR}"; \
|
||||
mkdir -p "$T${SHAREDIR}"; \
|
||||
-${Q}if [ ! -d $T${CALC_SHAREDIR} ]; then \
|
||||
echo mkdir $T${CALC_SHAREDIR}; \
|
||||
mkdir $T${CALC_SHAREDIR}; \
|
||||
if [ ! -d "$T${CALC_SHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${SHAREDIR}; \
|
||||
${CHMOD} 0755 $T${SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${CSHAREDIR} ]; then \
|
||||
echo mkdir $T${CSHAREDIR}; \
|
||||
mkdir $T${CSHAREDIR}; \
|
||||
if [ ! -d "$T${CSHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${CSHAREDIR}"; \
|
||||
mkdir -p "$T${CSHAREDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CSHAREDIR}; \
|
||||
${CHMOD} 0755 $T${CSHAREDIR}; \
|
||||
echo ${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@@ -585,7 +673,10 @@ install: all
|
||||
true; \
|
||||
fi
|
||||
-${Q}for i in ${STD_HELP_FILES} ${BLT_HELP_FILES} builtin \
|
||||
full ${DETAIL_HELP} ${SINGULAR_FILES}; do \
|
||||
full ${DETAIL_HELP} ${SINGULAR_FILES} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s $$i $T${HELPDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
|
14
help/address
14
help/address
@@ -23,7 +23,7 @@ DESCRIPTION
|
||||
0 <= i < sizeof(B). &B[i] then returns the address at which this
|
||||
octet is located until the block is freed or relocated. Freeing
|
||||
of an unnamed block B occurs when a new value is assigned to B or
|
||||
when B ceases to exist; a named block B is freed by blkfree(B().
|
||||
when B ceases to exist; a named block B is freed by blkfree(B).
|
||||
A block is relocated when an operation like copying to B requires
|
||||
a change of sizeof(B).
|
||||
|
||||
@@ -70,18 +70,18 @@ DESCRIPTION
|
||||
> p = &"abc"
|
||||
> A = "abc"
|
||||
|
||||
The address &*A of the value of A will be equal to p.
|
||||
the address &*A of the value of A will be equal to p.
|
||||
|
||||
Except in cases like strcat(A, "") when *A identified with a literal
|
||||
string as above, definitions of string values using strcat() or substr()
|
||||
will copy the relevant strings to newly allocated addresses which will
|
||||
be useable only while the variables retain these defined values.
|
||||
For example,
|
||||
For example, after
|
||||
|
||||
> B = C = strcat("a", "bc");
|
||||
|
||||
&*B and &*C will be different. If p is defined by p = &*B, p should
|
||||
not be used after a mew value is assigned to B, or B ceases to exist,
|
||||
not be used after a new value is assigned to B, or B ceases to exist,
|
||||
etc.
|
||||
|
||||
When compilation of a function encounters for the first time a particular
|
||||
@@ -117,7 +117,7 @@ DESCRIPTION
|
||||
|
||||
> A = B = C = f(2);
|
||||
|
||||
which, not only performs the addition n f() only once, but stores the
|
||||
which, not only performs the addition in f() only once, but stores the
|
||||
number values for A, B and C at the same address.
|
||||
|
||||
Whether a value V is a pointer and if so, its type, is indicated by the
|
||||
@@ -176,8 +176,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: address,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: address,v 29.3 2002/07/10 11:47:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/address,v $
|
||||
##
|
||||
## Under source code control: 1997/09/06 20:03:34
|
||||
|
@@ -13,7 +13,7 @@ TYPES
|
||||
DESCRIPTION
|
||||
p->X returns the same as (*p).X. Thus the current value of *p is
|
||||
to be an object of a type for which X identifies one element.
|
||||
p->X then returns the lvalue corresponding to that element of of the
|
||||
p->X then returns the lvalue corresponding to that element of the
|
||||
value of *p.
|
||||
|
||||
The expression *p.X will cause a runtime error since this is
|
||||
@@ -66,8 +66,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: arrow,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: arrow,v 29.3 2002/07/10 11:47:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/arrow,v $
|
||||
##
|
||||
## Under source code control: 1997/09/06 20:03:34
|
||||
|
@@ -14,7 +14,7 @@ DESCRIPTION
|
||||
Returns the asin of x to a multiple of eps with error less in
|
||||
absolute value than .75 * eps.
|
||||
|
||||
v = asin(x) is the number in [-p1/2, pi/2] for which sin(v) = x.
|
||||
v = asin(x) is the number in [-pi/2, pi/2] for which sin(v) = x.
|
||||
|
||||
EXAMPLE
|
||||
> print asin(.5, 1e-5), asin(.5, 1e-10), asin(.5, 1e-15), asin(.5, 1e-20)
|
||||
@@ -45,8 +45,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: asin,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: asin,v 29.3 2002/07/10 11:47:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/asin,v $
|
||||
##
|
||||
## Under source code control: 1994/03/19 01:40:24
|
||||
|
11
help/assoc
11
help/assoc
@@ -32,10 +32,9 @@ DESCRIPTION
|
||||
may have different numbers (between 1 and 4 inclusive) of indices,
|
||||
and these indices need not be integers in specified ranges.
|
||||
|
||||
Assignments of a null value
|
||||
to an element of an association does not delete the element, but
|
||||
a later reference to that element will return the null value as if
|
||||
the element is undefined.
|
||||
Assignment of a null value to an element of an association does not
|
||||
delete the element, but a later reference to that element will return
|
||||
the null value as if the element is undefined.
|
||||
|
||||
The elements of an association are stored in a hash table for
|
||||
quick access. The index values are hashed to select the correct
|
||||
@@ -99,8 +98,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: assoc,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: assoc,v 29.3 2002/07/10 11:47:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/assoc,v $
|
||||
##
|
||||
## Under source code control: 1994/09/25 20:22:31
|
||||
|
@@ -14,7 +14,7 @@ DESCRIPTION
|
||||
Returns the atan of x to a multiple of eps with error less in
|
||||
absolute value than .75 * eps.
|
||||
|
||||
v = atan(x) is the number in (-p1/2, pi/2) for which tan(v) = x.
|
||||
v = atan(x) is the number in (-pi/2, pi/2) for which tan(v) = x.
|
||||
|
||||
EXAMPLE
|
||||
> print atan(2, 1e-5), atan(2, 1e-10), atan(2, 1e-15), atan(2, 1e-20)
|
||||
@@ -45,8 +45,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: atan,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: atan,v 29.3 2002/07/10 11:47:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/atan,v $
|
||||
##
|
||||
## Under source code control: 1994/03/19 01:40:25
|
||||
|
@@ -57,7 +57,7 @@ DESCRIPTION
|
||||
base(1e20) base(2^64) base(2^8191-1)
|
||||
|
||||
However the base() function will only return one of the base values
|
||||
lised in the table above.
|
||||
listed in the table above.
|
||||
|
||||
EXAMPLE
|
||||
> base()
|
||||
@@ -79,7 +79,7 @@ LINK LIBRARY
|
||||
MODE_REAL, MODE_EXP, MODE_HEX, MODE_OCTAL, MODE_BINARY
|
||||
|
||||
SEE ALSO
|
||||
config
|
||||
base2, config, str
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
##
|
||||
@@ -97,8 +97,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: base,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.5 $
|
||||
## @(#) $Id: base,v 29.5 2002/12/29 09:17:54 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/base,v $
|
||||
##
|
||||
## Under source code control: 1994/09/30 00:09:39
|
||||
|
120
help/base2
Normal file
120
help/base2
Normal file
@@ -0,0 +1,120 @@
|
||||
NAME
|
||||
base2 - set 2nd output base
|
||||
|
||||
SYNOPSIS
|
||||
base2([mode])
|
||||
|
||||
TYPES
|
||||
mode real
|
||||
|
||||
return real
|
||||
|
||||
DESCRIPTION
|
||||
By default, calc will output values according to the default base
|
||||
as controlled by the base() builtin function.
|
||||
|
||||
The base2() builtin function, if given a non-zero argument, enables
|
||||
double base output mode. In double base output mode, calc values
|
||||
are displayed twice, once according to base() and again according
|
||||
to base2(). In double base output mode, the second time a value is
|
||||
displayed, it is displayed within comments:
|
||||
|
||||
21701 /* 0x54c5 */
|
||||
|
||||
The arguments for base2() are identical to base() with the addition
|
||||
of the 0 value:
|
||||
|
||||
base2 equivalent
|
||||
config("mode2")'s
|
||||
|
||||
2 "binary" base 2 fractions
|
||||
"bin"
|
||||
|
||||
8 "octal" base 8 fractions
|
||||
"oct"
|
||||
|
||||
10 "real" base 10 floating point
|
||||
"float"
|
||||
"default"
|
||||
|
||||
-10 "integer" base 10 integers
|
||||
"int"
|
||||
|
||||
16 "hexadecimal" base 16 fractions
|
||||
"hex"
|
||||
|
||||
1/3 "fraction" base 10 fractions
|
||||
"frac"
|
||||
|
||||
1e20 "scientific" base 10 scientific notation
|
||||
"sci"
|
||||
"exp"
|
||||
|
||||
0 "off" disable double base output
|
||||
|
||||
For convenience, any non-integer non-zero value is assumed to mean
|
||||
base 10 fractions and any integer >= 2^64 is assumed to mean base 10
|
||||
scientific notation.
|
||||
|
||||
These base2() calls have the same meaning as config("mode2", "fraction"):
|
||||
|
||||
base2(1/3) base2(0.1415) base2(16/37)
|
||||
|
||||
These base2() calls have the same meaning as config("mode2", "scientific"):
|
||||
|
||||
base2(1e20) base2(2^64) base2(2^8191-1)
|
||||
|
||||
However the base2() function will only return one of the base values
|
||||
listed in the table above.
|
||||
|
||||
EXAMPLE
|
||||
> base2()
|
||||
0
|
||||
> base2(8)
|
||||
0 /* 0 */
|
||||
> print 10
|
||||
10 /* 012 */
|
||||
> base2(16),
|
||||
> 131072
|
||||
131072 /* 0x20000 */
|
||||
> 2345
|
||||
2345 /* 0x929 */
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
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,
|
||||
MODE2_OFF
|
||||
|
||||
SEE ALSO
|
||||
base, config, str
|
||||
|
||||
## Copyright (C) 2002 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.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 1.3 $
|
||||
## @(#) $Id: base2,v 1.3 2002/12/29 09:17:54 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/base2,v $
|
||||
##
|
||||
## Under source code control: 2002/12/29 00:21:07
|
||||
## File existed as early as: 2002
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
@@ -15,7 +15,7 @@ DESCRIPTION
|
||||
|
||||
t/(exp(t) - 1) = Sum B_n * t^n/n!
|
||||
|
||||
bernouuli(n) is zero both for n < 0 and for n odd and > 2.
|
||||
bernoulli(n) is zero both for n < 0 and for n odd and > 2.
|
||||
When bernoulli(n) is computed for positive even n, the values for
|
||||
n and smaller positive even indices are stored in a table so that
|
||||
a later call to bernoulli(k) with 0 <= k < n will be executed quickly.
|
||||
@@ -57,8 +57,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: bernoulli,v 29.4 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Revision: 29.5 $
|
||||
## @(#) $Id: bernoulli,v 29.5 2002/07/10 11:47:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/bernoulli,v $
|
||||
##
|
||||
## Under source code control: 2000/07/13 01:33:00
|
||||
|
6
help/blk
6
help/blk
@@ -122,7 +122,7 @@ DESCRIPTION
|
||||
Named blocks are assigned index numbers 0, 1, 2, ..., in the order
|
||||
of their creation. The block with index id is returned by blocks(id).
|
||||
With no argument, blocks() returns the number of current unfreed
|
||||
named blocks. A named block may be used
|
||||
named blocks.
|
||||
|
||||
The memory allocated to a named block is freed by the blkfree()
|
||||
function with argument the named block, its name, or its id number.
|
||||
@@ -234,8 +234,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: blk,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: blk,v 29.3 2002/07/10 11:47:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/blk,v $
|
||||
##
|
||||
## Under source code control: 1997/04/05 13:07:13
|
||||
|
@@ -1,5 +1,5 @@
|
||||
NAME
|
||||
blocks - return a named file or number of unfreed named blocks
|
||||
blocks - return a named block or number of unfreed named blocks
|
||||
|
||||
SYNOPSIS
|
||||
blocks([id])
|
||||
@@ -58,8 +58,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: blocks,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: blocks,v 29.3 2002/07/10 11:47:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/blocks,v $
|
||||
##
|
||||
## Under source code control: 1997/04/05 13:07:13
|
||||
|
67
help/config
67
help/config
@@ -16,6 +16,7 @@ Configuration parameters
|
||||
"epsilon" sets error value for transcendentals.
|
||||
"maxprint" sets maximum number of elements printed.
|
||||
"mode" sets printout mode.
|
||||
"mode2" sets 2nd base printout mode.
|
||||
"mul2" sets size for alternative multiply.
|
||||
"sq2" sets size for alternative squaring.
|
||||
"pow2" sets size for alternate powering.
|
||||
@@ -48,6 +49,9 @@ Configuration parameters
|
||||
"program" Read-only calc program or shell script path
|
||||
"basename" Read-only basename of the program value
|
||||
"windows" Read-only indicator of MS windows
|
||||
"cygwin" TRUE=>calc compiled with cygwin, Read-only
|
||||
"compile_custom" TRUE=>calc was compiled with custom functions
|
||||
"allow_custom" TRUE=>custom functions are enabled
|
||||
"version" Read-only calc version
|
||||
|
||||
The "all" config value allows one to save/restore the configuration
|
||||
@@ -184,6 +188,7 @@ Detailed config descriptions
|
||||
=-=
|
||||
|
||||
config("mode", "mode_string")
|
||||
config("mode2", "mode_string")
|
||||
|
||||
The "mode" parameter is a string specifying the mode for printing of
|
||||
numbers by the unformatted print functions, and the default
|
||||
@@ -219,7 +224,17 @@ Detailed config descriptions
|
||||
Where multiple strings are given, the first string listed is what
|
||||
config("mode") will return.
|
||||
|
||||
The default "mode" is "real".
|
||||
The "mode2" controls the double base output. When set to a value
|
||||
other than "off", calc outputs files in both the "base" mode as
|
||||
well as the "base2" mode. The "mode2" value may be any of the
|
||||
"mode" values with the addition of:
|
||||
|
||||
"off" disable 2nd base output mode base2(0)
|
||||
|
||||
The base() builtin function sets and returns the "mode" value.
|
||||
The base2() builtin function sets and returns the "mode2" value.
|
||||
|
||||
The default "mode" is "real". The default "mode2" is "off".
|
||||
|
||||
=-=
|
||||
|
||||
@@ -540,7 +555,7 @@ Detailed config descriptions
|
||||
is displayed.
|
||||
|
||||
2 Show func will display more information about a functions
|
||||
arguments as well as more argument sdummary information.
|
||||
arguments and argument summary information.
|
||||
|
||||
3 During execution, allow calc standard resource files
|
||||
to output additional debugging information.
|
||||
@@ -687,6 +702,50 @@ Detailed config descriptions
|
||||
Returns TRUE if you are running on a MS windows system, false if you
|
||||
are running on an operating system that does not hate you.
|
||||
|
||||
This config parameter is read-only and cannot be set.
|
||||
|
||||
=-=
|
||||
|
||||
config("cygwin") <== NOTE: This is a read-only config value
|
||||
|
||||
Returns TRUE if you calc was compiled with cygwin, false otherwise.
|
||||
|
||||
This config parameter is read-only and cannot be set.
|
||||
|
||||
=-=
|
||||
|
||||
config("compile_custom") <== NOTE: This is a read-only config value
|
||||
|
||||
Returns TRUE if you calc was compiled with -DCUSTOM. By default,
|
||||
the calc Makefile uses ALLOW_CUSTOM= -DCUSTOM so by default
|
||||
config("compile_custom") is TRUE. If, however, calc is compiled
|
||||
without -DCUSTOM, then config("compile_custom") will be FALSE.
|
||||
|
||||
The config("compile_custom") value is only affected by compile
|
||||
flags. The calc -D runtime command line option does not change
|
||||
the config("compile_custom") value.
|
||||
|
||||
See also config("allow_custom").
|
||||
|
||||
This config parameter is read-only and cannot be set.
|
||||
|
||||
=-=
|
||||
|
||||
config("allow_custom") <== NOTE: This is a read-only config value
|
||||
|
||||
Returns TRUE if you custom functions are enabled. To allow the use
|
||||
of custom functions, calc must be compiled with -DCUSTOM (which it
|
||||
is by default) AND calc run be run with the -D runtime command line
|
||||
option (which it is not by default).
|
||||
|
||||
If config("allow_custom") is TRUE, then custom functions are allowed.
|
||||
If config("allow_custom") is FALSE, then custom functions are not
|
||||
allowed.
|
||||
|
||||
See also config("compile_custom").
|
||||
|
||||
This config parameter is read-only and cannot be set.
|
||||
|
||||
=-=
|
||||
|
||||
config("version") <== NOTE: This is a read-only config value
|
||||
@@ -713,8 +772,8 @@ Detailed config descriptions
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.6 $
|
||||
## @(#) $Id: config,v 29.6 2001/04/25 07:17:38 chongo Exp $
|
||||
## @(#) $Revision: 29.10 $
|
||||
## @(#) $Id: config,v 29.10 2004/07/27 23:45:52 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/config,v $
|
||||
##
|
||||
## Under source code control: 1991/07/21 04:37:17
|
||||
|
40
help/digits
40
help/digits
@@ -11,20 +11,38 @@ TYPES
|
||||
return integer
|
||||
|
||||
DESCRIPTION
|
||||
Returns the least non-negative integer n for which abs(x) < b^n.
|
||||
Returns number of digits in the standard base-b representation
|
||||
when x is truncated to an integer and the sign is ignored.
|
||||
|
||||
digits(x, b) = 0 if and only if abs(x) < 1.
|
||||
To be more precise: when abs(int(x)) > 0, this function returns
|
||||
the value 1 + ilog(x, b). When abs(int(x)) == 0, then this
|
||||
function returns the value 1.
|
||||
|
||||
For real x with absolute value >= 1, digits(x, b) is the number
|
||||
of digits in the standard base-b "decimal" representation of int(abs(x));
|
||||
this is also given by 1 + ilog(x, b).
|
||||
If omitted, b is assumed to be 10. If given, b must be an
|
||||
integer > 1.
|
||||
|
||||
One should remember these special cases:
|
||||
|
||||
digits(12.3456) == 2 computes with the integer part only
|
||||
digits(-1234) == 4 computes with the absolute value only
|
||||
digits(0) == 1 specical case
|
||||
digits(-0.123) == 1 combination of all of the above
|
||||
|
||||
EXAMPLE
|
||||
> print digits(0), digits(0.0123), digits(3.7), digits(-27), digits(-99.7)
|
||||
0 0 1 2 2
|
||||
> print digits(100), digits(23209), digits(2^72)
|
||||
3 5 22
|
||||
|
||||
> print digits(0), digits(1), digits(-1)
|
||||
1 1 1
|
||||
|
||||
> print digits(-1234), digits(12.3456), digits(107.207)
|
||||
4 2 3
|
||||
|
||||
> print digits(17^463-1, 17), digits(10000, 100), digits(21701, 2)
|
||||
3, 15 14
|
||||
|
||||
LIMITS
|
||||
none
|
||||
b > 1
|
||||
|
||||
LINK LIBRARY
|
||||
long qdigits(NUMBER *q, ZVALUE base)
|
||||
@@ -32,7 +50,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
digit, places
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
## Copyright (C) 1999-2003 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -48,8 +66,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: digits,v 29.3 2000/12/14 10:32:24 chongo Exp $
|
||||
## @(#) $Revision: 29.5 $
|
||||
## @(#) $Id: digits,v 29.5 2003/01/26 19:41:35 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/digits,v $
|
||||
##
|
||||
## Under source code control: 1995/10/03 10:40:01
|
||||
|
81
help/display
Normal file
81
help/display
Normal file
@@ -0,0 +1,81 @@
|
||||
NAME
|
||||
display - set and/or return decimal digits for displaying numbers
|
||||
|
||||
SYNOPSIS
|
||||
display([d])
|
||||
|
||||
TYPES
|
||||
d integer >= 0
|
||||
|
||||
return integer
|
||||
|
||||
DESCRIPTION
|
||||
When given an argument, this function sets 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
|
||||
formatted printing (printf, strprintf, fprintf) when precision is
|
||||
not specified. The return value is the previous display digit value.
|
||||
|
||||
When given no arguments, this function returns the current
|
||||
display digit value.
|
||||
|
||||
The builtin function:
|
||||
|
||||
display(d)
|
||||
display()
|
||||
|
||||
is an alias for:
|
||||
|
||||
config("display", d)
|
||||
config("display")
|
||||
|
||||
The display digit value does not change the stored value of a number.
|
||||
It only changes how a stored value is displayed.
|
||||
|
||||
Where rounding is necessary to display up to d decimal places,
|
||||
the type of rounding to be used is controlled by config("outround").
|
||||
|
||||
EXAMPLE
|
||||
> print display(), 2/3
|
||||
20 ~0.66666666666666666667
|
||||
|
||||
> print display(40), 2/3
|
||||
20 ~0.6666666666666666666666666666666666666667
|
||||
|
||||
> print display(5), 2/3
|
||||
40 ~0.66667
|
||||
|
||||
LIMITS
|
||||
d >= 0
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
config
|
||||
|
||||
## Copyright (C) 2004 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.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: display,v 29.1 2004/07/26 06:54:41 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/display,v $
|
||||
##
|
||||
## Under source code control: 2004/07/25 23:50:40
|
||||
## File existed as early as: 2004
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
@@ -9,11 +9,11 @@ Environment variables
|
||||
If this variable does not exist, a compiled value
|
||||
is used. Typically compiled in value is:
|
||||
|
||||
.:./cal:~/cal:${LIBDIR}/calc:${LIBDIR}/custom
|
||||
.:./cal:~/cal:${CALC_SHAREDIR}:${CUSTOMCALDIR}
|
||||
|
||||
where ${LIBDIR} is usually:
|
||||
which is usually:
|
||||
|
||||
/usr/local/lib/calc
|
||||
.:./cal:~/cal:/usr/share/calc:/usr/share/calc/custom
|
||||
|
||||
This value is used by the READ command. It is an error
|
||||
if no such readable file is found.
|
||||
@@ -30,11 +30,11 @@ Environment variables
|
||||
If this variable does not exist, a compiled value
|
||||
is used. Typically compiled in value is:
|
||||
|
||||
${LIBDIR}/startup:~/.calcrc
|
||||
${CALC_SHAREDIR}/startup:~/.calcrc:./.calcinit
|
||||
|
||||
where ${LIBDIR} is usually:
|
||||
which is usually:
|
||||
|
||||
/usr/local/lib/calc
|
||||
/usr/share/calc/startup:~/.calcrc:./.calcinit
|
||||
|
||||
Missing files along the $CALCRC path are silently ignored.
|
||||
|
||||
@@ -104,8 +104,8 @@ Environment variables
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: environment,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: environment,v 29.3 2004/07/26 07:10:43 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/environment,v $
|
||||
##
|
||||
## Under source code control: 1991/07/23 05:47:25
|
||||
|
@@ -1,5 +1,5 @@
|
||||
NAME
|
||||
freebernoulli - free stored Benoulli numbers
|
||||
freebernoulli - free stored Bernoulli numbers
|
||||
|
||||
SYNOPSIS
|
||||
freebernoulli()
|
||||
@@ -39,8 +39,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: freebernoulli,v 29.2 2000/07/17 15:36:26 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: freebernoulli,v 29.3 2004/07/26 05:54:00 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/freebernoulli,v $
|
||||
##
|
||||
## Under source code control: 2000/07/13
|
||||
|
31
help/hash
31
help/hash
@@ -1,5 +1,5 @@
|
||||
NAME
|
||||
hash - FNV-1 hash value
|
||||
hash - return the calc hash value
|
||||
|
||||
SYNOPSIS
|
||||
hash(x_1 [, x_2, x_3, ...])
|
||||
@@ -12,27 +12,16 @@ TYPES
|
||||
DESCRIPTION
|
||||
Returns a hash value for one or more values of arbitrary types.
|
||||
|
||||
The basis of this hash algorithm was taken from an idea sent
|
||||
as reviewer comments to the IEEE POSIX P1003.2 committee by:
|
||||
The calc hash value is based on the core Fowler/Noll/Vo hash
|
||||
known as FNV-1. The return value, however, cannot be used
|
||||
as an FNV hash value because calc's internal function also
|
||||
takes into account more abstract concepts such as data types.
|
||||
|
||||
Phong Vo (http://www.research.att.com/info/kpv/)
|
||||
Glenn Fowler (http://www.research.att.com/~gsf/)
|
||||
|
||||
In a subsequent ballot round:
|
||||
|
||||
Landon Curt Noll (http://www.isthe.com/chongo/)
|
||||
|
||||
improved on their algorithm. Some people tried this hash
|
||||
and found that it worked rather well. In an EMail message
|
||||
to Landon, they named it ``Fowler/Noll/Vo'' or the FNV hash.
|
||||
|
||||
FNV hashes are architected to be fast while maintaining a low
|
||||
collision rate. The FNV speed allows one to quickly hash lots
|
||||
of data while maintaining a reasonable collision rate. See:
|
||||
See:
|
||||
|
||||
http://www.isthe.com/chongo/tech/comp/fnv/
|
||||
|
||||
for more details as well as other forms of the FNV hash.
|
||||
information about the Fowler/Noll/Vo (FNV) hash.
|
||||
|
||||
EXAMPLE
|
||||
> a = isqrt(2e1000); s = "xyz";
|
||||
@@ -48,7 +37,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
sha, sha1, md5
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
## Copyright (C) 1999-2003 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
|
||||
@@ -64,8 +53,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: hash,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: hash,v 29.3 2003/03/01 01:16:02 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/hash,v $
|
||||
##
|
||||
## Under source code control: 1996/03/12 23:10:01
|
||||
|
6
help/im
6
help/im
@@ -20,7 +20,7 @@ LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
COMPLEX *cimag(COMPLEX *x)
|
||||
COMPLEX *c_imag(COMPLEX *x)
|
||||
|
||||
SEE ALSO
|
||||
re
|
||||
@@ -41,8 +41,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: im,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: im,v 29.3 2002/03/12 09:38:26 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/im,v $
|
||||
##
|
||||
## Under source code control: 1995/10/05 04:52:26
|
||||
|
11
help/places
11
help/places
@@ -16,6 +16,9 @@ DESCRIPTION
|
||||
|
||||
places(x,b) = 0 if and only if x is an integer.
|
||||
|
||||
If omitted, b is assumed to be 10. If given, b must be an
|
||||
integer > 1.
|
||||
|
||||
places(x,b) = n > 0 if and only if the fractional part of abs(x)
|
||||
has a finite base-b "decimal" representation with n digits of which
|
||||
the last digit is nonzero. This occurs if and only if every prime
|
||||
@@ -29,7 +32,7 @@ EXAMPLE
|
||||
-1 3 1
|
||||
|
||||
LIMITS
|
||||
none
|
||||
b > 1
|
||||
|
||||
LINK LIBRARY
|
||||
long qplaces(NUMBER *q, ZVALUE base)
|
||||
@@ -37,7 +40,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
digit, digits
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
## Copyright (C) 1999-2003 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
|
||||
@@ -53,8 +56,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: places,v 29.4 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Revision: 29.5 $
|
||||
## @(#) $Id: places,v 29.5 2003/01/26 19:43:45 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/places,v $
|
||||
##
|
||||
## Under source code control: 1995/10/03 10:40:02
|
||||
|
6
help/re
6
help/re
@@ -20,7 +20,7 @@ LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
COMPLEX *cimag(COMPLEX *x)
|
||||
COMPLEX *c_imag(COMPLEX *x)
|
||||
|
||||
SEE ALSO
|
||||
im
|
||||
@@ -41,8 +41,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: re,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: re,v 29.3 2002/03/12 09:38:26 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/re,v $
|
||||
##
|
||||
## Under source code control: 1995/10/05 04:52:27
|
||||
|
12
help/script
12
help/script
@@ -146,13 +146,19 @@ Calc shell scripts
|
||||
interpreter. Assuming the full path for calc is
|
||||
/usr/local/bin/calc, one could use the file addall3 with contents
|
||||
|
||||
#!/usr/local/bin/calc -q -s -f
|
||||
#!/usr/bin/calc -q -s -f
|
||||
global i, n, s;
|
||||
n = argv();
|
||||
for (i = 1; i <= n; i++)
|
||||
s += eval(argv(i));
|
||||
print "sum =", s;
|
||||
|
||||
IMPORTANT NOTE:
|
||||
|
||||
The -f flag must be at the very end of the #! line.
|
||||
The #! line must be the first line of the exeuctable file.
|
||||
The path after the #! must be the full path to the calc executable.
|
||||
|
||||
After the command:
|
||||
|
||||
addall3 2 3 4
|
||||
@@ -283,8 +289,8 @@ For more information use the following calc commands:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.5 $
|
||||
## @(#) $Id: script,v 29.5 2001/04/08 07:56:32 chongo Exp $
|
||||
## @(#) $Revision: 29.7 $
|
||||
## @(#) $Id: script,v 29.7 2004/10/23 00:41:11 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/script,v $
|
||||
##
|
||||
## Under source code control: 1999/11/30 05:29:48
|
||||
|
14
help/str
14
help/str
@@ -18,7 +18,7 @@ DESCRIPTION
|
||||
|
||||
For real or complex x, str(x) returns the string representing x
|
||||
in the current printing mode; configuration parameters affecting
|
||||
this are "mode", "display", "outround", "tilde", "leadzero",
|
||||
this are "mode", "mode2", "display", "outround", "tilde", "leadzero",
|
||||
|
||||
EXAMPLE
|
||||
> str("")
|
||||
@@ -28,6 +28,10 @@ EXAMPLE
|
||||
> print str(123), str("+"), str(4i), str("is the same as"), str(123+4i)
|
||||
123 + 4i is the same as 3+4i
|
||||
|
||||
> base2(16),
|
||||
> print str(23209)
|
||||
23209 /* 0x5aa9 */
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
@@ -41,9 +45,9 @@ LINK LIBRARY
|
||||
char *math_getdivertedio();
|
||||
|
||||
SEE ALSO
|
||||
XXX - fill in
|
||||
base, base2, config
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
## Copyright (C) 1999-2002 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
|
||||
@@ -59,8 +63,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: str,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: str,v 29.3 2002/12/29 09:19:56 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/str,v $
|
||||
##
|
||||
## Under source code control: 1995/10/05 04:52:27
|
||||
|
19
help/todo
19
help/todo
@@ -59,6 +59,15 @@ Very High priority items:
|
||||
* Fix any 'Known bugs' as noted in the BUGS file or as
|
||||
displayed by 'calc help bugs'.
|
||||
|
||||
* Internationalize calc by converting calc error messages and
|
||||
text strings (e.g., calc startup banner, show output, etc.)
|
||||
into calls to the GNU gettext internationalization facility.
|
||||
If somebody translated these strings into another language,
|
||||
setting $LANG would allow calc to produce error messages
|
||||
and text strings in that language.
|
||||
|
||||
* Consider using GNU autoconf / configure to build the calc Makefile.
|
||||
|
||||
=-=
|
||||
|
||||
High priority items:
|
||||
@@ -76,8 +85,6 @@ High priority items:
|
||||
* Perform a code coverage analysis of the 'make check' action
|
||||
and improve the coverage (within reason) of the regress.cal suite.
|
||||
|
||||
* Create a Linux rpm (Red Hat Package Manager) package for calc.
|
||||
|
||||
* Address, if possible and reasonable, any Calc Mis-features
|
||||
as noted in the BUGS file or as displayed by 'calc help bugs'.
|
||||
|
||||
@@ -115,9 +122,7 @@ Medium priority items:
|
||||
* Add a builtin function to access the 64 bit FNV hash which
|
||||
is currently being used internally in seed.c.
|
||||
|
||||
* Consider using configure to build the calc Makefile.
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
## Copyright (C) 1999-2003 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
|
||||
@@ -133,8 +138,8 @@ Medium priority items:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: todo,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.5 $
|
||||
## @(#) $Id: todo,v 29.5 2003/02/25 20:26:17 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/todo,v $
|
||||
##
|
||||
## Under source code control: 1999/10/20 07:42:55
|
||||
|
18
help/usage
18
help/usage
@@ -148,10 +148,14 @@ Calc command line
|
||||
when the mode disables opening of files for reading.
|
||||
|
||||
|
||||
-n Use the new configuration defaults instead of the old
|
||||
default classic defaults. This flag as the same effect
|
||||
as executing config("all", "newcfg") at startup time.
|
||||
-O Use the old classic defaults instead of the default
|
||||
configuration. This flag as the same effect as executing
|
||||
config("all", "oldcfg") at startup time.
|
||||
|
||||
NOTE: Older versions of calc used -n to setup a modified
|
||||
form of the default calc configuration. The -n flag
|
||||
currently does nothing. Use of the -n flag is now
|
||||
deprecated and may used for something else in the future.
|
||||
|
||||
-p Pipe processing is enabled by use of -p. For example:
|
||||
|
||||
@@ -249,8 +253,8 @@ Calc command line
|
||||
./myfile.cal
|
||||
${LIBDIR}/myfile
|
||||
${LIBDIR}/myfile.cal
|
||||
${CUSTOMLIBDIR}/myfile
|
||||
${CUSTOMLIBDIR}/myfile.cal
|
||||
${CUSTOMCALDIR}/myfile
|
||||
${CUSTOMCALDIR}/myfile.cal
|
||||
|
||||
If the file is found, the search stops and the commands in
|
||||
the file are executed. It is an error if no readable file
|
||||
@@ -353,8 +357,8 @@ For more information use the following calc commands:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: usage,v 29.3 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.6 $
|
||||
## @(#) $Id: usage,v 29.6 2003/06/10 21:39:34 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/usage,v $
|
||||
##
|
||||
## Under source code control: 1991/07/21 04:37:25
|
||||
|
16
hist.c
16
hist.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* hist - interactive readline module
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2004 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
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: hist.c,v 29.3 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: hist.c,v 29.6 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/hist.c,v $
|
||||
*
|
||||
* Under source code control: 1993/05/02 20:09:19
|
||||
@@ -67,6 +67,8 @@
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include "have_unused.h"
|
||||
|
||||
#if !defined(USE_READLINE)
|
||||
|
||||
extern FILE *curstream(void);
|
||||
@@ -193,8 +195,8 @@ static char esc_map_name[] = "esc-map";
|
||||
|
||||
|
||||
static KEY_MAP maps[] = {
|
||||
{base_map_name},
|
||||
{esc_map_name}
|
||||
{base_map_name, {NULL, NULL}, {NULL, NULL}},
|
||||
{esc_map_name, {NULL, NULL}, {NULL, NULL}},
|
||||
};
|
||||
|
||||
|
||||
@@ -407,7 +409,7 @@ hist_term(void)
|
||||
static KEY_MAP *
|
||||
find_map(char *map)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof(maps) / sizeof(maps[0]); i++) {
|
||||
if (strcmp(map, maps[i].name) == 0)
|
||||
@@ -1489,7 +1491,7 @@ my_stifle_history (void)
|
||||
|
||||
|
||||
int
|
||||
hist_init(char *filename)
|
||||
hist_init(char UNUSED *filename)
|
||||
{
|
||||
/* used when parsing conditionals in ~/.inputrc */
|
||||
rl_readline_name = "calc";
|
||||
|
8
hist.h
8
hist.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: hist.h,v 29.3 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: hist.h,v 29.4 2002/03/12 09:40:57 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/hist.h,v $
|
||||
*
|
||||
* Under source code control: 1993/05/02 20:09:20
|
||||
@@ -50,7 +50,11 @@
|
||||
#define HOMECHAR '~' /* char which indicates home directory */
|
||||
#define DOTCHAR '.' /* char which indicates current directory */
|
||||
#define PATHCHAR '/' /* char which separates path components */
|
||||
#if defined(__MSDOS__) || defined(__WIN32)
|
||||
#define LISTCHAR ';' /* char which separates paths in a list */
|
||||
#else
|
||||
#define LISTCHAR ':' /* char which separates paths in a list */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
29
input.c
29
input.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: input.c,v 29.5 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: input.c,v 29.6 2002/03/12 09:40:57 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/input.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:16
|
||||
@@ -46,6 +46,12 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__)
|
||||
#include <limits.h>
|
||||
#define _fullpath(f,n,s) (_fixpath(n,f),f)
|
||||
#define _MAX_PATH PATH_MAX
|
||||
#endif
|
||||
|
||||
#include "calc.h"
|
||||
#include "conf.h"
|
||||
#include "hist.h"
|
||||
@@ -816,11 +822,12 @@ runrcfiles(void)
|
||||
* given:
|
||||
* sbuf stat of the inode in question
|
||||
*/
|
||||
|
||||
static int
|
||||
isinoderead(struct stat *sbuf)
|
||||
{
|
||||
int i;
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32) || defined(__MSDOS__)
|
||||
char fullpathname[_MAX_PATH];
|
||||
#endif
|
||||
|
||||
@@ -832,11 +839,11 @@ isinoderead(struct stat *sbuf)
|
||||
|
||||
/* scan the entire readset */
|
||||
for (i=0; i < maxreadset; ++i) {
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32) || defined(__MSDOS__)
|
||||
if (readset[i].active &&
|
||||
strcmp(readset[i].path,
|
||||
_fullpath(fullpathname,cip->i_name,
|
||||
_MAX_PATH)) == 0) {
|
||||
strcasecmp(readset[i].path,
|
||||
_fullpath(fullpathname,cip->i_name,
|
||||
_MAX_PATH)) == 0) {
|
||||
/* found a match */
|
||||
return i;
|
||||
}
|
||||
@@ -954,14 +961,18 @@ addreadset(char *name, char *path, struct stat *sbuf)
|
||||
return -1;
|
||||
}
|
||||
strcpy(readset[ret].name, name);
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32) || defined(__MSDOS__)
|
||||
/*
|
||||
* For WIN32, _fullpath expands the path to a fully qualified
|
||||
* path name, which under WIN32 FAT and NTFS is unique, just
|
||||
* like UNIX inodes. _fullpath also allocated the memory for
|
||||
* this new longer path name.
|
||||
*/
|
||||
readset[ret].path = _fullpath(NULL, path, 0);
|
||||
{
|
||||
char fullpathname[_MAX_PATH];
|
||||
|
||||
readset[ret].path = _fullpath(fullpathname, path, _MAX_PATH);
|
||||
}
|
||||
#else /* Windoz free systems */
|
||||
readset[ret].path = (char *)malloc(strlen(path)+1);
|
||||
if (readset[ret].path == NULL) {
|
||||
|
40
lib_calc.c
40
lib_calc.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: lib_calc.c,v 29.7 2001/04/08 22:05:40 chongo Exp $
|
||||
* @(#) $Revision: 29.10 $
|
||||
* @(#) $Id: lib_calc.c,v 29.10 2004/07/26 06:35:32 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/lib_calc.c,v $
|
||||
*
|
||||
* Under source code control: 1996/06/17 18:06:19
|
||||
@@ -106,10 +106,10 @@ extern uid_t geteuid();
|
||||
/*
|
||||
* Common definitions
|
||||
*/
|
||||
int new_std = FALSE; /* TRUE (-n) => use newstd configuration */
|
||||
int abortlevel; /* current level of aborts */
|
||||
BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||
jmp_buf jmpbuf; /* for errors */
|
||||
int use_old_std = FALSE; /* TRUE => use old classic configuration */
|
||||
int abortlevel; /* current level of aborts */
|
||||
BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||
jmp_buf jmpbuf; /* for errors */
|
||||
char *program = "calc"; /* our name */
|
||||
char *base_name = "calc"; /* basename of our name */
|
||||
char cmdbuf[MAXCMD+1+1+1]; /* command line expression + "\n\0" + guard */
|
||||
@@ -217,6 +217,11 @@ libcalc_call_me_first(void)
|
||||
*/
|
||||
if (program != NULL) {
|
||||
p = strrchr(program, '/');
|
||||
#if defined(_WIN32) || defined(__MSDOS__)
|
||||
if (p == NULL) {
|
||||
p = strrchr(program, '\\');
|
||||
}
|
||||
#endif
|
||||
if (p == NULL) {
|
||||
base_name = program;
|
||||
} else {
|
||||
@@ -227,30 +232,31 @@ libcalc_call_me_first(void)
|
||||
/*
|
||||
* initialize old and new configuration values
|
||||
*/
|
||||
oldstd.epsilon = &_qonesqbase_; /* magic to fake early str2q() */
|
||||
oldstd.program = strdup(program);
|
||||
oldstd.base_name = strdup(base_name);
|
||||
oldstd.version = strdup(version());
|
||||
conf = config_copy(&oldstd); /* more magic to fake early str2q() */
|
||||
newstd.epsilon = &_qonesqbase_; /* magic to fake early str2q() */
|
||||
newstd.program = strdup(program);
|
||||
newstd.base_name = strdup(base_name);
|
||||
newstd.version = strdup(version());
|
||||
conf = config_copy(&newstd); /* more magic to fake early str2q() */
|
||||
conf->tab_ok = FALSE;
|
||||
newstd.epsilon = str2q(EPSILON_DEFAULT);
|
||||
oldstd.epsilon = str2q(EPSILON_DEFAULT);
|
||||
newstd.epsilon = str2q(NEW_EPSILON_DEFAULT);
|
||||
|
||||
/*
|
||||
* make oldstd our default config
|
||||
* make newstd our default config, unless -O
|
||||
*/
|
||||
config_free(conf);
|
||||
if (new_std) {
|
||||
conf = config_copy(&newstd);
|
||||
} else {
|
||||
if (use_old_std) {
|
||||
conf = config_copy(&oldstd);
|
||||
} else {
|
||||
conf = config_copy(&newstd);
|
||||
}
|
||||
|
||||
/*
|
||||
* -d turns off resource_debug
|
||||
* -d turns off resource_debug and tilde
|
||||
*/
|
||||
if (d_flag) {
|
||||
conf->resource_debug = 0;
|
||||
conf->tilde_ok = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
33
longbits.c
33
longbits.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: longbits.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: longbits.c,v 29.3 2004/03/31 04:18:19 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/longbits.c,v $
|
||||
*
|
||||
* Under source code control: 1994/03/18 03:06:18
|
||||
@@ -74,11 +74,6 @@
|
||||
* L(x) form a 33 to 64 bit signed constant
|
||||
* U(x) form a 33 to 64 bit unsigned constant
|
||||
*
|
||||
* We will also note if we have a standard 64 bit type (i.e., long). If we
|
||||
* do, we will typedef it and define HAVE_B64. If we do not then if longlong.h
|
||||
* says we can use long long types, we will use that. If we cannot use a
|
||||
* long long type, then HAVE_B64 will not be defined.
|
||||
*
|
||||
* We hide the comments within strings to avoid complaints from some snitty
|
||||
* compilers. We also hide 3 X's which is the calc symbol for "something bogus
|
||||
* this way comes". In such error cases, we add -=*#*=- to force a syntax
|
||||
@@ -101,8 +96,6 @@
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "longlong.h"
|
||||
|
||||
#if defined(__linux)
|
||||
# if !defined(isascii)
|
||||
extern int isascii(int c);
|
||||
@@ -201,7 +194,6 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* forced forming of HAVE_B64, USB64, SB64, U(x) and L(x)
|
||||
*/
|
||||
#if defined(HAVE_LONGLONG) && LONGLONG_BITS == 64
|
||||
printf("#undef HAVE_B64\n");
|
||||
printf("#define HAVE_B64\t\t/%s/\n",
|
||||
"* have USB64 and SB64 types *");
|
||||
@@ -218,16 +210,6 @@ main(int argc, char **argv)
|
||||
printf("#define U(x) ((unsigned long long)x)\n");
|
||||
printf("#define L(x) ((long long)x)\n");
|
||||
#endif
|
||||
#else
|
||||
printf("#undef HAVE_B64\t\t\t/%s/\n",
|
||||
"* we have no USB64 and no SB64 types *");
|
||||
putchar('\n');
|
||||
printf("/%s/\n", "* no 64 bit constants *");
|
||||
printf("#define U(x) no 33 to 64 bit constants %s\n",
|
||||
"- do not use this macro!");
|
||||
printf("#define L(x) no 33 to 64 bit constants %s\n",
|
||||
"- do not use this macro!");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* all done
|
||||
@@ -333,7 +315,6 @@ main(int argc, char **argv)
|
||||
printf("#define L(x) ((long)x)\n");
|
||||
#endif
|
||||
} else {
|
||||
#if defined(HAVE_LONGLONG) && LONGLONG_BITS == 64
|
||||
printf("#undef HAVE_B64\n");
|
||||
printf("#define HAVE_B64\t\t/%s/\n",
|
||||
"* have USB64 and SB64 types *");
|
||||
@@ -349,16 +330,6 @@ main(int argc, char **argv)
|
||||
#else
|
||||
printf("#define U(x) ((unsigned long long)x)\n");
|
||||
printf("#define L(x) ((long long)x)\n");
|
||||
#endif
|
||||
#else
|
||||
printf("#undef HAVE_B64\t\t\t/%s/\n",
|
||||
"* we have no USB64 and no SB64 types *");
|
||||
putchar('\n');
|
||||
printf("/%s/\n", "* no 64 bit constants *");
|
||||
printf("#define U(x) no 33 to 64 bit constants %s\n",
|
||||
"- do not use this macro!");
|
||||
printf("#define L(x) no 33 to 64 bit constants %s\n",
|
||||
"- do not use this macro!");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
145
longlong.c
145
longlong.c
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* longlong - determine the number of bits in a long long, if is exists
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: longlong.c,v 29.3 2001/02/23 20:46:38 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/longlong.c,v $
|
||||
*
|
||||
* Under source code control: 1994/08/05 01:09:19
|
||||
* File existed as early as: 1994
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* usage:
|
||||
* longlong [bits]
|
||||
*
|
||||
* bits if empty or missing causes this prog to compute its length,
|
||||
* if 0, this prog will output nothing
|
||||
* otherwise this prog will assume it is the long long bit length
|
||||
*
|
||||
* Not all compilers support the long long type, so this may not compile
|
||||
* on your system.
|
||||
*
|
||||
* This prog outputs several defines:
|
||||
*
|
||||
* HAVE_LONGLONG
|
||||
* defined ==> ok to use long long
|
||||
* undefined ==> do not use long long, even if they exist
|
||||
*
|
||||
* LONGLONG_BITS
|
||||
* 0 ==> do not use long long, even if they exist
|
||||
* != 0 ==> bits in an unsigned long long
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "have_stdlib.h"
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "have_string.h"
|
||||
#if defined(HAVE_STRING_H)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* have the compiler try its hand with unsigned and signed long longs
|
||||
*/
|
||||
unsigned long long val = 0x1234567890123456ULL;
|
||||
long long val2 = -1311768467284833366LL; /* -0x1234567890123456 */
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int longlong_bits; /* bits in a long long, or <=0 => dont use */
|
||||
char buf[BUFSIZ+1]; /* scan buffer */
|
||||
|
||||
/*
|
||||
* parse args
|
||||
*/
|
||||
if (argc < 2) {
|
||||
/* no arg means compute the length */
|
||||
longlong_bits = sizeof(unsigned long long)*8;
|
||||
} else if (strcmp(argv[1], "") == 0) {
|
||||
/* empty arg means compute the length */
|
||||
longlong_bits = sizeof(unsigned long long)*8;
|
||||
} else {
|
||||
longlong_bits = atoi(argv[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
* length is preset, or 0 ==> do not use
|
||||
*/
|
||||
if (longlong_bits > 0) {
|
||||
|
||||
/*
|
||||
* if size is longer than an unsigned long,
|
||||
* and the negative 'long long' works, then use long long's
|
||||
*/
|
||||
if (longlong_bits > sizeof(unsigned long)*8 && val2 < 0) {
|
||||
|
||||
/* use long long length */
|
||||
printf("#define HAVE_LONGLONG\n");
|
||||
printf("#define LONGLONG_BITS %d /* yes */\n",
|
||||
longlong_bits);
|
||||
|
||||
printf("\n/*\n");
|
||||
printf(" * how should 64 bit values be formatted?\n");
|
||||
printf(" *\n");
|
||||
|
||||
/* it is OK to get a printf format type warning here */
|
||||
sprintf(buf, "%ld", val);
|
||||
|
||||
printf(" * sprintf \"%%ld\" of 0x1234567890123456ULL "
|
||||
"is %s\n", buf);
|
||||
printf(" *\n");
|
||||
printf(" * if defined(L64_FORMAT), ok to use %%ld\n");
|
||||
printf(" * if !defined(L64_FORMAT), use %%lld\n");
|
||||
printf(" */\n");
|
||||
if (strcmp(buf, "1311768467284833366") == 0) {
|
||||
printf("#define L64_FORMAT\n");
|
||||
} else {
|
||||
printf("#undef L64_FORMAT\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* We have no useful 64 bit values
|
||||
*/
|
||||
} else {
|
||||
if (longlong_bits <= sizeof(unsigned long)*8) {
|
||||
printf("/* long long size <= long size */\n");
|
||||
} else {
|
||||
printf("/* unsigned long long constants "
|
||||
"don't work */\n");
|
||||
}
|
||||
printf("#undef HAVE_LONGLONG\n");
|
||||
printf("#define LONGLONG_BITS 0\t/%s/\n", "* no *");
|
||||
printf("#undef L64_FORMAT\n");
|
||||
}
|
||||
}
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
10
matfunc.c
10
matfunc.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* matfunc - extended precision rational arithmetic matrix functions
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2004 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
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: matfunc.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: matfunc.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/matfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:18
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "zrand.h"
|
||||
#include "calcerr.h"
|
||||
|
||||
#include "have_unused.h"
|
||||
|
||||
extern long irand(long s);
|
||||
|
||||
static void matswaprow(MATRIX *m, long r1, long r2);
|
||||
@@ -853,7 +855,7 @@ matfrac(MATRIX *m)
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE *
|
||||
matindex(MATRIX *mp, BOOL create, long dim, VALUE *indices)
|
||||
matindex(MATRIX *mp, BOOL UNUSED create, long dim, VALUE *indices)
|
||||
{
|
||||
NUMBER *q; /* index value */
|
||||
VALUE *vp;
|
||||
|
18
md5.c
18
md5.c
@@ -10,8 +10,8 @@
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: md5.c,v 29.1 1999/12/14 09:16:12 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: md5.c,v 29.3 2004/08/03 12:28:29 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/md5.c,v $
|
||||
*
|
||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||
@@ -194,7 +194,7 @@ MD5Update(HASH *state, USB8 *inBuf, USB32 count)
|
||||
#if CALC_BYTE_ORDER == BIG_ENDIAN
|
||||
if (state->bytes) {
|
||||
/* byte swap data into little endian order */
|
||||
for (cnt=0; cnt < MD5_CHUNKWORDS; ++cnt) {
|
||||
for (cnt=0; cnt < (int)MD5_CHUNKWORDS; ++cnt) {
|
||||
SWAP_B8_IN_B32(md5Ctx->data + cnt,
|
||||
md5Ctx->data + cnt);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ MD5Final(HASH *state)
|
||||
#if CALC_BYTE_ORDER == BIG_ENDIAN
|
||||
if (state->bytes) {
|
||||
data[count] = 0x80;
|
||||
for (i=0; i < MD5_CHUNKWORDS; ++i) {
|
||||
for (i=0; i < (int)MD5_CHUNKWORDS; ++i) {
|
||||
SWAP_B8_IN_B32(md5Ctx->data + i,
|
||||
md5Ctx->data + i);
|
||||
}
|
||||
@@ -400,7 +400,7 @@ MD5_chkpt(HASH *state)
|
||||
#if CALC_BYTE_ORDER == BIG_ENDIAN
|
||||
if (state->bytes) {
|
||||
/* byte swap data into little endian order */
|
||||
for (cnt=0; cnt < MD5_CHUNKWORDS; ++cnt) {
|
||||
for (cnt=0; cnt < (int)MD5_CHUNKWORDS; ++cnt) {
|
||||
SWAP_B8_IN_B32(dig->data + cnt,
|
||||
dig->data + cnt);
|
||||
}
|
||||
@@ -432,7 +432,7 @@ static void
|
||||
MD5_note(int special, HASH *state)
|
||||
{
|
||||
MD5_CTX *dig = &state->h_union.h_md5; /* digest state */
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* change state to reflect a special value
|
||||
@@ -463,7 +463,7 @@ static void
|
||||
MD5_type(int type, HASH *state)
|
||||
{
|
||||
MD5_CTX *dig = &state->h_union.h_md5; /* digest state */
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* ignore NUMBER and COMPLEX
|
||||
@@ -531,7 +531,7 @@ MD5_final_state(HASH *state)
|
||||
{
|
||||
MD5_CTX *dig = &state->h_union.h_md5; /* digest state */
|
||||
ZVALUE ret; /* return ZVALUE of completed hash state */
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* malloc and initialize if state is NULL
|
||||
@@ -571,7 +571,7 @@ MD5_final_state(HASH *state)
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i=0; i < ret.len; ++i) {
|
||||
for (i=0; i < (unsigned int)ret.len; ++i) {
|
||||
ret.v[ret.len-i-1] = ((HALF*)dig->digest)[i];
|
||||
}
|
||||
|
||||
|
47
no_implicit.c
Normal file
47
no_implicit.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* no-implicit - Determine if the compiler allows -Wno-implicit
|
||||
*
|
||||
* Copyright (C) 2003 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.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: no_implicit.c,v 29.1 2003/01/14 01:45:19 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/no_implicit.c,v $
|
||||
*
|
||||
* Under source code control: 2003/01/14 01:45:19
|
||||
* File existed as early as: 2003
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* If we are able to compile this program, then we the compiler must
|
||||
* allow the -Wno-implicit flag so we output the -Wno-implicit symbol.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
/* -Wno-implicit flag is allowed */
|
||||
printf("-Wno-implicit\n");
|
||||
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
8
obj.c
8
obj.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* obj - object handling primitives
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2004 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
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: obj.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: obj.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/obj.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:19
|
||||
@@ -115,7 +115,7 @@ static struct objectinfo {
|
||||
{1, A_VALUE, ERR_NONE, "backslash", "unary backslash op"},
|
||||
{2, A_VALUE, ERR_NONE, "setminus", "binary backslash op"},
|
||||
{1, A_VALUE, ERR_NONE, "plus", "unary + op"},
|
||||
{0, 0, 0, NULL}
|
||||
{0, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
66
opcodes.c
66
opcodes.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* opcodes - opcode execution module
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2004 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: opcodes.c,v 29.4 2001/04/25 07:16:26 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: opcodes.c,v 29.6 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/opcodes.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:19
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "block.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "have_unused.h"
|
||||
|
||||
#define QUICKLOCALS 20 /* local vars to handle quickly */
|
||||
|
||||
|
||||
@@ -115,7 +117,7 @@ extern void setconfig(int type, VALUE *vp);
|
||||
void
|
||||
initstack(void)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/* on first init, setup the stack array */
|
||||
if (stack == NULL) {
|
||||
@@ -163,7 +165,7 @@ o_localaddr(FUNC *fp, VALUE *locals, long index)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_globaladdr(FUNC *fp, GLOBAL *sp)
|
||||
o_globaladdr(FUNC UNUSED *fp, GLOBAL *sp)
|
||||
{
|
||||
if (sp == NULL) {
|
||||
math_error("Global variable \"%s\" not initialized", sp->g_name);
|
||||
@@ -178,9 +180,9 @@ o_globaladdr(FUNC *fp, GLOBAL *sp)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_paramaddr(FUNC *fp, int argcount, VALUE *args, long index)
|
||||
o_paramaddr(FUNC UNUSED *fp, int argcount, VALUE *args, long index)
|
||||
{
|
||||
if ((unsigned long)index >= argcount) {
|
||||
if ((long)index >= argcount) {
|
||||
math_error("Bad parameter index");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
@@ -210,7 +212,7 @@ o_localvalue(FUNC *fp, VALUE *locals, long index)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_globalvalue(FUNC *fp, GLOBAL *sp)
|
||||
o_globalvalue(FUNC UNUSED *fp, GLOBAL *sp)
|
||||
{
|
||||
if (sp == NULL) {
|
||||
math_error("Global variable not defined");
|
||||
@@ -222,9 +224,9 @@ o_globalvalue(FUNC *fp, GLOBAL *sp)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_paramvalue(FUNC *fp, int argcount, VALUE *args, long index)
|
||||
o_paramvalue(FUNC UNUSED *fp, int argcount, VALUE *args, long index)
|
||||
{
|
||||
if ((unsigned long)index >= argcount) {
|
||||
if ((long)index >= argcount) {
|
||||
math_error("Bad parameter index");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
@@ -267,7 +269,7 @@ o_argvalue(FUNC *fp, int argcount, VALUE *args)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_number(FUNC *fp, long arg)
|
||||
o_number(FUNC UNUSED *fp, long arg)
|
||||
{
|
||||
NUMBER *q;
|
||||
|
||||
@@ -285,7 +287,7 @@ o_number(FUNC *fp, long arg)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_imaginary(FUNC *fp, long arg)
|
||||
o_imaginary(FUNC UNUSED *fp, long arg)
|
||||
{
|
||||
NUMBER *q;
|
||||
COMPLEX *c;
|
||||
@@ -312,7 +314,7 @@ o_imaginary(FUNC *fp, long arg)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_string(FUNC *fp, long arg)
|
||||
o_string(FUNC UNUSED *fp, long arg)
|
||||
{
|
||||
stack++;
|
||||
stack->v_str = slink(findstring(arg));
|
||||
@@ -332,7 +334,7 @@ o_undef(void)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_matcreate(FUNC *fp, long dim)
|
||||
o_matcreate(FUNC UNUSED *fp, long dim)
|
||||
{
|
||||
register MATRIX *mp; /* matrix being defined */
|
||||
NUMBER *num1; /* first number from stack */
|
||||
@@ -400,7 +402,7 @@ o_matcreate(FUNC *fp, long dim)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_eleminit(FUNC *fp, long index)
|
||||
o_eleminit(FUNC UNUSED *fp, long index)
|
||||
{
|
||||
VALUE *vp;
|
||||
static VALUE *oldvp;
|
||||
@@ -501,7 +503,7 @@ o_eleminit(FUNC *fp, long index)
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_indexaddr(FUNC *fp, long dim, long writeflag)
|
||||
o_indexaddr(FUNC UNUSED *fp, long dim, long writeflag)
|
||||
{
|
||||
int i;
|
||||
BOOL flag;
|
||||
@@ -653,7 +655,7 @@ o_indexaddr(FUNC *fp, long dim, long writeflag)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_elemaddr(FUNC *fp, long index)
|
||||
o_elemaddr(FUNC UNUSED *fp, long index)
|
||||
{
|
||||
VALUE *vp;
|
||||
MATRIX *mp;
|
||||
@@ -708,7 +710,7 @@ o_elemvalue(FUNC *fp, long index)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_objcreate(FUNC *fp, long arg)
|
||||
o_objcreate(FUNC UNUSED *fp, long arg)
|
||||
{
|
||||
stack++;
|
||||
stack->v_type = V_OBJ;
|
||||
@@ -2558,7 +2560,7 @@ o_return(void)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_jumpz(FUNC *fp, BOOL *dojump)
|
||||
o_jumpz(FUNC UNUSED *fp, BOOL *dojump)
|
||||
{
|
||||
VALUE *vp;
|
||||
int i; /* result of comparison */
|
||||
@@ -2582,7 +2584,7 @@ o_jumpz(FUNC *fp, BOOL *dojump)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_jumpnz(FUNC *fp, BOOL *dojump)
|
||||
o_jumpnz(FUNC UNUSED *fp, BOOL *dojump)
|
||||
{
|
||||
VALUE *vp;
|
||||
int i; /* result of comparison */
|
||||
@@ -2609,7 +2611,7 @@ o_jumpnz(FUNC *fp, BOOL *dojump)
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_jumpnn(FUNC *fp, BOOL *dojump)
|
||||
o_jumpnn(FUNC UNUSED *fp, BOOL *dojump)
|
||||
{
|
||||
if (stack->v_addr->v_type) {
|
||||
*dojump = TRUE;
|
||||
@@ -2620,7 +2622,7 @@ o_jumpnn(FUNC *fp, BOOL *dojump)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_condorjump(FUNC *fp, BOOL *dojump)
|
||||
o_condorjump(FUNC UNUSED *fp, BOOL *dojump)
|
||||
{
|
||||
VALUE *vp;
|
||||
|
||||
@@ -2646,7 +2648,7 @@ o_condorjump(FUNC *fp, BOOL *dojump)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_condandjump(FUNC *fp, BOOL *dojump)
|
||||
o_condandjump(FUNC UNUSED *fp, BOOL *dojump)
|
||||
{
|
||||
VALUE *vp;
|
||||
|
||||
@@ -2677,7 +2679,7 @@ o_condandjump(FUNC *fp, BOOL *dojump)
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_casejump(FUNC *fp, BOOL *dojump)
|
||||
o_casejump(FUNC UNUSED *fp, BOOL *dojump)
|
||||
{
|
||||
VALUE *v1, *v2;
|
||||
int r;
|
||||
@@ -2699,7 +2701,7 @@ o_casejump(FUNC *fp, BOOL *dojump)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_jump(FUNC *fp, BOOL *dojump)
|
||||
o_jump(FUNC UNUSED *fp, BOOL *dojump)
|
||||
{
|
||||
*dojump = TRUE;
|
||||
}
|
||||
@@ -2719,7 +2721,7 @@ o_usercall(FUNC *fp, long index, long argcount)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_call(FUNC *fp, long index, long argcount)
|
||||
o_call(FUNC UNUSED *fp, long index, long argcount)
|
||||
{
|
||||
VALUE result;
|
||||
|
||||
@@ -3073,7 +3075,7 @@ o_rightshift(void)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_debug(FUNC *fp, long line)
|
||||
o_debug(FUNC UNUSED *fp, long line)
|
||||
{
|
||||
funcline = line;
|
||||
if (abortlevel >= ABORT_STATEMENT) {
|
||||
@@ -3104,7 +3106,7 @@ o_printresult(void)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_print(FUNC *fp, long flags)
|
||||
o_print(FUNC UNUSED *fp, long flags)
|
||||
{
|
||||
VALUE *vp;
|
||||
|
||||
@@ -3138,7 +3140,7 @@ o_printspace(void)
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
o_printstring(FUNC *fp, long index)
|
||||
o_printstring(FUNC UNUSED *fp, long index)
|
||||
{
|
||||
STRING *s;
|
||||
char *cp;
|
||||
@@ -3437,7 +3439,7 @@ o_initfill(void)
|
||||
static void
|
||||
o_show(FUNC *fp, long arg)
|
||||
{
|
||||
int size;
|
||||
unsigned int size;
|
||||
|
||||
switch((int) arg) {
|
||||
case 1: showbuiltins(); return;
|
||||
@@ -3662,7 +3664,7 @@ calculate(FUNC *fp, int argcount)
|
||||
long oldline; /* old value of line counter */
|
||||
unsigned int opnum; /* current opcode number */
|
||||
int origargcount; /* original number of arguments */
|
||||
int i; /* loop counter */
|
||||
unsigned int i; /* loop counter */
|
||||
BOOL dojump; /* TRUE if jump is to occur */
|
||||
char *oldname; /* old function name being executed */
|
||||
VALUE *beginstack; /* beginning of stack frame */
|
||||
@@ -3677,7 +3679,7 @@ calculate(FUNC *fp, int argcount)
|
||||
go = TRUE;
|
||||
++calc_depth;
|
||||
origargcount = argcount;
|
||||
while (argcount < fp->f_paramcount) {
|
||||
while ((unsigned)argcount < fp->f_paramcount) {
|
||||
stack++;
|
||||
stack->v_type = V_NULL;
|
||||
stack->v_subtype = V_NOSUBTYPE;
|
||||
|
20
qfunc.c
20
qfunc.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qfunc - extended precision rational arithmetic non-primitive functions
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2004 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: qfunc.c,v 29.4 2000/12/17 13:07:32 chongo Exp $
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: qfunc.c,v 29.7 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:20
|
||||
@@ -623,8 +623,16 @@ qilog(NUMBER *q, ZVALUE base)
|
||||
/*
|
||||
* Return the number of digits in the representation to a specified
|
||||
* base of the integral part of a number.
|
||||
*
|
||||
* Examples: qdigits(3456,10) = 4, qdigits(-23.45, 10) = 2.
|
||||
*
|
||||
* One should remember these special cases:
|
||||
*
|
||||
* digits(12.3456) == 2 computes with the integer part only
|
||||
* digits(-1234) == 4 computes with the absolute value only
|
||||
* digits(0) == 1 specical case
|
||||
* digits(-0.123) == 1 combination of all of the above
|
||||
*
|
||||
* given:
|
||||
* q number to count digits of
|
||||
*/
|
||||
@@ -634,8 +642,8 @@ qdigits(NUMBER *q, ZVALUE base)
|
||||
long n; /* number of digits */
|
||||
ZVALUE temp; /* temporary value */
|
||||
|
||||
if (zabsrel(q->num, q->den) < 1)
|
||||
return 0;
|
||||
if (zabsrel(q->num, q->den) < 0)
|
||||
return 1;
|
||||
if (qisint(q))
|
||||
return 1 + zlog(q->num, base);
|
||||
zquo(q->num, q->den, &temp, 2);
|
||||
@@ -1732,7 +1740,7 @@ qgcdrem(NUMBER *q1, NUMBER *q2)
|
||||
NUMBER *
|
||||
qlowfactor(NUMBER *q1, NUMBER *q2)
|
||||
{
|
||||
long count;
|
||||
unsigned long count;
|
||||
|
||||
if (qisfrac(q1) || qisfrac(q2)) {
|
||||
math_error("Non-integers for lowfactor");
|
||||
|
21
qio.c
21
qio.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qio - scanf and printf routines for arbitrary precision rational numbers
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2004 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
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: qio.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: qio.c,v 29.6 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qio.c,v $
|
||||
*
|
||||
* Under source code control: 1993/07/30 19:42:46
|
||||
@@ -32,6 +32,8 @@
|
||||
#include "config.h"
|
||||
#include "args.h"
|
||||
|
||||
#include "have_unused.h"
|
||||
|
||||
|
||||
#define PUTCHAR(ch) math_chr(ch)
|
||||
#define PUTSTR(str) math_str(str)
|
||||
@@ -180,9 +182,12 @@ qprintnum(NUMBER *q, int outmode)
|
||||
{
|
||||
NUMBER tmpval;
|
||||
long prec, exp;
|
||||
int outmode2 = MODE2_OFF;
|
||||
|
||||
if (outmode == MODE_DEFAULT)
|
||||
if (outmode == MODE_DEFAULT) {
|
||||
outmode = conf->outmode;
|
||||
outmode2 = conf->outmode2;
|
||||
}
|
||||
switch (outmode) {
|
||||
case MODE_INT:
|
||||
if (conf->tilde_ok && qisfrac(q))
|
||||
@@ -248,6 +253,12 @@ qprintnum(NUMBER *q, int outmode)
|
||||
math_error("Bad mode for print");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
if (outmode2 != MODE2_OFF) {
|
||||
PUTSTR(" /* ");
|
||||
qprintnum(q, outmode2);
|
||||
PUTSTR(" */");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -290,7 +301,7 @@ qprintff(NUMBER *q, long width, long precision)
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
qprintfe(NUMBER *q, long width, long precision)
|
||||
qprintfe(NUMBER *q, long UNUSED width, long precision)
|
||||
{
|
||||
long exponent;
|
||||
NUMBER q2;
|
||||
|
8
qmath.c
8
qmath.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qmath - extended precision rational arithmetic primitive routines
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2004 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: qmath.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: qmath.c,v 29.5 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qmath.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:21
|
||||
@@ -1296,7 +1296,7 @@ qreli(NUMBER *q, long n)
|
||||
if (n == 0)
|
||||
return (q->num.sign ? -1 : 0);
|
||||
|
||||
if (q->num.sign != n < 0)
|
||||
if (q->num.sign != (n < 0))
|
||||
return ((n < 0) ? 1 : -1);
|
||||
|
||||
itoz(n, &z1);
|
||||
|
25
qtrans.c
25
qtrans.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qtrans - transcendental functions for real numbers
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2004 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: qtrans.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: qtrans.c,v 29.6 2004/10/23 00:58:59 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qtrans.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:22
|
||||
@@ -479,7 +479,8 @@ qacos(NUMBER *q, NUMBER *epsilon)
|
||||
NUMBER *
|
||||
qatan(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
long m, k, i, d;
|
||||
long m, k, i;
|
||||
FULL d;
|
||||
ZVALUE X, D, DD, sum, mul, term, ztmp1, ztmp2;
|
||||
NUMBER *qtmp, *res;
|
||||
BOOL sign;
|
||||
@@ -986,16 +987,20 @@ qln(NUMBER *q, NUMBER *epsilon)
|
||||
}
|
||||
zfree(pow);
|
||||
zfree(mul);
|
||||
qtmp = qalloc(); /* qtmp is to be 2^n * sum / 2^m */
|
||||
k = zlowbit(sum);
|
||||
qtmp = qalloc();
|
||||
sum.sign = neg;
|
||||
if (k) {
|
||||
zshift(sum, -k, &qtmp->num);
|
||||
zfree(sum);
|
||||
if (k + n >= m) {
|
||||
zshift(sum, n - m, &qtmp->num);
|
||||
} else {
|
||||
qtmp->num = sum;
|
||||
if (k) {
|
||||
zshift(sum, -k, &qtmp->num);
|
||||
zfree(sum);
|
||||
} else {
|
||||
qtmp->num = sum;
|
||||
}
|
||||
zbitvalue(m - k - n, &qtmp->den);
|
||||
}
|
||||
zbitvalue(m - k - n, &qtmp->den);
|
||||
res = qmappr(qtmp, epsilon, 24L);
|
||||
qfree(qtmp);
|
||||
return res;
|
||||
|
149
quickhash.c
149
quickhash.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* quickhash - quickly hash a calc value using a partial Fowler/Noll/Vo hash
|
||||
* quickhash - quickly hash a calc value using a quasi Fowler/Noll/Vo hash
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2002 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,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: quickhash.c,v 29.4 2001/04/14 22:47:21 chongo Exp $
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: quickhash.c,v 29.8 2004/02/25 23:55:38 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/quickhash.c,v $
|
||||
*
|
||||
* Under source code control: 1995/03/04 11:34:23
|
||||
@@ -31,26 +31,6 @@
|
||||
/*
|
||||
* NOTE: This file does not contain a hash interface. It is used by
|
||||
* associative arrays and other internal processes.
|
||||
*
|
||||
* We will compute a hash value for any type of calc value
|
||||
* for use in associative arrays and the hash() builtin.
|
||||
* Hash speed is of primary importance to make associative
|
||||
* arrays work at a reasonable speed. For this reason, we
|
||||
* cut corners by hashing only a small part of a calc value.
|
||||
*
|
||||
* The Fowler/Noll/Vo hash does a very good job in producing
|
||||
* a 32 bit hash from ASCII strings in a short amount of time.
|
||||
* It is not bad for hashing calc data as well. So doing a
|
||||
* quick and dirty job of hashing on a part of a calc value,
|
||||
* combined with using a reasonable hash function will result
|
||||
* acceptable associative array performance.
|
||||
*
|
||||
* See:
|
||||
* http://www.isthe.com/chongo/src/fnv/fnv_hash.tar.gz
|
||||
* http://www.isthe.com/chongo/src/fnv/hash_32.c
|
||||
* http://www.isthe.com/chongo/src/fnv/hash_64.c
|
||||
*
|
||||
* for information on 32bit and 64bit Fowler/Noll/Vo hashs.
|
||||
*/
|
||||
|
||||
|
||||
@@ -77,7 +57,7 @@ static QCKHASH blk_hash(BLOCK *blk, QCKHASH val);
|
||||
|
||||
|
||||
/*
|
||||
* FNV-0 - Fowler/Noll/Vo-0 32 bit hash
|
||||
* quasi_fnv - quasi Fowler/Noll/Vo-0 32 bit hash
|
||||
*
|
||||
* The basis of this hash algorithm was taken from an idea sent
|
||||
* as reviewer comments to the IEEE POSIX P1003.2 committee by:
|
||||
@@ -97,7 +77,7 @@ static QCKHASH blk_hash(BLOCK *blk, QCKHASH val);
|
||||
* collision rate. The FNV speed allows one to quickly hash lots
|
||||
* of data while maintaining a reasonable collision rate. See:
|
||||
*
|
||||
* http://www.isthe.com/chongo/tech/comp/fnv/
|
||||
* http://www.isthe.com/chongo/tech/comp/fnv/index.html
|
||||
*
|
||||
* for more details as well as other forms of the FNV hash.
|
||||
*
|
||||
@@ -107,8 +87,55 @@ static QCKHASH blk_hash(BLOCK *blk, QCKHASH val);
|
||||
*
|
||||
* returns:
|
||||
* the next 32 bit QCKHASH
|
||||
*
|
||||
* Example:
|
||||
* QCKHASH val;
|
||||
* int x;
|
||||
*
|
||||
* quasi_fnv(x, val);
|
||||
*
|
||||
* NOTE: The (x) argument may be an expression such as something with
|
||||
* a ++ or --. The macro must only use (x) once.
|
||||
*
|
||||
* NOTE: The (val) argument just be a lvalue / something to which
|
||||
* a value can be assigned.
|
||||
*
|
||||
* The careful observer will note that (x) need not be a simple
|
||||
* octet. This is not a bug, but a feature. The FNV hash was
|
||||
* designed to operate on octets, not abstract objects such
|
||||
* as associations, file descriptors and PRNG states.
|
||||
* You will also notice that we sometimes add values directly
|
||||
* to the (val) hash state. This is a simulation of hashing
|
||||
* a variable type.
|
||||
*
|
||||
* The Fowler/Noll/Vo hash does a very good job in producing
|
||||
* a 32 bit hash arrays of octets in a short amount of time.
|
||||
* It is not bad for hashing calc data as well. So doing a
|
||||
* quick and dirty job of hashing on a part of a calc value
|
||||
* is all that calc really needs.
|
||||
*
|
||||
* The core of the of the FNV hash has been adopted as the calc
|
||||
* quick hash with the provision that it operates on 32 bit
|
||||
* objects instead of octets. For calc's internal purposes,
|
||||
* this is sufficent. For general FNV hashing, this is not
|
||||
* recommended.
|
||||
*
|
||||
* It has been observed that gcc, when using -O, -O2, -O3 or
|
||||
* better on an AMD or AMD-like processor (such as i686) will
|
||||
* produce slightly faster code when using the shift/add
|
||||
* expression than when performing a multiply with a constant.
|
||||
*/
|
||||
#define fnv(x,val) (((QCKHASH)(val)*(QCKHASH)16777619) ^ ((QCKHASH)(x)))
|
||||
#if defined(NO_HASH_CPU_OPTIMIZATION)
|
||||
#define quasi_fnv(x,val) \
|
||||
((val) = (((QCKHASH)(val)*(QCKHASH)16777619) ^ ((QCKHASH)(x))))
|
||||
#else
|
||||
#define quasi_fnv(x,val) ( \
|
||||
((val) += (((QCKHASH)(val)<<1) + ((QCKHASH)(val)<<4) + \
|
||||
((QCKHASH)(val)<<7) + ((QCKHASH)(val)<<8) + \
|
||||
((QCKHASH)(val)<<24))), \
|
||||
((val) ^= (QCKHASH)(x)) \
|
||||
)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -159,7 +186,8 @@ hashvalue(VALUE *vp, QCKHASH val)
|
||||
{
|
||||
switch (vp->v_type) {
|
||||
case V_INT:
|
||||
return fnv(vp->v_int, V_NUM+val);
|
||||
val += V_NUM;
|
||||
return quasi_fnv(vp->v_int, val);
|
||||
case V_NUM:
|
||||
return fnv_qhash(vp->v_num, val);
|
||||
case V_COM:
|
||||
@@ -177,7 +205,8 @@ hashvalue(VALUE *vp, QCKHASH val)
|
||||
case V_MAT:
|
||||
return mathash(vp->v_mat, val);
|
||||
case V_FILE:
|
||||
return fnv(vp->v_file, V_FILE+val);
|
||||
val += V_FILE;
|
||||
return quasi_fnv(vp->v_file, val);
|
||||
case V_RAND:
|
||||
return randhash(vp->v_rand, val);
|
||||
case V_RANDOM:
|
||||
@@ -189,7 +218,8 @@ hashvalue(VALUE *vp, QCKHASH val)
|
||||
case V_BLOCK:
|
||||
return blk_hash(vp->v_block, val);
|
||||
case V_OCTET:
|
||||
return fnv((int)*vp->v_octet, V_OCTET+val);
|
||||
val += V_OCTET;
|
||||
return quasi_fnv((int)*vp->v_octet, val);
|
||||
case V_NBLOCK:
|
||||
return blk_hash(vp->v_nblock->blk, val);
|
||||
default:
|
||||
@@ -207,7 +237,8 @@ static QCKHASH
|
||||
assochash(ASSOC *ap, QCKHASH val)
|
||||
{
|
||||
/* XXX - hash the first and last values??? */
|
||||
return fnv(ap->a_count, V_ASSOC+val);
|
||||
val += V_ASSOC;
|
||||
return quasi_fnv(ap->a_count, val);
|
||||
}
|
||||
|
||||
|
||||
@@ -250,15 +281,16 @@ mathash(MATRIX *m, QCKHASH val)
|
||||
/*
|
||||
* hash size parts of the matrix
|
||||
*/
|
||||
val = fnv(m->m_dim, V_MAT+val);
|
||||
val = fnv(m->m_size, val);
|
||||
val += V_MAT;
|
||||
quasi_fnv(m->m_dim, val);
|
||||
quasi_fnv(m->m_size, val);
|
||||
|
||||
/*
|
||||
* hash the matrix index bounds
|
||||
*/
|
||||
for (i = m->m_dim - 1; i >= 0; i--) {
|
||||
val = fnv(m->m_min[i], val);
|
||||
val = fnv(m->m_max[i], val);
|
||||
quasi_fnv(m->m_min[i], val);
|
||||
quasi_fnv(m->m_max[i], val);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -294,7 +326,7 @@ objhash(OBJECT *op, QCKHASH val)
|
||||
{
|
||||
int i;
|
||||
|
||||
val = fnv(op->o_actions->oa_index, val);
|
||||
quasi_fnv(op->o_actions->oa_index, val);
|
||||
|
||||
i = op->o_actions->oa_count;
|
||||
while (--i >= 0)
|
||||
@@ -323,10 +355,11 @@ randhash(RAND *r, QCKHASH val)
|
||||
return V_RAND+val;
|
||||
} else {
|
||||
/* hash control values */
|
||||
val = fnv(r->j, V_RAND+val);
|
||||
val = fnv(r->k, val);
|
||||
val = fnv(r->bits, val);
|
||||
val = fnv(r->need_to_skip, val);
|
||||
val += V_RAND;
|
||||
quasi_fnv(r->j, val);
|
||||
quasi_fnv(r->k, val);
|
||||
quasi_fnv(r->bits, val);
|
||||
quasi_fnv(r->need_to_skip, val);
|
||||
|
||||
/* hash the state arrays */
|
||||
return fnv_fullhash(&r->buffer[0], SLEN+SCNT+SHUFLEN, val);
|
||||
@@ -356,7 +389,8 @@ randomhash(RANDOM *state, QCKHASH val)
|
||||
/*
|
||||
* hash a seeded RANDOM state
|
||||
*/
|
||||
val = fnv(state->buffer+state->bits, V_RANDOM+val);
|
||||
val += V_RANDOM;
|
||||
quasi_fnv(state->buffer+state->bits, val);
|
||||
if (state->r.v != NULL) {
|
||||
val = fnv_zhash(state->r, val);
|
||||
}
|
||||
@@ -382,6 +416,7 @@ config_hash(CONFIG *cfg, QCKHASH val)
|
||||
*/
|
||||
value = cfg->outmode;
|
||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->outmode);
|
||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->outmode2);
|
||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->outdigits);
|
||||
/* epsilon is handeled out of order */
|
||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->epsilonprec);
|
||||
@@ -418,15 +453,24 @@ config_hash(CONFIG *cfg, QCKHASH val)
|
||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->ctrl_d);
|
||||
/* program is handeled out of order */
|
||||
/* basename is handeled out of order */
|
||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->windows);
|
||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->cygwin);
|
||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->compile_custom);
|
||||
if (cfg->allow_custom != NULL && *(cfg->allow_custom)) {
|
||||
value = (((value>>5) | (value<<27)) ^ (USB32)TRUE);
|
||||
} else {
|
||||
value = (((value>>5) | (value<<27)) ^ (USB32)FALSE);
|
||||
}
|
||||
/* version is handeled out of order */
|
||||
|
||||
/*
|
||||
* hash the built up scalar
|
||||
*/
|
||||
val = fnv(value, V_CONFIG+val);
|
||||
val += V_CONFIG;
|
||||
quasi_fnv(value, val);
|
||||
|
||||
/*
|
||||
* hash the strings if possible
|
||||
* hash the strings and pointers if possible
|
||||
*/
|
||||
if (cfg->prompt1) {
|
||||
val = fnv_strhash(cfg->prompt1, val);
|
||||
@@ -471,7 +515,7 @@ fnv_strhash(char *ch, QCKHASH val)
|
||||
* hash each character in the string
|
||||
*/
|
||||
while (*ch) {
|
||||
val = fnv(*ch++, val);
|
||||
quasi_fnv(*ch++, val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
@@ -499,7 +543,7 @@ fnv_STRhash(STRING *str, QCKHASH val)
|
||||
* hash each character in the string
|
||||
*/
|
||||
while (n-- > 0) {
|
||||
val = fnv(*ch++, val);
|
||||
quasi_fnv(*ch++, val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
@@ -523,7 +567,7 @@ fnv_fullhash(FULL *v, LEN len, QCKHASH val)
|
||||
* hash each character in the string
|
||||
*/
|
||||
while (len-- > 0) {
|
||||
val = fnv(*v++, val);
|
||||
quasi_fnv(*v++, val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
@@ -551,7 +595,8 @@ fnv_zhash(ZVALUE z, QCKHASH val)
|
||||
/*
|
||||
* hash the sign
|
||||
*/
|
||||
val = fnv(z.sign, val + V_NUM);
|
||||
val += V_NUM;
|
||||
quasi_fnv(z.sign, val);
|
||||
|
||||
n = z.len;
|
||||
hp = z.v;
|
||||
@@ -560,15 +605,15 @@ fnv_zhash(ZVALUE z, QCKHASH val)
|
||||
while (n > 1) {
|
||||
f = (FULL) *hp++;
|
||||
f |= (FULL) *hp++ << BASEB;
|
||||
val = fnv(f, val);
|
||||
quasi_fnv(f, val);
|
||||
n -= 2;
|
||||
}
|
||||
if (n) {
|
||||
val = fnv(*hp, val);
|
||||
quasi_fnv(*hp, val);
|
||||
}
|
||||
#else
|
||||
while (n-- > 0) {
|
||||
val = fnv(*hp, val);
|
||||
quasi_fnv(*hp, val);
|
||||
++hp;
|
||||
}
|
||||
#endif
|
||||
@@ -595,7 +640,7 @@ hash_hash(HASH *hash, QCKHASH val)
|
||||
* hash each USB8 in the BLOCK
|
||||
*/
|
||||
for (i=0; i < hash->unionsize; ++i) {
|
||||
val = fnv(hash->h_union.data[i], val);
|
||||
quasi_fnv(hash->h_union.data[i], val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
@@ -624,7 +669,7 @@ blk_hash(BLOCK *blk, QCKHASH val)
|
||||
*/
|
||||
if (blk->datalen > 0) {
|
||||
for (i=0; i < blk->datalen; ++i) {
|
||||
val = fnv(blk->data[i], val);
|
||||
quasi_fnv(blk->data[i], val);
|
||||
}
|
||||
}
|
||||
return val;
|
||||
|
183
rpm.mk
Normal file
183
rpm.mk
Normal file
@@ -0,0 +1,183 @@
|
||||
#!/bin/make
|
||||
#****h* calc/rpm.mk
|
||||
#
|
||||
# rpm.mk - Makefile for building rpm packages for calc
|
||||
#
|
||||
# Copyright (C) 2003 Petteri Kettunen and Landon Curt Noll
|
||||
#
|
||||
# Calc is open software; you can redistribute it and/or modify it under
|
||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
# Public License for more details.
|
||||
#
|
||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
MAKEFILE_REV= $$Revision: 29.13 $$
|
||||
# @(#) $Id: rpm.mk,v 29.13 2003/04/15 03:39:17 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/rpm.mk,v $
|
||||
#
|
||||
# Under source code control: 2003/02/16 20:21:39
|
||||
# File existed as early as: 2003
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
#
|
||||
# calculator by David I. Bell with help/mods from others
|
||||
# Makefile by Petteri Kettunen with modifications from Landon Curt Noll
|
||||
|
||||
# setup
|
||||
#
|
||||
SHELL= /bin/sh
|
||||
RPMBUILD_TOOL= rpmbuild
|
||||
TARCH= i686
|
||||
RPMBUILD_OPTION= -ba --target=${TARCH}
|
||||
RPM_TOOL= rpm
|
||||
MD5SUM= md5sum
|
||||
SHA1SUM= sha1sum
|
||||
SED= sed
|
||||
|
||||
# rpm-related parameters
|
||||
#
|
||||
PROJECT_NAME= calc
|
||||
PROJECT_VERSION=
|
||||
PROJECT_RELEASE=
|
||||
PROJECT= $(PROJECT_NAME)-$(PROJECT_VERSION)
|
||||
SPECFILE= $(PROJECT_NAME).spec
|
||||
TARBALL= $(PROJECT).tar.gz
|
||||
RPM686= $(PROJECT)-$(PROJECT_RELEASE).${TARCH}.rpm
|
||||
DRPM686= $(PROJECT_NAME)-devel-$(PROJECT_VERSION)-$(PROJECT_RELEASE).${TARCH}.rpm
|
||||
SRPM= $(PROJECT)-$(PROJECT_RELEASE).src.rpm
|
||||
TMPDIR= /var/tmp
|
||||
RHDIR= /usr/src/redhat
|
||||
|
||||
all: calc.spec ver_calc
|
||||
$(MAKE) -f rpm.mk PROJECT_VERSION="`./ver_calc`" \
|
||||
PROJECT_RELEASE="`${SED} -n -e '/^Release:/s/^Release: *//p' \
|
||||
calc.spec.in`" rpm
|
||||
|
||||
pkgme: $(PROJECT_NAME)-spec.tar.gz
|
||||
|
||||
ver_calc:
|
||||
$(MAKE) -f Makefile ver_calc
|
||||
|
||||
.PHONY: vers
|
||||
vers:
|
||||
$(MAKE) -f Makefile ver_calc
|
||||
|
||||
calc.spec: calc.spec.in ver_calc
|
||||
rm -f calc.spec
|
||||
${SED} -e 's/<<<PROJECT_VERSION>>>/'"`./ver_calc`"/g \
|
||||
calc.spec.in > calc.spec
|
||||
|
||||
.PHONY: srcpkg
|
||||
srcpkg: make_rhdir
|
||||
find . -depth -print | egrep -v '/RCS|/CVS|/NOTES|\.gone' | \
|
||||
cpio -dumpv $(TMPDIR)/$(PROJECT)
|
||||
(cd $(TMPDIR); tar cf - $(PROJECT) | \
|
||||
gzip -c > $(RHDIR)/SOURCES/$(TARBALL))
|
||||
rm -fr $(TMPDIR)/$(PROJECT)
|
||||
|
||||
.PHONY: rpm
|
||||
rpm: srcpkg calc.spec
|
||||
$(MAKE) -f Makefile clean
|
||||
cp $(SPECFILE) $(RHDIR)/SPECS/$(SPECFILE)
|
||||
rm -f $(RHDIR)/RPMS/${TARCH}/$(RPM686)
|
||||
rm -f $(RHDIR)/RPMS/${TARCH}/$(DRPM686)
|
||||
rm -f $(RHDIR)/SRPMS/$(SRPM)
|
||||
${RPMBUILD_TOOL} ${RPMBUILD_OPTION} $(RHDIR)/SPECS/$(SPECFILE)
|
||||
@if [ ! -f "$(RHDIR)/SRPMS/$(SRPM)" ]; then \
|
||||
echo "SRPMS/$(SRPM) not found" 1>&2; \
|
||||
exit 3; \
|
||||
fi
|
||||
@echo
|
||||
@echo "RPM package sizes:"
|
||||
@echo
|
||||
@cd $(RHDIR); ls -1s RPMS/${TARCH}/$(RPM686) \
|
||||
RPMS/${TARCH}/$(DRPM686) SRPMS/$(SRPM)
|
||||
@echo
|
||||
@echo "RPM package md5 hashes:"
|
||||
@echo
|
||||
-@cd $(RHDIR); ${MD5SUM} RPMS/${TARCH}/$(RPM686) \
|
||||
RPMS/${TARCH}/$(DRPM686) SRPMS/$(SRPM)
|
||||
@echo
|
||||
@echo "RPM package sha1 hashes:"
|
||||
@echo
|
||||
-@cd $(RHDIR); ${SHA1SUM} RPMS/${TARCH}/$(RPM686) \
|
||||
RPMS/${TARCH}/$(DRPM686) SRPMS/$(SRPM)
|
||||
@echo
|
||||
@echo "RPM package locations:"
|
||||
@echo
|
||||
@ls -1 $(RHDIR)/RPMS/${TARCH}/$(RPM686) \
|
||||
$(RHDIR)/RPMS/${TARCH}/$(DRPM686) $(RHDIR)/SRPMS/$(SRPM)
|
||||
@echo
|
||||
@echo "All done! -- Jessica Noll, Age 2"
|
||||
@echo
|
||||
|
||||
.PHONY: make_rhdir
|
||||
make_rhdir:
|
||||
for i in $(RHDIR) $(RHDIR)/RPMS $(RHDIR)/SOURCES \
|
||||
$(RHDIR)/SPECS $(RHDIR)/SRPMS $(RHDIR)/BUILD; do \
|
||||
if [ ! -d $$i ] ; then \
|
||||
mkdir -p $$i; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
# date format for spec file
|
||||
.PHONY: logdate
|
||||
logdate:
|
||||
echo "`date +'* %a %b %d %Y'` `whoami`"
|
||||
|
||||
.PHONY: chkpkg
|
||||
chkpkg:
|
||||
for i in $(RHDIR)/RPMS/${TARCH}/$(RPM686) \
|
||||
$(RHDIR)/RPMS/${TARCH}/$(DRPM686) \
|
||||
$(RHDIR)/SRPMS/$(SRPM) ; do \
|
||||
echo "***** start $$i" ; \
|
||||
${RPM_TOOL} -qpi $$i ; \
|
||||
echo "***** files $$i" ; \
|
||||
${RPM_TOOL} -qpl $$i ; \
|
||||
echo "***** end $$i" ; \
|
||||
done ;
|
||||
|
||||
.PHONY: chksys
|
||||
chksys:
|
||||
${RPM_TOOL} -qa | grep $(PROJECT_NAME)
|
||||
${RPM_TOOL} -qa | grep $(PROJECT_NAME)-devel
|
||||
|
||||
.PHONY: test
|
||||
test: ver_calc
|
||||
@if [ X"`id -u`" != X"0" ]; then \
|
||||
echo "test needs to install, must be root to test" 1>&2; \
|
||||
exit 4; \
|
||||
fi
|
||||
$(MAKE) -f rpm.mk PROJECT_VERSION="`./ver_calc`" installrpm chksys
|
||||
|
||||
.PHONY: installrpm
|
||||
installrpm:
|
||||
@if [ X"`id -u`" != X"0" ]; then \
|
||||
echo "must be root to install RPMs" 1>&2; \
|
||||
exit 5; \
|
||||
fi
|
||||
${RPM_TOOL} -ivh $(RHDIR)/RPMS/${TARCH}/$(RPM686)
|
||||
${RPM_TOOL} -ivh $(RHDIR)/RPMS/${TARCH}/$(DRPM686)
|
||||
|
||||
.PHONY: uninstallrpm
|
||||
uninstallrpm:
|
||||
@if [ X"`id -u`" != X"0" ]; then \
|
||||
echo "must be root to uninstall RPMs" 1>&2; \
|
||||
exit 6; \
|
||||
fi
|
||||
${RPM_TOOL} -e $(PROJECT_NAME)-devel
|
||||
${RPM_TOOL} -e $(PROJECT_NAME)
|
||||
|
||||
$(PROJECT_NAME)-spec.tar.gz: rpm.mk $(PROJECT_NAME).spec.in
|
||||
tar cf - $^ | gzip -c > $@
|
||||
|
||||
#****
|
133
sample/Makefile
133
sample/Makefile
@@ -17,8 +17,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.14 $
|
||||
# @(#) $Id: Makefile,v 29.14 2001/06/08 22:38:53 chongo Exp $
|
||||
# @(#) $Revision: 29.17 $
|
||||
# @(#) $Id: Makefile,v 29.17 2003/01/14 02:00:23 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/sample/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/04/19 22:46:49
|
||||
@@ -75,41 +75,111 @@ SAMPLE_OBJ= many_random.o test_random.o
|
||||
#Q=
|
||||
Q=@
|
||||
|
||||
####
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
####
|
||||
|
||||
# Where the system include (.h) files are kept
|
||||
#
|
||||
# where things go
|
||||
# For DJGPP, select:
|
||||
#
|
||||
# ${BINDIR} where to install binary files
|
||||
# ${SHAREDIR} where most common shared files are kept
|
||||
# ${INCDIR} where most .h files are kept
|
||||
# ${LIBDIR} where *.a files are installed
|
||||
# INCDIR= /dev/env/DJDIR/include
|
||||
#
|
||||
# ${CSHAREDIR} where most common shared calc files are kept
|
||||
# ${HELPDIR} where the help directory is installed.
|
||||
# If in doubt, set:
|
||||
#
|
||||
# INCDIR= /usr/include
|
||||
#
|
||||
|
||||
#INCDIR= /usr/local/include
|
||||
#INCDIR= /dev/env/DJDIR/include
|
||||
INCDIR= /usr/include
|
||||
|
||||
# where to install calc realted things
|
||||
#
|
||||
# ${BINDIR} where to install calc binary files
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
# BINDIR= /dev/env/DJDIR/bin
|
||||
# LIBDIR= /dev/env/DJDIR/lib
|
||||
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# BINDIR= /usr/bin
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
#BINDIR= /usr/local/bin
|
||||
#BINDIR= /dev/env/DJDIR/bin
|
||||
BINDIR= /usr/bin
|
||||
#BINDIR= /usr/contrib/bin
|
||||
#
|
||||
#SHAREDIR= /usr/local/lib
|
||||
SHAREDIR= /usr/share
|
||||
#
|
||||
#INCDIR= /usr/local/include
|
||||
INCDIR= /usr/include
|
||||
#
|
||||
|
||||
#LIBDIR= /usr/local/lib
|
||||
#LIBDIR= /dev/env/DJDIR/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
CSHAREDIR= ${SHAREDIR}/calc
|
||||
HELPDIR= ${LIBDIR}/help
|
||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||
CALC_SHAREDIR= /usr/share/calc
|
||||
|
||||
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
|
||||
# ---------------------------------------------------------------
|
||||
# ${HELPDIR} where the help directory is installed
|
||||
# ${CALC_INCDIR} where the calc include files are installed
|
||||
# ${CUSTOMCALDIR} where custom *.cal files are installed
|
||||
# ${CUSTOMHELPDIR} where custom help files are installed
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed
|
||||
# ${SCRIPTDIR} where calc shell scripts are installed
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
# HELPDIR= ${CALC_SHAREDIR}/help
|
||||
# CALC_INCDIR= ${INCDIR}/calc
|
||||
# CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
||||
# CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
||||
# CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
||||
# SCRIPTDIR= ${BINDIR}/cscript
|
||||
#
|
||||
HELPDIR= ${CALC_SHAREDIR}/help
|
||||
CALC_INCDIR= ${INCDIR}/calc
|
||||
CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
||||
CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
||||
CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
||||
SCRIPTDIR= ${BINDIR}/cscript
|
||||
|
||||
# T - top level directory under which calc will be installed
|
||||
#
|
||||
# The calc install is performed under $T, the calc build is
|
||||
# performed under /. The purpose for $T is to allow someone to
|
||||
# install calc somewhere other than into the system area. For example
|
||||
# when forming the calc rpm, the Makefile is called with T=$RPM_BUILD_ROOT.
|
||||
# performed under /. The purpose for $T is to allow someone
|
||||
# to install calc somewhere other than into the system area.
|
||||
#
|
||||
# For example, if:
|
||||
#
|
||||
# BINDIR= /usr/bin
|
||||
# LIBDIR= /usr/lib
|
||||
# CALC_SHAREDIR= /usr/share/calc
|
||||
#
|
||||
# and if:
|
||||
#
|
||||
# T= /var/tmp/testing
|
||||
#
|
||||
# Then the installation locations will be:
|
||||
#
|
||||
# calc binary files: /var/tmp/testing/usr/bin
|
||||
# calc link library: /var/tmp/testing/usr/lib
|
||||
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
# ... etc ... /var/tmp/testing/...
|
||||
#
|
||||
# If $T is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If $T is non-empty, then
|
||||
@@ -359,8 +429,10 @@ many_random: many_random.o ../libcalc.a
|
||||
##
|
||||
|
||||
distlist: ${DISTLIST}
|
||||
${Q}for i in ${DISTLIST}; do \
|
||||
${Q}for i in ${DISTLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo sample/$$i; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
distdir:
|
||||
@@ -396,11 +468,14 @@ depend:
|
||||
-${Q}rm -rf skel
|
||||
${Q}mkdir skel
|
||||
${Q}mkdir skel/sample
|
||||
-${Q}for i in ${C_SRC}; do \
|
||||
-${Q}for i in ${C_SRC} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' \
|
||||
"$$i" > "skel/sample/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${H_SRC} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/sample/$$i"; \
|
||||
@@ -409,18 +484,21 @@ depend:
|
||||
>> "skel/sample/$$i"; \
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/sample/$$i"; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
${Q}(cd ..; ${MAKE} hsrc)
|
||||
${Q}for i in `cd ..; ${MAKE} h_list 2>&1 | \
|
||||
${SED} -e '/Entering directory/d' \
|
||||
-e '/Nothing to be done/d' \
|
||||
-e '/Leaving directory/d'`; do \
|
||||
-e '/Leaving directory/d'` /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
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"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}rm -f skel/sample/makedep.out
|
||||
${Q}echo sample/skel formed
|
||||
@@ -428,8 +506,10 @@ depend:
|
||||
${Q}echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > \
|
||||
skel/sample/makedep.out
|
||||
${Q}cd skel/sample; ${MAKEDEPEND} -w 1 -f makedep.out -I.. ${C_SRC}
|
||||
-${Q}for i in ${C_SRC}; do \
|
||||
-${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/'; \
|
||||
fi; \
|
||||
done >> skel/sample/makedep.out
|
||||
${Q}echo sample dependency list formed
|
||||
${Q}echo forming new sample/Makefile
|
||||
@@ -491,7 +571,6 @@ install: all
|
||||
|
||||
# DO NOT DELETE THIS LINE
|
||||
|
||||
|
||||
many_random.o: ../alloc.h
|
||||
many_random.o: ../block.h
|
||||
many_random.o: ../byteswap.h
|
||||
|
11
seed.c
11
seed.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* seed - produce a pseudo-random seeds
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2004 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,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: seed.c,v 29.5 2001/05/08 06:44:29 chongo Exp $
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: seed.c,v 29.7 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/seed.c,v $
|
||||
*
|
||||
* Under source code control: 1999/10/03 10:06:53
|
||||
@@ -41,6 +41,11 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "have_stdlib.h"
|
||||
#if defined(HAVE_STDLIB_H)
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "have_unistd.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
|
14
shs.c
14
shs.c
@@ -31,8 +31,8 @@
|
||||
* Based on Version 2.11 (09 Mar 1995) from Landon Curt Noll's
|
||||
* (http://www.isthe.com/chongo/) shs hash program.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: shs.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: shs.c,v 29.3 2004/02/23 08:14:15 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/shs.c,v $
|
||||
*
|
||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||
@@ -286,7 +286,7 @@ shsUpdate(HASH *state, USB8 *buffer, USB32 count)
|
||||
USB32 datalen = dig->datalen;
|
||||
USB32 cpylen;
|
||||
#if CALC_BYTE_ORDER == LITTLE_ENDIAN
|
||||
int i;
|
||||
unsigned int i;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -365,7 +365,7 @@ shsFinal(HASH *state)
|
||||
USB32 highBitcount;
|
||||
USB8 *data = (USB8 *) dig->data;
|
||||
#if CALC_BYTE_ORDER == LITTLE_ENDIAN
|
||||
int i;
|
||||
unsigned int i;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -433,7 +433,7 @@ shs_chkpt(HASH *state)
|
||||
{
|
||||
SHS_INFO *dig = &state->h_union.h_shs; /* digest state */
|
||||
#if CALC_BYTE_ORDER == LITTLE_ENDIAN
|
||||
int i;
|
||||
unsigned int i;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -478,7 +478,7 @@ static void
|
||||
shs_note(int special, HASH *state)
|
||||
{
|
||||
SHS_INFO *dig = &state->h_union.h_shs; /* digest state */
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* change state to reflect a special value
|
||||
@@ -509,7 +509,7 @@ static void
|
||||
shs_type(int type, HASH *state)
|
||||
{
|
||||
SHS_INFO *dig = &state->h_union.h_shs; /* digest state */
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* ignore NUMBER and COMPLEX
|
||||
|
14
shs1.c
14
shs1.c
@@ -22,8 +22,8 @@
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: shs1.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: shs1.c,v 29.3 2004/02/23 08:15:52 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/shs1.c,v $
|
||||
*
|
||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||
@@ -261,7 +261,7 @@ shs1Update(HASH *state, USB8 *buffer, USB32 count)
|
||||
USB32 datalen = dig->datalen;
|
||||
USB32 cpylen;
|
||||
#if CALC_BYTE_ORDER == LITTLE_ENDIAN
|
||||
int i;
|
||||
unsigned int i;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -341,7 +341,7 @@ shs1Final(HASH *state)
|
||||
USB32 highBitcount;
|
||||
USB8 *data = (USB8 *) dig->data;
|
||||
#if CALC_BYTE_ORDER == LITTLE_ENDIAN
|
||||
int i;
|
||||
unsigned int i;
|
||||
#endif
|
||||
|
||||
/* Pad to end of chunk */
|
||||
@@ -411,7 +411,7 @@ shs1_chkpt(HASH *state)
|
||||
{
|
||||
SHS1_INFO *dig = &state->h_union.h_shs1; /* digest state */
|
||||
#if CALC_BYTE_ORDER == LITTLE_ENDIAN
|
||||
int i;
|
||||
unsigned int i;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -455,7 +455,7 @@ static void
|
||||
shs1_note(int special, HASH *state)
|
||||
{
|
||||
SHS1_INFO *dig = &state->h_union.h_shs1; /* digest state */
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* change state to reflect a special value
|
||||
@@ -486,7 +486,7 @@ static void
|
||||
shs1_type(int type, HASH *state)
|
||||
{
|
||||
SHS1_INFO *dig = &state->h_union.h_shs1; /* digest state */
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* ignore NUMBER and COMPLEX
|
||||
|
8
string.c
8
string.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* string - string list routines
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2004 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: string.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: string.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/string.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:10
|
||||
@@ -184,7 +184,7 @@ namestr(STRINGHEAD *hp, long n)
|
||||
{
|
||||
register char *str; /* current string */
|
||||
|
||||
if ((unsigned long)n >= hp->h_count)
|
||||
if (n >= hp->h_count)
|
||||
return "";
|
||||
str = hp->h_list;
|
||||
while (*str) {
|
||||
|
31
version.c
31
version.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* version - determine the version of calc
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Landon Curt Noll
|
||||
* Copyright (C) 1999-2004 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.37 $
|
||||
* @(#) $Id: version.c,v 29.37 2001/12/31 22:12:35 chongo Exp $
|
||||
* @(#) $Revision: 29.54 $
|
||||
* @(#) $Id: version.c,v 29.54 2004/10/23 01:16:23 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
|
||||
*
|
||||
* Under source code control: 1990/05/22 11:00:58
|
||||
@@ -43,10 +43,12 @@ static char *program;
|
||||
# include "calc.h"
|
||||
#endif
|
||||
|
||||
#include "have_unused.h"
|
||||
|
||||
#define MAJOR_VER 2 /* major version */
|
||||
#define MINOR_VER 11 /* minor version */
|
||||
#define MAJOR_PATCH 5 /* patch level or 0 if no patch */
|
||||
#define MINOR_PATCH 6 /* test number or 0 if no minor patch */
|
||||
#define MAJOR_PATCH 10 /* patch level or 0 if no patch */
|
||||
#define MINOR_PATCH 1 /* test number or 0 if no minor patch */
|
||||
|
||||
|
||||
/*
|
||||
@@ -70,7 +72,7 @@ static char *stored_version = NULL; /* version formed if != NULL */
|
||||
char *Copyright = "\n"
|
||||
"calc - arbitrary precision calculator\n"
|
||||
"\n"
|
||||
"@(#) Copyright (C) 1999 David I. Bell, Landon Curt Noll and Ernest Bowen\n"
|
||||
"@(#) Copyright (C) 2003 David I. Bell, Landon Curt Noll and Ernest Bowen\n"
|
||||
"\n"
|
||||
"Primary author: David I. Bell\n"
|
||||
"\n"
|
||||
@@ -93,6 +95,23 @@ char *Copyright = "\n"
|
||||
"\n";
|
||||
|
||||
|
||||
#if !defined(HAVE_SNPRINTF)
|
||||
/* Simulate snprintf with vsprintf, hoping that BUFSIZ is large enough. */
|
||||
#include <stdarg.h>
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
snprintf (char *buf, size_t UNUSED n, const char *fmt, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list arg;
|
||||
|
||||
va_start (arg, fmt);
|
||||
retval = vsprintf (buf, fmt, arg);
|
||||
va_end (arg);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* version - return version string
|
||||
*
|
||||
|
24
win32.mkdef
24
win32.mkdef
@@ -2,7 +2,6 @@ TERMCONTROL=-DUSE_WIN32
|
||||
HAVE_VSPRINTF=-UDONT_HAVE_VSPRINTF
|
||||
BYTE_ORDER=-DLITTLE_ENDIAN
|
||||
LONG_BITS=32
|
||||
LONGLONG_BITS=0
|
||||
HAVE_FPOS=-DHAVE_NO_FPOS
|
||||
HAVE_FPOS_POS=-DHAVE_NO_FPOS_POS
|
||||
FPOS_POS_BITS=-UFPOS_POS_BITS
|
||||
@@ -24,7 +23,7 @@ HAVE_GETPRID=-DHAVE_NO_GETPRID
|
||||
HAVE_URANDOM_H=NO
|
||||
HAVE_GETRUSAGE=-DHAVE_NO_GETRUSAGE
|
||||
HAVE_STRDUP=-UHAVE_NO_STRDUP
|
||||
ALIGN32=-UMUST_ALIGN32
|
||||
ALIGN32=-DMUST_ALIGN32
|
||||
HAVE_MALLOC_H=YES
|
||||
HAVE_STDLIB_H=YES
|
||||
HAVE_STRING_H=YES
|
||||
@@ -34,25 +33,28 @@ HAVE_TIME_H=YES
|
||||
HAVE_SYS_TIME_H=NO
|
||||
HAVE_UNISTD_H=NO
|
||||
|
||||
BINDIR=/usr/bin/calc
|
||||
LIBDIR=/lib/calc
|
||||
HELPDIR=/lib/calc/help
|
||||
INCDIRCALC=/include/calc
|
||||
CUSTOMLIBDIR=/lib/calc/custom
|
||||
CALC_INCDIR=/include/calc
|
||||
CUSTOMCALDIR=/lib/calc/custom
|
||||
CUSTOMHELPDIR=/lib/calc/help/custhelp
|
||||
SCRIPTDIR=/lib/calc/cscript
|
||||
MANDIR=
|
||||
CATDIR=
|
||||
MANEXT=
|
||||
CATEXT=
|
||||
NROFF=
|
||||
MANDIR=/usr/man/man1
|
||||
CATDIR=/usr/man/cat1
|
||||
MANEXT=1
|
||||
CATEXT=1
|
||||
NROFF=nroff
|
||||
NROFF_ARG=
|
||||
MANMAKE=
|
||||
MANMODE=
|
||||
CALCPATH=./cal
|
||||
CALCRC='/lib/calc/startup:~/.calcrc:./.calcinit'
|
||||
USE_READLINE=
|
||||
USE_READLINE=-DUSE_READLINE
|
||||
READLINE_LIB=
|
||||
READLINE_INCLUDE=
|
||||
CALCPAGER=
|
||||
CALCPAGER=less.exe
|
||||
|
||||
EXT=.exe
|
||||
|
||||
ECHO=
|
||||
|
@@ -8,8 +8,8 @@
|
||||
|
||||
|
||||
/* must we always align 32 bit accesses? */
|
||||
/* forced to not require 32 bit alignment */
|
||||
#undef MUST_ALIGN32
|
||||
/* forced to align 32 bit values */
|
||||
#define MUST_ALIGN32
|
||||
|
||||
|
||||
#endif /* !__MUST_ALIGN32_H__ */
|
||||
|
@@ -29,7 +29,7 @@
|
||||
|
||||
/* the default pager to use */
|
||||
#if !defined(DEFAULTCALCPAGER)
|
||||
#define DEFAULTCALCPAGER ""
|
||||
#define DEFAULTCALCPAGER "less.exe"
|
||||
#endif /* DEFAULTCALCPAGER */
|
||||
|
||||
/* where the echo command is located */
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#define __HAVE_MALLOC_H__
|
||||
|
||||
|
||||
/* do we have /usr/include/malloc.h? */
|
||||
/* do we have <malloc.h>? */
|
||||
#define HAVE_MALLOC_H /* yes */
|
||||
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#define __HAVE_STDLIB_H__
|
||||
|
||||
|
||||
/* do we have /usr/include/stdlib.h? */
|
||||
/* do we have <stdlib.h>? */
|
||||
#define HAVE_STDLIB_H /* yes */
|
||||
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#define __HAVE_STRING_H__
|
||||
|
||||
|
||||
/* do we have /usr/include/string.h? */
|
||||
/* do we have <string.h>? */
|
||||
#define HAVE_STRING_H /* yes */
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user