Module Name: src Committed By: rillig Date: Fri Jun 10 22:04:49 UTC 2022
Modified Files: src/usr.bin/make: parse.c Log Message: make: condense code for searching a file in the paths No functional change. To generate a diff of this commit: cvs rdiff -u -r1.671 -r1.672 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.671 src/usr.bin/make/parse.c:1.672 --- src/usr.bin/make/parse.c:1.671 Sat May 7 17:25:28 2022 +++ src/usr.bin/make/parse.c Fri Jun 10 22:04:49 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.671 2022/05/07 17:25:28 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.672 2022/06/10 22:04:49 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -106,7 +106,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.671 2022/05/07 17:25:28 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.672 2022/06/10 22:04:49 rillig Exp $"); /* * A file being read. @@ -1170,31 +1170,23 @@ IncludeFile(const char *file, bool isSys } free(incdir); + /* + * Makefile wasn't found in same directory as included + * makefile. Search for it on .PATH.suffix, then on the '-I' + * search path, then on the .PATH. + */ if (fullname == NULL) { - /* - * Makefile wasn't found in same directory as included - * makefile. - * - * Search for it first on the -I search path, then on - * the .PATH search path, if not found in a -I - * directory. If we have a suffix-specific path, we - * should use that. - */ const char *suff; - SearchPath *suffPath = NULL; + SearchPath *suffPath; - if ((suff = strrchr(file, '.')) != NULL) { - suffPath = Suff_GetPath(suff); - if (suffPath != NULL) - fullname = Dir_FindFile(file, suffPath); - } - if (fullname == NULL) { - fullname = Dir_FindFile(file, parseIncPath); - if (fullname == NULL) - fullname = Dir_FindFile(file, - &dirSearchPath); - } - } + if ((suff = strrchr(file, '.')) != NULL && + (suffPath = Suff_GetPath(suff)) != NULL) + fullname = Dir_FindFile(file, suffPath); + } + if (fullname == NULL) + fullname = Dir_FindFile(file, parseIncPath); + if (fullname == NULL) + fullname = Dir_FindFile(file, &dirSearchPath); } /* Looking for a system file or file still not found */