From 3b9393a8ac07446c81fce96c97f2e6530bab7aa0 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Wed, 13 Sep 2023 20:55:22 -0700 Subject: [PATCH] fix redundant #defines Removed from errsym.h (as built by errcode -d via the Makefile), E__NONE, E__BASE, E__USERDEF, and E__USERMAX. These symbols were also defined in errtbl.h, which is NOW the place of the #define. Update .gitigore with another temporary file. --- .gitignore | 11 ++++++----- Makefile | 1 + errtbl.c | 18 ++++++------------ func.c | 4 ++-- value.c | 1 + 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 41bf6db..6392173 100644 --- a/.gitignore +++ b/.gitignore @@ -23,8 +23,6 @@ core* .dynamic .hsrc .static -Makefile.our -NOTES align32 align32.h args.h @@ -42,12 +40,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 @@ -120,8 +118,6 @@ have_ustat have_ustat.h have_varvs help/.all -help/COPYING -help/COPYING-LGPL help/binding help/bindings help/bug @@ -131,6 +127,8 @@ help/change help/changes help/contrib help/copy +help/COPYING +help/COPYING-LGPL help/cscript help/custom_cal help/errorcode @@ -152,12 +150,15 @@ libcalc.* libcustcalc.* longbits longbits.h +Makefile.our +NOTES outfile sample_many sample_many-static sample_rand sample_rand-static status.chk_c.h +strdup_tmp tags terminal.h unused_tmp diff --git a/Makefile b/Makefile index 45abb8b..b5a48ca 100644 --- a/Makefile +++ b/Makefile @@ -5519,6 +5519,7 @@ value.o: config.h value.o: decl.h value.o: endian_calc.h value.o: errsym.h +value.o: errtbl.h value.o: file.h value.o: func.h value.o: hash.h diff --git a/errtbl.c b/errtbl.c index b636305..20ddf30 100644 --- a/errtbl.c +++ b/errtbl.c @@ -827,13 +827,13 @@ print_errorcodes(void) } /* - * print the help/errorcodes.h file trailer + * print the help/errorcodes file trailer */ printf("\n" - "\"E__HIGHEST\"\t%ld\thighest assigned calc computation error code\n" - "\"E__USERDEF\"\t%d\tuser defined error codes start here\n" - "\"E__USERMAX\"\t%d\tmaximum user defined error code\n", - MY_E__HIGHEST, E__USERDEF, E__USERMAX); + "\"E__HIGHEST\"\t%ld\thighest assigned calc computation error code\n" + "\"E__USERDEF\"\t%d\tuser defined error codes start here\n" + "\"E__USERMAX\"\t%d\tmaximum user defined error code\n", + MY_E__HIGHEST, E__USERDEF, E__USERMAX); printf("\n" "## Copyright (C) %d Landon Curt Noll\n" "##\n" @@ -905,10 +905,6 @@ print_errsym(void) "\n" "\n", ERRTBL_COPYRIGHT_YEAR); - printf("#define E__NONE\t\t%d\t/* calc_errno cleared: libc errno codes above here */\n" - "#define E__BASE\t\t%d\t/* Reserved for \"No error\" calc internal state */\n" - "\n", - E__NONE, E__BASE); /* * print the #define lines @@ -929,11 +925,9 @@ print_errsym(void) */ printf("\n" "#define E__HIGHEST\t%ld\t/* highest assigned calc computation error code */\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" "\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); + MY_E__HIGHEST, MY_ECOUNT); printf("\n" "\n" "#endif /* !INCLUDE_ERRSYM_H */\n"); diff --git a/func.c b/func.c index 296dbbf..6a4d943 100644 --- a/func.c +++ b/func.c @@ -8087,7 +8087,7 @@ f_newerror(int count, VALUE **vals) if (index >= 0) { errnum = E__USERDEF + index; } else { - if (nexterrnum == 32767) + if (nexterrnum == E__USERMAX) math_error("Too many new error values"); errnum = nexterrnum++; addstr(&newerrorstr, str); @@ -8116,7 +8116,7 @@ f_strerror(int count, VALUE **vals) if (vp->v_type != V_NUM || qisfrac(vp->v_num)) return error_value(E_STRERROR1); i = qtoi(vp->v_num); - if (i < 0 || i > 32767) + if (i < 0 || i > E__USERMAX) return error_value(E_STRERROR2); } } else { diff --git a/value.c b/value.c index ddb01a1..68c2edfa 100644 --- a/value.c +++ b/value.c @@ -37,6 +37,7 @@ #include "nametype.h" #include "file.h" #include "config.h" +#include "errtbl.h" #include "attribute.h"