mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.11.5t4
This commit is contained in:
79
CHANGES
79
CHANGES
@@ -1,4 +1,71 @@
|
||||
The following are the changes from calc version 2.11.5t2 to date:
|
||||
The following are the changes from calc version 2.11.5t3 to date:
|
||||
|
||||
The Makefile will now send both stdout and sterr to /dev/null
|
||||
when compiling hsrc intermeriates.
|
||||
|
||||
The config("verbose_quit") value was restored to a default
|
||||
value of FALSE.
|
||||
|
||||
Added the cscript:
|
||||
|
||||
powerterm [base_limit] value
|
||||
|
||||
to write the value as the sum (or difference) of powers <= base_limit
|
||||
where base_limit by default is 10000.
|
||||
|
||||
Applied a bug fix by Dr.D.J.Picton <dave at aps5.ph.bham.ac.uk>
|
||||
to have help with no args print the default help file.
|
||||
|
||||
Renamed lavarand to LavaRnd.
|
||||
|
||||
Added rules to build a calc rpm.
|
||||
|
||||
All installed files are first formed as foo.new, and then moved
|
||||
into place as foo via a atomic rename.
|
||||
|
||||
During installation, only files that are different are installed.
|
||||
If the built file and the installed file are the same, no
|
||||
installation is performed.
|
||||
|
||||
Calc has new default installation locations:
|
||||
|
||||
Makefile var old location new location
|
||||
------------ ------------ ------------
|
||||
TOPDIR /usr/local/lib <<no longer used>>
|
||||
BINDIR /usr/local/bin /usr/bin
|
||||
SHAREDIR <<not set>> /usr/share
|
||||
INCDIR /usr/local/include /usr/include
|
||||
LIBDIR /usr/local/lib/calc /usr/lib
|
||||
CSHAREDIR <<not set>> /usr/share/calc
|
||||
HELPDIR /usr/local/lib/calc/help /usr/share/calc/help
|
||||
INCDIRCALC /usr/local/include/calc /usr/include/calc
|
||||
CUSTOMLIBDIR /usr/local/lib/calc/custom /usr/share/calc/custom
|
||||
CUSTOMHELPDIR /usr/local/lib/calc/help/custhelp /usr/share/calc/custhelp
|
||||
CUSTOMINCDIR <<not set>> /usr/include/calc/custom
|
||||
SCRIPTDIR /usr/local/bin/cscript /usr/bin/cscript
|
||||
MANDIR <<not set>> /usr/share/man/man1
|
||||
CATDIR <<not set>> <<not set>>
|
||||
|
||||
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}.
|
||||
|
||||
The install rules no longer remove old obsolete files. We assume
|
||||
that these old files have long since vanished! :-)
|
||||
|
||||
Reduced the amount of output when doing a make all where nothing
|
||||
needs to be made.
|
||||
|
||||
Reduced the amount of output when doing a make install where nothing
|
||||
needs to be installed.
|
||||
|
||||
If you install using the new default locations, you can remove
|
||||
old calc files installed in the old default location by doing:
|
||||
|
||||
make olduninstall
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.5t2 to 2.11.5t2.1:
|
||||
|
||||
Fixed a bug, reported by Ernest Bowen <ernie at turing dot
|
||||
une dot edu dot au> that caused command lines to be echoed in
|
||||
@@ -48,7 +115,7 @@ The following are the changes from calc version 2.11.5t2 to date:
|
||||
Added regression test 8310 to test for the static bug fix.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.5t0 to date:
|
||||
The following are the changes from calc version 2.11.5t0 to 2.11.5t1.1:
|
||||
|
||||
Fixed a compile problem with Linux 2.4 / Debian. Thanks goes
|
||||
to Martin Buck <m at rtin-buck dot de> for help with this issue.
|
||||
@@ -171,7 +238,7 @@ The following are the changes from calc version 2.11.5t0 to date:
|
||||
that have been attempted to be built for windoz.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.4t1 to date:
|
||||
The following are the changes from calc version 2.11.4t1 to 2.11.4t2:
|
||||
|
||||
Added missing test8600.cal test file.
|
||||
|
||||
@@ -5198,7 +5265,7 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
|
||||
|
||||
A small bug in the library file regress.cal was fixed.
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
## Copyright (C) 2001 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
|
||||
@@ -5214,8 +5281,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.29 $
|
||||
## @(#) $Id: CHANGES,v 29.29 2001/04/14 22:56:46 chongo Exp $
|
||||
## @(#) $Revision: 29.32 $
|
||||
## @(#) $Id: CHANGES,v 29.32 2001/05/28 21:59:59 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
|
||||
##
|
||||
## Under source code control: 1993/06/02 18:12:57
|
||||
|
70
cal/Makefile
70
cal/Makefile
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.5 $
|
||||
# @(#) $Id: Makefile,v 29.5 2001/03/31 16:24:17 chongo Exp $
|
||||
# @(#) $Revision: 29.9 $
|
||||
# @(#) $Id: Makefile,v 29.9 2001/05/28 21:56:08 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1991/07/21 05:00:54
|
||||
@@ -40,11 +40,12 @@ MAKE_FILE = Makefile
|
||||
# a default here just in case you want to build from this directory.
|
||||
#
|
||||
# where to install things
|
||||
TOPDIR= /usr/local/lib
|
||||
#TOPDIR= /usr/lib
|
||||
#TOPDIR= /usr/libdata
|
||||
#SHAREDIR= /usr/local/lib
|
||||
#SHAREDIR= /usr/lib
|
||||
SHAREDIR= /usr/share
|
||||
#SHAREDIR= /usr/libdata
|
||||
|
||||
LIBDIR= ${TOPDIR}/calc
|
||||
CSHAREDIR= ${SHAREDIR}/calc
|
||||
|
||||
# Makefile debug
|
||||
#
|
||||
@@ -57,6 +58,7 @@ Q=@
|
||||
# standard tools
|
||||
#
|
||||
CHMOD= chmod
|
||||
CMP= cmp
|
||||
|
||||
# The calc files to install
|
||||
#
|
||||
@@ -116,34 +118,56 @@ calcliblist:
|
||||
fi; \
|
||||
done
|
||||
|
||||
##
|
||||
#
|
||||
# rpm rules
|
||||
#
|
||||
##
|
||||
|
||||
echo_CALC_FILES: ${MAKE_FILE}
|
||||
@echo ${CALC_FILES}
|
||||
|
||||
echo_install.list: ${MAKE_FILE}
|
||||
@for i in ${CALC_FILES}; do \
|
||||
echo ${CSHAREDIR}/$$i; \
|
||||
done
|
||||
|
||||
##
|
||||
#
|
||||
# Utility rules
|
||||
#
|
||||
##
|
||||
|
||||
clean:
|
||||
|
||||
clobber:
|
||||
rm -f .all
|
||||
|
||||
install: all
|
||||
-${Q}if [ ! -d ${TOPDIR} ]; then \
|
||||
echo mkdir ${TOPDIR}; \
|
||||
mkdir ${TOPDIR}; \
|
||||
-${Q}if [ ! -d ${SHAREDIR} ]; then \
|
||||
echo mkdir ${SHAREDIR}; \
|
||||
mkdir ${SHAREDIR}; \
|
||||
echo ${CHMOD} 0755 ${SHAREDIR}; \
|
||||
${CHMOD} 0755 ${SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d ${LIBDIR} ]; then \
|
||||
echo mkdir ${LIBDIR}; \
|
||||
mkdir ${LIBDIR}; \
|
||||
-${Q}if [ ! -d ${CSHAREDIR} ]; then \
|
||||
echo mkdir ${CSHAREDIR}; \
|
||||
mkdir ${CSHAREDIR}; \
|
||||
echo ${CHMOD} 0755 ${CSHAREDIR}; \
|
||||
${CHMOD} 0755 ${CSHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
${Q}for i in ${CALC_FILES}; do \
|
||||
echo rm -f ${LIBDIR}/$$i; \
|
||||
rm -f ${LIBDIR}/$$i; \
|
||||
echo cp $$i ${LIBDIR}; \
|
||||
cp $$i ${LIBDIR}; \
|
||||
echo ${CHMOD} 0444 ${LIBDIR}/$$i; \
|
||||
${CHMOD} 0444 ${LIBDIR}/$$i; \
|
||||
if ${CMP} -s $$i ${CSHAREDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f ${CSHAREDIR}/$$i.new; \
|
||||
cp -f $$i ${CSHAREDIR}/$$i.new; \
|
||||
${CHMOD} 0444 ${CSHAREDIR}/$$i.new; \
|
||||
mv -f ${CSHAREDIR}/$$i.new ${CSHAREDIR}/$$i; \
|
||||
echo "installed ${CSHAREDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
${Q}echo remove files that are obsolete
|
||||
-rm -f nextprime.cal nextprim.cal
|
||||
-rm -f test1000.cal test2000.cal ${LIBDIR}/test2000.cal
|
||||
-rm -f ${LIBDIR}/nextprime.cal ${LIBDIR}/nextprim.cal
|
||||
-rm -f ${LIBDIR}/test1000.cal ${LIBDIR}/cryrand.cal
|
||||
|
15
codegen.c
15
codegen.c
@@ -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.5 $
|
||||
* @(#) $Id: codegen.c,v 29.5 2001/04/14 22:55:39 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: codegen.c,v 29.6 2001/05/08 06:29:24 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/codegen.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:13
|
||||
@@ -127,6 +127,7 @@ getcommands(BOOL toplevel)
|
||||
if (!toplevel)
|
||||
enterfilescope();
|
||||
for (;;) {
|
||||
int i;
|
||||
(void) tokenmode(TM_NEWLINES);
|
||||
switch (gettoken()) {
|
||||
|
||||
@@ -144,10 +145,14 @@ getcommands(BOOL toplevel)
|
||||
return;
|
||||
|
||||
case T_HELP:
|
||||
for (;;) {
|
||||
for (i=1;;i++) {
|
||||
switch(getfilename(name, NULL)) {
|
||||
case 1:
|
||||
strcpy(name, DEFAULTCALCHELP);
|
||||
case -1:
|
||||
if(i == 1) {
|
||||
strcpy(name, DEFAULTCALCHELP);
|
||||
givehelp(name);
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
givehelp(name);
|
||||
continue;
|
||||
|
8
config.c
8
config.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: config.c,v 29.6 2001/04/08 10:07:19 chongo Exp $
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: config.c,v 29.7 2001/04/25 07:15:22 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
|
||||
*
|
||||
* Under source code control: 1991/07/20 00:21:56
|
||||
@@ -133,7 +133,7 @@ CONFIG oldstd = { /* backward compatible standard configuration */
|
||||
0, /* internal calc debug level */
|
||||
3, /* calc resource file debug level */
|
||||
0, /* user defined debug level */
|
||||
TRUE, /* print Quit or abort executed messages */
|
||||
FALSE, /* print Quit or abort executed messages */
|
||||
CTRL_D_VIRGIN_EOF, /* ^D only exits on virgin lines */
|
||||
NULL, /* our name */
|
||||
NULL, /* basename of our name */
|
||||
@@ -178,7 +178,7 @@ CONFIG newstd = { /* new non-backward compatible configuration */
|
||||
0, /* internal calc debug level */
|
||||
3, /* calc resource file debug level */
|
||||
0, /* user defined debug level */
|
||||
TRUE, /* print Quit or abort executed messages */
|
||||
FALSE, /* print Quit or abort executed messages */
|
||||
CTRL_D_VIRGIN_EOF, /* ^D only exits on virgin lines */
|
||||
NULL, /* our name */
|
||||
NULL, /* basename of our name */
|
||||
|
@@ -17,8 +17,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.9 $
|
||||
# @(#) $Id: Makefile,v 29.9 2001/04/08 10:53:52 chongo Exp $
|
||||
# @(#) $Revision: 29.13 $
|
||||
# @(#) $Id: Makefile,v 29.13 2001/05/13 14:43:56 chongo Exp chongo $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1999/11/29 11:10:26
|
||||
@@ -39,8 +39,8 @@ MAKE_FILE = Makefile
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
#
|
||||
BINDIR= /usr/local/bin
|
||||
#BINDIR= /usr/bin
|
||||
#BINDIR= /usr/local/bin
|
||||
BINDIR= /usr/bin
|
||||
#BINDIR= /usr/contrib/bin
|
||||
#
|
||||
SCRIPTDIR= ${BINDIR}/cscript
|
||||
@@ -59,6 +59,7 @@ CHMOD= chmod
|
||||
SED= sed
|
||||
SORT= sort
|
||||
FMT= fmt
|
||||
CMP= cmp
|
||||
|
||||
# The ${SCRIPT} list is the list of calc shell script files (without the .calc
|
||||
# extension) which will be installed.
|
||||
@@ -76,10 +77,10 @@ FMT= fmt
|
||||
#
|
||||
# make detaillist
|
||||
#
|
||||
SCRIPT= mersenne piforever plus simple square fproduct
|
||||
SCRIPT= mersenne piforever plus simple square fproduct powerterm
|
||||
|
||||
SCRIPT_SRC= mersenne.calc piforever.calc plus.calc simple.calc square.calc \
|
||||
fproduct.calc
|
||||
fproduct.calc powerterm.calc
|
||||
|
||||
# These files are found (but not built) in the distribution
|
||||
#
|
||||
@@ -89,9 +90,17 @@ DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README
|
||||
#
|
||||
CALCLIBLIST=
|
||||
|
||||
# complete list of targets
|
||||
#
|
||||
# NOTE: This list MUST be co-ordinated with the ${CSCRIPT_TARGETS} variable
|
||||
# in the upper level ../Makefile
|
||||
#
|
||||
CSCRIPT_TARGETS= ${SCRIPT}
|
||||
TARGETS= ${CSCRIPT_TARGETS}
|
||||
|
||||
# The reason for this Makefile
|
||||
#
|
||||
all: ${SCRIPT} ${SCRIPT_SRC} .all
|
||||
all: ${TARGETS} .all
|
||||
|
||||
# used by the upper level Makefile to determine if we have done all
|
||||
#
|
||||
@@ -185,7 +194,7 @@ depend:
|
||||
${Q}echo "" >> Makefile
|
||||
${Q}${SED} -n '3,$$p' makedep.out >> Makefile
|
||||
-${Q}rm -f makedep.out
|
||||
-${Q}if cmp -s Makefile.bak Makefile; then \
|
||||
-${Q}if ${CMP} -s Makefile.bak Makefile; then \
|
||||
echo 'sample Makefile was already up to date'; \
|
||||
mv -f Makefile.bak Makefile; \
|
||||
else \
|
||||
@@ -200,32 +209,59 @@ depend:
|
||||
fi; \
|
||||
fi
|
||||
|
||||
##
|
||||
#
|
||||
# rpm rules
|
||||
#
|
||||
##
|
||||
|
||||
echo_SCRIPT: ${MAKE_FILE}
|
||||
@echo ${SCRIPT}
|
||||
|
||||
|
||||
echo_install.list: ${MAKE_FILE}
|
||||
@for i in ${SCRIPT}; do \
|
||||
echo ${SCRIPTDIR}/$$i; \
|
||||
done
|
||||
##
|
||||
#
|
||||
# Utility rules
|
||||
#
|
||||
##
|
||||
|
||||
clean:
|
||||
-rm -f makedep.out
|
||||
|
||||
clobber:
|
||||
-rm -f ${SCRIPT}
|
||||
-rm -f ${TARGETS}
|
||||
|
||||
install: all
|
||||
-${Q}if [ ! -d ${BINDIR} ]; then \
|
||||
echo mkdir ${BINDIR}; \
|
||||
mkdir ${BINDIR}; \
|
||||
echo mkdir ${BINDIR}; \
|
||||
mkdir ${BINDIR}; \
|
||||
echo ${CHMOD} 0755 ${BINDIR}; \
|
||||
${CHMOD} 0755 ${BINDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d ${SCRIPTDIR} ]; then \
|
||||
echo mkdir ${SCRIPTDIR}; \
|
||||
mkdir ${SCRIPTDIR}; \
|
||||
echo mkdir ${SCRIPTDIR}; \
|
||||
mkdir ${SCRIPTDIR}; \
|
||||
echo ${CHMOD} 0755 ${SCRIPTDIR}; \
|
||||
${CHMOD} 0755 ${SCRIPTDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
${Q}for i in ${SCRIPT}; do \
|
||||
echo rm -f ${SCRIPTDIR}/$$i; \
|
||||
rm -f ${SCRIPTDIR}/$$i; \
|
||||
echo cp $$i ${SCRIPTDIR}; \
|
||||
cp $$i ${SCRIPTDIR}; \
|
||||
echo ${CHMOD} 0555 ${SCRIPTDIR}/$$i; \
|
||||
if ${CMP} -s $$i ${SCRIPTDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f ${SCRIPTDIR}/$$i.new; \
|
||||
cp -f $$i ${SCRIPTDIR}/$$i.new; \
|
||||
${CHMOD} 0555 ${SCRIPTDIR}/$$i; \
|
||||
mv -f ${SCRIPTDIR}/$$i.new ${SCRIPTDIR}/$$i; \
|
||||
echo "installed ${SCRIPTDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
@@ -254,3 +290,7 @@ fproduct: fproduct.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
powerterm: powerterm.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
|
@@ -39,6 +39,12 @@ plus arg ...
|
||||
Print the sum of 1 or more arguments.
|
||||
|
||||
|
||||
powerterm [base_limit] value
|
||||
|
||||
Print the value as a sum (or difference) of powers of integers up
|
||||
to and including powers <= base_limit. By default, base_limit is 10000.
|
||||
|
||||
|
||||
simple
|
||||
|
||||
A trivial example of a calc shell script.
|
||||
@@ -59,8 +65,8 @@ simple
|
||||
## 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: README,v 29.5 2001/04/08 08:24:40 chongo Exp $
|
||||
## @(#) $Revision: 29.6 $
|
||||
## @(#) $Id: README,v 29.6 2001/04/25 07:26:12 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/README,v $
|
||||
##
|
||||
## Under source code control: 1999/12/17 10:23:40
|
||||
|
185
cscript/powerterm.calc
Normal file
185
cscript/powerterm.calc
Normal file
@@ -0,0 +1,185 @@
|
||||
#!/usr/local/bin/calc -q -s -f
|
||||
/*
|
||||
* powerterm - print the argument as a sum of powers of integers
|
||||
*
|
||||
* usage:
|
||||
* powerterm [base_limit] value
|
||||
*
|
||||
* base_limit largest base we will consider (def: 10000)
|
||||
* value value to convert into sums of powers of integers
|
||||
*
|
||||
* Copyright (C) 2001 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the powerterm of the version 2.1 of the GNU Lesser General Public License
|
||||
* 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.5 $
|
||||
* @(#) $Id: powerterm.calc,v 29.5 2001/04/25 08:41:36 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/powerterm.calc,v $
|
||||
*
|
||||
* Under source code control: 2001/04/24 23:49:11
|
||||
* File existed as early as: 2001
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* parse args
|
||||
*/
|
||||
config("verbose_quit", 0),;
|
||||
base_lim = 10000; /* default: highest base we will consider */
|
||||
if (argv() < 2 || argv() > 3) {
|
||||
fprintf(files(2), "usage: %s [base_limit] value\n", argv(0));
|
||||
exit;
|
||||
}
|
||||
if (argv() == 3) {
|
||||
x = eval(argv(2));
|
||||
base_lim = eval(argv(1));
|
||||
} else {
|
||||
x = eval(argv(1));
|
||||
}
|
||||
if (! isint(x)) {
|
||||
fprintf(files(2), "%s: value must be an integer\n");
|
||||
exit;
|
||||
}
|
||||
if (! isint(base_lim)) {
|
||||
fprintf(files(2), "%s: base limit must be an integer\n");
|
||||
exit;
|
||||
}
|
||||
if (base_lim <= 1) {
|
||||
fprintf(files(2), "%s: base limit is too small\n");
|
||||
exit;
|
||||
}
|
||||
++base_lim;
|
||||
|
||||
/*
|
||||
* setup loop variables
|
||||
*/
|
||||
term = 0; /* number of powerterm found */
|
||||
|
||||
/*
|
||||
* log constants
|
||||
*/
|
||||
if (base_lim <= 2^20+1) { /* 2^20 requires ~96 Megs of memory */
|
||||
mat lni[base_lim]; /* log of integers */
|
||||
for (i=2; i < base_lim; ++i) {
|
||||
lni[i] = ln(i);
|
||||
}
|
||||
have_lni = 1; /* have lni[x] array */
|
||||
} else {
|
||||
mat lni[1]; /* not used */
|
||||
have_lni = 0; /* base_lim too large for array */
|
||||
}
|
||||
|
||||
/*
|
||||
* remove nestest powers
|
||||
*/
|
||||
while (abs(x) >= base_lim) {
|
||||
|
||||
/*
|
||||
* look for the nearest power
|
||||
*/
|
||||
lnx = ln(abs(x)); /* log of the remaining co-factor */
|
||||
closest = 0.5;
|
||||
base = 1;
|
||||
exponent = 0;
|
||||
if (have_lni) {
|
||||
|
||||
/*
|
||||
* use pre-calculated log array when looking for the nearest power
|
||||
*/
|
||||
for (i = 2; i < base_lim; ++i) {
|
||||
|
||||
/*
|
||||
* determine exponent closeness to an integer
|
||||
*/
|
||||
ex = lnx / lni[i];
|
||||
power = int(ex + 0.5);
|
||||
diff = ex - power;
|
||||
|
||||
/*
|
||||
* look for a closer power
|
||||
*/
|
||||
if (abs(diff) < closest) {
|
||||
closest = abs(diff);
|
||||
base = i;
|
||||
exponent = power;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/*
|
||||
* re-calculate logs when looking for the nearest power
|
||||
*/
|
||||
for (i = 2; i < base_lim; ++i) {
|
||||
|
||||
/*
|
||||
* determine exponent closeness to an integer
|
||||
*/
|
||||
ex = lnx / ln(i);
|
||||
power = int(ex + 0.5);
|
||||
diff = ex - power;
|
||||
|
||||
/*
|
||||
* look for a closer power
|
||||
*/
|
||||
if (abs(diff) < closest) {
|
||||
closest = abs(diff);
|
||||
base = i;
|
||||
exponent = power;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* output current term and then subtract it
|
||||
*/
|
||||
if (x != 0) {
|
||||
if (x < 0) {
|
||||
print "-",;
|
||||
} else if (term > 0) {
|
||||
print "+",;
|
||||
}
|
||||
if (exponent > 1) {
|
||||
print base: "^": exponent,;
|
||||
} else {
|
||||
print base,;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* subtract (or add) this near power
|
||||
*/
|
||||
if (x < 0) {
|
||||
x = x + base^exponent;
|
||||
} else {
|
||||
x = x - base^exponent;
|
||||
}
|
||||
++term;
|
||||
}
|
||||
|
||||
/*
|
||||
* print the final term
|
||||
*/
|
||||
if (x < 0) {
|
||||
print "-", -x;
|
||||
} else if (x > 0) {
|
||||
print "+", x;
|
||||
} else {
|
||||
print "";
|
||||
}
|
||||
exit;
|
190
custom/Makefile
190
custom/Makefile
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.6 $
|
||||
# @(#) $Id: Makefile,v 29.6 2001/04/08 10:53:52 chongo Exp $
|
||||
# @(#) $Revision: 29.11 $
|
||||
# @(#) $Id: Makefile,v 29.11 2001/05/28 22:23:56 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/03/09 02:28:54
|
||||
@@ -93,21 +93,28 @@ Q=@
|
||||
#
|
||||
# where to install things
|
||||
#
|
||||
# ${TOPDIR} is the directory under which the calc directory will be placed.
|
||||
# ${LIBDIR} is where the *.cal, *.h, *.a, bindings and help dir are installed.
|
||||
# ${HELPDIR} is where the help directory is installed.
|
||||
# ${CUSTOMLIBDIR} is where custom lib files are installed.
|
||||
# ${CUSTOMHELPDIR} is where custom help files are installed.
|
||||
# ${SHAREDIR} where most common shared files are kept
|
||||
# ${INCDIR} where most .h files are kept
|
||||
#
|
||||
TOPDIR= /usr/local/lib
|
||||
#TOPDIR= /usr/lib
|
||||
#TOPDIR= /usr/libdata
|
||||
#TOPDIR= /usr/contrib/lib
|
||||
# ${CSHAREDIR} where most common shared calc files are kept
|
||||
# ${HELPDIR} where the help directory is installed.
|
||||
# ${INCDIRCALC} where the calc include files are installed
|
||||
# ${CUSTOMLIBDIR} where custom *.cal files & libcustcalc.a are installed.
|
||||
# ${CUSTOMHELPDIR} where custom help files are installed.
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed.
|
||||
#
|
||||
LIBDIR= ${TOPDIR}/calc
|
||||
HELPDIR= ${LIBDIR}/help
|
||||
CUSTOMLIBDIR= ${LIBDIR}/custom
|
||||
CUSTOMHELPDIR= ${HELPDIR}/custhelp
|
||||
#SHAREDIR= /usr/local/lib
|
||||
SHAREDIR= /usr/share
|
||||
#
|
||||
#INCDIR= /usr/local/include
|
||||
INCDIR= /usr/include
|
||||
#
|
||||
CSHAREDIR= ${SHAREDIR}/calc
|
||||
HELPDIR= ${CSHAREDIR}/help
|
||||
INCDIRCALC= ${INCDIR}/calc
|
||||
CUSTOMLIBDIR= ${CSHAREDIR}/custom
|
||||
CUSTOMHELPDIR= ${CSHAREDIR}/custhelp
|
||||
CUSTOMINCDIR= ${INCDIRCALC}/custom
|
||||
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
@@ -288,9 +295,13 @@ DISTLIST= ${CUSTCALC_SRC} ${CUSTOM_CALC_FILES} ${CUSTOM_HELP} \
|
||||
#
|
||||
CALCLIBLIST= ${CUSTCALC_SRC} ${INSTALL_H_SRC} ${MAKE_FILE} HOW_TO_ADD
|
||||
|
||||
# This is the custom .a link library that is build
|
||||
#
|
||||
CALC_LIBCUSTOM= libcustcalc.a
|
||||
|
||||
# complete list of targets
|
||||
#
|
||||
TARGETS= libcustcalc.a ${CUSTCALC_OBJ}
|
||||
TARGETS= ${CALC_LIBCUSTOM} ${CUSTCALC_OBJ}
|
||||
|
||||
# required vars
|
||||
#
|
||||
@@ -303,6 +314,7 @@ SED= sed
|
||||
MAKEDEPEND= makedepend
|
||||
CHMOD= chmod
|
||||
SORT= sort
|
||||
CMP= cmp
|
||||
|
||||
##
|
||||
#
|
||||
@@ -313,7 +325,7 @@ SORT= sort
|
||||
all: ${TARGETS} ${INSTALL_H_SRC} ${CUSTOM_CALC_FILES} \
|
||||
${CUSTOM_HELP} ${MAKE_FILE} .all
|
||||
|
||||
libcustcalc.a: ${CUSTCALC_OBJ} ${MAKE_FILE} ../Makefile
|
||||
libcustcalc.a: ${CUSTCALC_OBJ} ${MAKE_FILE} ../${MAKE_FILE}
|
||||
-rm -f libcustcalc.a
|
||||
ar qc libcustcalc.a ${CUSTCALC_OBJ}
|
||||
${RANLIB} libcustcalc.a
|
||||
@@ -435,7 +447,7 @@ depend:
|
||||
${Q}${SED} -n '3,$$p' skel/custom/makedep.out | \
|
||||
LANG=C ${SORT} -u >> Makefile
|
||||
-${Q}rm -rf skel
|
||||
-${Q}if cmp -s Makefile.bak Makefile; then \
|
||||
-${Q}if ${CMP} -s Makefile.bak Makefile; then \
|
||||
echo 'custom Makefile was already up to date'; \
|
||||
mv -f Makefile.bak Makefile; \
|
||||
else \
|
||||
@@ -450,6 +462,35 @@ depend:
|
||||
fi; \
|
||||
fi
|
||||
|
||||
##
|
||||
#
|
||||
# rpm rules
|
||||
#
|
||||
##
|
||||
|
||||
echo_INSTALL_H_SRC: ${MAKE_FILE}
|
||||
@echo ${INSTALL_H_SRC}
|
||||
|
||||
echo_CUSTOM_CALC_FILES: ${MAKE_FILE}
|
||||
@echo ${CUSTOM_CALC_FILES}
|
||||
|
||||
echo_CUSTOM_HELP: ${MAKE_FILE}
|
||||
@echo ${CUSTOM_HELP}
|
||||
|
||||
echo_install.list: ${MAKE_FILE}
|
||||
@for i in ${INSTALL_H_SRC}; do \
|
||||
echo ${CUSTOMINCDIR}/$$i; \
|
||||
done
|
||||
@for i in ${CUSTOM_HELP}; do \
|
||||
echo ${CUSTOMHELPDIR}/$$i; \
|
||||
done
|
||||
@for i in ${CUSTOM_CALC_FILES}; do \
|
||||
echo ${CUSTOMLIBDIR}/$$i; \
|
||||
done
|
||||
@for i in ${CALC_LIBCUSTOM}; do \
|
||||
echo ${CUSTOMLIBDIR}/$$i; \
|
||||
done
|
||||
|
||||
##
|
||||
#
|
||||
# Utility rules
|
||||
@@ -464,70 +505,119 @@ clobber:
|
||||
rm -f .all Makefile.tmp Makefile.bak
|
||||
|
||||
install: all
|
||||
-${Q}if [ ! -d ${TOPDIR} ]; then \
|
||||
echo mkdir ${TOPDIR}; \
|
||||
mkdir ${TOPDIR}; \
|
||||
-${Q}if [ ! -d ${SHAREDIR} ]; then \
|
||||
echo mkdir ${SHAREDIR}; \
|
||||
mkdir ${SHAREDIR}; \
|
||||
echo ${CHMOD} 0755 ${SHAREDIR}; \
|
||||
${CHMOD} 0755 ${SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d ${LIBDIR} ]; then \
|
||||
echo mkdir ${LIBDIR}; \
|
||||
mkdir ${LIBDIR}; \
|
||||
-${Q}if [ ! -d ${INCDIR} ]; then \
|
||||
echo mkdir ${INCDIR}; \
|
||||
mkdir ${INCDIR}; \
|
||||
echo ${CHMOD} 0755 ${INCDIR}; \
|
||||
${CHMOD} 0755 ${INCDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d ${CSHAREDIR} ]; then \
|
||||
echo mkdir ${CSHAREDIR}; \
|
||||
mkdir ${CSHAREDIR}; \
|
||||
echo ${CHMOD} 0755 ${CSHAREDIR}; \
|
||||
${CHMOD} 0755 ${CSHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d ${INCDIRCALC} ]; then \
|
||||
echo mkdir ${INCDIRCALC}; \
|
||||
mkdir ${INCDIRCALC}; \
|
||||
echo ${CHMOD} 0755 ${INCDIRCALC}; \
|
||||
${CHMOD} 0755 ${INCDIRCALC}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d ${HELPDIR} ]; then \
|
||||
echo mkdir ${HELPDIR}; \
|
||||
mkdir ${HELPDIR}; \
|
||||
echo ${CHMOD} 0755 ${HELPDIR}; \
|
||||
${CHMOD} 0755 ${HELPDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d ${CUSTOMLIBDIR} ]; then \
|
||||
echo mkdir ${CUSTOMLIBDIR}; \
|
||||
mkdir ${CUSTOMLIBDIR}; \
|
||||
echo ${CHMOD} 0755 ${CUSTOMLIBDIR}; \
|
||||
${CHMOD} 0755 ${CUSTOMLIBDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d ${CUSTOMHELPDIR} ]; then \
|
||||
echo mkdir ${CUSTOMHELPDIR}; \
|
||||
mkdir ${CUSTOMHELPDIR}; \
|
||||
echo ${CHMOD} 0755 ${CUSTOMHELPDIR}; \
|
||||
${CHMOD} 0755 ${CUSTOMHELPDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
${Q}for i in ${INSTALL_H_SRC} /dev/null; do \
|
||||
if [ X$$i = X/dev/null ]; then continue; fi; \
|
||||
echo rm -f ${CUSTOMLIBDIR}/$$i; \
|
||||
rm -f ${CUSTOMLIBDIR}/$$i; \
|
||||
echo cp $$i ${CUSTOMLIBDIR}; \
|
||||
cp $$i ${CUSTOMLIBDIR}; \
|
||||
echo ${CHMOD} 0444 ${CUSTOMLIBDIR}/$$i; \
|
||||
${CHMOD} 0444 ${CUSTOMLIBDIR}/$$i; \
|
||||
-${Q}if [ ! -d ${CUSTOMINCDIR} ]; then \
|
||||
echo mkdir ${CUSTOMINCDIR}; \
|
||||
mkdir ${CUSTOMINCDIR}; \
|
||||
echo ${CHMOD} 0755 ${CUSTOMINCDIR}; \
|
||||
${CHMOD} 0755 ${CUSTOMINCDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}for i in ${INSTALL_H_SRC}; do \
|
||||
rm -f tmp; \
|
||||
${SED} -e 's/^\(#[ ]*include[ ][ ]*\)"/\1"calc\//' $$i > tmp; \
|
||||
if ${CMP} -s tmp ${CUSTOMINCDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f ${CUSTOMINCDIR}/$$i; \
|
||||
cp -f tmp ${INCDIRCALC}/$$i.new; \
|
||||
cp -f $$i ${CUSTOMINCDIR}/$$i.new; \
|
||||
${CHMOD} 0444 ${CUSTOMINCDIR}/$$i.new; \
|
||||
mv -f ${CUSTOMINCDIR}/$$i.new ${CUSTOMINCDIR}/$$i; \
|
||||
echo "installed ${CUSTOMINCDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
${Q}for i in ${CUSTOM_CALC_FILES}; do \
|
||||
echo rm -f ${CUSTOMLIBDIR}/$$i; \
|
||||
-${Q}rm -f tmp
|
||||
-${Q}for i in ${CUSTOM_CALC_FILES}; do \
|
||||
if ${CMP} -s $$i ${CUSTOMLIBDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f ${CUSTOMLIBDIR}/$$i; \
|
||||
echo cp $$i ${CUSTOMLIBDIR}; \
|
||||
cp $$i ${CUSTOMLIBDIR}; \
|
||||
echo ${CHMOD} 0444 ${CUSTOMLIBDIR}/$$i; \
|
||||
${CHMOD} 0444 ${CUSTOMLIBDIR}/$$i; \
|
||||
cp -f $$i ${CUSTOMLIBDIR}/$$i; \
|
||||
${CHMOD} 0444 ${CUSTOMLIBDIR}/$$i.new; \
|
||||
mv -f ${CUSTOMLIBDIR}/$$i.new ${CUSTOMLIBDIR}/$$i; \
|
||||
echo "installed ${CUSTOMLIBDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
${Q}for i in ${CUSTOM_HELP}; do \
|
||||
echo rm -f ${CUSTOMHELPDIR}/$$i; \
|
||||
-${Q}for i in ${CUSTOM_HELP}; do \
|
||||
if ${CMP} -s $$i ${CUSTOMHELPDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f ${CUSTOMHELPDIR}/$$i; \
|
||||
echo cp $$i ${CUSTOMHELPDIR}; \
|
||||
cp $$i ${CUSTOMHELPDIR}; \
|
||||
echo ${CHMOD} 0444 ${CUSTOMHELPDIR}/$$i; \
|
||||
${CHMOD} 0444 ${CUSTOMHELPDIR}/$$i; \
|
||||
cp -f $$i ${CUSTOMHELPDIR}/$$i.new; \
|
||||
${CHMOD} 0444 ${CUSTOMHELPDIR}/$$i.new; \
|
||||
mv -f ${CUSTOMHELPDIR}/$$i.new ${CUSTOMHELPDIR}/$$i; \
|
||||
echo "installed ${CUSTOMHELPDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}if [ ! -z ${ALLOW_CUSTOM} ]; then \
|
||||
echo "rm -f ${CUSTOMLIBDIR}/libcustcalc.a"; \
|
||||
rm -f ${CUSTOMLIBDIR}/libcustcalc.a; \
|
||||
echo "cp libcustcalc.a ${CUSTOMLIBDIR}/libcustcalc.a"; \
|
||||
cp libcustcalc.a ${CUSTOMLIBDIR}/libcustcalc.a; \
|
||||
echo "${CHMOD} 0644 ${CUSTOMLIBDIR}/libcustcalc.a"; \
|
||||
if ${CMP} -s libcustcalc.a ${CUSTOMLIBDIR}/libcustcalc.a; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f ${CUSTOMLIBDIR}/libcustcalc.a.new; \
|
||||
cp -f libcustcalc.a ${CUSTOMLIBDIR}/libcustcalc.a.new; \
|
||||
${CHMOD} 0644 ${CUSTOMLIBDIR}/libcustcalc.a; \
|
||||
echo "${RANLIB} ${CUSTOMLIBDIR}/libcustcalc.a"; \
|
||||
mv -f ${CUSTOMLIBDIR}/libcustcalc.a.new \
|
||||
${CUSTOMLIBDIR}/libcustcalc.a; \
|
||||
${RANLIB} ${CUSTOMLIBDIR}/libcustcalc.a; \
|
||||
echo "installed ${CUSTOMLIBDIR}/libcustcalc.a"; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
##
|
||||
|
101
help/Makefile
101
help/Makefile
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.6 $
|
||||
# @(#) $Id: Makefile,v 29.6 2001/04/08 10:53:52 chongo Exp $
|
||||
# @(#) $Revision: 29.12 $
|
||||
# @(#) $Id: Makefile,v 29.12 2001/05/28 22:36:28 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1991/07/23 06:47:57
|
||||
@@ -36,15 +36,16 @@
|
||||
SHELL= /bin/sh
|
||||
MAKE_FILE = Makefile
|
||||
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
# ${SHAREDIR} where most common shared files are kept
|
||||
#
|
||||
TOPDIR= /usr/local/lib
|
||||
#TOPDIR= /usr/lib
|
||||
#TOPDIR= /usr/libdata
|
||||
# ${CSHAREDIR} where most common shared calc files are kept
|
||||
# ${HELPDIR} where the help directory is installed.
|
||||
#
|
||||
#SHAREDIR= /usr/local/lib
|
||||
SHAREDIR= /usr/share
|
||||
|
||||
LIBDIR= ${TOPDIR}/calc
|
||||
HELPDIR= ${LIBDIR}/help
|
||||
CSHAREDIR= ${SHAREDIR}/calc
|
||||
HELPDIR= ${CSHAREDIR}/help
|
||||
|
||||
# Makefile debug
|
||||
#
|
||||
@@ -63,6 +64,7 @@ CHMOD= chmod
|
||||
SED= sed
|
||||
SORT= sort
|
||||
FMT= fmt
|
||||
CMP= cmp
|
||||
|
||||
# Standard and Builtin help files
|
||||
#
|
||||
@@ -489,6 +491,37 @@ detaillist:
|
||||
${SED} -e '1s/xxxxx/DETAIL_HELP=/' -e '2,$$s/^/ /' \
|
||||
-e 's/$$/ \\/' -e '$$s/ \\$$//'
|
||||
|
||||
##
|
||||
#
|
||||
# rpm rules
|
||||
#
|
||||
##
|
||||
|
||||
echo_STD_HELP_FILES: ${MAKE_FILE}
|
||||
@echo ${STD_HELP_FILES}
|
||||
|
||||
echo_BLT_HELP_FILES: ${MAKE_FILE}
|
||||
@echo ${BLT_HELP_FILES}
|
||||
|
||||
echo_DETAIL_HELP: ${MAKE_FILE}
|
||||
@echo ${DETAIL_HELP}
|
||||
|
||||
echo_SINGULAR_FILES: ${MAKE_FILE}
|
||||
@echo ${SINGULAR_FILES}
|
||||
|
||||
echo_install.list: ${MAKE_FILE}
|
||||
@for i in ${STD_HELP_FILES} full ${BLT_HELP_FILES} \
|
||||
builtin ${DETAIL_HELP} ${SINGULAR_FILES}; do \
|
||||
echo ${HELPDIR}/$$i; \
|
||||
done
|
||||
@echo ${HELPDIR}/obj
|
||||
|
||||
##
|
||||
#
|
||||
# Utility rules
|
||||
#
|
||||
##
|
||||
|
||||
clean:
|
||||
rm -f obj mkbuiltin funclist.c funclist.o funclist
|
||||
rm -f COPYING COPYING-LGPL
|
||||
@@ -500,36 +533,48 @@ clobber:
|
||||
rm -f ${SINGULAR_FILES} ${DETAIL_CLONE}
|
||||
|
||||
install: all
|
||||
-${Q}if [ ! -d ${TOPDIR} ]; then \
|
||||
echo mkdir ${TOPDIR}; \
|
||||
mkdir ${TOPDIR}; \
|
||||
-${Q}if [ ! -d ${SHAREDIR} ]; then \
|
||||
echo mkdir ${SHAREDIR}; \
|
||||
mkdir ${SHAREDIR}; \
|
||||
echo ${CHMOD} 0755 ${SHAREDIR}; \
|
||||
${CHMOD} 0755 ${SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d ${LIBDIR} ]; then \
|
||||
echo mkdir ${LIBDIR}; \
|
||||
mkdir ${LIBDIR}; \
|
||||
-${Q}if [ ! -d ${CSHAREDIR} ]; then \
|
||||
echo mkdir ${CSHAREDIR}; \
|
||||
mkdir ${CSHAREDIR}; \
|
||||
echo ${CHMOD} 0755 ${CSHAREDIR}; \
|
||||
${CHMOD} 0755 ${CSHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
-${Q}if [ ! -d ${HELPDIR} ]; then \
|
||||
echo mkdir ${HELPDIR}; \
|
||||
mkdir ${HELPDIR}; \
|
||||
echo ${CHMOD} 0755 ${HELPDIR}; \
|
||||
${CHMOD} 0755 ${HELPDIR}; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
${Q}for i in ${STD_HELP_FILES} ${BLT_HELP_FILES} builtin \
|
||||
-${Q}for i in ${STD_HELP_FILES} ${BLT_HELP_FILES} builtin \
|
||||
full ${DETAIL_HELP} ${SINGULAR_FILES}; do \
|
||||
echo rm -f ${HELPDIR}/$$i; \
|
||||
rm -f ${HELPDIR}/$$i; \
|
||||
echo cp $$i ${HELPDIR}; \
|
||||
cp $$i ${HELPDIR}; \
|
||||
echo ${CHMOD} 0444 ${HELPDIR}/$$i; \
|
||||
${CHMOD} 0444 ${HELPDIR}/$$i; \
|
||||
if ${CMP} -s $$i ${HELPDIR}/$$i; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f ${HELPDIR}/$$i.new; \
|
||||
cp -f $$i ${HELPDIR}/$$i.new; \
|
||||
${CHMOD} 0444 ${HELPDIR}/$$i.new; \
|
||||
mv -f ${HELPDIR}/$$i.new ${HELPDIR}/$$i; \
|
||||
echo "installed ${HELPDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
rm -f ${HELPDIR}/obj
|
||||
cp obj.file ${HELPDIR}/obj
|
||||
${CHMOD} 0444 ${HELPDIR}/obj
|
||||
${Q}echo remove files that are obsolete
|
||||
-rm -f rmblk block stdlib
|
||||
-rm -f ${HELPDIR}/rmblk ${HELPDIR}/block ${HELPDIR}/stdlib
|
||||
-${Q}if ${CMP} -s obj.file ${HELPDIR}/obj; then \
|
||||
true; \
|
||||
else \
|
||||
rm -f ${HELPDIR}/obj.new; \
|
||||
cp -f obj.file ${HELPDIR}/obj.new; \
|
||||
${CHMOD} 0444 ${HELPDIR}/obj.new; \
|
||||
mv -f ${HELPDIR}/obj.new ${HELPDIR}/obj; \
|
||||
echo "installed ${HELPDIR}/obj"; \
|
||||
fi
|
||||
|
@@ -580,12 +580,14 @@ Detailed config descriptions
|
||||
|
||||
The "verbose_quit" controls the print of the message:
|
||||
|
||||
Quit or abort executed
|
||||
quit or abort executed
|
||||
|
||||
when a non-interactive quit or abort without an argument is encountered.
|
||||
A quit of abort without an argument does not display a message when
|
||||
invoked at the interactive level.
|
||||
|
||||
By deafult, "verbose_quit" is false.
|
||||
|
||||
=-=
|
||||
|
||||
config("ctrl_d", "ctrl_d_string")
|
||||
@@ -711,8 +713,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.5 $
|
||||
## @(#) $Id: config,v 29.5 2001/04/14 22:46:33 chongo Exp $
|
||||
## @(#) $Revision: 29.6 $
|
||||
## @(#) $Id: config,v 29.6 2001/04/25 07:17:38 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/config,v $
|
||||
##
|
||||
## Under source code control: 1991/07/21 04:37:17
|
||||
|
@@ -19,9 +19,9 @@ DESCRIPTION
|
||||
is almost certainly non-chaotic. This function is likely not
|
||||
suitable for applications (such as cryptographic applications)
|
||||
where the unpredictability of seeds is critical. For such critical
|
||||
applications, lavarand should be used. See the URL:
|
||||
applications, LavaRnd should be used. See the URL:
|
||||
|
||||
http://lavarand.sgi.com/index.html
|
||||
http://www.LavaRnd.org/
|
||||
|
||||
for information about seeding a pseudo-random number generator
|
||||
(such as rand() or random()) with the cryptographic hash of the
|
||||
@@ -67,8 +67,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: seed,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: seed,v 29.3 2001/05/13 13:26:26 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/seed,v $
|
||||
##
|
||||
## Under source code control: 1999/10/03 10:04:29
|
||||
|
10
help/srandom
10
help/srandom
@@ -220,11 +220,11 @@ DESCRIPTION
|
||||
Blum moduli.
|
||||
|
||||
The pre-defined Blum moduli and quadratic residues were selected
|
||||
by lavarand, a hardware random number generator. See the URL:
|
||||
by LavaRnd, a hardware random number generator. See the URL:
|
||||
|
||||
http://lavarand.sgi.com/index.html
|
||||
http://www.LavaRnd.org/
|
||||
|
||||
for an explanation of how the lavarand random number generator works.
|
||||
for an explanation of how the LavaRnd random number generator works.
|
||||
For more information, see the comments at the top of the calc
|
||||
source file, zrandom.c.
|
||||
|
||||
@@ -354,8 +354,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: srandom,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: srandom,v 29.3 2001/05/13 13:26:26 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/srandom,v $
|
||||
##
|
||||
## Under source code control: 1997/02/17 01:18:22
|
||||
|
@@ -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: opcodes.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: opcodes.c,v 29.4 2001/04/25 07:16:26 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/opcodes.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:19
|
||||
@@ -3234,7 +3234,7 @@ o_quit(FUNC *fp, long index)
|
||||
if (cp)
|
||||
printf("%s\n", cp);
|
||||
else if (conf->verbose_quit)
|
||||
printf("Quit or abort executed\n");
|
||||
printf("quit or abort executed\n");
|
||||
if (!inputisterminal() && !strcmp(fp->f_name, "*"))
|
||||
closeinput();
|
||||
go = FALSE;
|
||||
|
@@ -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: Makefile,v 29.5 2001/04/08 10:53:52 chongo Exp $
|
||||
# @(#) $Revision: 29.9 $
|
||||
# @(#) $Id: Makefile,v 29.9 2001/05/28 22:27:15 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/sample/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/04/19 22:46:49
|
||||
@@ -78,18 +78,30 @@ Q=@
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
#
|
||||
# where to install things
|
||||
# where things go
|
||||
#
|
||||
# ${TOPDIR} is the directory under which the calc directory will be placed.
|
||||
# ${LIBDIR} is where the *.cal, *.h, *.a, bindings and help dir are installed.
|
||||
# ${HELPDIR} is where the help directory is installed.
|
||||
# ${BINDIR} where to install binary files
|
||||
# ${SHAREDIR} where most common shared files are kept
|
||||
# ${INCDIR} where most .h files are kept
|
||||
# ${LIBDIR} where *.a files are installed
|
||||
#
|
||||
TOPDIR= /usr/local/lib
|
||||
#TOPDIR= /usr/lib
|
||||
#TOPDIR= /usr/libdata
|
||||
#TOPDIR= /usr/contrib/lib
|
||||
# ${CSHAREDIR} where most common shared calc files are kept
|
||||
# ${HELPDIR} where the help directory is installed.
|
||||
#
|
||||
LIBDIR= ${TOPDIR}/calc
|
||||
#BINDIR= /usr/local/bin
|
||||
BINDIR= /usr/bin
|
||||
#BINDIR= /usr/contrib/bin
|
||||
#
|
||||
#SHAREDIR= /usr/local/lib
|
||||
SHAREDIR= /usr/share
|
||||
#
|
||||
#INCDIR= /usr/local/include
|
||||
INCDIR= /usr/include
|
||||
#
|
||||
#LIBDIR= /usr/local/lib
|
||||
LIBDIR= /usr/lib
|
||||
|
||||
CSHAREDIR= ${SHAREDIR}/calc
|
||||
HELPDIR= ${LIBDIR}/help
|
||||
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
@@ -266,12 +278,15 @@ CALCLIBLIST= ${C_SRC} ${H_SRC} ${MAKE_FILE} README_SAMPLE
|
||||
|
||||
# complete list of targets
|
||||
#
|
||||
TARGETS= many_random test_random
|
||||
# NOTE: This list MUST be co-ordinated with the ${SAMPLE_TARGETS} variable
|
||||
# in the upper level ../Makefile
|
||||
#
|
||||
SAMPLE_TARGETS= many_random test_random
|
||||
TARGETS= ${SAMPLE_TARGETS}
|
||||
|
||||
# required vars
|
||||
#
|
||||
SHELL= /bin/sh
|
||||
MAKE_FILE= Makefile
|
||||
|
||||
# standard tools
|
||||
#
|
||||
@@ -279,6 +294,7 @@ SED= sed
|
||||
MAKEDEPEND= makedepend
|
||||
CHMOD= chmod
|
||||
SORT= sort
|
||||
CMP= cmp
|
||||
|
||||
##
|
||||
#
|
||||
@@ -287,6 +303,7 @@ SORT= sort
|
||||
##
|
||||
|
||||
all: ${TARGETS} .all
|
||||
@true
|
||||
|
||||
test_random.o: test_random.c
|
||||
${CC} ${CFLAGS} ${ALLOW_CUSTOM} test_random.c -c
|
||||
@@ -407,7 +424,7 @@ depend:
|
||||
${Q}${SED} -n '3,$$p' skel/sample/makedep.out | \
|
||||
LANG=C ${SORT} -u >> Makefile
|
||||
-${Q}rm -rf skel
|
||||
-${Q}if cmp -s Makefile.bak Makefile; then \
|
||||
-${Q}if ${CMP} -s Makefile.bak Makefile; then \
|
||||
echo 'sample Makefile was already up to date'; \
|
||||
mv -f Makefile.bak Makefile; \
|
||||
else \
|
||||
@@ -422,6 +439,15 @@ depend:
|
||||
fi; \
|
||||
fi
|
||||
|
||||
##
|
||||
#
|
||||
# rpm rules
|
||||
#
|
||||
##
|
||||
|
||||
echo_install.list: Makefile
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
# Utility rules
|
||||
@@ -437,7 +463,9 @@ clobber:
|
||||
rm -f .all Makefile.tmp sample
|
||||
|
||||
# for right now we will not install anything
|
||||
#
|
||||
install: all
|
||||
@true
|
||||
|
||||
##
|
||||
#
|
||||
|
12
seed.c
12
seed.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: seed.c,v 29.4 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: seed.c,v 29.5 2001/05/08 06:44:29 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/seed.c,v $
|
||||
*
|
||||
* Under source code control: 1999/10/03 10:06:53
|
||||
@@ -31,10 +31,10 @@
|
||||
/*
|
||||
* Generate a quasi-random seed based on system and process information.
|
||||
*
|
||||
* NOTE: This is not a good source of chaotic data. The lavarand
|
||||
* NOTE: This is not a good source of chaotic data. The LavaRnd
|
||||
* system does a much better job of that. See:
|
||||
*
|
||||
* http://lavarand.sgi.com/index.html
|
||||
* http://www.LavaRnd.org/
|
||||
*/
|
||||
|
||||
|
||||
@@ -270,10 +270,10 @@ hash_buf(char *buf, unsigned len)
|
||||
*
|
||||
* Generate a quasi-random seed based on system and process information.
|
||||
*
|
||||
* NOTE: This is not a good source of chaotic data. The lavarand
|
||||
* NOTE: This is not a good source of chaotic data. The LavaRnd
|
||||
* system does a much better job of that. See:
|
||||
*
|
||||
* http://lavarand.sgi.com/index.html
|
||||
* http://www.LavaRnd.org/
|
||||
*
|
||||
* PORTING NOTE:
|
||||
* If when porting this code to your system and something
|
||||
|
98
spec-template
Normal file
98
spec-template
Normal file
@@ -0,0 +1,98 @@
|
||||
Summary: C-style arbitrary precision calculator
|
||||
Name: calc
|
||||
Version: ${VERSION}
|
||||
Release: ${RELEASE}
|
||||
Copyright: LGPL
|
||||
Group: Applications/Engineering
|
||||
Source: http://www.isthe.com/chongo/src/calc/calc-${VER_CALC}.tar.gz
|
||||
BuildRoot: /var/tmp/%{name}-buildroot
|
||||
|
||||
%description
|
||||
Calc is an interactive calculator which provides for easy large numeric
|
||||
calculations, but which also can be easily programmed for difficult or
|
||||
long calculations.
|
||||
|
||||
All numbers are represented as fractions with arbitrarily large numerators
|
||||
and denominators which are always reduced to lowest terms. Real or
|
||||
exponential format numbers are converted to the equivalent fraction.
|
||||
One use enter decinal, hex, octal, binary and complex values.
|
||||
|
||||
Commands are statements in a C-like language, where each input line is
|
||||
treated as the body of a procedure. You can define your own functions
|
||||
by using the 'define' keyword, followed by a function declaration very
|
||||
similar to C. Calc also comes with a rich set of builtin functions
|
||||
and calc shell commands.
|
||||
|
||||
In addition to numeric global, local and static variables, Calc as
|
||||
lists, associated arrays, matrices, byte blocks, dymanic strings and
|
||||
user defined objects.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
mkdir -p $RPM_BUILD_ROOT${BINDIR}
|
||||
mkdir -p $RPM_BUILD_ROOT${SHAREDIR}
|
||||
mkdir -p $RPM_BUILD_ROOT${INCDIR}
|
||||
mkdir -p $RPM_BUILD_ROOT${LIBDIR}
|
||||
mkdir -p $RPM_BUILD_ROOT${CSHAREDIR}
|
||||
mkdir -p $RPM_BUILD_ROOT${HELPDIR}
|
||||
mkdir -p $RPM_BUILD_ROOT${INCDIRCALC}
|
||||
mkdir -p $RPM_BUILD_ROOT${CUSTOMLIBDIR}
|
||||
mkdir -p $RPM_BUILD_ROOT${CUSTOMHELPDIR}
|
||||
mkdir -p $RPM_BUILD_ROOT${CUSTOMINCDIR}
|
||||
mkdir -p $RPM_BUILD_ROOT${SCRIPTDIR}
|
||||
mkdir -p $RPM_BUILD_ROOT${MANDIR}
|
||||
|
||||
install -m 0555 calc $RPM_BUILD_ROOT${BINDIR}
|
||||
|
||||
(cd help
|
||||
install -m 0444 ${STD_HELP_FILES} $RPM_BUILD_ROOT${HELPDIR}
|
||||
install -m 0444 ${BLT_HELP_FILES} $RPM_BUILD_ROOT${HELPDIR}
|
||||
install -m 0444 builtin full $RPM_BUILD_ROOT${HELPDIR}
|
||||
install -m 0444 ${DETAIL_HELP} $RPM_BUILD_ROOT${HELPDIR}
|
||||
install -m 0444 ${SINGULAR_FILES} $RPM_BUILD_ROOT${HELPDIR}
|
||||
install -m 0444 obj.file $RPM_BUILD_ROOT${HELPDIR}/obj
|
||||
)
|
||||
|
||||
(cd cal; install -m 0444 ${CALC_FILES} $RPM_BUILD_ROOT${LIBDIR})
|
||||
|
||||
(cd custom
|
||||
if [ ! -z "${INSTALL_H_SRC}" ]; then
|
||||
install -m 0444 ${INSTALL_H_SRC} $RPM_BUILD_ROOT${CUSTOMINCDIR}
|
||||
fi
|
||||
install -m 0444 ${CUSTOM_CALC_FILES} $RPM_BUILD_ROOT${CUSTOMLIBDIR}
|
||||
install -m 0444 ${CUSTOM_HELP} $RPM_BUILD_ROOT${CUSTOMHELPDIR}
|
||||
if [ ! -z "${ALLOW_CUSTOM}" ]; then
|
||||
install -m 0644 libcustcalc.a $RPM_BUILD_ROOT${CUSTOMLIBDIR}
|
||||
${RANLIB} $RPM_BUILD_ROOT${CUSTOMLIBDIR}
|
||||
fi
|
||||
)
|
||||
|
||||
(cd cscript
|
||||
install -m 0555 ${SCRIPT} $RPM_BUILD_ROOT${SCRIPTDIR}
|
||||
)
|
||||
|
||||
install -m 0444 libcalc.a $RPM_BUILD_ROOT${LIBDIR}
|
||||
${RANLIB} $RPM_BUILD_ROOT${LIBDIR}
|
||||
install -m 0444 ${LIB_H_SRC} $RPM_BUILD_ROOT${INCDIRCALC}
|
||||
install -m 0444 ${BUILD_H_SRC} $RPM_BUILD_ROOT${INCDIRCALC}
|
||||
install -m 0444 calc.1 $RPM_BUILD_ROOT${MANDIR}.${MANEXT}
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files -f install.list
|
||||
%defattr(-,root,root)
|
||||
%doc BUGS README COPYING COPYING-LGPL HOWTO.INSTALL
|
||||
%doc README LIBRARY README.WINDOWS calc.1
|
||||
%doc help/resource help/errorcodes help/custom_cal help/new_custom
|
||||
%doc help/cscript help/full
|
||||
|
||||
%changelog
|
||||
* ${DATE} Landon Curt Noll <http://www.isthe.com/chongo/index.html>
|
||||
- calc version ${VER_CALC}
|
92
version.c
92
version.c
@@ -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.24 $
|
||||
* @(#) $Id: version.c,v 29.24 2001/04/14 22:56:46 chongo Exp $
|
||||
* @(#) $Revision: 29.26 $
|
||||
* @(#) $Id: version.c,v 29.26 2001/05/28 22:00:22 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
|
||||
*
|
||||
* Under source code control: 1990/05/22 11:00:58
|
||||
@@ -43,7 +43,7 @@ static char *program;
|
||||
#define MAJOR_VER 2 /* major version */
|
||||
#define MINOR_VER 11 /* minor version */
|
||||
#define MAJOR_PATCH 5 /* patch level or 0 if no patch */
|
||||
#define MINOR_PATCH "3" /* test number or empty string if no patch */
|
||||
#define MINOR_PATCH "4" /* test number or empty string if no patch */
|
||||
|
||||
/*
|
||||
* calc version constants
|
||||
@@ -144,6 +144,82 @@ version(void)
|
||||
|
||||
#if defined(CALC_VER)
|
||||
|
||||
|
||||
/*
|
||||
* print_rpm_version_release - print the rpm style version-release
|
||||
*
|
||||
* This function prints a version-release string, rpm style:
|
||||
*
|
||||
* x.y.z-w
|
||||
* x.y.z-0
|
||||
* x.y-0
|
||||
*/
|
||||
void
|
||||
print_rpm_version_release(void)
|
||||
{
|
||||
/*
|
||||
* form the version buffer
|
||||
*/
|
||||
if (sizeof(MINOR_PATCH) > 1) {
|
||||
printf("%d.%d.%d-%s\n", calc_major_ver, calc_minor_ver,
|
||||
calc_major_patch, calc_minor_patch);
|
||||
} else if (MAJOR_PATCH > 0) {
|
||||
printf("%d.%d.%d-0\n", calc_major_ver, calc_minor_ver,
|
||||
calc_major_patch);
|
||||
} else {
|
||||
printf("%d.%d-0\n", calc_major_ver, calc_minor_ver);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* print_rpm_version - print just the version string, rpm style
|
||||
*
|
||||
* This function prints a version string, rpm style:
|
||||
*
|
||||
* x.y.z
|
||||
* x.y
|
||||
*/
|
||||
void
|
||||
print_rpm_version(void)
|
||||
{
|
||||
/*
|
||||
* form the version buffer
|
||||
*/
|
||||
if (MAJOR_PATCH > 0) {
|
||||
printf("%d.%d.%d\n", calc_major_ver, calc_minor_ver,
|
||||
calc_major_patch);
|
||||
} else {
|
||||
printf("%d.%d\n", calc_major_ver, calc_minor_ver);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* print_rpm_release - print just the release string, rpm style
|
||||
*
|
||||
* This function prints a release string, rpm style:
|
||||
*
|
||||
* w
|
||||
* 0
|
||||
*/
|
||||
void
|
||||
print_rpm_release(void)
|
||||
{
|
||||
/*
|
||||
* form the version buffer
|
||||
*/
|
||||
if (sizeof(MINOR_PATCH) > 1) {
|
||||
printf("%s\n", calc_minor_patch);
|
||||
} else {
|
||||
printf("0\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* version - print the calc version
|
||||
*/
|
||||
@@ -152,7 +228,15 @@ int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
program = argv[0];
|
||||
printf("%s\n", version());
|
||||
if (argc == 2 && strcmp(argv[1], "-R") == 0) {
|
||||
print_rpm_version_release();
|
||||
} else if (argc == 2 && strcmp(argv[1], "-v") == 0) {
|
||||
print_rpm_version();
|
||||
} else if (argc == 2 && strcmp(argv[1], "-r") == 0) {
|
||||
print_rpm_release();
|
||||
} else {
|
||||
printf("%s\n", version());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
8
zrand.c
8
zrand.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: zrand.c,v 29.3 2001/04/14 22:47:21 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: zrand.c,v 29.4 2001/05/08 06:44:29 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zrand.c,v $
|
||||
*
|
||||
* Under source code control: 1995/01/07 09:45:25
|
||||
@@ -284,7 +284,7 @@
|
||||
* SOURCE OF MAGIC NUMBERS:
|
||||
*
|
||||
* Most of the magic constants used on this file ultimately are
|
||||
* based on SGI Lavarand. SGI Lavarand produced a 5-way cryprographic
|
||||
* based on LavaRnd. LavaRnd produced them via a cryprographic
|
||||
* of the digitization of chaotic system that consisted of a noisy
|
||||
* digital camera and 6 Lava Lite(R) lamps.
|
||||
*
|
||||
@@ -568,7 +568,7 @@ static CONST RAND init_s100 = {
|
||||
*
|
||||
* The subtractive 100 table in init_s100 has been processed 256 times in order
|
||||
* to preload the shuffle table. The array below is the table before
|
||||
* this processing. These values have came from Lavarand.
|
||||
* this processing. These values have came from LavaRnd.
|
||||
*
|
||||
* This array is never changed, only copied.
|
||||
*/
|
||||
|
22
zrandom.c
22
zrandom.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: zrandom.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: zrandom.c,v 29.3 2001/05/08 06:44:29 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zrandom.c,v $
|
||||
*
|
||||
* Under source code control: 1997/02/15 04:01:56
|
||||
@@ -356,33 +356,33 @@
|
||||
*
|
||||
* The pre-defined Blum moduli was computed by searching for Blum
|
||||
* primes (primes == 3 mod 4) starting from new values that
|
||||
* were selected by lavarand, a hardware random number generator.
|
||||
* were selected by LavaRnd, a hardware random number generator.
|
||||
* See the URL:
|
||||
*
|
||||
* http://lavarand.sgi.com/index.html
|
||||
* http://www.LavaRnd.org/
|
||||
*
|
||||
* for an explination of how the lavarand random number generator works.
|
||||
* for an explination of how the LavaRnd random number generator works.
|
||||
*
|
||||
* For a given newn, we select a given bit length. For 0 < newn <= 20,
|
||||
* the bit length selected was by:
|
||||
*
|
||||
* bitlen = 2^(int((newn-1)/4)+7) + small_random_value;
|
||||
*
|
||||
* where small_random_value is also generated by lavarand. For
|
||||
* where small_random_value is also generated by LavaRnd. For
|
||||
* 1 <= newn <= 16, small_random_value is a random value in [0,40).
|
||||
* For 17 < newn <= 20, small_random_value is a random value in [0,120).
|
||||
* Given two random integers generated by lavarand, we used the following
|
||||
* Given two random integers generated by LavaRnd, we used the following
|
||||
* to compute Blum primes:
|
||||
*
|
||||
* (* find the first Blum prime *)
|
||||
* fp = int((ip-1)/2); (* ip was generated by lavarand *)
|
||||
* fp = int((ip-1)/2); (* ip was generated by LavaRnd *)
|
||||
* do {
|
||||
* fp = nextcand(fp+2, 25, 0, 3, 4);
|
||||
* p = 2*fp+1;
|
||||
* } while (ptest(p, 25) == 0);
|
||||
*
|
||||
* (* find the 2nd Blum prime *)
|
||||
* fq = int((iq-1)/2); (* iq was generated by lavarand *)
|
||||
* fq = int((iq-1)/2); (* iq was generated by LavaRnd *)
|
||||
* do {
|
||||
* fq = nextcand(fq+2, 25, 0, 3, 4);
|
||||
* q = 2*fq+1;
|
||||
@@ -391,8 +391,8 @@
|
||||
* (* compute the Blum modulus *)
|
||||
* n[newn] = p * q;
|
||||
*
|
||||
* The pre-defined quadratic residues was also generated by lavarand.
|
||||
* The value produced by lavarand was squared mod the Blum moduli
|
||||
* The pre-defined quadratic residues was also generated by LavaRnd.
|
||||
* The value produced by LavaRnd was squared mod the Blum moduli
|
||||
* that was previously computed.
|
||||
*
|
||||
* The purpose of these pre-defined Blum moduli is to provide users with
|
||||
|
Reference in New Issue
Block a user