mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
cbcb5801fb | ||
|
bdf495150e | ||
|
b3648f030f | ||
|
71e88bdc91 | ||
|
ca0dd4560b | ||
|
f62d9fa1e6 | ||
|
253b47942f | ||
|
c773ee736f | ||
|
7d0cc52afe | ||
|
2441df7fdc | ||
|
5c565a7cea | ||
|
810e541281 | ||
|
ee30d787ea | ||
|
4e92927183 | ||
|
fb4a03c1f1 | ||
|
81a523043e | ||
|
2c0d0bbc1b | ||
|
a7147039ee | ||
|
6fa83e417e | ||
|
c335809b5f | ||
|
ee99adf8ca | ||
|
87570b56fe | ||
|
afe37ec851 | ||
|
bd3086138b | ||
|
9d62873a02 |
107
BUGS
107
BUGS
@@ -68,22 +68,45 @@ of a context diff patch).
|
|||||||
|
|
||||||
Known bugs:
|
Known bugs:
|
||||||
|
|
||||||
The stoponerror() facility does not seem to work, or perhaps
|
|
||||||
the stoponerror help file is incorrect. The stoponerror help file
|
|
||||||
lacks examples because of this problem.
|
|
||||||
|
|
||||||
We are sure some more bugs exist. When you find them, please let
|
We are sure some more bugs exist. When you find them, please let
|
||||||
us know! See the above for details on how to report and were to
|
us know! See the above for details on how to report and were to
|
||||||
EMail your bug reports and hopefully patches to fix them.
|
EMail your bug reports and hopefully patches to fix them.
|
||||||
|
|
||||||
=-=
|
=-=
|
||||||
|
|
||||||
|
Problems that have known work-a-rounds:
|
||||||
|
|
||||||
|
* There is a bug in gcc v4.1.0 that causes calc to fail the regression
|
||||||
|
test. The work-a-round is to compile with gcc v4.1.1 or later. This
|
||||||
|
problems was observed on Fedora 5.
|
||||||
|
|
||||||
|
=-=
|
||||||
|
|
||||||
mis-features in calc:
|
mis-features in calc:
|
||||||
|
|
||||||
Some problems are not bugs but rarther mis-features / things that could
|
Some problems are not bugs but rarther mis-features / things that could
|
||||||
work better. The following is a list of mis-features that should be
|
work better. The following is a list of mis-features that should be
|
||||||
addressed and improved someday.
|
addressed and improved someday.
|
||||||
|
|
||||||
|
* When statement is of the form { ... }, the leading { MUST BE ON
|
||||||
|
THE SAME LINE as the if, for, while or do keyword.
|
||||||
|
|
||||||
|
This works as expected:
|
||||||
|
|
||||||
|
if (expr) {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
However this WILL NOT WORK AS EXPECTED:
|
||||||
|
|
||||||
|
if (expr)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
This needs to be changed. See also "help statement", "help unexpected",
|
||||||
|
and "help todo".
|
||||||
|
|
||||||
* The chi.cal resource file does not work well with odd degrees
|
* The chi.cal resource file does not work well with odd degrees
|
||||||
of freedom. Can someone improve this algorithm?
|
of freedom. Can someone improve this algorithm?
|
||||||
|
|
||||||
@@ -106,75 +129,7 @@ mis-features in calc:
|
|||||||
|
|
||||||
will not.
|
will not.
|
||||||
|
|
||||||
=-=
|
## Copyright (C) 1999-2007 Landon Curt Noll
|
||||||
|
|
||||||
Problems with old systems that have known work-a-rounds:
|
|
||||||
|
|
||||||
* There is a bug in gcc-2.95 that causes calc, when compiled with -O2,
|
|
||||||
to fail the regression test. The work-a-round is to compile with -O
|
|
||||||
or to use gcc-2.96 or later.
|
|
||||||
|
|
||||||
This bug has been observed on the Sparc and the PowerPC machine.
|
|
||||||
|
|
||||||
On the PowerPC with gcc-2.95 when compiled with -O2, the following
|
|
||||||
patch seems to help:
|
|
||||||
|
|
||||||
*** zfunc.c.orig Fri Feb 23 18:18:39 2001
|
|
||||||
--- zfunc.c Fri Feb 23 18:39:33 2001
|
|
||||||
***************
|
|
||||||
*** 1481,1487 ****
|
|
||||||
{
|
|
||||||
HALF *a, *A, *b, *a0, u;
|
|
||||||
int i, j, j1, j2, k, k1, m, m0, m1, n, n0, o;
|
|
||||||
! FULL d, e, f, g, h, s, t, x, topbit;
|
|
||||||
int remsign;
|
|
||||||
BOOL up, onebit;
|
|
||||||
ZVALUE sqrt;
|
|
||||||
--- 1481,1488 ----
|
|
||||||
{
|
|
||||||
HALF *a, *A, *b, *a0, u;
|
|
||||||
int i, j, j1, j2, k, k1, m, m0, m1, n, n0, o;
|
|
||||||
! volatile FULL d;
|
|
||||||
! FULL e, f, g, h, s, t, x, topbit;
|
|
||||||
int remsign;
|
|
||||||
BOOL up, onebit;
|
|
||||||
ZVALUE sqrt;
|
|
||||||
*** zmath.c 2000/06/07 14:02:13 29.2
|
|
||||||
--- zmath.c 2001/03/13 19:47:03
|
|
||||||
***************
|
|
||||||
*** 1608,1614 ****
|
|
||||||
void
|
|
||||||
zbitvalue(long n, ZVALUE *res)
|
|
||||||
{
|
|
||||||
! ZVALUE z;
|
|
||||||
|
|
||||||
if (n < 0) n = 0;
|
|
||||||
z.sign = 0;
|
|
||||||
--- 1608,1614 ----
|
|
||||||
void
|
|
||||||
zbitvalue(long n, ZVALUE *res)
|
|
||||||
{
|
|
||||||
! volatile ZVALUE z;
|
|
||||||
|
|
||||||
if (n < 0) n = 0;
|
|
||||||
z.sign = 0;
|
|
||||||
|
|
||||||
* There are problems compiling calc on the sparcv9 under 64 bit
|
|
||||||
Solaris. On that platform, gcc-2.96 is able to compile calc, but
|
|
||||||
calc dumps core very early on in startup. It is said that sparcv9
|
|
||||||
support in gcc-2.96 is very unofficial and thus there is no
|
|
||||||
work-a-round for gcc-2-96.
|
|
||||||
|
|
||||||
There is a work-a-round for this architecture us one is using the
|
|
||||||
Solaris CC on the sparcv9. It has been reported that setting the
|
|
||||||
following Makefile variables will produce a working version of
|
|
||||||
calc on the sparcv9 under 64 bit Solaris:
|
|
||||||
|
|
||||||
LCC="cc -xarch=v9"
|
|
||||||
CCWARN="-DFORCE_STDC -w"
|
|
||||||
DEBUG="-fast -xarch=v9"
|
|
||||||
|
|
||||||
## Copyright (C) 1999-2006 Landon Curt Noll
|
|
||||||
##
|
##
|
||||||
## Calc is open software; you can redistribute it and/or modify it under
|
## 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
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -188,10 +143,10 @@ Problems with old systems that have known work-a-rounds:
|
|||||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
## 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
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.24 $
|
## @(#) $Revision: 30.1 $
|
||||||
## @(#) $Id: BUGS,v 29.24 2006/05/21 07:54:13 chongo Exp $
|
## @(#) $Id: BUGS,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/BUGS,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/RCS/BUGS,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1994/03/18 14:06:13
|
## Under source code control: 1994/03/18 14:06:13
|
||||||
|
20
COPYING
20
COPYING
@@ -12,8 +12,8 @@ This file is Copyrighted
|
|||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
# @(#) $Revision: 29.8 $
|
# @(#) $Revision: 30.1 $
|
||||||
# @(#) $Id: COPYING,v 29.8 2006/05/01 19:16:57 chongo Exp $
|
# @(#) $Id: COPYING,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/COPYING,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/RCS/COPYING,v $
|
||||||
|
|
||||||
=-=
|
=-=
|
||||||
@@ -45,12 +45,12 @@ Calc is covered by the GNU Lesser General Public License
|
|||||||
Public License by the calc command: help copying-lgpl
|
Public License by the calc command: help copying-lgpl
|
||||||
|
|
||||||
You should have received a copy of the version 2.1 GNU Lesser General
|
You should have received a copy of the version 2.1 GNU Lesser General
|
||||||
Public License with calc; if not, write to:
|
Public License with calc; if not, write to the following address:
|
||||||
|
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
59 Temple Place
|
51 Franklin Street
|
||||||
Suite 330
|
Fifth Floor
|
||||||
Boston, MA 02111-1307
|
Boston, MA 02110-1301
|
||||||
USA
|
USA
|
||||||
|
|
||||||
The contact addresses for calc is as follows:
|
The contact addresses for calc is as follows:
|
||||||
@@ -182,9 +182,11 @@ Calc copyrights and exception files
|
|||||||
top of this file. It is important to note that you may distribute
|
top of this file. It is important to note that you may distribute
|
||||||
verbatim copies of this file but you may not modify this file.
|
verbatim copies of this file but you may not modify this file.
|
||||||
|
|
||||||
Some of these exception files are in the public domain. Other
|
Some of these exception files are in the public domain. The md5.c
|
||||||
exception files have non-LGPL Copyrights. Other files are under a
|
and md5.h files were "derived from the RSA Data Security, Inc. MD5
|
||||||
LGPL Copyright but have different authors.
|
Message-Digest Algorithm" and are under a copyright that allows these
|
||||||
|
two files to be freely used and distributed. Other files are under
|
||||||
|
the LGPL but have different authors that those listed above.
|
||||||
|
|
||||||
In all cases one may use and distribute these exception files freely.
|
In all cases one may use and distribute these exception files freely.
|
||||||
And because one may freely distribute the LGPL covered files, the
|
And because one may freely distribute the LGPL covered files, the
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
Version 2.1, February 1999
|
Version 2.1, February 1999
|
||||||
|
|
||||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
@@ -476,7 +476,7 @@ convey the exclusion of warranty; and each file should have at least the
|
|||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2 of the License, or (at your option) any later version.
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
@@ -485,7 +485,7 @@ convey the exclusion of warranty; and each file should have at least the
|
|||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Installing calc from the gziped tarball in 4 easy steps:
|
Installing calc from the bzip2-ed tarball in 4 easy steps:
|
||||||
|
|
||||||
0) If your platform supports i686 RPMs, you may want to go to:
|
0) If your platform supports i686 RPMs, you may want to go to:
|
||||||
|
|
||||||
@@ -17,16 +17,30 @@ Installing calc from the gziped tarball in 4 easy steps:
|
|||||||
|
|
||||||
The following 4 steps apply to calc source tree that comes from either:
|
The following 4 steps apply to calc source tree that comes from either:
|
||||||
|
|
||||||
gunzip -c calc-*.tar.gz | tar -xvf -
|
bunzip2 -c calc-*.tar.bz2 | tar -xvf -
|
||||||
|
|
||||||
or from:
|
or from:
|
||||||
|
|
||||||
rpm -ivh calc-*.src.rpm
|
rpm -ivh calc-*.src.rpm
|
||||||
cd /var/tmp
|
cd /var/tmp
|
||||||
gunzip -c /usr/src/redhat/SOURCES/calc-*.tar.gz | tar -xvf -
|
bunzip2 -c /usr/src/redhat/SOURCES/calc-*.tar.bz2 | tar -xvf -
|
||||||
|
|
||||||
1) Look at the makefile, and adjust it to suit your needs.
|
1) Look at the makefile, and adjust it to suit your needs.
|
||||||
|
|
||||||
|
The top level Makefile and the custom/Makefile require a GNU
|
||||||
|
Make (such as gmake) or an equivalently advanced make. On many
|
||||||
|
targets, the default make is sufficent. On FreeBSD for example,
|
||||||
|
one must use gmake instead of make.
|
||||||
|
|
||||||
|
If your target system does not have GNU Make (or equivalent), then
|
||||||
|
you should try using the Makefile.simple and custom/Makefile.simple
|
||||||
|
files:
|
||||||
|
|
||||||
|
mv Makefile Makefile.gmake
|
||||||
|
cp Makefile.simple Makefile
|
||||||
|
mv custom/Makefile custom/Makefile.gmake
|
||||||
|
cp custom/Makefile.simple custom/Makefile
|
||||||
|
|
||||||
The Makefile, as shipped, is suitable for installation under
|
The Makefile, as shipped, is suitable for installation under
|
||||||
Linux and Un*x-like environments. For the most part, the default
|
Linux and Un*x-like environments. For the most part, the default
|
||||||
values should work. If in doubt, follow the 'When in doubt'
|
values should work. If in doubt, follow the 'When in doubt'
|
||||||
@@ -52,14 +66,14 @@ Installing calc from the gziped tarball in 4 easy steps:
|
|||||||
CALC_INCDIR where the calc include files are installed
|
CALC_INCDIR where the calc include files are installed
|
||||||
CUSTOMCALDIR where custom *.cal files are installed
|
CUSTOMCALDIR where custom *.cal files are installed
|
||||||
CUSTOMHELPDIR where custom help files are installed
|
CUSTOMHELPDIR where custom help files are installed
|
||||||
CUSTOMINCPDIR where custom .h files are installed
|
CUSTOMINCDIR where custom .h files are installed
|
||||||
SCRIPTDIR where calc shell scripts are installed
|
SCRIPTDIR where calc shell scripts are installed
|
||||||
|
|
||||||
If you want to install calc files under a top level directory,
|
If you want to install calc files under a top level directory,
|
||||||
then set the T value:
|
then set the T value:
|
||||||
|
|
||||||
The calc install is performed under $T, the calc build is
|
The calc install is performed under ${T}, the calc build is
|
||||||
performed under /. The purpose for $T is to allow someone
|
performed under /. The purpose for ${T} is to allow someone
|
||||||
to install calc somewhere other than into the system area.
|
to install calc somewhere other than into the system area.
|
||||||
|
|
||||||
For example, if:
|
For example, if:
|
||||||
@@ -79,10 +93,10 @@ Installing calc from the gziped tarball in 4 easy steps:
|
|||||||
calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||||
... etc ... /var/tmp/testing/...
|
... etc ... /var/tmp/testing/...
|
||||||
|
|
||||||
If $T is empty, calc is installed under /, which is the same
|
If ${T} is empty, calc is installed under /, which is the same
|
||||||
top of tree for which it was built. If $T is non-empty, then
|
top of tree for which it was built. If ${T} is non-empty, then
|
||||||
calc is installed under $T, as if one had to chroot under
|
calc is installed under ${T}, as if one had to chroot under
|
||||||
$T for calc to operate.
|
${T} for calc to operate.
|
||||||
|
|
||||||
Look for the section that starts:
|
Look for the section that starts:
|
||||||
|
|
||||||
@@ -126,12 +140,36 @@ Installing calc from the gziped tarball in 4 easy steps:
|
|||||||
|
|
||||||
2) build calc:
|
2) build calc:
|
||||||
|
|
||||||
|
The top level Makefile and the custom/Makefile require a GNU
|
||||||
|
Make (such as gmake) or an equivalently advanced make. On many
|
||||||
|
targets, the default make is sufficent. On FreeBSD for example,
|
||||||
|
one must use gmake instead of make.
|
||||||
|
|
||||||
|
If your target system does not have GNU Make (or equivalent), then
|
||||||
|
you should try using the Makefile.simple and custom/Makefile.simple
|
||||||
|
files:
|
||||||
|
|
||||||
|
mv Makefile Makefile.gmake
|
||||||
|
cp Makefile.simple Makefile
|
||||||
|
mv custom/Makefile custom/Makefile.gmake
|
||||||
|
cp custom/Makefile.simple custom/Makefile
|
||||||
|
|
||||||
make all
|
make all
|
||||||
|
|
||||||
==> We are interested in any compiler warnings (and errors) that
|
==> We are interested in any compiler warnings (and errors) that
|
||||||
you may find. See the BUGS file if you find any compiler
|
you may find. See the BUGS file if you find any compiler
|
||||||
warning or errors.
|
warning or errors.
|
||||||
|
|
||||||
|
NOTE: You can force calc to build with only static libs:
|
||||||
|
|
||||||
|
make clobber
|
||||||
|
make calc-static-only BLD_TYPE=calc-static-only
|
||||||
|
|
||||||
|
or force calc to build with only dynamic libs:
|
||||||
|
|
||||||
|
make clobber
|
||||||
|
make calc-dynamic-only BLD_TYPE=calc-dynamic-only
|
||||||
|
|
||||||
3) test calc:
|
3) test calc:
|
||||||
|
|
||||||
make check
|
make check
|
||||||
@@ -139,6 +177,10 @@ Installing calc from the gziped tarball in 4 easy steps:
|
|||||||
==> If you run into problems, read the BUGS file and follow
|
==> If you run into problems, read the BUGS file and follow
|
||||||
the instructions found in there.
|
the instructions found in there.
|
||||||
|
|
||||||
|
NOTE: For a quiet check which only prints if something goes wrong:
|
||||||
|
|
||||||
|
make chk
|
||||||
|
|
||||||
4) install calc:
|
4) install calc:
|
||||||
|
|
||||||
make install
|
make install
|
||||||
@@ -146,7 +188,7 @@ Installing calc from the gziped tarball in 4 easy steps:
|
|||||||
We suggest that you might want to read the README file and look at
|
We suggest that you might want to read the README file and look at
|
||||||
the calc help subsystem. See the README file for details.
|
the calc help subsystem. See the README file for details.
|
||||||
|
|
||||||
## Copyright (C) 1999 Landon Curt Noll
|
## Copyright (C) 1999-2007 Landon Curt Noll
|
||||||
##
|
##
|
||||||
## Calc is open software; you can redistribute it and/or modify it under
|
## 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
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -160,10 +202,10 @@ the calc help subsystem. See the README file for details.
|
|||||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
## 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
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.7 $
|
## @(#) $Revision: 30.6 $
|
||||||
## @(#) $Id: HOWTO.INSTALL,v 29.7 2003/04/15 03:38:34 chongo Exp $
|
## @(#) $Id: HOWTO.INSTALL,v 30.6 2007/10/16 12:22:22 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/HOWTO.INSTALL,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/RCS/HOWTO.INSTALL,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1999/09/27 20:48:44
|
## Under source code control: 1999/09/27 20:48:44
|
||||||
|
251
LIBRARY
251
LIBRARY
@@ -58,13 +58,18 @@ External programs most likely want to use the installed calc header
|
|||||||
files under ${INCDIRCALC}. External programs most likely NOT want
|
files under ${INCDIRCALC}. External programs most likely NOT want
|
||||||
to define CALC_SRC.
|
to define CALC_SRC.
|
||||||
|
|
||||||
|
You need to include the following file to get the symbols and variables
|
||||||
|
related to error handling:
|
||||||
|
|
||||||
|
lib_calc.h
|
||||||
|
|
||||||
External programs may want to compile with:
|
External programs may want to compile with:
|
||||||
|
|
||||||
-L${LIBDIR} -lcalc
|
-I${INCDIR} -L${LIBDIR} -lcalc
|
||||||
|
|
||||||
If custom functions are also used, they may want to compile with:
|
If custom functions are also used, they may want to compile with:
|
||||||
|
|
||||||
-L${LIBDIR} -lcalc -lcustcalc
|
-I${INCDIR} -L${LIBDIR} -lcalc -lcustcalc
|
||||||
|
|
||||||
The CALC_SRC symbol should NOT be defined by default. However if you are
|
The CALC_SRC symbol should NOT be defined by default. However if you are
|
||||||
feeling pedantic you may want to force CALC_SRC to be undefined:
|
feeling pedantic you may want to force CALC_SRC to be undefined:
|
||||||
@@ -73,71 +78,215 @@ feeling pedantic you may want to force CALC_SRC to be undefined:
|
|||||||
|
|
||||||
as well.
|
as well.
|
||||||
|
|
||||||
--------------
|
-------------------
|
||||||
ERROR HANDLING
|
MATH ERROR HANDLING
|
||||||
--------------
|
-------------------
|
||||||
|
|
||||||
Your program MUST provide a function called math_error. This is called by
|
The math_error() function is called by the math routines on an error
|
||||||
the math routines on an error condition, such as malloc failures or a
|
condition, such as malloc failures, division by zero, or some form of
|
||||||
division by zero. The routine is called in the manner of printf, with a
|
an internal computation error. The routine is called in the manner of
|
||||||
format string and optional arguments. (However, none of the low level math
|
printf, with a format string and optional arguments:
|
||||||
routines currently uses formatting, so if you are lazy you can simply use
|
|
||||||
the first argument as a simple error string.) For example, one of the
|
|
||||||
error calls you might expect to receive is:
|
|
||||||
|
|
||||||
math_error("Division by zero");
|
void math_error(char *fmt, ...);
|
||||||
|
|
||||||
Your program can handle errors in basically one of two ways. Firstly, it
|
Your program must handle math errors in one of three ways:
|
||||||
can simply print the error message and then exit. Secondly, you can make
|
|
||||||
use of setjmp and longjmp in your program. Use setjmp at some appropriate
|
|
||||||
level in your program, and use longjmp in the math_error routine to return
|
|
||||||
to that level and so recover from the error. This is what the calc program
|
|
||||||
does.
|
|
||||||
|
|
||||||
For convenience, the link library libcalc.a contains a math_error routine.
|
1) Print the error message and then exit
|
||||||
By default, this routine simply prints a message to stderr and then exits.
|
|
||||||
By simply linking in this link library, any calc errors will result in a
|
|
||||||
error message on stderr followed by an exit.
|
|
||||||
|
|
||||||
External programs that wish to use this math_error may want to compile with:
|
There is a math_error() function supplied with the calc library.
|
||||||
|
By default, this routine simply prints a message to stderr and
|
||||||
|
then exits. By simply linking in this link library, any calc
|
||||||
|
errors will result in a error message on stderr followed by
|
||||||
|
an exit.
|
||||||
|
|
||||||
-I${LIBDIR} -L${LIBDIR} -lcalc
|
2) Use setjmp and longjmp in your program
|
||||||
|
|
||||||
If one sets up calc_jmp_buf, and then sets calc_jmp to non-zero then
|
Use setjmp at some appropriate level in your program, and let
|
||||||
this routine will longjmp back (with the value of calc_jmp) instead.
|
the longjmp in math_error() return to that level and to allow you
|
||||||
In addition, the last calc error message will be found in calc_error;
|
to recover from the error. This is what the calc program does.
|
||||||
this error is not printed to stderr. The calc error message will
|
|
||||||
not have a trailing newline.
|
|
||||||
|
|
||||||
For example:
|
If one sets up calc_matherr_jmpbuf, and then sets
|
||||||
|
calc_use_matherr_jmpbuf to non-zero then math_error() will
|
||||||
|
longjmp back with the return value of calc_use_matherr_jmpbuf.
|
||||||
|
In addition, the last calc error message will be found in
|
||||||
|
calc_err_msg; this error is not printed to stderr. The calc
|
||||||
|
error message will not have a trailing newline.
|
||||||
|
|
||||||
#include <setjmp.h>
|
For example:
|
||||||
|
|
||||||
extern jmp_buf calc_jmp_buf;
|
#include <setjmp.h>
|
||||||
extern int calc_jmp;
|
#include "lib_calc.h"
|
||||||
extern char *calc_error;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
...
|
int error;
|
||||||
|
|
||||||
if ((error = setjmp(calc_jmp_buf)) != 0) {
|
...
|
||||||
|
|
||||||
/* reinitialize calc after a longjmp */
|
if ((error = setjmp(calc_matherr_jmpbuf)) != 0) {
|
||||||
reinitialize();
|
|
||||||
|
/* report the error */
|
||||||
|
printf("Ouch: %s\n", calc_err_msg);
|
||||||
|
|
||||||
|
/* reinitialize calc after the longjmp */
|
||||||
|
reinitialize();
|
||||||
|
}
|
||||||
|
calc_use_matherr_jmpbuf = 1;
|
||||||
|
|
||||||
|
If calc_use_matherr_jmpbuf is non-zero, then the jmp_buf value
|
||||||
|
calc_matherr_jmpbuf must be initialized by the setjmp() function
|
||||||
|
or your program will crash.
|
||||||
|
|
||||||
|
3) Supply your own math_error function:
|
||||||
|
|
||||||
|
void math_error(char *fmt, ...);
|
||||||
|
|
||||||
|
Your math_error() function may exit or transfer control to outside
|
||||||
|
of the calc library, but it must never return or calc will crash.
|
||||||
|
|
||||||
|
External programs can obtain the appropriate calc symbols by compiling with:
|
||||||
|
|
||||||
|
-I${INCDIR} -L${LIBDIR} -lcalc
|
||||||
|
|
||||||
|
-------------------------
|
||||||
|
PARSE/SCAN ERROR HANDLING
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
The scanerror() function is called when calc encounters a parse/scan
|
||||||
|
error. For example, scanerror() is called when calc is given code
|
||||||
|
with a syntax error.
|
||||||
|
|
||||||
|
The variable, calc_print_scanerr_msg, controls if calc prints to stderr,
|
||||||
|
any parse/scan errors. By default, this variable it set to 1 and so
|
||||||
|
parse/scan errors are printed to stderr. By setting this value to zero,
|
||||||
|
parse/scan errors are not printed:
|
||||||
|
|
||||||
|
#include "lib_calc.h"
|
||||||
|
|
||||||
|
/* do not print parse/scan errors to stderr */
|
||||||
|
calc_print_scanerr_msg = 0;
|
||||||
|
|
||||||
|
The last calc math error or calc parse/scan error message is kept
|
||||||
|
in the NUL terminated buffer:
|
||||||
|
|
||||||
|
char calc_err_msg[MAXERROR+1];
|
||||||
|
|
||||||
|
The value of calc_print_scanerr_msg does not change the use
|
||||||
|
of the calc_err_msg[] buffer. Messages are stored in that
|
||||||
|
buffer regardless of the calc_print_scanerr_msg value.
|
||||||
|
|
||||||
|
The calc_print_scanerr_msg and the calc_err_msg[] buffer are declared
|
||||||
|
lib_calc.h include file. The initialized storage for these variables
|
||||||
|
comes from the calc library. The MAXERROR symbol is also declared in
|
||||||
|
the lib_calc.h include file.
|
||||||
|
|
||||||
|
Your program must handle parse/scan errors in one of two ways:
|
||||||
|
|
||||||
|
1) exit on error
|
||||||
|
|
||||||
|
If you do not setup the calc_scanerr_jmpbuf, then when calc
|
||||||
|
encounters a parse/scan error, a message will be printed to
|
||||||
|
stderr and calc will exit.
|
||||||
|
|
||||||
|
2) Use setjmp and longjmp in your program
|
||||||
|
|
||||||
|
Use setjmp at some appropriate level in your program, and let
|
||||||
|
the longjmp in scanerror() return to that level and to allow you
|
||||||
|
to recover from the error. This is what the calc program does.
|
||||||
|
|
||||||
|
If one sets up calc_scanerr_jmpbuf, and then sets
|
||||||
|
calc_use_scanerr_jmpbuf to non-zero then scanerror() will longjmp
|
||||||
|
back with the return with a non-zero code. In addition, the last
|
||||||
|
calc error message will be found in calc_err_msg[]; this error is
|
||||||
|
not printed to stderr. The calc error message will not have a
|
||||||
|
trailing newline.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include "lib_calc.h"
|
||||||
|
|
||||||
|
int scan_error;
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
/* delay the printing of the parse/scan error */
|
||||||
|
calc_use_scanerr_jmpbuf = 0; /* this is optional */
|
||||||
|
|
||||||
|
if ((scan_error = setjmp(calc_scanerr_jmpbuf)) != 0) {
|
||||||
|
|
||||||
|
/* report the parse/scan */
|
||||||
|
if (calc_use_scanerr_jmpbuf == 0) {
|
||||||
|
printf("parse error: %s\n", calc_err_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize calc after the longjmp */
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
calc_use_scanerr_jmpbuf = 1;
|
||||||
|
|
||||||
|
If calc_use_scanerr_jmpbuf is non-zero, then the jmp_buf value
|
||||||
|
calc_scanerr_jmpbuf must be initialized by the setjmp() function
|
||||||
|
or your program will crash.
|
||||||
|
|
||||||
|
External programs can obtain the appropriate calc symbols by compiling with:
|
||||||
|
|
||||||
|
-I${INCDIR} -L${LIBDIR} -lcalc
|
||||||
|
|
||||||
|
---------------------------
|
||||||
|
PARSE/SCAN WARNING HANDLING
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Calc parse/scan warning message are printed to stderr by the warning()
|
||||||
|
function. The routine is called in the manner of printf, with a format
|
||||||
|
string and optional arguments:
|
||||||
|
|
||||||
|
void warning(char *fmt, ...);
|
||||||
|
|
||||||
|
The variable, calc_print_scanwarn_msg, controls if calc prints to stderr,
|
||||||
|
any parse/scan warnings. By default, this variable it set to 1 and so
|
||||||
|
parse/scan warnings are printed to stderr. By setting this value to zero,
|
||||||
|
parse/scan warnings are not printed:
|
||||||
|
|
||||||
|
#include "lib_calc.h"
|
||||||
|
|
||||||
|
/* do not print parse/scan warnings to stderr */
|
||||||
|
calc_print_scanwarn_msg = 0;
|
||||||
|
|
||||||
|
The last calc calc parse/scan warning message is kept in the NUL
|
||||||
|
terminated buffer:
|
||||||
|
|
||||||
|
char calc_warn_msg[MAXERROR+1];
|
||||||
|
|
||||||
|
The value of calc_print_scanwarn_msg does not change the use
|
||||||
|
of the calc_warn_msg[] buffer. Messages are stored in that
|
||||||
|
buffer regardless of the calc_print_scanwarn_msg value.
|
||||||
|
|
||||||
|
Your program must handle parse/scan warnings in one of two ways:
|
||||||
|
|
||||||
|
1) print the warning to stderr and continue
|
||||||
|
|
||||||
|
The warning() from libcalc prints warning messages to
|
||||||
|
stderr and returns. The flow of execution is not changed.
|
||||||
|
This is what calc does by default.
|
||||||
|
|
||||||
|
2) Supply your own warning function:
|
||||||
|
|
||||||
|
void warning(char *fmt, ...);
|
||||||
|
|
||||||
|
Your warning function should simply return when it is finished.
|
||||||
|
|
||||||
|
External programs can obtain the appropriate calc symbols by compiling with:
|
||||||
|
|
||||||
|
-I${INCDIR} -L${LIBDIR} -lcalc
|
||||||
|
|
||||||
/* report the error */
|
|
||||||
printf("Ouch: %s\n", calc_error);
|
|
||||||
}
|
|
||||||
calc_jmp = 1;
|
|
||||||
|
|
||||||
---------------
|
---------------
|
||||||
OUTPUT ROUTINES
|
OUTPUT ROUTINES
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
The output from the routines in the link library normally goes to stdout. You
|
The output from the routines in the link library normally goes to stdout.
|
||||||
can divert that output to either another FILE handle, or else to a string.
|
You can divert that output to either another FILE handle, or else
|
||||||
Read the routines in zio.c to see what is available. Diversions can be
|
to a string. Read the routines in zio.c to see what is available.
|
||||||
nested.
|
Diversions can be nested.
|
||||||
|
|
||||||
You use math_setfp to divert output to another FILE handle. Calling
|
You use math_setfp to divert output to another FILE handle. Calling
|
||||||
math_setfp with stdout restores output to stdout.
|
math_setfp with stdout restores output to stdout.
|
||||||
@@ -487,10 +636,10 @@ need call libcalc_call_me_last() only once.
|
|||||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
## 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
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.5 $
|
## @(#) $Revision: 30.1 $
|
||||||
## @(#) $Id: LIBRARY,v 29.5 2001/06/08 22:57:35 chongo Exp $
|
## @(#) $Id: LIBRARY,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/LIBRARY,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/RCS/LIBRARY,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1993/07/30 19:44:49
|
## Under source code control: 1993/07/30 19:44:49
|
||||||
|
5593
Makefile.simple
Normal file
5593
Makefile.simple
Normal file
File diff suppressed because it is too large
Load Diff
6
README
6
README
@@ -132,10 +132,10 @@ The calc web site is located at:
|
|||||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
## 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
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.3 $
|
## @(#) $Revision: 30.1 $
|
||||||
## @(#) $Id: README,v 29.3 2001/06/01 11:26:53 chongo Exp $
|
## @(#) $Id: README,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/README,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/RCS/README,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1995/10/25 05:27:59
|
## Under source code control: 1995/10/25 05:27:59
|
||||||
|
@@ -56,7 +56,7 @@ recommends the following settings:
|
|||||||
CALCPATH= .;./cal;~/.cal;${CALC_SHAREDIR};${CUSTOMCALDIR}
|
CALCPATH= .;./cal;~/.cal;${CALC_SHAREDIR};${CUSTOMCALDIR}
|
||||||
CALCRC= ${CALC_SHAREDIR}/startup;~/.calcrc;./.calcinit
|
CALCRC= ${CALC_SHAREDIR}/startup;~/.calcrc;./.calcinit
|
||||||
CALCPAGER= less.exe -ci
|
CALCPAGER= less.exe -ci
|
||||||
DEBUG= -O2 -gstabs+
|
DEBUG= -O2 -gstabs+ -DWINDOZ
|
||||||
|
|
||||||
The 'Linux set' or 'gcc set' (see the Select your compiler type section)
|
The 'Linux set' or 'gcc set' (see the Select your compiler type section)
|
||||||
should work for DJGPP systems if you set the above Makefile variables.
|
should work for DJGPP systems if you set the above Makefile variables.
|
||||||
@@ -112,37 +112,8 @@ In particular:
|
|||||||
source directory, edit them (if needed) and build using the
|
source directory, edit them (if needed) and build using the
|
||||||
Cygwin GCC compiler and Cygwin build environment.
|
Cygwin GCC compiler and Cygwin build environment.
|
||||||
|
|
||||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
||||||
=-=-= calc maintenance folk =-=-=
|
|
||||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
||||||
|
|
||||||
People who maintain calc need to keep in mind the following:
|
## Copyright (C) 2002-2007 Landon Curt Noll and Thomas Jones-Low
|
||||||
|
|
||||||
The following was added to opcodes.h, config.h, zmath.h and value.h:
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#ifdef _EXPORTING
|
|
||||||
#define DLL __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define DLL __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else /* Windoz free systems */
|
|
||||||
|
|
||||||
#define DLL
|
|
||||||
|
|
||||||
#endif /* Windoz free systems */
|
|
||||||
|
|
||||||
Then DLL was added in front of all the exported functions. For example:
|
|
||||||
|
|
||||||
extern int configtype(char*);
|
|
||||||
|
|
||||||
was changed to:
|
|
||||||
|
|
||||||
DLL extern int configtype(char*);
|
|
||||||
|
|
||||||
|
|
||||||
## Copyright (C) 2002 Landon Curt Noll and Thomas Jones-Low
|
|
||||||
##
|
##
|
||||||
## Calc is open software; you can redistribute it and/or modify it under
|
## 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
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -156,10 +127,10 @@ was changed to:
|
|||||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
## 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
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.12 $
|
## @(#) $Revision: 30.1 $
|
||||||
## @(#) $Id: README.WINDOWS,v 29.12 2004/07/28 12:52:01 chongo Exp $
|
## @(#) $Id: README.WINDOWS,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/README.WINDOWS,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/RCS/README.WINDOWS,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 2001/02/25 14:00:05
|
## Under source code control: 2001/02/25 14:00:05
|
||||||
|
47
addop.c
47
addop.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* addop - add opcodes to a function being compiled
|
* addop - add opcodes to a function being compiled
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2006 David I. Bell and Ernest Bowen
|
* Copyright (C) 1999-2007 David I. Bell and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: David I. Bell
|
* Primary author: David I. Bell
|
||||||
*
|
*
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.9 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: addop.c,v 29.9 2006/05/22 19:04:45 chongo Exp $
|
* @(#) $Id: addop.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/addop.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/addop.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:48:10
|
* Under source code control: 1990/02/15 01:48:10
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "calc.h"
|
#include "calc.h"
|
||||||
#include "opcodes.h"
|
#include "opcodes.h"
|
||||||
#include "string.h"
|
#include "str.h"
|
||||||
#include "func.h"
|
#include "func.h"
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
@@ -44,17 +44,17 @@
|
|||||||
#define OPCODEALLOCSIZE 100 /* reallocate size for opcodes in functions */
|
#define OPCODEALLOCSIZE 100 /* reallocate size for opcodes in functions */
|
||||||
|
|
||||||
|
|
||||||
static unsigned long maxopcodes;/* number of opcodes available */
|
STATIC unsigned long maxopcodes;/* number of opcodes available */
|
||||||
static long newindex; /* index of new function */
|
STATIC long newindex; /* index of new function */
|
||||||
static char *newname; /* name of new function */
|
STATIC char *newname; /* name of new function */
|
||||||
static long oldop; /* previous opcode */
|
STATIC long oldop; /* previous opcode */
|
||||||
static long oldoldop; /* opcode before previous opcode */
|
STATIC long oldoldop; /* opcode before previous opcode */
|
||||||
static long debugline; /* line number of latest debug opcode */
|
STATIC long debugline; /* line number of latest debug opcode */
|
||||||
static long funccount; /* number of functions */
|
STATIC long funccount; /* number of functions */
|
||||||
static long funcavail; /* available number of functions */
|
STATIC long funcavail; /* available number of functions */
|
||||||
static FUNC *functemplate; /* function definition template */
|
STATIC FUNC *functemplate; /* function definition template */
|
||||||
static FUNC **functions; /* table of functions */
|
STATIC FUNC **functions; /* table of functions */
|
||||||
static STRINGHEAD funcnames; /* function names */
|
STATIC STRINGHEAD funcnames; /* function names */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -195,8 +195,8 @@ endfunc(void)
|
|||||||
checklabels();
|
checklabels();
|
||||||
|
|
||||||
if (errorcount) {
|
if (errorcount) {
|
||||||
printf("\"%s\": %ld error%s\n", newname, errorcount,
|
scanerror(T_NULL,"Compilation of \"%s\" failed: %ld error(s)",
|
||||||
((errorcount == 1) ? "" : "s"));
|
newname, errorcount);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size = funcsize(curfunc->f_opcodecount);
|
size = funcsize(curfunc->f_opcodecount);
|
||||||
@@ -280,12 +280,13 @@ rmuserfunc(char *name)
|
|||||||
|
|
||||||
index = findstr(&funcnames, name);
|
index = findstr(&funcnames, name);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
fprintf(stderr, "%s() has never been defined\n",
|
warning("No function named \"%s\" to be undefined", name);
|
||||||
name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (functions[index] == NULL)
|
if (functions[index] == NULL) {
|
||||||
|
warning("No defined function \"%s\" to be undefined", name);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
freenumbers(functions[index]);
|
freenumbers(functions[index]);
|
||||||
free(functions[index]);
|
free(functions[index]);
|
||||||
if ((inputisterminal() && conf->resource_debug & RSCDBG_STDIN_FUNC) ||
|
if ((inputisterminal() && conf->resource_debug & RSCDBG_STDIN_FUNC) ||
|
||||||
@@ -526,9 +527,7 @@ addop(long op)
|
|||||||
fp->f_opcodecount -= diff;
|
fp->f_opcodecount -= diff;
|
||||||
oldop = OP_NOP;
|
oldop = OP_NOP;
|
||||||
oldoldop = OP_NOP;
|
oldoldop = OP_NOP;
|
||||||
fprintf(stderr,
|
warning("Constant before comma operator");
|
||||||
"Line %ld: unused value ignored\n",
|
|
||||||
linenumber());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: align32.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
* @(#) $Id: align32.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/align32.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/align32.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/11/23 05:18:06
|
* Under source code control: 1995/11/23 05:18:06
|
||||||
|
59
alloc.h
59
alloc.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* alloc - storage allocation and storage debug macros
|
* alloc - storage allocation and storage debug macros
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 David I. Bell
|
* Copyright (C) 1999-2007 David I. Bell
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.4 $
|
* @(#) $Revision: 30.2 $
|
||||||
* @(#) $Id: alloc.h,v 29.4 2001/06/08 21:00:58 chongo Exp $
|
* @(#) $Id: alloc.h,v 30.2 2008/04/15 21:17:57 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/alloc.h,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/alloc.h,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:48:29
|
* Under source code control: 1990/02/15 01:48:29
|
||||||
@@ -33,54 +33,41 @@
|
|||||||
|
|
||||||
|
|
||||||
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
||||||
# include "have_malloc.h"
|
|
||||||
# include "have_newstr.h"
|
# include "have_newstr.h"
|
||||||
# include "have_string.h"
|
# include "have_string.h"
|
||||||
# include "have_memmv.h"
|
# include "have_memmv.h"
|
||||||
#else
|
#else
|
||||||
# include <calc/have_malloc.h>
|
|
||||||
# include <calc/have_newstr.h>
|
# include <calc/have_newstr.h>
|
||||||
# include <calc/have_string.h>
|
# include <calc/have_string.h>
|
||||||
# include <calc/have_memmv.h>
|
# include <calc/have_memmv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_MALLOC_H
|
|
||||||
# include <malloc.h>
|
|
||||||
#else
|
|
||||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
|
||||||
extern void *malloc();
|
|
||||||
extern void *realloc();
|
|
||||||
extern void free();
|
|
||||||
# else
|
|
||||||
extern char *malloc();
|
|
||||||
extern char *realloc();
|
|
||||||
extern void free();
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#if defined(_WIN32) && defined(NOTCYGWIN)
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
# if defined(HAVE_NEWSTR)
|
# if defined(HAVE_NEWSTR)
|
||||||
extern void *memcpy();
|
E_FUNC void *memcpy();
|
||||||
extern void *memset();
|
E_FUNC void *memset();
|
||||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||||
extern size_t strlen();
|
E_FUNC size_t strlen();
|
||||||
# else
|
# else
|
||||||
extern long strlen();
|
E_FUNC long strlen();
|
||||||
# endif
|
# endif
|
||||||
# else /* HAVE_NEWSTR */
|
# else /* HAVE_NEWSTR */
|
||||||
extern void bcopy();
|
E_FUNC void bcopy();
|
||||||
extern void bfill();
|
E_FUNC void bfill();
|
||||||
extern char *index();
|
E_FUNC char *index();
|
||||||
# endif /* HAVE_NEWSTR */
|
# endif /* HAVE_NEWSTR */
|
||||||
extern char *strchr();
|
E_FUNC char *strchr();
|
||||||
extern char *strcpy();
|
E_FUNC char *strcpy();
|
||||||
extern char *strncpy();
|
E_FUNC char *strncpy();
|
||||||
extern char *strcat();
|
E_FUNC char *strcat();
|
||||||
extern int strcmp();
|
E_FUNC int strcmp();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -94,13 +81,13 @@ extern int strcmp();
|
|||||||
#endif /* HAVE_NEWSTR */
|
#endif /* HAVE_NEWSTR */
|
||||||
|
|
||||||
#if !defined(HAVE_MEMMOVE)
|
#if !defined(HAVE_MEMMOVE)
|
||||||
# undef CALC_SIZE_T
|
# undef MEMMOVE_SIZE_T
|
||||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||||
# define CALC_SIZE_T size_t
|
# define MEMMOVE_SIZE_T size_t
|
||||||
# else
|
# else
|
||||||
# define CALC_SIZE_T long
|
# define MEMMOVE_SIZE_T long
|
||||||
# endif
|
# endif
|
||||||
extern void *memmove(void *s1, const void *s2, CALC_SIZE_T n);
|
E_FUNC void *memmove(void *s1, CONST void *s2, MEMMOVE_SIZE_T n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !__ALLOC_H__ */
|
#endif /* !__ALLOC_H__ */
|
||||||
|
26
assocfunc.c
26
assocfunc.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* assocfunc - association table routines
|
* assocfunc - association table routines
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 David I. Bell
|
* Copyright (C) 1999-2007 David I. Bell
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: assocfunc.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
* @(#) $Id: assocfunc.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/assocfunc.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/assocfunc.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1993/07/20 23:04:27
|
* Under source code control: 1993/07/20 23:04:27
|
||||||
@@ -46,10 +46,10 @@
|
|||||||
#define ELEMSIZE(n) (sizeof(ASSOCELEM) + (sizeof(VALUE) * ((n) - 1)))
|
#define ELEMSIZE(n) (sizeof(ASSOCELEM) + (sizeof(VALUE) * ((n) - 1)))
|
||||||
|
|
||||||
|
|
||||||
static ASSOCELEM *elemindex(ASSOC *ap, long index);
|
S_FUNC ASSOCELEM *elemindex(ASSOC *ap, long index);
|
||||||
static BOOL compareindices(VALUE *v1, VALUE *v2, long dim);
|
S_FUNC BOOL compareindices(VALUE *v1, VALUE *v2, long dim);
|
||||||
static void resize(ASSOC *ap, long newsize);
|
S_FUNC void resize(ASSOC *ap, long newsize);
|
||||||
static void assoc_elemfree(ASSOCELEM *ep);
|
S_FUNC void assoc_elemfree(ASSOCELEM *ep);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -69,7 +69,7 @@ associndex(ASSOC *ap, BOOL create, long dim, VALUE *indices)
|
|||||||
{
|
{
|
||||||
ASSOCELEM **listhead;
|
ASSOCELEM **listhead;
|
||||||
ASSOCELEM *ep;
|
ASSOCELEM *ep;
|
||||||
static VALUE val;
|
STATIC VALUE val;
|
||||||
QCKHASH hash;
|
QCKHASH hash;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ assocrsearch(ASSOC *ap, VALUE *vp, long i, long j, ZVALUE *index)
|
|||||||
* ap association to index into
|
* ap association to index into
|
||||||
* index index of desired element
|
* index index of desired element
|
||||||
*/
|
*/
|
||||||
static ASSOCELEM *
|
S_FUNC ASSOCELEM *
|
||||||
elemindex(ASSOC *ap, long index)
|
elemindex(ASSOC *ap, long index)
|
||||||
{
|
{
|
||||||
ASSOCELEM *ep;
|
ASSOCELEM *ep;
|
||||||
@@ -356,7 +356,7 @@ assoccopy(ASSOC *oldap)
|
|||||||
* This is only actually done if the growth from the previous size is
|
* This is only actually done if the growth from the previous size is
|
||||||
* enough to make this worthwhile.
|
* enough to make this worthwhile.
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
resize(ASSOC *ap, long newsize)
|
resize(ASSOC *ap, long newsize)
|
||||||
{
|
{
|
||||||
ASSOCELEM **oldtable;
|
ASSOCELEM **oldtable;
|
||||||
@@ -400,7 +400,7 @@ resize(ASSOC *ap, long newsize)
|
|||||||
/*
|
/*
|
||||||
* Free an association element, along with any contained values.
|
* Free an association element, along with any contained values.
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
assoc_elemfree(ASSOCELEM *ep)
|
assoc_elemfree(ASSOCELEM *ep)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -520,7 +520,7 @@ assocprint(ASSOC *ap, long max_print)
|
|||||||
* Compare two lists of index values to see if they are identical.
|
* Compare two lists of index values to see if they are identical.
|
||||||
* Returns TRUE if they are the same.
|
* Returns TRUE if they are the same.
|
||||||
*/
|
*/
|
||||||
static BOOL
|
S_FUNC BOOL
|
||||||
compareindices(VALUE *v1, VALUE *v2, long dim)
|
compareindices(VALUE *v1, VALUE *v2, long dim)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
12
blkcpy.c
12
blkcpy.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* blkcpy - general values and related routines used by the calculator
|
* blkcpy - general values and related routines used by the calculator
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2006 Landon Curt Noll and Ernest Bowen
|
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: Landon Curt Noll
|
* Primary author: Landon Curt Noll
|
||||||
*
|
*
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.9 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: blkcpy.c,v 29.9 2006/05/20 08:43:55 chongo Exp $
|
* @(#) $Id: blkcpy.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1997/04/18 20:41:26
|
* Under source code control: 1997/04/18 20:41:26
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "value.h"
|
#include "value.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "blkcpy.h"
|
#include "blkcpy.h"
|
||||||
#include "string.h"
|
#include "str.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -935,7 +935,7 @@ copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,BOOL noreloc)
|
|||||||
* s1
|
* s1
|
||||||
*/
|
*/
|
||||||
void *
|
void *
|
||||||
memmove(void *s1, const void *s2, CALC_SIZE_T n)
|
memmove(void *s1, CONST void *s2, MEMMOVE_SIZE_T n)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* firewall
|
* firewall
|
||||||
|
44
blkcpy.h
44
blkcpy.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* blkcpy - general values and related routines used by the calculator
|
* blkcpy - general values and related routines used by the calculator
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Landon Curt Noll and Ernest Bowen
|
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: Landon Curt Noll
|
* Primary author: Landon Curt Noll
|
||||||
*
|
*
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: blkcpy.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
* @(#) $Id: blkcpy.h,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.h,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.h,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1997/04/18 20:41:25
|
* Under source code control: 1997/04/18 20:41:25
|
||||||
@@ -36,27 +36,27 @@
|
|||||||
/*
|
/*
|
||||||
* the main copy gateway function
|
* the main copy gateway function
|
||||||
*/
|
*/
|
||||||
extern int copystod(VALUE *, long, long, VALUE *, long);
|
E_FUNC int copystod(VALUE *, long, long, VALUE *, long);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* specific copy functions
|
* specific copy functions
|
||||||
*/
|
*/
|
||||||
extern int copyblk2blk(BLOCK *, long, long, BLOCK *, long, BOOL);
|
E_FUNC int copyblk2blk(BLOCK *, long, long, BLOCK *, long, BOOL);
|
||||||
extern int copyblk2file(BLOCK *, long, long, FILEID, long);
|
E_FUNC int copyblk2file(BLOCK *, long, long, FILEID, long);
|
||||||
extern int copyblk2mat(BLOCK *, long, long, MATRIX *, long);
|
E_FUNC int copyblk2mat(BLOCK *, long, long, MATRIX *, long);
|
||||||
extern int copyblk2num(BLOCK *, long, long, NUMBER *, long, NUMBER **);
|
E_FUNC int copyblk2num(BLOCK *, long, long, NUMBER *, long, NUMBER **);
|
||||||
extern int copyblk2str(BLOCK *, long, long, STRING *, long);
|
E_FUNC int copyblk2str(BLOCK *, long, long, STRING *, long);
|
||||||
extern int copyfile2blk(FILEID, long, long, BLOCK *, long, BOOL);
|
E_FUNC int copyfile2blk(FILEID, long, long, BLOCK *, long, BOOL);
|
||||||
extern int copylist2list(LIST *, long, long, LIST *, long);
|
E_FUNC int copylist2list(LIST *, long, long, LIST *, long);
|
||||||
extern int copylist2mat(LIST *, long, long, MATRIX *, long);
|
E_FUNC int copylist2mat(LIST *, long, long, MATRIX *, long);
|
||||||
extern int copymat2blk(MATRIX *, long, long, BLOCK *, long, BOOL);
|
E_FUNC int copymat2blk(MATRIX *, long, long, BLOCK *, long, BOOL);
|
||||||
extern int copymat2list(MATRIX *, long, long, LIST *, long);
|
E_FUNC int copymat2list(MATRIX *, long, long, LIST *, long);
|
||||||
extern int copymat2mat(MATRIX *, long, long, MATRIX *, long);
|
E_FUNC int copymat2mat(MATRIX *, long, long, MATRIX *, long);
|
||||||
extern int copynum2blk(NUMBER *, long, long, BLOCK *, long, BOOL);
|
E_FUNC int copynum2blk(NUMBER *, long, long, BLOCK *, long, BOOL);
|
||||||
extern int copyostr2blk(char *, long, long, BLOCK *, long, BOOL);
|
E_FUNC int copyostr2blk(char *, long, long, BLOCK *, long, BOOL);
|
||||||
extern int copyostr2str(char *, long, long, STRING *, long);
|
E_FUNC int copyostr2str(char *, long, long, STRING *, long);
|
||||||
extern int copystr2blk(STRING *, long, long, BLOCK *, long, BOOL);
|
E_FUNC int copystr2blk(STRING *, long, long, BLOCK *, long, BOOL);
|
||||||
extern int copystr2file(STRING *, long, long, FILEID, long);
|
E_FUNC int copystr2file(STRING *, long, long, FILEID, long);
|
||||||
extern int copystr2str(STRING *, long, long, STRING *, long);
|
E_FUNC int copystr2str(STRING *, long, long, STRING *, long);
|
||||||
|
|
||||||
#endif /* !__BLKCPY_H__ */
|
#endif /* !__BLKCPY_H__ */
|
||||||
|
22
block.c
22
block.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* block - fixed, dynamic, fifo and circular memory blocks
|
* block - fixed, dynamic, fifo and circular memory blocks
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Landon Curt Noll and Ernest Bowen
|
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: Landon Curt Noll
|
* Primary author: Landon Curt Noll
|
||||||
*
|
*
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.3 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: block.c,v 29.3 2006/05/01 19:16:57 chongo Exp $
|
* @(#) $Id: block.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/block.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/block.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1997/02/27 00:29:40
|
* Under source code control: 1997/02/27 00:29:40
|
||||||
@@ -37,19 +37,19 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
#include "nametype.h"
|
#include "nametype.h"
|
||||||
#include "string.h"
|
#include "str.h"
|
||||||
#include "calcerr.h"
|
#include "calcerr.h"
|
||||||
|
|
||||||
#define NBLOCKCHUNK 16
|
#define NBLOCKCHUNK 16
|
||||||
|
|
||||||
static long nblockcount = 0;
|
STATIC long nblockcount = 0;
|
||||||
static long maxnblockcount = 0;
|
STATIC long maxnblockcount = 0;
|
||||||
static STRINGHEAD nblocknames;
|
STATIC STRINGHEAD nblocknames;
|
||||||
static NBLOCK **nblocks;
|
STATIC NBLOCK **nblocks;
|
||||||
|
|
||||||
|
|
||||||
/* forward declarations */
|
/* forward declarations */
|
||||||
static void blkchk(BLOCK*);
|
S_FUNC void blkchk(BLOCK*);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -154,7 +154,7 @@ blk_free(BLOCK *blk)
|
|||||||
* if all is ok, otherwise math_error() is called and this
|
* if all is ok, otherwise math_error() is called and this
|
||||||
* function does not return
|
* function does not return
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
blkchk(BLOCK *blk)
|
blkchk(BLOCK *blk)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
42
block.h
42
block.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* block - fixed, dynamic, fifo and circular memory blocks
|
* block - fixed, dynamic, fifo and circular memory blocks
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Landon Curt Noll and Ernest Bowen
|
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: Landon Curt Noll
|
* Primary author: Landon Curt Noll
|
||||||
*
|
*
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: block.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
* @(#) $Id: block.h,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/block.h,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/block.h,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1997/02/21 05:03:39
|
* Under source code control: 1997/02/21 05:03:39
|
||||||
@@ -160,7 +160,7 @@ typedef struct nblock NBLOCK;
|
|||||||
/*
|
/*
|
||||||
* block debug
|
* block debug
|
||||||
*/
|
*/
|
||||||
extern int blk_debug; /* 0 => debug off */
|
EXTERN int blk_debug; /* 0 => debug off */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -204,22 +204,22 @@ typedef USB8 OCTET;
|
|||||||
/*
|
/*
|
||||||
* external functions
|
* external functions
|
||||||
*/
|
*/
|
||||||
extern BLOCK *blkalloc(int, int);
|
E_FUNC BLOCK *blkalloc(int, int);
|
||||||
extern void blk_free(BLOCK*);
|
E_FUNC void blk_free(BLOCK*);
|
||||||
extern BLOCK *blkrealloc(BLOCK*, int, int);
|
E_FUNC BLOCK *blkrealloc(BLOCK*, int, int);
|
||||||
extern void blktrunc(BLOCK*);
|
E_FUNC void blktrunc(BLOCK*);
|
||||||
extern BLOCK *blk_copy(BLOCK*);
|
E_FUNC BLOCK *blk_copy(BLOCK*);
|
||||||
extern int blk_cmp(BLOCK*, BLOCK*);
|
E_FUNC int blk_cmp(BLOCK*, BLOCK*);
|
||||||
extern void blk_print(BLOCK*);
|
E_FUNC void blk_print(BLOCK*);
|
||||||
extern void nblock_print(NBLOCK *);
|
E_FUNC void nblock_print(NBLOCK *);
|
||||||
extern NBLOCK *createnblock(char *, int, int);
|
E_FUNC NBLOCK *createnblock(char *, int, int);
|
||||||
extern NBLOCK *reallocnblock(int, int, int);
|
E_FUNC NBLOCK *reallocnblock(int, int, int);
|
||||||
extern int removenblock(int);
|
E_FUNC int removenblock(int);
|
||||||
extern int findnblockid(char *);
|
E_FUNC int findnblockid(char *);
|
||||||
extern NBLOCK *findnblock(int);
|
E_FUNC NBLOCK *findnblock(int);
|
||||||
extern BLOCK *copyrealloc(BLOCK*, int, int);
|
E_FUNC BLOCK *copyrealloc(BLOCK*, int, int);
|
||||||
extern int countnblocks(void);
|
E_FUNC int countnblocks(void);
|
||||||
extern void shownblocks(void);
|
E_FUNC void shownblocks(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__BLOCK_H__ */
|
#endif /* !__BLOCK_H__ */
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: byteswap.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
* @(#) $Id: byteswap.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/byteswap.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/byteswap.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/10/11 04:44:01
|
* Under source code control: 1995/10/11 04:44:01
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.4 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: byteswap.h,v 29.4 2001/06/08 21:00:58 chongo Exp $
|
* @(#) $Id: byteswap.h,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/byteswap.h,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/byteswap.h,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/10/11 04:44:01
|
* Under source code control: 1995/10/11 04:44:01
|
||||||
|
151
cal/Makefile
151
cal/Makefile
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# cal - makefile for calc standard resource files
|
# cal - makefile for calc standard resource files
|
||||||
#
|
#
|
||||||
# Copyright (C) 1999 Landon Curt Noll
|
# Copyright (C) 1999-2006 Landon Curt Noll
|
||||||
#
|
#
|
||||||
# Calc is open software; you can redistribute it and/or modify it under
|
# 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
|
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
# 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
|
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.18 $
|
# @(#) $Revision: 30.3 $
|
||||||
# @(#) $Id: Makefile,v 29.18 2006/05/20 19:32:40 chongo Exp $
|
# @(#) $Id: Makefile,v 30.3 2007/09/21 01:27:27 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1991/07/21 05:00:54
|
# Under source code control: 1991/07/21 05:00:54
|
||||||
@@ -33,14 +33,31 @@
|
|||||||
|
|
||||||
# required vars
|
# required vars
|
||||||
#
|
#
|
||||||
SHELL = /bin/sh
|
SHELL= /bin/sh
|
||||||
MAKE_FILE = Makefile
|
|
||||||
|
|
||||||
####
|
####
|
||||||
# Normally, the upper level makefile will set these values. We provide
|
# Normally, the upper level makefile will set these values. We provide
|
||||||
# a default here just in case you want to build from this directory.
|
# a default here just in case you want to build from this directory.
|
||||||
####
|
####
|
||||||
|
|
||||||
|
# Normally certain files depend on the Makefile. If the Makefile is
|
||||||
|
# changed, then certain steps should be redone. If MAKE_FILE is
|
||||||
|
# set to Makefile, then these files will depend on Makefile. If
|
||||||
|
# MAKE_FILE is empty, then they wont.
|
||||||
|
#
|
||||||
|
# If in doubt, set MAKE_FILE to Makefile
|
||||||
|
#
|
||||||
|
MAKE_FILE= Makefile
|
||||||
|
|
||||||
|
# Controlling file makefile basename (without the path)
|
||||||
|
#
|
||||||
|
# This is the basename same of the makefile that may/does/will drive
|
||||||
|
# this makefile.
|
||||||
|
#
|
||||||
|
# If in doubt, set TOP_MAKE_FILE to Makefile
|
||||||
|
#
|
||||||
|
TOP_MAKE_FILE= Makefile
|
||||||
|
|
||||||
# Where the system include (.h) files are kept
|
# Where the system include (.h) files are kept
|
||||||
#
|
#
|
||||||
# For DJGPP, select:
|
# For DJGPP, select:
|
||||||
@@ -62,9 +79,9 @@ INCDIR= /usr/include
|
|||||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||||
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
||||||
#
|
#
|
||||||
# NOTE: The install rule prepends installation paths with $T, which
|
# NOTE: The install rule prepends installation paths with ${T}, which
|
||||||
# by default is empty. If $T is non-empty, then installation
|
# by default is empty. If ${T} is non-empty, then installation
|
||||||
# locations will be relative to the $T directory.
|
# locations will be relative to the ${T} directory.
|
||||||
#
|
#
|
||||||
# For DJGPP, select:
|
# For DJGPP, select:
|
||||||
#
|
#
|
||||||
@@ -94,35 +111,26 @@ CALC_SHAREDIR= /usr/share/calc
|
|||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# ${HELPDIR} where the help directory is installed
|
# ${HELPDIR} where the help directory is installed
|
||||||
# ${CALC_INCDIR} where the calc include files are installed
|
# ${CALC_INCDIR} where the calc include files are installed
|
||||||
# ${CUSTOMCALDIR} where custom *.cal files are installed
|
|
||||||
# ${CUSTOMHELPDIR} where custom help files are installed
|
|
||||||
# ${CUSTOMINCPDIR} where custom .h files are installed
|
|
||||||
# ${SCRIPTDIR} where calc shell scripts are installed
|
# ${SCRIPTDIR} where calc shell scripts are installed
|
||||||
#
|
#
|
||||||
# NOTE: The install rule prepends installation paths with $T, which
|
# NOTE: The install rule prepends installation paths with ${T}, which
|
||||||
# by default is empty. If $T is non-empty, then installation
|
# by default is empty. If ${T} is non-empty, then installation
|
||||||
# locations will be relative to the $T directory.
|
# locations will be relative to the ${T} directory.
|
||||||
#
|
#
|
||||||
# If in doubt, set:
|
# If in doubt, set:
|
||||||
#
|
#
|
||||||
# HELPDIR= ${CALC_SHAREDIR}/help
|
# HELPDIR= ${CALC_SHAREDIR}/help
|
||||||
# CALC_INCDIR= ${INCDIR}/calc
|
# CALC_INCDIR= ${INCDIR}/calc
|
||||||
# CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
|
||||||
# CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
|
||||||
# CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
|
||||||
# SCRIPTDIR= ${BINDIR}/cscript
|
# SCRIPTDIR= ${BINDIR}/cscript
|
||||||
#
|
#
|
||||||
HELPDIR= ${CALC_SHAREDIR}/help
|
HELPDIR= ${CALC_SHAREDIR}/help
|
||||||
CALC_INCDIR= ${INCDIR}/calc
|
CALC_INCDIR= ${INCDIR}/calc
|
||||||
CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
|
||||||
CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
|
||||||
CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
|
||||||
SCRIPTDIR= ${BINDIR}/cscript
|
SCRIPTDIR= ${BINDIR}/cscript
|
||||||
|
|
||||||
# T - top level directory under which calc will be installed
|
# T - top level directory under which calc will be installed
|
||||||
#
|
#
|
||||||
# The calc install is performed under $T, the calc build is
|
# The calc install is performed under ${T}, the calc build is
|
||||||
# performed under /. The purpose for $T is to allow someone
|
# performed under /. The purpose for ${T} is to allow someone
|
||||||
# to install calc somewhere other than into the system area.
|
# to install calc somewhere other than into the system area.
|
||||||
#
|
#
|
||||||
# For example, if:
|
# For example, if:
|
||||||
@@ -142,10 +150,10 @@ SCRIPTDIR= ${BINDIR}/cscript
|
|||||||
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||||
# ... etc ... /var/tmp/testing/...
|
# ... etc ... /var/tmp/testing/...
|
||||||
#
|
#
|
||||||
# If $T is empty, calc is installed under /, which is the same
|
# If ${T} is empty, calc is installed under /, which is the same
|
||||||
# top of tree for which it was built. If $T is non-empty, then
|
# top of tree for which it was built. If ${T} is non-empty, then
|
||||||
# calc is installed under $T, as if one had to chroot under
|
# calc is installed under ${T}, as if one had to chroot under
|
||||||
# $T for calc to operate.
|
# ${T} for calc to operate.
|
||||||
#
|
#
|
||||||
# If in doubt, use T=
|
# If in doubt, use T=
|
||||||
#
|
#
|
||||||
@@ -163,6 +171,14 @@ Q=@
|
|||||||
#
|
#
|
||||||
CHMOD= chmod
|
CHMOD= chmod
|
||||||
CMP= cmp
|
CMP= cmp
|
||||||
|
RM= rm
|
||||||
|
MKDIR= mkdir
|
||||||
|
RMDIR= rmdir
|
||||||
|
CP= cp
|
||||||
|
MV= mv
|
||||||
|
CO= co
|
||||||
|
TRUE= true
|
||||||
|
TOUCH= touch
|
||||||
|
|
||||||
# The calc files to install
|
# The calc files to install
|
||||||
#
|
#
|
||||||
@@ -177,7 +193,7 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
|
|||||||
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
|
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
|
||||||
randomrun.cal repeat.cal xx_print.cal natnumset.cal qtime.cal \
|
randomrun.cal repeat.cal xx_print.cal natnumset.cal qtime.cal \
|
||||||
test8400.cal test8500.cal test8600.cal chi.cal intfile.cal screen.cal \
|
test8400.cal test8500.cal test8600.cal chi.cal intfile.cal screen.cal \
|
||||||
dotest.cal set8700.cal set8700.line
|
dotest.cal set8700.cal set8700.line alg_config.cal sumtimes.cal
|
||||||
|
|
||||||
# These files are found (but not built) in the distribution
|
# These files are found (but not built) in the distribution
|
||||||
#
|
#
|
||||||
@@ -192,8 +208,8 @@ all: ${CALC_FILES} ${MAKE_FILE} .all
|
|||||||
# used by the upper level Makefile to determine of we have done all
|
# used by the upper level Makefile to determine of we have done all
|
||||||
#
|
#
|
||||||
.all:
|
.all:
|
||||||
rm -f .all
|
${RM} -f .all
|
||||||
touch .all
|
${TOUCH} .all
|
||||||
|
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
@@ -209,17 +225,17 @@ all: ${CALC_FILES} ${MAKE_FILE} .all
|
|||||||
##
|
##
|
||||||
|
|
||||||
distlist: ${DISTLIST}
|
distlist: ${DISTLIST}
|
||||||
${Q}for i in ${DISTLIST} /dev/null; do \
|
${Q} for i in ${DISTLIST} /dev/null; do \
|
||||||
if [ X"$$i" != X"/dev/null" ]; then \
|
if [ X"$$i" != X"/dev/null" ]; then \
|
||||||
echo cal/$$i; \
|
echo cal/$$i; \
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
|
||||||
distdir:
|
distdir:
|
||||||
${Q}echo cal
|
${Q} echo cal
|
||||||
|
|
||||||
calcliblist:
|
calcliblist:
|
||||||
${Q}for i in ${CALCLIBLIST} /dev/null; do \
|
${Q} for i in ${CALCLIBLIST} /dev/null; do \
|
||||||
if [ X"$$i" != X"/dev/null" ]; then \
|
if [ X"$$i" != X"/dev/null" ]; then \
|
||||||
echo cal/$$i; \
|
echo cal/$$i; \
|
||||||
fi; \
|
fi; \
|
||||||
@@ -232,7 +248,7 @@ calcliblist:
|
|||||||
##
|
##
|
||||||
|
|
||||||
echo_inst_files:
|
echo_inst_files:
|
||||||
${Q}for i in ${CALC_FILES} /dev/null; do \
|
${Q} for i in ${CALC_FILES} /dev/null; do \
|
||||||
if [ X"$$i" != X"/dev/null" ]; then \
|
if [ X"$$i" != X"/dev/null" ]; then \
|
||||||
echo __file__ ${CALC_SHAREDIR}/$$i; \
|
echo __file__ ${CALC_SHAREDIR}/$$i; \
|
||||||
fi; \
|
fi; \
|
||||||
@@ -246,33 +262,62 @@ echo_inst_files:
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
||||||
clobber:
|
clobber: clean
|
||||||
rm -f .all
|
${RM} -f .all
|
||||||
|
|
||||||
|
# install everything
|
||||||
|
#
|
||||||
|
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||||
|
#
|
||||||
install: all
|
install: all
|
||||||
-${Q}if [ ! -d $T${CALC_SHAREDIR} ]; then \
|
-${Q} if [ ! -d ${T}${CALC_SHAREDIR} ]; then \
|
||||||
echo mkdir $T${CALC_SHAREDIR}; \
|
echo ${MKDIR} ${T}${CALC_SHAREDIR}; \
|
||||||
mkdir $T${CALC_SHAREDIR}; \
|
${MKDIR} ${T}${CALC_SHAREDIR}; \
|
||||||
if [ ! -d "$T${CALC_SHAREDIR}" ]; then \
|
if [ ! -d "${T}${CALC_SHAREDIR}" ]; then \
|
||||||
echo mkdir -p "$T${CALC_SHAREDIR}"; \
|
echo ${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
||||||
mkdir -p "$T${CALC_SHAREDIR}"; \
|
${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
||||||
fi; \
|
fi; \
|
||||||
echo ${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
echo ${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
|
||||||
${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
|
||||||
else \
|
else \
|
||||||
true; \
|
${TRUE}; \
|
||||||
fi
|
fi
|
||||||
${Q}for i in ${CALC_FILES} /dev/null; do \
|
${Q} for i in ${CALC_FILES} /dev/null; do \
|
||||||
if [ "$$i" = "/dev/null" ]; then \
|
if [ "$$i" = "/dev/null" ]; then \
|
||||||
continue; \
|
continue; \
|
||||||
fi; \
|
fi; \
|
||||||
if ${CMP} -s $$i $T${CALC_SHAREDIR}/$$i; then \
|
if ${CMP} -s $$i ${T}${CALC_SHAREDIR}/$$i; then \
|
||||||
true; \
|
${TRUE}; \
|
||||||
else \
|
else \
|
||||||
rm -f $T${CALC_SHAREDIR}/$$i.new; \
|
${RM} -f ${T}${CALC_SHAREDIR}/$$i.new; \
|
||||||
cp -f $$i $T${CALC_SHAREDIR}/$$i.new; \
|
${CP} -f $$i ${T}${CALC_SHAREDIR}/$$i.new; \
|
||||||
${CHMOD} 0444 $T${CALC_SHAREDIR}/$$i.new; \
|
${CHMOD} 0444 ${T}${CALC_SHAREDIR}/$$i.new; \
|
||||||
mv -f $T${CALC_SHAREDIR}/$$i.new $T${CALC_SHAREDIR}/$$i; \
|
${MV} -f ${T}${CALC_SHAREDIR}/$$i.new ${T}${CALC_SHAREDIR}/$$i; \
|
||||||
echo "installed $T${CALC_SHAREDIR}/$$i"; \
|
echo "installed ${T}${CALC_SHAREDIR}/$$i"; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
|
||||||
|
# Try to remove everything that was installed
|
||||||
|
#
|
||||||
|
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||||
|
#
|
||||||
|
uninstall:
|
||||||
|
-${Q} for i in ${CALC_FILES} /dev/null; do \
|
||||||
|
if [ "$$i" = "/dev/null" ]; then \
|
||||||
|
continue; \
|
||||||
|
fi; \
|
||||||
|
if [ -f "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
||||||
|
${RM} -f "${T}${CALC_SHAREDIR}/$$i"; \
|
||||||
|
if [ -f "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
||||||
|
echo "cannot uninstall ${T}${CALC_SHAREDIR}/$$i"; \
|
||||||
|
else \
|
||||||
|
echo "uninstalled ${T}${CALC_SHAREDIR}/$$i"; \
|
||||||
|
fi; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
-${Q} for i in ${CALC_SHAREDIR}; do \
|
||||||
|
if [ -d "${T}$$i" ]; then \
|
||||||
|
${RMDIR} "${T}$$i" 2>/dev/null; \
|
||||||
|
echo "cleaned up ${T}$$i"; \
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
95
cal/README
95
cal/README
@@ -75,7 +75,7 @@ have meanings are as follows:
|
|||||||
is displayed.
|
is displayed.
|
||||||
|
|
||||||
2 Show func will display more information about a functions
|
2 Show func will display more information about a functions
|
||||||
arguments as well as more argument sdummary information.
|
arguments as well as more argument summary information.
|
||||||
|
|
||||||
3 During execution, allow calc standard resource files
|
3 During execution, allow calc standard resource files
|
||||||
to output additional debugging information.
|
to output additional debugging information.
|
||||||
@@ -103,7 +103,7 @@ either of the bottom 2 bits set:
|
|||||||
print "funcB(size, mass, ...) defined";
|
print "funcB(size, mass, ...) defined";
|
||||||
}
|
}
|
||||||
|
|
||||||
If your the resource file needs to output special debugging informatin,
|
If your the resource file needs to output special debugging information,
|
||||||
we recommend that you check for bit 3 of the config("resource_debug")
|
we recommend that you check for bit 3 of the config("resource_debug")
|
||||||
before printing the debug statement:
|
before printing the debug statement:
|
||||||
|
|
||||||
@@ -117,12 +117,68 @@ The following is a brief description of some of the calc resource files
|
|||||||
that are shipped with calc. See above for example of how to read in
|
that are shipped with calc. See above for example of how to read in
|
||||||
and execute these files.
|
and execute these files.
|
||||||
|
|
||||||
|
alg_config.cal
|
||||||
|
|
||||||
|
global test_time
|
||||||
|
mul_loop(repeat,x) defined
|
||||||
|
mul_ratio(len) defined
|
||||||
|
best_mul2() defined
|
||||||
|
sq_loop(repeat,x) defined
|
||||||
|
sq_ratio(len) defined
|
||||||
|
best_sq2() defined
|
||||||
|
pow_loop(repeat,x,ex) defined
|
||||||
|
pow_ratio(len) defined
|
||||||
|
best_pow2() defined
|
||||||
|
|
||||||
|
These functions search for an optimal value of config("mul2"),
|
||||||
|
config("sq2"), and config("pow2"). The calc default values of these
|
||||||
|
configuration values were set by running this resource file on a
|
||||||
|
1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS.
|
||||||
|
|
||||||
|
The best_mul2() function returns the optimal value of config("mul2").
|
||||||
|
The best_sq2() function returns the optimal value of config("sq2").
|
||||||
|
The best_pow2() function returns the optimal value of config("pow2").
|
||||||
|
The other functions are just support functions.
|
||||||
|
|
||||||
|
By design, best_mul2(), best_sq2(), and best_pow2() take a few
|
||||||
|
minutes to run. These functions increase the number of times a
|
||||||
|
given computational loop is executed until a minimum amount of CPU
|
||||||
|
time is consumed. To watch these functions progress, one can set
|
||||||
|
the config("user_debug") value.
|
||||||
|
|
||||||
|
Here is a suggested way to use this resource file:
|
||||||
|
|
||||||
|
; read alg_config
|
||||||
|
; config("user_debug",2),;
|
||||||
|
; best_mul2(); best_sq2(); best_pow2();
|
||||||
|
; best_mul2(); best_sq2(); best_pow2();
|
||||||
|
; best_mul2(); best_sq2(); best_pow2();
|
||||||
|
|
||||||
|
NOTE: It is perfectly normal for the optimal value returned to differ
|
||||||
|
slightly from run to run. Slight variations due to inaccuracy in
|
||||||
|
CPU timings will cause the best value returned to differ slightly
|
||||||
|
from run to run.
|
||||||
|
|
||||||
|
One can use a calc startup file to change the initial values of
|
||||||
|
config("mul2"), config("sq2"), and config("pow2"). For example one
|
||||||
|
can place into ~/.calcrc these lines:
|
||||||
|
|
||||||
|
config("mul2", 1780),;
|
||||||
|
config("sq2", 3388),;
|
||||||
|
config("pow2", 176),;
|
||||||
|
|
||||||
|
to automatically and silently change these config values.
|
||||||
|
See help/config and CALCRC in help/environment for more information.
|
||||||
|
|
||||||
|
|
||||||
beer.cal
|
beer.cal
|
||||||
|
|
||||||
Calc's contribution to the 99 Bottles of Beer web page:
|
Calc's contribution to the 99 Bottles of Beer web page:
|
||||||
|
|
||||||
http://www.ionet.net/~timtroyr/funhouse/beer.html#calc
|
http://www.ionet.net/~timtroyr/funhouse/beer.html#calc
|
||||||
|
|
||||||
|
NOTE: This resource produces a lot of output. :-)
|
||||||
|
|
||||||
|
|
||||||
bernoulli.cal
|
bernoulli.cal
|
||||||
|
|
||||||
@@ -132,7 +188,7 @@ bernoulli.cal
|
|||||||
|
|
||||||
NOTE: There is now a bernoulli() builtin function. This file is
|
NOTE: There is now a bernoulli() builtin function. This file is
|
||||||
left here for backward compatibility and now simply returns
|
left here for backward compatibility and now simply returns
|
||||||
the buildin function.
|
the builtin function.
|
||||||
|
|
||||||
|
|
||||||
bigprime.cal
|
bigprime.cal
|
||||||
@@ -153,9 +209,9 @@ chi.cal
|
|||||||
|
|
||||||
The chi_prob() function does not work well with odd degrees of freedom.
|
The chi_prob() function does not work well with odd degrees of freedom.
|
||||||
It is reasonable with even degrees of freedom, although one must give
|
It is reasonable with even degrees of freedom, although one must give
|
||||||
a sifficently small error term as the degress gets large (>100).
|
a sufficiently small error term as the degrees gets large (>100).
|
||||||
|
|
||||||
The Z(x) and P(x) are internal statistical funcions.
|
The Z(x) and P(x) are internal statistical functions.
|
||||||
|
|
||||||
eps is an optional epsilon() like error term.
|
eps is an optional epsilon() like error term.
|
||||||
|
|
||||||
@@ -226,6 +282,8 @@ hello.cal
|
|||||||
http://www.latech.edu/~acm/HelloWorld.shtml
|
http://www.latech.edu/~acm/HelloWorld.shtml
|
||||||
http://www.latech.edu/~acm/helloworld/calc.html
|
http://www.latech.edu/~acm/helloworld/calc.html
|
||||||
|
|
||||||
|
NOTE: This resource produces a lot of output. :-)
|
||||||
|
|
||||||
|
|
||||||
intfile.cal
|
intfile.cal
|
||||||
|
|
||||||
@@ -643,6 +701,27 @@ sumsq.cal
|
|||||||
4N+1, and always impossible for primes of the form 4N-1.
|
4N+1, and always impossible for primes of the form 4N-1.
|
||||||
|
|
||||||
|
|
||||||
|
sumtimes.cal
|
||||||
|
|
||||||
|
timematsum(N)
|
||||||
|
timelistsum(N)
|
||||||
|
timematsort(N)
|
||||||
|
timelistsort(N)
|
||||||
|
timematreverse(N)
|
||||||
|
timelistreverse(N)
|
||||||
|
timematssq(N)
|
||||||
|
timelistssq(N)
|
||||||
|
timehmean(N,M)
|
||||||
|
doalltimes(N)
|
||||||
|
|
||||||
|
Give the user CPU time for various ways of evaluating sums, sums of
|
||||||
|
squares, etc, for large lists and matrices. N is the size of
|
||||||
|
the list or matrix to use. The doalltimes() function will run
|
||||||
|
all fo the sumtimes tests. For example:
|
||||||
|
|
||||||
|
doalltimes(1e6);
|
||||||
|
|
||||||
|
|
||||||
surd.cal
|
surd.cal
|
||||||
|
|
||||||
surd(a, b)
|
surd(a, b)
|
||||||
@@ -933,10 +1012,10 @@ xx_print.cal
|
|||||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
## 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
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.12 $
|
## @(#) $Revision: 30.1 $
|
||||||
## @(#) $Id: README,v 29.12 2006/05/21 04:41:09 chongo Exp $
|
## @(#) $Id: README,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1990/02/15 01:50:32
|
## Under source code control: 1990/02/15 01:50:32
|
||||||
|
1253
cal/alg_config.cal
Normal file
1253
cal/alg_config.cal
Normal file
File diff suppressed because it is too large
Load Diff
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: beer.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: beer.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/beer.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/beer.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1996/11/13 13:21:05
|
* Under source code control: 1996/11/13 13:21:05
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.3 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: bernoulli.cal,v 29.3 2000/12/17 12:26:04 chongo Exp $
|
* @(#) $Id: bernoulli.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bernoulli.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bernoulli.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1991/09/30 11:18:41
|
* Under source code control: 1991/09/30 11:18:41
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: bigprime.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: bigprime.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bigprime.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bigprime.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1991/05/22 21:56:32
|
* Under source code control: 1991/05/22 21:56:32
|
||||||
|
@@ -14,10 +14,10 @@
|
|||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
# 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
|
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.2 $
|
# @(#) $Revision: 30.1 $
|
||||||
# @(#) $Id: bindings,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
# @(#) $Id: bindings,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bindings,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bindings,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1993/05/02 20:09:19
|
# Under source code control: 1993/05/02 20:09:19
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: chi.cal,v 29.2 2001/04/08 10:21:23 chongo Exp $
|
* @(#) $Id: chi.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/chi.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/chi.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 2001/03/27 14:10:11
|
* Under source code control: 2001/03/27 14:10:11
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: chrem.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: chrem.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/chrem.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/chrem.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1992/09/26 01:00:47
|
* Under source code control: 1992/09/26 01:00:47
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.4 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: deg.cal,v 29.4 2003/01/26 19:32:41 chongo Exp $
|
* @(#) $Id: deg.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/deg.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/deg.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:33
|
* Under source code control: 1990/02/15 01:50:33
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.2 $
|
||||||
* @(#) $Id: dotest.cal,v 29.2 2006/05/21 00:55:27 chongo Exp $
|
* @(#) $Id: dotest.cal,v 30.2 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/dotest.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/dotest.cal,v $
|
||||||
*
|
*
|
||||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.3 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: ellip.cal,v 29.3 2006/03/07 22:16:25 chongo Exp $
|
* @(#) $Id: ellip.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/ellip.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/ellip.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:33
|
* Under source code control: 1990/02/15 01:50:33
|
||||||
@@ -28,16 +28,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attempt to factor numbers using elliptic functions.
|
* Attempt to factor numbers using elliptic functions:
|
||||||
* y^2 = x^3 + a*x + b (mod N).
|
|
||||||
*
|
*
|
||||||
* Many points (x,y) (mod N) are found that solve the above equation,
|
* y^2 = x^3 + a*x + b (mod ellip_N).
|
||||||
|
*
|
||||||
|
* Many points (x,y) (mod ellip_N) are found that solve the above equation,
|
||||||
* starting from a trivial solution and 'multiplying' that point together
|
* starting from a trivial solution and 'multiplying' that point together
|
||||||
* to generate high powers of the point, looking for such a point whose
|
* to generate high powers of the point, looking for such a point whose
|
||||||
* order contains a common factor with N. The order of the group of points
|
* order contains a common factor with ellip_N. The order of the group of
|
||||||
* varies almost randomly within a certain interval for each choice of a
|
* points varies almost randomly within a certain interval for each choice of
|
||||||
* and b, and thus each choice provides an independent opportunity to
|
* a and b, and thus each choice provides an independent opportunity to
|
||||||
* factor N. To generate a trivial solution, a is chosen and then b is
|
* factor ellip_N. To generate a trivial solution, a is chosen and then b is
|
||||||
* selected so that (1,1) is a solution. The multiplication is done using
|
* selected so that (1,1) is a solution. The multiplication is done using
|
||||||
* the basic fact that the equation is a cubic, and so if a line hits the
|
* the basic fact that the equation is a cubic, and so if a line hits the
|
||||||
* curve in two rational points, then the third intersection point must
|
* curve in two rational points, then the third intersection point must
|
||||||
@@ -45,9 +46,9 @@
|
|||||||
* the number of rational solutions can be made very large. When modular
|
* the number of rational solutions can be made very large. When modular
|
||||||
* arithmetic is used, solving for the third point requires the taking of a
|
* arithmetic is used, solving for the third point requires the taking of a
|
||||||
* modular inverse (instead of division), and if this fails, then the GCD
|
* modular inverse (instead of division), and if this fails, then the GCD
|
||||||
* of the failing value and N provides a factor of N. This description is
|
* of the failing value and ellip_N provides a factor of ellip_N.
|
||||||
* only an approximation, read "A Course in Number Theory and Cryptography"
|
* This description is only an approximation, read "A Course in Number
|
||||||
* by Neal Koblitz for a good explanation.
|
* Theory and Cryptography" by Neal Koblitz for a good explanation.
|
||||||
*
|
*
|
||||||
* efactor(iN, ia, B, force)
|
* efactor(iN, ia, B, force)
|
||||||
* iN is the number to be factored.
|
* iN is the number to be factored.
|
||||||
@@ -81,15 +82,15 @@
|
|||||||
*
|
*
|
||||||
* If a factor is found, it is returned and is also saved in the global
|
* If a factor is found, it is returned and is also saved in the global
|
||||||
* variable f. The number being factored is also saved in the global
|
* variable f. The number being factored is also saved in the global
|
||||||
* variable N.
|
* variable ellip_N.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
obj point {x, y};
|
obj point {x, y};
|
||||||
global N; /* number to factor */
|
global ellip_N; /* number to factor */
|
||||||
global a; /* first coefficient */
|
global ellip_a; /* first coefficient */
|
||||||
global b; /* second coefficient */
|
global ellip_b; /* second coefficient */
|
||||||
global f; /* found factor */
|
global ellip_f; /* found factor */
|
||||||
|
|
||||||
|
|
||||||
define efactor(iN, ia, B, force)
|
define efactor(iN, ia, B, force)
|
||||||
@@ -103,28 +104,28 @@ define efactor(iN, ia, B, force)
|
|||||||
if (isnull(ia))
|
if (isnull(ia))
|
||||||
ia = 1;
|
ia = 1;
|
||||||
obj point x;
|
obj point x;
|
||||||
a = ia;
|
ellip_a = ia;
|
||||||
b = -ia;
|
ellip_b = -ia;
|
||||||
N = iN;
|
ellip_N = iN;
|
||||||
C = isqrt(N);
|
C = isqrt(ellip_N);
|
||||||
C = 2 * C + 2 * isqrt(C) + 1;
|
C = 2 * C + 2 * isqrt(C) + 1;
|
||||||
f = 0;
|
ellip_f = 0;
|
||||||
while (f == 0) {
|
while (ellip_f == 0) {
|
||||||
print "A =", a;
|
print "A =", ellip_a;
|
||||||
x.x = 1;
|
x.x = 1;
|
||||||
x.y = 1;
|
x.y = 1;
|
||||||
print 2, x;
|
print 2, x;
|
||||||
x = x ^ (2 ^ (highbit(C) + 1));
|
x = x ^ (2 ^ (highbit(C) + 1));
|
||||||
for (p = 3; ((p < B) && (f == 0)); p += 2) {
|
for (p = 3; ((p < B) && (ellip_f == 0)); p += 2) {
|
||||||
if (!ptest(p, 1))
|
if (!ptest(p, 1))
|
||||||
continue;
|
continue;
|
||||||
print p, x;
|
print p, x;
|
||||||
x = x ^ (p ^ ((highbit(C) // highbit(p)) + 1));
|
x = x ^ (p ^ ((highbit(C) // highbit(p)) + 1));
|
||||||
}
|
}
|
||||||
a++;
|
ellip_a++;
|
||||||
b--;
|
ellip_b--;
|
||||||
}
|
}
|
||||||
return f;
|
return ellip_f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,16 +144,16 @@ define point_mul(p1, p2)
|
|||||||
if (p1 == p2)
|
if (p1 == p2)
|
||||||
return point_square(`p1);
|
return point_square(`p1);
|
||||||
obj point r;
|
obj point r;
|
||||||
m = (minv(p2.x - p1.x, N) * (p2.y - p1.y)) % N;
|
m = (minv(p2.x - p1.x, ellip_N) * (p2.y - p1.y)) % ellip_N;
|
||||||
if (m == 0) {
|
if (m == 0) {
|
||||||
if (f == 0)
|
if (ellip_f == 0)
|
||||||
f = gcd(p2.x - p1.x, N);
|
ellip_f = gcd(p2.x - p1.x, ellip_N);
|
||||||
r.x = 1;
|
r.x = 1;
|
||||||
r.y = 1;
|
r.y = 1;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
r.x = (m^2 - p1.x - p2.x) % N;
|
r.x = (m^2 - p1.x - p2.x) % ellip_N;
|
||||||
r.y = ((m * (p1.x - r.x)) - p1.y) % N;
|
r.y = ((m * (p1.x - r.x)) - p1.y) % ellip_N;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,16 +163,16 @@ define point_square(p)
|
|||||||
local r, m;
|
local r, m;
|
||||||
|
|
||||||
obj point r;
|
obj point r;
|
||||||
m = ((3 * p.x^2 + a) * minv(p.y << 1, N)) % N;
|
m = ((3 * p.x^2 + ellip_a) * minv(p.y << 1, ellip_N)) % ellip_N;
|
||||||
if (m == 0) {
|
if (m == 0) {
|
||||||
if (f == 0)
|
if (ellip_f == 0)
|
||||||
f = gcd(p.y << 1, N);
|
ellip_f = gcd(p.y << 1, ellip_N);
|
||||||
r.x = 1;
|
r.x = 1;
|
||||||
r.y = 1;
|
r.y = 1;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
r.x = (m^2 - p.x - p.x) % N;
|
r.x = (m^2 - p.x - p.x) % ellip_N;
|
||||||
r.y = ((m * (p.x - r.x)) - p.y) % N;
|
r.y = ((m * (p.x - r.x)) - p.y) % ellip_N;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +185,7 @@ define point_pow(p, pow)
|
|||||||
if (isodd(pow))
|
if (isodd(pow))
|
||||||
r = p;
|
r = p;
|
||||||
t = p;
|
t = p;
|
||||||
for (bit = 2; ((bit <= pow) && (f == 0)); bit <<= 1) {
|
for (bit = 2; ((bit <= pow) && (ellip_f == 0)); bit <<= 1) {
|
||||||
t = point_square(`t);
|
t = point_square(`t);
|
||||||
if (bit & pow)
|
if (bit & pow)
|
||||||
r = point_mul(`t, `r);
|
r = point_mul(`t, `r);
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: hello.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: hello.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/hello.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/hello.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1996/11/13 13:25:43
|
* Under source code control: 1996/11/13 13:25:43
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.5 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: intfile.cal,v 29.5 2001/04/10 22:09:34 chongo Exp $
|
* @(#) $Id: intfile.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/intfile.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/intfile.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 2001/03/31 08:13:11
|
* Under source code control: 2001/03/31 08:13:11
|
||||||
|
@@ -1,3 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* linear - perform a simple two point 2D linear interpolation
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005-2007 Landon Curt Noll
|
||||||
|
*
|
||||||
|
* Calc is open software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @(#) $Revision: 30.2 $
|
||||||
|
* @(#) $Id: linear.cal,v 30.2 2007/03/17 05:57:42 chongo Exp $
|
||||||
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/linear.cal,v $
|
||||||
|
*
|
||||||
|
* Under source code control: 2005/12/12 06:41:50
|
||||||
|
* File existed as early as: 2005
|
||||||
|
*
|
||||||
|
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||||
|
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* linear - perform a simple two point 2D linear interpolation
|
* linear - perform a simple two point 2D linear interpolation
|
||||||
*
|
*
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.6 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: lucas.cal,v 29.6 2002/07/10 09:43:46 chongo Exp $
|
* @(#) $Id: lucas.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/05/03 16:49:51
|
* Under source code control: 1990/05/03 16:49:51
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.3 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: lucas_chk.cal,v 29.3 2001/03/31 13:31:34 chongo Exp $
|
* @(#) $Id: lucas_chk.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas_chk.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas_chk.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1991/01/11 05:41:43
|
* Under source code control: 1991/01/11 05:41:43
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: lucas_tbl.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: lucas_tbl.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas_tbl.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas_tbl.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1991/01/26 02:43:43
|
* Under source code control: 1991/01/26 02:43:43
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: mersenne.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: mersenne.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mersenne.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mersenne.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1991/05/22 21:56:36
|
* Under source code control: 1991/05/22 21:56:36
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: mfactor.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: mfactor.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mfactor.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mfactor.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1996/07/06 06:09:40
|
* Under source code control: 1996/07/06 06:09:40
|
||||||
@@ -261,7 +261,7 @@ define mfactor(n, start_k, rept_loop, p_elim)
|
|||||||
} else {
|
} else {
|
||||||
/* report this loop */
|
/* report this loop */
|
||||||
printf("at 2*%d*%d+1, cpu: %f\n",
|
printf("at 2*%d*%d+1, cpu: %f\n",
|
||||||
(q-1)/(2*n), n, runtime());
|
(q-1)/(2*n), n, usertime());
|
||||||
fflush(files(1));
|
fflush(files(1));
|
||||||
loop = 0;
|
loop = 0;
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ define mfactor(n, start_k, rept_loop, p_elim)
|
|||||||
if (rept_loop <= ++loop) {
|
if (rept_loop <= ++loop) {
|
||||||
/* report this loop */
|
/* report this loop */
|
||||||
printf("at 2*%d*%d+1, cpu: %f\n",
|
printf("at 2*%d*%d+1, cpu: %f\n",
|
||||||
(q-1)/(2*n), n, runtime());
|
(q-1)/(2*n), n, usertime());
|
||||||
fflush(files(1));
|
fflush(files(1));
|
||||||
loop = 0;
|
loop = 0;
|
||||||
}
|
}
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: mod.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: mod.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mod.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mod.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:34
|
* Under source code control: 1990/02/15 01:50:34
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.3 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: natnumset.cal,v 29.3 2006/05/01 19:19:46 chongo Exp $
|
* @(#) $Id: natnumset.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/natnumset.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/natnumset.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1997/09/07 23:53:51
|
* Under source code control: 1997/09/07 23:53:51
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: pell.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: pell.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pell.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pell.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:34
|
* Under source code control: 1990/02/15 01:50:34
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.5 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: pi.cal,v 29.5 2004/02/23 14:04:01 chongo Exp $
|
* @(#) $Id: pi.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pi.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pi.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1991/05/22 21:56:37
|
* Under source code control: 1991/05/22 21:56:37
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: pix.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: pix.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pix.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pix.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1996/07/09 03:14:14
|
* Under source code control: 1996/07/09 03:14:14
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: pollard.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: pollard.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pollard.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pollard.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1991/05/22 21:56:37
|
* Under source code control: 1991/05/22 21:56:37
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: poly.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: poly.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/poly.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/poly.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:35
|
* Under source code control: 1990/02/15 01:50:35
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: prompt.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: prompt.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/prompt.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/prompt.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/12/18 04:43:25
|
* Under source code control: 1995/12/18 04:43:25
|
||||||
@@ -101,7 +101,7 @@ define adder() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
global x;
|
global prompt_x;
|
||||||
|
|
||||||
define showvalues(str) {
|
define showvalues(str) {
|
||||||
local s;
|
local s;
|
||||||
@@ -109,8 +109,8 @@ define showvalues(str) {
|
|||||||
s = prompt("? ");
|
s = prompt("? ");
|
||||||
if (s == "end")
|
if (s == "end")
|
||||||
break;
|
break;
|
||||||
x = eval(s);
|
prompt_x = eval(s);
|
||||||
if (!isnum(x)) {
|
if (!isnum(prompt_x)) {
|
||||||
print "Please enter a number";
|
print "Please enter a number";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: psqrt.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: psqrt.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/psqrt.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/psqrt.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:35
|
* Under source code control: 1990/02/15 01:50:35
|
||||||
|
@@ -18,10 +18,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.4 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: qtime.cal,v 29.4 2000/12/18 10:18:40 chongo Exp $
|
* @(#) $Id: qtime.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/qtime.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/qtime.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1999/10/13 04:10:33
|
* Under source code control: 1999/10/13 04:10:33
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: quat.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: quat.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/quat.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/quat.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:35
|
* Under source code control: 1990/02/15 01:50:35
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: randbitrun.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: randbitrun.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randbitrun.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randbitrun.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/02/13 03:43:11
|
* Under source code control: 1995/02/13 03:43:11
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: randmprime.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: randmprime.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randmprime.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randmprime.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1994/03/14 23:11:21
|
* Under source code control: 1994/03/14 23:11:21
|
||||||
@@ -88,8 +88,8 @@ randmprime(bits, seed, dbg)
|
|||||||
* loop until we find a prime
|
* loop until we find a prime
|
||||||
*/
|
*/
|
||||||
if (dbg >= 1) {
|
if (dbg >= 1) {
|
||||||
start = runtime();
|
start = usertime();
|
||||||
init = runtime();
|
init = usertime();
|
||||||
plush = 0;
|
plush = 0;
|
||||||
print "DEBUG1: testing (h+" : plush : ")*2^" : n : "-1";
|
print "DEBUG1: testing (h+" : plush : ")*2^" : n : "-1";
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ randmprime(bits, seed, dbg)
|
|||||||
|
|
||||||
/* bump h, and n if needed */
|
/* bump h, and n if needed */
|
||||||
if (dbg >= 2) {
|
if (dbg >= 2) {
|
||||||
stop = runtime();
|
stop = usertime();
|
||||||
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
||||||
}
|
}
|
||||||
if (dbg >= 1) {
|
if (dbg >= 1) {
|
||||||
@@ -116,7 +116,7 @@ randmprime(bits, seed, dbg)
|
|||||||
|
|
||||||
/* found a prime */
|
/* found a prime */
|
||||||
if (dbg >= 2) {
|
if (dbg >= 2) {
|
||||||
stop = runtime();
|
stop = usertime();
|
||||||
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
||||||
print "DEBUG3: " : h : "*2^" : n : "-1 is prime";
|
print "DEBUG3: " : h : "*2^" : n : "-1 is prime";
|
||||||
}
|
}
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: randombitrun.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: randombitrun.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randombitrun.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randombitrun.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/02/13 03:43:11
|
* Under source code control: 1995/02/13 03:43:11
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: randomrun.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: randomrun.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randomrun.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randomrun.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1997/02/19 03:35:59
|
* Under source code control: 1997/02/19 03:35:59
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: randrun.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: randrun.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randrun.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randrun.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/02/12 20:00:06
|
* Under source code control: 1995/02/12 20:00:06
|
||||||
|
629
cal/regress.cal
629
cal/regress.cal
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.25 $
|
* @(#) $Revision: 30.4 $
|
||||||
* @(#) $Id: regress.cal,v 29.25 2006/05/21 00:58:31 chongo Exp $
|
* @(#) $Id: regress.cal,v 30.4 2008/02/24 07:41:49 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:36
|
* Under source code control: 1990/02/15 01:50:36
|
||||||
@@ -201,7 +201,6 @@ define test_variables()
|
|||||||
local x1, x2, x3;
|
local x1, x2, x3;
|
||||||
global g1, g2;
|
global g1, g2;
|
||||||
local t;
|
local t;
|
||||||
global globalvar;
|
|
||||||
local x;
|
local x;
|
||||||
|
|
||||||
print '350: Beginning test_variables';
|
print '350: Beginning test_variables';
|
||||||
@@ -404,14 +403,14 @@ define test_config()
|
|||||||
'512: config("trace") == 0');
|
'512: config("trace") == 0');
|
||||||
vrfy(config("maxprint") == 16,
|
vrfy(config("maxprint") == 16,
|
||||||
'513: config("maxprint") == 16');
|
'513: config("maxprint") == 16');
|
||||||
vrfy(config("mul2") == 20,
|
vrfy(config("mul2") == 1780,
|
||||||
'514: config("mul2") == 20');
|
'514: config("mul2") == 1780');
|
||||||
vrfy(config("sq2") == 20,
|
vrfy(config("sq2") == 3388,
|
||||||
'515: config("sq2") == 20');
|
'515: config("sq2") == 3388');
|
||||||
vrfy(config("pow2") == 40,
|
vrfy(config("pow2") == 176,
|
||||||
'516: config("pow2") == 40');
|
'516: config("pow2") == 176');
|
||||||
vrfy(config("redc2") == 50,
|
vrfy(config("redc2") == 220,
|
||||||
'517: config("redc2") == 50');
|
'517: config("redc2") == 220');
|
||||||
vrfy(config("tilde"),
|
vrfy(config("tilde"),
|
||||||
'518: config("tilde")');
|
'518: config("tilde")');
|
||||||
vrfy(config("tab"),
|
vrfy(config("tab"),
|
||||||
@@ -498,7 +497,33 @@ define test_config()
|
|||||||
vrfy(config("mode2") == "off",
|
vrfy(config("mode2") == "off",
|
||||||
'556: config("mode2") == "off"');
|
'556: config("mode2") == "off"');
|
||||||
|
|
||||||
print '557: Ending test_config';
|
/* hz is numeric */
|
||||||
|
vrfy(isint(config("hz")), '557: isint(config("hz"))');
|
||||||
|
|
||||||
|
/* compile_custom is simple */
|
||||||
|
vrfy(issimple(config("compile_custom")),
|
||||||
|
'558: issimple(config("compile_custom"))');
|
||||||
|
|
||||||
|
/* allow_custom is simple */
|
||||||
|
vrfy(issimple(config("allow_custom")),
|
||||||
|
'559: issimple(config("allow_custom"))');
|
||||||
|
|
||||||
|
/* allow_custom is simple */
|
||||||
|
vrfy(issimple(config("allow_custom")),
|
||||||
|
'559: issimple(config("allow_custom"))');
|
||||||
|
|
||||||
|
/* baseb is numeric */
|
||||||
|
vrfy(isint(config("baseb")), '560: isint(config("baseb"))');
|
||||||
|
|
||||||
|
/* redecl_warn is simple */
|
||||||
|
vrfy(issimple(config("redecl_warn")),
|
||||||
|
'561: issimple(config("redecl_warn"))');
|
||||||
|
|
||||||
|
/* dupvar_warn is simple */
|
||||||
|
vrfy(issimple(config("dupvar_warn")),
|
||||||
|
'562: issimple(config("rdupvar_warn"))');
|
||||||
|
|
||||||
|
print '563: Ending test_config';
|
||||||
}
|
}
|
||||||
print '010: parsed test_config()';
|
print '010: parsed test_config()';
|
||||||
|
|
||||||
@@ -571,12 +596,18 @@ print '012: parsed squarecheck(a, b, str)';
|
|||||||
define powercheck(a, p1, p2, str)
|
define powercheck(a, p1, p2, str)
|
||||||
{
|
{
|
||||||
local a1, a2, a3;
|
local a1, a2, a3;
|
||||||
|
local b1, b2, b3;
|
||||||
|
|
||||||
a1 = (a^p1)^p2;
|
a1 = (a^p1)^p2;
|
||||||
a2 = (a^p2)^p1;
|
a2 = (a^p2)^p1;
|
||||||
a3 = a^(p1*p2);
|
a3 = a^(p1*p2);
|
||||||
|
b1 = (a**p1)**p2;
|
||||||
|
b2 = (a**p2)**p1;
|
||||||
|
b3 = a**(p1*p2);
|
||||||
if (a1 != a2) {print '**** (a^p1)^p2 != (a^p2)^p1:', str; ++prob;}
|
if (a1 != a2) {print '**** (a^p1)^p2 != (a^p2)^p1:', str; ++prob;}
|
||||||
if (a1 != a3) {print '**** (a^p1)^p2 != a^(p1*p2):', str; ++prob;}
|
if (a1 != a3) {print '**** (a^p1)^p2 != a^(p1*p2):', str; ++prob;}
|
||||||
|
if (b1 != b2) {print '**** (b^p1)^p2 != (b^p2)^p1:', str; ++prob;}
|
||||||
|
if (b1 != b3) {print '**** (b^p1)^p2 != b^(p1*p2):', str; ++prob;}
|
||||||
print str;
|
print str;
|
||||||
}
|
}
|
||||||
print '013: parsed powercheck(a, p1, p2, str)';
|
print '013: parsed powercheck(a, p1, p2, str)';
|
||||||
@@ -744,6 +775,7 @@ define test_functions()
|
|||||||
local pi;
|
local pi;
|
||||||
local h, n, r, m, v;
|
local h, n, r, m, v;
|
||||||
local n2, m2, v2;
|
local n2, m2, v2;
|
||||||
|
local t;
|
||||||
|
|
||||||
print '700: Beginning test_functions';
|
print '700: Beginning test_functions';
|
||||||
|
|
||||||
@@ -1317,7 +1349,102 @@ define test_functions()
|
|||||||
*/
|
*/
|
||||||
vrfy(isstr(calcpath()), '1155: isstr(calcpath())');
|
vrfy(isstr(calcpath()), '1155: isstr(calcpath())');
|
||||||
|
|
||||||
print '1156: Ending test_functions';
|
/*
|
||||||
|
* ssq use of lists
|
||||||
|
*/
|
||||||
|
vrfy(ssq(1,2, list(3,4,list(5,6)), list(), 7, 8) == 204,
|
||||||
|
'1156: ssq(1,2, list(3,4,list(5,6)), list(), 7, 8) == 204');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* quomod 5th argument rounding tests
|
||||||
|
*/
|
||||||
|
vrfy(quomod(10,-3,a,b,0) == 1, '1157: vrfy(quomod(10,-3,a,b,0) == 1');
|
||||||
|
vrfy(a == -4, '1158: a == -4');
|
||||||
|
vrfy(b == -2, '1159: b == -2');
|
||||||
|
vrfy(quomod(-10,-3,a,b,1) == 1, '1160: vrfy(quomod(-10,-3,a,b,1) == 1');
|
||||||
|
vrfy(a == 4, '1161: a == 4');
|
||||||
|
vrfy(b == 2, '1162: b == 2');
|
||||||
|
vrfy(quomod(10,3,a,b,2) == 1, '1163: vrfy(quomod(10,3,a,b,2) == 1');
|
||||||
|
vrfy(a == 3, '1164: a == 3');
|
||||||
|
vrfy(b == 1, '1165: b == 1');
|
||||||
|
vrfy(quomod(-10,3,a,b,3) == 1, '1166: vrfy(quomod(-10,3,a,b,3) == 1');
|
||||||
|
vrfy(a == -4, '1167: a == -4');
|
||||||
|
vrfy(b == 2, '1168: b == 2');
|
||||||
|
vrfy(quomod(10,-3,a,b,4) == 1, '1169: vrfy(quomod(10,-3,a,b,4) == 1');
|
||||||
|
vrfy(a == -3, '1170: a == -3');
|
||||||
|
vrfy(b == 1, '1171: b == 1');
|
||||||
|
vrfy(quomod(-10,-3,a,b,5) == 1, '1172: vrfy(quomod(-10,-3,a,b,5) == 1');
|
||||||
|
vrfy(a == 3, '1173: a == 3');
|
||||||
|
vrfy(b == -1, '1174: b == -1');
|
||||||
|
vrfy(quomod(10,3,a,b,6) == 1, '1175: vrfy(quomod(10,3,a,b,6) == 1');
|
||||||
|
vrfy(a == 3, '1176: a == 3');
|
||||||
|
vrfy(b == 1, '1177: b == 1');
|
||||||
|
vrfy(quomod(-10,3,a,b,7) == 1, '1178: vrfy(quomod(-10,3,a,b,7) == 1');
|
||||||
|
vrfy(a == -4, '1179: a == -4');
|
||||||
|
vrfy(b == 2, '1180: b == 2');
|
||||||
|
vrfy(quomod(10,-3,a,b,8) == 1, '1181: vrfy(quomod(10,-3,a,b,8) == 1');
|
||||||
|
vrfy(a == -4, '1182: a == -4');
|
||||||
|
vrfy(b == -2, '1183: b == -2');
|
||||||
|
vrfy(quomod(-10,-3,a,b,9) == 1, '1184: vrfy(quomod(-10,-3,a,b,9) == 1');
|
||||||
|
vrfy(a == 3, '1185: a == 3');
|
||||||
|
vrfy(b == -1, '1186: b == -1');
|
||||||
|
vrfy(quomod(10,3,a,b,10) == 1, '1187: vrfy(quomod(10,3,a,b,10) == 1');
|
||||||
|
vrfy(a == 4, '1188: a == 4');
|
||||||
|
vrfy(b == -2, '1189: b == -2');
|
||||||
|
vrfy(quomod(-10,3,a,b,11) == 1, '1190: vrfy(quomod(-10,3,a,b,11) == 1');
|
||||||
|
vrfy(a == -4, '1191: a == -4');
|
||||||
|
vrfy(b == 2, '1192: b == 2');
|
||||||
|
vrfy(quomod(10,-3,a,b,12) == 1, '1193: vrfy(quomod(10,-3,a,b,12) == 1');
|
||||||
|
vrfy(a == -3, '1194: a == -3');
|
||||||
|
vrfy(b == 1, '1195: b == 1');
|
||||||
|
vrfy(quomod(-10,-3,a,b,13) == 1,'1196: vrfy(quomod(-10,-3,a,b,13) == 1');
|
||||||
|
vrfy(a == 4, '1197: a == 4');
|
||||||
|
vrfy(b == 2, '1198: b == 2');
|
||||||
|
vrfy(quomod(10,3,a,b,14) == 1, '1199: vrfy(quomod(10,3,a,b,14) == 1');
|
||||||
|
vrfy(a == 4, '1200: a == 4');
|
||||||
|
vrfy(b == -2, '1201: b == -2');
|
||||||
|
vrfy(quomod(-10,3,a,b,15) == 1, '1202: vrfy(quomod(-10,3,a,b,15) == 1');
|
||||||
|
vrfy(a == -4, '1203: a == -4');
|
||||||
|
vrfy(b == 2, '1204: b == 2');
|
||||||
|
|
||||||
|
/* runtime(), systime(), usertime() return numeric values */
|
||||||
|
vrfy(isnum(runtime()), '1205: isnum(runtime())');
|
||||||
|
vrfy(isnum(systime()), '1206: isnum(systime())');
|
||||||
|
vrfy(isnum(usertime()), '1207: isnum(usertime())');
|
||||||
|
|
||||||
|
/* more jacobi tests */
|
||||||
|
vrfy(jacobi(987897,987) == 0, '1208: jacobi(987897,987) == 0');
|
||||||
|
vrfy(jacobi(897,987) == 0, '1209: jacobi(897,987) == 0');
|
||||||
|
vrfy(jacobi(987,897) == 0, '1210: jacobi(987,897) == 0');
|
||||||
|
vrfy(jacobi(90,897) == 0, '1211: jacobi(90,897) == 0');
|
||||||
|
vrfy(jacobi(45,897) == 0, '1212: jacobi(45,897) == 0');
|
||||||
|
vrfy(jacobi(897,45) == 0, '1213: jacobi(897,45) == 0');
|
||||||
|
vrfy(jacobi(42,45) == 0, '1214: jacobi(42,45) == 0');
|
||||||
|
vrfy(jacobi(21,45) == 0, '1215: jacobi(21,45) == 0');
|
||||||
|
vrfy(jacobi(45,21) == 0, '1216: jacobi(45,21) == 0');
|
||||||
|
vrfy(jacobi(3,21) == 0, '1217: jacobi(3,21) == 0');
|
||||||
|
vrfy(jacobi(0,21) == 0, '1218: jacobi(0,21) == 0');
|
||||||
|
vrfy(jacobi(0,20003) == 0, '1219: jacobi(0,20003) == 0');
|
||||||
|
vrfy(jacobi(1,20003) == 1, '1220: jacobi(1,20003) == 1');
|
||||||
|
vrfy(jacobi(1236,20003) == 1, '1221: jacobi(1236,20003) == 1');
|
||||||
|
vrfy(jacobi(618,20003) == -1, '1222: jacobi(618,20003) == -1');
|
||||||
|
vrfy(jacobi(309,20003) == 1, '1223: jacobi(309,20003) == 1');
|
||||||
|
vrfy(jacobi(227,309) == 1, '1224: jacobi(227,309) == 1');
|
||||||
|
vrfy(jacobi(82,227) == 1, '1225: jacobi(82,227) == 1');
|
||||||
|
vrfy(jacobi(41,227) == -1, '1226: jacobi(41,227) == -1');
|
||||||
|
vrfy(jacobi(22,41) == -1, '1227: jacobi(22,41) == -1');
|
||||||
|
vrfy(jacobi(11,41) == -1, '1228: jacobi(11,41) == -1');
|
||||||
|
vrfy(jacobi(8,11) == -1, '1229: jacobi(8,11) == -1');
|
||||||
|
vrfy(jacobi(4,11) == 1, '1230: jacobi(4,11) == 1');
|
||||||
|
vrfy(jacobi(2,11) == -1, '1231: jacobi(2,11) == -1');
|
||||||
|
vrfy(jacobi(1,11) == 1, '1232: jacobi(1,11) == 1');
|
||||||
|
vrfy(jacobi(0,11) == 0, '1233: jacobi(0,11) == 0');
|
||||||
|
vrfy(jacobi(0,0) == 0, '1234: jacobi(0,0) == 0');
|
||||||
|
vrfy(jacobi(-1,0) == 0, '1235: jacobi(-1,0) == 0');
|
||||||
|
vrfy(jacobi(-1,-1) == 0, '1236: jacobi(-1,-1) == 0');
|
||||||
|
vrfy(jacobi(0,-1) == 0, '1237: jacobi(0,-1) == 0');
|
||||||
|
|
||||||
|
print '1238: Ending test_functions';
|
||||||
}
|
}
|
||||||
print '017: parsed test_functions()';
|
print '017: parsed test_functions()';
|
||||||
|
|
||||||
@@ -1334,14 +1461,14 @@ define _test_underscore()
|
|||||||
local _a = 27;
|
local _a = 27;
|
||||||
local __a = 23209;
|
local __a = 23209;
|
||||||
|
|
||||||
print "1200: Beginning _test_underscore";
|
print "1290: Beginning _test_underscore";
|
||||||
|
|
||||||
vrfy(_a == 27, '1201: _a == 27');
|
vrfy(_a == 27, '1291: _a == 27');
|
||||||
vrfy(_ == 49, '1202: _ == 49');
|
vrfy(_ == 49, '1292: _ == 49');
|
||||||
vrfy(__ == 63, '1203: __ == 63');
|
vrfy(__ == 63, '1293: __ == 63');
|
||||||
vrfy(__a == 23209, '1204: __a == 23209');
|
vrfy(__a == 23209, '1294: __a == 23209');
|
||||||
|
|
||||||
print "1205: Ending _test_underscore";
|
print "1295: Ending _test_underscore";
|
||||||
}
|
}
|
||||||
print '020: parsed _test_underscore';
|
print '020: parsed _test_underscore';
|
||||||
|
|
||||||
@@ -3170,7 +3297,7 @@ define test_error()
|
|||||||
'3654: scale(3,2^31) == error(10034)');
|
'3654: scale(3,2^31) == error(10034)');
|
||||||
vrfy("x" ^ 3 == error(10035), '3655: "x" ^ 3 == error(10035)');
|
vrfy("x" ^ 3 == error(10035), '3655: "x" ^ 3 == error(10035)');
|
||||||
vrfy(2 ^ "x" == error(10036), '3656: 2 ^ "x" == error(10036)');
|
vrfy(2 ^ "x" == error(10036), '3656: 2 ^ "x" == error(10036)');
|
||||||
vrfy(2 ^ 2.5 == error(10036), '3657: 2 ^ 2.5 == error(10036)');
|
vrfy(2 ^ "2" == error(10036), '3657: 2 ^ "2" == error(10036)');
|
||||||
vrfy(power("x",2.1) == error(10037),
|
vrfy(power("x",2.1) == error(10037),
|
||||||
'3658: power("x",2.1) == error(10037)');
|
'3658: power("x",2.1) == error(10037)');
|
||||||
vrfy(power(2,"x") == error(10038),
|
vrfy(power(2,"x") == error(10038),
|
||||||
@@ -3404,11 +3531,12 @@ print '070: parsed test_redc()';
|
|||||||
*/
|
*/
|
||||||
define test_fileops()
|
define test_fileops()
|
||||||
{
|
{
|
||||||
local a, b, c, f, m, n, p, r, x, y, z;
|
local a, b, c, f, m, n, p, r, s, x, y, z;
|
||||||
local L = "Landon";
|
local L = "Landon";
|
||||||
local C = "Curt";
|
local C = "Curt";
|
||||||
local N = "Noll";
|
local N = "Noll";
|
||||||
local LCN = "Landon\nCurt\nNoll\n";
|
local LCN = "Landon\nCurt\nNoll\n";
|
||||||
|
local long = "0123456789abcdef0123456789abcdef";
|
||||||
|
|
||||||
print '4200: Beginning test_fileops';
|
print '4200: Beginning test_fileops';
|
||||||
|
|
||||||
@@ -3511,16 +3639,55 @@ define test_fileops()
|
|||||||
*/
|
*/
|
||||||
vrfy(!iserror(p=fpathopen("junk4200","r",".")),
|
vrfy(!iserror(p=fpathopen("junk4200","r",".")),
|
||||||
'4260: !iserror(p=fparhopen("junk4200","r","."))');
|
'4260: !iserror(p=fparhopen("junk4200","r","."))');
|
||||||
|
vrfy(!iserror(fclose(p)), '4261: !iserror(fclose(p))');
|
||||||
vrfy(!iserror(r=fpathopen("regress.cal","r")),
|
vrfy(!iserror(r=fpathopen("regress.cal","r")),
|
||||||
'4261: !iserror(r=fparhopen("regress.cal","r","."))');
|
'4262: !iserror(r=fparhopen("regress.cal","r","."))');
|
||||||
|
vrfy(!iserror(fclose(r)), '4263: !iserror(fclose(r))');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* verify non-stack overflow on long filenames
|
||||||
|
*/
|
||||||
|
long = long + long + long + long;
|
||||||
|
print '4264: long = long + long + long + long;';
|
||||||
|
long = long + long + long + long;
|
||||||
|
print '4265: long = long + long + long + long;';
|
||||||
|
vrfy(strlen(long) == 512, '4266: strlen(long) == 512');
|
||||||
|
/* bump ecnt up by 1 */
|
||||||
|
++ecnt;
|
||||||
|
print '4267: ++ecnt;';
|
||||||
|
vrfy(isfile(p=fopen(long,"r")) == 0,
|
||||||
|
'4268: isfile(p=fopen(long,"r")) == 0');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* test fgetfile() and fgetline()
|
||||||
|
*/
|
||||||
|
vrfy(!iserror(p=fopen("tmp4200","w")),
|
||||||
|
'4269: !iserror(p=fopen("tmp4200","w"))');
|
||||||
|
vrfy(!iserror(fputs(p,"chongo\n")),
|
||||||
|
'4270: !iserror(fputs(p,"chongo\n"))');
|
||||||
|
vrfy(!iserror(fputs(p,"w\0a\0s\n")),
|
||||||
|
'4271: !iserror(fputs(p,"w\0a\0s\n"))');
|
||||||
|
vrfy(!iserror(fputs(p,"here\n")),
|
||||||
|
'4272: !iserror(fputs(p,"here\n"))');
|
||||||
|
vrfy(!iserror(fclose(p)), '4273: !iserror(fclose(p))');
|
||||||
|
vrfy(!iserror(p=fopen("tmp4200","r")),
|
||||||
|
'4274: !iserror(p=fopen("tmp4200","r"))');
|
||||||
|
vrfy(!iserror(s=fgetline(p)), '4275: !iserror(s=fgetline(p))');
|
||||||
|
vrfy(strcmp(s,"chongo") == 0, '4276: strcmp(s,"chongo") == 0');
|
||||||
|
vrfy(!iserror(s=fgetfile(p)), '4277: !iserror(s=fgetfile(p))');
|
||||||
|
vrfy(strcmp(s,"w\0a\0s\nhere\n") == 0,
|
||||||
|
'4278: strcmp(s,"w\0a\0s\nhere\n") == 0');
|
||||||
|
vrfy(!iserror(fclose(p)), '4279: !iserror(fclose(p))');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cleanup
|
* cleanup
|
||||||
*/
|
*/
|
||||||
x = rm("junk4200");
|
x = rm("junk4200");
|
||||||
print '4262: x = rm("junk4200")';
|
print '4280: x = rm("junk4200")';
|
||||||
|
x = rm("tmp4200");
|
||||||
|
print '4281: x = rm("tmp4200")';
|
||||||
|
|
||||||
print '4263: Ending test_fileops';
|
print '4282: Ending test_fileops';
|
||||||
}
|
}
|
||||||
print '071: parsed test_fileops()';
|
print '071: parsed test_fileops()';
|
||||||
|
|
||||||
@@ -3955,7 +4122,7 @@ print '088: parsed test_fileop()';
|
|||||||
/*
|
/*
|
||||||
* global and static assignment tests
|
* global and static assignment tests
|
||||||
*/
|
*/
|
||||||
global a = 10, b, c d = 20, e, f;
|
global a = 10, b, c d = 20, e;
|
||||||
print '089: global a = 10, b, c d = 20, e, f';
|
print '089: global a = 10, b, c d = 20, e, f';
|
||||||
vrfy(a == 10, '090: a == 10');
|
vrfy(a == 10, '090: a == 10');
|
||||||
vrfy(b == 0, '091: b == 0');
|
vrfy(b == 0, '091: b == 0');
|
||||||
@@ -4655,13 +4822,11 @@ print '137: parsed test_random()';
|
|||||||
/*
|
/*
|
||||||
* test_newsyn - test new command completion syntax and scope rules
|
* test_newsyn - test new command completion syntax and scope rules
|
||||||
*/
|
*/
|
||||||
for (s5500 = 0, i = 0; i < 5; i++)
|
for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;
|
||||||
s5500 += i;
|
|
||||||
print "138: for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;";
|
print "138: for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;";
|
||||||
vrfy(s5500 == 10, '139: s5500 == 10');
|
vrfy(s5500 == 10, '139: s5500 == 10');
|
||||||
vrfy(i == 5, '140: i == 5');
|
vrfy(i == 5, '140: i == 5');
|
||||||
for (s5500 = 0, i = 0; i < 9; i++)
|
for (s5500 = 0, i = 0; i < 9; i++) {
|
||||||
{
|
|
||||||
s5500 += i;
|
s5500 += i;
|
||||||
}
|
}
|
||||||
print "141: for (s5500 = 0, i = 0; i < 9; i++) { s5500 += i; }";
|
print "141: for (s5500 = 0, i = 0; i < 9; i++) { s5500 += i; }";
|
||||||
@@ -4709,7 +4874,6 @@ define test_newsyn()
|
|||||||
vrfy(i == 3, '5509: i == 3');
|
vrfy(i == 3, '5509: i == 3');
|
||||||
/**/
|
/**/
|
||||||
{
|
{
|
||||||
local i;
|
|
||||||
for (s5500 = 0, i = 0; i < 11; i++)
|
for (s5500 = 0, i = 0; i < 11; i++)
|
||||||
s5500 += i;
|
s5500 += i;
|
||||||
vrfy(s5500 == 55, '5510: s5500 == 45');
|
vrfy(s5500 == 55, '5510: s5500 == 45');
|
||||||
@@ -5121,8 +5285,6 @@ print '156: parsed test_size()';
|
|||||||
/*
|
/*
|
||||||
* test_assign - test assignment of constants and variables
|
* test_assign - test assignment of constants and variables
|
||||||
*/
|
*/
|
||||||
global A, B; /* A, B for "constants" */
|
|
||||||
print '157: global A, B';
|
|
||||||
global X5800, Y5800; /* X5800, Y5800 for "variables" */
|
global X5800, Y5800; /* X5800, Y5800 for "variables" */
|
||||||
print '158: global X5800, Y5800';
|
print '158: global X5800, Y5800';
|
||||||
obj xy5800 {x, y};
|
obj xy5800 {x, y};
|
||||||
@@ -5196,7 +5358,7 @@ define test_is()
|
|||||||
local nerr; /* new error value */
|
local nerr; /* new error value */
|
||||||
local odd; /* odd integer */
|
local odd; /* odd integer */
|
||||||
local even; /* even integer that is 10 times odd */
|
local even; /* even integer that is 10 times odd */
|
||||||
local hash; /* sha hash value */
|
local hash; /* sha1 hash value */
|
||||||
local id; /* identity matrix */
|
local id; /* identity matrix */
|
||||||
local list; /* list value */
|
local list; /* list value */
|
||||||
local matrix; /* non-identity matrix */
|
local matrix; /* non-identity matrix */
|
||||||
@@ -5209,6 +5371,11 @@ define test_is()
|
|||||||
local square; /* square of an odd prime */
|
local square; /* square of an odd prime */
|
||||||
local string; /* string */
|
local string; /* string */
|
||||||
local com; /* complex value */
|
local com; /* complex value */
|
||||||
|
local rndint; /* a random integer */
|
||||||
|
local rndexp; /* a random exponent */
|
||||||
|
local rndval; /* rndint ^ rndexp */
|
||||||
|
local i; /* integer value */
|
||||||
|
local ok; /* 1 ==> issq() tests were OK, 0 ==> failure */
|
||||||
|
|
||||||
print '5900: Beginning test_is';
|
print '5900: Beginning test_is';
|
||||||
|
|
||||||
@@ -5246,8 +5413,8 @@ define test_is()
|
|||||||
print '5911: odd = 23209';
|
print '5911: odd = 23209';
|
||||||
even = odd*10;
|
even = odd*10;
|
||||||
print '5912: even = odd*10';
|
print '5912: even = odd*10';
|
||||||
hash = sha();
|
hash = sha1();
|
||||||
print '5913: hash = sha()';
|
print '5913: hash = sha1()';
|
||||||
mat id[3,3] = {1,0,0,0,1,0,0,0,1};
|
mat id[3,3] = {1,0,0,0,1,0,0,0,1};
|
||||||
print '5914: id[3,3] = {1,0,0,0,1,0,0,0,1}';
|
print '5914: id[3,3] = {1,0,0,0,1,0,0,0,1}';
|
||||||
list = list(2,3,4);
|
list = list(2,3,4);
|
||||||
@@ -5570,7 +5737,7 @@ define test_is()
|
|||||||
vrfy(ishash(nerr) == 0, '6178: ishash(nerr) == 0');
|
vrfy(ishash(nerr) == 0, '6178: ishash(nerr) == 0');
|
||||||
vrfy(ishash(odd) == 0, '6179: ishash(odd) == 0');
|
vrfy(ishash(odd) == 0, '6179: ishash(odd) == 0');
|
||||||
vrfy(ishash(even) == 0, '6180: ishash(even) == 0');
|
vrfy(ishash(even) == 0, '6180: ishash(even) == 0');
|
||||||
vrfy(ishash(hash) == 1, '6181: ishash(hash) == 1');
|
vrfy(ishash(hash) == 2, '6181: ishash(hash) == 2');
|
||||||
vrfy(ishash(id) == 0, '6182: ishash(id) == 0');
|
vrfy(ishash(id) == 0, '6182: ishash(id) == 0');
|
||||||
vrfy(ishash(list) == 0, '6183: ishash(list) == 0');
|
vrfy(ishash(list) == 0, '6183: ishash(list) == 0');
|
||||||
vrfy(ishash(matrix) == 0, '6184: ishash(matrix) == 0');
|
vrfy(ishash(matrix) == 0, '6184: ishash(matrix) == 0');
|
||||||
@@ -6146,15 +6313,75 @@ define test_is()
|
|||||||
vrfy(istype(matrix,odd) == 0, '6661: istype(matrix,odd) == 0');
|
vrfy(istype(matrix,odd) == 0, '6661: istype(matrix,odd) == 0');
|
||||||
vrfy(istype(a,odd) == 0, '6662: istype(a,odd) == 0');
|
vrfy(istype(a,odd) == 0, '6662: istype(a,odd) == 0');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* perform more extensive issq() testing
|
||||||
|
*/
|
||||||
|
ok = 1;
|
||||||
|
for (i=0; i < 256; ++i) {
|
||||||
|
/* rndval will be a square - even powers>0 of x>1 */
|
||||||
|
rndexp = random(1, 16) * 2;
|
||||||
|
rndint = random(2, 4294967296);
|
||||||
|
if (issq(rndint)) {
|
||||||
|
++rndint;
|
||||||
|
}
|
||||||
|
rndval = rndint ^ rndexp;
|
||||||
|
if (issq(rndval) == 0) {
|
||||||
|
prob(strprintf("issq(%d^%d) returned 0",
|
||||||
|
rndint, rndexp));
|
||||||
|
ok = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
print '6663: issq() on 256 squares';
|
||||||
|
} else {
|
||||||
|
print '****: failure(s): 6663: faiissq() on 256 squares';
|
||||||
|
}
|
||||||
|
for (i=0; i < 256; ++i) {
|
||||||
|
/* rndval will not be a square - 1 + even powers>0 of x>1 */
|
||||||
|
rndexp = random(1, 16) * 2;
|
||||||
|
rndint = random(2, 4294967296);
|
||||||
|
rndval = rndint ^ rndexp;
|
||||||
|
if (issq(rndval+1) != 0) {
|
||||||
|
prob(strprintf("issq(%d^%d)+1 returned non-zero",
|
||||||
|
rndint, rndexp));
|
||||||
|
ok = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
print '6664: issq() on 256 squares+1';
|
||||||
|
} else {
|
||||||
|
print '****: failure(s): 6664: issq() on 256 squares+1';
|
||||||
|
}
|
||||||
|
print '6664: issq() on 256 squares+1';
|
||||||
|
for (i=0; i < 256; ++i) {
|
||||||
|
/* rndval will not be a square - odd powers>0 of x>1 */
|
||||||
|
rndexp = (random(1, 16) * 2) + 1;
|
||||||
|
rndint = random(2, 4294967296);
|
||||||
|
if (issq(rndint)) {
|
||||||
|
++rndint;
|
||||||
|
}
|
||||||
|
rndval = rndint ^ rndexp;
|
||||||
|
if (issq(rndval) != 0) {
|
||||||
|
prob(strprintf("issq(%d^%d) returned non-zero",
|
||||||
|
rndint, rndexp));
|
||||||
|
ok = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
print '6665: issq() on 256 non-squares';
|
||||||
|
} else {
|
||||||
|
print '****: failure(s): 6665: issq() on 256 non-squares';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cleanup
|
* cleanup
|
||||||
*/
|
*/
|
||||||
blkfree("blk5900");
|
blkfree("blk5900");
|
||||||
print '6663: blkfree("blk5900")';
|
print '6666: blkfree("blk5900")';
|
||||||
fclose(ofd);
|
fclose(ofd);
|
||||||
print '6664: fclose(ofd)';
|
print '6667: fclose(ofd)';
|
||||||
|
|
||||||
print '6665: Ending test_is';
|
print '6668: Ending test_is';
|
||||||
}
|
}
|
||||||
print '168: test_is()';
|
print '168: test_is()';
|
||||||
|
|
||||||
@@ -6603,108 +6830,6 @@ define test_blkprintf()
|
|||||||
print '172: parsed test_blkprintf()';
|
print '172: parsed test_blkprintf()';
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* test_sha - test the sha hash
|
|
||||||
*/
|
|
||||||
define test_sha()
|
|
||||||
{
|
|
||||||
local a, b, c, d, e, f, x, y, z, L, M, B1, B2, B;
|
|
||||||
|
|
||||||
print '7100: Beginning test_sha';
|
|
||||||
y = sha();
|
|
||||||
print '7101: y = sha();';
|
|
||||||
z = sha();
|
|
||||||
print '7102: z = sha();';
|
|
||||||
vrfy(y == z, '7103: y == z');
|
|
||||||
vrfy(sha("") == y, '7104: sha("") == y');
|
|
||||||
y = sha(y,1);
|
|
||||||
print '7105: y = sha(y,1);';
|
|
||||||
vrfy(y == sha(1), '7106: y == sha(1)');
|
|
||||||
vrfy(sha(y,2) == sha(1,2), '7107: sha(y,2) == sha(1,2)');
|
|
||||||
|
|
||||||
vrfy(sha(sha()) == 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef,
|
|
||||||
'7108: sha(sha()) == 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef');
|
|
||||||
|
|
||||||
vrfy(sha(sha("a"))==0x37f297772fae4cb1ba39b6cf9cf0381180bd62f2,
|
|
||||||
'7109: sha(sha("a"))==0x37f297772fae4cb1ba39b6cf9cf0381180bd62f2');
|
|
||||||
|
|
||||||
vrfy(sha(sha("ab"))==0x488373d362684af3d3f7a6a408b59dfe85419e09,
|
|
||||||
'7110: sha(sha("ab"))==0x488373d362684af3d3f7a6a408b59dfe85419e09');
|
|
||||||
vrfy(sha(sha("abc"))==0x0164b8a914cd2a5e74c4f7ff082c4d97f1edf880,
|
|
||||||
'7111: sha(sha("abc"))==0x0164b8a914cd2a5e74c4f7ff082c4d97f1edf880');
|
|
||||||
vrfy(sha(sha("abcd"))==0x082c73b06f71185d840fb4b28eb3abade67714bc,
|
|
||||||
'7112: sha(sha("abcd"))==0x082c73b06f71185d840fb4b28eb3abade67714bc');
|
|
||||||
vrfy(sha(sha("abcde"))==0xd624e34951bb800f0acae773001df8cffe781ba8,
|
|
||||||
'7113: sha(sha("abcde"))==0xd624e34951bb800f0acae773001df8cffe781ba8');
|
|
||||||
vrfy(sha(sha("abcdef"))==0x2a589f7750598dc0ea0a608719e04327f609279a,
|
|
||||||
'7114: sha(sha("abcdef"))==0x2a589f7750598dc0ea0a608719e04327f609279a');
|
|
||||||
vrfy(sha(sha("abcdefg"))==0x5bdf01f9298e9d19d3f8d15520fd74eed600b497,
|
|
||||||
'7115: sha(sha("abcdefg"))==0x5bdf01f9298e9d19d3f8d15520fd74eed600b497');
|
|
||||||
vrfy(sha(sha("abcdefgh"))==0x734ba8b31975d0dbae4d6e249f4e8da270796c94,
|
|
||||||
'7116: sha(sha("abcdefgh"))==0x734ba8b31975d0dbae4d6e249f4e8da270796c94');
|
|
||||||
|
|
||||||
vrfy(sha(sha(1)) == 0x864c8d09e828c7c31d62693736a5a9302c282777,
|
|
||||||
'7117: sha(sha(1)) == 0x864c8d09e828c7c31d62693736a5a9302c282777');
|
|
||||||
|
|
||||||
vrfy(sha(sha(2)) == 0x2c0b59c512cb20fad6bb0883b69c9f5a46545808,
|
|
||||||
'7118: sha(sha(2)) == 0x2c0b59c512cb20fad6bb0883b69c9f5a46545808');
|
|
||||||
|
|
||||||
vrfy(sha(sha(22/7))==0x7ddb7f8a7e9d70757f157744fddea7a6c6a6bcc6,
|
|
||||||
'7119: sha(sha(22/7)==0x7ddb7f8a7e9d70757f157744fddea7a6c6a6bcc6');
|
|
||||||
vrfy(sha(sha(isqrt(2e1000))) ==
|
|
||||||
0x6db8d9cf0b018b8f9cbbf5aa1edb8066d19e1bb0,
|
|
||||||
'7120: sha(sha(isqrt(2e1000)==0x6db8d9cf0b018b8f9cbbf5aa1edb8066d19e1bb0');
|
|
||||||
vrfy(sha("x", "y", "z") == sha("xyz"),
|
|
||||||
'7121: sha("x", "y", "z") == sha("xyz")');
|
|
||||||
|
|
||||||
vrfy(sha(sha("this is", 7^19-8, "a composit", 3i+4.5, "hash")) ==
|
|
||||||
0x21e42319a26787046c2b28b7ae70f1b54bf0ba2a,
|
|
||||||
'7122: sha(sha("this is", 7^19-8, ..., "hash")) == 0x21e4...');
|
|
||||||
|
|
||||||
z = sha(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));
|
|
||||||
print '7123: z = sha(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));';
|
|
||||||
vrfy(sha(z) == 257075527903934749824451356785709876382198951165,
|
|
||||||
'7124: sha(z) == 257075527903934749824451356785709876382198951165');
|
|
||||||
|
|
||||||
y = sha();
|
|
||||||
print '7125: y = sha()';
|
|
||||||
y = sha(y, list(1,2,3), "curds and whey");
|
|
||||||
print '7126: y = sha(y, list(1,2,3), "curds and whey")';
|
|
||||||
y = sha(y, 2^21701-1);
|
|
||||||
print '7127: y = sha(y, 2^21701-1)';
|
|
||||||
y = sha(y, pi(1e-100));
|
|
||||||
print '7128: y = sha(y, pi(1e-100))';
|
|
||||||
vrfy(y == z, '7129: y == z');
|
|
||||||
|
|
||||||
B = blk() = {"a", "b", "c"};
|
|
||||||
print '7130: B = blk() = {"a", "b", "c"};';
|
|
||||||
vrfy(sha(B) == sha("abc"), '7131: sha(B) == sha("abc")');
|
|
||||||
|
|
||||||
B1 = blk() = {1,2,3,4};
|
|
||||||
print '7132: B1 = blk() = {1,2,3,4};';
|
|
||||||
B2 = blk() = {5,6,7,8};
|
|
||||||
print '7133: B2 = blk() = {5,6,7,8};';
|
|
||||||
B = blk() = {1,2,3,4,5,6,7,8};
|
|
||||||
print '7134: B = blk() = {1,2,3,4,5,6,7,8};';
|
|
||||||
|
|
||||||
vrfy(sha(B1, B2) == sha(B), '7135: sha(B1, B2) == sha(B)');
|
|
||||||
vrfy(sha(B[1], B[3], B[5]) == sha("\02\04\06"),
|
|
||||||
'7136: sha(B[1], B[3], B[5]) == sha("\02\04\06")');
|
|
||||||
|
|
||||||
L = list(1,2,3);
|
|
||||||
print '7137: L = list(1,2,3)';
|
|
||||||
mat M[3] = {4,5,6};
|
|
||||||
print '7138: mat M[3] = {4,5,6}';
|
|
||||||
vrfy(sha(sha(L), M, B) == sha(L, M, B),
|
|
||||||
'7139: sha(sha(L), M, B) == sha(L, M, B)');
|
|
||||||
vrfy(sha(sha(L,M), B) == sha(L, M, B),
|
|
||||||
'7140: sha(sha(L, M), B) == sha(L, M, B)');
|
|
||||||
|
|
||||||
print '7141: Ending test_sha';
|
|
||||||
}
|
|
||||||
print '173: parsed test_sha()';
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test_sha1 - test the sha1 hash
|
* test_sha1 - test the sha1 hash
|
||||||
*/
|
*/
|
||||||
@@ -6790,88 +6915,6 @@ define test_sha1()
|
|||||||
print '174: parsed test_sha1()';
|
print '174: parsed test_sha1()';
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* test_md5 - test the md5 hash
|
|
||||||
*/
|
|
||||||
define test_md5()
|
|
||||||
{
|
|
||||||
local a, b, c, d, e, f, x, y, z, L, M, B;
|
|
||||||
|
|
||||||
print '7300: Beginning test_md5';
|
|
||||||
y = md5();
|
|
||||||
print '7301: y = md5();';
|
|
||||||
z = md5();
|
|
||||||
print '7302: z = md5();';
|
|
||||||
vrfy(y == z, '7303: y == z');
|
|
||||||
y = md5(y,1);
|
|
||||||
print '7304: y = md5(y,1);';
|
|
||||||
z = md5(1);
|
|
||||||
print '7305: z = md5(1);';
|
|
||||||
vrfy(y == z, '7306: y == z');
|
|
||||||
vrfy(md5(z,2) == md5(1,2), '7307: md5(z,2) == md5(1,2)');
|
|
||||||
|
|
||||||
vrfy(md5(md5()) == 0xd41d8cd98f00b204e9800998ecf8427e,
|
|
||||||
'7308: md5(md5()) == 0xd41d8cd98f00b204e9800998ecf8427e');
|
|
||||||
vrfy(md5("x", "y", "z") == md5("xyz"),
|
|
||||||
'7309: md5("x", "y", "z") == md5("xyz")');
|
|
||||||
|
|
||||||
vrfy(md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) ==
|
|
||||||
0x39a5a8e24a2eb65a51af462c8bdd5e3,
|
|
||||||
'7310: md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == ...');
|
|
||||||
|
|
||||||
|
|
||||||
z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));
|
|
||||||
print '7311: z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi(1e-100));';
|
|
||||||
vrfy(md5(z) == 0x487462e577eabef0302dd13af6632546,
|
|
||||||
'7312: md5(z) == 0x487462e577eabef0302dd13af6632546');
|
|
||||||
y = md5();
|
|
||||||
print '7313: y = md5();';
|
|
||||||
y = md5(y, list(1,2,3), "curds and whey");
|
|
||||||
print '7314: y = md5(y, list(1,2,3), "curds and whey")';
|
|
||||||
y = md5(y, 2^21701-1);
|
|
||||||
print '7315: y = md5(y, 2^21701-1);';
|
|
||||||
y = md5(y, pi(1e-100));
|
|
||||||
print '7316: y = md5(y, pi(1e-100));';
|
|
||||||
vrfy(y == z, '7317: y == z');
|
|
||||||
|
|
||||||
vrfy(md5(md5("a")) == 0x0cc175b9c0f1b6a831c399e269772661,
|
|
||||||
'7318: md5(md5("a")) == 0x0cc175b9c0f1b6a831c399e269772661');
|
|
||||||
vrfy(md5(md5("ab")) == 0x187ef4436122d1cc2f40dc2b92f0eba0,
|
|
||||||
'7319: md5(md5("ab")) == 0x187ef4436122d1cc2f40dc2b92f0eba0');
|
|
||||||
vrfy(md5(md5("abc")) == 0x900150983cd24fb0d6963f7d28e17f72,
|
|
||||||
'7320: md5(md5("abc")) == 0x900150983cd24fb0d6963f7d28e17f72');
|
|
||||||
vrfy(md5(md5("abcd")) == 0xe2fc714c4727ee9395f324cd2e7f331f,
|
|
||||||
'7321: md5(md5("abcd")) == 0xe2fc714c4727ee9395f324cd2e7f331f');
|
|
||||||
vrfy(md5(md5("abcde")) == 0xab56b4d92b40713acc5af89985d4b786,
|
|
||||||
'7322: md5(md5("abcde")) == 0xab56b4d92b40713acc5af89985d4b786');
|
|
||||||
vrfy(md5(md5("abcdef")) == 0xe80b5017098950fc58aad83c8c14978e,
|
|
||||||
'7323: md5(md5("abcdef")) == 0xe80b5017098950fc58aad83c8c14978e');
|
|
||||||
vrfy(md5(md5("abcdefg")) == 0x7ac66c0f148de9519b8bd264312c4d64,
|
|
||||||
'7324: md5(md5("abcdefg")) == 0x7ac66c0f148de9519b8bd264312c4d64');
|
|
||||||
vrfy(md5(md5("abcdefgh")) == 0xe8dc4081b13434b45189a720b77b6818,
|
|
||||||
'7325: md5(md5("abcdefgh")) == 0xe8dc4081b13434b45189a720b77b6818');
|
|
||||||
vrfy(md5(md5(1)) == 0x44fe7987067ac45311c88772038f60d1,
|
|
||||||
'7326: md5(md5(1)) == 0x44fe7987067ac45311c88772038f60d1');
|
|
||||||
vrfy(md5(md5(22/7)) == 0x9274b951e1dfb9cba22af1c127daa8e7,
|
|
||||||
'7327: md5(md5(22/7) == 0x9274b951e1dfb9cba22af1c127daa8e7');
|
|
||||||
vrfy(md5(md5(isqrt(2e1000))) == 0xe56ac4b8cad869e738a04fedc97058f3,
|
|
||||||
'7328: md5(md5(isqrt(2e1000))) == 0xe56ac4b8cad869e738a04fedc97058f3');
|
|
||||||
L = list(1,2,3);
|
|
||||||
print '7329: L = list(1,2,3)';
|
|
||||||
mat M[3] = {4,5,6};
|
|
||||||
print '7330: mat M[3] = {4,5,6}';
|
|
||||||
B = blk() = {7,8,9};
|
|
||||||
print '7331: B = blk() = {7,8,9}';
|
|
||||||
vrfy(md5(md5(L), M, B) == md5(L, M, B),
|
|
||||||
'7332: md5(md5(L), M, B) == md5(L, M, B)');
|
|
||||||
vrfy(md5(md5(L,M), B) == md5(L, M, B),
|
|
||||||
'7333: md5(md5(L, M), B) == md5(L, M, B)');
|
|
||||||
|
|
||||||
print '7334: Ending test_md5';
|
|
||||||
}
|
|
||||||
print '175: parsed test_md5()';
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The 7400's contain tests for saveval and dot. These tests are
|
* The 7400's contain tests for saveval and dot. These tests are
|
||||||
* done inline near the bottom.
|
* done inline near the bottom.
|
||||||
@@ -7404,6 +7447,85 @@ define test_somenew()
|
|||||||
print '190: parsed test_somenew()';
|
print '190: parsed test_somenew()';
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* test_exponentiation - test new exponentiation functionaltiy
|
||||||
|
*/
|
||||||
|
define test_exponentiation()
|
||||||
|
{
|
||||||
|
local a;
|
||||||
|
|
||||||
|
print '8800: Starting test_somenew';
|
||||||
|
|
||||||
|
/* unexpected help file cases */
|
||||||
|
vrfy(2^3 == 8, '8801: 2^3 == 8');
|
||||||
|
vrfy(2.5 ^ 3.5 == power(2.5, 3.5),
|
||||||
|
'8802: 2.5 ^ 3.5 == power(2.5, 3.5)');
|
||||||
|
vrfy(2.5 ^ 2.718i == power(2.5, 2.718i),
|
||||||
|
'8803: 2.5 ^ 2.718i == power(2.5, 2.718i)');
|
||||||
|
vrfy(3i^4 == 81, '8804: 3i^4 == 81');
|
||||||
|
vrfy(0.5i ^ 0.25 == power(0.5i, 0.25),
|
||||||
|
'8804: 0.5i ^ 0.25 == power(0.5i, 0.25)');
|
||||||
|
vrfy(3.13145i^0.30103i == power(3.13145i, 0.30103i),
|
||||||
|
'8806: 3.13145i^0.30103i == power(3.13145i, 0.30103i)');
|
||||||
|
|
||||||
|
/* deal with some corner error cases */
|
||||||
|
ecnt += 12;
|
||||||
|
print '8807: ecnt += 2';
|
||||||
|
vrfy((1/0) ^ -1 == 0, '8808: (1/0) ^ -1 == 0');
|
||||||
|
vrfy((1/0) ^ -2 == 0, '8809: (1/0) ^ -2 == 0');
|
||||||
|
vrfy((1/0) ^ 0 == error(10001), '8810: (1/0) ^ 0 == error(10001)');
|
||||||
|
vrfy((1/0) ^ 3 == error(10001), '8811: (1/0) ^ 3 == error(10001)');
|
||||||
|
vrfy(0 ^ -2 == error(10001), '8812: 0 ^ -2 == error(10001)');
|
||||||
|
vrfy((1/0) ^ 1i == error(10001),'8813: (1/0) ^ 1i == error(10001)');
|
||||||
|
vrfy((1/0) ^ 0i == error(10001),'8814: (1/0) ^ 0i == error(10001)');
|
||||||
|
|
||||||
|
/* real ^ real */
|
||||||
|
vrfy(5^6 == 15625, '8815: 5^6 == 15625');
|
||||||
|
vrfy(10^31 == 1e31, '8816: 10^31 == 1e31');
|
||||||
|
vrfy(10 ^ (127/31) == power(10, 127/31),
|
||||||
|
'8817: 10 ^ (127/31) == power(10, 127/31)');
|
||||||
|
vrfy((10^31) ^ 10 == 1e310, '8818: (10^31) ^ 10 == 1e310');
|
||||||
|
|
||||||
|
/* complex ^ real */
|
||||||
|
vrfy(10i ^ 10 == -1e10, '8819: 10i ^ 10 == -1e10');
|
||||||
|
vrfy((-10i) ^ 10 == -1e10, '8820: (-10i) ^ 10 == -1e10');
|
||||||
|
vrfy((1+1i) ^ 4 == -4, '8821: (1+1i) ^ 4 == -4');
|
||||||
|
vrfy((1+1i) ^ 65536 == 2^32768, '8822: (1+1i) ^ 65536 == 2^32768');
|
||||||
|
vrfy((1+1i) ^ (2^20) == 2^(2^19),
|
||||||
|
'8823: (1+1i) ^ (2^20) == 2^(2^19)');
|
||||||
|
vrfy((31+17i) ^ pi() == power(31+17i, pi()),
|
||||||
|
'8824: (31+17i) ^ pi() == power(31+17i, pi()');
|
||||||
|
vrfy((5+7i) ^ exp(5) == power(5+7i, exp(5)),
|
||||||
|
'8825: (5+7i) ^ exp(5) == power(5+7i, exp(5))');
|
||||||
|
|
||||||
|
/* real ^ complex */
|
||||||
|
vrfy(10 ^ 1i == power(10, 1i), '8826: 10 ^ 1i == power(10, 1i)');
|
||||||
|
vrfy(10 ^ (2+3i) == power(10, 2+3i),
|
||||||
|
'8827: 10 ^ (2+3i) == power(10, 2+3i)');
|
||||||
|
vrfy(pi() ^ (2+3i) == power(pi(), 2+3i),
|
||||||
|
'8828: pi() ^ (2+3i) == power(pi(), 2+3i)');
|
||||||
|
vrfy(exp(64) ^ (2+3i) == power(exp(64), 2+3i),
|
||||||
|
'8828: exp(64) ^ (2+3i) == power(exp(64), 2+3i)');
|
||||||
|
vrfy(pi() ^ (257+127i) == power(pi(), 257+127i),
|
||||||
|
'8829: pi() ^ (257+127i) == power(pi(), 257+127i)');
|
||||||
|
vrfy(pi() ^ asin(-2) == power(pi(), asin(-2)),
|
||||||
|
'8830: pi() ^ asin(-2) == power(pi(), asin(-2)');
|
||||||
|
|
||||||
|
/* complex ^ complex */
|
||||||
|
vrfy((3+4i) ^ (2+3i) == power(3+4i, 2+3i),
|
||||||
|
'8831: (3+4i) ^ (2+3i) == power(3+4i, 2+3i)');
|
||||||
|
vrfy(ln(-10) ^ (2+3i) == power(ln(-10), 2+3i),
|
||||||
|
'8832: ln(-10) ^ (2+3i) == power(ln(-10), 2+3i)');
|
||||||
|
vrfy((pi()*1i) ^ asin(-2) == power(pi()*1i, asin(-2)),
|
||||||
|
'8833: (pi()*1i) ^ asin(-2) == power(pi()*1i, asin(-2))');
|
||||||
|
vrfy((exp(1)+pi()*1i) ^ asin(-2) == power(exp(1)+pi()*1i, asin(-2)),
|
||||||
|
'8834: (exp(1)+pi()*1i) ^ asin(-2) == power(exp(1)+pi()*1i, asin(-2))');
|
||||||
|
|
||||||
|
print '8835: Ending test_somenew';
|
||||||
|
}
|
||||||
|
print '191: parsed test_exponentiation()';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test_quit - test the QUIT functionality
|
* test_quit - test the QUIT functionality
|
||||||
*/
|
*/
|
||||||
@@ -7631,12 +7753,8 @@ return test_name();
|
|||||||
print;
|
print;
|
||||||
return test_blkprintf();
|
return test_blkprintf();
|
||||||
print;
|
print;
|
||||||
return test_sha();
|
|
||||||
print;
|
|
||||||
return test_sha1();
|
return test_sha1();
|
||||||
print;
|
print;
|
||||||
return test_md5();
|
|
||||||
print;
|
|
||||||
|
|
||||||
print '7400: Beginning test_savedot';
|
print '7400: Beginning test_savedot';
|
||||||
print '7401: saveval(1);';
|
print '7401: saveval(1);';
|
||||||
@@ -7736,7 +7854,27 @@ read -once "test8500";
|
|||||||
print;
|
print;
|
||||||
print '8600: Starting test of up to 1024 args'
|
print '8600: Starting test of up to 1024 args'
|
||||||
read -once "test8600";
|
read -once "test8600";
|
||||||
/* 86xx: Ending test of up to 1024 args is printed by test8600.cal */
|
/* 860x: Ending test of up to 1024 args is printed by test8600.cal */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* dupvar_warn and redecl_warn testing
|
||||||
|
*/
|
||||||
|
print;
|
||||||
|
print '8650: Starting test of dupvar_warn and redecl_warn config parameters';
|
||||||
|
vrfy(config("redecl_warn",0), '8651: config("redecl_warn",0)');
|
||||||
|
vrfy(config("dupvar_warn",0), '8652: config("dupvar_warn",0)');
|
||||||
|
vrfy(u_glob == 6, '8653: u_glob == 6');
|
||||||
|
global u_glob = 555;
|
||||||
|
print '8654: reclare u_glob';
|
||||||
|
vrfy(u_glob == 555, '8655: u_glob == 555');
|
||||||
|
define func_8650(u_glob) { local u_glob; return u_glob; }
|
||||||
|
print '8656: u_glob as both local and parameter';
|
||||||
|
define func_8650a(u_glob) { static u_glob; return u_glob; }
|
||||||
|
print '8657: u_glob as both static and parameter';
|
||||||
|
vrfy(config("redecl_warn",1)==0, '8658: config("redecl_warn",1)==0');
|
||||||
|
vrfy(config("dupvar_warn",1)==0, '8659: config("dupvar_warn",1)==0');
|
||||||
|
/* 865x: Ending test of up to 1024 args is printed by test8600.cal */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -7744,6 +7882,7 @@ read -once "test8600";
|
|||||||
*
|
*
|
||||||
* We use the dotest driver to evaluate test-97xx data files.
|
* We use the dotest driver to evaluate test-97xx data files.
|
||||||
*/
|
*/
|
||||||
|
print;
|
||||||
print '8700: Starting dotest runs'
|
print '8700: Starting dotest runs'
|
||||||
print '8701: read -once "dotest"';
|
print '8701: read -once "dotest"';
|
||||||
read -once "dotest";
|
read -once "dotest";
|
||||||
@@ -7753,6 +7892,15 @@ vrfy(dotest("set8700.line", 8703) == 0,
|
|||||||
'8703: dotest("set8700.line", 8703) == 0');
|
'8703: dotest("set8700.line", 8703) == 0');
|
||||||
/* 87xx: Ending dotest runs is printed by set8700.test */
|
/* 87xx: Ending dotest runs is printed by set8700.test */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* new exponentiation functionaltiy
|
||||||
|
*/
|
||||||
|
print;
|
||||||
|
return test_exponentiation();
|
||||||
|
/* 88xx: test exponentiation */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read various calc resource files
|
* read various calc resource files
|
||||||
*
|
*
|
||||||
@@ -7830,7 +7978,28 @@ read -once varargs;
|
|||||||
print '9827: read -once varargs';
|
print '9827: read -once varargs';
|
||||||
read -once qtime;
|
read -once qtime;
|
||||||
print '9828: read -once qtime';
|
print '9828: read -once qtime';
|
||||||
print '9829: Ending read of selected calc resource files';
|
read -once chi;
|
||||||
|
print '9829: read -once chi';
|
||||||
|
read -once intfile;
|
||||||
|
print '9830: read -once intfile';
|
||||||
|
read -once lucas;
|
||||||
|
print '9831: read -once lucas';
|
||||||
|
read -once lucas_tbl;
|
||||||
|
print '9832: read -once lucas_tbl';
|
||||||
|
read -once natnumset;
|
||||||
|
print '9833: read -once natnumset';
|
||||||
|
read -once repeat;
|
||||||
|
print '9834: read -once repeat';
|
||||||
|
read -once screen;
|
||||||
|
print '9835: read -once screen';
|
||||||
|
read -once linear;
|
||||||
|
print '9836: read -once linear';
|
||||||
|
print '9837: skipping read -once beer.cal because it is an infinite loop';
|
||||||
|
print '9838: skipping read -once hello.cal because it is an infinite loop';
|
||||||
|
print '9839: skipping read -once xx_print.cal because it is a printing demo';
|
||||||
|
read -once sumtimes;
|
||||||
|
print '9840: read -once sumtimes';
|
||||||
|
print '9841: Ending read of selected calc resource files';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.4 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: repeat.cal,v 29.4 2003/01/26 19:42:03 chongo Exp $
|
* @(#) $Id: repeat.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/repeat.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/repeat.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 2003/01/05 00:00:01
|
* Under source code control: 2003/01/05 00:00:01
|
||||||
|
@@ -15,8 +15,8 @@
|
|||||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.2 $
|
||||||
* @(#) $Id: screen.cal,v 29.2 2006/05/01 19:21:18 chongo Exp $
|
* @(#) $Id: screen.cal,v 30.2 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/screen.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/screen.cal,v $
|
||||||
*
|
*
|
||||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.3 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: seedrandom.cal,v 29.3 2001/03/31 13:31:34 chongo Exp $
|
* @(#) $Id: seedrandom.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/seedrandom.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/seedrandom.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1996/01/01 08:21:00
|
* Under source code control: 1996/01/01 08:21:00
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.1 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: set8700.cal,v 29.1 2006/05/20 19:35:33 chongo Exp $
|
* @(#) $Id: set8700.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 2006/05/20 14:10:11
|
* Under source code control: 2006/05/20 14:10:11
|
||||||
@@ -70,3 +70,8 @@ define set8700_g(set8700_x)
|
|||||||
obj set8700_point {
|
obj set8700_point {
|
||||||
set8700_x, set8700_y, set8700_z
|
set8700_x, set8700_y, set8700_z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global mat set8700_c[] = { 1, 2+3i, -5+4i, 5i+6, -7i };
|
||||||
|
|
||||||
|
global mat set8700_e[] = { 0, 1, 0, 0, 2, -3/2, 2, -1/2,
|
||||||
|
-3, 0.5, -1.0, 0.5, 1.0, 0.0, 0.0, 0.0 };
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
## 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
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.1 $
|
## @(#) $Revision: 30.1 $
|
||||||
## @(#) $Id: set8700.line,v 29.1 2006/05/20 19:35:33 chongo Exp $
|
## @(#) $Id: set8700.line,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.line,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.line,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 2006/05/20 14:10:11
|
## Under source code control: 2006/05/20 14:10:11
|
||||||
@@ -143,7 +143,7 @@ a #= 4, a == 1
|
|||||||
|
|
||||||
## Binary # operator not defined for strings
|
## Binary # operator not defined for strings
|
||||||
|
|
||||||
global set8700_A; protect(set8700_A) == 0
|
protect(set8700_A) == 0
|
||||||
## Testing with one lvalue
|
## Testing with one lvalue
|
||||||
isnull(protect(set8700_A,65))
|
isnull(protect(set8700_A,65))
|
||||||
protect(set8700_A) == 65
|
protect(set8700_A) == 65
|
||||||
@@ -302,7 +302,7 @@ protect(set8700_B,0), set8700_B = set8700_getA1(), protect(set8700_B) == 1024
|
|||||||
protect(set8700_B,0), set8700_B = set8700_getA2(), protect(set8700_B) == 1024
|
protect(set8700_B,0), set8700_B = set8700_getA2(), protect(set8700_B) == 1024
|
||||||
set8700_B = set8700_getvar(), protect(set8700_B) == 1024 + 256
|
set8700_B = set8700_getvar(), protect(set8700_B) == 1024 + 256
|
||||||
|
|
||||||
global set8700_x, set8700_y; set8700_x = 7, protect(set8700_x) == 0
|
set8700_x = 7, protect(set8700_x) == 0
|
||||||
protect(7,2) == error(10234)
|
protect(7,2) == error(10234)
|
||||||
protect(set8700_x,2.5) == error(10235)
|
protect(set8700_x,2.5) == error(10235)
|
||||||
protect(set8700_x,"abc") == error(10235)
|
protect(set8700_x,"abc") == error(10235)
|
||||||
@@ -322,7 +322,6 @@ set8700_x++ == error(10385)
|
|||||||
set8700_x == 7
|
set8700_x == 7
|
||||||
set8700_x-- == error(10388)
|
set8700_x-- == error(10388)
|
||||||
|
|
||||||
global set8700_A, set8700_B; 1
|
|
||||||
protect(set8700_A,0), protect(set8700_A,16), 1
|
protect(set8700_A,0), protect(set8700_A,16), 1
|
||||||
set8700_A = "abcdef", protect(set8700_A) == 16 ## No copy to set8700_A
|
set8700_A = "abcdef", protect(set8700_A) == 16 ## No copy to set8700_A
|
||||||
protect(set8700_B,0), set8700_B = "xyz", protect(set8700_B) == 0
|
protect(set8700_B,0), set8700_B = "xyz", protect(set8700_B) == 0
|
||||||
@@ -403,3 +402,28 @@ set8700_P == (obj set8700_point = {1,2,3})
|
|||||||
set8700_L = list(mat[1] = {set8700_P}), protect(set8700_L[0][0]) == 16
|
set8700_L = list(mat[1] = {set8700_P}), protect(set8700_L[0][0]) == 16
|
||||||
set8700_L = {{{4,5,6}}}, set8700_L[0][0] == set8700_P
|
set8700_L = {{{4,5,6}}}, set8700_L[0][0] == set8700_P
|
||||||
protect(set8700_L,0,2), set8700_L = {{{4,5,6}}}, set8700_L[0][0] == (obj set8700_point = {4,5,6})
|
protect(set8700_L,0,2), set8700_L = {{{4,5,6}}}, set8700_L[0][0] == (obj set8700_point = {4,5,6})
|
||||||
|
|
||||||
|
## Testing quomod
|
||||||
|
quomod(14,5,3,4) == error(10374)
|
||||||
|
global set8700_a,set8700_b; quomod("abc", 4, set8700_a, set8700_b) == error(10375)
|
||||||
|
quomod(14,5,set8700_a,set8700_b,0) == 1 && set8700_a == 2 && set8700_b == 4
|
||||||
|
quomod(14,5,set8700_a,set8700_b,1) == 1 && set8700_a == 3 && set8700_b == -1
|
||||||
|
quomod("abc",2,set8700_a,set8700_b) == error(10375)
|
||||||
|
set8700_a = "abc"; quomod(14,5,set8700_a,set8700_b) == error(10375)
|
||||||
|
set8700_a = null(); quomod(14,5,set8700_a,set8700_b,24) == 1; set8700_a == 3 && set8700_b == -1
|
||||||
|
quomod(14,5,set8700_a,set8700_a) == error(10374)
|
||||||
|
quomod(14,5,set8700_a,set8700_b,-1) == error(10375)
|
||||||
|
protect(set8700_a,1); quomod(17,2,set8700_a,set8700_b) == error(10376)
|
||||||
|
protect(set8700_a,0); quomod(17,2,set8700_a,set8700_b); set8700_a == 8 && set8700_b == 1
|
||||||
|
set8700_p = &set8700_a, set8700_q = &set8700_b; quomod(14,5,*set8700_p,*set8700_q); *set8700_p == 2 && *set8700_q == 4
|
||||||
|
|
||||||
|
## Testing estr
|
||||||
|
base(1/3) == 10
|
||||||
|
strcmp(estr(null()), "\"\"") == 0
|
||||||
|
strcmp(estr(bernoulli(48)), "-5609403368997817686249127547/46410") == 0
|
||||||
|
strcmp(estr(sin(3i)), "1001787492740990189897i/100000000000000000000") == 0
|
||||||
|
base(10) == 1/3
|
||||||
|
strcmp(estr("fizzbin"), "\"fizzbin\"") == 0
|
||||||
|
strcmp(estr(set8700_c), "mat[5]={1,2+3i,-5+4i,6+5i,-7i}") == 0
|
||||||
|
strcmp(estr(set8700_e), "mat[16]={0,1,0,0,2,-3/2,2,-1/2,-3,1/2,-1,1/2,1,0,0,0}") == 0
|
||||||
|
strcmp(estr(list(2,3,5)), "list(2,3,5)") == 0
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: solve.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: solve.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/solve.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/solve.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:37
|
* Under source code control: 1990/02/15 01:50:37
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: sumsq.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: sumsq.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/sumsq.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/sumsq.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:37
|
* Under source code control: 1990/02/15 01:50:37
|
||||||
|
186
cal/sumtimes.cal
Normal file
186
cal/sumtimes.cal
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
/*
|
||||||
|
* sumtimes - runtimes evaluating sums & squares of large lists and mats
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Ernest Bowen
|
||||||
|
*
|
||||||
|
* Calc is open software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @(#) $Revision: 30.1 $
|
||||||
|
* @(#) $Id: sumtimes.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/sumtimes.cal,v $
|
||||||
|
*
|
||||||
|
* Under source code control: 2006/06/22 17:29
|
||||||
|
* File existed as early as: 2006
|
||||||
|
*
|
||||||
|
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
global sumtimes_t0, sumtimes_t1, sumtimes_t2, sumtimes_t3;
|
||||||
|
global sumtimes_A, sumtimes_B;
|
||||||
|
config("tilde", 0),;
|
||||||
|
|
||||||
|
define timematsum(N) {
|
||||||
|
local n, s, p, ptop;
|
||||||
|
|
||||||
|
sumtimes_A = mat[N];
|
||||||
|
|
||||||
|
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||||
|
|
||||||
|
ptop = &sumtimes_A[n-1];
|
||||||
|
sumtimes_t0 = usertime();
|
||||||
|
for (s = n = 0; n < N; n++) s += sumtimes_A[n];
|
||||||
|
sumtimes_t1 = usertime();
|
||||||
|
for (s = 0, p = &sumtimes_A[0]; p <= ptop; p++) s += *p;
|
||||||
|
sumtimes_t2 = usertime();
|
||||||
|
s = matsum(sumtimes_A);
|
||||||
|
sumtimes_t3 = usertime();
|
||||||
|
|
||||||
|
print "Matrix sum runtimes";
|
||||||
|
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||||
|
printf('\t"For" loop using pointers:\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
|
||||||
|
printf('\tUsing builtin "matsum":\t\t%.4f\n', sumtimes_t3 - sumtimes_t2);
|
||||||
|
}
|
||||||
|
|
||||||
|
define timelistsum(N) {
|
||||||
|
local n, s;
|
||||||
|
|
||||||
|
sumtimes_A = makelist(N);
|
||||||
|
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||||
|
|
||||||
|
sumtimes_t0 = usertime();
|
||||||
|
for (s = n = 0; n < N; n++) s += sumtimes_A[n];
|
||||||
|
sumtimes_t1 = usertime();
|
||||||
|
s = sum(sumtimes_A);
|
||||||
|
sumtimes_t2 = usertime();
|
||||||
|
print "List sum runtimes";
|
||||||
|
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||||
|
printf('\tUsing builtin "sum":\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
define timematsort(N) {
|
||||||
|
local n;
|
||||||
|
|
||||||
|
sumtimes_A = mat[N];
|
||||||
|
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||||
|
sumtimes_t0 = usertime();
|
||||||
|
sort(sumtimes_A);
|
||||||
|
sumtimes_t1 = usertime();
|
||||||
|
printf('\tMatrix sort runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
define timelistsort(N) {
|
||||||
|
local n;
|
||||||
|
|
||||||
|
sumtimes_A = makelist(N);
|
||||||
|
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||||
|
sumtimes_t0 = usertime();
|
||||||
|
sort(sumtimes_A);
|
||||||
|
sumtimes_t1 = usertime();
|
||||||
|
printf('\tList sort runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||||
|
}
|
||||||
|
|
||||||
|
define timematreverse(N) {
|
||||||
|
local n;
|
||||||
|
|
||||||
|
sumtimes_A = mat[N];
|
||||||
|
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||||
|
sumtimes_t0 = usertime();
|
||||||
|
reverse(sumtimes_A);
|
||||||
|
sumtimes_t1 = usertime();
|
||||||
|
printf('\tMatrix reverse runtime %.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||||
|
}
|
||||||
|
|
||||||
|
define timelistreverse(N) {
|
||||||
|
local n;
|
||||||
|
|
||||||
|
sumtimes_A = makelist(N);
|
||||||
|
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||||
|
sumtimes_t0 = usertime();
|
||||||
|
reverse(sumtimes_A);
|
||||||
|
sumtimes_t1 = usertime();
|
||||||
|
printf('\tList reverse runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||||
|
}
|
||||||
|
|
||||||
|
define timematssq(N) {
|
||||||
|
local n, s, p, ptop;
|
||||||
|
|
||||||
|
sumtimes_A = mat[N];
|
||||||
|
|
||||||
|
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||||
|
|
||||||
|
ptop = &sumtimes_A[n-1];
|
||||||
|
sumtimes_t0 = usertime();
|
||||||
|
for (s = n = 0; n < N; n++) s += sumtimes_A[n]^2;
|
||||||
|
sumtimes_t1 = usertime();
|
||||||
|
for (s = 0, p = &sumtimes_A[0]; p <= ptop; p++) s += (*p)^2;
|
||||||
|
sumtimes_t2 = usertime();
|
||||||
|
|
||||||
|
print "Matrix sum of squares runtimes";
|
||||||
|
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||||
|
printf('\t"For" loop using pointers:\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
|
||||||
|
}
|
||||||
|
|
||||||
|
define timelistssq(N) {
|
||||||
|
local n, s;
|
||||||
|
|
||||||
|
sumtimes_A = makelist(N);
|
||||||
|
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||||
|
|
||||||
|
sumtimes_t0 = usertime();
|
||||||
|
for (s = n = 0; n < N; n++) s += sumtimes_A[n]^2;
|
||||||
|
sumtimes_t1 = usertime();
|
||||||
|
s = ssq(sumtimes_A);
|
||||||
|
sumtimes_t2 = usertime();
|
||||||
|
print "List sum of squares runtimes";
|
||||||
|
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||||
|
printf('\tUsing builtin "ssq":\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
|
||||||
|
}
|
||||||
|
|
||||||
|
define timehmean(N, M = 10) {
|
||||||
|
local n, s, v1, v2;
|
||||||
|
|
||||||
|
sumtimes_A = makelist(N);
|
||||||
|
for (n = 0; n < N; n++) sumtimes_A[n] = rand(1, M);
|
||||||
|
|
||||||
|
sumtimes_t0 = usertime();
|
||||||
|
for (s = n = 0; n < N; n++) s += 1/sumtimes_A[n];
|
||||||
|
v1 = N/s;
|
||||||
|
sumtimes_t1 = usertime();
|
||||||
|
v2 = hmean(sumtimes_A);
|
||||||
|
sumtimes_t2 = usertime();
|
||||||
|
print v1, v2;
|
||||||
|
print "List harmonic meanruntimes";
|
||||||
|
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||||
|
printf('\tUsing builtin "hmean":\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
|
||||||
|
}
|
||||||
|
|
||||||
|
define doalltimes(N) {
|
||||||
|
timematsum(N);
|
||||||
|
print;
|
||||||
|
timelistsum(N);
|
||||||
|
print;
|
||||||
|
timematssq(N);
|
||||||
|
print;
|
||||||
|
timelistssq(N);
|
||||||
|
print;
|
||||||
|
timematsort(N);
|
||||||
|
timelistsort(N);
|
||||||
|
timematreverse(N);
|
||||||
|
timelistreverse(N);
|
||||||
|
print;
|
||||||
|
}
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: surd.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: surd.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/surd.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/surd.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:38
|
* Under source code control: 1990/02/15 01:50:38
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test1700.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test1700.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test1700.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test1700.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1994/03/14 23:12:51
|
* Under source code control: 1994/03/14 23:12:51
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test2300.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test2300.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2300.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2300.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/07/09 06:12:13
|
* Under source code control: 1995/07/09 06:12:13
|
||||||
|
103
cal/test2600.cal
103
cal/test2600.cal
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.2 $
|
||||||
* @(#) $Id: test2600.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test2600.cal,v 30.2 2007/07/11 22:57:23 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2600.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2600.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/10/13 00:13:14
|
* Under source code control: 1995/10/13 00:13:14
|
||||||
@@ -313,6 +313,102 @@ define testpower(str, n, b, eps, verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
define testpower2(str, n, eps, verbose)
|
||||||
|
{
|
||||||
|
local i, a, c, m, min, max;
|
||||||
|
local b;
|
||||||
|
local num;
|
||||||
|
local c2;
|
||||||
|
local oldeps;
|
||||||
|
|
||||||
|
if (isnull(verbose)) verbose = 2;
|
||||||
|
if (verbose > 0) {
|
||||||
|
print str:":",:;
|
||||||
|
}
|
||||||
|
if (isnull(eps))
|
||||||
|
eps = epsilon();
|
||||||
|
oldeps = epsilon(eps);
|
||||||
|
epsilon(eps),;
|
||||||
|
if (!isnum(b))
|
||||||
|
quit "Second argument (exponent) to be a number";
|
||||||
|
min = 1000;
|
||||||
|
max = -1000;
|
||||||
|
for (i = 1; i <= n; i++) {
|
||||||
|
if (verbose > 2) print i,:;
|
||||||
|
|
||||||
|
/* real ^ real */
|
||||||
|
a = rand(1,1e20);
|
||||||
|
a = a / (int(a/2)+rand(1,1e20));
|
||||||
|
b = rand(1,1e20);
|
||||||
|
b = b / (int(b/2)+rand(1,1e20));
|
||||||
|
c = a ^ b;
|
||||||
|
c2 = power(a, b);
|
||||||
|
if (c != c2) {
|
||||||
|
m++;
|
||||||
|
if (verbose > 1) {
|
||||||
|
printf("*** real^real failure for a = %d\n", a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* complex ^ real */
|
||||||
|
a = rand(1,1e20);
|
||||||
|
a = a / (int(a/2)+rand(1,1e20));
|
||||||
|
b = rand(1,1e20);
|
||||||
|
b = b / (int(b/2)+rand(1,1e20));
|
||||||
|
c = (a*1i) ^ b;
|
||||||
|
c2 = power(a*1i, b);
|
||||||
|
if (c != c2) {
|
||||||
|
m++;
|
||||||
|
if (verbose > 1) {
|
||||||
|
printf("*** comp^real failure for a = %d\n", a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* real ^ complex */
|
||||||
|
a = rand(1,1e20);
|
||||||
|
a = a / (int(a/2)+rand(1,1e20));
|
||||||
|
b = rand(1,1e20);
|
||||||
|
b = b / (int(b/2)+rand(1,1e20));
|
||||||
|
c = a ^ (b*1i);
|
||||||
|
c2 = power(a, b*1i);
|
||||||
|
if (c != c2) {
|
||||||
|
m++;
|
||||||
|
if (verbose > 1) {
|
||||||
|
printf("*** real^comp failure for a = %d\n", a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* complex ^ complex */
|
||||||
|
a = rand(1,1e20);
|
||||||
|
a = a / (int(a/2)+rand(1,1e20));
|
||||||
|
b = rand(1,1e20);
|
||||||
|
b = b / (int(b/2)+rand(1,1e20));
|
||||||
|
c = (a*1i) ^ (b*1i);
|
||||||
|
c2 = power(a*1i, b*1i);
|
||||||
|
if (c != c2) {
|
||||||
|
m++;
|
||||||
|
if (verbose > 1) {
|
||||||
|
printf("*** comp^comp failure for a = %d\n", a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
epsilon(oldeps),;
|
||||||
|
if (verbose > 0) {
|
||||||
|
if (m) {
|
||||||
|
printf("*** %d error(s)\n", m);
|
||||||
|
printf(" %s: rem/eps min=%d, max=%d\n",
|
||||||
|
str, min, max);
|
||||||
|
} else {
|
||||||
|
printf("no errors\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (verbose > 1) {
|
||||||
|
printf(" %s: rem/eps min=%0.4d, max=%0.4d\n", str, min, max);
|
||||||
|
}
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
define cpow(a, b, eps) /* Find rem/eps for power(a,b,eps) */
|
define cpow(a, b, eps) /* Find rem/eps for power(a,b,eps) */
|
||||||
{
|
{
|
||||||
local v, v1, c, n, d, h;
|
local v, v1, c, n, d, h;
|
||||||
@@ -504,6 +600,7 @@ define test2600(verbose, tnum)
|
|||||||
err += testsqrt(strcat(str(tnum++),": sqrt",str(i)), n*10,
|
err += testsqrt(strcat(str(tnum++),": sqrt",str(i)), n*10,
|
||||||
ep, verbose);
|
ep, verbose);
|
||||||
}
|
}
|
||||||
|
err += testpower2(strcat(str(tnum++),": power"), n*4, ep, verbose);
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
if (err) {
|
if (err) {
|
||||||
print "***", err, "error(s) found in test2600";
|
print "***", err, "error(s) found in test2600";
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test2700.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test2700.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2700.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2700.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/11/01 22:52:25
|
* Under source code control: 1995/11/01 22:52:25
|
||||||
@@ -41,8 +41,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
global defaultverbose = 1;
|
defaultverbose = 1;
|
||||||
global err;
|
|
||||||
|
|
||||||
define mknonnegreal() {
|
define mknonnegreal() {
|
||||||
switch(rand(8)) {
|
switch(rand(8)) {
|
||||||
@@ -89,11 +88,11 @@ define mkfrac() = rand(2) ? mkposfrac() : -mkposfrac();
|
|||||||
define mksquarereal() = mknonnegreal()^2;
|
define mksquarereal() = mknonnegreal()^2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX - Should be able to do better than the following. For nonsquare
|
* We might be able to do better than the following. For nonsquare
|
||||||
* positive integer less than 1e6, could use
|
* positive integer less than 1e6, could use:
|
||||||
* x = rand(1, 1000);
|
* x = rand(1, 1000);
|
||||||
* return rand(x^2 + 1, (x + 1)^2);
|
* return rand(x^2 + 1, (x + 1)^2);
|
||||||
* Maybe could do
|
* Maybe could do:
|
||||||
* do
|
* do
|
||||||
* x = mkreal_2700();
|
* x = mkreal_2700();
|
||||||
* while
|
* while
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test3100.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test3100.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3100.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3100.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/11/28 11:56:57
|
* Under source code control: 1995/11/28 11:56:57
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test3300.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test3300.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3300.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3300.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/12/02 04:27:41
|
* Under source code control: 1995/12/02 04:27:41
|
||||||
@@ -30,8 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
global defaultverbose = 1; /* default verbose value */
|
defaultverbose = 1; /* default verbose value */
|
||||||
global err;
|
|
||||||
|
|
||||||
define testi(str, n, N, verbose)
|
define testi(str, n, N, verbose)
|
||||||
{
|
{
|
||||||
@@ -82,9 +81,9 @@ define testr(str, n, N, verbose)
|
|||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
for (j = 0; j < n; j++)
|
for (j = 0; j < n; j++)
|
||||||
A[i,j] = rand(-(N^2), N^2)/rand(1, N);
|
A[i,j] = rand(-(N^2), N^2)/rand(1, N);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
d1 = det(A);
|
d1 = det(A);
|
||||||
t = runtime() - t;
|
t = usertime() - t;
|
||||||
d2 = det(A^2);
|
d2 = det(A^2);
|
||||||
if (d2 != d1^2) {
|
if (d2 != d1^2) {
|
||||||
if (verbose > 0) {
|
if (verbose > 0) {
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test3400.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test3400.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3400.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3400.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/12/02 05:20:11
|
* Under source code control: 1995/12/02 05:20:11
|
||||||
@@ -54,8 +54,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
global defaultverbose = 1; /* default verbose value */
|
defaultverbose = 1; /* default verbose value */
|
||||||
global err;
|
|
||||||
|
|
||||||
global pi1k = pi(1e-1000);
|
global pi1k = pi(1e-1000);
|
||||||
|
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test3500.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test3500.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3500.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3500.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/12/18 22:50:46
|
* Under source code control: 1995/12/18 22:50:46
|
||||||
@@ -53,8 +53,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
global defaultverbose = 1; /* default verbose value */
|
defaultverbose = 1; /* default verbose value */
|
||||||
global err;
|
|
||||||
|
|
||||||
define testfrem(x,y,verbose)
|
define testfrem(x,y,verbose)
|
||||||
{
|
{
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test4000.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test4000.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4000.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4000.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1996/03/13 02:38:45
|
* Under source code control: 1996/03/13 02:38:45
|
||||||
@@ -75,8 +75,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
global defaultverbose = 1; /* default verbose value */
|
defaultverbose = 1; /* default verbose value */
|
||||||
global err;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test defaults
|
* test defaults
|
||||||
@@ -146,7 +145,7 @@ define ptimes(str, N, n, count, skip, verbose)
|
|||||||
mat A[n];
|
mat A[n];
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
A[i] = plen(N);
|
A[i] = plen(N);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
p = ptest(A[i], count, skip);
|
p = ptest(A[i], count, skip);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
@@ -160,7 +159,7 @@ define ptimes(str, N, n, count, skip, verbose)
|
|||||||
if (m) {
|
if (m) {
|
||||||
printf("*** %d error(s)\n", m);
|
printf("*** %d error(s)\n", m);
|
||||||
} else {
|
} else {
|
||||||
t = round(runtime() - t, 4);
|
t = round(usertime() - t, 4);
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
printf("%d probable primes: time = %d\n", n, t);
|
printf("%d probable primes: time = %d\n", n, t);
|
||||||
} else {
|
} else {
|
||||||
@@ -195,7 +194,7 @@ define ctimes(str, N, n, count, skip, verbose)
|
|||||||
mat A[n];
|
mat A[n];
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
A[i] = clen(N);
|
A[i] = clen(N);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
p = ptest(A[i], count, skip);
|
p = ptest(A[i], count, skip);
|
||||||
if (p) {
|
if (p) {
|
||||||
@@ -209,7 +208,7 @@ define ctimes(str, N, n, count, skip, verbose)
|
|||||||
if (m) {
|
if (m) {
|
||||||
printf("*** %d error(s)\n", m);
|
printf("*** %d error(s)\n", m);
|
||||||
} else {
|
} else {
|
||||||
t = round(runtime() - t, 4);
|
t = round(usertime() - t, 4);
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
printf("%d probable primes: time = %d\n", n, t);
|
printf("%d probable primes: time = %d\n", n, t);
|
||||||
} else {
|
} else {
|
||||||
@@ -243,7 +242,7 @@ define crtimes(str, a, b, n, count, skip, verbose)
|
|||||||
A[i] = rand(a,b);
|
A[i] = rand(a,b);
|
||||||
P[i] = ptest(A[i], 20, 0);
|
P[i] = ptest(A[i], 20, 0);
|
||||||
}
|
}
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
p = ptest(A[i], count, skip);
|
p = ptest(A[i], count, skip);
|
||||||
if (p != P[i]) {
|
if (p != P[i]) {
|
||||||
@@ -258,7 +257,7 @@ define crtimes(str, a, b, n, count, skip, verbose)
|
|||||||
if (m) {
|
if (m) {
|
||||||
printf("*** %d error(s)?\n", m);
|
printf("*** %d error(s)?\n", m);
|
||||||
} else {
|
} else {
|
||||||
t = round(runtime() - t, 4);
|
t = round(usertime() - t, 4);
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
printf("%d probable primes: time = %d\n", n, t);
|
printf("%d probable primes: time = %d\n", n, t);
|
||||||
} else {
|
} else {
|
||||||
@@ -296,16 +295,16 @@ define ntimes(str, N, n, count, skip, residue, modulus, verbose)
|
|||||||
mat A[n];
|
mat A[n];
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
A[i] = rlen(N);
|
A[i] = rlen(N);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
p = nextcand(A[i], count, skip, residue, modulus);
|
p = nextcand(A[i], count, skip, residue, modulus);
|
||||||
}
|
}
|
||||||
tnext = round(runtime() - t, 4);
|
tnext = round(usertime() - t, 4);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
p = prevcand(A[i], count, skip, residue, modulus);
|
p = prevcand(A[i], count, skip, residue, modulus);
|
||||||
}
|
}
|
||||||
tprev = round(runtime() - t, 4);
|
tprev = round(usertime() - t, 4);
|
||||||
if (verbose > 0) {
|
if (verbose > 0) {
|
||||||
printf("%d evaluations, nextcand: %d, prevcand: %d\n", n, tnext, tprev);
|
printf("%d evaluations, nextcand: %d, prevcand: %d\n", n, tnext, tprev);
|
||||||
}
|
}
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test4100.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test4100.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4100.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4100.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1996/03/13 03:53:22
|
* Under source code control: 1996/03/13 03:53:22
|
||||||
@@ -70,18 +70,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
global defaultverbose = 1; /* default verbose value */
|
defaultverbose = 1; /* default verbose value */
|
||||||
global err;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test defaults
|
* test defaults
|
||||||
*/
|
*/
|
||||||
global K1 = 2^17;
|
global test4100_K1 = 2^17;
|
||||||
global K2 = 2^12;
|
global test4100_K2 = 2^12;
|
||||||
global BASEB = 16;
|
global test4100_BASE = 2^config("baseb");
|
||||||
global BASE = 2^BASEB;
|
|
||||||
|
|
||||||
define rlen_4100(N) = rand(BASE^(N-1), BASE^N);
|
define rlen_4100(N) = rand(test4100_BASE^(N-1), test4100_BASE^N);
|
||||||
|
|
||||||
define olen(N)
|
define olen(N)
|
||||||
{
|
{
|
||||||
@@ -234,7 +232,7 @@ define times(str,N,n,verbose)
|
|||||||
m = olen(N);
|
m = olen(N);
|
||||||
m2 = m^2;
|
m2 = m^2;
|
||||||
if (isnull(n)) {
|
if (isnull(n)) {
|
||||||
n = ceil(K1/power(N,1.585));
|
n = ceil(test4100_K1/power(N,1.585));
|
||||||
if (verbose > 1)
|
if (verbose > 1)
|
||||||
printf("n = %d\n", n);
|
printf("n = %d\n", n);
|
||||||
}
|
}
|
||||||
@@ -247,38 +245,38 @@ define times(str,N,n,verbose)
|
|||||||
C[i] = rand(m2);
|
C[i] = rand(m2);
|
||||||
}
|
}
|
||||||
z = rcin(0,m); /* to initialize redc and maybe lastmod information */
|
z = rcin(0,m); /* to initialize redc and maybe lastmod information */
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z = rcin(A[i],m);
|
z = rcin(A[i],m);
|
||||||
trcin = round(runtime() - t, 3);
|
trcin = round(usertime() - t, 3);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z = rcout(A[i],m);
|
z = rcout(A[i],m);
|
||||||
trcout = round(runtime() - t, 3);
|
trcout = round(usertime() - t, 3);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z = rcmul(A[i],B[i],m);
|
z = rcmul(A[i],B[i],m);
|
||||||
trcmul = round(runtime() - t, 3);
|
trcmul = round(usertime() - t, 3);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z = rcsq(A[i],m);
|
z = rcsq(A[i],m);
|
||||||
trcsq = round(runtime() - t, 3);
|
trcsq = round(usertime() - t, 3);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z = A[i] * B[i];
|
z = A[i] * B[i];
|
||||||
tmul = round(runtime() - t, 3);
|
tmul = round(usertime() - t, 3);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z = A[i]^2;
|
z = A[i]^2;
|
||||||
tsq = round(runtime() - t, 3);
|
tsq = round(usertime() - t, 3);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z = C[i] % A[i];
|
z = C[i] % A[i];
|
||||||
tmod = round(runtime() - t, 3);
|
tmod = round(usertime() - t, 3);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
quomod(C[i], A[i], x, y);
|
quomod(C[i], A[i], x, y);
|
||||||
tquomod = round(runtime() - t,3);
|
tquomod = round(usertime() - t,3);
|
||||||
|
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
printf("rcin: %d, rcout: %d, rcmul: %d, rcsq: %d\n",
|
printf("rcin: %d, rcout: %d, rcmul: %d, rcsq: %d\n",
|
||||||
@@ -308,7 +306,7 @@ define powtimes(str, N1, N2, n, verbose)
|
|||||||
N2 = 1;
|
N2 = 1;
|
||||||
|
|
||||||
if (isnull(n)) {
|
if (isnull(n)) {
|
||||||
n = ceil(K2/power(N1, 1.585)/N2);
|
n = ceil(test4100_K2/power(N1, 1.585)/N2);
|
||||||
printf ("n = %d\n", n);
|
printf ("n = %d\n", n);
|
||||||
}
|
}
|
||||||
mat A[n];
|
mat A[n];
|
||||||
@@ -316,8 +314,8 @@ define powtimes(str, N1, N2, n, verbose)
|
|||||||
mat B[n];
|
mat B[n];
|
||||||
v = olen(N1);
|
v = olen(N1);
|
||||||
|
|
||||||
cp = config("pow2", 1);
|
cp = config("pow2", 2);
|
||||||
crc = config("redc2", 1);
|
crc = config("redc2", 2);
|
||||||
|
|
||||||
/* initialize redc and lastmod info */
|
/* initialize redc and lastmod info */
|
||||||
|
|
||||||
@@ -328,29 +326,29 @@ define powtimes(str, N1, N2, n, verbose)
|
|||||||
Ar[i] = rcin(A[i], v);
|
Ar[i] = rcin(A[i], v);
|
||||||
B[i] = rlen_4100(N2);
|
B[i] = rlen_4100(N2);
|
||||||
}
|
}
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z1 += pmod(A[i], B[i], v);
|
z1 += pmod(A[i], B[i], v);
|
||||||
tbignum = round(runtime() - t, 4);
|
tbignum = round(usertime() - t, 4);
|
||||||
config("pow2", 1e6);
|
config("pow2", 1e6);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z2 += pmod(A[i], B[i], v);
|
z2 += pmod(A[i], B[i], v);
|
||||||
tnormal = round(runtime() - t, 4);
|
tnormal = round(usertime() - t, 4);
|
||||||
config("redc2",1e6);
|
config("redc2",1e6);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z3 += pmod(A[i], B[i], v);
|
z3 += pmod(A[i], B[i], v);
|
||||||
tsmall = round(runtime() - t, 4);
|
tsmall = round(usertime() - t, 4);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z4 += rcpow(Ar[i], B[i], v);
|
z4 += rcpow(Ar[i], B[i], v);
|
||||||
trcsmall = round(runtime() - t, 4);
|
trcsmall = round(usertime() - t, 4);
|
||||||
config("redc2", 1);
|
config("redc2", 2);
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
z5 += rcpow(Ar[i], B[i], v);
|
z5 += rcpow(Ar[i], B[i], v);
|
||||||
trcbig = round(runtime() - t, 4);
|
trcbig = round(usertime() - t, 4);
|
||||||
|
|
||||||
if (z1 != z2) {
|
if (z1 != z2) {
|
||||||
++m;
|
++m;
|
||||||
@@ -408,7 +406,7 @@ define inittimes(str,N,n,verbose)
|
|||||||
}
|
}
|
||||||
m = 0;
|
m = 0;
|
||||||
if (isnull(n)) {
|
if (isnull(n)) {
|
||||||
n = ceil(K1/N^2);
|
n = ceil(test4100_K1/N^2);
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
printf ("n = %d\n", n);
|
printf ("n = %d\n", n);
|
||||||
}
|
}
|
||||||
@@ -421,13 +419,13 @@ define inittimes(str,N,n,verbose)
|
|||||||
M[i] = olen(N);
|
M[i] = olen(N);
|
||||||
A[i] = rand(M[i]);
|
A[i] = rand(M[i]);
|
||||||
}
|
}
|
||||||
t = runtime();
|
t = usertime();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
R[i] = rcin(A[i], M[i]);
|
R[i] = rcin(A[i], M[i]);
|
||||||
trcin = round(runtime() - t, 4);
|
trcin = round(usertime() - t, 4);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
B[i] = rcout(R[i], M[i]);
|
B[i] = rcout(R[i], M[i]);
|
||||||
trcout = round(runtime() - t, 4);
|
trcout = round(usertime() - t, 4);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (B[i] != A[i]) {
|
if (B[i] != A[i]) {
|
||||||
++m;
|
++m;
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.4 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test4600.cal,v 29.4 2001/04/10 22:09:02 chongo Exp $
|
* @(#) $Id: test4600.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4600.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4600.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1996/07/02 20:04:40
|
* Under source code control: 1996/07/02 20:04:40
|
||||||
@@ -30,8 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
global defaultverbose = 1 /* default verbose value */
|
defaultverbose = 1; /* default verbose value */
|
||||||
global err;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test globals
|
* test globals
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test5100.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test5100.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test5100.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test5100.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1996/12/02 23:57:10
|
* Under source code control: 1996/12/02 23:57:10
|
||||||
@@ -30,8 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
global defaultverbose = 1; /* default verbose value */
|
defaultverbose = 1; /* default verbose value */
|
||||||
global err;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We test the new code generator declaration scope and order.
|
* We test the new code generator declaration scope and order.
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test5200.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test5200.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test5200.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test5200.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1997/02/07 02:48:10
|
* Under source code control: 1997/02/07 02:48:10
|
||||||
@@ -30,8 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
global defaultverbose = 1; /* default verbose value */
|
defaultverbose = 1; /* default verbose value */
|
||||||
global err;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test the fix of a global/static bug
|
* test the fix of a global/static bug
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test8400.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test8400.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test8400.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test8400.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1999/10/31 01:00:03
|
* Under source code control: 1999/10/31 01:00:03
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test8500.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: test8500.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test8500.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test8500.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1999/11/12 20:59:59
|
* Under source code control: 1999/11/12 20:59:59
|
||||||
|
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.1 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: test8600.cal,v 29.1 2000/12/04 19:57:02 chongo Exp $
|
* @(#) $Id: test8600.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test8600.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test8600.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 2000/12/04 19:57:02
|
* Under source code control: 2000/12/04 19:57:02
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: unitfrac.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: unitfrac.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/unitfrac.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/unitfrac.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:50:38
|
* Under source code control: 1990/02/15 01:50:38
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: varargs.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: varargs.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/varargs.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/varargs.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1991/05/22 21:56:34
|
* Under source code control: 1991/05/22 21:56:34
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: xx_print.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
* @(#) $Id: xx_print.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/xx_print.cal,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/xx_print.cal,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1997/04/17 00:08:50
|
* Under source code control: 1997/04/17 00:08:50
|
||||||
|
115
calc.c
115
calc.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* calc - arbitrary precision calculator
|
* calc - arbitrary precision calculator
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2006 David I. Bell, Landon Curt Noll and Ernest Bowen
|
* Copyright (C) 1999-2007 David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: David I. Bell
|
* Primary author: David I. Bell
|
||||||
*
|
*
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.13 $
|
* @(#) $Revision: 30.4 $
|
||||||
* @(#) $Id: calc.c,v 29.13 2006/05/19 15:26:10 chongo Exp $
|
* @(#) $Id: calc.c,v 30.4 2008/04/15 21:17:57 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:48:11
|
* Under source code control: 1990/02/15 01:48:11
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
|
# if !defined(NOTCYGWIN)
|
||||||
/*
|
/*
|
||||||
* getopt.h file is from the Cygwin GNU library
|
* getopt.h file is from the Cygwin GNU library
|
||||||
*
|
*
|
||||||
@@ -49,6 +50,7 @@
|
|||||||
* http://sources.redhat.com/cygwin/
|
* http://sources.redhat.com/cygwin/
|
||||||
*/
|
*/
|
||||||
# include "../getopt/getopt.h"
|
# include "../getopt/getopt.h"
|
||||||
|
# endif
|
||||||
# define strdup _strdup
|
# define strdup _strdup
|
||||||
# define isatty _isatty
|
# define isatty _isatty
|
||||||
#endif /* Windoz */
|
#endif /* Windoz */
|
||||||
@@ -64,7 +66,7 @@
|
|||||||
#include "have_uid_t.h"
|
#include "have_uid_t.h"
|
||||||
#include "have_const.h"
|
#include "have_const.h"
|
||||||
#include "custom.h"
|
#include "custom.h"
|
||||||
#include "math_error.h"
|
#include "lib_calc.h"
|
||||||
#include "args.h"
|
#include "args.h"
|
||||||
#include "zmath.h"
|
#include "zmath.h"
|
||||||
|
|
||||||
@@ -87,11 +89,12 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* static definitions and functions
|
* S_FUNC definitions and functions
|
||||||
*/
|
*/
|
||||||
static void intint(int arg); /* interrupt routine */
|
S_FUNC void intint(int arg); /* interrupt routine */
|
||||||
static int nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr);
|
S_FUNC void calc_interrupt(char *fmt, ...);
|
||||||
static void set_run_state(run state);
|
S_FUNC int nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr);
|
||||||
|
S_FUNC void set_run_state(run state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Top level calculator routine.
|
* Top level calculator routine.
|
||||||
@@ -188,7 +191,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"-m expects"
|
"-m expects"
|
||||||
" argument");
|
" argument");
|
||||||
exit (1);
|
exit(2);
|
||||||
}
|
}
|
||||||
cp = argv[index];
|
cp = argv[index];
|
||||||
}
|
}
|
||||||
@@ -203,7 +206,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: unknown -m arg\n",
|
"%s: unknown -m arg\n",
|
||||||
program);
|
program);
|
||||||
exit(1);
|
exit(3);
|
||||||
}
|
}
|
||||||
allow_read = (((*cp-'0') & 04) > 0);
|
allow_read = (((*cp-'0') & 04) > 0);
|
||||||
allow_write = (((*cp-'0') & 02) > 0);
|
allow_write = (((*cp-'0') & 02) > 0);
|
||||||
@@ -211,7 +214,7 @@ main(int argc, char **argv)
|
|||||||
cp++;
|
cp++;
|
||||||
if (*cp != ' ' && *cp != '\0') {
|
if (*cp != ' ' && *cp != '\0') {
|
||||||
fprintf(stderr, "??? m-arg");
|
fprintf(stderr, "??? m-arg");
|
||||||
exit(1);
|
exit(4);
|
||||||
}
|
}
|
||||||
havearg = TRUE;
|
havearg = TRUE;
|
||||||
break;
|
break;
|
||||||
@@ -245,8 +248,13 @@ main(int argc, char **argv)
|
|||||||
* call libcalc_call_me_last() -
|
* call libcalc_call_me_last() -
|
||||||
* nothing to cleanup
|
* nothing to cleanup
|
||||||
*/
|
*/
|
||||||
printf("%s (version %s)\n",
|
fputs(CALC_TITLE, stdout);
|
||||||
CALC_TITLE, version());
|
#if defined(CUSTOM)
|
||||||
|
fputs(" w/custom functions", stdout);
|
||||||
|
#else
|
||||||
|
fputs(" w/o custom functions", stdout);
|
||||||
|
#endif /* CUSTOM */
|
||||||
|
printf(" (version %s)\n", version());
|
||||||
exit(0);
|
exit(0);
|
||||||
case 'D':
|
case 'D':
|
||||||
/*
|
/*
|
||||||
@@ -262,7 +270,7 @@ main(int argc, char **argv)
|
|||||||
FALSE)) {
|
FALSE)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"-D expects argument\n");
|
"-D expects argument\n");
|
||||||
exit (1);
|
exit(5);
|
||||||
}
|
}
|
||||||
havearg = TRUE;
|
havearg = TRUE;
|
||||||
if (*cp != ':') {
|
if (*cp != ':') {
|
||||||
@@ -270,7 +278,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"-D expects"
|
"-D expects"
|
||||||
" integer\n");
|
" integer\n");
|
||||||
exit (1);
|
exit(6);
|
||||||
}
|
}
|
||||||
calc_debug = cp;
|
calc_debug = cp;
|
||||||
(void) strtol(cp, &endcp, 10);
|
(void) strtol(cp, &endcp, 10);
|
||||||
@@ -280,7 +288,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Bad syntax im -D"
|
"Bad syntax im -D"
|
||||||
" arg\n");
|
" arg\n");
|
||||||
exit (1);
|
exit(7);
|
||||||
}
|
}
|
||||||
if (*cp != ':') {
|
if (*cp != ':') {
|
||||||
if (nextcp(&cp, &index,
|
if (nextcp(&cp, &index,
|
||||||
@@ -295,14 +303,14 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"-D : expects"
|
"-D : expects"
|
||||||
" argument\n");
|
" argument\n");
|
||||||
exit (1);
|
exit(8);
|
||||||
}
|
}
|
||||||
if (*cp != ':') {
|
if (*cp != ':') {
|
||||||
if (*cp < '0' || *cp > '9') {
|
if (*cp < '0' || *cp > '9') {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"-D : expects"
|
"-D : expects"
|
||||||
" integer\n");
|
" integer\n");
|
||||||
exit (1);
|
exit(9);
|
||||||
}
|
}
|
||||||
resource_debug = cp;
|
resource_debug = cp;
|
||||||
(void) strtol(cp, &endcp, 10);
|
(void) strtol(cp, &endcp, 10);
|
||||||
@@ -312,7 +320,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Bad syntax im -D"
|
"Bad syntax im -D"
|
||||||
" : arg\n");
|
" : arg\n");
|
||||||
exit (1);
|
exit(10);
|
||||||
}
|
}
|
||||||
if (*cp != ':') {
|
if (*cp != ':') {
|
||||||
if (nextcp(&cp, &index,
|
if (nextcp(&cp, &index,
|
||||||
@@ -327,12 +335,12 @@ main(int argc, char **argv)
|
|||||||
FALSE)) {
|
FALSE)) {
|
||||||
fprintf(stderr, "-D : : expects"
|
fprintf(stderr, "-D : : expects"
|
||||||
" argument\n");
|
" argument\n");
|
||||||
exit (1);
|
exit(11);
|
||||||
}
|
}
|
||||||
if (*cp < '0' || *cp > '9') {
|
if (*cp < '0' || *cp > '9') {
|
||||||
fprintf(stderr, "-D :: expects"
|
fprintf(stderr, "-D :: expects"
|
||||||
" integer\n");
|
" integer\n");
|
||||||
exit (1);
|
exit(12);
|
||||||
}
|
}
|
||||||
user_debug = cp;
|
user_debug = cp;
|
||||||
(void) strtol(cp, &endcp, 10);
|
(void) strtol(cp, &endcp, 10);
|
||||||
@@ -340,7 +348,7 @@ main(int argc, char **argv)
|
|||||||
if (*cp != '\0' && *cp != ' ') {
|
if (*cp != '\0' && *cp != ' ') {
|
||||||
fprintf(stderr, "Bad syntax in"
|
fprintf(stderr, "Bad syntax in"
|
||||||
" -D : : arg\n");
|
" -D : : arg\n");
|
||||||
exit (1);
|
exit(13);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
@@ -349,13 +357,13 @@ main(int argc, char **argv)
|
|||||||
haveendstr)) {
|
haveendstr)) {
|
||||||
fprintf(stderr, "-f expects"
|
fprintf(stderr, "-f expects"
|
||||||
" filename\n");
|
" filename\n");
|
||||||
exit (1);
|
exit(14);
|
||||||
}
|
}
|
||||||
if (*cp == ';') {
|
if (*cp == ';') {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"-f expects"
|
"-f expects"
|
||||||
" filename\n");
|
" filename\n");
|
||||||
exit (1);
|
exit(15);
|
||||||
}
|
}
|
||||||
havearg = TRUE;
|
havearg = TRUE;
|
||||||
if (cmdlen > 0)
|
if (cmdlen > 0)
|
||||||
@@ -373,7 +381,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr, "-f -once"
|
fprintf(stderr, "-f -once"
|
||||||
" expects"
|
" expects"
|
||||||
" filename\n");
|
" filename\n");
|
||||||
exit (1);
|
exit(16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bp = cmdbuf + cmdlen;
|
bp = cmdbuf + cmdlen;
|
||||||
@@ -383,13 +391,13 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Null"
|
"Null"
|
||||||
" filename!");
|
" filename!");
|
||||||
exit (1);
|
exit(17);
|
||||||
}
|
}
|
||||||
if (cmdlen + len + 2 > MAXCMD) {
|
if (cmdlen + len + 2 > MAXCMD) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Commands too"
|
"Commands too"
|
||||||
" long");
|
" long");
|
||||||
exit (1);
|
exit(18);
|
||||||
}
|
}
|
||||||
/* XXX What if *cp = '\''? */
|
/* XXX What if *cp = '\''? */
|
||||||
*bp++ = '\'';
|
*bp++ = '\'';
|
||||||
@@ -404,7 +412,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Commands"
|
"Commands"
|
||||||
" too long");
|
" too long");
|
||||||
exit (1);
|
exit(19);
|
||||||
}
|
}
|
||||||
*bp++ = *cp++;
|
*bp++ = *cp++;
|
||||||
cmdlen++;
|
cmdlen++;
|
||||||
@@ -416,6 +424,7 @@ main(int argc, char **argv)
|
|||||||
cp++;
|
cp++;
|
||||||
*bp++ = ';';
|
*bp++ = ';';
|
||||||
cmdlen++;
|
cmdlen++;
|
||||||
|
s_flag = TRUE; /* -f implies -s */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
@@ -431,12 +440,14 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr, "Illegal option -%c\n",
|
fprintf(stderr, "Illegal option -%c\n",
|
||||||
c);
|
c);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [-a] [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
|
"usage: %s [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
|
||||||
"\t[-D calc_debug[:resource_debug[:user_debug]]]\n"
|
"\t[-D calc_debug[:resource_debug[:user_debug]]]\n"
|
||||||
"\t[-O] [-p] [-q] [-u] [-v] "
|
"\t[-O] [-p] [-q] [-s] [-u] [-v] "
|
||||||
"[--] [calc_cmd ...]\n",
|
"[--] [calc_cmd ...]\n"
|
||||||
program);
|
"usage: %s ... -f filename\n"
|
||||||
exit(1);
|
"1st cscript line: #/path/to/calc ... -f\n",
|
||||||
|
program, program);
|
||||||
|
exit(20);
|
||||||
}
|
}
|
||||||
if (havearg)
|
if (havearg)
|
||||||
break;
|
break;
|
||||||
@@ -462,7 +473,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: commands too long\n",
|
"%s: commands too long\n",
|
||||||
program);
|
program);
|
||||||
exit(1);
|
exit(21);
|
||||||
}
|
}
|
||||||
strncpy(cmdbuf + cmdlen, cp, cplen+1);
|
strncpy(cmdbuf + cmdlen, cp, cplen+1);
|
||||||
cmdlen = newcmdlen;
|
cmdlen = newcmdlen;
|
||||||
@@ -533,14 +544,13 @@ main(int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* establish error longjump point with initial conditions
|
* establish error longjump point with initial conditions
|
||||||
*/
|
*/
|
||||||
if (setjmp(jmpbuf) == 0) {
|
if (setjmp(calc_scanerr_jmpbuf) == 0) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* reset/initialize the computing environment
|
* reset/initialize the computing environment
|
||||||
*/
|
*/
|
||||||
if (post_init)
|
initialize();
|
||||||
initialize();
|
calc_use_scanerr_jmpbuf = 1;
|
||||||
post_init = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -710,12 +720,12 @@ main(int argc, char **argv)
|
|||||||
* arg to keep ANSI C happy
|
* arg to keep ANSI C happy
|
||||||
*/
|
*/
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
static void
|
S_FUNC void
|
||||||
intint(int UNUSED arg)
|
intint(int UNUSED arg)
|
||||||
{
|
{
|
||||||
(void) signal(SIGINT, intint);
|
(void) signal(SIGINT, intint);
|
||||||
if (inputwait || (++abortlevel >= ABORT_NOW)) {
|
if (inputwait || (++abortlevel >= ABORT_NOW)) {
|
||||||
math_error("\nABORT");
|
calc_interrupt("\nABORT");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
if (abortlevel >= ABORT_MATH)
|
if (abortlevel >= ABORT_MATH)
|
||||||
@@ -725,14 +735,12 @@ intint(int UNUSED arg)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Routine called on any runtime error, to complain about it (with possible
|
* report an interrupt
|
||||||
* arguments), and then longjump back to the top level command scanner.
|
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
math_error(char *fmt, ...)
|
calc_interrupt(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char buf[MAXERROR+1];
|
|
||||||
|
|
||||||
if (funcname && (*funcname != '*'))
|
if (funcname && (*funcname != '*'))
|
||||||
fprintf(stderr, "\"%s\": ", funcname);
|
fprintf(stderr, "\"%s\": ", funcname);
|
||||||
@@ -740,12 +748,13 @@ math_error(char *fmt, ...)
|
|||||||
!inputisterminal()))
|
!inputisterminal()))
|
||||||
fprintf(stderr, "line %ld: ", funcline);
|
fprintf(stderr, "line %ld: ", funcline);
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsprintf(buf, fmt, ap);
|
vsnprintf(calc_err_msg, MAXERROR, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fprintf(stderr, "%s\n", buf);
|
calc_err_msg[MAXERROR] = '\0';
|
||||||
|
fprintf(stderr, "%s\n\n", calc_err_msg);
|
||||||
funcname = NULL;
|
funcname = NULL;
|
||||||
if (post_init) {
|
if (calc_use_scanerr_jmpbuf != 0) {
|
||||||
longjmp(jmpbuf, 1);
|
longjmp(calc_scanerr_jmpbuf, 22);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "It is too early provide a command line prompt "
|
fprintf(stderr, "It is too early provide a command line prompt "
|
||||||
"so we must simply exit. Sorry!\n");
|
"so we must simply exit. Sorry!\n");
|
||||||
@@ -753,11 +762,11 @@ math_error(char *fmt, ...)
|
|||||||
* don't call libcalc_call_me_last() -- we might loop
|
* don't call libcalc_call_me_last() -- we might loop
|
||||||
* and besides ... this is an unusual internal error case
|
* and besides ... this is an unusual internal error case
|
||||||
*/
|
*/
|
||||||
exit(3);
|
exit(22);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
S_FUNC int
|
||||||
nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr)
|
nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr)
|
||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
@@ -796,7 +805,7 @@ nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
S_FUNC void
|
||||||
set_run_state(run state)
|
set_run_state(run state)
|
||||||
{
|
{
|
||||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||||
|
239
calc.h
239
calc.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* calc - definitions for calculator program
|
* calc - definitions for calculator program
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2006 David I. Bell
|
* Copyright (C) 1999-2007 David I. Bell
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.18 $
|
* @(#) $Revision: 30.2 $
|
||||||
* @(#) $Id: calc.h,v 29.18 2006/05/21 07:28:54 chongo Exp $
|
* @(#) $Id: calc.h,v 30.2 2007/07/10 17:44:52 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.h,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.h,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:48:31
|
* Under source code control: 1990/02/15 01:48:31
|
||||||
@@ -33,11 +33,11 @@
|
|||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
||||||
# include "win32dll.h"
|
# include "decl.h"
|
||||||
# include "value.h"
|
# include "value.h"
|
||||||
# include "have_const.h"
|
# include "have_const.h"
|
||||||
#else
|
#else
|
||||||
# include <calc/win32dll.h>
|
# include <calc/decl.h>
|
||||||
# include <calc/value.h>
|
# include <calc/value.h>
|
||||||
# include <calc/have_const.h>
|
# include <calc/have_const.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -66,7 +66,6 @@
|
|||||||
#define LISTCHAR ':' /* char which separates paths in a list */
|
#define LISTCHAR ':' /* char which separates paths in a list */
|
||||||
#endif
|
#endif
|
||||||
#define MAXCMD 16384 /* maximum length of command invocation */
|
#define MAXCMD 16384 /* maximum length of command invocation */
|
||||||
#define MAXERROR 512 /* maximum length of error message string */
|
|
||||||
|
|
||||||
#define SYMBOLSIZE 256 /* maximum symbol name size */
|
#define SYMBOLSIZE 256 /* maximum symbol name size */
|
||||||
#define MAXLABELS 100 /* maximum number of user labels in function */
|
#define MAXLABELS 100 /* maximum number of user labels in function */
|
||||||
@@ -91,6 +90,7 @@
|
|||||||
#define ABORT_NOW 4 /* abort right away */
|
#define ABORT_NOW 4 /* abort right away */
|
||||||
|
|
||||||
#define ERRMAX 20 /* default errmax value */
|
#define ERRMAX 20 /* default errmax value */
|
||||||
|
#define E_OK 0 /* no error */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* File ids corresponding to standard in, out, error, and when not in use.
|
* File ids corresponding to standard in, out, error, and when not in use.
|
||||||
@@ -103,141 +103,138 @@
|
|||||||
/*
|
/*
|
||||||
* File I/O routines.
|
* File I/O routines.
|
||||||
*/
|
*/
|
||||||
extern DLL FILEID openid(char *name, char *mode);
|
E_FUNC FILEID openid(char *name, char *mode);
|
||||||
extern DLL FILEID openpathid(char *name, char *mode, char *pathlist);
|
E_FUNC FILEID openpathid(char *name, char *mode, char *pathlist);
|
||||||
extern DLL FILEID indexid(long index);
|
E_FUNC FILEID indexid(long index);
|
||||||
extern DLL BOOL validid(FILEID id);
|
E_FUNC BOOL validid(FILEID id);
|
||||||
extern DLL BOOL errorid(FILEID id);
|
E_FUNC BOOL errorid(FILEID id);
|
||||||
extern DLL BOOL eofid(FILEID id);
|
E_FUNC BOOL eofid(FILEID id);
|
||||||
extern DLL int closeid(FILEID id);
|
E_FUNC int closeid(FILEID id);
|
||||||
extern DLL int getcharid(FILEID id);
|
E_FUNC int getcharid(FILEID id);
|
||||||
extern DLL int idprintf(FILEID id, char *fmt, int count, VALUE **vals);
|
E_FUNC int idprintf(FILEID id, char *fmt, int count, VALUE **vals);
|
||||||
extern DLL int idfputc(FILEID id, int ch);
|
E_FUNC int idfputc(FILEID id, int ch);
|
||||||
extern DLL int idfputs(FILEID id, char *str);
|
E_FUNC int idfputs(FILEID id, STRING *str);
|
||||||
extern DLL int printid(FILEID id, int flags);
|
E_FUNC int printid(FILEID id, int flags);
|
||||||
extern DLL int flushid(FILEID id);
|
E_FUNC int flushid(FILEID id);
|
||||||
extern DLL int readid(FILEID id, int flags, char **retptr);
|
E_FUNC int readid(FILEID id, int flags, STRING **retptr);
|
||||||
extern DLL int getloc(FILEID id, ZVALUE *loc);
|
E_FUNC int getloc(FILEID id, ZVALUE *loc);
|
||||||
extern DLL int setloc(FILEID id, ZVALUE zpos);
|
E_FUNC int setloc(FILEID id, ZVALUE zpos);
|
||||||
extern DLL int getsize(FILEID id, ZVALUE *size);
|
E_FUNC int getsize(FILEID id, ZVALUE *size);
|
||||||
extern DLL int get_device(FILEID id, ZVALUE *dev);
|
E_FUNC int get_device(FILEID id, ZVALUE *dev);
|
||||||
extern DLL int get_inode(FILEID id, ZVALUE *ino);
|
E_FUNC int get_inode(FILEID id, ZVALUE *ino);
|
||||||
extern DLL FILEID reopenid(FILEID id, char *mode, char *name);
|
E_FUNC FILEID reopenid(FILEID id, char *mode, char *name);
|
||||||
extern DLL int closeall(void);
|
E_FUNC int closeall(void);
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
extern DLL int flushall(void);
|
E_FUNC int flushall(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern DLL int idfputstr(FILEID id, char *str);
|
E_FUNC int idfputstr(FILEID id, char *str);
|
||||||
extern DLL int rewindid(FILEID id);
|
E_FUNC int rewindid(FILEID id);
|
||||||
extern DLL void rewindall(void);
|
E_FUNC void rewindall(void);
|
||||||
extern DLL ZVALUE zfilesize(FILEID id);
|
E_FUNC ZVALUE zfilesize(FILEID id);
|
||||||
extern DLL void showfiles(void);
|
E_FUNC void showfiles(void);
|
||||||
extern DLL int fscanfid(FILEID id, char *fmt, int count, VALUE **vals);
|
E_FUNC int fscanfid(FILEID id, char *fmt, int count, VALUE **vals);
|
||||||
extern DLL int scanfstr(char *str, char *fmt, int count, VALUE **vals);
|
E_FUNC int scanfstr(char *str, char *fmt, int count, VALUE **vals);
|
||||||
extern DLL int ftellid(FILEID id, ZVALUE *res);
|
E_FUNC int ftellid(FILEID id, ZVALUE *res);
|
||||||
extern DLL int fseekid(FILEID id, ZVALUE offset, int whence);
|
E_FUNC int fseekid(FILEID id, ZVALUE offset, int whence);
|
||||||
extern DLL int isattyid(FILEID id);
|
E_FUNC int isattyid(FILEID id);
|
||||||
extern DLL int fsearch(FILEID id, char *str, ZVALUE start, ZVALUE end, ZVALUE *res);
|
E_FUNC int fsearch(FILEID id, char *str, ZVALUE start, ZVALUE end, ZVALUE *res);
|
||||||
extern DLL int frsearch(FILEID id, char *str, ZVALUE first, ZVALUE last, ZVALUE *res);
|
E_FUNC int frsearch(FILEID id, char *str, ZVALUE first, ZVALUE last, ZVALUE *res);
|
||||||
extern DLL void showconstants(void);
|
E_FUNC void showconstants(void);
|
||||||
extern DLL void freeconstant(unsigned long);
|
E_FUNC void freeconstant(unsigned long);
|
||||||
extern DLL void freestringconstant(long);
|
E_FUNC void freestringconstant(long);
|
||||||
extern DLL void trimconstants(void);
|
E_FUNC void trimconstants(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Input routines.
|
* Input routines.
|
||||||
*/
|
*/
|
||||||
extern DLL int openstring(char *str, size_t num);
|
E_FUNC int openstring(char *str, size_t num);
|
||||||
extern DLL int openterminal(void);
|
E_FUNC int openterminal(void);
|
||||||
extern DLL int opensearchfile(char *name, char *pathlist, char *exten, int reopen_ok);
|
E_FUNC int opensearchfile(char *name, char *pathlist, char *exten, int reopen_ok);
|
||||||
extern DLL char *nextline(void);
|
E_FUNC char *nextline(void);
|
||||||
extern DLL int nextchar(void);
|
E_FUNC int nextchar(void);
|
||||||
extern DLL void reread(void);
|
E_FUNC void reread(void);
|
||||||
extern DLL void resetinput(void);
|
E_FUNC void resetinput(void);
|
||||||
extern DLL void setprompt(char *);
|
E_FUNC void setprompt(char *);
|
||||||
extern DLL BOOL inputisterminal(void);
|
E_FUNC BOOL inputisterminal(void);
|
||||||
extern DLL int inputlevel(void);
|
E_FUNC int inputlevel(void);
|
||||||
extern DLL long calclevel(void);
|
E_FUNC long calclevel(void);
|
||||||
extern DLL char *inputname(void);
|
E_FUNC char *inputname(void);
|
||||||
extern DLL long linenumber(void);
|
E_FUNC long linenumber(void);
|
||||||
extern DLL void runrcfiles(void);
|
E_FUNC void runrcfiles(void);
|
||||||
extern DLL void closeinput(void);
|
E_FUNC void closeinput(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Other routines.
|
* Other routines.
|
||||||
*/
|
*/
|
||||||
extern DLL NUMBER *constvalue(unsigned long index);
|
E_FUNC NUMBER *constvalue(unsigned long index);
|
||||||
extern DLL long addnumber(char *str);
|
E_FUNC long addnumber(char *str);
|
||||||
extern DLL long addqconstant(NUMBER *q);
|
E_FUNC long addqconstant(NUMBER *q);
|
||||||
extern DLL void initstack(void);
|
E_FUNC void initstack(void);
|
||||||
extern DLL void getcommands(BOOL toplevel);
|
E_FUNC void getcommands(BOOL toplevel);
|
||||||
extern DLL void givehelp(char *type);
|
E_FUNC void givehelp(char *type);
|
||||||
extern DLL void libcalc_call_me_first(void);
|
E_FUNC void libcalc_call_me_first(void);
|
||||||
extern DLL void libcalc_call_me_last(void);
|
E_FUNC void libcalc_call_me_last(void);
|
||||||
extern DLL BOOL calc_tty(int fd);
|
E_FUNC BOOL calc_tty(int fd);
|
||||||
extern DLL BOOL orig_tty(int fd);
|
E_FUNC BOOL orig_tty(int fd);
|
||||||
extern DLL void showerrors(void);
|
E_FUNC void showerrors(void);
|
||||||
extern DLL char *calc_strdup(CONST char *);
|
E_FUNC char *calc_strdup(CONST char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialization
|
* Initialization
|
||||||
*/
|
*/
|
||||||
extern DLL void initialize(void);
|
E_FUNC void initialize(void);
|
||||||
extern DLL void reinitialize(void);
|
E_FUNC void reinitialize(void);
|
||||||
#if !defined (_WIN32)
|
#if !defined (_WIN32)
|
||||||
extern DLL int isatty(int tty); /* TRUE if fd is a tty */
|
E_FUNC int isatty(int tty); /* TRUE if fd is a tty */
|
||||||
#endif
|
#endif
|
||||||
extern DLL char *version(void); /* return version string */
|
E_FUNC char *version(void); /* return version string */
|
||||||
extern DLL int post_init; /* TRUE => math_error setjmp is ready */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* global flags and definitions
|
* global flags and definitions
|
||||||
*/
|
*/
|
||||||
extern DLL int abortlevel; /* current level of aborts */
|
EXTERN int abortlevel; /* current level of aborts */
|
||||||
extern DLL BOOL inputwait; /* TRUE if in a terminal input wait */
|
EXTERN BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||||
extern DLL jmp_buf jmpbuf; /* for errors */
|
|
||||||
|
|
||||||
extern DLL int p_flag; /* TRUE => pipe mode */
|
EXTERN int p_flag; /* TRUE => pipe mode */
|
||||||
extern DLL int q_flag; /* TRUE => don't execute rc files */
|
EXTERN int q_flag; /* TRUE => don't execute rc files */
|
||||||
extern DLL int u_flag; /* TRUE => unbuffer stdin and stdout */
|
EXTERN int u_flag; /* TRUE => unbuffer stdin and stdout */
|
||||||
extern DLL int d_flag; /* TRUE => disable heading, resource_debug */
|
EXTERN int d_flag; /* TRUE => disable heading, resource_debug */
|
||||||
extern DLL int c_flag; /* TRUE => continue after error if permitted */
|
EXTERN int c_flag; /* TRUE => continue after error if permitted */
|
||||||
extern DLL int i_flag; /* TRUE => try to go interactive after error */
|
EXTERN int i_flag; /* TRUE => try to go interactive after error */
|
||||||
extern DLL int s_flag; /* TRUE => keep args as strings for argv() */
|
E_FUNC int s_flag; /* TRUE => keep args as strings for argv() */
|
||||||
extern DLL long stoponerror; /* >0 => stop, <0 => continue, ==0 => use -c */
|
EXTERN long stoponerror; /* >0 => stop, <0 => continue, ==0 => use -c */
|
||||||
extern DLL BOOL abort_now; /* TRUE => try to go interactive */
|
EXTERN BOOL abort_now; /* TRUE => try to go interactive */
|
||||||
|
|
||||||
extern DLL int argc_value; /* count of argv[] strings for argv() builtin */
|
E_FUNC int argc_value; /* count of argv[] strings for argv() builtin */
|
||||||
extern DLL char **argv_value; /* argv[] strings for argv() builtin */
|
E_FUNC char **argv_value; /* argv[] strings for argv() builtin */
|
||||||
|
|
||||||
extern DLL char *pager; /* $PAGER or default */
|
EXTERN char *pager; /* $PAGER or default */
|
||||||
extern DLL int stdin_tty; /* TRUE if stdin is a tty */
|
EXTERN int stdin_tty; /* TRUE if stdin is a tty */
|
||||||
extern DLL int havecommands; /* TRUE if have cmd args) */
|
EXTERN int havecommands; /* TRUE if have cmd args) */
|
||||||
extern DLL char *program; /* our name */
|
EXTERN char *program; /* our name */
|
||||||
extern DLL char *base_name; /* basename of our name */
|
EXTERN char *base_name; /* basename of our name */
|
||||||
extern DLL char cmdbuf[]; /* command line expression */
|
EXTERN char cmdbuf[]; /* command line expression */
|
||||||
|
|
||||||
extern DLL int abortlevel; /* current level of aborts */
|
EXTERN int abortlevel; /* current level of aborts */
|
||||||
extern DLL BOOL inputwait; /* TRUE if in a terminal input wait */
|
EXTERN BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||||
extern DLL VALUE *stack; /* execution stack */
|
EXTERN VALUE *stack; /* execution stack */
|
||||||
extern DLL int dumpnames; /* TRUE => dump names rather than indices */
|
EXTERN int dumpnames; /* TRUE => dump names rather than indices */
|
||||||
|
|
||||||
extern DLL char *calcpath; /* $CALCPATH or default */
|
EXTERN char *calcpath; /* $CALCPATH or default */
|
||||||
extern DLL char *calcrc; /* $CALCRC or default */
|
EXTERN char *calcrc; /* $CALCRC or default */
|
||||||
extern DLL char *calcbindings; /* $CALCBINDINGS or default */
|
EXTERN char *calcbindings; /* $CALCBINDINGS or default */
|
||||||
extern DLL char *home; /* $HOME or default */
|
EXTERN char *home; /* $HOME or default */
|
||||||
extern DLL char *shell; /* $SHELL or default */
|
EXTERN char *shell; /* $SHELL or default */
|
||||||
extern DLL char *program; /* our name (argv[0]) */
|
|
||||||
|
|
||||||
extern DLL int no_env; /* TRUE (-e) => ignore env vars on startup */
|
EXTERN int no_env; /* TRUE (-e) => ignore env vars on startup */
|
||||||
extern DLL long errmax; /* if >= 0, error when errcount exceeds errmax */
|
EXTERN long errmax; /* if >= 0, error when errcount exceeds errmax */
|
||||||
extern DLL int use_old_std; /* TRUE (-O) => use classic configuration */
|
EXTERN int use_old_std; /* TRUE (-O) => use classic configuration */
|
||||||
|
|
||||||
extern DLL int allow_read; /* FALSE => dont open any files for reading */
|
EXTERN int allow_read; /* FALSE => dont open any files for reading */
|
||||||
extern DLL int allow_write; /* FALSE => dont open any files for writing */
|
EXTERN int allow_write; /* FALSE => dont open any files for writing */
|
||||||
extern DLL int allow_exec; /* FALSE => may not execute any commands */
|
EXTERN int allow_exec; /* FALSE => may not execute any commands */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* calc startup and run state
|
* calc startup and run state
|
||||||
@@ -253,19 +250,19 @@ typedef enum {
|
|||||||
RUN_EXIT, /* normal exit from calc */
|
RUN_EXIT, /* normal exit from calc */
|
||||||
RUN_EXIT_WITH_ERROR /* exit with error */
|
RUN_EXIT_WITH_ERROR /* exit with error */
|
||||||
} run;
|
} run;
|
||||||
extern DLL run run_state;
|
EXTERN run run_state;
|
||||||
extern DLL char *run_state_name(run state);
|
E_FUNC char *run_state_name(run state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* calc version information
|
* calc version information
|
||||||
*/
|
*/
|
||||||
#define CALC_TITLE "C-style arbitrary precision calculator"
|
#define CALC_TITLE "C-style arbitrary precision calculator"
|
||||||
extern int calc_major_ver;
|
EXTERN int calc_major_ver;
|
||||||
extern int calc_minor_ver;
|
EXTERN int calc_minor_ver;
|
||||||
extern int calc_major_patch;
|
EXTERN int calc_major_patch;
|
||||||
extern int calc_minor_patch;
|
EXTERN int calc_minor_patch;
|
||||||
extern char *Copyright;
|
EXTERN char *Copyright;
|
||||||
extern DLL char *version(void);
|
E_FUNC char *version(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__CALC_H__ */
|
#endif /* !__CALC_H__ */
|
||||||
|
43
calc.man
43
calc.man
@@ -1,5 +1,5 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" Copyright (C) 1999-2004 Landon Curt Noll
|
.\" Copyright (C) 1999-2007 Landon Curt Noll
|
||||||
.\"
|
.\"
|
||||||
.\" Calc is open software; you can redistribute it and/or modify it under
|
.\" 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
|
.\" the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -13,10 +13,10 @@
|
|||||||
.\" A copy of version 2.1 of the GNU Lesser General Public License is
|
.\" 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
|
.\" distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
.\" received a copy with calc; if not, write to Free Software Foundation, Inc.
|
.\" received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
.\" 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
.\"
|
.\"
|
||||||
.\" @(#) $Revision: 29.18 $
|
.\" @(#) $Revision: 30.3 $
|
||||||
.\" @(#) $Id: calc.man,v 29.18 2005/10/18 11:10:18 chongo Exp $
|
.\" @(#) $Id: calc.man,v 30.3 2007/09/08 02:53:09 chongo Exp $
|
||||||
.\" @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.man,v $
|
.\" @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.man,v $
|
||||||
.\"
|
.\"
|
||||||
.\" Under source code control: 1991/07/23 05:48:26
|
.\" Under source code control: 1991/07/23 05:48:26
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
.\" calculator by David I. Bell
|
.\" calculator by David I. Bell
|
||||||
.\" man page by Landon Noll
|
.\" man page by Landon Noll
|
||||||
.\"
|
.\"
|
||||||
.TH calc 1 "^..^" "1999-11-30"
|
.TH calc 1 "^..^" "2007-02-06"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
calc \- arbitrary precision calculator
|
calc \- arbitrary precision calculator
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -63,8 +63,11 @@ CALC OPTIONS
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-c
|
.B \-c
|
||||||
Continue reading command lines even after an execution
|
Continue reading command lines even after a scan/parse
|
||||||
error has caused the abandonment of a line.
|
error has caused the abandonment of a line.
|
||||||
|
Note that this option only deals with scanning and
|
||||||
|
parsing of the calc language.
|
||||||
|
It does not deal with execution or run-time errors.
|
||||||
.sp 1
|
.sp 1
|
||||||
For example:
|
For example:
|
||||||
.sp 1
|
.sp 1
|
||||||
@@ -76,7 +79,7 @@ calc read many_errors.cal
|
|||||||
.sp 1
|
.sp 1
|
||||||
will cause
|
will cause
|
||||||
.B calc
|
.B calc
|
||||||
to abort on the first error, whereas:
|
to abort on the first syntax error, whereas:
|
||||||
.sp 1
|
.sp 1
|
||||||
.in +5n
|
.in +5n
|
||||||
.nf
|
.nf
|
||||||
@@ -88,7 +91,7 @@ will
|
|||||||
cause
|
cause
|
||||||
.B calc
|
.B calc
|
||||||
to try to process each line being read
|
to try to process each line being read
|
||||||
despite the errors that it encounters.
|
despite the scan/parse errors that it encounters.
|
||||||
.sp 1
|
.sp 1
|
||||||
By default, calc startup resource files are silently
|
By default, calc startup resource files are silently
|
||||||
ignored if not found.
|
ignored if not found.
|
||||||
@@ -222,7 +225,7 @@ filename
|
|||||||
.sp 1
|
.sp 1
|
||||||
On systems that treat an executable that begins with
|
On systems that treat an executable that begins with
|
||||||
.B #!
|
.B #!
|
||||||
as a script, the path of the execurable is appended by the kernel
|
as a script, the path of the executable is appended by the kernel
|
||||||
as the final argument to the exec() system call.
|
as the final argument to the exec() system call.
|
||||||
This is why the
|
This is why the
|
||||||
.B \-f
|
.B \-f
|
||||||
@@ -272,18 +275,14 @@ See
|
|||||||
.TP
|
.TP
|
||||||
.B \-i
|
.B \-i
|
||||||
Become interactive if possible.
|
Become interactive if possible.
|
||||||
If
|
|
||||||
.I calc_cmd
|
|
||||||
args are given,
|
|
||||||
.B calc
|
|
||||||
by default, calc will execute them and exit.
|
|
||||||
This flag causes
|
|
||||||
.B calc
|
|
||||||
to drop into interactive mode after the commands are executed.
|
|
||||||
This flag will cause
|
This flag will cause
|
||||||
.B calc
|
.B calc
|
||||||
to drop into interactive mode after the
|
to drop into interactive mode after the
|
||||||
commands are executed.
|
.I calc_cmd
|
||||||
|
arguments on the command line are evaluated.
|
||||||
|
Without this flag,
|
||||||
|
.B calc
|
||||||
|
will exit after they are evaluated.
|
||||||
.sp 1
|
.sp 1
|
||||||
For example:
|
For example:
|
||||||
.sp 1
|
.sp 1
|
||||||
@@ -703,7 +702,7 @@ the rest of the file will be processed in
|
|||||||
.BR "shell script mode" .
|
.BR "shell script mode" .
|
||||||
Note that
|
Note that
|
||||||
.B \-f
|
.B \-f
|
||||||
must at the end of the intiial ``#!'' line.
|
must at the end of the initial ``#!'' line.
|
||||||
Any other optional
|
Any other optional
|
||||||
.B "other_flags"
|
.B "other_flags"
|
||||||
must come before
|
must come before
|
||||||
@@ -1075,9 +1074,9 @@ If you do not have these files, write to:
|
|||||||
.in +0.5i
|
.in +0.5i
|
||||||
.nf
|
.nf
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
59 Temple Place
|
51 Franklin Street
|
||||||
Suite 330
|
Fifth Floor
|
||||||
Boston, MA 02111-1307
|
Boston, MA 02110-1301
|
||||||
USA
|
USA
|
||||||
.fi
|
.fi
|
||||||
.in -0.5i
|
.in -0.5i
|
||||||
|
74
calc.spec.in
74
calc.spec.in
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# calc.spec.in - template specfile for calc
|
# calc.spec.in - template specfile for calc
|
||||||
#
|
#
|
||||||
# Copyright (C) 2003-2005 Petteri Kettunen and Landon Curt Noll
|
# Copyright (C) 2003-2007 Petteri Kettunen and Landon Curt Noll
|
||||||
#
|
#
|
||||||
# Calc is open software; you can redistribute it and/or modify it under
|
# 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
|
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
# 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
|
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.15 $
|
# @(#) $Revision: 30.6 $
|
||||||
# @(#) $Id: calc.spec.in,v 29.15 2006/05/21 06:26:00 chongo Exp $
|
# @(#) $Id: calc.spec.in,v 30.6 2007/10/16 12:22:22 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.spec.in,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.spec.in,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 2003/02/16 20:21:39
|
# Under source code control: 2003/02/16 20:21:39
|
||||||
@@ -37,10 +37,10 @@
|
|||||||
Summary: Arbitrary precision calculator.
|
Summary: Arbitrary precision calculator.
|
||||||
Name: calc
|
Name: calc
|
||||||
Version: <<<PROJECT_VERSION>>>
|
Version: <<<PROJECT_VERSION>>>
|
||||||
Release: 0
|
Release: 1.1
|
||||||
Copyright: LGPL
|
License: LGPL
|
||||||
Group: Applications/Engineering
|
Group: Applications/Engineering
|
||||||
Source: %{name}-%{version}.tar.gz
|
Source: %{name}-%{version}.tar.bz2
|
||||||
URL: http://www.isthe.com/chongo/tech/comp/calc/index.html
|
URL: http://www.isthe.com/chongo/tech/comp/calc/index.html
|
||||||
Requires: ncurses >= 5.2-26, readline >= 4.2, less >= 358
|
Requires: ncurses >= 5.2-26, readline >= 4.2, less >= 358
|
||||||
BuildRequires: ncurses-devel >= 5.2-26, readline-devel >= 4.2
|
BuildRequires: ncurses-devel >= 5.2-26, readline-devel >= 4.2
|
||||||
@@ -73,12 +73,40 @@ For the latest calc release, see the project home page:
|
|||||||
%setup -q
|
%setup -q
|
||||||
|
|
||||||
%build
|
%build
|
||||||
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 all chk
|
echo '-=- calc.spec beginning make clobber -=-'
|
||||||
|
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 EXT= V=@ clobber
|
||||||
|
echo '-=- calc.spec ending make clobber -=-'
|
||||||
|
echo '-=- calc.spec beginning make calc-static-only -=-'
|
||||||
|
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 EXT= V=@ calc-static-only BLD_TYPE=calc-static-only
|
||||||
|
echo '-=- calc.spec ending make calc-static-only -=-'
|
||||||
|
echo '-=- calc.spec beginning make rpm-hide-static -=-'
|
||||||
|
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 EXT= V=@ rpm-hide-static
|
||||||
|
echo '-=- calc.spec ending make rpm-hide-static -=-'
|
||||||
|
echo '-=- calc.spec beginning make clobber (again) -=-'
|
||||||
|
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 EXT= V=@ clobber
|
||||||
|
echo '-=- calc.spec ending make clobber (again) -=-'
|
||||||
|
echo '-=- calc.spec beginning make calc-dynamic-only -=-'
|
||||||
|
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 EXT= V=@ calc-dynamic-only BLD_TYPE=calc-dynamic-only LD_SHARE=
|
||||||
|
echo '-=- calc.spec ending make calc-dynamic-only -=-'
|
||||||
|
echo '-=- calc.spec beginning make chk -=-'
|
||||||
|
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 EXT= V=@ chk
|
||||||
|
echo '-=- calc.spec ending make chk -=-'
|
||||||
|
echo '-=- calc.spec beginning make rpm-unhide-static -=-'
|
||||||
|
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 EXT= V=@ rpm-unhide-static
|
||||||
|
echo '-=- calc.spec ending make rpm-unhide-static -=-'
|
||||||
|
echo '-=- calc.spec beginning make rpm-clean-static -=-'
|
||||||
|
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 EXT= V=@ rpm-clean-static
|
||||||
|
echo '-=- calc.spec ending make rpm-clean-static -=-'
|
||||||
|
echo '-=- calc.spec beginning make rpm-chk-static -=-'
|
||||||
|
make %{?_smp_mflags} T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 EXT= V=@ rpm-chk-static
|
||||||
|
echo '-=- calc.spec ending make rpm-chk-static -=-'
|
||||||
|
|
||||||
%install
|
%install
|
||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
mkdir -p %{buildroot}
|
mkdir -p %{buildroot}
|
||||||
make T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 install
|
echo '-=- calc.spec beginning make install -=-'
|
||||||
|
make T=%{buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc MANDIR=%{_mandir}/man1 EXT= V=@ install
|
||||||
|
echo '-=- calc.spec ending make install -=-'
|
||||||
|
|
||||||
%clean
|
%clean
|
||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
@@ -86,21 +114,33 @@ rm -rf %{buildroot}
|
|||||||
%files
|
%files
|
||||||
%defattr(-, root, root)
|
%defattr(-, root, root)
|
||||||
%doc BUGS CHANGES COPYING COPYING-LGPL
|
%doc BUGS CHANGES COPYING COPYING-LGPL
|
||||||
%{_bindir}/*
|
%attr(755, root, root) %{_bindir}/calc
|
||||||
%{_mandir}/man1/*
|
%attr(755, root, root) %{_bindir}/cscript/*
|
||||||
%{_datadir}/%{name}/*/*
|
%attr(644, root, root) %{_mandir}/man1/calc.1.gz
|
||||||
%{_datadir}/%{name}/bindings
|
%attr(644, root, root) %{_datadir}/%{name}/README
|
||||||
%{_datadir}/%{name}/README
|
%attr(644, root, root) %{_datadir}/%{name}/bindings
|
||||||
%{_datadir}/%{name}/*.cal
|
%attr(644, root, root) %{_datadir}/%{name}/custhelp/*
|
||||||
%{_datadir}/%{name}/*.line
|
%attr(644, root, root) %{_datadir}/%{name}/custom/*.cal
|
||||||
|
%attr(644, root, root) %{_datadir}/%{name}/help/*
|
||||||
|
%attr(644, root, root) %{_datadir}/%{name}/*.cal
|
||||||
|
%attr(644, root, root) %{_datadir}/%{name}/*.line
|
||||||
|
%attr(644, root, root) %{_libdir}/libcalc.so.%{version}
|
||||||
|
%attr(644, root, root) %{_libdir}/libcustcalc.so.%{version}
|
||||||
|
|
||||||
%files devel
|
%files devel
|
||||||
%defattr(-, root, root)
|
%defattr(-, root, root)
|
||||||
%doc BUGS COPYING COPYING-LGPL LIBRARY
|
%doc BUGS COPYING COPYING-LGPL LIBRARY
|
||||||
|
%attr(755, root, root) %{_bindir}/calc-static
|
||||||
%attr(644, root, root) %{_includedir}/calc/*
|
%attr(644, root, root) %{_includedir}/calc/*
|
||||||
%attr(644, root, root) %{_libdir}/*.a
|
%attr(644, root, root) %{_libdir}/libcalc.a
|
||||||
|
%attr(644, root, root) %{_libdir}/libcustcalc.a
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sun Sep 01 2007 Landon Curt Noll http://www.isthe.com/chongo
|
||||||
|
- Release of calc-2.12.2
|
||||||
|
- Calc builds with shared libraries
|
||||||
|
* Sun Jun 25 2006 Landon Curt Noll http://www.isthe.com/chongo
|
||||||
|
- Changed Copyright to License as per new rpm v4.4 syntax
|
||||||
* Sun May 20 2006 Landon Curt Noll http://www.isthe.com/chongo
|
* Sun May 20 2006 Landon Curt Noll http://www.isthe.com/chongo
|
||||||
- Release of calc-2.12.0
|
- Release of calc-2.12.0
|
||||||
- Added *.line set files to the list of packaged files
|
- Added *.line set files to the list of packaged files
|
||||||
|
18
calcerr.tbl
18
calcerr.tbl
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# calcerr - error codes and messages
|
# calcerr - error codes and messages
|
||||||
#
|
#
|
||||||
# Copyright (C) 1999 Ernest Bowen
|
# Copyright (C) 1999-2006 Ernest Bowen
|
||||||
#
|
#
|
||||||
# Calc is open software; you can redistribute it and/or modify it under
|
# 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
|
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
# 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
|
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.8 $
|
# @(#) $Revision: 30.1 $
|
||||||
# @(#) $Id: calcerr.tbl,v 29.8 2006/05/19 15:12:57 chongo Exp $
|
# @(#) $Id: calcerr.tbl,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr.tbl,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr.tbl,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1996/05/23 17:38:44
|
# Under source code control: 1996/05/23 17:38:44
|
||||||
@@ -404,9 +404,9 @@ E_ASSIGN8 No-type-change destination for assign
|
|||||||
E_ASSIGN9 No-error-value destination for assign
|
E_ASSIGN9 No-error-value destination for assign
|
||||||
E_SWAP1 No-copy argument for octet swap
|
E_SWAP1 No-copy argument for octet swap
|
||||||
E_SWAP2 No-assign-to-or-from argument for swap
|
E_SWAP2 No-assign-to-or-from argument for swap
|
||||||
E_SWAP3 Non-variable argument for swap
|
E_SWAP3 Non-lvalue argument for swap
|
||||||
E_QUOMOD1 Non-variable argument 4 or 4 for quomod
|
E_QUOMOD1 Non-lvalue argument 3 or 4 for quomod
|
||||||
E_QUOMOD2 Non-real-number argument 1 or 2 for quomod
|
E_QUOMOD2 Non-real-number arg 1 or 2 or bad arg 5 for quomod
|
||||||
E_QUOMOD3 No-assign-to argument 3 or 4 for quomod
|
E_QUOMOD3 No-assign-to argument 3 or 4 for quomod
|
||||||
E_PREINC1 No-copy-to or no-change argument for octet preinc
|
E_PREINC1 No-copy-to or no-change argument for octet preinc
|
||||||
E_PREINC2 Non-variable argument for preinc
|
E_PREINC2 Non-variable argument for preinc
|
||||||
@@ -445,3 +445,7 @@ E_FPATHOPEN1 Non-string arguments for fpathopen
|
|||||||
E_FPATHOPEN2 Unrecognized mode for fpathopen
|
E_FPATHOPEN2 Unrecognized mode for fpathopen
|
||||||
E_LOG1 Bad epsilon argument for log
|
E_LOG1 Bad epsilon argument for log
|
||||||
E_LOG2 Non-numeric first argument for log
|
E_LOG2 Non-numeric first argument for log
|
||||||
|
E_FGETFILE1 Non-file argument for fgetfile
|
||||||
|
E_FGETFILE2 File argument for fgetfile not open for reading
|
||||||
|
E_FGETFILE3 Unable to set file position in fgetfile
|
||||||
|
E_ESTR Non-representable type for estr
|
||||||
|
@@ -16,10 +16,10 @@
|
|||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
# 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
|
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.2 $
|
# @(#) $Revision: 30.1 $
|
||||||
# @(#) $Id: calcerr_c.awk,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
# @(#) $Id: calcerr_c.awk,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_c.awk,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_c.awk,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1996/05/24 03:15:35
|
# Under source code control: 1996/05/24 03:15:35
|
||||||
|
@@ -16,10 +16,10 @@
|
|||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
# 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
|
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.2 $
|
# @(#) $Revision: 30.1 $
|
||||||
# @(#) $Id: calcerr_c.sed,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
# @(#) $Id: calcerr_c.sed,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_c.sed,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_c.sed,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1996/05/24 03:15:35
|
# Under source code control: 1996/05/24 03:15:35
|
||||||
|
@@ -16,10 +16,10 @@
|
|||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
# 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
|
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.2 $
|
# @(#) $Revision: 30.1 $
|
||||||
# @(#) $Id: calcerr_h.awk,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
# @(#) $Id: calcerr_h.awk,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_h.awk,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_h.awk,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1996/05/23 17:38:44
|
# Under source code control: 1996/05/23 17:38:44
|
||||||
|
@@ -16,10 +16,10 @@
|
|||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
# 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
|
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.2 $
|
# @(#) $Revision: 30.1 $
|
||||||
# @(#) $Id: calcerr_h.sed,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
# @(#) $Id: calcerr_h.sed,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_h.sed,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_h.sed,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1996/05/23 17:38:44
|
# Under source code control: 1996/05/23 17:38:44
|
||||||
|
@@ -16,10 +16,10 @@
|
|||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
# 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
|
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.3 $
|
# @(#) $Revision: 30.1 $
|
||||||
# @(#) $Id: check.awk,v 29.3 2006/05/20 19:43:39 chongo Exp $
|
# @(#) $Id: check.awk,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/check.awk,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/RCS/check.awk,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1996/05/25 22:07:58
|
# Under source code control: 1996/05/25 22:07:58
|
||||||
@@ -64,7 +64,7 @@ NF == 0 {
|
|||||||
end_seen = 1;
|
end_seen = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$1 ~ /^[0-9]+:/ || $1 ~ /^[0-9]+-[0-9]*:/ {
|
$1 ~ /^[0-9]+:/ || $1 ~ /^[0-9]+-[0-9]*:/ || $1 ~ /^"\)\)$/ {
|
||||||
if (error > 0) {
|
if (error > 0) {
|
||||||
if (havebuf2) {
|
if (havebuf2) {
|
||||||
print buf2;
|
print buf2;
|
||||||
|
120
cmath.h
120
cmath.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* cmath - data structures for extended precision complex arithmetic
|
* cmath - data structures for extended precision complex arithmetic
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 David I. Bell
|
* Copyright (C) 1999-2007 David I. Bell
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.7 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: cmath.h,v 29.7 2005/10/18 10:43:49 chongo Exp $
|
* @(#) $Id: cmath.h,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/cmath.h,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/cmath.h,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1993/07/30 19:42:45
|
* Under source code control: 1993/07/30 19:42:45
|
||||||
@@ -52,84 +52,84 @@ typedef struct {
|
|||||||
/*
|
/*
|
||||||
* Input, output, and conversion routines.
|
* Input, output, and conversion routines.
|
||||||
*/
|
*/
|
||||||
extern COMPLEX *comalloc(void);
|
E_FUNC COMPLEX *comalloc(void);
|
||||||
extern COMPLEX *qqtoc(NUMBER *q1, NUMBER *q2);
|
E_FUNC COMPLEX *qqtoc(NUMBER *q1, NUMBER *q2);
|
||||||
extern void comfree(COMPLEX *c);
|
E_FUNC void comfree(COMPLEX *c);
|
||||||
extern void comprint(COMPLEX *c);
|
E_FUNC void comprint(COMPLEX *c);
|
||||||
extern void cprintfr(COMPLEX *c);
|
E_FUNC void cprintfr(COMPLEX *c);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Basic numeric routines.
|
* Basic numeric routines.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern COMPLEX *c_add(COMPLEX *c1, COMPLEX *c2);
|
E_FUNC COMPLEX *c_add(COMPLEX *c1, COMPLEX *c2);
|
||||||
extern COMPLEX *c_sub(COMPLEX *c1, COMPLEX *c2);
|
E_FUNC COMPLEX *c_sub(COMPLEX *c1, COMPLEX *c2);
|
||||||
extern COMPLEX *c_mul(COMPLEX *c1, COMPLEX *c2);
|
E_FUNC COMPLEX *c_mul(COMPLEX *c1, COMPLEX *c2);
|
||||||
extern COMPLEX *c_div(COMPLEX *c1, COMPLEX *c2);
|
E_FUNC COMPLEX *c_div(COMPLEX *c1, COMPLEX *c2);
|
||||||
extern COMPLEX *c_addq(COMPLEX *c, NUMBER *q);
|
E_FUNC COMPLEX *c_addq(COMPLEX *c, NUMBER *q);
|
||||||
extern COMPLEX *c_subq(COMPLEX *c, NUMBER *q);
|
E_FUNC COMPLEX *c_subq(COMPLEX *c, NUMBER *q);
|
||||||
extern COMPLEX *c_mulq(COMPLEX *c, NUMBER *q);
|
E_FUNC COMPLEX *c_mulq(COMPLEX *c, NUMBER *q);
|
||||||
extern COMPLEX *c_divq(COMPLEX *c, NUMBER *q);
|
E_FUNC COMPLEX *c_divq(COMPLEX *c, NUMBER *q);
|
||||||
extern COMPLEX *c_scale(COMPLEX *c, long i);
|
E_FUNC COMPLEX *c_scale(COMPLEX *c, long i);
|
||||||
extern COMPLEX *c_shift(COMPLEX *c, long i);
|
E_FUNC COMPLEX *c_shift(COMPLEX *c, long i);
|
||||||
extern COMPLEX *c_square(COMPLEX *c);
|
E_FUNC COMPLEX *c_square(COMPLEX *c);
|
||||||
extern COMPLEX *c_conj(COMPLEX *c);
|
E_FUNC COMPLEX *c_conj(COMPLEX *c);
|
||||||
extern COMPLEX *c_real(COMPLEX *c);
|
E_FUNC COMPLEX *c_real(COMPLEX *c);
|
||||||
extern COMPLEX *c_imag(COMPLEX *c);
|
E_FUNC COMPLEX *c_imag(COMPLEX *c);
|
||||||
extern COMPLEX *c_neg(COMPLEX *c);
|
E_FUNC COMPLEX *c_neg(COMPLEX *c);
|
||||||
extern COMPLEX *c_inv(COMPLEX *c);
|
E_FUNC COMPLEX *c_inv(COMPLEX *c);
|
||||||
extern COMPLEX *c_int(COMPLEX *c);
|
E_FUNC COMPLEX *c_int(COMPLEX *c);
|
||||||
extern COMPLEX *c_frac(COMPLEX *c);
|
E_FUNC COMPLEX *c_frac(COMPLEX *c);
|
||||||
extern BOOL c_cmp(COMPLEX *c1, COMPLEX *c2);
|
E_FUNC BOOL c_cmp(COMPLEX *c1, COMPLEX *c2);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* More complicated functions.
|
* More complicated functions.
|
||||||
*/
|
*/
|
||||||
extern COMPLEX *c_powi(COMPLEX *c, NUMBER *q);
|
E_FUNC COMPLEX *c_powi(COMPLEX *c, NUMBER *q);
|
||||||
extern NUMBER *c_ilog(COMPLEX *c, ZVALUE base);
|
E_FUNC NUMBER *c_ilog(COMPLEX *c, ZVALUE base);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Transcendental routines. These all take an epsilon argument to
|
* Transcendental routines. These all take an epsilon argument to
|
||||||
* specify how accurately these are to be calculated.
|
* specify how accurately these are to be calculated.
|
||||||
*/
|
*/
|
||||||
extern COMPLEX *c_power(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_power(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_sqrt(COMPLEX *c, NUMBER *epsilon, long R);
|
E_FUNC COMPLEX *c_sqrt(COMPLEX *c, NUMBER *epsilon, long R);
|
||||||
extern COMPLEX *c_root(COMPLEX *c, NUMBER *q, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_root(COMPLEX *c, NUMBER *q, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_exp(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_exp(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_ln(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_ln(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_log(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_log(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_cos(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_cos(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_sin(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_sin(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_cosh(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_cosh(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_sinh(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_sinh(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_polar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_polar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_rel(COMPLEX *c1, COMPLEX *c2);
|
E_FUNC COMPLEX *c_rel(COMPLEX *c1, COMPLEX *c2);
|
||||||
extern COMPLEX *c_asin(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_asin(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_acos(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_acos(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_atan(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_atan(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_acot(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_acot(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_asec(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_asec(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_acsc(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_acsc(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_asinh(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_asinh(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_acosh(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_acosh(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_atanh(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_atanh(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_acoth(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_acoth(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_asech(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_asech(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_acsch(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_acsch(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_gd(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_gd(COMPLEX *c, NUMBER *epsilon);
|
||||||
extern COMPLEX *c_agd(COMPLEX *c, NUMBER *epsilon);
|
E_FUNC COMPLEX *c_agd(COMPLEX *c, NUMBER *epsilon);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* external functions
|
* external functions
|
||||||
*/
|
*/
|
||||||
extern COMPLEX *swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
E_FUNC COMPLEX *swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
||||||
extern COMPLEX *swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
E_FUNC COMPLEX *swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
||||||
extern COMPLEX *swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
E_FUNC COMPLEX *swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -153,7 +153,7 @@ extern COMPLEX *swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
|||||||
/*
|
/*
|
||||||
* Pre-defined values.
|
* Pre-defined values.
|
||||||
*/
|
*/
|
||||||
extern COMPLEX _czero_, _cone_, _conei_;
|
EXTERN COMPLEX _czero_, _cone_, _conei_;
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__CMATH_H__ */
|
#endif /* !__CMATH_H__ */
|
||||||
|
402
codegen.c
402
codegen.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* codegen - module to generate opcodes from the input tokens
|
* codegen - module to generate opcodes from the input tokens
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2006 David I. Bell and Ernest Bowen
|
* Copyright (C) 1999-2007 David I. Bell and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: David I. Bell
|
* Primary author: David I. Bell
|
||||||
*
|
*
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.15 $
|
* @(#) $Revision: 30.2 $
|
||||||
* @(#) $Id: codegen.c,v 29.15 2006/05/20 09:42:57 chongo Exp $
|
* @(#) $Id: codegen.c,v 30.2 2007/07/05 13:30:38 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/codegen.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/codegen.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:48:13
|
* Under source code control: 1990/02/15 01:48:13
|
||||||
@@ -36,12 +36,13 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "lib_calc.h"
|
||||||
#include "calc.h"
|
#include "calc.h"
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
#include "opcodes.h"
|
#include "opcodes.h"
|
||||||
#include "string.h"
|
#include "str.h"
|
||||||
#include "func.h"
|
#include "func.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
@@ -49,61 +50,61 @@
|
|||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static BOOL rdonce; /* TRUE => do not reread this file */
|
STATIC BOOL rdonce; /* TRUE => do not reread this file */
|
||||||
|
|
||||||
FUNC *curfunc;
|
FUNC *curfunc;
|
||||||
|
|
||||||
static int getsymvalue(char *name, VALUE *v_p);
|
S_FUNC int getsymvalue(char *name, VALUE *v_p);
|
||||||
static int getfilename(char *name, size_t namelen, BOOL *once);
|
S_FUNC int getfilename(char *name, size_t namelen, BOOL *once);
|
||||||
static BOOL getid(char *buf);
|
S_FUNC BOOL getid(char *buf);
|
||||||
static void getshowstatement(void);
|
S_FUNC void getshowstatement(void);
|
||||||
static void getfunction(void);
|
S_FUNC void getfunction(void);
|
||||||
static void ungetfunction(void);
|
S_FUNC void ungetfunction(void);
|
||||||
static void getbody(LABEL *contlabel, LABEL *breaklabel,
|
S_FUNC void getbody(LABEL *contlabel, LABEL *breaklabel,
|
||||||
LABEL *nextcaselabel, LABEL *defaultlabel);
|
LABEL *nextcaselabel, LABEL *defaultlabel);
|
||||||
static int getdeclarations(int symtype);
|
S_FUNC int getdeclarations(int symtype);
|
||||||
static int getsimpledeclaration (int symtype);
|
S_FUNC int getsimpledeclaration (int symtype);
|
||||||
static int getonevariable (int symtype);
|
S_FUNC int getonevariable (int symtype);
|
||||||
static void getstatement(LABEL *contlabel, LABEL *breaklabel,
|
S_FUNC void getstatement(LABEL *contlabel, LABEL *breaklabel,
|
||||||
LABEL *nextcaselabel, LABEL *defaultlabel);
|
LABEL *nextcaselabel, LABEL *defaultlabel);
|
||||||
static void getobjdeclaration(int symtype);
|
S_FUNC void getobjdeclaration(int symtype);
|
||||||
static void getoneobj(long index, int symtype);
|
S_FUNC void getoneobj(long index, int symtype);
|
||||||
static void getobjvars(char *name, int symtype);
|
S_FUNC void getobjvars(char *name, int symtype);
|
||||||
static void getmatdeclaration(int symtype);
|
S_FUNC void getmatdeclaration(int symtype);
|
||||||
static void getonematrix(int symtype);
|
S_FUNC void getonematrix(int symtype);
|
||||||
static void creatematrix(void);
|
S_FUNC void creatematrix(void);
|
||||||
static void getsimplebody(void);
|
S_FUNC void getsimplebody(void);
|
||||||
static void getcondition(void);
|
S_FUNC void getcondition(void);
|
||||||
static void getmatargs(void);
|
S_FUNC void getmatargs(void);
|
||||||
static void getelement(void);
|
S_FUNC void getelement(void);
|
||||||
static void usesymbol(char *name, int autodef);
|
S_FUNC void usesymbol(char *name, int autodef);
|
||||||
static void definesymbol(char *name, int symtype);
|
S_FUNC void definesymbol(char *name, int symtype);
|
||||||
static void getcallargs(char *name);
|
S_FUNC void getcallargs(char *name);
|
||||||
static void do_changedir(void);
|
S_FUNC void do_changedir(void);
|
||||||
static int getexprlist(void);
|
S_FUNC int getexprlist(void);
|
||||||
static int getopassignment(void);
|
S_FUNC int getopassignment(void);
|
||||||
static int getassignment(void);
|
S_FUNC int getassignment(void);
|
||||||
static int getaltcond(void);
|
S_FUNC int getaltcond(void);
|
||||||
static int getorcond(void);
|
S_FUNC int getorcond(void);
|
||||||
static int getandcond(void);
|
S_FUNC int getandcond(void);
|
||||||
static int getrelation(void);
|
S_FUNC int getrelation(void);
|
||||||
static int getsum(void);
|
S_FUNC int getsum(void);
|
||||||
static int getproduct(void);
|
S_FUNC int getproduct(void);
|
||||||
static int getorexpr(void);
|
S_FUNC int getorexpr(void);
|
||||||
static int getandexpr(void);
|
S_FUNC int getandexpr(void);
|
||||||
static int getshiftexpr(void);
|
S_FUNC int getshiftexpr(void);
|
||||||
static int getreference(void);
|
S_FUNC int getreference(void);
|
||||||
static int getincdecexpr(void);
|
S_FUNC int getincdecexpr(void);
|
||||||
static int getterm(void);
|
S_FUNC int getterm(void);
|
||||||
static int getidexpr(BOOL okmat, int autodef);
|
S_FUNC int getidexpr(BOOL okmat, int autodef);
|
||||||
static long getinitlist(void);
|
S_FUNC long getinitlist(void);
|
||||||
|
|
||||||
#define INDICALLOC 8
|
#define INDICALLOC 8
|
||||||
|
|
||||||
static int quickindices[INDICALLOC];
|
STATIC int quickindices[INDICALLOC];
|
||||||
static int * newindices;
|
STATIC int * newindices;
|
||||||
static int * indices;
|
STATIC int * indices;
|
||||||
static int maxindices;
|
STATIC int maxindices;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -136,10 +137,6 @@ getcommands(BOOL toplevel)
|
|||||||
getfunction();
|
getfunction();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_UNDEFINE:
|
|
||||||
ungetfunction();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_EOF:
|
case T_EOF:
|
||||||
if (!toplevel)
|
if (!toplevel)
|
||||||
exitfilescope();
|
exitfilescope();
|
||||||
@@ -148,6 +145,7 @@ getcommands(BOOL toplevel)
|
|||||||
case T_HELP:
|
case T_HELP:
|
||||||
for (i=1;;i++) {
|
for (i=1;;i++) {
|
||||||
switch(getfilename(name, MAXCMD+1, NULL)) {
|
switch(getfilename(name, MAXCMD+1, NULL)) {
|
||||||
|
case 1:
|
||||||
case -1:
|
case -1:
|
||||||
if(i == 1) {
|
if(i == 1) {
|
||||||
strcpy(name, DEFAULTCALCHELP);
|
strcpy(name, DEFAULTCALCHELP);
|
||||||
@@ -230,7 +228,14 @@ getcommands(BOOL toplevel)
|
|||||||
run_state = RUN_EXIT;
|
run_state = RUN_EXIT;
|
||||||
else if (run_state < RUN_PRE_TOP_LEVEL)
|
else if (run_state < RUN_PRE_TOP_LEVEL)
|
||||||
run_state = RUN_PRE_TOP_LEVEL;
|
run_state = RUN_PRE_TOP_LEVEL;
|
||||||
longjmp(jmpbuf, 1);
|
if (calc_use_scanerr_jmpbuf != 0) {
|
||||||
|
longjmp(calc_scanerr_jmpbuf, 30);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr,
|
||||||
|
"calc_scanerr_jmpbuf not setup, exiting code 30\n");
|
||||||
|
libcalc_call_me_last();
|
||||||
|
exit(30);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,7 +297,7 @@ evaluate(BOOL nestflag)
|
|||||||
/*
|
/*
|
||||||
* Undefine one or more functions
|
* Undefine one or more functions
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
ungetfunction(void)
|
ungetfunction(void)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
@@ -306,8 +311,8 @@ ungetfunction(void)
|
|||||||
name = tokensymbol();
|
name = tokensymbol();
|
||||||
type = getbuiltinfunc(name);
|
type = getbuiltinfunc(name);
|
||||||
if (type >= 0) {
|
if (type >= 0) {
|
||||||
fprintf(stderr,
|
warning(
|
||||||
"Attempt to undefine builtin function \"%s\" ignored\n", name);
|
"Cannot undefine builtin function \"%s\"", name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
rmuserfunc(name);
|
rmuserfunc(name);
|
||||||
@@ -315,6 +320,16 @@ ungetfunction(void)
|
|||||||
case T_MULT:
|
case T_MULT:
|
||||||
rmalluserfunc();
|
rmalluserfunc();
|
||||||
continue;
|
continue;
|
||||||
|
case T_STATIC:
|
||||||
|
if (gettoken() != T_SYMBOL) {
|
||||||
|
scanerror(T_SEMICOLON,
|
||||||
|
"Non-identifier following \"undefine static\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
name = tokensymbol();
|
||||||
|
endscope(name, FALSE);
|
||||||
|
continue;
|
||||||
|
|
||||||
case T_NEWLINE:
|
case T_NEWLINE:
|
||||||
case T_SEMICOLON:
|
case T_SEMICOLON:
|
||||||
case T_EOF:
|
case T_EOF:
|
||||||
@@ -333,7 +348,7 @@ ungetfunction(void)
|
|||||||
* func = name '(' '' | name [ ',' name] ... ')' simplebody
|
* func = name '(' '' | name [ ',' name] ... ')' simplebody
|
||||||
* | name '(' '' | name [ ',' name] ... ')' body.
|
* | name '(' '' | name [ ',' name] ... ')' body.
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
getfunction(void)
|
getfunction(void)
|
||||||
{
|
{
|
||||||
char *name; /* parameter name */
|
char *name; /* parameter name */
|
||||||
@@ -365,7 +380,8 @@ getfunction(void)
|
|||||||
if (type == T_RIGHTPAREN)
|
if (type == T_RIGHTPAREN)
|
||||||
break;
|
break;
|
||||||
if (type != T_SYMBOL) {
|
if (type != T_SYMBOL) {
|
||||||
scanerror(T_COMMA, "Bad function definition");
|
scanerror(T_COMMA,
|
||||||
|
"Using non-identifier as function parameter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
name = tokensymbol();
|
name = tokensymbol();
|
||||||
@@ -394,7 +410,8 @@ getfunction(void)
|
|||||||
if (type == T_RIGHTPAREN)
|
if (type == T_RIGHTPAREN)
|
||||||
break;
|
break;
|
||||||
if (type != T_COMMA) {
|
if (type != T_COMMA) {
|
||||||
scanerror(T_COMMA, "Bad function definition");
|
scanerror(T_COMMA,
|
||||||
|
"Using other than comma to separate parameters");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -408,8 +425,7 @@ getfunction(void)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
scanerror(T_NULL,
|
scanerror(T_NULL,
|
||||||
"Left brace or equals sign "
|
"Left brace or equals sign expected for function");
|
||||||
"expected for function");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
endfunc();
|
endfunc();
|
||||||
@@ -421,7 +437,7 @@ getfunction(void)
|
|||||||
* Get a simple assignment style body for a function declaration.
|
* Get a simple assignment style body for a function declaration.
|
||||||
* simplebody = '=' assignment '\n'.
|
* simplebody = '=' assignment '\n'.
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
getsimplebody(void)
|
getsimplebody(void)
|
||||||
{
|
{
|
||||||
(void) tokenmode(TM_NEWLINES);
|
(void) tokenmode(TM_NEWLINES);
|
||||||
@@ -436,7 +452,7 @@ getsimplebody(void)
|
|||||||
* | [ declarations ] ... [statement ] ... '\n'
|
* | [ declarations ] ... [statement ] ... '\n'
|
||||||
*/
|
*/
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
static void
|
S_FUNC void
|
||||||
getbody(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaultlabel)
|
getbody(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaultlabel)
|
||||||
{
|
{
|
||||||
int oldmode;
|
int oldmode;
|
||||||
@@ -466,7 +482,7 @@ getbody(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaul
|
|||||||
* declarations = { LOCAL | GLOBAL | STATIC } onedeclaration
|
* declarations = { LOCAL | GLOBAL | STATIC } onedeclaration
|
||||||
* [ ',' onedeclaration ] ... ';'.
|
* [ ',' onedeclaration ] ... ';'.
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getdeclarations(int symtype)
|
getdeclarations(int symtype)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
@@ -518,7 +534,7 @@ getdeclarations(int symtype)
|
|||||||
* Subsequences end with "," or at end of line; spaces indicate
|
* Subsequences end with "," or at end of line; spaces indicate
|
||||||
* repeated assignment, e.g. "c d = 2" has the effect of "c = 2, d = 2".
|
* repeated assignment, e.g. "c d = 2" has the effect of "c = 2, d = 2".
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getsimpledeclaration(int symtype)
|
getsimpledeclaration(int symtype)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
@@ -546,9 +562,9 @@ getsimpledeclaration(int symtype)
|
|||||||
* Get one variable in a sequence of simple identifiers.
|
* Get one variable in a sequence of simple identifiers.
|
||||||
* Returns 1 if the subsequence in which the variable occurs ends with
|
* Returns 1 if the subsequence in which the variable occurs ends with
|
||||||
* an assignment, e.g. for the variables b, c, d, in
|
* an assignment, e.g. for the variables b, c, d, in
|
||||||
* static a, b = 1, c d = 2, d;
|
* S_FUNC a, b = 1, c d = 2, d;
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getonevariable(int symtype)
|
getonevariable(int symtype)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
@@ -600,7 +616,7 @@ getonevariable(int symtype)
|
|||||||
* nextcaselabel label for next case statement
|
* nextcaselabel label for next case statement
|
||||||
* defaultlabel label for default case
|
* defaultlabel label for default case
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaultlabel)
|
getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaultlabel)
|
||||||
{
|
{
|
||||||
LABEL label;
|
LABEL label;
|
||||||
@@ -632,6 +648,10 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
|
|||||||
(void) getdeclarations(SYM_LOCAL);
|
(void) getdeclarations(SYM_LOCAL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_UNDEFINE:
|
||||||
|
ungetfunction();
|
||||||
|
break;
|
||||||
|
|
||||||
case T_RIGHTBRACE:
|
case T_RIGHTBRACE:
|
||||||
scanerror(T_NULL, "Extraneous right brace");
|
scanerror(T_NULL, "Extraneous right brace");
|
||||||
return;
|
return;
|
||||||
@@ -797,10 +817,10 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
|
|||||||
setlabel(&label3);
|
setlabel(&label3);
|
||||||
if (contlabel == NULL_LABEL)
|
if (contlabel == NULL_LABEL)
|
||||||
contlabel = &label3;
|
contlabel = &label3;
|
||||||
|
(void) tokenmode(oldmode);
|
||||||
getstatement(contlabel, breaklabel, NULL_LABEL, NULL_LABEL);
|
getstatement(contlabel, breaklabel, NULL_LABEL, NULL_LABEL);
|
||||||
addoplabel(OP_JUMP, contlabel);
|
addoplabel(OP_JUMP, contlabel);
|
||||||
setlabel(breaklabel);
|
setlabel(breaklabel);
|
||||||
(void) tokenmode(oldmode);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case T_WHILE:
|
case T_WHILE:
|
||||||
@@ -809,6 +829,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
|
|||||||
clearlabel(contlabel);
|
clearlabel(contlabel);
|
||||||
setlabel(contlabel);
|
setlabel(contlabel);
|
||||||
getcondition();
|
getcondition();
|
||||||
|
(void) tokenmode(oldmode);
|
||||||
if (gettoken() != T_SEMICOLON) {
|
if (gettoken() != T_SEMICOLON) {
|
||||||
breaklabel = &label2;
|
breaklabel = &label2;
|
||||||
clearlabel(breaklabel);
|
clearlabel(breaklabel);
|
||||||
@@ -821,7 +842,6 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
|
|||||||
} else {
|
} else {
|
||||||
addoplabel(OP_JUMPNZ, contlabel);
|
addoplabel(OP_JUMPNZ, contlabel);
|
||||||
}
|
}
|
||||||
(void) tokenmode(oldmode);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case T_DO:
|
case T_DO:
|
||||||
@@ -938,6 +958,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
|
|||||||
case T_RIGHTBRACKET:
|
case T_RIGHTBRACKET:
|
||||||
case T_RIGHTBRACE:
|
case T_RIGHTBRACE:
|
||||||
case T_NEWLINE:
|
case T_NEWLINE:
|
||||||
|
case T_ELSE:
|
||||||
case T_EOF:
|
case T_EOF:
|
||||||
rescantoken();
|
rescantoken();
|
||||||
/*FALLTHRU*/
|
/*FALLTHRU*/
|
||||||
@@ -1020,6 +1041,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
|
|||||||
case T_RIGHTBRACE:
|
case T_RIGHTBRACE:
|
||||||
case T_NEWLINE:
|
case T_NEWLINE:
|
||||||
case T_EOF:
|
case T_EOF:
|
||||||
|
case T_ELSE:
|
||||||
rescantoken();
|
rescantoken();
|
||||||
return;
|
return;
|
||||||
case T_SEMICOLON:
|
case T_SEMICOLON:
|
||||||
@@ -1045,7 +1067,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
|
|||||||
* is an OBJ statement, otherwise this is part of a declaration which will
|
* is an OBJ statement, otherwise this is part of a declaration which will
|
||||||
* define new symbols with the specified type.
|
* define new symbols with the specified type.
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
getobjdeclaration(int symtype)
|
getobjdeclaration(int symtype)
|
||||||
{
|
{
|
||||||
char *name; /* name of object type */
|
char *name; /* name of object type */
|
||||||
@@ -1151,7 +1173,7 @@ getobjdeclaration(int symtype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
S_FUNC void
|
||||||
getoneobj(long index, int symtype)
|
getoneobj(long index, int symtype)
|
||||||
{
|
{
|
||||||
char *symname;
|
char *symname;
|
||||||
@@ -1178,7 +1200,7 @@ getoneobj(long index, int symtype)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Routine to assign a specified object-type value to each of a set of
|
* Routine to assign a specified object-type value to each of a set of
|
||||||
* variables in a "global", "local" or "static" declaration, or, if
|
* variables in a "global", "local" or "S_FUNC" declaration, or, if
|
||||||
* symtype is SYM_UNDEFINED, to create one object value of the specified
|
* symtype is SYM_UNDEFINED, to create one object value of the specified
|
||||||
* type.
|
* type.
|
||||||
*
|
*
|
||||||
@@ -1186,7 +1208,7 @@ getoneobj(long index, int symtype)
|
|||||||
* name object name
|
* name object name
|
||||||
* symtype declaration type
|
* symtype declaration type
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
getobjvars(char *name, int symtype)
|
getobjvars(char *name, int symtype)
|
||||||
{
|
{
|
||||||
long index; /* index for object */
|
long index; /* index for object */
|
||||||
@@ -1210,7 +1232,7 @@ getobjvars(char *name, int symtype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
S_FUNC void
|
||||||
getmatdeclaration(int symtype)
|
getmatdeclaration(int symtype)
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -1230,7 +1252,7 @@ getmatdeclaration(int symtype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
S_FUNC void
|
||||||
getonematrix(int symtype)
|
getonematrix(int symtype)
|
||||||
{
|
{
|
||||||
long dim;
|
long dim;
|
||||||
@@ -1326,7 +1348,7 @@ getonematrix(int symtype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
S_FUNC void
|
||||||
creatematrix(void)
|
creatematrix(void)
|
||||||
{
|
{
|
||||||
long dim;
|
long dim;
|
||||||
@@ -1348,7 +1370,7 @@ creatematrix(void)
|
|||||||
rescantoken();
|
rescantoken();
|
||||||
if (++dim > MAXDIM) {
|
if (++dim > MAXDIM) {
|
||||||
scanerror(T_SEMICOLON,
|
scanerror(T_SEMICOLON,
|
||||||
"Only %ld dimensions allowed", MAXDIM);
|
"Only %d dimensions allowed", MAXDIM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(void) getopassignment();
|
(void) getopassignment();
|
||||||
@@ -1384,7 +1406,7 @@ creatematrix(void)
|
|||||||
* Returns the number of elements that are in the list, or -1 on parse error.
|
* Returns the number of elements that are in the list, or -1 on parse error.
|
||||||
* initlist = { assignment [ , assignment ] ... }.
|
* initlist = { assignment [ , assignment ] ... }.
|
||||||
*/
|
*/
|
||||||
static long
|
S_FUNC long
|
||||||
getinitlist(void)
|
getinitlist(void)
|
||||||
{
|
{
|
||||||
long index;
|
long index;
|
||||||
@@ -1393,7 +1415,7 @@ getinitlist(void)
|
|||||||
oldmode = tokenmode(TM_DEFAULT);
|
oldmode = tokenmode(TM_DEFAULT);
|
||||||
|
|
||||||
if (gettoken() != T_LEFTBRACE) {
|
if (gettoken() != T_LEFTBRACE) {
|
||||||
scanerror(T_SEMICOLON, "Missing brace for initialization list");
|
scanerror(T_SEMICOLON, "Missing left brace for initialization list");
|
||||||
(void) tokenmode(oldmode);
|
(void) tokenmode(oldmode);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1428,7 +1450,7 @@ getinitlist(void)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
scanerror(T_SEMICOLON,
|
scanerror(T_SEMICOLON,
|
||||||
"Bad initialization list");
|
"Missing right brace for initialization list");
|
||||||
(void) tokenmode(oldmode);
|
(void) tokenmode(oldmode);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1440,7 +1462,7 @@ getinitlist(void)
|
|||||||
* Get a condition.
|
* Get a condition.
|
||||||
* condition = '(' assignment ')'.
|
* condition = '(' assignment ')'.
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
getcondition(void)
|
getcondition(void)
|
||||||
{
|
{
|
||||||
if (gettoken() != T_LEFTPAREN) {
|
if (gettoken() != T_LEFTPAREN) {
|
||||||
@@ -1464,7 +1486,7 @@ getcondition(void)
|
|||||||
* Returns flags describing the type of the last assignment or expression found.
|
* Returns flags describing the type of the last assignment or expression found.
|
||||||
* exprlist = assignment [ ',' assignment ] ...
|
* exprlist = assignment [ ',' assignment ] ...
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getexprlist(void)
|
getexprlist(void)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
@@ -1497,7 +1519,7 @@ getexprlist(void)
|
|||||||
* | lvalue '**=' assignment
|
* | lvalue '**=' assignment
|
||||||
* | orcond.
|
* | orcond.
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getopassignment(void)
|
getopassignment(void)
|
||||||
{
|
{
|
||||||
int type; /* type of expression */
|
int type; /* type of expression */
|
||||||
@@ -1573,7 +1595,7 @@ getopassignment(void)
|
|||||||
* Get an assignment (lvalue = ...) or possibly just an expression
|
* Get an assignment (lvalue = ...) or possibly just an expression
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
S_FUNC int
|
||||||
getassignment (void)
|
getassignment (void)
|
||||||
{
|
{
|
||||||
int type; /* type of expression */
|
int type; /* type of expression */
|
||||||
@@ -1643,7 +1665,7 @@ getassignment (void)
|
|||||||
* Flags are returned indicating the type of expression found.
|
* Flags are returned indicating the type of expression found.
|
||||||
* altcond = orcond [ '?' orcond ':' altcond ].
|
* altcond = orcond [ '?' orcond ':' altcond ].
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getaltcond(void)
|
getaltcond(void)
|
||||||
{
|
{
|
||||||
int type; /* type of expression */
|
int type; /* type of expression */
|
||||||
@@ -1677,7 +1699,7 @@ getaltcond(void)
|
|||||||
* Flags are returned indicating the type of expression found.
|
* Flags are returned indicating the type of expression found.
|
||||||
* orcond = andcond [ '||' andcond ] ...
|
* orcond = andcond [ '||' andcond ] ...
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getorcond(void)
|
getorcond(void)
|
||||||
{
|
{
|
||||||
int type; /* type of expression */
|
int type; /* type of expression */
|
||||||
@@ -1701,7 +1723,7 @@ getorcond(void)
|
|||||||
* Flags are returned indicating the type of expression found.
|
* Flags are returned indicating the type of expression found.
|
||||||
* andcond = relation [ '&&' relation ] ...
|
* andcond = relation [ '&&' relation ] ...
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getandcond(void)
|
getandcond(void)
|
||||||
{
|
{
|
||||||
int type; /* type of expression */
|
int type; /* type of expression */
|
||||||
@@ -1731,7 +1753,7 @@ getandcond(void)
|
|||||||
* | sum '>' sum
|
* | sum '>' sum
|
||||||
* | sum.
|
* | sum.
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getrelation(void)
|
getrelation(void)
|
||||||
{
|
{
|
||||||
int type; /* type of expression */
|
int type; /* type of expression */
|
||||||
@@ -1762,7 +1784,7 @@ getrelation(void)
|
|||||||
* Flags indicating the type of expression found are returned.
|
* Flags indicating the type of expression found are returned.
|
||||||
* sum = product [ {'+' | '-'} product ] ...
|
* sum = product [ {'+' | '-'} product ] ...
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getsum(void)
|
getsum(void)
|
||||||
{
|
{
|
||||||
int type; /* type of expression found */
|
int type; /* type of expression found */
|
||||||
@@ -1805,7 +1827,7 @@ getsum(void)
|
|||||||
* Flags indicating the type of expression found are returned.
|
* Flags indicating the type of expression found are returned.
|
||||||
* product = orexpr [ {'*' | '/' | '//' | '%'} orexpr ] ...
|
* product = orexpr [ {'*' | '/' | '//' | '%'} orexpr ] ...
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getproduct(void)
|
getproduct(void)
|
||||||
{
|
{
|
||||||
int type; /* type of value found */
|
int type; /* type of value found */
|
||||||
@@ -1836,7 +1858,7 @@ getproduct(void)
|
|||||||
* Flags indicating the type of expression found are returned.
|
* Flags indicating the type of expression found are returned.
|
||||||
* orexpr = andexpr [ '|' andexpr ] ...
|
* orexpr = andexpr [ '|' andexpr ] ...
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getorexpr(void)
|
getorexpr(void)
|
||||||
{
|
{
|
||||||
int type; /* type of value found */
|
int type; /* type of value found */
|
||||||
@@ -1859,7 +1881,7 @@ getorexpr(void)
|
|||||||
* Flags indicating the type of expression found are returned.
|
* Flags indicating the type of expression found are returned.
|
||||||
* andexpr = shiftexpr [ '&' shiftexpr ] ...
|
* andexpr = shiftexpr [ '&' shiftexpr ] ...
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getandexpr(void)
|
getandexpr(void)
|
||||||
{
|
{
|
||||||
int type; /* type of value found */
|
int type; /* type of value found */
|
||||||
@@ -1898,7 +1920,7 @@ getandexpr(void)
|
|||||||
* | reference '>>' shiftexpr
|
* | reference '>>' shiftexpr
|
||||||
* | reference.
|
* | reference.
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getshiftexpr(void)
|
getshiftexpr(void)
|
||||||
{
|
{
|
||||||
int type; /* type of value found */
|
int type; /* type of value found */
|
||||||
@@ -1942,14 +1964,15 @@ getshiftexpr(void)
|
|||||||
* address = '&' term
|
* address = '&' term
|
||||||
* dereference = '*' term
|
* dereference = '*' term
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getreference(void)
|
getreference(void)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
switch(gettoken()) {
|
switch(gettoken()) {
|
||||||
case T_ANDAND:
|
case T_ANDAND:
|
||||||
scanerror(T_NULL, "Non-variable operand for &");
|
scanerror(T_NULL, "&& used as prefix operator");
|
||||||
|
/*FALLTHRU*/
|
||||||
case T_AND:
|
case T_AND:
|
||||||
type = getreference();
|
type = getreference();
|
||||||
addop(OP_PTR);
|
addop(OP_PTR);
|
||||||
@@ -1978,7 +2001,7 @@ getreference(void)
|
|||||||
* get an increment or decrement expression
|
* get an increment or decrement expression
|
||||||
* ++expr, --expr, expr++, expr--
|
* ++expr, --expr, expr++, expr--
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getincdecexpr(void)
|
getincdecexpr(void)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
@@ -2036,7 +2059,7 @@ getincdecexpr(void)
|
|||||||
* | function [ '(' [assignment [',' assignment] ] ')' ]
|
* | function [ '(' [assignment [',' assignment] ] ')' ]
|
||||||
* | '!' term
|
* | '!' term
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getterm(void)
|
getterm(void)
|
||||||
{
|
{
|
||||||
int type; /* type of term found */
|
int type; /* type of term found */
|
||||||
@@ -2104,9 +2127,23 @@ getterm(void)
|
|||||||
type = getidexpr(TRUE, 0);
|
type = getidexpr(TRUE, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_MULT:
|
||||||
|
(void) getterm();
|
||||||
|
addop(OP_DEREF);
|
||||||
|
type = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_POWER: /* '**' or '^' */
|
||||||
|
(void) getterm();
|
||||||
|
addop(OP_DEREF);
|
||||||
|
addop(OP_DEREF);
|
||||||
|
type = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case T_GLOBAL:
|
case T_GLOBAL:
|
||||||
if (gettoken() != T_SYMBOL) {
|
if (gettoken() != T_SYMBOL) {
|
||||||
scanerror(T_NULL, "Global id expected");
|
scanerror(T_NULL,
|
||||||
|
"No identifier after global specifier");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rescantoken();
|
rescantoken();
|
||||||
@@ -2115,19 +2152,30 @@ getterm(void)
|
|||||||
|
|
||||||
case T_LOCAL:
|
case T_LOCAL:
|
||||||
if (gettoken() != T_SYMBOL) {
|
if (gettoken() != T_SYMBOL) {
|
||||||
scanerror(T_NULL, "Local id expected");
|
scanerror(T_NULL,
|
||||||
|
"No identifier after local specifier");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rescantoken();
|
rescantoken();
|
||||||
type = getidexpr(TRUE, T_LOCAL);
|
type = getidexpr(TRUE, T_LOCAL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_STATIC:
|
||||||
|
if (gettoken() != T_SYMBOL) {
|
||||||
|
scanerror(T_NULL,
|
||||||
|
"No identifier after static specifier");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
rescantoken();
|
||||||
|
type = getidexpr(TRUE, T_STATIC);
|
||||||
|
break;
|
||||||
|
|
||||||
case T_LEFTBRACKET:
|
case T_LEFTBRACKET:
|
||||||
scanerror(T_NULL, "Bad index usage");
|
scanerror(T_NULL, "Left bracket with no preceding lvalue");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_PERIOD:
|
case T_PERIOD:
|
||||||
scanerror(T_NULL, "Bad element reference");
|
scanerror(T_NULL, "Period with no preceding lvalue");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -2171,7 +2219,7 @@ getterm(void)
|
|||||||
* element references. The symbol can be a global or a local variable name.
|
* element references. The symbol can be a global or a local variable name.
|
||||||
* Returns the type of expression found.
|
* Returns the type of expression found.
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getidexpr(BOOL okmat, int autodef)
|
getidexpr(BOOL okmat, int autodef)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
@@ -2189,7 +2237,8 @@ getidexpr(BOOL okmat, int autodef)
|
|||||||
type = 0;
|
type = 0;
|
||||||
break;
|
break;
|
||||||
case T_ASSIGN:
|
case T_ASSIGN:
|
||||||
if (autodef != T_GLOBAL && autodef != T_LOCAL)
|
if (autodef != T_GLOBAL && autodef != T_LOCAL &&
|
||||||
|
autodef != T_STATIC)
|
||||||
autodef = 1;
|
autodef = 1;
|
||||||
/* fall into default case */
|
/* fall into default case */
|
||||||
default:
|
default:
|
||||||
@@ -2245,7 +2294,7 @@ getidexpr(BOOL okmat, int autodef)
|
|||||||
* to get the value of a symbol. It should NOT be used in the
|
* to get the value of a symbol. It should NOT be used in the
|
||||||
* general op code generation / calc code parsing case.
|
* general op code generation / calc code parsing case.
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getsymvalue(char *name, VALUE *v_p)
|
getsymvalue(char *name, VALUE *v_p)
|
||||||
{
|
{
|
||||||
GLOBAL *g_ret; /* global return from findglobal() */
|
GLOBAL *g_ret; /* global return from findglobal() */
|
||||||
@@ -2278,7 +2327,7 @@ getsymvalue(char *name, VALUE *v_p)
|
|||||||
* namelen length of filename buffer including NUL byte
|
* namelen length of filename buffer including NUL byte
|
||||||
* once non-NULL => set to TRUE of -once read
|
* once non-NULL => set to TRUE of -once read
|
||||||
*/
|
*/
|
||||||
static int
|
S_FUNC int
|
||||||
getfilename(char *name, size_t namelen, BOOL *once)
|
getfilename(char *name, size_t namelen, BOOL *once)
|
||||||
{
|
{
|
||||||
STRING *s;
|
STRING *s;
|
||||||
@@ -2305,7 +2354,7 @@ getfilename(char *name, size_t namelen, BOOL *once)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* special hack - symbols starting with $ are
|
* special hack - symbols starting with $ are
|
||||||
* treated as a gloabl variable
|
* treated as a global variable
|
||||||
* instead of a literal string.
|
* instead of a literal string.
|
||||||
*/
|
*/
|
||||||
if (symstr[0] == '$') {
|
if (symstr[0] == '$') {
|
||||||
@@ -2360,7 +2409,7 @@ getfilename(char *name, size_t namelen, BOOL *once)
|
|||||||
/*
|
/*
|
||||||
* Read the show command to display useful information
|
* Read the show command to display useful information
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
getshowstatement(void)
|
getshowstatement(void)
|
||||||
{
|
{
|
||||||
char name[5];
|
char name[5];
|
||||||
@@ -2390,22 +2439,11 @@ getshowstatement(void)
|
|||||||
"stri\000"
|
"stri\000"
|
||||||
"lite\000"
|
"lite\000"
|
||||||
"opco\000", name);
|
"opco\000", name);
|
||||||
if (arg == 19) {
|
break;
|
||||||
if (gettoken() != T_SYMBOL) {
|
case T_GLOBAL:
|
||||||
rescantoken();
|
arg = 13; break;
|
||||||
scanerror(T_SEMICOLON,
|
case T_STATIC:
|
||||||
"Function name expected");
|
arg = 14; break;
|
||||||
return;
|
|
||||||
}
|
|
||||||
index = adduserfunc(tokensymbol());
|
|
||||||
addopone(OP_SHOW, index + 19);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (arg > 0)
|
|
||||||
addopone(OP_SHOW, arg);
|
|
||||||
else
|
|
||||||
printf("Unknown SHOW parameter ignored\n");
|
|
||||||
return;
|
|
||||||
default:
|
default:
|
||||||
printf("SHOW command to be followed by at least ");
|
printf("SHOW command to be followed by at least ");
|
||||||
printf("four letters of one of:\n");
|
printf("four letters of one of:\n");
|
||||||
@@ -2420,6 +2458,21 @@ getshowstatement(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (arg == 19) {
|
||||||
|
if (gettoken() != T_SYMBOL) {
|
||||||
|
rescantoken();
|
||||||
|
scanerror(T_SEMICOLON,
|
||||||
|
"Function name expected for show statement");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
index = adduserfunc(tokensymbol());
|
||||||
|
addopone(OP_SHOW, index + 19);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (arg > 0)
|
||||||
|
addopone(OP_SHOW, arg);
|
||||||
|
else
|
||||||
|
warning("Unknown parameter for show statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2427,7 +2480,7 @@ getshowstatement(void)
|
|||||||
* Read in a set of matrix index arguments, surrounded with square brackets.
|
* Read in a set of matrix index arguments, surrounded with square brackets.
|
||||||
* This also handles double square brackets for 'fast indexing'.
|
* This also handles double square brackets for 'fast indexing'.
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
getmatargs(void)
|
getmatargs(void)
|
||||||
{
|
{
|
||||||
int dim;
|
int dim;
|
||||||
@@ -2489,7 +2542,7 @@ getmatargs(void)
|
|||||||
* Get an element of an object reference.
|
* Get an element of an object reference.
|
||||||
* The leading period which introduces the element has already been read.
|
* The leading period which introduces the element has already been read.
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
getelement(void)
|
getelement(void)
|
||||||
{
|
{
|
||||||
long index;
|
long index;
|
||||||
@@ -2510,7 +2563,7 @@ getelement(void)
|
|||||||
* Read in a single symbol name and copy its value into the given buffer.
|
* Read in a single symbol name and copy its value into the given buffer.
|
||||||
* Returns TRUE if a valid symbol id was found.
|
* Returns TRUE if a valid symbol id was found.
|
||||||
*/
|
*/
|
||||||
static BOOL
|
S_FUNC BOOL
|
||||||
getid(char *buf)
|
getid(char *buf)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
@@ -2538,35 +2591,59 @@ getid(char *buf)
|
|||||||
* Define a symbol name to be of the specified symbol type. The scope
|
* Define a symbol name to be of the specified symbol type. The scope
|
||||||
* of a static variable with the same name is terminated if symtype is
|
* of a static variable with the same name is terminated if symtype is
|
||||||
* global or if symtype is static and the old variable is at the same
|
* global or if symtype is static and the old variable is at the same
|
||||||
* level. A scan error occurs if the name is already in use in an
|
* level. Warnings are issued when a global or local variable is
|
||||||
* incompatible manner.
|
* redeclared and when in the same body the variable will be accessible only
|
||||||
|
^ with the appropriate specfier.
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
definesymbol(char *name, int symtype)
|
definesymbol(char *name, int symtype)
|
||||||
{
|
{
|
||||||
switch (symboltype(name)) {
|
switch (symboltype(name)) {
|
||||||
case SYM_STATIC:
|
case SYM_STATIC:
|
||||||
if (symtype == SYM_GLOBAL || symtype == SYM_STATIC)
|
if (symtype == SYM_GLOBAL || symtype == SYM_STATIC)
|
||||||
endscope(name, symtype == SYM_GLOBAL);
|
endscope(name, symtype == SYM_GLOBAL);
|
||||||
/*FALLTHRU*/
|
break;
|
||||||
case SYM_UNDEFINED:
|
|
||||||
case SYM_GLOBAL:
|
case SYM_GLOBAL:
|
||||||
if (symtype == SYM_LOCAL)
|
if (symtype == SYM_GLOBAL && conf->redecl_warn) {
|
||||||
(void) addlocal(name);
|
warning("redeclaraion of global \"%s\"",
|
||||||
else
|
name);
|
||||||
(void) addglobal(name, (symtype == SYM_STATIC));
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYM_LOCAL:
|
case SYM_LOCAL:
|
||||||
if (symtype == SYM_LOCAL)
|
if (symtype == SYM_LOCAL && conf->redecl_warn) {
|
||||||
|
warning("redeclaraion of local \"%s\"",
|
||||||
|
name);
|
||||||
return;
|
return;
|
||||||
/*FALLTHRU*/
|
}
|
||||||
|
if (symtype == SYM_GLOBAL && conf->dupvar_warn) {
|
||||||
|
warning("both local and global \"%s\" defined", name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (conf->dupvar_warn) {
|
||||||
|
warning("both local and static \"%s\" defined", name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SYM_PARAM:
|
case SYM_PARAM:
|
||||||
scanerror(T_COMMA,
|
if (symtype == SYM_LOCAL && conf->dupvar_warn) {
|
||||||
"Variable \"%s\" is already defined", name);
|
warning("both local and parameter \"%s\" defined",
|
||||||
return;
|
name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (symtype == SYM_GLOBAL && conf->dupvar_warn) {
|
||||||
|
warning("both global and parameter \"%s\" defined",
|
||||||
|
name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (conf->dupvar_warn) {
|
||||||
|
warning("both static and parameter \"%s\" defined", name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (symtype == SYM_LOCAL)
|
||||||
|
(void) addlocal(name);
|
||||||
|
else
|
||||||
|
(void) addglobal(name, (symtype == SYM_STATIC));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2581,24 +2658,31 @@ definesymbol(char *name, int symtype)
|
|||||||
* autodef 1 => define if symbol is not known
|
* autodef 1 => define if symbol is not known
|
||||||
* T_GLOBAL => get global, define if necessary
|
* T_GLOBAL => get global, define if necessary
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
usesymbol(char *name, int autodef)
|
usesymbol(char *name, int autodef)
|
||||||
{
|
{
|
||||||
|
int type;
|
||||||
|
|
||||||
|
type = symboltype(name);
|
||||||
if (autodef == T_GLOBAL) {
|
if (autodef == T_GLOBAL) {
|
||||||
addopptr(OP_GLOBALADDR, (char *) addglobal(name, FALSE));
|
if (type == SYM_GLOBAL) {
|
||||||
return;
|
warning("Unnecessary global specifier");
|
||||||
|
}
|
||||||
|
addopptr(OP_GLOBALADDR, (char *) addglobal(name, FALSE));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (autodef == T_STATIC) {
|
||||||
|
addopptr(OP_GLOBALADDR, (char *) addglobal(name, TRUE));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (autodef == T_LOCAL) {
|
if (autodef == T_LOCAL) {
|
||||||
if (symboltype(name) == SYM_PARAM) {
|
if (type == SYM_LOCAL) {
|
||||||
scanerror(T_COMMA,
|
warning("Unnecessary local specifier");
|
||||||
"Variable \"%s\" is already defined", name);
|
}
|
||||||
return;
|
addopone(OP_LOCALADDR, addlocal(name));
|
||||||
}
|
return;
|
||||||
addopone(OP_LOCALADDR, addlocal(name));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
switch (symboltype(name)) {
|
switch (type) {
|
||||||
case SYM_LOCAL:
|
case SYM_LOCAL:
|
||||||
addopone(OP_LOCALADDR, (long) findlocal(name));
|
addopone(OP_LOCALADDR, (long) findlocal(name));
|
||||||
return;
|
return;
|
||||||
@@ -2631,7 +2715,7 @@ usesymbol(char *name, int autodef)
|
|||||||
* given:
|
* given:
|
||||||
* name name of function
|
* name name of function
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
getcallargs(char *name)
|
getcallargs(char *name)
|
||||||
{
|
{
|
||||||
long index; /* function index */
|
long index; /* function index */
|
||||||
@@ -2700,7 +2784,7 @@ getcallargs(char *name)
|
|||||||
/*
|
/*
|
||||||
* Change the current directory. If no directory is given, assume home.
|
* Change the current directory. If no directory is given, assume home.
|
||||||
*/
|
*/
|
||||||
static void
|
S_FUNC void
|
||||||
do_changedir(void)
|
do_changedir(void)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
20
comfunc.c
20
comfunc.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* comfunc - extended precision complex arithmetic non-primitive routines
|
* comfunc - extended precision complex arithmetic non-primitive routines
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 David I. Bell and Ernest Bowen
|
* Copyright (C) 1999-2007 David I. Bell and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: David I. Bell
|
* Primary author: David I. Bell
|
||||||
*
|
*
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.6 $
|
* @(#) $Revision: 30.2 $
|
||||||
* @(#) $Id: comfunc.c,v 29.6 2006/05/20 08:43:55 chongo Exp $
|
* @(#) $Id: comfunc.c,v 30.2 2007/07/11 23:05:49 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/comfunc.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/comfunc.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:48:13
|
* Under source code control: 1990/02/15 01:48:13
|
||||||
@@ -36,10 +36,10 @@
|
|||||||
/*
|
/*
|
||||||
* cache the natural logarithm of 10
|
* cache the natural logarithm of 10
|
||||||
*/
|
*/
|
||||||
static COMPLEX *cln_10 = NULL;
|
STATIC COMPLEX *cln_10 = NULL;
|
||||||
static NUMBER *cln_10_epsilon = NULL;
|
STATIC NUMBER *cln_10_epsilon = NULL;
|
||||||
static NUMBER _q10_ = { { _tenval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL };
|
STATIC NUMBER _q10_ = { { _tenval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL };
|
||||||
static NUMBER _q0_ = { { _zeroval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL };
|
STATIC NUMBER _q0_ = { { _zeroval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL };
|
||||||
COMPLEX _cten_ = { &_q10_, &_q0_, 1 };
|
COMPLEX _cten_ = { &_q10_, &_q0_, 1 };
|
||||||
|
|
||||||
|
|
||||||
@@ -1117,8 +1117,8 @@ c_power(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon)
|
|||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
if (ciszero(c1)) {
|
if (ciszero(c1)) {
|
||||||
if (qisneg(c2->real) || qiszero(c2->real)) {
|
if (cisreal(c2) && qisneg(c2->real)) {
|
||||||
math_error ("Non-positive exponent of zero");
|
math_error ("Non-positive real exponent of zero");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
return clink(&_czero_);
|
return clink(&_czero_);
|
||||||
|
10
commath.c
10
commath.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* commath - extended precision complex arithmetic primitive routines
|
* commath - extended precision complex arithmetic primitive routines
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 David I. Bell
|
* Copyright (C) 1999-2007 David I. Bell
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.4 $
|
* @(#) $Revision: 30.1 $
|
||||||
* @(#) $Id: commath.c,v 29.4 2005/10/18 10:43:49 chongo Exp $
|
* @(#) $Id: commath.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/commath.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/commath.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:48:10
|
* Under source code control: 1990/02/15 01:48:10
|
||||||
@@ -35,7 +35,7 @@ COMPLEX _czero_ = { &_qzero_, &_qzero_, 1 };
|
|||||||
COMPLEX _cone_ = { &_qone_, &_qzero_, 1 };
|
COMPLEX _cone_ = { &_qone_, &_qzero_, 1 };
|
||||||
COMPLEX _conei_ = { &_qzero_, &_qone_, 1 };
|
COMPLEX _conei_ = { &_qzero_, &_qone_, 1 };
|
||||||
|
|
||||||
static COMPLEX _cnegone_ = { &_qnegone_, &_qzero_, 1 };
|
STATIC COMPLEX _cnegone_ = { &_qnegone_, &_qzero_, 1 };
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
224
config.c
224
config.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* config - configuration routines
|
* config - configuration routines
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2006 David I. Bell and Landon Curt Noll
|
* Copyright (C) 1999-2007 David I. Bell and Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Primary author: David I. Bell
|
* Primary author: David I. Bell
|
||||||
*
|
*
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
* 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
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.17 $
|
* @(#) $Revision: 30.2 $
|
||||||
* @(#) $Id: config.c,v 29.17 2006/05/19 15:26:10 chongo Exp $
|
* @(#) $Id: config.c,v 30.2 2007/07/05 13:30:38 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1991/07/20 00:21:56
|
* Under source code control: 1991/07/20 00:21:56
|
||||||
@@ -31,13 +31,31 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "have_times.h"
|
||||||
|
#if defined(HAVE_TIME_H)
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_TIMES_H)
|
||||||
|
#include <times.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_SYS_TIME_H)
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_SYS_TIMES_H)
|
||||||
|
#include <sys/times.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "calc.h"
|
#include "calc.h"
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include "zrand.h"
|
#include "zrand.h"
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
#include "nametype.h"
|
#include "nametype.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "string.h"
|
#include "str.h"
|
||||||
#include "custom.h"
|
#include "custom.h"
|
||||||
|
|
||||||
#include "have_strdup.h"
|
#include "have_strdup.h"
|
||||||
@@ -45,6 +63,15 @@
|
|||||||
# define strdup(x) calc_strdup((CONST char *)(x))
|
# define strdup(x) calc_strdup((CONST char *)(x))
|
||||||
#endif /* HAVE_STRDUP */
|
#endif /* HAVE_STRDUP */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* deal with systems that lack a defined CLK_TCK
|
||||||
|
*/
|
||||||
|
#if defined(CLK_TCK)
|
||||||
|
# define CALC_HZ ((long)(CLK_TCK))
|
||||||
|
#else
|
||||||
|
# define CALC_HZ (0L) /* no defined clock tick rate */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Table of configuration types that can be set or read.
|
* Table of configuration types that can be set or read.
|
||||||
@@ -97,6 +124,10 @@ NAMETYPE configs[] = {
|
|||||||
{"compile_custom", CONFIG_COMPILE_CUSTOM},
|
{"compile_custom", CONFIG_COMPILE_CUSTOM},
|
||||||
{"allow_custom", CONFIG_ALLOW_CUSTOM},
|
{"allow_custom", CONFIG_ALLOW_CUSTOM},
|
||||||
{"version", CONFIG_VERSION},
|
{"version", CONFIG_VERSION},
|
||||||
|
{"baseb", CONFIG_BASEB},
|
||||||
|
{"redecl_warn", CONFIG_REDECL_WARN},
|
||||||
|
{"dupvar_warn", CONFIG_DUPVAR_WARN},
|
||||||
|
{"hz", CONFIG_HZ},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -159,7 +190,10 @@ CONFIG oldstd = { /* backward compatible standard configuration */
|
|||||||
FALSE, /* compiled without -DCUSTOM */
|
FALSE, /* compiled without -DCUSTOM */
|
||||||
#endif
|
#endif
|
||||||
&allow_custom, /* *TRUE=> custom functions are enabled */
|
&allow_custom, /* *TRUE=> custom functions are enabled */
|
||||||
NULL /* version */
|
NULL, /* version */
|
||||||
|
BASEB, /* base for calculations */
|
||||||
|
TRUE, /* warn when redeclaring */
|
||||||
|
TRUE, /* warn when variable names collide */
|
||||||
};
|
};
|
||||||
CONFIG newstd = { /* new non-backward compatible configuration */
|
CONFIG newstd = { /* new non-backward compatible configuration */
|
||||||
MODE_INITIAL, /* current output mode */
|
MODE_INITIAL, /* current output mode */
|
||||||
@@ -216,7 +250,10 @@ CONFIG newstd = { /* new non-backward compatible configuration */
|
|||||||
FALSE, /* compiled without -DCUSTOM */
|
FALSE, /* compiled without -DCUSTOM */
|
||||||
#endif
|
#endif
|
||||||
&allow_custom, /* *TRUE=> custom functions are enabled */
|
&allow_custom, /* *TRUE=> custom functions are enabled */
|
||||||
NULL /* version */
|
NULL, /* version */
|
||||||
|
BASEB, /* base for calculations */
|
||||||
|
TRUE, /* warn when redeclaring */
|
||||||
|
TRUE, /* warn when variable names collide */
|
||||||
};
|
};
|
||||||
CONFIG *conf = NULL; /* loaded in at startup - current configuration */
|
CONFIG *conf = NULL; /* loaded in at startup - current configuration */
|
||||||
|
|
||||||
@@ -224,7 +261,7 @@ CONFIG *conf = NULL; /* loaded in at startup - current configuration */
|
|||||||
/*
|
/*
|
||||||
* Possible output modes.
|
* Possible output modes.
|
||||||
*/
|
*/
|
||||||
static NAMETYPE modes[] = {
|
STATIC NAMETYPE modes[] = {
|
||||||
{"fraction", MODE_FRAC},
|
{"fraction", MODE_FRAC},
|
||||||
{"frac", MODE_FRAC},
|
{"frac", MODE_FRAC},
|
||||||
{"integer", MODE_INT},
|
{"integer", MODE_INT},
|
||||||
@@ -249,7 +286,7 @@ static NAMETYPE modes[] = {
|
|||||||
/*
|
/*
|
||||||
* Possible block base output modes
|
* Possible block base output modes
|
||||||
*/
|
*/
|
||||||
static NAMETYPE blk_base[] = {
|
STATIC NAMETYPE blk_base[] = {
|
||||||
{"hexadecimal", BLK_BASE_HEX},
|
{"hexadecimal", BLK_BASE_HEX},
|
||||||
{"hex", BLK_BASE_HEX},
|
{"hex", BLK_BASE_HEX},
|
||||||
{"default", BLK_BASE_HEX},
|
{"default", BLK_BASE_HEX},
|
||||||
@@ -268,7 +305,7 @@ static NAMETYPE blk_base[] = {
|
|||||||
/*
|
/*
|
||||||
* Possible block output formats
|
* Possible block output formats
|
||||||
*/
|
*/
|
||||||
static NAMETYPE blk_fmt[] = {
|
STATIC NAMETYPE blk_fmt[] = {
|
||||||
{"lines", BLK_FMT_LINE},
|
{"lines", BLK_FMT_LINE},
|
||||||
{"line", BLK_FMT_LINE},
|
{"line", BLK_FMT_LINE},
|
||||||
{"strings", BLK_FMT_STRING},
|
{"strings", BLK_FMT_STRING},
|
||||||
@@ -288,7 +325,7 @@ static NAMETYPE blk_fmt[] = {
|
|||||||
/*
|
/*
|
||||||
* Possible ctrl_d styles
|
* Possible ctrl_d styles
|
||||||
*/
|
*/
|
||||||
static NAMETYPE ctrl_d[] = {
|
STATIC NAMETYPE ctrl_d[] = {
|
||||||
{"virgin_eof", CTRL_D_VIRGIN_EOF},
|
{"virgin_eof", CTRL_D_VIRGIN_EOF},
|
||||||
{"virgineof", CTRL_D_VIRGIN_EOF},
|
{"virgineof", CTRL_D_VIRGIN_EOF},
|
||||||
{"virgin", CTRL_D_VIRGIN_EOF},
|
{"virgin", CTRL_D_VIRGIN_EOF},
|
||||||
@@ -308,7 +345,7 @@ static NAMETYPE ctrl_d[] = {
|
|||||||
*/
|
*/
|
||||||
#define TRUE_STRING "true"
|
#define TRUE_STRING "true"
|
||||||
#define FALSE_STRING "false"
|
#define FALSE_STRING "false"
|
||||||
static NAMETYPE truth[] = {
|
STATIC NAMETYPE truth[] = {
|
||||||
{TRUE_STRING, TRUE},
|
{TRUE_STRING, TRUE},
|
||||||
{"t", TRUE},
|
{"t", TRUE},
|
||||||
{"on", TRUE},
|
{"on", TRUE},
|
||||||
@@ -330,9 +367,9 @@ static NAMETYPE truth[] = {
|
|||||||
/*
|
/*
|
||||||
* declare static functions
|
* declare static functions
|
||||||
*/
|
*/
|
||||||
static long lookup_long(NAMETYPE *set, char *name);
|
S_FUNC long lookup_long(NAMETYPE *set, char *name);
|
||||||
static char *lookup_name(NAMETYPE *set, long val);
|
S_FUNC char *lookup_name(NAMETYPE *set, long val);
|
||||||
static int getlen(VALUE *vp, LEN *lp);
|
S_FUNC int getlen(VALUE *vp, LEN *lp);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -366,7 +403,7 @@ configtype(char *name)
|
|||||||
* returns:
|
* returns:
|
||||||
* numeric value of the name or -1 if not found
|
* numeric value of the name or -1 if not found
|
||||||
*/
|
*/
|
||||||
static long
|
S_FUNC long
|
||||||
lookup_long(NAMETYPE *set, char *name)
|
lookup_long(NAMETYPE *set, char *name)
|
||||||
{
|
{
|
||||||
NAMETYPE *cp; /* current config pointer */
|
NAMETYPE *cp; /* current config pointer */
|
||||||
@@ -389,7 +426,7 @@ lookup_long(NAMETYPE *set, char *name)
|
|||||||
* returns:
|
* returns:
|
||||||
* name of the value found of NULL
|
* name of the value found of NULL
|
||||||
*/
|
*/
|
||||||
static char *
|
S_FUNC char *
|
||||||
lookup_name(NAMETYPE *set, long val)
|
lookup_name(NAMETYPE *set, long val)
|
||||||
{
|
{
|
||||||
NAMETYPE *cp; /* current config pointer */
|
NAMETYPE *cp; /* current config pointer */
|
||||||
@@ -405,10 +442,11 @@ lookup_name(NAMETYPE *set, long val)
|
|||||||
/*
|
/*
|
||||||
* Check whether VALUE at vp is a LEN (32-bit signed integer) and if so,
|
* Check whether VALUE at vp is a LEN (32-bit signed integer) and if so,
|
||||||
* copy that integer to lp.
|
* copy that integer to lp.
|
||||||
* Return: 1, 2, 0, or -1 XXX
|
*
|
||||||
|
* Return: 1 ==> not an integer, 2 ==> int > 2^31, 0 ==> OK, -1 ==> error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
S_FUNC int
|
||||||
getlen(VALUE *vp, LEN *lp)
|
getlen(VALUE *vp, LEN *lp)
|
||||||
{
|
{
|
||||||
if (vp->v_type != V_NUM || !qisint(vp->v_num))
|
if (vp->v_type != V_NUM || !qisint(vp->v_num))
|
||||||
@@ -491,7 +529,7 @@ setconfig(int type, VALUE *vp)
|
|||||||
}
|
}
|
||||||
temp = lookup_long(modes, vp->v_str->s_str);
|
temp = lookup_long(modes, vp->v_str->s_str);
|
||||||
if (temp < 0) {
|
if (temp < 0) {
|
||||||
math_error("Unknown mode \"%s\"", vp->v_str);
|
math_error("Unknown mode \"%s\"", vp->v_str->s_str);
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
math_setmode((int) temp);
|
math_setmode((int) temp);
|
||||||
@@ -504,7 +542,7 @@ setconfig(int type, VALUE *vp)
|
|||||||
}
|
}
|
||||||
temp = lookup_long(modes, vp->v_str->s_str);
|
temp = lookup_long(modes, vp->v_str->s_str);
|
||||||
if (temp < 0) {
|
if (temp < 0) {
|
||||||
math_error("Unknown mode \"%s\"", vp->v_str);
|
math_error("Unknown mode \"%s\"", vp->v_str->s_str);
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
math_setmode2((int) temp);
|
math_setmode2((int) temp);
|
||||||
@@ -527,7 +565,7 @@ setconfig(int type, VALUE *vp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CONFIG_MUL2:
|
case CONFIG_MUL2:
|
||||||
if (getlen(vp, &len)) {
|
if (getlen(vp, &len) || len < 0 || len == 1) {
|
||||||
math_error("Bad value for mul2");
|
math_error("Bad value for mul2");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
@@ -537,7 +575,7 @@ setconfig(int type, VALUE *vp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CONFIG_SQ2:
|
case CONFIG_SQ2:
|
||||||
if (getlen(vp, &len)) {
|
if (getlen(vp, &len) || len < 0 || len == 1) {
|
||||||
math_error("Bad value for sq2");
|
math_error("Bad value for sq2");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
@@ -547,7 +585,7 @@ setconfig(int type, VALUE *vp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CONFIG_POW2:
|
case CONFIG_POW2:
|
||||||
if (getlen(vp, &len)) {
|
if (getlen(vp, &len) || len < 0 || len == 1) {
|
||||||
math_error("Bad value for pow2");
|
math_error("Bad value for pow2");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
@@ -557,7 +595,7 @@ setconfig(int type, VALUE *vp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CONFIG_REDC2:
|
case CONFIG_REDC2:
|
||||||
if (getlen(vp, &len)) {
|
if (getlen(vp, &len) || len < 0 || len == 1) {
|
||||||
math_error("Bad value for redc2");
|
math_error("Bad value for redc2");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
@@ -899,6 +937,42 @@ setconfig(int type, VALUE *vp)
|
|||||||
math_error("The version config parameter is read-only");
|
math_error("The version config parameter is read-only");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
|
||||||
|
case CONFIG_BASEB:
|
||||||
|
math_error("The baseb config parameter is read-only");
|
||||||
|
/*NOTREACHED*/
|
||||||
|
|
||||||
|
case CONFIG_REDECL_WARN:
|
||||||
|
if (vp->v_type == V_NUM) {
|
||||||
|
q = vp->v_num;
|
||||||
|
conf->redecl_warn = !qiszero(q);
|
||||||
|
} else if (vp->v_type == V_STR) {
|
||||||
|
temp = lookup_long(truth, vp->v_str->s_str);
|
||||||
|
if (temp < 0) {
|
||||||
|
math_error("Illegal truth value for redecl_warn");
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
conf->redecl_warn = (int)temp;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONFIG_DUPVAR_WARN:
|
||||||
|
if (vp->v_type == V_NUM) {
|
||||||
|
q = vp->v_num;
|
||||||
|
conf->dupvar_warn = !qiszero(q);
|
||||||
|
} else if (vp->v_type == V_STR) {
|
||||||
|
temp = lookup_long(truth, vp->v_str->s_str);
|
||||||
|
if (temp < 0) {
|
||||||
|
math_error("Illegal truth value for dupvar_warn");
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
conf->dupvar_warn = (int)temp;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONFIG_HZ:
|
||||||
|
math_error("The clock tick rate config parameter is read-only");
|
||||||
|
/*NOTREACHED*/
|
||||||
|
|
||||||
default:
|
default:
|
||||||
math_error("Setting illegal config parameter");
|
math_error("Setting illegal config parameter");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
@@ -1110,20 +1184,12 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CONFIG_TILDE:
|
case CONFIG_TILDE:
|
||||||
if (cfg->tilde_ok) {
|
i = (cfg->tilde_ok ? 1 : 0);
|
||||||
vp->v_num = itoq(1);
|
break;
|
||||||
} else {
|
|
||||||
vp->v_num = itoq(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case CONFIG_TAB:
|
case CONFIG_TAB:
|
||||||
if (cfg->tab_ok) {
|
i = (cfg->tab_ok ? 1 : 0);
|
||||||
vp->v_num = itoq(1);
|
break;
|
||||||
} else {
|
|
||||||
vp->v_num = itoq(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case CONFIG_QUOMOD:
|
case CONFIG_QUOMOD:
|
||||||
i = cfg->quomod;
|
i = cfg->quomod;
|
||||||
@@ -1162,20 +1228,12 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CONFIG_LEADZERO:
|
case CONFIG_LEADZERO:
|
||||||
if (cfg->leadzero) {
|
i = (cfg->leadzero ? 1 : 0);
|
||||||
vp->v_num = itoq(1);
|
break;
|
||||||
} else {
|
|
||||||
vp->v_num = itoq(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case CONFIG_FULLZERO:
|
case CONFIG_FULLZERO:
|
||||||
if (cfg->fullzero) {
|
i = (cfg->fullzero ? 1 : 0);
|
||||||
vp->v_num = itoq(1);
|
break;
|
||||||
} else {
|
|
||||||
vp->v_num = itoq(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case CONFIG_MAXSCAN:
|
case CONFIG_MAXSCAN:
|
||||||
i = cfg->maxscancount;
|
i = cfg->maxscancount;
|
||||||
@@ -1196,12 +1254,8 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CONFIG_BLKVERBOSE:
|
case CONFIG_BLKVERBOSE:
|
||||||
if (cfg->blkverbose) {
|
i = (cfg->blkverbose ? 1 : 0);
|
||||||
vp->v_num = itoq(1);
|
break;
|
||||||
} else {
|
|
||||||
vp->v_num = itoq(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case CONFIG_BLKBASE:
|
case CONFIG_BLKBASE:
|
||||||
vp->v_type = V_STR;
|
vp->v_type = V_STR;
|
||||||
@@ -1236,12 +1290,8 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CONFIG_VERBOSE_QUIT:
|
case CONFIG_VERBOSE_QUIT:
|
||||||
if (cfg->verbose_quit) {
|
i = (cfg->verbose_quit ? 1 : 0);
|
||||||
vp->v_num = itoq(1);
|
break;
|
||||||
} else {
|
|
||||||
vp->v_num = itoq(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case CONFIG_CTRL_D:
|
case CONFIG_CTRL_D:
|
||||||
vp->v_type = V_STR;
|
vp->v_type = V_STR;
|
||||||
@@ -1272,40 +1322,24 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case CONFIG_WINDOWS:
|
case CONFIG_WINDOWS:
|
||||||
if (cfg->windows) {
|
i = (cfg->windows ? 1 : 0);
|
||||||
vp->v_num = itoq(1);
|
break;
|
||||||
} else {
|
|
||||||
vp->v_num = itoq(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case CONFIG_CYGWIN:
|
case CONFIG_CYGWIN:
|
||||||
if (cfg->cygwin) {
|
i = (cfg->cygwin ? 1 : 0);
|
||||||
vp->v_num = itoq(1);
|
break;
|
||||||
} else {
|
|
||||||
vp->v_num = itoq(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case CONFIG_COMPILE_CUSTOM:
|
case CONFIG_COMPILE_CUSTOM:
|
||||||
if (cfg->compile_custom) {
|
i = (cfg->compile_custom ? 1 : 0);
|
||||||
vp->v_num = itoq(1);
|
break;
|
||||||
} else {
|
|
||||||
vp->v_num = itoq(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case CONFIG_ALLOW_CUSTOM:
|
case CONFIG_ALLOW_CUSTOM:
|
||||||
/* firewall */
|
/* firewall */
|
||||||
if (cfg->allow_custom == NULL) {
|
if (cfg->allow_custom == NULL) {
|
||||||
cfg->allow_custom = &allow_custom;
|
cfg->allow_custom = &allow_custom;
|
||||||
}
|
}
|
||||||
if (*(cfg->allow_custom)) {
|
i = (*(cfg->allow_custom) ? 1 : 0);
|
||||||
vp->v_num = itoq(1);
|
break;
|
||||||
} else {
|
|
||||||
vp->v_num = itoq(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case CONFIG_VERSION:
|
case CONFIG_VERSION:
|
||||||
vp->v_type = V_STR;
|
vp->v_type = V_STR;
|
||||||
@@ -1316,6 +1350,22 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case CONFIG_BASEB:
|
||||||
|
i = BASEB;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONFIG_REDECL_WARN:
|
||||||
|
i = (cfg->redecl_warn ? 1 : 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONFIG_DUPVAR_WARN:
|
||||||
|
i = (cfg->dupvar_warn ? 1 : 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONFIG_HZ:
|
||||||
|
i = CALC_HZ;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
math_error("Getting illegal CONFIG element");
|
math_error("Getting illegal CONFIG element");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
@@ -1420,5 +1470,7 @@ config_cmp(CONFIG *cfg1, CONFIG *cfg2)
|
|||||||
(cfg1->version == NULL && cfg2->version != NULL) ||
|
(cfg1->version == NULL && cfg2->version != NULL) ||
|
||||||
(cfg1->version != NULL && cfg2->version == NULL) ||
|
(cfg1->version != NULL && cfg2->version == NULL) ||
|
||||||
(cfg1->version != NULL && cfg2->version != NULL &&
|
(cfg1->version != NULL && cfg2->version != NULL &&
|
||||||
strcmp(cfg1->version, cfg2->version) != 0);
|
strcmp(cfg1->version, cfg2->version) != 0) ||
|
||||||
|
|
||||||
|
cfg1->baseb != cfg2->baseb;
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user