-/* $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 $ */
/*-
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));
-/* $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 $ */
/*
#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 */
#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,
* 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");
curPTR = (PTR *) emalloc (sizeof (PTR));
curPTR->str = curPTR->ptr = str;
lineno = newlineno;
- fname = estrdup(fname);
}
* 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");
if ((ifile = (IFile *)Lst_DeQueue(includes)) == NULL)
return DONE;
- free ((Address) fname);
fname = ifile->fname;
lineno = ifile->lineno;
if (opened && curFILE)
*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;
includes = Lst_Init();
#ifdef CLEANUP
targCmds = Lst_Init();
+ fileNames = Lst_Init();
#endif
}
{
#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);
return lineno;
}
+const char *
+Parse_Getfilename()
+{
+ return fname;
+}
+