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): reduce indentation in SuffFindNormalDe...



details:   https://anonhg.NetBSD.org/src/rev/038ae40e34f5
branches:  trunk
changeset: 945110:038ae40e34f5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Oct 21 06:46:21 2020 +0000

description:
make(1): reduce indentation in SuffFindNormalDepsPath

diffstat:

 usr.bin/make/suff.c |  94 +++++++++++++++++++++++++++-------------------------
 1 files changed, 48 insertions(+), 46 deletions(-)

diffs (129 lines):

diff -r 51e7d47c204f -r 038ae40e34f5 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Wed Oct 21 06:40:28 2020 +0000
+++ b/usr.bin/make/suff.c       Wed Oct 21 06:46:21 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.205 2020/10/21 06:40:28 rillig Exp $        */
+/*     $NetBSD: suff.c,v 1.206 2020/10/21 06:46:21 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include "dir.h"
 
 /*     "@(#)suff.c     8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.205 2020/10/21 06:40:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.206 2020/10/21 06:46:21 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -175,7 +175,8 @@
     SearchPath  *searchPath;   /* The path along which files of this suffix
                                 * may be found */
     int          sNum;         /* The suffix number */
-    int                 refCount;      /* Reference count of list membership */
+    int                 refCount;      /* Reference count of list membership
+                                * and several other places */
     SuffList    *parents;      /* Suffixes we have a transformation to */
     SuffList    *children;     /* Suffixes we have a transformation from */
     SuffListList *ref;         /* Lists in which this suffix is referenced */
@@ -1676,56 +1677,57 @@
 static void
 SuffFindNormalDepsPath(GNode *gn, Src *targ)
 {
-    if ((gn->type & (OP_PHONY|OP_NOPATH)) == 0) {
-       free(gn->path);
-       gn->path = Dir_FindFile(gn->name,
-                               (targ == NULL ? dirSearchPath :
-                                targ->suff->searchPath));
-       if (gn->path != NULL) {
-           char *ptr;
-           Var_Set(TARGET, gn->path, gn);
+    if (gn->type & (OP_PHONY | OP_NOPATH))
+        return;
+
+    free(gn->path);
+    gn->path = Dir_FindFile(gn->name,
+                           (targ == NULL ? dirSearchPath :
+                            targ->suff->searchPath));
+    if (gn->path == NULL)
+        return;
+
+    Var_Set(TARGET, gn->path, gn);
 
-           if (targ != NULL) {
-               /*
-                * Suffix known for the thing -- trim the suffix off
-                * the path to form the proper .PREFIX variable.
-                */
-               size_t savep = strlen(gn->path) - targ->suff->nameLen;
-               char    savec;
+    if (targ != NULL) {
+       /*
+        * Suffix known for the thing -- trim the suffix off
+        * the path to form the proper .PREFIX variable.
+        */
+       size_t savep = strlen(gn->path) - targ->suff->nameLen;
+       char savec;
+       char *ptr;
 
-               if (gn->suffix)
-                   gn->suffix->refCount--;
-               gn->suffix = targ->suff;
-               gn->suffix->refCount++;
-
-               savec = gn->path[savep];
-               gn->path[savep] = '\0';
+       if (gn->suffix)
+           gn->suffix->refCount--;
+       gn->suffix = targ->suff;
+       gn->suffix->refCount++;
 
-               if ((ptr = strrchr(gn->path, '/')) != NULL)
-                   ptr++;
-               else
-                   ptr = gn->path;
+       savec = gn->path[savep];
+       gn->path[savep] = '\0';
 
-               Var_Set(PREFIX, ptr, gn);
+       if ((ptr = strrchr(gn->path, '/')) != NULL)
+           ptr++;
+       else
+           ptr = gn->path;
+
+       Var_Set(PREFIX, ptr, gn);
 
-               gn->path[savep] = savec;
-           } else {
-               /*
-                * The .PREFIX gets the full path if the target has
-                * no known suffix.
-                */
-               if (gn->suffix)
-                   gn->suffix->refCount--;
-               gn->suffix = NULL;
+       gn->path[savep] = savec;
+    } else {
+       char *ptr;
 
-               if ((ptr = strrchr(gn->path, '/')) != NULL)
-                   ptr++;
-               else
-                   ptr = gn->path;
+       /* The .PREFIX gets the full path if the target has no known suffix. */
+       if (gn->suffix)
+           gn->suffix->refCount--;
+       gn->suffix = NULL;
 
-               Var_Set(PREFIX, ptr, gn);
-           }
-       }
+       if ((ptr = strrchr(gn->path, '/')) != NULL)
+           ptr++;
+       else
+           ptr = gn->path;
+
+       Var_Set(PREFIX, ptr, gn);
     }
 }
 



Home | Main Index | Thread Index | Old Index