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