Release calc version 2.11.8

This commit is contained in:
Landon Curt Noll
2003-06-10 14:51:42 -07:00
parent e1a3dfda0b
commit 0d06d90751
16 changed files with 315 additions and 218 deletions

51
CHANGES
View File

@@ -1,4 +1,51 @@
The following are the changes from calc version 2.11.7.0 to date:
The following are the changes from calc version 2.11.8.0 to date:
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 stardard"
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.
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>.
@@ -5562,7 +5609,7 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.59 $
## @(#) $Id: CHANGES,v 29.59 2003/02/26 17:17:12 chongo Exp $
## @(#) $Id: CHANGES,v 29.59 2003/02/26 17:17:12 chongo Exp chongo $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
##
## Under source code control: 1993/06/02 18:12:57

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

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.15 $
* @(#) $Id: regress.cal,v 29.15 2003/01/26 19:42:03 chongo Exp $
* @(#) $Revision: 29.17 $
* @(#) $Id: regress.cal,v 29.17 2003/06/10 21:17:55 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');

12
calc.c
View File

@@ -20,7 +20,7 @@
* 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 $
* @(#) $Id: calc.c,v 29.8 2001/04/10 22:03:13 chongo Exp chongo $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
*
* Under source code control: 1990/02/15 01:48:11
@@ -214,7 +214,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 +431,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);

4
calc.h
View File

@@ -18,7 +18,7 @@
* 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 $
* @(#) $Id: calc.h,v 29.10 2002/03/12 09:40:57 chongo Exp chongo $
* @(#) $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

@@ -16,7 +16,7 @@
.\" 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
.\"
.\" @(#) $Revision: 29.10 $
.\" @(#) $Id: calc.man,v 29.10 2003/01/18 21:19:21 chongo Exp $
.\" @(#) $Id: calc.man,v 29.10 2003/01/18 21:19:21 chongo Exp chongo $
.\" @(#) $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 ]
@@ -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

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.11 $
# @(#) $Id: calc.spec.in,v 29.11 2003/02/26 17:59:01 chongo Exp $
# @(#) $Revision: 29.12 $
# @(#) $Id: calc.spec.in,v 29.12 2003/04/15 03:37:59 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.spec.in,v $
#
# Under source code control: 2003/02/16 20:21:39
@@ -37,7 +37,7 @@
Summary: Arbitrary precision calculator.
Name: calc
Version: <<<PROJECT_VERSION>>>
Release: 2
Release: 0
Copyright: LGPL
Group: Applications/Engineering
Source: %{name}-%{version}.tar.gz

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.8 $
* @(#) $Id: config.c,v 29.8 2002/12/29 09:20:25 chongo Exp $
* @(#) $Revision: 29.9 $
* @(#) $Id: config.c,v 29.9 2003/04/15 03:37:16 chongo Exp chongo $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
*
* Under source code control: 1991/07/20 00:21:56
@@ -149,9 +149,9 @@ CONFIG oldstd = { /* backward compatible standard configuration */
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 +161,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 +170,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 */

View File

@@ -20,7 +20,7 @@
* 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 $
* @(#) $Id: config.h,v 29.12 2002/12/29 09:20:25 chongo Exp chongo $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.h,v $
*
* Under source code control: 1995/11/01 22:20:17
@@ -99,8 +99,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 */
@@ -196,8 +194,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") */

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: c_sysinfo.c,v 29.5 2001/04/14 23:04:17 chongo Exp $
* @(#) $Revision: 29.6 $
* @(#) $Id: c_sysinfo.c,v 29.6 2003/06/10 21:44:17 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_sysinfo.c,v $
*
* Under source code control: 1997/03/09 23:14:40
@@ -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},

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

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

View File

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

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.7 $
* @(#) $Id: quickhash.c,v 29.7 2003/03/01 01:21:12 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);
}
@@ -424,7 +458,8 @@ config_hash(CONFIG *cfg, QCKHASH val)
/*
* hash the built up scalar
*/
val = fnv(value, V_CONFIG+val);
val += V_CONFIG;
quasi_fnv(value, val);
/*
* hash the strings if possible
@@ -472,7 +507,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 +535,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 +559,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 +587,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 +597,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 +632,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 +661,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;

63
rpm.mk
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.
#
MAKEFILE_REV= $$Revision: 29.12 $$
# @(#) $Id: rpm.mk,v 29.12 2003/02/26 17:36:14 chongo Exp $
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
@@ -36,6 +36,8 @@ MAKEFILE_REV= $$Revision: 29.12 $$
#
SHELL= /bin/sh
RPMBUILD_TOOL= rpmbuild
TARCH= i686
RPMBUILD_OPTION= -ba --target=${TARCH}
RPM_TOOL= rpm
MD5SUM= md5sum
SHA1SUM= sha1sum
@@ -49,10 +51,8 @@ PROJECT_RELEASE=
PROJECT= $(PROJECT_NAME)-$(PROJECT_VERSION)
SPECFILE= $(PROJECT_NAME).spec
TARBALL= $(PROJECT).tar.gz
RPM386= $(PROJECT)-$(PROJECT_RELEASE).i386.rpm
RPM686= $(PROJECT)-$(PROJECT_RELEASE).i686.rpm
DRPM386= $(PROJECT_NAME)-devel-$(PROJECT_VERSION)-$(PROJECT_RELEASE).i386.rpm
DRPM686= $(PROJECT_NAME)-devel-$(PROJECT_VERSION)-$(PROJECT_RELEASE).i686.rpm
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
@@ -88,30 +88,10 @@ srcpkg: make_rhdir
rpm: srcpkg calc.spec
$(MAKE) -f Makefile clean
cp $(SPECFILE) $(RHDIR)/SPECS/$(SPECFILE)
rm -f $(RHDIR)/RPMS/i386/$(RPM386)
rm -f $(RHDIR)/RPMS/i386/$(DRPM386)
rm -f $(RHDIR)/RPMS/${TARCH}/$(RPM686)
rm -f $(RHDIR)/RPMS/${TARCH}/$(DRPM686)
rm -f $(RHDIR)/SRPMS/$(SRPM)
${RPMBUILD_TOOL} -ba $(RHDIR)/SPECS/$(SPECFILE)
@if [ ! -f "RPMS/i386/$(RPM686)" ]; then \
rm -f "$(RHDIR)/RPMS/i386/$(RPM686)"; \
echo mv -f "$(RHDIR)/RPMS/i386/$(RPM386)" \
"$(RHDIR)/RPMS/i386/$(RPM686)"; \
mv -f "$(RHDIR)/RPMS/i386/$(RPM386)" \
"$(RHDIR)/RPMS/i386/$(RPM686)"; \
else \
echo "RPMS/i386/$(RPM686) not found" 1>&2; \
exit 1; \
fi
@if [ ! -f "RPMS/i386/$(DRPM386)" ]; then \
rm -f "$(RHDIR)/RPMS/i386/$(DRPM686)"; \
echo mv -f "$(RHDIR)/RPMS/i386/$(DRPM386)" \
"$(RHDIR)/RPMS/i386/$(DRPM686)"; \
mv -f "$(RHDIR)/RPMS/i386/$(DRPM386)" \
"$(RHDIR)/RPMS/i386/$(DRPM686)"; \
else \
echo "RPMS/i386/$(DRPM386) not found" 1>&2; \
exit 2; \
fi
${RPMBUILD_TOOL} ${RPMBUILD_OPTION} $(RHDIR)/SPECS/$(SPECFILE)
@if [ ! -f "$(RHDIR)/SRPMS/$(SRPM)" ]; then \
echo "SRPMS/$(SRPM) not found" 1>&2; \
exit 3; \
@@ -119,23 +99,23 @@ rpm: srcpkg calc.spec
@echo
@echo "RPM package sizes:"
@echo
@cd $(RHDIR); ls -1s RPMS/i386/$(RPM686) \
RPMS/i386/$(DRPM686) SRPMS/$(SRPM)
@cd $(RHDIR); ls -1s RPMS/${TARCH}/$(RPM686) \
RPMS/${TARCH}/$(DRPM686) SRPMS/$(SRPM)
@echo
@echo "RPM package md5 hashes:"
@echo
-@cd $(RHDIR); ${MD5SUM} RPMS/i386/$(RPM686) \
RPMS/i386/$(DRPM686) SRPMS/$(SRPM)
-@cd $(RHDIR); ${MD5SUM} RPMS/${TARCH}/$(RPM686) \
RPMS/${TARCH}/$(DRPM686) SRPMS/$(SRPM)
@echo
@echo "RPM package sha1 hashes:"
@echo
-@cd $(RHDIR); ${SHA1SUM} RPMS/i386/$(RPM686) \
RPMS/i386/$(DRPM686) SRPMS/$(SRPM)
-@cd $(RHDIR); ${SHA1SUM} RPMS/${TARCH}/$(RPM686) \
RPMS/${TARCH}/$(DRPM686) SRPMS/$(SRPM)
@echo
@echo "RPM package locations:"
@echo
@ls -1 $(RHDIR)/RPMS/i386/$(RPM686) \
$(RHDIR)/RPMS/i386/$(DRPM686) $(RHDIR)/SRPMS/$(SRPM)
@ls -1 $(RHDIR)/RPMS/${TARCH}/$(RPM686) \
$(RHDIR)/RPMS/${TARCH}/$(DRPM686) $(RHDIR)/SRPMS/$(SRPM)
@echo
@echo "All done! -- Jessica Noll, Age 2"
@echo
@@ -156,8 +136,9 @@ logdate:
.PHONY: chkpkg
chkpkg:
for i in $(RHDIR)/RPMS/i386/$(RPM686) $(RHDIR)/RPMS/i386/$(DRPM686) \
$(RHDIR)/SRPMS/$(SRPM) ; do \
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" ; \
@@ -184,8 +165,8 @@ installrpm:
echo "must be root to install RPMs" 1>&2; \
exit 5; \
fi
${RPM_TOOL} -ivh $(RHDIR)/RPMS/i386/$(RPM686)
${RPM_TOOL} -ivh $(RHDIR)/RPMS/i386/$(DRPM686)
${RPM_TOOL} -ivh $(RHDIR)/RPMS/${TARCH}/$(RPM686)
${RPM_TOOL} -ivh $(RHDIR)/RPMS/${TARCH}/$(DRPM686)
.PHONY: uninstallrpm
uninstallrpm:

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.46 $
* @(#) $Id: version.c,v 29.46 2003/02/25 20:28:42 chongo Exp $
* @(#) $Revision: 29.47 $
* @(#) $Id: version.c,v 29.47 2003/06/10 19:23:33 chongo Exp chongo $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
*
* Under source code control: 1990/05/22 11:00:58
@@ -45,7 +45,7 @@ static char *program;
#define MAJOR_VER 2 /* major version */
#define MINOR_VER 11 /* minor version */
#define MAJOR_PATCH 7 /* patch level or 0 if no patch */
#define MAJOR_PATCH 8 /* patch level or 0 if no patch */
#define MINOR_PATCH 0 /* test number or 0 if no minor patch */
@@ -70,7 +70,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"