Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Feb 2003 13:47:37 -0800 (PST)
From:      Juli Mallett <jmallett@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 25238 for review
Message-ID:  <200302152147.h1FLlbTS091169@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=25238

Change 25238 by jmallett@jmallett_dalek on 2003/02/15 13:47:10

	Integrate config(8) from trunk, and apply local patches with the
	new list style in mind.

Affected files ...

.. //depot/projects/mips/usr.sbin/config/config.h#3 integrate
.. //depot/projects/mips/usr.sbin/config/config.y#3 integrate
.. //depot/projects/mips/usr.sbin/config/lang.l#3 integrate
.. //depot/projects/mips/usr.sbin/config/main.c#4 integrate
.. //depot/projects/mips/usr.sbin/config/mkheaders.c#2 integrate
.. //depot/projects/mips/usr.sbin/config/mkmakefile.c#3 integrate
.. //depot/projects/mips/usr.sbin/config/mkoptions.c#4 integrate

Differences ...

==== //depot/projects/mips/usr.sbin/config/config.h#3 (text+ko) ====

@@ -31,18 +31,19 @@
  * SUCH DAMAGE.
  *
  *	@(#)config.h	8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.sbin/config/config.h,v 1.51 2002/02/20 23:35:56 peter Exp $
+ * $FreeBSD: src/usr.sbin/config/config.h,v 1.52 2003/02/15 02:26:13 ru Exp $
  */
 
 /*
  * Config.
  */
 #include <sys/types.h>
+#include <sys/queue.h>
 #include <stdlib.h>
 #include <string.h>
 
 struct file_list {
-	struct	file_list *f_next;
+	STAILQ_ENTRY(file_list) f_next;
 	char	*f_fn;			/* the name */
 	int     f_type;                 /* type or count */
 	u_char	f_flags;		/* see below */
@@ -79,7 +80,7 @@
 	char	*d_name;		/* name of device (e.g. rk11) */
 	int	d_count;		/* device count */
 #define	UNKNOWN -2	/* -2 means not set yet */
-	struct	device *d_next;		/* Next one in list */
+	STAILQ_ENTRY(device) d_next;	/* Next one in list */
 };
 
 struct config {
@@ -103,8 +104,10 @@
  */
 struct cputype {
 	char	*cpu_name;
-	struct	cputype *cpu_next;
-} *cputype;
+	SLIST_ENTRY(cputype) cpu_next;
+};
+
+SLIST_HEAD(, cputype) cputype;
 
 /*
  * A set of options may also be specified which are like CPU types,
@@ -115,14 +118,18 @@
 	char	*op_name;
 	char	*op_value;
 	int	op_ownfile;	/* true = own file, false = makefile */
-	struct	opt *op_next;
-} *opt, *mkopt;
+	SLIST_ENTRY(opt) op_next;
+};
+
+SLIST_HEAD(opt_head, opt) opt, mkopt;
 
 struct opt_list {
 	char *o_name;
 	char *o_file;
-	struct opt_list *o_next;
-} *otab;
+	SLIST_ENTRY(opt_list) o_next;
+};
+
+SLIST_HEAD(, opt_list) otab;
 
 extern char	*ident;
 extern char	*env;
@@ -143,13 +150,13 @@
 void	makefile(void);
 void	headers(void);
 
-extern struct	device *dtab;
+extern STAILQ_HEAD(device_head, device) dtab;
 
 extern char	errbuf[80];
 extern int	yyline;
 extern const	char *yyfile;
 
-extern struct	file_list *ftab;
+extern STAILQ_HEAD(file_list_head, file_list) ftab;
 
 extern int	profiling;
 extern int	debugging;

==== //depot/projects/mips/usr.sbin/config/config.y#3 (text+ko) ====

@@ -14,6 +14,7 @@
 %token	HINTS
 %token	IDENT
 %token	MAXUSERS
+%token	NODEVICE
 %token	PLATFORM
 %token	PROFILE
 %token	OPTIONS
@@ -63,7 +64,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)config.y	8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.sbin/config/config.y,v 1.56 2001/08/27 05:11:53 peter Exp $
+ * $FreeBSD: src/usr.sbin/config/config.y,v 1.58 2003/02/15 02:39:13 ru Exp $
  */
 
 #include <ctype.h>
@@ -73,9 +74,7 @@
 
 #include "config.h"
 
-static struct	device *curp = 0;
-
-struct  device *dtab;
+struct	device_head dtab;
 char	*ident;
 char	*env;
 int	envmode;
@@ -83,7 +82,7 @@
 int	hintmode;
 int	yyline;
 const	char *yyfile;
-struct  file_list *ftab;
+struct  file_list_head ftab;
 char	errbuf[80];
 int	maxusers;
 
@@ -134,8 +133,7 @@
 		    (struct cputype *)malloc(sizeof (struct cputype));
 		memset(cp, 0, sizeof(*cp));
 		cp->cpu_name = $2;
-		cp->cpu_next = cputype;
-		cputype = cp;
+		SLIST_INSERT_HEAD(&cputype, cp, cpu_next);
 	      } |
 	PLATFORM Save_id
 	    = {
@@ -250,6 +248,12 @@
 		if ($3 == 0)
 			errx(1, "%s:%d: devices with zero units are not "
 			    "likely to be correct", yyfile, yyline);
+		} |
+	NODEVICE Dev
+	      = {
+		rmopt(&opt, devopt($2));
+		/* and the device part */
+		rmdev($2);
 		} ;
 
 %%
@@ -273,16 +277,32 @@
 	memset(np, 0, sizeof(*np));
 	np->d_name = name;
 	np->d_count = count;
-	np->d_next = 0;
-	if (curp == 0)
-		dtab = np;
-	else
-		curp->d_next = np;
-	curp = np;
+	STAILQ_INSERT_TAIL(&dtab, np, d_next);
+}
+
+/*
+ * remove a device from the list of devices
+ */
+static void
+rmdev(char *name)
+{
+	struct device *dp, *rmdp;
+
+	STAILQ_FOREACH(dp, &dtab, d_next) {
+		if (eq(dp->d_name, name)) {
+			rmdp = dp;
+			dp = STAILQ_NEXT(dp, d_next);
+			STAILQ_REMOVE(&dtab, rmdp, device, d_next);
+			free(rmdp->d_name);
+			free(rmdp);
+			if (dp == NULL)
+				break;
+		}
+	}
 }
 
 static void
-newopt(struct opt **list, char *name, char *value)
+newopt(struct opt_head *list, char *name, char *value)
 {
 	struct opt *op;
 
@@ -291,6 +311,24 @@
 	op->op_name = name;
 	op->op_ownfile = 0;
 	op->op_value = value;
-	op->op_next = *list;
-	*list = op;
+	SLIST_INSERT_HEAD(list, op, op_next);
+}
+
+static void
+rmopt(struct opt_head *list, char *name)
+{
+	struct opt *op, *rmop;
+
+	SLIST_FOREACH(op, list, op_next) {
+		if (eq(op->op_name, name)) {
+			rmop = op;
+			op = SLIST_NEXT(op, op_next);
+			SLIST_REMOVE(list, rmop, opt, op_next);
+			free(rmop->op_name);
+			free(rmop->op_value);
+			free(rmop);
+			if (op == NULL)
+				break;
+		}
+	}
 }

==== //depot/projects/mips/usr.sbin/config/lang.l#3 (text+ko) ====

@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)lang.l	8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.sbin/config/lang.l,v 1.33 2002/06/21 10:56:44 jmallett Exp $
+ * $FreeBSD: src/usr.sbin/config/lang.l,v 1.34 2003/02/15 02:39:13 ru Exp $
  */
 
 #include <assert.h>
@@ -73,6 +73,7 @@
 	{ "machine",	ARCH }, /* MACHINE is defined in /sys/param.h */
 	{ "makeoptions", MAKEOPTIONS },
 	{ "maxusers",	MAXUSERS },
+	{ "nodevice",	NODEVICE },
 	{ "platform",	PLATFORM },
 	{ "profile",	PROFILE },
 	{ "option",	OPTIONS },
@@ -110,7 +111,7 @@
 
 			if ((i = kw_lookup(yytext)) == -1)
 				REJECT;
-			if (i == DEVICE)
+			if (i == DEVICE || i == NODEVICE)
 				BEGIN NONUM;
 			return i;
 		}

==== //depot/projects/mips/usr.sbin/config/main.c#4 (text+ko) ====

@@ -42,7 +42,7 @@
 static char sccsid[] = "@(#)main.c	8.1 (Berkeley) 6/6/93";
 #endif
 static const char rcsid[] =
-  "$FreeBSD: src/usr.sbin/config/main.c,v 1.56 2002/07/06 01:07:48 obrien Exp $";
+  "$FreeBSD: src/usr.sbin/config/main.c,v 1.57 2003/02/15 02:26:13 ru Exp $";
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -144,7 +144,8 @@
 	else if ((buf.st_mode & S_IFMT) != S_IFDIR)
 		errx(2, "%s isn't a directory", p);
 
-	dtab = NULL;
+	STAILQ_INIT(&dtab);
+	SLIST_INIT(&cputype);
 	yyfile = *argv;
 	if (yyparse())
 		exit(3);
@@ -436,7 +437,7 @@
 
 	remember("y.tab.h");
 	remember("setdefs.h");
-	for (fl = ftab; fl != NULL; fl = fl->f_next)
+	STAILQ_FOREACH(fl, &ftab, f_next)
 		remember(fl->f_fn);
 
 	/*

==== //depot/projects/mips/usr.sbin/config/mkheaders.c#2 (text+ko) ====

@@ -36,7 +36,7 @@
 static char sccsid[] = "@(#)mkheaders.c	8.1 (Berkeley) 6/6/93";
 #endif
 static const char rcsid[] =
-  "$FreeBSD: src/usr.sbin/config/mkheaders.c,v 1.25 2002/07/21 23:31:43 peter Exp $";
+  "$FreeBSD: src/usr.sbin/config/mkheaders.c,v 1.26 2003/02/15 02:26:13 ru Exp $";
 #endif /* not lint */
 
 /*
@@ -64,10 +64,10 @@
 	int errors;
 
 	errors = 0;
-	for (fl = ftab; fl != 0; fl = fl->f_next) {
+	STAILQ_FOREACH(fl, &ftab, f_next) {
 		if (fl->f_needs != 0) {
 			match = 0;
-			for (dp = dtab; dp != 0; dp = dp->d_next) {
+			STAILQ_FOREACH(dp, &dtab, d_next) {
 				if (eq(dp->d_name, fl->f_needs)) {
 					match++;
 					dp->d_done |= DEVDONE;
@@ -77,7 +77,7 @@
 				errors += do_header(fl->f_needs, match);
 		}
 	}
-	for (dp = dtab; dp != 0; dp = dp->d_next) {
+	STAILQ_FOREACH(dp, &dtab, d_next) {
 		if (!(dp->d_done & DEVDONE)) {
 			warnx("Error: device \"%s\" is unknown",
 			       dp->d_name);
@@ -86,7 +86,7 @@
 		if (dp->d_count == UNKNOWN)
 			continue;
 		match = 0;
-		for (fl = ftab; fl != 0; fl = fl->f_next) {
+		STAILQ_FOREACH(fl, &ftab, f_next) {
 			if (fl->f_needs == 0)
 				continue;
 			if ((fl->f_flags & NEED_COUNT) == 0)
@@ -110,7 +110,8 @@
 do_header(char *dev, int match)
 {
 	char *file, *name, *inw;
-	struct file_list *fl, *fl_head, *tflp;
+	struct file_list *fl, *tflp;
+	struct file_list_head fl_head;
 	struct device *dp;
 	FILE *inf, *outf;
 	int inc, oldcount;
@@ -123,7 +124,8 @@
 	 * must use this higher of these values.
 	 */
 	errors = 0;
-	for (hicount = count = 0, dp = dtab; dp != 0; dp = dp->d_next) {
+	hicount = count = 0;
+	STAILQ_FOREACH(dp, &dtab, d_next) {
 		if (eq(dp->d_name, dev)) {
 			if (dp->d_count == UNKNOWN) {
 				warnx("Device \"%s\" requires a count", dev);
@@ -148,7 +150,7 @@
 		(void) fclose(outf);
 		return 0;
 	}
-	fl_head = NULL;
+	STAILQ_INIT(&fl_head);
 	for (;;) {
 		char *cp;
 		if ((inw = get_word(inf)) == 0 || inw == (char *)EOF)
@@ -171,13 +173,12 @@
 		bzero(fl, sizeof(*fl));
 		fl->f_fn = inw;		/* malloced */
 		fl->f_type = inc;
-		fl->f_next = fl_head;
-		fl_head = fl;
+		STAILQ_INSERT_HEAD(&fl_head, fl, f_next);
 	}
 	(void) fclose(inf);
 	if (count == oldcount) {
-		for (fl = fl_head; fl != NULL; fl = tflp) {
-			tflp = fl->f_next;
+		for (fl = STAILQ_FIRST(&fl_head); fl != NULL; fl = tflp) {
+			tflp = STAILQ_NEXT(fl, f_next);
 			free(fl->f_fn);
 			free(fl);
 		}
@@ -188,16 +189,15 @@
 		bzero(fl, sizeof(*fl));
 		fl->f_fn = ns(name);
 		fl->f_type = count;
-		fl->f_next = fl_head;
-		fl_head = fl;
+		STAILQ_INSERT_HEAD(&fl_head, fl, f_next);
 	}
 	outf = fopen(file, "w");
 	if (outf == 0)
 		err(1, "%s", file);
-	for (fl = fl_head; fl != NULL; fl = tflp) {
+	for (fl = STAILQ_FIRST(&fl_head); fl != NULL; fl = tflp) {
 		fprintf(outf,
 		    "#define %s %u\n", fl->f_fn, count ? fl->f_type : 0);
-		tflp = fl->f_next;
+		tflp = STAILQ_NEXT(fl, f_next);
 		free(fl->f_fn);
 		free(fl);
 	}

==== //depot/projects/mips/usr.sbin/config/mkmakefile.c#3 (text+ko) ====

@@ -36,7 +36,7 @@
 static char sccsid[] = "@(#)mkmakefile.c	8.1 (Berkeley) 6/6/93";
 #endif
 static const char rcsid[] =
-  "$FreeBSD: src/usr.sbin/config/mkmakefile.c,v 1.73 2002/07/13 19:36:13 bde Exp $";
+  "$FreeBSD: src/usr.sbin/config/mkmakefile.c,v 1.74 2003/02/15 02:26:13 ru Exp $";
 #endif /* not lint */
 
 /*
@@ -69,8 +69,6 @@
 		wd = word; \
 	}
 
-static struct file_list *fcur;
-
 static char *tail(char *);
 static void do_clean(FILE *);
 static void do_rules(FILE *);
@@ -89,7 +87,7 @@
 {
 	struct file_list *fp;
 
-	for (fp = ftab ; fp != 0; fp = fp->f_next) {
+	STAILQ_FOREACH(fp, &ftab, f_next) {
 		if (eq(fp->f_fn, file))
 			return (fp);
 	}
@@ -106,11 +104,7 @@
 
 	fp = (struct file_list *) malloc(sizeof *fp);
 	bzero(fp, sizeof *fp);
-	if (fcur == 0)
-		fcur = ftab = fp;
-	else
-		fcur->f_next = fp;
-	fcur = fp;
+	STAILQ_INSERT_TAIL(&ftab, fp, f_next);
 	return (fp);
 }
 
@@ -137,7 +131,7 @@
 		err(1, "%s", line);
 
 	/* XXX this check seems to be misplaced. */
-	if (cputype == 0) {
+	if (SLIST_EMPTY(&cputype)) {
 		printf("cpu type must be specified\n");
 		exit(1);
 	}
@@ -146,7 +140,7 @@
 	if (ofp == 0)
 		err(1, "%s", path("Makefile.new"));
 	fprintf(ofp, "KERN_IDENT=%s\n", raisestr(ident));
-	for (op = mkopt; op; op = op->op_next)
+	SLIST_FOREACH(op, &mkopt, op_next)
 		fprintf(ofp, "%s=%s\n", op->op_name, op->op_value);
 	if (debugging)
 		fprintf(ofp, "DEBUG=-g\n");
@@ -318,7 +312,7 @@
 	int nreqs, first = 1, isdup, std, filetype,
 	    imp_rule, no_obj, needcount, before_depend, mandatory, nowerror;
 
-	ftab = 0;
+	STAILQ_INIT(&ftab);
 	if (ident == NULL) {
 		printf("no ident line specified\n");
 		exit(1);
@@ -483,7 +477,7 @@
 		needs = ns(wd);
 	if (isdup)
 		goto invis;
-	for (dp = dtab; dp != 0; dp = dp->d_next)
+	STAILQ_FOREACH(dp, &dtab, d_next)
 		if (eq(dp->d_name, wd)) {
 			if (std && dp->d_count <= 0)
 				dp->d_count = 1;
@@ -499,7 +493,7 @@
 		       this, wd);
 		exit(1);
 	}
-	for (op = opt; op != 0; op = op->op_next)
+	SLIST_FOREACH(op, &opt, op_next)
 		if (op->op_value == 0 && opteq(op->op_name, wd)) {
 			if (nreqs == 1) {
 				free(needs);
@@ -588,7 +582,7 @@
 
 	fputs("BEFORE_DEPEND=", fp);
 	lpos = 15;
-	for (tp = ftab; tp; tp = tp->f_next)
+	STAILQ_FOREACH(tp, &ftab, f_next)
 		if (tp->f_flags & BEFORE_DEPEND) {
 			len = strlen(tp->f_fn);
 			if ((len = 3 + len) + lpos > 72) {
@@ -614,7 +608,7 @@
 
 	fprintf(fp, "OBJS=");
 	lpos = 6;
-	for (tp = ftab; tp != 0; tp = tp->f_next) {
+	STAILQ_FOREACH(tp, &ftab, f_next) {
 		if (tp->f_type == INVISIBLE || tp->f_flags & NO_OBJ)
 			continue;
 		sp = tail(tp->f_fn);
@@ -650,7 +644,7 @@
 
 	fprintf(fp, "%sFILES=", SUFF);
 	lpos = 8;
-	for (tp = ftab; tp; tp = tp->f_next)
+	STAILQ_FOREACH(tp, &ftab, f_next)
 		if (tp->f_type != INVISIBLE && tp->f_type != NODEPEND) {
 			len = strlen(tp->f_fn);
 			if (tp->f_fn[len - slen - 1] != '.')
@@ -693,7 +687,7 @@
 	struct file_list *ftp;
 	char *compilewith;
 
-	for (ftp = ftab; ftp != 0; ftp = ftp->f_next) {
+	STAILQ_FOREACH(ftp, &ftab, f_next) {
 		if (ftp->f_type == INVISIBLE)
 			continue;
 		if (ftp->f_warn)
@@ -760,7 +754,7 @@
 
 	fputs("CLEAN=", fp);
 	lpos = 7;
-	for (tp = ftab; tp; tp = tp->f_next)
+	STAILQ_FOREACH(tp, &ftab, f_next)
 		if (tp->f_clean) {
 			len = strlen(tp->f_clean);
 			if (len + lpos > 72) {

==== //depot/projects/mips/usr.sbin/config/mkoptions.c#4 (text+ko) ====

@@ -37,7 +37,7 @@
 static char sccsid[] = "@(#)mkheaders.c	8.1 (Berkeley) 6/6/93";
 #endif
 static const char rcsid[] =
-  "$FreeBSD: src/usr.sbin/config/mkoptions.c,v 1.29 2001/12/09 01:57:05 dillon Exp $";
+  "$FreeBSD: src/usr.sbin/config/mkoptions.c,v 1.30 2003/02/15 02:26:13 ru Exp $";
 #endif /* not lint */
 
 /*
@@ -72,13 +72,12 @@
 	struct opt *op;
 
 	/* Fake the cpu types as options. */
-	for (cp = cputype; cp != NULL; cp = cp->cpu_next) {
+	SLIST_FOREACH(cp, &cputype, cpu_next) {
 		op = (struct opt *)malloc(sizeof(*op));
 		memset(op, 0, sizeof(*op));
 		op->op_name = ns(cp->cpu_name);
-		op->op_next = opt;
-		opt = op;
-	}
+		SLIST_INSERT_HEAD(&opt, op, op_next);
+	}	
 
 	/* Fake the platform as an option. */
 	if (platformname != NULL) {
@@ -88,8 +87,7 @@
 		memset(op, 0, sizeof(*op));
 		p = ns(platformname);
 		op->op_name = raisestr(p);
-		op->op_next = opt;
-		opt = op;
+		SLIST_INSERT_HEAD(&opt, op, op_next);
 	}
 
 	if (maxusers == 0) {
@@ -106,13 +104,12 @@
 	op->op_name = ns("MAXUSERS");
 	snprintf(buf, sizeof(buf), "%d", maxusers);
 	op->op_value = ns(buf);
-	op->op_next = opt;
-	opt = op;
+	SLIST_INSERT_HEAD(&opt, op, op_next);
 
 	read_options();
-	for (ol = otab; ol != 0; ol = ol->o_next)
+	SLIST_FOREACH(ol, &otab, o_next)
 		do_option(ol->o_name);
-	for (op = opt; op; op = op->op_next) {
+	SLIST_FOREACH(op, &opt, op_next) {
 		if (!op->op_ownfile && strncmp(op->op_name, "DEV_", 4)) {
 			printf("%s: unknown option \"%s\"\n",
 			       PREFIX, op->op_name);
@@ -131,7 +128,8 @@
 	char *file, *inw;
 	const char *basefile;
 	struct opt_list *ol;
-	struct opt *op, *op_head, *topp;
+	struct opt *op;
+	struct opt_head op_head;
 	FILE *inf, *outf;
 	char *value;
 	char *oldvalue;
@@ -144,7 +142,7 @@
 	 * Check to see if the option was specified..
 	 */
 	value = NULL;
-	for (op = opt; op; op = op->op_next) {
+	SLIST_FOREACH(op, &opt, op_next) {
 		if (eq(name, op->op_name)) {
 			oldvalue = value;
 			value = op->op_value;
@@ -175,13 +173,13 @@
 		return;
 	}
 	basefile = "";
-	for (ol = otab; ol != 0; ol = ol->o_next)
+	SLIST_FOREACH(ol, &otab, o_next)
 		if (eq(name, ol->o_name)) {
 			basefile = ol->o_file;
 			break;
 		}
 	oldvalue = NULL;
-	op_head = NULL;
+	SLIST_INIT(&op_head);
 	seen = 0;
 	tidy = 0;
 	for (;;) {
@@ -205,7 +203,7 @@
 			invalue = value;
 			seen++;
 		}
-		for (ol = otab; ol != 0; ol = ol->o_next)
+		SLIST_FOREACH(ol, &otab, o_next)
 			if (eq(inw, ol->o_name))
 				break;
 		if (!eq(inw, name) && !ol) {
@@ -221,8 +219,7 @@
 			bzero(op, sizeof(*op));
 			op->op_name = inw;
 			op->op_value = invalue;
-			op->op_next = op_head;
-			op_head = op;
+			SLIST_INSERT_HEAD(&op_head, op, op_next);
 		}
 
 		/* EOL? */
@@ -233,8 +230,9 @@
 	(void) fclose(inf);
 	if (!tidy && ((value == NULL && oldvalue == NULL) ||
 	    (value && oldvalue && eq(value, oldvalue)))) {	
-		for (op = op_head; op != NULL; op = topp) {
-			topp = op->op_next;
+		while (!SLIST_EMPTY(&op_head)) {
+			op = SLIST_FIRST(&op_head);
+			SLIST_REMOVE_HEAD(&op_head, op_next);
 			free(op->op_name);
 			free(op->op_value);
 			free(op);
@@ -248,20 +246,20 @@
 		bzero(op, sizeof(*op));
 		op->op_name = ns(name);
 		op->op_value = value ? ns(value) : NULL;
-		op->op_next = op_head;
-		op_head = op;
+		SLIST_INSERT_HEAD(&op_head, op, op_next);
 	}
 
 	outf = fopen(file, "w");
 	if (outf == 0)
 		err(1, "%s", file);
-	for (op = op_head; op != NULL; op = topp) {
+	while (!SLIST_EMPTY(&op_head)) {
+		op = SLIST_FIRST(&op_head);
 		/* was the option in the config file? */
 		if (op->op_value) {
 			fprintf(outf, "#define %s %s\n",
 				op->op_name, op->op_value);
 		}
-		topp = op->op_next;
+		SLIST_REMOVE_HEAD(&op_head, op_next);
 		free(op->op_name);
 		free(op->op_value);
 		free(op);
@@ -282,7 +280,7 @@
 	/* "cannot happen"?  the otab list should be complete.. */
 	(void) strlcpy(nbuf, "options.h", sizeof(nbuf));
 
-	for (po = otab ; po != 0; po = po->o_next) {
+	SLIST_FOREACH(po, &otab, o_next) {
 		if (eq(po->o_name, name)) {
 			strlcpy(nbuf, po->o_file, sizeof(nbuf));
 			break;
@@ -306,7 +304,7 @@
 	int first = 1;
 	char genopt[MAXPATHLEN];
 
-	otab = 0;
+	SLIST_INIT(&otab);
 	if (ident == NULL) {
 		printf("no ident line specified\n");
 		exit(1);
@@ -352,7 +350,7 @@
 	}
 	val = ns(val);
 
-	for (po = otab ; po != 0; po = po->o_next) {
+	SLIST_FOREACH(po, &otab, o_next) {
 		if (eq(po->o_name, this)) {
 			printf("%s: Duplicate option %s.\n",
 			       fname, this);
@@ -364,8 +362,7 @@
 	bzero(po, sizeof(*po));
 	po->o_name = this;
 	po->o_file = val;
-	po->o_next = otab;
-	otab = po;
+	SLIST_INSERT_HEAD(&otab, po, o_next);
 
 	goto next;
 }

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302152147.h1FLlbTS091169>