Compare commits

...

4 Commits

Author SHA1 Message Date
Landon Curt Noll
59837e385c Release calc version 2.11.5t2.1 2017-05-21 15:38:40 -07:00
Landon Curt Noll
bea726fc16 Release calc version 2.11.5t2 2017-05-21 15:38:40 -07:00
Landon Curt Noll
fc0a3dd183 Release calc version 2.11.5t1.1 2017-05-21 15:38:39 -07:00
Landon Curt Noll
63d9b22067 Release calc version 2.11.5t1.0 2017-05-21 15:38:39 -07:00
81 changed files with 3607 additions and 901 deletions

45
BUGS
View File

@@ -108,6 +108,25 @@ Problems with known work-a-rounds:
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
@@ -189,6 +208,28 @@ Problems with known work-a-rounds:
or performance. The work-a-round is to ignore these warnings
under BSDI.
* The chi.cal resource file does not work well with odd degrees
of freedom. Can someone improve this algorithm?
* The intfile.cal resource file reads and writes big or little Endian
integers to/from files the hard way. It does NOT use blkcpy. The
following code:
i = (ord("\n") << 16) | (ord("i") << 8) | ord("H")
b = blk()
copy(i, b)
fd = fopen("file", "w")
copy(b, fd);
fclose(fd)
will write an extra NUL octet to the file. Where as:
read intfile
i = (ord("\n") << 16) | (ord("i") << 8) | ord("H")
be2file(i, "file2")
will not.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
@@ -205,8 +246,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.7 $
## @(#) $Id: BUGS,v 29.7 2001/02/25 21:01:52 chongo Exp $
## @(#) $Revision: 29.10 $
## @(#) $Id: BUGS,v 29.10 2001/04/08 11:32:52 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/BUGS,v $
##
## Under source code control: 1994/03/18 14:06:13

148
CHANGES
View File

@@ -1,6 +1,41 @@
The following are the changes from calc version 2.11.5t2 to date:
Fixed a bug, reported by Ernest Bowen <ernie at turing dot
une dot edu dot au> that caused command lines to be echoed in
interactive mode. Fixed a bug that sometimes left the terminal
in a non-echoing state when calc exited.
Renamed error codes E_FGETWORD1 and E_FGETWORD2 symbols to
E_FGETFIELD1 and E_FGETFIELD2.
Made a minor format change to the top of the calc man page.
The findid() function in file.c 2nd argument changed. The argument
is now mostly a writable flag. This function now finds the file
I/O structure for the specified file id, and verifies that
it is opened in the required manner (0 for reading or 1 for writing).
If the 2nd argument is -1, then no open checks are made at all and
NULL is then returned if the id represents a closed file.
The calc builtin function, fopen(), now allows one to specify
opening files in binary modes. On POSIX / Linux / Un*x-like systems,
text file is the same as a binary file and so 'b' to an fopen has
no effect and is ignored. However on systems such as MS Windoz
the 'b' / binary mode has meaning. See 'help fopen' for details.
On systems (such as MS Windoz), calc will produce a different error
message when it attempts to open /dev/tty. This will condition
will occur in things like calc scripts when they switch from ``batch
processing'' commands from and want to start interactive mode.
Regression tests fopen in binary mode in a few places where a
difference between text and binary string lengths matter.
The intfile calc resource file also uses binary mode.
The following are the changes from calc version 2.11.5t0 to date:
Fixed a compile problem with Linux 2.4 / Debian. Thanks goes
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"
@@ -10,11 +45,116 @@ The following are the changes from calc version 2.11.5t0 to date:
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
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.
Added chi.cal for a initial stab as a Chi^2 function. The chi_prob()
function does not work well with odd degrees of freedom, however.
Added big 3 to config("resource_debug"). Calc resource file scripts
check for config("resource_debug") & 8 prior to printing internal debug
statements. Thus by default they do not print them.
Added intfile.cal as a calc resource file script:
file2be(filename)
Read filename and return an integer that is built from the
octets in that file in Big Endian order. The first octets
of the file become the most significant bits of the integer.
file2le(filename)
Read filename and return an integer that is built from the
octets in that file in Little Endian order. The first octets
of the file become the most significant bits of the integer.
be2file(v, filename)
Write the absolute value of v into filename in Big Endian order.
The v argument must be on integer. The most significant bits
of the integer become the first octets of the file.
le2file(v, filename)
Write the absolute value of v into filename in Little Endian order.
The v argument must be on integer. The least significant bits
of the integer become the last octets of the file.
Added the following help aliases:
copy blkcpy
read command
write command
quit command
exit command
abort command
cd command
show command
Added the cscript:
fproduct filename term ...
to write the big Endian product of terms to a filename. Use - for stdout.
Fixed calc path in help/script.
Added read-only parameter, config("windows") to indicate if the system
is MS windowz WIN32 like system.
Configuration values that used to return "true" or "false" now return
1 (a true value) or 0 (a false value). Thus one can do:
if (config("tab")) { ... } else { ... }
The configuration values that now return 1 or 0 are:
config("tilde")
config("tab")
config("leadzero")
config("blkverbose")
config("verbose_quit")
config("windows")
Now shipping a win32 sub-directory that contains hsrc .h files
that have been attempted to be built for windoz.
The following are the changes from calc version 2.11.4t1 to date:
@@ -5059,8 +5199,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.20 $
## @(#) $Id: CHANGES,v 29.20 2001/02/25 22:07:36 chongo Exp $
## @(#) $Revision: 29.28 $
## @(#) $Id: CHANGES,v 29.28 2001/04/10 22:13:40 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
##
## Under source code control: 1993/06/02 18:12:57

551
Makefile

File diff suppressed because it is too large Load Diff

View File

@@ -55,8 +55,11 @@ by the make file:
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.
You will find generated versions of these files located in the win32
sub-directory. These files may be appropriate for your Cygwin building
needs. Just copy the win32/*.[ch] files up into the top level calc
source directory, edited (if needed) and build using the Cygwin GCC
compiler.
=-=
@@ -64,7 +67,7 @@ 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)
#if defined(_WIN32)
#ifdef _EXPORTING
#define DLL __declspec(dllexport)
#else
@@ -102,8 +105,8 @@ was changed to:
## 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.WINDOWS,v 29.2 2001/02/25 22:20:38 chongo Exp $
## @(#) $Revision: 29.6 $
## @(#) $Id: README.WINDOWS,v 29.6 2001/04/08 22:13:38 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/README.WINDOWS,v $
##
## Under source code control: 2001/02/25 14:00:05

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: blkcpy.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: blkcpy.c,v 29.3 2001/04/10 22:06:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.c,v $
*
* Under source code control: 1997/04/18 20:41:26
@@ -581,7 +581,7 @@ copyblk2file(BLOCK *sblk, long ssi, long num, FILEID id, long dsi)
if (num == 0)
return 0;
fiop = findid(id, 'w');
fiop = findid(id, TRUE);
if (fiop == NULL)
return E_COPYF1;
fp = fiop->fp;
@@ -618,7 +618,7 @@ copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, BOOL noreloc)
if (id < 3) /* excludes copying from stdin */
return E_COPYF1;
fiop = findid(id, 'r');
fiop = findid(id, FALSE);
if (fiop == NULL)
return E_COPYF1;
@@ -690,7 +690,7 @@ copystr2file(STRING *str, long ssi, long num, FILEID id, long dsi)
return 0;
if ((USB32) ssi + num > len)
return E_COPY5; /* Insufficient memory in str */
fiop = findid(id, 'w');
fiop = findid(id, TRUE);
if (fiop == NULL)
return E_COPYF1;
fp = fiop->fp;

View File

@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.3 $
# @(#) $Id: Makefile,v 29.3 2000/12/15 14:42:52 chongo Exp $
# @(#) $Revision: 29.5 $
# @(#) $Id: Makefile,v 29.5 2001/03/31 16:24:17 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 test8600.cal
test8500.cal test8600.cal chi.cal intfile.cal
# These files are found (but not built) in the distribution
#

View File

@@ -64,7 +64,7 @@ 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:
n Meaning of bit n of config("resource_debug")
n Meaning of bit n of config("resource_debug")
0 When a function is defined, redefined or undefined at
interactive level, a message saying what has been done
@@ -74,6 +74,12 @@ have meanings are as follows:
the reading of a file, a message saying what has been done
is displayed.
2 Show func will display more information about a functions
arguments as well as more argument sdummary information.
3 During execution, allow calc standard resource files
to output additional debugging information.
The value for config("resource_debug") in both oldstd and newstd is 3,
but if calc is invoked with the -d flag, its initial value is zero.
Thus, if calc is started without the -d flag, until config("resource_debug")
@@ -97,6 +103,14 @@ either of the bottom 2 bits set:
print "funcB(size, mass, ...) defined";
}
If your the resource file needs to output special debugging informatin,
we recommend that you check for bit 3 of the config("resource_debug")
before printing the debug statement:
if (config("resource_debug") & 8) {
print "DEBUG: This a sample debug statement";
}
=-=
The following is a brief description of some of the calc resource files
@@ -128,6 +142,24 @@ bigprime.cal
A prime test, base a, on p*2^x+1 for even x>m.
chi.cal
Z(x[, eps])
P(x[, eps])
chi_prob(chi_sq, v[, eps])
Computes the Probability, given the Null Hypothesis, that a given
Chi squared values >= chi_sq with v degrees of freedom.
The chi_prob() function does not work well with odd degrees of freedom.
It is reasonable with even degrees of freedom, although one must give
a sifficently small error term as the degress gets large (>100).
The Z(x) and P(x) are internal statistical funcions.
eps is an optional epsilon() like error term.
chrem.cal
chrem(r1,m1 [,r2,m2, ...])
@@ -163,6 +195,33 @@ hello.cal
http://www.latech.edu/~acm/helloworld/calc.html
intfile.cal
file2be(filename)
Read filename and return an integer that is built from the
octets in that file in Big Endian order. The first octets
of the file become the most significant bits of the integer.
file2le(filename)
Read filename and return an integer that is built from the
octets in that file in Little Endian order. The first octets
of the file become the most significant bits of the integer.
be2file(v, filename)
Write the absolute value of v into filename in Big Endian order.
The v argument must be on integer. The most significant bits
of the integer become the first octets of the file.
le2file(v, filename)
Write the absolute value of v into filename in Little Endian order.
The v argument must be on integer. The least significant bits
of the integer become the last octets of the file.
lucas.cal
lucas(h, n)
@@ -756,8 +815,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.4 $
## @(#) $Id: README,v 29.4 2000/12/17 12:26:04 chongo Exp $
## @(#) $Revision: 29.8 $
## @(#) $Id: README,v 29.8 2001/03/31 16:26:23 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
##
## Under source code control: 1990/02/15 01:50:32

251
cal/chi.cal Normal file
View File

@@ -0,0 +1,251 @@
/*
* chi - chi^2 probabilities with degrees of freedom for null hypothesis
*
* 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.2 $
* @(#) $Id: chi.cal,v 29.2 2001/04/08 10:21:23 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/chi.cal,v $
*
* Under source code control: 2001/03/27 14:10:11
* File existed as early as: 2001
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
/*
* Z(x)
*
* From Handbook of Mathematical Functions
* 10th printing, Dec 1972 with corrections
* National Bureau of Standards
*
* Section 26.2.1, p931.
*/
define Z(x, eps_term)
{
local eps; /* error term */
/* obtain the error term */
if (isnull(eps_term)) {
eps = epsilon();
} else {
eps = eps_term;
}
/* compute Z(x) value */
return exp(-x*x/2, eps) / sqrt(2*pi(eps), eps);
}
/*
* P(x[, eps]) asymtotic P(x) expansion for x>0 to an given epsilon error term
*
* NOTE: If eps is omitted, the stored epsilon value is used.
*
* From Handbook of Mathematical Functions
* 10th printing, Dec 1972 with corrections
* National Bureau of Standards
*
* 26.2.11, p932:
*
* P(x) = 1/2 + Z(x) * sum(n=0; n < infinity){x^(2*n+1)/(1*3*5*...(2*n+1)};
*
* We continue the fraction until it is less than epsilon error term.
*
* Also note 26.2.5:
*
* P(x) + Q(x) = 1
*/
define P(x, eps_term)
{
local eps; /* error term */
local s; /* sum */
local x2; /* x^2 */
local x_term; /* x^(2*r+1) */
local odd_prod; /* 1*3*5* ... */
local odd_term; /* next odd value to multiply into odd_prod */
local term; /* the recent term added to the sum */
/* obtain the error term */
if (isnull(eps_term)) {
eps = epsilon();
} else {
eps = eps_term;
}
/* firewall */
if (x <= 0) {
if (x == 0) {
return 0; /* hack */
} else {
quit "Q(x[,eps]) 1st argument must be >= 0";
}
}
if (eps <= 0) {
quit "Q(x[,eps]) 2nd argument must be > 0";
}
/*
* aproximate sum(n=0; n < infinity){x^(2*n+1)/(1*3*5*...(2*n+1)}
*/
x2 = x*x;
x_term = x;
s = x_term; /* 1st term */
odd_term = 1;
odd_prod = 1;
do {
/* compute the term */
odd_term += 2;
odd_prod *= odd_term;
x_term *= x2;
term = x_term / odd_prod;
s += term;
} while (term >= eps);
/* apply term and factor */
return 0.5 + Z(x,eps)*s;
}
/*
* chi_prob(chi_sq, v[, eps]) - Prob of >= chi^2 with v degrees of freedom
*
* Computes the Probability, given the Null Hypothesis, that a given
* Chi squared values >= chi_sq with v degrees of freedom.
*
* The chi_prob() function does not work well with odd degrees of freedom.
* It is reasonable with even degrees of freedom, although one must give
* a sifficently small error term as the degress gets large (>100).
*
* NOTE: This function does not work well with odd degrees of freedom.
* Can somebody help / find a bug / provide a better method of
* this odd degrees of freedom case?
*
* NOTE: This function works well with even degrees of freedom. However
* when the even degrees gets large (say, as you approach 100), you
* need to increase your error term.
*
* From Handbook of Mathematical Functions
* 10th printing, Dec 1972 with corrections
* National Bureau of Standards
*
* Section 26.4.4, p941:
*
* For odd v:
*
* Q(chi_sq, v) = 2*Q(chi) + 2*Z(chi) * (
* sum(r=1, r<=(r-1)/2) {(chi_sq^r/chi) / (1*3*5*...(2*r-1)});
*
* chi = sqrt(chi_sq)
*
* NOTE: Q(x) = 1-P(x)
*
* Section 26.4.5, p941.
*
* For even v:
*
* Q(chi_sq, v) = sqrt(2*pi()) * Z(chi) * ( 1 +
* sum(r=1, r=((v-2)/2)) { chi_sq^r / (2*4*...*(2r)) } );
*
* chi = sqrt(chi_sq)
*
* Observe that:
*
* Z(x) = exp(-x*x/2) / sqrt(2*pi()); (Section 26.2.1, p931)
*
* and thus:
*
* sqrt(2*pi()) * Z(chi) =
* sqrt(2*pi()) * Z(sqrt(chi_sq)) =
* sqrt(2*pi()) * exp(-sqrt(chi_sq)*sqrt(chi_sq)/2) / sqrt(2*pi()) =
* exp(-sqrt(chi_sq)*sqrt(chi_sq)/2) =
* exp(-sqrt(-chi_sq/2)
*
* So:
*
* Q(chi_sq, v) = exp(-sqrt(-chi_sq/2) * ( 1 + sum(....){...} );
*/
define chi_prob(chi_sq, v, eps_term)
{
local eps; /* error term */
local r; /* index in finite sum */
local r_lim; /* limit value for r */
local s; /* sum */
local d; /* demoninator (2*4*6*... or 1*3*5...) */
local chi_term; /* chi_sq^r */
local ret; /* return value */
/* obtain the error term */
if (isnull(eps_term)) {
eps = epsilon();
} else {
eps = eps_term;
}
/*
* odd degrees of freedom
*/
if (isodd(v)) {
local chi; /* sqrt(chi_sq) */
/* setup for sum */
s = 1;
d = 1;
chi = sqrt(abs(chi_sq), eps);
chi_term = chi;
r_lim = (v-1)/2;
/* compute sum(r=1, r=((v-1)/2)) {(chi_sq^r/chi) / (1*3*5...*(2r-1))} */
for (r=2; r <= r_lim; ++r) {
chi_term *= chi_sq;
d *= (2*r)-1;
s += chi_term/d;
}
/* apply term and factor, Q(x) = 1-P(x) */
ret = 2*(1-P(chi)) + 2*Z(chi)*s;
/*
* even degrees of freedom
*/
} else {
/* setup for sum */
s =1;
d = 1;
chi_term = 1;
r_lim = (v-2)/2;
/* compute sum(r=1, r=((v-2)/2)) { chi_sq^r / (2*4*...*(2r)) } */
for (r=1; r <= r_lim; ++r) {
chi_term *= chi_sq;
d *= r*2;
s += chi_term/d;
}
/* apply factor - see observation in the main comment above */
ret = exp(-chi_sq/2, eps) * s;
}
return ret;
}

222
cal/intfile.cal Normal file
View File

@@ -0,0 +1,222 @@
/*
* intfile - integer to file and file to integer conversion
*
* 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.5 $
* @(#) $Id: intfile.cal,v 29.5 2001/04/10 22:09:34 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/intfile.cal,v $
*
* Under source code control: 2001/03/31 08:13:11
* File existed as early as: 2001
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
/*
* NOTE: Because leading HALF values are trimmed from integer, a file
* that begins with lots of 0 bits (in the case of big endian)
* or that ends with lots of 0 bits (in the case of little endian)
* will be changed when the subsequent integer is written back.
*/
/*
* file2be - convert a file into an big endian integer
*
* given:
* filename filename to read
*
* returns:
* integer read from its contents on big endian order
*/
define file2be(filename)
{
local fd; /* open file */
local ret; /* integer to return */
local c; /* character read from the file */
local i;
/*
* open the file for reading
*/
fd = fopen(filename, "rb");
if (!isfile(fd)) quit "file2be: cannot open file for reading";
/*
* read the contents of the file
*
* The first octets become the most significant bits of the integer.
*/
ret = 0;
while (! isnull(c = fgetc(fd))) {
ret <<= 8;
ret += ord(c);
}
/*
* cleanup and return the integer
*/
fclose(fd);
return ret;
}
/*
* file2le - convert a file into an little endian integer
*
* given:
* filename filename to read
*
* returns:
* integer read from its contents on little endian order
*/
define file2le(filename)
{
local fd; /* open file */
local ret; /* integer to return */
local c; /* character read from the file */
local shft; /* bit shift for the c value */
local i;
/*
* open the file for reading
*/
fd = fopen(filename, "rb");
if (!isfile(fd)) quit "file2le: cannot open file for reading";
/*
* read the contents of the file into a string
*
* The first octets become are the least significant bits of the integer.
*/
ret = 0;
shft = 0;
while (! isnull(c = fgetc(fd))) {
ret |= (ord(c) << shft);
shft += 8;
}
/*
* cleanup and return the integer
*/
fclose(fd);
return ret;
}
/*
* be2file - convert a big endian integer into a file
*
* given:
* v integer to write to the file
* filename filename to write
*
* returns:
* The number of octets written to the file.
*
* NOTE: The absolute value of the integer is written to the file.
*/
define be2file(v, filename)
{
local fd; /* open file */
local octlen; /* length of v in octets */
local i;
/*
* firewall
*/
if (!isint(v)) {
quit "be2file: 1st arg not an integer";
}
v = abs(v);
/*
* open the file for writing
*/
fd = fopen(filename, "wb");
if (!isfile(fd)) quit "be2file: cannot open file for writing";
/*
* write the octets to the file
*
* The most significant bits of the integer become the first file octets.
*/
octlen = int((highbit(v)+8) / 8);
for (i=octlen-1; i >= 0; --i) {
fputc(fd, char(v >> (i*8)));
}
/*
* cleanup
*/
fclose(fd);
return octlen;
}
/*
* le2file - convert a little endian integer into a file
*
* given:
* v integer to write to the file
* filename filename to write
*
* returns:
* The number of octets written to the file.
*
* NOTE: The absolute value of the integer is written to the file.
*/
define le2file(v, filename)
{
local fd; /* open file */
local cnt; /* octets written */
/*
* firewall
*/
if (!isint(v)) {
quit "be2file: 1st arg not an integer";
}
v = abs(v);
/*
* open the file for writing
*/
fd = fopen(filename, "wb");
if (!isfile(fd)) quit "le2file: cannot open file for writing";
/*
* Write the octets to the file.
*
* The least significant bits of the integer become the first file octets.
*/
cnt = 0;
while (v > 0) {
fputc(fd, char(v));
v >>= 8;
++cnt;
}
/*
* cleanup
*/
fclose(fd);
return cnt;
}

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: lucas.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: lucas.cal,v 29.3 2001/03/31 13:31:34 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas.cal,v $
*
* Under source code control: 1990/05/03 16:49:51
@@ -1030,7 +1030,7 @@ gen_v1(h, n)
define
ldebug(funct, str)
{
if (config("resource_debug") & 3) {
if (config("resource_debug") & 8) {
print "DEBUG:", funct:":", str;
}
return;

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: lucas_chk.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: lucas_chk.cal,v 29.3 2001/03/31 13:31:34 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/lucas_chk.cal,v $
*
* Under source code control: 1991/01/11 05:41:43
@@ -336,7 +336,7 @@ lucas_chk(high_n, quiet)
/* skip primes where h>=2^n */
if (highbit(h_p[i]) >= n_p[i]) {
if (config("resource_debug") & 3) {
if (config("resource_debug") & 8) {
print "h>=2^n skip:", h_p[i]:"*2^":n_p[i]:"-1";
}
continue;

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.6 $
* @(#) $Id: regress.cal,v 29.6 2000/12/17 12:26:42 chongo Exp $
* @(#) $Revision: 29.8 $
* @(#) $Id: regress.cal,v 29.8 2001/04/10 22:08:20 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
*
* Under source code control: 1990/02/15 01:50:36
@@ -411,10 +411,10 @@ define test_config()
'516: config("pow2") == 40');
vrfy(config("redc2") == 50,
'517: config("redc2") == 50');
vrfy(config("tilde") == "true",
'518: config("tilde") == "true"');
vrfy(config("tab") == "true",
'519: config("tab") == "true"');
vrfy(config("tilde"),
'518: config("tilde")');
vrfy(config("tab"),
'519: config("tab")');
vrfy(config("quomod") == 0,
'520: config("quomod") == 0');
vrfy(config("quo") == 2,
@@ -433,10 +433,10 @@ define test_config()
'527: config("outround") == 2');
vrfy(config("round") == 24,
'528: config("round") == 24');
vrfy(config("leadzero") == "false",
'529: config("leadzero") == "false"');
vrfy(config("fullzero") == "false",
'530: config("fullzero") == "false"');
vrfy(config("leadzero") == 0,
'529: config("leadzero") == 0');
vrfy(config("fullzero") == 0,
'530: config("fullzero") == 0');
vrfy(config("maxscan") == 20,
'531: config("maxscan") == 20');
vrfy(config("prompt") == "> ",
@@ -452,10 +452,10 @@ define test_config()
vrfy(config("quo", 0) == 2, '536: config("quo", 0) == 2');
vrfy(config("outround", 24) == 2,
'537: config("outround", 24) == 2');
vrfy(config("leadzero","y") == "false",
'538: config("leadzero","y") == "false"');
vrfy(config("fullzero", 1) == "false",
'539: config("fullzero", 1) == "false"');
vrfy(config("leadzero","y") == 0,
'538: config("leadzero","y") == 0');
vrfy(config("fullzero", 1) == 0,
'539: config("fullzero", 1) == 0');
vrfy(config("prompt", "; ") == "> ",
'540: config("prompt", "; ") == "> "');
vrfy(config("more", ";; ") == ">> ",
@@ -467,14 +467,14 @@ define test_config()
'543: config("all",callcfg) == newcfg');
vrfy(config("display",2) == 20,
'544: config("display",2) == 20');
vrfy(config("fullzero",1) == "false",
'545: config("fullzero",1) == "false"');
vrfy(config("fullzero",1) == 0,
'545: config("fullzero",1) == 0');
vrfy(strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00",
'546: strprintf("%d %d %d", 0, 1, 2) == ".00 1.00 2.00"');
vrfy(config("display",20) == 2,
'547: config("display",20) == 2');
vrfy(config("fullzero",0) == "true",
'548: config("fullzero",0) == "true"');
vrfy(config("fullzero",0),
'548: config("fullzero",0)');
vrfy(strprintf("%d %d %d", 0, 1, 2) == "0 1 2",
'549: strprintf("%d %d %d", 0, 1, 2) == "0 1 2"');
@@ -996,8 +996,13 @@ define test_functions()
vrfy(strpos(a, "abc") == 1, '946: strpos(a, "abc") == 1');
vrfy(strpos(a, "xyz") == 0, '947: strpos(a, "xyz") == 0');
vrfy(strpos(a, a) == 1, '948: strpos(a, a) == 1');
vrfy(system("") == 0, '949: system("") == 0');
vrfy(system("true") == 0, '950: system("true") == 0');
if (config("windows")) {
print '949: test skipped for windows systems';
print '950: test skipped for windows systems';
} else {
vrfy(system("") == 0, '949: system("") == 0');
vrfy(system("true") == 0, '950: system("true") == 0');
}
print '951: test disabled due to stdin dependency';
print '952: test removed';
print '953: test removed';
@@ -5112,10 +5117,17 @@ define test_is()
*/
a = assoc();
print '5901: a = assoc()';
ofd = fopen("/dev/null", "r");
print '5902: ofd = fopen("/dev/null", "r")';
cfd = fopen("/dev/null", "r");
print '5903: cfd = fopen("/dev/null", "r")';
if (config("windows")) {
ofd = fopen("NUL:", "rb");
print '5902: ofd = fopen("NUL:", "rb")';
cfd = fopen("NUL:", "rb");
print '5903: cfd = fopen("NUL:", "rb")';
} else {
ofd = fopen("/dev/null","rb");
print '5902: ofd = fopen("/dev/null","rb")';
cfd = fopen("/dev/null","rb");
print '5903: cfd = fopen("/dev/null","rb")';
}
fclose(cfd);
print '5904: fclose(cfd)';
blk = blk();
@@ -6293,8 +6305,8 @@ define test_blkcpy()
/* blkcpy the last 5 octets of B1 to a new block C */
blkcpy(C = blk(), B1, 5, ,100);
print '6821: blkcpy(C = blk(), B1, 5, ,100);';
blkcpy(C = blk(), B1,5,,100);
print '6821: blkcpy(C = blk(), B1,5,,100);';
vrfy(C == A, '6822: C == A');
/* blkcpy to and from a file */
@@ -6310,8 +6322,8 @@ define test_blkcpy()
blkcpy(fs, A, ,100);
print '6828: blkcpy(fs, A, ,100);';
vrfy(size(fs) == 105, '6829: size(f) == 105');
blkcpy(C = blk(), fs, 2, ,100);
print '6830: blkcpy(C = blk(), fs, 2, ,100)';
blkcpy(C = blk(), fs,2,,100);
print '6830: blkcpy(C = blk(), fs,2,,100)';
vrfy(C == (blk() = {1,2}), '6831: C == (blk() = {1,2}');
/* blkcpy string to a block */

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: seedrandom.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: seedrandom.cal,v 29.3 2001/03/31 13:31:34 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/seedrandom.cal,v $
*
* Under source code control: 1996/01/01 08:21:00
@@ -115,7 +115,7 @@ define seedrandom(seed1, seed2, size, trials)
p = 2*fp+1;
} while (ptest(p,1,0) == 0);
} while(ptest(p, trials) == 0 || ptest(fp, trials) == 0);
if (config("resource_debug") & 3) {
if (config("resource_debug") & 8) {
print "/* 1st Blum prime */ p=", p;
}
@@ -129,7 +129,7 @@ define seedrandom(seed1, seed2, size, trials)
q = 2*fq+1;
} while (ptest(q,1,0) == 0);
} while(ptest(q, trials) == 0 || ptest(fq, trials) == 0);
if (config("resource_debug") & 3) {
if (config("resource_debug") & 8) {
print "/* 2nd Blum prime */ q=", q;
}
@@ -139,7 +139,7 @@ define seedrandom(seed1, seed2, size, trials)
n = p*q; /* the Blum modulus */
binsize = highbit(n)+1; /* smallest power of 2 > p*q */
r = pmod(rand(1<<ceil(binsize*4/5), 1<<(binsize-2)), 2, n);
if (config("resource_debug") & 3) {
if (config("resource_debug") & 8) {
print "/* seed quadratic residue */ r=", r;
print "/* newn", binsize, "bit quadratic residue*/ newn=", n;
}

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test4600.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: test4600.cal,v 29.4 2001/04/10 22:09:02 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4600.cal,v $
*
* Under source code control: 1996/07/02 20:04:40
@@ -53,10 +53,10 @@ define stest(str, verbose)
/*
* do file operations
*/
f = fopen("junk4600", "w");
f = fopen("junk4600", "wb");
if (iserror(f)) {
print 'failed';
print '**** fopen("junk4600", "w") failed';
print '**** fopen("junk4600", "wb") failed';
return 1;
}
if (iserror(fputs(f,
@@ -67,9 +67,9 @@ define stest(str, verbose)
print '**** fputs(f, "Fourscore ... failed';
return 1;
}
if (iserror(freopen(f, "r"))) {
if (iserror(freopen(f, "rb"))) {
print 'failed';
print '**** iserror(freopen(f, "r")) failed';
print '**** iserror(freopen(f, "rb")) failed';
return 1;
}
if (iserror(rewind(f))) {
@@ -173,7 +173,7 @@ define ttest(str, m, n, verbose)
print str:":",:;
}
i = rm("-f", "junk4600");
f = fopen("junk4600", "w");
f = fopen("junk4600", "wb");
if (isnull(n))
n = 4;
@@ -198,7 +198,7 @@ define ttest(str, m, n, verbose)
fflush(f);
if (verbose > 1)
printf("File has size %d\n", pos[i]);
freopen(f, "r");
freopen(f, "rb");
if (size(f) != pos[i]) {
print 'failed';
printf("**** Failure 1 for file size\n");

42
calc.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.6 $
* @(#) $Id: calc.c,v 29.6 2001/02/25 22:07:36 chongo Exp $
* @(#) $Revision: 29.8 $
* @(#) $Id: calc.c,v 29.8 2001/04/10 22:03:13 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
*
* Under source code control: 1990/02/15 01:48:11
@@ -32,20 +32,25 @@
#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
#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
# include "../getopt/getopt.h"
# define strdup _strdup
# define isatty _isatty
#endif /* Windoz */
#define CALC_C
@@ -61,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)
@@ -619,9 +625,18 @@ main(int argc, char **argv)
if (!p_flag && i_flag && !stdin_tty) {
closeinput();
if(!freopen("/dev/tty", "r", stdin)) {
#if defined (_WIN32)
fprintf(stderr,
"/dev/tty does not exist on "
"this operating system. "
"Change operating systems\n"
"or don't use this calc mode "
"in the future, sorry!\n");
#else /* Windoz free systems */
fprintf(stderr,
"Unable to associate stdin"
" with /dev/tty");
#endif /* Windoz free systems */
set_run_state(RUN_EXIT_WITH_ERROR);
break;
}
@@ -640,9 +655,18 @@ main(int argc, char **argv)
!p_flag && (!havecommands||i_flag)) {
closeinput();
if(!freopen("/dev/tty", "r", stdin)) {
#if defined (_WIN32)
fprintf(stderr,
"/dev/tty does not exist on "
"this operating system. "
"Change operating systems\n"
"or don't use this calc mode "
"in the future, sorry!\n");
#else /* Windoz free systems */
fprintf(stderr,
"Unable to associate stdin"
" with /dev/tty");
#endif /* Windoz free systems */
set_run_state(RUN_EXIT_WITH_ERROR);
break;
}

229
calc.h
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.5 $
* @(#) $Id: calc.h,v 29.5 2000/12/04 19:32:33 chongo Exp $
* @(#) $Revision: 29.6 $
* @(#) $Id: calc.h,v 29.6 2001/03/17 21:31:47 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.h,v $
*
* Under source code control: 1990/02/15 01:48:31
@@ -32,9 +32,8 @@
#define __CALC_H__
#include <setjmp.h>
#include "win32dll.h"
#include "value.h"
#include "have_const.h"
@@ -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__ */

View File

@@ -15,8 +15,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: calc.man,v 29.5 2000/06/07 14:02:13 chongo Exp $
.\" @(#) $Revision: 29.6 $
.\" @(#) $Id: calc.man,v 29.6 2001/04/10 21:48:46 chongo Exp $
.\" @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.man,v $
.\"
.\" Under source code control: 1991/07/23 05:48:26
@@ -36,20 +36,21 @@ calc \- arbitrary precision calculator
.RB [ \-c ]
.RB [ \-C ]
.RB [ \-d ]
.RB [ -D\ \&calc_debug[:resource_debug[:user_debug]] ]
.br
.in +5n
.RB [ -D\ \&calc_debug[:resource_debug[:user_debug]] ]
.br
.RB [ \-e ]
.RB [ \-h ]
.RB [ \-i ]
.RB [ \-m\ \&mode ]
.RB [ \-n ]
.br
.RB [ \-p ]
.RB [ \-q ]
.RB [ \-s ]
.RB [ \-u ]
.RB [ \-v ]
.br
.RB [ calc_cmd\ \&.\|.\|. ]
.in -5n
.sp

View File

@@ -17,8 +17,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.3 $
# @(#) $Id: calcerr.tbl,v 29.3 2000/07/17 15:35:49 chongo Exp $
# @(#) $Revision: 29.4 $
# @(#) $Id: calcerr.tbl,v 29.4 2001/04/10 22:06:46 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr.tbl,v $
#
# Under source code control: 1996/05/23 17:38:44
@@ -108,8 +108,8 @@ E_FGETSTR1 Non-file first argument for fgetstr
E_FGETSTR2 File not open for reading for fgetstr
E_FGETLINE1 Non-file argument for fgetline
E_FGETLINE2 File not open for reading for fgetline
E_FGETWORD1 Non-file argument for fgetword
E_FGETWORD2 File not open for reading for fgetword
E_FGETFIELD1 Non-file argument for fgetfield
E_FGETFIELD2 File not open for reading for fgetfield
E_REWIND1 Non-file argument for rewind
E_FILES Non-integer argument for files
E_PRINTF1 Non-string fmt argument for fprint

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: codegen.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: codegen.c,v 29.4 2001/03/17 21:31:47 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/codegen.c,v $
*
* Under source code control: 1990/02/15 01:48:13
@@ -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;

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: config.c,v 29.4 2000/07/17 15:35:49 chongo Exp $
* @(#) $Revision: 29.6 $
* @(#) $Id: config.c,v 29.6 2001/04/08 10:07:19 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
*
* Under source code control: 1991/07/20 00:21:56
@@ -90,6 +90,7 @@ NAMETYPE configs[] = {
{"ctrl-d", CONFIG_CTRL_D}, /* alias for ctrl_d */
{"program", CONFIG_PROGRAM},
{"basename", CONFIG_BASENAME},
{"windows", CONFIG_WINDOWS},
{"version", CONFIG_VERSION},
{NULL, 0}
};
@@ -136,6 +137,11 @@ CONFIG oldstd = { /* backward compatible standard configuration */
CTRL_D_VIRGIN_EOF, /* ^D only exits on virgin lines */
NULL, /* our name */
NULL, /* basename of our name */
#if defined(_WIN32)
TRUE, /* running under windows */
#else
FALSE, /* congrats, you are not using windows */
#endif
NULL /* version */
};
CONFIG newstd = { /* new non-backward compatible configuration */
@@ -176,6 +182,11 @@ CONFIG newstd = { /* new non-backward compatible configuration */
CTRL_D_VIRGIN_EOF, /* ^D only exits on virgin lines */
NULL, /* our name */
NULL, /* basename of our name */
#if defined(_WIN32)
TRUE, /* running under windows */
#else
FALSE, /* congrats, you are not using windows */
#endif
NULL /* version */
};
CONFIG *conf = NULL; /* loaded in at startup - current configuration */
@@ -822,11 +833,15 @@ setconfig(int type, VALUE *vp)
/*NOTREACHED*/
case CONFIG_BASENAME:
math_error("The program config parameter is read-only");
math_error("The basename config parameter is read-only");
/*NOTREACHED*/
case CONFIG_WINDOWS:
math_error("The windows config parameter is read-only");
/*NOTREACHED*/
case CONFIG_VERSION:
math_error("The program config parameter is read-only");
math_error("The version config parameter is read-only");
/*NOTREACHED*/
default:
@@ -1028,20 +1043,18 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
break;
case CONFIG_TILDE:
vp->v_type = V_STR;
if (cfg->tilde_ok) {
vp->v_str = makenewstring(TRUE_STRING);
vp->v_num = itoq(1);
} else {
vp->v_str = makenewstring(FALSE_STRING);
vp->v_num = itoq(0);
}
return;
case CONFIG_TAB:
vp->v_type = V_STR;
if (cfg->tab_ok) {
vp->v_str = makenewstring(TRUE_STRING);
vp->v_num = itoq(1);
} else {
vp->v_str = makenewstring(FALSE_STRING);
vp->v_num = itoq(0);
}
return;
@@ -1082,20 +1095,18 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
break;
case CONFIG_LEADZERO:
vp->v_type = V_STR;
if (cfg->leadzero) {
vp->v_str = makenewstring(TRUE_STRING);
vp->v_num = itoq(1);
} else {
vp->v_str = makenewstring(FALSE_STRING);
vp->v_num = itoq(0);
}
return;
case CONFIG_FULLZERO:
vp->v_type = V_STR;
if (cfg->fullzero) {
vp->v_str = makenewstring(TRUE_STRING);
vp->v_num = itoq(1);
} else {
vp->v_str = makenewstring(FALSE_STRING);
vp->v_num = itoq(0);
}
return;
@@ -1118,11 +1129,10 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
break;
case CONFIG_BLKVERBOSE:
vp->v_type = V_STR;
if (cfg->blkverbose) {
vp->v_str = makenewstring(TRUE_STRING);
vp->v_num = itoq(1);
} else {
vp->v_str = makenewstring(FALSE_STRING);
vp->v_num = itoq(0);
}
return;
@@ -1159,11 +1169,10 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
break;
case CONFIG_VERBOSE_QUIT:
vp->v_type = V_STR;
if (cfg->verbose_quit) {
vp->v_str = makenewstring(TRUE_STRING);
vp->v_num = itoq(1);
} else {
vp->v_str = makenewstring(FALSE_STRING);
vp->v_num = itoq(0);
}
return;
@@ -1195,6 +1204,14 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
}
return;
case CONFIG_WINDOWS:
if (cfg->windows) {
vp->v_num = itoq(1);
} else {
vp->v_num = itoq(0);
}
return;
case CONFIG_VERSION:
vp->v_type = V_STR;
if (cfg->version == NULL) {
@@ -1295,6 +1312,7 @@ config_cmp(CONFIG *cfg1, CONFIG *cfg2)
(cfg1->version == NULL && cfg2->version != NULL) ||
(cfg1->version != NULL && cfg2->version == NULL) ||
cfg1->windows != cfg2->windows ||
(cfg1->version != NULL && cfg2->version != NULL &&
strcmp(cfg1->version, cfg2->version) != 0);
}

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.5 $
* @(#) $Id: config.h,v 29.5 2001/02/25 22:07:36 chongo Exp $
* @(#) $Revision: 29.8 $
* @(#) $Id: config.h,v 29.8 2001/04/08 09:08:57 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.h,v $
*
* Under source code control: 1995/11/01 22:20:17
@@ -35,20 +35,7 @@
#define __CONFIG_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 */
#include "win32dll.h"
#include "nametype.h"
#include "qmath.h"
@@ -96,6 +83,7 @@
#define CONFIG_PROGRAM 35
#define CONFIG_BASENAME 36
#define CONFIG_VERSION 37
#define CONFIG_WINDOWS 38
/*
@@ -160,6 +148,7 @@ struct config {
int ctrl_d; /* see CTRL_D_xyz below */
char *program; /* our name */
char *base_name; /* basename of our name */
BOOL windows; /* TRUE => running under MS windows */
char *version; /* calc version string */
};
typedef struct config CONFIG;
@@ -171,7 +160,8 @@ typedef struct config CONFIG;
#define RSCDBG_STDIN_FUNC (0x00000001) /* interactive func define debug */
#define RSCDBG_FILE_FUNC (0x00000002) /* file read func define debug */
#define RSCDBG_FUNC_INFO (0x00000004) /* print extra info for show func */
#define RSCDBG_MASK (0x00000007)
#define RSCDBG_PRINT_DBG (0x00000008) /* print debug messages */
#define RSCDBG_MASK (0x0000000f)
/*
@@ -196,23 +186,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
*/
DLL extern CONFIG *config_copy(CONFIG *src);
DLL extern void config_free(CONFIG *cfg);
DLL extern void config_print(CONFIG *cfg);
DLL extern int configtype(char*);
DLL extern void config_print(CONFIG*);
DLL 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__ */

View File

@@ -17,8 +17,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.6 $
# @(#) $Id: Makefile,v 29.6 2000/12/15 14:56:14 chongo Exp $
# @(#) $Revision: 29.9 $
# @(#) $Id: Makefile,v 29.9 2001/04/08 10:53:52 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
#
# Under source code control: 1999/11/29 11:10:26
@@ -76,9 +76,10 @@ FMT= fmt
#
# make detaillist
#
SCRIPT= mersenne piforever plus simple square
SCRIPT= mersenne piforever plus simple square fproduct
SCRIPT_SRC= mersenne.calc piforever.calc plus.calc simple.calc square.calc
SCRIPT_SRC= mersenne.calc piforever.calc plus.calc simple.calc square.calc \
fproduct.calc
# These files are found (but not built) in the distribution
#
@@ -114,7 +115,7 @@ all: ${SCRIPT} ${SCRIPT_SRC} .all
distlist: ${DISTLIST}
${Q}for i in ${DISTLIST}; do \
echo cscript/$$i; \
done | ${SORT}
done | LANG=C ${SORT}
distdir:
${Q}echo cscript
@@ -131,7 +132,7 @@ detaillist:
else \
echo $$i; \
fi; \
done | ${SORT}) | ${FMT} -70 | \
done | LANG=C ${SORT}) | ${FMT} -70 | \
${SED} -e '1s/xxxxxxx/SCRIPT=/' -e '2,$$s/^/ /' \
-e 's/$$/ \\/' -e '$$s/ \\$$//'
${Q}echo
@@ -142,7 +143,7 @@ detaillist:
else \
echo $$i.calc; \
fi; \
done | ${SORT}) | ${FMT} -70 | \
done | LANG=C ${SORT}) | ${FMT} -70 | \
${SED} -e '1s/xxxxxxxxxxx/SCRIPT_SRC=/' -e '2,$$s/^/ /' \
-e 's/$$/ \\/' -e '$$s/ \\$$//'
@@ -249,3 +250,7 @@ square: square.calc
rm -f $@
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
${CHMOD} +x $@
fproduct: fproduct.calc
rm -f $@
${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
${CHMOD} +x $@

View File

@@ -19,6 +19,11 @@ For more info, see:
=-=
fproduct filename term ...
Write the big Endian product of terms to a file. Use - for stdout.
mersenne exp
Print the value of 2^exp-1.
@@ -54,8 +59,8 @@ simple
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.4 $
## @(#) $Id: README,v 29.4 2000/06/07 14:02:59 chongo Exp $
## @(#) $Revision: 29.5 $
## @(#) $Id: README,v 29.5 2001/04/08 08:24:40 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/README,v $
##
## Under source code control: 1999/12/17 10:23:40

88
cscript/fproduct.calc Normal file
View File

@@ -0,0 +1,88 @@
#!/usr/local/bin/calc -q -s -f
/*
* fproduct - write the big Endian product of terms to a file
*
* usage:
* fproduct filename term [term ...]
*
* filename where to write the product, use - for stdout
* term ... terms to multiply
*
* 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: fproduct.calc,v 29.1 2001/04/08 08:25:15 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/fproduct.calc,v $
*
* Under source code control: 2001/04/07 20:13:11
* File existed as early as: 2001
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
/*
* parse args
*/
argc = argv();
if (argc < 2) {
fprintf(files(2), "usage: %s term [term ...]\n", argv(0));
exit;
}
filename = argv(1);
/*
* build the product
*/
product = 1;
for (i=2; i < argc; ++i) {
product *= eval(argv(i));
}
product = abs(product);
/*
* open the file for writing, "-" is stdout
*/
if (filename == "-") {
fd = files(1);
} else {
fd = fopen(filename, "w");
if (!isfile(fd)) quit "be2file: cannot open file for writing";
}
/*
* write the octets to the file
*
* The most significant bits of the integer become the first file octets.
*/
if (product > 0) {
octlen = int((highbit(product)+8) / 8);
for (i=octlen-1; i >= 0; --i) {
fputc(fd, char(product >> (i*8)));
}
}
/*
* cleanup
*/
if (filename != "-") {
fclose(fd);
}

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.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"

View File

@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.3 $
# @(#) $Id: Makefile,v 29.3 2000/12/17 12:28:15 chongo Exp $
# @(#) $Revision: 29.6 $
# @(#) $Id: Makefile,v 29.6 2001/04/08 10:53:52 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/Makefile,v $
#
# Under source code control: 1997/03/09 02:28:54
@@ -432,7 +432,8 @@ depend:
${Q}mv Makefile Makefile.bak
${Q}${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak > Makefile
${Q}echo "" >> Makefile
${Q}${SED} -n '3,$$p' skel/custom/makedep.out | ${SORT} -u >> Makefile
${Q}${SED} -n '3,$$p' skel/custom/makedep.out | \
LANG=C ${SORT} -u >> Makefile
-${Q}rm -rf skel
-${Q}if cmp -s Makefile.bak Makefile; then \
echo 'custom Makefile was already up to date'; \
@@ -460,7 +461,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 \
@@ -537,11 +538,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
@@ -557,16 +560,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
@@ -582,16 +586,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
@@ -607,18 +612,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
@@ -632,20 +638,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
@@ -663,14 +670,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
@@ -678,6 +685,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
@@ -690,9 +698,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

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.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;
}

150
file.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.5 $
* @(#) $Id: file.c,v 29.5 2001/02/25 22:07:36 chongo Exp $
* @(#) $Revision: 29.7 $
* @(#) $Id: file.c,v 29.7 2001/04/10 22:06:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/file.c,v $
*
* Under source code control: 1991/07/20 00:21:56
@@ -37,7 +37,7 @@
#include <stdlib.h>
#include "have_unistd.h"
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <ctype.h>
#include "calc.h"
@@ -48,6 +48,10 @@
#include "file.h"
#include "calcerr.h"
#if defined(_WIN32)
# include <io.h>
#endif
#define READSIZE 1024 /* buffer size for reading */
/*
@@ -154,7 +158,7 @@ file_init(void)
} else {
fp = (FILE *) fdopen(i, "w");
if (fp) {
strcpy(files[idnum].mode, "w?");
strcpy(files[idnum].mode, "w");
files[idnum].reading = FALSE;
}
else
@@ -203,7 +207,7 @@ openid(char *name, char *mode)
int i;
if (idnum >= MAXFILES)
return -77;
return -E_FOPEN3;
fiop = &files[3];
for (i = 3; i < MAXFILES; fiop++,i++) {
@@ -239,11 +243,32 @@ openid(char *name, char *mode)
fiop->reading = TRUE;
fiop->writing = TRUE;
fiop->action = 0;
if (mode[1] == '\0') {
if (*mode == 'r')
/*
* determine file open mode
*
* While a leading 'r' is for reading and a leading 'w' is
* for writing, the presense of a '+' in the string means
* both reading and writing. A leading 'a' means append
* which is writing.
*/
if (mode[0] == 'r') {
fiop->reading = TRUE;
if (strchr(mode, '+') == NULL) {
fiop->writing = FALSE;
else
} else {
fiop->writing = TRUE;
}
} else if (mode[0] == 'w' || mode[0] == 'a') {
fiop->writing = TRUE;
if (strchr(mode, '+') == NULL) {
fiop->reading = FALSE;
} else {
fiop->reading = TRUE;
}
} else {
fiop->reading = FALSE;
fiop->writing = FALSE;
}
strcpy(fiop->mode, mode);
return id;
@@ -342,11 +367,32 @@ reopenid(FILEID id, char *mode, char *name)
fiop->reading = TRUE;
fiop->writing = TRUE;
fiop->action = 0;
if (mode[1] == '\0') {
if (*mode == 'r')
/*
* determine file open mode
*
* While a leading 'r' is for reading and a leading 'w' is
* for writing, the presense of a '+' in the string means
* both reading and writing. A leading 'a' means append
* which is writing.
*/
if (mode[0] == 'r') {
fiop->reading = TRUE;
if (strchr(mode, '+') == NULL) {
fiop->writing = FALSE;
else
} else {
fiop->writing = TRUE;
}
} else if (mode[0] == 'w' || mode[0] == 'a') {
fiop->writing = TRUE;
if (strchr(mode, '+') == NULL) {
fiop->reading = FALSE;
} else {
fiop->reading = TRUE;
}
} else {
fiop->reading = FALSE;
fiop->writing = FALSE;
}
strcpy(fiop->mode, mode);
return id;
@@ -354,13 +400,13 @@ reopenid(FILEID id, char *mode, char *name)
/*
* Find the file I/O structure for the specified file id, and verify that
* it is opened in the required manner ('r' for reading or 'w' for writing).
* If mode is 0, then no open checks are made at all, and NULL is then
* Find the file I/O structure for the specified file id, and verifies that
* it is opened in the required manner (0 for reading or 1 for writing).
* If writable is -1, then no open checks are made at all and NULL is then
* returned if the id represents a closed file.
*/
FILEIO *
findid(FILEID id, int mode)
findid(FILEID id, int writable)
{
FILEIO *fiop; /* file structure */
int i;
@@ -379,21 +425,11 @@ findid(FILEID id, int mode)
if (i == idnum)
return NULL;
switch (mode) {
case 'r':
if (!fiop->reading)
return NULL;
break;
case 'w':
if (!fiop->writing)
return NULL;
break;
case 0:
break;
default:
/* This should not happen */
math_error("Unknown findid mode");
/*NOTREACHED*/
if (writable >= 0) {
if ((writable && !fiop->writing) ||
(!writable && !fiop->reading)) {
return NULL;
}
}
return fiop;
}
@@ -405,7 +441,7 @@ findid(FILEID id, int mode)
BOOL
validid(FILEID id)
{
return (findid(id, 0) != NULL);
return (findid(id, -1) != NULL);
}
@@ -501,7 +537,7 @@ errorid(FILEID id)
{
FILEIO *fiop; /* file structure */
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL)
return EOF;
return (ferror(fiop->fp) != 0);
@@ -516,7 +552,7 @@ eofid(FILEID id)
{
FILEIO *fiop; /* file structure */
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL)
return EOF;
return (feof(fiop->fp) != 0);
@@ -531,7 +567,7 @@ flushid(FILEID id)
{
FILEIO *fiop; /* file structure */
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL)
return 0;
if (!fiop->writing || fiop->action == 'r')
@@ -540,6 +576,7 @@ flushid(FILEID id)
}
#if !defined(_WIN32)
int
flushall(void)
{
@@ -555,6 +592,7 @@ flushall(void)
}
return err;
}
#endif /* Windoz free systems */
/*
@@ -592,7 +630,7 @@ readid(FILEID id, int flags, char **retptr)
totlen = 0;
str = NULL;
fiop = findid(id, 'r');
fiop = findid(id, FALSE);
if (fiop == NULL)
return 1;
nlstop = (flags & 1);
@@ -673,7 +711,7 @@ getcharid(FILEID id)
FILEIO *fiop;
FILEPOS fpos;
fiop = findid(id, 'r');
fiop = findid(id, FALSE);
if (fiop == NULL)
return -2;
if (fiop->action == 'w') {
@@ -704,7 +742,7 @@ printid(FILEID id, int flags)
/*
* filewall - file is closed
*/
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL) {
if (flags & PRINT_UNAMBIG)
math_fmt("FILE %d closed", id);
@@ -781,7 +819,7 @@ idprintf(FILEID id, char *fmt, int count, VALUE **vals)
BOOL printstring;
BOOL printchar;
fiop = findid(id, 'w');
fiop = findid(id, TRUE);
if (fiop == NULL)
return 1;
if (fiop->action == 'r') {
@@ -1008,7 +1046,7 @@ idfputc(FILEID id, int ch)
FILEPOS fpos;
/* get the file info pointer */
fiop = findid(id, 'w');
fiop = findid(id, TRUE);
if (fiop == NULL)
return 1;
if (fiop->action == 'r') {
@@ -1043,7 +1081,7 @@ idungetc(FILEID id, int ch)
{
FILEIO *fiop;
fiop = findid(id, 'r');
fiop = findid(id, FALSE);
if (fiop == NULL)
return -2;
if (fiop->action != 'r')
@@ -1066,7 +1104,7 @@ idfputs(FILEID id, char *str)
FILEPOS fpos;
/* get the file info pointer */
fiop = findid(id, 'w');
fiop = findid(id, TRUE);
if (fiop == NULL)
return 1;
@@ -1104,7 +1142,7 @@ idfputstr(FILEID id, char *str)
FILEPOS fpos;
/* get the file info pointer */
fiop = findid(id, 'w');
fiop = findid(id, TRUE);
if (fiop == NULL)
return 1;
@@ -1134,7 +1172,7 @@ int
rewindid(FILEID id)
{
FILEIO *fiop;
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL)
return 1;
rewind(fiop->fp);
@@ -1322,7 +1360,7 @@ getloc(FILEID id, ZVALUE *res)
/*
* convert id to stream
*/
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL) {
/* file not open */
return -1;
@@ -1347,7 +1385,7 @@ ftellid(FILEID id, ZVALUE *res)
FILEPOS fpos; /* current file position */
/* get FILEIO */
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL)
return -2;
@@ -1370,7 +1408,7 @@ fseekid(FILEID id, ZVALUE offset, int whence)
int ret = 0; /* return code */
/* setup */
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL)
return -2;
@@ -1495,7 +1533,7 @@ setloc(FILEID id, ZVALUE zpos)
/*
* convert id to stream
*/
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL) {
/* file not open */
return -1;
@@ -1663,7 +1701,7 @@ getsize(FILEID id, ZVALUE *res)
/*
* convert id to stream
*/
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL) {
/* file not open */
return 1;
@@ -1699,7 +1737,7 @@ get_device(FILEID id, ZVALUE *dev)
/*
* convert id to stream
*/
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL) {
/* file not open */
return -1;
@@ -1732,7 +1770,7 @@ get_inode(FILEID id, ZVALUE *inode)
/*
* convert id to stream
*/
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL) {
/* file not open */
return -1;
@@ -1768,7 +1806,7 @@ zfilesize(FILEID id)
ZVALUE ret; /* file size as a ZVALUE return value */
/* file FILEIO */
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL) {
/* return neg value for non-file error */
itoz(-1, &ret);
@@ -2138,7 +2176,7 @@ fscanfid(FILEID id, char *fmt, int count, VALUE **vals)
FILE *fp;
FILEPOS fpos;
fiop = findid(id, 'r');
fiop = findid(id, FALSE);
if (fiop == NULL)
return -2;
@@ -2402,7 +2440,7 @@ isattyid(FILEID id)
{
FILEIO *fiop;
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL)
return -2;
return isatty(fileno(fiop->fp));
@@ -2439,7 +2477,7 @@ fsearch(FILEID id, char *str, ZVALUE start, ZVALUE end, ZVALUE *res)
long k = 0;
/* get FILEIO */
fiop = findid(id, 'r');
fiop = findid(id, FALSE);
if (fiop == NULL)
return -2;
@@ -2558,7 +2596,7 @@ frsearch(FILEID id, char *str, ZVALUE first, ZVALUE last, ZVALUE *res)
char *s; /* str comparison pointer */
/* get FILEIO */
fiop = findid(id, 'r');
fiop = findid(id, FALSE);
if (fiop == NULL)
return -2;
@@ -2635,7 +2673,7 @@ findfname(FILEID id)
{
FILEIO *fiop;
fiop = findid(id, 0);
fiop = findid(id, -1);
if (fiop == NULL)
return NULL;

8
file.h
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: file.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: file.h,v 29.3 2001/04/10 22:06:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/file.h,v $
*
* Under source code control: 1996/05/24 05:55:58
@@ -50,7 +50,7 @@ typedef struct {
BOOL reading; /* TRUE if opened for reading */
BOOL writing; /* TRUE if opened for writing */
char action; /* most recent use for 'r', 'w' or 0 */
char mode[3]; /* open mode */
char mode[sizeof("rb+")];/* open mode */
} FILEIO;
@@ -85,7 +85,7 @@ typedef struct {
/*
* external functions
*/
extern FILEIO * findid(FILEID id, int mode);
extern FILEIO * findid(FILEID id, int writable);
extern int fgetposid(FILEID id, FILEPOS *ptr);
extern int fsetposid(FILEID id, FILEPOS *ptr);
extern int get_open_siz(FILE *fp, ZVALUE *res);

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.5 $
* @(#) $Id: fposval.c,v 29.5 2001/02/25 21:01:34 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
@@ -87,7 +87,11 @@ main(int argc, char **argv)
#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);
@@ -127,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
@@ -161,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');
@@ -169,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
@@ -198,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
@@ -234,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;

78
func.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.6 $
* @(#) $Id: func.c,v 29.6 2001/02/25 22:07:36 chongo Exp $
* @(#) $Revision: 29.9 $
* @(#) $Id: func.c,v 29.9 2001/04/10 22:06:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/func.c,v $
*
* Under source code control: 1990/02/15 01:48:15
@@ -36,9 +36,9 @@
#include <errno.h>
#if defined(_WIN32)
#include <io.h>
#define _access access
#endif /* Windoz */
# include <io.h>
# define _access access
#endif
#if defined(FUNCLIST)
@@ -1225,8 +1225,10 @@ f_primetest(int count, NUMBER **vals)
{
/* parse args */
switch (count) {
case 1: return itoq((long) qprimetest(vals[0], &_qone_, &_qone_));
case 2: return itoq((long) qprimetest(vals[0], vals[1], &_qone_));
case 1: return itoq((long) qprimetest(vals[0],
qlink(&_qone_), qlink(&_qone_)));
case 2: return itoq((long) qprimetest(vals[0],
vals[1], qlink(&_qone_)));
default: return itoq((long) qprimetest(vals[0], vals[1], vals[2]));
}
}
@@ -2013,7 +2015,7 @@ f_ln(int count, VALUE **vals)
return result;
}
ctmp.real = vals[0]->v_num;
ctmp.imag = &_qzero_;
ctmp.imag = qlink(&_qzero_);
ctmp.links = 1;
c = cln(&ctmp, err);
break;
@@ -3351,7 +3353,7 @@ f_trunc(int count, NUMBER **vals)
{
NUMBER *val;
val = &_qzero_;
val = qlink(&_qzero_);
if (count == 2)
val = vals[1];
return qtrunc(*vals, val);
@@ -3433,7 +3435,7 @@ f_btrunc(int count, NUMBER **vals)
{
NUMBER *val;
val = &_qzero_;
val = qlink(&_qzero_);
if (count == 2)
val = vals[1];
return qbtrunc(*vals, val);
@@ -3538,7 +3540,7 @@ f_ceil(VALUE *val)
tmp.v_subtype = V_NOSUBTYPE;
tmp.v_type = V_NUM;
tmp.v_num = &_qone_;
tmp.v_num = qlink(&_qone_);
apprvalue(val, &tmp, &tmp, &res);
return res;
}
@@ -3555,9 +3557,9 @@ f_floor(VALUE *val)
tmp2.v_subtype = V_NOSUBTYPE;
tmp1.v_type = V_NUM;
tmp1.v_num = &_qone_;
tmp1.v_num = qlink(&_qone_);
tmp2.v_type = V_NUM;
tmp2.v_num = &_qzero_;
tmp2.v_num = qlink(&_qzero_);
apprvalue(val, &tmp1, &tmp2, &res);
return res;
}
@@ -4985,24 +4987,31 @@ f_fopen(VALUE *v1, VALUE *v2)
/* initialize VALUE */
result.v_subtype = V_NOSUBTYPE;
/* check for a valid mode [rwa][b+\0][b+\0] */
if (v1->v_type != V_STR || v2->v_type != V_STR)
return error_value(E_FOPEN1);
mode = v2->v_str->s_str;
if ((*mode != 'r') && (*mode != 'w') && (*mode != 'a'))
return error_value(E_FOPEN2);
if (mode[1] != '\0') {
if (mode[1] != '+')
return error_value(E_FOPEN2);
if (mode[2] != '\0')
if (mode[1] != '+' && mode[1] != 'b')
return error_value(E_FOPEN2);
if (mode[2] != '\0') {
if ((mode[2] != '+' && mode[2] != 'b') ||
mode[1] == mode[2])
return error_value(E_FOPEN2);
if (mode[3] != '\0')
return error_value(E_FOPEN2);
}
}
/* try to open */
errno = 0;
id = openid(v1->v_str->s_str, v2->v_str->s_str);
if (id == FILEID_NONE)
return error_value(errno);
if (id < 0)
return error_value(E_FOPEN3);
return error_value(-id);
result.v_type = V_FILE;
result.v_file = id;
return result;
@@ -5019,21 +5028,27 @@ f_freopen(int count, VALUE **vals)
/* initialize VALUE */
result.v_subtype = V_NOSUBTYPE;
/* check for a valid mode [rwa][b+\0][b+\0] */
if (vals[0]->v_type != V_FILE)
return error_value(E_FREOPEN1);
if (vals[1]->v_type != V_STR)
return error_value(E_FREOPEN2);
mode = vals[1]->v_str->s_str;
if ((*mode != 'r') && (*mode != 'w') && (*mode != 'a'))
return error_value(E_FREOPEN2);
if (mode[1] != '\0') {
if (mode[1] != '+')
return error_value(E_FREOPEN2);
if (mode[2] != '\0')
if (mode[1] != '+' && mode[1] != 'b')
return error_value(E_FREOPEN2);
if (mode[2] != '\0') {
if ((mode[2] != '+' && mode[2] != 'b') ||
mode[1] == mode[2])
return error_value(E_FOPEN2);
if (mode[3] != '\0')
return error_value(E_FREOPEN2);
}
}
/* try to reopen */
errno = 0;
if (count == 2) {
id = reopenid(vals[0]->v_file, mode, NULL);
@@ -6139,10 +6154,10 @@ f_fgetfield(VALUE *vp)
result.v_subtype = V_NOSUBTYPE;
if (vp->v_type != V_FILE)
return error_value(E_FGETWORD1);
return error_value(E_FGETFIELD1);
i = readid(vp->v_file, 14, &str);
if (i > 0)
return error_value(E_FGETWORD2);
return error_value(E_FGETFIELD2);
result.v_type = V_NULL;
if (i == 0) {
result.v_type = V_STR;
@@ -6894,7 +6909,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;
}
@@ -6907,6 +6931,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);
@@ -6937,6 +6962,7 @@ f_sleep(int count, VALUE **vals)
res.v_type = V_NUM;
res.v_num = itoq(time);
}
#endif /* Windoz free systems */
return res;
}

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.1 $
* @(#) $Id: have_fpos_pos.c,v 29.1 2000/12/17 11:25:22 chongo Exp $
* @(#) $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
@@ -51,8 +51,17 @@ main(void)
printf("#define HAVE_FPOS_POS 1 /* yes */\n\n");
/* determine __pos element size */
printf("#undef FPOS_POS_BITS\n");
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;

17
help.c
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.5 $
* @(#) $Id: help.c,v 29.5 2001/02/25 22:07:36 chongo Exp $
* @(#) $Revision: 29.8 $
* @(#) $Id: help.c,v 29.8 2001/04/08 08:29:28 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
@@ -57,6 +62,7 @@ static struct help_alias {
{".", "oldvalue"},
{"%", "mod"},
{"//", "quo"},
{"copy", "blkcpy"},
{"copying", "COPYING"},
{"copying-lgpl", "COPYING-LGPL"},
{"copying_lgpl", "COPYING-LGPL"},
@@ -65,6 +71,13 @@ static struct help_alias {
{"COPYRIGHT", "copyright"},
{"Copyleft", "copyright"},
{"COPYLEFT", "copyright"},
{"read", "command"},
{"write", "command"},
{"quit", "command"},
{"exit", "command"},
{"abort", "command"},
{"cd", "command"},
{"show", "command"},
{"stdlib", "resource"},
{NULL, NULL}
};

View File

@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.5 $
# @(#) $Id: Makefile,v 29.5 2000/12/14 10:33:06 chongo Exp $
# @(#) $Revision: 29.6 $
# @(#) $Id: Makefile,v 29.6 2001/04/08 10:53:52 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
#
# Under source code control: 1991/07/23 06:47:57
@@ -455,7 +455,7 @@ builtin: builtin.top builtin.end ../func.c funclist.sed
distlist: ${DISTLIST}
${Q}for i in ${DISTLIST}; do \
echo help/$$i; \
done | ${SORT}
done | LANG=C ${SORT}
distdir:
${Q}echo help
@@ -485,7 +485,7 @@ detaillist:
else \
echo $$i; \
fi; \
done | ${SORT}) | ${FMT} -70 | \
done | LANG=C ${SORT}) | ${FMT} -70 | \
${SED} -e '1s/xxxxx/DETAIL_HELP=/' -e '2,$$s/^/ /' \
-e 's/$$/ \\/' -e '$$s/ \\$$//'

View File

@@ -47,6 +47,7 @@ Configuration parameters
"ctrl_d" The interactive meaning of ^D (Control D)
"program" Read-only calc program or shell script path
"basename" Read-only basename of the program value
"windows" Read-only indicator of MS windows
"version" Read-only calc version
The "all" config value allows one to save/restore the configuration
@@ -539,6 +540,9 @@ Detailed config descriptions
2 Show func will display more information about a functions
arguments as well as more argument sdummary information.
3 During execution, allow calc standard resource files
to output additional debugging information.
The value for config("resource_debug") in both oldstd and newstd is 3,
but if calc is invoked with the -d flag, its initial value is zero.
Thus, if calc is started without the -d flag, until config("resource_debug")
@@ -674,6 +678,13 @@ Detailed config descriptions
=-=
config("windows") <== NOTE: This is a read-only config value
Returns TRUE if you are running on a MS windows system, false if you
are running on an operating system that does not hate you.
=-=
config("version") <== NOTE: This is a read-only config value
The version string of the calc program can be obtained by:
@@ -698,8 +709,8 @@ Detailed config descriptions
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: config,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.4 $
## @(#) $Id: config,v 29.4 2001/04/08 09:08:27 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/config,v $
##
## Under source code control: 1991/07/21 04:37:17

View File

@@ -15,9 +15,39 @@ DESCRIPTION
opened for either reading, writing, or appending. The mode
is controlled by the mode flag as follows:
"r" reading
"w" writing
"a" appending
allow allow file is positioned file(*)
mode reading writing truncated at mode
---- ------- ------- --------- --------- ----
r Y N N beginning text
rb Y N N beginning binary
r+ Y N N beginning text
r+b Y N N beginning binary
rb+ Y N N beginning binary
w N Y Y beginning text
wb N Y Y beginning binary
w+ Y Y Y beginning text
w+b Y Y Y beginning binary
wb+ Y Y Y beginning binary
a N Y Y end text
ab N Y Y end binary
a+ Y Y Y end text
a+b Y Y Y end binary
ab+ Y Y Y end binary
(*) NOTE on 'b' / binary/text mode:
The 'b' or fopen binary mode has no effect on POSIX / Linux
/ Un*x-like systems. On those systems a text file is the
same as a binary file (as it should be for any modern-day
operating system). Adding 'b' to an fopen has no effect
and is ignored.
Some non-POSIX systems sucn as MS Windoz treat text files
and binary files differently. In text mode MS Windoz consider
"\r\n" and end-of-line character. On an Apple MAC, the
text mode end-of-line character is "\r".
Names of files are subject to ~ expansion just like the C or
Korn shell. For example, the file name:
@@ -90,8 +120,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: fopen,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: fopen,v 29.3 2001/04/10 21:46:45 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fopen,v $
##
## Under source code control: 1994/10/27 03:04:17

View File

@@ -144,9 +144,9 @@ Calc shell scripts
For systems that support interpreter files, essentially the
same thing may be done more efficiently by using calc as an
interpreter. Assuming the full path for calc is
/usr/bin/calc, one could use the file addall3 with contents
/usr/local/bin/calc, one could use the file addall3 with contents
#!/usr/bin/calc -q -s -f
#!/usr/local/bin/calc -q -s -f
global i, n, s;
n = argv();
for (i = 1; i <= n; i++)
@@ -166,7 +166,7 @@ Calc shell scripts
or what is essentially an interpreter equivalent sqrts2:
#!/usr/bin/calc -q -f
#!/usr/local/bin/calc -q -f
global s;
while (scanf('%s', s) == 1)
print sqrt(eval(s));
@@ -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.4 $
## @(#) $Id: script,v 29.4 2000/07/17 15:36:26 chongo Exp $
## @(#) $Revision: 29.5 $
## @(#) $Id: script,v 29.5 2001/04/08 07:56:32 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/script,v $
##
## Under source code control: 1999/11/30 05:29:48

8
hist.c
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.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
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.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__ */

42
input.c
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: input.c,v 29.4 2001/02/25 22:07:36 chongo Exp $
* @(#) $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
@@ -36,8 +36,8 @@
#include <stdio.h>
#include <ctype.h>
#if !defined(_WIN32)
#include <pwd.h>
#endif /* Windoz free systems */
# include <pwd.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
@@ -259,7 +259,7 @@ opensearchfile(char *name, char *pathlist, char *extension, int rd_once)
static char *
homeexpand(char *name)
{
#if defined (_WIN32)
#if defined(_WIN32)
return NULL;
@@ -804,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
*/
@@ -811,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) {
@@ -820,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 */
@@ -932,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;

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.5 $
* @(#) $Id: lib_calc.c,v 29.5 2001/02/25 22:07:36 chongo Exp $
* @(#) $Revision: 29.7 $
* @(#) $Id: lib_calc.c,v 29.7 2001/04/08 22:05:40 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,7 +66,7 @@
# include <termios.h>
typedef struct termios ttystruct;
#elif defined(USE_TERMIOS)
#elif defined(USE_TERMIO)
# include <termio.h>
typedef struct termio ttystruct;
@@ -73,12 +76,20 @@ typedef struct termio ttystruct;
# include <sys/ioctl.h>
typedef struct sgttyb ttystruct;
#elif !defined(_WIN32)
#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
#endif /* Windoz */
/*
* in case we do not have certain .h files
@@ -199,7 +210,7 @@ libcalc_call_me_first(void)
*/
#if !defined(_WIN32)
(void) signal(SIGPIPE, SIG_IGN);
#endif /* Windoz free systems */
#endif
/*
* determine the basename
@@ -382,7 +393,7 @@ initenv(void)
{
#if !defined(_WIN32)
struct passwd *ent; /* our password entry */
#endif /* Windoz free systems */
#endif
char *c;
/* determine the $CALCPATH value */
@@ -742,10 +753,10 @@ 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_TERMIOS)
/*
* assume USE_SGTTY tty state method
* USE_TERMIOS tty state method
*/
if (fd_setup[slot] < 0 && tcgetattr(fd, fd_orig+slot) < 0) {
if (conf->calc_debug & CALCDBG_TTY)
@@ -768,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
/*
@@ -833,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_TERMIOS)
/*
* assume USE_SGTTY tty state method
@@ -841,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
/*

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.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__ */

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: opcodes.h,v 29.3 2001/02/25 22:07:36 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,18 +32,7 @@
#define __OPCODES_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 */
#include "win32dll.h"
/*
@@ -188,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__ */

View File

@@ -17,8 +17,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.3 $
# @(#) $Id: Makefile,v 29.3 2000/12/17 12:28:31 chongo Exp $
# @(#) $Revision: 29.5 $
# @(#) $Id: Makefile,v 29.5 2001/04/08 10:53:52 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/sample/RCS/Makefile,v $
#
# Under source code control: 1997/04/19 22:46:49
@@ -404,7 +404,8 @@ depend:
${Q}mv Makefile Makefile.bak
${Q}${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak > Makefile
${Q}echo "" >> Makefile
${Q}${SED} -n '3,$$p' skel/sample/makedep.out | ${SORT} -u >> Makefile
${Q}${SED} -n '3,$$p' skel/sample/makedep.out | \
LANG=C ${SORT} -u >> Makefile
-${Q}rm -rf skel
-${Q}if cmp -s Makefile.bak Makefile; then \
echo 'sample Makefile was already up to date'; \
@@ -446,11 +447,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
@@ -463,21 +465,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
@@ -493,10 +496,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

18
seed.c
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: seed.c,v 29.3 2001/02/25 22:07:36 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
@@ -47,9 +47,9 @@
#endif
#if defined(_WIN32)
#include <process.h>
#define pid_t int
#endif /* Windoz */
# include <process.h>
# define pid_t int
#endif
/*
* PORTING NOTE:
@@ -75,8 +75,8 @@
#include <sys/times.h>
#endif
#if !defined(_WIN32)
#include <sys/resource.h>
#endif /* Windoz free systems */
# include <sys/resource.h>
#endif
#include <setjmp.h>
#include "qmath.h"
#include "longbits.h"
@@ -308,7 +308,9 @@ pseudo_seed(void)
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 */
@@ -387,7 +389,9 @@ pseudo_seed(void)
(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();

355
value.h
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: value.h,v 29.4 2001/02/25 22:07:36 chongo Exp $
* @(#) $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,20 +32,7 @@
#define __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 */
#include "win32dll.h"
#include "cmath.h"
#include "config.h"
#include "shs.h"
@@ -201,59 +188,59 @@ struct value {
/*
* value functions
*/
DLL extern void freevalue(VALUE *vp);
DLL extern void copyvalue(VALUE *vp, VALUE *vres);
DLL extern void negvalue(VALUE *vp, VALUE *vres);
DLL extern void addvalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void subvalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void mulvalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void orvalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void andvalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void compvalue(VALUE *vp, VALUE *vres);
DLL extern void xorvalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void squarevalue(VALUE *vp, VALUE *vres);
DLL extern void invertvalue(VALUE *vp, VALUE *vres);
DLL extern void roundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
DLL extern void broundvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
DLL extern void setminusvalue(VALUE *, VALUE *, VALUE *);
DLL extern void backslashvalue(VALUE *, VALUE *);
DLL extern void contentvalue(VALUE *, VALUE *);
DLL extern void hashopvalue(VALUE *, VALUE *, VALUE *);
DLL extern void apprvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
DLL extern void intvalue(VALUE *vp, VALUE *vres);
DLL extern void fracvalue(VALUE *vp, VALUE *vres);
DLL extern void incvalue(VALUE *vp, VALUE *vres);
DLL extern void decvalue(VALUE *vp, VALUE *vres);
DLL extern void conjvalue(VALUE *vp, VALUE *vres);
DLL extern void sqrtvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
DLL extern void rootvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
DLL extern void absvalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void normvalue(VALUE *vp, VALUE *vres);
DLL extern void shiftvalue(VALUE *v1, VALUE *v2, BOOL rightshift, VALUE *vres);
DLL extern void scalevalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void powivalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
DLL extern void divvalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void quovalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
DLL extern void modvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres);
DLL extern BOOL testvalue(VALUE *vp);
DLL extern BOOL comparevalue(VALUE *v1, VALUE *v2);
DLL extern BOOL acceptvalue(VALUE *v1, VALUE *v2);
DLL extern void relvalue(VALUE *v1, VALUE *v2, VALUE *vres);
DLL extern void sgnvalue(VALUE *vp, VALUE *vres);
DLL extern QCKHASH hashvalue(VALUE *vp, QCKHASH val);
DLL extern void printvalue(VALUE *vp, int flags);
DLL extern BOOL precvalue(VALUE *v1, VALUE *v2);
DLL extern VALUE error_value(int e);
DLL extern int set_errno(int e);
DLL extern int set_errcount(int e);
DLL extern long countlistitems(LIST *lp);
DLL extern void addlistitems(LIST *lp, VALUE *vres);
DLL extern void addlistinv(LIST *lp, VALUE *vres);
DLL extern void copy2octet(VALUE *, OCTET *);
DLL extern int copystod(VALUE *, long, long, VALUE *, long);
DLL extern void protectall(VALUE *, int);
DLL 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);
/*
@@ -270,44 +257,44 @@ struct matrix {
#define matsize(n) (sizeof(MATRIX) - sizeof(VALUE) + ((n) * sizeof(VALUE)))
DLL extern MATRIX *matadd(MATRIX *m1, MATRIX *m2);
DLL extern MATRIX *matsub(MATRIX *m1, MATRIX *m2);
DLL extern MATRIX *matmul(MATRIX *m1, MATRIX *m2);
DLL extern MATRIX *matneg(MATRIX *m);
DLL extern MATRIX *matalloc(long size);
DLL extern MATRIX *matcopy(MATRIX *m);
DLL extern MATRIX *matinit(MATRIX *m, VALUE *v1, VALUE *v2);
DLL extern MATRIX *matsquare(MATRIX *m);
DLL extern MATRIX *matinv(MATRIX *m);
DLL extern MATRIX *matscale(MATRIX *m, long n);
DLL extern MATRIX *matshift(MATRIX *m, long n);
DLL extern MATRIX *matmulval(MATRIX *m, VALUE *vp);
DLL extern MATRIX *matpowi(MATRIX *m, NUMBER *q);
DLL extern MATRIX *matconj(MATRIX *m);
DLL extern MATRIX *matquoval(MATRIX *m, VALUE *vp, VALUE *v3);
DLL extern MATRIX *matmodval(MATRIX *m, VALUE *vp, VALUE *v3);
DLL extern MATRIX *matint(MATRIX *m);
DLL extern MATRIX *matfrac(MATRIX *m);
DLL extern MATRIX *matappr(MATRIX *m, VALUE *v2, VALUE *v3);
DLL extern VALUE mattrace(MATRIX *m);
DLL extern MATRIX *mattrans(MATRIX *m);
DLL extern MATRIX *matcross(MATRIX *m1, MATRIX *m2);
DLL extern BOOL mattest(MATRIX *m);
DLL extern void matsum(MATRIX *m, VALUE *vres);
DLL extern BOOL matcmp(MATRIX *m1, MATRIX *m2);
DLL extern int matsearch(MATRIX *m, VALUE *vp, long start, long end, ZVALUE *index);
DLL extern int matrsearch(MATRIX *m, VALUE *vp, long start, long end, ZVALUE *index);
DLL extern VALUE matdet(MATRIX *m);
DLL extern VALUE matdot(MATRIX *m1, MATRIX *m2);
DLL extern void matfill(MATRIX *m, VALUE *v1, VALUE *v2);
DLL extern void matfree(MATRIX *m);
DLL extern void matprint(MATRIX *m, long max_print);
DLL extern VALUE *matindex(MATRIX *mp, BOOL create, long dim, VALUE *indices);
DLL extern void matreverse(MATRIX *m);
DLL extern void matsort(MATRIX *m);
DLL extern BOOL matisident(MATRIX *m);
DLL extern MATRIX *matround(MATRIX *m, VALUE *v2, VALUE *v3);
DLL 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);
/*
@@ -334,32 +321,32 @@ struct list {
};
DLL extern void insertlistfirst(LIST *lp, VALUE *vp);
DLL extern void insertlistlast(LIST *lp, VALUE *vp);
DLL extern void insertlistmiddle(LIST *lp, long index, VALUE *vp);
DLL extern void removelistfirst(LIST *lp, VALUE *vp);
DLL extern void removelistlast(LIST *lp, VALUE *vp);
DLL extern void removelistmiddle(LIST *lp, long index, VALUE *vp);
DLL extern void listfree(LIST *lp);
DLL extern void listprint(LIST *lp, long max_print);
DLL extern int listsearch(LIST *lp, VALUE *vp, long start, long end, ZVALUE *index);
DLL extern int listrsearch(LIST *lp, VALUE *vp, long start, long end, ZVALUE *index);
DLL extern BOOL listcmp(LIST *lp1, LIST *lp2);
DLL extern VALUE *listfindex(LIST *lp, long index);
DLL extern LIST *listalloc(void);
DLL extern LIST *listcopy(LIST *lp);
DLL extern void listreverse(LIST *lp);
DLL extern void listsort(LIST *lp);
DLL extern LIST *listappr(LIST *lp, VALUE *v2, VALUE *v3);
DLL extern LIST *listround(LIST *m, VALUE *v2, VALUE *v3);
DLL extern LIST *listbround(LIST *m, VALUE *v2, VALUE *v3);
DLL extern LIST *listquo(LIST *lp, VALUE *v2, VALUE *v3);
DLL extern LIST *listmod(LIST *lp, VALUE *v2, VALUE *v3);
DLL extern BOOL evp(LISTELEM *cp, LISTELEM *x, VALUE *vres);
DLL extern BOOL evalpoly(LIST *clist, LISTELEM *x, VALUE *vres);
DLL extern void insertitems(LIST *lp1, LIST *lp2);
DLL extern LISTELEM *listelement(LIST *, long);
DLL 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);
/*
@@ -384,15 +371,15 @@ struct assoc {
};
DLL extern ASSOC *assocalloc(long initsize);
DLL extern ASSOC *assoccopy(ASSOC *ap);
DLL extern void assocfree(ASSOC *ap);
DLL extern void assocprint(ASSOC *ap, long max_print);
DLL extern int assocsearch(ASSOC *ap, VALUE *vp, long start, long end, ZVALUE *index);
DLL extern int assocrsearch(ASSOC *ap, VALUE *vp, long start, long end, ZVALUE *index);
DLL extern BOOL assoccmp(ASSOC *ap1, ASSOC *ap2);
DLL extern VALUE *assocfindex(ASSOC *ap, long index);
DLL 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);
/*
@@ -474,62 +461,62 @@ struct object {
(sizeof(OBJECT) + ((elements) - USUAL_ELEMENTS) * sizeof(VALUE))
DLL extern OBJECT *objcopy(OBJECT *op);
DLL extern OBJECT *objalloc(long index);
DLL extern VALUE objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3);
DLL extern void objfree(OBJECT *op);
DLL extern int addelement(char *name);
DLL extern int defineobject(char *name, int indices[], int count);
DLL extern int checkobject(char *name);
DLL extern void showobjfuncs(void);
DLL extern void showobjtypes(void);
DLL extern int findelement(char *name);
DLL extern char *objtypename(unsigned long index);
DLL 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[];
DLL extern void config_value(CONFIG *cfg, int type, VALUE *ret);
DLL extern void setconfig(int type, VALUE *vp);
DLL 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
*/
DLL extern long elm_count(VALUE *vp);
DLL extern long lsizeof(VALUE *vp);
DLL 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
*/
DLL extern STRING *stringadd(STRING *, STRING *);
DLL extern STRING *stringcopy(STRING *);
DLL extern STRING *stringsub(STRING *, STRING *);
DLL extern STRING *stringmul(NUMBER *, STRING *);
DLL extern STRING *stringand(STRING *, STRING *);
DLL extern STRING *stringor(STRING *, STRING *);
DLL extern STRING *stringxor(STRING *, STRING *);
DLL extern STRING *stringdiff(STRING *, STRING *);
DLL extern STRING *stringsegment(STRING *, long, long);
DLL extern STRING *stringshift(STRING *, long);
DLL extern STRING *stringcomp(STRING *);
DLL extern STRING *stringneg(STRING *);
DLL extern STRING *stringcpy(STRING *, STRING *);
DLL extern STRING *stringncpy(STRING *, STRING *, long);
DLL extern long stringcontent(STRING *s);
DLL extern long stringlowbit(STRING *s);
DLL extern long stringhighbit(STRING *s);
DLL extern BOOL stringcmp(STRING *, STRING *);
DLL extern BOOL stringrel(STRING *, STRING *);
DLL extern int stringbit(STRING *, long);
DLL extern BOOL stringtest(STRING *);
DLL extern int stringsetbit(STRING *, long, BOOL);
DLL extern int stringsearch(STRING *, STRING *, long, long, ZVALUE *);
DLL 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__ */

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.19 $
* @(#) $Id: version.c,v 29.19 2001/02/25 22:07:36 chongo Exp $
* @(#) $Revision: 29.23 $
* @(#) $Id: version.c,v 29.23 2001/04/10 22:13:40 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
*
* Under source code control: 1990/05/22 11:00:58
@@ -43,7 +43,7 @@ static char *program;
#define MAJOR_VER 2 /* major version */
#define MINOR_VER 11 /* minor version */
#define MAJOR_PATCH 5 /* patch level or 0 if no patch */
#define MINOR_PATCH "0" /* test number or empty string if no patch */
#define MINOR_PATCH "2.1" /* test number or empty string if no patch */
/*
* calc version constants

58
win32.mkdef Normal file
View File

@@ -0,0 +1,58 @@
TERMCONTROL=-DUSE_WIN32
HAVE_VSPRINTF=-UDONT_HAVE_VSPRINTF
BYTE_ORDER=-DLITTLE_ENDIAN
LONG_BITS=32
LONGLONG_BITS=0
HAVE_FPOS=-DHAVE_NO_FPOS
HAVE_FPOS_POS=-DHAVE_NO_FPOS_POS
FPOS_POS_BITS=-UFPOS_POS_BITS
FPOS_BITS=-DFPOS_BITS=64
OFF_T_BITS=-DOFF_T_BITS=32
DEV_BITS=-DDEV_BITS=32
INODE_BITS=-DINODE_BITS=16
HAVE_OFFSCL=-UOFF_T_NON_SCALAR
HAVE_POSSCL=-UFILEPOS_NON_SCALAR
HAVE_CONST=-UHAVE_NO_CONST
HAVE_UID_T=-DHAVE_NO_UID_T
HAVE_NEWSTR=-UHAVE_NO_NEWSTR
HAVE_MEMMOVE=-UHAVE_NO_MEMMOVE
HAVE_USTAT=-DHAVE_NO_USTAT
HAVE_GETSID=-DHAVE_NO_GETSID
HAVE_GETPGID=-DHAVE_NO_GETPGID
HAVE_GETTIME=-DHAVE_NO_GETTIME
HAVE_GETPRID=-DHAVE_NO_GETPRID
HAVE_URANDOM_H=NO
HAVE_GETRUSAGE=-DHAVE_NO_GETRUSAGE
HAVE_STRDUP=-UHAVE_NO_STRDUP
ALIGN32=-UMUST_ALIGN32
HAVE_MALLOC_H=YES
HAVE_STDLIB_H=YES
HAVE_STRING_H=YES
HAVE_TIMES_H=NO
HAVE_SYS_TIMES_H=NO
HAVE_TIME_H=YES
HAVE_SYS_TIME_H=NO
HAVE_UNISTD_H=NO
LIBDIR=/lib/calc
HELPDIR=/lib/calc/help
INCDIRCALC=/include/calc
CUSTOMLIBDIR=/lib/calc/custom
CUSTOMHELPDIR=/lib/calc/help/custhelp
SCRIPTDIR=/lib/calc/cscript
MANDIR=
CATDIR=
MANEXT=
CATEXT=
NROFF=
NROFF_ARG=
MANMAKE=
MANMODE=
CALCPATH=./cal
CALCRC='/lib/calc/startup:~/.calcrc:./.calcinit'
USE_READLINE=
READLINE_LIB=
READLINE_INCLUDE=
CALCPAGER=
ECHO=

15
win32/align32.h Normal file
View File

@@ -0,0 +1,15 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__MUST_ALIGN32_H__)
#define __MUST_ALIGN32_H__
/* must we always align 32 bit accesses? */
/* forced to not require 32 bit alignment */
#undef MUST_ALIGN32
#endif /* !__MUST_ALIGN32_H__ */

18
win32/args.h Normal file
View File

@@ -0,0 +1,18 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__ARGS_H__)
#define __ARGS_H__
/* what type of variable args do we have? */
#define STDARG /* use <stdarg.h> */
#include <stdarg.h>
/* should we use vsprintf()? */
#define HAVE_VS /* yes */
#endif /* !__ARGS_H__ */

379
win32/calcerr.c Normal file
View File

@@ -0,0 +1,379 @@
/*
* DO NOT EDIT
*
* generated by calcerr.tbl via Makefile
*/
#include <stdio.h>
#include "calcerr.h"
#include "have_const.h"
/*
* names of calc error values
*/
CONST char *error_table[E__COUNT+2] = {
"No error",
"Division by zero",
"Indeterminate (0/0)",
"Bad arguments for +",
"Bad arguments for binary -",
"Bad arguments for *",
"Bad arguments for /",
"Bad argument for unary -",
"Bad argument for squaring",
"Bad argument for inverse",
"Bad argument for ++",
"Bad argument for --",
"Bad argument for int",
"Bad argument for frac",
"Bad argument for conj",
"Bad first argument for appr",
"Bad second argument for appr",
"Bad third argument for appr",
"Bad first argument for round",
"Bad second argument for round",
"Bad third argument for round",
"Bad first argument for bround",
"Bad second argument for bround",
"Bad third argument for bround",
"Bad first argument for sqrt",
"Bad second argument for sqrt",
"Bad third argument for sqrt",
"Bad first argument for root",
"Bad second argument for root",
"Bad third argument for root",
"Bad argument for norm",
"Bad first argument for << or >>",
"Bad second argument for << or >>",
"Bad first argument for scale",
"Bad second argument for scale",
"Bad first argument for ^",
"Bad second argument for ^",
"Bad first argument for power",
"Bad second argument for power",
"Bad third argument for power",
"Bad first argument for quo or //",
"Bad second argument for quo or //",
"Bad third argument for quo",
"Bad first argument for mod or %",
"Bad second argument for mod or %",
"Bad third argument for mod",
"Bad argument for sgn",
"Bad first argument for abs",
"Bad second argument for abs",
"Scan error in argument for eval",
"Non-simple type for str",
"Non-real epsilon for exp",
"Bad first argument for exp",
"Non-file first argument for fputc",
"Bad second argument for fputc",
"File not open for writing for fputc",
"Non-file first argument for fgetc",
"File not open for reading for fgetc",
"Non-string arguments for fopen",
"Unrecognized mode for fopen",
"Non-file first argument for freopen",
"Non-string or unrecognized mode for freopen",
"Non-string third argument for freopen",
"Non-file argument for fclose",
"Non-file argument for fflush",
"Non-file first argument for fputs",
"Non-string argument after first for fputs",
"File not open for writing for fputs",
"Non-file argument for fgets",
"File not open for reading for fgets",
"Non-file first argument for fputstr",
"Non-string argument after first for fputstr",
"File not open for writing for fputstr",
"Non-file first argument for fgetstr",
"File not open for reading for fgetstr",
"Non-file argument for fgetline",
"File not open for reading for fgetline",
"Non-file argument for fgetfield",
"File not open for reading for fgetfield",
"Non-file argument for rewind",
"Non-integer argument for files",
"Non-string fmt argument for fprint",
"Stdout not open for writing to ???",
"Non-file first argument for fprintf",
"Non-string second (fmt) argument for fprintf",
"File not open for writing for fprintf",
"Non-string first (fmt) argument for strprintf",
"Error in attempting strprintf ???",
"Non-file first argument for fscan",
"File not open for reading for fscan",
"Non-string first argument for strscan",
"Non-file first argument for fscanf",
"Non-string second (fmt) argument for fscanf",
"Non-lvalue argument after second for fscanf",
"File not open for reading or other error for fscanf",
"Non-string first argument for strscanf",
"Non-string second (fmt) argument for strscanf",
"Non-lvalue argument after second for strscanf",
"Some error in attempting strscanf ???",
"Non-string first (fmt) argument for scanf",
"Non-lvalue argument after first for scanf",
"Some error in attempting scanf ???",
"Non-file argument for ftell",
"File not open or other error for ftell",
"Non-file first argument for fseek",
"Non-integer or negative second argument for fseek",
"File not open or other error for fseek",
"Non-file argument for fsize",
"File not open or other error for fsize",
"Non-file argument for feof",
"File not open or other error for feof",
"Non-file argument for ferror",
"File not open or other error for ferror",
"Non-file argument for ungetc",
"File not open for reading for ungetc",
"Bad second argument or other error for ungetc",
"Exponent too big in scanning",
"E_ISATTY1 is no longer used",
"E_ISATTY2 is no longer used",
"Non-string first argument for access",
"Bad second argument for access",
"Bad first argument for search",
"Bad second argument for search",
"Bad third argument for search",
"Bad fourth argument for search",
"Cannot find fsize or fpos for search",
"File not readable for search",
"Bad first argument for rsearch",
"Bad second argument for rsearch",
"Bad third argument for rsearch",
"Bad fourth argument for rsearch",
"Cannot find fsize or fpos for rsearch",
"File not readable for rsearch",
"Too many open files",
"Attempt to rewind a file that is not open",
"Bad argument type for strerror",
"Index out of range for strerror",
"Bad epsilon for cos",
"Bad first argument for cos",
"Bad epsilon for sin",
"Bad first argument for sin",
"Non-string argument for eval",
"Bad epsilon for arg",
"Bad first argument for arg",
"Non-real argument for polar",
"Bad epsilon for polar",
"Non-integral argument for fcnt",
"Non-variable first argument for matfill",
"Non-matrix first argument-value for matfill",
"Non-matrix argument for matdim",
"Non-matrix argument for matsum",
"E_ISIDENT is no longer used",
"Non-matrix argument for mattrans",
"Non-two-dimensional matrix for mattrans",
"Non-matrix argument for det",
"Matrix for det not of dimension 2",
"Non-square matrix for det",
"Non-matrix first argument for matmin",
"Non-positive-integer second argument for matmin",
"Second argument for matmin exceeds dimension",
"Non-matrix first argument for matmin",
"Second argument for matmax not positive integer",
"Second argument for matmax exceeds dimension",
"Non-matrix argument for cp",
"Non-one-dimensional matrix for cp",
"Matrix size not 3 for cp",
"Non-matrix argument for dp",
"Non-one-dimensional matrix for dp",
"Different-size matrices for dp",
"Non-string argument for strlen",
"Non-string argument for strcat",
"Non-string first argument for strcat",
"Non-non-negative integer second argument for strcat",
"Bad argument for char",
"Non-string argument for ord",
"Non-list-variable first argument for insert",
"Non-integral second argument for insert",
"Non-list-variable first argument for push",
"Non-list-variable first argument for append",
"Non-list-variable first argument for delete",
"Non-integral second argument for delete",
"Non-list-variable argument for pop",
"Non-list-variable argument for remove",
"Bad epsilon argument for ln",
"Non-numeric first argument for ln",
"Non-integer argument for error",
"Argument outside range for error",
"Attempt to eval at maximum input depth",
"Unable to open string for reading",
"First argument for rm is not a non-empty string",
"Unable to remove a file",
"Operation allowed because calc mode disallows read operations",
"Operation allowed because calc mode disallows write operations",
"Operation allowed because calc mode disallows exec operations",
"Unordered arguments for min",
"Unordered arguments for max",
"Unordered items for minimum of list",
"Unordered items for maximum of list",
"Size undefined for argument type",
"Calc must be run with a -C argument to use custom function",
"Calc was built with custom functions disabled",
"Custom function unknown, try: show custom",
"Non-integral length for block",
"Negative or too-large length for block",
"Non-integral chunksize for block",
"Negative or too-large chunksize for block",
"Named block does not exist for blkfree",
"Non-integral id specification for blkfree",
"Block with specified id does not exist",
"Block already freed",
"No-realloc protection prevents blkfree",
"Non-integer argument for blocks",
"Non-allocated index number for blocks",
"Non-integer or negative source index for copy",
"Source index too large for copy",
"E_COPY3 is no longer used",
"Non-integer or negative number for copy",
"Number too large for copy",
"Non-integer or negative destination index for copy",
"Destination index too large for copy",
"Freed block source for copy",
"Unsuitable source type for copy",
"Freed block destinction for copy",
"Unsuitable destination type for copy",
"Incompatible source and destination for copy",
"No-copy-from source variable",
"No-copy-to destination variable",
"No-copy-from source named block",
"No-copy-to destination named block",
"No-relocation destination for copy",
"File not open for copy",
"fseek or fsize failure for copy",
"fwrite error for copy",
"fread error for copy",
"Non-variable first argument for protect",
"Non-integer second argument for protect",
"Out-of-range second argument for protect",
"No-copy-to destination for matfill",
"No-assign-from source for matfill",
"Non-matrix argument for mattrace",
"Non-two-dimensional argument for mattrace",
"Non-square argument for mattrace",
"Bad epsilon for tan",
"Bad argument for tan",
"Bad epsilon for cot",
"Bad argument for cot",
"Bad epsilon for sec",
"Bad argument for sec",
"Bad epsilon for csc",
"Bad argument for csc",
"Bad epsilon for sinh",
"Bad argument for sinh",
"Bad epsilon for cosh",
"Bad argument for cosh",
"Bad epsilon for tanh",
"Bad argument for tanh",
"Bad epsilon for coth",
"Bad argument for coth",
"Bad epsilon for sech",
"Bad argument for sech",
"Bad epsilon for csch",
"Bad argument for csch",
"Bad epsilon for asin",
"Bad argument for asin",
"Bad epsilon for acos",
"Bad argument for acos",
"Bad epsilon for atan",
"Bad argument for atan",
"Bad epsilon for acot",
"Bad argument for acot",
"Bad epsilon for asec",
"Bad argument for asec",
"Bad epsilon for acsc",
"Bad argument for acsc",
"Bad epsilon for asin",
"Bad argument for asinh",
"Bad epsilon for acosh",
"Bad argument for acosh",
"Bad epsilon for atanh",
"Bad argument for atanh",
"Bad epsilon for acoth",
"Bad argument for acoth",
"Bad epsilon for asech",
"Bad argument for asech",
"Bad epsilon for acsch",
"Bad argument for acsch",
"Bad epsilon for gd",
"Bad argument for gd",
"Bad epsilon for agd",
"Bad argument for agd",
"Log of zero or infinity",
"String addition failure",
"String multiplication failure",
"String reversal failure",
"String subtraction failure",
"Bad argument type for bit",
"Index too large for bit",
"Non-integer second argument for setbit",
"Out-of-range index for setbit",
"Non-string first argument for setbit",
"Bad argument for or",
"Bad argument for and",
"Allocation failure for string or",
"Allocation failure for string and",
"Bad argument for xorvalue",
"Bad argument for comp",
"Allocation failure for string diff",
"Allocation failure for string comp",
"Bad first argument for segment",
"Bad second argument for segment",
"Bad third argument for segment",
"Failure for string segment",
"Bad argument type for highbit",
"Non-integer argument for highbit",
"Bad argument type for lowbit",
"Non-integer argument for lowbit",
"Bad argument type for unary hash op",
"Bad argument type for binary hash op",
"Bad first argument for head",
"Bad second argument for head",
"Failure for strhead",
"Bad first argument for tail",
"Bad second argument for tail",
"Failure for strtail",
"Failure for strshift",
"Non-string argument for strcmp",
"Bad argument type for strncmp",
"Varying types of argument for xor",
"Bad argument type for xor",
"Bad argument type for strcpy",
"Bad argument type for strncpy",
"Bad argument type for unary backslash",
"Bad argument type for setminus",
"Bad first argument type for indices",
"Bad second argument for indices",
"Too-large re(argument) for exp",
"Too-large re(argument) for sinh",
"Too-large re(argument) for cosh",
"Too-large im(argument) for sin",
"Too-large im(argument) for cos",
"Infinite or too-large result for gd",
"Infinite or too-large result for agd",
"Too-large value for power",
"Too-large value for root",
"Non-real first arg for digit",
"Non-integral second arg for digit",
"Bad third arg for digit",
"Bad first argument for places",
"Bad second argument for places",
"Bad first argument for digits",
"Bad second argument for digits",
"Bad first argument for ilog",
"Bad second argument for ilog",
"Bad argument for ilog10",
"Bad argument for ilog2",
"Non-integer second arg for comb",
"Too-large second arg for comb",
"Bad argument for catalan",
"Bad argument for bern",
"Bad argument for euler",
"Bad argument for sleep",
"calc_tty failure",
NULL
};

383
win32/calcerr.h Normal file
View File

@@ -0,0 +1,383 @@
/*
* DO NOT EDIT
*
* generated by calcerr.tbl via Makefile
*/
#if !defined(__CALCERR_H__)
#define __CALCERR_H__
#define E__BASE 10000 /* calc errors start above here */
#define E_1OVER0 10001 /* Division by zero */
#define E_0OVER0 10002 /* Indeterminate (0/0) */
#define E_ADD 10003 /* Bad arguments for + */
#define E_SUB 10004 /* Bad arguments for binary - */
#define E_MUL 10005 /* Bad arguments for * */
#define E_DIV 10006 /* Bad arguments for / */
#define E_NEG 10007 /* Bad argument for unary - */
#define E_SQUARE 10008 /* Bad argument for squaring */
#define E_INV 10009 /* Bad argument for inverse */
#define E_INCV 10010 /* Bad argument for ++ */
#define E_DECV 10011 /* Bad argument for -- */
#define E_INT 10012 /* Bad argument for int */
#define E_FRAC 10013 /* Bad argument for frac */
#define E_CONJ 10014 /* Bad argument for conj */
#define E_APPR 10015 /* Bad first argument for appr */
#define E_APPR2 10016 /* Bad second argument for appr */
#define E_APPR3 10017 /* Bad third argument for appr */
#define E_ROUND 10018 /* Bad first argument for round */
#define E_ROUND2 10019 /* Bad second argument for round */
#define E_ROUND3 10020 /* Bad third argument for round */
#define E_BROUND 10021 /* Bad first argument for bround */
#define E_BROUND2 10022 /* Bad second argument for bround */
#define E_BROUND3 10023 /* Bad third argument for bround */
#define E_SQRT 10024 /* Bad first argument for sqrt */
#define E_SQRT2 10025 /* Bad second argument for sqrt */
#define E_SQRT3 10026 /* Bad third argument for sqrt */
#define E_ROOT 10027 /* Bad first argument for root */
#define E_ROOT2 10028 /* Bad second argument for root */
#define E_ROOT3 10029 /* Bad third argument for root */
#define E_NORM 10030 /* Bad argument for norm */
#define E_SHIFT 10031 /* Bad first argument for << or >> */
#define E_SHIFT2 10032 /* Bad second argument for << or >> */
#define E_SCALE 10033 /* Bad first argument for scale */
#define E_SCALE2 10034 /* Bad second argument for scale */
#define E_POWI 10035 /* Bad first argument for ^ */
#define E_POWI2 10036 /* Bad second argument for ^ */
#define E_POWER 10037 /* Bad first argument for power */
#define E_POWER2 10038 /* Bad second argument for power */
#define E_POWER3 10039 /* Bad third argument for power */
#define E_QUO 10040 /* Bad first argument for quo or // */
#define E_QUO2 10041 /* Bad second argument for quo or // */
#define E_QUO3 10042 /* Bad third argument for quo */
#define E_MOD 10043 /* Bad first argument for mod or % */
#define E_MOD2 10044 /* Bad second argument for mod or % */
#define E_MOD3 10045 /* Bad third argument for mod */
#define E_SGN 10046 /* Bad argument for sgn */
#define E_ABS 10047 /* Bad first argument for abs */
#define E_ABS2 10048 /* Bad second argument for abs */
#define E_EVAL 10049 /* Scan error in argument for eval */
#define E_STR 10050 /* Non-simple type for str */
#define E_EXP1 10051 /* Non-real epsilon for exp */
#define E_EXP2 10052 /* Bad first argument for exp */
#define E_FPUTC1 10053 /* Non-file first argument for fputc */
#define E_FPUTC2 10054 /* Bad second argument for fputc */
#define E_FPUTC3 10055 /* File not open for writing for fputc */
#define E_FGETC1 10056 /* Non-file first argument for fgetc */
#define E_FGETC2 10057 /* File not open for reading for fgetc */
#define E_FOPEN1 10058 /* Non-string arguments for fopen */
#define E_FOPEN2 10059 /* Unrecognized mode for fopen */
#define E_FREOPEN1 10060 /* Non-file first argument for freopen */
#define E_FREOPEN2 10061 /* Non-string or unrecognized mode for freopen */
#define E_FREOPEN3 10062 /* Non-string third argument for freopen */
#define E_FCLOSE1 10063 /* Non-file argument for fclose */
#define E_FFLUSH 10064 /* Non-file argument for fflush */
#define E_FPUTS1 10065 /* Non-file first argument for fputs */
#define E_FPUTS2 10066 /* Non-string argument after first for fputs */
#define E_FPUTS3 10067 /* File not open for writing for fputs */
#define E_FGETS1 10068 /* Non-file argument for fgets */
#define E_FGETS2 10069 /* File not open for reading for fgets */
#define E_FPUTSTR1 10070 /* Non-file first argument for fputstr */
#define E_FPUTSTR2 10071 /* Non-string argument after first for fputstr */
#define E_FPUTSTR3 10072 /* File not open for writing for fputstr */
#define E_FGETSTR1 10073 /* Non-file first argument for fgetstr */
#define E_FGETSTR2 10074 /* File not open for reading for fgetstr */
#define E_FGETLINE1 10075 /* Non-file argument for fgetline */
#define E_FGETLINE2 10076 /* File not open for reading for fgetline */
#define E_FGETFIELD1 10077 /* Non-file argument for fgetfield */
#define E_FGETFIELD2 10078 /* File not open for reading for fgetfield */
#define E_REWIND1 10079 /* Non-file argument for rewind */
#define E_FILES 10080 /* Non-integer argument for files */
#define E_PRINTF1 10081 /* Non-string fmt argument for fprint */
#define E_PRINTF2 10082 /* Stdout not open for writing to ??? */
#define E_FPRINTF1 10083 /* Non-file first argument for fprintf */
#define E_FPRINTF2 10084 /* Non-string second (fmt) argument for fprintf */
#define E_FPRINTF3 10085 /* File not open for writing for fprintf */
#define E_STRPRINTF1 10086 /* Non-string first (fmt) argument for strprintf */
#define E_STRPRINTF2 10087 /* Error in attempting strprintf ??? */
#define E_FSCAN1 10088 /* Non-file first argument for fscan */
#define E_FSCAN2 10089 /* File not open for reading for fscan */
#define E_STRSCAN 10090 /* Non-string first argument for strscan */
#define E_FSCANF1 10091 /* Non-file first argument for fscanf */
#define E_FSCANF2 10092 /* Non-string second (fmt) argument for fscanf */
#define E_FSCANF3 10093 /* Non-lvalue argument after second for fscanf */
#define E_FSCANF4 10094 /* File not open for reading or other error for fscanf */
#define E_STRSCANF1 10095 /* Non-string first argument for strscanf */
#define E_STRSCANF2 10096 /* Non-string second (fmt) argument for strscanf */
#define E_STRSCANF3 10097 /* Non-lvalue argument after second for strscanf */
#define E_STRSCANF4 10098 /* Some error in attempting strscanf ??? */
#define E_SCANF1 10099 /* Non-string first (fmt) argument for scanf */
#define E_SCANF2 10100 /* Non-lvalue argument after first for scanf */
#define E_SCANF3 10101 /* Some error in attempting scanf ??? */
#define E_FTELL1 10102 /* Non-file argument for ftell */
#define E_FTELL2 10103 /* File not open or other error for ftell */
#define E_FSEEK1 10104 /* Non-file first argument for fseek */
#define E_FSEEK2 10105 /* Non-integer or negative second argument for fseek */
#define E_FSEEK3 10106 /* File not open or other error for fseek */
#define E_FSIZE1 10107 /* Non-file argument for fsize */
#define E_FSIZE2 10108 /* File not open or other error for fsize */
#define E_FEOF1 10109 /* Non-file argument for feof */
#define E_FEOF2 10110 /* File not open or other error for feof */
#define E_FERROR1 10111 /* Non-file argument for ferror */
#define E_FERROR2 10112 /* File not open or other error for ferror */
#define E_UNGETC1 10113 /* Non-file argument for ungetc */
#define E_UNGETC2 10114 /* File not open for reading for ungetc */
#define E_UNGETC3 10115 /* Bad second argument or other error for ungetc */
#define E_BIGEXP 10116 /* Exponent too big in scanning */
#define E_ISATTY1 10117 /* E_ISATTY1 is no longer used */
#define E_ISATTY2 10118 /* E_ISATTY2 is no longer used */
#define E_ACCESS1 10119 /* Non-string first argument for access */
#define E_ACCESS2 10120 /* Bad second argument for access */
#define E_SEARCH1 10121 /* Bad first argument for search */
#define E_SEARCH2 10122 /* Bad second argument for search */
#define E_SEARCH3 10123 /* Bad third argument for search */
#define E_SEARCH4 10124 /* Bad fourth argument for search */
#define E_SEARCH5 10125 /* Cannot find fsize or fpos for search */
#define E_SEARCH6 10126 /* File not readable for search */
#define E_RSEARCH1 10127 /* Bad first argument for rsearch */
#define E_RSEARCH2 10128 /* Bad second argument for rsearch */
#define E_RSEARCH3 10129 /* Bad third argument for rsearch */
#define E_RSEARCH4 10130 /* Bad fourth argument for rsearch */
#define E_RSEARCH5 10131 /* Cannot find fsize or fpos for rsearch */
#define E_RSEARCH6 10132 /* File not readable for rsearch */
#define E_FOPEN3 10133 /* Too many open files */
#define E_REWIND2 10134 /* Attempt to rewind a file that is not open */
#define E_STRERROR1 10135 /* Bad argument type for strerror */
#define E_STRERROR2 10136 /* Index out of range for strerror */
#define E_COS1 10137 /* Bad epsilon for cos */
#define E_COS2 10138 /* Bad first argument for cos */
#define E_SIN1 10139 /* Bad epsilon for sin */
#define E_SIN2 10140 /* Bad first argument for sin */
#define E_EVAL2 10141 /* Non-string argument for eval */
#define E_ARG1 10142 /* Bad epsilon for arg */
#define E_ARG2 10143 /* Bad first argument for arg */
#define E_POLAR1 10144 /* Non-real argument for polar */
#define E_POLAR2 10145 /* Bad epsilon for polar */
#define E_FCNT 10146 /* Non-integral argument for fcnt */
#define E_MATFILL1 10147 /* Non-variable first argument for matfill */
#define E_MATFILL2 10148 /* Non-matrix first argument-value for matfill */
#define E_MATDIM 10149 /* Non-matrix argument for matdim */
#define E_MATSUM 10150 /* Non-matrix argument for matsum */
#define E_ISIDENT 10151 /* E_ISIDENT is no longer used */
#define E_MATTRANS1 10152 /* Non-matrix argument for mattrans */
#define E_MATTRANS2 10153 /* Non-two-dimensional matrix for mattrans */
#define E_DET1 10154 /* Non-matrix argument for det */
#define E_DET2 10155 /* Matrix for det not of dimension 2 */
#define E_DET3 10156 /* Non-square matrix for det */
#define E_MATMIN1 10157 /* Non-matrix first argument for matmin */
#define E_MATMIN2 10158 /* Non-positive-integer second argument for matmin */
#define E_MATMIN3 10159 /* Second argument for matmin exceeds dimension */
#define E_MATMAX1 10160 /* Non-matrix first argument for matmin */
#define E_MATMAX2 10161 /* Second argument for matmax not positive integer */
#define E_MATMAX3 10162 /* Second argument for matmax exceeds dimension */
#define E_CP1 10163 /* Non-matrix argument for cp */
#define E_CP2 10164 /* Non-one-dimensional matrix for cp */
#define E_CP3 10165 /* Matrix size not 3 for cp */
#define E_DP1 10166 /* Non-matrix argument for dp */
#define E_DP2 10167 /* Non-one-dimensional matrix for dp */
#define E_DP3 10168 /* Different-size matrices for dp */
#define E_STRLEN 10169 /* Non-string argument for strlen */
#define E_STRCAT 10170 /* Non-string argument for strcat */
#define E_SUBSTR1 10171 /* Non-string first argument for strcat */
#define E_SUBSTR2 10172 /* Non-non-negative integer second argument for strcat */
#define E_CHAR 10173 /* Bad argument for char */
#define E_ORD 10174 /* Non-string argument for ord */
#define E_INSERT1 10175 /* Non-list-variable first argument for insert */
#define E_INSERT2 10176 /* Non-integral second argument for insert */
#define E_PUSH 10177 /* Non-list-variable first argument for push */
#define E_APPEND 10178 /* Non-list-variable first argument for append */
#define E_DELETE1 10179 /* Non-list-variable first argument for delete */
#define E_DELETE2 10180 /* Non-integral second argument for delete */
#define E_POP 10181 /* Non-list-variable argument for pop */
#define E_REMOVE 10182 /* Non-list-variable argument for remove */
#define E_LN1 10183 /* Bad epsilon argument for ln */
#define E_LN2 10184 /* Non-numeric first argument for ln */
#define E_ERROR1 10185 /* Non-integer argument for error */
#define E_ERROR2 10186 /* Argument outside range for error */
#define E_EVAL3 10187 /* Attempt to eval at maximum input depth */
#define E_EVAL4 10188 /* Unable to open string for reading */
#define E_RM1 10189 /* First argument for rm is not a non-empty string */
#define E_RM2 10190 /* Unable to remove a file */
#define E_RDPERM 10191 /* Operation allowed because calc mode disallows read operations */
#define E_WRPERM 10192 /* Operation allowed because calc mode disallows write operations */
#define E_EXPERM 10193 /* Operation allowed because calc mode disallows exec operations */
#define E_MIN 10194 /* Unordered arguments for min */
#define E_MAX 10195 /* Unordered arguments for max */
#define E_LISTMIN 10196 /* Unordered items for minimum of list */
#define E_LISTMAX 10197 /* Unordered items for maximum of list */
#define E_SIZE 10198 /* Size undefined for argument type */
#define E_NO_C_ARG 10199 /* Calc must be run with a -C argument to use custom function */
#define E_NO_CUSTOM 10200 /* Calc was built with custom functions disabled */
#define E_UNK_CUSTOM 10201 /* Custom function unknown, try: show custom */
#define E_BLK1 10202 /* Non-integral length for block */
#define E_BLK2 10203 /* Negative or too-large length for block */
#define E_BLK3 10204 /* Non-integral chunksize for block */
#define E_BLK4 10205 /* Negative or too-large chunksize for block */
#define E_BLKFREE1 10206 /* Named block does not exist for blkfree */
#define E_BLKFREE2 10207 /* Non-integral id specification for blkfree */
#define E_BLKFREE3 10208 /* Block with specified id does not exist */
#define E_BLKFREE4 10209 /* Block already freed */
#define E_BLKFREE5 10210 /* No-realloc protection prevents blkfree */
#define E_BLOCKS1 10211 /* Non-integer argument for blocks */
#define E_BLOCKS2 10212 /* Non-allocated index number for blocks */
#define E_COPY1 10213 /* Non-integer or negative source index for copy */
#define E_COPY2 10214 /* Source index too large for copy */
#define E_COPY3 10215 /* E_COPY3 is no longer used */
#define E_COPY4 10216 /* Non-integer or negative number for copy */
#define E_COPY5 10217 /* Number too large for copy */
#define E_COPY6 10218 /* Non-integer or negative destination index for copy */
#define E_COPY7 10219 /* Destination index too large for copy */
#define E_COPY8 10220 /* Freed block source for copy */
#define E_COPY9 10221 /* Unsuitable source type for copy */
#define E_COPY10 10222 /* Freed block destinction for copy */
#define E_COPY11 10223 /* Unsuitable destination type for copy */
#define E_COPY12 10224 /* Incompatible source and destination for copy */
#define E_COPY13 10225 /* No-copy-from source variable */
#define E_COPY14 10226 /* No-copy-to destination variable */
#define E_COPY15 10227 /* No-copy-from source named block */
#define E_COPY16 10228 /* No-copy-to destination named block */
#define E_COPY17 10229 /* No-relocation destination for copy */
#define E_COPYF1 10230 /* File not open for copy */
#define E_COPYF2 10231 /* fseek or fsize failure for copy */
#define E_COPYF3 10232 /* fwrite error for copy */
#define E_COPYF4 10233 /* fread error for copy */
#define E_PROTECT1 10234 /* Non-variable first argument for protect */
#define E_PROTECT2 10235 /* Non-integer second argument for protect */
#define E_PROTECT3 10236 /* Out-of-range second argument for protect */
#define E_MATFILL3 10237 /* No-copy-to destination for matfill */
#define E_MATFILL4 10238 /* No-assign-from source for matfill */
#define E_MATTRACE1 10239 /* Non-matrix argument for mattrace */
#define E_MATTRACE2 10240 /* Non-two-dimensional argument for mattrace */
#define E_MATTRACE3 10241 /* Non-square argument for mattrace */
#define E_TAN1 10242 /* Bad epsilon for tan */
#define E_TAN2 10243 /* Bad argument for tan */
#define E_COT1 10244 /* Bad epsilon for cot */
#define E_COT2 10245 /* Bad argument for cot */
#define E_SEC1 10246 /* Bad epsilon for sec */
#define E_SEC2 10247 /* Bad argument for sec */
#define E_CSC1 10248 /* Bad epsilon for csc */
#define E_CSC2 10249 /* Bad argument for csc */
#define E_SINH1 10250 /* Bad epsilon for sinh */
#define E_SINH2 10251 /* Bad argument for sinh */
#define E_COSH1 10252 /* Bad epsilon for cosh */
#define E_COSH2 10253 /* Bad argument for cosh */
#define E_TANH1 10254 /* Bad epsilon for tanh */
#define E_TANH2 10255 /* Bad argument for tanh */
#define E_COTH1 10256 /* Bad epsilon for coth */
#define E_COTH2 10257 /* Bad argument for coth */
#define E_SECH1 10258 /* Bad epsilon for sech */
#define E_SECH2 10259 /* Bad argument for sech */
#define E_CSCH1 10260 /* Bad epsilon for csch */
#define E_CSCH2 10261 /* Bad argument for csch */
#define E_ASIN1 10262 /* Bad epsilon for asin */
#define E_ASIN2 10263 /* Bad argument for asin */
#define E_ACOS1 10264 /* Bad epsilon for acos */
#define E_ACOS2 10265 /* Bad argument for acos */
#define E_ATAN1 10266 /* Bad epsilon for atan */
#define E_ATAN2 10267 /* Bad argument for atan */
#define E_ACOT1 10268 /* Bad epsilon for acot */
#define E_ACOT2 10269 /* Bad argument for acot */
#define E_ASEC1 10270 /* Bad epsilon for asec */
#define E_ASEC2 10271 /* Bad argument for asec */
#define E_ACSC1 10272 /* Bad epsilon for acsc */
#define E_ACSC2 10273 /* Bad argument for acsc */
#define E_ASINH1 10274 /* Bad epsilon for asin */
#define E_ASINH2 10275 /* Bad argument for asinh */
#define E_ACOSH1 10276 /* Bad epsilon for acosh */
#define E_ACOSH2 10277 /* Bad argument for acosh */
#define E_ATANH1 10278 /* Bad epsilon for atanh */
#define E_ATANH2 10279 /* Bad argument for atanh */
#define E_ACOTH1 10280 /* Bad epsilon for acoth */
#define E_ACOTH2 10281 /* Bad argument for acoth */
#define E_ASECH1 10282 /* Bad epsilon for asech */
#define E_ASECH2 10283 /* Bad argument for asech */
#define E_ACSCH1 10284 /* Bad epsilon for acsch */
#define E_ACSCH2 10285 /* Bad argument for acsch */
#define E_GD1 10286 /* Bad epsilon for gd */
#define E_GD2 10287 /* Bad argument for gd */
#define E_AGD1 10288 /* Bad epsilon for agd */
#define E_AGD2 10289 /* Bad argument for agd */
#define E_LOGINF 10290 /* Log of zero or infinity */
#define E_STRADD 10291 /* String addition failure */
#define E_STRMUL 10292 /* String multiplication failure */
#define E_STRNEG 10293 /* String reversal failure */
#define E_STRSUB 10294 /* String subtraction failure */
#define E_BIT1 10295 /* Bad argument type for bit */
#define E_BIT2 10296 /* Index too large for bit */
#define E_SETBIT1 10297 /* Non-integer second argument for setbit */
#define E_SETBIT2 10298 /* Out-of-range index for setbit */
#define E_SETBIT3 10299 /* Non-string first argument for setbit */
#define E_OR 10300 /* Bad argument for or */
#define E_AND 10301 /* Bad argument for and */
#define E_STROR 10302 /* Allocation failure for string or */
#define E_STRAND 10303 /* Allocation failure for string and */
#define E_XOR 10304 /* Bad argument for xorvalue */
#define E_COMP 10305 /* Bad argument for comp */
#define E_STRDIFF 10306 /* Allocation failure for string diff */
#define E_STRCOMP 10307 /* Allocation failure for string comp */
#define E_SEG1 10308 /* Bad first argument for segment */
#define E_SEG2 10309 /* Bad second argument for segment */
#define E_SEG3 10310 /* Bad third argument for segment */
#define E_STRSEG 10311 /* Failure for string segment */
#define E_HIGHBIT1 10312 /* Bad argument type for highbit */
#define E_HIGHBIT2 10313 /* Non-integer argument for highbit */
#define E_LOWBIT1 10314 /* Bad argument type for lowbit */
#define E_LOWBIT2 10315 /* Non-integer argument for lowbit */
#define E_CONTENT 10316 /* Bad argument type for unary hash op */
#define E_HASHOP 10317 /* Bad argument type for binary hash op */
#define E_HEAD1 10318 /* Bad first argument for head */
#define E_HEAD2 10319 /* Bad second argument for head */
#define E_STRHEAD 10320 /* Failure for strhead */
#define E_TAIL1 10321 /* Bad first argument for tail */
#define E_TAIL2 10322 /* Bad second argument for tail */
#define E_STRTAIL 10323 /* Failure for strtail */
#define E_STRSHIFT 10324 /* Failure for strshift */
#define E_STRCMP 10325 /* Non-string argument for strcmp */
#define E_STRNCMP 10326 /* Bad argument type for strncmp */
#define E_XOR1 10327 /* Varying types of argument for xor */
#define E_XOR2 10328 /* Bad argument type for xor */
#define E_STRCPY 10329 /* Bad argument type for strcpy */
#define E_STRNCPY 10330 /* Bad argument type for strncpy */
#define E_BACKSLASH 10331 /* Bad argument type for unary backslash */
#define E_SETMINUS 10332 /* Bad argument type for setminus */
#define E_INDICES1 10333 /* Bad first argument type for indices */
#define E_INDICES2 10334 /* Bad second argument for indices */
#define E_EXP3 10335 /* Too-large re(argument) for exp */
#define E_SINH3 10336 /* Too-large re(argument) for sinh */
#define E_COSH3 10337 /* Too-large re(argument) for cosh */
#define E_SIN3 10338 /* Too-large im(argument) for sin */
#define E_COS3 10339 /* Too-large im(argument) for cos */
#define E_GD3 10340 /* Infinite or too-large result for gd */
#define E_AGD3 10341 /* Infinite or too-large result for agd */
#define E_POWER4 10342 /* Too-large value for power */
#define E_ROOT4 10343 /* Too-large value for root */
#define E_DGT1 10344 /* Non-real first arg for digit */
#define E_DGT2 10345 /* Non-integral second arg for digit */
#define E_DGT3 10346 /* Bad third arg for digit */
#define E_PLCS1 10347 /* Bad first argument for places */
#define E_PLCS2 10348 /* Bad second argument for places */
#define E_DGTS1 10349 /* Bad first argument for digits */
#define E_DGTS2 10350 /* Bad second argument for digits */
#define E_ILOG 10351 /* Bad first argument for ilog */
#define E_ILOGB 10352 /* Bad second argument for ilog */
#define E_ILOG10 10353 /* Bad argument for ilog10 */
#define E_ILOG2 10354 /* Bad argument for ilog2 */
#define E_COMB1 10355 /* Non-integer second arg for comb */
#define E_COMB2 10356 /* Too-large second arg for comb */
#define E_CTLN 10357 /* Bad argument for catalan */
#define E_BERN 10358 /* Bad argument for bern */
#define E_EULER 10359 /* Bad argument for euler */
#define E_SLEEP 10360 /* Bad argument for sleep */
#define E_TTY 10361 /* calc_tty failure */
#define E__HIGHEST 10361 /* highest calc error */
#define E__COUNT 361 /* number of calc errors */
#define E_USERDEF 20000 /* base of user defined errors */
/* names of calc error values */
#endif /* !__CALCERR_H__ */

41
win32/conf.h Normal file
View File

@@ -0,0 +1,41 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__CONF_H__)
#define __CONF_H__
/* the default :-separated search path */
#if !defined(DEFAULTCALCPATH)
#define DEFAULTCALCPATH "./cal"
#endif /* DEFAULTCALCPATH */
/* the default :-separated startup file list */
#if !defined(DEFAULTCALCRC)
#define DEFAULTCALCRC "/lib/calc/startup:~/.calcrc:./.calcinit"
#endif /* DEFAULTCALCRC */
/* the location of the help directory */
#if !defined(HELPDIR)
#define HELPDIR "/lib/calc/help"
#endif /* HELPDIR */
/* the location of the custom help directory */
#if !defined(CUSTOMHELPDIR)
#define CUSTOMHELPDIR "/lib/calc/help/custhelp"
#endif /* CUSTOMHELPDIR */
/* the default pager to use */
#if !defined(DEFAULTCALCPAGER)
#define DEFAULTCALCPAGER ""
#endif /* DEFAULTCALCPAGER */
/* where the echo command is located */
#if !defined(ECHO_PROG)
#define ECHO_PROG ""
#endif /* ECHO_PROG */
#endif /* !__CONF_H__ */

16
win32/endian_calc.h Normal file
View File

@@ -0,0 +1,16 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__ENDIAN_CALC_H__)
#define __ENDIAN_CALC_H__
/* what byte order are we? */
#define BIG_ENDIAN 4321
#define LITTLE_ENDIAN 1234
#define CALC_BYTE_ORDER LITTLE_ENDIAN
#endif /* !__ENDIAN_CALC_H__ */

28
win32/fposval.h Normal file
View File

@@ -0,0 +1,28 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__FPOSVAL_H__)
#define __FPOSVAL_H__
/* what are our file position & size types? */
#undef FILEPOS_BITS
#define FILEPOS_BITS 64
#define SWAP_HALF_IN_FILEPOS(dest, src) (*(dest) = *(src))
#undef OFF_T_BITS
#define OFF_T_BITS 32
#define SWAP_HALF_IN_OFF_T(dest, src) (*(dest) = *(src))
#undef DEV_BITS
#define DEV_BITS 32
#define SWAP_HALF_IN_DEV(dest, src) memcpy((void *)(dest), (void *)(src), 4)
#undef INODE_BITS
#define INODE_BITS 16
#define SWAP_HALF_IN_INODE(dest, src) memcpy((void *)(dest), (void *)(src), 2)
#endif /* !__FPOSVAL_H__ */

16
win32/have_const.h Normal file
View File

@@ -0,0 +1,16 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_CONST_H__)
#define __HAVE_CONST_H__
/* do we have or want const? */
#define HAVE_CONST /* yes */
#undef CONST
#define CONST const /* yes */
#endif /* !__HAVE_CONST_H__ */

16
win32/have_fpos.h Normal file
View File

@@ -0,0 +1,16 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_FPOS_H__)
#define __HAVE_FPOS_H__
/* do we have fgetpos & fsetpos functions? */
#undef HAVE_FPOS /* no */
typedef long FILEPOS;
#endif /* !__HAVE_FPOS_H__ */

15
win32/have_fpos_pos.h Normal file
View File

@@ -0,0 +1,15 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_FPOS_POS_H__)
#define __HAVE_FPOS_POS_H__
/* do we have fgetpos & fsetpos functions? */
#undef HAVE_FPOS_POS /* no */
#undef FPOS_POS_BITS
#endif /* !__HAVE_FPOS_POS_H__ */

14
win32/have_getpgid.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_GETPGID_H__)
#define __HAVE_GETPGID_H__
/* do we have or want getpgid()? */
#undef HAVE_GETPGID /* no */
#endif /* !__HAVE_GETPGID_H__ */

14
win32/have_getprid.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_GETPRID_H__)
#define __HAVE_GETPRID_H__
/* do we have or want getprid()? */
#undef HAVE_GETPRID /* no */
#endif /* !__HAVE_GETPRID_H__ */

14
win32/have_getsid.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_GETSID_H__)
#define __HAVE_GETSID_H__
/* do we have or want getsid()? */
#undef HAVE_GETSID /* no */
#endif /* !__HAVE_GETSID_H__ */

14
win32/have_gettime.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_GETTIME_H__)
#define __HAVE_GETTIME_H__
/* do we have or want clock_gettime()? */
#undef HAVE_GETTIME /* no */
#endif /* !__HAVE_GETTIME_H__ */

14
win32/have_malloc.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_MALLOC_H__)
#define __HAVE_MALLOC_H__
/* do we have /usr/include/malloc.h? */
#define HAVE_MALLOC_H /* yes */
#endif /* !__HAVE_MALLOC_H__ */

14
win32/have_memmv.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_MEMMV_H__)
#define __HAVE_MEMMV_H__
/* do we have or want memmove()? */
#define HAVE_MEMMOVE /* yes */
#endif /* !__HAVE_MEMMV_H__ */

14
win32/have_newstr.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_NEWSTR_H__)
#define __HAVE_NEWSTR_H__
/* do we have or want memcpy(), memset() & strchr()? */
#define HAVE_NEWSTR /* yes */
#endif /* !__HAVE_NEWSTR_H__ */

14
win32/have_offscl.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_OFFSCL_H__)
#define __HAVE_OFFSCL_H__
#undef HAVE_OFF_T_SCALAR
#define HAVE_OFF_T_SCALAR /* off_t is a simple value */
#endif /* !__HAVE_OFFSCL_H__ */

14
win32/have_posscl.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_POSSCL_H__)
#define __HAVE_POSSCL_H__
#undef HAVE_FILEPOS_SCALAR
#define HAVE_FILEPOS_SCALAR /* FILEPOS is a simple value */
#endif /* !__HAVE_POSSCL_H__ */

14
win32/have_rusage.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_RUSAGE_H__)
#define __HAVE_RUSAGE_H__
/* do we have or want getrusage()? */
#undef HAVE_GETRUSAGE /* no */
#endif /* !__HAVE_RUSAGE_H__ */

14
win32/have_stdlib.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_STDLIB_H__)
#define __HAVE_STDLIB_H__
/* do we have /usr/include/stdlib.h? */
#define HAVE_STDLIB_H /* yes */
#endif /* !__HAVE_STDLIB_H__ */

14
win32/have_strdup.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_RUSAGE_H__)
#define __HAVE_RUSAGE_H__
/* do we have or want getstrdup()? */
#define HAVE_STRDUP /* yes */
#endif /* !__HAVE_RUSAGE_H__ */

14
win32/have_string.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_STRING_H__)
#define __HAVE_STRING_H__
/* do we have /usr/include/string.h? */
#define HAVE_STRING_H /* yes */
#endif /* !__HAVE_STRING_H__ */

17
win32/have_times.h Normal file
View File

@@ -0,0 +1,17 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_TIMES_H__)
#define __HAVE_TIMES_H__
/* do we have /usr/include/times.h? */
#undef HAVE_TIMES_H /* no */
#undef HAVE_SYS_TIMES_H /* no */
#define HAVE_TIME_H /* yes */
#undef HAVE_SYS_TIME_H /* no */
#endif /* !__HAVE_TIMES_H__ */

14
win32/have_uid_t.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_UID_T_H__)
#define __HAVE_UID_T_H__
/* do we have or want uid_t? */
#undef HAVE_UID_T /* no */
#endif /* !__HAVE_UID_T_H__ */

14
win32/have_unistd.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_UNISTD_H__)
#define __HAVE_UNISTD_H__
/* do we have /usr/include/unistd.h? */
#undef HAVE_UNISTD_H /* no */
#endif /* !__HAVE_UNISTD_H__ */

14
win32/have_urandom.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_URANDOM_H__)
#define __HAVE_URANDOM_H__
/* do we have /dev/urandom? */
#undef HAVE_URANDOM_H /* no */
#endif /* !__HAVE_URANDOM_H__ */

14
win32/have_ustat.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__HAVE_USTAT_H__)
#define __HAVE_USTAT_H__
/* do we have or want ustat()? */
#undef HAVE_USTAT /* no */
#endif /* !__HAVE_USTAT_H__ */

31
win32/longbits.h Normal file
View File

@@ -0,0 +1,31 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__LONGBITS_H__)
#define __LONGBITS_H__
#undef LONG_BITS
#define LONG_BITS 32 /* bit length of a long */
/* size of long was forced */
typedef unsigned char USB8; /* unsigned 8 bits */
typedef signed char SB8; /* signed 8 bits */
typedef unsigned short USB16; /* unsigned 16 bits */
typedef short SB16; /* signed 16 bits */
typedef unsigned long USB32; /* unsigned 32 bits */
typedef long SB32; /* signed 32 bits */
#undef HAVE_B64 /* we have no USB64 and no SB64 types */
/* no 64 bit constants */
#define U(x) no 33 to 64 bit constants - do not use this macro!
#define L(x) no 33 to 64 bit constants - do not use this macro!
#endif /* !__LONGBITS_H__ */

16
win32/longlong.h Normal file
View File

@@ -0,0 +1,16 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__LONGLONG_H__)
#define __LONGLONG_H__
/* do we have/want to use a long long type? */
#undef HAVE_LONGLONG
#define LONGLONG_BITS 0 /* no */
#undef L64_FORMAT
#endif /* !__LONGLONG_H__ */

23
win32/terminal.h Normal file
View File

@@ -0,0 +1,23 @@
/*
* DO NOT EDIT -- generated by the Makefile
*/
#if !defined(__TERMINAL_H__)
#define __TERMINAL_H__
/* determine the type of terminal interface */
#if !defined(USE_TERMIOS)
#if !defined(USE_TERMIO)
#if !defined(USE_SGTTY)
/* windoz, use none of these modes */
#undef USE_TERMIOS /* <termios.h> */
#undef USE_TERMIO /* <termio.h> */
#undef USE_SGTTY /* <sys/ioctl.h> */
#endif
#endif
#endif
#endif /* !__TERMINAL_H__ */

50
win32dll.h Normal file
View 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__ */

243
zmath.h
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: zmath.h,v 29.4 2001/02/25 22:07:36 chongo Exp $
* @(#) $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,20 +38,7 @@
#define __ZMATH_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 */
#include "win32dll.h"
#include "alloc.h"
#include "endian_calc.h"
#include "longbits.h"
@@ -281,126 +268,126 @@ typedef struct {
/*
* Function prototypes for integer math routines.
*/
DLL extern HALF * alloc(LEN len);
extern DLL HALF * alloc(LEN len);
#ifdef ALLOCTEST
DLL extern void freeh(HALF *);
extern DLL void freeh(HALF *);
#endif
/*
* Input, output, and conversion routines.
*/
DLL extern void zcopy(ZVALUE z, ZVALUE *res);
DLL extern void itoz(long i, ZVALUE *res);
DLL extern void utoz(FULL i, ZVALUE *res);
DLL extern void str2z(char *s, ZVALUE *res);
DLL extern long ztoi(ZVALUE z);
DLL extern FULL ztou(ZVALUE z);
DLL extern void zprintval(ZVALUE z, long decimals, long width);
DLL extern void zprintx(ZVALUE z, long width);
DLL extern void zprintb(ZVALUE z, long width);
DLL extern void zprinto(ZVALUE z, long width);
DLL 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.
*/
DLL extern void zmuli(ZVALUE z, long n, ZVALUE *res);
DLL extern long zdivi(ZVALUE z, long n, ZVALUE *res);
DLL extern long zmodi(ZVALUE z, long n);
DLL extern void zadd(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern void zsub(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern void zmul(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern long zdiv(ZVALUE z1, ZVALUE z2, ZVALUE *res, ZVALUE *rem, long R);
DLL extern long zquo(ZVALUE z1, ZVALUE z2, ZVALUE *res, long R);
DLL extern long zmod(ZVALUE z1, ZVALUE z2, ZVALUE *rem, long R);
DLL extern void zequo(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern BOOL zdivides(ZVALUE z1, ZVALUE z2);
DLL extern void zor(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern void zand(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern void zxor(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern void zandnot(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern long zpopcnt(ZVALUE z, int bitval);
DLL extern void zshift(ZVALUE z, long n, ZVALUE *res);
DLL extern void zsquare(ZVALUE z, ZVALUE *res);
DLL extern long zlowbit(ZVALUE z);
DLL extern LEN zhighbit(ZVALUE z);
DLL extern void zbitvalue(long n, ZVALUE *res);
DLL extern BOOL zisset(ZVALUE z, long n);
DLL extern BOOL zisonebit(ZVALUE z);
DLL extern BOOL zisallbits(ZVALUE z);
DLL extern FLAG ztest(ZVALUE z);
DLL extern FLAG zrel(ZVALUE z1, ZVALUE z2);
DLL extern FLAG zabsrel(ZVALUE z1, ZVALUE z2);
DLL 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.
*/
DLL extern FULL uugcd(FULL i1, FULL i2);
DLL extern long iigcd(long i1, long i2);
DLL extern void zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern void zlcm(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern void zreduce(ZVALUE z1, ZVALUE z2, ZVALUE *z1res, ZVALUE *z2res);
DLL extern void zfact(ZVALUE z, ZVALUE *dest);
DLL extern void zperm(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern int zcomb(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern FLAG zjacobi(ZVALUE z1, ZVALUE z2);
DLL extern void zfib(ZVALUE z, ZVALUE *res);
DLL extern void zpowi(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern void ztenpow(long power, ZVALUE *res);
DLL extern void zpowermod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res);
DLL extern BOOL zmodinv(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern BOOL zrelprime(ZVALUE z1, ZVALUE z2);
DLL extern long zlog(ZVALUE z1, ZVALUE z2);
DLL extern long zlog10(ZVALUE z);
DLL extern long zdivcount(ZVALUE z1, ZVALUE z2);
DLL extern long zfacrem(ZVALUE z1, ZVALUE z2, ZVALUE *rem);
DLL extern long zgcdrem(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern long zdigits(ZVALUE z1);
DLL extern long zdigit(ZVALUE z1, long n);
DLL extern FLAG zsqrt(ZVALUE z1, ZVALUE *dest, long R);
DLL extern void zroot(ZVALUE z1, ZVALUE z2, ZVALUE *dest);
DLL extern BOOL zissquare(ZVALUE z);
DLL 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.
*/
DLL extern FLAG zisprime(ZVALUE z);
DLL extern FULL znprime(ZVALUE z);
DLL extern FULL next_prime(FULL v);
DLL extern FULL zpprime(ZVALUE z);
DLL extern void zpfact(ZVALUE z, ZVALUE *dest);
DLL extern BOOL zprimetest(ZVALUE z, long count, ZVALUE skip);
DLL extern BOOL zredcprimetest(ZVALUE z, long count, ZVALUE skip);
DLL extern BOOL znextcand(ZVALUE z1, long count, ZVALUE skip, ZVALUE res, ZVALUE mod, ZVALUE *cand);
DLL extern BOOL zprevcand(ZVALUE z1, long count, ZVALUE skip, ZVALUE res, ZVALUE mod, ZVALUE *cand);
DLL extern FULL zlowfactor(ZVALUE z, long count);
DLL extern FLAG zfactor(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern long zpix(ZVALUE z1);
DLL 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. :-)
*/
DLL extern void zsquaremod(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern void zminmod(ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern BOOL zcmpmod(ZVALUE z1, ZVALUE z2, ZVALUE z3);
DLL 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.
*/
DLL extern void ztrim(ZVALUE *z);
DLL extern void zshiftr(ZVALUE z, long n);
DLL extern void zshiftl(ZVALUE z, long n);
DLL 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);
/*
@@ -417,13 +404,13 @@ typedef struct {
ZVALUE one; /* REDC format for the number 1 */
} REDC;
DLL extern REDC *zredcalloc(ZVALUE z1);
DLL extern void zredcfree(REDC *rp);
DLL extern void zredcencode(REDC *rp, ZVALUE z1, ZVALUE *res);
DLL extern void zredcdecode(REDC *rp, ZVALUE z1, ZVALUE *res);
DLL extern void zredcmul(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res);
DLL extern void zredcsquare(REDC *rp, ZVALUE z1, ZVALUE *res);
DLL 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);
/*
@@ -564,32 +551,32 @@ DLL extern void zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res);
/*
* Output routines for either FILE handles or strings.
*/
DLL extern void math_chr(int ch);
DLL extern void math_str(char *str);
DLL extern void math_fill(char *str, long width);
DLL extern void math_flush(void);
DLL extern void math_divertio(void);
DLL extern void math_cleardiversions(void);
DLL extern char *math_getdivertedio(void);
DLL extern int math_setmode(int mode);
DLL extern LEN math_setdigits(LEN digits);
DLL 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.
*/
DLL extern void math_error(char *, ...);
extern DLL void math_error(char *, ...);
/*
* external swap functions
*/
DLL extern HALF *swap_b8_in_HALFs(HALF *dest, HALF *src, LEN len);
DLL extern ZVALUE *swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);
DLL extern HALF *swap_b16_in_HALFs(HALF *dest, HALF *src, LEN len);
DLL extern ZVALUE *swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);
DLL 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);
/*
@@ -609,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 */
/*