From 2c72ea9339be3d9c232877e50bab4fa80336bdf1 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Wed, 20 Oct 1999 03:08:51 -0700 Subject: [PATCH] Release calc version 2.11.0t8 --- BUGS | 46 +++++++-- CHANGES | 79 +++++++++------ README | 4 +- align32.c | 5 +- blkcpy.c | 2 +- block.c | 8 +- block.h | 8 +- calc.c | 131 ++++++++++++++----------- calc.h | 19 ++-- calc.man | 2 +- codegen.c | 5 +- config.h | 8 +- custom.c | 8 +- custom.h | 9 +- custom/CUSTOM_CAL | 2 +- custom/Makefile | 8 +- custom/argv.cal | 2 +- custom/c_argv.c | 8 +- custom/c_devnull.c | 8 +- custom/c_help.c | 8 +- custom/c_sysinfo.c | 8 +- custom/custtbl.c | 8 +- custom/halflen.cal | 2 +- func.c | 23 ++++- help/Makefile | 2 +- help/archive | 5 +- help/contrib | 5 +- help/credit | 8 +- help/help | 3 +- help/todo | 236 +++++++++------------------------------------ help/wishlist | 215 +++++++++++++++++++++++++++++++++++++++++ input.c | 48 +++++---- lib/chrem.cal | 2 +- lib/lucas.cal | 5 +- lib/lucas_chk.cal | 5 +- lib/lucas_tbl.cal | 5 +- lib/mfactor.cal | 5 +- lib/qtime.cal | 2 +- lib/randmprime.cal | 5 +- lib/regress.cal | 17 ++++ lib/seedrandom.cal | 5 +- lib/test1700.cal | 6 +- lib/test2300.cal | 6 +- lib/test2600.cal | 2 +- lib/test2700.cal | 2 +- lib/test3100.cal | 2 +- lib/test3300.cal | 2 +- lib/test3400.cal | 2 +- lib/test3500.cal | 2 +- lib/test4000.cal | 2 +- lib/test4100.cal | 2 +- lib/test4600.cal | 2 +- lib/test5100.cal | 2 +- lib/test5200.cal | 2 +- lib_calc.c | 3 +- math_error.h | 8 +- nametype.h | 8 +- poly.c | 2 +- quickhash.c | 7 +- sample/Makefile | 8 +- seed.c | 9 +- shs.c | 7 +- shs.h | 5 +- shs1.c | 5 +- shs1.h | 5 +- version.c | 2 +- zrand.c | 8 +- zrand.h | 8 +- zrandom.c | 8 +- zrandom.h | 8 +- 70 files changed, 656 insertions(+), 463 deletions(-) create mode 100644 help/wishlist diff --git a/BUGS b/BUGS index 9ca27b5..0bef9ae 100644 --- a/BUGS +++ b/BUGS @@ -46,7 +46,7 @@ When you send your report, please include the following information: * the type of compiler you were using - * any compiler warnings or erros that you saw + * any compiler warnings or errors that you saw * cd to the calc source directory, and type: @@ -66,14 +66,42 @@ importantly, fixes (in the form of a context diff patch) to: =-= -Known problems or mis-features: +Known bugs: - * Many of and SEE ALSO sections of help files - for builtins are either inconsistent or missing information. + None reported. We are sure some bugs exist. When you find them, + please let us know! See the above for details on how to report and + were to EMail your bug reports and hopefully patches to fix them. - * Many of the LIBRARY sections are incorrect now that libcalc.a - contains most of the calc system. +=-= - * There is some places in the source with obscure variable names - and not much in the way of comments. We need some major cleanup - and documentation. +Calc Mis-features: + + * The following shell command (written in sh,ksh,bash-like form) works: + + calc '/* + * comment + */ + print 2+3;' + + However this (also written in sh,ksh,bash-like form) does not work: + + echo '/* + * comment + */ + print 2+3;' | calc + + The 2nd example will result in an 'Unterminated comment' error. + + * Calc does not support the #! exec method. For example of the + following is placed in an executable file (assume the path to + calc is correct) called /tmp/xyzzy: + + #!/usr/local/bin/calc + /* + * comment + */ + print 2+3; + + Will result in '"tmp" is undefined' and '"xyzzy" is undefined' + error messages because calc considers $0 as an expression to + evaluate. diff --git a/CHANGES b/CHANGES index 7bee872..a3e0549 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,33 @@ -Following is the change from calc version 2.11.0t7 to date: +Following is the change from calc version 2.11.0t8 to date: + + Moved 'wishlist' enhancements from the help/todo file to a new + help/wishlist file. Ordered, by priority, help/todo items into + Very High, High and Medium priority items. + + The BUGS file now has a 'bugs' section as well as a 'mis-features' + section. + + Improved how calc internally dealt with reading EOF or '\0' characters. + + Calc now allows multiple defines to occur on the same line: + (Thanks goes to Ernest Bowen ) + + define f8300(x) = x^2; define g8300(x) = 1 - x; + + Improved calc's ability to deal with and recover from errors. + + Added inputlevel() builtin to return the input processing level. + In an interact mode, inputlevel() returns 0. When directly reading + a calc script, inputlevel() returns 1. When reading a script which + in turn reads another script, inputlevel() returns 2. etc... + + If $CALCRC has more than one file as in file1:file2 and an error + occurs in file1, then calc -c will not read file2. + + Fixed some of the old EMail addresses found in calc documentation. + + +Following is the change from calc version 2.11.0t7 to 2.11.0t7.5: Calc has some new command line flags / command line meaning: (Thanks goes to Ernest Bowen ) @@ -110,40 +139,40 @@ Following is the change from calc version 2.11.0t7 to date: calc -p 2+17 | whey - will write '19' instead of '\t19' to the whey command. + will write '19' instead of '\t19' to the whey command. - Updated calc man page and help/usage file to reflect recent - command line changes. + Updated calc man page and help/usage file to reflect recent + command line changes. - Converted start_done into a general calc run state enum called - run_state within the calc source. + Converted start_done into a general calc run state enum called + run_state within the calc source. - Removed README.OLD. + Removed README.OLD. - Added the Makefile variable ${LCC} to invoke the local c compiler. - By default, ${CC} also run the ${LCC} compiler. The distinction is - useful when using something such as purify. In the case of ${LCC}, - only the local C compiler is invoked. In the case of ${CC} a purify - compile is invoked. Only the source that must be compiled and run - on the local machine use ${LCC}; everything else uses ${CC}. + Added the Makefile variable ${LCC} to invoke the local c compiler. + By default, ${CC} also run the ${LCC} compiler. The distinction is + useful when using something such as purify. In the case of ${LCC}, + only the local C compiler is invoked. In the case of ${CC} a purify + compile is invoked. Only the source that must be compiled and run + on the local machine use ${LCC}; everything else uses ${CC}. - Fixed memory buffer ovreread problem in eatstring() in token.c. + Fixed memory buffer ovreread problem in eatstring() in token.c. - Fixed memory leaks related to putenv(). + Fixed memory leaks related to putenv(). - Fixed memory leaks realted to srandom(). + Fixed memory leaks realted to srandom(). - Fixed compilation warnings and problems on BSDI. + Fixed compilation warnings and problems on BSDI. - Removed ${CCMAIN} as a variable from the Makefile. Now files - use either ${CFLAGS} for general C source and ${ICFLAGS} for - intermediate C source (e.g., special code for building hsrc files). + Removed ${CCMAIN} as a variable from the Makefile. Now files + use either ${CFLAGS} for general C source and ${ICFLAGS} for + intermediate C source (e.g., special code for building hsrc files). - The main calc URL is now: + The main calc URL is now: http://reality.sgi.com/chongo/tech/comp/calc - Misc calc man page fixes. + Misc calc man page fixes. Following is the change from calc version 2.11.0t1 to 2.11.0t6.3: @@ -3719,9 +3748,6 @@ Following is the change from calc version 2.9.3t8 to 2.9.3t9.2: Following is the change from calc version 2.9.3t7 to 2.9.3t7: - WARNING: This patch is an beta test patch by chongo@toad.com - (Landon Curt Noll). - The 'show' command by itself will issue an error message that will remind one of the possible show arguments. (thanks to Ha S. Lam ) @@ -3769,9 +3795,6 @@ Following is the change from calc version 2.9.3t7 to 2.9.3t7: Following is the change from calc version 2.9.2 to 2.9.3t7: - WARNING: This patch is an beta test patch by chongo@toad.com - (Landon Curt Noll). - Calc can now compile on OSF/1, SGI and IBM RS6000 systems. A number of systems that have both and do diff --git a/README b/README index 3928219..d1d8166 100644 --- a/README +++ b/README @@ -60,10 +60,12 @@ Calc is shipped with a library of calc scripts. For a list see: See the file: help/todo + help/wishlist or run: - calc 'help todo' + calc help todo + calc help wishlist for a wish/todo list. Code contributions are welcome. diff --git a/align32.c b/align32.c index 172cb71..61a67cd 100644 --- a/align32.c +++ b/align32.c @@ -3,7 +3,10 @@ * * This file was written by: * - * Landon Curt Noll (chongo@toad.com) chongo /\../\ + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ * * This code has been placed in the public domain. Please do not * copyright this code. diff --git a/blkcpy.c b/blkcpy.c index 0876447..ba8754f 100644 --- a/blkcpy.c +++ b/blkcpy.c @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo */ #include diff --git a/block.c b/block.c index 8dcc613..3d83550 100644 --- a/block.c +++ b/block.c @@ -27,12 +27,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ diff --git a/block.h b/block.h index 8eb34ec..a07857e 100644 --- a/block.h +++ b/block.h @@ -27,12 +27,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ diff --git a/calc.c b/calc.c index 47bd5a4..549c1b4 100644 --- a/calc.c +++ b/calc.c @@ -237,73 +237,92 @@ main(int argc, char **argv) /* * execute calc code based on the run state */ - if (run_state == RUN_PRE_BEGIN) { + if (run_state == RUN_BEGIN) { if (!q_flag && allow_read) { - run_state = RUN_PRE_RCFILES; + run_state = RUN_RCFILES; runrcfiles(); } - run_state = RUN_POST_RCFILES; - } - if (run_state == RUN_PRE_RCFILES) { - fprintf(stderr, "Execution error in rcfiles\n"); - if ((c_flag && !stoponerror) || stoponerror < 0) { - getcommands(FALSE); - run_state = RUN_POST_RCFILES; - } else { - if ((havecommands && !i_flag) || !stdin_tty) - run_state = RUN_STOP_ON_ERROR; - else if (havecommands) - run_state = RUN_POST_CMD_ARGS; - else - run_state = RUN_POST_RCFILES; - } - } - if (run_state == RUN_POST_RCFILES) { - if (havecommands) { - run_state = RUN_PRE_CMD_ARGS; - (void) openstring(cmdbuf); - getcommands(FALSE); - } - run_state = RUN_POST_CMD_ARGS; - } - if (run_state == RUN_PRE_CMD_ARGS) { - fprintf(stderr, "Execution error in commands\n"); - if ((c_flag && !stoponerror) || stoponerror < 0) { - getcommands(FALSE); - run_state = RUN_POST_CMD_ARGS; - } else { - closeinput(); - if (!stdin_tty || !i_flag) - run_state = RUN_STOP_ON_ERROR; - else - run_state = RUN_POST_CMD_ARGS; - } - } - if (run_state == RUN_POST_CMD_ARGS) { - if (stdin_tty && ((havecommands && !i_flag) || p_flag)) - run_state = RUN_NOT_TOP_LEVEL; - else - openterminal(); - } else if (run_state == RUN_TOP_LEVEL) { - if (!stdin_tty && (!c_flag || stoponerror) && - stoponerror >= 0) { - run_state = RUN_STOP_ON_ERROR; - } else if ((c_flag && !stoponerror) || stoponerror < 0) - getcommands(FALSE); - else - reinitialize(); + run_state = RUN_PRE_CMD_ARGS; } - if (run_state < RUN_NOT_TOP_LEVEL) { - run_state = RUN_TOP_LEVEL; - getcommands(TRUE); + while (run_state == RUN_RCFILES) { + fprintf(stderr, "Error in rcfiles\n"); + if ((c_flag && !stoponerror) || stoponerror < 0) { + getcommands(FALSE); + closeinput(); + if (inputisterminal()) + run_state = RUN_PRE_CMD_ARGS; + } else { + if ((havecommands && !i_flag) || !stdin_tty) + run_state = RUN_EXIT_WITH_ERROR; + else + run_state = RUN_PRE_CMD_ARGS; + } + } + + if (run_state == RUN_PRE_CMD_ARGS) { + if (havecommands) { + run_state = RUN_CMD_ARGS; + (void) openstring(cmdbuf, (long) strlen(cmdbuf)); + getcommands(FALSE); + closeinput(); + } + run_state = RUN_PRE_TOP_LEVEL; + } + + while (run_state == RUN_CMD_ARGS) { + fprintf(stderr, "Error in commands\n"); + if ((c_flag && !stoponerror) || stoponerror < 0) { + getcommands(FALSE); + closeinput(); + if (inputlevel() == 0) { + getcommands(FALSE); + run_state = RUN_PRE_TOP_LEVEL; + } + } else { + closeinput(); + if (!stdin_tty || !i_flag || p_flag) + run_state = RUN_EXIT_WITH_ERROR; + else + run_state = RUN_PRE_TOP_LEVEL; + } + } + + if (run_state == RUN_PRE_TOP_LEVEL) { + if (stdin_tty && ((havecommands && !i_flag) || p_flag)) { + run_state = RUN_EXIT; + } else { + if (stdin_tty) { + reinitialize(); + } else { + resetinput(); + openterminal(); + } + run_state = RUN_TOP_LEVEL; + getcommands(TRUE); + } + } + + while (run_state == RUN_TOP_LEVEL) { + if ((c_flag && !stoponerror) || stoponerror < 0) { + getcommands(TRUE); + if (!inputisterminal()) + closeinput(); + } else { + if (stdin_tty) { + reinitialize(); + getcommands(TRUE); + } else { + run_state = RUN_EXIT_WITH_ERROR; + } + } } /* * all done */ libcalc_call_me_last(); - return (run_state == RUN_STOP_ON_ERROR || + return (run_state == RUN_EXIT_WITH_ERROR || run_state == RUN_UNKNOWN) ? 1 : 0; } diff --git a/calc.h b/calc.h index 6dd8f62..cf3b6e1 100644 --- a/calc.h +++ b/calc.h @@ -113,7 +113,7 @@ extern void trimconstants(void); /* * Input routines. */ -extern int openstring(char *str); +extern int openstring(char *str, long num); extern int openterminal(void); extern int opensearchfile(char *name, char *pathlist, char *exten, int reopen_ok); extern char *nextline(void); @@ -122,6 +122,7 @@ extern void reread(void); extern void resetinput(void); extern void setprompt(char *); extern BOOL inputisterminal(void); +extern int inputlevel(void); extern char *inputname(void); extern long linenumber(void); extern void runrcfiles(void); @@ -195,14 +196,14 @@ extern int allow_exec; /* FALSE => may not execute any commands */ */ typedef enum { RUN_UNKNOWN = -1, /* unknown or unset start state */ - RUN_PRE_BEGIN = 0, /* pre-startup state, calc execution started */ - RUN_PRE_RCFILES = 1, /* rc files about to or are being evaluated */ - RUN_POST_RCFILES = 2, /* rc files have been evaluated */ - RUN_PRE_CMD_ARGS = 3, /* cmd_args about to or are being evaluated */ - RUN_POST_CMD_ARGS = 4, /* cmd_args have been evaluated */ - RUN_TOP_LEVEL = 5, /* running at the top interactive level */ - RUN_NOT_TOP_LEVEL = 6, /* running not at the top interactive level */ - RUN_STOP_ON_ERROR = 7 /* we need to stop due to errors */ + RUN_BEGIN = 0, /* calc execution starts */ + RUN_RCFILES = 1, /* rc files being evaluated */ + RUN_PRE_CMD_ARGS = 2, /* prepare to evaluate cmd args */ + RUN_CMD_ARGS = 3, /* cmd args being evaluated */ + RUN_PRE_TOP_LEVEL = 4, /* prepare to start top level activity */ + RUN_TOP_LEVEL = 5, /* running at top level */ + RUN_EXIT = 6, /* normal exit from calc */ + RUN_EXIT_WITH_ERROR = 7 /* exit with error */ } run; extern run run_state; diff --git a/calc.man b/calc.man index 74ff52c..a4a1b0e 100644 --- a/calc.man +++ b/calc.man @@ -567,7 +567,7 @@ scripts that you would like you see included in future distributions to: .sp .in +0.5i -calc-tester-request@postofc.corp.sgi.com +calc-tester@postofc.corp.sgi.com .in -0.5i .sp Landon Noll maintains the the diff --git a/codegen.c b/codegen.c index b20b390..273ef93 100644 --- a/codegen.c +++ b/codegen.c @@ -125,6 +125,7 @@ getcommands(BOOL toplevel) switch (opensearchfile(name,calcpath,CALCEXT,rdonce)) { case 0: getcommands(FALSE); + closeinput(); break; case 1: /* previously read and -once was given */ @@ -354,10 +355,6 @@ getsimplebody(void) (void) tokenmode(TM_NEWLINES); (void) getexprlist(); addop(OP_RETURN); - if (gettoken() != T_SEMICOLON) - rescantoken(); - if (gettoken() != T_NEWLINE) - scanerror(T_NULL, "Illegal function definition"); } diff --git a/config.h b/config.h index 09270df..aa1c220 100644 --- a/config.h +++ b/config.h @@ -28,12 +28,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ diff --git a/custom.c b/custom.c index d0e3ff8..9876007 100644 --- a/custom.c +++ b/custom.c @@ -24,12 +24,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ /* these include files are needed regardless of CUSTOM */ diff --git a/custom.h b/custom.h index a8384b6..898f0dd 100644 --- a/custom.h +++ b/custom.h @@ -28,15 +28,12 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ - /* * Be careful what you put in this file, upper .c files include * this file even when CUSTOM is not defined (ALLOW_CUSTOM is empty). diff --git a/custom/CUSTOM_CAL b/custom/CUSTOM_CAL index 2504d9c..34e64ac 100644 --- a/custom/CUSTOM_CAL +++ b/custom/CUSTOM_CAL @@ -19,7 +19,7 @@ # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. # -# chongo was here /\../\ chongo@toad.com +# chongo was here /\../\ http://reality.sgi.com/chongo The following custom calc library files are provided because they serve as examples of how use the custom interface. The custom interface diff --git a/custom/Makefile b/custom/Makefile index 780440c..4d0118e 100644 --- a/custom/Makefile +++ b/custom/Makefile @@ -26,12 +26,10 @@ # # Happy bit twiddling, # -# Landon Curt Noll +# Landon Curt Noll +# http://reality.sgi.com/chongo # -# chongo@toad.com -# ...!{pyramid,sun,uunet}!hoptoad!chongo -# -# chongo was here /\../\ +# chongo /\../\ ############################################################################## #-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-# diff --git a/custom/argv.cal b/custom/argv.cal index ab94ff7..7e561a1 100644 --- a/custom/argv.cal +++ b/custom/argv.cal @@ -10,7 +10,7 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * chongo was here /\../\ chongo@toad.com + * chongo was here /\../\ http://reality.sgi.com/chongo */ /* * argv - print information about various args diff --git a/custom/c_argv.c b/custom/c_argv.c index 9f16720..d045592 100644 --- a/custom/c_argv.c +++ b/custom/c_argv.c @@ -15,12 +15,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ #if defined(CUSTOM) diff --git a/custom/c_devnull.c b/custom/c_devnull.c index af64d33..acc17b4 100644 --- a/custom/c_devnull.c +++ b/custom/c_devnull.c @@ -15,12 +15,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ #if defined(CUSTOM) diff --git a/custom/c_help.c b/custom/c_help.c index e11a653..da3fe84 100644 --- a/custom/c_help.c +++ b/custom/c_help.c @@ -15,12 +15,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ #if defined(CUSTOM) diff --git a/custom/c_sysinfo.c b/custom/c_sysinfo.c index 2f1d5a8..6023baa 100644 --- a/custom/c_sysinfo.c +++ b/custom/c_sysinfo.c @@ -15,12 +15,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ #if defined(CUSTOM) diff --git a/custom/custtbl.c b/custom/custtbl.c index bb5c594..849580e 100644 --- a/custom/custtbl.c +++ b/custom/custtbl.c @@ -24,12 +24,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ diff --git a/custom/halflen.cal b/custom/halflen.cal index 8f81810..4e4fd98 100644 --- a/custom/halflen.cal +++ b/custom/halflen.cal @@ -10,7 +10,7 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * chongo was here /\../\ chongo@toad.com + * chongo was here /\../\ http://reality.sgi.com/chongo */ /* * halflen - determine the length of numeric value in HALFs diff --git a/func.c b/func.c index fa83754..ead1b4e 100644 --- a/func.c +++ b/func.c @@ -153,12 +153,14 @@ f_eval(VALUE *vp) FUNC *oldfunc; FUNC *newfunc; VALUE result; - char *cp; + char *str; + long num; if (vp->v_type != V_STR) return error_value(E_EVAL2); - cp = vp->v_str->s_str; - switch (openstring(cp)) { + str = vp->v_str->s_str; + num = vp->v_str->s_len; + switch (openstring(str, num)) { case -2: return error_value(E_EVAL3); case -1: @@ -167,6 +169,7 @@ f_eval(VALUE *vp) oldfunc = curfunc; enterfilescope(); if (evaluate(TRUE)) { + closeinput(); exitfilescope(); freevalue(stack--); newfunc = curfunc; @@ -178,6 +181,7 @@ f_eval(VALUE *vp) free(newfunc); return result; } + closeinput(); exitfilescope(); newfunc = curfunc; curfunc = oldfunc; @@ -5889,6 +5893,17 @@ f_isatty(VALUE *vp) } +static VALUE +f_inputlevel (void) +{ + VALUE result; + + result.v_type = V_NUM; + result.v_num = itoq((long) inputlevel()); + return result; +} + + static VALUE f_access(int count, VALUE **vals) { @@ -6973,6 +6988,8 @@ static CONST struct builtin builtins[] = { "integral log of a number base 2"}, {"im", 1, 1, 0, OP_IM, 0, 0, "imaginary part of complex number"}, + {"inputlevel", 0, 0, 0, OP_NOP, 0, f_inputlevel, + "current input depth"}, {"insert", 2, IN, FA, OP_NOP, 0, f_listinsert, "insert values c ... into list a at position b"}, {"int", 1, 1, 0, OP_INT, qint, 0, diff --git a/help/Makefile b/help/Makefile index b9617bc..892e1e5 100644 --- a/help/Makefile +++ b/help/Makefile @@ -74,7 +74,7 @@ STD_HELP_FILES_12= archive BLT_HELP_FILES_13= bugs changes -STD_HELP_FILES_14= contrib credit todo +STD_HELP_FILES_14= contrib credit wishlist todo # These files are used in the following order to construct full # diff --git a/help/archive b/help/archive index c62fe5b..3bbcc9c 100644 --- a/help/archive +++ b/help/archive @@ -22,4 +22,7 @@ Where to get the the latest versions of calc where "address" is your EMail address and "your_full_name" is your full name. -Landon Curt Noll /\oo/\ +Landon Curt Noll +http://reality.sgi.com/chongo + +chongo /\../\ diff --git a/help/contrib b/help/contrib index 9856418..ee60411 100644 --- a/help/contrib +++ b/help/contrib @@ -45,4 +45,7 @@ Thanks for considering submitting code to calc. Calc is a collective work by a number of people. It would not be what it is today without your efforts and submissions! -Landon Curt Noll /\oo/\ +Landon Curt Noll +http://reality.sgi.com/chongo + +chongo /\../\ diff --git a/help/credit b/help/credit index 0e4fd3e..6869be4 100644 --- a/help/credit +++ b/help/credit @@ -34,12 +34,12 @@ Credits interesting calc scripts that you would like you see included in future distributions to: - dbell@auug.org.au - chongo@toad.com + calc-tester@postofc.corp.sgi.com - Landon Noll maintains the official calc ftp archive at: + Landon Noll maintains the official calc http/ftp archive at: - ftp://ftp.uu.net/pub/calc + ftp://reality.sgi.com/users/chongo/src/calc + http://reality.sgi.com/chongo/src/calc/ Alpha test versions, complete with bugs, untested code and experimental features may be fetched (if you are brave) under: diff --git a/help/help b/help/help index ad86b5d..5a64f9b 100644 --- a/help/help +++ b/help/help @@ -42,7 +42,8 @@ following topics: changes recent changes to calc contrib how to contribute scripts, code or custom functions credit who wrote calc and who helped - todo needed enhancements and wish list + todo list of priority action items for calc + wishlist wish list of future enhancements of calc full all of the above (in the above order) diff --git a/help/todo b/help/todo index cc0971e..18fb2a5 100644 --- a/help/todo +++ b/help/todo @@ -1,183 +1,71 @@ -Needed enhancements +Calc Todo Items: - Send calc comments, suggestions, bug fixes, enhancements and - interesting calc scripts that you would like you see included in - future distributions to: + The following items should be addressed sometime in the short to + medium term future, if not before the next release. - dbell@auug.org.au - chongo@toad.com + Code contributions are welcome. Send patches to: - The following items are in the calc wish list. Programs like this - can be extended and improved forever. + calc-tester@postofc.corp.sgi.com - * In general use faster algorithms for large numbers when they - become known. In particular, look at better algorithms for - very large numbers -- multiply, square and mod in particular. + See also the 'wishlist' help files for the calc enhancement wish list. - * Implement an autoload feature. Associate a calc library filename - with a function or global variable. On the first reference of - such item, perform an automatic load of that file. +=-= - * Add error handling statements, so that QUITs, errors from the - 'eval' function, division by zeroes, and so on can be caught. - This should be done using syntax similar to: +Very High priority items: - ONERROR statement DO statement; + * Write the help file for the inputlevel() builtin function. - Something like signal isn't versatile enough. + * Write the help file for the display() builtin function. - * Add a debugging capability so that functions can be single stepped, - breakpoints inserted, variables displayed, and so on. + * Write the help file for the stoponerror() builtin function. - * Figure out how to write all variables out to a file, including - deeply nested arrays, lists, and objects. + * Update the errmax about the meaning of errmax(-1). - Add the ability to read and write a value in some binary form. - Clearly this is easy for non-neg integers. The question of - everything else is worth pondering. + * Document the new meanings for bit values and the sign of + of config("lib_debug") in the appropriate help file(s). - * Eliminate the need for the define keyword by doing smarter parsing. + * Fix any 'Known bugs' as noted in the BUGS file or as + displayed by 'calc help bugs'. - * Allow results of a command (or all commands) to be re-directed to a - file or piped into a command. +=-= - * Add some kind of #include and #define facility. Perhaps use - the C pre-processor itself? +High priority items: - * Support a more general input and output base mode other than - just dec, hex or octal. + * Verify, complete or fix the 'SEE ALSO' help file sections. - * Implement a form of symbolic algebra. Work on this has already - begun. This will use backquotes to define expressions, and new - functions will be able to act on expressions. For example: + * Verify, complete or fix the 'LIBRARY' help file sections. - x = `hello * strlen(mom)`; - x = sub(x, `hello`, `hello + 1`); - x = sub(x, `hello`, 10, `mom`, "curds"); - eval(x); + * Verify, complete or fix the 'LIMITS' help file sections. - prints 55. + * Verify, complete or fix the 'SYNOPSIS' and 'TYPES' help file sections. - * Place the results of previous commands into a parallel history list. - Add a binding that returns the saved result of the command so - that one does not need to re-execute a previous command simply - to obtain its value. + * Where reasonable, be sure that regress.cal tests builtin functions. - If you have a command that takes a very long time to execute, - it would be nice if you could get at its result without having - to spend the time to reexecute it. + * Perform a code coverage analysis of the 'make check' action + and improve the coverage (within reason) of the regress.cal suite. - * Add a binding to delete a value from the history list. + * Create a Linux rpm (Red Hat Package Manager) package for calc. - One may need to remove a large value from the history list if - it is very large. Deleting the value would replace the history - entry with a null value. + * Address, if possible and reasonable, any Calc Mis-features + as noted in the BUGS file or as displayed by 'calc help bugs'. - * Add a binding to delete a command from the history list. + * The shell script that is currently constructed to display a help + file (in help.c) is a gross hack. That code should be replaced + with code that looks for the help file in the pre-defined help + directories. When the specific help file is found and opened, + then a $PAGER should be forked and execed after doing things such + as closing open file descriptors that the $PAGER does not need. - Since you can delete values, you might as well be able to - delete commands. + * Inspect changes made since the last major calc release (the + initial x.y.z version ... prior to any t sub-version) to help + ensure that they have not introduced new or re-introduced old bugs + into calc. - * All one to alter the size of the history list thru config(). +=-= - In some cases, 256 values is too small, in others it is too large. +Medium priority items: - * Add a builtin that returns a value from the history list. - As an example: - - histval(-10) - - returns the 10th value on the history value list, if such - a value is in the history list (null otherwise). And: - - histval(23) - - return the value of the 23rd command given to calc, if - such a value is in the history list (null otherwise). - - It would be very helpful to use the history values in - subsequent equations. - - * Add a builtin that returns command as a string from the - history list. As an example: - - history(-10) - - returns a string containing the 10th command on the - history list, if a such a value is in the history list - (empty string otherwise). And: - - history(23) - - return the string containing the 23rd command given to calc, if - such a value is in the history list (empty string otherwise). - - One could use the eval() function to re-evaluate the command. - - * Allow one to optionally restore the command number to calc - prompts. When going back in the history list, indicate the - command number that is being examined. - - The command number was a useful item. When one is scanning the - history list, knowing where you are is hard without it. It can - get confusing when the history list wraps or when you use - search bindings. Command numbers would be useful in - conjunction with positive args for the history() and histval() - functions as suggested above. - - * Add a builtin that returns the current command number. - For example: - - cmdnum() - - returns the current command number. - - This would allow one to tag a value in the history list. One - could save the result of cmdnum() in a variable and later use - it as an arg to the histval() or history() functions. - - * Add a factoring builtin functions. Provide functions that perform - multiple polynomial quadratic sieves, elliptic curve, difference - of two squares, N-1 factoring as so on. Provide a easy general - factoring builtin (say factor(foo)) that would attempt to apply - whatever process was needed based on the value. - - Factoring builtins would return a matrix of factors. - - It would be handy to configure, via config(), the maximum time - that one should try to factor a number. By default the time - should be infinite. If one set the time limit to a finite - value and the time limit was exceeded, the factoring builtin - would return whatever if had found thus far, even if no new - factors had been found. - - Another factoring configuration interface, via config(), that - is needed would be to direct the factoring builtins to return - as soon as a factor was found. - - * Allow one to config calc break up long output lines. - - The command: calc '2^100000' will produce one very long - line. Many times this is reasonable. Long output lines - are a problem for some utilities. It would be nice if one - could configure, via config(), calc to fold long lines. - - By default, calc should continue to produce long lines. - - One option to config should be to specify the length to - fold output. Another option should be to append a trailing - \ on folded lines (as some symbolic packages use). - - * Allow one to use the READ and WRITE commands inside a function. - - * Remove or increase limits on factor(), lfactor(), isprime(), - nextprime(), and prevprime(). Currently these functions cannot - search for factors > 2^32. - - * Add read -once -try "filename" which would do nothing - if "filename" was not a readable file. - - * Complete the use of CONST where appropirate: + * Complete the use of CONST where appropriate: CONST is beginning to be used with read-only tables and some function arguments. This allows certain compilers to better @@ -196,48 +84,10 @@ Needed enhancements at by 'fizbin' and the HALF array pointer at by 'data' should be treated as read-only. - * Blocks should have the following features: - - + read/write to/from files (ala fread/fwrite) - - + misc memory functions (ala memcpy, memcmp, memset, - memchr, etc.) - - + scatter and gather functions (to send every n-th octet - to another block and to copy from n blocks, the 1st - then 2nd then 3rd ... octets) - - * Printing of blocks should be under the control of the - config() interface. This should allow one to select - from any of the following formats: - - + as one long string - - + as a series of lines (< 80 chars wide) - - + in od command style (offset: value value value ...) - - + in hex dump style (offset: val val val val ... 3hf.Uas.c) - - * In addition one should be able to control the following - aspects of printing blocks via the config() interface: - - + base (hex, octal, char, base 2) - - + amount of data (the first n octets or the entire block) - - + skipping printing of duplicate print lines (ala od) - - + have the ability to print the block as raw data - * It is overkill to have nearly everything wind up in libcalc.a. - One should make available a the fundimental math operations + One should make available a the fundamental math operations on ZVALUE, NUMBER and perhaps COMPLEX (without all of the other stuff) in a separate library. - * improve the coverage in the 'SEE ALSO' help file lists - - * where reasonable, be sure that regress.cal tests builtin functions - - * clean the source code and document it better + * Clean the source code and document it better. diff --git a/help/wishlist b/help/wishlist new file mode 100644 index 0000000..7671f80 --- /dev/null +++ b/help/wishlist @@ -0,0 +1,215 @@ +Calc Enhancement Wish List: + + Send calc comments, suggestions, bug fixes, enhancements and + interesting calc scripts that you would like you see included in + future distributions to: + + calc-tester@postofc.corp.sgi.com + + The following items are in the calc wish list. Programs like this + can be extended and improved forever. + + See the 'todo' help file for higher priority todo items. + +=-= + + * In general use faster algorithms for large numbers when they + become known. In particular, look at better algorithms for + very large numbers -- multiply, square and mod in particular. + + * Implement an autoload feature. Associate a calc library filename + with a function or global variable. On the first reference of + such item, perform an automatic load of that file. + + * Add error handling statements, so that QUITs, errors from the + 'eval' function, division by zeroes, and so on can be caught. + This should be done using syntax similar to: + + ONERROR statement DO statement; + + Something like signal isn't versatile enough. + + * Add a debugging capability so that functions can be single stepped, + breakpoints inserted, variables displayed, and so on. + + * Figure out how to write all variables out to a file, including + deeply nested arrays, lists, and objects. + + Add the ability to read and write a value in some binary form. + Clearly this is easy for non-neg integers. The question of + everything else is worth pondering. + + * Eliminate the need for the define keyword by doing smarter parsing. + + * Allow results of a command (or all commands) to be re-directed to a + file or piped into a command. + + * Add some kind of #include and #define facility. Perhaps use + the C pre-processor itself? + + * Support a more general input and output base mode other than + just dec, hex or octal. + + * Implement a form of symbolic algebra. Work on this has already + begun. This will use backquotes to define expressions, and new + functions will be able to act on expressions. For example: + + x = `hello * strlen(mom)`; + x = sub(x, `hello`, `hello + 1`); + x = sub(x, `hello`, 10, `mom`, "curds"); + eval(x); + + prints 55. + + * Place the results of previous commands into a parallel history list. + Add a binding that returns the saved result of the command so + that one does not need to re-execute a previous command simply + to obtain its value. + + If you have a command that takes a very long time to execute, + it would be nice if you could get at its result without having + to spend the time to reexecute it. + + * Add a binding to delete a value from the history list. + + One may need to remove a large value from the history list if + it is very large. Deleting the value would replace the history + entry with a null value. + + * Add a binding to delete a command from the history list. + + Since you can delete values, you might as well be able to + delete commands. + + * All one to alter the size of the history list thru config(). + + In some cases, 256 values is too small, in others it is too large. + + * Add a builtin that returns a value from the history list. + As an example: + + histval(-10) + + returns the 10th value on the history value list, if such + a value is in the history list (null otherwise). And: + + histval(23) + + return the value of the 23rd command given to calc, if + such a value is in the history list (null otherwise). + + It would be very helpful to use the history values in + subsequent equations. + + * Add a builtin that returns command as a string from the + history list. As an example: + + history(-10) + + returns a string containing the 10th command on the + history list, if a such a value is in the history list + (empty string otherwise). And: + + history(23) + + return the string containing the 23rd command given to calc, if + such a value is in the history list (empty string otherwise). + + One could use the eval() function to re-evaluate the command. + + * Allow one to optionally restore the command number to calc + prompts. When going back in the history list, indicate the + command number that is being examined. + + The command number was a useful item. When one is scanning the + history list, knowing where you are is hard without it. It can + get confusing when the history list wraps or when you use + search bindings. Command numbers would be useful in + conjunction with positive args for the history() and histval() + functions as suggested above. + + * Add a builtin that returns the current command number. + For example: + + cmdnum() + + returns the current command number. + + This would allow one to tag a value in the history list. One + could save the result of cmdnum() in a variable and later use + it as an arg to the histval() or history() functions. + + * Add a factoring builtin functions. Provide functions that perform + multiple polynomial quadratic sieves, elliptic curve, difference + of two squares, N-1 factoring as so on. Provide a easy general + factoring builtin (say factor(foo)) that would attempt to apply + whatever process was needed based on the value. + + Factoring builtins would return a matrix of factors. + + It would be handy to configure, via config(), the maximum time + that one should try to factor a number. By default the time + should be infinite. If one set the time limit to a finite + value and the time limit was exceeded, the factoring builtin + would return whatever if had found thus far, even if no new + factors had been found. + + Another factoring configuration interface, via config(), that + is needed would be to direct the factoring builtins to return + as soon as a factor was found. + + * Allow one to config calc break up long output lines. + + The command: calc '2^100000' will produce one very long + line. Many times this is reasonable. Long output lines + are a problem for some utilities. It would be nice if one + could configure, via config(), calc to fold long lines. + + By default, calc should continue to produce long lines. + + One option to config should be to specify the length to + fold output. Another option should be to append a trailing + \ on folded lines (as some symbolic packages use). + + * Allow one to use the READ and WRITE commands inside a function. + + * Remove or increase limits on factor(), lfactor(), isprime(), + nextprime(), and prevprime(). Currently these functions cannot + search for factors > 2^32. + + * Add read -once -try "filename" which would do nothing + if "filename" was not a readable file. + + * Blocks should have the following features: + + + read/write to/from files (ala fread/fwrite) + + + misc memory functions (ala memcpy, memcmp, memset, + memchr, etc.) + + + scatter and gather functions (to send every n-th octet + to another block and to copy from n blocks, the 1st + then 2nd then 3rd ... octets) + + * Printing of blocks should be under the control of the + config() interface. This should allow one to select + from any of the following formats: + + + as one long string + + + as a series of lines (< 80 chars wide) + + + in od command style (offset: value value value ...) + + + in hex dump style (offset: val val val val ... 3hf.Uas.c) + + * In addition one should be able to control the following + aspects of printing blocks via the config() interface: + + + base (hex, octal, char, base 2) + + + amount of data (the first n octets or the entire block) + + + skipping printing of duplicate print lines (ala od) + + + have the ability to print the block as raw data diff --git a/input.c b/input.c index 13efa8a..17422b3 100644 --- a/input.c +++ b/input.c @@ -33,8 +33,9 @@ typedef struct { int i_state; /* state (read, reread) */ int i_char; /* currently read char */ long i_line; /* line number */ - char *i_str; /* current string for input (if not NULL) */ - char *i_origstr; /* original string so it can be freed */ + char *i_cp; /* pointer to string character to be read */ + char *i_str; /* start of string copy to be read, or NULL */ + long i_num; /* number of string characters remaining */ char *i_ttystr; /* current character of tty line (or NULL) */ FILE *i_fp; /* current file for input (if not NULL) */ char *i_name; /* file name if known */ @@ -311,7 +312,7 @@ f_open(char *name, char *mode) */ if (!allow_read && !allow_write) { /* no reads and no writes means no opens! */ - if (run_state > RUN_PRE_BEGIN) { + if (run_state > RUN_BEGIN) { fprintf(stderr, "open of %s mode %s - %s\n", name, mode, "open for read or write disallowed by -m\n"); @@ -319,7 +320,7 @@ f_open(char *name, char *mode) return NULL; } else if (!allow_read && strchr(mode, 'r') != NULL) { /* reading new files disallowed */ - if (run_state > RUN_PRE_BEGIN) { + if (run_state > RUN_BEGIN) { fprintf(stderr, "open of %s mode %s - %s\n", name, mode, "open for read disallowed by -m\n"); @@ -330,7 +331,7 @@ f_open(char *name, char *mode) strchr(mode, 'a') != NULL || strchr(mode, '+') != NULL)) { /* writing new files disallowed */ - if (run_state > RUN_PRE_BEGIN) { + if (run_state > RUN_BEGIN) { fprintf(stderr, "open of %s mode %s - %s\n", name, mode, "open for write disallowed by -m\n"); @@ -375,7 +376,6 @@ openfile(char *name) cip->i_state = IS_READ; cip->i_char = '\0'; cip->i_str = NULL; - cip->i_origstr = NULL; cip->i_ttystr = NULL; cip->i_fp = fp; cip->i_line = 1; @@ -401,7 +401,7 @@ curstream(void) /* - * Open a string for scanning. String is ended by a null character. + * Open a string for scanning, num characters to be read. * String is copied into local memory so it can be trashed afterwards. * Returns -1 if cannot open string. * @@ -409,21 +409,22 @@ curstream(void) * str string to be opened */ int -openstring(char *str) +openstring(char *str, long num) { char *cp; /* copied string */ if ((depth >= MAXDEPTH) || (str == NULL)) return -2; - cp = (char *)malloc(strlen(str) + 1); + cp = (char *) malloc(num + 1); if (cp == NULL) return -1; strcpy(cp, str); cip = inputs + depth++; cip->i_state = IS_READ; cip->i_char = '\0'; + cip->i_cp = cp; cip->i_str = cp; - cip->i_origstr = cp; + cip->i_num = num; cip->i_fp = NULL; cip->i_name = NULL; cip->i_ttystr = NULL; @@ -445,7 +446,6 @@ openterminal(void) cip->i_state = IS_READ; cip->i_char = '\0'; cip->i_str = NULL; - cip->i_origstr = NULL; cip->i_ttystr = NULL; cip->i_fp = NULL; cip->i_name = NULL; @@ -462,8 +462,8 @@ closeinput(void) { if (depth <= 0) return; - if (cip->i_origstr) - free(cip->i_origstr); + if (cip->i_str) + free(cip->i_str); if (cip->i_fp) fclose(cip->i_fp); if (cip->i_name) @@ -515,8 +515,11 @@ nextchar(void) return ch; } if (cip->i_str) { /* from string */ - ch = chartoint(*cip->i_str++); - if (ch == '\0') + if (cip->i_num) { + ch = chartoint(*cip->i_cp++); + cip->i_num--; + } + else ch = EOF; } else if (cip->i_fp) { /* from file */ ch = fgetc(cip->i_fp); @@ -525,10 +528,6 @@ nextchar(void) } else { /* from terminal */ ch = ttychar(); } - if (ch == EOF) { /* fix up end of file */ - closeinput(); - ch = EOF; - } if (depth > 0) cip->i_char = ch; /* save for rereads */ if (ch == '\n') @@ -663,6 +662,16 @@ inputisterminal(void) } +/* + * Return depth of current input source + */ +int +inputlevel(void) +{ + return depth - 1; +} + + /* * Return the name of the current input file. * Returns NULL for terminal or strings. @@ -739,6 +748,7 @@ runrcfiles(void) if (i < 0) continue; getcommands(FALSE); + closeinput(); } } diff --git a/lib/chrem.cal b/lib/chrem.cal index c4ffdff..45d9972 100644 --- a/lib/chrem.cal +++ b/lib/chrem.cal @@ -86,7 +86,7 @@ * i.e., any value that is 301 mod 420. * * Written by: Ernest W Bowen - * Interface by: Landon Curt Noll + * Interface by: Landon Curt Noll http://reality.sgi.com/chongo */ static defaultmlist = list(2,3,5,7,11,13,17,19); /* The first eight primes */ diff --git a/lib/lucas.cal b/lib/lucas.cal index 812f069..ad7eccd 100644 --- a/lib/lucas.cal +++ b/lib/lucas.cal @@ -19,7 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * chongo was here /\../\ chongo@toad.com + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ */ /* * lucas - perform a Lucas primality test on h*2^n-1 diff --git a/lib/lucas_chk.cal b/lib/lucas_chk.cal index b5cb9b8..4a712a8 100644 --- a/lib/lucas_chk.cal +++ b/lib/lucas_chk.cal @@ -19,7 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * chongo was here /\../\ chongo@toad.com + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ */ /* * primes of the form h*2^n-1 for 1<=h<200 and 1<=n<1000 diff --git a/lib/lucas_tbl.cal b/lib/lucas_tbl.cal index 4d386da..bca75c7 100644 --- a/lib/lucas_tbl.cal +++ b/lib/lucas_tbl.cal @@ -19,7 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * chongo was here /\../\ chongo@toad.com + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ */ /* * Lucasian criteria for primality diff --git a/lib/mfactor.cal b/lib/mfactor.cal index fa4b08f..773ba9a 100644 --- a/lib/mfactor.cal +++ b/lib/mfactor.cal @@ -19,7 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * chongo was here /\../\ chongo@toad.com + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ */ diff --git a/lib/qtime.cal b/lib/qtime.cal index 676b4a0..6f83e0e 100644 --- a/lib/qtime.cal +++ b/lib/qtime.cal @@ -7,7 +7,7 @@ * utc_hr_offset Offset from UTC in hours. * * Written by: Klaus Alexander Seistrup - * With minor mods by: Landon Curt Noll + * With minor mods by: Landon Curt Noll * * See: * http://www.magnetic-ink.dk/download/qtime.html diff --git a/lib/randmprime.cal b/lib/randmprime.cal index 438036d..2bad6a8 100644 --- a/lib/randmprime.cal +++ b/lib/randmprime.cal @@ -21,7 +21,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * chongo was here /\../\ chongo@toad.com + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ */ /* obtain our required libs */ diff --git a/lib/regress.cal b/lib/regress.cal index cb86e4f..4bd5a8e 100644 --- a/lib/regress.cal +++ b/lib/regress.cal @@ -7393,6 +7393,23 @@ print; return test_somenew(); +/* + * misc define tests + */ +print; +print '8300: Starting define tests'; +define f8300(x) = x^2; define g8300(x) = 1 - x; +print '8301: define f8300(x) = x^2; define g8300(x) = 1 - x;'; +vrfy(f8300(10) == 100, '8302: f8300(10) == 100'); +vrfy(g8300(10) == -9, '8303: g8300(10) == -9'); +define h8300(x)=x^3;define i8300(x)=x-1;define j8300(x)=x+1; +print '8304: define h8300(x)=x^3;define i8300(x)=x-1;define j8300(x)=x+1;'; +vrfy(h8300(10) == 1000, '8305: h8300(10) == 1000'); +vrfy(i8300(10) == 9, '8306: i8300(10) == 9'); +vrfy(j8300(10) == 11, '8307: j8300(10) == 11'); +print '8308: Ending define tests'; + + /* * read various calc libs * diff --git a/lib/seedrandom.cal b/lib/seedrandom.cal index 6ad63f5..6d28f7d 100644 --- a/lib/seedrandom.cal +++ b/lib/seedrandom.cal @@ -19,7 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * chongo was here /\../\ chongo@toad.com + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ */ /* diff --git a/lib/test1700.cal b/lib/test1700.cal index 081d8b3..74c9d0d 100644 --- a/lib/test1700.cal +++ b/lib/test1700.cal @@ -3,8 +3,10 @@ * Permission is granted to use, distribute, or modify this source, * provided that this copyright notice remains intact. * - * By: Landon Curt Noll - * chongo@toad.com -or- ...!{pyramid,sun,uunet}!hoptoad!chongo + * By: Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ * * This library is used by the 1700 series of the regress.cal test suite. */ diff --git a/lib/test2300.cal b/lib/test2300.cal index d288339..823eca3 100644 --- a/lib/test2300.cal +++ b/lib/test2300.cal @@ -3,8 +3,10 @@ * Permission is granted to use, distribute, or modify this source, * provided that this copyright notice remains intact. * - * By: Landon Curt Noll - * chongo@toad.com -or- ...!{pyramid,sun,uunet}!hoptoad!chongo + * By: Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ * * This library is used by the 2300 series of the regress.cal test suite. */ diff --git a/lib/test2600.cal b/lib/test2600.cal index ddd39b0..1b79ee1 100644 --- a/lib/test2600.cal +++ b/lib/test2600.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 2600 series of the regress.cal test suite. */ diff --git a/lib/test2700.cal b/lib/test2700.cal index 28a1848..0a9f955 100644 --- a/lib/test2700.cal +++ b/lib/test2700.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 2700 series of the regress.cal test suite. */ diff --git a/lib/test3100.cal b/lib/test3100.cal index e75c3a6..a4ee9da 100644 --- a/lib/test3100.cal +++ b/lib/test3100.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 3100 series of the regress.cal test suite. */ diff --git a/lib/test3300.cal b/lib/test3300.cal index 5178636..829a52b 100644 --- a/lib/test3300.cal +++ b/lib/test3300.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 3300 series of the regress.cal test suite. */ diff --git a/lib/test3400.cal b/lib/test3400.cal index 6273040..23a5789 100644 --- a/lib/test3400.cal +++ b/lib/test3400.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 3400 series of the regress.cal test suite. */ diff --git a/lib/test3500.cal b/lib/test3500.cal index ba2acd6..b18e044 100644 --- a/lib/test3500.cal +++ b/lib/test3500.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 3500 series of the regress.cal test suite. */ diff --git a/lib/test4000.cal b/lib/test4000.cal index 8c94fcd..61d9e10 100644 --- a/lib/test4000.cal +++ b/lib/test4000.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 4000 series of the regress.cal test suite. */ diff --git a/lib/test4100.cal b/lib/test4100.cal index c05cadc..67ce2f2 100644 --- a/lib/test4100.cal +++ b/lib/test4100.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 4100 series of the regress.cal test suite. */ diff --git a/lib/test4600.cal b/lib/test4600.cal index 2b075fc..8697d69 100644 --- a/lib/test4600.cal +++ b/lib/test4600.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 4600 series of the regress.cal test suite. */ diff --git a/lib/test5100.cal b/lib/test5100.cal index 25dec81..19f2c35 100644 --- a/lib/test5100.cal +++ b/lib/test5100.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 5100 series of the regress.cal test suite. */ diff --git a/lib/test5200.cal b/lib/test5200.cal index 49c4c22..941adaf 100644 --- a/lib/test5200.cal +++ b/lib/test5200.cal @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo * * This library is used by the 5200 series of the regress.cal test suite. */ diff --git a/lib_calc.c b/lib_calc.c index 162492d..2d7a27d 100644 --- a/lib_calc.c +++ b/lib_calc.c @@ -180,7 +180,7 @@ libcalc_call_me_first(void) /* * ready to rock & roll .. */ - run_state = RUN_PRE_BEGIN; + run_state = RUN_BEGIN; init_done = 1; return; } @@ -247,6 +247,7 @@ reinitialize(void) math_setfp(stdout); resetscopes(); resetinput(); + inittokens(); (void) openterminal(); } diff --git a/math_error.h b/math_error.h index d9b176a..159e968 100644 --- a/math_error.h +++ b/math_error.h @@ -27,12 +27,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ diff --git a/nametype.h b/nametype.h index 625909c..81ae513 100644 --- a/nametype.h +++ b/nametype.h @@ -28,12 +28,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ diff --git a/poly.c b/poly.c index 781a866..3b8eee3 100644 --- a/poly.c +++ b/poly.c @@ -4,7 +4,7 @@ * provided that this copyright notice remains intact. * * By: Ernest Bowen and Landon Curt Noll - * ernie@neumann.une.edu.au and chongo@toad.com + * ernie@neumann.une.edu.au and http://reality.sgi.com/chongo */ #include "value.h" diff --git a/quickhash.c b/quickhash.c index c7d5083..6674fc8 100644 --- a/quickhash.c +++ b/quickhash.c @@ -19,7 +19,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * chongo was here /\../\ + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ */ /* @@ -81,7 +84,7 @@ static QCKHASH blk_hash(BLOCK *blk, QCKHASH val); * The basis of the hash algorithm was taken from an idea * sent by Email to the IEEE Posix P1003.2 mailing list from * Phong Vo (kpv@research.att.com) and Glenn Fowler (gsf@research.att.com). - * Landon Curt Noll (chongo@toad.com) later improved on there + * Landon Curt Noll (http://reality.sgi.com/chongo) later improved on there * algorithm to come up with Fowler/Noll/Vo hash. * * The magic lies in the constant 16777619, which for 32 bit hashing diff --git a/sample/Makefile b/sample/Makefile index 5d980d1..e8d8431 100644 --- a/sample/Makefile +++ b/sample/Makefile @@ -26,12 +26,10 @@ # # Happy bit twiddling, # -# Landon Curt Noll +# Landon Curt Noll +# http://reality.sgi.com/chongo # -# chongo@toad.com -# ...!{pyramid,sun,uunet}!hoptoad!chongo -# -# chongo was here /\../\ +# chongo /\../\ ############################################################################## #-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-# diff --git a/seed.c b/seed.c index 067171a..c991fc6 100644 --- a/seed.c +++ b/seed.c @@ -28,7 +28,10 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * chongo was here /\../\ {chongo,noll}@{toad,sgi}.com + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ * * Share and enjoy! :-) */ @@ -113,8 +116,8 @@ hash_buf(char *buf, unsigned len) * * for information on 32bit and 64bit Fowler/Noll/Vo hashes. * - * Landon Curt Noll (chongo@toad.com) later improved on their - * algorithm to come up with Fowler/Noll/Vo hash. + * Landon Curt Noll (http://reality.sgi.com/chongo) later improved + * on their algorithm to come up with Fowler/Noll/Vo hash. * * The 32 hash was able to process 234936 words from the web2 dictionary * without any 32 bit collisions using a constant of diff --git a/shs.c b/shs.c index 07b6650..079cea5 100644 --- a/shs.c +++ b/shs.c @@ -11,7 +11,10 @@ * * This file was Modified/Re-written by: * - * Landon Curt Noll (chongo@toad.com) chongo /\../\ + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ * * This code has been placed in the public domain. Please do not * copyright this code. @@ -26,7 +29,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Based on Version 2.11 (09 Mar 1995) from Landon Curt Noll's - * (chongo@toad.com) shs hash program. + * (http://reality.sgi.com/chongo) shs hash program. * **** * diff --git a/shs.h b/shs.h index a1cb24d..cc819c6 100644 --- a/shs.h +++ b/shs.h @@ -11,7 +11,10 @@ * * This file was Modified by: * - * Landon Curt Noll (chongo@toad.com) chongo /\../\ + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ * * This code has been placed in the public domain. Please do not * copyright this code. diff --git a/shs1.c b/shs1.c index 1218092..4c187a8 100644 --- a/shs1.c +++ b/shs1.c @@ -5,7 +5,10 @@ * * This file was Modified/Re-written by: * - * Landon Curt Noll (chongo@toad.com) chongo /\../\ + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ * * This code has been placed in the public domain. Please do not * copyright this code. diff --git a/shs1.h b/shs1.h index 4553102..6c0b11e 100644 --- a/shs1.h +++ b/shs1.h @@ -5,7 +5,10 @@ * * This file was Modified by: * - * Landon Curt Noll (chongo@toad.com) chongo /\../\ + * Landon Curt Noll + * http://reality.sgi.com/chongo + * + * chongo /\../\ * * This code has been placed in the public domain. Please do not * copyright this code. diff --git a/version.c b/version.c index 6e00dc2..247388f 100644 --- a/version.c +++ b/version.c @@ -12,7 +12,7 @@ #define MAJOR_VER 2 /* major version */ #define MINOR_VER 11 /* minor version */ #define MAJOR_PATCH 0 /* patch level or 0 if no patch */ -#define MINOR_PATCH "7.5" /* test number or empty string if no patch */ +#define MINOR_PATCH "8" /* test number or empty string if no patch */ /* * calc version constants diff --git a/zrand.c b/zrand.c index 6cf74d4..2b0b60d 100644 --- a/zrand.c +++ b/zrand.c @@ -28,12 +28,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ /* diff --git a/zrand.h b/zrand.h index 6c86cb8..d3b0ec5 100644 --- a/zrand.h +++ b/zrand.h @@ -28,12 +28,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ /* * random number generator - see zrand.c for details diff --git a/zrandom.c b/zrandom.c index 8191e44..9580cae 100644 --- a/zrandom.c +++ b/zrandom.c @@ -28,12 +28,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ /* diff --git a/zrandom.h b/zrandom.h index 85f4f86..46d00fd 100644 --- a/zrandom.h +++ b/zrandom.h @@ -28,12 +28,10 @@ * * Happy bit twiddling, * - * Landon Curt Noll + * Landon Curt Noll + * http://reality.sgi.com/chongo * - * chongo@toad.com - * ...!{pyramid,sun,uunet}!hoptoad!chongo - * - * chongo was here /\../\ + * chongo /\../\ */ /* * random number generator - see zrandom.c for details