change error printing from errnum to errsym

When printing an error, calc used to print the errnum (error number):

    ; 1/0
	    Error 10001

Calc now prints the errsym (errsym):

    ; 1/0
	    Error E_DIVBYZERO

Added errsym E_LN_3 for ln(0).
Added errsym E_LOG_5 for log(0).
Added errsym E_LOG2_4 for log2(0).
Added errsym E_LOGN_6 for logn(0,base).
This commit is contained in:
Landon Curt Noll
2023-10-03 22:12:14 -07:00
parent db582d6e34
commit 42129a3672
22 changed files with 113 additions and 44 deletions

26
value.c
View File

@@ -2794,15 +2794,31 @@ printvalue(VALUE *vp, int flags)
{
NUMBER *qtemp;
int type;
char *errsym;
bool alloced;
type = vp->v_type;
if (type < 0) {
if (userfunc("error_print", vp))
if (userfunc("error_print", vp)) {
return;
if (-type >= E__BASE)
math_fmt("Error %d", -type);
else
math_fmt("System error %d", -type);
}
errsym = errnum_2_errsym(-type, &alloced);
if (errsym == NULL) {
if (-type >= E__BASE) {
math_fmt("Error %d", -type);
} else {
math_fmt("System error %d", -type);
}
} else {
if (-type >= E__BASE) {
math_fmt("Error %s", errsym);
} else {
math_fmt("System error %s", errsym);
}
if (alloced == true) {
free(errsym);
}
}
return;
}
switch (type) {