Module Name:    src
Committed By:   rillig
Date:           Sat Nov 28 22:13:56 UTC 2020

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

Log Message:
make(1): rename some Dir functions to SearchPath

These functions have the search path as their main subject.


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/usr.bin/make/dir.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/dir.h
cvs rdiff -u -r1.457 -r1.458 src/usr.bin/make/parse.c
cvs rdiff -u -r1.313 -r1.314 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.223 src/usr.bin/make/dir.c:1.224
--- src/usr.bin/make/dir.c:1.223	Sat Nov 28 19:22:32 2020
+++ src/usr.bin/make/dir.c	Sat Nov 28 22:13:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.223 2020/11/28 19:22:32 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.224 2020/11/28 22:13:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -106,7 +106,8 @@
  *
  *	Dir_AddDir	Add a directory to a search path.
  *
- *	Dir_MakeFlags	Given a search path and a command flag, create
+ *	SearchPath_ToFlags
+ *			Given a search path and a command flag, create
  *			a string with each of the directories in the path
  *			preceded by the command flag and all of them
  *			separated by a space.
@@ -116,7 +117,8 @@
  *			as the element is no longer referenced by any other
  *			search path.
  *
- *	Dir_ClearPath	Resets a search path to the empty list.
+ *	SearchPath_Clear
+ *			Resets a search path to the empty list.
  *
  * For debugging:
  *	Dir_PrintDirectories
@@ -134,7 +136,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.223 2020/11/28 19:22:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.224 2020/11/28 22:13:56 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -455,7 +457,7 @@ Dir_End(void)
 	dotLast->refCount--;
 	Dir_Destroy(dotLast);
 	Dir_Destroy(dot);
-	Dir_ClearPath(dirSearchPath);
+	SearchPath_Clear(dirSearchPath);
 	Lst_Free(dirSearchPath);
 	OpenDirs_Done(&openDirs);
 	HashTable_Done(&mtimes);
@@ -1485,7 +1487,7 @@ Dir_CopyDirSearchPath(void)
 
 /*-
  *-----------------------------------------------------------------------
- * Dir_MakeFlags --
+ * SearchPath_ToFlags --
  *	Make a string by taking all the directories in the given search
  *	path and preceding them by the given flag. Used by the suffix
  *	module to create variables for compilers based on suffix search
@@ -1505,7 +1507,7 @@ Dir_CopyDirSearchPath(void)
  *-----------------------------------------------------------------------
  */
 char *
-Dir_MakeFlags(const char *flag, SearchPath *path)
+SearchPath_ToFlags(const char *flag, SearchPath *path)
 {
 	Buffer buf;
 	SearchPathNode *ln;
@@ -1548,7 +1550,7 @@ Dir_Destroy(void *dirp)
 /* Clear out all elements from the given search path.
  * The path is set to the empty list but is not destroyed. */
 void
-Dir_ClearPath(SearchPath *path)
+SearchPath_Clear(SearchPath *path)
 {
 	while (!Lst_IsEmpty(path)) {
 		CachedDir *dir = Lst_Dequeue(path);
@@ -1560,7 +1562,7 @@ Dir_ClearPath(SearchPath *path)
 /* Concatenate two paths, adding the second to the end of the first,
  * skipping duplicates. */
 void
-Dir_Concat(SearchPath *dst, SearchPath *src)
+SearchPath_AddAll(SearchPath *dst, SearchPath *src)
 {
 	SearchPathNode *ln;
 
@@ -1600,7 +1602,7 @@ Dir_PrintDirectories(void)
 }
 
 void
-Dir_PrintPath(SearchPath *path)
+SearchPath_Print(SearchPath *path)
 {
 	SearchPathNode *node;
 	for (node = path->first; node != NULL; node = node->next) {

Index: src/usr.bin/make/dir.h
diff -u src/usr.bin/make/dir.h:1.35 src/usr.bin/make/dir.h:1.36
--- src/usr.bin/make/dir.h:1.35	Mon Nov 23 18:24:05 2020
+++ src/usr.bin/make/dir.h	Sat Nov 28 22:13:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.35 2020/11/23 18:24:05 rillig Exp $	*/
+/*	$NetBSD: dir.h,v 1.36 2020/11/28 22:13:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -102,11 +102,11 @@ char *Dir_FindFile(const char *, SearchP
 char *Dir_FindHereOrAbove(const char *, const char *);
 void Dir_UpdateMTime(GNode *, Boolean);
 CachedDir *Dir_AddDir(SearchPath *, const char *);
-char *Dir_MakeFlags(const char *, SearchPath *);
-void Dir_ClearPath(SearchPath *);
-void Dir_Concat(SearchPath *, SearchPath *);
+char *SearchPath_ToFlags(const char *, SearchPath *);
+void SearchPath_Clear(SearchPath *);
+void SearchPath_AddAll(SearchPath *, SearchPath *);
 void Dir_PrintDirectories(void);
-void Dir_PrintPath(SearchPath *);
+void SearchPath_Print(SearchPath *);
 void Dir_Destroy(void *);
 SearchPath *Dir_CopyDirSearchPath(void);
 

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.457 src/usr.bin/make/parse.c:1.458
--- src/usr.bin/make/parse.c:1.457	Sat Nov 28 19:20:03 2020
+++ src/usr.bin/make/parse.c	Sat Nov 28 22:13:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.457 2020/11/28 19:20:03 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.458 2020/11/28 22:13:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.457 2020/11/28 19:20:03 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.458 2020/11/28 22:13:56 rillig Exp $");
 
 /* types and constants */
 
@@ -1312,7 +1312,7 @@ ClearPaths(SearchPathList *paths)
     if (paths != NULL) {
 	SearchPathListNode *ln;
 	for (ln = paths->first; ln != NULL; ln = ln->next)
-	    Dir_ClearPath(ln->datum);
+	    SearchPath_Clear(ln->datum);
     }
 
     Dir_SetPATH();

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.313 src/usr.bin/make/suff.c:1.314
--- src/usr.bin/make/suff.c:1.313	Sat Nov 28 19:22:32 2020
+++ src/usr.bin/make/suff.c	Sat Nov 28 22:13:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.313 2020/11/28 19:22:32 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.314 2020/11/28 22:13:56 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.313 2020/11/28 19:22:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.314 2020/11/28 22:13:56 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -467,7 +467,7 @@ Suff_ClearSuffixes(void)
 	SuffFree(nullSuff);
     emptySuff = nullSuff = Suffix_New("");
 
-    Dir_Concat(nullSuff->searchPath, dirSearchPath);
+    SearchPath_AddAll(nullSuff->searchPath, dirSearchPath);
     nullSuff->flags = SUFF_NULL;
 }
 
@@ -834,7 +834,7 @@ void
 Suff_DoPaths(void)
 {
     SuffixListNode *ln;
-    char *ptr;
+    char *flags;
     SearchPath *inIncludes; /* Cumulative .INCLUDES path */
     SearchPath *inLibs;	    /* Cumulative .LIBS path */
 
@@ -846,23 +846,26 @@ Suff_DoPaths(void)
 	if (!Lst_IsEmpty(suff->searchPath)) {
 #ifdef INCLUDES
 	    if (suff->flags & SUFF_INCLUDE)
-		Dir_Concat(inIncludes, suff->searchPath);
+		SearchPath_AddAll(inIncludes, suff->searchPath);
 #endif
 #ifdef LIBRARIES
 	    if (suff->flags & SUFF_LIBRARY)
-		Dir_Concat(inLibs, suff->searchPath);
+		SearchPath_AddAll(inLibs, suff->searchPath);
 #endif
-	    Dir_Concat(suff->searchPath, dirSearchPath);
+	    SearchPath_AddAll(suff->searchPath, dirSearchPath);
 	} else {
 	    Lst_Destroy(suff->searchPath, Dir_Destroy);
 	    suff->searchPath = Dir_CopyDirSearchPath();
 	}
     }
 
-    Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL);
-    free(ptr);
-    Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL);
-    free(ptr);
+    flags = SearchPath_ToFlags("-I", inIncludes);
+    Var_Set(".INCLUDES", flags, VAR_GLOBAL);
+    free(flags);
+
+    flags = SearchPath_ToFlags("-L", inLibs);
+    Var_Set(".LIBS", flags, VAR_GLOBAL);
+    free(flags);
 
     Lst_Destroy(inIncludes, Dir_Destroy);
     Lst_Destroy(inLibs, Dir_Destroy);
@@ -2120,7 +2123,7 @@ Suffix_Print(Suffix *suff)
     PrintSuffNames("From", suff->children);
 
     debug_printf("#\tSearch Path: ");
-    Dir_PrintPath(suff->searchPath);
+    SearchPath_Print(suff->searchPath);
     debug_printf("\n");
 }
 

Reply via email to