aboutsummaryrefslogtreecommitdiffstats
path: root/vi
diff options
context:
space:
mode:
Diffstat (limited to 'vi')
-rw-r--r--vi/v_itxt.c4
-rw-r--r--vi/v_paragraph.c10
-rw-r--r--vi/v_section.c3
-rw-r--r--vi/v_sentence.c3
-rw-r--r--vi/v_txt.c11
-rw-r--r--vi/vi.c4
-rw-r--r--vi/vs_line.c10
-rw-r--r--vi/vs_msg.c13
-rw-r--r--vi/vs_refresh.c9
-rw-r--r--vi/vs_relative.c7
-rw-r--r--vi/vs_smap.c4
11 files changed, 46 insertions, 32 deletions
diff --git a/vi/v_itxt.c b/vi/v_itxt.c
index 704a0c322176..3c69ed7065fe 100644
--- a/vi/v_itxt.c
+++ b/vi/v_itxt.c
@@ -48,10 +48,10 @@
* position.) We also check for mapped keys waiting, i.e. if we're in the
* middle of a map, don't bother logging the cursor.
*/
-#define LOG_CORRECT { \
+#define LOG_CORRECT do { \
if (!MAPPED_KEYS_WAITING(sp)) \
(void)log_cursor(sp); \
-}
+} while (0)
static u_int32_t set_txt_std(SCR *, VICMD *, u_int32_t);
diff --git a/vi/v_paragraph.c b/vi/v_paragraph.c
index e3fdce969695..abe8d9cf50e0 100644
--- a/vi/v_paragraph.c
+++ b/vi/v_paragraph.c
@@ -23,7 +23,7 @@
#include "../common/common.h"
#include "vi.h"
-#define INTEXT_CHECK { \
+#define INTEXT_CHECK do { \
if (len == 0 || v_isempty(p, len)) { \
if (!--cnt) \
goto found; \
@@ -48,7 +48,7 @@
(lp[1] == ' ' && len == 2 || lp[1] == p[2]) && \
!--cnt) \
goto found; \
-}
+} while (0)
/*
* v_paragraphf -- [count]}
@@ -83,7 +83,7 @@ v_paragraphf(SCR *sp, VICMD *vp)
* line itself remained. If somebody complains, don't pause, don't
* hesitate, just hit them.
*/
- if (ISMOTION(vp))
+ if (ISMOTION(vp)) {
if (vp->m_start.cno == 0)
F_SET(vp, VM_LMODE);
else {
@@ -94,6 +94,7 @@ v_paragraphf(SCR *sp, VICMD *vp)
if (vp->m_start.cno <= vp->m_stop.cno)
F_SET(vp, VM_LMODE);
}
+ }
/* Figure out what state we're currently in. */
lno = vp->m_start.lno;
@@ -226,7 +227,7 @@ v_paragraphb(SCR *sp, VICMD *vp)
*/
lno = vp->m_start.lno;
- if (ISMOTION(vp))
+ if (ISMOTION(vp)) {
if (vp->m_start.cno == 0) {
if (vp->m_start.lno == 1) {
v_sof(sp, &vp->m_start);
@@ -236,6 +237,7 @@ v_paragraphb(SCR *sp, VICMD *vp)
F_SET(vp, VM_LMODE);
} else
--vp->m_start.cno;
+ }
if (vp->m_start.lno <= 1)
goto sof;
diff --git a/vi/v_section.c b/vi/v_section.c
index 5314f4621ad0..09da4bac38ee 100644
--- a/vi/v_section.c
+++ b/vi/v_section.c
@@ -77,7 +77,7 @@ v_sectionf(SCR *sp, VICMD *vp)
* check here, because we know that the end is going to be the start
* or end of a line.
*/
- if (ISMOTION(vp))
+ if (ISMOTION(vp)) {
if (vp->m_start.cno == 0)
F_SET(vp, VM_LMODE);
else {
@@ -88,6 +88,7 @@ v_sectionf(SCR *sp, VICMD *vp)
if (vp->m_start.cno <= vp->m_stop.cno)
F_SET(vp, VM_LMODE);
}
+ }
cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1;
for (lno = vp->m_start.lno; !db_get(sp, ++lno, 0, &p, &len);) {
diff --git a/vi/v_sentence.c b/vi/v_sentence.c
index 3415fbd18937..4ba9cfc1df33 100644
--- a/vi/v_sentence.c
+++ b/vi/v_sentence.c
@@ -336,7 +336,7 @@ okret: vp->m_stop.lno = cs.cs_lno;
* All commands move to the end of the range. Adjust the start of
* the range for motion commands.
*/
- if (ISMOTION(vp))
+ if (ISMOTION(vp)) {
if (vp->m_start.cno == 0 &&
(cs.cs_flags != 0 || vp->m_stop.cno == 0)) {
if (db_get(sp,
@@ -346,6 +346,7 @@ okret: vp->m_stop.lno = cs.cs_lno;
F_SET(vp, VM_LMODE);
} else
--vp->m_start.cno;
+ }
vp->m_final = vp->m_stop;
return (0);
}
diff --git a/vi/v_txt.c b/vi/v_txt.c
index 84d20c6ad1c1..c6dc7cee4659 100644
--- a/vi/v_txt.c
+++ b/vi/v_txt.c
@@ -221,10 +221,10 @@ txt_map_end(SCR *sp)
* Internally, we maintain tp->lno and tp->cno, externally, everyone uses
* sp->lno and sp->cno. Make them consistent as necessary.
*/
-#define UPDATE_POSITION(sp, tp) { \
+#define UPDATE_POSITION(sp, tp) do { \
(sp)->lno = (tp)->lno; \
(sp)->cno = (tp)->cno; \
-}
+} while (0)
/*
* v_txt --
@@ -677,7 +677,7 @@ k_cr: if (LF_ISSET(TXT_CR)) {
goto k_escape;
}
-#define LINE_RESOLVE { \
+#define LINE_RESOLVE do { \
/* \
* Handle abbreviations. If there was one, discard the \
* replay characters. \
@@ -708,7 +708,7 @@ k_cr: if (LF_ISSET(TXT_CR)) {
--tp->len; \
--tp->insert; \
} \
-}
+} while (0)
LINE_RESOLVE;
/*
@@ -1527,7 +1527,7 @@ txt_abbrev(SCR *sp, TEXT *tp, CHAR_T *pushcp, int isinfoline, int *didsubp, int
*
* This makes the layering look like a Nachos Supreme.
*/
-search: if (isinfoline)
+search: if (isinfoline) {
if (off == tp->ai || off == tp->offset)
if (ex_is_abbrev(p, len)) {
*turnoffp = 1;
@@ -1537,6 +1537,7 @@ search: if (isinfoline)
else
if (*turnoffp)
return (0);
+ }
/* Check for any abbreviations. */
if ((qp = seq_find(sp, NULL, NULL, p, len, SEQ_ABBREV, NULL)) == NULL)
diff --git a/vi/vi.c b/vi/vi.c
index 27ace47a8ea3..af0b7598beea 100644
--- a/vi/vi.c
+++ b/vi/vi.c
@@ -405,7 +405,7 @@ ret: rval = 1;
return (rval);
}
-#define KEY(key, ec_flags) { \
+#define KEY(key, ec_flags) do { \
if ((gcret = v_key(sp, 0, &ev, ec_flags)) != GC_OK) \
return (gcret); \
if (ev.e_value == K_ESCAPE) \
@@ -413,7 +413,7 @@ ret: rval = 1;
if (F_ISSET(&ev.e_ch, CH_MAPPED)) \
*mappedp = 1; \
key = ev.e_c; \
-}
+} while (0)
/*
* The O_TILDEOP option makes the ~ command take a motion instead
diff --git a/vi/vs_line.c b/vi/vs_line.c
index 3bb8057ade92..e5778e1971e6 100644
--- a/vi/vs_line.c
+++ b/vi/vs_line.c
@@ -165,7 +165,7 @@ vs_line(SCR *sp, SMAP *smp, size_t *yp, size_t *xp)
* Lots of special cases for empty lines, but they only apply
* if we're displaying the first screen of the line.
*/
- if (skip_cols == 0)
+ if (skip_cols == 0) {
if (dne) {
if (smp->lno == 1) {
if (list_dollar) {
@@ -176,12 +176,14 @@ vs_line(SCR *sp, SMAP *smp, size_t *yp, size_t *xp)
ch = '~';
goto empty;
}
- } else
+ } else {
if (list_dollar) {
ch = '$';
empty: (void)gp->scr_addstr(sp,
KEY_NAME(sp, ch), KEY_LEN(sp, ch));
}
+ }
+ }
(void)gp->scr_clrtoeol(sp);
(void)gp->scr_move(sp, oldy, oldx);
@@ -402,11 +404,11 @@ display:
if (is_cached || no_draw)
continue;
-#define FLUSH { \
+#define FLUSH do { \
*cbp = '\0'; \
(void)gp->scr_waddstr(sp, cbuf, cbp - cbuf); \
cbp = cbuf; \
-}
+} while (0)
/*
* Display the character. We do tab expansion here because
* the screen interface doesn't have any way to set the tab
diff --git a/vi/vs_msg.c b/vi/vs_msg.c
index d6144bca692c..25421f0bb1e2 100644
--- a/vi/vs_msg.c
+++ b/vi/vs_msg.c
@@ -240,12 +240,13 @@ vs_msg(SCR *sp, mtype_t mtype, char *line, size_t len)
* XXX
* Shouldn't we save this, too?
*/
- if (F_ISSET(sp, SC_TINPUT_INFO) || F_ISSET(gp, G_BELLSCHED))
+ if (F_ISSET(sp, SC_TINPUT_INFO) || F_ISSET(gp, G_BELLSCHED)) {
if (F_ISSET(sp, SC_SCR_VI)) {
F_CLR(gp, G_BELLSCHED);
(void)gp->scr_bell(sp);
} else
F_SET(gp, G_BELLSCHED);
+ }
/*
* If vi is using the error line for text input, there's no screen
@@ -271,13 +272,14 @@ vs_msg(SCR *sp, mtype_t mtype, char *line, size_t len)
* the screen, so previous opinions are ignored.
*/
if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE)) {
- if (!F_ISSET(sp, SC_SCR_EX))
+ if (!F_ISSET(sp, SC_SCR_EX)) {
if (F_ISSET(sp, SC_SCR_EXWROTE)) {
if (sp->gp->scr_screen(sp, SC_EX))
return;
} else
if (ex_init(sp))
return;
+ }
if (mtype == M_ERR)
(void)gp->scr_attr(sp, SA_INVERSE, 1);
@@ -339,13 +341,14 @@ vs_msg(SCR *sp, mtype_t mtype, char *line, size_t len)
padding += 2;
maxcols = sp->cols - 1;
- if (vip->lcontinue != 0)
+ if (vip->lcontinue != 0) {
if (len + vip->lcontinue + padding > maxcols)
vs_output(sp, vip->mtype, ".\n", 2);
else {
vs_output(sp, vip->mtype, ";", 1);
vs_output(sp, M_NONE, " ", 1);
}
+ }
vip->mtype = mtype;
for (s = line;; s = t) {
for (; len > 0 && isblank((u_char)*s); --len, ++s);
@@ -452,11 +455,11 @@ vs_output(SCR *sp, mtype_t mtype, const char *line, int llen)
(void)gp->scr_attr(sp, SA_INVERSE, 1);
/* Display the line, doing character translation. */
-#define FLUSH { \
+#define FLUSH do { \
*cbp = '\0'; \
(void)gp->scr_addstr(sp, cbuf, cbp - cbuf); \
cbp = cbuf; \
-}
+} while (0)
ecbp = (cbp = cbuf) + sizeof(cbuf) - 1;
for (t = line, tlen = len; tlen--; ++t) {
/*
diff --git a/vi/vs_refresh.c b/vi/vs_refresh.c
index a512f0a04c00..b64ec7392cbb 100644
--- a/vi/vs_refresh.c
+++ b/vi/vs_refresh.c
@@ -241,7 +241,7 @@ vs_paint(
* screen but the column offset is not, we'll end up in the adjust
* code, when we should probably have compressed the screen.
*/
- if (IS_SMALL(sp))
+ if (IS_SMALL(sp)) {
if (LNO < HMAP->lno) {
lcnt = vs_sm_nlines(sp, HMAP, LNO, sp->t_maxrows);
if (lcnt <= HALFSCREEN(sp))
@@ -278,6 +278,7 @@ small_fill: (void)gp->scr_move(sp, LASTLINE(sp), 0);
goto adjust;
}
}
+ }
/*
* 6b: Line down, or current screen.
@@ -390,7 +391,7 @@ top: if (vs_sm_fill(sp, LNO, P_TOP))
adjust: if (!O_ISSET(sp, O_LEFTRIGHT) &&
(LNO == HMAP->lno || LNO == TMAP->lno)) {
cnt = vs_screens(sp, LNO, &CNO);
- if (LNO == HMAP->lno && cnt < HMAP->soff)
+ if (LNO == HMAP->lno && cnt < HMAP->soff) {
if ((HMAP->soff - cnt) > HALFTEXT(sp)) {
HMAP->soff = cnt;
vs_sm_fill(sp, OOBLNO, P_TOP);
@@ -399,7 +400,8 @@ adjust: if (!O_ISSET(sp, O_LEFTRIGHT) &&
while (cnt < HMAP->soff)
if (vs_sm_1down(sp))
return (1);
- if (LNO == TMAP->lno && cnt > TMAP->soff)
+ }
+ if (LNO == TMAP->lno && cnt > TMAP->soff) {
if ((cnt - TMAP->soff) > HALFTEXT(sp)) {
TMAP->soff = cnt;
vs_sm_fill(sp, OOBLNO, P_BOTTOM);
@@ -408,6 +410,7 @@ adjust: if (!O_ISSET(sp, O_LEFTRIGHT) &&
while (cnt > TMAP->soff)
if (vs_sm_1up(sp))
return (1);
+ }
}
/*
diff --git a/vi/vs_relative.c b/vi/vs_relative.c
index 5df8c3c3f22d..353dcbe9d572 100644
--- a/vi/vs_relative.c
+++ b/vi/vs_relative.c
@@ -142,15 +142,16 @@ done: if (diffp != NULL) /* XXX */
* last column of the screen. Otherwise, display the rest of the
* character in the next screen.
*/
-#define TAB_RESET { \
+#define TAB_RESET do { \
curoff += chlen; \
- if (!leftright && curoff >= sp->cols) \
+ if (!leftright && curoff >= sp->cols) { \
if (ch == '\t') { \
curoff = 0; \
scno -= scno % sp->cols; \
} else \
curoff -= sp->cols; \
-}
+ } \
+} while (0)
if (cnop == NULL)
while (len--) {
chlen = CHLEN(curoff);
diff --git a/vi/vs_smap.c b/vi/vs_smap.c
index 971502ebd62b..2c0f2a4d94d3 100644
--- a/vi/vs_smap.c
+++ b/vi/vs_smap.c
@@ -292,12 +292,12 @@ err: HMAP->lno = 1;
* so the screen map is refilled and the screen redrawn, and return. This
* is amazingly slow, but it's not clear that anyone will care.
*/
-#define HANDLE_WEIRDNESS(cnt) { \
+#define HANDLE_WEIRDNESS(cnt) do { \
if (cnt >= sp->t_rows) { \
F_SET(sp, SC_SCR_REFORMAT); \
return (0); \
} \
-}
+} while (0)
/*
* vs_sm_delete --