]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Formerly read.c.~37~
authorRoland McGrath <roland@redhat.com>
Wed, 16 Sep 1992 20:15:19 +0000 (20:15 +0000)
committerRoland McGrath <roland@redhat.com>
Wed, 16 Sep 1992 20:15:19 +0000 (20:15 +0000)
read.c

diff --git a/read.c b/read.c
index 5933447dfe62ddc81aa1bedcdcf8fbedc9c80196..31ca06a2b23759663c21457a3e697d7e711a0ac6 100644 (file)
--- a/read.c
+++ b/read.c
@@ -234,6 +234,8 @@ read_makefile (filename, type)
   int two_colon;
   char *pattern = 0, *pattern_percent;
 
+  int makefile_errno;
+
 #define record_waiting_files()                                               \
   do                                                                         \
     {                                                                        \
@@ -252,6 +254,8 @@ read_makefile (filename, type)
   /* First, get a stream to read.  */
 
   infile = fopen (filename, "r");
+  /* Save the error code so we print the right message later.  */
+  makefile_errno = errno;
 
   /* If the makefile wasn't found and it's either a makefile from
      the `MAKEFILES' variable (type 1) or an included makefile (type 2),
@@ -297,7 +301,12 @@ read_makefile (filename, type)
   if (infile == 0)
     {
       if (type != 1)
-       perror_with_name ("fopen: ", filename);
+       {
+         /* If we did some searching, errno has the error
+            from the last attempt, rather from FILENAME itself.  */
+         errno = makefile_errno;
+         perror_with_name ("fopen: ", filename);
+       }
       return;
     }