From f62d9fa1e62ef0609369fed3a8711ba6ccf63327 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Sun, 18 Feb 2007 07:31:59 -0800 Subject: [PATCH] Release calc version 2.12.1.13 --- CHANGES | 79 ++- LIBRARY | 249 ++++++++-- Makefile | 543 ++++++++++++--------- addop.c | 6 +- blkcpy.c | 6 +- block.c | 6 +- calc.c | 65 ++- calc.h | 7 +- codegen.c | 16 +- config.c | 6 +- custom/Makefile | 375 ++++++++++++--- custom/c_argv.c | 16 +- custom/c_devnull.c | 16 +- custom/c_help.c | 16 +- custom/c_pmodm127.c | 14 +- custom/c_pzasusb8.c | 14 +- custom/c_sysinfo.c | 42 +- custom/custtbl.c | 11 +- decl.h | 12 +- func.c | 6 +- label.c | 6 +- lib_calc.c | 42 +- math_error.h => lib_calc.h | 42 +- math_error.c | 45 +- obj.c | 6 +- opcodes.c | 17 +- sample/README_SAMPLE => sample.README | 12 +- sample/Makefile | 667 -------------------------- sample/many_random.c => sample_many.c | 18 +- sample/test_random.c => sample_rand.c | 18 +- string.c => str.c | 10 +- string.h => str.h | 8 +- symbol.c | 6 +- token.c | 97 +++- value.c | 6 +- value.h | 8 +- version.c | 26 +- 37 files changed, 1263 insertions(+), 1276 deletions(-) rename math_error.h => lib_calc.h (52%) rename sample/README_SAMPLE => sample.README (88%) delete mode 100644 sample/Makefile rename sample/many_random.c => sample_many.c (90%) rename sample/test_random.c => sample_rand.c (87%) rename string.c => str.c (99%) rename string.h => str.h (92%) diff --git a/CHANGES b/CHANGES index 114f1b7..4702133 100644 --- a/CHANGES +++ b/CHANGES @@ -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 . @@ -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 diff --git a/LIBRARY b/LIBRARY index a521299..c7ce7f6 100644 --- a/LIBRARY +++ b/LIBRARY @@ -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 + For example: - extern jmp_buf calc_jmp_buf; - extern int calc_jmp; - extern char *calc_error; - int error; + #include + #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 + #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 diff --git a/Makefile b/Makefile index 2925096..0a7cfb9 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,8 @@ # received a copy with calc; if not, write to Free Software Foundation, Inc. # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # -MAKEFILE_REV= $$Revision: 29.89 $$ -# @(#) $Id: Makefile.ship,v 29.89 2007/02/12 04:19:38 chongo Exp $ +MAKEFILE_REV= $$Revision: 29.94 $$ +# @(#) $Id: Makefile.ship,v 29.94 2007/02/18 15:29:23 chongo Exp $ # @(#) $Source: /usr/local/src/cmd/calc/RCS/Makefile.ship,v $ # # Under source code control: 1990/02/15 01:48:41 @@ -599,6 +599,10 @@ LIBDIR= /usr/lib #CALC_SHAREDIR= /dev/env/DJDIR/share/calc CALC_SHAREDIR= /usr/share/calc +# NOTE: Do not set CALC_INCDIR to /usr/include or /usr/local/include!!! +# Always be sure that the CALC_INCDIR path ends in /calc to avoid +# conflicts with system or other application include files!!! +# #CALC_INCDIR= /usr/local/include/calc #CALC_INCDIR= /dev/env/DJDIR/include/calc CALC_INCDIR= ${INCDIR}/calc @@ -838,35 +842,70 @@ DEBUG= -O3 -g3 # #DEBUG= -O2 -gstabs+ -DWINDOZ -# On systems that have dynamic shared link libs, you may want want to disable -# them for faster calc startup. +# How to compile .c files so that we can form a shared library. # -# System type NO_SHARED recommendation +# CC_SHARE= -fPIC +# Building for shared library using the gcc position independent code +# (PIC) model. +# CC_SHARE= +# Do not build for shared libraries. # -# BSD NO_SHARED= -# SYSV NO_SHARED= -dn -# IRIX NO_SHARED= -non_shared -# disable 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 NO_SHARED= +# If in doubt, try: +# CC_SHARE= -fPIC +# If that fails try: +# CC_SHARE= # -NO_SHARED= -#NO_SHARED= -dn -#NO_SHARED= -non_shared +# NOTE: Shared libraries are not yet supported. For now, use CC_SHARE= +# +#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= + +# 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 @@ -994,13 +1033,13 @@ EXT= # CCWARN= -Wall -W -Wno-comment CCWERR= -CCOPT= ${DEBUG} ${NO_SHARED} +CCOPT= ${DEBUG} ${CC_SHARE} CCMISC= # CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} # -LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED} +LDFLAGS= ${LD_SHARE} ILDFLAGS= # LCC= gcc @@ -1012,13 +1051,13 @@ CC= ${PURIFY} ${LCC} ${CCWERR} # #CCWARN= -Wall -W -Wno-comment #CCWERR= -#CCOPT= ${DEBUG} ${NO_SHARED} +#CCOPT= ${DEBUG} ${CC_SHARE} #CCMISC= -arch i386 -arch ppc # #CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} #ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} # -#LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED} -arch i386 -arch ppc +#LDFLAGS= ${LD_SHARE} -arch i386 -arch ppc #ILDFLAGS= # #LCC= gcc @@ -1030,13 +1069,13 @@ CC= ${PURIFY} ${LCC} ${CCWERR} # #CCWARN= -Wall -W -Wno-comment #CCWERR= -#CCOPT= ${DEBUG} ${NO_SHARED} +#CCOPT= ${DEBUG} ${CC_SHARE} #CCMISC= # #CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} #ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} # -#LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED} +#LDFLAGS= ${LD_SHARE} #ILDFLAGS= # #LCC= gcc @@ -1051,13 +1090,13 @@ CC= ${PURIFY} ${LCC} ${CCWERR} # #CCWARN= #CCWERR= -#CCOPT= ${DEBUG} ${NO_SHARED} +#CCOPT= ${DEBUG} ${CC_SHARE} #CCMISC= # #CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} #ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} # -#LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED} +#LDFLAGS= ${LD_SHARE} #ILDFLAGS= # #LCC= cc @@ -1065,35 +1104,6 @@ CC= ${PURIFY} ${LCC} ${CCWERR} # ### # -# SGI IRIX6.2 (or later) -n32 (v7.1 or later) Compiler -# -# You must set above: RANLIB=: -# -# If -O3 -g3 is not supported try: DEBUG= -O2 -g -# If -O2 -g is not supported try: DEBUG= -O -g -# -# If you have the directory /usr/lib32/nonshared, then set the following above: -# NO_SHARED= -non_shared -# LD_NO_SHARED= -Wl,-rdata_shared -# -# woff 1209: cancel 'controlling expression is constant' warnings -# -#CCWARN= -fullwarn -woff 1209 -#CCWERR= -#CCOPT= ${DEBUG} ${NO_SHARED} -#CCMISC= -rdata_shared -# -#CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} -#ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} -# -#LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED} -#ILDFLAGS= -# -#LCC= cc -n32 -xansi -#CC= ${PURIFY} ${LCC} ${CCWERR} -# -### -# # HP-UX set # # If -O3 -g3 is not supported try: DEBUG= -O2 -g @@ -1104,13 +1114,13 @@ CC= ${PURIFY} ${LCC} ${CCWERR} # #CCWARN= #CCWERR= -#CCOPT= ${DEBUG} ${NO_SHARED} +#CCOPT= ${DEBUG} ${CC_SHARE} #CCMISC= +e # #CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} #ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} # -#LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED} +#LDFLAGS= ${LD_SHARE} #ILDFLAGS= # #LCC= cc @@ -1125,13 +1135,13 @@ CC= ${PURIFY} ${LCC} ${CCWERR} # #CCWARN= #CCWERR= -#CCOPT= ${DEBUG} ${NO_SHARED} +#CCOPT= ${DEBUG} ${CC_SHARE} #CCMISC= -qlanglvl=ansi # #CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} #ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} # -#LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED} +#LDFLAGS= ${LD_SHARE} #ILDFLAGS= # #LCC= cc @@ -1149,13 +1159,13 @@ CC= ${PURIFY} ${LCC} ${CCWERR} # #CCWARN= #CCWERR= -#CCOPT= ${DEBUG} ${NO_SHARED} +#CCOPT= ${DEBUG} ${CC_SHARE} #CCMISC= -DFORCE_STDC # #CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} #ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} # -#LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED} +#LDFLAGS= ${LD_SHARE} #ILDFLAGS= # #LCC= cc @@ -1169,13 +1179,13 @@ CC= ${PURIFY} ${LCC} ${CCWERR} # #CCWARN= #CCWERR= -#CCOPT= ${DEBUG} ${NO_SHARED} +#CCOPT= ${DEBUG} ${CC_SHARE} #CCMISC= # #CFLAGS= -DCALC_SRC ${CCWARN} ${CCOPT} ${CCMISC} #ICFLAGS= -DCALC_SRC ${CCWARN} ${CCMISC} -Wno-unused # -#LDFLAGS= ${NO_SHARED} ${LD_NO_SHARED} +#LDFLAGS= ${LD_SHARE} #ILDFLAGS= # #LCC= cc @@ -1240,7 +1250,7 @@ LIBSRC= addop.c assocfunc.c blkcpy.c block.c byteswap.c \ lib_calc.c lib_util.c listfunc.c matfunc.c math_error.c \ md5.c obj.c opcodes.c pix.c poly.c prime.c qfunc.c qio.c \ qmath.c qmod.c qtrans.c quickhash.c seed.c shs.c shs1.c size.c \ - string.c symbol.c token.c value.c version.c zfunc.c zio.c \ + str.c symbol.c token.c value.c version.c zfunc.c zio.c \ zmath.c zmod.c zmul.c zprime.c zrand.c zrandom.c # the object files which are built into a math link library @@ -1254,7 +1264,7 @@ LIBOBJS= addop.o assocfunc.o blkcpy.o block.o byteswap.o calcerr.o \ lib_calc.o lib_util.o listfunc.o matfunc.o math_error.o \ md5.o obj.o opcodes.o pix.o poly.o prime.o qfunc.o qio.o \ qmath.o qmod.o qtrans.o quickhash.o seed.o shs.o shs1.o size.o \ - string.o symbol.o token.o value.o version.o zfunc.o zio.o \ + str.o symbol.o token.o value.o version.o zfunc.o zio.o \ zmath.o zmod.o zmul.o zprime.o zrand.o zrandom.o # the calculator source files @@ -1273,8 +1283,8 @@ CALCOBJS= calc.o # LIB_H_SRC= alloc.h blkcpy.h block.h byteswap.h calc.h cmath.h \ config.h custom.h decl.h file.h func.h hash.h hist.h jump.h \ - label.h lib_util.h math_error.h md5.h nametype.h \ - opcodes.h prime.h qmath.h shs.h shs1.h string.h \ + label.h lib_util.h lib_calc.h md5.h nametype.h \ + opcodes.h prime.h qmath.h shs.h shs1.h str.h \ symbol.h token.h value.h zmath.h zrand.h zrandom.h # we build these .h files during the make @@ -1336,6 +1346,22 @@ UTIL_PROGS= align32${EXT} fposval${EXT} have_uid_t${EXT} have_const${EXT} \ have_unused${EXT} have_fpos${EXT} have_fpos_pos${EXT} \ have_offscl${EXT} have_rusage${EXT} have_args.sh +# Any .h files that are needed to compile sample code. +# +SAMPLE_H_SRC= + +# Any .c files that are needed to compile sample code. +# +# There MUST be a .c in SAMPLE_C_SRC for every .o in SAMPLE_OBJ. +# +SAMPLE_C_SRC= sample_many.c sample_rand.c + +# Any .o files that are needed to compile sample code. +# +# There MUST be a .c in SAMPLE_C_SRC for every .o in SAMPLE_OBJ. +# +SAMPLE_OBJ= sample_many.o sample_rand.o + # The complete list of Makefile vars passed down to custom/Makefile. # CUSTOM_PASSDOWN= Q="${Q}" \ @@ -1350,14 +1376,15 @@ CUSTOM_PASSDOWN= Q="${Q}" \ CUSTOMINCDIR="${CUSTOMINCDIR}" \ SCRIPTDIR="${SCRIPTDIR}" \ DEBUG="${DEBUG}" \ - NO_SHARED="${NO_SHARED}" \ + CC_SHARE="${CC_SHARE}" \ + LD_SHARE="${LD_SHARE}" \ RANLIB="${RANLIB}" \ PURIFY="${PURIFY}" \ ALLOW_CUSTOM="${ALLOW_CUSTOM}" \ CCWARN="${CCWARN}" \ CCOPT="${CCOPT}" \ CCMISC="${CCMISC}" \ - CFLAGS="${CFLAGS} ${ALLOW_CUSTOM}" \ + CFLAGS="${CFLAGS} ${ALLOW_CUSTOM} -I/usr/include -I.." \ ICFLAGS="${ICFLAGS}" \ LDFLAGS="${LDFLAGS}" \ ILDFLAGS="${ILDFLAGS}" \ @@ -1382,53 +1409,6 @@ CUSTOM_PASSDOWN= Q="${Q}" \ CAT=${CAT} \ T=${T} -# The complete list of Makefile vars passed down to sample/Makefile. -# -SAMPLE_PASSDOWN= Q="${Q}" \ - INCDIR="${INCDIR}" \ - BINDIR="${BINDIR}" \ - LIBDIR="${LIBDIR}" \ - CALC_SHAREDIR="${CALC_SHAREDIR}" \ - HELPDIR="${HELPDIR}" \ - CALC_INCDIR="${CALC_INCDIR}" \ - CUSTOMCALDIR="${CUSTOMCALDIR}" \ - CUSTOMHELPDIR="${CUSTOMHELPDIR}" \ - CUSTOMINCDIR="${CUSTOMINCDIR}" \ - SCRIPTDIR="${SCRIPTDIR}" \ - DEBUG="${DEBUG}" \ - NO_SHARED="${NO_SHARED}" \ - RANLIB="${RANLIB}" \ - PURIFY="${PURIFY}" \ - ALLOW_CUSTOM="${ALLOW_CUSTOM}" \ - CCWARN="${CCWARN}" \ - CCOPT="${CCOPT}" \ - CCMISC="${CCMISC}" \ - CFLAGS="${CFLAGS} ${ALLOW_CUSTOM}" \ - ICFLAGS="${ICFLAGS}" \ - LDFLAGS="${LDFLAGS}" \ - ILDFLAGS="${ILDFLAGS}" \ - CALC_LIBS="../libcalc.a ../custom/libcustcalc.a ${READLINE_LIB}" \ - LCC="${LCC}" \ - CC="${CC}" \ - MAKE_FILE=${MAKE_FILE} \ - SED=${SED} \ - CHMOD=${CHMOD} \ - CMP=${CMP} \ - MAKEDEPEND=${MAKEDEPEND} \ - SORT=${SORT} \ - LANG=${LANG} \ - RM=${RM} \ - TOUCH=${TOUCH} \ - MKDIR=${MKDIR} \ - RMDIR=${RMDIR} \ - CP=${CP} \ - MV=${MV} \ - CO=${CO} \ - AR=${AR} \ - TRUE=${TRUE} \ - CAT=${CAT} \ - T=${T} - # The compelte list of Makefile vars passed down to help/Makefile. # HELP_PASSDOWN= Q="${Q}" \ @@ -1527,11 +1507,11 @@ CSCRIPT_PASSDOWN= Q="${Q}" \ # complete list of .h files found (but not built) in the distribution # -H_SRC= ${LIB_H_SRC} +H_SRC= ${LIB_H_SRC} ${SAMPLE_H_SRC} # complete list of .c files found (but not built) in the distribution # -C_SRC= ${LIBSRC} ${CALCSRC} ${UTIL_C_SRC} +C_SRC= ${LIBSRC} ${CALCSRC} ${UTIL_C_SRC} ${SAMPLE_C_SRC} # The list of files that describe calc's GNU Lesser General Public License # @@ -1541,7 +1521,7 @@ LICENSE= COPYING COPYING-LGPL # DISTLIST= ${C_SRC} ${H_SRC} ${MAKE_FILE} BUGS CHANGES LIBRARY README \ README.WINDOWS calc.man HOWTO.INSTALL ${UTIL_MISC_SRC} ${LICENSE} \ - calc.spec.in rpm.mk + sample.README calc.spec.in rpm.mk # These files are used to make (but not built) a calc .a link library # @@ -1550,18 +1530,17 @@ CALCLIBLIST= ${LIBSRC} ${UTIL_C_SRC} ${LIB_H_SRC} ${MAKE_FILE} \ # complete list of .o files # -OBJS= ${LIBOBJS} ${CALCOBJS} ${UTIL_OBJS} +OBJS= ${LIBOBJS} ${CALCOBJS} ${UTIL_OBJS} ${SAMPLE_OBJS} # Libaraies created and used to build calc # -CALC_LIBS= libcalc.a custom/libcustcalc.a +CALC_STATIC_LIBS= libcalc.a custom/libcustcalc.a -# list of sample programs to that need to be built to satisfy sample/.all +# list of sample programs to that need to be built to satisfy sample rule # -# NOTE: This list MUST be coordinated with the ${SAMPLE_TARGETS} variable -# in the sample/Makefile +# NOTE: The ${SAMPLE_TARGETS} are built but not installed at this time. # -SAMPLE_TARGETS= sample/test_random sample/many_random +SAMPLE_TARGETS= sample_rand${EXE} sample_many${EXE} # list of cscript programs to that need to be built to satisfy cscript/.all # @@ -1577,8 +1556,9 @@ PROGS= calc${EXT} ${UTIL_PROGS} # complete list of targets # -TARGETS= ${LICENSE} ${CALC_LIBS} custom/.all calc${EXT} sample/.all \ - cal/.all help/.all help/builtin cscript/.all calc.1 calc.usage +TARGETS= ${LICENSE} ${CALC_STATIC_LIBS} custom/.all calc${EXT} \ + ${SAMPLE_TARGETS} calc.1 calc.usage \ + cal/.all help/.all help/builtin cscript/.all ### @@ -1587,12 +1567,12 @@ TARGETS= ${LICENSE} ${CALC_LIBS} custom/.all calc${EXT} sample/.all \ # ### -all: .hsrc ${TARGETS} CHANGES +all: .hsrc ver_calc${EXE} ${TARGETS} CHANGES -calc${EXT}: .hsrc ${CALC_LIBS} ${CALCOBJS} +calc${EXT}: .hsrc ${CALC_STATIC_LIBS} ${CALCOBJS} ${MAKE_FILE} ${RM} -f $@ - ${CC} ${LDFLAGS} ${CALCOBJS} ${CALC_LIBS} ${LD_DEBUG} \ - ${READLINE_LIB} -o $@ + ${CC} ${LDFLAGS} ${CALCOBJS} ${CALC_STATIC_LIBS} \ + ${LD_DEBUG} ${READLINE_LIB} -o $@; \ libcalc.a: ${LIBOBJS} ${MAKE_FILE} -${RM} -f libcalc.a @@ -1600,6 +1580,11 @@ libcalc.a: ${LIBOBJS} ${MAKE_FILE} ${RANLIB} libcalc.a ${CHMOD} 0644 libcalc.a +# NOTE: Shared libraries are not yet supported. +# +libcalc.so: ${LIBOBJS} ver_calc${EXE} ${MAKE_FILE} + ${CC} ${CC_SHLIB} ${LIBOBJS} -o libcalc.so.`./ver_calc${EXE}` + calc.1: calc.man ${MAKE_FILE} -${RM} -f $@ ${Q} echo forming calc.1 from calc.man @@ -1620,6 +1605,30 @@ calc.usage: calc.1 ${CALCPAGER} calc.1 | ${COL} -b > $@ ${Q} echo calc.usage formed + +## +# +# These rules compile the sample code against the calc library +# +## + +sample: ${SAMPLE_TARGETS} + +sample_rand.o: sample_rand.c + ${CC} ${CFLAGS} ${ALLOW_CUSTOM} sample_rand.c -c + +sample_rand${EXE}: sample_rand.o ${CALC_STATIC_LIBS} ${MAKE_FILE} + ${CC} ${LDFLAGS} sample_rand.o ${CALC_STATIC_LIBS} \ + ${LD_DEBUG} ${READLINE_LIB} -o $@ + +sample_many.o: sample_many.c + ${CC} ${CFLAGS} ${ALLOW_CUSTOM} sample_many.c -c + +sample_many${EXE}: sample_many.o ${CALC_STATIC_LIBS} ${MAKE_FILE} + ${CC} ${LDFLAGS} sample_many.o ${CALC_STATIC_LIBS} \ + ${LD_DEBUG} ${READLINE_LIB} -o $@ + + ## # # Special .o files @@ -1644,6 +1653,7 @@ func.o: func.c ${MAKE_FILE} seed.o: seed.c no_implicit.arg ${MAKE_FILE} ${CC} ${CFLAGS} `${CAT} no_implicit.arg` -c seed.c + ## # # The next set of rules cause the .h files BUILD_H_SRC files to be built @@ -2951,6 +2961,7 @@ have_unused.h: have_unused.c ${MAKE_FILE} ${TRUE}; \ fi + ## # # Build .h files for windoz based systems @@ -2998,6 +3009,7 @@ longbits${EXT}: longbits.o ${RM} -f $@ ${LCC} ${ICFLAGS} longbits.o -o $@ + ## # # These two .all rules are used to determine of the lower level @@ -3035,8 +3047,6 @@ ${CSCRIPT_TARGETS}: ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-=' -sample/.all: ${SAMPLE_TARGETS} - custom/.all: ${V} echo '=-=-=-=-= start of $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking all rule for custom =-=-=-=-=' @@ -3044,13 +3054,6 @@ custom/.all: ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-=' -${SAMPLE_TARGETS}: libcalc.a - ${V} echo '=-=-=-=-= start of $@ rule =-=-=-=-=' - ${V} echo '=-=-=-=-= Invoking all rule for cscript =-=-=-=-=' - cd sample; ${MAKE} -f Makefile ${SAMPLE_PASSDOWN} all - ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' - ${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-=' - # This is a special rule that first tries to determine of a lower level # make is needed, and it so a make will be performed. Because it is # triggered as the first dependent of the all rule, it will ensure @@ -3087,6 +3090,7 @@ custom/libcustcalc.a: ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-=' + ## # # Home grown make dependency rules. Your system make not support @@ -3109,9 +3113,6 @@ depend: hsrc ${V} echo '=-=-=-=-= Invoking depend rule for custom =-=-=-=-=' -${Q} (cd custom; ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} depend) ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' - ${V} echo '=-=-=-=-= Invoking depend rule for sample =-=-=-=-=' - -${Q} (cd sample; ${MAKE} -f Makefile ${SAMPLE_PASSDOWN} depend) - ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${Q} echo forming skel -${Q} ${RM} -rf skel ${Q} ${MKDIR} skel @@ -3172,6 +3173,7 @@ ver_calc${EXT}: version.c have_unused.h -${RM} -f $@ ${LCC} ${ICFLAGS} -DCALC_VER ${ILDFLAGS} version.c -o $@ + ## # # File distribution list generation. You can ignore this section. @@ -3195,8 +3197,7 @@ distlist: ${DISTLIST} (cd help; ${MAKE} ${HELP_PASSDOWN} $@); \ (cd cal; ${MAKE} ${CAL_PASSDOWN} $@); \ (cd custom; ${MAKE} ${CUSTOM_PASSDOWN} $@); \ - (cd cscript; ${MAKE} ${CSCRIPT_PASSDOWN} $@); \ - (cd sample; ${MAKE} ${SAMPLE_PASSDOWN} $@)) | LANG=C ${SORT} + (cd cscript; ${MAKE} ${CSCRIPT_PASSDOWN} $@)) | LANG=C ${SORT} distdir: ${Q} (echo .; \ @@ -3204,8 +3205,7 @@ distdir: (cd help; ${MAKE} ${HELP_PASSDOWN} $@); \ (cd cal; ${MAKE} ${CAL_PASSDOWN} $@); \ (cd custom; ${MAKE} ${CUSTOM_PASSDOWN} $@); \ - (cd cscript; ${MAKE} ${CSCRIPT_PASSDOWN} $@); \ - (cd sample; ${MAKE} ${SAMPLE_PASSDOWN} $@)) | LANG=C ${SORT} + (cd cscript; ${MAKE} ${CSCRIPT_PASSDOWN} $@)) | LANG=C ${SORT} calcliblist: ${Q} (for i in ${CALCLIBLIST} /dev/null; do \ @@ -3216,12 +3216,12 @@ calcliblist: (cd help; ${MAKE} ${HELP_PASSDOWN} $@); \ (cd cal; ${MAKE} ${CAL_PASSDOWN} $@); \ (cd custom; ${MAKE} ${CUSTOM_PASSDOWN} $@); \ - (cd cscript; ${MAKE} ${CSCRIPT_PASSDOWN} $@); \ - (cd sample; ${MAKE} ${SAMPLE_PASSDOWN} $@)) | LANG=C ${SORT} + (cd cscript; ${MAKE} ${CSCRIPT_PASSDOWN} $@)) | LANG=C ${SORT} calcliblistfmt: ${Q} ${MAKE} calcliblist | ${FMT} -64 | ${SED} -e 's/^/ /' + ## # # Doing a 'make check' will cause the regression test suite to be executed. @@ -3242,6 +3242,7 @@ chk: ./cal/regress.cal ${CALC_ENV} ./calc${EXT} -d -q read regress 2>&1 | ${AWK} -f check.awk ${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-=' + ## # # debug @@ -3300,8 +3301,8 @@ env: @echo 'CALCRC=${CALCRC}'; echo '' @echo 'CALCPAGER=${CALCPAGER}'; echo '' @echo 'DEBUG=${DEBUG}'; echo '' - @echo 'NO_SHARED=${NO_SHARED}'; echo '' - @echo 'LD_NO_SHARED=${LD_NO_SHARED}'; echo '' + @echo 'CC_SHARE=${CC_SHARE}'; echo '' + @echo 'LD_SHARE=${LD_SHARE}'; echo '' @echo 'RANLIB=${RANLIB}'; echo '' @echo 'MAKE_FILE=${MAKE_FILE}'; echo '' @echo 'PURIFY=${PURIFY}'; echo '' @@ -3364,7 +3365,7 @@ env: @echo 'C_SRC=${C_SRC}'; echo '' @echo 'DISTLIST=${DISTLIST}'; echo '' @echo 'OBJS=${OBJS}'; echo '' - @echo 'CALC_LIBS=${CALC_LIBS}'; echo '' + @echo 'CALC_STATIC_LIBS=${CALC_STATIC_LIBS}'; echo '' @echo 'PROGS=${PROGS}'; echo '' @echo 'TARGETS=${TARGETS}'; echo '' @echo '=-=-=-=-= end of major make variable dump =-=-=-=-=' @@ -3403,6 +3404,7 @@ debug: env rpm.release @echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' @echo '=-=-=-=-= end of $@ rule =-=-=-=-=' + ## # # make run @@ -3521,6 +3523,7 @@ clean: -${RM} -f ${UTIL_OBJS} -${RM} -f ${UTIL_TMP} -${RM} -f ${UTIL_PROGS} + -${RM} -f ${SAMPLE_OBJ} -${RM} -f .libcustcalc_error -${RM} -f calc.spec.sed ${Q} echo '=-=-=-=-= Invoking $@ rule for help =-=-=-=-=' @@ -3532,17 +3535,14 @@ clean: ${V} echo '=-=-=-=-= Invoking $@ rule for custom =-=-=-=-=' cd custom; ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} clean ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' - ${V} echo '=-=-=-=-= Invoking $@ rule for sample =-=-=-=-=' - cd sample; ${MAKE} -f Makefile ${SAMPLE_PASSDOWN} clean - ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking $@ rule for cscript =-=-=-=-=' cd cscript; ${MAKE} -f Makefile ${CSCRIPT_PASSDOWN} clean ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${Q} echo remove files that are obsolete -${RM} -rf lib - -${RM} -f endian.h stdarg.h libcalcerr.a cal/obj help/obj win32dll.h + -${RM} -f endian.h stdarg.h libcalcerr.a cal/obj help/obj -${RM} -f have_vs.c std_arg.h try_stdarg.c fnvhash.c - -${RM} -f have_malloc.h + -${RM} -f win32dll.h have_malloc.h math_error.h string.h string.c ${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-=' clobber: @@ -3552,6 +3552,7 @@ clobber: -${RM} -f ${UTIL_OBJS} -${RM} -f ${UTIL_TMP} -${RM} -f ${UTIL_PROGS} + -${RM} -f ${SAMPLE_TARGETS} -${RM} -f tags .hsrc hsrc -${RM} -f ${BUILD_H_SRC} -${RM} -f ${BUILD_C_SRC} @@ -3571,17 +3572,14 @@ clobber: ${V} echo '=-=-=-=-= Invoking $@ rule for custom =-=-=-=-=' cd custom; ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} clobber ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' - ${V} echo '=-=-=-=-= Invoking $@ rule for sample =-=-=-=-=' - cd sample; ${MAKE} -f Makefile ${SAMPLE_PASSDOWN} clobber - ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking $@ rule for cscript =-=-=-=-=' cd cscript; ${MAKE} -f Makefile ${CSCRIPT_PASSDOWN} clobber ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo remove files that are obsolete -${RM} -rf lib - -${RM} -f endian.h stdarg.h libcalcerr.a cal/obj help/obj win32dll.h - -${RM} -f have_vs.c std_arg.h try_stdarg.c fnvhash.c calc.spec - -${RM} -f have_malloc.h + -${RM} -f endian.h stdarg.h libcalcerr.a cal/obj help/obj + -${RM} -f have_vs.c std_arg.h try_stdarg.c fnvhash.c + -${RM} -f win32dll.h have_malloc.h math_error.h string.h string.c -${RM} -rf win32 ${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-=' @@ -3721,9 +3719,6 @@ install: calc libcalc.a ${LIB_H_SRC} ${BUILD_H_SRC} calc.1 ${V} echo '=-=-=-=-= Invoking $@ rule for custom =-=-=-=-=' ${Q} cd custom; ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} install ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' - ${V} echo '=-=-=-=-= Invoking $@ rule for sample =-=-=-=-=' - ${Q} cd sample; ${MAKE} -f Makefile ${SAMPLE_PASSDOWN} install - ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking $@ rule for cscript =-=-=-=-=' ${Q} cd cscript; ${MAKE} -f Makefile ${CSCRIPT_PASSDOWN} install ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' @@ -3752,6 +3747,26 @@ install: calc libcalc.a ${LIB_H_SRC} ${BUILD_H_SRC} calc.1 ${MV} -f ${T}${CALC_INCDIR}/$$i.new ${T}${CALC_INCDIR}/$$i; \ echo "installed ${T}${CALC_INCDIR}/$$i"; \ fi; \ + if [ -f "${T}${CALC_INCDIR}/std_arg.h" ]; then \ + ${RM} -f ${T}${CALC_INCDIR}/std_arg.h; \ + echo "removed old ${T}${CALC_INCDIR}/std_arg.h"; \ + fi; \ + if [ -f "${T}${CALC_INCDIR}/win32dll.h" ]; then \ + ${RM} -f ${T}${CALC_INCDIR}/win32dll.h; \ + echo "removed old ${T}${CALC_INCDIR}/win32dll.h"; \ + fi; \ + if [ -f "${T}${CALC_INCDIR}/have_malloc.h" ]; then \ + ${RM} -f ${T}${CALC_INCDIR}/have_malloc.h; \ + echo "removed old ${T}${CALC_INCDIR}/have_malloc.h"; \ + fi; \ + if [ -f "${T}${CALC_INCDIR}/math_error.h" ]; then \ + ${RM} -f ${T}${CALC_INCDIR}/math_error.h; \ + echo "removed old ${T}${CALC_INCDIR}/math_error.h"; \ + fi; \ + if [ -f "${T}${CALC_INCDIR}/string.h" ]; then \ + ${RM} -f ${T}${CALC_INCDIR}/string.h; \ + echo "removed old ${T}${CALC_INCDIR}/string.h"; \ + fi; \ done ${Q} ${RM} -f tmp -${Q} if [ -z "${MANDIR}" ]; then \ @@ -3844,9 +3859,6 @@ uninstall: ${V} echo '=-=-=-=-= Invoking $@ rule for cscript =-=-=-=-=' ${Q} cd cscript; ${MAKE} -f Makefile ${CSCRIPT_PASSDOWN} uninstall ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' - ${V} echo '=-=-=-=-= Invoking $@ rule for sample =-=-=-=-=' - ${Q} cd sample; ${MAKE} -f Makefile ${SAMPLE_PASSDOWN} uninstall - ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' ${V} echo '=-=-=-=-= Invoking $@ rule for custom =-=-=-=-=' ${Q} cd custom; ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} uninstall ${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-=' @@ -3886,6 +3898,7 @@ splint: #hsrc ${SPLINT} ${SPLINT_OPTS} -DCALC_SRC -I. \ ${CALCSRC} ${LIBSRC} ${BUILD_C_SRC} ${UTIL_C_SRC} + ## # # make depend stuff @@ -3919,7 +3932,7 @@ addop.o: opcodes.h addop.o: qmath.h addop.o: shs.h addop.o: shs1.h -addop.o: string.h +addop.o: str.h addop.o: symbol.h addop.o: token.h addop.o: value.h @@ -3948,7 +3961,7 @@ assocfunc.o: nametype.h assocfunc.o: qmath.h assocfunc.o: shs.h assocfunc.o: shs1.h -assocfunc.o: string.h +assocfunc.o: str.h assocfunc.o: value.h assocfunc.o: zmath.h blkcpy.o: alloc.h @@ -3976,7 +3989,7 @@ blkcpy.o: nametype.h blkcpy.o: qmath.h blkcpy.o: shs.h blkcpy.o: shs1.h -blkcpy.o: string.h +blkcpy.o: str.h blkcpy.o: value.h blkcpy.o: zmath.h block.o: alloc.h @@ -4000,7 +4013,7 @@ block.o: nametype.h block.o: qmath.h block.o: shs.h block.o: shs1.h -block.o: string.h +block.o: str.h block.o: value.h block.o: zmath.h byteswap.o: alloc.h @@ -4043,15 +4056,15 @@ calc.o: have_unistd.h calc.o: have_unused.h calc.o: hist.h calc.o: label.h +calc.o: lib_calc.h calc.o: longbits.h -calc.o: math_error.h calc.o: md5.h calc.o: nametype.h calc.o: opcodes.h calc.o: qmath.h calc.o: shs.h calc.o: shs1.h -calc.o: string.h +calc.o: str.h calc.o: symbol.h calc.o: token.h calc.o: value.h @@ -4079,6 +4092,7 @@ codegen.o: have_stdlib.h codegen.o: have_string.h codegen.o: have_unistd.h codegen.o: label.h +codegen.o: lib_calc.h codegen.o: longbits.h codegen.o: md5.h codegen.o: nametype.h @@ -4086,7 +4100,7 @@ codegen.o: opcodes.h codegen.o: qmath.h codegen.o: shs.h codegen.o: shs1.h -codegen.o: string.h +codegen.o: str.h codegen.o: symbol.h codegen.o: token.h codegen.o: value.h @@ -4146,7 +4160,7 @@ config.o: nametype.h config.o: qmath.h config.o: shs.h config.o: shs1.h -config.o: string.h +config.o: str.h config.o: token.h config.o: value.h config.o: zmath.h @@ -4173,7 +4187,7 @@ const.o: nametype.h const.o: qmath.h const.o: shs.h const.o: shs1.h -const.o: string.h +const.o: str.h const.o: value.h const.o: zmath.h custom.o: alloc.h @@ -4199,7 +4213,7 @@ custom.o: nametype.h custom.o: qmath.h custom.o: shs.h custom.o: shs1.h -custom.o: string.h +custom.o: str.h custom.o: value.h custom.o: zmath.h endian.o: endian.c @@ -4232,7 +4246,7 @@ file.o: nametype.h file.o: qmath.h file.o: shs.h file.o: shs1.h -file.o: string.h +file.o: str.h file.o: value.h file.o: zmath.h fposval.o: endian_calc.h @@ -4275,7 +4289,7 @@ func.o: prime.h func.o: qmath.h func.o: shs.h func.o: shs1.h -func.o: string.h +func.o: str.h func.o: symbol.h func.o: token.h func.o: value.h @@ -4304,7 +4318,7 @@ hash.o: nametype.h hash.o: qmath.h hash.o: shs.h hash.o: shs1.h -hash.o: string.h +hash.o: str.h hash.o: value.h hash.o: zmath.h hash.o: zrand.h @@ -4359,7 +4373,7 @@ help.o: nametype.h help.o: qmath.h help.o: shs.h help.o: shs1.h -help.o: string.h +help.o: str.h help.o: value.h help.o: zmath.h hist.o: alloc.h @@ -4388,7 +4402,7 @@ hist.o: nametype.h hist.o: qmath.h hist.o: shs.h hist.o: shs1.h -hist.o: string.h +hist.o: str.h hist.o: value.h hist.o: zmath.h input.o: alloc.h @@ -4416,7 +4430,7 @@ input.o: nametype.h input.o: qmath.h input.o: shs.h input.o: shs1.h -input.o: string.h +input.o: str.h input.o: value.h input.o: zmath.h jump.o: decl.h @@ -4448,7 +4462,7 @@ label.o: opcodes.h label.o: qmath.h label.o: shs.h label.o: shs1.h -label.o: string.h +label.o: str.h label.o: token.h label.o: value.h label.o: zmath.h @@ -4473,13 +4487,14 @@ lib_calc.o: have_string.h lib_calc.o: have_unistd.h lib_calc.o: label.h lib_calc.o: lib_calc.c +lib_calc.o: lib_calc.h lib_calc.o: longbits.h lib_calc.o: md5.h lib_calc.o: nametype.h lib_calc.o: qmath.h lib_calc.o: shs.h lib_calc.o: shs1.h -lib_calc.o: string.h +lib_calc.o: str.h lib_calc.o: symbol.h lib_calc.o: terminal.h lib_calc.o: token.h @@ -4520,7 +4535,7 @@ listfunc.o: nametype.h listfunc.o: qmath.h listfunc.o: shs.h listfunc.o: shs1.h -listfunc.o: string.h +listfunc.o: str.h listfunc.o: value.h listfunc.o: zmath.h listfunc.o: zrand.h @@ -4549,7 +4564,7 @@ matfunc.o: nametype.h matfunc.o: qmath.h matfunc.o: shs.h matfunc.o: shs1.h -matfunc.o: string.h +matfunc.o: str.h matfunc.o: value.h matfunc.o: zmath.h matfunc.o: zrand.h @@ -4569,15 +4584,15 @@ math_error.o: have_memmv.h math_error.o: have_newstr.h math_error.o: have_stdlib.h math_error.o: have_string.h +math_error.o: lib_calc.h math_error.o: longbits.h math_error.o: math_error.c -math_error.o: math_error.h math_error.o: md5.h math_error.o: nametype.h math_error.o: qmath.h math_error.o: shs.h math_error.o: shs1.h -math_error.o: string.h +math_error.o: str.h math_error.o: value.h math_error.o: zmath.h md5.o: align32.h @@ -4602,7 +4617,7 @@ md5.o: nametype.h md5.o: qmath.h md5.o: shs.h md5.o: shs1.h -md5.o: string.h +md5.o: str.h md5.o: value.h md5.o: zmath.h no_implicit.o: no_implicit.c @@ -4631,7 +4646,7 @@ obj.o: opcodes.h obj.o: qmath.h obj.o: shs.h obj.o: shs1.h -obj.o: string.h +obj.o: str.h obj.o: symbol.h obj.o: value.h obj.o: zmath.h @@ -4657,8 +4672,8 @@ opcodes.o: have_string.h opcodes.o: have_unused.h opcodes.o: hist.h opcodes.o: label.h +opcodes.o: lib_calc.h opcodes.o: longbits.h -opcodes.o: math_error.h opcodes.o: md5.h opcodes.o: nametype.h opcodes.o: opcodes.c @@ -4666,7 +4681,7 @@ opcodes.o: opcodes.h opcodes.o: qmath.h opcodes.o: shs.h opcodes.o: shs1.h -opcodes.o: string.h +opcodes.o: str.h opcodes.o: symbol.h opcodes.o: value.h opcodes.o: zmath.h @@ -4707,7 +4722,7 @@ poly.o: poly.c poly.o: qmath.h poly.o: shs.h poly.o: shs1.h -poly.o: string.h +poly.o: str.h poly.o: value.h poly.o: zmath.h prime.o: alloc.h @@ -4822,11 +4837,65 @@ quickhash.o: qmath.h quickhash.o: quickhash.c quickhash.o: shs.h quickhash.o: shs1.h -quickhash.o: string.h +quickhash.o: str.h quickhash.o: value.h quickhash.o: zmath.h quickhash.o: zrand.h quickhash.o: zrandom.h +sample_many.o: alloc.h +sample_many.o: block.h +sample_many.o: byteswap.h +sample_many.o: calc.h +sample_many.o: calcerr.h +sample_many.o: cmath.h +sample_many.o: config.h +sample_many.o: decl.h +sample_many.o: endian_calc.h +sample_many.o: hash.h +sample_many.o: have_const.h +sample_many.o: have_memmv.h +sample_many.o: have_newstr.h +sample_many.o: have_stdlib.h +sample_many.o: have_string.h +sample_many.o: lib_util.h +sample_many.o: longbits.h +sample_many.o: md5.h +sample_many.o: nametype.h +sample_many.o: qmath.h +sample_many.o: sample_many.c +sample_many.o: shs.h +sample_many.o: shs1.h +sample_many.o: str.h +sample_many.o: value.h +sample_many.o: zmath.h +sample_many.o: zrandom.h +sample_rand.o: alloc.h +sample_rand.o: block.h +sample_rand.o: byteswap.h +sample_rand.o: calc.h +sample_rand.o: calcerr.h +sample_rand.o: cmath.h +sample_rand.o: config.h +sample_rand.o: decl.h +sample_rand.o: endian_calc.h +sample_rand.o: hash.h +sample_rand.o: have_const.h +sample_rand.o: have_memmv.h +sample_rand.o: have_newstr.h +sample_rand.o: have_stdlib.h +sample_rand.o: have_string.h +sample_rand.o: lib_util.h +sample_rand.o: longbits.h +sample_rand.o: md5.h +sample_rand.o: nametype.h +sample_rand.o: qmath.h +sample_rand.o: sample_rand.c +sample_rand.o: shs.h +sample_rand.o: shs1.h +sample_rand.o: str.h +sample_rand.o: value.h +sample_rand.o: zmath.h +sample_rand.o: zrandom.h seed.o: alloc.h seed.o: byteswap.h seed.o: decl.h @@ -4872,7 +4941,7 @@ shs.o: qmath.h shs.o: shs.c shs.o: shs.h shs.o: shs1.h -shs.o: string.h +shs.o: str.h shs.o: value.h shs.o: zmath.h shs1.o: align32.h @@ -4897,7 +4966,7 @@ shs1.o: qmath.h shs1.o: shs.h shs1.o: shs1.c shs1.o: shs1.h -shs1.o: string.h +shs1.o: str.h shs1.o: value.h shs1.o: zmath.h size.o: alloc.h @@ -4921,36 +4990,36 @@ size.o: qmath.h size.o: shs.h size.o: shs1.h size.o: size.c -size.o: string.h +size.o: str.h size.o: value.h size.o: zmath.h size.o: zrand.h size.o: zrandom.h -string.o: alloc.h -string.o: block.h -string.o: byteswap.h -string.o: calc.h -string.o: calcerr.h -string.o: cmath.h -string.o: config.h -string.o: decl.h -string.o: endian_calc.h -string.o: hash.h -string.o: have_const.h -string.o: have_memmv.h -string.o: have_newstr.h -string.o: have_stdlib.h -string.o: have_string.h -string.o: longbits.h -string.o: md5.h -string.o: nametype.h -string.o: qmath.h -string.o: shs.h -string.o: shs1.h -string.o: string.c -string.o: string.h -string.o: value.h -string.o: zmath.h +str.o: alloc.h +str.o: block.h +str.o: byteswap.h +str.o: calc.h +str.o: calcerr.h +str.o: cmath.h +str.o: config.h +str.o: decl.h +str.o: endian_calc.h +str.o: hash.h +str.o: have_const.h +str.o: have_memmv.h +str.o: have_newstr.h +str.o: have_stdlib.h +str.o: have_string.h +str.o: longbits.h +str.o: md5.h +str.o: nametype.h +str.o: qmath.h +str.o: shs.h +str.o: shs1.h +str.o: str.c +str.o: str.h +str.o: value.h +str.o: zmath.h symbol.o: alloc.h symbol.o: block.h symbol.o: byteswap.h @@ -4975,7 +5044,7 @@ symbol.o: opcodes.h symbol.o: qmath.h symbol.o: shs.h symbol.o: shs1.h -symbol.o: string.h +symbol.o: str.h symbol.o: symbol.c symbol.o: symbol.h symbol.o: token.h @@ -4997,14 +5066,14 @@ token.o: have_memmv.h token.o: have_newstr.h token.o: have_stdlib.h token.o: have_string.h +token.o: lib_calc.h token.o: longbits.h -token.o: math_error.h token.o: md5.h token.o: nametype.h token.o: qmath.h token.o: shs.h token.o: shs1.h -token.o: string.h +token.o: str.h token.o: token.c token.o: token.h token.o: value.h @@ -5035,7 +5104,7 @@ value.o: opcodes.h value.o: qmath.h value.o: shs.h value.o: shs1.h -value.o: string.h +value.o: str.h value.o: symbol.h value.o: value.c value.o: value.h @@ -5064,7 +5133,7 @@ version.o: nametype.h version.o: qmath.h version.o: shs.h version.o: shs1.h -version.o: string.h +version.o: str.h version.o: value.h version.o: version.c version.o: zmath.h @@ -5160,7 +5229,7 @@ zprime.o: prime.h zprime.o: qmath.h zprime.o: shs.h zprime.o: shs1.h -zprime.o: string.h +zprime.o: str.h zprime.o: value.h zprime.o: zmath.h zprime.o: zprime.c @@ -5186,7 +5255,7 @@ zrand.o: nametype.h zrand.o: qmath.h zrand.o: shs.h zrand.o: shs1.h -zrand.o: string.h +zrand.o: str.h zrand.o: value.h zrand.o: zmath.h zrand.o: zrand.c @@ -5212,7 +5281,7 @@ zrandom.o: nametype.h zrandom.o: qmath.h zrandom.o: shs.h zrandom.o: shs1.h -zrandom.o: string.h +zrandom.o: str.h zrandom.o: value.h zrandom.o: zmath.h zrandom.o: zrandom.c diff --git a/addop.c b/addop.c index 8cb8a6e..4125b12 100644 --- a/addop.c +++ b/addop.c @@ -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 #include "calc.h" #include "opcodes.h" -#include "string.h" +#include "str.h" #include "func.h" #include "token.h" #include "label.h" diff --git a/blkcpy.c b/blkcpy.c index 66b5487..3a2112f 100644 --- a/blkcpy.c +++ b/blkcpy.c @@ -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" /* diff --git a/block.c b/block.c index d6ac8e7..56ceca7 100644 --- a/block.c +++ b/block.c @@ -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 diff --git a/calc.c b/calc.c index b1e1c6f..424869b 100644 --- a/calc.c +++ b/calc.c @@ -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); } } diff --git a/calc.h b/calc.h index 8fe38e2..0ac6339 100644 --- a/calc.h +++ b/calc.h @@ -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 */ diff --git a/codegen.c b/codegen.c index a4f6b10..e76e41b 100644 --- a/codegen.c +++ b/codegen.c @@ -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 #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); + } } } } diff --git a/config.c b/config.c index 322b9d5..b371f20 100644 --- a/config.c +++ b/config.c @@ -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" diff --git a/custom/Makefile b/custom/Makefile index af2e9e0..5d08aaa 100644 --- a/custom/Makefile +++ b/custom/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.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 diff --git a/custom/c_argv.c b/custom/c_argv.c index b59ec99..84a6b83 100644 --- a/custom/c_argv.c +++ b/custom/c_argv.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.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 -#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 diff --git a/custom/c_devnull.c b/custom/c_devnull.c index 34ce91c..8afae6e 100644 --- a/custom/c_devnull.c +++ b/custom/c_devnull.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.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 +#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" /* diff --git a/custom/c_help.c b/custom/c_help.c index 0f73dd0..c9e9f12 100644 --- a/custom/c_help.c +++ b/custom/c_help.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.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 +#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" /* diff --git a/custom/c_pmodm127.c b/custom/c_pmodm127.c index 661da95..82cd982 100644 --- a/custom/c_pmodm127.c +++ b/custom/c_pmodm127.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.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 -#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[] = { diff --git a/custom/c_pzasusb8.c b/custom/c_pzasusb8.c index 587ec6a..0e4195b 100644 --- a/custom/c_pzasusb8.c +++ b/custom/c_pzasusb8.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.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 -#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 diff --git a/custom/c_sysinfo.c b/custom/c_sysinfo.c index 10d0474..f5911a1 100644 --- a/custom/c_sysinfo.c +++ b/custom/c_sysinfo.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.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 #include -#include "../have_const.h" -#include "../value.h" -#include "../custom.h" +#include "have_string.h" +#if defined(HAVE_STRING_H) +#include +#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" /* diff --git a/custom/custtbl.c b/custom/custtbl.c index cef72b9..fa406fe 100644 --- a/custom/custtbl.c +++ b/custom/custtbl.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.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 -#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 diff --git a/decl.h b/decl.h index a94efdb..60619f6 100644 --- a/decl.h +++ b/decl.h @@ -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 */ diff --git a/func.c b/func.c index 7214427..31a59f7 100644 --- a/func.c +++ b/func.c @@ -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" diff --git a/label.c b/label.c index 275a965..7375252 100644 --- a/label.c +++ b/label.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.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" diff --git a/lib_calc.c b/lib_calc.c index d5c20de..b78c9f7 100644 --- a/lib_calc.c +++ b/lib_calc.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.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 #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; } diff --git a/math_error.h b/lib_calc.h similarity index 52% rename from math_error.h rename to lib_calc.h index a0bc2d6..52f6afc 100644 --- a/math_error.h +++ b/lib_calc.h @@ -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 #if defined(CALC_SRC) /* if we are building from the calc source tree */ # include "decl.h" @@ -39,11 +40,42 @@ # include #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__ */ diff --git a/math_error.c b/math_error.c index 653bdf8..d223baa 100644 --- a/math_error.c +++ b/math_error.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.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 + * #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 #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); } diff --git a/obj.c b/obj.c index 9fc88f7..f9cb432 100644 --- a/obj.c +++ b/obj.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.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" /* diff --git a/opcodes.c b/opcodes.c index 8d789b8..96ea9de 100644 --- a/opcodes.c +++ b/opcodes.c @@ -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); diff --git a/sample/README_SAMPLE b/sample.README similarity index 88% rename from sample/README_SAMPLE rename to sample.README index 93a0e56..9e05235 100644 --- a/sample/README_SAMPLE +++ b/sample.README @@ -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 /\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 diff --git a/sample/Makefile b/sample/Makefile deleted file mode 100644 index c0fb7ca..0000000 --- a/sample/Makefile +++ /dev/null @@ -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 /\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 diff --git a/sample/many_random.c b/sample_many.c similarity index 90% rename from sample/many_random.c rename to sample_many.c index 71aa613..9c35955 100644 --- a/sample/many_random.c +++ b/sample_many.c @@ -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 #include -#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 */ diff --git a/sample/test_random.c b/sample_rand.c similarity index 87% rename from sample/test_random.c rename to sample_rand.c index d63ead4..e05cf72 100644 --- a/sample/test_random.c +++ b/sample_rand.c @@ -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 #include -#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 */ diff --git a/string.c b/str.c similarity index 99% rename from string.c rename to str.c index 7332091..995872f 100644 --- a/string.c +++ b/str.c @@ -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 #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 */ diff --git a/string.h b/str.h similarity index 92% rename from string.h rename to str.h index 7b5669e..bc8e883 100644 --- a/string.h +++ b/str.h @@ -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 diff --git a/symbol.c b/symbol.c index ce157de..4936279 100644 --- a/symbol.c +++ b/symbol.c @@ -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" diff --git a/token.c b/token.c index fc119c4..dc88cb0 100644 --- a/token.c +++ b/token.c @@ -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; } diff --git a/value.c b/value.c index 9e999ec..3395bf1 100644 --- a/value.c +++ b/value.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.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" diff --git a/value.h b/value.h index 9c4ecee..686e2ee 100644 --- a/value.h +++ b/value.h @@ -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 # include @@ -51,7 +51,7 @@ # include # include # include -# include +# include #endif diff --git a/version.c b/version.c index 34f1486..022d235 100644 --- a/version.c +++ b/version.c @@ -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; }