Release calc version 2.12.1.13

This commit is contained in:
Landon Curt Noll
2007-02-18 07:31:59 -08:00
parent 253b47942f
commit f62d9fa1e6
37 changed files with 1263 additions and 1276 deletions

79
CHANGES
View File

@@ -16,9 +16,9 @@ The following are the changes from calc version 2.12.1.10 to date:
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.
When WITH_TLS is defined, calc attempts to compile with Thread Local
Storage. As of version 2.12.1.12 this mode is extremely experimental.
Calc may not compile when WITH_TLS defined.
Fixed E_FUNC vs EXTERN issues discovered by Mirko Viviani
<mirko at objectlab dot org>.
@@ -31,6 +31,69 @@ The following are the changes from calc version 2.12.1.10 to date:
Fixed FreeBSD dereferencing type-punned pointer error in filepos2z().
Removed SGI IRIX from the compiler section.
Moved the sample code in the sample sub-directory up into the
main source level. The sample/many_random.c source file is
now sample_many.c. The sample/test_random.c source file is now
sample_rand.c. The sample Makefile and the sub-directory is no more.
Renamed the following source files:
math_error.h ==> lib_calc.h
string.c ==> str.c
string.h ==> str.h
Renamed the following variables related to calc error processing:
int calc_jmp ==> int calc_use_matherr_jmpbuf
jmp_buf calc_jmp_buf ==> jmp_buf calc_matherr_jmpbuf
int post_init ==> int calc_use_scanerr_jmpbuf
jmp_buf jmpbuf ==> jmpbuf calc_scanerr_jmpbuf
char *calc_error ==> char calc_err_msg[MAXERROR+1]
These values are now declared in the lib_calc.h include file.
The value MAXERROR is now defined in lib_calc.h instead of calc.h.
The calc_err_msg[] buffer is now used for math errors as well
as scan and parse errors.
Parse/scan errors will not be printed if calc_print_scanerr_msg
is zero. By default:
int calc_print_scanerr_msg = 1;
This variable is declared in the lib_calc.h include file. Storage
comes from libcalc.
Parse/scan warnings will not be printed if calc_print_scanwarn_msg
is zero. By default:
int calc_print_scanwarn_msg = 1;
This variable is declared in the lib_calc.h include file. Storage
comes from libcalc.
The last parse/scan error message is stored in the calc_err_msg[]
buffer. This happens even when calc_print_scanerr_msg is zero.
The last parse/scan warning message is stored in the calc_warn_msg[]
buffer. After each parse/scan warning condition is detected,
the value calc_warn_cnt is incremented. This happens even when
calc_print_scanwarn_msg is zero.
The calc_warn_msg[] buffer and calc_warn_cnt variables are declared
in the lib_calc.h include file. Storage comes from libcalc.
See the file, LIBRARY or use the calc command "help libcalc" for
more information on calc error processing. This file has been
updated to reflect the changes noted above in this section.
The make install rule removes std_arg.h, have_malloc.h, math_error.h,
string.h, and win32dll.h from ${INCDIR} if they exist. These calc
include files are no longer supported.
The following are the changes from calc version 2.12.1.8 to 2.12.1.9:
@@ -41,11 +104,11 @@ The following are the changes from calc version 2.12.1.8 to 2.12.1.9:
/* c style comments */
/*
* multi-line
* commentts
* comments
*/
## two or more #-signs
### in a row
### Note that # along is a calc uniary and binary operator
### Note that # along is a calc unary and binary operator
Added "help pound" or "help #' to document the # operator, comments,
and the first line of cscript files.
@@ -169,7 +232,7 @@ The following are the changes from calc version 2.12.1 to 2.12.1.5:
Removed the ECHO_PROG Makefile variable. Also removed it from
the sysinfo() custom function.
Improved the support for cross-compiled environmens by using
Improved the support for cross-compiled environments by using
make symbols for all non-shell commands executed by Makefiles.
Fixed a problem with the make chk awk script which failed under
@@ -6373,8 +6436,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.100 $
## @(#) $Id: CHANGES,v 29.100 2007/02/12 08:22:13 chongo Exp $
## @(#) $Revision: 29.102 $
## @(#) $Id: CHANGES,v 29.102 2007/02/18 14:45:46 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
##
## Under source code control: 1993/06/02 18:12:57

249
LIBRARY
View File

@@ -58,13 +58,18 @@ External programs most likely want to use the installed calc header
files under ${INCDIRCALC}. External programs most likely NOT want
to define CALC_SRC.
You need to include the following file to get the symbols and variables
related to error handling:
lib_calc.h
External programs may want to compile with:
-L${LIBDIR} -lcalc
-I${INCDIR} -L${LIBDIR} -lcalc
If custom functions are also used, they may want to compile with:
-L${LIBDIR} -lcalc -lcustcalc
-I${INCDIR} -L${LIBDIR} -lcalc -lcustcalc
The CALC_SRC symbol should NOT be defined by default. However if you are
feeling pedantic you may want to force CALC_SRC to be undefined:
@@ -73,71 +78,215 @@ feeling pedantic you may want to force CALC_SRC to be undefined:
as well.
--------------
ERROR HANDLING
--------------
-------------------
MATH ERROR HANDLING
-------------------
Your program MUST provide a function called math_error. This is called by
the math routines on an error condition, such as malloc failures or a
division by zero. The routine is called in the manner of printf, with a
format string and optional arguments. (However, none of the low level math
routines currently uses formatting, so if you are lazy you can simply use
the first argument as a simple error string.) For example, one of the
error calls you might expect to receive is:
The math_error() function is called by the math routines on an error
condition, such as malloc failures, division by zero, or some form of
an internal computation error. The routine is called in the manner of
printf, with a format string and optional arguments:
math_error("Division by zero");
void math_error(char *fmt, ...);
Your program can handle errors in basically one of two ways. Firstly, it
can simply print the error message and then exit. Secondly, you can make
use of setjmp and longjmp in your program. Use setjmp at some appropriate
level in your program, and use longjmp in the math_error routine to return
to that level and so recover from the error. This is what the calc program
does.
Your program must handle math errors in one of three ways:
For convenience, the link library libcalc.a contains a math_error routine.
By default, this routine simply prints a message to stderr and then exits.
By simply linking in this link library, any calc errors will result in a
error message on stderr followed by an exit.
1) Print the error message and then exit
External programs that wish to use this math_error may want to compile with:
There is a math_error() function supplied with the calc library.
By default, this routine simply prints a message to stderr and
then exits. By simply linking in this link library, any calc
errors will result in a error message on stderr followed by
an exit.
-I${LIBDIR} -L${LIBDIR} -lcalc
2) Use setjmp and longjmp in your program
If one sets up calc_jmp_buf, and then sets calc_jmp to non-zero then
this routine will longjmp back (with the value of calc_jmp) instead.
In addition, the last calc error message will be found in calc_error;
this error is not printed to stderr. The calc error message will
not have a trailing newline.
Use setjmp at some appropriate level in your program, and let
the longjmp in math_error() return to that level and to allow you
to recover from the error. This is what the calc program does.
For example:
If one sets up calc_matherr_jmpbuf, and then sets
calc_use_matherr_jmpbuf to non-zero then math_error() will
longjmp back with the return value of calc_use_matherr_jmpbuf.
In addition, the last calc error message will be found in
calc_err_msg; this error is not printed to stderr. The calc
error message will not have a trailing newline.
#include <setjmp.h>
For example:
extern jmp_buf calc_jmp_buf;
extern int calc_jmp;
extern char *calc_error;
int error;
#include <setjmp.h>
#include "lib_calc.h"
...
int error;
if ((error = setjmp(calc_jmp_buf)) != 0) {
...
/* reinitialize calc after a longjmp */
reinitialize();
if ((error = setjmp(calc_matherr_jmpbuf)) != 0) {
/* report the error */
printf("Ouch: %s\n", calc_err_msg);
/* reinitialize calc after the longjmp */
reinitialize();
}
calc_use_matherr_jmpbuf = 1;
If calc_use_matherr_jmpbuf is non-zero, then the jmp_buf value
calc_matherr_jmpbuf must be initialized by the setjmp() function
or your program will crash.
3) Supply your own math_error function:
void math_error(char *fmt, ...);
Your math_error() function may exit or transfer control to outside
of the calc library, but it must never return or calc will crash.
External programs can obtain the appropriate calc symbols by compiling with:
-I${INCDIR} -L${LIBDIR} -lcalc
-------------------------
PARSE/SCAN ERROR HANDLING
-------------------------
The scanerror() function is called when calc encounters a parse/scan
error. For example, scanerror() is called when calc is given code
with a syntax error.
The variable, calc_print_scanerr_msg, controls if calc prints to stderr,
any parse/scan errors. By default, this variable it set to 1 and so
parse/scan errors are printed to stderr. By setting this value to zero,
parse/scan errors are not printed:
#include "lib_calc.h"
/* do not print parse/scan errors to stderr */
calc_print_scanerr_msg = 0;
The last calc math error or calc parse/scan error message is kept
in the NUL terminated buffer:
char calc_err_msg[MAXERROR+1];
The value of calc_print_scanerr_msg does not change the use
of the calc_err_msg[] buffer. Messages are stored in that
buffer regardless of the calc_print_scanerr_msg value.
The calc_print_scanerr_msg and the calc_err_msg[] buffer are declared
lib_calc.h include file. The initialized storage for these variables
comes from the calc library. The MAXERROR symbol is also declared in
the lib_calc.h include file.
Your program must handle parse/scan errors in one of two ways:
1) exit on error
If you do not setup the calc_scanerr_jmpbuf, then when calc
encounters a parse/scan error, a message will be printed to
stderr and calc will exit.
2) Use setjmp and longjmp in your program
Use setjmp at some appropriate level in your program, and let
the longjmp in scanerror() return to that level and to allow you
to recover from the error. This is what the calc program does.
If one sets up calc_scanerr_jmpbuf, and then sets
calc_use_scanerr_jmpbuf to non-zero then scanerror() will longjmp
back with the return with a non-zero code. In addition, the last
calc error message will be found in calc_err_msg[]; this error is
not printed to stderr. The calc error message will not have a
trailing newline.
For example:
#include <setjmp.h>
#include "lib_calc.h"
int scan_error;
...
/* delay the printing of the parse/scan error */
calc_use_scanerr_jmpbuf = 0; /* this is optional */
if ((scan_error = setjmp(calc_scanerr_jmpbuf)) != 0) {
/* report the parse/scan */
if (calc_use_scanerr_jmpbuf == 0) {
printf("parse error: %s\n", calc_err_msg);
}
/* initialize calc after the longjmp */
initialize();
}
calc_use_scanerr_jmpbuf = 1;
If calc_use_scanerr_jmpbuf is non-zero, then the jmp_buf value
calc_scanerr_jmpbuf must be initialized by the setjmp() function
or your program will crash.
External programs can obtain the appropriate calc symbols by compiling with:
-I${INCDIR} -L${LIBDIR} -lcalc
---------------------------
PARSE/SCAN WARNING HANDLING
---------------------------
Calc parse/scan warning message are printed to stderr by the warning()
function. The routine is called in the manner of printf, with a format
string and optional arguments:
void warning(char *fmt, ...);
The variable, calc_print_scanwarn_msg, controls if calc prints to stderr,
any parse/scan warnings. By default, this variable it set to 1 and so
parse/scan warnings are printed to stderr. By setting this value to zero,
parse/scan warnings are not printed:
#include "lib_calc.h"
/* do not print parse/scan warnings to stderr */
calc_print_scanwarn_msg = 0;
The last calc calc parse/scan warning message is kept in the NUL
terminated buffer:
char calc_warn_msg[MAXERROR+1];
The value of calc_print_scanwarn_msg does not change the use
of the calc_warn_msg[] buffer. Messages are stored in that
buffer regardless of the calc_print_scanwarn_msg value.
Your program must handle parse/scan warnings in one of two ways:
1) print the warning to stderr and continue
The warning() from libcalc prints warning messages to
stderr and returns. The flow of execution is not changed.
This is what calc does by default.
2) Supply your own warning function:
void warning(char *fmt, ...);
Your warning function should simply return when it is finished.
External programs can obtain the appropriate calc symbols by compiling with:
-I${INCDIR} -L${LIBDIR} -lcalc
/* report the error */
printf("Ouch: %s\n", calc_error);
}
calc_jmp = 1;
---------------
OUTPUT ROUTINES
---------------
The output from the routines in the link library normally goes to stdout. You
can divert that output to either another FILE handle, or else to a string.
Read the routines in zio.c to see what is available. Diversions can be
nested.
The output from the routines in the link library normally goes to stdout.
You can divert that output to either another FILE handle, or else
to a string. Read the routines in zio.c to see what is available.
Diversions can be nested.
You use math_setfp to divert output to another FILE handle. Calling
math_setfp with stdout restores output to stdout.
@@ -489,8 +638,8 @@ need call libcalc_call_me_last() only once.
## received 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: LIBRARY,v 29.5 2001/06/08 22:57:35 chongo Exp $
## @(#) $Revision: 29.7 $
## @(#) $Id: LIBRARY,v 29.7 2007/02/18 14:45:46 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/LIBRARY,v $
##
## Under source code control: 1993/07/30 19:44:49

543
Makefile

File diff suppressed because it is too large Load Diff

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.14 $
* @(#) $Id: addop.c,v 29.14 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.15 $
* @(#) $Id: addop.c,v 29.15 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/addop.c,v $
*
* Under source code control: 1990/02/15 01:48:10
@@ -33,7 +33,7 @@
#include <stdio.h>
#include "calc.h"
#include "opcodes.h"
#include "string.h"
#include "str.h"
#include "func.h"
#include "token.h"
#include "label.h"

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.11 $
* @(#) $Id: blkcpy.c,v 29.11 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.12 $
* @(#) $Id: blkcpy.c,v 29.12 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.c,v $
*
* Under source code control: 1997/04/18 20:41:26
@@ -36,7 +36,7 @@
#include "value.h"
#include "file.h"
#include "blkcpy.h"
#include "string.h"
#include "str.h"
/*

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: block.c,v 29.4 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.5 $
* @(#) $Id: block.c,v 29.5 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/block.c,v $
*
* Under source code control: 1997/02/27 00:29:40
@@ -37,7 +37,7 @@
#include "config.h"
#include "block.h"
#include "nametype.h"
#include "string.h"
#include "str.h"
#include "calcerr.h"
#define NBLOCKCHUNK 16

65
calc.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.15 $
* @(#) $Id: calc.c,v 29.15 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.16 $
* @(#) $Id: calc.c,v 29.16 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
*
* Under source code control: 1990/02/15 01:48:11
@@ -64,7 +64,7 @@
#include "have_uid_t.h"
#include "have_const.h"
#include "custom.h"
#include "math_error.h"
#include "lib_calc.h"
#include "args.h"
#include "zmath.h"
@@ -188,7 +188,7 @@ main(int argc, char **argv)
fprintf(stderr,
"-m expects"
" argument");
exit (1);
exit(2);
}
cp = argv[index];
}
@@ -203,7 +203,7 @@ main(int argc, char **argv)
fprintf(stderr,
"%s: unknown -m arg\n",
program);
exit(1);
exit(3);
}
allow_read = (((*cp-'0') & 04) > 0);
allow_write = (((*cp-'0') & 02) > 0);
@@ -211,7 +211,7 @@ main(int argc, char **argv)
cp++;
if (*cp != ' ' && *cp != '\0') {
fprintf(stderr, "??? m-arg");
exit(1);
exit(4);
}
havearg = TRUE;
break;
@@ -262,7 +262,7 @@ main(int argc, char **argv)
FALSE)) {
fprintf(stderr,
"-D expects argument\n");
exit (1);
exit(5);
}
havearg = TRUE;
if (*cp != ':') {
@@ -270,7 +270,7 @@ main(int argc, char **argv)
fprintf(stderr,
"-D expects"
" integer\n");
exit (1);
exit(6);
}
calc_debug = cp;
(void) strtol(cp, &endcp, 10);
@@ -280,7 +280,7 @@ main(int argc, char **argv)
fprintf(stderr,
"Bad syntax im -D"
" arg\n");
exit (1);
exit(7);
}
if (*cp != ':') {
if (nextcp(&cp, &index,
@@ -295,14 +295,14 @@ main(int argc, char **argv)
fprintf(stderr,
"-D : expects"
" argument\n");
exit (1);
exit(8);
}
if (*cp != ':') {
if (*cp < '0' || *cp > '9') {
fprintf(stderr,
"-D : expects"
" integer\n");
exit (1);
exit(9);
}
resource_debug = cp;
(void) strtol(cp, &endcp, 10);
@@ -312,7 +312,7 @@ main(int argc, char **argv)
fprintf(stderr,
"Bad syntax im -D"
" : arg\n");
exit (1);
exit(10);
}
if (*cp != ':') {
if (nextcp(&cp, &index,
@@ -327,12 +327,12 @@ main(int argc, char **argv)
FALSE)) {
fprintf(stderr, "-D : : expects"
" argument\n");
exit (1);
exit(11);
}
if (*cp < '0' || *cp > '9') {
fprintf(stderr, "-D :: expects"
" integer\n");
exit (1);
exit(12);
}
user_debug = cp;
(void) strtol(cp, &endcp, 10);
@@ -340,7 +340,7 @@ main(int argc, char **argv)
if (*cp != '\0' && *cp != ' ') {
fprintf(stderr, "Bad syntax in"
" -D : : arg\n");
exit (1);
exit(13);
}
break;
case 'f':
@@ -349,13 +349,13 @@ main(int argc, char **argv)
haveendstr)) {
fprintf(stderr, "-f expects"
" filename\n");
exit (1);
exit(14);
}
if (*cp == ';') {
fprintf(stderr,
"-f expects"
" filename\n");
exit (1);
exit(15);
}
havearg = TRUE;
if (cmdlen > 0)
@@ -373,7 +373,7 @@ main(int argc, char **argv)
fprintf(stderr, "-f -once"
" expects"
" filename\n");
exit (1);
exit(16);
}
}
bp = cmdbuf + cmdlen;
@@ -383,13 +383,13 @@ main(int argc, char **argv)
fprintf(stderr,
"Null"
" filename!");
exit (1);
exit(17);
}
if (cmdlen + len + 2 > MAXCMD) {
fprintf(stderr,
"Commands too"
" long");
exit (1);
exit(18);
}
/* XXX What if *cp = '\''? */
*bp++ = '\'';
@@ -404,7 +404,7 @@ main(int argc, char **argv)
fprintf(stderr,
"Commands"
" too long");
exit (1);
exit(19);
}
*bp++ = *cp++;
cmdlen++;
@@ -439,7 +439,7 @@ main(int argc, char **argv)
"usage: %s ... -f filename\n"
"1st cscript line: #/path/to/calc ... -f\n",
program, program);
exit(1);
exit(20);
}
if (havearg)
break;
@@ -465,7 +465,7 @@ main(int argc, char **argv)
fprintf(stderr,
"%s: commands too long\n",
program);
exit(1);
exit(21);
}
strncpy(cmdbuf + cmdlen, cp, cplen+1);
cmdlen = newcmdlen;
@@ -536,14 +536,13 @@ main(int argc, char **argv)
/*
* establish error longjump point with initial conditions
*/
if (setjmp(jmpbuf) == 0) {
if (setjmp(calc_scanerr_jmpbuf) == 0) {
/*
* reset/initialize the computing environment
*/
if (post_init)
initialize();
post_init = TRUE;
initialize();
calc_use_scanerr_jmpbuf = 1;
}
/*
@@ -735,7 +734,6 @@ void
math_error(char *fmt, ...)
{
va_list ap;
char buf[MAXERROR+1];
if (funcname && (*funcname != '*'))
fprintf(stderr, "\"%s\": ", funcname);
@@ -743,12 +741,13 @@ math_error(char *fmt, ...)
!inputisterminal()))
fprintf(stderr, "line %ld: ", funcline);
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
vsnprintf(calc_err_msg, MAXERROR, fmt, ap);
va_end(ap);
fprintf(stderr, "%s\n", buf);
calc_err_msg[MAXERROR] = '\0';
fprintf(stderr, "%s\n\n", calc_err_msg);
funcname = NULL;
if (post_init) {
longjmp(jmpbuf, 1);
if (calc_use_scanerr_jmpbuf != 0) {
longjmp(calc_scanerr_jmpbuf, 22);
} else {
fprintf(stderr, "It is too early provide a command line prompt "
"so we must simply exit. Sorry!\n");
@@ -756,7 +755,7 @@ math_error(char *fmt, ...)
* don't call libcalc_call_me_last() -- we might loop
* and besides ... this is an unusual internal error case
*/
exit(3);
exit(22);
}
}

7
calc.h
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.21 $
* @(#) $Id: calc.h,v 29.21 2007/02/12 03:26:23 chongo Exp $
* @(#) $Revision: 29.22 $
* @(#) $Id: calc.h,v 29.22 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.h,v $
*
* Under source code control: 1990/02/15 01:48:31
@@ -66,7 +66,6 @@
#define LISTCHAR ':' /* char which separates paths in a list */
#endif
#define MAXCMD 16384 /* maximum length of command invocation */
#define MAXERROR 512 /* maximum length of error message string */
#define SYMBOLSIZE 256 /* maximum symbol name size */
#define MAXLABELS 100 /* maximum number of user labels in function */
@@ -190,14 +189,12 @@ E_FUNC void reinitialize(void);
E_FUNC int isatty(int tty); /* TRUE if fd is a tty */
#endif
E_FUNC char *version(void); /* return version string */
EXTERN int post_init; /* TRUE => math_error setjmp is ready */
/*
* global flags and definitions
*/
EXTERN int abortlevel; /* current level of aborts */
EXTERN BOOL inputwait; /* TRUE if in a terminal input wait */
EXTERN jmp_buf jmpbuf; /* for errors */
EXTERN int p_flag; /* TRUE => pipe mode */
EXTERN int q_flag; /* TRUE => don't execute rc files */

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.23 $
* @(#) $Id: codegen.c,v 29.23 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.24 $
* @(#) $Id: codegen.c,v 29.24 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/codegen.c,v $
*
* Under source code control: 1990/02/15 01:48:13
@@ -36,12 +36,13 @@
#include <unistd.h>
#endif
#include "lib_calc.h"
#include "calc.h"
#include "token.h"
#include "symbol.h"
#include "label.h"
#include "opcodes.h"
#include "string.h"
#include "str.h"
#include "func.h"
#include "conf.h"
@@ -227,7 +228,14 @@ getcommands(BOOL toplevel)
run_state = RUN_EXIT;
else if (run_state < RUN_PRE_TOP_LEVEL)
run_state = RUN_PRE_TOP_LEVEL;
longjmp(jmpbuf, 1);
if (calc_use_scanerr_jmpbuf != 0) {
longjmp(calc_scanerr_jmpbuf, 30);
} else {
fprintf(stderr,
"calc_scanerr_jmpbuf not setup, exiting code 30\n");
libcalc_call_me_last();
exit(30);
}
}
}
}

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.24 $
* @(#) $Id: config.c,v 29.24 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.25 $
* @(#) $Id: config.c,v 29.25 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
*
* Under source code control: 1991/07/20 00:21:56
@@ -55,7 +55,7 @@
#include "block.h"
#include "nametype.h"
#include "config.h"
#include "string.h"
#include "str.h"
#include "custom.h"
#include "have_strdup.h"

View File

@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.31 $
# @(#) $Id: Makefile,v 29.31 2007/02/12 04:19:17 chongo Exp $
# @(#) $Revision: 29.32 $
# @(#) $Id: Makefile,v 29.32 2007/02/18 14:24:56 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/Makefile,v $
#
# Under source code control: 1997/03/09 02:28:54
@@ -203,103 +203,164 @@ SCRIPTDIR= ${BINDIR}/cscript
#
T=
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
# Debug/Optimize options for ${CC} and ${LCC}
#
# Debug/Optimize options for ${CC}
# Select DEBUG= -O2 -gstabs+ -DWINDOZ for DJGPP.
#
DEBUG= -O
#DEBUG=
#
#DEBUG= -O
#DEBUG= -O -g
#DEBUG= -O -g3
#
#DEBUG= -O1
#DEBUG= -O1 -g
#DEBUG= -O1 -g3
#
#DEBUG= -O2
#DEBUG= -O2 -g
#DEBUG= -O2 -g3
#DEBUG= -O2 -ipa
#DEBUG= -O2 -g3 -ipa
#
#DEBUG= -O3
#DEBUG= -O3 -g
#DEBUG= -O3 -g3
DEBUG= -O3 -g3
#DEBUG= -O3 -ipa
#DEBUG= -O3 -g3 -ipa
#
#DEBUG= -std0 -fast -O4 -static
#
#DEBUG= -g
#DEBUG= -g3
#DEBUG= -gx
#DEBUG= -WM,-g
#DEBUG=
#
#DEBUG= -O2 -gstabs+ -DWINDOZ
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
# How to compile .c files so that we can form a shared library.
#
# On systems that have dynamic shared libs, you may want want to disable them
# for faster calc startup.
# CC_SHARE= -fPIC
# Building for shared library using the gcc position independent code
# (PIC) model.
# CC_SHARE=
# Do not build for shared libraries.
#
# System type NO_SHARED recommendation
# NOTE: If CC_SHARE= is empty, then you very likely want to set
# CC_SHLIB= and LD_SHARE= to empty.
#
# BSD NO_SHARED=
# SYSV NO_SHARED= -dn
# IRIX NO_SHARED= -non_shared
# disable NO_SHARED=
# If in doubt, try:
# CC_SHARE= -fPIC
# If that fails try:
# CC_SHARE=
#
# If in doubt, use NO_SHARED=
# NOTE: Shared libraries are not yet supported. For now, use CC_SHARE=
#
NO_SHARED=
#NO_SHARED= -dn
#NO_SHARED= -non_shared
#CC_SHARE= -fPIC
CC_SHARE=
# 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.
# How build a shared librtary
# NOTE: This is not yet supported
#
# System type NO_SHARED recommendation
# CC_SHLIB= -shared "-Wl,-soname,libcalc.so.`./ver_calc${EXE} -V`"
# Building for shared library using the gcc position independent code
# (PIC) model.
# CC_SHLIB=
# Do not build for shared libraries.
#
# IRIX with NO_SHARED= -non_shared LD_NO_SHARED= -Wl,-rdata_shared
# IRIX with NO_SHARED= LD_NO_SHARED=
# others LD_NO_SHARED=
# NOTE: If CC_SHARE= is empty, then you very likely want to set
# CC_SHLIB= and LD_SHARE= to empty.
#
# If in doubt, use LD_NO_SHARED=
# If in doubt, try:
# CC_SHLIB= -shared "-Wl,-soname,libcalc.so.`./ver_calc${EXE} -V`"
# If that fails, try:
# CC_SHLIB=
#
LD_NO_SHARED=
#LD_NO_SHARED= -Wl,-rdata_shared
# NOTE: Shared libraries are not yet supported. For now, use CC_SHLIB=
#
#CC_SHLIB= -shared "-Wl,-soname,libcalc.so.`./ver_calc${EXE} -V`"
CC_SHLIB=
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
# How to link with a shared library
# NOTE: This is not yet supported
#
# LD_SHARE= -L.
# Building for shared library using the gcc position independent code
# (PIC) model.
# LD_SHARE=
#
# NOTE: If CC_SHARE= is empty, then you very likely want to set
# CC_SHLIB= and LD_SHARE= to empty.
# Do not build for shared libraries.
#
# If in doubt, try:
# LD_SHARE= -L.
# If that fails, try:
# LD_SHARE=
#
# NOTE: Shared libraries are not yet supported. For now, use LD_SHARE=
#
#LD_SHARE= -L.
LD_SHARE=
# Some systems require one to use ranlib to add a symbol table to
# a *.a link library. Set RANLIB to the utility that performs this action.
# Set RANLIB to : if your system does not need such a utility.
# a *.a link library. Set RANLIB to the utility that performs this
# action. Set RANLIB to : if your system does not need such a utility.
#
#RANLIB=ranlib
RANLIB=:
RANLIB=ranlib
#RANLIB=:
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
#
# Normally certain files depend on the Makefile. If the Makefile is
# changed, then certain steps should be redone. If MAKE_FILE is
# set to Makefile, then these files will depend on Makefile. If
# MAKE_FILE is empty, they they wont.
# MAKE_FILE is empty, then they wont.
#
# If in doubt, set MAKE_FILE to Makefile
#
MAKE_FILE= Makefile
#MAKE_FILE=
# 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, set PURIFY to an empty string.
#
# If in doubt, use PURIFY=
#
#PURIFY= purify -logfile=pure.out
#PURIFY= purify
#PURIFY= purify -m71-engine
#PURIFY= purify -logfile=pure.out
#PURIFY= purify -m71-engine -logfile=pure.out
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.
# 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=
# When doing a:
#
# make check
# make chk
# make debug
#
# the ${CALC_ENV} is used to supply the proper environment variables
# to calc. Most people will simply need 'CALCPATH=./cal' to ensure
# that these debug rules will only use calc resource files under the
# local source directory. The longer lines (with MALLOC_VERBOSE=1 ...)
# are useful for SGI IRIX people who have 'WorkShop Performance Tools'
# and who also set 'LD_DEBUG= -lmalloc_cv' above.
#
# If in doubt, use CALC_ENV= CALCPATH=./cal.
#
CALC_ENV= CALCPATH=./cal
#CALC_ENV= CALCPATH=./cal MALLOC_VERBOSE=1 MALLOC_TRACING=1 \
# MALLOC_FASTCHK=1 MALLOC_FULLWARN=1
#CALC_ENV= CALCPATH=./cal MALLOC_VERBOSE=1 MALLOC_TRACING=1 \
# MALLOC_FASTCHK=1 MALLOC_FULLWARN=1 MALLOC_CLEAR_FREE=1 \
# MALLOC_CLEAR_MALLOC=1
# By default, custom builtin functions may only be executed if calc
# is given the -C option. This is because custom builtin functions
# may invoke non-standard or non-portable code. One may completely
@@ -313,15 +374,44 @@ PURIFY=
ALLOW_CUSTOM= -DCUSTOM
#ALLOW_CUSTOM=
###
# The install rule uses:
#
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
# ${MKDIR} ${MKDIR_ARG}
#
# to create directorties. Normall this amounts to usins mkdir -p dir ...
# Some older systems may not have mkdir -p. If you system does not
# make mkdir -p, then set MKDIR_ARG to empty.
#
# MKDIR_ARG= -p # use mkdir -p when creating paths
# MKDIR_ARG= # use if system does not understand mkdir -p
#
MKDIR_ARG= -p
#MKDIR_ARG=
# Some out of date operating systems require / want an executable to
# end with a certain file extension. Some compile systems such as
# Cygwin build calc as calc.exe. The EXT variable is used to denote
# the extension required by such.
#
# EXT= # normal Un*x / Linux / GNU/Linux systems
# EXT=.exe # windoz / Cygwin
#
# If in doubt, use EXT=
#
EXT=
#EXT=.exe
################
# compiler set #
################
#
# Select your compiler type by commenting out one of the cc sets below:
#
# CCOPT are flags given to ${CC} for optimization
# CCWARN are flags given to ${CC} for warning message control
# CCWERR are flags given to ${CC} to make warnings fatal errors
# NOTE: CCWERR is only set in development Makefiles and must
# only be used with ${CC}, not ${LCC}.
# CCMISC are misc flags given to ${CC}
#
# CFLAGS are all flags given to ${CC} [[often includes CCOPT, CCWARN, CCMISC]]
@@ -330,23 +420,173 @@ ALLOW_CUSTOM= -DCUSTOM
# LDFLAGS are flags given to ${CC} for linking .o files
# ILDFLAGS are flags given to ${CC} for linking .o files for intermediate progs
#
# CC is how the the C compiler is invoked
# LCC how the the C compiler is invoked on locally executed intermediate progs
# CC is how the the C compiler is invoked (with an optional Purify)
#
###
#
# Linux set
#
CCWARN= -Wall -W -Wno-comment
CCWERR= -Werror
CCOPT= ${DEBUG} ${CC_SHARE}
CCMISC=
#
CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} -I/usr/include -I..
ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} -I/usr/include -I..
#
LDFLAGS= ${LD_SHARE}
ILDFLAGS=
#
LCC= gcc
CC= ${PURIFY} ${LCC} ${CCWERR}
#
###
#
# Apple Mac OS X
#
#CCWARN= -Wall -W -Wno-comment
#CCWERR=
#CCOPT= ${DEBUG} ${CC_SHARE}
#CCMISC= -arch i386 -arch ppc
#
#CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} -I/usr/include -I..
#ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} -I/usr/include -I..
#
#LDFLAGS= ${LD_SHARE} -arch i386 -arch ppc
#ILDFLAGS=
#
#LCC= gcc
#CC= ${PURIFY} ${LCC} ${CCWERR}
#
###
#
# gcc set
#
#CCWARN= -Wall -W -Wno-comment
#CCWERR=
#CCOPT= ${DEBUG} ${CC_SHARE}
#CCMISC=
#
#CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} -I/usr/include -I..
#ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} -I/usr/include -I..
#
#LDFLAGS= ${LD_SHARE}
#ILDFLAGS=
#
#LCC= gcc
#CC= ${PURIFY} ${LCC} ${CCWERR}
#
###
#
# common cc set
#
CCWARN=
CCOPT= ${DEBUG} ${NO_SHARED}
CCMISC=
# If -O3 -g3 is not supported try: DEBUG= -O2 -g
# If -O2 -g is not supported try: DEBUG= -O -g
#
CFLAGS= ${CCWARN} ${CCOPT} ${CCMISC} ${ALLOW_CUSTOM}
ICFLAGS= ${CCWARN} ${CCMISC}
#CCWARN=
#CCWERR=
#CCOPT= ${DEBUG} ${CC_SHARE}
#CCMISC=
#
LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED}
ILDFLAGS=
#CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} -I/usr/include -I..
#ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} -I/usr/include -I..
#
CC= ${PURIFY} cc
#LDFLAGS= ${LD_SHARE}
#ILDFLAGS=
#
#LCC= cc
#CC= ${PURIFY} ${LCC} ${CCWERR}
#
###
#
# HP-UX set
#
# If -O3 -g3 is not supported try: DEBUG= -O2 -g
# If -O2 -g is not supported try: DEBUG= -O -g
#
# Warning: Some HP-UX optimizers are brain-damaged.
# If 'make check' fails use: DEBUG= -g
#
#CCWARN=
#CCWERR=
#CCOPT= ${DEBUG} ${CC_SHARE}
#CCMISC= +e
#
#CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} -I/usr/include -I..
#ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} -I/usr/include -I..
#
#LDFLAGS= ${LD_SHARE}
#ILDFLAGS=
#
#LCC= cc
#CC= ${PURIFY} ${LCC} ${CCWERR}
#
###
#
# AIX RS/6000 set
#
# If -O3 -g3 is not supported try: DEBUG= -O2 -g
# If -O2 -g is not supported try: DEBUG= -O -g
#
#CCWARN=
#CCWERR=
#CCOPT= ${DEBUG} ${CC_SHARE}
#CCMISC= -qlanglvl=ansi
#
#CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} -I/usr/include -I..
#ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} -I/usr/include -I..
#
#LDFLAGS= ${LD_SHARE}
#ILDFLAGS=
#
#LCC= cc
#CC= ${PURIFY} ${LCC} ${CCWERR}
#
###
#
# Solaris Sun cc compiler set
#
# If -O3 -g3 is not supported try: DEBUG= -O2 -g
# If -O2 -g is not supported try: DEBUG= -O -g
#
# We need -DFORCE_STDC to make use of ANSI-C like features and
# to avoid the use of -Xc (which as a lose performance wise).
#
#CCWARN=
#CCWERR=
#CCOPT= ${DEBUG} ${CC_SHARE}
#CCMISC= -DFORCE_STDC
#
#CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} -I/usr/include -I..
#ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} -I/usr/include -I..
#
#LDFLAGS= ${LD_SHARE}
#ILDFLAGS=
#
#LCC= cc
#CC= ${PURIFY} ${LCC} ${CCWERR}
#
###
#
# Dec Alpha / Compaq Tru64 cc (non-gnu) compiler set
#
# For better performance, set the following: DEBUG= -std0 -fast -O4 -static
#
#CCWARN=
#CCWERR=
#CCOPT= ${DEBUG} ${CC_SHARE}
#CCMISC=
#
#CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} -I/usr/include -I..
#ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} -Wno-unused -I/usr/include -I..
#
#LDFLAGS= ${LD_SHARE}
#ILDFLAGS=
#
#LCC= cc
#CC= ${PURIFY} ${LCC} ${CCWERR}
##############################################################################
#-=-=-=-=-=-=-=-=- Be careful if you change something below -=-=-=-=-=-=-=-=-#
@@ -553,7 +793,7 @@ depend:
${Q} echo forming custom dependency list
${Q} echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > \
skel/custom/makedep.out
${Q} cd skel/custom; ${MAKEDEPEND} -w 1 -f makedep.out ${C_SRC}
${Q} cd skel/custom; ${MAKEDEPEND} -I.. -w 1 -f makedep.out ${C_SRC}
-${Q} for i in ${C_SRC} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
echo "$$i" | ${SED} 's/^\(.*\)\.c/\1.o: \1.c/'; \
@@ -860,7 +1100,7 @@ c_argv.o: ../nametype.h
c_argv.o: ../qmath.h
c_argv.o: ../shs.h
c_argv.o: ../shs1.h
c_argv.o: ../string.h
c_argv.o: ../str.h
c_argv.o: ../value.h
c_argv.o: ../zmath.h
c_argv.o: c_argv.c
@@ -879,6 +1119,7 @@ c_devnull.o: ../have_memmv.h
c_devnull.o: ../have_newstr.h
c_devnull.o: ../have_stdlib.h
c_devnull.o: ../have_string.h
c_devnull.o: ../have_unistd.h
c_devnull.o: ../have_unused.h
c_devnull.o: ../longbits.h
c_devnull.o: ../md5.h
@@ -886,7 +1127,7 @@ c_devnull.o: ../nametype.h
c_devnull.o: ../qmath.h
c_devnull.o: ../shs.h
c_devnull.o: ../shs1.h
c_devnull.o: ../string.h
c_devnull.o: ../str.h
c_devnull.o: ../value.h
c_devnull.o: ../zmath.h
c_devnull.o: c_devnull.c
@@ -905,6 +1146,7 @@ c_help.o: ../have_memmv.h
c_help.o: ../have_newstr.h
c_help.o: ../have_stdlib.h
c_help.o: ../have_string.h
c_help.o: ../have_unistd.h
c_help.o: ../have_unused.h
c_help.o: ../longbits.h
c_help.o: ../md5.h
@@ -912,7 +1154,7 @@ c_help.o: ../nametype.h
c_help.o: ../qmath.h
c_help.o: ../shs.h
c_help.o: ../shs1.h
c_help.o: ../string.h
c_help.o: ../str.h
c_help.o: ../value.h
c_help.o: ../zmath.h
c_help.o: c_help.c
@@ -938,7 +1180,7 @@ c_pmodm127.o: ../nametype.h
c_pmodm127.o: ../qmath.h
c_pmodm127.o: ../shs.h
c_pmodm127.o: ../shs1.h
c_pmodm127.o: ../string.h
c_pmodm127.o: ../str.h
c_pmodm127.o: ../value.h
c_pmodm127.o: ../zmath.h
c_pmodm127.o: c_pmodm127.c
@@ -964,7 +1206,7 @@ c_pzasusb8.o: ../nametype.h
c_pzasusb8.o: ../qmath.h
c_pzasusb8.o: ../shs.h
c_pzasusb8.o: ../shs1.h
c_pzasusb8.o: ../string.h
c_pzasusb8.o: ../str.h
c_pzasusb8.o: ../value.h
c_pzasusb8.o: ../zmath.h
c_pzasusb8.o: c_pzasusb8.c
@@ -988,6 +1230,7 @@ c_sysinfo.o: ../have_stdlib.h
c_sysinfo.o: ../have_string.h
c_sysinfo.o: ../have_unused.h
c_sysinfo.o: ../hist.h
c_sysinfo.o: ../lib_calc.h
c_sysinfo.o: ../longbits.h
c_sysinfo.o: ../md5.h
c_sysinfo.o: ../nametype.h
@@ -995,7 +1238,7 @@ c_sysinfo.o: ../prime.h
c_sysinfo.o: ../qmath.h
c_sysinfo.o: ../shs.h
c_sysinfo.o: ../shs1.h
c_sysinfo.o: ../string.h
c_sysinfo.o: ../str.h
c_sysinfo.o: ../value.h
c_sysinfo.o: ../zmath.h
c_sysinfo.o: ../zrand.h
@@ -1022,7 +1265,7 @@ custtbl.o: ../nametype.h
custtbl.o: ../qmath.h
custtbl.o: ../shs.h
custtbl.o: ../shs1.h
custtbl.o: ../string.h
custtbl.o: ../str.h
custtbl.o: ../value.h
custtbl.o: ../zmath.h
custtbl.o: custtbl.c

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.8 $
* @(#) $Id: c_argv.c,v 29.8 2006/06/25 22:06:23 chongo Exp $
* @(#) $Revision: 29.9 $
* @(#) $Id: c_argv.c,v 29.9 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_argv.c,v $
*
* Under source code control: 1997/03/09 20:27:37
@@ -33,14 +33,14 @@
#include <stdio.h>
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "../config.h"
#include "../calc.h"
#include "config.h"
#include "calc.h"
#include "../have_unused.h"
#include "have_unused.h"
/*
* c_argv - a custom function display info about its args

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: c_devnull.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
* @(#) $Revision: 29.5 $
* @(#) $Id: c_devnull.c,v 29.5 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_devnull.c,v $
*
* Under source code control: 1997/03/09 17:49:12
@@ -31,12 +31,16 @@
#if defined(CUSTOM)
#include "have_unistd.h"
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "../have_unused.h"
#include "have_unused.h"
/*

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: c_help.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
* @(#) $Revision: 29.5 $
* @(#) $Id: c_help.c,v 29.5 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_help.c,v $
*
* Under source code control: 1997/03/09 05:25:41
@@ -31,12 +31,16 @@
#if defined(CUSTOM)
#include "have_unistd.h"
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "../have_unused.h"
#include "have_unused.h"
/*

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.6 $
* @(#) $Id: c_pmodm127.c,v 29.6 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.7 $
* @(#) $Id: c_pmodm127.c,v 29.7 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_pmodm127.c,v $
*
* Under source code control: 2004/07/28 22:12:25
@@ -32,12 +32,12 @@
#include <stdio.h>
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "../zmath.h"
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "zmath.h"
#include "../have_unused.h"
#include "have_unused.h"
/* 2^255 */
STATIC HALF h255[] = {

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: c_pzasusb8.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
* @(#) $Revision: 29.5 $
* @(#) $Id: c_pzasusb8.c,v 29.5 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_pzasusb8.c,v $
*
* Under source code control: 1999/10/06 03:12:25
@@ -32,12 +32,12 @@
#include <stdio.h>
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "../zmath.h"
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "zmath.h"
#include "../have_unused.h"
#include "have_unused.h"
/*
* c_pzasusb8 - print numereator as a string of USB8s

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.13 $
* @(#) $Id: c_sysinfo.c,v 29.13 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.14 $
* @(#) $Id: c_sysinfo.c,v 29.14 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_sysinfo.c,v $
*
* Under source code control: 1997/03/09 23:14:40
@@ -34,25 +34,31 @@
#include <stdio.h>
#include <ctype.h>
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "have_string.h"
#if defined(HAVE_STRING_H)
#include <string.h>
#endif
#include "../config.h"
#include "../calc.h"
#include "../longbits.h"
#include "have_const.h"
#include "value.h"
#include "custom.h"
#include "config.h"
#include "lib_calc.h"
#include "calc.h"
#include "longbits.h"
#define CHECK_L_FORMAT
#include "../block.h"
#include "../calcerr.h"
#include "../conf.h"
#include "../endian_calc.h"
#include "../fposval.h"
#include "../hist.h"
#include "../prime.h"
#include "../zrand.h"
#include "../zrandom.h"
#include "block.h"
#include "calcerr.h"
#include "conf.h"
#include "endian_calc.h"
#include "fposval.h"
#include "hist.h"
#include "prime.h"
#include "zrand.h"
#include "zrandom.h"
#include "../have_unused.h"
#include "have_unused.h"
/*

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.5 $
* @(#) $Id: custtbl.c,v 29.5 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.6 $
* @(#) $Id: custtbl.c,v 29.6 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/custtbl.c,v $
*
* Under source code control: 1997/03/09 02:28:54
@@ -28,10 +28,11 @@
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
#include <unistd.h>
#include "../have_const.h"
#include "../value.h"
#include "../custom.h"
#include "have_const.h"
#include "value.h"
#include "custom.h"
/*
* NOTE: See the file CUSTOM for instructions on how to add

12
decl.h
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: decl.h,v 29.4 2007/02/12 03:38:42 chongo Exp $
* @(#) $Revision: 29.5 $
* @(#) $Id: decl.h,v 29.5 2007/02/15 09:50:28 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/decl.h,v $
*
* Under source code control: 2007/02/09 05:24:25
@@ -38,12 +38,12 @@
/*
* Mac OS X Thread Local Storage macros
* Thread Local Storage macros
*
* NOTE: The use of -DMACOSX_TLS is extremely experimental. Calc may not
* compile with MACOSX_TLS defined.
* NOTE: The use of -DWITH_TLS is extremely experimental. Calc may not
* compile with WITH_TLS defined.
*/
#if defined(MACOSX_TLS)
#if defined(WITH_TLS)
/* variable related macros */

6
func.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.33 $
* @(#) $Id: func.c,v 29.33 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.34 $
* @(#) $Id: func.c,v 29.34 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/func.c,v $
*
* Under source code control: 1990/02/15 01:48:15
@@ -101,7 +101,7 @@
#include "opcodes.h"
#include "token.h"
#include "func.h"
#include "string.h"
#include "str.h"
#include "symbol.h"
#include "prime.h"
#include "file.h"

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: label.c,v 29.3 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: label.c,v 29.4 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/label.c,v $
*
* Under source code control: 1990/02/15 01:48:17
@@ -31,7 +31,7 @@
#include "calc.h"
#include "token.h"
#include "label.h"
#include "string.h"
#include "str.h"
#include "opcodes.h"
#include "func.h"

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.15 $
* @(#) $Id: lib_calc.c,v 29.15 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.16 $
* @(#) $Id: lib_calc.c,v 29.16 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/lib_calc.c,v $
*
* Under source code control: 1996/06/17 18:06:19
@@ -37,6 +37,7 @@
# include <pwd.h>
#endif
#include "lib_calc.h"
#include "calc.h"
#include "zmath.h"
#include "zrandom.h"
@@ -109,7 +110,6 @@ E_FUNC uid_t geteuid();
int use_old_std = FALSE; /* TRUE => use old classic configuration */
int abortlevel; /* current level of aborts */
BOOL inputwait; /* TRUE if in a terminal input wait */
jmp_buf jmpbuf; /* for errors */
char *program = "calc"; /* our name */
char *base_name = "calc"; /* basename of our name */
char cmdbuf[MAXCMD+1+1+1]; /* command line expression + "\n\0" + guard */
@@ -148,9 +148,30 @@ char *shell = NULL; /* $SHELL or default */
int stdin_tty = FALSE; /* TRUE if stdin is a tty */
int havecommands = FALSE; /* TRUE if have one or more cmd args */
long stoponerror = 0; /* >0 => stop, <0 => continue, ==0 => use -c */
int post_init = FALSE; /* TRUE setjmp for math_error is ready */
BOOL abort_now = FALSE; /* TRUE => go interactive now, if permitted */
/* non-zero => calc_scanerr_jmpbuf ready */
int calc_use_scanerr_jmpbuf = 0;
/* for scan and parse errors */
jmp_buf calc_scanerr_jmpbuf;
/* non-zero => use calc_use_matherr_jmpbuf */
int calc_use_matherr_jmpbuf = 0;
/* math_error() control jump point when calc_use_matherr_jmpbuf != 0 */
jmp_buf calc_matherr_jmpbuf;
/* last calc error message, also parse/scan errors use this buffer */
char calc_err_msg[MAXERROR+1];
/* 0 ==> do not print parse/scan errors */
int calc_print_scanerr_msg = 1;
/* last parse/scan warning message */
char calc_warn_msg[MAXERROR+1];
/* 0 ==> do not print parse/scan warnings */
int calc_print_scanwarn_msg = 1;
/* number of parse/scan warnings found */
unsigned long calc_warn_cnt = 0;
int argc_value = 0; /* count of argv[] strings for argv() builtin */
char **argv_value = NULL; /* argv[] strings for argv() builtin */
@@ -184,6 +205,7 @@ 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 */
STATIC BOOL initialized = FALSE; /* TRUE => initialize() has been run */
/*
@@ -304,6 +326,13 @@ libcalc_call_me_first(void)
void
initialize(void)
{
/*
* firewall
*/
if (initialized) {
return;
}
/*
* ZVALUE io initialization
*/
@@ -340,6 +369,11 @@ initialize(void)
math_setmode(MODE_INITIAL);
math_setdigits(DISPLAY_DEFAULT);
conf->maxprint = MAXPRINT_DEFAULT;
/*
* note that we are done
*/
initialized = TRUE;
}

View File

@@ -17,9 +17,9 @@
* received 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: 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 $
* @(#) $Revision: 29.7 $
* @(#) $Id: lib_calc.h,v 29.7 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/lib_calc.h,v $
*
* Under source code control: 1997/03/23 18:37:10
* File existed as early as: 1997
@@ -32,6 +32,7 @@
#if !defined(__MATH_ERROR_H__)
#define __MATH_ERROR_H__
#include <setjmp.h>
#if defined(CALC_SRC) /* if we are building from the calc source tree */
# include "decl.h"
@@ -39,11 +40,42 @@
# include <calc/decl.h>
#endif
/*
* error buffer definitions
*/
#define MAXERROR 512 /* maximum length of error message string */
/*
* Global data definitions.
* calc math error control
*/
EXTERN jmp_buf jmpbuf; /* for errors */
/* non-zero => use calc_use_matherr_jmpbuf */
EXTERN int calc_use_matherr_jmpbuf;
/* math_error() control jump point when calc_use_matherr_jmpbuf != 0 */
EXTERN jmp_buf calc_matherr_jmpbuf;
/*
* calc parse/scan error control
*/
/* non-zero => calc_scanerr_jmpbuf is ready */
EXTERN int calc_use_scanerr_jmpbuf;
/* scanerror() control jump point when calc_use_scanerr_jmpbuf != 0 */
EXTERN jmp_buf calc_scanerr_jmpbuf;
/*
* last calc math error, parse/scan error message
*/
EXTERN char calc_err_msg[MAXERROR+1];
/* 0 ==> do not print parse/scan errors */
EXTERN int calc_print_scanerr_msg;
/*
* calc parse/scan warning control
*/
/* last parse/scan warning message */
EXTERN char calc_warn_msg[MAXERROR+1];
/* 0 ==> do not print parse/scan warnings */
EXTERN int calc_print_scanwarn_msg;
/* number of parse/scan warnings found */
EXTERN unsigned long calc_warn_cnt;
#endif /* !__MATH_ERROR_H__ */

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: math_error.c,v 29.3 2006/06/02 09:52:22 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: math_error.c,v 29.4 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/math_error.c,v $
*
* Under source code control: 1994/08/03 05:08:22
@@ -36,31 +36,29 @@
*
* By default, this routine simply prints a message to stderr and then exits.
*
* If one sets up calc_jmp_buf, and then sets calc_jmp to non-zero then
* this routine will longjmp back (with the value of calc_jmp) instead.
* In addition, the last calc error message will be found in calc_error;
* this error is not printed to sttderr.
* If one sets up calc_matherr_jmpbuf, and then sets calc_use_matherr_jmpbuf
* to non-zero then this routine will longjmp back with the return value of
* calc_use_matherr_jmpbuf. In addition, the last calc error message will be
* found in calc_use_matherr_jmpbuf_msg. This error is not printed to sttderr.
*
* For example:
*
* #include <setjmp.h>
* #include "lib_calc.h"
*
* extern jmp_buf calc_jmp_buf;
* extern int calc_jmp;
* extern char *calc_error;
* int error;
*
* ...
*
* if ((error = setjmp(calc_jmp_buf)) != 0) {
* if ((error = setjmp(calc_matherr_jmpbuf)) != 0) {
*
* (* reinitialize calc after a longjmp *)
* reinitialize();
*
* (* report the error *)
* printf("Ouch: %s\n", calc_error);
* printf("Ouch: %s\n", calc_err_msg);
* }
* calc_jmp = 1;
* calc_use_matherr_jmpbuf = 1;
*/
@@ -68,15 +66,7 @@
#include <setjmp.h>
#include "args.h"
#include "calc.h"
#include "math_error.h"
/*
* error jump point we will longjmp to this jmp_buf if calc_jmp is non-zero
*/
jmp_buf calc_jmp_buf;
int calc_jmp = 0; /* non-zero => use calc_jmp_buf */
char calc_error[MAXERROR+1]; /* last calc error message */
#include "lib_calc.h"
/*
@@ -95,15 +85,15 @@ math_error(char *fmt, ...)
#else
va_start(ap, fmt);
#endif
vsnprintf(calc_error, MAXERROR, fmt, ap);
vsnprintf(calc_err_msg, MAXERROR, fmt, ap);
va_end(ap);
calc_error[MAXERROR] = '\0';
calc_err_msg[MAXERROR] = '\0';
/*
* if we should longjmp, so do
*/
if (calc_jmp != 0) {
longjmp(calc_jmp_buf, calc_jmp);
if (calc_use_matherr_jmpbuf != 0) {
longjmp(calc_matherr_jmpbuf, calc_use_matherr_jmpbuf);
}
/*
@@ -111,8 +101,7 @@ math_error(char *fmt, ...)
*/
(void) fflush(stdout);
(void) fflush(stderr);
fprintf(stderr, "%s\n", calc_error);
fputc('\n', stderr);
fprintf(stderr, "%s\n\n", calc_err_msg);
libcalc_call_me_last();
exit(1);
exit(40);
}

6
obj.c
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.9 $
* @(#) $Id: obj.c,v 29.9 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.10 $
* @(#) $Id: obj.c,v 29.10 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/obj.c,v $
*
* Under source code control: 1990/02/15 01:48:19
@@ -38,7 +38,7 @@
#include "opcodes.h"
#include "func.h"
#include "symbol.h"
#include "string.h"
#include "str.h"
/*

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.13 $
* @(#) $Id: opcodes.c,v 29.13 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.14 $
* @(#) $Id: opcodes.c,v 29.14 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/opcodes.c,v $
*
* Under source code control: 1990/02/15 01:48:19
@@ -44,9 +44,9 @@
#include "zrandom.h"
#include "have_fpos.h"
#include "custom.h"
#include "math_error.h"
#include "lib_calc.h"
#include "block.h"
#include "string.h"
#include "str.h"
#include "have_unused.h"
@@ -3260,7 +3260,14 @@ o_quit(FUNC *fp, long index)
}
freevalue(stackarray);
run_state = RUN_EXIT;
longjmp(jmpbuf, 1);
if (calc_use_scanerr_jmpbuf != 0) {
longjmp(calc_scanerr_jmpbuf, 50);
} else {
fprintf(stderr,
"calc_scanerr_jmpbuf not setup, exiting code 50\n");
libcalc_call_me_last();
exit(50);
}
}
if (cp)
printf("%s\n", cp);

View File

@@ -3,9 +3,7 @@ Sample usage of libcalc.a
This directory contains a few examples of how to use libcalc.a.
For more details on how to use libcalc.a, see the file ../LIBRARY.
chongo <share and enjoy :-)> /\oo/\
For more details on how to use libcalc.a, see the file LIBRARY.
=-=
@@ -54,7 +52,7 @@ many_random
bitlen number of random bits per line set (default: 128 bits)
seed_string seed using this ASCII string (default: use default seed)
## 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
@@ -70,9 +68,9 @@ many_random
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: README_SAMPLE,v 29.2 2000/06/07 14:02:54 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/sample/RCS/README_SAMPLE,v $
## @(#) $Revision: 29.3 $
## @(#) $Id: sample.README,v 29.3 2007/02/15 09:27:18 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/sample.README,v $
##
## Under source code control: 1997/04/19 23:15:42
## File existed as early as: 1997

View File

@@ -1,667 +0,0 @@
#
# sample - makefile for calc sample programs
#
# Copyright (C) 1999-2006 Landon Curt Noll
#
# Calc is open software; you can redistribute it and/or modify it under
# the terms of the version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# Calc is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
# Public License for more details.
#
# A copy of version 2.1 of the GNU Lesser General Public License is
# distributed with calc under the filename COPYING-LGPL. You should have
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.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
# File existed as early as: 1997
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
#
# calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll
##############################################################################
#-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-#
##############################################################################
# Any .h files that are needed by programs that use libcustcalc.a
#
# Put any .h files that you add which might be useful to other
# programs here.
#
SAMPLE_H_SRC=
# Any .c files that are needed to build libcustcalc.a.
#
# There MUST be a .c in SAMPLE_SRC for every .o in SAMPLE_OBJ.
#
# Put your sample .c files here.
#
SAMPLE_SRC= many_random.c test_random.c
# Any .o files that are needed by program that use libcustcalc.a.
#
# There MUST be a .c in SAMPLE_SRC for every .o in SAMPLE_OBJ.
#
# Put your sample .o files here.
#
SAMPLE_OBJ= many_random.o test_random.o
##############################################################################
#-=-=-=-=-=-=- Defaults in case you want to build from this dir -=-=-=-=-=-=-#
##############################################################################
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
#
# Makefile debug
#
# Q=@ do not echo internal makefile actions (quiet mode)
# Q= echo internal makefile actions (debug / verbose mode)
#
#Q=
Q=@
####
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
####
# Where the system include (.h) files are kept
#
# For DJGPP, select:
#
# INCDIR= /dev/env/DJDIR/include
#
# If in doubt, set:
#
# INCDIR= /usr/include
#
#INCDIR= /usr/local/include
#INCDIR= /dev/env/DJDIR/include
INCDIR= /usr/include
# where to install calc realted things
#
# ${BINDIR} where to install calc binary files
# ${LIBDIR} where calc link library (*.a) files are installed
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
#
# NOTE: The install rule prepends installation paths with ${T}, which
# by default is empty. If ${T} is non-empty, then installation
# locations will be relative to the ${T} directory.
#
# For DJGPP, select:
#
# BINDIR= /dev/env/DJDIR/bin
# LIBDIR= /dev/env/DJDIR/lib
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
#
# If in doubt, set:
#
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
#
#BINDIR= /usr/local/bin
#BINDIR= /dev/env/DJDIR/bin
BINDIR= /usr/bin
#LIBDIR= /usr/local/lib
#LIBDIR= /dev/env/DJDIR/lib
LIBDIR= /usr/lib
#CALC_SHAREDIR= /usr/local/lib/calc
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
CALC_SHAREDIR= /usr/share/calc
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
# ---------------------------------------------------------------
# ${HELPDIR} where the help directory is installed
# ${CALC_INCDIR} where the calc include files are installed
# ${CUSTOMCALDIR} where custom *.cal files are installed
# ${CUSTOMHELPDIR} where custom help files are installed
# ${CUSTOMINCDIR} where custom .h files are installed
# ${SCRIPTDIR} where calc shell scripts are installed
#
# NOTE: The install rule prepends installation paths with ${T}, which
# by default is empty. If ${T} is non-empty, then installation
# locations will be relative to the ${T} directory.
#
# If in doubt, set:
#
# HELPDIR= ${CALC_SHAREDIR}/help
# CALC_INCDIR= ${INCDIR}/calc
# CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
# CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
# CUSTOMINCDIR= ${CALC_INCDIR}/custom
# SCRIPTDIR= ${BINDIR}/cscript
#
HELPDIR= ${CALC_SHAREDIR}/help
CALC_INCDIR= ${INCDIR}/calc
CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
CUSTOMINCDIR= ${CALC_INCDIR}/custom
SCRIPTDIR= ${BINDIR}/cscript
# T - top level directory under which calc will be installed
#
# The calc install is performed under ${T}, the calc build is
# performed under /. The purpose for ${T} is to allow someone
# to install calc somewhere other than into the system area.
#
# For example, if:
#
# BINDIR= /usr/bin
# LIBDIR= /usr/lib
# CALC_SHAREDIR= /usr/share/calc
#
# and if:
#
# T= /var/tmp/testing
#
# Then the installation locations will be:
#
# calc binary files: /var/tmp/testing/usr/bin
# calc link library: /var/tmp/testing/usr/lib
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
# ... etc ... /var/tmp/testing/...
#
# If ${T} is empty, calc is installed under /, which is the same
# top of tree for which it was built. If ${T} is non-empty, then
# calc is installed under ${T}, as if one had to chroot under
# ${T} for calc to operate.
#
# If in doubt, use T=
#
T=
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
#
# Debug/Optimize options for ${CC}
#
DEBUG= -O
#DEBUG= -O -g
#DEBUG= -O -g3
#DEBUG= -O1
#DEBUG= -O1 -g
#DEBUG= -O1 -g3
#DEBUG= -O2
#DEBUG= -O2 -g
#DEBUG= -O2 -g3
#DEBUG= -O2 -ipa
#DEBUG= -O2 -g3 -ipa
#DEBUG= -O3
#DEBUG= -O3 -g
#DEBUG= -O3 -g3
#DEBUG= -O3 -ipa
#DEBUG= -O3 -g3 -ipa
#DEBUG= -g
#DEBUG= -g3
#DEBUG= -gx
#DEBUG= -WM,-g
#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.
#
# On systems that have dynamic shared libs, you may want want to disable them
# for faster calc startup.
#
# System type NO_SHARED recommendation
#
# BSD NO_SHARED=
# SYSV NO_SHARED= -dn
# IRIX NO_SHARED= -non_shared
# disable NO_SHARED=
#
# If in doubt, use NO_SHARED=
#
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.
#
# Some systems require one to use ranlib to add a symbol table to
# a *.a link library. Set RANLIB to the utility that performs this action.
# Set RANLIB to : if your system does not need such a utility.
#
#RANLIB=ranlib
RANLIB=:
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
#
# Normally certain files depend on the Makefile. If the Makefile is
# changed, then certain steps should be redone. If MAKE_FILE is
# set to Makefile, then these files will depend on Makefile. If
# MAKE_FILE is empty, they they wont.
#
# If in doubt, set MAKE_FILE to Makefile
#
MAKE_FILE= Makefile
#MAKE_FILE=
# 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, set PURIFY to an empty string.
#
# 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.
#
# By default, custom builtin functions may only be executed if calc
# is given the -C option. This is because custom builtin functions
# may invoke non-standard or non-portable code. One may completely
# disable custom builtin functions by not compiling any of code
#
# ALLOW_CUSTOM= -DCUSTOM # allow custom only if -C is given
# ALLOW_CUSTOM= # disable custom even if -C is given
#
# If in doubt, use ALLOW_CUSTOM= -DCUSTOM
#
ALLOW_CUSTOM= -DCUSTOM
#ALLOW_CUSTOM=
# Normally, the upper level makefile will set these values. We provide
# a default here just in case you want to build from this directory.
#
# The sample routines need to be compiled with libcalc.a. The ${CALC_LIBS}
# variable tells where this link library may be found
#
# CALC_LIBS= ../libcalc.a ... # compile with libcalc.a in dir above
# CALC_LIBS= ${LIBDIR}/libcalc.a ... # compile the installed libcalc.a
# CALC_LIBS= -lcalc ... # compile with the system libcalc.a
#
# If in doubt, use CALC_LIBS= ../libcalc.a
#
CALC_LIBS= ../libcalc.a ../custom/libcustcalc.a
#CALC_LIBS= ${LIBDIR}/libcalc.a ${LIBDIR}/libcustcalc.a
#CALC_LIBS= -lcalc -lcustcalc
###
#
# CCOPT are flags given to ${CC} for optimization
# CCWARN are flags given to ${CC} for warning message control
# CCMISC are misc flags given to ${CC}
#
# CFLAGS are all flags given to ${CC} [[often includes CCOPT, CCWARN, CCMISC]]
# ICFLAGS are given to ${CC} for intermediate progs
#
# LDFLAGS are flags given to ${CC} for linking .o files
# ILDFLAGS are flags given to ${CC} for linking .o files for intermediate progs
#
# LCC how the the C compiler is invoked on locally executed intermediate progs
# CC is how the the C compiler is invoked (with an optional Purify)
#
###
#
# default set
#
# Normally these values are passed in from the upper level Makefile.
# Change these as needed if you intend to build directly in this directory.
#
# for better performance, set the following above:
# DEBUG= -O2
#
CCWARN= -Wall -Wno-implicit -Wno-comment
CCOPT= ${DEBUG} ${NO_SHARED}
CCMISC=
#
CFLAGS= ${CCWARN} ${CCOPT} ${CCMISC}
ICFLAGS= ${CCWARN} ${CCMISC}
#
LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED}
ILDFLAGS=
#
LCC= gcc
CC= ${PURIFY} ${LCC}
##############################################################################
#-=-=-=-=-=-=-=-=- Be careful if you change something below -=-=-=-=-=-=-=-=-#
##############################################################################
# These .c files are used to build the dependency list
#
C_SRC= ${SAMPLE_SRC}
# These .h files are used to build the dependecy list
#
H_SRC= ${SAMPLE_H_SRC}
# These files are found (but not built) in the distribution
#
# The SAMPLE_CAL and HOW_TO_ADD are files distributed from this
# directory but are installed as help files from the help/Makefile.
#
DISTLIST= ${C_SRC} ${H_SRC} ${MAKE_FILE} README_SAMPLE
# These files are used to make (but not built) a calc .a link library
#
CALCLIBLIST= ${C_SRC} ${H_SRC} ${MAKE_FILE} README_SAMPLE
# complete list of targets
#
# NOTE: This list MUST be coordinated with the ${SAMPLE_TARGETS} variable
# in the upper level ../Makefile
#
SAMPLE_TARGETS= many_random test_random
TARGETS= ${SAMPLE_TARGETS}
# required vars
#
SHELL= /bin/sh
# standard tools
#
SED= sed
MAKEDEPEND= makedepend
CHMOD= chmod
SORT= sort
CMP= cmp
TRUE= true
RM= rm
TOUCH= touch
MKDIR= mkdir
MV= mv
CO= co
##
#
# Standard rules and targets
#
##
all: ${TARGETS} .all
@${TRUE}
test_random.o: test_random.c
${CC} ${CFLAGS} ${ALLOW_CUSTOM} test_random.c -c
test_random: test_random.o ../libcalc.a
${CC} ${LDFLAGS} test_random.o ${CALC_LIBS} ${LD_DEBUG} -o test_random
many_random.o: many_random.c
${CC} ${CFLAGS} ${ALLOW_CUSTOM} many_random.c -c
many_random: many_random.o ../libcalc.a
${CC} ${LDFLAGS} many_random.o ${CALC_LIBS} ${LD_DEBUG} -o many_random
##
#
# used by the upper level Makefile
#
##
# to determine of we have done all
#
.all:
${RM} -f .all
${TOUCH} .all
##
#
# File list generation. You can ignore this section.
#
#
# We will form the names of source files as if they were in a
# sub-directory called calc/lib.
#
# NOTE: Due to bogus shells found on one common system we must have
# an non-emoty else clause for every if condition. *sigh*
#
##
distlist: ${DISTLIST}
${Q} for i in ${DISTLIST} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
echo sample/$$i; \
fi; \
done
distdir:
${Q} echo sample
calcliblist:
${Q} for i in ${CALCLIBLIST} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
echo sample/$$i; \
fi; \
done
##
#
# Home grown make dependency rules. Your system make not support
# or have the needed tools. You can ignore this section.
#
# We will form a skelaton tree of *.c files containing only #include "foo.h"
# lines and .h files containing the same lines surrounded by multiple include
# prevention lines. This allows us to build a static depend list that will
# satisfy all possible cpp symbol definition combinations.
#
##
depend:
${Q} if [ -f Makefile.bak ]; then \
echo "Makefile.bak exists, remove or move it out of the way"; \
exit 1; \
else \
${TRUE}; \
fi
${Q} echo forming sample/skel
-${Q} ${RM} -rf skel
${Q} ${MKDIR} skel
${Q} ${MKDIR} skel/sample
-${Q} for i in ${C_SRC} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
${SED} -n '/^#[ ]*include[ ]*"/p' \
"$$i" > "skel/sample/$$i"; \
fi; \
done
-${Q} for i in ${H_SRC} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
if [ X"$$i" != X"/dev/null" ]; then \
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
echo "#if !defined($$tag)" > "skel/sample/$$i"; \
echo "#define $$tag" >> "skel/sample/$$i"; \
${SED} -n '/^#[ ]*include[ ]*"/p' "$$i" \
>> "skel/sample/$$i"; \
echo '#endif /* '"$$tag"' */' >> "skel/sample/$$i"; \
fi; \
fi; \
done
${Q} (cd ..; $(MAKE) hsrc)
${Q} for i in `cd ..; $(MAKE) h_list 2>&1 | \
${SED} -e '/Entering directory/d' \
-e '/Nothing to be done/d' \
-e '/Leaving directory/d'` /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
echo "#if !defined($$tag)" > "skel/$$i"; \
echo "#define $$tag" >> "skel/$$i"; \
${SED} -n '/^#[ ]*include[ ]*"/p' "../$$i" \
>> "skel/$$i"; \
echo '#endif /* '"$$tag"' */' >> "skel/$$i"; \
fi; \
done
-${Q} ${RM} -f skel/sample/makedep.out
${Q} echo sample/skel formed
${Q} echo forming sample dependency list
${Q} echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > \
skel/sample/makedep.out
${Q} cd skel/sample; ${MAKEDEPEND} -w 1 -f makedep.out -I.. ${C_SRC}
-${Q} for i in ${C_SRC} /dev/null; do \
if [ X"$$i" != X"/dev/null" ]; then \
echo "$$i" | ${SED} 's/^\(.*\)\.c/\1.o: \1.c/'; \
fi; \
done >> skel/sample/makedep.out
${Q} echo sample dependency list formed
${Q} echo forming new sample/Makefile
-${Q} ${RM} -f Makefile.bak
${Q} ${MV} Makefile Makefile.bak
${Q} ${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak > Makefile
${Q} echo "" >> Makefile
${Q} ${SED} -n '3,$$p' skel/sample/makedep.out | \
LANG=C ${SORT} -u >> Makefile
-${Q} ${RM} -rf skel
-${Q} if ${CMP} -s Makefile.bak Makefile; then \
echo 'sample Makefile was already up to date'; \
${MV} -f Makefile.bak Makefile; \
else \
${RM} -f Makefile.tmp; \
${MV} Makefile Makefile.tmp; \
if [ -d RCS ]; then \
${CO} -l Makefile; \
fi; \
${MV} Makefile.tmp Makefile; \
if [ -d RCS ]; then \
echo new sample Makefile formed, you need to check it in; \
fi; \
fi
##
#
# rpm rules
#
##
echo_inst_files: Makefile
##
#
# Utility rules
#
##
clean:
-${RM} -f ${SAMPLE_OBJ} core
clobber:
-${RM} -f ${SAMPLE_OBJ}
-${RM} -f ${TARGETS}
${RM} -f .all Makefile.tmp sample
# install everything
#
# NOTE: Keep the uninstall rule in reverse order to the install rule
#
# NOTE: for right now we will not install anything
#
install: all
@${TRUE}
# Try to remove everything that was installed
#
# NOTE: Keep the uninstall rule in reverse order to the install rule
#
# NOTE: nothing installed, nothing to uninstall
#
uninstall:
@${TRUE}
##
#
# make depend stuff
#
##
# DO NOT DELETE THIS LINE
many_random.o: ../alloc.h
many_random.o: ../block.h
many_random.o: ../byteswap.h
many_random.o: ../calc.h
many_random.o: ../calcerr.h
many_random.o: ../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_memmv.h
many_random.o: ../have_newstr.h
many_random.o: ../have_stdlib.h
many_random.o: ../have_string.h
many_random.o: ../lib_util.h
many_random.o: ../longbits.h
many_random.o: ../md5.h
many_random.o: ../nametype.h
many_random.o: ../qmath.h
many_random.o: ../shs.h
many_random.o: ../shs1.h
many_random.o: ../string.h
many_random.o: ../value.h
many_random.o: ../zmath.h
many_random.o: ../zrandom.h
many_random.o: many_random.c
test_random.o: ../alloc.h
test_random.o: ../block.h
test_random.o: ../byteswap.h
test_random.o: ../calc.h
test_random.o: ../calcerr.h
test_random.o: ../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_memmv.h
test_random.o: ../have_newstr.h
test_random.o: ../have_stdlib.h
test_random.o: ../have_string.h
test_random.o: ../lib_util.h
test_random.o: ../longbits.h
test_random.o: ../md5.h
test_random.o: ../nametype.h
test_random.o: ../qmath.h
test_random.o: ../shs.h
test_random.o: ../shs1.h
test_random.o: ../string.h
test_random.o: ../value.h
test_random.o: ../zmath.h
test_random.o: ../zrandom.h
test_random.o: test_random.c

View File

@@ -1,7 +1,7 @@
/*
* many_random - generate many random values via random number generator
* sample_many - generate many random values via random number generator
*
* 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,9 +17,9 @@
* received 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: many_random.c,v 29.2 2000/06/07 14:02:54 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/sample/RCS/many_random.c,v $
* @(#) $Revision: 29.4 $
* @(#) $Id: sample_many.c,v 29.4 2007/02/15 09:49:57 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/sample_many.c,v $
*
* Under source code control: 1997/04/19 22:46:49
* File existed as early as: 1997
@@ -39,10 +39,10 @@
#include <sys/types.h>
#include <stdio.h>
#include "../calc.h"
#include "../zrandom.h"
#include "../have_const.h"
#include "../lib_util.h"
#include "calc.h"
#include "zrandom.h"
#include "have_const.h"
#include "lib_util.h"
#define DEF_CNT 128 /* default number of bits to generate */
#define RESEED 1000 /* number of random numbers to generate */

View File

@@ -1,7 +1,7 @@
/*
* test_random - test the libcalc random number generator
* sample_rand - test the libcalc random number generator
*
* 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,9 +17,9 @@
* received 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: test_random.c,v 29.2 2000/06/07 14:02:54 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/sample/RCS/test_random.c,v $
* @(#) $Revision: 29.4 $
* @(#) $Id: sample_rand.c,v 29.4 2007/02/15 09:49:32 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/sample_rand.c,v $
*
* Under source code control: 1997/04/19 22:46:49
* File existed as early as: 1997
@@ -39,10 +39,10 @@
#include <sys/types.h>
#include <stdio.h>
#include "../calc.h"
#include "../zrandom.h"
#include "../have_const.h"
#include "../lib_util.h"
#include "calc.h"
#include "zrandom.h"
#include "have_const.h"
#include "lib_util.h"
#define DEF_CNT 128 /* default number of bits to generate */

View File

@@ -1,5 +1,5 @@
/*
* string - string list routines
* str - string list routines
*
* Copyright (C) 1999-2007 David I. Bell and Ernest Bowen
*
@@ -19,9 +19,9 @@
* received 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: string.c,v 29.11 2007/02/11 10:19:14 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/string.c,v $
* @(#) $Revision: 29.12 $
* @(#) $Id: str.c,v 29.12 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/str.c,v $
*
* Under source code control: 1990/02/15 01:48:10
* File existed as early as: before 1990
@@ -32,7 +32,7 @@
#include <stdio.h>
#include "calc.h"
#include "string.h"
#include "str.h"
#define STR_TABLECHUNK 100 /* how often to reallocate string table */
#define STR_CHUNK 2000 /* size of string storage allocation */

View File

@@ -1,5 +1,5 @@
/*
* string - string list routines
* str - string list routines
*
* Copyright (C) 1999-2007 David I. Bell
*
@@ -17,9 +17,9 @@
* received 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: string.h,v 29.8 2007/02/11 10:19:14 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/string.h,v $
* @(#) $Revision: 29.9 $
* @(#) $Id: str.h,v 29.9 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/str.h,v $
*
* Under source code control: 1990/02/15 01:48:36
* File existed as early as: before 1990

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.7 $
* @(#) $Id: symbol.c,v 29.7 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.8 $
* @(#) $Id: symbol.c,v 29.8 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/symbol.c,v $
*
* Under source code control: 1990/02/15 01:48:23
@@ -34,7 +34,7 @@
#include "calc.h"
#include "token.h"
#include "symbol.h"
#include "string.h"
#include "str.h"
#include "opcodes.h"
#include "func.h"

97
token.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.11 $
* @(#) $Id: token.c,v 29.11 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.12 $
* @(#) $Id: token.c,v 29.12 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/token.c,v $
*
* Under source code control: 1990/02/15 01:48:25
@@ -35,9 +35,9 @@
#include "calc.h"
#include "token.h"
#include "string.h"
#include "str.h"
#include "args.h"
#include "math_error.h"
#include "lib_calc.h"
#define isletter(ch) ((((ch) >= 'a') && ((ch) <= 'z')) || \
@@ -710,30 +710,58 @@ scanerror(int skip, char *fmt, ...)
{
va_list ap;
char *name; /* name of file with error */
char buf[MAXERROR+1];
int len; /* length of error msg bufer */
/* count the error */
errorcount++;
/* print the error message */
/* form the error message */
name = inputname();
if (name)
fprintf(stderr, "\"%s\", line %ld: ", name, linenumber());
va_start(ap, fmt);
vsnprintf(buf, MAXERROR, fmt, ap);
if (name) {
snprintf(calc_err_msg, MAXERROR, "\"%s\", line %ld: ",
name, linenumber());
calc_err_msg[MAXERROR] = '\0'; /* firewall */
len = strlen(calc_err_msg);
if (len < MAXERROR) {
vsnprintf(calc_err_msg+len, MAXERROR-len, fmt, ap);
}
} else {
vsnprintf(calc_err_msg, MAXERROR, fmt, ap);
}
va_end(ap);
buf[MAXERROR] = '\0';
fprintf(stderr, "%s\n", buf);
calc_err_msg[MAXERROR] = '\0';
/* print error message if allowed */
if (calc_print_scanerr_msg != 0) {
fprintf(stderr, "%s\n\n", calc_err_msg);
}
/* bail out if continuation not permitted */
if ((!c_flag && !stoponerror) || stoponerror > 0)
longjmp(jmpbuf, 1);
if ((!c_flag && !stoponerror) || stoponerror > 0) {
if (calc_use_scanerr_jmpbuf != 0) {
longjmp(calc_scanerr_jmpbuf, 60);
/*NOTREACHED*/
} else {
fprintf(stderr,
"calc_scanerr_jmpbuf not setup, exiting code 60\n");
libcalc_call_me_last();
exit(60);
}
}
/* bail out if too many errors */
if (conf->maxscancount > 0 && errorcount > conf->maxscancount) {
fputs("Too many scan errors, compilation aborted.\n", stderr);
longjmp(jmpbuf, 1);
/*NOTREACHED*/
fprintf(stderr, "Too many scan errors, compilation aborted.\n");
if (calc_use_scanerr_jmpbuf != 0) {
longjmp(calc_scanerr_jmpbuf, 61);
/*NOTREACHED*/
} else {
fprintf(stderr,
"calc_scanerr_jmpbuf not ready: exit 61\n");
libcalc_call_me_last();
exit(61);
}
}
/* post-error report processing */
@@ -755,7 +783,12 @@ scanerror(int skip, char *fmt, ...)
}
}
default:
fprintf(stderr, "Unknown skip token for scanerror\n");
snprintf(calc_err_msg, MAXERROR,
"Unknown skip token for scanerror\n");
calc_err_msg[MAXERROR] = '\0';
if (calc_print_scanerr_msg != 0) {
fprintf(stderr, "%s\n\n", calc_err_msg);
}
/* fall into semicolon case */
/*FALLTHRU*/
case T_SEMICOLON:
@@ -782,14 +815,32 @@ warning(char *fmt, ...)
{
va_list ap;
char *name; /* name of file with error */
char buf[MAXERROR+1];
int len; /* length of error msg bufer */
/* count this warning */
++calc_warn_cnt;
/* form the error message */
name = inputname();
if (name)
fprintf(stderr, "\"%s\", line %ld: ", name, linenumber());
va_start(ap, fmt);
vsnprintf(buf, MAXERROR, fmt, ap);
vsnprintf(calc_warn_msg, MAXERROR, fmt, ap);
if (name) {
snprintf(calc_warn_msg, MAXERROR, "\"%s\", line %ld: ",
name, linenumber());
calc_warn_msg[MAXERROR] = '\0'; /* firewall */
len = strlen(calc_warn_msg);
if (len < MAXERROR) {
vsnprintf(calc_warn_msg+len, MAXERROR-len, fmt, ap);
}
} else {
vsnprintf(calc_warn_msg, MAXERROR, fmt, ap);
}
va_end(ap);
buf[MAXERROR] = '\0';
fprintf(stderr, "Warning: %s\n", buf);
calc_warn_msg[MAXERROR] = '\0';
/* print the warning if allowed */
if (calc_print_scanwarn_msg != 0) {
fprintf(stderr, "Warning: %s\n", calc_warn_msg);
}
return;
}

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.11 $
* @(#) $Id: value.c,v 29.11 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.12 $
* @(#) $Id: value.c,v 29.12 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/value.c,v $
*
* Under source code control: 1990/02/15 01:48:25
@@ -34,7 +34,7 @@
#include "opcodes.h"
#include "func.h"
#include "symbol.h"
#include "string.h"
#include "str.h"
#include "zrand.h"
#include "zrandom.h"
#include "cmath.h"

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.12 $
* @(#) $Id: value.h,v 29.12 2007/02/11 10:19:14 chongo Exp $
* @(#) $Revision: 29.13 $
* @(#) $Id: value.h,v 29.13 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/value.h,v $
*
* Under source code control: 1993/07/30 19:42:47
@@ -41,7 +41,7 @@
# include "hash.h"
# include "block.h"
# include "nametype.h"
# include "string.h"
# include "str.h"
#else
# include <calc/decl.h>
# include <calc/cmath.h>
@@ -51,7 +51,7 @@
# include <calc/hash.h>
# include <calc/block.h>
# include <calc/nametype.h>
# include <calc/string.h>
# include <calc/str.h>
#endif

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.81 $
* @(#) $Id: version.c,v 29.81 2007/02/12 03:40:35 chongo Exp $
* @(#) $Revision: 29.82 $
* @(#) $Id: version.c,v 29.82 2007/02/18 14:24:56 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
*
* Under source code control: 1990/05/22 11:00:58
@@ -46,10 +46,10 @@ static char *program;
#include "have_unused.h"
#define MAJOR_VER 2 /* major version */
#define MINOR_VER 12 /* minor version */
#define MAJOR_PATCH 1 /* patch level or 0 if no patch */
#define MINOR_PATCH 12 /* test number or 0 if no minor patch */
#define MAJOR_VER 2 /* major library version */
#define MINOR_VER 12 /* minor library version */
#define MAJOR_PATCH 1 /* major software level under library version */
#define MINOR_PATCH 13 /* minor software level or 0 if none */
/*
@@ -136,8 +136,8 @@ version(void)
*/
stored_version = (char *)malloc(strlen(verbuf)+1);
if (stored_version == NULL) {
fprintf(stderr, "%s: version formation value\n", program);
exit(1);
fprintf(stderr, "%s: cannot malloc version string\n", program);
exit(70);
}
strcpy(stored_version, verbuf);
@@ -175,13 +175,13 @@ print_rpm_version(char *release)
if (file == NULL) {
fprintf(stderr, "%s: cannot open %s: %s\n",
program, release, strerror(errno));
exit(2);
exit(71);
}
buf[BUFSIZ] = '\0';
if (fgets(buf, BUFSIZ, file) == NULL) {
fprintf(stderr, "%s: cannot read %s: %s\n",
program, release, strerror(errno));
exit(3);
exit(72);
}
p = strchr(buf, '\n');
if (p != NULL) {
@@ -244,13 +244,13 @@ print_rpm_release(char *release)
if (file == NULL) {
fprintf(stderr, "%s: cannot open %s: %s\n",
program, release, strerror(errno));
exit(2);
exit(73);
}
buf[BUFSIZ] = '\0';
if (fgets(buf, BUFSIZ, file) == NULL) {
fprintf(stderr, "%s: cannot read %s: %s\n",
program, release, strerror(errno));
exit(3);
exit(74);
}
p = strchr(buf, '\n');
if (p != NULL) {
@@ -289,7 +289,7 @@ main(int argc, char *argv[])
fprintf(stderr,
"usage: %s [-V] [-R release_file] [-r release_file]\n",
program);
exit(4);
exit(75);
}
return 0;
}