Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make: split IncludeFile into separate functions
details: https://anonhg.NetBSD.org/src/rev/09df81ecb6fe
branches: trunk
changeset: 366720:09df81ecb6fe
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jun 10 22:35:05 2022 +0000
description:
make: split IncludeFile into separate functions
No functional change.
diffstat:
usr.bin/make/parse.c | 50 +++++++++++++++++++++++++-------------------------
1 files changed, 25 insertions(+), 25 deletions(-)
diffs (86 lines):
diff -r 8c6e91509280 -r 09df81ecb6fe usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Fri Jun 10 22:23:19 2022 +0000
+++ b/usr.bin/make/parse.c Fri Jun 10 22:35:05 2022 +0000
@@ -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 @@
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 @@
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);
- }
-
- /* Looking for a system file or file still not found */
+ if (fullname == NULL && !isSystem)
+ fullname = FindInQuotPath(file);
+
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index