summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@kolpackov.net>2011-04-29 15:27:39 +0000
committerBoris Kolpackov <boris@kolpackov.net>2011-04-29 15:27:39 +0000
commit15a79d723de278d76737b5cbb8d7a1afbe72de7b (patch)
tree9399f7cd071ee67505f6f0c8afc95f92d2aaca22 /read.c
parentb34438bee83ee906a23b881f257e684a0993b9b1 (diff)
downloadgunmake-15a79d723de278d76737b5cbb8d7a1afbe72de7b.tar.gz
Delay caching of the file name in eval_makefile() until after all the
expansions and searches are complete. This fixes an assertion in a situation where the MAKEFILES variable contains a file path that contains tilde.
Diffstat (limited to 'read.c')
-rw-r--r--read.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/read.c b/read.c
index c13ead8..299c2e5 100644
--- 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;