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): replace macros with functions



details:   https://anonhg.NetBSD.org/src/rev/28e5c3afb5b7
branches:  trunk
changeset: 936350:28e5c3afb5b7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 26 07:24:27 2020 +0000

description:
make(1): replace macros with functions

diffstat:

 usr.bin/make/lst.c |  42 ++++++++++++++++++++++++++----------------
 1 files changed, 26 insertions(+), 16 deletions(-)

diffs (103 lines):

diff -r e5361bcd20dc -r 28e5c3afb5b7 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c        Sun Jul 26 07:15:26 2020 +0000
+++ b/usr.bin/make/lst.c        Sun Jul 26 07:24:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.1 2020/07/26 07:15:26 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.2 2020/07/26 07:24:27 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -36,11 +36,11 @@
 #include "make_malloc.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.1 2020/07/26 07:15:26 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.2 2020/07/26 07:24:27 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.1 2020/07/26 07:15:26 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.2 2020/07/26 07:24:27 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -85,24 +85,34 @@
 #define        PAlloc(var,ptype)       var = (ptype) bmake_malloc(sizeof *(var))
 
 /*
- * LstValid (l) --
- *     Return TRUE if the list l is valid
+ * LstValid --
+ *     Return TRUE if the list is valid
  */
-#define LstValid(l)    ((Lst)(l) != NULL)
+static Boolean
+LstValid(Lst l)
+{
+    return l != NULL;
+}
 
 /*
- * LstNodeValid (ln, l) --
- *     Return TRUE if the LstNode ln is valid with respect to l
+ * LstNodeValid --
+ *     Return TRUE if the list node is valid
  */
-#define LstNodeValid(ln, l)    ((ln) != NULL)
+static Boolean
+LstNodeValid(LstNode ln)
+{
+    return ln != NULL;
+}
 
 /*
  * LstIsEmpty (l) --
  *     TRUE if the list l is empty.
  */
-#define LstIsEmpty(l)  (((List)(l))->firstPtr == NULL)
-
-/*     $NetBSD: lst.c,v 1.1 2020/07/26 07:15:26 rillig Exp $   */
+static Boolean
+LstIsEmpty(Lst l)
+{
+    return l->firstPtr == NULL;
+}
 
 /*-
  *-----------------------------------------------------------------------
@@ -275,7 +285,7 @@
     if (LstValid (l) && (LstIsEmpty (l) && ln == NULL))
        goto ok;
 
-    if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
+    if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln)) {
        return FAILURE;
     }
 
@@ -341,7 +351,7 @@
        goto ok;
     }
 
-    if (!LstValid (l) || LstIsEmpty (l)  || ! LstNodeValid (ln, l)) {
+    if (!LstValid (l) || LstIsEmpty (l)  || ! LstNodeValid (ln)) {
        return FAILURE;
     }
     ok:
@@ -447,7 +457,7 @@
     List       list = l;
     ListNode   lNode = ln;
 
-    if (!LstValid (l) || !LstNodeValid (ln, l)) {
+    if (!LstValid (l) || !LstNodeValid (ln)) {
            return FAILURE;
     }
 
@@ -722,7 +732,7 @@
 {
     ListNode   tln;
 
-    if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
+    if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln)) {
        return NULL;
     }
 



Home | Main Index | Thread Index | Old Index