summaryrefslogtreecommitdiff
path: root/usr.bin/vi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2013-12-01 13:42:43 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2013-12-01 13:42:43 +0000
commit086d3af546cd0bd67aed0ec2406b6a85be894254 (patch)
treecbe9067086691f0b24c6e07615b17bce612738f7 /usr.bin/vi
parent2eaca287e7ba13be5c6de3309cce8b9914be0fd2 (diff)
Convert the ranges CIRCLEQ to TAILQ.
ok zhuk@
Diffstat (limited to 'usr.bin/vi')
-rw-r--r--usr.bin/vi/ex/ex.c13
-rw-r--r--usr.bin/vi/ex/ex.h6
-rw-r--r--usr.bin/vi/ex/ex_at.c6
-rw-r--r--usr.bin/vi/ex/ex_global.c18
4 files changed, 21 insertions, 22 deletions
diff --git a/usr.bin/vi/ex/ex.c b/usr.bin/vi/ex/ex.c
index 5da0f2cf5b5..13ba98b61ab 100644
--- a/usr.bin/vi/ex/ex.c
+++ b/usr.bin/vi/ex/ex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex.c,v 1.17 2013/11/25 23:27:11 krw Exp $ */
+/* $OpenBSD: ex.c,v 1.18 2013/12/01 13:42:42 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -2091,15 +2091,16 @@ ex_load(sp)
*/
if (FL_ISSET(ecp->agv_flags, AGV_ALL)) {
/* Discard any exhausted ranges. */
- while ((rp = CIRCLEQ_FIRST(&ecp->rq)) != (void *)&ecp->rq)
+ while ((rp = TAILQ_FIRST(&ecp->rq))) {
if (rp->start > rp->stop) {
- CIRCLEQ_REMOVE(&ecp->rq, rp, q);
+ TAILQ_REMOVE(&ecp->rq, rp, q);
free(rp);
} else
break;
+ }
/* If there's another range, continue with it. */
- if (rp != (void *)&ecp->rq)
+ if (rp)
break;
/* If it's a global/v command, fix up the last line. */
@@ -2156,8 +2157,8 @@ ex_discard(sp)
*/
for (gp = sp->gp; (ecp = LIST_FIRST(&gp->ecq)) != &gp->excmd;) {
if (FL_ISSET(ecp->agv_flags, AGV_ALL)) {
- while ((rp = CIRCLEQ_FIRST(&ecp->rq)) != CIRCLEQ_END(&ecp->rq)) {
- CIRCLEQ_REMOVE(&ecp->rq, rp, q);
+ while ((rp = TAILQ_FIRST(&ecp->rq))) {
+ TAILQ_REMOVE(&ecp->rq, rp, q);
free(rp);
}
free(ecp->o_cp);
diff --git a/usr.bin/vi/ex/ex.h b/usr.bin/vi/ex/ex.h
index 95de526aa64..b1a6ba208a1 100644
--- a/usr.bin/vi/ex/ex.h
+++ b/usr.bin/vi/ex/ex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex.h,v 1.6 2006/01/08 21:05:40 miod Exp $ */
+/* $OpenBSD: ex.h,v 1.7 2013/12/01 13:42:42 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -66,7 +66,7 @@ extern EXCMDLIST const cmds[]; /* Table of ex commands. */
/* Range structures for global and @ commands. */
typedef struct _range RANGE;
struct _range { /* Global command range. */
- CIRCLEQ_ENTRY(_range) q; /* Linked list of ranges. */
+ TAILQ_ENTRY(_range) q; /* Linked list of ranges. */
recno_t start, stop; /* Start/stop of the range. */
};
@@ -91,7 +91,7 @@ struct _excmd {
EXCMDLIST const *cmd; /* Command: entry in command table. */
EXCMDLIST rcmd; /* Command: table entry/replacement. */
- CIRCLEQ_HEAD(_rh, _range) rq; /* @/global range: linked list. */
+ TAILQ_HEAD(_rh, _range) rq; /* @/global range: linked list. */
recno_t range_lno; /* @/global range: set line number. */
char *o_cp; /* Original @/global command. */
size_t o_clen; /* Original @/global command length. */
diff --git a/usr.bin/vi/ex/ex_at.c b/usr.bin/vi/ex/ex_at.c
index e695189847e..d46bd82c5b1 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.9 2013/11/25 23:27:11 krw Exp $ */
+/* $OpenBSD: ex_at.c,v 1.10 2013/12/01 13:42:42 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -82,7 +82,7 @@ ex_at(sp, cmdp)
* means @ buffers are still useful in a multi-screen environment.
*/
CALLOC_RET(sp, ecp, EXCMD *, 1, sizeof(EXCMD));
- CIRCLEQ_INIT(&ecp->rq);
+ TAILQ_INIT(&ecp->rq);
CALLOC_RET(sp, rp, RANGE *, 1, sizeof(RANGE));
rp->start = cmdp->addr1.lno;
if (F_ISSET(cmdp, E_ADDR_DEF)) {
@@ -92,7 +92,7 @@ ex_at(sp, cmdp)
rp->stop = cmdp->addr2.lno;
FL_SET(ecp->agv_flags, AGV_AT);
}
- CIRCLEQ_INSERT_HEAD(&ecp->rq, rp, q);
+ TAILQ_INSERT_HEAD(&ecp->rq, rp, q);
/*
* Buffers executed in ex mode or from the colon command line in vi
diff --git a/usr.bin/vi/ex/ex_global.c b/usr.bin/vi/ex/ex_global.c
index 842012112e6..7769fba7571 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.11 2009/10/27 23:59:47 deraadt Exp $ */
+/* $OpenBSD: ex_global.c,v 1.12 2013/12/01 13:42:42 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -163,7 +163,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
/* Get an EXCMD structure. */
CALLOC_RET(sp, ecp, EXCMD *, 1, sizeof(EXCMD));
- CIRCLEQ_INIT(&ecp->rq);
+ TAILQ_INIT(&ecp->rq);
/*
* Get a copy of the command string; the default command is print.
@@ -232,8 +232,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
}
/* If follows the last entry, extend the last entry's range. */
- if ((rp = CIRCLEQ_LAST(&ecp->rq)) != CIRCLEQ_END(&ecp->rq) &&
- rp->stop == start - 1) {
+ if ((rp = TAILQ_LAST(&ecp->rq, _rh)) && rp->stop == start - 1) {
++rp->stop;
continue;
}
@@ -243,7 +242,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
if (rp == NULL)
return (1);
rp->start = rp->stop = start;
- CIRCLEQ_INSERT_TAIL(&ecp->rq, rp, q);
+ TAILQ_INSERT_TAIL(&ecp->rq, rp, q);
}
search_busy(sp, BUSY_OFF);
return (0);
@@ -274,9 +273,8 @@ ex_g_insdel(sp, op, lno)
LIST_FOREACH(ecp, &sp->gp->ecq, q) {
if (!FL_ISSET(ecp->agv_flags, AGV_AT | AGV_GLOBAL | AGV_V))
continue;
- for (rp = CIRCLEQ_FIRST(&ecp->rq); rp != CIRCLEQ_END(&ecp->rq);
- rp = nrp) {
- nrp = CIRCLEQ_NEXT(rp, q);
+ for (rp = TAILQ_FIRST(&ecp->rq); rp != NULL; rp = nrp) {
+ nrp = TAILQ_NEXT(rp, q);
/* If range less than the line, ignore it. */
if (rp->stop < lno)
@@ -305,7 +303,7 @@ ex_g_insdel(sp, op, lno)
*/
if (op == LINE_DELETE) {
if (rp->start > --rp->stop) {
- CIRCLEQ_REMOVE(&ecp->rq, rp, q);
+ TAILQ_REMOVE(&ecp->rq, rp, q);
free(rp);
}
} else {
@@ -313,7 +311,7 @@ ex_g_insdel(sp, op, lno)
nrp->start = lno + 1;
nrp->stop = rp->stop + 1;
rp->stop = lno - 1;
- CIRCLEQ_INSERT_AFTER(&ecp->rq, rp, nrp, q);
+ TAILQ_INSERT_AFTER(&ecp->rq, rp, nrp, q);
rp = nrp;
}
}