Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): reformat main.c more closely to share/...



details:   https://anonhg.NetBSD.org/src/rev/78301e781cb9
branches:  trunk
changeset: 942470:78301e781cb9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 08 14:50:24 2020 +0000

description:
make(1): reformat main.c more closely to share/misc/style

diffstat:

 usr.bin/make/main.c |  725 ++++++++++++++++++++++++++-------------------------
 1 files changed, 364 insertions(+), 361 deletions(-)

diffs (truncated from 1056 to 300 lines):

diff -r 67c8a83d57f8 -r 78301e781cb9 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Nov 08 14:19:15 2020 +0000
+++ b/usr.bin/make/main.c       Sun Nov 08 14:50:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.452 2020/11/08 14:19:15 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.453 2020/11/08 14:50:24 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,38 +109,38 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.452 2020/11/08 14:19:15 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.453 2020/11/08 14:50:24 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
            "All rights reserved.");
 #endif
 
-#ifndef        DEFMAXLOCAL
-#define        DEFMAXLOCAL DEFMAXJOBS
+#ifndef DEFMAXLOCAL
+#define DEFMAXLOCAL DEFMAXJOBS
 #endif
 
 CmdOpts opts;
-time_t                 now;            /* Time at start of make */
-GNode                  *DEFAULT;       /* .DEFAULT node */
-Boolean                        allPrecious;    /* .PRECIOUS given on line by itself */
-Boolean                        deleteOnError;  /* .DELETE_ON_ERROR: set */
+time_t now;                    /* Time at start of make */
+GNode *DEFAULT;                        /* .DEFAULT node */
+Boolean allPrecious;           /* .PRECIOUS given on line by itself */
+Boolean deleteOnError;         /* .DELETE_ON_ERROR: set */
 
-static int             maxJobTokens;   /* -j argument */
-Boolean                        enterFlagObj;   /* -w and objdir != srcdir */
+static int maxJobTokens;       /* -j argument */
+Boolean enterFlagObj;          /* -w and objdir != srcdir */
 
 Boolean preserveUndefined;
-static int jp_0 = -1, jp_1 = -1;       /* ends of parent job pipe */
-Boolean                        doing_depend;   /* Set while reading .depend */
-static Boolean         jobsRunning;    /* TRUE if the jobs might be running */
-static const char *    tracefile;
-static int             ReadMakefile(const char *);
-static void            purge_cached_realpaths(void);
+static int jp_0 = -1, jp_1 = -1; /* ends of parent job pipe */
+Boolean doing_depend;          /* Set while reading .depend */
+static Boolean jobsRunning;    /* TRUE if the jobs might be running */
+static const char *tracefile;
+static int ReadMakefile(const char *);
+static void purge_cached_realpaths(void);
 
-static Boolean         ignorePWD;      /* if we use -C, PWD is meaningless */
-static char objdir[MAXPATHLEN + 1];    /* where we chdir'ed to */
-char curdir[MAXPATHLEN + 1];           /* Startup directory */
-char *progname;                                /* the program name */
+static Boolean ignorePWD;      /* if we use -C, PWD is meaningless */
+static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */
+char curdir[MAXPATHLEN + 1];   /* Startup directory */
+char *progname;                        /* the program name */
 char *makeDependfile;
 pid_t myPid;
 int makelevel;
@@ -155,29 +155,29 @@
 static char *
 explode(const char *flags)
 {
-    size_t len;
-    char *nf, *st;
-    const char *f;
+       size_t len;
+       char *nf, *st;
+       const char *f;
 
-    if (flags == NULL)
-       return NULL;
+       if (flags == NULL)
+               return NULL;
 
-    for (f = flags; *f; f++)
-       if (!ch_isalpha(*f))
-           break;
+       for (f = flags; *f; f++)
+               if (!ch_isalpha(*f))
+                       break;
 
-    if (*f)
-       return bmake_strdup(flags);
+       if (*f)
+               return bmake_strdup(flags);
 
-    len = strlen(flags);
-    st = nf = bmake_malloc(len * 3 + 1);
-    while (*flags) {
-       *nf++ = '-';
-       *nf++ = *flags++;
-       *nf++ = ' ';
-    }
-    *nf = '\0';
-    return st;
+       len = strlen(flags);
+       st = nf = bmake_malloc(len * 3 + 1);
+       while (*flags) {
+               *nf++ = '-';
+               *nf++ = *flags++;
+               *nf++ = ' ';
+       }
+       *nf = '\0';
+       return st;
 }
 
 /*
@@ -196,50 +196,50 @@
 "            [-C directory] [-D variable] [-d flags] [-f makefile]\n"
 "            [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n"
 "            [-V variable] [-v variable] [variable=value] [target ...]\n",
-                     progname);
+           progname);
        exit(2);
 }
 
 static void
 parse_debug_option_F(const char *modules)
 {
-    const char *mode;
-    size_t len;
-    char *fname;
+       const char *mode;
+       size_t len;
+       char *fname;
 
-    if (opts.debug_file != stdout && opts.debug_file != stderr)
-       fclose(opts.debug_file);
+       if (opts.debug_file != stdout && opts.debug_file != stderr)
+               fclose(opts.debug_file);
 
-    if (*modules == '+') {
-       modules++;
-       mode = "a";
-    } else
-       mode = "w";
+       if (*modules == '+') {
+               modules++;
+               mode = "a";
+       } else
+               mode = "w";
 
-    if (strcmp(modules, "stdout") == 0) {
-       opts.debug_file = stdout;
-       return;
-    }
-    if (strcmp(modules, "stderr") == 0) {
-       opts.debug_file = stderr;
-       return;
-    }
+       if (strcmp(modules, "stdout") == 0) {
+               opts.debug_file = stdout;
+               return;
+       }
+       if (strcmp(modules, "stderr") == 0) {
+               opts.debug_file = stderr;
+               return;
+       }
 
-    len = strlen(modules);
-    fname = bmake_malloc(len + 20);
-    memcpy(fname, modules, len + 1);
+       len = strlen(modules);
+       fname = bmake_malloc(len + 20);
+       memcpy(fname, modules, len + 1);
 
-    /* Let the filename be modified by the pid */
-    if (strcmp(fname + len - 3, ".%d") == 0)
-       snprintf(fname + len - 2, 20, "%d", getpid());
+       /* Let the filename be modified by the pid */
+       if (strcmp(fname + len - 3, ".%d") == 0)
+               snprintf(fname + len - 2, 20, "%d", getpid());
 
-    opts.debug_file = fopen(fname, mode);
-    if (opts.debug_file == NULL) {
-       fprintf(stderr, "Cannot open debug file %s\n",
-               fname);
-       usage();
-    }
-    free(fname);
+       opts.debug_file = fopen(fname, mode);
+       if (opts.debug_file == NULL) {
+               fprintf(stderr, "Cannot open debug file %s\n",
+                   fname);
+               usage();
+       }
+       free(fname);
 }
 
 static void
@@ -253,7 +253,7 @@
                        opts.debug &= DEBUG_LINT;
                        break;
                case 'A':
-                       opts.debug = ~(0|DEBUG_LINT);
+                       opts.debug = ~(0 | DEBUG_LINT);
                        break;
                case 'a':
                        opts.debug |= DEBUG_ARCH;
@@ -334,6 +334,7 @@
                        usage();
                }
        }
+
 debug_setbuf:
        /*
         * Make the debug_file unbuffered, and make
@@ -359,7 +360,7 @@
        while ((cp = strstr(cp, "/.")) != NULL) {
                cp += 2;
                if (*cp == '.')
-                   cp++;
+                       cp++;
                if (cp[0] == '/' || cp[0] == '\0')
                        return TRUE;
        }
@@ -395,8 +396,8 @@
        char end;
        if (sscanf(argvalue, "%d,%d%c", &jp_0, &jp_1, &end) != 2) {
                (void)fprintf(stderr,
-                             "%s: internal error -- J option malformed (%s)\n",
-                             progname, argvalue);
+                   "%s: internal error -- J option malformed (%s)\n",
+                   progname, argvalue);
                usage();
        }
        if ((fcntl(jp_0, F_GETFD, 0) < 0) ||
@@ -733,7 +734,7 @@
                if ((strcmp(path, curdir) != 0 && access(path, W_OK) != 0) ||
                    (chdir(path) != 0)) {
                        (void)fprintf(stderr, "make warning: %s: %s.\n",
-                                     path, strerror(errno));
+                           path, strerror(errno));
                } else {
                        snprintf(objdir, sizeof objdir, "%s", path);
                        Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
@@ -781,17 +782,17 @@
 int
 str2Lst_Append(StringList *lp, char *str, const char *sep)
 {
-    char *cp;
-    int n;
+       char *cp;
+       int n;
 
-    if (!sep)
-       sep = " \t";
+       if (!sep)
+               sep = " \t";
 
-    for (n = 0, cp = strtok(str, sep); cp; cp = strtok(NULL, sep)) {
-       Lst_Append(lp, cp);
-       n++;
-    }
-    return n;
+       for (n = 0, cp = strtok(str, sep); cp; cp = strtok(NULL, sep)) {
+               Lst_Append(lp, cp);
+               n++;
+       }
+       return n;
 }
 
 #ifdef SIGINFO
@@ -816,27 +817,27 @@
 void
 MakeMode(const char *mode)
 {
-    char *mode_freeIt = NULL;
+       char *mode_freeIt = NULL;
 
-    if (mode == NULL) {
-       (void)Var_Subst("${" MAKE_MODE ":tl}",
-                 VAR_GLOBAL, VARE_WANTRES, &mode_freeIt);
-       /* TODO: handle errors */
-       mode = mode_freeIt;
-    }
+       if (mode == NULL) {
+               (void)Var_Subst("${" MAKE_MODE ":tl}",
+                   VAR_GLOBAL, VARE_WANTRES, &mode_freeIt);
+               /* TODO: handle errors */
+               mode = mode_freeIt;
+       }
 
-    if (mode[0] != '\0') {
-       if (strstr(mode, "compat")) {
-           opts.compatMake = TRUE;
-           forceJobs = FALSE;
-       }
+       if (mode[0] != '\0') {
+               if (strstr(mode, "compat")) {
+                       opts.compatMake = TRUE;



Home | Main Index | Thread Index | Old Index