mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
11 Commits
2.11.1t2
...
2.11.5t1.0
Author | SHA1 | Date | |
---|---|---|---|
|
63d9b22067 | ||
|
fc85ac3791 | ||
|
3d55811205 | ||
|
296aa50ac7 | ||
|
5e098d2adf | ||
|
ae2a752314 | ||
|
61dd47526f | ||
|
417ffb6ab5 | ||
|
121b8f72c6 | ||
|
9968a69f50 | ||
|
1ea579d929 |
67
BUGS
67
BUGS
@@ -20,20 +20,21 @@ configuration, try backing them out and see if things get better.
|
||||
|
||||
To be sure that your version of calc is up to date, check out:
|
||||
|
||||
http://reality.sgi.com/chongo/tech/comp/calc/calc-download.html
|
||||
http://www.isthe.com/chongo/tech/comp/calc/calc-download.html
|
||||
|
||||
The calc web site is located at:
|
||||
|
||||
http://reality.sgi.com/chongo/tech/comp/calc/index.html
|
||||
http://www.isthe.com/chongo/tech/comp/calc/index.html
|
||||
|
||||
=-=
|
||||
|
||||
If you have tried all of the above and things still are not right,
|
||||
then it may be time to send in a bug report. You can send bug reports to:
|
||||
|
||||
calc-bugs at postofc dot corp dot sgi dot com
|
||||
calc-bugs at asthe dot com
|
||||
|
||||
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: The EMail address uses 'asthe', the web site URL uses 'isthe' ]]
|
||||
|
||||
When you send your report, please include the following information:
|
||||
|
||||
@@ -58,9 +59,10 @@ Stack traces from core dumps are useful to send as well.
|
||||
Send any comments, compiler warning messages, suggestions and most
|
||||
importantly, fixes (in the form of a context diff patch) to:
|
||||
|
||||
calc-tester at postofc dot corp dot sgi dot com
|
||||
calc-bugs at asthe dot com
|
||||
|
||||
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: The EMail address uses 'asthe', the web site URL uses 'isthe' ]]
|
||||
|
||||
You should use the above calc-bugs address for bug reports, if you are
|
||||
not currently a member of the calc-tester mailing list.
|
||||
@@ -81,6 +83,51 @@ Problems with known work-a-rounds:
|
||||
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;
|
||||
|
||||
* Solaris cc somtimes barfs while compiling zrand.c. In particular, calc
|
||||
barfs on on the SVAL macro. The work-a-round is to use the Solaric cc
|
||||
Makefile set sets -DFORCE_STDC. I.e,:
|
||||
@@ -177,12 +224,12 @@ Problems with known work-a-rounds:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: BUGS,v 29.4 1999/12/15 09:13:29 chongo Exp $
|
||||
## @(#) $Revision: 29.9 $
|
||||
## @(#) $Id: BUGS,v 29.9 2001/03/18 03:34:41 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/BUGS,v $
|
||||
##
|
||||
## Under source code control: 1994/03/18 14:06:13
|
||||
## File existed as early as: 1994
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
## Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
47
COPYING
47
COPYING
@@ -12,8 +12,8 @@ This file is Copyrighted
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: COPYING,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
# @(#) $Revision: 29.5 $
|
||||
# @(#) $Id: COPYING,v 29.5 2000/12/18 10:22:55 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/COPYING,v $
|
||||
|
||||
=-=
|
||||
@@ -55,16 +55,28 @@ Calc is covered by the GNU Lesser General Public License
|
||||
|
||||
The contact addresses for calc is as follows:
|
||||
|
||||
Web: http://reality.sgi.com/chongo/tech/comp/calc/index.html
|
||||
http://www.isthe.com/chongo/tech/comp/calc/index.html
|
||||
Web: http://www.isthe.com/chongo/tech/comp/calc/index.html
|
||||
EMail: calc-contrib at asthe dot com
|
||||
|
||||
EMail: calc-tester at postofc dot corp dot sgi dot com
|
||||
calc-tester at isthe dot com
|
||||
To join the calc-tester mailing list. Send a request to:
|
||||
|
||||
[[ Replace 'at' with @, 'dot' is with . and remove spaces ]]
|
||||
calc-tester-request at asthe dot com
|
||||
|
||||
The 2nd address set is provided in case the 1st address set no
|
||||
longer functions.
|
||||
Your message body (not the subject) should consist of:
|
||||
|
||||
subscribe calc-tester address
|
||||
end
|
||||
name your_full_name
|
||||
|
||||
where ``address'' is your EMail address and ``your_full_name'' is
|
||||
your full name.
|
||||
|
||||
Calc bug reports, however should be sent to:
|
||||
|
||||
calc-bugs at asthe dot com
|
||||
|
||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
||||
|
||||
=-=
|
||||
|
||||
@@ -128,7 +140,7 @@ Calc copyrights and exception files
|
||||
-----------------------------------
|
||||
|
||||
With the exception of the files listed below, Calc is covered under
|
||||
the following Copyrights:
|
||||
the following GNU Lesser General Public License Copyrights:
|
||||
|
||||
Copyright (C) year David I. Bell
|
||||
Copyright (C) year David I. Bell and Landon Curt Noll
|
||||
@@ -138,12 +150,11 @@ Calc copyrights and exception files
|
||||
Copyright (C) year Ernest Bowen and Landon Curt Noll
|
||||
Copyright (C) year Ernest Bowen
|
||||
|
||||
A few files are not covered under the GNU Lesser General Public
|
||||
License. The source files not covered are:
|
||||
These files are not covered under one of the Copyrights listed above:
|
||||
|
||||
shs1.c shs1.h shs.c shs.h
|
||||
md5.c md5.h lib/qtime.cal COPYING
|
||||
COPYING-LGPL
|
||||
md5.c md5.h COPYING COPYING-LGPL
|
||||
cal/qtime.cal
|
||||
|
||||
The file COPYING-LGPL, which contains a copy of the version 2.1
|
||||
GNU Lesser General Public License, is itself Copyrighted by the
|
||||
@@ -155,6 +166,14 @@ Calc copyrights and exception files
|
||||
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.
|
||||
|
||||
Some of these exception files are in the public domain. Other
|
||||
exception files have non-LGPL Copyrights. Other files are under a
|
||||
LGPL Copyright but have different authors.
|
||||
|
||||
In all cases one may use and distribute these exception files freely.
|
||||
And because one may freely distribute the LGPL covered files, the
|
||||
entire calc source may be freely used and distributed.
|
||||
|
||||
=-=
|
||||
|
||||
General Copyleft and License info
|
||||
|
@@ -65,12 +65,12 @@ the calc help subsystem. See the README file for details.
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: HOWTO.INSTALL,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: HOWTO.INSTALL,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/HOWTO.INSTALL,v $
|
||||
##
|
||||
## Under source code control: 1999/09/27 20:48:44
|
||||
## File existed as early as: 1999
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
## Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
8
LIBRARY
8
LIBRARY
@@ -471,12 +471,12 @@ need call libcalc_call_me_last() only once.
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: LIBRARY,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: LIBRARY,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/LIBRARY,v $
|
||||
##
|
||||
## Under source code control: 1993/07/30 19:44:49
|
||||
## File existed as early as: 1993
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
## Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
22
README
22
README
@@ -4,7 +4,7 @@ See the HOWTO.INSTALL file for information on how to build and install calc.
|
||||
|
||||
To be sure that your version of calc is up to date, check out:
|
||||
|
||||
http://reality.sgi.com/chongo/tech/comp/calc/calc-download.html
|
||||
http://www.isthe.com/chongo/tech/comp/calc/calc-download.html
|
||||
|
||||
We are interested in any/all feedback on recent versions of calc.
|
||||
In particular we would like to hear about:
|
||||
@@ -75,9 +75,10 @@ for a wish/todo list. Code contributions are welcome.
|
||||
|
||||
To join the calc-tester mailing list. Send a request to:
|
||||
|
||||
calc-tester-request at postofc dot corp dot sgi dot com
|
||||
calc-tester-request at asthe dot com
|
||||
|
||||
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
||||
|
||||
Your message body (not the subject) should consist of:
|
||||
|
||||
@@ -90,15 +91,16 @@ your full name.
|
||||
|
||||
Calc bug reports, however should be sent to:
|
||||
|
||||
calc-bugs at postofc dot corp dot sgi dot com
|
||||
calc-bugs at asthe dot com
|
||||
|
||||
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
||||
|
||||
but see the BUGS file first.
|
||||
|
||||
The calc web site is located at:
|
||||
|
||||
http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
##
|
||||
@@ -116,12 +118,12 @@ The calc web site is located at:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: README,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: README,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/README,v $
|
||||
##
|
||||
## Under source code control: 1995/10/25 05:27:59
|
||||
## File existed as early as: 1995
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
## Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
113
README.WINDOWS
Normal file
113
README.WINDOWS
Normal file
@@ -0,0 +1,113 @@
|
||||
Dear calc user on a Windoz based system,
|
||||
|
||||
See the HOWTO.INSTALL file for information on how to build and install calc.
|
||||
See also the README file.
|
||||
|
||||
NOTE: The Windoz port is extremely experimental, untested and perhaps
|
||||
incomplete. We are in the process of making it easier. The
|
||||
following should help anyone who is trying to make a go of this
|
||||
under the current code conditions.
|
||||
|
||||
NOTE: We are currently ONLY making an effort to support building under
|
||||
Windoz using the Cygwin project (http://sources.redhat.com/cygwin/)
|
||||
with the GCC compiler and Un*x tools for Windows.
|
||||
|
||||
NOTE: The main developers do not have access to a Windoz based platform.
|
||||
While we will make an effort to not break calc Windoz based system,
|
||||
our lack of a Windoz test environment will mean we will make mistakes
|
||||
from time to time. Hopefully Windowz users can overcome these mistakes.
|
||||
Of course you are welcome to send us any patches that fix your
|
||||
Windoz build environment.
|
||||
|
||||
=-=
|
||||
|
||||
An effort is being made to allow windows users to compile calc using the
|
||||
Cygwin project (http://sources.redhat.com/cygwin/) with the GCC compiler
|
||||
and Un*x tools for Windows.
|
||||
|
||||
The major porting work was performed by Thomas Jones-Low
|
||||
(tjoneslo at softstart dot com). He said:
|
||||
|
||||
I had previous stated to this group that I have successfully managed
|
||||
to port a version of Calc to Windows, and promised some point to
|
||||
post what was required, so here it is.
|
||||
|
||||
One obvious manner of doing this port is to get the latest version
|
||||
of the Cygwin project (http://sources.redhat.com/cygwin/) with the
|
||||
GCC compiler and Un*x tools for Windows and recompile.
|
||||
|
||||
I built my working version using Calc ... I am using Visual C++
|
||||
version 7.0, which is an older version of the Microsoft development
|
||||
tools. The make file provided with Calc is not compatible with
|
||||
NMAKE, so I used the Visual Studio tools to generate another one
|
||||
(not included). Calc is built in two parts, calc.dll, which is the
|
||||
library, and calcexe.exe which is the command line interface.
|
||||
|
||||
He recommends that you generate by hand all of the header files generated
|
||||
by the make file:
|
||||
|
||||
align32.h args.h calcerr.h conf.h endian_calc.h
|
||||
fposval.h have_const.h have_fpos.h have_fpos_pos.h have_malloc.h
|
||||
have_memmv.h have_newstr.h have_offscl.h have_posscl.h
|
||||
have_stdlib.h have_string.h have_times.h have_uid_t.h
|
||||
have_unistd.h longbits.h longlong.h terminal.h
|
||||
have_ustat.h have_getsid.h have_getpgid.h
|
||||
have_gettime.h have_getprid.h have_urandom.h have_rusage.h
|
||||
have_strdup.h
|
||||
|
||||
NOTE: In a future release, a tarball of these files will be shipped with
|
||||
calc so that you do not have to do much other than inspect them.
|
||||
|
||||
=-=
|
||||
|
||||
People who maintain calc need to keep in mind the following:
|
||||
|
||||
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) 2001 Landon Curt Noll and Thomas Jones-Low
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: README.WINDOWS,v 29.3 2001/03/17 21:31:47 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/README.WINDOWS,v $
|
||||
##
|
||||
## Under source code control: 2001/02/25 14:00:05
|
||||
## File existed as early as: 2001
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
10
addop.c
10
addop.c
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: addop.c,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: addop.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/addop.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:10
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ endfunc(void)
|
||||
memcpy((char *) fp, (char *) curfunc, size);
|
||||
if (curfunc != functemplate)
|
||||
free(curfunc);
|
||||
if (conf->traceflags & TRACE_FNCODES) {
|
||||
if (newname[0] != '*' && (conf->traceflags & TRACE_FNCODES)) {
|
||||
dumpnames = TRUE;
|
||||
for (size = 0; size < fp->f_opcodecount; ) {
|
||||
printf("%ld: ", (long)size);
|
||||
@@ -318,7 +318,7 @@ freefunc(FUNC *fp)
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
}
|
||||
if (conf->traceflags & TRACE_FNCODES) {
|
||||
if (newname[0] != '*' && (conf->traceflags & TRACE_FNCODES)) {
|
||||
printf("Freeing function \"%s\"\n",namestr(&funcnames,index));
|
||||
dumpnames = FALSE;
|
||||
for (i = 0; i < fp->f_opcodecount; ) {
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: align32.c,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: align32.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/align32.c,v $
|
||||
*
|
||||
* Under source code control: 1995/11/23 05:18:06
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
6
alloc.h
6
alloc.h
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: alloc.h,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: alloc.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/alloc.h,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:29
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: assocfunc.c,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: assocfunc.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/assocfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1993/07/20 23:04:27
|
||||
* File existed as early as: 1993
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
6
blkcpy.c
6
blkcpy.c
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: blkcpy.c,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: blkcpy.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.c,v $
|
||||
*
|
||||
* Under source code control: 1997/04/18 20:41:26
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
6
blkcpy.h
6
blkcpy.h
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: blkcpy.h,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: blkcpy.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.h,v $
|
||||
*
|
||||
* Under source code control: 1997/04/18 20:41:25
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
8
block.c
8
block.c
@@ -19,15 +19,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: block.c,v 29.1 1999/12/14 09:15:29 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: block.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/block.c,v $
|
||||
*
|
||||
* Under source code control: 1997/02/27 00:29:40
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
8
block.h
8
block.h
@@ -19,15 +19,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: block.h,v 29.1 1999/12/14 09:15:30 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: block.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/block.h,v $
|
||||
*
|
||||
* Under source code control: 1997/02/21 05:03:39
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: byteswap.c,v 29.1 1999/12/14 09:15:30 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: byteswap.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/byteswap.c,v $
|
||||
*
|
||||
* Under source code control: 1995/10/11 04:44:01
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: byteswap.h,v 29.1 1999/12/14 09:15:30 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: byteswap.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/byteswap.h,v $
|
||||
*
|
||||
* Under source code control: 1995/10/11 04:44:01
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
10
cal/Makefile
10
cal/Makefile
@@ -18,15 +18,15 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: Makefile,v 29.1 1999/12/14 09:15:30 chongo Exp $
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: Makefile,v 29.3 2000/12/15 14:42:52 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1991/07/21 05:00:54
|
||||
# File existed as early as: 1991
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
#
|
||||
# calculator by David I. Bell with help/mods from others
|
||||
# Makefile by Landon Curt Noll
|
||||
@@ -70,7 +70,7 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
|
||||
test3500.cal seedrandom.cal test4000.cal test4100.cal test4600.cal \
|
||||
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
|
||||
randomrun.cal xx_print.cal natnumset.cal qtime.cal test8400.cal \
|
||||
test8500.cal
|
||||
test8500.cal test8600.cal
|
||||
|
||||
# These files are found (but not built) in the distribution
|
||||
#
|
||||
|
68
cal/README
68
cal/README
@@ -1,7 +1,7 @@
|
||||
Calc standard resource files
|
||||
----------------------------
|
||||
|
||||
To load a reosurce file, try:
|
||||
To load a resource file, try:
|
||||
|
||||
read filename
|
||||
|
||||
@@ -37,9 +37,10 @@ be useful!
|
||||
|
||||
If you write something that you think is useful, please send it to:
|
||||
|
||||
calc-tester at postofc dot corp dot sgi dot com
|
||||
calc-contrib at asthe dot com
|
||||
|
||||
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
||||
|
||||
By convention, a resource file only defines and/or initializes functions,
|
||||
objects and variables. (The regress.cal and testxxx.cal regression test
|
||||
@@ -58,7 +59,7 @@ files have already been read, the read -once will act as a noop.
|
||||
|
||||
The "resource_debug" parameter is intended for controlling the possible
|
||||
display of special information relating to functions, objects, and
|
||||
other structures created by instructions in calc resoure files.
|
||||
other structures created by instructions in calc resource files.
|
||||
Zero value of config("resource_debug") means that no such information
|
||||
is displayed. For other values, the non-zero bits which currently
|
||||
have meanings are as follows:
|
||||
@@ -115,6 +116,10 @@ bernoulli.cal
|
||||
|
||||
Calculate the nth Bernoulli number.
|
||||
|
||||
NOTE: There is now a bernoulli() builtin function. This file is
|
||||
left here for backward compatibility and now simply returns
|
||||
the buildin function.
|
||||
|
||||
|
||||
bigprime.cal
|
||||
|
||||
@@ -273,7 +278,7 @@ pell.cal
|
||||
pell(D)
|
||||
|
||||
Solve Pell's equation; Returns the solution X to: X^2 - D * Y^2 = 1.
|
||||
Type the solution to pells equation for a particular D.
|
||||
Type the solution to Pell's equation for a particular D.
|
||||
|
||||
|
||||
pi.cal
|
||||
@@ -287,7 +292,7 @@ pi.cal
|
||||
The piforever() prints digits of pi, nicely formatted, for as long
|
||||
as your free memory space and system up time allows.
|
||||
|
||||
The piforever() funcion (written by Klaus Alexander Seistrup
|
||||
The piforever() function (written by Klaus Alexander Seistrup
|
||||
<klaus@seistrup.dk>) was inspired by an algorithm conceived by
|
||||
Lambert Meertens. See also the ABC Programmer's Handbook, by Geurts,
|
||||
Meertens & Pemberton, published by Prentice-Hall (UK) Ltd., 1990.
|
||||
@@ -355,7 +360,7 @@ quat.cal
|
||||
quat_shift(a, b)
|
||||
|
||||
Calculate using quaternions of the form: a + bi + cj + dk. In these
|
||||
functions, quaternians are manipulated in the form: s + v, where
|
||||
functions, quaternions are manipulated in the form: s + v, where
|
||||
s is a scalar and v is a vector of size 3.
|
||||
|
||||
|
||||
@@ -385,7 +390,7 @@ randombitrun.cal
|
||||
randombitrun([run_cnt])
|
||||
|
||||
Using randombit(1) to generate a sequence of random bits, determine if
|
||||
the number and kength of identical bits runs match what is expected.
|
||||
the number and length of identical bits runs match what is expected.
|
||||
By default, run_cnt is to test the next 65536 random values.
|
||||
|
||||
This tests the Blum-Blum-Shub generator.
|
||||
@@ -488,7 +493,7 @@ test1700.cal
|
||||
|
||||
value
|
||||
|
||||
This resoure files is used by regress.cal to test the read and use keywords.
|
||||
This resource files is used by regress.cal to test the read and use keywords.
|
||||
|
||||
|
||||
test2600.cal
|
||||
@@ -513,7 +518,7 @@ test2600.cal
|
||||
checkresult(x, y, z, a)
|
||||
test2600(verbose, tnum)
|
||||
|
||||
This resoure files is used by regress.cal to test some of builtin functions
|
||||
This resource files is used by regress.cal to test some of builtin functions
|
||||
in terms of accuracy and roundoff.
|
||||
|
||||
|
||||
@@ -536,7 +541,7 @@ test2700.cal
|
||||
iscomsq(x)
|
||||
test2700(verbose, tnum)
|
||||
|
||||
This resoure files is used by regress.cal to test sqrt() for real and
|
||||
This resource files is used by regress.cal to test sqrt() for real and
|
||||
complex values.
|
||||
|
||||
|
||||
@@ -624,7 +629,7 @@ test4000.cal
|
||||
test4000(verbose, tnum) defined
|
||||
|
||||
This resource file is used by regress.cal to test ptest, nextcand and
|
||||
prevcand buildins.
|
||||
prevcand builtins.
|
||||
|
||||
test4100.cal
|
||||
|
||||
@@ -676,6 +681,35 @@ test5200.cal
|
||||
This resource file is used by regress.cal to test the fix of a
|
||||
global/static bug.
|
||||
|
||||
test8400.cal
|
||||
|
||||
test8400() defined
|
||||
|
||||
This resource file is used by regress.cal to check for quit-based
|
||||
memory leaks.
|
||||
|
||||
test8500.cal
|
||||
|
||||
global err_8500
|
||||
global L_8500
|
||||
global ver_8500
|
||||
global old_seed_8500
|
||||
global cfg_8500
|
||||
onetest_8500(a,b,rnd) defined
|
||||
divmod_8500(N, M1, M2, testnum) defined
|
||||
|
||||
This resource file is used by regress.cal to the // and % operators.
|
||||
|
||||
test8600.cal
|
||||
|
||||
global min_8600
|
||||
global max_8600
|
||||
global hash_8600
|
||||
global hmean_8600
|
||||
|
||||
This resource file is used by regress.cal to test a change of
|
||||
allowing up to 1024 args to be passed to a builtin function.
|
||||
|
||||
unitfrac.cal
|
||||
|
||||
unitfrac(x)
|
||||
@@ -704,7 +738,7 @@ xx_print.cal
|
||||
|
||||
Demo for the xx_print object routines.
|
||||
|
||||
## Copyright (C) 1999 David I. Bell and Landon Curt Noll
|
||||
## Copyright (C) 2000 David I. Bell and Landon Curt Noll
|
||||
##
|
||||
## Primary author: Landon Curt Noll
|
||||
##
|
||||
@@ -722,12 +756,12 @@ xx_print.cal
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: README,v 29.1 1999/12/14 09:15:30 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: README,v 29.4 2000/12/17 12:26:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
|
||||
##
|
||||
## Under source code control: 1990/02/15 01:50:32
|
||||
## File existed as early as: before 1990
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
## Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: beer.cal,v 29.1 1999/12/14 09:15:30 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: beer.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/beer.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/11/13 13:21:05
|
||||
* File existed as early as: 1996
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* bernoulli - clculate the Nth Bernoulli number B(n)
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 2000 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,24 +17,28 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: bernoulli.cal,v 29.1 1999/12/14 09:15:30 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: bernoulli.cal,v 29.3 2000/12/17 12:26:04 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bernoulli.cal,v $
|
||||
*
|
||||
* Under source code control: 1991/09/30 11:18:41
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* Calculate the Nth Bernoulli number B(n).
|
||||
* This uses the following symbolic formula to calculate B(n):
|
||||
*
|
||||
* NOTE: This is now a bulitin function.
|
||||
*
|
||||
* The non-buildin code used the following symbolic formula to calculate B(n):
|
||||
*
|
||||
* (b+1)^(n+1) - b^(n+1) = 0
|
||||
*
|
||||
* where b is a dummy value, and each power b^i gets replaced by B(i).
|
||||
* For example, for n = 3:
|
||||
*
|
||||
* (b+1)^4 - b^4 = 0
|
||||
* b^4 + 4*b^3 + 6*b^2 + 4*b + 1 - b^4 = 0
|
||||
* 4*b^3 + 6*b^2 + 4*b + 1 = 0
|
||||
@@ -48,11 +52,14 @@
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
static Bnmax;
|
||||
static mat Bn[1001];
|
||||
*/
|
||||
|
||||
define B(n)
|
||||
{
|
||||
/*
|
||||
local nn, np1, i, sum, mulval, divval, combval;
|
||||
|
||||
if (!isint(n) || (n < 0))
|
||||
@@ -85,4 +92,6 @@ define B(n)
|
||||
}
|
||||
Bnmax = n;
|
||||
return Bn[n];
|
||||
*/
|
||||
return bernoulli(n);
|
||||
}
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: bigprime.cal,v 29.1 1999/12/14 09:15:30 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: bigprime.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bigprime.cal,v $
|
||||
*
|
||||
* Under source code control: 1991/05/22 21:56:32
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -16,14 +16,14 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: bindings,v 29.1 1999/12/14 09:15:30 chongo Exp $
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: bindings,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bindings,v $
|
||||
#
|
||||
# Under source code control: 1993/05/02 20:09:19
|
||||
# File existed as early as: 1993
|
||||
#
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
# NOTE: This facility is ignored if calc was compiled with GNU-readline.
|
||||
# In that case, the standard readline mechanisms (see readline(3))
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: chrem.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: chrem.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/chrem.cal,v $
|
||||
*
|
||||
* Under source code control: 1992/09/26 01:00:47
|
||||
* File existed as early as: 1992
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: deg.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: deg.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/deg.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:33
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: ellip.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: ellip.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/ellip.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:33
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: hello.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: hello.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/hello.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/11/13 13:25:43
|
||||
* File existed as early as: 1996
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: lucas.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: lucas.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/05/03 16:49:51
|
||||
* File existed as early as: 1990
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: lucas_chk.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: lucas_chk.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas_chk.cal,v $
|
||||
*
|
||||
* Under source code control: 1991/01/11 05:41:43
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: lucas_tbl.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: lucas_tbl.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas_tbl.cal,v $
|
||||
*
|
||||
* Under source code control: 1991/01/26 02:43:43
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: mersenne.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: mersenne.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mersenne.cal,v $
|
||||
*
|
||||
* Under source code control: 1991/05/22 21:56:36
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: mfactor.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: mfactor.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mfactor.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/07/06 06:09:40
|
||||
* File existed as early as: 1996
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: mod.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: mod.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mod.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:34
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: natnumset.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: natnumset.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/natnumset.cal,v $
|
||||
*
|
||||
* Under source code control: 1997/09/07 23:53:51
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: pell.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: pell.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pell.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:34
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: pi.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: pi.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pi.cal,v $
|
||||
*
|
||||
* Under source code control: 1991/05/22 21:56:37
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: pix.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: pix.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pix.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/07/09 03:14:14
|
||||
* File existed as early as: 1996
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: pollard.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: pollard.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/pollard.cal,v $
|
||||
*
|
||||
* Under source code control: 1991/05/22 21:56:37
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: poly.cal,v 29.1 1999/12/14 09:15:31 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: poly.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/poly.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:35
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: prompt.cal,v 29.1 1999/12/14 09:15:32 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: prompt.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/prompt.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/12/18 04:43:25
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: psqrt.cal,v 29.1 1999/12/14 09:15:32 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: psqrt.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/psqrt.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:35
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -1,24 +1,46 @@
|
||||
/*
|
||||
* qtime - Display time as English sentence
|
||||
*
|
||||
* Copyright (C) 1999 Klaus Alexander Seistrup and Landon Curt Noll
|
||||
*
|
||||
* Written by: Klaus Alexander Seistrup <kseis@magnetic-ink.dk>
|
||||
* With mods by: Landon Curt Noll <http://www.isthe.com/chongo/>
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: qtime.cal,v 29.4 2000/12/18 10:18:40 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/qtime.cal,v $
|
||||
*
|
||||
* Under source code control: 1999/10/13 04:10:33
|
||||
* File existed as early as: 1999
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* usage:
|
||||
* qtime(utc_hr_offset)
|
||||
*
|
||||
* utc_hr_offset Offset from UTC in hours.
|
||||
*
|
||||
* Written by: Klaus Alexander Seistrup <kseis@magnetic-ink.dk>
|
||||
* With minor mods by: Landon Curt Noll <http://reality.sgi.com/chongo/>
|
||||
*
|
||||
* See:
|
||||
* http://www.magnetic-ink.dk/download/qtime.html
|
||||
*
|
||||
* for examples of qtime() written on other languages.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: qtime.cal,v 29.1 1999/12/14 09:15:32 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/qtime.cal,v $
|
||||
*
|
||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: quat.cal,v 29.1 1999/12/14 09:15:32 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: quat.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/quat.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:35
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: randbitrun.cal,v 29.1 1999/12/14 09:15:32 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: randbitrun.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randbitrun.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/02/13 03:43:11
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: randmprime.cal,v 29.1 1999/12/14 09:15:32 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: randmprime.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randmprime.cal,v $
|
||||
*
|
||||
* Under source code control: 1994/03/14 23:11:21
|
||||
* File existed as early as: 1994
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: randombitrun.cal,v 29.1 1999/12/14 09:15:32 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: randombitrun.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randombitrun.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/02/13 03:43:11
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: randomrun.cal,v 29.1 1999/12/14 09:15:32 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: randomrun.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randomrun.cal,v $
|
||||
*
|
||||
* Under source code control: 1997/02/19 03:35:59
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: randrun.cal,v 29.1 1999/12/14 09:15:32 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: randrun.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randrun.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/02/12 20:00:06
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
112
cal/regress.cal
112
cal/regress.cal
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: regress.cal,v 29.1 1999/12/14 09:15:32 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: regress.cal,v 29.6 2000/12/17 12:26:42 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:36
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -755,7 +755,7 @@ define test_functions()
|
||||
vrfy(den(17) == 1, '712: den(17) == 1');
|
||||
vrfy(den(3/7) == 7, '713: den(3/7) == 7');
|
||||
vrfy(den(-2/3) == 3, '714: den(-2/3) == 3');
|
||||
vrfy(digits(0) == 1, '715: digits(0) == 1');
|
||||
vrfy(digits(0) == 0, '715: digits(0) == 0');
|
||||
vrfy(digits(9) == 1, '716: digits(9) == 1');
|
||||
vrfy(digits(10) == 2, '717: digits(10) == 2');
|
||||
vrfy(digits(-691) == 3, '718: digits(-691) == 3');
|
||||
@@ -1029,8 +1029,8 @@ define test_functions()
|
||||
vrfy(digit(a,-1) == 4, '974: digit(a,-1) == 4');
|
||||
vrfy(digit(a,-2) == 2, '975: digit(a,-2) == 2');
|
||||
vrfy(digit(a,-3) == 8, '976: digit(a,-3) == 8');
|
||||
vrfy(digits(0) == 1, '977: digits(0) == 1');
|
||||
vrfy(digits(0.0123) == 1, '978: digits(0.0123) == 1');
|
||||
vrfy(digits(0) == 0, '977: digits(0) == 0');
|
||||
vrfy(digits(0.0123) == 0, '978: digits(0.0123) == 0');
|
||||
vrfy(digits(3.7) == 1, '979: digits(3.7) == 1');
|
||||
vrfy(digits(-27) == 2, '980: digits(-27) == 2');
|
||||
vrfy(digits(-99.7) == 2, '981: digits(-99.7) == 2');
|
||||
@@ -1223,7 +1223,85 @@ define test_functions()
|
||||
vrfy(hnrmod(21<<500+7,3,500,-1) == (21<<500+7)%(3<<500-1),
|
||||
'1112: hnrmod(21<<500+7,3,500,-1) == (21<<500+7)%(3<<500-1)');
|
||||
|
||||
print '1113: Ending test_functions';
|
||||
/*
|
||||
* catalan testing
|
||||
*/
|
||||
vrfy(catalan(2) == 2, '1113: catalan(2) == 2');
|
||||
vrfy(catalan(3) == 5, '1114: catalan(3) == 5');
|
||||
vrfy(catalan(4) == 14, '1115: catalan(4) == 14');
|
||||
vrfy(catalan(20) == 6564120420, '1116: catalan(20) == 6564120420');
|
||||
|
||||
/*
|
||||
* bernoulli builtin function testing
|
||||
*/
|
||||
vrfy(bernoulli(0) == 1, '1117: bernoulli(0) == 1');
|
||||
vrfy(bernoulli(1) == -1/2, '1118: bernoulli(1) == -1/2');
|
||||
vrfy(bernoulli(2) == 1/6, '1119: bernoulli(2) == 1/6');
|
||||
vrfy(bernoulli(3) == 0, '1120: bernoulli(3) == 0');
|
||||
vrfy(bernoulli(4) == -1/30, '1121: bernoulli(4) == -1/30');
|
||||
vrfy(bernoulli(5) == 0, '1122: bernoulli(5) == 0');
|
||||
vrfy(bernoulli(6) == 1/42, '1123: bernoulli(6) == 1/42');
|
||||
vrfy(bernoulli(32) == -7709321041217/510,
|
||||
'1124: bernoulli(32) == -7709321041217/510');
|
||||
|
||||
/*
|
||||
* euler function testing
|
||||
*/
|
||||
vrfy(euler(0) == 1, '1125: euler(0) == 1');
|
||||
vrfy(euler(1) == 0, '1126: euler(1) == 0');
|
||||
vrfy(euler(2) == -1, '1127: euler(2) == -1');
|
||||
vrfy(euler(3) == 0, '1128: euler(3) == 0');
|
||||
vrfy(freeeuler() == null(), '1129: freeeuler() == null()');
|
||||
vrfy(euler(4) == 5, '1130: euler(4) == 5');
|
||||
vrfy(euler(5) == 0, '1131: euler(5) == 0');
|
||||
vrfy(euler(6) == -61, '1132: euler(6) == -61');
|
||||
vrfy(euler(32) == 177519391579539289436664789665,
|
||||
'1130: euler(32) == 177519391579539289436664789665');
|
||||
vrfy(freeeuler() == null(), '1133: freeeuler() == null()');
|
||||
|
||||
/*
|
||||
* digit with non-10 base
|
||||
*/
|
||||
a = 123456.789;
|
||||
print '1134: a = 123456.789';
|
||||
vrfy(digit(a, 6, 100) == 0, '1135: digit(a, 6, 100) == 0');
|
||||
vrfy(digit(a, 5, 100) == 0, '1136: digit(a, 5, 100) == 0');
|
||||
vrfy(digit(a, 4, 100) == 0, '1137: digit(a, 4, 100) == 0');
|
||||
vrfy(digit(a, 3, 100) == 0, '1138: digit(a, 3, 100) == 0');
|
||||
vrfy(digit(a, 2, 100) == 12, '1139: digit(a, 2, 100) == 12');
|
||||
vrfy(digit(a, 1, 100) == 34, '1140: digit(a, 1, 100) == 34');
|
||||
vrfy(digit(a, 0, 100) == 56, '1141: digit(a, 0, 100) == 56');
|
||||
vrfy(digit(a, -1, 100) == 78, '1142: digit(a, -1, 100) == 78');
|
||||
vrfy(digit(a, -2, 100) == 90, '1143: digit(a, -2, 100) == 90');
|
||||
vrfy(digit(a, -3, 100) == 0, '1144: digit(a, -3, 100) == 0');
|
||||
vrfy(digit(a, -4, 100) == 0, '1145: digit(a, -4, 100) == 0');
|
||||
vrfy(digit(a, -5, 100) == 0, '1146: digit(a, -5, 100) == 0');
|
||||
vrfy(digit(a, -6, 100) == 0, '1146: digit(a, -6, 100) == 0');
|
||||
|
||||
/*
|
||||
* digits with a non-10 base
|
||||
*/
|
||||
vrfy(digits(a, 100) == 3, '1147: digits(a, 100) == 3');
|
||||
vrfy(digits(2^256-1, 256) == 32,'1148: digits(2^256-1, 256) == 32');
|
||||
|
||||
/*
|
||||
* places with a non-10 base
|
||||
*/
|
||||
vrfy(places(0.0123, 2) == -1, '1149: places(0.0123, 2) == -1');
|
||||
vrfy(places(0.625, 2) == 3, '1150: places(0.625, 2) == 3');
|
||||
vrfy(places(0.625, 8) == 1, '1151: places(0.625, 8) == 1');
|
||||
vrfy(places(171/2^712, 2) == 712,
|
||||
'1152: places(171/2^7120.625, 2) == 712');
|
||||
vrfy(places(171/2^712, 64) == 119,
|
||||
'1152: places(171/2^7120.625, 64) == 119');
|
||||
|
||||
/*
|
||||
* verify sleep
|
||||
*/
|
||||
vrfy(sleep(1/5) == null(), '1153: sleep(1/5) == null()');
|
||||
vrfy(sleep(1) == null(), '1154: sleep(1) == null()');
|
||||
|
||||
print '1155: Ending test_functions';
|
||||
}
|
||||
print '017: parsed test_functions()';
|
||||
|
||||
@@ -2987,7 +3065,7 @@ define test_error()
|
||||
vrfy(root(3,2,0) == error(10029),
|
||||
'3644: root(3,2,0) == error(10029)');
|
||||
vrfy(norm("x") == error(10030), '3645: norm("x") == error(10030)');
|
||||
vrfy(null() << 2 == error(10031),'3646: null() << 2 == error(10031)');
|
||||
vrfy(list() << 2 == error(10031),'3646: list() << 2 == error(10031)');
|
||||
vrfy(1.5 << 2 == error(10031), '3647: 1.5 << 2 == error(10031)');
|
||||
vrfy(3 << "x" == error(10032), '3648: 3 << "x" == error(10032)');
|
||||
vrfy(3 << 1.5 == error(10032), '3649: 3 << 1.5 == error(10032)');
|
||||
@@ -3085,8 +3163,7 @@ define test_error()
|
||||
print '3712: e9999 = error(9999)';
|
||||
vrfy(errno() == 9999, '3713: errno() == 9999');
|
||||
vrfy(error() == e9999, '3714: error() == e9999');
|
||||
vrfy(substr(strerror(), strpos(strerror(),"9999"), 4) == "9999",
|
||||
'3715: substr(strerror(), strpos(strerror(),"9999"), 4) == "9999"');
|
||||
/* test 3715 removed due to non-portable strerror() output */
|
||||
x = newerror("Alpha");
|
||||
print '3716: x = newerror("Alpha")';
|
||||
n = iserror(x);
|
||||
@@ -3097,16 +3174,14 @@ define test_error()
|
||||
vrfy(errno(9999) == n, '3721: errno() == n');
|
||||
vrfy(errno() == 9999, '3722: errno() == 9999');
|
||||
vrfy(error() == e9999, '3723: error() == e9999');
|
||||
vrfy(substr(strerror(), strpos(strerror(),"9999"), 4) == "9999",
|
||||
'3724: substr(strerror(), strpos(strerror(),"9999"), 4) == "9999"');
|
||||
/* test 3724 removed due to non-portable strerror() output */
|
||||
a = 1/0;
|
||||
print '3725: a = 1/0';
|
||||
vrfy(strerror() == "Division by zero",
|
||||
'3726: strerror() == "Division by zero"');
|
||||
n = 8191;
|
||||
print '3727: n = 8191';
|
||||
vrfy(substr(strerror(8191),strpos(strerror(n),"8191"), 4) == "8191",
|
||||
'3728: substr(strerror(n),strpos(strerror(n),"8191"),4) == "8191"');
|
||||
/* test 3728 removed due to non-portable strerror() output */
|
||||
|
||||
/* errmax and errcount should be bumped up the 148 errors above */
|
||||
vrfy(errcount() == ecnt, '3729: errcount() == ecnt');
|
||||
@@ -7541,6 +7616,15 @@ read -once "test8500";
|
||||
/* 85xx: Ending test_divmod is printed by test8500.cal */
|
||||
|
||||
|
||||
/*
|
||||
* test_maxargs - test up to 1024 args being passed to a builtin function
|
||||
*/
|
||||
print;
|
||||
print '8600: Starting test_1024args'
|
||||
read -once "test8600";
|
||||
/* 86xx: Ending test_1024args is printed by test8600.cal */
|
||||
|
||||
|
||||
/*
|
||||
* read various calc resource files
|
||||
*
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: seedrandom.cal,v 29.1 1999/12/14 09:15:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: seedrandom.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/seedrandom.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/01/01 08:21:00
|
||||
* File existed as early as: 1996
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: solve.cal,v 29.1 1999/12/14 09:15:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: solve.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/solve.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:37
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: sumsq.cal,v 29.1 1999/12/14 09:15:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: sumsq.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/sumsq.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:37
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: surd.cal,v 29.1 1999/12/14 09:15:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: surd.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/surd.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:38
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test1700.cal,v 29.1 1999/12/14 09:15:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test1700.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test1700.cal,v $
|
||||
*
|
||||
* Under source code control: 1994/03/14 23:12:51
|
||||
* File existed as early as: 1994
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test2300.cal,v 29.1 1999/12/14 09:15:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test2300.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2300.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/07/09 06:12:13
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test2600.cal,v 29.1 1999/12/14 09:15:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test2600.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2600.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/10/13 00:13:14
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test2700.cal,v 29.1 1999/12/14 09:15:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test2700.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2700.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/11/01 22:52:25
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test3100.cal,v 29.1 1999/12/14 09:15:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test3100.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3100.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/11/28 11:56:57
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test3300.cal,v 29.1 1999/12/14 09:15:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test3300.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3300.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/12/02 04:27:41
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test3400.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test3400.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3400.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/12/02 05:20:11
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test3500.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test3500.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3500.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/12/18 22:50:46
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test4000.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test4000.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4000.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/03/13 02:38:45
|
||||
* File existed as early as: 1996
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test4100.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test4100.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4100.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/03/13 03:53:22
|
||||
* File existed as early as: 1996
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test4600.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test4600.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4600.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/07/02 20:04:40
|
||||
* File existed as early as: 1996
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test5100.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test5100.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test5100.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/12/02 23:57:10
|
||||
* File existed as early as: 1996
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test5200.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test5200.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test5200.cal,v $
|
||||
*
|
||||
* Under source code control: 1997/02/07 02:48:10
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test8400.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test8400.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test8400.cal,v $
|
||||
*
|
||||
* Under source code control: 1999/10/31 01:00:03
|
||||
* File existed as early as: 1999
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: test8500.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test8500.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test8500.cal,v $
|
||||
*
|
||||
* Under source code control: 1999/11/12 20:59:59
|
||||
* File existed as early as: 1999
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
1406
cal/test8600.cal
Normal file
1406
cal/test8600.cal
Normal file
File diff suppressed because it is too large
Load Diff
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: unitfrac.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: unitfrac.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/unitfrac.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:38
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: varargs.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: varargs.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/varargs.cal,v $
|
||||
*
|
||||
* Under source code control: 1991/05/22 21:56:34
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: xx_print.cal,v 29.1 1999/12/14 09:15:34 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: xx_print.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/xx_print.cal,v $
|
||||
*
|
||||
* Under source code control: 1997/04/17 00:08:50
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
755
calc.c
755
calc.c
@@ -19,23 +19,40 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: calc.c,v 29.2 1999/12/17 09:21:45 chongo Exp $
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: calc.c,v 29.7 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:11
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#if !defined (_WIN32)
|
||||
# include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <io.h>
|
||||
/*
|
||||
* getopt.h file is from the Cygwin GNU library
|
||||
*
|
||||
* See:
|
||||
* http://sources.redhat.com/cygwin/
|
||||
*/
|
||||
# include "../getopt/getopt.h"
|
||||
# define strdup _strdup
|
||||
# define isatty _isatty
|
||||
#endif /* Windoz */
|
||||
|
||||
#define CALC_C
|
||||
#include "calc.h"
|
||||
#include "hist.h"
|
||||
@@ -49,6 +66,7 @@
|
||||
#include "custom.h"
|
||||
#include "math_error.h"
|
||||
#include "args.h"
|
||||
#include "zmath.h"
|
||||
|
||||
#include "have_unistd.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
@@ -70,8 +88,8 @@
|
||||
* static definitions and functions
|
||||
*/
|
||||
static void intint(int arg); /* interrupt routine */
|
||||
static int script_args(int argc,char ***argv,char **shellfile,char **program);
|
||||
|
||||
static int nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr);
|
||||
static void set_run_state(run state);
|
||||
|
||||
/*
|
||||
* Top level calculator routine.
|
||||
@@ -81,26 +99,57 @@ main(int argc, char **argv)
|
||||
{
|
||||
int want_defhelp = 0; /* 1=> we only want the default help */
|
||||
int cmdlen; /* length of the command string */
|
||||
char *shellfile = NULL; /* != NULL ==> name of calc shell script */
|
||||
extern char *optarg; /* option argument */
|
||||
extern int optind; /* option index */
|
||||
int newcmdlen;
|
||||
int c; /* option */
|
||||
char *p;
|
||||
long i;
|
||||
int index;
|
||||
int maxindex;
|
||||
char *cp;
|
||||
char *endcp;
|
||||
char *bp;
|
||||
BOOL done = FALSE;
|
||||
BOOL havearg;
|
||||
BOOL haveendstr;
|
||||
int len;
|
||||
|
||||
/*
|
||||
* parse args
|
||||
*/
|
||||
program = argv[0];
|
||||
/* catch the case of a leading -S option */
|
||||
if (argc > 2 && strncmp(argv[1], "-S", 2) == 0) {
|
||||
/* convert the calc shell options into command line options */
|
||||
argc = script_args(argc, &argv, &shellfile, &program);
|
||||
/* -S implies -s */
|
||||
s_flag = TRUE;
|
||||
}
|
||||
|
||||
cmdbuf[0] = '\0';
|
||||
cmdlen = 0;
|
||||
|
||||
/* process command line options */
|
||||
while ((c = getopt(argc, argv, "Cehim:npquvcdD:s")) != -1) {
|
||||
|
||||
index = 1;
|
||||
cp = endcp = NULL;
|
||||
maxindex = argc;
|
||||
havecommands = FALSE;
|
||||
while (index < maxindex && !done) {
|
||||
cp = argv[index];
|
||||
if (*cp == '\0') {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
for (;;) {
|
||||
havearg = FALSE;
|
||||
if (*cp != '-') {
|
||||
done = TRUE;
|
||||
break;
|
||||
}
|
||||
++cp;
|
||||
if (*cp == '-') {
|
||||
cp++;
|
||||
while (*cp == ' ')
|
||||
++cp;
|
||||
done = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
c = *cp;
|
||||
if (c == '\0' || c == ' ')
|
||||
break;
|
||||
switch (c) {
|
||||
case 'C':
|
||||
#if defined(CUSTOM)
|
||||
@@ -108,12 +157,14 @@ main(int argc, char **argv)
|
||||
break;
|
||||
#else /* CUSTOM */
|
||||
/*
|
||||
* we are too early in processing to call
|
||||
* libcalc_call_me_last() - nothing to cleanup
|
||||
* we are too early in processing to
|
||||
* call libcalc_call_me_last() -
|
||||
* nothing to cleanup
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"%s: calc was built with custom functions "
|
||||
"disabled, -C usage is disallowed\n", program);
|
||||
"%s: calc was built with custom"
|
||||
" functions disabled, -C usage is"
|
||||
" disallowed\n", program);
|
||||
exit(1);
|
||||
#endif /* CUSTOM */
|
||||
case 'e':
|
||||
@@ -126,19 +177,41 @@ main(int argc, char **argv)
|
||||
i_flag = TRUE;
|
||||
break;
|
||||
case 'm':
|
||||
if (optarg[1] != '\0' || *optarg<'0' || *optarg>'7') {
|
||||
cp++;
|
||||
while (*cp == ' ' || *cp == '\t')
|
||||
cp++;
|
||||
if (*cp == '\0') {
|
||||
index++;
|
||||
if (index >= argc) {
|
||||
fprintf(stderr,
|
||||
"-m expects"
|
||||
" argument");
|
||||
exit (1);
|
||||
}
|
||||
cp = argv[index];
|
||||
}
|
||||
|
||||
if (*cp < '0' || *cp > '7') {
|
||||
/*
|
||||
* we are too early in processing to
|
||||
* call libcalc_call_me_last()
|
||||
* we are too early in
|
||||
* processing to call
|
||||
* libcalc_call_me_last()
|
||||
* nothing to cleanup
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"%s: unknown -m arg\n", program);
|
||||
"%s: unknown -m arg\n",
|
||||
program);
|
||||
exit(1);
|
||||
}
|
||||
allow_read = (((*optarg-'0') & 04) > 0);
|
||||
allow_write = (((*optarg-'0') & 02) > 0);
|
||||
allow_exec = (((*optarg-'0') & 01) > 0);
|
||||
allow_read = (((*cp-'0') & 04) > 0);
|
||||
allow_write = (((*cp-'0') & 02) > 0);
|
||||
allow_exec = (((*cp-'0') & 01) > 0);
|
||||
cp++;
|
||||
if (*cp != ' ' && *cp != '\0') {
|
||||
fprintf(stderr, "??? m-arg");
|
||||
exit(1);
|
||||
}
|
||||
havearg = TRUE;
|
||||
break;
|
||||
case 'n':
|
||||
new_std = TRUE;
|
||||
@@ -160,107 +233,242 @@ main(int argc, char **argv)
|
||||
break;
|
||||
case 'v':
|
||||
/*
|
||||
* we are too early in processing to call
|
||||
* libcalc_call_me_last() - nothing to cleanup
|
||||
* we are too early in processing to
|
||||
* call libcalc_call_me_last() -
|
||||
* nothing to cleanup
|
||||
*/
|
||||
printf("%s (version %s)\n", CALC_TITLE, version());
|
||||
printf("%s (version %s)\n",
|
||||
CALC_TITLE, version());
|
||||
exit(0);
|
||||
case 'D':
|
||||
/*
|
||||
* parse the -D optarg
|
||||
* parse the -D arg
|
||||
*
|
||||
* Could be calc_debug
|
||||
* or calc_debug:resource_debug
|
||||
* or calc_debug:resource_debug:user_debug
|
||||
* Could be:
|
||||
*
|
||||
* calc_debug
|
||||
* calc_debug:resource_debug
|
||||
* calc_debug:resource_debug:user_debug
|
||||
*/
|
||||
calc_debug = optarg;
|
||||
p = strchr(optarg, ':');
|
||||
if (p != NULL) {
|
||||
*p = '\0';
|
||||
resource_debug = p+1;
|
||||
p = strchr(resource_debug, ':');
|
||||
if (p != NULL) {
|
||||
*p = '\0';
|
||||
user_debug = p+1;
|
||||
if (nextcp(&cp, &index, argc, argv,
|
||||
FALSE)) {
|
||||
fprintf(stderr,
|
||||
"-D expects argument\n");
|
||||
exit (1);
|
||||
}
|
||||
havearg = TRUE;
|
||||
if (*cp != ':') {
|
||||
if (*cp < '0' || *cp > '9') {
|
||||
fprintf(stderr,
|
||||
"-D expects"
|
||||
" integer\n");
|
||||
exit (1);
|
||||
}
|
||||
calc_debug = cp;
|
||||
(void) strtol(cp, &endcp, 10);
|
||||
cp = endcp;
|
||||
if (*cp != '\0' &&
|
||||
*cp != ' ' && *cp != ':') {
|
||||
fprintf(stderr,
|
||||
"Bad syntax im -D"
|
||||
" arg\n");
|
||||
exit (1);
|
||||
}
|
||||
if (*cp != ':') {
|
||||
if (nextcp(&cp, &index,
|
||||
argc, argv,
|
||||
FALSE)
|
||||
|| *cp != ':')
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nextcp(&cp, &index, argc, argv,
|
||||
FALSE)) {
|
||||
fprintf(stderr,
|
||||
"-D : expects"
|
||||
" argument\n");
|
||||
exit (1);
|
||||
}
|
||||
if (*cp != ':') {
|
||||
if (*cp < '0' || *cp > '9') {
|
||||
fprintf(stderr,
|
||||
"-D : expects"
|
||||
" integer\n");
|
||||
exit (1);
|
||||
}
|
||||
resource_debug = cp;
|
||||
(void) strtol(cp, &endcp, 10);
|
||||
cp = endcp;
|
||||
if (*cp != '\0' &&
|
||||
*cp != ' ' && *cp != ':') {
|
||||
fprintf(stderr,
|
||||
"Bad syntax im -D"
|
||||
" : arg\n");
|
||||
exit (1);
|
||||
}
|
||||
if (*cp != ':') {
|
||||
if (nextcp(&cp, &index,
|
||||
argc, argv,
|
||||
FALSE)
|
||||
|| *cp != ':') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nextcp(&cp, &index, argc, argv,
|
||||
FALSE)) {
|
||||
fprintf(stderr, "-D : : expects"
|
||||
" argument\n");
|
||||
exit (1);
|
||||
}
|
||||
if (*cp < '0' || *cp > '9') {
|
||||
fprintf(stderr, "-D :: expects"
|
||||
" integer\n");
|
||||
exit (1);
|
||||
}
|
||||
user_debug = cp;
|
||||
(void) strtol(cp, &endcp, 10);
|
||||
cp = endcp;
|
||||
if (*cp != '\0' && *cp != ' ') {
|
||||
fprintf(stderr, "Bad syntax in"
|
||||
" -D : : arg\n");
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
haveendstr = (cp[1] == '\0');
|
||||
if (nextcp(&cp, &index, argc, argv,
|
||||
haveendstr)) {
|
||||
fprintf(stderr, "-f expects"
|
||||
" filename\n");
|
||||
exit (1);
|
||||
}
|
||||
if (*cp == ';') {
|
||||
fprintf(stderr,
|
||||
"-f expects"
|
||||
" filename\n");
|
||||
exit (1);
|
||||
}
|
||||
havearg = TRUE;
|
||||
if (cmdlen > 0)
|
||||
cmdbuf[cmdlen++] = ' ';
|
||||
strcpy(cmdbuf + cmdlen, "read ");
|
||||
cmdlen += 5;
|
||||
if (strncmp(cp, "-once", 5) == 0 &&
|
||||
(cp[5] == '\0' || cp[5] == ' ')) {
|
||||
cp += 5;
|
||||
haveendstr = (*cp == '\0');
|
||||
strcpy(cmdbuf+cmdlen, "-once ");
|
||||
cmdlen += 6;
|
||||
if (nextcp(&cp, &index, argc,
|
||||
argv, haveendstr)) {
|
||||
fprintf(stderr, "-f -once"
|
||||
" expects"
|
||||
" filename\n");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
bp = cmdbuf + cmdlen;
|
||||
if (haveendstr) {
|
||||
len = strlen(cp);
|
||||
if (len == 0) {
|
||||
fprintf(stderr,
|
||||
"Null"
|
||||
" filename!");
|
||||
exit (1);
|
||||
}
|
||||
if (cmdlen + len + 2 > MAXCMD) {
|
||||
fprintf(stderr,
|
||||
"Commands too"
|
||||
" long");
|
||||
exit (1);
|
||||
}
|
||||
/* XXX What if *cp = '\''? */
|
||||
*bp++ = '\'';
|
||||
strcpy(bp, cp);
|
||||
bp += len;
|
||||
*bp++ = '\'';
|
||||
cp += len;
|
||||
cmdlen += len + 2;
|
||||
} else {
|
||||
do {
|
||||
if (cmdlen > MAXCMD) {
|
||||
fprintf(stderr,
|
||||
"Commands"
|
||||
" too long");
|
||||
exit (1);
|
||||
}
|
||||
*bp++ = *cp++;
|
||||
cmdlen++;
|
||||
} while (*cp != '\0' &&
|
||||
*cp != ';' &&
|
||||
*cp != ' ');
|
||||
}
|
||||
if (*cp == ';')
|
||||
cp++;
|
||||
*bp++ = ';';
|
||||
cmdlen++;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
s_flag = TRUE;
|
||||
maxindex = index + 1;
|
||||
break;
|
||||
case 'S':
|
||||
/*FALLTHRU*/
|
||||
default:
|
||||
/*
|
||||
* we are too early in processing to call
|
||||
* libcalc_call_me_last() - nothing to cleanup
|
||||
* we are too early in processing to
|
||||
* call libcalc_call_me_last() -
|
||||
* nothing to cleanup
|
||||
*/
|
||||
fprintf(stderr, "Illegal option -%c\n",
|
||||
c);
|
||||
fprintf(stderr,
|
||||
"usage: %s [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
|
||||
"usage: %s [-a] [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
|
||||
"\t[-D calc_debug[:resource_debug[:user_debug]]]\n"
|
||||
"\t[-n] [-p] [-q] [-s] [-u] [-v] "
|
||||
"[[--] calc_cmd ...]\n",
|
||||
"\t[-n] [-p] [-q] [-u] [-v] "
|
||||
"[--] [calc_cmd ...]\n",
|
||||
program);
|
||||
exit(1);
|
||||
}
|
||||
if (havearg)
|
||||
break;
|
||||
cp++;
|
||||
}
|
||||
while (*cp == ' ')
|
||||
cp++;
|
||||
if (*cp == '\0') {
|
||||
index++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If -S was given via a calc shell script, imply -p and -d
|
||||
* unless -i was also given.
|
||||
*/
|
||||
if (shellfile != NULL && !i_flag) {
|
||||
p_flag = TRUE;
|
||||
d_flag = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* look at the length of any trailing command args
|
||||
*
|
||||
* We make room for the trailing '\0\n' as well as an extra guard byte.
|
||||
*
|
||||
* However, if -S is in effect, we will pretend that we have no
|
||||
* command args and allow the argv() builtin access to the strings.
|
||||
*/
|
||||
cmdbuf[0] = '\0';
|
||||
if (s_flag) {
|
||||
havecommands = FALSE;
|
||||
argc_value = argc - optind;
|
||||
argv_value = argv + optind;
|
||||
} else {
|
||||
havecommands = (optind < argc);
|
||||
for (cmdlen=0, i=optind; i < argc; ++i) {
|
||||
/* argument + space separator */
|
||||
cmdlen += strlen(argv[i]) + 1;
|
||||
}
|
||||
if (i > MAXCMD) {
|
||||
/*
|
||||
* we are too early in processing to call
|
||||
* libcalc_call_me_last() - nothing to cleanup
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"%s: command in arg list is too long\n",
|
||||
program);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Form a command the remaining args separated by spaces.
|
||||
*/
|
||||
if (optind < argc) {
|
||||
strcpy(cmdbuf, argv[optind]);
|
||||
cmdlen = strlen(argv[optind]);
|
||||
for (i=optind+1; i < argc; ++i) {
|
||||
while (index < maxindex) {
|
||||
if (cmdlen > 0)
|
||||
cmdbuf[cmdlen++] = ' ';
|
||||
strcpy(cmdbuf+cmdlen, argv[i]);
|
||||
cmdlen += strlen(argv[i]);
|
||||
newcmdlen = cmdlen + strlen(cp);
|
||||
if (newcmdlen > MAXCMD) {
|
||||
fprintf(stderr,
|
||||
"%s: commands too long\n",
|
||||
program);
|
||||
exit(1);
|
||||
}
|
||||
strcpy(cmdbuf + cmdlen, cp);
|
||||
cmdlen = newcmdlen;
|
||||
index++;
|
||||
if (index < maxindex)
|
||||
cp = argv[index];
|
||||
}
|
||||
|
||||
havecommands = (cmdlen > 0);
|
||||
|
||||
if (havecommands) {
|
||||
cmdbuf[cmdlen++] = '\n';
|
||||
cmdbuf[cmdlen] = '\0';
|
||||
}
|
||||
argc_value = 0;
|
||||
argv_value = argv+argc;
|
||||
}
|
||||
|
||||
argc_value = argc - maxindex;
|
||||
argv_value = argv + maxindex;
|
||||
|
||||
/*
|
||||
* unbuffered mode
|
||||
@@ -270,6 +478,7 @@ main(int argc, char **argv)
|
||||
setbuf(stdout, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* initialize
|
||||
*/
|
||||
@@ -333,18 +542,10 @@ main(int argc, char **argv)
|
||||
*/
|
||||
if (run_state == RUN_BEGIN) {
|
||||
if (!q_flag && allow_read) {
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_RCFILES));
|
||||
run_state = RUN_RCFILES;
|
||||
set_run_state(RUN_RCFILES);
|
||||
runrcfiles();
|
||||
}
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_PRE_CMD_ARGS));
|
||||
run_state = RUN_PRE_CMD_ARGS;
|
||||
set_run_state(RUN_PRE_CMD_ARGS);
|
||||
}
|
||||
|
||||
while (run_state == RUN_RCFILES) {
|
||||
@@ -354,55 +555,27 @@ main(int argc, char **argv)
|
||||
if (inputlevel() == 0) {
|
||||
closeinput();
|
||||
runrcfiles();
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_PRE_CMD_ARGS));
|
||||
run_state = RUN_PRE_CMD_ARGS;
|
||||
set_run_state(RUN_PRE_CMD_ARGS);
|
||||
} else {
|
||||
closeinput();
|
||||
}
|
||||
} else {
|
||||
if ((havecommands && !i_flag) || !stdin_tty) {
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_EXIT_WITH_ERROR));
|
||||
run_state = RUN_EXIT_WITH_ERROR;
|
||||
set_run_state(RUN_EXIT_WITH_ERROR);
|
||||
} else {
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_PRE_CMD_ARGS));
|
||||
run_state = RUN_PRE_CMD_ARGS;
|
||||
set_run_state(RUN_PRE_CMD_ARGS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (run_state == RUN_PRE_CMD_ARGS) {
|
||||
if (havecommands) {
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_CMD_ARGS));
|
||||
run_state = RUN_CMD_ARGS;
|
||||
set_run_state(RUN_CMD_ARGS);
|
||||
(void) openstring(cmdbuf, (long) strlen(cmdbuf));
|
||||
getcommands(FALSE);
|
||||
closeinput();
|
||||
} else if (shellfile != NULL) {
|
||||
/* XXX - shellfile stuff needs it own run_state name */
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_CMD_ARGS));
|
||||
run_state = RUN_CMD_ARGS;
|
||||
getshellfile(shellfile);
|
||||
}
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_PRE_TOP_LEVEL));
|
||||
run_state = RUN_PRE_TOP_LEVEL;
|
||||
set_run_state(RUN_PRE_TOP_LEVEL);
|
||||
}
|
||||
|
||||
while (run_state == RUN_CMD_ARGS) {
|
||||
@@ -410,38 +583,22 @@ main(int argc, char **argv)
|
||||
if ((c_flag && !stoponerror) || stoponerror < 0) {
|
||||
getcommands(FALSE);
|
||||
if (inputlevel() == 0)
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_PRE_TOP_LEVEL));
|
||||
run_state = RUN_PRE_TOP_LEVEL;
|
||||
set_run_state(RUN_PRE_TOP_LEVEL);
|
||||
closeinput();
|
||||
} else {
|
||||
closeinput();
|
||||
if (!stdin_tty || !i_flag || p_flag) {
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_EXIT_WITH_ERROR));
|
||||
run_state = RUN_EXIT_WITH_ERROR;
|
||||
set_run_state(RUN_EXIT_WITH_ERROR);
|
||||
} else {
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_PRE_TOP_LEVEL));
|
||||
run_state = RUN_PRE_TOP_LEVEL;
|
||||
set_run_state(RUN_PRE_TOP_LEVEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (run_state == RUN_PRE_TOP_LEVEL) {
|
||||
if (stdin_tty &&
|
||||
(((havecommands || shellfile) && !i_flag) || p_flag)) {
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_EXIT));
|
||||
run_state = RUN_EXIT;
|
||||
(((havecommands) && !i_flag) || p_flag)) {
|
||||
set_run_state(RUN_EXIT);
|
||||
} else {
|
||||
if (stdin_tty) {
|
||||
reinitialize();
|
||||
@@ -449,40 +606,71 @@ main(int argc, char **argv)
|
||||
resetinput();
|
||||
openterminal();
|
||||
}
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_TOP_LEVEL));
|
||||
run_state = RUN_TOP_LEVEL;
|
||||
set_run_state(RUN_TOP_LEVEL);
|
||||
getcommands(TRUE);
|
||||
}
|
||||
if (p_flag || (!i_flag && havecommands))
|
||||
set_run_state(RUN_EXIT);
|
||||
}
|
||||
|
||||
while (run_state == RUN_TOP_LEVEL) {
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state = TOP_LEVEL\n");
|
||||
if ((c_flag && !stoponerror) || stoponerror < 0) {
|
||||
getcommands(TRUE);
|
||||
if (!inputisterminal())
|
||||
if (!inputisterminal()) {
|
||||
closeinput();
|
||||
continue;
|
||||
}
|
||||
if (!p_flag && i_flag && !stdin_tty) {
|
||||
closeinput();
|
||||
if(!freopen("/dev/tty", "r", stdin)) {
|
||||
fprintf(stderr,
|
||||
"Unable to associate stdin"
|
||||
" with /dev/tty");
|
||||
set_run_state(RUN_EXIT_WITH_ERROR);
|
||||
break;
|
||||
}
|
||||
|
||||
stdin_tty = TRUE;
|
||||
if (conf->calc_debug & CALCDBG_TTY)
|
||||
printf("main: stdin_tty is %d\n",
|
||||
stdin_tty);
|
||||
reinitialize();
|
||||
}
|
||||
} else {
|
||||
if (stdin_tty) {
|
||||
reinitialize();
|
||||
getcommands(TRUE);
|
||||
} else if (inputisterminal() &&
|
||||
!p_flag && (!havecommands||i_flag)) {
|
||||
closeinput();
|
||||
if(!freopen("/dev/tty", "r", stdin)) {
|
||||
fprintf(stderr,
|
||||
"Unable to associate stdin"
|
||||
" with /dev/tty");
|
||||
set_run_state(RUN_EXIT_WITH_ERROR);
|
||||
break;
|
||||
}
|
||||
stdin_tty = TRUE;
|
||||
if (conf->calc_debug & CALCDBG_TTY)
|
||||
printf("main: stdin_tty is %d\n",
|
||||
stdin_tty);
|
||||
reinitialize();
|
||||
} else {
|
||||
set_run_state(RUN_EXIT_WITH_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(RUN_EXIT_WITH_ERROR));
|
||||
run_state = RUN_EXIT_WITH_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("main: run_state = %s\n", run_state_name(run_state));
|
||||
|
||||
/*
|
||||
* all done
|
||||
*/
|
||||
libcalc_call_me_last();
|
||||
return (run_state == RUN_EXIT_WITH_ERROR ||
|
||||
run_state == RUN_UNKNOWN) ? 1 : 0;
|
||||
run_state == RUN_ZERO) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -540,183 +728,52 @@ math_error(char *fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* script_args - concert shell script options into command line form
|
||||
*
|
||||
* When a calc shell script is executed, the args are presented to calc
|
||||
* in a different form. Consider the a calc shell script called /tmp/calcit:
|
||||
*
|
||||
* #!/usr/local/bin/calc -S -q -p
|
||||
* a=eval(prompt("Enter a: "));
|
||||
* b=eval(prompt("Enter b: "));
|
||||
* print a+b;
|
||||
*
|
||||
* When it is executed as:
|
||||
*
|
||||
* /tmp/calcit -D 31
|
||||
*
|
||||
* then calc will receive the following as args to main():
|
||||
*
|
||||
* argc: 5
|
||||
* argv[0]: "/usr/local/bin/calc"
|
||||
* argv[1]: "-S -q -p -e"
|
||||
* argv[2]: "/tmp/calcit"
|
||||
* argv[3]: "-D"
|
||||
* argv[4]: "31"
|
||||
* argv[5]: NULL
|
||||
*
|
||||
* NOTE: The user MUST put -S as the first characters on the calc shell
|
||||
* script #! line, right after the calc binary path.
|
||||
*
|
||||
* NOTE: The arg supplied on the #! calc shell script line are returned
|
||||
* as a single string. All tabs are converted into spaces.
|
||||
*
|
||||
* We must remember the calc script filename, break apart the #! args
|
||||
* and remove the -S argument. In the above case we would return:
|
||||
*
|
||||
* argc: 6
|
||||
* argv[0]: "/usr/local/bin/calc"
|
||||
* argv[1]: "-q"
|
||||
* argv[2]: "-p"
|
||||
* argv[3]: "-e"
|
||||
* argv[4]: "-D"
|
||||
* argv[5]: "31"
|
||||
* argv[6]: NULL
|
||||
*
|
||||
* shellfile: "/tmp/calcit"
|
||||
* s_flag: TRUE
|
||||
*/
|
||||
static int
|
||||
script_args(int argc, char ***argv_p, char **shellfile_p, char **program_p)
|
||||
nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr)
|
||||
{
|
||||
char **argv; /* new argv to return */
|
||||
char *shellfile; /* shell file pathname to return */
|
||||
int delta; /* the change needed in argc */
|
||||
int i;
|
||||
int j;
|
||||
char *p;
|
||||
char *q;
|
||||
char *cp;
|
||||
int index;
|
||||
|
||||
/*
|
||||
* must have at least 3 args and the 2nd must start with -S
|
||||
*/
|
||||
argv = *argv_p;
|
||||
if (argc < 3 || strncmp(argv[1], "-S", 2) != 0) {
|
||||
/*
|
||||
* we are too early in processing to call
|
||||
* libcalc_call_me_last() - nothing to cleanup
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"%s: FATAL: bad args passed to script_args\n", program);
|
||||
exit(1);
|
||||
}
|
||||
shellfile = argv[2];
|
||||
cp = *cpp;
|
||||
index = *ip;
|
||||
|
||||
/*
|
||||
* count the additional args beyond the -S
|
||||
*/
|
||||
if (argv[1][2] == ' ') {
|
||||
|
||||
/*
|
||||
* process args beyond -S on the #!/usr/local/bin line
|
||||
*/
|
||||
p = argv[1]+3 + strspn(argv[1]+3," ");
|
||||
q = p;
|
||||
if (q == '\0') {
|
||||
|
||||
/* only trailing spaces after -S, ignore them */
|
||||
for (i = 3; i <= argc; ++i) {
|
||||
argv[i-2] = argv[i];
|
||||
}
|
||||
argc -= 2;
|
||||
|
||||
} else {
|
||||
|
||||
/* count the space separated strings that follow -S */
|
||||
for (delta = -1; p != NULL && *p;
|
||||
p = strchr(p+1,' '), ++delta) {
|
||||
/* skip multiple spaces in a row */
|
||||
p += strspn(p, " ");
|
||||
if (haveendstr) {
|
||||
index++;
|
||||
*ip = index;
|
||||
if (index >= argc)
|
||||
return 1;
|
||||
*cpp = argv[index];
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* allocate the new set of argv pointers */
|
||||
argv = (char **)malloc(sizeof(char *) * argc+delta);
|
||||
if (argv == NULL) {
|
||||
/*
|
||||
* we are too early in processing to call
|
||||
* libcalc_call_me_last() - nothing to cleanup
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"%s: failed to malloc %d pointers\n",
|
||||
shellfile, argc+delta);
|
||||
exit(1);
|
||||
if (*cp != '\0')
|
||||
cp++;
|
||||
for (;;) {
|
||||
if (*cp == '\0') {
|
||||
index++;
|
||||
*ip = index;
|
||||
if (index >= argc)
|
||||
return 1;
|
||||
cp = argv[index];
|
||||
}
|
||||
while (*cp == ' ')
|
||||
cp++;
|
||||
if (*cp != '\0')
|
||||
break;
|
||||
}
|
||||
*cpp = cp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* we have the same 0th arg */
|
||||
argv[0] = (*argv_p)[0];
|
||||
|
||||
/* args may be read-only, so duplicate 1st arg */
|
||||
p = strdup(q);
|
||||
if (p == NULL) {
|
||||
/*
|
||||
* we are too early in processing to call
|
||||
* libcalc_call_me_last() - nothing to cleanup
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"%s: failed to duplicate 1st arg\n",
|
||||
shellfile);
|
||||
exit(1);
|
||||
static void
|
||||
set_run_state(run state)
|
||||
{
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
printf("main: run_state from %s to %s\n",
|
||||
run_state_name(run_state),
|
||||
run_state_name(state));
|
||||
run_state = state;
|
||||
}
|
||||
|
||||
/* tokenize the 1st arg */
|
||||
for (p=strtok(q," "), i=1; p != NULL;
|
||||
p=strtok(NULL," "), ++i) {
|
||||
argv[i] = p;
|
||||
}
|
||||
|
||||
/* save the 3rd and later args */
|
||||
for (j=3; (*argv_p)[j] != NULL; ++j, ++i) {
|
||||
argv[i] = (*argv_p)[j];
|
||||
}
|
||||
argv[i] = NULL;
|
||||
|
||||
/* set argc */
|
||||
argc = i;
|
||||
}
|
||||
|
||||
/*
|
||||
* catch the case of #!/usr/local/bin -Stuff_not_extra_args
|
||||
*/
|
||||
} else if (argv[1][2] != '\0') {
|
||||
|
||||
/*
|
||||
* we are too early in processing to call
|
||||
* libcalc_call_me_last() - nothing to cleanup
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"%s: malformed #! line, -S must be "
|
||||
"followed by space or newline\n",
|
||||
shellfile);
|
||||
exit(1);
|
||||
|
||||
/*
|
||||
* Only -S was given in the #!/usr/local/bin line, so we just
|
||||
* toss the 2nd and 3rd args
|
||||
*/
|
||||
} else {
|
||||
for (i = 3; i <= argc; ++i) {
|
||||
argv[i-2] = argv[i];
|
||||
}
|
||||
argc -= 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* return and set the argc, argv, shellfile_p and s_flag values
|
||||
*/
|
||||
*argv_p = argv;
|
||||
*shellfile_p = shellfile;
|
||||
*program_p = shellfile;
|
||||
s_flag = TRUE;
|
||||
return argc;
|
||||
}
|
||||
|
253
calc.h
253
calc.h
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: calc.h,v 29.2 1999/12/14 19:37:46 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: calc.h,v 29.6 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.h,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:31
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
@@ -32,9 +32,8 @@
|
||||
#define __CALC_H__
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#include "win32dll.h"
|
||||
#include "value.h"
|
||||
|
||||
#include "have_const.h"
|
||||
|
||||
|
||||
@@ -60,10 +59,9 @@
|
||||
#define MAXERROR 512 /* maximum length of error message string */
|
||||
|
||||
#define SYMBOLSIZE 256 /* maximum symbol name size */
|
||||
#define MAXINDICES 20 /* maximum number of indices for objects */
|
||||
#define MAXLABELS 100 /* maximum number of user labels in function */
|
||||
#define MAXSTRING 1024 /* maximum size of string constant */
|
||||
#define MAXSTACK 1000 /* maximum depth of evaluation stack */
|
||||
#define MAXSTACK 2048 /* maximum depth of evaluation stack */
|
||||
#define MAXFILES 20 /* maximum number of opened files */
|
||||
#define PROMPT1 "> " /* default normal prompt*/
|
||||
#define PROMPT2 ">> " /* default prompt inside multi-line input */
|
||||
@@ -95,152 +93,157 @@
|
||||
/*
|
||||
* File I/O routines.
|
||||
*/
|
||||
extern FILEID openid(char *name, char *mode);
|
||||
extern FILEID indexid(long index);
|
||||
extern BOOL validid(FILEID id);
|
||||
extern BOOL errorid(FILEID id);
|
||||
extern BOOL eofid(FILEID id);
|
||||
extern int closeid(FILEID id);
|
||||
extern int getcharid(FILEID id);
|
||||
extern int idprintf(FILEID id, char *fmt, int count, VALUE **vals);
|
||||
extern int idfputc(FILEID id, int ch);
|
||||
extern int idfputs(FILEID id, char *str);
|
||||
extern int printid(FILEID id, int flags);
|
||||
extern int flushid(FILEID id);
|
||||
extern int readid(FILEID id, int flags, char **retptr);
|
||||
extern int getloc(FILEID id, ZVALUE *loc);
|
||||
extern int setloc(FILEID id, ZVALUE zpos);
|
||||
extern int getsize(FILEID id, ZVALUE *size);
|
||||
extern int get_device(FILEID id, ZVALUE *dev);
|
||||
extern int get_inode(FILEID id, ZVALUE *ino);
|
||||
extern FILEID reopenid(FILEID id, char *mode, char *name);
|
||||
extern int closeall(void);
|
||||
extern int flushall(void);
|
||||
extern int idfputstr(FILEID id, char *str);
|
||||
extern int rewindid(FILEID id);
|
||||
extern void rewindall(void);
|
||||
extern ZVALUE zfilesize(FILEID id);
|
||||
extern void showfiles(void);
|
||||
extern int fscanfid(FILEID id, char *fmt, int count, VALUE **vals);
|
||||
extern int scanfstr(char *str, char *fmt, int count, VALUE **vals);
|
||||
extern int ftellid(FILEID id, ZVALUE *res);
|
||||
extern int fseekid(FILEID id, ZVALUE offset, int whence);
|
||||
extern int isattyid(FILEID id);
|
||||
extern int fsearch(FILEID id, char *str, ZVALUE start, ZVALUE end, ZVALUE *res);
|
||||
extern int frsearch(FILEID id, char *str, ZVALUE first, ZVALUE last, ZVALUE *res);
|
||||
extern void showconstants(void);
|
||||
extern void freeconstant(unsigned long);
|
||||
extern void freestringconstant(long);
|
||||
extern void trimconstants(void);
|
||||
extern DLL FILEID openid(char *name, char *mode);
|
||||
extern DLL FILEID indexid(long index);
|
||||
extern DLL BOOL validid(FILEID id);
|
||||
extern DLL BOOL errorid(FILEID id);
|
||||
extern DLL BOOL eofid(FILEID id);
|
||||
extern DLL int closeid(FILEID id);
|
||||
extern DLL int getcharid(FILEID id);
|
||||
extern DLL int idprintf(FILEID id, char *fmt, int count, VALUE **vals);
|
||||
extern DLL int idfputc(FILEID id, int ch);
|
||||
extern DLL int idfputs(FILEID id, char *str);
|
||||
extern DLL int printid(FILEID id, int flags);
|
||||
extern DLL int flushid(FILEID id);
|
||||
extern DLL int readid(FILEID id, int flags, char **retptr);
|
||||
extern DLL int getloc(FILEID id, ZVALUE *loc);
|
||||
extern DLL int setloc(FILEID id, ZVALUE zpos);
|
||||
extern DLL int getsize(FILEID id, ZVALUE *size);
|
||||
extern DLL int get_device(FILEID id, ZVALUE *dev);
|
||||
extern DLL int get_inode(FILEID id, ZVALUE *ino);
|
||||
extern DLL FILEID reopenid(FILEID id, char *mode, char *name);
|
||||
extern DLL int closeall(void);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
extern DLL int flushall(void);
|
||||
#endif
|
||||
|
||||
extern DLL int idfputstr(FILEID id, char *str);
|
||||
extern DLL int rewindid(FILEID id);
|
||||
extern DLL void rewindall(void);
|
||||
extern DLL ZVALUE zfilesize(FILEID id);
|
||||
extern DLL void showfiles(void);
|
||||
extern DLL int fscanfid(FILEID id, char *fmt, int count, VALUE **vals);
|
||||
extern DLL int scanfstr(char *str, char *fmt, int count, VALUE **vals);
|
||||
extern DLL int ftellid(FILEID id, ZVALUE *res);
|
||||
extern DLL int fseekid(FILEID id, ZVALUE offset, int whence);
|
||||
extern DLL int isattyid(FILEID id);
|
||||
extern DLL 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);
|
||||
extern DLL void showconstants(void);
|
||||
extern DLL void freeconstant(unsigned long);
|
||||
extern DLL void freestringconstant(long);
|
||||
extern DLL void trimconstants(void);
|
||||
|
||||
/*
|
||||
* Input routines.
|
||||
*/
|
||||
extern int openstring(char *str, long num);
|
||||
extern int openterminal(void);
|
||||
extern int opensearchfile(char *name, char *pathlist, char *exten, int reopen_ok);
|
||||
extern char *nextline(void);
|
||||
extern int nextchar(void);
|
||||
extern void reread(void);
|
||||
extern void resetinput(void);
|
||||
extern void setprompt(char *);
|
||||
extern BOOL inputisterminal(void);
|
||||
extern int inputlevel(void);
|
||||
extern long calclevel(void);
|
||||
extern char *inputname(void);
|
||||
extern long linenumber(void);
|
||||
extern void runrcfiles(void);
|
||||
extern void closeinput(void);
|
||||
extern DLL int openstring(char *str, long num);
|
||||
extern DLL int openterminal(void);
|
||||
extern DLL int opensearchfile(char *name, char *pathlist, char *exten, int reopen_ok);
|
||||
extern DLL char *nextline(void);
|
||||
extern DLL int nextchar(void);
|
||||
extern DLL void reread(void);
|
||||
extern DLL void resetinput(void);
|
||||
extern DLL void setprompt(char *);
|
||||
extern DLL BOOL inputisterminal(void);
|
||||
extern DLL int inputlevel(void);
|
||||
extern DLL long calclevel(void);
|
||||
extern DLL char *inputname(void);
|
||||
extern DLL long linenumber(void);
|
||||
extern DLL void runrcfiles(void);
|
||||
extern DLL void closeinput(void);
|
||||
|
||||
/*
|
||||
* Other routines.
|
||||
*/
|
||||
extern NUMBER *constvalue(unsigned long index);
|
||||
extern long addnumber(char *str);
|
||||
extern long addqconstant(NUMBER *q);
|
||||
extern void initstack(void);
|
||||
extern void getcommands(BOOL toplevel);
|
||||
extern void givehelp(char *type);
|
||||
extern void libcalc_call_me_first(void);
|
||||
extern void libcalc_call_me_last(void);
|
||||
extern BOOL calc_tty(int fd);
|
||||
extern BOOL orig_tty(int fd);
|
||||
extern void showerrors(void);
|
||||
extern char *calc_strdup(CONST char *);
|
||||
extern void getshellfile(char *shellfile);
|
||||
extern DLL NUMBER *constvalue(unsigned long index);
|
||||
extern DLL long addnumber(char *str);
|
||||
extern DLL long addqconstant(NUMBER *q);
|
||||
extern DLL void initstack(void);
|
||||
extern DLL void getcommands(BOOL toplevel);
|
||||
extern DLL void givehelp(char *type);
|
||||
extern DLL void libcalc_call_me_first(void);
|
||||
extern DLL void libcalc_call_me_last(void);
|
||||
extern DLL BOOL calc_tty(int fd);
|
||||
extern DLL BOOL orig_tty(int fd);
|
||||
extern DLL void showerrors(void);
|
||||
extern DLL char *calc_strdup(CONST char *);
|
||||
|
||||
/*
|
||||
* Initialization
|
||||
*/
|
||||
extern void initialize(void);
|
||||
extern void reinitialize(void);
|
||||
extern int isatty(int tty); /* TRUE if fd is a tty */
|
||||
extern char *version(void); /* return version string */
|
||||
extern int post_init; /* TRUE => setjmp for math_error is ready */
|
||||
extern DLL void initialize(void);
|
||||
extern DLL void reinitialize(void);
|
||||
#if !defined (_WIN32)
|
||||
extern DLL int isatty(int tty); /* TRUE if fd is a tty */
|
||||
#endif
|
||||
extern DLL char *version(void); /* return version string */
|
||||
extern DLL int post_init; /* TRUE => math_error setjmp is ready */
|
||||
|
||||
/*
|
||||
* global flags and definitions
|
||||
*/
|
||||
extern int abortlevel; /* current level of aborts */
|
||||
extern BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||
extern jmp_buf jmpbuf; /* for errors */
|
||||
extern DLL int abortlevel; /* current level of aborts */
|
||||
extern DLL BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||
extern DLL jmp_buf jmpbuf; /* for errors */
|
||||
|
||||
extern int p_flag; /* TRUE => pipe mode */
|
||||
extern int q_flag; /* TRUE => don't execute rc files */
|
||||
extern int u_flag; /* TRUE => unbuffer stdin and stdout */
|
||||
extern int d_flag; /* TRUE => disable heading, resource_debug */
|
||||
extern int c_flag; /* TRUE => continue after error if permitted */
|
||||
extern int i_flag; /* TRUE => try to go interactive after error */
|
||||
extern int s_flag; /* TRUE => keep args as strings for argv() */
|
||||
extern int stoponerror; /* >0 => stop, <0 => continue, ==0 => use -c */
|
||||
extern BOOL abort_now; /* TRUE => try to go interactive */
|
||||
extern DLL int p_flag; /* TRUE => pipe mode */
|
||||
extern DLL int q_flag; /* TRUE => don't execute rc files */
|
||||
extern DLL int u_flag; /* TRUE => unbuffer stdin and stdout */
|
||||
extern DLL int d_flag; /* TRUE => disable heading, resource_debug */
|
||||
extern DLL int c_flag; /* TRUE => continue after error if permitted */
|
||||
extern DLL int i_flag; /* TRUE => try to go interactive after error */
|
||||
extern DLL int s_flag; /* TRUE => keep args as strings for argv() */
|
||||
extern DLL int stoponerror; /* >0 => stop, <0 => continue, ==0 => use -c */
|
||||
extern DLL BOOL abort_now; /* TRUE => try to go interactive */
|
||||
|
||||
extern int argc_value; /* count of argv[] strings for argv() builtin */
|
||||
extern char **argv_value; /* argv[] strings for argv() builtin */
|
||||
extern DLL int argc_value; /* count of argv[] strings for argv() builtin */
|
||||
extern DLL char **argv_value; /* argv[] strings for argv() builtin */
|
||||
|
||||
extern char *pager; /* $PAGER or default */
|
||||
extern int stdin_tty; /* TRUE if stdin is a tty */
|
||||
extern int havecommands; /* TRUE if have cmd args) */
|
||||
extern char *program; /* our name */
|
||||
extern char *base_name; /* basename of our name */
|
||||
extern char cmdbuf[]; /* command line expression */
|
||||
extern DLL char *pager; /* $PAGER or default */
|
||||
extern DLL int stdin_tty; /* TRUE if stdin is a tty */
|
||||
extern DLL int havecommands; /* TRUE if have cmd args) */
|
||||
extern DLL char *program; /* our name */
|
||||
extern DLL char *base_name; /* basename of our name */
|
||||
extern DLL char cmdbuf[]; /* command line expression */
|
||||
|
||||
extern int abortlevel; /* current level of aborts */
|
||||
extern BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||
extern VALUE *stack; /* execution stack */
|
||||
extern int dumpnames; /* TRUE => dump names rather than indices */
|
||||
extern DLL int abortlevel; /* current level of aborts */
|
||||
extern DLL BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||
extern DLL VALUE *stack; /* execution stack */
|
||||
extern DLL int dumpnames; /* TRUE => dump names rather than indices */
|
||||
|
||||
extern char *calcpath; /* $CALCPATH or default */
|
||||
extern char *calcrc; /* $CALCRC or default */
|
||||
extern char *calcbindings; /* $CALCBINDINGS or default */
|
||||
extern char *home; /* $HOME or default */
|
||||
extern char *shell; /* $SHELL or default */
|
||||
extern char *program; /* our name (argv[0]) */
|
||||
extern DLL char *calcpath; /* $CALCPATH or default */
|
||||
extern DLL char *calcrc; /* $CALCRC or default */
|
||||
extern DLL char *calcbindings; /* $CALCBINDINGS or default */
|
||||
extern DLL char *home; /* $HOME or default */
|
||||
extern DLL char *shell; /* $SHELL or default */
|
||||
extern DLL char *program; /* our name (argv[0]) */
|
||||
|
||||
extern int no_env; /* TRUE (-e) => ignore env vars on startup */
|
||||
extern int errmax; /* if >= 0, error when errcount exceeds errmax */
|
||||
extern int new_std; /* TRUE (-n) => use newstd configuration */
|
||||
extern DLL int no_env; /* TRUE (-e) => ignore env vars on startup */
|
||||
extern DLL int errmax; /* if >= 0, error when errcount exceeds errmax */
|
||||
extern DLL int new_std; /* TRUE (-n) => use newstd configuration */
|
||||
|
||||
extern int allow_read; /* FALSE => may not open any files for reading */
|
||||
extern int allow_write; /* FALSE => may not open any files for writing */
|
||||
extern int allow_exec; /* FALSE => may not execute any commands */
|
||||
extern DLL int allow_read; /* FALSE => dont open any files for reading */
|
||||
extern DLL int allow_write; /* FALSE => dont open any files for writing */
|
||||
extern DLL int allow_exec; /* FALSE => may not execute any commands */
|
||||
|
||||
/*
|
||||
* calc startup and run state
|
||||
*/
|
||||
typedef enum {
|
||||
RUN_UNKNOWN = -1, /* unknown or unset start state */
|
||||
RUN_BEGIN = 0, /* calc execution starts */
|
||||
RUN_RCFILES = 1, /* rc files being evaluated */
|
||||
RUN_PRE_CMD_ARGS = 2, /* prepare to evaluate cmd args */
|
||||
RUN_CMD_ARGS = 3, /* cmd args being evaluated */
|
||||
RUN_PRE_TOP_LEVEL = 4, /* prepare to start top level activity */
|
||||
RUN_TOP_LEVEL = 5, /* running at top level */
|
||||
RUN_EXIT = 6, /* normal exit from calc */
|
||||
RUN_EXIT_WITH_ERROR = 7 /* exit with error */
|
||||
RUN_ZERO, /* unknown or unset start state */
|
||||
RUN_BEGIN, /* calc execution starts */
|
||||
RUN_RCFILES, /* rc files being evaluated */
|
||||
RUN_PRE_CMD_ARGS, /* prepare to evaluate cmd args */
|
||||
RUN_CMD_ARGS, /* cmd args being evaluated */
|
||||
RUN_PRE_TOP_LEVEL, /* prepare to start top level activity */
|
||||
RUN_TOP_LEVEL, /* running at top level */
|
||||
RUN_EXIT, /* normal exit from calc */
|
||||
RUN_EXIT_WITH_ERROR /* exit with error */
|
||||
} run;
|
||||
extern run run_state;
|
||||
extern char *run_state_name(run state);
|
||||
extern DLL run run_state;
|
||||
extern DLL char *run_state_name(run state);
|
||||
|
||||
/*
|
||||
* calc version information
|
||||
@@ -251,7 +254,7 @@ extern int calc_minor_ver;
|
||||
extern int calc_major_patch;
|
||||
extern char *calc_minor_patch;
|
||||
extern char *Copyright;
|
||||
extern char *version(void);
|
||||
extern DLL char *version(void);
|
||||
|
||||
|
||||
#endif /* !__CALC_H__ */
|
||||
|
24
calc.man
24
calc.man
@@ -15,15 +15,15 @@
|
||||
.\" received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
.\" 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
.\"
|
||||
.\" @(#) $Revision: 29.4 $
|
||||
.\" @(#) $Id: calc.man,v 29.4 1999/12/17 10:06:31 chongo Exp $
|
||||
.\" @(#) $Revision: 29.5 $
|
||||
.\" @(#) $Id: calc.man,v 29.5 2000/06/07 14:02:13 chongo Exp $
|
||||
.\" @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.man,v $
|
||||
.\"
|
||||
.\" Under source code control: 1991/07/23 05:48:26
|
||||
.\" File existed as early as: 1991
|
||||
.\"
|
||||
.\" chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
.\" Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
.\" chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
.\" Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
.\"
|
||||
.\" calculator by David I. Bell
|
||||
.\" man page by Landon Noll
|
||||
@@ -1007,9 +1007,7 @@ in future distributions to:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
calc-tester at postofc dot corp dot sgi dot com
|
||||
|
||||
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
calc-contrib at asthe dot com
|
||||
.fi
|
||||
.in -0.5i
|
||||
.sp
|
||||
@@ -1017,9 +1015,10 @@ Bug reports are sent to:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
calc-bugs at postofc dot corp dot sgi dot com
|
||||
calc-bugs at asthe dot com
|
||||
|
||||
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
||||
.fi
|
||||
.in -0.5i
|
||||
.sp
|
||||
@@ -1045,7 +1044,7 @@ Landon Noll maintains the the
|
||||
web site is located at:
|
||||
.sp
|
||||
.in +0.5i
|
||||
http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
http://www.isthe.com/chongo/tech/comp/calc/
|
||||
.in -0.5i
|
||||
.sp
|
||||
One may join the
|
||||
@@ -1054,9 +1053,10 @@ testing group by sending a request to:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.nf
|
||||
calc-tester-request at postofc dot corp dot sgi dot com
|
||||
calc-tester-request at asthe dot com
|
||||
|
||||
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
||||
.fi
|
||||
.in -0.5i
|
||||
.sp
|
||||
|
24
calcerr.tbl
24
calcerr.tbl
@@ -17,14 +17,14 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: calcerr.tbl,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: calcerr.tbl,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr.tbl,v $
|
||||
#
|
||||
# Under source code control: 1996/05/23 17:38:44
|
||||
# File existed as early as: 1996
|
||||
#
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
# This file is used to build calcerr.h include file.
|
||||
#
|
||||
@@ -375,3 +375,21 @@ E_GD3 Infinite or too-large result for gd
|
||||
E_AGD3 Infinite or too-large result for agd
|
||||
E_POWER4 Too-large value for power
|
||||
E_ROOT4 Too-large value for root
|
||||
E_DGT1 Non-real first arg for digit
|
||||
E_DGT2 Non-integral second arg for digit
|
||||
E_DGT3 Bad third arg for digit
|
||||
E_PLCS1 Bad first argument for places
|
||||
E_PLCS2 Bad second argument for places
|
||||
E_DGTS1 Bad first argument for digits
|
||||
E_DGTS2 Bad second argument for digits
|
||||
E_ILOG Bad first argument for ilog
|
||||
E_ILOGB Bad second argument for ilog
|
||||
E_ILOG10 Bad argument for ilog10
|
||||
E_ILOG2 Bad argument for ilog2
|
||||
E_COMB1 Non-integer second arg for comb
|
||||
E_COMB2 Too-large second arg for comb
|
||||
E_CTLN Bad argument for catalan
|
||||
E_BERN Bad argument for bern
|
||||
E_EULER Bad argument for euler
|
||||
E_SLEEP Bad argument for sleep
|
||||
E_TTY calc_tty failure
|
||||
|
@@ -18,15 +18,15 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: calcerr_c.awk,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: calcerr_c.awk,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_c.awk,v $
|
||||
#
|
||||
# Under source code control: 1996/05/24 03:15:35
|
||||
# File existed as early as: 1996
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
#
|
||||
BEGIN {
|
||||
printf("#include <stdio.h>\n");
|
||||
|
@@ -18,15 +18,15 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: calcerr_c.sed,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: calcerr_c.sed,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_c.sed,v $
|
||||
#
|
||||
# Under source code control: 1996/05/24 03:15:35
|
||||
# File existed as early as: 1996
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
#
|
||||
s/#.*//
|
||||
s/[ ][ ]*$//
|
||||
|
@@ -18,15 +18,15 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: calcerr_h.awk,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: calcerr_h.awk,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_h.awk,v $
|
||||
#
|
||||
# Under source code control: 1996/05/23 17:38:44
|
||||
# File existed as early as: 1996
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
#
|
||||
BEGIN {
|
||||
ebase = 10000;
|
||||
|
@@ -18,15 +18,15 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: calcerr_h.sed,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: calcerr_h.sed,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr_h.sed,v $
|
||||
#
|
||||
# Under source code control: 1996/05/23 17:38:44
|
||||
# File existed as early as: 1996
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
#
|
||||
s/#.*//
|
||||
s/[ ][ ]*$//
|
||||
|
@@ -18,15 +18,15 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: check.awk,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: check.awk,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/check.awk,v $
|
||||
#
|
||||
# Under source code control: 1996/05/25 22:07:58
|
||||
# File existed as early as: 1996
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
#
|
||||
# This awk script will print 3 lines before and after any non-blank line that
|
||||
# does not begin with a number. This allows the 'make debug' rule to remove
|
||||
|
7
cmath.h
7
cmath.h
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: cmath.h,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: cmath.h,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/cmath.h,v $
|
||||
*
|
||||
* Under source code control: 1993/07/30 19:42:45
|
||||
* File existed as early as: 1993
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ extern BOOL ccmp(COMPLEX *c1, COMPLEX *c2);
|
||||
* More complicated functions.
|
||||
*/
|
||||
extern COMPLEX *cpowi(COMPLEX *c, NUMBER *q);
|
||||
extern NUMBER *cilog(COMPLEX *c, ZVALUE base);
|
||||
|
||||
|
||||
/*
|
||||
|
271
codegen.c
271
codegen.c
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: codegen.c,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: codegen.c,v 29.4 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/codegen.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:13
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
@@ -45,11 +45,15 @@
|
||||
#include "func.h"
|
||||
#include "conf.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <direct.h>
|
||||
#endif
|
||||
|
||||
static BOOL rdonce; /* TRUE => do not reread this file */
|
||||
|
||||
FUNC *curfunc;
|
||||
|
||||
static BOOL getfilename(char *name, BOOL msg_ok, BOOL *once);
|
||||
static int getfilename(char *name, BOOL *once);
|
||||
static BOOL getid(char *buf);
|
||||
static void getshowstatement(void);
|
||||
static void getfunction(void);
|
||||
@@ -71,7 +75,7 @@ static void getsimplebody(void);
|
||||
static void getcondition(void);
|
||||
static void getmatargs(void);
|
||||
static void getelement(void);
|
||||
static void usesymbol(char *name, BOOL autodef);
|
||||
static void usesymbol(char *name, int autodef);
|
||||
static void definesymbol(char *name, int symtype);
|
||||
static void getcallargs(char *name);
|
||||
static void do_changedir(void);
|
||||
@@ -90,9 +94,16 @@ static int getshiftexpr(void);
|
||||
static int getreference(void);
|
||||
static int getincdecexpr(void);
|
||||
static int getterm(void);
|
||||
static int getidexpr(BOOL okmat, BOOL autodef);
|
||||
static int getidexpr(BOOL okmat, int autodef);
|
||||
static long getinitlist(void);
|
||||
|
||||
#define INDICALLOC 8
|
||||
|
||||
static int quickindices[INDICALLOC];
|
||||
static int * newindices;
|
||||
static int * indices;
|
||||
static int maxindices;
|
||||
|
||||
|
||||
/*
|
||||
* Read all the commands from an input file.
|
||||
@@ -133,49 +144,63 @@ getcommands(BOOL toplevel)
|
||||
return;
|
||||
|
||||
case T_HELP:
|
||||
if (!getfilename(name, FALSE, NULL)) {
|
||||
for (;;) {
|
||||
switch(getfilename(name, NULL)) {
|
||||
case 1:
|
||||
strcpy(name, DEFAULTCALCHELP);
|
||||
}
|
||||
case 0:
|
||||
givehelp(name);
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case T_READ:
|
||||
if (!getfilename(name, TRUE, &rdonce))
|
||||
break;
|
||||
if (!allow_read) {
|
||||
scanerror(T_NULL,
|
||||
"read command disallowed by -m mode\n");
|
||||
break;
|
||||
}
|
||||
switch (opensearchfile(name,calcpath,CALCEXT,rdonce)) {
|
||||
for (;;) {
|
||||
if (getfilename(name, &rdonce))
|
||||
break;
|
||||
switch (opensearchfile(name,calcpath,
|
||||
CALCEXT,rdonce)) {
|
||||
case 0:
|
||||
getcommands(FALSE);
|
||||
closeinput();
|
||||
break;
|
||||
continue;
|
||||
case 1:
|
||||
/* previously read and -once was given */
|
||||
break;
|
||||
/* prev read and -once was given */
|
||||
continue;
|
||||
case -2:
|
||||
scanerror(T_NULL,
|
||||
"Maximum input depth reached");
|
||||
break;
|
||||
default:
|
||||
scanerror(T_NULL, "Cannot open \"%s\"\n", name);
|
||||
scanerror(T_NULL,
|
||||
"Cannot open \"%s\"", name);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case T_WRITE:
|
||||
if (!getfilename(name, TRUE, NULL))
|
||||
break;
|
||||
if (!allow_write) {
|
||||
scanerror(T_NULL,
|
||||
"write command disallowed by -m mode\n");
|
||||
break;
|
||||
}
|
||||
if (writeglobals(name))
|
||||
if (getfilename(name, NULL))
|
||||
break;
|
||||
if (writeglobals(name)) {
|
||||
scanerror(T_NULL,
|
||||
"Error writing \"%s\"\n", name);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_CD:
|
||||
@@ -529,7 +554,7 @@ getonevariable(int symtype)
|
||||
res = getonevariable(symtype);
|
||||
definesymbol(name, symtype);
|
||||
if (res) {
|
||||
usesymbol(name, FALSE);
|
||||
usesymbol(name, 0);
|
||||
addop(OP_ASSIGNBACK);
|
||||
}
|
||||
return res;
|
||||
@@ -892,7 +917,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
|
||||
return;
|
||||
|
||||
case T_ELSE:
|
||||
scanerror(T_SEMICOLON, "ELSE without preceeding IF");
|
||||
scanerror(T_SEMICOLON, "ELSE without preceding IF");
|
||||
return;
|
||||
|
||||
case T_SHOW:
|
||||
@@ -1021,7 +1046,6 @@ getobjdeclaration(int symtype)
|
||||
int count; /* number of elements */
|
||||
int index; /* current index */
|
||||
int i; /* loop counter */
|
||||
int indices[MAXINDICES]; /* indices for elements */
|
||||
int oldmode;
|
||||
|
||||
if (gettoken() != T_SYMBOL) {
|
||||
@@ -1038,23 +1062,46 @@ getobjdeclaration(int symtype)
|
||||
* Read in the definition of the elements of the object.
|
||||
*/
|
||||
count = 0;
|
||||
indices = quickindices;
|
||||
maxindices = INDICALLOC;
|
||||
|
||||
oldmode = tokenmode(TM_DEFAULT);
|
||||
|
||||
for (;;) {
|
||||
switch (gettoken()) {
|
||||
case T_SYMBOL:
|
||||
if (count == MAXINDICES) {
|
||||
scanerror(T_SEMICOLON,
|
||||
"Too many elements in OBJ "
|
||||
"statement");
|
||||
if (count == maxindices) {
|
||||
if (maxindices == INDICALLOC) {
|
||||
maxindices += INDICALLOC;
|
||||
newindices = (int *) malloc(maxindices *
|
||||
sizeof(int));
|
||||
if (newindices == NULL) {
|
||||
scanerror(T_SEMICOLON, "Out of memory for indices malloc");
|
||||
(void) tokenmode(oldmode);
|
||||
return;
|
||||
}
|
||||
memcpy(newindices, quickindices,
|
||||
INDICALLOC * sizeof(int));
|
||||
indices = newindices;
|
||||
} else {
|
||||
maxindices += INDICALLOC;
|
||||
newindices = (int *) realloc(indices,
|
||||
maxindices * sizeof(int));
|
||||
if (newindices == NULL) {
|
||||
free(indices);
|
||||
scanerror(T_SEMICOLON, "Out of memory for indices realloc");
|
||||
(void) tokenmode(oldmode);
|
||||
return;
|
||||
}
|
||||
indices = newindices;
|
||||
}
|
||||
}
|
||||
index = addelement(tokensymbol());
|
||||
for (i = 0; i < count; i++) {
|
||||
if (indices[i] == index) {
|
||||
scanerror(T_SEMICOLON,
|
||||
"Duplicate element name "
|
||||
"\"%s\"", tokensymbol());
|
||||
if (indices != quickindices)
|
||||
free(indices);
|
||||
scanerror(T_SEMICOLON, "Duplicate element name \"%s\"", tokensymbol());
|
||||
(void) tokenmode(oldmode);
|
||||
return;
|
||||
}
|
||||
@@ -1064,8 +1111,9 @@ getobjdeclaration(int symtype)
|
||||
continue;
|
||||
rescantoken();
|
||||
if (gettoken() != T_RIGHTBRACE) {
|
||||
scanerror(T_SEMICOLON,
|
||||
"Bad object type definition");
|
||||
if (indices != quickindices)
|
||||
free(indices);
|
||||
scanerror(T_SEMICOLON, "Bad object type definition");
|
||||
(void) tokenmode(oldmode);
|
||||
return;
|
||||
}
|
||||
@@ -1073,23 +1121,30 @@ getobjdeclaration(int symtype)
|
||||
case T_RIGHTBRACE:
|
||||
(void) tokenmode(oldmode);
|
||||
if (defineobject(name, indices, count)) {
|
||||
if (indices != quickindices)
|
||||
free(indices);
|
||||
scanerror(T_NULL,
|
||||
"Object type \"%s\" is already defined", name);
|
||||
return;
|
||||
}
|
||||
if (indices != quickindices)
|
||||
free(indices);
|
||||
getobjvars(name, symtype);
|
||||
return;
|
||||
case T_NEWLINE:
|
||||
continue;
|
||||
default:
|
||||
scanerror(T_SEMICOLON,
|
||||
"Bad object type definition");
|
||||
if (indices != quickindices)
|
||||
free(indices);
|
||||
scanerror(T_SEMICOLON, "Bad object type definition");
|
||||
(void) tokenmode(oldmode);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
getoneobj(long index, int symtype)
|
||||
{
|
||||
@@ -1098,11 +1153,11 @@ getoneobj(long index, int symtype)
|
||||
if (gettoken() == T_SYMBOL) {
|
||||
if (symtype == SYM_UNDEFINED) {
|
||||
rescantoken();
|
||||
(void) getidexpr(TRUE, TRUE);
|
||||
(void) getidexpr(TRUE, 1);
|
||||
} else {
|
||||
symname = tokensymbol();
|
||||
definesymbol(symname, symtype);
|
||||
usesymbol(symname, FALSE);
|
||||
usesymbol(symname, 0);
|
||||
}
|
||||
getoneobj(index, symtype);
|
||||
addop(OP_ASSIGN);
|
||||
@@ -1181,11 +1236,11 @@ getonematrix(int symtype)
|
||||
if (gettoken() == T_SYMBOL) {
|
||||
if (symtype == SYM_UNDEFINED) {
|
||||
rescantoken();
|
||||
(void) getidexpr(FALSE, TRUE);
|
||||
(void) getidexpr(FALSE, 1);
|
||||
} else {
|
||||
name = tokensymbol();
|
||||
definesymbol(name, symtype);
|
||||
usesymbol(name, FALSE);
|
||||
usesymbol(name, 0);
|
||||
}
|
||||
while (gettoken() == T_COMMA);
|
||||
rescantoken();
|
||||
@@ -2028,7 +2083,25 @@ getterm(void)
|
||||
|
||||
case T_SYMBOL:
|
||||
rescantoken();
|
||||
type = getidexpr(TRUE, FALSE);
|
||||
type = getidexpr(TRUE, 0);
|
||||
break;
|
||||
|
||||
case T_GLOBAL:
|
||||
if (gettoken() != T_SYMBOL) {
|
||||
scanerror(T_NULL, "Global id expected");
|
||||
break;
|
||||
}
|
||||
rescantoken();
|
||||
type = getidexpr(TRUE, T_GLOBAL);
|
||||
break;
|
||||
|
||||
case T_LOCAL:
|
||||
if (gettoken() != T_SYMBOL) {
|
||||
scanerror(T_NULL, "Local id expected");
|
||||
break;
|
||||
}
|
||||
rescantoken();
|
||||
type = getidexpr(TRUE, T_LOCAL);
|
||||
break;
|
||||
|
||||
case T_LEFTBRACKET:
|
||||
@@ -2077,11 +2150,11 @@ getterm(void)
|
||||
/*
|
||||
* Read in an identifier expressions.
|
||||
* This is a symbol name followed by parenthesis, or by square brackets or
|
||||
* element refernces. 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.
|
||||
*/
|
||||
static int
|
||||
getidexpr(BOOL okmat, BOOL autodef)
|
||||
getidexpr(BOOL okmat, int autodef)
|
||||
{
|
||||
int type;
|
||||
char name[SYMBOLSIZE+1]; /* symbol name */
|
||||
@@ -2098,7 +2171,8 @@ getidexpr(BOOL okmat, BOOL autodef)
|
||||
type = 0;
|
||||
break;
|
||||
case T_ASSIGN:
|
||||
autodef = TRUE;
|
||||
if (autodef != T_GLOBAL && autodef != T_LOCAL)
|
||||
autodef = 1;
|
||||
/* fall into default case */
|
||||
default:
|
||||
rescantoken();
|
||||
@@ -2144,16 +2218,16 @@ getidexpr(BOOL okmat, BOOL autodef)
|
||||
*
|
||||
* given:
|
||||
* name filename to read
|
||||
* msg_ok TRUE => ok to print error messages
|
||||
* once non-NULL => set to TRUE of -once read
|
||||
*/
|
||||
static BOOL
|
||||
getfilename(char *name, BOOL msg_ok, BOOL *once)
|
||||
static int
|
||||
getfilename(char *name, BOOL *once)
|
||||
{
|
||||
STRING *s;
|
||||
int i;
|
||||
|
||||
/* look at the next token */
|
||||
(void) tokenmode(TM_NEWLINES | TM_ALLSYMS);
|
||||
for (i = 2; i > 0; i--) {
|
||||
switch (gettoken()) {
|
||||
case T_STRING:
|
||||
s = findstring(tokenstring());
|
||||
@@ -2164,51 +2238,17 @@ getfilename(char *name, BOOL msg_ok, BOOL *once)
|
||||
strcpy(name, tokensymbol());
|
||||
break;
|
||||
default:
|
||||
if (msg_ok)
|
||||
scanerror(T_SEMICOLON, "Filename expected");
|
||||
return FALSE;
|
||||
rescantoken();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* determine if we care about a possible -once option */
|
||||
if (once != NULL) {
|
||||
/* we care about a possible -once option */
|
||||
if (strcmp(name, "-once") == 0) {
|
||||
/* -once option found */
|
||||
*once = TRUE;
|
||||
/* look for the filename */
|
||||
switch (gettoken()) {
|
||||
case T_STRING:
|
||||
s = findstring(tokenstring());
|
||||
strcpy(name, s->s_str);
|
||||
sfree(s);
|
||||
if (i == 2 && once != NULL) {
|
||||
if ((*once = !strcmp(name, "-once")))
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case T_SYMBOL:
|
||||
strcpy(name, tokensymbol());
|
||||
break;
|
||||
default:
|
||||
if (msg_ok)
|
||||
scanerror(T_SEMICOLON,
|
||||
"Filename expected");
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
*once = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* look at the next token */
|
||||
switch (gettoken()) {
|
||||
case T_SEMICOLON:
|
||||
case T_NEWLINE:
|
||||
case T_EOF:
|
||||
break;
|
||||
default:
|
||||
if (msg_ok)
|
||||
scanerror(T_SEMICOLON,
|
||||
"Missing semicolon after filename");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2433,11 +2473,26 @@ definesymbol(char *name, int symtype)
|
||||
*
|
||||
* given:
|
||||
* name symbol name to be checked
|
||||
* autodef TRUE => define is symbol is not known
|
||||
* autodef 1 => define if symbol is not known
|
||||
* T_GLOBAL => get global, define if necessary
|
||||
*/
|
||||
static void
|
||||
usesymbol(char *name, BOOL autodef)
|
||||
usesymbol(char *name, int autodef)
|
||||
{
|
||||
|
||||
if (autodef == T_GLOBAL) {
|
||||
addopptr(OP_GLOBALADDR, (char *) addglobal(name, FALSE));
|
||||
return;
|
||||
}
|
||||
if (autodef == T_LOCAL) {
|
||||
if (symboltype(name) == SYM_PARAM) {
|
||||
scanerror(T_COMMA,
|
||||
"Variable \"%s\" is already defined", name);
|
||||
return;
|
||||
}
|
||||
addopone(OP_LOCALADDR, addlocal(name));
|
||||
return;
|
||||
}
|
||||
switch (symboltype(name)) {
|
||||
case SYM_LOCAL:
|
||||
addopone(OP_LOCALADDR, (long) findlocal(name));
|
||||
@@ -2544,24 +2599,25 @@ static void
|
||||
do_changedir(void)
|
||||
{
|
||||
char *p;
|
||||
STRING *s;
|
||||
|
||||
/* look at the next token */
|
||||
(void) tokenmode(TM_NEWLINES | TM_ALLSYMS);
|
||||
|
||||
/* determine the new directory */
|
||||
s = NULL;
|
||||
switch (gettoken()) {
|
||||
case T_NULL:
|
||||
case T_NEWLINE:
|
||||
case T_SEMICOLON:
|
||||
p = home;
|
||||
case T_STRING:
|
||||
s = findstring(tokenstring());
|
||||
p = s->s_str;
|
||||
break;
|
||||
case T_SYMBOL:
|
||||
p = tokensymbol();
|
||||
break;
|
||||
default:
|
||||
p = tokensymbol(); /* This is not enough XXX */
|
||||
if (p == NULL) {
|
||||
p = home;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (p == NULL) {
|
||||
fprintf(stderr, "Cannot determine HOME directory\n");
|
||||
}
|
||||
@@ -2570,29 +2626,8 @@ do_changedir(void)
|
||||
if (chdir(p)) {
|
||||
perror(p);
|
||||
}
|
||||
return;
|
||||
if (s != NULL)
|
||||
sfree(s);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* getshellfile - process the contents of a shellfile
|
||||
*/
|
||||
void
|
||||
getshellfile(char *shellfile)
|
||||
{
|
||||
/*
|
||||
* treat the calc shell script as if we were reading it
|
||||
*/
|
||||
if (!allow_read) {
|
||||
scanerror(T_NULL,
|
||||
"reading of calc shell script \"%s\" "
|
||||
"dislloaed by -m mode\n", shellfile);
|
||||
} else if (opensearchfile(shellfile, NULL, NULL, FALSE) == 0) {
|
||||
getcommands(FALSE);
|
||||
closeinput();
|
||||
} else {
|
||||
scanerror(T_NULL,
|
||||
"Cannot open calc shell script \"%s\"\n", shellfile);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
32
comfunc.c
32
comfunc.c
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: comfunc.c,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: comfunc.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/comfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:13
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
@@ -1007,7 +1007,7 @@ cpolar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon)
|
||||
long m, n;
|
||||
|
||||
if (qiszero(epsilon)) {
|
||||
math_error("Zero epsilson for cpolar");
|
||||
math_error("Zero epsilon for cpolar");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (qiszero(q1))
|
||||
@@ -1162,3 +1162,27 @@ cprintfr(COMPLEX *c)
|
||||
zprintval(i->den, 0L, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NUMBER *
|
||||
cilog(COMPLEX *c, ZVALUE base)
|
||||
{
|
||||
NUMBER *qr, *qi;
|
||||
|
||||
qr = qilog(c->real, base);
|
||||
qi = qilog(c->imag, base);
|
||||
|
||||
if (qr == NULL) {
|
||||
if (qi == NULL)
|
||||
return NULL;
|
||||
return qi;
|
||||
}
|
||||
if (qi == NULL)
|
||||
return qr;
|
||||
if (qrel(qr, qi) >= 0) {
|
||||
qfree(qi);
|
||||
return qr;
|
||||
}
|
||||
qfree(qr);
|
||||
return qi;
|
||||
}
|
||||
|
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: commath.c,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: commath.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/commath.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:10
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
246
config.c
246
config.c
@@ -19,14 +19,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: config.c,v 29.2 1999/12/14 19:37:46 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: config.c,v 29.4 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
|
||||
*
|
||||
* Under source code control: 1991/07/20 00:21:56
|
||||
* File existed as early as: 1991
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
@@ -109,10 +109,10 @@ CONFIG oldstd = { /* backward compatible standard configuration */
|
||||
SQ_ALG2, /* size of number to use square alg 2 */
|
||||
POW_ALG2, /* size of modulus to use REDC for powers */
|
||||
REDC_ALG2, /* size of modulus to use REDC algorithm 2 */
|
||||
TRUE, /* ok to print a tilde on aproximations */
|
||||
TRUE, /* ok to print a tilde on approximations */
|
||||
TRUE, /* ok to print tab before numeric values */
|
||||
0, /* quomod() default rounding mode */
|
||||
2, /* quotent // default rounding mode */
|
||||
2, /* quotient // default rounding mode */
|
||||
0, /* mod % default rounding mode */
|
||||
24, /* sqrt() default rounding mode */
|
||||
24, /* appr() default rounding mode */
|
||||
@@ -149,10 +149,10 @@ CONFIG newstd = { /* new non-backward compatible configuration */
|
||||
SQ_ALG2, /* size of number to use square alg 2 */
|
||||
POW_ALG2, /* size of modulus to use REDC for powers */
|
||||
REDC_ALG2, /* size of modulus to use REDC algorithm 2 */
|
||||
TRUE, /* ok to print a tilde on aproximations */
|
||||
TRUE, /* ok to print a tilde on approximations */
|
||||
TRUE, /* ok to print tab before numeric values */
|
||||
0, /* quomod() default rounding mode */
|
||||
0, /* quotent // default rounding mode */
|
||||
0, /* quotient // default rounding mode */
|
||||
0, /* mod % default rounding mode */
|
||||
24, /* sqrt() default rounding mode */
|
||||
24, /* appr() default rounding mode */
|
||||
@@ -287,10 +287,11 @@ static NAMETYPE truth[] = {
|
||||
|
||||
|
||||
/*
|
||||
* declate static functions
|
||||
* declare static functions
|
||||
*/
|
||||
static long lookup_long(NAMETYPE *set, char *name);
|
||||
static char *lookup_name(NAMETYPE *set, long val);
|
||||
static int getlen(VALUE *vp, LEN *lp);
|
||||
|
||||
|
||||
/*
|
||||
@@ -360,6 +361,26 @@ lookup_name(NAMETYPE *set, long val)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check whether VALUE at vp is a LEN (32-bit signed integer) and if so,
|
||||
* copy that integer to lp.
|
||||
* Return: 1, 2, 0, or -1 XXX
|
||||
*/
|
||||
|
||||
static int
|
||||
getlen(VALUE *vp, LEN *lp)
|
||||
{
|
||||
if (vp->v_type != V_NUM || !qisint(vp->v_num))
|
||||
return 1;
|
||||
if (zge31b(vp->v_num->num))
|
||||
return 2;
|
||||
*lp = ztoi(vp->v_num->num);
|
||||
if (*lp < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the specified configuration type to the specified value.
|
||||
* An error is generated if the type number or value is illegal.
|
||||
@@ -370,6 +391,7 @@ setconfig(int type, VALUE *vp)
|
||||
NUMBER *q;
|
||||
CONFIG *newconf; /* new configuration to set */
|
||||
long temp;
|
||||
LEN len;
|
||||
char *p;
|
||||
|
||||
switch (type) {
|
||||
@@ -414,15 +436,11 @@ setconfig(int type, VALUE *vp)
|
||||
break;
|
||||
|
||||
case CONFIG_DISPLAY:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non-numeric for display");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Bad value for display");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num))
|
||||
temp = -1;
|
||||
math_setdigits(temp);
|
||||
math_setdigits(len);
|
||||
break;
|
||||
|
||||
case CONFIG_MODE:
|
||||
@@ -447,91 +465,51 @@ setconfig(int type, VALUE *vp)
|
||||
break;
|
||||
|
||||
case CONFIG_MAXPRINT:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non-numeric for maxprint");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Bad value for maxprint");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num))
|
||||
temp = -1;
|
||||
if (temp < 0) {
|
||||
math_error("Maxprint value is out of range");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->maxprint = temp;
|
||||
conf->maxprint = len;
|
||||
break;
|
||||
|
||||
case CONFIG_MUL2:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non-numeric for mul2");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Bad value for mul2");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q))
|
||||
temp = -1;
|
||||
if (temp == 0)
|
||||
temp = MUL_ALG2;
|
||||
if (temp < 2) {
|
||||
math_error("Illegal mul2 value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->mul2 = (int)temp;
|
||||
if (len == 0)
|
||||
len = MUL_ALG2;
|
||||
conf->mul2 = len;
|
||||
break;
|
||||
|
||||
case CONFIG_SQ2:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non-numeric for sq2");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Bad value for sq2");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q))
|
||||
temp = -1;
|
||||
if (temp == 0)
|
||||
temp = SQ_ALG2;
|
||||
if (temp < 2) {
|
||||
math_error("Illegal sq2 value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->sq2 = (int)temp;
|
||||
if (len == 0)
|
||||
len = SQ_ALG2;
|
||||
conf->sq2 = len;
|
||||
break;
|
||||
|
||||
case CONFIG_POW2:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non-numeric for pow2");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Bad value for pow2");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q))
|
||||
temp = -1;
|
||||
if (temp == 0)
|
||||
temp = POW_ALG2;
|
||||
if (temp < 1) {
|
||||
math_error("Illegal pow2 value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->pow2 = (int)temp;
|
||||
if (len == 0)
|
||||
len = POW_ALG2;
|
||||
conf->pow2 = len;
|
||||
break;
|
||||
|
||||
case CONFIG_REDC2:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non-numeric for redc2");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Bad value for redc2");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q))
|
||||
temp = -1;
|
||||
if (temp == 0)
|
||||
temp = REDC_ALG2;
|
||||
if (temp < 1) {
|
||||
math_error("Illegal redc2 value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->redc2 = (int)temp;
|
||||
if (len == 0)
|
||||
len = REDC_ALG2;
|
||||
conf->redc2 = len;
|
||||
break;
|
||||
|
||||
case CONFIG_TILDE:
|
||||
@@ -563,129 +541,75 @@ setconfig(int type, VALUE *vp)
|
||||
break;
|
||||
|
||||
case CONFIG_QUOMOD:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non numeric for quomod");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Illegal value for quomod");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num)) {
|
||||
math_error("Illegal quomod parameter value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->quomod = temp;
|
||||
conf->quomod = len;
|
||||
break;
|
||||
|
||||
case CONFIG_QUO:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non numeric for quo");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Illegal value for quo");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num)) {
|
||||
math_error("Illegal quo parameter value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->quo = temp;
|
||||
conf->quo = len;
|
||||
break;
|
||||
|
||||
case CONFIG_MOD:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non numeric for mod");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Illegal value for mod");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num)) {
|
||||
math_error("Illegal mod parameter value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->mod = temp;
|
||||
conf->mod = len;
|
||||
break;
|
||||
|
||||
case CONFIG_SQRT:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non numeric for sqrt");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Illegal value for sqrt");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num)) {
|
||||
math_error("Illegal sqrt parameter value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->sqrt = temp;
|
||||
conf->sqrt = len;
|
||||
break;
|
||||
|
||||
case CONFIG_APPR:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non numeric for appr");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Illegal value for appr");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num)) {
|
||||
math_error("Illegal appr parameter value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->appr = temp;
|
||||
conf->appr = len;
|
||||
break;
|
||||
|
||||
case CONFIG_CFAPPR:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non numeric for cfappr");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Illegal value for cfappr");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num)) {
|
||||
math_error("Illegal cfappr parameter value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->cfappr = temp;
|
||||
conf->cfappr = len;
|
||||
break;
|
||||
|
||||
case CONFIG_CFSIM:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non numeric for cfsim");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Illegal value for cfsim");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num)) {
|
||||
math_error("Illegal cfsim parameter value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->cfsim = temp;
|
||||
conf->cfsim = len;
|
||||
break;
|
||||
|
||||
case CONFIG_OUTROUND:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non numeric for outround");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Illegal value for outround");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num)) {
|
||||
math_error("Illegal output parameter value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->outround = temp;
|
||||
conf->outround = len;
|
||||
break;
|
||||
|
||||
case CONFIG_ROUND:
|
||||
if (vp->v_type != V_NUM) {
|
||||
math_error("Non numeric for round");
|
||||
if (getlen(vp, &len)) {
|
||||
math_error("Illegal value for round");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
q = vp->v_num;
|
||||
temp = qtoi(q);
|
||||
if (qisfrac(q) || qisneg(q) || !zistiny(q->num)) {
|
||||
math_error("Illegal output parameter value");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
conf->round = temp;
|
||||
conf->round = len;
|
||||
break;
|
||||
|
||||
case CONFIG_LEADZERO:
|
||||
@@ -1311,12 +1235,12 @@ config_cmp(CONFIG *cfg1, CONFIG *cfg2)
|
||||
*/
|
||||
if (cfg1 == NULL || cfg1->epsilon == NULL || cfg1->prompt1 == NULL ||
|
||||
cfg1->prompt2 == NULL) {
|
||||
math_error("CONFIG #1 value is invaid");
|
||||
math_error("CONFIG #1 value is invalid");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (cfg2 == NULL || cfg2->epsilon == NULL || cfg2->prompt1 == NULL ||
|
||||
cfg2->prompt2 == NULL) {
|
||||
math_error("CONFIG #2 value is invaid");
|
||||
math_error("CONFIG #2 value is invalid");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
|
55
config.h
55
config.h
@@ -19,15 +19,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: config.h,v 29.2 1999/12/14 19:37:46 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: config.h,v 29.6 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.h,v $
|
||||
*
|
||||
* Under source code control: 1995/11/01 22:20:17
|
||||
* File existed as early as: 1995
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#define __CONFIG_H__
|
||||
|
||||
|
||||
#include "win32dll.h"
|
||||
#include "nametype.h"
|
||||
#include "qmath.h"
|
||||
|
||||
@@ -110,26 +111,26 @@
|
||||
*/
|
||||
struct config {
|
||||
int outmode; /* current output mode */
|
||||
long outdigits; /* current output digits for float or exp */
|
||||
LEN outdigits; /* current output digits for float or exp */
|
||||
NUMBER *epsilon; /* default error for real functions */
|
||||
long epsilonprec; /* epsilon binary precision (tied to epsilon) */
|
||||
FLAG traceflags; /* tracing flags */
|
||||
long maxprint; /* number of elements to print */
|
||||
LEN maxprint; /* number of elements to print */
|
||||
LEN mul2; /* size of number to use multiply algorithm 2 */
|
||||
LEN sq2; /* size of number to use square algorithm 2 */
|
||||
LEN pow2; /* size of modulus to use REDC for powers */
|
||||
LEN redc2; /* size of modulus to use REDC algorithm 2 */
|
||||
BOOL tilde_ok; /* ok to print a tilde on aproximations */
|
||||
BOOL tab_ok; /* ok to print tab before numeric values */
|
||||
long quomod; /* quomod() default rounding mode */
|
||||
long quo; /* quotent // default rounding mode */
|
||||
long mod; /* mod % default rounding mode */
|
||||
long sqrt; /* sqrt() default rounding mode */
|
||||
long appr; /* appr() default rounding mode */
|
||||
long cfappr; /* cfappr() default rounding mode */
|
||||
long cfsim; /* cfsim() default rounding mode */
|
||||
long outround; /* output default rounding mode */
|
||||
long round; /* round()/bround() default rounding mode */
|
||||
LEN quomod; /* quomod() default rounding mode */
|
||||
LEN quo; /* quotient // default rounding mode */
|
||||
LEN mod; /* mod % default rounding mode */
|
||||
LEN sqrt; /* sqrt() default rounding mode */
|
||||
LEN appr; /* appr() default rounding mode */
|
||||
LEN cfappr; /* cfappr() default rounding mode */
|
||||
LEN cfsim; /* cfsim() default rounding mode */
|
||||
LEN outround; /* output default rounding mode */
|
||||
LEN round; /* round()/bround() default rounding mode */
|
||||
BOOL leadzero; /* ok to print leading 0 before decimal pt */
|
||||
BOOL fullzero; /* ok to print trailing 0's */
|
||||
long maxscancount; /* max scan errors before abort */
|
||||
@@ -182,23 +183,23 @@ typedef struct config CONFIG;
|
||||
/*
|
||||
* global configuration states and aliases
|
||||
*/
|
||||
extern CONFIG *conf; /* current configuration */
|
||||
extern CONFIG oldstd; /* backward compatible standard configuration */
|
||||
extern CONFIG newstd; /* new non-backward compatible configuration */
|
||||
extern char *calc_debug; /* !=NULL => value of config("calc_debug") */
|
||||
extern char *resource_debug; /* !=NULL => config("resource_debug") value */
|
||||
extern char *user_debug; /* !=NULL => value of config("user_debug") */
|
||||
extern DLL CONFIG *conf; /* current configuration */
|
||||
extern DLL CONFIG oldstd; /* backward compatible standard configuration */
|
||||
extern DLL CONFIG newstd; /* new non-backward compatible configuration */
|
||||
extern DLL char *calc_debug; /* !=NULL => value of config("calc_debug") */
|
||||
extern DLL char *resource_debug; /* !=NULL => config("resource_debug") value */
|
||||
extern DLL char *user_debug; /* !=NULL => value of config("user_debug") */
|
||||
|
||||
|
||||
/*
|
||||
* configuration externals
|
||||
*/
|
||||
extern CONFIG *config_copy(CONFIG *src);
|
||||
extern void config_free(CONFIG *cfg);
|
||||
extern void config_print(CONFIG *cfg);
|
||||
extern int configtype(char*);
|
||||
extern void config_print(CONFIG*);
|
||||
extern BOOL config_cmp(CONFIG*, CONFIG*);
|
||||
extern DLL CONFIG *config_copy(CONFIG *src);
|
||||
extern DLL void config_free(CONFIG *cfg);
|
||||
extern DLL void config_print(CONFIG *cfg);
|
||||
extern DLL int configtype(char*);
|
||||
extern DLL void config_print(CONFIG*);
|
||||
extern DLL BOOL config_cmp(CONFIG*, CONFIG*);
|
||||
|
||||
|
||||
#endif /* !__CONFIG_H__ */
|
||||
|
6
const.c
6
const.c
@@ -17,14 +17,14 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: const.c,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: const.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/const.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:14
|
||||
* File existed as early as: before 1990
|
||||
*
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -17,15 +17,15 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: Makefile,v 29.3 1999/12/14 19:30:19 chongo Exp $
|
||||
# @(#) $Revision: 29.6 $
|
||||
# @(#) $Id: Makefile,v 29.6 2000/12/15 14:56:14 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1999/11/29 11:10:26
|
||||
# File existed as early as: 1999
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
#
|
||||
# calculator by David I. Bell with help/mods from others
|
||||
# Makefile by Landon Curt Noll
|
||||
@@ -65,7 +65,7 @@ FMT= fmt
|
||||
#
|
||||
# The ${SCRIPT_SRC} is built from ${SCRIPT} and has the .calc extensions.
|
||||
#
|
||||
# This list is prodiced by the detaillist rule when no WARNINGS are detected.
|
||||
# This list is produced by the detaillist rule when no WARNINGS are detected.
|
||||
# To add a script:
|
||||
#
|
||||
# 1) Name the file with a .calc filename extension
|
||||
@@ -76,15 +76,15 @@ FMT= fmt
|
||||
#
|
||||
# make detaillist
|
||||
#
|
||||
SCRIPT= mersenne piforever plus simple
|
||||
SCRIPT= mersenne piforever plus simple square
|
||||
|
||||
SCRIPT_SRC= mersenne.calc piforever.calc plus.calc simple.calc
|
||||
SCRIPT_SRC= mersenne.calc piforever.calc plus.calc simple.calc square.calc
|
||||
|
||||
# These files are found (but not built) in the distribution
|
||||
#
|
||||
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE}
|
||||
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README
|
||||
|
||||
# These files are used to make (but not built) a calc .a library
|
||||
# These files are used to make (but not build) a calc .a library
|
||||
#
|
||||
CALCLIBLIST=
|
||||
|
||||
@@ -92,10 +92,10 @@ CALCLIBLIST=
|
||||
#
|
||||
all: ${SCRIPT} ${SCRIPT_SRC} .all
|
||||
|
||||
# used by the upper level Makefile to determine of we have done all
|
||||
# used by the upper level Makefile to determine if we have done all
|
||||
#
|
||||
# NOTE: Due to bogus shells found on one common system we must have
|
||||
# an non-emoty else clause for every if condition. *sigh*
|
||||
# a non-empty else clause for every if condition. *sigh*
|
||||
#
|
||||
.all:
|
||||
rm -f .all
|
||||
@@ -245,3 +245,7 @@ simple: simple.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
square: square.calc
|
||||
rm -f $@
|
||||
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
${CHMOD} +x $@
|
||||
|
65
cscript/README
Normal file
65
cscript/README
Normal file
@@ -0,0 +1,65 @@
|
||||
calc shell script examples
|
||||
--------------------------
|
||||
|
||||
These calc shell scripts are provided because they serve as examples of
|
||||
how use the calc language, and/or because the authors thought them to
|
||||
be useful!
|
||||
|
||||
If you write something that you think is useful, please send it to:
|
||||
|
||||
calc-contrib at asthe dot com
|
||||
|
||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
||||
|
||||
For more info, see:
|
||||
|
||||
help script
|
||||
help cscript
|
||||
|
||||
=-=
|
||||
|
||||
mersenne exp
|
||||
|
||||
Print the value of 2^exp-1.
|
||||
|
||||
|
||||
piforever
|
||||
|
||||
Print the value of pi forever, or as long as you cpu / memory allows.
|
||||
|
||||
|
||||
plus arg ...
|
||||
|
||||
Print the sum of 1 or more arguments.
|
||||
|
||||
|
||||
simple
|
||||
|
||||
A trivial example of a calc shell script.
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: README,v 29.4 2000/06/07 14:02:59 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/README,v $
|
||||
##
|
||||
## Under source code control: 1999/12/17 10:23:40
|
||||
## File existed as early as: 1999
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/local/src/cmd/calc/calc -S
|
||||
#!/usr/local/src/cmd/calc/calc -q -s -f
|
||||
#
|
||||
# mersenne - print the value of a mersenne number
|
||||
#
|
||||
@@ -18,15 +18,15 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: mersenne.calc,v 29.1 1999/12/14 09:15:35 chongo Exp $
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: mersenne.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/mersenne.calc,v $
|
||||
#
|
||||
# Under source code control: 1999/11/30 00:09:01;
|
||||
# File existed as early as: 1999
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
# usage:
|
||||
# mersenne exp
|
||||
@@ -35,13 +35,19 @@
|
||||
/*
|
||||
* parse args
|
||||
*/
|
||||
if (argv() != 1) {
|
||||
if (argv() != 2) {
|
||||
/* we include the name of this script in the error message */
|
||||
fprintf(files(2), "usage: %s exp\n", config("program"));
|
||||
abort "wrong number of args";
|
||||
}
|
||||
|
||||
global n = eval(argv(1));
|
||||
|
||||
if (!isint(n) || n <= 0) {
|
||||
quit "Argument to be a positive integer";
|
||||
}
|
||||
|
||||
/*
|
||||
* print the decimal value of 2^n-1
|
||||
*/
|
||||
print "2^": argv(0) : "-1 =", 2^eval(argv(0))-1;
|
||||
print "2^": n : "-1 =", 2^n-1;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/local/src/cmd/calc/calc -S
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
#
|
||||
# piforever - print digits of pi forever (or as long as your mem/cpu allow)
|
||||
#
|
||||
@@ -18,15 +18,15 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: piforever.calc,v 29.1 1999/12/14 09:15:36 chongo Exp $
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: piforever.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/piforever.calc,v $
|
||||
#
|
||||
# Under source code control: 1999/11/30 00:11:36
|
||||
# File existed as early as: 1999
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
# usage:
|
||||
# piforever
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/local/src/cmd/calc/calc -S
|
||||
#!/usr/local/src/cmd/calc/calc -q -s -f
|
||||
#
|
||||
# plus - add two or more arguments together
|
||||
#
|
||||
@@ -18,15 +18,15 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: plus.calc,v 29.1 1999/12/14 09:15:36 chongo Exp $
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: plus.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/plus.calc,v $
|
||||
#
|
||||
# Under source code control: 1999/11/29 10:22:37
|
||||
# File existed as early as: 1999
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
# usage:
|
||||
# plus val ...
|
||||
@@ -35,19 +35,19 @@
|
||||
/*
|
||||
* parse args
|
||||
*/
|
||||
if (argv() < 1) {
|
||||
if (argv() < 2) {
|
||||
/* we include the name of this script in the error message */
|
||||
fprintf(files(2), "usage: %s value ...\n", config("program"));
|
||||
abort "not enough args";
|
||||
}
|
||||
|
||||
/*
|
||||
* print the sum of the 2 args
|
||||
* print the sum of the args
|
||||
*
|
||||
* Since args are strings, we must eval them before using them numerically.
|
||||
*/
|
||||
sum = 0;
|
||||
for (i=0; i < argv(); ++i) {
|
||||
for (i=1; i < argv(); ++i) {
|
||||
sum += eval(argv(i));
|
||||
}
|
||||
print sum;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/local/src/cmd/calc/calc -S
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
#
|
||||
# simple - an example of a simple calc shell script
|
||||
#
|
||||
@@ -18,18 +18,18 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.1 $
|
||||
# @(#) $Id: simple.calc,v 29.1 1999/12/14 09:15:36 chongo Exp $
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: simple.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/simple.calc,v $
|
||||
#
|
||||
# Under source code control: 1999/11/29 10:22:37
|
||||
# File existed as early as: 1999
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
# Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
|
||||
/*
|
||||
* This is an example of a simple calc shell script.
|
||||
*/
|
||||
print "The simple calc shell script works!"
|
||||
print "This simple calc shell script works!"
|
||||
|
65
cscript/square.calc
Normal file
65
cscript/square.calc
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
#
|
||||
# sqaure - print the squares of input values
|
||||
#
|
||||
# Copyright (C) 2000 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.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: square.calc,v 29.3 2000/12/17 14:31:58 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/square.calc,v $
|
||||
#
|
||||
# Under source code control: 2000/12/15 06:52:01
|
||||
# File existed as early as: 2000
|
||||
#
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# From the shell:
|
||||
#
|
||||
# ./square
|
||||
# cat file | ./square
|
||||
# echo "123" | ./square
|
||||
#
|
||||
# Within calc:
|
||||
#
|
||||
# > read square
|
||||
#
|
||||
# With input from a terminal, there is no prompt but each non-empty
|
||||
# line of input is evaluated as a calc expression and if it can be
|
||||
# calculated, the square of the value of that expression is displayed.
|
||||
# Execution stops when an empty line is input.
|
||||
#
|
||||
# From the shell:
|
||||
#
|
||||
# ./square
|
||||
#
|
||||
# The following shows lines of input followed by output:
|
||||
#
|
||||
# 1234
|
||||
# 1522756
|
||||
# ln(2)
|
||||
# ~.48045301391820142467
|
||||
# config("mode","frac"), bernoulli(10)
|
||||
# 25/4356
|
||||
# config("mode", "hex"), 0xff
|
||||
# 0xfe01
|
||||
#
|
||||
|
||||
global s;
|
||||
while ((s = prompt("")))
|
||||
print "\t":eval(s)^2;
|
11
custom.c
11
custom.c
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: custom.c,v 29.1 1999/12/14 09:15:36 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: custom.c,v 29.3 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/custom.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/03 04:53:08
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
@@ -34,11 +34,10 @@
|
||||
#include "value.h"
|
||||
#include "custom.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(CUSTOM)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "calc.h"
|
||||
|
||||
#include "have_string.h"
|
||||
|
8
custom.h
8
custom.h
@@ -17,15 +17,15 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: custom.h,v 29.1 1999/12/14 09:15:36 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: custom.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/custom.h,v $
|
||||
*
|
||||
* Under source code control: 1997/03/03 04:53:08
|
||||
* File existed as early as: 1997
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
* Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -57,12 +57,12 @@ pzasusb8.cal
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: CUSTOM_CAL,v 29.1 1999/12/14 09:15:36 chongo Exp $
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: CUSTOM_CAL,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/CUSTOM_CAL,v $
|
||||
##
|
||||
## Under source code control: 1997/03/08 20:51:32
|
||||
## File existed as early as: 1997
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
## Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
@@ -635,12 +635,12 @@ Step 12: Contribute
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: HOW_TO_ADD,v 29.1 1999/12/14 09:15:36 chongo Exp $
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: HOW_TO_ADD,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/HOW_TO_ADD,v $
|
||||
##
|
||||
## Under source code control: 1997/03/10 03:03:21
|
||||
## File existed as early as: 1997
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://reality.sgi.com/chongo/
|
||||
## Share and enjoy! :-) http://reality.sgi.com/chongo/tech/comp/calc/
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user