Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/nvi/dist - replace CIRCLEQ with TAILQ
details: https://anonhg.NetBSD.org/src/rev/8fb2c8872a1f
branches: trunk
changeset: 791609:8fb2c8872a1f
user: christos <christos%NetBSD.org@localhost>
date: Mon Nov 25 22:43:46 2013 +0000
description:
- replace CIRCLEQ with TAILQ
- fix open-coded LIST code
- fix destroy screen bug (was not removed from list)
diffstat:
external/bsd/nvi/dist/cl/cl_funcs.c | 10 +-
external/bsd/nvi/dist/cl/cl_screen.c | 4 +-
external/bsd/nvi/dist/cl/cl_term.c | 8 +-
external/bsd/nvi/dist/common/api.c | 33 ++++----
external/bsd/nvi/dist/common/cut.c | 18 ++--
external/bsd/nvi/dist/common/cut.h | 6 +-
external/bsd/nvi/dist/common/exf.c | 28 +++----
external/bsd/nvi/dist/common/exf.h | 6 +-
external/bsd/nvi/dist/common/gs.c | 38 +++++----
external/bsd/nvi/dist/common/gs.h | 12 +-
external/bsd/nvi/dist/common/key.c | 12 +-
external/bsd/nvi/dist/common/main.c | 6 +-
external/bsd/nvi/dist/common/mark.c | 14 +--
external/bsd/nvi/dist/common/put.c | 22 ++--
external/bsd/nvi/dist/common/screen.c | 22 ++---
external/bsd/nvi/dist/common/screen.h | 10 +-
external/bsd/nvi/dist/common/seq.c | 14 ++-
external/bsd/nvi/dist/common/vi_db.c | 35 ++++-----
external/bsd/nvi/dist/common/vi_db1.c | 35 ++++-----
external/bsd/nvi/dist/ex/ex.c | 31 ++++----
external/bsd/nvi/dist/ex/ex.h | 8 +-
external/bsd/nvi/dist/ex/ex_append.c | 8 +-
external/bsd/nvi/dist/ex/ex_at.c | 14 +-
external/bsd/nvi/dist/ex/ex_cscope.c | 49 ++++++-------
external/bsd/nvi/dist/ex/ex_display.c | 15 +--
external/bsd/nvi/dist/ex/ex_edit.c | 4 +-
external/bsd/nvi/dist/ex/ex_global.c | 19 ++--
external/bsd/nvi/dist/ex/ex_init.c | 4 +-
external/bsd/nvi/dist/ex/ex_move.c | 15 +--
external/bsd/nvi/dist/ex/ex_screen.c | 8 +-
external/bsd/nvi/dist/ex/ex_script.c | 17 +--
external/bsd/nvi/dist/ex/ex_subst.c | 6 +-
external/bsd/nvi/dist/ex/ex_tag.c | 126 +++++++++++++++++----------------
external/bsd/nvi/dist/ex/ex_txt.c | 13 +-
external/bsd/nvi/dist/ex/tag.h | 8 +-
external/bsd/nvi/dist/ip/ip_term.c | 7 +-
external/bsd/nvi/dist/vi/v_at.c | 7 +-
external/bsd/nvi/dist/vi/v_ex.c | 8 +-
external/bsd/nvi/dist/vi/v_screen.c | 10 +-
external/bsd/nvi/dist/vi/v_search.c | 4 +-
external/bsd/nvi/dist/vi/v_txt.c | 28 +++---
external/bsd/nvi/dist/vi/vi.c | 12 +-
external/bsd/nvi/dist/vi/vs_msg.c | 16 ++--
external/bsd/nvi/dist/vi/vs_refresh.c | 12 +-
external/bsd/nvi/dist/vi/vs_split.c | 103 +++++++++++++--------------
45 files changed, 424 insertions(+), 461 deletions(-)
diffs (truncated from 2788 to 300 lines):
diff -r 093b02cde3b5 -r 8fb2c8872a1f external/bsd/nvi/dist/cl/cl_funcs.c
--- a/external/bsd/nvi/dist/cl/cl_funcs.c Mon Nov 25 16:29:25 2013 +0000
+++ b/external/bsd/nvi/dist/cl/cl_funcs.c Mon Nov 25 22:43:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cl_funcs.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
+/* $NetBSD: cl_funcs.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
/*-
* Copyright (c) 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -570,11 +570,9 @@
*/
if (repaint || F_ISSET(clp, CL_LAYOUT)) {
getyx(stdscr, y, x);
- for (psp = sp;
- psp != (void *)&sp->wp->scrq; psp = psp->q.cqe_next)
- for (tsp = psp->q.cqe_next;
- tsp != (void *)&sp->wp->scrq;
- tsp = tsp->q.cqe_next)
+ for (psp = sp; psp != NULL; psp = TAILQ_NEXT(psp, q))
+ for (tsp = TAILQ_NEXT(psp, q); tsp != NULL;
+ tsp = TAILQ_NEXT(tsp, q))
if (psp->roff == tsp->roff) {
if (psp->coff + psp->cols + 1 == tsp->coff)
cl_rdiv(psp);
diff -r 093b02cde3b5 -r 8fb2c8872a1f external/bsd/nvi/dist/cl/cl_screen.c
--- a/external/bsd/nvi/dist/cl/cl_screen.c Mon Nov 25 16:29:25 2013 +0000
+++ b/external/bsd/nvi/dist/cl/cl_screen.c Mon Nov 25 22:43:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cl_screen.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
+/* $NetBSD: cl_screen.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
/*-
* Copyright (c) 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -94,7 +94,7 @@
if (F_ISSET(sp, SC_SCR_VI)) {
F_CLR(sp, SC_SCR_VI);
- if (sp->q.cqe_next != (void *)&sp->wp->scrq) {
+ if (TAILQ_NEXT(sp, q) != NULL) {
(void)wmove(win, RLNO(sp, sp->rows), 0);
wclrtobot(win);
}
diff -r 093b02cde3b5 -r 8fb2c8872a1f external/bsd/nvi/dist/cl/cl_term.c
--- a/external/bsd/nvi/dist/cl/cl_term.c Mon Nov 25 16:29:25 2013 +0000
+++ b/external/bsd/nvi/dist/cl/cl_term.c Mon Nov 25 22:43:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cl_term.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
+/* $NetBSD: cl_term.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
/*-
* Copyright (c) 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -172,7 +172,7 @@
* 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);
@@ -191,11 +191,9 @@
SEQ *qp, *nqp;
/* Delete screen specific mappings. */
- for (qp = gp->seqq.lh_first; qp != NULL; qp = nqp) {
- nqp = qp->q.le_next;
+ LIST_FOREACH_SAFE(qp, &gp->seqq, q, nqp)
if (F_ISSET(qp, SEQ_SCREEN))
(void)seq_mdel(qp);
- }
return (0);
}
diff -r 093b02cde3b5 -r 8fb2c8872a1f external/bsd/nvi/dist/common/api.c
--- a/external/bsd/nvi/dist/common/api.c Mon Nov 25 16:29:25 2013 +0000
+++ b/external/bsd/nvi/dist/common/api.c Mon Nov 25 22:43:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: api.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
+/* $NetBSD: api.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -50,19 +50,16 @@
gp = __global_list;
/* Search the displayed lists. */
- for (wp = gp->dq.cqh_first;
- wp != (void *)&gp->dq; wp = wp->q.cqe_next)
- for (tsp = wp->scrq.cqh_first;
- tsp != (void *)&wp->scrq; tsp = tsp->q.cqe_next)
- if (name == NULL) {
- if (id == tsp->id)
+ TAILQ_FOREACH(wp, &gp->dq, q)
+ TAILQ_FOREACH(tsp, &wp->scrq, q)
+ if (name == NULL) {
+ if (id == tsp->id)
+ return (tsp);
+ } else if (!strcmp(name, tsp->frp->name))
return (tsp);
- } else if (!strcmp(name, tsp->frp->name))
- return (tsp);
/* Search the hidden list. */
- for (tsp = gp->hq.cqh_first;
- tsp != (void *)&gp->hq; tsp = tsp->q.cqe_next)
+ TAILQ_FOREACH (tsp, &gp->hq, q)
if (name == NULL) {
if (id == tsp->id)
return (tsp);
@@ -216,11 +213,11 @@
{
LMARK *mp;
- mp = sp->ep->marks.lh_first;
+ mp = LIST_FIRST(&sp->ep->marks);
if (next)
- for (; mp != NULL; mp = mp->q.le_next)
+ for (; mp != NULL; mp = LIST_NEXT(mp, q))
if (mp->name == *namep) {
- mp = mp->q.le_next;
+ mp = LIST_NEXT(mp, q);
break;
}
if (mp == NULL)
@@ -528,7 +525,7 @@
/* Allocate and initialize the tag queue structure. */
len = strlen(tag);
CALLOC_GOTO(sp, tqp, TAGQ *, 1, sizeof(TAGQ) + len + 1);
- CIRCLEQ_INIT(&tqp->tagq);
+ TAILQ_INIT(&tqp->tagq);
tqp->tag = tqp->buf;
memcpy(tqp->tag, tag, (tqp->tlen = len) + 1);
@@ -565,7 +562,7 @@
CHAR2INT(sp, msg, mlen + 1, wp, wlen);
MEMCPYW(tp->msg, wp, wlen);
tp->mlen = mlen;
- CIRCLEQ_INSERT_TAIL(&tqp->tagq, tp, q);
+ TAILQ_INSERT_TAIL(&tqp->tagq, tp, q);
alloc_err:
return;
@@ -584,12 +581,12 @@
*tqpp = 0;
/* Check to see if we found anything. */
- if (tqp->tagq.cqh_first == (void *)&tqp->tagq) {
+ if (TAILQ_EMPTY(&tqp->tagq)) {
free(tqp);
return 0;
}
- tqp->current = tqp->tagq.cqh_first;
+ tqp->current = TAILQ_FIRST(&tqp->tagq);
if (tagq_push(sp, tqp, 0, 0))
return 1;
diff -r 093b02cde3b5 -r 8fb2c8872a1f external/bsd/nvi/dist/common/cut.c
--- a/external/bsd/nvi/dist/common/cut.c Mon Nov 25 16:29:25 2013 +0000
+++ b/external/bsd/nvi/dist/common/cut.c Mon Nov 25 22:43:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cut.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
+/* $NetBSD: cut.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -124,7 +124,7 @@
if (cbp == NULL) {
CALLOC_RET(sp, cbp, CB *, 1, sizeof(CB));
cbp->name = name;
- CIRCLEQ_INIT(&cbp->textq);
+ TAILQ_INIT(&cbp->textq);
LIST_INSERT_HEAD(&sp->wp->cutq, cbp, q);
} else if (!append) {
text_lfree(&cbp->textq);
@@ -192,7 +192,7 @@
CB *cbp, *del_cbp;
del_cbp = NULL;
- for (cbp = sp->wp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next)
+ LIST_FOREACH(cbp, &sp->wp->cutq, q)
switch(cbp->name) {
case L('1'):
cbp->name = L('2');
@@ -262,7 +262,7 @@
}
/* Append to the end of the cut buffer. */
- CIRCLEQ_INSERT_TAIL(&cbp->textq, tp, q);
+ TAILQ_INSERT_TAIL(&cbp->textq, tp, q);
cbp->len += tp->len;
return (0);
@@ -280,8 +280,8 @@
CB *cbp;
/* Free cut buffer list. */
- while ((cbp = wp->cutq.lh_first) != NULL) {
- if (cbp->textq.cqh_first != (void *)&cbp->textq)
+ while ((cbp = LIST_FIRST(&wp->cutq)) != NULL) {
+ if (!TAILQ_EMPTY(&cbp->textq))
text_lfree(&cbp->textq);
LIST_REMOVE(cbp, q);
free(cbp);
@@ -289,7 +289,7 @@
/* Free default cut storage. */
cbp = &wp->dcb_store;
- if (cbp->textq.cqh_first != (void *)&cbp->textq)
+ if (!TAILQ_EMPTY(&cbp->textq))
text_lfree(&cbp->textq);
}
@@ -332,8 +332,8 @@
{
TEXT *tp;
- while ((tp = headp->cqh_first) != (void *)headp) {
- CIRCLEQ_REMOVE(headp, tp, q);
+ while ((tp = TAILQ_FIRST(headp)) != NULL) {
+ TAILQ_REMOVE(headp, tp, q);
text_free(tp);
}
}
diff -r 093b02cde3b5 -r 8fb2c8872a1f external/bsd/nvi/dist/common/cut.h
--- a/external/bsd/nvi/dist/common/cut.h Mon Nov 25 16:29:25 2013 +0000
+++ b/external/bsd/nvi/dist/common/cut.h Mon Nov 25 22:43:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cut.h,v 1.2 2013/11/22 15:52:05 christos Exp $ */
+/* $NetBSD: cut.h,v 1.3 2013/11/25 22:43:46 christos Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -11,7 +11,7 @@
*/
typedef struct _texth TEXTH; /* TEXT list head structure. */
-CIRCLEQ_HEAD(_texth, _text);
+TAILQ_HEAD(_texth, _text);
/* Cut buffers. */
struct _cb {
@@ -27,7 +27,7 @@
/* Lines/blocks of text. */
struct _text { /* Text: a linked list of lines. */
- CIRCLEQ_ENTRY(_text) q; /* Linked list of text structures. */
+ TAILQ_ENTRY(_text) q; /* Linked list of text structures. */
CHAR_T *lb; /* Line buffer. */
size_t lb_len; /* Line buffer length. */
size_t len; /* Line length. */
diff -r 093b02cde3b5 -r 8fb2c8872a1f external/bsd/nvi/dist/common/exf.c
--- a/external/bsd/nvi/dist/common/exf.c Mon Nov 25 16:29:25 2013 +0000
+++ b/external/bsd/nvi/dist/common/exf.c Mon Nov 25 22:43:46 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exf.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
+/* $NetBSD: exf.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -77,15 +77,12 @@
*/
gp = sp->gp;
if (name != NULL)
- for (frp = gp->frefq.cqh_first;
- frp != (FREF *)(void *)&gp->frefq; frp = frp->q.cqe_next) {
+ TAILQ_FOREACH_SAFE(frp, &gp->frefq, q, tfrp) {
if (frp->name == NULL) {
- tfrp = frp->q.cqe_next;
- CIRCLEQ_REMOVE(&gp->frefq, frp, q);
+ TAILQ_REMOVE(&gp->frefq, frp, q);
if (frp->name != NULL)
free(frp->name);
free(frp);
- frp = tfrp;
continue;
}
if (!strcmp(frp->name, name))
@@ -110,7 +107,7 @@
}
/* Append into the chain of file names. */
- CIRCLEQ_INSERT_TAIL(&gp->frefq, frp, q);
+ TAILQ_INSERT_TAIL(&gp->frefq, frp, q);
return (frp);
}
@@ -165,8 +162,7 @@
*/
if (exists) {
EXF *exfp;
- for (exfp = sp->gp->exfq.cqh_first;
- exfp != (EXF *)&sp->gp->exfq; exfp = exfp->q.cqe_next) {
+ TAILQ_FOREACH(exfp, &sp->gp->exfq, q) {
if (exfp->mdev == sb.st_dev &&
exfp->minode == sb.st_ino &&
(exfp != sp->ep || exfp->refcnt > 1)) {
@@ -184,7 +180,7 @@
* Set initial EXF flag bits.
*/
Home |
Main Index |
Thread Index |
Old Index