mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Updated COPYING file to indicate that these files are now covered under "The Unlicense" (see https://unlicense.org): sha1.c sha1.h cal/dotest.cal cal/screen.cal Updated help/credit to match the above changes to COPYING. Updated CONTRIB-CODE and calc.man to refer to using GitHub pull requests for contributing to calc (instead of using Email). Updated BUGS and calc.man to refer to using GitHub issues for reporting calc bugs (instead of using Email). Updated QUESTIONS and calc.man to refer to using GitHub issues for asking calc questions (instead of using Email). Fixed Makefile.local command example to refer to overriding the Makefile variable DEBUG (instead of CDEBUG). Fixed all make chk ASAN warnings under macOS 13.2.1 when calc is compiled with the following uncommented lines in Makefile.local: DEBUG:= -O0 -g CFLAGS+= -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined LDFLAGS+= -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1 Improved how pointers to functions are declared for the builtins array in func.c to avoid function declarations without a prototype that is now deprecated in C. Improved how pointers to functions are declared for the opcodes array in opcodes.c to avoid function declarations without a prototype Replaced use of egrep with grep -E in Makefiles. Fixed cases where variables were set but not used in symbol.c, calc.c, and the main function in func.c as used by funclist.c. Added rule name to "DO NOT EDIT -- generated by the Makefile" lines in constructed files. Test if <sys/vfs.h> exists and set HAVE_SYS_VFS_H accordingly in have_sys_vfs.h. Added HAVE_SYS_VFS_H to allow one to force this value. Test if <sys/param.h> exists and set HAVE_SYS_PARAM_H accordingly in have_sys_param.h. Added HAVE_SYS_PARAM_H to allow one to force this value. Test if <sys/mount.h> exists and set HAVE_SYS_MOUNT_H accordingly in have_sys_mount.h. Added HAVE_SYS_MOUNT_H to allow one to force this value. Test if the system as the statfs() system call and set HAVE_STATFS accordingly in have_statfs.h. Added HAVE_STATFS to allow one to force this value. The pseudo_seed() function will also try to call statfs() if possible and permitted by the HAVE_STATFS value.
208 lines
6.3 KiB
Plaintext
208 lines
6.3 KiB
Plaintext
/*
|
|
* dotest - test truth statements found in line tests of dotest_testline file
|
|
*
|
|
* This file was created by Ernest Bowen <ebowen at une dot edu dot au>
|
|
* and modified by Landon Curt Noll.
|
|
*
|
|
* This file is not covered under version 2.1 of the GNU LGPL.
|
|
* This file is covered under "The unlicense":
|
|
*
|
|
* https://unlicense.org
|
|
*
|
|
* In particular:
|
|
*
|
|
* This is free and unencumbered software released into the public domain.
|
|
*
|
|
* Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
* distribute this software, either in source code form or as a compiled
|
|
* binary, for any purpose, commercial or non-commercial, and by any
|
|
* means.
|
|
*
|
|
* In jurisdictions that recognize copyright laws, the author or authors
|
|
* of this software dedicate any and all copyright interest in the
|
|
* software to the public domain. We make this dedication for the benefit
|
|
* of the public at large and to the detriment of our heirs and
|
|
* successors. We intend this dedication to be an overt act of
|
|
* relinquishment in perpetuity of all present and future rights to this
|
|
* software under copyright law.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
* For more information, please refer to <http://unlicense.org/>
|
|
*
|
|
* Under source dotest_code control: 2006/03/08 05:54:09
|
|
* File existed as early as: 2006
|
|
*/
|
|
|
|
|
|
/*
|
|
* dotest - perform tests from dotest_testline file
|
|
*
|
|
* given:
|
|
* dotest_file filename containing single test lines
|
|
* dotest_code regress.cal test number to use (def: 0)
|
|
* dotest_maxcond max error conditions allowed (def: <0 ==> 2^31-1)
|
|
*
|
|
* returns:
|
|
* number of line test failures
|
|
*
|
|
* NOTE: All variables used by the dotest() function start with "dotest_".
|
|
* The dotest_file and dotest_read should not use any variable
|
|
* that starts with "dotest_".
|
|
*/
|
|
define dotest(dotest_file, dotest_code = 0, dotest_maxcond = -1)
|
|
{
|
|
local dotest_f_file; /* open file containing test lines */
|
|
local dotest_testline; /* test line */
|
|
local dotest_testeval; /* eval value from dotest_testline test line */
|
|
local dotest_tmperrcnt; /* temp error count after line test */
|
|
local dotest_errcnt; /* total number of errors */
|
|
local dotest_failcnt; /* number of line tests failed */
|
|
local dotest_testnum; /* number of test lines evaluated */
|
|
local dotest_linenum; /* test line number */
|
|
local dotest_old_errmax; /* value of errmax() prior to calling */
|
|
local dotest_old_errcount; /* value of errcount() prior to calling */
|
|
|
|
/*
|
|
* preserve calling stats
|
|
*/
|
|
dotest_old_errmax = errmax();
|
|
dotest_old_errcount = errcount(0);
|
|
|
|
/*
|
|
* initialize test accounting
|
|
*/
|
|
dotest_errcnt = errcount();
|
|
dotest_failcnt = 0;
|
|
dotest_testnum = 0;
|
|
dotest_linenum = 0;
|
|
|
|
/*
|
|
* setup error accounting for dotest
|
|
*/
|
|
if (dotest_maxcond >= 0 && dotest_maxcond < 2147483647) {
|
|
errmax(dotest_maxcond + dotest_old_errcount + 1),;
|
|
} else {
|
|
errmax(2147483647),;
|
|
}
|
|
|
|
/*
|
|
* open the test line file
|
|
*/
|
|
printf("%d-: opening line file: %d", dotest_code, dotest_file);
|
|
dotest_f_file = fpathopen(dotest_file, "r");
|
|
if (!isfile(dotest_f_file)) {
|
|
printf("**** Unable to file or open file \"%s\"\n",
|
|
dotest_file);
|
|
quit;
|
|
}
|
|
printf('%d: testing "%s"\n', dotest_code, dotest_file);
|
|
|
|
/*
|
|
* perform dotest_testline test on each line of the file
|
|
*/
|
|
for (;;) {
|
|
|
|
/* get the next test line */
|
|
dotest_testline = fgets(dotest_f_file);
|
|
++dotest_linenum;
|
|
if (iserror(dotest_testline)) {
|
|
quit "**** Error while reading file";
|
|
} else if (isnull(dotest_testline)) {
|
|
/* EOF - end of test file */
|
|
break;
|
|
}
|
|
|
|
/* skip empty lines */
|
|
if (dotest_testline == "\n") {
|
|
continue;
|
|
}
|
|
|
|
/* evaluate the test line */
|
|
dotest_testeval = eval(dotest_testline);
|
|
|
|
/* ignore white space or comment lines */
|
|
if (isnull(dotest_testeval)) {
|
|
continue;
|
|
}
|
|
|
|
/* look for test line parse errors */
|
|
if (iserror(dotest_testeval)) {
|
|
printf("**** evaluation error: ");
|
|
++dotest_failcnt;
|
|
|
|
/* look for test line dotest_failcnt */
|
|
} else if (dotest_testeval != 1) {
|
|
printf("**** did not return 1: ");
|
|
++dotest_failcnt;
|
|
}
|
|
|
|
/* show the test line we just performed */
|
|
printf("%d-%d: %s", dotest_code, dotest_linenum, dotest_testline);
|
|
|
|
/* error accounting */
|
|
dotest_tmperrcnt = errcount() - dotest_errcnt;
|
|
if (dotest_tmperrcnt > 0) {
|
|
|
|
/* report any other errors */
|
|
if (dotest_tmperrcnt > 1) {
|
|
printf("%d-%d: NOTE: %d error conditions(s): %s\n",
|
|
dotest_code, dotest_linenum, dotest_tmperrcnt);
|
|
}
|
|
|
|
/* report the calc error string */
|
|
printf("%d-%d: NOTE: last error string: %s\n",
|
|
dotest_code, dotest_linenum, strerror());
|
|
|
|
/* new error count level */
|
|
dotest_errcnt = errcount();
|
|
if (dotest_maxcond >= 0 &&
|
|
dotest_old_errcount-dotest_errcnt > dotest_maxcond) {
|
|
printf("%d-%d: total error conditions: %d > %d\n",
|
|
dotest_code, dotest_linenum,
|
|
dotest_maxcond, dotest_old_errcount-dotest_errcnt);
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
* test the close of the line file
|
|
*/
|
|
printf("%d-: detected %d error condition(s), many of which may be OK\n",
|
|
dotest_code, dotest_old_errcount-dotest_errcnt);
|
|
printf("%d-: closing line file: %d\n", dotest_code, dotest_file);
|
|
fclose(dotest_f_file);
|
|
|
|
/*
|
|
* test line file accounting
|
|
*/
|
|
if (dotest_failcnt > 0) {
|
|
printf("**** %d-: %d test failure(s) in %d line(s)\n",
|
|
dotest_code, dotest_failcnt, dotest_linenum);
|
|
} else {
|
|
printf("%d-: no failure(s) in %d line(s)\n",
|
|
dotest_code, dotest_linenum);
|
|
}
|
|
|
|
/*
|
|
* prepare to return to the caller environment
|
|
*
|
|
* We increase the caller's error count by the number
|
|
* of line tests that failed, not the number of internal
|
|
* errors that were noted.
|
|
*/
|
|
errmax(dotest_old_errmax),;
|
|
errcount(dotest_old_errcount + dotest_failcnt),;
|
|
|
|
/*
|
|
* All Done!!! -- Jessica Noll, Age 2
|
|
*/
|
|
return dotest_failcnt;
|
|
}
|