diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1996-11-30 21:09:23 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1996-11-30 21:09:23 +0000 |
commit | 67e9b81bf2c3acfeba94fdb222f197904c16cfef (patch) | |
tree | d3c86e29fa60fc56eb72f9263478434f9b2f3607 /usr.bin/make/dir.c | |
parent | 66030e0876e2f9722b759c1df2901e526a7be102 (diff) |
Sync with NetBSD:
- Merge in FreeBSD and Lite2 changes.
- Fix bug where a non-archive target with a .a suffix would always
be considered to be out of date, since it does not have a TOC.
- Fix NetBSD PR #2930: declare missing variable.
Diffstat (limited to 'usr.bin/make/dir.c')
-rw-r--r-- | usr.bin/make/dir.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index 7e3ae7b0023..79622bcedf1 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -1,5 +1,5 @@ -/* $OpenBSD: dir.c,v 1.5 1996/09/02 16:04:09 briggs Exp $ */ -/* $NetBSD: dir.c,v 1.11 1996/08/13 16:42:02 christos Exp $ */ +/* $OpenBSD: dir.c,v 1.6 1996/11/30 21:08:53 millert Exp $ */ +/* $NetBSD: dir.c,v 1.12 1996/11/06 17:59:04 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -41,9 +41,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)dir.c 5.6 (Berkeley) 12/28/90"; +static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -static char rcsid[] = "$OpenBSD: dir.c,v 1.5 1996/09/02 16:04:09 briggs Exp $"; +static char rcsid[] = "$OpenBSD: dir.c,v 1.6 1996/11/30 21:08:53 millert Exp $"; #endif #endif /* not lint */ @@ -218,7 +218,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), @@ -298,7 +298,7 @@ Dir_HasWildcards (name) char *name; /* name to check */ { register char *cp; - + for (cp = name; *cp; cp++) { switch(*cp) { case '{': @@ -334,12 +334,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)) @@ -558,7 +558,7 @@ Dir_Expand (word, path, expansions) if (DEBUG(DIR)) { printf("expanding \"%s\"...", word); } - + cp = strchr(word, '{'); if (cp) { DirExpandCurly(word, cp, path, expansions); @@ -632,7 +632,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. */ @@ -677,7 +677,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) @@ -690,7 +690,7 @@ Dir_FindFile (name, path) hasSlash = FALSE; cp = name; } - + if (DEBUG(DIR)) { printf("Searching for %s...", name); } @@ -709,7 +709,7 @@ Dir_FindFile (name, path) dot->hits += 1; return (estrdup (name)); } - + if (Lst_Open (path) == FAILURE) { if (DEBUG(DIR)) { printf("couldn't open path, file not found\n"); @@ -717,7 +717,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 @@ -782,7 +782,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. @@ -802,10 +802,10 @@ Dir_FindFile (name, path) misses += 1; return ((char *) NULL); } - + if (*name != '/') { Boolean checkedDot = FALSE; - + if (DEBUG(DIR)) { printf("failed. Trying subdirectories..."); } @@ -824,15 +824,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 @@ -847,7 +847,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. @@ -865,7 +865,7 @@ Dir_FindFile (name, path) free (file); } } - + if (DEBUG(DIR)) { printf("failed. "); } @@ -882,7 +882,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 @@ -904,7 +904,7 @@ Dir_FindFile (name, path) cp[-1] = '\0'; Dir_AddDir (path, name); cp[-1] = '/'; - + bigmisses += 1; ln = Lst_Last (path); if (ln == NILLNODE) { @@ -912,7 +912,7 @@ Dir_FindFile (name, path) } else { p = (Path *) Lst_Datum (ln); } - + if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) { return (estrdup (name)); } else { @@ -922,7 +922,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) { @@ -952,7 +952,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 * @@ -970,7 +970,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) { @@ -978,7 +978,7 @@ Dir_MTime (gn) } else { fullName = gn->path; } - + if (fullName == (char *)NULL) { fullName = estrdup(gn->name); } @@ -1008,7 +1008,7 @@ Dir_MTime (gn) if (fullName && gn->path == (char *)NULL) { gn->path = fullName; } - + gn->mtime = stb.st_mtime; return (gn->mtime); } @@ -1024,7 +1024,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. *----------------------------------------------------------------------- */ @@ -1038,7 +1038,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); @@ -1051,20 +1051,20 @@ Dir_AddDir (path, name) printf("Caching %s...", name); fflush(stdout); } - + if ((d = opendir (name)) != (DIR *) NULL) { p = (Path *) emalloc (sizeof (Path)); p->name = estrdup (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) { #if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */ /* @@ -1137,9 +1137,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 = estrdup (""); - + if (Lst_Open (path) == SUCCESS) { while ((ln = Lst_Next (path)) != NILLNODE) { p = (Path *) Lst_Datum (ln); @@ -1148,7 +1148,7 @@ Dir_MakeFlags (flag, path) } Lst_Close (path); } - + return (str); } @@ -1210,7 +1210,7 @@ Dir_ClearPath(path) Dir_Destroy((ClientData) p); } } - + /*- *----------------------------------------------------------------------- @@ -1249,7 +1249,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, @@ -1268,7 +1268,7 @@ Dir_PrintDirectories() static int DirPrintDir (p, dummy) ClientData p; ClientData dummy; -{ +{ printf ("%s ", ((Path *) p)->name); return (dummy ? 0 : 0); } |