]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/aclocal.m4
ncurses 6.0 - patch 20160910
[ncurses.git] / test / aclocal.m4
index 4ac571ce26f55c03791b1acf09ea378dcaa83b56..561a64f30b97aee5c7c41848e7659f267370775b 100644 (file)
@@ -26,7 +26,7 @@ dnl sale, use or other dealings in this Software without prior written       *
 dnl authorization.                                                           *
 dnl***************************************************************************
 dnl
-dnl $Id: aclocal.m4,v 1.133 2016/08/27 16:27:51 tom Exp $
+dnl $Id: aclocal.m4,v 1.135 2016/09/10 22:09:38 tom Exp $
 dnl
 dnl Author: Thomas E. Dickey
 dnl
@@ -376,7 +376,7 @@ ifelse([$3],,[    :]dnl
 ])dnl
 ])])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CC_ENV_FLAGS version: 5 updated: 2016/08/27 11:24:46
+dnl CF_CC_ENV_FLAGS version: 6 updated: 2016/08/29 20:57:00
 dnl ---------------
 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
 dnl into CC.  This will not help with broken scripts that wrap the compiler
@@ -401,7 +401,17 @@ case "$CC" in
        # humor him...
        cf_flags=`echo "$CC" | sed -e 's/^.*[[  ]]\(-[[^        ]]\)/\1/'`
        CC=`echo "$CC " | sed -e 's/[[  ]]-[[^  ]].*$//' -e 's/[[       ]]*$//'`
-       CF_ADD_CFLAGS($cf_flags)
+       for cf_arg in $cf_flags
+       do
+               case "x$cf_arg" in
+               (x-[[IUDfgOW]]*)
+                       CF_ADD_CFLAGS($cf_flags)
+                       ;;
+               (*)
+                       CC="$CC $cf_arg"
+                       ;;
+               esac
+       done
        CF_VERBOSE(resulting CC: '$CC')
        CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
        CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
@@ -1108,6 +1118,44 @@ if test "$cf_disable_rpath_hack" = no ; then
 fi
 ])
 dnl ---------------------------------------------------------------------------
+dnl CF_ENABLE_STRING_HACKS version: 4 updated: 2016/09/10 15:33:21
+dnl ----------------------
+dnl On a few platforms, the compiler and/or loader nags with untruthful
+dnl comments stating that "most" uses of strcat/strcpy/sprintf are incorrect,
+dnl and implying that most uses of the recommended alternatives are correct.
+dnl
+dnl Factually speaking, no one has actually counted the number of uses of these
+dnl functions versus the total of incorrect uses.  Samples of a few thousand
+dnl instances are meaningless compared to the hundreds of millions of lines of
+dnl existing C code.
+dnl
+dnl strlcat/strlcpy are (as of 2012) non-standard, and are available on some
+dnl platforms, in implementations of varying quality.  Likewise, snprintf is
+dnl standard - but evolved through phases, and older implementations are likely
+dnl to yield surprising results, as documented in manpages on various systems.
+AC_DEFUN([CF_ENABLE_STRING_HACKS],
+[
+AC_MSG_CHECKING(if you want to work around bogus compiler/loader warnings)
+AC_ARG_ENABLE(string-hacks,
+       [  --enable-string-hacks   work around bogus compiler/loader warnings],
+       [with_string_hacks=$enableval],
+       [with_string_hacks=no])
+AC_MSG_RESULT($with_string_hacks)
+
+if test "x$with_string_hacks" = "xyes"; then
+       AC_DEFINE(USE_STRING_HACKS,1,[Define to 1 to work around bogus compiler/loader warnings])
+       AC_MSG_WARN(enabling string-hacks to work around bogus compiler/loader warnings)
+       AC_CHECK_FUNC(strlcat,,[
+               AC_CHECK_LIB(bsd,strlcat,[
+                       CF_ADD_LIB(bsd)
+                       AC_CHECK_HEADERS(bsd/string.h)
+                       AC_DEFINE(HAVE_STRLCAT,1,[Define to 1 if we have strlcat function])
+                       ])
+               ])
+       AC_CHECK_FUNCS( strlcpy snprintf )
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_ENABLE_WARNINGS version: 4 updated: 2009/07/26 17:53:03
 dnl ------------------
 dnl Configure-option to enable gcc warnings