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 large parts of var.c with tabs ...



details:   https://anonhg.NetBSD.org/src/rev/215047e55203
branches:  trunk
changeset: 946631:215047e55203
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 05 14:28:09 2020 +0000

description:
make(1): indent large parts of var.c with tabs instead of spaces

The few remaining functions need to be cleaned up before being indented
further, to reduce the overall indentation.

diffstat:

 usr.bin/make/var.c |  4965 ++++++++++++++++++++++++++-------------------------
 1 files changed, 2537 insertions(+), 2428 deletions(-)

diffs (truncated from 5746 to 300 lines):

diff -r ddaad9a9f012 -r 215047e55203 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Dec 05 13:01:33 2020 +0000
+++ b/usr.bin/make/var.c        Sat Dec 05 14:28:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.702 2020/12/05 13:01:33 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.703 2020/12/05 14:28:09 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.702 2020/12/05 13:01:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.703 2020/12/05 14:28:09 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -189,31 +189,42 @@
 
 typedef enum VarFlags {
 
-    /* The variable's value is currently being used by Var_Parse or Var_Subst.
-     * This marker is used to avoid endless recursion. */
-    VAR_IN_USE = 0x01,
-
-    /* The variable comes from the environment.
-     * These variables are not registered in any GNode, therefore they must
-     * be freed as soon as they are not used anymore. */
-    VAR_FROM_ENV = 0x02,
-
-    /* The variable is exported to the environment, to be used by child
-     * processes. */
-    VAR_EXPORTED = 0x10,
-
-    /* At the point where this variable was exported, it contained an
-     * unresolved reference to another variable.  Before any child process is
-     * started, it needs to be exported again, in the hope that the referenced
-     * variable can then be resolved. */
-    VAR_REEXPORT = 0x20,
-
-    /* The variable came from the command line. */
-    VAR_FROM_CMD = 0x40,
-
-    /* The variable value cannot be changed anymore, and the variable cannot
-     * be deleted.  Any attempts to do so are ignored. */
-    VAR_READONLY = 0x80
+       /*
+        * The variable's value is currently being used by Var_Parse or
+        * Var_Subst.  This marker is used to avoid endless recursion.
+        */
+       VAR_IN_USE = 0x01,
+
+       /*
+        * The variable comes from the environment.
+        * These variables are not registered in any GNode, therefore they
+        * must be freed as soon as they are not used anymore.
+        */
+       VAR_FROM_ENV = 0x02,
+
+       /*
+        * The variable is exported to the environment, to be used by child
+        * processes.
+        */
+       VAR_EXPORTED = 0x10,
+
+       /*
+        * At the point where this variable was exported, it contained an
+        * unresolved reference to another variable.  Before any child
+        * process is started, it needs to be exported again, in the hope
+        * that the referenced variable can then be resolved.
+        */
+       VAR_REEXPORT = 0x20,
+
+       /* The variable came from the command line. */
+       VAR_FROM_CMD = 0x40,
+
+       /*
+        * The variable value cannot be changed anymore, and the variable
+        * cannot be deleted.  Any attempts to do so are silently ignored,
+        * they are logged with -dv though.
+        */
+       VAR_READONLY = 0x80
 } VarFlags;
 
 ENUM_FLAGS_RTTI_6(VarFlags,
@@ -239,110 +250,118 @@
  * as ${UNDEF:Ufallback} in Var_Parse and ApplyModifiers.
  */
 typedef struct Var {
-    /* The name of the variable, once set, doesn't change anymore.
-     * For context variables, it aliases the corresponding HashEntry name.
-     * For environment and undefined variables, it is allocated. */
-    const char *name;
-    void *name_freeIt;
-
-    Buffer       val;          /* its value */
-    VarFlags     flags;        /* miscellaneous status flags */
+       /*
+        * The name of the variable, once set, doesn't change anymore.
+        * For context variables, it aliases the corresponding HashEntry name.
+        * For environment and undefined variables, it is allocated.
+        */
+       const char *name;
+       void *name_freeIt;
+
+       /* The unexpanded value of the variable. */
+       Buffer val;
+       /* Miscellaneous status flags. */
+       VarFlags flags;
 } Var;
 
 /*
  * Exporting vars is expensive so skip it if we can
  */
 typedef enum VarExportedMode {
-    VAR_EXPORTED_NONE,
-    VAR_EXPORTED_SOME,
-    VAR_EXPORTED_ALL
+       VAR_EXPORTED_NONE,
+       VAR_EXPORTED_SOME,
+       VAR_EXPORTED_ALL
 } VarExportedMode;
 
 static VarExportedMode var_exportedVars = VAR_EXPORTED_NONE;
 
 typedef enum VarExportFlags {
-    VAR_EXPORT_NORMAL = 0,
-    /*
-     * We pass this to Var_Export when doing the initial export
-     * or after updating an exported var.
-     */
-    VAR_EXPORT_PARENT  = 0x01,
-    /*
-     * We pass this to Var_Export1 to tell it to leave the value alone.
-     */
-    VAR_EXPORT_LITERAL = 0x02
+       VAR_EXPORT_NORMAL = 0,
+       /*
+        * We pass this to Var_Export when doing the initial export
+        * or after updating an exported var.
+        */
+       VAR_EXPORT_PARENT = 0x01,
+       /*
+        * We pass this to Var_Export1 to tell it to leave the value alone.
+        */
+       VAR_EXPORT_LITERAL = 0x02
 } VarExportFlags;
 
 /* Flags for pattern matching in the :S and :C modifiers */
 typedef enum VarPatternFlags {
-    VARP_SUB_GLOBAL    = 0x01, /* Replace as often as possible ('g') */
-    VARP_SUB_ONE       = 0x02, /* Replace only once ('1') */
-    VARP_ANCHOR_START  = 0x04, /* Match at start of word ('^') */
-    VARP_ANCHOR_END    = 0x08  /* Match at end of word ('$') */
+       /* Replace as often as possible ('g') */
+       VARP_SUB_GLOBAL         = 1 << 0,
+       /* Replace only once ('1') */
+       VARP_SUB_ONE            = 1 << 1,
+       /* Match at start of word ('^') */
+       VARP_ANCHOR_START       = 1 << 2,
+       /* Match at end of word ('$') */
+       VARP_ANCHOR_END         = 1 << 3
 } VarPatternFlags;
 
 static Var *
 VarNew(const char *name, void *name_freeIt, const char *value, VarFlags flags)
 {
-    size_t value_len = strlen(value);
-    Var *var = bmake_malloc(sizeof *var);
-    var->name = name;
-    var->name_freeIt = name_freeIt;
-    Buf_InitSize(&var->val, value_len + 1);
-    Buf_AddBytes(&var->val, value, value_len);
-    var->flags = flags;
-    return var;
+       size_t value_len = strlen(value);
+       Var *var = bmake_malloc(sizeof *var);
+       var->name = name;
+       var->name_freeIt = name_freeIt;
+       Buf_InitSize(&var->val, value_len + 1);
+       Buf_AddBytes(&var->val, value, value_len);
+       var->flags = flags;
+       return var;
 }
 
 static const char *
 CanonicalVarname(const char *name)
 {
-    if (*name == '.' && ch_isupper(name[1])) {
-       switch (name[1]) {
-       case 'A':
-           if (strcmp(name, ".ALLSRC") == 0)
-               name = ALLSRC;
-           if (strcmp(name, ".ARCHIVE") == 0)
-               name = ARCHIVE;
-           break;
-       case 'I':
-           if (strcmp(name, ".IMPSRC") == 0)
-               name = IMPSRC;
-           break;
-       case 'M':
-           if (strcmp(name, ".MEMBER") == 0)
-               name = MEMBER;
-           break;
-       case 'O':
-           if (strcmp(name, ".OODATE") == 0)
-               name = OODATE;
-           break;
-       case 'P':
-           if (strcmp(name, ".PREFIX") == 0)
-               name = PREFIX;
-           break;
-       case 'S':
-           if (strcmp(name, ".SHELL") == 0) {
-               if (!shellPath)
-                   Shell_Init();
-           }
-           break;
-       case 'T':
-           if (strcmp(name, ".TARGET") == 0)
-               name = TARGET;
-           break;
+       if (*name == '.' && ch_isupper(name[1])) {
+               switch (name[1]) {
+               case 'A':
+                       if (strcmp(name, ".ALLSRC") == 0)
+                               name = ALLSRC;
+                       if (strcmp(name, ".ARCHIVE") == 0)
+                               name = ARCHIVE;
+                       break;
+               case 'I':
+                       if (strcmp(name, ".IMPSRC") == 0)
+                               name = IMPSRC;
+                       break;
+               case 'M':
+                       if (strcmp(name, ".MEMBER") == 0)
+                               name = MEMBER;
+                       break;
+               case 'O':
+                       if (strcmp(name, ".OODATE") == 0)
+                               name = OODATE;
+                       break;
+               case 'P':
+                       if (strcmp(name, ".PREFIX") == 0)
+                               name = PREFIX;
+                       break;
+               case 'S':
+                       if (strcmp(name, ".SHELL") == 0) {
+                               if (!shellPath)
+                                       Shell_Init();
+                       }
+                       break;
+               case 'T':
+                       if (strcmp(name, ".TARGET") == 0)
+                               name = TARGET;
+                       break;
+               }
        }
-    }
-
-    /* GNU make has an additional alias $^ == ${.ALLSRC}. */
-
-    return name;
+
+       /* GNU make has an additional alias $^ == ${.ALLSRC}. */
+
+       return name;
 }
 
 static Var *
 GNode_FindVar(GNode *ctxt, const char *varname, unsigned int hash)
 {
-    return HashTable_FindValueHash(&ctxt->vars, varname, hash);
+       return HashTable_FindValueHash(&ctxt->vars, varname, hash);
 }
 
 /* Find the variable in the context, and maybe in other contexts as well.
@@ -360,55 +379,58 @@
 static Var *
 VarFind(const char *name, GNode *ctxt, Boolean elsewhere)
 {
-    Var *var;
-    unsigned int nameHash;
-
-    /*
-     * If the variable name begins with a '.', it could very well be one of
-     * the local ones.  We check the name against all the local variables
-     * and substitute the short version in for 'name' if it matches one of
-     * them.
-     */
-    name = CanonicalVarname(name);
-    nameHash = Hash_Hash(name);
-
-    /* First look for the variable in the given context. */
-    var = GNode_FindVar(ctxt, name, nameHash);
-    if (!elsewhere)
+       Var *var;
+       unsigned int nameHash;
+



Home | Main Index | Thread Index | Old Index