Release calc version 2.12.0.8

This commit is contained in:
Landon Curt Noll
2006-08-20 10:53:51 -07:00
parent ee99adf8ca
commit c335809b5f
25 changed files with 598 additions and 231 deletions

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.29 $
# @(#) $Id: Makefile,v 29.29 2006/06/26 05:46:06 chongo Exp $
# @(#) $Revision: 29.30 $
# @(#) $Id: Makefile,v 29.30 2006/08/20 15:01:57 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
#
# Under source code control: 1991/07/23 06:47:57
@@ -267,15 +267,15 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
#
DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd append \
appr arg argv arrow asec asech asin asinh assign atan atan2 atanh \
avg base base2 bernoulli bit blk blkcpy blkfree blocks bround btrunc \
calc_tty calclevel catalan ceil cfappr cfsim char cmdbuf cmp comb \
conj cos cosh cot coth count cp csc csch ctime delete den dereference \
det digit digits display dp epsilon errcount errmax errno error \
euler eval exp fact factor fclose fcnt feof ferror fflush fgetc \
fgetfield fgetline fgets fgetstr fib files floor fopen forall \
fpathopen fprintf fputc fputs fputstr frac free freebernoulli \
freeeuler freeglobals freeredc freestatics frem freopen fscan \
fscanf fseek fsize ftell gcd gcdrem gd getenv hash head highbit \
avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
btrunc calc_tty calclevel catalan ceil cfappr cfsim char cmdbuf \
cmp comb conj cos cosh cot coth count cp csc csch ctime delete den \
dereference det digit digits display dp epsilon errcount errmax \
errno error estr euler eval exp fact factor fclose fcnt feof ferror \
fflush fgetc fgetfield fgetfile fgetline fgets fgetstr fib files \
floor fopen forall fpathopen fprintf fputc fputs fputstr frac free \
freebernoulli freeeuler freeglobals freeredc freestatics frem freopen \
fscan fscanf fseek fsize ftell gcd gcdrem gd getenv hash head highbit \
hmean hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert \
int inverse iroot isassoc isatty isblk isconfig isdefined iserror \
iseven isfile ishash isident isint islist ismat ismult isnull isnum \

45
help/estr Normal file
View File

@@ -0,0 +1,45 @@
NAME
estr - represent some types of value by text strings
SYNOPSIS
estr(x)
TYPES
x null, string, real or complex number, list, matrix,
object. block, named block, error
return string
DESCRIPTION
This function attempts to represent x exactly by a string s of
ordinary text characters such that eval(s) == x.
If x is null, estr(x) returns the string "".
If x is a string, estr(x) returns the string in which occurrences of
newline, tab, ", \, etc. have been converted to \n, \t, \",
\\, etc., '\0' to \000 or \0 according as the next character is
or is not an octal digit, and other non-text characters to their
escaped hex representation, e.g. char(165) becomes \xa5.
For real x, estr(x) represebts x in fractional mode.
EXAMPLE
; estr("abc\0xyz\00023\n\xa5\r\n")
""abc\0xyz\00023\n\xa5\r\n""
; estr(1.67)
"167/100"
; estr(mat[3] = {2, list(3,5), "abc"})
"mat[3]={2,list(3,5),"abc""
LIMITS
none
LINK LIBRARY
none
SEE ALSO
str, strprintf

View File

@@ -7,19 +7,18 @@ SYNOPSIS
TYPES
fs file stream open for reading
return string, null or error value
return string or null
DESCRIPTION
If characters cannot be read from the file, an error value is returned.
Otherwise starting at the current file position, any whitespace
Starting at the current file position, any whitespace
characters are skipped. If the reading reaches end-of-file, the
null value is returned. If non-whitespace is encountered, formation
of a string begins, continuing until whitespace of '\0' or end-of-file
is reached. The returned value is this string (terminated as usual
by a null character). After the operation, the file position will
be immediately after the first whitespace character of '\0' or at
end-of-file.
null value is returned. Otherwise the function returns the empty
string "" if the first non-white character is '\0', and in other cases,
the string formed by the non-white-space characters read until '\0' or
a white-space character or te end of the file is reached. In the
cases where the reading is stopped by '\0' or white-space character,
the file position will be that immediately after that character.
EXAMPLE
@@ -67,8 +66,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.5 $
## @(#) $Id: fgetfield,v 29.5 2006/06/25 22:16:55 chongo Exp $
## @(#) $Revision: 29.6 $
## @(#) $Id: fgetfield,v 29.6 2006/08/20 15:01:57 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fgetfield,v $
##
## Under source code control: 1996/04/30 03:05:17

72
help/fgetfile Normal file
View File

@@ -0,0 +1,72 @@
NAME
fgetfile - read the rest of a file to form a string
SYNOPSIS
fgetfile(fs)
TYPES
fs file stream open for reading
return string or null value
DESCRIPTION
If the current file position for fs is the end of the file, the
null value is returned.
Otherwise the function returns the string formed from reading all
characters from the current file position to the end of the file.
If the content of the file "newfile" is a sequence of statements that
could form the body of function definition, the statement sequence
fs = fopen("newfile", "r");
eval(fgetfile(fs));
achieves the same as the command
read newfile;
EXAMPLE
; f = fopen("/tmp/newfile", "w")
; fputs(f, "abc\0xyz\n\t\xb0\0\r\v123"
; freopen(f, "r")
; estr(fgetfile(f))
""abc\0xyz\n\t\xb0\0\r\v123""
LIMITS
none
LINK LIBRARY
none
SEE ALSO
fgets, fgetstr, files, fopen, fprintf, fputs, fputstr
## Copyright (C) 1999-2006 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: fgetfile,v 29.2 2006/08/20 15:01:57 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fgetfile,v $
##
## Under source code control: 1996/04/30 03:05:17
## File existed as early as: 1996
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

View File

@@ -2,34 +2,34 @@ NAME
fputs - write a string to a file
SYNOPSIS
fputs(fd, data)
fputs(fd, s1, s2, ...)
TYPES
fd file
data str
fd file stream open for writing
s1, s2, ... strings
return nil
return null value
DESCRIPTION
This function writes the string found in data to the file
associated with fd.
This function writes in succession the strings s1, s2, ..., to the
file associated with fd.
EXAMPLE
; fd = fopen("/tmp/newfile", "w")
; fputs(fd, "chongo was here\n")
; fputs(fd, "chongo was", " here\n")
; fd2 = fopen("/tmp/newfile", "r")
; fgetline(fd2)
"chongo was here"
LIMITS
fd must be associated with an open file
The number of arguments is not to exceed 1024
LINK LIBRARY
none
SEE ALSO
errno, fclose, feof, ferror, fflush, fgetc, fgetline, fgets, files, fopen,
fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt
errno, fclose, feof, ferror, fflush, fgetc, fgetfile, fgetline, fgets,
files, fopen, fprintf, fputc, fseek, fsize, ftell, isfile
## Copyright (C) 1999 Landon Curt Noll
##
@@ -47,8 +47,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.3 $
## @(#) $Id: fputs,v 29.3 2006/05/07 07:25:46 chongo Exp $
## @(#) $Revision: 29.4 $
## @(#) $Id: fputs,v 29.4 2006/08/20 15:01:57 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fputs,v $
##
## Under source code control: 1995/03/04 11:33:20

View File

@@ -26,7 +26,7 @@ EXAMPLE
; name(f)
"/tmp/beta"
; names(files(0))
; name(files(0))
"(stdin)"
LIMITS
@@ -54,8 +54,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.4 $
## @(#) $Id: name,v 29.4 2006/06/25 22:16:55 chongo Exp $
## @(#) $Revision: 29.5 $
## @(#) $Id: name,v 29.5 2006/08/20 15:01:57 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/name,v $
##
## Under source code control: 1997/04/05 14:12:44

View File

@@ -1,41 +1,73 @@
NAME
quomod - assign quotient and remainder to two variables
quomod - assign quotient and remainder to two lvalues
SYNOPSIS
quomod(x, y, q, r [, rnd])
quomod(x, y, Q, R [, rnd])
TYPES
x real
y real
q any
r any
rnd integer, defaults to config("quomod")
Q null-or-real-valued lvalue with assign-to permission
R null-or-real-valued lvalue with assign-to permission
rnd nonnegative integer, defaults to config("quomod")
return real
return 0 or 1
DESCRIPTION
Returns 0 or 1 according as x is or is not a multiple of y.
Let x = q * y + r where q is an integer and 0 <= r < y
This function assigns the values q and r to the variables
Q and R. If x >= 0, the results for Q and R are the same as
those given by Q = x // y, R = x % y.
If y is nonzero and x/y is an integer q, this function assigns
q to Q and zero to R, and returns zero.
The argument rnd (if passed or config value config("quomod") if the
rnd argument is not passed) impacts the rounding mode for producing
the quotient and modulus. See "help quo" details of how the quotient
is impacted by rounding modes. See "help mod" for details of how
the modulus is impacted by rounding modes. The only difference on
those descriptions is that quomod() is controlled by a single config
value config("quomod") instead of config("quo") and config("mod").
If y is zero, zero is assigned to Q, x to R and 0 or 1 returned
according as x is zero or nonzero.
XXX - replace the above paragraph and directly describe how rnd
and config("quomod") impact quomod.
In the remaining case, y nonzero and x/y not an intger, there
are two pairs (q,r) for which x = q * y + r, q is an integer, and
abs(r) < abs(y). Depending on the low 5 bits of rnd, the q and r
of one of these pairs will be assigned to Q and R respectively,
and the number 1 returned. The effects of rnd can be described in
terms of the way q is related to x/y, e.g. by rounding down,
rounding towards zero, rounding to a nearest integeri, etc. or
by properties of the remainder r, e.g. positive, negative,
smallest, etc. The effects of the most commonly used values of
rnd are described in the following table:
The C language method of modulus and integer division is:
rnd q r
0 round down. q = floor(x/y) same sign as y
1 round up, q = ceil(x/y) opposite sign to y
2 round to zero, q = int(x/y) same sign as x, r = y * frac(x/y)
3 round from zero oppsite sign to x
4 positive
5 negative
6 same sign as x/y
7 opposite sigh to x/y
8 to nearest even
9 to nearest odd
For 16 <= rnd < 32, the rounding is to the nearest integer and r
is the smallest (in absolute value) remainder except when x/y is
halfway between consecutive integers, in which case the rounding
is as given by the 4 low bits of rnd. Using rnd = 24 gives the
cpmmonly used principle of rounding: round to the nearest integer,
but take the even integer when there are two equally close integers.
For more detail on the effects of rnd for values other than those
listed above, see "help quo" and "help mod".
In all cases, the values assigned to Q and R by quomod(x, y, Q, R, rnd)
are the same as those given by Q = quo(x,y,rnd), R = mod(x,y,rnd).
If config("quo") == rnd, Q is also given by quo(x,y) or x // y.
If config("mod") == rnd, R is also given by mod(x,y) or x % y.
The rounding used by the C language for x / y and x % y corresponds
to rnd = 2.
An error values is returned and the values of Q and R are not changed
if Q and R are not both lvalues, or if the current value of any
argument is not as specified above, or if Q or R has no-assign-to
prptection, e.g. after protect(Q,1).
config("quomod", 2)
config("quo", 2)
config("mod", 2)
EXAMPLE
; global u, v;
@@ -59,13 +91,13 @@ EXAMPLE
1 3 -1
LIMITS
y > 0
rnd < 2^31
LINK LIBRARY
BOOL qquomod(NUMBER *q1, NUMBER *q2, NUMBER **retqdiv, NUMBER **retqmod)
BOOL qquomod(NUMBER *q1, NUMBER *q2, NUMBER **quo, NUMBER **mod)
SEE ALSO
//, %
//, %, quo, mod, floor. ceil, int. frac
## Copyright (C) 1999-2006 Landon Curt Noll
##
@@ -83,8 +115,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.5 $
## @(#) $Id: quomod,v 29.5 2006/06/25 20:33:26 chongo Exp $
## @(#) $Revision: 29.7 $
## @(#) $Id: quomod,v 29.7 2006/08/20 15:01:57 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/quomod,v $
##
## Under source code control: 1995/05/07 03:17:03