Module Name: othersrc
Committed By: dholland
Date: Sat Mar 23 19:15:40 UTC 2013
Modified Files:
othersrc/usr.bin/dholland-make2: parse.c
Log Message:
Remove the last linked list.
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.10 othersrc/usr.bin/dholland-make2/parse.c:1.11
--- othersrc/usr.bin/dholland-make2/parse.c:1.10 Sat Mar 23 19:06:42 2013
+++ othersrc/usr.bin/dholland-make2/parse.c Sat Mar 23 19:15:40 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.10 2013/03/23 19:06:42 dholland Exp $ */
+/* $NetBSD: parse.c,v 1.11 2013/03/23 19:15:40 dholland Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -137,7 +137,7 @@
#include "buf.h"
#include "pathnames.h"
-MAKE_RCSID("$NetBSD: parse.c,v 1.10 2013/03/23 19:06:42 dholland Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.11 2013/03/23 19:15:40 dholland Exp $");
//#define CLEANUP
@@ -160,8 +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);
+DECLARRAY_BYTYPE(ifilestack, struct IFile, static);
+DEFARRAY_BYTYPE(ifilestack, struct IFile, MAKE_ATTR_UNUSED static);
/*
* These values are returned by ParseEOF to tell Parse_File whether to
@@ -269,7 +269,7 @@ static int fatals = 0;
static IFile *curFile;
/* stack of IFiles generated by .includes */
-static Lst includes;
+static struct ifilestack includes;
/* include paths (lists of directories) */
struct patharray parseIncPath; /* dirs for "..." includes */
@@ -561,6 +561,30 @@ done:
}
////////////////////////////////////////////////////////////
+// stack ops for the array-as-stack
+
+static void
+ifilestack_push(struct ifilestack *arr, IFile *f)
+{
+ ifilestack_add(arr, f, NULL);
+}
+
+static IFile *
+ifilestack_pop(struct ifilestack *arr)
+{
+ unsigned num;
+ IFile *ret;
+
+ num = ifilestack_num(arr);
+ if (num == 0) {
+ return NULL;
+ }
+ ret = ifilestack_get(arr, num - 1);
+ ifilestack_setsize(arr, num - 1);
+ return ret;
+}
+
+////////////////////////////////////////////////////////////
// old code
/*-
@@ -2274,7 +2298,7 @@ Parse_SetInput(const char *name, int lin
if (curFile != NULL) {
/* Save exiting file info */
- Lst_AtFront(includes, curFile);
+ ifilestack_push(&includes, curFile);
}
/* Allocate and fill in new structure */
@@ -2469,7 +2493,7 @@ ParseEOF(void)
free(curFile->P_str);
free(curFile);
- curFile = Lst_DeQueue(includes);
+ curFile = ifilestack_pop(&includes);
if (curFile == NULL) {
/* We've run out of input */
@@ -3013,7 +3037,7 @@ Parse_Init(void)
patharray_init(&parseIncPath);
patharray_init(&sysIncPath);
patharray_init(&defIncPath);
- includes = Lst_Init(FALSE);
+ ifilestack_init(&includes);
glist_init(&targets);
#ifdef CLEANUP
stringarray_init(&targCmds);
@@ -3041,7 +3065,7 @@ Parse_End(void)
patharray_cleanup(&sysIncPath);
patharray_cleanup(&parseIncPath);
/* Should be empty now */
- Lst_Destroy(includes, NULL);
+ ifilestack_cleanup(&includes);
#endif
}