Module Name: othersrc Committed By: dholland Date: Sat Mar 23 19:06:42 UTC 2013
Modified Files: othersrc/usr.bin/dholland-make2: parse.c Log Message: More arrays, fewer lists. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 othersrc/usr.bin/dholland-make2/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: othersrc/usr.bin/dholland-make2/parse.c diff -u othersrc/usr.bin/dholland-make2/parse.c:1.9 othersrc/usr.bin/dholland-make2/parse.c:1.10 --- othersrc/usr.bin/dholland-make2/parse.c:1.9 Sat Mar 23 18:35:31 2013 +++ othersrc/usr.bin/dholland-make2/parse.c Sat Mar 23 19:06:42 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.9 2013/03/23 18:35:31 dholland Exp $ */ +/* $NetBSD: parse.c,v 1.10 2013/03/23 19:06:42 dholland Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -81,10 +81,9 @@ * main entry point and controls most of the other functions in this * module. * - * Most important structures are kept in Lsts. Directories for - * the .include "..." function are kept in the 'parseIncPath' Lst, while - * those for the .include <...> are kept in the 'sysIncPath' Lst. The - * targets currently being defined are kept in the 'targets' Lst. + * Directories for .include "..." are kept in parseIncPath[]. + * Those for .include <...> are kept in sysIncPath[]. The + * targets currently being defined are kept in targets[]. * * The variables 'fname' and 'lineno' are used to track the name * of the current file and the line number in that file so that error @@ -111,7 +110,7 @@ * Parse_Error Function called when an error occurs in * parsing. Used by the variable and * conditional modules. - * Parse_MainName Returns a Lst of the main target to create. + * Parse_MainName Returns the main target(s) to create. */ #include <sys/types.h> @@ -138,7 +137,9 @@ #include "buf.h" #include "pathnames.h" -MAKE_RCSID("$NetBSD: parse.c,v 1.9 2013/03/23 18:35:31 dholland Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.10 2013/03/23 19:06:42 dholland Exp $"); + +//#define CLEANUP //////////////////////////////////////////////////////////// // types and constants @@ -159,6 +160,8 @@ typedef struct IFile { struct loadedfile *lf; /* loadedfile object, if any */ } IFile; +DECLARRAY_BYTYPE(ifilearray, struct IFile, static); +DEFARRAY_BYTYPE(ifilearray, struct IFile, MAKE_ATTR_UNUSED static); /* * These values are returned by ParseEOF to tell Parse_File whether to @@ -232,7 +235,7 @@ static GList targets; #ifdef CLEANUP /* command lines for targets */ -static Lst targCmds; +static struct stringarray targCmds; #endif /* @@ -2004,7 +2007,7 @@ Parse_AddIncludeDir(char *dir) * None * * Side Effects: - * A structure is added to the includes Lst and readProc, lineno, + * A structure is added to the includes list and readProc, lineno, * fname and curFILE are altered for the new file *--------------------------------------------------------------------- */ @@ -2245,7 +2248,7 @@ ParseTrackInput(const char *name) * None * * Side Effects: - * A structure is added to the includes Lst and readProc, lineno, + * A structure is added to the includes list and readProc, lineno, * fname and curFile are altered for the new file *--------------------------------------------------------------------- */ @@ -2269,9 +2272,10 @@ Parse_SetInput(const char *name, int lin /* sanity */ return; - if (curFile != NULL) + if (curFile != NULL) { /* Save exiting file info */ Lst_AtFront(includes, curFile); + } /* Allocate and fill in new structure */ curFile = bmake_malloc(sizeof *curFile); @@ -2319,7 +2323,7 @@ Parse_SetInput(const char *name, int lin * None * * Side Effects: - * A structure is added to the includes Lst and readProc, lineno, + * A structure is added to the includes list and readProc, lineno, * fname and curFILE are altered for the new file *--------------------------------------------------------------------- */ @@ -2855,7 +2859,7 @@ Parse_File(const char *name, int fd) ParseAddCmd(glist_get(&targets, i), cp); } #ifdef CLEANUP - Lst_AtEnd(targCmds, cp); + stringarray_add(&targCmds, cp, NULL); #endif } } @@ -3012,7 +3016,7 @@ Parse_Init(void) includes = Lst_Init(FALSE); glist_init(&targets); #ifdef CLEANUP - targCmds = Lst_Init(FALSE); + stringarray_init(&targCmds); #endif } @@ -3020,16 +3024,24 @@ void Parse_End(void) { #ifdef CLEANUP - Lst_Destroy(targCmds, (FreeProc *)free); + unsigned i, num; + + num = stringarray_num(&targCmds); + for (i=0; i<num; i++) { + free(stringarray_get(&targCmds, i)); + } + stringarray_setsize(&targCmds, 0); + stringarray_cleanup(&targCmds); glist_setsize(&targets, 0); glist_cleanup(&targets); Dir_ClearPath(&defIncPath); Dir_ClearPath(&sysIncPath); Dir_ClearPath(&parseIncPath); - patharray_cleaup(&defIncPath); - patharray_cleaup(&sysIncPath); - patharray_cleaup(&parseIncPath); - Lst_Destroy(includes, NULL); /* Should be empty now */ + patharray_cleanup(&defIncPath); + patharray_cleanup(&sysIncPath); + patharray_cleanup(&parseIncPath); + /* Should be empty now */ + Lst_Destroy(includes, NULL); #endif }