diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2000-04-17 23:45:25 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2000-04-17 23:45:25 +0000 |
commit | 30ea95f57dba3607bdf80a4dbec0462eac63b41d (patch) | |
tree | 0c5b569333dd1638e7727993198a4c7780ef4e6e /usr.bin | |
parent | 5b47c63196cad2e0c7389e146f43830aa6009152 (diff) |
Don't free Makefile filenames when the file is finished reading, but
keep them for error reporting.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/make/extern.h | 3 | ||||
-rw-r--r-- | usr.bin/make/parse.c | 29 |
2 files changed, 26 insertions, 6 deletions
diff --git a/usr.bin/make/extern.h b/usr.bin/make/extern.h index c0f3ecee080..6ac0af8c4fd 100644 --- a/usr.bin/make/extern.h +++ b/usr.bin/make/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.19 2000/02/02 13:47:47 espie Exp $ */ +/* $OpenBSD: extern.h,v 1.20 2000/04/17 23:45:23 espie Exp $ */ /* $NetBSD: nonints.h,v 1.12 1996/11/06 17:59:19 christos Exp $ */ /*- @@ -98,6 +98,7 @@ void Parse_End __P((void)); void Parse_FromString __P((char *, unsigned long)); Lst Parse_MainName __P((void)); unsigned long Parse_Getlineno __P((void)); +const char *Parse_Getfilename __P((void)); /* str.c */ void str_init __P((void)); diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index a2d99608c97..309f20b43cc 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.37 2000/03/26 16:21:32 espie Exp $ */ +/* $OpenBSD: parse.c,v 1.38 2000/04/17 23:45:24 espie Exp $ */ /* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: parse.c,v 1.37 2000/03/26 16:21:32 espie Exp $"; +static char rcsid[] = "$OpenBSD: parse.c,v 1.38 2000/04/17 23:45:24 espie Exp $"; #endif #endif /* not lint */ @@ -104,6 +104,10 @@ static char rcsid[] = "$OpenBSD: parse.c,v 1.37 2000/03/26 16:21:32 espie Exp $" #include "buf.h" #include "pathnames.h" +#ifdef CLEANUP +static Lst fileNames; /* file names to free at end */ +#endif + /* * These values are returned by ParseEOF to tell Parse_File whether to * CONTINUE parsing, i.e. it had only reached the end of an include file, @@ -1808,6 +1812,9 @@ ParseDoInclude (file) * place. Naturally enough, we start reading at line number 0. */ fname = fullname; +#ifdef CLEANUP + Lst_AtEnd(fileNames, fname); +#endif lineno = 0; curFILE = fopen (fullname, "r"); @@ -1857,7 +1864,6 @@ Parse_FromString(str, newlineno) curPTR = (PTR *) emalloc (sizeof (PTR)); curPTR->str = curPTR->ptr = str; lineno = newlineno; - fname = estrdup(fname); } @@ -1991,6 +1997,9 @@ ParseTraditionalInclude (file) * place. Naturally enough, we start reading at line number 0. */ fname = fullname; +#ifdef CLEANUP + lst_AtEnd(fileNames, fname); +#endif lineno = 0; curFILE = fopen (fullname, "r"); @@ -2028,7 +2037,6 @@ ParseEOF (opened) if ((ifile = (IFile *)Lst_DeQueue(includes)) == NULL) return DONE; - free ((Address) fname); fname = ifile->fname; lineno = ifile->lineno; if (opened && curFILE) @@ -2455,7 +2463,10 @@ Parse_File(name, stream) *line; /* the line we're working on */ inLine = FALSE; - fname = name; + fname = estrdup(name); +#ifdef CLEANUP + Lst_AtEnd(fileNames, fname); +#endif curFILE = stream; lineno = 0; fatals = 0; @@ -2641,6 +2652,7 @@ Parse_Init () includes = Lst_Init(); #ifdef CLEANUP targCmds = Lst_Init(); + fileNames = Lst_Init(); #endif } @@ -2649,6 +2661,7 @@ Parse_End() { #ifdef CLEANUP Lst_Destroy(targCmds, (void (*) __P((ClientData))) free); + Lst_Destroy(fileNames, (void (*) __P((ClientData))) free); if (targets) Lst_Destroy(targets, NOFREE); Lst_Destroy(sysIncPath, Dir_Destroy); @@ -2697,3 +2710,9 @@ Parse_Getlineno() return lineno; } +const char * +Parse_Getfilename() +{ + return fname; +} + |