diff --git a/CHANGES b/CHANGES index 2936dd0..1d40348 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,10 @@ The following are the changes from calc version 2.14.0.15 to date: Improve comments on Makefile.local and add a few more examples of how it might be used. + Changed /*NOTREACHED*/ to not_reached(); and use "attribute.h". + + Added .PHONY rule, just after all rule, to Makefiles. + The following are the changes from calc version 2.14.0.14 to 2.14.0.14: @@ -8219,7 +8223,7 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1: A small bug in the library file regress.cal was fixed. -## Copyright (C) 2001-2017,2021 Landon Curt Noll +## Copyright (C) 2001-2017,2021,2022 Landon Curt Noll ## ## Calc is open software; you can redistribute it and/or modify it under ## the terms of the version 2.1 of the GNU Lesser General Public License diff --git a/Makefile b/Makefile index 94e40d4..8b1bbdc 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # # calc - arbitrary precision calculator # -# Copyright (C) 1999-2018,2021 Landon Curt Noll +# Copyright (C) 1999-2018,2021,2022 Landon Curt Noll # # SRC: Makefile - top level Makefile # @@ -2054,7 +2054,7 @@ LIB_H_SRC= alloc.h banned.h blkcpy.h block.h byteswap.h calc.h cmath.h \ config.h custom.h decl.h file.h func.h hash.h hist.h jump.h \ label.h lib_util.h lib_calc.h nametype.h \ opcodes.h prime.h qmath.h sha1.h str.h strl.h \ - symbol.h token.h value.h zmath.h zrand.h zrandom.h + symbol.h token.h value.h zmath.h zrand.h zrandom.h attribute.h # we build these .h files during the make # @@ -2464,6 +2464,12 @@ LATE_TARGETS= calc.1 calc.usage \ # TARGETS= ${EARLY_TARGETS} ${BLD_TYPE} ${LATE_TARGETS} +# rules that are not also names of files +# +PHONY= all calcliblist calc_version check chk clobber debug depend distdir \ + distlist hsrc install inst_files mkdebug rpm sample splint tags \ + uninstall win32_hsrc + #if 0 /* start of skip for non-Gnu makefiles */ # ### @@ -2483,6 +2489,8 @@ include ${LOC_MKF} all: check_include ${BLD_TYPE} CHANGES +.PHONY: ${PHONY} + check_include: ${Q} if ! echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo "ERROR: Missing critical include file." 1>&2; \ @@ -5747,6 +5755,7 @@ calc-unsymlink: addop.o: addop.c addop.o: alloc.h +addop.o: attribute.h addop.o: banned.h addop.o: block.h addop.o: byteswap.h @@ -5782,6 +5791,7 @@ align32.o: have_unistd.h align32.o: longbits.h assocfunc.o: alloc.h assocfunc.o: assocfunc.c +assocfunc.o: attribute.h assocfunc.o: banned.h assocfunc.o: block.h assocfunc.o: byteswap.h @@ -5805,6 +5815,7 @@ assocfunc.o: str.h assocfunc.o: value.h assocfunc.o: zmath.h blkcpy.o: alloc.h +blkcpy.o: attribute.h blkcpy.o: banned.h blkcpy.o: blkcpy.c blkcpy.o: blkcpy.h @@ -5833,6 +5844,7 @@ blkcpy.o: str.h blkcpy.o: value.h blkcpy.o: zmath.h block.o: alloc.h +block.o: attribute.h block.o: banned.h block.o: block.c block.o: block.h @@ -5857,6 +5869,7 @@ block.o: str.h block.o: value.h block.o: zmath.h byteswap.o: alloc.h +byteswap.o: attribute.h byteswap.o: banned.h byteswap.o: byteswap.c byteswap.o: byteswap.h @@ -5874,6 +5887,7 @@ byteswap.o: qmath.h byteswap.o: zmath.h calc.o: alloc.h calc.o: args.h +calc.o: attribute.h calc.o: banned.h calc.o: block.h calc.o: byteswap.h @@ -5924,6 +5938,7 @@ charbit.o: charbit.c charbit.o: have_ban_pragma.h charbit.o: have_limits.h codegen.o: alloc.h +codegen.o: attribute.h codegen.o: banned.h codegen.o: block.h codegen.o: byteswap.h @@ -5960,6 +5975,7 @@ codegen.o: token.h codegen.o: value.h codegen.o: zmath.h comfunc.o: alloc.h +comfunc.o: attribute.h comfunc.o: banned.h comfunc.o: byteswap.h comfunc.o: cmath.h @@ -5978,6 +5994,7 @@ comfunc.o: nametype.h comfunc.o: qmath.h comfunc.o: zmath.h commath.o: alloc.h +commath.o: attribute.h commath.o: banned.h commath.o: byteswap.h commath.o: cmath.h @@ -5994,6 +6011,7 @@ commath.o: longbits.h commath.o: qmath.h commath.o: zmath.h config.o: alloc.h +config.o: attribute.h config.o: banned.h config.o: block.h config.o: byteswap.h @@ -6027,6 +6045,7 @@ config.o: value.h config.o: zmath.h config.o: zrand.h const.o: alloc.h +const.o: attribute.h const.o: banned.h const.o: block.h const.o: byteswap.h @@ -6052,6 +6071,7 @@ const.o: str.h const.o: value.h const.o: zmath.h custom.o: alloc.h +custom.o: attribute.h custom.o: banned.h custom.o: block.h custom.o: byteswap.h @@ -6083,6 +6103,7 @@ endian.o: have_ban_pragma.h endian.o: have_stdlib.h endian.o: have_unistd.h file.o: alloc.h +file.o: attribute.h file.o: banned.h file.o: block.h file.o: byteswap.h @@ -6128,6 +6149,7 @@ fposval.o: have_offscl.h fposval.o: have_posscl.h fposval.o: have_string.h func.o: alloc.h +func.o: attribute.h func.o: banned.h func.o: block.h func.o: byteswap.h @@ -6172,6 +6194,7 @@ func.o: zmath.h func.o: zrand.h func.o: zrandom.h hash.o: alloc.h +hash.o: attribute.h hash.o: banned.h hash.o: block.h hash.o: byteswap.h @@ -6316,6 +6339,7 @@ help.o: str.h help.o: value.h help.o: zmath.h hist.o: alloc.h +hist.o: attribute.h hist.o: banned.h hist.o: block.h hist.o: byteswap.h @@ -6349,6 +6373,7 @@ hist.o: strl.h hist.o: value.h hist.o: zmath.h input.o: alloc.h +input.o: attribute.h input.o: banned.h input.o: block.h input.o: byteswap.h @@ -6415,6 +6440,7 @@ label.o: token.h label.o: value.h label.o: zmath.h lib_calc.o: alloc.h +lib_calc.o: attribute.h lib_calc.o: banned.h lib_calc.o: block.h lib_calc.o: byteswap.h @@ -6454,6 +6480,7 @@ lib_calc.o: value.h lib_calc.o: zmath.h lib_calc.o: zrandom.h lib_util.o: alloc.h +lib_util.o: attribute.h lib_util.o: banned.h lib_util.o: byteswap.h lib_util.o: decl.h @@ -6469,6 +6496,7 @@ lib_util.o: lib_util.h lib_util.o: longbits.h lib_util.o: zmath.h listfunc.o: alloc.h +listfunc.o: attribute.h listfunc.o: banned.h listfunc.o: block.h listfunc.o: byteswap.h @@ -6501,6 +6529,7 @@ longbits.o: have_stdlib.h longbits.o: have_unistd.h longbits.o: longbits.c matfunc.o: alloc.h +matfunc.o: attribute.h matfunc.o: banned.h matfunc.o: block.h matfunc.o: byteswap.h @@ -6554,6 +6583,7 @@ math_error.o: str.h math_error.o: value.h math_error.o: zmath.h obj.o: alloc.h +obj.o: attribute.h obj.o: banned.h obj.o: block.h obj.o: byteswap.h @@ -6586,6 +6616,7 @@ obj.o: symbol.h obj.o: value.h obj.o: zmath.h opcodes.o: alloc.h +opcodes.o: attribute.h opcodes.o: banned.h opcodes.o: block.h opcodes.o: byteswap.h @@ -6680,6 +6711,7 @@ prime.o: prime.h prime.o: qmath.h prime.o: zmath.h qfunc.o: alloc.h +qfunc.o: attribute.h qfunc.o: banned.h qfunc.o: byteswap.h qfunc.o: config.h @@ -6699,6 +6731,7 @@ qfunc.o: qmath.h qfunc.o: zmath.h qio.o: alloc.h qio.o: args.h +qio.o: attribute.h qio.o: banned.h qio.o: byteswap.h qio.o: config.h @@ -6717,6 +6750,7 @@ qio.o: qio.c qio.o: qmath.h qio.o: zmath.h qmath.o: alloc.h +qmath.o: attribute.h qmath.o: banned.h qmath.o: byteswap.h qmath.o: config.h @@ -6734,6 +6768,7 @@ qmath.o: qmath.c qmath.o: qmath.h qmath.o: zmath.h qmod.o: alloc.h +qmod.o: attribute.h qmod.o: banned.h qmod.o: byteswap.h qmod.o: config.h @@ -6751,6 +6786,7 @@ qmod.o: qmath.h qmod.o: qmod.c qmod.o: zmath.h qtrans.o: alloc.h +qtrans.o: attribute.h qtrans.o: banned.h qtrans.o: byteswap.h qtrans.o: decl.h @@ -6766,6 +6802,7 @@ qtrans.o: qmath.h qtrans.o: qtrans.c qtrans.o: zmath.h quickhash.o: alloc.h +quickhash.o: attribute.h quickhash.o: banned.h quickhash.o: block.h quickhash.o: byteswap.h @@ -6792,6 +6829,7 @@ quickhash.o: zmath.h quickhash.o: zrand.h quickhash.o: zrandom.h sample_many.o: alloc.h +sample_many.o: attribute.h sample_many.o: banned.h sample_many.o: block.h sample_many.o: byteswap.h @@ -6819,6 +6857,7 @@ sample_many.o: value.h sample_many.o: zmath.h sample_many.o: zrandom.h sample_rand.o: alloc.h +sample_rand.o: attribute.h sample_rand.o: banned.h sample_rand.o: block.h sample_rand.o: byteswap.h @@ -6874,6 +6913,7 @@ seed.o: seed.c seed.o: zmath.h sha1.o: align32.h sha1.o: alloc.h +sha1.o: attribute.h sha1.o: banned.h sha1.o: block.h sha1.o: byteswap.h @@ -6898,6 +6938,7 @@ sha1.o: str.h sha1.o: value.h sha1.o: zmath.h size.o: alloc.h +size.o: attribute.h size.o: banned.h size.o: block.h size.o: byteswap.h @@ -6924,6 +6965,7 @@ size.o: zmath.h size.o: zrand.h size.o: zrandom.h str.o: alloc.h +str.o: attribute.h str.o: banned.h str.o: block.h str.o: byteswap.h @@ -6964,6 +7006,7 @@ strl.o: have_strlcpy.h strl.o: strl.c strl.o: strl.h symbol.o: alloc.h +symbol.o: attribute.h symbol.o: banned.h symbol.o: block.h symbol.o: byteswap.h @@ -6995,6 +7038,7 @@ symbol.o: value.h symbol.o: zmath.h token.o: alloc.h token.o: args.h +token.o: attribute.h token.o: banned.h token.o: block.h token.o: byteswap.h @@ -7022,6 +7066,7 @@ token.o: token.h token.o: value.h token.o: zmath.h value.o: alloc.h +value.o: attribute.h value.o: banned.h value.o: block.h value.o: byteswap.h @@ -7084,6 +7129,7 @@ version.o: value.h version.o: version.c version.o: zmath.h zfunc.o: alloc.h +zfunc.o: attribute.h zfunc.o: banned.h zfunc.o: byteswap.h zfunc.o: decl.h @@ -7099,6 +7145,7 @@ zfunc.o: zfunc.c zfunc.o: zmath.h zio.o: alloc.h zio.o: args.h +zio.o: attribute.h zio.o: banned.h zio.o: byteswap.h zio.o: config.h @@ -7116,6 +7163,7 @@ zio.o: qmath.h zio.o: zio.c zio.o: zmath.h zmath.o: alloc.h +zmath.o: attribute.h zmath.o: banned.h zmath.o: byteswap.h zmath.o: decl.h @@ -7130,6 +7178,7 @@ zmath.o: longbits.h zmath.o: zmath.c zmath.o: zmath.h zmod.o: alloc.h +zmod.o: attribute.h zmod.o: banned.h zmod.o: byteswap.h zmod.o: config.h @@ -7147,6 +7196,7 @@ zmod.o: qmath.h zmod.o: zmath.h zmod.o: zmod.c zmul.o: alloc.h +zmul.o: attribute.h zmul.o: banned.h zmul.o: byteswap.h zmul.o: config.h @@ -7164,6 +7214,7 @@ zmul.o: qmath.h zmul.o: zmath.h zmul.o: zmul.c zprime.o: alloc.h +zprime.o: attribute.h zprime.o: banned.h zprime.o: block.h zprime.o: byteswap.h @@ -7191,6 +7242,7 @@ zprime.o: zmath.h zprime.o: zprime.c zprime.o: zrand.h zrand.o: alloc.h +zrand.o: attribute.h zrand.o: banned.h zrand.o: block.h zrand.o: byteswap.h @@ -7217,6 +7269,7 @@ zrand.o: zmath.h zrand.o: zrand.c zrand.o: zrand.h zrandom.o: alloc.h +zrandom.o: attribute.h zrandom.o: banned.h zrandom.o: block.h zrandom.o: byteswap.h diff --git a/Makefile.simple b/Makefile.simple index a613bb7..05048a5 100644 --- a/Makefile.simple +++ b/Makefile.simple @@ -2,7 +2,7 @@ # # calc - arbitrary precision calculator # -# Copyright (C) 1999-2018,2021 Landon Curt Noll +# Copyright (C) 1999-2018,2021,2022 Landon Curt Noll # # SRC: Makefile.simple - non-GNU version # @@ -1472,7 +1472,7 @@ LIB_H_SRC= alloc.h banned.h blkcpy.h block.h byteswap.h calc.h cmath.h \ config.h custom.h decl.h file.h func.h hash.h hist.h jump.h \ label.h lib_util.h lib_calc.h nametype.h \ opcodes.h prime.h qmath.h sha1.h str.h strl.h \ - symbol.h token.h value.h zmath.h zrand.h zrandom.h + symbol.h token.h value.h zmath.h zrand.h zrandom.h attribute.h # we build these .h files during the make # @@ -1833,6 +1833,12 @@ LATE_TARGETS= calc.1 calc.usage \ # TARGETS= ${EARLY_TARGETS} ${BLD_TYPE} ${LATE_TARGETS} +# rules that are not files +# +PHONY= all calcliblist calc_version check chk clobber debug depend distdir \ + distlist hsrc install inst_files mkdebug rpm sample splint tags \ + uninstall win32_hsrc + ### # @@ -1842,6 +1848,8 @@ TARGETS= ${EARLY_TARGETS} ${BLD_TYPE} ${LATE_TARGETS} all: check_include ${BLD_TYPE} CHANGES +.PHONY: ${PHONY} + check_include: ${Q} if ! echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo "ERROR: Missing critical include file." 1>&2; \ @@ -5026,6 +5034,7 @@ calc-unsymlink: addop.o: addop.c addop.o: alloc.h +addop.o: attribute.h addop.o: banned.h addop.o: block.h addop.o: byteswap.h @@ -5061,6 +5070,7 @@ align32.o: have_unistd.h align32.o: longbits.h assocfunc.o: alloc.h assocfunc.o: assocfunc.c +assocfunc.o: attribute.h assocfunc.o: banned.h assocfunc.o: block.h assocfunc.o: byteswap.h @@ -5084,6 +5094,7 @@ assocfunc.o: str.h assocfunc.o: value.h assocfunc.o: zmath.h blkcpy.o: alloc.h +blkcpy.o: attribute.h blkcpy.o: banned.h blkcpy.o: blkcpy.c blkcpy.o: blkcpy.h @@ -5112,6 +5123,7 @@ blkcpy.o: str.h blkcpy.o: value.h blkcpy.o: zmath.h block.o: alloc.h +block.o: attribute.h block.o: banned.h block.o: block.c block.o: block.h @@ -5136,6 +5148,7 @@ block.o: str.h block.o: value.h block.o: zmath.h byteswap.o: alloc.h +byteswap.o: attribute.h byteswap.o: banned.h byteswap.o: byteswap.c byteswap.o: byteswap.h @@ -5153,6 +5166,7 @@ byteswap.o: qmath.h byteswap.o: zmath.h calc.o: alloc.h calc.o: args.h +calc.o: attribute.h calc.o: banned.h calc.o: block.h calc.o: byteswap.h @@ -5203,6 +5217,7 @@ charbit.o: charbit.c charbit.o: have_ban_pragma.h charbit.o: have_limits.h codegen.o: alloc.h +codegen.o: attribute.h codegen.o: banned.h codegen.o: block.h codegen.o: byteswap.h @@ -5239,6 +5254,7 @@ codegen.o: token.h codegen.o: value.h codegen.o: zmath.h comfunc.o: alloc.h +comfunc.o: attribute.h comfunc.o: banned.h comfunc.o: byteswap.h comfunc.o: cmath.h @@ -5257,6 +5273,7 @@ comfunc.o: nametype.h comfunc.o: qmath.h comfunc.o: zmath.h commath.o: alloc.h +commath.o: attribute.h commath.o: banned.h commath.o: byteswap.h commath.o: cmath.h @@ -5273,6 +5290,7 @@ commath.o: longbits.h commath.o: qmath.h commath.o: zmath.h config.o: alloc.h +config.o: attribute.h config.o: banned.h config.o: block.h config.o: byteswap.h @@ -5306,6 +5324,7 @@ config.o: value.h config.o: zmath.h config.o: zrand.h const.o: alloc.h +const.o: attribute.h const.o: banned.h const.o: block.h const.o: byteswap.h @@ -5331,6 +5350,7 @@ const.o: str.h const.o: value.h const.o: zmath.h custom.o: alloc.h +custom.o: attribute.h custom.o: banned.h custom.o: block.h custom.o: byteswap.h @@ -5362,6 +5382,7 @@ endian.o: have_ban_pragma.h endian.o: have_stdlib.h endian.o: have_unistd.h file.o: alloc.h +file.o: attribute.h file.o: banned.h file.o: block.h file.o: byteswap.h @@ -5407,6 +5428,7 @@ fposval.o: have_offscl.h fposval.o: have_posscl.h fposval.o: have_string.h func.o: alloc.h +func.o: attribute.h func.o: banned.h func.o: block.h func.o: byteswap.h @@ -5451,6 +5473,7 @@ func.o: zmath.h func.o: zrand.h func.o: zrandom.h hash.o: alloc.h +hash.o: attribute.h hash.o: banned.h hash.o: block.h hash.o: byteswap.h @@ -5595,6 +5618,7 @@ help.o: str.h help.o: value.h help.o: zmath.h hist.o: alloc.h +hist.o: attribute.h hist.o: banned.h hist.o: block.h hist.o: byteswap.h @@ -5628,6 +5652,7 @@ hist.o: strl.h hist.o: value.h hist.o: zmath.h input.o: alloc.h +input.o: attribute.h input.o: banned.h input.o: block.h input.o: byteswap.h @@ -5694,6 +5719,7 @@ label.o: token.h label.o: value.h label.o: zmath.h lib_calc.o: alloc.h +lib_calc.o: attribute.h lib_calc.o: banned.h lib_calc.o: block.h lib_calc.o: byteswap.h @@ -5733,6 +5759,7 @@ lib_calc.o: value.h lib_calc.o: zmath.h lib_calc.o: zrandom.h lib_util.o: alloc.h +lib_util.o: attribute.h lib_util.o: banned.h lib_util.o: byteswap.h lib_util.o: decl.h @@ -5748,6 +5775,7 @@ lib_util.o: lib_util.h lib_util.o: longbits.h lib_util.o: zmath.h listfunc.o: alloc.h +listfunc.o: attribute.h listfunc.o: banned.h listfunc.o: block.h listfunc.o: byteswap.h @@ -5780,6 +5808,7 @@ longbits.o: have_stdlib.h longbits.o: have_unistd.h longbits.o: longbits.c matfunc.o: alloc.h +matfunc.o: attribute.h matfunc.o: banned.h matfunc.o: block.h matfunc.o: byteswap.h @@ -5833,6 +5862,7 @@ math_error.o: str.h math_error.o: value.h math_error.o: zmath.h obj.o: alloc.h +obj.o: attribute.h obj.o: banned.h obj.o: block.h obj.o: byteswap.h @@ -5865,6 +5895,7 @@ obj.o: symbol.h obj.o: value.h obj.o: zmath.h opcodes.o: alloc.h +opcodes.o: attribute.h opcodes.o: banned.h opcodes.o: block.h opcodes.o: byteswap.h @@ -5959,6 +5990,7 @@ prime.o: prime.h prime.o: qmath.h prime.o: zmath.h qfunc.o: alloc.h +qfunc.o: attribute.h qfunc.o: banned.h qfunc.o: byteswap.h qfunc.o: config.h @@ -5978,6 +6010,7 @@ qfunc.o: qmath.h qfunc.o: zmath.h qio.o: alloc.h qio.o: args.h +qio.o: attribute.h qio.o: banned.h qio.o: byteswap.h qio.o: config.h @@ -5996,6 +6029,7 @@ qio.o: qio.c qio.o: qmath.h qio.o: zmath.h qmath.o: alloc.h +qmath.o: attribute.h qmath.o: banned.h qmath.o: byteswap.h qmath.o: config.h @@ -6013,6 +6047,7 @@ qmath.o: qmath.c qmath.o: qmath.h qmath.o: zmath.h qmod.o: alloc.h +qmod.o: attribute.h qmod.o: banned.h qmod.o: byteswap.h qmod.o: config.h @@ -6030,6 +6065,7 @@ qmod.o: qmath.h qmod.o: qmod.c qmod.o: zmath.h qtrans.o: alloc.h +qtrans.o: attribute.h qtrans.o: banned.h qtrans.o: byteswap.h qtrans.o: decl.h @@ -6045,6 +6081,7 @@ qtrans.o: qmath.h qtrans.o: qtrans.c qtrans.o: zmath.h quickhash.o: alloc.h +quickhash.o: attribute.h quickhash.o: banned.h quickhash.o: block.h quickhash.o: byteswap.h @@ -6071,6 +6108,7 @@ quickhash.o: zmath.h quickhash.o: zrand.h quickhash.o: zrandom.h sample_many.o: alloc.h +sample_many.o: attribute.h sample_many.o: banned.h sample_many.o: block.h sample_many.o: byteswap.h @@ -6098,6 +6136,7 @@ sample_many.o: value.h sample_many.o: zmath.h sample_many.o: zrandom.h sample_rand.o: alloc.h +sample_rand.o: attribute.h sample_rand.o: banned.h sample_rand.o: block.h sample_rand.o: byteswap.h @@ -6153,6 +6192,7 @@ seed.o: seed.c seed.o: zmath.h sha1.o: align32.h sha1.o: alloc.h +sha1.o: attribute.h sha1.o: banned.h sha1.o: block.h sha1.o: byteswap.h @@ -6177,6 +6217,7 @@ sha1.o: str.h sha1.o: value.h sha1.o: zmath.h size.o: alloc.h +size.o: attribute.h size.o: banned.h size.o: block.h size.o: byteswap.h @@ -6203,6 +6244,7 @@ size.o: zmath.h size.o: zrand.h size.o: zrandom.h str.o: alloc.h +str.o: attribute.h str.o: banned.h str.o: block.h str.o: byteswap.h @@ -6243,6 +6285,7 @@ strl.o: have_strlcpy.h strl.o: strl.c strl.o: strl.h symbol.o: alloc.h +symbol.o: attribute.h symbol.o: banned.h symbol.o: block.h symbol.o: byteswap.h @@ -6274,6 +6317,7 @@ symbol.o: value.h symbol.o: zmath.h token.o: alloc.h token.o: args.h +token.o: attribute.h token.o: banned.h token.o: block.h token.o: byteswap.h @@ -6301,6 +6345,7 @@ token.o: token.h token.o: value.h token.o: zmath.h value.o: alloc.h +value.o: attribute.h value.o: banned.h value.o: block.h value.o: byteswap.h @@ -6363,6 +6408,7 @@ version.o: value.h version.o: version.c version.o: zmath.h zfunc.o: alloc.h +zfunc.o: attribute.h zfunc.o: banned.h zfunc.o: byteswap.h zfunc.o: decl.h @@ -6378,6 +6424,7 @@ zfunc.o: zfunc.c zfunc.o: zmath.h zio.o: alloc.h zio.o: args.h +zio.o: attribute.h zio.o: banned.h zio.o: byteswap.h zio.o: config.h @@ -6395,6 +6442,7 @@ zio.o: qmath.h zio.o: zio.c zio.o: zmath.h zmath.o: alloc.h +zmath.o: attribute.h zmath.o: banned.h zmath.o: byteswap.h zmath.o: decl.h @@ -6409,6 +6457,7 @@ zmath.o: longbits.h zmath.o: zmath.c zmath.o: zmath.h zmod.o: alloc.h +zmod.o: attribute.h zmod.o: banned.h zmod.o: byteswap.h zmod.o: config.h @@ -6426,6 +6475,7 @@ zmod.o: qmath.h zmod.o: zmath.h zmod.o: zmod.c zmul.o: alloc.h +zmul.o: attribute.h zmul.o: banned.h zmul.o: byteswap.h zmul.o: config.h @@ -6443,6 +6493,7 @@ zmul.o: qmath.h zmul.o: zmath.h zmul.o: zmul.c zprime.o: alloc.h +zprime.o: attribute.h zprime.o: banned.h zprime.o: block.h zprime.o: byteswap.h @@ -6470,6 +6521,7 @@ zprime.o: zmath.h zprime.o: zprime.c zprime.o: zrand.h zrand.o: alloc.h +zrand.o: attribute.h zrand.o: banned.h zrand.o: block.h zrand.o: byteswap.h @@ -6496,6 +6548,7 @@ zrand.o: zmath.h zrand.o: zrand.c zrand.o: zrand.h zrandom.o: alloc.h +zrandom.o: attribute.h zrandom.o: banned.h zrandom.o: block.h zrandom.o: byteswap.h diff --git a/addop.c b/addop.c index 7255142..2005075 100644 --- a/addop.c +++ b/addop.c @@ -1,7 +1,7 @@ /* * addop - add opcodes to a function being compiled * - * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -37,6 +37,7 @@ #include "symbol.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -68,12 +69,12 @@ initfunctions(void) functemplate = (FUNC *) malloc(funcsize(maxopcodes)); if (functemplate == NULL) { math_error("Cannot allocate function template"); - /*NOTREACHED*/ + not_reached(); } functions = (FUNC **) malloc(sizeof(FUNC *) * FUNCALLOCSIZE); if (functions == NULL) { math_error("Cannot allocate function table"); - /*NOTREACHED*/ + not_reached(); } funccount = 0; funcavail = FUNCALLOCSIZE; @@ -155,7 +156,7 @@ beginfunc(char *name, BOOL newflag) fp = (FUNC *) malloc(funcsize(maxopcodes)); if (fp == NULL) { math_error("Cannot allocate temporary function"); - /*NOTREACHED*/ + not_reached(); } } fp->f_next = NULL; @@ -203,7 +204,7 @@ endfunc(void) fp = (FUNC *) malloc(size); if (fp == NULL) { math_error("Cannot commit function"); - /*NOTREACHED*/ + not_reached(); } memcpy((char *) fp, (char *) curfunc, size); if (curfunc != functemplate) @@ -257,13 +258,13 @@ adduserfunc(char *name) sizeof(FUNC *) * (funcavail + FUNCALLOCSIZE)); if (functions == NULL) { math_error("Failed to reallocate function table"); - /*NOTREACHED*/ + not_reached(); } funcavail += FUNCALLOCSIZE; } if (addstr(&funcnames, name) == NULL) { math_error("Cannot save function name"); - /*NOTREACHED*/ + not_reached(); } index = funccount++; functions[index] = NULL; @@ -316,7 +317,7 @@ freefunc(FUNC *fp) } if (index == funccount) { math_error("Bad call to freefunc!!!"); - /*NOTREACHED*/ + not_reached(); } } if (newname[0] != '*' && (conf->traceflags & TRACE_FNCODES)) { @@ -386,7 +387,7 @@ findfunc(long index) { if (index >= funccount) { math_error("Undefined function"); - /*NOTREACHED*/ + not_reached(); } return functions[index]; } @@ -438,7 +439,7 @@ addop(long op) fp = (FUNC *) malloc(funcsize(maxopcodes)); if (fp == NULL) { math_error("cannot malloc function"); - /*NOTREACHED*/ + not_reached(); } memcpy((char *) fp, (char *) curfunc, funcsize(curfunc->f_opcodecount)); diff --git a/assocfunc.c b/assocfunc.c index 1ad522f..f481d8b 100644 --- a/assocfunc.c +++ b/assocfunc.c @@ -1,7 +1,7 @@ /* * assocfunc - association table routines * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -36,6 +36,7 @@ #include "value.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -74,7 +75,7 @@ associndex(ASSOC *ap, BOOL create, long dim, VALUE *indices) if (dim < 0) { math_error("Negative dimension for indexing association"); - /*NOTREACHED*/ + not_reached(); } /* @@ -112,7 +113,7 @@ associndex(ASSOC *ap, BOOL create, long dim, VALUE *indices) ep = (ASSOCELEM *) malloc(ELEMSIZE(dim)); if (ep == NULL) { math_error("Cannot allocate association element"); - /*NOTREACHED*/ + not_reached(); } ep->e_dim = dim; ep->e_hash = hash; @@ -142,13 +143,13 @@ assocsearch(ASSOC *ap, VALUE *vp, long i, long j, ZVALUE *index) if (i < 0 || j > ap->a_count) { math_error("This should not happen in assocsearch"); - /*NOTREACHED*/ + not_reached(); } while (i < j) { ep = elemindex(ap, i); if (ep == NULL) { math_error("This should not happen in assocsearch"); - /*NOTREACHED*/ + not_reached(); } if (acceptvalue(&ep->e_value, vp)) { utoz(i, index); @@ -172,14 +173,14 @@ assocrsearch(ASSOC *ap, VALUE *vp, long i, long j, ZVALUE *index) if (i < 0 || j > ap->a_count) { math_error("This should not happen in assocsearch"); - /*NOTREACHED*/ + not_reached(); } j--; while (j >= i) { ep = elemindex(ap, j); if (ep == NULL) { math_error("This should not happen in assocsearch"); - /*NOTREACHED*/ + not_reached(); } if (acceptvalue(&ep->e_value, vp)) { utoz(j, index); @@ -333,7 +334,7 @@ assoccopy(ASSOC *oldap) if (ep == NULL) { math_error("Cannot allocate " "association element"); - /*NOTREACHED*/ + not_reached(); } ep->e_dim = oldep->e_dim; ep->e_hash = oldep->e_hash; @@ -374,7 +375,7 @@ resize(ASSOC *ap, long newsize) newtable = (ASSOCELEM **) malloc(sizeof(ASSOCELEM *) * newsize); if (newtable == NULL) { math_error("No memory to grow association"); - /*NOTREACHED*/ + not_reached(); } for (i = 0; i < newsize; i++) newtable[i] = NULL; @@ -430,7 +431,7 @@ assocalloc(long initsize) ap = (ASSOC *) malloc(sizeof(ASSOC)); if (ap == NULL) { math_error("No memory for association"); - /*NOTREACHED*/ + not_reached(); } ap->a_count = 0; ap->a_size = initsize; @@ -438,7 +439,7 @@ assocalloc(long initsize) if (ap->a_table == NULL) { free((char *) ap); math_error("No memory for association"); - /*NOTREACHED*/ + not_reached(); } for (i = 0; i < initsize; i++) ap->a_table[i] = NULL; diff --git a/attribute.h b/attribute.h new file mode 100644 index 0000000..feb5497 --- /dev/null +++ b/attribute.h @@ -0,0 +1,69 @@ +/* + * attribute - control use of attributes in a backward compatible way + * + * Copyright (C) 2022 Landon Curt Noll + * + * Calc is open software; you can redistribute it and/or modify it under + * the terms of the version 2.1 of the GNU Lesser General Public License + * as published by the Free Software Foundation. + * + * Calc is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + * Public License for more details. + * + * A copy of version 2.1 of the GNU Lesser General Public License is + * distributed with calc under the filename COPYING-LGPL. You should have + * received a copy with calc; if not, write to Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Under source code control: 2022/01/21 22:51:25 + * File existed as early as: 2022 + * + * chongo /\oo/\ http://www.isthe.com/chongo/ + * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ + */ + + +#if !defined(INCLUDE_ATTRIBUTE_H) +#define INCLUDE_ATTRIBUTE_H + + +/* + * backward compatibility + * + * Not all compilers support __attribute__ nor do they suuport __has_builtin. + * For example, MSVC, TenDRAm and Little C Compiler doesn't support __attribute__. + * Early gcc does not support __attribute__. + * + * Not all compiles have __has_builtin + */ +#if !defined(__attribute__) && \ + (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) +# define __attribute__(A) +#endif +#if !defined __has_builtin +# define __has_builtin(x) 0 +#endif + + +/* + * not_reached + * + * In the old days of lint, one could give lint and friends a hint by + * placing the token NOTREACHED immediately between opening and closing + * comments. Modern compilers do not honor such commented tokens + * and instead rely on features such as __builtin_unreachable + * and __attribute__((noreturn)). + * + * The not_reached will either yield a __builtin_unreachable() feature call, + * or it will call abort from stdlib. + */ +#if __has_builtin(__builtin_unreachable) +# define not_reached() __builtin_unreachable() +#else +# define not_reached() abort() +#endif /* __has_builtin(__builtin_unreachable) */ + + +#endif /* !INCLUDE_ATTRIBUTE_H */ diff --git a/blkcpy.c b/blkcpy.c index 40d384e..9ecdcee 100644 --- a/blkcpy.c +++ b/blkcpy.c @@ -1,7 +1,7 @@ /* * blkcpy - general values and related routines used by the calculator * - * Copyright (C) 1999-2007,2021 Landon Curt Noll and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll and Ernest Bowen * * Primary author: Landon Curt Noll * @@ -36,6 +36,7 @@ #include "str.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -298,7 +299,7 @@ copymat2mat(MATRIX *smat, long ssi, long num, MATRIX *dmat, long dsi) vtemp = (VALUE *) malloc(num * sizeof(VALUE)); if (vtemp == NULL) { math_error("Out of memory for mat-to-mat copy"); - /*NOTREACHED*/ + not_reached(); } vp = smat->m_table + ssi; vq = vtemp; @@ -347,7 +348,7 @@ copyblk2mat(BLOCK *blk, long ssi, long num, MATRIX *dmat, long dsi) vtemp = (VALUE *) malloc(num * sizeof(VALUE)); if (vtemp == NULL) { math_error("Out of memory for block-to-matrix copy"); - /*NOTREACHED*/ + not_reached(); } vp = vtemp; i = num; @@ -404,7 +405,7 @@ copymat2blk(MATRIX *smat, long ssi, long num, BLOCK *dblk, long dsi, newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { math_error("Out of memory for matrix-to-block copy"); - /*NOTREACHED*/ + not_reached(); } dblk->data = newdata; dblk->maxsize = newsize; @@ -447,7 +448,7 @@ copymat2list(MATRIX *smat, long ssi, long num, LIST *lp, long dsi) vtemp = (VALUE *) malloc(num * sizeof(VALUE)); if (vtemp == NULL) { math_error("Out of memory for matrix-to-list copy"); - /*NOTREACHED*/ + not_reached(); } vp = smat->m_table + ssi; vq = vtemp; @@ -497,7 +498,7 @@ copylist2mat(LIST *lp, long ssi, long num, MATRIX *dmat, long dsi) vtemp = (VALUE *) malloc(num * sizeof(VALUE)); if (vtemp == NULL) { math_error("Out of memory for list-to-matrix copy"); - /*NOTREACHED*/ + not_reached(); } ep = listelement(lp, (long) ssi); vp = vtemp; @@ -547,7 +548,7 @@ copylist2list(LIST *slp, long ssi, long num, LIST *dlp, long dsi) vtemp = (VALUE *) malloc(num * sizeof(VALUE)); if (vtemp == NULL) { math_error("Out of memory for list-to-list copy"); - /*NOTREACHED*/ + not_reached(); } sep = listelement(slp, (long) ssi); vp = vtemp; @@ -662,7 +663,7 @@ copyfile2blk(FILEID id, long ssi, long num, BLOCK *dblk, long dsi, BOOL noreloc) newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { math_error("Out of memory for block-to-block copy"); - /*NOTREACHED*/ + not_reached(); } dblk->data = newdata; dblk->maxsize = newsize; @@ -748,7 +749,7 @@ copyblk2blk(BLOCK *sblk, long ssi, long num, BLOCK *dblk, long dsi, newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { math_error("Out of memory for block-to-block copy"); - /*NOTREACHED*/ + not_reached(); } dblk->data = newdata; dblk->maxsize = newsize; @@ -792,7 +793,7 @@ copystr2blk(STRING *str, long ssi, long num, BLOCK *dblk, long dsi, newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { math_error("Out of memory for string-to-block copy"); - /*NOTREACHED*/ + not_reached(); } dblk->data = newdata; dblk->maxsize = newsize; @@ -913,7 +914,7 @@ copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,BOOL noreloc) newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { math_error("Out of memory for string-to-block copy"); - /*NOTREACHED*/ + not_reached(); } dblk->data = newdata; dblk->maxsize = newsize; @@ -945,7 +946,7 @@ memmove(void *s1, CONST void *s2, MEMMOVE_SIZE_T n) */ if (s1 == NULL || s2 == NULL) { math_error("bogus memmove NULL ptr"); - /*NOTREACHED*/ + not_reached(); } if (n <= 0) { /* neg or 0 count does nothing */ @@ -1015,7 +1016,7 @@ copynum2blk(NUMBER *snum, long ssi, long num, BLOCK *dblk, long dsi, newdata = (USB8*) realloc(dblk->data, newsize); if (newdata == NULL) { math_error("Out of memory for num-to-block copy"); - /*NOTREACHED*/ + not_reached(); } dblk->data = newdata; dblk->maxsize = newsize; @@ -1086,7 +1087,7 @@ copyblk2num(BLOCK *sblk, long ssi, long num, NUMBER *dnum, long dsi, swapped = (HALF *)malloc(halflen * sizeof(HALF)); if (swapped == NULL) { math_error("Out of memory for block-to-num copy"); - /*NOTREACHED*/ + not_reached(); } /* ensure that any trailing octets will be zero filled */ swapped[halflen-1] = 0; diff --git a/block.c b/block.c index c2b439a..ddcacf1 100644 --- a/block.c +++ b/block.c @@ -1,7 +1,7 @@ /* * block - fixed, dynamic, fifo and circular memory blocks * - * Copyright (C) 1999-2007,2021 Landon Curt Noll and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll and Ernest Bowen * * Primary author: Landon Curt Noll * @@ -42,6 +42,7 @@ #include "calcerr.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -87,7 +88,7 @@ blkalloc(int len, int chunk) nblk = (BLOCK *)malloc(sizeof(BLOCK)); if (nblk == NULL) { math_error("cannot allocate block"); - /*NOTREACHED*/ + not_reached(); } /* @@ -98,7 +99,7 @@ blkalloc(int len, int chunk) nblk->data = (USB8*)malloc(nblk->maxsize); if (nblk->data == NULL) { math_error("cannot allocate block data storage"); - /*NOTREACHED*/ + not_reached(); } memset(nblk->data, 0, nblk->maxsize); nblk->datalen = len; @@ -172,7 +173,7 @@ blkchk(BLOCK *blk) } if (blk == NULL) { math_error("internal: blk ptr is NULL"); - /*NOTREACHED*/ + not_reached(); } /* @@ -180,7 +181,7 @@ blkchk(BLOCK *blk) */ if (blk->data == NULL) { math_error("internal: blk->data ptr is NULL"); - /*NOTREACHED*/ + not_reached(); } /* @@ -188,7 +189,7 @@ blkchk(BLOCK *blk) */ if (blk->datalen < 0) { math_error("internal: blk->datalen < 0"); - /*NOTREACHED*/ + not_reached(); } /* @@ -196,7 +197,7 @@ blkchk(BLOCK *blk) */ if (blk->datalen < 0) { math_error("internal: blk->datalen < 0"); - /*NOTREACHED*/ + not_reached(); } return; } @@ -259,7 +260,7 @@ blkrealloc(BLOCK *blk, int newlen, int newchunk) nblk = (USB8*)realloc(blk->data, newmax); if (nblk == NULL) { math_error("cannot reallocate block storage"); - /*NOTREACHED*/ + not_reached(); } /* clear any new storage */ @@ -367,7 +368,7 @@ blktrunc(BLOCK *blk) blk->data = (USB8*)malloc(1); if (blk->data == NULL) { math_error("cannot allocate truncated block storage"); - /*NOTREACHED*/ + not_reached(); } blk->data[0] = (USB8)0; if (conf->calc_debug & CALCDBG_BLOCK) { @@ -397,7 +398,7 @@ blk_copy(BLOCK *blk) nblk = (BLOCK *)malloc(sizeof(BLOCK)); if (nblk == NULL) { math_error("blk_copy: cannot malloc BLOCK"); - /*NOTREACHED*/ + not_reached(); } /* @@ -411,7 +412,7 @@ blk_copy(BLOCK *blk) nblk->data = (USB8 *)malloc(blk->maxsize); if (nblk->data == NULL) { math_error("blk_copy: cannot duplicate block data"); - /*NOTREACHED*/ + not_reached(); } memcpy(nblk->data, blk->data, blk->maxsize); return nblk; @@ -539,7 +540,7 @@ reallocnblock(int id, int len, int chunk) /* Fire wall */ if (id < 0 || id >= nblockcount) { math_error("Bad id in call to reallocnblock"); - /*NOTREACHED*/ + not_reached(); } blk = nblocks[id]->blk; @@ -556,13 +557,13 @@ reallocnblock(int id, int len, int chunk) newdata = malloc(newsize); if (newdata == NULL) { math_error("Allocation failed"); - /*NOTREACHED*/ + not_reached(); } } else if (newsize != oldsize) { newdata = realloc(blk->data, newsize); if (newdata == NULL) { math_error("Reallocation failed"); - /*NOTREACHED*/ + not_reached(); } } memset(newdata + len, 0, newsize - len); @@ -593,7 +594,7 @@ createnblock(char *name, int len, int chunk) if (nblocks == NULL) { maxnblockcount = 0; math_error("unable to malloc new named blocks"); - /*NOTREACHED*/ + not_reached(); } } else { maxnblockcount += NBLOCKCHUNK; @@ -602,7 +603,7 @@ createnblock(char *name, int len, int chunk) if (nblocks == NULL) { maxnblockcount = 0; math_error("cannot malloc more named blocks"); - /*NOTREACHED*/ + not_reached(); } } } @@ -610,18 +611,18 @@ createnblock(char *name, int len, int chunk) initstr(&nblocknames); if (findstr(&nblocknames, name) >= 0) { math_error("Named block already exists!!!"); - /*NOTREACHED*/ + not_reached(); } newname = addstr(&nblocknames, name); if (newname == NULL) { math_error("Block name allocation failed"); - /*NOTREACHED*/ + not_reached(); } res = (NBLOCK *) malloc(sizeof(NBLOCK)); if (res == NULL) { math_error("Named block allocation failed"); - /*NOTREACHED*/ + not_reached(); } nblocks[nblockcount] = res; diff --git a/byteswap.c b/byteswap.c index 369db46..c1c5e55 100644 --- a/byteswap.c +++ b/byteswap.c @@ -1,7 +1,7 @@ /* * byteswap - byte swapping routines * - * Copyright (C) 1999,2021 Landon Curt Noll + * Copyright (C) 1999,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -29,6 +29,7 @@ #include "byteswap.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -103,7 +104,7 @@ swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all) if (dest == NULL) { math_error("swap_b8_in_ZVALUE: swap_b8_in_ZVALUE: " "Not enough memory"); - /*NOTREACHED*/ + not_reached(); } /* @@ -170,7 +171,7 @@ swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all) dest = malloc(sizeof(NUMBER)); if (dest == NULL) { math_error("swap_b8_in_NUMBER: Not enough memory"); - /*NOTREACHED*/ + not_reached(); } /* @@ -234,7 +235,7 @@ swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all) dest = malloc(sizeof(COMPLEX)); if (dest == NULL) { math_error("swap_b8_in_COMPLEX: Not enough memory"); - /*NOTREACHED*/ + not_reached(); } /* @@ -338,7 +339,7 @@ swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all) dest = malloc(sizeof(ZVALUE)); if (dest == NULL) { math_error("swap_b16_in_ZVALUE: Not enough memory"); - /*NOTREACHED*/ + not_reached(); } /* @@ -405,7 +406,7 @@ swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all) dest = malloc(sizeof(NUMBER)); if (dest == NULL) { math_error("swap_b16_in_NUMBER: Not enough memory"); - /*NOTREACHED*/ + not_reached(); } /* @@ -469,7 +470,7 @@ swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all) dest = malloc(sizeof(COMPLEX)); if (dest == NULL) { math_error("swap_b16_in_COMPLEX: Not enough memory"); - /*NOTREACHED*/ + not_reached(); } /* @@ -533,7 +534,7 @@ swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all) dest = malloc(sizeof(ZVALUE)); if (dest == NULL) { math_error("swap_HALF_in_ZVALUE: Not enough memory"); - /*NOTREACHED*/ + not_reached(); } /* @@ -601,7 +602,7 @@ swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all) dest = malloc(sizeof(NUMBER)); if (dest == NULL) { math_error("swap_HALF_in_NUMBER: Not enough memory"); - /*NOTREACHED*/ + not_reached(); } /* @@ -665,7 +666,7 @@ swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all) dest = malloc(sizeof(COMPLEX)); if (dest == NULL) { math_error("swap_HALF_in_COMPLEX: Not enough memory"); - /*NOTREACHED*/ + not_reached(); } /* diff --git a/cal/Makefile b/cal/Makefile index 0e9a01d..6ffa16c 100644 --- a/cal/Makefile +++ b/cal/Makefile @@ -2,7 +2,7 @@ # # cal - makefile for calc standard resource files # -# Copyright (C) 1999-2006,2017,2021 Landon Curt Noll +# Copyright (C) 1999-2006,2017,2021,2022 Landon Curt Noll # # SRC: cal/Makefile # @@ -293,6 +293,10 @@ DISTLIST= ${CALC_FILES} ${MAKE_FILE} # These files are used to make (but not built) a calc .a link library # CALCLIBLIST= +# +# rules that are not also names of files +# +PHONY= all clobber distlist install all: ${CALC_FILES} ${MAKE_FILE} .all @@ -302,6 +306,8 @@ all: ${CALC_FILES} ${MAKE_FILE} .all ${RM} -f .all ${TOUCH} .all +.PHONY: ${PHONY} + ## # # File list generation. You can ignore this section. diff --git a/calc.c b/calc.c index 5ff1d2c..3f574cb 100644 --- a/calc.c +++ b/calc.c @@ -1,8 +1,7 @@ /* * calc - arbitrary precision calculator * - * Copyright (C) 1999-2013,2021 David I. Bell, Landon Curt Noll - * and Ernest Bowen + * Copyright (C) 1999-2013,2021,2022 David I. Bell, Landon Curt Noll and Ernest Bowen * * Primary author: David I. Bell * @@ -85,6 +84,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -786,7 +786,7 @@ intint(int UNUSED(arg)) (void) signal(SIGINT, intint); if (inputwait || (++abortlevel >= ABORT_NOW)) { calc_interrupt("\nABORT"); - /*NOTREACHED*/ + not_reached(); } if (abortlevel >= ABORT_MATH) _math_abort_ = TRUE; diff --git a/codegen.c b/codegen.c index 0867b1f..ae3b24e 100644 --- a/codegen.c +++ b/codegen.c @@ -1,7 +1,7 @@ /* * codegen - module to generate opcodes from the input tokens * - * Copyright (C) 1999-2007,2017,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2017,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -51,6 +51,7 @@ #endif +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -2383,16 +2384,16 @@ getfilename(char *name, size_t namelen, BOOL *once) if (symstr == NULL) { math_error( "string value pointer is NULL!!"); - /*NOTREACHED*/ + not_reached(); } } else { math_error( "a filename variable must be a string"); - /*NOTREACHED*/ + not_reached(); } } else { math_error("no such global variable"); - /*NOTREACHED*/ + not_reached(); } } diff --git a/comfunc.c b/comfunc.c index c4ffd7d..4a5770e 100644 --- a/comfunc.c +++ b/comfunc.c @@ -1,7 +1,7 @@ /* * comfunc - extended precision complex arithmetic non-primitive routines * - * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -30,6 +30,7 @@ #include "cmath.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -60,16 +61,16 @@ c_powi(COMPLEX *c, NUMBER *q) if (qisfrac(q)) { math_error("Raising number to non-integral power"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(q->num)) { math_error("Raising number to very large power"); - /*NOTREACHED*/ + not_reached(); } power = ztolong(q->num); if (ciszero(c) && (power == 0)) { math_error("Raising zero to zeroth power"); - /*NOTREACHED*/ + not_reached(); } sign = 1; if (qisneg(q)) @@ -381,7 +382,7 @@ c_root(COMPLEX *c, NUMBER *q, NUMBER *epsilon) if (qisneg(q) || qiszero(q) || qisfrac(q)) { math_error("Taking bad root of complex number"); - /*NOTREACHED*/ + not_reached(); } if (cisone(c) || qisone(q)) return clink(c); @@ -446,7 +447,7 @@ c_exp(COMPLEX *c, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon for cexp"); - /*NOTREACHED*/ + not_reached(); } if (cisreal(c)) { tmp1 = qexp(c->real, epsilon); @@ -502,7 +503,7 @@ c_ln(COMPLEX *c, NUMBER *epsilon) if (ciszero(c)) { math_error("logarithm of zero"); - /*NOTREACHED*/ + not_reached(); } if (cisone(c)) return clink(&_czero_); @@ -599,7 +600,7 @@ c_cos(COMPLEX *c, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon for ccos"); - /*NOTREACHED*/ + not_reached(); } n = qilog2(epsilon); ctmp1 = comalloc(); @@ -649,7 +650,7 @@ c_sin(COMPLEX *c, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon for csin"); - /*NOTREACHED*/ + not_reached(); } if (ciszero(c)) return clink(&_czero_); @@ -1072,7 +1073,7 @@ c_polar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon for cpolar"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q1)) return clink(&_czero_); @@ -1114,12 +1115,12 @@ c_power(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon for cpower"); - /*NOTREACHED*/ + not_reached(); } if (ciszero(c1)) { if (cisreal(c2) && qisneg(c2->real)) { math_error ("Non-positive real exponent of zero"); - /*NOTREACHED*/ + not_reached(); } return clink(&_czero_); } diff --git a/commath.c b/commath.c index 1879140..32e0f51 100644 --- a/commath.c +++ b/commath.c @@ -1,7 +1,7 @@ /* * commath - extended precision complex arithmetic primitive routines * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -27,6 +27,7 @@ #include "cmath.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -189,7 +190,7 @@ c_div(COMPLEX *c1, COMPLEX *c2) if (ciszero(c2)) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } if ((c1->real == c2->real) && (c1->imag == c2->imag)) return clink(&_cone_); @@ -260,7 +261,7 @@ c_inv(COMPLEX *c) if (ciszero(c)) { math_error("Inverting zero"); - /*NOTREACHED*/ + not_reached(); } r = comalloc(); if (cisreal(c)) { @@ -522,7 +523,7 @@ c_divq(COMPLEX *c, NUMBER *q) if (qiszero(q)) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } if (qisone(q)) return clink(c); @@ -605,7 +606,7 @@ comalloc(void) r = (COMPLEX *) malloc(sizeof(COMPLEX)); if (r == NULL) { math_error("Cannot allocate complex number"); - /*NOTREACHED*/ + not_reached(); } r->links = 1; r->real = qlink(&_qzero_); diff --git a/config.c b/config.c index 55f15eb..6d0a1bc 100644 --- a/config.c +++ b/config.c @@ -1,7 +1,7 @@ /* * config - configuration routines * - * Copyright (C) 1999-2007,2021 David I. Bell and Landon Curt Noll + * Copyright (C) 1999-2007,2021,2022 David I. Bell and Landon Curt Noll * * Primary author: David I. Bell * @@ -62,6 +62,7 @@ #endif /* HAVE_STRDUP */ +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -488,11 +489,11 @@ setconfig(int type, VALUE *vp) newconf = &newstd; } else { math_error("CONFIG alias not oldstd or newstd"); - /*NOTREACHED*/ + not_reached(); } } else if (vp->v_type != V_CONFIG) { math_error("non-CONFIG for all"); - /*NOTREACHED*/ + not_reached(); } else { newconf = vp->v_config; } @@ -507,14 +508,14 @@ setconfig(int type, VALUE *vp) case CONFIG_TRACE: if (vp->v_type != V_NUM) { math_error("Non-numeric for trace"); - /*NOTREACHED*/ + not_reached(); } q = vp->v_num; temp = qtoi(q); if (qisfrac(q) || !zistiny(q->num) || ((unsigned long) temp > TRACE_MAX)) { math_error("Bad trace value"); - /*NOTREACHED*/ + not_reached(); } conf->traceflags = (FLAG)temp; break; @@ -522,7 +523,7 @@ setconfig(int type, VALUE *vp) case CONFIG_DISPLAY: if (getlen(vp, &len)) { math_error("Bad value for display"); - /*NOTREACHED*/ + not_reached(); } math_setdigits(len); break; @@ -530,12 +531,12 @@ setconfig(int type, VALUE *vp) case CONFIG_MODE: if (vp->v_type != V_STR) { math_error("Non-string for mode"); - /*NOTREACHED*/ + not_reached(); } temp = lookup_long(modes, vp->v_str->s_str); if (temp < 0) { math_error("Unknown mode \"%s\"", vp->v_str->s_str); - /*NOTREACHED*/ + not_reached(); } math_setmode((int) temp); break; @@ -543,12 +544,12 @@ setconfig(int type, VALUE *vp) case CONFIG_MODE2: if (vp->v_type != V_STR) { math_error("Non-string for mode"); - /*NOTREACHED*/ + not_reached(); } temp = lookup_long(modes, vp->v_str->s_str); if (temp < 0) { math_error("Unknown mode \"%s\"", vp->v_str->s_str); - /*NOTREACHED*/ + not_reached(); } math_setmode2((int) temp); break; @@ -556,7 +557,7 @@ setconfig(int type, VALUE *vp) case CONFIG_EPSILON: if (vp->v_type != V_NUM) { math_error("Non-numeric for epsilon"); - /*NOTREACHED*/ + not_reached(); } setepsilon(vp->v_num); break; @@ -564,7 +565,7 @@ setconfig(int type, VALUE *vp) case CONFIG_MAXPRINT: if (getlen(vp, &len)) { math_error("Bad value for maxprint"); - /*NOTREACHED*/ + not_reached(); } conf->maxprint = len; break; @@ -572,7 +573,7 @@ setconfig(int type, VALUE *vp) case CONFIG_MUL2: if (getlen(vp, &len) || len < 0 || len == 1) { math_error("Bad value for mul2"); - /*NOTREACHED*/ + not_reached(); } if (len == 0) len = MUL_ALG2; @@ -582,7 +583,7 @@ setconfig(int type, VALUE *vp) case CONFIG_SQ2: if (getlen(vp, &len) || len < 0 || len == 1) { math_error("Bad value for sq2"); - /*NOTREACHED*/ + not_reached(); } if (len == 0) len = SQ_ALG2; @@ -592,7 +593,7 @@ setconfig(int type, VALUE *vp) case CONFIG_POW2: if (getlen(vp, &len) || len < 0 || len == 1) { math_error("Bad value for pow2"); - /*NOTREACHED*/ + not_reached(); } if (len == 0) len = POW_ALG2; @@ -602,7 +603,7 @@ setconfig(int type, VALUE *vp) case CONFIG_REDC2: if (getlen(vp, &len) || len < 0 || len == 1) { math_error("Bad value for redc2"); - /*NOTREACHED*/ + not_reached(); } if (len == 0) len = REDC_ALG2; @@ -617,7 +618,7 @@ setconfig(int type, VALUE *vp) temp = lookup_long(truth, vp->v_str->s_str); if (temp < 0) { math_error("Illegal truth value for tilde"); - /*NOTREACHED*/ + not_reached(); } conf->tilde_ok = (int)temp; } @@ -631,7 +632,7 @@ setconfig(int type, VALUE *vp) temp = lookup_long(truth, vp->v_str->s_str); if (temp < 0) { math_error("Illegal truth value for tab"); - /*NOTREACHED*/ + not_reached(); } conf->tab_ok = (int)temp; } @@ -640,7 +641,7 @@ setconfig(int type, VALUE *vp) case CONFIG_QUOMOD: if (getlen(vp, &len)) { math_error("Illegal value for quomod"); - /*NOTREACHED*/ + not_reached(); } conf->quomod = len; break; @@ -648,7 +649,7 @@ setconfig(int type, VALUE *vp) case CONFIG_QUO: if (getlen(vp, &len)) { math_error("Illegal value for quo"); - /*NOTREACHED*/ + not_reached(); } conf->quo = len; break; @@ -656,7 +657,7 @@ setconfig(int type, VALUE *vp) case CONFIG_MOD: if (getlen(vp, &len)) { math_error("Illegal value for mod"); - /*NOTREACHED*/ + not_reached(); } conf->mod = len; break; @@ -664,7 +665,7 @@ setconfig(int type, VALUE *vp) case CONFIG_SQRT: if (getlen(vp, &len)) { math_error("Illegal value for sqrt"); - /*NOTREACHED*/ + not_reached(); } conf->sqrt = len; break; @@ -672,7 +673,7 @@ setconfig(int type, VALUE *vp) case CONFIG_APPR: if (getlen(vp, &len)) { math_error("Illegal value for appr"); - /*NOTREACHED*/ + not_reached(); } conf->appr = len; break; @@ -680,7 +681,7 @@ setconfig(int type, VALUE *vp) case CONFIG_CFAPPR: if (getlen(vp, &len)) { math_error("Illegal value for cfappr"); - /*NOTREACHED*/ + not_reached(); } conf->cfappr = len; break; @@ -688,7 +689,7 @@ setconfig(int type, VALUE *vp) case CONFIG_CFSIM: if (getlen(vp, &len)) { math_error("Illegal value for cfsim"); - /*NOTREACHED*/ + not_reached(); } conf->cfsim = len; break; @@ -696,7 +697,7 @@ setconfig(int type, VALUE *vp) case CONFIG_OUTROUND: if (getlen(vp, &len)) { math_error("Illegal value for outround"); - /*NOTREACHED*/ + not_reached(); } conf->outround = len; break; @@ -704,7 +705,7 @@ setconfig(int type, VALUE *vp) case CONFIG_ROUND: if (getlen(vp, &len)) { math_error("Illegal value for round"); - /*NOTREACHED*/ + not_reached(); } conf->round = len; break; @@ -715,10 +716,9 @@ setconfig(int type, VALUE *vp) conf->leadzero = !qiszero(q); } else if (vp->v_type == V_STR) { temp = lookup_long(truth, vp->v_str->s_str); - if (temp < 0) { { + if (temp < 0) { math_error("Illegal truth value for leadzero"); - /*NOTREACHED*/ - } + not_reached(); } conf->leadzero = (int)temp; } @@ -732,7 +732,7 @@ setconfig(int type, VALUE *vp) temp = lookup_long(truth, vp->v_str->s_str); if (temp < 0) { { math_error("Illegal truth value for fullzero"); - /*NOTREACHED*/ + not_reached(); } } conf->fullzero = (int)temp; @@ -742,7 +742,7 @@ setconfig(int type, VALUE *vp) case CONFIG_MAXSCAN: if (vp->v_type != V_NUM) { math_error("Non-numeric for maxscancount"); - /*NOTREACHED*/ + not_reached(); } q = vp->v_num; temp = qtoi(q); @@ -750,7 +750,7 @@ setconfig(int type, VALUE *vp) temp = -1; if (temp < 0) { math_error("Maxscan value is out of range"); - /*NOTREACHED*/ + not_reached(); } conf->maxscancount = temp; break; @@ -758,12 +758,12 @@ setconfig(int type, VALUE *vp) case CONFIG_PROMPT: if (vp->v_type != V_STR) { math_error("Non-string for prompt"); - /*NOTREACHED*/ + not_reached(); } p = (char *)malloc(vp->v_str->s_len + 1); if (p == NULL) { math_error("Cannot duplicate new prompt"); - /*NOTREACHED*/ + not_reached(); } strlcpy(p, vp->v_str->s_str, vp->v_str->s_len + 1); free(conf->prompt1); @@ -773,12 +773,12 @@ setconfig(int type, VALUE *vp) case CONFIG_MORE: if (vp->v_type != V_STR) { math_error("Non-string for more prompt"); - /*NOTREACHED*/ + not_reached(); } p = (char *)malloc(vp->v_str->s_len + 1); if (p == NULL) { math_error("Cannot duplicate new more prompt"); - /*NOTREACHED*/ + not_reached(); } strlcpy(p, vp->v_str->s_str, vp->v_str->s_len + 1); free(conf->prompt2); @@ -788,7 +788,7 @@ setconfig(int type, VALUE *vp) case CONFIG_BLKMAXPRINT: if (vp->v_type != V_NUM) { math_error("Non-numeric for blkmaxprint"); - /*NOTREACHED*/ + not_reached(); } q = vp->v_num; temp = qtoi(q); @@ -796,7 +796,7 @@ setconfig(int type, VALUE *vp) temp = -1; if (temp < 0) { math_error("Blkmaxprint value is out of range"); - /*NOTREACHED*/ + not_reached(); } conf->blkmaxprint = temp; break; @@ -809,7 +809,7 @@ setconfig(int type, VALUE *vp) temp = lookup_long(truth, vp->v_str->s_str); if (temp < 0) { math_error("Illegal truth value for blkverbose"); - /*NOTREACHED*/ + not_reached(); } conf->blkverbose = (int)temp; } @@ -818,13 +818,13 @@ setconfig(int type, VALUE *vp) case CONFIG_BLKBASE: if (vp->v_type != V_STR) { math_error("Non-string for blkbase"); - /*NOTREACHED*/ + not_reached(); } temp = lookup_long(blk_base, vp->v_str->s_str); if (temp < 0) { math_error("Unknown mode \"%s\" for blkbase", vp->v_str->s_str); - /*NOTREACHED*/ + not_reached(); } conf->blkbase = temp; break; @@ -832,13 +832,13 @@ setconfig(int type, VALUE *vp) case CONFIG_BLKFMT: if (vp->v_type != V_STR) { math_error("Non-string for blkfmt"); - /*NOTREACHED*/ + not_reached(); } temp = lookup_long(blk_fmt, vp->v_str->s_str); if (temp < 0) { math_error("Unknown mode \"%s\" for blkfmt", vp->v_str->s_str); - /*NOTREACHED*/ + not_reached(); } conf->blkfmt = temp; break; @@ -846,13 +846,13 @@ setconfig(int type, VALUE *vp) case CONFIG_CALC_DEBUG: if (vp->v_type != V_NUM) { math_error("Non numeric for calc_debug"); - /*NOTREACHED*/ + not_reached(); } q = vp->v_num; temp = qtoi(q); if (qisfrac(q) || !zistiny(q->num)) { math_error("Illegal calc_debug parameter value"); - /*NOTREACHED*/ + not_reached(); } conf->calc_debug = temp; break; @@ -860,13 +860,13 @@ setconfig(int type, VALUE *vp) case CONFIG_RESOURCE_DEBUG: if (vp->v_type != V_NUM) { math_error("Non numeric for resource_debug"); - /*NOTREACHED*/ + not_reached(); } q = vp->v_num; temp = qtoi(q); if (qisfrac(q) || !zistiny(q->num)) { math_error("Illegal resource_debug parameter value"); - /*NOTREACHED*/ + not_reached(); } conf->resource_debug = temp; break; @@ -874,13 +874,13 @@ setconfig(int type, VALUE *vp) case CONFIG_USER_DEBUG: if (vp->v_type != V_NUM) { math_error("Non numeric for user_debug"); - /*NOTREACHED*/ + not_reached(); } q = vp->v_num; temp = qtoi(q); if (qisfrac(q) || !zistiny(q->num)) { math_error("Illegal user_debug parameter value"); - /*NOTREACHED*/ + not_reached(); } conf->user_debug = temp; break; @@ -894,7 +894,7 @@ setconfig(int type, VALUE *vp) if (temp < 0) { math_error("Illegal truth value " "for verbose_quit"); - /*NOTREACHED*/ + not_reached(); } conf->verbose_quit = (int)temp; } @@ -903,56 +903,56 @@ setconfig(int type, VALUE *vp) case CONFIG_CTRL_D: if (vp->v_type != V_STR) { math_error("Non-string for ctrl_d"); - /*NOTREACHED*/ + not_reached(); } temp = lookup_long(ctrl_d, vp->v_str->s_str); if (temp < 0) { math_error("Unknown mode \"%s\" for ctrl_d", vp->v_str->s_str); - /*NOTREACHED*/ + not_reached(); } conf->ctrl_d = temp; break; case CONFIG_PROGRAM: math_error("The program config parameter is read-only"); - /*NOTREACHED*/ - abort(); + not_reached(); + break; case CONFIG_BASENAME: math_error("The basename config parameter is read-only"); - /*NOTREACHED*/ - abort(); + not_reached(); + break; case CONFIG_WINDOWS: math_error("The windows config parameter is read-only"); - /*NOTREACHED*/ - abort(); + not_reached(); + break; case CONFIG_CYGWIN: math_error("The cygwin config parameter is read-only"); - /*NOTREACHED*/ - abort(); + not_reached(); + break; case CONFIG_COMPILE_CUSTOM: math_error("The custom config parameter is read-only"); - /*NOTREACHED*/ - abort(); + not_reached(); + break; case CONFIG_ALLOW_CUSTOM: math_error("The allow_custom config parameter is read-only"); - /*NOTREACHED*/ - abort(); + not_reached(); + break; case CONFIG_VERSION: math_error("The version config parameter is read-only"); - /*NOTREACHED*/ - abort(); + not_reached(); + break; case CONFIG_BASEB: math_error("The baseb config parameter is read-only"); - /*NOTREACHED*/ - abort(); + not_reached(); + break; case CONFIG_REDECL_WARN: if (vp->v_type == V_NUM) { @@ -963,7 +963,7 @@ setconfig(int type, VALUE *vp) if (temp < 0) { math_error("Illegal truth value for " "redecl_warn"); - /*NOTREACHED*/ + not_reached(); } conf->redecl_warn = (int)temp; } @@ -978,7 +978,7 @@ setconfig(int type, VALUE *vp) if (temp < 0) { math_error("Illegal truth value for " "dupvar_warn"); - /*NOTREACHED*/ + not_reached(); } conf->dupvar_warn = (int)temp; } @@ -986,13 +986,13 @@ setconfig(int type, VALUE *vp) case CONFIG_HZ: math_error("The clock tick rate config parameter is read-only"); - /*NOTREACHED*/ - abort(); + not_reached(); + break; default: math_error("Setting illegal config parameter"); - /*NOTREACHED*/ - abort(); + not_reached(); + break; } } @@ -1017,7 +1017,7 @@ config_copy(CONFIG *src) if (src == NULL || src->epsilon == NULL || src->prompt1 == NULL || src->prompt2 == NULL) { math_error("bad CONFIG value"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1026,7 +1026,7 @@ config_copy(CONFIG *src) dest = (CONFIG *)malloc(sizeof(CONFIG)); if (dest == NULL) { math_error("malloc of CONFIG failed"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1134,7 +1134,7 @@ config_value(CONFIG *cfg, int type, VALUE *vp) if (cfg == NULL || cfg->epsilon == NULL || cfg->prompt1 == NULL || cfg->prompt2 == NULL) { math_error("bad CONFIG value"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1161,7 +1161,7 @@ config_value(CONFIG *cfg, int type, VALUE *vp) p = lookup_name(modes, cfg->outmode); if (p == NULL) { math_error("invalid output mode: %d", cfg->outmode); - /*NOTREACHED*/ + not_reached(); } vp->v_str = makenewstring(p); return; @@ -1172,7 +1172,7 @@ config_value(CONFIG *cfg, int type, VALUE *vp) if (p == NULL) { math_error("invalid secondary output mode: %d", cfg->outmode2); - /*NOTREACHED*/ + not_reached(); } vp->v_str = makenewstring(p); return; @@ -1280,7 +1280,7 @@ config_value(CONFIG *cfg, int type, VALUE *vp) p = lookup_name(blk_base, cfg->blkbase); if (p == NULL) { math_error("invalid block base: %d", cfg->blkbase); - /*NOTREACHED*/ + not_reached(); } vp->v_str = makenewstring(p); return; @@ -1290,7 +1290,7 @@ config_value(CONFIG *cfg, int type, VALUE *vp) p = lookup_name(blk_fmt, cfg->blkfmt); if (p == NULL) { math_error("invalid block format: %d", cfg->blkfmt); - /*NOTREACHED*/ + not_reached(); } vp->v_str = makenewstring(p); return; @@ -1316,7 +1316,7 @@ config_value(CONFIG *cfg, int type, VALUE *vp) p = lookup_name(ctrl_d, cfg->ctrl_d); if (p == NULL) { math_error("invalid Control-D: %d", cfg->ctrl_d); - /*NOTREACHED*/ + not_reached(); } vp->v_str = makenewstring(p); return; @@ -1386,7 +1386,7 @@ config_value(CONFIG *cfg, int type, VALUE *vp) default: math_error("Getting illegal CONFIG element"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1416,12 +1416,12 @@ config_cmp(CONFIG *cfg1, CONFIG *cfg2) if (cfg1 == NULL || cfg1->epsilon == NULL || cfg1->prompt1 == NULL || cfg1->prompt2 == NULL) { math_error("CONFIG #1 value is invalid"); - /*NOTREACHED*/ + not_reached(); } if (cfg2 == NULL || cfg2->epsilon == NULL || cfg2->prompt1 == NULL || cfg2->prompt2 == NULL) { math_error("CONFIG #2 value is invalid"); - /*NOTREACHED*/ + not_reached(); } /* diff --git a/const.c b/const.c index 61a6b1d..655b87e 100644 --- a/const.c +++ b/const.c @@ -1,7 +1,7 @@ /* * const - constant number storage module * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -29,6 +29,7 @@ #include "qmath.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -47,7 +48,7 @@ initconstants(void) consttable = (NUMBER **) calloc(sizeof(NUMBER *), CONSTALLOCSIZE); if (consttable == NULL) { math_error("Unable to allocate constant table"); - /*NOTREACHED*/ + not_reached(); } for (i = 0; initnumbs[i] != NULL; i++) { consttable[i] = initnumbs[i]; @@ -108,7 +109,7 @@ addqconstant(NUMBER *q) sizeof(NUMBER *) * (constcount + CONSTALLOCSIZE)); if (tp == NULL) { math_error("Unable to reallocate const table"); - /*NOTREACHED*/ + not_reached(); } consttable = tp; constavail = CONSTALLOCSIZE; @@ -179,11 +180,11 @@ constvalue(unsigned long index) { if (index >= constcount) { math_error("Bad index value for constvalue"); - /*NOTREACHED*/ + not_reached(); } if (consttable[index]->links == 0) { math_error("Constvalue has been freed!!!"); - /*NOTREACHED*/ + not_reached(); } return consttable[index]; } @@ -196,12 +197,12 @@ freeconstant(unsigned long index) if (index >= constcount) { math_error("Bad index value for freeconst"); - /*NOTREACHED*/ + not_reached(); } q = consttable[index]; if (q->links == 0) { math_error("Attempting to free freed const location"); - /*NOTREACHED*/ + not_reached(); } qfree(q); if (index == constcount - 1) { diff --git a/cscript/Makefile b/cscript/Makefile index 86ec9b6..fd750e7 100644 --- a/cscript/Makefile +++ b/cscript/Makefile @@ -1,7 +1,7 @@ # # cscript - makefile for calc shell script files # -# Copyright (C) 1999-2006,2014,2017,2021 Landon Curt Noll +# Copyright (C) 1999-2006,2014,2017,2021,2022 Landon Curt Noll # # SRC: cscript/Makefile # @@ -297,11 +297,17 @@ CALCLIBLIST= # CSCRIPT_TARGETS= ${SCRIPT} TARGETS= ${CSCRIPT_TARGETS} README +# +# rules that are not also names of files +# +PHONY= all clobber distlist install # The reason for this Makefile # all: ${TARGETS} .all +.PHONY: ${PHONY} + README: README.src @${RM} -f $@ @${SED} -e "s:#!/usr/local/src/bin/calc/calc:#!${BINDIR}/calc:" $?>$@ diff --git a/custom.c b/custom.c index f0376de..58f0d15 100644 --- a/custom.c +++ b/custom.c @@ -1,7 +1,7 @@ /* * custom - interface for custom software and hardware interfaces * - * Copyright (C) 1999-2006,2018,2021 Landon Curt Noll + * Copyright (C) 1999-2006,2018,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -48,6 +48,7 @@ #endif /* CUSTOM */ +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -77,12 +78,12 @@ custom(char *name, int count, VALUE **vals) if (count < p->minargs) { math_error("Too few arguments for custom " "function \"%s\"", p->name); - /*NOTREACHED*/ + not_reached(); } if (count > p->maxargs) { math_error("Too many arguments for custom " "function \"%s\"", p->name); - /*NOTREACHED*/ + not_reached(); } /* call the custom function */ @@ -200,7 +201,7 @@ customhelp(char *name) customname = (char *)malloc(snprintf_len+1); if (customname == NULL) { math_error("bad malloc of customname"); - /*NOTREACHED*/ + not_reached(); } snprintf(customname, snprintf_len, "custhelp/%s", name); customname[snprintf_len] = '\0'; /* paranoia */ diff --git a/custom/Makefile b/custom/Makefile index 232bf53..db5082f 100644 --- a/custom/Makefile +++ b/custom/Makefile @@ -1215,6 +1215,7 @@ c_devnull.o: ../value.h c_devnull.o: ../zmath.h c_devnull.o: c_devnull.c c_help.o: ../alloc.h +c_help.o: ../attribute.h c_help.o: ../banned.h c_help.o: ../block.h c_help.o: ../byteswap.h @@ -1242,6 +1243,7 @@ c_help.o: ../value.h c_help.o: ../zmath.h c_help.o: c_help.c c_pmodm127.o: ../alloc.h +c_pmodm127.o: ../attribute.h c_pmodm127.o: ../banned.h c_pmodm127.o: ../block.h c_pmodm127.o: ../byteswap.h @@ -1268,6 +1270,7 @@ c_pmodm127.o: ../value.h c_pmodm127.o: ../zmath.h c_pmodm127.o: c_pmodm127.c c_pzasusb8.o: ../alloc.h +c_pzasusb8.o: ../attribute.h c_pzasusb8.o: ../banned.h c_pzasusb8.o: ../block.h c_pzasusb8.o: ../byteswap.h @@ -1294,6 +1297,7 @@ c_pzasusb8.o: ../value.h c_pzasusb8.o: ../zmath.h c_pzasusb8.o: c_pzasusb8.c c_register.o: ../alloc.h +c_register.o: ../attribute.h c_register.o: ../banned.h c_register.o: ../block.h c_register.o: ../byteswap.h @@ -1321,6 +1325,7 @@ c_register.o: ../value.h c_register.o: ../zmath.h c_register.o: c_register.c c_sysinfo.o: ../alloc.h +c_sysinfo.o: ../attribute.h c_sysinfo.o: ../banned.h c_sysinfo.o: ../block.h c_sysinfo.o: ../byteswap.h diff --git a/custom/Makefile.simple b/custom/Makefile.simple index 6cac9b1..e4bac05 100644 --- a/custom/Makefile.simple +++ b/custom/Makefile.simple @@ -1220,6 +1220,7 @@ c_devnull.o: ../value.h c_devnull.o: ../zmath.h c_devnull.o: c_devnull.c c_help.o: ../alloc.h +c_help.o: ../attribute.h c_help.o: ../banned.h c_help.o: ../block.h c_help.o: ../byteswap.h @@ -1247,6 +1248,7 @@ c_help.o: ../value.h c_help.o: ../zmath.h c_help.o: c_help.c c_pmodm127.o: ../alloc.h +c_pmodm127.o: ../attribute.h c_pmodm127.o: ../banned.h c_pmodm127.o: ../block.h c_pmodm127.o: ../byteswap.h @@ -1273,6 +1275,7 @@ c_pmodm127.o: ../value.h c_pmodm127.o: ../zmath.h c_pmodm127.o: c_pmodm127.c c_pzasusb8.o: ../alloc.h +c_pzasusb8.o: ../attribute.h c_pzasusb8.o: ../banned.h c_pzasusb8.o: ../block.h c_pzasusb8.o: ../byteswap.h @@ -1299,6 +1302,7 @@ c_pzasusb8.o: ../value.h c_pzasusb8.o: ../zmath.h c_pzasusb8.o: c_pzasusb8.c c_register.o: ../alloc.h +c_register.o: ../attribute.h c_register.o: ../banned.h c_register.o: ../block.h c_register.o: ../byteswap.h @@ -1326,6 +1330,7 @@ c_register.o: ../value.h c_register.o: ../zmath.h c_register.o: c_register.c c_sysinfo.o: ../alloc.h +c_sysinfo.o: ../attribute.h c_sysinfo.o: ../banned.h c_sysinfo.o: ../block.h c_sysinfo.o: ../byteswap.h diff --git a/custom/c_help.c b/custom/c_help.c index 619a314..fa2b28e 100644 --- a/custom/c_help.c +++ b/custom/c_help.c @@ -1,7 +1,7 @@ /* * c_help - custom help function * - * Copyright (C) 1999-2004,2021 Landon Curt Noll + * Copyright (C) 1999-2004,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -39,6 +39,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -70,7 +71,7 @@ c_help(char *UNUSED(name), int UNUSED(count), VALUE **vals) */ if (vals[0]->v_type != V_STR) { math_error("custom help arg 1 must be a string"); - /*NOTREACHED*/ + not_reached(); } /* diff --git a/custom/c_pmodm127.c b/custom/c_pmodm127.c index 5b385e6..03c5f99 100644 --- a/custom/c_pmodm127.c +++ b/custom/c_pmodm127.c @@ -1,7 +1,7 @@ /* * c_pmodm127 - calculate q mod 2^(2^127-1) * - * Copyright (C) 2004-2007,2021 Landon Curt Noll + * Copyright (C) 2004-2007,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -36,6 +36,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -88,15 +89,15 @@ c_pmodm127(char *UNUSED(name), int UNUSED(count), VALUE **vals) result.v_type = V_NULL; if (vals[0]->v_type != V_NUM) { math_error("Non-numeric argument for pmodm127"); - /*NOTREACHED*/ + not_reached(); } if (qisfrac(vals[0]->v_num)) { math_error("Non-integer argument for pmodm127"); - /*NOTREACHED*/ + not_reached(); } if (qisneg(vals[0]->v_num) || qiszero(vals[0]->v_num)) { math_error("argument for pmodm127 <= 0"); - /*NOTREACHED*/ + not_reached(); } /* @@ -250,7 +251,7 @@ zmod5_or_zmod(ZVALUE *zp) subcount++; if (subcount > 2) { math_error("Too many subtractions in zmod5_or_zmod"); - /*NOTREACHED*/ + not_reached(); } j = modlen; a = zp->v; diff --git a/custom/c_pzasusb8.c b/custom/c_pzasusb8.c index 07d32d9..78e5441 100644 --- a/custom/c_pzasusb8.c +++ b/custom/c_pzasusb8.c @@ -1,7 +1,7 @@ /* * c_pzasusb8 - print numerator as a string of USB8s * - * Copyright (C) 1999-2004,2021 Ernest Bowen + * Copyright (C) 1999-2004,2021,2022 Ernest Bowen * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -36,6 +36,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -67,7 +68,7 @@ c_pzasusb8(char *UNUSED(name), int UNUSED(count), VALUE **vals) result.v_type = V_NULL; if (vals[0]->v_type != V_NUM) { math_error("Non-real argument for pzasusb8"); - /*NOTREACHED*/ + not_reached(); } /* diff --git a/custom/c_register.c b/custom/c_register.c index 7cecd62..df5e99a 100644 --- a/custom/c_register.c +++ b/custom/c_register.c @@ -1,7 +1,7 @@ /* * c_register - set or print a custom register value * - * Copyright (C) 2007,2021 Landon Curt Noll + * Copyright (C) 2007,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -39,6 +39,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -90,24 +91,24 @@ c_register(char *UNUSED(name), int count, VALUE **vals) result.v_type = V_NULL; if (vals[0]->v_type != V_NUM) { math_error("Non-numeric register number"); - /*NOTREACHED*/ + not_reached(); } if (qisfrac(vals[0]->v_num)) { math_error("Non-integer register number"); - /*NOTREACHED*/ + not_reached(); } if (qisneg(vals[0]->v_num)) { math_error("register number < 0"); - /*NOTREACHED*/ + not_reached(); } if (! qistiny(vals[0]->v_num)) { math_error("register is huge"); - /*NOTREACHED*/ + not_reached(); } reg = qtoi(vals[0]->v_num); if (reg > CUSTOM_REG_MAX) { math_error("register is larger than CUSTOM_REG_MAX"); - /*NOTREACHED*/ + not_reached(); } /* diff --git a/custom/c_sysinfo.c b/custom/c_sysinfo.c index 5192697..49b4610 100644 --- a/custom/c_sysinfo.c +++ b/custom/c_sysinfo.c @@ -1,7 +1,7 @@ /* * c_sysinfo - names and values of selected #defines * - * Copyright (C) 1999-2007,2021 Landon Curt Noll + * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -57,6 +57,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -301,7 +302,7 @@ c_sysinfo(char *UNUSED(name), int count, VALUE **vals) qisfrac(vals[0]->v_num) || zge31b(vals[0]->v_num->num)) { math_error("sysinfo: arg must be string, 0, 1 or 2"); - /*NOTREACHED*/ + not_reached(); } /* @@ -319,7 +320,7 @@ c_sysinfo(char *UNUSED(name), int count, VALUE **vals) break; default: math_error("sysinfo: arg must be string, 0, 1 or 2"); - /*NOTREACHED*/ + not_reached(); } /* @@ -368,7 +369,7 @@ c_sysinfo(char *UNUSED(name), int count, VALUE **vals) */ } else { math_error("sysinfo: arg must be string, 0, 1 or 2"); - /*NOTREACHED*/ + not_reached(); } /* diff --git a/file.c b/file.c index f1ee34e..3f9fbe6 100644 --- a/file.c +++ b/file.c @@ -1,7 +1,7 @@ /* * file - file I/O routines callable by users * - * Copyright (C) 1999-2007,2018,2021 David I. Bell and Landon Curt Noll + * Copyright (C) 1999-2007,2018,2021,2022 David I. Bell and Landon Curt Noll * * Primary author: David I. Bell * @@ -51,6 +51,7 @@ #endif +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -179,7 +180,7 @@ file_init(void) tname = (char *)malloc(snprintf_len+1); if (tname == NULL) { math_error("Out of memory for init_file"); - /*NOTREACHED*/ + not_reached(); } snprintf(tname, snprintf_len, "descriptor[%d]", i); tname[snprintf_len] = '\0'; /* paranoia */ @@ -231,7 +232,7 @@ init_fileio(FILEIO *fiop, char *name, char *mode, fiop->name = (char *)malloc(namelen + 1); if (fiop->name == NULL) { math_error("No memory for filename"); - /*NOTREACHED*/ + not_reached(); } } @@ -367,7 +368,7 @@ openid(char *name, char *mode) } if (fstat(fileno(fp), &sbuf) < 0) { math_error("bad fstat"); - /*NOTREACHED*/ + not_reached(); } /* get a new FILEID */ @@ -436,12 +437,12 @@ openpathid(char *name, char *mode, char *pathlist) free(openpath); } math_error("bad fstat"); - /*NOTREACHED*/ + not_reached(); } if (openpath == NULL) { fclose(fp); math_error("bad openpath"); - /*NOTREACHED*/ + not_reached(); } /* get a new FILEID */ @@ -482,7 +483,7 @@ reopenid(FILEID id, char *mode, char *name) if ((id == FILEID_STDIN) || (id == FILEID_STDOUT) || (id == FILEID_STDERR)) { math_error("Cannot freopen stdin, stdout, or stderr"); - /*NOTREACHED*/ + not_reached(); } /* reopen the file */ @@ -507,7 +508,7 @@ reopenid(FILEID id, char *mode, char *name) } if (i >= MAXFILES) { math_error("This should not happen in reopenid"); - /*NOTREACHED*/ + not_reached(); } fp = f_open(name, mode); if (fp == NULL) { @@ -532,7 +533,7 @@ reopenid(FILEID id, char *mode, char *name) } if (fstat(fileno(fp), &sbuf) < 0) { math_error("bad fstat"); - /*NOTREACHED*/ + not_reached(); } /* initialize FILEIO structure */ @@ -632,7 +633,7 @@ closeid(FILEID id) if ((id == FILEID_STDIN) || (id == FILEID_STDOUT) || (id == FILEID_STDERR)) { math_error("Cannot close stdin, stdout, or stderr"); - /*NOTREACHED*/ + not_reached(); } /* get file structure */ @@ -832,7 +833,7 @@ readid(FILEID id, int flags, STRING **retstr) str = (char *)malloc(n + 1); if (str == NULL) { math_error("Out of memory for readid"); - /*NOTREACHED*/ + not_reached(); } if (n > 0) memcpy(&str[totlen], buf, n); @@ -1536,7 +1537,7 @@ getloc(FILEID id, ZVALUE *res) fp = fiop->fp; if (fp == NULL) { math_error("Bogus internal file pointer!"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1695,7 +1696,7 @@ setloc(FILEID id, ZVALUE zpos) if ((id == FILEID_STDIN) || (id == FILEID_STDOUT) || (id == FILEID_STDERR)) { math_error("Cannot fseek stdin, stdout, or stderr"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1709,7 +1710,7 @@ setloc(FILEID id, ZVALUE zpos) fp = fiop->fp; if (fp == NULL) { math_error("Bogus internal file pointer!"); - /*NOTREACHED*/ + not_reached(); } fiop->action = 0; @@ -1960,7 +1961,7 @@ filesize(FILEIO *fiop) /* return length */ if (fstat(fileno(fiop->fp), &sbuf) < 0) { math_error("bad fstat"); - /*NOTREACHED*/ + not_reached(); } return sbuf.st_size; } @@ -2099,7 +2100,7 @@ getscanfield(FILE *fp, BOOL skip, unsigned int width, int scannum, str = (char *) malloc(len + 1); if (str == NULL) { math_error("Out of memory for scanning"); - /*NOTREACHED*/ + not_reached(); } if (len) memcpy(&str[totlen], buf, len); @@ -2177,7 +2178,7 @@ getscanwhite(FILE *fp, BOOL skip, unsigned int width, int scannum, str = (char *) malloc(len + 1); if (str == NULL) { math_error("Out of memory for scanning"); - /*NOTREACHED*/ + not_reached(); } if (len) memcpy(&str[totlen], buf, len); @@ -2721,7 +2722,7 @@ fsearch(FILEID id, char *str, ZVALUE start, ZVALUE end, ZVALUE *res) while (k < tmp.len && tmp.v[k] == 0); if (k == tmp.len) { math_error("This should not happen"); - /*NOTREACHED*/ + not_reached(); } tmp.v[k]--; if (tmp.v[tmp.len - 1] == 0) diff --git a/func.c b/func.c index accd5e2..1b7ca6c 100644 --- a/func.c +++ b/func.c @@ -1,8 +1,7 @@ /* * func - built-in functions implemented here * - * Copyright (C) 1999-2007,2018,2021 David I. Bell, Landon Curt Noll - * and Ernest Bowen + * Copyright (C) 1999-2007,2018,2021,2022 David I. Bell, Landon Curt Noll and Ernest Bowen * * Primary author: David I. Bell * @@ -114,6 +113,7 @@ #endif +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -290,7 +290,7 @@ f_prompt(VALUE *vp) newcp = (char *) malloc(len + 1); if (newcp == NULL) { math_error("Cannot allocate string"); - /*NOTREACHED*/ + not_reached(); } strlcpy(newcp, cp, len+1); result.v_str = makestring(newcp); @@ -486,7 +486,7 @@ f_isrel(NUMBER *val1, NUMBER *val2) { if (qisfrac(val1) || qisfrac(val2)) { math_error("Non-integer for isrel"); - /*NOTREACHED*/ + not_reached(); } return itoq((long) zrelprime(val1->num, val2->num)); } @@ -508,7 +508,7 @@ f_isprime(int count, NUMBER **vals) if (count == 2) { if (qisfrac(vals[1])) { math_error("2nd isprime arg must be an integer"); - /*NOTREACHED*/ + not_reached(); } err = vals[1]; } else { @@ -521,7 +521,7 @@ f_isprime(int count, NUMBER **vals) return qlink(err); } math_error("non-integral arg for builtin function isprime"); - /*NOTREACHED*/ + not_reached(); } /* test the integer */ @@ -533,7 +533,7 @@ f_isprime(int count, NUMBER **vals) /* error return */ if (!err) { math_error("isprime argument is an odd value > 2^32"); - /*NOTREACHED*/ + not_reached(); } return qlink(err); } @@ -549,7 +549,7 @@ f_nprime(int count, NUMBER **vals) if (count == 2) { if (qisfrac(vals[1])) { math_error("2nd nextprime arg must be an integer"); - /*NOTREACHED*/ + not_reached(); } err = vals[1]; } else { @@ -562,7 +562,7 @@ f_nprime(int count, NUMBER **vals) return qlink(err); } math_error("non-integral arg 1 for builtin function nextprime"); - /*NOTREACHED*/ + not_reached(); } /* test the integer */ @@ -577,7 +577,7 @@ f_nprime(int count, NUMBER **vals) /* error return */ if (!err) { math_error("nextprime arg 1 is >= 2^32"); - /*NOTREACHED*/ + not_reached(); } return qlink(err); } @@ -593,7 +593,7 @@ f_pprime(int count, NUMBER **vals) if (count == 2) { if (qisfrac(vals[1])) { math_error("2nd prevprime arg must be an integer"); - /*NOTREACHED*/ + not_reached(); } err = vals[1]; } else { @@ -606,7 +606,7 @@ f_pprime(int count, NUMBER **vals) return qlink(err); } math_error("non-integral arg 1 for builtin function prevprime"); - /*NOTREACHED*/ + not_reached(); } /* test the integer */ @@ -621,10 +621,10 @@ f_pprime(int count, NUMBER **vals) if (!err) { if (prev_prime == 0) { math_error("prevprime arg 1 is <= 2"); - /*NOTREACHED*/ + not_reached(); } else { math_error("prevprime arg 1 is >= 2^32"); - /*NOTREACHED*/ + not_reached(); } } return qlink(err); @@ -646,7 +646,7 @@ f_factor(int count, NUMBER **vals) if (count == 3) { if (qisfrac(vals[2])) { math_error("3rd factor arg must be an integer"); - /*NOTREACHED*/ + not_reached(); } err = vals[2]; } else { @@ -658,7 +658,7 @@ f_factor(int count, NUMBER **vals) return qlink(err); } math_error("non-integral arg 2 for builtin factor"); - /*NOTREACHED*/ + not_reached(); } limit = vals[1]->num; } else { @@ -672,7 +672,7 @@ f_factor(int count, NUMBER **vals) return qlink(err); } math_error("non-integral arg 1 for builtin pfactor"); - /*NOTREACHED*/ + not_reached(); } n = vals[0]->num; @@ -687,7 +687,7 @@ f_factor(int count, NUMBER **vals) return qlink(err); } math_error("limit >= 2^32 for builtin factor"); - /*NOTREACHED*/ + not_reached(); } else if (res == 0) { if (count < 2) zfree(limit); @@ -714,7 +714,7 @@ f_pix(int count, NUMBER **vals) if (count == 2) { if (qisfrac(vals[1])) { math_error("2nd pix arg must be an integer"); - /*NOTREACHED*/ + not_reached(); } err = vals[1]; } else { @@ -727,7 +727,7 @@ f_pix(int count, NUMBER **vals) return qlink(err); } math_error("non-integral arg 1 for builtin function pix"); - /*NOTREACHED*/ + not_reached(); } /* determine the number of primes <= x */ @@ -739,7 +739,7 @@ f_pix(int count, NUMBER **vals) /* error return */ if (!err) { math_error("pix arg 1 is >= 2^32"); - /*NOTREACHED*/ + not_reached(); } return qlink(err); } @@ -765,14 +765,14 @@ f_prevcand(int count, NUMBER **vals) case 5: if (!qisint(vals[4])) { math_error( "prevcand 5th arg must both be integer"); - /*NOTREACHED*/ + not_reached(); } zmodulus = vals[4]->num; /*FALLTHRU*/ case 4: if (!qisint(vals[3])) { math_error( "prevcand 4th arg must both be integer"); - /*NOTREACHED*/ + not_reached(); } zresidue = vals[3]->num; /*FALLTHRU*/ @@ -780,7 +780,7 @@ f_prevcand(int count, NUMBER **vals) if (!qisint(vals[2])) { math_error( "prevcand skip arg (3rd) must be an integer or omitted"); - /*NOTREACHED*/ + not_reached(); } zskip = vals[2]->num; /*FALLTHRU*/ @@ -788,7 +788,7 @@ f_prevcand(int count, NUMBER **vals) if (!qisint(vals[1])) { math_error( "prevcand count arg (2nd) must be an integer or omitted"); - /*NOTREACHED*/ + not_reached(); } zcount = &vals[1]->num; /*FALLTHRU*/ @@ -796,12 +796,13 @@ f_prevcand(int count, NUMBER **vals) if (!qisint(vals[0])) { math_error( "prevcand search arg (1st) must be an integer"); - /*NOTREACHED*/ + not_reached(); } break; default: math_error("invalid number of args passed to prevcand"); - /*NOTREACHED*/ + not_reached(); + break; } if (zcount == NULL) { @@ -809,7 +810,7 @@ f_prevcand(int count, NUMBER **vals) } else { if (zge24b(*zcount)) { math_error("prevcand count arg (2nd) must be < 2^24"); - /*NOTREACHED*/ + not_reached(); } count = ztoi(*zcount); } @@ -847,7 +848,7 @@ f_nextcand(int count, NUMBER **vals) if (!qisint(vals[4])) { math_error( "nextcand 5th args must be integer"); - /*NOTREACHED*/ + not_reached(); } zmodulus = vals[4]->num; /*FALLTHRU*/ @@ -855,7 +856,7 @@ f_nextcand(int count, NUMBER **vals) if (!qisint(vals[3])) { math_error( "nextcand 5th args must be integer"); - /*NOTREACHED*/ + not_reached(); } zresidue = vals[3]->num; /*FALLTHRU*/ @@ -863,7 +864,7 @@ f_nextcand(int count, NUMBER **vals) if (!qisint(vals[2])) { math_error( "nextcand skip arg (3rd) must be an integer or omitted"); - /*NOTREACHED*/ + not_reached(); } zskip = vals[2]->num; /*FALLTHRU*/ @@ -871,7 +872,7 @@ f_nextcand(int count, NUMBER **vals) if (!qisint(vals[1])) { math_error( "nextcand count arg (2nd) must be an integer or omitted"); - /*NOTREACHED*/ + not_reached(); } zcount = &vals[1]->num; /*FALLTHRU*/ @@ -879,12 +880,12 @@ f_nextcand(int count, NUMBER **vals) if (!qisint(vals[0])) { math_error( "nextcand search arg (1st) must be an integer"); - /*NOTREACHED*/ + not_reached(); } break; default: math_error("invalid number of args passed to nextcand"); - /*NOTREACHED*/ + not_reached(); } /* @@ -895,7 +896,7 @@ f_nextcand(int count, NUMBER **vals) } else { if (zge24b(*zcount)) { math_error("prevcand count arg (2nd) must be < 2^24"); - /*NOTREACHED*/ + not_reached(); } count = ztoi(*zcount); } @@ -935,11 +936,11 @@ f_rand(int count, NUMBER **vals) case 1: /* rand(limit) */ if (!qisint(vals[0])) { math_error("rand limit must be an integer"); - /*NOTREACHED*/ + not_reached(); } if (zislezero(vals[0]->num)) { math_error("rand limit must > 0"); - /*NOTREACHED*/ + not_reached(); } ans = qalloc(); zrandrange(_zero_, vals[0]->num, &ans->num); @@ -949,7 +950,7 @@ f_rand(int count, NUMBER **vals) /* firewall */ if (!qisint(vals[0]) || !qisint(vals[1])) { math_error("rand range must be integers"); - /*NOTREACHED*/ + not_reached(); } ans = qalloc(); zrandrange(vals[0]->num, vals[1]->num, &ans->num); @@ -957,7 +958,7 @@ f_rand(int count, NUMBER **vals) default: math_error("invalid number of args passed to rand"); - /*NOTREACHED*/ + not_reached(); return NULL; } @@ -986,11 +987,11 @@ f_randbit(int count, NUMBER **vals) */ if (!qisint(vals[0])) { math_error("rand bit count must be an integer"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(vals[0]->num)) { math_error("huge rand bit count"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1037,7 +1038,7 @@ f_srand(int count, VALUE **vals) if (!qisint(vals[0]->v_num)) { math_error( "srand number seed must be an integer"); - /*NOTREACHED*/ + not_reached(); } result.v_rand = zsrand(&vals[0]->v_num->num, NULL); break; @@ -1054,14 +1055,14 @@ f_srand(int count, VALUE **vals) default: math_error("illegal type of arg passed to srand()"); - /*NOTREACHED*/ + not_reached(); break; } break; default: math_error("bad arg count to srand()"); - /*NOTREACHED*/ + not_reached(); break; } @@ -1086,11 +1087,11 @@ f_random(int count, NUMBER **vals) case 1: /* random(limit) */ if (!qisint(vals[0])) { math_error("random limit must be an integer"); - /*NOTREACHED*/ + not_reached(); } if (zislezero(vals[0]->num)) { math_error("random limit must > 0"); - /*NOTREACHED*/ + not_reached(); } ans = qalloc(); zrandomrange(_zero_, vals[0]->num, &ans->num); @@ -1100,7 +1101,7 @@ f_random(int count, NUMBER **vals) /* firewall */ if (!qisint(vals[0]) || !qisint(vals[1])) { math_error("random range must be integers"); - /*NOTREACHED*/ + not_reached(); } ans = qalloc(); zrandomrange(vals[0]->num, vals[1]->num, &ans->num); @@ -1108,7 +1109,7 @@ f_random(int count, NUMBER **vals) default: math_error("invalid number of args passed to random"); - /*NOTREACHED*/ + not_reached(); return NULL; } @@ -1140,11 +1141,11 @@ f_randombit(int count, NUMBER **vals) */ if (!qisint(vals[0])) { math_error("random bit count must be an integer"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(vals[0]->num)) { math_error("huge random bit count"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1191,7 +1192,7 @@ f_srandom(int count, VALUE **vals) if (!qisint(vals[0]->v_num)) { math_error( "srandom number seed must be an integer"); - /*NOTREACHED*/ + not_reached(); } result.v_random = zsrandom1(vals[0]->v_num->num, TRUE); break; @@ -1203,7 +1204,7 @@ f_srandom(int count, VALUE **vals) default: math_error("illegal type of arg passed to srandom()"); - /*NOTREACHED*/ + not_reached(); break; } break; @@ -1211,11 +1212,11 @@ f_srandom(int count, VALUE **vals) case 2: /* srandom(seed, newn) */ if (vals[0]->v_type != V_NUM || !qisint(vals[0]->v_num)) { math_error("srandom seed must be an integer"); - /*NOTREACHED*/ + not_reached(); } if (vals[1]->v_type != V_NUM || !qisint(vals[1]->v_num)) { math_error("srandom Blum modulus must be an integer"); - /*NOTREACHED*/ + not_reached(); } result.v_random = zsrandom2(vals[0]->v_num->num, vals[1]->v_num->num); @@ -1224,23 +1225,23 @@ f_srandom(int count, VALUE **vals) case 4: /* srandom(seed, ip, iq, trials) */ if (vals[0]->v_type != V_NUM || !qisint(vals[0]->v_num)) { math_error("srandom seed must be an integer"); - /*NOTREACHED*/ + not_reached(); } if (vals[1]->v_type != V_NUM || !qisint(vals[1]->v_num)) { math_error("srandom 2nd arg must be an integer"); - /*NOTREACHED*/ + not_reached(); } if (vals[2]->v_type != V_NUM || !qisint(vals[2]->v_num)) { math_error("srandom 3rd arg must be an integer"); - /*NOTREACHED*/ + not_reached(); } if (vals[3]->v_type != V_NUM || !qisint(vals[3]->v_num)) { math_error("srandom 4th arg must be an integer"); - /*NOTREACHED*/ + not_reached(); } if (zge24b(vals[3]->v_num->num)) { math_error("srandom trials count is excessive"); - /*NOTREACHED*/ + not_reached(); } result.v_random = zsrandom4(vals[0]->v_num->num, vals[1]->v_num->num, @@ -1250,7 +1251,7 @@ f_srandom(int count, VALUE **vals) default: math_error("bad arg count to srandom()"); - /*NOTREACHED*/ + not_reached(); break; } @@ -1856,7 +1857,7 @@ f_fact(VALUE *vp) } if (vp->v_type != V_NUM) { math_error("Non-real argument for fact()"); - /*NOTREACHED*/ + not_reached(); } res.v_num = qfact(vp->v_num); return res; @@ -1913,19 +1914,19 @@ f_hnrmod(NUMBER *val1, NUMBER *val2, NUMBER *val3, NUMBER *val4) */ if (qisfrac(val1)) { math_error("1st arg of hnrmod (v) must be an integer"); - /*NOTREACHED*/ + not_reached(); } if (qisfrac(val2) || qisneg(val2) || qiszero(val2)) { math_error("2nd arg of hnrmod (h) must be an integer > 0"); - /*NOTREACHED*/ + not_reached(); } if (qisfrac(val3) || qisneg(val3) || qiszero(val3)) { math_error("3rd arg of hnrmod (n) must be an integer > 0"); - /*NOTREACHED*/ + not_reached(); } if (qisfrac(val4) || !zisabsleone(val4->num)) { math_error("4th arg of hnrmod (r) must be -1, 0 or 1"); - /*NOTREACHED*/ + not_reached(); } /* @@ -5686,7 +5687,7 @@ f_strcat(int count, VALUE **vals) c = (char *) malloc(len + 1) ; if (c == NULL) { math_error("No memory for strcat"); - /*NOTREACHED*/ + not_reached(); } result.v_str = stralloc(); result.v_str->s_str = c; @@ -5774,7 +5775,7 @@ f_substr(VALUE *v1, VALUE *v2, VALUE *v3) ccp = (char *) malloc(len + 1); if (ccp == NULL) { math_error("No memory for substr"); - /*NOTREACHED*/ + not_reached(); } result.v_str = stralloc(); result.v_str->s_len = len; @@ -7144,7 +7145,7 @@ f_errno(int count, VALUE **vals) if (vp->v_type != V_NUM || qisfrac(vp->v_num) || qisneg(vp->v_num) || zge16b(vp->v_num->num)) { math_error("errno argument out of range"); - /*NOTREACHED*/ + not_reached(); } newerr = (int) ztoi(vp->v_num->num); } @@ -7174,7 +7175,7 @@ f_errcount(int count, VALUE **vals) if (vp->v_type != V_NUM || qisfrac(vp->v_num) || qisneg(vp->v_num) || zge31b(vp->v_num->num)) { math_error("errcount argument out of range"); - /*NOTREACHED*/ + not_reached(); } newcount = (int) ztoi(vp->v_num->num); } @@ -7395,7 +7396,7 @@ f_strerror(int count, VALUE **vals) cp = (char *) malloc(snprintf_len+1); if (cp == NULL) { math_error("Out of memory for strerror"); - /*NOTREACHED*/ + not_reached(); } snprintf(cp, snprintf_len, "Unknown error %ld", i); cp[snprintf_len] = '\0'; /* paranoia */ @@ -8297,7 +8298,7 @@ f_reverse(VALUE *val) break; default: math_error("Bad argument type for reverse"); - /*NOTREACHED*/ + not_reached(); } return res; } @@ -8321,7 +8322,7 @@ f_sort(VALUE *val) break; default: math_error("Bad argument type for sort"); - /*NOTREACHED*/ + not_reached(); } return res; } @@ -8562,12 +8563,12 @@ f_forall(VALUE *v1, VALUE *v2) if (v2->v_type != V_STR) { math_error("Non-string second argument for forall"); - /*NOTREACHED*/ + not_reached(); } fp = findfunc(adduserfunc(v2->v_str->s_str)); if (!fp) { math_error("Undefined function for forall"); - /*NOTREACHED*/ + not_reached(); } switch (v1->v_type) { case V_LIST: @@ -8588,7 +8589,7 @@ f_forall(VALUE *v1, VALUE *v2) break; default: math_error("Non list or matrix first argument for forall"); - /*NOTREACHED*/ + not_reached(); } return res; } @@ -8608,16 +8609,16 @@ f_select(VALUE *v1, VALUE *v2) if (v1->v_type != V_LIST) { math_error("Non-list first argument for select"); - /*NOTREACHED*/ + not_reached(); } if (v2->v_type != V_STR) { math_error("Non-string second argument for select"); - /*NOTREACHED*/ + not_reached(); } fp = findfunc(adduserfunc(v2->v_str->s_str)); if (!fp) { math_error("Undefined function for select"); - /*NOTREACHED*/ + not_reached(); } lp = listalloc(); for (ep = v1->v_list->l_first; ep; ep = ep->e_next) { @@ -8648,12 +8649,12 @@ f_count(VALUE *v1, VALUE *v2) if (v2->v_type != V_STR) { math_error("Non-string second argument for select"); - /*NOTREACHED*/ + not_reached(); } fp = findfunc(adduserfunc(v2->v_str->s_str)); if (!fp) { math_error("Undefined function for select"); - /*NOTREACHED*/ + not_reached(); } switch (v1->v_type) { case V_LIST: @@ -8678,7 +8679,8 @@ f_count(VALUE *v1, VALUE *v2) break; default: math_error("Bad argument type for count"); - /*NOTREACHED*/ + not_reached(); + break; } res.v_num = itoq(n); return res; @@ -8698,11 +8700,11 @@ f_makelist(VALUE *v1) if (v1->v_type != V_NUM || qisfrac(v1->v_num) || qisneg(v1->v_num)) { math_error("Bad argument for makelist"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(v1->v_num->num)) { math_error("makelist count >= 2^31"); - /*NOTREACHED*/ + not_reached(); } n = qtoi(v1->v_num); lp = listalloc(); @@ -8734,7 +8736,7 @@ f_randperm(VALUE *val) break; default: math_error("Bad argument type for randperm"); - /*NOTREACHED*/ + not_reached(); } return res; } @@ -8755,7 +8757,7 @@ f_cmdbuf(void) newcp = (char *)malloc(cmdbuf_len+1); if (newcp == NULL) { math_error("Cannot allocate string in cmdbuf"); - /*NOTREACHED*/ + not_reached(); } strlcpy(newcp, cmdbuf, cmdbuf_len+1); result.v_str = makestring(newcp); @@ -8774,7 +8776,7 @@ f_getenv(VALUE *v1) if (v1->v_type != V_STR) { math_error("Non-string argument for getenv"); - /*NOTREACHED*/ + not_reached(); } result.v_type = V_STR; str = getenv(v1->v_str->s_str); @@ -8930,7 +8932,7 @@ f_putenv(int count, VALUE **vals) /* firewall */ if (vals[0]->v_type != V_STR || vals[1]->v_type != V_STR) { math_error("Non-string argument for putenv"); - /*NOTREACHED*/ + not_reached(); } /* convert putenv("foo","bar") into putenv("foo=bar") */ @@ -8939,7 +8941,7 @@ f_putenv(int count, VALUE **vals) putenv_str = (char *)malloc(snprintf_len+1); if (putenv_str == NULL) { math_error("Cannot allocate string in putenv"); - /*NOTREACHED*/ + not_reached(); } /* * The next statement could be: @@ -8969,13 +8971,13 @@ f_putenv(int count, VALUE **vals) /* firewall */ if (vals[0]->v_type != V_STR) { math_error("Non-string argument for putenv"); - /*NOTREACHED*/ + not_reached(); } /* putenv(arg) must be of the form "foo=bar" */ if ((char *)strchr(vals[0]->v_str->s_str, '=') == NULL) { math_error("putenv single arg string missing ="); - /*NOTREACHED*/ + not_reached(); } /* @@ -8985,7 +8987,7 @@ f_putenv(int count, VALUE **vals) putenv_str = (char *)malloc(vals[0]->v_str->s_len + 1); if (putenv_str == NULL) { math_error("Cannot allocate string in putenv"); - /*NOTREACHED*/ + not_reached(); } strlcpy(putenv_str, vals[0]->v_str->s_str, vals[0]->v_str->s_len+1); @@ -9010,7 +9012,7 @@ f_strpos(VALUE *haystack, VALUE *needle) if (haystack->v_type != V_STR || needle->v_type != V_STR) { math_error("Non-string argument for index"); - /*NOTREACHED*/ + not_reached(); } cpointer = strstr(haystack->v_str->s_str, needle->v_str->s_str); @@ -9034,11 +9036,11 @@ f_system(VALUE *vp) if (vp->v_type != V_STR) { math_error("Non-string argument for system"); - /*NOTREACHED*/ + not_reached(); } if (!allow_exec) { math_error("execution disallowed by -m"); - /*NOTREACHED*/ + not_reached(); } if (conf->calc_debug & CALCDBG_SYSTEM) { printf("%s\n", vp->v_str->s_str); @@ -9147,7 +9149,7 @@ f_base(int count, NUMBER **vals) break; default: math_error("Unsupported base"); - /*NOTREACHED*/ + not_reached(); break; } @@ -9204,7 +9206,7 @@ f_base2(int count, NUMBER **vals) break; default: math_error("Unsupported base"); - /*NOTREACHED*/ + not_reached(); break; } @@ -9333,7 +9335,7 @@ f_custom(int count, VALUE **vals) /* firewall */ if (vals[0]->v_type != V_STR) { math_error("custom: 1st arg not a string name"); - /*NOTREACHED*/ + not_reached(); } /* perform the custom function */ @@ -9776,7 +9778,7 @@ f_argv(int count, VALUE **vals) qisneg(vals[0]->v_num) || zge31b(vals[0]->v_num->num)) { math_error("argv argument must be a integer [0,2^31)"); - /*NOTREACHED*/ + not_reached(); } /* determine the arg value of the argv() function */ @@ -10609,18 +10611,18 @@ builtinfunc(long index, int argcount, VALUE *stck) if ((unsigned long)index >= (sizeof(builtins) / sizeof(builtins[0])) - 1) { math_error("Bad built-in function index"); - /*NOTREACHED*/ + not_reached(); } bp = &builtins[index]; if (argcount < bp->b_minargs) { math_error("Too few arguments for builtin function \"%s\"", bp->b_name); - /*NOTREACHED*/ + not_reached(); } if ((argcount > bp->b_maxargs) || (argcount > IN)) { math_error("Too many arguments for builtin function \"%s\"", bp->b_name); - /*NOTREACHED*/ + not_reached(); } /* * If an address was passed, then point at the real variable, @@ -10662,7 +10664,7 @@ builtinfunc(long index, int argcount, VALUE *stck) if ((*vpp)->v_type != V_NUM) { math_error("Non-real argument for builtin function %s", bp->b_name); - /*NOTREACHED*/ + not_reached(); } numargs[i] = (*vpp)->v_num; vpp++; @@ -10696,7 +10698,7 @@ builtinfunc(long index, int argcount, VALUE *stck) break; default: math_error("Bad builtin function call"); - /*NOTREACHED*/ + not_reached(); } return result; } @@ -10745,7 +10747,7 @@ builtincheck(long index, int count) if ((unsigned long)index >= (sizeof(builtins) / sizeof(builtins[0])) - 1) { math_error("Unknown built in index"); - /*NOTREACHED*/ + not_reached(); } bp = &builtins[index]; if (count < bp->b_minargs) @@ -10813,11 +10815,11 @@ malloced_putenv(char *str) */ if (str == NULL) { math_error("malloced_putenv given a NULL pointer!!"); - /*NOTREACHED*/ + not_reached(); } if (str[0] == '=') { math_error("malloced_putenv = is first character in string!!"); - /*NOTREACHED*/ + not_reached(); } /* @@ -10826,7 +10828,7 @@ malloced_putenv(char *str) value = strchr(str, '='); if (value == NULL) { math_error("malloced_putenv = not found in string!!"); - /*NOTREACHED*/ + not_reached(); } ++value; @@ -10876,7 +10878,7 @@ malloced_putenv(char *str) sizeof(struct env_pool)); if (new == NULL) { math_error("malloced_putenv malloc failed"); - /*NOTREACHED*/ + not_reached(); } e_pool = new; env_pool_max = ENV_POOL_CHUNK; @@ -10892,7 +10894,7 @@ malloced_putenv(char *str) sizeof(struct env_pool)); if (new == NULL) { math_error("malloced_putenv realloc failed"); - /*NOTREACHED*/ + not_reached(); } e_pool = new; for (i=env_pool_max; i <= env_pool_max + ENV_POOL_CHUNK; ++i) { @@ -10919,7 +10921,7 @@ malloced_putenv(char *str) } if (i >= env_pool_max) { math_error("malloced_putenv missed unused entry!!"); - /*NOTREACHED*/ + not_reached(); } /* diff --git a/hash.c b/hash.c index 0909228..2b80142 100644 --- a/hash.c +++ b/hash.c @@ -1,7 +1,7 @@ /* * hash - one-way hash routines * - * Copyright (C) 1999-2007,2021 Landon Curt Noll + * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -40,6 +40,7 @@ #include "hash.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -94,7 +95,7 @@ hash_init(int type, HASH *state) state = (HASH *)malloc(sizeof(HASH)); if (state == NULL) { math_error("hash_init: cannot malloc HASH"); - /*NOTREACHED*/ + not_reached(); } } @@ -119,7 +120,7 @@ hash_init(int type, HASH *state) if (state->chunksize > MAX_CHUNKSIZE) { math_error( "internal error: MAX_CHUNKSIZE is too small"); - /*NOTREACHED*/ + not_reached(); } return state; } @@ -174,7 +175,7 @@ hash_copy(HASH *state) hnew = (HASH *)malloc(sizeof(HASH)); if (hnew == NULL) { math_error("hash_init: cannot malloc HASH"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1048,7 +1049,7 @@ hash_value(int type, void *v, HASH *state) default: math_error("hashing an unknown value"); - /*NOTREACHED*/ + not_reached(); } return state; } diff --git a/help/Makefile b/help/Makefile index 9d19502..2c5e729 100644 --- a/help/Makefile +++ b/help/Makefile @@ -2,7 +2,7 @@ # # help - makefile for calc help files # -# Copyright (C) 1999-2006,2017,2021 Landon Curt Noll +# Copyright (C) 1999-2006,2017,2021,2022 Landon Curt Noll # # SRC: help/Makefile # @@ -408,6 +408,10 @@ DISTLIST= ${STD_HELP_FILES} ${DETAIL_HELP} ${MAKE_FILE} \ # These files are used to make (but not built) a calc .a link library # CALCLIBLIST= +# +# rules that are not also names of files +# +PHONY= all clobber distlist install all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \ ${SINGULAR_FILES} .all @@ -421,6 +425,8 @@ all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \ ${RM} -f .all ${TOUCH} .all +.PHONY: ${PHONY} + bindings: ../cal/bindings ${RM} -f $@ ${CP} ../cal/bindings $@ @@ -750,14 +756,6 @@ calcliblist: fi; \ done -# The BSDI cdrom makefile expects all help files to be pre-built. This rule -# creates these files so that the release can be shipped off to BSDI. You can -# ignore this rule. -# -bsdi: all - ${RM} -f obj - ${CP} obj.file obj - # These next rule help form the ${DETAIL_HELP} makefile variables above. # # NOTE: The ${DETAIL_HELP} list does not include special help files. diff --git a/hist.c b/hist.c index 1c2eb61..84c4147 100644 --- a/hist.c +++ b/hist.c @@ -1,7 +1,7 @@ /* * hist - interactive readline module * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -69,6 +69,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -1493,7 +1494,7 @@ hist_getline(char *prompt, char *buf, size_t len) case CTRL_D_EMPTY_EOF: default: quit_calc(); - /*NOTREACHED*/ + not_reached(); } } strlcpy(buf, line, len); diff --git a/input.c b/input.c index 7a23f95..3ce2b92 100644 --- a/input.c +++ b/input.c @@ -1,7 +1,7 @@ /* * input - nested input source file reader * - * Copyright (C) 1999-2007,2014,2018,2021 David I. Bell + * Copyright (C) 1999-2007,2014,2018,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -55,6 +55,7 @@ #include "strl.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -148,7 +149,7 @@ opensearchfile(char *name, char *pathlist, char *extension, int rd_once) /* firewall */ if (name == NULL) { math_error("NULL name given to opensearchfile"); - /*NOTREACHED*/ + not_reached(); } /* @@ -190,7 +191,7 @@ opensearchfile(char *name, char *pathlist, char *extension, int rd_once) path = malloc(path_alloc+1); if (path == NULL) { math_error("Cannot allocate filename path buffer"); - /*NOTREACHED*/ + not_reached(); } path[0] = '\0'; /* paranoia */ path[path_alloc] = '\0'; /* paranoia */ @@ -304,11 +305,11 @@ f_pathopen(char *name, char *mode, char *pathlist, char **openpath) /* firewall */ if (name == NULL) { math_error("NULL name given to f_pathopen"); - /*NOTREACHED*/ + not_reached(); } if (mode == NULL) { math_error("NULL mode given to f_pathopen"); - /*NOTREACHED*/ + not_reached(); } /* @@ -342,7 +343,7 @@ f_pathopen(char *name, char *mode, char *pathlist, char **openpath) path = malloc(pathlen+1 + 1 + namelen+1 + 1 + 1); if (path == NULL) { math_error("Cannot allocate f_pathopen buffer"); - /*NOTREACHED*/ + not_reached(); } /* @@ -375,7 +376,7 @@ f_pathopen(char *name, char *mode, char *pathlist, char **openpath) } fclose(ret); math_error("cannot malloc return openpath buffer"); - /*NOTREACHED*/ + not_reached(); } } free(path); @@ -756,7 +757,7 @@ nextline(void) cp = (char *)malloc(TTYSIZE + 1); if (cp == NULL) { math_error("Cannot allocate line buffer"); - /*NOTREACHED*/ + not_reached(); } linebuf = cp; linesize = TTYSIZE; @@ -776,7 +777,7 @@ nextline(void) cp = (char *)realloc(cp, linesize + TTYSIZE + 1); if (cp == NULL) { math_error("Cannot realloc line buffer"); - /*NOTREACHED*/ + not_reached(); } linebuf = cp; linesize += TTYSIZE; diff --git a/lib_calc.c b/lib_calc.c index 58db95a..9ce07e6 100644 --- a/lib_calc.c +++ b/lib_calc.c @@ -1,7 +1,7 @@ /* * lib_calc - calc link library initialization and shutdown routines * - * Copyright (C) 1999-2007,2018,2021 Landon Curt Noll + * Copyright (C) 1999-2007,2018,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -94,6 +94,7 @@ typedef struct {int fd;} ttystruct; #endif /* Windows */ +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -500,7 +501,7 @@ initenv(void) if (strlen(calcrc) > MAX_CALCRC) { math_error("The $CALCRC variable is longer than %d chars", MAX_CALCRC); - /*NOTREACHED*/ + not_reached(); } /* determine the $CALCBINDINGS value */ @@ -542,7 +543,7 @@ initenv(void) /* paranoia */ if (home == NULL) { math_error("Unable to allocate string for $HOME"); - /*NOTREACHED*/ + not_reached(); } /* determine the $PAGER value */ diff --git a/lib_util.c b/lib_util.c index 52cc425..dadf85f 100644 --- a/lib_util.c +++ b/lib_util.c @@ -1,7 +1,7 @@ /* * lib_util - calc library utility routines * - * Copyright (C) 1999-2006,2021 Landon Curt Noll + * Copyright (C) 1999-2006,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -35,6 +35,7 @@ #include "lib_util.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -151,7 +152,7 @@ convstr2z(char *str) v = (HALF *)malloc(len * sizeof(HALF)); if (v == NULL) { math_error("convstr2z bad malloc"); - /*NOTREACHED*/ + not_reached(); } v[len-1] = 0; /* deal with possible partial end of string HALF */ @@ -222,7 +223,7 @@ convhex2z(char *hex) v = (HALF *)malloc(len * sizeof(HALF)); if (v == NULL) { math_error("convhex2z bad malloc"); - /*NOTREACHED*/ + not_reached(); } v[len-1] = 0; /* deal with possible partial end of string HALF */ @@ -313,7 +314,7 @@ convz2hex(ZVALUE z) ret = (char *)malloc(sizeof("0")); if (ret == NULL) { math_error("convz2hex bad malloc of 0 value"); - /*NOTREACHED*/ + not_reached(); } ret[0] = '0'; ret[1] = '\0'; @@ -327,7 +328,7 @@ convz2hex(ZVALUE z) ret = (char *)calloc(slen+1+1, sizeof(char)); if (ret == NULL) { math_error("convz2hex bad malloc of string"); - /*NOTREACHED*/ + not_reached(); } /* diff --git a/listfunc.c b/listfunc.c index 3977751..a8e29f9 100644 --- a/listfunc.c +++ b/listfunc.c @@ -1,7 +1,7 @@ /* * listfunc - list handling routines * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -37,6 +37,7 @@ #include "zrand.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -129,7 +130,7 @@ insertlistmiddle(LIST *lp, long index, VALUE *vp) oldep = listelement(lp, index); if (oldep == NULL) { math_error("Index out of bounds for list insertion"); - /*NOTREACHED*/ + not_reached(); } ep = elemalloc(); copyvalue(vp, &ep->e_value); @@ -207,7 +208,7 @@ removelistmiddle(LIST *lp, long index, VALUE *vp) ep = listelement(lp, index); if (ep == NULL) { math_error("Index out of bounds for list deletion"); - /*NOTREACHED*/ + not_reached(); } *vp = ep->e_value; ep->e_value.v_type = V_NULL; @@ -297,14 +298,14 @@ listsearch(LIST *lp, VALUE *vp, long i, long j, ZVALUE *index) if (i < 0 || j > lp->l_count) { math_error("This should not happen in call to listsearch"); - /*NOTREACHED*/ + not_reached(); } ep = listelement(lp, i); while (i < j) { if (!ep) { math_error("This should not happen in listsearch"); - /*NOTREACHED*/ + not_reached(); } if (acceptvalue(&ep->e_value, vp)) { lp->l_cache = ep; @@ -331,14 +332,14 @@ listrsearch(LIST *lp, VALUE *vp, long i, long j, ZVALUE *index) if (i < 0 || j > lp->l_count) { math_error("This should not happen in call to listrsearch"); - /*NOTREACHED*/ + not_reached(); } ep = listelement(lp, --j); while (j >= i) { if (!ep) { math_error("This should not happen in listsearch"); - /*NOTREACHED*/ + not_reached(); } if (acceptvalue(&ep->e_value, vp)) { lp->l_cache = ep; @@ -771,7 +772,7 @@ listsort(LIST *lp) if (k >= LONG_BITS) { /* this should never happen */ math_error("impossible k overflow in listsort!"); - /*NOTREACHED*/ + not_reached(); } lp->l_first = start->e_next; lp->l_first->e_prev = NULL; @@ -812,7 +813,7 @@ elemalloc(void) ep = (LISTELEM *) malloc(sizeof(LISTELEM)); if (ep == NULL) { math_error("Cannot allocate list element"); - /*NOTREACHED*/ + not_reached(); } ep->e_next = NULL; ep->e_prev = NULL; @@ -845,7 +846,7 @@ listalloc(void) lp = (LIST *) malloc(sizeof(LIST)); if (lp == NULL) { math_error("Cannot allocate list header"); - /*NOTREACHED*/ + not_reached(); } lp->l_first = NULL; lp->l_last = NULL; diff --git a/matfunc.c b/matfunc.c index 58c82c1..056fea4 100644 --- a/matfunc.c +++ b/matfunc.c @@ -1,7 +1,7 @@ /* * matfunc - extended precision rational arithmetic matrix functions * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -36,6 +36,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -63,7 +64,7 @@ matadd(MATRIX *m1, MATRIX *m2) if (m1->m_dim != m2->m_dim) { math_error("Incompatible matrix dimensions for add"); - /*NOTREACHED*/ + not_reached(); } tmp.m_dim = m1->m_dim; tmp.m_size = m1->m_size; @@ -75,7 +76,7 @@ matadd(MATRIX *m1, MATRIX *m2) if ((min1 && min2 && (min1 != min2)) || ((max1-min1) != (max2-min2))) { math_error("Incompatible matrix bounds for add"); - /*NOTREACHED*/ + not_reached(); } tmp.m_min[dim] = (min1 ? min1 : min2); tmp.m_max[dim] = tmp.m_min[dim] + (max1 - min1); @@ -105,7 +106,7 @@ matsub(MATRIX *m1, MATRIX *m2) if (m1->m_dim != m2->m_dim) { math_error("Incompatible matrix dimensions for sub"); - /*NOTREACHED*/ + not_reached(); } tmp.m_dim = m1->m_dim; tmp.m_size = m1->m_size; @@ -117,7 +118,7 @@ matsub(MATRIX *m1, MATRIX *m2) if ((min1 && min2 && (min1 != min2)) || ((max1-min1) != (max2-min2))) { math_error("Incompatible matrix bounds for sub"); - /*NOTREACHED*/ + not_reached(); } tmp.m_min[dim] = (min1 ? min1 : min2); tmp.m_max[dim] = tmp.m_min[dim] + (max1 - min1); @@ -187,7 +188,7 @@ matmul(MATRIX *m1, MATRIX *m2) if (m1->m_dim == 1 && m2->m_dim == 1) { if (m1->m_max[0]-m1->m_min[0] != m2->m_max[0]-m2->m_min[0]) { math_error("Incompatible bounds for 1D * 1D matmul"); - /*NOTREACHED*/ + not_reached(); } res = matalloc(m1->m_size); *res = *m1; @@ -201,7 +202,7 @@ matmul(MATRIX *m1, MATRIX *m2) if (m1->m_dim == 1 && m2->m_dim == 2) { if (m1->m_max[0]-m1->m_min[0] != m2->m_max[0]-m2->m_min[0]) { math_error("Incompatible bounds for 1D * 2D matmul"); - /*NOTREACHED*/ + not_reached(); } res = matalloc(m2->m_size); *res = *m2; @@ -221,7 +222,7 @@ matmul(MATRIX *m1, MATRIX *m2) if (m1->m_dim == 2 && m2->m_dim == 1) { if (m1->m_max[1]-m1->m_min[1] != m2->m_max[0]-m2->m_min[0]) { math_error("Incompatible bounds for 2D * 1D matmul"); - /*NOTREACHED*/ + not_reached(); } res = matalloc(m1->m_size); *res = *m1; @@ -240,11 +241,11 @@ matmul(MATRIX *m1, MATRIX *m2) if ((m1->m_dim != 2) || (m2->m_dim != 2)) { math_error("Matrix dimensions not compatible for mul"); - /*NOTREACHED*/ + not_reached(); } if ((m1->m_max[1]-m1->m_min[1]) != (m2->m_max[0]-m2->m_min[0])) { math_error("Incompatible bounds for 2D * 2D matrix mul"); - /*NOTREACHED*/ + not_reached(); } max1 = (m1->m_max[0] - m1->m_min[0] + 1); max2 = (m2->m_max[1] - m2->m_min[1] + 1); @@ -301,11 +302,11 @@ matsquare(MATRIX *m) } if (m->m_dim != 2) { math_error("Matrix dimension exceeds two for square"); - /*NOTREACHED*/ + not_reached(); } if ((m->m_max[0] - m->m_min[0]) != (m->m_max[1] - m->m_min[1])) { math_error("Squaring non-square matrix"); - /*NOTREACHED*/ + not_reached(); } max = (m->m_max[0] - m->m_min[0] + 1); res = matalloc(max * max); @@ -357,20 +358,20 @@ matpowi(MATRIX *m, NUMBER *q) if (m->m_dim > 2) { math_error("Matrix dimension greater than 2 for power"); - /*NOTREACHED*/ + not_reached(); } if (m->m_dim == 2 && (m->m_max[0] - m->m_min[0] != m->m_max[1] - m->m_min[1])) { math_error("Raising non-square 2D matrix to a power"); - /*NOTREACHED*/ + not_reached(); } if (qisfrac(q)) { math_error("Raising matrix to non-integral power"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(q->num)) { math_error("Raising matrix to very large power"); - /*NOTREACHED*/ + not_reached(); } power = ztolong(q->num); if (qisneg(q)) @@ -610,7 +611,7 @@ matquoval(MATRIX *m, VALUE *vp, VALUE *v3) if ((vp->v_type == V_NUM) && qiszero(vp->v_num)) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } res = matalloc(m->m_size); *res = *m; @@ -640,7 +641,7 @@ matmodval(MATRIX *m, VALUE *vp, VALUE *v3) if ((vp->v_type == V_NUM) && qiszero(vp->v_num)) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } res = matalloc(m->m_size); *res = *m; @@ -866,31 +867,31 @@ matindex(MATRIX *mp, BOOL UNUSED(create), long dim, VALUE *indices) if (dim < 0) { math_error("Negative dimension %ld for matrix", dim); - /*NOTREACHED*/ + not_reached(); } for (;;) { if (dim < mp->m_dim) { math_error( "Indexing a %ldd matrix as a %ldd matrix", mp->m_dim, dim); - /*NOTREACHED*/ + not_reached(); } offset = 0; for (i = 0; i < mp->m_dim; i++) { if (indices->v_type != V_NUM) { math_error("Non-numeric index for matrix"); - /*NOTREACHED*/ + not_reached(); } q = indices->v_num; if (qisfrac(q)) { math_error("Non-integral index for matrix"); - /*NOTREACHED*/ + not_reached(); } index = qtoi(q); if (zge31b(q->num) || (index < mp->m_min[i]) || (index > mp->m_max[i])) { math_error("Index out of bounds for matrix"); - /*NOTREACHED*/ + not_reached(); } offset *= (mp->m_max[i] - mp->m_min[i] + 1); offset += (index - mp->m_min[i]); @@ -902,7 +903,7 @@ matindex(MATRIX *mp, BOOL UNUSED(create), long dim, VALUE *indices) break; if (vp->v_type != V_MAT) { math_error("Non-matrix argument for matindex"); - /*NOTREACHED*/ + not_reached(); } mp = vp->v_mat; } @@ -953,7 +954,7 @@ matsearch(MATRIX *m, VALUE *vp, long i, long j, ZVALUE *index) val = &m->m_table[i]; if (i < 0 || j > m->m_size) { math_error("This should not happen in call to matsearch"); - /*NOTREACHED*/ + not_reached(); } while (i < j) { if (acceptvalue(val++, vp)) { @@ -978,7 +979,7 @@ matrsearch(MATRIX *m, VALUE *vp, long i, long j, ZVALUE *index) if (i < 0 || j > m->m_size) { math_error("This should not happen in call to matrsearch"); - /*NOTREACHED*/ + not_reached(); } val = &m->m_table[--j]; while (j >= i) { @@ -1056,11 +1057,11 @@ matident(MATRIX *m) if (m->m_dim != 2) { math_error( "Matrix dimension must be two for setting to identity"); - /*NOTREACHED*/ + not_reached(); } if ((m->m_max[0] - m->m_min[0]) != (m->m_max[1] - m->m_min[1])) { math_error("Matrix must be square for setting to identity"); - /*NOTREACHED*/ + not_reached(); } res = matalloc(m->m_size); *res = *m; @@ -1108,11 +1109,11 @@ matinv(MATRIX *m) } if (m->m_dim != 2) { math_error("Matrix dimension exceeds two for inverse"); - /*NOTREACHED*/ + not_reached(); } if ((m->m_max[0] - m->m_min[0]) != (m->m_max[1] - m->m_min[1])) { math_error("Inverting non-square matrix"); - /*NOTREACHED*/ + not_reached(); } /* * Begin by creating the identity matrix with the same attributes. @@ -1154,7 +1155,7 @@ matinv(MATRIX *m) matfree(m); matfree(res); math_error("Matrix is not invertible"); - /*NOTREACHED*/ + not_reached(); } val += rows; } @@ -1447,7 +1448,7 @@ matinit(MATRIX *m, VALUE *v1, VALUE *v2) ((res->m_max[0] - res->m_min[0]) != (res->m_max[1] - res->m_min[1])))) { math_error("Filling diagonals of non-square matrix"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1489,7 +1490,7 @@ matalloc(long size) if (m == NULL) { math_error("Cannot get memory to allocate matrix of size %ld", size); - /*NOTREACHED*/ + not_reached(); } m->m_size = size; for (i = size, vp = m->m_table; i > 0; i--, vp++) @@ -1617,7 +1618,7 @@ matsort(MATRIX *m) buf = (VALUE *) malloc(m->m_size * sizeof(VALUE)); if (buf == NULL) { math_error("Not enough memory for matsort"); - /*NOTREACHED*/ + not_reached(); } next = m->m_table; end = next + m->m_size; @@ -1672,7 +1673,7 @@ matsort(MATRIX *m) if (k >= LONG_BITS) { /* this should never happen */ math_error("impossible k overflow in matsort!"); - /*NOTREACHED*/ + not_reached(); } } diff --git a/obj.c b/obj.c index 33f185f..ba4923f 100644 --- a/obj.c +++ b/obj.c @@ -1,7 +1,7 @@ /* * obj - object handling primitives * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -38,6 +38,7 @@ #include "strl.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -223,7 +224,7 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) if ((unsigned)action > OBJ_MAXFUNC) { math_error("Illegal action for object call"); - /*NOTREACHED*/ + not_reached(); } oip = &objectinfo[action]; if (v1->v_type == V_OBJ) { @@ -232,20 +233,20 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) oap = v2->v_obj->o_actions; } else { math_error("Object routine called with non-object"); - /*NOTREACHED*/ + not_reached(); } index = oap->oa_indices[action]; if (index < 0) { namestr_ret = namestr(&objectnames, oap->oa_index); if (namestr_ret == NULL) { math_error("namestr returned NULL!!!"); - /*NOTREACHED*/ + not_reached(); } namestr_len = strlen(namestr_ret); opi_name_len = strlen(oip->name); if (namestr_len > (size_t)SYMBOLSIZE-1-opi_name_len) { math_error("namestr returned a strong too long!!!"); - /*NOTREACHED*/ + not_reached(); } name[0] = '\0'; strlcpy(name, namestr_ret, namestr_len+1); @@ -278,7 +279,7 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) case ERR_POW: if (v2->v_type != V_NUM) { math_error("Non-real power"); - /*NOTREACHED*/ + not_reached(); } val = objpowi(v1, v2->v_num); break; @@ -312,7 +313,7 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) default: math_error("Function \"%s\" is undefined", namefunc(index)); - /*NOTREACHED*/ + not_reached(); } return val; } @@ -345,7 +346,7 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) break; default: math_error("Bad number of args to calculate"); - /*NOTREACHED*/ + not_reached(); } calculate(fp, oip->args); switch (oip->retval) { @@ -358,7 +359,7 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) case A_INT: if ((stack->v_type != V_NUM) || qisfrac(stack->v_num)) { math_error("Integer return value required"); - /*NOTREACHED*/ + not_reached(); } index = qtoi(stack->v_num); qfree(stack->v_num); @@ -368,7 +369,7 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) break; default: math_error("Bad object return"); - /*NOTREACHED*/ + not_reached(); } return val; } @@ -457,11 +458,11 @@ objpowi(VALUE *vp, NUMBER *q) if (qisfrac(q)) { math_error("Raising object to non-integral power"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(q->num)) { math_error("Raising object to very large power"); - /*NOTREACHED*/ + not_reached(); } power = ztolong(q->num); if (qisneg(q)) @@ -572,7 +573,7 @@ defineobject(char *name, int indices[], int count) } if (newobjects == NULL) { math_error("Allocation failure for new object type"); - /*NOTREACHED*/ + not_reached(); } objects = newobjects; } @@ -580,12 +581,12 @@ defineobject(char *name, int indices[], int count) oap = (OBJECTACTIONS *) malloc(objectactionsize(count)); if (oap == NULL) { math_error("Cannot allocate object type #0"); - /*NOTREACHED*/ + not_reached(); } name = addstr(hp, name); if (name == NULL) { math_error("Cannot allocate object type #1"); - /*NOTREACHED*/ + not_reached(); } oap->oa_count = count; for (index = OBJ_MAXFUNC; index >= 0; index--) @@ -634,7 +635,7 @@ addelement(char *name) return index; if (addstr(hp, name) == NULL) { math_error("Cannot allocate element name"); - /*NOTREACHED*/ + not_reached(); } return findstr(hp, name); } @@ -699,12 +700,12 @@ objalloc(long index) if (index < 0 || index > maxobjcount) { math_error("Allocating bad object index"); - /*NOTREACHED*/ + not_reached(); } oap = objects[index]; if (oap == NULL) { math_error("Object type not defined"); - /*NOTREACHED*/ + not_reached(); } i = oap->oa_count; if (i < USUAL_ELEMENTS) @@ -715,7 +716,7 @@ objalloc(long index) op = (OBJECT *) malloc(objectsize(i)); if (op == NULL) { math_error("Cannot allocate object"); - /*NOTREACHED*/ + not_reached(); } op->o_actions = oap; vp = op->o_table; @@ -771,7 +772,7 @@ objcopy(OBJECT *op) np = (OBJECT *) malloc(objectsize(i)); if (np == NULL) { math_error("Cannot allocate object"); - /*NOTREACHED*/ + not_reached(); } np->o_actions = op->o_actions; v1 = op->o_table; diff --git a/opcodes.c b/opcodes.c index a5637aa..8a89804 100644 --- a/opcodes.c +++ b/opcodes.c @@ -1,7 +1,7 @@ /* * opcodes - opcode execution module * - * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -47,6 +47,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -153,7 +154,7 @@ o_localaddr(FUNC *fp, VALUE *locals, long index) { if ((unsigned long)index >= fp->f_localcount) { math_error("Bad local variable index"); - /*NOTREACHED*/ + not_reached(); } locals += index; stack++; @@ -170,7 +171,7 @@ o_globaladdr(FUNC *UNUSED(fp), GLOBAL *sp) if (sp == NULL) { math_error("Global variable \"%s\" not initialized", sp->g_name); - /*NOTREACHED*/ + not_reached(); } stack++; stack->v_addr = &sp->g_value; @@ -185,7 +186,7 @@ o_paramaddr(FUNC *UNUSED(fp), int argcount, VALUE *args, long index) { if ((long)index >= argcount) { math_error("Bad parameter index"); - /*NOTREACHED*/ + not_reached(); } args += index; stack++; @@ -204,7 +205,7 @@ o_localvalue(FUNC *fp, VALUE *locals, long index) { if ((unsigned long)index >= fp->f_localcount) { math_error("Bad local variable index"); - /*NOTREACHED*/ + not_reached(); } locals += index; copyvalue(locals, ++stack); @@ -217,7 +218,7 @@ o_globalvalue(FUNC *UNUSED(fp), GLOBAL *sp) { if (sp == NULL) { math_error("Global variable not defined"); - /*NOTREACHED*/ + not_reached(); } copyvalue(&sp->g_value, ++stack); } @@ -229,7 +230,7 @@ o_paramvalue(FUNC *UNUSED(fp), int argcount, VALUE *args, long index) { if ((long)index >= argcount) { math_error("Bad parameter index"); - /*NOTREACHED*/ + not_reached(); } args += index; if (args->v_type == V_ADDR) @@ -250,7 +251,7 @@ o_argvalue(FUNC *fp, int argcount, VALUE *args) if ((vp->v_type != V_NUM) || qisneg(vp->v_num) || qisfrac(vp->v_num)) { math_error("Illegal argument for arg function"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(vp->v_num)) { if (stack->v_type == V_NUM) @@ -277,7 +278,7 @@ o_number(FUNC *UNUSED(fp), long arg) q = constvalue(arg); if (q == NULL) { math_error("Numeric constant value not found"); - /*NOTREACHED*/ + not_reached(); } stack++; stack->v_num = qlink(q); @@ -296,7 +297,7 @@ o_imaginary(FUNC *UNUSED(fp), long arg) q = constvalue(arg); if (q == NULL) { math_error("Numeric constant value not found"); - /*NOTREACHED*/ + not_reached(); } stack++; stack->v_subtype = V_NOSUBTYPE; @@ -349,7 +350,7 @@ o_matcreate(FUNC *UNUSED(fp), long dim) if ((dim < 0) || (dim > MAXDIM)) { math_error("Bad dimension %ld for matrix", dim); - /*NOTREACHED*/ + not_reached(); } size = 1; for (i = dim - 1; i >= 0; i--) { @@ -361,17 +362,17 @@ o_matcreate(FUNC *UNUSED(fp), long dim) v2 = v2->v_addr; if ((v1->v_type != V_NUM) || (v2->v_type != V_NUM)) { math_error("Non-numeric bounds for matrix"); - /*NOTREACHED*/ + not_reached(); } num1 = v1->v_num; num2 = v2->v_num; if (qisfrac(num1) || qisfrac(num2)) { math_error("Non-integral bounds for matrix"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(num1->num) || zge31b(num2->num)) { math_error("Very large bounds for matrix"); - /*NOTREACHED*/ + not_reached(); } min[i] = qtoi(num1); max[i] = qtoi(num2); @@ -383,7 +384,7 @@ o_matcreate(FUNC *UNUSED(fp), long dim) size *= (max[i] - min[i] + 1); if (size > 10000000) { math_error("Very large size for matrix"); - /*NOTREACHED*/ + not_reached(); } freevalue(stack--); freevalue(stack--); @@ -558,13 +559,13 @@ o_indexaddr(FUNC *UNUSED(fp), long dim, long writeflag) flag = (writeflag != 0); if (dim < 0) { math_error("Negative dimension for indexing"); - /*NOTREACHED*/ + not_reached(); } val = &stack[-dim]; if (val->v_type != V_NBLOCK && val->v_type != V_FILE) { if (val->v_type != V_ADDR) { math_error("Non-pointer for indexaddr"); - /*NOTREACHED*/ + not_reached(); } val = val->v_addr; } @@ -593,7 +594,7 @@ o_indexaddr(FUNC *UNUSED(fp), long dim, long writeflag) blk = val->v_nblock->blk; if (blk->data == NULL) { math_error("Freed block"); - /*NOTREACHED*/ + not_reached(); } /* @@ -601,26 +602,26 @@ o_indexaddr(FUNC *UNUSED(fp), long dim, long writeflag) */ if (dim != 1) { math_error("block has only one dimension"); - /*NOTREACHED*/ + not_reached(); } if (indices[0].v_type != V_NUM) { math_error("Non-numeric index for block"); - /*NOTREACHED*/ + not_reached(); } if (qisfrac(indices[0].v_num)) { math_error("Non-integral index for block"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(indices[0].v_num->num) || zisneg(indices[0].v_num->num)) { math_error("Index out of bounds for block"); - /*NOTREACHED*/ + not_reached(); } index = ztoi(indices[0].v_num->num); if (index >= blk->maxsize) { math_error("Index out of bounds for block"); - /*NOTREACHED*/ + not_reached(); } if (index >= blk->datalen) blk->datalen = index + 1; @@ -633,25 +634,25 @@ o_indexaddr(FUNC *UNUSED(fp), long dim, long writeflag) case V_STR: if (dim != 1) { math_error("string has only one dimension"); - /*NOTREACHED*/ + not_reached(); } if (indices[0].v_type != V_NUM) { math_error("Non-numeric index for string"); - /*NOTREACHED*/ + not_reached(); } if (qisfrac(indices[0].v_num)) { math_error("Non-integral index for string"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(indices[0].v_num->num) || zisneg(indices[0].v_num->num)) { math_error("Index out of bounds for string"); - /*NOTREACHED*/ + not_reached(); } index = ztoi(indices[0].v_num->num); if (index < 0 || (size_t)index >= val->v_str->s_len) { math_error("Index out of bounds for string"); - /*NOTREACHED*/ + not_reached(); } ret.v_type = V_OCTET; ret.v_subtype = val->v_subtype; @@ -662,31 +663,31 @@ o_indexaddr(FUNC *UNUSED(fp), long dim, long writeflag) case V_LIST: if (dim != 1) { math_error("list has only one dimension"); - /*NOTREACHED*/ + not_reached(); } if (indices[0].v_type != V_NUM) { math_error("Non-numeric index for list"); - /*NOTREACHED*/ + not_reached(); } if (qisfrac(indices[0].v_num)) { math_error("Non-integral index for list"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(indices[0].v_num->num) || zisneg(indices[0].v_num->num)) { math_error("Index out of bounds for list"); - /*NOTREACHED*/ + not_reached(); } index = ztoi(indices[0].v_num->num); vp = listfindex(val->v_list, index); if (vp == NULL) { math_error("Index out of bounds for list"); - /*NOTREACHED*/ + not_reached(); } break; default: math_error("Illegal value for indexing"); - /*NOTREACHED*/ + not_reached(); } while (dim-- > 0) freevalue(stack--); @@ -712,7 +713,7 @@ o_elemaddr(FUNC *UNUSED(fp), long index) mp = vp->v_mat; if ((index < 0) || (index >= mp->m_size)) { math_error("Non-existent element for matrix"); - /*NOTREACHED*/ + not_reached(); } vp = &mp->m_table[index]; break; @@ -721,7 +722,7 @@ o_elemaddr(FUNC *UNUSED(fp), long index) offset = objoffset(op, index); if (offset < 0) { math_error("Non-existent element for object"); - /*NOTREACHED*/ + not_reached(); } vp = &op->o_table[offset]; break; @@ -729,12 +730,12 @@ o_elemaddr(FUNC *UNUSED(fp), long index) vp = listfindex(vp->v_list, index); if (vp == NULL) { math_error("Index out of bounds for list"); - /*NOTREACHED*/ + not_reached(); } break; default: math_error("Not initializing matrix, object or list"); - /*NOTREACHED*/ + not_reached(); } stack->v_type = V_ADDR; stack->v_addr = vp; @@ -917,7 +918,7 @@ o_ptr(void) break; default: math_error("Addressing non-addressable type"); - /*NOTREACHED*/ + not_reached(); } } @@ -957,7 +958,7 @@ o_deref(void) } if (stack->v_type != V_ADDR) { math_error("Dereferencing a non-variable"); - /*NOTREACHED*/ + not_reached(); } vp = vp->v_addr; switch (vp->v_type) { @@ -1578,7 +1579,7 @@ o_links(void) } if (links <= 0) { math_error("Non-positive links!!!"); - /*NOTREACHED*/ + not_reached(); } freevalue(stack); if (!haveaddress) @@ -2138,7 +2139,7 @@ o_isdefined(void) vp = vp->v_addr; if (vp->v_type != V_STR) { math_error("Non-string argument for isdefined"); - /*NOTREACHED*/ + not_reached(); } r = 0; index = getbuiltinfunc(vp->v_str->s_str); @@ -2167,7 +2168,7 @@ o_isobjtype(void) vp = vp->v_addr; if (vp->v_type != V_STR) { math_error("Non-string argument for isobjtype"); - /*NOTREACHED*/ + not_reached(); } index = checkobject(vp->v_str->s_str); freevalue(stack); @@ -2311,7 +2312,7 @@ o_re(void) } if (vp->v_type != V_COM) { math_error("Taking real part of non-number"); - /*NOTREACHED*/ + not_reached(); } q = qlink(vp->v_com->real); if (stack->v_type == V_COM) @@ -2341,7 +2342,7 @@ o_im(void) } if (vp->v_type != V_COM) { math_error("Taking imaginary part of non-number"); - /*NOTREACHED*/ + not_reached(); } q = qlink(vp->v_com->imag); if (stack->v_type == V_COM) @@ -2391,12 +2392,12 @@ o_fiaddr(void) vp = vp->v_addr; if (vp->v_type != V_NUM || qisfrac(vp->v_num)) { math_error("Fast indexing by non-integer"); - /*NOTREACHED*/ + not_reached(); } index = qtoi(vp->v_num); if (zge31b(vp->v_num->num) || (index < 0)) { math_error("Index out of range for fast indexing"); - /*NOTREACHED*/ + not_reached(); } if (stack->v_type == V_NUM) qfree(stack->v_num); @@ -2404,14 +2405,14 @@ o_fiaddr(void) vp = stack; if (vp->v_type != V_ADDR) { math_error("Non-pointer for fast indexing"); - /*NOTREACHED*/ + not_reached(); } vp = vp->v_addr; switch (vp->v_type) { case V_OBJ: if (index >= vp->v_obj->o_actions->oa_count) { math_error("Index out of bounds for object"); - /*NOTREACHED*/ + not_reached(); } res = vp->v_obj->o_table + index; break; @@ -2419,7 +2420,7 @@ o_fiaddr(void) m = vp->v_mat; if (index >= m->m_size) { math_error("Index out of bounds for matrix"); - /*NOTREACHED*/ + not_reached(); } res = m->m_table + index; break; @@ -2428,7 +2429,7 @@ o_fiaddr(void) res = listfindex(lp, index); if (res == NULL) { math_error("Index out of bounds for list"); - /*NOTREACHED*/ + not_reached(); } break; case V_ASSOC: @@ -2436,12 +2437,12 @@ o_fiaddr(void) res = assocfindex(ap, index); if (res == NULL) { math_error("Index out of bounds for association"); - /*NOTREACHED*/ + not_reached(); } break; default: math_error("Bad variable type for fast indexing"); - /*NOTREACHED*/ + not_reached(); } stack->v_addr = res; } @@ -2491,7 +2492,7 @@ o_numerator(void) vp = vp->v_addr; if (vp->v_type != V_NUM) { math_error("Numerator of non-number"); - /*NOTREACHED*/ + not_reached(); } if ((stack->v_type == V_NUM) && qisint(vp->v_num)) return; @@ -2515,7 +2516,7 @@ o_denominator(void) vp = vp->v_addr; if (vp->v_type != V_NUM) { math_error("Denominator of non-number"); - /*NOTREACHED*/ + not_reached(); } q = qden(vp->v_num); if (stack->v_type == V_NUM) @@ -2715,7 +2716,7 @@ o_usercall(FUNC *fp, long index, long argcount) fp = findfunc(index); if (fp == NULL) { math_error("Function \"%s\" is undefined", namefunc(index)); - /*NOTREACHED*/ + not_reached(); } calculate(fp, (int) argcount); } @@ -3110,7 +3111,7 @@ o_debug(FUNC *UNUSED(fp), long line) funcline = line; if (abortlevel >= ABORT_STATEMENT) { math_error("Calculation aborted at statement boundary"); - /*NOTREACHED*/ + not_reached(); } } @@ -3319,7 +3320,7 @@ o_setepsilon(void) vp = vp->v_addr; if (vp->v_type != V_NUM) { math_error("Non-numeric for epsilon"); - /*NOTREACHED*/ + not_reached(); } newep = vp->v_num; stack->v_num = qlink(conf->epsilon); @@ -3346,13 +3347,13 @@ o_setconfig(void) v2 = v2->v_addr; if (v1->v_type != V_STR) { math_error("Non-string for config"); - /*NOTREACHED*/ + not_reached(); } type = configtype(v1->v_str->s_str); if (type < 0) { math_error("Unknown config name \"%s\"", v1->v_str->s_str); - /*NOTREACHED*/ + not_reached(); } config_value(conf, type, &tmp); setconfig(type, v2); @@ -3373,13 +3374,13 @@ o_getconfig(void) vp = vp->v_addr; if (vp->v_type != V_STR) { math_error("Non-string for config"); - /*NOTREACHED*/ + not_reached(); } type = configtype(vp->v_str->s_str); if (type < 0) { math_error("Unknown config name \"%s\"", vp->v_str->s_str); - /*NOTREACHED*/ + not_reached(); } freevalue(stack); config_value(conf, type, stack); @@ -3416,7 +3417,7 @@ error_value(int e) errcount++; if (errmax >= 0 && errcount > errmax) { math_error("Error %d caused errcount to exceed errmax", e); - /*NOTREACHED*/ + not_reached(); } res.v_type = (short) -e; res.v_subtype = V_NOSUBTYPE; @@ -3472,7 +3473,7 @@ o_initfill(void) v2 = v2->v_addr; if (v1->v_type != V_MAT) { math_error("Non-matrix argument for o_initfill"); - /*NOTREACHED*/ + not_reached(); } s = v1->v_mat->m_size; vp = v1->v_mat->m_table; @@ -3868,7 +3869,7 @@ calculate(FUNC *fp, int argcount) locals = (VALUE *) malloc(sizeof(VALUE) * fp->f_localcount); if (locals == NULL) { math_error("No memory for local variables"); - /*NOTREACHED*/ + not_reached(); } } for (i = 0; i < fp->f_localcount; i++) { @@ -3882,20 +3883,20 @@ calculate(FUNC *fp, int argcount) while (go) { if (abortlevel >= ABORT_OPCODE) { math_error("Calculation aborted in opcode"); - /*NOTREACHED*/ + not_reached(); } if (pc >= fp->f_opcodecount) { math_error("Function pc out of range"); - /*NOTREACHED*/ + not_reached(); } if (stack > &stackarray[MAXSTACK-3]) { math_error("Evaluation stack depth exceeded"); - /*NOTREACHED*/ + not_reached(); } opnum = fp->f_opcodes[pc]; if (opnum > MAX_OPCODE) { math_error("Function opcode out of range"); - /*NOTREACHED*/ + not_reached(); } op = &opcodes[opnum]; if (conf->traceflags & TRACE_OPCODES) { @@ -3961,7 +3962,7 @@ calculate(FUNC *fp, int argcount) free(locals); if (stack != &beginstack[1]) { math_error("Misaligned stack"); - /*NOTREACHED*/ + not_reached(); } if (argcount > 0) { retval = *stack--; @@ -3980,7 +3981,7 @@ calculate(FUNC *fp, int argcount) default: math_error("Unknown opcode type: %d", op->o_type); - /*NOTREACHED*/ + not_reached(); } } for (i = 0; i < fp->f_localcount; i++) @@ -4125,12 +4126,12 @@ freenumbers(FUNC *fp) continue; default: math_error("Unknown opcode type for freeing"); - /*NOTREACHED*/ + not_reached(); } } if (pc != fp->f_opcodecount) { math_error("Incorrect opcodecount ???"); - /*NOTREACHED*/ + not_reached(); } trimconstants(); } diff --git a/qfunc.c b/qfunc.c index 9d941be..79d0ca9 100644 --- a/qfunc.c +++ b/qfunc.c @@ -1,7 +1,7 @@ /* * qfunc - extended precision rational arithmetic non-primitive functions * - * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -31,6 +31,7 @@ #include "prime.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -56,7 +57,7 @@ setepsilon(NUMBER *q) if (qisneg(q) || qiszero(q)) { math_error("Epsilon value must be greater than zero"); - /*NOTREACHED*/ + not_reached(); } old = conf->epsilon; conf->epsilonprec = qprecision(q); @@ -82,7 +83,7 @@ qminv(NUMBER *q1, NUMBER *q2) if (qisfrac(q1) || qisfrac(q2)) { math_error("Non-integers for minv"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q2)) { if (qisunit(q1)) @@ -135,11 +136,11 @@ qpowermod(NUMBER *q1, NUMBER *q2, NUMBER *q3) if (qisfrac(q1) || qisfrac(q2) || qisfrac(q3)) { math_error("Non-integers for pmod"); - /*NOTREACHED*/ + not_reached(); } if (qisneg(q2)) { math_error("Negative power for pmod"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q3)) return qpowi(q1, q2); @@ -191,7 +192,7 @@ qpowi(NUMBER *q1, NUMBER *q2) if (qisfrac(q2)) { math_error("Raising number to fractional power"); - /*NOTREACHED*/ + not_reached(); } num = q1->num; zden = q1->den; @@ -206,7 +207,7 @@ qpowi(NUMBER *q1, NUMBER *q2) if (ziszero(num) && !ziszero(z2)) { /* zero raised to a power */ if (invert) { math_error("Zero raised to negative power"); - /*NOTREACHED*/ + not_reached(); } return qlink(&_qzero_); } @@ -251,7 +252,7 @@ qhypot(NUMBER *q1, NUMBER *q2, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for hypot"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q1)) return qqabs(q2); @@ -281,7 +282,7 @@ qlegtoleg(NUMBER *q, NUMBER *epsilon, BOOL wantneg) if (qiszero(epsilon)) { math_error("Zero epsilon value for legtoleg"); - /*NOTREACHED*/ + not_reached(); } if (qisunit(q)) return qlink(&_qzero_); @@ -294,7 +295,7 @@ qlegtoleg(NUMBER *q, NUMBER *epsilon, BOOL wantneg) num.sign = 0; if (zrel(num, q->den) >= 0) { math_error("Leg too large in legtoleg"); - /*NOTREACHED*/ + not_reached(); } qtmp1 = qsquare(q); qtmp2 = qsub(&_qone_, qtmp1); @@ -329,14 +330,14 @@ qsqrt(NUMBER *q1, NUMBER *epsilon, long rnd) if (qisneg(q1)) { math_error("Square root of negative number"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q1)) return qlink(&_qzero_); sign = (rnd & 64) != 0; if (qiszero(epsilon)) { math_error("Zero epsilon for qsqrt"); - /*NOTREACHED*/ + not_reached(); } etemp = *epsilon; @@ -435,7 +436,7 @@ qisqrt(NUMBER *q) if (qisneg(q)) { math_error("Square root of negative number"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) return qlink(&_qzero_); @@ -477,7 +478,7 @@ qiroot(NUMBER *q1, NUMBER *q2) if (qisneg(q2) || qiszero(q2) || qisfrac(q2)) { math_error("Taking number to bad root value"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q1)) return qlink(&_qzero_); @@ -514,7 +515,7 @@ qilog2(NUMBER *q) if (qiszero(q)) { math_error("Zero argument for ilog2"); - /*NOTREACHED*/ + not_reached(); } if (qisint(q)) return zhighbit(q->num); @@ -554,7 +555,7 @@ qilog10(NUMBER *q) if (qiszero(q)) { math_error("Zero argument for ilog10"); - /*NOTREACHED*/ + not_reached(); } tmp1 = q->num; tmp1.sign = 0; @@ -810,7 +811,7 @@ qfact(NUMBER *q) if (qisfrac(q)) { math_error("Non-integral factorial"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q) || zisone(q->num)) return qlink(&_qone_); @@ -831,7 +832,7 @@ qpfact(NUMBER *q) if (qisfrac(q)) { math_error("Non-integral factorial"); - /*NOTREACHED*/ + not_reached(); } r = qalloc(); zpfact(q->num, &r->num); @@ -850,7 +851,7 @@ qlcmfact(NUMBER *q) if (qisfrac(q)) { math_error("Non-integral lcmfact"); - /*NOTREACHED*/ + not_reached(); } r = qalloc(); zlcmfact(q->num, &r->num); @@ -870,7 +871,7 @@ qperm(NUMBER *q1, NUMBER *q2) if (qisfrac(q2)) { math_error("Non-integral second arg for permutation"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q2)) return qlink(&_qone_); @@ -887,7 +888,7 @@ qperm(NUMBER *q1, NUMBER *q2) } if (zge31b(q2->num)) { math_error("Too large arg2 for permutation"); - /*NOTREACHED*/ + not_reached(); } i = qtoi(q2); if (i > 0) { @@ -934,7 +935,7 @@ qcomb(NUMBER *q, NUMBER *n) if (!qisint(n) || qisneg(n)) { math_error("Bad second arg in call to qcomb!"); - /*NOTREACHED*/ + not_reached(); } if (qisint(q)) { switch (zcomb(q->num, n->num, &z)) { @@ -1181,7 +1182,7 @@ qjacobi(NUMBER *q1, NUMBER *q2) { if (qisfrac(q1) || qisfrac(q2)) { math_error("Non-integral arguments for jacobi"); - /*NOTREACHED*/ + not_reached(); } return itoq((long) zjacobi(q1->num, q2->num)); } @@ -1197,7 +1198,7 @@ qfib(NUMBER *q) if (qisfrac(q)) { math_error("Non-integral Fibonacci number"); - /*NOTREACHED*/ + not_reached(); } r = qalloc(); zfib(q->num, &r->num); @@ -1216,7 +1217,7 @@ qtrunc(NUMBER *q1, NUMBER *q2) if (qisfrac(q2) || !zistiny(q2->num)) { math_error("Bad number of places for qtrunc"); - /*NOTREACHED*/ + not_reached(); } places = qtoi(q2); e = qtenpow(-places); @@ -1240,7 +1241,7 @@ qbtrunc(NUMBER *q1, NUMBER *q2) if (qisfrac(q2) || !zistiny(q2->num)) { math_error("Bad number of places for qtrunc"); - /*NOTREACHED*/ + not_reached(); } places = qtoi(q2); e = qbitvalue(-places); @@ -1678,7 +1679,7 @@ qfacrem(NUMBER *q1, NUMBER *q2) if (qisfrac(q1) || qisfrac(q2)) { math_error("Non-integers for factor removal"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q2)) return qqabs(q1); @@ -1711,7 +1712,7 @@ qgcdrem(NUMBER *q1, NUMBER *q2) if (qisfrac(q1) || qisfrac(q2)) { math_error("Non-integers for gcdrem"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q2)) return qlink(&_qone_); @@ -1745,12 +1746,12 @@ qlowfactor(NUMBER *q1, NUMBER *q2) if (qisfrac(q1) || qisfrac(q2)) { math_error("Non-integers for lowfactor"); - /*NOTREACHED*/ + not_reached(); } count = ztoi(q2->num); if (count > PIX_32B) { math_error("lowfactor count is too large"); - /*NOTREACHED*/ + not_reached(); } return utoq(zlowfactor(q1->num, count)); } @@ -1840,11 +1841,11 @@ qprimetest(NUMBER *q1, NUMBER *q2, NUMBER *q3) { if (qisfrac(q1) || qisfrac(q2) || qisfrac(q3)) { math_error("Bad arguments for ptest"); - /*NOTREACHED*/ + not_reached(); } if (zge24b(q2->num)) { math_error("ptest count >= 2^24"); - /*NOTREACHED*/ + not_reached(); } return zprimetest(q1->num, ztoi(q2->num), q3->num); } diff --git a/qio.c b/qio.c index 962f91a..131ad82 100644 --- a/qio.c +++ b/qio.c @@ -1,7 +1,7 @@ /* * qio - scanf and printf routines for arbitrary precision rational numbers * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -31,6 +31,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -306,7 +307,7 @@ qprintnum(NUMBER *q, int outmode, LEN outdigits) default: math_error("Bad mode for print"); - /*NOTREACHED*/ + not_reached(); } if (outmode2 != MODE2_OFF) { @@ -536,7 +537,7 @@ str2q(char *s) exp = (exp * 10) + *t++ - '0'; if (exp > (MAXLONG/10L)) { math_error("Exponent too large"); - /*NOTREACHED*/ + not_reached(); } } } diff --git a/qmath.c b/qmath.c index d329078..29b7815 100644 --- a/qmath.c +++ b/qmath.c @@ -1,7 +1,7 @@ /* * qmath - extended precision rational arithmetic primitive routines * - * Copyright (C) 1999-2007,2014,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2014,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -31,6 +31,7 @@ #include "config.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -224,7 +225,7 @@ uutoq(FULL inum, FULL iden) if (iden == 0) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } if (inum == 0) return qlink(&_qzero_); @@ -256,7 +257,7 @@ iitoq(long inum, long iden) if (iden == 0) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } if (inum == 0) return qlink(&_qzero_); @@ -504,7 +505,7 @@ qmul(NUMBER *q1, NUMBER *q2) d2 = q2->den; if (ziszero(d1) || ziszero(d2)) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } if (ziszero(n1) || ziszero(n2)) return qlink(&_qzero_); @@ -583,7 +584,7 @@ qqdiv(NUMBER *q1, NUMBER *q2) if (qiszero(q2)) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } if ((q1 == q2) || !qcmp(q1, q2)) return qlink(&_qone_); @@ -611,7 +612,7 @@ qdivi(NUMBER *q, long n) if (n == 0) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } if ((n == 1) || qiszero(q)) return qlink(q); @@ -734,7 +735,7 @@ qinv(NUMBER *q) } if (qiszero(q)) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } r = qalloc(); if (!zisunit(q->num)) @@ -861,7 +862,7 @@ qshift(NUMBER *q, long n) if (qisfrac(q)) { math_error("Shift of non-integer"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q) || (n == 0)) return qlink(q); @@ -954,7 +955,7 @@ qor(NUMBER *q1, NUMBER *q2) if (qisfrac(q1) || qisfrac(q2)) { math_error("Non-integers for bitwise or"); - /*NOTREACHED*/ + not_reached(); } if (qcmp(q1,q2) == 0 || qiszero(q2)) return qlink(q1); @@ -1003,7 +1004,7 @@ qand(NUMBER *q1, NUMBER *q2) if (qisfrac(q1) || qisfrac(q2)) { math_error("Non-integers for bitwise and"); - /*NOTREACHED*/ + not_reached(); } if (qcmp(q1, q2) == 0) return qlink(q1); @@ -1053,7 +1054,7 @@ qxor(NUMBER *q1, NUMBER *q2) if (qisfrac(q1) || qisfrac(q2)) { math_error("Non-integers for bitwise xor"); - /*NOTREACHED*/ + not_reached(); } if (qcmp(q1,q2) == 0) return qlink(&_qzero_); @@ -1106,7 +1107,7 @@ qandnot(NUMBER *q1, NUMBER *q2) if (qisfrac(q1) || qisfrac(q2)) { math_error("Non-integers for bitwise xor"); - /*NOTREACHED*/ + not_reached(); } if (qcmp(q1,q2) == 0 || qiszero(q1)) return qlink(&_qzero_); @@ -1213,7 +1214,7 @@ qprecision(NUMBER *q) if (qiszero(q) || qisneg(q)) { math_error("Non-positive number for precision"); - /*NOTREACHED*/ + not_reached(); } r = - qilog2(q); return (r < 0 ? 0 : r); @@ -1408,7 +1409,7 @@ qalloc(void) freeNum = (NUMBER *) malloc(sizeof (NUMBER) * NNALLOC); if (freeNum == NULL) { math_error("Not enough memory"); - /*NOTREACHED*/ + not_reached(); } freeNum[NNALLOC - 1].next = NULL; freeNum[NNALLOC - 1].links = 0; @@ -1438,7 +1439,7 @@ qalloc(void) } if (newfn == NULL) { math_error("Cannot allocate new number block"); - /*NOTREACHED*/ + not_reached(); } firstNums = newfn; firstNums[blockcount - 1] = freeNum; @@ -1457,11 +1458,11 @@ qfreenum(NUMBER *q) { if (q == NULL) { math_error("Calling qfreenum with null argument!!!"); - /*NOTREACHED*/ + not_reached(); } if (q->links != 0) { math_error("Calling qfreenum with non-zero links!!!"); - /*NOTREACHED*/ + not_reached(); } zfree(q->num); zfree(q->den); diff --git a/qmod.c b/qmod.c index b84fc9a..6fdf970 100644 --- a/qmod.c +++ b/qmod.c @@ -1,7 +1,7 @@ /* * qmod - modular arithmetic routines for normal numbers and REDC numbers * - * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -31,6 +31,7 @@ #include "config.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -371,7 +372,7 @@ qfindredc(NUMBER *q) */ if (qisfrac(q) || qisneg(q)) { math_error("REDC modulus must be positive odd integer"); - /*NOTREACHED*/ + not_reached(); } bestrcp = NULL; diff --git a/qtrans.c b/qtrans.c index 8447d50..ca6534c 100644 --- a/qtrans.c +++ b/qtrans.c @@ -1,7 +1,7 @@ /* * qtrans - transcendental functions for real numbers * - * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -34,6 +34,7 @@ #include "qmath.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -209,7 +210,7 @@ qcos(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for cosine"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) return qlink(&_qone_); @@ -236,7 +237,7 @@ qsin(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for sine"); - /*NOTREACHED*/ + not_reached(); } n = -qilog2(epsilon); if (qiszero(q) || n < 0) @@ -260,7 +261,7 @@ qtan(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for tangent"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) return qlink(q); @@ -301,11 +302,11 @@ qcot(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for cotangent"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) { math_error("Zero argument for cotangent"); - /*NOTREACHED*/ + not_reached(); } k = -qilog2(q); n = qilog2(epsilon); @@ -347,7 +348,7 @@ qsec(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for secant"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) return qlink(&_qone_); @@ -386,11 +387,11 @@ qcsc(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for cosecant"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) { math_error("Zero argument for cosecant"); - /*NOTREACHED*/ + not_reached(); } k = -qilog2(q); n = qilog2(epsilon); @@ -431,7 +432,7 @@ qasin(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for asin"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) return qlink(&_qzero_); @@ -480,7 +481,7 @@ qacos(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for acos"); - /*NOTREACHED*/ + not_reached(); } if (qisone(q)) return qlink(&_qzero_); @@ -526,7 +527,7 @@ qatan(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for arctangent"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) return qlink(&_qzero_); @@ -569,7 +570,7 @@ qatan(NUMBER *q, NUMBER *epsilon) for (;;) { if (d > BASE) { math_error("Too many terms required for atan"); - /*NOTREACHED*/ + not_reached(); } zmul(X, mul, &ztmp1); zfree(X); @@ -644,7 +645,7 @@ qacot(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon for acot"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) { epsilon1 = qscale(epsilon, 1L); @@ -687,7 +688,7 @@ qatan2(NUMBER *qy, NUMBER *qx, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for atan2"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(qy) && qiszero(qx)) { /* conform to 4.3BSD ANSI/IEEE 754-1985 math lib */ @@ -761,7 +762,7 @@ qpi(NUMBER *epsilon) /* firewall */ if (qiszero(epsilon)) { math_error("zero epsilon value for pi"); - /*NOTREACHED*/ + not_reached(); } /* use pi cache if epsilon marches, else flush if needed */ @@ -829,7 +830,7 @@ qpidiv180(NUMBER *epsilon) /* firewall */ if (qiszero(epsilon)) { math_error("zero epsilon value for qpidiv180"); - /*NOTREACHED*/ + not_reached(); } /* use pi/180 cache if epsilon marches, else flush if needed */ @@ -873,7 +874,7 @@ qpidiv200(NUMBER *epsilon) /* firewall */ if (qiszero(epsilon)) { math_error("zero epsilon value for qpidiv200"); - /*NOTREACHED*/ + not_reached(); } /* use pi/200 cache if epsilon marches, else flush if needed */ @@ -916,7 +917,7 @@ qexp(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for exp"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) return qlink(&_qone_); @@ -1048,7 +1049,7 @@ qln(NUMBER *q, NUMBER *epsilon) if (qiszero(q) || qiszero(epsilon)) { math_error("logarithm of 0"); - /*NOTREACHED*/ + not_reached(); } if (qisunit(q)) return qlink(&_qzero_); @@ -1160,7 +1161,7 @@ qlog(NUMBER *q, NUMBER *epsilon) /* firewall */ if (qiszero(q) || qiszero(epsilon)) { math_error("logarithm of 0"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1236,11 +1237,11 @@ qpower(NUMBER *q1, NUMBER *q2, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon for power"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q1) && qisneg(q2)) { math_error("Negative power of zero"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q2) || qisone(q1)) return qlink(&_qone_); @@ -1248,7 +1249,7 @@ qpower(NUMBER *q1, NUMBER *q2, NUMBER *epsilon) return qlink(&_qzero_); if (qisneg(q1)) { math_error("Negative base for qpower"); - /*NOTREACHED*/ + not_reached(); } if (qisone(q2)) return qmappr(q1, epsilon, 24); @@ -1353,11 +1354,11 @@ qroot(NUMBER *q1, NUMBER *q2, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon for root"); - /*NOTREACHED*/ + not_reached(); } if (qisneg(q2) || qiszero(q2) || qisfrac(q2)) { math_error("Taking bad root of number"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q1) || qisone(q1) || qisone(q2)) return qlink(q1); @@ -1367,7 +1368,7 @@ qroot(NUMBER *q1, NUMBER *q2, NUMBER *epsilon) if (neg) { if (ziseven(q2->num)) { math_error("Taking even root of negative number"); - /*NOTREACHED*/ + not_reached(); } q1 = qqabs(q1); } @@ -1510,11 +1511,11 @@ qcoth(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for coth"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) { math_error("Zero argument for coth"); - /*NOTREACHED*/ + not_reached(); } tmp1 = qscale(q, 1); tmp2 = qqabs(tmp1); @@ -1537,7 +1538,7 @@ qcoth(NUMBER *q, NUMBER *epsilon) qfree(tmp1); if (qiszero(tmp2)) { math_error("This should not happen ????"); - /*NOTREACHED*/ + not_reached(); } tmp1 = qinv(tmp2); qfree(tmp2); @@ -1564,7 +1565,7 @@ qsech(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for sech"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) return qlink(&_qone_); @@ -1605,11 +1606,11 @@ qcsch(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for csch"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) { math_error("Zero argument for csch"); - /*NOTREACHED*/ + not_reached(); } n = qilog2(epsilon); @@ -1657,7 +1658,7 @@ qacosh(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for acosh"); - /*NOTREACHED*/ + not_reached(); } if (qisone(q)) return qlink(&_qzero_); @@ -1695,7 +1696,7 @@ qasinh(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for asinh"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) return qlink(&_qzero_); @@ -1737,7 +1738,7 @@ qatanh(NUMBER *q, NUMBER *epsilon) if (qiszero(epsilon)) { math_error("Zero epsilon value for atanh"); - /*NOTREACHED*/ + not_reached(); } if (qiszero(q)) return qlink(&_qzero_); diff --git a/quickhash.c b/quickhash.c index 01821e0..9a584d1 100644 --- a/quickhash.c +++ b/quickhash.c @@ -6,7 +6,7 @@ * * http://www.isthe.com/chongo/tech/comp/fnv/index.html * - * Copyright (C) 1999-2007,2014,2021 Landon Curt Noll + * Copyright (C) 1999-2007,2014,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -40,6 +40,7 @@ #include "zrandom.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -231,7 +232,7 @@ hashvalue(VALUE *vp, QCKHASH val) return blk_hash(vp->v_nblock->blk, val); default: math_error("Hashing unknown value"); - /*NOTREACHED*/ + not_reached(); } return (QCKHASH)0; } diff --git a/sample_many.c b/sample_many.c index 3049043..03a5836 100644 --- a/sample_many.c +++ b/sample_many.c @@ -1,7 +1,7 @@ /* * sample_many - generate many random values via random number generator * - * Copyright (C) 1999-2007,2021 Landon Curt Noll + * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -41,6 +41,7 @@ #include "lib_util.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -106,7 +107,7 @@ main(int argc, char **argv) prev_state = zsrandom2(seed, _one_); if (prev_state == NULL) { math_error("previous random state is NULL"); - /*NOTREACHED*/ + not_reached(); } randomfree(prev_state); diff --git a/sample_rand.c b/sample_rand.c index 12edc6f..753304f 100644 --- a/sample_rand.c +++ b/sample_rand.c @@ -1,7 +1,7 @@ /* * sample_rand - test the libcalc random number generator * - * Copyright (C) 1999-2007,2021 Landon Curt Noll + * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -41,6 +41,7 @@ #include "lib_util.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -96,7 +97,7 @@ main(int argc, char **argv) prev_state = zsrandom2(seed, _ten_); if (prev_state == NULL) { math_error("previous random state is NULL"); - /*NOTREACHED*/ + not_reached(); } /* diff --git a/sha1.c b/sha1.c index 38b665a..b3e9c9d 100644 --- a/sha1.c +++ b/sha1.c @@ -36,6 +36,7 @@ #include "sha1.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -367,7 +368,7 @@ sha1Final(HASH *state) } else { if (count % 4) { math_error("This should not happen in sha1Final"); - /*NOTREACHED*/ + not_reached(); } data[count + 3] = 0x80; } @@ -563,7 +564,7 @@ sha1_final_state(HASH *state) state = (HASH *)malloc(sizeof(HASH)); if (state == NULL) { math_error("cannot malloc HASH"); - /*NOTREACHED*/ + not_reached(); } sha1_init_state(state); } diff --git a/size.c b/size.c index 5421f16..12cbf8d 100644 --- a/size.c +++ b/size.c @@ -1,7 +1,7 @@ /* * size - size and sizeof functions are implemented here * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -30,6 +30,7 @@ #include "block.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -316,7 +317,7 @@ lsizeof(VALUE *vp) break; default: math_error("sizeof not defined for value type"); - /*NOTREACHED*/ + not_reached(); } } return s; @@ -436,7 +437,7 @@ memsize(VALUE *vp) break; default: math_error("memsize not defined for value type"); - /*NOTREACHED*/ + not_reached(); } } return s; diff --git a/str.c b/str.c index 17a9361..1d98ef5 100644 --- a/str.c +++ b/str.c @@ -1,7 +1,7 @@ /* * str - string list routines * - * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -38,6 +38,7 @@ #include "strl.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -73,7 +74,7 @@ initstr(STRINGHEAD *hp) hp->h_list = (char *)malloc(STR_CHUNK + 1); if (hp->h_list == NULL) { math_error("Cannot allocate string header"); - /*NOTREACHED*/ + not_reached(); } hp->h_list[STR_CHUNK] = '\0'; /* guard paranoia */ hp->h_avail = STR_CHUNK; @@ -144,7 +145,7 @@ charstr(int ch) cp = (char *)malloc((OCTET_VALUES + 1)*2); if (cp == NULL) { math_error("Cannot allocate character table"); - /*NOTREACHED*/ + not_reached(); } for (i = 0; i < OCTET_VALUES; i++) { *cp++ = (char)i; @@ -295,7 +296,7 @@ addliteral(char *str) } if (table == NULL) { math_error("Cannot allocate string literal table"); - /*NOTREACHED*/ + not_reached(); } literals.l_table = table; literals.l_maxcount = count; @@ -314,7 +315,7 @@ addliteral(char *str) newstr = (char *)malloc(len + 1); if (newstr == NULL) { math_error("Cannot allocate large literal string"); - /*NOTREACHED*/ + not_reached(); } newstr[len] = '\0'; /* guard paranoia */ strlcpy(newstr, str, len); @@ -330,7 +331,7 @@ addliteral(char *str) newstr = (char *)malloc(STR_CHUNK + 1); if (newstr == NULL) { math_error("Cannot allocate new literal string"); - /*NOTREACHED*/ + not_reached(); } newstr[STR_CHUNK] = '\0'; /* guard paranoia */ literals.l_alloc = newstr; @@ -1128,7 +1129,7 @@ stralloc(void) freeStr = (STRING *) malloc(sizeof (STRING) * (STRALLOC + 1)); if (freeStr == NULL) { math_error("Unable to allocate memory for stralloc"); - /*NOTREACHED*/ + not_reached(); } /* guard paranoia */ memset(freeStr+STRALLOC, 0, sizeof(STRING)); @@ -1166,7 +1167,7 @@ stralloc(void) } if (newfn == NULL) { math_error("Cannot allocate new string block"); - /*NOTREACHED*/ + not_reached(); } firstStrs = newfn; firstStrs[blockcount - 1] = freeStr; @@ -1204,7 +1205,7 @@ charstring(int ch) c = (char *) malloc(2); if (c == NULL) { math_error("Allocation failure for charstring"); - /*NOTREACHED*/ + not_reached(); } s = stralloc(); s->s_len = 1; @@ -1232,7 +1233,7 @@ makenewstring(char *str) c = (char *) malloc(len + 1); if (c == NULL) { math_error("malloc for makenewstring failed"); - /*NOTREACHED*/ + not_reached(); } s = stralloc(); s->s_str = c; @@ -1256,7 +1257,7 @@ stringcopy (STRING *s1) c = malloc(len + 1); if (c == NULL) { math_error("Malloc failed for stringcopy"); - /*NOTREACHED*/ + not_reached(); } s = stralloc(); s->s_len = len; @@ -1272,7 +1273,7 @@ slink(STRING *s) { if (s->s_links <= 0) { math_error("Argument for slink has non-positive links!!!"); - /*NOTREACHED*/ + not_reached(); } ++s->s_links; return s; @@ -1284,7 +1285,7 @@ sfree(STRING *s) { if (s->s_links <= 0) { math_error("Argument for sfree has non-positive links!!!"); - /*NOTREACHED*/ + not_reached(); } if (--s->s_links > 0 || s->s_len == 0) return; @@ -1306,7 +1307,7 @@ initstrings(void) malloc(sizeof(STRING *) * (STRCONSTALLOC + 1)); if (stringconsttable == NULL) { math_error("Unable to allocate constant table"); - /*NOTREACHED*/ + not_reached(); } stringconsttable[STRCONSTALLOC] = NULL; /* guard paranoia */ stringconsttable[0] = &_nullstring_; @@ -1343,7 +1344,7 @@ addstring(char *str, size_t len) if (sp == NULL) { math_error("Unable to reallocate string " "const table"); - /*NOTREACHED*/ + not_reached(); } /* guard paranoia */ sp[stringconstcount + STRCONSTALLOC] = NULL; @@ -1373,7 +1374,7 @@ addstring(char *str, size_t len) c = (char *) malloc(len + 1); if (c == NULL) { math_error("Unable to allocate string constant memory"); - /*NOTREACHED*/ + not_reached(); } s->s_str = c; s->s_len = len; @@ -1393,7 +1394,7 @@ findstring(long index) { if (index < 0 || index >= stringconstcount) { math_error("Bad index for findstring"); - /*NOTREACHED*/ + not_reached(); } return stringconsttable[index]; } diff --git a/symbol.c b/symbol.c index 758c00b..887850f 100644 --- a/symbol.c +++ b/symbol.c @@ -1,7 +1,7 @@ /* * symbol - global and local symbol routines * - * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -35,6 +35,7 @@ #include "func.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -539,7 +540,7 @@ addstatic(GLOBAL *sp) (20 + staticcount) * sizeof(GLOBAL *)); if (stp == NULL) { math_error("Cannot allocate static-variable table"); - /*NOTREACHED*/ + not_reached(); } statictable = stp; staticavail = 20; diff --git a/token.c b/token.c index 1829746..00e8e39 100644 --- a/token.c +++ b/token.c @@ -1,7 +1,7 @@ /* * token - read input file characters into tokens * - * Copyright (C) 1999-2007,2017,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2017,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -37,6 +37,7 @@ #include "lib_calc.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -537,7 +538,7 @@ eatstring(int quotechar) str = (char *) malloc(len); if (str == NULL) { math_error("Out of memory for reading tokens"); - /*NOTREACHED*/ + not_reached(); } memcpy(str + totlen, buf, len); totlen += len; @@ -628,7 +629,7 @@ eatnumber(void) cp = (char *)realloc(numbuf, numbufsize + 1001); if (cp == NULL) { math_error("Cannot reallocate number buffer"); - /*NOTREACHED*/ + not_reached(); } numbuf = cp; numbufsize += 1000; @@ -745,7 +746,7 @@ scanerror(int skip, char *fmt, ...) if ((!c_flag && !stoponerror) || stoponerror > 0) { if (calc_use_scanerr_jmpbuf != 0) { longjmp(calc_scanerr_jmpbuf, 60); - /*NOTREACHED*/ + not_reached(); } else { fprintf(stderr, "calc_scanerr_jmpbuf not setup, exiting code 60\n"); @@ -759,7 +760,7 @@ scanerror(int skip, char *fmt, ...) fprintf(stderr, "Too many scan errors, compilation aborted.\n"); if (calc_use_scanerr_jmpbuf != 0) { longjmp(calc_scanerr_jmpbuf, 61); - /*NOTREACHED*/ + not_reached(); } else { fprintf(stderr, "calc_scanerr_jmpbuf not ready: exit 61\n"); diff --git a/value.c b/value.c index f21348c..4f5fb38 100644 --- a/value.c +++ b/value.c @@ -1,7 +1,7 @@ /* * value - generic value manipulation routines * - * Copyright (C) 1999-2007,2014,2017,2021 David I. Bell + * Copyright (C) 1999-2007,2014,2017,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -39,6 +39,7 @@ #include "config.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -109,7 +110,7 @@ freevalue(VALUE *vp) break; default: math_error("Freeing unknown value type"); - /*NOTREACHED*/ + not_reached(); } } @@ -242,7 +243,7 @@ copyvalue(VALUE *oldvp, VALUE *newvp) break; default: math_error("Copying unknown value type"); - /*NOTREACHED*/ + not_reached(); } } newvp->v_subtype = oldvp->v_subtype; @@ -434,7 +435,7 @@ addvalue(VALUE *v1, VALUE *v2, VALUE *vres) q = v2->v_num; if (qisfrac(q)) { math_error("Adding non-integer to address"); - /*NOTREACHED*/ + not_reached(); } i = qtoi(q); vres->v_addr = v1->v_addr + i; @@ -444,7 +445,7 @@ addvalue(VALUE *v1, VALUE *v2, VALUE *vres) q = v2->v_num; if (qisfrac(q)) { math_error("Adding non-integer to address"); - /*NOTREACHED*/ + not_reached(); } i = qtoi(q); vres->v_octet = v1->v_octet + i; @@ -513,7 +514,7 @@ subvalue(VALUE *v1, VALUE *v2, VALUE *vres) q = v2->v_num; if (qisfrac(q)) { math_error("Subtracting non-integer from address"); - /*NOTREACHED*/ + not_reached(); } i = qtoi(q); vres->v_addr = v1->v_addr - i; @@ -523,7 +524,7 @@ subvalue(VALUE *v1, VALUE *v2, VALUE *vres) q = v2->v_num; if (qisfrac(q)) { math_error("Adding non-integer to address"); - /*NOTREACHED*/ + not_reached(); } i = qtoi(q); vres->v_octet = v1->v_octet - i; @@ -2474,7 +2475,7 @@ comparevalue(VALUE *v1, VALUE *v2) return (v1->v_num != v2->v_num); default: math_error("Illegal values for comparevalue"); - /*NOTREACHED*/ + not_reached(); } return (r != 0); } @@ -2859,7 +2860,7 @@ printvalue(VALUE *vp, int flags) break; default: math_error("Printing unrecognized type of value"); - /*NOTREACHED*/ + not_reached(); } } @@ -2996,7 +2997,7 @@ config_print(CONFIG *cfg) if (cfg == NULL || cfg->epsilon == NULL || cfg->prompt1 == NULL || cfg->prompt2 == NULL) { math_error("CONFIG value is invalid"); - /*NOTREACHED*/ + not_reached(); } /* diff --git a/zfunc.c b/zfunc.c index 41075fc..82b4120 100644 --- a/zfunc.c +++ b/zfunc.c @@ -1,8 +1,7 @@ /* * zfunc - extended precision integral arithmetic non-primitive routines * - * Copyright (C) 1999-2007,2021 David I. Bell, Landon Curt Noll - * and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell, Landon Curt Noll and Ernest Bowen * * Primary author: David I. Bell * @@ -31,6 +30,7 @@ #include "alloc.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -196,11 +196,11 @@ zfact(ZVALUE z, ZVALUE *dest) if (zisneg(z)) { math_error("Negative argument for factorial"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(z)) { math_error("Very large factorial"); - /*NOTREACHED*/ + not_reached(); } n = ztolong(z); ptwo = 0; @@ -249,15 +249,15 @@ zperm(ZVALUE z1, ZVALUE z2, ZVALUE *res) if (zisneg(z1) || zisneg(z2)) { math_error("Negative argument for permutation"); - /*NOTREACHED*/ + not_reached(); } if (zrel(z1, z2) < 0) { math_error("Second arg larger than first in permutation"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(z2)) { math_error("Very large permutation"); - /*NOTREACHED*/ + not_reached(); } count = ztolong(z2); zcopy(z1, &ans); @@ -468,7 +468,7 @@ zfib(ZVALUE z, ZVALUE *res) if (zge31b(z)) { math_error("Very large Fibonacci number"); - /*NOTREACHED*/ + not_reached(); } n = ztolong(z); if (n == 0) { @@ -547,7 +547,7 @@ zpowi(ZVALUE z1, ZVALUE z2, ZVALUE *res) } if (zge31b(z2)) { math_error("Raising to very large power"); - /*NOTREACHED*/ + not_reached(); } power = ztoulong(z2); if (zistwo(z1)) { /* two raised to a power */ @@ -669,7 +669,7 @@ ztenpow(long power, ZVALUE *res) zsquare(_tenpowers_[i-1], &_tenpowers_[i]); } else { math_error("cannot compute 10^2^(TEN_MAX+1)"); - /*NOTREACHED*/ + not_reached(); } } if (power & 0x1) { @@ -1267,7 +1267,7 @@ zlog(ZVALUE z, ZVALUE base) */ if (ziszero(z) || ziszero(base) || zisone(base)) { math_error("Zero or too small argument argument for zlog!!!"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1337,7 +1337,7 @@ zlog10(ZVALUE z, BOOL *was_10_power) if (ziszero(z)) { math_error("Zero argument argument for zlog10"); - /*NOTREACHED*/ + not_reached(); } /* Ignore sign of z */ @@ -1357,7 +1357,7 @@ zlog10(ZVALUE z, BOOL *was_10_power) power10 = malloc(sizeof(long) * (max_power10_exp+1)); if (power10 == NULL) { math_error("cannot malloc power10 table"); - /*NOTREACHED*/ + not_reached(); } /* load power10 table */ @@ -1396,7 +1396,7 @@ zlog10(ZVALUE z, BOOL *was_10_power) while (((zp->len * 2) - 1) <= z.len) { /* while square not too large */ if (zp >= &_tenpowers_[TEN_MAX]) { math_error("Maximum storable power of 10 reached!"); - /*NOTREACHED*/ + not_reached(); } if (zp[1].len == 0) zsquare(*zp, zp + 1); @@ -1420,7 +1420,7 @@ zlog10(ZVALUE z, BOOL *was_10_power) } while (rel > 0 && --zp >= _tenpowers_); if (zp < _tenpowers_) { math_error("fell off bottom of tenpower table!"); - /*NOTREACHED*/ + not_reached(); } /* the tenpower value is now our starting comparison value */ @@ -1625,7 +1625,7 @@ zgcdrem(ZVALUE z1, ZVALUE z2, ZVALUE *res) if (ziszero(z1) || ziszero(z2)) { math_error("Zero argument in call to zgcdrem!!!"); - /*NOTREACHED*/ + not_reached(); } /* * Begin by taking the gcd for the first time. @@ -1755,7 +1755,7 @@ zsqrt(ZVALUE z, ZVALUE *dest, long rnd) if (z.sign) { math_error("Square root of negative number"); - /*NOTREACHED*/ + not_reached(); } if (ziszero(z)) { *dest = _zero_; @@ -2026,11 +2026,11 @@ zroot(ZVALUE z1, ZVALUE z2, ZVALUE *dest) sign = z1.sign; if (sign && ziseven(z2)) { math_error("Even root of negative number"); - /*NOTREACHED*/ + not_reached(); } if (ziszero(z2) || zisneg(z2)) { math_error("Non-positive root"); - /*NOTREACHED*/ + not_reached(); } if (ziszero(z1)) { /* root of zero */ *dest = _zero_; diff --git a/zio.c b/zio.c index 0735885..339d2af 100644 --- a/zio.c +++ b/zio.c @@ -1,7 +1,7 @@ /* * zio - scanf and printf routines for arbitrary precision integers * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -31,6 +31,7 @@ #include "args.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -105,7 +106,7 @@ math_chr(int ch) cp = (char *)realloc(outbuf, outbufsize + OUTBUFSIZE + 1); if (cp == NULL) { math_error("Cannot realloc output string"); - /*NOTREACHED*/ + not_reached(); } outbuf = cp; outbufsize += OUTBUFSIZE; @@ -133,7 +134,7 @@ math_str(char *str) cp = (char *)realloc(outbuf, outbufsize + len + OUTBUFSIZE + 1); if (cp == NULL) { math_error("Cannot realloc output string"); - /*NOTREACHED*/ + not_reached(); } outbuf = cp; outbufsize += (len + OUTBUFSIZE); @@ -211,7 +212,7 @@ math_divertio(void) sp = (IOSTATE *) malloc(sizeof(IOSTATE)); if (sp == NULL) { math_error("No memory for diverting output"); - /*NOTREACHED*/ + not_reached(); } sp->oldiostates = oldiostates; sp->outdigits = conf->outdigits; @@ -228,7 +229,7 @@ math_divertio(void) outbuf = (char *) malloc(OUTBUFSIZE + 1); if (outbuf == NULL) { math_error("Cannot allocate divert string"); - /*NOTREACHED*/ + not_reached(); } outbufsize = OUTBUFSIZE; outputisstring = TRUE; @@ -250,7 +251,7 @@ math_getdivertedio(void) sp = oldiostates; if (sp == NULL) { math_error("No diverted state to restore"); - /*NOTREACHED*/ + not_reached(); } cp = outbuf; cp[outbufused] = '\0'; @@ -310,7 +311,7 @@ math_setmode(int newmode) if ((newmode <= MODE_DEFAULT) || (newmode > MODE_MAX)) { math_error("Setting illegal output mode"); - /*NOTREACHED*/ + not_reached(); } oldmode = conf->outmode; conf->outmode = newmode; @@ -330,7 +331,7 @@ math_setmode2(int newmode) if (newmode != MODE2_OFF && ((newmode <= MODE_DEFAULT) || (newmode > MODE_MAX))) { math_error("Setting illegal secondary output mode"); - /*NOTREACHED*/ + not_reached(); } oldmode = conf->outmode2; conf->outmode2 = newmode; @@ -349,7 +350,7 @@ math_setdigits(LEN newdigits) if (newdigits < 0) { math_error("Setting illegal number of digits"); - /*NOTREACHED*/ + not_reached(); } olddigits = conf->outdigits; conf->outdigits = newdigits; @@ -630,7 +631,7 @@ zprintval(ZVALUE z, long decimals, long width) &_tenpowers_[depth]); } else { math_error("cannot compute 10^2^(TEN_MAX+1)"); - /*NOTREACHED*/ + not_reached(); } } } diff --git a/zmath.c b/zmath.c index 560a4fb..5b3f648 100644 --- a/zmath.c +++ b/zmath.c @@ -1,7 +1,7 @@ /* * zmath - extended precision integral arithmetic primitives * - * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -31,6 +31,7 @@ #include "zmath.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -233,12 +234,12 @@ alloc(LEN len) if (_math_abort_) { math_error("Calculation aborted"); - /*NOTREACHED*/ + not_reached(); } hp = (HALF *) malloc((len+1) * sizeof(HALF)); if (hp == 0) { math_error("Not enough memory"); - /*NOTREACHED*/ + not_reached(); } #ifdef ALLOCTEST ++nalloc; @@ -725,7 +726,7 @@ zdiv(ZVALUE z1, ZVALUE z2, ZVALUE *quo, ZVALUE *rem, long rnd) if (ziszero(z2)) { math_error("Division by zero in zdiv"); - /*NOTREACHED*/ + not_reached(); } m = z1.len; n = z2.len; @@ -998,7 +999,7 @@ zequo(ZVALUE z1, ZVALUE z2, ZVALUE *res) } if (ziszero(z2)) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } if (zisone(z2)) { zcopy(z1, res); @@ -1006,7 +1007,7 @@ zequo(ZVALUE z1, ZVALUE z2, ZVALUE *res) } if (zhighbit(z1) < zhighbit(z2)) { math_error("Bad call to zequo"); - /*NOTREACHED*/ + not_reached(); } B = z2.v; o = 0; @@ -1124,7 +1125,7 @@ zdivi(ZVALUE z, long n, ZVALUE *res) if (n == 0) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } if (ziszero(z)) { *res = _zero_; @@ -1195,11 +1196,11 @@ zmodi(ZVALUE z, long n) if (n == 0) { math_error("Division by zero"); - /*NOTREACHED*/ + not_reached(); } if (n < 0) { math_error("Non-positive modulus"); - /*NOTREACHED*/ + not_reached(); } if (ziszero(z) || (n == 1)) return 0; diff --git a/zmod.c b/zmod.c index 8dc5318..762d188 100644 --- a/zmod.c +++ b/zmod.c @@ -1,8 +1,7 @@ /* * zmod - modulo arithmetic routines * - * Copyright (C) 1999-2007,2021 David I. Bell, Landon Curt Noll - * and Ernest Bowen + * Copyright (C) 1999-2007,2021,2022 David I. Bell, Landon Curt Noll and Ernest Bowen * * Primary author: David I. Bell * @@ -42,6 +41,7 @@ #include "zmath.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -76,9 +76,10 @@ zsquaremod(ZVALUE z1, ZVALUE z2, ZVALUE *res) FULL prod; FULL digit; - if (ziszero(z2) || zisneg(z2)) + if (ziszero(z2) || zisneg(z2)) { math_error("Mod of non-positive integer"); - /*NOTREACHED*/ + not_reached(); + } if (ziszero(z1) || zisunit(z2)) { *res = _zero_; return; @@ -139,7 +140,7 @@ zminmod(ZVALUE z1, ZVALUE z2, ZVALUE *res) if (ziszero(z2) || zisneg(z2)) { math_error("Mod of non-positive integer"); - /*NOTREACHED*/ + not_reached(); } if (ziszero(z1) || zisunit(z2)) { *res = _zero_; @@ -232,7 +233,7 @@ zcmpmod(ZVALUE z1, ZVALUE z2, ZVALUE z3) if (zisneg(z3) || ziszero(z3)) { math_error("Non-positive modulus in zcmpmod"); - /*NOTREACHED*/ + not_reached(); } if (zistwo(z3)) return (((z1.v[0] + z2.v[0]) & 0x1) != 0); @@ -363,7 +364,7 @@ zmod5(ZVALUE *zp) z1.sign = z2.sign = z3.sign = 0; if (z1.len > modlen + 1) { math_error("Bad call to zmod5!!!"); - /*NOTREACHED*/ + not_reached(); } z2.v = lastmodinv->v + modlen + 1 - z1.len; z2.len = lastmodinv->len - modlen - 1 + z1.len; @@ -400,7 +401,7 @@ zmod5(ZVALUE *zp) subcount++; if (subcount > 2) { math_error("Too many subtractions in zmod5"); - /*NOTREACHED*/ + not_reached(); } j = modlen; a = zp->v; @@ -498,11 +499,11 @@ zpowermod(ZVALUE z1, ZVALUE z2, ZVALUE z3, ZVALUE *res) if (zisneg(z3) || ziszero(z3)) { math_error("Non-positive modulus in zpowermod"); - /*NOTREACHED*/ + not_reached(); } if (zisneg(z2)) { math_error("Negative power in zpowermod"); - /*NOTREACHED*/ + not_reached(); } @@ -884,13 +885,13 @@ zredcalloc(ZVALUE z1) if (ziseven(z1) || zisneg(z1)) { math_error("REDC requires positive odd modulus"); - /*NOTREACHED*/ + not_reached(); } rp = (REDC *) malloc(sizeof(REDC)); if (rp == NULL) { math_error("Cannot allocate REDC structure"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1708,7 +1709,7 @@ zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res) if (zisneg(z2)) { math_error("Negative power in zredcpower"); - /*NOTREACHED*/ + not_reached(); } if (zisunit(rp->mod)) { @@ -1991,19 +1992,19 @@ zhnrmod(ZVALUE v, ZVALUE zh, ZVALUE zn, ZVALUE zr, ZVALUE *res) */ if (zisneg(zh) || ziszero(zh)) { math_error("h must be > 0"); - /*NOTREACHED*/ + not_reached(); } if (zisneg(zn) || ziszero(zn)) { math_error("n must be > 0"); - /*NOTREACHED*/ + not_reached(); } if (zge31b(zn)) { math_error("n must be < 2^31"); - /*NOTREACHED*/ + not_reached(); } if (!zisabsleone(zr)) { math_error("r must be -1, 0 or 1"); - /*NOTREACHED*/ + not_reached(); } diff --git a/zmul.c b/zmul.c index 0efc948..5f0afeb 100644 --- a/zmul.c +++ b/zmul.c @@ -1,7 +1,7 @@ /* * zmul - faster than usual multiplying and squaring routines * - * Copyright (C) 1999-2007,2021 David I. Bell + * Copyright (C) 1999-2007,2021,2022 David I. Bell * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -37,6 +37,7 @@ #include "zmath.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -1072,7 +1073,7 @@ zalloctemp(LEN len) hp = (HALF *) malloc((len+1) * sizeof(HALF)); if (hp == NULL) { math_error("No memory for temp buffer"); - /*NOTREACHED*/ + not_reached(); } bufptr = hp; buflen = len; diff --git a/zprime.c b/zprime.c index ad3c965..c3a64ea 100644 --- a/zprime.c +++ b/zprime.c @@ -1,7 +1,7 @@ /* * zprime - rapid small prime routines * - * Copyright (C) 1999-2007,2021 Landon Curt Noll + * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -33,6 +33,7 @@ #include "have_const.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -830,11 +831,11 @@ zpfact(ZVALUE z, ZVALUE *dest) /* firewall */ if (zisneg(z)) { math_error("Negative argument for factorial"); - /*NOTREACHED*/ + not_reached(); } if (zge24b(z)) { math_error("Very large factorial"); - /*NOTREACHED*/ + not_reached(); } n = ztolong(z); @@ -1534,11 +1535,11 @@ zlcmfact(ZVALUE z, ZVALUE *dest) if (zisneg(z) || ziszero(z)) { math_error("Non-positive argument for lcmfact"); - /*NOTREACHED*/ + not_reached(); } if (zge24b(z)) { math_error("Very large lcmfact"); - /*NOTREACHED*/ + not_reached(); } n = ztolong(z); /* diff --git a/zrand.c b/zrand.c index 88d9e47..cc83bf5 100644 --- a/zrand.c +++ b/zrand.c @@ -1,7 +1,7 @@ /* * zrand - subtractive 100 shuffle generator * - * Copyright (C) 1999-2007,2021 Landon Curt Noll + * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -357,6 +357,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -1176,7 +1177,7 @@ zsrand(CONST ZVALUE *pseed, CONST MATRIX *pmat100) */ if (pseed != NULL && zisneg(*pseed)) { math_error("neg seeds for srand reserved for future use"); - /*NOTREACHED*/ + not_reached(); } /* @@ -1192,7 +1193,7 @@ zsrand(CONST ZVALUE *pseed, CONST MATRIX *pmat100) ret = (RAND *)malloc(sizeof(RAND)); if (ret == NULL) { math_error("cannot allocate RAND state"); - /*NOTREACHED*/ + not_reached(); } *ret = s100; @@ -1236,14 +1237,14 @@ zsrand(CONST ZVALUE *pseed, CONST MATRIX *pmat100) */ if (pmat100->m_size < S100) { math_error("matrix for srand has < 100 elements"); - /*NOTREACHED*/ + not_reached(); } for (v=pmat100->m_table, i=0; i < S100; ++i, ++v) { /* reject if not integer */ if (v->v_type != V_NUM || qisfrac(v->v_num)) { math_error("matrix for srand must contain ints"); - /*NOTREACHED*/ + not_reached(); } /* load table element from matrix element mod 2^64 */ @@ -1927,12 +1928,12 @@ zrand(long cnt, ZVALUE *res) return; } else { math_error("negative zrand bit count"); - /*NOTREACHED*/ + not_reached(); } #if LONG_BITS > 32 } else if (cnt > (1L<<31)) { math_error("huge rand bit count in internal zrand function"); - /*NOTREACHED*/ + not_reached(); #endif } @@ -2191,7 +2192,7 @@ zrandrange(CONST ZVALUE low, CONST ZVALUE beyond, ZVALUE *res) */ if (zrel(low, beyond) >= 0) { math_error("srand low range >= beyond range"); - /*NOTREACHED*/ + not_reached(); } /* @@ -2251,7 +2252,7 @@ irand(long s) if (s <= 0) { math_error("Non-positive argument for irand()"); - /*NOTREACHED*/ + not_reached(); } if (s == 1) return 0; @@ -2284,7 +2285,7 @@ randcopy(CONST RAND *state) ret = (RAND *)malloc(sizeof(RAND)); if (ret == NULL) { math_error("can't allocate RAND state"); - /*NOTREACHED*/ + not_reached(); } memcpy(ret, state, sizeof(RAND)); diff --git a/zrandom.c b/zrandom.c index 7975a82..ca38e23 100644 --- a/zrandom.c +++ b/zrandom.c @@ -1,7 +1,7 @@ /* * zrandom - Blum-Blum-Shub pseudo-random generator * - * Copyright (C) 1999-2007,2021 Landon Curt Noll + * Copyright (C) 1999-2007,2021,2022 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -1099,6 +1099,7 @@ #include "have_unused.h" +#include "attribute.h" #include "banned.h" /* include after system header <> includes */ @@ -2342,7 +2343,7 @@ zsrandom1(CONST ZVALUE seed, BOOL need_ret) */ } else { math_error("srandom seed must be 0 or >= 2^32"); - /*NOTREACHED*/ + not_reached(); } /* @@ -2409,12 +2410,12 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn) */ if (ziszero(newn)) { math_error("srandom newn == 0 reserved for future use"); - /*NOTREACHED*/ + not_reached(); } set = (HALF)z1tol(newn); if (!zistiny(newn) || set > BLUM_PREGEN) { math_error("srandom small newn must be [1,20]"); - /*NOTREACHED*/ + not_reached(); } zfree_random(blum.n); zcopy(random_pregen[set-1].n, &blum.n); @@ -2452,7 +2453,7 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn) */ if (newn.v[0] % 4 != 1) { math_error("srandom large newn must be 1 mod 4"); - /*NOTREACHED*/ + not_reached(); } /* @@ -2498,7 +2499,7 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn) */ } else { math_error("srandom newn must be [1,20] or >= 2^32"); - /*NOTREACHED*/ + not_reached(); } /* @@ -2559,11 +2560,11 @@ zsrandom4(CONST ZVALUE seed, CONST ZVALUE ip, CONST ZVALUE iq, long trials) */ if (!znextcand(ip, trials, _zero_, _three_, _four_, &p)) { math_error("failed to find 1st Blum prime"); - /*NOTREACHED*/ + not_reached(); } if (!znextcand(iq, trials, _zero_, _three_, _four_, &q)) { math_error("failed to find 2nd Blum prime"); - /*NOTREACHED*/ + not_reached(); } /* @@ -2777,12 +2778,12 @@ zrandom(long cnt, ZVALUE *res) return; } else { math_error("negative zrandom bit count"); - /*NOTREACHED*/ + not_reached(); } #if LONG_BITS > 32 } else if (cnt > (1L<<31)) { math_error("huge random count in internal zrandom function"); - /*NOTREACHED*/ + not_reached(); #endif } @@ -2955,7 +2956,7 @@ zrandomrange(CONST ZVALUE low, CONST ZVALUE beyond, ZVALUE *res) */ if (zrel(low, beyond) >= 0) { math_error("srand low range >= beyond range"); - /*NOTREACHED*/ + not_reached(); } /* @@ -3015,7 +3016,7 @@ irandom(long s) if (s <= 0) { math_error("Non-positive argument for irandom()"); - /*NOTREACHED*/ + not_reached(); } if (s == 1) return 0; @@ -3048,7 +3049,7 @@ randomcopy(CONST RANDOM *state) ret = (RANDOM *)malloc(sizeof(RANDOM)); if (ret == NULL) { math_error("can't allocate RANDOM state"); - /*NOTREACHED*/ + not_reached(); } /*