mirror of
https://github.com/lcn2/calc.git
synced 2025-08-22 01:23:28 +03:00
Compare commits
5 Commits
2.11.3t0
...
2.11.5t1.0
Author | SHA1 | Date | |
---|---|---|---|
|
63d9b22067 | ||
|
fc85ac3791 | ||
|
3d55811205 | ||
|
296aa50ac7 | ||
|
5e098d2adf |
49
BUGS
49
BUGS
@@ -83,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,:
|
||||
@@ -179,8 +224,8 @@ Problems with known work-a-rounds:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.5 $
|
||||
## @(#) $Id: BUGS,v 29.5 2000/06/07 14:02:13 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
|
||||
|
102
CHANGES
102
CHANGES
@@ -1,4 +1,98 @@
|
||||
The following are the changes from calc version 2.11.3t0 to date:
|
||||
The following are the changes from calc version 2.11.5t0 to date:
|
||||
|
||||
Fixed a compile problem with Linux 2.4 / Debian. Thanks goes
|
||||
to Martin Buck <m at rtin-buck dot de> for help with this issue.
|
||||
|
||||
Fixed a bug in how L64_FORMAT (it determined if "%ld" or "%lld"
|
||||
is appropriate for printing of 64 bit long longs) was determined.
|
||||
Thanks goes to Martin Buck <m at rtin-buck dot de> for reporting
|
||||
this bug and testing the fix.
|
||||
|
||||
An effort was made to make calc easier to build under Windoz
|
||||
using the Cygwin project (http://sources.redhat.com/cygwin/).
|
||||
Thanks to the work of Thomas Jones-Low (tjoneslo and softstart
|
||||
dot com), a number of #if defined(_WIN32)'s have been added
|
||||
to calc source. These changes should not effect Windoz
|
||||
free system such as GNU/Linux, Solaris, POSIX-like, etc ...
|
||||
|
||||
Added windll.h to deal with Windoz related DLL issues.
|
||||
Using the convention of 'extern DLL' instead of 'DLL extern'
|
||||
to deal with symbols that export to or import from a DLL.
|
||||
|
||||
Added HAVE_MALLOC_H, HAVE_STDLIB_H, HAVE_STRING_H, HAVE_TIMES_H,
|
||||
HAVE_SYS_TIMES_H, HAVE_TIME_H, HAVE_SYS_TIME_H, HAVE_UNISTD_H
|
||||
and HAVE_URANDOM to the Makefile. If these symcols are empty,
|
||||
then the Makefile looks for the appropriate system include file.
|
||||
If they are YES, then the Makefile will assume they exist.
|
||||
If they are NO, then the Makefile will assume they do not exist.
|
||||
|
||||
Changed HAVE_URANDOM to match the empty, YES, NO values.
|
||||
If HAVE_URANDOM is empty, then the Makefile will look for /dev/urandom.
|
||||
If HAVE_URANDOM is YES, then the Makefile will assume /dev/urandom exists.
|
||||
If HAVE_URANDOM is NO, then the Makefile will assume /dev/urandom does
|
||||
not exist.
|
||||
|
||||
If TERMCONTROL is -DUSE_WIN32, then the Windoz terminal control
|
||||
(no TERMIOS, no TERMIO, no SGTTY) will be assumed.
|
||||
|
||||
Added a win32_hsrc Makefile rule to create hsrc files appropriate
|
||||
for a Windoz system using Cygwin gcc environment. Added win32.mkdef
|
||||
which is used by the win32_hsrc rule to set the Windoz specific
|
||||
Makefile values to build hsrc files. The hsrc files are built
|
||||
under the win32 directory.
|
||||
|
||||
Added FPOS_POS_BITS, OFF_T_BITS, DEV_BITS and INODE_BITS Makefile
|
||||
symbiols to allow one to force the size of a file position, file
|
||||
offset, dev and inode value. Leaving these values blank will
|
||||
Makefile to determine their size.
|
||||
|
||||
Fixed a bug in the way file offsets, device and inode values are copied.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.4t1 to date:
|
||||
|
||||
Added missing test8600.cal test file.
|
||||
|
||||
Fixes cscript files to deal with the -S flag being replaced by
|
||||
-f and possibly other flags.
|
||||
|
||||
Added regression tests for builtin functions bernoulli, catalan,
|
||||
euler, freeeuler, and sleep. Added non-base 10 regression tests
|
||||
for digit, digits and places.
|
||||
|
||||
The bernoulli.cal script now just calls the bernoulli() builtin
|
||||
function. It remains for backward compatibility.
|
||||
|
||||
The Makefile now builds have_fpos_pos.h to determine if the
|
||||
a non-scalar FILEPOS has a __pos stucture element. If it does,
|
||||
the FILEPOS_BITS is taken to be the size of just the __pos element.
|
||||
|
||||
Misc fixes related to non-scalar (e.g., structure) FILEPOS. Fixed
|
||||
a compile problems where non-scalar FILEPOS were incorrectly assigned.
|
||||
|
||||
Fixed make depend rule.
|
||||
|
||||
Return an error on malloc / realloc failures for bernoulli and
|
||||
euler functions.
|
||||
|
||||
Added MAKEFILE_REV make variable to help determine Makefile version.
|
||||
Fixed the way the env rule reports Makefile values.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.3t0 to 2.11.4:
|
||||
|
||||
Increased the maximum number of args for functions from 100 to 1024.
|
||||
Increased calc's internal evaluation stack from 1024 to 2048 args.
|
||||
Added test8600.cal to the regression suite to test these new limits.
|
||||
|
||||
Updated and fixed misc typos in calc/README.
|
||||
|
||||
Clarified in the COPYING file that ALL calc source files, both
|
||||
LGPL covered and exceptions to the LGPL files may be freely used
|
||||
and distributed.
|
||||
|
||||
Added help files or updated for: bernoulli, calc_tty, catalan,
|
||||
digit, digits, euler, freeeuler, places and sleep.
|
||||
|
||||
A collection of 18 patches from Ernest Bowen
|
||||
<ernie at turing dot une dot edu dot au>:
|
||||
@@ -167,7 +261,7 @@ The following are the changes from calc version 2.11.3t0 to date:
|
||||
size of n in digit(x, n, b), for example, digit(1/7, -1e100) which
|
||||
would not work before can now be handled.
|
||||
|
||||
(13) The function, digits(x)m which returns the number of decimal
|
||||
(13) The function, digits(x), which returns the number of decimal
|
||||
digits in the integer part of x has been changed so that if abs(x) <
|
||||
1, it returns 0 rather than 1. This also now applies to digits(x,b).
|
||||
|
||||
@@ -4998,8 +5092,8 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.11 $
|
||||
## @(#) $Id: CHANGES,v 29.11 2000/06/07 15:51:35 chongo Exp chongo $
|
||||
## @(#) $Revision: 29.22 $
|
||||
## @(#) $Id: CHANGES,v 29.22 2001/03/18 03:27:28 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
|
||||
##
|
||||
## Under source code control: 1993/06/02 18:12:57
|
||||
|
23
COPYING
23
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.2 $
|
||||
# @(#) $Id: COPYING,v 29.2 2000/06/07 14:02:13 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 $
|
||||
|
||||
=-=
|
||||
@@ -140,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
|
||||
@@ -150,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
|
||||
shs1.c shs1.h shs.c shs.h
|
||||
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
|
||||
@@ -167,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
|
||||
|
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/
|
4
addop.c
4
addop.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: addop.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $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
|
||||
|
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: Makefile,v 29.2 2000/06/07 14:02:25 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
|
||||
@@ -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
|
||||
#
|
||||
|
59
cal/README
59
cal/README
@@ -1,7 +1,7 @@
|
||||
Calc standard resource files
|
||||
----------------------------
|
||||
|
||||
To load a reosurce file, try:
|
||||
To load a resource file, try:
|
||||
|
||||
read filename
|
||||
|
||||
@@ -59,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:
|
||||
@@ -116,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
|
||||
|
||||
@@ -274,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
|
||||
@@ -288,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.
|
||||
@@ -356,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.
|
||||
|
||||
|
||||
@@ -386,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.
|
||||
@@ -489,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
|
||||
@@ -514,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.
|
||||
|
||||
|
||||
@@ -537,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.
|
||||
|
||||
|
||||
@@ -625,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
|
||||
|
||||
@@ -677,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)
|
||||
@@ -705,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
|
||||
##
|
||||
@@ -723,8 +756,8 @@ 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.2 $
|
||||
## @(#) $Id: README,v 29.2 2000/06/07 14:02:25 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
|
||||
|
@@ -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,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: bernoulli.cal,v 29.2 2000/06/07 14:02:25 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
|
||||
@@ -29,12 +29,16 @@
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
@@ -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://www.isthe.com/chongo/>
|
||||
*
|
||||
* See:
|
||||
* http://www.magnetic-ink.dk/download/qtime.html
|
||||
*
|
||||
* for examples of qtime() written on other languages.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: qtime.cal,v 29.2 2000/06/07 14:02:25 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,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: regress.cal,v 29.3 2000/06/07 14:02:25 chongo Exp chongo $
|
||||
* @(#) $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
|
||||
@@ -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()';
|
||||
|
||||
@@ -7538,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
|
||||
*
|
||||
|
1406
cal/test8600.cal
Normal file
1406
cal/test8600.cal
Normal file
File diff suppressed because it is too large
Load Diff
24
calc.c
24
calc.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: calc.c,v 29.4 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $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
|
||||
@@ -32,10 +32,27 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <pwd.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)
|
||||
|
231
calc.h
231
calc.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: calc.h,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $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
|
||||
@@ -32,9 +32,8 @@
|
||||
#define __CALC_H__
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#include "win32dll.h"
|
||||
#include "value.h"
|
||||
|
||||
#include "have_const.h"
|
||||
|
||||
|
||||
@@ -62,7 +61,7 @@
|
||||
#define SYMBOLSIZE 256 /* maximum symbol name size */
|
||||
#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 */
|
||||
@@ -94,134 +93,140 @@
|
||||
/*
|
||||
* 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 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
|
||||
@@ -237,8 +242,8 @@ typedef enum {
|
||||
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
|
||||
@@ -249,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__ */
|
||||
|
@@ -17,8 +17,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: calcerr.tbl,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
# @(#) $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
|
||||
|
4
cmath.h
4
cmath.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: cmath.h,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $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
|
||||
|
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: codegen.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $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
|
||||
@@ -45,6 +45,10 @@
|
||||
#include "func.h"
|
||||
#include "conf.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <direct.h>
|
||||
#endif
|
||||
|
||||
static BOOL rdonce; /* TRUE => do not reread this file */
|
||||
|
||||
FUNC *curfunc;
|
||||
@@ -162,6 +166,7 @@ getcommands(BOOL toplevel)
|
||||
}
|
||||
for (;;) {
|
||||
if (getfilename(name, &rdonce))
|
||||
break;
|
||||
switch (opensearchfile(name,calcpath,
|
||||
CALCEXT,rdonce)) {
|
||||
case 0:
|
||||
|
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: comfunc.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $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
|
||||
|
4
config.c
4
config.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: config.c,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $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
|
||||
|
29
config.h
29
config.h
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: config.h,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $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
|
||||
@@ -35,6 +35,7 @@
|
||||
#define __CONFIG_H__
|
||||
|
||||
|
||||
#include "win32dll.h"
|
||||
#include "nametype.h"
|
||||
#include "qmath.h"
|
||||
|
||||
@@ -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__ */
|
||||
|
@@ -17,8 +17,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.5 $
|
||||
# @(#) $Id: Makefile,v 29.5 2000/06/07 14:02:59 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
|
||||
@@ -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} 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 $@
|
||||
|
@@ -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,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: mersenne.calc,v 29.2 2000/06/07 14:02:59 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;
|
||||
@@ -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,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: piforever.calc,v 29.2 2000/06/07 14:02:59 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
|
||||
|
@@ -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,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: plus.calc,v 29.2 2000/06/07 14:02:59 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
|
||||
@@ -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,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: simple.calc,v 29.2 2000/06/07 14:02:59 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
|
||||
@@ -32,4 +32,4 @@
|
||||
/*
|
||||
* 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;
|
7
custom.c
7
custom.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: custom.c,v 29.2 2000/06/07 14:02:13 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
|
||||
@@ -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"
|
||||
|
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: Makefile,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
# @(#) $Revision: 29.5 $
|
||||
# @(#) $Id: Makefile,v 29.5 2001/03/17 21:39:24 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/03/09 02:28:54
|
||||
@@ -406,7 +406,10 @@ depend:
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/custom/$$i"; \
|
||||
done
|
||||
${Q}(cd ..; ${MAKE} hsrc)
|
||||
${Q}for i in `cd ..; ${MAKE} h_list`; do \
|
||||
${Q}for i in `cd ..; ${MAKE} h_list 2>&1 | \
|
||||
${SED} -e '/Entering directory/d' \
|
||||
-e '/Nothing to be done/d' \
|
||||
-e '/Leaving directory/d'`; do \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/$$i"; \
|
||||
echo "#define $$tag" >> "skel/$$i"; \
|
||||
@@ -457,7 +460,7 @@ clean:
|
||||
|
||||
clobber:
|
||||
-rm -f ${TARGETS}
|
||||
rm -f .all Makefile.tmp
|
||||
rm -f .all Makefile.tmp Makefile.bak
|
||||
|
||||
install: all
|
||||
-${Q}if [ ! -d ${TOPDIR} ]; then \
|
||||
@@ -534,11 +537,13 @@ install: all
|
||||
|
||||
# DO NOT DELETE THIS LINE
|
||||
|
||||
|
||||
c_argv.o: ../alloc.h
|
||||
c_argv.o: ../block.h
|
||||
c_argv.o: ../byteswap.h
|
||||
c_argv.o: ../calc.h
|
||||
c_argv.o: ../calcerr.h
|
||||
c_argv.o: ../calc.h
|
||||
c_argv.o: c_argv.c
|
||||
c_argv.o: ../cmath.h
|
||||
c_argv.o: ../config.h
|
||||
c_argv.o: ../custom.h
|
||||
@@ -554,16 +559,17 @@ c_argv.o: ../longbits.h
|
||||
c_argv.o: ../md5.h
|
||||
c_argv.o: ../nametype.h
|
||||
c_argv.o: ../qmath.h
|
||||
c_argv.o: ../shs.h
|
||||
c_argv.o: ../shs1.h
|
||||
c_argv.o: ../shs.h
|
||||
c_argv.o: ../string.h
|
||||
c_argv.o: ../value.h
|
||||
c_argv.o: ../win32dll.h
|
||||
c_argv.o: ../zmath.h
|
||||
c_argv.o: c_argv.c
|
||||
c_devnull.o: ../alloc.h
|
||||
c_devnull.o: ../block.h
|
||||
c_devnull.o: ../byteswap.h
|
||||
c_devnull.o: ../calcerr.h
|
||||
c_devnull.o: c_devnull.c
|
||||
c_devnull.o: ../cmath.h
|
||||
c_devnull.o: ../config.h
|
||||
c_devnull.o: ../custom.h
|
||||
@@ -579,16 +585,17 @@ c_devnull.o: ../longbits.h
|
||||
c_devnull.o: ../md5.h
|
||||
c_devnull.o: ../nametype.h
|
||||
c_devnull.o: ../qmath.h
|
||||
c_devnull.o: ../shs.h
|
||||
c_devnull.o: ../shs1.h
|
||||
c_devnull.o: ../shs.h
|
||||
c_devnull.o: ../string.h
|
||||
c_devnull.o: ../value.h
|
||||
c_devnull.o: ../win32dll.h
|
||||
c_devnull.o: ../zmath.h
|
||||
c_devnull.o: c_devnull.c
|
||||
c_help.o: ../alloc.h
|
||||
c_help.o: ../block.h
|
||||
c_help.o: ../byteswap.h
|
||||
c_help.o: ../calcerr.h
|
||||
c_help.o: c_help.c
|
||||
c_help.o: ../cmath.h
|
||||
c_help.o: ../config.h
|
||||
c_help.o: ../custom.h
|
||||
@@ -604,18 +611,19 @@ c_help.o: ../longbits.h
|
||||
c_help.o: ../md5.h
|
||||
c_help.o: ../nametype.h
|
||||
c_help.o: ../qmath.h
|
||||
c_help.o: ../shs.h
|
||||
c_help.o: ../shs1.h
|
||||
c_help.o: ../shs.h
|
||||
c_help.o: ../string.h
|
||||
c_help.o: ../value.h
|
||||
c_help.o: ../win32dll.h
|
||||
c_help.o: ../zmath.h
|
||||
c_help.o: c_help.c
|
||||
c_pzasusb8.o: ../alloc.h
|
||||
c_pzasusb8.o: ../block.h
|
||||
c_pzasusb8.o: ../byteswap.h
|
||||
c_pzasusb8.o: ../calcerr.h
|
||||
c_pzasusb8.o: ../cmath.h
|
||||
c_pzasusb8.o: ../config.h
|
||||
c_pzasusb8.o: c_pzasusb8.c
|
||||
c_pzasusb8.o: ../custom.h
|
||||
c_pzasusb8.o: ../endian_calc.h
|
||||
c_pzasusb8.o: ../hash.h
|
||||
@@ -629,20 +637,21 @@ c_pzasusb8.o: ../longbits.h
|
||||
c_pzasusb8.o: ../md5.h
|
||||
c_pzasusb8.o: ../nametype.h
|
||||
c_pzasusb8.o: ../qmath.h
|
||||
c_pzasusb8.o: ../shs.h
|
||||
c_pzasusb8.o: ../shs1.h
|
||||
c_pzasusb8.o: ../shs.h
|
||||
c_pzasusb8.o: ../string.h
|
||||
c_pzasusb8.o: ../value.h
|
||||
c_pzasusb8.o: ../win32dll.h
|
||||
c_pzasusb8.o: ../zmath.h
|
||||
c_pzasusb8.o: c_pzasusb8.c
|
||||
c_sysinfo.o: ../alloc.h
|
||||
c_sysinfo.o: ../block.h
|
||||
c_sysinfo.o: ../byteswap.h
|
||||
c_sysinfo.o: ../calc.h
|
||||
c_sysinfo.o: ../calcerr.h
|
||||
c_sysinfo.o: ../calc.h
|
||||
c_sysinfo.o: ../cmath.h
|
||||
c_sysinfo.o: ../conf.h
|
||||
c_sysinfo.o: ../config.h
|
||||
c_sysinfo.o: c_sysinfo.c
|
||||
c_sysinfo.o: ../custom.h
|
||||
c_sysinfo.o: ../endian_calc.h
|
||||
c_sysinfo.o: ../fposval.h
|
||||
@@ -660,14 +669,14 @@ c_sysinfo.o: ../md5.h
|
||||
c_sysinfo.o: ../nametype.h
|
||||
c_sysinfo.o: ../prime.h
|
||||
c_sysinfo.o: ../qmath.h
|
||||
c_sysinfo.o: ../shs.h
|
||||
c_sysinfo.o: ../shs1.h
|
||||
c_sysinfo.o: ../shs.h
|
||||
c_sysinfo.o: ../string.h
|
||||
c_sysinfo.o: ../value.h
|
||||
c_sysinfo.o: ../win32dll.h
|
||||
c_sysinfo.o: ../zmath.h
|
||||
c_sysinfo.o: ../zrand.h
|
||||
c_sysinfo.o: ../zrandom.h
|
||||
c_sysinfo.o: c_sysinfo.c
|
||||
custtbl.o: ../alloc.h
|
||||
custtbl.o: ../block.h
|
||||
custtbl.o: ../byteswap.h
|
||||
@@ -675,6 +684,7 @@ custtbl.o: ../calcerr.h
|
||||
custtbl.o: ../cmath.h
|
||||
custtbl.o: ../config.h
|
||||
custtbl.o: ../custom.h
|
||||
custtbl.o: custtbl.c
|
||||
custtbl.o: ../endian_calc.h
|
||||
custtbl.o: ../hash.h
|
||||
custtbl.o: ../have_const.h
|
||||
@@ -687,9 +697,9 @@ custtbl.o: ../longbits.h
|
||||
custtbl.o: ../md5.h
|
||||
custtbl.o: ../nametype.h
|
||||
custtbl.o: ../qmath.h
|
||||
custtbl.o: ../shs.h
|
||||
custtbl.o: ../shs1.h
|
||||
custtbl.o: ../shs.h
|
||||
custtbl.o: ../string.h
|
||||
custtbl.o: ../value.h
|
||||
custtbl.o: ../win32dll.h
|
||||
custtbl.o: ../zmath.h
|
||||
custtbl.o: custtbl.c
|
||||
|
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: c_sysinfo.c,v 29.3 2000/06/07 14:03:03 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: c_sysinfo.c,v 29.4 2000/07/17 15:37:12 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_sysinfo.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 23:14:40
|
||||
|
12
endian.c
12
endian.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: endian.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: endian.c,v 29.3 2001/03/18 02:59:42 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/endian.c,v $
|
||||
*
|
||||
* Under source code control: 1993/11/15 04:32:58
|
||||
@@ -48,8 +48,10 @@ char byte[8] = { (char)0x12, (char)0x36, (char)0x48, (char)0x59,
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#if !defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
|
||||
/* pointers into the byte order array */
|
||||
int *intp = (int *)byte;
|
||||
#endif
|
||||
#if defined(DEBUG)
|
||||
short *shortp = (short *)byte;
|
||||
long *longp = (long *)byte;
|
||||
@@ -69,6 +71,11 @@ main(void)
|
||||
printf("#define BIG_ENDIAN\t4321\n");
|
||||
printf("#define LITTLE_ENDIAN\t1234\n");
|
||||
|
||||
#if defined(LITTLE_ENDIAN)
|
||||
printf("#define CALC_BYTE_ORDER\tLITTLE_ENDIAN\n");
|
||||
#elif defined(BIG_ENDIAN)
|
||||
printf("#define CALC_BYTE_ORDER\tBIG_ENDIAN\n");
|
||||
#else
|
||||
/* Determine byte order */
|
||||
if (intp[0] == 0x12364859) {
|
||||
/* Most Significant Byte first */
|
||||
@@ -81,6 +88,7 @@ main(void)
|
||||
"Unknown int Byte Order, set CALC_BYTE_ORDER in Makefile\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
||||
|
23
file.c
23
file.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: file.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: file.c,v 29.6 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/file.c,v $
|
||||
*
|
||||
* Under source code control: 1991/07/20 00:21:56
|
||||
@@ -35,15 +35,23 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "have_unistd.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#include <ctype.h>
|
||||
#include "calc.h"
|
||||
#include "longbits.h"
|
||||
#include "have_fpos.h"
|
||||
#include "have_fpos_pos.h"
|
||||
#include "fposval.h"
|
||||
#include "file.h"
|
||||
#include "calcerr.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#define READSIZE 1024 /* buffer size for reading */
|
||||
|
||||
/*
|
||||
@@ -536,6 +544,7 @@ flushid(FILEID id)
|
||||
}
|
||||
|
||||
|
||||
#if !defined(_WIN32)
|
||||
int
|
||||
flushall(void)
|
||||
{
|
||||
@@ -551,6 +560,7 @@ flushall(void)
|
||||
}
|
||||
return err;
|
||||
}
|
||||
#endif /* Windoz free systems */
|
||||
|
||||
|
||||
/*
|
||||
@@ -1178,7 +1188,7 @@ filepos2z(FILEPOS pos)
|
||||
ret.len = FILEPOS_BITS/BASEB;
|
||||
ret.v = alloc(ret.len);
|
||||
zclearval(ret);
|
||||
SWAP_HALF_IN_FILEPOS(ret.v, &pos);
|
||||
SWAP_HALF_IN_FILEPOS(ret.v, (HALF *)&pos);
|
||||
ret.sign = 0;
|
||||
ztrim(&ret);
|
||||
|
||||
@@ -1239,7 +1249,8 @@ z2filepos(ZVALUE zpos)
|
||||
if (!zgtmaxfull(zpos)) {
|
||||
/* ztofull puts the value into native byte order */
|
||||
pos = ztofull(zpos);
|
||||
ret = pos;
|
||||
memset(&ret, 0, sizeof(FILEPOS));
|
||||
memcpy((void *)&ret, (void *)&pos, sizeof(pos));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1251,7 +1262,7 @@ z2filepos(ZVALUE zpos)
|
||||
memcpy(&tmp, zpos.v, sizeof(FILEPOS));
|
||||
} else {
|
||||
/* copy what bits we can into the temp value */
|
||||
tmp = 0;
|
||||
memset(&tmp, 0, sizeof(FILEPOS));
|
||||
memcpy(&tmp, zpos.v, zpos.len*BASEB/8);
|
||||
}
|
||||
/* swap into native byte order */
|
||||
|
35
fposval.c
35
fposval.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: fposval.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: fposval.c,v 29.6 2001/03/18 03:01:41 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/fposval.c,v $
|
||||
*
|
||||
* Under source code control: 1994/11/05 03:19:52
|
||||
@@ -63,6 +63,7 @@
|
||||
#include "endian_calc.h"
|
||||
#include "have_offscl.h"
|
||||
#include "have_posscl.h"
|
||||
#include "have_fpos_pos.h"
|
||||
|
||||
char *program; /* our name */
|
||||
|
||||
@@ -83,7 +84,15 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* print the file position information
|
||||
*/
|
||||
#if defined(HAVE_FPOS_POS)
|
||||
fileposlen = FPOS_POS_BITS;
|
||||
#else /* ! HAVE_FPOS_POS */
|
||||
# if defined(FPOS_BITS)
|
||||
fileposlen = FPOS_BITS;
|
||||
# else
|
||||
fileposlen = sizeof(FILEPOS)*8;
|
||||
# endif
|
||||
#endif /* ! HAVE_FPOS_POS */
|
||||
printf("#undef FILEPOS_BITS\n");
|
||||
printf("#define FILEPOS_BITS %d\n", fileposlen);
|
||||
#if CALC_BYTE_ORDER == BIG_ENDIAN
|
||||
@@ -113,8 +122,8 @@ main(int argc, char **argv)
|
||||
* Normally a "(*(dest) = *(src))" would do, but on some
|
||||
* systems a FILEPOS is not a scalar hince we must memcpy.
|
||||
*/
|
||||
printf("#define SWAP_HALF_IN_FILEPOS(dest, src)\t%s%d%s\n",
|
||||
"memcpy((void *)(dest), (void *)(src), sizeof(",fileposlen,"))");
|
||||
printf("#define SWAP_HALF_IN_FILEPOS(dest, src)\t%s\n",
|
||||
"memcpy((void *)(dest), (void *)(src), sizeof(FPOS_POS_BITS))");
|
||||
#endif /* HAVE_FILEPOS_SCALAR */
|
||||
#endif /* CALC_BYTE_ORDER == BIG_ENDIAN */
|
||||
putchar('\n');
|
||||
@@ -122,7 +131,11 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* print the stat file size information
|
||||
*/
|
||||
#if defined(OFF_T_BITS)
|
||||
stsizelen = OFF_T_BITS;
|
||||
#else
|
||||
stsizelen = sizeof(buf.st_size)*8;
|
||||
#endif
|
||||
printf("#undef OFF_T_BITS\n");
|
||||
printf("#define OFF_T_BITS %d\n", stsizelen);
|
||||
#if CALC_BYTE_ORDER == BIG_ENDIAN
|
||||
@@ -156,7 +169,7 @@ main(int argc, char **argv)
|
||||
* systems, a off_t is not a scalar hince we must memcpy.
|
||||
*/
|
||||
printf("#define SWAP_HALF_IN_OFF_T(dest, src)\t%s%d%s\n",
|
||||
"memcpy((void *)(dest), (void *)(src), sizeof(",stsizelen,"))");
|
||||
"memcpy((void *)(dest), (void *)(src), ", stsizelen/8, ")");
|
||||
#endif /* HAVE_OFF_T_SCALAR */
|
||||
#endif /* CALC_BYTE_ORDER == BIG_ENDIAN */
|
||||
putchar('\n');
|
||||
@@ -164,7 +177,11 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* print the dev_t size
|
||||
*/
|
||||
#if defined(DEV_BITS)
|
||||
devlen = DEV_BITS;
|
||||
#else
|
||||
devlen = sizeof(buf.st_dev)*8;
|
||||
#endif
|
||||
printf("#undef DEV_BITS\n");
|
||||
printf("#define DEV_BITS %d\n", devlen);
|
||||
#if CALC_BYTE_ORDER == BIG_ENDIAN
|
||||
@@ -193,14 +210,18 @@ main(int argc, char **argv)
|
||||
* systems, a DEV is not a scalar hince we must memcpy.
|
||||
*/
|
||||
printf("#define SWAP_HALF_IN_DEV(dest, src)\t%s%d%s\n",
|
||||
"memcpy((void *)(dest), (void *)(src), sizeof(",devlen,"))");
|
||||
"memcpy((void *)(dest), (void *)(src), ", devlen/8, ")");
|
||||
#endif /* CALC_BYTE_ORDER == BIG_ENDIAN */
|
||||
putchar('\n');
|
||||
|
||||
/*
|
||||
* print the ino_t size
|
||||
*/
|
||||
#if defined(INODE_BITS)
|
||||
inodelen = INODE_BITS;
|
||||
#else
|
||||
inodelen = sizeof(buf.st_ino)*8;
|
||||
#endif
|
||||
printf("#undef INODE_BITS\n");
|
||||
printf("#define INODE_BITS %d\n", inodelen);
|
||||
#if CALC_BYTE_ORDER == BIG_ENDIAN
|
||||
@@ -229,7 +250,7 @@ main(int argc, char **argv)
|
||||
* systems, a INODE is not a scalar hince we must memcpy.
|
||||
*/
|
||||
printf("#define SWAP_HALF_IN_INODE(dest, src)\t%s%d%s\n",
|
||||
"memcpy((void *)(dest), (void *)(src), sizeof(",inodelen,"))");
|
||||
"memcpy((void *)(dest), (void *)(src), ", inodelen/8, ")");
|
||||
#endif /* CALC_BYTE_ORDER == BIG_ENDIAN */
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
|
28
func.c
28
func.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: func.c,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: func.c,v 29.7 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/func.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:15
|
||||
@@ -35,6 +35,11 @@
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <io.h>
|
||||
# define _access access
|
||||
#endif
|
||||
|
||||
#if defined(FUNCLIST)
|
||||
|
||||
#define CONST /* disabled for FUNCLIST in case NATIVE_CC doesn't have it */
|
||||
@@ -162,7 +167,7 @@ static STRINGHEAD newerrorstr;
|
||||
/*
|
||||
* arg count definitions
|
||||
*/
|
||||
#define IN 100 /* maximum number of arguments */
|
||||
#define IN 1024 /* maximum number of arguments */
|
||||
#define FE 0x01 /* flag to indicate default epsilon argument */
|
||||
#define FA 0x02 /* preserve addresses of variables */
|
||||
|
||||
@@ -4922,10 +4927,14 @@ f_listremove(VALUE *vp)
|
||||
static NUMBER *
|
||||
f_runtime(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return qlink(&_qzero_);
|
||||
#else /* Windoz free systems */
|
||||
struct tms buf;
|
||||
|
||||
times(&buf);
|
||||
return iitoq((long) buf.tms_utime, (long) CLK_TCK);
|
||||
#endif /* Windoz free systems */
|
||||
}
|
||||
|
||||
|
||||
@@ -6885,7 +6894,16 @@ f_system(VALUE *vp)
|
||||
if (conf->calc_debug & CALCDBG_SYSTEM) {
|
||||
printf("%s\n", vp->v_str->s_str);
|
||||
}
|
||||
result.v_num = itoq((long) system(vp->v_str->s_str));
|
||||
#if defined(_WIN32)
|
||||
/* if the execute length is 0 then use NULL in system call */
|
||||
if (strlen(vp->v_str->s_str) == 0) {
|
||||
result.v_num = itoq((long)system(NULL));
|
||||
} else {
|
||||
result.v_num = itoq((long)system(vp->v_str->s_str));
|
||||
}
|
||||
#else /* Windoz free systems */
|
||||
result.v_num = itoq((long)system(vp->v_str->s_str));
|
||||
#endif /* Windoz free systems */
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -6898,6 +6916,7 @@ f_sleep(int count, VALUE **vals)
|
||||
NUMBER *q1, *q2;
|
||||
|
||||
res.v_type = V_NULL;
|
||||
#if !defined(_WIN32)
|
||||
if (count > 0) {
|
||||
if (vals[0]->v_type != V_NUM || qisneg(vals[0]->v_num))
|
||||
return error_value(E_SLEEP);
|
||||
@@ -6928,6 +6947,7 @@ f_sleep(int count, VALUE **vals)
|
||||
res.v_type = V_NUM;
|
||||
res.v_num = itoq(time);
|
||||
}
|
||||
#endif /* Windoz free systems */
|
||||
return res;
|
||||
}
|
||||
|
||||
|
68
have_fpos_pos.c
Normal file
68
have_fpos_pos.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* have_fpos_pos - Determine if a __pos element in FILEPOS
|
||||
*
|
||||
* Copyright (C) 2000 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: have_fpos_pos.c,v 29.2 2001/03/18 03:00:11 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/have_fpos_pos.c,v $
|
||||
*
|
||||
* Under source code control: 2000/12/17 01:23
|
||||
* File existed as early as: 2000
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* If the symbol HAVE_NO_FPOS is defined, we will output nothing.
|
||||
* If the HAVE_FILEPOS_SCALAR is defuned, we will output nothing.
|
||||
* If we are able to compile this program, then we must have the
|
||||
* __pos element in a non-scalar FILEPOS.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "have_fpos.h"
|
||||
#include "have_posscl.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#if !defined(HAVE_NO_FPOS) && !defined(HAVE_FILEPOS_SCALAR)
|
||||
fpos_t pos; /* file position */
|
||||
|
||||
/* print a __pos element in fpos_t */
|
||||
printf("#undef HAVE_FPOS_POS\n");
|
||||
printf("#define HAVE_FPOS_POS 1 /* yes */\n\n");
|
||||
|
||||
/* determine __pos element size */
|
||||
printf("#undef FPOS_POS_BITS\t/* no */\n");
|
||||
# if defined(FPOS_POS_BITS)
|
||||
printf("#define FPOS_POS_BITS %d\n\n", FPOS_POS_BITS);
|
||||
# else
|
||||
printf("#define FPOS_POS_BITS %d\n\n", sizeof(pos.__pos)*8);
|
||||
# endif
|
||||
|
||||
#else
|
||||
/* we have no __pos element */
|
||||
printf("#undef HAVE_FPOS_POS\t/* no */\n");
|
||||
printf("#undef FPOS_POS_BITS\n");
|
||||
#endif
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
15
help.c
15
help.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: help.c,v 29.4 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: help.c,v 29.6 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/help.c,v $
|
||||
*
|
||||
* Under source code control: 1997/09/14 10:58:30
|
||||
@@ -42,6 +42,11 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define popen _popen
|
||||
# define pclose _pclose
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* some help topics are symbols, so we alias them to nice filenames
|
||||
@@ -105,7 +110,11 @@ page_file(FILE *stream)
|
||||
/*
|
||||
* form a write pipe to a pager
|
||||
*/
|
||||
cmd = popen(pager, "w");
|
||||
if (pager == NULL || pager[0] == '\0') {
|
||||
cmd = stdout;
|
||||
} else {
|
||||
cmd = popen(pager, "w");
|
||||
}
|
||||
if (cmd == NULL) {
|
||||
fprintf(stderr, "unable form pipe to pager: %s", pager);
|
||||
return;
|
||||
|
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: Makefile,v 29.3 2000/06/07 14:02:33 chongo Exp chongo $
|
||||
# @(#) $Revision: 29.5 $
|
||||
# @(#) $Id: Makefile,v 29.5 2000/12/14 10:33:06 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1991/07/23 06:47:57
|
||||
@@ -140,31 +140,31 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
|
||||
# This list is prodiced by the detaillist rule when no WARNINGS are detected.
|
||||
#
|
||||
DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd append \
|
||||
appr arg argv arrow asec asech asin asinh assign atan atan2 atanh \
|
||||
avg base bernoulli bit blk blkcpy blkfree blocks bround btrunc \
|
||||
calclevel ceil cfappr cfsim char cmdbuf cmp comb conj cos cosh \
|
||||
cot coth count cp csc csch ctime delete den dereference det digit \
|
||||
digits dp epsilon errcount errmax errno error eval exp fact factor \
|
||||
fclose fcnt feof ferror fflush fgetc fgetfield fgetline fgets fgetstr \
|
||||
fib files floor fopen forall fprintf fputc fputs fputstr frac free \
|
||||
freebernoulli freeglobals freeredc freestatics frem freopen fscan \
|
||||
fscanf fseek fsize ftell gcd gcdrem gd getenv hash head highbit \
|
||||
hmean hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert \
|
||||
int inverse iroot isassoc isatty isblk isconfig isdefined iserror \
|
||||
iseven isfile ishash isident isint islist ismat ismult isnull isnum \
|
||||
isobj isobjtype isodd isprime isptr isqrt isrand israndom isreal \
|
||||
isrel issimple issq isstr istype jacobi join lcm lcmfact lfactor ln \
|
||||
lowbit ltol makelist matdim matfill matmax matmin matsum mattrace \
|
||||
mattrans max md5 memsize meq min minv mmin mne mod modify name \
|
||||
near newerror nextcand nextprime norm null num oldvalue ord param \
|
||||
perm pfact pi pix places pmod polar poly pop popcnt power prevcand \
|
||||
prevprime printf prompt protect ptest push putenv quo quomod rand \
|
||||
randbit random randombit randperm rcin rcmul rcout rcpow rcsq re \
|
||||
remove reverse rewind rm root round rsearch runtime saveval scale \
|
||||
scan scanf search sec sech seed segment select sgn sha sha1 sin \
|
||||
sinh size sizeof sort sqrt srand srandom ssq str strcat strerror \
|
||||
strlen strpos strprintf strscan strscanf substr sum swap system \
|
||||
tail tan tanh test time trunc xor
|
||||
appr arg argv arrow asec asech asin asinh assign atan atan2 atanh avg \
|
||||
base bernoulli bit blk blkcpy blkfree blocks bround btrunc calc_tty \
|
||||
calclevel catalan ceil cfappr cfsim char cmdbuf cmp comb conj cos \
|
||||
cosh cot coth count cp csc csch ctime delete den dereference det \
|
||||
digit digits dp epsilon errcount errmax errno error euler eval \
|
||||
exp fact factor fclose fcnt feof ferror fflush fgetc fgetfield \
|
||||
fgetline fgets fgetstr fib files floor fopen forall fprintf fputc \
|
||||
fputs fputstr frac free freebernoulli freeeuler freeglobals freeredc \
|
||||
freestatics frem freopen fscan fscanf fseek fsize ftell gcd gcdrem \
|
||||
gd getenv hash head highbit hmean hnrmod hypot ilog ilog10 ilog2 \
|
||||
im indices inputlevel insert int inverse iroot isassoc isatty isblk \
|
||||
isconfig isdefined iserror iseven isfile ishash isident isint islist \
|
||||
ismat ismult isnull isnum isobj isobjtype isodd isprime isptr isqrt \
|
||||
isrand israndom isreal isrel issimple issq isstr istype jacobi join \
|
||||
lcm lcmfact lfactor ln lowbit ltol makelist matdim matfill matmax \
|
||||
matmin matsum mattrace mattrans max md5 memsize meq min minv mmin \
|
||||
mne mod modify name near newerror nextcand nextprime norm null \
|
||||
num oldvalue ord param perm pfact pi pix places pmod polar poly \
|
||||
pop popcnt power prevcand prevprime printf prompt protect ptest \
|
||||
push putenv quo quomod rand randbit random randombit randperm rcin \
|
||||
rcmul rcout rcpow rcsq re remove reverse rewind rm root round rsearch \
|
||||
runtime saveval scale scan scanf search sec sech seed segment select \
|
||||
sgn sha sha1 sin sinh size sizeof sleep sort sqrt srand srandom \
|
||||
ssq str strcat strerror strlen strpos strprintf strscan strscanf \
|
||||
substr sum swap system tail tan tanh test time trunc xor
|
||||
|
||||
# This list is of files that are clones of DETAIL_HELP files. They are
|
||||
# built from DETAIL_HELP files.
|
||||
|
@@ -35,11 +35,11 @@ EXAMPLE
|
||||
LIMITS
|
||||
n < 2^31-1
|
||||
|
||||
LINK LIBRARY
|
||||
LIBRARY
|
||||
NUMBER *qbernoulli(long n)
|
||||
|
||||
SEE ALSO
|
||||
euler, freebernoulli, catalan, comb, fact, perm
|
||||
euler, catalan, comb, fact, perm
|
||||
|
||||
## Copyright (C) 2000 Ernest Bowen
|
||||
##
|
||||
@@ -57,11 +57,11 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: sin,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sin,v $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: bernoulli,v 29.4 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/bernoulli,v $
|
||||
##
|
||||
## Under source code control: 2000/07/13
|
||||
## Under source code control: 2000/07/13 01:33:00
|
||||
## File existed as early as: 2000
|
||||
##
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
52
help/calc_tty
Normal file
52
help/calc_tty
Normal file
@@ -0,0 +1,52 @@
|
||||
NAME
|
||||
calc_tty - restore normal input conditions for interactive use
|
||||
|
||||
SYNOPSIS
|
||||
calc_tty()
|
||||
|
||||
TYPES
|
||||
return none if appears to be successful, error-value otherwise
|
||||
|
||||
DESCRIPTION
|
||||
This may enable a return to normal operation if abnormal activity
|
||||
results from a change of one or more terminal characteristics, as
|
||||
may occur when activity is resumed by an fg command after a ctrl-Z
|
||||
interrupt, or by any of the three commands:
|
||||
|
||||
> !stty echo
|
||||
> !stty -cbreak
|
||||
> !stty echo -cbreak
|
||||
|
||||
EXAMPLE
|
||||
> calc_tty();
|
||||
|
||||
LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
none
|
||||
|
||||
## 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.1 $
|
||||
## @(#) $Id: calc_tty,v 29.1 2000/12/14 10:31:45 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/calc_tty,v $
|
||||
##
|
||||
## Under source code control: 2000/12/14 01:33:00
|
||||
## File existed as early as: 2000
|
||||
##
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
63
help/catalan
Normal file
63
help/catalan
Normal file
@@ -0,0 +1,63 @@
|
||||
NAME
|
||||
catalan - Catalan number
|
||||
|
||||
SYNOPSIS
|
||||
catalan(n)
|
||||
|
||||
TYPES
|
||||
n integer
|
||||
|
||||
return integer
|
||||
|
||||
DESCRIPTION
|
||||
If n >= 0, this returns the Catalan number for index n:
|
||||
|
||||
catalan(n) = comb(2*n,n)/(n + 1)
|
||||
|
||||
Zero is returned for negative n.
|
||||
|
||||
The Catalan numbers occur in solutions of several elementary
|
||||
combinatorial problems, e.g. for n >= 1, catalan(n) is the number of
|
||||
ways of using parentheses to express a product of n + 1 letters in
|
||||
terms of binary products; it is the number of ways of dissecting a
|
||||
convex polygon with n + 2 sides into triangles by nonintersecting
|
||||
diagonals; it is the number of integer-component-incrementing paths
|
||||
from (x,y) = (0,0) to (x,y) = (n,n) for which always y <= x.
|
||||
|
||||
EXAMPLE
|
||||
> print catalan(2), catalan(3), catalan(4), catalan(20)
|
||||
2 5 14 6564120420
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qcatalan(NUMBER *n)
|
||||
|
||||
SEE ALSO
|
||||
comb, fact, perm
|
||||
|
||||
## 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.2 $
|
||||
## @(#) $Id: catalan,v 29.2 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/catalan,v $
|
||||
##
|
||||
## Under source code control: 2000/12/14 01:33:00
|
||||
## File existed as early as: 2000
|
||||
##
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
@@ -207,9 +207,9 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: sin,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sin,v $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: define,v 29.3 2000/07/17 15:36:26 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/define,v $
|
||||
##
|
||||
##
|
||||
## Under source code control: 1991/07/21 04:37:18
|
||||
|
91
help/digit
91
help/digit
@@ -1,38 +1,93 @@
|
||||
NAME
|
||||
digit - digit at specified position in a decimal representation
|
||||
digit - digit at specified position in a "decimal" representation
|
||||
|
||||
SYNOPSIS
|
||||
digit(x, y)
|
||||
digit(x, n [, b])
|
||||
|
||||
TYPES
|
||||
x real
|
||||
y integer
|
||||
n integer
|
||||
b integer >= 2, default = 10
|
||||
|
||||
return integer
|
||||
|
||||
DESCRIPTION
|
||||
By extending the digits on the left, and if necessary, the digits
|
||||
on the right, by infinite strings of zeros, abs(x) may be considered
|
||||
to have the decimal representation:
|
||||
|
||||
... d_2 d_1 d_0.d_-1 d_-2 ...
|
||||
d(x,n,b) returns the digit with index n in a standard base-b "decimal"
|
||||
representation of x, which may be described as follows:
|
||||
|
||||
For an arbitrary base b >= 2, following the pattern of decimal (base 10)
|
||||
notation in elementary arithmetic, a base-b "decimal" representation of
|
||||
a positive real number may be considered to be specified by a finite or
|
||||
infinite sequence of "digits" with possibly a "decimal" point
|
||||
to indicate where the fractional part of the representation begins.
|
||||
Just as the digits for base 10 are the integers 0, 1, 2, ..., 9, the
|
||||
digits for a base-b representation are the integers d for which
|
||||
0 <= d < b. The index for a digit position is the count, positively to
|
||||
the left, of the number from the "units" position immediately to the
|
||||
left of the "decimal" point; the digit d_n at position n contributes
|
||||
additively d_n * b^n to the value of x. For example,
|
||||
|
||||
d_2 d_1 d_0 . d_-1 d_-2
|
||||
|
||||
represents the number
|
||||
|
||||
d_2 * b^2 + d_1 * b + d0 + d_-1 * b^-1 + d_-2 * b^-2
|
||||
|
||||
The sequence of digits has to be infinite if den(x) has a prime factor
|
||||
which is not a factor of the base b. In cases where the representation
|
||||
may terminate, the digits are considered to continue with an infinite
|
||||
string of zeros rather than the other possibility of an infinite
|
||||
sequence of (b - 1)s. Thus, for the above example, d_n = 0 for
|
||||
n = -3, -4, ... Similarly, a representation may be considered to
|
||||
continue with an infinite string of zeros on the left, so that in the
|
||||
above example d_n = 0 also for n >= 3.
|
||||
|
||||
For negative x, digit(x,n,b) is given by digit(abs(x),n,b); the
|
||||
standard "decimal" representation of this x is a - sign followed by
|
||||
the representation of abs(x).
|
||||
|
||||
In calc, the "real" numbers are all rational and for these the
|
||||
digits following the decimal point eventually form a recurring sequence.
|
||||
|
||||
With base-b digits for x as explained above, the integer whose base-b
|
||||
representation is
|
||||
|
||||
b_n+k-1 b_n_k-2 ... b_n,
|
||||
|
||||
i.e. the k digits with last digit b_n, is given by
|
||||
|
||||
digit(b^-r * x, q, b^k)
|
||||
|
||||
if r and q satisfy n = q * b + r.
|
||||
|
||||
digit(x,y) then returns the digit d_y.
|
||||
|
||||
EXAMPLE
|
||||
> x = 12.34
|
||||
> print digit(x,2), digit(x,1), digit(x,0), digit(x,-1), digit(x,-2)
|
||||
0 1 2 3 4
|
||||
> a = 123456.789
|
||||
> for (n = 6; n >= -6; n++) print digit(a, n),; print
|
||||
0 1 2 3 4 5 6 7 8 9 0 0 0
|
||||
|
||||
> x = 10/7
|
||||
> print digit(x,1), digit(x,0), digit(x,-1), digit(x,-2), digit(x,-3)
|
||||
0 1 4 2 8
|
||||
> for (n = 6; n >= -6; n--) print digit(a, n, 100),; print
|
||||
0 0 0 0 12 34 56 78 90 0 0 0 0
|
||||
|
||||
> for (n = 6; n >= -6; n--) print digit(a, n, 256),; print
|
||||
0 0 0 0 1 226 64 201 251 231 108 139 67
|
||||
|
||||
> for (n = 1; n >= -12; n++) print digit(10/7, n),; print
|
||||
> 0 1 4 2 8 5 7 1 4 2 8 5 7 1
|
||||
|
||||
> print digit(10/7, -7e1000, 1e6)
|
||||
428571
|
||||
|
||||
LIMITS
|
||||
If x is not an integer, y > -2^31
|
||||
|
||||
The absolute value of the integral part of x is assumed to be less
|
||||
than 2^2^31, ensuring that digit(x, n, b) will be zero if n >= 2^31.
|
||||
The size of negative n is limited only by the capacity of the computer
|
||||
being used.
|
||||
|
||||
LINK LIBRARY
|
||||
long qdigit(NUMBER *x, long y)
|
||||
NUMBER * qdigit(NUMBER *q, ZVALUE dpos, ZVALUE base)
|
||||
|
||||
SEE ALSO
|
||||
bit
|
||||
@@ -53,8 +108,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: digit,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: digit,v 29.4 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/digit,v $
|
||||
##
|
||||
## Under source code control: 1995/10/03 10:40:01
|
||||
|
24
help/digits
24
help/digits
@@ -1,30 +1,36 @@
|
||||
NAME
|
||||
digits - return number of digits in an integer or integer part
|
||||
digits - return number of "decimal" digits in an integral part
|
||||
|
||||
SYNOPSIS
|
||||
digits(x)
|
||||
digits(x [,b])
|
||||
|
||||
TYPES
|
||||
x real
|
||||
b integer >= 2, defaults to 10
|
||||
|
||||
return integer
|
||||
|
||||
DESCRIPTION
|
||||
For real x, digits(x) returns the number of digits in the decimal
|
||||
representation of int(abs(x)). If x >= 1, digits(x) = 1 + ilog10(x).
|
||||
Returns the least non-negative integer n for which abs(x) < b^n.
|
||||
|
||||
digits(x, b) = 0 if and only if abs(x) < 1.
|
||||
|
||||
For real x with absolute value >= 1, digits(x, b) is the number
|
||||
of digits in the standard base-b "decimal" representation of int(abs(x));
|
||||
this is also given by 1 + ilog(x, b).
|
||||
|
||||
EXAMPLE
|
||||
> print digits(0), digits(0.0123), digits(3.7), digits(-27), digits(-99.7)
|
||||
1 1 1 2 2
|
||||
0 0 1 2 2
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
long qdigits(NUMBER *x)
|
||||
long qdigits(NUMBER *q, ZVALUE base)
|
||||
|
||||
SEE ALSO
|
||||
places
|
||||
digit, places
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
##
|
||||
@@ -42,8 +48,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: digits,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: digits,v 29.3 2000/12/14 10:32:24 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/digits,v $
|
||||
##
|
||||
## Under source code control: 1995/10/03 10:40:01
|
||||
|
63
help/euler
Normal file
63
help/euler
Normal file
@@ -0,0 +1,63 @@
|
||||
NAME
|
||||
euler - Euler number
|
||||
|
||||
SYNOPSIS
|
||||
euler(n)
|
||||
|
||||
TYPES
|
||||
n integer, n <= 1000000 if even
|
||||
|
||||
return integer
|
||||
|
||||
DESCRIPTION
|
||||
Returns the Euler number with index n, i.e. the coefficient E_n in
|
||||
the expansion
|
||||
|
||||
sech(t) = Sigma E_n * t^n/n!
|
||||
|
||||
When euler(n) is computed for positive even n, the values for
|
||||
n and smaller positive even indices are stored in a table so that
|
||||
a later call to euler(k) with 0 <= k <= n will be executed quickly.
|
||||
If euler(k) is called with negative k, zero is returned and the
|
||||
memory used by the table iu freed.
|
||||
|
||||
Considerable runtime and memery are required for calculating
|
||||
euler(n) for large even n.
|
||||
|
||||
EXAMPLE
|
||||
> for (n = 0; n <= 6; n++) print euler(n),; print;
|
||||
1 0 -1 0 5 0 -61
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qeuler(long n)
|
||||
|
||||
SEE ALSO
|
||||
bernoulli, bell, catalan, comb, fact, perm
|
||||
|
||||
## 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.2 $
|
||||
## @(#) $Id: euler,v 29.2 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/euler,v $
|
||||
##
|
||||
## Under source code control: 2000/12/14 01:33:00
|
||||
## File existed as early as: 2000
|
||||
##
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
@@ -40,8 +40,8 @@ SEE ALSO
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: sin,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sin,v $
|
||||
## @(#) $Id: freebernoulli,v 29.2 2000/07/17 15:36:26 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/freebernoulli,v $
|
||||
##
|
||||
## Under source code control: 2000/07/13
|
||||
## File existed as early as: 2000
|
||||
|
49
help/freeeuler
Normal file
49
help/freeeuler
Normal file
@@ -0,0 +1,49 @@
|
||||
NAME
|
||||
freeeuler - free stored Euler numbers
|
||||
|
||||
SYNOPSIS
|
||||
freeeuler()
|
||||
|
||||
TYPES
|
||||
return none
|
||||
|
||||
DESCRIPTION
|
||||
The memory used to store calculated Euler numbers is freed by
|
||||
freeeuler().
|
||||
|
||||
EXAMPLE
|
||||
> freeeuler();
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
void qfreeeuler(void);
|
||||
|
||||
SEE ALSO
|
||||
euler, bernoulli, freebernoulli
|
||||
|
||||
## 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.1 $
|
||||
## @(#) $Id: freeeuler,v 29.1 2000/12/14 10:31:45 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/freeeuler,v $
|
||||
##
|
||||
## Under source code control: 2000/12/14 01:33:00
|
||||
## File existed as early as: 2000
|
||||
##
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
@@ -36,7 +36,7 @@ ABORT opcodes
|
||||
various places in the opcodes for evaluation of command lines
|
||||
and functions defined by "define ... { ... }" commands. In the
|
||||
following, config("trace") has been set equal to 8 so that opcodes
|
||||
are displayed when a function is defined. The function f(x)
|
||||
are displayed when a function is defined. The function f(x)
|
||||
evaluates x + (x - 1) + (x - 2) + ... until a zero term is
|
||||
encountered. If f() is called with a negative or fractional x,
|
||||
the calculation is never completed and to stop it, an interruption
|
||||
@@ -64,7 +64,7 @@ ABORT opcodes
|
||||
(The line number following DEBUG refers to the line in the file
|
||||
from which the definition is read.) If an attempt is made to
|
||||
evaluate f(-1), the effect of the DEBUG at opcode 6 ensures that
|
||||
a single SIGINT will stop the calculation at a start of
|
||||
a single SIGINT will stop the calculation at a start of
|
||||
{s += x--} loop. In interactive mode, with ^C indicating
|
||||
input of ctrl-C, the displayed output is as in:
|
||||
|
||||
@@ -115,8 +115,8 @@ ABORT opcodes
|
||||
## 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: interrupt,v 29.2 2000/06/07 14:02:33 chongo Exp chongo $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: interrupt,v 29.4 2000/07/17 15:38:52 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/interrupt,v $
|
||||
##
|
||||
## Under source code control: 1991/07/21 04:37:21
|
||||
|
29
help/places
29
help/places
@@ -1,34 +1,41 @@
|
||||
NAME
|
||||
places - return number of decimal places
|
||||
places - return number of "decimal" places in a fractional part
|
||||
|
||||
SYNOPSIS
|
||||
places(x)
|
||||
places(x [,b])
|
||||
|
||||
TYPES
|
||||
x real
|
||||
b integer >= 2, defaults to 10
|
||||
|
||||
return integer
|
||||
|
||||
DESCRIPTION
|
||||
If x has a finite decimal representation (with nonzero last digit),
|
||||
places(x) returns the number of digits after the decimal point in this
|
||||
representation; this is the least non-negative integer n for which
|
||||
10^n * x is an integer.
|
||||
Returns the least non-negative integer n for which b^n * x is an
|
||||
integer, or -1 if there is no such integer.
|
||||
|
||||
If x does not have a finite decimal representation, places(x) returns -1.
|
||||
places(x,b) = 0 if and only if x is an integer.
|
||||
|
||||
places(x,b) = n > 0 if and only if the fractional part of abs(x)
|
||||
has a finite base-b "decimal" representation with n digits of which
|
||||
the last digit is nonzero. This occurs if and only if every prime
|
||||
factor of den(x) is a factor of b.
|
||||
|
||||
EXAMPLE
|
||||
> print places(3), places(0.0123), places(3.70), places(1e-10), places(3/7)
|
||||
0 4 1 10 -1
|
||||
|
||||
> print places(0.0123, 2), places(.625, 2), places(.625, 8)
|
||||
-1 3 1
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
long qplaces(NUMBER *x)
|
||||
long qplaces(NUMBER *q, ZVALUE base)
|
||||
|
||||
SEE ALSO
|
||||
digits
|
||||
digit, digits
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
##
|
||||
@@ -46,8 +53,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: places,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: places,v 29.4 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/places,v $
|
||||
##
|
||||
## Under source code control: 1995/10/03 10:40:02
|
||||
|
@@ -283,8 +283,8 @@ For more information use the following calc commands:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: script,v 29.3 2000/06/07 14:02:33 chongo Exp chongo $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: script,v 29.4 2000/07/17 15:36:26 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/script,v $
|
||||
##
|
||||
## Under source code control: 1999/11/30 05:29:48
|
||||
|
68
help/sleep
Normal file
68
help/sleep
Normal file
@@ -0,0 +1,68 @@
|
||||
NAME
|
||||
sleep - suspend operation for a specified time
|
||||
|
||||
SYNOPSIS
|
||||
sleep([n])
|
||||
|
||||
TYPES
|
||||
n non-negative real, defaults to 1
|
||||
|
||||
return integer or null value
|
||||
|
||||
DESCRIPTION
|
||||
This uses the C-library sleep (if n is integral) or usleep (for
|
||||
non-integral n) to suspend operation for n seconds. If n is an
|
||||
integer and the sleep is stopped by an interruption, the number
|
||||
of seconds remaining is returned.
|
||||
|
||||
One kind of use is to slow down output to permit easier reading of
|
||||
results, as in:
|
||||
|
||||
> for (i = 0; i < 100; i++) {
|
||||
print sqrt(i);
|
||||
sleep(1/2);
|
||||
}
|
||||
|
||||
The following illustrates what happens if ctrl-C is hit 5 seconds
|
||||
after the first command:
|
||||
|
||||
> print sleep(20)
|
||||
|
||||
[Abort level 1]
|
||||
15
|
||||
>
|
||||
|
||||
EXAMPLE
|
||||
> sleep(1/3);
|
||||
> sleep(20);
|
||||
|
||||
LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
none
|
||||
|
||||
## 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.2 $
|
||||
## @(#) $Id: sleep,v 29.2 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sleep,v $
|
||||
##
|
||||
## Under source code control: 2000/12/14 01:33:00
|
||||
## File existed as early as: 2000
|
||||
##
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
8
hist.c
8
hist.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: hist.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: hist.c,v 29.3 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/hist.c,v $
|
||||
*
|
||||
* Under source code control: 1993/05/02 20:09:19
|
||||
@@ -40,7 +40,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <pwd.h>
|
||||
#if !defined(_WIN32)
|
||||
# include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include "have_unistd.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
|
12
hist.h
12
hist.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: hist.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: hist.h,v 29.3 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/hist.h,v $
|
||||
*
|
||||
* Under source code control: 1993/05/02 20:09:20
|
||||
@@ -64,10 +64,10 @@
|
||||
#define HIST_NOTTY 3 /* terminal modes could not be set */
|
||||
|
||||
|
||||
extern int hist_init(char *filename);
|
||||
extern void hist_term(void);
|
||||
extern int hist_getline(char *prompt, char *buf, int len);
|
||||
extern void hist_saveline(char *line, int len);
|
||||
extern DLL int hist_init(char *filename);
|
||||
extern DLL void hist_term(void);
|
||||
extern DLL int hist_getline(char *prompt, char *buf, int len);
|
||||
extern DLL void hist_saveline(char *line, int len);
|
||||
|
||||
|
||||
#endif /* !__HIST_H__ */
|
||||
|
47
input.c
47
input.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: input.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: input.c,v 29.5 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/input.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:16
|
||||
@@ -35,7 +35,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <pwd.h>
|
||||
#if !defined(_WIN32)
|
||||
# include <pwd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -257,6 +259,12 @@ opensearchfile(char *name, char *pathlist, char *extension, int rd_once)
|
||||
static char *
|
||||
homeexpand(char *name)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
|
||||
return NULL;
|
||||
|
||||
#else /* Windoz free systems */
|
||||
|
||||
struct passwd *ent; /* password entry */
|
||||
char *home2; /* fullpath of the home directory */
|
||||
char *fullpath; /* the malloced expanded path */
|
||||
@@ -323,6 +331,7 @@ homeexpand(char *name)
|
||||
}
|
||||
sprintf(fullpath, "%s%s", home2, after);
|
||||
return fullpath;
|
||||
#endif /* Windoz free systems */
|
||||
}
|
||||
|
||||
|
||||
@@ -795,6 +804,15 @@ runrcfiles(void)
|
||||
* This function returns the index of the readset element that matches
|
||||
* a given device/inode, -1 otherwise.
|
||||
*
|
||||
*
|
||||
* WIN32 NOTE:
|
||||
*
|
||||
* This function does not work under WIN32. The sbuf->st_ino is always
|
||||
* zero because the FAT and NTFS filesystems do not support inodes.
|
||||
* They also don't support links, which is why you need this function
|
||||
* under UNIX. For WIN32, use _fullpath() to determine if you have
|
||||
* already opened a file.
|
||||
*
|
||||
* given:
|
||||
* sbuf stat of the inode in question
|
||||
*/
|
||||
@@ -802,6 +820,9 @@ static int
|
||||
isinoderead(struct stat *sbuf)
|
||||
{
|
||||
int i;
|
||||
#if defined(_WIN32)
|
||||
char fullpathname[_MAX_PATH];
|
||||
#endif
|
||||
|
||||
/* deal with the empty case */
|
||||
if (readset == NULL || maxreadset <= 0) {
|
||||
@@ -811,12 +832,22 @@ isinoderead(struct stat *sbuf)
|
||||
|
||||
/* scan the entire readset */
|
||||
for (i=0; i < maxreadset; ++i) {
|
||||
#if defined(_WIN32)
|
||||
if (readset[i].active &&
|
||||
strcmp(readset[i].path,
|
||||
_fullpath(fullpathname,cip->i_name,
|
||||
_MAX_PATH)) == 0) {
|
||||
/* found a match */
|
||||
return i;
|
||||
}
|
||||
#else /* Windoz free systems */
|
||||
if (readset[i].active &&
|
||||
sbuf->st_dev == readset[i].inode.st_dev &&
|
||||
sbuf->st_ino == readset[i].inode.st_ino) {
|
||||
/* found a match */
|
||||
return i;
|
||||
}
|
||||
#endif /* Windoz free systems */
|
||||
}
|
||||
|
||||
/* no match found */
|
||||
@@ -923,11 +954,21 @@ addreadset(char *name, char *path, struct stat *sbuf)
|
||||
return -1;
|
||||
}
|
||||
strcpy(readset[ret].name, name);
|
||||
#if defined(_WIN32)
|
||||
/*
|
||||
* For WIN32, _fullpath expands the path to a fully qualified
|
||||
* path name, which under WIN32 FAT and NTFS is unique, just
|
||||
* like UNIX inodes. _fullpath also allocated the memory for
|
||||
* this new longer path name.
|
||||
*/
|
||||
readset[ret].path = _fullpath(NULL, path, 0);
|
||||
#else /* Windoz free systems */
|
||||
readset[ret].path = (char *)malloc(strlen(path)+1);
|
||||
if (readset[ret].path == NULL) {
|
||||
return -1;
|
||||
}
|
||||
strcpy(readset[ret].path, path);
|
||||
#endif /* Windoz free systems */
|
||||
readset[ret].inode = *sbuf;
|
||||
readset[ret].active = 1;
|
||||
|
||||
|
51
lib_calc.c
51
lib_calc.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: lib_calc.c,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: lib_calc.c,v 29.6 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/lib_calc.c,v $
|
||||
*
|
||||
* Under source code control: 1996/06/17 18:06:19
|
||||
@@ -32,7 +32,10 @@
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
# include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include "calc.h"
|
||||
#include "zmath.h"
|
||||
@@ -63,18 +66,31 @@
|
||||
# include <termios.h>
|
||||
typedef struct termios ttystruct;
|
||||
|
||||
#elif defined(USE_TERMIOS)
|
||||
#elif defined(USE_TERMIO)
|
||||
|
||||
# include <termio.h>
|
||||
typedef struct termio ttystruct;
|
||||
|
||||
#else /* assume USE_SGTTY */
|
||||
#elif defined(USE_SGTTY)
|
||||
|
||||
# include <sys/ioctl.h>
|
||||
typedef struct sgttyb ttystruct;
|
||||
|
||||
#else
|
||||
|
||||
typedef struct {int fd;} ttystruct;
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32)
|
||||
# if !defined(USE_SGTTY) && !defined (USE_TERMIOS) && !defined(USE_TERMIO)
|
||||
|
||||
-=*#*=- A Windoz free system without termio, termios or sgtty!!! -=*#*=-
|
||||
-=*#*=- We do not know how to compile for such a host, sorry!!!! -=*#*=-
|
||||
|
||||
# endif
|
||||
#endif /* Windoz */
|
||||
|
||||
/*
|
||||
* in case we do not have certain .h files
|
||||
*/
|
||||
@@ -192,7 +208,9 @@ libcalc_call_me_first(void)
|
||||
* Disable SIGPIPE so that the pipe to the help file pager will
|
||||
* not stop calc.
|
||||
*/
|
||||
#if !defined(_WIN32)
|
||||
(void) signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* determine the basename
|
||||
@@ -373,7 +391,9 @@ cvmalloc_error(char *message)
|
||||
static void
|
||||
initenv(void)
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
struct passwd *ent; /* our password entry */
|
||||
#endif
|
||||
char *c;
|
||||
|
||||
/* determine the $CALCPATH value */
|
||||
@@ -402,6 +422,12 @@ initenv(void)
|
||||
/* determine the $HOME value */
|
||||
c = (no_env ? NULL : getenv(HOME));
|
||||
home = (c ? strdup(c) : NULL);
|
||||
#if defined(_WIN32)
|
||||
if (home == NULL || home[0] == '\0') {
|
||||
/* just assume . is home if all else fails */
|
||||
home = ".";
|
||||
}
|
||||
#else /* Windoz free systems */
|
||||
if (home == NULL || home[0] == '\0') {
|
||||
ent = (struct passwd *)getpwuid(geteuid());
|
||||
if (ent == NULL) {
|
||||
@@ -411,6 +437,7 @@ initenv(void)
|
||||
home = (char *)malloc(strlen(ent->pw_dir)+1);
|
||||
strcpy(home, ent->pw_dir);
|
||||
}
|
||||
#endif /* Windoz free systems */
|
||||
|
||||
/* determine the $PAGER value */
|
||||
c = (no_env ? NULL : getenv(PAGER));
|
||||
@@ -726,7 +753,7 @@ calc_tty(int fd)
|
||||
printf("calc_tty: stty -ECHO -ECHOE -ECHOK -ICANON +ISTRIP "
|
||||
"VMIN=1 VTIME=0: fd %d\n", fd);
|
||||
|
||||
#else /* assume USE_SGTTY */
|
||||
#elif defined (USE_SGTTY)/* assume USE_SGTTY */
|
||||
|
||||
/*
|
||||
* assume USE_SGTTY tty state method
|
||||
@@ -752,6 +779,10 @@ calc_tty(int fd)
|
||||
if (conf->calc_debug & CALCDBG_TTY)
|
||||
printf("calc_tty: stty -ECHO -ECHOE -ECHOK -ICANON +ISTRIP "
|
||||
"VMIN=1 VTIME=0: fd %d\n", fd);
|
||||
|
||||
#else /* Using none of the above */
|
||||
fd_cur[slot] = fd_orig[slot];
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -817,7 +848,7 @@ orig_tty(int fd)
|
||||
if (conf->calc_debug & CALCDBG_TTY)
|
||||
printf("orig_tty: TCSETAW restored fd %d\n", fd);
|
||||
|
||||
#else /* assume USE_SGTTY */
|
||||
#elif defined (USE_SGTTY)/* assume USE_SGTTY */
|
||||
|
||||
/*
|
||||
* assume USE_SGTTY tty state method
|
||||
@@ -825,6 +856,12 @@ orig_tty(int fd)
|
||||
(void) tcsetattr(fd, TCSANOW, fd_orig+slot);
|
||||
if (conf->calc_debug & CALCDBG_TTY)
|
||||
printf("orig_tty: TCSANOW restored fd %d\n", fd);
|
||||
|
||||
#else /* nothing assigned */
|
||||
|
||||
if (conf->calc_debug & CALCDBG_TTY)
|
||||
printf ("orig_tty: nothing restored to fd %d\n", fd);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
10
longlong.c
10
longlong.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: longlong.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: longlong.c,v 29.3 2001/02/23 20:46:38 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/longlong.c,v $
|
||||
*
|
||||
* Under source code control: 1994/08/05 01:09:19
|
||||
@@ -119,10 +119,10 @@ main(int argc, char **argv)
|
||||
printf(" * if defined(L64_FORMAT), ok to use %%ld\n");
|
||||
printf(" * if !defined(L64_FORMAT), use %%lld\n");
|
||||
printf(" */\n");
|
||||
if (buf[0] == '-') {
|
||||
printf("#undef L64_FORMAT\n");
|
||||
} else {
|
||||
if (strcmp(buf, "1311768467284833366") == 0) {
|
||||
printf("#define L64_FORMAT\n");
|
||||
} else {
|
||||
printf("#undef L64_FORMAT\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: math_error.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: math_error.h,v 29.3 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/math_error.h,v $
|
||||
*
|
||||
* Under source code control: 1997/03/23 18:37:10
|
||||
@@ -33,10 +33,13 @@
|
||||
#define __MATH_ERROR_H__
|
||||
|
||||
|
||||
#include "win32dll.h"
|
||||
|
||||
|
||||
/*
|
||||
* Global data definitions.
|
||||
*/
|
||||
extern jmp_buf jmpbuf; /* for errors */
|
||||
extern DLL jmp_buf jmpbuf; /* for errors */
|
||||
|
||||
|
||||
#endif /* !__MATH_ERROR_H__ */
|
||||
|
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: opcodes.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: opcodes.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/opcodes.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:19
|
||||
|
11
opcodes.h
11
opcodes.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: opcodes.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: opcodes.h,v 29.4 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/opcodes.h,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:35
|
||||
@@ -32,6 +32,9 @@
|
||||
#define __OPCODES_H__
|
||||
|
||||
|
||||
#include "win32dll.h"
|
||||
|
||||
|
||||
/*
|
||||
* Opcodes
|
||||
*/
|
||||
@@ -174,8 +177,8 @@
|
||||
/*
|
||||
* external declarations
|
||||
*/
|
||||
extern char *funcname; /* function being executed */
|
||||
extern long funcline; /* function line being executed */
|
||||
extern DLL char *funcname; /* function being executed */
|
||||
extern DLL long funcline; /* function line being executed */
|
||||
|
||||
|
||||
#endif /* !__OPCODES_H__ */
|
||||
|
34
qfunc.c
34
qfunc.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: qfunc.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: qfunc.c,v 29.4 2000/12/17 13:07:32 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:20
|
||||
@@ -976,6 +976,7 @@ qbern(ZVALUE z)
|
||||
long n, i, k, m, nn, dd;
|
||||
NUMBER **p;
|
||||
NUMBER *s, *s1, *c, *c1, *t;
|
||||
size_t sz;
|
||||
|
||||
if (zisone(z))
|
||||
return qlink(&_qneghalf_);
|
||||
@@ -999,15 +1000,15 @@ qbern(ZVALUE z)
|
||||
|
||||
if (m >= B_allocnum) {
|
||||
k = (m/QALLOCNUM + 1) * QALLOCNUM;
|
||||
sz = k * sizeof(NUMBER *);
|
||||
if (sz < (size_t) k)
|
||||
return NULL;
|
||||
if (B_allocnum == 0)
|
||||
p = (NUMBER **) malloc(k * sizeof(NUMBER *));
|
||||
p = (NUMBER **) malloc(sz);
|
||||
else
|
||||
p = (NUMBER **) realloc(B_table,
|
||||
k * sizeof(NUMBER *));
|
||||
if (p == NULL) {
|
||||
math_error("Not enough memory for Bernoulli numbers");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
p = (NUMBER **) realloc(B_table, sz);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
B_allocnum = k;
|
||||
B_table = p;
|
||||
}
|
||||
@@ -1069,6 +1070,7 @@ qeuler(ZVALUE z)
|
||||
long i, k, m, n, nn, dd;
|
||||
NUMBER **p;
|
||||
NUMBER *s, *s1, *c, *c1, *t;
|
||||
size_t sz;
|
||||
|
||||
|
||||
if (ziszero(z))
|
||||
@@ -1081,11 +1083,15 @@ qeuler(ZVALUE z)
|
||||
m = (n >> 1) - 1;
|
||||
if (m < E_num)
|
||||
return qlink(E_table[m]);
|
||||
p = (NUMBER **) realloc(E_table, (m + 1) * sizeof(NUMBER *));
|
||||
if (p == NULL) {
|
||||
math_error("Unable to allocate memory for Euler numbers");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
sz = (m + 1) * sizeof(NUMBER *);
|
||||
if (sz < (size_t) m + 1)
|
||||
return NULL;
|
||||
if (E_num)
|
||||
p = (NUMBER **) realloc(E_table, sz);
|
||||
else
|
||||
p = (NUMBER **) malloc(sz);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
E_table = p;
|
||||
for (k = E_num; k <= m; k++) {
|
||||
nn = 2 * k + 2;
|
||||
|
4
qio.c
4
qio.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: qio.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: qio.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qio.c,v $
|
||||
*
|
||||
* Under source code control: 1993/07/30 19:42:46
|
||||
|
4
qmath.c
4
qmath.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: qmath.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: qmath.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qmath.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:21
|
||||
|
4
qmath.h
4
qmath.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: qmath.h,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: qmath.h,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qmath.h,v $
|
||||
*
|
||||
* Under source code control: 1993/07/30 19:42:47
|
||||
|
@@ -17,8 +17,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: Makefile,v 29.2 2000/06/07 14:02:54 chongo Exp $
|
||||
# @(#) $Revision: 29.4 $
|
||||
# @(#) $Id: Makefile,v 29.4 2001/03/17 21:37:54 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/sample/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/04/19 22:46:49
|
||||
@@ -378,7 +378,10 @@ depend:
|
||||
fi; \
|
||||
done
|
||||
${Q}(cd ..; ${MAKE} hsrc)
|
||||
${Q}for i in `cd ..; ${MAKE} h_list`; do \
|
||||
${Q}for i in `cd ..; ${MAKE} h_list 2>&1 | \
|
||||
${SED} -e '/Entering directory/d' \
|
||||
-e '/Nothing to be done/d' \
|
||||
-e '/Leaving directory/d'`; do \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/$$i"; \
|
||||
echo "#define $$tag" >> "skel/$$i"; \
|
||||
@@ -443,11 +446,12 @@ install: all
|
||||
|
||||
# DO NOT DELETE THIS LINE
|
||||
|
||||
|
||||
many_random.o: ../alloc.h
|
||||
many_random.o: ../block.h
|
||||
many_random.o: ../byteswap.h
|
||||
many_random.o: ../calc.h
|
||||
many_random.o: ../calcerr.h
|
||||
many_random.o: ../calc.h
|
||||
many_random.o: ../cmath.h
|
||||
many_random.o: ../config.h
|
||||
many_random.o: ../endian_calc.h
|
||||
@@ -460,21 +464,22 @@ many_random.o: ../have_stdlib.h
|
||||
many_random.o: ../have_string.h
|
||||
many_random.o: ../lib_util.h
|
||||
many_random.o: ../longbits.h
|
||||
many_random.o: many_random.c
|
||||
many_random.o: ../md5.h
|
||||
many_random.o: ../nametype.h
|
||||
many_random.o: ../qmath.h
|
||||
many_random.o: ../shs.h
|
||||
many_random.o: ../shs1.h
|
||||
many_random.o: ../shs.h
|
||||
many_random.o: ../string.h
|
||||
many_random.o: ../value.h
|
||||
many_random.o: ../win32dll.h
|
||||
many_random.o: ../zmath.h
|
||||
many_random.o: ../zrandom.h
|
||||
many_random.o: many_random.c
|
||||
test_random.o: ../alloc.h
|
||||
test_random.o: ../block.h
|
||||
test_random.o: ../byteswap.h
|
||||
test_random.o: ../calc.h
|
||||
test_random.o: ../calcerr.h
|
||||
test_random.o: ../calc.h
|
||||
test_random.o: ../cmath.h
|
||||
test_random.o: ../config.h
|
||||
test_random.o: ../endian_calc.h
|
||||
@@ -490,10 +495,11 @@ test_random.o: ../longbits.h
|
||||
test_random.o: ../md5.h
|
||||
test_random.o: ../nametype.h
|
||||
test_random.o: ../qmath.h
|
||||
test_random.o: ../shs.h
|
||||
test_random.o: ../shs1.h
|
||||
test_random.o: ../shs.h
|
||||
test_random.o: ../string.h
|
||||
test_random.o: test_random.c
|
||||
test_random.o: ../value.h
|
||||
test_random.o: ../win32dll.h
|
||||
test_random.o: ../zmath.h
|
||||
test_random.o: ../zrandom.h
|
||||
test_random.o: test_random.c
|
||||
|
79
seed.c
79
seed.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: seed.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: seed.c,v 29.4 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/seed.c,v $
|
||||
*
|
||||
* Under source code control: 1999/10/03 10:06:53
|
||||
@@ -40,7 +40,16 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "have_unistd.h"
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <process.h>
|
||||
# define pid_t int
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PORTING NOTE:
|
||||
@@ -55,10 +64,19 @@
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "have_times.h"
|
||||
#if defined(HAVE_TIME_H)
|
||||
#include <time.h>
|
||||
#endif
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#if defined(HAVE_SYS_TIMES_H)
|
||||
#include <sys/times.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
#if !defined(_WIN32)
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
#include <setjmp.h>
|
||||
#include "qmath.h"
|
||||
#include "longbits.h"
|
||||
@@ -69,14 +87,15 @@
|
||||
#include "have_getprid.h"
|
||||
#include "have_urandom.h"
|
||||
#include "have_rusage.h"
|
||||
#include "have_uid_t.h"
|
||||
#if defined(HAVE_USTAT)
|
||||
# include <ustat.h>
|
||||
#endif /* HAVE_USTAT */
|
||||
#endif
|
||||
#if defined(HAVE_URANDOM)
|
||||
# include <fcntl.h>
|
||||
# define DEV_URANDOM "/dev/urandom"
|
||||
# define DEV_URANDOM_POOL 16
|
||||
#endif /* HAVE_URANDOM */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -272,26 +291,32 @@ pseudo_seed(void)
|
||||
#if defined(HAVE_GETTIME)
|
||||
# if defined(CLOCK_SGI_CYCLE)
|
||||
struct timespec sgi_cycle; /* SGI hardware clock */
|
||||
# endif /* CLOCK_SGI_CYCLE */
|
||||
# endif
|
||||
# if defined(CLOCK_REALTIME)
|
||||
struct timespec realtime; /* POSIX realtime clock */
|
||||
# endif /* CLOCK_REALTIME */
|
||||
#endif /* HAVE_GETTIME */
|
||||
# endif
|
||||
#endif
|
||||
#if defined(HAVE_GETPRID)
|
||||
prid_t getprid; /* project ID */
|
||||
#endif /* HAVE_GETPRID */
|
||||
#endif
|
||||
#if defined(HAVE_URANDOM)
|
||||
int urandom_fd; /* open descriptor for /dev/urandom */
|
||||
int urandom_ret; /* read() of /dev/random */
|
||||
char urandom_pool[DEV_URANDOM_POOL]; /* /dev/urandom data pool */
|
||||
#endif /* HAVE_URANDOM */
|
||||
#endif
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
struct timeval tp; /* time of day */
|
||||
#endif
|
||||
pid_t getpid; /* process ID */
|
||||
#if !defined(_WIN32)
|
||||
pid_t getppid; /* parent process ID */
|
||||
#endif
|
||||
#if defined(HAVE_UID_T)
|
||||
uid_t getuid; /* real user ID */
|
||||
uid_t geteuid; /* effective user ID */
|
||||
gid_t getgid; /* real group ID */
|
||||
gid_t getegid; /* effective group ID */
|
||||
#endif
|
||||
struct stat stat_dot; /* stat of "." */
|
||||
struct stat stat_dotdot; /* stat of ".." */
|
||||
struct stat stat_tmp; /* stat of "/tmp" */
|
||||
@@ -307,19 +332,21 @@ pseudo_seed(void)
|
||||
struct ustat ustat_stdin; /* usage stat of stdin */
|
||||
struct ustat ustat_stdout; /* usage stat of stdout */
|
||||
struct ustat ustat_stderr; /* usage stat of stderr */
|
||||
#endif /* HAVE_USTAT */
|
||||
#endif
|
||||
#if defined(HAVE_GETSID)
|
||||
pid_t getsid; /* session ID */
|
||||
#endif /* HAVE_GETSID */
|
||||
#endif
|
||||
#if defined(HAVE_GETPGID)
|
||||
pid_t getpgid; /* process group ID */
|
||||
#endif /* HAVE_GETPGID */
|
||||
#endif
|
||||
#if defined(HAVE_GETRUSAGE)
|
||||
struct rusage rusage; /* resource utilization */
|
||||
struct rusage rusage_chld; /* resource utilization of children */
|
||||
#endif /* HAVE_GETRUSAGE */
|
||||
#endif
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
struct timeval tp2; /* time of day again */
|
||||
struct tms times; /* process times */
|
||||
#endif
|
||||
time_t time; /* local time */
|
||||
size_t size; /* size of this data structure */
|
||||
jmp_buf env; /* setjmp() context */
|
||||
@@ -339,14 +366,14 @@ pseudo_seed(void)
|
||||
#if defined(HAVE_GETTIME)
|
||||
# if defined(CLOCK_SGI_CYCLE)
|
||||
(void) clock_gettime(CLOCK_SGI_CYCLE, &sdata.sgi_cycle);
|
||||
# endif /* CLOCK_SGI_CYCLE */
|
||||
# endif
|
||||
# if defined(CLOCK_REALTIME)
|
||||
(void) clock_gettime(CLOCK_REALTIME, &sdata.realtime);
|
||||
# endif /* CLOCK_REALTIME */
|
||||
#endif /* HAVE_GETTIME */
|
||||
# endif
|
||||
#endif
|
||||
#if defined(HAVE_GETPRID)
|
||||
sdata.getprid = getprid();
|
||||
#endif /* HAVE_GETPRID */
|
||||
#endif
|
||||
#if defined(HAVE_URANDOM)
|
||||
sdata.urandom_fd = open(DEV_URANDOM, O_NONBLOCK|O_RDONLY);
|
||||
if (sdata.urandom_fd >= 0) {
|
||||
@@ -358,13 +385,19 @@ pseudo_seed(void)
|
||||
sdata.urandom_ret = EOF;
|
||||
}
|
||||
#endif /* HAVE_URANDOM */
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
(void) gettimeofday(&sdata.tp, NULL);
|
||||
#endif
|
||||
sdata.getpid = getpid();
|
||||
#if !defined(_WIN32)
|
||||
sdata.getppid = getppid();
|
||||
#endif
|
||||
#if defined(HAVE_UID_T)
|
||||
sdata.getuid = getuid();
|
||||
sdata.geteuid = geteuid();
|
||||
sdata.getgid = getgid();
|
||||
sdata.getegid = getegid();
|
||||
#endif
|
||||
(void) stat(".", &sdata.stat_dot);
|
||||
(void) stat("..", &sdata.stat_dotdot);
|
||||
(void) stat("/tmp", &sdata.stat_tmp);
|
||||
@@ -380,19 +413,21 @@ pseudo_seed(void)
|
||||
(void) ustat(sdata.fstat_stdin.st_dev, &sdata.ustat_stdin);
|
||||
(void) ustat(sdata.fstat_stdout.st_dev, &sdata.ustat_stdout);
|
||||
(void) ustat(sdata.fstat_stderr.st_dev, &sdata.ustat_stderr);
|
||||
#endif /* HAVE_USTAT */
|
||||
#endif
|
||||
#if defined(HAVE_GETSID)
|
||||
sdata.getsid = getsid((pid_t)0);
|
||||
#endif /* HAVE_GETSID */
|
||||
#endif
|
||||
#if defined(HAVE_GETPGID)
|
||||
sdata.getpgid = getpgid((pid_t)0);
|
||||
#endif /* HAVE_GETPGID */
|
||||
#endif
|
||||
#if defined(HAVE_GETRUSAGE)
|
||||
(void) getrusage(RUSAGE_SELF, &sdata.rusage);
|
||||
(void) getrusage(RUSAGE_CHILDREN, &sdata.rusage_chld);
|
||||
#endif /* HAVE_GETRUSAGE */
|
||||
#endif
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
(void) gettimeofday(&sdata.tp2, NULL);
|
||||
(void) times(&sdata.times);
|
||||
#endif
|
||||
sdata.time = time(NULL);
|
||||
sdata.size = sizeof(sdata);
|
||||
(void) setjmp(sdata.env);
|
||||
|
4
token.c
4
token.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: token.c,v 29.3 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: token.c,v 29.4 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/token.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:25
|
||||
|
4
value.c
4
value.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: value.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: value.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/value.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:25
|
||||
|
341
value.h
341
value.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: value.h,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: value.h,v 29.5 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/value.h,v $
|
||||
*
|
||||
* Under source code control: 1993/07/30 19:42:47
|
||||
@@ -32,6 +32,7 @@
|
||||
#define __VALUE_H__
|
||||
|
||||
|
||||
#include "win32dll.h"
|
||||
#include "cmath.h"
|
||||
#include "config.h"
|
||||
#include "shs.h"
|
||||
@@ -187,59 +188,59 @@ struct value {
|
||||
/*
|
||||
* value functions
|
||||
*/
|
||||
extern void freevalue(VALUE *vp);
|
||||
extern void copyvalue(VALUE *vp, VALUE *vres);
|
||||
extern void negvalue(VALUE *vp, VALUE *vres);
|
||||
extern void addvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void subvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void mulvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void orvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void andvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void compvalue(VALUE *vp, VALUE *vres);
|
||||
extern void xorvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void squarevalue(VALUE *vp, VALUE *vres);
|
||||
extern void invertvalue(VALUE *vp, VALUE *vres);
|
||||
extern void roundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern void broundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern void setminusvalue(VALUE *, VALUE *, VALUE *);
|
||||
extern void backslashvalue(VALUE *, VALUE *);
|
||||
extern void contentvalue(VALUE *, VALUE *);
|
||||
extern void hashopvalue(VALUE *, VALUE *, VALUE *);
|
||||
extern void apprvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern void intvalue(VALUE *vp, VALUE *vres);
|
||||
extern void fracvalue(VALUE *vp, VALUE *vres);
|
||||
extern void incvalue(VALUE *vp, VALUE *vres);
|
||||
extern void decvalue(VALUE *vp, VALUE *vres);
|
||||
extern void conjvalue(VALUE *vp, VALUE *vres);
|
||||
extern void sqrtvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern void rootvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern void absvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void normvalue(VALUE *vp, VALUE *vres);
|
||||
extern void shiftvalue(VALUE *v1, VALUE *v2, BOOL rightshift, VALUE *vres);
|
||||
extern void scalevalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void powivalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern void divvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void quovalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern void modvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern BOOL testvalue(VALUE *vp);
|
||||
extern BOOL comparevalue(VALUE *v1, VALUE *v2);
|
||||
extern BOOL acceptvalue(VALUE *v1, VALUE *v2);
|
||||
extern void relvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern void sgnvalue(VALUE *vp, VALUE *vres);
|
||||
extern QCKHASH hashvalue(VALUE *vp, QCKHASH val);
|
||||
extern void printvalue(VALUE *vp, int flags);
|
||||
extern BOOL precvalue(VALUE *v1, VALUE *v2);
|
||||
extern VALUE error_value(int e);
|
||||
extern int set_errno(int e);
|
||||
extern int set_errcount(int e);
|
||||
extern long countlistitems(LIST *lp);
|
||||
extern void addlistitems(LIST *lp, VALUE *vres);
|
||||
extern void addlistinv(LIST *lp, VALUE *vres);
|
||||
extern void copy2octet(VALUE *, OCTET *);
|
||||
extern int copystod(VALUE *, long, long, VALUE *, long);
|
||||
extern void protectall(VALUE *, int);
|
||||
extern void set_update(int);
|
||||
extern DLL void freevalue(VALUE *vp);
|
||||
extern DLL void copyvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void negvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void addvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void subvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void mulvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void orvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void andvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void compvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void xorvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void squarevalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void invertvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void roundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern DLL void broundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern DLL void setminusvalue(VALUE *, VALUE *, VALUE *);
|
||||
extern DLL void backslashvalue(VALUE *, VALUE *);
|
||||
extern DLL void contentvalue(VALUE *, VALUE *);
|
||||
extern DLL void hashopvalue(VALUE *, VALUE *, VALUE *);
|
||||
extern DLL void apprvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern DLL void intvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void fracvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void incvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void decvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void conjvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void sqrtvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern DLL void rootvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern DLL void absvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void normvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL void shiftvalue(VALUE *v1, VALUE *v2, BOOL rightshift, VALUE *vres);
|
||||
extern DLL void scalevalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void powivalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern DLL void divvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void quovalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern DLL void modvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
|
||||
extern DLL BOOL testvalue(VALUE *vp);
|
||||
extern DLL BOOL comparevalue(VALUE *v1, VALUE *v2);
|
||||
extern DLL BOOL acceptvalue(VALUE *v1, VALUE *v2);
|
||||
extern DLL void relvalue(VALUE *v1, VALUE *v2, VALUE *vres);
|
||||
extern DLL void sgnvalue(VALUE *vp, VALUE *vres);
|
||||
extern DLL QCKHASH hashvalue(VALUE *vp, QCKHASH val);
|
||||
extern DLL void printvalue(VALUE *vp, int flags);
|
||||
extern DLL BOOL precvalue(VALUE *v1, VALUE *v2);
|
||||
extern DLL VALUE error_value(int e);
|
||||
extern DLL int set_errno(int e);
|
||||
extern DLL int set_errcount(int e);
|
||||
extern DLL long countlistitems(LIST *lp);
|
||||
extern DLL void addlistitems(LIST *lp, VALUE *vres);
|
||||
extern DLL void addlistinv(LIST *lp, VALUE *vres);
|
||||
extern DLL void copy2octet(VALUE *, OCTET *);
|
||||
extern DLL int copystod(VALUE *, long, long, VALUE *, long);
|
||||
extern DLL void protectall(VALUE *, int);
|
||||
extern DLL void set_update(int);
|
||||
|
||||
|
||||
/*
|
||||
@@ -256,44 +257,44 @@ struct matrix {
|
||||
#define matsize(n) (sizeof(MATRIX) - sizeof(VALUE) + ((n) * sizeof(VALUE)))
|
||||
|
||||
|
||||
extern MATRIX *matadd(MATRIX *m1, MATRIX *m2);
|
||||
extern MATRIX *matsub(MATRIX *m1, MATRIX *m2);
|
||||
extern MATRIX *matmul(MATRIX *m1, MATRIX *m2);
|
||||
extern MATRIX *matneg(MATRIX *m);
|
||||
extern MATRIX *matalloc(long size);
|
||||
extern MATRIX *matcopy(MATRIX *m);
|
||||
extern MATRIX *matinit(MATRIX *m, VALUE *v1, VALUE *v2);
|
||||
extern MATRIX *matsquare(MATRIX *m);
|
||||
extern MATRIX *matinv(MATRIX *m);
|
||||
extern MATRIX *matscale(MATRIX *m, long n);
|
||||
extern MATRIX *matshift(MATRIX *m, long n);
|
||||
extern MATRIX *matmulval(MATRIX *m, VALUE *vp);
|
||||
extern MATRIX *matpowi(MATRIX *m, NUMBER *q);
|
||||
extern MATRIX *matconj(MATRIX *m);
|
||||
extern MATRIX *matquoval(MATRIX *m, VALUE *vp, VALUE *v3);
|
||||
extern MATRIX *matmodval(MATRIX *m, VALUE *vp, VALUE *v3);
|
||||
extern MATRIX *matint(MATRIX *m);
|
||||
extern MATRIX *matfrac(MATRIX *m);
|
||||
extern MATRIX *matappr(MATRIX *m, VALUE *v2, VALUE *v3);
|
||||
extern VALUE mattrace(MATRIX *m);
|
||||
extern MATRIX *mattrans(MATRIX *m);
|
||||
extern MATRIX *matcross(MATRIX *m1, MATRIX *m2);
|
||||
extern BOOL mattest(MATRIX *m);
|
||||
extern void matsum(MATRIX *m, VALUE *vres);
|
||||
extern BOOL matcmp(MATRIX *m1, MATRIX *m2);
|
||||
extern int matsearch(MATRIX *m, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern int matrsearch(MATRIX *m, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern VALUE matdet(MATRIX *m);
|
||||
extern VALUE matdot(MATRIX *m1, MATRIX *m2);
|
||||
extern void matfill(MATRIX *m, VALUE *v1, VALUE *v2);
|
||||
extern void matfree(MATRIX *m);
|
||||
extern void matprint(MATRIX *m, long max_print);
|
||||
extern VALUE *matindex(MATRIX *mp, BOOL create, long dim, VALUE *indices);
|
||||
extern void matreverse(MATRIX *m);
|
||||
extern void matsort(MATRIX *m);
|
||||
extern BOOL matisident(MATRIX *m);
|
||||
extern MATRIX *matround(MATRIX *m, VALUE *v2, VALUE *v3);
|
||||
extern MATRIX *matbround(MATRIX *m, VALUE *v2, VALUE *v3);
|
||||
extern DLL MATRIX *matadd(MATRIX *m1, MATRIX *m2);
|
||||
extern DLL MATRIX *matsub(MATRIX *m1, MATRIX *m2);
|
||||
extern DLL MATRIX *matmul(MATRIX *m1, MATRIX *m2);
|
||||
extern DLL MATRIX *matneg(MATRIX *m);
|
||||
extern DLL MATRIX *matalloc(long size);
|
||||
extern DLL MATRIX *matcopy(MATRIX *m);
|
||||
extern DLL MATRIX *matinit(MATRIX *m, VALUE *v1, VALUE *v2);
|
||||
extern DLL MATRIX *matsquare(MATRIX *m);
|
||||
extern DLL MATRIX *matinv(MATRIX *m);
|
||||
extern DLL MATRIX *matscale(MATRIX *m, long n);
|
||||
extern DLL MATRIX *matshift(MATRIX *m, long n);
|
||||
extern DLL MATRIX *matmulval(MATRIX *m, VALUE *vp);
|
||||
extern DLL MATRIX *matpowi(MATRIX *m, NUMBER *q);
|
||||
extern DLL MATRIX *matconj(MATRIX *m);
|
||||
extern DLL MATRIX *matquoval(MATRIX *m, VALUE *vp, VALUE *v3);
|
||||
extern DLL MATRIX *matmodval(MATRIX *m, VALUE *vp, VALUE *v3);
|
||||
extern DLL MATRIX *matint(MATRIX *m);
|
||||
extern DLL MATRIX *matfrac(MATRIX *m);
|
||||
extern DLL MATRIX *matappr(MATRIX *m, VALUE *v2, VALUE *v3);
|
||||
extern DLL VALUE mattrace(MATRIX *m);
|
||||
extern DLL MATRIX *mattrans(MATRIX *m);
|
||||
extern DLL MATRIX *matcross(MATRIX *m1, MATRIX *m2);
|
||||
extern DLL BOOL mattest(MATRIX *m);
|
||||
extern DLL void matsum(MATRIX *m, VALUE *vres);
|
||||
extern DLL BOOL matcmp(MATRIX *m1, MATRIX *m2);
|
||||
extern DLL int matsearch(MATRIX *m, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern DLL int matrsearch(MATRIX *m, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern DLL VALUE matdet(MATRIX *m);
|
||||
extern DLL VALUE matdot(MATRIX *m1, MATRIX *m2);
|
||||
extern DLL void matfill(MATRIX *m, VALUE *v1, VALUE *v2);
|
||||
extern DLL void matfree(MATRIX *m);
|
||||
extern DLL void matprint(MATRIX *m, long max_print);
|
||||
extern DLL VALUE *matindex(MATRIX *mp, BOOL create, long dim, VALUE *indices);
|
||||
extern DLL void matreverse(MATRIX *m);
|
||||
extern DLL void matsort(MATRIX *m);
|
||||
extern DLL BOOL matisident(MATRIX *m);
|
||||
extern DLL MATRIX *matround(MATRIX *m, VALUE *v2, VALUE *v3);
|
||||
extern DLL MATRIX *matbround(MATRIX *m, VALUE *v2, VALUE *v3);
|
||||
|
||||
|
||||
/*
|
||||
@@ -320,32 +321,32 @@ struct list {
|
||||
};
|
||||
|
||||
|
||||
extern void insertlistfirst(LIST *lp, VALUE *vp);
|
||||
extern void insertlistlast(LIST *lp, VALUE *vp);
|
||||
extern void insertlistmiddle(LIST *lp, long index, VALUE *vp);
|
||||
extern void removelistfirst(LIST *lp, VALUE *vp);
|
||||
extern void removelistlast(LIST *lp, VALUE *vp);
|
||||
extern void removelistmiddle(LIST *lp, long index, VALUE *vp);
|
||||
extern void listfree(LIST *lp);
|
||||
extern void listprint(LIST *lp, long max_print);
|
||||
extern int listsearch(LIST *lp, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern int listrsearch(LIST *lp, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern BOOL listcmp(LIST *lp1, LIST *lp2);
|
||||
extern VALUE *listfindex(LIST *lp, long index);
|
||||
extern LIST *listalloc(void);
|
||||
extern LIST *listcopy(LIST *lp);
|
||||
extern void listreverse(LIST *lp);
|
||||
extern void listsort(LIST *lp);
|
||||
extern LIST *listappr(LIST *lp, VALUE *v2, VALUE *v3);
|
||||
extern LIST *listround(LIST *m, VALUE *v2, VALUE *v3);
|
||||
extern LIST *listbround(LIST *m, VALUE *v2, VALUE *v3);
|
||||
extern LIST *listquo(LIST *lp, VALUE *v2, VALUE *v3);
|
||||
extern LIST *listmod(LIST *lp, VALUE *v2, VALUE *v3);
|
||||
extern BOOL evp(LISTELEM *cp, LISTELEM *x, VALUE *vres);
|
||||
extern BOOL evalpoly(LIST *clist, LISTELEM *x, VALUE *vres);
|
||||
extern void insertitems(LIST *lp1, LIST *lp2);
|
||||
extern LISTELEM *listelement(LIST *, long);
|
||||
extern LIST *listsegment(LIST *, long, long);
|
||||
extern DLL void insertlistfirst(LIST *lp, VALUE *vp);
|
||||
extern DLL void insertlistlast(LIST *lp, VALUE *vp);
|
||||
extern DLL void insertlistmiddle(LIST *lp, long index, VALUE *vp);
|
||||
extern DLL void removelistfirst(LIST *lp, VALUE *vp);
|
||||
extern DLL void removelistlast(LIST *lp, VALUE *vp);
|
||||
extern DLL void removelistmiddle(LIST *lp, long index, VALUE *vp);
|
||||
extern DLL void listfree(LIST *lp);
|
||||
extern DLL void listprint(LIST *lp, long max_print);
|
||||
extern DLL int listsearch(LIST *lp, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern DLL int listrsearch(LIST *lp, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern DLL BOOL listcmp(LIST *lp1, LIST *lp2);
|
||||
extern DLL VALUE *listfindex(LIST *lp, long index);
|
||||
extern DLL LIST *listalloc(void);
|
||||
extern DLL LIST *listcopy(LIST *lp);
|
||||
extern DLL void listreverse(LIST *lp);
|
||||
extern DLL void listsort(LIST *lp);
|
||||
extern DLL LIST *listappr(LIST *lp, VALUE *v2, VALUE *v3);
|
||||
extern DLL LIST *listround(LIST *m, VALUE *v2, VALUE *v3);
|
||||
extern DLL LIST *listbround(LIST *m, VALUE *v2, VALUE *v3);
|
||||
extern DLL LIST *listquo(LIST *lp, VALUE *v2, VALUE *v3);
|
||||
extern DLL LIST *listmod(LIST *lp, VALUE *v2, VALUE *v3);
|
||||
extern DLL BOOL evp(LISTELEM *cp, LISTELEM *x, VALUE *vres);
|
||||
extern DLL BOOL evalpoly(LIST *clist, LISTELEM *x, VALUE *vres);
|
||||
extern DLL void insertitems(LIST *lp1, LIST *lp2);
|
||||
extern DLL LISTELEM *listelement(LIST *, long);
|
||||
extern DLL LIST *listsegment(LIST *, long, long);
|
||||
|
||||
|
||||
/*
|
||||
@@ -370,15 +371,15 @@ struct assoc {
|
||||
};
|
||||
|
||||
|
||||
extern ASSOC *assocalloc(long initsize);
|
||||
extern ASSOC *assoccopy(ASSOC *ap);
|
||||
extern void assocfree(ASSOC *ap);
|
||||
extern void assocprint(ASSOC *ap, long max_print);
|
||||
extern int assocsearch(ASSOC *ap, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern int assocrsearch(ASSOC *ap, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern BOOL assoccmp(ASSOC *ap1, ASSOC *ap2);
|
||||
extern VALUE *assocfindex(ASSOC *ap, long index);
|
||||
extern VALUE *associndex(ASSOC *ap, BOOL create, long dim, VALUE *indices);
|
||||
extern DLL ASSOC *assocalloc(long initsize);
|
||||
extern DLL ASSOC *assoccopy(ASSOC *ap);
|
||||
extern DLL void assocfree(ASSOC *ap);
|
||||
extern DLL void assocprint(ASSOC *ap, long max_print);
|
||||
extern DLL int assocsearch(ASSOC *ap, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern DLL int assocrsearch(ASSOC *ap, VALUE *vp, long start, long end, ZVALUE *index);
|
||||
extern DLL BOOL assoccmp(ASSOC *ap1, ASSOC *ap2);
|
||||
extern DLL VALUE *assocfindex(ASSOC *ap, long index);
|
||||
extern DLL VALUE *associndex(ASSOC *ap, BOOL create, long dim, VALUE *indices);
|
||||
|
||||
|
||||
/*
|
||||
@@ -460,62 +461,62 @@ struct object {
|
||||
(sizeof(OBJECT) + ((elements) - USUAL_ELEMENTS) * sizeof(VALUE))
|
||||
|
||||
|
||||
extern OBJECT *objcopy(OBJECT *op);
|
||||
extern OBJECT *objalloc(long index);
|
||||
extern VALUE objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3);
|
||||
extern void objfree(OBJECT *op);
|
||||
extern int addelement(char *name);
|
||||
extern int defineobject(char *name, int indices[], int count);
|
||||
extern int checkobject(char *name);
|
||||
extern void showobjfuncs(void);
|
||||
extern void showobjtypes(void);
|
||||
extern int findelement(char *name);
|
||||
extern char *objtypename(unsigned long index);
|
||||
extern int objoffset(OBJECT *op, long index);
|
||||
extern DLL OBJECT *objcopy(OBJECT *op);
|
||||
extern DLL OBJECT *objalloc(long index);
|
||||
extern DLL VALUE objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3);
|
||||
extern DLL void objfree(OBJECT *op);
|
||||
extern DLL int addelement(char *name);
|
||||
extern DLL int defineobject(char *name, int indices[], int count);
|
||||
extern DLL int checkobject(char *name);
|
||||
extern DLL void showobjfuncs(void);
|
||||
extern DLL void showobjtypes(void);
|
||||
extern DLL int findelement(char *name);
|
||||
extern DLL char *objtypename(unsigned long index);
|
||||
extern DLL int objoffset(OBJECT *op, long index);
|
||||
|
||||
|
||||
/*
|
||||
* Configuration parameter name and type.
|
||||
*/
|
||||
extern NAMETYPE configs[];
|
||||
extern void config_value(CONFIG *cfg, int type, VALUE *ret);
|
||||
extern void setconfig(int type, VALUE *vp);
|
||||
extern void config_print(CONFIG *cfg); /* the CONFIG to print */
|
||||
extern DLL void config_value(CONFIG *cfg, int type, VALUE *ret);
|
||||
extern DLL void setconfig(int type, VALUE *vp);
|
||||
extern DLL void config_print(CONFIG *cfg); /* the CONFIG to print */
|
||||
|
||||
|
||||
/*
|
||||
* size, memsize and sizeof support
|
||||
*/
|
||||
extern long elm_count(VALUE *vp);
|
||||
extern long lsizeof(VALUE *vp);
|
||||
extern long memsize(VALUE *vp);
|
||||
extern DLL long elm_count(VALUE *vp);
|
||||
extern DLL long lsizeof(VALUE *vp);
|
||||
extern DLL long memsize(VALUE *vp);
|
||||
|
||||
/*
|
||||
* String functions
|
||||
*/
|
||||
extern STRING *stringadd(STRING *, STRING *);
|
||||
extern STRING *stringcopy(STRING *);
|
||||
extern STRING *stringsub(STRING *, STRING *);
|
||||
extern STRING *stringmul(NUMBER *, STRING *);
|
||||
extern STRING *stringand(STRING *, STRING *);
|
||||
extern STRING *stringor(STRING *, STRING *);
|
||||
extern STRING *stringxor(STRING *, STRING *);
|
||||
extern STRING *stringdiff(STRING *, STRING *);
|
||||
extern STRING *stringsegment(STRING *, long, long);
|
||||
extern STRING *stringshift(STRING *, long);
|
||||
extern STRING *stringcomp(STRING *);
|
||||
extern STRING *stringneg(STRING *);
|
||||
extern STRING *stringcpy(STRING *, STRING *);
|
||||
extern STRING *stringncpy(STRING *, STRING *, long);
|
||||
extern long stringcontent(STRING *s);
|
||||
extern long stringlowbit(STRING *s);
|
||||
extern long stringhighbit(STRING *s);
|
||||
extern BOOL stringcmp(STRING *, STRING *);
|
||||
extern BOOL stringrel(STRING *, STRING *);
|
||||
extern int stringbit(STRING *, long);
|
||||
extern BOOL stringtest(STRING *);
|
||||
extern int stringsetbit(STRING *, long, BOOL);
|
||||
extern int stringsearch(STRING *, STRING *, long, long, ZVALUE *);
|
||||
extern int stringrsearch(STRING *, STRING *, long, long, ZVALUE *);
|
||||
extern DLL STRING *stringadd(STRING *, STRING *);
|
||||
extern DLL STRING *stringcopy(STRING *);
|
||||
extern DLL STRING *stringsub(STRING *, STRING *);
|
||||
extern DLL STRING *stringmul(NUMBER *, STRING *);
|
||||
extern DLL STRING *stringand(STRING *, STRING *);
|
||||
extern DLL STRING *stringor(STRING *, STRING *);
|
||||
extern DLL STRING *stringxor(STRING *, STRING *);
|
||||
extern DLL STRING *stringdiff(STRING *, STRING *);
|
||||
extern DLL STRING *stringsegment(STRING *, long, long);
|
||||
extern DLL STRING *stringshift(STRING *, long);
|
||||
extern DLL STRING *stringcomp(STRING *);
|
||||
extern DLL STRING *stringneg(STRING *);
|
||||
extern DLL STRING *stringcpy(STRING *, STRING *);
|
||||
extern DLL STRING *stringncpy(STRING *, STRING *, long);
|
||||
extern DLL long stringcontent(STRING *s);
|
||||
extern DLL long stringlowbit(STRING *s);
|
||||
extern DLL long stringhighbit(STRING *s);
|
||||
extern DLL BOOL stringcmp(STRING *, STRING *);
|
||||
extern DLL BOOL stringrel(STRING *, STRING *);
|
||||
extern DLL int stringbit(STRING *, long);
|
||||
extern DLL BOOL stringtest(STRING *);
|
||||
extern DLL int stringsetbit(STRING *, long, BOOL);
|
||||
extern DLL int stringsearch(STRING *, STRING *, long, long, ZVALUE *);
|
||||
extern DLL int stringrsearch(STRING *, STRING *, long, long, ZVALUE *);
|
||||
|
||||
#endif /* !__VALUE_H__ */
|
||||
|
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.14 $
|
||||
* @(#) $Id: version.c,v 29.14 2000/07/14 07:20:42 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.20 $
|
||||
* @(#) $Id: version.c,v 29.20 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
|
||||
*
|
||||
* Under source code control: 1990/05/22 11:00:58
|
||||
@@ -42,8 +42,8 @@ static char *program;
|
||||
|
||||
#define MAJOR_VER 2 /* major version */
|
||||
#define MINOR_VER 11 /* minor version */
|
||||
#define MAJOR_PATCH 3 /* patch level or 0 if no patch */
|
||||
#define MINOR_PATCH "0" /* test number or empty string if no patch */
|
||||
#define MAJOR_PATCH 5 /* patch level or 0 if no patch */
|
||||
#define MINOR_PATCH "1.0" /* test number or empty string if no patch */
|
||||
|
||||
/*
|
||||
* calc version constants
|
||||
|
50
win32dll.h
Normal file
50
win32dll.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* win32dll - definitions for building windoz dll files
|
||||
*
|
||||
* Copyright (C) 2001 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: win32dll.h,v 29.1 2001/03/18 03:03:11 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/win32dll.h,v $
|
||||
*
|
||||
* Under source code control: 2001/03/17 13:05:31
|
||||
* 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/
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(__WIN32DLL_H__)
|
||||
#define __WIN32DLL_H__
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
# if defined(_EXPORTING)
|
||||
# define DLL __declspec(dllexport)
|
||||
# else
|
||||
# define DLL __declspec(dllimport)
|
||||
# endif
|
||||
|
||||
#else /* Windoz free systems */
|
||||
|
||||
# define DLL
|
||||
|
||||
#endif /* Windoz free systems */
|
||||
|
||||
|
||||
#endif /* !__WIN32DLL_H__ */
|
4
zfunc.c
4
zfunc.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: zfunc.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: zfunc.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:27
|
||||
|
4
zio.c
4
zio.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: zio.c,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: zio.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zio.c,v $
|
||||
*
|
||||
* Under source code control: 1993/07/30 19:42:48
|
||||
|
229
zmath.h
229
zmath.h
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: zmath.h,v 29.2 2000/06/07 14:02:13 chongo Exp chongo $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: zmath.h,v 29.5 2001/03/17 21:31:47 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zmath.h,v $
|
||||
*
|
||||
* Under source code control: 1993/07/30 19:42:48
|
||||
@@ -38,6 +38,7 @@
|
||||
#define __ZMATH_H__
|
||||
|
||||
|
||||
#include "win32dll.h"
|
||||
#include "alloc.h"
|
||||
#include "endian_calc.h"
|
||||
#include "longbits.h"
|
||||
@@ -267,126 +268,126 @@ typedef struct {
|
||||
/*
|
||||
* Function prototypes for integer math routines.
|
||||
*/
|
||||
extern HALF * alloc(LEN len);
|
||||
extern DLL HALF * alloc(LEN len);
|
||||
#ifdef ALLOCTEST
|
||||
extern void freeh(HALF *);
|
||||
extern DLL void freeh(HALF *);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Input, output, and conversion routines.
|
||||
*/
|
||||
extern void zcopy(ZVALUE z, ZVALUE *res);
|
||||
extern void itoz(long i, ZVALUE *res);
|
||||
extern void utoz(FULL i, ZVALUE *res);
|
||||
extern void str2z(char *s, ZVALUE *res);
|
||||
extern long ztoi(ZVALUE z);
|
||||
extern FULL ztou(ZVALUE z);
|
||||
extern void zprintval(ZVALUE z, long decimals, long width);
|
||||
extern void zprintx(ZVALUE z, long width);
|
||||
extern void zprintb(ZVALUE z, long width);
|
||||
extern void zprinto(ZVALUE z, long width);
|
||||
extern void fitzprint(ZVALUE, long, long);
|
||||
extern DLL void zcopy(ZVALUE z, ZVALUE *res);
|
||||
extern DLL void itoz(long i, ZVALUE *res);
|
||||
extern DLL void utoz(FULL i, ZVALUE *res);
|
||||
extern DLL void str2z(char *s, ZVALUE *res);
|
||||
extern DLL long ztoi(ZVALUE z);
|
||||
extern DLL FULL ztou(ZVALUE z);
|
||||
extern DLL void zprintval(ZVALUE z, long decimals, long width);
|
||||
extern DLL void zprintx(ZVALUE z, long width);
|
||||
extern DLL void zprintb(ZVALUE z, long width);
|
||||
extern DLL void zprinto(ZVALUE z, long width);
|
||||
extern DLL void fitzprint(ZVALUE, long, long);
|
||||
|
||||
|
||||
/*
|
||||
* Basic numeric routines.
|
||||
*/
|
||||
extern void zmuli(ZVALUE z, long n, ZVALUE *res);
|
||||
extern long zdivi(ZVALUE z, long n, ZVALUE *res);
|
||||
extern long zmodi(ZVALUE z, long n);
|
||||
extern void zadd(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern void zsub(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern void zmul(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern long zdiv(ZVALUE z1, ZVALUE z2, ZVALUE *res, ZVALUE *rem, long R);
|
||||
extern long zquo(ZVALUE z1, ZVALUE z2, ZVALUE *res, long R);
|
||||
extern long zmod(ZVALUE z1, ZVALUE z2, ZVALUE *rem, long R);
|
||||
extern void zequo(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern BOOL zdivides(ZVALUE z1, ZVALUE z2);
|
||||
extern void zor(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern void zand(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern void zxor(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern void zandnot(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern long zpopcnt(ZVALUE z, int bitval);
|
||||
extern void zshift(ZVALUE z, long n, ZVALUE *res);
|
||||
extern void zsquare(ZVALUE z, ZVALUE *res);
|
||||
extern long zlowbit(ZVALUE z);
|
||||
extern LEN zhighbit(ZVALUE z);
|
||||
extern void zbitvalue(long n, ZVALUE *res);
|
||||
extern BOOL zisset(ZVALUE z, long n);
|
||||
extern BOOL zisonebit(ZVALUE z);
|
||||
extern BOOL zisallbits(ZVALUE z);
|
||||
extern FLAG ztest(ZVALUE z);
|
||||
extern FLAG zrel(ZVALUE z1, ZVALUE z2);
|
||||
extern FLAG zabsrel(ZVALUE z1, ZVALUE z2);
|
||||
extern BOOL zcmp(ZVALUE z1, ZVALUE z2);
|
||||
extern DLL void zmuli(ZVALUE z, long n, ZVALUE *res);
|
||||
extern DLL long zdivi(ZVALUE z, long n, ZVALUE *res);
|
||||
extern DLL long zmodi(ZVALUE z, long n);
|
||||
extern DLL void zadd(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL void zsub(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL void zmul(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL long zdiv(ZVALUE z1, ZVALUE z2, ZVALUE *res, ZVALUE *rem, long R);
|
||||
extern DLL long zquo(ZVALUE z1, ZVALUE z2, ZVALUE *res, long R);
|
||||
extern DLL long zmod(ZVALUE z1, ZVALUE z2, ZVALUE *rem, long R);
|
||||
extern DLL void zequo(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL BOOL zdivides(ZVALUE z1, ZVALUE z2);
|
||||
extern DLL void zor(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL void zand(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL void zxor(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL void zandnot(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL long zpopcnt(ZVALUE z, int bitval);
|
||||
extern DLL void zshift(ZVALUE z, long n, ZVALUE *res);
|
||||
extern DLL void zsquare(ZVALUE z, ZVALUE *res);
|
||||
extern DLL long zlowbit(ZVALUE z);
|
||||
extern DLL LEN zhighbit(ZVALUE z);
|
||||
extern DLL void zbitvalue(long n, ZVALUE *res);
|
||||
extern DLL BOOL zisset(ZVALUE z, long n);
|
||||
extern DLL BOOL zisonebit(ZVALUE z);
|
||||
extern DLL BOOL zisallbits(ZVALUE z);
|
||||
extern DLL FLAG ztest(ZVALUE z);
|
||||
extern DLL FLAG zrel(ZVALUE z1, ZVALUE z2);
|
||||
extern DLL FLAG zabsrel(ZVALUE z1, ZVALUE z2);
|
||||
extern DLL BOOL zcmp(ZVALUE z1, ZVALUE z2);
|
||||
|
||||
|
||||
/*
|
||||
* More complicated numeric functions.
|
||||
*/
|
||||
extern FULL uugcd(FULL i1, FULL i2);
|
||||
extern long iigcd(long i1, long i2);
|
||||
extern void zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern void zlcm(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern void zreduce(ZVALUE z1, ZVALUE z2, ZVALUE *z1res, ZVALUE *z2res);
|
||||
extern void zfact(ZVALUE z, ZVALUE *dest);
|
||||
extern void zperm(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern int zcomb(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern FLAG zjacobi(ZVALUE z1, ZVALUE z2);
|
||||
extern void zfib(ZVALUE z, ZVALUE *res);
|
||||
extern void zpowi(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern void ztenpow(long power, ZVALUE *res);
|
||||
extern void zpowermod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res);
|
||||
extern BOOL zmodinv(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern BOOL zrelprime(ZVALUE z1, ZVALUE z2);
|
||||
extern long zlog(ZVALUE z1, ZVALUE z2);
|
||||
extern long zlog10(ZVALUE z);
|
||||
extern long zdivcount(ZVALUE z1, ZVALUE z2);
|
||||
extern long zfacrem(ZVALUE z1, ZVALUE z2, ZVALUE *rem);
|
||||
extern long zgcdrem(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern long zdigits(ZVALUE z1);
|
||||
extern long zdigit(ZVALUE z1, long n);
|
||||
extern FLAG zsqrt(ZVALUE z1, ZVALUE *dest, long R);
|
||||
extern void zroot(ZVALUE z1, ZVALUE z2, ZVALUE *dest);
|
||||
extern BOOL zissquare(ZVALUE z);
|
||||
extern void zhnrmod(ZVALUE v, ZVALUE h, ZVALUE zn, ZVALUE zr, ZVALUE *res);
|
||||
extern DLL FULL uugcd(FULL i1, FULL i2);
|
||||
extern DLL long iigcd(long i1, long i2);
|
||||
extern DLL void zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL void zlcm(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL void zreduce(ZVALUE z1, ZVALUE z2, ZVALUE *z1res, ZVALUE *z2res);
|
||||
extern DLL void zfact(ZVALUE z, ZVALUE *dest);
|
||||
extern DLL void zperm(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL int zcomb(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL FLAG zjacobi(ZVALUE z1, ZVALUE z2);
|
||||
extern DLL void zfib(ZVALUE z, ZVALUE *res);
|
||||
extern DLL void zpowi(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL void ztenpow(long power, ZVALUE *res);
|
||||
extern DLL void zpowermod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res);
|
||||
extern DLL BOOL zmodinv(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL BOOL zrelprime(ZVALUE z1, ZVALUE z2);
|
||||
extern DLL long zlog(ZVALUE z1, ZVALUE z2);
|
||||
extern DLL long zlog10(ZVALUE z);
|
||||
extern DLL long zdivcount(ZVALUE z1, ZVALUE z2);
|
||||
extern DLL long zfacrem(ZVALUE z1, ZVALUE z2, ZVALUE *rem);
|
||||
extern DLL long zgcdrem(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL long zdigits(ZVALUE z1);
|
||||
extern DLL long zdigit(ZVALUE z1, long n);
|
||||
extern DLL FLAG zsqrt(ZVALUE z1, ZVALUE *dest, long R);
|
||||
extern DLL void zroot(ZVALUE z1, ZVALUE z2, ZVALUE *dest);
|
||||
extern DLL BOOL zissquare(ZVALUE z);
|
||||
extern DLL void zhnrmod(ZVALUE v, ZVALUE h, ZVALUE zn, ZVALUE zr, ZVALUE *res);
|
||||
|
||||
|
||||
/*
|
||||
* Prime related functions.
|
||||
*/
|
||||
extern FLAG zisprime(ZVALUE z);
|
||||
extern FULL znprime(ZVALUE z);
|
||||
extern FULL next_prime(FULL v);
|
||||
extern FULL zpprime(ZVALUE z);
|
||||
extern void zpfact(ZVALUE z, ZVALUE *dest);
|
||||
extern BOOL zprimetest(ZVALUE z, long count, ZVALUE skip);
|
||||
extern BOOL zredcprimetest(ZVALUE z, long count, ZVALUE skip);
|
||||
extern BOOL znextcand(ZVALUE z1, long count, ZVALUE skip, ZVALUE res, ZVALUE mod, ZVALUE *cand);
|
||||
extern BOOL zprevcand(ZVALUE z1, long count, ZVALUE skip, ZVALUE res, ZVALUE mod, ZVALUE *cand);
|
||||
extern FULL zlowfactor(ZVALUE z, long count);
|
||||
extern FLAG zfactor(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern long zpix(ZVALUE z1);
|
||||
extern void zlcmfact(ZVALUE z, ZVALUE *dest);
|
||||
extern DLL FLAG zisprime(ZVALUE z);
|
||||
extern DLL FULL znprime(ZVALUE z);
|
||||
extern DLL FULL next_prime(FULL v);
|
||||
extern DLL FULL zpprime(ZVALUE z);
|
||||
extern DLL void zpfact(ZVALUE z, ZVALUE *dest);
|
||||
extern DLL BOOL zprimetest(ZVALUE z, long count, ZVALUE skip);
|
||||
extern DLL BOOL zredcprimetest(ZVALUE z, long count, ZVALUE skip);
|
||||
extern DLL BOOL znextcand(ZVALUE z1, long count, ZVALUE skip, ZVALUE res, ZVALUE mod, ZVALUE *cand);
|
||||
extern DLL BOOL zprevcand(ZVALUE z1, long count, ZVALUE skip, ZVALUE res, ZVALUE mod, ZVALUE *cand);
|
||||
extern DLL FULL zlowfactor(ZVALUE z, long count);
|
||||
extern DLL FLAG zfactor(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL long zpix(ZVALUE z1);
|
||||
extern DLL void zlcmfact(ZVALUE z, ZVALUE *dest);
|
||||
|
||||
|
||||
/*
|
||||
* Misc misc functions. :-)
|
||||
*/
|
||||
extern void zsquaremod(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern void zminmod(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern BOOL zcmpmod(ZVALUE z1, ZVALUE z2, ZVALUE z3);
|
||||
extern void zio_init(void);
|
||||
extern DLL void zsquaremod(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL void zminmod(ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL BOOL zcmpmod(ZVALUE z1, ZVALUE z2, ZVALUE z3);
|
||||
extern DLL void zio_init(void);
|
||||
|
||||
|
||||
/*
|
||||
* These functions are for internal use only.
|
||||
*/
|
||||
extern void ztrim(ZVALUE *z);
|
||||
extern void zshiftr(ZVALUE z, long n);
|
||||
extern void zshiftl(ZVALUE z, long n);
|
||||
extern HALF *zalloctemp(LEN len);
|
||||
extern DLL void ztrim(ZVALUE *z);
|
||||
extern DLL void zshiftr(ZVALUE z, long n);
|
||||
extern DLL void zshiftl(ZVALUE z, long n);
|
||||
extern DLL HALF *zalloctemp(LEN len);
|
||||
|
||||
|
||||
/*
|
||||
@@ -403,13 +404,13 @@ typedef struct {
|
||||
ZVALUE one; /* REDC format for the number 1 */
|
||||
} REDC;
|
||||
|
||||
extern REDC *zredcalloc(ZVALUE z1);
|
||||
extern void zredcfree(REDC *rp);
|
||||
extern void zredcencode(REDC *rp, ZVALUE z1, ZVALUE *res);
|
||||
extern void zredcdecode(REDC *rp, ZVALUE z1, ZVALUE *res);
|
||||
extern void zredcmul(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern void zredcsquare(REDC *rp, ZVALUE z1, ZVALUE *res);
|
||||
extern void zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL REDC *zredcalloc(ZVALUE z1);
|
||||
extern DLL void zredcfree(REDC *rp);
|
||||
extern DLL void zredcencode(REDC *rp, ZVALUE z1, ZVALUE *res);
|
||||
extern DLL void zredcdecode(REDC *rp, ZVALUE z1, ZVALUE *res);
|
||||
extern DLL void zredcmul(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
extern DLL void zredcsquare(REDC *rp, ZVALUE z1, ZVALUE *res);
|
||||
extern DLL void zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
|
||||
|
||||
/*
|
||||
@@ -550,32 +551,32 @@ extern void zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res);
|
||||
/*
|
||||
* Output routines for either FILE handles or strings.
|
||||
*/
|
||||
extern void math_chr(int ch);
|
||||
extern void math_str(char *str);
|
||||
extern void math_fill(char *str, long width);
|
||||
extern void math_flush(void);
|
||||
extern void math_divertio(void);
|
||||
extern void math_cleardiversions(void);
|
||||
extern char *math_getdivertedio(void);
|
||||
extern int math_setmode(int mode);
|
||||
extern LEN math_setdigits(LEN digits);
|
||||
extern void math_fmt(char *, ...);
|
||||
extern DLL void math_chr(int ch);
|
||||
extern DLL void math_str(char *str);
|
||||
extern DLL void math_fill(char *str, long width);
|
||||
extern DLL void math_flush(void);
|
||||
extern DLL void math_divertio(void);
|
||||
extern DLL void math_cleardiversions(void);
|
||||
extern DLL char *math_getdivertedio(void);
|
||||
extern DLL int math_setmode(int mode);
|
||||
extern DLL LEN math_setdigits(LEN digits);
|
||||
extern DLL void math_fmt(char *, ...);
|
||||
|
||||
|
||||
/*
|
||||
* The error routine.
|
||||
*/
|
||||
extern void math_error(char *, ...);
|
||||
extern DLL void math_error(char *, ...);
|
||||
|
||||
|
||||
/*
|
||||
* external swap functions
|
||||
*/
|
||||
extern HALF *swap_b8_in_HALFs(HALF *dest, HALF *src, LEN len);
|
||||
extern ZVALUE *swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);
|
||||
extern HALF *swap_b16_in_HALFs(HALF *dest, HALF *src, LEN len);
|
||||
extern ZVALUE *swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);
|
||||
extern ZVALUE *swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);
|
||||
extern DLL HALF *swap_b8_in_HALFs(HALF *dest, HALF *src, LEN len);
|
||||
extern DLL ZVALUE *swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);
|
||||
extern DLL HALF *swap_b16_in_HALFs(HALF *dest, HALF *src, LEN len);
|
||||
extern DLL ZVALUE *swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);
|
||||
extern DLL ZVALUE *swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);
|
||||
|
||||
|
||||
/*
|
||||
@@ -595,7 +596,7 @@ extern ZVALUE _sqbase_, _pow4base_, _pow8base_;
|
||||
|
||||
extern ZVALUE _b32_, _b64_;
|
||||
|
||||
extern BOOL _math_abort_; /* nonzero to abort calculations */
|
||||
extern DLL BOOL _math_abort_; /* nonzero to abort calculations */
|
||||
extern ZVALUE _tenpowers_[]; /* table of 10^2^n */
|
||||
|
||||
/*
|
||||
|
7
zmod.c
7
zmod.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: zmod.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: zmod.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/zmod.c,v $
|
||||
*
|
||||
* Under source code control: 1991/05/22 23:03:55
|
||||
@@ -544,10 +544,9 @@ zpowermod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res)
|
||||
*res = _zero_;
|
||||
return;
|
||||
}
|
||||
if (zisone(z1) && ziseven(z2)) {
|
||||
if (zisone(z1)) {
|
||||
if (ztmp.len)
|
||||
zfree(ztmp);
|
||||
zfree(z1);
|
||||
*res = _one_;
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user