patch 8.0.1709: some non-C89 code may slip through

Problem:    Some non-C89 code may slip through.
Solution:   Enforce C89 in configure. Fix detected problems. (James McCoy,
            closes #2735)
diff --git a/src/configure.ac b/src/configure.ac
index f2655a5..27309b2 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -11,7 +11,7 @@
 AC_PROG_MAKE_SET
 
 dnl Checks for programs.
-AC_PROG_CC		dnl required by almost everything
+AC_PROG_CC_C89		dnl required by almost everything
 AC_PROG_CPP		dnl required by header file checks
 AC_PROGRAM_EGREP	dnl required by AC_EGREP_CPP
 AC_PROG_FGREP		dnl finds working grep -F
@@ -61,6 +61,9 @@
       CFLAGS="$CFLAGS -fno-strength-reduce"
     fi
   fi
+
+  dnl Declare what standards the code should comply with
+  CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
 fi
 
 dnl clang-500.2.75 or around has abandoned -f[no-]strength-reduce and issues a
@@ -135,7 +138,7 @@
 if test "`(uname) 2>/dev/null`" = Darwin; then
   AC_MSG_RESULT(yes)
   MACOS_X=yes
-  CPPFLAGS="$CPPFLAGS -DMACOS_X"
+  CPPFLAGS="$CPPFLAGS -D_DARWIN_C_SOURCE -DMACOS_X"
 
   AC_MSG_CHECKING(--disable-darwin argument)
   AC_ARG_ENABLE(darwin,
@@ -4400,6 +4403,12 @@
 	CFLAGS="-D_ALL_SOURCE -Wc,float\(ieee\),dll"
 fi
 
+dnl Declare what standards the code should comply with.  But not when using
+dnl GTK, the header files cause all kinds of warnings.
+if test "$GCC" = yes -a "$GUITYPE" != "GTK"; then
+  CFLAGS="$CFLAGS -ansi"
+fi
+
 dnl write output files
 AC_OUTPUT(auto/config.mk:config.mk.in)