summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2005-10-17 19:04:19 +0000
committerotto <otto@openbsd.org>2005-10-17 19:04:19 +0000
commitce7de1e948ce7a3d7e32075367abd09763cca4df (patch)
tree9afab2fd471840864a9b935b504eab333e333b1d
parentinitial documentation of 'show fib'; ok claudio@ jmc@ (diff)
downloadwireguard-openbsd-ce7de1e948ce7a3d7e32075367abd09763cca4df.tar.xz
wireguard-openbsd-ce7de1e948ce7a3d7e32075367abd09763cca4df.zip
Use queue macros instead of directly accessing fields. ok pat@ "put it
in" deraadt@
-rw-r--r--usr.bin/apropos/apropos.c8
-rw-r--r--usr.bin/gencat/gencat.c36
-rw-r--r--usr.bin/man/config.c10
-rw-r--r--usr.bin/man/man.c56
-rw-r--r--usr.bin/netstat/if.c26
-rw-r--r--usr.bin/netstat/inet.c12
-rw-r--r--usr.bin/netstat/ipx.c12
-rw-r--r--usr.bin/netstat/mroute.c4
-rw-r--r--usr.bin/systat/netstat.c12
-rw-r--r--usr.bin/vi/cl/cl_read.c8
-rw-r--r--usr.bin/vi/cl/cl_screen.c4
-rw-r--r--usr.bin/vi/cl/cl_term.c8
-rw-r--r--usr.bin/vi/common/cut.c12
-rw-r--r--usr.bin/vi/common/cut.h5
-rw-r--r--usr.bin/vi/common/exf.c7
-rw-r--r--usr.bin/vi/common/gs.h4
-rw-r--r--usr.bin/vi/common/key.c6
-rw-r--r--usr.bin/vi/common/line.c17
-rw-r--r--usr.bin/vi/common/main.c8
-rw-r--r--usr.bin/vi/common/mark.c14
-rw-r--r--usr.bin/vi/common/put.c19
-rw-r--r--usr.bin/vi/common/screen.c13
-rw-r--r--usr.bin/vi/common/seq.c12
-rw-r--r--usr.bin/vi/ex/ex.c25
-rw-r--r--usr.bin/vi/ex/ex_append.c6
-rw-r--r--usr.bin/vi/ex/ex_at.c10
-rw-r--r--usr.bin/vi/ex/ex_cscope.c30
-rw-r--r--usr.bin/vi/ex/ex_display.c15
-rw-r--r--usr.bin/vi/ex/ex_global.c9
-rw-r--r--usr.bin/vi/ex/ex_move.c13
-rw-r--r--usr.bin/vi/ex/ex_screen.c6
-rw-r--r--usr.bin/vi/ex/ex_script.c10
-rw-r--r--usr.bin/vi/ex/ex_subst.c4
-rw-r--r--usr.bin/vi/ex/ex_tag.c96
-rw-r--r--usr.bin/vi/ex/ex_txt.c8
-rw-r--r--usr.bin/vi/vi/v_at.c7
-rw-r--r--usr.bin/vi/vi/v_ex.c6
-rw-r--r--usr.bin/vi/vi/v_screen.c10
-rw-r--r--usr.bin/vi/vi/v_search.c4
-rw-r--r--usr.bin/vi/vi/v_txt.c22
-rw-r--r--usr.bin/vi/vi/vi.c4
-rw-r--r--usr.bin/vi/vi/vi.h6
-rw-r--r--usr.bin/vi/vi/vs_msg.c14
-rw-r--r--usr.bin/vi/vi/vs_refresh.c12
-rw-r--r--usr.bin/vi/vi/vs_split.c22
-rw-r--r--usr.bin/vmstat/dkstats.c8
-rw-r--r--usr.bin/whatis/whatis.c6
47 files changed, 321 insertions, 345 deletions
diff --git a/usr.bin/apropos/apropos.c b/usr.bin/apropos/apropos.c
index e39d546e0d9..d680b7e44bc 100644
--- a/usr.bin/apropos/apropos.c
+++ b/usr.bin/apropos/apropos.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apropos.c,v 1.10 2003/06/10 22:20:44 deraadt Exp $ */
+/* $OpenBSD: apropos.c,v 1.11 2005/10/17 19:04:19 otto Exp $ */
/* $NetBSD: apropos.c,v 1.5 1995/09/04 20:46:20 tls Exp $ */
/*
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)apropos.c 8.8 (Berkeley) 5/4/95";
#else
-static char rcsid[] = "$OpenBSD: apropos.c,v 1.10 2003/06/10 22:20:44 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: apropos.c,v 1.11 2005/10/17 19:04:19 otto Exp $";
#endif
#endif /* not lint */
@@ -113,8 +113,8 @@ main(int argc, char *argv[])
else {
config(conffile);
ep = (tp = getlist("_whatdb")) == NULL ?
- NULL : tp->list.tqh_first;
- for (; ep != NULL; ep = ep->q.tqe_next)
+ NULL : TAILQ_FIRST(&tp->list);
+ for (; ep != NULL; ep = TAILQ_NEXT(ep, q))
apropos(argv, ep->s, 0);
}
diff --git a/usr.bin/gencat/gencat.c b/usr.bin/gencat/gencat.c
index 3e7851b2506..78430f226ce 100644
--- a/usr.bin/gencat/gencat.c
+++ b/usr.bin/gencat/gencat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gencat.c,v 1.9 2004/07/01 19:23:34 mickey Exp $ */
+/* $OpenBSD: gencat.c,v 1.10 2005/10/17 19:04:20 otto Exp $ */
/* $NetBSD: gencat.c,v 1.9 1998/10/09 17:00:56 itohy Exp $ */
/*-
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
static const char rcsid[] =
- "$OpenBSD: gencat.c,v 1.9 2004/07/01 19:23:34 mickey Exp $";
+ "$OpenBSD: gencat.c,v 1.10 2005/10/17 19:04:20 otto Exp $";
#endif /* not lint */
/***********************************************************
@@ -522,12 +522,10 @@ MCWriteCat(int fd)
nmsgs = 0;
string_size = 0;
- for (set = sethead.lh_first; set != NULL;
- set = set->entries.le_next) {
+ LIST_FOREACH(set, &sethead, entries) {
nsets++;
- for (msg = set->msghead.lh_first; msg != NULL;
- msg = msg->entries.le_next) {
+ LIST_FOREACH(msg, &set->msghead, entries) {
nmsgs++;
string_size += strlen(msg->str) + 1;
}
@@ -573,12 +571,10 @@ MCWriteCat(int fd)
msg_index = 0;
msg_offset = 0;
- for (set = sethead.lh_first; set != NULL;
- set = set->entries.le_next) {
+ LIST_FOREACH(set, &sethead, entries) {
nmsgs = 0;
- for (msg = set->msghead.lh_first; msg != NULL;
- msg = msg->entries.le_next) {
+ LIST_FOREACH(msg, &set->msghead, entries) {
int msg_len = strlen(msg->str) + 1;
msg_hdr->__msgno = htonl(msg->msgId);
@@ -621,9 +617,9 @@ MCAddSet(int setId)
}
#endif
- p = sethead.lh_first;
+ p = LIST_FIRST(&sethead);
q = NULL;
- for (; p != NULL && p->setId < setId; q = p, p = p->entries.le_next);
+ for (; p != NULL && p->setId < setId; q = p, p = LIST_NEXT(p, entries));
if (p && p->setId == setId) {
;
@@ -664,9 +660,9 @@ MCAddMsg(int msgId, const char *str)
}
#endif
- p = curSet->msghead.lh_first;
+ p = LIST_FIRST(&curSet->msghead);
q = NULL;
- for (; p != NULL && p->msgId < msgId; q = p, p = p->entries.le_next);
+ for (; p != NULL && p->msgId < msgId; q = p, p = LIST_NEXT(p, entries));
if (p && p->msgId == msgId) {
free(p->str);
@@ -691,12 +687,13 @@ MCDelSet(int setId)
struct _setT *set;
struct _msgT *msg;
- set = sethead.lh_first;
- for (; set != NULL && set->setId < setId; set = set->entries.le_next);
+ set = LIST_FIRST(&sethead);
+ for (; set != NULL && set->setId < setId;
+ set = LIST_NEXT(set, entries));
if (set && set->setId == setId) {
- msg = set->msghead.lh_first;
+ msg = LIST_FIRST(&set->msghead);
while (msg) {
free(msg->str);
LIST_REMOVE(msg, entries);
@@ -716,8 +713,9 @@ MCDelMsg(int msgId)
if (!curSet)
error(NULL, "you can't delete a message before defining the set");
- msg = curSet->msghead.lh_first;
- for (; msg != NULL && msg->msgId < msgId; msg = msg->entries.le_next);
+ msg = LIST_FIRST(&curSet->msghead);
+ for (; msg != NULL && msg->msgId < msgId;
+ msg = LIST_NEXT(msg, entries));
if (msg && msg->msgId == msgId) {
free(msg->str);
diff --git a/usr.bin/man/config.c b/usr.bin/man/config.c
index bc944547a40..63a174f3279 100644
--- a/usr.bin/man/config.c
+++ b/usr.bin/man/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.6 2004/09/15 22:20:03 deraadt Exp $ */
+/* $OpenBSD: config.c,v 1.7 2005/10/17 19:08:46 otto Exp $ */
/* $NetBSD: config.c,v 1.7 1995/09/28 06:05:21 tls Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)config.c 8.8 (Berkeley) 1/31/95";
#else
-static char rcsid[] = "$OpenBSD: config.c,v 1.6 2004/09/15 22:20:03 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: config.c,v 1.7 2005/10/17 19:08:46 otto Exp $";
#endif
#endif /* not lint */
@@ -100,8 +100,8 @@ config(char *fname)
continue;
*t = '\0';
- for (tp = head.tqh_first; /* Find any matching tag. */
- tp != NULL && strcmp(p, tp->s); tp = tp->q.tqe_next);
+ for (tp = TAILQ_FIRST(&head); /* Find any matching tag. */
+ tp != NULL && strcmp(p, tp->s); tp = TAILQ_NEXT(tp, q));
if (tp == NULL) /* Create a new tag. */
tp = addlist(p);
@@ -156,7 +156,7 @@ getlist(char *name)
{
TAG *tp;
- for (tp = head.tqh_first; tp != NULL; tp = tp->q.tqe_next)
+ TAILQ_FOREACH(tp, &head, q)
if (!strcmp(name, tp->s))
return (tp);
return (NULL);
diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c
index cc04876b357..15e766841af 100644
--- a/usr.bin/man/man.c
+++ b/usr.bin/man/man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.c,v 1.28 2004/02/23 14:14:14 jmc Exp $ */
+/* $OpenBSD: man.c,v 1.29 2005/10/17 19:08:46 otto Exp $ */
/* $NetBSD: man.c,v 1.7 1995/09/28 06:05:34 tls Exp $ */
/*
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
#else
-static char rcsid[] = "$OpenBSD: man.c,v 1.28 2004/02/23 14:14:14 jmc Exp $";
+static char rcsid[] = "$OpenBSD: man.c,v 1.29 2005/10/17 19:08:46 otto Exp $";
#endif
#endif /* not lint */
@@ -187,7 +187,7 @@ main(int argc, char *argv[])
if (p_path == NULL)
p_path = getenv("MANPATH");
if (p_path != NULL) {
- while ((e_defp = defp->list.tqh_first) != NULL) {
+ while ((e_defp = TAILQ_FIRST(&defp->list)) != NULL) {
free(e_defp->s);
TAILQ_REMOVE(&defp->list, e_defp, q);
}
@@ -195,8 +195,8 @@ main(int argc, char *argv[])
p != NULL; p = strtok(NULL, ":")) {
slashp = p[strlen(p) - 1] == '/' ? "" : "/";
e_subp = (subp = getlist("_subdir")) == NULL ?
- NULL : subp->list.tqh_first;
- for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
+ NULL : TAILQ_FIRST(&subp->list);
+ for (; e_subp != NULL; e_subp = TAILQ_NEXT(e_subp, q)) {
(void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
p, slashp, e_subp->s, machine);
if ((ep = malloc(sizeof(ENTRY))) == NULL ||
@@ -221,14 +221,13 @@ main(int argc, char *argv[])
}
if (p_path == NULL && section == NULL) {
defnewp = addlist("_default_new");
- e_defp =
- defp->list.tqh_first == NULL ? NULL : defp->list.tqh_first;
- for (; e_defp != NULL; e_defp = e_defp->q.tqe_next) {
+ e_defp = TAILQ_FIRST(&defp->list);
+ for (; e_defp != NULL; e_defp = TAILQ_NEXT(e_defp, q)) {
slashp =
e_defp->s[strlen(e_defp->s) - 1] == '/' ? "" : "/";
e_subp = (subp = getlist("_subdir")) == NULL ?
- NULL : subp->list.tqh_first;
- for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
+ NULL : TAILQ_FIRST(&subp->list);
+ for (; e_subp != NULL; e_subp = TAILQ_NEXT(e_subp, q)) {
(void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
e_defp->s, slashp, e_subp->s, machine);
if ((ep = malloc(sizeof(ENTRY))) == NULL ||
@@ -238,7 +237,7 @@ main(int argc, char *argv[])
}
}
defp = getlist("_default");
- while ((e_defp = defp->list.tqh_first) != NULL) {
+ while ((e_defp = TAILQ_FIRST(&defp->list)) != NULL) {
free(e_defp->s);
TAILQ_REMOVE(&defp->list, e_defp, q);
}
@@ -260,8 +259,8 @@ main(int argc, char *argv[])
for (p = strtok(p_add, ":"); p != NULL; p = strtok(NULL, ":")) {
slashp = p[strlen(p) - 1] == '/' ? "" : "/";
e_subp = (subp = getlist("_subdir")) == NULL ?
- NULL : subp->list.tqh_first;
- for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
+ NULL : TAILQ_FIRST(&subp->list);
+ for (; e_subp != NULL; e_subp = TAILQ_NEXT(e_subp, q)) {
(void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
p, slashp, e_subp->s, machine);
if ((ep = malloc(sizeof(ENTRY))) == NULL ||
@@ -280,9 +279,9 @@ main(int argc, char *argv[])
}
if (e_sectp != NULL) { /* entries added, fix order */
/* save original head */
- ep->q.tqe_next = defp->list.tqh_first;
+ TAILQ_NEXT(ep, q) = TAILQ_FIRST(&defp->list);
/* first added entry, new top */
- defp->list.tqh_first = e_sectp;
+ TAILQ_FIRST(&defp->list) = e_sectp;
/* terminate list */
*e_sectp->q.tqe_prev = NULL;
}
@@ -294,8 +293,7 @@ main(int argc, char *argv[])
*/
if (p_add == NULL && section != NULL) {
sectnewp = addlist("_section_new");
- for (e_sectp = section->list.tqh_first;
- e_sectp != NULL; e_sectp = e_sectp->q.tqe_next) {
+ TAILQ_FOREACH(e_sectp, &section->list, q) {
if (e_sectp->s[strlen(e_sectp->s) - 1] != '/') {
(void)snprintf(buf, sizeof(buf),
"%s{/%s,}", e_sectp->s, machine);
@@ -306,8 +304,8 @@ main(int argc, char *argv[])
continue;
}
e_subp = (subp = getlist("_subdir")) == NULL ?
- NULL : subp->list.tqh_first;
- for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
+ NULL : TAILQ_FIRST(&subp->list);
+ for (; e_subp != NULL; e_subp = TAILQ_NEXT(e_subp, q)) {
(void)snprintf(buf, sizeof(buf), "%s%s{/%s,}",
e_sectp->s, e_subp->s, machine);
if ((ep = malloc(sizeof(ENTRY))) == NULL ||
@@ -420,8 +418,8 @@ manual(char *page, TAG *tag, glob_t *pg)
buf[0] = '*';
/* For each element in the list... */
- e_tag = tag == NULL ? NULL : tag->list.tqh_first;
- for (; e_tag != NULL; e_tag = e_tag->q.tqe_next) {
+ e_tag = tag == NULL ? NULL : TAILQ_FIRST(&tag->list);
+ for (; e_tag != NULL; e_tag = TAILQ_NEXT(e_tag, q)) {
(void)snprintf(buf, sizeof(buf), "%s/%s.*", e_tag->s, page);
if (glob(buf,
GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT | GLOB_QUOTE,
@@ -451,9 +449,9 @@ manual(char *page, TAG *tag, glob_t *pg)
goto next;
e_sufp = (sufp = getlist("_suffix")) == NULL ?
- NULL : sufp->list.tqh_first;
+ NULL : TAILQ_FIRST(&sufp->list);
for (found = 0;
- e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) {
+ e_sufp != NULL; e_sufp = TAILQ_NEXT(e_sufp, q)) {
(void)snprintf(buf,
sizeof(buf), "*/%s%s", page, e_sufp->s);
if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
@@ -466,9 +464,9 @@ manual(char *page, TAG *tag, glob_t *pg)
/* Try the _build key words next. */
e_sufp = (sufp = getlist("_build")) == NULL ?
- NULL : sufp->list.tqh_first;
+ NULL : TAILQ_FIRST(&sufp->list);
for (found = 0;
- e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) {
+ e_sufp != NULL; e_sufp = TAILQ_NEXT(e_sufp, q)) {
for (p = e_sufp->s;
*p != '\0' && !isspace(*p); ++p);
if (*p == '\0')
@@ -766,9 +764,9 @@ cleanup(void)
rval = 0;
ep = (missp = getlist("_missing")) == NULL ?
- NULL : missp->list.tqh_first;
+ NULL : TAILQ_FIRST(&missp->list);
if (ep != NULL)
- for (; ep != NULL; ep = ep->q.tqe_next) {
+ for (; ep != NULL; ep = TAILQ_NEXT(ep, q)) {
if (section)
warnx("no entry for %s in section %s of the manual.",
ep->s, section->s);
@@ -778,8 +776,8 @@ cleanup(void)
}
ep = (intmpp = getlist("_intmp")) == NULL ?
- NULL : intmpp->list.tqh_first;
- for (; ep != NULL; ep = ep->q.tqe_next)
+ NULL : TAILQ_FIRST(&intmpp->list);
+ for (; ep != NULL; ep = TAILQ_NEXT(ep, q))
(void)unlink(ep->s);
return (rval);
}
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index 7e140e6f2a7..448241b4e1b 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.44 2005/06/08 04:47:04 henning Exp $ */
+/* $OpenBSD: if.c,v 1.45 2005/10/17 19:09:36 otto Exp $ */
/* $NetBSD: if.c,v 1.16.4.2 1996/06/07 21:46:46 thorpej Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
#else
-static char *rcsid = "$OpenBSD: if.c,v 1.44 2005/06/08 04:47:04 henning Exp $";
+static char *rcsid = "$OpenBSD: if.c,v 1.45 2005/10/17 19:09:36 otto Exp $";
#endif
#endif /* not lint */
@@ -105,7 +105,7 @@ intpr(int interval, u_long ifnetaddr)
*/
if (kread(ifnetaddr, &ifhead, sizeof ifhead))
return;
- ifnetaddr = (u_long)ifhead.tqh_first;
+ ifnetaddr = (u_long)TAILQ_FIRST(&ifhead);
printf("%-7.7s %-5.5s %-11.11s %-17.17s ",
"Name", "Mtu", "Network", "Address");
@@ -133,14 +133,14 @@ intpr(int interval, u_long ifnetaddr)
return;
bcopy(ifnet.if_xname, name, IFNAMSIZ);
name[IFNAMSIZ - 1] = '\0'; /* sanity */
- ifnetaddr = (u_long)ifnet.if_list.tqe_next;
+ ifnetaddr = (u_long)TAILQ_NEXT(&ifnet, if_list);
if (interface != 0 && strcmp(name, interface) != 0)
continue;
cp = strchr(name, '\0');
if ((ifnet.if_flags & IFF_UP) == 0)
*cp++ = '*';
*cp = '\0';
- ifaddraddr = (u_long)ifnet.if_addrlist.tqh_first;
+ ifaddraddr = (u_long)TAILQ_FIRST(&ifnet.if_addrlist);
}
if (qflag) {
@@ -205,12 +205,12 @@ intpr(int interval, u_long ifnetaddr)
u_long multiaddr;
struct in_multi inm;
- multiaddr = (u_long)ifaddr.in.ia_multiaddrs.lh_first;
+ multiaddr = (u_long)LIST_FIRST(&ifaddr.in.ia_multiaddrs);
while (multiaddr != 0) {
kread(multiaddr, &inm, sizeof inm);
printf("\n%25s %-17.17s ", "",
routename(inm.inm_addr.s_addr));
- multiaddr = (u_long)inm.inm_list.le_next;
+ multiaddr = (u_long)LIST_NEXT(&inm, inm_list);
}
}
break;
@@ -244,7 +244,7 @@ intpr(int interval, u_long ifnetaddr)
struct in6_multi inm;
struct sockaddr_in6 m6;
- multiaddr = (u_long)ifaddr.in6.ia6_multiaddrs.lh_first;
+ multiaddr = (u_long)LIST_FIRST(&ifaddr.in6.ia6_multiaddrs);
while (multiaddr != 0) {
kread(multiaddr, &inm, sizeof inm);
memset(&m6, 0, sizeof(m6));
@@ -267,7 +267,7 @@ intpr(int interval, u_long ifnetaddr)
n = 17;
printf("\n%25s %-*.*s ", "",
n, n, cp);
- multiaddr = (u_long)inm.in6m_entry.le_next;
+ multiaddr = (u_long)LIST_NEXT(&inm, in6m_entry);
}
}
break;
@@ -325,7 +325,7 @@ intpr(int interval, u_long ifnetaddr)
putchar(' ');
break;
}
- ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next;
+ ifaddraddr = (u_long)TAILQ_NEXT(&ifaddr.ifa, ifa_list);
}
if (bflag)
printf("%10lu %10lu",
@@ -382,7 +382,7 @@ sidewaysintpr(unsigned int interval, u_long off)
*/
if (kread(off, &ifhead, sizeof ifhead))
return;
- firstifnet = (u_long)ifhead.tqh_first;
+ firstifnet = (u_long)TAILQ_FIRST(&ifhead);
lastif = iftot;
sum = iftot + MAXIF - 1;
@@ -398,7 +398,7 @@ sidewaysintpr(unsigned int interval, u_long off)
ip++;
if (ip >= iftot + MAXIF - 2)
break;
- off = (u_long)ifnet.if_list.tqe_next;
+ off = (u_long)TAILQ_NEXT(&ifnet, if_list);
}
if (interesting == NULL) {
fprintf(stderr, "%s: %s: unknown interface\n",
@@ -509,7 +509,7 @@ loop:
sum->ift_oe += ip->ift_oe;
sum->ift_co += ip->ift_co;
sum->ift_dr += ip->ift_dr;
- off = (u_long)ifnet.if_list.tqe_next;
+ off = (u_long)TAILQ_NEXT(&ifnet, if_list);
}
if (lastif - iftot > 0) {
if (bflag)
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index f504c368c93..2740e11ad79 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet.c,v 1.98 2005/08/11 15:52:14 markus Exp $ */
+/* $OpenBSD: inet.c,v 1.99 2005/10/17 19:09:36 otto Exp $ */
/* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94";
#else
-static const char *rcsid = "$OpenBSD: inet.c,v 1.98 2005/08/11 15:52:14 markus Exp $";
+static const char *rcsid = "$OpenBSD: inet.c,v 1.99 2005/10/17 19:09:36 otto Exp $";
#endif
#endif /* not lint */
@@ -140,17 +140,17 @@ protopr0(u_long off, char *name, int af)
israw = strncmp(name, "ip", 2) == 0;
kread(off, &table, sizeof table);
prev = head =
- (struct inpcb *)&((struct inpcbtable *)off)->inpt_queue.cqh_first;
- next = table.inpt_queue.cqh_first;
+ (struct inpcb *)&CIRCLEQ_FIRST(&((struct inpcbtable *)off)->inpt_queue);
+ next = CIRCLEQ_FIRST(&table.inpt_queue);
while (next != head) {
kread((u_long)next, &inpcb, sizeof inpcb);
- if (inpcb.inp_queue.cqe_prev != prev) {
+ if (CIRCLEQ_PREV(&inpcb, inp_queue) != prev) {
printf("???\n");
break;
}
prev = next;
- next = inpcb.inp_queue.cqe_next;
+ next = CIRCLEQ_NEXT(&inpcb, inp_queue);
switch (af) {
case AF_INET:
diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c
index ba581825278..6c5e1b57d06 100644
--- a/usr.bin/netstat/ipx.c
+++ b/usr.bin/netstat/ipx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipx.c,v 1.17 2005/03/30 06:45:34 deraadt Exp $ */
+/* $OpenBSD: ipx.c,v 1.18 2005/10/17 19:09:36 otto Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)ns.c 8.1 (Berkeley) 6/6/93";
#else
-static char *rcsid = "$OpenBSD: ipx.c,v 1.17 2005/03/30 06:45:34 deraadt Exp $";
+static char *rcsid = "$OpenBSD: ipx.c,v 1.18 2005/10/17 19:09:36 otto Exp $";
#endif
#endif /* not lint */
@@ -98,17 +98,17 @@ ipxprotopr(u_long off, char *name)
isspx = strcmp(name, "spx") == 0;
kread(off, &table, sizeof (table));
prev = head = (struct ipxpcb *)
- &((struct ipxpcbtable *)off)->ipxpt_queue.cqh_first;
- next = table.ipxpt_queue.cqh_first;
+ &CIRCLEQ_FIRST(&((struct ipxpcbtable *)off)->ipxpt_queue);
+ next = CIRCLEQ_FIRST(&table.ipxpt_queue);
while (next != head) {
kread((u_long)next, &ipxpcb, sizeof (ipxpcb));
- if (ipxpcb.ipxp_queue.cqe_prev != prev) {
+ if (CIRCLEQ_PREV(&ipxpcb, ipxp_queue) != prev) {
printf("???\n");
break;
}
prev = next;
- next = ipxpcb.ipxp_queue.cqe_next;
+ next = CIRCLEQ_NEXT(&ipxpcb, ipxp_queue);
if (!aflag && ipx_nullhost(ipxpcb.ipxp_faddr) )
continue;
diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c
index 5393b11b463..bd60dd9bc32 100644
--- a/usr.bin/netstat/mroute.c
+++ b/usr.bin/netstat/mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mroute.c,v 1.14 2005/03/30 07:50:11 deraadt Exp $ */
+/* $OpenBSD: mroute.c,v 1.15 2005/10/17 19:09:36 otto Exp $ */
/* $NetBSD: mroute.c,v 1.10 1996/05/11 13:51:27 mycroft Exp $ */
/*
@@ -168,7 +168,7 @@ mroutepr(u_long mrpaddr, u_long mfchashtbladdr, u_long mfchashaddr, u_long vifad
for (i = 0; i <= mfchash; ++i) {
kread((u_long)&mfchashtbl[i], &mfcp, sizeof(mfcp));
- for (; mfcp != 0; mfcp = mfc.mfc_hash.le_next) {
+ for (; mfcp != 0; mfcp = LIST_NEXT(&mfc, mfc_hash)) {
if (!banner_printed) {
printf("\nMulticast Forwarding Cache\n %s%s",
"Hash Origin Mcastgroup ",
diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c
index 2756d0d9090..2d81da1c9ad 100644
--- a/usr.bin/systat/netstat.c
+++ b/usr.bin/systat/netstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netstat.c,v 1.27 2005/05/10 17:12:00 deraadt Exp $ */
+/* $OpenBSD: netstat.c,v 1.28 2005/10/17 19:04:20 otto Exp $ */
/* $NetBSD: netstat.c,v 1.3 1995/06/18 23:53:07 cgd Exp $ */
/*-
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: netstat.c,v 1.27 2005/05/10 17:12:00 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: netstat.c,v 1.28 2005/10/17 19:04:20 otto Exp $";
#endif /* not lint */
/*
@@ -195,12 +195,12 @@ fetchnetstat(void)
again:
KREAD(off, &pcbtable, sizeof (struct inpcbtable));
prev = head = (struct inpcb *)&((struct inpcbtable *)off)->inpt_queue;
- next = pcbtable.inpt_queue.cqh_first;
+ next = CIRCLEQ_FIRST(&pcbtable.inpt_queue);
while (next != head) {
KREAD(next, &inpcb, sizeof (inpcb));
- if (inpcb.inp_queue.cqe_prev != prev) {
+ if (CIRCLEQ_PREV(&inpcb, inp_queue) != prev) {
printf("prev = %p, head = %p, next = %p, inpcb...prev = %p\n",
- prev, head, next, inpcb.inp_queue.cqe_prev);
+ prev, head, next, CIRCLEQ_PREV(&inpcb, inp_queue));
p = netcb.nif_forw;
for (; p != (struct netinfo *)&netcb; p = p->nif_forw)
p->nif_seen = 1;
@@ -208,7 +208,7 @@ again:
return;
}
prev = next;
- next = inpcb.inp_queue.cqe_next;
+ next = CIRCLEQ_NEXT(&inpcb, inp_queue);
if (!aflag) {
if (!(inpcb.inp_flags & INP_IPV6) &&
diff --git a/usr.bin/vi/cl/cl_read.c b/usr.bin/vi/cl/cl_read.c
index 8b3db162f65..0d49c42bb58 100644
--- a/usr.bin/vi/cl/cl_read.c
+++ b/usr.bin/vi/cl/cl_read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cl_read.c,v 1.12 2003/09/02 22:44:06 dhartmei Exp $ */
+/* $OpenBSD: cl_read.c,v 1.13 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -156,8 +156,7 @@ cl_read(sp, flags, bp, blen, nrp, tp)
/* Allocate space for rdfd. */
maxfd = STDIN_FILENO;
- for (tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
+ CIRCLEQ_FOREACH(tsp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT) && sp->script->sh_master > maxfd)
maxfd = sp->script->sh_master;
rdfd = (fd_set *)malloc(howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
@@ -240,8 +239,7 @@ cl_read(sp, flags, bp, blen, nrp, tp)
if (F_ISSET(gp, G_SCRWIN)) {
loop: memset(rdfd, 0, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
FD_SET(STDIN_FILENO, rdfd);
- for (tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
+ CIRCLEQ_FOREACH(tsp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT))
FD_SET(sp->script->sh_master, rdfd);
switch (select(maxfd + 1, rdfd, NULL, NULL, NULL)) {
diff --git a/usr.bin/vi/cl/cl_screen.c b/usr.bin/vi/cl/cl_screen.c
index 22fac8f8249..a870d1bc63e 100644
--- a/usr.bin/vi/cl/cl_screen.c
+++ b/usr.bin/vi/cl/cl_screen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cl_screen.c,v 1.15 2005/04/21 09:00:25 otto Exp $ */
+/* $OpenBSD: cl_screen.c,v 1.16 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -93,7 +93,7 @@ cl_screen(sp, flags)
if (F_ISSET(sp, SC_SCR_VI)) {
F_CLR(sp, SC_SCR_VI);
- if (sp->q.cqe_next != (void *)&gp->dq) {
+ if (CIRCLEQ_NEXT(sp, q) != CIRCLEQ_END(&gp->dq)) {
(void)move(RLNO(sp, sp->rows), 0);
clrtobot();
}
diff --git a/usr.bin/vi/cl/cl_term.c b/usr.bin/vi/cl/cl_term.c
index 6a945ef5b9f..cbfb8119168 100644
--- a/usr.bin/vi/cl/cl_term.c
+++ b/usr.bin/vi/cl/cl_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cl_term.c,v 1.12 2002/02/16 21:27:56 millert Exp $ */
+/* $OpenBSD: cl_term.c,v 1.13 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -144,7 +144,7 @@ cl_term_init(sp)
* Rework any function key mappings that were set before the
* screen was initialized.
*/
- for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next)
+ LIST_FOREACH(qp, & sp->gp->seqq, q)
if (F_ISSET(qp, SEQ_FUNCMAP))
(void)cl_pfmap(sp, qp->stype,
qp->input, qp->ilen, qp->output, qp->olen);
@@ -164,8 +164,8 @@ cl_term_end(gp)
SEQ *qp, *nqp;
/* Delete screen specific mappings. */
- for (qp = gp->seqq.lh_first; qp != NULL; qp = nqp) {
- nqp = qp->q.le_next;
+ for (qp = LIST_FIRST(&gp->seqq); qp != NULL; qp = nqp) {
+ nqp = LIST_NEXT(qp, q);
if (F_ISSET(qp, SEQ_SCREEN))
(void)seq_mdel(qp);
}
diff --git a/usr.bin/vi/common/cut.c b/usr.bin/vi/common/cut.c
index 32a5fb512f1..c5beeb8fb0d 100644
--- a/usr.bin/vi/common/cut.c
+++ b/usr.bin/vi/common/cut.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cut.c,v 1.7 2002/02/16 21:27:56 millert Exp $ */
+/* $OpenBSD: cut.c,v 1.8 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -198,7 +198,7 @@ cb_rotate(sp)
CB *cbp, *del_cbp;
del_cbp = NULL;
- for (cbp = sp->gp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next)
+ LIST_FOREACH(cbp, &sp->gp->cutq, q)
switch(cbp->name) {
case '1':
cbp->name = '2';
@@ -291,8 +291,8 @@ cut_close(gp)
CB *cbp;
/* Free cut buffer list. */
- while ((cbp = gp->cutq.lh_first) != NULL) {
- if (cbp->textq.cqh_first != (void *)&cbp->textq)
+ while ((cbp = LIST_FIRST(&gp->cutq)) != NULL) {
+ if (CIRCLEQ_FIRST(&cbp->textq) != CIRCLEQ_END(&cbp->textq))
text_lfree(&cbp->textq);
LIST_REMOVE(cbp, q);
free(cbp);
@@ -300,7 +300,7 @@ cut_close(gp)
/* Free default cut storage. */
cbp = &gp->dcb_store;
- if (cbp->textq.cqh_first != (void *)&cbp->textq)
+ if (CIRCLEQ_FIRST(&cbp->textq) != CIRCLEQ_END(&cbp->textq))
text_lfree(&cbp->textq);
}
@@ -347,7 +347,7 @@ text_lfree(headp)
{
TEXT *tp;
- while ((tp = headp->cqh_first) != (void *)headp) {
+ while ((tp = CIRCLEQ_FIRST(headp)) != CIRCLEQ_END(headp)) {
CIRCLEQ_REMOVE(headp, tp, q);
text_free(tp);
}
diff --git a/usr.bin/vi/common/cut.h b/usr.bin/vi/common/cut.h
index 1202004193b..8ea31d58040 100644
--- a/usr.bin/vi/common/cut.h
+++ b/usr.bin/vi/common/cut.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cut.h,v 1.4 2002/01/31 11:10:39 hugh Exp $ */
+/* $OpenBSD: cut.h,v 1.5 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -67,8 +67,7 @@ struct _text { /* Text: a linked list of lines. */
#define CBNAME(sp, cbp, nch) { \
CHAR_T L__name; \
L__name = isupper(nch) ? tolower(nch) : (nch); \
- for (cbp = sp->gp->cutq.lh_first; \
- cbp != NULL; cbp = cbp->q.le_next) \
+ LIST_FOREACH((cbp), &(sp)->gp->cutq, q) \
if (cbp->name == L__name) \
break; \
}
diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c
index 94046cc8392..065ac0d8af9 100644
--- a/usr.bin/vi/common/exf.c
+++ b/usr.bin/vi/common/exf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exf.c,v 1.20 2003/12/31 18:18:22 millert Exp $ */
+/* $OpenBSD: exf.c,v 1.21 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -79,10 +79,9 @@ file_add(sp, name)
*/
gp = sp->gp;
if (name != NULL)
- for (frp = gp->frefq.cqh_first;
- frp != (FREF *)&gp->frefq; frp = frp->q.cqe_next) {
+ CIRCLEQ_FOREACH(frp, &gp->frefq, q) {
if (frp->name == NULL) {
- tfrp = frp->q.cqe_next;
+ tfrp = CIRCLEQ_NEXT(frp, q);
CIRCLEQ_REMOVE(&gp->frefq, frp, q);
if (frp->name != NULL)
free(frp->name);
diff --git a/usr.bin/vi/common/gs.h b/usr.bin/vi/common/gs.h
index c0674b63b6c..eca92f90ee5 100644
--- a/usr.bin/vi/common/gs.h
+++ b/usr.bin/vi/common/gs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: gs.h,v 1.7 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: gs.h,v 1.8 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -91,7 +91,7 @@ struct _gs {
* Ex command structures (EXCMD). Defined here because ex commands
* exist outside of any particular screen or file.
*/
-#define EXCMD_RUNNING(gp) ((gp)->ecq.lh_first->clen != 0)
+#define EXCMD_RUNNING(gp) (LIST_FIRST(&(gp)->ecq)->clen != 0)
LIST_HEAD(_excmdh, _excmd) ecq; /* Ex command linked list. */
EXCMD excmd; /* Default ex command structure. */
char *if_name; /* Current associated file. */
diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c
index d23dccda1d0..f08a2039c5a 100644
--- a/usr.bin/vi/common/key.c
+++ b/usr.bin/vi/common/key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key.c,v 1.6 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: key.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -753,9 +753,9 @@ v_sync(sp, flags)
GS *gp;
gp = sp->gp;
- for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
+ CIRCLEQ_FOREACH(sp, &gp->dq, q)
rcv_sync(sp, flags);
- for (sp = gp->hq.cqh_first; sp != (void *)&gp->hq; sp = sp->q.cqe_next)
+ CIRCLEQ_FOREACH(sp, &gp->hq, q)
rcv_sync(sp, flags);
}
diff --git a/usr.bin/vi/common/line.c b/usr.bin/vi/common/line.c
index b1075923451..0e64f8c761b 100644
--- a/usr.bin/vi/common/line.c
+++ b/usr.bin/vi/common/line.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: line.c,v 1.5 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: line.c,v 1.6 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -115,14 +115,14 @@ db_get(sp, lno, flags, pp, lenp)
* is there.
*/
if (F_ISSET(sp, SC_TINPUT)) {
- l1 = ((TEXT *)sp->tiq.cqh_first)->lno;
- l2 = ((TEXT *)sp->tiq.cqh_last)->lno;
+ l1 = ((TEXT *)CIRCLEQ_FIRST(&sp->tiq))->lno;
+ l2 = ((TEXT *)CIRCLEQ_LAST(&sp->tiq))->lno;
if (l1 <= lno && l2 >= lno) {
#if defined(DEBUG) && 0
TRACE(sp, "retrieve TEXT buffer line %lu\n", (u_long)lno);
#endif
- for (tp = sp->tiq.cqh_first;
- tp->lno != lno; tp = tp->q.cqe_next);
+ for (tp = CIRCLEQ_FIRST(&sp->tiq);
+ tp->lno != lno; tp = CIRCLEQ_NEXT(tp, q));
if (lenp != NULL)
*lenp = tp->len;
if (pp != NULL)
@@ -467,7 +467,7 @@ db_exist(sp, lno)
if (ep->c_nlines != OOBLNO)
return (lno <= (F_ISSET(sp, SC_TINPUT) ?
ep->c_nlines + (((TEXT *)sp->tiq.cqh_last)->lno -
- ((TEXT *)sp->tiq.cqh_first)->lno) : ep->c_nlines));
+ ((TEXT *)CIRCLEQ_FIRST(&sp->tiq))->lno) : ep->c_nlines));
/* Go get the line. */
return (!db_get(sp, lno, 0, NULL, NULL));
@@ -502,7 +502,7 @@ db_last(sp, lnop)
*lnop = ep->c_nlines;
if (F_ISSET(sp, SC_TINPUT))
*lnop += ((TEXT *)sp->tiq.cqh_last)->lno -
- ((TEXT *)sp->tiq.cqh_first)->lno;
+ ((TEXT *)CIRCLEQ_FIRST(&sp->tiq))->lno;
return (0);
}
@@ -569,8 +569,7 @@ scr_update(sp, lno, op, current)
ep = sp->ep;
if (ep->refcnt != 1)
- for (tsp = sp->gp->dq.cqh_first;
- tsp != (void *)&sp->gp->dq; tsp = tsp->q.cqe_next)
+ CIRCLEQ_FOREACH(tsp, &sp->gp->dq, q)
if (sp != tsp && tsp->ep == ep)
if (vs_change(tsp, lno, op))
return (1);
diff --git a/usr.bin/vi/common/main.c b/usr.bin/vi/common/main.c
index aa81444c60f..d776e6153a3 100644
--- a/usr.bin/vi/common/main.c
+++ b/usr.bin/vi/common/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.10 2003/04/17 02:22:56 itojun Exp $ */
+/* $OpenBSD: main.c,v 1.11 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -450,9 +450,9 @@ v_end(gp)
(void)file_end(gp->ccl_sp, NULL, 1);
(void)screen_end(gp->ccl_sp);
}
- while ((sp = gp->dq.cqh_first) != (void *)&gp->dq)
+ while ((sp = CIRCLEQ_FIRST(&gp->dq)) != CIRCLEQ_END(&gp->dq))
(void)screen_end(sp);
- while ((sp = gp->hq.cqh_first) != (void *)&gp->hq)
+ while ((sp = CIRCLEQ_FIRST(&gp->hq)) != CIRCLEQ_END(&gp->hq))
(void)screen_end(sp);
#ifdef HAVE_PERL_INTERP
@@ -499,7 +499,7 @@ v_end(gp)
* it's possible that the user is sourcing a file that exits from the
* editor).
*/
- while ((mp = gp->msgq.lh_first) != NULL) {
+ while ((mp = LIST_FIRST(&gp->msgq)) != NULL) {
(void)fprintf(stderr, "%s%.*s",
mp->mtype == M_ERR ? "ex/vi: " : "", (int)mp->len, mp->buf);
LIST_REMOVE(mp, q);
diff --git a/usr.bin/vi/common/mark.c b/usr.bin/vi/common/mark.c
index e18183732c9..53427bf0580 100644
--- a/usr.bin/vi/common/mark.c
+++ b/usr.bin/vi/common/mark.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mark.c,v 1.5 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: mark.c,v 1.6 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -98,7 +98,7 @@ mark_end(sp, ep)
* !!!
* ep MAY NOT BE THE SAME AS sp->ep, DON'T USE THE LATTER.
*/
- while ((lmp = ep->marks.lh_first) != NULL) {
+ while ((lmp = LIST_FIRST(&ep->marks)) != NULL) {
LIST_REMOVE(lmp, q);
free(lmp);
}
@@ -209,8 +209,8 @@ mark_find(sp, key)
* Return the requested mark or the slot immediately before
* where it should go.
*/
- for (lastlmp = NULL, lmp = sp->ep->marks.lh_first;
- lmp != NULL; lastlmp = lmp, lmp = lmp->q.le_next)
+ for (lastlmp = NULL, lmp = LIST_FIRST(&sp->ep->marks);
+ lmp != NULL; lastlmp = lmp, lmp = LIST_NEXT(lmp, q))
if (lmp->name >= key)
return (lmp->name == key ? lmp : lastlmp);
return (lastlmp);
@@ -236,8 +236,7 @@ mark_insdel(sp, op, lno)
/* All insert/append operations are done as inserts. */
abort();
case LINE_DELETE:
- for (lmp = sp->ep->marks.lh_first;
- lmp != NULL; lmp = lmp->q.le_next)
+ LIST_FOREACH(lmp, &sp->ep->marks, q)
if (lmp->lno >= lno)
if (lmp->lno == lno) {
F_SET(lmp, MARK_DELETED);
@@ -267,8 +266,7 @@ mark_insdel(sp, op, lno)
return (0);
}
- for (lmp = sp->ep->marks.lh_first;
- lmp != NULL; lmp = lmp->q.le_next)
+ LIST_FOREACH(lmp, &sp->ep->marks, q)
if (lmp->lno >= lno)
++lmp->lno;
break;
diff --git a/usr.bin/vi/common/put.c b/usr.bin/vi/common/put.c
index 08ee3b79240..9e855818ac2 100644
--- a/usr.bin/vi/common/put.c
+++ b/usr.bin/vi/common/put.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: put.c,v 1.6 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: put.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -65,7 +65,7 @@ put(sp, cbp, namep, cp, rp, append)
return (1);
}
}
- tp = cbp->textq.cqh_first;
+ tp = CIRCLEQ_FIRST(&cbp->textq);
/*
* It's possible to do a put into an empty file, meaning that the cut
@@ -87,7 +87,8 @@ put(sp, cbp, namep, cp, rp, append)
return (1);
if (lno == 0) {
for (; tp != (void *)&cbp->textq;
- ++lno, ++sp->rptlines[L_ADDED], tp = tp->q.cqe_next)
+ ++lno, ++sp->rptlines[L_ADDED],
+ tp = CIRCLEQ_NEXT(tp, q))
if (db_append(sp, 1, lno, tp->lb, tp->len))
return (1);
rp->lno = 1;
@@ -100,8 +101,8 @@ put(sp, cbp, namep, cp, rp, append)
if (F_ISSET(cbp, CB_LMODE)) {
lno = append ? cp->lno : cp->lno - 1;
rp->lno = lno + 1;
- for (; tp != (void *)&cbp->textq;
- ++lno, ++sp->rptlines[L_ADDED], tp = tp->q.cqe_next)
+ for (; tp != CIRCLEQ_END(&cbp->textq);
+ ++lno, ++sp->rptlines[L_ADDED], tp = CIRCLEQ_NEXT(tp, q))
if (db_append(sp, 1, lno, tp->lb, tp->len))
return (1);
rp->cno = 0;
@@ -163,7 +164,7 @@ put(sp, cbp, namep, cp, rp, append)
* the intermediate lines, because the line changes will lose
* the cached line.
*/
- if (tp->q.cqe_next == (void *)&cbp->textq) {
+ if (CIRCLEQ_NEXT(tp, q) == CIRCLEQ_END(&cbp->textq)) {
if (clen > 0) {
memcpy(t, p, clen);
t += clen;
@@ -213,9 +214,9 @@ put(sp, cbp, namep, cp, rp, append)
}
/* Output any intermediate lines in the CB. */
- for (tp = tp->q.cqe_next;
- tp->q.cqe_next != (void *)&cbp->textq;
- ++lno, ++sp->rptlines[L_ADDED], tp = tp->q.cqe_next)
+ for (tp = CIRCLEQ_NEXT(tp, q);
+ CIRCLEQ_NEXT(tp, q) != CIRCLEQ_END(&cbp->textq);
+ ++lno, ++sp->rptlines[L_ADDED], tp = CIRCLEQ_NEXT(tp, q))
if (db_append(sp, 1, lno, tp->lb, tp->len))
goto err;
diff --git a/usr.bin/vi/common/screen.c b/usr.bin/vi/common/screen.c
index 78a7283ed83..d82fb005c5c 100644
--- a/usr.bin/vi/common/screen.c
+++ b/usr.bin/vi/common/screen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen.c,v 1.6 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: screen.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -146,7 +146,7 @@ screen_end(sp)
* If a created screen failed during initialization, it may not
* be linked into the chain.
*/
- if (sp->q.cqe_next != NULL)
+ if (CIRCLEQ_NEXT(sp, q) != NULL)
CIRCLEQ_REMOVE(&sp->gp->dq, sp, q);
/* The screen is no longer real. */
@@ -172,7 +172,7 @@ screen_end(sp)
}
/* Free any text input. */
- if (sp->tiq.cqh_first != NULL)
+ if (CIRCLEQ_FIRST(&sp->tiq) != NULL)
text_lfree(&sp->tiq);
/* Free alternate file name. */
@@ -217,16 +217,15 @@ screen_next(sp)
/* Try the display queue, without returning the current screen. */
gp = sp->gp;
- for (next = gp->dq.cqh_first;
- next != (void *)&gp->dq; next = next->q.cqe_next)
+ CIRCLEQ_FOREACH(next, &gp->dq, q)
if (next != sp)
break;
if (next != (void *)&gp->dq)
return (next);
/* Try the hidden queue; if found, move screen to the display queue. */
- if (gp->hq.cqh_first != (void *)&gp->hq) {
- next = gp->hq.cqh_first;
+ if (CIRCLEQ_FIRST(&gp->hq) != CIRCLEQ_END(&gp->hq)) {
+ next = CIRCLEQ_FIRST(&gp->hq);
CIRCLEQ_REMOVE(&gp->hq, next, q);
CIRCLEQ_INSERT_HEAD(&gp->dq, next, q);
return (next);
diff --git a/usr.bin/vi/common/seq.c b/usr.bin/vi/common/seq.c
index 6c4c05917ed..268c46c5b3d 100644
--- a/usr.bin/vi/common/seq.c
+++ b/usr.bin/vi/common/seq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: seq.c,v 1.6 2002/02/17 19:42:34 millert Exp $ */
+/* $OpenBSD: seq.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -202,8 +202,8 @@ seq_find(sp, lastqp, e_input, c_input, ilen, stype, ispartialp)
*/
if (ispartialp != NULL)
*ispartialp = 0;
- for (lqp = NULL, qp = sp->gp->seqq.lh_first;
- qp != NULL; lqp = qp, qp = qp->q.le_next) {
+ for (lqp = NULL, qp = LIST_FIRST(&sp->gp->seqq);
+ qp != NULL; lqp = qp, qp = LIST_NEXT(qp, q)) {
/*
* Fast checks on the first character and type, and then
* a real comparison.
@@ -268,7 +268,7 @@ seq_close(gp)
{
SEQ *qp;
- while ((qp = gp->seqq.lh_first) != NULL) {
+ while ((qp = LIST_FIRST(&gp->seqq)) != NULL) {
if (qp->name != NULL)
free(qp->name);
if (qp->input != NULL)
@@ -299,7 +299,7 @@ seq_dump(sp, stype, isname)
cnt = 0;
gp = sp->gp;
- for (qp = gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next) {
+ LIST_FOREACH(qp, &gp->seqq, q) {
if (stype != qp->stype || F_ISSET(qp, SEQ_FUNCMAP))
continue;
++cnt;
@@ -347,7 +347,7 @@ seq_save(sp, fp, prefix, stype)
int ch;
/* Write a sequence command for all keys the user defined. */
- for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next) {
+ LIST_FOREACH(qp, &sp->gp->seqq, q) {
if (stype != qp->stype || !F_ISSET(qp, SEQ_USERDEF))
continue;
if (prefix)
diff --git a/usr.bin/vi/ex/ex.c b/usr.bin/vi/ex/ex.c
index 0fda351ba1e..68d82bc8bb1 100644
--- a/usr.bin/vi/ex/ex.c
+++ b/usr.bin/vi/ex/ex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex.c,v 1.11 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: ex.c,v 1.12 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -69,7 +69,7 @@ ex(spp)
return (1);
/* Flush any saved messages. */
- while ((mp = gp->msgq.lh_first) != NULL) {
+ while ((mp = LIST_FIRST(&gp->msgq)) != NULL) {
gp->scr_msg(sp, mp->mtype, mp->buf, mp->len);
LIST_REMOVE(mp, q);
free(mp->buf);
@@ -122,7 +122,7 @@ ex(spp)
* If the user entered a single carriage return, send
* ex_cmd() a separator -- it discards single newlines.
*/
- tp = sp->tiq.cqh_first;
+ tp = CIRCLEQ_FIRST(&sp->tiq);
if (tp->len == 0) {
gp->excmd.cp = " "; /* __TK__ why not |? */
gp->excmd.clen = 1;
@@ -219,7 +219,7 @@ ex_cmd(sp)
* This means that *everything* must be resolved when we leave
* this function for any reason.
*/
-loop: ecp = gp->ecq.lh_first;
+loop: ecp = LIST_FIRST(&gp->ecq);
/* If we're reading a command from a file, set up error information. */
if (ecp->if_name != NULL) {
@@ -323,7 +323,7 @@ loop: ecp = gp->ecq.lh_first;
(!notempty || F_ISSET(sp, SC_VI) || F_ISSET(ecp, E_BLIGNORE))) {
if (ex_load(sp))
goto rfail;
- ecp = gp->ecq.lh_first;
+ ecp = LIST_FIRST(&gp->ecq);
if (ecp->clen == 0)
goto rsuccess;
goto loop;
@@ -1529,8 +1529,7 @@ addr_verify:
*/
if (F_ISSET(sp, SC_EXIT | SC_EXIT_FORCE | SC_FSWITCH | SC_SSWITCH)) {
at_found = gv_found = 0;
- for (ecp = sp->gp->ecq.lh_first;
- ecp != NULL; ecp = ecp->q.le_next)
+ LIST_FOREACH(ecp, &sp->gp->ecq, q)
switch (ecp->agv_flags) {
case 0:
case AGV_AT_NORANGE:
@@ -1582,7 +1581,7 @@ err: /*
break;
}
}
- if (ecp->save_cmdlen != 0 || gp->ecq.lh_first != &gp->excmd) {
+ if (ecp->save_cmdlen != 0 || LIST_FIRST(&gp->ecq) != &gp->excmd) {
discard: msgq(sp, M_BERR,
"092|Ex command failed: pending commands discarded");
ex_discard(sp);
@@ -2083,7 +2082,7 @@ ex_load(sp)
* but discard any allocated source name, we've returned to
* the beginning of the command stack.
*/
- if ((ecp = gp->ecq.lh_first) == &gp->excmd) {
+ if ((ecp = LIST_FIRST(&gp->ecq)) == &gp->excmd) {
if (F_ISSET(ecp, E_NAMEDISCARD)) {
free(ecp->if_name);
ecp->if_name = NULL;
@@ -2107,7 +2106,7 @@ ex_load(sp)
*/
if (FL_ISSET(ecp->agv_flags, AGV_ALL)) {
/* Discard any exhausted ranges. */
- while ((rp = ecp->rq.cqh_first) != (void *)&ecp->rq)
+ while ((rp = CIRCLEQ_FIRST(&ecp->rq)) != (void *)&ecp->rq)
if (rp->start > rp->stop) {
CIRCLEQ_REMOVE(&ecp->rq, rp, q);
free(rp);
@@ -2169,9 +2168,9 @@ ex_discard(sp)
* We know the first command can't be an AGV command, so we don't
* process it specially. We do, however, nail the command itself.
*/
- for (gp = sp->gp; (ecp = gp->ecq.lh_first) != &gp->excmd;) {
+ for (gp = sp->gp; (ecp = LIST_FIRST(&gp->ecq)) != &gp->excmd;) {
if (FL_ISSET(ecp->agv_flags, AGV_ALL)) {
- while ((rp = ecp->rq.cqh_first) != (void *)&ecp->rq) {
+ while ((rp = CIRCLEQ_FIRST(&ecp->rq)) != CIRCLEQ_END(&ecp->rq)) {
CIRCLEQ_REMOVE(&ecp->rq, rp, q);
free(rp);
}
@@ -2180,7 +2179,7 @@ ex_discard(sp)
LIST_REMOVE(ecp, q);
free(ecp);
}
- gp->ecq.lh_first->clen = 0;
+ LIST_FIRST(&gp->ecq)->clen = 0;
return (0);
}
diff --git a/usr.bin/vi/ex/ex_append.c b/usr.bin/vi/ex/ex_append.c
index 88e2a8c5344..1016d319c5d 100644
--- a/usr.bin/vi/ex/ex_append.c
+++ b/usr.bin/vi/ex/ex_append.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_append.c,v 1.6 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: ex_append.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -262,8 +262,8 @@ ex_aci(sp, cmdp, cmd)
if (ex_txt(sp, &tiq, 0, flags))
return (1);
- for (cnt = 0, tp = tiq.cqh_first;
- tp != (TEXT *)&tiq; ++cnt, tp = tp->q.cqe_next)
+ for (cnt = 0, tp = CIRCLEQ_FIRST(&tiq);
+ tp != (TEXT *)&tiq; ++cnt, tp = CIRCLEQ_NEXT(tp, q))
if (db_append(sp, 1, lno++, tp->lb, tp->len))
return (1);
diff --git a/usr.bin/vi/ex/ex_at.c b/usr.bin/vi/ex/ex_at.c
index ec51fb28dc1..71ce279f696 100644
--- a/usr.bin/vi/ex/ex_at.c
+++ b/usr.bin/vi/ex/ex_at.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_at.c,v 1.6 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: ex_at.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -106,8 +106,8 @@ ex_at(sp, cmdp)
* Build two copies of the command. We need two copies because the
* ex parser may step on the command string when it's parsing it.
*/
- for (len = 0, tp = cbp->textq.cqh_last;
- tp != (void *)&cbp->textq; tp = tp->q.cqe_prev)
+ for (len = 0, tp = CIRCLEQ_LAST(&cbp->textq);
+ tp != CIRCLEQ_END(&cbp->textq); tp = CIRCLEQ_PREV(tp, q))
len += tp->len + 1;
MALLOC_RET(sp, ecp->cp, char *, len * 2);
@@ -116,8 +116,8 @@ ex_at(sp, cmdp)
ecp->cp[len] = '\0';
/* Copy the buffer into the command space. */
- for (p = ecp->cp + len, tp = cbp->textq.cqh_last;
- tp != (void *)&cbp->textq; tp = tp->q.cqe_prev) {
+ for (p = ecp->cp + len, tp = CIRCLEQ_LAST(&cbp->textq);
+ tp != CIRCLEQ_END(&cbp->textq); tp = CIRCLEQ_PREV(tp, q)) {
memcpy(p, tp->lb, tp->len);
p += tp->len;
*p++ = '\n';
diff --git a/usr.bin/vi/ex/ex_cscope.c b/usr.bin/vi/ex/ex_cscope.c
index bdd11124079..83b5ca5a3dd 100644
--- a/usr.bin/vi/ex/ex_cscope.c
+++ b/usr.bin/vi/ex/ex_cscope.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_cscope.c,v 1.10 2003/07/09 20:01:31 millert Exp $ */
+/* $OpenBSD: ex_cscope.c,v 1.11 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1994, 1996
@@ -447,7 +447,7 @@ cscope_find(sp, cmdp, pattern)
exp = EXP(sp);
/* Check for connections. */
- if (exp->cscq.lh_first == NULL) {
+ if (LIST_FIRST(&exp->cscq) == NULL) {
msgq(sp, M_ERR, "310|No cscope connections running");
return (1);
}
@@ -459,7 +459,7 @@ cscope_find(sp, cmdp, pattern)
*/
rtp = NULL;
rtqp = NULL;
- if (exp->tq.cqh_first == (void *)&exp->tq) {
+ if (CIRCLEQ_FIRST(&exp->tq) == CIRCLEQ_END(&exp->tq)) {
/* Initialize the `local context' tag queue structure. */
CALLOC_GOTO(sp, rtqp, TAGQ *, 1, sizeof(TAGQ));
CIRCLEQ_INIT(&rtqp->tagq);
@@ -485,9 +485,9 @@ cscope_find(sp, cmdp, pattern)
/* Search all open connections for a match. */
matches = 0;
- for (csc = exp->cscq.lh_first; csc != NULL; csc = csc_next) {
+ for (csc = LIST_FIRST(&exp->cscq); csc != NULL; csc = csc_next) {
/* Copy csc->q.lh_next here in case csc is killed. */
- csc_next = csc->q.le_next;
+ csc_next = LIST_NEXT(csc, q);
/*
* Send the command to the cscope program. (We skip the
@@ -512,7 +512,7 @@ cscope_find(sp, cmdp, pattern)
return (0);
}
- tqp->current = tqp->tagq.cqh_first;
+ tqp->current = CIRCLEQ_FIRST(&tqp->tagq);
/* Try to switch to the first tag. */
force = FL_ISSET(cmdp->iflags, E_C_FORCE);
@@ -532,10 +532,10 @@ cscope_find(sp, cmdp, pattern)
* in place, so we can pop all the way back to the current mark.
* Note, it doesn't point to much of anything, it's a placeholder.
*/
- if (exp->tq.cqh_first == (void *)&exp->tq) {
+ if (CIRCLEQ_FIRST(&exp->tq) == CIRCLEQ_END(&exp->tq)) {
CIRCLEQ_INSERT_HEAD(&exp->tq, rtqp, q);
} else
- rtqp = exp->tq.cqh_first;
+ rtqp = CIRCLEQ_FIRST(&exp->tq);
/* Link the current TAGQ structure into place. */
CIRCLEQ_INSERT_HEAD(&exp->tq, tqp, q);
@@ -624,8 +624,8 @@ usage: (void)csc_help(sp, "find");
if (p[0] == '"' && p[1] != '\0' && p[2] == '\0')
CBNAME(sp, cbp, p[1]);
if (cbp != NULL) {
- p = cbp->textq.cqh_first->lb;
- tlen = cbp->textq.cqh_first->len;
+ p = CIRCLEQ_FIRST(&cbp->textq)->lb;
+ tlen = CIRCLEQ_FIRST(&cbp->textq)->len;
} else
tlen = strlen(p);
@@ -877,8 +877,8 @@ terminate(sp, csc, n)
if (csc == NULL) {
if (n < 1)
goto badno;
- for (i = 1, csc = exp->cscq.lh_first;
- csc != NULL; csc = csc->q.le_next, i++)
+ for (i = 1, csc = LIST_FIRST(&exp->cscq);
+ csc != NULL; csc = LIST_NEXT(csc, q), i++)
if (i == n)
break;
if (csc == NULL) {
@@ -923,7 +923,7 @@ cscope_reset(sp, cmdp, notusedp)
{
EX_PRIVATE *exp;
- for (exp = EXP(sp); exp->cscq.lh_first != NULL;)
+ for (exp = EXP(sp); LIST_FIRST(&exp->cscq) != NULL;)
if (cscope_kill(sp, cmdp, "1"))
return (1);
return (0);
@@ -944,12 +944,12 @@ cscope_display(sp)
int i;
exp = EXP(sp);
- if (exp->cscq.lh_first == NULL) {
+ if (LIST_FIRST(&exp->cscq) == NULL) {
ex_printf(sp, "No cscope connections.\n");
return (0);
}
for (i = 1,
- csc = exp->cscq.lh_first; csc != NULL; ++i, csc = csc->q.le_next)
+ csc = LIST_FIRST(&exp->cscq); csc != NULL; ++i, csc = LIST_NEXT(csc, q))
ex_printf(sp,
"%2d %s (process %ld)\n", i, csc->dname, (long)csc->pid);
return (0);
diff --git a/usr.bin/vi/ex/ex_display.c b/usr.bin/vi/ex/ex_display.c
index 64b9333bca8..13ebe8af77d 100644
--- a/usr.bin/vi/ex/ex_display.c
+++ b/usr.bin/vi/ex/ex_display.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_display.c,v 1.4 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: ex_display.c,v 1.5 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -87,25 +87,25 @@ bdisplay(sp)
{
CB *cbp;
- if (sp->gp->cutq.lh_first == NULL && sp->gp->dcbp == NULL) {
+ if (LIST_FIRST(&sp->gp->cutq) == NULL && sp->gp->dcbp == NULL) {
msgq(sp, M_INFO, "123|No cut buffers to display");
return (0);
}
/* Display regular cut buffers. */
- for (cbp = sp->gp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
+ LIST_FOREACH(cbp, &sp->gp->cutq, q) {
if (isdigit(cbp->name))
continue;
- if (cbp->textq.cqh_first != (void *)&cbp->textq)
+ if (CIRCLEQ_FIRST(&cbp->textq) != CIRCLEQ_END(&cbp->textq))
db(sp, cbp, NULL);
if (INTERRUPTED(sp))
return (0);
}
/* Display numbered buffers. */
- for (cbp = sp->gp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
+ LIST_FOREACH(cbp, &sp->gp->cutq, q) {
if (!isdigit(cbp->name))
continue;
- if (cbp->textq.cqh_first != (void *)&cbp->textq)
+ if (CIRCLEQ_FIRST(&cbp->textq) != CIRCLEQ_END(&cbp->textq))
db(sp, cbp, NULL);
if (INTERRUPTED(sp))
return (0);
@@ -135,8 +135,7 @@ db(sp, cbp, name)
(void)ex_printf(sp, "********** %s%s\n",
name == NULL ? KEY_NAME(sp, cbp->name) : name,
F_ISSET(cbp, CB_LMODE) ? " (line mode)" : " (character mode)");
- for (tp = cbp->textq.cqh_first;
- tp != (void *)&cbp->textq; tp = tp->q.cqe_next) {
+ CIRCLEQ_FOREACH(tp, &cbp->textq, q) {
for (len = tp->len, p = tp->lb; len--; ++p) {
(void)ex_puts(sp, KEY_NAME(sp, *p));
if (INTERRUPTED(sp))
diff --git a/usr.bin/vi/ex/ex_global.c b/usr.bin/vi/ex/ex_global.c
index eae27259fcb..8c55c211d8b 100644
--- a/usr.bin/vi/ex/ex_global.c
+++ b/usr.bin/vi/ex/ex_global.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_global.c,v 1.6 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: ex_global.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -274,11 +274,12 @@ ex_g_insdel(sp, op, lno)
if (op == LINE_RESET)
return (0);
- for (ecp = sp->gp->ecq.lh_first; ecp != NULL; ecp = ecp->q.le_next) {
+ LIST_FOREACH(ecp, &sp->gp->ecq, q) {
if (!FL_ISSET(ecp->agv_flags, AGV_AT | AGV_GLOBAL | AGV_V))
continue;
- for (rp = ecp->rq.cqh_first; rp != (void *)&ecp->rq; rp = nrp) {
- nrp = rp->q.cqe_next;
+ for (rp = CIRCLEQ_FIRST(&ecp->rq); rp != CIRCLEQ_END(&ecp->rq);
+ rp = nrp) {
+ nrp = CIRCLEQ_NEXT(rp, q);
/* If range less than the line, ignore it. */
if (rp->stop < lno)
diff --git a/usr.bin/vi/ex/ex_move.c b/usr.bin/vi/ex/ex_move.c
index be901fcf888..5155f4889db 100644
--- a/usr.bin/vi/ex/ex_move.c
+++ b/usr.bin/vi/ex/ex_move.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_move.c,v 1.6 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: ex_move.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -128,7 +128,7 @@ ex_move(sp, cmdp)
/* Log the old positions of the marks. */
mark_reset = 0;
- for (lmp = sp->ep->marks.lh_first; lmp != NULL; lmp = lmp->q.le_next)
+ LIST_FOREACH(lmp, &sp->ep->marks, q)
if (lmp->name != ABSMARK1 &&
lmp->lno >= fl && lmp->lno <= tl) {
mark_reset = 1;
@@ -152,8 +152,7 @@ ex_move(sp, cmdp)
if (db_append(sp, 1, tl, bp, len))
return (1);
if (mark_reset)
- for (lmp = sp->ep->marks.lh_first;
- lmp != NULL; lmp = lmp->q.le_next)
+ LIST_FOREACH(lmp, &sp->ep->marks, q)
if (lmp->name != ABSMARK1 &&
lmp->lno == fl)
lmp->lno = tl + 1;
@@ -171,8 +170,7 @@ ex_move(sp, cmdp)
if (db_append(sp, 1, tl++, bp, len))
return (1);
if (mark_reset)
- for (lmp = sp->ep->marks.lh_first;
- lmp != NULL; lmp = lmp->q.le_next)
+ LIST_FOREACH(lmp, &sp->ep->marks, q)
if (lmp->name != ABSMARK1 &&
lmp->lno == fl)
lmp->lno = tl;
@@ -188,8 +186,7 @@ ex_move(sp, cmdp)
/* Log the new positions of the marks. */
if (mark_reset)
- for (lmp = sp->ep->marks.lh_first;
- lmp != NULL; lmp = lmp->q.le_next)
+ LIST_FOREACH(lmp, &sp->ep->marks, q)
if (lmp->name != ABSMARK1 &&
lmp->lno >= mfl && lmp->lno <= mtl)
(void)log_mark(sp, lmp);
diff --git a/usr.bin/vi/ex/ex_screen.c b/usr.bin/vi/ex/ex_screen.c
index 70361d936cf..1684fef2b5f 100644
--- a/usr.bin/vi/ex/ex_screen.c
+++ b/usr.bin/vi/ex/ex_screen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_screen.c,v 1.5 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: ex_screen.c,v 1.6 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -114,14 +114,14 @@ ex_sdisplay(sp)
int cnt, col, len, sep;
gp = sp->gp;
- if ((tsp = gp->hq.cqh_first) == (void *)&gp->hq) {
+ if ((tsp = CIRCLEQ_FIRST(&gp->hq)) == CIRCLEQ_END(&gp->hq)) {
msgq(sp, M_INFO, "149|No background screens to display");
return (0);
}
col = len = sep = 0;
for (cnt = 1; tsp != (void *)&gp->hq && !INTERRUPTED(sp);
- tsp = tsp->q.cqe_next) {
+ tsp = CIRCLEQ_NEXT(tsp, q)) {
col += len = strlen(tsp->frp->name) + sep;
if (col >= sp->cols - 1) {
col = len;
diff --git a/usr.bin/vi/ex/ex_script.c b/usr.bin/vi/ex/ex_script.c
index 50692c2899e..a98bc633fa1 100644
--- a/usr.bin/vi/ex/ex_script.c
+++ b/usr.bin/vi/ex/ex_script.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_script.c,v 1.11 2003/09/02 22:44:06 dhartmei Exp $ */
+/* $OpenBSD: ex_script.c,v 1.12 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -385,7 +385,7 @@ sscr_input(sp)
/* Allocate space for rdfd. */
maxfd = STDIN_FILENO;
- for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
+ CIRCLEQ_FOREACH(sp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT) && sp->script->sh_master > maxfd)
maxfd = sp->script->sh_master;
rdfd = (fd_set *)malloc(howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
@@ -399,7 +399,7 @@ loop: memset(rdfd, 0, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
tv.tv_usec = 0;
/* Set up the input mask. */
- for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
+ CIRCLEQ_FOREACH(sp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT))
FD_SET(sp->script->sh_master, rdfd);
@@ -417,7 +417,7 @@ loop: memset(rdfd, 0, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
}
/* Read the input. */
- for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
+ CIRCLEQ_FOREACH(sp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT) &&
FD_ISSET(sp->script->sh_master, rdfd) && sscr_insert(sp)) {
free(rdfd);
@@ -626,7 +626,7 @@ sscr_check(sp)
GS *gp;
gp = sp->gp;
- for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
+ CIRCLEQ_FOREACH(sp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT)) {
F_SET(gp, G_SCRWIN);
return;
diff --git a/usr.bin/vi/ex/ex_subst.c b/usr.bin/vi/ex/ex_subst.c
index bb10bcea575..454f1d2f85e 100644
--- a/usr.bin/vi/ex/ex_subst.c
+++ b/usr.bin/vi/ex/ex_subst.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_subst.c,v 1.12 2002/02/17 19:42:34 millert Exp $ */
+/* $OpenBSD: ex_subst.c,v 1.13 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -662,7 +662,7 @@ nextmatch: match[0].rm_so = 0;
goto lquit;
if (ex_txt(sp, &tiq, 0, TXT_CR))
goto err;
- ev.e_c = tiq.cqh_first->lb[0];
+ ev.e_c = CIRCLEQ_FIRST(&tiq)->lb[0];
}
switch (ev.e_c) {
diff --git a/usr.bin/vi/ex/ex_tag.c b/usr.bin/vi/ex/ex_tag.c
index 21188ed30f2..56022d9b051 100644
--- a/usr.bin/vi/ex/ex_tag.c
+++ b/usr.bin/vi/ex/ex_tag.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_tag.c,v 1.10 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: ex_tag.c,v 1.11 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -149,7 +149,7 @@ ex_tag_push(sp, cmdp)
*/
rtp = NULL;
rtqp = NULL;
- if (exp->tq.cqh_first == (void *)&exp->tq) {
+ if (CIRCLEQ_FIRST(&exp->tq) == CIRCLEQ_END(&exp->tq)) {
/* Initialize the `local context' tag queue structure. */
CALLOC_GOTO(sp, rtqp, TAGQ *, 1, sizeof(TAGQ));
CIRCLEQ_INIT(&rtqp->tagq);
@@ -174,14 +174,14 @@ ex_tag_push(sp, cmdp)
/* Try to switch to the tag. */
force = FL_ISSET(cmdp->iflags, E_C_FORCE);
if (F_ISSET(cmdp, E_NEWSCREEN)) {
- if (ex_tag_Nswitch(sp, tqp->tagq.cqh_first, force))
+ if (ex_tag_Nswitch(sp, CIRCLEQ_FIRST(&tqp->tagq), force))
goto err;
/* Everything else gets done in the new screen. */
sp = sp->nextdisp;
exp = EXP(sp);
} else
- if (ex_tag_nswitch(sp, tqp->tagq.cqh_first, force))
+ if (ex_tag_nswitch(sp, CIRCLEQ_FIRST(&tqp->tagq), force))
goto err;
/*
@@ -189,10 +189,10 @@ ex_tag_push(sp, cmdp)
* in place, so we can pop all the way back to the current mark.
* Note, it doesn't point to much of anything, it's a placeholder.
*/
- if (exp->tq.cqh_first == (void *)&exp->tq) {
+ if (CIRCLEQ_FIRST(&exp->tq) == CIRCLEQ_END(&exp->tq)) {
CIRCLEQ_INSERT_HEAD(&exp->tq, rtqp, q);
} else
- rtqp = exp->tq.cqh_first;
+ rtqp = CIRCLEQ_FIRST(&exp->tq);
/* Link the new TAGQ structure into place. */
CIRCLEQ_INSERT_HEAD(&exp->tq, tqp, q);
@@ -246,11 +246,11 @@ ex_tag_next(sp, cmdp)
TAGQ *tqp;
exp = EXP(sp);
- if ((tqp = exp->tq.cqh_first) == (void *)&exp->tq) {
+ if ((tqp = CIRCLEQ_FIRST(&exp->tq)) == CIRCLEQ_END(&exp->tq)) {
tag_msg(sp, TAG_EMPTY, NULL);
return (1);
}
- if ((tp = tqp->current->q.cqe_next) == (void *)&tqp->tagq) {
+ if ((tp = CIRCLEQ_NEXT(tqp->current, q)) == CIRCLEQ_END(&tqp->tagq)) {
msgq(sp, M_ERR, "282|Already at the last tag of this group");
return (1);
}
@@ -281,11 +281,11 @@ ex_tag_prev(sp, cmdp)
TAGQ *tqp;
exp = EXP(sp);
- if ((tqp = exp->tq.cqh_first) == (void *)&exp->tq) {
+ if ((tqp = CIRCLEQ_FIRST(&exp->tq)) == CIRCLEQ_END(&exp->tq)) {
tag_msg(sp, TAG_EMPTY, NULL);
return (0);
}
- if ((tp = tqp->current->q.cqe_prev) == (void *)&tqp->tagq) {
+ if ((tp = CIRCLEQ_PREV(tqp->current, q)) == CIRCLEQ_END(&tqp->tagq)) {
msgq(sp, M_ERR, "255|Already at the first tag of this group");
return (1);
}
@@ -413,7 +413,7 @@ ex_tag_pop(sp, cmdp)
/* Check for an empty stack. */
exp = EXP(sp);
- if (exp->tq.cqh_first == (void *)&exp->tq) {
+ if (CIRCLEQ_FIRST(&exp->tq) == CIRCLEQ_END(&exp->tq)) {
tag_msg(sp, TAG_EMPTY, NULL);
return (1);
}
@@ -421,7 +421,7 @@ ex_tag_pop(sp, cmdp)
/* Find the last TAG structure that we're going to DISCARD! */
switch (cmdp->argc) {
case 0: /* Pop one tag. */
- dtqp = exp->tq.cqh_first;
+ dtqp = CIRCLEQ_FIRST(&exp->tq);
break;
case 1: /* Name or number. */
arg = cmdp->argv[0]->bp;
@@ -432,9 +432,9 @@ ex_tag_pop(sp, cmdp)
/* Number: pop that many queue entries. */
if (off < 1)
return (0);
- for (tqp = exp->tq.cqh_first;
- tqp != (void *)&exp->tq && --off > 1;
- tqp = tqp->q.cqe_next);
+ for (tqp = CIRCLEQ_FIRST(&exp->tq);
+ tqp != CIRCLEQ_END(&exp->tq) && --off > 1;
+ tqp = CIRCLEQ_NEXT(tqp, q));
if (tqp == (void *)&exp->tq) {
msgq(sp, M_ERR,
"159|Less than %s entries on the tags stack; use :display t[ags]",
@@ -446,11 +446,11 @@ ex_tag_pop(sp, cmdp)
/* File argument: pop to that queue entry. */
filearg: arglen = strlen(arg);
- for (tqp = exp->tq.cqh_first;
- tqp != (void *)&exp->tq;
- dtqp = tqp, tqp = tqp->q.cqe_next) {
+ for (tqp = CIRCLEQ_FIRST(&exp->tq);
+ tqp != CIRCLEQ_END(&exp->tq);
+ dtqp = tqp, tqp = CIRCLEQ_NEXT(tqp, q)) {
/* Don't pop to the current file. */
- if (tqp == exp->tq.cqh_first)
+ if (tqp == CIRCLEQ_FIRST(&exp->tq))
continue;
p = tqp->current->frp->name;
if ((t = strrchr(p, '/')) == NULL)
@@ -465,7 +465,7 @@ filearg: arglen = strlen(arg);
"160|No file %s on the tags stack to return to; use :display t[ags]");
return (1);
}
- if (tqp == exp->tq.cqh_first)
+ if (tqp == CIRCLEQ_FIRST(&exp->tq))
return (0);
break;
default:
@@ -491,14 +491,15 @@ ex_tag_top(sp, cmdp)
exp = EXP(sp);
/* Check for an empty stack. */
- if (exp->tq.cqh_first == (void *)&exp->tq) {
+ if (CIRCLEQ_FIRST(&exp->tq) == CIRCLEQ_END(&exp->tq)) {
tag_msg(sp, TAG_EMPTY, NULL);
return (1);
}
/* Return to the oldest information. */
return (tag_pop(sp,
- exp->tq.cqh_last->q.cqe_prev, FL_ISSET(cmdp->iflags, E_C_FORCE)));
+ CIRCLEQ_PREV(CIRCLEQ_LAST(&exp->tq), q),
+ FL_ISSET(cmdp->iflags, E_C_FORCE)));
}
/*
@@ -521,7 +522,7 @@ tag_pop(sp, dtqp, force)
* Update the cursor from the saved TAG information of the TAG
* structure we're moving to.
*/
- tp = dtqp->q.cqe_next->current;
+ tp = CIRCLEQ_NEXT(dtqp, q)->current;
if (tp->frp == sp->frp) {
sp->lno = tp->lno;
sp->cno = tp->cno;
@@ -540,7 +541,7 @@ tag_pop(sp, dtqp, force)
/* Pop entries off the queue up to and including dtqp. */
do {
- tqp = exp->tq.cqh_first;
+ tqp = CIRCLEQ_FIRST(&exp->tq);
if (tagq_free(sp, tqp))
return (0);
} while (tqp != dtqp);
@@ -549,8 +550,8 @@ tag_pop(sp, dtqp, force)
* If only a single tag left, we've returned to the first tag point,
* and the stack is now empty.
*/
- if (exp->tq.cqh_first->q.cqe_next == (void *)&exp->tq)
- tagq_free(sp, exp->tq.cqh_first);
+ if (CIRCLEQ_NEXT(CIRCLEQ_FIRST(&exp->tq), q) == CIRCLEQ_END(&exp->tq))
+ tagq_free(sp, CIRCLEQ_FIRST(&exp->tq));
return (0);
}
@@ -573,7 +574,7 @@ ex_tag_display(sp)
char *p, *sep;
exp = EXP(sp);
- if ((tqp = exp->tq.cqh_first) == (void *)&exp->tq) {
+ if ((tqp = CIRCLEQ_FIRST(&exp->tq)) == CIRCLEQ_END(&exp->tq)) {
tag_msg(sp, TAG_EMPTY, NULL);
return (0);
}
@@ -601,11 +602,10 @@ ex_tag_display(sp)
* Display the list of tags for each queue entry. The first entry
* is numbered, and the current tag entry has an asterisk appended.
*/
- for (cnt = 1, tqp = exp->tq.cqh_first; !INTERRUPTED(sp) &&
- tqp != (void *)&exp->tq; ++cnt, tqp = tqp->q.cqe_next)
- for (tp = tqp->tagq.cqh_first;
- tp != (void *)&tqp->tagq; tp = tp->q.cqe_next) {
- if (tp == tqp->tagq.cqh_first)
+ for (cnt = 1, tqp = CIRCLEQ_FIRST(&exp->tq); !INTERRUPTED(sp) &&
+ tqp != CIRCLEQ_END(&exp->tq); ++cnt, tqp = CIRCLEQ_NEXT(tqp, q))
+ CIRCLEQ_FOREACH(tp, &tqp->tagq, q) {
+ if (tp == CIRCLEQ_FIRST(&tqp->tagq))
(void)ex_printf(sp, "%2d ", cnt);
else
(void)ex_printf(sp, " ");
@@ -620,7 +620,7 @@ ex_tag_display(sp)
if (tqp->current == tp)
(void)ex_printf(sp, "*");
- if (tp == tqp->tagq.cqh_first && tqp->tag != NULL &&
+ if (tp == CIRCLEQ_FIRST(&tqp->tagq) && tqp->tag != NULL &&
(sp->cols - L_NAME) >= L_TAG + L_SPACE) {
len = strlen(tqp->tag);
if (len > sp->cols - (L_NAME + L_SPACE))
@@ -653,12 +653,10 @@ ex_tag_copy(orig, sp)
nexp = EXP(sp);
/* Copy tag queue and tags stack. */
- for (aqp = oexp->tq.cqh_first;
- aqp != (void *)&oexp->tq; aqp = aqp->q.cqe_next) {
+ CIRCLEQ_FOREACH(aqp, &oexp->tq, q) {
if (tagq_copy(sp, aqp, &tqp))
return (1);
- for (ap = aqp->tagq.cqh_first;
- ap != (void *)&aqp->tagq; ap = ap->q.cqe_next) {
+ CIRCLEQ_FOREACH(ap, &aqp->tagq, q) {
if (tag_copy(sp, ap, &tp))
return (1);
/* Set the current pointer. */
@@ -670,8 +668,7 @@ ex_tag_copy(orig, sp)
}
/* Copy list of tag files. */
- for (atfp = oexp->tagfq.tqh_first;
- atfp != NULL; atfp = atfp->q.tqe_next) {
+ TAILQ_FOREACH(atfp, &oexp->tagfq, q) {
if (tagf_copy(sp, atfp, &tfp))
return (1);
TAILQ_INSERT_TAIL(&nexp->tagfq, tfp, q);
@@ -797,7 +794,7 @@ tagq_free(sp, tqp)
TAG *tp;
exp = EXP(sp);
- while ((tp = tqp->tagq.cqh_first) != (void *)&tqp->tagq) {
+ while ((tp = CIRCLEQ_FIRST(&tqp->tagq)) != CIRCLEQ_END(&tqp->tagq)) {
CIRCLEQ_REMOVE(&tqp->tagq, tp, q);
free(tp);
}
@@ -806,7 +803,7 @@ tagq_free(sp, tqp)
* If allocated and then the user failed to switch files, the TAGQ
* structure was never attached to any list.
*/
- if (tqp->q.cqe_next != NULL)
+ if (CIRCLEQ_NEXT(tqp, q) != NULL)
CIRCLEQ_REMOVE(&exp->tq, tqp, q);
free(tqp);
return (0);
@@ -858,7 +855,7 @@ ex_tagf_alloc(sp, str)
/* Free current queue. */
exp = EXP(sp);
- while ((tfp = exp->tagfq.tqh_first) != NULL)
+ while ((tfp = TAILQ_FIRST(&exp->tagfq)) != NULL)
tagf_free(sp, tfp);
/* Create new queue. */
@@ -900,9 +897,9 @@ ex_tag_free(sp)
/* Free up tag information. */
exp = EXP(sp);
- while ((tqp = exp->tq.cqh_first) != (void *)&exp->tq)
+ while ((tqp = CIRCLEQ_FIRST(&exp->tq)) != CIRCLEQ_END(&exp->tq))
tagq_free(sp, tqp);
- while ((tfp = exp->tagfq.tqh_first) != NULL)
+ while ((tfp = TAILQ_FIRST(&exp->tagfq)) != NULL)
tagf_free(sp, tfp);
if (exp->tag_last != NULL)
free(exp->tag_last);
@@ -999,8 +996,8 @@ ctag_slist(sp, tag)
* Find the tag, only display missing file messages once, and
* then only if we didn't find the tag.
*/
- for (echk = 0,
- tfp = exp->tagfq.tqh_first; tfp != NULL; tfp = tfp->q.tqe_next)
+ echk = 0;
+ TAILQ_FOREACH(tfp, &exp->tagfq, q)
if (ctag_sfile(sp, tfp, tqp, tag)) {
echk = 1;
F_SET(tfp, TAGF_ERR);
@@ -1008,11 +1005,10 @@ ctag_slist(sp, tag)
F_CLR(tfp, TAGF_ERR | TAGF_ERR_WARN);
/* Check to see if we found anything. */
- if (tqp->tagq.cqh_first == (void *)&tqp->tagq) {
+ if (CIRCLEQ_FIRST(&tqp->tagq) == CIRCLEQ_END(&tqp->tagq)) {
msgq_str(sp, M_ERR, tag, "162|%s: tag not found");
if (echk)
- for (tfp = exp->tagfq.tqh_first;
- tfp != NULL; tfp = tfp->q.tqe_next)
+ TAILQ_FOREACH(tfp, &exp->tagfq, q)
if (F_ISSET(tfp, TAGF_ERR) &&
!F_ISSET(tfp, TAGF_ERR_WARN)) {
errno = tfp->errnum;
@@ -1023,7 +1019,7 @@ ctag_slist(sp, tag)
return (NULL);
}
- tqp->current = tqp->tagq.cqh_first;
+ tqp->current = CIRCLEQ_FIRST(&tqp->tagq);
return (tqp);
alloc_err:
diff --git a/usr.bin/vi/ex/ex_txt.c b/usr.bin/vi/ex/ex_txt.c
index 84f6fac05fc..b13c5990da0 100644
--- a/usr.bin/vi/ex/ex_txt.c
+++ b/usr.bin/vi/ex/ex_txt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_txt.c,v 1.7 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: ex_txt.c,v 1.8 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -74,9 +74,9 @@ ex_txt(sp, tiqh, prompt, flags)
* last one if it's big enough. (All TEXT bookkeeping fields default
* to 0 -- text_init() handles this.)
*/
- if (tiqh->cqh_first != (void *)tiqh) {
- tp = tiqh->cqh_first;
- if (tp->q.cqe_next != (void *)tiqh || tp->lb_len < 32) {
+ if (CIRCLEQ_FIRST(tiqh) != CIRCLEQ_END(tiqh)) {
+ tp = CIRCLEQ_FIRST(tiqh);
+ if (CIRCLEQ_NEXT(tp, q) != CIRCLEQ_END(tiqh) || tp->lb_len < 32) {
text_lfree(tiqh);
goto newtp;
}
diff --git a/usr.bin/vi/vi/v_at.c b/usr.bin/vi/vi/v_at.c
index 10674d2d893..62a65cc1999 100644
--- a/usr.bin/vi/vi/v_at.c
+++ b/usr.bin/vi/vi/v_at.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: v_at.c,v 1.4 2002/02/16 21:27:58 millert Exp $ */
+/* $OpenBSD: v_at.c,v 1.5 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -89,10 +89,9 @@ v_at(sp, vp)
* together. We don't get this right; I'm waiting for the new DB
* logging code to be available.
*/
- for (tp = cbp->textq.cqh_last;
- tp != (void *)&cbp->textq; tp = tp->q.cqe_prev)
+ CIRCLEQ_FOREACH_REVERSE(tp, &cbp->textq, q)
if ((F_ISSET(cbp, CB_LMODE) ||
- tp->q.cqe_next != (void *)&cbp->textq) &&
+ CIRCLEQ_NEXT(tp, q) != CIRCLEQ_END(&cbp->textq)) &&
v_event_push(sp, NULL, "\n", 1, 0) ||
v_event_push(sp, NULL, tp->lb, tp->len, 0))
return (1);
diff --git a/usr.bin/vi/vi/v_ex.c b/usr.bin/vi/vi/v_ex.c
index 42fbb6cbb94..325e0a1d917 100644
--- a/usr.bin/vi/vi/v_ex.c
+++ b/usr.bin/vi/vi/v_ex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: v_ex.c,v 1.5 2002/02/16 21:27:58 millert Exp $ */
+/* $OpenBSD: v_ex.c,v 1.6 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -308,7 +308,7 @@ v_filter(sp, vp)
* Entering <escape> on an empty line was historically an error,
* this implementation doesn't bother.
*/
- tp = sp->tiq.cqh_first;
+ tp = CIRCLEQ_FIRST(&sp->tiq);
if (tp->term != TERM_OK) {
vp->m_final.lno = sp->lno;
vp->m_final.cno = sp->cno;
@@ -407,7 +407,7 @@ v_ex(sp, vp)
if (v_tcmd(sp, vp, ':',
TXT_BS | TXT_CEDIT | TXT_FILEC | TXT_PROMPT))
return (1);
- tp = sp->tiq.cqh_first;
+ tp = CIRCLEQ_FIRST(&sp->tiq);
/*
* If the user entered a single <esc>, they want to
diff --git a/usr.bin/vi/vi/v_screen.c b/usr.bin/vi/vi/v_screen.c
index e6bf6d99bb8..b28cb7d1f5c 100644
--- a/usr.bin/vi/vi/v_screen.c
+++ b/usr.bin/vi/vi/v_screen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: v_screen.c,v 1.4 2002/02/16 21:27:58 millert Exp $ */
+/* $OpenBSD: v_screen.c,v 1.5 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -53,13 +53,13 @@ v_screen(sp, vp)
* Try for the next lower screen, or, go back to the first
* screen on the stack.
*/
- if (sp->q.cqe_next != (void *)&sp->gp->dq)
- sp->nextdisp = sp->q.cqe_next;
- else if (sp->gp->dq.cqh_first == sp) {
+ if (CIRCLEQ_NEXT(sp, q) != CIRCLEQ_END(&sp->gp->dq))
+ sp->nextdisp = CIRCLEQ_NEXT(sp, q);
+ else if (CIRCLEQ_FIRST(&sp->gp->dq) == sp) {
msgq(sp, M_ERR, "187|No other screen to switch to");
return (1);
} else
- sp->nextdisp = sp->gp->dq.cqh_first;
+ sp->nextdisp = CIRCLEQ_FIRST(&sp->gp->dq);
F_SET(sp->nextdisp, SC_STATUS);
F_SET(sp, SC_SSWITCH | SC_STATUS);
diff --git a/usr.bin/vi/vi/v_search.c b/usr.bin/vi/vi/v_search.c
index 2b497d77527..1cb1a24b819 100644
--- a/usr.bin/vi/vi/v_search.c
+++ b/usr.bin/vi/vi/v_search.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: v_search.c,v 1.7 2002/02/16 21:27:58 millert Exp $ */
+/* $OpenBSD: v_search.c,v 1.8 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -95,7 +95,7 @@ v_exaddr(sp, vp, dir)
(O_ISSET(sp, O_SEARCHINCR) ? TXT_SEARCHINCR : 0)))
return (1);
- tp = sp->tiq.cqh_first;
+ tp = CIRCLEQ_FIRST(&sp->tiq);
/* If the user backspaced over the prompt, do nothing. */
if (tp->term == TERM_BS)
diff --git a/usr.bin/vi/vi/v_txt.c b/usr.bin/vi/vi/v_txt.c
index 29948fb1a6f..f73fd7ba0ee 100644
--- a/usr.bin/vi/vi/v_txt.c
+++ b/usr.bin/vi/vi/v_txt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: v_txt.c,v 1.15 2005/01/08 05:20:34 pvalchev Exp $ */
+/* $OpenBSD: v_txt.c,v 1.16 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -301,9 +301,9 @@ v_txt(sp, vp, tm, lp, len, prompt, ai_line, rcount, flags)
* copy it into the TEXT buffer.
*/
tiqh = &sp->tiq;
- if (tiqh->cqh_first != (void *)tiqh) {
- tp = tiqh->cqh_first;
- if (tp->q.cqe_next != (void *)tiqh || tp->lb_len < len + 32) {
+ if (CIRCLEQ_FIRST(tiqh) != CIRCLEQ_END(tiqh)) {
+ tp = CIRCLEQ_FIRST(tiqh);
+ if (CIRCLEQ_NEXT(tp, q) != CIRCLEQ_END(tiqh) || tp->lb_len < len + 32) {
text_lfree(tiqh);
goto newtp;
}
@@ -1835,7 +1835,7 @@ txt_backup(sp, tiqh, tp, flagsp)
TEXT *ntp;
/* Get a handle on the previous TEXT structure. */
- if ((ntp = tp->q.cqe_prev) == (void *)tiqh) {
+ if ((ntp = CIRCLEQ_PREV(tp, q)) == CIRCLEQ_END(tiqh)) {
if (!FL_ISSET(*flagsp, TXT_REPLAY))
msgq(sp, M_BERR,
"193|Already at the beginning of the insert");
@@ -2342,7 +2342,7 @@ txt_err(sp, tiqh)
* We depend on at least one line number being set in the text
* chain.
*/
- for (lno = tiqh->cqh_first->lno;
+ for (lno = CIRCLEQ_FIRST(tiqh)->lno;
!db_exist(sp, lno) && lno > 0; --lno);
sp->lno = lno == 0 ? 1 : lno;
@@ -2700,7 +2700,7 @@ txt_resolve(sp, tiqh, flags)
* about the line will be wrong.
*/
vip = VIP(sp);
- tp = tiqh->cqh_first;
+ tp = CIRCLEQ_FIRST(tiqh);
if (LF_ISSET(TXT_AUTOINDENT))
txt_ai_resolve(sp, tp, &changed);
@@ -2710,7 +2710,7 @@ txt_resolve(sp, tiqh, flags)
changed && vs_change(sp, tp->lno, LINE_RESET))
return (1);
- for (lno = tp->lno; (tp = tp->q.cqe_next) != (void *)&sp->tiq; ++lno) {
+ for (lno = tp->lno; (tp = CIRCLEQ_NEXT(tp, q)) != (void *)&sp->tiq; ++lno) {
if (LF_ISSET(TXT_AUTOINDENT))
txt_ai_resolve(sp, tp, &changed);
else
@@ -2909,9 +2909,9 @@ txt_Rresolve(sp, tiqh, tp, orig_len)
* Calculate how many characters the user has entered,
* plus the blanks erased by <carriage-return>/<newline>s.
*/
- for (ttp = tiqh->cqh_first, input_len = 0;;) {
+ for (ttp = CIRCLEQ_FIRST(tiqh), input_len = 0;;) {
input_len += ttp == tp ? tp->cno : ttp->len + ttp->R_erase;
- if ((ttp = ttp->q.cqe_next) == (void *)&sp->tiq)
+ if ((ttp = CIRCLEQ_NEXT(ttp, q)) == CIRCLEQ_END(&sp->tiq))
break;
}
@@ -2932,7 +2932,7 @@ txt_Rresolve(sp, tiqh, tp, orig_len)
if (input_len < orig_len) {
retain = MIN(tp->owrite, orig_len - input_len);
if (db_get(sp,
- tiqh->cqh_first->lno, DBG_FATAL | DBG_NOCACHE, &p, NULL))
+ CIRCLEQ_FIRST(tiqh)->lno, DBG_FATAL | DBG_NOCACHE, &p, NULL))
return;
memcpy(tp->lb + tp->cno, p + input_len, retain);
tp->len -= tp->owrite - retain;
diff --git a/usr.bin/vi/vi/vi.c b/usr.bin/vi/vi/vi.c
index ebf121ec4e8..d67e2a93215 100644
--- a/usr.bin/vi/vi/vi.c
+++ b/usr.bin/vi/vi/vi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vi.c,v 1.10 2005/01/08 05:22:25 pvalchev Exp $ */
+/* $OpenBSD: vi.c,v 1.11 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -1012,7 +1012,7 @@ v_dtoh(sp)
/* Move all screens to the hidden queue, tossing screen maps. */
for (hidden = 0, gp = sp->gp;
- (tsp = gp->dq.cqh_first) != (void *)&gp->dq; ++hidden) {
+ (tsp = CIRCLEQ_FIRST(&gp->dq)) != CIRCLEQ_END(&gp->dq); ++hidden) {
if (_HMAP(tsp) != NULL) {
free(_HMAP(tsp));
_HMAP(tsp) = NULL;
diff --git a/usr.bin/vi/vi/vi.h b/usr.bin/vi/vi/vi.h
index 71233457bef..8e90e6af3c1 100644
--- a/usr.bin/vi/vi/vi.h
+++ b/usr.bin/vi/vi/vi.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vi.h,v 1.4 2002/02/16 21:27:58 millert Exp $ */
+/* $OpenBSD: vi.h,v 1.5 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -355,8 +355,8 @@ typedef struct _vi_private {
/* If more than one screen being shown. */
#define IS_SPLIT(sp) \
- ((sp)->q.cqe_next != (void *)&(sp)->gp->dq || \
- (sp)->q.cqe_prev != (void *)&(sp)->gp->dq)
+ (CIRCLEQ_NEXT((sp), q) != (void *)&(sp)->gp->dq || \
+ CIRCLEQ_PREV((sp), q) != (void *)&(sp)->gp->dq)
/* Screen adjustment operations. */
typedef enum { A_DECREASE, A_INCREASE, A_SET } adj_t;
diff --git a/usr.bin/vi/vi/vs_msg.c b/usr.bin/vi/vi/vs_msg.c
index 8fe633f2c8c..6ac0236691b 100644
--- a/usr.bin/vi/vi/vs_msg.c
+++ b/usr.bin/vi/vi/vs_msg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vs_msg.c,v 1.7 2002/02/16 21:27:58 millert Exp $ */
+/* $OpenBSD: vs_msg.c,v 1.8 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -600,7 +600,7 @@ vs_ex_resolve(sp, continuep)
* If we're not the bottom of the split screen stack, the screen
* image itself is wrong, so redraw everything.
*/
- if (sp->q.cqe_next != (void *)&sp->gp->dq)
+ if (CIRCLEQ_NEXT(sp, q) != CIRCLEQ_END(&sp->gp->dq))
F_SET(sp, SC_SCR_REDRAW);
/* If ex changed the underlying file, the map itself is wrong. */
@@ -698,10 +698,10 @@ vs_resolve(sp, csp, forcewait)
* messages.) Once this is done, don't trust the cursor. That
* extra refresh screwed the pooch.
*/
- if (gp->msgq.lh_first != NULL) {
+ if (LIST_FIRST(&gp->msgq) != NULL) {
if (!F_ISSET(sp, SC_SCR_VI) && vs_refresh(sp, 1))
return (1);
- while ((mp = gp->msgq.lh_first) != NULL) {
+ while ((mp = LIST_FIRST(&gp->msgq)) != NULL) {
gp->scr_msg(sp, mp->mtype, mp->buf, mp->len);
LIST_REMOVE(mp, q);
free(mp->buf);
@@ -781,7 +781,7 @@ vs_scroll(sp, continuep, wtype)
(void)gp->scr_deleteln(sp);
/* If there are screens below us, push them back into place. */
- if (sp->q.cqe_next != (void *)&sp->gp->dq) {
+ if (CIRCLEQ_NEXT(sp, q) != CIRCLEQ_END(&sp->gp->dq)) {
(void)gp->scr_move(sp, LASTLINE(sp), 0);
(void)gp->scr_insertln(sp);
}
@@ -914,10 +914,10 @@ vs_msgsave(sp, mt, p, len)
mp_n->mtype = mt;
gp = sp->gp;
- if ((mp_c = gp->msgq.lh_first) == NULL) {
+ if ((mp_c = LIST_FIRST(&gp->msgq)) == NULL) {
LIST_INSERT_HEAD(&gp->msgq, mp_n, q);
} else {
- for (; mp_c->q.le_next != NULL; mp_c = mp_c->q.le_next);
+ for (; LIST_NEXT(mp_c, q) != NULL; mp_c = LIST_NEXT(mp_c, q));
LIST_INSERT_AFTER(mp_c, mp_n, q);
}
return;
diff --git a/usr.bin/vi/vi/vs_refresh.c b/usr.bin/vi/vi/vs_refresh.c
index 0a5c949014f..e842cc79dd0 100644
--- a/usr.bin/vi/vi/vs_refresh.c
+++ b/usr.bin/vi/vi/vs_refresh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vs_refresh.c,v 1.9 2002/02/16 21:27:58 millert Exp $ */
+/* $OpenBSD: vs_refresh.c,v 1.10 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -82,8 +82,7 @@ vs_refresh(sp, forcepaint)
* that we can find, including status lines.
*/
if (F_ISSET(sp, SC_SCR_REDRAW))
- for (tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
+ CIRCLEQ_FOREACH(tsp, &gp->dq, q)
if (tsp != sp)
F_SET(tsp, SC_SCR_REDRAW | SC_STATUS);
@@ -100,8 +99,7 @@ vs_refresh(sp, forcepaint)
priv_paint = VIP_CUR_INVALID | VIP_N_REFRESH;
if (O_ISSET(sp, O_NUMBER))
priv_paint |= VIP_N_RENUMBER;
- for (tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
+ CIRCLEQ_FOREACH(tsp, &gp->dq, q)
if (tsp != sp && !F_ISSET(tsp, SC_EXIT | SC_EXIT_FORCE) &&
(F_ISSET(tsp, pub_paint) ||
F_ISSET(VIP(tsp), priv_paint))) {
@@ -136,8 +134,8 @@ vs_refresh(sp, forcepaint)
* And, finally, if we updated any status lines, make sure the cursor
* gets back to where it belongs.
*/
- for (need_refresh = 0, tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
+ need_refresh = 0;
+ CIRCLEQ_FOREACH(tsp, &gp->dq, q)
if (F_ISSET(tsp, SC_STATUS)) {
need_refresh = 1;
vs_resolve(tsp, sp, 0);
diff --git a/usr.bin/vi/vi/vs_split.c b/usr.bin/vi/vi/vs_split.c
index f281b1a702a..0442e79ace3 100644
--- a/usr.bin/vi/vi/vs_split.c
+++ b/usr.bin/vi/vi/vs_split.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vs_split.c,v 1.7 2002/02/16 21:27:58 millert Exp $ */
+/* $OpenBSD: vs_split.c,v 1.8 2005/10/17 19:12:16 otto Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -223,11 +223,11 @@ vs_discard(sp, spp)
* they're the closest to the current screen. If that doesn't work,
* there was no screen to join.
*/
- if ((nsp = sp->q.cqe_prev) != (void *)&sp->gp->dq) {
+ if ((nsp = CIRCLEQ_PREV(sp, q)) != CIRCLEQ_END(&sp->gp->dq)) {
nsp->rows += sp->rows;
sp = nsp;
dir = FORWARD;
- } else if ((nsp = sp->q.cqe_next) != (void *)&sp->gp->dq) {
+ } else if ((nsp = CIRCLEQ_NEXT(sp, q)) != CIRCLEQ_END(&sp->gp->dq)) {
nsp->woff = sp->woff;
nsp->rows += sp->rows;
sp = nsp;
@@ -503,15 +503,15 @@ vs_resize(sp, count, adj)
s = sp;
if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count)
goto toosmall;
- if ((g = sp->q.cqe_prev) == (void *)&gp->dq) {
- if ((g = sp->q.cqe_next) == (void *)&gp->dq)
+ if ((g = CIRCLEQ_PREV(sp, q)) == CIRCLEQ_END(&gp->dq)) {
+ if ((g = CIRCLEQ_NEXT(sp, q)) == CIRCLEQ_END(&gp->dq))
goto toobig;
g_off = -count;
} else
s_off = count;
} else {
g = sp;
- if ((s = sp->q.cqe_next) != (void *)&gp->dq)
+ if ((s = CIRCLEQ_NEXT(sp, q)) != CIRCLEQ_END(&gp->dq))
if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count)
s = NULL;
else
@@ -519,7 +519,7 @@ vs_resize(sp, count, adj)
else
s = NULL;
if (s == NULL) {
- if ((s = sp->q.cqe_prev) == (void *)&gp->dq) {
+ if ((s = CIRCLEQ_PREV(sp, q)) == CIRCLEQ_END(&gp->dq)) {
toobig: msgq(sp, M_BERR, adj == A_DECREASE ?
"227|The screen cannot shrink" :
"228|The screen cannot grow");
@@ -580,21 +580,19 @@ vs_getbg(sp, name)
/* If name is NULL, return the first background screen on the list. */
if (name == NULL) {
- nsp = gp->hq.cqh_first;
+ nsp = CIRCLEQ_FIRST(&gp->hq);
return (nsp == (void *)&gp->hq ? NULL : nsp);
}
/* Search for a full match. */
- for (nsp = gp->hq.cqh_first;
- nsp != (void *)&gp->hq; nsp = nsp->q.cqe_next)
+ CIRCLEQ_FOREACH(nsp, &gp->hq, q)
if (!strcmp(nsp->frp->name, name))
break;
if (nsp != (void *)&gp->hq)
return (nsp);
/* Search for a last-component match. */
- for (nsp = gp->hq.cqh_first;
- nsp != (void *)&gp->hq; nsp = nsp->q.cqe_next) {
+ CIRCLEQ_FOREACH(nsp, &gp->hq, q) {
if ((p = strrchr(nsp->frp->name, '/')) == NULL)
p = nsp->frp->name;
else
diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c
index d27244d5f71..3ad4b138489 100644
--- a/usr.bin/vmstat/dkstats.c
+++ b/usr.bin/vmstat/dkstats.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkstats.c,v 1.26 2005/07/04 01:54:10 djm Exp $ */
+/* $OpenBSD: dkstats.c,v 1.27 2005/10/17 19:04:20 otto Exp $ */
/* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */
/*
@@ -382,7 +382,7 @@ dkreadstats(void)
cur.dk_rbytes[i] = cur_disk.dk_rbytes;
cur.dk_wbytes[i] = cur_disk.dk_wbytes;
timerset(&(cur_disk.dk_time), &(cur.dk_time[i]));
- p = cur_disk.dk_link.tqe_next;
+ p = TAILQ_NEXT(&cur_disk, dk_link);
}
deref_nl(X_CP_TIME, cur.cp_time, sizeof(cur.cp_time));
deref_nl(X_TK_NIN, &cur.tk_nin, sizeof(cur.tk_nin));
@@ -443,7 +443,7 @@ dkinit(int select)
/* Get a pointer to the first disk. */
deref_nl(X_DISKLIST, &disk_head, sizeof(disk_head));
- dk_drivehead = disk_head.tqh_first;
+ dk_drivehead = TAILQ_FIRST(&disk_head);
/* Get ticks per second. */
deref_nl(X_STATHZ, &hz, sizeof(hz));
@@ -528,7 +528,7 @@ dkinit(int select)
errx(1, "Memory allocation failure.");
cur.dk_select[i] = select;
- p = cur_disk.dk_link.tqe_next;
+ p = TAILQ_NEXT(&cur_disk, dk_link);
}
#endif /* !defined(NOKVM) */
}
diff --git a/usr.bin/whatis/whatis.c b/usr.bin/whatis/whatis.c
index b0f18de11ec..ddd74440a6f 100644
--- a/usr.bin/whatis/whatis.c
+++ b/usr.bin/whatis/whatis.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: whatis.c,v 1.9 2003/06/10 22:20:54 deraadt Exp $ */
+/* $OpenBSD: whatis.c,v 1.10 2005/10/17 19:04:20 otto Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -108,8 +108,8 @@ main(int argc, char *argv[])
else {
config(conffile);
ep = (tp = getlist("_whatdb")) == NULL ?
- NULL : tp->list.tqh_first;
- for (; ep != NULL; ep = ep->q.tqe_next)
+ NULL : TAILQ_FIRST(&tp->list);
+ for (; ep != NULL; ep = TAILQ_NEXT(ep, q))
whatis(argv, ep->s, 0);
}