From f3fceff1b66848d814c83f2873bbe12e7aff2c01 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Mon, 1 Nov 1999 01:28:44 -0800 Subject: [PATCH] Release calc version 2.11.0t9 --- CHANGES | 8 ++++++++ calc.h | 1 + func.c | 13 +++++++++++++ help/Makefile | 51 +++++++++++++++++++++++++------------------------ help/calclevel | 35 +++++++++++++++++++++++++++++++++ help/inputlevel | 36 ++++++++++++++++++++++++++++++++++ help/todo | 2 -- lib/regress.cal | 23 ++++++++++++++++------ opcodes.c | 26 ++++++++++++++++--------- version.c | 2 +- 10 files changed, 154 insertions(+), 43 deletions(-) create mode 100644 help/calclevel create mode 100644 help/inputlevel diff --git a/CHANGES b/CHANGES index 0839e7b..4cc50fe 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,14 @@ Following is the change from calc version 2.11.0t8.9.1 to date: 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. + Following is the change from calc version 2.11.0t8 to 2.11.0t8.9: diff --git a/calc.h b/calc.h index 8a4617f..69a6795 100644 --- a/calc.h +++ b/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); diff --git a/func.c b/func.c index 7bfdd8b..53cc83a 100644 --- a/func.c +++ b/func.c @@ -5893,6 +5893,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 +6829,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, diff --git a/help/Makefile b/help/Makefile index c5cc0ed..977c094 100644 --- a/help/Makefile +++ b/help/Makefile @@ -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; \ diff --git a/help/calclevel b/help/calclevel new file mode 100644 index 0000000..b7c3f3a --- /dev/null +++ b/help/calclevel @@ -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 diff --git a/help/inputlevel b/help/inputlevel new file mode 100644 index 0000000..a0da8ce --- /dev/null +++ b/help/inputlevel @@ -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 diff --git a/help/todo b/help/todo index d612c33..826e72f 100644 --- a/help/todo +++ b/help/todo @@ -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. diff --git a/lib/regress.cal b/lib/regress.cal index 1e9f6e8..90cc137 100644 --- a/lib/regress.cal +++ b/lib/regress.cal @@ -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()'; /* @@ -7175,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()'; /* diff --git a/opcodes.c b/opcodes.c index 0d6202d..2f7a3ab 100644 --- a/opcodes.c +++ b/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; } @@ -3576,7 +3580,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 +3696,7 @@ calculate(FUNC *fp, int argcount) } funcname = oldname; funcline = oldline; + --calc_depth; return; case OPSTI: /* static initialization code */ @@ -3713,14 +3718,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 +3855,13 @@ freenumbers(FUNC *fp) } trimconstants(); } + + +long +calclevel(void) +{ + return calc_depth - 1; +} + + +/* END CODE */ diff --git a/version.c b/version.c index 5f8907d..a787800 100644 --- a/version.c +++ b/version.c @@ -12,7 +12,7 @@ #define MAJOR_VER 2 /* major version */ #define MINOR_VER 11 /* minor version */ #define MAJOR_PATCH 0 /* patch level or 0 if no patch */ -#define MINOR_PATCH "8.10" /* test number or empty string if no patch */ +#define MINOR_PATCH "9" /* test number or empty string if no patch */ /* * calc version constants