summaryrefslogtreecommitdiff
path: root/usr.bin/vi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2013-11-28 22:12:41 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2013-11-28 22:12:41 +0000
commit4f7881a33f315e2775d67d25c5154c9ecfc5cea1 (patch)
tree75429fa97714ef5f86ffa8394a53345c6c8bc0d5 /usr.bin/vi
parent290f5e984f706b1e66ceb9741dee87bd6aa8ed4c (diff)
Convert the display screens and hidden screens CIRCLEQ's to TAILQ's.
ok pelikan@ zhuk@
Diffstat (limited to 'usr.bin/vi')
-rw-r--r--usr.bin/vi/cl/cl_screen.c4
-rw-r--r--usr.bin/vi/common/api.c6
-rw-r--r--usr.bin/vi/common/gs.h6
-rw-r--r--usr.bin/vi/common/key.c6
-rw-r--r--usr.bin/vi/common/line.c4
-rw-r--r--usr.bin/vi/common/main.c18
-rw-r--r--usr.bin/vi/common/screen.c35
-rw-r--r--usr.bin/vi/common/screen.h4
-rw-r--r--usr.bin/vi/ex/ex_screen.c10
-rw-r--r--usr.bin/vi/ex/ex_script.c16
-rw-r--r--usr.bin/vi/vi/v_screen.c10
-rw-r--r--usr.bin/vi/vi/vi.c16
-rw-r--r--usr.bin/vi/vi/vi.h6
-rw-r--r--usr.bin/vi/vi/vs_msg.c6
-rw-r--r--usr.bin/vi/vi/vs_refresh.c8
-rw-r--r--usr.bin/vi/vi/vs_split.c53
16 files changed, 107 insertions, 101 deletions
diff --git a/usr.bin/vi/cl/cl_screen.c b/usr.bin/vi/cl/cl_screen.c
index 610f5bef919..4fc553cdb56 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.19 2009/10/27 23:59:47 deraadt Exp $ */
+/* $OpenBSD: cl_screen.c,v 1.20 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -89,7 +89,7 @@ cl_screen(sp, flags)
if (F_ISSET(sp, SC_SCR_VI)) {
F_CLR(sp, SC_SCR_VI);
- if (CIRCLEQ_NEXT(sp, q) != CIRCLEQ_END(&gp->dq)) {
+ if (TAILQ_NEXT(sp, q)) {
(void)move(RLNO(sp, sp->rows), 0);
clrtobot();
}
diff --git a/usr.bin/vi/common/api.c b/usr.bin/vi/common/api.c
index 0e6799a6b51..e87bc1a1824 100644
--- a/usr.bin/vi/common/api.c
+++ b/usr.bin/vi/common/api.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: api.c,v 1.14 2009/10/27 23:59:47 deraadt Exp $ */
+/* $OpenBSD: api.c,v 1.15 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -47,7 +47,7 @@ api_fscreen(id, name)
gp = __global_list;
/* Search the displayed list. */
- CIRCLEQ_FOREACH(tsp, &gp->dq, q)
+ TAILQ_FOREACH(tsp, &gp->dq, q)
if (name == NULL) {
if (id == tsp->id)
return (tsp);
@@ -55,7 +55,7 @@ api_fscreen(id, name)
return (tsp);
/* Search the hidden list. */
- CIRCLEQ_FOREACH(tsp, &gp->hq, q)
+ TAILQ_FOREACH(tsp, &gp->hq, q)
if (name == NULL) {
if (id == tsp->id)
return (tsp);
diff --git a/usr.bin/vi/common/gs.h b/usr.bin/vi/common/gs.h
index b3c0fd42808..e3c4609e57a 100644
--- a/usr.bin/vi/common/gs.h
+++ b/usr.bin/vi/common/gs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: gs.h,v 1.9 2006/01/08 21:05:39 miod Exp $ */
+/* $OpenBSD: gs.h,v 1.10 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -58,8 +58,8 @@ struct _gs {
char *progname; /* Programe name. */
int id; /* Last allocated screen id. */
- CIRCLEQ_HEAD(_dqh, _scr) dq; /* Displayed screens. */
- CIRCLEQ_HEAD(_hqh, _scr) hq; /* Hidden screens. */
+ TAILQ_HEAD(_dqh, _scr) dq; /* Displayed screens. */
+ TAILQ_HEAD(_hqh, _scr) hq; /* Hidden screens. */
SCR *ccl_sp; /* Colon command-line screen. */
diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c
index 5a93f7fa856..43617a12d87 100644
--- a/usr.bin/vi/common/key.c
+++ b/usr.bin/vi/common/key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key.c,v 1.10 2009/10/27 23:59:47 deraadt Exp $ */
+/* $OpenBSD: key.c,v 1.11 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -749,9 +749,9 @@ v_sync(sp, flags)
GS *gp;
gp = sp->gp;
- CIRCLEQ_FOREACH(sp, &gp->dq, q)
+ TAILQ_FOREACH(sp, &gp->dq, q)
rcv_sync(sp, flags);
- CIRCLEQ_FOREACH(sp, &gp->hq, q)
+ TAILQ_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 c1ab6d34fd6..e81019e0242 100644
--- a/usr.bin/vi/common/line.c
+++ b/usr.bin/vi/common/line.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: line.c,v 1.11 2013/11/27 08:52:41 zhuk Exp $ */
+/* $OpenBSD: line.c,v 1.12 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -567,7 +567,7 @@ scr_update(sp, lno, op, current)
ep = sp->ep;
if (ep->refcnt != 1)
- CIRCLEQ_FOREACH(tsp, &sp->gp->dq, q)
+ TAILQ_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 435e6d81596..e1a26f3a5a8 100644
--- a/usr.bin/vi/common/main.c
+++ b/usr.bin/vi/common/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.20 2013/11/25 23:27:11 krw Exp $ */
+/* $OpenBSD: main.c,v 1.21 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -78,8 +78,8 @@ editor(gp, argc, argv)
gp->scr_msg = vs_msg;
/* Common global structure initialization. */
- CIRCLEQ_INIT(&gp->dq);
- CIRCLEQ_INIT(&gp->hq);
+ TAILQ_INIT(&gp->dq);
+ TAILQ_INIT(&gp->hq);
LIST_INIT(&gp->ecq);
LIST_INSERT_HEAD(&gp->ecq, &gp->excmd, q);
gp->noprint = DEFAULT_NOPRINT;
@@ -244,11 +244,11 @@ editor(gp, argc, argv)
*/
if (screen_init(gp, NULL, &sp)) {
if (sp != NULL)
- CIRCLEQ_INSERT_HEAD(&gp->dq, sp, q);
+ TAILQ_INSERT_HEAD(&gp->dq, sp, q);
goto err;
}
F_SET(sp, SC_EX);
- CIRCLEQ_INSERT_HEAD(&gp->dq, sp, q);
+ TAILQ_INSERT_HEAD(&gp->dq, sp, q);
if (v_key_init(sp)) /* Special key initialization. */
goto err;
@@ -456,10 +456,10 @@ v_end(gp)
(void)file_end(gp->ccl_sp, NULL, 1);
(void)screen_end(gp->ccl_sp);
}
- while ((sp = CIRCLEQ_FIRST(&gp->dq)) != CIRCLEQ_END(&gp->dq))
- (void)screen_end(sp);
- while ((sp = CIRCLEQ_FIRST(&gp->hq)) != CIRCLEQ_END(&gp->hq))
- (void)screen_end(sp);
+ while ((sp = TAILQ_FIRST(&gp->dq)))
+ (void)screen_end(sp); /* Removes sp from the queue. */
+ while ((sp = TAILQ_FIRST(&gp->hq)))
+ (void)screen_end(sp); /* Removes sp from the queue. */
#ifdef HAVE_PERL_INTERP
perl_end(gp);
diff --git a/usr.bin/vi/common/screen.c b/usr.bin/vi/common/screen.c
index 2f5e747d66b..91c79c9596f 100644
--- a/usr.bin/vi/common/screen.c
+++ b/usr.bin/vi/common/screen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen.c,v 1.9 2013/11/25 23:27:11 krw Exp $ */
+/* $OpenBSD: screen.c,v 1.10 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -131,19 +131,30 @@ screen_end(sp)
SCR *sp;
{
int rval;
+ SCR *tsp;
/* If multiply referenced, just decrement the count and return. */
if (--sp->refcnt != 0)
return (0);
/*
- * Remove the screen from the displayed queue.
+ * Remove the screen from the displayed and hidden queues.
*
* If a created screen failed during initialization, it may not
- * be linked into the chain.
+ * be linked into a queue.
*/
- if (CIRCLEQ_NEXT(sp, q) != NULL)
- CIRCLEQ_REMOVE(&sp->gp->dq, sp, q);
+ TAILQ_FOREACH(tsp, &sp->gp->dq, q) {
+ if (tsp == sp) {
+ TAILQ_REMOVE(&sp->gp->dq, sp, q);
+ break;
+ }
+ }
+ TAILQ_FOREACH(tsp, &sp->gp->hq, q) {
+ if (tsp == sp) {
+ TAILQ_REMOVE(&sp->gp->hq, sp, q);
+ break;
+ }
+ }
/* The screen is no longer real. */
F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
@@ -213,17 +224,15 @@ screen_next(sp)
/* Try the display queue, without returning the current screen. */
gp = sp->gp;
- CIRCLEQ_FOREACH(next, &gp->dq, q)
+ TAILQ_FOREACH(next, &gp->dq, q)
if (next != sp)
- break;
- if (next != (void *)&gp->dq)
- return (next);
+ return (next);
/* Try the hidden queue; if found, move screen to the display queue. */
- 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);
+ if (!TAILQ_EMPTY(&gp->hq)) {
+ next = TAILQ_FIRST(&gp->hq);
+ TAILQ_REMOVE(&gp->hq, next, q);
+ TAILQ_INSERT_HEAD(&gp->dq, next, q);
return (next);
}
return (NULL);
diff --git a/usr.bin/vi/common/screen.h b/usr.bin/vi/common/screen.h
index 1bd10a38fe6..dfe3a574453 100644
--- a/usr.bin/vi/common/screen.h
+++ b/usr.bin/vi/common/screen.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen.h,v 1.5 2001/01/29 01:58:31 niklas Exp $ */
+/* $OpenBSD: screen.h,v 1.6 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -34,7 +34,7 @@
*/
struct _scr {
/* INITIALIZED AT SCREEN CREATE. */
- CIRCLEQ_ENTRY(_scr) q; /* Screens. */
+ TAILQ_ENTRY(_scr) q; /* Screens. */
int id; /* Screen id #. */
int refcnt; /* Reference count. */
diff --git a/usr.bin/vi/ex/ex_screen.c b/usr.bin/vi/ex/ex_screen.c
index 301ee4bfc1b..9407770a588 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.7 2009/10/27 23:59:47 deraadt Exp $ */
+/* $OpenBSD: ex_screen.c,v 1.8 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -110,14 +110,16 @@ ex_sdisplay(sp)
int cnt, col, len, sep;
gp = sp->gp;
- if ((tsp = CIRCLEQ_FIRST(&gp->hq)) == CIRCLEQ_END(&gp->hq)) {
+ if (TAILQ_EMPTY(&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 = CIRCLEQ_NEXT(tsp, q)) {
+ cnt = 1;
+ TAILQ_FOREACH(tsp, &gp->hq, q) {
+ if (INTERRUPTED(sp))
+ break;
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 a2e6fc8e95d..23d7c7dc73c 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.18 2012/12/20 20:28:12 naddy Exp $ */
+/* $OpenBSD: ex_script.c,v 1.19 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -366,7 +366,7 @@ sscr_check_input(SCR *sp)
/* Allocate space for pfd. */
nfds = 1;
- CIRCLEQ_FOREACH(tsp, &gp->dq, q)
+ TAILQ_FOREACH(tsp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT))
nfds++;
pfd = calloc(nfds, sizeof(struct pollfd));
@@ -379,7 +379,7 @@ sscr_check_input(SCR *sp)
pfd[0].fd = STDIN_FILENO;
pfd[0].events = POLLIN;
nfds = 1;
- CIRCLEQ_FOREACH(tsp, &gp->dq, q)
+ TAILQ_FOREACH(tsp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT)) {
pfd[nfds].fd = sp->script->sh_master;
pfd[nfds].events = POLLIN;
@@ -402,7 +402,7 @@ loop:
/* Only insert from the scripting windows if no command input */
if (!(pfd[0].revents & POLLIN)) {
nfds = 1;
- CIRCLEQ_FOREACH(tsp, &gp->dq, q)
+ TAILQ_FOREACH(tsp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT)) {
if ((pfd[nfds].revents & POLLHUP) && sscr_end(sp))
goto done;
@@ -436,7 +436,7 @@ sscr_input(sp)
/* Allocate space for pfd. */
nfds = 0;
- CIRCLEQ_FOREACH(sp, &gp->dq, q)
+ TAILQ_FOREACH(sp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT))
nfds++;
if (nfds == 0)
@@ -449,7 +449,7 @@ sscr_input(sp)
/* Setup events bitmasks. */
nfds = 0;
- CIRCLEQ_FOREACH(sp, &gp->dq, q)
+ TAILQ_FOREACH(sp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT)) {
pfd[nfds].fd = sp->script->sh_master;
pfd[nfds].events = POLLIN;
@@ -471,7 +471,7 @@ loop:
/* Read the input. */
nfds = 0;
- CIRCLEQ_FOREACH(sp, &gp->dq, q)
+ TAILQ_FOREACH(sp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT)) {
if ((pfd[nfds].revents & POLLHUP) && sscr_end(sp))
goto done;
@@ -684,7 +684,7 @@ sscr_check(sp)
GS *gp;
gp = sp->gp;
- CIRCLEQ_FOREACH(sp, &gp->dq, q)
+ TAILQ_FOREACH(sp, &gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT)) {
F_SET(gp, G_SCRWIN);
return;
diff --git a/usr.bin/vi/vi/v_screen.c b/usr.bin/vi/vi/v_screen.c
index 015e99f158e..8b048c74702 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.6 2009/10/27 23:59:48 deraadt Exp $ */
+/* $OpenBSD: v_screen.c,v 1.7 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -49,13 +49,13 @@ v_screen(sp, vp)
* Try for the next lower screen, or, go back to the first
* screen on the stack.
*/
- if (CIRCLEQ_NEXT(sp, q) != CIRCLEQ_END(&sp->gp->dq))
- sp->nextdisp = CIRCLEQ_NEXT(sp, q);
- else if (CIRCLEQ_FIRST(&sp->gp->dq) == sp) {
+ if (TAILQ_NEXT(sp, q))
+ sp->nextdisp = TAILQ_NEXT(sp, q);
+ else if (TAILQ_FIRST(&sp->gp->dq) == sp) {
msgq(sp, M_ERR, "187|No other screen to switch to");
return (1);
} else
- sp->nextdisp = CIRCLEQ_FIRST(&sp->gp->dq);
+ sp->nextdisp = TAILQ_FIRST(&sp->gp->dq);
F_SET(sp->nextdisp, SC_STATUS);
F_SET(sp, SC_SSWITCH | SC_STATUS);
diff --git a/usr.bin/vi/vi/vi.c b/usr.bin/vi/vi/vi.c
index 8caf156bd80..a94597717fa 100644
--- a/usr.bin/vi/vi/vi.c
+++ b/usr.bin/vi/vi/vi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vi.c,v 1.13 2009/10/27 23:59:48 deraadt Exp $ */
+/* $OpenBSD: vi.c,v 1.14 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -1007,19 +1007,21 @@ v_dtoh(sp)
int hidden;
/* Move all screens to the hidden queue, tossing screen maps. */
- for (hidden = 0, gp = sp->gp;
- (tsp = CIRCLEQ_FIRST(&gp->dq)) != CIRCLEQ_END(&gp->dq); ++hidden) {
+ hidden = 0;
+ gp = sp->gp;
+ while ((tsp = TAILQ_FIRST(&gp->dq))) {
if (_HMAP(tsp) != NULL) {
free(_HMAP(tsp));
_HMAP(tsp) = NULL;
}
- CIRCLEQ_REMOVE(&gp->dq, tsp, q);
- CIRCLEQ_INSERT_TAIL(&gp->hq, tsp, q);
+ TAILQ_REMOVE(&gp->dq, tsp, q);
+ TAILQ_INSERT_TAIL(&gp->hq, tsp, q);
+ ++hidden;
}
/* Move current screen back to the display queue. */
- CIRCLEQ_REMOVE(&gp->hq, sp, q);
- CIRCLEQ_INSERT_TAIL(&gp->dq, sp, q);
+ TAILQ_REMOVE(&gp->hq, sp, q);
+ TAILQ_INSERT_TAIL(&gp->dq, sp, q);
/*
* XXX
diff --git a/usr.bin/vi/vi/vi.h b/usr.bin/vi/vi/vi.h
index 54a536de164..bcf928d8347 100644
--- a/usr.bin/vi/vi/vi.h
+++ b/usr.bin/vi/vi/vi.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vi.h,v 1.6 2006/01/08 21:05:40 miod Exp $ */
+/* $OpenBSD: vi.h,v 1.7 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -354,9 +354,7 @@ typedef struct _vi_private {
#define TAB_OFF(c) COL_OFF((c), O_VAL(sp, O_TABSTOP))
/* If more than one screen being shown. */
-#define IS_SPLIT(sp) \
- (CIRCLEQ_NEXT((sp), q) != (void *)&(sp)->gp->dq || \
- CIRCLEQ_PREV((sp), q) != (void *)&(sp)->gp->dq)
+#define IS_SPLIT(sp) (TAILQ_NEXT((sp), q) || TAILQ_PREV((sp), _dqh, q))
/* 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 6ffbbb393dc..83598704493 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.11 2009/10/27 23:59:49 deraadt Exp $ */
+/* $OpenBSD: vs_msg.c,v 1.12 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -599,7 +599,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 (CIRCLEQ_NEXT(sp, q) != CIRCLEQ_END(&sp->gp->dq))
+ if (TAILQ_NEXT(sp, q))
F_SET(sp, SC_SCR_REDRAW);
/* If ex changed the underlying file, the map itself is wrong. */
@@ -780,7 +780,7 @@ vs_scroll(sp, continuep, wtype)
(void)gp->scr_deleteln(sp);
/* If there are screens below us, push them back into place. */
- if (CIRCLEQ_NEXT(sp, q) != CIRCLEQ_END(&sp->gp->dq)) {
+ if (TAILQ_NEXT(sp, q)) {
(void)gp->scr_move(sp, LASTLINE(sp), 0);
(void)gp->scr_insertln(sp);
}
diff --git a/usr.bin/vi/vi/vs_refresh.c b/usr.bin/vi/vi/vs_refresh.c
index ef28c91d041..263f68c701e 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.17 2011/04/10 21:21:50 martynas Exp $ */
+/* $OpenBSD: vs_refresh.c,v 1.18 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -78,7 +78,7 @@ vs_refresh(sp, forcepaint)
* that we can find, including status lines.
*/
if (F_ISSET(sp, SC_SCR_REDRAW))
- CIRCLEQ_FOREACH(tsp, &gp->dq, q)
+ TAILQ_FOREACH(tsp, &gp->dq, q)
if (tsp != sp)
F_SET(tsp, SC_SCR_REDRAW | SC_STATUS);
@@ -95,7 +95,7 @@ vs_refresh(sp, forcepaint)
priv_paint = VIP_CUR_INVALID | VIP_N_REFRESH;
if (O_ISSET(sp, O_NUMBER))
priv_paint |= VIP_N_RENUMBER;
- CIRCLEQ_FOREACH(tsp, &gp->dq, q)
+ TAILQ_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))) {
@@ -131,7 +131,7 @@ vs_refresh(sp, forcepaint)
* gets back to where it belongs.
*/
need_refresh = 0;
- CIRCLEQ_FOREACH(tsp, &gp->dq, q)
+ TAILQ_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 fb4074adc26..4b6b2683504 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.10 2009/10/27 23:59:49 deraadt Exp $ */
+/* $OpenBSD: vs_split.c,v 1.11 2013/11/28 22:12:40 krw Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -95,7 +95,7 @@ vs_split(sp, new, ccl)
sp->rows = half; /* Old. */
sp->woff += new->rows;
/* Link in before old. */
- CIRCLEQ_INSERT_BEFORE(&gp->dq, sp, new, q);
+ TAILQ_INSERT_BEFORE(sp, new, q);
/*
* If the parent is the bottom half of the screen, shift
@@ -108,7 +108,7 @@ vs_split(sp, new, ccl)
sp->rows -= half; /* Old. */
new->woff = sp->woff + sp->rows;
/* Link in after old. */
- CIRCLEQ_INSERT_AFTER(&gp->dq, sp, new, q);
+ TAILQ_INSERT_AFTER(&gp->dq, sp, new, q);
}
/* Adjust maximum text count. */
@@ -219,11 +219,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 = CIRCLEQ_PREV(sp, q)) != CIRCLEQ_END(&sp->gp->dq)) {
+ if ((nsp = TAILQ_PREV(sp, _dqh, q))) {
nsp->rows += sp->rows;
sp = nsp;
dir = FORWARD;
- } else if ((nsp = CIRCLEQ_NEXT(sp, q)) != CIRCLEQ_END(&sp->gp->dq)) {
+ } else if ((nsp = TAILQ_NEXT(sp, q))) {
nsp->woff = sp->woff;
nsp->rows += sp->rows;
sp = nsp;
@@ -312,17 +312,17 @@ vs_fg(sp, nspp, name, newscreen)
if (newscreen) {
/* Remove the new screen from the background queue. */
- CIRCLEQ_REMOVE(&gp->hq, nsp, q);
+ TAILQ_REMOVE(&gp->hq, nsp, q);
/* Split the screen; if we fail, hook the screen back in. */
if (vs_split(sp, nsp, 0)) {
- CIRCLEQ_INSERT_TAIL(&gp->hq, nsp, q);
+ TAILQ_INSERT_TAIL(&gp->hq, nsp, q);
return (1);
}
} else {
/* Move the old screen to the background queue. */
- CIRCLEQ_REMOVE(&gp->dq, sp, q);
- CIRCLEQ_INSERT_TAIL(&gp->hq, sp, q);
+ TAILQ_REMOVE(&gp->dq, sp, q);
+ TAILQ_INSERT_TAIL(&gp->hq, sp, q);
}
return (0);
}
@@ -352,8 +352,8 @@ vs_bg(sp)
}
/* Move the old screen to the background queue. */
- CIRCLEQ_REMOVE(&gp->dq, sp, q);
- CIRCLEQ_INSERT_TAIL(&gp->hq, sp, q);
+ TAILQ_REMOVE(&gp->dq, sp, q);
+ TAILQ_INSERT_TAIL(&gp->hq, sp, q);
/* Toss the screen map. */
free(_HMAP(sp));
@@ -444,8 +444,8 @@ vs_swap(sp, nspp, name)
* the exit will delete the old one, if we're foregrounding, the fg
* code will move the old one to the background queue.
*/
- CIRCLEQ_REMOVE(&gp->hq, nsp, q);
- CIRCLEQ_INSERT_AFTER(&gp->dq, sp, nsp, q);
+ TAILQ_REMOVE(&gp->hq, nsp, q);
+ TAILQ_INSERT_AFTER(&gp->dq, sp, nsp, q);
/*
* Don't change the screen's cursor information other than to
@@ -501,15 +501,15 @@ vs_resize(sp, count, adj)
s = sp;
if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count)
goto toosmall;
- if ((g = CIRCLEQ_PREV(sp, q)) == CIRCLEQ_END(&gp->dq)) {
- if ((g = CIRCLEQ_NEXT(sp, q)) == CIRCLEQ_END(&gp->dq))
+ if ((g = TAILQ_PREV(sp, _dqh, q)) == NULL) {
+ if ((g = TAILQ_NEXT(sp, q)) == NULL)
goto toobig;
g_off = -count;
} else
s_off = count;
} else {
g = sp;
- if ((s = CIRCLEQ_NEXT(sp, q)) != CIRCLEQ_END(&gp->dq))
+ if ((s = TAILQ_NEXT(sp, q)))
if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count)
s = NULL;
else
@@ -517,7 +517,7 @@ vs_resize(sp, count, adj)
else
s = NULL;
if (s == NULL) {
- if ((s = CIRCLEQ_PREV(sp, q)) == CIRCLEQ_END(&gp->dq)) {
+ if ((s = TAILQ_PREV(sp, _dqh, q)) == NULL) {
toobig: msgq(sp, M_BERR, adj == A_DECREASE ?
"227|The screen cannot shrink" :
"228|The screen cannot grow");
@@ -577,29 +577,24 @@ vs_getbg(sp, name)
gp = sp->gp;
/* If name is NULL, return the first background screen on the list. */
- if (name == NULL) {
- nsp = CIRCLEQ_FIRST(&gp->hq);
- return (nsp == (void *)&gp->hq ? NULL : nsp);
- }
+ if (name == NULL)
+ return (TAILQ_FIRST(&gp->hq));
/* Search for a full match. */
- CIRCLEQ_FOREACH(nsp, &gp->hq, q)
+ TAILQ_FOREACH(nsp, &gp->hq, q) {
if (!strcmp(nsp->frp->name, name))
- break;
- if (nsp != (void *)&gp->hq)
- return (nsp);
+ return(nsp);
+ }
/* Search for a last-component match. */
- CIRCLEQ_FOREACH(nsp, &gp->hq, q) {
+ TAILQ_FOREACH(nsp, &gp->hq, q) {
if ((p = strrchr(nsp->frp->name, '/')) == NULL)
p = nsp->frp->name;
else
++p;
if (!strcmp(p, name))
- break;
+ return(nsp);
}
- if (nsp != (void *)&gp->hq)
- return (nsp);
return (NULL);
}