mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c773ee736f | ||
|
7d0cc52afe | ||
|
2441df7fdc | ||
|
5c565a7cea | ||
|
810e541281 | ||
|
ee30d787ea | ||
|
4e92927183 | ||
|
fb4a03c1f1 | ||
|
81a523043e | ||
|
2c0d0bbc1b | ||
|
a7147039ee | ||
|
6fa83e417e | ||
|
c335809b5f |
72
BUGS
72
BUGS
@@ -68,10 +68,6 @@ of a context diff patch).
|
||||
|
||||
Known bugs:
|
||||
|
||||
The stoponerror() facility does not seem to work, or perhaps
|
||||
the stoponerror help file is incorrect. The stoponerror help file
|
||||
lacks examples because of this problem.
|
||||
|
||||
We are sure some more bugs exist. When you find them, please let
|
||||
us know! See the above for details on how to report and were to
|
||||
EMail your bug reports and hopefully patches to fix them.
|
||||
@@ -84,6 +80,25 @@ mis-features in calc:
|
||||
work better. The following is a list of mis-features that should be
|
||||
addressed and improved someday.
|
||||
|
||||
* When statement is of the form { ... }, the leading { MUST BE ON
|
||||
THE SAME LINE as the if, for, while or do keyword.
|
||||
|
||||
This works as expected:
|
||||
|
||||
if (expr) {
|
||||
...
|
||||
}
|
||||
|
||||
However this WILL NOT WORK AS EXPECTED:
|
||||
|
||||
if (expr)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
This needs to be changed. See also "help statement", "help unexpected",
|
||||
and "help todo".
|
||||
|
||||
* The chi.cal resource file does not work well with odd degrees
|
||||
of freedom. Can someone improve this algorithm?
|
||||
|
||||
@@ -114,51 +129,6 @@ Problems with old systems that have known work-a-rounds:
|
||||
to fail the regression test. The work-a-round is to compile with -O
|
||||
or to use gcc-2.96 or later.
|
||||
|
||||
This bug has been observed on the Sparc and the PowerPC machine.
|
||||
|
||||
On the PowerPC with gcc-2.95 when compiled with -O2, the following
|
||||
patch seems to help:
|
||||
|
||||
*** zfunc.c.orig Fri Feb 23 18:18:39 2001
|
||||
--- zfunc.c Fri Feb 23 18:39:33 2001
|
||||
***************
|
||||
*** 1481,1487 ****
|
||||
{
|
||||
HALF *a, *A, *b, *a0, u;
|
||||
int i, j, j1, j2, k, k1, m, m0, m1, n, n0, o;
|
||||
! FULL d, e, f, g, h, s, t, x, topbit;
|
||||
int remsign;
|
||||
BOOL up, onebit;
|
||||
ZVALUE sqrt;
|
||||
--- 1481,1488 ----
|
||||
{
|
||||
HALF *a, *A, *b, *a0, u;
|
||||
int i, j, j1, j2, k, k1, m, m0, m1, n, n0, o;
|
||||
! volatile FULL d;
|
||||
! FULL e, f, g, h, s, t, x, topbit;
|
||||
int remsign;
|
||||
BOOL up, onebit;
|
||||
ZVALUE sqrt;
|
||||
*** zmath.c 2000/06/07 14:02:13 29.2
|
||||
--- zmath.c 2001/03/13 19:47:03
|
||||
***************
|
||||
*** 1608,1614 ****
|
||||
void
|
||||
zbitvalue(long n, ZVALUE *res)
|
||||
{
|
||||
! ZVALUE z;
|
||||
|
||||
if (n < 0) n = 0;
|
||||
z.sign = 0;
|
||||
--- 1608,1614 ----
|
||||
void
|
||||
zbitvalue(long n, ZVALUE *res)
|
||||
{
|
||||
! volatile ZVALUE z;
|
||||
|
||||
if (n < 0) n = 0;
|
||||
z.sign = 0;
|
||||
|
||||
* There are problems compiling calc on the sparcv9 under 64 bit
|
||||
Solaris. On that platform, gcc-2.96 is able to compile calc, but
|
||||
calc dumps core very early on in startup. It is said that sparcv9
|
||||
@@ -190,8 +160,8 @@ Problems with old systems that have 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.24 $
|
||||
## @(#) $Id: BUGS,v 29.24 2006/05/21 07:54:13 chongo Exp $
|
||||
## @(#) $Revision: 29.26 $
|
||||
## @(#) $Id: BUGS,v 29.26 2007/01/03 21:26:22 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/BUGS,v $
|
||||
##
|
||||
## Under source code control: 1994/03/18 14:06:13
|
||||
|
273
CHANGES
273
CHANGES
@@ -1,4 +1,172 @@
|
||||
The following are the changes from calc version 2.12.0 to date:
|
||||
The following are the changes from calc version 2.12.1.10 to date:
|
||||
|
||||
Put back the missing -s flags on the cscripts: mersenne, 4dsphere,
|
||||
fprodcut, plus, and powerterm. Thanks goes to Bradley Reed
|
||||
<bradreed1 at gmail dot com> for discovering this problem.
|
||||
|
||||
All static variables are now declared with the symbol STATIC.
|
||||
All extern variables are now declared with the symbol EXTERN.
|
||||
All static functions are now declared with the symbol S_FUNC.
|
||||
All extern functions are now declared with the symbol E_FUNC.
|
||||
The include file decl.h defines these 4 symbols by default
|
||||
to static, extern, static, and extern respectively. Under
|
||||
Windoz, DLL is also defined accorind to the _EXPORTING symbol
|
||||
and is prepended to the EXTERN and E_FUNC symbols. The decl.h
|
||||
file has replaced the win32dll.h file.
|
||||
|
||||
Added Apple Mac OS X compiler set in the Makefile.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.12.1.8 to 2.12.1.9:
|
||||
|
||||
Fixed calc cscripts that contained comments that were not valid calc
|
||||
comments. Improved calc comment documentation in "help unexpected"
|
||||
to help other avoid similar mistakes. Calc comments are of the form:
|
||||
|
||||
/* c style comments */
|
||||
/*
|
||||
* multi-line
|
||||
* commentts
|
||||
*/
|
||||
## two or more #-signs
|
||||
### in a row
|
||||
### Note that # along is a calc uniary and binary operator
|
||||
|
||||
Added "help pound" or "help #' to document the # operator, comments,
|
||||
and the first line of cscript files.
|
||||
|
||||
Documented these help commands in "help help":
|
||||
|
||||
help ->
|
||||
help *
|
||||
help .
|
||||
help %
|
||||
help //
|
||||
help #
|
||||
|
||||
The usage help file is now formed from the contents of the calc man page.
|
||||
So "help usage" prints the version of the calc man page. Added ${COL}
|
||||
makefile symbol to support the formation of the calc.usage file from
|
||||
calc.1 via the CALCPAGER (less).
|
||||
|
||||
The "help calc" command is now equivalent to "help help".
|
||||
|
||||
The "help define" command is now equivalent to "help command".
|
||||
|
||||
Fixed calc command line usage message.
|
||||
|
||||
Fixed missing README.src file in RPM src and tgz src tarball.
|
||||
|
||||
Removed HAVE_SNPRINTF test in version.c. We now assume that
|
||||
all systems come with the standard snprintf() library function.
|
||||
|
||||
Make does not assume that DONT_HAVE_VSPRINTF must be defined in
|
||||
order to test for varargs (via have_varvs.c). Instead it uses the
|
||||
${HAVE_VSPRINTF} to determine if the vsprintf() and vsnprintf()
|
||||
should be tested to assumed to exist or not exist.
|
||||
|
||||
Tests for the existence of vsprintf() now also require the existence
|
||||
of vsnprintf(). Test for the existence of vsnprintf() now also
|
||||
require the existence of vsprintf().
|
||||
|
||||
The #define CALC_SIZE_T was never used except when memmove() was
|
||||
not found. This symbol was renamed to MEMMOVE_SIZE_T. Calc
|
||||
requires that size_t must be a known type.
|
||||
|
||||
Calc and cscripts are installed mode 0755 instead of 0555 to
|
||||
make rpmlint happy.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.12.1.6 to 2.12.1.7:
|
||||
|
||||
Added the calc builtin function, usertime(), to return the amount of
|
||||
user CPU time used by the current process. Unlike the old runtime()
|
||||
builtin, the CPU time reported for long running processes will not
|
||||
wrap around to 0 after only a few months.
|
||||
|
||||
Added the calc builtin function, systime(), to return the amount of
|
||||
kernel CPU time used by the current process.
|
||||
|
||||
The runtime() builtin function now returns the total amount of CPU
|
||||
time used by the current process. This time includes both user mode
|
||||
and kernel mode time. Unlike the old runtime() builtin, the builtin
|
||||
includes time spent executing operating system code on behalf of
|
||||
the current process.
|
||||
|
||||
Fixed runtime() so that the CPU time reported for long running
|
||||
processes will wrap around to 0 for a long time.
|
||||
|
||||
Added config("hz") to return the clock tick rate. This is
|
||||
a read-only configuration value.
|
||||
|
||||
Added regression tests for recently added config() parameters.
|
||||
|
||||
Fixed the #define symbols that were created in have_strdup.h.
|
||||
Previously this file looked as if have_rusage.h has been
|
||||
included already.
|
||||
|
||||
Restored the function of "help" (without any args) printing the
|
||||
default help file. Thanks for this fix goes to Silvan Minghetti
|
||||
<bullet at users dot sourceforge dot net>.
|
||||
|
||||
Fixed a problem where some old MS environments failed some of the
|
||||
regression tests because "read -once foo.cal" was not behaving
|
||||
correctly due to how the _fullpath() was being called. Thanks for
|
||||
this fix goes to Anatoly <notexistent-anb at yandex dot ru>.
|
||||
|
||||
Documented the mis-feature about how calc parses if, for, while
|
||||
and do statements in an unexpected way. For example:
|
||||
|
||||
This works as expected:
|
||||
|
||||
if (expr) {
|
||||
...
|
||||
}
|
||||
|
||||
However this WILL NOT WORK AS EXPECTED:
|
||||
|
||||
if (expr)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
because calc will parse the if being terminated by
|
||||
an empty statement followed by a
|
||||
|
||||
if (expr) ;
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
See also "help statement", "help unexpected", "help todo", and
|
||||
"help bugs".
|
||||
|
||||
|
||||
The following are the changes from calc version 2.12.1 to 2.12.1.5:
|
||||
|
||||
Fixed minor typos in the 'version 2.12.0 to 2.12.0.8' section below.
|
||||
Made minor formatting changes as well.
|
||||
|
||||
Changed use of ${Q} in the Makefile to avoid an make "feature"
|
||||
related to OpenBSD. Added ${RM} make variable for make tools that
|
||||
do not have builtin defined terms.
|
||||
|
||||
Removed the ECHO_PROG Makefile variable. Also removed it from
|
||||
the sysinfo() custom function.
|
||||
|
||||
Improved the support for cross-compiled environmens by using
|
||||
make symbols for all non-shell commands executed by Makefiles.
|
||||
|
||||
Fixed a problem with the make chk awk script which failed under
|
||||
OS X 10.4.7.
|
||||
|
||||
Fixed a few minor variables that were not set to default values in
|
||||
lower level Makefiles.
|
||||
|
||||
Fixed a reference to a non-existent make variable in HOWTO.INSTALL.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.12.0 to 2.12.0.8:
|
||||
|
||||
Fixed ellip.cal to deal with a calc syntax change that happened
|
||||
many ages ago but was never applied to this file until now.
|
||||
@@ -109,34 +277,34 @@ The following are the changes from calc version 2.12.0 to date:
|
||||
<ebowen at une dot edu dot au>, the dotest evaluates individual
|
||||
lines from a file. The dotest() function takes 1 to 3 arguments:
|
||||
|
||||
dotest(dotest_file [,dotest_code [,dotest_maxcond]])
|
||||
dotest(dotest_file [,dotest_code [,dotest_maxcond]])
|
||||
|
||||
dotest_file
|
||||
dotest_file
|
||||
|
||||
Search along CALCPATH for dotest_file, which contains lines that
|
||||
should evaluate to 1. Comment lines and empty lines are ignored.
|
||||
Comment lines should use ## instead of the multi like /* ... */
|
||||
because lines are evaluated one line at a time.
|
||||
Search along CALCPATH for dotest_file, which contains lines that
|
||||
should evaluate to 1. Comment lines and empty lines are ignored.
|
||||
Comment lines should use ## instead of the multi like /* ... */
|
||||
because lines are evaluated one line at a time.
|
||||
|
||||
dotest_code
|
||||
dotest_code
|
||||
|
||||
Assign the code number that is to be printed at the start of
|
||||
each non-error line and after **** in each error line.
|
||||
The default code number is 999.
|
||||
Assign the code number that is to be printed at the start of
|
||||
each non-error line and after **** in each error line.
|
||||
The default code number is 999.
|
||||
|
||||
dotest_maxcond
|
||||
dotest_maxcond
|
||||
|
||||
The maximum number of error conditions that may be detected.
|
||||
An error condition is not a sign of a problem, in some cases
|
||||
a line deliberately forces an error condition. A value of -1,
|
||||
the default, implies a maximum of 2147483647.
|
||||
The maximum number of error conditions that may be detected.
|
||||
An error condition is not a sign of a problem, in some cases
|
||||
a line deliberately forces an error condition. A value of -1,
|
||||
the default, implies a maximum of 2147483647.
|
||||
|
||||
Global variables and functions must be declared ahead of time because
|
||||
the dotest scope of evaluation is a line at a time. For example:
|
||||
Global variables and functions must be declared ahead of time because
|
||||
the dotest scope of evaluation is a line at a time. For example:
|
||||
|
||||
; read dotest.cal
|
||||
; read set8700.cal
|
||||
; dotest("set8700.line");
|
||||
; read dotest.cal
|
||||
; read set8700.cal
|
||||
; dotest("set8700.line");
|
||||
|
||||
Updated the todo / wish list items. The top priority now is to
|
||||
convert calc to GNU autoconf / configure to build the calc.
|
||||
@@ -164,7 +332,7 @@ The following are the changes from calc version 2.12.0 to date:
|
||||
Made math_error() in math_error.c more robust against a error
|
||||
message constant that is too long.
|
||||
|
||||
Made read_bindings() in hist.c more robust against very line bindings
|
||||
Made read_bindings() in hist.c more robust against very long bindings
|
||||
config lines.
|
||||
|
||||
Made listsort() in listfunc.c and matsort() matfunc.c more robust
|
||||
@@ -179,8 +347,7 @@ The following are the changes from calc version 2.12.0 to date:
|
||||
no other compile errors, only the unterminated comment will stop
|
||||
completion of the function being defined.
|
||||
|
||||
Added the reading of more calc resource files to the cal/regress.cal
|
||||
regression test.
|
||||
The cal/regress.cal now reads most of the calc resource files.
|
||||
|
||||
The issq() test had a slight performance boost. A minor note
|
||||
was added to the help/issq file.
|
||||
@@ -192,25 +359,18 @@ The following are the changes from calc version 2.12.0 to date:
|
||||
the number of bits in the fundamental base in which calculations
|
||||
are performed. This is a read-only configuration value.
|
||||
|
||||
Calc now permits such as:
|
||||
|
||||
++*p-- ++*----*++p----
|
||||
|
||||
Calc now will allow syntax such as ++*p-- and ++*----*++p----
|
||||
where p is an lvalue; successful evaluation of course require the
|
||||
successive operations to be performed to have operands of appropriate
|
||||
types; e.g. in *A, A is usually an lvalue whose current value is a
|
||||
pointer. ++ and -- act on lvalues. In the above examples there are
|
||||
implied parentheses from the beginning to immediately after p. If
|
||||
there are no pre ++ or -- operations, as in
|
||||
|
||||
**p++
|
||||
|
||||
the implied parentheses are from immediately before p to the end.
|
||||
there are no pre ++ or -- operations, as in **p++. The implied
|
||||
parentheses are from immediately before p to the end.
|
||||
|
||||
Improved the error message when && is used as a prefix operator.
|
||||
|
||||
Changed the help/config file to read like a builtin function
|
||||
help file.
|
||||
Changed the help/config file to read like a builtin function help file.
|
||||
|
||||
One can no longer set to 1, or to a value < 0, the config()
|
||||
parameters: "mul2", "sq2", "pow2", and "redc2". These values
|
||||
@@ -224,10 +384,10 @@ The following are the changes from calc version 2.12.0 to date:
|
||||
config("sq2") == 3388
|
||||
config("pow2") == 176
|
||||
|
||||
These values were determined established on a 1.8GHz AMD 32-bit
|
||||
CPU of ~3406 BogoMIPS by the new resource file:
|
||||
These values were determined established on a 1.8GHz AMD 32-bit
|
||||
CPU of ~3406 BogoMIPS by the new resource file:
|
||||
|
||||
cal/alg_config.cal
|
||||
cal/alg_config.cal
|
||||
|
||||
Regarding the alg_config.cal resource file:
|
||||
|
||||
@@ -255,7 +415,7 @@ The following are the changes from calc version 2.12.0 to date:
|
||||
inaccuracy in CPU timings will cause the best value returned to
|
||||
differ slightly from run to run.
|
||||
|
||||
See "help resource" for more information on alg_config.cal.
|
||||
See "help resource" for more information on alg_config.cal.
|
||||
|
||||
Updated the "help variable" text to reflect the current calc
|
||||
use of ` (backquote), * (star), and & (ampersand).
|
||||
@@ -304,24 +464,22 @@ The following are the changes from calc version 2.12.0 to date:
|
||||
silly to use the same identifier for both a parameter and local
|
||||
variable, it should not be illegal.
|
||||
|
||||
The provision of warnings for possibly questionable programming in
|
||||
function definitions.
|
||||
Added warnings for possibly questionable code in function definitions.
|
||||
|
||||
Added config("redecl_warn", boolean) to control if calc issues
|
||||
warnings about variables being declared. The config("redecl_warn")
|
||||
value is TRUE by default.
|
||||
|
||||
Added config("dupvar_warn", boolean) to control if calc issues
|
||||
warnings about when variable names collide. Examples of variable name
|
||||
collisions include when:
|
||||
warnings about when variable names collide. The config("dupvar_warn")
|
||||
value is TRUE by default. Examples of variable name collisions
|
||||
include when:
|
||||
|
||||
* both local and static variables have the same name
|
||||
* both local and global variables have the same name
|
||||
* both function parameter and local variables have the same name
|
||||
* both function parameter and global variables have the same name
|
||||
|
||||
The config("dupvar_warn") value is TRUE by default.
|
||||
|
||||
Fix of a bug which causes some static variables not to be correctly
|
||||
unscoped when their identifiers are used in a global declaration.
|
||||
|
||||
@@ -351,7 +509,7 @@ The following are the changes from calc version 2.12.0 to date:
|
||||
read sumtimes
|
||||
doalltimes(1e6)
|
||||
|
||||
Calc now ignores carrage returns (\r), vertical tabs (\v), and
|
||||
Calc now ignores carriage returns (\r), vertical tabs (\v), and
|
||||
form feeds (\f) when token parsing. Thus users on Windoz systems
|
||||
can write files using their \r\n format and users on non-Windoz
|
||||
systems can read them without errors.
|
||||
@@ -359,7 +517,7 @@ The following are the changes from calc version 2.12.0 to date:
|
||||
The quomod() builtin function now takes an optional 5th argument
|
||||
which controls the rounding mode like config("quomod") does, but
|
||||
only for that call. Now quomod() is in line with quo() and mod()
|
||||
in that the final augument is an optional rounding mode.
|
||||
in that the final argument is an optional rounding mode.
|
||||
|
||||
Added a "make uninstall" rule which will attempt to remove everything
|
||||
that was installed by a "make install".
|
||||
@@ -367,6 +525,21 @@ The following are the changes from calc version 2.12.0 to date:
|
||||
Changed the "Copyright" line in the rpm spec file to a "License" line
|
||||
as per new rpm v4.4 syntax.
|
||||
|
||||
The quomod() builtin function does not allow constants for its 3rd
|
||||
and 4th arguments. Updated the "help quomod" file and added more
|
||||
quomod regression tests.
|
||||
|
||||
Added patch from Ernest Bowen <ebowen at une dot edu dot au> to
|
||||
add the builtin: estr(). The estr(x) will return a representation
|
||||
of a null, string, real number, complex number, list, matrix,
|
||||
object. block, named block, error as a string.
|
||||
|
||||
Added patch from Ernest Bowen <ebowen at une dot edu dot au> to
|
||||
add the builtin: fgetfile(). The fgetfile(x) will return the rest
|
||||
of an open file as a string.
|
||||
|
||||
Improved help files for fgetfield, fputs, name, or quomod.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.10.1 to 2.11.11:
|
||||
|
||||
@@ -2552,8 +2725,6 @@ The following are the changes from calc version 2.10.3t5.38 to 2.11.3t5.46:
|
||||
into a single section.
|
||||
|
||||
|
||||
|
||||
|
||||
The following are the changes from calc version 2.10.3t5.34 to 2.10.3t5.37:
|
||||
|
||||
Per request from David I Bell, the README line:
|
||||
@@ -6187,8 +6358,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.84 $
|
||||
## @(#) $Id: CHANGES,v 29.84 2006/06/26 05:53:25 chongo Exp $
|
||||
## @(#) $Revision: 29.97 $
|
||||
## @(#) $Id: CHANGES,v 29.97 2007/02/11 10:25:01 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
|
||||
##
|
||||
## Under source code control: 1993/06/02 18:12:57
|
||||
|
12
COPYING
12
COPYING
@@ -12,8 +12,8 @@ This file is Copyrighted
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
# @(#) $Revision: 29.8 $
|
||||
# @(#) $Id: COPYING,v 29.8 2006/05/01 19:16:57 chongo Exp $
|
||||
# @(#) $Revision: 29.9 $
|
||||
# @(#) $Id: COPYING,v 29.9 2007/02/11 10:16:31 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/COPYING,v $
|
||||
|
||||
=-=
|
||||
@@ -182,9 +182,11 @@ Calc copyrights and exception files
|
||||
top of this file. It is important to note that you may distribute
|
||||
verbatim copies of this file but you may not modify this file.
|
||||
|
||||
Some of these exception files are in the public domain. Other
|
||||
exception files have non-LGPL Copyrights. Other files are under a
|
||||
LGPL Copyright but have different authors.
|
||||
Some of these exception files are in the public domain. The md5.c
|
||||
and md5.h files were "derived from the RSA Data Security, Inc. MD5
|
||||
Message-Digest Algorithm" and are under a copyright that allows these
|
||||
two files to be freely used and distributed. Other files are under
|
||||
the LGPL but have different authors that those listed above.
|
||||
|
||||
In all cases one may use and distribute these exception files freely.
|
||||
And because one may freely distribute the LGPL covered files, the
|
||||
|
@@ -52,14 +52,14 @@ Installing calc from the gziped tarball in 4 easy steps:
|
||||
CALC_INCDIR where the calc include files are installed
|
||||
CUSTOMCALDIR where custom *.cal files are installed
|
||||
CUSTOMHELPDIR where custom help files are installed
|
||||
CUSTOMINCPDIR where custom .h files are installed
|
||||
CUSTOMINCDIR where custom .h files are installed
|
||||
SCRIPTDIR where calc shell scripts are installed
|
||||
|
||||
If you want to install calc files under a top level directory,
|
||||
then set the T value:
|
||||
|
||||
The calc install is performed under $T, the calc build is
|
||||
performed under /. The purpose for $T is to allow someone
|
||||
The calc install is performed under ${T}, the calc build is
|
||||
performed under /. The purpose for ${T} is to allow someone
|
||||
to install calc somewhere other than into the system area.
|
||||
|
||||
For example, if:
|
||||
@@ -79,10 +79,10 @@ Installing calc from the gziped tarball in 4 easy steps:
|
||||
calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
... etc ... /var/tmp/testing/...
|
||||
|
||||
If $T is empty, calc is installed under /, which is the same
|
||||
top of tree for which it was built. If $T is non-empty, then
|
||||
calc is installed under $T, as if one had to chroot under
|
||||
$T for calc to operate.
|
||||
If ${T} is empty, calc is installed under /, which is the same
|
||||
top of tree for which it was built. If ${T} is non-empty, then
|
||||
calc is installed under ${T}, as if one had to chroot under
|
||||
${T} for calc to operate.
|
||||
|
||||
Look for the section that starts:
|
||||
|
||||
@@ -162,8 +162,8 @@ the calc help subsystem. See the README file for details.
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.7 $
|
||||
## @(#) $Id: HOWTO.INSTALL,v 29.7 2003/04/15 03:38:34 chongo Exp $
|
||||
## @(#) $Revision: 29.9 $
|
||||
## @(#) $Id: HOWTO.INSTALL,v 29.9 2006/09/18 13:11:57 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/HOWTO.INSTALL,v $
|
||||
##
|
||||
## Under source code control: 1999/09/27 20:48:44
|
||||
|
@@ -56,7 +56,7 @@ recommends the following settings:
|
||||
CALCPATH= .;./cal;~/.cal;${CALC_SHAREDIR};${CUSTOMCALDIR}
|
||||
CALCRC= ${CALC_SHAREDIR}/startup;~/.calcrc;./.calcinit
|
||||
CALCPAGER= less.exe -ci
|
||||
DEBUG= -O2 -gstabs+
|
||||
DEBUG= -O2 -gstabs+ -DWINDOZ
|
||||
|
||||
The 'Linux set' or 'gcc set' (see the Select your compiler type section)
|
||||
should work for DJGPP systems if you set the above Makefile variables.
|
||||
@@ -112,37 +112,8 @@ In particular:
|
||||
source directory, edit them (if needed) and build using the
|
||||
Cygwin GCC compiler and Cygwin build environment.
|
||||
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
=-=-= calc maintenance folk =-=-=
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
People who maintain calc need to keep in mind the following:
|
||||
|
||||
The following was added to opcodes.h, config.h, zmath.h and value.h:
|
||||
|
||||
#if defined(_WIN32)
|
||||
#ifdef _EXPORTING
|
||||
#define DLL __declspec(dllexport)
|
||||
#else
|
||||
#define DLL __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#else /* Windoz free systems */
|
||||
|
||||
#define DLL
|
||||
|
||||
#endif /* Windoz free systems */
|
||||
|
||||
Then DLL was added in front of all the exported functions. For example:
|
||||
|
||||
extern int configtype(char*);
|
||||
|
||||
was changed to:
|
||||
|
||||
DLL extern int configtype(char*);
|
||||
|
||||
|
||||
## Copyright (C) 2002 Landon Curt Noll and Thomas Jones-Low
|
||||
## Copyright (C) 2002-2007 Landon Curt Noll and Thomas Jones-Low
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -158,8 +129,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.12 $
|
||||
## @(#) $Id: README.WINDOWS,v 29.12 2004/07/28 12:52:01 chongo Exp $
|
||||
## @(#) $Revision: 29.13 $
|
||||
## @(#) $Id: README.WINDOWS,v 29.13 2007/02/11 10:23:28 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/README.WINDOWS,v $
|
||||
##
|
||||
## Under source code control: 2001/02/25 14:00:05
|
||||
|
28
addop.c
28
addop.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* addop - add opcodes to a function being compiled
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2007 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -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.13 $
|
||||
* @(#) $Id: addop.c,v 29.13 2006/06/20 10:28:06 chongo Exp $
|
||||
* @(#) $Revision: 29.14 $
|
||||
* @(#) $Id: addop.c,v 29.14 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/addop.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:10
|
||||
@@ -44,17 +44,17 @@
|
||||
#define OPCODEALLOCSIZE 100 /* reallocate size for opcodes in functions */
|
||||
|
||||
|
||||
static unsigned long maxopcodes;/* number of opcodes available */
|
||||
static long newindex; /* index of new function */
|
||||
static char *newname; /* name of new function */
|
||||
static long oldop; /* previous opcode */
|
||||
static long oldoldop; /* opcode before previous opcode */
|
||||
static long debugline; /* line number of latest debug opcode */
|
||||
static long funccount; /* number of functions */
|
||||
static long funcavail; /* available number of functions */
|
||||
static FUNC *functemplate; /* function definition template */
|
||||
static FUNC **functions; /* table of functions */
|
||||
static STRINGHEAD funcnames; /* function names */
|
||||
STATIC unsigned long maxopcodes;/* number of opcodes available */
|
||||
STATIC long newindex; /* index of new function */
|
||||
STATIC char *newname; /* name of new function */
|
||||
STATIC long oldop; /* previous opcode */
|
||||
STATIC long oldoldop; /* opcode before previous opcode */
|
||||
STATIC long debugline; /* line number of latest debug opcode */
|
||||
STATIC long funccount; /* number of functions */
|
||||
STATIC long funcavail; /* available number of functions */
|
||||
STATIC FUNC *functemplate; /* function definition template */
|
||||
STATIC FUNC **functions; /* table of functions */
|
||||
STATIC STRINGHEAD funcnames; /* function names */
|
||||
|
||||
|
||||
/*
|
||||
|
50
alloc.h
50
alloc.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* alloc - storage allocation and storage debug macros
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: alloc.h,v 29.4 2001/06/08 21:00:58 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: alloc.h,v 29.6 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/alloc.h,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:29
|
||||
@@ -48,13 +48,13 @@
|
||||
# include <malloc.h>
|
||||
#else
|
||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||
extern void *malloc();
|
||||
extern void *realloc();
|
||||
extern void free();
|
||||
E_FUNC void *malloc();
|
||||
E_FUNC void *realloc();
|
||||
E_FUNC void free();
|
||||
# else
|
||||
extern char *malloc();
|
||||
extern char *realloc();
|
||||
extern void free();
|
||||
E_FUNC char *malloc();
|
||||
E_FUNC char *realloc();
|
||||
E_FUNC void free();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -64,23 +64,23 @@
|
||||
#else
|
||||
|
||||
# if defined(HAVE_NEWSTR)
|
||||
extern void *memcpy();
|
||||
extern void *memset();
|
||||
E_FUNC void *memcpy();
|
||||
E_FUNC void *memset();
|
||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||
extern size_t strlen();
|
||||
E_FUNC size_t strlen();
|
||||
# else
|
||||
extern long strlen();
|
||||
E_FUNC long strlen();
|
||||
# endif
|
||||
# else /* HAVE_NEWSTR */
|
||||
extern void bcopy();
|
||||
extern void bfill();
|
||||
extern char *index();
|
||||
E_FUNC void bcopy();
|
||||
E_FUNC void bfill();
|
||||
E_FUNC char *index();
|
||||
# endif /* HAVE_NEWSTR */
|
||||
extern char *strchr();
|
||||
extern char *strcpy();
|
||||
extern char *strncpy();
|
||||
extern char *strcat();
|
||||
extern int strcmp();
|
||||
E_FUNC char *strchr();
|
||||
E_FUNC char *strcpy();
|
||||
E_FUNC char *strncpy();
|
||||
E_FUNC char *strcat();
|
||||
E_FUNC int strcmp();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -94,13 +94,13 @@ extern int strcmp();
|
||||
#endif /* HAVE_NEWSTR */
|
||||
|
||||
#if !defined(HAVE_MEMMOVE)
|
||||
# undef CALC_SIZE_T
|
||||
# undef MEMMOVE_SIZE_T
|
||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||
# define CALC_SIZE_T size_t
|
||||
# define MEMMOVE_SIZE_T size_t
|
||||
# else
|
||||
# define CALC_SIZE_T long
|
||||
# define MEMMOVE_SIZE_T long
|
||||
# endif
|
||||
extern void *memmove(void *s1, const void *s2, CALC_SIZE_T n);
|
||||
E_FUNC void *memmove(void *s1, CONST void *s2, MEMMOVE_SIZE_T n);
|
||||
#endif
|
||||
|
||||
#endif /* !__ALLOC_H__ */
|
||||
|
24
assocfunc.c
24
assocfunc.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* assocfunc - association table routines
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: assocfunc.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: assocfunc.c,v 29.3 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/assocfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1993/07/20 23:04:27
|
||||
@@ -46,10 +46,10 @@
|
||||
#define ELEMSIZE(n) (sizeof(ASSOCELEM) + (sizeof(VALUE) * ((n) - 1)))
|
||||
|
||||
|
||||
static ASSOCELEM *elemindex(ASSOC *ap, long index);
|
||||
static BOOL compareindices(VALUE *v1, VALUE *v2, long dim);
|
||||
static void resize(ASSOC *ap, long newsize);
|
||||
static void assoc_elemfree(ASSOCELEM *ep);
|
||||
S_FUNC ASSOCELEM *elemindex(ASSOC *ap, long index);
|
||||
S_FUNC BOOL compareindices(VALUE *v1, VALUE *v2, long dim);
|
||||
S_FUNC void resize(ASSOC *ap, long newsize);
|
||||
S_FUNC void assoc_elemfree(ASSOCELEM *ep);
|
||||
|
||||
|
||||
/*
|
||||
@@ -69,7 +69,7 @@ associndex(ASSOC *ap, BOOL create, long dim, VALUE *indices)
|
||||
{
|
||||
ASSOCELEM **listhead;
|
||||
ASSOCELEM *ep;
|
||||
static VALUE val;
|
||||
STATIC VALUE val;
|
||||
QCKHASH hash;
|
||||
int i;
|
||||
|
||||
@@ -200,7 +200,7 @@ assocrsearch(ASSOC *ap, VALUE *vp, long i, long j, ZVALUE *index)
|
||||
* ap association to index into
|
||||
* index index of desired element
|
||||
*/
|
||||
static ASSOCELEM *
|
||||
S_FUNC ASSOCELEM *
|
||||
elemindex(ASSOC *ap, long index)
|
||||
{
|
||||
ASSOCELEM *ep;
|
||||
@@ -356,7 +356,7 @@ assoccopy(ASSOC *oldap)
|
||||
* This is only actually done if the growth from the previous size is
|
||||
* enough to make this worthwhile.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
resize(ASSOC *ap, long newsize)
|
||||
{
|
||||
ASSOCELEM **oldtable;
|
||||
@@ -400,7 +400,7 @@ resize(ASSOC *ap, long newsize)
|
||||
/*
|
||||
* Free an association element, along with any contained values.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
assoc_elemfree(ASSOCELEM *ep)
|
||||
{
|
||||
int i;
|
||||
@@ -520,7 +520,7 @@ assocprint(ASSOC *ap, long max_print)
|
||||
* Compare two lists of index values to see if they are identical.
|
||||
* Returns TRUE if they are the same.
|
||||
*/
|
||||
static BOOL
|
||||
S_FUNC BOOL
|
||||
compareindices(VALUE *v1, VALUE *v2, long dim)
|
||||
{
|
||||
int i;
|
||||
|
8
blkcpy.c
8
blkcpy.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* blkcpy - general values and related routines used by the calculator
|
||||
*
|
||||
* Copyright (C) 1999-2006 Landon Curt Noll and Ernest Bowen
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
||||
*
|
||||
* Primary author: Landon Curt Noll
|
||||
*
|
||||
@@ -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.9 $
|
||||
* @(#) $Id: blkcpy.c,v 29.9 2006/05/20 08:43:55 chongo Exp $
|
||||
* @(#) $Revision: 29.11 $
|
||||
* @(#) $Id: blkcpy.c,v 29.11 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.c,v $
|
||||
*
|
||||
* Under source code control: 1997/04/18 20:41:26
|
||||
@@ -935,7 +935,7 @@ copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,BOOL noreloc)
|
||||
* s1
|
||||
*/
|
||||
void *
|
||||
memmove(void *s1, const void *s2, CALC_SIZE_T n)
|
||||
memmove(void *s1, CONST void *s2, MEMMOVE_SIZE_T n)
|
||||
{
|
||||
/*
|
||||
* firewall
|
||||
|
42
blkcpy.h
42
blkcpy.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* blkcpy - general values and related routines used by the calculator
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll and Ernest Bowen
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
||||
*
|
||||
* Primary author: Landon Curt Noll
|
||||
*
|
||||
@@ -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.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: blkcpy.h,v 29.3 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.h,v $
|
||||
*
|
||||
* Under source code control: 1997/04/18 20:41:25
|
||||
@@ -36,27 +36,27 @@
|
||||
/*
|
||||
* the main copy gateway function
|
||||
*/
|
||||
extern int copystod(VALUE *, long, long, VALUE *, long);
|
||||
E_FUNC int copystod(VALUE *, long, long, VALUE *, long);
|
||||
|
||||
/*
|
||||
* specific copy functions
|
||||
*/
|
||||
extern int copyblk2blk(BLOCK *, long, long, BLOCK *, long, BOOL);
|
||||
extern int copyblk2file(BLOCK *, long, long, FILEID, long);
|
||||
extern int copyblk2mat(BLOCK *, long, long, MATRIX *, long);
|
||||
extern int copyblk2num(BLOCK *, long, long, NUMBER *, long, NUMBER **);
|
||||
extern int copyblk2str(BLOCK *, long, long, STRING *, long);
|
||||
extern int copyfile2blk(FILEID, long, long, BLOCK *, long, BOOL);
|
||||
extern int copylist2list(LIST *, long, long, LIST *, long);
|
||||
extern int copylist2mat(LIST *, long, long, MATRIX *, long);
|
||||
extern int copymat2blk(MATRIX *, long, long, BLOCK *, long, BOOL);
|
||||
extern int copymat2list(MATRIX *, long, long, LIST *, long);
|
||||
extern int copymat2mat(MATRIX *, long, long, MATRIX *, long);
|
||||
extern int copynum2blk(NUMBER *, long, long, BLOCK *, long, BOOL);
|
||||
extern int copyostr2blk(char *, long, long, BLOCK *, long, BOOL);
|
||||
extern int copyostr2str(char *, long, long, STRING *, long);
|
||||
extern int copystr2blk(STRING *, long, long, BLOCK *, long, BOOL);
|
||||
extern int copystr2file(STRING *, long, long, FILEID, long);
|
||||
extern int copystr2str(STRING *, long, long, STRING *, long);
|
||||
E_FUNC int copyblk2blk(BLOCK *, long, long, BLOCK *, long, BOOL);
|
||||
E_FUNC int copyblk2file(BLOCK *, long, long, FILEID, long);
|
||||
E_FUNC int copyblk2mat(BLOCK *, long, long, MATRIX *, long);
|
||||
E_FUNC int copyblk2num(BLOCK *, long, long, NUMBER *, long, NUMBER **);
|
||||
E_FUNC int copyblk2str(BLOCK *, long, long, STRING *, long);
|
||||
E_FUNC int copyfile2blk(FILEID, long, long, BLOCK *, long, BOOL);
|
||||
E_FUNC int copylist2list(LIST *, long, long, LIST *, long);
|
||||
E_FUNC int copylist2mat(LIST *, long, long, MATRIX *, long);
|
||||
E_FUNC int copymat2blk(MATRIX *, long, long, BLOCK *, long, BOOL);
|
||||
E_FUNC int copymat2list(MATRIX *, long, long, LIST *, long);
|
||||
E_FUNC int copymat2mat(MATRIX *, long, long, MATRIX *, long);
|
||||
E_FUNC int copynum2blk(NUMBER *, long, long, BLOCK *, long, BOOL);
|
||||
E_FUNC int copyostr2blk(char *, long, long, BLOCK *, long, BOOL);
|
||||
E_FUNC int copyostr2str(char *, long, long, STRING *, long);
|
||||
E_FUNC int copystr2blk(STRING *, long, long, BLOCK *, long, BOOL);
|
||||
E_FUNC int copystr2file(STRING *, long, long, FILEID, long);
|
||||
E_FUNC int copystr2str(STRING *, long, long, STRING *, long);
|
||||
|
||||
#endif /* !__BLKCPY_H__ */
|
||||
|
18
block.c
18
block.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* block - fixed, dynamic, fifo and circular memory blocks
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll and Ernest Bowen
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
||||
*
|
||||
* Primary author: Landon Curt Noll
|
||||
*
|
||||
@@ -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: block.c,v 29.3 2006/05/01 19:16:57 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: block.c,v 29.4 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/block.c,v $
|
||||
*
|
||||
* Under source code control: 1997/02/27 00:29:40
|
||||
@@ -42,14 +42,14 @@
|
||||
|
||||
#define NBLOCKCHUNK 16
|
||||
|
||||
static long nblockcount = 0;
|
||||
static long maxnblockcount = 0;
|
||||
static STRINGHEAD nblocknames;
|
||||
static NBLOCK **nblocks;
|
||||
STATIC long nblockcount = 0;
|
||||
STATIC long maxnblockcount = 0;
|
||||
STATIC STRINGHEAD nblocknames;
|
||||
STATIC NBLOCK **nblocks;
|
||||
|
||||
|
||||
/* forward declarations */
|
||||
static void blkchk(BLOCK*);
|
||||
S_FUNC void blkchk(BLOCK*);
|
||||
|
||||
|
||||
/*
|
||||
@@ -154,7 +154,7 @@ blk_free(BLOCK *blk)
|
||||
* if all is ok, otherwise math_error() is called and this
|
||||
* function does not return
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
blkchk(BLOCK *blk)
|
||||
{
|
||||
|
||||
|
40
block.h
40
block.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* block - fixed, dynamic, fifo and circular memory blocks
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll and Ernest Bowen
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
||||
*
|
||||
* Primary author: Landon Curt Noll
|
||||
*
|
||||
@@ -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: block.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: block.h,v 29.3 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/block.h,v $
|
||||
*
|
||||
* Under source code control: 1997/02/21 05:03:39
|
||||
@@ -160,7 +160,7 @@ typedef struct nblock NBLOCK;
|
||||
/*
|
||||
* block debug
|
||||
*/
|
||||
extern int blk_debug; /* 0 => debug off */
|
||||
EXTERN int blk_debug; /* 0 => debug off */
|
||||
|
||||
|
||||
/*
|
||||
@@ -204,22 +204,22 @@ typedef USB8 OCTET;
|
||||
/*
|
||||
* external functions
|
||||
*/
|
||||
extern BLOCK *blkalloc(int, int);
|
||||
extern void blk_free(BLOCK*);
|
||||
extern BLOCK *blkrealloc(BLOCK*, int, int);
|
||||
extern void blktrunc(BLOCK*);
|
||||
extern BLOCK *blk_copy(BLOCK*);
|
||||
extern int blk_cmp(BLOCK*, BLOCK*);
|
||||
extern void blk_print(BLOCK*);
|
||||
extern void nblock_print(NBLOCK *);
|
||||
extern NBLOCK *createnblock(char *, int, int);
|
||||
extern NBLOCK *reallocnblock(int, int, int);
|
||||
extern int removenblock(int);
|
||||
extern int findnblockid(char *);
|
||||
extern NBLOCK *findnblock(int);
|
||||
extern BLOCK *copyrealloc(BLOCK*, int, int);
|
||||
extern int countnblocks(void);
|
||||
extern void shownblocks(void);
|
||||
E_FUNC BLOCK *blkalloc(int, int);
|
||||
E_FUNC void blk_free(BLOCK*);
|
||||
E_FUNC BLOCK *blkrealloc(BLOCK*, int, int);
|
||||
E_FUNC void blktrunc(BLOCK*);
|
||||
E_FUNC BLOCK *blk_copy(BLOCK*);
|
||||
E_FUNC int blk_cmp(BLOCK*, BLOCK*);
|
||||
E_FUNC void blk_print(BLOCK*);
|
||||
E_FUNC void nblock_print(NBLOCK *);
|
||||
E_FUNC NBLOCK *createnblock(char *, int, int);
|
||||
E_FUNC NBLOCK *reallocnblock(int, int, int);
|
||||
E_FUNC int removenblock(int);
|
||||
E_FUNC int findnblockid(char *);
|
||||
E_FUNC NBLOCK *findnblock(int);
|
||||
E_FUNC BLOCK *copyrealloc(BLOCK*, int, int);
|
||||
E_FUNC int countnblocks(void);
|
||||
E_FUNC void shownblocks(void);
|
||||
|
||||
|
||||
#endif /* !__BLOCK_H__ */
|
||||
|
112
cal/Makefile
112
cal/Makefile
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# cal - makefile for calc standard resource files
|
||||
#
|
||||
# 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
|
||||
@@ -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.21 $
|
||||
# @(#) $Id: Makefile,v 29.21 2006/06/26 05:46:06 chongo Exp $
|
||||
# @(#) $Revision: 29.24 $
|
||||
# @(#) $Id: Makefile,v 29.24 2006/09/18 13:13:25 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1991/07/21 05:00:54
|
||||
@@ -33,8 +33,8 @@
|
||||
|
||||
# required vars
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
MAKE_FILE = Makefile
|
||||
SHELL= /bin/sh
|
||||
MAKE_FILE= Makefile
|
||||
|
||||
####
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
@@ -62,9 +62,9 @@ INCDIR= /usr/include
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
# NOTE: The install rule prepends installation paths with ${T}, which
|
||||
# by default is empty. If ${T} is non-empty, then installation
|
||||
# locations will be relative to the ${T} directory.
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
@@ -96,12 +96,12 @@ CALC_SHAREDIR= /usr/share/calc
|
||||
# ${CALC_INCDIR} where the calc include files are installed
|
||||
# ${CUSTOMCALDIR} where custom *.cal files are installed
|
||||
# ${CUSTOMHELPDIR} where custom help files are installed
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed
|
||||
# ${CUSTOMINCDIR} where custom .h files are installed
|
||||
# ${SCRIPTDIR} where calc shell scripts are installed
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
# NOTE: The install rule prepends installation paths with ${T}, which
|
||||
# by default is empty. If ${T} is non-empty, then installation
|
||||
# locations will be relative to the ${T} directory.
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
@@ -121,8 +121,8 @@ SCRIPTDIR= ${BINDIR}/cscript
|
||||
|
||||
# T - top level directory under which calc will be installed
|
||||
#
|
||||
# The calc install is performed under $T, the calc build is
|
||||
# performed under /. The purpose for $T is to allow someone
|
||||
# The calc install is performed under ${T}, the calc build is
|
||||
# performed under /. The purpose for ${T} is to allow someone
|
||||
# to install calc somewhere other than into the system area.
|
||||
#
|
||||
# For example, if:
|
||||
@@ -142,10 +142,10 @@ SCRIPTDIR= ${BINDIR}/cscript
|
||||
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
# ... etc ... /var/tmp/testing/...
|
||||
#
|
||||
# If $T is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If $T is non-empty, then
|
||||
# calc is installed under $T, as if one had to chroot under
|
||||
# $T for calc to operate.
|
||||
# If ${T} is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If ${T} is non-empty, then
|
||||
# calc is installed under ${T}, as if one had to chroot under
|
||||
# ${T} for calc to operate.
|
||||
#
|
||||
# If in doubt, use T=
|
||||
#
|
||||
@@ -163,6 +163,14 @@ Q=@
|
||||
#
|
||||
CHMOD= chmod
|
||||
CMP= cmp
|
||||
RM= rm
|
||||
MKDIR= mkdir
|
||||
RMDIR= rmdir
|
||||
CP= cp
|
||||
MV= mv
|
||||
CO= co
|
||||
TRUE= true
|
||||
TOUCH= touch
|
||||
|
||||
# The calc files to install
|
||||
#
|
||||
@@ -192,8 +200,8 @@ all: ${CALC_FILES} ${MAKE_FILE} .all
|
||||
# used by the upper level Makefile to determine of we have done all
|
||||
#
|
||||
.all:
|
||||
rm -f .all
|
||||
touch .all
|
||||
${RM} -f .all
|
||||
${TOUCH} .all
|
||||
|
||||
##
|
||||
#
|
||||
@@ -209,17 +217,17 @@ all: ${CALC_FILES} ${MAKE_FILE} .all
|
||||
##
|
||||
|
||||
distlist: ${DISTLIST}
|
||||
${Q}for i in ${DISTLIST} /dev/null; do \
|
||||
${Q} for i in ${DISTLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo cal/$$i; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
distdir:
|
||||
${Q}echo cal
|
||||
${Q} echo cal
|
||||
|
||||
calcliblist:
|
||||
${Q}for i in ${CALCLIBLIST} /dev/null; do \
|
||||
${Q} for i in ${CALCLIBLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo cal/$$i; \
|
||||
fi; \
|
||||
@@ -232,7 +240,7 @@ calcliblist:
|
||||
##
|
||||
|
||||
echo_inst_files:
|
||||
${Q}for i in ${CALC_FILES} /dev/null; do \
|
||||
${Q} for i in ${CALC_FILES} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${CALC_SHAREDIR}/$$i; \
|
||||
fi; \
|
||||
@@ -247,37 +255,37 @@ echo_inst_files:
|
||||
clean:
|
||||
|
||||
clobber:
|
||||
rm -f .all
|
||||
${RM} -f .all
|
||||
|
||||
# install everything
|
||||
#
|
||||
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||
#
|
||||
install: all
|
||||
-${Q}if [ ! -d $T${CALC_SHAREDIR} ]; then \
|
||||
echo mkdir $T${CALC_SHAREDIR}; \
|
||||
mkdir $T${CALC_SHAREDIR}; \
|
||||
if [ ! -d "$T${CALC_SHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${CALC_SHAREDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${CALC_SHAREDIR}; \
|
||||
${MKDIR} ${T}${CALC_SHAREDIR}; \
|
||||
if [ ! -d "${T}${CALC_SHAREDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
||||
${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
|
||||
${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
${Q}for i in ${CALC_FILES} /dev/null; do \
|
||||
${Q} for i in ${CALC_FILES} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s $$i $T${CALC_SHAREDIR}/$$i; then \
|
||||
true; \
|
||||
if ${CMP} -s $$i ${T}${CALC_SHAREDIR}/$$i; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
rm -f $T${CALC_SHAREDIR}/$$i.new; \
|
||||
cp -f $$i $T${CALC_SHAREDIR}/$$i.new; \
|
||||
${CHMOD} 0444 $T${CALC_SHAREDIR}/$$i.new; \
|
||||
mv -f $T${CALC_SHAREDIR}/$$i.new $T${CALC_SHAREDIR}/$$i; \
|
||||
echo "installed $T${CALC_SHAREDIR}/$$i"; \
|
||||
${RM} -f ${T}${CALC_SHAREDIR}/$$i.new; \
|
||||
${CP} -f $$i ${T}${CALC_SHAREDIR}/$$i.new; \
|
||||
${CHMOD} 0444 ${T}${CALC_SHAREDIR}/$$i.new; \
|
||||
${MV} -f ${T}${CALC_SHAREDIR}/$$i.new ${T}${CALC_SHAREDIR}/$$i; \
|
||||
echo "installed ${T}${CALC_SHAREDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
@@ -286,22 +294,22 @@ install: all
|
||||
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||
#
|
||||
uninstall:
|
||||
-${Q}for i in ${CALC_FILES} /dev/null; do \
|
||||
-${Q} for i in ${CALC_FILES} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if [ -f "$T${CALC_SHAREDIR}/$$i" ]; then \
|
||||
rm -f "$T${CALC_SHAREDIR}/$$i"; \
|
||||
if [ -f "$T${CALC_SHAREDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall $T${CALC_SHAREDIR}/$$i"; \
|
||||
if [ -f "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
||||
${RM} -f "${T}${CALC_SHAREDIR}/$$i"; \
|
||||
if [ -f "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall ${T}${CALC_SHAREDIR}/$$i"; \
|
||||
else \
|
||||
echo "uninstalled $T${CALC_SHAREDIR}/$$i"; \
|
||||
echo "uninstalled ${T}${CALC_SHAREDIR}/$$i"; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${CALC_SHAREDIR}; do \
|
||||
if [ -d "$T$$i" ]; then \
|
||||
rmdir "$T$$i" 2>/dev/null; \
|
||||
echo "cleaned up $T$$i"; \
|
||||
-${Q} for i in ${CALC_SHAREDIR}; do \
|
||||
if [ -d "${T}$$i" ]; then \
|
||||
${RMDIR} "${T}$$i" 2>/dev/null; \
|
||||
echo "cleaned up ${T}$$i"; \
|
||||
fi; \
|
||||
done
|
||||
|
@@ -714,7 +714,7 @@ sumtimes.cal
|
||||
timehmean(N,M)
|
||||
doalltimes(N)
|
||||
|
||||
Give the runtimes for various ways of evaluating sums, sums of
|
||||
Give the user CPU time for various ways of evaluating sums, sums of
|
||||
squares, etc, for large lists and matrices. N is the size of
|
||||
the list or matrix to use. The doalltimes() function will run
|
||||
all fo the sumtimes tests. For example:
|
||||
@@ -1014,8 +1014,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.15 $
|
||||
## @(#) $Id: README,v 29.15 2006/06/23 00:34:55 chongo Exp $
|
||||
## @(#) $Revision: 29.16 $
|
||||
## @(#) $Id: README,v 29.16 2006/12/16 11:18:46 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
|
||||
##
|
||||
## Under source code control: 1990/02/15 01:50:32
|
||||
|
@@ -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.14 $
|
||||
* @(#) $Id: alg_config.cal,v 29.14 2006/06/11 07:22:05 chongo Exp $
|
||||
* @(#) $Revision: 29.15 $
|
||||
* @(#) $Id: alg_config.cal,v 29.15 2006/12/16 11:18:46 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/alg_config.cal,v $
|
||||
*
|
||||
* Under source code control: 2006/06/07 14:10:11
|
||||
@@ -85,7 +85,7 @@ define mul_loop(repeat, x)
|
||||
}
|
||||
|
||||
/* multiply pairwise, all sets of a given length */
|
||||
start = runtime();
|
||||
start = usertime();
|
||||
for (i=0; i < repeat; ++i) {
|
||||
|
||||
if (len == 1) {
|
||||
@@ -130,7 +130,7 @@ define mul_loop(repeat, x)
|
||||
/*
|
||||
* return duration
|
||||
*/
|
||||
end = runtime();
|
||||
end = usertime();
|
||||
return end-start;
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ define sq_loop(repeat, x)
|
||||
}
|
||||
|
||||
/* square pairwise, all sets of a given length */
|
||||
start = runtime();
|
||||
start = usertime();
|
||||
for (i=0; i < repeat; ++i) {
|
||||
|
||||
if (len == 1) {
|
||||
@@ -524,7 +524,7 @@ define sq_loop(repeat, x)
|
||||
/*
|
||||
* return duration
|
||||
*/
|
||||
end = runtime();
|
||||
end = usertime();
|
||||
return end-start;
|
||||
}
|
||||
|
||||
@@ -874,7 +874,7 @@ define pow_loop(repeat, x, ex)
|
||||
}
|
||||
|
||||
/* pmod pairwise, all sets of a given length */
|
||||
start = runtime();
|
||||
start = usertime();
|
||||
for (i=0; i < repeat; ++i) {
|
||||
|
||||
if (len == 1) {
|
||||
@@ -927,7 +927,7 @@ define pow_loop(repeat, x, ex)
|
||||
/*
|
||||
* return duration
|
||||
*/
|
||||
end = runtime();
|
||||
end = usertime();
|
||||
return end-start;
|
||||
}
|
||||
|
||||
|
@@ -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: mfactor.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: mfactor.cal,v 29.3 2006/12/16 11:18:46 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mfactor.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/07/06 06:09:40
|
||||
@@ -261,7 +261,7 @@ define mfactor(n, start_k, rept_loop, p_elim)
|
||||
} else {
|
||||
/* report this loop */
|
||||
printf("at 2*%d*%d+1, cpu: %f\n",
|
||||
(q-1)/(2*n), n, runtime());
|
||||
(q-1)/(2*n), n, usertime());
|
||||
fflush(files(1));
|
||||
loop = 0;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ define mfactor(n, start_k, rept_loop, p_elim)
|
||||
if (rept_loop <= ++loop) {
|
||||
/* report this loop */
|
||||
printf("at 2*%d*%d+1, cpu: %f\n",
|
||||
(q-1)/(2*n), n, runtime());
|
||||
(q-1)/(2*n), n, usertime());
|
||||
fflush(files(1));
|
||||
loop = 0;
|
||||
}
|
||||
|
@@ -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: randmprime.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: randmprime.cal,v 29.3 2006/12/16 11:18:46 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randmprime.cal,v $
|
||||
*
|
||||
* Under source code control: 1994/03/14 23:11:21
|
||||
@@ -88,8 +88,8 @@ randmprime(bits, seed, dbg)
|
||||
* loop until we find a prime
|
||||
*/
|
||||
if (dbg >= 1) {
|
||||
start = runtime();
|
||||
init = runtime();
|
||||
start = usertime();
|
||||
init = usertime();
|
||||
plush = 0;
|
||||
print "DEBUG1: testing (h+" : plush : ")*2^" : n : "-1";
|
||||
}
|
||||
@@ -97,7 +97,7 @@ randmprime(bits, seed, dbg)
|
||||
|
||||
/* bump h, and n if needed */
|
||||
if (dbg >= 2) {
|
||||
stop = runtime();
|
||||
stop = usertime();
|
||||
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
||||
}
|
||||
if (dbg >= 1) {
|
||||
@@ -116,7 +116,7 @@ randmprime(bits, seed, dbg)
|
||||
|
||||
/* found a prime */
|
||||
if (dbg >= 2) {
|
||||
stop = runtime();
|
||||
stop = usertime();
|
||||
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
||||
print "DEBUG3: " : h : "*2^" : n : "-1 is prime";
|
||||
}
|
||||
|
@@ -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.34 $
|
||||
* @(#) $Id: regress.cal,v 29.34 2006/06/25 20:33:26 chongo Exp $
|
||||
* @(#) $Revision: 29.36 $
|
||||
* @(#) $Id: regress.cal,v 29.36 2006/12/16 11:18:46 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:36
|
||||
@@ -497,7 +497,33 @@ define test_config()
|
||||
vrfy(config("mode2") == "off",
|
||||
'556: config("mode2") == "off"');
|
||||
|
||||
print '557: Ending test_config';
|
||||
/* hz is numeric */
|
||||
vrfy(isint(config("hz")), '557: isint(config("hz"))');
|
||||
|
||||
/* compile_custom is simple */
|
||||
vrfy(issimple(config("compile_custom")),
|
||||
'558: issimple(config("compile_custom"))');
|
||||
|
||||
/* allow_custom is simple */
|
||||
vrfy(issimple(config("allow_custom")),
|
||||
'559: issimple(config("allow_custom"))');
|
||||
|
||||
/* allow_custom is simple */
|
||||
vrfy(issimple(config("allow_custom")),
|
||||
'559: issimple(config("allow_custom"))');
|
||||
|
||||
/* baseb is numeric */
|
||||
vrfy(isint(config("baseb")), '560: isint(config("baseb"))');
|
||||
|
||||
/* redecl_warn is simple */
|
||||
vrfy(issimple(config("redecl_warn")),
|
||||
'561: issimple(config("redecl_warn"))');
|
||||
|
||||
/* dupvar_warn is simple */
|
||||
vrfy(issimple(config("dupvar_warn")),
|
||||
'562: issimple(config("rdupvar_warn"))');
|
||||
|
||||
print '563: Ending test_config';
|
||||
}
|
||||
print '010: parsed test_config()';
|
||||
|
||||
@@ -743,6 +769,7 @@ define test_functions()
|
||||
local pi;
|
||||
local h, n, r, m, v;
|
||||
local n2, m2, v2;
|
||||
local t;
|
||||
|
||||
print '700: Beginning test_functions';
|
||||
|
||||
@@ -1374,7 +1401,12 @@ define test_functions()
|
||||
vrfy(a == -4, '1203: a == -4');
|
||||
vrfy(b == 2, '1204: b == 2');
|
||||
|
||||
print '1205: Ending test_functions';
|
||||
/* runtime(), systime(), usertime() return numeric values */
|
||||
vrfy(isnum(runtime()), '1205: isnum(runtime())');
|
||||
vrfy(isnum(systime()), '1206: isnum(systime())');
|
||||
vrfy(isnum(usertime()), '1207: isnum(usertime())');
|
||||
|
||||
print '1208: Ending test_functions';
|
||||
}
|
||||
print '017: parsed test_functions()';
|
||||
|
||||
@@ -3461,7 +3493,7 @@ print '070: parsed test_redc()';
|
||||
*/
|
||||
define test_fileops()
|
||||
{
|
||||
local a, b, c, f, m, n, p, r, x, y, z;
|
||||
local a, b, c, f, m, n, p, r, s, x, y, z;
|
||||
local L = "Landon";
|
||||
local C = "Curt";
|
||||
local N = "Noll";
|
||||
@@ -3586,15 +3618,38 @@ define test_fileops()
|
||||
++ecnt;
|
||||
print '4267: ++ecnt;';
|
||||
vrfy(isfile(p=fopen(long,"r")) == 0,
|
||||
'4268: isfile(p=fopen(long,"r")) == 0');
|
||||
'4268: isfile(p=fopen(long,"r")) == 0');
|
||||
|
||||
/*
|
||||
* test fgetfile() and fgetline()
|
||||
*/
|
||||
vrfy(!iserror(p=fopen("tmp4200","w")),
|
||||
'4269: !iserror(p=fopen("tmp4200","w"))');
|
||||
vrfy(!iserror(fputs(p,"chongo\n")),
|
||||
'4270: !iserror(fputs(p,"chongo\n"))');
|
||||
vrfy(!iserror(fputs(p,"w\0a\0s\n")),
|
||||
'4271: !iserror(fputs(p,"w\0a\0s\n"))');
|
||||
vrfy(!iserror(fputs(p,"here\n")),
|
||||
'4272: !iserror(fputs(p,"here\n"))');
|
||||
vrfy(!iserror(fclose(p)), '4273: !iserror(fclose(p))');
|
||||
vrfy(!iserror(p=fopen("tmp4200","r")),
|
||||
'4274: !iserror(p=fopen("tmp4200","r"))');
|
||||
vrfy(!iserror(s=fgetline(p)), '4275: !iserror(s=fgetline(p))');
|
||||
vrfy(strcmp(s,"chongo") == 0, '4276: strcmp(s,"chongo") == 0');
|
||||
vrfy(!iserror(s=fgetfile(p)), '4277: !iserror(s=fgetfile(p))');
|
||||
vrfy(strcmp(s,"w\0a\0s\nhere\n") == 0,
|
||||
'4278: strcmp(s,"w\0a\0s\nhere\n") == 0');
|
||||
vrfy(!iserror(fclose(p)), '4279: !iserror(fclose(p))');
|
||||
|
||||
/*
|
||||
* cleanup
|
||||
*/
|
||||
x = rm("junk4200");
|
||||
print '4269: x = rm("junk4200")';
|
||||
print '4280: x = rm("junk4200")';
|
||||
x = rm("tmp4200");
|
||||
print '4281: x = rm("tmp4200")';
|
||||
|
||||
print '4270: Ending test_fileops';
|
||||
print '4282: Ending test_fileops';
|
||||
}
|
||||
print '071: parsed test_fileops()';
|
||||
|
||||
|
@@ -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: set8700.cal,v 29.1 2006/05/20 19:35:33 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: set8700.cal,v 29.2 2006/08/20 16:16:11 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.cal,v $
|
||||
*
|
||||
* Under source code control: 2006/05/20 14:10:11
|
||||
@@ -70,3 +70,8 @@ define set8700_g(set8700_x)
|
||||
obj set8700_point {
|
||||
set8700_x, set8700_y, set8700_z
|
||||
}
|
||||
|
||||
global mat set8700_c[] = { 1, 2+3i, -5+4i, 5i+6, -7i };
|
||||
|
||||
global mat set8700_e[] = { 0, 1, 0, 0, 2, -3/2, 2, -1/2,
|
||||
-3, 0.5, -1.0, 0.5, 1.0, 0.0, 0.0, 0.0 };
|
||||
|
@@ -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: set8700.line,v 29.2 2006/06/20 09:29:16 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: set8700.line,v 29.4 2006/08/20 16:16:11 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.line,v $
|
||||
##
|
||||
## Under source code control: 2006/05/20 14:10:11
|
||||
@@ -402,3 +402,28 @@ set8700_P == (obj set8700_point = {1,2,3})
|
||||
set8700_L = list(mat[1] = {set8700_P}), protect(set8700_L[0][0]) == 16
|
||||
set8700_L = {{{4,5,6}}}, set8700_L[0][0] == set8700_P
|
||||
protect(set8700_L,0,2), set8700_L = {{{4,5,6}}}, set8700_L[0][0] == (obj set8700_point = {4,5,6})
|
||||
|
||||
## Testing quomod
|
||||
quomod(14,5,3,4) == error(10374)
|
||||
global set8700_a,set8700_b; quomod("abc", 4, set8700_a, set8700_b) == error(10375)
|
||||
quomod(14,5,set8700_a,set8700_b,0) == 1 && set8700_a == 2 && set8700_b == 4
|
||||
quomod(14,5,set8700_a,set8700_b,1) == 1 && set8700_a == 3 && set8700_b == -1
|
||||
quomod("abc",2,set8700_a,set8700_b) == error(10375)
|
||||
set8700_a = "abc"; quomod(14,5,set8700_a,set8700_b) == error(10375)
|
||||
set8700_a = null(); quomod(14,5,set8700_a,set8700_b,24) == 1; set8700_a == 3 && set8700_b == -1
|
||||
quomod(14,5,set8700_a,set8700_a) == error(10374)
|
||||
quomod(14,5,set8700_a,set8700_b,-1) == error(10375)
|
||||
protect(set8700_a,1); quomod(17,2,set8700_a,set8700_b) == error(10376)
|
||||
protect(set8700_a,0); quomod(17,2,set8700_a,set8700_b); set8700_a == 8 && set8700_b == 1
|
||||
set8700_p = &set8700_a, set8700_q = &set8700_b; quomod(14,5,*set8700_p,*set8700_q); *set8700_p == 2 && *set8700_q == 4
|
||||
|
||||
## Testing estr
|
||||
base(1/3) == 10
|
||||
strcmp(estr(null()), "\"\"") == 0
|
||||
strcmp(estr(bernoulli(48)), "-5609403368997817686249127547/46410") == 0
|
||||
strcmp(estr(sin(3i)), "1001787492740990189897i/100000000000000000000") == 0
|
||||
base(10) == 1/3
|
||||
strcmp(estr("fizzbin"), "\"fizzbin\"") == 0
|
||||
strcmp(estr(set8700_c), "mat[5]={1,2+3i,-5+4i,6+5i,-7i}") == 0
|
||||
strcmp(estr(set8700_e), "mat[16]={0,1,0,0,2,-3/2,2,-1/2,-3,1/2,-1,1/2,1,0,0,0}") == 0
|
||||
strcmp(estr(list(2,3,5)), "list(2,3,5)") == 0
|
||||
|
@@ -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: sumtimes.cal,v 29.1 2006/06/23 00:35:30 chongo Exp $
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: sumtimes.cal,v 29.2 2006/12/16 11:18:46 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/sumtimes.cal,v $
|
||||
*
|
||||
* Under source code control: 2006/06/22 17:29
|
||||
@@ -40,13 +40,13 @@ define timematsum(N) {
|
||||
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||
|
||||
ptop = &sumtimes_A[n-1];
|
||||
sumtimes_t0 = runtime();
|
||||
sumtimes_t0 = usertime();
|
||||
for (s = n = 0; n < N; n++) s += sumtimes_A[n];
|
||||
sumtimes_t1 = runtime();
|
||||
sumtimes_t1 = usertime();
|
||||
for (s = 0, p = &sumtimes_A[0]; p <= ptop; p++) s += *p;
|
||||
sumtimes_t2 = runtime();
|
||||
sumtimes_t2 = usertime();
|
||||
s = matsum(sumtimes_A);
|
||||
sumtimes_t3 = runtime();
|
||||
sumtimes_t3 = usertime();
|
||||
|
||||
print "Matrix sum runtimes";
|
||||
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||
@@ -60,11 +60,11 @@ define timelistsum(N) {
|
||||
sumtimes_A = makelist(N);
|
||||
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||
|
||||
sumtimes_t0 = runtime();
|
||||
sumtimes_t0 = usertime();
|
||||
for (s = n = 0; n < N; n++) s += sumtimes_A[n];
|
||||
sumtimes_t1 = runtime();
|
||||
sumtimes_t1 = usertime();
|
||||
s = sum(sumtimes_A);
|
||||
sumtimes_t2 = runtime();
|
||||
sumtimes_t2 = usertime();
|
||||
print "List sum runtimes";
|
||||
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||
printf('\tUsing builtin "sum":\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
|
||||
@@ -76,9 +76,9 @@ define timematsort(N) {
|
||||
|
||||
sumtimes_A = mat[N];
|
||||
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||
sumtimes_t0 = runtime();
|
||||
sumtimes_t0 = usertime();
|
||||
sort(sumtimes_A);
|
||||
sumtimes_t1 = runtime();
|
||||
sumtimes_t1 = usertime();
|
||||
printf('\tMatrix sort runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ define timelistsort(N) {
|
||||
|
||||
sumtimes_A = makelist(N);
|
||||
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||
sumtimes_t0 = runtime();
|
||||
sumtimes_t0 = usertime();
|
||||
sort(sumtimes_A);
|
||||
sumtimes_t1 = runtime();
|
||||
sumtimes_t1 = usertime();
|
||||
printf('\tList sort runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ define timematreverse(N) {
|
||||
|
||||
sumtimes_A = mat[N];
|
||||
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||
sumtimes_t0 = runtime();
|
||||
sumtimes_t0 = usertime();
|
||||
reverse(sumtimes_A);
|
||||
sumtimes_t1 = runtime();
|
||||
sumtimes_t1 = usertime();
|
||||
printf('\tMatrix reverse runtime %.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||
}
|
||||
|
||||
@@ -110,9 +110,9 @@ define timelistreverse(N) {
|
||||
|
||||
sumtimes_A = makelist(N);
|
||||
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||
sumtimes_t0 = runtime();
|
||||
sumtimes_t0 = usertime();
|
||||
reverse(sumtimes_A);
|
||||
sumtimes_t1 = runtime();
|
||||
sumtimes_t1 = usertime();
|
||||
printf('\tList reverse runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||
}
|
||||
|
||||
@@ -124,11 +124,11 @@ define timematssq(N) {
|
||||
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||
|
||||
ptop = &sumtimes_A[n-1];
|
||||
sumtimes_t0 = runtime();
|
||||
sumtimes_t0 = usertime();
|
||||
for (s = n = 0; n < N; n++) s += sumtimes_A[n]^2;
|
||||
sumtimes_t1 = runtime();
|
||||
sumtimes_t1 = usertime();
|
||||
for (s = 0, p = &sumtimes_A[0]; p <= ptop; p++) s += (*p)^2;
|
||||
sumtimes_t2 = runtime();
|
||||
sumtimes_t2 = usertime();
|
||||
|
||||
print "Matrix sum of squares runtimes";
|
||||
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||
@@ -141,11 +141,11 @@ define timelistssq(N) {
|
||||
sumtimes_A = makelist(N);
|
||||
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
|
||||
|
||||
sumtimes_t0 = runtime();
|
||||
sumtimes_t0 = usertime();
|
||||
for (s = n = 0; n < N; n++) s += sumtimes_A[n]^2;
|
||||
sumtimes_t1 = runtime();
|
||||
sumtimes_t1 = usertime();
|
||||
s = ssq(sumtimes_A);
|
||||
sumtimes_t2 = runtime();
|
||||
sumtimes_t2 = usertime();
|
||||
print "List sum of squares runtimes";
|
||||
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||
printf('\tUsing builtin "ssq":\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
|
||||
@@ -157,12 +157,12 @@ define timehmean(N, M = 10) {
|
||||
sumtimes_A = makelist(N);
|
||||
for (n = 0; n < N; n++) sumtimes_A[n] = rand(1, M);
|
||||
|
||||
sumtimes_t0 = runtime();
|
||||
sumtimes_t0 = usertime();
|
||||
for (s = n = 0; n < N; n++) s += 1/sumtimes_A[n];
|
||||
v1 = N/s;
|
||||
sumtimes_t1 = runtime();
|
||||
sumtimes_t1 = usertime();
|
||||
v2 = hmean(sumtimes_A);
|
||||
sumtimes_t2 = runtime();
|
||||
sumtimes_t2 = usertime();
|
||||
print v1, v2;
|
||||
print "List harmonic meanruntimes";
|
||||
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
|
||||
|
@@ -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: test3300.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: test3300.cal,v 29.5 2006/12/16 11:19:45 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3300.cal,v $
|
||||
*
|
||||
* Under source code control: 1995/12/02 04:27:41
|
||||
@@ -81,9 +81,9 @@ define testr(str, n, N, verbose)
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = 0; j < n; j++)
|
||||
A[i,j] = rand(-(N^2), N^2)/rand(1, N);
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
d1 = det(A);
|
||||
t = runtime() - t;
|
||||
t = usertime() - t;
|
||||
d2 = det(A^2);
|
||||
if (d2 != d1^2) {
|
||||
if (verbose > 0) {
|
||||
|
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: test4000.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: test4000.cal,v 29.4 2006/12/16 11:18:46 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4000.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/03/13 02:38:45
|
||||
@@ -145,7 +145,7 @@ define ptimes(str, N, n, count, skip, verbose)
|
||||
mat A[n];
|
||||
for (i = 0; i < n; i++)
|
||||
A[i] = plen(N);
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++) {
|
||||
p = ptest(A[i], count, skip);
|
||||
if (!p) {
|
||||
@@ -159,7 +159,7 @@ define ptimes(str, N, n, count, skip, verbose)
|
||||
if (m) {
|
||||
printf("*** %d error(s)\n", m);
|
||||
} else {
|
||||
t = round(runtime() - t, 4);
|
||||
t = round(usertime() - t, 4);
|
||||
if (verbose > 1) {
|
||||
printf("%d probable primes: time = %d\n", n, t);
|
||||
} else {
|
||||
@@ -194,7 +194,7 @@ define ctimes(str, N, n, count, skip, verbose)
|
||||
mat A[n];
|
||||
for (i = 0; i < n; i++)
|
||||
A[i] = clen(N);
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++) {
|
||||
p = ptest(A[i], count, skip);
|
||||
if (p) {
|
||||
@@ -208,7 +208,7 @@ define ctimes(str, N, n, count, skip, verbose)
|
||||
if (m) {
|
||||
printf("*** %d error(s)\n", m);
|
||||
} else {
|
||||
t = round(runtime() - t, 4);
|
||||
t = round(usertime() - t, 4);
|
||||
if (verbose > 1) {
|
||||
printf("%d probable primes: time = %d\n", n, t);
|
||||
} else {
|
||||
@@ -242,7 +242,7 @@ define crtimes(str, a, b, n, count, skip, verbose)
|
||||
A[i] = rand(a,b);
|
||||
P[i] = ptest(A[i], 20, 0);
|
||||
}
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++) {
|
||||
p = ptest(A[i], count, skip);
|
||||
if (p != P[i]) {
|
||||
@@ -257,7 +257,7 @@ define crtimes(str, a, b, n, count, skip, verbose)
|
||||
if (m) {
|
||||
printf("*** %d error(s)?\n", m);
|
||||
} else {
|
||||
t = round(runtime() - t, 4);
|
||||
t = round(usertime() - t, 4);
|
||||
if (verbose > 1) {
|
||||
printf("%d probable primes: time = %d\n", n, t);
|
||||
} else {
|
||||
@@ -295,16 +295,16 @@ define ntimes(str, N, n, count, skip, residue, modulus, verbose)
|
||||
mat A[n];
|
||||
for (i = 0; i < n; i++)
|
||||
A[i] = rlen(N);
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++) {
|
||||
p = nextcand(A[i], count, skip, residue, modulus);
|
||||
}
|
||||
tnext = round(runtime() - t, 4);
|
||||
t = runtime();
|
||||
tnext = round(usertime() - t, 4);
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++) {
|
||||
p = prevcand(A[i], count, skip, residue, modulus);
|
||||
}
|
||||
tprev = round(runtime() - t, 4);
|
||||
tprev = round(usertime() - t, 4);
|
||||
if (verbose > 0) {
|
||||
printf("%d evaluations, nextcand: %d, prevcand: %d\n", n, tnext, tprev);
|
||||
}
|
||||
|
@@ -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: test4100.cal,v 29.4 2006/06/20 09:29:16 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: test4100.cal,v 29.5 2006/12/16 11:18:46 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4100.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/03/13 03:53:22
|
||||
@@ -245,38 +245,38 @@ define times(str,N,n,verbose)
|
||||
C[i] = rand(m2);
|
||||
}
|
||||
z = rcin(0,m); /* to initialize redc and maybe lastmod information */
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z = rcin(A[i],m);
|
||||
trcin = round(runtime() - t, 3);
|
||||
t = runtime();
|
||||
trcin = round(usertime() - t, 3);
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z = rcout(A[i],m);
|
||||
trcout = round(runtime() - t, 3);
|
||||
t = runtime();
|
||||
trcout = round(usertime() - t, 3);
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z = rcmul(A[i],B[i],m);
|
||||
trcmul = round(runtime() - t, 3);
|
||||
t = runtime();
|
||||
trcmul = round(usertime() - t, 3);
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z = rcsq(A[i],m);
|
||||
trcsq = round(runtime() - t, 3);
|
||||
t = runtime();
|
||||
trcsq = round(usertime() - t, 3);
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z = A[i] * B[i];
|
||||
tmul = round(runtime() - t, 3);
|
||||
t = runtime();
|
||||
tmul = round(usertime() - t, 3);
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z = A[i]^2;
|
||||
tsq = round(runtime() - t, 3);
|
||||
t = runtime();
|
||||
tsq = round(usertime() - t, 3);
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z = C[i] % A[i];
|
||||
tmod = round(runtime() - t, 3);
|
||||
t = runtime();
|
||||
tmod = round(usertime() - t, 3);
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
quomod(C[i], A[i], x, y);
|
||||
tquomod = round(runtime() - t,3);
|
||||
tquomod = round(usertime() - t,3);
|
||||
|
||||
if (verbose > 1) {
|
||||
printf("rcin: %d, rcout: %d, rcmul: %d, rcsq: %d\n",
|
||||
@@ -326,29 +326,29 @@ define powtimes(str, N1, N2, n, verbose)
|
||||
Ar[i] = rcin(A[i], v);
|
||||
B[i] = rlen_4100(N2);
|
||||
}
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z1 += pmod(A[i], B[i], v);
|
||||
tbignum = round(runtime() - t, 4);
|
||||
tbignum = round(usertime() - t, 4);
|
||||
config("pow2", 1e6);
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z2 += pmod(A[i], B[i], v);
|
||||
tnormal = round(runtime() - t, 4);
|
||||
tnormal = round(usertime() - t, 4);
|
||||
config("redc2",1e6);
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z3 += pmod(A[i], B[i], v);
|
||||
tsmall = round(runtime() - t, 4);
|
||||
t = runtime();
|
||||
tsmall = round(usertime() - t, 4);
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z4 += rcpow(Ar[i], B[i], v);
|
||||
trcsmall = round(runtime() - t, 4);
|
||||
trcsmall = round(usertime() - t, 4);
|
||||
config("redc2", 2);
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
z5 += rcpow(Ar[i], B[i], v);
|
||||
trcbig = round(runtime() - t, 4);
|
||||
trcbig = round(usertime() - t, 4);
|
||||
|
||||
if (z1 != z2) {
|
||||
++m;
|
||||
@@ -419,13 +419,13 @@ define inittimes(str,N,n,verbose)
|
||||
M[i] = olen(N);
|
||||
A[i] = rand(M[i]);
|
||||
}
|
||||
t = runtime();
|
||||
t = usertime();
|
||||
for (i = 0; i < n; i++)
|
||||
R[i] = rcin(A[i], M[i]);
|
||||
trcin = round(runtime() - t, 4);
|
||||
trcin = round(usertime() - t, 4);
|
||||
for (i = 0; i < n; i++)
|
||||
B[i] = rcout(R[i], M[i]);
|
||||
trcout = round(runtime() - t, 4);
|
||||
trcout = round(usertime() - t, 4);
|
||||
for (i = 0; i < n; i++) {
|
||||
if (B[i] != A[i]) {
|
||||
++m;
|
||||
|
31
calc.c
31
calc.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* calc - arbitrary precision calculator
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
* Copyright (C) 1999-2007 David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -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.13 $
|
||||
* @(#) $Id: calc.c,v 29.13 2006/05/19 15:26:10 chongo Exp $
|
||||
* @(#) $Revision: 29.15 $
|
||||
* @(#) $Id: calc.c,v 29.15 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:11
|
||||
@@ -87,11 +87,11 @@
|
||||
|
||||
|
||||
/*
|
||||
* static definitions and functions
|
||||
* S_FUNC definitions and functions
|
||||
*/
|
||||
static void intint(int arg); /* interrupt routine */
|
||||
static int nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr);
|
||||
static void set_run_state(run state);
|
||||
S_FUNC void intint(int arg); /* interrupt routine */
|
||||
S_FUNC int nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr);
|
||||
S_FUNC void set_run_state(run state);
|
||||
|
||||
/*
|
||||
* Top level calculator routine.
|
||||
@@ -416,6 +416,7 @@ main(int argc, char **argv)
|
||||
cp++;
|
||||
*bp++ = ';';
|
||||
cmdlen++;
|
||||
s_flag = TRUE; /* -f implies -s */
|
||||
break;
|
||||
|
||||
case 's':
|
||||
@@ -431,11 +432,13 @@ main(int argc, char **argv)
|
||||
fprintf(stderr, "Illegal option -%c\n",
|
||||
c);
|
||||
fprintf(stderr,
|
||||
"usage: %s [-a] [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
|
||||
"usage: %s [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
|
||||
"\t[-D calc_debug[:resource_debug[:user_debug]]]\n"
|
||||
"\t[-O] [-p] [-q] [-u] [-v] "
|
||||
"[--] [calc_cmd ...]\n",
|
||||
program);
|
||||
"\t[-O] [-p] [-q] [-s] [-u] [-v] "
|
||||
"[--] [calc_cmd ...]\n"
|
||||
"usage: %s ... -f filename\n"
|
||||
"1st cscript line: #/path/to/calc ... -f\n",
|
||||
program, program);
|
||||
exit(1);
|
||||
}
|
||||
if (havearg)
|
||||
@@ -710,7 +713,7 @@ main(int argc, char **argv)
|
||||
* arg to keep ANSI C happy
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
S_FUNC void
|
||||
intint(int UNUSED arg)
|
||||
{
|
||||
(void) signal(SIGINT, intint);
|
||||
@@ -757,7 +760,7 @@ math_error(char *fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
S_FUNC int
|
||||
nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr)
|
||||
{
|
||||
char *cp;
|
||||
@@ -796,7 +799,7 @@ nextcp(char **cpp, int *ip, int argc, char **argv, BOOL haveendstr)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
set_run_state(run state)
|
||||
{
|
||||
if (conf->calc_debug & CALCDBG_RUNSTATE)
|
||||
|
238
calc.h
238
calc.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* calc - definitions for calculator program
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.18 $
|
||||
* @(#) $Id: calc.h,v 29.18 2006/05/21 07:28:54 chongo Exp $
|
||||
* @(#) $Revision: 29.20 $
|
||||
* @(#) $Id: calc.h,v 29.20 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.h,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:31
|
||||
@@ -33,11 +33,11 @@
|
||||
|
||||
#include <setjmp.h>
|
||||
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
||||
# include "win32dll.h"
|
||||
# include "decl.h"
|
||||
# include "value.h"
|
||||
# include "have_const.h"
|
||||
#else
|
||||
# include <calc/win32dll.h>
|
||||
# include <calc/decl.h>
|
||||
# include <calc/value.h>
|
||||
# include <calc/have_const.h>
|
||||
#endif
|
||||
@@ -103,141 +103,141 @@
|
||||
/*
|
||||
* File I/O routines.
|
||||
*/
|
||||
extern DLL FILEID openid(char *name, char *mode);
|
||||
extern DLL FILEID openpathid(char *name, char *mode, char *pathlist);
|
||||
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);
|
||||
E_FUNC FILEID openid(char *name, char *mode);
|
||||
E_FUNC FILEID openpathid(char *name, char *mode, char *pathlist);
|
||||
E_FUNC FILEID indexid(long index);
|
||||
E_FUNC BOOL validid(FILEID id);
|
||||
E_FUNC BOOL errorid(FILEID id);
|
||||
E_FUNC BOOL eofid(FILEID id);
|
||||
E_FUNC int closeid(FILEID id);
|
||||
E_FUNC int getcharid(FILEID id);
|
||||
E_FUNC int idprintf(FILEID id, char *fmt, int count, VALUE **vals);
|
||||
E_FUNC int idfputc(FILEID id, int ch);
|
||||
E_FUNC int idfputs(FILEID id, STRING *str);
|
||||
E_FUNC int printid(FILEID id, int flags);
|
||||
E_FUNC int flushid(FILEID id);
|
||||
E_FUNC int readid(FILEID id, int flags, STRING **retptr);
|
||||
E_FUNC int getloc(FILEID id, ZVALUE *loc);
|
||||
E_FUNC int setloc(FILEID id, ZVALUE zpos);
|
||||
E_FUNC int getsize(FILEID id, ZVALUE *size);
|
||||
E_FUNC int get_device(FILEID id, ZVALUE *dev);
|
||||
E_FUNC int get_inode(FILEID id, ZVALUE *ino);
|
||||
E_FUNC FILEID reopenid(FILEID id, char *mode, char *name);
|
||||
E_FUNC int closeall(void);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
extern DLL int flushall(void);
|
||||
E_FUNC 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);
|
||||
E_FUNC int idfputstr(FILEID id, char *str);
|
||||
E_FUNC int rewindid(FILEID id);
|
||||
E_FUNC void rewindall(void);
|
||||
E_FUNC ZVALUE zfilesize(FILEID id);
|
||||
E_FUNC void showfiles(void);
|
||||
E_FUNC int fscanfid(FILEID id, char *fmt, int count, VALUE **vals);
|
||||
E_FUNC int scanfstr(char *str, char *fmt, int count, VALUE **vals);
|
||||
E_FUNC int ftellid(FILEID id, ZVALUE *res);
|
||||
E_FUNC int fseekid(FILEID id, ZVALUE offset, int whence);
|
||||
E_FUNC int isattyid(FILEID id);
|
||||
E_FUNC int fsearch(FILEID id, char *str, ZVALUE start, ZVALUE end, ZVALUE *res);
|
||||
E_FUNC int frsearch(FILEID id, char *str, ZVALUE first, ZVALUE last, ZVALUE *res);
|
||||
E_FUNC void showconstants(void);
|
||||
E_FUNC void freeconstant(unsigned long);
|
||||
E_FUNC void freestringconstant(long);
|
||||
E_FUNC void trimconstants(void);
|
||||
|
||||
/*
|
||||
* Input routines.
|
||||
*/
|
||||
extern DLL int openstring(char *str, size_t 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);
|
||||
E_FUNC int openstring(char *str, size_t num);
|
||||
E_FUNC int openterminal(void);
|
||||
E_FUNC int opensearchfile(char *name, char *pathlist, char *exten, int reopen_ok);
|
||||
E_FUNC char *nextline(void);
|
||||
E_FUNC int nextchar(void);
|
||||
E_FUNC void reread(void);
|
||||
E_FUNC void resetinput(void);
|
||||
E_FUNC void setprompt(char *);
|
||||
E_FUNC BOOL inputisterminal(void);
|
||||
E_FUNC int inputlevel(void);
|
||||
E_FUNC long calclevel(void);
|
||||
E_FUNC char *inputname(void);
|
||||
E_FUNC long linenumber(void);
|
||||
E_FUNC void runrcfiles(void);
|
||||
E_FUNC void closeinput(void);
|
||||
|
||||
/*
|
||||
* Other routines.
|
||||
*/
|
||||
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 *);
|
||||
E_FUNC NUMBER *constvalue(unsigned long index);
|
||||
E_FUNC long addnumber(char *str);
|
||||
E_FUNC long addqconstant(NUMBER *q);
|
||||
E_FUNC void initstack(void);
|
||||
E_FUNC void getcommands(BOOL toplevel);
|
||||
E_FUNC void givehelp(char *type);
|
||||
E_FUNC void libcalc_call_me_first(void);
|
||||
E_FUNC void libcalc_call_me_last(void);
|
||||
E_FUNC BOOL calc_tty(int fd);
|
||||
E_FUNC BOOL orig_tty(int fd);
|
||||
E_FUNC void showerrors(void);
|
||||
E_FUNC char *calc_strdup(CONST char *);
|
||||
|
||||
/*
|
||||
* Initialization
|
||||
*/
|
||||
extern DLL void initialize(void);
|
||||
extern DLL void reinitialize(void);
|
||||
E_FUNC void initialize(void);
|
||||
E_FUNC void reinitialize(void);
|
||||
#if !defined (_WIN32)
|
||||
extern DLL int isatty(int tty); /* TRUE if fd is a tty */
|
||||
E_FUNC 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 */
|
||||
E_FUNC char *version(void); /* return version string */
|
||||
EXTERN int post_init; /* TRUE => math_error setjmp is ready */
|
||||
|
||||
/*
|
||||
* global flags and definitions
|
||||
*/
|
||||
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 abortlevel; /* current level of aborts */
|
||||
EXTERN BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||
EXTERN jmp_buf jmpbuf; /* for errors */
|
||||
|
||||
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 long stoponerror; /* >0 => stop, <0 => continue, ==0 => use -c */
|
||||
extern DLL BOOL abort_now; /* TRUE => try to go interactive */
|
||||
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 */
|
||||
E_FUNC int s_flag; /* TRUE => keep args as strings for argv() */
|
||||
EXTERN long stoponerror; /* >0 => stop, <0 => continue, ==0 => use -c */
|
||||
EXTERN BOOL abort_now; /* TRUE => try to go interactive */
|
||||
|
||||
extern DLL int argc_value; /* count of argv[] strings for argv() builtin */
|
||||
extern DLL char **argv_value; /* argv[] strings for argv() builtin */
|
||||
E_FUNC int argc_value; /* count of argv[] strings for argv() builtin */
|
||||
E_FUNC char **argv_value; /* argv[] strings for argv() builtin */
|
||||
|
||||
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 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 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 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 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 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 */
|
||||
E_FUNC char *program; /* our name (argv[0]) */
|
||||
|
||||
extern DLL int no_env; /* TRUE (-e) => ignore env vars on startup */
|
||||
extern DLL long errmax; /* if >= 0, error when errcount exceeds errmax */
|
||||
extern DLL int use_old_std; /* TRUE (-O) => use classic configuration */
|
||||
E_FUNC int no_env; /* TRUE (-e) => ignore env vars on startup */
|
||||
EXTERN long errmax; /* if >= 0, error when errcount exceeds errmax */
|
||||
E_FUNC int use_old_std; /* TRUE (-O) => use classic configuration */
|
||||
|
||||
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 */
|
||||
EXTERN int allow_read; /* FALSE => dont open any files for reading */
|
||||
EXTERN int allow_write; /* FALSE => dont open any files for writing */
|
||||
EXTERN int allow_exec; /* FALSE => may not execute any commands */
|
||||
|
||||
/*
|
||||
* calc startup and run state
|
||||
@@ -253,19 +253,19 @@ typedef enum {
|
||||
RUN_EXIT, /* normal exit from calc */
|
||||
RUN_EXIT_WITH_ERROR /* exit with error */
|
||||
} run;
|
||||
extern DLL run run_state;
|
||||
extern DLL char *run_state_name(run state);
|
||||
EXTERN run run_state;
|
||||
E_FUNC char *run_state_name(run state);
|
||||
|
||||
/*
|
||||
* calc version information
|
||||
*/
|
||||
#define CALC_TITLE "C-style arbitrary precision calculator"
|
||||
extern int calc_major_ver;
|
||||
extern int calc_minor_ver;
|
||||
extern int calc_major_patch;
|
||||
extern int calc_minor_patch;
|
||||
extern char *Copyright;
|
||||
extern DLL char *version(void);
|
||||
EXTERN int calc_major_ver;
|
||||
EXTERN int calc_minor_ver;
|
||||
EXTERN int calc_major_patch;
|
||||
EXTERN int calc_minor_patch;
|
||||
EXTERN char *Copyright;
|
||||
E_FUNC char *version(void);
|
||||
|
||||
|
||||
#endif /* !__CALC_H__ */
|
||||
|
8
calc.man
8
calc.man
@@ -1,5 +1,5 @@
|
||||
.\"
|
||||
.\" Copyright (C) 1999-2004 Landon Curt Noll
|
||||
.\" Copyright (C) 1999-2007 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
|
||||
@@ -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.20 $
|
||||
.\" @(#) $Id: calc.man,v 29.20 2006/06/01 12:04:16 chongo Exp $
|
||||
.\" @(#) $Revision: 29.21 $
|
||||
.\" @(#) $Id: calc.man,v 29.21 2007/02/07 00:38:43 chongo Exp $
|
||||
.\" @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.man,v $
|
||||
.\"
|
||||
.\" Under source code control: 1991/07/23 05:48:26
|
||||
@@ -28,7 +28,7 @@
|
||||
.\" calculator by David I. Bell
|
||||
.\" man page by Landon Noll
|
||||
.\"
|
||||
.TH calc 1 "^..^" "1999-11-30"
|
||||
.TH calc 1 "^..^" "2007-02-06"
|
||||
.SH NAME
|
||||
calc \- arbitrary precision calculator
|
||||
.SH SYNOPSIS
|
||||
|
@@ -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.9 $
|
||||
# @(#) $Id: calcerr.tbl,v 29.9 2006/06/25 20:33:26 chongo Exp $
|
||||
# @(#) $Revision: 29.10 $
|
||||
# @(#) $Id: calcerr.tbl,v 29.10 2006/08/20 15:01:30 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr.tbl,v $
|
||||
#
|
||||
# Under source code control: 1996/05/23 17:38:44
|
||||
@@ -445,3 +445,7 @@ E_FPATHOPEN1 Non-string arguments for fpathopen
|
||||
E_FPATHOPEN2 Unrecognized mode for fpathopen
|
||||
E_LOG1 Bad epsilon argument for log
|
||||
E_LOG2 Non-numeric first argument for log
|
||||
E_FGETFILE1 Non-file argument for fgetfile
|
||||
E_FGETFILE2 File argument for fgetfile not open for reading
|
||||
E_FGETFILE3 Unable to set file position in fgetfile
|
||||
E_ESTR Non-representable type for estr
|
||||
|
@@ -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: check.awk,v 29.3 2006/05/20 19:43:39 chongo Exp $
|
||||
# @(#) $Revision: 29.5 $
|
||||
# @(#) $Id: check.awk,v 29.5 2006/09/18 08:01:13 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/check.awk,v $
|
||||
#
|
||||
# Under source code control: 1996/05/25 22:07:58
|
||||
@@ -64,7 +64,7 @@ NF == 0 {
|
||||
end_seen = 1;
|
||||
}
|
||||
|
||||
$1 ~ /^[0-9]+:/ || $1 ~ /^[0-9]+-[0-9]*:/ {
|
||||
$1 ~ /^[0-9]+:/ || $1 ~ /^[0-9]+-[0-9]*:/ || $1 ~ /^"\)\)$/ {
|
||||
if (error > 0) {
|
||||
if (havebuf2) {
|
||||
print buf2;
|
||||
|
114
cmath.h
114
cmath.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* cmath - data structures for extended precision complex arithmetic
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* 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
|
||||
@@ -52,84 +52,84 @@ typedef struct {
|
||||
/*
|
||||
* Input, output, and conversion routines.
|
||||
*/
|
||||
extern COMPLEX *comalloc(void);
|
||||
extern COMPLEX *qqtoc(NUMBER *q1, NUMBER *q2);
|
||||
extern void comfree(COMPLEX *c);
|
||||
extern void comprint(COMPLEX *c);
|
||||
extern void cprintfr(COMPLEX *c);
|
||||
E_FUNC COMPLEX *comalloc(void);
|
||||
E_FUNC COMPLEX *qqtoc(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC void comfree(COMPLEX *c);
|
||||
E_FUNC void comprint(COMPLEX *c);
|
||||
E_FUNC void cprintfr(COMPLEX *c);
|
||||
|
||||
|
||||
/*
|
||||
* Basic numeric routines.
|
||||
*/
|
||||
|
||||
extern COMPLEX *c_add(COMPLEX *c1, COMPLEX *c2);
|
||||
extern COMPLEX *c_sub(COMPLEX *c1, COMPLEX *c2);
|
||||
extern COMPLEX *c_mul(COMPLEX *c1, COMPLEX *c2);
|
||||
extern COMPLEX *c_div(COMPLEX *c1, COMPLEX *c2);
|
||||
extern COMPLEX *c_addq(COMPLEX *c, NUMBER *q);
|
||||
extern COMPLEX *c_subq(COMPLEX *c, NUMBER *q);
|
||||
extern COMPLEX *c_mulq(COMPLEX *c, NUMBER *q);
|
||||
extern COMPLEX *c_divq(COMPLEX *c, NUMBER *q);
|
||||
extern COMPLEX *c_scale(COMPLEX *c, long i);
|
||||
extern COMPLEX *c_shift(COMPLEX *c, long i);
|
||||
extern COMPLEX *c_square(COMPLEX *c);
|
||||
extern COMPLEX *c_conj(COMPLEX *c);
|
||||
extern COMPLEX *c_real(COMPLEX *c);
|
||||
extern COMPLEX *c_imag(COMPLEX *c);
|
||||
extern COMPLEX *c_neg(COMPLEX *c);
|
||||
extern COMPLEX *c_inv(COMPLEX *c);
|
||||
extern COMPLEX *c_int(COMPLEX *c);
|
||||
extern COMPLEX *c_frac(COMPLEX *c);
|
||||
extern BOOL c_cmp(COMPLEX *c1, COMPLEX *c2);
|
||||
E_FUNC COMPLEX *c_add(COMPLEX *c1, COMPLEX *c2);
|
||||
E_FUNC COMPLEX *c_sub(COMPLEX *c1, COMPLEX *c2);
|
||||
E_FUNC COMPLEX *c_mul(COMPLEX *c1, COMPLEX *c2);
|
||||
E_FUNC COMPLEX *c_div(COMPLEX *c1, COMPLEX *c2);
|
||||
E_FUNC COMPLEX *c_addq(COMPLEX *c, NUMBER *q);
|
||||
E_FUNC COMPLEX *c_subq(COMPLEX *c, NUMBER *q);
|
||||
E_FUNC COMPLEX *c_mulq(COMPLEX *c, NUMBER *q);
|
||||
E_FUNC COMPLEX *c_divq(COMPLEX *c, NUMBER *q);
|
||||
E_FUNC COMPLEX *c_scale(COMPLEX *c, long i);
|
||||
E_FUNC COMPLEX *c_shift(COMPLEX *c, long i);
|
||||
E_FUNC COMPLEX *c_square(COMPLEX *c);
|
||||
E_FUNC COMPLEX *c_conj(COMPLEX *c);
|
||||
E_FUNC COMPLEX *c_real(COMPLEX *c);
|
||||
E_FUNC COMPLEX *c_imag(COMPLEX *c);
|
||||
E_FUNC COMPLEX *c_neg(COMPLEX *c);
|
||||
E_FUNC COMPLEX *c_inv(COMPLEX *c);
|
||||
E_FUNC COMPLEX *c_int(COMPLEX *c);
|
||||
E_FUNC COMPLEX *c_frac(COMPLEX *c);
|
||||
E_FUNC BOOL c_cmp(COMPLEX *c1, COMPLEX *c2);
|
||||
|
||||
|
||||
/*
|
||||
* More complicated functions.
|
||||
*/
|
||||
extern COMPLEX *c_powi(COMPLEX *c, NUMBER *q);
|
||||
extern NUMBER *c_ilog(COMPLEX *c, ZVALUE base);
|
||||
E_FUNC COMPLEX *c_powi(COMPLEX *c, NUMBER *q);
|
||||
E_FUNC NUMBER *c_ilog(COMPLEX *c, ZVALUE base);
|
||||
|
||||
|
||||
/*
|
||||
* Transcendental routines. These all take an epsilon argument to
|
||||
* specify how accurately these are to be calculated.
|
||||
*/
|
||||
extern COMPLEX *c_power(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon);
|
||||
extern COMPLEX *c_sqrt(COMPLEX *c, NUMBER *epsilon, long R);
|
||||
extern COMPLEX *c_root(COMPLEX *c, NUMBER *q, NUMBER *epsilon);
|
||||
extern COMPLEX *c_exp(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_ln(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_log(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_cos(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_sin(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_cosh(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_sinh(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_polar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
extern COMPLEX *c_rel(COMPLEX *c1, COMPLEX *c2);
|
||||
extern COMPLEX *c_asin(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_acos(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_atan(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_acot(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_asec(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_acsc(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_asinh(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_acosh(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_atanh(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_acoth(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_asech(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_acsch(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_gd(COMPLEX *c, NUMBER *epsilon);
|
||||
extern COMPLEX *c_agd(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_power(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_sqrt(COMPLEX *c, NUMBER *epsilon, long R);
|
||||
E_FUNC COMPLEX *c_root(COMPLEX *c, NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_exp(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_ln(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_log(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_cos(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_sin(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_cosh(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_sinh(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_polar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_rel(COMPLEX *c1, COMPLEX *c2);
|
||||
E_FUNC COMPLEX *c_asin(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_acos(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_atan(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_acot(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_asec(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_acsc(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_asinh(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_acosh(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_atanh(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_acoth(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_asech(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_acsch(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_gd(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_agd(COMPLEX *c, NUMBER *epsilon);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* external functions
|
||||
*/
|
||||
extern COMPLEX *swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
||||
extern COMPLEX *swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
||||
extern COMPLEX *swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
||||
E_FUNC COMPLEX *swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
||||
E_FUNC COMPLEX *swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
||||
E_FUNC COMPLEX *swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
||||
|
||||
|
||||
/*
|
||||
@@ -153,7 +153,7 @@ extern COMPLEX *swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all);
|
||||
/*
|
||||
* Pre-defined values.
|
||||
*/
|
||||
extern COMPLEX _czero_, _cone_, _conei_;
|
||||
EXTERN COMPLEX _czero_, _cone_, _conei_;
|
||||
|
||||
|
||||
#endif /* !__CMATH_H__ */
|
||||
|
189
codegen.c
189
codegen.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* codegen - module to generate opcodes from the input tokens
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2007 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -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.21 $
|
||||
* @(#) $Id: codegen.c,v 29.21 2006/06/20 10:28:06 chongo Exp $
|
||||
* @(#) $Revision: 29.23 $
|
||||
* @(#) $Id: codegen.c,v 29.23 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/codegen.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:13
|
||||
@@ -49,61 +49,61 @@
|
||||
# include <direct.h>
|
||||
#endif
|
||||
|
||||
static BOOL rdonce; /* TRUE => do not reread this file */
|
||||
STATIC BOOL rdonce; /* TRUE => do not reread this file */
|
||||
|
||||
FUNC *curfunc;
|
||||
|
||||
static int getsymvalue(char *name, VALUE *v_p);
|
||||
static int getfilename(char *name, size_t namelen, BOOL *once);
|
||||
static BOOL getid(char *buf);
|
||||
static void getshowstatement(void);
|
||||
static void getfunction(void);
|
||||
static void ungetfunction(void);
|
||||
static void getbody(LABEL *contlabel, LABEL *breaklabel,
|
||||
S_FUNC int getsymvalue(char *name, VALUE *v_p);
|
||||
S_FUNC int getfilename(char *name, size_t namelen, BOOL *once);
|
||||
S_FUNC BOOL getid(char *buf);
|
||||
S_FUNC void getshowstatement(void);
|
||||
S_FUNC void getfunction(void);
|
||||
S_FUNC void ungetfunction(void);
|
||||
S_FUNC void getbody(LABEL *contlabel, LABEL *breaklabel,
|
||||
LABEL *nextcaselabel, LABEL *defaultlabel);
|
||||
static int getdeclarations(int symtype);
|
||||
static int getsimpledeclaration (int symtype);
|
||||
static int getonevariable (int symtype);
|
||||
static void getstatement(LABEL *contlabel, LABEL *breaklabel,
|
||||
S_FUNC int getdeclarations(int symtype);
|
||||
S_FUNC int getsimpledeclaration (int symtype);
|
||||
S_FUNC int getonevariable (int symtype);
|
||||
S_FUNC void getstatement(LABEL *contlabel, LABEL *breaklabel,
|
||||
LABEL *nextcaselabel, LABEL *defaultlabel);
|
||||
static void getobjdeclaration(int symtype);
|
||||
static void getoneobj(long index, int symtype);
|
||||
static void getobjvars(char *name, int symtype);
|
||||
static void getmatdeclaration(int symtype);
|
||||
static void getonematrix(int symtype);
|
||||
static void creatematrix(void);
|
||||
static void getsimplebody(void);
|
||||
static void getcondition(void);
|
||||
static void getmatargs(void);
|
||||
static void getelement(void);
|
||||
static void usesymbol(char *name, int autodef);
|
||||
static void definesymbol(char *name, int symtype);
|
||||
static void getcallargs(char *name);
|
||||
static void do_changedir(void);
|
||||
static int getexprlist(void);
|
||||
static int getopassignment(void);
|
||||
static int getassignment(void);
|
||||
static int getaltcond(void);
|
||||
static int getorcond(void);
|
||||
static int getandcond(void);
|
||||
static int getrelation(void);
|
||||
static int getsum(void);
|
||||
static int getproduct(void);
|
||||
static int getorexpr(void);
|
||||
static int getandexpr(void);
|
||||
static int getshiftexpr(void);
|
||||
static int getreference(void);
|
||||
static int getincdecexpr(void);
|
||||
static int getterm(void);
|
||||
static int getidexpr(BOOL okmat, int autodef);
|
||||
static long getinitlist(void);
|
||||
S_FUNC void getobjdeclaration(int symtype);
|
||||
S_FUNC void getoneobj(long index, int symtype);
|
||||
S_FUNC void getobjvars(char *name, int symtype);
|
||||
S_FUNC void getmatdeclaration(int symtype);
|
||||
S_FUNC void getonematrix(int symtype);
|
||||
S_FUNC void creatematrix(void);
|
||||
S_FUNC void getsimplebody(void);
|
||||
S_FUNC void getcondition(void);
|
||||
S_FUNC void getmatargs(void);
|
||||
S_FUNC void getelement(void);
|
||||
S_FUNC void usesymbol(char *name, int autodef);
|
||||
S_FUNC void definesymbol(char *name, int symtype);
|
||||
S_FUNC void getcallargs(char *name);
|
||||
S_FUNC void do_changedir(void);
|
||||
S_FUNC int getexprlist(void);
|
||||
S_FUNC int getopassignment(void);
|
||||
S_FUNC int getassignment(void);
|
||||
S_FUNC int getaltcond(void);
|
||||
S_FUNC int getorcond(void);
|
||||
S_FUNC int getandcond(void);
|
||||
S_FUNC int getrelation(void);
|
||||
S_FUNC int getsum(void);
|
||||
S_FUNC int getproduct(void);
|
||||
S_FUNC int getorexpr(void);
|
||||
S_FUNC int getandexpr(void);
|
||||
S_FUNC int getshiftexpr(void);
|
||||
S_FUNC int getreference(void);
|
||||
S_FUNC int getincdecexpr(void);
|
||||
S_FUNC int getterm(void);
|
||||
S_FUNC int getidexpr(BOOL okmat, int autodef);
|
||||
S_FUNC long getinitlist(void);
|
||||
|
||||
#define INDICALLOC 8
|
||||
|
||||
static int quickindices[INDICALLOC];
|
||||
static int * newindices;
|
||||
static int * indices;
|
||||
static int maxindices;
|
||||
STATIC int quickindices[INDICALLOC];
|
||||
STATIC int * newindices;
|
||||
STATIC int * indices;
|
||||
STATIC int maxindices;
|
||||
|
||||
|
||||
/*
|
||||
@@ -144,6 +144,7 @@ getcommands(BOOL toplevel)
|
||||
case T_HELP:
|
||||
for (i=1;;i++) {
|
||||
switch(getfilename(name, MAXCMD+1, NULL)) {
|
||||
case 1:
|
||||
case -1:
|
||||
if(i == 1) {
|
||||
strcpy(name, DEFAULTCALCHELP);
|
||||
@@ -288,7 +289,7 @@ evaluate(BOOL nestflag)
|
||||
/*
|
||||
* Undefine one or more functions
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
ungetfunction(void)
|
||||
{
|
||||
char *name;
|
||||
@@ -339,7 +340,7 @@ ungetfunction(void)
|
||||
* func = name '(' '' | name [ ',' name] ... ')' simplebody
|
||||
* | name '(' '' | name [ ',' name] ... ')' body.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getfunction(void)
|
||||
{
|
||||
char *name; /* parameter name */
|
||||
@@ -428,7 +429,7 @@ getfunction(void)
|
||||
* Get a simple assignment style body for a function declaration.
|
||||
* simplebody = '=' assignment '\n'.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getsimplebody(void)
|
||||
{
|
||||
(void) tokenmode(TM_NEWLINES);
|
||||
@@ -443,7 +444,7 @@ getsimplebody(void)
|
||||
* | [ declarations ] ... [statement ] ... '\n'
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getbody(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaultlabel)
|
||||
{
|
||||
int oldmode;
|
||||
@@ -473,7 +474,7 @@ getbody(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaul
|
||||
* declarations = { LOCAL | GLOBAL | STATIC } onedeclaration
|
||||
* [ ',' onedeclaration ] ... ';'.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getdeclarations(int symtype)
|
||||
{
|
||||
int res = 0;
|
||||
@@ -525,7 +526,7 @@ getdeclarations(int symtype)
|
||||
* Subsequences end with "," or at end of line; spaces indicate
|
||||
* repeated assignment, e.g. "c d = 2" has the effect of "c = 2, d = 2".
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getsimpledeclaration(int symtype)
|
||||
{
|
||||
int res = 0;
|
||||
@@ -553,9 +554,9 @@ getsimpledeclaration(int symtype)
|
||||
* Get one variable in a sequence of simple identifiers.
|
||||
* Returns 1 if the subsequence in which the variable occurs ends with
|
||||
* an assignment, e.g. for the variables b, c, d, in
|
||||
* static a, b = 1, c d = 2, d;
|
||||
* S_FUNC a, b = 1, c d = 2, d;
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getonevariable(int symtype)
|
||||
{
|
||||
char *name;
|
||||
@@ -607,7 +608,7 @@ getonevariable(int symtype)
|
||||
* nextcaselabel label for next case statement
|
||||
* defaultlabel label for default case
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaultlabel)
|
||||
{
|
||||
LABEL label;
|
||||
@@ -1058,7 +1059,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
|
||||
* is an OBJ statement, otherwise this is part of a declaration which will
|
||||
* define new symbols with the specified type.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getobjdeclaration(int symtype)
|
||||
{
|
||||
char *name; /* name of object type */
|
||||
@@ -1164,7 +1165,7 @@ getobjdeclaration(int symtype)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
getoneobj(long index, int symtype)
|
||||
{
|
||||
char *symname;
|
||||
@@ -1191,7 +1192,7 @@ getoneobj(long index, int symtype)
|
||||
|
||||
/*
|
||||
* Routine to assign a specified object-type value to each of a set of
|
||||
* variables in a "global", "local" or "static" declaration, or, if
|
||||
* variables in a "global", "local" or "S_FUNC" declaration, or, if
|
||||
* symtype is SYM_UNDEFINED, to create one object value of the specified
|
||||
* type.
|
||||
*
|
||||
@@ -1199,7 +1200,7 @@ getoneobj(long index, int symtype)
|
||||
* name object name
|
||||
* symtype declaration type
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getobjvars(char *name, int symtype)
|
||||
{
|
||||
long index; /* index for object */
|
||||
@@ -1223,7 +1224,7 @@ getobjvars(char *name, int symtype)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
getmatdeclaration(int symtype)
|
||||
{
|
||||
for (;;) {
|
||||
@@ -1243,7 +1244,7 @@ getmatdeclaration(int symtype)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
getonematrix(int symtype)
|
||||
{
|
||||
long dim;
|
||||
@@ -1339,7 +1340,7 @@ getonematrix(int symtype)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
creatematrix(void)
|
||||
{
|
||||
long dim;
|
||||
@@ -1397,7 +1398,7 @@ creatematrix(void)
|
||||
* Returns the number of elements that are in the list, or -1 on parse error.
|
||||
* initlist = { assignment [ , assignment ] ... }.
|
||||
*/
|
||||
static long
|
||||
S_FUNC long
|
||||
getinitlist(void)
|
||||
{
|
||||
long index;
|
||||
@@ -1453,7 +1454,7 @@ getinitlist(void)
|
||||
* Get a condition.
|
||||
* condition = '(' assignment ')'.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getcondition(void)
|
||||
{
|
||||
if (gettoken() != T_LEFTPAREN) {
|
||||
@@ -1477,7 +1478,7 @@ getcondition(void)
|
||||
* Returns flags describing the type of the last assignment or expression found.
|
||||
* exprlist = assignment [ ',' assignment ] ...
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getexprlist(void)
|
||||
{
|
||||
int type;
|
||||
@@ -1510,7 +1511,7 @@ getexprlist(void)
|
||||
* | lvalue '**=' assignment
|
||||
* | orcond.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getopassignment(void)
|
||||
{
|
||||
int type; /* type of expression */
|
||||
@@ -1586,7 +1587,7 @@ getopassignment(void)
|
||||
* Get an assignment (lvalue = ...) or possibly just an expression
|
||||
*/
|
||||
|
||||
static int
|
||||
S_FUNC int
|
||||
getassignment (void)
|
||||
{
|
||||
int type; /* type of expression */
|
||||
@@ -1656,7 +1657,7 @@ getassignment (void)
|
||||
* Flags are returned indicating the type of expression found.
|
||||
* altcond = orcond [ '?' orcond ':' altcond ].
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getaltcond(void)
|
||||
{
|
||||
int type; /* type of expression */
|
||||
@@ -1690,7 +1691,7 @@ getaltcond(void)
|
||||
* Flags are returned indicating the type of expression found.
|
||||
* orcond = andcond [ '||' andcond ] ...
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getorcond(void)
|
||||
{
|
||||
int type; /* type of expression */
|
||||
@@ -1714,7 +1715,7 @@ getorcond(void)
|
||||
* Flags are returned indicating the type of expression found.
|
||||
* andcond = relation [ '&&' relation ] ...
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getandcond(void)
|
||||
{
|
||||
int type; /* type of expression */
|
||||
@@ -1744,7 +1745,7 @@ getandcond(void)
|
||||
* | sum '>' sum
|
||||
* | sum.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getrelation(void)
|
||||
{
|
||||
int type; /* type of expression */
|
||||
@@ -1775,7 +1776,7 @@ getrelation(void)
|
||||
* Flags indicating the type of expression found are returned.
|
||||
* sum = product [ {'+' | '-'} product ] ...
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getsum(void)
|
||||
{
|
||||
int type; /* type of expression found */
|
||||
@@ -1818,7 +1819,7 @@ getsum(void)
|
||||
* Flags indicating the type of expression found are returned.
|
||||
* product = orexpr [ {'*' | '/' | '//' | '%'} orexpr ] ...
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getproduct(void)
|
||||
{
|
||||
int type; /* type of value found */
|
||||
@@ -1849,7 +1850,7 @@ getproduct(void)
|
||||
* Flags indicating the type of expression found are returned.
|
||||
* orexpr = andexpr [ '|' andexpr ] ...
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getorexpr(void)
|
||||
{
|
||||
int type; /* type of value found */
|
||||
@@ -1872,7 +1873,7 @@ getorexpr(void)
|
||||
* Flags indicating the type of expression found are returned.
|
||||
* andexpr = shiftexpr [ '&' shiftexpr ] ...
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getandexpr(void)
|
||||
{
|
||||
int type; /* type of value found */
|
||||
@@ -1911,7 +1912,7 @@ getandexpr(void)
|
||||
* | reference '>>' shiftexpr
|
||||
* | reference.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getshiftexpr(void)
|
||||
{
|
||||
int type; /* type of value found */
|
||||
@@ -1955,7 +1956,7 @@ getshiftexpr(void)
|
||||
* address = '&' term
|
||||
* dereference = '*' term
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getreference(void)
|
||||
{
|
||||
int type;
|
||||
@@ -1992,7 +1993,7 @@ getreference(void)
|
||||
* get an increment or decrement expression
|
||||
* ++expr, --expr, expr++, expr--
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getincdecexpr(void)
|
||||
{
|
||||
int type;
|
||||
@@ -2050,7 +2051,7 @@ getincdecexpr(void)
|
||||
* | function [ '(' [assignment [',' assignment] ] ')' ]
|
||||
* | '!' term
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getterm(void)
|
||||
{
|
||||
int type; /* type of term found */
|
||||
@@ -2210,7 +2211,7 @@ getterm(void)
|
||||
* element references. The symbol can be a global or a local variable name.
|
||||
* Returns the type of expression found.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getidexpr(BOOL okmat, int autodef)
|
||||
{
|
||||
int type;
|
||||
@@ -2285,7 +2286,7 @@ getidexpr(BOOL okmat, int autodef)
|
||||
* to get the value of a symbol. It should NOT be used in the
|
||||
* general op code generation / calc code parsing case.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getsymvalue(char *name, VALUE *v_p)
|
||||
{
|
||||
GLOBAL *g_ret; /* global return from findglobal() */
|
||||
@@ -2318,7 +2319,7 @@ getsymvalue(char *name, VALUE *v_p)
|
||||
* namelen length of filename buffer including NUL byte
|
||||
* once non-NULL => set to TRUE of -once read
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
getfilename(char *name, size_t namelen, BOOL *once)
|
||||
{
|
||||
STRING *s;
|
||||
@@ -2400,7 +2401,7 @@ getfilename(char *name, size_t namelen, BOOL *once)
|
||||
/*
|
||||
* Read the show command to display useful information
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getshowstatement(void)
|
||||
{
|
||||
char name[5];
|
||||
@@ -2471,7 +2472,7 @@ getshowstatement(void)
|
||||
* Read in a set of matrix index arguments, surrounded with square brackets.
|
||||
* This also handles double square brackets for 'fast indexing'.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getmatargs(void)
|
||||
{
|
||||
int dim;
|
||||
@@ -2533,7 +2534,7 @@ getmatargs(void)
|
||||
* Get an element of an object reference.
|
||||
* The leading period which introduces the element has already been read.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getelement(void)
|
||||
{
|
||||
long index;
|
||||
@@ -2554,7 +2555,7 @@ getelement(void)
|
||||
* Read in a single symbol name and copy its value into the given buffer.
|
||||
* Returns TRUE if a valid symbol id was found.
|
||||
*/
|
||||
static BOOL
|
||||
S_FUNC BOOL
|
||||
getid(char *buf)
|
||||
{
|
||||
int type;
|
||||
@@ -2586,7 +2587,7 @@ getid(char *buf)
|
||||
* redeclared and when in the same body the variable will be accessible only
|
||||
^ with the appropriate specfier.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
definesymbol(char *name, int symtype)
|
||||
{
|
||||
switch (symboltype(name)) {
|
||||
@@ -2649,7 +2650,7 @@ definesymbol(char *name, int symtype)
|
||||
* autodef 1 => define if symbol is not known
|
||||
* T_GLOBAL => get global, define if necessary
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
usesymbol(char *name, int autodef)
|
||||
{
|
||||
int type;
|
||||
@@ -2706,7 +2707,7 @@ usesymbol(char *name, int autodef)
|
||||
* given:
|
||||
* name name of function
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getcallargs(char *name)
|
||||
{
|
||||
long index; /* function index */
|
||||
@@ -2775,7 +2776,7 @@ getcallargs(char *name)
|
||||
/*
|
||||
* Change the current directory. If no directory is given, assume home.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
do_changedir(void)
|
||||
{
|
||||
char *p;
|
||||
|
14
comfunc.c
14
comfunc.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* comfunc - extended precision complex arithmetic non-primitive routines
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell and Ernest Bowen
|
||||
* Copyright (C) 1999-2007 David I. Bell and Ernest Bowen
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -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: comfunc.c,v 29.6 2006/05/20 08:43:55 chongo Exp $
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: comfunc.c,v 29.7 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/comfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:13
|
||||
@@ -36,10 +36,10 @@
|
||||
/*
|
||||
* cache the natural logarithm of 10
|
||||
*/
|
||||
static COMPLEX *cln_10 = NULL;
|
||||
static NUMBER *cln_10_epsilon = NULL;
|
||||
static NUMBER _q10_ = { { _tenval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL };
|
||||
static NUMBER _q0_ = { { _zeroval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL };
|
||||
STATIC COMPLEX *cln_10 = NULL;
|
||||
STATIC NUMBER *cln_10_epsilon = NULL;
|
||||
STATIC NUMBER _q10_ = { { _tenval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL };
|
||||
STATIC NUMBER _q0_ = { { _zeroval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL };
|
||||
COMPLEX _cten_ = { &_q10_, &_q0_, 1 };
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* commath - extended precision complex arithmetic primitive routines
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: commath.c,v 29.4 2005/10/18 10:43:49 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: commath.c,v 29.5 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/commath.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:10
|
||||
@@ -35,7 +35,7 @@ COMPLEX _czero_ = { &_qzero_, &_qzero_, 1 };
|
||||
COMPLEX _cone_ = { &_qone_, &_qzero_, 1 };
|
||||
COMPLEX _conei_ = { &_qzero_, &_qone_, 1 };
|
||||
|
||||
static COMPLEX _cnegone_ = { &_qnegone_, &_qzero_, 1 };
|
||||
STATIC COMPLEX _cnegone_ = { &_qnegone_, &_qzero_, 1 };
|
||||
|
||||
|
||||
/*
|
||||
|
64
config.c
64
config.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* config - configuration routines
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell and Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -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.22 $
|
||||
* @(#) $Id: config.c,v 29.22 2006/06/25 22:05:38 chongo Exp $
|
||||
* @(#) $Revision: 29.24 $
|
||||
* @(#) $Id: config.c,v 29.24 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
|
||||
*
|
||||
* Under source code control: 1991/07/20 00:21:56
|
||||
@@ -31,6 +31,24 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "have_times.h"
|
||||
#if defined(HAVE_TIME_H)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_TIMES_H)
|
||||
#include <times.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SYS_TIMES_H)
|
||||
#include <sys/times.h>
|
||||
#endif
|
||||
|
||||
#include "calc.h"
|
||||
#include "token.h"
|
||||
#include "zrand.h"
|
||||
@@ -45,6 +63,15 @@
|
||||
# define strdup(x) calc_strdup((CONST char *)(x))
|
||||
#endif /* HAVE_STRDUP */
|
||||
|
||||
/*
|
||||
* deal with systems that lack a defined CLK_TCK
|
||||
*/
|
||||
#if defined(CLK_TCK)
|
||||
# define CALC_HZ ((long)(CLK_TCK))
|
||||
#else
|
||||
# define CALC_HZ (0L) /* no defined clock tick rate */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Table of configuration types that can be set or read.
|
||||
@@ -100,6 +127,7 @@ NAMETYPE configs[] = {
|
||||
{"baseb", CONFIG_BASEB},
|
||||
{"redecl_warn", CONFIG_REDECL_WARN},
|
||||
{"dupvar_warn", CONFIG_DUPVAR_WARN},
|
||||
{"hz", CONFIG_HZ},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
@@ -233,7 +261,7 @@ CONFIG *conf = NULL; /* loaded in at startup - current configuration */
|
||||
/*
|
||||
* Possible output modes.
|
||||
*/
|
||||
static NAMETYPE modes[] = {
|
||||
STATIC NAMETYPE modes[] = {
|
||||
{"fraction", MODE_FRAC},
|
||||
{"frac", MODE_FRAC},
|
||||
{"integer", MODE_INT},
|
||||
@@ -258,7 +286,7 @@ static NAMETYPE modes[] = {
|
||||
/*
|
||||
* Possible block base output modes
|
||||
*/
|
||||
static NAMETYPE blk_base[] = {
|
||||
STATIC NAMETYPE blk_base[] = {
|
||||
{"hexadecimal", BLK_BASE_HEX},
|
||||
{"hex", BLK_BASE_HEX},
|
||||
{"default", BLK_BASE_HEX},
|
||||
@@ -277,7 +305,7 @@ static NAMETYPE blk_base[] = {
|
||||
/*
|
||||
* Possible block output formats
|
||||
*/
|
||||
static NAMETYPE blk_fmt[] = {
|
||||
STATIC NAMETYPE blk_fmt[] = {
|
||||
{"lines", BLK_FMT_LINE},
|
||||
{"line", BLK_FMT_LINE},
|
||||
{"strings", BLK_FMT_STRING},
|
||||
@@ -297,7 +325,7 @@ static NAMETYPE blk_fmt[] = {
|
||||
/*
|
||||
* Possible ctrl_d styles
|
||||
*/
|
||||
static NAMETYPE ctrl_d[] = {
|
||||
STATIC NAMETYPE ctrl_d[] = {
|
||||
{"virgin_eof", CTRL_D_VIRGIN_EOF},
|
||||
{"virgineof", CTRL_D_VIRGIN_EOF},
|
||||
{"virgin", CTRL_D_VIRGIN_EOF},
|
||||
@@ -317,7 +345,7 @@ static NAMETYPE ctrl_d[] = {
|
||||
*/
|
||||
#define TRUE_STRING "true"
|
||||
#define FALSE_STRING "false"
|
||||
static NAMETYPE truth[] = {
|
||||
STATIC NAMETYPE truth[] = {
|
||||
{TRUE_STRING, TRUE},
|
||||
{"t", TRUE},
|
||||
{"on", TRUE},
|
||||
@@ -339,9 +367,9 @@ static NAMETYPE truth[] = {
|
||||
/*
|
||||
* declare static functions
|
||||
*/
|
||||
static long lookup_long(NAMETYPE *set, char *name);
|
||||
static char *lookup_name(NAMETYPE *set, long val);
|
||||
static int getlen(VALUE *vp, LEN *lp);
|
||||
S_FUNC long lookup_long(NAMETYPE *set, char *name);
|
||||
S_FUNC char *lookup_name(NAMETYPE *set, long val);
|
||||
S_FUNC int getlen(VALUE *vp, LEN *lp);
|
||||
|
||||
|
||||
/*
|
||||
@@ -375,7 +403,7 @@ configtype(char *name)
|
||||
* returns:
|
||||
* numeric value of the name or -1 if not found
|
||||
*/
|
||||
static long
|
||||
S_FUNC long
|
||||
lookup_long(NAMETYPE *set, char *name)
|
||||
{
|
||||
NAMETYPE *cp; /* current config pointer */
|
||||
@@ -398,7 +426,7 @@ lookup_long(NAMETYPE *set, char *name)
|
||||
* returns:
|
||||
* name of the value found of NULL
|
||||
*/
|
||||
static char *
|
||||
S_FUNC char *
|
||||
lookup_name(NAMETYPE *set, long val)
|
||||
{
|
||||
NAMETYPE *cp; /* current config pointer */
|
||||
@@ -418,7 +446,7 @@ lookup_name(NAMETYPE *set, long val)
|
||||
* Return: 1 ==> not an integer, 2 ==> int > 2^31, 0 ==> OK, -1 ==> error
|
||||
*/
|
||||
|
||||
static int
|
||||
S_FUNC int
|
||||
getlen(VALUE *vp, LEN *lp)
|
||||
{
|
||||
if (vp->v_type != V_NUM || !qisint(vp->v_num))
|
||||
@@ -941,6 +969,10 @@ setconfig(int type, VALUE *vp)
|
||||
}
|
||||
break;
|
||||
|
||||
case CONFIG_HZ:
|
||||
math_error("The clock tick rate config parameter is read-only");
|
||||
/*NOTREACHED*/
|
||||
|
||||
default:
|
||||
math_error("Setting illegal config parameter");
|
||||
/*NOTREACHED*/
|
||||
@@ -1330,6 +1362,10 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
||||
i = (cfg->dupvar_warn ? 1 : 0);
|
||||
break;
|
||||
|
||||
case CONFIG_HZ:
|
||||
i = CALC_HZ;
|
||||
break;
|
||||
|
||||
default:
|
||||
math_error("Getting illegal CONFIG element");
|
||||
/*NOTREACHED*/
|
||||
|
35
config.h
35
config.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* config - configuration routines
|
||||
*
|
||||
* Copyright (C) 1999-2004 Landon Curt Noll and David I. Bell
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll and David I. Bell
|
||||
*
|
||||
* Primary author: Landon Curt Noll
|
||||
*
|
||||
@@ -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.20 $
|
||||
* @(#) $Id: config.h,v 29.20 2006/06/25 22:05:38 chongo Exp $
|
||||
* @(#) $Revision: 29.22 $
|
||||
* @(#) $Id: config.h,v 29.22 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.h,v $
|
||||
*
|
||||
* Under source code control: 1995/11/01 22:20:17
|
||||
@@ -36,11 +36,11 @@
|
||||
|
||||
|
||||
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
||||
# include "win32dll.h"
|
||||
# include "decl.h"
|
||||
# include "nametype.h"
|
||||
# include "qmath.h"
|
||||
#else
|
||||
# include <calc/win32dll.h>
|
||||
# include <calc/decl.h>
|
||||
# include <calc/nametype.h>
|
||||
# include <calc/qmath.h>
|
||||
#endif
|
||||
@@ -97,6 +97,7 @@
|
||||
#define CONFIG_BASEB 43
|
||||
#define CONFIG_REDECL_WARN 44
|
||||
#define CONFIG_DUPVAR_WARN 45
|
||||
#define CONFIG_HZ 46
|
||||
|
||||
|
||||
/*
|
||||
@@ -205,23 +206,23 @@ typedef struct config CONFIG;
|
||||
/*
|
||||
* global configuration states and aliases
|
||||
*/
|
||||
extern DLL CONFIG *conf; /* current configuration */
|
||||
extern DLL CONFIG oldstd; /* old classic standard configuration */
|
||||
extern DLL CONFIG newstd; /* default 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") */
|
||||
EXTERN CONFIG *conf; /* current configuration */
|
||||
EXTERN CONFIG oldstd; /* old classic standard configuration */
|
||||
EXTERN CONFIG newstd; /* default compatible configuration */
|
||||
E_FUNC char *calc_debug; /* !=NULL => value of config("calc_debug") */
|
||||
E_FUNC char *resource_debug; /* !=NULL => config("resource_debug") value */
|
||||
E_FUNC char *user_debug; /* !=NULL => value of config("user_debug") */
|
||||
|
||||
|
||||
/*
|
||||
* configuration externals
|
||||
*/
|
||||
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*);
|
||||
E_FUNC CONFIG *config_copy(CONFIG *src);
|
||||
E_FUNC void config_free(CONFIG *cfg);
|
||||
E_FUNC void config_print(CONFIG *cfg);
|
||||
E_FUNC int configtype(char*);
|
||||
E_FUNC void config_print(CONFIG*);
|
||||
E_FUNC BOOL config_cmp(CONFIG*, CONFIG*);
|
||||
|
||||
|
||||
#endif /* !__CONFIG_H__ */
|
||||
|
12
const.c
12
const.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* const - constant number storage module
|
||||
*
|
||||
* Copyright (C) 1999-2004 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: const.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: const.c,v 29.5 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/const.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:14
|
||||
@@ -34,9 +34,9 @@
|
||||
|
||||
#define CONSTALLOCSIZE 400 /* number of constants to allocate */
|
||||
|
||||
static unsigned long constcount;/* number of constants defined */
|
||||
static long constavail; /* number of constants available */
|
||||
static NUMBER **consttable; /* table of constants */
|
||||
STATIC unsigned long constcount;/* number of constants defined */
|
||||
STATIC long constavail; /* number of constants available */
|
||||
STATIC NUMBER **consttable; /* table of constants */
|
||||
|
||||
|
||||
void
|
||||
|
@@ -26,8 +26,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: 1.3 $
|
||||
* @(#) $Id: 4dsphere.calc,v 1.3 2001/06/06 09:06:29 chongo Exp $
|
||||
* @(#) $Revision: 1.5 $
|
||||
* @(#) $Id: 4dsphere.calc,v 1.5 2007/02/11 10:05:56 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/4dsphere.calc,v $
|
||||
*
|
||||
* Under source code control: 2001/05/03 19:02:03
|
||||
|
225
cscript/Makefile
225
cscript/Makefile
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# cscript - makefile for calc shell script files
|
||||
#
|
||||
# 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
|
||||
@@ -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.24 $
|
||||
# @(#) $Id: Makefile,v 29.24 2006/06/26 05:46:06 chongo Exp $
|
||||
# @(#) $Revision: 29.32 $
|
||||
# @(#) $Id: Makefile,v 29.32 2007/02/08 21:21:25 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1999/11/29 11:10:26
|
||||
@@ -34,7 +34,7 @@
|
||||
# required vars
|
||||
#
|
||||
SHELL= /bin/sh
|
||||
MAKE_FILE = Makefile
|
||||
MAKE_FILE= Makefile
|
||||
|
||||
####
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
@@ -62,9 +62,9 @@ INCDIR= /usr/include
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
# NOTE: The install rule prepends installation paths with ${T}, which
|
||||
# by default is empty. If ${T} is non-empty, then installation
|
||||
# locations will be relative to the ${T} directory.
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
@@ -96,12 +96,12 @@ CALC_SHAREDIR= /usr/share/calc
|
||||
# ${CALC_INCDIR} where the calc include files are installed
|
||||
# ${CUSTOMCALDIR} where custom *.cal files are installed
|
||||
# ${CUSTOMHELPDIR} where custom help files are installed
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed
|
||||
# ${CUSTOMINCDIR} where custom .h files are installed
|
||||
# ${SCRIPTDIR} where calc shell scripts are installed
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
# NOTE: The install rule prepends installation paths with ${T}, which
|
||||
# by default is empty. If ${T} is non-empty, then installation
|
||||
# locations will be relative to the ${T} directory.
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
@@ -121,8 +121,8 @@ SCRIPTDIR= ${BINDIR}/cscript
|
||||
|
||||
# T - top level directory under which calc will be installed
|
||||
#
|
||||
# The calc install is performed under $T, the calc build is
|
||||
# performed under /. The purpose for $T is to allow someone
|
||||
# The calc install is performed under ${T}, the calc build is
|
||||
# performed under /. The purpose for ${T} is to allow someone
|
||||
# to install calc somewhere other than into the system area.
|
||||
#
|
||||
# For example, if:
|
||||
@@ -142,10 +142,10 @@ SCRIPTDIR= ${BINDIR}/cscript
|
||||
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
# ... etc ... /var/tmp/testing/...
|
||||
#
|
||||
# If $T is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If $T is non-empty, then
|
||||
# calc is installed under $T, as if one had to chroot under
|
||||
# $T for calc to operate.
|
||||
# If ${T} is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If ${T} is non-empty, then
|
||||
# calc is installed under ${T}, as if one had to chroot under
|
||||
# ${T} for calc to operate.
|
||||
#
|
||||
# If in doubt, use T=
|
||||
#
|
||||
@@ -166,6 +166,14 @@ SED= sed
|
||||
SORT= sort
|
||||
FMT= fmt
|
||||
CMP= cmp
|
||||
MKDIR= mkdir
|
||||
RMDIR= rmdir
|
||||
RM= rm
|
||||
TOUCH= touch
|
||||
MV= mv
|
||||
CP= cp
|
||||
CO= co
|
||||
TRUE= true
|
||||
|
||||
# The ${SCRIPT} list is the list of calc shell script files (without the .calc
|
||||
# extension) which will be installed.
|
||||
@@ -191,7 +199,7 @@ SCRIPT_SRC= 4dsphere.calc fproduct.calc mersenne.calc \
|
||||
|
||||
# These files are found (but not built) in the distribution
|
||||
#
|
||||
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README
|
||||
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README.src
|
||||
|
||||
# These files are used to make (but not build) a calc .a library
|
||||
#
|
||||
@@ -199,24 +207,28 @@ CALCLIBLIST=
|
||||
|
||||
# complete list of targets
|
||||
#
|
||||
# NOTE: This list MUST be co-ordinated with the ${CSCRIPT_TARGETS} variable
|
||||
# NOTE: This list MUST be coordinated with the ${CSCRIPT_TARGETS} variable
|
||||
# in the upper level ../Makefile
|
||||
#
|
||||
CSCRIPT_TARGETS= ${SCRIPT}
|
||||
TARGETS= ${CSCRIPT_TARGETS}
|
||||
TARGETS= ${CSCRIPT_TARGETS} README
|
||||
|
||||
# The reason for this Makefile
|
||||
#
|
||||
all: ${TARGETS} .all
|
||||
|
||||
README: README.src
|
||||
@${RM} -f $@
|
||||
@${SED} -e "s:#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
|
||||
# used by the upper level Makefile to determine if we have done all
|
||||
#
|
||||
# NOTE: Due to bogus shells found on one common system we must have
|
||||
# a non-empty else clause for every if condition. *sigh*
|
||||
#
|
||||
.all:
|
||||
rm -f .all
|
||||
touch .all
|
||||
${RM} -f .all
|
||||
${TOUCH} .all
|
||||
|
||||
##
|
||||
#
|
||||
@@ -229,21 +241,22 @@ all: ${TARGETS} .all
|
||||
##
|
||||
|
||||
distlist: ${DISTLIST}
|
||||
${Q}for i in ${DISTLIST} /dev/null; do \
|
||||
${Q} for i in ${DISTLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo cscript/$$i; \
|
||||
fi; \
|
||||
done | LANG=C ${SORT}
|
||||
|
||||
distdir:
|
||||
${Q}echo cscript
|
||||
${Q} echo cscript
|
||||
|
||||
calcliblist:
|
||||
|
||||
# These next rule help me form the ${DETAIL_HELP} makefile variables above.
|
||||
# These next rule help me form the ${SCRIPT} and ${SCRIPT_SRC} makefile
|
||||
# variables above.
|
||||
#
|
||||
detaillist:
|
||||
${Q}-(echo "xxxxxxx"; \
|
||||
${Q} -(echo "xxxxxxx"; \
|
||||
for i in ${SCRIPT} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
if [ ! -f RCS/$$i.calc,v ]; then \
|
||||
@@ -255,9 +268,9 @@ detaillist:
|
||||
done | LANG=C ${SORT}) | ${FMT} -70 | \
|
||||
${SED} -e '1s/xxxxxxx/SCRIPT=/' -e '2,$$s/^/ /' \
|
||||
-e 's/$$/ \\/' -e '$$s/ \\$$//'
|
||||
${Q}echo
|
||||
${Q}-(echo "xxxxxxxxxxx"; \
|
||||
for i in ${SCRIPT} /dev/null; do \
|
||||
${Q} echo
|
||||
${Q} -(echo "xxxxxxxxxxx"; \
|
||||
for i in ${SCRIPT} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
if [ ! -f RCS/$$i.calc,v ]; then \
|
||||
echo "WARNING: $$i.calc not under RCS control" 1>&2; \
|
||||
@@ -282,46 +295,46 @@ detaillist:
|
||||
##
|
||||
|
||||
depend:
|
||||
${Q}if [ -f Makefile.bak ]; then \
|
||||
echo "Makefile.bak exists, remove or move it out of the way"; \
|
||||
exit 1; \
|
||||
${Q} if [ -f Makefile.bak ]; then \
|
||||
echo "Makefile.bak exists, remove or move it out of the way"; \
|
||||
exit 1; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}rm -f makedep.out
|
||||
${Q}echo forming cscript dependency list
|
||||
${Q}echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > \
|
||||
-${Q} ${RM} -f makedep.out
|
||||
${Q} echo forming cscript dependency list
|
||||
${Q} echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > \
|
||||
makedep.out
|
||||
${Q}echo "" >> makedep.out
|
||||
${Q}for i in ${SCRIPT} /dev/null; do \
|
||||
${Q} echo "" >> makedep.out
|
||||
${Q} for i in ${SCRIPT} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo "$$i: $$i.calc"; \
|
||||
echo ' @rm -f $$@'; \
|
||||
echo ' @$${RM} -f $$@'; \
|
||||
echo ' @$${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!$${BINDIR}/calc:" $$?>$$@'; \
|
||||
echo ' @$${CHMOD} +x $$@'; \
|
||||
fi; \
|
||||
done >> makedep.out
|
||||
${Q}echo sample dependency list formed
|
||||
${Q}echo forming new cscript/Makefile
|
||||
-${Q}rm -f Makefile.bak
|
||||
${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' makedep.out >> Makefile
|
||||
-${Q}rm -f makedep.out
|
||||
-${Q}if ${CMP} -s Makefile.bak Makefile; then \
|
||||
echo 'sample Makefile was already up to date'; \
|
||||
mv -f Makefile.bak Makefile; \
|
||||
${Q} echo sample dependency list formed
|
||||
${Q} echo forming new cscript/Makefile
|
||||
-${Q} ${RM} -f Makefile.bak
|
||||
${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' makedep.out >> Makefile
|
||||
-${Q} ${RM} -f makedep.out
|
||||
-${Q} if ${CMP} -s Makefile.bak Makefile; then \
|
||||
echo 'sample Makefile was already up to date'; \
|
||||
${MV} -f Makefile.bak Makefile; \
|
||||
else \
|
||||
rm -f Makefile.tmp; \
|
||||
mv Makefile Makefile.tmp; \
|
||||
if [ -d RCS ]; then \
|
||||
co -l Makefile; \
|
||||
fi; \
|
||||
mv Makefile.tmp Makefile; \
|
||||
if [ -d RCS ]; then \
|
||||
echo new sample Makefile formed, you need to check it in; \
|
||||
fi; \
|
||||
${RM} -f Makefile.tmp; \
|
||||
${MV} Makefile Makefile.tmp; \
|
||||
if [ -d RCS ]; then \
|
||||
${CO} -l Makefile; \
|
||||
fi; \
|
||||
${MV} Makefile.tmp Makefile; \
|
||||
if [ -d RCS ]; then \
|
||||
echo new sample Makefile formed, you need to check it in; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
##
|
||||
@@ -331,7 +344,7 @@ depend:
|
||||
##
|
||||
|
||||
echo_inst_files:
|
||||
${Q}for i in ${SCRIPT} /dev/null; do \
|
||||
${Q} for i in ${SCRIPT} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${SCRIPTDIR}/$$i; \
|
||||
fi; \
|
||||
@@ -344,52 +357,52 @@ echo_inst_files:
|
||||
##
|
||||
|
||||
clean:
|
||||
-rm -f makedep.out
|
||||
-${RM} -f makedep.out
|
||||
|
||||
clobber:
|
||||
-rm -f ${TARGETS}
|
||||
-${RM} -f ${TARGETS}
|
||||
|
||||
# install everything
|
||||
#
|
||||
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||
#
|
||||
install: all
|
||||
-${Q}if [ ! -d $T${BINDIR} ]; then \
|
||||
echo mkdir $T${BINDIR}; \
|
||||
mkdir $T${BINDIR}; \
|
||||
if [ ! -d "$T${BINDIR}" ]; then \
|
||||
echo mkdir -p "$T${BINDIR}"; \
|
||||
mkdir -p "$T${BINDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${BINDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${BINDIR}; \
|
||||
${MKDIR} ${T}${BINDIR}; \
|
||||
if [ ! -d "${T}${BINDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${BINDIR}"; \
|
||||
${MKDIR} -p "${T}${BINDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${BINDIR}; \
|
||||
${CHMOD} 0755 $T${BINDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${BINDIR}; \
|
||||
${CHMOD} 0755 ${T}${BINDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${SCRIPTDIR} ]; then \
|
||||
echo mkdir $T${SCRIPTDIR}; \
|
||||
mkdir $T${SCRIPTDIR}; \
|
||||
if [ ! -d "$T${SCRIPTDIR}" ]; then \
|
||||
echo mkdir -p "$T${SCRIPTDIR}"; \
|
||||
mkdir -p "$T${SCRIPTDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${SCRIPTDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${SCRIPTDIR}; \
|
||||
${MKDIR} ${T}${SCRIPTDIR}; \
|
||||
if [ ! -d "${T}${SCRIPTDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${SCRIPTDIR}"; \
|
||||
${MKDIR} -p "${T}${SCRIPTDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${SCRIPTDIR}; \
|
||||
${CHMOD} 0755 $T${SCRIPTDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${SCRIPTDIR}; \
|
||||
${CHMOD} 0755 ${T}${SCRIPTDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
${Q}for i in ${SCRIPT} /dev/null; do \
|
||||
${Q} for i in ${SCRIPT} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s $$i $T${SCRIPTDIR}/$$i; then \
|
||||
true; \
|
||||
if ${CMP} -s $$i ${T}${SCRIPTDIR}/$$i; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
rm -f $T${SCRIPTDIR}/$$i.new; \
|
||||
cp -f $$i $T${SCRIPTDIR}/$$i.new; \
|
||||
${CHMOD} 0555 $T${SCRIPTDIR}/$$i.new; \
|
||||
mv -f $T${SCRIPTDIR}/$$i.new $T${SCRIPTDIR}/$$i; \
|
||||
echo "installed $T${SCRIPTDIR}/$$i"; \
|
||||
${RM} -f ${T}${SCRIPTDIR}/$$i.new; \
|
||||
${CP} -f $$i ${T}${SCRIPTDIR}/$$i.new; \
|
||||
${CHMOD} 0755 ${T}${SCRIPTDIR}/$$i.new; \
|
||||
${MV} -f ${T}${SCRIPTDIR}/$$i.new ${T}${SCRIPTDIR}/$$i; \
|
||||
echo "installed ${T}${SCRIPTDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
@@ -398,57 +411,57 @@ install: all
|
||||
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||
#
|
||||
uninstall:
|
||||
-${Q}for i in ${SCRIPT} /dev/null; do \
|
||||
-${Q} for i in ${SCRIPT} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if [ -f "$T${SCRIPTDIR}/$$i" ]; then \
|
||||
rm -f "$T${SCRIPTDIR}/$$i"; \
|
||||
if [ -f "$T${SCRIPTDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall $T${SCRIPTDIR}/$$i"; \
|
||||
if [ -f "${T}${SCRIPTDIR}/$$i" ]; then \
|
||||
${RM} -f "${T}${SCRIPTDIR}/$$i"; \
|
||||
if [ -f "${T}${SCRIPTDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall ${T}${SCRIPTDIR}/$$i"; \
|
||||
else \
|
||||
echo "uninstalled $T${SCRIPTDIR}/$$i"; \
|
||||
echo "uninstalled ${T}${SCRIPTDIR}/$$i"; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${SCRIPTDIR} ${BINDIR}; do \
|
||||
if [ -d "$T$$i" ]; then \
|
||||
rmdir "$T$$i" 2>/dev/null; \
|
||||
echo "cleaned up $T$$i"; \
|
||||
-${Q} for i in ${SCRIPTDIR} ${BINDIR}; do \
|
||||
if [ -d "${T}$$i" ]; then \
|
||||
${RMDIR} "${T}$$i" 2>/dev/null; \
|
||||
echo "cleaned up ${T}$$i"; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
4dsphere: 4dsphere.calc
|
||||
@rm -f $@
|
||||
@${RM} -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
fproduct: fproduct.calc
|
||||
@rm -f $@
|
||||
@${RM} -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
mersenne: mersenne.calc
|
||||
@rm -f $@
|
||||
@${RM} -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
piforever: piforever.calc
|
||||
@rm -f $@
|
||||
@${RM} -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
plus: plus.calc
|
||||
@rm -f $@
|
||||
@${RM} -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
powerterm: powerterm.calc
|
||||
@rm -f $@
|
||||
@${RM} -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
simple: simple.calc
|
||||
@rm -f $@
|
||||
@${RM} -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
square: square.calc
|
||||
@rm -f $@
|
||||
@${RM} -f $@
|
||||
@${SED} -e "1s:^#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||
@${CHMOD} +x $@
|
||||
|
@@ -5,6 +5,46 @@ These calc shell scripts are provided because they serve as examples of
|
||||
how use the calc language, and/or because the authors thought them to
|
||||
be useful!
|
||||
|
||||
Please note that calc shell scripts must start with the line:
|
||||
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
|
||||
The above line MUST start in column 1 of the first line. The first line
|
||||
must also end in -f. The -q is optional, but is recommended to disable
|
||||
the processing of calc startup scripts.
|
||||
|
||||
Also please note that single # shell line comments are not supported in calc.
|
||||
Comments must be /* c-like comment */ or start with a double ## symbol.
|
||||
|
||||
This is the correct way to form a calc shell script:
|
||||
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
|
||||
/* a correct comment */
|
||||
## another correct comment
|
||||
### two or more together is also a comment
|
||||
/*
|
||||
* another correct comment
|
||||
*/
|
||||
print "2+2 =", 2+2; ## yet another comment
|
||||
|
||||
The first argument after the path to calc executable must be an -S.
|
||||
The next arguments are optional. The -q is often recommended because
|
||||
it will disable the processing of the startup scripts.
|
||||
|
||||
For more informaton about calc command lines, see "help usage".
|
||||
|
||||
This next example WRONG:
|
||||
|
||||
#!/usr/local/src/cmd/calc/calc -q
|
||||
|
||||
# This is not a calc calc comment because it has only a single #
|
||||
# You must to start comments with ## or /*
|
||||
# is is also wrong because the first line does not end in -f
|
||||
print "This example has invalid comments"
|
||||
|
||||
#####
|
||||
|
||||
If you write something that you think is useful, please send it to:
|
||||
|
||||
calc-contrib at asthe dot com
|
||||
@@ -77,9 +117,9 @@ 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.10 $
|
||||
## @(#) $Id: README,v 29.10 2001/06/10 19:34:40 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/README,v $
|
||||
## @(#) $Revision: 29.11 $
|
||||
## @(#) $Id: README.src,v 29.11 2007/02/07 00:33:10 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/README.src,v $
|
||||
##
|
||||
## Under source code control: 1999/12/17 10:23:40
|
||||
## File existed as early as: 1999
|
@@ -24,8 +24,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: fproduct.calc,v 29.2 2001/06/06 09:06:29 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: fproduct.calc,v 29.4 2007/02/11 10:05:56 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/fproduct.calc,v $
|
||||
*
|
||||
* Under source code control: 2001/04/07 20:13:11
|
||||
|
@@ -1,35 +1,36 @@
|
||||
#!/usr/local/src/cmd/calc/calc -q -s -f
|
||||
#
|
||||
# mersenne - print the value of a mersenne number
|
||||
#
|
||||
# Copyright (C) 1999 Landon Curt Noll
|
||||
#
|
||||
# Calc is open software; you can redistribute it and/or modify it under
|
||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
# Public License for more details.
|
||||
#
|
||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: mersenne.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/mersenne.calc,v $
|
||||
#
|
||||
# Under source code control: 1999/11/30 00:09:01;
|
||||
# File existed as early as: 1999
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
# usage:
|
||||
# mersenne exp
|
||||
/*
|
||||
* mersenne - print the value of a mersenne number
|
||||
*
|
||||
* Copyright (C) 1999-2007 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: mersenne.calc,v 29.5 2007/02/11 10:05:56 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/mersenne.calc,v $
|
||||
*
|
||||
* Under source code control: 1999/11/30 00:09:01;
|
||||
* File existed as early as: 1999
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*
|
||||
* usage:
|
||||
* mersenne exp
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -1,35 +1,36 @@
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
#
|
||||
# piforever - print digits of pi forever (or as long as your mem/cpu allow)
|
||||
#
|
||||
# Copyright (C) 1999 Landon Curt Noll
|
||||
#
|
||||
# Calc is open software; you can redistribute it and/or modify it under
|
||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
# Public License for more details.
|
||||
#
|
||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: piforever.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/piforever.calc,v $
|
||||
#
|
||||
# Under source code control: 1999/11/30 00:11:36
|
||||
# File existed as early as: 1999
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
# usage:
|
||||
# piforever
|
||||
/*
|
||||
* piforever - print digits of pi forever (or as long as your mem/cpu allow)
|
||||
*
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: piforever.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/piforever.calc,v $
|
||||
*
|
||||
* Under source code control: 1999/11/30 00:11:36
|
||||
* File existed as early as: 1999
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*
|
||||
* usage:
|
||||
* piforever
|
||||
*/
|
||||
|
||||
|
||||
read -once pi.cal
|
||||
|
@@ -1,35 +1,36 @@
|
||||
#!/usr/local/src/cmd/calc/calc -q -s -f
|
||||
#
|
||||
# plus - add two or more arguments together
|
||||
#
|
||||
# Copyright (C) 1999 Landon Curt Noll
|
||||
#
|
||||
# Calc is open software; you can redistribute it and/or modify it under
|
||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
# Public License for more details.
|
||||
#
|
||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: plus.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/plus.calc,v $
|
||||
#
|
||||
# Under source code control: 1999/11/29 10:22:37
|
||||
# File existed as early as: 1999
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
|
||||
# usage:
|
||||
# plus val ...
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
/*
|
||||
* plus - add two or more arguments together
|
||||
*
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: plus.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/plus.calc,v $
|
||||
*
|
||||
* Under source code control: 1999/11/29 10:22:37
|
||||
* File existed as early as: 1999
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*
|
||||
* usage:
|
||||
* plus val ...
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -24,8 +24,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: powerterm.calc,v 29.6 2001/06/06 09:06:29 chongo Exp $
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: powerterm.calc,v 29.8 2007/02/11 10:05:56 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/powerterm.calc,v $
|
||||
*
|
||||
* Under source code control: 2001/04/24 23:49:11
|
||||
|
@@ -1,32 +1,33 @@
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
#
|
||||
# simple - an example of a simple calc shell script
|
||||
#
|
||||
# Copyright (C) 1999 Landon Curt Noll
|
||||
#
|
||||
# Calc is open software; you can redistribute it and/or modify it under
|
||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
# Public License for more details.
|
||||
#
|
||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: simple.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/simple.calc,v $
|
||||
#
|
||||
# Under source code control: 1999/11/29 10:22:37
|
||||
# File existed as early as: 1999
|
||||
#
|
||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
/*
|
||||
* simple - an example of a simple calc shell script
|
||||
*
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: simple.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/simple.calc,v $
|
||||
*
|
||||
* Under source code control: 1999/11/29 10:22:37
|
||||
* File existed as early as: 1999
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -1,64 +1,67 @@
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
#
|
||||
# sqaure - print the squares of input values
|
||||
#
|
||||
# Copyright (C) 2000 Ernest Bowen
|
||||
#
|
||||
# Calc is open software; you can redistribute it and/or modify it under
|
||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
# Public License for more details.
|
||||
#
|
||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: square.calc,v 29.3 2000/12/17 14:31:58 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/square.calc,v $
|
||||
#
|
||||
# Under source code control: 2000/12/15 06:52:01
|
||||
# File existed as early as: 2000
|
||||
#
|
||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
/*
|
||||
* sqaure - print the squares of input values
|
||||
*
|
||||
* Copyright (C) 2000-2007 Ernest Bowen
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: square.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/square.calc,v $
|
||||
*
|
||||
* Under source code control: 2000/12/15 06:52:01
|
||||
* File existed as early as: 2000
|
||||
*
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* Usage:
|
||||
*
|
||||
* From the shell:
|
||||
*
|
||||
* ./square
|
||||
* cat file | ./square
|
||||
* echo "123" | ./square
|
||||
*
|
||||
* Within calc:
|
||||
*
|
||||
* > read square
|
||||
*
|
||||
* With input from a terminal, there is no prompt but each non-empty
|
||||
* line of input is evaluated as a calc expression and if it can be
|
||||
* calculated, the square of the value of that expression is displayed.
|
||||
* Execution stops when an empty line is input.
|
||||
*
|
||||
* From the shell:
|
||||
*
|
||||
* ./square
|
||||
*
|
||||
* The following shows lines of input followed by output:
|
||||
*
|
||||
* 1234
|
||||
* 1522756
|
||||
* ln(2)
|
||||
* ~.48045301391820142467
|
||||
* config("mode","frac"), bernoulli(10)
|
||||
* 25/4356
|
||||
* config("mode", "hex"), 0xff
|
||||
* 0xfe01
|
||||
*/
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# From the shell:
|
||||
#
|
||||
# ./square
|
||||
# cat file | ./square
|
||||
# echo "123" | ./square
|
||||
#
|
||||
# Within calc:
|
||||
#
|
||||
# > read square
|
||||
#
|
||||
# With input from a terminal, there is no prompt but each non-empty
|
||||
# line of input is evaluated as a calc expression and if it can be
|
||||
# calculated, the square of the value of that expression is displayed.
|
||||
# Execution stops when an empty line is input.
|
||||
#
|
||||
# From the shell:
|
||||
#
|
||||
# ./square
|
||||
#
|
||||
# The following shows lines of input followed by output:
|
||||
#
|
||||
# 1234
|
||||
# 1522756
|
||||
# ln(2)
|
||||
# ~.48045301391820142467
|
||||
# config("mode","frac"), bernoulli(10)
|
||||
# 25/4356
|
||||
# config("mode", "hex"), 0xff
|
||||
# 0xfe01
|
||||
#
|
||||
|
||||
global s;
|
||||
while ((s = prompt("")))
|
||||
|
16
custom.h
16
custom.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* custom - interface for custom software and hardware interfaces
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: custom.h,v 29.3 2004/02/25 23:54:40 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: custom.h,v 29.4 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/custom.h,v $
|
||||
*
|
||||
* Under source code control: 1997/03/03 04:53:08
|
||||
@@ -71,10 +71,10 @@ struct custom {
|
||||
*
|
||||
* These are the required interfaces. The dummy.c stubs these interfaces too.
|
||||
*/
|
||||
extern VALUE custom(char*, int, VALUE**); /* master custom interface */
|
||||
extern BOOL allow_custom; /* TRUE => custom builtins allowed */
|
||||
extern void showcustom(void); /* print custom functions */
|
||||
extern void customhelp(char *); /* direct custom help */
|
||||
extern CONST struct custom cust[]; /* custom interface table */
|
||||
E_FUNC VALUE custom(char*, int, VALUE**); /* master custom interface */
|
||||
EXTERN BOOL allow_custom; /* TRUE => custom builtins allowed */
|
||||
E_FUNC void showcustom(void); /* print custom functions */
|
||||
E_FUNC void customhelp(char *); /* direct custom help */
|
||||
EXTERN CONST struct custom cust[]; /* custom interface table */
|
||||
|
||||
#endif /* !CUSTOM_H */
|
||||
|
@@ -480,18 +480,18 @@ Step 6: Register the function in the custom interface table
|
||||
*
|
||||
* Declare custom functions as follows:
|
||||
*
|
||||
* extern VALUE c_xyz(char*, int, VALUE**);
|
||||
* E_FUNC VALUE c_xyz(char*, int, VALUE**);
|
||||
*
|
||||
* We suggest that you sort the entries below by name.
|
||||
*/
|
||||
extern VALUE c_argv(char*, int, VALUE**);
|
||||
extern VALUE c_devnull(char*, int, VALUE**);
|
||||
extern VALUE c_help(char*, int, VALUE**);
|
||||
extern VALUE c_sysinfo(char*, int, VALUE**);
|
||||
E_FUNC VALUE c_argv(char*, int, VALUE**);
|
||||
E_FUNC VALUE c_devnull(char*, int, VALUE**);
|
||||
E_FUNC VALUE c_help(char*, int, VALUE**);
|
||||
E_FUNC VALUE c_sysinfo(char*, int, VALUE**);
|
||||
|
||||
For u_curds we would add the line:
|
||||
|
||||
extern VALUE u_curds(char*, int, VALUE**);
|
||||
E_FUNC VALUE u_curds(char*, int, VALUE**);
|
||||
|
||||
|
||||
Step 7: Add the required information to the custom/Makefile
|
||||
@@ -631,7 +631,7 @@ Step 12: Contribute
|
||||
and consider submitting your custom function for possible
|
||||
inclusion in later versions of calc.
|
||||
|
||||
## Copyright (C) 1999-2004 Landon Curt Noll
|
||||
## Copyright (C) 1999-2007 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
|
||||
@@ -647,8 +647,8 @@ Step 12: Contribute
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.5 $
|
||||
## @(#) $Id: HOW_TO_ADD,v 29.5 2005/10/18 11:18:34 chongo Exp $
|
||||
## @(#) $Revision: 29.6 $
|
||||
## @(#) $Id: HOW_TO_ADD,v 29.6 2007/02/11 10:22:46 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/HOW_TO_ADD,v $
|
||||
##
|
||||
## Under source code control: 1997/03/10 03:03:21
|
||||
|
469
custom/Makefile
469
custom/Makefile
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# custom - makefile for calc custom routines
|
||||
#
|
||||
# Copyright (C) 1999,2004 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
|
||||
@@ -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.25 $
|
||||
# @(#) $Id: Makefile,v 29.25 2006/06/26 05:46:06 chongo Exp $
|
||||
# @(#) $Revision: 29.30 $
|
||||
# @(#) $Id: Makefile,v 29.30 2007/02/11 10:22:29 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/03/09 02:28:54
|
||||
@@ -114,9 +114,9 @@ INCDIR= /usr/include
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
# NOTE: The install rule prepends installation paths with ${T}, which
|
||||
# by default is empty. If ${T} is non-empty, then installation
|
||||
# locations will be relative to the ${T} directory.
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
@@ -148,12 +148,12 @@ CALC_SHAREDIR= /usr/share/calc
|
||||
# ${CALC_INCDIR} where the calc include files are installed
|
||||
# ${CUSTOMCALDIR} where custom *.cal files are installed
|
||||
# ${CUSTOMHELPDIR} where custom help files are installed
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed
|
||||
# ${CUSTOMINCDIR} where custom .h files are installed
|
||||
# ${SCRIPTDIR} where calc shell scripts are installed
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
# NOTE: The install rule prepends installation paths with ${T}, which
|
||||
# by default is empty. If ${T} is non-empty, then installation
|
||||
# locations will be relative to the ${T} directory.
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
@@ -173,8 +173,8 @@ SCRIPTDIR= ${BINDIR}/cscript
|
||||
|
||||
# T - top level directory under which calc will be installed
|
||||
#
|
||||
# The calc install is performed under $T, the calc build is
|
||||
# performed under /. The purpose for $T is to allow someone
|
||||
# The calc install is performed under ${T}, the calc build is
|
||||
# performed under /. The purpose for ${T} is to allow someone
|
||||
# to install calc somewhere other than into the system area.
|
||||
#
|
||||
# For example, if:
|
||||
@@ -194,10 +194,10 @@ SCRIPTDIR= ${BINDIR}/cscript
|
||||
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
# ... etc ... /var/tmp/testing/...
|
||||
#
|
||||
# If $T is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If $T is non-empty, then
|
||||
# calc is installed under $T, as if one had to chroot under
|
||||
# $T for calc to operate.
|
||||
# If ${T} is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If ${T} is non-empty, then
|
||||
# calc is installed under ${T}, as if one had to chroot under
|
||||
# ${T} for calc to operate.
|
||||
#
|
||||
# If in doubt, use T=
|
||||
#
|
||||
@@ -249,6 +249,20 @@ NO_SHARED=
|
||||
#NO_SHARED= -dn
|
||||
#NO_SHARED= -non_shared
|
||||
|
||||
# On some systems where you are disabling dynamic shared link libs, you may
|
||||
# need to pass a special flag to ${CC} and ${LCC} during linking stage.
|
||||
#
|
||||
# System type NO_SHARED recommendation
|
||||
#
|
||||
# IRIX with NO_SHARED= -non_shared LD_NO_SHARED= -Wl,-rdata_shared
|
||||
# IRIX with NO_SHARED= LD_NO_SHARED=
|
||||
# others LD_NO_SHARED=
|
||||
#
|
||||
# If in doubt, use LD_NO_SHARED=
|
||||
#
|
||||
LD_NO_SHARED=
|
||||
#LD_NO_SHARED= -Wl,-rdata_shared
|
||||
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
#
|
||||
@@ -275,12 +289,13 @@ MAKE_FILE= Makefile
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
#
|
||||
# If you do not wish to use purify, leave PURIFY commented out.
|
||||
# If you do not wish to use purify, set PURIFY to an empty string.
|
||||
#
|
||||
# If in doubt, leave PURIFY commented out.
|
||||
# If in doubt, use PURIFY=
|
||||
#
|
||||
#PURIFY= purify -logfile=pure.out
|
||||
#PURIFY= purify
|
||||
PURIFY=
|
||||
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
@@ -402,6 +417,16 @@ MAKEDEPEND= makedepend
|
||||
CHMOD= chmod
|
||||
SORT= sort
|
||||
CMP= cmp
|
||||
AR= ar
|
||||
RM= rm
|
||||
TOUCH= touch
|
||||
MKDIR= mkdir
|
||||
RMDIR= rmdir
|
||||
MV= mv
|
||||
CP= cp
|
||||
CO= co
|
||||
TRUE= true
|
||||
MAKE= make
|
||||
|
||||
##
|
||||
#
|
||||
@@ -413,8 +438,8 @@ all: ${TARGETS} ${INSTALL_H_SRC} ${CUSTOM_CALC_FILES} \
|
||||
${CUSTOM_HELP} ${MAKE_FILE} .all
|
||||
|
||||
libcustcalc.a: ${CUSTCALC_OBJ} ${MAKE_FILE} ../${MAKE_FILE}
|
||||
-rm -f libcustcalc.a
|
||||
ar qc libcustcalc.a ${CUSTCALC_OBJ}
|
||||
-${RM} -f libcustcalc.a
|
||||
${AR} qc libcustcalc.a ${CUSTCALC_OBJ}
|
||||
${RANLIB} libcustcalc.a
|
||||
|
||||
##
|
||||
@@ -435,8 +460,8 @@ c_sysinfo.o: c_sysinfo.c ${MAKE_FILE}
|
||||
# to determine of we have done all
|
||||
#
|
||||
.all:
|
||||
rm -f .all
|
||||
touch .all
|
||||
${RM} -f .all
|
||||
${TOUCH} .all
|
||||
|
||||
##
|
||||
#
|
||||
@@ -452,17 +477,17 @@ c_sysinfo.o: c_sysinfo.c ${MAKE_FILE}
|
||||
##
|
||||
|
||||
distlist: ${DISTLIST}
|
||||
${Q}for i in ${DISTLIST} /dev/null; do \
|
||||
${Q} for i in ${DISTLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo custom/$$i; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
distdir:
|
||||
${Q}echo custom
|
||||
${Q} echo custom
|
||||
|
||||
calcliblist: ${CALCLIBLIST}
|
||||
${Q}for i in ${CALCLIBLIST} /dev/null; do \
|
||||
${Q} for i in ${CALCLIBLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo custom/$$i; \
|
||||
fi; \
|
||||
@@ -481,81 +506,81 @@ calcliblist: ${CALCLIBLIST}
|
||||
##
|
||||
|
||||
depend:
|
||||
${Q}if [ -f Makefile.bak ]; then \
|
||||
echo "Makefile.bak exists, remove or move it out of the way"; \
|
||||
exit 1; \
|
||||
${Q} if [ -f Makefile.bak ]; then \
|
||||
echo "Makefile.bak exists, remove or move it out of the way"; \
|
||||
exit 1; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
${Q}echo forming custom/skel
|
||||
-${Q}rm -rf skel
|
||||
${Q}mkdir skel
|
||||
${Q}mkdir skel/custom
|
||||
-${Q}for i in ${C_SRC} /dev/null; do \
|
||||
${Q} echo forming custom/skel
|
||||
-${Q} ${RM} -rf skel
|
||||
${Q} ${MKDIR} skel
|
||||
${Q} ${MKDIR} skel/custom
|
||||
-${Q} for i in ${C_SRC} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' \
|
||||
"$$i" > "skel/custom/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${H_SRC} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/custom/$$i"; \
|
||||
echo "#define $$tag" >> "skel/custom/$$i"; \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' "$$i" \
|
||||
>> "skel/custom/$$i"; \
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/custom/$$i"; \
|
||||
-${Q} for i in ${H_SRC} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/custom/$$i"; \
|
||||
echo "#define $$tag" >> "skel/custom/$$i"; \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' "$$i" \
|
||||
>> "skel/custom/$$i"; \
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/custom/$$i"; \
|
||||
done
|
||||
${Q}(cd ..; ${MAKE} hsrc)
|
||||
${Q}for i in `cd ..; ${MAKE} h_list 2>&1 | \
|
||||
${SED} -e '/Entering directory/d' \
|
||||
-e '/Nothing to be done/d' \
|
||||
-e '/Leaving directory/d'` /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/$$i"; \
|
||||
echo "#define $$tag" >> "skel/$$i"; \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' "../$$i" \
|
||||
>> "skel/$$i"; \
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/$$i"; \
|
||||
${Q} (cd ..; $(MAKE) hsrc)
|
||||
${Q} for i in `cd ..; $(MAKE) h_list 2>&1 | \
|
||||
${SED} -e '/Entering directory/d' \
|
||||
-e '/Nothing to be done/d' \
|
||||
-e '/Leaving directory/d'` /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/$$i"; \
|
||||
echo "#define $$tag" >> "skel/$$i"; \
|
||||
${SED} -n '/^#[ ]*include[ ]*"/p' "../$$i" \
|
||||
>> "skel/$$i"; \
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/$$i"; \
|
||||
done
|
||||
-${Q}rm -f skel/custom/makedep.out
|
||||
${Q}echo custom/skel formed
|
||||
${Q}echo forming custom dependency list
|
||||
${Q}echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > \
|
||||
-${Q} ${RM} -f skel/custom/makedep.out
|
||||
${Q} echo custom/skel formed
|
||||
${Q} echo forming custom dependency list
|
||||
${Q} echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > \
|
||||
skel/custom/makedep.out
|
||||
${Q}cd skel/custom; ${MAKEDEPEND} -w 1 -f makedep.out ${C_SRC}
|
||||
-${Q}for i in ${C_SRC} /dev/null; do \
|
||||
${Q} cd skel/custom; ${MAKEDEPEND} -w 1 -f makedep.out ${C_SRC}
|
||||
-${Q} for i in ${C_SRC} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo "$$i" | ${SED} 's/^\(.*\)\.c/\1.o: \1.c/'; \
|
||||
fi; \
|
||||
done >> skel/custom/makedep.out
|
||||
${Q}echo custom dependency list formed
|
||||
${Q}echo forming new custom/Makefile
|
||||
-${Q}rm -f Makefile.bak
|
||||
${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 | \
|
||||
${Q} echo custom dependency list formed
|
||||
${Q} echo forming new custom/Makefile
|
||||
-${Q} ${RM} -f Makefile.bak
|
||||
${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 | \
|
||||
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'; \
|
||||
mv -f Makefile.bak Makefile; \
|
||||
-${Q} ${RM} -rf skel
|
||||
-${Q} if ${CMP} -s Makefile.bak Makefile; then \
|
||||
echo 'custom Makefile was already up to date'; \
|
||||
${MV} -f Makefile.bak Makefile; \
|
||||
else \
|
||||
rm -f Makefile.tmp; \
|
||||
mv Makefile Makefile.tmp; \
|
||||
if [ -d RCS ]; then \
|
||||
co -l Makefile; \
|
||||
fi ;\
|
||||
mv Makefile.tmp Makefile; \
|
||||
if [ -d RCS ]; then \
|
||||
echo 'new custom Makefile formed -- you need to check it in'; \
|
||||
fi; \
|
||||
${RM} -f Makefile.tmp; \
|
||||
${MV} Makefile Makefile.tmp; \
|
||||
if [ -d RCS ]; then \
|
||||
${CO} -l Makefile; \
|
||||
fi ;\
|
||||
${MV} Makefile.tmp Makefile; \
|
||||
if [ -d RCS ]; then \
|
||||
echo 'new custom Makefile formed -- you need to check it in'; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
##
|
||||
@@ -565,22 +590,22 @@ depend:
|
||||
##
|
||||
|
||||
echo_inst_files:
|
||||
${Q}for i in ${INSTALL_H_SRC} /dev/null; do \
|
||||
${Q} for i in ${INSTALL_H_SRC} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${CUSTOMINCDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
${Q}for i in ${CUSTOM_HELP} /dev/null; do \
|
||||
${Q} for i in ${CUSTOM_HELP} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${CUSTOMHELPDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
${Q}for i in ${CUSTOM_CALC_FILES} /dev/null; do \
|
||||
${Q} for i in ${CUSTOM_CALC_FILES} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${CUSTOMCALDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
${Q}for i in ${CALC_LIBCUSTOM} /dev/null; do \
|
||||
${Q} for i in ${CALC_LIBCUSTOM} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${CUSTOMCALDIR}/$$i; \
|
||||
fi; \
|
||||
@@ -593,154 +618,154 @@ echo_inst_files:
|
||||
##
|
||||
|
||||
clean:
|
||||
-rm -f ${CUSTCALC_OBJ}
|
||||
-${RM} -f ${CUSTCALC_OBJ}
|
||||
|
||||
clobber:
|
||||
-rm -f ${TARGETS}
|
||||
rm -f .all Makefile.tmp Makefile.bak
|
||||
-${RM} -f ${TARGETS}
|
||||
${RM} -f .all Makefile.tmp Makefile.bak
|
||||
|
||||
# install everything
|
||||
#
|
||||
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||
#
|
||||
install: all
|
||||
-${Q}if [ ! -d $T${INCDIR} ]; then \
|
||||
echo mkdir $T${INCDIR}; \
|
||||
mkdir $T${INCDIR}; \
|
||||
if [ ! -d "$T${INCDIR}" ]; then \
|
||||
echo mkdir -p "$T${INCDIR}"; \
|
||||
mkdir -p "$T${INCDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${INCDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${INCDIR}; \
|
||||
${MKDIR} ${T}${INCDIR}; \
|
||||
if [ ! -d "${T}${INCDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${INCDIR}"; \
|
||||
${MKDIR} -p "${T}${INCDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${INCDIR}; \
|
||||
${CHMOD} 0755 $T${INCDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${INCDIR}; \
|
||||
${CHMOD} 0755 ${T}${INCDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${CALC_SHAREDIR} ]; then \
|
||||
echo mkdir $T${CALC_SHAREDIR}; \
|
||||
mkdir $T${CALC_SHAREDIR}; \
|
||||
if [ ! -d "$T${CALC_SHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${CALC_SHAREDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${CALC_SHAREDIR}; \
|
||||
${MKDIR} ${T}${CALC_SHAREDIR}; \
|
||||
if [ ! -d "${T}${CALC_SHAREDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
||||
${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
|
||||
${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${CALC_INCDIR} ]; then \
|
||||
echo mkdir $T${CALC_INCDIR}; \
|
||||
mkdir $T${CALC_INCDIR}; \
|
||||
if [ ! -d "$T${CALC_INCDIR}" ]; then \
|
||||
echo mkdir -p "$T${CALC_INCDIR}"; \
|
||||
mkdir -p "$T${CALC_INCDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${CALC_INCDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${CALC_INCDIR}; \
|
||||
${MKDIR} ${T}${CALC_INCDIR}; \
|
||||
if [ ! -d "${T}${CALC_INCDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${CALC_INCDIR}"; \
|
||||
${MKDIR} -p "${T}${CALC_INCDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CALC_INCDIR}; \
|
||||
${CHMOD} 0755 $T${CALC_INCDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${CALC_INCDIR}; \
|
||||
${CHMOD} 0755 ${T}${CALC_INCDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${HELPDIR} ]; then \
|
||||
echo mkdir $T${HELPDIR}; \
|
||||
mkdir $T${HELPDIR}; \
|
||||
if [ ! -d "$T${HELPDIR}" ]; then \
|
||||
echo mkdir -p "$T${HELPDIR}"; \
|
||||
mkdir -p "$T${HELPDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${HELPDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${HELPDIR}; \
|
||||
${MKDIR} ${T}${HELPDIR}; \
|
||||
if [ ! -d "${T}${HELPDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${HELPDIR}"; \
|
||||
${MKDIR} -p "${T}${HELPDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${HELPDIR}; \
|
||||
${CHMOD} 0755 $T${HELPDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${HELPDIR}; \
|
||||
${CHMOD} 0755 ${T}${HELPDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${CUSTOMCALDIR} ]; then \
|
||||
echo mkdir $T${CUSTOMCALDIR}; \
|
||||
mkdir $T${CUSTOMCALDIR}; \
|
||||
if [ ! -d "$T${CUSTOMCALDIR}" ]; then \
|
||||
echo mkdir -p "$T${CUSTOMCALDIR}"; \
|
||||
mkdir -p "$T${CUSTOMCALDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${CUSTOMCALDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${CUSTOMCALDIR}; \
|
||||
${MKDIR} ${T}${CUSTOMCALDIR}; \
|
||||
if [ ! -d "${T}${CUSTOMCALDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${CUSTOMCALDIR}"; \
|
||||
${MKDIR} -p "${T}${CUSTOMCALDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CUSTOMCALDIR}; \
|
||||
${CHMOD} 0755 $T${CUSTOMCALDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${CUSTOMCALDIR}; \
|
||||
${CHMOD} 0755 ${T}${CUSTOMCALDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${CUSTOMHELPDIR} ]; then \
|
||||
echo mkdir $T${CUSTOMHELPDIR}; \
|
||||
mkdir $T${CUSTOMHELPDIR}; \
|
||||
if [ ! -d "$T${CUSTOMHELPDIR}" ]; then \
|
||||
echo mkdir -p "$T${CUSTOMHELPDIR}"; \
|
||||
mkdir -p "$T${CUSTOMHELPDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${CUSTOMHELPDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${CUSTOMHELPDIR}; \
|
||||
${MKDIR} ${T}${CUSTOMHELPDIR}; \
|
||||
if [ ! -d "${T}${CUSTOMHELPDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${CUSTOMHELPDIR}"; \
|
||||
${MKDIR} -p "${T}${CUSTOMHELPDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CUSTOMHELPDIR}; \
|
||||
${CHMOD} 0755 $T${CUSTOMHELPDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${CUSTOMHELPDIR}; \
|
||||
${CHMOD} 0755 ${T}${CUSTOMHELPDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${CUSTOMINCDIR} ]; then \
|
||||
echo mkdir $T${CUSTOMINCDIR}; \
|
||||
mkdir $T${CUSTOMINCDIR}; \
|
||||
if [ ! -d "$T${CUSTOMINCDIR}" ]; then \
|
||||
echo mkdir -p "$T${CUSTOMINCDIR}"; \
|
||||
mkdir -p "$T${CUSTOMINCDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${CUSTOMINCDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${CUSTOMINCDIR}; \
|
||||
${MKDIR} ${T}${CUSTOMINCDIR}; \
|
||||
if [ ! -d "${T}${CUSTOMINCDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${CUSTOMINCDIR}"; \
|
||||
${MKDIR} -p "${T}${CUSTOMINCDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CUSTOMINCDIR}; \
|
||||
${CHMOD} 0755 $T${CUSTOMINCDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${CUSTOMINCDIR}; \
|
||||
${CHMOD} 0755 ${T}${CUSTOMINCDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}for i in ${INSTALL_H_SRC} /dev/null; do \
|
||||
-${Q} for i in ${INSTALL_H_SRC} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s "$$i" $T${CUSTOMINCDIR}/$$i; then \
|
||||
true; \
|
||||
if ${CMP} -s "$$i" ${T}${CUSTOMINCDIR}/$$i; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
rm -f $T${CUSTOMINCDIR}/$$i.new; \
|
||||
cp -f $$i $T${CUSTOMINCDIR}/$$i.new; \
|
||||
${CHMOD} 0444 $T${CUSTOMINCDIR}/$$i.new; \
|
||||
mv -f $T${CUSTOMINCDIR}/$$i.new $T${CUSTOMINCDIR}/$$i; \
|
||||
echo "installed $T${CUSTOMINCDIR}/$$i"; \
|
||||
${RM} -f ${T}${CUSTOMINCDIR}/$$i.new; \
|
||||
${CP} -f $$i ${T}${CUSTOMINCDIR}/$$i.new; \
|
||||
${CHMOD} 0444 ${T}${CUSTOMINCDIR}/$$i.new; \
|
||||
${MV} -f ${T}${CUSTOMINCDIR}/$$i.new ${T}${CUSTOMINCDIR}/$$i; \
|
||||
echo "installed ${T}${CUSTOMINCDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${CUSTOM_CALC_FILES} /dev/null; do \
|
||||
-${Q} for i in ${CUSTOM_CALC_FILES} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s $$i $T${CUSTOMCALDIR}/$$i; then \
|
||||
true; \
|
||||
if ${CMP} -s $$i ${T}${CUSTOMCALDIR}/$$i; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
rm -f $T${CUSTOMCALDIR}/$$i.new; \
|
||||
cp -f $$i $T${CUSTOMCALDIR}/$$i.new; \
|
||||
${CHMOD} 0444 $T${CUSTOMCALDIR}/$$i.new; \
|
||||
mv -f $T${CUSTOMCALDIR}/$$i.new $T${CUSTOMCALDIR}/$$i; \
|
||||
echo "installed $T${CUSTOMCALDIR}/$$i"; \
|
||||
${RM} -f ${T}${CUSTOMCALDIR}/$$i.new; \
|
||||
${CP} -f $$i ${T}${CUSTOMCALDIR}/$$i.new; \
|
||||
${CHMOD} 0444 ${T}${CUSTOMCALDIR}/$$i.new; \
|
||||
${MV} -f ${T}${CUSTOMCALDIR}/$$i.new ${T}${CUSTOMCALDIR}/$$i; \
|
||||
echo "installed ${T}${CUSTOMCALDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${CUSTOM_HELP} /dev/null; do \
|
||||
-${Q} for i in ${CUSTOM_HELP} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s $$i $T${CUSTOMHELPDIR}/$$i; then \
|
||||
true; \
|
||||
if ${CMP} -s $$i ${T}${CUSTOMHELPDIR}/$$i; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
rm -f $T${CUSTOMHELPDIR}/$$i.new; \
|
||||
cp -f $$i $T${CUSTOMHELPDIR}/$$i.new; \
|
||||
${CHMOD} 0444 $T${CUSTOMHELPDIR}/$$i.new; \
|
||||
mv -f $T${CUSTOMHELPDIR}/$$i.new $T${CUSTOMHELPDIR}/$$i; \
|
||||
echo "installed $T${CUSTOMHELPDIR}/$$i"; \
|
||||
${RM} -f ${T}${CUSTOMHELPDIR}/$$i.new; \
|
||||
${CP} -f $$i ${T}${CUSTOMHELPDIR}/$$i.new; \
|
||||
${CHMOD} 0444 ${T}${CUSTOMHELPDIR}/$$i.new; \
|
||||
${MV} -f ${T}${CUSTOMHELPDIR}/$$i.new ${T}${CUSTOMHELPDIR}/$$i; \
|
||||
echo "installed ${T}${CUSTOMHELPDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}if [ ! -z ${ALLOW_CUSTOM} ]; then \
|
||||
if ${CMP} -s libcustcalc.a $T${CUSTOMCALDIR}/libcustcalc.a; then \
|
||||
true; \
|
||||
-${Q} if [ ! -z ${ALLOW_CUSTOM} ]; then \
|
||||
if ${CMP} -s libcustcalc.a ${T}${CUSTOMCALDIR}/libcustcalc.a; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
rm -f $T${CUSTOMCALDIR}/libcustcalc.a.new; \
|
||||
cp -f libcustcalc.a $T${CUSTOMCALDIR}/libcustcalc.a.new; \
|
||||
${CHMOD} 0644 $T${CUSTOMCALDIR}/libcustcalc.a.new; \
|
||||
mv -f $T${CUSTOMCALDIR}/libcustcalc.a.new \
|
||||
$T${CUSTOMCALDIR}/libcustcalc.a; \
|
||||
${RANLIB} $T${CUSTOMCALDIR}/libcustcalc.a; \
|
||||
echo "installed $T${CUSTOMCALDIR}/libcustcalc.a"; \
|
||||
${RM} -f ${T}${CUSTOMCALDIR}/libcustcalc.a.new; \
|
||||
${CP} -f libcustcalc.a ${T}${CUSTOMCALDIR}/libcustcalc.a.new; \
|
||||
${CHMOD} 0644 ${T}${CUSTOMCALDIR}/libcustcalc.a.new; \
|
||||
${MV} -f ${T}${CUSTOMCALDIR}/libcustcalc.a.new \
|
||||
${T}${CUSTOMCALDIR}/libcustcalc.a; \
|
||||
${RANLIB} ${T}${CUSTOMCALDIR}/libcustcalc.a; \
|
||||
echo "installed ${T}${CUSTOMCALDIR}/libcustcalc.a"; \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
@@ -749,58 +774,58 @@ install: all
|
||||
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||
#
|
||||
uninstall:
|
||||
-${Q}if [ -f "$T${CUSTOMCALDIR}/libcustcalc.a" ]; then \
|
||||
rm -f "$T${CUSTOMCALDIR}/libcustcalc.a"; \
|
||||
if [ -f "$T${CUSTOMCALDIR}/libcustcalc.a" ]; then \
|
||||
echo "cannot uninstall $T${CUSTOMCALDIR}/libcustcalc.a"; \
|
||||
-${Q} if [ -f "${T}${CUSTOMCALDIR}/libcustcalc.a" ]; then \
|
||||
${RM} -f "${T}${CUSTOMCALDIR}/libcustcalc.a"; \
|
||||
if [ -f "${T}${CUSTOMCALDIR}/libcustcalc.a" ]; then \
|
||||
echo "cannot uninstall ${T}${CUSTOMCALDIR}/libcustcalc.a"; \
|
||||
else \
|
||||
echo "uninstalled $T${CUSTOMCALDIR}/libcustcalc.a"; \
|
||||
echo "uninstalled ${T}${CUSTOMCALDIR}/libcustcalc.a"; \
|
||||
fi; \
|
||||
fi
|
||||
-${Q}for i in ${CUSTOM_HELP} /dev/null; do \
|
||||
-${Q} for i in ${CUSTOM_HELP} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if [ -f "$T${CUSTOMHELPDIR}/$$i" ]; then \
|
||||
rm -f "$T${CUSTOMHELPDIR}/$$i"; \
|
||||
if [ -f "$T${CUSTOMHELPDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall $T${CUSTOMHELPDIR}/$$i"; \
|
||||
if [ -f "${T}${CUSTOMHELPDIR}/$$i" ]; then \
|
||||
${RM} -f "${T}${CUSTOMHELPDIR}/$$i"; \
|
||||
if [ -f "${T}${CUSTOMHELPDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall ${T}${CUSTOMHELPDIR}/$$i"; \
|
||||
else \
|
||||
echo "uninstalled $T${CUSTOMHELPDIR}/$$i"; \
|
||||
echo "uninstalled ${T}${CUSTOMHELPDIR}/$$i"; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${CUSTOM_CALC_FILES} /dev/null; do \
|
||||
-${Q} for i in ${CUSTOM_CALC_FILES} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if [ -f "$T${CUSTOMCALDIR}/$$i" ]; then \
|
||||
rm -f "$T${CUSTOMCALDIR}/$$i"; \
|
||||
if [ -f "$T${CUSTOMCALDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall $T${CUSTOMCALDIR}/$$i"; \
|
||||
if [ -f "${T}${CUSTOMCALDIR}/$$i" ]; then \
|
||||
${RM} -f "${T}${CUSTOMCALDIR}/$$i"; \
|
||||
if [ -f "${T}${CUSTOMCALDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall ${T}${CUSTOMCALDIR}/$$i"; \
|
||||
else \
|
||||
echo "uninstalled $T${CUSTOMCALDIR}/$$i"; \
|
||||
echo "uninstalled ${T}${CUSTOMCALDIR}/$$i"; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${INSTALL_H_SRC} /dev/null; do \
|
||||
-${Q} for i in ${INSTALL_H_SRC} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if [ -f "$T${CUSTOMINCDIR}/$$i" ]; then \
|
||||
rm -f "$T${CUSTOMINCDIR}/$$i"; \
|
||||
if [ -f "$T${CUSTOMINCDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall $T${CUSTOMINCDIR}/$$i"; \
|
||||
if [ -f "${T}${CUSTOMINCDIR}/$$i" ]; then \
|
||||
${RM} -f "${T}${CUSTOMINCDIR}/$$i"; \
|
||||
if [ -f "${T}${CUSTOMINCDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall ${T}${CUSTOMINCDIR}/$$i"; \
|
||||
else \
|
||||
echo "uninstalled $T${CUSTOMINCDIR}/$$i"; \
|
||||
echo "uninstalled ${T}${CUSTOMINCDIR}/$$i"; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${CUSTOMINCDIR} ${CUSTOMHELPDIR} ${CUSTOMCALDIR} \
|
||||
-${Q} for i in ${CUSTOMINCDIR} ${CUSTOMHELPDIR} ${CUSTOMCALDIR} \
|
||||
${HELPDIR} ${CALC_INCDIR} ${CALC_SHAREDIR} ${INCDIR}; do \
|
||||
if [ -d "$T$$i" ]; then \
|
||||
rmdir "$T$$i" 2>/dev/null; \
|
||||
echo "cleaned up $T$$i"; \
|
||||
if [ -d "${T}$$i" ]; then \
|
||||
${RMDIR} "${T}$$i" 2>/dev/null; \
|
||||
echo "cleaned up ${T}$$i"; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
@@ -820,6 +845,7 @@ c_argv.o: ../calcerr.h
|
||||
c_argv.o: ../cmath.h
|
||||
c_argv.o: ../config.h
|
||||
c_argv.o: ../custom.h
|
||||
c_argv.o: ../decl.h
|
||||
c_argv.o: ../endian_calc.h
|
||||
c_argv.o: ../hash.h
|
||||
c_argv.o: ../have_const.h
|
||||
@@ -837,7 +863,6 @@ c_argv.o: ../shs.h
|
||||
c_argv.o: ../shs1.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
|
||||
@@ -847,6 +872,7 @@ c_devnull.o: ../calcerr.h
|
||||
c_devnull.o: ../cmath.h
|
||||
c_devnull.o: ../config.h
|
||||
c_devnull.o: ../custom.h
|
||||
c_devnull.o: ../decl.h
|
||||
c_devnull.o: ../endian_calc.h
|
||||
c_devnull.o: ../hash.h
|
||||
c_devnull.o: ../have_const.h
|
||||
@@ -864,7 +890,6 @@ c_devnull.o: ../shs.h
|
||||
c_devnull.o: ../shs1.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
|
||||
@@ -874,6 +899,7 @@ c_help.o: ../calcerr.h
|
||||
c_help.o: ../cmath.h
|
||||
c_help.o: ../config.h
|
||||
c_help.o: ../custom.h
|
||||
c_help.o: ../decl.h
|
||||
c_help.o: ../endian_calc.h
|
||||
c_help.o: ../hash.h
|
||||
c_help.o: ../have_const.h
|
||||
@@ -891,7 +917,6 @@ c_help.o: ../shs.h
|
||||
c_help.o: ../shs1.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_pmodm127.o: ../alloc.h
|
||||
@@ -901,6 +926,7 @@ c_pmodm127.o: ../calcerr.h
|
||||
c_pmodm127.o: ../cmath.h
|
||||
c_pmodm127.o: ../config.h
|
||||
c_pmodm127.o: ../custom.h
|
||||
c_pmodm127.o: ../decl.h
|
||||
c_pmodm127.o: ../endian_calc.h
|
||||
c_pmodm127.o: ../hash.h
|
||||
c_pmodm127.o: ../have_const.h
|
||||
@@ -918,7 +944,6 @@ c_pmodm127.o: ../shs.h
|
||||
c_pmodm127.o: ../shs1.h
|
||||
c_pmodm127.o: ../string.h
|
||||
c_pmodm127.o: ../value.h
|
||||
c_pmodm127.o: ../win32dll.h
|
||||
c_pmodm127.o: ../zmath.h
|
||||
c_pmodm127.o: c_pmodm127.c
|
||||
c_pzasusb8.o: ../alloc.h
|
||||
@@ -928,6 +953,7 @@ c_pzasusb8.o: ../calcerr.h
|
||||
c_pzasusb8.o: ../cmath.h
|
||||
c_pzasusb8.o: ../config.h
|
||||
c_pzasusb8.o: ../custom.h
|
||||
c_pzasusb8.o: ../decl.h
|
||||
c_pzasusb8.o: ../endian_calc.h
|
||||
c_pzasusb8.o: ../hash.h
|
||||
c_pzasusb8.o: ../have_const.h
|
||||
@@ -945,7 +971,6 @@ c_pzasusb8.o: ../shs.h
|
||||
c_pzasusb8.o: ../shs1.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
|
||||
@@ -957,6 +982,7 @@ c_sysinfo.o: ../cmath.h
|
||||
c_sysinfo.o: ../conf.h
|
||||
c_sysinfo.o: ../config.h
|
||||
c_sysinfo.o: ../custom.h
|
||||
c_sysinfo.o: ../decl.h
|
||||
c_sysinfo.o: ../endian_calc.h
|
||||
c_sysinfo.o: ../fposval.h
|
||||
c_sysinfo.o: ../hash.h
|
||||
@@ -977,7 +1003,6 @@ c_sysinfo.o: ../shs.h
|
||||
c_sysinfo.o: ../shs1.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
|
||||
@@ -989,6 +1014,7 @@ custtbl.o: ../calcerr.h
|
||||
custtbl.o: ../cmath.h
|
||||
custtbl.o: ../config.h
|
||||
custtbl.o: ../custom.h
|
||||
custtbl.o: ../decl.h
|
||||
custtbl.o: ../endian_calc.h
|
||||
custtbl.o: ../hash.h
|
||||
custtbl.o: ../have_const.h
|
||||
@@ -1005,6 +1031,5 @@ custtbl.o: ../shs.h
|
||||
custtbl.o: ../shs1.h
|
||||
custtbl.o: ../string.h
|
||||
custtbl.o: ../value.h
|
||||
custtbl.o: ../win32dll.h
|
||||
custtbl.o: ../zmath.h
|
||||
custtbl.o: custtbl.c
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_pmodm127 - calculate q mod 2^(2^127-1)
|
||||
*
|
||||
* Copyright (C) 2004 Landon Curt Noll
|
||||
* Copyright (C) 2004-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: c_pmodm127.c,v 29.5 2006/06/25 22:08:42 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: c_pmodm127.c,v 29.6 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_pmodm127.c,v $
|
||||
*
|
||||
* Under source code control: 2004/07/28 22:12:25
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "../have_unused.h"
|
||||
|
||||
/* 2^255 */
|
||||
static HALF h255[] = {
|
||||
STATIC HALF h255[] = {
|
||||
#if BASEB == 32
|
||||
(HALF)0x00000000, (HALF)0x00000000, (HALF)0x00000000, (HALF)0x00000000,
|
||||
(HALF)0x00000000, (HALF)0x00000000, (HALF)0x00000000, (HALF)0x80000000
|
||||
@@ -57,10 +57,10 @@ ZVALUE p255 = {
|
||||
|
||||
|
||||
/* static declarations */
|
||||
static void zmod5_or_zmod(ZVALUE *zp);
|
||||
static BOOL havelastmod = FALSE;
|
||||
static ZVALUE lastmod[1];
|
||||
static ZVALUE lastmodinv[1];
|
||||
S_FUNC void zmod5_or_zmod(ZVALUE *zp);
|
||||
STATIC BOOL havelastmod = FALSE;
|
||||
STATIC ZVALUE lastmod[1];
|
||||
STATIC ZVALUE lastmodinv[1];
|
||||
|
||||
|
||||
/*
|
||||
@@ -187,7 +187,7 @@ c_pmodm127(char UNUSED *name, int UNUSED count, VALUE **vals)
|
||||
* the result of the zmod5_or_zmod conditions do not apply to the argument
|
||||
* and saved mod.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
zmod5_or_zmod(ZVALUE *zp)
|
||||
{
|
||||
LEN len, modlen, j;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_sysinfo - names and values of selected #defines
|
||||
*
|
||||
* Copyright (C) 1999,2004 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.11 $
|
||||
* @(#) $Id: c_sysinfo.c,v 29.11 2006/05/22 19:04:45 chongo Exp $
|
||||
* @(#) $Revision: 29.13 $
|
||||
* @(#) $Id: c_sysinfo.c,v 29.13 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_sysinfo.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 23:14:40
|
||||
@@ -64,7 +64,7 @@ struct infoname {
|
||||
char *str; /* non-NULL ==> value of #define is a string */
|
||||
FULL nmbr; /* if str==NULL ==> value fo #define as a FULL */
|
||||
};
|
||||
static struct infoname sys_info[] = {
|
||||
STATIC struct infoname sys_info[] = {
|
||||
{"S100", "slots in an subtractive 100 table", NULL, (FULL)S100},
|
||||
{"BASE", "base for calculations", NULL, (FULL)BASE},
|
||||
{"BASE1", "one less than base", NULL, (FULL)BASE},
|
||||
@@ -85,7 +85,6 @@ static struct infoname sys_info[] = {
|
||||
{"DEFAULTSHELL", "default shell to use", DEFAULTSHELL, (FULL)0},
|
||||
{"DEV_BITS", "device number size in bits", NULL, (FULL)DEV_BITS},
|
||||
{"DISPLAY_DEFAULT", "default digits for float display", NULL, (FULL)DISPLAY_DEFAULT},
|
||||
{"ECHO_PROG", "where the echo command is located", ECHO_PROG, (FULL)0},
|
||||
{"EPSILONPREC_DEFAULT", "2^-EPSILON_DEFAULT <= EPSILON_DEFAULT", NULL, (FULL)EPSILONPREC_DEFAULT},
|
||||
{"EPSILON_DEFAULT", "allowed error for float calculations", EPSILON_DEFAULT, (FULL)0},
|
||||
{"ERRMAX", "default errmax value", NULL, (FULL)ERRMAX},
|
||||
@@ -161,9 +160,9 @@ static struct infoname sys_info[] = {
|
||||
/*
|
||||
* forward declarations
|
||||
*/
|
||||
static void dump_name_meaning(void); /* custom("sysinfo", 0) */
|
||||
static void dump_name_value(void); /* custom("sysinfo", 1) */
|
||||
static void dump_mening_value(void); /* custom("sysinfo", 2) */
|
||||
S_FUNC void dump_name_meaning(void); /* custom("sysinfo", 0) */
|
||||
S_FUNC void dump_name_value(void); /* custom("sysinfo", 1) */
|
||||
S_FUNC void dump_mening_value(void); /* custom("sysinfo", 2) */
|
||||
|
||||
|
||||
/*
|
||||
@@ -291,7 +290,7 @@ c_sysinfo(char UNUSED *name, int count, VALUE **vals)
|
||||
/*
|
||||
* dump_name_meaning - print all infonames and meanings
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
dump_name_meaning(void)
|
||||
{
|
||||
struct infoname *p; /* current infoname */
|
||||
@@ -308,7 +307,7 @@ dump_name_meaning(void)
|
||||
/*
|
||||
* dump_name_value - print all infonames and values
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
dump_name_value(void)
|
||||
{
|
||||
struct infoname *p; /* current infoname */
|
||||
@@ -339,7 +338,7 @@ dump_name_value(void)
|
||||
/*
|
||||
* dump_mening_value - print all values and meanings
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
dump_mening_value(void)
|
||||
{
|
||||
struct infoname *p; /* current infoname */
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* custtbl - custom interface table
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: custtbl.c,v 29.4 2005/02/05 06:16:19 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: custtbl.c,v 29.5 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/custtbl.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 02:28:54
|
||||
@@ -47,16 +47,16 @@
|
||||
*
|
||||
* Declare custom functions as follows:
|
||||
*
|
||||
* extern VALUE c_xyz(char*, int, VALUE**);
|
||||
* E_FUNC VALUE c_xyz(char*, int, VALUE**);
|
||||
*
|
||||
* We suggest that you sort the entries below by name.
|
||||
*/
|
||||
extern VALUE c_argv(char*, int, VALUE**);
|
||||
extern VALUE c_devnull(char*, int, VALUE**);
|
||||
extern VALUE c_help(char*, int, VALUE**);
|
||||
extern VALUE c_sysinfo(char*, int, VALUE**);
|
||||
extern VALUE c_pzasusb8(char*, int, VALUE**);
|
||||
extern VALUE c_pmodm127(char*, int, VALUE**);
|
||||
E_FUNC VALUE c_argv(char*, int, VALUE**);
|
||||
E_FUNC VALUE c_devnull(char*, int, VALUE**);
|
||||
E_FUNC VALUE c_help(char*, int, VALUE**);
|
||||
E_FUNC VALUE c_sysinfo(char*, int, VALUE**);
|
||||
E_FUNC VALUE c_pzasusb8(char*, int, VALUE**);
|
||||
E_FUNC VALUE c_pmodm127(char*, int, VALUE**);
|
||||
|
||||
|
||||
#endif /* CUSTOM */
|
||||
|
94
decl.h
Normal file
94
decl.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* decl - variable and function declaration macros
|
||||
*
|
||||
* Copyright (C) 2007 Landon Curt Noll
|
||||
*
|
||||
* Primary author: 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: decl.h,v 29.2 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/decl.h,v $
|
||||
*
|
||||
* Under source code control: 2007/02/09 05:24:25
|
||||
* File existed as early as: 2007
|
||||
*
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
#include "have_const.h"
|
||||
|
||||
|
||||
#if !defined(__DECL_H__)
|
||||
#define __DECL_H__
|
||||
|
||||
|
||||
/*
|
||||
* Mac OS X macros that promote thread safety
|
||||
*/
|
||||
#if defined(MACOSX_TLS)
|
||||
|
||||
|
||||
/* variable related macros */
|
||||
# define EXTERN extern __thread
|
||||
# define STATIC static __thread
|
||||
|
||||
/* function related macros */
|
||||
# define E_FUNC extern
|
||||
# define S_FUNC static
|
||||
|
||||
|
||||
/*
|
||||
* MS windoz macros
|
||||
*/
|
||||
#elif defined(_WIN32) || defined(WINDOZ)
|
||||
|
||||
|
||||
/* determine which type of DLL we must generate */
|
||||
# if defined(_EXPORTING)
|
||||
# define DLL __declspec(dllexport)
|
||||
# else
|
||||
# define DLL __declspec(dllimport)
|
||||
# endif
|
||||
|
||||
/* variable related macros */
|
||||
# define EXTERN extern DLL
|
||||
# define STATIC static
|
||||
|
||||
/* function related macros */
|
||||
# define E_FUNC extern DLL
|
||||
# define S_FUNC static
|
||||
|
||||
|
||||
/*
|
||||
* default macros
|
||||
*/
|
||||
#else
|
||||
|
||||
|
||||
/* variable related macros */
|
||||
# define EXTERN extern
|
||||
# define STATIC static
|
||||
|
||||
/* function related macros */
|
||||
# define E_FUNC extern
|
||||
# define S_FUNC static
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !__DECL_H__ */
|
114
file.c
114
file.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* file - file I/O routines callable by users
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell and Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -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.15 $
|
||||
* @(#) $Id: file.c,v 29.15 2006/05/22 19:04:45 chongo Exp $
|
||||
* @(#) $Revision: 29.17 $
|
||||
* @(#) $Id: file.c,v 29.17 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/file.c,v $
|
||||
*
|
||||
* Under source code control: 1991/07/20 00:21:56
|
||||
@@ -57,8 +57,8 @@
|
||||
/*
|
||||
* external STDIO functions
|
||||
*/
|
||||
extern void math_setfp(FILE *fp);
|
||||
extern FILE *f_open(char *name, char *mode);
|
||||
E_FUNC void math_setfp(FILE *fp);
|
||||
E_FUNC FILE *f_open(char *name, char *mode);
|
||||
|
||||
|
||||
/*
|
||||
@@ -66,7 +66,7 @@ extern FILE *f_open(char *name, char *mode);
|
||||
* The first three entries always correspond to stdin, stdout, and stderr,
|
||||
* and cannot be closed. Their file ids are always 0, 1, and 2.
|
||||
*/
|
||||
static FILEIO files[MAXFILES] = {
|
||||
STATIC FILEIO files[MAXFILES] = {
|
||||
{FILEID_STDIN, NULL, (dev_t)0, (ino_t)0,
|
||||
"(stdin)", TRUE, FALSE, FALSE, FALSE, 'r', "r"},
|
||||
{FILEID_STDOUT, NULL, (dev_t)0, (ino_t)0,
|
||||
@@ -76,28 +76,28 @@ static FILEIO files[MAXFILES] = {
|
||||
};
|
||||
|
||||
|
||||
static int ioindex[MAXFILES] = {0,1,2}; /* Indices for FILEIO table */
|
||||
static FILEID lastid = FILEID_STDERR; /* Last allocated file id */
|
||||
static int idnum = 3; /* Number of allocated file ids */
|
||||
STATIC int ioindex[MAXFILES] = {0,1,2}; /* Indices for FILEIO table */
|
||||
STATIC FILEID lastid = FILEID_STDERR; /* Last allocated file id */
|
||||
STATIC int idnum = 3; /* Number of allocated file ids */
|
||||
|
||||
|
||||
/* forward static declarations */
|
||||
static ZVALUE filepos2z(FILEPOS pos);
|
||||
static FILEPOS z2filepos(ZVALUE pos);
|
||||
static int set_open_pos(FILE *fp, ZVALUE zpos);
|
||||
static int get_open_pos(FILE *fp, ZVALUE *res);
|
||||
static ZVALUE off_t2z(off_t siz);
|
||||
static ZVALUE dev2z(dev_t dev);
|
||||
static ZVALUE inode2z(ino_t inode);
|
||||
static void getscanfield(FILE *fp, BOOL skip, unsigned int width,
|
||||
S_FUNC ZVALUE filepos2z(FILEPOS pos);
|
||||
S_FUNC FILEPOS z2filepos(ZVALUE pos);
|
||||
S_FUNC int set_open_pos(FILE *fp, ZVALUE zpos);
|
||||
S_FUNC int get_open_pos(FILE *fp, ZVALUE *res);
|
||||
S_FUNC ZVALUE off_t2z(off_t siz);
|
||||
S_FUNC ZVALUE dev2z(dev_t dev);
|
||||
S_FUNC ZVALUE inode2z(ino_t inode);
|
||||
S_FUNC void getscanfield(FILE *fp, BOOL skip, unsigned int width,
|
||||
int scannum, char *scanptr, char **strptr);
|
||||
static void getscanwhite(FILE *fp, BOOL skip, unsigned int width,
|
||||
S_FUNC void getscanwhite(FILE *fp, BOOL skip, unsigned int width,
|
||||
int scannum, char **strptr);
|
||||
static int fscanfile(FILE *fp, char *fmt, int count, VALUE **vals);
|
||||
static void freadnum(FILE *fp, VALUE *valptr);
|
||||
static void freadsum(FILE *fp, VALUE *valptr);
|
||||
static void freadprod(FILE *fp, VALUE *valptr);
|
||||
static void fskipnum(FILE *fp);
|
||||
S_FUNC int fscanfile(FILE *fp, char *fmt, int count, VALUE **vals);
|
||||
S_FUNC void freadnum(FILE *fp, VALUE *valptr);
|
||||
S_FUNC void freadsum(FILE *fp, VALUE *valptr);
|
||||
S_FUNC void freadprod(FILE *fp, VALUE *valptr);
|
||||
S_FUNC void fskipnum(FILE *fp);
|
||||
|
||||
|
||||
/*
|
||||
@@ -112,7 +112,7 @@ static void fskipnum(FILE *fp);
|
||||
void
|
||||
file_init(void)
|
||||
{
|
||||
static int done = 0; /* 1 => routine already called */
|
||||
STATIC int done = 0; /* 1 => routine already called */
|
||||
struct stat sbuf; /* file status */
|
||||
FILEIO *fiop;
|
||||
FILE *fp;
|
||||
@@ -202,7 +202,7 @@ file_init(void)
|
||||
* id calc file ID
|
||||
* fp open file stream
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
init_fileio(FILEIO *fiop, char *name, char *mode,
|
||||
struct stat *sbufp, FILEID id, FILE *fp)
|
||||
{
|
||||
@@ -746,10 +746,10 @@ flushall(void)
|
||||
* given:
|
||||
* id file to read from
|
||||
* flags read flags (see above)
|
||||
* retptr returned pointer to string
|
||||
* retstr returned pointer to string
|
||||
*/
|
||||
int
|
||||
readid(FILEID id, int flags, char **retptr)
|
||||
readid(FILEID id, int flags, STRING **retstr)
|
||||
{
|
||||
FILEIO *fiop; /* file structure */
|
||||
FILE *fp;
|
||||
@@ -761,6 +761,7 @@ readid(FILEID id, int flags, char **retptr)
|
||||
int c;
|
||||
BOOL nlstop, nullstop, wsstop, rmstop, done;
|
||||
FILEPOS fpos;
|
||||
STRING *newstr;
|
||||
|
||||
totlen = 0;
|
||||
str = NULL;
|
||||
@@ -831,7 +832,10 @@ readid(FILEID id, int flags, char **retptr)
|
||||
if ((nullstop && c == '\0') && !rmstop)
|
||||
str[totlen - 1] = '\0';
|
||||
str[totlen] = '\0';
|
||||
*retptr = str;
|
||||
newstr = stralloc();
|
||||
newstr->s_len = totlen;
|
||||
newstr->s_str = str;
|
||||
*retstr = newstr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -895,7 +899,7 @@ printid(FILEID id, int flags)
|
||||
math_chr('"');
|
||||
return 0;
|
||||
}
|
||||
math_fmt("FILE %d \"%s\" (%s, ", id, fiop->name, fiop->mode);
|
||||
math_fmt("FILE %d \"%s\" (%s", id, fiop->name, fiop->mode);
|
||||
|
||||
/*
|
||||
* print file position
|
||||
@@ -904,11 +908,13 @@ printid(FILEID id, int flags)
|
||||
fp = fiop->fp;
|
||||
|
||||
if (get_open_pos(fp, &pos) < 0) {
|
||||
math_str("Error while determining file position!)");
|
||||
if (fileno(fp) > 2)
|
||||
math_str("Error while determining file position!");
|
||||
math_chr(')');
|
||||
return 0;
|
||||
}
|
||||
|
||||
math_str("pos ");
|
||||
math_str(", pos ");
|
||||
zprintval(pos, 0, 0);
|
||||
zfree(pos);
|
||||
|
||||
@@ -1233,10 +1239,13 @@ idungetc(FILEID id, int ch)
|
||||
* str string to write
|
||||
*/
|
||||
int
|
||||
idfputs(FILEID id, char *str)
|
||||
idfputs(FILEID id, STRING *str)
|
||||
{
|
||||
FILEIO *fiop;
|
||||
FILEPOS fpos;
|
||||
FILE *fp;
|
||||
char *c;
|
||||
long len;
|
||||
|
||||
/* get the file info pointer */
|
||||
fiop = findid(id, TRUE);
|
||||
@@ -1251,14 +1260,13 @@ idfputs(FILEID id, char *str)
|
||||
|
||||
fiop->action = 'w';
|
||||
|
||||
/* set output to file */
|
||||
math_setfp(fiop->fp);
|
||||
fp = fiop->fp;
|
||||
len = str->s_len;
|
||||
c = str->s_str;
|
||||
|
||||
/* write the string */
|
||||
math_str(str);
|
||||
while (len-- > 0)
|
||||
fputc(*c++, fp);
|
||||
|
||||
/* restore output to stdout */
|
||||
math_setfp(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1344,7 +1352,7 @@ rewindall(void)
|
||||
* NOTE: Does not support negative file positions.
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static ZVALUE
|
||||
S_FUNC ZVALUE
|
||||
filepos2z(FILEPOS pos)
|
||||
{
|
||||
ZVALUE ret; /* ZVALUE file position to return */
|
||||
@@ -1377,7 +1385,7 @@ filepos2z(FILEPOS pos)
|
||||
*
|
||||
* NOTE: Does not support negative file positions.
|
||||
*/
|
||||
static FILEPOS
|
||||
S_FUNC FILEPOS
|
||||
z2filepos(ZVALUE zpos)
|
||||
{
|
||||
#if FILEPOS_BITS > FULL_BITS
|
||||
@@ -1454,7 +1462,7 @@ z2filepos(ZVALUE zpos)
|
||||
* 0 res points to the file position
|
||||
* -1 error
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
get_open_pos(FILE *fp, ZVALUE *res)
|
||||
{
|
||||
FILEPOS pos; /* current file position */
|
||||
@@ -1614,7 +1622,7 @@ fseekid(FILEID id, ZVALUE offset, int whence)
|
||||
* NOTE: Due to fsetpos limitation, position is set relative to only
|
||||
* the beginning of the file.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
set_open_pos(FILE *fp, ZVALUE zpos)
|
||||
{
|
||||
FILEPOS pos; /* current file position */
|
||||
@@ -1698,7 +1706,7 @@ setloc(FILEID id, ZVALUE zpos)
|
||||
* file size as a ZVALUE
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static ZVALUE
|
||||
S_FUNC ZVALUE
|
||||
off_t2z(off_t siz)
|
||||
{
|
||||
ZVALUE ret; /* ZVALUE file size to return */
|
||||
@@ -1729,7 +1737,7 @@ off_t2z(off_t siz)
|
||||
* returns:
|
||||
* file size as a ZVALUE
|
||||
*/
|
||||
static ZVALUE
|
||||
S_FUNC ZVALUE
|
||||
dev2z(dev_t dev)
|
||||
{
|
||||
ZVALUE ret; /* ZVALUE file size to return */
|
||||
@@ -1761,7 +1769,7 @@ dev2z(dev_t dev)
|
||||
* file size as a ZVALUE
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static ZVALUE
|
||||
S_FUNC ZVALUE
|
||||
inode2z(ino_t inode)
|
||||
{
|
||||
ZVALUE ret; /* ZVALUE file size to return */
|
||||
@@ -1919,7 +1927,7 @@ get_inode(FILEID id, ZVALUE *inode)
|
||||
}
|
||||
|
||||
|
||||
static off_t
|
||||
S_FUNC off_t
|
||||
filesize(FILEIO *fiop)
|
||||
{
|
||||
struct stat sbuf;
|
||||
@@ -2017,7 +2025,7 @@ showfiles(void)
|
||||
* scanptr string of characters considered separators
|
||||
* strptr pointer to where the new field pointer may be found
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getscanfield(FILE *fp, BOOL skip, unsigned int width, int scannum, char *scanptr, char **strptr)
|
||||
{
|
||||
char *str; /* current string */
|
||||
@@ -2095,7 +2103,7 @@ getscanfield(FILE *fp, BOOL skip, unsigned int width, int scannum, char *scanptr
|
||||
* scannum Number of characters in scanset
|
||||
* strptr pointer to where the new field pointer may be found
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
getscanwhite(FILE *fp, BOOL skip, unsigned int width, int scannum, char **strptr)
|
||||
{
|
||||
char *str; /* current string */
|
||||
@@ -2162,7 +2170,7 @@ getscanwhite(FILE *fp, BOOL skip, unsigned int width, int scannum, char **strptr
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
S_FUNC int
|
||||
fscanfile(FILE *fp, char *fmt, int count, VALUE **vals)
|
||||
{
|
||||
int assnum; /* Number of assignments made */
|
||||
@@ -2356,7 +2364,7 @@ scanfstr(char *str, char *fmt, int count, VALUE **vals)
|
||||
* a sign immediately following 'e' or 'E', or a dot is encountered.
|
||||
* Absence of digits is interpreted as zero.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
freadnum(FILE *fp, VALUE *valptr)
|
||||
{
|
||||
ZVALUE num, zden, newnum, newden, div, tmp;
|
||||
@@ -2494,7 +2502,7 @@ freadnum(FILE *fp, VALUE *valptr)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
freadsum(FILE *fp, VALUE *valptr)
|
||||
{
|
||||
VALUE v1, v2, v3;
|
||||
@@ -2520,7 +2528,7 @@ freadsum(FILE *fp, VALUE *valptr)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
freadprod(FILE *fp, VALUE *valptr)
|
||||
{
|
||||
VALUE v1, v2, v3;
|
||||
@@ -2544,7 +2552,7 @@ freadprod(FILE *fp, VALUE *valptr)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
fskipnum(FILE *fp)
|
||||
{
|
||||
char ch;
|
||||
|
18
file.h
18
file.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* file - file I/O routines callable by users
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell and Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Primary author: David I. Bell
|
||||
*
|
||||
@@ -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.8 $
|
||||
* @(#) $Id: file.h,v 29.8 2006/05/19 15:26:10 chongo Exp $
|
||||
* @(#) $Revision: 29.9 $
|
||||
* @(#) $Id: file.h,v 29.9 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/file.h,v $
|
||||
*
|
||||
* Under source code control: 1996/05/24 05:55:58
|
||||
@@ -91,12 +91,12 @@ typedef struct {
|
||||
/*
|
||||
* external functions
|
||||
*/
|
||||
extern DLL FILEIO * findid(FILEID id, int writable);
|
||||
extern DLL int fgetposid(FILEID id, FILEPOS *ptr);
|
||||
extern DLL int fsetposid(FILEID id, FILEPOS *ptr);
|
||||
extern DLL int get_open_siz(FILE *fp, ZVALUE *res);
|
||||
extern DLL char* findfname(FILEID);
|
||||
extern DLL FILE *f_pathopen(char *name, char *mode, char *pathlist, char **openpath);
|
||||
E_FUNC FILEIO * findid(FILEID id, int writable);
|
||||
E_FUNC int fgetposid(FILEID id, FILEPOS *ptr);
|
||||
E_FUNC int fsetposid(FILEID id, FILEPOS *ptr);
|
||||
E_FUNC int get_open_siz(FILE *fp, ZVALUE *res);
|
||||
E_FUNC char* findfname(FILEID);
|
||||
E_FUNC FILE *f_pathopen(char *name, char *mode, char *pathlist, char **openpath);
|
||||
|
||||
|
||||
#endif /* !__FILE_H__ */
|
||||
|
68
func.h
68
func.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* func - built-in function interface definitions
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: func.h,v 29.4 2001/06/08 21:00:58 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: func.h,v 29.5 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/func.h,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:33
|
||||
@@ -72,42 +72,42 @@ struct func {
|
||||
/*
|
||||
* The current function being compiled.
|
||||
*/
|
||||
extern FUNC *curfunc;
|
||||
EXTERN FUNC *curfunc;
|
||||
|
||||
|
||||
/*
|
||||
* Functions to handle functions.
|
||||
*/
|
||||
extern FUNC *findfunc(long index);
|
||||
extern char *namefunc(long index);
|
||||
extern BOOL evaluate(BOOL nestflag);
|
||||
extern long adduserfunc(char *name);
|
||||
extern void rmuserfunc(char *name);
|
||||
extern void rmalluserfunc(void);
|
||||
extern long getuserfunc(char *name);
|
||||
extern void beginfunc(char *name, BOOL newflag);
|
||||
extern int builtinopcode(long index);
|
||||
extern char *builtinname(long index);
|
||||
extern int dumpop(unsigned long *pc);
|
||||
extern void addop(long op);
|
||||
extern void endfunc(void);
|
||||
extern void addopone(long op, long arg);
|
||||
extern void addoptwo(long op, long arg1, long arg2);
|
||||
extern void addoplabel(long op, LABEL *label);
|
||||
extern void addopptr(long op, char *ptr);
|
||||
extern void writeindexop(void);
|
||||
extern void showbuiltins(void);
|
||||
extern int getbuiltinfunc(char *name);
|
||||
extern void builtincheck(long index, int count);
|
||||
extern void addopfunction(long op, long index, int count);
|
||||
extern void showfunctions(void);
|
||||
extern void initfunctions(void);
|
||||
extern void clearopt(void);
|
||||
extern void updateoldvalue(FUNC *fp);
|
||||
extern void calculate(FUNC *fp, int argcount);
|
||||
extern VALUE builtinfunc(long index, int argcount, VALUE *stck);
|
||||
extern void freenumbers(FUNC *);
|
||||
extern void freefunc(FUNC *);
|
||||
E_FUNC FUNC *findfunc(long index);
|
||||
E_FUNC char *namefunc(long index);
|
||||
E_FUNC BOOL evaluate(BOOL nestflag);
|
||||
E_FUNC long adduserfunc(char *name);
|
||||
E_FUNC void rmuserfunc(char *name);
|
||||
E_FUNC void rmalluserfunc(void);
|
||||
E_FUNC long getuserfunc(char *name);
|
||||
E_FUNC void beginfunc(char *name, BOOL newflag);
|
||||
E_FUNC int builtinopcode(long index);
|
||||
E_FUNC char *builtinname(long index);
|
||||
E_FUNC int dumpop(unsigned long *pc);
|
||||
E_FUNC void addop(long op);
|
||||
E_FUNC void endfunc(void);
|
||||
E_FUNC void addopone(long op, long arg);
|
||||
E_FUNC void addoptwo(long op, long arg1, long arg2);
|
||||
E_FUNC void addoplabel(long op, LABEL *label);
|
||||
E_FUNC void addopptr(long op, char *ptr);
|
||||
E_FUNC void writeindexop(void);
|
||||
E_FUNC void showbuiltins(void);
|
||||
E_FUNC int getbuiltinfunc(char *name);
|
||||
E_FUNC void builtincheck(long index, int count);
|
||||
E_FUNC void addopfunction(long op, long index, int count);
|
||||
E_FUNC void showfunctions(void);
|
||||
E_FUNC void initfunctions(void);
|
||||
E_FUNC void clearopt(void);
|
||||
E_FUNC void updateoldvalue(FUNC *fp);
|
||||
E_FUNC void calculate(FUNC *fp, int argcount);
|
||||
E_FUNC VALUE builtinfunc(long index, int argcount, VALUE *stck);
|
||||
E_FUNC void freenumbers(FUNC *);
|
||||
E_FUNC void freefunc(FUNC *);
|
||||
|
||||
|
||||
#endif /* !__FUNC_H__ */
|
||||
|
14
hash.c
14
hash.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* hash - one-way hash routines
|
||||
*
|
||||
* Copyright (C) 1999-2006 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.10 $
|
||||
* @(#) $Id: hash.c,v 29.10 2006/06/20 10:25:45 chongo Exp $
|
||||
* @(#) $Revision: 29.11 $
|
||||
* @(#) $Id: hash.c,v 29.11 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/hash.c,v $
|
||||
*
|
||||
* Under source code control: 1995/11/23 05:13:11
|
||||
@@ -43,9 +43,9 @@
|
||||
/*
|
||||
* external hash_setup functions
|
||||
*/
|
||||
extern void shs_init_state(HASH*);
|
||||
extern void shs1_init_state(HASH*);
|
||||
extern void MD5_init_state(HASH*);
|
||||
E_FUNC void shs_init_state(HASH*);
|
||||
E_FUNC void shs1_init_state(HASH*);
|
||||
E_FUNC void MD5_init_state(HASH*);
|
||||
|
||||
|
||||
/*
|
||||
@@ -60,7 +60,7 @@ extern void MD5_init_state(HASH*);
|
||||
/*
|
||||
* hash_setup - setup the hash state for a given hash
|
||||
*/
|
||||
static struct hash_setup {
|
||||
STATIC struct hash_setup {
|
||||
int type; /* hash type (see XYZ_HASH_TYPE below) */
|
||||
void (*init_state)(HASH*); /* initialize a hash state */
|
||||
} htbl[] = {
|
||||
|
32
hash.h
32
hash.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* hash - one-way hash routines
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: hash.h,v 29.4 2001/06/08 21:00:58 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: hash.h,v 29.5 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/hash.h,v $
|
||||
*
|
||||
* Under source code control: 1995/11/14 23:57:45
|
||||
@@ -123,19 +123,19 @@ struct hashstate {
|
||||
/*
|
||||
* external functions
|
||||
*/
|
||||
extern HASH* hash_init(int, HASH*);
|
||||
extern void hash_free(HASH*);
|
||||
extern HASH* hash_copy(HASH*);
|
||||
extern int hash_cmp(HASH*, HASH*);
|
||||
extern void hash_print(HASH*);
|
||||
extern ZVALUE hash_final(HASH*);
|
||||
extern HASH* hash_long(int, long, HASH*);
|
||||
extern HASH* hash_zvalue(int, ZVALUE, HASH*);
|
||||
extern HASH* hash_number(int, void*, HASH*);
|
||||
extern HASH* hash_complex(int, void*, HASH*);
|
||||
extern HASH* hash_str(int, char*, HASH*);
|
||||
extern HASH* hash_usb8(int, USB8*, int, HASH*);
|
||||
extern HASH* hash_value(int, void*, HASH*);
|
||||
E_FUNC HASH* hash_init(int, HASH*);
|
||||
E_FUNC void hash_free(HASH*);
|
||||
E_FUNC HASH* hash_copy(HASH*);
|
||||
E_FUNC int hash_cmp(HASH*, HASH*);
|
||||
E_FUNC void hash_print(HASH*);
|
||||
E_FUNC ZVALUE hash_final(HASH*);
|
||||
E_FUNC HASH* hash_long(int, long, HASH*);
|
||||
E_FUNC HASH* hash_zvalue(int, ZVALUE, HASH*);
|
||||
E_FUNC HASH* hash_number(int, void*, HASH*);
|
||||
E_FUNC HASH* hash_complex(int, void*, HASH*);
|
||||
E_FUNC HASH* hash_str(int, char*, HASH*);
|
||||
E_FUNC HASH* hash_usb8(int, USB8*, int, HASH*);
|
||||
E_FUNC HASH* hash_value(int, void*, HASH*);
|
||||
|
||||
|
||||
#endif /* !__HASH_H__ */
|
||||
|
65
have_stdvs.c
65
have_stdvs.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: have_stdvs.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: have_stdvs.c,v 29.3 2007/02/07 20:53:18 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/have_stdvs.c,v $
|
||||
*
|
||||
* Under source code control: 1995/09/09 22:41:10
|
||||
@@ -56,6 +56,13 @@
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#undef VSPRINTF_SIZE_T
|
||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||
# define VSPRINTF_SIZE_T size_t
|
||||
#else
|
||||
# define VSPRINTF_SIZE_T long
|
||||
#endif
|
||||
|
||||
char buf[BUFSIZ];
|
||||
|
||||
|
||||
@@ -74,6 +81,21 @@ try_this(char *fmt, ...)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
try_nthis(char *fmt, VSPRINTF_SIZE_T size, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
vsnprintf(buf, size, fmt, ap);
|
||||
#else
|
||||
snprintf(buf, size, fmt, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
@@ -95,9 +117,9 @@ main(void)
|
||||
exit(1);
|
||||
}
|
||||
try_this("%s %d%s%d%d %s",
|
||||
"Landon Noll 1st proved that", 2, "^", 23209, -1, "was prime");
|
||||
"Landon Noll 1st coproved that", 2, "^", 21701, -1, "was prime");
|
||||
if (strcmp(buf,
|
||||
"Landon Noll 1st proved that 2^23209-1 was prime") != 0) {
|
||||
"Landon Noll 1st coproved that 2^21701-1 was prime") != 0) {
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
/* <stdarg.h> with vsprintf() didn't work */
|
||||
#else
|
||||
@@ -106,6 +128,30 @@ main(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* test variable args and vsnprintf/snprintf
|
||||
*/
|
||||
try_nthis("@%d:%s:%d@", sizeof(buf)-1, 1, "hello", 5);
|
||||
if (strcmp(buf, "@1:hello:5@") != 0) {
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
/* <stdarg.h> with vsnprintf() didn't work */
|
||||
#else
|
||||
/* <stdarg.h> with snprintf() simulating vsnprintf() didn't work */
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
try_nthis("%s %d%s%d%d %s", sizeof(buf)-1,
|
||||
"Landon Noll 1st proved that", 2, "^", 23209, -1, "was prime");
|
||||
if (strcmp(buf,
|
||||
"Landon Noll 1st proved that 2^23209-1 was prime") != 0) {
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
/* <stdarg.h> with vsnprintf() didn't work */
|
||||
#else
|
||||
/* <stdarg.h> with snprintf() simulating vsnprintf() didn't work */
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* report the result
|
||||
*/
|
||||
@@ -128,19 +174,22 @@ main(void)
|
||||
puts("#define STDARG /* use <stdarg.h> */");
|
||||
puts("#include <stdarg.h>");
|
||||
#endif
|
||||
puts("\n/* should we use vsprintf()? */");
|
||||
puts("\n/* should we use vsprintf() and vsnprintf()? */");
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
puts("#define HAVE_VS /* yes */");
|
||||
puts("#define HAVE_VSPRINTF /* yes */");
|
||||
#else
|
||||
puts("/*");
|
||||
puts(" * Hack aleart!!!");
|
||||
puts(" *");
|
||||
puts(" * Systems that do not have vsprintf() need something. In some");
|
||||
puts(" * cases the sprintf function will deal correctly with the");
|
||||
puts(" * va_alist 3rd arg. Hope for the best!");
|
||||
puts(" * va_alist 3rd arg. Same gors for a lack of an vsnprintf()");
|
||||
puts(" * function. In either case we use the #defines below and");
|
||||
puts(" * hope for the best!");
|
||||
puts(" */");
|
||||
puts("#define vsprintf sprintf");
|
||||
puts("#undef HAVE_VS");
|
||||
puts("#define vsnprintf snprintf");
|
||||
puts("#undef HAVE_VSPRINTF");
|
||||
#endif
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
|
72
have_varvs.c
72
have_varvs.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: have_varvs.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: have_varvs.c,v 29.3 2007/02/07 20:53:18 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/have_varvs.c,v $
|
||||
*
|
||||
* Under source code control: 1995/09/09 22:41:10
|
||||
@@ -52,6 +52,13 @@
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#undef VSPRINTF_SIZE_T
|
||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||
# define VSPRINTF_SIZE_T size_t
|
||||
#else
|
||||
# define VSPRINTF_SIZE_T long
|
||||
#endif
|
||||
|
||||
char buf[BUFSIZ];
|
||||
|
||||
#if !defined(STDARG) && !defined(SIMULATE_STDARG)
|
||||
@@ -73,6 +80,22 @@ try_this(char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
try_nthis(char *fmt, VSPRINTF_SIZE_T size, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap);
|
||||
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
vsnprintf(buf, size, fmt, ap);
|
||||
#else
|
||||
snprintf(buf, size, fmt, ap);
|
||||
#endif
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
@@ -81,6 +104,12 @@ try_this(char *a, int b, char *c, int d)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
try_nthis(char *a, VSPRINTF_SIZE_T size, int b, char *c, int d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -109,9 +138,33 @@ main(void)
|
||||
if (strcmp(buf,
|
||||
"Landon Noll 1st proved that 2^23209-1 was prime") != 0) {
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
/* <stdarg.h> with vsprintf() didn't work */
|
||||
/* <varargs.h> with vsprintf() didn't work */
|
||||
#else
|
||||
/* <stdarg.h> with sprintf() simulating vsprintf() didn't work */
|
||||
/* <varargs.h> with sprintf() simulating vsprintf() didn't work */
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* test variable args and vsnprintf/snprintf
|
||||
*/
|
||||
try_nthis("@%d:%s:%d@", sizeof(buf)-1, 1, "hello", 5);
|
||||
if (strcmp(buf, "@1:hello:5@") != 0) {
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
/* <varargs.h> with vsnprintf() didn't work */
|
||||
#else
|
||||
/* <varargs.h> with snprintf() simulating vsnprintf() didn't work */
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
try_nthis("%s %d%s%d%d %s", sizeof(buf)-1,
|
||||
"Landon Noll 1st proved that", 2, "^", 23209, -1, "was prime");
|
||||
if (strcmp(buf,
|
||||
"Landon Noll 1st proved that 2^23209-1 was prime") != 0) {
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
/* <varargs.h> with vsnprintf() didn't work */
|
||||
#else
|
||||
/* <varargs.h> with snprintf() simulating vsnprintf() didn't work */
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
@@ -122,19 +175,22 @@ main(void)
|
||||
puts("/* what type of variable args do we have? */");
|
||||
puts("#define VARARGS /* use <varargs.h> */");
|
||||
puts("#include <varargs.h>");
|
||||
puts("\n/* should we use vsprintf()? */");
|
||||
puts("\n/* should we use vsprintf() and vsnprintf()? */");
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
puts("#define HAVE_VS /* yes */");
|
||||
puts("#define HAVE_VSPRINTF /* yes */");
|
||||
#else
|
||||
puts("/*");
|
||||
puts(" * Hack aleart!!!");
|
||||
puts(" *");
|
||||
puts(" * Systems that do not have vsprintf() need something. In some");
|
||||
puts(" * cases the sprintf function will deal correctly with the");
|
||||
puts(" * va_alist 3rd arg. Hope for the best!");
|
||||
puts(" * va_alist 3rd arg. Same gors for a lack of an vsnprintf()");
|
||||
puts(" * function. In either case we use the #defines below and");
|
||||
puts(" * hope for the best!");
|
||||
puts(" */");
|
||||
puts("#define vsprintf sprintf");
|
||||
puts("#undef HAVE_VS");
|
||||
puts("#define vsnprintf snprintf");
|
||||
puts("#undef HAVE_VSPRINTF");
|
||||
#endif
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
|
15
help.c
15
help.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* help - display help for calc
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: help.c,v 29.8 2001/04/08 08:29:28 chongo Exp $
|
||||
* @(#) $Revision: 29.10 $
|
||||
* @(#) $Id: help.c,v 29.10 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/help.c,v $
|
||||
*
|
||||
* Under source code control: 1997/09/14 10:58:30
|
||||
@@ -51,7 +51,7 @@
|
||||
/*
|
||||
* some help topics are symbols, so we alias them to nice filenames
|
||||
*/
|
||||
static struct help_alias {
|
||||
STATIC struct help_alias {
|
||||
char *topic;
|
||||
char *filename;
|
||||
} halias[] = {
|
||||
@@ -62,6 +62,8 @@ static struct help_alias {
|
||||
{".", "oldvalue"},
|
||||
{"%", "mod"},
|
||||
{"//", "quo"},
|
||||
{"#", "pound"},
|
||||
{"calc", "help"},
|
||||
{"copy", "blkcpy"},
|
||||
{"copying", "COPYING"},
|
||||
{"copying-lgpl", "COPYING-LGPL"},
|
||||
@@ -71,6 +73,7 @@ static struct help_alias {
|
||||
{"COPYRIGHT", "copyright"},
|
||||
{"Copyleft", "copyright"},
|
||||
{"COPYLEFT", "copyright"},
|
||||
{"define", "command"},
|
||||
{"read", "command"},
|
||||
{"write", "command"},
|
||||
{"quit", "command"},
|
||||
@@ -86,7 +89,7 @@ static struct help_alias {
|
||||
/*
|
||||
* external values
|
||||
*/
|
||||
extern char *pager; /* $PAGER or default */
|
||||
EXTERN char *pager; /* $PAGER or default */
|
||||
|
||||
|
||||
/*
|
||||
@@ -101,7 +104,7 @@ extern char *pager; /* $PAGER or default */
|
||||
* given:
|
||||
* stream open file stream of the file to send to the pager
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
page_file(FILE *stream)
|
||||
{
|
||||
FILE *cmd; /* pager command */
|
||||
|
382
help/Makefile
382
help/Makefile
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# help - makefile for calc help files
|
||||
#
|
||||
# Copyright (C) 1999-2002 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
|
||||
@@ -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.36 $
|
||||
# @(#) $Id: Makefile,v 29.36 2007/02/07 00:31:06 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1991/07/23 06:47:57
|
||||
@@ -34,7 +34,7 @@
|
||||
# required vars
|
||||
#
|
||||
SHELL= /bin/sh
|
||||
MAKE_FILE = Makefile
|
||||
MAKE_FILE= Makefile
|
||||
|
||||
####
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
@@ -62,9 +62,9 @@ INCDIR= /usr/include
|
||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
# NOTE: The install rule prepends installation paths with ${T}, which
|
||||
# by default is empty. If ${T} is non-empty, then installation
|
||||
# locations will be relative to the ${T} directory.
|
||||
#
|
||||
# For DJGPP, select:
|
||||
#
|
||||
@@ -99,9 +99,9 @@ CALC_SHAREDIR= /usr/share/calc
|
||||
# ${CUSTOMINCPDIR} where custom .h files are installed
|
||||
# ${SCRIPTDIR} where calc shell scripts are installed
|
||||
#
|
||||
# NOTE: The install rule prepends installation paths with $T, which
|
||||
# by default is empty. If $T is non-empty, then installation
|
||||
# locations will be relative to the $T directory.
|
||||
# NOTE: The install rule prepends installation paths with ${T}, which
|
||||
# by default is empty. If ${T} is non-empty, then installation
|
||||
# locations will be relative to the ${T} directory.
|
||||
#
|
||||
# If in doubt, set:
|
||||
#
|
||||
@@ -121,8 +121,8 @@ SCRIPTDIR= ${BINDIR}/cscript
|
||||
|
||||
# T - top level directory under which calc will be installed
|
||||
#
|
||||
# The calc install is performed under $T, the calc build is
|
||||
# performed under /. The purpose for $T is to allow someone
|
||||
# The calc install is performed under ${T}, the calc build is
|
||||
# performed under /. The purpose for ${T} is to allow someone
|
||||
# to install calc somewhere other than into the system area.
|
||||
#
|
||||
# For example, if:
|
||||
@@ -142,10 +142,10 @@ SCRIPTDIR= ${BINDIR}/cscript
|
||||
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
||||
# ... etc ... /var/tmp/testing/...
|
||||
#
|
||||
# If $T is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If $T is non-empty, then
|
||||
# calc is installed under $T, as if one had to chroot under
|
||||
# $T for calc to operate.
|
||||
# If ${T} is empty, calc is installed under /, which is the same
|
||||
# top of tree for which it was built. If ${T} is non-empty, then
|
||||
# calc is installed under ${T}, as if one had to chroot under
|
||||
# ${T} for calc to operate.
|
||||
#
|
||||
# If in doubt, use T=
|
||||
#
|
||||
@@ -169,6 +169,14 @@ SED= sed
|
||||
SORT= sort
|
||||
FMT= fmt
|
||||
CMP= cmp
|
||||
CP= cp
|
||||
MV= mv
|
||||
TRUE= true
|
||||
RM= rm
|
||||
MKDIR= mkdir
|
||||
RMDIR= rmdir
|
||||
TOUCH= touch
|
||||
CAT= cat
|
||||
|
||||
# Some out of date operating systems require / want an executable to
|
||||
# end with a certain file extension. Some compile systems such as
|
||||
@@ -206,9 +214,9 @@ STD_HELP_FILES_8= operator statement
|
||||
|
||||
BLT_HELP_FILES_9= resource
|
||||
|
||||
STD_HELP_FILES_10= types usage script
|
||||
STD_HELP_FILES_10= types script
|
||||
|
||||
BLT_HELP_FILES_10a= cscript
|
||||
BLT_HELP_FILES_10a= usage cscript
|
||||
|
||||
STD_HELP_FILES_10b= unexpected variable
|
||||
|
||||
@@ -267,15 +275,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 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 \
|
||||
@@ -284,15 +292,15 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd append \
|
||||
ln log lowbit ltol makelist matdim matfill matmax matmin matsum \
|
||||
mattrace mattrans max md5 memsize meq min minv mmin mne mod modify \
|
||||
name near newerror nextcand nextprime norm null num oldvalue ord \
|
||||
param perm pfact pi pix places pmod polar poly pop popcnt power \
|
||||
prevcand prevprime printf prompt protect ptest push putenv quo \
|
||||
quomod rand randbit random randombit randperm rcin rcmul rcout \
|
||||
param perm pfact pi pix places pmod polar poly pop popcnt pound \
|
||||
power prevcand prevprime printf prompt protect ptest push putenv \
|
||||
quo quomod rand randbit random randombit randperm rcin rcmul rcout \
|
||||
rcpow rcsq re remove reverse rewind rm root round rsearch runtime \
|
||||
saveval scale scan scanf search sec sech seed segment select sgn \
|
||||
sha sha1 sin sinh size sizeof sleep sort sqrt srand srandom ssq \
|
||||
str strcat strcmp strcpy strerror strlen strncmp strncpy strpos \
|
||||
strprintf strscan strscanf substr sum swap system tail tan tanh \
|
||||
test time trunc version xor
|
||||
strprintf strscan strscanf substr sum swap system systime tail tan \
|
||||
tanh test time trunc usertime version xor
|
||||
|
||||
# This list is of files that are clones of DETAIL_HELP files. They are
|
||||
# built from DETAIL_HELP files.
|
||||
@@ -317,7 +325,7 @@ DISTLIST= ${STD_HELP_FILES} ${DETAIL_HELP} ${MAKE_FILE} \
|
||||
CALCLIBLIST=
|
||||
|
||||
all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \
|
||||
${SINGULAR_FILES} calc .all
|
||||
${SINGULAR_FILES} .all
|
||||
|
||||
# used by the upper level Makefile to determine of we have done all
|
||||
#
|
||||
@@ -325,175 +333,183 @@ all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \
|
||||
# an non-emoty else clause for every if condition. *sigh*
|
||||
#
|
||||
.all:
|
||||
rm -f .all
|
||||
touch .all
|
||||
${RM} -f .all
|
||||
${TOUCH} .all
|
||||
|
||||
bindings: ../cal/bindings
|
||||
rm -f $@
|
||||
cp ../cal/bindings $@
|
||||
${RM} -f $@
|
||||
${CP} ../cal/bindings $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
resource: ../cal/README
|
||||
rm -f $@
|
||||
cp ../cal/README $@
|
||||
${RM} -f $@
|
||||
${CP} ../cal/README $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
changes: ../CHANGES
|
||||
rm -f $@
|
||||
cp ../CHANGES $@
|
||||
${RM} -f $@
|
||||
${CP} ../CHANGES $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
libcalc: ../LIBRARY
|
||||
rm -f $@
|
||||
${RM} -f $@
|
||||
${SED} -e 's:$${LIBDIR}:${LIBDIR}:g' \
|
||||
-e 's:$${CALC_INCDIR}:${CALC_INCDIR}:g' < ../LIBRARY > $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
bugs: ../BUGS
|
||||
rm -f $@
|
||||
cp ../BUGS $@
|
||||
${RM} -f $@
|
||||
${CP} ../BUGS $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
errorcodes: ../calcerr.h errorcodes.hdr errorcodes.sed
|
||||
rm -f $@
|
||||
cat errorcodes.hdr > $@
|
||||
${RM} -f $@
|
||||
${CAT} errorcodes.hdr > $@
|
||||
${SED} -n -f errorcodes.sed < ../calcerr.h >> $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
calc: usage
|
||||
rm -f $@
|
||||
cp usage $@
|
||||
usage: ../calc.usage
|
||||
${RM} -f $@
|
||||
${CP} ../calc.usage $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
../calc.usage:
|
||||
(cd ..; $(MAKE) calc.usage)
|
||||
|
||||
custom_cal: ../custom/CUSTOM_CAL
|
||||
rm -f $@
|
||||
cp ../custom/CUSTOM_CAL $@
|
||||
${RM} -f $@
|
||||
${CP} ../custom/CUSTOM_CAL $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
new_custom: ../custom/HOW_TO_ADD
|
||||
rm -f $@
|
||||
cp ../custom/HOW_TO_ADD $@
|
||||
${RM} -f $@
|
||||
${CP} ../custom/HOW_TO_ADD $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
copy: blkcpy
|
||||
rm -f $@
|
||||
cp blkcpy $@
|
||||
${RM} -f $@
|
||||
${CP} blkcpy $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
COPYING: ../COPYING
|
||||
rm -f $@
|
||||
cp ../COPYING $@
|
||||
${RM} -f $@
|
||||
${CP} ../COPYING $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
COPYING-LGPL: ../COPYING-LGPL
|
||||
rm -f $@
|
||||
cp ../COPYING-LGPL $@
|
||||
${RM} -f $@
|
||||
${CP} ../COPYING-LGPL $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
cscript: ../cscript/README
|
||||
rm -f $@
|
||||
cp ../cscript/README $@
|
||||
${RM} -f $@
|
||||
${CP} ../cscript/README $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
../cscript/README: ../cscript/README.src
|
||||
${Q} echo "forming cscript/README"
|
||||
-${Q} ${RM} -f $@
|
||||
(cd ../cscript; $(MAKE) README)
|
||||
|
||||
full: ${FULL_HELP_FILES} ${MAKE_FILE}
|
||||
${Q}echo "forming full"
|
||||
-${Q}rm -f $@
|
||||
-${Q}for i in ${FULL_HELP_FILES}; do \
|
||||
${Q} echo "forming full"
|
||||
-${Q} ${RM} -f $@
|
||||
-${Q} for i in ${FULL_HELP_FILES}; do \
|
||||
if [ Xintro != X"$$i" ]; then \
|
||||
echo ""; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi; \
|
||||
if [ Xobj.file = X"$$i" ]; then \
|
||||
j=obj; \
|
||||
@@ -504,34 +520,34 @@ full: ${FULL_HELP_FILES} ${MAKE_FILE}
|
||||
echo "* $$j"; \
|
||||
echo "*************"; \
|
||||
echo ""; \
|
||||
cat $$i; \
|
||||
${CAT} $$i; \
|
||||
done > $@
|
||||
${Q}echo "full formed"
|
||||
${Q} echo "full formed"
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
# Singular files are the same files as their plural form.
|
||||
#
|
||||
${SINGULAR_FILES}: ${PLURAL_FILES}
|
||||
${Q}for i in ${SINGULAR_FILES} /dev/null; do \
|
||||
${Q} for i in ${SINGULAR_FILES} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo "rm -f $${i}"; \
|
||||
rm -f $${i}; \
|
||||
echo "cp $${i}s $${i}"; \
|
||||
cp $${i}s $${i}; \
|
||||
echo "${RM} -f $${i}"; \
|
||||
${RM} -f $${i}; \
|
||||
echo "${CP} $${i}s $${i}"; \
|
||||
${CP} $${i}s $${i}; \
|
||||
fi; \
|
||||
done
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/SINGULAR_FILES =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/SINGULAR_FILES =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
# Form the builtin file
|
||||
@@ -553,25 +569,25 @@ ${SINGULAR_FILES}: ${PLURAL_FILES}
|
||||
# do not treat -I.. correctly!
|
||||
#
|
||||
builtin: builtin.top builtin.end ../func.c funclist.sed
|
||||
${Q}echo "forming builtin help file"
|
||||
-${Q}rm -f funclist.c
|
||||
${Q}${SED} -n -f funclist.sed ../func.c > funclist.c
|
||||
-${Q}rm -f funclist.o funclist${EXT}
|
||||
${Q}${LCC} ${ICFLAGS} -DFUNCLIST -I/usr/include \
|
||||
${Q} echo "forming builtin help file"
|
||||
-${Q} ${RM} -f funclist.c
|
||||
${Q} ${SED} -n -f funclist.sed ../func.c > funclist.c
|
||||
-${Q} ${RM} -f funclist.o funclist${EXT}
|
||||
${Q} ${LCC} ${ICFLAGS} -DFUNCLIST -I/usr/include \
|
||||
-I.. funclist.c -c 2>/dev/null
|
||||
${Q}${LCC} ${ILDFLAGS} funclist.o -o funclist${EXT}
|
||||
-${Q}rm -f builtin
|
||||
${Q}cat builtin.top > builtin
|
||||
${Q}./funclist${EXT} | \
|
||||
${Q} ${LCC} ${ILDFLAGS} funclist.o -o funclist${EXT}
|
||||
-${Q} ${RM} -f builtin
|
||||
${Q} ${CAT} builtin.top > builtin
|
||||
${Q} ./funclist${EXT} | \
|
||||
${SED} -e 's/^/ /' -e 's/[ ][ ]*$$//' >> builtin
|
||||
${Q}cat builtin.end >> builtin
|
||||
${Q}echo "builtin help file formed"
|
||||
${Q} ${CAT} builtin.end >> builtin
|
||||
${Q} echo "builtin help file formed"
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the cat of help/$@ =-=-='; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
##
|
||||
@@ -585,17 +601,17 @@ builtin: builtin.top builtin.end ../func.c funclist.sed
|
||||
##
|
||||
|
||||
distlist: ${DISTLIST}
|
||||
${Q}for i in ${DISTLIST} /dev/null; do \
|
||||
${Q} for i in ${DISTLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo help/$$i; \
|
||||
fi; \
|
||||
done | LANG=C ${SORT}
|
||||
|
||||
distdir:
|
||||
${Q}echo help
|
||||
${Q} echo help
|
||||
|
||||
calcliblist:
|
||||
${Q}for i in ${CALCLIBLIST} /dev/null; do \
|
||||
${Q} for i in ${CALCLIBLIST} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo help/$$i; \
|
||||
fi; \
|
||||
@@ -606,21 +622,21 @@ calcliblist:
|
||||
# ignore this rule.
|
||||
#
|
||||
bsdi: all
|
||||
rm -f obj
|
||||
cp obj.file obj
|
||||
${RM} -f obj
|
||||
${CP} obj.file obj
|
||||
|
||||
# These next rule help me form the ${DETAIL_HELP} makefile variables above.
|
||||
#
|
||||
detaillist:
|
||||
${Q}-(echo "xxxxx"; \
|
||||
${Q} -(echo "xxxxx"; \
|
||||
for i in ${DETAIL_HELP} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
if [ ! -f RCS/$$i,v ]; then \
|
||||
echo "WARNING: $$i not under RCS control" 1>&2; \
|
||||
else \
|
||||
echo $$i; \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
if [ ! -f RCS/$$i,v ]; then \
|
||||
echo "WARNING: $$i not under RCS control" 1>&2; \
|
||||
else \
|
||||
echo $$i; \
|
||||
fi; \
|
||||
fi; \
|
||||
fi; \
|
||||
done | LANG=C ${SORT}) | ${FMT} -70 | \
|
||||
${SED} -e '1s/xxxxx/DETAIL_HELP=/' -e '2,$$s/^/ /' \
|
||||
-e 's/$$/ \\/' -e '$$s/ \\$$//'
|
||||
@@ -632,13 +648,13 @@ detaillist:
|
||||
##
|
||||
|
||||
echo_inst_files:
|
||||
${Q}for i in ${STD_HELP_FILES} full ${BLT_HELP_FILES} \
|
||||
${Q} for i in ${STD_HELP_FILES} full ${BLT_HELP_FILES} \
|
||||
builtin ${DETAIL_HELP} ${SINGULAR_FILES} /dev/null; do \
|
||||
if [ X"$$i" != X"/dev/null" ]; then \
|
||||
echo __file__ ${HELPDIR}/$$i; \
|
||||
fi; \
|
||||
done
|
||||
${Q}echo __file__ ${HELPDIR}/obj
|
||||
${Q} echo __file__ ${HELPDIR}/obj
|
||||
|
||||
##
|
||||
#
|
||||
@@ -647,67 +663,67 @@ echo_inst_files:
|
||||
##
|
||||
|
||||
clean:
|
||||
rm -f obj mkbuiltin funclist.c funclist.o funclist${EXT}
|
||||
rm -f COPYING COPYING-LGPL
|
||||
${RM} -f obj mkbuiltin funclist.c funclist.o funclist${EXT}
|
||||
${RM} -f COPYING COPYING-LGPL
|
||||
|
||||
clobber:
|
||||
rm -f ${BLT_HELP_FILES} full .all calc
|
||||
rm -f obj mkbuiltin funclist.c funclist.o funclist${EXT}
|
||||
rm -f COPYING COPYING-LGPL
|
||||
rm -f ${SINGULAR_FILES} ${DETAIL_CLONE}
|
||||
${RM} -f ${BLT_HELP_FILES} full .all calc
|
||||
${RM} -f obj mkbuiltin funclist.c funclist.o funclist${EXT}
|
||||
${RM} -f COPYING COPYING-LGPL
|
||||
${RM} -f ${SINGULAR_FILES} ${DETAIL_CLONE}
|
||||
|
||||
# install everything
|
||||
#
|
||||
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||
#
|
||||
install: all
|
||||
-${Q}if [ ! -d $T${CALC_SHAREDIR} ]; then \
|
||||
echo mkdir $T${CALC_SHAREDIR}; \
|
||||
mkdir $T${CALC_SHAREDIR}; \
|
||||
if [ ! -d "$T${CALC_SHAREDIR}" ]; then \
|
||||
echo mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
mkdir -p "$T${CALC_SHAREDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${CALC_SHAREDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${CALC_SHAREDIR}; \
|
||||
${MKDIR} ${T}${CALC_SHAREDIR}; \
|
||||
if [ ! -d "${T}${CALC_SHAREDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
||||
${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
${CHMOD} 0755 $T${CALC_SHAREDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
|
||||
${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}if [ ! -d $T${HELPDIR} ]; then \
|
||||
echo mkdir $T${HELPDIR}; \
|
||||
mkdir $T${HELPDIR}; \
|
||||
if [ ! -d "$T${HELPDIR}" ]; then \
|
||||
echo mkdir -p "$T${HELPDIR}"; \
|
||||
mkdir -p "$T${HELPDIR}"; \
|
||||
-${Q} if [ ! -d ${T}${HELPDIR} ]; then \
|
||||
echo ${MKDIR} ${T}${HELPDIR}; \
|
||||
${MKDIR} ${T}${HELPDIR}; \
|
||||
if [ ! -d "${T}${HELPDIR}" ]; then \
|
||||
echo ${MKDIR} -p "${T}${HELPDIR}"; \
|
||||
${MKDIR} -p "${T}${HELPDIR}"; \
|
||||
fi; \
|
||||
echo ${CHMOD} 0755 $T${HELPDIR}; \
|
||||
${CHMOD} 0755 $T${HELPDIR}; \
|
||||
echo ${CHMOD} 0755 ${T}${HELPDIR}; \
|
||||
${CHMOD} 0755 ${T}${HELPDIR}; \
|
||||
else \
|
||||
true; \
|
||||
${TRUE}; \
|
||||
fi
|
||||
-${Q}for i in ${STD_HELP_FILES} ${BLT_HELP_FILES} builtin \
|
||||
-${Q} for i in ${STD_HELP_FILES} ${BLT_HELP_FILES} builtin \
|
||||
full ${DETAIL_HELP} ${SINGULAR_FILES} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if ${CMP} -s $$i $T${HELPDIR}/$$i; then \
|
||||
true; \
|
||||
if ${CMP} -s $$i ${T}${HELPDIR}/$$i; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
rm -f $T${HELPDIR}/$$i.new; \
|
||||
cp -f $$i $T${HELPDIR}/$$i.new; \
|
||||
${CHMOD} 0444 $T${HELPDIR}/$$i.new; \
|
||||
mv -f $T${HELPDIR}/$$i.new $T${HELPDIR}/$$i; \
|
||||
echo "installed $T${HELPDIR}/$$i"; \
|
||||
${RM} -f ${T}${HELPDIR}/$$i.new; \
|
||||
${CP} -f $$i ${T}${HELPDIR}/$$i.new; \
|
||||
${CHMOD} 0444 ${T}${HELPDIR}/$$i.new; \
|
||||
${MV} -f ${T}${HELPDIR}/$$i.new ${T}${HELPDIR}/$$i; \
|
||||
echo "installed ${T}${HELPDIR}/$$i"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}if ${CMP} -s obj.file $T${HELPDIR}/obj; then \
|
||||
true; \
|
||||
-${Q} if ${CMP} -s obj.file ${T}${HELPDIR}/obj; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
rm -f $T${HELPDIR}/obj.new; \
|
||||
cp -f obj.file $T${HELPDIR}/obj.new; \
|
||||
${CHMOD} 0444 $T${HELPDIR}/obj.new; \
|
||||
mv -f $T${HELPDIR}/obj.new $T${HELPDIR}/obj; \
|
||||
echo "installed $T${HELPDIR}/obj"; \
|
||||
${RM} -f ${T}${HELPDIR}/obj.new; \
|
||||
${CP} -f obj.file ${T}${HELPDIR}/obj.new; \
|
||||
${CHMOD} 0444 ${T}${HELPDIR}/obj.new; \
|
||||
${MV} -f ${T}${HELPDIR}/obj.new ${T}${HELPDIR}/obj; \
|
||||
echo "installed ${T}${HELPDIR}/obj"; \
|
||||
fi
|
||||
|
||||
# Try to remove everything that was installed
|
||||
@@ -715,31 +731,31 @@ install: all
|
||||
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||
#
|
||||
uninstall:
|
||||
-${Q}if [ -f "$T${HELPDIR}/obj" ]; then \
|
||||
rm -f "$T${HELPDIR}/obj"; \
|
||||
if [ -f "$T${HELPDIR}/obj" ]; then \
|
||||
echo "cannot uninstall $T${HELPDIR}/obj"; \
|
||||
-${Q} if [ -f "${T}${HELPDIR}/obj" ]; then \
|
||||
${RM} -f "${T}${HELPDIR}/obj"; \
|
||||
if [ -f "${T}${HELPDIR}/obj" ]; then \
|
||||
echo "cannot uninstall ${T}${HELPDIR}/obj"; \
|
||||
else \
|
||||
echo "uninstalled $T${HELPDIR}/obj"; \
|
||||
echo "uninstalled ${T}${HELPDIR}/obj"; \
|
||||
fi; \
|
||||
fi
|
||||
-${Q}for i in ${SINGULAR_FILES} ${DETAIL_HELP} full builtin \
|
||||
-${Q} for i in ${SINGULAR_FILES} ${DETAIL_HELP} full builtin \
|
||||
${BLT_HELP_FILES} ${STD_HELP_FILES} /dev/null; do \
|
||||
if [ "$$i" = "/dev/null" ]; then \
|
||||
continue; \
|
||||
fi; \
|
||||
if [ -f "$T${HELPDIR}/$$i" ]; then \
|
||||
rm -f "$T${HELPDIR}/$$i"; \
|
||||
if [ -f "$T${HELPDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall $T${HELPDIR}/$$i"; \
|
||||
if [ -f "${T}${HELPDIR}/$$i" ]; then \
|
||||
${RM} -f "${T}${HELPDIR}/$$i"; \
|
||||
if [ -f "${T}${HELPDIR}/$$i" ]; then \
|
||||
echo "cannot uninstall ${T}${HELPDIR}/$$i"; \
|
||||
else \
|
||||
echo "uninstalled $T${HELPDIR}/$$i"; \
|
||||
echo "uninstalled ${T}${HELPDIR}/$$i"; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
-${Q}for i in ${HELPDIR} ${CALC_SHAREDIR}; do \
|
||||
if [ -d "$T$$i" ]; then \
|
||||
rmdir "$T$$i" 2>/dev/null; \
|
||||
echo "cleaned up $T$$i"; \
|
||||
-${Q} for i in ${HELPDIR} ${CALC_SHAREDIR}; do \
|
||||
if [ -d "${T}$$i" ]; then \
|
||||
${RMDIR} "${T}$$i" 2>/dev/null; \
|
||||
echo "cleaned up ${T}$$i"; \
|
||||
fi; \
|
||||
done
|
||||
|
@@ -178,7 +178,7 @@
|
||||
the hash value may change with different versions of the calculator.
|
||||
|
||||
The base function allows one to specify how numbers should be
|
||||
printer. The base function provides a numeric shorthand to the
|
||||
printed. The base function provides a numeric shorthand to the
|
||||
config("mode") interface. With no args, base() will return the
|
||||
current mode. With 1 arg, base(val) will set the mode according to
|
||||
the arg and return the previous mode.
|
||||
@@ -199,7 +199,7 @@
|
||||
For convenience, any non-integer value is assumed to mean "frac",
|
||||
and any integer >= 2^64 is assumed to mean "exp".
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
## Copyright (C) 1999-2007 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
|
||||
@@ -215,8 +215,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: builtin.end,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: builtin.end,v 29.3 2007/02/08 06:25:23 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/builtin.end,v $
|
||||
##
|
||||
## Under source code control: 1995/07/10 01:17:53
|
||||
|
16
help/config
16
help/config
@@ -68,6 +68,7 @@ DESCRIPTION
|
||||
"baseb" bits in calculation base, a read-only value
|
||||
"redecl_warn" TRUE => warn when redeclaring
|
||||
"dupvar_warn" TRUE => warn when variable names collide
|
||||
"hz" Read-only operating system tick rate or 0
|
||||
|
||||
The "all" config value allows one to save/restore the configuration
|
||||
set of values. The return of:
|
||||
@@ -867,6 +868,16 @@ DESCRIPTION
|
||||
|
||||
The initial "redecl_warn" value is 1.
|
||||
|
||||
=-=
|
||||
|
||||
config("hz") <== NOTE: This is a read-only config value
|
||||
|
||||
Returns the rate at which the operating system advances the clock
|
||||
on POSIX based systems. Returns 0 on non-POSIX based systems.
|
||||
The non-zero value returned is in Hetrz.
|
||||
|
||||
This config parameter is read-only and cannot be set.
|
||||
|
||||
|
||||
EXAMPLE
|
||||
; current_cfg = config("all");
|
||||
@@ -928,6 +939,7 @@ EXAMPLE
|
||||
baseb 32
|
||||
redecl_warn 1
|
||||
dupvar_warn 1
|
||||
hz 100
|
||||
|
||||
; display()
|
||||
20
|
||||
@@ -960,8 +972,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.17 $
|
||||
## @(#) $Id: config,v 29.17 2006/06/24 19:06:58 chongo Exp $
|
||||
## @(#) $Revision: 29.18 $
|
||||
## @(#) $Id: config,v 29.18 2006/12/16 11:14:28 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/config,v $
|
||||
##
|
||||
## Under source code control: 1991/07/21 04:37:17
|
||||
|
63
help/cp
63
help/cp
@@ -1,63 +0,0 @@
|
||||
NAME
|
||||
cp - cross product of two 3 element vectors
|
||||
|
||||
SYNOPSIS
|
||||
cp(x, y)
|
||||
|
||||
TYPES
|
||||
x, y 1-dimensional matrices with 3 elements
|
||||
|
||||
return 1-dimensional matrix with 3 elements
|
||||
|
||||
DESCRIPTION
|
||||
Calculate the product of two 3 1-dimensional matrices.
|
||||
If x has elements (x0, x1, x2), and y has elements (y0, y1, y2),
|
||||
cp(x,y) returns the matrix of type [0:2] with elements:
|
||||
|
||||
{x1 * y2 - x2 * y1, x3 * y1 - x1 * y3, x1 * y2 - x2 * y1}
|
||||
|
||||
EXAMPLE
|
||||
; mat x[3] = {2,3,4}
|
||||
; mat y[3] = {3,4,5}
|
||||
; print cp(x,y)
|
||||
|
||||
mat [3] (3 elements, 3 nonzero):
|
||||
[0] = -1
|
||||
[1] = 2
|
||||
[2] = -1
|
||||
|
||||
LIMITS
|
||||
The components of the matrices are to be of types for which the
|
||||
required algebraic operations have been defined.
|
||||
|
||||
LINK LIBRARY
|
||||
MATRIX *matcross(MATRIX *x, MATRIX *y)
|
||||
|
||||
SEE ALSO
|
||||
dp
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: cp,v 29.3 2006/05/07 07:25:46 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/cp,v $
|
||||
##
|
||||
## Under source code control: 1995/10/05 04:52:26
|
||||
## File existed as early as: 1995
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
45
help/estr
Normal file
45
help/estr
Normal 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
|
||||
|
@@ -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
72
help/fgetfile
Normal 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/
|
24
help/fputs
24
help/fputs
@@ -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
|
||||
|
36
help/help
36
help/help
@@ -51,15 +51,6 @@ following topics:
|
||||
|
||||
full all of the above (in the above order)
|
||||
|
||||
You can also ask for help on a particular function name. For example,
|
||||
|
||||
help asinh
|
||||
help round
|
||||
|
||||
or on a particular symbol such as:
|
||||
|
||||
help =
|
||||
|
||||
For example:
|
||||
|
||||
help usage
|
||||
@@ -71,6 +62,27 @@ without invoking any startup code by running calc as follows:
|
||||
|
||||
where 'topic' is one of the topics listed above.
|
||||
|
||||
You can also ask for help on a particular builtin function name. For example:
|
||||
|
||||
help asinh
|
||||
help round
|
||||
|
||||
See:
|
||||
|
||||
help builtin
|
||||
|
||||
for a list of builtin functions.
|
||||
|
||||
Some calc operators have their own help pages:
|
||||
|
||||
help =
|
||||
help ->
|
||||
help *
|
||||
help .
|
||||
help %
|
||||
help //
|
||||
help #
|
||||
|
||||
If the -m mode disallows opening files for reading or execution of programs,
|
||||
then the help facility will be disabled. See:
|
||||
|
||||
@@ -103,7 +115,7 @@ as the same effect as:
|
||||
|
||||
custom("help", "anything");
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
## Copyright (C) 1999-2007 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
|
||||
@@ -119,8 +131,8 @@ as the same effect as:
|
||||
## 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: help,v 29.3 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: help,v 29.4 2007/02/07 00:30:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/help,v $
|
||||
##
|
||||
## Under source code control: 1991/07/21 04:37:20
|
||||
|
@@ -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
|
||||
|
127
help/pound
Normal file
127
help/pound
Normal file
@@ -0,0 +1,127 @@
|
||||
NAME
|
||||
#
|
||||
|
||||
SYNOPSIS
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
# x
|
||||
x # y
|
||||
## comment
|
||||
|
||||
TYPES
|
||||
x, y integer or real
|
||||
|
||||
return integer (uniary operator case)
|
||||
integer or real (binary operator case)
|
||||
|
||||
DESCRIPTION
|
||||
The pound sign or sharp sign "#" has special meaning in calc.
|
||||
|
||||
As a uniary operator:
|
||||
|
||||
# value
|
||||
|
||||
returns the number of 1 bits, or pop-count of the absolute value of
|
||||
the numerator (abs(num(value))). Therefore when x is a non-negative
|
||||
integer , # x is the pop-count of x. And thus when x is a negative
|
||||
integer, # x returns the pop-count of abs(x). And in the general
|
||||
case when x is a real, # x returns the pop-count of abs(num(x)).
|
||||
|
||||
As a binary operator:
|
||||
|
||||
x # y
|
||||
|
||||
returns abs(x-y), the absolute value of the difference.
|
||||
|
||||
When two or more pound signs in a row start a comment:
|
||||
|
||||
## this is a comment
|
||||
### this is also a comment
|
||||
print "this will print"; ## but this will not because it is a comment
|
||||
|
||||
A pound sign followed by a bang also starts a comment:
|
||||
|
||||
#! strictly speaking, this is a comment
|
||||
print "this is correct but not recommended" #! acts like ##
|
||||
|
||||
On POSIX / Un*X / Linux / BSD conforming systems, when an executable
|
||||
starts with the two bytes # and !, the remainder of the 1st line
|
||||
(up to an operating system imposed limit) is taken to be the path
|
||||
to the shell (plus shell arguments) that is to be executed. The
|
||||
kernel appends the filename of the executable as a final argument
|
||||
to the shell.
|
||||
|
||||
For example, of an executable file contains:
|
||||
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
/* NOTE: The #! above must start in column 1 of the 1st line */
|
||||
/* The 1st line must end with -f */
|
||||
## Single # shell comments don't work, use two or more
|
||||
print "2+2 =", 2+2;
|
||||
|
||||
When the above file it is executed by the kernel, it will print:
|
||||
|
||||
2+2 = 4
|
||||
|
||||
Such files are known to calc as cscripts. See "help cscript"
|
||||
for examples.
|
||||
|
||||
It is suggested that the -q be added to the first line to
|
||||
disable the reading of the startup scripts. It is not mandatory.
|
||||
|
||||
The last argument of the first line must be -f without the filename
|
||||
because the kernel will supply the cscript filename as a final
|
||||
argument. The final -f also implies -s. See "help usage" for
|
||||
more information.
|
||||
|
||||
|
||||
EXAMPLE
|
||||
; #3
|
||||
2
|
||||
; #3.5
|
||||
3
|
||||
; 4 # 5
|
||||
1
|
||||
; 5 # 4
|
||||
1
|
||||
|
||||
; pi() # exp(1)
|
||||
0.4233108251307480031
|
||||
; exp(1) # pi()
|
||||
0.4233108251307480031
|
||||
|
||||
; ## this is a comment
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
cscript, unexpected, usage
|
||||
|
||||
## Copyright (C) 2007 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: pound,v 29.1 2007/02/06 23:48:15 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/pound,v $
|
||||
##
|
||||
## Under source code control: 2007/02/06 14:09
|
||||
## File existed as early as: 2007
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
90
help/quomod
90
help/quomod
@@ -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
|
||||
|
30
help/runtime
30
help/runtime
@@ -1,5 +1,5 @@
|
||||
NAME
|
||||
runtime - user runtime
|
||||
runtime - CPU time used by the current process in both user and kernel modes
|
||||
|
||||
SYNOPSIS
|
||||
runtime()
|
||||
@@ -8,27 +8,33 @@ TYPES
|
||||
return nonnegative real
|
||||
|
||||
DESCRIPTION
|
||||
Returns the current user mode cpu runtime in seconds.
|
||||
In POSIX based systems, this function will return the CPU seconds
|
||||
used by the current process in both user and kernel mode. Time
|
||||
spent in the kernel executing system calls and time spend executing
|
||||
user code (such as performing computation on behalf of calc) are
|
||||
both included.
|
||||
|
||||
On non-POSIX based systems, this function will always return 0.
|
||||
In particular, most MS windows based systems do not have the required
|
||||
POSIX system call and so this function will always return 0.
|
||||
|
||||
EXAMPLE
|
||||
|
||||
The result for this example will depend on the speed and number of
|
||||
of clock-ticks per second for the computer being used. The result
|
||||
is a multiple of 1/CLK_TCK, where CLK_TCK is usually 60, 100, or 1000.
|
||||
The result for this example will depend on the speed of the CPU
|
||||
and precision of the operating CPU time accounting sub-system:
|
||||
|
||||
; t = runtime();
|
||||
; pi = pi(1e-1000);
|
||||
; x = ptest(2^4253-1);
|
||||
; runtime() - t;
|
||||
.2
|
||||
1.288804
|
||||
|
||||
LIMITS
|
||||
none
|
||||
On non-POSIX based systems, this function always returns 0.
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
ctime, time
|
||||
config, ctime, systime, time, usertime
|
||||
|
||||
## Copyright (C) 1999-2006 Landon Curt Noll
|
||||
##
|
||||
@@ -46,8 +52,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: runtime,v 29.5 2006/06/25 22:16:55 chongo Exp $
|
||||
## @(#) $Revision: 29.7 $
|
||||
## @(#) $Id: runtime,v 29.7 2006/12/16 10:52:27 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/runtime,v $
|
||||
##
|
||||
## Under source code control: 1996/03/12 23:10:01
|
||||
|
109
help/statement
109
help/statement
@@ -3,22 +3,76 @@ Statements
|
||||
Statements are very much like C statements. Most statements act
|
||||
identically to those in C, but there are minor differences and
|
||||
some additions. The following is a list of the statement types,
|
||||
with explanation of the non-C statements. In this list, upper
|
||||
case words identify the keywords which are actually in lower case.
|
||||
Statements are generally terminated with semicolons, except if the
|
||||
statement is the compound one formed by matching braces. Various
|
||||
expressions are optional and may be omitted (as in RETURN).
|
||||
with explanation of the non-C statements.
|
||||
|
||||
Statements are generally terminated with semicolons or { ... }.
|
||||
|
||||
C-like statements
|
||||
-----------------
|
||||
{ statement }
|
||||
{ statement; ... statement }
|
||||
|
||||
|
||||
C-like flow control
|
||||
-------------------
|
||||
if (expr) statement
|
||||
if (expr) statement ELSE statement
|
||||
if (expr) statement else statement
|
||||
for (optionalexpr ; optionalexpr ; optionalexpr) statement
|
||||
while (expr) statement
|
||||
do statement while (expr)
|
||||
|
||||
These all work like in normal C.
|
||||
|
||||
IMPORTANT NOTE: When statement is of the form { ... },
|
||||
the leading { must be on the same line as the if, for,
|
||||
while or do keyword.
|
||||
|
||||
This works as expected:
|
||||
|
||||
if (expr) {
|
||||
...
|
||||
}
|
||||
|
||||
However this WILL NOT WORK AS EXPECTED:
|
||||
|
||||
if (expr)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
because calc will parse the if being terminated by
|
||||
an empty statement followed by a
|
||||
|
||||
if (expr) ;
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
In the same way, use these forms:
|
||||
|
||||
for (optionalexpr ; optionalexpr ; optionalexpr) {
|
||||
...
|
||||
}
|
||||
|
||||
while (expr) {
|
||||
...
|
||||
}
|
||||
|
||||
do {
|
||||
...
|
||||
while (expr);
|
||||
|
||||
where the initial { is on the SAME LINE as the if, while,
|
||||
for or do.
|
||||
|
||||
See 'help expression' for details on expressions.
|
||||
See 'help builtin' for details on calc builtin functions.
|
||||
See 'help unexpanded' for things C programmers do not expect.
|
||||
See also 'help todo' and 'help bugs'.
|
||||
|
||||
|
||||
C-like flow breaks
|
||||
------------------
|
||||
continue
|
||||
break
|
||||
goto label
|
||||
@@ -30,8 +84,9 @@ Statements
|
||||
|
||||
return
|
||||
------
|
||||
return optionalexpr
|
||||
return ( optionalexpr )
|
||||
return
|
||||
return expr
|
||||
return ( expr )
|
||||
This returns a value from a function. Functions always
|
||||
have a return value, even if this statement is not used.
|
||||
If no return statement is executed, or if no expression
|
||||
@@ -236,12 +291,36 @@ Statements
|
||||
|
||||
Also see the help topic:
|
||||
|
||||
command top level commands
|
||||
expression calc expression syntax
|
||||
builtin calc builtin functions
|
||||
usage how to invoke the calc command and calc -options
|
||||
help command top level commands
|
||||
help expression calc expression syntax
|
||||
help builtin calc builtin functions
|
||||
help usage how to invoke the calc command and calc -options
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
You may obtain help on individual builtin functions. For example:
|
||||
|
||||
help asinh
|
||||
help round
|
||||
|
||||
See:
|
||||
help builtin
|
||||
|
||||
for a list of builtin functions.
|
||||
|
||||
Some calc operators have their own help pages:
|
||||
|
||||
help ->
|
||||
help *
|
||||
help .
|
||||
help %
|
||||
help //
|
||||
help #
|
||||
|
||||
See also:
|
||||
|
||||
help help
|
||||
|
||||
|
||||
## Copyright (C) 1999-2007 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
|
||||
@@ -257,8 +336,8 @@ Statements
|
||||
## 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: statement,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: statement,v 29.4 2007/02/07 00:29:06 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/statement,v $
|
||||
##
|
||||
## Under source code control: 1991/07/21 04:37:23
|
||||
|
63
help/systime
Normal file
63
help/systime
Normal file
@@ -0,0 +1,63 @@
|
||||
NAME
|
||||
systime - kernel CPU time used by the current process
|
||||
|
||||
SYNOPSIS
|
||||
systime()
|
||||
|
||||
TYPES
|
||||
return nonnegative real
|
||||
|
||||
DESCRIPTION
|
||||
In POSIX based systems, this function will return the CPU seconds
|
||||
used by the current process while in kernel mode executing kernel
|
||||
code on behalf of the current process. Time spent by the current
|
||||
process executing user code (such as performing computation on
|
||||
behalf of calc) is not counted.
|
||||
|
||||
On non-POSIX based systems, this function will always return 0.
|
||||
In particular, most MS windows based systems do not have the required
|
||||
POSIX system call and so this function will always return 0.
|
||||
|
||||
EXAMPLE
|
||||
The result for this example will depend on the speed of the CPU
|
||||
and precision of the operating CPU time accounting sub-system:
|
||||
|
||||
; t = systime();
|
||||
; system("true"),
|
||||
; systime() - t;
|
||||
.001
|
||||
|
||||
LIMITS
|
||||
On non-POSIX based systems, this function always returns 0.
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
config, ctime, runtime, systime, time
|
||||
|
||||
## Copyright (C) 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.3 $
|
||||
## @(#) $Id: systime,v 29.3 2006/12/16 10:53:01 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/systime,v $
|
||||
##
|
||||
## Under source code control: 2006/12/16 10:31:08
|
||||
## File existed as early as: 2006
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
69
help/todo
69
help/todo
@@ -24,14 +24,32 @@ Calc Todo Items:
|
||||
|
||||
Very High priority items:
|
||||
|
||||
* Consider using GNU autoconf / configure to build calc.
|
||||
* Improve the way that calc parses statements such as if, for, while
|
||||
and do so that when a C programmer does. This works as expected:
|
||||
|
||||
* Internationalize calc by converting calc error messages and
|
||||
text strings (e.g., calc startup banner, show output, etc.)
|
||||
into calls to the GNU gettext internationalization facility.
|
||||
If somebody translated these strings into another language,
|
||||
setting $LANG would allow calc to produce error messages
|
||||
and text strings in that language.
|
||||
if (expr) {
|
||||
...
|
||||
}
|
||||
|
||||
However this WILL NOT WORK AS EXPECTED:
|
||||
|
||||
if (expr)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
because calc will parse the if being terminated by
|
||||
an empty statement followed by a
|
||||
|
||||
if (expr) ;
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
See also "help statement", "help unexpected", "help todo", and
|
||||
"help bugs".
|
||||
|
||||
* Consider using GNU autoconf / configure to build calc.
|
||||
|
||||
* Fix any 'Known bugs' as noted in the BUGS file or as
|
||||
displayed by 'calc help bugs'.
|
||||
@@ -54,36 +72,17 @@ High priority items:
|
||||
* Address, if possible and reasonable, any Calc Mis-features
|
||||
as noted in the BUGS file or as displayed by 'calc help bugs'.
|
||||
|
||||
* Internationalize calc by converting calc error messages and
|
||||
text strings (e.g., calc startup banner, show output, etc.)
|
||||
into calls to the GNU gettext internationalization facility.
|
||||
If somebody translated these strings into another language,
|
||||
setting $LANG would allow calc to produce error messages
|
||||
and text strings in that language.
|
||||
|
||||
=-=
|
||||
|
||||
Medium priority items:
|
||||
|
||||
* Review and if needed, correct/update the help topics:
|
||||
|
||||
topic description
|
||||
----- -----------
|
||||
intro introduction to calc
|
||||
overview overview of calc
|
||||
assoc using associations
|
||||
command top level commands
|
||||
define how to define functions
|
||||
environment how environment variables effect calc
|
||||
errorcodes calc generated error codes
|
||||
expression expression sequences
|
||||
file using files
|
||||
history command history
|
||||
interrupt how interrupts are handled
|
||||
list using lists
|
||||
obj user defined data types
|
||||
operator math, relational, logic and variable access ...
|
||||
statement flow control and declaration statements
|
||||
types builtin data types
|
||||
unexpected unexpected syntax/usage surprises for C ...
|
||||
variable variables and variable declarations
|
||||
libcalc using the arbitrary precision routines in ...
|
||||
bugs known bugs and mis-features
|
||||
wishlist wish list of future enhancements of calc
|
||||
|
||||
* Complete the use of CONST where appropriate:
|
||||
|
||||
CONST is beginning to be used with read-only tables and some
|
||||
@@ -130,8 +129,8 @@ Medium priority items:
|
||||
## 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.8 $
|
||||
## @(#) $Id: todo,v 29.8 2006/05/21 07:50:11 chongo Exp $
|
||||
## @(#) $Revision: 29.10 $
|
||||
## @(#) $Id: todo,v 29.10 2007/01/03 21:26:22 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/todo,v $
|
||||
##
|
||||
## Under source code control: 1999/10/20 07:42:55
|
||||
|
@@ -248,7 +248,78 @@ Unexpected
|
||||
In addition to the C style /* comment lines */, lines that begin with
|
||||
#! are treated as comments.
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
A single # is an calc operator, not a comment. However two or more
|
||||
##'s in a row is a comment. See "help pound" for more information.
|
||||
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
|
||||
/* a correct comment */
|
||||
## another correct comment
|
||||
### two or more together is also a comment
|
||||
/*
|
||||
* another correct comment
|
||||
*/
|
||||
print "2+2 =", 2+2; ## yet another comment
|
||||
|
||||
This next example is WRONG:
|
||||
|
||||
#!/usr/local/src/cmd/calc/calc -q -f
|
||||
|
||||
# This is not a calc calc comment because it has only a single #
|
||||
# You must to start comments with ## or /*
|
||||
print "This example has invalid comments"
|
||||
|
||||
See "help cscript" and "help usage" for more information.
|
||||
|
||||
|
||||
The { must be on the same line as an if, for, while or do
|
||||
=========================================================
|
||||
|
||||
When statement is of the form { ... }, the leading { MUST BE ON
|
||||
THE SAME LINE as the if, for, while or do keyword.
|
||||
|
||||
This works as expected:
|
||||
|
||||
if (expr) {
|
||||
...
|
||||
}
|
||||
|
||||
However this WILL NOT WORK AS EXPECTED:
|
||||
|
||||
if (expr)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
because calc will parse the if being terminated by
|
||||
an empty statement followed by a
|
||||
|
||||
if (expr) ;
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
In the same way, use these forms:
|
||||
|
||||
for (optionalexpr ; optionalexpr ; optionalexpr) {
|
||||
...
|
||||
}
|
||||
|
||||
while (expr) {
|
||||
...
|
||||
}
|
||||
|
||||
do {
|
||||
...
|
||||
while (expr);
|
||||
|
||||
where the initial { is on the SAME LINE as the if, while,
|
||||
for or do keyword.
|
||||
|
||||
NOTE: See "help statement", "help todo", and "help bugs".
|
||||
|
||||
|
||||
## 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
|
||||
@@ -264,8 +335,8 @@ Unexpected
|
||||
## 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: unexpected,v 29.2 2000/06/07 14:02:33 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: unexpected,v 29.4 2007/02/07 00:30:33 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/unexpected,v $
|
||||
##
|
||||
## Under source code control: 1997/03/21 13:15:18
|
||||
|
370
help/usage
370
help/usage
@@ -1,370 +0,0 @@
|
||||
Calc command line
|
||||
|
||||
Calc has the following command line:
|
||||
|
||||
calc [-c] [-C] [-d] [-D calc_debug[:resource_debug[:user_debug]]]
|
||||
[-e] [-h] [-i] [-m mode] [-n] [-p] [-q] [-s] [-u] [-v]
|
||||
[calc_cmd ...]
|
||||
|
||||
#!/usr/local/bin/calc -S [other_flags]
|
||||
|
||||
-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 syntax error, whereas:
|
||||
|
||||
calc -c read many_errors.cal
|
||||
|
||||
will cause calc to try to process each line being read
|
||||
despite the scan/parse errors that it encounters.
|
||||
|
||||
By default, calc startup resource files are
|
||||
silently ignored if not found. This flag will report
|
||||
missing startup scripts unless -d is also given.
|
||||
|
||||
|
||||
-C Permit the execution of custom builtin functions.
|
||||
Without this flag, calling the custom() builtin
|
||||
function will simply generate an error.
|
||||
|
||||
Use of this flag may cause calc to execute functions
|
||||
that are non-standard and that are not portable.
|
||||
Custom builtin functions are disabled by default for
|
||||
this reason.
|
||||
|
||||
|
||||
-d Disable the printing of the opening title. The
|
||||
printing of resource file debug and informational messages is
|
||||
also disabled as if config("resource_debug", 0) had been
|
||||
executed.
|
||||
|
||||
For example:
|
||||
|
||||
calc 'read qtime; qtime(2)'
|
||||
|
||||
will output something like:
|
||||
|
||||
qtime(utc_hr_offset) defined
|
||||
It's nearly ten past six.
|
||||
|
||||
whereas:
|
||||
|
||||
calc -d 'read qtime; qtime(2)'
|
||||
|
||||
will just say:
|
||||
|
||||
It's nearly ten past six.
|
||||
|
||||
This flag disables the reporting of missing calc
|
||||
startup scripts.
|
||||
|
||||
|
||||
-D calc_debug[:resource_debug:[user_debug]]
|
||||
Force the initial value of config("calc_debug"),
|
||||
config("resource_debug") and config("user_debug").
|
||||
|
||||
The : separated strings are interpreted as signed 32
|
||||
bit integers. After an optional leading sign a leading
|
||||
zero indicates octal conversion, and a leading ``0x''
|
||||
or ``0X'' hexadecimal conversion. Otherwise, decimal
|
||||
conversion is assumed.
|
||||
|
||||
By default, calc_debug is 0, resource_debug is 3 and
|
||||
user_debug is 0.
|
||||
|
||||
For more information use the following calc command:
|
||||
|
||||
help config
|
||||
|
||||
|
||||
-e Ignore any environment variables on startup. The
|
||||
getenv() builtin will still return values, however.
|
||||
|
||||
|
||||
-h Print a help message. This option implies -q. This is
|
||||
equivalent to the calc command help help. The help
|
||||
facility is disabled unless the mode is 5 or 7. See
|
||||
-m.
|
||||
|
||||
|
||||
-i Become interactive if possible. If calc_cmd args are given,
|
||||
by default, calc will execute them and exit. This flag causes
|
||||
calc to drop into interactive mode after the commands are
|
||||
executed.
|
||||
|
||||
For example:
|
||||
|
||||
calc 2+5
|
||||
|
||||
will print the value 7 and exit whereas:
|
||||
|
||||
calc -i 2+5
|
||||
|
||||
will print the value 7 and prompt the user for more
|
||||
calc commands.
|
||||
|
||||
|
||||
-m mode
|
||||
This flag sets the permission mode of calc. It
|
||||
controls the ability for calc to open files and execute
|
||||
programs. Mode may be a number from 0 to 7.
|
||||
|
||||
The mode value is interpreted in a way similar to that
|
||||
of the chmod(1) octal mode:
|
||||
|
||||
0 do not open any file, do not execute progs
|
||||
1 do not open any file
|
||||
2 do not open files for reading, do not execute progs
|
||||
3 do not open files for reading
|
||||
4 do not open files for writing, do not execute progs
|
||||
5 do not open files for writing
|
||||
6 do not execute any program
|
||||
7 allow everything (default mode)
|
||||
|
||||
If one wished to run calc from a privileged user, one
|
||||
might want to use -m 0 in an effort to make calc
|
||||
somewhat more secure.
|
||||
|
||||
Mode bits for reading and writing apply only on an
|
||||
open. Files already open are not effected. Thus if
|
||||
one wanted to use the -m 0 in an effort to make calc
|
||||
somewhat more secure, but still wanted to read and
|
||||
write a specific file, one might want to do in sh(1),
|
||||
ksh(1), bash(1)-like shells:
|
||||
|
||||
calc -m 0 3<a.file
|
||||
|
||||
Files presented to calc in this way are opened in an
|
||||
unknown mode. Calc will attempt to read or write them
|
||||
if directed.
|
||||
|
||||
If the mode disables opening of files for reading, then
|
||||
the startup resource files are disabled as if -q was
|
||||
given. The reading of key bindings is also disabled
|
||||
when the mode disables opening of files for reading.
|
||||
|
||||
|
||||
-O Use the old classic defaults instead of the default
|
||||
configuration. This flag as the same effect as executing
|
||||
config("all", "oldcfg") at startup time.
|
||||
|
||||
NOTE: Older versions of calc used -n to setup a modified
|
||||
form of the default calc configuration. The -n flag
|
||||
currently does nothing. Use of the -n flag is now
|
||||
deprecated and may used for something else in the future.
|
||||
|
||||
-p Pipe processing is enabled by use of -p. For example:
|
||||
|
||||
calc -p '2^21701-1' | fizzbin
|
||||
|
||||
In pipe mode, calc does not prompt, does not print
|
||||
leading tabs and does not print the initial header.
|
||||
The -p flag overrides -i.
|
||||
|
||||
|
||||
-q Disable the reading of the startup scripts.
|
||||
|
||||
|
||||
-s By default, all calc_cmd args are evaluated and
|
||||
executed. This flag will disable their evaluation and
|
||||
instead make them available as strings for the argv()
|
||||
builtin function.
|
||||
|
||||
|
||||
-u Disable buffering of stdin and stdout.
|
||||
|
||||
|
||||
-v Print the calc version number and exit.
|
||||
|
||||
|
||||
CALC COMMAND ARGUMENTS
|
||||
|
||||
With no calc_cmd arguments, calc operates interactively. If one
|
||||
or more arguments are given on the command line and -s is NOT
|
||||
given, then calc will read and execute them and either attempt
|
||||
to go interactive according as the -i flag was present or absent.
|
||||
|
||||
If -s is given, calc will not evaluate any calc_cmd
|
||||
arguments but instead make them available as strings to the
|
||||
argv() builtin function.
|
||||
|
||||
Sufficiently simple commands with no no characters like
|
||||
parentheses, brackets, semicolons, '*', which have special
|
||||
interpretations in UNIX commands may be entered, possibly with
|
||||
spaces, until the terminating newline. For example:
|
||||
|
||||
calc 23 + 47
|
||||
|
||||
should respond with display of 70, but:
|
||||
|
||||
calc 23 * 47
|
||||
|
||||
may fail. Such cases can usually be made to work as expected by
|
||||
enclosing the command between single quotation marks as in:
|
||||
|
||||
calc '23 * 47'
|
||||
|
||||
and
|
||||
|
||||
calc 'print sqrt(2), exp(1)'
|
||||
|
||||
If '!' is to be used to indicate the factorial function, for
|
||||
shells like csh for which '!' followed by a non-space character
|
||||
is used for history substitution, it may be necessary to
|
||||
include a space or use a backslash to escape the special
|
||||
meaning of '!'. For example, the command "print 27!^2" may have
|
||||
to be replaced by "print 27! ^2" or "print 27\!^2".
|
||||
|
||||
|
||||
CALC STARTUP FILES
|
||||
|
||||
Normally on startup, if the environment variable $CALCRC is
|
||||
undefined and calc is invoked without the -q flag, or if
|
||||
$CALCRC is defined and calc is invoked with -e, calc looks
|
||||
for a file "startup" in the calc resource directory, .calcrc in
|
||||
the user's home directory, and .calcinit in the current directory.
|
||||
If one or more of these are found, they are read in succession
|
||||
as calc scripts and their commands executed. When defined,
|
||||
$CALCRC is to contain a ':' separated list of names of files,
|
||||
and if calc is then invoked without either the -q or -e flags,
|
||||
these files are read in succession and their commands executed.
|
||||
No error condition is produced if a listed file is not found.
|
||||
|
||||
If the mode specified by -m disables opening of files for
|
||||
reading, then the reading of startup files is also disabled
|
||||
as if -q was given.
|
||||
|
||||
|
||||
CALC FILE SEARCH PATH
|
||||
|
||||
If the environment variable $CALCPATH is undefined, or if it
|
||||
is defined and calc is invoked with the -e flag, when a file
|
||||
name not beginning with /, ~ or ./, is specified as in:
|
||||
|
||||
calc read myfile
|
||||
|
||||
calc searches in succession:
|
||||
|
||||
./myfile
|
||||
./myfile.cal
|
||||
${LIBDIR}/myfile
|
||||
${LIBDIR}/myfile.cal
|
||||
${CUSTOMCALDIR}/myfile
|
||||
${CUSTOMCALDIR}/myfile.cal
|
||||
|
||||
If the file is found, the search stops and the commands in
|
||||
the file are executed. It is an error if no readable file
|
||||
with the specified name is found. An alternative search
|
||||
path can be specified by defining $CALCPATH in the same way
|
||||
as PATH is defined, as a ':' separated list of directories,
|
||||
and then invoking calc without the -e flag.
|
||||
|
||||
Calc treats all open files, other than stdin, stdout and
|
||||
stderr as files available for reading and writing. One may
|
||||
present calc with an already open file using sh(1), ksh(1),
|
||||
bash(1)-like shells is to:
|
||||
|
||||
calc 3<open_file 4<open_file2
|
||||
|
||||
|
||||
SHELL SCRIPT MODE
|
||||
|
||||
If first line of an executable file begins #! followed by the
|
||||
absolute pathname of the calc program and the flag -S as in
|
||||
|
||||
#!/usr/local/bin/calc -S [other_flags]
|
||||
|
||||
the rest of the file will be processed in shell script mode.
|
||||
Note that -S (UPPER CASE S) must be the first -flag on the
|
||||
``#!'' line. Any optional ``other_flags'' must come after
|
||||
the -S.
|
||||
|
||||
In shell script mode the contents of the file are read and
|
||||
executed as if they were in a file being processed by a read
|
||||
command, except that a "command" beginning with '#' followed by
|
||||
whitespace and ending at the next newline is treated as a comment.
|
||||
Any optional ``other_flags'' will be parsed first followed by
|
||||
the later lines within the script itself.
|
||||
|
||||
In shell script mode, -s (lower case s) is always assumed.
|
||||
In addition, -d and -p are automatically set if -i is not
|
||||
given.
|
||||
|
||||
For example, if the file /tmp/mersenne:
|
||||
|
||||
#!/usr/local/bin/calc -S -q
|
||||
#
|
||||
# mersenne - an example of a calc shell script file
|
||||
|
||||
/* parse args */
|
||||
if (argv() != 1) {
|
||||
fprintf(files(2), "usage: %s exp\n", config("program"));
|
||||
abort "must give one exponent arg";
|
||||
}
|
||||
|
||||
/* print the mersenne number */
|
||||
print "2^": argv(0) : "-1 =", 2^eval(argv(0))-1;
|
||||
|
||||
is made an executable file by:
|
||||
|
||||
chmod +x /tmp/mersenne
|
||||
|
||||
then the command line:
|
||||
|
||||
/tmp/mersenne 127
|
||||
|
||||
will print:
|
||||
|
||||
2^127-1 = 170141183460469231731687303715884105727
|
||||
|
||||
Note that because -s is assumed in shell script mode and
|
||||
non-dashed args are made available as strings via the argv()
|
||||
builtin function. Therefore:
|
||||
|
||||
2^eval(argv(0))-1
|
||||
|
||||
will print the decimal value of 2^n-1 but
|
||||
|
||||
2^argv(0)-1
|
||||
|
||||
will not.
|
||||
|
||||
For more information use the following calc commands:
|
||||
|
||||
help help
|
||||
help overview
|
||||
help config
|
||||
help argv
|
||||
help environment
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.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
|
||||
## File existed as early as: 1991
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
61
help/usertime
Normal file
61
help/usertime
Normal file
@@ -0,0 +1,61 @@
|
||||
NAME
|
||||
usertime - user CPU time used by the current process
|
||||
|
||||
SYNOPSIS
|
||||
usertime()
|
||||
|
||||
TYPES
|
||||
return nonnegative real
|
||||
|
||||
DESCRIPTION
|
||||
In POSIX based systems, this function will return the CPU seconds
|
||||
used by the current process while in user mode. Time spent in the
|
||||
kernel executing system calls is not included.
|
||||
|
||||
On non-POSIX based systems, this function will always return 0.
|
||||
In particular, most MS windows based systems do not have the required
|
||||
POSIX system call and so this function will always return 0.
|
||||
|
||||
EXAMPLE
|
||||
The result for this example will depend on the speed of the CPU
|
||||
and precision of the operating CPU time accounting sub-system:
|
||||
|
||||
; t = usertime();
|
||||
; x = ptest(2^4253-1);
|
||||
; usertime() - t;
|
||||
1.287804
|
||||
|
||||
LIMITS
|
||||
On non-POSIX based systems, this function always returns 0.
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
config, ctime, usertime, systime, time
|
||||
|
||||
## Copyright (C) 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: usertime,v 29.2 2006/12/16 10:50:19 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/usertime,v $
|
||||
##
|
||||
## Under source code control: 2006/12/16 10:31:08
|
||||
## File existed as early as: 2006
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
@@ -139,8 +139,6 @@ Variable declarations
|
||||
arguments as addresses, there is no gain in using the backquote when
|
||||
calling these functions.
|
||||
|
||||
XXX - this file needs to be updated to be in sync with calc source code.
|
||||
|
||||
## Copyright (C) 1999-2006 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
@@ -157,8 +155,8 @@ Variable declarations
|
||||
## 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: variable,v 29.4 2006/06/25 23:07:08 chongo Exp $
|
||||
## @(#) $Revision: 29.5 $
|
||||
## @(#) $Id: variable,v 29.5 2006/09/17 20:54:07 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/variable,v $
|
||||
##
|
||||
## Under source code control: 1991/07/21 04:37:25
|
||||
|
278
hist.c
278
hist.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* hist - interactive readline module
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.12 $
|
||||
* @(#) $Id: hist.c,v 29.12 2006/06/02 09:57:12 chongo Exp $
|
||||
* @(#) $Revision: 29.13 $
|
||||
* @(#) $Id: hist.c,v 29.13 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/hist.c,v $
|
||||
*
|
||||
* Under source code control: 1993/05/02 20:09:19
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
#if !defined(USE_READLINE)
|
||||
|
||||
extern FILE *curstream(void);
|
||||
E_FUNC FILE *curstream(void);
|
||||
|
||||
#define STDIN 0
|
||||
#define SAVE_SIZE 256 /* size of save buffer */
|
||||
@@ -80,7 +80,7 @@ extern FILE *curstream(void);
|
||||
|
||||
#define CONTROL(x) ((char)(((int)(x)) & 0x1f))
|
||||
|
||||
static struct {
|
||||
STATIC struct {
|
||||
char *prompt;
|
||||
char *buf;
|
||||
char *pos;
|
||||
@@ -102,41 +102,41 @@ typedef struct {
|
||||
} FUNC;
|
||||
|
||||
/* declare binding functions */
|
||||
static void flush_input(void);
|
||||
static void start_of_line(void);
|
||||
static void end_of_line(void);
|
||||
static void forward_char(void);
|
||||
static void backward_char(void);
|
||||
static void forward_word(void);
|
||||
static void backward_word(void);
|
||||
static void delete_char(void);
|
||||
static void forward_kill_char(void);
|
||||
static void backward_kill_char(void);
|
||||
static void forward_kill_word(void);
|
||||
static void kill_line(void);
|
||||
static void new_line(void);
|
||||
static void save_line(void);
|
||||
static void forward_history(void);
|
||||
static void backward_history(void);
|
||||
static void insert_char(int key);
|
||||
static void goto_line(void);
|
||||
static void list_history(void);
|
||||
static void refresh_line(void);
|
||||
static void swap_chars(void);
|
||||
static void set_mark(void);
|
||||
static void yank(void);
|
||||
static void save_region(void);
|
||||
static void kill_region(void);
|
||||
static void reverse_search(void);
|
||||
static void quote_char(void);
|
||||
static void uppercase_word(void);
|
||||
static void lowercase_word(void);
|
||||
static void ignore_char(void);
|
||||
static void arrow_key(void);
|
||||
static void quit_calc(void);
|
||||
S_FUNC void flush_input(void);
|
||||
S_FUNC void start_of_line(void);
|
||||
S_FUNC void end_of_line(void);
|
||||
S_FUNC void forward_char(void);
|
||||
S_FUNC void backward_char(void);
|
||||
S_FUNC void forward_word(void);
|
||||
S_FUNC void backward_word(void);
|
||||
S_FUNC void delete_char(void);
|
||||
S_FUNC void forward_kill_char(void);
|
||||
S_FUNC void backward_kill_char(void);
|
||||
S_FUNC void forward_kill_word(void);
|
||||
S_FUNC void kill_line(void);
|
||||
S_FUNC void new_line(void);
|
||||
S_FUNC void save_line(void);
|
||||
S_FUNC void forward_history(void);
|
||||
S_FUNC void backward_history(void);
|
||||
S_FUNC void insert_char(int key);
|
||||
S_FUNC void goto_line(void);
|
||||
S_FUNC void list_history(void);
|
||||
S_FUNC void refresh_line(void);
|
||||
S_FUNC void swap_chars(void);
|
||||
S_FUNC void set_mark(void);
|
||||
S_FUNC void yank(void);
|
||||
S_FUNC void save_region(void);
|
||||
S_FUNC void kill_region(void);
|
||||
S_FUNC void reverse_search(void);
|
||||
S_FUNC void quote_char(void);
|
||||
S_FUNC void uppercase_word(void);
|
||||
S_FUNC void lowercase_word(void);
|
||||
S_FUNC void ignore_char(void);
|
||||
S_FUNC void arrow_key(void);
|
||||
S_FUNC void quit_calc(void);
|
||||
|
||||
|
||||
static FUNC funcs[] =
|
||||
STATIC FUNC funcs[] =
|
||||
{
|
||||
{"ignore-char", ignore_char},
|
||||
{"flush-input", flush_input},
|
||||
@@ -190,11 +190,11 @@ struct key_map {
|
||||
};
|
||||
|
||||
|
||||
static char base_map_name[] = "base-map";
|
||||
static char esc_map_name[] = "esc-map";
|
||||
STATIC char base_map_name[] = "base-map";
|
||||
STATIC char esc_map_name[] = "esc-map";
|
||||
|
||||
|
||||
static KEY_MAP maps[] = {
|
||||
STATIC KEY_MAP maps[] = {
|
||||
{base_map_name, {NULL, NULL}, {NULL, NULL}},
|
||||
{esc_map_name, {NULL, NULL}, {NULL, NULL}},
|
||||
};
|
||||
@@ -213,46 +213,46 @@ typedef struct {
|
||||
} HIST;
|
||||
|
||||
|
||||
static int inited;
|
||||
static int canedit;
|
||||
static int histused;
|
||||
static int key_count;
|
||||
static int save_len;
|
||||
static KEY_MAP *cur_map;
|
||||
static KEY_MAP *base_map;
|
||||
static KEY_ENT key_table[MAX_KEYS];
|
||||
static char histbuf[HIST_SIZE + 1];
|
||||
static char save_buffer[SAVE_SIZE];
|
||||
STATIC int inited;
|
||||
STATIC int canedit;
|
||||
STATIC int histused;
|
||||
STATIC int key_count;
|
||||
STATIC int save_len;
|
||||
STATIC KEY_MAP *cur_map;
|
||||
STATIC KEY_MAP *base_map;
|
||||
STATIC KEY_ENT key_table[MAX_KEYS];
|
||||
STATIC char histbuf[HIST_SIZE + 1];
|
||||
STATIC char save_buffer[SAVE_SIZE];
|
||||
|
||||
/* declare other static functions */
|
||||
static FUNCPTR find_func(char *name);
|
||||
static HIST *get_event(int n);
|
||||
static HIST *find_event(char *pat, int len);
|
||||
static void read_key(void);
|
||||
static void erasechar(void);
|
||||
static void newline(void);
|
||||
static void backspace(void);
|
||||
static void beep(void);
|
||||
static void echo_char(int ch);
|
||||
static void echo_string(char *str, int len);
|
||||
static void savetext(char *str, int len);
|
||||
static void memrcpy(char *dest, char *src, int len);
|
||||
static int read_bindings(FILE *fp);
|
||||
static int in_word(int ch);
|
||||
static KEY_MAP *find_map(char *map);
|
||||
static void unbind_key(KEY_MAP *map, int key);
|
||||
static void raw_bind_key(KEY_MAP *map, int key,
|
||||
S_FUNC FUNCPTR find_func(char *name);
|
||||
S_FUNC HIST *get_event(int n);
|
||||
S_FUNC HIST *find_event(char *pat, int len);
|
||||
S_FUNC void read_key(void);
|
||||
S_FUNC void erasechar(void);
|
||||
S_FUNC void newline(void);
|
||||
S_FUNC void backspace(void);
|
||||
S_FUNC void beep(void);
|
||||
S_FUNC void echo_char(int ch);
|
||||
S_FUNC void echo_string(char *str, int len);
|
||||
S_FUNC void savetext(char *str, int len);
|
||||
S_FUNC void memrcpy(char *dest, char *src, int len);
|
||||
S_FUNC int read_bindings(FILE *fp);
|
||||
S_FUNC int in_word(int ch);
|
||||
S_FUNC KEY_MAP *find_map(char *map);
|
||||
S_FUNC void unbind_key(KEY_MAP *map, int key);
|
||||
S_FUNC void raw_bind_key(KEY_MAP *map, int key,
|
||||
FUNCPTR func, KEY_MAP *next_map);
|
||||
static KEY_MAP *do_map_line(char *line);
|
||||
static void do_default_line(KEY_MAP *map, char *line);
|
||||
static void do_bind_line(KEY_MAP *map, char *line);
|
||||
static void back_over_char(int ch);
|
||||
static void echo_rest_of_line(void);
|
||||
static void goto_start_of_line(void);
|
||||
static void goto_end_of_line(void);
|
||||
static void remove_char(int ch);
|
||||
static void decrement_end(int n);
|
||||
static void insert_string(char *str, int len);
|
||||
S_FUNC KEY_MAP *do_map_line(char *line);
|
||||
S_FUNC void do_default_line(KEY_MAP *map, char *line);
|
||||
S_FUNC void do_bind_line(KEY_MAP *map, char *line);
|
||||
S_FUNC void back_over_char(int ch);
|
||||
S_FUNC void echo_rest_of_line(void);
|
||||
S_FUNC void goto_start_of_line(void);
|
||||
S_FUNC void goto_end_of_line(void);
|
||||
S_FUNC void remove_char(int ch);
|
||||
S_FUNC void decrement_end(int n);
|
||||
S_FUNC void insert_string(char *str, int len);
|
||||
|
||||
|
||||
/*
|
||||
@@ -406,7 +406,7 @@ hist_term(void)
|
||||
}
|
||||
|
||||
|
||||
static KEY_MAP *
|
||||
S_FUNC KEY_MAP *
|
||||
find_map(char *map)
|
||||
{
|
||||
unsigned int i;
|
||||
@@ -419,14 +419,14 @@ find_map(char *map)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
unbind_key(KEY_MAP *map, int key)
|
||||
{
|
||||
map->map[key] = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
raw_bind_key(KEY_MAP *map, int key, FUNCPTR func, KEY_MAP *next_map)
|
||||
{
|
||||
if (map->map[key] == NULL) {
|
||||
@@ -439,7 +439,7 @@ raw_bind_key(KEY_MAP *map, int key, FUNCPTR func, KEY_MAP *next_map)
|
||||
}
|
||||
|
||||
|
||||
static KEY_MAP *
|
||||
S_FUNC KEY_MAP *
|
||||
do_map_line(char *line)
|
||||
{
|
||||
char *cp;
|
||||
@@ -458,7 +458,7 @@ do_map_line(char *line)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
do_bind_line(KEY_MAP *map, char *line)
|
||||
{
|
||||
char *cp;
|
||||
@@ -529,7 +529,7 @@ do_bind_line(KEY_MAP *map, char *line)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
do_default_line(KEY_MAP *map, char *line)
|
||||
{
|
||||
char *cp;
|
||||
@@ -584,7 +584,7 @@ do_default_line(KEY_MAP *map, char *line)
|
||||
*
|
||||
* Returns nonzero on error.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
read_bindings(FILE *fp)
|
||||
{
|
||||
char *cp;
|
||||
@@ -621,7 +621,7 @@ read_bindings(FILE *fp)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
read_key(void)
|
||||
{
|
||||
KEY_ENT *ent;
|
||||
@@ -653,7 +653,7 @@ read_key(void)
|
||||
* Return the Nth history event, indexed from zero.
|
||||
* Earlier history events are lower in number.
|
||||
*/
|
||||
static HIST *
|
||||
S_FUNC HIST *
|
||||
get_event(int n)
|
||||
{
|
||||
register HIST * hp;
|
||||
@@ -671,7 +671,7 @@ get_event(int n)
|
||||
* Search the history list for the specified pattern.
|
||||
* Returns the found history, or NULL.
|
||||
*/
|
||||
static HIST *
|
||||
S_FUNC HIST *
|
||||
find_event(char *pat, int len)
|
||||
{
|
||||
register HIST * hp;
|
||||
@@ -747,7 +747,7 @@ hist_saveline(char *line, int len)
|
||||
/*
|
||||
* Find the function for a specified name.
|
||||
*/
|
||||
static FUNCPTR
|
||||
S_FUNC FUNCPTR
|
||||
find_func(char *name)
|
||||
{
|
||||
FUNC *fp;
|
||||
@@ -760,7 +760,7 @@ find_func(char *name)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
arrow_key(void)
|
||||
{
|
||||
switch (fgetc(stdin)) {
|
||||
@@ -780,7 +780,7 @@ arrow_key(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
back_over_char(int ch)
|
||||
{
|
||||
backspace();
|
||||
@@ -789,7 +789,7 @@ back_over_char(int ch)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
remove_char(int ch)
|
||||
{
|
||||
erasechar();
|
||||
@@ -798,14 +798,14 @@ remove_char(int ch)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
echo_rest_of_line(void)
|
||||
{
|
||||
echo_string(HS.pos, HS.end - HS.pos);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
goto_start_of_line(void)
|
||||
{
|
||||
while (HS.pos > HS.buf)
|
||||
@@ -813,7 +813,7 @@ goto_start_of_line(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
goto_end_of_line(void)
|
||||
{
|
||||
echo_rest_of_line();
|
||||
@@ -821,7 +821,7 @@ goto_end_of_line(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
decrement_end(int n)
|
||||
{
|
||||
HS.end -= n;
|
||||
@@ -830,13 +830,13 @@ decrement_end(int n)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
ignore_char(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
flush_input(void)
|
||||
{
|
||||
echo_rest_of_line();
|
||||
@@ -847,21 +847,21 @@ flush_input(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
start_of_line(void)
|
||||
{
|
||||
goto_start_of_line();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
end_of_line(void)
|
||||
{
|
||||
goto_end_of_line();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
forward_char(void)
|
||||
{
|
||||
if (HS.pos < HS.end)
|
||||
@@ -869,7 +869,7 @@ forward_char(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
backward_char(void)
|
||||
{
|
||||
if (HS.pos > HS.buf)
|
||||
@@ -877,7 +877,7 @@ backward_char(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
uppercase_word(void)
|
||||
{
|
||||
while ((HS.pos < HS.end) && !in_word((int)(*HS.pos)))
|
||||
@@ -890,7 +890,7 @@ uppercase_word(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
lowercase_word(void)
|
||||
{
|
||||
while ((HS.pos < HS.end) && !in_word((int)(*HS.pos)))
|
||||
@@ -903,7 +903,7 @@ lowercase_word(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
forward_word(void)
|
||||
{
|
||||
while ((HS.pos < HS.end) && !in_word((int)(*HS.pos)))
|
||||
@@ -913,7 +913,7 @@ forward_word(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
backward_word(void)
|
||||
{
|
||||
if ((HS.pos > HS.buf) && in_word((int)(*HS.pos)))
|
||||
@@ -927,7 +927,7 @@ backward_word(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
forward_kill_char(void)
|
||||
{
|
||||
int rest;
|
||||
@@ -949,7 +949,7 @@ forward_kill_char(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
delete_char(void)
|
||||
{
|
||||
/*
|
||||
@@ -972,7 +972,7 @@ delete_char(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
backward_kill_char(void)
|
||||
{
|
||||
if (HS.pos > HS.buf) {
|
||||
@@ -983,7 +983,7 @@ backward_kill_char(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
forward_kill_word(void)
|
||||
{
|
||||
char *cp;
|
||||
@@ -1007,7 +1007,7 @@ forward_kill_word(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
kill_line(void)
|
||||
{
|
||||
if (HS.end <= HS.pos)
|
||||
@@ -1026,7 +1026,7 @@ kill_line(void)
|
||||
* The line is NOT put into the edit history, so that the caller can
|
||||
* decide whether or not this should be done.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
new_line(void)
|
||||
{
|
||||
int len;
|
||||
@@ -1050,7 +1050,7 @@ new_line(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
save_line(void)
|
||||
{
|
||||
int len;
|
||||
@@ -1064,7 +1064,7 @@ save_line(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
goto_line(void)
|
||||
{
|
||||
int num;
|
||||
@@ -1088,7 +1088,7 @@ goto_line(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
forward_history(void)
|
||||
{
|
||||
HIST *hp;
|
||||
@@ -1105,7 +1105,7 @@ forward_history(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
backward_history(void)
|
||||
{
|
||||
HIST *hp;
|
||||
@@ -1122,7 +1122,7 @@ backward_history(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
insert_char(int key)
|
||||
{
|
||||
int len;
|
||||
@@ -1145,7 +1145,7 @@ insert_char(int key)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
insert_string(char *str, int len)
|
||||
{
|
||||
int rest;
|
||||
@@ -1171,7 +1171,7 @@ insert_string(char *str, int len)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
list_history(void)
|
||||
{
|
||||
HIST *hp;
|
||||
@@ -1186,7 +1186,7 @@ list_history(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
refresh_line(void)
|
||||
{
|
||||
char *cp;
|
||||
@@ -1202,7 +1202,7 @@ refresh_line(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
swap_chars(void)
|
||||
{
|
||||
char ch1;
|
||||
@@ -1221,14 +1221,14 @@ swap_chars(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
set_mark(void)
|
||||
{
|
||||
HS.mark = HS.pos;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
save_region(void)
|
||||
{
|
||||
int len;
|
||||
@@ -1243,7 +1243,7 @@ save_region(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
kill_region(void)
|
||||
{
|
||||
char *cp;
|
||||
@@ -1275,14 +1275,14 @@ kill_region(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
yank(void)
|
||||
{
|
||||
insert_string(save_buffer, save_len);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
reverse_search(void)
|
||||
{
|
||||
int len;
|
||||
@@ -1318,7 +1318,7 @@ reverse_search(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
quote_char(void)
|
||||
{
|
||||
int ch;
|
||||
@@ -1332,7 +1332,7 @@ quote_char(void)
|
||||
/*
|
||||
* Save data in the save buffer.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
savetext(char *str, int len)
|
||||
{
|
||||
save_len = 0;
|
||||
@@ -1348,42 +1348,42 @@ savetext(char *str, int len)
|
||||
/*
|
||||
* Test whether a character is part of a word.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
in_word(int ch)
|
||||
{
|
||||
return (isalnum(ch) || (ch == '_'));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
erasechar(void)
|
||||
{
|
||||
fputs("\b \b", stdout);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
newline(void)
|
||||
{
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
backspace(void)
|
||||
{
|
||||
fputc('\b', stdout);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
beep(void)
|
||||
{
|
||||
fputc('\007', stdout);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
echo_char(int ch)
|
||||
{
|
||||
if (isprint(ch)) {
|
||||
@@ -1395,7 +1395,7 @@ echo_char(int ch)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
echo_string(char *str, int len)
|
||||
{
|
||||
while (len-- > 0)
|
||||
@@ -1403,7 +1403,7 @@ echo_string(char *str, int len)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
memrcpy(char *dest, char *src, int len)
|
||||
{
|
||||
dest += len - 1;
|
||||
@@ -1414,7 +1414,7 @@ memrcpy(char *dest, char *src, int len)
|
||||
|
||||
#endif /* !USE_READLINE */
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
quit_calc(void)
|
||||
{
|
||||
hist_term();
|
||||
@@ -1480,7 +1480,7 @@ hist_term(void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
my_stifle_history (void)
|
||||
{
|
||||
/* only save last number of entries */
|
||||
@@ -1514,7 +1514,7 @@ hist_init(char UNUSED *filename)
|
||||
void
|
||||
hist_saveline(char *line, int len)
|
||||
{
|
||||
static char *prev = NULL;
|
||||
STATIC char *prev = NULL;
|
||||
|
||||
if (len <= 1)
|
||||
return;
|
||||
|
14
hist.h
14
hist.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* hist - definitions for command history module
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: hist.h,v 29.6 2006/05/19 15:26:10 chongo Exp $
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: hist.h,v 29.7 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/hist.h,v $
|
||||
*
|
||||
* Under source code control: 1993/05/02 20:09:20
|
||||
@@ -68,10 +68,10 @@
|
||||
#define HIST_NOTTY 3 /* terminal modes could not be set */
|
||||
|
||||
|
||||
extern DLL int hist_init(char *filename);
|
||||
extern DLL void hist_term(void);
|
||||
extern DLL size_t hist_getline(char *prompt, char *buf, size_t len);
|
||||
extern DLL void hist_saveline(char *line, int len);
|
||||
E_FUNC int hist_init(char *filename);
|
||||
E_FUNC void hist_term(void);
|
||||
E_FUNC size_t hist_getline(char *prompt, char *buf, size_t len);
|
||||
E_FUNC void hist_saveline(char *line, int len);
|
||||
|
||||
|
||||
#endif /* !__HIST_H__ */
|
||||
|
76
input.c
76
input.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* input - nested input source file reader
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.11 $
|
||||
* @(#) $Id: input.c,v 29.11 2006/05/19 15:26:10 chongo Exp $
|
||||
* @(#) $Revision: 29.13 $
|
||||
* @(#) $Id: input.c,v 29.13 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/input.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:16
|
||||
@@ -56,9 +56,9 @@
|
||||
#include "conf.h"
|
||||
#include "hist.h"
|
||||
|
||||
extern int stdin_tty; /* TRUE if stdin is a tty */
|
||||
extern FILE *f_open(char *name, char *mode);
|
||||
extern FILE *curstream(void);
|
||||
EXTERN int stdin_tty; /* TRUE if stdin is a tty */
|
||||
E_FUNC FILE *f_open(char *name, char *mode);
|
||||
E_FUNC FILE *curstream(void);
|
||||
|
||||
|
||||
#define TTYSIZE 100 /* reallocation size for terminal buffers */
|
||||
@@ -90,25 +90,25 @@ typedef struct {
|
||||
struct stat inode; /* inode information for file */
|
||||
} READSET;
|
||||
|
||||
static READSET *readset = NULL; /* array of files read */
|
||||
static int maxreadset = 0; /* length of readset */
|
||||
STATIC READSET *readset = NULL; /* array of files read */
|
||||
STATIC int maxreadset = 0; /* length of readset */
|
||||
|
||||
static int linesize; /* current max size of input line */
|
||||
static char *linebuf; /* current input line buffer */
|
||||
static char *prompt; /* current prompt for terminal */
|
||||
static BOOL noprompt; /* TRUE if should not print prompt */
|
||||
STATIC int linesize; /* current max size of input line */
|
||||
STATIC char *linebuf; /* current input line buffer */
|
||||
STATIC char *prompt; /* current prompt for terminal */
|
||||
STATIC BOOL noprompt; /* TRUE if should not print prompt */
|
||||
|
||||
static int depth; /* current input depth */
|
||||
static INPUT *cip; /* current input source */
|
||||
static INPUT inputs[MAXDEPTH]; /* input sources */
|
||||
STATIC int depth; /* current input depth */
|
||||
STATIC INPUT *cip; /* current input source */
|
||||
STATIC INPUT inputs[MAXDEPTH]; /* input sources */
|
||||
|
||||
|
||||
static int openfile(char *name);
|
||||
static int ttychar(void);
|
||||
static int isinoderead(struct stat *sbuf);
|
||||
static int findfreeread(void);
|
||||
static int addreadset(char *name, char *path, struct stat *sbuf);
|
||||
static char *homeexpand(char *name);
|
||||
S_FUNC int openfile(char *name);
|
||||
S_FUNC int ttychar(void);
|
||||
S_FUNC int isinoderead(struct stat *sbuf);
|
||||
S_FUNC int findfreeread(void);
|
||||
S_FUNC int addreadset(char *name, char *path, struct stat *sbuf);
|
||||
S_FUNC char *homeexpand(char *name);
|
||||
|
||||
|
||||
/*
|
||||
@@ -390,7 +390,7 @@ f_pathopen(char *name, char *mode, char *pathlist, char **openpath)
|
||||
* given:
|
||||
* name a filename with a leading ~
|
||||
*/
|
||||
static char *
|
||||
S_FUNC char *
|
||||
homeexpand(char *name)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
@@ -539,7 +539,7 @@ f_open(char *name, char *mode)
|
||||
* given:
|
||||
* name file name to be read
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
openfile(char *name)
|
||||
{
|
||||
FILE *fp; /* open file descriptor */
|
||||
@@ -773,12 +773,12 @@ nextline(void)
|
||||
* The routines in the history module are called so that the user
|
||||
* can use a command history and emacs-like editing of the line.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
ttychar(void)
|
||||
{
|
||||
int ch; /* current char */
|
||||
int len; /* length of current command */
|
||||
static char charbuf[1024];
|
||||
STATIC char charbuf[1024];
|
||||
|
||||
/*
|
||||
* If we have more to read from the saved command line, then do that.
|
||||
@@ -957,13 +957,10 @@ runrcfiles(void)
|
||||
* sbuf stat of the inode in question
|
||||
*/
|
||||
|
||||
static int
|
||||
S_FUNC int
|
||||
isinoderead(struct stat *sbuf)
|
||||
{
|
||||
int i;
|
||||
#if defined(_WIN32) || defined(__MSDOS__)
|
||||
char fullpathname[_MAX_PATH];
|
||||
#endif
|
||||
|
||||
/* deal with the empty case */
|
||||
if (readset == NULL || maxreadset <= 0) {
|
||||
@@ -974,13 +971,17 @@ isinoderead(struct stat *sbuf)
|
||||
/* scan the entire readset */
|
||||
for (i=0; i < maxreadset; ++i) {
|
||||
#if defined(_WIN32) || defined(__MSDOS__)
|
||||
tmp = _fullpath(NULL, cip->i_name, _MAX_PATH);
|
||||
if (readset[i].active &&
|
||||
strcasecmp(readset[i].path,
|
||||
_fullpath(fullpathname,cip->i_name,
|
||||
_MAX_PATH)) == 0) {
|
||||
tmp != NULL &&
|
||||
strcasecmp(readset[i].path, tmp) == 0) {
|
||||
/* found a match */
|
||||
free(tmp);
|
||||
return i;
|
||||
}
|
||||
if (tmp != NULL) {
|
||||
free(tmp);
|
||||
}
|
||||
#else /* Windoz free systems */
|
||||
if (readset[i].active &&
|
||||
sbuf->st_dev == readset[i].inode.st_dev &&
|
||||
@@ -1004,7 +1005,7 @@ isinoderead(struct stat *sbuf)
|
||||
*
|
||||
* This function returns the index of the next free element, or -1.
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
findfreeread(void)
|
||||
{
|
||||
int i;
|
||||
@@ -1065,7 +1066,7 @@ findfreeread(void)
|
||||
* path full pathname of file
|
||||
* sbuf stat of the path
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
addreadset(char *name, char *path, struct stat *sbuf)
|
||||
{
|
||||
int ret; /* index to return */
|
||||
@@ -1106,9 +1107,10 @@ addreadset(char *name, char *path, struct stat *sbuf)
|
||||
* this new longer path name.
|
||||
*/
|
||||
{
|
||||
char fullpathname[_MAX_PATH];
|
||||
|
||||
readset[ret].path = _fullpath(fullpathname, path, _MAX_PATH);
|
||||
readset[ret].path = _fullpath(NULL, path, _MAX_PATH);
|
||||
if (readset[ret].path == NULL) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#else /* Windoz free systems */
|
||||
path_len = strlen(path);
|
||||
|
14
jump.h
14
jump.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* jump - trivial prime jump table
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: jump.h,v 29.4 2001/06/08 21:00:58 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: jump.h,v 29.5 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/jump.h,v $
|
||||
*
|
||||
* Under source code control: 1994/06/29 04:03:55
|
||||
@@ -68,8 +68,10 @@
|
||||
|
||||
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
||||
# include "have_const.h"
|
||||
# include "decl.h"
|
||||
#else
|
||||
# include <calc/have_const.h>
|
||||
# include <calc/decl.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -101,8 +103,8 @@
|
||||
/*
|
||||
* external jump tables
|
||||
*/
|
||||
extern CONST short jmpindx[];
|
||||
extern CONST unsigned char jmp[];
|
||||
extern CONST unsigned char *CONST lastjmp;
|
||||
EXTERN CONST short jmpindx[];
|
||||
EXTERN CONST unsigned char jmp[];
|
||||
EXTERN CONST unsigned char *CONST lastjmp;
|
||||
|
||||
#endif /* !__JUMP_H__ */
|
||||
|
12
label.c
12
label.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* label - label handling routines
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: label.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: label.c,v 29.3 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/label.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:17
|
||||
@@ -35,9 +35,9 @@
|
||||
#include "opcodes.h"
|
||||
#include "func.h"
|
||||
|
||||
static long labelcount; /* number of user labels defined */
|
||||
static STRINGHEAD labelnames; /* list of user label names */
|
||||
static LABEL labels[MAXLABELS]; /* list of user labels */
|
||||
STATIC long labelcount; /* number of user labels defined */
|
||||
STATIC STRINGHEAD labelnames; /* list of user label names */
|
||||
STATIC LABEL labels[MAXLABELS]; /* list of user labels */
|
||||
|
||||
|
||||
/*
|
||||
|
20
label.h
20
label.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* label - label handling routines
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: label.h,v 29.4 2001/06/08 21:00:58 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: label.h,v 29.5 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/label.h,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:33
|
||||
@@ -52,13 +52,13 @@ typedef struct {
|
||||
} LABEL;
|
||||
|
||||
|
||||
extern void initlabels(void);
|
||||
extern void definelabel(char *name);
|
||||
extern void addlabel(char *name);
|
||||
extern void clearlabel(LABEL *lp);
|
||||
extern void setlabel(LABEL *lp);
|
||||
extern void uselabel(LABEL *lp);
|
||||
extern void checklabels(void);
|
||||
E_FUNC void initlabels(void);
|
||||
E_FUNC void definelabel(char *name);
|
||||
E_FUNC void addlabel(char *name);
|
||||
E_FUNC void clearlabel(LABEL *lp);
|
||||
E_FUNC void setlabel(LABEL *lp);
|
||||
E_FUNC void uselabel(LABEL *lp);
|
||||
E_FUNC void checklabels(void);
|
||||
|
||||
|
||||
#endif /* !__LABEL_H__ */
|
||||
|
38
lib_calc.c
38
lib_calc.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* lib_calc - calc link library initialization and shutdown routines
|
||||
*
|
||||
* Copyright (C) 1999-2006 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.14 $
|
||||
* @(#) $Id: lib_calc.c,v 29.14 2006/05/21 07:28:54 chongo Exp $
|
||||
* @(#) $Revision: 29.15 $
|
||||
* @(#) $Id: lib_calc.c,v 29.15 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/lib_calc.c,v $
|
||||
*
|
||||
* Under source code control: 1996/06/17 18:06:19
|
||||
@@ -98,8 +98,8 @@ typedef struct {int fd;} ttystruct;
|
||||
#if !defined(HAVE_UID_T) && !defined(_UID_T)
|
||||
typedef unsigned short uid_t;
|
||||
#endif
|
||||
extern char *getenv();
|
||||
extern uid_t geteuid();
|
||||
E_FUNC char *getenv();
|
||||
E_FUNC uid_t geteuid();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -167,23 +167,23 @@ char *user_debug = NULL; /* !=NULL => value of config("user_debug") */
|
||||
/*
|
||||
* initialization functions
|
||||
*/
|
||||
extern void math_setfp(FILE *fp);
|
||||
extern void file_init(void);
|
||||
extern void zio_init(void);
|
||||
extern void initialize(void);
|
||||
extern void reinitialize(void);
|
||||
E_FUNC void math_setfp(FILE *fp);
|
||||
E_FUNC void file_init(void);
|
||||
E_FUNC void zio_init(void);
|
||||
E_FUNC void initialize(void);
|
||||
E_FUNC void reinitialize(void);
|
||||
|
||||
|
||||
/*
|
||||
* static declarations
|
||||
*/
|
||||
static int init_done = 0; /* 1 => we already initialized */
|
||||
static int *fd_setup = NULL; /* fd's setup for interaction or -1 */
|
||||
static int fd_setup_len = 0; /* number of fd's in fd_setup */
|
||||
static ttystruct *fd_orig = NULL; /* fd original state */
|
||||
static ttystruct *fd_cur = NULL; /* fd current state */
|
||||
static void initenv(void); /* setup calc environment */
|
||||
static int find_tty_state(int fd); /* find slot for saved tty state */
|
||||
STATIC int init_done = 0; /* 1 => we already initialized */
|
||||
STATIC int *fd_setup = NULL; /* fd's setup for interaction or -1 */
|
||||
STATIC int fd_setup_len = 0; /* number of fd's in fd_setup */
|
||||
STATIC ttystruct *fd_orig = NULL; /* fd original state */
|
||||
STATIC ttystruct *fd_cur = NULL; /* fd current state */
|
||||
S_FUNC void initenv(void); /* setup calc environment */
|
||||
S_FUNC int find_tty_state(int fd); /* find slot for saved tty state */
|
||||
|
||||
|
||||
/*
|
||||
@@ -394,7 +394,7 @@ cvmalloc_error(char *message)
|
||||
* use a default value. If $HOME does not exist, or is empty, use the home
|
||||
* directory information from the password file.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
initenv(void)
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
@@ -597,7 +597,7 @@ calc_strdup(CONST char *s1)
|
||||
* Returns:
|
||||
* indx The index into fd_setup[], fd_orig[] and fd_cur[] to use or -1
|
||||
*/
|
||||
static int
|
||||
S_FUNC int
|
||||
find_tty_state(int fd)
|
||||
{
|
||||
int *new_fd_setup; /* new fd_setup array */
|
||||
|
16
lib_util.h
16
lib_util.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* lib_util - calc link library utility routines
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: lib_util.h,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: lib_util.h,v 29.3 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/lib_util.h,v $
|
||||
*
|
||||
* Under source code control: 1997/04/19 21:38:30
|
||||
@@ -38,10 +38,10 @@
|
||||
#define __LIB_UTIL_H__
|
||||
|
||||
/* external functions in lib_util.c */
|
||||
extern int lowhex2bin[256];
|
||||
extern char lowbin2hex[256];
|
||||
extern ZVALUE convstr2z(char*);
|
||||
extern ZVALUE convhex2z(char *hex);
|
||||
extern char *convz2hex(ZVALUE z);
|
||||
EXTERN int lowhex2bin[256];
|
||||
EXTERN char lowbin2hex[256];
|
||||
E_FUNC ZVALUE convstr2z(char*);
|
||||
E_FUNC ZVALUE convhex2z(char *hex);
|
||||
E_FUNC char *convz2hex(ZVALUE z);
|
||||
|
||||
#endif /* __LIB_UTIL_H__ */
|
||||
|
20
listfunc.c
20
listfunc.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* listfunc - list handling routines
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: listfunc.c,v 29.3 2006/06/02 10:24:09 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: listfunc.c,v 29.4 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/listfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:18
|
||||
@@ -40,11 +40,11 @@
|
||||
#include "value.h"
|
||||
#include "zrand.h"
|
||||
|
||||
extern long irand(long s);
|
||||
E_FUNC long irand(long s);
|
||||
|
||||
static LISTELEM *elemalloc(void);
|
||||
static void elemfree(LISTELEM *ep);
|
||||
static void removelistelement(LIST *lp, LISTELEM *ep);
|
||||
S_FUNC LISTELEM *elemalloc(void);
|
||||
S_FUNC void elemfree(LISTELEM *ep);
|
||||
S_FUNC void removelistelement(LIST *lp, LISTELEM *ep);
|
||||
|
||||
|
||||
/*
|
||||
@@ -224,7 +224,7 @@ removelistmiddle(LIST *lp, long index, VALUE *vp)
|
||||
* lp list header
|
||||
* ep list element to remove
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
removelistelement(LIST *lp, LISTELEM *ep)
|
||||
{
|
||||
if ((ep == lp->l_cache) || ((ep != lp->l_first) && (ep != lp->l_last)))
|
||||
@@ -804,7 +804,7 @@ listrandperm(LIST *lp)
|
||||
/*
|
||||
* Allocate an element for a list.
|
||||
*/
|
||||
static LISTELEM *
|
||||
S_FUNC LISTELEM *
|
||||
elemalloc(void)
|
||||
{
|
||||
LISTELEM *ep;
|
||||
@@ -825,7 +825,7 @@ elemalloc(void)
|
||||
/*
|
||||
* Free a list element, along with any contained value.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
elemfree(LISTELEM *ep)
|
||||
{
|
||||
if (ep->e_value.v_type != V_NULL)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* longbits - Determine the number if bits in a char, short, int or long
|
||||
*
|
||||
* Copyright (C) 1999-2006 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: longbits.c,v 29.7 2006/06/01 11:37:20 chongo Exp $
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: longbits.c,v 29.8 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/longbits.c,v $
|
||||
*
|
||||
* Under source code control: 1994/03/18 03:06:18
|
||||
@@ -98,7 +98,7 @@
|
||||
|
||||
#if defined(__linux)
|
||||
# if !defined(isascii)
|
||||
extern int isascii(int c);
|
||||
E_FUNC int isascii(int c);
|
||||
# endif /* !isascii */
|
||||
#endif /* __linux */
|
||||
|
||||
|
24
matfunc.c
24
matfunc.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* matfunc - extended precision rational arithmetic matrix functions
|
||||
*
|
||||
* Copyright (C) 1999-2004 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: matfunc.c,v 29.7 2006/06/02 10:24:09 chongo Exp $
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: matfunc.c,v 29.8 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/matfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:18
|
||||
@@ -38,12 +38,12 @@
|
||||
|
||||
#include "have_unused.h"
|
||||
|
||||
extern long irand(long s);
|
||||
E_FUNC long irand(long s);
|
||||
|
||||
static void matswaprow(MATRIX *m, long r1, long r2);
|
||||
static void matsubrow(MATRIX *m, long oprow, long baserow, VALUE *mulval);
|
||||
static void matmulrow(MATRIX *m, long row, VALUE *mulval);
|
||||
static MATRIX *matident(MATRIX *m);
|
||||
S_FUNC void matswaprow(MATRIX *m, long r1, long r2);
|
||||
S_FUNC void matsubrow(MATRIX *m, long oprow, long baserow, VALUE *mulval);
|
||||
S_FUNC void matmulrow(MATRIX *m, long row, VALUE *mulval);
|
||||
S_FUNC MATRIX *matident(MATRIX *m);
|
||||
|
||||
|
||||
|
||||
@@ -1043,7 +1043,7 @@ matfill(MATRIX *m, VALUE *v1, VALUE *v2)
|
||||
/*
|
||||
* Set a copy of a square matrix to the identity matrix.
|
||||
*/
|
||||
static MATRIX *
|
||||
S_FUNC MATRIX *
|
||||
matident(MATRIX *m)
|
||||
{
|
||||
register VALUE *val; /* current value */
|
||||
@@ -1318,7 +1318,7 @@ matdet(MATRIX *m)
|
||||
* Local utility routine to swap two rows of a square matrix.
|
||||
* No checks are made to verify the legality of the arguments.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
matswaprow(MATRIX *m, long r1, long r2)
|
||||
{
|
||||
register VALUE *v1, *v2;
|
||||
@@ -1345,7 +1345,7 @@ matswaprow(MATRIX *m, long r1, long r2)
|
||||
* The row to be changed is oprow, the row to be subtracted is baserow.
|
||||
* No checks are made to verify the legality of the arguments.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
matsubrow(MATRIX *m, long oprow, long baserow, VALUE *mulval)
|
||||
{
|
||||
register VALUE *vop, *vbase;
|
||||
@@ -1371,7 +1371,7 @@ matsubrow(MATRIX *m, long oprow, long baserow, VALUE *mulval)
|
||||
* Local utility routine to multiply a row by a specified number.
|
||||
* No checks are made to verify the legality of the arguments.
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
matmulrow(MATRIX *m, long row, VALUE *mulval)
|
||||
{
|
||||
register VALUE *val;
|
||||
|
12
math_error.h
12
math_error.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* math_error - a simple libcalc math error routine
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: math_error.h,v 29.5 2001/06/08 21:00:58 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: math_error.h,v 29.6 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/math_error.h,v $
|
||||
*
|
||||
* Under source code control: 1997/03/23 18:37:10
|
||||
@@ -34,16 +34,16 @@
|
||||
|
||||
|
||||
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
||||
# include "win32dll.h"
|
||||
# include "decl.h"
|
||||
#else
|
||||
# include <calc/win32dll.h>
|
||||
# include <calc/decl.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Global data definitions.
|
||||
*/
|
||||
extern DLL jmp_buf jmpbuf; /* for errors */
|
||||
EXTERN jmp_buf jmpbuf; /* for errors */
|
||||
|
||||
|
||||
#endif /* !__MATH_ERROR_H__ */
|
||||
|
8
md5.c
8
md5.c
@@ -10,8 +10,8 @@
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: md5.c,v 29.3 2004/08/03 12:28:29 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: md5.c,v 29.4 2007/02/11 10:16:31 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/md5.c,v $
|
||||
*
|
||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||
@@ -54,6 +54,7 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "decl.h"
|
||||
#include "longbits.h"
|
||||
#include "align32.h"
|
||||
#include "endian_calc.h"
|
||||
@@ -61,6 +62,9 @@
|
||||
#include "hash.h"
|
||||
#include "md5.h"
|
||||
|
||||
CONST char *rsa_notice = "The md5 code was derived from the RSA "
|
||||
"Data Security, Inc. MD5 Message-Digest Algorithm.";
|
||||
|
||||
|
||||
/*
|
||||
* The F, G, H and I are basic MD5 functions. The following
|
||||
|
34
obj.c
34
obj.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* obj - object handling primitives
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: obj.c,v 29.8 2006/05/20 08:43:55 chongo Exp $
|
||||
* @(#) $Revision: 29.9 $
|
||||
* @(#) $Id: obj.c,v 29.9 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/obj.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:19
|
||||
@@ -64,7 +64,7 @@
|
||||
#define ERR_ASSIGN 10 /* assign value */
|
||||
|
||||
|
||||
static struct objectinfo {
|
||||
STATIC struct objectinfo {
|
||||
short args; /* number of arguments */
|
||||
short retval; /* type of return value */
|
||||
short error; /* special action on errors */
|
||||
@@ -119,17 +119,17 @@ static struct objectinfo {
|
||||
};
|
||||
|
||||
|
||||
static STRINGHEAD objectnames; /* names of objects */
|
||||
static STRINGHEAD elements; /* element names for parts of objects */
|
||||
static OBJECTACTIONS **objects; /* table of actions for objects */
|
||||
STATIC STRINGHEAD objectnames; /* names of objects */
|
||||
STATIC STRINGHEAD elements; /* element names for parts of objects */
|
||||
STATIC OBJECTACTIONS **objects; /* table of actions for objects */
|
||||
|
||||
#define OBJALLOC 16
|
||||
static long maxobjcount = 0;
|
||||
STATIC long maxobjcount = 0;
|
||||
|
||||
static VALUE objpowi(VALUE *vp, NUMBER *q);
|
||||
static BOOL objtest(OBJECT *op);
|
||||
static BOOL objcmp(OBJECT *op1, OBJECT *op2);
|
||||
static void objprint(OBJECT *op);
|
||||
S_FUNC VALUE objpowi(VALUE *vp, NUMBER *q);
|
||||
S_FUNC BOOL objtest(OBJECT *op);
|
||||
S_FUNC BOOL objcmp(OBJECT *op1, OBJECT *op2);
|
||||
S_FUNC void objprint(OBJECT *op);
|
||||
|
||||
|
||||
/*
|
||||
@@ -159,7 +159,7 @@ VALUE
|
||||
objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3)
|
||||
{
|
||||
FUNC *fp; /* function to call */
|
||||
static OBJECTACTIONS *oap; /* object to call for */
|
||||
STATIC OBJECTACTIONS *oap; /* object to call for */
|
||||
struct objectinfo *oip; /* information about action */
|
||||
long index; /* index of function (negative if undefined) */
|
||||
VALUE val; /* return value */
|
||||
@@ -332,7 +332,7 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3)
|
||||
* given:
|
||||
* op object being printed
|
||||
*/
|
||||
static void
|
||||
S_FUNC void
|
||||
objprint(OBJECT *op)
|
||||
{
|
||||
int count; /* number of elements */
|
||||
@@ -354,7 +354,7 @@ objprint(OBJECT *op)
|
||||
* This is the default routine if the user's is not defined.
|
||||
* Returns TRUE if any of the elements are "nonzero".
|
||||
*/
|
||||
static BOOL
|
||||
S_FUNC BOOL
|
||||
objtest(OBJECT *op)
|
||||
{
|
||||
int i; /* loop counter */
|
||||
@@ -373,7 +373,7 @@ objtest(OBJECT *op)
|
||||
* This is the default routine if the user's is not defined.
|
||||
* For equality, all elements must be equal.
|
||||
*/
|
||||
static BOOL
|
||||
S_FUNC BOOL
|
||||
objcmp(OBJECT *op1, OBJECT *op2)
|
||||
{
|
||||
int i; /* loop counter */
|
||||
@@ -399,7 +399,7 @@ objcmp(OBJECT *op1, OBJECT *op2)
|
||||
* vp value to be powered
|
||||
* q power to raise number to
|
||||
*/
|
||||
static VALUE
|
||||
S_FUNC VALUE
|
||||
objpowi(VALUE *vp, NUMBER *q)
|
||||
{
|
||||
VALUE res, tmp;
|
||||
|
14
opcodes.h
14
opcodes.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* opcodes - opcode execution module definition
|
||||
*
|
||||
* Copyright (C) 1999-2006 David I. Bell
|
||||
* Copyright (C) 1999-2007 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: opcodes.h,v 29.7 2006/06/25 20:33:26 chongo Exp $
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: opcodes.h,v 29.8 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/opcodes.h,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:35
|
||||
@@ -33,9 +33,9 @@
|
||||
|
||||
|
||||
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
||||
# include "win32dll.h"
|
||||
# include "decl.h"
|
||||
#else
|
||||
# include <calc/win32dll.h>
|
||||
# include <calc/decl.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -180,8 +180,8 @@
|
||||
/*
|
||||
* external declarations
|
||||
*/
|
||||
extern DLL char *funcname; /* function being executed */
|
||||
extern DLL long funcline; /* function line being executed */
|
||||
EXTERN char *funcname; /* function being executed */
|
||||
EXTERN long funcline; /* function line being executed */
|
||||
|
||||
|
||||
#endif /* !__OPCODES_H__ */
|
||||
|
12
prime.c
12
prime.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* prime - quickly determine if a small number is prime
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: prime.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: prime.c,v 29.3 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/prime.c,v $
|
||||
*
|
||||
* Under source code control: 1994/06/04 03:26:14
|
||||
@@ -916,11 +916,11 @@ CONST unsigned short prime[MAP_POPCNT+1] = {
|
||||
* smallest prime > MAX_SM_PRIME (2^32-5) == 2^32+15
|
||||
*/
|
||||
#if BASEB == 32
|
||||
static CONST HALF _nxt_prime_val_[] = { 0xf, 0x1 };
|
||||
STATIC CONST HALF _nxt_prime_val_[] = { 0xf, 0x1 };
|
||||
ZVALUE CONST _nxt_prime_ = { (HALF *)_nxt_prime_val_, 2, 0 };
|
||||
NUMBER _nxtprime_ = {{(HALF *)_nxt_prime_val_,2,0}, {_oneval_,1,0}, 1, NULL};
|
||||
#else
|
||||
static CONST HALF _nxt_prime_val_[] = { 0xf, 0x0, 0x1 };
|
||||
STATIC CONST HALF _nxt_prime_val_[] = { 0xf, 0x0, 0x1 };
|
||||
ZVALUE CONST _nxt_prime_ = { (HALF *)_nxt_prime_val_, 3, 0 };
|
||||
NUMBER _nxtprime_ = {{(HALF *)_nxt_prime_val_,3,0}, {_oneval_,1,0}, 1, NULL};
|
||||
#endif
|
||||
@@ -928,5 +928,5 @@ NUMBER _nxtprime_ = {{(HALF *)_nxt_prime_val_,3,0}, {_oneval_,1,0}, 1, NULL};
|
||||
/*
|
||||
* JMPMOD*2 as a ZVALUE
|
||||
*/
|
||||
static CONST HALF _jmpmod2_val_[] = { JMPMOD*2 };
|
||||
STATIC CONST HALF _jmpmod2_val_[] = { JMPMOD*2 };
|
||||
CONST ZVALUE _jmpmod2_ = { (HALF *)_jmpmod2_val_, 1, 0 };
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user