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): remove module name from local function...



details:   https://anonhg.NetBSD.org/src/rev/71a455017314
branches:  trunk
changeset: 978464:71a455017314
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 21 23:51:28 2020 +0000

description:
make(1): remove module name from local functions in Suff module

The module name doesn't provide any useful information.  More often than
not, it creates a wrong impression of a very specific function name; the
function name has to be expressive enough even without the module name.
The word Suff may have even be misleading since not all of the functions
in this module affect suffixes, some also simply work on strings.

Module boundaries are marked by function names of the form Module_Func.
Therefore, local function names don't need to start with the module
name.

Rename the FindDeps functions to list their hierarchical position in the
function name, from broad to narrow.

diffstat:

 usr.bin/make/suff.c |  116 ++++++++++++++++++++++++++--------------------------
 1 files changed, 58 insertions(+), 58 deletions(-)

diffs (truncated from 488 to 300 lines):

diff -r 275b51794965 -r 71a455017314 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Sat Nov 21 23:25:29 2020 +0000
+++ b/usr.bin/make/suff.c       Sat Nov 21 23:51:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.280 2020/11/21 23:25:29 rillig Exp $        */
+/*     $NetBSD: suff.c,v 1.281 2020/11/21 23:51:28 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*     "@(#)suff.c     8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.280 2020/11/21 23:25:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.281 2020/11/21 23:51:28 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -238,7 +238,7 @@
  * Return NULL if it ain't, pointer to character in str after prefix if so.
  */
 static const char *
-SuffStrIsPrefix(const char *pref, const char *str)
+StrIsPrefix(const char *pref, const char *str)
 {
     while (*str && *pref == *str) {
        pref++;
@@ -392,7 +392,7 @@
 }
 
 static void
-SuffRelate(Suffix *srcSuff, Suffix *targSuff)
+Relate(Suffix *srcSuff, Suffix *targSuff)
 {
     SuffixList_Insert(targSuff->children, srcSuff);
     SuffixList_Insert(srcSuff->parents, targSuff);
@@ -447,7 +447,7 @@
  * Return TRUE if the string is a valid transformation.
  */
 static Boolean
-SuffParseTransform(const char *str, Suffix **out_src, Suffix **out_targ)
+ParseTransform(const char *str, Suffix **out_src, Suffix **out_targ)
 {
     SuffixListNode *ln;
     Suffix *singleSrc = NULL;
@@ -461,7 +461,7 @@
     for (ln = sufflist->first; ln != NULL; ln = ln->next) {
        Suffix *src = ln->datum;
 
-       if (SuffStrIsPrefix(src->name, str) == NULL)
+       if (StrIsPrefix(src->name, str) == NULL)
            continue;
 
        if (str[src->nameLen] == '\0') {
@@ -501,7 +501,7 @@
 {
     Suffix *src, *targ;
 
-    return SuffParseTransform(str, &src, &targ);
+    return ParseTransform(str, &src, &targ);
 }
 
 /* Add the transformation rule to the list of rules and place the
@@ -545,7 +545,7 @@
     gn->type = OP_TRANSFORM;
 
     {
-       Boolean ok = SuffParseTransform(name, &srcSuff, &targSuff);
+       Boolean ok = ParseTransform(name, &srcSuff, &targSuff);
        assert(ok);
        (void)ok;
     }
@@ -555,7 +555,7 @@
      */
     SUFF_DEBUG2("defining transformation from `%s' to `%s'\n",
                srcSuff->name, targSuff->name);
-    SuffRelate(srcSuff, targSuff);
+    Relate(srcSuff, targSuff);
 
     return gn;
 }
@@ -590,7 +590,7 @@
      * SuffParseTransform() may fail for special rules which are not
      * actual transformation rules. (e.g. .DEFAULT)
      */
-    if (!SuffParseTransform(gn->name, &srcSuff, &targSuff))
+    if (!ParseTransform(gn->name, &srcSuff, &targSuff))
        return;
 
     SUFF_DEBUG2("deleting incomplete transformation from `%s' to `%s'\n",
@@ -616,7 +616,7 @@
  *     suff            Suffix to rebuild
  */
 static void
-SuffRebuildGraph(GNode *transform, Suffix *suff)
+RebuildGraph(GNode *transform, Suffix *suff)
 {
     const char *name = transform->name;
     size_t nameLen = strlen(name);
@@ -625,12 +625,12 @@
     /*
      * First see if it is a transformation from this suffix.
      */
-    toName = SuffStrIsPrefix(suff->name, name);
+    toName = StrIsPrefix(suff->name, name);
     if (toName != NULL) {
        Suffix *to = FindSuffixByName(toName);
        if (to != NULL) {
            /* Link in and return, since it can't be anything else. */
-           SuffRelate(suff, to);
+           Relate(suff, to);
            return;
        }
     }
@@ -642,7 +642,7 @@
     if (toName != NULL) {
        Suffix *from = FindSuffixByNameLen(name, (size_t)(toName - name));
        if (from != NULL)
-           SuffRelate(from, suff);
+           Relate(from, suff);
     }
 }
 
@@ -657,7 +657,7 @@
  *     TRUE iff a new main target has been selected.
  */
 static Boolean
-SuffUpdateTarget(GNode *target, GNode **inout_main, Suffix *suff,
+UpdateTarget(GNode *target, GNode **inout_main, Suffix *suff,
                 Boolean *inout_removedMain)
 {
     Suffix *srcSuff, *targSuff;
@@ -693,7 +693,7 @@
     if (ptr == target->name)
        return FALSE;
 
-    if (SuffParseTransform(target->name, &srcSuff, &targSuff)) {
+    if (ParseTransform(target->name, &srcSuff, &targSuff)) {
        if (*inout_main == target) {
            *inout_removedMain = TRUE;
            *inout_main = NULL;
@@ -707,7 +707,7 @@
         */
        SUFF_DEBUG2("defining transformation from `%s' to `%s'\n",
                    srcSuff->name, targSuff->name);
-       SuffRelate(srcSuff, targSuff);
+       Relate(srcSuff, targSuff);
     }
     return FALSE;
 }
@@ -724,7 +724,7 @@
     GNodeListNode *ln;
     for (ln = Targ_List()->first; ln != NULL; ln = ln->next) {
        GNode *gn = ln->datum;
-       if (SuffUpdateTarget(gn, inout_main, suff, &r))
+       if (UpdateTarget(gn, inout_main, suff, &r))
            break;
     }
 }
@@ -760,7 +760,7 @@
      * XXX: Only do this after a Suff_ClearSuffixes?
      */
     for (ln = transforms->first; ln != NULL; ln = ln->next)
-       SuffRebuildGraph(ln->datum, suff);
+       RebuildGraph(ln->datum, suff);
 }
 
 /* Return the search path for the given suffix, or NULL. */
@@ -910,7 +910,7 @@
  *     targ            parent for the new Src
  */
 static void
-SuffAddSources(Suffix *suff, SrcList *srcList, Src *targ)
+AddSources(Suffix *suff, SrcList *srcList, Src *targ)
 {
     if ((suff->flags & SUFF_NULL) && suff->name[0] != '\0') {
        /*
@@ -925,19 +925,19 @@
 
 /* Add all the children of targ to the list. */
 static void
-SuffAddLevel(SrcList *srcs, Src *targ)
+AddLevel(SrcList *srcs, Src *targ)
 {
     SrcListNode *ln;
     for (ln = targ->suff->children->first; ln != NULL; ln = ln->next) {
        Suffix *childSuff = ln->datum;
-       SuffAddSources(childSuff, srcs, targ);
+       AddSources(childSuff, srcs, targ);
     }
 }
 
 /* Free the first Src in the list that is not referenced anymore.
  * Return whether a Src was removed. */
 static Boolean
-SuffRemoveSrc(SrcList *srcs)
+RemoveSrc(SrcList *srcs)
 {
     SrcListNode *ln;
 
@@ -984,7 +984,7 @@
 
 /* Find the first existing file/target in srcs. */
 static Src *
-SuffFindThem(SrcList *srcs, SrcList *slst)
+FindThem(SrcList *srcs, SrcList *slst)
 {
     Src *retsrc = NULL;
 
@@ -1019,7 +1019,7 @@
 
        SUFF_DEBUG0("not there\n");
 
-       SuffAddLevel(srcs, src);
+       AddLevel(srcs, src);
        Lst_Append(slst, src);
     }
 
@@ -1040,7 +1040,7 @@
  *     The Src of the "winning" child, or NULL.
  */
 static Src *
-SuffFindCmds(Src *targ, SrcList *slst)
+FindCmds(Src *targ, SrcList *slst)
 {
     GNodeListNode *gln;
     GNode *tgn;                        /* Target GNode */
@@ -1112,7 +1112,7 @@
 }
 
 static void
-SuffExpandWildcards(GNodeListNode *cln, GNode *pgn)
+ExpandWildcards(GNodeListNode *cln, GNode *pgn)
 {
     GNode *cgn = cln->datum;
     StringList *expansions;
@@ -1166,7 +1166,7 @@
  *     pgn             Parent node being processed
  */
 static void
-SuffExpandChildren(GNodeListNode *cln, GNode *pgn)
+ExpandChildren(GNodeListNode *cln, GNode *pgn)
 {
     GNode *cgn = cln->datum;
     GNode *gn;                 /* New source 8) */
@@ -1187,7 +1187,7 @@
      * the children list.
      */
     if (strchr(cgn->name, '$') == NULL) {
-       SuffExpandWildcards(cln, pgn);
+       ExpandWildcards(cln, pgn);
        return;
     }
 
@@ -1289,7 +1289,7 @@
            Lst_Append(gn->parents, pgn);
            pgn->unmade++;
            /* Expand wildcards on new node */
-           SuffExpandWildcards(cln->prev, pgn);
+           ExpandWildcards(cln->prev, pgn);
        }
        Lst_Free(members);
 
@@ -1360,7 +1360,7 @@
  *     TRUE if successful, FALSE if not.
  */
 static Boolean
-SuffApplyTransform(GNode *tgn, GNode *sgn, Suffix *tsuff, Suffix *ssuff)
+ApplyTransform(GNode *tgn, GNode *sgn, Suffix *tsuff, Suffix *ssuff)
 {
     GNodeListNode *ln;
     char *tname;               /* Name of transformation rule */
@@ -1398,7 +1398,7 @@
     ln = ln != NULL ? ln->next : NULL;
     while (ln != NULL) {
        GNodeListNode *nln = ln->next;
-       SuffExpandChildren(ln, tgn);
+       ExpandChildren(ln, tgn);
        ln = nln;
     }
 
@@ -1412,7 +1412,7 @@
 }
 
 
-static void SuffFindDeps(GNode *, SrcList *);
+static void FindDeps(GNode *, SrcList *);
 
 /* Locate dependencies for an OP_ARCHV node.
  *
@@ -1423,7 +1423,7 @@
  *     Same as Suff_FindDeps
  */
 static void
-SuffFindArchiveDeps(GNode *gn, SrcList *slst)
+FindDepsArchive(GNode *gn, SrcList *slst)
 {
     char *eoarch;              /* End of archive portion */
     char *eoname;              /* End of member portion */
@@ -1459,7 +1459,7 @@



Home | Main Index | Thread Index | Old Index