char *base, *newName;
char *newName;
ParseLookupIncludeFile(spec, endSpec, isSystem, errIfNotFound)    char *spec;    char *endSpec;    Boolean isSystem;    Boolean errIfNotFound;{    char *file;    char *fullname;    char endc;    /* Substitute for any variables in the file name before trying to     * find the thing.	*/    endc = *endSpec;    *endSpec = '\0';    file = Var_Subst(spec, NULL, FALSE);    *endSpec = endc;    /* Now that we know the file name and its search path, we attempt to     * find the durn thing. NULL indicates the file still hasn't been     * found.  */    fullname = NULL;    /* Handle non-system non-absolute files... */    if (!isSystem && file[0] != '/') {	/* ... by first searching relative to the including file's	 * location. We don't want to cd there, of course, so we	 * just tack on the old file's leading path components	 * and call Dir_FindFile to see if we can locate the beast.  */	char	  *slash;	slash = strrchr(Parse_Getfilename(), '/');	if (slash != NULL) {	    char *base, *newName;	    base = interval_dup(Parse_Getfilename(), slash);	    newName = str_concat(base, file, '/');	    free(base);	    fullname = Dir_FindFile(newName, &parseIncPath);	    if (fullname == NULL)		fullname = Dir_FindFile(newName, &dirSearchPath);	    free(newName);	}    }    /* Now look first on the -I search path, then on the .PATH     * search path, if not found in a -I directory.     * XXX: Suffix specific?  */    if (fullname == NULL)	fullname = Dir_FindFile(file, &parseIncPath);    if (fullname == NULL)	fullname = Dir_FindFile(file, &dirSearchPath);    /* Still haven't found the makefile. Look for it on the system     * path as a last resort.  */    if (fullname == NULL)	fullname = Dir_FindFile(file, &sysIncPath);    if (fullname == NULL && errIfNotFound)	    Parse_Error(PARSE_FATAL, "Could not find %s", file);	    free(file);    if (fullname != NULL) {	FILE *f;	f = fopen(fullname, "r");	if (f == NULL && errIfNotFound) {	    Parse_Error(PARSE_FATAL, "Cannot open %s", fullname);	} else {	    /* Once we find the absolute path to the file, we push the current	     * stream to the includes stack, and start reading from the new	     * file.  We set up the file name to be its absolute name so that	     * error messages are informative.	*/	    Parse_FromFile(fullname, f);	}    }}