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): indent cond.c with tabs instead of spaces



details:   https://anonhg.NetBSD.org/src/rev/3277705497ae
branches:  trunk
changeset: 946326:3277705497ae
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 23 20:05:31 2020 +0000

description:
make(1): indent cond.c with tabs instead of spaces

diffstat:

 usr.bin/make/cond.c |  1479 ++++++++++++++++++++++++++------------------------
 1 files changed, 762 insertions(+), 717 deletions(-)

diffs (truncated from 1817 to 300 lines):

diff -r 8a316caa30c6 -r 3277705497ae usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Mon Nov 23 19:35:10 2020 +0000
+++ b/usr.bin/make/cond.c       Mon Nov 23 20:05:31 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.214 2020/11/13 09:01:59 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.215 2020/11/23 20:05:31 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -94,7 +94,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.214 2020/11/13 09:01:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.215 2020/11/23 20:05:31 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -135,20 +135,22 @@
  * CondParser_Term) return either TOK_FALSE, TOK_TRUE, or TOK_ERROR on error.
  */
 typedef enum Token {
-    TOK_FALSE = 0, TOK_TRUE = 1, TOK_AND, TOK_OR, TOK_NOT,
-    TOK_LPAREN, TOK_RPAREN, TOK_EOF, TOK_NONE, TOK_ERROR
+       TOK_FALSE = 0, TOK_TRUE = 1, TOK_AND, TOK_OR, TOK_NOT,
+       TOK_LPAREN, TOK_RPAREN, TOK_EOF, TOK_NONE, TOK_ERROR
 } Token;
 
 typedef struct CondParser {
-    const struct If *if_info;  /* Info for current statement */
-    const char *p;             /* The remaining condition to parse */
-    Token curr;                        /* Single push-back token used in parsing */
+       const struct If *if_info; /* Info for current statement */
+       const char *p;          /* The remaining condition to parse */
+       Token curr;             /* Single push-back token used in parsing */
 
-    /* Whether an error message has already been printed for this condition.
-     * The first available error message is usually the most specific one,
-     * therefore it makes sense to suppress the standard "Malformed
-     * conditional" message. */
-    Boolean printedError;
+       /*
+        * Whether an error message has already been printed for this
+        * condition. The first available error message is usually the most
+        * specific one, therefore it makes sense to suppress the standard
+        * "Malformed conditional" message.
+        */
+       Boolean printedError;
 } CondParser;
 
 static Token CondParser_Expr(CondParser *par, Boolean);
@@ -171,29 +173,29 @@
 static int
 is_token(const char *str, const char *tok, size_t len)
 {
-    return strncmp(str, tok, len) == 0 && !ch_isalpha(str[len]);
+       return strncmp(str, tok, len) == 0 && !ch_isalpha(str[len]);
 }
 
 static Token
 ToToken(Boolean cond)
 {
-    return cond ? TOK_TRUE : TOK_FALSE;
+       return cond ? TOK_TRUE : TOK_FALSE;
 }
 
 /* Push back the most recent token read. We only need one level of this. */
 static void
 CondParser_PushBack(CondParser *par, Token t)
 {
-    assert(par->curr == TOK_NONE);
-    assert(t != TOK_NONE);
+       assert(par->curr == TOK_NONE);
+       assert(t != TOK_NONE);
 
-    par->curr = t;
+       par->curr = t;
 }
 
 static void
 CondParser_SkipWhitespace(CondParser *par)
 {
-    cpp_skip_whitespace(&par->p);
+       cpp_skip_whitespace(&par->p);
 }
 
 /* Parse the argument of a built-in function.
@@ -210,116 +212,121 @@
  * Return the length of the argument, or 0 on error. */
 static size_t
 ParseFuncArg(const char **pp, Boolean doEval, const char *func,
-            char **out_arg) {
-    const char *p = *pp;
-    Buffer argBuf;
-    int paren_depth;
-    size_t argLen;
-
-    if (func != NULL)
-       p++;                    /* Skip opening '(' - verified by caller */
+            char **out_arg)
+{
+       const char *p = *pp;
+       Buffer argBuf;
+       int paren_depth;
+       size_t argLen;
 
-    if (*p == '\0') {
-       *out_arg = NULL;        /* Missing closing parenthesis: */
-       return 0;               /* .if defined( */
-    }
+       if (func != NULL)
+               p++;            /* Skip opening '(' - verified by caller */
 
-    cpp_skip_hspace(&p);
+       if (*p == '\0') {
+               *out_arg = NULL; /* Missing closing parenthesis: */
+               return 0;       /* .if defined( */
+       }
 
-    Buf_InitSize(&argBuf, 16);
+       cpp_skip_hspace(&p);
+
+       Buf_InitSize(&argBuf, 16);
 
-    paren_depth = 0;
-    for (;;) {
-       char ch = *p;
-       if (ch == '\0' || ch == ' ' || ch == '\t')
-           break;
-       if ((ch == '&' || ch == '|') && paren_depth == 0)
-           break;
-       if (*p == '$') {
-           /*
-            * Parse the variable spec and install it as part of the argument
-            * if it's valid. We tell Var_Parse to complain on an undefined
-            * variable, so we don't need to do it. Nor do we return an error,
-            * though perhaps we should...
-            */
-           void *nestedVal_freeIt;
-           VarEvalFlags eflags = doEval ? VARE_WANTRES | VARE_UNDEFERR
-                                        : VARE_NONE;
-           const char *nestedVal;
-           (void)Var_Parse(&p, VAR_CMDLINE, eflags, &nestedVal,
-                           &nestedVal_freeIt);
-           /* TODO: handle errors */
-           Buf_AddStr(&argBuf, nestedVal);
-           free(nestedVal_freeIt);
-           continue;
+       paren_depth = 0;
+       for (;;) {
+               char ch = *p;
+               if (ch == '\0' || ch == ' ' || ch == '\t')
+                       break;
+               if ((ch == '&' || ch == '|') && paren_depth == 0)
+                       break;
+               if (*p == '$') {
+                       /*
+                        * Parse the variable expression and install it as
+                        * part of the argument if it's valid. We tell
+                        * Var_Parse to complain on an undefined variable,
+                        * (XXX: but Var_Parse ignores that request)
+                        * so we don't need to do it. Nor do we return an
+                        * error, though perhaps we should.
+                        */
+                       void *nestedVal_freeIt;
+                       VarEvalFlags eflags = doEval
+                           ? VARE_WANTRES | VARE_UNDEFERR
+                           : VARE_NONE;
+                       const char *nestedVal;
+                       (void)Var_Parse(&p, VAR_CMDLINE, eflags,
+                                       &nestedVal, &nestedVal_freeIt);
+                       /* TODO: handle errors */
+                       Buf_AddStr(&argBuf, nestedVal);
+                       free(nestedVal_freeIt);
+                       continue;
+               }
+               if (ch == '(')
+                       paren_depth++;
+               else if (ch == ')' && --paren_depth < 0)
+                       break;
+               Buf_AddByte(&argBuf, *p);
+               p++;
        }
-       if (ch == '(')
-           paren_depth++;
-       else if (ch == ')' && --paren_depth < 0)
-           break;
-       Buf_AddByte(&argBuf, *p);
-       p++;
-    }
 
-    *out_arg = Buf_GetAll(&argBuf, &argLen);
-    Buf_Destroy(&argBuf, FALSE);
+       *out_arg = Buf_GetAll(&argBuf, &argLen);
+       Buf_Destroy(&argBuf, FALSE);
+
+       cpp_skip_hspace(&p);
 
-    cpp_skip_hspace(&p);
+       if (func != NULL && *p++ != ')') {
+               Parse_Error(PARSE_WARNING,
+                           "Missing closing parenthesis for %s()",
+                           func);
+               /* The PARSE_FATAL follows in CondEvalExpression. */
+               return 0;
+       }
 
-    if (func != NULL && *p++ != ')') {
-       Parse_Error(PARSE_WARNING, "Missing closing parenthesis for %s()",
-                   func);
-       /* The PARSE_FATAL is done as a follow-up by CondEvalExpression. */
-       return 0;
-    }
-
-    *pp = p;
-    return argLen;
+       *pp = p;
+       return argLen;
 }
 
 /* Test whether the given variable is defined. */
 static Boolean
 FuncDefined(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-    void *freeIt;
-    Boolean result = Var_Value(arg, VAR_CMDLINE, &freeIt) != NULL;
-    bmake_free(freeIt);
-    return result;
+       void *freeIt;
+       Boolean result = Var_Value(arg, VAR_CMDLINE, &freeIt) != NULL;
+       bmake_free(freeIt);
+       return result;
 }
 
 /* See if the given target is being made. */
 static Boolean
 FuncMake(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-    StringListNode *ln;
+       StringListNode *ln;
 
-    for (ln = opts.create->first; ln != NULL; ln = ln->next)
-       if (Str_Match(ln->datum, arg))
-           return TRUE;
-    return FALSE;
+       for (ln = opts.create->first; ln != NULL; ln = ln->next)
+               if (Str_Match(ln->datum, arg))
+                       return TRUE;
+       return FALSE;
 }
 
 /* See if the given file exists. */
 static Boolean
 FuncExists(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-    Boolean result;
-    char *path;
+       Boolean result;
+       char *path;
 
-    path = Dir_FindFile(arg, dirSearchPath);
-    DEBUG2(COND, "exists(%s) result is \"%s\"\n",
-          arg, path != NULL ? path : "");
-    result = path != NULL;
-    free(path);
-    return result;
+       path = Dir_FindFile(arg, dirSearchPath);
+       DEBUG2(COND, "exists(%s) result is \"%s\"\n",
+              arg, path != NULL ? path : "");
+       result = path != NULL;
+       free(path);
+       return result;
 }
 
 /* See if the given node exists and is an actual target. */
 static Boolean
 FuncTarget(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-    GNode *gn = Targ_FindNode(arg);
-    return gn != NULL && GNode_IsTarget(gn);
+       GNode *gn = Targ_FindNode(arg);
+       return gn != NULL && GNode_IsTarget(gn);
 }
 
 /* See if the given node exists and is an actual target with commands
@@ -327,8 +334,8 @@
 static Boolean
 FuncCommands(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
 {
-    GNode *gn = Targ_FindNode(arg);
-    return gn != NULL && GNode_IsTarget(gn) && !Lst_IsEmpty(gn->commands);
+       GNode *gn = Targ_FindNode(arg);
+       return gn != NULL && GNode_IsTarget(gn) && !Lst_IsEmpty(gn->commands);
 }
 
 /*
@@ -343,36 +350,36 @@
 static Boolean
 TryParseNumber(const char *str, double *out_value)
 {



Home | Main Index | Thread Index | Old Index