diff options
Diffstat (limited to 'usr.bin/make/dir.c')
-rw-r--r-- | usr.bin/make/dir.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index 6ed3c19..70f5038 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -211,7 +211,7 @@ Dir_Init () dirSearchPath = Lst_Init (FALSE); openDirectories = Lst_Init (FALSE); Hash_InitTable(&mtimes, 0); - + /* * Since the Path structure is placed on both openDirectories and * the path we give Dir_AddDir (which in this case is openDirectories), @@ -291,7 +291,7 @@ Dir_HasWildcards (name) char *name; /* name to check */ { register char *cp; - + for (cp = name; *cp; cp++) { switch(*cp) { case '{': @@ -327,12 +327,12 @@ DirMatchFiles (pattern, p, expansions) Path *p; /* Directory to search */ Lst expansions; /* Place to store the results */ { - Hash_Search search; /* Index into the directory's table */ + 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 . */ - + isDot = (*p->name == '.' && p->name[1] == '\0'); - + for (entry = Hash_EnumFirst(&p->files, &search); entry != (Hash_Entry *)NULL; entry = Hash_EnumNext(&search)) @@ -551,7 +551,7 @@ Dir_Expand (word, path, expansions) if (DEBUG(DIR)) { printf("expanding \"%s\"...", word); } - + cp = strchr(word, '{'); if (cp) { DirExpandCurly(word, cp, path, expansions); @@ -625,7 +625,7 @@ Dir_Expand (word, path, expansions) * First the files in dot */ DirMatchFiles(word, dot, expansions); - + /* * Then the files in every other directory on the path. */ @@ -670,7 +670,7 @@ Dir_FindFile (name, path) Boolean hasSlash; /* true if 'name' contains a / */ struct stat stb; /* Buffer for stat, if necessary */ Hash_Entry *entry; /* Entry for mtimes table */ - + /* * Find the final component of the name and note whether it has a * slash in it (the name, I mean) @@ -683,7 +683,7 @@ Dir_FindFile (name, path) hasSlash = FALSE; cp = name; } - + if (DEBUG(DIR)) { printf("Searching for %s...", name); } @@ -702,7 +702,7 @@ Dir_FindFile (name, path) dot->hits += 1; return (strdup (name)); } - + if (Lst_Open (path) == FAILURE) { if (DEBUG(DIR)) { printf("couldn't open path, file not found\n"); @@ -710,7 +710,7 @@ Dir_FindFile (name, path) misses += 1; return ((char *) NULL); } - + /* * We look through all the directories on the path seeking one which * contains the final component of the given name and whose final @@ -775,7 +775,7 @@ Dir_FindFile (name, path) } } } - + /* * We didn't find the file on any existing members of the directory. * If the name doesn't contain a slash, that means it doesn't exist. @@ -795,10 +795,10 @@ Dir_FindFile (name, path) misses += 1; return ((char *) NULL); } - + if (*name != '/') { Boolean checkedDot = FALSE; - + if (DEBUG(DIR)) { printf("failed. Trying subdirectories..."); } @@ -817,15 +817,15 @@ Dir_FindFile (name, path) if (DEBUG(DIR)) { printf("checking %s...", file); } - - + + if (stat (file, &stb) == 0) { if (DEBUG(DIR)) { printf("got it.\n"); } - + Lst_Close (path); - + /* * We've found another directory to search. We know there's * a slash in 'file' because we put one there. We nuke it after @@ -840,7 +840,7 @@ Dir_FindFile (name, path) *cp = '\0'; Dir_AddDir (path, file); *cp = '/'; - + /* * Save the modification time so if it's needed, we don't have * to fetch it again. @@ -858,7 +858,7 @@ Dir_FindFile (name, path) free (file); } } - + if (DEBUG(DIR)) { printf("failed. "); } @@ -875,7 +875,7 @@ Dir_FindFile (name, path) return(NULL); } } - + /* * Didn't find it that way, either. Sigh. Phase 3. Add its directory * onto the search path in any case, just in case, then look for the @@ -897,7 +897,7 @@ Dir_FindFile (name, path) cp[-1] = '\0'; Dir_AddDir (path, name); cp[-1] = '/'; - + bigmisses += 1; ln = Lst_Last (path); if (ln == NILLNODE) { @@ -905,7 +905,7 @@ Dir_FindFile (name, path) } else { p = (Path *) Lst_Datum (ln); } - + if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) { return (strdup (name)); } else { @@ -915,7 +915,7 @@ Dir_FindFile (name, path) if (DEBUG(DIR)) { printf("Looking for \"%s\"...", name); } - + bigmisses += 1; entry = Hash_FindEntry(&mtimes, name); if (entry != (Hash_Entry *)NULL) { @@ -945,7 +945,7 @@ Dir_FindFile (name, path) * Dir_MTime -- * Find the modification time of the file described by gn along the * search path dirSearchPath. - * + * * Results: * The modification time or 0 if it doesn't exist * @@ -963,7 +963,7 @@ Dir_MTime (gn) char *fullName; /* the full pathname of name */ struct stat stb; /* buffer for finding the mod time */ Hash_Entry *entry; - + if (gn->type & OP_ARCHV) { return Arch_MTime (gn); } else if (gn->path == (char *)NULL) { @@ -971,7 +971,7 @@ Dir_MTime (gn) } else { fullName = gn->path; } - + if (fullName == (char *)NULL) { fullName = strdup(gn->name); } @@ -1001,7 +1001,7 @@ Dir_MTime (gn) if (fullName && gn->path == (char *)NULL) { gn->path = fullName; } - + gn->mtime = stb.st_mtime; return (gn->mtime); } @@ -1017,7 +1017,7 @@ Dir_MTime (gn) * none * * Side Effects: - * A structure is added to the list and the directory is + * A structure is added to the list and the directory is * read and hashed. *----------------------------------------------------------------------- */ @@ -1031,7 +1031,7 @@ Dir_AddDir (path, name) register Path *p; /* pointer to new Path structure */ DIR *d; /* for reading directory */ register struct dirent *dp; /* entry in directory */ - + ln = Lst_Find (openDirectories, (ClientData)name, DirFindName); if (ln != NILLNODE) { p = (Path *)Lst_Datum (ln); @@ -1044,20 +1044,20 @@ Dir_AddDir (path, name) printf("Caching %s...", name); fflush(stdout); } - + if ((d = opendir (name)) != (DIR *) NULL) { p = (Path *) emalloc (sizeof (Path)); p->name = strdup (name); p->hits = 0; p->refCount = 1; Hash_InitTable (&p->files, -1); - + /* * Skip the first two entries -- these will *always* be . and .. */ (void)readdir(d); (void)readdir(d); - + while ((dp = readdir (d)) != (struct dirent *) NULL) { #ifdef sun /* @@ -1130,9 +1130,9 @@ Dir_MakeFlags (flag, path) char *tstr; /* the current directory preceded by 'flag' */ LstNode ln; /* the node of the current directory */ Path *p; /* the structure describing the current directory */ - + str = strdup (""); - + if (Lst_Open (path) == SUCCESS) { while ((ln = Lst_Next (path)) != NILLNODE) { p = (Path *) Lst_Datum (ln); @@ -1141,7 +1141,7 @@ Dir_MakeFlags (flag, path) } Lst_Close (path); } - + return (str); } @@ -1203,7 +1203,7 @@ Dir_ClearPath(path) Dir_Destroy((ClientData) p); } } - + /*- *----------------------------------------------------------------------- @@ -1242,7 +1242,7 @@ Dir_PrintDirectories() { LstNode ln; Path *p; - + printf ("#*** Directory Cache:\n"); printf ("# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n", hits, misses, nearmisses, bigmisses, @@ -1261,7 +1261,7 @@ Dir_PrintDirectories() static int DirPrintDir (p, dummy) ClientData p; ClientData dummy; -{ +{ printf ("%s ", ((Path *) p)->name); return (dummy ? 0 : 0); } |