mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
253b47942f | ||
|
c773ee736f | ||
|
7d0cc52afe | ||
|
2441df7fdc | ||
|
5c565a7cea | ||
|
810e541281 | ||
|
ee30d787ea | ||
|
4e92927183 | ||
|
fb4a03c1f1 |
23
BUGS
23
BUGS
@@ -80,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?
|
||||
|
||||
@@ -141,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.25 $
|
||||
## @(#) $Id: BUGS,v 29.25 2006/08/20 17:51:25 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
|
||||
|
175
CHANGES
175
CHANGES
@@ -1,4 +1,163 @@
|
||||
The following are the changes from calc version 2.12.1 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.
|
||||
|
||||
When MACOSX_TLS is defined, calc attempts to compile with OS
|
||||
X Thread Local Storage. As of version 2.12.1.12 this mode is
|
||||
extremely experimental. Calc may not compile with MACOSX_TLS defined.
|
||||
|
||||
Fixed E_FUNC vs EXTERN issues discovered by Mirko Viviani
|
||||
<mirko at objectlab dot org>.
|
||||
|
||||
Removed include of <malloc.h>. The building of the include file
|
||||
"have_malloc.h" has been removed from the Makefile. One some
|
||||
systems such as FreeBSD, the file /usr/include/malloc.h exists
|
||||
and contains an forced error saying that stdlib.h should be used
|
||||
instead. The Makefile symbol HAVE_MALLOC has been removed.
|
||||
|
||||
Fixed FreeBSD dereferencing type-punned pointer error in filepos2z().
|
||||
|
||||
|
||||
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.
|
||||
@@ -13,6 +172,14 @@ The following are the changes from calc version 2.12.1 to date:
|
||||
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:
|
||||
|
||||
@@ -2573,8 +2740,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:
|
||||
@@ -6208,8 +6373,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.88 $
|
||||
## @(#) $Id: CHANGES,v 29.88 2006/09/18 06:29:07 chongo Exp $
|
||||
## @(#) $Revision: 29.100 $
|
||||
## @(#) $Id: CHANGES,v 29.100 2007/02/12 08:22:13 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,7 +52,7 @@ 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,
|
||||
@@ -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.8 $
|
||||
## @(#) $Id: HOWTO.INSTALL,v 29.8 2006/09/18 06:27:39 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 */
|
||||
|
||||
|
||||
/*
|
||||
|
54
alloc.h
54
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.7 $
|
||||
* @(#) $Id: alloc.h,v 29.7 2007/02/12 03:57:00 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/alloc.h,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:29
|
||||
@@ -33,54 +33,38 @@
|
||||
|
||||
|
||||
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
||||
# include "have_malloc.h"
|
||||
# include "have_newstr.h"
|
||||
# include "have_string.h"
|
||||
# include "have_memmv.h"
|
||||
#else
|
||||
# include <calc/have_malloc.h>
|
||||
# include <calc/have_newstr.h>
|
||||
# include <calc/have_string.h>
|
||||
# include <calc/have_memmv.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MALLOC_H
|
||||
# include <malloc.h>
|
||||
#else
|
||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||
extern void *malloc();
|
||||
extern void *realloc();
|
||||
extern void free();
|
||||
# else
|
||||
extern char *malloc();
|
||||
extern char *realloc();
|
||||
extern void free();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
|
||||
#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 +78,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__ */
|
||||
|
11
cal/Makefile
11
cal/Makefile
@@ -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.23 $
|
||||
# @(#) $Id: Makefile,v 29.23 2006/09/18 06:27:39 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
|
||||
@@ -96,7 +96,7 @@ 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
|
||||
@@ -170,6 +170,7 @@ CP= cp
|
||||
MV= mv
|
||||
CO= co
|
||||
TRUE= true
|
||||
TOUCH= touch
|
||||
|
||||
# The calc files to install
|
||||
#
|
||||
|
@@ -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.35 $
|
||||
* @(#) $Id: regress.cal,v 29.35 2006/08/20 16:16:11 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()';
|
||||
|
||||
@@ -1375,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()';
|
||||
|
||||
|
@@ -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)
|
||||
|
237
calc.h
237
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.19 $
|
||||
* @(#) $Id: calc.h,v 29.19 2006/08/20 15:01:30 chongo Exp $
|
||||
* @(#) $Revision: 29.21 $
|
||||
* @(#) $Id: calc.h,v 29.21 2007/02/12 03:26:23 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,140 @@
|
||||
/*
|
||||
* 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, STRING *str);
|
||||
extern DLL int printid(FILEID id, int flags);
|
||||
extern DLL int flushid(FILEID id);
|
||||
extern DLL int readid(FILEID id, int flags, STRING **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 */
|
||||
|
||||
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 */
|
||||
EXTERN int no_env; /* TRUE (-e) => ignore env vars on startup */
|
||||
EXTERN long errmax; /* if >= 0, error when errcount exceeds errmax */
|
||||
EXTERN 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 +252,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
|
||||
|
@@ -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.4 $
|
||||
# @(#) $Id: check.awk,v 29.4 2006/08/20 16:16:31 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 ~ /^"))$/ {
|
||||
$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
|
||||
|
@@ -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.27 $
|
||||
# @(#) $Id: Makefile,v 29.27 2006/09/18 07:04:42 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
|
||||
@@ -96,7 +96,7 @@ 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
|
||||
@@ -199,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
|
||||
#
|
||||
@@ -211,12 +211,16 @@ CALCLIBLIST=
|
||||
# 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
|
||||
@@ -248,7 +252,8 @@ distdir:
|
||||
|
||||
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"; \
|
||||
@@ -395,7 +400,7 @@ install: all
|
||||
else \
|
||||
${RM} -f ${T}${SCRIPTDIR}/$$i.new; \
|
||||
${CP} -f $$i ${T}${SCRIPTDIR}/$$i.new; \
|
||||
${CHMOD} 0555 ${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; \
|
||||
|
@@ -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
|
||||
|
@@ -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.28 $
|
||||
# @(#) $Id: Makefile,v 29.28 2006/09/18 07:04:42 chongo Exp $
|
||||
# @(#) $Revision: 29.31 $
|
||||
# @(#) $Id: Makefile,v 29.31 2007/02/12 04:19:17 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/03/09 02:28:54
|
||||
@@ -148,7 +148,7 @@ 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
|
||||
@@ -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.
|
||||
@@ -411,6 +426,7 @@ MV= mv
|
||||
CP= cp
|
||||
CO= co
|
||||
TRUE= true
|
||||
MAKE= make
|
||||
|
||||
##
|
||||
#
|
||||
@@ -517,8 +533,8 @@ depend:
|
||||
>> "skel/custom/$$i"; \
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/custom/$$i"; \
|
||||
done
|
||||
${Q} (cd ..; ${MAKE} hsrc)
|
||||
${Q} for i in `cd ..; ${MAKE} h_list 2>&1 | \
|
||||
${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 \
|
||||
@@ -829,10 +845,10 @@ 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
|
||||
c_argv.o: ../have_malloc.h
|
||||
c_argv.o: ../have_memmv.h
|
||||
c_argv.o: ../have_newstr.h
|
||||
c_argv.o: ../have_stdlib.h
|
||||
@@ -846,7 +862,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
|
||||
@@ -856,10 +871,10 @@ 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
|
||||
c_devnull.o: ../have_malloc.h
|
||||
c_devnull.o: ../have_memmv.h
|
||||
c_devnull.o: ../have_newstr.h
|
||||
c_devnull.o: ../have_stdlib.h
|
||||
@@ -873,7 +888,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
|
||||
@@ -883,10 +897,10 @@ 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
|
||||
c_help.o: ../have_malloc.h
|
||||
c_help.o: ../have_memmv.h
|
||||
c_help.o: ../have_newstr.h
|
||||
c_help.o: ../have_stdlib.h
|
||||
@@ -900,7 +914,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
|
||||
@@ -910,10 +923,10 @@ 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
|
||||
c_pmodm127.o: ../have_malloc.h
|
||||
c_pmodm127.o: ../have_memmv.h
|
||||
c_pmodm127.o: ../have_newstr.h
|
||||
c_pmodm127.o: ../have_stdlib.h
|
||||
@@ -927,7 +940,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
|
||||
@@ -937,10 +949,10 @@ 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
|
||||
c_pzasusb8.o: ../have_malloc.h
|
||||
c_pzasusb8.o: ../have_memmv.h
|
||||
c_pzasusb8.o: ../have_newstr.h
|
||||
c_pzasusb8.o: ../have_stdlib.h
|
||||
@@ -954,7 +966,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
|
||||
@@ -966,11 +977,11 @@ 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
|
||||
c_sysinfo.o: ../have_const.h
|
||||
c_sysinfo.o: ../have_malloc.h
|
||||
c_sysinfo.o: ../have_memmv.h
|
||||
c_sysinfo.o: ../have_newstr.h
|
||||
c_sysinfo.o: ../have_stdlib.h
|
||||
@@ -986,7 +997,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
|
||||
@@ -998,10 +1008,10 @@ 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
|
||||
custtbl.o: ../have_malloc.h
|
||||
custtbl.o: ../have_memmv.h
|
||||
custtbl.o: ../have_newstr.h
|
||||
custtbl.o: ../have_stdlib.h
|
||||
@@ -1014,6 +1024,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.12 $
|
||||
* @(#) $Id: c_sysinfo.c,v 29.12 2006/09/18 06:28:47 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},
|
||||
@@ -160,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) */
|
||||
|
||||
|
||||
/*
|
||||
@@ -290,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 */
|
||||
@@ -307,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 */
|
||||
@@ -338,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 */
|
||||
|
97
decl.h
Normal file
97
decl.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.4 $
|
||||
* @(#) $Id: decl.h,v 29.4 2007/02/12 03:38:42 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 Thread Local Storage macros
|
||||
*
|
||||
* NOTE: The use of -DMACOSX_TLS is extremely experimental. Calc may not
|
||||
* compile with MACOSX_TLS defined.
|
||||
*/
|
||||
#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__ */
|
82
file.c
82
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.16 $
|
||||
* @(#) $Id: file.c,v 29.16 2006/08/20 15:01:30 chongo Exp $
|
||||
* @(#) $Revision: 29.18 $
|
||||
* @(#) $Id: file.c,v 29.18 2007/02/12 08:20:24 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)
|
||||
{
|
||||
@@ -1352,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 */
|
||||
@@ -1363,7 +1363,7 @@ filepos2z(FILEPOS pos)
|
||||
ret.len = FILEPOS_BITS/BASEB;
|
||||
ret.v = alloc(ret.len);
|
||||
zclearval(ret);
|
||||
SWAP_HALF_IN_FILEPOS(ret.v, (HALF *)&pos);
|
||||
SWAP_HALF_IN_FILEPOS(ret.v, &pos);
|
||||
ret.sign = 0;
|
||||
ztrim(&ret);
|
||||
|
||||
@@ -1385,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
|
||||
@@ -1462,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 */
|
||||
@@ -1622,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 */
|
||||
@@ -1706,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 */
|
||||
@@ -1737,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 */
|
||||
@@ -1769,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 */
|
||||
@@ -1927,7 +1927,7 @@ get_inode(FILEID id, ZVALUE *inode)
|
||||
}
|
||||
|
||||
|
||||
static off_t
|
||||
S_FUNC off_t
|
||||
filesize(FILEIO *fiop)
|
||||
{
|
||||
struct stat sbuf;
|
||||
@@ -2025,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 */
|
||||
@@ -2103,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 */
|
||||
@@ -2170,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 */
|
||||
@@ -2364,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;
|
||||
@@ -2502,7 +2502,7 @@ freadnum(FILE *fp, VALUE *valptr)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
freadsum(FILE *fp, VALUE *valptr)
|
||||
{
|
||||
VALUE v1, v2, v3;
|
||||
@@ -2528,7 +2528,7 @@ freadsum(FILE *fp, VALUE *valptr)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
S_FUNC void
|
||||
freadprod(FILE *fp, VALUE *valptr)
|
||||
{
|
||||
VALUE v1, v2, v3;
|
||||
@@ -2552,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.6 $
|
||||
* @(#) $Id: func.h,v 29.6 2007/02/12 03:40:06 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;
|
||||
E_FUNC FUNC *curfunc; /* NOTE: This is a function pointer, we need E_FUNC */
|
||||
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
|
@@ -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.33 $
|
||||
# @(#) $Id: Makefile,v 29.33 2006/09/18 07:04:42 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
|
||||
@@ -169,7 +169,7 @@ SED= sed
|
||||
SORT= sort
|
||||
FMT= fmt
|
||||
CMP= cmp
|
||||
CP= cm
|
||||
CP= cp
|
||||
MV= mv
|
||||
TRUE= true
|
||||
RM= rm
|
||||
@@ -214,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
|
||||
|
||||
@@ -277,7 +277,7 @@ 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 \
|
||||
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 \
|
||||
@@ -292,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 \
|
||||
rcpow rcsq re remove reverse rewind ${RM} root round rsearch runtime \
|
||||
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.
|
||||
@@ -325,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
|
||||
#
|
||||
@@ -410,9 +410,9 @@ errorcodes: ../calcerr.h errorcodes.hdr errorcodes.sed
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
calc: usage
|
||||
usage: ../calc.usage
|
||||
${RM} -f $@
|
||||
${CP} usage $@
|
||||
${CP} ../calc.usage $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
@@ -422,6 +422,9 @@ calc: usage
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
../calc.usage:
|
||||
(cd ..; $(MAKE) calc.usage)
|
||||
|
||||
custom_cal: ../custom/CUSTOM_CAL
|
||||
${RM} -f $@
|
||||
${CP} ../custom/CUSTOM_CAL $@
|
||||
@@ -494,6 +497,11 @@ cscript: ../cscript/README
|
||||
${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 $@
|
||||
|
@@ -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/
|
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
|
||||
|
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/
|
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/
|
43
help/todo
43
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,6 +72,13 @@ 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:
|
||||
@@ -104,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.9 $
|
||||
## @(#) $Id: todo,v 29.9 2006/09/17 20:54:07 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/
|
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 };
|
||||
|
20
prime.h
20
prime.h
@@ -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.4 $
|
||||
* @(#) $Id: prime.h,v 29.4 2001/06/08 21:00:58 chongo Exp $
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: prime.h,v 29.5 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/prime.h,v $
|
||||
*
|
||||
* Under source code control: 1994/06/04 03:26:15
|
||||
@@ -82,13 +82,13 @@
|
||||
/*
|
||||
* Prime related external arrays.
|
||||
*/
|
||||
extern CONST unsigned short prime[];
|
||||
extern CONST unsigned char pr_map[];
|
||||
extern CONST unsigned short pi10b[];
|
||||
extern CONST unsigned short pi18b[];
|
||||
extern NUMBER _nxtprime_; /* 2^32+15 - smallest prime > 2^32 */
|
||||
extern CONST ZVALUE _nxt_prime_; /* 2^32+15 - smallest prime > 2^32 */
|
||||
extern CONST ZVALUE _jmpmod2_; /* JMPMOD*2 as a ZVALUE */
|
||||
EXTERN CONST unsigned short prime[];
|
||||
EXTERN CONST unsigned char pr_map[];
|
||||
EXTERN CONST unsigned short pi10b[];
|
||||
EXTERN CONST unsigned short pi18b[];
|
||||
EXTERN NUMBER _nxtprime_; /* 2^32+15 - smallest prime > 2^32 */
|
||||
EXTERN CONST ZVALUE _nxt_prime_; /* 2^32+15 - smallest prime > 2^32 */
|
||||
EXTERN CONST ZVALUE _jmpmod2_; /* JMPMOD*2 as a ZVALUE */
|
||||
|
||||
|
||||
#endif /* !__PRIME_H__ */
|
||||
|
16
qfunc.c
16
qfunc.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qfunc - extended precision rational arithmetic non-primitive functions
|
||||
*
|
||||
* Copyright (C) 1999-2004 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.9 $
|
||||
* @(#) $Id: qfunc.c,v 29.9 2006/05/20 08:43:55 chongo Exp $
|
||||
* @(#) $Revision: 29.10 $
|
||||
* @(#) $Id: qfunc.c,v 29.10 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:20
|
||||
@@ -34,11 +34,11 @@
|
||||
#include "config.h"
|
||||
#include "prime.h"
|
||||
|
||||
static NUMBER **B_table;
|
||||
static long B_num;
|
||||
static long B_allocnum;
|
||||
static NUMBER **E_table;
|
||||
static long E_num;
|
||||
STATIC NUMBER **B_table;
|
||||
STATIC long B_num;
|
||||
STATIC long B_allocnum;
|
||||
STATIC NUMBER **E_table;
|
||||
STATIC long E_num;
|
||||
|
||||
#define QALLOCNUM 64
|
||||
|
||||
|
10
qio.c
10
qio.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qio - scanf and printf routines for arbitrary precision rational numbers
|
||||
*
|
||||
* 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.8 $
|
||||
* @(#) $Id: qio.c,v 29.8 2006/05/20 08:43:55 chongo Exp $
|
||||
* @(#) $Revision: 29.9 $
|
||||
* @(#) $Id: qio.c,v 29.9 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qio.c,v $
|
||||
*
|
||||
* Under source code control: 1993/07/30 19:42:46
|
||||
@@ -40,8 +40,8 @@
|
||||
#define PRINTF1(fmt, a1) math_fmt(fmt, a1)
|
||||
#define PRINTF2(fmt, a1, a2) math_fmt(fmt, a1, a2)
|
||||
|
||||
static long scalefactor;
|
||||
static ZVALUE scalenumber = { 0, 0, 0 };
|
||||
STATIC long scalefactor;
|
||||
STATIC ZVALUE scalenumber = { 0, 0, 0 };
|
||||
|
||||
|
||||
/*
|
||||
|
57
qmath.c
57
qmath.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qmath - extended precision rational arithmetic primitive routines
|
||||
*
|
||||
* Copyright (C) 1999-2004 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: qmath.c,v 29.6 2006/05/20 08:43:55 chongo Exp $
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: qmath.c,v 29.8 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qmath.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:21
|
||||
@@ -140,6 +140,25 @@ qtou(NUMBER *q)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert a number to a normal signed integer.
|
||||
* s = qtos(q);
|
||||
*/
|
||||
SFULL
|
||||
qtos(NUMBER *q)
|
||||
{
|
||||
SFULL i;
|
||||
ZVALUE res;
|
||||
|
||||
if (qisint(q))
|
||||
return ztos(q->num);
|
||||
zquo(q->num, q->den, &res, 0);
|
||||
i = ztos(res);
|
||||
zfree(res);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert a normal unsigned integer into a number.
|
||||
* q = utoq(i);
|
||||
@@ -166,6 +185,32 @@ utoq(FULL i)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert a normal signed integer into a number.
|
||||
* q = stoq(s);
|
||||
*/
|
||||
NUMBER *
|
||||
stoq(SFULL i)
|
||||
{
|
||||
register NUMBER *q;
|
||||
|
||||
if (i <= 10) {
|
||||
switch ((int) i) {
|
||||
case 0: q = &_qzero_; break;
|
||||
case 1: q = &_qone_; break;
|
||||
case 2: q = &_qtwo_; break;
|
||||
case 10: q = &_qten_; break;
|
||||
default: q = NULL;
|
||||
}
|
||||
if (q)
|
||||
return qlink(q);
|
||||
}
|
||||
q = qalloc();
|
||||
stoz(i, &q->num);
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create a number from the given FULL numerator and denominator.
|
||||
* q = uutoq(inum, iden);
|
||||
@@ -1348,9 +1393,9 @@ qcmpi(NUMBER *q, long n)
|
||||
#define NNALLOC 1000
|
||||
|
||||
|
||||
static NUMBER *freeNum = NULL;
|
||||
static NUMBER **firstNums = NULL;
|
||||
static long blockcount = 0;
|
||||
STATIC NUMBER *freeNum = NULL;
|
||||
STATIC NUMBER **firstNums = NULL;
|
||||
STATIC long blockcount = 0;
|
||||
|
||||
|
||||
NUMBER *
|
||||
|
312
qmath.h
312
qmath.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qmath - declarations for extended precision rational arithmetic
|
||||
*
|
||||
* 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: qmath.h,v 29.7 2006/06/25 20:33:26 chongo Exp $
|
||||
* @(#) $Revision: 29.9 $
|
||||
* @(#) $Id: qmath.h,v 29.9 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qmath.h,v $
|
||||
*
|
||||
* Under source code control: 1993/07/30 19:42:47
|
||||
@@ -53,186 +53,188 @@ struct number {
|
||||
|
||||
typedef struct number NUMBER;
|
||||
|
||||
extern NUMBER _qlge_;
|
||||
EXTERN NUMBER _qlge_;
|
||||
|
||||
/*
|
||||
* Input. output, allocation, and conversion routines.
|
||||
*/
|
||||
extern NUMBER *qalloc(void);
|
||||
extern NUMBER *qcopy(NUMBER *q);
|
||||
extern NUMBER *uutoq(FULL i1, FULL i2);
|
||||
extern NUMBER *iitoq(long i1, long i2);
|
||||
extern NUMBER *str2q(char *str);
|
||||
extern NUMBER *itoq(long i);
|
||||
extern NUMBER *utoq(FULL i);
|
||||
extern long qtoi(NUMBER *q);
|
||||
extern FULL qtou(NUMBER *q);
|
||||
extern long qparse(char *str, int flags);
|
||||
extern void qfreenum(NUMBER *q);
|
||||
extern void qprintnum(NUMBER *q, int mode);
|
||||
extern void qprintff(NUMBER *q, long width, long precision);
|
||||
extern void qprintfe(NUMBER *q, long width, long precision);
|
||||
extern void qprintfr(NUMBER *q, long width, BOOL force);
|
||||
extern void qprintfd(NUMBER *q, long width);
|
||||
extern void qprintfx(NUMBER *q, long width);
|
||||
extern void qprintfb(NUMBER *q, long width);
|
||||
extern void qprintfo(NUMBER *q, long width);
|
||||
extern void qprintf(char *, ...);
|
||||
extern void shownumbers(void);
|
||||
extern void showredcdata(void);
|
||||
extern void freeredcdata(void);
|
||||
extern void fitprint(NUMBER *, long);
|
||||
E_FUNC NUMBER *qalloc(void);
|
||||
E_FUNC NUMBER *qcopy(NUMBER *q);
|
||||
E_FUNC NUMBER *uutoq(FULL i1, FULL i2);
|
||||
E_FUNC NUMBER *iitoq(long i1, long i2);
|
||||
E_FUNC NUMBER *str2q(char *str);
|
||||
E_FUNC NUMBER *itoq(long i);
|
||||
E_FUNC NUMBER *utoq(FULL i);
|
||||
E_FUNC NUMBER *stoq(SFULL i);
|
||||
E_FUNC long qtoi(NUMBER *q);
|
||||
E_FUNC FULL qtou(NUMBER *q);
|
||||
E_FUNC SFULL qtos(NUMBER *q);
|
||||
E_FUNC long qparse(char *str, int flags);
|
||||
E_FUNC void qfreenum(NUMBER *q);
|
||||
E_FUNC void qprintnum(NUMBER *q, int mode);
|
||||
E_FUNC void qprintff(NUMBER *q, long width, long precision);
|
||||
E_FUNC void qprintfe(NUMBER *q, long width, long precision);
|
||||
E_FUNC void qprintfr(NUMBER *q, long width, BOOL force);
|
||||
E_FUNC void qprintfd(NUMBER *q, long width);
|
||||
E_FUNC void qprintfx(NUMBER *q, long width);
|
||||
E_FUNC void qprintfb(NUMBER *q, long width);
|
||||
E_FUNC void qprintfo(NUMBER *q, long width);
|
||||
E_FUNC void qprintf(char *, ...);
|
||||
E_FUNC void shownumbers(void);
|
||||
E_FUNC void showredcdata(void);
|
||||
E_FUNC void freeredcdata(void);
|
||||
E_FUNC void fitprint(NUMBER *, long);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Basic numeric routines.
|
||||
*/
|
||||
extern NUMBER *qaddi(NUMBER *q, long i);
|
||||
extern NUMBER *qmuli(NUMBER *q, long i);
|
||||
extern NUMBER *qdivi(NUMBER *q, long i);
|
||||
extern NUMBER *qqadd(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qsub(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qmul(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qqdiv(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qquo(NUMBER *q1, NUMBER *q2, long rnd);
|
||||
extern NUMBER *qmod(NUMBER *q1, NUMBER *q2, long rnd);
|
||||
extern NUMBER *qmin(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qmax(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qand(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qor(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qxor(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qandnot(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qcomp(NUMBER *q);
|
||||
extern NUMBER *qpowermod(NUMBER *q1, NUMBER *q2, NUMBER *q3);
|
||||
extern NUMBER *qpowi(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qsquare(NUMBER *q);
|
||||
extern NUMBER *qneg(NUMBER *q);
|
||||
extern NUMBER *qsign(NUMBER *q);
|
||||
extern NUMBER *qint(NUMBER *q);
|
||||
extern NUMBER *qfrac(NUMBER *q);
|
||||
extern NUMBER *qnum(NUMBER *q);
|
||||
extern NUMBER *qden(NUMBER *q);
|
||||
extern NUMBER *qinv(NUMBER *q);
|
||||
extern NUMBER *qqabs(NUMBER *q);
|
||||
extern NUMBER *qinc(NUMBER *q);
|
||||
extern NUMBER *qdec(NUMBER *q);
|
||||
extern NUMBER *qshift(NUMBER *q, long n);
|
||||
extern NUMBER *qtrunc(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qround(NUMBER *q, long places, long rnd);
|
||||
extern NUMBER *qbtrunc(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qbround(NUMBER *q, long places, long rnd);
|
||||
extern NUMBER *qscale(NUMBER *q, long i);
|
||||
extern BOOL qdivides(NUMBER *q1, NUMBER *q2);
|
||||
extern BOOL qcmp(NUMBER *q1, NUMBER *q2);
|
||||
extern BOOL qcmpi(NUMBER *q, long i);
|
||||
extern FLAG qrel(NUMBER *q1, NUMBER *q2);
|
||||
extern FLAG qreli(NUMBER *q, long i);
|
||||
extern BOOL qisset(NUMBER *q, long i);
|
||||
E_FUNC NUMBER *qaddi(NUMBER *q, long i);
|
||||
E_FUNC NUMBER *qmuli(NUMBER *q, long i);
|
||||
E_FUNC NUMBER *qdivi(NUMBER *q, long i);
|
||||
E_FUNC NUMBER *qqadd(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qsub(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qmul(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qqdiv(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qquo(NUMBER *q1, NUMBER *q2, long rnd);
|
||||
E_FUNC NUMBER *qmod(NUMBER *q1, NUMBER *q2, long rnd);
|
||||
E_FUNC NUMBER *qmin(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qmax(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qand(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qor(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qxor(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qandnot(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qcomp(NUMBER *q);
|
||||
E_FUNC NUMBER *qpowermod(NUMBER *q1, NUMBER *q2, NUMBER *q3);
|
||||
E_FUNC NUMBER *qpowi(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qsquare(NUMBER *q);
|
||||
E_FUNC NUMBER *qneg(NUMBER *q);
|
||||
E_FUNC NUMBER *qsign(NUMBER *q);
|
||||
E_FUNC NUMBER *qint(NUMBER *q);
|
||||
E_FUNC NUMBER *qfrac(NUMBER *q);
|
||||
E_FUNC NUMBER *qnum(NUMBER *q);
|
||||
E_FUNC NUMBER *qden(NUMBER *q);
|
||||
E_FUNC NUMBER *qinv(NUMBER *q);
|
||||
E_FUNC NUMBER *qqabs(NUMBER *q);
|
||||
E_FUNC NUMBER *qinc(NUMBER *q);
|
||||
E_FUNC NUMBER *qdec(NUMBER *q);
|
||||
E_FUNC NUMBER *qshift(NUMBER *q, long n);
|
||||
E_FUNC NUMBER *qtrunc(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qround(NUMBER *q, long places, long rnd);
|
||||
E_FUNC NUMBER *qbtrunc(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qbround(NUMBER *q, long places, long rnd);
|
||||
E_FUNC NUMBER *qscale(NUMBER *q, long i);
|
||||
E_FUNC BOOL qdivides(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC BOOL qcmp(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC BOOL qcmpi(NUMBER *q, long i);
|
||||
E_FUNC FLAG qrel(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC FLAG qreli(NUMBER *q, long i);
|
||||
E_FUNC BOOL qisset(NUMBER *q, long i);
|
||||
|
||||
|
||||
/*
|
||||
* More complicated numeric functions.
|
||||
*/
|
||||
extern NUMBER *qcomb(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qgcd(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qlcm(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qfact(NUMBER *q);
|
||||
extern NUMBER *qpfact(NUMBER *q);
|
||||
extern NUMBER *qminv(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qfacrem(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qperm(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qgcdrem(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qlowfactor(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qfib(NUMBER *q);
|
||||
extern NUMBER *qcfappr(NUMBER *q, NUMBER *epsilon, long R);
|
||||
extern NUMBER *qcfsim(NUMBER *q, long R);
|
||||
extern NUMBER *qisqrt(NUMBER *q);
|
||||
extern NUMBER *qjacobi(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qiroot(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qmappr(NUMBER *q, NUMBER *e, long R);
|
||||
extern NUMBER *qlcmfact(NUMBER *q);
|
||||
extern NUMBER *qredcin(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qredcout(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qredcmul(NUMBER *q1, NUMBER *q2, NUMBER *q3);
|
||||
extern NUMBER *qredcsquare(NUMBER *q1, NUMBER *q2);
|
||||
extern NUMBER *qredcpower(NUMBER *q1, NUMBER *q2, NUMBER *q3);
|
||||
extern BOOL qprimetest(NUMBER *q1, NUMBER *q2, NUMBER *q3);
|
||||
extern BOOL qissquare(NUMBER *q);
|
||||
extern long qilog2(NUMBER *q);
|
||||
extern long qilog10(NUMBER *q);
|
||||
extern NUMBER *qilog(NUMBER *q, ZVALUE base);
|
||||
extern BOOL qcmpmod(NUMBER *q1, NUMBER *q2, NUMBER *q3);
|
||||
extern BOOL qquomod(NUMBER *q1, NUMBER *q2, NUMBER **quo, NUMBER **mod, long rnd);
|
||||
extern FLAG qnear(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
extern NUMBER *qdigit(NUMBER *q, ZVALUE dpos, ZVALUE base);
|
||||
extern long qprecision(NUMBER *q);
|
||||
extern long qplaces(NUMBER *q, ZVALUE base);
|
||||
extern long qdecplaces(NUMBER *q);
|
||||
extern long qdigits(NUMBER *q, ZVALUE base);
|
||||
extern void setepsilon(NUMBER *q);
|
||||
extern NUMBER *qbitvalue(long i);
|
||||
extern NUMBER *qtenpow(long i);
|
||||
E_FUNC NUMBER *qcomb(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qgcd(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qlcm(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qfact(NUMBER *q);
|
||||
E_FUNC NUMBER *qpfact(NUMBER *q);
|
||||
E_FUNC NUMBER *qminv(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qfacrem(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qperm(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qgcdrem(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qlowfactor(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qfib(NUMBER *q);
|
||||
E_FUNC NUMBER *qcfappr(NUMBER *q, NUMBER *epsilon, long R);
|
||||
E_FUNC NUMBER *qcfsim(NUMBER *q, long R);
|
||||
E_FUNC NUMBER *qisqrt(NUMBER *q);
|
||||
E_FUNC NUMBER *qjacobi(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qiroot(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qmappr(NUMBER *q, NUMBER *e, long R);
|
||||
E_FUNC NUMBER *qlcmfact(NUMBER *q);
|
||||
E_FUNC NUMBER *qredcin(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qredcout(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qredcmul(NUMBER *q1, NUMBER *q2, NUMBER *q3);
|
||||
E_FUNC NUMBER *qredcsquare(NUMBER *q1, NUMBER *q2);
|
||||
E_FUNC NUMBER *qredcpower(NUMBER *q1, NUMBER *q2, NUMBER *q3);
|
||||
E_FUNC BOOL qprimetest(NUMBER *q1, NUMBER *q2, NUMBER *q3);
|
||||
E_FUNC BOOL qissquare(NUMBER *q);
|
||||
E_FUNC long qilog2(NUMBER *q);
|
||||
E_FUNC long qilog10(NUMBER *q);
|
||||
E_FUNC NUMBER *qilog(NUMBER *q, ZVALUE base);
|
||||
E_FUNC BOOL qcmpmod(NUMBER *q1, NUMBER *q2, NUMBER *q3);
|
||||
E_FUNC BOOL qquomod(NUMBER *q1, NUMBER *q2, NUMBER **quo, NUMBER **mod, long rnd);
|
||||
E_FUNC FLAG qnear(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qdigit(NUMBER *q, ZVALUE dpos, ZVALUE base);
|
||||
E_FUNC long qprecision(NUMBER *q);
|
||||
E_FUNC long qplaces(NUMBER *q, ZVALUE base);
|
||||
E_FUNC long qdecplaces(NUMBER *q);
|
||||
E_FUNC long qdigits(NUMBER *q, ZVALUE base);
|
||||
E_FUNC void setepsilon(NUMBER *q);
|
||||
E_FUNC NUMBER *qbitvalue(long i);
|
||||
E_FUNC NUMBER *qtenpow(long i);
|
||||
|
||||
|
||||
/*
|
||||
* Transcendental functions. These all take an epsilon argument to
|
||||
* specify the required accuracy of the calculation.
|
||||
*/
|
||||
extern void qsincos(NUMBER *q, long bitnum, NUMBER **vs, NUMBER **vc);
|
||||
extern NUMBER *qsqrt(NUMBER *q, NUMBER *epsilon, long R);
|
||||
extern NUMBER *qpower(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
extern NUMBER *qroot(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
extern NUMBER *qcos(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qsin(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qexp(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qln(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qlog(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qtan(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qsec(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qcot(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qcsc(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qacos(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qasin(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qatan(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qasec(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qacsc(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qacot(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qatan2(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
extern NUMBER *qhypot(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
extern NUMBER *qcosh(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qsinh(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qtanh(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qcoth(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qsech(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qcsch(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qacosh(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qasinh(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qatanh(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qasech(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qacsch(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qacoth(NUMBER *q, NUMBER *epsilon);
|
||||
extern NUMBER *qlegtoleg(NUMBER *q, NUMBER *epsilon, BOOL wantneg);
|
||||
extern NUMBER *qpi(NUMBER *epsilon);
|
||||
extern NUMBER *qcatalan(NUMBER *);
|
||||
extern NUMBER *qbern(ZVALUE z);
|
||||
extern void qfreebern(void);
|
||||
extern NUMBER *qeuler(ZVALUE z);
|
||||
extern void qfreeeuler(void);
|
||||
E_FUNC void qsincos(NUMBER *q, long bitnum, NUMBER **vs, NUMBER **vc);
|
||||
E_FUNC NUMBER *qsqrt(NUMBER *q, NUMBER *epsilon, long R);
|
||||
E_FUNC NUMBER *qpower(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qroot(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qcos(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qsin(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qexp(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qln(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qlog(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qtan(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qsec(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qcot(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qcsc(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qacos(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qasin(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qatan(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qasec(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qacsc(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qacot(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qatan2(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qhypot(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qcosh(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qsinh(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qtanh(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qcoth(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qsech(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qcsch(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qacosh(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qasinh(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qatanh(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qasech(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qacsch(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qacoth(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qlegtoleg(NUMBER *q, NUMBER *epsilon, BOOL wantneg);
|
||||
E_FUNC NUMBER *qpi(NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qcatalan(NUMBER *);
|
||||
E_FUNC NUMBER *qbern(ZVALUE z);
|
||||
E_FUNC void qfreebern(void);
|
||||
E_FUNC NUMBER *qeuler(ZVALUE z);
|
||||
E_FUNC void qfreeeuler(void);
|
||||
|
||||
|
||||
/*
|
||||
* pseudo-seed generator
|
||||
*/
|
||||
extern NUMBER *pseudo_seed(void);
|
||||
E_FUNC NUMBER *pseudo_seed(void);
|
||||
|
||||
|
||||
/*
|
||||
* external swap functions
|
||||
*/
|
||||
extern NUMBER *swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all);
|
||||
extern NUMBER *swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all);
|
||||
extern NUMBER *swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all);
|
||||
E_FUNC NUMBER *swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all);
|
||||
E_FUNC NUMBER *swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all);
|
||||
E_FUNC NUMBER *swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all);
|
||||
|
||||
|
||||
/*
|
||||
@@ -269,9 +271,9 @@ extern NUMBER *swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all);
|
||||
/*
|
||||
* constants used often by the arithmetic routines
|
||||
*/
|
||||
extern NUMBER _qzero_, _qone_, _qnegone_, _qonehalf_, _qneghalf_, _qonesqbase_;
|
||||
extern NUMBER _qtwo_, _qthree_, _qfour_, _qten_;
|
||||
extern NUMBER * initnumbs[];
|
||||
EXTERN NUMBER _qzero_, _qone_, _qnegone_, _qonehalf_, _qneghalf_, _qonesqbase_;
|
||||
EXTERN NUMBER _qtwo_, _qthree_, _qfour_, _qten_;
|
||||
EXTERN NUMBER * initnumbs[];
|
||||
|
||||
|
||||
#endif /* !__QMATH_H__ */
|
||||
|
14
qmod.c
14
qmod.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qmod - modular arithmetic routines for normal numbers and REDC numbers
|
||||
*
|
||||
* 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.3 $
|
||||
* @(#) $Id: qmod.c,v 29.3 2006/06/25 20:33:26 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: qmod.c,v 29.4 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qmod.c,v $
|
||||
*
|
||||
* Under source code control: 1991/05/22 23:15:07
|
||||
@@ -45,11 +45,11 @@ typedef struct {
|
||||
} REDC_CACHE;
|
||||
|
||||
|
||||
static long redc_age; /* current age counter */
|
||||
static REDC_CACHE redc_cache[MAXREDC]; /* cached REDC info */
|
||||
STATIC long redc_age; /* current age counter */
|
||||
STATIC REDC_CACHE redc_cache[MAXREDC]; /* cached REDC info */
|
||||
|
||||
|
||||
static REDC *qfindredc(NUMBER *q);
|
||||
S_FUNC REDC *qfindredc(NUMBER *q);
|
||||
|
||||
|
||||
/*
|
||||
@@ -339,7 +339,7 @@ qredcpower(NUMBER *q1, NUMBER *q2, NUMBER *q3)
|
||||
* given:
|
||||
* q modulus to find REDC information of
|
||||
*/
|
||||
static REDC *
|
||||
S_FUNC REDC *
|
||||
qfindredc(NUMBER *q)
|
||||
{
|
||||
register REDC_CACHE *rcp;
|
||||
|
16
qtrans.c
16
qtrans.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qtrans - transcendental functions for real numbers
|
||||
*
|
||||
* Copyright (C) 1999-2004 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.7 $
|
||||
* @(#) $Id: qtrans.c,v 29.7 2006/05/07 13:04:18 chongo Exp $
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: qtrans.c,v 29.8 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qtrans.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:22
|
||||
@@ -44,11 +44,11 @@ NUMBER _qlge_ = { { _qlgenum_, 1, 0 }, { _qlgeden_, 1, 0 }, 1, NULL };
|
||||
/*
|
||||
* cache the natural logarithm of 10
|
||||
*/
|
||||
static NUMBER *ln_10 = NULL;
|
||||
static NUMBER *ln_10_epsilon = NULL;
|
||||
STATIC NUMBER *ln_10 = NULL;
|
||||
STATIC NUMBER *ln_10_epsilon = NULL;
|
||||
|
||||
static NUMBER *pivalue[2];
|
||||
static NUMBER *qexprel(NUMBER *q, long bitnum);
|
||||
STATIC NUMBER *pivalue[2];
|
||||
STATIC NUMBER *qexprel(NUMBER *q, long bitnum);
|
||||
|
||||
/*
|
||||
* Evaluate and store in specified locations the sin and cos of a given
|
||||
@@ -821,7 +821,7 @@ qexp(NUMBER *q, NUMBER *epsilon)
|
||||
* Requires *q >= 0, bitnum >= 0.
|
||||
* This returns NULL if more than 2^30 working bits would be required.
|
||||
*/
|
||||
static NUMBER *
|
||||
S_FUNC NUMBER *
|
||||
qexprel(NUMBER *q, long bitnum)
|
||||
{
|
||||
long n, m, k, h, s, t, d;
|
||||
|
58
quickhash.c
58
quickhash.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* quickhash - quickly hash a calc value using a quasi Fowler/Noll/Vo hash
|
||||
*
|
||||
* Copyright (C) 1999-2002 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.13 $
|
||||
* @(#) $Id: quickhash.c,v 29.13 2006/06/25 23:24:16 chongo Exp $
|
||||
* @(#) $Revision: 29.14 $
|
||||
* @(#) $Id: quickhash.c,v 29.14 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/quickhash.c,v $
|
||||
*
|
||||
* Under source code control: 1995/03/04 11:34:23
|
||||
@@ -41,19 +41,19 @@
|
||||
/*
|
||||
* forward declarations
|
||||
*/
|
||||
static QCKHASH assochash(ASSOC *ap, QCKHASH val);
|
||||
static QCKHASH listhash(LIST *lp, QCKHASH val);
|
||||
static QCKHASH mathash(MATRIX *m, QCKHASH val);
|
||||
static QCKHASH objhash(OBJECT *op, QCKHASH val);
|
||||
static QCKHASH randhash(RAND *r, QCKHASH val);
|
||||
static QCKHASH randomhash(RANDOM *state, QCKHASH val);
|
||||
static QCKHASH config_hash(CONFIG *cfg, QCKHASH val);
|
||||
static QCKHASH fnv_strhash(char *ch, QCKHASH val);
|
||||
static QCKHASH fnv_STRhash(STRING *str, QCKHASH val);
|
||||
static QCKHASH fnv_fullhash(FULL *v, LEN len, QCKHASH val);
|
||||
static QCKHASH fnv_zhash(ZVALUE z, QCKHASH val);
|
||||
static QCKHASH hash_hash(HASH *hash, QCKHASH val);
|
||||
static QCKHASH blk_hash(BLOCK *blk, QCKHASH val);
|
||||
S_FUNC QCKHASH assochash(ASSOC *ap, QCKHASH val);
|
||||
S_FUNC QCKHASH listhash(LIST *lp, QCKHASH val);
|
||||
S_FUNC QCKHASH mathash(MATRIX *m, QCKHASH val);
|
||||
S_FUNC QCKHASH objhash(OBJECT *op, QCKHASH val);
|
||||
S_FUNC QCKHASH randhash(RAND *r, QCKHASH val);
|
||||
S_FUNC QCKHASH randomhash(RANDOM *state, QCKHASH val);
|
||||
S_FUNC QCKHASH config_hash(CONFIG *cfg, QCKHASH val);
|
||||
S_FUNC QCKHASH fnv_strhash(char *ch, QCKHASH val);
|
||||
S_FUNC QCKHASH fnv_STRhash(STRING *str, QCKHASH val);
|
||||
S_FUNC QCKHASH fnv_fullhash(FULL *v, LEN len, QCKHASH val);
|
||||
S_FUNC QCKHASH fnv_zhash(ZVALUE z, QCKHASH val);
|
||||
S_FUNC QCKHASH hash_hash(HASH *hash, QCKHASH val);
|
||||
S_FUNC QCKHASH blk_hash(BLOCK *blk, QCKHASH val);
|
||||
|
||||
|
||||
/*
|
||||
@@ -233,7 +233,7 @@ hashvalue(VALUE *vp, QCKHASH val)
|
||||
/*
|
||||
* Return a trivial hash value for an association.
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
assochash(ASSOC *ap, QCKHASH val)
|
||||
{
|
||||
/*
|
||||
@@ -249,7 +249,7 @@ assochash(ASSOC *ap, QCKHASH val)
|
||||
/*
|
||||
* Return a trivial hash value for a list.
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
listhash(LIST *lp, QCKHASH val)
|
||||
{
|
||||
/*
|
||||
@@ -275,7 +275,7 @@ listhash(LIST *lp, QCKHASH val)
|
||||
/*
|
||||
* Return a trivial hash value for a matrix.
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
mathash(MATRIX *m, QCKHASH val)
|
||||
{
|
||||
long skip;
|
||||
@@ -325,7 +325,7 @@ mathash(MATRIX *m, QCKHASH val)
|
||||
/*
|
||||
* Return a trivial hash value for an object.
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
objhash(OBJECT *op, QCKHASH val)
|
||||
{
|
||||
int i;
|
||||
@@ -348,7 +348,7 @@ objhash(OBJECT *op, QCKHASH val)
|
||||
* returns:
|
||||
* trivial hash integer
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
randhash(RAND *r, QCKHASH val)
|
||||
{
|
||||
/*
|
||||
@@ -380,7 +380,7 @@ randhash(RAND *r, QCKHASH val)
|
||||
* returns:
|
||||
* trivial hash integer
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
randomhash(RANDOM *state, QCKHASH val)
|
||||
{
|
||||
/*
|
||||
@@ -408,7 +408,7 @@ randomhash(RANDOM *state, QCKHASH val)
|
||||
/*
|
||||
* config_hash - return a trivial hash for a configuration state
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
config_hash(CONFIG *cfg, QCKHASH val)
|
||||
{
|
||||
USB32 value; /* value to hash from hash elements */
|
||||
@@ -515,7 +515,7 @@ config_hash(CONFIG *cfg, QCKHASH val)
|
||||
* returns:
|
||||
* a 32 bit QCKHASH value
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
fnv_strhash(char *ch, QCKHASH val)
|
||||
{
|
||||
/*
|
||||
@@ -537,7 +537,7 @@ fnv_strhash(char *ch, QCKHASH val)
|
||||
* returns:
|
||||
* a 32 bit QCKHASH value
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
fnv_STRhash(STRING *str, QCKHASH val)
|
||||
{
|
||||
char *ch;
|
||||
@@ -567,7 +567,7 @@ fnv_STRhash(STRING *str, QCKHASH val)
|
||||
* returns:
|
||||
* a 32 bit QCKHASH value
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
fnv_fullhash(FULL *v, LEN len, QCKHASH val)
|
||||
{
|
||||
/*
|
||||
@@ -590,7 +590,7 @@ fnv_fullhash(FULL *v, LEN len, QCKHASH val)
|
||||
* returns:
|
||||
* a 32 bit QCKHASH value
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
fnv_zhash(ZVALUE z, QCKHASH val)
|
||||
{
|
||||
LEN n;
|
||||
@@ -638,7 +638,7 @@ fnv_zhash(ZVALUE z, QCKHASH val)
|
||||
* returns:
|
||||
* a 32 bit QCKHASH value
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
hash_hash(HASH *hash, QCKHASH val)
|
||||
{
|
||||
int i;
|
||||
@@ -663,7 +663,7 @@ hash_hash(HASH *hash, QCKHASH val)
|
||||
* returns:
|
||||
* a 32 bit QCKHASH value
|
||||
*/
|
||||
static QCKHASH
|
||||
S_FUNC QCKHASH
|
||||
blk_hash(BLOCK *blk, QCKHASH val)
|
||||
{
|
||||
int i;
|
||||
|
@@ -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.22 $
|
||||
# @(#) $Id: Makefile,v 29.22 2006/09/18 07:04:42 chongo Exp $
|
||||
# @(#) $Revision: 29.25 $
|
||||
# @(#) $Id: Makefile,v 29.25 2007/02/12 04:19:17 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/sample/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/04/19 22:46:49
|
||||
@@ -35,7 +35,6 @@
|
||||
##############################################################################
|
||||
|
||||
# Any .h files that are needed by programs that use libcustcalc.a
|
||||
# Don't put ${REQUIRED_H_SRC} files in this list.
|
||||
#
|
||||
# Put any .h files that you add which might be useful to other
|
||||
# programs here.
|
||||
@@ -43,7 +42,6 @@
|
||||
SAMPLE_H_SRC=
|
||||
|
||||
# Any .c files that are needed to build libcustcalc.a.
|
||||
# Don't put ${REQUIRED_SRC} files in this list.
|
||||
#
|
||||
# There MUST be a .c in SAMPLE_SRC for every .o in SAMPLE_OBJ.
|
||||
#
|
||||
@@ -52,7 +50,6 @@ SAMPLE_H_SRC=
|
||||
SAMPLE_SRC= many_random.c test_random.c
|
||||
|
||||
# Any .o files that are needed by program that use libcustcalc.a.
|
||||
# Don't put ${REQUIRED_OBJ} files in this list.
|
||||
#
|
||||
# There MUST be a .c in SAMPLE_SRC for every .o in SAMPLE_OBJ.
|
||||
#
|
||||
@@ -135,7 +132,7 @@ 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
|
||||
@@ -236,6 +233,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.
|
||||
#
|
||||
@@ -262,12 +273,22 @@ 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=
|
||||
|
||||
# If you want to use a debugging link library such as a malloc debug link
|
||||
# library, or need to add special ld flags after the calc link libraries
|
||||
# are included, set ${LD_DEBUG} below.
|
||||
#
|
||||
# If in doubt, set LD_DEBUG to empty.
|
||||
#
|
||||
#LD_DEBUG= -lmalloc_cv
|
||||
LD_DEBUG=
|
||||
|
||||
# Normally, the upper level makefile will set these values. We provide
|
||||
# a default here just in case you want to build from this directory.
|
||||
@@ -492,8 +513,8 @@ depend:
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
${Q} (cd ..; ${MAKE} hsrc)
|
||||
${Q} for i in `cd ..; ${MAKE} h_list 2>&1 | \
|
||||
${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 \
|
||||
@@ -597,10 +618,10 @@ many_random.o: ../calc.h
|
||||
many_random.o: ../calcerr.h
|
||||
many_random.o: ../cmath.h
|
||||
many_random.o: ../config.h
|
||||
many_random.o: ../decl.h
|
||||
many_random.o: ../endian_calc.h
|
||||
many_random.o: ../hash.h
|
||||
many_random.o: ../have_const.h
|
||||
many_random.o: ../have_malloc.h
|
||||
many_random.o: ../have_memmv.h
|
||||
many_random.o: ../have_newstr.h
|
||||
many_random.o: ../have_stdlib.h
|
||||
@@ -614,7 +635,6 @@ many_random.o: ../shs.h
|
||||
many_random.o: ../shs1.h
|
||||
many_random.o: ../string.h
|
||||
many_random.o: ../value.h
|
||||
many_random.o: ../win32dll.h
|
||||
many_random.o: ../zmath.h
|
||||
many_random.o: ../zrandom.h
|
||||
many_random.o: many_random.c
|
||||
@@ -625,10 +645,10 @@ test_random.o: ../calc.h
|
||||
test_random.o: ../calcerr.h
|
||||
test_random.o: ../cmath.h
|
||||
test_random.o: ../config.h
|
||||
test_random.o: ../decl.h
|
||||
test_random.o: ../endian_calc.h
|
||||
test_random.o: ../hash.h
|
||||
test_random.o: ../have_const.h
|
||||
test_random.o: ../have_malloc.h
|
||||
test_random.o: ../have_memmv.h
|
||||
test_random.o: ../have_newstr.h
|
||||
test_random.o: ../have_stdlib.h
|
||||
@@ -642,7 +662,6 @@ test_random.o: ../shs.h
|
||||
test_random.o: ../shs1.h
|
||||
test_random.o: ../string.h
|
||||
test_random.o: ../value.h
|
||||
test_random.o: ../win32dll.h
|
||||
test_random.o: ../zmath.h
|
||||
test_random.o: ../zrandom.h
|
||||
test_random.o: test_random.c
|
||||
|
8
seed.c
8
seed.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* seed - produce a pseudo-random seeds
|
||||
*
|
||||
* 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.7 $
|
||||
* @(#) $Id: seed.c,v 29.7 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Revision: 29.8 $
|
||||
* @(#) $Id: seed.c,v 29.8 2007/02/11 10:19:14 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/seed.c,v $
|
||||
*
|
||||
* Under source code control: 1999/10/03 10:06:53
|
||||
@@ -171,7 +171,7 @@ typedef struct s_hash64 hash64;
|
||||
* returns:
|
||||
* 64 bit hash as a static hash64 structure
|
||||
*/
|
||||
static hash64
|
||||
S_FUNC hash64
|
||||
hash_buf(char *buf, unsigned len)
|
||||
{
|
||||
hash64 hval; /* current hash value */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user