diff --git a/.gitignore b/.gitignore index 20a5d2d..41bf6db 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,8 @@ core* .dynamic .hsrc .static +Makefile.our +NOTES align32 align32.h args.h @@ -40,12 +42,12 @@ conf.h const_tmp cscript/.all cscript/4dsphere +cscript/README cscript/fproduct cscript/mersenne cscript/piforever cscript/plus cscript/powerterm -cscript/README cscript/simple cscript/square custom/.all @@ -118,6 +120,8 @@ have_ustat have_ustat.h have_varvs help/.all +help/COPYING +help/COPYING-LGPL help/binding help/bindings help/bug @@ -127,8 +131,6 @@ help/change help/changes help/contrib help/copy -help/COPYING -help/COPYING-LGPL help/cscript help/custom_cal help/errorcode @@ -150,8 +152,6 @@ libcalc.* libcustcalc.* longbits longbits.h -Makefile.our -NOTES outfile sample_many sample_many-static @@ -160,5 +160,6 @@ sample_rand-static status.chk_c.h tags terminal.h +unused_tmp ver_calc win32/ diff --git a/CHANGES b/CHANGES index a77b833..b51a0c4 100644 --- a/CHANGES +++ b/CHANGES @@ -289,6 +289,9 @@ The following are the changes from calc version 2.14.3.5 to date: msg = error_table[errnum - E__BASE].errmsg; + Rename the #define E__COUNT to ECOUNT to avoid confusion + with "E_STRING" error symbols. + The following are the changes from calc version 2.14.3.4 to 2.14.3.5: diff --git a/errtbl.c b/errtbl.c index 57c9e68..b636305 100644 --- a/errtbl.c +++ b/errtbl.c @@ -35,10 +35,10 @@ #define ERRTBL_COPYRIGHT_YEAR 2023 /* Copyright (C) year for generated files */ /* number of calc computation error codes */ -#define MY_E__COUNT ((sizeof(error_table) / sizeof(error_table[0])) - 2) +#define MY_ECOUNT ((sizeof(error_table) / sizeof(error_table[0])) - 2) /* highest assigned calc computation error code */ -#define MY_E__HIGHEST (E__BASE + MY_E__COUNT) +#define MY_E__HIGHEST (E__BASE + MY_ECOUNT) /************************************************************************/ @@ -669,7 +669,7 @@ S_FUNC void verify_error_table(void) { size_t len; /* length of the error_table */ - size_t e__count; /* computed E__COUNT value */ + size_t e__count; /* computed ECOUNT value */ char *p; size_t i; @@ -678,9 +678,9 @@ verify_error_table(void) */ len = sizeof(error_table) / sizeof(error_table[0]); e__count = len - 2; - if (e__count != MY_E__COUNT) { - fprintf(stderr, "**** %s ERROR: error_table length: %zu != MY_E__COUNT+2: %lu\n", - program, len, MY_E__COUNT+2); + if (e__count != MY_ECOUNT) { + fprintf(stderr, "**** %s ERROR: error_table length: %zu != MY_ECOUNT+2: %lu\n", + program, len, MY_ECOUNT+2); exit(10); } @@ -929,10 +929,11 @@ print_errsym(void) */ printf("\n" "#define E__HIGHEST\t%ld\t/* highest assigned calc computation error code */\n" - "#define E__COUNT\t%ld\t/* number of calc computation error codes w/o E__BASE */\n" "#define E__USERDEF\t%d\t/* user defined error codes start here */\n" - "#define E__USERMAX\t%d\t/* maximum user defined error code */\n", - MY_E__HIGHEST, MY_E__COUNT, E__USERDEF, E__USERMAX); + "#define E__USERMAX\t%d\t/* maximum user defined error code */\n" + "\n" + "#define ECOUNT\t%ld\t/* number of calc computation error codes w/o E__BASE */\n", + MY_E__HIGHEST, E__USERDEF, E__USERMAX, MY_ECOUNT); printf("\n" "\n" "#endif /* !INCLUDE_ERRSYM_H */\n"); diff --git a/errtbl.h b/errtbl.h index 3ac2c20..e90d829 100644 --- a/errtbl.h +++ b/errtbl.h @@ -35,10 +35,10 @@ /* * primary error code defines */ -#define E__NONE 0 /* calc_errno cleared: libc errno codes above here */ -#define E__BASE 10000 /* calc errors start above here */ -#define E__USERDEF 20000 /* user defined error codes start here */ -#define E__USERMAX 32767 /* maximum user defined error code */ +#define E__NONE 0 /* calc_errno cleared: libc errno codes above here */ +#define E__BASE 10000 /* calc errors start above here */ +#define E__USERDEF 20000 /* user defined error codes start here */ +#define E__USERMAX 32767 /* maximum user defined error code */ /* diff --git a/help/errno b/help/errno index b37cdb0..18cb5da 100644 --- a/help/errno +++ b/help/errno @@ -11,11 +11,22 @@ TYPES return integer DESCRIPTION - Whenever an operation or evaluation of function returns an error-value, - the numerical code for that value is stored as "global calc_errno value". + With errno(errnum) numeric argument: - The term "global calc_errno value" is an internal calc state. - This is NOT a calc variable called calc_errno. + errno(errnum) sets "global calc_errno value" to the value + errnum and returns its previous value. Unlike error(errnum) + calling errno(errnum) does NOT increment the global calc + error count (see help errcount). + + With errno("E_STRING") string argument: + + XXX - fill in - XXX + + With errno() no argument: + + errno() returns the current value of "global calc_errno + value". Unlike error() calling errno() does NOT increment + the global calc error count (see help errcount). NOTE: @@ -27,14 +38,11 @@ DESCRIPTION Unlike error() calling errno() does NOT increment the global calc error count (see help errcount). - errno() returns the current value of "global calc_errno value". - Unlike error() calling errno() does NOT increment the global - calc error count (see help errcount). + Whenever an operation or evaluation of function returns an error-value, + the numerical code for that value is stored as "global calc_errno value". - errno(errnum) sets "global calc_errno value" to the value errnum - and returns its previous value. Unlike error(errnum) calling - errno(errnum) does NOT increment the global calc error count - (see help errcount). + The term "global calc_errno value" is an internal calc state. + This is NOT a calc variable called calc_errno. To detect whether an error occurs during some sequence of operations, one may immediately before that sequence set the stored error-number @@ -66,10 +74,12 @@ EXAMPLE LIMITS 0 <= errnum <= 32767 -LINK LIBRARY - int calc_errno; /* global calc_errno value */ + E_STRING is string matching the regular expression: "^E_[A-Z0-9_]+$" - E_STRING is C string matching the regular expression: "^E_[A-Z0-9_]+$" +LINK LIBRARY + int calc_errno; /* global calc_errno value */ + + CONST struct errtbl error_table[ECOUNT+2]; /* calc error codes, error symbols and error messages */ SEE ALSO errmax, errcount, error, strerror, iserror, newerror, errorcodes, diff --git a/help/error b/help/error index 19488d5..0c82ecb 100644 --- a/help/error +++ b/help/error @@ -32,15 +32,19 @@ DESCRIPTION If the global calc error count exceeds the maximum count (see help errmax), any ongoing calc execution is aborted. - All other values of errnum are reserved for future use and currently - will generate an error. + With error("E_STRING") string argument: - NOTE: + XXX - fill in - XXX + + For no errnum arg: Calling error() without an argument will return the current "global calc_errno value" AND will also increment the global calc error count. + All other values of errnum are reserved for future use and currently + will generate an error. + Use errno() instead of error() to return the "global calc_errno value" without incrementing the global calc error count. @@ -57,31 +61,22 @@ DESCRIPTION By convention, the "global calc_errno value" has the following ranges: errnum < 0 Reserved for future use - errnum == 0 calc_errno cleared: libc errno codes above here - 1 <= errnum <= 9999 system error and libc errno codes - errnum == 10000 Reserved for "No error" calc internal state - 10001 <= errnum <= E__HIGHEST calc computation error codes - E__HIGHEST < errnum < 20000 Reserved for future calc error codes - 20000 < errnum <= 32767 User defined error codes start here - errnum >= 32768 Reserved for future use The following constants are part of the calc error code mechanism: - E__BASE == 10000 # 1 less than the 1st calc computation error code - - E__COUNT # number of calc computation error codes (not including E__BASE) - E__HIGHEST # highest assigned calc computation error code - - E__USERDEF == 20000 # user defined error codes start here - E__USERMAX == 32767 # maximum user defined error code + E__BASE == 10000 1 less than the 1st calc computation error code + E__HIGHEST highest assigned calc computation error code + E__USERDEF == 20000 user defined error codes start here + E__USERMAX == 32767 maximum user defined error code + ECOUNT number of calc computation error codes (not including E__BASE) See help errorcodes for the actual values of the above constants. @@ -115,10 +110,12 @@ EXAMPLE LIMITS 0 <= errnum <= 32767 - E_STRING is C string matching the regular expression: "^E_[A-Z0-9_]+$" + E_STRING is string matching the regular expression: "^E_[A-Z0-9_]+$" LINK LIBRARY - int calc_errno; /* global calc_errno value */ + int calc_errno; /* global calc_errno value */ + + CONST struct errtbl error_table[ECOUNT+2]; /* calc error codes, error symbols and error messages */ SEE ALSO errcount, errmax, errorcodes, iserror, errno, strerror, newerror, diff --git a/help/strerror b/help/strerror index 6596e69..7474034 100644 --- a/help/strerror +++ b/help/strerror @@ -18,6 +18,10 @@ DESCRIPTION * user-defined description string created by newerror(str) * "Unknown error errnum" (where errnum is in decimal) + With strerror("E_STRING") string argument: + + XXX - fill in - XXX + Without a argument, strerror() returns as if it were called with: strerror(errno()) @@ -34,17 +38,17 @@ DESCRIPTION For users of libcalc: The libcalc array error_table[] contains the hard coded - calc-generated error array of E__COUNT+2 pointers to strings + calc-generated error array of ECOUNT+2 pointers to strings starting with E__BASE, ending with E__HIGHEST and terminated by a NULL pointer. The error_table[0] is for errnum of E__BASE, and is the string "No error". - The error_table[E__COUNT] is string associated with the + The error_table[ECOUNT] is string associated with the highest calc-generated error message. - The error_table[E__COUNT+1] is a NULL pointer. + The error_table[ECOUNT+1] is a NULL pointer. See help error for more information on the ranges of errnum and the meaning of the above mentioned constants. @@ -79,11 +83,12 @@ EXAMPLE LIMITS 0 <= errnum <= 32767 - E_STRING is C string matching the regular expression: "^E_[A-Z0-9_]+$" + E_STRING is string matching the regular expression: "^E_[A-Z0-9_]+$" LINK LIBRARY int calc_errno; /* global calc_errno value */ - CONST char *error_table[E__COUNT+2]; /* calc coded error messages */ + + CONST struct errtbl error_table[ECOUNT+2]; /* calc error codes, error symbols and error messages */ SEE ALSO strcat, strcpy, strlen, strncmp, strncpy, strpos,