Subject: Re: make: Dir_FindFile still broken
To: Simon Gerraty <sjg@juniper.net>
From: Christos Zoulas <christos@zoulas.com>
List: tech-toolchain
Date: 11/14/2002 15:41:24
On Nov 14, 11:52am, sjg@juniper.net (Simon Gerraty) wrote:
-- Subject: Re: make: Dir_FindFile still broken

I think I like this :-)

christos

| I've always wanted to be able to get make -V .PATH to do something
| useful.  Now it does.  From this we can see that 'cur' is always the
| first entry in .PATH (followed by '.'), so the XXX comment in
| DirLookupSubdir asking if 'dot' should be looked up rather than 'cur'
| when .DOTLAST is not set, is correct - the initial call using 'cur'
| was pointless anyway.
| 
| --sjg
| 
| --- dir.c.~1~	Mon Sep 16 16:16:14 2002
| +++ dir.c	Thu Nov 14 11:48:35 2002
| @@ -237,6 +237,7 @@ Dir_Init (const char *cdname)
|      openDirectories = Lst_Init (FALSE);
|      Hash_InitTable(&mtimes, 0);
|  
| +    Var_Delete(".PATH", VAR_GLOBAL);
|      if (cdname != NULL) {
|  	/*
|  	 * Our build directory is not the same as our source directory.
| @@ -1070,9 +1090,7 @@ Dir_FindFile(char *name, Lst path)
|  	    printf("failed. Trying subdirectories...");
|  	}
|  
| -	/* XXX - should we look in `dot' subdirs here? */
| -
| -	if (!hasLastDot && cur && (file = DirLookupSubdir(cur, name)) != NULL)
| +	if (!hasLastDot && dot && (file = DirLookupSubdir(dot, name)) != NULL)
|  	    return file;
|  
|  	(void) Lst_Open (path);
| @@ -1305,7 +1323,7 @@ Dir_MTime(GNode *gn)
|  Path *
|  Dir_AddDir(Lst path, const char *name)
|  {
| -    LstNode       ln;	      /* node in case Path structure is found */
| +    LstNode       ln = NILLNODE; /* node in case Path structure is found */
|      Path	  *p = NULL;  /* pointer to new Path structure */
|      DIR     	  *d;	      /* for reading directory */
|      struct dirent *dp;	      /* entry in directory */
| @@ -1320,7 +1338,8 @@ Dir_AddDir(Lst path, const char *name)
|  	}
|      }
|  
| -    ln = Lst_Find (openDirectories, (ClientData)name, DirFindName);
| +    if (path)
| +	ln = Lst_Find (openDirectories, (ClientData)name, DirFindName);
|      if (ln != NILLNODE) {
|  	p = (Path *)Lst_Datum (ln);
|  	if (Lst_Member(path, (ClientData)p) == NILLNODE) {
| @@ -1339,6 +1358,7 @@ Dir_AddDir(Lst path, const char *name)
|  	    p->hits = 0;
|  	    p->refCount = 1;
|  	    Hash_InitTable (&p->files, -1);
| +	    Var_Append(".PATH", p->name, VAR_GLOBAL);
|  
|  	    /*
|  	     * Skip the first two entries -- these will *always* be . and ..
| --- parse.c.~1~	Mon Sep 16 16:16:15 2002
| +++ parse.c	Thu Nov 14 11:48:06 2002
| @@ -1158,6 +1158,7 @@ ParseDoDependency(char *line)
|  		break;
|  	    case ExPath:
|  		Lst_ForEach(paths, ParseClearPath, (ClientData)NULL);
| +		Var_Delete(".PATH", VAR_GLOBAL);
|  		break;
|  #ifdef POSIX
|              case Posix:
| @@ -1598,6 +1599,16 @@ Parse_DoVar(char *line, GNode *ctxt)
|      }
|      if (strcmp(line, MAKEOVERRIDES) == 0)
|  	Main_ExportMAKEFLAGS(FALSE);	/* re-export MAKEFLAGS */
| +    else if (strcmp(line, ".CURDIR") == 0) {
| +	/*
| +	 * Somone is trying to be way too clever.
| +	 * Let's just pretend they know what they are doing...
| +	 * and re-initialize dirSearchPath
| +	 */
| +	Dir_End();
| +	Dir_Init(cp);
| +	Dir_InitDot();
| +    }
|  }
|  
|  
-- End of excerpt from Simon Gerraty