Compare commits

..

10 Commits

Author SHA1 Message Date
Landon Curt Noll
a6a37f9cad Release calc version 2.11.10 2017-05-21 15:38:45 -07:00
Landon Curt Noll
42b089a87c Release calc version 2.11.9.3 2017-05-21 15:38:44 -07:00
Landon Curt Noll
8c5e9e62fa Release calc version 2.11.9.2 2017-05-21 15:38:44 -07:00
Landon Curt Noll
29e956819c Release calc version 2.11.9.1 2017-05-21 15:38:44 -07:00
Landon Curt Noll
66c3d26611 Release calc version 2.11.9 2017-05-21 15:38:44 -07:00
Landon Curt Noll
b4952bd44f Release calc version 2.11.8.1 2017-05-21 15:38:44 -07:00
Landon Curt Noll
0d06d90751 Release calc version 2.11.8 2017-05-21 15:38:43 -07:00
Landon Curt Noll
e1a3dfda0b Release calc version 2.11.7 2017-05-21 15:38:43 -07:00
Landon Curt Noll
8db4e7af47 Release calc version 2.11.6.3 2017-05-21 15:38:43 -07:00
Landon Curt Noll
bb5c624382 Release calc version 2.11.6.1 2017-05-21 15:38:43 -07:00
80 changed files with 3999 additions and 1864 deletions

6
BUGS
View File

@@ -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
@@ -288,8 +288,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.18 $
## @(#) $Id: BUGS,v 29.18 2004/07/26 05:56:40 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/BUGS,v $
##
## Under source code control: 1994/03/18 14:06:13

420
CHANGES
View File

@@ -1,4 +1,254 @@
The following are the changes from calc version 2.11.6.0 to date:
The following are the changes from calc version 2.11.10 to date:
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 to no warrent trying to support this deprecated mode.
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 test 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.
@@ -132,7 +382,7 @@ The following are the changes from calc version 2.11.5.5 to 2.11.5.9:
Updated README.WINDOWS to include information on building with DJGPP.
The pld folks are building RPMs based on our calc distrbutions.
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
@@ -214,7 +464,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
@@ -222,13 +472,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.
@@ -275,7 +525,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! :-)
@@ -365,7 +615,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.
@@ -386,7 +636,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.
@@ -538,7 +788,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()
@@ -667,7 +917,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.
@@ -806,7 +1056,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
@@ -836,7 +1086,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>.
@@ -846,7 +1096,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
@@ -1084,7 +1334,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)
@@ -1223,11 +1473,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
@@ -1241,7 +1491,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
@@ -1284,7 +1534,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
@@ -1293,7 +1543,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
@@ -1312,7 +1562,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.
@@ -1362,7 +1612,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:
@@ -1385,7 +1635,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";
@@ -1454,7 +1704,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.
@@ -1601,11 +1851,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.
@@ -1907,13 +2157,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().
@@ -1987,7 +2237,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;
@@ -2200,7 +2450,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)
@@ -2657,16 +2907,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:
@@ -2738,7 +2988,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.
@@ -2801,7 +3051,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.
@@ -2864,7 +3114,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.
@@ -3010,7 +3260,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().
@@ -3058,13 +3308,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.
@@ -3083,14 +3333,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)
@@ -3115,7 +3365,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:
@@ -3169,7 +3419,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.
@@ -3214,14 +3464,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
@@ -3404,7 +3654,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.
@@ -3477,7 +3727,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;
@@ -3611,7 +3861,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;}
@@ -3869,7 +4119,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.
@@ -3910,7 +4160,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:
@@ -3925,13 +4175,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.
@@ -4046,7 +4296,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);
@@ -4152,9 +4402,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.
@@ -4170,7 +4420,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.
@@ -4261,7 +4511,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.
@@ -4284,7 +4534,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
@@ -4308,10 +4558,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.
@@ -4466,9 +4716,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>
@@ -4541,7 +4791,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.
@@ -4601,7 +4851,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
@@ -4620,7 +4870,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
@@ -4651,7 +4901,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
@@ -4725,7 +4975,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
@@ -4754,7 +5004,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
@@ -4762,7 +5012,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
@@ -4802,7 +5052,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.
@@ -4818,7 +5068,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.
@@ -4902,7 +5152,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,
@@ -4947,7 +5197,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.
@@ -5128,7 +5378,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.
@@ -5288,8 +5538,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.
@@ -5477,8 +5727,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.
@@ -5508,8 +5758,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.54 $
## @(#) $Id: CHANGES,v 29.54 2003/01/14 04:04:26 chongo Exp $
## @(#) $Revision: 29.69 $
## @(#) $Id: CHANGES,v 29.69 2004/08/03 12:29:19 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
##
## Under source code control: 1993/06/02 18:12:57

View File

@@ -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:

View File

@@ -1,4 +1,29 @@
Installing calc in 4 easy steps:
Installing calc from the gziped tarball in 4 easy steps:
0) If your platform supports i686 RPMs, you may want to go to:
http://www.isthe.com/chongo/src/calc/
and use these RPMs:
* calc*.i686.rpm
- all that is needed if you just want to use calc
* calc-devel-*.i686.rpm
- calc *.h header and *.a lib files for use in other programs
* calc.*.src.rpm
- calc source in RPM package form
The following 4 steps apply to calc source tree that comes from either:
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.
@@ -137,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.6 $
## @(#) $Id: HOWTO.INSTALL,v 29.6 2002/03/14 00:28:28 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

775
Makefile

File diff suppressed because it is too large Load Diff

View File

@@ -27,7 +27,6 @@ recommends the following settings:
TERMCONTROL= -DUSE_TERMIOS
BYTE_ORDER= -DLITTLE_ENDIAN
LONG_BITS= 32
LONGLONG_BITS= 64
HAVE_FPOS_POS= -DHAVE_NO_FPOS_POS
FPOS_BITS= 32
OFF_T_BITS= 32
@@ -93,25 +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:
@@ -155,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.8 $
## @(#) $Id: README.WINDOWS,v 29.8 2002/03/14 00:28:28 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
View File

@@ -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*/
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -1,7 +1,7 @@
/*
* regress - calc regression and correctness test suite
*
* Copyright (C) 1999-2002 David I. Bell and Landon Curt Noll
* 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.14 $
* @(#) $Id: regress.cal,v 29.14 2002/12/29 09:16:07 chongo Exp $
* @(#) $Revision: 29.19 $
* @(#) $Id: regress.cal,v 29.19 2004/02/23 14:04:01 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');
@@ -759,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');
@@ -1000,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');
@@ -1038,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');
@@ -2208,6 +2210,7 @@ print '033: read -once test2300';
define test_xx_incdec()
{
local A, B;
local n;
print '2300: Beginning object increment/decrement test';
@@ -2240,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()';

View File

@@ -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: repeat.cal,v 29.3 2003/01/14 04:03:20 chongo Exp $
* @(#) $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
@@ -48,6 +48,6 @@ define repeat(digit_set, repeat_count)
}
/* return repeated set of digits */
digit_count = max(digits(digit_set), 1);
digit_count = digits(digit_set);
return digit_set * (10^(digit_count*repeat_count)-1) / (10^digit_count-1);
}

20
calc.c
View File

@@ -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)) {

6
calc.h
View File

@@ -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: calc.h,v 29.10 2002/03/12 09:40:57 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
@@ -232,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 */

View File

@@ -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.9 $
.\" @(#) $Id: calc.man,v 29.9 2002/03/14 00:28:28 chongo Exp $
.\" @(#) $Revision: 29.15 $
.\" @(#) $Id: calc.man,v 29.15 2004/08/03 05:06:22 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\-f\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
@@ -302,11 +302,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 +327,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 +417,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 +425,7 @@ and
.sp 1
.in +5n
.nf
calc 'print sqrt(2), exp(1)'
calc "print sqrt(2), exp(1)"
.fi
.in -5n
.sp
@@ -577,7 +588,7 @@ as in:
.sp 1
.in +5n
.nf
\fI#!${BINDIR}/calc\fP\ \fB\-f\fP\ [other_flags\ \&...]
\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-f\fP
.fi
.in -5n
.sp 1
@@ -623,7 +634,7 @@ the file
.sp 1
.in +5n
.nf
\fI#!${BINDIR}/calc\fP\ \fB\-f\fP\ \&\fB\-q\fP
\fI#!${BINDIR}/calc\fP\ \&\fB\-q\fP \fB\-f\fP
#
# mersenne - an example of a calc \fBshell script file\fP
@@ -1086,7 +1097,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
View 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
#****

View File

@@ -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.7 $
* @(#) $Id: codegen.c,v 29.7 2002/07/10 11:51:51 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
@@ -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;

View File

@@ -1,7 +1,7 @@
/*
* config - configuration routines
*
* Copyright (C) 1999-2002 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.8 $
* @(#) $Id: config.c,v 29.8 2002/12/29 09:20:25 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)
@@ -92,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}
};
@@ -144,14 +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 */
MODE2_INITIAL, /* current output mode */
10, /* current output digits for float or exp */
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 */
@@ -161,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 */
@@ -170,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 */
@@ -190,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 */
@@ -857,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*/
@@ -921,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 {
@@ -968,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);
}
@@ -1239,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) {
@@ -1338,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);
}

View File

@@ -1,7 +1,7 @@
/*
* config - configuration routines
*
* Copyright (C) 1999-2002 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.12 $
* @(#) $Id: config.h,v 29.12 2002/12/29 09:20:25 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,19 +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
/*
@@ -99,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 */
@@ -157,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;
@@ -196,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
View File

@@ -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;

View File

@@ -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 */
/*

View File

@@ -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 */

View File

@@ -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

View File

@@ -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.20 $
# @(#) $Id: Makefile,v 29.20 2003/01/14 02:18:45 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 -=-=-=-=-=-=-#
@@ -765,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
@@ -791,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
@@ -817,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
@@ -828,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
@@ -843,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
@@ -872,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

View File

@@ -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";
}

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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
View 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 */

View File

@@ -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 */

View File

@@ -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",

View File

@@ -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 */

View File

@@ -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
View 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
View 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";
}

View File

@@ -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;

8
file.c
View File

@@ -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;

15
func.c
View File

@@ -1,7 +1,7 @@
/*
* func - built-in functions implemented here
*
* Copyright (C) 1999-2002 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.12 $
* @(#) $Id: func.c,v 29.12 2002/12/29 09:20:25 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"
@@ -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;
@@ -8026,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,
@@ -8344,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,

13
hash.c
View File

@@ -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: hash.c,v 29.5 2002/12/29 09:20:25 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
@@ -985,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
View 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;
}

View File

@@ -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.23 $
# @(#) $Id: Makefile,v 29.23 2003/01/14 02:24:48 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
@@ -170,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
@@ -250,8 +263,8 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd append \
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 dp epsilon errcount errmax errno error euler eval \
exp fact factor fclose fcnt feof ferror fflush fgetc fgetfield \
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 \
@@ -534,13 +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}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
${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"
@@ -625,12 +638,12 @@ 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}

View File

@@ -49,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
@@ -552,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.
@@ -699,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
@@ -725,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.7 $
## @(#) $Id: config,v 29.7 2002/12/29 08:32:04 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

View File

@@ -11,23 +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.
NOTE: both digits(0) and digits(1) return the value of 1.
This is not a bug, it is a feature of the above equation. :-)
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)
@@ -51,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.4 $
## @(#) $Id: digits,v 29.4 2003/01/14 04:09:35 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
View 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/

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -66,6 +66,8 @@ Very High priority items:
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:
@@ -83,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'.
@@ -122,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
@@ -140,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.4 $
## @(#) $Id: todo,v 29.4 2002/07/10 17:30:28 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

View File

@@ -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:
@@ -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.4 $
## @(#) $Id: usage,v 29.4 2002/07/10 11:47:04 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
View File

@@ -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";

View File

@@ -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.8 $
* @(#) $Id: lib_calc.c,v 29.8 2002/03/12 09:40:57 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 */
@@ -232,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;
}
/*

View File

@@ -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
}

View File

@@ -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;
}

View File

@@ -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
View File

@@ -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];
}

8
obj.c
View File

@@ -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}
};

View File

@@ -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
View File

@@ -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");

10
qio.c
View File

@@ -1,7 +1,7 @@
/*
* qio - scanf and printf routines for arbitrary precision rational numbers
*
* Copyright (C) 1999-2002 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.4 $
* @(#) $Id: qio.c,v 29.4 2002/12/29 09:20:25 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)
@@ -299,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;

View File

@@ -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);

View File

@@ -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.5 $
* @(#) $Id: qtrans.c,v 29.5 2004/02/23 14:04:01 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;

View File

@@ -1,5 +1,5 @@
/*
* 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-2002 Landon Curt Noll
*
@@ -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: quickhash.c,v 29.5 2002/12/29 09:20:25 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);
}
@@ -419,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);
@@ -472,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;
}
@@ -500,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;
}
@@ -524,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;
}
@@ -552,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;
@@ -561,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
@@ -596,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;
}
@@ -625,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
View 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 > $@
#****

6
seed.c
View File

@@ -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.6 $
* @(#) $Id: seed.c,v 29.6 2003/01/14 00:51:53 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

14
shs.c
View File

@@ -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
View File

@@ -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

View File

@@ -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) {

View File

@@ -1,7 +1,7 @@
/*
* version - determine the version of calc
*
* Copyright (C) 1999-2002 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.43 $
* @(#) $Id: version.c,v 29.43 2003/01/14 04:10:16 chongo Exp $
* @(#) $Revision: 29.53 $
* @(#) $Id: version.c,v 29.53 2004/07/27 23:49:41 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 6 /* patch level or 0 if no patch */
#define MINOR_PATCH 2 /* test number or 0 if no minor patch */
#define MAJOR_PATCH 10 /* patch level or 0 if no patch */
#define MINOR_PATCH 0 /* 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"
@@ -96,8 +98,9 @@ char *Copyright = "\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 n, const char *fmt, ...)
snprintf (char *buf, size_t UNUSED n, const char *fmt, ...)
{
int retval;
va_list arg;

View File

@@ -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
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=

View File

@@ -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__ */

View File

@@ -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 */

16
win32/have_unused.h Normal file
View File

@@ -0,0 +1,16 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_UNUSED_H__)
#define __HAVE_UNUSED_H__
/* do we have/want the unused attribute? */
#define HAVE_UNUSED /* yes */
#undef UNUSED
#define UNUSED __attribute__((unused)) /* yes */
#endif /* !__HAVE_UNUSED_H__ */

View File

@@ -21,11 +21,14 @@ typedef short SB16; /* signed 16 bits */
typedef unsigned long USB32; /* unsigned 32 bits */
typedef long SB32; /* signed 32 bits */
#undef HAVE_B64 /* we have no USB64 and no SB64 types */
#undef HAVE_B64
#define HAVE_B64 /* have USB64 and SB64 types */
typedef unsigned long long USB64; /* unsigned 64 bits */
typedef long long SB64; /* signed 64 bits */
/* no 64 bit constants */
#define U(x) no 33 to 64 bit constants - do not use this macro!
#define L(x) no 33 to 64 bit constants - do not use this macro!
/* how to form 64 bit constants */
#define U(x) x ## ULL
#define L(x) x ## LL
#endif /* !__LONGBITS_H__ */

View File

@@ -1,16 +0,0 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__LONGLONG_H__)
#define __LONGLONG_H__
/* do we have/want to use a long long type? */
#undef HAVE_LONGLONG
#define LONGLONG_BITS 0 /* no */
#undef L64_FORMAT
#endif /* !__LONGLONG_H__ */

12
zfunc.c
View File

@@ -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: zfunc.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: zfunc.c,v 29.4 2003/08/26 04:35:11 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zfunc.c,v $
*
* Under source code control: 1990/02/15 01:48:27
@@ -817,7 +817,9 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res)
needw = TRUE;
w = 0;
j = 0;
while (m) { /* START OF MAIN LOOP */
if (m - n < 2 || needw) {
q = 0;
u = *a0;
v = 1;
@@ -872,6 +874,8 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res)
else g &= BASE1;
}
else g = 1;
} else
g = (HALF) *a0 * w;
a = a0;
b = b0;
i = n;
@@ -947,6 +951,10 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res)
}
a0 += q;
m -= q;
while (m && !*a0) { /* Removing trailing zeros */
m--;
a0++;
}
}
while (m && !a0[m-1]) m--; /* Removing leading zeros */
}

37
zmath.h
View File

@@ -1,7 +1,7 @@
/*
* zmath - declarations for extended precision integer arithmetic
*
* Copyright (C) 1999-2002 David I. Bell
* Copyright (C) 1999,2002,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.10 $
* @(#) $Id: zmath.h,v 29.10 2003/01/14 00:44:39 chongo Exp $
* @(#) $Revision: 29.12 $
* @(#) $Id: zmath.h,v 29.12 2004/03/31 04:58:40 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zmath.h,v $
*
* Under source code control: 1993/07/30 19:42:48
@@ -637,35 +637,4 @@ typedef struct {
} BITSTR;
/*
* HVAL(a,b) - form an array of HALFs given 8 hex digits
* a: up to 4 hex digits without the leading 0x (upper half)
* b: up to 4 hex digits without the leading 0x (lower half)
*
* NOTE: Due to a SunOS cc bug, don't put spaces in the HVAL call!
*/
#if FULL_BITS == 64
# if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
# define HVAL(a,b) (HALF)(0x ## a ## b)
# else
# define HVAL(a,b) (HALF)(0x/**/a/**/b)
# endif
#elif 2*FULL_BITS == 64
# if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
# define HVAL(a,b) (HALF)0x##b, (HALF)0x##a
# else
/* NOTE: Due to a SunOS cc bug, don't put spaces in the HVAL call! */
# define HVAL(a,b) (HALF)0x/**/b, (HALF)0x/**/a
# endif
#else
/\../\ FULL_BITS must be 32 or 64 /\../\ !!!
#endif
#endif /* !__ZMATH_H__*/

726
zrand.c
View File

@@ -1,7 +1,7 @@
/*
* zrand - subtractive 100 shuffle generator
*
* 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: zrand.c,v 29.5 2003/01/14 00:54:24 chongo Exp $
* @(#) $Revision: 29.9 $
* @(#) $Id: zrand.c,v 29.9 2004/03/31 04:58:40 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zrand.c,v $
*
* Under source code control: 1995/01/07 09:45:25
@@ -357,6 +357,7 @@
#include "zrand.h"
#include "have_const.h"
#include "have_unused.h"
/*
@@ -378,190 +379,375 @@ static CONST RAND init_s100 = {
INIT_J, /* j */
INIT_K, /* k */
RAND_CONSEQ_USE, /* use this many before skipping values */
/* NOTE: Due to a SunOS cc bug, don't put spaces in the SVAL call! */
#if FULL_BITS == SBITS
{ /* subtractive 100 table */
SVAL(c8c0370c,7db7dc19), SVAL(738e33b9,40a06fbb),
SVAL(481abb76,a859ed2b), SVAL(74106bb3,9ccdccb5),
SVAL(05a8eeb5,c3173bfc), SVAL(efd5100d,5a02e577),
SVAL(a69271f7,4030b24a), SVAL(641282fc,16fe22c5),
SVAL(7aa7267c,40438da3), SVAL(1fdf4abd,c2d878d1),
SVAL(d9899e7a,95702379), SVAL(5ea8e217,d02d7f08),
SVAL(770587fe,4d47a353), SVAL(de7d1bdd,0a33a2b8),
SVAL(4378c3c5,900e7c45), SVAL(77c94478,19a514f9),
SVAL(fc5edb22,843d1d32), SVAL(4fc42ce5,e8ee5e6e),
SVAL(c938713c,8488013e), SVAL(6a318f03,20ab0cac),
SVAL(73e6d1a3,ffc8bff3), SVAL(0cd3232a,8ca96aa7),
SVAL(605c8036,905f770d), SVAL(4d037b00,8b8d04a2),
SVAL(1ed81965,cb277294), SVAL(408d9c47,7a254ff3),
SVAL(8b68587a,e26c7377), SVAL(cff191a4,8a48832f),
SVAL(12d3df1d,8aeb6fe6), SVAL(b2bf907e,1feda37a),
SVAL(4e5f7719,3bb5f39f), SVAL(33ebcf6f,8f5d1581),
SVAL(203c8e48,d33654eb), SVAL(68d3656e,f19c8a4e),
SVAL(3ec20b04,986eb2af), SVAL(5d73a03b,062c3841),
SVAL(836ce709,5d4e49eb), SVAL(2310bc40,c3f49221),
SVAL(3868ee48,a6d0cbf6), SVAL(67578aa6,4a43deb1),
SVAL(6e3426c1,150dfc26), SVAL(c541ccaa,3131be30),
SVAL(f7e57432,cec7aab2), SVAL(2b35de99,8cb3c873),
SVAL(7b9f7764,8663a5d7), SVAL(23b00e6a,a771e5a6),
SVAL(859c775c,a9985d05), SVAL(99636ea1,6b692f1f),
SVAL(8700ac70,3730800d), SVAL(46142502,4298a753),
SVAL(ea4a411b,809e955f), SVAL(3119ad40,33709dfb),
SVAL(b76a6c6e,5f01cb7c), SVAL(6109dc8a,15984eaf),
SVAL(5d686db9,a5ca9505), SVAL(8e80d761,3b7e6add),
SVAL(79cbd718,de6f6fd3), SVAL(40e9cd15,1da0f699),
SVAL(e82158ba,b24f312d), SVAL(79a4c927,f5e5c36b),
SVAL(c25247c9,a0039333), SVAL(93687116,1766d81d),
SVAL(3c6a03b4,a6741327), SVAL(c8a7b6e8,c002f29a),
SVAL(0e2a67c6,7bbd5ea3), SVAL(0929042d,441eabc1),
SVAL(7dbe232a,25e82085), SVAL(8cfb26e5,44fbac3d),
SVAL(8e40384d,388ab983), SVAL(48dc1230,554632f8),
SVAL(ab405048,ab492397), SVAL(21c9e2f5,a118e387),
SVAL(484d1a8c,343b61b5), SVAL(d49e3dec,ab256f26),
SVAL(e615c7fd,78f2d2e3), SVAL(8442cc33,ce6cc2ed),
SVAL(0a3b93d8,44d4bbf6), SVAL(2d7e4efe,9301de77),
SVAL(33711b76,d8790d8a), SVAL(c07dc30e,44df77e7),
SVAL(b9132ed0,9ddd508f), SVAL(45d06cf8,c6fb43cc),
SVAL(22bed18a,d585dd7b), SVAL(61c6cced,10799ffa),
SVAL(d7f2393b,e4bd9aa9), SVAL(706753fb,cfd55094),
SVAL(f65a6713,ede6e446), SVAL(8bf6dfae,47c0d5c3),
SVAL(fb4dfc17,9f7927d6), SVAL(12ebbc16,e212c297),
SVAL(43c71283,a00a954c), SVAL(8957087a,e7bd40a5),
SVAL(b0859d71,08344837), SVAL(fbf4b9a3,aeb313f5),
SVAL(5e66e5be,ce81823a), SVAL(09a11c6e,58ad6da1),
SVAL(c76f4316,c608054f), SVAL(b5821361,46084099),
SVAL(4210008f,17a725ed), SVAL(e5ff8912,d347c481)
(FULL)U(0xc8c0370c7db7dc19), (FULL)U(0x738e33b940a06fbb),
(FULL)U(0x481abb76a859ed2b), (FULL)U(0x74106bb39ccdccb5),
(FULL)U(0x05a8eeb5c3173bfc), (FULL)U(0xefd5100d5a02e577),
(FULL)U(0xa69271f74030b24a), (FULL)U(0x641282fc16fe22c5),
(FULL)U(0x7aa7267c40438da3), (FULL)U(0x1fdf4abdc2d878d1),
(FULL)U(0xd9899e7a95702379), (FULL)U(0x5ea8e217d02d7f08),
(FULL)U(0x770587fe4d47a353), (FULL)U(0xde7d1bdd0a33a2b8),
(FULL)U(0x4378c3c5900e7c45), (FULL)U(0x77c9447819a514f9),
(FULL)U(0xfc5edb22843d1d32), (FULL)U(0x4fc42ce5e8ee5e6e),
(FULL)U(0xc938713c8488013e), (FULL)U(0x6a318f0320ab0cac),
(FULL)U(0x73e6d1a3ffc8bff3), (FULL)U(0x0cd3232a8ca96aa7),
(FULL)U(0x605c8036905f770d), (FULL)U(0x4d037b008b8d04a2),
(FULL)U(0x1ed81965cb277294), (FULL)U(0x408d9c477a254ff3),
(FULL)U(0x8b68587ae26c7377), (FULL)U(0xcff191a48a48832f),
(FULL)U(0x12d3df1d8aeb6fe6), (FULL)U(0xb2bf907e1feda37a),
(FULL)U(0x4e5f77193bb5f39f), (FULL)U(0x33ebcf6f8f5d1581),
(FULL)U(0x203c8e48d33654eb), (FULL)U(0x68d3656ef19c8a4e),
(FULL)U(0x3ec20b04986eb2af), (FULL)U(0x5d73a03b062c3841),
(FULL)U(0x836ce7095d4e49eb), (FULL)U(0x2310bc40c3f49221),
(FULL)U(0x3868ee48a6d0cbf6), (FULL)U(0x67578aa64a43deb1),
(FULL)U(0x6e3426c1150dfc26), (FULL)U(0xc541ccaa3131be30),
(FULL)U(0xf7e57432cec7aab2), (FULL)U(0x2b35de998cb3c873),
(FULL)U(0x7b9f77648663a5d7), (FULL)U(0x23b00e6aa771e5a6),
(FULL)U(0x859c775ca9985d05), (FULL)U(0x99636ea16b692f1f),
(FULL)U(0x8700ac703730800d), (FULL)U(0x461425024298a753),
(FULL)U(0xea4a411b809e955f), (FULL)U(0x3119ad4033709dfb),
(FULL)U(0xb76a6c6e5f01cb7c), (FULL)U(0x6109dc8a15984eaf),
(FULL)U(0x5d686db9a5ca9505), (FULL)U(0x8e80d7613b7e6add),
(FULL)U(0x79cbd718de6f6fd3), (FULL)U(0x40e9cd151da0f699),
(FULL)U(0xe82158bab24f312d), (FULL)U(0x79a4c927f5e5c36b),
(FULL)U(0xc25247c9a0039333), (FULL)U(0x936871161766d81d),
(FULL)U(0x3c6a03b4a6741327), (FULL)U(0xc8a7b6e8c002f29a),
(FULL)U(0x0e2a67c67bbd5ea3), (FULL)U(0x0929042d441eabc1),
(FULL)U(0x7dbe232a25e82085), (FULL)U(0x8cfb26e544fbac3d),
(FULL)U(0x8e40384d388ab983), (FULL)U(0x48dc1230554632f8),
(FULL)U(0xab405048ab492397), (FULL)U(0x21c9e2f5a118e387),
(FULL)U(0x484d1a8c343b61b5), (FULL)U(0xd49e3decab256f26),
(FULL)U(0xe615c7fd78f2d2e3), (FULL)U(0x8442cc33ce6cc2ed),
(FULL)U(0x0a3b93d844d4bbf6), (FULL)U(0x2d7e4efe9301de77),
(FULL)U(0x33711b76d8790d8a), (FULL)U(0xc07dc30e44df77e7),
(FULL)U(0xb9132ed09ddd508f), (FULL)U(0x45d06cf8c6fb43cc),
(FULL)U(0x22bed18ad585dd7b), (FULL)U(0x61c6cced10799ffa),
(FULL)U(0xd7f2393be4bd9aa9), (FULL)U(0x706753fbcfd55094),
(FULL)U(0xf65a6713ede6e446), (FULL)U(0x8bf6dfae47c0d5c3),
(FULL)U(0xfb4dfc179f7927d6), (FULL)U(0x12ebbc16e212c297),
(FULL)U(0x43c71283a00a954c), (FULL)U(0x8957087ae7bd40a5),
(FULL)U(0xb0859d7108344837), (FULL)U(0xfbf4b9a3aeb313f5),
(FULL)U(0x5e66e5bece81823a), (FULL)U(0x09a11c6e58ad6da1),
(FULL)U(0xc76f4316c608054f), (FULL)U(0xb582136146084099),
(FULL)U(0x4210008f17a725ed), (FULL)U(0xe5ff8912d347c481)
},
/* NOTE: Due to a SunOS cc bug, don't put spaces in the SVAL call! */
{ /* shuffle table */
SVAL(69a2296c,ec8abd57), SVAL(867e1869,99a6df81),
SVAL(c05ab96b,d849a48a), SVAL(7eb3ce0c,fa00554b),
SVAL(520d01f6,5a5a9acd), SVAL(d4ef1e33,36022d81),
SVAL(af44772b,c6f84f70), SVAL(647e85a6,a7c55173),
SVAL(26746cf1,959df8d1), SVAL(98681a90,4db28abd),
SVAL(b146c969,744c5cd2), SVAL(8ce69d1f,706f88c2),
SVAL(fd12eac4,21b4a748), SVAL(f12e70fe,2710eea5),
SVAL(0b8f7805,5901f2b5), SVAL(48860a76,4f2c115e),
SVAL(0edf6d2a,30767e2c), SVAL(8a6d7dc5,fce2713b),
SVAL(46a362ea,4e0e2346), SVAL(6c369a0a,359f5aa7),
SVAL(dfca81fe,41def54e), SVAL(4b733819,96c2bc4e),
SVAL(659e8b99,6f3f14f9), SVAL(8b97b934,93d47e6f),
SVAL(a73a8704,dfa10a55), SVAL(8d9eafe9,b06503da),
SVAL(2556fb88,f32336b0), SVAL(e71e9f75,1002a161),
SVAL(27a7be6e,200af907), SVAL(1b9b734e,d028e9a3),
SVAL(950cfeed,4c0be0d3), SVAL(f4c41694,2536d275),
SVAL(f05a58e8,5687b76e), SVAL(ba53ac01,71a62d54),
SVAL(4b14cbcb,285adc96), SVAL(fdf66edd,b00a5557),
SVAL(bb43d58d,185b6ea1), SVAL(905db9cd,f355c9a6),
SVAL(fc3a07fc,04429c8a), SVAL(65d7e365,aa3a4f7e),
SVAL(2d284c18,b243ac65), SVAL(72fba65d,44e417fd),
SVAL(422d50b4,5c934805), SVAL(b62a6053,d1587441),
SVAL(a5e71ce9,6f7ae035), SVAL(93abca2e,595c8dd8),
SVAL(534231af,e39afad5), SVAL(08d26cac,12eaad56),
SVAL(ec18bf8d,7fb1b1c2), SVAL(3d28ea16,faf6f09b),
SVAL(ea357a78,16697dd6), SVAL(51471ea1,420f3f51),
SVAL(5e051aeb,7f8946b4), SVAL(881be097,0cf0524c),
SVAL(d558b25b,1b31489e), SVAL(707d1a94,3a8b065c),
SVAL(37017e66,568ff836), SVAL(b9cd627c,24c2f747),
SVAL(1485549f,fb1d9ff6), SVAL(308d32d9,bdf2dc6f),
SVAL(4d4142ca,d543818a), SVAL(5d9c7aee,87ebba43),
SVAL(81c5bdd8,e17adb2f), SVAL(3dc9752e,c8d8677a),
SVAL(66b086e6,c34e4212), SVAL(3af7a90d,c62b25e3),
SVAL(f8349f79,35539315), SVAL(6bcfd9d5,a22917f0),
SVAL(8639bb76,5f5ee517), SVAL(d3c5e369,8095b092),
SVAL(8a33851e,7eb44748), SVAL(5e29d443,ea54bbcf),
SVAL(0f84651f,4d59a834), SVAL(85040bea,f1a5f951),
SVAL(3dba1c74,98002078), SVAL(5d70712b,f0b2cc15),
SVAL(fa3af8eb,cce8e5a7), SVAL(fb3e2237,04bba57d),
SVAL(5d3b8785,8a950434), SVAL(ce3112bd,ba3f8dcf),
SVAL(44904f55,860d3051), SVAL(cec8fed4,4ed3e98b),
SVAL(4581698d,25d01ea4), SVAL(11eb6828,9a9548e0),
SVAL(796cb4c6,e911fac8), SVAL(2164cf26,b5fd813e),
SVAL(4ac8e0f5,d5de640f), SVAL(e9e757d7,8802ab4e),
SVAL(3c97de26,f49dfcbd), SVAL(c604881b,6ee6dbe6),
SVAL(a7c22a6e,57d6154e), SVAL(234e2370,877b3cc7),
SVAL(c0bdb72b,df1f8358), SVAL(6522e0fc,a95b7b55),
SVAL(ba174c90,22344162), SVAL(712c9b2d,75d48867),
SVAL(240f7e92,e59f3700), SVAL(e83cc2d4,ad95d763),
SVAL(8509445a,4336d717), SVAL(f1e572c5,dfff1804),
SVAL(ed10eb5d,623232dd), SVAL(9205ea1b,d4f957e8),
SVAL(4973a54f,2ff062f5), SVAL(26b018f1,e8c48cd5),
SVAL(56908401,d1c7ed9f), SVAL(2e48937b,df89a247),
SVAL(9d53069b,2be47129), SVAL(98069e3b,c048a2b0),
SVAL(f25b7d65,1cd83f93), SVAL(2b004e6c,e6f886c8),
SVAL(f618442a,5c635935), SVAL(a502ab5c,7198e052),
SVAL(c14241a4,a6c41b0b), SVAL(720e845a,7db9b18e),
SVAL(2abb13e9,4b713918), SVAL(90fc0c20,7f52467d),
SVAL(799c8ccd,7868d348), SVAL(f4817ced,912a0ea4),
SVAL(d68c0f4c,c4903a57), SVAL(a3171f29,e2b7934c),
SVAL(b1158baa,0b4ccc22), SVAL(f5d85553,49a29eda),
SVAL(59d1a078,959442ef), SVAL(db9b4a96,a67fd518),
SVAL(cc7ca9ee,d2870636), SVAL(548f021c,ecf59920),
SVAL(25b7f4b6,571bc8c5), SVAL(4fa52747,3a44f536),
SVAL(b246845f,df0ebdc2), SVAL(dd8d68ae,42058793),
SVAL(3ba13328,9f6c39fb), SVAL(8bfdfbf3,7b6b42af),
SVAL(fb34c5ca,7fb2b3b0), SVAL(2345dcec,d428e32a),
SVAL(6891e850,ad42b63e), SVAL(930642c8,362c1381),
SVAL(13871e9b,1886aff5), SVAL(d0cf2407,482bda55),
SVAL(125b5fc9,5069bc31), SVAL(9b71d0a9,f07dfa5d),
SVAL(55c044cc,6712e524), SVAL(f0377358,bb601978),
SVAL(152ad5f8,7fa51e8b), SVAL(e5ebf478,9fcdd9af),
SVAL(3d78e18c,66ebce7e), SVAL(8246db72,f36aa83f),
SVAL(cc6ddc6d,2c64c0a3), SVAL(a758d687,0d91851e),
SVAL(24b20a6f,9488ee36), SVAL(be11ccdf,09798197),
SVAL(11aca015,99c1f4e3), SVAL(40e89e36,6437ac05),
SVAL(c8bfc762,5af675f8), SVAL(6367c578,b577e759),
SVAL(00380346,615f0b74), SVAL(ee964cc4,8de07d81),
SVAL(17f6ac16,859d9261), SVAL(092f4a17,3a6e2f6c),
SVAL(79981a3d,b9024b95), SVAL(36db1660,04f7f540),
SVAL(c36252cf,65a2f1c8), SVAL(705b6fde,124c9bd2),
SVAL(31e58dda,85db40ce), SVAL(6342b1a5,9f5e8d6d),
SVAL(5c2c67d0,bd6d1d4d), SVAL(1fe5b46f,ba7e069d),
SVAL(21c46c6c,ac72e13c), SVAL(b80c5fd5,9eb8f52a),
SVAL(56c3aebf,a74c92bc), SVAL(c1aff1fc,bf8c4196),
SVAL(2b1df645,754ad208), SVAL(5c734600,d46eeb50),
SVAL(e0ff1b12,6a70a765), SVAL(d5416497,7a94547c),
SVAL(67b59d7c,4ea35206), SVAL(53be7146,779203b4),
SVAL(6b589fe5,414026b8), SVAL(9e81016c,3083bfee),
SVAL(b23526b9,3b4b7671), SVAL(4fa9ffb1,7ee300ba),
SVAL(6217e212,ad05fb21), SVAL(f5b3fcd3,b294e6c2),
SVAL(ac040bbe,216beb2a), SVAL(1f8d8a54,71d0e78c),
SVAL(b6d15b41,9cfec96b), SVAL(c5477845,d0508c78),
SVAL(5b486e81,b4bba621), SVAL(90c35c94,ef4c4121),
SVAL(efce7346,f6a6bc55), SVAL(a27828d9,25bdb9bb),
SVAL(e3a53095,a1f0b205), SVAL(1bfa6093,d9f208ab),
SVAL(fb078f6a,6842cdf4), SVAL(07806d72,97133a38),
SVAL(2c6c901b,a3ce9592), SVAL(1f0ab2cf,ebc1b789),
SVAL(2ce81415,e2d03d5e), SVAL(7da45d5b,aa9f2417),
SVAL(3be4f76d,dd800682), SVAL(dbf4e4a3,364d72d3),
SVAL(b538cccf,4fc59da5), SVAL(b0aa39d5,487f66ec),
SVAL(2fd28dfd,87927d3d), SVAL(d14e77f0,5900c6b1),
SVAL(2523fad2,5330c7b4), SVAL(991b5938,d82368a4),
SVAL(b7c11443,2b9c1302), SVAL(db842db6,1394b116),
SVAL(3641548d,78ed26d8), SVAL(274fa8ef,0a61dacf),
SVAL(a554ba63,112df6f1), SVAL(7b7fe985,6b50438d),
SVAL(c9fa0042,bb63bbad), SVAL(3abf45d0,e27f00da),
SVAL(d95faa15,9f87aabb), SVAL(4a95012e,3488e7ae),
SVAL(1be2bdb9,0c642d04), SVAL(145c8881,8b4abf3e),
SVAL(7f9fb635,544cf17f), SVAL(b8ab2f62,cc78db70),
SVAL(8ee64bcd,b4242f9a), SVAL(abd52858,95dad129),
SVAL(be722c2f,ccf31141), SVAL(7c330703,575e26a9),
SVAL(45d3e3b3,361b79e4), SVAL(241163a7,54b2e6a6),
SVAL(8f678d7d,f7cacb77), SVAL(988a68a4,83211d19),
SVAL(79599598,ba7836f6), SVAL(4850c887,eeda68bf),
SVAL(afa69a71,8052ce25), SVAL(8b21efc6,bdd73573),
SVAL(89dbae18,d0972493), SVAL(560776bf,537d9454),
SVAL(3c009f78,165310f2), SVAL(a3680021,0160c3af),
SVAL(3353ec3c,a643bd40), SVAL(7e593f99,911dab02),
SVAL(72d1ddd9,4f676e89), SVAL(fd18b8bd,6b43c0ea),
SVAL(43cacef2,ddbd697d), SVAL(2868a4d0,acefe884),
SVAL(5f377b63,a506f013), SVAL(eaa0975e,05ca662b),
SVAL(3740e6b8,eb433931), SVAL(ce85df00,08557948),
SVAL(784745fb,547e33f9), SVAL(4a1fc5d4,e5c6f598),
SVAL(85fa6fec,768430a7), SVAL(990d0c24,d2332a51),
SVAL(55245c2c,33b676d5), SVAL(b1091519,e2bcfa71),
SVAL(38521478,d23a28d8), SVAL(9b794f89,9a573010),
SVAL(61d225e8,699bb486), SVAL(21476d24,1c2158b0)
(FULL)U(0x69a2296cec8abd57), (FULL)U(0x867e186999a6df81),
(FULL)U(0xc05ab96bd849a48a), (FULL)U(0x7eb3ce0cfa00554b),
(FULL)U(0x520d01f65a5a9acd), (FULL)U(0xd4ef1e3336022d81),
(FULL)U(0xaf44772bc6f84f70), (FULL)U(0x647e85a6a7c55173),
(FULL)U(0x26746cf1959df8d1), (FULL)U(0x98681a904db28abd),
(FULL)U(0xb146c969744c5cd2), (FULL)U(0x8ce69d1f706f88c2),
(FULL)U(0xfd12eac421b4a748), (FULL)U(0xf12e70fe2710eea5),
(FULL)U(0x0b8f78055901f2b5), (FULL)U(0x48860a764f2c115e),
(FULL)U(0x0edf6d2a30767e2c), (FULL)U(0x8a6d7dc5fce2713b),
(FULL)U(0x46a362ea4e0e2346), (FULL)U(0x6c369a0a359f5aa7),
(FULL)U(0xdfca81fe41def54e), (FULL)U(0x4b73381996c2bc4e),
(FULL)U(0x659e8b996f3f14f9), (FULL)U(0x8b97b93493d47e6f),
(FULL)U(0xa73a8704dfa10a55), (FULL)U(0x8d9eafe9b06503da),
(FULL)U(0x2556fb88f32336b0), (FULL)U(0xe71e9f751002a161),
(FULL)U(0x27a7be6e200af907), (FULL)U(0x1b9b734ed028e9a3),
(FULL)U(0x950cfeed4c0be0d3), (FULL)U(0xf4c416942536d275),
(FULL)U(0xf05a58e85687b76e), (FULL)U(0xba53ac0171a62d54),
(FULL)U(0x4b14cbcb285adc96), (FULL)U(0xfdf66eddb00a5557),
(FULL)U(0xbb43d58d185b6ea1), (FULL)U(0x905db9cdf355c9a6),
(FULL)U(0xfc3a07fc04429c8a), (FULL)U(0x65d7e365aa3a4f7e),
(FULL)U(0x2d284c18b243ac65), (FULL)U(0x72fba65d44e417fd),
(FULL)U(0x422d50b45c934805), (FULL)U(0xb62a6053d1587441),
(FULL)U(0xa5e71ce96f7ae035), (FULL)U(0x93abca2e595c8dd8),
(FULL)U(0x534231afe39afad5), (FULL)U(0x08d26cac12eaad56),
(FULL)U(0xec18bf8d7fb1b1c2), (FULL)U(0x3d28ea16faf6f09b),
(FULL)U(0xea357a7816697dd6), (FULL)U(0x51471ea1420f3f51),
(FULL)U(0x5e051aeb7f8946b4), (FULL)U(0x881be0970cf0524c),
(FULL)U(0xd558b25b1b31489e), (FULL)U(0x707d1a943a8b065c),
(FULL)U(0x37017e66568ff836), (FULL)U(0xb9cd627c24c2f747),
(FULL)U(0x1485549ffb1d9ff6), (FULL)U(0x308d32d9bdf2dc6f),
(FULL)U(0x4d4142cad543818a), (FULL)U(0x5d9c7aee87ebba43),
(FULL)U(0x81c5bdd8e17adb2f), (FULL)U(0x3dc9752ec8d8677a),
(FULL)U(0x66b086e6c34e4212), (FULL)U(0x3af7a90dc62b25e3),
(FULL)U(0xf8349f7935539315), (FULL)U(0x6bcfd9d5a22917f0),
(FULL)U(0x8639bb765f5ee517), (FULL)U(0xd3c5e3698095b092),
(FULL)U(0x8a33851e7eb44748), (FULL)U(0x5e29d443ea54bbcf),
(FULL)U(0x0f84651f4d59a834), (FULL)U(0x85040beaf1a5f951),
(FULL)U(0x3dba1c7498002078), (FULL)U(0x5d70712bf0b2cc15),
(FULL)U(0xfa3af8ebcce8e5a7), (FULL)U(0xfb3e223704bba57d),
(FULL)U(0x5d3b87858a950434), (FULL)U(0xce3112bdba3f8dcf),
(FULL)U(0x44904f55860d3051), (FULL)U(0xcec8fed44ed3e98b),
(FULL)U(0x4581698d25d01ea4), (FULL)U(0x11eb68289a9548e0),
(FULL)U(0x796cb4c6e911fac8), (FULL)U(0x2164cf26b5fd813e),
(FULL)U(0x4ac8e0f5d5de640f), (FULL)U(0xe9e757d78802ab4e),
(FULL)U(0x3c97de26f49dfcbd), (FULL)U(0xc604881b6ee6dbe6),
(FULL)U(0xa7c22a6e57d6154e), (FULL)U(0x234e2370877b3cc7),
(FULL)U(0xc0bdb72bdf1f8358), (FULL)U(0x6522e0fca95b7b55),
(FULL)U(0xba174c9022344162), (FULL)U(0x712c9b2d75d48867),
(FULL)U(0x240f7e92e59f3700), (FULL)U(0xe83cc2d4ad95d763),
(FULL)U(0x8509445a4336d717), (FULL)U(0xf1e572c5dfff1804),
(FULL)U(0xed10eb5d623232dd), (FULL)U(0x9205ea1bd4f957e8),
(FULL)U(0x4973a54f2ff062f5), (FULL)U(0x26b018f1e8c48cd5),
(FULL)U(0x56908401d1c7ed9f), (FULL)U(0x2e48937bdf89a247),
(FULL)U(0x9d53069b2be47129), (FULL)U(0x98069e3bc048a2b0),
(FULL)U(0xf25b7d651cd83f93), (FULL)U(0x2b004e6ce6f886c8),
(FULL)U(0xf618442a5c635935), (FULL)U(0xa502ab5c7198e052),
(FULL)U(0xc14241a4a6c41b0b), (FULL)U(0x720e845a7db9b18e),
(FULL)U(0x2abb13e94b713918), (FULL)U(0x90fc0c207f52467d),
(FULL)U(0x799c8ccd7868d348), (FULL)U(0xf4817ced912a0ea4),
(FULL)U(0xd68c0f4cc4903a57), (FULL)U(0xa3171f29e2b7934c),
(FULL)U(0xb1158baa0b4ccc22), (FULL)U(0xf5d8555349a29eda),
(FULL)U(0x59d1a078959442ef), (FULL)U(0xdb9b4a96a67fd518),
(FULL)U(0xcc7ca9eed2870636), (FULL)U(0x548f021cecf59920),
(FULL)U(0x25b7f4b6571bc8c5), (FULL)U(0x4fa527473a44f536),
(FULL)U(0xb246845fdf0ebdc2), (FULL)U(0xdd8d68ae42058793),
(FULL)U(0x3ba133289f6c39fb), (FULL)U(0x8bfdfbf37b6b42af),
(FULL)U(0xfb34c5ca7fb2b3b0), (FULL)U(0x2345dcecd428e32a),
(FULL)U(0x6891e850ad42b63e), (FULL)U(0x930642c8362c1381),
(FULL)U(0x13871e9b1886aff5), (FULL)U(0xd0cf2407482bda55),
(FULL)U(0x125b5fc95069bc31), (FULL)U(0x9b71d0a9f07dfa5d),
(FULL)U(0x55c044cc6712e524), (FULL)U(0xf0377358bb601978),
(FULL)U(0x152ad5f87fa51e8b), (FULL)U(0xe5ebf4789fcdd9af),
(FULL)U(0x3d78e18c66ebce7e), (FULL)U(0x8246db72f36aa83f),
(FULL)U(0xcc6ddc6d2c64c0a3), (FULL)U(0xa758d6870d91851e),
(FULL)U(0x24b20a6f9488ee36), (FULL)U(0xbe11ccdf09798197),
(FULL)U(0x11aca01599c1f4e3), (FULL)U(0x40e89e366437ac05),
(FULL)U(0xc8bfc7625af675f8), (FULL)U(0x6367c578b577e759),
(FULL)U(0x00380346615f0b74), (FULL)U(0xee964cc48de07d81),
(FULL)U(0x17f6ac16859d9261), (FULL)U(0x092f4a173a6e2f6c),
(FULL)U(0x79981a3db9024b95), (FULL)U(0x36db166004f7f540),
(FULL)U(0xc36252cf65a2f1c8), (FULL)U(0x705b6fde124c9bd2),
(FULL)U(0x31e58dda85db40ce), (FULL)U(0x6342b1a59f5e8d6d),
(FULL)U(0x5c2c67d0bd6d1d4d), (FULL)U(0x1fe5b46fba7e069d),
(FULL)U(0x21c46c6cac72e13c), (FULL)U(0xb80c5fd59eb8f52a),
(FULL)U(0x56c3aebfa74c92bc), (FULL)U(0xc1aff1fcbf8c4196),
(FULL)U(0x2b1df645754ad208), (FULL)U(0x5c734600d46eeb50),
(FULL)U(0xe0ff1b126a70a765), (FULL)U(0xd54164977a94547c),
(FULL)U(0x67b59d7c4ea35206), (FULL)U(0x53be7146779203b4),
(FULL)U(0x6b589fe5414026b8), (FULL)U(0x9e81016c3083bfee),
(FULL)U(0xb23526b93b4b7671), (FULL)U(0x4fa9ffb17ee300ba),
(FULL)U(0x6217e212ad05fb21), (FULL)U(0xf5b3fcd3b294e6c2),
(FULL)U(0xac040bbe216beb2a), (FULL)U(0x1f8d8a5471d0e78c),
(FULL)U(0xb6d15b419cfec96b), (FULL)U(0xc5477845d0508c78),
(FULL)U(0x5b486e81b4bba621), (FULL)U(0x90c35c94ef4c4121),
(FULL)U(0xefce7346f6a6bc55), (FULL)U(0xa27828d925bdb9bb),
(FULL)U(0xe3a53095a1f0b205), (FULL)U(0x1bfa6093d9f208ab),
(FULL)U(0xfb078f6a6842cdf4), (FULL)U(0x07806d7297133a38),
(FULL)U(0x2c6c901ba3ce9592), (FULL)U(0x1f0ab2cfebc1b789),
(FULL)U(0x2ce81415e2d03d5e), (FULL)U(0x7da45d5baa9f2417),
(FULL)U(0x3be4f76ddd800682), (FULL)U(0xdbf4e4a3364d72d3),
(FULL)U(0xb538cccf4fc59da5), (FULL)U(0xb0aa39d5487f66ec),
(FULL)U(0x2fd28dfd87927d3d), (FULL)U(0xd14e77f05900c6b1),
(FULL)U(0x2523fad25330c7b4), (FULL)U(0x991b5938d82368a4),
(FULL)U(0xb7c114432b9c1302), (FULL)U(0xdb842db61394b116),
(FULL)U(0x3641548d78ed26d8), (FULL)U(0x274fa8ef0a61dacf),
(FULL)U(0xa554ba63112df6f1), (FULL)U(0x7b7fe9856b50438d),
(FULL)U(0xc9fa0042bb63bbad), (FULL)U(0x3abf45d0e27f00da),
(FULL)U(0xd95faa159f87aabb), (FULL)U(0x4a95012e3488e7ae),
(FULL)U(0x1be2bdb90c642d04), (FULL)U(0x145c88818b4abf3e),
(FULL)U(0x7f9fb635544cf17f), (FULL)U(0xb8ab2f62cc78db70),
(FULL)U(0x8ee64bcdb4242f9a), (FULL)U(0xabd5285895dad129),
(FULL)U(0xbe722c2fccf31141), (FULL)U(0x7c330703575e26a9),
(FULL)U(0x45d3e3b3361b79e4), (FULL)U(0x241163a754b2e6a6),
(FULL)U(0x8f678d7df7cacb77), (FULL)U(0x988a68a483211d19),
(FULL)U(0x79599598ba7836f6), (FULL)U(0x4850c887eeda68bf),
(FULL)U(0xafa69a718052ce25), (FULL)U(0x8b21efc6bdd73573),
(FULL)U(0x89dbae18d0972493), (FULL)U(0x560776bf537d9454),
(FULL)U(0x3c009f78165310f2), (FULL)U(0xa36800210160c3af),
(FULL)U(0x3353ec3ca643bd40), (FULL)U(0x7e593f99911dab02),
(FULL)U(0x72d1ddd94f676e89), (FULL)U(0xfd18b8bd6b43c0ea),
(FULL)U(0x43cacef2ddbd697d), (FULL)U(0x2868a4d0acefe884),
(FULL)U(0x5f377b63a506f013), (FULL)U(0xeaa0975e05ca662b),
(FULL)U(0x3740e6b8eb433931), (FULL)U(0xce85df0008557948),
(FULL)U(0x784745fb547e33f9), (FULL)U(0x4a1fc5d4e5c6f598),
(FULL)U(0x85fa6fec768430a7), (FULL)U(0x990d0c24d2332a51),
(FULL)U(0x55245c2c33b676d5), (FULL)U(0xb1091519e2bcfa71),
(FULL)U(0x38521478d23a28d8), (FULL)U(0x9b794f899a573010),
(FULL)U(0x61d225e8699bb486), (FULL)U(0x21476d241c2158b0)
}
#elif 2*FULL_BITS == SBITS
{ /* subtractive 100 table */
(FULL)0x7db7dc19,(FULL)0xc8c0370c,(FULL)0x40a06fbb,(FULL)0x738e33b9,
(FULL)0xa859ed2b,(FULL)0x481abb76,(FULL)0x9ccdccb5,(FULL)0x74106bb3,
(FULL)0xc3173bfc,(FULL)0x05a8eeb5,(FULL)0x5a02e577,(FULL)0xefd5100d,
(FULL)0x4030b24a,(FULL)0xa69271f7,(FULL)0x16fe22c5,(FULL)0x641282fc,
(FULL)0x40438da3,(FULL)0x7aa7267c,(FULL)0xc2d878d1,(FULL)0x1fdf4abd,
(FULL)0x95702379,(FULL)0xd9899e7a,(FULL)0xd02d7f08,(FULL)0x5ea8e217,
(FULL)0x4d47a353,(FULL)0x770587fe,(FULL)0x0a33a2b8,(FULL)0xde7d1bdd,
(FULL)0x900e7c45,(FULL)0x4378c3c5,(FULL)0x19a514f9,(FULL)0x77c94478,
(FULL)0x843d1d32,(FULL)0xfc5edb22,(FULL)0xe8ee5e6e,(FULL)0x4fc42ce5,
(FULL)0x8488013e,(FULL)0xc938713c,(FULL)0x20ab0cac,(FULL)0x6a318f03,
(FULL)0xffc8bff3,(FULL)0x73e6d1a3,(FULL)0x8ca96aa7,(FULL)0x0cd3232a,
(FULL)0x905f770d,(FULL)0x605c8036,(FULL)0x8b8d04a2,(FULL)0x4d037b00,
(FULL)0xcb277294,(FULL)0x1ed81965,(FULL)0x7a254ff3,(FULL)0x408d9c47,
(FULL)0xe26c7377,(FULL)0x8b68587a,(FULL)0x8a48832f,(FULL)0xcff191a4,
(FULL)0x8aeb6fe6,(FULL)0x12d3df1d,(FULL)0x1feda37a,(FULL)0xb2bf907e,
(FULL)0x3bb5f39f,(FULL)0x4e5f7719,(FULL)0x8f5d1581,(FULL)0x33ebcf6f,
(FULL)0xd33654eb,(FULL)0x203c8e48,(FULL)0xf19c8a4e,(FULL)0x68d3656e,
(FULL)0x986eb2af,(FULL)0x3ec20b04,(FULL)0x062c3841,(FULL)0x5d73a03b,
(FULL)0x5d4e49eb,(FULL)0x836ce709,(FULL)0xc3f49221,(FULL)0x2310bc40,
(FULL)0xa6d0cbf6,(FULL)0x3868ee48,(FULL)0x4a43deb1,(FULL)0x67578aa6,
(FULL)0x150dfc26,(FULL)0x6e3426c1,(FULL)0x3131be30,(FULL)0xc541ccaa,
(FULL)0xcec7aab2,(FULL)0xf7e57432,(FULL)0x8cb3c873,(FULL)0x2b35de99,
(FULL)0x8663a5d7,(FULL)0x7b9f7764,(FULL)0xa771e5a6,(FULL)0x23b00e6a,
(FULL)0xa9985d05,(FULL)0x859c775c,(FULL)0x6b692f1f,(FULL)0x99636ea1,
(FULL)0x3730800d,(FULL)0x8700ac70,(FULL)0x4298a753,(FULL)0x46142502,
(FULL)0x809e955f,(FULL)0xea4a411b,(FULL)0x33709dfb,(FULL)0x3119ad40,
(FULL)0x5f01cb7c,(FULL)0xb76a6c6e,(FULL)0x15984eaf,(FULL)0x6109dc8a,
(FULL)0xa5ca9505,(FULL)0x5d686db9,(FULL)0x3b7e6add,(FULL)0x8e80d761,
(FULL)0xde6f6fd3,(FULL)0x79cbd718,(FULL)0x1da0f699,(FULL)0x40e9cd15,
(FULL)0xb24f312d,(FULL)0xe82158ba,(FULL)0xf5e5c36b,(FULL)0x79a4c927,
(FULL)0xa0039333,(FULL)0xc25247c9,(FULL)0x1766d81d,(FULL)0x93687116,
(FULL)0xa6741327,(FULL)0x3c6a03b4,(FULL)0xc002f29a,(FULL)0xc8a7b6e8,
(FULL)0x7bbd5ea3,(FULL)0x0e2a67c6,(FULL)0x441eabc1,(FULL)0x0929042d,
(FULL)0x25e82085,(FULL)0x7dbe232a,(FULL)0x44fbac3d,(FULL)0x8cfb26e5,
(FULL)0x388ab983,(FULL)0x8e40384d,(FULL)0x554632f8,(FULL)0x48dc1230,
(FULL)0xab492397,(FULL)0xab405048,(FULL)0xa118e387,(FULL)0x21c9e2f5,
(FULL)0x343b61b5,(FULL)0x484d1a8c,(FULL)0xab256f26,(FULL)0xd49e3dec,
(FULL)0x78f2d2e3,(FULL)0xe615c7fd,(FULL)0xce6cc2ed,(FULL)0x8442cc33,
(FULL)0x44d4bbf6,(FULL)0x0a3b93d8,(FULL)0x9301de77,(FULL)0x2d7e4efe,
(FULL)0xd8790d8a,(FULL)0x33711b76,(FULL)0x44df77e7,(FULL)0xc07dc30e,
(FULL)0x9ddd508f,(FULL)0xb9132ed0,(FULL)0xc6fb43cc,(FULL)0x45d06cf8,
(FULL)0xd585dd7b,(FULL)0x22bed18a,(FULL)0x10799ffa,(FULL)0x61c6cced,
(FULL)0xe4bd9aa9,(FULL)0xd7f2393b,(FULL)0xcfd55094,(FULL)0x706753fb,
(FULL)0xede6e446,(FULL)0xf65a6713,(FULL)0x47c0d5c3,(FULL)0x8bf6dfae,
(FULL)0x9f7927d6,(FULL)0xfb4dfc17,(FULL)0xe212c297,(FULL)0x12ebbc16,
(FULL)0xa00a954c,(FULL)0x43c71283,(FULL)0xe7bd40a5,(FULL)0x8957087a,
(FULL)0x08344837,(FULL)0xb0859d71,(FULL)0xaeb313f5,(FULL)0xfbf4b9a3,
(FULL)0xce81823a,(FULL)0x5e66e5be,(FULL)0x58ad6da1,(FULL)0x09a11c6e,
(FULL)0xc608054f,(FULL)0xc76f4316,(FULL)0x46084099,(FULL)0xb5821361,
(FULL)0x17a725ed,(FULL)0x4210008f,(FULL)0xd347c481,(FULL)0xe5ff8912
},
{ /* shuffle table */
(FULL)0xec8abd57,(FULL)0x69a2296c,(FULL)0x99a6df81,(FULL)0x867e1869,
(FULL)0xd849a48a,(FULL)0xc05ab96b,(FULL)0xfa00554b,(FULL)0x7eb3ce0c,
(FULL)0x5a5a9acd,(FULL)0x520d01f6,(FULL)0x36022d81,(FULL)0xd4ef1e33,
(FULL)0xc6f84f70,(FULL)0xaf44772b,(FULL)0xa7c55173,(FULL)0x647e85a6,
(FULL)0x959df8d1,(FULL)0x26746cf1,(FULL)0x4db28abd,(FULL)0x98681a90,
(FULL)0x744c5cd2,(FULL)0xb146c969,(FULL)0x706f88c2,(FULL)0x8ce69d1f,
(FULL)0x21b4a748,(FULL)0xfd12eac4,(FULL)0x2710eea5,(FULL)0xf12e70fe,
(FULL)0x5901f2b5,(FULL)0x0b8f7805,(FULL)0x4f2c115e,(FULL)0x48860a76,
(FULL)0x30767e2c,(FULL)0x0edf6d2a,(FULL)0xfce2713b,(FULL)0x8a6d7dc5,
(FULL)0x4e0e2346,(FULL)0x46a362ea,(FULL)0x359f5aa7,(FULL)0x6c369a0a,
(FULL)0x41def54e,(FULL)0xdfca81fe,(FULL)0x96c2bc4e,(FULL)0x4b733819,
(FULL)0x6f3f14f9,(FULL)0x659e8b99,(FULL)0x93d47e6f,(FULL)0x8b97b934,
(FULL)0xdfa10a55,(FULL)0xa73a8704,(FULL)0xb06503da,(FULL)0x8d9eafe9,
(FULL)0xf32336b0,(FULL)0x2556fb88,(FULL)0x1002a161,(FULL)0xe71e9f75,
(FULL)0x200af907,(FULL)0x27a7be6e,(FULL)0xd028e9a3,(FULL)0x1b9b734e,
(FULL)0x4c0be0d3,(FULL)0x950cfeed,(FULL)0x2536d275,(FULL)0xf4c41694,
(FULL)0x5687b76e,(FULL)0xf05a58e8,(FULL)0x71a62d54,(FULL)0xba53ac01,
(FULL)0x285adc96,(FULL)0x4b14cbcb,(FULL)0xb00a5557,(FULL)0xfdf66edd,
(FULL)0x185b6ea1,(FULL)0xbb43d58d,(FULL)0xf355c9a6,(FULL)0x905db9cd,
(FULL)0x04429c8a,(FULL)0xfc3a07fc,(FULL)0xaa3a4f7e,(FULL)0x65d7e365,
(FULL)0xb243ac65,(FULL)0x2d284c18,(FULL)0x44e417fd,(FULL)0x72fba65d,
(FULL)0x5c934805,(FULL)0x422d50b4,(FULL)0xd1587441,(FULL)0xb62a6053,
(FULL)0x6f7ae035,(FULL)0xa5e71ce9,(FULL)0x595c8dd8,(FULL)0x93abca2e,
(FULL)0xe39afad5,(FULL)0x534231af,(FULL)0x12eaad56,(FULL)0x08d26cac,
(FULL)0x7fb1b1c2,(FULL)0xec18bf8d,(FULL)0xfaf6f09b,(FULL)0x3d28ea16,
(FULL)0x16697dd6,(FULL)0xea357a78,(FULL)0x420f3f51,(FULL)0x51471ea1,
(FULL)0x7f8946b4,(FULL)0x5e051aeb,(FULL)0x0cf0524c,(FULL)0x881be097,
(FULL)0x1b31489e,(FULL)0xd558b25b,(FULL)0x3a8b065c,(FULL)0x707d1a94,
(FULL)0x568ff836,(FULL)0x37017e66,(FULL)0x24c2f747,(FULL)0xb9cd627c,
(FULL)0xfb1d9ff6,(FULL)0x1485549f,(FULL)0xbdf2dc6f,(FULL)0x308d32d9,
(FULL)0xd543818a,(FULL)0x4d4142ca,(FULL)0x87ebba43,(FULL)0x5d9c7aee,
(FULL)0xe17adb2f,(FULL)0x81c5bdd8,(FULL)0xc8d8677a,(FULL)0x3dc9752e,
(FULL)0xc34e4212,(FULL)0x66b086e6,(FULL)0xc62b25e3,(FULL)0x3af7a90d,
(FULL)0x35539315,(FULL)0xf8349f79,(FULL)0xa22917f0,(FULL)0x6bcfd9d5,
(FULL)0x5f5ee517,(FULL)0x8639bb76,(FULL)0x8095b092,(FULL)0xd3c5e369,
(FULL)0x7eb44748,(FULL)0x8a33851e,(FULL)0xea54bbcf,(FULL)0x5e29d443,
(FULL)0x4d59a834,(FULL)0x0f84651f,(FULL)0xf1a5f951,(FULL)0x85040bea,
(FULL)0x98002078,(FULL)0x3dba1c74,(FULL)0xf0b2cc15,(FULL)0x5d70712b,
(FULL)0xcce8e5a7,(FULL)0xfa3af8eb,(FULL)0x04bba57d,(FULL)0xfb3e2237,
(FULL)0x8a950434,(FULL)0x5d3b8785,(FULL)0xba3f8dcf,(FULL)0xce3112bd,
(FULL)0x860d3051,(FULL)0x44904f55,(FULL)0x4ed3e98b,(FULL)0xcec8fed4,
(FULL)0x25d01ea4,(FULL)0x4581698d,(FULL)0x9a9548e0,(FULL)0x11eb6828,
(FULL)0xe911fac8,(FULL)0x796cb4c6,(FULL)0xb5fd813e,(FULL)0x2164cf26,
(FULL)0xd5de640f,(FULL)0x4ac8e0f5,(FULL)0x8802ab4e,(FULL)0xe9e757d7,
(FULL)0xf49dfcbd,(FULL)0x3c97de26,(FULL)0x6ee6dbe6,(FULL)0xc604881b,
(FULL)0x57d6154e,(FULL)0xa7c22a6e,(FULL)0x877b3cc7,(FULL)0x234e2370,
(FULL)0xdf1f8358,(FULL)0xc0bdb72b,(FULL)0xa95b7b55,(FULL)0x6522e0fc,
(FULL)0x22344162,(FULL)0xba174c90,(FULL)0x75d48867,(FULL)0x712c9b2d,
(FULL)0xe59f3700,(FULL)0x240f7e92,(FULL)0xad95d763,(FULL)0xe83cc2d4,
(FULL)0x4336d717,(FULL)0x8509445a,(FULL)0xdfff1804,(FULL)0xf1e572c5,
(FULL)0x623232dd,(FULL)0xed10eb5d,(FULL)0xd4f957e8,(FULL)0x9205ea1b,
(FULL)0x2ff062f5,(FULL)0x4973a54f,(FULL)0xe8c48cd5,(FULL)0x26b018f1,
(FULL)0xd1c7ed9f,(FULL)0x56908401,(FULL)0xdf89a247,(FULL)0x2e48937b,
(FULL)0x2be47129,(FULL)0x9d53069b,(FULL)0xc048a2b0,(FULL)0x98069e3b,
(FULL)0x1cd83f93,(FULL)0xf25b7d65,(FULL)0xe6f886c8,(FULL)0x2b004e6c,
(FULL)0x5c635935,(FULL)0xf618442a,(FULL)0x7198e052,(FULL)0xa502ab5c,
(FULL)0xa6c41b0b,(FULL)0xc14241a4,(FULL)0x7db9b18e,(FULL)0x720e845a,
(FULL)0x4b713918,(FULL)0x2abb13e9,(FULL)0x7f52467d,(FULL)0x90fc0c20,
(FULL)0x7868d348,(FULL)0x799c8ccd,(FULL)0x912a0ea4,(FULL)0xf4817ced,
(FULL)0xc4903a57,(FULL)0xd68c0f4c,(FULL)0xe2b7934c,(FULL)0xa3171f29,
(FULL)0x0b4ccc22,(FULL)0xb1158baa,(FULL)0x49a29eda,(FULL)0xf5d85553,
(FULL)0x959442ef,(FULL)0x59d1a078,(FULL)0xa67fd518,(FULL)0xdb9b4a96,
(FULL)0xd2870636,(FULL)0xcc7ca9ee,(FULL)0xecf59920,(FULL)0x548f021c,
(FULL)0x571bc8c5,(FULL)0x25b7f4b6,(FULL)0x3a44f536,(FULL)0x4fa52747,
(FULL)0xdf0ebdc2,(FULL)0xb246845f,(FULL)0x42058793,(FULL)0xdd8d68ae,
(FULL)0x9f6c39fb,(FULL)0x3ba13328,(FULL)0x7b6b42af,(FULL)0x8bfdfbf3,
(FULL)0x7fb2b3b0,(FULL)0xfb34c5ca,(FULL)0xd428e32a,(FULL)0x2345dcec,
(FULL)0xad42b63e,(FULL)0x6891e850,(FULL)0x362c1381,(FULL)0x930642c8,
(FULL)0x1886aff5,(FULL)0x13871e9b,(FULL)0x482bda55,(FULL)0xd0cf2407,
(FULL)0x5069bc31,(FULL)0x125b5fc9,(FULL)0xf07dfa5d,(FULL)0x9b71d0a9,
(FULL)0x6712e524,(FULL)0x55c044cc,(FULL)0xbb601978,(FULL)0xf0377358,
(FULL)0x7fa51e8b,(FULL)0x152ad5f8,(FULL)0x9fcdd9af,(FULL)0xe5ebf478,
(FULL)0x66ebce7e,(FULL)0x3d78e18c,(FULL)0xf36aa83f,(FULL)0x8246db72,
(FULL)0x2c64c0a3,(FULL)0xcc6ddc6d,(FULL)0x0d91851e,(FULL)0xa758d687,
(FULL)0x9488ee36,(FULL)0x24b20a6f,(FULL)0x09798197,(FULL)0xbe11ccdf,
(FULL)0x99c1f4e3,(FULL)0x11aca015,(FULL)0x6437ac05,(FULL)0x40e89e36,
(FULL)0x5af675f8,(FULL)0xc8bfc762,(FULL)0xb577e759,(FULL)0x6367c578,
(FULL)0x615f0b74,(FULL)0x00380346,(FULL)0x8de07d81,(FULL)0xee964cc4,
(FULL)0x859d9261,(FULL)0x17f6ac16,(FULL)0x3a6e2f6c,(FULL)0x092f4a17,
(FULL)0xb9024b95,(FULL)0x79981a3d,(FULL)0x04f7f540,(FULL)0x36db1660,
(FULL)0x65a2f1c8,(FULL)0xc36252cf,(FULL)0x124c9bd2,(FULL)0x705b6fde,
(FULL)0x85db40ce,(FULL)0x31e58dda,(FULL)0x9f5e8d6d,(FULL)0x6342b1a5,
(FULL)0xbd6d1d4d,(FULL)0x5c2c67d0,(FULL)0xba7e069d,(FULL)0x1fe5b46f,
(FULL)0xac72e13c,(FULL)0x21c46c6c,(FULL)0x9eb8f52a,(FULL)0xb80c5fd5,
(FULL)0xa74c92bc,(FULL)0x56c3aebf,(FULL)0xbf8c4196,(FULL)0xc1aff1fc,
(FULL)0x754ad208,(FULL)0x2b1df645,(FULL)0xd46eeb50,(FULL)0x5c734600,
(FULL)0x6a70a765,(FULL)0xe0ff1b12,(FULL)0x7a94547c,(FULL)0xd5416497,
(FULL)0x4ea35206,(FULL)0x67b59d7c,(FULL)0x779203b4,(FULL)0x53be7146,
(FULL)0x414026b8,(FULL)0x6b589fe5,(FULL)0x3083bfee,(FULL)0x9e81016c,
(FULL)0x3b4b7671,(FULL)0xb23526b9,(FULL)0x7ee300ba,(FULL)0x4fa9ffb1,
(FULL)0xad05fb21,(FULL)0x6217e212,(FULL)0xb294e6c2,(FULL)0xf5b3fcd3,
(FULL)0x216beb2a,(FULL)0xac040bbe,(FULL)0x71d0e78c,(FULL)0x1f8d8a54,
(FULL)0x9cfec96b,(FULL)0xb6d15b41,(FULL)0xd0508c78,(FULL)0xc5477845,
(FULL)0xb4bba621,(FULL)0x5b486e81,(FULL)0xef4c4121,(FULL)0x90c35c94,
(FULL)0xf6a6bc55,(FULL)0xefce7346,(FULL)0x25bdb9bb,(FULL)0xa27828d9,
(FULL)0xa1f0b205,(FULL)0xe3a53095,(FULL)0xd9f208ab,(FULL)0x1bfa6093,
(FULL)0x6842cdf4,(FULL)0xfb078f6a,(FULL)0x97133a38,(FULL)0x07806d72,
(FULL)0xa3ce9592,(FULL)0x2c6c901b,(FULL)0xebc1b789,(FULL)0x1f0ab2cf,
(FULL)0xe2d03d5e,(FULL)0x2ce81415,(FULL)0xaa9f2417,(FULL)0x7da45d5b,
(FULL)0xdd800682,(FULL)0x3be4f76d,(FULL)0x364d72d3,(FULL)0xdbf4e4a3,
(FULL)0x4fc59da5,(FULL)0xb538cccf,(FULL)0x487f66ec,(FULL)0xb0aa39d5,
(FULL)0x87927d3d,(FULL)0x2fd28dfd,(FULL)0x5900c6b1,(FULL)0xd14e77f0,
(FULL)0x5330c7b4,(FULL)0x2523fad2,(FULL)0xd82368a4,(FULL)0x991b5938,
(FULL)0x2b9c1302,(FULL)0xb7c11443,(FULL)0x1394b116,(FULL)0xdb842db6,
(FULL)0x78ed26d8,(FULL)0x3641548d,(FULL)0x0a61dacf,(FULL)0x274fa8ef,
(FULL)0x112df6f1,(FULL)0xa554ba63,(FULL)0x6b50438d,(FULL)0x7b7fe985,
(FULL)0xbb63bbad,(FULL)0xc9fa0042,(FULL)0xe27f00da,(FULL)0x3abf45d0,
(FULL)0x9f87aabb,(FULL)0xd95faa15,(FULL)0x3488e7ae,(FULL)0x4a95012e,
(FULL)0x0c642d04,(FULL)0x1be2bdb9,(FULL)0x8b4abf3e,(FULL)0x145c8881,
(FULL)0x544cf17f,(FULL)0x7f9fb635,(FULL)0xcc78db70,(FULL)0xb8ab2f62,
(FULL)0xb4242f9a,(FULL)0x8ee64bcd,(FULL)0x95dad129,(FULL)0xabd52858,
(FULL)0xccf31141,(FULL)0xbe722c2f,(FULL)0x575e26a9,(FULL)0x7c330703,
(FULL)0x361b79e4,(FULL)0x45d3e3b3,(FULL)0x54b2e6a6,(FULL)0x241163a7,
(FULL)0xf7cacb77,(FULL)0x8f678d7d,(FULL)0x83211d19,(FULL)0x988a68a4,
(FULL)0xba7836f6,(FULL)0x79599598,(FULL)0xeeda68bf,(FULL)0x4850c887,
(FULL)0x8052ce25,(FULL)0xafa69a71,(FULL)0xbdd73573,(FULL)0x8b21efc6,
(FULL)0xd0972493,(FULL)0x89dbae18,(FULL)0x537d9454,(FULL)0x560776bf,
(FULL)0x165310f2,(FULL)0x3c009f78,(FULL)0x0160c3af,(FULL)0xa3680021,
(FULL)0xa643bd40,(FULL)0x3353ec3c,(FULL)0x911dab02,(FULL)0x7e593f99,
(FULL)0x4f676e89,(FULL)0x72d1ddd9,(FULL)0x6b43c0ea,(FULL)0xfd18b8bd,
(FULL)0xddbd697d,(FULL)0x43cacef2,(FULL)0xacefe884,(FULL)0x2868a4d0,
(FULL)0xa506f013,(FULL)0x5f377b63,(FULL)0x05ca662b,(FULL)0xeaa0975e,
(FULL)0xeb433931,(FULL)0x3740e6b8,(FULL)0x08557948,(FULL)0xce85df00,
(FULL)0x547e33f9,(FULL)0x784745fb,(FULL)0xe5c6f598,(FULL)0x4a1fc5d4,
(FULL)0x768430a7,(FULL)0x85fa6fec,(FULL)0xd2332a51,(FULL)0x990d0c24,
(FULL)0x33b676d5,(FULL)0x55245c2c,(FULL)0xe2bcfa71,(FULL)0xb1091519,
(FULL)0xd23a28d8,(FULL)0x38521478,(FULL)0x9a573010,(FULL)0x9b794f89,
(FULL)0x699bb486,(FULL)0x61d225e8,(FULL)0x1c2158b0,(FULL)0x21476d24
}
#else
/\../\ FULL_BITS must be 32 or 64 /\../\ !!!
#endif
};
/*
@@ -574,57 +760,111 @@ static CONST RAND init_s100 = {
* This array is never changed, only copied.
*/
static CONST FULL def_subtract[SCNT] = {
/* NOTE: Due to a SunOS cc bug, don't put spaces in the SVAL call! */
SVAL(c8c0370c,7db7dc19), SVAL(738e33b9,40a06fbb),
SVAL(481abb76,a859ed2b), SVAL(74106bb3,9ccdccb5),
SVAL(05a8eeb5,c3173bfc), SVAL(efd5100d,5a02e577),
SVAL(a69271f7,4030b24a), SVAL(641282fc,16fe22c5),
SVAL(7aa7267c,40438da3), SVAL(1fdf4abd,c2d878d1),
SVAL(d9899e7a,95702379), SVAL(5ea8e217,d02d7f08),
SVAL(770587fe,4d47a353), SVAL(de7d1bdd,0a33a2b8),
SVAL(4378c3c5,900e7c45), SVAL(77c94478,19a514f9),
SVAL(fc5edb22,843d1d32), SVAL(4fc42ce5,e8ee5e6e),
SVAL(c938713c,8488013e), SVAL(6a318f03,20ab0cac),
SVAL(73e6d1a3,ffc8bff3), SVAL(0cd3232a,8ca96aa7),
SVAL(605c8036,905f770d), SVAL(4d037b00,8b8d04a2),
SVAL(1ed81965,cb277294), SVAL(408d9c47,7a254ff3),
SVAL(8b68587a,e26c7377), SVAL(cff191a4,8a48832f),
SVAL(12d3df1d,8aeb6fe6), SVAL(b2bf907e,1feda37a),
SVAL(4e5f7719,3bb5f39f), SVAL(33ebcf6f,8f5d1581),
SVAL(203c8e48,d33654eb), SVAL(68d3656e,f19c8a4e),
SVAL(3ec20b04,986eb2af), SVAL(5d73a03b,062c3841),
SVAL(836ce709,5d4e49eb), SVAL(2310bc40,c3f49221),
SVAL(3868ee48,a6d0cbf6), SVAL(67578aa6,4a43deb1),
SVAL(6e3426c1,150dfc26), SVAL(c541ccaa,3131be30),
SVAL(f7e57432,cec7aab2), SVAL(2b35de99,8cb3c873),
SVAL(7b9f7764,8663a5d7), SVAL(23b00e6a,a771e5a6),
SVAL(859c775c,a9985d05), SVAL(99636ea1,6b692f1f),
SVAL(8700ac70,3730800d), SVAL(46142502,4298a753),
SVAL(ea4a411b,809e955f), SVAL(3119ad40,33709dfb),
SVAL(b76a6c6e,5f01cb7c), SVAL(6109dc8a,15984eaf),
SVAL(5d686db9,a5ca9505), SVAL(8e80d761,3b7e6add),
SVAL(79cbd718,de6f6fd3), SVAL(40e9cd15,1da0f699),
SVAL(e82158ba,b24f312d), SVAL(79a4c927,f5e5c36b),
SVAL(c25247c9,a0039333), SVAL(93687116,1766d81d),
SVAL(3c6a03b4,a6741327), SVAL(c8a7b6e8,c002f29a),
SVAL(0e2a67c6,7bbd5ea3), SVAL(0929042d,441eabc1),
SVAL(7dbe232a,25e82085), SVAL(8cfb26e5,44fbac3d),
SVAL(8e40384d,388ab983), SVAL(48dc1230,554632f8),
SVAL(ab405048,ab492397), SVAL(21c9e2f5,a118e387),
SVAL(484d1a8c,343b61b5), SVAL(d49e3dec,ab256f26),
SVAL(e615c7fd,78f2d2e3), SVAL(8442cc33,ce6cc2ed),
SVAL(0a3b93d8,44d4bbf6), SVAL(2d7e4efe,9301de77),
SVAL(33711b76,d8790d8a), SVAL(c07dc30e,44df77e7),
SVAL(b9132ed0,9ddd508f), SVAL(45d06cf8,c6fb43cc),
SVAL(22bed18a,d585dd7b), SVAL(61c6cced,10799ffa),
SVAL(d7f2393b,e4bd9aa9), SVAL(706753fb,cfd55094),
SVAL(f65a6713,ede6e446), SVAL(8bf6dfae,47c0d5c3),
SVAL(fb4dfc17,9f7927d6), SVAL(12ebbc16,e212c297),
SVAL(43c71283,a00a954c), SVAL(8957087a,e7bd40a5),
SVAL(b0859d71,08344837), SVAL(fbf4b9a3,aeb313f5),
SVAL(5e66e5be,ce81823a), SVAL(09a11c6e,58ad6da1),
SVAL(c76f4316,c608054f), SVAL(b5821361,46084099),
SVAL(4210008f,17a725ed), SVAL(e5ff8912,d347c481)
#if FULL_BITS == SBITS
(FULL)U(0xc8c0370c7db7dc19), (FULL)U(0x738e33b940a06fbb),
(FULL)U(0x481abb76a859ed2b), (FULL)U(0x74106bb39ccdccb5),
(FULL)U(0x05a8eeb5c3173bfc), (FULL)U(0xefd5100d5a02e577),
(FULL)U(0xa69271f74030b24a), (FULL)U(0x641282fc16fe22c5),
(FULL)U(0x7aa7267c40438da3), (FULL)U(0x1fdf4abdc2d878d1),
(FULL)U(0xd9899e7a95702379), (FULL)U(0x5ea8e217d02d7f08),
(FULL)U(0x770587fe4d47a353), (FULL)U(0xde7d1bdd0a33a2b8),
(FULL)U(0x4378c3c5900e7c45), (FULL)U(0x77c9447819a514f9),
(FULL)U(0xfc5edb22843d1d32), (FULL)U(0x4fc42ce5e8ee5e6e),
(FULL)U(0xc938713c8488013e), (FULL)U(0x6a318f0320ab0cac),
(FULL)U(0x73e6d1a3ffc8bff3), (FULL)U(0x0cd3232a8ca96aa7),
(FULL)U(0x605c8036905f770d), (FULL)U(0x4d037b008b8d04a2),
(FULL)U(0x1ed81965cb277294), (FULL)U(0x408d9c477a254ff3),
(FULL)U(0x8b68587ae26c7377), (FULL)U(0xcff191a48a48832f),
(FULL)U(0x12d3df1d8aeb6fe6), (FULL)U(0xb2bf907e1feda37a),
(FULL)U(0x4e5f77193bb5f39f), (FULL)U(0x33ebcf6f8f5d1581),
(FULL)U(0x203c8e48d33654eb), (FULL)U(0x68d3656ef19c8a4e),
(FULL)U(0x3ec20b04986eb2af), (FULL)U(0x5d73a03b062c3841),
(FULL)U(0x836ce7095d4e49eb), (FULL)U(0x2310bc40c3f49221),
(FULL)U(0x3868ee48a6d0cbf6), (FULL)U(0x67578aa64a43deb1),
(FULL)U(0x6e3426c1150dfc26), (FULL)U(0xc541ccaa3131be30),
(FULL)U(0xf7e57432cec7aab2), (FULL)U(0x2b35de998cb3c873),
(FULL)U(0x7b9f77648663a5d7), (FULL)U(0x23b00e6aa771e5a6),
(FULL)U(0x859c775ca9985d05), (FULL)U(0x99636ea16b692f1f),
(FULL)U(0x8700ac703730800d), (FULL)U(0x461425024298a753),
(FULL)U(0xea4a411b809e955f), (FULL)U(0x3119ad4033709dfb),
(FULL)U(0xb76a6c6e5f01cb7c), (FULL)U(0x6109dc8a15984eaf),
(FULL)U(0x5d686db9a5ca9505), (FULL)U(0x8e80d7613b7e6add),
(FULL)U(0x79cbd718de6f6fd3), (FULL)U(0x40e9cd151da0f699),
(FULL)U(0xe82158bab24f312d), (FULL)U(0x79a4c927f5e5c36b),
(FULL)U(0xc25247c9a0039333), (FULL)U(0x936871161766d81d),
(FULL)U(0x3c6a03b4a6741327), (FULL)U(0xc8a7b6e8c002f29a),
(FULL)U(0x0e2a67c67bbd5ea3), (FULL)U(0x0929042d441eabc1),
(FULL)U(0x7dbe232a25e82085), (FULL)U(0x8cfb26e544fbac3d),
(FULL)U(0x8e40384d388ab983), (FULL)U(0x48dc1230554632f8),
(FULL)U(0xab405048ab492397), (FULL)U(0x21c9e2f5a118e387),
(FULL)U(0x484d1a8c343b61b5), (FULL)U(0xd49e3decab256f26),
(FULL)U(0xe615c7fd78f2d2e3), (FULL)U(0x8442cc33ce6cc2ed),
(FULL)U(0x0a3b93d844d4bbf6), (FULL)U(0x2d7e4efe9301de77),
(FULL)U(0x33711b76d8790d8a), (FULL)U(0xc07dc30e44df77e7),
(FULL)U(0xb9132ed09ddd508f), (FULL)U(0x45d06cf8c6fb43cc),
(FULL)U(0x22bed18ad585dd7b), (FULL)U(0x61c6cced10799ffa),
(FULL)U(0xd7f2393be4bd9aa9), (FULL)U(0x706753fbcfd55094),
(FULL)U(0xf65a6713ede6e446), (FULL)U(0x8bf6dfae47c0d5c3),
(FULL)U(0xfb4dfc179f7927d6), (FULL)U(0x12ebbc16e212c297),
(FULL)U(0x43c71283a00a954c), (FULL)U(0x8957087ae7bd40a5),
(FULL)U(0xb0859d7108344837), (FULL)U(0xfbf4b9a3aeb313f5),
(FULL)U(0x5e66e5bece81823a), (FULL)U(0x09a11c6e58ad6da1),
(FULL)U(0xc76f4316c608054f), (FULL)U(0xb582136146084099),
(FULL)U(0x4210008f17a725ed), (FULL)U(0xe5ff8912d347c481)
#elif 2*FULL_BITS == SBITS
(FULL)0x7db7dc19,(FULL)0xc8c0370c,(FULL)0x40a06fbb,(FULL)0x738e33b9,
(FULL)0xa859ed2b,(FULL)0x481abb76,(FULL)0x9ccdccb5,(FULL)0x74106bb3,
(FULL)0xc3173bfc,(FULL)0x05a8eeb5,(FULL)0x5a02e577,(FULL)0xefd5100d,
(FULL)0x4030b24a,(FULL)0xa69271f7,(FULL)0x16fe22c5,(FULL)0x641282fc,
(FULL)0x40438da3,(FULL)0x7aa7267c,(FULL)0xc2d878d1,(FULL)0x1fdf4abd,
(FULL)0x95702379,(FULL)0xd9899e7a,(FULL)0xd02d7f08,(FULL)0x5ea8e217,
(FULL)0x4d47a353,(FULL)0x770587fe,(FULL)0x0a33a2b8,(FULL)0xde7d1bdd,
(FULL)0x900e7c45,(FULL)0x4378c3c5,(FULL)0x19a514f9,(FULL)0x77c94478,
(FULL)0x843d1d32,(FULL)0xfc5edb22,(FULL)0xe8ee5e6e,(FULL)0x4fc42ce5,
(FULL)0x8488013e,(FULL)0xc938713c,(FULL)0x20ab0cac,(FULL)0x6a318f03,
(FULL)0xffc8bff3,(FULL)0x73e6d1a3,(FULL)0x8ca96aa7,(FULL)0x0cd3232a,
(FULL)0x905f770d,(FULL)0x605c8036,(FULL)0x8b8d04a2,(FULL)0x4d037b00,
(FULL)0xcb277294,(FULL)0x1ed81965,(FULL)0x7a254ff3,(FULL)0x408d9c47,
(FULL)0xe26c7377,(FULL)0x8b68587a,(FULL)0x8a48832f,(FULL)0xcff191a4,
(FULL)0x8aeb6fe6,(FULL)0x12d3df1d,(FULL)0x1feda37a,(FULL)0xb2bf907e,
(FULL)0x3bb5f39f,(FULL)0x4e5f7719,(FULL)0x8f5d1581,(FULL)0x33ebcf6f,
(FULL)0xd33654eb,(FULL)0x203c8e48,(FULL)0xf19c8a4e,(FULL)0x68d3656e,
(FULL)0x986eb2af,(FULL)0x3ec20b04,(FULL)0x062c3841,(FULL)0x5d73a03b,
(FULL)0x5d4e49eb,(FULL)0x836ce709,(FULL)0xc3f49221,(FULL)0x2310bc40,
(FULL)0xa6d0cbf6,(FULL)0x3868ee48,(FULL)0x4a43deb1,(FULL)0x67578aa6,
(FULL)0x150dfc26,(FULL)0x6e3426c1,(FULL)0x3131be30,(FULL)0xc541ccaa,
(FULL)0xcec7aab2,(FULL)0xf7e57432,(FULL)0x8cb3c873,(FULL)0x2b35de99,
(FULL)0x8663a5d7,(FULL)0x7b9f7764,(FULL)0xa771e5a6,(FULL)0x23b00e6a,
(FULL)0xa9985d05,(FULL)0x859c775c,(FULL)0x6b692f1f,(FULL)0x99636ea1,
(FULL)0x3730800d,(FULL)0x8700ac70,(FULL)0x4298a753,(FULL)0x46142502,
(FULL)0x809e955f,(FULL)0xea4a411b,(FULL)0x33709dfb,(FULL)0x3119ad40,
(FULL)0x5f01cb7c,(FULL)0xb76a6c6e,(FULL)0x15984eaf,(FULL)0x6109dc8a,
(FULL)0xa5ca9505,(FULL)0x5d686db9,(FULL)0x3b7e6add,(FULL)0x8e80d761,
(FULL)0xde6f6fd3,(FULL)0x79cbd718,(FULL)0x1da0f699,(FULL)0x40e9cd15,
(FULL)0xb24f312d,(FULL)0xe82158ba,(FULL)0xf5e5c36b,(FULL)0x79a4c927,
(FULL)0xa0039333,(FULL)0xc25247c9,(FULL)0x1766d81d,(FULL)0x93687116,
(FULL)0xa6741327,(FULL)0x3c6a03b4,(FULL)0xc002f29a,(FULL)0xc8a7b6e8,
(FULL)0x7bbd5ea3,(FULL)0x0e2a67c6,(FULL)0x441eabc1,(FULL)0x0929042d,
(FULL)0x25e82085,(FULL)0x7dbe232a,(FULL)0x44fbac3d,(FULL)0x8cfb26e5,
(FULL)0x388ab983,(FULL)0x8e40384d,(FULL)0x554632f8,(FULL)0x48dc1230,
(FULL)0xab492397,(FULL)0xab405048,(FULL)0xa118e387,(FULL)0x21c9e2f5,
(FULL)0x343b61b5,(FULL)0x484d1a8c,(FULL)0xab256f26,(FULL)0xd49e3dec,
(FULL)0x78f2d2e3,(FULL)0xe615c7fd,(FULL)0xce6cc2ed,(FULL)0x8442cc33,
(FULL)0x44d4bbf6,(FULL)0x0a3b93d8,(FULL)0x9301de77,(FULL)0x2d7e4efe,
(FULL)0xd8790d8a,(FULL)0x33711b76,(FULL)0x44df77e7,(FULL)0xc07dc30e,
(FULL)0x9ddd508f,(FULL)0xb9132ed0,(FULL)0xc6fb43cc,(FULL)0x45d06cf8,
(FULL)0xd585dd7b,(FULL)0x22bed18a,(FULL)0x10799ffa,(FULL)0x61c6cced,
(FULL)0xe4bd9aa9,(FULL)0xd7f2393b,(FULL)0xcfd55094,(FULL)0x706753fb,
(FULL)0xede6e446,(FULL)0xf65a6713,(FULL)0x47c0d5c3,(FULL)0x8bf6dfae,
(FULL)0x9f7927d6,(FULL)0xfb4dfc17,(FULL)0xe212c297,(FULL)0x12ebbc16,
(FULL)0xa00a954c,(FULL)0x43c71283,(FULL)0xe7bd40a5,(FULL)0x8957087a,
(FULL)0x08344837,(FULL)0xb0859d71,(FULL)0xaeb313f5,(FULL)0xfbf4b9a3,
(FULL)0xce81823a,(FULL)0x5e66e5be,(FULL)0x58ad6da1,(FULL)0x09a11c6e,
(FULL)0xc608054f,(FULL)0xc76f4316,(FULL)0x46084099,(FULL)0xb5821361,
(FULL)0x17a725ed,(FULL)0x4210008f,(FULL)0xd347c481,(FULL)0xe5ff8912
#else
/\../\ FULL_BITS must be 32 or 64 /\../\ !!!
#endif
};
@@ -636,9 +876,17 @@ static CONST FULL def_subtract[SCNT] = {
*
* These constants are used in the randreseed64(). See below.
*/
/* NOTE: Due to a SunOS cc bug, don't put spaces in the SHVAL call! */
static CONST HALF a_vec[SHALFS] = {SHVAL(57aa,0ff4,73c0,ccbd)};
static CONST HALF c_vec[SHALFS] = {SHVAL(12ea,8057,18e0,9865)};
#if FULL_BITS == SBITS
static CONST HALF a_vec[SHALFS] = { (HALF)0x73c0ccbd, (HALF)0x57aa0ff4 };
static CONST HALF c_vec[SHALFS] = { (HALF)0x18e09865, (HALF)0x12ea8057 };
#elif 2*FULL_BITS == SBITS
static CONST HALF a_vec[SHALFS] = { (HALF)0xccbd, (HALF)0x73c0,
(HALF)0x0ff4, (HALF)0x57aa };
static CONST HALF c_vec[SHALFS] = { (HALF)0x9865, (HALF)0x18e0,
(HALF)0x8057, (HALF)0x12ea };
#else
/\../\ FULL_BITS must be 32 or 64 /\../\ !!!
#endif
static CONST ZVALUE a_val = {(HALF *)a_vec, SHALFS, 0};
static CONST ZVALUE c_val = {(HALF *)c_vec, SHALFS, 0};
@@ -860,7 +1108,7 @@ randreseed64(ZVALUE seed, ZVALUE *res)
/*
* form chunk mod 2^64
*/
if (chunk.len > SHALFS) {
if (chunk.len > (SB32)SHALFS) {
/* result is too large, reduce to 64 bits */
v64 = alloc(SHALFS);
memcpy(v64, chunk.v, SHALFS*sizeof(HALF));
@@ -2104,7 +2352,7 @@ randcmp(CONST RAND *s1, CONST RAND *s2)
*/
/*ARGSUSED*/
void
randprint(CONST RAND *state, int flags)
randprint(CONST RAND UNUSED *state, int UNUSED flags)
{
math_str("RAND state");
}

38
zrand.h
View File

@@ -1,7 +1,7 @@
/*
* zrand - subtractive 100 shuffle generator
*
* 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: zrand.h,v 29.5 2001/06/08 21:00:58 chongo Exp $
* @(#) $Revision: 29.7 $
* @(#) $Id: zrand.h,v 29.7 2004/03/31 04:58:40 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zrand.h,v $
*
* Under source code control: 1995/01/07 09:45:26
@@ -81,20 +81,6 @@
*
* SLEN - length in FULLs of an subtractive 100 slot
*
* SVAL(a,b) - form a 64 bit hex slot entry in the subtractive 100 table
* a: up to 8 hex digits without the leading 0x (upper half)
* b: up to 8 hex digits without the leading 0x (lower half)
*
* NOTE: Due to a SunOS cc bug, don't put spaces in the SVAL call!
*
* SHVAL(a,b,c,d) - form an 64 bit array of HALFs
* a: up to 4 hex digits without the leading 0x (upper half)
* b: up to 4 hex digits without the leading 0x (2nd half)
* c: up to 4 hex digits without the leading 0x (3rd half)
* d: up to 4 hex digits without the leading 0x (lower half)
*
* NOTE: Due to a SunOS cc bug, don't put spaces in the SHVAL call!
*
* SLOAD(s,i,z) - load table slot i from subtractive 100 state s with zvalue z
* s: type RAND
* i: type int, s.slot[i] slot index
@@ -140,13 +126,6 @@
#if FULL_BITS == SBITS
# define SLEN 1 /* a 64 bit slot can be held in a FULL */
# if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
# define SVAL(a,b) (FULL)U(0x ## a ## b)
# define SHVAL(a,b,c,d) (HALF)0x ## c ## d, (HALF)0x ## a ## b
# else
# define SVAL(a,b) (FULL)U(0x/**/a/**/b)
# define SHVAL(a,b,c,d) (HALF)0x/**/c/**/d,(HALF)0x/**/a/**/b
# endif
#define SLOAD(s,i,z) ((s).slot[i] = ztofull(z))
#define SSUB(s,k,j) ((s).slot[k] -= (s).slot[j])
#define SINDX(s,k) ((int)((s).slot[k] >> (FULL_BITS - SHUFPOW)))
@@ -164,17 +143,6 @@
#elif 2*FULL_BITS == SBITS
# define SLEN 2 /* a 64 bit slot needs 2 FULLs */
# if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
# define SVAL(a,b) (FULL)0x##b, (FULL)0x##a
# define SHVAL(a,b,c,d) (HALF)0x##d, (HALF)0x##c, \
(HALF)0x##b, (HALF)0x##a
# else
/* NOTE: Due to a SunOS cc bug, don't put spaces in the SVAL call! */
# define SVAL(a,b) (FULL)0x/**/b, (FULL)0x/**/a
/* NOTE: Due to a SunOS cc bug, don't put spaces in the SHVAL call! */
# define SHVAL(a,b,c,d) (HALF)0x/**/d, (HALF)0x/**/c, \
(HALF)0x/**/b, (HALF)0x/**/a
# endif
#define SLOAD(s,i,z) {(s).slot[(i)<<1] = ztofull(z); \
(s).slot[1+((i)<<1)] = \
(((z).len <= 2) ? (FULL)0 : \

1223
zrandom.c

File diff suppressed because it is too large Load Diff