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): make data types in Dir_HasWildcards mo...
details: https://anonhg.NetBSD.org/src/rev/4a9e321eabea
branches: trunk
changeset: 938080:4a9e321eabea
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Sep 01 17:56:32 2020 +0000
description:
make(1): make data types in Dir_HasWildcards more precise
diffstat:
usr.bin/make/dir.c | 29 +++++++++++++++--------------
usr.bin/make/dir.h | 12 +++++++-----
2 files changed, 22 insertions(+), 19 deletions(-)
diffs (118 lines):
diff -r 4d05ab663190 -r 4a9e321eabea usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Tue Sep 01 17:40:34 2020 +0000
+++ b/usr.bin/make/dir.c Tue Sep 01 17:56:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.127 2020/08/30 14:11:42 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.128 2020/09/01 17:56:32 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.127 2020/08/30 14:11:42 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.128 2020/09/01 17:56:32 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.127 2020/08/30 14:11:42 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.128 2020/09/01 17:56:32 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -517,36 +517,37 @@
* returns TRUE if the word should be expanded, FALSE otherwise
*/
Boolean
-Dir_HasWildcards(char *name)
+Dir_HasWildcards(const char *name)
{
- char *cp;
- int wild = 0, brace = 0, bracket = 0;
+ const char *cp;
+ Boolean wild = FALSE;
+ int braces = 0, brackets = 0;
for (cp = name; *cp; cp++) {
switch (*cp) {
case '{':
- brace++;
- wild = 1;
+ braces++;
+ wild = TRUE;
break;
case '}':
- brace--;
+ braces--;
break;
case '[':
- bracket++;
- wild = 1;
+ brackets++;
+ wild = TRUE;
break;
case ']':
- bracket--;
+ brackets--;
break;
case '?':
case '*':
- wild = 1;
+ wild = TRUE;
break;
default:
break;
}
}
- return wild && bracket == 0 && brace == 0;
+ return wild && brackets == 0 && braces == 0;
}
/*-
diff -r 4d05ab663190 -r 4a9e321eabea usr.bin/make/dir.h
--- a/usr.bin/make/dir.h Tue Sep 01 17:40:34 2020 +0000
+++ b/usr.bin/make/dir.h Tue Sep 01 17:56:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.h,v 1.20 2020/08/22 21:42:38 rillig Exp $ */
+/* $NetBSD: dir.h,v 1.21 2020/09/01 17:56:32 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -75,12 +75,14 @@
#ifndef MAKE_DIR_H
#define MAKE_DIR_H
-typedef struct Path {
+/* A cache of a directory, remembering all the files that exist in that
+ * directory. */
+typedef struct {
char *name; /* Name of directory */
int refCount; /* Number of paths with this directory */
int hits; /* the number of times a file in this
* directory has been found */
- Hash_Table files; /* Hash table of files in directory */
+ Hash_Table files; /* Hash set of files in directory */
} Path;
void Dir_Init(void);
@@ -89,7 +91,7 @@
void Dir_InitDot(void);
void Dir_End(void);
void Dir_SetPATH(void);
-Boolean Dir_HasWildcards(char *);
+Boolean Dir_HasWildcards(const char *);
void Dir_Expand(const char *, Lst, Lst);
char *Dir_FindFile(const char *, Lst);
int Dir_FindHereOrAbove(char *, char *, char *, int);
@@ -101,6 +103,6 @@
void Dir_PrintDirectories(void);
void Dir_PrintPath(Lst);
void Dir_Destroy(void *);
-void * Dir_CopyDir(void *);
+void *Dir_CopyDir(void *);
#endif /* MAKE_DIR_H */
Home |
Main Index |
Thread Index |
Old Index