mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
5 Commits
2.11.0t8.9
...
2.11.0t9.1
Author | SHA1 | Date | |
---|---|---|---|
|
1b42111665 | ||
|
ea6b3904be | ||
|
f3fceff1b6 | ||
|
69d4a17187 | ||
|
a99a3400e7 |
211
BUGS
211
BUGS
@@ -68,178 +68,6 @@ importantly, fixes (in the form of a context diff patch) to:
|
|||||||
|
|
||||||
Known bugs:
|
Known bugs:
|
||||||
|
|
||||||
* When compiled on some Big Endian machines with BASEB forced to
|
|
||||||
be 16 (by setting LONGLONG_BITS= 0 in the Makefile), calc fails
|
|
||||||
a number of regression tests:
|
|
||||||
|
|
||||||
4230: n = ftell(f)
|
|
||||||
4231: isnull(fputs(f,L,"\n",C,"\n",N,"\n"))
|
|
||||||
4232: fseek(f, n)
|
|
||||||
**** Non-true result (0): 4233: fgetstr(f) == LCN
|
|
||||||
4234: isnull(fclose(f))
|
|
||||||
4235: a = exp(27, 1e-1000)
|
|
||||||
4236: b = sqrt(7 + 5i, 1e-2000)
|
|
||||||
4252: fscanf(f, "%*[^|]%*c%n%*[^[]%*c%n", m, n) == 2
|
|
||||||
4253: fseek(f, m)
|
|
||||||
4254: fscanf(f, "%3c", x) == 1
|
|
||||||
**** Non-true result (0): 4255: x == " Cu"
|
|
||||||
4256: fseek(f, n)
|
|
||||||
4257: fscanf(f, "%s", y) == 1
|
|
||||||
**** Non-true result (0): 4258: y == "Noll"
|
|
||||||
4259: isnull(fclose(f))
|
|
||||||
4260: x = rm("junk4200")
|
|
||||||
4261: Ending test_fileops
|
|
||||||
4600: Beginning test_fileop
|
|
||||||
4601: ttest(0,0): passed
|
|
||||||
4602: stest(): failed
|
|
||||||
**** search(f, "and") != 10 failed
|
|
||||||
4603: ttest(1,1): failed
|
|
||||||
**** Failure 2 for i = 0
|
|
||||||
4604: stest(): failed
|
|
||||||
**** search(f, "and") != 10 failed
|
|
||||||
4605: ttest(2,2): failed
|
|
||||||
**** Failure 2 for i = 0
|
|
||||||
4606: stest(): failed
|
|
||||||
**** search(f, "and") != 10 failed
|
|
||||||
4607: ttest(3,3): failed
|
|
||||||
**** Failure 2 for i = 0
|
|
||||||
4608: stest(): failed
|
|
||||||
**** search(f, "and") != 10 failed
|
|
||||||
4609: ttest(4,4): failed
|
|
||||||
**** Failure 2 for i = 0
|
|
||||||
4610: stest(): failed
|
|
||||||
**** search(f, "and") != 10 failed
|
|
||||||
4611: ttest(5,5): failed
|
|
||||||
**** Failure 2 for i = 0
|
|
||||||
4612: stest(): failed
|
|
||||||
**** search(f, "and") != 10 failed
|
|
||||||
4613: ttest(6,6): failed
|
|
||||||
**** Failure 2 for i = 0
|
|
||||||
4614: stest(): failed
|
|
||||||
**** search(f, "and") != 10 failed
|
|
||||||
4615: ttest(7,7): failed
|
|
||||||
**** Failure 2 for i = 0
|
|
||||||
4616: stest(): failed
|
|
||||||
**** search(f, "and") != 10 failed
|
|
||||||
4617: ttest(8,8): failed
|
|
||||||
**** Failure 2 for i = 0
|
|
||||||
4618: stest(): failed
|
|
||||||
**** search(f, "and") != 10 failed
|
|
||||||
4619: ttest(9,9): failed
|
|
||||||
**** Failure 1 for file size
|
|
||||||
4620: stest(): failed
|
|
||||||
**** fopen("junk4600", "w") failed
|
|
||||||
4621: Ending test_fileop
|
|
||||||
|
|
||||||
4700: Beginning test_charset
|
|
||||||
**** errcount:172 > ecnt:150
|
|
||||||
4701: "\a" == char(7)
|
|
||||||
4702: "\v" == char(11)
|
|
||||||
4703: "\e" == char(27)
|
|
||||||
5000: Beginning test_filesearch
|
|
||||||
5001: x = rm("-f", "junk5000")
|
|
||||||
5002: f = fopen("junk5000", "w")
|
|
||||||
**** Unable to open "junk5000" for writing
|
|
||||||
|
|
||||||
5100: Beginning test_newdecl
|
|
||||||
5101: test5100(1)
|
|
||||||
**** errcount:173 > ecnt:172
|
|
||||||
5102: a5100 == 0
|
|
||||||
5103: b5100 == 2
|
|
||||||
5104: test5100(1)
|
|
||||||
5927: test unused
|
|
||||||
5928: test unused
|
|
||||||
5929: test unused
|
|
||||||
**** errcount:180 > ecnt:177
|
|
||||||
5930: isassoc(loc) == 0
|
|
||||||
5931: isassoc(a) == 1
|
|
||||||
5932: isassoc(ofd) == 0
|
|
||||||
6079: test unused
|
|
||||||
6080: iserror(loc) == 0
|
|
||||||
6081: iserror(a) == 0
|
|
||||||
**** Non-true result (0): 6082: iserror(ofd) == 0
|
|
||||||
**** Non-true result (0): 6083: iserror(cfd) == 0
|
|
||||||
6084: iserror(blk) == 0
|
|
||||||
6085: iserror(nblk) == 0
|
|
||||||
6086: iserror(cfg) == 0
|
|
||||||
6139: test unused
|
|
||||||
6140: isfile(loc) == 0
|
|
||||||
6141: isfile(a) == 0
|
|
||||||
**** Non-true result (0): 6142: isfile(ofd) == 1
|
|
||||||
**** Non-true result (0): 6143: isfile(cfd) == 1
|
|
||||||
6144: isfile(blk) == 0
|
|
||||||
6145: isfile(nblk) == 0
|
|
||||||
6146: isfile(cfg) == 0
|
|
||||||
|
|
||||||
6700: Beginning test_blk
|
|
||||||
6701: A = blk(20);
|
|
||||||
**** errcount:181 > ecnt:180
|
|
||||||
6702: size(A) == 20
|
|
||||||
6703: sizeof(A) == 256
|
|
||||||
6704: B = A;
|
|
||||||
6822: C == A
|
|
||||||
6823: fs = fopen("junk6800", "w+");
|
|
||||||
6824: blkcpy(fs, A);
|
|
||||||
**** errcount:183 > ecnt:181
|
|
||||||
**** Non-true result (0): 6825: size(f) == 5
|
|
||||||
6826: blkcpy(B = blk(), fs);
|
|
||||||
**** errcount:184 > ecnt:183
|
|
||||||
**** Non-true result (0): 6827: B == A
|
|
||||||
6828: blkcpy(fs, A, ,100);
|
|
||||||
**** errcount:185 > ecnt:184
|
|
||||||
**** Non-true result (0): 6829: size(f) == 105
|
|
||||||
6830: blkcpy(C = blk(), fs, 2, ,100)
|
|
||||||
**** errcount:186 > ecnt:185
|
|
||||||
**** Non-true result (0): 6831: C == (blk() = {1,2}
|
|
||||||
6832: A = blk();
|
|
||||||
6833: blkcpy(A, "blk6800");
|
|
||||||
6834: size(A) == 9
|
|
||||||
6900: Beginning test_name
|
|
||||||
6901: x = rm("-f", "junk6900")
|
|
||||||
6902: f = fopen("junk6900", "w")
|
|
||||||
**** errcount:189 > ecnt:186
|
|
||||||
**** Non-true result (0): 6903: name(f) == "junk6900"
|
|
||||||
6904: fclose(f)
|
|
||||||
**** errcount:190 > ecnt:189
|
|
||||||
6905: name(f) == null()
|
|
||||||
6906: A = blk("blk6900")
|
|
||||||
6907: name(A) == "blk6900"
|
|
||||||
7002: B = blk();
|
|
||||||
7003: copy("abc yz", A);
|
|
||||||
7004: copy("defg", B);
|
|
||||||
**** errcount:191 > ecnt:190
|
|
||||||
7005: strprintf("%s", A) == "abc yz"
|
|
||||||
7006: strprintf("%s", A[2]) == "c yz"
|
|
||||||
7007: strprintf("%s", A[7]) == ""
|
|
||||||
|
|
||||||
9995: freeredc()
|
|
||||||
9996: freestatics()
|
|
||||||
**** 24 error(s) found \/++\/
|
|
||||||
|
|
||||||
We are sure some more 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.
|
|
||||||
|
|
||||||
=-=
|
|
||||||
|
|
||||||
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
|
* Calc does not support the #! exec method. For example of the
|
||||||
following is placed in an executable file (assume the path to
|
following is placed in an executable file (assume the path to
|
||||||
calc is correct) called /tmp/xyzzy:
|
calc is correct) called /tmp/xyzzy:
|
||||||
@@ -253,3 +81,42 @@ Calc Mis-features:
|
|||||||
Will result in '"tmp" is undefined' and '"xyzzy" is undefined'
|
Will result in '"tmp" is undefined' and '"xyzzy" is undefined'
|
||||||
error messages because calc considers $0 as an expression to
|
error messages because calc considers $0 as an expression to
|
||||||
evaluate.
|
evaluate.
|
||||||
|
|
||||||
|
* The following file:
|
||||||
|
|
||||||
|
/* this is bugdemo.cal */
|
||||||
|
x = eval(prompt(">>> "));
|
||||||
|
print x;
|
||||||
|
|
||||||
|
when executed as:
|
||||||
|
|
||||||
|
calc read bugdemo.cal
|
||||||
|
|
||||||
|
will obtain a prompt from the terminal, print the value but leave
|
||||||
|
the terminal in a 'bad' state, as if stty -icanon -echo -echoe
|
||||||
|
had been executed.
|
||||||
|
|
||||||
|
* Dec Alpha Linux compiling with gcc-2.95.1 and -O2 fails the
|
||||||
|
regression test with:
|
||||||
|
|
||||||
|
make -s check
|
||||||
|
000: Beginning regression tests
|
||||||
|
001: Some of these tests may take a while ...
|
||||||
|
002: Within each section, output should be numbered sequentially
|
||||||
|
003: parsed global definitions
|
||||||
|
004: parsed vrfy()
|
||||||
|
005: parsed prob(str)
|
||||||
|
006: parsed getglobalvar()
|
||||||
|
007: parsed test_booleans()
|
||||||
|
008: parsed test_variables()
|
||||||
|
make: *** [check] Segmentation fault (core dumped)
|
||||||
|
|
||||||
|
Other programs have reported problems when compiling -O2 with
|
||||||
|
gcc-2.95.1 on the Alpha and Mips.
|
||||||
|
|
||||||
|
One work-a-round is to not compile with -O2 (perhaps just -O).
|
||||||
|
Another work-a-round is not use gcc-2.95.1.
|
||||||
|
|
||||||
|
We are sure some more 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.
|
||||||
|
69
CHANGES
69
CHANGES
@@ -1,4 +1,71 @@
|
|||||||
Following is the change from calc version 2.11.0t8 to date:
|
Following is the change from calc version 2.11.0t8.9.1 to date:
|
||||||
|
|
||||||
|
The config("verbose_quit") will control the printing of the message:
|
||||||
|
|
||||||
|
Quit or abort executed
|
||||||
|
|
||||||
|
when a non-interactive ABORT, QUIT or EXIT is encounted. By default,
|
||||||
|
config("verbose_quit") is TRUE and the message is printed. If one does:
|
||||||
|
|
||||||
|
config("verbose_quit", 0)
|
||||||
|
|
||||||
|
the message is disabled.
|
||||||
|
|
||||||
|
Added 8400 regression test set and test8400.cal to test the new
|
||||||
|
quit and config("verbose_quit") functionality.
|
||||||
|
|
||||||
|
Fixed the BigEndian BASEB==16 regression bugs by correctly swapping
|
||||||
|
16 bit HALFs in a 64 bit value (such as a 64 bit file pointer).
|
||||||
|
|
||||||
|
Added calclevel() builtin to calculation level at which it is called.
|
||||||
|
|
||||||
|
Added help/calclevel and help/inputlevel help files.
|
||||||
|
|
||||||
|
Removed regression tests 951 and 5984 so that the regress test will
|
||||||
|
run in non-interactively / without a TTY such as under Debian's
|
||||||
|
build daemon.
|
||||||
|
|
||||||
|
The eval(str) builtin will return an error-value rather than cause
|
||||||
|
an execution error str has a scan-error.
|
||||||
|
|
||||||
|
Declaration are permitted to end with EOF as well as a newline or ';'.
|
||||||
|
|
||||||
|
When prompt() occurs in reading a file, it will take inout from
|
||||||
|
the terminal rather than taking it from a file. For example,
|
||||||
|
this script, when read, now works:
|
||||||
|
|
||||||
|
/* This demonstrates the use of prompt() and some other things */
|
||||||
|
config("verbose_quit", 0);
|
||||||
|
define getnumber() {
|
||||||
|
local x;
|
||||||
|
for (;;) {
|
||||||
|
x = eval(prompt(">>> "));
|
||||||
|
if (isnum(x))
|
||||||
|
return x;
|
||||||
|
print "Not a number! Try again";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print "This will display the sqrt of each number you enter";
|
||||||
|
print "Enter quit to stop";
|
||||||
|
for (;;) {
|
||||||
|
print sqrt(getnumber());
|
||||||
|
}
|
||||||
|
print "Good bye";
|
||||||
|
|
||||||
|
Comments entered at inputisterminal level may be spread over several
|
||||||
|
lines. For example:
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These commands work given the file: comment.cal
|
||||||
|
*
|
||||||
|
* cat comment.cal | calc
|
||||||
|
* calc < comment.cal
|
||||||
|
*/
|
||||||
|
print "Hello";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Following is the change from calc version 2.11.0t8 to 2.11.0t8.9:
|
||||||
|
|
||||||
Moved 'wishlist' enhancements from the help/todo file to a new
|
Moved 'wishlist' enhancements from the help/todo file to a new
|
||||||
help/wishlist file. Ordered, by priority, help/todo items into
|
help/wishlist file. Ordered, by priority, help/todo items into
|
||||||
|
1
calc.h
1
calc.h
@@ -123,6 +123,7 @@ 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 int inputlevel(void);
|
||||||
|
extern long calclevel(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);
|
||||||
|
@@ -409,6 +409,7 @@ getdeclarations(int symtype)
|
|||||||
case T_NEWLINE:
|
case T_NEWLINE:
|
||||||
case T_SEMICOLON:
|
case T_SEMICOLON:
|
||||||
case T_RIGHTBRACE:
|
case T_RIGHTBRACE:
|
||||||
|
case T_EOF:
|
||||||
rescantoken();
|
rescantoken();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
29
config.c
29
config.c
@@ -55,6 +55,7 @@ NAMETYPE configs[] = {
|
|||||||
{"lib_debug", CONFIG_LIB_DEBUG},
|
{"lib_debug", CONFIG_LIB_DEBUG},
|
||||||
{"calc_debug", CONFIG_CALC_DEBUG},
|
{"calc_debug", CONFIG_CALC_DEBUG},
|
||||||
{"user_debug", CONFIG_USER_DEBUG},
|
{"user_debug", CONFIG_USER_DEBUG},
|
||||||
|
{"verbose_quit",CONFIG_VERBOSE_QUIT},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -95,7 +96,8 @@ CONFIG oldstd = { /* backward compatible standard configuration */
|
|||||||
BLK_FMT_HD_STYLE, /* block output format */
|
BLK_FMT_HD_STYLE, /* block output format */
|
||||||
3, /* calc library debug level */
|
3, /* calc library debug level */
|
||||||
0, /* internal calc debug level */
|
0, /* internal calc debug level */
|
||||||
0 /* user defined debug level */
|
0, /* user defined debug level */
|
||||||
|
TRUE /* print Quit or abort executed messages */
|
||||||
};
|
};
|
||||||
CONFIG newstd = { /* new non-backward compatible configuration */
|
CONFIG newstd = { /* new non-backward compatible configuration */
|
||||||
MODE_INITIAL, /* current output mode */
|
MODE_INITIAL, /* current output mode */
|
||||||
@@ -130,7 +132,8 @@ CONFIG newstd = { /* new non-backward compatible configuration */
|
|||||||
BLK_FMT_HD_STYLE, /* block output format */
|
BLK_FMT_HD_STYLE, /* block output format */
|
||||||
3, /* calc library debug level */
|
3, /* calc library debug level */
|
||||||
0, /* internal calc debug level */
|
0, /* internal calc debug level */
|
||||||
0 /* user defined debug level */
|
0, /* user defined debug level */
|
||||||
|
TRUE /* print Quit or abort executed messages */
|
||||||
};
|
};
|
||||||
CONFIG *conf = NULL; /* loaded in at startup - current configuration */
|
CONFIG *conf = NULL; /* loaded in at startup - current configuration */
|
||||||
|
|
||||||
@@ -848,6 +851,21 @@ setconfig(int type, VALUE *vp)
|
|||||||
conf->user_debug = temp;
|
conf->user_debug = temp;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CONFIG_VERBOSE_QUIT:
|
||||||
|
if (vp->v_type == V_NUM) {
|
||||||
|
q = vp->v_num;
|
||||||
|
conf->verbose_quit = !qiszero(q);
|
||||||
|
} else if (vp->v_type == V_STR) {
|
||||||
|
temp = truthtype(vp->v_str->s_str);
|
||||||
|
if (temp < 0) {
|
||||||
|
math_error("Illegal truth value"
|
||||||
|
"for verbose_quit");
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
conf->verbose_quit = (int)temp;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
math_error("Setting illegal config parameter");
|
math_error("Setting illegal config parameter");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
@@ -1119,6 +1137,10 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
|||||||
i = cfg->user_debug;
|
i = cfg->user_debug;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CONFIG_VERBOSE_QUIT:
|
||||||
|
i = cfg->verbose_quit;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
math_error("Getting illegal CONFIG element");
|
math_error("Getting illegal CONFIG element");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
@@ -1194,5 +1216,6 @@ config_cmp(CONFIG *cfg1, CONFIG *cfg2)
|
|||||||
cfg1->blkfmt != cfg2->blkfmt ||
|
cfg1->blkfmt != cfg2->blkfmt ||
|
||||||
cfg1->lib_debug != cfg2->lib_debug ||
|
cfg1->lib_debug != cfg2->lib_debug ||
|
||||||
cfg1->calc_debug != cfg2->calc_debug ||
|
cfg1->calc_debug != cfg2->calc_debug ||
|
||||||
cfg1->user_debug != cfg2->user_debug;
|
cfg1->user_debug != cfg2->user_debug ||
|
||||||
|
cfg1->verbose_quit != cfg2->verbose_quit;
|
||||||
}
|
}
|
||||||
|
12
config.h
12
config.h
@@ -80,6 +80,7 @@
|
|||||||
#define CONFIG_LIB_DEBUG 30
|
#define CONFIG_LIB_DEBUG 30
|
||||||
#define CONFIG_CALC_DEBUG 31
|
#define CONFIG_CALC_DEBUG 31
|
||||||
#define CONFIG_USER_DEBUG 32
|
#define CONFIG_USER_DEBUG 32
|
||||||
|
#define CONFIG_VERBOSE_QUIT 33
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -114,8 +115,8 @@ struct config {
|
|||||||
LEN sq2; /* size of number to use square algorithm 2 */
|
LEN sq2; /* size of number to use square algorithm 2 */
|
||||||
LEN pow2; /* size of modulus to use REDC for powers */
|
LEN pow2; /* size of modulus to use REDC for powers */
|
||||||
LEN redc2; /* size of modulus to use REDC algorithm 2 */
|
LEN redc2; /* size of modulus to use REDC algorithm 2 */
|
||||||
int tilde_ok; /* ok to print a tilde on aproximations */
|
BOOL tilde_ok; /* ok to print a tilde on aproximations */
|
||||||
int tab_ok; /* ok to print tab before numeric values */
|
BOOL tab_ok; /* ok to print tab before numeric values */
|
||||||
long quomod; /* quomod() default rounding mode */
|
long quomod; /* quomod() default rounding mode */
|
||||||
long quo; /* quotent // default rounding mode */
|
long quo; /* quotent // default rounding mode */
|
||||||
long mod; /* mod % default rounding mode */
|
long mod; /* mod % default rounding mode */
|
||||||
@@ -125,18 +126,19 @@ struct config {
|
|||||||
long cfsim; /* cfsim() default rounding mode */
|
long cfsim; /* cfsim() default rounding mode */
|
||||||
long outround; /* output default rounding mode */
|
long outround; /* output default rounding mode */
|
||||||
long round; /* round()/bround() default rounding mode */
|
long round; /* round()/bround() default rounding mode */
|
||||||
int leadzero; /* ok to print leading 0 before decimal pt */
|
BOOL leadzero; /* ok to print leading 0 before decimal pt */
|
||||||
int fullzero; /* ok to print trailing 0's */
|
BOOL fullzero; /* ok to print trailing 0's */
|
||||||
long maxscancount; /* max scan errors before abort */
|
long maxscancount; /* max scan errors before abort */
|
||||||
char *prompt1; /* normal prompt */
|
char *prompt1; /* normal prompt */
|
||||||
char *prompt2; /* prompt when inside multi-line input */
|
char *prompt2; /* prompt when inside multi-line input */
|
||||||
int blkmaxprint; /* octets of a block to print, 0 => all */
|
int blkmaxprint; /* octets of a block to print, 0 => all */
|
||||||
int blkverbose; /* TRUE => print all lines if a block */
|
BOOL blkverbose; /* TRUE => print all lines if a block */
|
||||||
int blkbase; /* block output base */
|
int blkbase; /* block output base */
|
||||||
int blkfmt; /* block output style */
|
int blkfmt; /* block output style */
|
||||||
int lib_debug; /* library debug, see LIB_DEBUG_XXX below */
|
int lib_debug; /* library debug, see LIB_DEBUG_XXX below */
|
||||||
int calc_debug; /* internal debug, see CALC_DEBUG_XXX below */
|
int calc_debug; /* internal debug, see CALC_DEBUG_XXX below */
|
||||||
int user_debug; /* user defined debug value: 0 default */
|
int user_debug; /* user defined debug value: 0 default */
|
||||||
|
BOOL verbose_quit; /* TRUE => print Quit or abort executed msg */
|
||||||
};
|
};
|
||||||
typedef struct config CONFIG;
|
typedef struct config CONFIG;
|
||||||
|
|
||||||
|
26
func.c
26
func.c
@@ -155,6 +155,7 @@ f_eval(VALUE *vp)
|
|||||||
VALUE result;
|
VALUE result;
|
||||||
char *str;
|
char *str;
|
||||||
long num;
|
long num;
|
||||||
|
int temp;
|
||||||
|
|
||||||
if (vp->v_type != V_STR)
|
if (vp->v_type != V_STR)
|
||||||
return error_value(E_EVAL2);
|
return error_value(E_EVAL2);
|
||||||
@@ -168,7 +169,10 @@ f_eval(VALUE *vp)
|
|||||||
}
|
}
|
||||||
oldfunc = curfunc;
|
oldfunc = curfunc;
|
||||||
enterfilescope();
|
enterfilescope();
|
||||||
|
temp = stoponerror;
|
||||||
|
stoponerror = -1;
|
||||||
if (evaluate(TRUE)) {
|
if (evaluate(TRUE)) {
|
||||||
|
stoponerror = temp;
|
||||||
closeinput();
|
closeinput();
|
||||||
exitfilescope();
|
exitfilescope();
|
||||||
freevalue(stack--);
|
freevalue(stack--);
|
||||||
@@ -181,6 +185,7 @@ f_eval(VALUE *vp)
|
|||||||
free(newfunc);
|
free(newfunc);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
stoponerror = temp;
|
||||||
closeinput();
|
closeinput();
|
||||||
exitfilescope();
|
exitfilescope();
|
||||||
newfunc = curfunc;
|
newfunc = curfunc;
|
||||||
@@ -203,11 +208,11 @@ f_prompt(VALUE *vp)
|
|||||||
unsigned int len;
|
unsigned int len;
|
||||||
|
|
||||||
result.v_type = V_STR;
|
result.v_type = V_STR;
|
||||||
if (inputisterminal()) {
|
openterminal();
|
||||||
printvalue(vp, PRINT_SHORT);
|
printvalue(vp, PRINT_SHORT);
|
||||||
math_flush();
|
math_flush();
|
||||||
}
|
|
||||||
cp = nextline();
|
cp = nextline();
|
||||||
|
closeinput();
|
||||||
if (cp == NULL) {
|
if (cp == NULL) {
|
||||||
math_error("End of file while prompting");
|
math_error("End of file while prompting");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
@@ -5893,6 +5898,17 @@ f_inputlevel (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
f_calclevel (void)
|
||||||
|
{
|
||||||
|
VALUE result;
|
||||||
|
|
||||||
|
result.v_type = V_NUM;
|
||||||
|
result.v_num = itoq(calclevel());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
f_access(int count, VALUE **vals)
|
f_access(int count, VALUE **vals)
|
||||||
{
|
{
|
||||||
@@ -6818,6 +6834,8 @@ static CONST struct builtin builtins[] = {
|
|||||||
"round value a to b number of binary places"},
|
"round value a to b number of binary places"},
|
||||||
{"btrunc", 1, 2, 0, OP_NOP, f_btrunc, 0,
|
{"btrunc", 1, 2, 0, OP_NOP, f_btrunc, 0,
|
||||||
"truncate a to b number of binary places"},
|
"truncate a to b number of binary places"},
|
||||||
|
{"calclevel", 0, 0, 0, OP_NOP, 0, f_calclevel,
|
||||||
|
"current calculation level"},
|
||||||
{"ceil", 1, 1, 0, OP_NOP, 0, f_ceil,
|
{"ceil", 1, 1, 0, OP_NOP, 0, f_ceil,
|
||||||
"smallest integer greater than or equal to number"},
|
"smallest integer greater than or equal to number"},
|
||||||
{"cfappr", 1, 3, 0, OP_NOP, f_cfappr, 0,
|
{"cfappr", 1, 3, 0, OP_NOP, f_cfappr, 0,
|
||||||
|
@@ -105,29 +105,30 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
|
|||||||
# This list is prodiced by the detaillist rule when no WARNINGS are detected.
|
# This list is prodiced by the detaillist rule when no WARNINGS are detected.
|
||||||
#
|
#
|
||||||
DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd append \
|
DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd append \
|
||||||
appr arg arrow asec asech asin asinh assign atan atan2 atanh avg base \
|
appr arg arrow asec asech asin asinh assign atan atan2 atanh avg \
|
||||||
bit blk blkcpy blkfree blocks bround btrunc ceil cfappr cfsim char \
|
base bit blk blkcpy blkfree blocks bround btrunc calclevel ceil \
|
||||||
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime delete \
|
cfappr cfsim char cmdbuf cmp comb conj cos cosh cot coth count cp \
|
||||||
den dereference det digit digits dp epsilon errcount errmax errno \
|
csc csch ctime delete den dereference det digit digits dp epsilon \
|
||||||
error eval exp fact factor fclose fcnt feof ferror fflush fgetc \
|
errcount errmax errno error eval exp fact factor fclose fcnt feof \
|
||||||
fgetfield fgetline fgets fgetstr fib files floor fopen forall fprintf \
|
ferror fflush fgetc fgetfield fgetline fgets fgetstr fib files \
|
||||||
fputc fputs fputstr frac free freeglobals freeredc freestatics frem \
|
floor fopen forall fprintf fputc fputs fputstr frac free freeglobals \
|
||||||
freopen fscan fscanf fseek fsize ftell gcd gcdrem gd getenv hash head \
|
freeredc freestatics frem freopen fscan fscanf fseek fsize ftell gcd \
|
||||||
highbit hmean hnrmod hypot ilog ilog10 ilog2 im insert int inverse \
|
gcdrem gd getenv hash head highbit hmean hnrmod hypot ilog ilog10 \
|
||||||
iroot isassoc isatty isblk isconfig isdefined iserror iseven isfile \
|
ilog2 im inputlevel insert int inverse iroot isassoc isatty isblk \
|
||||||
ishash isident isint islist ismat ismult isnull isnum isobj isobjtype \
|
isconfig isdefined iserror iseven isfile ishash isident isint islist \
|
||||||
isodd isprime isptr isqrt isrand israndom isreal isrel issimple issq \
|
ismat ismult isnull isnum isobj isobjtype isodd isprime isptr isqrt \
|
||||||
isstr istype jacobi join lcm lcmfact lfactor ln lowbit ltol makelist \
|
isrand israndom isreal isrel issimple issq isstr istype jacobi join \
|
||||||
matdim matfill matmax matmin matsum mattrace mattrans max md5 memsize \
|
lcm lcmfact lfactor ln lowbit ltol makelist matdim matfill matmax \
|
||||||
meq min minv mmin mne mod modify name near newerror nextcand \
|
matmin matsum mattrace mattrans max md5 memsize meq min minv mmin \
|
||||||
nextprime norm null num oldvalue ord param perm pfact pi pix places \
|
mne mod modify name near newerror nextcand nextprime norm null \
|
||||||
pmod polar poly pop popcnt power prevcand prevprime printf prompt \
|
num oldvalue ord param perm pfact pi pix places pmod polar poly \
|
||||||
protect ptest push putenv quo quomod rand randbit random randombit \
|
pop popcnt power prevcand prevprime printf prompt protect ptest \
|
||||||
randperm rcin rcmul rcout rcpow rcsq re remove reverse rewind rm root \
|
push putenv quo quomod rand randbit random randombit randperm rcin \
|
||||||
round rsearch runtime saveval scale scan scanf search sec sech seed \
|
rcmul rcout rcpow rcsq re remove reverse rewind rm root round rsearch \
|
||||||
segment select sgn sha sha1 sin sinh size sizeof sort sqrt srand \
|
runtime saveval scale scan scanf search sec sech seed segment select \
|
||||||
srandom ssq str strcat strerror strlen strpos strprintf strscan \
|
sgn sha sha1 sin sinh size sizeof sort sqrt srand srandom ssq str \
|
||||||
strscanf substr sum swap system tail tan tanh test time trunc xor
|
strcat strerror strlen strpos strprintf strscan strscanf substr \
|
||||||
|
sum swap system tail tan tanh test time trunc xor
|
||||||
|
|
||||||
# This list is of files that are clones of DETAIL_HELP files. They are
|
# This list is of files that are clones of DETAIL_HELP files. They are
|
||||||
# built from DETAIL_HELP files.
|
# built from DETAIL_HELP files.
|
||||||
@@ -416,8 +417,8 @@ bsdi: all
|
|||||||
detaillist:
|
detaillist:
|
||||||
${Q}-(echo "xxxxx"; \
|
${Q}-(echo "xxxxx"; \
|
||||||
for i in ${DETAIL_HELP}; do \
|
for i in ${DETAIL_HELP}; do \
|
||||||
if [ ! -f SCCS/s.$$i ]; then \
|
if [ ! -f RCS/$$i,v ]; then \
|
||||||
echo "WARNING: $$i not under SCCS control" 1>&2; \
|
echo "WARNING: $$i not under RCS control" 1>&2; \
|
||||||
else \
|
else \
|
||||||
echo $$i; \
|
echo $$i; \
|
||||||
fi; \
|
fi; \
|
||||||
|
35
help/calclevel
Normal file
35
help/calclevel
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
NAME
|
||||||
|
calclevel - current calculation level
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
calclevel()
|
||||||
|
|
||||||
|
TYPES
|
||||||
|
return nonnegative integer
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
This function returns the calculation level at which it is called.
|
||||||
|
When a command is being read from a terminal or from a file,
|
||||||
|
calc is at calculation level zero. The level is increased
|
||||||
|
by 1 each time calculation starts of a user-defined function
|
||||||
|
or of eval(S) for some expression S which evaluates to a string. It
|
||||||
|
decreases to zero if an error occurs or a quit or abort statement
|
||||||
|
is executed. Otherwise, it decreases by 1 when the calculation
|
||||||
|
is completed. Except when an error occurs or abort is executed,
|
||||||
|
the input level is not affected by changes in the calculation level.
|
||||||
|
|
||||||
|
Zero calculation level is also called top calculation level; greater
|
||||||
|
values of calclevel() indicate calculation is occurring at greater
|
||||||
|
depths.
|
||||||
|
|
||||||
|
EXAMPLE
|
||||||
|
n/a
|
||||||
|
|
||||||
|
LIMITS
|
||||||
|
none
|
||||||
|
|
||||||
|
LIBRARY
|
||||||
|
none
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
eval, read, quit, abort, inputlevel
|
@@ -43,6 +43,7 @@ Configuration parameters
|
|||||||
"lib_debug" controls library script debug information
|
"lib_debug" controls library script debug information
|
||||||
"calc_debug" controls internal calc debug information
|
"calc_debug" controls internal calc debug information
|
||||||
"user_debug" for user defined debug information
|
"user_debug" for user defined debug information
|
||||||
|
"verbose_quit" TRUE=>print message on empty quit or abort
|
||||||
|
|
||||||
|
|
||||||
The "all" config value allows one to save/restore the configuration
|
The "all" config value allows one to save/restore the configuration
|
||||||
@@ -375,6 +376,14 @@ Configuration parameters
|
|||||||
slower operation or more memory usage, and a particular value (like
|
slower operation or more memory usage, and a particular value (like
|
||||||
-1 or 0) corresponding to "no tests".
|
-1 or 0) corresponding to "no tests".
|
||||||
|
|
||||||
|
The "verbose_quit" controls the print of the message:
|
||||||
|
|
||||||
|
Quit or abort executed
|
||||||
|
|
||||||
|
when a non-interactive quit or abort without an argument is encounted.
|
||||||
|
A quit of abort without an argument does not display a message when
|
||||||
|
invoked at the interactive level.
|
||||||
|
|
||||||
The following are synonyms for true:
|
The following are synonyms for true:
|
||||||
|
|
||||||
"on" "yes" "y" "true" "t" "1" any non-zero number
|
"on" "yes" "y" "true" "t" "1" any non-zero number
|
||||||
|
36
help/inputlevel
Normal file
36
help/inputlevel
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
NAME
|
||||||
|
inputlevel - current input level
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
inputlevel()
|
||||||
|
|
||||||
|
TYPES
|
||||||
|
return nonnegative integer
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
This function returns the input level at which it is called.
|
||||||
|
When calc starts, it is at level zero. The level is increased
|
||||||
|
by 1 each time execution starts of a read file command or a call to
|
||||||
|
eval(S) for some expression S which evaluates to a string. It
|
||||||
|
decreases by 1 when a file being read reaches EOF or a string
|
||||||
|
being eval-ed reaches '\0', or earlier if a quit statement is
|
||||||
|
encountered at top calculation-level in the flle or string. It
|
||||||
|
decreases to zero if an abort statement is encountered at any
|
||||||
|
function-level in the file or string. If a quit or abort
|
||||||
|
statement is encountered at top calculation-level at top input-level,
|
||||||
|
calc is exited.
|
||||||
|
|
||||||
|
Zero input level is also called top input level; greater values
|
||||||
|
of inputlevel() indicate reading at greater depths.
|
||||||
|
|
||||||
|
EXAMPLE
|
||||||
|
n/a
|
||||||
|
|
||||||
|
LIMITS
|
||||||
|
none
|
||||||
|
|
||||||
|
LIBRARY
|
||||||
|
none
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
read, eval, quit, abort, calclevel
|
@@ -13,8 +13,6 @@ Calc Todo Items:
|
|||||||
|
|
||||||
Very High priority items:
|
Very High priority items:
|
||||||
|
|
||||||
* Write the help file for the inputlevel() builtin function.
|
|
||||||
|
|
||||||
* Write the help file for the display() builtin function.
|
* Write the help file for the display() builtin function.
|
||||||
|
|
||||||
* Write the help file for the stoponerror() builtin function.
|
* Write the help file for the stoponerror() builtin function.
|
||||||
|
@@ -44,7 +44,7 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
|
|||||||
test2700.cal test3100.cal test3300.cal test3400.cal prompt.cal \
|
test2700.cal test3100.cal test3300.cal test3400.cal prompt.cal \
|
||||||
test3500.cal seedrandom.cal test4000.cal test4100.cal test4600.cal \
|
test3500.cal seedrandom.cal test4000.cal test4100.cal test4600.cal \
|
||||||
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
|
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
|
||||||
randomrun.cal xx_print.cal natnumset.cal qtime.cal
|
randomrun.cal xx_print.cal natnumset.cal qtime.cal test8400.cal
|
||||||
|
|
||||||
# These files are found (but not built) in the distribution
|
# These files are found (but not built) in the distribution
|
||||||
#
|
#
|
||||||
|
@@ -30,6 +30,7 @@ ecnt = 0; /* clear expected errcount() value */
|
|||||||
initcfg = config("all", "oldstd"); /* set config to startup default */
|
initcfg = config("all", "oldstd"); /* set config to startup default */
|
||||||
initcfg = config("lib_debug", 0); /* disable lib startup messages */
|
initcfg = config("lib_debug", 0); /* disable lib startup messages */
|
||||||
initcfg = config("calc_debug", 0); /* disable internal debugging */
|
initcfg = config("calc_debug", 0); /* disable internal debugging */
|
||||||
|
initcnf = config("verbose_quit", 0); /* disable quit messages */
|
||||||
initcfg = config("all"); /* save state for later use */
|
initcfg = config("all"); /* save state for later use */
|
||||||
|
|
||||||
print '003: parsed global definitions';
|
print '003: parsed global definitions';
|
||||||
@@ -964,7 +965,7 @@ define test_functions()
|
|||||||
vrfy(strpos(a, a) == 1, '948: strpos(a, a) == 1');
|
vrfy(strpos(a, a) == 1, '948: strpos(a, a) == 1');
|
||||||
vrfy(system("") == 0, '949: system("") == 0');
|
vrfy(system("") == 0, '949: system("") == 0');
|
||||||
vrfy(system("true") == 0, '950: system("true") == 0');
|
vrfy(system("true") == 0, '950: system("true") == 0');
|
||||||
vrfy(isatty(files(0)) == 1, '951: isatty(files(0)) == 1');
|
print '951: test disabled due to stdin dependency';
|
||||||
print '952: test removed';
|
print '952: test removed';
|
||||||
print '953: test removed';
|
print '953: test removed';
|
||||||
vrfy(isstr(cmdbuf()) == 1, '954: isstr(cmdbuf()) == 1');
|
vrfy(isstr(cmdbuf()) == 1, '954: isstr(cmdbuf()) == 1');
|
||||||
@@ -5106,7 +5107,7 @@ define test_is()
|
|||||||
vrfy(isatty(square) == 0, '5981: isatty(square) == 0');
|
vrfy(isatty(square) == 0, '5981: isatty(square) == 0');
|
||||||
vrfy(isatty(string) == 0, '5982: isatty(string) == 0');
|
vrfy(isatty(string) == 0, '5982: isatty(string) == 0');
|
||||||
vrfy(isatty(com) == 0, '5983: isatty(com) == 0');
|
vrfy(isatty(com) == 0, '5983: isatty(com) == 0');
|
||||||
vrfy(isatty(files(0)) == 1, '5984: isatty(files(0)) == 1');
|
print '5984: test disabled due to stdin dependency';
|
||||||
/* if we pipe to awk (for make chk), stdout and stderr are not ttys */
|
/* if we pipe to awk (for make chk), stdout and stderr are not ttys */
|
||||||
print '5985: test unused';
|
print '5985: test unused';
|
||||||
print '5986: test unused';
|
print '5986: test unused';
|
||||||
@@ -7120,9 +7121,11 @@ print '188: parsed test_natnumset()';
|
|||||||
/*
|
/*
|
||||||
* test_somenew - test some new features
|
* test_somenew - test some new features
|
||||||
*/
|
*/
|
||||||
|
define func8200(x,y) {if (x>0) return calclevel()+func8200(x-1,y)-y; return 0;}
|
||||||
|
print '189: define func8200(x,y)';
|
||||||
define test_somenew()
|
define test_somenew()
|
||||||
{
|
{
|
||||||
local a, s;
|
local a, s, y;
|
||||||
|
|
||||||
print '8200: Starting test_somenew';
|
print '8200: Starting test_somenew';
|
||||||
|
|
||||||
@@ -7154,9 +7157,36 @@ define test_somenew()
|
|||||||
vrfy(hash("curds n whey") == 2376141927,
|
vrfy(hash("curds n whey") == 2376141927,
|
||||||
'8219: hash("curds n whey") == 2376141927');
|
'8219: hash("curds n whey") == 2376141927');
|
||||||
|
|
||||||
print '8220: Ending test_somenew';
|
y = calclevel();
|
||||||
|
print '8220: y = calclevel()';
|
||||||
|
vrfy(func8200(0,y) == 0, '8221: func8200(0,y) == 0');
|
||||||
|
vrfy(func8200(1,y) == 1, '8222: func8200(1,y) == 1');
|
||||||
|
vrfy(func8200(10,y) == 55, '8223: func8200(10,y) == 55');
|
||||||
|
vrfy(func8200(100,y) == 5050, '8224: func8200(100,y) == 5050');
|
||||||
|
|
||||||
|
vrfy(inputlevel() == 1, '8225: inputlevel() == 1');
|
||||||
|
|
||||||
|
print '8226: Ending test_somenew';
|
||||||
}
|
}
|
||||||
print '189: parsed test_somenew()';
|
print '190: parsed test_somenew()';
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* test_quit - test the QUIT functionality
|
||||||
|
*/
|
||||||
|
define test_quit()
|
||||||
|
{
|
||||||
|
local x8400 = 23209; /* watch for lost memory */
|
||||||
|
static s8400 = 21701; /* watch for lost memory */
|
||||||
|
|
||||||
|
print '8400: Starting test_quit';
|
||||||
|
|
||||||
|
quit;
|
||||||
|
prob('quit did not end the test_quit() function');
|
||||||
|
|
||||||
|
/* 8400 serise continued after return, do not print end here */
|
||||||
|
}
|
||||||
|
print '191: parsed test_quit()';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -7442,6 +7472,17 @@ vrfy(l8300(10) == 15, '8309: l8300(10) == 15');
|
|||||||
print '8310: Ending define tests';
|
print '8310: Ending define tests';
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* quit tests
|
||||||
|
*/
|
||||||
|
print;
|
||||||
|
return test_quit();
|
||||||
|
read -once test8400;
|
||||||
|
print '8404: read -once test8400';
|
||||||
|
vrfy(test8400() == 64434, '8405: test8400() == 64434');
|
||||||
|
print '8406: Ending test_quit';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read various calc libs
|
* read various calc libs
|
||||||
*
|
*
|
||||||
@@ -7455,7 +7496,7 @@ print '8310: Ending define tests';
|
|||||||
* lucas_tbl.cal - duplicatres code already read by another file
|
* lucas_tbl.cal - duplicatres code already read by another file
|
||||||
* regress.cal - this file
|
* regress.cal - this file
|
||||||
* surd.cal - already read by this file
|
* surd.cal - already read by this file
|
||||||
* testXXXX.cal - already read by this file
|
* test9999.cal - files of this form are already read by this file
|
||||||
* xx_print.cal - prints a bunch of things when loaded
|
* xx_print.cal - prints a bunch of things when loaded
|
||||||
*
|
*
|
||||||
* We want to do this 2nd to last; ahead of any final cleanup and behind
|
* We want to do this 2nd to last; ahead of any final cleanup and behind
|
||||||
|
30
lib/test8400.cal
Normal file
30
lib/test8400.cal
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1999 Landon Curt Noll
|
||||||
|
* Permission is granted to use, distribute, or modify this source,
|
||||||
|
* provided that this copyright notice remains intact.
|
||||||
|
*
|
||||||
|
* By: Landon Curt Noll
|
||||||
|
* http://reality.sgi.com/chongo
|
||||||
|
*
|
||||||
|
* chongo <was here> /\../\
|
||||||
|
*
|
||||||
|
* This library is used by the 8400 series of the regress.cal test suite.
|
||||||
|
*/
|
||||||
|
|
||||||
|
print "8401: in test8400.cal";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* test8400 - dummy function to allow a check of quit-based memory leaks
|
||||||
|
*/
|
||||||
|
define test8400()
|
||||||
|
{
|
||||||
|
local x8401 = 19937; /* watch for lost memory */
|
||||||
|
static s8401 = 44497; /* watch for lost memory */
|
||||||
|
|
||||||
|
return x8401+s8401;
|
||||||
|
}
|
||||||
|
print "8402: parsed test8400()";
|
||||||
|
vrfy(test8400() == 64434, '8403: test8400() == 64434');
|
||||||
|
|
||||||
|
quit;
|
||||||
|
prob('quit did not end test8400.cal');
|
33
opcodes.c
33
opcodes.c
@@ -33,6 +33,7 @@ static BOOL saveval = TRUE; /* to enable or disable saving */
|
|||||||
static int calc_errno; /* most recent error-number */
|
static int calc_errno; /* most recent error-number */
|
||||||
static int errcount; /* counts calls to error_value */
|
static int errcount; /* counts calls to error_value */
|
||||||
static BOOL go;
|
static BOOL go;
|
||||||
|
static long calc_depth;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* global symbols
|
* global symbols
|
||||||
@@ -106,6 +107,9 @@ initstack(void)
|
|||||||
freevalue(stack--);
|
freevalue(stack--);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* initialize calc_depth */
|
||||||
|
|
||||||
|
calc_depth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3124,8 +3128,7 @@ o_quit(FUNC *fp, long index)
|
|||||||
s = findstring(index);
|
s = findstring(index);
|
||||||
cp = s->s_str;
|
cp = s->s_str;
|
||||||
}
|
}
|
||||||
if (inputisterminal() && (fp->f_name[0] == '*')
|
if (inputisterminal() && !strcmp(fp->f_name, "*")) {
|
||||||
&& (fp->f_name[1] == '\0')) {
|
|
||||||
if (cp)
|
if (cp)
|
||||||
printf("%s\n", cp);
|
printf("%s\n", cp);
|
||||||
hist_term();
|
hist_term();
|
||||||
@@ -3138,9 +3141,9 @@ o_quit(FUNC *fp, long index)
|
|||||||
}
|
}
|
||||||
if (cp)
|
if (cp)
|
||||||
printf("%s\n", cp);
|
printf("%s\n", cp);
|
||||||
else
|
else if (conf->verbose_quit)
|
||||||
printf("Quit or abort executed\n");
|
printf("Quit or abort executed\n");
|
||||||
if (!inputisterminal() && fp->f_name[0] == '*')
|
if (!inputisterminal() && !strcmp(fp->f_name, "*"))
|
||||||
closeinput();
|
closeinput();
|
||||||
go = FALSE;
|
go = FALSE;
|
||||||
}
|
}
|
||||||
@@ -3576,7 +3579,7 @@ calculate(FUNC *fp, int argcount)
|
|||||||
funcname = fp->f_name;
|
funcname = fp->f_name;
|
||||||
funcline = 0;
|
funcline = 0;
|
||||||
go = TRUE;
|
go = TRUE;
|
||||||
abort_now = FALSE;
|
++calc_depth;
|
||||||
origargcount = argcount;
|
origargcount = argcount;
|
||||||
while (argcount < fp->f_paramcount) {
|
while (argcount < fp->f_paramcount) {
|
||||||
stack++;
|
stack++;
|
||||||
@@ -3692,6 +3695,7 @@ calculate(FUNC *fp, int argcount)
|
|||||||
}
|
}
|
||||||
funcname = oldname;
|
funcname = oldname;
|
||||||
funcline = oldline;
|
funcline = oldline;
|
||||||
|
--calc_depth;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case OPSTI: /* static initialization code */
|
case OPSTI: /* static initialization code */
|
||||||
@@ -3713,14 +3717,7 @@ calculate(FUNC *fp, int argcount)
|
|||||||
freevalue(stack--);
|
freevalue(stack--);
|
||||||
funcname = oldname;
|
funcname = oldname;
|
||||||
funcline = oldline;
|
funcline = oldline;
|
||||||
if (abort_now && stack == stackarray) {
|
--calc_depth;
|
||||||
if (!stdin_tty)
|
|
||||||
run_state = RUN_EXIT;
|
|
||||||
else if (run_state < RUN_PRE_TOP_LEVEL)
|
|
||||||
run_state = RUN_PRE_TOP_LEVEL;
|
|
||||||
freefunc(curfunc);
|
|
||||||
longjmp(jmpbuf, 1);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3857,3 +3854,13 @@ freenumbers(FUNC *fp)
|
|||||||
}
|
}
|
||||||
trimconstants();
|
trimconstants();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long
|
||||||
|
calclevel(void)
|
||||||
|
{
|
||||||
|
return calc_depth - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* END CODE */
|
||||||
|
@@ -407,6 +407,7 @@ config_hash(CONFIG *cfg, QCKHASH val)
|
|||||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->lib_debug);
|
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->lib_debug);
|
||||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->calc_debug);
|
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->calc_debug);
|
||||||
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->user_debug);
|
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->user_debug);
|
||||||
|
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->verbose_quit);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hash the built up scalar
|
* hash the built up scalar
|
||||||
|
14
token.c
14
token.c
@@ -335,22 +335,22 @@ static void
|
|||||||
eatcomment(void)
|
eatcomment(void)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
|
setprompt(conf->prompt2);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ch = nextchar();
|
ch = nextchar();
|
||||||
if (ch == '*') {
|
if (ch == '*') {
|
||||||
ch = nextchar();
|
ch = nextchar();
|
||||||
if (ch == '/')
|
if (ch == '/')
|
||||||
return;
|
break;
|
||||||
reread();
|
reread();
|
||||||
}
|
}
|
||||||
if ((ch == EOF) || (ch == '\0') ||
|
if (ch == EOF || ch == '\0') {
|
||||||
(newlines && (ch == '\n') && inputisterminal())) {
|
fprintf(stderr, "Unterminated comment ignored\n");
|
||||||
reread();
|
reread();
|
||||||
scanerror(T_NULL, "Unterminated comment");
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setprompt(conf->prompt1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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 "8.9" /* test number or empty string if no patch */
|
#define MINOR_PATCH "9.1.1" /* test number or empty string if no patch */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* calc version constants
|
* calc version constants
|
||||||
|
2
zmath.h
2
zmath.h
@@ -72,7 +72,7 @@ typedef SB16 SHALF; /* signed HALF */
|
|||||||
typedef USB32 FULL; /* double unit of number storage */
|
typedef USB32 FULL; /* double unit of number storage */
|
||||||
typedef SB32 SFULL; /* signed FULL */
|
typedef SB32 SFULL; /* signed FULL */
|
||||||
|
|
||||||
#define SWAP_HALF_IN_B64(dest, src) SWAP_B32_IN_B64(dest, src)
|
#define SWAP_HALF_IN_B64(dest, src) SWAP_B16_IN_B64(dest, src)
|
||||||
#define SWAP_HALF_IN_B32(dest, src) SWAP_B16_IN_B32(dest, src)
|
#define SWAP_HALF_IN_B32(dest, src) SWAP_B16_IN_B32(dest, src)
|
||||||
#define SWAP_HALF_IN_FULL(dest, src) SWAP_B16_IN_B32(dest, src)
|
#define SWAP_HALF_IN_FULL(dest, src) SWAP_B16_IN_B32(dest, src)
|
||||||
#define SWAP_HALF_IN_HASH(dest, src) SWAP_B16_IN_HASH(dest, src)
|
#define SWAP_HALF_IN_HASH(dest, src) SWAP_B16_IN_HASH(dest, src)
|
||||||
|
Reference in New Issue
Block a user