Module Name:    src
Committed By:   rillig
Date:           Mon Aug 10 19:30:30 UTC 2020

Modified Files:
        src/usr.bin/make: dir.c make.h nonints.h str.c suff.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/usr.bin/make/dir.c
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/make/make.h
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/make/str.c
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/make/suff.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.85 src/usr.bin/make/dir.c:1.86
--- src/usr.bin/make/dir.c:1.85	Sun Aug  9 19:51:02 2020
+++ src/usr.bin/make/dir.c	Mon Aug 10 19:30:30 2020
@@ -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 @@ Dir_MakeFlags(const char *flag, Lst path
     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);

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.113 src/usr.bin/make/make.h:1.114
--- src/usr.bin/make/make.h:1.113	Sat Aug  1 18:02:37 2020
+++ src/usr.bin/make/make.h	Mon Aug 10 19:30:30 2020
@@ -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 @@ typedef struct GNode {
 #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.

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.91 src/usr.bin/make/nonints.h:1.92
--- src/usr.bin/make/nonints.h:1.91	Sun Aug  9 13:05:04 2020
+++ src/usr.bin/make/nonints.h	Mon Aug 10 19:30:30 2020
@@ -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 @@ void Parse_SetInput(const char *, int, i
 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 *);

Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.57 src/usr.bin/make/str.c:1.58
--- src/usr.bin/make/str.c:1.57	Mon Aug 10 19:20:33 2020
+++ src/usr.bin/make/str.c	Mon Aug 10 19:30:30 2020
@@ -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 @@ __RCSID("$NetBSD: str.c,v 1.57 2020/08/1
  *	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 @@ str_concat(const char *s1, const char *s
 	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;
 	}

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.93 src/usr.bin/make/suff.c:1.94
--- src/usr.bin/make/suff.c:1.93	Sat Aug  1 14:47:49 2020
+++ src/usr.bin/make/suff.c	Mon Aug 10 19:30:30 2020
@@ -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 @@ SuffAddSrc(void *sp, void *lsp)
 #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 @@ SuffApplyTransform(GNode *tGn, GNode *sG
     /*
      * 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);
 

Reply via email to