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): clean up comments in suff.c, small ref...



details:   https://anonhg.NetBSD.org/src/rev/332e9cd7a366
branches:  trunk
changeset: 937958:332e9cd7a366
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 29 12:01:46 2020 +0000

description:
make(1): clean up comments in suff.c, small refactorings

In SuffParseTransform, the parameter names have been renamed to make the
"side effects" comment redundant.

In Suff_AddSuffix and Suff_AddLib, the parameter has been made const.

In SuffRemoveSrc, the unused variable has been removed, and the return
type has been fixed.

diffstat:

 usr.bin/make/nonints.h |    6 +-
 usr.bin/make/suff.c    |  500 ++++++++++++------------------------------------
 2 files changed, 126 insertions(+), 380 deletions(-)

diffs (truncated from 886 to 300 lines):

diff -r 5a66075d289c -r 332e9cd7a366 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Sat Aug 29 11:24:54 2020 +0000
+++ b/usr.bin/make/nonints.h    Sat Aug 29 12:01:46 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.100 2020/08/29 07:52:55 rillig Exp $     */
+/*     $NetBSD: nonints.h,v 1.101 2020/08/29 12:01:46 rillig Exp $     */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -145,11 +145,11 @@
 Boolean Suff_IsTransform(char *);
 GNode *Suff_AddTransform(char *);
 int Suff_EndTransform(void *, void *);
-void Suff_AddSuffix(char *, GNode **);
+void Suff_AddSuffix(const char *, GNode **);
 Lst Suff_GetPath(char *);
 void Suff_DoPaths(void);
 void Suff_AddInclude(char *);
-void Suff_AddLib(char *);
+void Suff_AddLib(const char *);
 void Suff_FindDeps(GNode *);
 Lst Suff_FindPath(GNode *);
 void Suff_SetNull(char *);
diff -r 5a66075d289c -r 332e9cd7a366 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Sat Aug 29 11:24:54 2020 +0000
+++ b/usr.bin/make/suff.c       Sat Aug 29 12:01:46 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.133 2020/08/29 11:24:54 rillig Exp $        */
+/*     $NetBSD: suff.c,v 1.134 2020/08/29 12:01:46 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.133 2020/08/29 11:24:54 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.134 2020/08/29 12:01:46 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)suff.c     8.4 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: suff.c,v 1.133 2020/08/29 11:24:54 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.134 2020/08/29 12:01:46 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -217,7 +217,6 @@
 static int SuffRebuildGraph(void *, void *);
 static int SuffScanTargets(void *, void *);
 static int SuffAddSrc(void *, void *);
-static int SuffRemoveSrc(Lst);
 static void SuffAddLevel(Lst, Src *);
 static Src *SuffFindCmds(Src *, Lst);
 static void SuffExpandChildren(LstNode, GNode *);
@@ -338,22 +337,11 @@
     }
 }
 
-/*-
- *-----------------------------------------------------------------------
- * SuffFree  --
- *     Free up all memory associated with the given suffix structure.
- *
- * Results:
- *     none
- *
- * Side Effects:
- *     the suffix entry is detroyed
- *-----------------------------------------------------------------------
- */
+/* Free up all memory associated with the given suffix structure. */
 static void
 SuffFree(void *sp)
 {
-    Suff           *s = (Suff *)sp;
+    Suff *s = (Suff *)sp;
 
     if (s == suffNull)
        suffNull = NULL;
@@ -377,19 +365,7 @@
     free(s);
 }
 
-/*-
- *-----------------------------------------------------------------------
- * SuffRemove  --
- *     Remove the suffix into the list
- *
- * Results:
- *     None
- *
- * Side Effects:
- *     The reference count for the suffix is decremented and the
- *     suffix is possibly freed
- *-----------------------------------------------------------------------
- */
+/* Remove the suffix from the list, and free if it is otherwise unused. */
 static void
 SuffRemove(Lst l, Suff *s)
 {
@@ -400,22 +376,11 @@
     }
 }
 
-/*-
- *-----------------------------------------------------------------------
- * SuffInsert  --
- *     Insert the suffix into the list keeping the list ordered by suffix
- *     numbers.
+/* Insert the suffix into the list keeping the list ordered by suffix numbers.
  *
  * Input:
  *     l               the list where in s should be inserted
  *     s               the suffix to insert
- *
- * Results:
- *     None
- *
- * Side Effects:
- *     The reference count of the suffix is incremented
- *-----------------------------------------------------------------------
  */
 static void
 SuffInsert(Lst l, Suff *s)
@@ -472,23 +437,11 @@
     return s;
 }
 
-/*-
- *-----------------------------------------------------------------------
- * Suff_ClearSuffixes --
- *     This is gross. Nuke the list of suffixes but keep all transformation
- *     rules around. The transformation graph is destroyed in this process,
- *     but we leave the list of rules so when a new graph is formed the rules
- *     will remain.
- *     This function is called from the parse module when a
- *     .SUFFIXES:\n line is encountered.
- *
- * Results:
- *     none
- *
- * Side Effects:
- *     the sufflist and its graph nodes are destroyed
- *-----------------------------------------------------------------------
- */
+/* This is gross. Nuke the list of suffixes but keep all transformation
+ * rules around. The transformation graph is destroyed in this process, but
+ * we leave the list of rules so when a new graph is formed the rules will
+ * remain. This function is called from the parse module when a .SUFFIXES:\n
+ * line is encountered. */
 void
 Suff_ClearSuffixes(void)
 {
@@ -505,26 +458,18 @@
     suffNull->flags =              SUFF_NULL;
 }
 
-/*-
- *-----------------------------------------------------------------------
- * SuffParseTransform --
- *     Parse a transformation string to find its two component suffixes.
+/* Parse a transformation string to find its two component suffixes.
  *
  * Input:
  *     str             String being parsed
- *     srcPtr          Place to store source of trans.
- *     targPtr         Place to store target of trans.
+ *     out_src         Place to store source of trans.
+ *     out_targ        Place to store target of trans.
  *
  * Results:
- *     TRUE if the string is a valid transformation and FALSE otherwise.
- *
- * Side Effects:
- *     The passed pointers are overwritten.
- *
- *-----------------------------------------------------------------------
+ *     TRUE if the string is a valid transformation, FALSE otherwise.
  */
 static Boolean
-SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
+SuffParseTransform(char *str, Suff **out_src, Suff **out_targ)
 {
     LstNode            srcLn;      /* element in suffix list of trans source*/
     Suff               *src;       /* Source of transformation */
@@ -565,8 +510,8 @@
                 *
                 * XXX: Use emptySuff over suffNull?
                 */
-               *srcPtr = single;
-               *targPtr = suffNull;
+               *out_src = single;
+               *out_targ = suffNull;
                return TRUE;
            }
            return FALSE;
@@ -579,31 +524,16 @@
        } else {
            targLn = Lst_Find(sufflist, SuffSuffHasName, str2);
            if (targLn != NULL) {
-               *srcPtr = src;
-               *targPtr = Lst_Datum(targLn);
+               *out_src = src;
+               *out_targ = Lst_Datum(targLn);
                return TRUE;
            }
        }
     }
 }
 
-/*-
- *-----------------------------------------------------------------------
- * Suff_IsTransform  --
- *     Return TRUE if the given string is a transformation rule
- *
- *
- * Input:
- *     str             string to check
- *
- * Results:
- *     TRUE if the string is a concatenation of two known suffixes.
- *     FALSE otherwise
- *
- * Side Effects:
- *     None
- *-----------------------------------------------------------------------
- */
+/* Return TRUE if the given string is a transformation rule, that is, a
+ * concatenation of two known suffixes. */
 Boolean
 Suff_IsTransform(char *str)
 {
@@ -612,22 +542,17 @@
     return SuffParseTransform(str, &src, &targ);
 }
 
-/*-
- *-----------------------------------------------------------------------
- * Suff_AddTransform --
- *     Add the transformation rule described by the line to the
- *     list of rules and place the transformation itself in the graph
+/* Add the transformation rule described by the line to the list of rules
+ * and place the transformation itself in the graph.
  *
+ * The node is placed on the end of the transforms Lst and links are made
+ * between the two suffixes mentioned in the target name.
+
  * Input:
  *     line            name of transformation to add
  *
  * Results:
  *     The node created for the transformation in the transforms list
- *
- * Side Effects:
- *     The node is placed on the end of the transforms Lst and links are
- *     made between the two suffixes mentioned in the target name
- *-----------------------------------------------------------------------
  */
 GNode *
 Suff_AddTransform(char *line)
@@ -676,26 +601,18 @@
     return gn;
 }
 
-/*-
- *-----------------------------------------------------------------------
- * Suff_EndTransform --
- *     Handle the finish of a transformation definition, removing the
- *     transformation from the graph if it has neither commands nor
- *     sources. This is a callback procedure for the Parse module via
- *     Lst_ForEach
+/* Handle the finish of a transformation definition, removing the
+ * transformation from the graph if it has neither commands nor sources.
+ * This is a callback procedure for the Parse module via Lst_ForEach.
+ *
+ * If the node has no commands or children, the children and parents lists
+ * of the affected suffixes are altered.
  *
  * Input:
  *     gnp             Node for transformation
- *     dummy           Node for transformation
  *
  * Results:
- *     === 0
- *
- * Side Effects:
- *     If the node has no commands or children, the children and parents
- *     lists of the affected suffixes are altered.
- *
- *-----------------------------------------------------------------------
+ *     0, so that Lst_ForEach continues
  */
 int
 Suff_EndTransform(void *gnp, void *dummy MAKE_ATTR_UNUSED)
@@ -748,28 +665,21 @@
     return 0;
 }



Home | Main Index | Thread Index | Old Index