rename E__COUNT to ECOUNT

Rename the #define E__COUNT to ECOUNT to avoid confusion
with "E_STRING" error symbols.

Improve formatting of help/error, help/errno, and help/strerror.

Update .gitignore.
This commit is contained in:
Landon Curt Noll
2023-09-13 20:20:46 -07:00
parent d943fda3eb
commit 40c8f875c1
7 changed files with 73 additions and 56 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,