Date: Mon, 9 Aug 1999 06:32:35 -0700 (PDT) From: hyc@highlandsun.com To: freebsd-gnats-submit@freebsd.org Subject: bin/13042: make doesn't handle wildcards in subdirectory paths Message-ID: <19990809133235.907BE14C1A@hub.freebsd.org>
index | next in thread | raw e-mail
>Number: 13042
>Category: bin
>Synopsis: make doesn't handle wildcards in subdirectory paths
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Mon Aug 9 06:40:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator: Howard Chu
>Release: current
>Organization:
Highland Sun
>Environment:
Linux mandolin 2.2.5 #1 Tue Aug 3 07:30:26 PDT 1999 i686 unknow
>Description:
(Yes, I'm testing on Linux. I pulled the source from the current tree on ftp.freebsd.org.)
The make program only handles wildcard expansion for simple filenames.
Dependencies of the form "dir*foo/file*bar" are not handled.
>How-To-Repeat:
Use a sample Makefile like:
#
foo: sub*/lib*.a
touch foo
#
make
mkdir sub1 sub2
touch sub{1,2}/libx.a
make <-- this should cause foo to be remade, but it doesn't.
>Fix:
--- dir.c.O Sun Aug 8 15:33:58 1999
+++ dir.c Mon Aug 9 05:32:19 1999
@@ -189,7 +189,7 @@
static int DirFindName __P((ClientData, ClientData));
-static int DirMatchFiles __P((char *, Path *, Lst));
+static int DirMatchFiles __P((char *, Lst, Path *, Lst));
static void DirExpandCurly __P((char *, char *, Lst, Lst));
static void DirExpandInt __P((char *, Lst, Lst));
static int DirPrintWord __P((ClientData, ClientData));
@@ -324,16 +324,24 @@
*-----------------------------------------------------------------------
*/
static int
-DirMatchFiles (pattern, p, expansions)
+DirMatchFiles (pattern, path, p, expansions)
char *pattern; /* Pattern to look for */
+ Lst path;
Path *p; /* Directory to search */
Lst expansions; /* Place to store the results */
{
Hash_Search search; /* Index into the directory's table */
Hash_Entry *entry; /* Current entry in the table */
Boolean isDot; /* TRUE if the directory being searched is . */
+ Boolean isWild; /* TRUE if the pattern has wildcards */
+ char *cp;
isDot = (*p->name == '.' && p->name[1] == '\0');
+ isWild = Dir_HasWildcards(pattern);
+
+ if ((cp = strchr(pattern, '/'))) {
+ *cp = '\0';
+ }
for (entry = Hash_EnumFirst(&p->files, &search);
entry != (Hash_Entry *)NULL;
@@ -349,12 +357,27 @@
((entry->name[0] != '.') ||
(pattern[0] == '.')))
{
- (void)Lst_AtEnd(expansions,
- (isDot ? estrdup(entry->name) :
+ char *s = isDot ? estrdup(entry->name) :
str_concat(p->name, entry->name,
- STR_ADDSLASH)));
+ STR_ADDSLASH);
+ if (cp) {
+ LstNode ln;
+ Path *q;
+ Dir_AddDir(path, s);
+ free(s);
+ ln = Lst_Last(path);
+ q = (Path *)Lst_Datum(ln);
+ DirMatchFiles(cp+1, path, q, expansions);
+ } else {
+ (void)Lst_AtEnd(expansions, s);
+ }
+ if (!isWild)
+ break;
}
}
+ if (cp) {
+ *cp = '/';
+ }
return (0);
}
@@ -494,10 +517,11 @@
LstNode ln; /* Current node */
Path *p; /* Directory in the node */
+ DirMatchFiles(word, path, dot, expansions);
if (Lst_Open(path) == SUCCESS) {
while ((ln = Lst_Next(path)) != NILLNODE) {
p = (Path *)Lst_Datum(ln);
- DirMatchFiles(word, p, expansions);
+ DirMatchFiles(word, path, p, expansions);
}
Lst_Close(path);
}
@@ -623,11 +647,6 @@
DirExpandInt(word, path, expansions);
}
} else {
- /*
- * First the files in dot
- */
- DirMatchFiles(word, dot, expansions);
-
/*
* Then the files in every other directory on the path.
*/
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990809133235.907BE14C1A>
