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): fix parameter name of str_concat



details:   https://anonhg.NetBSD.org/src/rev/a27753bb9136
branches:  trunk
changeset: 974779:a27753bb9136
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Aug 10 19:30:30 2020 +0000

description:
make(1): fix parameter name of str_concat

The previous documentation mentioned Str_Concat, but str_concat has been
written in lowercase for years.  The "flags" are not flags since they
cannot be combined, not even when they are written in hex.

diffstat:

 usr.bin/make/dir.c     |   8 ++++----
 usr.bin/make/make.h    |  14 +-------------
 usr.bin/make/nonints.h |  11 +++++++++--
 usr.bin/make/str.c     |  12 ++++++------
 usr.bin/make/suff.c    |  10 +++++-----
 5 files changed, 25 insertions(+), 30 deletions(-)

diffs (180 lines):

diff -r a24e863e701d -r a27753bb9136 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Mon Aug 10 19:29:13 2020 +0000
+++ b/usr.bin/make/dir.c        Mon Aug 10 19:30:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.85 2020/08/09 19:51:02 rillig Exp $  */
+/*     $NetBSD: dir.c,v 1.86 2020/08/10 19:30:30 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.85 2020/08/09 19:51:02 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.86 2020/08/10 19:30:30 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c      8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.85 2020/08/09 19:51:02 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.86 2020/08/10 19:30:30 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1735,7 +1735,7 @@
     if (Lst_Open(path) == SUCCESS) {
        while ((ln = Lst_Next(path)) != NULL) {
            p = (Path *)Lst_Datum(ln);
-           s2 = str_concat(flag, p->name, 0);
+           s2 = str_concat(flag, p->name, STR_ADDNONE);
            str = str_concat(s1 = str, s2, STR_ADDSPACE);
            free(s1);
            free(s2);
diff -r a24e863e701d -r a27753bb9136 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Mon Aug 10 19:29:13 2020 +0000
+++ b/usr.bin/make/make.h       Mon Aug 10 19:30:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.113 2020/08/01 18:02:37 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.114 2020/08/10 19:30:30 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -314,18 +314,6 @@
 #define TARG_NOHASH    0x02      /* don't look in/add to hash table */
 
 /*
- * These constants are all used by the Str_Concat function to decide how the
- * final string should look. If STR_ADDSPACE is given, a space will be
- * placed between the two strings. If STR_ADDSLASH is given, a '/' will
- * be used instead of a space. If neither is given, no intervening characters
- * will be placed between the two strings in the final output. If the
- * STR_DOFREE bit is set, the two input strings will be freed before
- * Str_Concat returns.
- */
-#define STR_ADDSPACE   0x01    /* add a space when Str_Concat'ing */
-#define STR_ADDSLASH   0x02    /* add a slash when Str_Concat'ing */
-
-/*
  * Error levels for parsing. PARSE_FATAL means the process cannot continue
  * once the makefile has been parsed. PARSE_WARNING means it can. Passed
  * as the first argument to Parse_Error.
diff -r a24e863e701d -r a27753bb9136 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Mon Aug 10 19:29:13 2020 +0000
+++ b/usr.bin/make/nonints.h    Mon Aug 10 19:30:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.91 2020/08/09 13:05:04 rillig Exp $      */
+/*     $NetBSD: nonints.h,v 1.92 2020/08/10 19:30:30 rillig Exp $      */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -134,7 +134,14 @@
 Lst Parse_MainName(void);
 
 /* str.c */
-char *str_concat(const char *, const char *, int);
+
+typedef enum {
+    STR_ADDNONE,               /* just concat the two strings */
+    STR_ADDSPACE,              /* add a space between the two strings */
+    STR_ADDSLASH               /* add a slash between the two strings */
+} StrConcatMode;
+
+char *str_concat(const char *, const char *, StrConcatMode);
 char **brk_string(const char *, int *, Boolean, char **);
 char *Str_FindSubstring(const char *, const char *);
 Boolean Str_Match(const char *, const char *);
diff -r a24e863e701d -r a27753bb9136 usr.bin/make/str.c
--- a/usr.bin/make/str.c        Mon Aug 10 19:29:13 2020 +0000
+++ b/usr.bin/make/str.c        Mon Aug 10 19:30:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: str.c,v 1.57 2020/08/10 19:20:33 rillig Exp $  */
+/*     $NetBSD: str.c,v 1.58 2020/08/10 19:30:30 rillig Exp $  */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.57 2020/08/10 19:20:33 rillig Exp $";
+static char rcsid[] = "$NetBSD: str.c,v 1.58 2020/08/10 19:30:30 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char     sccsid[] = "@(#)str.c  5.8 (Berkeley) 6/1/90";
 #else
-__RCSID("$NetBSD: str.c,v 1.57 2020/08/10 19:20:33 rillig Exp $");
+__RCSID("$NetBSD: str.c,v 1.58 2020/08/10 19:30:30 rillig Exp $");
 #endif
 #endif                         /* not lint */
 #endif
@@ -91,7 +91,7 @@
  *     the resulting string in allocated space.
  */
 char *
-str_concat(const char *s1, const char *s2, int flags)
+str_concat(const char *s1, const char *s2, StrConcatMode mode)
 {
        size_t len1 = strlen(s1);
        size_t len2 = strlen(s2);
@@ -101,10 +101,10 @@
        memcpy(result, s1, len1);
 
        /* add separator character */
-       if (flags & STR_ADDSPACE) {
+       if (mode == STR_ADDSPACE) {
                result[len1] = ' ';
                ++len1;
-       } else if (flags & STR_ADDSLASH) {
+       } else if (mode == STR_ADDSLASH) {
                result[len1] = '/';
                ++len1;
        }
diff -r a24e863e701d -r a27753bb9136 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Mon Aug 10 19:29:13 2020 +0000
+++ b/usr.bin/make/suff.c       Mon Aug 10 19:30:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.93 2020/08/01 14:47:49 rillig Exp $ */
+/*     $NetBSD: suff.c,v 1.94 2020/08/10 19:30:30 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.93 2020/08/01 14:47:49 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.94 2020/08/10 19:30:30 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.93 2020/08/01 14:47:49 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.94 2020/08/10 19:30:30 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1222,7 +1222,7 @@
 #endif
     }
     s2 = bmake_malloc(sizeof(Src));
-    s2->file =             str_concat(targ->pref, s->name, 0);
+    s2->file =             str_concat(targ->pref, s->name, STR_ADDNONE);
     s2->pref =     targ->pref;
     s2->parent =    targ;
     s2->node =             NULL;
@@ -1821,7 +1821,7 @@
     /*
      * Locate the transformation rule itself
      */
-    tname = str_concat(s->name, t->name, 0);
+    tname = str_concat(s->name, t->name, STR_ADDNONE);
     ln = Lst_Find(transforms, tname, SuffGNHasNameP);
     free(tname);
 



Home | Main Index | Thread Index | Old Index