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): rename some Dir functions to SearchPath



details:   https://anonhg.NetBSD.org/src/rev/514df0462e22
branches:  trunk
changeset: 946473:514df0462e22
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 28 22:13:56 2020 +0000

description:
make(1): rename some Dir functions to SearchPath

These functions have the search path as their main subject.

diffstat:

 usr.bin/make/dir.c   |  22 ++++++++++++----------
 usr.bin/make/dir.h   |  10 +++++-----
 usr.bin/make/parse.c |   6 +++---
 usr.bin/make/suff.c  |  27 +++++++++++++++------------
 4 files changed, 35 insertions(+), 30 deletions(-)

diffs (223 lines):

diff -r 58dd5b849ae8 -r 514df0462e22 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c        Sat Nov 28 19:26:10 2020 +0000
+++ b/usr.bin/make/dir.c        Sat Nov 28 22:13:56 2020 +0000
@@ -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 @@
        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_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 @@
  *-----------------------------------------------------------------------
  */
 char *
-Dir_MakeFlags(const char *flag, SearchPath *path)
+SearchPath_ToFlags(const char *flag, SearchPath *path)
 {
        Buffer buf;
        SearchPathNode *ln;
@@ -1548,7 +1550,7 @@
 /* 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 @@
 /* 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 @@
 }
 
 void
-Dir_PrintPath(SearchPath *path)
+SearchPath_Print(SearchPath *path)
 {
        SearchPathNode *node;
        for (node = path->first; node != NULL; node = node->next) {
diff -r 58dd5b849ae8 -r 514df0462e22 usr.bin/make/dir.h
--- a/usr.bin/make/dir.h        Sat Nov 28 19:26:10 2020 +0000
+++ b/usr.bin/make/dir.h        Sat Nov 28 22:13:56 2020 +0000
@@ -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_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);
 
diff -r 58dd5b849ae8 -r 514df0462e22 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Nov 28 19:26:10 2020 +0000
+++ b/usr.bin/make/parse.c      Sat Nov 28 22:13:56 2020 +0000
@@ -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 @@
     if (paths != NULL) {
        SearchPathListNode *ln;
        for (ln = paths->first; ln != NULL; ln = ln->next)
-           Dir_ClearPath(ln->datum);
+           SearchPath_Clear(ln->datum);
     }
 
     Dir_SetPATH();
diff -r 58dd5b849ae8 -r 514df0462e22 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Sat Nov 28 19:26:10 2020 +0000
+++ b/usr.bin/make/suff.c       Sat Nov 28 22:13:56 2020 +0000
@@ -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 @@
        SuffFree(nullSuff);
     emptySuff = nullSuff = Suffix_New("");
 
-    Dir_Concat(nullSuff->searchPath, dirSearchPath);
+    SearchPath_AddAll(nullSuff->searchPath, dirSearchPath);
     nullSuff->flags = SUFF_NULL;
 }
 
@@ -834,7 +834,7 @@
 Suff_DoPaths(void)
 {
     SuffixListNode *ln;
-    char *ptr;
+    char *flags;
     SearchPath *inIncludes; /* Cumulative .INCLUDES path */
     SearchPath *inLibs;            /* Cumulative .LIBS path */
 
@@ -846,23 +846,26 @@
        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 @@
     PrintSuffNames("From", suff->children);
 
     debug_printf("#\tSearch Path: ");
-    Dir_PrintPath(suff->searchPath);
+    SearchPath_Print(suff->searchPath);
     debug_printf("\n");
 }
 



Home | Main Index | Thread Index | Old Index