summaryrefslogtreecommitdiff
path: root/src/read.c
diff options
context:
space:
mode:
authorDmitry Goncharov <dgoncharov@users.sf.net>2021-09-06 20:20:28 -0400
committerPaul Smith <psmith@gnu.org>2021-09-06 20:20:28 -0400
commite7eb8b5962efe316b08a4a6209d2a63130d1f22f (patch)
tree70f2d72230a4d145e855b662f154764c4671ec57 /src/read.c
parent0c2fc00544b89314643561dcb6d78f35eb98da68 (diff)
downloadmake-git-e7eb8b5962efe316b08a4a6209d2a63130d1f22f.tar.gz
[SV 57778] Don't ignore included makefiles that can't be read
If we find an included makefile but it's not readable, stop immediately with an error rather than continuing to look in other directories. * src/read.c (eval_makefile): Only keep searching if the fopen error is ENOENT, else stop and fail. * tests/scripts/features/include: Add tests to verify this behavior.
Diffstat (limited to 'src/read.c')
-rw-r--r--src/read.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/read.c b/src/read.c
index 58c69a25..1db51cfa 100644
--- a/src/read.c
+++ b/src/read.c
@@ -370,20 +370,27 @@ eval_makefile (const char *filename, unsigned short flags)
}
}
- /* If the makefile wasn't found and it's either a makefile from
- the 'MAKEFILES' variable or an included makefile,
- search the included makefile search path for this makefile. */
- if (ebuf.fp == NULL && (flags & RM_INCLUDED) && *filename != '/'
- && include_directories)
+ /* If the makefile wasn't found and it's either a makefile from the
+ 'MAKEFILES' variable or an included makefile, search the included
+ makefile search path for this makefile. */
+ if (ebuf.fp == NULL && deps->error == ENOENT && (flags & RM_INCLUDED)
+ && *filename != '/' && include_directories)
for (const char **dir = include_directories; *dir != NULL; ++dir)
{
const char *included = concat (3, *dir, "/", filename);
- ebuf.fp = fopen (included, "r");
+
+ ENULLLOOP(ebuf.fp, fopen (included, "r"));
if (ebuf.fp)
{
filename = included;
break;
}
+ if (errno != ENOENT)
+ {
+ filename = included;
+ deps->error = errno;
+ break;
+ }
}
/* Enter the final name for this makefile as a goaldep. */