diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-11-25 23:27:12 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-11-25 23:27:12 +0000 |
commit | 6f581aba60a8f680856da3c901973b3dab492ec5 (patch) | |
tree | 38089be69f9759fd0d0eb3ae6dedaff63a67b027 /usr.bin/vi/ex | |
parent | 363922592d53d3db6ac4873fcc21776988c9ade4 (diff) |
Replace _texth CIRCLEQ with TAILQ. One down, five to go.
Read, tested, fixed and ok'd zhuk@ pelikan@ millert@
Diffstat (limited to 'usr.bin/vi/ex')
-rw-r--r-- | usr.bin/vi/ex/ex.c | 4 | ||||
-rw-r--r-- | usr.bin/vi/ex/ex_append.c | 10 | ||||
-rw-r--r-- | usr.bin/vi/ex/ex_at.c | 11 | ||||
-rw-r--r-- | usr.bin/vi/ex/ex_cscope.c | 6 | ||||
-rw-r--r-- | usr.bin/vi/ex/ex_display.c | 8 | ||||
-rw-r--r-- | usr.bin/vi/ex/ex_move.c | 4 | ||||
-rw-r--r-- | usr.bin/vi/ex/ex_subst.c | 6 | ||||
-rw-r--r-- | usr.bin/vi/ex/ex_txt.c | 14 |
8 files changed, 33 insertions, 30 deletions
diff --git a/usr.bin/vi/ex/ex.c b/usr.bin/vi/ex/ex.c index 6c352e3b7c7..5da0f2cf5b5 100644 --- a/usr.bin/vi/ex/ex.c +++ b/usr.bin/vi/ex/ex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex.c,v 1.16 2009/10/27 23:59:47 deraadt Exp $ */ +/* $OpenBSD: ex.c,v 1.17 2013/11/25 23:27:11 krw Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -116,7 +116,7 @@ ex(spp) * If the user entered a single carriage return, send * ex_cmd() a separator -- it discards single newlines. */ - tp = CIRCLEQ_FIRST(&sp->tiq); + tp = TAILQ_FIRST(&sp->tiq); if (tp->len == 0) { gp->excmd.cp = " "; /* __TK__ why not |? */ gp->excmd.clen = 1; diff --git a/usr.bin/vi/ex/ex_append.c b/usr.bin/vi/ex/ex_append.c index 686ed84b370..b3d78061714 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.8 2009/10/27 23:59:47 deraadt Exp $ */ +/* $OpenBSD: ex_append.c,v 1.9 2013/11/25 23:27:11 krw Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -253,15 +253,17 @@ ex_aci(sp, cmdp, cmd) * into the file, above.) */ memset(&tiq, 0, sizeof(TEXTH)); - CIRCLEQ_INIT(&tiq); + TAILQ_INIT(&tiq); if (ex_txt(sp, &tiq, 0, flags)) return (1); - for (cnt = 0, tp = CIRCLEQ_FIRST(&tiq); - tp != (TEXT *)&tiq; ++cnt, tp = CIRCLEQ_NEXT(tp, q)) + cnt = 0; + TAILQ_FOREACH(tp, &tiq, q) { if (db_append(sp, 1, lno++, tp->lb, tp->len)) return (1); + cnt++; + } /* * Set sp->lno to the final line number value (correcting for a diff --git a/usr.bin/vi/ex/ex_at.c b/usr.bin/vi/ex/ex_at.c index e3fd1832146..e695189847e 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.8 2009/10/27 23:59:47 deraadt Exp $ */ +/* $OpenBSD: ex_at.c,v 1.9 2013/11/25 23:27:11 krw Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -102,9 +102,10 @@ 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 = CIRCLEQ_LAST(&cbp->textq); - tp != CIRCLEQ_END(&cbp->textq); tp = CIRCLEQ_PREV(tp, q)) + len = 0; + TAILQ_FOREACH_REVERSE(tp, &cbp->textq, _texth, q) { len += tp->len + 1; + } MALLOC_RET(sp, ecp->cp, char *, len * 2); ecp->o_cp = ecp->cp; @@ -112,8 +113,8 @@ ex_at(sp, cmdp) ecp->cp[len] = '\0'; /* Copy the buffer into the command space. */ - for (p = ecp->cp + len, tp = CIRCLEQ_LAST(&cbp->textq); - tp != CIRCLEQ_END(&cbp->textq); tp = CIRCLEQ_PREV(tp, q)) { + p = ecp->cp + len; + TAILQ_FOREACH_REVERSE(tp, &cbp->textq, _texth, 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 060bee19f6f..8c2fd7511a9 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.17 2013/08/22 04:43:40 guenther Exp $ */ +/* $OpenBSD: ex_cscope.c,v 1.18 2013/11/25 23:27:11 krw Exp $ */ /*- * Copyright (c) 1994, 1996 @@ -625,8 +625,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 = CIRCLEQ_FIRST(&cbp->textq)->lb; - tlen = CIRCLEQ_FIRST(&cbp->textq)->len; + p = TAILQ_FIRST(&cbp->textq)->lb; + tlen = TAILQ_FIRST(&cbp->textq)->len; } else tlen = strlen(p); diff --git a/usr.bin/vi/ex/ex_display.c b/usr.bin/vi/ex/ex_display.c index ce5c0ed4520..bb717e48ced 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.7 2009/10/27 23:59:47 deraadt Exp $ */ +/* $OpenBSD: ex_display.c,v 1.8 2013/11/25 23:27:11 krw Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -92,7 +92,7 @@ bdisplay(sp) LIST_FOREACH(cbp, &sp->gp->cutq, q) { if (isdigit(cbp->name)) continue; - if (CIRCLEQ_FIRST(&cbp->textq) != CIRCLEQ_END(&cbp->textq)) + if (!TAILQ_EMPTY(&cbp->textq)) db(sp, cbp, NULL); if (INTERRUPTED(sp)) return (0); @@ -101,7 +101,7 @@ bdisplay(sp) LIST_FOREACH(cbp, &sp->gp->cutq, q) { if (!isdigit(cbp->name)) continue; - if (CIRCLEQ_FIRST(&cbp->textq) != CIRCLEQ_END(&cbp->textq)) + if (!TAILQ_EMPTY(&cbp->textq)) db(sp, cbp, NULL); if (INTERRUPTED(sp)) return (0); @@ -129,7 +129,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)"); - CIRCLEQ_FOREACH(tp, &cbp->textq, q) { + TAILQ_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_move.c b/usr.bin/vi/ex/ex_move.c index 95e8261e529..7a7651a88be 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.8 2009/10/27 23:59:47 deraadt Exp $ */ +/* $OpenBSD: ex_move.c,v 1.9 2013/11/25 23:27:11 krw Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -50,7 +50,7 @@ ex_copy(sp, cmdp) fm1 = cmdp->addr1; fm2 = cmdp->addr2; memset(&cb, 0, sizeof(cb)); - CIRCLEQ_INIT(&cb.textq); + TAILQ_INIT(&cb.textq); for (cnt = fm1.lno; cnt <= fm2.lno; ++cnt) if (cut_line(sp, cnt, 0, CUT_LINE_TO_EOL, &cb)) { rval = 1; diff --git a/usr.bin/vi/ex/ex_subst.c b/usr.bin/vi/ex/ex_subst.c index 3b2053bac3a..c52ab9d0bea 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.17 2009/10/27 23:59:47 deraadt Exp $ */ +/* $OpenBSD: ex_subst.c,v 1.18 2013/11/25 23:27:11 krw Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -444,7 +444,7 @@ s(sp, cmdp, s, re, flags) /* Ex text structure initialization. */ if (F_ISSET(sp, SC_EX)) { memset(&tiq, 0, sizeof(TEXTH)); - CIRCLEQ_INIT(&tiq); + TAILQ_INIT(&tiq); } break; case 'g': @@ -659,7 +659,7 @@ nextmatch: match[0].rm_so = 0; goto lquit; if (ex_txt(sp, &tiq, 0, TXT_CR)) goto err; - ev.e_c = CIRCLEQ_FIRST(&tiq)->lb[0]; + ev.e_c = TAILQ_FIRST(&tiq)->lb[0]; } switch (ev.e_c) { diff --git a/usr.bin/vi/ex/ex_txt.c b/usr.bin/vi/ex/ex_txt.c index 5d6e7b5c776..ed2bb3f1b70 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.10 2009/10/27 23:59:47 deraadt Exp $ */ +/* $OpenBSD: ex_txt.c,v 1.11 2013/11/25 23:27:11 krw Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -70,9 +70,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 (CIRCLEQ_FIRST(tiqh) != CIRCLEQ_END(tiqh)) { - tp = CIRCLEQ_FIRST(tiqh); - if (CIRCLEQ_NEXT(tp, q) != CIRCLEQ_END(tiqh) || tp->lb_len < 32) { + if (!TAILQ_EMPTY(tiqh)) { + tp = TAILQ_FIRST(tiqh); + if (TAILQ_NEXT(tp, q) || tp->lb_len < 32) { text_lfree(tiqh); goto newtp; } @@ -80,7 +80,7 @@ ex_txt(sp, tiqh, prompt, flags) } else { newtp: if ((tp = text_init(sp, NULL, 0, 32)) == NULL) goto err; - CIRCLEQ_INSERT_HEAD(tiqh, tp, q); + TAILQ_INSERT_HEAD(tiqh, tp, q); } /* Set the starting line number. */ @@ -187,7 +187,7 @@ newtp: if ((tp = text_init(sp, NULL, 0, 32)) == NULL) */ if (LF_ISSET(TXT_DOTTERM) && tp->len == tp->ai + 1 && tp->lb[tp->len - 1] == '.') { -notlast: CIRCLEQ_REMOVE(tiqh, tp, q); +notlast: TAILQ_REMOVE(tiqh, tp, q); text_free(tp); goto done; } @@ -224,7 +224,7 @@ notlast: CIRCLEQ_REMOVE(tiqh, tp, q); * into the queue. */ tp = ntp; - CIRCLEQ_INSERT_TAIL(tiqh, tp, q); + TAILQ_INSERT_TAIL(tiqh, tp, q); break; case K_CARAT: /* Delete autoindent chars. */ if (tp->len <= tp->ai && LF_ISSET(TXT_AUTOINDENT)) |