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): format the source code consistently, a...



details:   https://anonhg.NetBSD.org/src/rev/89ba762063e6
branches:  trunk
changeset: 937147:89ba762063e6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 09 19:51:02 2020 +0000

description:
make(1): format the source code consistently, at least per file

Some files use 4 spaces per indentation level, others use 8.  At least
for the few files from this commit, they use a consistent style
throughout each file now.

In Cond_Eval, the #define has changed into an enum since the identifiers
need not be visible to the C preprocessor.

diffstat:

 usr.bin/make/buf.c     |   12 +-
 usr.bin/make/cond.c    |  242 ++++++++++++------------
 usr.bin/make/dir.c     |  477 ++++++++++++++++++++++++------------------------
 usr.bin/make/for.c     |   54 ++--
 usr.bin/make/strlist.c |   16 +-
 5 files changed, 401 insertions(+), 400 deletions(-)

diffs (truncated from 1550 to 300 lines):

diff -r cb6d3c367fa9 -r 89ba762063e6 usr.bin/make/buf.c
--- a/usr.bin/make/buf.c        Sun Aug 09 18:54:59 2020 +0000
+++ b/usr.bin/make/buf.c        Sun Aug 09 19:51:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf.c,v 1.33 2020/08/09 18:52:03 rillig Exp $  */
+/*     $NetBSD: buf.c,v 1.34 2020/08/09 19:51:02 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: buf.c,v 1.33 2020/08/09 18:52:03 rillig Exp $";
+static char rcsid[] = "$NetBSD: buf.c,v 1.34 2020/08/09 19:51:02 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)buf.c      8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: buf.c,v 1.33 2020/08/09 18:52:03 rillig Exp $");
+__RCSID("$NetBSD: buf.c,v 1.34 2020/08/09 19:51:02 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -144,8 +144,8 @@
      * add enough slop to cope with a '-' sign and a trailing '\0'.
      */
     enum {
-        bits  = sizeof(int) * CHAR_BIT,
-        buf_size = 1 + (bits + 2) / 3 + 1
+       bits = sizeof(int) * CHAR_BIT,
+       buf_size = 1 + (bits + 2) / 3 + 1
     };
     char buf[buf_size];
 
@@ -209,7 +209,7 @@
 }
 
 #ifndef BUF_COMPACT_LIMIT
-# define BUF_COMPACT_LIMIT 128          /* worthwhile saving */
+# define BUF_COMPACT_LIMIT 128         /* worthwhile saving */
 #endif
 
 /* Reset the buffer and return its data.
diff -r cb6d3c367fa9 -r 89ba762063e6 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Sun Aug 09 18:54:59 2020 +0000
+++ b/usr.bin/make/cond.c       Sun Aug 09 19:51:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.92 2020/08/08 18:54:04 rillig Exp $ */
+/*     $NetBSD: cond.c,v 1.93 2020/08/09 19:51:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.92 2020/08/08 18:54:04 rillig Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.93 2020/08/09 19:51:02 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c     8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.92 2020/08/08 18:54:04 rillig Exp $");
+__RCSID("$NetBSD: cond.c,v 1.93 2020/08/09 19:51:02 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -93,7 +93,7 @@
 
 #include    <assert.h>
 #include    <ctype.h>
-#include    <errno.h>    /* For strtoul() error checking */
+#include    <errno.h>
 
 #include    "make.h"
 #include    "hash.h"
@@ -148,13 +148,13 @@
 static Token CondE(Boolean);
 static CondEvalResult do_Cond_EvalExpression(Boolean *);
 
-static const struct If *if_info;        /* Info for current statement */
-static const char *condExpr;           /* The expression to parse */
-static Token     condPushBack=TOK_NONE;        /* Single push-back token used in
+static const struct If *if_info;       /* Info for current statement */
+static const char *condExpr;           /* The expression to parse */
+static Token condPushBack = TOK_NONE;  /* Single push-back token used in
                                         * parsing */
 
-static unsigned int    cond_depth = 0;         /* current .if nesting level */
-static unsigned int    cond_min_depth = 0;     /* depth at makefile open */
+static unsigned int cond_depth = 0;    /* current .if nesting level */
+static unsigned int cond_min_depth = 0;        /* depth at makefile open */
 
 /*
  * Indicate when we should be strict about lhs of comparisons.
@@ -168,7 +168,7 @@
 static int
 istoken(const char *str, const char *tok, size_t len)
 {
-       return strncmp(str, tok, len) == 0 && !isalpha((unsigned char)str[len]);
+    return strncmp(str, tok, len) == 0 && !isalpha((unsigned char)str[len]);
 }
 
 /* Push back the most recent token read. We only need one level of
@@ -191,11 +191,11 @@
 CondGetArg(Boolean doEval, const char **linePtr, char **argPtr,
           const char *func)
 {
-    const char   *cp;
-    Buffer       buf;
-    int           paren_depth;
-    char          ch;
-    size_t       argLen;
+    const char *cp;
+    Buffer buf;
+    int paren_depth;
+    char ch;
+    size_t argLen;
 
     cp = *linePtr;
     if (func != NULL)
@@ -237,8 +237,8 @@
             * variable, so we don't do it too. Nor do we return an error,
             * though perhaps we should...
             */
-           int         len;
-           void        *freeIt;
+           int len;
+           void *freeIt;
            VarEvalFlags eflags = VARE_UNDEFERR | (doEval ? VARE_WANTRES : 0);
            const char *cp2 = Var_Parse(cp, VAR_CMD, eflags, &len, &freeIt);
            Buf_AddStr(&buf, cp2);
@@ -248,9 +248,8 @@
        }
        if (ch == '(')
            paren_depth++;
-       else
-           if (ch == ')' && --paren_depth < 0)
-               break;
+       else if (ch == ')' && --paren_depth < 0)
+           break;
        Buf_AddByte(&buf, *cp);
        cp++;
     }
@@ -264,7 +263,7 @@
 
     if (func != NULL && *cp++ != ')') {
        Parse_Error(PARSE_WARNING, "Missing closing parenthesis for %s()",
-                    func);
+                   func);
        return 0;
     }
 
@@ -302,12 +301,12 @@
 CondDoExists(int argLen MAKE_ATTR_UNUSED, const char *arg)
 {
     Boolean result;
-    char    *path;
+    char *path;
 
     path = Dir_FindFile(arg, dirSearchPath);
     if (DEBUG(COND)) {
        fprintf(debug_file, "exists(%s) result is \"%s\"\n",
-              arg, path ? path : "");
+               arg, path ? path : "");
     }
     if (path != NULL) {
        result = TRUE;
@@ -322,7 +321,7 @@
 static Boolean
 CondDoTarget(int argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-    GNode   *gn;
+    GNode *gn;
 
     gn = Targ_FindNode(arg, TARG_NOCREATE);
     return gn != NULL && !OP_NOP(gn->type);
@@ -333,7 +332,7 @@
 static Boolean
 CondDoCommands(int argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-    GNode   *gn;
+    GNode *gn;
 
     gn = Targ_FindNode(arg, TARG_NOCREATE);
     return gn != NULL && !OP_NOP(gn->type) && !Lst_IsEmpty(gn->commands);
@@ -395,7 +394,7 @@
     Buffer buf;
     const char *cp;
     const char *str;
-    int        len;
+    int len;
     int qt;
     const char *start;
 
@@ -457,7 +456,7 @@
             */
            if ((condExpr == start + len) &&
                (*condExpr == '\0' ||
-                isspace((unsigned char) *condExpr) ||
+                isspace((unsigned char)*condExpr) ||
                 strchr("!=><)", *condExpr))) {
                goto cleanup;
            }
@@ -471,12 +470,12 @@
                free(*freeIt);
                *freeIt = NULL;
            }
-           str = NULL;                 /* not finished yet */
-           condExpr--;                 /* don't skip over next char */
+           str = NULL;         /* not finished yet */
+           condExpr--;         /* don't skip over next char */
            break;
        default:
            if (strictLHS && !qt && *start != '$' &&
-               !isdigit((unsigned char) *start)) {
+               !isdigit((unsigned char)*start)) {
                /* lhs must be quoted, a variable reference or number */
                if (*freeIt) {
                    free(*freeIt);
@@ -489,26 +488,26 @@
            break;
        }
     }
- got_str:
+got_str:
     *freeIt = Buf_GetAll(&buf, NULL);
     str = *freeIt;
- cleanup:
+cleanup:
     Buf_Destroy(&buf, FALSE);
     return str;
 }
 
 static const struct If {
-    const char *form;        /* Form of if */
-    int                formlen;      /* Length of form */
-    Boolean    doNot;        /* TRUE if default function should be negated */
-    Boolean    (*defProc)(int, const char *); /* Default function to apply */
+    const char *form;          /* Form of if */
+    int formlen;               /* Length of form */
+    Boolean doNot;             /* TRUE if default function should be negated */
+    Boolean (*defProc)(int, const char *); /* Default function to apply */
 } ifs[] = {
-    { "def",     3,      FALSE,  CondDoDefined },
-    { "ndef",    4,      TRUE,   CondDoDefined },
-    { "make",    4,      FALSE,  CondDoMake },
-    { "nmake",   5,      TRUE,   CondDoMake },
-    { "",        0,      FALSE,  CondDoDefined },
-    { NULL,      0,      FALSE,  NULL }
+    { "def",   3, FALSE, CondDoDefined },
+    { "ndef",  4, TRUE,  CondDoDefined },
+    { "make",  4, FALSE, CondDoMake },
+    { "nmake", 5, TRUE,  CondDoMake },
+    { "",      0, FALSE, CondDoDefined },
+    { NULL,    0, FALSE, NULL }
 };
 
 /*-
@@ -520,15 +519,15 @@
 static Token
 compare_expression(Boolean doEval)
 {
-    Token      t;
-    const char *lhs;
-    const char *rhs;
-    const char *op;
-    void       *lhsFree;
-    void       *rhsFree;
+    Token t;
+    const char *lhs;
+    const char *rhs;
+    const char *op;
+    void *lhsFree;
+    void *rhsFree;
     Boolean lhsQuoted;
     Boolean rhsQuoted;
-    double     left, right;
+    double left, right;
 
     t = TOK_ERROR;
     rhs = NULL;
@@ -546,7 +545,7 @@
     /*
      * Skip whitespace to get to the operator
      */
-    while (isspace((unsigned char) *condExpr))
+    while (isspace((unsigned char)*condExpr))
        condExpr++;
 
     /*
@@ -556,39 +555,39 @@
      */
     op = condExpr;
     switch (*condExpr) {



Home | Main Index | Thread Index | Old Index