Release calc version 2.11.0t8

This commit is contained in:
Landon Curt Noll
1999-10-20 03:08:51 -07:00
parent 0ffc341b10
commit 2c72ea9339
70 changed files with 656 additions and 463 deletions

46
BUGS
View File

@@ -46,7 +46,7 @@ When you send your report, please include the following information:
* the type of compiler you were using * 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: * 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 None reported. We are sure some bugs exist. When you find them,
for builtins are either inconsistent or missing information. 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 Calc Mis-features:
and not much in the way of comments. We need some major cleanup
and documentation. * 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.

37
CHANGES
View File

@@ -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 <ernie@turing.une.edu.au>)
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: Calc has some new command line flags / command line meaning:
(Thanks goes to Ernest Bowen <ernie@turing.une.edu.au>) (Thanks goes to Ernest Bowen <ernie@turing.une.edu.au>)
@@ -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: 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 The 'show' command by itself will issue an error message
that will remind one of the possible show arguments. that will remind one of the possible show arguments.
(thanks to Ha S. Lam <hl@kuhep4.phsx.ukans.edu>) (thanks to Ha S. Lam <hl@kuhep4.phsx.ukans.edu>)
@@ -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: 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. Calc can now compile on OSF/1, SGI and IBM RS6000 systems.
A number of systems that have both <varargs.h> and <stdarg.h> do A number of systems that have both <varargs.h> and <stdarg.h> do

4
README
View File

@@ -60,10 +60,12 @@ Calc is shipped with a library of calc scripts. For a list see:
See the file: See the file:
help/todo help/todo
help/wishlist
or run: or run:
calc 'help todo' calc help todo
calc help wishlist
for a wish/todo list. Code contributions are welcome. for a wish/todo list. Code contributions are welcome.

View File

@@ -3,7 +3,10 @@
* *
* This file was written by: * This file was written by:
* *
* Landon Curt Noll (chongo@toad.com) chongo <was here> /\../\ * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
* *
* This code has been placed in the public domain. Please do not * This code has been placed in the public domain. Please do not
* copyright this code. * copyright this code.

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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 <stdio.h> #include <stdio.h>

View File

@@ -28,11 +28,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */

View File

@@ -28,11 +28,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */

125
calc.c
View File

@@ -237,73 +237,92 @@ main(int argc, char **argv)
/* /*
* execute calc code based on the run state * execute calc code based on the run state
*/ */
if (run_state == RUN_PRE_BEGIN) { if (run_state == RUN_BEGIN) {
if (!q_flag && allow_read) { if (!q_flag && allow_read) {
run_state = RUN_PRE_RCFILES; run_state = RUN_RCFILES;
runrcfiles(); 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; 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();
} }
if (run_state < RUN_NOT_TOP_LEVEL) { 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; run_state = RUN_TOP_LEVEL;
getcommands(TRUE); 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 * all done
*/ */
libcalc_call_me_last(); libcalc_call_me_last();
return (run_state == RUN_STOP_ON_ERROR || return (run_state == RUN_EXIT_WITH_ERROR ||
run_state == RUN_UNKNOWN) ? 1 : 0; run_state == RUN_UNKNOWN) ? 1 : 0;
} }

19
calc.h
View File

@@ -113,7 +113,7 @@ extern void trimconstants(void);
/* /*
* Input routines. * Input routines.
*/ */
extern int openstring(char *str); extern int openstring(char *str, long num);
extern int openterminal(void); extern int openterminal(void);
extern int opensearchfile(char *name, char *pathlist, char *exten, int reopen_ok); extern int opensearchfile(char *name, char *pathlist, char *exten, int reopen_ok);
extern char *nextline(void); extern char *nextline(void);
@@ -122,6 +122,7 @@ extern void reread(void);
extern void resetinput(void); extern void resetinput(void);
extern void setprompt(char *); extern void setprompt(char *);
extern BOOL inputisterminal(void); extern BOOL inputisterminal(void);
extern int inputlevel(void);
extern char *inputname(void); extern char *inputname(void);
extern long linenumber(void); extern long linenumber(void);
extern void runrcfiles(void); extern void runrcfiles(void);
@@ -195,14 +196,14 @@ extern int allow_exec; /* FALSE => may not execute any commands */
*/ */
typedef enum { typedef enum {
RUN_UNKNOWN = -1, /* unknown or unset start state */ RUN_UNKNOWN = -1, /* unknown or unset start state */
RUN_PRE_BEGIN = 0, /* pre-startup state, calc execution started */ RUN_BEGIN = 0, /* calc execution starts */
RUN_PRE_RCFILES = 1, /* rc files about to or are being evaluated */ RUN_RCFILES = 1, /* rc files being evaluated */
RUN_POST_RCFILES = 2, /* rc files have been evaluated */ RUN_PRE_CMD_ARGS = 2, /* prepare to evaluate cmd args */
RUN_PRE_CMD_ARGS = 3, /* cmd_args about to or are being evaluated */ RUN_CMD_ARGS = 3, /* cmd args being evaluated */
RUN_POST_CMD_ARGS = 4, /* cmd_args have been evaluated */ RUN_PRE_TOP_LEVEL = 4, /* prepare to start top level activity */
RUN_TOP_LEVEL = 5, /* running at the top interactive level */ RUN_TOP_LEVEL = 5, /* running at top level */
RUN_NOT_TOP_LEVEL = 6, /* running not at the top interactive level */ RUN_EXIT = 6, /* normal exit from calc */
RUN_STOP_ON_ERROR = 7 /* we need to stop due to errors */ RUN_EXIT_WITH_ERROR = 7 /* exit with error */
} run; } run;
extern run run_state; extern run run_state;

View File

@@ -567,7 +567,7 @@ scripts that you would like you see included
in future distributions to: in future distributions to:
.sp .sp
.in +0.5i .in +0.5i
calc-tester-request@postofc.corp.sgi.com calc-tester@postofc.corp.sgi.com
.in -0.5i .in -0.5i
.sp .sp
Landon Noll maintains the the Landon Noll maintains the the

View File

@@ -125,6 +125,7 @@ getcommands(BOOL toplevel)
switch (opensearchfile(name,calcpath,CALCEXT,rdonce)) { switch (opensearchfile(name,calcpath,CALCEXT,rdonce)) {
case 0: case 0:
getcommands(FALSE); getcommands(FALSE);
closeinput();
break; break;
case 1: case 1:
/* previously read and -once was given */ /* previously read and -once was given */
@@ -354,10 +355,6 @@ getsimplebody(void)
(void) tokenmode(TM_NEWLINES); (void) tokenmode(TM_NEWLINES);
(void) getexprlist(); (void) getexprlist();
addop(OP_RETURN); addop(OP_RETURN);
if (gettoken() != T_SEMICOLON)
rescantoken();
if (gettoken() != T_NEWLINE)
scanerror(T_NULL, "Illegal function definition");
} }

View File

@@ -29,11 +29,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */

View File

@@ -25,11 +25,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */
/* these include files are needed regardless of CUSTOM */ /* these include files are needed regardless of CUSTOM */

View File

@@ -29,14 +29,11 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */
/* /*
* Be careful what you put in this file, upper .c files include * Be careful what you put in this file, upper .c files include
* this file even when CUSTOM is not defined (ALLOW_CUSTOM is empty). * this file even when CUSTOM is not defined (ALLOW_CUSTOM is empty).

View File

@@ -19,7 +19,7 @@
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE. # 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 The following custom calc library files are provided because they serve
as examples of how use the custom interface. The custom interface as examples of how use the custom interface. The custom interface

View File

@@ -27,11 +27,9 @@
# Happy bit twiddling, # Happy bit twiddling,
# #
# Landon Curt Noll # Landon Curt Noll
# http://reality.sgi.com/chongo
# #
# chongo@toad.com # chongo <was here> /\../\
# ...!{pyramid,sun,uunet}!hoptoad!chongo
#
# chongo was here /\../\
############################################################################## ##############################################################################
#-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-# #-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-#

View File

@@ -10,7 +10,7 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
* *
* chongo was here /\../\ chongo@toad.com * chongo was here /\../\ http://reality.sgi.com/chongo
*/ */
/* /*
* argv - print information about various args * argv - print information about various args

View File

@@ -16,11 +16,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */
#if defined(CUSTOM) #if defined(CUSTOM)

View File

@@ -16,11 +16,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */
#if defined(CUSTOM) #if defined(CUSTOM)

View File

@@ -16,11 +16,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */
#if defined(CUSTOM) #if defined(CUSTOM)

View File

@@ -16,11 +16,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */
#if defined(CUSTOM) #if defined(CUSTOM)

View File

@@ -25,11 +25,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */

View File

@@ -10,7 +10,7 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * 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 * halflen - determine the length of numeric value in HALFs

23
func.c
View File

@@ -153,12 +153,14 @@ f_eval(VALUE *vp)
FUNC *oldfunc; FUNC *oldfunc;
FUNC *newfunc; FUNC *newfunc;
VALUE result; VALUE result;
char *cp; char *str;
long num;
if (vp->v_type != V_STR) if (vp->v_type != V_STR)
return error_value(E_EVAL2); return error_value(E_EVAL2);
cp = vp->v_str->s_str; str = vp->v_str->s_str;
switch (openstring(cp)) { num = vp->v_str->s_len;
switch (openstring(str, num)) {
case -2: case -2:
return error_value(E_EVAL3); return error_value(E_EVAL3);
case -1: case -1:
@@ -167,6 +169,7 @@ f_eval(VALUE *vp)
oldfunc = curfunc; oldfunc = curfunc;
enterfilescope(); enterfilescope();
if (evaluate(TRUE)) { if (evaluate(TRUE)) {
closeinput();
exitfilescope(); exitfilescope();
freevalue(stack--); freevalue(stack--);
newfunc = curfunc; newfunc = curfunc;
@@ -178,6 +181,7 @@ f_eval(VALUE *vp)
free(newfunc); free(newfunc);
return result; return result;
} }
closeinput();
exitfilescope(); exitfilescope();
newfunc = curfunc; newfunc = curfunc;
curfunc = oldfunc; 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 static VALUE
f_access(int count, VALUE **vals) f_access(int count, VALUE **vals)
{ {
@@ -6973,6 +6988,8 @@ static CONST struct builtin builtins[] = {
"integral log of a number base 2"}, "integral log of a number base 2"},
{"im", 1, 1, 0, OP_IM, 0, 0, {"im", 1, 1, 0, OP_IM, 0, 0,
"imaginary part of complex number"}, "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", 2, IN, FA, OP_NOP, 0, f_listinsert,
"insert values c ... into list a at position b"}, "insert values c ... into list a at position b"},
{"int", 1, 1, 0, OP_INT, qint, 0, {"int", 1, 1, 0, OP_INT, qint, 0,

View File

@@ -74,7 +74,7 @@ STD_HELP_FILES_12= archive
BLT_HELP_FILES_13= bugs changes 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 # These files are used in the following order to construct full
# #

View File

@@ -22,4 +22,7 @@ Where to get the the latest versions of calc
where "address" is your EMail address and "your_full_name" where "address" is your EMail address and "your_full_name"
is your full name. is your full name.
Landon Curt Noll <chongo@toad.com> /\oo/\ Landon Curt Noll
http://reality.sgi.com/chongo
chongo <was here> /\../\

View File

@@ -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 work by a number of people. It would not be what it is today without
your efforts and submissions! your efforts and submissions!
Landon Curt Noll <chongo@toad.com> /\oo/\ Landon Curt Noll
http://reality.sgi.com/chongo
chongo <was here> /\../\

View File

@@ -34,12 +34,12 @@ Credits
interesting calc scripts that you would like you see included in interesting calc scripts that you would like you see included in
future distributions to: future distributions to:
dbell@auug.org.au calc-tester@postofc.corp.sgi.com
chongo@toad.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 Alpha test versions, complete with bugs, untested code and
experimental features may be fetched (if you are brave) under: experimental features may be fetched (if you are brave) under:

View File

@@ -42,7 +42,8 @@ following topics:
changes recent changes to calc changes recent changes to calc
contrib how to contribute scripts, code or custom functions contrib how to contribute scripts, code or custom functions
credit who wrote calc and who helped 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) full all of the above (in the above order)

236
help/todo
View File

@@ -1,183 +1,71 @@
Needed enhancements Calc Todo Items:
Send calc comments, suggestions, bug fixes, enhancements and The following items should be addressed sometime in the short to
interesting calc scripts that you would like you see included in medium term future, if not before the next release.
future distributions to:
dbell@auug.org.au Code contributions are welcome. Send patches to:
chongo@toad.com
The following items are in the calc wish list. Programs like this calc-tester@postofc.corp.sgi.com
can be extended and improved forever.
* In general use faster algorithms for large numbers when they See also the 'wishlist' help files for the calc enhancement wish list.
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 Very High priority items:
'eval' function, division by zeroes, and so on can be caught.
This should be done using syntax similar to:
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, * Write the help file for the stoponerror() builtin function.
breakpoints inserted, variables displayed, and so on.
* Figure out how to write all variables out to a file, including * Update the errmax about the meaning of errmax(-1).
deeply nested arrays, lists, and objects.
Add the ability to read and write a value in some binary form. * Document the new meanings for bit values and the sign of
Clearly this is easy for non-neg integers. The question of of config("lib_debug") in the appropriate help file(s).
everything else is worth pondering.
* 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 High priority items:
the C pre-processor itself?
* Support a more general input and output base mode other than * Verify, complete or fix the 'SEE ALSO' help file sections.
just dec, hex or octal.
* Implement a form of symbolic algebra. Work on this has already * Verify, complete or fix the 'LIBRARY' help file sections.
begun. This will use backquotes to define expressions, and new
functions will be able to act on expressions. For example:
x = `hello * strlen(mom)`; * Verify, complete or fix the 'LIMITS' help file sections.
x = sub(x, `hello`, `hello + 1`);
x = sub(x, `hello`, 10, `mom`, "curds");
eval(x);
prints 55. * Verify, complete or fix the 'SYNOPSIS' and 'TYPES' help file sections.
* Place the results of previous commands into a parallel history list. * Where reasonable, be sure that regress.cal tests builtin functions.
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, * Perform a code coverage analysis of the 'make check' action
it would be nice if you could get at its result without having and improve the coverage (within reason) of the regress.cal suite.
to spend the time to reexecute it.
* 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 * Address, if possible and reasonable, any Calc Mis-features
it is very large. Deleting the value would replace the history as noted in the BUGS file or as displayed by 'calc help bugs'.
entry with a null value.
* 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 * Inspect changes made since the last major calc release (the
delete commands. 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. * Complete the use of CONST where appropriate:
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:
CONST is beginning to be used with read-only tables and some CONST is beginning to be used with read-only tables and some
function arguments. This allows certain compilers to better 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 at by 'fizbin' and the HALF array pointer at by 'data' should be
treated as read-only. 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. * 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 on ZVALUE, NUMBER and perhaps COMPLEX (without all of the
other stuff) in a separate library. other stuff) in a separate library.
* improve the coverage in the 'SEE ALSO' help file lists * Clean the source code and document it better.
* where reasonable, be sure that regress.cal tests builtin functions
* clean the source code and document it better

215
help/wishlist Normal file
View File

@@ -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

48
input.c
View File

@@ -33,8 +33,9 @@ typedef struct {
int i_state; /* state (read, reread) */ int i_state; /* state (read, reread) */
int i_char; /* currently read char */ int i_char; /* currently read char */
long i_line; /* line number */ long i_line; /* line number */
char *i_str; /* current string for input (if not NULL) */ char *i_cp; /* pointer to string character to be read */
char *i_origstr; /* original string so it can be freed */ 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) */ char *i_ttystr; /* current character of tty line (or NULL) */
FILE *i_fp; /* current file for input (if not NULL) */ FILE *i_fp; /* current file for input (if not NULL) */
char *i_name; /* file name if known */ char *i_name; /* file name if known */
@@ -311,7 +312,7 @@ f_open(char *name, char *mode)
*/ */
if (!allow_read && !allow_write) { if (!allow_read && !allow_write) {
/* no reads and no writes means no opens! */ /* no reads and no writes means no opens! */
if (run_state > RUN_PRE_BEGIN) { if (run_state > RUN_BEGIN) {
fprintf(stderr, fprintf(stderr,
"open of %s mode %s - %s\n", name, mode, "open of %s mode %s - %s\n", name, mode,
"open for read or write disallowed by -m\n"); "open for read or write disallowed by -m\n");
@@ -319,7 +320,7 @@ f_open(char *name, char *mode)
return NULL; return NULL;
} else if (!allow_read && strchr(mode, 'r') != NULL) { } else if (!allow_read && strchr(mode, 'r') != NULL) {
/* reading new files disallowed */ /* reading new files disallowed */
if (run_state > RUN_PRE_BEGIN) { if (run_state > RUN_BEGIN) {
fprintf(stderr, fprintf(stderr,
"open of %s mode %s - %s\n", name, mode, "open of %s mode %s - %s\n", name, mode,
"open for read disallowed by -m\n"); "open for read disallowed by -m\n");
@@ -330,7 +331,7 @@ f_open(char *name, char *mode)
strchr(mode, 'a') != NULL || strchr(mode, 'a') != NULL ||
strchr(mode, '+') != NULL)) { strchr(mode, '+') != NULL)) {
/* writing new files disallowed */ /* writing new files disallowed */
if (run_state > RUN_PRE_BEGIN) { if (run_state > RUN_BEGIN) {
fprintf(stderr, fprintf(stderr,
"open of %s mode %s - %s\n", name, mode, "open of %s mode %s - %s\n", name, mode,
"open for write disallowed by -m\n"); "open for write disallowed by -m\n");
@@ -375,7 +376,6 @@ openfile(char *name)
cip->i_state = IS_READ; cip->i_state = IS_READ;
cip->i_char = '\0'; cip->i_char = '\0';
cip->i_str = NULL; cip->i_str = NULL;
cip->i_origstr = NULL;
cip->i_ttystr = NULL; cip->i_ttystr = NULL;
cip->i_fp = fp; cip->i_fp = fp;
cip->i_line = 1; 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. * String is copied into local memory so it can be trashed afterwards.
* Returns -1 if cannot open string. * Returns -1 if cannot open string.
* *
@@ -409,21 +409,22 @@ curstream(void)
* str string to be opened * str string to be opened
*/ */
int int
openstring(char *str) openstring(char *str, long num)
{ {
char *cp; /* copied string */ char *cp; /* copied string */
if ((depth >= MAXDEPTH) || (str == NULL)) if ((depth >= MAXDEPTH) || (str == NULL))
return -2; return -2;
cp = (char *)malloc(strlen(str) + 1); cp = (char *) malloc(num + 1);
if (cp == NULL) if (cp == NULL)
return -1; return -1;
strcpy(cp, str); strcpy(cp, str);
cip = inputs + depth++; cip = inputs + depth++;
cip->i_state = IS_READ; cip->i_state = IS_READ;
cip->i_char = '\0'; cip->i_char = '\0';
cip->i_cp = cp;
cip->i_str = cp; cip->i_str = cp;
cip->i_origstr = cp; cip->i_num = num;
cip->i_fp = NULL; cip->i_fp = NULL;
cip->i_name = NULL; cip->i_name = NULL;
cip->i_ttystr = NULL; cip->i_ttystr = NULL;
@@ -445,7 +446,6 @@ openterminal(void)
cip->i_state = IS_READ; cip->i_state = IS_READ;
cip->i_char = '\0'; cip->i_char = '\0';
cip->i_str = NULL; cip->i_str = NULL;
cip->i_origstr = NULL;
cip->i_ttystr = NULL; cip->i_ttystr = NULL;
cip->i_fp = NULL; cip->i_fp = NULL;
cip->i_name = NULL; cip->i_name = NULL;
@@ -462,8 +462,8 @@ closeinput(void)
{ {
if (depth <= 0) if (depth <= 0)
return; return;
if (cip->i_origstr) if (cip->i_str)
free(cip->i_origstr); free(cip->i_str);
if (cip->i_fp) if (cip->i_fp)
fclose(cip->i_fp); fclose(cip->i_fp);
if (cip->i_name) if (cip->i_name)
@@ -515,8 +515,11 @@ nextchar(void)
return ch; return ch;
} }
if (cip->i_str) { /* from string */ if (cip->i_str) { /* from string */
ch = chartoint(*cip->i_str++); if (cip->i_num) {
if (ch == '\0') ch = chartoint(*cip->i_cp++);
cip->i_num--;
}
else
ch = EOF; ch = EOF;
} else if (cip->i_fp) { /* from file */ } else if (cip->i_fp) { /* from file */
ch = fgetc(cip->i_fp); ch = fgetc(cip->i_fp);
@@ -525,10 +528,6 @@ nextchar(void)
} else { /* from terminal */ } else { /* from terminal */
ch = ttychar(); ch = ttychar();
} }
if (ch == EOF) { /* fix up end of file */
closeinput();
ch = EOF;
}
if (depth > 0) if (depth > 0)
cip->i_char = ch; /* save for rereads */ cip->i_char = ch; /* save for rereads */
if (ch == '\n') 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. * Return the name of the current input file.
* Returns NULL for terminal or strings. * Returns NULL for terminal or strings.
@@ -739,6 +748,7 @@ runrcfiles(void)
if (i < 0) if (i < 0)
continue; continue;
getcommands(FALSE); getcommands(FALSE);
closeinput();
} }
} }

View File

@@ -86,7 +86,7 @@
* i.e., any value that is 301 mod 420. * i.e., any value that is 301 mod 420.
* *
* Written by: Ernest W Bowen <ernie@neumann.une.edu.au> * Written by: Ernest W Bowen <ernie@neumann.une.edu.au>
* Interface by: Landon Curt Noll <chongo@toad.com> * 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 */ static defaultmlist = list(2,3,5,7,11,13,17,19); /* The first eight primes */

View File

@@ -19,7 +19,10 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
* *
* chongo was here /\../\ chongo@toad.com * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
*/ */
/* /*
* lucas - perform a Lucas primality test on h*2^n-1 * lucas - perform a Lucas primality test on h*2^n-1

View File

@@ -19,7 +19,10 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
* *
* chongo was here /\../\ chongo@toad.com * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
*/ */
/* /*
* primes of the form h*2^n-1 for 1<=h<200 and 1<=n<1000 * primes of the form h*2^n-1 for 1<=h<200 and 1<=n<1000

View File

@@ -19,7 +19,10 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
* *
* chongo was here /\../\ chongo@toad.com * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
*/ */
/* /*
* Lucasian criteria for primality * Lucasian criteria for primality

View File

@@ -19,7 +19,10 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
* *
* chongo was here /\../\ chongo@toad.com * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
*/ */

View File

@@ -7,7 +7,7 @@
* utc_hr_offset Offset from UTC in hours. * utc_hr_offset Offset from UTC in hours.
* *
* Written by: Klaus Alexander Seistrup <kseis@magnetic-ink.dk> * Written by: Klaus Alexander Seistrup <kseis@magnetic-ink.dk>
* With minor mods by: Landon Curt Noll <chongo@toad.com> * With minor mods by: Landon Curt Noll <http://reality.sgi.com/chongo>
* *
* See: * See:
* http://www.magnetic-ink.dk/download/qtime.html * http://www.magnetic-ink.dk/download/qtime.html

View File

@@ -21,7 +21,10 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
* *
* chongo was here /\../\ chongo@toad.com * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
*/ */
/* obtain our required libs */ /* obtain our required libs */

View File

@@ -7393,6 +7393,23 @@ print;
return test_somenew(); 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 * read various calc libs
* *

View File

@@ -19,7 +19,10 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
* *
* chongo was here /\../\ chongo@toad.com * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
*/ */
/* /*

View File

@@ -4,7 +4,9 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Landon Curt Noll * By: Landon Curt Noll
* chongo@toad.com -or- ...!{pyramid,sun,uunet}!hoptoad!chongo * http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
* *
* This library is used by the 1700 series of the regress.cal test suite. * This library is used by the 1700 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,9 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Landon Curt Noll * By: Landon Curt Noll
* chongo@toad.com -or- ...!{pyramid,sun,uunet}!hoptoad!chongo * http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
* *
* This library is used by the 2300 series of the regress.cal test suite. * This library is used by the 2300 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 2600 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 2700 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 3100 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 3300 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 3400 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 3500 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 4000 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 4100 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 4600 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 5100 series of the regress.cal test suite.
*/ */

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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. * This library is used by the 5200 series of the regress.cal test suite.
*/ */

View File

@@ -180,7 +180,7 @@ libcalc_call_me_first(void)
/* /*
* ready to rock & roll .. * ready to rock & roll ..
*/ */
run_state = RUN_PRE_BEGIN; run_state = RUN_BEGIN;
init_done = 1; init_done = 1;
return; return;
} }
@@ -247,6 +247,7 @@ reinitialize(void)
math_setfp(stdout); math_setfp(stdout);
resetscopes(); resetscopes();
resetinput(); resetinput();
inittokens();
(void) openterminal(); (void) openterminal();
} }

View File

@@ -28,11 +28,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */

View File

@@ -29,11 +29,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */

2
poly.c
View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact. * provided that this copyright notice remains intact.
* *
* By: Ernest Bowen and Landon Curt Noll * 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" #include "value.h"

View File

@@ -19,7 +19,10 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
* *
* chongo was here /\../\ * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
*/ */
/* /*
@@ -81,7 +84,7 @@ static QCKHASH blk_hash(BLOCK *blk, QCKHASH val);
* The basis of the hash algorithm was taken from an idea * The basis of the hash algorithm was taken from an idea
* sent by Email to the IEEE Posix P1003.2 mailing list from * 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). * 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. * algorithm to come up with Fowler/Noll/Vo hash.
* *
* The magic lies in the constant 16777619, which for 32 bit hashing * The magic lies in the constant 16777619, which for 32 bit hashing

View File

@@ -27,11 +27,9 @@
# Happy bit twiddling, # Happy bit twiddling,
# #
# Landon Curt Noll # Landon Curt Noll
# http://reality.sgi.com/chongo
# #
# chongo@toad.com # chongo <was here> /\../\
# ...!{pyramid,sun,uunet}!hoptoad!chongo
#
# chongo was here /\../\
############################################################################## ##############################################################################
#-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-# #-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-#

9
seed.c
View File

@@ -28,7 +28,10 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
* *
* chongo was here /\../\ {chongo,noll}@{toad,sgi}.com * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
* *
* Share and enjoy! :-) * Share and enjoy! :-)
*/ */
@@ -113,8 +116,8 @@ hash_buf(char *buf, unsigned len)
* *
* for information on 32bit and 64bit Fowler/Noll/Vo hashes. * for information on 32bit and 64bit Fowler/Noll/Vo hashes.
* *
* Landon Curt Noll (chongo@toad.com) later improved on their * Landon Curt Noll (http://reality.sgi.com/chongo) later improved
* algorithm to come up with Fowler/Noll/Vo hash. * on their algorithm to come up with Fowler/Noll/Vo hash.
* *
* The 32 hash was able to process 234936 words from the web2 dictionary * The 32 hash was able to process 234936 words from the web2 dictionary
* without any 32 bit collisions using a constant of * without any 32 bit collisions using a constant of

7
shs.c
View File

@@ -11,7 +11,10 @@
* *
* This file was Modified/Re-written by: * This file was Modified/Re-written by:
* *
* Landon Curt Noll (chongo@toad.com) chongo <was here> /\../\ * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
* *
* This code has been placed in the public domain. Please do not * This code has been placed in the public domain. Please do not
* copyright this code. * copyright this code.
@@ -26,7 +29,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* Based on Version 2.11 (09 Mar 1995) from Landon Curt Noll's * 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.
* *
**** ****
* *

5
shs.h
View File

@@ -11,7 +11,10 @@
* *
* This file was Modified by: * This file was Modified by:
* *
* Landon Curt Noll (chongo@toad.com) chongo <was here> /\../\ * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
* *
* This code has been placed in the public domain. Please do not * This code has been placed in the public domain. Please do not
* copyright this code. * copyright this code.

5
shs1.c
View File

@@ -5,7 +5,10 @@
* *
* This file was Modified/Re-written by: * This file was Modified/Re-written by:
* *
* Landon Curt Noll (chongo@toad.com) chongo <was here> /\../\ * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
* *
* This code has been placed in the public domain. Please do not * This code has been placed in the public domain. Please do not
* copyright this code. * copyright this code.

5
shs1.h
View File

@@ -5,7 +5,10 @@
* *
* This file was Modified by: * This file was Modified by:
* *
* Landon Curt Noll (chongo@toad.com) chongo <was here> /\../\ * Landon Curt Noll
* http://reality.sgi.com/chongo
*
* chongo <was here> /\../\
* *
* This code has been placed in the public domain. Please do not * This code has been placed in the public domain. Please do not
* copyright this code. * copyright this code.

View File

@@ -12,7 +12,7 @@
#define MAJOR_VER 2 /* major version */ #define MAJOR_VER 2 /* major version */
#define MINOR_VER 11 /* minor version */ #define MINOR_VER 11 /* minor version */
#define MAJOR_PATCH 0 /* patch level or 0 if no patch */ #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 * calc version constants

View File

@@ -29,11 +29,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */
/* /*

View File

@@ -29,11 +29,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */
/* /*
* random number generator - see zrand.c for details * random number generator - see zrand.c for details

View File

@@ -29,11 +29,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */
/* /*

View File

@@ -29,11 +29,9 @@
* Happy bit twiddling, * Happy bit twiddling,
* *
* Landon Curt Noll * Landon Curt Noll
* http://reality.sgi.com/chongo
* *
* chongo@toad.com * chongo <was here> /\../\
* ...!{pyramid,sun,uunet}!hoptoad!chongo
*
* chongo was here /\../\
*/ */
/* /*
* random number generator - see zrandom.c for details * random number generator - see zrandom.c for details