Module Name: src
Committed By: rillig
Date: Fri Jun 10 22:35:05 UTC 2022
Modified Files:
src/usr.bin/make: parse.c
Log Message:
make: split IncludeFile into separate functions
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.673 -r1.674 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.673 src/usr.bin/make/parse.c:1.674
--- src/usr.bin/make/parse.c:1.673 Fri Jun 10 22:23:19 2022
+++ src/usr.bin/make/parse.c Fri Jun 10 22:35:05 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.673 2022/06/10 22:23:19 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.674 2022/06/10 22:35:05 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.673 2022/06/10 22:23:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.674 2022/06/10 22:35:05 rillig Exp $");
/*
* A file being read.
@@ -1147,6 +1147,25 @@ FindInDirOfIncludingFile(const char *fil
return fullname;
}
+static char *
+FindInQuotPath(const char *file)
+{
+ const char *suff;
+ SearchPath *suffPath;
+ char *fullname;
+
+ fullname = FindInDirOfIncludingFile(file);
+ if (fullname == NULL &&
+ (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);
+ return fullname;
+}
+
/*
* Handle one of the .[-ds]include directives by remembering the current file
* and pushing the included file on the stack. After the included file has
@@ -1166,27 +1185,10 @@ IncludeFile(const char *file, bool isSys
fullname = file[0] == '/' ? bmake_strdup(file) : NULL;
- if (fullname == NULL && !isSystem) {
- fullname = FindInDirOfIncludingFile(file);
- if (fullname == NULL) {
- const char *suff;
- SearchPath *suffPath;
-
- 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);
- }
+ if (fullname == NULL && !isSystem)
+ fullname = FindInQuotPath(file);
- /* Looking for a system file or file still not found */
if (fullname == NULL) {
- /*
- * Look for it on the system path
- */
SearchPath *path = Lst_IsEmpty(&sysIncPath->dirs)
? defSysIncPath : sysIncPath;
fullname = Dir_FindFile(file, path);
@@ -1198,9 +1200,7 @@ IncludeFile(const char *file, bool isSys
return;
}
- /* Actually open the file... */
- fd = open(fullname, O_RDONLY);
- if (fd == -1) {
+ if ((fd = open(fullname, O_RDONLY)) == -1) {
if (!silent)
Parse_Error(PARSE_FATAL, "Cannot open %s", fullname);
free(fullname);