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 arch.c with tabs instead of spaces



details:   https://anonhg.NetBSD.org/src/rev/1f915b06f185
branches:  trunk
changeset: 978518:1f915b06f185
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 23 19:02:54 2020 +0000

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

diffstat:

 usr.bin/make/arch.c |  1234 +++++++++++++++++++++++++-------------------------
 1 files changed, 628 insertions(+), 606 deletions(-)

diffs (truncated from 1463 to 300 lines):

diff -r 3a37b7e12556 -r 1f915b06f185 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Mon Nov 23 18:24:05 2020 +0000
+++ b/usr.bin/make/arch.c       Mon Nov 23 19:02:54 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.177 2020/11/14 21:29:44 rillig Exp $        */
+/*     $NetBSD: arch.c,v 1.178 2020/11/23 19:02:54 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -125,7 +125,7 @@
 #include "config.h"
 
 /*     "@(#)arch.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: arch.c,v 1.177 2020/11/14 21:29:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.178 2020/11/23 19:02:54 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -133,11 +133,11 @@
 static ArchList *archives;     /* The archives we've already examined */
 
 typedef struct Arch {
-    char *name;                        /* Name of archive */
-    HashTable members;         /* All the members of the archive described
+       char *name;             /* Name of archive */
+       HashTable members;      /* All the members of the archive described
                                 * by <name, struct ar_hdr *> key/value pairs */
-    char *fnametab;            /* Extended name table strings */
-    size_t fnamesize;          /* Size of the string table */
+       char *fnametab;         /* Extended name table strings */
+       size_t fnamesize;       /* Size of the string table */
 } Arch;
 
 static FILE *ArchFindMember(const char *, const char *,
@@ -151,18 +151,18 @@
 static void
 ArchFree(void *ap)
 {
-    Arch *a = ap;
-    HashIter hi;
+       Arch *a = ap;
+       HashIter hi;
 
-    /* Free memory from hash entries */
-    HashIter_Init(&hi, &a->members);
-    while (HashIter_Next(&hi) != NULL)
-       free(hi.entry->value);
+       /* Free memory from hash entries */
+       HashIter_Init(&hi, &a->members);
+       while (HashIter_Next(&hi) != NULL)
+               free(hi.entry->value);
 
-    free(a->name);
-    free(a->fnametab);
-    HashTable_Done(&a->members);
-    free(a);
+       free(a->name);
+       free(a->fnametab);
+       HashTable_Done(&a->members);
+       free(a);
 }
 #endif
 
@@ -185,203 +185,211 @@
 Boolean
 Arch_ParseArchive(char **pp, GNodeList *nodeLst, GNode *ctxt)
 {
-    char *cp;                  /* Pointer into line */
-    GNode *gn;                 /* New node */
-    char *libName;             /* Library-part of specification */
-    char *libName_freeIt = NULL;
-    char *memName;             /* Member-part of specification */
-    char saveChar;             /* Ending delimiter of member-name */
-    Boolean expandLibName;     /* Whether the parsed libName contains
+       char *cp;               /* Pointer into line */
+       GNode *gn;              /* New node */
+       char *libName;          /* Library-part of specification */
+       char *libName_freeIt = NULL;
+       char *memName;          /* Member-part of specification */
+       char saveChar;          /* Ending delimiter of member-name */
+       Boolean expandLibName;  /* Whether the parsed libName contains
                                 * variable expressions that need to be
                                 * expanded */
 
-    libName = *pp;
-    expandLibName = FALSE;
-
-    for (cp = libName; *cp != '(' && *cp != '\0';) {
-       if (*cp == '$') {
-           /*
-            * Variable spec, so call the Var module to parse the puppy
-            * so we can safely advance beyond it...
-            */
-           const char *nested_p = cp;
-           void *result_freeIt;
-           const char *result;
-           Boolean isError;
+       libName = *pp;
+       expandLibName = FALSE;
 
-           /* XXX: is expanded twice: once here and once below */
-           (void)Var_Parse(&nested_p, ctxt, VARE_WANTRES | VARE_UNDEFERR,
-                           &result, &result_freeIt);
-           /* TODO: handle errors */
-           isError = result == var_Error;
-           free(result_freeIt);
-           if (isError)
-               return FALSE;
-
-           expandLibName = TRUE;
-           cp += nested_p - cp;
-       } else
-           cp++;
-    }
-
-    *cp++ = '\0';
-    if (expandLibName) {
-       (void)Var_Subst(libName, ctxt, VARE_WANTRES | VARE_UNDEFERR, &libName);
-       /* TODO: handle errors */
-       libName_freeIt = libName;
-    }
-
+       for (cp = libName; *cp != '(' && *cp != '\0';) {
+               if (*cp == '$') {
+                       /* Expand nested variable expressions. */
+                       /* XXX: This code can probably be shortened. */
+                       const char *nested_p = cp;
+                       void *result_freeIt;
+                       const char *result;
+                       Boolean isError;
 
-    for (;;) {
-       /*
-        * First skip to the start of the member's name, mark that
-        * place and skip to the end of it (either white-space or
-        * a close paren).
-        */
-       Boolean doSubst = FALSE; /* TRUE if need to substitute in memName */
-
-       pp_skip_whitespace(&cp);
+                       /* XXX: is expanded twice: once here and once below */
+                       (void)Var_Parse(&nested_p, ctxt,
+                                       VARE_WANTRES | VARE_UNDEFERR,
+                                       &result, &result_freeIt);
+                       /* TODO: handle errors */
+                       isError = result == var_Error;
+                       free(result_freeIt);
+                       if (isError)
+                               return FALSE;
 
-       memName = cp;
-       while (*cp != '\0' && *cp != ')' && !ch_isspace(*cp)) {
-           if (*cp == '$') {
-               /*
-                * Variable spec, so call the Var module to parse the puppy
-                * so we can safely advance beyond it...
-                */
-               void *freeIt;
-               const char *result;
-               Boolean isError;
-               const char *nested_p = cp;
-
-               (void)Var_Parse(&nested_p, ctxt, VARE_WANTRES | VARE_UNDEFERR,
-                               &result, &freeIt);
-               /* TODO: handle errors */
-               isError = result == var_Error;
-               free(freeIt);
-
-               if (isError)
-                   return FALSE;
-
-               doSubst = TRUE;
-               cp += nested_p - cp;
-           } else {
-               cp++;
-           }
+                       expandLibName = TRUE;
+                       cp += nested_p - cp;
+               } else
+                       cp++;
        }
 
-       /*
-        * If the specification ends without a closing parenthesis,
-        * chances are there's something wrong (like a missing backslash),
-        * so it's better to return failure than allow such things to happen
-        */
-       if (*cp == '\0') {
-           Parse_Error(PARSE_FATAL, "No closing parenthesis in archive specification");
-           return FALSE;
-       }
-
-       /*
-        * If we didn't move anywhere, we must be done
-        */
-       if (cp == memName) {
-           break;
+       *cp++ = '\0';
+       if (expandLibName) {
+               (void)Var_Subst(libName, ctxt, VARE_WANTRES | VARE_UNDEFERR,
+                               &libName);
+               /* TODO: handle errors */
+               libName_freeIt = libName;
        }
 
-       saveChar = *cp;
-       *cp = '\0';
+
+       for (;;) {
+               /*
+                * First skip to the start of the member's name, mark that
+                * place and skip to the end of it (either white-space or
+                * a close paren).
+                */
+               Boolean doSubst = FALSE;
+
+               pp_skip_whitespace(&cp);
 
-       /*
-        * XXX: This should be taken care of intelligently by
-        * SuffExpandChildren, both for the archive and the member portions.
-        */
-       /*
-        * If member contains variables, try and substitute for them.
-        * This will slow down archive specs with dynamic sources, of course,
-        * since we'll be (non-)substituting them three times, but them's
-        * the breaks -- we need to do this since SuffExpandChildren calls
-        * us, otherwise we could assume the thing would be taken care of
-        * later.
-        */
-       if (doSubst) {
-           char *buf;
-           char *sacrifice;
-           char *oldMemName = memName;
+               memName = cp;
+               while (*cp != '\0' && *cp != ')' && !ch_isspace(*cp)) {
+                       if (*cp == '$') {
+                               /* Expand nested variable expressions. */
+                               /* XXX: This code can probably be shortened. */
+                               void *freeIt;
+                               const char *result;
+                               Boolean isError;
+                               const char *nested_p = cp;
+
+                               (void)Var_Parse(&nested_p, ctxt,
+                                               VARE_WANTRES | VARE_UNDEFERR,
+                                               &result, &freeIt);
+                               /* TODO: handle errors */
+                               isError = result == var_Error;
+                               free(freeIt);
 
-           (void)Var_Subst(memName, ctxt, VARE_WANTRES | VARE_UNDEFERR,
-                           &memName);
-           /* TODO: handle errors */
+                               if (isError)
+                                       return FALSE;
 
-           /*
-            * Now form an archive spec and recurse to deal with nested
-            * variables and multi-word variable values.... The results
-            * are just placed at the end of the nodeLst we're returning.
-            */
-           buf = sacrifice = str_concat4(libName, "(", memName, ")");
+                               doSubst = TRUE;
+                               cp += nested_p - cp;
+                       } else {
+                               cp++;
+                       }
+               }
 
-           if (strchr(memName, '$') != NULL &&
-               strcmp(memName, oldMemName) == 0) {
                /*
-                * Must contain dynamic sources, so we can't deal with it now.
-                * Just create an ARCHV node for the thing and let
-                * SuffExpandChildren handle it...
+                * If the specification ends without a closing parenthesis,
+                * chances are there's something wrong (like a missing
+                * backslash), so it's better to return failure than allow
+                * such things to happen
                 */
-               gn = Targ_GetNode(buf);
-               gn->type |= OP_ARCHV;
-               Lst_Append(nodeLst, gn);
+               if (*cp == '\0') {
+                       Parse_Error(PARSE_FATAL,
+                                   "No closing parenthesis "
+                                   "in archive specification");
+                       return FALSE;
+               }
+
+               /*
+                * If we didn't move anywhere, we must be done
+                */
+               if (cp == memName)
+                       break;
+
+               saveChar = *cp;
+               *cp = '\0';
 



Home | Main Index | Thread Index | Old Index