mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
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:
11
.gitignore
vendored
11
.gitignore
vendored
@@ -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/
|
||||
|
3
CHANGES
3
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:
|
||||
|
||||
|
19
errtbl.c
19
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");
|
||||
|
34
help/errno
34
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
|
||||
|
||||
E_STRING is string matching the regular expression: "^E_[A-Z0-9_]+$"
|
||||
|
||||
LINK LIBRARY
|
||||
int calc_errno; /* global calc_errno value */
|
||||
|
||||
E_STRING is C string matching the regular expression: "^E_[A-Z0-9_]+$"
|
||||
CONST struct errtbl error_table[ECOUNT+2]; /* calc error codes, error symbols and error messages */
|
||||
|
||||
SEE ALSO
|
||||
errmax, errcount, error, strerror, iserror, newerror, errorcodes,
|
||||
|
33
help/error
33
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,11 +110,13 @@ 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 struct errtbl error_table[ECOUNT+2]; /* calc error codes, error symbols and error messages */
|
||||
|
||||
SEE ALSO
|
||||
errcount, errmax, errorcodes, iserror, errno, strerror, newerror,
|
||||
stoponerror
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user