diff --git a/Makefile b/Makefile index a40e6e6..4917063 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,11 @@ # calculator by David I. Bell with help/mods from others # Makefile by Landon Curt Noll + +# our shell +# +SHELL= /bin/sh + # Try uname -s if the target was not already set on the make command line # ifeq ($(target),) @@ -142,7 +147,6 @@ endif # standard utilities used during make # -SHELL= /bin/sh MAKE= make SED= sed GREP= egrep diff --git a/Makefile.ship b/Makefile.ship index bfc761f..d76233e 100644 --- a/Makefile.ship +++ b/Makefile.ship @@ -48,6 +48,11 @@ # calculator by David I. Bell with help/mods from others # Makefile by Landon Curt Noll + +# our shell +# +SHELL= /bin/sh + #if 0 /* start of skip for non-Gnu makefiles */ ############################################################################## #-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-# @@ -1062,7 +1067,6 @@ LIB_EXT_VERSION= ${LIB_EXT}.${VERSION} # standard utilities used during make # -SHELL= /bin/sh AR= ar AWK= awk CAT= cat @@ -4297,7 +4301,7 @@ debug: calcinfo env @${MAKE} -f Makefile Q= V=@ ver_calc${EXT} -@./ver_calc${EXT} @echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-=' - @echo -n '=-=-=-= Print #defile values if custom functions ' + @/bin/echo -n '=-=-=-= Print #defile values if custom functions ' @echo 'are allowed =-=-=-=' -@${CALC_ENV} ./calc${EXT} -e -q -C 'print custom("sysinfo", 2);' @echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-=' @@ -4899,7 +4903,7 @@ uninstall: custom/Makefile -${Q} if [ -f "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}" ]; then \ ${RM} -f "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}"; \ if [ -f "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}" ]; then \ - echo -n "cannot uninstall " \ + /bin/echo -n "cannot uninstall " \ echo "${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}"; \ else \ echo "uninstalled ${T}${LIBDIR}/libcalc${LIB_EXT_VERSION}"; \ @@ -5021,7 +5025,7 @@ calc-symlink: if [ ! -L "${CATDIR}/calc.${CATEXT}" -a \ "${T}${CATDIR}/calc.${CATEXT}" -ef \ "${CATDIR}/calc.${CATEXT}" ]; then \ - echo -n "ERROR: ${T}${CATDIR}/calc.${CATEXT}" 2>&1; \ + /bin/echo -n "ERROR: ${T}${CATDIR}/calc.${CATEXT}" 2>&1; \ echo "is the same as ${CATDIR}/calc.${CATEXT}" 1>&2; \ else \ if [ -e "${CATDIR}/calc.${CATEXT}" ]; then \ diff --git a/banned.h b/banned.h new file mode 100644 index 0000000..ca5ce48 --- /dev/null +++ b/banned.h @@ -0,0 +1,82 @@ +/* + * banned - indicate which functions are banned in calc source + * + * inspired by https://github.com/git/git/blob/master/banned.h + * + * 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/06 21:07:31 + * File existed as early as: 2021 + * + * chongo /\oo/\ http://www.isthe.com/chongo/ + * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ + */ + + +#if !defined(INCLUDE_BANNED_H) +#define INCLUDE_BANNED_H + +#include "have_stdlib.h" +#ifdef HAVE_STDLIB_H +# include +#endif + +/* + * From: //github.com/git/git/blob/master/banned.h + * + * 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. + */ + +#define BANNED(func,better) sorry_##func##_is_a_banned_function_use_##better##_instead + +#undef strcpy +#define strcpy(x,y) BANNED(strcpy,strlcpy) +#undef strcat +#define strcat(x,y) BANNED(strcat,strlcat) +#undef strncpy +#define strncpy(x,y,n) BANNED(strncpy,memccpy) +#undef strncat +#define strncat(x,y,n) BANNED(strncat,memccpy) + +#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 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 */ + + +#endif /* !INCLUDE_BANNED_H */ diff --git a/cal/Makefile b/cal/Makefile index 6106883..1491620 100644 --- a/cal/Makefile +++ b/cal/Makefile @@ -27,7 +27,8 @@ # calculator by David I. Bell with help/mods from others # Makefile by Landon Curt Noll -# required vars + +# our shell # SHELL= /bin/sh @@ -167,17 +168,17 @@ Q=@ # CHMOD= chmod CMP= cmp -RM= rm -MKDIR= mkdir -RMDIR= rmdir -CP= cp -MV= mv CO= co -TRUE= true -TOUCH= touch +CP= cp +FMT= fmt +MKDIR= mkdir +MV= mv +RM= rm +RMDIR= rmdir SED= sed SORT= sort -FMT= fmt +TOUCH= touch +TRUE= true # The calc files to install # diff --git a/cscript/Makefile b/cscript/Makefile index 6023c11..d4a99df 100644 --- a/cscript/Makefile +++ b/cscript/Makefile @@ -27,7 +27,7 @@ # Makefile by Landon Curt Noll -# required vars +# our shell # SHELL= /bin/sh @@ -165,18 +165,19 @@ Q=@ # standard tools # +CAT= cat CHMOD= chmod +CMP= cmp +CO= co +CP= cp +FMT= fmt +MKDIR= mkdir +MV= mv +RM= rm +RMDIR= rmdir SED= sed SORT= sort -FMT= fmt -CMP= cmp -MKDIR= mkdir -RMDIR= rmdir -RM= rm TOUCH= touch -MV= mv -CP= cp -CO= co TRUE= true # The ${SCRIPT} list is the list of calc shell script files (without the .calc @@ -312,7 +313,7 @@ depend: if [ X"$$i" != X"/dev/null" ]; then \ echo "$$i: $$i.calc"; \ echo ' @$${RM} -f $$@'; \ - echo -n ' @$${SED} -e "1s:^#!/usr/local/src/bin/'; \ + /bin/echo -n ' @$${SED} -e "1s:^#!/usr/local/src/bin/'; \ echo 'calc/calc:#!$${BINDIR}/calc:" $$?>$$@'; \ echo ' @$${CHMOD} +x $$@'; \ fi; \ diff --git a/custom/Makefile b/custom/Makefile index 09e7732..43f36f4 100644 --- a/custom/Makefile +++ b/custom/Makefile @@ -27,6 +27,11 @@ # calculator by David I. Bell with help/mods from others # Makefile by Landon Curt Noll + +# our shell +# +SHELL= /bin/sh + #if 0 /* start of skip for non-Gnu makefiles */ ############################################################################## #-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-# @@ -357,26 +362,25 @@ LIB_EXT_VERSION= ${LIB_EXT}.${VERSION} # standard tools # -SHELL= /bin/sh -SED= sed -MAKEDEPEND= makedepend -GREP= egrep -CHMOD= chmod -FMT= fmt -SORT= sort -CMP= cmp AR= ar -RM= rm -TOUCH= touch -MKDIR= mkdir -RMDIR= rmdir -MV= mv -CP= cp -CO= co -TRUE= true -MAKE= make -LN= ln AWK= awk +CHMOD= chmod +CMP= cmp +CO= co +CP= cp +FMT= fmt +GREP= egrep +LN= ln +MAKE= make +MAKEDEPEND= makedepend +MKDIR= mkdir +MV= mv +RM= rm +RMDIR= rmdir +SED= sed +SORT= sort +TOUCH= touch +TRUE= true # EXTRA_CFLAGS are flags given to ${CC} when compiling C files # EXTRA_LDFLAGS are flags given to ${CC} when linking progs diff --git a/custom/Makefile.head b/custom/Makefile.head index 31f9643..c12c35e 100644 --- a/custom/Makefile.head +++ b/custom/Makefile.head @@ -27,6 +27,11 @@ # calculator by David I. Bell with help/mods from others # Makefile by Landon Curt Noll + +# our shell +# +SHELL= /bin/sh + #if 0 /* start of skip for non-Gnu makefiles */ ############################################################################## #-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-# @@ -357,26 +362,25 @@ LIB_EXT_VERSION= ${LIB_EXT}.${VERSION} # standard tools # -SHELL= /bin/sh -SED= sed -MAKEDEPEND= makedepend -GREP= egrep -CHMOD= chmod -FMT= fmt -SORT= sort -CMP= cmp AR= ar -RM= rm -TOUCH= touch -MKDIR= mkdir -RMDIR= rmdir -MV= mv -CP= cp -CO= co -TRUE= true -MAKE= make -LN= ln AWK= awk +CHMOD= chmod +CMP= cmp +CO= co +CP= cp +FMT= fmt +GREP= egrep +LN= ln +MAKE= make +MAKEDEPEND= makedepend +MKDIR= mkdir +MV= mv +RM= rm +RMDIR= rmdir +SED= sed +SORT= sort +TOUCH= touch +TRUE= true # EXTRA_CFLAGS are flags given to ${CC} when compiling C files # EXTRA_LDFLAGS are flags given to ${CC} when linking progs diff --git a/help/Makefile b/help/Makefile index 81ddfb6..0aa3829 100644 --- a/help/Makefile +++ b/help/Makefile @@ -165,23 +165,23 @@ Q=@ # standard tools # -LCC= cc -ICFLAGS= -ILDFLAGS= -GREP= egrep +CAT= cat CHMOD= chmod -SED= sed -SORT= sort -FMT= fmt CMP= cmp CP= cp -MV= mv -TRUE= true -RM= rm +FMT= fmt +GREP= egrep +ICFLAGS= +ILDFLAGS= +LCC= cc MKDIR= mkdir +MV= mv +RM= rm RMDIR= rmdir +SED= sed +SORT= sort TOUCH= touch -CAT= cat +TRUE= true # Some out of date operating systems require / want an executable to # end with a certain file extension. Some compile systems such as