From: Florian Weimer <fweimer@redhat.com>
Message-ID: <874jso2g70.fsf@oldenburg.str.redhat.com>
Subject: C99 compatibility fixes for the plotutils configure script
Date: Wed, 18 Jan 2023 13:13:55 +0100
To: bug-plotutils@gnu.org

Future C compilers will only support calling functions which are
declared.  The attached patch is required to avoid changing the outcome
of configure checks with such compilers.

Related to:

  <https://fedoraproject.org/wiki/Changes/PortingToModernC>
  <https://fedoraproject.org/wiki/Toolchain/PortingToModernC>

Thanks,
Florian


Do not call the undeclared exit function.  This avoids build problems
with future compilers which do not support implicit function
declarations.

--- a/configure
+++ b/configure
@@ -19535,13 +19535,13 @@ int main()
   if ((fpw = fopen ("conftest0", "w")) == (FILE *)0
       || fwrite ("FOOBAR", 1, 7, fpw) != 7
       || fflush ((FILE *)0) < 0
       || (fpr = fopen ("conftest0", "r")) == (FILE *)0
       || fread (test_array, 1, 7, fpr) != 7)
-    exit (1);
+    return 1;
   else
-    exit(0); }
+    return 0; }
 _ACEOF
 rm -f conftest$ac_exeext
 if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
@@ -24020,11 +24020,11 @@ int main()
   static int Array[3];
   unsigned int B = 3;
   int i;
   for (i=0; i < B; i++)
     Array[i] = i - 3;
-  exit (Array[1] != -2);
+  return Array[1] != -2;
 }
 _ACEOF
 rm -f conftest$ac_exeext
 if { (ac_try="$ac_link"
 case "(($ac_try" in
--- a/configure.ac
+++ b/configure.ac
@@ -87,13 +87,13 @@ int main()
   if ((fpw = fopen ("conftest0", "w")) == (FILE *)0
       || fwrite ("FOOBAR", 1, 7, fpw) != 7
       || fflush ((FILE *)0) < 0
       || (fpr = fopen ("conftest0", "r")) == (FILE *)0
       || fread (test_array, 1, 7, fpr) != 7)
-    exit (1);
+    return 1;
   else
-    exit(0); }]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NULL_FLUSH)],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
+    return 0; }]])],[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_NULL_FLUSH)],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
 
 # Checks for header files: ANSI C, POSIX, and nonstandard Unix headers.
 AC_HEADER_STDC
 AC_CHECK_HEADERS(string.h limits.h float.h)
 AC_CHECK_HEADERS(malloc.h pthread.h strings.h unistd.h values.h sys/select.h sys/stdtypes.h sys/time.h sys/types.h sys/wait.h)
@@ -382,11 +382,11 @@ int main()
   static int Array[[3]];
   unsigned int B = 3;
   int i;
   for (i=0; i < B; i++)
     Array[[i]] = i - 3;
-  exit (Array[[1]] != -2);
+  return Array[[1]] != -2;
 }]])],
 [ac_cv_c_gcc_strength_bug="no"],[ac_cv_c_gcc_strength_bug="yes"],[ac_cv_c_gcc_strength_bug="yes"]) )
   if test "$ac_cv_c_gcc_strength_bug" = "yes"
   then
     CFLAGS="$CFLAGS -fno-strength-reduce"
