diff options
author | Hartmut Brandt <harti@FreeBSD.org> | 2004-12-08 16:22:01 +0000 |
---|---|---|
committer | Hartmut Brandt <harti@FreeBSD.org> | 2004-12-08 16:22:01 +0000 |
commit | c76d7d5047d90b7777133dd0769abbfb5d58ddbf (patch) | |
tree | 033640eae93833ae9810ed9247ac98509312f27b /usr.bin/make/dir.c | |
parent | bb87c3794781abee9042b91c98c27ed8bdcfd369 (diff) | |
download | src-c76d7d5047d90b7777133dd0769abbfb5d58ddbf.tar.gz src-c76d7d5047d90b7777133dd0769abbfb5d58ddbf.zip |
Get rid of the sequential access feature of the lists. This was used
only in a couple of places and all of them except for one were easily
converted to use Lst_First/Lst_Succ. The one place is compatibility
mode in job.c where the it was used to advance to the next command on
each invocation of JobStart. For this case add a pointer to the node to
hold the currently executed command.
Notes
Notes:
svn path=/head/; revision=138564
Diffstat (limited to 'usr.bin/make/dir.c')
-rw-r--r-- | usr.bin/make/dir.c | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index c4ed05048ae6..fdaf76886607 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -506,15 +506,9 @@ static void DirExpandInt(const char *word, Lst *path, Lst *expansions) { LstNode *ln; /* Current node */ - Path *p; /* Directory in the node */ - if (Lst_Open(path) == SUCCESS) { - while ((ln = Lst_Next(path)) != NULL) { - p = Lst_Datum(ln); - DirMatchFiles(word, p, expansions); - } - Lst_Close(path); - } + for (ln = Lst_First(path); ln != NULL; ln = Lst_Succ(ln)) + DirMatchFiles(word, (Path *)Lst_Datum(ln), expansions); } /*- @@ -716,12 +710,6 @@ Dir_FindFile(char *name, Lst *path) return (estrdup(name)); } - if (Lst_Open(path) == FAILURE) { - DEBUGF(DIR, ("couldn't open path, file not found\n")); - misses += 1; - return (NULL); - } - /* * We look through all the directories on the path seeking one which * contains the final component of the given name and whose final @@ -730,7 +718,7 @@ Dir_FindFile(char *name, Lst *path) * and return the resulting string. If we don't find any such thing, * we go on to phase two... */ - while ((ln = Lst_Next(path)) != NULL) { + for (ln = Lst_First(path); ln != NULL; ln = Lst_Succ(ln)) { p = Lst_Datum(ln); DEBUGF(DIR, ("%s...", p->name)); if (Hash_FindEntry(&p->files, cp) != NULL) { @@ -761,7 +749,6 @@ Dir_FindFile(char *name, Lst *path) } file = str_concat(p->name, cp, STR_ADDSLASH); DEBUGF(DIR, ("returning %s\n", file)); - Lst_Close(path); p->hits += 1; hits += 1; return (file); @@ -776,7 +763,6 @@ Dir_FindFile(char *name, Lst *path) p1++, p2++) continue; if (*p1 == '\0' && p2 == cp - 1) { - Lst_Close(path); if (*cp == '\0' || ISDOT(cp) || ISDOTDOT(cp)) { DEBUGF(DIR, ("returning %s\n", name)); return (estrdup(name)); @@ -811,8 +797,7 @@ Dir_FindFile(char *name, Lst *path) Boolean checkedDot = FALSE; DEBUGF(DIR, ("failed. Trying subdirectories...")); - Lst_Open(path); - while ((ln = Lst_Next(path)) != NULL) { + for (ln = Lst_First(path); ln != NULL; ln = Lst_Succ(ln)) { p = Lst_Datum(ln); if (p != dot) { file = str_concat(p->name, name, STR_ADDSLASH); @@ -829,8 +814,6 @@ Dir_FindFile(char *name, Lst *path) if (stat(file, &stb) == 0) { DEBUGF(DIR, ("got it.\n")); - Lst_Close(path); - /* * We've found another directory to search. We * know there's a slash in 'file' because we put @@ -867,7 +850,6 @@ Dir_FindFile(char *name, Lst *path) } DEBUGF(DIR, ("failed. ")); - Lst_Close(path); if (checkedDot) { /* @@ -1120,16 +1102,13 @@ Dir_MakeFlags(char *flag, Lst *path) str = estrdup(""); - if (Lst_Open(path) == SUCCESS) { - while ((ln = Lst_Next(path)) != NULL) { - p = Lst_Datum(ln); - tstr = str_concat(flag, p->name, 0); - nstr = str_concat(str, tstr, STR_ADDSPACE); - free(str); - free(tstr); - str = nstr; - } - Lst_Close(path); + for (ln = Lst_First(path); ln != NULL; ln = Lst_Succ(ln)) { + p = Lst_Datum(ln); + tstr = str_concat(flag, p->name, 0); + nstr = str_concat(str, tstr, STR_ADDSPACE); + free(str); + free(tstr); + str = nstr; } return (str); @@ -1237,13 +1216,9 @@ Dir_PrintDirectories(void) (hits + bigmisses + nearmisses ? hits * 100 / (hits + bigmisses + nearmisses) : 0)); printf("# %-20s referenced\thits\n", "directory"); - if (Lst_Open(openDirectories) == SUCCESS) { - while ((ln = Lst_Next(openDirectories)) != NULL) { - p = Lst_Datum(ln); - printf("# %-20s %10d\t%4d\n", p->name, p->refCount, - p->hits); - } - Lst_Close(openDirectories); + for (ln = Lst_First(openDirectories); ln != NULL; ln = Lst_Succ(ln)) { + p = Lst_Datum(ln); + printf("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits); } } |