Release calc version 2.12.0.2

This commit is contained in:
Landon Curt Noll
2006-06-03 15:54:31 -07:00
parent 23a5fc3ede
commit 9d62873a02
23 changed files with 229 additions and 139 deletions

View File

@@ -34,8 +34,9 @@ DESCRIPTION
EXAMPLE
Assuming there is no file with name "not_a_file"
; errno(0)
; errmax(errcount()+4)
0
; errmax(errcount()+4)
20
; badfile = fopen("not_a_file", "r")
; print errno(), error(), strerror()
2 System error 2 No such file or directory
@@ -70,8 +71,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: errno,v 29.4 2006/05/21 07:31:46 chongo Exp $
## @(#) $Revision: 29.5 $
## @(#) $Id: errno,v 29.5 2006/05/23 19:15:48 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/errno,v $
##
## Under source code control: 1994/10/27 03:05:08

View File

@@ -19,17 +19,13 @@ DESCRIPTION
is returned by some function, errno() will return the value n.
EXAMPLE
Note that by default, errmax() is 0 so unless errmax() is
increased you will get:
; ba = error(10009)
Error 10009 caused errcount to exceed errmax
; errmax(errcount()+1)
0
20
; a = error(10009)
; a
Error 10009
; strerror(a)
"Bad argument for inverse"
LIMITS
none
@@ -57,8 +53,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.4 $
## @(#) $Id: error,v 29.4 2006/05/21 07:31:46 chongo Exp $
## @(#) $Revision: 29.5 $
## @(#) $Id: error,v 29.5 2006/05/23 19:15:48 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/error,v $
##
## Under source code control: 1995/12/18 03:30:59

View File

@@ -9,38 +9,47 @@ TYPES
limit integer with abs(limit) < 2^32, defaults to 2^32 - 1
err integer
return positive integer, -1 or err
return positive integer or err
DESCRIPTION
This function ignores the signs of n and limit, so here we shall
assume n and limit are both nonnegative.
If n >= 0 and n has a prime factor less than or equal to limit,
factor(n, limit) returns the smallest such factor. If n >= 0
and the smallest prime factor of n exceeds limit, 1 is returned.
In particular, if n >= 0 and limit <= 1, factor(n, limit)
always returns 1; factor(n,2) returns 2 if and only if n is even.
If n has a prime proper factor less than or equal to limit, then
factor(n, limit) returns the smallest such factor.
If n < 0, -1 is returned.
NOTE: A proper factor of n>1 is a factor < n. In other words,
for n>1 is not a proper factor of itself. The value 1
is a special case because 1 is a proper factor of 1.
If abs(limit) >= 2^32, factor(n, limit) causes an error,
factor(n, limit, err) returns the value of err.
When every prime proper factor of n is greater than limit, 1 is
returned. In particular, if limit < 2, factor(n, limit) always
returns 1. Also, factor(n,2) returns 2 if and only if n is even
and n > 2.
If 1 < n < nextprime(limit)^2, then f(n, limit) == 1 <==> n is prime.
For example, if 1 < n < 121, n is prime if and only if f(n,7) == 1.
If limit >= 2^32, factor(n, limit) causes an error and factor(n,
limit, err) returns the value of err.
EXAMPLE
; print factor(35,4), factor(35,5), factor(35), factor(-35)
1 5 5 -1
1 5 5 5
; print factor(2^32 + 1), factor(2^47 - 1), factor(2^59 - 1)
641 2351 179951
LIMITS
none
limit < 2^32
LINK LIBRARY
FLAG zfactor(ZVALUE n, ZVALUE limit, ZVALUE *res)
FLAG zfactor(ZVALUE n, ZVALUE limit, ZVALUE *res)
SEE ALSO
lfactor
## Copyright (C) 1999 Landon Curt Noll
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
@@ -56,8 +65,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: factor,v 29.3 2006/05/07 07:25:46 chongo Exp $
## @(#) $Revision: 29.4 $
## @(#) $Id: factor,v 29.4 2006/06/01 11:36:02 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/factor,v $
##
## Under source code control: 1995/12/18 12:34:57

View File

@@ -35,7 +35,7 @@ EXAMPLE
file is open
; err = fclose(fd);
; if (isnull(err)) print "close successful"; else errno(err);
; if (isnull(err)) print "close successful"; else strerror(err);
close successful
; if (!fd) print "file is closed";
@@ -51,7 +51,7 @@ SEE ALSO
errno, fclose, feof, ferror, fflush, fgetc, fgetline, fgets, files, fopen,
fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt
## Copyright (C) 1999 Landon Curt Noll
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
@@ -67,8 +67,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: fclose,v 29.3 2006/05/07 07:25:46 chongo Exp $
## @(#) $Revision: 29.4 $
## @(#) $Id: fclose,v 29.4 2006/05/23 19:15:48 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fclose,v $
##
## Under source code control: 1994/10/27 03:04:16

View File

@@ -59,12 +59,12 @@ Using files
function returns the numeric value of errno if there had been an
error using the file, or the null value if there was no error.
The builtin 'errno' can be use to convert an errno number into
The builtin 'strerror' can be use to convert an errno number into
a slightly more meaningful error message:
badfile = fopen("not_a_file", "r");
if (!isfile(badfile)) {
print "error #" : badfile : ":", errno(badfile);
print "error #" : badfile : ":", strerror(badfile);
}
File values can be printed. When this is done, the filename of the
@@ -166,7 +166,7 @@ Using files
but the output is returned as a string value instead of being
printed.
## Copyright (C) 1999 Landon Curt Noll
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
@@ -182,8 +182,8 @@ Using files
## 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,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: file,v 29.3 2006/05/23 19:15:48 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/file,v $
##
## Under source code control: 1991/07/21 04:37:19

View File

@@ -75,7 +75,7 @@ DESCRIPTION
The truth value of an opened file is TRUE.
If the open is unsuccessful, the numeric value of errno is returned.
You can the errno() builtin to determine what the errno number means.
You can the strerror() builtin to determine what the errno number means.
EXAMPLE
; fd = fopen("/etc/motd", "r")
@@ -90,9 +90,11 @@ EXAMPLE
; outfile
FILE 4 "~/tmp/output" (writing, pos 0)
; badfile = fopen("not_a_file", "r")
; if (!isfile(badfile)) print "error #" : badfile : ":", errno(badfile);
error #2: No such file or directory
; badfile = fopen("not_a_file", "r");
; if (!isfile(badfile)) {
;; printf("error(%d): %s\n", errno(badfile), strerror(badfile));
;; }
error(2): No such file or directory
LIMITS
none
@@ -103,9 +105,9 @@ LINK LIBRARY
SEE ALSO
errno, fclose, feof, ferror, fflush, fgetc, fgetline, fgets, files, fopen,
fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt,
fpathopen
fpathopen, strerror
## Copyright (C) 1999 Landon Curt Noll
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
@@ -121,8 +123,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: fopen,v 29.4 2006/05/07 07:18:26 chongo Exp $
## @(#) $Revision: 29.6 $
## @(#) $Id: fopen,v 29.6 2006/05/23 20:06:16 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fopen,v $
##
## Under source code control: 1994/10/27 03:04:17

View File

@@ -165,7 +165,7 @@ EXAMPLE
FILE 7 "/home/chongo/tmp/output" (writing, pos 0)
; badfile = fpathopen("no_such_file", "r")
; if (!isfile(badfile)) print "error #" : badfile : ":", errno(badfile);
; if (!isfile(badfile)) print "error #" errno(badfile) : ":" : strerror(badfile);
error #2: No such file or directory
LIMITS
@@ -195,8 +195,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: fpathopen,v 29.2 2006/05/07 07:24:34 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: fpathopen,v 29.3 2006/05/23 19:15:48 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fpathopen,v $
##
## Under source code control: 2006/05/07 23:56:04

View File

@@ -11,20 +11,29 @@ TYPES
return positive integer
DESCRIPTION
If n >= 0 and n has a prime factor in the first m primes,
lfactor(n, m) returns the smallest such factor.
This function ignores the signs of n and m, so here we shall
assume n and limit are both nonnegative.
If n < 0, -1 is returned.
If n is nonzero and abs(n) has a prime proper factor in the first
m primes (2, 3, 5, ...), then lfactor(n, m) returns the smallest
such factor. Otherwise 1 is returned.
If n is nonzero and m = pix(limit), then lfactor(n, m) returns the
same as factor(n, limit).
Both lfactor(n, 0) and lfactor(1, m) return 1 for all n and m.
Also lfactor(0, m) always returns 1, and factor(0, limit) always
returns 2 if limit >= 2.
EXAMPLE
; print lfactor(35,2), lfactor(35,3), lfactor(-35, 3)
1 5 -1
1 5 5
; print lfactor(2^32+1,115), lfactor(2^32+1,116), lfactor(2^59-1,1e5)
1 641 179951
LIMITS
none
m <= 203280221 (= number of primes < 2^32)
LINK LIBRARY
NUMBER *qlowfactor(NUMBER *n, NUMBER *count)
@@ -33,7 +42,7 @@ LINK LIBRARY
SEE ALSO
factor
## Copyright (C) 1999 Landon Curt Noll
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
@@ -49,8 +58,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: lfactor,v 29.3 2006/05/07 07:25:46 chongo Exp $
## @(#) $Revision: 29.4 $
## @(#) $Id: lfactor,v 29.4 2006/06/01 11:36:02 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/lfactor,v $
##
## Under source code control: 1995/12/18 12:34:57

View File

@@ -8,19 +8,21 @@ Calc command line
#!/usr/local/bin/calc -S [other_flags]
-c Continue reading command lines even after an execution
error has caused the abandonment of a line.
-c Continue reading command lines even after an scan/parse
error has caused the abandonment of a line. Note that this
option only deals with scanning and parsing of the calc
language. It does not deal with execution or run-time errors.
For example:
calc read many_errors.cal
will cause calc to abort on the first error, whereas:
will cause calc to abort on the first syntax error, whereas:
calc -c read many_errors.cal
will cause calc to try to process each line being read
despite the errors that it encounters.
despite the scan/parse errors that it encounters.
By default, calc startup resource files are
silently ignored if not found. This flag will report
@@ -357,8 +359,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.6 $
## @(#) $Id: usage,v 29.6 2003/06/10 21:39:34 chongo Exp $
## @(#) $Revision: 29.8 $
## @(#) $Id: usage,v 29.8 2006/06/01 12:04:16 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/usage,v $
##
## Under source code control: 1991/07/21 04:37:25