]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Delay caching of the file name in eval_makefile() until after all the
authorBoris Kolpackov <boris@kolpackov.net>
Fri, 29 Apr 2011 15:27:39 +0000 (15:27 +0000)
committerBoris Kolpackov <boris@kolpackov.net>
Fri, 29 Apr 2011 15:27:39 +0000 (15:27 +0000)
expansions and searches are complete. This fixes an assertion in a
situation where the MAKEFILES variable contains a file path that
contains tilde.

ChangeLog
read.c

index 7d2155acd8e577983bad52c7684f13098de20993..e365f6bb2206d49eefcd4a15ddae00e5a4509cd4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-04-29 Boris Kolpackov  <boris@codesynthesis.com>
+
+       * read.c (eval_makefile): Delay caching of the file name until after
+       all the expansions and searches.
+
 2011-04-17  David A. Wheeler  <dwheeler@dwheeler.com>
 
        * doc/make.texi (Reading Makefiles): Document "!=".
diff --git a/read.c b/read.c
index c13ead8754e896b6de190b2850589f6c3463c7cf..299c2e5d47ab1bf52f20e86da73a6e231f4b4fbb 100644 (file)
--- a/read.c
+++ b/read.c
@@ -324,8 +324,7 @@ eval_makefile (const char *filename, int flags)
   char *expanded = 0;
   int makefile_errno;
 
-  filename = strcache_add (filename);
-  ebuf.floc.filenm = filename;
+  ebuf.floc.filenm = filename; /* Use the original file name.  */
   ebuf.floc.lineno = 1;
 
   if (ISDB (DB_VERBOSE))
@@ -369,13 +368,17 @@ eval_makefile (const char *filename, int flags)
                                          "/", filename);
          ebuf.fp = fopen (included, "r");
          if (ebuf.fp)
-           {
-             filename = strcache_add (included);
-             break;
-           }
+            {
+              filename = included;
+              break;
+            }
        }
     }
 
+  /* Now we have the final name for this makefile. Enter it into
+     the cache.  */
+  filename = strcache_add (filename);
+
   /* Add FILENAME to the chain of read makefiles.  */
   deps = alloc_dep ();
   deps->next = read_makefiles;