mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
3 Commits
2.11.0t8.9
...
2.11.0t9.1
Author | SHA1 | Date | |
---|---|---|---|
|
ea6b3904be | ||
|
f3fceff1b6 | ||
|
69d4a17187 |
190
BUGS
190
BUGS
@@ -68,178 +68,6 @@ importantly, fixes (in the form of a context diff patch) to:
|
||||
|
||||
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
|
||||
following is placed in an executable file (assume the path to
|
||||
calc is correct) called /tmp/xyzzy:
|
||||
@@ -253,3 +81,21 @@ Calc Mis-features:
|
||||
Will result in '"tmp" is undefined' and '"xyzzy" is undefined'
|
||||
error messages because calc considers $0 as an expression to
|
||||
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.
|
||||
|
||||
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.
|
||||
|
83
CHANGES
83
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
|
||||
help/wishlist file. Ordered, by priority, help/todo items into
|
||||
@@ -151,20 +218,6 @@ Following is the change from calc version 2.11.0t8 to date:
|
||||
Fixed a bug, reported by Michael Somos <somos@grail.cba.csuohio.edu>,
|
||||
which prevented calc -m from being used.
|
||||
|
||||
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 misc compiler warnings.
|
||||
|
||||
|
||||
|
1
calc.h
1
calc.h
@@ -123,6 +123,7 @@ extern void resetinput(void);
|
||||
extern void setprompt(char *);
|
||||
extern BOOL inputisterminal(void);
|
||||
extern int inputlevel(void);
|
||||
extern long calclevel(void);
|
||||
extern char *inputname(void);
|
||||
extern long linenumber(void);
|
||||
extern void runrcfiles(void);
|
||||
|
@@ -409,6 +409,7 @@ getdeclarations(int symtype)
|
||||
case T_NEWLINE:
|
||||
case T_SEMICOLON:
|
||||
case T_RIGHTBRACE:
|
||||
case T_EOF:
|
||||
rescantoken();
|
||||
return;
|
||||
|
||||
|
22
func.c
22
func.c
@@ -155,6 +155,7 @@ f_eval(VALUE *vp)
|
||||
VALUE result;
|
||||
char *str;
|
||||
long num;
|
||||
int temp;
|
||||
|
||||
if (vp->v_type != V_STR)
|
||||
return error_value(E_EVAL2);
|
||||
@@ -168,7 +169,10 @@ f_eval(VALUE *vp)
|
||||
}
|
||||
oldfunc = curfunc;
|
||||
enterfilescope();
|
||||
temp = stoponerror;
|
||||
stoponerror = -1;
|
||||
if (evaluate(TRUE)) {
|
||||
stoponerror = temp;
|
||||
closeinput();
|
||||
exitfilescope();
|
||||
freevalue(stack--);
|
||||
@@ -181,6 +185,7 @@ f_eval(VALUE *vp)
|
||||
free(newfunc);
|
||||
return result;
|
||||
}
|
||||
stoponerror = temp;
|
||||
closeinput();
|
||||
exitfilescope();
|
||||
newfunc = curfunc;
|
||||
@@ -203,11 +208,11 @@ f_prompt(VALUE *vp)
|
||||
unsigned int len;
|
||||
|
||||
result.v_type = V_STR;
|
||||
if (inputisterminal()) {
|
||||
openterminal();
|
||||
printvalue(vp, PRINT_SHORT);
|
||||
math_flush();
|
||||
}
|
||||
cp = nextline();
|
||||
closeinput();
|
||||
if (cp == NULL) {
|
||||
math_error("End of file while prompting");
|
||||
/*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
|
||||
f_access(int count, VALUE **vals)
|
||||
{
|
||||
@@ -6818,6 +6834,8 @@ static CONST struct builtin builtins[] = {
|
||||
"round value a to b number of binary places"},
|
||||
{"btrunc", 1, 2, 0, OP_NOP, f_btrunc, 0,
|
||||
"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,
|
||||
"smallest integer greater than or equal to number"},
|
||||
{"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.
|
||||
#
|
||||
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 \
|
||||
bit blk blkcpy blkfree blocks bround btrunc ceil cfappr cfsim char \
|
||||
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime delete \
|
||||
den dereference det digit digits dp epsilon errcount errmax errno \
|
||||
error eval exp fact factor fclose fcnt feof ferror fflush fgetc \
|
||||
fgetfield fgetline fgets fgetstr fib files floor fopen forall fprintf \
|
||||
fputc fputs fputstr frac free freeglobals freeredc freestatics frem \
|
||||
freopen fscan fscanf fseek fsize ftell gcd gcdrem gd getenv hash head \
|
||||
highbit hmean hnrmod hypot ilog ilog10 ilog2 im insert int inverse \
|
||||
iroot isassoc isatty isblk isconfig isdefined iserror iseven isfile \
|
||||
ishash isident isint islist ismat ismult isnull isnum isobj isobjtype \
|
||||
isodd isprime isptr isqrt isrand israndom isreal isrel issimple issq \
|
||||
isstr istype jacobi join lcm lcmfact lfactor ln lowbit ltol makelist \
|
||||
matdim matfill matmax matmin matsum mattrace mattrans max md5 memsize \
|
||||
meq min minv mmin mne mod modify name near newerror nextcand \
|
||||
nextprime norm null num oldvalue ord param perm pfact pi pix places \
|
||||
pmod polar poly pop popcnt power prevcand prevprime printf prompt \
|
||||
protect ptest push putenv quo quomod rand randbit random randombit \
|
||||
randperm rcin rcmul rcout rcpow rcsq re remove reverse rewind rm root \
|
||||
round rsearch runtime saveval scale scan scanf search sec sech seed \
|
||||
segment select sgn sha sha1 sin sinh size sizeof sort sqrt srand \
|
||||
srandom ssq str strcat strerror strlen strpos strprintf strscan \
|
||||
strscanf substr sum swap system tail tan tanh test time trunc xor
|
||||
appr arg arrow asec asech asin asinh assign atan atan2 atanh avg \
|
||||
base bit blk blkcpy blkfree blocks bround btrunc calclevel ceil \
|
||||
cfappr cfsim char cmdbuf cmp comb conj cos cosh cot coth count cp \
|
||||
csc csch ctime delete den dereference det digit digits dp epsilon \
|
||||
errcount errmax errno error eval exp fact factor fclose fcnt feof \
|
||||
ferror fflush fgetc fgetfield fgetline fgets fgetstr fib files \
|
||||
floor fopen forall fprintf fputc fputs fputstr frac free freeglobals \
|
||||
freeredc freestatics frem freopen fscan fscanf fseek fsize ftell gcd \
|
||||
gcdrem gd getenv hash head highbit hmean hnrmod hypot ilog ilog10 \
|
||||
ilog2 im inputlevel insert int inverse iroot isassoc isatty isblk \
|
||||
isconfig isdefined iserror iseven isfile ishash isident isint islist \
|
||||
ismat ismult isnull isnum isobj isobjtype isodd isprime isptr isqrt \
|
||||
isrand israndom isreal isrel issimple issq isstr istype jacobi join \
|
||||
lcm lcmfact lfactor ln lowbit ltol makelist matdim matfill matmax \
|
||||
matmin matsum mattrace mattrans max md5 memsize meq min minv mmin \
|
||||
mne mod modify name near newerror nextcand nextprime norm null \
|
||||
num oldvalue ord param perm pfact pi pix places pmod polar poly \
|
||||
pop popcnt power prevcand prevprime printf prompt protect ptest \
|
||||
push putenv quo quomod rand randbit random randombit randperm rcin \
|
||||
rcmul rcout rcpow rcsq re remove reverse rewind rm root round rsearch \
|
||||
runtime saveval scale scan scanf search sec sech seed segment select \
|
||||
sgn sha sha1 sin sinh size sizeof sort sqrt srand srandom ssq str \
|
||||
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
|
||||
# built from DETAIL_HELP files.
|
||||
@@ -416,8 +417,8 @@ bsdi: all
|
||||
detaillist:
|
||||
${Q}-(echo "xxxxx"; \
|
||||
for i in ${DETAIL_HELP}; do \
|
||||
if [ ! -f SCCS/s.$$i ]; then \
|
||||
echo "WARNING: $$i not under SCCS control" 1>&2; \
|
||||
if [ ! -f RCS/$$i,v ]; then \
|
||||
echo "WARNING: $$i not under RCS control" 1>&2; \
|
||||
else \
|
||||
echo $$i; \
|
||||
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
|
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:
|
||||
|
||||
* Write the help file for the inputlevel() builtin function.
|
||||
|
||||
* Write the help file for the display() builtin function.
|
||||
|
||||
* Write the help file for the stoponerror() builtin function.
|
||||
|
@@ -965,7 +965,7 @@ define test_functions()
|
||||
vrfy(strpos(a, a) == 1, '948: strpos(a, a) == 1');
|
||||
vrfy(system("") == 0, '949: system("") == 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 '953: test removed';
|
||||
vrfy(isstr(cmdbuf()) == 1, '954: isstr(cmdbuf()) == 1');
|
||||
@@ -5107,7 +5107,7 @@ define test_is()
|
||||
vrfy(isatty(square) == 0, '5981: isatty(square) == 0');
|
||||
vrfy(isatty(string) == 0, '5982: isatty(string) == 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 */
|
||||
print '5985: test unused';
|
||||
print '5986: test unused';
|
||||
@@ -7121,9 +7121,11 @@ print '188: parsed test_natnumset()';
|
||||
/*
|
||||
* 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()
|
||||
{
|
||||
local a, s;
|
||||
local a, s, y;
|
||||
|
||||
print '8200: Starting test_somenew';
|
||||
|
||||
@@ -7155,9 +7157,18 @@ define test_somenew()
|
||||
vrfy(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()';
|
||||
|
||||
|
||||
/*
|
||||
@@ -7165,6 +7176,9 @@ print '189: parsed test_somenew()';
|
||||
*/
|
||||
define test_quit()
|
||||
{
|
||||
local x8400 = 23209; /* watch for lost memory */
|
||||
static s8400 = 21701; /* watch for lost memory */
|
||||
|
||||
print '8400: Starting test_quit';
|
||||
|
||||
quit;
|
||||
@@ -7172,7 +7186,7 @@ define test_quit()
|
||||
|
||||
/* 8400 serise continued after return, do not print end here */
|
||||
}
|
||||
print '190: parsed test_quit()';
|
||||
print '191: parsed test_quit()';
|
||||
|
||||
|
||||
/*
|
||||
@@ -7464,8 +7478,9 @@ print '8310: Ending define tests';
|
||||
print;
|
||||
return test_quit();
|
||||
read -once test8400;
|
||||
print '8402: read -once test8400';
|
||||
print '8403: Ending test_quit';
|
||||
print '8404: read -once test8400';
|
||||
vrfy(test8400() == 64434, '8405: test8400() == 64434');
|
||||
print '8406: Ending test_quit';
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -12,5 +12,19 @@
|
||||
*/
|
||||
|
||||
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');
|
||||
|
31
opcodes.c
31
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 errcount; /* counts calls to error_value */
|
||||
static BOOL go;
|
||||
static long calc_depth;
|
||||
|
||||
/*
|
||||
* global symbols
|
||||
@@ -106,6 +107,9 @@ initstack(void)
|
||||
freevalue(stack--);
|
||||
}
|
||||
}
|
||||
/* initialize calc_depth */
|
||||
|
||||
calc_depth = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -3124,8 +3128,7 @@ o_quit(FUNC *fp, long index)
|
||||
s = findstring(index);
|
||||
cp = s->s_str;
|
||||
}
|
||||
if (inputisterminal() && (fp->f_name[0] == '*')
|
||||
&& (fp->f_name[1] == '\0')) {
|
||||
if (inputisterminal() && !strcmp(fp->f_name, "*")) {
|
||||
if (cp)
|
||||
printf("%s\n", cp);
|
||||
hist_term();
|
||||
@@ -3140,7 +3143,7 @@ o_quit(FUNC *fp, long index)
|
||||
printf("%s\n", cp);
|
||||
else if (conf->verbose_quit)
|
||||
printf("Quit or abort executed\n");
|
||||
if (!inputisterminal() && fp->f_name[0] == '*')
|
||||
if (!inputisterminal() && !strcmp(fp->f_name, "*"))
|
||||
closeinput();
|
||||
go = FALSE;
|
||||
}
|
||||
@@ -3576,7 +3579,7 @@ calculate(FUNC *fp, int argcount)
|
||||
funcname = fp->f_name;
|
||||
funcline = 0;
|
||||
go = TRUE;
|
||||
abort_now = FALSE;
|
||||
++calc_depth;
|
||||
origargcount = argcount;
|
||||
while (argcount < fp->f_paramcount) {
|
||||
stack++;
|
||||
@@ -3692,6 +3695,7 @@ calculate(FUNC *fp, int argcount)
|
||||
}
|
||||
funcname = oldname;
|
||||
funcline = oldline;
|
||||
--calc_depth;
|
||||
return;
|
||||
|
||||
case OPSTI: /* static initialization code */
|
||||
@@ -3713,14 +3717,7 @@ calculate(FUNC *fp, int argcount)
|
||||
freevalue(stack--);
|
||||
funcname = oldname;
|
||||
funcline = oldline;
|
||||
if (abort_now && stack == stackarray) {
|
||||
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);
|
||||
}
|
||||
--calc_depth;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3857,3 +3854,13 @@ freenumbers(FUNC *fp)
|
||||
}
|
||||
trimconstants();
|
||||
}
|
||||
|
||||
|
||||
long
|
||||
calclevel(void)
|
||||
{
|
||||
return calc_depth - 1;
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
|
12
token.c
12
token.c
@@ -335,22 +335,22 @@ static void
|
||||
eatcomment(void)
|
||||
{
|
||||
int ch;
|
||||
|
||||
setprompt(conf->prompt2);
|
||||
for (;;) {
|
||||
ch = nextchar();
|
||||
if (ch == '*') {
|
||||
ch = nextchar();
|
||||
if (ch == '/')
|
||||
return;
|
||||
break;
|
||||
reread();
|
||||
}
|
||||
if ((ch == EOF) || (ch == '\0') ||
|
||||
(newlines && (ch == '\n') && inputisterminal())) {
|
||||
if (ch == EOF || ch == '\0') {
|
||||
fprintf(stderr, "Unterminated comment ignored\n");
|
||||
reread();
|
||||
scanerror(T_NULL, "Unterminated comment");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setprompt(conf->prompt1);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#define MAJOR_VER 2 /* major version */
|
||||
#define MINOR_VER 11 /* minor version */
|
||||
#define MAJOR_PATCH 0 /* patch level or 0 if no patch */
|
||||
#define MINOR_PATCH "8.9.1" /* test number or empty string if no patch */
|
||||
#define MINOR_PATCH "9.1" /* test number or empty string if no patch */
|
||||
|
||||
/*
|
||||
* 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 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_FULL(dest, src) SWAP_B16_IN_B32(dest, src)
|
||||
#define SWAP_HALF_IN_HASH(dest, src) SWAP_B16_IN_HASH(dest, src)
|
||||
|
Reference in New Issue
Block a user