make(1): indent Dir_Expand with tabs instead of spaces
This commit is contained in:
parent
6b10d49042
commit
819d0d717c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: dir.c,v 1.215 2020/11/23 21:45:30 rillig Exp $ */
|
/* $NetBSD: dir.c,v 1.216 2020/11/23 21:48:42 rillig Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||||
@ -134,7 +134,7 @@
|
|||||||
#include "job.h"
|
#include "job.h"
|
||||||
|
|
||||||
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
|
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
|
||||||
MAKE_RCSID("$NetBSD: dir.c,v 1.215 2020/11/23 21:45:30 rillig Exp $");
|
MAKE_RCSID("$NetBSD: dir.c,v 1.216 2020/11/23 21:48:42 rillig Exp $");
|
||||||
|
|
||||||
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
|
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
|
||||||
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
|
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
|
||||||
@ -762,98 +762,98 @@ PrintExpansions(StringList *expansions)
|
|||||||
void
|
void
|
||||||
Dir_Expand(const char *word, SearchPath *path, StringList *expansions)
|
Dir_Expand(const char *word, SearchPath *path, StringList *expansions)
|
||||||
{
|
{
|
||||||
const char *cp;
|
const char *cp;
|
||||||
|
|
||||||
assert(path != NULL);
|
assert(path != NULL);
|
||||||
assert(expansions != NULL);
|
assert(expansions != NULL);
|
||||||
|
|
||||||
DIR_DEBUG1("Expanding \"%s\"... ", word);
|
DIR_DEBUG1("Expanding \"%s\"... ", word);
|
||||||
|
|
||||||
cp = strchr(word, '{');
|
cp = strchr(word, '{');
|
||||||
if (cp != NULL) {
|
if (cp != NULL) {
|
||||||
DirExpandCurly(word, cp, path, expansions);
|
DirExpandCurly(word, cp, path, expansions);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* At this point, the word does not contain '{'. */
|
/* At this point, the word does not contain '{'. */
|
||||||
|
|
||||||
cp = strchr(word, '/');
|
cp = strchr(word, '/');
|
||||||
if (cp == NULL) {
|
if (cp == NULL) {
|
||||||
/* The word has no directory component. */
|
/* The word has no directory component. */
|
||||||
/* First the files in dot. */
|
/* First the files in dot. */
|
||||||
DirMatchFiles(word, dot, expansions);
|
DirMatchFiles(word, dot, expansions);
|
||||||
|
|
||||||
/* Then the files in every other directory on the path. */
|
/* Then the files in every other directory on the path. */
|
||||||
DirExpandPath(word, path, expansions);
|
DirExpandPath(word, path, expansions);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* At this point, the word has a directory component. */
|
/* At this point, the word has a directory component. */
|
||||||
|
|
||||||
/* Find the first wildcard in the string. */
|
/* Find the first wildcard in the string. */
|
||||||
for (cp = word; *cp != '\0'; cp++)
|
for (cp = word; *cp != '\0'; cp++)
|
||||||
if (*cp == '?' || *cp == '[' || *cp == '*')
|
if (*cp == '?' || *cp == '[' || *cp == '*')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (*cp == '\0') {
|
if (*cp == '\0') {
|
||||||
/*
|
/*
|
||||||
* No directory component and no wildcard at all -- this should
|
* No directory component and no wildcard at all -- this
|
||||||
* never happen as in such a simple case there is no need to
|
* should never happen as in such a simple case there is no
|
||||||
* expand anything.
|
* need to expand anything.
|
||||||
*/
|
*/
|
||||||
DirExpandPath(word, path, expansions);
|
DirExpandPath(word, path, expansions);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Back up to the start of the component containing the wildcard. */
|
/* Back up to the start of the component containing the wildcard. */
|
||||||
/* XXX: This handles '///' and '/' differently. */
|
/* XXX: This handles '///' and '/' differently. */
|
||||||
while (cp > word && *cp != '/')
|
while (cp > word && *cp != '/')
|
||||||
cp--;
|
cp--;
|
||||||
|
|
||||||
if (cp == word) {
|
if (cp == word) {
|
||||||
/* The first component contains the wildcard. */
|
/* The first component contains the wildcard. */
|
||||||
/* Start the search from the local directory */
|
/* Start the search from the local directory */
|
||||||
DirExpandPath(word, path, expansions);
|
DirExpandPath(word, path, expansions);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
char *prefix = bmake_strsedup(word, cp + 1);
|
char *prefix = bmake_strsedup(word, cp + 1);
|
||||||
/*
|
/*
|
||||||
* The wildcard isn't in the first component.
|
* The wildcard isn't in the first component.
|
||||||
* Find all the components up to the one with the wildcard.
|
* Find all the components up to the one with the wildcard.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* XXX: Check the "the directory is added to the path" part.
|
* XXX: Check the "the directory is added to the path" part.
|
||||||
* It is probably surprising that the directory before a wildcard
|
* It is probably surprising that the directory before a
|
||||||
* gets added to the path.
|
* wildcard gets added to the path.
|
||||||
*/
|
*/
|
||||||
char *dirpath = Dir_FindFile(prefix, path);
|
char *dirpath = Dir_FindFile(prefix, path);
|
||||||
free(prefix);
|
free(prefix);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dirpath is null if can't find the leading component
|
* dirpath is null if can't find the leading component
|
||||||
* XXX: Dir_FindFile won't find internal components.
|
* XXX: Dir_FindFile won't find internal components.
|
||||||
* i.e. if the path contains ../Etc/Object and we're
|
* i.e. if the path contains ../Etc/Object and we're
|
||||||
* looking for Etc, it won't be found. Ah well.
|
* looking for Etc, it won't be found. Ah well.
|
||||||
* Probably not important.
|
* Probably not important.
|
||||||
* XXX: Check whether the above comment is still true.
|
* XXX: Check whether the above comment is still true.
|
||||||
*/
|
*/
|
||||||
if (dirpath != NULL) {
|
if (dirpath != NULL) {
|
||||||
char *dp = &dirpath[strlen(dirpath) - 1];
|
char *dp = &dirpath[strlen(dirpath) - 1];
|
||||||
if (*dp == '/')
|
if (*dp == '/')
|
||||||
*dp = '\0';
|
*dp = '\0';
|
||||||
|
|
||||||
path = Lst_New();
|
path = Lst_New();
|
||||||
(void)Dir_AddDir(path, dirpath);
|
(void)Dir_AddDir(path, dirpath);
|
||||||
DirExpandPath(cp + 1, path, expansions);
|
DirExpandPath(cp + 1, path, expansions);
|
||||||
Lst_Free(path);
|
Lst_Free(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (DEBUG(DIR))
|
if (DEBUG(DIR))
|
||||||
PrintExpansions(expansions);
|
PrintExpansions(expansions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find if the file with the given name exists in the given path.
|
/* Find if the file with the given name exists in the given path.
|
||||||
|
Loading…
Reference in New Issue
Block a user