=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/dir.c,v retrieving revision 1.21 retrieving revision 1.22 diff -c -r1.21 -r1.22 *** src/usr.bin/make/dir.c 2000/06/17 14:40:27 1.21 --- src/usr.bin/make/dir.c 2000/06/23 16:15:49 1.22 *************** *** 1,4 **** ! /* $OpenBSD: dir.c,v 1.21 2000/06/17 14:40:27 espie Exp $ */ /* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: dir.c,v 1.22 2000/06/23 16:15:49 espie Exp $ */ /* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */ /* *************** *** 43,49 **** #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else ! static char rcsid[] = "$OpenBSD: dir.c,v 1.21 2000/06/17 14:40:27 espie Exp $"; #endif #endif /* not lint */ --- 43,49 ---- #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else ! static char rcsid[] = "$OpenBSD: dir.c,v 1.22 2000/06/23 16:15:49 espie Exp $"; #endif #endif /* not lint */ *************** *** 522,534 **** LstNode ln; /* Current node */ Path *p; /* Directory in the node */ ! if (Lst_Open(path) == SUCCESS) { ! while ((ln = Lst_Next(path)) != NULL) { ! p = (Path *)Lst_Datum(ln); ! DirMatchFiles(word, p, expansions); ! } ! Lst_Close(path); } } /*- --- 522,533 ---- LstNode ln; /* Current node */ Path *p; /* Directory in the node */ ! Lst_Open(path); ! while ((ln = Lst_Next(path)) != NULL) { ! p = (Path *)Lst_Datum(ln); ! DirMatchFiles(word, p, expansions); } + Lst_Close(path); } /*- *************** *** 710,722 **** return (estrdup (name)); } ! if (Lst_Open (path) == FAILURE) { ! if (DEBUG(DIR)) { ! printf("couldn't open path, file not found\n"); ! } ! misses += 1; ! return ((char *) NULL); ! } /* * We look through all the directories on the path seeking one which --- 709,715 ---- return (estrdup (name)); } ! Lst_Open(path); /* * We look through all the directories on the path seeking one which *************** *** 727,733 **** * we go on to phase two... */ while ((ln = Lst_Next (path)) != NULL) { ! p = (Path *) Lst_Datum (ln); if (DEBUG(DIR)) { printf("%s...", p->name); } --- 720,726 ---- * we go on to phase two... */ while ((ln = Lst_Next (path)) != NULL) { ! p = (Path *)Lst_Datum(ln); if (DEBUG(DIR)) { printf("%s...", p->name); } *************** *** 809,817 **** if (DEBUG(DIR)) { printf("failed. Trying subdirectories..."); } ! (void) Lst_Open (path); while ((ln = Lst_Next (path)) != NULL) { ! p = (Path *) Lst_Datum (ln); if (p != dot) { file = str_concat (p->name, name, STR_ADDSLASH); } else { --- 802,810 ---- if (DEBUG(DIR)) { printf("failed. Trying subdirectories..."); } ! Lst_Open(path); while ((ln = Lst_Next (path)) != NULL) { ! p = (Path *)Lst_Datum(ln); if (p != dot) { file = str_concat (p->name, name, STR_ADDSLASH); } else { *************** *** 907,918 **** cp[-1] = '/'; bigmisses += 1; ! ln = Lst_Last (path); ! if (ln == NULL) { ! return ((char *) NULL); ! } else { ! p = (Path *) Lst_Datum (ln); ! } if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) { return (estrdup (name)); --- 900,910 ---- cp[-1] = '/'; bigmisses += 1; ! ln = Lst_Last(path); ! if (ln == NULL) ! return NULL; ! else ! p = (Path *)Lst_Datum(ln); if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) { return (estrdup (name)); *************** *** 1051,1057 **** ln = Lst_Find(&openDirectories, DirFindName, name); if (ln != NULL) { ! p = (Path *)Lst_Datum (ln); if (Lst_Member(path, p) == NULL) { p->refCount += 1; Lst_AtEnd(path, p); --- 1043,1049 ---- ln = Lst_Find(&openDirectories, DirFindName, name); if (ln != NULL) { ! p = (Path *)Lst_Datum(ln); if (Lst_Member(path, p) == NULL) { p->refCount += 1; Lst_AtEnd(path, p); *************** *** 1139,1145 **** *----------------------------------------------------------------------- */ char * ! Dir_MakeFlags (flag, path) char *flag; /* flag which should precede each directory */ Lst path; /* list of directories */ { --- 1131,1137 ---- *----------------------------------------------------------------------- */ char * ! Dir_MakeFlags(flag, path) char *flag; /* flag which should precede each directory */ Lst path; /* list of directories */ { *************** *** 1148,1165 **** 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)) != NULL) { ! p = (Path *) Lst_Datum (ln); ! tstr = str_concat (flag, p->name, 0); ! str = str_concat (str, tstr, STR_ADDSPACE | STR_DOFREE); ! } ! Lst_Close (path); } ! return (str); } /*- --- 1140,1156 ---- LstNode ln; /* the node of the current directory */ Path *p; /* the structure describing the current directory */ ! str = estrdup(""); ! Lst_Open(path); ! while ((ln = Lst_Next(path)) != NULL) { ! p = (Path *)Lst_Datum(ln); ! tstr = str_concat(flag, p->name, 0); ! str = str_concat(str, tstr, STR_ADDSPACE | STR_DOFREE); } + Lst_Close(path); ! return str; } /*- *************** *** 1242,1248 **** LstNode ln; Path *p; ! for (ln = Lst_First(path2); ln != NULL; ln = Lst_Succ(ln)) { p = (Path *)Lst_Datum(ln); if (Lst_Member(path1, p) == NULL) { p->refCount += 1; --- 1233,1239 ---- LstNode ln; Path *p; ! for (ln = Lst_First(path2); ln != NULL; ln = Lst_Adv(ln)) { p = (Path *)Lst_Datum(ln); if (Lst_Member(path1, p) == NULL) { p->refCount += 1; *************** *** 1264,1276 **** (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 = (Path *) Lst_Datum (ln); ! printf ("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits); ! } ! Lst_Close(&openDirectories); } } static void --- 1255,1266 ---- (hits+bigmisses+nearmisses ? hits * 100 / (hits + bigmisses + nearmisses) : 0)); printf ("# %-20s referenced\thits\n", "directory"); ! Lst_Open(&openDirectories); ! while ((ln = Lst_Next(&openDirectories)) != NULL) { ! p = (Path *)Lst_Datum(ln); ! printf("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits); } + Lst_Close(&openDirectories); } static void