diff options
author | Paul Smith <psmith@gnu.org> | 2006-02-10 05:29:00 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2006-02-10 05:29:00 +0000 |
commit | 5a7a42cfce638f52f702b4d317c45c7186b8c0b4 (patch) | |
tree | f212e35eac087bedeb88d64d96fb5a4c8c25d08c /read.c | |
parent | d0c4e92f1145110793ffb04596019a864c88d2fc (diff) | |
download | gunmake-5a7a42cfce638f52f702b4d317c45c7186b8c0b4.tar.gz |
- New code capability: a read-only string cache. Start of solution for
Savannah bug #15182, but not much uses it yet. Coming shortly.
- Added short-circuiting $(and ..) and $(or ...) functions.
Diffstat (limited to 'read.c')
-rw-r--r-- | read.c | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -311,10 +311,12 @@ eval_makefile (char *filename, int flags) struct dep *deps; struct ebuffer ebuf; const struct floc *curfile; + char *expanded = 0; + char *included = 0; int makefile_errno; int r; - ebuf.floc.filenm = filename; + ebuf.floc.filenm = strcache_add (filename); ebuf.floc.lineno = 1; if (ISDB (DB_VERBOSE)) @@ -337,7 +339,7 @@ eval_makefile (char *filename, int flags) in which case it was already done. */ if (!(flags & RM_NO_TILDE) && filename[0] == '~') { - char *expanded = tilde_expand (filename); + expanded = tilde_expand (filename); if (expanded != 0) filename = expanded; } @@ -354,16 +356,18 @@ eval_makefile (char *filename, int flags) register unsigned int i; for (i = 0; include_directories[i] != 0; ++i) { - char *name = concat (include_directories[i], "/", filename); - ebuf.fp = fopen (name, "r"); - if (ebuf.fp == 0) - free (name); - else + included = concat (include_directories[i], "/", filename); + ebuf.fp = fopen (included, "r"); + if (ebuf.fp) { - filename = name; + filename = included; break; } + free (included); } + /* If we're not using it, we already freed it above. */ + if (filename != included) + included = 0; } /* Add FILENAME to the chain of read makefiles. */ @@ -374,8 +378,6 @@ eval_makefile (char *filename, int flags) deps->file = lookup_file (filename); if (deps->file == 0) deps->file = enter_file (xstrdup (filename)); - if (filename != ebuf.floc.filenm) - free (filename); filename = deps->file->name; deps->changed = flags; deps->ignore_mtime = 0; @@ -384,6 +386,11 @@ eval_makefile (char *filename, int flags) if (flags & RM_DONTCARE) deps->file->dontcare = 1; + if (expanded) + free (expanded); + if (included) + free (included); + /* If the makefile can't be found at all, give up entirely. */ if (ebuf.fp == 0) |