]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Avoid C99 constructs
authorPaul Smith <psmith@gnu.org>
Fri, 28 Oct 2022 17:03:18 +0000 (13:03 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 29 Oct 2022 17:36:21 +0000 (13:36 -0400)
Although gnulib requires C99, most of the code does compile with a
C90 compiler (perhaps with a lot of warnings).  Reinstate our C90
configuration test, and clean up a few C99 things that crept in.

* src/job.c (construct_command_argv_internal): Don't use loop-local
variables or C++ comments.
* src/read.c (eval_makefile): Don't use loop-local variables.

maintMakefile
src/job.c
src/read.c

index fb98a42fdb34a747b613f5acf5a800a7c8bd26f1..b9f822ad8a39df5d27277aa38be4862662506b62 100644 (file)
@@ -259,7 +259,8 @@ CFGCHECK_BUILDFLAGS  =
 # as well, and that will fail.
 CFGCHECK_MAKEFLAGS   = # CFLAGS='$(AM_CFLAGS)'
 
-# This test can no longer be run: now that we rely on gnulib we must use C99+
+# We don't support C90 anymore, strictly, but this test still works (with lots
+# of warnings) and it helps us avoid egregious incompatibilities.
 checkcfg.strict-c90:  CFGCHECK_CONFIGFLAGS = CFLAGS='-std=c90 -pedantic'
 checkcfg.strict-c90:  CFGCHECK_MAKEFLAGS   =
 
@@ -277,6 +278,7 @@ checkcfg.no-sync:     CFGCHECK_CONFIGFLAGS = CPPFLAGS=-DNO_OUTPUT_SYNC
 checkcfg.no-archives: CFGCHECK_CONFIGFLAGS = CPPFLAGS=-DNO_ARCHIVES
 
 CONFIG_CHECKS := \
+       checkcfg.strict-c90 \
        checkcfg.no-jobserver \
        checkcfg.no-load \
        checkcfg.no-guile \
index bebe16e8306b88dcc957b48331706aa9aa4d07d5..ed951026ee6ce9a353a00b095f70ee7e04aa11d2 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -3376,12 +3376,12 @@ construct_command_argv_internal (char *line, char **restp, const char *shell,
             {
               /* Parse shellflags using construct_command_argv_internal to
                  handle quotes. */
-              char **argv;
+              char **argv, **a;
               char *f;
-              f = alloca (sflags_len + 1); // +1 for null terminator.
+              f = alloca (sflags_len + 1); /* +1 for null terminator.  */
               memcpy (f, shellflags, sflags_len + 1);
               argv = construct_command_argv_internal (f, 0, 0, 0, 0, flags, 0);
-              for (char **a = argv; a && *a; ++a)
+              for (a = argv; a && *a; ++a)
                 new_argv[n++] = *a;
               free (argv);
             }
index a7200190c6dd7d7d35ac61d3b8d4738cfb86e7c9..0743124087f250f36195b86f8f28c85a5aa71f6f 100644 (file)
@@ -375,23 +375,26 @@ eval_makefile (const char *filename, unsigned short flags)
      makefile search path for this makefile.  */
   if (ebuf.fp == NULL && deps->error == ENOENT && (flags & RM_INCLUDED)
       && *filename != '/' && include_directories)
-    for (const char **dir = include_directories; *dir != NULL; ++dir)
-      {
-        const char *included = concat (3, *dir, "/", filename);
+    {
+      const char **dir;
+      for (dir = include_directories; *dir != NULL; ++dir)
+        {
+          const char *included = concat (3, *dir, "/", filename);
 
-        ENULLLOOP(ebuf.fp, fopen (included, "r"));
-        if (ebuf.fp)
-          {
-            filename = included;
-            break;
-          }
-        if (errno != ENOENT)
-          {
-            filename = included;
-            deps->error = errno;
-            break;
-          }
-      }
+          ENULLLOOP(ebuf.fp, fopen (included, "r"));
+          if (ebuf.fp)
+            {
+              filename = included;
+              break;
+            }
+          if (errno != ENOENT)
+            {
+              filename = included;
+              deps->error = errno;
+              break;
+            }
+        }
+    }
 
   /* Enter the final name for this makefile as a goaldep.  */
   filename = strcache_add (filename);