Module Name: othersrc
Committed By: dholland
Date: Mon Mar 4 07:28:45 UTC 2013
Modified Files:
othersrc/usr.bin/dholland-make2: compat.c dir.c graph.h make.c suff.c
targ.c
Log Message:
Use array.h instead of the list library for one of the lists in the
graph node structure.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/usr.bin/dholland-make2/compat.c \
othersrc/usr.bin/dholland-make2/dir.c \
othersrc/usr.bin/dholland-make2/make.c \
othersrc/usr.bin/dholland-make2/suff.c \
othersrc/usr.bin/dholland-make2/targ.c
cvs rdiff -u -r1.1 -r1.2 othersrc/usr.bin/dholland-make2/graph.h
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/compat.c
diff -u othersrc/usr.bin/dholland-make2/compat.c:1.2 othersrc/usr.bin/dholland-make2/compat.c:1.3
--- othersrc/usr.bin/dholland-make2/compat.c:1.2 Mon Feb 25 03:39:28 2013
+++ othersrc/usr.bin/dholland-make2/compat.c Mon Mar 4 07:28:45 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.2 2013/02/25 03:39:28 dholland Exp $ */
+/* $NetBSD: compat.c,v 1.3 2013/03/04 07:28:45 dholland Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -101,7 +101,7 @@
#include "job.h"
#include "pathnames.h"
-MAKE_RCSID("$NetBSD: compat.c,v 1.2 2013/02/25 03:39:28 dholland Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.3 2013/03/04 07:28:45 dholland Exp $");
/*
* The following array is used to make a fast determination of which
@@ -519,7 +519,7 @@ Compat_Make(void *gnp, void *pgnp)
goto cohorts;
}
- if (Lst_Member(gn->iParents, pgn) != NULL) {
+ if (glist_contains(&gn->iParents, pgn)) {
char *p1;
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
if (p1)
@@ -623,7 +623,7 @@ Compat_Make(void *gnp, void *pgnp)
*/
pgn->flags &= ~REMAKE;
} else {
- if (Lst_Member(gn->iParents, pgn) != NULL) {
+ if (glist_contains(&gn->iParents, pgn)) {
char *p1;
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
if (p1)
Index: othersrc/usr.bin/dholland-make2/dir.c
diff -u othersrc/usr.bin/dholland-make2/dir.c:1.2 othersrc/usr.bin/dholland-make2/dir.c:1.3
--- othersrc/usr.bin/dholland-make2/dir.c:1.2 Mon Feb 25 03:39:28 2013
+++ othersrc/usr.bin/dholland-make2/dir.c Mon Mar 4 07:28:45 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.2 2013/02/25 03:39:28 dholland Exp $ */
+/* $NetBSD: dir.c,v 1.3 2013/03/04 07:28:45 dholland Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -137,7 +137,7 @@
#include "hash.h"
#include "dir.h"
-__RCSID("$NetBSD: dir.c,v 1.2 2013/02/25 03:39:28 dholland Exp $");
+__RCSID("$NetBSD: dir.c,v 1.3 2013/03/04 07:28:45 dholland Exp $");
/*
* A search path consists of a Lst of Path structures. A Path structure
@@ -1438,7 +1438,7 @@ Dir_MTime(GNode *gn, Boolean recheck)
else {
fullName = Dir_FindFile(gn->name, Suff_FindPath(gn));
if (fullName == NULL && gn->flags & FROM_DEPEND &&
- !Lst_IsEmpty(gn->iParents)) {
+ glist_num(&gn->iParents) > 0) {
char *cp;
cp = strrchr(gn->name, '/');
Index: othersrc/usr.bin/dholland-make2/make.c
diff -u othersrc/usr.bin/dholland-make2/make.c:1.2 othersrc/usr.bin/dholland-make2/make.c:1.3
--- othersrc/usr.bin/dholland-make2/make.c:1.2 Mon Feb 25 03:39:28 2013
+++ othersrc/usr.bin/dholland-make2/make.c Mon Mar 4 07:28:45 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.2 2013/02/25 03:39:28 dholland Exp $ */
+/* $NetBSD: make.c,v 1.3 2013/03/04 07:28:45 dholland Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
#include "dir.h"
#include "job.h"
-MAKE_RCSID("$NetBSD: make.c,v 1.2 2013/02/25 03:39:28 dholland Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.3 2013/03/04 07:28:45 dholland Exp $");
static unsigned int checked = 1;/* Sequence # to detect recursion */
static Lst toBeMade; /* The current fringe of the graph. These
@@ -820,11 +820,12 @@ Make_Update(GNode *cgn)
* Set the .PREFIX and .IMPSRC variables for all the implied parents
* of this node.
*/
- if (Lst_Open(cgn->iParents) == SUCCESS) {
+ /*if (Lst_Open(cgn->iParents) == SUCCESS)*/ {
char *cpref = Var_Value(PREFIX, cgn, &p1);
+ unsigned i;
- while ((ln = Lst_Next(cgn->iParents)) != NULL) {
- pgn = (GNode *)Lst_Datum(ln);
+ for (i=0; i<glist_num(&cgn->iParents); i++) {
+ pgn = glist_get(&cgn->iParents, i);
if (pgn->flags & REMAKE) {
Var_Set(IMPSRC, cname, pgn, 0);
if (cpref != NULL)
@@ -833,7 +834,7 @@ Make_Update(GNode *cgn)
}
if (p1)
free(p1);
- Lst_Close(cgn->iParents);
+ /*Lst_Close(cgn->iParents);*/
}
}
Index: othersrc/usr.bin/dholland-make2/suff.c
diff -u othersrc/usr.bin/dholland-make2/suff.c:1.2 othersrc/usr.bin/dholland-make2/suff.c:1.3
--- othersrc/usr.bin/dholland-make2/suff.c:1.2 Mon Feb 25 03:39:28 2013
+++ othersrc/usr.bin/dholland-make2/suff.c Mon Mar 4 07:28:45 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.2 2013/02/25 03:39:28 dholland Exp $ */
+/* $NetBSD: suff.c,v 1.3 2013/03/04 07:28:45 dholland Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
#include "hash.h"
#include "dir.h"
-MAKE_RCSID("$NetBSD: suff.c,v 1.2 2013/02/25 03:39:28 dholland Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.3 2013/03/04 07:28:45 dholland Exp $");
static Lst sufflist; /* Lst of suffixes */
#ifdef CLEANUP
@@ -1841,7 +1841,7 @@ SuffApplyTransform(GNode *tGn, GNode *sG
* Keep track of another parent to which this beast is transformed so
* the .IMPSRC variable can be set correctly for the parent.
*/
- (void)Lst_AtEnd(sGn->iParents, tGn);
+ glist_add(&sGn->iParents, tGn, NULL);
return(TRUE);
}
Index: othersrc/usr.bin/dholland-make2/targ.c
diff -u othersrc/usr.bin/dholland-make2/targ.c:1.2 othersrc/usr.bin/dholland-make2/targ.c:1.3
--- othersrc/usr.bin/dholland-make2/targ.c:1.2 Mon Feb 25 03:39:28 2013
+++ othersrc/usr.bin/dholland-make2/targ.c Mon Mar 4 07:28:45 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.2 2013/02/25 03:39:28 dholland Exp $ */
+/* $NetBSD: targ.c,v 1.3 2013/03/04 07:28:45 dholland Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -127,7 +127,7 @@
#include "hash.h"
#include "dir.h"
-MAKE_RCSID("$NetBSD: targ.c,v 1.2 2013/02/25 03:39:28 dholland Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.3 2013/03/04 07:28:45 dholland Exp $");
static Lst allTargets; /* the list of all targets found so far */
#ifdef CLEANUP
@@ -244,7 +244,7 @@ Targ_NewGN(const char *name)
gn->checked = 0;
gn->mtime = 0;
gn->cmgn = NULL;
- gn->iParents = Lst_Init(FALSE);
+ glist_init(&gn->iParents);
gn->cohorts = Lst_Init(FALSE);
gn->parents = Lst_Init(FALSE);
gn->children = Lst_Init(FALSE);
@@ -291,7 +291,8 @@ TargFreeGN(void *gnp)
free(gn->path);
/* gn->fname points to name allocated when file was opened, don't free */
- Lst_Destroy(gn->iParents, NULL);
+ glist_setsize(&gn->iParents, 0);
+ glist_cleanup(&gn->iParents);
Lst_Destroy(gn->cohorts, NULL);
Lst_Destroy(gn->parents, NULL);
Lst_Destroy(gn->children, NULL);
@@ -650,9 +651,13 @@ Targ_PrintNode(void *gnp, void *passp)
fprintf(debug_file, "# unmade\n");
}
}
- if (!Lst_IsEmpty (gn->iParents)) {
+ if (glist_num(&gn->iParents) > 0) {
+ unsigned i;
+
fprintf(debug_file, "# implicit parents: ");
- Lst_ForEach(gn->iParents, TargPrintName, NULL);
+ for (i=0; i<glist_num(&gn->iParents); i++) {
+ TargPrintName(glist_get(&gn->iParents, i), NULL);
+ }
fprintf(debug_file, "\n");
}
} else {
Index: othersrc/usr.bin/dholland-make2/graph.h
diff -u othersrc/usr.bin/dholland-make2/graph.h:1.1 othersrc/usr.bin/dholland-make2/graph.h:1.2
--- othersrc/usr.bin/dholland-make2/graph.h:1.1 Mon Mar 4 05:50:49 2013
+++ othersrc/usr.bin/dholland-make2/graph.h Mon Mar 4 07:28:45 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: graph.h,v 1.1 2013/03/04 05:50:49 dholland Exp $ */
+/* $NetBSD: graph.h,v 1.2 2013/03/04 07:28:45 dholland Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -75,6 +75,17 @@
#ifndef GRAPH_H
#define GRAPH_H
+#include "array.h"
+
+/*
+ * Array of gnodes - the type will be "GList" and the operations will
+ * be glist_create(), glist_add(), etc.
+ */
+struct GNode;
+DECLARRAY_BYTYPE(glist, struct GNode, MAKE_INLINE);
+DEFARRAY_BYTYPE(glist, struct GNode, MAKE_INLINE);
+typedef struct glist GList;
+
/*
* State of processing of a node.
*/
@@ -122,7 +133,7 @@ enum enum_made {
* 19) a Lst of strings that are commands to be given to a shell
* to create this target.
*/
-typedef struct GNode {
+struct GNode {
char *name; /* The target's name */
char *uname; /* The unexpanded name of a .USE node */
char *path; /* The full pathname of the file */
@@ -145,7 +156,7 @@ typedef struct GNode {
time_t mtime; /* Its modification time */
struct GNode *cmgn; /* The youngest child */
- Lst iParents; /* Links to parents for which this is an
+ GList iParents; /* Links to parents for which this is an
* implied source, if any */
Lst cohorts; /* Other nodes for the :: operator */
Lst parents; /* Nodes that depend on this one */
@@ -168,7 +179,9 @@ typedef struct GNode {
* but the Suff module) */
const char *fname; /* filename where the GNode got defined */
int lineno; /* line number where the GNode got defined */
-} GNode;
+};
+
+typedef struct GNode GNode;
/*
* The OP_ constants are used when parsing a dependency line as a way of