diff --git a/.gitignore b/.gitignore index 4421751..9d5125f 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ custom/libcustcalc* endian endian_calc.h fposval.h +have_ban_pragma.h have_const.h have_fpos.h have_fpos_pos.h @@ -49,6 +50,8 @@ have_stdlib.h have_stdvs have_strdup.h have_string.h +have_strlcat.h +have_strlcpy.h have_times.h have_uid_t.h have_unistd.h @@ -88,6 +91,7 @@ longbits longbits.h sample_many sample_rand +tags terminal.h ver_calc diff --git a/BUGS b/BUGS index feebd37..6e885a8 100644 --- a/BUGS +++ b/BUGS @@ -116,8 +116,6 @@ of a context diff patch). Known bugs in calc: - Under macOS, runtime(), systime(), and usertime() only return 0. - Under macOS, the installation of the calc man page fails. The output of the alg_config.cal resource file is bogus. diff --git a/CHANGES b/CHANGES index b95e633..9417cf0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,16 +1,4 @@ -The following are the changes from calc version 2.12.8.1 to date: - - Fixed how the *.tar.bz2 are formed. The calc-2.12.8.0.tar.bz2 file - that was formed for calc version 2.12.8.0 was missing most files. - - Expanded 'make chk' to also verify that 'make distchk' and 'make - distlist' execute successfully. This will help check a regression - of the bug that produced the bogus calc-2.12.8.0.tar.bz2 file. - - Added additional regression tests related 0^(zero_expression)==1. - - Calc can now correctly compile without CUSTOM being defined, - thanks to a report by . +The following are the changes from calc version 2.12.9.0 to date: Added notes to help/unexpected about: @@ -22,7 +10,7 @@ The following are the changes from calc version 2.12.8.1 to date: fprintf(fd, "%d\n", huge_value) may need fflush(fd) to finish - Fixed Makefile dependenies for the args.h rule. + Fixed Makefile dependencies for the args.h rule. Fixed Makefile cases where echo with -n is used. On some systems, /bin/sh does not use -n, so we must call /bin/echo -n instead @@ -37,6 +25,110 @@ The following are the changes from calc version 2.12.8.1 to date: Fixed the depend rule in the custom Makefile. + Improved the messages produced by the depend in the Makefiles. + + Changed the UNUSED define in have_unused.h to be a macro with + a parameter. Changed all use of UNUSED in *.c to be UNUSED(x). + + Removed need for HAVE_UNUSED in building the have_unused.h file. + + CCBAN is given to ${CC} in order to control if banned.h is in effect. + + The banned.h attempts to ban the use of certain dangerous functions + that, if improperly used, could compromise the computational integrity + if calculations. + + In the case of calc, we are motivated in part by the desire for calc + to correctly calculate: even during extremely long calculations. + + If UNBAN is NOT defined, then calling certain functions + will result in a call to a non-existent function (link error). + + While we do NOT encourage defining UNBAN, there may be + a system / compiler environment where re-defining a + function may lead to a fatal compiler complication. + If that happens, consider compiling as: + + make clobber all chk CCBAN=-DUNBAN + + as see if this is a work-a-round. + + If YOU discover a need for the -DUNBAN work-a-round, PLEASE tell us! + Please send us a bug report. See the file: + + BUGS + + or the URL: + + http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html + + for how to send us such a bug report. + + Added the building of have_ban_pragma.h, which will determine + if "#pragma GCC poison func_name" is supported. If it is not, + or of HAVE_PRAGMA_GCC_POSION=-DHAVE_NO_PRAGMA_GCC_POSION, then + banned.h will have no effect. + + Fixed building of the have_getpgid.h file. + Fixed building of the have_getprid.h file. + Fixed building of the have_getsid.h file. + Fixed building of the have_gettime.h file. + Fixed building of the have_strdup.h file. + Fixed building of the have_ustat.h file. + Fixed building of the have_rusage.h file. + + Added HAVE_NO_STRLCPY to control if we want to test if + the system has a strlcpy() function. This in turn produces + the have_strlcpy.h file wherein the symbol HAVE_STRLCPY will + be defined, or not depending if the system comes with a + strlcpy() function. + + If the system does not have a strlcpy() function, we + compile our own strlcpy() function. See strl.c for details. + + Added HAVE_NO_STRLCAT to control if we want to test if + the system has a strlcat() function. This in turn produces + the have_strlcat.h file wherein the symbol HAVE_STRLCAT will + be defined, or not depending if the system comes with a + strlcat() function. + + If the system does not have a strlcat() function, we + compile our own strlcat() function. See strl.c for details. + + Fixed places were , using #ifdef HAVE_STRING_H + for legacy systems that do not have that include file. + + Added ${H} Makefile symbol to control the announcement + of forming and having formed hsrc related files. By default + H=@ (announce hsrc file formation) vs. H=@: to silence hsrc + related file formation. + + Explicitly turn off quiet mode (set Makefile variable ${Q} to + be empty) when building rpms. + + Improved and fixed the hsrc build process. + + Forming rpms is performed in verbose mode to assist debugging + to the rpm build process. + + Compile custom code, if needed, after main code is compiled. + + +The following are the changes from calc version 2.12.8.1 to 2.12.8.2: + + Fixed how the *.tar.bz2 are formed. The calc-2.12.8.0.tar.bz2 file + that was formed for calc version 2.12.8.0 was missing most files. + + Expanded 'make chk' to also verify that 'make distchk' and 'make + distlist' execute successfully. This will help check a regression + of the bug that produced the bogus calc-2.12.8.0.tar.bz2 file. + + Added additional regression tests related 0^(zero_expression)==1. + + Calc can now correctly compile without CUSTOM being defined, + thanks to a report by . + + The following are the changes from calc version 2.12.7.5 to 2.12.8.0: diff --git a/Makefile b/Makefile index de0ae9a..ae45011 100644 --- a/Makefile +++ b/Makefile @@ -54,9 +54,63 @@ # Makefile by Landon Curt Noll -# our shell +# The shell used by this Makefile # -SHELL= /bin/zsh +# On some systems, /bin/sh is a rather reduced shell with +# deprecated behavor. +# +# If your system has a up to date, bash shell, then +# you may wish to use: +# +# SHELL= /bin/bash +# +# On some systems such as macOS, the bash shell is very +# far behind to the point wehre is cannot be depended on. +# On such systems, the zsh may be a much better alternative +# shell for this Makefile to use: +# +# SHELL= /bin/zsh +# +#SHELL= /bin/sh +SHELL= /bin/bash +#SHELL= /bin/zsh + + +# CCBAN is given to ${CC} in order to control if banned.h is in effect. +# +# The banned.h attempts to ban the use of certain dangerous functions +# that, if improperly used, could compromise the computational integrity +# if calculations. +# +# In the case of calc, we are motivated in part by the desire for calc +# to correctly calculate: even durings extremely long calculations. +# +# If UNBAN is NOT defined, then calling certain functions +# will result in a call to a non-existent function (link error). +# +# While we do NOT encourage defining UNBAN, there may be +# a system / compiler environment where re-defining a +# function may lead to a fatal compiler complication. +# If that happens, consider compiling as: +# +# make clobber all chk CCBAN=-DUNBAN +# +# as see if this is a work-a-round. +# +# If YOU discover a need for the -DUNBAN work-a-round, PLEASE tell us! +# Please send us a bug report. See the file: +# +# BUGS +# +# or the URL: +# +# http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html +# +# for how to send us such a bug report. +# +CCBAN= -UUNBAN +#CCBAN= -DUNBAN + # Try uname -s if the target was not already set on the make command line # @@ -164,11 +218,30 @@ CI= ci # Q=@ do not echo internal Makefile actions (quiet mode) # Q= echo internal Makefile actions (debug / verbose mode) # +# H=@: do not report hsrc file formation progress +# H=@ do echo hsrc file formation progress +# +# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation +# S= full ${CC} output during hsrc file formation +# +# E= 2>/dev/null slience command stderr during hsrc file formation +# E= full command stderr during hsrc file formation +# # V=@: do not echo debug statements (quiet mode) # V=@ do echo debug statements (debug / verbose mode) # #Q= Q=@ +# +S= >/dev/null 2>&1 +#S= +# +E= 2>/dev/null +#E= +# +#H=@: +H=@ +# V=@: #V=@ @@ -184,20 +257,24 @@ XARG= # that invokes the ${MAKE_FILE}. # XVAR= \ - target=${target} \ - USE_READLINE='${USE_READLINE}' \ - READLINE_LIB='${READLINE_LIB}' \ - READLINE_INCLUDE='${READLINE_INCLUDE}' \ - RPM_TOP='${RPM_TOP}' \ - MAKE_FILE='${MAKE_FILE}' \ - EXT='${EXT}' \ - DARWIN_ARCH='${DARWIN_ARCH}' \ + CCBAN='${CCBAN}' \ CCWERR='${CCWERR}' \ - NROFF='${NROFF}' \ COMMON_ADD='${COMMON_ADD}' \ + DARWIN_ARCH='${DARWIN_ARCH}' \ + E='${E}' \ + EXT='${EXT}' \ + H='${H}' \ + MAKE_FILE='${MAKE_FILE}' \ MANDIR='${MANDIR}' \ + NROFF='${NROFF}' \ Q='${Q}' \ - V='${V}' + READLINE_INCLUDE='${READLINE_INCLUDE}' \ + READLINE_LIB='${READLINE_LIB}' \ + RPM_TOP='${RPM_TOP}' \ + S='${S}' \ + USE_READLINE='${USE_READLINE}' \ + V='${V}' \ + target=${target} # We update the calc version string in these makefiles # @@ -213,7 +290,7 @@ XMKVER= ${MAKE_FILE} custom/Makefile.head # ### -all: fix_version check_include +all: fix_version ${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-=' ${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR} ${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-=' @@ -508,6 +585,20 @@ have_unused.h: ${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR} ${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-=' +have_ban_pragma.h: + ${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-=' + ${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR} + ${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-=' + +have_strlcpy.h: + ${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-=' + ${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR} + ${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-=' + +have_strlcat.h: + ${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-=' + ${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR} + ${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-=' ## # @@ -523,34 +614,6 @@ win32_hsrc: ${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR} ${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-=' - -## -# -# These rules are used in the process of building the BUILD_H_SRC. -# -## - -endian.o: - ${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-=' - ${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR} - ${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-=' - -endian${EXT}: - ${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-=' - ${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR} - ${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-=' - -longbits.o: - ${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-=' - ${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR} - ${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-=' - -longbits${EXT}: - ${V} echo '=-=-=-=-= private Makefile $@ rule start =-=-=-=-=' - ${Q} ${MAKE} ${XARG} -f ${MAKE_FILE} $@ ${XVAR} - ${V} echo '=-=-=-=-= private Makefile $@ rule end =-=-=-=-=' - - ## # # These two .all rules are used to determine of the lower level diff --git a/Makefile.ship b/Makefile.ship index ac38005..7a40b85 100644 --- a/Makefile.ship +++ b/Makefile.ship @@ -1,4 +1,3 @@ -#!/bin/make # # calc - arbitrary precision calculator # @@ -49,9 +48,63 @@ # Makefile by Landon Curt Noll -# our shell +# The shell used by this Makefile +# +# On some systems, /bin/sh is a rather reduced shell with +# deprecated behavor. +# +# If your system has a up to date, bash shell, then +# you may wish to use: +# +# SHELL= /bin/bash +# +# On some systems such as macOS, the bash shell is very +# far behind to the point wehre is cannot be depended on. +# On such systems, the zsh may be a much better alternative +# shell for this Makefile to use: +# +# SHELL= /bin/zsh # SHELL= /bin/sh +#SHELL= /bin/bash +#SHELL= /bin/zsh + + +# CCBAN is given to ${CC} in order to control if banned.h is in effect. +# +# The banned.h attempts to ban the use of certain dangerous functions +# that, if improperly used, could compromise the computational integrity +# if calculations. +# +# In the case of calc, we are motivated in part by the desire for calc +# to correctly calculate: even durings extremely long calculations. +# +# If UNBAN is NOT defined, then calling certain functions +# will result in a call to a non-existent function (link error). +# +# While we do NOT encourage defining UNBAN, there may be +# a system / compiler environment where re-defining a +# function may lead to a fatal compiler complication. +# If that happens, consider compiling as: +# +# make clobber all chk CCBAN=-DUNBAN +# +# as see if this is a work-a-round. +# +# If YOU discover a need for the -DUNBAN work-a-round, PLEASE tell us! +# Please send us a bug report. See the file: +# +# BUGS +# +# or the URL: +# +# http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html +# +# for how to send us such a bug report. +# +CCBAN= -UUNBAN +#CCBAN= -DUNBAN + #if 0 /* start of skip for non-Gnu makefiles */ ############################################################################## @@ -559,6 +612,44 @@ HAVE_UNISTD_H= HAVE_UNUSED= #HAVE_UNUSED= -DHAVE_NO_UNUSED +# Determine if we allow use of "#pragma GCC poison func_name" +# +# If HAVE_PRAGMA_GCC_POSION is empty, then Makefile will run the +# have_bprag program to determine if the "#pragma GCC poison func_name" +# is supported. If HAVE_PRAGMA_GCC_POSION is set to +# -DHAVE_NO_PRAGMA_GCC_POSION. then the "#pragma GCC poison func_name" +# is not used. +# +# If in doubt, leave HAVE_PRAGMA_GCC_POSION empty and this Makefile +# will figure it out. +# +HAVE_PRAGMA_GCC_POSION= +#HAVE_PRAGMA_GCC_POSION= -DHAVE_NO_PRAGMA_GCC_POSION + +# Determine if we have strlcpy() +# +# If HAVE_STRLCPY is empty, this Makefile will run the have_strlcpy program +# to determine if strlcpy() is supported. If HAVE_STRLCPY is set to +# -DHAVE_NO_STRLCPY, then calc will use internal functions to simulate +# the strlcpy() function. +# +# If in doubt, leave HAVE_STRLCPY empty and this Makefile will figure it out. +# +HAVE_STRLCPY= +#HAVE_STRLCPY= -DHAVE_NO_STRLCPY + +# Determine if we have strlcat() +# +# If HAVE_STRLCAT is empty, this Makefile will run the have_strlcat program +# to determine if strlcat() is supported. If HAVE_STRLCAT is set to +# -DHAVE_NO_STRLCAT, then calc will use internal functions to simulate +# the strlcat() function. +# +# If in doubt, leave HAVE_STRLCAT empty and this Makefile will figure it out. +# +HAVE_STRLCAT= +#HAVE_STRLCAT= -DHAVE_NO_STRLCAT + # System include files # # ${INCDIR} where the system include (.h) files are kept @@ -1058,7 +1149,7 @@ EXT= # The default calc versions # -VERSION= 2.12.8.2 +VERSION= 2.12.9.0 # Names of shared libraries with versions # @@ -1187,12 +1278,20 @@ COMMON_LDFLAGS= ${EXTRA_LDFLAGS} # CCOPT are flags given to ${CC} for optimization # CCWARN are flags given to ${CC} for warning message control # -# WNO_IMPLICT, WNO_ERROR_LONG_LONG and WNO_LONG_LONG are given to ${CC} -# when compiling special .o files that may need special compile options +# The following are given to ${CC}: +# +# WNO_IMPLICT +# WNO_ERROR_LONG_LONG +# WNO_LONG_LONG +# +# when compiling special .o files that may need special compile options: +# # NOTE: These flags simply turn off certain compiler warnings, # which is useful only when CCWERR is set to -Werror. +# # NOTE: If your compiler does not have these -Wno files, just # set these variables to nothing as in: +# # WNO_IMPLICT= # WNO_ERROR_LONG_LONG= # WNO_LONG_LONG= @@ -1203,6 +1302,9 @@ COMMON_LDFLAGS= ${EXTRA_LDFLAGS} # to abort on warnings, then leave CCWERR blank. # CCMISC are misc flags given to ${CC} # +# CCBAN is given to ${CC} in order to control if banned.h is in effect. +# NOTE: See where CCBAN is defined above for details. +# # LCC is how the C compiler is invoked on locally executed intermediate programs # CC is how the C compiler is invoked (with an optional Purify) # @@ -1625,7 +1727,7 @@ CC= ${PURIFY} ${LCC} ${CCWERR} # ILDFLAGS for ${CC} in linking intermediate programs used to help compile calc # LDFLAGS for ${CC} in linking calc programs other than intermediate programs # -ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC} +ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC} CFLAGS= ${ICFLAGS} ${CCOPT} # ILDFLAGS= ${COMMON_LDFLAGS} ${LD_STATIC} @@ -1752,9 +1854,9 @@ endif # NOTE: This does not work for: make-XYZ-only and BLD_TYPE != make-XYZ-only # ifeq ($(BLD_TYPE),calc-static-only) -ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC} +ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC} else -ICFLAGS= ${COMMON_CFLAGS} ${CC_SHARE} +ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_SHARE} endif CFLAGS= ${ICFLAGS} ${CCOPT} @@ -1781,11 +1883,30 @@ LDFLAGS= ${LD_DEBUG} ${ILDFLAGS} # Q=@ do not echo internal Makefile actions (quiet mode) # Q= echo internal Makefile actions (debug / verbose mode) # +# H=@: do not report hsrc file formation progress +# H=@ do echo hsrc file formation progress +# +# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation +# S= full ${CC} output during hsrc file formation +# +# E= 2>/dev/null slience command stderr during hsrc file formation +# E= full command stderr during hsrc file formation +# # V=@: do not echo debug statements (quiet mode) # V=@ do echo debug statements (debug / verbose mode) # #Q= Q=@ +# +S= >/dev/null 2>&1 +#S= +# +E= 2>/dev/null +#E= +# +#H=@: +H=@ +# V=@: #V=@ @@ -1799,7 +1920,7 @@ LIBSRC= addop.c assocfunc.c blkcpy.c block.c byteswap.c \ lib_calc.c lib_util.c listfunc.c matfunc.c math_error.c \ obj.c opcodes.c pix.c poly.c prime.c qfunc.c qio.c \ qmath.c qmod.c qtrans.c quickhash.c seed.c sha1.c size.c \ - str.c symbol.c token.c value.c version.c zfunc.c zio.c \ + str.c strl.c symbol.c token.c value.c version.c zfunc.c zio.c \ zmath.c zmod.c zmul.c zprime.c zrand.c zrandom.c # the object files which are built into a math link library @@ -1813,7 +1934,7 @@ LIBOBJS= addop.o assocfunc.o blkcpy.o block.o byteswap.o calcerr.o \ lib_calc.o lib_util.o listfunc.o matfunc.o math_error.o \ obj.o opcodes.o pix.o poly.o prime.o qfunc.o qio.o \ qmath.o qmod.o qtrans.o quickhash.o seed.o sha1.o size.o \ - str.o symbol.o token.o value.o version.o zfunc.o zio.o \ + str.o strl.o symbol.o token.o value.o version.o zfunc.o zio.o \ zmath.o zmod.o zmul.o zprime.o zrand.o zrandom.o # the calculator source files @@ -1830,22 +1951,22 @@ CALCOBJS= calc.o # these .h files are needed to build the math link library # -LIB_H_SRC= alloc.h blkcpy.h block.h byteswap.h calc.h cmath.h \ +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 \ + opcodes.h prime.h qmath.h sha1.h str.h strl.h \ symbol.h token.h value.h zmath.h zrand.h zrandom.h # we build these .h files during the make # -BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.h \ - fposval.h have_const.h have_fpos.h have_fpos_pos.h \ - have_memmv.h have_newstr.h have_offscl.h have_posscl.h \ - have_stdlib.h have_string.h have_times.h have_uid_t.h \ - have_unistd.h longbits.h terminal.h \ - have_ustat.h have_getsid.h have_getpgid.h \ - have_gettime.h have_getprid.h have_urandom.h have_rusage.h \ - have_strdup.h have_unused.h +BUILD_H_SRC= align32.h args.h calcerr.c calcerr.h conf.h endian_calc.h \ + fposval.h have_ban_pragma.h have_const.h have_fpos.h \ + have_fpos_pos.h have_getpgid.h have_getprid.h have_getsid.h \ + have_gettime.h have_memmv.h have_newstr.h have_offscl.h \ + have_posscl.h have_rusage.h have_stdlib.h have_strdup.h \ + have_string.h have_strlcat.h have_strlcpy.h have_times.h \ + have_uid_t.h have_unistd.h have_unused.h have_urandom.h \ + have_ustat.h longbits.h terminal.h # we build these .c files during the make # @@ -1860,13 +1981,13 @@ UTIL_C_SRC= align32.c endian.c longbits.c have_newstr.c have_uid_t.c \ have_fpos_pos.c have_offscl.c have_posscl.c have_memmv.c \ have_ustat.c have_getsid.c have_getpgid.c \ have_gettime.c have_getprid.c have_rusage.c have_strdup.c \ - have_unused.c + have_unused.c have_ban_pragma.c have_strlcpy.c have_strlcat.c # these awk and sed tools are used in the process of building BUILD_H_SRC # and BUILD_C_SRC # UTIL_MISC_SRC= calcerr_h.sed calcerr_h.awk calcerr_c.sed calcerr_c.awk \ - calcerr.tbl check.awk win32.mkdef + calcerr.tbl check.awk win32.mkdef fposval.h.def # these .o files may get built in the process of building BUILD_H_SRC # @@ -1877,11 +1998,11 @@ UTIL_OBJS= endian.o longbits.o have_newstr.o have_uid_t.o \ try_strarg.o have_stdvs.o have_varvs.o have_posscl.o have_memmv.o \ have_ustat.o have_getsid.o have_getpgid.o \ have_gettime.o have_getprid.o ver_calc.o have_rusage.o have_strdup.o \ - have_unused.o + have_unused.o have_ban_pragma.o have_strlcpy.o have_strlcat.o # these temp files may be created (and removed) during the build of BUILD_C_SRC # -UTIL_TMP= ll_tmp fpos_tmp fposv_tmp const_tmp uid_tmp newstr_tmp vs_tmp \ +UTIL_TMP= ll_tmp fpos_tmp fposval_tmp const_tmp uid_tmp newstr_tmp vs_tmp \ memmv_tmp offscl_tmp posscl_tmp newstr_tmp \ getsid_tmp gettime_tmp getprid_tmp rusage_tmp strdup_tmp @@ -1894,7 +2015,8 @@ UTIL_PROGS= align32${EXT} fposval${EXT} have_uid_t${EXT} have_const${EXT} \ have_getpgid${EXT} have_gettime${EXT} have_getprid${EXT} \ ver_calc${EXT} have_strdup${EXT} \ have_unused${EXT} have_fpos${EXT} have_fpos_pos${EXT} \ - have_offscl${EXT} have_rusage${EXT} + have_offscl${EXT} have_rusage${EXT} have_ban_pragma${EXT} \ + have_strlcpy${EXT} have_strlcat${EXT} # these utility files and scripts may be created in the process of building # the BUILD_H_SRC file set @@ -1930,6 +2052,7 @@ CUSTOM_PASSDOWN= \ CALC_SHAREDIR="${CALC_SHAREDIR}" \ CAT=${CAT} \ CC="${CC}" \ + CCBAN="${CCBAN}" \ CCERR="${CCERR}" \ CCMISC="${CCMISC}" \ CCOPT="${CCOPT}" \ @@ -1948,8 +2071,10 @@ CUSTOM_PASSDOWN= \ CUSTOMINCDIR="${CUSTOMINCDIR}" \ DEBUG="${DEBUG}" \ DEFAULT_LIB_INSTALL_PATH="${DEFAULT_LIB_INSTALL_PATH}" \ + E="${E}" \ FMT=${FMT} \ GREP=${GREP} \ + H="${H}" \ HELPDIR="${HELPDIR}" \ ICFLAGS="${ICFLAGS} -I.." \ ILDFLAGS="${ILDFLAGS}" \ @@ -1972,14 +2097,19 @@ CUSTOM_PASSDOWN= \ RANLIB="${RANLIB}" \ RM=${RM} \ RMDIR=${RMDIR} \ + S="${S}" \ SCRIPTDIR="${SCRIPTDIR}" \ SED=${SED} \ + SHELL=${SHELL} \ SORT=${SORT} \ T=${T} \ TOP_MAKE_FILE=${MAKE_FILE} \ TOUCH=${TOUCH} \ TRUE=${TRUE} \ VERSION=${VERSION} \ + WNO_IMPLICT=${WNO_IMPLICT} \ + WNO_ERROR_LONG_LONG=${WNO_ERROR_LONG_LONG} \ + WNO_LONG_LONG=${WNO_LONG_LONG} \ target=${target} # The complete list of Makefile vars passed down to help/Makefile. @@ -2001,6 +2131,7 @@ HELP_PASSDOWN= \ EXT=${EXT} \ FMT=${FMT} \ GREP=${GREP} \ + H="${H}" \ HELPDIR="${HELPDIR}" \ ICFLAGS="${ICFLAGS}" \ ILDFLAGS="${ILDFLAGS}" \ @@ -2016,6 +2147,7 @@ HELP_PASSDOWN= \ RMDIR=${RMDIR} \ SCRIPTDIR="${SCRIPTDIR}" \ SED=${SED} \ + SHELL=${SHELL} \ T=${T} \ TOP_MAKE_FILE=${MAKE_FILE} \ TOUCH=${TOUCH} \ @@ -2033,6 +2165,7 @@ CAL_PASSDOWN= \ CMP=${CMP} \ CO=${CO} \ CP=${CP} \ + H="${H}" \ HELPDIR="${HELPDIR}" \ INCDIR="${INCDIR}" \ LANG=${LANG} \ @@ -2044,6 +2177,7 @@ CAL_PASSDOWN= \ RM=${RM} \ RMDIR=${RMDIR} \ SCRIPTDIR="${SCRIPTDIR}" \ + SHELL=${SHELL} \ T=${T} \ TOP_MAKE_FILE=${MAKE_FILE} \ TOUCH=${TOUCH} \ @@ -2063,6 +2197,7 @@ CSCRIPT_PASSDOWN= \ CP=${CP} \ ECHON="${ECHON}" \ FMT=${FMT} \ + H="${H}" \ HELPDIR="${HELPDIR}" \ INCDIR="${INCDIR}" \ LANG=${LANG} \ @@ -2075,6 +2210,7 @@ CSCRIPT_PASSDOWN= \ RMDIR=${RMDIR} \ SCRIPTDIR="${SCRIPTDIR}" \ SED=${SED} \ + SHELL=${SHELL} \ SORT=${SORT} \ T=${T} \ TOP_MAKE_FILE=${MAKE_FILE} \ @@ -2177,7 +2313,7 @@ STATIC_FIRST_TARGETS= ${LICENSE} .static #if 0 /* start of skip for non-Gnu makefiles */ ifdef ALLOW_CUSTOM #endif /* end of skip for non-Gnu makefiles */ -EARLY_TARGETS= custom/Makefile hsrc .hsrc custom/.all +EARLY_TARGETS= hsrc .hsrc custom/.all custom/Makefile #if 0 /* start of skip for non-Gnu makefiles */ else EARLY_TARGETS= hsrc .hsrc @@ -2203,7 +2339,7 @@ TARGETS= ${EARLY_TARGETS} ${BLD_TYPE} ${LATE_TARGETS} all: check_include ${BLD_TYPE} CHANGES check_include: - $(Q) if ! echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ + ${Q} if ! echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo "ERROR: Missing critical include file." 1>&2; \ echo "Without critical include files, we cannot compile." 1>&2; \ echo "Perhaps your system isn't setup to compile C source?" 1>&2; \ @@ -2407,67 +2543,67 @@ hsrc: ${BUILD_H_SRC} ${BUILD_C_SRC} -${Q} ${TOUCH} .hsrc conf.h: ${MAKE_FILE} - ${Q} ${RM} -f conf.h - ${Q} echo 'forming conf.h' - ${Q} echo '/*' > conf.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> conf.h - ${Q} echo ' */' >> conf.h - ${Q} echo '' >> conf.h - ${Q} echo '' >> conf.h - ${Q} echo '#if !defined(__CONF_H__)' >> conf.h - ${Q} echo '#define __CONF_H__' >> conf.h - ${Q} echo '' >> conf.h - ${Q} echo '' >> conf.h - ${Q} echo '/* the default :-separated search path */' >> conf.h - ${Q} echo '#if !defined(DEFAULTCALCPATH)' >> conf.h - ${Q} echo '#define DEFAULTCALCPATH "${CALCPATH}"' >> conf.h - ${Q} echo '#endif /* DEFAULTCALCPATH */' >> conf.h - ${Q} echo '' >> conf.h - ${Q} echo '/* the default :-separated startup file list */' >> conf.h - ${Q} echo '#if !defined(DEFAULTCALCRC)' >> conf.h - ${Q} echo '#define DEFAULTCALCRC "${CALCRC}"' >> conf.h - ${Q} echo '#endif /* DEFAULTCALCRC */' >> conf.h - ${Q} echo '' >> conf.h - ${Q} echo '/* the location of the help directory */' >> conf.h - ${Q} echo '#if !defined(HELPDIR)' >> conf.h + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_CONF_H)' >> $@ + ${Q} echo '#define CALC_CONF_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* the default :-separated search path */' >> $@ + ${Q} echo '#if !defined(DEFAULTCALCPATH)' >> $@ + ${Q} echo '#define DEFAULTCALCPATH "${CALCPATH}"' >> $@ + ${Q} echo '#endif /* DEFAULTCALCPATH */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* the default :-separated startup file list */' >> $@ + ${Q} echo '#if !defined(DEFAULTCALCRC)' >> $@ + ${Q} echo '#define DEFAULTCALCRC "${CALCRC}"' >> $@ + ${Q} echo '#endif /* DEFAULTCALCRC */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* the location of the help directory */' >> $@ + ${Q} echo '#if !defined(HELPDIR)' >> $@ #if 0 /* start of skip for non-Gnu makefiles */ ifdef RPM_TOP - ${Q} echo '#define HELPDIR "${HELPDIR}"' >> conf.h + ${Q} echo '#define HELPDIR "${HELPDIR}"' >> $@ else #endif /* end of skip for non-Gnu makefiles */ - ${Q} echo '#define HELPDIR "${T}${HELPDIR}"' >> conf.h + ${Q} echo '#define HELPDIR "${T}${HELPDIR}"' >> $@ #if 0 /* start of skip for non-Gnu makefiles */ endif #endif /* end of skip for non-Gnu makefiles */ - ${Q} echo '#endif /* HELPDIR */' >> conf.h - ${Q} echo '' >> conf.h + ${Q} echo '#endif /* HELPDIR */' >> $@ + ${Q} echo '' >> $@ #if 0 /* start of skip for non-Gnu makefiles */ ifdef ALLOW_CUSTOM #endif /* end of skip for non-Gnu makefiles */ - ${Q} echo '/* the location of the custom help directory */' >> conf.h - ${Q} echo '#if !defined(CUSTOMHELPDIR)' >> conf.h + ${Q} echo '/* the location of the custom help directory */' >> $@ + ${Q} echo '#if !defined(CUSTOMHELPDIR)' >> $@ #if 0 /* start of skip for non-Gnu makefiles */ ifdef RPM_TOP - ${Q} echo '#define CUSTOMHELPDIR "${CUSTOMHELPDIR}"' >> conf.h + ${Q} echo '#define CUSTOMHELPDIR "${CUSTOMHELPDIR}"' >> $@ else #endif /* end of skip for non-Gnu makefiles */ - ${Q} echo '#define CUSTOMHELPDIR "${T}${CUSTOMHELPDIR}"' >> conf.h + ${Q} echo '#define CUSTOMHELPDIR "${T}${CUSTOMHELPDIR}"' >> $@ #if 0 /* start of skip for non-Gnu makefiles */ endif #endif /* end of skip for non-Gnu makefiles */ - ${Q} echo '#endif /* CUSTOMHELPDIR */' >> conf.h - ${Q} echo '' >> conf.h + ${Q} echo '#endif /* CUSTOMHELPDIR */' >> $@ + ${Q} echo '' >> $@ #if 0 /* start of skip for non-Gnu makefiles */ endif #endif /* end of skip for non-Gnu makefiles */ - ${Q} echo '/* the default pager to use */' >> conf.h - ${Q} echo '#if !defined(DEFAULTCALCPAGER)' >> conf.h - ${Q} echo '#define DEFAULTCALCPAGER "${CALCPAGER}"' >> conf.h - ${Q} echo '#endif /* DEFAULTCALCPAGER */' >> conf.h - ${Q} echo '' >> conf.h - ${Q} echo '' >> conf.h - ${Q} echo '#endif /* !__CONF_H__ */' >> conf.h - ${Q} echo 'conf.h formed' + ${Q} echo '/* the default pager to use */' >> $@ + ${Q} echo '#if !defined(DEFAULTCALCPAGER)' >> $@ + ${Q} echo '#define DEFAULTCALCPAGER "${CALCPAGER}"' >> $@ + ${Q} echo '#endif /* DEFAULTCALCPAGER */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_CONF_H */' >> $@ + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2478,41 +2614,48 @@ endif ${TRUE}; \ fi -endian_calc.h: endian${EXT} ${MAKE_FILE} - ${Q} ${RM} -f endian_calc.h - ${Q} echo 'forming endian_calc.h' - ${Q} echo '/*' > endian_calc.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> endian_calc.h - ${Q} echo ' */' >> endian_calc.h - ${Q} echo '' >> endian_calc.h - ${Q} echo '' >> endian_calc.h - ${Q} echo '#if !defined(__ENDIAN_CALC_H__)' >> endian_calc.h - ${Q} echo '#define __ENDIAN_CALC_H__' >> endian_calc.h - ${Q} echo '' >> endian_calc.h - ${Q} echo '' >> endian_calc.h - ${Q} echo '/* what byte order are we? */' >> endian_calc.h +endian_calc.h: endian.c have_stdlib.h have_unistd.h \ + banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f endian.o endian${EXT} $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(ENDIAN_CALC_H)' >> $@ + ${Q} echo '#define ENDIAN_CALC_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* what byte order are we? */' >> $@ -${Q} if [ X"${CALC_BYTE_ORDER}" = X ]; then \ - if echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ - echo '#include ' >> endian_calc.h; \ - echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \ + if echo '#include ' | ${CC} -E - ${S}; then \ + echo '#include ' >> $@; \ + echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> $@; \ elif echo '#include ' | \ - ${CC} -E - >/dev/null 2>&1; then \ - echo '#include ' >> endian_calc.h; \ - echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \ + ${CC} -E - ${S}; then \ + echo '#include ' >> $@; \ + echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> $@; \ elif echo '#include ' | \ - ${CC} -E- >/dev/null 2>&1; then \ - echo '#include ' >> endian_calc.h; \ - echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \ + ${CC} -E- ${S}; then \ + echo '#include ' >> $@; \ + echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> $@; \ else \ - ./endian${EXT} >> endian_calc.h; \ + ${LCC} ${ICFLAGS} ${CALC_BYTE_ORDER} endian.c -c ${S}; \ + ${LCC} ${ILDFLAGS} endian.o -o endian${EXT} ${S}; \ + ./endian${EXT} >> $@; \ + ${RM} -f endian.o endian${EXT}; \ fi; \ else \ - ./endian${EXT} >> endian_calc.h; \ + ${LCC} ${ICFLAGS} ${CALC_BYTE_ORDER} endian.c -c ${S}; \ + ${LCC} ${ILDFLAGS} endian.o -o endian${EXT} ${S}; \ + ./endian${EXT} >> $@; \ + ${RM} -f endian.o endian${EXT}; \ fi - ${Q} echo '' >> endian_calc.h - ${Q} echo '' >> endian_calc.h - ${Q} echo '#endif /* !__ENDIAN_CALC_H__ */' >> endian_calc.h - ${Q} echo 'endian_calc.h formed' + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !ENDIAN_CALC_H */' >> $@ + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2523,23 +2666,27 @@ endian_calc.h: endian${EXT} ${MAKE_FILE} ${TRUE}; \ fi -longbits.h: longbits${EXT} ${MAKE_FILE} - ${Q} ${RM} -f longbits.h - ${Q} echo 'forming longbits.h' - ${Q} echo '/*' > longbits.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> longbits.h - ${Q} echo ' */' >> longbits.h - ${Q} echo '' >> longbits.h - ${Q} echo '' >> longbits.h - ${Q} echo '#if !defined(__LONGBITS_H__)' >> longbits.h - ${Q} echo '#define __LONGBITS_H__' >> longbits.h - ${Q} echo '' >> longbits.h - ${Q} echo '' >> longbits.h - ${Q} ./longbits${EXT} ${LONG_BITS} >> longbits.h - ${Q} echo '' >> longbits.h - ${Q} echo '' >> longbits.h - ${Q} echo '#endif /* !__LONGBITS_H__ */' >> longbits.h - ${Q} echo 'longbits.h formed' +longbits.h: longbits.c have_unistd.h have_stdlib.h \ + banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f longbits.o longbits${EXT} $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_LONGBITS_H)' >> $@ + ${Q} echo '#define CALC_LONGBITS_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} ${LCC} ${ICFLAGS} longbits.c -c ${S} + ${Q} ${LCC} ${ILDFLAGS} longbits.o -o longbits${EXT} ${S} + ${Q} ./longbits${EXT} ${LONG_BITS} >> $@ ${E} + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_LONGBITS_H */' >> $@ + ${H} echo '$@ formed' + ${Q} ${RM} -f longbits.o longbits${EXT} -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2551,58 +2698,61 @@ longbits.h: longbits${EXT} ${MAKE_FILE} fi have_times.h: ${MAKE_FILE} - ${Q} ${RM} -f have_times.h - ${Q} echo 'forming have_times.h' - ${Q} echo '/*' > have_times.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_times.h - ${Q} echo ' */' >> have_times.h - ${Q} echo '' >> have_times.h - ${Q} echo '' >> have_times.h - ${Q} echo '#if !defined(CALC_HAVE_TIMES_H)' >> have_times.h - ${Q} echo '#define CALC_HAVE_TIMES_H' >> have_times.h - ${Q} echo '' >> have_times.h - ${Q} echo '' >> have_times.h - ${Q} echo '/* do we have ? */' >> have_times.h + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_TIMES_H)' >> $@ + ${Q} echo '#define CALC_HAVE_TIMES_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have ? */' >> $@ -${Q} if [ X"${HAVE_TIMES_H}" = X"YES" ]; then \ - echo '#define HAVE_TIMES_H /* yes */' >> have_times.h; \ + echo '#define HAVE_TIMES_H /* yes */' >> $@; \ elif [ X"${HAVE_TIMES_H}" = X"NO" ]; then \ - echo '#undef HAVE_TIMES_H /* no */' >> have_times.h; \ - elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ - echo '#define HAVE_TIMES_H /* yes */' >> have_times.h; \ + echo '#undef HAVE_TIMES_H /* no */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_TIMES_H /* yes */' >> $@; \ else \ - echo '#undef HAVE_TIMES_H /* no */' >> have_times.h; \ + echo '#undef HAVE_TIMES_H /* no */' >> $@; \ fi + ${Q} echo '/* do we have ? */' >> $@ -${Q} if [ X"${HAVE_SYS_TIMES_H}" = X"YES" ]; then \ - echo '#define HAVE_SYS_TIMES_H /* yes */' >> have_times.h; \ + echo '#define HAVE_SYS_TIMES_H /* yes */' >> $@; \ elif [ X"${HAVE_SYS_TIMES_H}" = X"NO" ]; then \ - echo '#undef HAVE_SYS_TIMES_H /* no */' >> have_times.h; \ - elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ - echo '#define HAVE_SYS_TIMES_H /* yes */' >> have_times.h; \ + echo '#undef HAVE_SYS_TIMES_H /* no */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_SYS_TIMES_H /* yes */' >> $@; \ else \ - echo '#undef HAVE_SYS_TIMES_H /* no */' >> have_times.h; \ + echo '#undef HAVE_SYS_TIMES_H /* no */' >> $@; \ fi + ${Q} echo '/* do we have ? */' >> $@ -${Q} if [ X"${HAVE_TIME_H}" = X"YES" ]; then \ - echo '#define HAVE_TIME_H /* yes */' >> have_times.h; \ + echo '#define HAVE_TIME_H /* yes */' >> $@; \ elif [ X"${HAVE_TIME_H}" = X"NO" ]; then \ - echo '#undef HAVE_TIME_H /* no */' >> have_times.h; \ - elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ - echo '#define HAVE_TIME_H /* yes */' >> have_times.h; \ + echo '#undef HAVE_TIME_H /* no */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_TIME_H /* yes */' >> $@; \ else \ - echo '#undef HAVE_TIME_H /* no */' >> have_times.h; \ + echo '#undef HAVE_TIME_H /* no */' >> $@; \ fi + ${Q} echo '/* do we have ? */' >> $@ -${Q} if [ X"${HAVE_SYS_TIME_H}" = X"YES" ]; then \ - echo '#define HAVE_SYS_TIME_H /* yes */' >> have_times.h; \ + echo '#define HAVE_SYS_TIME_H /* yes */' >> $@; \ elif [ X"${HAVE_SYS_TIME_H}" = X"NO" ]; then \ - echo '#undef HAVE_SYS_TIME_H /* no */' >> have_times.h; \ - elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ - echo '#define HAVE_SYS_TIME_H /* yes */' >> have_times.h; \ + echo '#undef HAVE_SYS_TIME_H /* no */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_SYS_TIME_H /* yes */' >> $@; \ else \ - echo '#undef HAVE_SYS_TIME_H /* no */' >> have_times.h; \ + echo '#undef HAVE_SYS_TIME_H /* no */' >> $@; \ fi - ${Q} echo '' >> have_times.h - ${Q} echo '' >> have_times.h - ${Q} echo '#endif /* !CALC_HAVE_TIMES_H */' >> have_times.h - ${Q} echo 'have_times.h formed' + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_TIMES_H */' >> $@ + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2614,31 +2764,31 @@ have_times.h: ${MAKE_FILE} fi have_stdlib.h: ${MAKE_FILE} - ${Q} ${RM} -f have_stdlib.h - ${Q} echo 'forming have_stdlib.h' - ${Q} echo '/*' > have_stdlib.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_stdlib.h - ${Q} echo ' */' >> have_stdlib.h - ${Q} echo '' >> have_stdlib.h - ${Q} echo '' >> have_stdlib.h + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ ${Q} echo '#if !defined(CALC_HAVE_STDLIB_H)' >> have_stdlib.h ${Q} echo '#define CALC_HAVE_STDLIB_H' >> have_stdlib.h - ${Q} echo '' >> have_stdlib.h - ${Q} echo '' >> have_stdlib.h - ${Q} echo '/* do we have ? */' >> have_stdlib.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have ? */' >> $@ -${Q} if [ X"${HAVE_STDLIB_H}" = X"YES" ]; then \ echo '#define HAVE_STDLIB_H /* yes */' >> have_stdlib.h; \ elif [ X"${HAVE_STDLIB_H}" = X"NO" ]; then \ echo '#undef HAVE_STDLIB_H /* no */' >> have_stdlib.h; \ - elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ + elif echo '#include ' | ${CC} -E - ${S}; then \ echo '#define HAVE_STDLIB_H /* yes */' >> have_stdlib.h; \ else \ echo '#undef HAVE_STDLIB_H /* no */' >> have_stdlib.h; \ fi - ${Q} echo '' >> have_stdlib.h - ${Q} echo '' >> have_stdlib.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ ${Q} echo '#endif /* !CALC_HAVE_STDLIB_H */' >> have_stdlib.h - ${Q} echo 'have_stdlib.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2650,31 +2800,31 @@ have_stdlib.h: ${MAKE_FILE} fi have_unistd.h: ${MAKE_FILE} - ${Q} ${RM} -f have_unistd.h - ${Q} echo 'forming have_unistd.h' - ${Q} echo '/*' > have_unistd.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_unistd.h - ${Q} echo ' */' >> have_unistd.h - ${Q} echo '' >> have_unistd.h - ${Q} echo '' >> have_unistd.h - ${Q} echo '#if !defined(CALC_HAVE_UNISTD_H)' >> have_unistd.h - ${Q} echo '#define CALC_HAVE_UNISTD_H' >> have_unistd.h - ${Q} echo '' >> have_unistd.h - ${Q} echo '' >> have_unistd.h - ${Q} echo '/* do we have ? */' >> have_unistd.h + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_UNISTD_H)' >> $@ + ${Q} echo '#define CALC_HAVE_UNISTD_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have ? */' >> $@ -${Q} if [ X"${HAVE_UNISTD_H}" = X"YES" ]; then \ - echo '#define HAVE_UNISTD_H /* yes */' >> have_unistd.h; \ + echo '#define $@ /* yes */' >> $@; \ elif [ X"${HAVE_UNISTD_H}" = X"NO" ]; then \ - echo '#undef HAVE_UNISTD_H /* no */' >> have_unistd.h; \ - elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ - echo '#define HAVE_UNISTD_H /* yes */' >> have_unistd.h; \ + echo '#undef HAVE_UNISTD_H /* no */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_UNISTD_H /* yes */' >> $@; \ else \ - echo '#undef HAVE_UNISTD_H /* no */' >> have_unistd.h; \ + echo '#undef HAVE_UNISTD_H /* no */' >> $@; \ fi - ${Q} echo '' >> have_unistd.h - ${Q} echo '' >> have_unistd.h - ${Q} echo '#endif /* !CALC_HAVE_UNISTD_H */' >> have_unistd.h - ${Q} echo 'have_unistd.h formed' + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_UNISTD_H */' >> $@ + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2686,31 +2836,31 @@ have_unistd.h: ${MAKE_FILE} fi have_string.h: ${MAKE_FILE} - ${Q} ${RM} -f have_string.h - ${Q} echo 'forming have_string.h' - ${Q} echo '/*' > have_string.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_string.h - ${Q} echo ' */' >> have_string.h - ${Q} echo '' >> have_string.h - ${Q} echo '' >> have_string.h - ${Q} echo '#if !defined(CALC_HAVE_STRING_H)' >> have_string.h - ${Q} echo '#define CALC_HAVE_STRING_H' >> have_string.h - ${Q} echo '' >> have_string.h - ${Q} echo '' >> have_string.h - ${Q} echo '/* do we have ? */' >> have_string.h + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_STRING_H)' >> $@ + ${Q} echo '#define CALC_HAVE_STRING_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have ? */' >> $@ -${Q} if [ X"${HAVE_STRING_H}" = X"YES" ]; then \ - echo '#define HAVE_STRING_H /* yes */' >> have_string.h; \ + echo '#define $@ /* yes */' >> $@; \ elif [ X"${HAVE_STRING_H}" = X"NO" ]; then \ - echo '#undef HAVE_STRING_H /* no */' >> have_string.h; \ - elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ - echo '#define HAVE_STRING_H /* yes */' >> have_string.h; \ + echo '#undef HAVE_STRING_H /* no */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_STRING_H /* yes */' >> $@; \ else \ - echo '#undef HAVE_STRING_H /* no */' >> have_string.h; \ + echo '#undef HAVE_STRING_H /* no */' >> $@; \ fi - ${Q} echo '' >> have_string.h - ${Q} echo '' >> have_string.h - ${Q} echo '#endif /* !CALC_HAVE_STRING_H */' >> have_string.h - ${Q} echo 'have_string.h formed' + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_STRING_H */' >> $@ + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2722,49 +2872,49 @@ have_string.h: ${MAKE_FILE} fi terminal.h: ${MAKE_FILE} - ${Q} ${RM} -f terminal.h - ${Q} echo 'forming terminal.h' - ${Q} echo '/*' > terminal.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> terminal.h - ${Q} echo ' */' >> terminal.h - ${Q} echo '' >> terminal.h - ${Q} echo '' >> terminal.h - ${Q} echo '#if !defined(__TERMINAL_H__)' >> terminal.h - ${Q} echo '#define __TERMINAL_H__' >> terminal.h - ${Q} echo '' >> terminal.h - ${Q} echo '' >> terminal.h - ${Q} echo '/* determine the type of terminal interface */' >> terminal.h - ${Q} echo '#if !defined(USE_TERMIOS)' >> terminal.h - ${Q} echo '#if !defined(USE_TERMIO)' >> terminal.h - ${Q} echo '#if !defined(USE_SGTTY)' >> terminal.h + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_TERMINAL_H)' >> $@ + ${Q} echo '#define CALC_TERMINAL_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* determine the type of terminal interface */' >> $@ + ${Q} echo '#if !defined(USE_TERMIOS)' >> $@ + ${Q} echo '#if !defined(USE_TERMIO)' >> $@ + ${Q} echo '#if !defined(USE_SGTTY)' >> $@ -${Q} if [ X"${TERMCONTROL}" = X"-DUSE_WIN32" ]; then \ - echo '/* windoz, use none of these modes */' >> terminal.h; \ - echo '#undef USE_TERMIOS /* */' >> terminal.h; \ - echo '#undef USE_TERMIO /* */' >> terminal.h; \ - echo '#undef USE_SGTTY /* */' >> terminal.h; \ - elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ - echo '/* use termios */' >> terminal.h; \ - echo '#define USE_TERMIOS /* */' >> terminal.h; \ - echo '#undef USE_TERMIO /* */' >> terminal.h; \ - echo '#undef USE_SGTTY /* */' >> terminal.h; \ - elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ - echo '/* use termio */' >> terminal.h; \ - echo '#undef USE_TERMIOS /* */' >> terminal.h; \ - echo '#define USE_TERMIO /* */' >> terminal.h; \ - echo '#undef USE_SGTTY /* */' >> terminal.h; \ + echo '/* windoz, use none of these modes */' >> $@; \ + echo '#undef USE_TERMIOS /* */' >> $@; \ + echo '#undef USE_TERMIO /* */' >> $@; \ + echo '#undef USE_SGTTY /* */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '/* use termios */' >> $@; \ + echo '#define USE_TERMIOS /* */' >> $@; \ + echo '#undef USE_TERMIO /* */' >> $@; \ + echo '#undef USE_SGTTY /* */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '/* use termio */' >> $@; \ + echo '#undef USE_TERMIOS /* */' >> $@; \ + echo '#define USE_TERMIO /* */' >> $@; \ + echo '#undef USE_SGTTY /* */' >> $@; \ else \ - echo '/* use sgtty */' >> terminal.h; \ - echo '#undef USE_TERMIOS /* */' >> terminal.h; \ - echo '#undef USE_TERMIO /* */' >> terminal.h; \ - echo '#define USE_SGTTY /* */' >> terminal.h; \ + echo '/* use sgtty */' >> $@; \ + echo '#undef USE_TERMIOS /* */' >> $@; \ + echo '#undef USE_TERMIO /* */' >> $@; \ + echo '#define USE_SGTTY /* */' >> $@; \ fi - ${Q} echo '#endif' >> terminal.h - ${Q} echo '#endif' >> terminal.h - ${Q} echo '#endif' >> terminal.h - ${Q} echo '' >> terminal.h - ${Q} echo '' >> terminal.h - ${Q} echo '#endif /* !__TERMINAL_H__ */' >> terminal.h - ${Q} echo 'terminal.h formed' + ${Q} echo '#endif' >> $@ + ${Q} echo '#endif' >> $@ + ${Q} echo '#endif' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_TERMINAL_H */' >> $@ + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2775,38 +2925,38 @@ terminal.h: ${MAKE_FILE} ${TRUE}; \ fi -have_fpos.h: have_fpos.c ${MAKE_FILE} - ${Q} ${RM} -f fpos_tmp have_fpos.h - ${Q} echo 'forming have_fpos.h' - ${Q} echo '/*' > have_fpos.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_fpos.h - ${Q} echo ' */' >> have_fpos.h - ${Q} echo '' >> have_fpos.h - ${Q} echo '' >> have_fpos.h - ${Q} echo '#if !defined(CALC_HAVE_FPOS_H)' >> have_fpos.h - ${Q} echo '#define CALC_HAVE_FPOS_H' >> have_fpos.h - ${Q} echo '' >> have_fpos.h - ${Q} echo '' >> have_fpos.h - ${Q} echo '/* do we have fgetpos & fsetpos functions? */' >> have_fpos.h +have_fpos.h: have_fpos.c banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f fpos_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_FPOS_H)' >> $@ + ${Q} echo '#define CALC_HAVE_FPOS_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have fgetpos & fsetpos functions? */' >> $@ ${Q} ${RM} -f have_fpos.o have_fpos${EXT} - -${Q} ${LCC} ${HAVE_FPOS} ${ICFLAGS} have_fpos.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_fpos.o -o have_fpos${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_fpos${EXT} > fpos_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${HAVE_FPOS} ${ICFLAGS} have_fpos.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_fpos.o -o have_fpos${EXT} ${S} \ + || ${TRUE} + -${Q} ./have_fpos${EXT} > fpos_tmp ${E} \ + || ${TRUE} -${Q} if [ -s fpos_tmp ]; then \ - ${CAT} fpos_tmp >> have_fpos.h; \ + ${CAT} fpos_tmp >> $@; \ else \ - echo '#undef HAVE_FPOS /* no */' >> have_fpos.h; \ - echo '' >> have_fpos.h; \ - echo 'typedef long FILEPOS;' >> have_fpos.h; \ + echo '#undef HAVE_FPOS /* no */' >> $@; \ + echo '' >> $@; \ + echo 'typedef long FILEPOS;' >> $@; \ fi - ${Q} echo '' >> have_fpos.h - ${Q} echo '' >> have_fpos.h - ${Q} echo '#endif /* !CALC_HAVE_FPOS_H */' >> have_fpos.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_FPOS_H */' >> $@ ${Q} ${RM} -f have_fpos${EXT} have_fpos.o fpos_tmp - ${Q} echo 'have_fpos.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2817,40 +2967,40 @@ have_fpos.h: have_fpos.c ${MAKE_FILE} ${TRUE}; \ fi -have_fpos_pos.h: have_fpos_pos.c have_fpos.h have_posscl.h ${MAKE_FILE} - ${Q} ${RM} -f fpos_tmp have_fpos_pos.h - ${Q} echo 'forming have_fpos_pos.h' - ${Q} echo '/*' > have_fpos_pos.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' \ - >> have_fpos_pos.h - ${Q} echo ' */' >> have_fpos_pos.h - ${Q} echo '' >> have_fpos_pos.h - ${Q} echo '' >> have_fpos_pos.h - ${Q} echo '#if !defined(CALC_HAVE_FPOS_POS_H)' >> have_fpos_pos.h - ${Q} echo '#define CALC_HAVE_FPOS_POS_H' >> have_fpos_pos.h - ${Q} echo '' >> have_fpos_pos.h - ${Q} echo '' >> have_fpos_pos.h - ${Q} echo '/* do we have fgetpos & fsetpos functions? */' \ - >> have_fpos_pos.h +have_fpos_pos.h: have_fpos_pos.c have_fpos.h have_posscl.h \ + banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f fpos_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_FPOS_POS_H)' >> $@ + ${Q} echo '#define CALC_HAVE_FPOS_POS_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have fgetpos & fsetpos functions? */' >> $@ ${Q} ${RM} -f have_fpos_pos.o have_fpos_pos${EXT} - -${Q} ${LCC} ${HAVE_FPOS} ${HAVE_FPOS_POS} \ - ${ICFLAGS} have_fpos_pos.c -c >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_fpos_pos.o -o have_fpos_pos${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_fpos_pos${EXT} > fpos_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${HAVE_FPOS} ${HAVE_FPOS_POS} ${ICFLAGS} \ + have_fpos_pos.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_fpos_pos.o -o have_fpos_pos${EXT} ${S} \ + || ${TRUE} + -${Q} ./have_fpos_pos${EXT} > fpos_tmp ${E} \ + || ${TRUE} -${Q} if [ -s fpos_tmp ]; then \ - ${CAT} fpos_tmp >> have_fpos_pos.h; \ + ${CAT} fpos_tmp >> $@; \ else \ - echo '#undef HAVE_FPOS_POS /* no */' >> have_fpos_pos.h; \ - echo '' >> have_fpos_pos.h; \ - echo '#undef FPOS_POS_BITS' >> have_fpos_pos.h; \ + echo '#undef HAVE_FPOS_POS /* no */' >> $@; \ + echo '' >> $@; \ + echo '#undef FPOS_POS_BITS' >> $@; \ fi - ${Q} echo '' >> have_fpos_pos.h - ${Q} echo '' >> have_fpos_pos.h - ${Q} echo '#endif /* !CALC_HAVE_FPOS_POS_H */' >> have_fpos_pos.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_FPOS_POS_H */' >> $@ ${Q} ${RM} -f have_fpos_pos${EXT} have_fpos_pos.o fpos_tmp - ${Q} echo 'have_fpos_pos.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2862,31 +3012,39 @@ have_fpos_pos.h: have_fpos_pos.c have_fpos.h have_posscl.h ${MAKE_FILE} fi fposval.h: fposval.c have_fpos.h have_fpos_pos.h have_offscl.h have_posscl.h \ - endian_calc.h ${MAKE_FILE} - ${Q} ${RM} -f fposv_tmp fposval.h - ${Q} echo 'forming fposval.h' - ${Q} echo '/*' > fposval.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> fposval.h - ${Q} echo ' */' >> fposval.h - ${Q} echo '' >> fposval.h - ${Q} echo '' >> fposval.h - ${Q} echo '#if !defined(__FPOSVAL_H__)' >> fposval.h - ${Q} echo '#define __FPOSVAL_H__' >> fposval.h - ${Q} echo '' >> fposval.h - ${Q} echo '' >> fposval.h - ${Q} echo '/* what are our file position & size types? */' >> fposval.h + endian_calc.h banned.h have_ban_pragma.h fposval.h.def alloc.h \ + have_newstr.h have_memmv.h ${MAKE_FILE} + ${Q} ${RM} -f fposval_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_FPOSVAL_H)' >> $@ + ${Q} echo '#define CALC_FPOSVAL_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* what are our file position & size types? */' >> $@ ${Q} ${RM} -f fposval.o fposval${EXT} -${Q} ${LCC} ${ICFLAGS} ${FPOS_BITS} ${OFF_T_BITS} \ - ${DEV_BITS} ${INODE_BITS} fposval.c -c >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} fposval.o -o fposval${EXT} >/dev/null \ - 2>&1; ${TRUE} - ${Q} ${SHELL} -c "./fposval${EXT} fposv_tmp >> fposval.h 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} - ${Q} echo '' >> fposval.h - ${Q} echo '' >> fposval.h - ${Q} echo '#endif /* !__FPOSVAL_H__ */' >> fposval.h - ${Q} ${RM} -f fposval${EXT} fposval.o fposv_tmp - ${Q} echo 'fposval.h formed' + ${DEV_BITS} ${INODE_BITS} fposval.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} fposval.o -o fposval${EXT} ${S} \ + || ${TRUE} + -${Q} ./fposval${EXT} > fposval_tmp ${E} \ + || ${TRUE} + -${Q} if [ -s fposval_tmp ]; then \ + ${CAT} fposval_tmp >> $@; \ + else \ + echo 'WARNING!! ./fposval${EXT} failed, using fposval.h.def' 1>&2; \ + ${CAT} fposval.h.def >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_FPOSVAL_H */' >> $@ + ${Q} ${RM} -f fposval${EXT} fposval.o fposval_tmp + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2897,38 +3055,38 @@ fposval.h: fposval.c have_fpos.h have_fpos_pos.h have_offscl.h have_posscl.h \ ${TRUE}; \ fi -have_const.h: have_const.c ${MAKE_FILE} - ${Q} ${RM} -f have_const const_tmp have_const.h - ${Q} echo 'forming have_const.h' - ${Q} echo '/*' > have_const.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_const.h - ${Q} echo ' */' >> have_const.h - ${Q} echo '' >> have_const.h - ${Q} echo '' >> have_const.h - ${Q} echo '#if !defined(CALC_HAVE_CONST_H)' >> have_const.h - ${Q} echo '#define CALC_HAVE_CONST_H' >> have_const.h - ${Q} echo '' >> have_const.h - ${Q} echo '' >> have_const.h - ${Q} echo '/* do we have or want const? */' >> have_const.h +have_const.h: have_const.c banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f have_const const_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_CONST_H)' >> $@ + ${Q} echo '#define CALC_HAVE_CONST_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want const? */' >> $@ ${Q} ${RM} -f have_const.o have_const${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_CONST} have_const.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_const.o -o have_const${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_const${EXT} > const_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_CONST} have_const.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_const.o -o have_const${EXT} ${S} \ + || ${TRUE} + -${Q} ./have_const${EXT} > const_tmp ${E} \ + || ${TRUE} -${Q} if [ -s const_tmp ]; then \ - ${CAT} const_tmp >> have_const.h; \ + ${CAT} const_tmp >> $@; \ else \ - echo '#undef HAVE_CONST /* no */' >> have_const.h; \ - echo '#undef CONST' >> have_const.h; \ - echo '#define CONST /* no */' >> have_const.h; \ + echo '#undef HAVE_CONST /* no */' >> $@; \ + echo '#undef CONST' >> $@; \ + echo '#define CONST /* no */' >> $@; \ fi - ${Q} echo '' >> have_const.h - ${Q} echo '' >> have_const.h - ${Q} echo '#endif /* !CALC_HAVE_CONST_H */' >> have_const.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_CONST_H */' >> $@ ${Q} ${RM} -f have_const${EXT} have_const.o const_tmp - ${Q} echo 'have_const.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2939,36 +3097,37 @@ have_const.h: have_const.c ${MAKE_FILE} ${TRUE}; \ fi -have_offscl.h: have_offscl.c have_unistd.h ${MAKE_FILE} - ${Q} ${RM} -f offscl_tmp have_offscl.h - ${Q} echo 'forming have_offscl.h' - ${Q} echo '/*' > have_offscl.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_offscl.h - ${Q} echo ' */' >> have_offscl.h - ${Q} echo '' >> have_offscl.h - ${Q} echo '' >> have_offscl.h - ${Q} echo '#if !defined(CALC_HAVE_OFFSCL_H)' >> have_offscl.h - ${Q} echo '#define CALC_HAVE_OFFSCL_H' >> have_offscl.h - ${Q} echo '' >> have_offscl.h - ${Q} echo '' >> have_offscl.h +have_offscl.h: have_offscl.c have_unistd.h \ + banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f offscl_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_OFFSCL_H)' >> $@ + ${Q} echo '#define CALC_HAVE_OFFSCL_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ ${Q} ${RM} -f have_offscl.o have_offscl${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_OFFSCL} have_offscl.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_offscl.o -o have_offscl${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_offscl${EXT} > offscl_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_OFFSCL} have_offscl.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_offscl.o -o have_offscl${EXT} ${S} \ + || ${TRUE} + -${Q} ./have_offscl${EXT} > offscl_tmp ${E} \ + || ${TRUE} -${Q} if [ -s offscl_tmp ]; then \ - ${CAT} offscl_tmp >> have_offscl.h; \ + ${CAT} offscl_tmp >> $@; \ else \ echo '#undef HAVE_OFF_T_SCALAR /* off_t is not a simple value */' \ - >> have_offscl.h; \ + >> $@; \ fi - ${Q} echo '' >> have_offscl.h - ${Q} echo '' >> have_offscl.h - ${Q} echo '#endif /* !CALC_HAVE_OFFSCL_H */' >> have_offscl.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_OFFSCL_H */' >> $@ ${Q} ${RM} -f have_offscl${EXT} have_offscl.o offscl_tmp - ${Q} echo 'have_offscl.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -2979,36 +3138,37 @@ have_offscl.h: have_offscl.c have_unistd.h ${MAKE_FILE} ${TRUE}; \ fi -have_posscl.h: have_posscl.c have_fpos.h have_unistd.h ${MAKE_FILE} - ${Q} ${RM} -f have_posscl have_posscl.o posscl_tmp have_posscl.h - ${Q} echo 'forming have_posscl.h' - ${Q} echo '/*' > have_posscl.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_posscl.h - ${Q} echo ' */' >> have_posscl.h - ${Q} echo '' >> have_posscl.h - ${Q} echo '' >> have_posscl.h - ${Q} echo '#if !defined(CALC_HAVE_POSSCL_H)' >> have_posscl.h - ${Q} echo '#define CALC_HAVE_POSSCL_H' >> have_posscl.h - ${Q} echo '' >> have_posscl.h - ${Q} echo '' >> have_posscl.h +have_posscl.h: have_posscl.c have_fpos.h have_unistd.h \ + banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f have_posscl have_posscl.o posscl_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_POSSCL_H)' >> $@ + ${Q} echo '#define CALC_HAVE_POSSCL_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ ${Q} ${RM} -f have_posscl.o have_posscl - -${Q} ${LCC} ${ICFLAGS} ${HAVE_POSSCL} have_posscl.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_posscl.o -o have_posscl \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_posscl > posscl_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_POSSCL} have_posscl.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_posscl.o -o have_posscl ${S} \ + || ${TRUE} + -${Q} ./have_posscl > posscl_tmp ${E} \ + || ${TRUE} -${Q} if [ -s posscl_tmp ]; then \ - ${CAT} posscl_tmp >> have_posscl.h; \ + ${CAT} posscl_tmp >> $@; \ else \ - echo '/* FILEPOS is not a simple value */' >> have_posscl.h; \ - echo '#undef HAVE_FILEPOS_SCALAR' >> have_posscl.h; \ + echo '/* FILEPOS is not a simple value */' >> $@; \ + echo '#undef HAVE_FILEPOS_SCALAR' >> $@; \ fi - ${Q} echo '' >> have_posscl.h - ${Q} echo '' >> have_posscl.h - ${Q} echo '#endif /* !CALC_HAVE_POSSCL_H */' >> have_posscl.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_POSSCL_H */' >> $@ ${Q} ${RM} -f have_posscl have_posscl.o posscl_tmp - ${Q} echo 'have_posscl.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3019,51 +3179,51 @@ have_posscl.h: have_posscl.c have_fpos.h have_unistd.h ${MAKE_FILE} ${TRUE}; \ fi -align32.h: align32.c longbits.h have_unistd.h ${MAKE_FILE} - ${Q} ${RM} -f align32 align32_tmp align32.h - ${Q} echo 'forming align32.h' - ${Q} echo '/*' > align32.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> align32.h - ${Q} echo ' */' >> align32.h - ${Q} echo '' >> align32.h - ${Q} echo '' >> align32.h - ${Q} echo '#if !defined(__MUST_ALIGN32_H__)' >> align32.h - ${Q} echo '#define __MUST_ALIGN32_H__' >> align32.h - ${Q} echo '' >> align32.h - ${Q} echo '' >> align32.h - ${Q} echo '/* must we always align 32 bit accesses? */' >> align32.h +align32.h: align32.c longbits.h have_unistd.h \ + banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f align32 align32_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_ALIGN32_H)' >> $@ + ${Q} echo '#define CALC_ALIGN32_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* must we always align 32 bit accesses? */' >> $@ -${Q} if [ X"-DMUST_ALIGN32" = X${ALIGN32} ]; then \ - echo '/* forced to align 32 bit values */' >> align32.h; \ - echo '#define MUST_ALIGN32' >> align32.h; \ + echo '/* forced to align 32 bit values */' >> $@; \ + echo '#define MUST_ALIGN32' >> $@; \ else \ ${TRUE}; \ fi -${Q} if [ X"-UMUST_ALIGN32" = X${ALIGN32} ]; then \ - echo '/* forced to not require 32 bit alignment */' >> align32.h; \ - echo '#undef MUST_ALIGN32' >> align32.h; \ + echo '/* forced to not require 32 bit alignment */' >> $@; \ + echo '#undef MUST_ALIGN32' >> $@; \ else \ ${TRUE}; \ fi -${Q} if [ X = X${ALIGN32} ]; then \ ${RM} -f align32.o align32${EXT}; \ - ${LCC} ${ICFLAGS} ${ALIGN32} align32.c -c >/dev/null 2>&1; \ - ${LCC} ${ILDFLAGS} align32.o -o align32${EXT} >/dev/null 2>&1; \ - ${SHELL} -c \ - "./align32${EXT} >align32_tmp 2>/dev/null" >/dev/null 2>&1; \ + ${LCC} ${ICFLAGS} ${ALIGN32} align32.c -c ${S}; \ + ${LCC} ${ILDFLAGS} align32.o -o align32${EXT} ${S}; \ + ./align32${EXT} >align32_tmp ${E}; \ if [ -s align32_tmp ]; then \ - ${CAT} align32_tmp >> align32.h; \ + ${CAT} align32_tmp >> $@; \ else \ - echo '/* guess we must align 32 bit values */' >> align32.h; \ - echo '#define MUST_ALIGN32' >> align32.h; \ + echo '/* guess we must align 32 bit values */' >> $@; \ + echo '#define MUST_ALIGN32' >> $@; \ fi; \ ${RM} -f align32${EXT} align32.o align32_tmp core; \ else \ ${TRUE}; \ fi - ${Q} echo '' >> align32.h - ${Q} echo '' >> align32.h - ${Q} echo '#endif /* !__MUST_ALIGN32_H__ */' >> align32.h - ${Q} echo 'align32.h formed' + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_ALIGN32_H */' >> $@ + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3074,36 +3234,37 @@ align32.h: align32.c longbits.h have_unistd.h ${MAKE_FILE} ${TRUE}; \ fi -have_uid_t.h: have_uid_t.c have_unistd.h ${MAKE_FILE} - ${Q} ${RM} -f have_uid_t uid_tmp have_uid_t.h - ${Q} echo 'forming have_uid_t.h' - ${Q} echo '/*' > have_uid_t.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_uid_t.h - ${Q} echo ' */' >> have_uid_t.h - ${Q} echo '' >> have_uid_t.h - ${Q} echo '' >> have_uid_t.h - ${Q} echo '#if !defined(CALC_HAVE_UID_T_H)' >> have_uid_t.h - ${Q} echo '#define CALC_HAVE_UID_T_H' >> have_uid_t.h - ${Q} echo '' >> have_uid_t.h - ${Q} echo '' >> have_uid_t.h - ${Q} echo '/* do we have or want uid_t? */' >> have_uid_t.h +have_uid_t.h: have_uid_t.c have_unistd.h \ + banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f have_uid_t uid_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_UID_T_H)' >> $@ + ${Q} echo '#define CALC_HAVE_UID_T_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want uid_t? */' >> $@ ${Q} ${RM} -f have_uid_t.o have_uid_t${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_UID_T} have_uid_t.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_uid_t.o -o have_uid_t${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_uid_t${EXT} > uid_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_UID_T} have_uid_t.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_uid_t.o -o have_uid_t${EXT} ${S} \ + || ${TRUE} + -${Q} ./have_uid_t${EXT} > uid_tmp ${E} \ + || ${TRUE} -${Q} if [ -s uid_tmp ]; then \ - ${CAT} uid_tmp >> have_uid_t.h; \ + ${CAT} uid_tmp >> $@; \ else \ - echo '#undef HAVE_UID_T /* no */' >> have_uid_t.h; \ + echo '#undef HAVE_UID_T /* no */' >> $@; \ fi - ${Q} echo '' >> have_uid_t.h - ${Q} echo '' >> have_uid_t.h - ${Q} echo '#endif /* !CALC_HAVE_UID_T_H */' >> have_uid_t.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_UID_T_H */' >> $@ ${Q} ${RM} -f have_uid_t${EXT} have_uid_t.o uid_tmp - ${Q} echo 'have_uid_t.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3114,37 +3275,36 @@ have_uid_t.h: have_uid_t.c have_unistd.h ${MAKE_FILE} ${TRUE}; \ fi -have_newstr.h: have_newstr.c ${MAKE_FILE} - ${Q} ${RM} -f newstr_tmp have_newstr.h - ${Q} echo 'forming have_newstr.h' - ${Q} echo '/*' > have_newstr.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_newstr.h - ${Q} echo ' */' >> have_newstr.h - ${Q} echo '' >> have_newstr.h - ${Q} echo '' >> have_newstr.h - ${Q} echo '#if !defined(CALC_HAVE_NEWSTR_H)' >> have_newstr.h - ${Q} echo '#define CALC_HAVE_NEWSTR_H' >> have_newstr.h - ${Q} echo '' >> have_newstr.h - ${Q} echo '' >> have_newstr.h - ${Q} echo '/* do we have or want memcpy(), memset() & strchr()? */' \ - >> have_newstr.h +have_newstr.h: have_newstr.c banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f newstr_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_NEWSTR_H)' >> $@ + ${Q} echo '#define CALC_HAVE_NEWSTR_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have/want memcpy(), memset() & strchr()? */' >> $@ ${Q} ${RM} -f have_newstr.o have_newstr${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_NEWSTR} have_newstr.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_newstr.o -o have_newstr${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_newstr${EXT} > newstr_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_NEWSTR} have_newstr.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_newstr.o -o have_newstr${EXT} ${S} \ + || ${TRUE} + -${Q} ./have_newstr${EXT} > newstr_tmp ${E} \ + || ${TRUE} -${Q} if [ -s newstr_tmp ]; then \ - ${CAT} newstr_tmp >> have_newstr.h; \ + ${CAT} newstr_tmp >> $@; \ else \ - echo '#undef HAVE_NEWSTR /* no */' >> have_newstr.h; \ + echo '#undef HAVE_NEWSTR /* no */' >> $@; \ fi - ${Q} echo '' >> have_newstr.h - ${Q} echo '' >> have_newstr.h - ${Q} echo '#endif /* !CALC_HAVE_NEWSTR_H */' >> have_newstr.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_NEWSTR_H */' >> $@ ${Q} ${RM} -f have_newstr${EXT} have_newstr.o newstr_tmp - ${Q} echo 'have_newstr.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3155,36 +3315,36 @@ have_newstr.h: have_newstr.c ${MAKE_FILE} ${TRUE}; \ fi -have_memmv.h: have_memmv.c ${MAKE_FILE} - ${Q} ${RM} -f have_memmv have_memmv.o memmv_tmp have_memmv.h - ${Q} echo 'forming have_memmv.h' - ${Q} echo '/*' > have_memmv.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_memmv.h - ${Q} echo ' */' >> have_memmv.h - ${Q} echo '' >> have_memmv.h - ${Q} echo '' >> have_memmv.h - ${Q} echo '#if !defined(CALC_HAVE_MEMMV_H)' >> have_memmv.h - ${Q} echo '#define CALC_HAVE_MEMMV_H' >> have_memmv.h - ${Q} echo '' >> have_memmv.h - ${Q} echo '' >> have_memmv.h - ${Q} echo '/* do we have or want memmove()? */' >> have_memmv.h +have_memmv.h: have_memmv.c banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f have_memmv have_memmv.o memmv_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_MEMMV_H)' >> $@ + ${Q} echo '#define CALC_HAVE_MEMMV_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want memmove()? */' >> $@ ${Q} ${RM} -f have_memmv.o have_memmv - -${Q} ${LCC} ${ICFLAGS} ${HAVE_MEMMOVE} have_memmv.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_memmv.o -o have_memmv \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_memmv > memmv_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_MEMMOVE} have_memmv.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_memmv.o -o have_memmv ${S} \ + || ${TRUE} + -${Q} ./have_memmv > memmv_tmp ${E} \ + || ${TRUE} -${Q} if [ -s memmv_tmp ]; then \ - ${CAT} memmv_tmp >> have_memmv.h; \ + ${CAT} memmv_tmp >> $@; \ else \ - echo '#undef HAVE_MEMMOVE /* no */' >> have_memmv.h; \ + echo '#undef HAVE_MEMMOVE /* no */' >> $@; \ fi - ${Q} echo '' >> have_memmv.h - ${Q} echo '' >> have_memmv.h - ${Q} echo '#endif /* !CALC_HAVE_MEMMV_H */' >> have_memmv.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_MEMMV_H */' >> $@ ${Q} ${RM} -f have_memmv have_memmv.o memmv_tmp - ${Q} echo 'have_memmv.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3195,36 +3355,35 @@ have_memmv.h: have_memmv.c ${MAKE_FILE} ${TRUE}; \ fi -have_ustat.h: have_ustat.c ${MAKE_FILE} - ${Q} ${RM} -f ustat_tmp have_ustat.h - ${Q} echo 'forming have_ustat.h' - ${Q} echo '/*' > have_ustat.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_ustat.h - ${Q} echo ' */' >> have_ustat.h - ${Q} echo '' >> have_ustat.h - ${Q} echo '' >> have_ustat.h - ${Q} echo '#if !defined(CALC_HAVE_USTAT_H)' >> have_ustat.h - ${Q} echo '#define CALC_HAVE_USTAT_H' >> have_ustat.h - ${Q} echo '' >> have_ustat.h - ${Q} echo '' >> have_ustat.h - ${Q} echo '/* do we have or want ustat()? */' >> have_ustat.h +have_ustat.h: have_ustat.c banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f ustat_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_USTAT_H)' >> $@ + ${Q} echo '#define CALC_HAVE_USTAT_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want ustat()? */' >> $@ ${Q} ${RM} -f have_ustat.o have_ustat${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_USTAT} have_ustat.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_ustat.o -o have_ustat${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_ustat${EXT} > ustat_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} if echo '#include ' | ${CC} -E - ${S}; then \ + ${Q} ${LCC} ${ICFLAGS} ${HAVE_USTAT} have_ustat.c -c ${S}; \ + ${Q} ${LCC} ${ILDFLAGS} have_ustat.o -o have_ustat${EXT} ${S}; \ + ${Q} ./have_ustat${EXT} > ustat_tmp ${E}; \ + fi -${Q} if [ -s ustat_tmp ]; then \ - ${CAT} ustat_tmp >> have_ustat.h; \ + ${CAT} ustat_tmp >> $@; \ else \ - echo '#undef HAVE_USTAT /* no */' >> have_ustat.h; \ + echo '#undef HAVE_USTAT /* no */' >> $@; \ fi - ${Q} echo '' >> have_ustat.h - ${Q} echo '' >> have_ustat.h - ${Q} echo '#endif /* !CALC_HAVE_USTAT_H */' >> have_ustat.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_USTAT_H */' >> $@ ${Q} ${RM} -f have_ustat${EXT} have_ustat.o ustat_tmp - ${Q} echo 'have_ustat.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3235,36 +3394,37 @@ have_ustat.h: have_ustat.c ${MAKE_FILE} ${TRUE}; \ fi -have_getsid.h: have_getsid.c have_unistd.h ${MAKE_FILE} - ${Q} ${RM} -f getsid_tmp have_getsid.h - ${Q} echo 'forming have_getsid.h' - ${Q} echo '/*' > have_getsid.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_getsid.h - ${Q} echo ' */' >> have_getsid.h - ${Q} echo '' >> have_getsid.h - ${Q} echo '' >> have_getsid.h - ${Q} echo '#if !defined(CALC_HAVE_GETSID_H)' >> have_getsid.h - ${Q} echo '#define CALC_HAVE_GETSID_H' >> have_getsid.h - ${Q} echo '' >> have_getsid.h - ${Q} echo '' >> have_getsid.h - ${Q} echo '/* do we have or want getsid()? */' >> have_getsid.h +have_getsid.h: have_getsid.c have_unistd.h \ + banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f getsid_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_GETSID_H)' >> $@ + ${Q} echo '#define CALC_HAVE_GETSID_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want getsid()? */' >> $@ ${Q} ${RM} -f have_getsid.o have_getsid${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_GETSID} have_getsid.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_getsid.o -o have_getsid \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_getsid${EXT} > getsid_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_GETSID} have_getsid.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_getsid.o -o have_getsid ${S} \ + || ${TRUE} + -${Q} ./have_getsid${EXT} > getsid_tmp ${E} \ + || ${TRUE} -${Q} if [ -s getsid_tmp ]; then \ - ${CAT} getsid_tmp >> have_getsid.h; \ + ${CAT} getsid_tmp >> $@; \ else \ - echo '#undef HAVE_GETSID /* no */' >> have_getsid.h; \ + echo '#undef HAVE_GETSID /* no */' >> $@; \ fi - ${Q} echo '' >> have_getsid.h - ${Q} echo '' >> have_getsid.h - ${Q} echo '#endif /* !CALC_HAVE_GETSID_H */' >> have_getsid.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_GETSID_H */' >> $@ ${Q} ${RM} -f have_getsid${EXT} have_getsid.o getsid_tmp - ${Q} echo 'have_getsid.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3275,37 +3435,37 @@ have_getsid.h: have_getsid.c have_unistd.h ${MAKE_FILE} ${TRUE}; \ fi -have_getpgid.h: have_getpgid.c have_unistd.h ${MAKE_FILE} - ${Q} ${RM} -f getpgid_tmp have_getpgid.h - ${Q} echo 'forming have_getpgid.h' - ${Q} echo '/*' > have_getpgid.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> \ - have_getpgid.h - ${Q} echo ' */' >> have_getpgid.h - ${Q} echo '' >> have_getpgid.h - ${Q} echo '' >> have_getpgid.h - ${Q} echo '#if !defined(CALC_HAVE_GETPGID_H)' >> have_getpgid.h - ${Q} echo '#define CALC_HAVE_GETPGID_H' >> have_getpgid.h - ${Q} echo '' >> have_getpgid.h - ${Q} echo '' >> have_getpgid.h - ${Q} echo '/* do we have or want getpgid()? */' >> have_getpgid.h +have_getpgid.h: have_getpgid.c have_unistd.h \ + banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f getpgid_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_GETPGID_H)' >> $@ + ${Q} echo '#define CALC_HAVE_GETPGID_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want getpgid()? */' >> $@ ${Q} ${RM} -f have_getpgid.o have_getpgid${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_GETPGID} have_getpgid.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_getpgid.o -o have_getpgid${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_getpgid${EXT} > getpgid_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_GETPGID} have_getpgid.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_getpgid.o -o have_getpgid${EXT} ${S} \ + || ${TRUE} + -${Q} ./have_getpgid${EXT} > getpgid_tmp ${E} \ + || ${TRUE} -${Q} if [ -s getpgid_tmp ]; then \ - ${CAT} getpgid_tmp >> have_getpgid.h; \ + ${CAT} getpgid_tmp >> $@; \ else \ - echo '#undef HAVE_GETPGID /* no */' >> have_getpgid.h; \ + echo '#undef HAVE_GETPGID /* no */' >> $@; \ fi - ${Q} echo '' >> have_getpgid.h - ${Q} echo '' >> have_getpgid.h - ${Q} echo '#endif /* !CALC_HAVE_GETPGID_H */' >> have_getpgid.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_GETPGID_H */' >> $@ ${Q} ${RM} -f have_getpgid${EXT} have_getpgid.o getpgid_tmp - ${Q} echo 'have_getpgid.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3316,37 +3476,36 @@ have_getpgid.h: have_getpgid.c have_unistd.h ${MAKE_FILE} ${TRUE}; \ fi -have_gettime.h: have_gettime.c ${MAKE_FILE} - ${Q} ${RM} -f gettime_tmp have_gettime.h - ${Q} echo 'forming have_gettime.h' - ${Q} echo '/*' > have_gettime.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> \ - have_gettime.h - ${Q} echo ' */' >> have_gettime.h - ${Q} echo '' >> have_gettime.h - ${Q} echo '' >> have_gettime.h - ${Q} echo '#if !defined(CALC_HAVE_GETTIME_H)' >> have_gettime.h - ${Q} echo '#define CALC_HAVE_GETTIME_H' >> have_gettime.h - ${Q} echo '' >> have_gettime.h - ${Q} echo '' >> have_gettime.h - ${Q} echo '/* do we have or want clock_gettime()? */' >> have_gettime.h +have_gettime.h: have_gettime.c banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f gettime_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_GETTIME_H)' >> $@ + ${Q} echo '#define CALC_HAVE_GETTIME_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want clock_gettime()? */' >> $@ ${Q} ${RM} -f have_gettime.o have_gettime${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_GETTIME} have_gettime.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_gettime.o -o have_gettime \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_gettime${EXT} > gettime_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_GETTIME} have_gettime.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_gettime.o -o have_gettime ${S} \ + || ${TRUE} + -${Q} ./have_gettime${EXT} > gettime_tmp ${E} \ + || ${TRUE} -${Q} if [ -s gettime_tmp ]; then \ - ${CAT} gettime_tmp >> have_gettime.h; \ + ${CAT} gettime_tmp >> $@; \ else \ - echo '#undef HAVE_GETTIME /* no */' >> have_gettime.h; \ + echo '#undef HAVE_GETTIME /* no */' >> $@; \ fi - ${Q} echo '' >> have_gettime.h - ${Q} echo '' >> have_gettime.h - ${Q} echo '#endif /* !CALC_HAVE_GETTIME_H */' >> have_gettime.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_GETTIME_H */' >> $@ ${Q} ${RM} -f have_gettime${EXT} have_gettime.o gettime_tmp - ${Q} echo 'have_gettime.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3357,37 +3516,37 @@ have_gettime.h: have_gettime.c ${MAKE_FILE} ${TRUE}; \ fi -have_getprid.h: have_getprid.c have_unistd.h ${MAKE_FILE} - ${Q} ${RM} -f getprid_tmp have_getprid.h - ${Q} echo 'forming have_getprid.h' - ${Q} echo '/*' > have_getprid.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> \ - have_getprid.h - ${Q} echo ' */' >> have_getprid.h - ${Q} echo '' >> have_getprid.h - ${Q} echo '' >> have_getprid.h - ${Q} echo '#if !defined(CALC_HAVE_GETPRID_H)' >> have_getprid.h - ${Q} echo '#define CALC_HAVE_GETPRID_H' >> have_getprid.h - ${Q} echo '' >> have_getprid.h - ${Q} echo '' >> have_getprid.h - ${Q} echo '/* do we have or want getprid()? */' >> have_getprid.h +have_getprid.h: have_getprid.c have_unistd.h \ + banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f getprid_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_GETPRID_H)' >> $@ + ${Q} echo '#define CALC_HAVE_GETPRID_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want getprid()? */' >> $@ ${Q} ${RM} -f have_getprid.o have_getprid${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_GETPRID} have_getprid.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_getprid.o -o have_getprid${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_getprid${EXT} > getprid_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_GETPRID} have_getprid.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_getprid.o -o have_getprid${EXT} ${S} \ + || ${TRUE} + -${Q} ./have_getprid${EXT} > getprid_tmp ${E} \ + || ${TRUE} -${Q} if [ -s getprid_tmp ]; then \ - ${CAT} getprid_tmp >> have_getprid.h; \ + ${CAT} getprid_tmp >> $@; \ else \ - echo '#undef HAVE_GETPRID /* no */' >> have_getprid.h; \ + echo '#undef HAVE_GETPRID /* no */' >> $@; \ fi - ${Q} echo '' >> have_getprid.h - ${Q} echo '' >> have_getprid.h - ${Q} echo '#endif /* !CALC_HAVE_GETPRID_H */' >> have_getprid.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_GETPRID_H */' >> $@ ${Q} ${RM} -f have_getprid${EXT} have_getprid.o getprid_tmp - ${Q} echo 'have_getprid.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3399,32 +3558,31 @@ have_getprid.h: have_getprid.c have_unistd.h ${MAKE_FILE} fi have_urandom.h: ${MAKE_FILE} - ${Q} ${RM} -f have_urandom.h - ${Q} echo 'forming have_urandom.h' - ${Q} echo '/*' > have_urandom.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> \ - have_urandom.h - ${Q} echo ' */' >> have_urandom.h - ${Q} echo '' >> have_urandom.h - ${Q} echo '' >> have_urandom.h - ${Q} echo '#if !defined(CALC_HAVE_URANDOM_H)' >> have_urandom.h - ${Q} echo '#define CALC_HAVE_URANDOM_H' >> have_urandom.h - ${Q} echo '' >> have_urandom.h - ${Q} echo '' >> have_urandom.h - ${Q} echo '/* do we have /dev/urandom? */' >> have_urandom.h - -${Q} if [ X"${HAVE_URANDOM_H}" = X"YES" ]; then \ - echo '#define HAVE_URANDOM_H /* yes */' >> have_urandom.h; \ - elif [ X"${HAVE_URANDOM_H}" = X"NO" ]; then \ - echo '#undef HAVE_URANDOM_H /* no */' >> have_urandom.h; \ + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_URANDOM_H)' >> $@ + ${Q} echo '#define CALC_HAVE_URANDOM_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have /dev/urandom? */' >> $@ + -${Q} if [ X"${HAVE_URANDOM}" = X"YES" ]; then \ + echo '#define $@ /* yes */' >> $@; \ + elif [ X"${HAVE_URANDOM}" = X"NO" ]; then \ + echo '#undef HAVE_URANDOM /* no */' >> $@; \ elif [ -r /dev/urandom ] 2>/dev/null; then \ - echo '#define HAVE_URANDOM_H /* yes */' >> have_urandom.h; \ + echo '#define HAVE_URANDOM /* yes */' >> $@; \ else \ - echo '#undef HAVE_URANDOM_H /* no */' >> have_urandom.h; \ + echo '#undef HAVE_URANDOM /* no */' >> $@; \ fi - ${Q} echo '' >> have_urandom.h - ${Q} echo '' >> have_urandom.h - ${Q} echo '#endif /* !CALC_HAVE_URANDOM_H */' >> have_urandom.h - ${Q} echo 'have_urandom.h formed' + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_URANDOM_H */' >> $@ + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3435,37 +3593,36 @@ have_urandom.h: ${MAKE_FILE} ${TRUE}; \ fi -have_rusage.h: have_rusage.c ${MAKE_FILE} - ${Q} ${RM} -f rusage_tmp have_rusage.h - ${Q} echo 'forming have_rusage.h' - ${Q} echo '/*' > have_rusage.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> \ - have_rusage.h - ${Q} echo ' */' >> have_rusage.h - ${Q} echo '' >> have_rusage.h - ${Q} echo '' >> have_rusage.h - ${Q} echo '#if !defined(CALC_HAVE_RUSAGE_H)' >> have_rusage.h - ${Q} echo '#define CALC_HAVE_RUSAGE_H' >> have_rusage.h - ${Q} echo '' >> have_rusage.h - ${Q} echo '' >> have_rusage.h - ${Q} echo '/* do we have or want getrusage()? */' >> have_rusage.h +have_rusage.h: have_rusage.c banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f rusage_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_RUSAGE_H)' >> $@ + ${Q} echo '#define CALC_HAVE_RUSAGE_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want getrusage()? */' >> $@ ${Q} ${RM} -f have_rusage.o have_rusage${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_GETRUSAGE} have_rusage.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_rusage.o -o have_rusage${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_rusage${EXT} > rusage_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_GETRUSAGE} have_rusage.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_rusage.o -o have_rusage${EXT} ${S} \ + || ${TRUE} + -${Q} ./have_rusage${EXT} > rusage_tmp ${E} \ + || ${TRUE} -${Q} if [ -s rusage_tmp ]; then \ - ${CAT} rusage_tmp >> have_rusage.h; \ + ${CAT} rusage_tmp >> $@; \ else \ - echo '#undef HAVE_GETRUSAGE /* no */' >> have_rusage.h; \ + echo '#undef HAVE_GETRUSAGE /* no */' >> $@; \ fi - ${Q} echo '' >> have_rusage.h - ${Q} echo '' >> have_rusage.h - ${Q} echo '#endif /* !CALC_HAVE_RUSAGE_H */' >> have_rusage.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_RUSAGE_H */' >> $@ ${Q} ${RM} -f have_rusage${EXT} have_rusage.o rusage_tmp - ${Q} echo 'have_rusage.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3476,36 +3633,36 @@ have_rusage.h: have_rusage.c ${MAKE_FILE} ${TRUE}; \ fi -have_strdup.h: have_strdup.c ${MAKE_FILE} - ${Q} ${RM} -f strdup_tmp have_strdup.h - ${Q} echo 'forming have_strdup.h' - ${Q} echo '/*' > have_strdup.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_strdup.h - ${Q} echo ' */' >> have_strdup.h - ${Q} echo '' >> have_strdup.h - ${Q} echo '' >> have_strdup.h - ${Q} echo '#if !defined(CALC_HAVE_STRDUP_H)' >> have_strdup.h - ${Q} echo '#define CALC_HAVE_STRDUP_H' >> have_strdup.h - ${Q} echo '' >> have_strdup.h - ${Q} echo '' >> have_strdup.h - ${Q} echo '/* do we have or want getstrdup()? */' >> have_strdup.h +have_strdup.h: have_strdup.c banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f strdup_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_STRDUP_H)' >> $@ + ${Q} echo '#define CALC_HAVE_STRDUP_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want getstrdup()? */' >> $@ ${Q} ${RM} -f have_strdup.o have_strdup${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_STRDUP} have_strdup.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_strdup.o -o have_strdup \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_strdup${EXT} > strdup_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_STRDUP} have_strdup.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_strdup.o -o have_strdup ${S} \ + || ${TRUE} + -${Q} ./have_strdup${EXT} > strdup_tmp ${E} \ + || ${TRUE} -${Q} if [ -s strdup_tmp ]; then \ - ${CAT} strdup_tmp >> have_strdup.h; \ + ${CAT} strdup_tmp >> $@; \ else \ - echo '#undef HAVE_STRDUP /* no */' >> have_strdup.h; \ + echo '#undef HAVE_STRDUP /* no */' >> $@; \ fi - ${Q} echo '' >> have_strdup.h - ${Q} echo '' >> have_strdup.h - ${Q} echo '#endif /* !CALC_HAVE_STRDUP_H */' >> have_strdup.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_STRDUP_H */' >> $@ ${Q} ${RM} -f have_strdup${EXT} have_strdup.o strdup_tmp - ${Q} echo 'have_strdup.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3516,25 +3673,25 @@ have_strdup.h: have_strdup.c ${MAKE_FILE} ${TRUE}; \ fi -args.h: have_stdvs.c have_varvs.c have_string.h have_unistd.h have_string.h \ - have_stdlib.h - ${Q} ${RM} -f args.h - ${Q} echo 'forming args.h' - ${Q} echo '/*' > args.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> args.h - ${Q} echo ' */' >> args.h - ${Q} echo '' >> args.h - ${Q} echo '' >> args.h - ${Q} echo '#if !defined(__ARGS_H__)' >> args.h - ${Q} echo '#define __ARGS_H__' >> args.h - ${Q} echo '' >> args.h - ${Q} echo '' >> args.h +args.h: have_stdvs.c have_varvs.c have_string.h have_unistd.h \ + have_stdlib.h banned.h have_ban_pragma.h + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_ARGS_H)' >> $@ + ${Q} echo '#define CALC_ARGS_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ ${Q} ${RM} -f have_stdvs.o have_stdvs${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_VSNPRINTF} have_stdvs.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_stdvs.o -o have_stdvs${EXT} \ - >/dev/null 2>&1; ${TRUE} - -${Q} if ./have_stdvs${EXT} >>args.h 2>/dev/null; then \ + -${Q} ${LCC} ${ICFLAGS} ${HAVE_VSNPRINTF} have_stdvs.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_stdvs.o -o have_stdvs${EXT} ${S} \ + || ${TRUE} + -${Q} if ./have_stdvs${EXT} >>$@ ${E}; then \ ${TOUCH} have_args.sh; \ else \ ${TRUE}; \ @@ -3542,10 +3699,9 @@ args.h: have_stdvs.c have_varvs.c have_string.h have_unistd.h have_string.h \ -${Q} if [ ! -f have_args.sh ] && [ X"${HAVE_VSNPRINTF}" = X ]; then \ ${RM} -f have_stdvs.o have_stdvs${EXT} have_varvs.o; \ ${RM} -f have_varvs${EXT}; \ - ${LCC} ${ICFLAGS} ${HAVE_VSNPRINTF} have_varvs.c -c \ - 2>/dev/null; \ - ${LCC} ${ILDFLAGS} have_varvs.o -o have_varvs${EXT} 2>/dev/null; \ - if ./have_varvs${EXT} >>args.h 2>/dev/null; then \ + ${LCC} ${ICFLAGS} ${HAVE_VSNPRINTF} have_varvs.c -c ${S}; \ + ${LCC} ${ILDFLAGS} have_varvs.o -o have_varvs${EXT} ${E}; \ + if ./have_varvs${EXT} >>$@ 2>/dev/null; then \ ${TOUCH} have_args.sh; \ else \ ${TRUE}; \ @@ -3562,12 +3718,12 @@ args.h: have_stdvs.c have_varvs.c have_string.h have_unistd.h have_string.h \ echo "the Makefile variable HAVE_VSNPRINTF."; \ fi ${Q} sh ./have_args.sh - ${Q} echo '' >> args.h - ${Q} echo '' >> args.h - ${Q} echo '#endif /* !__ARGS_H__ */' >> args.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_ARGS_H */' >> $@ ${Q} ${RM} -f have_stdvs.o have_varvs.o have_varvs${EXT} have_args.sh ${Q} ${RM} -f core - ${Q} echo 'args.h formed' + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3580,24 +3736,24 @@ args.h: have_stdvs.c have_varvs.c have_string.h have_unistd.h have_string.h \ calcerr.h: calcerr.tbl calcerr_h.sed calcerr_h.awk ${MAKE_FILE} ${Q} ${RM} -f calerr.h - ${Q} echo 'forming calcerr.h' - ${Q} echo '/*' > calcerr.h - ${Q} echo ' * DO NOT EDIT' >> calcerr.h - ${Q} echo ' *' >> calcerr.h - ${Q} echo ' * generated by calcerr.tbl via Makefile' >> calcerr.h - ${Q} echo ' */' >> calcerr.h - ${Q} echo '' >> calcerr.h - ${Q} echo '' >> calcerr.h - ${Q} echo '#if !defined(__CALCERR_H__)' >> calcerr.h - ${Q} echo '#define __CALCERR_H__' >> calcerr.h - ${Q} echo '' >> calcerr.h - ${Q} echo '' >> calcerr.h + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT' >> $@ + ${Q} echo ' *' >> $@ + ${Q} echo ' * generated by calcerr.tbl via Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_CALCERR_H)' >> $@ + ${Q} echo '#define CALC_CALCERR_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ ${Q} ${SED} -f calcerr_h.sed < calcerr.tbl | \ - ${AWK} -f calcerr_h.awk >> calcerr.h - ${Q} echo '' >> calcerr.h - ${Q} echo '' >> calcerr.h - ${Q} echo '#endif /* !__CALCERR_H__ */' >> calcerr.h - ${Q} echo 'calcerr.h formed' + ${AWK} -f calcerr_h.awk >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_CALCERR_H */' >> $@ + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3610,16 +3766,16 @@ calcerr.h: calcerr.tbl calcerr_h.sed calcerr_h.awk ${MAKE_FILE} calcerr.c: calcerr.tbl calcerr_c.sed calcerr_c.awk ${MAKE_FILE} ${Q} ${RM} -f calerr.c - ${Q} echo 'forming calcerr.c' - ${Q} echo '/*' > calcerr.c - ${Q} echo ' * DO NOT EDIT' >> calcerr.c - ${Q} echo ' *' >> calcerr.c - ${Q} echo ' * generated by calcerr.tbl via Makefile' >> calcerr.c - ${Q} echo ' */' >> calcerr.c - ${Q} echo '' >> calcerr.c + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT' >> $@ + ${Q} echo ' *' >> $@ + ${Q} echo ' * generated by calcerr.tbl via Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ ${Q} ${SED} -f calcerr_c.sed < calcerr.tbl | \ - ${AWK} -f calcerr_c.awk >> calcerr.c - ${Q} echo 'calcerr.c formed' + ${AWK} -f calcerr_c.awk >> $@ + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3630,38 +3786,162 @@ calcerr.c: calcerr.tbl calcerr_c.sed calcerr_c.awk ${MAKE_FILE} ${TRUE}; \ fi -have_unused.h: have_unused.c ${MAKE_FILE} - ${Q} ${RM} -f unused_tmp have_unused.h - ${Q} echo 'forming have_unused.h' - ${Q} echo '/*' > have_unused.h - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> have_unused.h - ${Q} echo ' */' >> have_unused.h - ${Q} echo '' >> have_unused.h - ${Q} echo '' >> have_unused.h - ${Q} echo '#if !defined(CALC_HAVE_UNUSED_H)' >> have_unused.h - ${Q} echo '#define CALC_HAVE_UNUSED_H' >> have_unused.h - ${Q} echo '' >> have_unused.h - ${Q} echo '' >> have_unused.h - ${Q} echo '/* do we have/want the unused attribute? */' >> have_unused.h +have_unused.h: have_unused.c have_stdlib.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f unused_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_UNUSED_H)' >> $@ + ${Q} echo '#define CALC_HAVE_UNUSED_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have/want the unused attribute? */' >> $@ ${Q} ${RM} -f have_unused.o have_unused${EXT} - -${Q} ${LCC} ${ICFLAGS} ${HAVE_UNUSED} have_unused.c -c \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${LCC} ${ILDFLAGS} have_unused.o -o have_unused \ - >/dev/null 2>&1; ${TRUE} - -${Q} ${SHELL} -c "./have_unused${EXT} > unused_tmp 2>/dev/null" \ - >/dev/null 2>&1; ${TRUE} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_UNUSED} have_unused.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_unused.o -o have_unused ${S} \ + || ${TRUE} + -${Q} ./have_unused${EXT} > unused_tmp ${E} \ + || ${TRUE} -${Q} if [ -s unused_tmp ]; then \ - ${CAT} unused_tmp >> have_unused.h; \ + ${CAT} unused_tmp >> $@; \ else \ - echo '#undef HAVE_UNUSED /* no */' >> have_unused.h; \ - echo '#undef UNUSED' >> have_unused.h; \ - echo '#define UNUSED /* no */' >> have_unused.h; \ + echo '#undef HAVE_UNUSED /* no */' >> $@; \ + echo '#undef UNUSED' >> $@; \ + echo '#define UNUSED /* no */' >> $@; \ fi - ${Q} echo '' >> have_unused.h - ${Q} echo '' >> have_unused.h - ${Q} echo '#endif /* !CALC_HAVE_UNUSED_H */' >> have_unused.h + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_UNUSED_H */' >> $@ ${Q} ${RM} -f have_unused${EXT} have_unused.o unused_tmp - ${Q} echo 'have_unused.h formed' + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + +have_ban_pragma.h: have_ban_pragma.c banned.h ${MAKE_FILE} + ${Q} ${RM} -f unused_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_BAN_PRAGMA_H)' >> $@ + ${Q} echo '#define CALC_HAVE_BAN_PRAGMA_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have/want #pragma GCC poison func_name? */' >> $@ + ${Q} ${RM} -f have_ban_pragma.o have_ban_pragma${EXT} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_PRAGMA_GCC_POSION} \ + have_ban_pragma.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_ban_pragma.o -o have_ban_pragma ${S} \ + || ${TRUE} + -${Q} ./have_ban_pragma${EXT} > unused_tmp ${E} \ + || ${TRUE} + -${Q} if [ -s unused_tmp ]; then \ + ${CAT} unused_tmp >> $@; \ + else \ + echo '#undef HAVE_PRAGMA_GCC_POSION /* no */' \ + >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_BAN_PRAGMA_H */' >> $@ + ${Q} ${RM} -f have_ban_pragma${EXT} have_ban_pragma.o unused_tmp + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + +have_strlcpy.h: have_strlcpy.c banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f unused_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_STRLCPY_H)' >> $@ + ${Q} echo '#define CALC_HAVE_STRLCPY_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have/want the strlcpy() function? */' >> $@ + ${Q} ${RM} -f have_strlcpy.o have_strlcpy${EXT} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_NO_STRLCPY} have_strlcpy.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_strlcpy.o -o have_strlcpy ${S} \ + || ${TRUE} + -${Q} ./have_strlcpy${EXT} > unused_tmp ${E} \ + || ${TRUE} + -${Q} if [ -s unused_tmp ]; then \ + ${CAT} unused_tmp >> $@; \ + else \ + echo '#undef HAVE_STRLCPY /* no */' \ + >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_STRLCPY_H */' >> $@ + ${Q} ${RM} -f have_strlcpy${EXT} have_strlcpy.o unused_tmp + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + +have_strlcat.h: have_strlcat.c banned.h have_ban_pragma.h ${MAKE_FILE} + ${Q} ${RM} -f unused_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_STRLCAT_H)' >> $@ + ${Q} echo '#define CALC_HAVE_STRLCAT_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have/want the strlcat() function? */' >> $@ + ${Q} ${RM} -f have_strlcat.o have_strlcat${EXT} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_NO_STRLCAT} have_strlcat.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_strlcat.o -o have_strlcat ${S} \ + || ${TRUE} + -${Q} ./have_strlcat${EXT} > unused_tmp ${E} \ + || ${TRUE} + -${Q} if [ -s unused_tmp ]; then \ + ${CAT} unused_tmp >> $@; \ + else \ + echo '#undef HAVE_STRLCAT /* no */' \ + >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_STRLCAT_H */' >> $@ + ${Q} ${RM} -f have_strlcat${EXT} have_strlcat.o unused_tmp + ${H} echo '$@ formed' -@if [ -z "${Q}" ]; then \ echo ''; \ echo '=-=-= start of $@ =-=-='; \ @@ -3682,7 +3962,7 @@ have_unused.h: have_unused.c ${MAKE_FILE} ### win32_hsrc: win32.mkdef ${MAKE_FILE} - ${Q} echo 'forming win32 directory' + ${H} echo 'forming win32 directory' ${Q} ${RM} -rf win32 ${Q} ${MKDIR} -p win32 ${Q} ${CP} ${UTIL_C_SRC} win32 @@ -3697,27 +3977,7 @@ win32_hsrc: win32.mkdef ${MAKE_FILE} ${RM} -f ${UTIL_PROGS}; \ ${RM} -f ${UTIL_FILES}; \ ${RM} -f ${MAKE_FILE}) - ${Q} echo 'win32 directory formed' - -### -# -# These rules are used in the process of building the BUILD_H_SRC. -# -### - -endian.o: endian.c have_unistd.h - ${LCC} ${ICFLAGS} ${CALC_BYTE_ORDER} endian.c -c - -endian${EXT}: endian.o - ${RM} -f $@ - ${LCC} ${ICFLAGS} endian.o -o $@ - -longbits.o: longbits.c have_unistd.h - ${LCC} ${ICFLAGS} longbits.c -c - -longbits${EXT}: longbits.o - ${RM} -f $@ - ${LCC} ${ICFLAGS} longbits.o -o $@ + ${H} echo 'win32 directory formed' ### # @@ -3841,7 +4101,7 @@ sample_many-static${EXT}: sample_many.o ${CALC_STATIC_LIBS} ${MAKE_FILE} # ### -depend: custom/Makefile hsrc +depend: hsrc custom/Makefile ${Q} if [ -f ${MAKE_FILE}.bak ]; then \ echo "${MAKE_FILE}.bak exists, remove or move it"; \ exit 1; \ @@ -3873,7 +4133,7 @@ depend: custom/Makefile hsrc fi; \ done ${Q} ${RM} -f skel/makedep.out - ${Q} echo skel formed + ${Q} echo top level skel formed ${Q} echo forming dependency list ${Q} :> skel/makedep.out ${Q} cd skel; ${MAKEDEPEND} \ @@ -3893,13 +4153,14 @@ depend: custom/Makefile hsrc ${Q} ${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' \ ${MAKE_FILE}.bak > ${MAKE_FILE} ${Q} ${GREP} -v '^#' skel/makedep.out >> ${MAKE_FILE} + ${Q} echo removing top level skel ${Q} ${RM} -rf skel -${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \ echo 'top level ${MAKE_FILE} was already up to date'; \ echo 'restoring original ${MAKE_FILE}'; \ ${MV} -f ${MAKE_FILE}.bak ${MAKE_FILE}; \ else \ - echo 'previous ${MAKE_FILE} is now ${MAKE_FILE}.bak'; \ + echo 'old ${MAKE_FILE} is now ${MAKE_FILE}.bak'; \ echo 'new top level ${MAKE_FILE} formed'; \ echo 'try: diff -u ${MAKE_FILE}.bak ${MAKE_FILE}'; \ fi @@ -3937,9 +4198,11 @@ calc_version: ver_calc${EXT} version: @echo ${VERSION} -ver_calc${EXT}: version.c have_unused.h +ver_calc${EXT}: version.c strl.c have_string.h have_const.h have_newstr.h \ + have_strlcpy.h have_memmv.h have_strlcat.h endian_calc.h longbits.h \ + have_unused.h ${RM} -f $@ - ${LCC} ${ICFLAGS} -DCALC_VER ${ILDFLAGS} version.c -o $@ + ${LCC} ${ICFLAGS} -DCALC_VER ${ILDFLAGS} version.c strl.c -o $@ ### # @@ -3950,7 +4213,7 @@ ver_calc${EXT}: version.c have_unused.h # ### -distlist: custom/Makefile ${DISTLIST} +distlist: ${DISTLIST} custom/Makefile ${Q} (for i in ${DISTLIST} /dev/null; do \ if [ X"$$i" != X"/dev/null" ]; then \ echo $$i; \ @@ -4139,6 +4402,7 @@ env: @echo 'CATEXT=${CATEXT}'; echo '' @echo 'CATMODE=${CATMODE}'; echo '' @echo 'CC=${CC}'; echo '' + @echo 'CCBAN=${CCBAN}'; echo '' @echo 'CCMISC=${CCMISC}'; echo '' @echo 'CCOPT=${CCOPT}'; echo '' @echo 'CCWARN=${CCWARN}'; echo '' @@ -4166,11 +4430,13 @@ env: @echo 'DEV_BITS=${DEV_BITS}'; echo '' @echo 'DIFF=${DIFF}'; echo '' @echo 'DISTLIST=${DISTLIST}'; echo '' + @echo 'E=${E}'; echo '' @echo 'EXT=${EXT}'; echo '' @echo 'FMT=${FMT}'; echo '' @echo 'FPOS_BITS=${FPOS_BITS}'; echo '' @echo 'FPOS_POS_BITS=${FPOS_POS_BITS}'; echo '' @echo 'GREP=${GREP}'; echo '' + @echo 'H=${H}'; echo '' @echo 'HAVE_CONST=${HAVE_CONST}'; echo '' @echo 'HAVE_FPOS=${HAVE_FPOS}'; echo '' @echo 'HAVE_FPOS_POS=${HAVE_FPOS_POS}'; echo '' @@ -4183,9 +4449,12 @@ env: @echo 'HAVE_NEWSTR=${HAVE_NEWSTR}'; echo '' @echo 'HAVE_OFFSCL=${HAVE_OFFSCL}'; echo '' @echo 'HAVE_POSSCL=${HAVE_POSSCL}'; echo '' + @echo 'HAVE_PRAGMA_GCC_POSION=${HAVE_PRAGMA_GCC_POSION}'; echo '' @echo 'HAVE_STDLIB_H=${HAVE_STDLIB_H}'; echo '' @echo 'HAVE_STRDUP=${HAVE_STRDUP}'; echo '' @echo 'HAVE_STRING_H=${HAVE_STRING_H}'; echo '' + @echo 'HAVE_STRLCAT=${HAVE_STRLCAT}'; echo '' + @echo 'HAVE_STRLCPY=${HAVE_STRLCPY}'; echo '' @echo 'HAVE_SYS_TIMES_H=${HAVE_SYS_TIMES_H}'; echo '' @echo 'HAVE_SYS_TIME_H=${HAVE_SYS_TIME_H}'; echo '' @echo 'HAVE_TIMES_H=${HAVE_TIMES_H}'; echo '' @@ -4208,7 +4477,6 @@ env: @echo 'LCC=${LCC}'; echo '' @echo 'LDCONFIG=${LDCONFIG}'; echo '' @echo 'LDFLAGS=${LDFLAGS}'; echo '' - @echo 'LDFLAGS=${LDFLAGS}'; echo '' @echo 'LD_DEBUG=${LD_DEBUG}'; echo '' @echo 'LD_SHARE=${LD_SHARE}'; echo '' @echo 'LIBCALC_SHLIB=${LIBCALC_SHLIB}'; echo '' @@ -4243,6 +4511,7 @@ env: @echo 'READLINE_LIB=${READLINE_LIB}'; echo '' @echo 'RM=${RM}'; echo '' @echo 'RMDIR=${RMDIR}'; echo '' + @echo 'S=${S}'; echo '' @echo 'SAMPLE_C_SRC=${SAMPLE_C_SRC}'; echo '' @echo 'SAMPLE_H_SRC=${SAMPLE_H_SRC}'; echo '' @echo 'SAMPLE_OBJ=${SAMPLE_OBJ}'; echo '' @@ -4272,6 +4541,9 @@ env: @echo 'UTIL_TMP=${UTIL_TMP}'; echo '' @echo 'V=${V}'; echo '' @echo 'VERSION=${VERSION}'; echo '' + @echo 'WNO_ERROR_LONG_LONG=${WNO_ERROR_LONG_LONG}; echo '' + @echo 'WNO_IMPLICT=${WNO_IMPLICT}; echo '' + @echo 'WNO_LONG_LONG=${WNO_LONG_LONG}; echo '' @echo 'XARGS=${XARGS}'; echo '' @echo 'target=${target}'; echo '' @echo '=-=-=-=-= ${MAKE_FILE} end of major make variable dump =-=-=-=-=' @@ -4351,12 +4623,12 @@ gdb: rpm: clobber rpm-preclean rpm.mk calc.spec.in ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' - ${MAKE} -f rpm.mk all V=${V} RPM_TOP="${RPM_TOP}" + ${MAKE} -f rpm.mk all V=${V} RPM_TOP="${RPM_TOP}" Q= S= E= ${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-=' rpm-preclean: ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' - ${MAKE} -f rpm.mk $@ V=${V} RPM_TOP="${RPM_TOP}" + ${MAKE} -f rpm.mk $@ V=${V} RPM_TOP="${RPM_TOP}" Q= S= E= ${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-=' # rpm static rules @@ -4398,8 +4670,8 @@ rpm-clean-static: # Form the installed file list # -inst_files: ${MAKE_FILE} help/Makefile cal/Makefile custom/Makefile \ - cscript/Makefile ver_calc${EXT} +inst_files: ${MAKE_FILE} help/Makefile cal/Makefile \ + cscript/Makefile ver_calc${EXT} custom/Makefile ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' ${Q} ${RM} -f inst_files ${Q} echo ${BINDIR}/calc${EXT} > inst_files @@ -4491,7 +4763,7 @@ clean: custom/Makefile ${RM} -f win32dll.h have_malloc.h math_error.h string.h string.c ${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-=' -clobber: custom/Makefile clean +clobber: clean custom/Makefile ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' ${RM} -f ${SAMPLE_TARGETS} ${RM} -f ${SAMPLE_STATIC_TARGETS} @@ -4507,7 +4779,8 @@ clobber: custom/Makefile clean ${RM} -f libcustcalc.a ${RM} -f calc.1 calc.usage ${RM} -f calc.pixie calc.rf calc.Counts calc.cord - ${RM} -rf gen_h skel Makefile.bak tmp.patch + ${RM} -f gen_h Makefile.bak tmp.patch + ${RM} -rf skel ${RM} -f calc.spec inst_files rpm.mk.patch tmp ${RM} -f libcalc${LIB_EXT_VERSION} ${RM} -f libcalc* @@ -4515,6 +4788,7 @@ clobber: custom/Makefile clean ${RM} -f libcustcalc* ${RM} -f calc-static${EXT} ${RM} -f ${CALC_STATIC_LIBS} + ${RM} -f a.out ${RM} -f all ${V} echo '=-=-=-=-= Invoking $@ rule for help =-=-=-=-=' -cd help; ${RM} -f all; ${MAKE} -f Makefile ${HELP_PASSDOWN} $@ @@ -4548,7 +4822,7 @@ clobber: custom/Makefile clean # # NOTE: Keep the uninstall rule in the reverse order of the install rule # -install: custom/Makefile ${LIB_H_SRC} ${BUILD_H_SRC} calc.1 all +install: ${LIB_H_SRC} ${BUILD_H_SRC} calc.1 all custom/Makefile ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' -${Q} if [ ! -z "${T}" ]; then \ if [ ! -d ${T} ]; then \ @@ -5080,6 +5354,7 @@ calc-unsymlink: addop.o: addop.c addop.o: alloc.h +addop.o: banned.h addop.o: block.h addop.o: byteswap.h addop.o: calc.h @@ -5090,6 +5365,7 @@ addop.o: decl.h addop.o: endian_calc.h addop.o: func.h addop.o: hash.h +addop.o: have_ban_pragma.h addop.o: have_const.h addop.o: have_memmv.h addop.o: have_newstr.h @@ -5107,10 +5383,13 @@ addop.o: token.h addop.o: value.h addop.o: zmath.h align32.o: align32.c +align32.o: banned.h +align32.o: have_ban_pragma.h align32.o: have_unistd.h align32.o: longbits.h assocfunc.o: alloc.h assocfunc.o: assocfunc.c +assocfunc.o: banned.h assocfunc.o: block.h assocfunc.o: byteswap.h assocfunc.o: calcerr.h @@ -5119,6 +5398,7 @@ assocfunc.o: config.h assocfunc.o: decl.h assocfunc.o: endian_calc.h assocfunc.o: hash.h +assocfunc.o: have_ban_pragma.h assocfunc.o: have_const.h assocfunc.o: have_memmv.h assocfunc.o: have_newstr.h @@ -5132,6 +5412,7 @@ assocfunc.o: str.h assocfunc.o: value.h assocfunc.o: zmath.h blkcpy.o: alloc.h +blkcpy.o: banned.h blkcpy.o: blkcpy.c blkcpy.o: blkcpy.h blkcpy.o: block.h @@ -5144,6 +5425,7 @@ blkcpy.o: decl.h blkcpy.o: endian_calc.h blkcpy.o: file.h blkcpy.o: hash.h +blkcpy.o: have_ban_pragma.h blkcpy.o: have_const.h blkcpy.o: have_fpos.h blkcpy.o: have_memmv.h @@ -5158,6 +5440,7 @@ blkcpy.o: str.h blkcpy.o: value.h blkcpy.o: zmath.h block.o: alloc.h +block.o: banned.h block.o: block.c block.o: block.h block.o: byteswap.h @@ -5167,6 +5450,7 @@ block.o: config.h block.o: decl.h block.o: endian_calc.h block.o: hash.h +block.o: have_ban_pragma.h block.o: have_const.h block.o: have_memmv.h block.o: have_newstr.h @@ -5180,11 +5464,13 @@ block.o: str.h block.o: value.h block.o: zmath.h byteswap.o: alloc.h +byteswap.o: banned.h byteswap.o: byteswap.c byteswap.o: byteswap.h byteswap.o: cmath.h byteswap.o: decl.h byteswap.o: endian_calc.h +byteswap.o: have_ban_pragma.h byteswap.o: have_const.h byteswap.o: have_memmv.h byteswap.o: have_newstr.h @@ -5195,6 +5481,7 @@ byteswap.o: qmath.h byteswap.o: zmath.h calc.o: alloc.h calc.o: args.h +calc.o: banned.h calc.o: block.h calc.o: byteswap.h calc.o: calc.c @@ -5208,12 +5495,15 @@ calc.o: decl.h calc.o: endian_calc.h calc.o: func.h calc.o: hash.h +calc.o: have_ban_pragma.h calc.o: have_const.h calc.o: have_memmv.h calc.o: have_newstr.h calc.o: have_stdlib.h calc.o: have_strdup.h calc.o: have_string.h +calc.o: have_strlcat.h +calc.o: have_strlcpy.h calc.o: have_uid_t.h calc.o: have_unistd.h calc.o: have_unused.h @@ -5226,14 +5516,18 @@ calc.o: opcodes.h calc.o: qmath.h calc.o: sha1.h calc.o: str.h +calc.o: strl.h calc.o: symbol.h calc.o: token.h calc.o: value.h calc.o: zmath.h +calcerr.o: banned.h calcerr.o: calcerr.c calcerr.o: calcerr.h +calcerr.o: have_ban_pragma.h calcerr.o: have_const.h codegen.o: alloc.h +codegen.o: banned.h codegen.o: block.h codegen.o: byteswap.h codegen.o: calc.h @@ -5246,11 +5540,14 @@ codegen.o: decl.h codegen.o: endian_calc.h codegen.o: func.h codegen.o: hash.h +codegen.o: have_ban_pragma.h codegen.o: have_const.h codegen.o: have_memmv.h codegen.o: have_newstr.h codegen.o: have_stdlib.h codegen.o: have_string.h +codegen.o: have_strlcat.h +codegen.o: have_strlcpy.h codegen.o: have_unistd.h codegen.o: label.h codegen.o: lib_calc.h @@ -5260,17 +5557,20 @@ codegen.o: opcodes.h codegen.o: qmath.h codegen.o: sha1.h codegen.o: str.h +codegen.o: strl.h codegen.o: symbol.h codegen.o: token.h codegen.o: value.h codegen.o: zmath.h comfunc.o: alloc.h +comfunc.o: banned.h comfunc.o: byteswap.h comfunc.o: cmath.h comfunc.o: comfunc.c comfunc.o: config.h comfunc.o: decl.h comfunc.o: endian_calc.h +comfunc.o: have_ban_pragma.h comfunc.o: have_const.h comfunc.o: have_memmv.h comfunc.o: have_newstr.h @@ -5281,11 +5581,13 @@ comfunc.o: nametype.h comfunc.o: qmath.h comfunc.o: zmath.h commath.o: alloc.h +commath.o: banned.h commath.o: byteswap.h commath.o: cmath.h commath.o: commath.c commath.o: decl.h commath.o: endian_calc.h +commath.o: have_ban_pragma.h commath.o: have_const.h commath.o: have_memmv.h commath.o: have_newstr.h @@ -5295,6 +5597,7 @@ commath.o: longbits.h commath.o: qmath.h commath.o: zmath.h config.o: alloc.h +config.o: banned.h config.o: block.h config.o: byteswap.h config.o: calc.h @@ -5306,23 +5609,28 @@ config.o: custom.h config.o: decl.h config.o: endian_calc.h config.o: hash.h +config.o: have_ban_pragma.h config.o: have_const.h config.o: have_memmv.h config.o: have_newstr.h config.o: have_stdlib.h config.o: have_strdup.h config.o: have_string.h +config.o: have_strlcat.h +config.o: have_strlcpy.h config.o: have_times.h config.o: longbits.h config.o: nametype.h config.o: qmath.h config.o: sha1.h config.o: str.h +config.o: strl.h config.o: token.h config.o: value.h config.o: zmath.h config.o: zrand.h const.o: alloc.h +const.o: banned.h const.o: block.h const.o: byteswap.h const.o: calc.h @@ -5333,6 +5641,7 @@ const.o: const.c const.o: decl.h const.o: endian_calc.h const.o: hash.h +const.o: have_ban_pragma.h const.o: have_const.h const.o: have_memmv.h const.o: have_newstr.h @@ -5346,6 +5655,7 @@ const.o: str.h const.o: value.h const.o: zmath.h custom.o: alloc.h +custom.o: banned.h custom.o: block.h custom.o: byteswap.h custom.o: calc.h @@ -5357,6 +5667,7 @@ custom.o: custom.h custom.o: decl.h custom.o: endian_calc.h custom.o: hash.h +custom.o: have_ban_pragma.h custom.o: have_const.h custom.o: have_memmv.h custom.o: have_newstr.h @@ -5369,10 +5680,13 @@ custom.o: sha1.h custom.o: str.h custom.o: value.h custom.o: zmath.h +endian.o: banned.h endian.o: endian.c +endian.o: have_ban_pragma.h endian.o: have_stdlib.h endian.o: have_unistd.h file.o: alloc.h +file.o: banned.h file.o: block.h file.o: byteswap.h file.o: calc.h @@ -5385,6 +5699,7 @@ file.o: file.c file.o: file.h file.o: fposval.h file.o: hash.h +file.o: have_ban_pragma.h file.o: have_const.h file.o: have_fpos.h file.o: have_fpos_pos.h @@ -5392,21 +5707,31 @@ file.o: have_memmv.h file.o: have_newstr.h file.o: have_stdlib.h file.o: have_string.h +file.o: have_strlcat.h +file.o: have_strlcpy.h file.o: have_unistd.h file.o: longbits.h file.o: nametype.h file.o: qmath.h file.o: sha1.h file.o: str.h +file.o: strl.h file.o: value.h file.o: zmath.h +fposval.o: alloc.h +fposval.o: banned.h fposval.o: endian_calc.h fposval.o: fposval.c +fposval.o: have_ban_pragma.h fposval.o: have_fpos.h fposval.o: have_fpos_pos.h +fposval.o: have_memmv.h +fposval.o: have_newstr.h fposval.o: have_offscl.h fposval.o: have_posscl.h +fposval.o: have_string.h func.o: alloc.h +func.o: banned.h func.o: block.h func.o: byteswap.h func.o: calc.h @@ -5420,6 +5745,7 @@ func.o: file.h func.o: func.c func.o: func.h func.o: hash.h +func.o: have_ban_pragma.h func.o: have_const.h func.o: have_fpos.h func.o: have_memmv.h @@ -5428,6 +5754,8 @@ func.o: have_rusage.h func.o: have_stdlib.h func.o: have_strdup.h func.o: have_string.h +func.o: have_strlcat.h +func.o: have_strlcpy.h func.o: have_times.h func.o: have_unistd.h func.o: have_unused.h @@ -5439,6 +5767,7 @@ func.o: prime.h func.o: qmath.h func.o: sha1.h func.o: str.h +func.o: strl.h func.o: symbol.h func.o: token.h func.o: value.h @@ -5446,6 +5775,7 @@ func.o: zmath.h func.o: zrand.h func.o: zrandom.h hash.o: alloc.h +hash.o: banned.h hash.o: block.h hash.o: byteswap.h hash.o: calc.h @@ -5456,6 +5786,7 @@ hash.o: decl.h hash.o: endian_calc.h hash.o: hash.c hash.o: hash.h +hash.o: have_ban_pragma.h hash.o: have_const.h hash.o: have_memmv.h hash.o: have_newstr.h @@ -5470,39 +5801,90 @@ hash.o: value.h hash.o: zmath.h hash.o: zrand.h hash.o: zrandom.h +have_ban_pragma.o: banned.h +have_ban_pragma.o: have_ban_pragma.c +have_ban_pragma.o: have_ban_pragma.h +have_const.o: banned.h +have_const.o: have_ban_pragma.h have_const.o: have_const.c +have_fpos.o: banned.h +have_fpos.o: have_ban_pragma.h have_fpos.o: have_fpos.c +have_fpos_pos.o: banned.h +have_fpos_pos.o: have_ban_pragma.h have_fpos_pos.o: have_fpos.h have_fpos_pos.o: have_fpos_pos.c have_fpos_pos.o: have_posscl.h +have_getpgid.o: banned.h +have_getpgid.o: have_ban_pragma.h have_getpgid.o: have_getpgid.c have_getpgid.o: have_unistd.h +have_getprid.o: banned.h +have_getprid.o: have_ban_pragma.h have_getprid.o: have_getprid.c have_getprid.o: have_unistd.h +have_getsid.o: banned.h +have_getsid.o: have_ban_pragma.h have_getsid.o: have_getsid.c have_getsid.o: have_unistd.h +have_gettime.o: banned.h +have_gettime.o: have_ban_pragma.h have_gettime.o: have_gettime.c +have_memmv.o: banned.h +have_memmv.o: have_ban_pragma.h have_memmv.o: have_memmv.c +have_memmv.o: have_string.h +have_newstr.o: banned.h +have_newstr.o: have_ban_pragma.h have_newstr.o: have_newstr.c +have_newstr.o: have_string.h +have_offscl.o: banned.h +have_offscl.o: have_ban_pragma.h have_offscl.o: have_offscl.c have_offscl.o: have_unistd.h +have_posscl.o: banned.h +have_posscl.o: have_ban_pragma.h have_posscl.o: have_fpos.h have_posscl.o: have_posscl.c have_posscl.o: have_unistd.h +have_rusage.o: banned.h +have_rusage.o: have_ban_pragma.h have_rusage.o: have_rusage.c +have_stdvs.o: banned.h +have_stdvs.o: have_ban_pragma.h have_stdvs.o: have_stdlib.h have_stdvs.o: have_stdvs.c have_stdvs.o: have_string.h have_stdvs.o: have_unistd.h +have_strdup.o: banned.h +have_strdup.o: have_ban_pragma.h have_strdup.o: have_strdup.c +have_strdup.o: have_string.h +have_strlcat.o: banned.h +have_strlcat.o: have_ban_pragma.h +have_strlcat.o: have_string.h +have_strlcat.o: have_strlcat.c +have_strlcpy.o: banned.h +have_strlcpy.o: have_ban_pragma.h +have_strlcpy.o: have_string.h +have_strlcpy.o: have_strlcpy.c +have_uid_t.o: banned.h +have_uid_t.o: have_ban_pragma.h have_uid_t.o: have_uid_t.c have_uid_t.o: have_unistd.h +have_unused.o: banned.h +have_unused.o: have_ban_pragma.h have_unused.o: have_unused.c +have_ustat.o: banned.h +have_ustat.o: have_ban_pragma.h have_ustat.o: have_ustat.c +have_varvs.o: banned.h +have_varvs.o: have_ban_pragma.h have_varvs.o: have_string.h have_varvs.o: have_unistd.h have_varvs.o: have_varvs.c help.o: alloc.h +help.o: banned.h help.o: block.h help.o: byteswap.h help.o: calc.h @@ -5513,6 +5895,7 @@ help.o: config.h help.o: decl.h help.o: endian_calc.h help.o: hash.h +help.o: have_ban_pragma.h help.o: have_const.h help.o: have_memmv.h help.o: have_newstr.h @@ -5529,6 +5912,7 @@ help.o: str.h help.o: value.h help.o: zmath.h hist.o: alloc.h +hist.o: banned.h hist.o: block.h hist.o: byteswap.h hist.o: calc.h @@ -5538,12 +5922,15 @@ hist.o: config.h hist.o: decl.h hist.o: endian_calc.h hist.o: hash.h +hist.o: have_ban_pragma.h hist.o: have_const.h hist.o: have_memmv.h hist.o: have_newstr.h hist.o: have_stdlib.h hist.o: have_strdup.h hist.o: have_string.h +hist.o: have_strlcat.h +hist.o: have_strlcpy.h hist.o: have_unistd.h hist.o: have_unused.h hist.o: hist.c @@ -5554,9 +5941,11 @@ hist.o: nametype.h hist.o: qmath.h hist.o: sha1.h hist.o: str.h +hist.o: strl.h hist.o: value.h hist.o: zmath.h input.o: alloc.h +input.o: banned.h input.o: block.h input.o: byteswap.h input.o: calc.h @@ -5567,11 +5956,14 @@ input.o: config.h input.o: decl.h input.o: endian_calc.h input.o: hash.h +input.o: have_ban_pragma.h input.o: have_const.h input.o: have_memmv.h input.o: have_newstr.h input.o: have_stdlib.h input.o: have_string.h +input.o: have_strlcat.h +input.o: have_strlcpy.h input.o: have_unistd.h input.o: hist.h input.o: input.c @@ -5580,13 +5972,17 @@ input.o: nametype.h input.o: qmath.h input.o: sha1.h input.o: str.h +input.o: strl.h input.o: value.h input.o: zmath.h +jump.o: banned.h jump.o: decl.h +jump.o: have_ban_pragma.h jump.o: have_const.h jump.o: jump.c jump.o: jump.h label.o: alloc.h +label.o: banned.h label.o: block.h label.o: byteswap.h label.o: calc.h @@ -5597,6 +5993,7 @@ label.o: decl.h label.o: endian_calc.h label.o: func.h label.o: hash.h +label.o: have_ban_pragma.h label.o: have_const.h label.o: have_memmv.h label.o: have_newstr.h @@ -5614,6 +6011,7 @@ label.o: token.h label.o: value.h label.o: zmath.h lib_calc.o: alloc.h +lib_calc.o: banned.h lib_calc.o: block.h lib_calc.o: byteswap.h lib_calc.o: calc.h @@ -5626,12 +6024,15 @@ lib_calc.o: decl.h lib_calc.o: endian_calc.h lib_calc.o: func.h lib_calc.o: hash.h +lib_calc.o: have_ban_pragma.h lib_calc.o: have_const.h lib_calc.o: have_memmv.h lib_calc.o: have_newstr.h lib_calc.o: have_stdlib.h lib_calc.o: have_strdup.h lib_calc.o: have_string.h +lib_calc.o: have_strlcat.h +lib_calc.o: have_strlcpy.h lib_calc.o: have_unistd.h lib_calc.o: label.h lib_calc.o: lib_calc.c @@ -5641,6 +6042,7 @@ lib_calc.o: nametype.h lib_calc.o: qmath.h lib_calc.o: sha1.h lib_calc.o: str.h +lib_calc.o: strl.h lib_calc.o: symbol.h lib_calc.o: terminal.h lib_calc.o: token.h @@ -5648,9 +6050,11 @@ lib_calc.o: value.h lib_calc.o: zmath.h lib_calc.o: zrandom.h lib_util.o: alloc.h +lib_util.o: banned.h lib_util.o: byteswap.h lib_util.o: decl.h lib_util.o: endian_calc.h +lib_util.o: have_ban_pragma.h lib_util.o: have_const.h lib_util.o: have_memmv.h lib_util.o: have_newstr.h @@ -5661,6 +6065,7 @@ lib_util.o: lib_util.h lib_util.o: longbits.h lib_util.o: zmath.h listfunc.o: alloc.h +listfunc.o: banned.h listfunc.o: block.h listfunc.o: byteswap.h listfunc.o: calcerr.h @@ -5669,6 +6074,7 @@ listfunc.o: config.h listfunc.o: decl.h listfunc.o: endian_calc.h listfunc.o: hash.h +listfunc.o: have_ban_pragma.h listfunc.o: have_const.h listfunc.o: have_memmv.h listfunc.o: have_newstr.h @@ -5683,10 +6089,13 @@ listfunc.o: str.h listfunc.o: value.h listfunc.o: zmath.h listfunc.o: zrand.h +longbits.o: banned.h +longbits.o: have_ban_pragma.h longbits.o: have_stdlib.h longbits.o: have_unistd.h longbits.o: longbits.c matfunc.o: alloc.h +matfunc.o: banned.h matfunc.o: block.h matfunc.o: byteswap.h matfunc.o: calcerr.h @@ -5695,6 +6104,7 @@ matfunc.o: config.h matfunc.o: decl.h matfunc.o: endian_calc.h matfunc.o: hash.h +matfunc.o: have_ban_pragma.h matfunc.o: have_const.h matfunc.o: have_memmv.h matfunc.o: have_newstr.h @@ -5712,6 +6122,7 @@ matfunc.o: zmath.h matfunc.o: zrand.h math_error.o: alloc.h math_error.o: args.h +math_error.o: banned.h math_error.o: block.h math_error.o: byteswap.h math_error.o: calc.h @@ -5721,6 +6132,7 @@ math_error.o: config.h math_error.o: decl.h math_error.o: endian_calc.h math_error.o: hash.h +math_error.o: have_ban_pragma.h math_error.o: have_const.h math_error.o: have_memmv.h math_error.o: have_newstr.h @@ -5736,6 +6148,7 @@ math_error.o: str.h math_error.o: value.h math_error.o: zmath.h obj.o: alloc.h +obj.o: banned.h obj.o: block.h obj.o: byteswap.h obj.o: calc.h @@ -5746,11 +6159,14 @@ obj.o: decl.h obj.o: endian_calc.h obj.o: func.h obj.o: hash.h +obj.o: have_ban_pragma.h obj.o: have_const.h obj.o: have_memmv.h obj.o: have_newstr.h obj.o: have_stdlib.h obj.o: have_string.h +obj.o: have_strlcat.h +obj.o: have_strlcpy.h obj.o: label.h obj.o: longbits.h obj.o: nametype.h @@ -5759,10 +6175,12 @@ obj.o: opcodes.h obj.o: qmath.h obj.o: sha1.h obj.o: str.h +obj.o: strl.h obj.o: symbol.h obj.o: value.h obj.o: zmath.h opcodes.o: alloc.h +opcodes.o: banned.h opcodes.o: block.h opcodes.o: byteswap.h opcodes.o: calc.h @@ -5775,6 +6193,7 @@ opcodes.o: endian_calc.h opcodes.o: file.h opcodes.o: func.h opcodes.o: hash.h +opcodes.o: have_ban_pragma.h opcodes.o: have_const.h opcodes.o: have_fpos.h opcodes.o: have_memmv.h @@ -5798,9 +6217,11 @@ opcodes.o: zmath.h opcodes.o: zrand.h opcodes.o: zrandom.h pix.o: alloc.h +pix.o: banned.h pix.o: byteswap.h pix.o: decl.h pix.o: endian_calc.h +pix.o: have_ban_pragma.h pix.o: have_const.h pix.o: have_memmv.h pix.o: have_newstr.h @@ -5812,6 +6233,7 @@ pix.o: prime.h pix.o: qmath.h pix.o: zmath.h poly.o: alloc.h +poly.o: banned.h poly.o: block.h poly.o: byteswap.h poly.o: calcerr.h @@ -5820,6 +6242,7 @@ poly.o: config.h poly.o: decl.h poly.o: endian_calc.h poly.o: hash.h +poly.o: have_ban_pragma.h poly.o: have_const.h poly.o: have_memmv.h poly.o: have_newstr.h @@ -5834,9 +6257,11 @@ poly.o: str.h poly.o: value.h poly.o: zmath.h prime.o: alloc.h +prime.o: banned.h prime.o: byteswap.h prime.o: decl.h prime.o: endian_calc.h +prime.o: have_ban_pragma.h prime.o: have_const.h prime.o: have_memmv.h prime.o: have_newstr.h @@ -5849,10 +6274,12 @@ prime.o: prime.h prime.o: qmath.h prime.o: zmath.h qfunc.o: alloc.h +qfunc.o: banned.h qfunc.o: byteswap.h qfunc.o: config.h qfunc.o: decl.h qfunc.o: endian_calc.h +qfunc.o: have_ban_pragma.h qfunc.o: have_const.h qfunc.o: have_memmv.h qfunc.o: have_newstr.h @@ -5866,10 +6293,12 @@ qfunc.o: qmath.h qfunc.o: zmath.h qio.o: alloc.h qio.o: args.h +qio.o: banned.h qio.o: byteswap.h qio.o: config.h qio.o: decl.h qio.o: endian_calc.h +qio.o: have_ban_pragma.h qio.o: have_const.h qio.o: have_memmv.h qio.o: have_newstr.h @@ -5882,10 +6311,12 @@ qio.o: qio.c qio.o: qmath.h qio.o: zmath.h qmath.o: alloc.h +qmath.o: banned.h qmath.o: byteswap.h qmath.o: config.h qmath.o: decl.h qmath.o: endian_calc.h +qmath.o: have_ban_pragma.h qmath.o: have_const.h qmath.o: have_memmv.h qmath.o: have_newstr.h @@ -5897,10 +6328,12 @@ qmath.o: qmath.c qmath.o: qmath.h qmath.o: zmath.h qmod.o: alloc.h +qmod.o: banned.h qmod.o: byteswap.h qmod.o: config.h qmod.o: decl.h qmod.o: endian_calc.h +qmod.o: have_ban_pragma.h qmod.o: have_const.h qmod.o: have_memmv.h qmod.o: have_newstr.h @@ -5912,9 +6345,11 @@ qmod.o: qmath.h qmod.o: qmod.c qmod.o: zmath.h qtrans.o: alloc.h +qtrans.o: banned.h qtrans.o: byteswap.h qtrans.o: decl.h qtrans.o: endian_calc.h +qtrans.o: have_ban_pragma.h qtrans.o: have_const.h qtrans.o: have_memmv.h qtrans.o: have_newstr.h @@ -5925,6 +6360,7 @@ qtrans.o: qmath.h qtrans.o: qtrans.c qtrans.o: zmath.h quickhash.o: alloc.h +quickhash.o: banned.h quickhash.o: block.h quickhash.o: byteswap.h quickhash.o: calcerr.h @@ -5933,6 +6369,7 @@ quickhash.o: config.h quickhash.o: decl.h quickhash.o: endian_calc.h quickhash.o: hash.h +quickhash.o: have_ban_pragma.h quickhash.o: have_const.h quickhash.o: have_memmv.h quickhash.o: have_newstr.h @@ -5949,6 +6386,7 @@ quickhash.o: zmath.h quickhash.o: zrand.h quickhash.o: zrandom.h sample_many.o: alloc.h +sample_many.o: banned.h sample_many.o: block.h sample_many.o: byteswap.h sample_many.o: calc.h @@ -5958,6 +6396,7 @@ sample_many.o: config.h sample_many.o: decl.h sample_many.o: endian_calc.h sample_many.o: hash.h +sample_many.o: have_ban_pragma.h sample_many.o: have_const.h sample_many.o: have_memmv.h sample_many.o: have_newstr.h @@ -5974,6 +6413,7 @@ sample_many.o: value.h sample_many.o: zmath.h sample_many.o: zrandom.h sample_rand.o: alloc.h +sample_rand.o: banned.h sample_rand.o: block.h sample_rand.o: byteswap.h sample_rand.o: calc.h @@ -5983,6 +6423,7 @@ sample_rand.o: config.h sample_rand.o: decl.h sample_rand.o: endian_calc.h sample_rand.o: hash.h +sample_rand.o: have_ban_pragma.h sample_rand.o: have_const.h sample_rand.o: have_memmv.h sample_rand.o: have_newstr.h @@ -5999,9 +6440,11 @@ sample_rand.o: value.h sample_rand.o: zmath.h sample_rand.o: zrandom.h seed.o: alloc.h +seed.o: banned.h seed.o: byteswap.h seed.o: decl.h seed.o: endian_calc.h +seed.o: have_ban_pragma.h seed.o: have_const.h seed.o: have_getpgid.h seed.o: have_getprid.h @@ -6023,6 +6466,7 @@ seed.o: seed.c seed.o: zmath.h sha1.o: align32.h sha1.o: alloc.h +sha1.o: banned.h sha1.o: block.h sha1.o: byteswap.h sha1.o: calcerr.h @@ -6031,6 +6475,7 @@ sha1.o: config.h sha1.o: decl.h sha1.o: endian_calc.h sha1.o: hash.h +sha1.o: have_ban_pragma.h sha1.o: have_const.h sha1.o: have_memmv.h sha1.o: have_newstr.h @@ -6045,6 +6490,7 @@ sha1.o: str.h sha1.o: value.h sha1.o: zmath.h size.o: alloc.h +size.o: banned.h size.o: block.h size.o: byteswap.h size.o: calcerr.h @@ -6053,6 +6499,7 @@ size.o: config.h size.o: decl.h size.o: endian_calc.h size.o: hash.h +size.o: have_ban_pragma.h size.o: have_const.h size.o: have_memmv.h size.o: have_newstr.h @@ -6069,6 +6516,7 @@ size.o: zmath.h size.o: zrand.h size.o: zrandom.h str.o: alloc.h +str.o: banned.h str.o: block.h str.o: byteswap.h str.o: calc.h @@ -6078,20 +6526,37 @@ str.o: config.h str.o: decl.h str.o: endian_calc.h str.o: hash.h +str.o: have_ban_pragma.h str.o: have_const.h str.o: have_memmv.h str.o: have_newstr.h str.o: have_stdlib.h str.o: have_string.h +str.o: have_strlcat.h +str.o: have_strlcpy.h str.o: longbits.h str.o: nametype.h str.o: qmath.h str.o: sha1.h str.o: str.c str.o: str.h +str.o: strl.h str.o: value.h str.o: zmath.h +strl.o: alloc.h +strl.o: banned.h +strl.o: decl.h +strl.o: have_ban_pragma.h +strl.o: have_const.h +strl.o: have_memmv.h +strl.o: have_newstr.h +strl.o: have_string.h +strl.o: have_strlcat.h +strl.o: have_strlcpy.h +strl.o: strl.c +strl.o: strl.h symbol.o: alloc.h +symbol.o: banned.h symbol.o: block.h symbol.o: byteswap.h symbol.o: calc.h @@ -6102,6 +6567,7 @@ symbol.o: decl.h symbol.o: endian_calc.h symbol.o: func.h symbol.o: hash.h +symbol.o: have_ban_pragma.h symbol.o: have_const.h symbol.o: have_memmv.h symbol.o: have_newstr.h @@ -6121,6 +6587,7 @@ symbol.o: value.h symbol.o: zmath.h token.o: alloc.h token.o: args.h +token.o: banned.h token.o: block.h token.o: byteswap.h token.o: calc.h @@ -6130,6 +6597,7 @@ token.o: config.h token.o: decl.h token.o: endian_calc.h token.o: hash.h +token.o: have_ban_pragma.h token.o: have_const.h token.o: have_memmv.h token.o: have_newstr.h @@ -6146,6 +6614,7 @@ token.o: token.h token.o: value.h token.o: zmath.h value.o: alloc.h +value.o: banned.h value.o: block.h value.o: byteswap.h value.o: calc.h @@ -6157,6 +6626,7 @@ value.o: endian_calc.h value.o: file.h value.o: func.h value.o: hash.h +value.o: have_ban_pragma.h value.o: have_const.h value.o: have_fpos.h value.o: have_memmv.h @@ -6177,6 +6647,7 @@ value.o: zmath.h value.o: zrand.h value.o: zrandom.h version.o: alloc.h +version.o: banned.h version.o: block.h version.o: byteswap.h version.o: calc.h @@ -6186,24 +6657,30 @@ version.o: config.h version.o: decl.h version.o: endian_calc.h version.o: hash.h +version.o: have_ban_pragma.h version.o: have_const.h version.o: have_memmv.h version.o: have_newstr.h version.o: have_stdlib.h version.o: have_string.h +version.o: have_strlcat.h +version.o: have_strlcpy.h version.o: have_unused.h version.o: longbits.h version.o: nametype.h version.o: qmath.h version.o: sha1.h version.o: str.h +version.o: strl.h version.o: value.h version.o: version.c version.o: zmath.h zfunc.o: alloc.h +zfunc.o: banned.h zfunc.o: byteswap.h zfunc.o: decl.h zfunc.o: endian_calc.h +zfunc.o: have_ban_pragma.h zfunc.o: have_const.h zfunc.o: have_memmv.h zfunc.o: have_newstr.h @@ -6214,10 +6691,12 @@ zfunc.o: zfunc.c zfunc.o: zmath.h zio.o: alloc.h zio.o: args.h +zio.o: banned.h zio.o: byteswap.h zio.o: config.h zio.o: decl.h zio.o: endian_calc.h +zio.o: have_ban_pragma.h zio.o: have_const.h zio.o: have_memmv.h zio.o: have_newstr.h @@ -6229,9 +6708,11 @@ zio.o: qmath.h zio.o: zio.c zio.o: zmath.h zmath.o: alloc.h +zmath.o: banned.h zmath.o: byteswap.h zmath.o: decl.h zmath.o: endian_calc.h +zmath.o: have_ban_pragma.h zmath.o: have_const.h zmath.o: have_memmv.h zmath.o: have_newstr.h @@ -6241,10 +6722,12 @@ zmath.o: longbits.h zmath.o: zmath.c zmath.o: zmath.h zmod.o: alloc.h +zmod.o: banned.h zmod.o: byteswap.h zmod.o: config.h zmod.o: decl.h zmod.o: endian_calc.h +zmod.o: have_ban_pragma.h zmod.o: have_const.h zmod.o: have_memmv.h zmod.o: have_newstr.h @@ -6256,10 +6739,12 @@ zmod.o: qmath.h zmod.o: zmath.h zmod.o: zmod.c zmul.o: alloc.h +zmul.o: banned.h zmul.o: byteswap.h zmul.o: config.h zmul.o: decl.h zmul.o: endian_calc.h +zmul.o: have_ban_pragma.h zmul.o: have_const.h zmul.o: have_memmv.h zmul.o: have_newstr.h @@ -6271,6 +6756,7 @@ zmul.o: qmath.h zmul.o: zmath.h zmul.o: zmul.c zprime.o: alloc.h +zprime.o: banned.h zprime.o: block.h zprime.o: byteswap.h zprime.o: calcerr.h @@ -6279,6 +6765,7 @@ zprime.o: config.h zprime.o: decl.h zprime.o: endian_calc.h zprime.o: hash.h +zprime.o: have_ban_pragma.h zprime.o: have_const.h zprime.o: have_memmv.h zprime.o: have_newstr.h @@ -6296,6 +6783,7 @@ zprime.o: zmath.h zprime.o: zprime.c zprime.o: zrand.h zrand.o: alloc.h +zrand.o: banned.h zrand.o: block.h zrand.o: byteswap.h zrand.o: calcerr.h @@ -6304,6 +6792,7 @@ zrand.o: config.h zrand.o: decl.h zrand.o: endian_calc.h zrand.o: hash.h +zrand.o: have_ban_pragma.h zrand.o: have_const.h zrand.o: have_memmv.h zrand.o: have_newstr.h @@ -6320,6 +6809,7 @@ zrand.o: zmath.h zrand.o: zrand.c zrand.o: zrand.h zrandom.o: alloc.h +zrandom.o: banned.h zrandom.o: block.h zrandom.o: byteswap.h zrandom.o: calcerr.h @@ -6328,6 +6818,7 @@ zrandom.o: config.h zrandom.o: decl.h zrandom.o: endian_calc.h zrandom.o: hash.h +zrandom.o: have_ban_pragma.h zrandom.o: have_const.h zrandom.o: have_memmv.h zrandom.o: have_newstr.h diff --git a/addop.c b/addop.c index 5bd999a..7255142 100644 --- a/addop.c +++ b/addop.c @@ -1,7 +1,7 @@ /* * addop - add opcodes to a function being compiled * - * Copyright (C) 1999-2007 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -28,6 +28,7 @@ #include #include "calc.h" +#include "alloc.h" #include "opcodes.h" #include "str.h" #include "func.h" @@ -36,6 +37,9 @@ #include "symbol.h" +#include "banned.h" /* include after system header <> includes */ + + #define FUNCALLOCSIZE 20 /* reallocate size for functions */ #define OPCODEALLOCSIZE 100 /* reallocate size for opcodes in functions */ diff --git a/align32.c b/align32.c index be45aef..d76f609 100644 --- a/align32.c +++ b/align32.c @@ -1,7 +1,7 @@ /* * align32 - determine if 32 bit accesses must be aligned * - * Copyright (C) 1999 Landon Curt Noll + * Copyright (C) 1999,2021 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 @@ -34,6 +34,10 @@ #include #endif + +#include "banned.h" /* include after system header <> includes */ + + static void buserr(void); /* catch alignment errors */ diff --git a/assocfunc.c b/assocfunc.c index f350d11..1ad522f 100644 --- a/assocfunc.c +++ b/assocfunc.c @@ -1,7 +1,7 @@ /* * assocfunc - association table routines * - * Copyright (C) 1999-2007 David I. Bell + * Copyright (C) 1999-2007,2021 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,9 @@ #include "value.h" +#include "banned.h" /* include after system header <> includes */ + + #define MINHASHSIZE 31 /* minimum size of hash tables */ #define GROWHASHSIZE 50 /* approximate growth for hash tables */ #define CHAINLENGTH 10 /* desired number of elements on a hash chain */ diff --git a/banned.h b/banned.h index ca5ce48..ca53c1c 100644 --- a/banned.h +++ b/banned.h @@ -1,7 +1,46 @@ /* - * banned - indicate which functions are banned in calc source + * banned - optionally ban dqngerious functions * - * inspired by https://github.com/git/git/blob/master/banned.h + * Unless UNBAN is defined, this file will turn the use + * of certain dangerous functions into syntax errors. + * + * In the case of calc, we are motivated in part by the desire for + * calc to correctly calculate: even durings extremely long calculations. + * + * If UNBAN is NOT defined, then calling certain functions + * will result in a syntaxc error. + * + * If we define UNBAN, then the effect of this file is disabled. + * + * The banned.h attempts to ban the use of certain dangerous functions + * that, if improperly used, could compromise the computational integrity + * if calculations. + * + * In the case of calc, we are motivated in part by the desire for calc + * to correctly calculate: even durings extremely long calculations. + * + * If UNBAN is NOT defined, then calling certain functions + * will result in a call to a non-existent function (link error). + * + * While we do NOT encourage defining UNBAN, there may be + * a system / compiler environment where re-defining a + * function may lead to a fatal compiler complication. + * If that happens, consider compiling as: + * + * make clobber all chk CCBAN=-DUNBAN + * + * as see if this is a work-a-round. + * + * If YOU discover a need for the -DUNBAN work-a-round, PLEASE tell us! + * Please send us a bug report. See the file: + * + * BUGS + * + * or the URL: + * + * http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html + * + * for how to send us such a bug report. * * Copyright (C) 2021 Landon Curt Noll * @@ -27,56 +66,115 @@ */ +#if !defined(PRE_HAVE_BAN_PRAGMA_H) +#include "have_ban_pragma.h" +#endif /* ! PRE_HAVE_BAN_PRAGMA_H */ + + #if !defined(INCLUDE_BANNED_H) #define INCLUDE_BANNED_H -#include "have_stdlib.h" -#ifdef HAVE_STDLIB_H -# include -#endif +/* + * If we define UNBAN, then the effect of this file is disabled. + */ +#if !defined(UNBAN) /* - * From: //github.com/git/git/blob/master/banned.h + * In the spirit of: * - * This header lists functions that have been banned from our code base, - * because they're too easy to misuse (and even if used correctly, - * complicate audits). Including this header turns them into compile-time - * errors. + * https://github.com/git/git/blob/master/banned.h + * + * we will ban the use of certain unsafe functions by turning + * then into function calls that do not exist. + * + * In the case of calc, we are motivated in part by the desire + * for calc to correctly calculate: even durings extremely long + * calculations. + * + * If UNBAN is NOT defined, then calling certain functions + * will result in a syntaxc error. + * + * Unlike the above URL, we suggest an alternative function. + * In many cases, additional logic is required to use the + * alternative function, we cannot simply replace one function + * with another. */ -#define BANNED(func,better) sorry_##func##_is_a_banned_function_use_##better##_instead - +/* + * If one is not careful, strcpy() can lead to buffer overflows. + * Use strlcpy() instead. + */ +#if defined(HAVE_PRAGMA_GCC_POSION) #undef strcpy -#define strcpy(x,y) BANNED(strcpy,strlcpy) +#pragma GCC poison strcpy +#endif /* HAVE_PRAGMA_GCC_POSION */ + +/* + * If one is not careful, strcat() can lead to buffer overflows. + * Use strlcat() instead. + */ +#if defined(HAVE_PRAGMA_GCC_POSION) #undef strcat -#define strcat(x,y) BANNED(strcat,strlcat) +#pragma GCC poison strcat +#endif /* HAVE_PRAGMA_GCC_POSION */ + +/* + * If one is not careful, strncpy() can lead to buffer overflows. + * Use memccpy() instead. + */ +#if defined(HAVE_PRAGMA_GCC_POSION) #undef strncpy -#define strncpy(x,y,n) BANNED(strncpy,memccpy) +#pragma GCC poison strncpy +#endif /* HAVE_PRAGMA_GCC_POSION */ + +/* + * If one is not careful, strncat() can lead to buffer overflows. + * Use memccpy() instead. + */ +#if defined(HAVE_PRAGMA_GCC_POSION) #undef strncat -#define strncat(x,y,n) BANNED(strncat,memccpy) +#pragma GCC poison strncat +#endif /* HAVE_PRAGMA_GCC_POSION */ -#if defined(STDARG) -#define sprintf(...) BANNED(sprintf,snprintf) -#define vsprintf(...) BANNED(vsprintf,vsnprintf) -#else /* STDARG */ -#define sprintf(buf,fmt,arg) BANNED(sprintf,snprintf) -#define vsprintf(buf,fmt,arg) BANNED(vsprintf,vsnprintf) -#endif /* STDARG */ +/* + * If one is not careful, sprintf() can lead to buffer overflows. + * Use snprintf() instead. + */ +#if defined(HAVE_PRAGMA_GCC_POSION) +#undef sprintf +#pragma GCC poison sprintf +#endif /* HAVE_PRAGMA_GCC_POSION */ -#if 0 /* the XYtimeZZY_s() c11 functions are not yet universal - so do not ban XYtimeZZY() just yet - XXX */ -#undef gmtime -#define gmtime(t) BANNED(gmtime,gmtime_s) -#undef localtime -#define localtime(t) BANNED(localtime,localtime_s) -#undef ctime -#define ctime(t) BANNED(ctime,ctime_s) -#undef ctime_r -#define ctime_r(t, buf) BANNED(ctime_r,ctime_s) -#undef asctime -#define asctime(t) BANNED(asctime,asctime_s) -#undef asctime_r -#define asctime_r(t, buf) BANNED(asctime_r,asctime_s) -#endif /* XXX */ +/* + * If one is not careful, vsprintf() can lead to buffer overflows. + * Use vsnprintf() instead. + */ +#if defined(HAVE_PRAGMA_GCC_POSION) +#undef vsprintf +#pragma GCC poison vsprintf +#endif /* HAVE_PRAGMA_GCC_POSION */ +/* + * XXX - As of 2021, functions such as: + * + * gmtime_s + * localtime_s + * ctime_s + * asctime_s + * + * are not universal. We cannot yet ban the following + * functions because we do not have a portable AND + * widely available alternative. Therefore we just + * have to be extra careful when using: + * + * gmtime + * localtime + * ctime + * ctime_r + * asctime + * asctime_r + */ + +#endif /* !UNBAN */ #endif /* !INCLUDE_BANNED_H */ diff --git a/blkcpy.c b/blkcpy.c index 9fea67f..40d384e 100644 --- a/blkcpy.c +++ b/blkcpy.c @@ -29,12 +29,16 @@ #include #include #include "calc.h" +#include "alloc.h" #include "value.h" #include "file.h" #include "blkcpy.h" #include "str.h" +#include "banned.h" /* include after system header <> includes */ + + /* * copystod - copy num indexed items from source value to destination value * diff --git a/block.c b/block.c index dfbde07..75e4a34 100644 --- a/block.c +++ b/block.c @@ -28,6 +28,11 @@ #include +#include "have_string.h" +#ifdef HAVE_STRING_H +# include +#endif +#include "alloc.h" #include "value.h" #include "zmath.h" #include "config.h" @@ -36,6 +41,10 @@ #include "str.h" #include "calcerr.h" + +#include "banned.h" /* include after system header <> includes */ + + #define NBLOCKCHUNK 16 STATIC long nblockcount = 0; diff --git a/byteswap.c b/byteswap.c index 2f51983..e215485 100644 --- a/byteswap.c +++ b/byteswap.c @@ -29,6 +29,9 @@ #include "byteswap.h" +#include "banned.h" /* include after system header <> includes */ + + /* * swap_b8_in_HALFs - swap 8 and if needed, 16 bits in an array of HALFs * diff --git a/cal/Makefile b/cal/Makefile index a09e6ff..a8da990 100644 --- a/cal/Makefile +++ b/cal/Makefile @@ -28,9 +28,27 @@ # Makefile by Landon Curt Noll -# our shell +# The shell used by this Makefile +# +# On some systems, /bin/sh is a rather reduced shell with +# deprecated behavor. +# +# If your system has a up to date, bash shell, then +# you may wish to use: +# +# SHELL= /bin/bash +# +# On some systems such as macOS, the bash shell is very +# far behind to the point wehre is cannot be depended on. +# On such systems, the zsh may be a much better alternative +# shell for this Makefile to use: +# +# SHELL= /bin/zsh # SHELL= /bin/sh +#SHELL= /bin/bash +#SHELL= /bin/zsh + #### # Normally, the upper level makefile will set these values. We provide diff --git a/calc.c b/calc.c index b5bbb13..d52efb3 100644 --- a/calc.c +++ b/calc.c @@ -26,7 +26,6 @@ * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ */ - #include #include @@ -66,6 +65,7 @@ #include "lib_calc.h" #include "args.h" #include "zmath.h" +#include "strl.h" #include "have_unistd.h" #if defined(HAVE_UNISTD_H) @@ -85,6 +85,9 @@ #include "have_unused.h" +#include "banned.h" /* include after system header <> includes */ + + /* * S_FUNC definitions and functions */ @@ -373,14 +376,20 @@ main(int argc, char **argv) havearg = TRUE; if (cmdlen > 0) cmdbuf[cmdlen++] = ' '; - strcpy(cmdbuf + cmdlen, "read "); - cmdlen += 5; - if (strncmp(cp, "-once", 5) == 0 && - (cp[5] == '\0' || cp[5] == ' ')) { - cp += 5; + strlcpy(cmdbuf + cmdlen, "read ", + sizeof("read ")); + cmdlen += sizeof("read ")-1; + cmdbuf[cmdlen] = '\0'; + if (strncmp(cp, "-once", + sizeof("-once")) == 0 && + (cp[sizeof("-once")-1] == '\0' || + cp[sizeof("-once")-1] == ' ')) { + cp += sizeof("-once")-1; haveendstr = (*cp == '\0'); - strcpy(cmdbuf+cmdlen, "-once "); - cmdlen += 6; + strlcpy(cmdbuf+cmdlen, "-once ", + sizeof("-once ")); + cmdlen += sizeof("-once ")-1; + cmdbuf[cmdlen] = '\0'; if (nextcp(&cp, &index, argc, argv, haveendstr)) { fprintf(stderr, "-f -once" @@ -406,7 +415,7 @@ main(int argc, char **argv) } /* XXX - what if *cp = '\''? */ *bp++ = '\''; - strncpy(bp, cp, len+1); + strlcpy(bp, cp, len+1); bp += len; *bp++ = '\''; cp += len; @@ -428,6 +437,7 @@ main(int argc, char **argv) if (*cp == ';') cp++; *bp++ = ';'; + *bp = '\0'; cmdlen++; s_flag = TRUE; /* -f implies -s */ break; @@ -480,21 +490,7 @@ main(int argc, char **argv) program); exit(21); } - /* - * The next statement could be: - * - * strncpy(cmdbuf + cmdlen, cp, cplen); - * - * however compilers like gcc would issue warnings such as: - * - * specified bound depends on the length of the - * source argument - * - * even though we terminate the string by setting a NUL - * byte following the copy. Therefore we call memcpy() - * instead to avoid such warnings. - */ - memcpy(cmdbuf + cmdlen, cp, cplen); + strlcpy(cmdbuf + cmdlen, cp, cplen+1); cmdbuf[newcmdlen] = '\0'; cmdlen = newcmdlen; index++; @@ -762,7 +758,7 @@ main(int argc, char **argv) */ /*ARGSUSED*/ S_FUNC void -intint(int UNUSED arg) +intint(int UNUSED(arg)) { (void) signal(SIGINT, intint); if (inputwait || (++abortlevel >= ABORT_NOW)) { diff --git a/calcerr_c.awk b/calcerr_c.awk index d1d6761..fbe06f5 100644 --- a/calcerr_c.awk +++ b/calcerr_c.awk @@ -28,6 +28,8 @@ BEGIN { printf("#include \n"); printf("#include \"calcerr.h\"\n\n"); printf("#include \"have_const.h\"\n\n"); + printf("#include \"banned.h\"\t"); + printf("/* include after system header <> includes */\n\n"); printf("/*\n"); printf(" * names of calc error values\n"); printf(" */\n"); diff --git a/codegen.c b/codegen.c index 93f7f68..acb0694 100644 --- a/codegen.c +++ b/codegen.c @@ -34,6 +34,7 @@ #include "lib_calc.h" #include "calc.h" +#include "alloc.h" #include "token.h" #include "symbol.h" #include "label.h" @@ -41,11 +42,16 @@ #include "str.h" #include "func.h" #include "conf.h" +#include "strl.h" #if defined(_WIN32) && !defined(__CYGWIN__) # include #endif + +#include "banned.h" /* include after system header <> includes */ + + STATIC BOOL rdonce; /* TRUE => do not reread this file */ FUNC *curfunc; @@ -144,11 +150,9 @@ getcommands(BOOL toplevel) case 1: case -1: if(i == 1) { - strncpy(name, + strlcpy(name, DEFAULTCALCHELP, - MAXCMD); - /* paranoia */ - name[MAXCMD] = '\0'; + MAXCMD+1); givehelp(name); } break; @@ -2354,8 +2358,7 @@ getfilename(char *name, size_t namelen, BOOL *once) /* use the value of the literal string */ s = findstring(tokenstring()); - strncpy(name, s->s_str, namelen-1); - name[namelen-1] = '\0'; + strlcpy(name, s->s_str, namelen); sfree(s); break; @@ -2392,8 +2395,7 @@ getfilename(char *name, size_t namelen, BOOL *once) } /* return symbol name or value of global var string */ - strncpy(name, symstr, namelen-1); - name[namelen-1] = '\0'; + strlcpy(name, symstr, namelen); break; case T_NEWLINE: @@ -2431,7 +2433,7 @@ getshowstatement(void) switch (gettoken()) { case T_SYMBOL: - strncpy(name, tokensymbol(), 4); + strlcpy(name, tokensymbol(), sizeof(name)); name[4] = '\0'; /* Yuck! */ arg = stringindex("buil\000" @@ -2595,8 +2597,7 @@ getid(char *buf) *buf = '\0'; return FALSE; } - strncpy(buf, tokensymbol(), SYMBOLSIZE); - buf[SYMBOLSIZE] = '\0'; + strlcpy(buf, tokensymbol(), SYMBOLSIZE+1); return TRUE; } diff --git a/comfunc.c b/comfunc.c index 52b4f00..c4ffd7d 100644 --- a/comfunc.c +++ b/comfunc.c @@ -29,6 +29,10 @@ #include "config.h" #include "cmath.h" + +#include "banned.h" /* include after system header <> includes */ + + /* * cache the natural logarithm of 10 */ diff --git a/commath.c b/commath.c index 41145a0..1879140 100644 --- a/commath.c +++ b/commath.c @@ -1,7 +1,7 @@ /* * commath - extended precision complex arithmetic primitive routines * - * Copyright (C) 1999-2007 David I. Bell + * Copyright (C) 1999-2007,2021 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,9 @@ #include "cmath.h" +#include "banned.h" /* include after system header <> includes */ + + COMPLEX _czero_ = { &_qzero_, &_qzero_, 1 }; COMPLEX _cone_ = { &_qone_, &_qzero_, 1 }; COMPLEX _conei_ = { &_qzero_, &_qone_, 1 }; diff --git a/config.c b/config.c index 1bf1975..96416a0 100644 --- a/config.c +++ b/config.c @@ -1,7 +1,7 @@ /* * config - configuration routines * - * Copyright (C) 1999-2007 David I. Bell and Landon Curt Noll + * Copyright (C) 1999-2007,2021 David I. Bell and Landon Curt Noll * * Primary author: David I. Bell * @@ -46,6 +46,7 @@ #endif #include "calc.h" +#include "alloc.h" #include "token.h" #include "zrand.h" #include "block.h" @@ -53,12 +54,17 @@ #include "config.h" #include "str.h" #include "custom.h" +#include "strl.h" #include "have_strdup.h" #if !defined(HAVE_STRDUP) # define strdup(x) calc_strdup((CONST char *)(x)) #endif /* HAVE_STRDUP */ + +#include "banned.h" /* include after system header <> includes */ + + /* * deal with systems that lack a defined CLK_TCK */ @@ -757,7 +763,7 @@ setconfig(int type, VALUE *vp) math_error("Cannot duplicate new prompt"); /*NOTREACHED*/ } - strncpy(p, vp->v_str->s_str, vp->v_str->s_len + 1); + strlcpy(p, vp->v_str->s_str, vp->v_str->s_len + 1); free(conf->prompt1); conf->prompt1 = p; break; @@ -772,7 +778,7 @@ setconfig(int type, VALUE *vp) math_error("Cannot duplicate new more prompt"); /*NOTREACHED*/ } - strncpy(p, vp->v_str->s_str, vp->v_str->s_len + 1); + strlcpy(p, vp->v_str->s_str, vp->v_str->s_len + 1); free(conf->prompt2); conf->prompt2 = p; break; diff --git a/const.c b/const.c index 25a4dd7..c7fed1d 100644 --- a/const.c +++ b/const.c @@ -1,7 +1,7 @@ /* * const - constant number storage module * - * Copyright (C) 1999-2007 David I. Bell + * Copyright (C) 1999-2007,2021 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 @@ -28,6 +28,10 @@ #include "calc.h" #include "qmath.h" + +#include "banned.h" /* include after system header <> includes */ + + #define CONSTALLOCSIZE 400 /* number of constants to allocate */ STATIC unsigned long constcount;/* number of constants defined */ diff --git a/cscript/Makefile b/cscript/Makefile index f180c8c..cee50ce 100644 --- a/cscript/Makefile +++ b/cscript/Makefile @@ -27,9 +27,27 @@ # Makefile by Landon Curt Noll -# our shell +# The shell used by this Makefile +# +# On some systems, /bin/sh is a rather reduced shell with +# deprecated behavor. +# +# If your system has a up to date, bash shell, then +# you may wish to use: +# +# SHELL= /bin/bash +# +# On some systems such as macOS, the bash shell is very +# far behind to the point wehre is cannot be depended on. +# On such systems, the zsh may be a much better alternative +# shell for this Makefile to use: +# +# SHELL= /bin/zsh # SHELL= /bin/sh +#SHELL= /bin/bash +#SHELL= /bin/zsh + #### # Normally, the upper level makefile will set these values. We provide @@ -328,7 +346,7 @@ depend: echo 'restoring original cscript/${MAKE_FILE}'; \ ${MV} -f ${MAKE_FILE}.bak ${MAKE_FILE}; \ else \ - echo 'previous cscript/${MAKE_FILE} is now cscript/${MAKE_FILE}.bak'; \ + echo 'old cscript/${MAKE_FILE} is now cscript/${MAKE_FILE}.bak'; \ echo 'new cscript/${MAKE_FILE} formed'; \ echo 'try: diff -u cscript/${MAKE_FILE}.bak cscript/${MAKE_FILE}'; \ fi diff --git a/custom.c b/custom.c index 39259f5..f0376de 100644 --- a/custom.c +++ b/custom.c @@ -47,6 +47,10 @@ #endif /* CUSTOM */ + +#include "banned.h" /* include after system header <> includes */ + + BOOL allow_custom = FALSE; /* TRUE => custom builtins allowed */ diff --git a/custom/Makefile b/custom/Makefile index 350d24b..cc28372 100644 --- a/custom/Makefile +++ b/custom/Makefile @@ -28,9 +28,63 @@ # Makefile by Landon Curt Noll -# our shell +# The shell used by this Makefile +# +# On some systems, /bin/sh is a rather reduced shell with +# deprecated behavor. +# +# If your system has a up to date, bash shell, then +# you may wish to use: +# +# SHELL= /bin/bash +# +# On some systems such as macOS, the bash shell is very +# far behind to the point wehre is cannot be depended on. +# On such systems, the zsh may be a much better alternative +# shell for this Makefile to use: +# +# SHELL= /bin/zsh # SHELL= /bin/sh +#SHELL= /bin/bash +#SHELL= /bin/zsh + + +# CCBAN is given to ${CC} in order to control if banned.h is in effect. +# +# The banned.h attempts to ban the use of certain dangerous functions +# that, if improperly used, could compromise the computational integrity +# if calculations. +# +# In the case of calc, we are motivated in part by the desire for calc +# to correctly calculate: even durings extremely long calculations. +# +# If UNBAN is NOT defined, then calling certain functions +# will result in a call to a non-existent function (link error). +# +# While we do NOT encourage defining UNBAN, there may be +# a system / compiler environment where re-defining a +# function may lead to a fatal compiler complication. +# If that happens, consider compiling as: +# +# make clobber all chk CCBAN=-DUNBAN +# +# as see if this is a work-a-round. +# +# If YOU discover a need for the -DUNBAN work-a-round, PLEASE tell us! +# Please send us a bug report. See the file: +# +# BUGS +# +# or the URL: +# +# http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html +# +# for how to send us such a bug report. +# +CCBAN= -UUNBAN +#CCBAN= -DUNBAN + #if 0 /* start of skip for non-Gnu makefiles */ ############################################################################## @@ -353,7 +407,7 @@ EXT= # The default calc versions # -VERSION= 2.12.8.2 +VERSION= 2.12.9.0 # Names of shared libraries with versions # @@ -424,9 +478,9 @@ COMMON_LDFLAGS= ${EXTRA_LDFLAGS} # NOTE: This does not work for: make-XYZ-only and BLD_TYPE != make-XYZ-only # ifeq ($(BLD_TYPE),calc-static-only) -ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC} +ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC} else -ICFLAGS= ${COMMON_CFLAGS} ${CC_SHARE} +ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_SHARE} endif CFLAGS= ${ICFLAGS} ${CCOPT} @@ -470,12 +524,20 @@ LDFLAGS= ${LD_DEBUG} ${ILDFLAGS} # CCOPT are flags given to ${CC} for optimization # CCWARN are flags given to ${CC} for warning message control # -# WNO_IMPLICT, WNO_ERROR_LONG_LONG and WNO_LONG_LONG are given to ${CC} -# when compiling special .o files that may need special compile options +# The following are given to ${CC}: +# +# WNO_IMPLICT +# WNO_ERROR_LONG_LONG +# WNO_LONG_LONG +# +# when compiling special .o files that may need special compile options: +# # NOTE: These flags simply turn off certain compiler warnings, # which is useful only when CCWERR is set to -Werror. +# # NOTE: If your compiler does not have these -Wno files, just # set these variables to nothing as in: +# # WNO_IMPLICT= # WNO_ERROR_LONG_LONG= # WNO_LONG_LONG= @@ -486,6 +548,9 @@ LDFLAGS= ${LD_DEBUG} ${ILDFLAGS} # to abort on warnings, then leave CCWERR blank. # CCMISC are misc flags given to ${CC} # +# CCBAN is given to ${CC} in order to control if banned.h is in effect. +# NOTE: See where CCBAN is defined above for details. +# # LCC is how the C compiler is invoked on locally executed intermediate programs # CC is how the C compiler is invoked (with an optional Purify) # @@ -908,7 +973,7 @@ CC= ${PURIFY} ${LCC} ${CCWERR} # ILDFLAGS for ${CC} in linking intermediate programs used to help compile calc # LDFLAGS for ${CC} in linking calc programs other than intermediate programs # -ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC} +ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC} CFLAGS= ${ICFLAGS} ${CCOPT} # ILDFLAGS= ${COMMON_LDFLAGS} ${LD_STATIC} @@ -1035,9 +1100,9 @@ endif # NOTE: This does not work for: make-XYZ-only and BLD_TYPE != make-XYZ-only # ifeq ($(BLD_TYPE),calc-static-only) -ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC} +ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC} else -ICFLAGS= ${COMMON_CFLAGS} ${CC_SHARE} +ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_SHARE} endif CFLAGS= ${ICFLAGS} ${CCOPT} @@ -1284,13 +1349,14 @@ depend: ${Q} ${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' \ ${MAKE_FILE}.bak > ${MAKE_FILE} ${Q} ${GREP} -v '^#' skel/custom/makedep.out >> ${MAKE_FILE} + ${Q} echo removing skel ${Q} ${RM} -rf skel -${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \ echo 'custom/${MAKE_FILE} was already up to date'; \ echo 'restoring original custom/${MAKE_FILE}'; \ ${MV} -f ${MAKE_FILE}.bak ${MAKE_FILE}; \ else \ - echo 'previous custom/${MAKE_FILE} is now custom/${MAKE_FILE}.bak'; \ + echo 'old custom/${MAKE_FILE} is now custom/${MAKE_FILE}.bak'; \ echo 'new custom/${MAKE_FILE} formed'; \ echo 'try: diff -u custom/${MAKE_FILE}.bak custom/${MAKE_FILE}'; \ fi @@ -1339,6 +1405,7 @@ clobber: clean ${RM} -f libcustcalc${LIB_EXT} ${RM} -f libcustcalc.a ${RM} -f libcustcalc* + ${RM} -rf skel ${V} echo remove files that are obsolete #if 0 /* start of skip for non-Gnu makefiles */ ${RM} -f Makefile.simple @@ -1585,6 +1652,7 @@ uninstall: # DO NOT DELETE THIS LINE -- make depend depends on it. c_argv.o: ../alloc.h +c_argv.o: ../banned.h c_argv.o: ../block.h c_argv.o: ../byteswap.h c_argv.o: ../calc.h @@ -1595,6 +1663,7 @@ c_argv.o: ../custom.h c_argv.o: ../decl.h c_argv.o: ../endian_calc.h c_argv.o: ../hash.h +c_argv.o: ../have_ban_pragma.h c_argv.o: ../have_const.h c_argv.o: ../have_memmv.h c_argv.o: ../have_newstr.h @@ -1610,6 +1679,7 @@ c_argv.o: ../value.h c_argv.o: ../zmath.h c_argv.o: c_argv.c c_devnull.o: ../alloc.h +c_devnull.o: ../banned.h c_devnull.o: ../block.h c_devnull.o: ../byteswap.h c_devnull.o: ../calcerr.h @@ -1619,6 +1689,7 @@ c_devnull.o: ../custom.h c_devnull.o: ../decl.h c_devnull.o: ../endian_calc.h c_devnull.o: ../hash.h +c_devnull.o: ../have_ban_pragma.h c_devnull.o: ../have_const.h c_devnull.o: ../have_memmv.h c_devnull.o: ../have_newstr.h @@ -1635,6 +1706,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: ../banned.h c_help.o: ../block.h c_help.o: ../byteswap.h c_help.o: ../calcerr.h @@ -1644,6 +1716,7 @@ c_help.o: ../custom.h c_help.o: ../decl.h c_help.o: ../endian_calc.h c_help.o: ../hash.h +c_help.o: ../have_ban_pragma.h c_help.o: ../have_const.h c_help.o: ../have_memmv.h c_help.o: ../have_newstr.h @@ -1660,6 +1733,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: ../banned.h c_pmodm127.o: ../block.h c_pmodm127.o: ../byteswap.h c_pmodm127.o: ../calcerr.h @@ -1669,6 +1743,7 @@ c_pmodm127.o: ../custom.h c_pmodm127.o: ../decl.h c_pmodm127.o: ../endian_calc.h c_pmodm127.o: ../hash.h +c_pmodm127.o: ../have_ban_pragma.h c_pmodm127.o: ../have_const.h c_pmodm127.o: ../have_memmv.h c_pmodm127.o: ../have_newstr.h @@ -1684,6 +1759,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: ../banned.h c_pzasusb8.o: ../block.h c_pzasusb8.o: ../byteswap.h c_pzasusb8.o: ../calcerr.h @@ -1693,6 +1769,7 @@ c_pzasusb8.o: ../custom.h c_pzasusb8.o: ../decl.h c_pzasusb8.o: ../endian_calc.h c_pzasusb8.o: ../hash.h +c_pzasusb8.o: ../have_ban_pragma.h c_pzasusb8.o: ../have_const.h c_pzasusb8.o: ../have_memmv.h c_pzasusb8.o: ../have_newstr.h @@ -1708,6 +1785,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: ../banned.h c_register.o: ../block.h c_register.o: ../byteswap.h c_register.o: ../calc.h @@ -1718,6 +1796,7 @@ c_register.o: ../custom.h c_register.o: ../decl.h c_register.o: ../endian_calc.h c_register.o: ../hash.h +c_register.o: ../have_ban_pragma.h c_register.o: ../have_const.h c_register.o: ../have_memmv.h c_register.o: ../have_newstr.h @@ -1733,6 +1812,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: ../banned.h c_sysinfo.o: ../block.h c_sysinfo.o: ../byteswap.h c_sysinfo.o: ../calc.h @@ -1745,6 +1825,7 @@ c_sysinfo.o: ../decl.h c_sysinfo.o: ../endian_calc.h c_sysinfo.o: ../fposval.h c_sysinfo.o: ../hash.h +c_sysinfo.o: ../have_ban_pragma.h c_sysinfo.o: ../have_const.h c_sysinfo.o: ../have_memmv.h c_sysinfo.o: ../have_newstr.h @@ -1765,6 +1846,7 @@ c_sysinfo.o: ../zrand.h c_sysinfo.o: ../zrandom.h c_sysinfo.o: c_sysinfo.c custtbl.o: ../alloc.h +custtbl.o: ../banned.h custtbl.o: ../block.h custtbl.o: ../byteswap.h custtbl.o: ../calcerr.h @@ -1774,6 +1856,7 @@ custtbl.o: ../custom.h custtbl.o: ../decl.h custtbl.o: ../endian_calc.h custtbl.o: ../hash.h +custtbl.o: ../have_ban_pragma.h custtbl.o: ../have_const.h custtbl.o: ../have_memmv.h custtbl.o: ../have_newstr.h diff --git a/custom/Makefile.head b/custom/Makefile.head index c12c35e..a87a62f 100644 --- a/custom/Makefile.head +++ b/custom/Makefile.head @@ -28,9 +28,63 @@ # Makefile by Landon Curt Noll -# our shell +# The shell used by this Makefile +# +# On some systems, /bin/sh is a rather reduced shell with +# deprecated behavor. +# +# If your system has a up to date, bash shell, then +# you may wish to use: +# +# SHELL= /bin/bash +# +# On some systems such as macOS, the bash shell is very +# far behind to the point wehre is cannot be depended on. +# On such systems, the zsh may be a much better alternative +# shell for this Makefile to use: +# +# SHELL= /bin/zsh # SHELL= /bin/sh +#SHELL= /bin/bash +#SHELL= /bin/zsh + + +# CCBAN is given to ${CC} in order to control if banned.h is in effect. +# +# The banned.h attempts to ban the use of certain dangerous functions +# that, if improperly used, could compromise the computational integrity +# if calculations. +# +# In the case of calc, we are motivated in part by the desire for calc +# to correctly calculate: even durings extremely long calculations. +# +# If UNBAN is NOT defined, then calling certain functions +# will result in a call to a non-existent function (link error). +# +# While we do NOT encourage defining UNBAN, there may be +# a system / compiler environment where re-defining a +# function may lead to a fatal compiler complication. +# If that happens, consider compiling as: +# +# make clobber all chk CCBAN=-DUNBAN +# +# as see if this is a work-a-round. +# +# If YOU discover a need for the -DUNBAN work-a-round, PLEASE tell us! +# Please send us a bug report. See the file: +# +# BUGS +# +# or the URL: +# +# http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html +# +# for how to send us such a bug report. +# +CCBAN= -UUNBAN +#CCBAN= -DUNBAN + #if 0 /* start of skip for non-Gnu makefiles */ ############################################################################## @@ -353,7 +407,7 @@ EXT= # The default calc versions # -VERSION= 2.12.8.2 +VERSION= 2.12.9.0 # Names of shared libraries with versions # @@ -424,9 +478,9 @@ COMMON_LDFLAGS= ${EXTRA_LDFLAGS} # NOTE: This does not work for: make-XYZ-only and BLD_TYPE != make-XYZ-only # ifeq ($(BLD_TYPE),calc-static-only) -ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC} +ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC} else -ICFLAGS= ${COMMON_CFLAGS} ${CC_SHARE} +ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_SHARE} endif CFLAGS= ${ICFLAGS} ${CCOPT} diff --git a/custom/Makefile.tail b/custom/Makefile.tail index 4d72329..96763d7 100644 --- a/custom/Makefile.tail +++ b/custom/Makefile.tail @@ -228,13 +228,14 @@ depend: ${Q} ${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' \ ${MAKE_FILE}.bak > ${MAKE_FILE} ${Q} ${GREP} -v '^#' skel/custom/makedep.out >> ${MAKE_FILE} + ${Q} echo removing skel ${Q} ${RM} -rf skel -${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \ echo 'custom/${MAKE_FILE} was already up to date'; \ echo 'restoring original custom/${MAKE_FILE}'; \ ${MV} -f ${MAKE_FILE}.bak ${MAKE_FILE}; \ else \ - echo 'previous custom/${MAKE_FILE} is now custom/${MAKE_FILE}.bak'; \ + echo 'old custom/${MAKE_FILE} is now custom/${MAKE_FILE}.bak'; \ echo 'new custom/${MAKE_FILE} formed'; \ echo 'try: diff -u custom/${MAKE_FILE}.bak custom/${MAKE_FILE}'; \ fi @@ -283,6 +284,7 @@ clobber: clean ${RM} -f libcustcalc${LIB_EXT} ${RM} -f libcustcalc.a ${RM} -f libcustcalc* + ${RM} -rf skel ${V} echo remove files that are obsolete #if 0 /* start of skip for non-Gnu makefiles */ ${RM} -f Makefile.simple @@ -529,6 +531,7 @@ uninstall: # DO NOT DELETE THIS LINE -- make depend depends on it. c_argv.o: ../alloc.h +c_argv.o: ../banned.h c_argv.o: ../block.h c_argv.o: ../byteswap.h c_argv.o: ../calc.h @@ -539,6 +542,7 @@ c_argv.o: ../custom.h c_argv.o: ../decl.h c_argv.o: ../endian_calc.h c_argv.o: ../hash.h +c_argv.o: ../have_ban_pragma.h c_argv.o: ../have_const.h c_argv.o: ../have_memmv.h c_argv.o: ../have_newstr.h @@ -554,6 +558,7 @@ c_argv.o: ../value.h c_argv.o: ../zmath.h c_argv.o: c_argv.c c_devnull.o: ../alloc.h +c_devnull.o: ../banned.h c_devnull.o: ../block.h c_devnull.o: ../byteswap.h c_devnull.o: ../calcerr.h @@ -563,6 +568,7 @@ c_devnull.o: ../custom.h c_devnull.o: ../decl.h c_devnull.o: ../endian_calc.h c_devnull.o: ../hash.h +c_devnull.o: ../have_ban_pragma.h c_devnull.o: ../have_const.h c_devnull.o: ../have_memmv.h c_devnull.o: ../have_newstr.h @@ -579,6 +585,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: ../banned.h c_help.o: ../block.h c_help.o: ../byteswap.h c_help.o: ../calcerr.h @@ -588,6 +595,7 @@ c_help.o: ../custom.h c_help.o: ../decl.h c_help.o: ../endian_calc.h c_help.o: ../hash.h +c_help.o: ../have_ban_pragma.h c_help.o: ../have_const.h c_help.o: ../have_memmv.h c_help.o: ../have_newstr.h @@ -604,6 +612,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: ../banned.h c_pmodm127.o: ../block.h c_pmodm127.o: ../byteswap.h c_pmodm127.o: ../calcerr.h @@ -613,6 +622,7 @@ c_pmodm127.o: ../custom.h c_pmodm127.o: ../decl.h c_pmodm127.o: ../endian_calc.h c_pmodm127.o: ../hash.h +c_pmodm127.o: ../have_ban_pragma.h c_pmodm127.o: ../have_const.h c_pmodm127.o: ../have_memmv.h c_pmodm127.o: ../have_newstr.h @@ -628,6 +638,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: ../banned.h c_pzasusb8.o: ../block.h c_pzasusb8.o: ../byteswap.h c_pzasusb8.o: ../calcerr.h @@ -637,6 +648,7 @@ c_pzasusb8.o: ../custom.h c_pzasusb8.o: ../decl.h c_pzasusb8.o: ../endian_calc.h c_pzasusb8.o: ../hash.h +c_pzasusb8.o: ../have_ban_pragma.h c_pzasusb8.o: ../have_const.h c_pzasusb8.o: ../have_memmv.h c_pzasusb8.o: ../have_newstr.h @@ -652,6 +664,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: ../banned.h c_register.o: ../block.h c_register.o: ../byteswap.h c_register.o: ../calc.h @@ -662,6 +675,7 @@ c_register.o: ../custom.h c_register.o: ../decl.h c_register.o: ../endian_calc.h c_register.o: ../hash.h +c_register.o: ../have_ban_pragma.h c_register.o: ../have_const.h c_register.o: ../have_memmv.h c_register.o: ../have_newstr.h @@ -677,6 +691,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: ../banned.h c_sysinfo.o: ../block.h c_sysinfo.o: ../byteswap.h c_sysinfo.o: ../calc.h @@ -689,6 +704,7 @@ c_sysinfo.o: ../decl.h c_sysinfo.o: ../endian_calc.h c_sysinfo.o: ../fposval.h c_sysinfo.o: ../hash.h +c_sysinfo.o: ../have_ban_pragma.h c_sysinfo.o: ../have_const.h c_sysinfo.o: ../have_memmv.h c_sysinfo.o: ../have_newstr.h @@ -709,6 +725,7 @@ c_sysinfo.o: ../zrand.h c_sysinfo.o: ../zrandom.h c_sysinfo.o: c_sysinfo.c custtbl.o: ../alloc.h +custtbl.o: ../banned.h custtbl.o: ../block.h custtbl.o: ../byteswap.h custtbl.o: ../calcerr.h @@ -718,6 +735,7 @@ custtbl.o: ../custom.h custtbl.o: ../decl.h custtbl.o: ../endian_calc.h custtbl.o: ../hash.h +custtbl.o: ../have_ban_pragma.h custtbl.o: ../have_const.h custtbl.o: ../have_memmv.h custtbl.o: ../have_newstr.h diff --git a/custom/c_argv.c b/custom/c_argv.c index 621c7ae..d1a9de9 100644 --- a/custom/c_argv.c +++ b/custom/c_argv.c @@ -1,7 +1,7 @@ /* * c_argv - a custom function display info about its args * - * Copyright (C) 1999-2006 Landon Curt Noll + * Copyright (C) 1999-2006,2021 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 @@ -38,6 +38,10 @@ #include "have_unused.h" + +#include "banned.h" /* include after system header <> includes */ + + /* * c_argv - a custom function display info about its args * @@ -49,7 +53,7 @@ */ /*ARGSUSED*/ VALUE -c_argv(char UNUSED *name, int count, VALUE **vals) +c_argv(char *UNUSED(name), int count, VALUE **vals) { VALUE result; /* what we will return */ ZVALUE zfilelen; /* length of a file as a ZVALUE */ diff --git a/custom/c_devnull.c b/custom/c_devnull.c index accd8a9..1c02c09 100644 --- a/custom/c_devnull.c +++ b/custom/c_devnull.c @@ -1,7 +1,7 @@ /* * c_devnull - a custom function that does nothing * - * Copyright (C) 1999-2004 Landon Curt Noll + * Copyright (C) 1999-2004,2021 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,9 @@ #include "have_unused.h" +#include "banned.h" /* include after system header <> includes */ + + /* * c_devnull - a custom function that does nothing * @@ -47,7 +50,7 @@ */ /*ARGSUSED*/ VALUE -c_devnull(char UNUSED *name, int UNUSED count, VALUE UNUSED **vals) +c_devnull(char *UNUSED(name), int UNUSED(count), VALUE **UNUSED(vals)) { VALUE result; /* what we will return */ diff --git a/custom/c_help.c b/custom/c_help.c index c17a2bc..619a314 100644 --- a/custom/c_help.c +++ b/custom/c_help.c @@ -1,7 +1,7 @@ /* * c_help - custom help function * - * Copyright (C) 1999-2004 Landon Curt Noll + * Copyright (C) 1999-2004,2021 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,9 @@ #include "have_unused.h" +#include "banned.h" /* include after system header <> includes */ + + /* * c_help - custom help function * @@ -58,7 +61,7 @@ */ /*ARGSUSED*/ VALUE -c_help(char UNUSED *name, int UNUSED count, VALUE **vals) +c_help(char *UNUSED(name), int UNUSED(count), VALUE **vals) { VALUE result; /* what we will return */ diff --git a/custom/c_pmodm127.c b/custom/c_pmodm127.c index 929fbf8..5b385e6 100644 --- a/custom/c_pmodm127.c +++ b/custom/c_pmodm127.c @@ -35,6 +35,10 @@ #include "have_unused.h" + +#include "banned.h" /* include after system header <> includes */ + + /* 2^255 */ STATIC HALF h255[] = { #if BASEB == 32 @@ -71,7 +75,7 @@ STATIC ZVALUE lastmodinv[1]; */ /*ARGSUSED*/ VALUE -c_pmodm127(char UNUSED *name, int UNUSED count, VALUE **vals) +c_pmodm127(char *UNUSED(name), int UNUSED(count), VALUE **vals) { VALUE result; /* what we will return */ ZVALUE q; /* test factor */ diff --git a/custom/c_pzasusb8.c b/custom/c_pzasusb8.c index 9720a28..07d32d9 100644 --- a/custom/c_pzasusb8.c +++ b/custom/c_pzasusb8.c @@ -35,6 +35,10 @@ #include "have_unused.h" + +#include "banned.h" /* include after system header <> includes */ + + /* * c_pzasusb8 - print numerator as a string of USB8s * @@ -47,7 +51,7 @@ */ /*ARGSUSED*/ VALUE -c_pzasusb8(char UNUSED *name, int UNUSED count, VALUE **vals) +c_pzasusb8(char *UNUSED(name), int UNUSED(count), VALUE **vals) { VALUE result; /* what we will return */ ZVALUE z; /* numerator of the value */ diff --git a/custom/c_register.c b/custom/c_register.c index 0065af4..7cecd62 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 Landon Curt Noll + * Copyright (C) 2007,2021 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,9 @@ #include "have_unused.h" +#include "banned.h" /* include after system header <> includes */ + + /* * registers */ @@ -76,7 +79,7 @@ init_custreg(void) */ /*ARGSUSED*/ VALUE -c_register(char UNUSED *name, int count, VALUE **vals) +c_register(char *UNUSED(name), int count, VALUE **vals) { VALUE result; /* what we will return */ long reg; /* register number */ diff --git a/custom/c_sysinfo.c b/custom/c_sysinfo.c index a24bcf8..3b3897d 100644 --- a/custom/c_sysinfo.c +++ b/custom/c_sysinfo.c @@ -57,6 +57,9 @@ #include "have_unused.h" +#include "banned.h" /* include after system header <> includes */ + + /* * sys_info - names and values of selected #defines */ @@ -266,7 +269,7 @@ S_FUNC void dump_mening_value(void); /* custom("sysinfo", 2) */ */ /*ARGSUSED*/ VALUE -c_sysinfo(char UNUSED *name, int count, VALUE **vals) +c_sysinfo(char *UNUSED(name), int count, VALUE **vals) { VALUE result; /* what we will return */ struct infoname *p; /* current infoname */ diff --git a/custom/custtbl.c b/custom/custtbl.c index 0a407ce..028c91c 100644 --- a/custom/custtbl.c +++ b/custom/custtbl.c @@ -30,6 +30,10 @@ #include "value.h" #include "custom.h" + +#include "banned.h" /* include after system header <> includes */ + + /* * NOTE: See the file CUSTOM for instructions on how to add * custom functions. diff --git a/decl.h b/decl.h index e5d8b34..729f855 100644 --- a/decl.h +++ b/decl.h @@ -1,7 +1,7 @@ /* * decl - variable and function declaration macros * - * Copyright (C) 2007,2014 Landon Curt Noll + * Copyright (C) 2007,2014,2021 Landon Curt Noll * * Primary author: Landon Curt Noll * diff --git a/endian.c b/endian.c index e8c9712..135fbe8 100644 --- a/endian.c +++ b/endian.c @@ -42,6 +42,10 @@ #include #endif + +#include "banned.h" /* include after system header <> includes */ + + /* byte order array */ char byte[8] = { (char)0x12, (char)0x36, (char)0x48, (char)0x59, (char)0x01, (char)0x23, (char)0x45, (char)0x67 }; diff --git a/file.c b/file.c index 0ea9cb9..ecd15f3 100644 --- a/file.c +++ b/file.c @@ -37,17 +37,23 @@ #endif /* HAVE_UNISTD_H */ #include #include "calc.h" +#include "alloc.h" #include "longbits.h" #include "have_fpos.h" #include "have_fpos_pos.h" #include "fposval.h" #include "file.h" #include "calcerr.h" +#include "strl.h" #if defined(_WIN32) # include #endif + +#include "banned.h" /* include after system header <> includes */ + + #define READSIZE 1024 /* buffer size for reading */ #define MIN(a,b) (((a) <= (b)) ? (a) : (b)) @@ -141,6 +147,7 @@ file_init(void) files[idnum].reading = TRUE; files[idnum].writing = TRUE; files[idnum].action = 0; + memset(files[idnum].mode, 0, MODE_LEN+1); /* * stat the descriptor to see what we have */ @@ -148,16 +155,19 @@ file_init(void) size_t snprintf_len; /* malloced snprintf length */ fp = (FILE *) fdopen(i,"r+"); /*guess mode*/ if (fp) { - strcpy(files[idnum].mode, "r+"); + strlcpy(files[idnum].mode, "r+", + sizeof(files[idnum].mode)); } else { fp = (FILE *) fdopen(i, "r"); if (fp) { - strcpy(files[idnum].mode, "r"); + strlcpy(files[idnum].mode, "r", + sizeof(files[idnum].mode)); files[idnum].writing = FALSE; } else { fp = (FILE *) fdopen(i, "w"); if (fp) { - strcpy(files[idnum].mode, "w"); + strlcpy(files[idnum].mode, "w", + sizeof(files[idnum].mode)); files[idnum].reading = FALSE; } else @@ -208,10 +218,14 @@ S_FUNC void init_fileio(FILEIO *fiop, char *name, char *mode, struct stat *sbufp, FILEID id, FILE *fp) { - char modestr[sizeof(fiop->mode)]; /* mode [rwa]b?\+? */ - size_t namelen; /* length of name */ + char modestr[MODE_LEN+1]; /* mode [rwa]b?\+? */ + size_t namelen; /* length of name */ + + /* clear modestr */ + memset(modestr, 0, sizeof(modestr)); /* allocate filename if requested */ + namelen = 0; if (name != NULL) { namelen = strlen(name); fiop->name = (char *)malloc(namelen + 1); @@ -223,7 +237,7 @@ init_fileio(FILEIO *fiop, char *name, char *mode, /* initialize FILEIO structure */ if (name != NULL) { - strncpy(fiop->name, name, namelen+1); + strlcpy(fiop->name, name, namelen+1); } fiop->id = id; fiop->fp = fp; @@ -234,7 +248,7 @@ init_fileio(FILEIO *fiop, char *name, char *mode, fiop->appending = FALSE; fiop->binary = FALSE; fiop->action = 0; - fiop->mode[0] = '\0'; + memset(fiop->mode, 0, sizeof(fiop->mode)); /* * determine file open mode @@ -248,65 +262,65 @@ init_fileio(FILEIO *fiop, char *name, char *mode, if (mode[0] == 'r') { /* note read mode */ - strcpy(modestr, "r"); + strlcpy(modestr, "r", sizeof(modestr)); fiop->reading = TRUE; /* note binary mode even though mode is not used / ignored */ if (strchr(mode, 'b') != NULL) { - strcat(modestr, "b"); + strlcat(modestr, "b", sizeof(modestr)); } /* note if reading and writing */ if (strchr(mode, '+') != NULL) { fiop->writing = TRUE; - strcat(modestr, "+"); + strlcat(modestr, "+", sizeof(modestr)); } /* canonicalize write modes */ } else if (mode[0] == 'w') { /* note write mode */ - strcpy(modestr, "w"); + strlcpy(modestr, "w", sizeof(modestr)); fiop->writing = TRUE; /* note binary mode even though mode is not used / ignored */ if (strchr(mode, 'b') != NULL) { - strcat(modestr, "b"); + strlcat(modestr, "b", sizeof(modestr)); } /* note if reading and writing */ if (strchr(mode, '+') != NULL) { fiop->reading = TRUE; - strcat(modestr, "+"); + strlcat(modestr, "+", sizeof(modestr)); } /* canonicalize append modes */ } else if (mode[0] == 'a') { /* note append mode */ - strcpy(modestr, "a"); + strlcpy(modestr, "a", sizeof(modestr)); fiop->writing = TRUE; fiop->appending = TRUE; /* note binary mode even though mode is not used / ignored */ if (strchr(mode, 'b') != NULL) { - strcat(modestr, "b"); + strlcat(modestr, "b", sizeof(modestr)); } /* note if reading and writing */ if (strchr(mode, '+') != NULL) { fiop->reading = TRUE; - strcat(modestr, "+"); + strlcat(modestr, "+", sizeof(modestr)); } /* canonicalize no I/O modes */ } else { modestr[0] = '\0'; } - modestr[sizeof(modestr)-1] = '\0'; /* firewall */ + modestr[MODE_LEN] = '\0'; /* firewall */ /* record canonical open mode string */ - strncpy(fiop->mode, modestr, sizeof(fiop->mode)); + strlcpy(fiop->mode, modestr, sizeof(fiop->mode)); } diff --git a/file.h b/file.h index 6583bbe..7697440 100644 --- a/file.h +++ b/file.h @@ -41,6 +41,7 @@ /* * Definition of opened files. */ +#define MODE_LEN (sizeof("rb+")-1) typedef struct { FILEID id; /* id to identify this file */ FILE *fp; /* real file structure for I/O */ @@ -52,7 +53,7 @@ typedef struct { BOOL appending; /* TRUE if also opened for appending */ BOOL binary; /* TRUE if binary mode - mode ignored/unused */ char action; /* most recent use for 'r', 'w' or 0 */ - char mode[sizeof("rb+")+1];/* open mode */ + char mode[MODE_LEN+1]; /* open mode */ } FILEIO; diff --git a/fposval.c b/fposval.c index 56a686e..ca18d6c 100644 --- a/fposval.c +++ b/fposval.c @@ -64,6 +64,11 @@ #include "have_offscl.h" #include "have_posscl.h" #include "have_fpos_pos.h" +#include "alloc.h" + + +#include "banned.h" /* include after system header <> includes */ + char *program; /* our name */ diff --git a/fposval.h.def b/fposval.h.def new file mode 100644 index 0000000..c9bee60 --- /dev/null +++ b/fposval.h.def @@ -0,0 +1,54 @@ +/* + * fposval.h.def - fposval.h default macros + * + * Copyright (C) 2021 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: 2021/03/10 22;14:26 + * File existed as early as: 2021 + * + * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ + */ + +/* + * WARNING: For some reason fposval failed to generate values + * so we choose these values that are hopefully OK + */ + +/* what are our file position & size types? */ +#undef FILEPOS_BITS +#define FILEPOS_BITS 64 +#undef FILEPOS_LEN +#define FILEPOS_LEN 8 +#define SWAP_HALF_IN_FILEPOS(dest, src) (*(dest) = *(src)) + +#undef OFF_T_BITS +#define OFF_T_BITS 64 +#undef OFF_T_LEN +#define OFF_T_LEN 8 +#define SWAP_HALF_IN_OFF_T(dest, src) (*(dest) = *(src)) + +#undef DEV_BITS +#define DEV_BITS 32 +#undef DEV_LEN +#define DEV_LEN 4 +#define SWAP_HALF_IN_DEV(dest, src) memcpy((void *)(dest), (void *)(src), 4) + +#undef INODE_BITS +#define INODE_BITS 64 +#undef INODE_LEN +#define INODE_LEN 8 +#define SWAP_HALF_IN_INODE(dest, src) memcpy((void *)(dest), (void *)(src), 8) diff --git a/func.c b/func.c index 42e28a1..00788eb 100644 --- a/func.c +++ b/func.c @@ -105,6 +105,7 @@ #include "zrand.h" #include "zrandom.h" #include "custom.h" +#include "strl.h" #if defined(CUSTOM) # define E_CUSTOM_ERROR E_NO_C_ARG @@ -113,6 +114,9 @@ #endif +#include "banned.h" /* include after system header <> includes */ + + /* * forward declarations */ @@ -269,22 +273,7 @@ f_prompt(VALUE *vp) math_error("Cannot allocate string"); /*NOTREACHED*/ } - /* - * The next statement could be:: - * - * strncpy(newcp, cp, len); - * - * however compilers like gcc would issue warnings such as: - * - * specified bound depends on the length of the - * source argument - * - * even though we terminate the string by setting a NUL - * byte following the copy. Therefore we call memcpy() - * instead to avoid such warnings. - */ - memcpy(newcp, cp, len); - newcp[len] = '\0'; + strlcpy(newcp, cp, len+1); result.v_str = makestring(newcp); return result; } @@ -317,7 +306,7 @@ f_display(int count, VALUE **vals) /*ARGSUSED*/ S_FUNC VALUE -f_null(int UNUSED count, VALUE UNUSED **vals) +f_null(int UNUSED(count), VALUE **UNUSED(vals)) { VALUE res; @@ -5341,7 +5330,7 @@ f_list(int count, VALUE **vals) /*ARGSUSED*/ S_FUNC VALUE -f_assoc(int UNUSED count, VALUE UNUSED **vals) +f_assoc(int UNUSED(count), VALUE **UNUSED(vals)) { VALUE result; @@ -7466,22 +7455,7 @@ f_cmdbuf(void) math_error("Cannot allocate string in cmdbuf"); /*NOTREACHED*/ } - /* - * The next statement could be:: - * - * strncpy(newcp, cmdbuf, cmdbuf_len); - * - * however compilers like gcc would issue warnings such as: - * - * specified bound depends on the length of the - * source argument - * - * even though we terminate the string by setting a NUL - * byte following the copy. Therefore we call memcpy() - * instead to avoid such warnings. - */ - memcpy(newcp, cmdbuf, cmdbuf_len); - newcp[cmdbuf_len] = '\0'; + strlcpy(newcp, cmdbuf, cmdbuf_len+1); result.v_str = makestring(newcp); return result; } @@ -7666,7 +7640,7 @@ f_putenv(int count, VALUE **vals) /*NOTREACHED*/ } /* - * The next statement could be:: + * The next statement could be: * * snprintf(putenv_str, snprintf_len, * "%s=%s", vals[0]->v_str->s_str, @@ -7677,16 +7651,16 @@ f_putenv(int count, VALUE **vals) * null destination pointer * * even though we check that putenv_str is non-NULL - * above before using it. Therefore we call memcpy() + * above before using it. Therefore we call strlcpy() * twice and make an assignment instead to avoid such warnings. */ - memcpy(putenv_str, + strlcpy(putenv_str, vals[0]->v_str->s_str, - vals[0]->v_str->s_len); + vals[0]->v_str->s_len+1); putenv_str[vals[0]->v_str->s_len] = '='; - memcpy(putenv_str + vals[0]->v_str->s_len + 1, + strlcpy(putenv_str + vals[0]->v_str->s_len + 1, vals[1]->v_str->s_str, - vals[1]->v_str->s_len); + vals[1]->v_str->s_len+1); putenv_str[snprintf_len] = '\0'; } else { @@ -7711,9 +7685,8 @@ f_putenv(int count, VALUE **vals) math_error("Cannot allocate string in putenv"); /*NOTREACHED*/ } - memcpy(putenv_str, vals[0]->v_str->s_str, - vals[0]->v_str->s_len); - putenv_str[vals[0]->v_str->s_len] = '\0'; + strlcpy(putenv_str, vals[0]->v_str->s_str, + vals[0]->v_str->s_len+1); } /* return putenv result */ diff --git a/hash.c b/hash.c index 5bf3091..0909228 100644 --- a/hash.c +++ b/hash.c @@ -26,16 +26,23 @@ #include -#include +#include "have_string.h" +#ifdef HAVE_STRING_H +# include +#endif #include #include #include "calc.h" +#include "alloc.h" #include "value.h" #include "zrand.h" #include "zrandom.h" #include "hash.h" +#include "banned.h" /* include after system header <> includes */ + + /* * external hash_setup functions */ diff --git a/have_ban_pragma.c b/have_ban_pragma.c new file mode 100644 index 0000000..988b0bd --- /dev/null +++ b/have_ban_pragma.c @@ -0,0 +1,71 @@ +/* + * have_ban_pragma.c - Determine if we have #pragma GCC poison func_name + * + * Copyright (C) 2021 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: 2021/03/08 01:02:34 + * File existed as early as: 2021 + * + * chongo /\oo/\ http://www.isthe.com/chongo/ + * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ + */ + +/* + * usage: + * have_ban_pragma + * + * Not all systems have #pragma GCC poison func_name, so this may not + * compile on your system. + * + * This prog outputs several defines: + * + * HAVE_PRAGMA_GCC_POSION + * defined ==> use #pragma GCC poison func_name + * undefined ==> do not use #pragma GCC poison func_name + * + * NOTE: Modern clang compilers allow for 'pragma GCC poison func_name'. + * This is NOT simply a GCC feature. + */ + +#include + + +/* undef UNBAN to be undefined to force use of banned.h */ +#undef UNBAN + +/* prevent banned.h from including have_ban_pragma.h */ +#define PRE_HAVE_BAN_PRAGMA_H + +#include "banned.h" /* include after system header <> includes */ + + +int +main(void) +{ +#if defined(HAVE_NO_PRAGMA_GCC_POSION) + + printf("#undef HAVE_PRAGMA_GCC_POSION /* no */\n"); + +#else /* HAVE_NO_PRAGMA_GCC_POSION */ + + printf("#define HAVE_PRAGMA_GCC_POSION /* yes */\n"); + +#endif /* HAVE_NO_PRAGMA_GCC_POSION */ + + /* exit(0); */ + return 0; +} diff --git a/have_const.c b/have_const.c index d7100ce..568f326 100644 --- a/have_const.c +++ b/have_const.c @@ -41,9 +41,12 @@ * (nothing) ==> const not used */ - #include + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_fpos.c b/have_fpos.c index 3988946..403baad 100644 --- a/have_fpos.c +++ b/have_fpos.c @@ -1,7 +1,7 @@ /* * have_fpos - Determine if have fgetpos and fsetpos functions * - * Copyright (C) 1999 Landon Curt Noll + * Copyright (C) 1999,2021 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 @@ -31,9 +31,12 @@ * appropriate have_fpos.h file body. */ - #include + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_fpos_pos.c b/have_fpos_pos.c index 939c06e..56817cf 100644 --- a/have_fpos_pos.c +++ b/have_fpos_pos.c @@ -1,7 +1,7 @@ /* * have_fpos_pos - Determine if a __pos element in FILEPOS * - * Copyright (C) 2000 Landon Curt Noll + * Copyright (C) 2000,2021 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 @@ -31,11 +31,14 @@ * __pos element in a non-scalar FILEPOS. */ - #include #include "have_fpos.h" #include "have_posscl.h" + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_getpgid.c b/have_getpgid.c index c4ec173..59aaaca 100644 --- a/have_getpgid.c +++ b/have_getpgid.c @@ -38,12 +38,17 @@ * undefined ==> do not or cannot call getpgid() */ +#include #include #include "have_unistd.h" #if defined(HAVE_UNISTD_H) #include #endif + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_getprid.c b/have_getprid.c index 0b75f5c..f350f82 100644 --- a/have_getprid.c +++ b/have_getprid.c @@ -38,13 +38,17 @@ * undefined ==> do not or cannot call getprid() */ - +#include #include #include "have_unistd.h" #if defined(HAVE_UNISTD_H) #include #endif + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_getsid.c b/have_getsid.c index b2247ec..ecdbda9 100644 --- a/have_getsid.c +++ b/have_getsid.c @@ -38,13 +38,17 @@ * undefined ==> do not call or cannot call getsid() */ - +#include #include #include "have_unistd.h" #if defined(HAVE_UNISTD_H) #include #endif + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_gettime.c b/have_gettime.c index 5694b58..39a462f 100644 --- a/have_gettime.c +++ b/have_gettime.c @@ -1,7 +1,7 @@ /* * have_gettime - determine if we have clock_gettime() * - * Copyright (C) 1999 Landon Curt Noll + * Copyright (C) 1999,2021 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,9 +40,13 @@ * CLOCK_SGI_CYCLE and CLOCK_REALTIME */ - +#include #include + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_memmv.c b/have_memmv.c index 9d06f2d..9339aea 100644 --- a/have_memmv.c +++ b/have_memmv.c @@ -38,9 +38,15 @@ * undefined ==> use internal slow memmove() instead */ - #include -#include +#include "have_string.h" +#ifdef HAVE_STRING_H +# include +#endif + + +#include "banned.h" /* include after system header <> includes */ + #define MOVELEN 3 diff --git a/have_newstr.c b/have_newstr.c index 2663504..cdff2c8 100644 --- a/have_newstr.c +++ b/have_newstr.c @@ -40,9 +40,15 @@ * use index() instead of strchr() */ - #include -#include +#include "have_string.h" +#ifdef HAVE_STRING_H +# include +#endif + + +#include "banned.h" /* include after system header <> includes */ + #define MOVELEN 3 diff --git a/have_offscl.c b/have_offscl.c index 6efb3ee..35b336c 100644 --- a/have_offscl.c +++ b/have_offscl.c @@ -42,7 +42,6 @@ * undefined ==> convert to ZVALUE first */ - #include #include #include @@ -51,6 +50,10 @@ #include #endif + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_posscl.c b/have_posscl.c index 577a115..82e54a2 100644 --- a/have_posscl.c +++ b/have_posscl.c @@ -41,7 +41,6 @@ * undefined ==> convert to ZVALUE first */ - #include #include #include @@ -51,6 +50,10 @@ #endif #include "have_fpos.h" + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_rusage.c b/have_rusage.c index 46d1cfe..7afb165 100644 --- a/have_rusage.c +++ b/have_rusage.c @@ -1,7 +1,7 @@ /* * have_rusage - Determine if we have getrusage() * - * Copyright (C) 1999 Landon Curt Noll + * Copyright (C) 1999,2021 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 @@ -38,10 +38,14 @@ * undefined ==> do not call or cannot call getrusage() */ - +#include #include #include + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_stdvs.c b/have_stdvs.c index eedd61f..6bc17c6 100644 --- a/have_stdvs.c +++ b/have_stdvs.c @@ -1,7 +1,7 @@ /* * have_stdvs - try to see if it really works with vsnprintf() * - * Copyright (C) 1999,2014,2018 Landon Curt Noll + * Copyright (C) 1999,2014,2018,2021 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 @@ -38,7 +38,6 @@ * include file. */ - #include #include "have_unistd.h" @@ -65,6 +64,10 @@ # define VSNPRINTF_SIZE_T long #endif + +#include "banned.h" /* include after system header <> includes */ + + char buf[BUFSIZ+1]; diff --git a/have_strdup.c b/have_strdup.c index bbcfc01..f6312a0 100644 --- a/have_strdup.c +++ b/have_strdup.c @@ -1,7 +1,7 @@ /* * have_strdup - determine if we have strdup() * - * Copyright (C) 1999 Landon Curt Noll + * Copyright (C) 1999,2021 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 @@ -38,8 +38,15 @@ * undefined ==> do not call or cannot call strdup() */ +#include +#include "have_string.h" +#ifdef HAVE_STRING_H +# include +#endif + + +#include "banned.h" /* include after system header <> includes */ -#include int main(void) diff --git a/have_strlcat.c b/have_strlcat.c new file mode 100644 index 0000000..534bca3 --- /dev/null +++ b/have_strlcat.c @@ -0,0 +1,76 @@ +/* + * have_strlcat - determine if we have strlcat() + * + * Copyright (C) 2021 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: 2021/03/08 20:34:13 + * File existed as early as: 2021 + * + * chongo /\oo/\ http://www.isthe.com/chongo/ + * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ + */ + +/* + * usage: + * have_strlcat + * + * Not all systems have the strlcat() function, so this may not + * compile on your system. + * + * This prog outputs several defines: + * + * HAVE_STRLCAT + * defined ==> use strlcat() + * undefined ==> do not or cannot call strlcat() + */ + +#include +#include "have_string.h" +#ifdef HAVE_STRING_H +# include +#endif + + +#include "banned.h" /* include after system header <> includes */ + + +#define BUF_SIZ 5 + +char src[BUF_SIZ+1] = "abcde"; + + +int +main(void) +{ +#if defined(HAVE_NO_STRLCAT) + + printf("#undef HAVE_STRLCAT /* no */\n"); + +#else /* HAVE_NO_STRLCAT */ + char dst[BUF_SIZ+1+1]; + + dst[0] = 'S'; + dst[1] = '\0'; + (void) strlcat(dst, src, sizeof(dst)); + + printf("#define HAVE_STRLCAT /* yes */\n"); + +#endif /* HAVE_NO_STRLCAT */ + + /* exit(0); */ + return 0; +} diff --git a/have_strlcpy.c b/have_strlcpy.c new file mode 100644 index 0000000..f77bd63 --- /dev/null +++ b/have_strlcpy.c @@ -0,0 +1,74 @@ +/* + * have_strlcpy - determine if we have strlcpy() + * + * Copyright (C) 2021 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: 2021/03/08 20:34:13 + * File existed as early as: 2021 + * + * chongo /\oo/\ http://www.isthe.com/chongo/ + * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ + */ + +/* + * usage: + * have_strlcpy + * + * Not all systems have the strlcpy() function, so this may not + * compile on your system. + * + * This prog outputs several defines: + * + * HAVE_STRLCPY + * defined ==> use strlcpy() + * undefined ==> do not or cannot call strlcpy() + */ + +#include +#include "have_string.h" +#ifdef HAVE_STRING_H +# include +#endif + + +#include "banned.h" /* include after system header <> includes */ + + +#define BUF_SIZ (sizeof("abcde")-1) + +char src[BUF_SIZ+1] = "abcde"; + + +int +main(void) +{ +#if defined(HAVE_NO_STRLCPY) + + printf("#undef HAVE_STRLCPY /* no */\n"); + +#else /* HAVE_NO_STRLCPY */ + char dst[BUF_SIZ+1]; + + (void) strlcpy(dst, src, sizeof(dst)); + + printf("#define HAVE_STRLCPY /* yes */\n"); + +#endif /* HAVE_NO_STRLCPY */ + + /* exit(0); */ + return 0; +} diff --git a/have_uid_t.c b/have_uid_t.c index d0d4912..7139d5c 100644 --- a/have_uid_t.c +++ b/have_uid_t.c @@ -1,7 +1,7 @@ /* * have_uid_t - Determine if we want or can support uid_t * - * Copyright (C) 1999 Landon Curt Noll + * Copyright (C) 1999,2021 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 @@ -37,7 +37,6 @@ * undefined ==> do not use uid_t */ - #include #if !defined(HAVE_NO_UID_T) @@ -49,6 +48,10 @@ #include #endif /* ! HAVE_NO_UID_T */ + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_unused.c b/have_unused.c index bc9d365..45951b7 100644 --- a/have_unused.c +++ b/have_unused.c @@ -1,7 +1,7 @@ /* * have_unused - Determine if we want or can support the unused attribute * - * Copyright (C) 2004 Landon Curt Noll + * Copyright (C) 2004,2021 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 @@ -42,22 +42,25 @@ * (nothing) ==> unused not used */ - #include + +#include "banned.h" /* include after system header <> includes */ + + #if !defined(HAVE_NO_UNUSED) -/* make sure that we can use the __attribute__((unused)) in #define's */ +/* make sure that we can use the __attribute__((x)) in #define's */ #undef UNUSED -#define UNUSED __attribute__((unused)) +#define UNUSED(x) UNUSED_ ## x __attribute__((unused)) /* * unused_str - a function with an unused argument */ static char * -unused_str(char UNUSED *str) +unused_str(char *UNUSED(str)) { - return "__attribute__((unused))"; + return "UNUSED_ ## x __attribute__((unused))"; } #endif /* !HAVE_NO_UNUSED */ @@ -68,15 +71,17 @@ main(void) { #if defined(HAVE_NO_UNUSED) - printf("#undef HAVE_UNUSED /* no */\n"); printf("#undef UNUSED\n"); - printf("#define UNUSED /* no */\n"); + printf("#if defined(__LCLINT__)\n"); + printf("# define UNUSED(x) /*@unused@*/ x\n"); + printf("#else\n"); + printf("# define UNUSED(x) x\n"); + printf("#endif\n"); #else /* HAVE_NO_UNUSED */ - printf("#define HAVE_UNUSED /* yes */\n"); printf("#undef UNUSED\n"); - printf("#define UNUSED %s /* yes */\n", unused_str(NULL)); + printf("#define UNUSED(x) %s\n", unused_str(NULL)); #endif /* HAVE_NO_UNUSED */ diff --git a/have_ustat.c b/have_ustat.c index 1b3fb36..eb5fa4c 100644 --- a/have_ustat.c +++ b/have_ustat.c @@ -1,7 +1,7 @@ /* * have_ustat - Determine if we have ustat() * - * Copyright (C) 1999 Landon Curt Noll + * Copyright (C) 1999,2021 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 @@ -38,11 +38,15 @@ * undefined ==> do not call or cannot call ustat() */ - +#include #include #include #include + +#include "banned.h" /* include after system header <> includes */ + + int main(void) { diff --git a/have_varvs.c b/have_varvs.c index 0ccf450..846c1ab 100644 --- a/have_varvs.c +++ b/have_varvs.c @@ -1,7 +1,7 @@ /* * have_varvs - try to see if it really works with vsnprintf() * - * Copyright (C) 1999,2018 Landon Curt Noll + * Copyright (C) 1999,2018,2021 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,7 +35,6 @@ * include file. */ - #include #include "have_unistd.h" @@ -56,10 +55,17 @@ # define VSNPRINTF_SIZE_T long #endif +#if !defined(STDARG) && !defined(SIMULATE_STDARG) +#include +#endif + + +#include "banned.h" /* include after system header <> includes */ + + char buf[BUFSIZ+1]; #if !defined(STDARG) && !defined(SIMULATE_STDARG) -#include void try_nthis(char *fmt, VSNPRINTF_SIZE_T size, ...) diff --git a/help.c b/help.c index b48e0ce..70cee67 100644 --- a/help.c +++ b/help.c @@ -45,6 +45,9 @@ #endif +#include "banned.h" /* include after system header <> includes */ + + /* * some help topics are symbols, so we alias them to nice filenames */ diff --git a/help/Makefile b/help/Makefile index 9d14027..eb48305 100644 --- a/help/Makefile +++ b/help/Makefile @@ -27,9 +27,28 @@ # calculator by David I. Bell with help/mods from others # Makefile by Landon Curt Noll -# required vars + +# The shell used by this Makefile +# +# On some systems, /bin/sh is a rather reduced shell with +# deprecated behavor. +# +# If your system has a up to date, bash shell, then +# you may wish to use: +# +# SHELL= /bin/bash +# +# On some systems such as macOS, the bash shell is very +# far behind to the point wehre is cannot be depended on. +# On such systems, the zsh may be a much better alternative +# shell for this Makefile to use: +# +# SHELL= /bin/zsh # SHELL= /bin/sh +#SHELL= /bin/bash +#SHELL= /bin/zsh + #### # Normally, the upper level makefile will set these values. We provide diff --git a/hist.c b/hist.c index 08376c6..a7367d5 100644 --- a/hist.c +++ b/hist.c @@ -52,20 +52,26 @@ #include "calc.h" #include "lib_calc.h" +#include "alloc.h" #include "hist.h" -#include "have_string.h" +#include "strl.h" #include "have_strdup.h" #if !defined(HAVE_STRDUP) # define strdup(x) calc_strdup((CONST char *)(x)) #endif /* HAVE_STRDUP */ +#include "have_string.h" #ifdef HAVE_STRING_H # include #endif #include "have_unused.h" + +#include "banned.h" /* include after system header <> includes */ + + #if !defined(USE_READLINE) E_FUNC FILE *curstream(void); @@ -1490,7 +1496,7 @@ hist_getline(char *prompt, char *buf, size_t len) /*NOTREACHED*/ } } - strncpy(buf, line, len - 1); + strlcpy(buf, line, len); buf[len - 2] = '\0'; len = strlen(buf); buf[len] = '\n'; @@ -1518,7 +1524,7 @@ my_stifle_history (void) int -hist_init(char UNUSED *filename) +hist_init(char *UNUSED(filename)) { /* used when parsing conditionals in ~/.inputrc */ rl_readline_name = "calc"; @@ -1570,7 +1576,7 @@ hist_saveline(char *line, int len) /* * Main routine to test history. */ -void +int main(int argc, char **argv) { char *filename; diff --git a/input.c b/input.c index 8f86cec..61d9c67 100644 --- a/input.c +++ b/input.c @@ -1,7 +1,7 @@ /* * input - nested input source file reader * - * Copyright (C) 1999-2007,2014,2018 David I. Bell + * Copyright (C) 1999-2007,2014,2018,2021 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 @@ -53,6 +53,11 @@ #include "calc.h" #include "conf.h" #include "hist.h" +#include "strl.h" + + +#include "banned.h" /* include after system header <> includes */ + EXTERN int stdin_tty; /* TRUE if stdin is a tty */ E_FUNC FILE *f_open(char *name, char *mode); @@ -135,6 +140,7 @@ opensearchfile(char *name, char *pathlist, char *extension, int rd_once) int i; char *cp; char *path; /* name being searched for */ + size_t path_alloc; /* length of malloced path */ struct stat statbuf; /* stat of the path */ size_t namelen; /* length of name */ size_t extlen; /* length of the extension if non-NULL or 0 */ @@ -181,11 +187,14 @@ opensearchfile(char *name, char *pathlist, char *extension, int rd_once) extlen = 0; } pathlen = strlen(pathlist); - path = malloc(pathlen+1 + 1 + namelen+1 + extlen+1 + 1 + 1); + path_alloc = pathlen+1 + 1 + namelen+1 + extlen+1 + 1 + 1; + path = malloc(path_alloc+1); if (path == NULL) { math_error("Cannot allocate filename path buffer"); /*NOTREACHED*/ } + path[0] = '\0'; /* paranoia */ + path[path_alloc] = '\0'; /* paranoia */ /* * Don't try the extension if the filename already contains it. @@ -206,11 +215,11 @@ opensearchfile(char *name, char *pathlist, char *extension, int rd_once) *cp++ = *pathlist++; if (cp != path) *cp++ = PATHCHAR; - strncpy(cp, name, namelen+1); + strlcpy(cp, name, namelen+1); i = openfile(path); if ((i < 0) && (extension != NULL && extension[0] != '\0')) { - strcat(path, extension); + strlcat(path, extension, path_alloc+1); i = openfile(path); } } while ((i < 0) && *pathlist); @@ -348,7 +357,7 @@ f_pathopen(char *name, char *mode, char *pathlist, char **openpath) *cp++ = *pathlist++; if (cp != path) *cp++ = PATHCHAR; - strncpy(cp, name, namelen+1); + strlcpy(cp, name, namelen+1); ret = f_open(path, mode); } while ((ret == NULL) && *pathlist); @@ -442,23 +451,7 @@ homeexpand(char *name) if (fullpath == NULL) { return NULL; } - /* - * The next statement could be: - * - * strncpy(fullpath, ent->pw_dir, fullpath_len); - * - * however compilers like gcc would issue warnings - * such as: - * - * specified bound depends on the length of the - * source argument - * - * even though we terminate the string by setting a NUL - * byte following the copy. Therefore we call memcpy() - * instead to avoid such warnings. - */ - memcpy(fullpath, ent->pw_dir, fullpath_len); - fullpath[fullpath_len] = '\0'; + strlcpy(fullpath, ent->pw_dir, fullpath_len+1); return fullpath; } username = (char *) malloc(after-name + 1 + 1); @@ -466,8 +459,7 @@ homeexpand(char *name) /* failed to malloc username */ return NULL; } - strncpy(username, name+1, after-name-1); - username[after-name-1] = '\0'; + strlcpy(username, name+1, after-name+1+1); /* get that user's home directory */ ent = (struct passwd *)getpwnam(username); @@ -587,7 +579,7 @@ openfile(char *name) if (cip->i_name == NULL) { return -1; } - strncpy(cip->i_name, name, namelen+1); + strlcpy(cip->i_name, name, namelen+1); return 0; } @@ -623,8 +615,7 @@ openstring(char *str, size_t num) cp = (char *) malloc(num + 1); if (cp == NULL) return -1; - strncpy(cp, str, num); - cp[num] = '\0'; /* firewall */ + strlcpy(cp, str, num+1); cip = inputs + depth++; cip->i_state = IS_READ; cip->i_char = '\0'; @@ -946,10 +937,9 @@ runrcfiles(void) /* load file name into the path */ if (calcrc == NULL) { - strncpy(path, cp, MAX_CALCRC+1); + strlcpy(path, cp, MAX_CALCRC+1); } else { - strncpy(path, cp, calcrc - cp); - path[calcrc - cp] = '\0'; + strlcpy(path, cp, calcrc - cp + 1); } /* find the start of the path */ @@ -1129,7 +1119,7 @@ addreadset(char *name, char *path, struct stat *sbuf) if (readset[ret].name == NULL) { return -1; } - strncpy(readset[ret].name, name, name_len+1); + strlcpy(readset[ret].name, name, name_len+1); #if defined(_WIN32) || defined(__MSDOS__) /* * For WIN32, _fullpath expands the path to a fully qualified @@ -1149,7 +1139,7 @@ addreadset(char *name, char *path, struct stat *sbuf) if (readset[ret].path == NULL) { return -1; } - strncpy(readset[ret].path, path, path_len+1); + strlcpy(readset[ret].path, path, path_len+1); #endif /* Windoz free systems */ readset[ret].inode = *sbuf; readset[ret].active = 1; diff --git a/jump.c b/jump.c index 278c133..aa02778 100644 --- a/jump.c +++ b/jump.c @@ -1,7 +1,7 @@ /* * jump - trivial prime jump table * - * Copyright (C) 1999 Landon Curt Noll + * Copyright (C) 1999,2021 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 @@ -50,6 +50,10 @@ #include "jump.h" + +#include "banned.h" /* include after system header <> includes */ + + /* * jmpindx - how to find the next value not divisible by a trivial prime * diff --git a/label.c b/label.c index abca52f..a2ed2a2 100644 --- a/label.c +++ b/label.c @@ -1,7 +1,7 @@ /* * label - label handling routines * - * Copyright (C) 1999-2007 David I. Bell + * Copyright (C) 1999-2007,2021 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,10 @@ #include "opcodes.h" #include "func.h" + +#include "banned.h" /* include after system header <> includes */ + + STATIC long labelcount; /* number of user labels defined */ STATIC STRINGHEAD labelnames; /* list of user label names */ STATIC LABEL labels[MAXLABELS]; /* list of user labels */ diff --git a/lib_calc.c b/lib_calc.c index ec50d0f..c7587f5 100644 --- a/lib_calc.c +++ b/lib_calc.c @@ -41,6 +41,7 @@ #include "token.h" #include "symbol.h" #include "func.h" +#include "strl.h" #if defined(CUSTOM) #include "custom.h" @@ -92,6 +93,10 @@ typedef struct {int fd;} ttystruct; # endif #endif /* Windoz */ + +#include "banned.h" /* include after system header <> includes */ + + /* * in case we do not have certain .h files */ @@ -692,7 +697,7 @@ calc_strdup(CONST char *s1) * if we have storage, duplicate the string */ if (ret != NULL) { - strncpy(ret, s1, s1_len+1); + strlcpy(ret, s1, s1_len+1); } /* diff --git a/lib_util.c b/lib_util.c index 0271ed9..52cc425 100644 --- a/lib_util.c +++ b/lib_util.c @@ -31,9 +31,13 @@ #include "zmath.h" +#include "alloc.h" #include "lib_util.h" +#include "banned.h" /* include after system header <> includes */ + + /* * lowhex2bin - quick low order ASCII hex to binary conversion * diff --git a/listfunc.c b/listfunc.c index 6a9cb1e..51bae22 100644 --- a/listfunc.c +++ b/listfunc.c @@ -1,7 +1,7 @@ /* * listfunc - list handling routines * - * Copyright (C) 1999-2007 David I. Bell + * Copyright (C) 1999-2007,2021 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,10 @@ #include "value.h" #include "zrand.h" + +#include "banned.h" /* include after system header <> includes */ + + E_FUNC long irand(long s); S_FUNC LISTELEM *elemalloc(void); diff --git a/longbits.c b/longbits.c index dcd8eac..76339d1 100644 --- a/longbits.c +++ b/longbits.c @@ -1,7 +1,7 @@ /* * longbits - Determine the number if bits in a char, short, int or long * - * Copyright (C) 1999-2007,2014 Landon Curt Noll + * Copyright (C) 1999-2007,2014,2021 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 @@ -92,6 +92,10 @@ # include #endif + +#include "banned.h" /* include after system header <> includes */ + + char *program; /* our name */ int diff --git a/matfunc.c b/matfunc.c index e31182d..15e9d15 100644 --- a/matfunc.c +++ b/matfunc.c @@ -28,12 +28,17 @@ * Matrices can contain arbitrary types of elements. */ +#include "alloc.h" #include "value.h" #include "zrand.h" #include "calcerr.h" #include "have_unused.h" + +#include "banned.h" /* include after system header <> includes */ + + E_FUNC long irand(long s); S_FUNC void matswaprow(MATRIX *m, long r1, long r2); @@ -851,7 +856,7 @@ matfrac(MATRIX *m) */ /*ARGSUSED*/ VALUE * -matindex(MATRIX *mp, BOOL UNUSED create, long dim, VALUE *indices) +matindex(MATRIX *mp, BOOL UNUSED(create), long dim, VALUE *indices) { NUMBER *q; /* index value */ VALUE *vp; diff --git a/math_error.c b/math_error.c index 3029502..41670f2 100644 --- a/math_error.c +++ b/math_error.c @@ -65,6 +65,9 @@ #include "lib_calc.h" +#include "banned.h" /* include after system header <> includes */ + + /* * math_error - print a math error and exit */ diff --git a/obj.c b/obj.c index 61e98b0..816d8b3 100644 --- a/obj.c +++ b/obj.c @@ -1,7 +1,7 @@ /* * obj - object handling primitives * - * Copyright (C) 1999-2007 David I. Bell + * Copyright (C) 1999-2007,2021 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 @@ -35,6 +35,10 @@ #include "func.h" #include "symbol.h" #include "str.h" +#include "strl.h" + + +#include "banned.h" /* include after system header <> includes */ /* @@ -210,6 +214,9 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) char *namestr_ret; /* namestr() return string */ size_t opi_name_len; /* length of the oip name */ + /* initilaize name */ + memset(name, 0, sizeof(name)); + /* initialize VALUEs */ val.v_subtype = V_NOSUBTYPE; tmp.v_subtype = V_NOSUBTYPE; @@ -241,9 +248,9 @@ objcall(int action, VALUE *v1, VALUE *v2, VALUE *v3) /*NOTREACHED*/ } name[0] = '\0'; - strncpy(name, namestr_ret, namestr_len+1); - strcat(name, "_"); - strncat(name, oip->name, opi_name_len+1); + strlcpy(name, namestr_ret, namestr_len+1); + strlcat(name, "_", sizeof(name)); + strlcat(name, oip->name, sizeof(name)); index = adduserfunc(name); oap->oa_indices[action] = index; } diff --git a/opcodes.c b/opcodes.c index adce0d1..3ba7103 100644 --- a/opcodes.c +++ b/opcodes.c @@ -1,7 +1,7 @@ /* * opcodes - opcode execution module * - * Copyright (C) 1999-2007 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -46,6 +46,10 @@ #include "have_unused.h" + +#include "banned.h" /* include after system header <> includes */ + + #define QUICKLOCALS 20 /* local vars to handle quickly */ @@ -161,7 +165,7 @@ o_localaddr(FUNC *fp, VALUE *locals, long index) /*ARGSUSED*/ S_FUNC void -o_globaladdr(FUNC UNUSED *fp, GLOBAL *sp) +o_globaladdr(FUNC *UNUSED(fp), GLOBAL *sp) { if (sp == NULL) { math_error("Global variable \"%s\" not initialized", @@ -177,7 +181,7 @@ o_globaladdr(FUNC UNUSED *fp, GLOBAL *sp) /*ARGSUSED*/ S_FUNC void -o_paramaddr(FUNC UNUSED *fp, int argcount, VALUE *args, long index) +o_paramaddr(FUNC *UNUSED(fp), int argcount, VALUE *args, long index) { if ((long)index >= argcount) { math_error("Bad parameter index"); @@ -209,7 +213,7 @@ o_localvalue(FUNC *fp, VALUE *locals, long index) /*ARGSUSED*/ S_FUNC void -o_globalvalue(FUNC UNUSED *fp, GLOBAL *sp) +o_globalvalue(FUNC *UNUSED(fp), GLOBAL *sp) { if (sp == NULL) { math_error("Global variable not defined"); @@ -221,7 +225,7 @@ o_globalvalue(FUNC UNUSED *fp, GLOBAL *sp) /*ARGSUSED*/ S_FUNC void -o_paramvalue(FUNC UNUSED *fp, int argcount, VALUE *args, long index) +o_paramvalue(FUNC *UNUSED(fp), int argcount, VALUE *args, long index) { if ((long)index >= argcount) { math_error("Bad parameter index"); @@ -266,7 +270,7 @@ o_argvalue(FUNC *fp, int argcount, VALUE *args) /*ARGSUSED*/ S_FUNC void -o_number(FUNC UNUSED *fp, long arg) +o_number(FUNC *UNUSED(fp), long arg) { NUMBER *q; @@ -284,7 +288,7 @@ o_number(FUNC UNUSED *fp, long arg) /*ARGSUSED*/ S_FUNC void -o_imaginary(FUNC UNUSED *fp, long arg) +o_imaginary(FUNC *UNUSED(fp), long arg) { NUMBER *q; COMPLEX *c; @@ -311,7 +315,7 @@ o_imaginary(FUNC UNUSED *fp, long arg) /*ARGSUSED*/ S_FUNC void -o_string(FUNC UNUSED *fp, long arg) +o_string(FUNC *UNUSED(fp), long arg) { stack++; stack->v_str = slink(findstring(arg)); @@ -331,7 +335,7 @@ o_undef(void) /*ARGSUSED*/ S_FUNC void -o_matcreate(FUNC UNUSED *fp, long dim) +o_matcreate(FUNC *UNUSED(fp), long dim) { register MATRIX *mp; /* matrix being defined */ NUMBER *num1; /* first number from stack */ @@ -399,7 +403,7 @@ o_matcreate(FUNC UNUSED *fp, long dim) /*ARGSUSED*/ S_FUNC void -o_eleminit(FUNC UNUSED *fp, long index) +o_eleminit(FUNC *UNUSED(fp), long index) { VALUE *vp; STATIC VALUE *oldvp; @@ -540,7 +544,7 @@ o_eleminit(FUNC UNUSED *fp, long index) */ /*ARGSUSED*/ S_FUNC void -o_indexaddr(FUNC UNUSED *fp, long dim, long writeflag) +o_indexaddr(FUNC *UNUSED(fp), long dim, long writeflag) { int i; BOOL flag; @@ -693,7 +697,7 @@ o_indexaddr(FUNC UNUSED *fp, long dim, long writeflag) /*ARGSUSED*/ S_FUNC void -o_elemaddr(FUNC UNUSED *fp, long index) +o_elemaddr(FUNC *UNUSED(fp), long index) { VALUE *vp; MATRIX *mp; @@ -748,7 +752,7 @@ o_elemvalue(FUNC *fp, long index) /*ARGSUSED*/ S_FUNC void -o_objcreate(FUNC UNUSED *fp, long arg) +o_objcreate(FUNC *UNUSED(fp), long arg) { stack++; stack->v_type = V_OBJ; @@ -2558,7 +2562,7 @@ o_return(void) /*ARGSUSED*/ S_FUNC void -o_jumpz(FUNC UNUSED *fp, BOOL *dojump) +o_jumpz(FUNC *UNUSED(fp), BOOL *dojump) { VALUE *vp; int i; /* result of comparison */ @@ -2582,7 +2586,7 @@ o_jumpz(FUNC UNUSED *fp, BOOL *dojump) /*ARGSUSED*/ S_FUNC void -o_jumpnz(FUNC UNUSED *fp, BOOL *dojump) +o_jumpnz(FUNC *UNUSED(fp), BOOL *dojump) { VALUE *vp; int i; /* result of comparison */ @@ -2609,7 +2613,7 @@ o_jumpnz(FUNC UNUSED *fp, BOOL *dojump) */ /*ARGSUSED*/ S_FUNC void -o_jumpnn(FUNC UNUSED *fp, BOOL *dojump) +o_jumpnn(FUNC *UNUSED(fp), BOOL *dojump) { if (stack->v_addr->v_type) { *dojump = TRUE; @@ -2620,7 +2624,7 @@ o_jumpnn(FUNC UNUSED *fp, BOOL *dojump) /*ARGSUSED*/ S_FUNC void -o_condorjump(FUNC UNUSED *fp, BOOL *dojump) +o_condorjump(FUNC *UNUSED(fp), BOOL *dojump) { VALUE *vp; @@ -2646,7 +2650,7 @@ o_condorjump(FUNC UNUSED *fp, BOOL *dojump) /*ARGSUSED*/ S_FUNC void -o_condandjump(FUNC UNUSED *fp, BOOL *dojump) +o_condandjump(FUNC *UNUSED(fp), BOOL *dojump) { VALUE *vp; @@ -2677,7 +2681,7 @@ o_condandjump(FUNC UNUSED *fp, BOOL *dojump) */ /*ARGSUSED*/ S_FUNC void -o_casejump(FUNC UNUSED *fp, BOOL *dojump) +o_casejump(FUNC *UNUSED(fp), BOOL *dojump) { VALUE *v1, *v2; int r; @@ -2699,7 +2703,7 @@ o_casejump(FUNC UNUSED *fp, BOOL *dojump) /*ARGSUSED*/ S_FUNC void -o_jump(FUNC UNUSED *fp, BOOL *dojump) +o_jump(FUNC *UNUSED(fp), BOOL *dojump) { *dojump = TRUE; } @@ -2719,7 +2723,7 @@ o_usercall(FUNC *fp, long index, long argcount) /*ARGSUSED*/ S_FUNC void -o_call(FUNC UNUSED *fp, long index, long argcount) +o_call(FUNC *UNUSED(fp), long index, long argcount) { VALUE result; @@ -3101,7 +3105,7 @@ o_rightshift(void) /*ARGSUSED*/ S_FUNC void -o_debug(FUNC UNUSED *fp, long line) +o_debug(FUNC *UNUSED(fp), long line) { funcline = line; if (abortlevel >= ABORT_STATEMENT) { @@ -3142,7 +3146,7 @@ o_printresult(void) /*ARGSUSED*/ S_FUNC void -o_print(FUNC UNUSED *fp, long flags) +o_print(FUNC *UNUSED(fp), long flags) { VALUE *vp; @@ -3176,7 +3180,7 @@ o_printspace(void) /*ARGSUSED*/ S_FUNC void -o_printstring(FUNC UNUSED *fp, long index) +o_printstring(FUNC *UNUSED(fp), long index) { STRING *s; char *cp; diff --git a/pix.c b/pix.c index 8188fae..8e04ad1 100644 --- a/pix.c +++ b/pix.c @@ -1,7 +1,7 @@ /* * pix - number of primes less than a small value * - * Copyright (C) 1999 Landon Curt Noll + * Copyright (C) 1999,2021 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 @@ -30,6 +30,9 @@ #include "have_const.h" +#include "banned.h" /* include after system header <> includes */ + + /* * pi10b - number of primes <= 2^18 in multiples of 2^10 * diff --git a/poly.c b/poly.c index 2329deb..5945f36 100644 --- a/poly.c +++ b/poly.c @@ -1,7 +1,7 @@ /* * poly - polynomial functions * - * Copyright (C) 1999 Ernest Bowen and Landon Curt Noll + * Copyright (C) 1999,2021 Ernest Bowen and Landon Curt Noll * * Primary author: Ernest Bowen * @@ -30,6 +30,9 @@ #include "value.h" +#include "banned.h" /* include after system header <> includes */ + + BOOL evp(LISTELEM *cp, LISTELEM *x, VALUE *vres) { diff --git a/prime.c b/prime.c index 693e65e..d1e817a 100644 --- a/prime.c +++ b/prime.c @@ -1,7 +1,7 @@ /* * prime - quickly determine if a small number is prime * - * Copyright (C) 1999-2007 Landon Curt Noll + * Copyright (C) 1999-2007,2021 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 @@ -31,6 +31,9 @@ #include "have_const.h" +#include "banned.h" /* include after system header <> includes */ + + /* * odd prime bitmap for odd values < 2^16 * diff --git a/qfunc.c b/qfunc.c index 07ae1f4..46ef72c 100644 --- a/qfunc.c +++ b/qfunc.c @@ -30,6 +30,10 @@ #include "config.h" #include "prime.h" + +#include "banned.h" /* include after system header <> includes */ + + STATIC NUMBER **B_table; STATIC long B_num; STATIC long B_allocnum; diff --git a/qio.c b/qio.c index 9541cd8..d3170c2 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 David I. Bell + * Copyright (C) 1999-2007,2021 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,9 @@ #include "have_unused.h" +#include "banned.h" /* include after system header <> includes */ + + #define PUTCHAR(ch) math_chr(ch) #define PUTSTR(str) math_str(str) #define PRINTF1(fmt, a1) math_fmt(fmt, a1) @@ -322,7 +325,7 @@ qprintff(NUMBER *q, long width, long precision) */ /*ARGSUSED*/ void -qprintfe(NUMBER *q, long UNUSED width, long precision) +qprintfe(NUMBER *q, long UNUSED(width), long precision) { long exponent; NUMBER q2; diff --git a/qmath.c b/qmath.c index 9e8738a..4c95359 100644 --- a/qmath.c +++ b/qmath.c @@ -31,6 +31,9 @@ #include "config.h" +#include "banned.h" /* include after system header <> includes */ + + NUMBER _qzero_ = { { _zeroval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL }; NUMBER _qone_ = { { _oneval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL }; NUMBER _qtwo_ = { { _twoval_, 1, 0 }, { _oneval_, 1, 0 }, 1, NULL }; diff --git a/qmod.c b/qmod.c index 9f30699..b84fc9a 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 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -31,6 +31,9 @@ #include "config.h" +#include "banned.h" /* include after system header <> includes */ + + /* * Structure used for caching REDC information. */ diff --git a/qtrans.c b/qtrans.c index 9f500c7..b15811c 100644 --- a/qtrans.c +++ b/qtrans.c @@ -33,6 +33,10 @@ #include "qmath.h" + +#include "banned.h" /* include after system header <> includes */ + + HALF _qlgenum_[] = { 36744 }; HALF _qlgeden_[] = { 25469 }; NUMBER _qlge_ = { { _qlgenum_, 1, 0 }, { _qlgeden_, 1, 0 }, 1, NULL }; diff --git a/quickhash.c b/quickhash.c index aa43a1c..5b84606 100644 --- a/quickhash.c +++ b/quickhash.c @@ -39,6 +39,10 @@ #include "zrand.h" #include "zrandom.h" + +#include "banned.h" /* include after system header <> includes */ + + /* * forward declarations */ diff --git a/rpm.mk b/rpm.mk index 5960465..9acce39 100644 --- a/rpm.mk +++ b/rpm.mk @@ -106,11 +106,30 @@ TMPDIR= ${RPM_TOP}/tmp # Q=@ do not echo internal Makefile actions (quiet mode) # Q= echo internal Makefile actions (debug / verbose mode) # +# H=@: do not report hsrc file formation progress +# H=@ do echo hsrc file formation progress +# +# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation +# S= full ${CC} output during hsrc file formation +# +# E= 2>/dev/null slience command stderr during hsrc file formation +# E= full command stderr during hsrc file formation +# # V=@: do not echo debug statements (quiet mode) # V=@ do echo debug statements (debug / verbose mode) # #Q= Q=@ +# +S= >/dev/null 2>&1 +#S= +# +E= 2>/dev/null +#E= +# +#H=@: +H=@ +# V=@: #V=@ @@ -121,20 +140,20 @@ all: ver_calc calc.spec -e '/^Release:/s/^Release: *//p' calc.spec.in`"; \ $(MAKE) -f rpm.mk rpm \ PROJECT_VERSION="$$PROJECT_VERSION" \ - PROJECT_RELEASE="$$PROJECT_RELEASE" + PROJECT_RELEASE="$$PROJECT_RELEASE" Q= S= E= ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-=' pkgme: $(PROJECT_NAME)-spec.${TAR}.bz2 ver_calc: ${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-=' - $(MAKE) -f Makefile ver_calc + $(MAKE) -f Makefile ver_calc Q= S= E= ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-=' .PHONY: vers vers: ${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-=' - $(MAKE) -f Makefile ver_calc + $(MAKE) -f Makefile ver_calc Q= S= E= ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-=' calc.spec: calc.spec.in ver_calc @@ -174,7 +193,7 @@ rpm: srcpkg calc.spec ${V} echo RPM_BUILD_ROOT="${RPM_BUILD_ROOT}" ${V} echo PROJECT_VERSION="${PROJECT_VERSION}" ${V} echo PROJECT_RELEASE="${PROJECT_RELEASE}" - $(MAKE) -f Makefile clean + $(MAKE) -f Makefile clean Q= S= E= ${CP} "$(SPECFILE)" "$(RPM_TOP)/SPECS/$(SPECFILE)" ${RM} -f "$(RPM_TOP)/RPMS/$(TARCH)/$(RPMx86_64)" ${RM} -f "$(RPM_TOP)/RPMS/$(TARCH)/$(DRPMx86_64)" @@ -270,7 +289,8 @@ test: ver_calc echo "test needs to install, must be root to test" 1>&2; \ exit 6; \ fi - $(MAKE) -f rpm.mk PROJECT_VERSION="`./ver_calc`" installrpm chksys + $(MAKE) -f rpm.mk PROJECT_VERSION="`./ver_calc`" installrpm \ + chksys Q= S= E= ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-=' .PHONY: installrpm diff --git a/sample_many.c b/sample_many.c index 80de5a1..f455866 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 Landon Curt Noll + * Copyright (C) 1999-2007,2021 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,10 @@ #include "have_const.h" #include "lib_util.h" + +#include "banned.h" /* include after system header <> includes */ + + #define DEF_CNT 128 /* default number of bits to generate */ #define RESEED 1000 /* number of random numbers to generate */ #define MANY 100 /* number of random numbers to generate */ diff --git a/sample_rand.c b/sample_rand.c index 9dffe14..66390cd 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 Landon Curt Noll + * Copyright (C) 1999-2007,2021 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,10 @@ #include "have_const.h" #include "lib_util.h" + +#include "banned.h" /* include after system header <> includes */ + + #define DEF_CNT 128 /* default number of bits to generate */ extern char *program; /* our name */ diff --git a/seed.c b/seed.c index d13083b..7509958 100644 --- a/seed.c +++ b/seed.c @@ -79,6 +79,7 @@ # include #endif #include +#include "alloc.h" #include "qmath.h" #include "longbits.h" #include "have_ustat.h" @@ -99,6 +100,9 @@ #endif +#include "banned.h" /* include after system header <> includes */ + + /* * 64 bit hash value */ diff --git a/sha1.c b/sha1.c index f4f96f9..d963098 100644 --- a/sha1.c +++ b/sha1.c @@ -27,6 +27,7 @@ #include +#include "alloc.h" #include "longbits.h" #include "align32.h" #include "endian_calc.h" @@ -35,6 +36,9 @@ #include "sha1.h" +#include "banned.h" /* include after system header <> includes */ + + /* * The SHA1 f()-functions. The f1 and f3 functions can be optimized * to save one boolean operation each - thanks to Rich Schroeppel, diff --git a/size.c b/size.c index 0534a88..5421f16 100644 --- a/size.c +++ b/size.c @@ -1,7 +1,7 @@ /* * size - size and sizeof functions are implemented here * - * Copyright (C) 1999-2007 David I. Bell + * Copyright (C) 1999-2007,2021 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,9 @@ #include "block.h" +#include "banned.h" /* include after system header <> includes */ + + /* * forward declarations */ diff --git a/str.c b/str.c index 9cb0f7a..ad351b9 100644 --- a/str.c +++ b/str.c @@ -1,7 +1,7 @@ /* * str - string list routines * - * Copyright (C) 1999-2007 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -28,12 +28,22 @@ #include #include +#include "have_string.h" +#ifdef HAVE_STRING_H +# include +#endif #include "calc.h" +#include "alloc.h" #include "str.h" +#include "strl.h" + + +#include "banned.h" /* include after system header <> includes */ + #define STR_TABLECHUNK 100 /* how often to reallocate string table */ -#define STR_CHUNK 2000 /* size of string storage allocation */ -#define STR_UNIQUE 100 /* size of string to allocate separately */ +#define STR_CHUNK (1<<11) /* size of string storage allocation */ +#define STR_UNIQUE (1<<7) /* size of string to allocate separately */ STRING _nullstring_ = {"", 0, 1, NULL}; @@ -107,7 +117,7 @@ addstr(STRINGHEAD *hp, char *str) hp->h_used += len; hp->h_avail -= len; hp->h_count++; - strcpy(retstr, str); + strlcpy(retstr, str, len); retstr[len] = '\0'; return retstr; } @@ -279,15 +289,19 @@ addliteral(char *str) table = literals.l_table; /* * If the new string is very long, allocate it manually. + * + * Add room for trailing NUL and then round up to a + * memory chunk (in this case we pick the size of a FULL + * just because that is a nice size) for extra padded room. */ - len = (len + 2) & ~1; /* add room for null and round up to word */ + len = ROUNDUP(len+1, FULL_LEN); if (len >= STR_UNIQUE) { newstr = (char *)malloc(len); if (newstr == NULL) { math_error("Cannot allocate large literal string"); /*NOTREACHED*/ } - strcpy(newstr, str); + strlcpy(newstr, str, len); table[literals.l_count++] = newstr; return newstr; } @@ -311,7 +325,7 @@ addliteral(char *str) literals.l_avail -= len; literals.l_alloc += len; table[literals.l_count++] = newstr; - strcpy(newstr, str); + strlcpy(newstr, str, len); return newstr; } diff --git a/str.h b/str.h index 18887e3..a4a1434 100644 --- a/str.h +++ b/str.h @@ -24,8 +24,8 @@ */ -#if !defined(INCLUDE_CALCSTRING_H) -#define INCLUDE_CALCSTRING_H +#if !defined(INCLUDE_STR_H) +#define INCLUDE_STR_H #if defined(CALC_SRC) /* if we are building from the calc source tree */ @@ -35,6 +35,7 @@ #endif + struct string { char *s_str; size_t s_len; @@ -52,6 +53,7 @@ typedef struct { long h_count; /* number of strings */ } STRINGHEAD; +EXTERN STRING _nullstring_; E_FUNC void initstr(STRINGHEAD *hp); E_FUNC char *addstr(STRINGHEAD *hp, char *str); @@ -72,7 +74,6 @@ E_FUNC void fitstring(char *, long, long); E_FUNC void strprint(STRING *); E_FUNC void showstrings(void); E_FUNC void showliterals(void); -EXTERN STRING _nullstring_; -#endif /* !INCLUDE_CALCSTRING_H */ +#endif /* !INCLUDE_STR_H */ diff --git a/strl.c b/strl.c new file mode 100644 index 0000000..130c36d --- /dev/null +++ b/strl.c @@ -0,0 +1,301 @@ +/* + * strl - size-bounded string copying and concatenation + * + * Copyright (C) 2021 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: 2021/03/08 21;58:10 + * File existed as early as: 2021 + * + * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ + */ + + +#include "have_string.h" +#ifdef HAVE_STRING_H +# include +#endif +#include "strl.h" +#include "alloc.h" + +#if defined(STRL_TEST) +#include +#include +#endif /* STRL_TEST */ + + +#include "banned.h" /* include after system header <> includes */ + + +#if !defined(HAVE_STRLCPY) || defined(STRL_TEST) +/* + * calc_strlcpy - calc STRL_TEST test version of strlcpy + * strlcpy - size-bounded string copying + * + * The strlcpy() functions copies up to dstsize-1 characters from the + * string src to dst, NUL-terminating the result if dstsize > 0. + * + * This function attempts to simulate strlcpy() on systems that + * do not have this function in their C library. + * + * given: + * dst destination string + * src source string + * dstsize size of the destination string buffer including NUL + * + * returns: + * total length of source string excluding NUL, + * 0 ==> invalid arguments + * + * NOTE: If return value is >= dstsize, the result was truncated. + * I.e., there was not enough room in dst and so the copy + * was stopped before it would have overflowed and was NUL terminated. + */ +#if defined(STRL_TEST) +size_t +calc_strlcpy(char * dst, const char * src, size_t dstsize) +#else /* STRL_TEST */ +size_t +strlcpy(char * dst, const char * src, size_t dstsize) +#endif /* STRL_TEST */ +{ + size_t srclen; /* src string length not including NUL */ + + /* + * firewall + */ + if (dst == NULL || src == NULL || dstsize <= 0) { + /* nothing can be copied */ +#if defined(STRL_TEST) + printf("in %s: return 0\n", __FUNCTION__); +#endif /* STRL_TEST */ + return 0; + } + + /* + * determine how much string we could copy + */ + srclen = strlen(src); + + /* + * perform the size limited copy and NUL terminate + */ + if (srclen > dstsize-1) { + memcpy(dst, src, dstsize-1); + dst[dstsize-1] = '\0'; +#if defined(STRL_TEST) + printf("in %s: if memcpy(\"%s\", \"%s\", %zu)\n", + __FUNCTION__, dst, src, dstsize-1); +#endif /* STRL_TEST */ + } else { + memcpy(dst, src, srclen); + dst[srclen] = '\0'; +#if defined(STRL_TEST) + printf("in %s: else memcpy(\"%s\", \"%s\", %zu)\n", + __FUNCTION__, dst, src, srclen); +#endif /* STRL_TEST */ + } + + /* + * return the length we tried to copy, not including NUL + */ +#if defined(STRL_TEST) + printf("in %s: return %zu\n", __FUNCTION__, srclen); +#endif /* STRL_TEST */ + return srclen; +} +#endif /* !HAVE_STRLCPY || STRL_TEST */ + + +#if !defined(HAVE_STRLCAT) || defined(STRL_TEST) +/* + * calc_strlcat - calc STRL_TEST test version of strlcat + * strlcat - size-bounded string cat + * + * The strlcat() appends string src to the end of dst. + * At most, dstsize - strlen(dst) - 1 characters will of appended. + * + * This function attempts to simulate strlcat() on systems that + * do not have this function in their C library. + * + * given: + * dst destination string + * src source string + * dstsize size of the destination string buffer including NUL + * + * returns: + * total length of string could have been copied excluding NUL, + * 0 ==> invalid arguments + * + * NOTE: If return value is >= dstsize, the output string was truncated. + * I.e., there was not enough room and so the result was truncated + * and NUL terminated. + */ +#if defined(STRL_TEST) +size_t +calc_strlcat(char * dst, const char * src, size_t dstsize) +#else /* STRL_TEST */ +size_t +strlcat(char * dst, const char * src, size_t dstsize) +#endif /* STRL_TEST */ +{ + size_t srclen; /* src string length not including NUL */ + size_t dstlen; /* dst string length not including NUL */ + size_t catlen; /* amount from src we can copy */ + + /* + * firewall + */ + if (dst == NULL || src == NULL || dstsize <= 0) { + /* nothing can be concatinated */ +#if defined(STRL_TEST) + printf("in %s: return 0\n", __FUNCTION__); +#endif /* STRL_TEST */ + return 0; + } + + /* + * prep to determine the room we have + */ + dstlen = strlen(dst); + srclen = strlen(src); +#if defined(STRL_TEST) + printf("in %s: dst = ((%s)) src = ((%s)) dstsize = %zu\n", + __FUNCTION__, dst, src, dstsize); + printf("in %s: dstlen = %zu srclen = %zu\n", + __FUNCTION__, dstlen, srclen); +#endif /* STRL_TEST */ + if (dstsize <= dstlen+1) { + /* dst is already full */ +#if defined(STRL_TEST) + printf("in %s: dstsize: %zu <= dstlen+1: %zu\n", + __FUNCTION__, dstsize, dstlen+1); + printf("in %s: already full return %zu\n", + __FUNCTION__, srclen+dstlen); +#endif /* STRL_TEST */ + return srclen+dstlen; + } + + /* + * determine the amount data we can copy + */ + catlen = dstsize - dstlen; + + /* + * perform the cancatimation + */ + dst += dstlen; +#if defined(STRL_TEST) + printf("in %s: catlen = %zu\n", __FUNCTION__, catlen); +#endif /* STRL_TEST */ + if (catlen > srclen+1) { + memcpy(dst, src, srclen); + dst[srclen] = '\0'; +#if defined(STRL_TEST) + printf("in %s: if memcpy(\"%s\", \"%s\", %zu)\n", + __FUNCTION__, dst, src, srclen); +#endif /* STRL_TEST */ + } else { + memcpy(dst, src, catlen); + dst[catlen] = '\0'; +#if defined(STRL_TEST) + printf("in %s: if memcpy(\"%s\", \"%s\", %zu)\n", + __FUNCTION__, dst, src, catlen); +#endif /* STRL_TEST */ + } + + /* + * return the length, not including NUL, of what could have been formed + */ +#if defined(STRL_TEST) + printf("in %s: return %zu\n", __FUNCTION__, srclen+dstlen); +#endif /* STRL_TEST */ + return srclen+dstlen; +} +#endif /* !HAVE_STRLCAT || STRL_TEST */ + +#if defined(STRL_TEST) + +static char src[] = "abcde"; /* test source string */ + +/* + * Main routine to test the strlcpy() and strlcat() functions. + */ +int +main(int argc, char **argv) +{ + char dst[sizeof(src)]; /* test destination string */ + size_t ret; /* strlcpy() or strlcat() return */ + + /* + * normal copy + */ + memset(dst, 0, sizeof(dst)); + printf("src: %s\n", src); + ret = calc_strlcpy(dst, src, sizeof(dst)); + printf("ret: %zu\n", ret); + printf("dst: %s\n\n", dst); + + /* + * truncated copy + */ + memset(dst, 0, sizeof(dst)); + printf("src: %s\n", src); + ret = calc_strlcpy(dst, src, sizeof(dst)-3); + printf("ret: %zu\n", ret); + printf("dst: %s\n\n", dst); + + /* + * overcat + */ + printf("src: %s\n", src); + ret = calc_strlcat(dst, src, sizeof(dst)); + printf("ret: %zu\n", ret); + printf("dst: %s\n\n", dst); + + /* + * fullcat + */ + printf("src: %s\n", src); + ret = calc_strlcat(dst, src, sizeof(dst)); + printf("ret: %zu\n", ret); + printf("dst: %s\n\n", dst); + + /* + * nilcat + */ + dst[0] = '\0'; + printf("src: %s\n", src); + ret = calc_strlcat(dst, src, sizeof(dst)); + printf("ret: %zu\n", ret); + printf("dst: %s\n\n", dst); + + /* + * shortcat + */ + dst[1] = '\0'; + printf("src: %s\n", src); + ret = calc_strlcat(dst, src, sizeof(dst)-3); + printf("ret: %zu\n", ret); + printf("dst: %s\n\n", dst); + + /* + * all done + */ + exit(0); +} + +#endif /* STRL_TEST */ diff --git a/strl.h b/strl.h new file mode 100644 index 0000000..56e72b0 --- /dev/null +++ b/strl.h @@ -0,0 +1,59 @@ +/* + * strl - size-bounded string copying and concatenation + * + * Copyright (C) 2021 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: 2021/03/08 21;58:10 + * File existed as early as: 2021 + * + * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ + */ + + +#if !defined(INCLUDE_STRL_H) +#define INCLUDE_STRL_H + + +#if defined(CALC_SRC) /* if we are building from the calc source tree */ +#include "have_string.h" +#else +#include +#endif +#ifdef HAVE_STRING_H +# include +#endif + +#if defined(CALC_SRC) /* if we are building from the calc source tree */ +# include "have_strlcpy.h" +# include "have_strlcat.h" +# include "decl.h" +#else +# include +# include +# include +#endif + +#if !defined(HAVE_STRLCPY) +E_FUNC size_t strlcpy(char * dst, const char * src, size_t dstsize); +#endif /* !HAVE_STRLCPY */ + +#if !defined(HAVE_STRLCAT) +E_FUNC size_t strlcat(char * dst, const char * src, size_t dstsize); +#endif /* !HAVE_STRLCAT */ + + +#endif /* !INCLUDE_STRL_H */ diff --git a/symbol.c b/symbol.c index aa101b8..31fddee 100644 --- a/symbol.c +++ b/symbol.c @@ -1,7 +1,7 @@ /* * symbol - global and local symbol routines * - * Copyright (C) 1999-2007 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -34,6 +34,10 @@ #include "opcodes.h" #include "func.h" + +#include "banned.h" /* include after system header <> includes */ + + #define HASHSIZE 37 /* size of hash table */ E_FUNC FILE *f_open(char *name, char *mode); diff --git a/token.c b/token.c index fedee85..1829746 100644 --- a/token.c +++ b/token.c @@ -1,7 +1,7 @@ /* * token - read input file characters into tokens * - * Copyright (C) 1999-2007,2017 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2017,2021 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -30,12 +30,16 @@ #include #include "calc.h" +#include "alloc.h" #include "token.h" #include "str.h" #include "args.h" #include "lib_calc.h" +#include "banned.h" /* include after system header <> includes */ + + #define isletter(ch) ((((ch) >= 'a') && ((ch) <= 'z')) || \ (((ch) >= 'A') && ((ch) <= 'Z'))) #define isdigit(ch) (((ch) >= '0') && ((ch) <= '9')) diff --git a/value.c b/value.c index dd0fbee..5a9212f 100644 --- a/value.c +++ b/value.c @@ -1,7 +1,7 @@ /* * value - generic value manipulation routines * - * Copyright (C) 1999-2007,2014,2017 David I. Bell + * Copyright (C) 1999-2007,2014,2017,2021 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,10 @@ #include "file.h" #include "config.h" + +#include "banned.h" /* include after system header <> includes */ + + #define LINELEN 80 /* length of a typical tty line */ /* diff --git a/value.h b/value.h index 5cbefa0..5fe0b41 100644 --- a/value.h +++ b/value.h @@ -1,7 +1,7 @@ /* * value - definitions of general values and related routines used by calc * - * Copyright (C) 1999-2007,2014 David I. Bell + * Copyright (C) 1999-2007,2014,2021 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 diff --git a/version.c b/version.c index dc2db31..43b9f5f 100644 --- a/version.c +++ b/version.c @@ -29,7 +29,10 @@ #include #include -#include +#include "have_string.h" +#ifdef HAVE_STRING_H +# include +#endif #if defined(CALC_VER) # include @@ -39,13 +42,19 @@ static char *program; #else # include "calc.h" #endif +#include "str.h" +#include "strl.h" #include "have_unused.h" + +#include "banned.h" /* include after system header <> includes */ + + #define MAJOR_VER 2 /* major library version */ #define MINOR_VER 12 /* minor library version */ -#define MAJOR_PATCH 8 /* major software version level */ -#define MINOR_PATCH 2 /* minor software version level */ +#define MAJOR_PATCH 9 /* major software version level */ +#define MINOR_PATCH 0 /* minor software version level */ /* @@ -131,22 +140,7 @@ version(void) fprintf(stderr, "%s: cannot malloc version string\n", program); exit(70); } - /* - * The next statement could be: - * - * strncpy(stored_version, verbuf, len); - * - * however compilers like gcc would issue warnings such as: - * - * specified bound depends on the length of the - * source argument - * - * even though we terminate the string by setting a NUL - * byte following the copy. Therefore we call memcpy() - * instead to avoid such warnings. - */ - memcpy(stored_version, verbuf, len); - stored_version[len] = '\0'; + strlcpy(stored_version, verbuf, len+1); /* * return the newly malloced buffer diff --git a/zfunc.c b/zfunc.c index 3fd7cca..9988628 100644 --- a/zfunc.c +++ b/zfunc.c @@ -1,7 +1,8 @@ /* * zfunc - extended precision integral arithmetic non-primitive routines * - * Copyright (C) 1999-2007 David I. Bell, Landon Curt Noll and Ernest Bowen + * Copyright (C) 1999-2007,2021 David I. Bell, Landon Curt Noll + * and Ernest Bowen * * Primary author: David I. Bell * @@ -27,6 +28,11 @@ #include "zmath.h" +#include "alloc.h" + + +#include "banned.h" /* include after system header <> includes */ + ZVALUE _tenpowers_[TEN_MAX+1]; /* table of 10^2^n */ diff --git a/zio.c b/zio.c index 4be2f7b..931de01 100644 --- a/zio.c +++ b/zio.c @@ -1,7 +1,7 @@ /* * zio - scanf and printf routines for arbitrary precision integers * - * Copyright (C) 1999-2007 David I. Bell + * Copyright (C) 1999-2007,2021 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 @@ -25,11 +25,15 @@ #include +#include "alloc.h" #include "config.h" #include "zmath.h" #include "args.h" +#include "banned.h" /* include after system header <> includes */ + + #define OUTBUFSIZE 200 /* realloc size for output buffers */ #define PUTCHAR(ch) math_chr(ch) diff --git a/zmath.c b/zmath.c index 826970c..2f90907 100644 --- a/zmath.c +++ b/zmath.c @@ -1,7 +1,7 @@ /* * zmath - extended precision integral arithmetic primitives * - * Copyright (C) 1999-2007 David I. Bell and Ernest Bowen + * Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen * * Primary author: David I. Bell * @@ -27,8 +27,13 @@ #include +#include "alloc.h" #include "zmath.h" + +#include "banned.h" /* include after system header <> includes */ + + HALF _zeroval_[] = { 0 }; HALF _oneval_[] = { 1 }; HALF _twoval_[] = { 2 }; diff --git a/zmath.h b/zmath.h index 92edd27..83aa942 100644 --- a/zmath.h +++ b/zmath.h @@ -1,7 +1,7 @@ /* * zmath - declarations for extended precision integer arithmetic * - * Copyright (C) 1999-2007,2014 David I. Bell + * Copyright (C) 1999-2007,2014,2021 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 @@ -121,6 +121,20 @@ typedef SB32 SFULL; /* signed FULL */ #define BASE1 (BASE - (FULL)1) /* one less than base */ #define BASEDIG ((BASEB/16)*5) /* number of digits in base */ #define FULL_BITS (2*BASEB) /* bits in a FULL */ +#define HALF_LEN (sizeof(HALF)) /* length of HALF in bites */ +#define FULL_LEN (sizeof(FULL)) /* length of FULL in bites */ + +/* + * ROUNDUP(value, mult) - round up value to the next multiple of mult + * + * NOTE: value and mult musty be of an integer type. + * + * NOTE: mult must != 0 + * + * NOTE: If value is a multiple of mult, then ROUNDUP(value, mult) + * will just return value. + */ +#define ROUNDUP(value, mult) ( ( ((value)+(mult)-1) / (mult) ) * (mult) ) #define TOPHALF ((FULL)1 << (BASEB-1)) /* highest bit in a HALF */ #define MAXHALF (TOPHALF - (FULL)1) /* largest SHALF value */ diff --git a/zmod.c b/zmod.c index 34be1d1..4d075b9 100644 --- a/zmod.c +++ b/zmod.c @@ -1,7 +1,8 @@ /* * zmod - modulo arithmetic routines * - * Copyright (C) 1999-2007 David I. Bell, Landon Curt Noll and Ernest Bowen + * Copyright (C) 1999-2007,2021 David I. Bell, Landon Curt Noll + * and Ernest Bowen * * Primary author: David I. Bell * @@ -36,10 +37,14 @@ */ +#include "alloc.h" #include "config.h" #include "zmath.h" +#include "banned.h" /* include after system header <> includes */ + + #define POWBITS 4 /* bits for power chunks (must divide BASEB) */ #define POWNUMS (1< includes */ + + STATIC HALF *tempbuf; /* temporary buffer for multiply and square */ S_FUNC LEN domul(HALF *v1, LEN size1, HALF *v2, LEN size2, HALF *ans); diff --git a/zprime.c b/zprime.c index a659fa2..20bb5f0 100644 --- a/zprime.c +++ b/zprime.c @@ -1,7 +1,7 @@ /* * zprime - rapid small prime routines * - * Copyright (C) 1999-2007 Landon Curt Noll + * Copyright (C) 1999-2007,2021 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,9 @@ #include "have_const.h" +#include "banned.h" /* include after system header <> includes */ + + /* * When performing a probabilistic primality test, check to see * if the number has a factor <= PTEST_PRECHECK. diff --git a/zrand.c b/zrand.c index c04eabb..b706ffb 100644 --- a/zrand.c +++ b/zrand.c @@ -1,7 +1,7 @@ /* * zrand - subtractive 100 shuffle generator * - * Copyright (C) 1999-2007 Landon Curt Noll + * Copyright (C) 1999-2007,2021 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 @@ -351,11 +351,15 @@ #include +#include "alloc.h" #include "zrand.h" #include "have_const.h" #include "have_unused.h" +#include "banned.h" /* include after system header <> includes */ + + /* * default s100 generator state * @@ -2348,7 +2352,7 @@ randcmp(CONST RAND *s1, CONST RAND *s2) */ /*ARGSUSED*/ void -randprint(CONST RAND UNUSED *state, int UNUSED flags) +randprint(CONST RAND *UNUSED(state), int UNUSED(flags)) { math_str("RAND state"); } diff --git a/zrandom.c b/zrandom.c index d467a5e..e9c2d3e 100644 --- a/zrandom.c +++ b/zrandom.c @@ -1,7 +1,7 @@ /* * zrandom - Blum-Blum-Shub pseudo-random generator * - * Copyright (C) 1999-2007 Landon Curt Noll + * Copyright (C) 1999-2007,2021 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 @@ -1083,6 +1083,9 @@ #include "have_unused.h" +#include "banned.h" /* include after system header <> includes */ + + /* * current Blum generator state */ @@ -3139,7 +3142,7 @@ randomcmp(CONST RANDOM *s1, CONST RANDOM *s2) */ /*ARGSUSED*/ void -randomprint(CONST RANDOM UNUSED *state, int UNUSED flags) +randomprint(CONST RANDOM *UNUSED(state), int UNUSED(flags)) { math_str("RANDOM state"); }