Module Name:    src
Committed By:   rillig
Date:           Sun Sep 27 22:17:07 UTC 2020

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

Log Message:
make(1): improve documentation of CachedDir and Dir_AddDir


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/make/dir.c
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/dir.h

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.149 src/usr.bin/make/dir.c:1.150
--- src/usr.bin/make/dir.c:1.149	Sun Sep 27 21:35:16 2020
+++ src/usr.bin/make/dir.c	Sun Sep 27 22:17:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.149 2020/09/27 21:35:16 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.150 2020/09/27 22:17:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -136,7 +136,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.149 2020/09/27 21:35:16 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.150 2020/09/27 22:17:07 rillig Exp $");
 
 #define DIR_DEBUG0(fmt) \
     if (!DEBUG(DIR)) (void) 0; else fprintf(debug_file, fmt)
@@ -1480,27 +1480,17 @@ Dir_MTime(GNode *gn, Boolean recheck)
     return gn->mtime;
 }
 
-/*-
- *-----------------------------------------------------------------------
- * Dir_AddDir --
- *	Add the given name to the end of the given path. The order of
- *	the arguments is backwards so ParseDoDependency can do a
- *	Lst_ForEachUntil of its list of paths...
- *
- * Input:
- *	path		the path to which the directory should be
- *			added
- *			XXX: Why would this ever be NULL, and what does
- *			that mean?
- *	name		the name of the directory to add
+/* Read the list of filenames in the directory and store the result
+ * in openDirectories.
  *
- * Results:
- *	none
+ * If a path is given, append the directory to that path.
  *
- * Side Effects:
- *	A structure is added to the list and the directory is
- *	read and hashed.
- *-----------------------------------------------------------------------
+ * Input:
+ *	path		The path to which the directory should be
+ *			added, or NULL to only add the directory to
+ *			openDirectories
+ *	name		The name of the directory to add.
+ *			The name is not normalized in any way.
  */
 CachedDir *
 Dir_AddDir(SearchPath *path, const char *name)

Index: src/usr.bin/make/dir.h
diff -u src/usr.bin/make/dir.h:1.26 src/usr.bin/make/dir.h:1.27
--- src/usr.bin/make/dir.h:1.26	Sun Sep 27 21:35:16 2020
+++ src/usr.bin/make/dir.h	Sun Sep 27 22:17:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.26 2020/09/27 21:35:16 rillig Exp $	*/
+/*	$NetBSD: dir.h,v 1.27 2020/09/27 22:17:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -75,21 +75,21 @@
 #ifndef	MAKE_DIR_H
 #define	MAKE_DIR_H
 
-/* A cache of a directory, remembering all the files that exist in that
- * directory. */
+/* A cache for the filenames in a directory. */
 typedef struct CachedDir {
-    char *name;			/* Name of directory */
-    int refCount;		/* Number of paths with this directory */
-    int hits;			/* the number of times a file in this
+    char *name;			/* Name of directory, either absolute or
+				 * relative to the current directory.
+				 * The name is not normalized in any way,
+				 * that is, "." and "./." are different.
+				 *
+				 * Not sure what happens when .CURDIR is
+				 * assigned a new value; see Parse_DoVar. */
+    int refCount;		/* Number of SearchPaths with this directory */
+    int hits;			/* The number of times a file in this
 				 * directory has been found */
     Hash_Table files;		/* Hash set of files in directory */
 } CachedDir;
 
-struct make_stat {
-    time_t mst_mtime;
-    mode_t mst_mode;
-};
-
 void Dir_Init(void);
 void Dir_InitDir(const char *);
 void Dir_InitCur(const char *);
@@ -110,6 +110,12 @@ void Dir_PrintPath(SearchPath *);
 void Dir_Destroy(void *);
 void *Dir_CopyDir(void *);
 
+/* Stripped-down variant of struct stat. */
+struct make_stat {
+    time_t mst_mtime;
+    mode_t mst_mode;
+};
+
 int cached_lstat(const char *, struct make_stat *);
 int cached_stat(const char *, struct make_stat *);
 

Reply via email to