diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-01-08 21:05:41 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-01-08 21:05:41 +0000 |
commit | fcde5ec1a7e7dda343ba822c73be5f080b0ff0c8 (patch) | |
tree | fae8f53125cc8dbd05f4b107c32d3733dbfdd6da | |
parent | e36b0788688a5dd823dc99c40167de645deb9988 (diff) |
Explicit braces around macro fields and logical operations, gets rid of 148
warnings, no functional change.
From Ray Lai.
54 files changed, 352 insertions, 317 deletions
diff --git a/usr.bin/vi/catalog/dump.c b/usr.bin/vi/catalog/dump.c index 49ec8e4cf6b..e8950ec5773 100644 --- a/usr.bin/vi/catalog/dump.c +++ b/usr.bin/vi/catalog/dump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dump.c,v 1.3 2003/06/03 02:56:21 millert Exp $ */ +/* $OpenBSD: dump.c,v 1.4 2006/01/08 21:05:38 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -49,7 +49,7 @@ parse(fp) int ch, s1, s2, s3; #define TESTD(s) { \ - if ((s = getc(fp)) == EOF) \ + if (((s) = getc(fp)) == EOF) \ return; \ if (!isdigit(s)) \ continue; \ diff --git a/usr.bin/vi/cl/cl.h b/usr.bin/vi/cl/cl.h index babb122d1e5..f54c5babf75 100644 --- a/usr.bin/vi/cl/cl.h +++ b/usr.bin/vi/cl/cl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cl.h,v 1.6 2001/01/29 01:58:26 niklas Exp $ */ +/* $OpenBSD: cl.h,v 1.7 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -54,7 +54,7 @@ typedef struct _cl_private { } CL_PRIVATE; #define CLP(sp) ((CL_PRIVATE *)((sp)->gp->cl_private)) -#define GCLP(gp) ((CL_PRIVATE *)gp->cl_private) +#define GCLP(gp) ((CL_PRIVATE *)(gp)->cl_private) /* Return possibilities from the keyboard read routine. */ typedef enum { INP_OK=0, INP_EOF, INP_ERR, INP_INTR, INP_TIMEOUT } input_t; diff --git a/usr.bin/vi/cl/cl_main.c b/usr.bin/vi/cl/cl_main.c index a33ecaadc94..7d5a32bf160 100644 --- a/usr.bin/vi/cl/cl_main.c +++ b/usr.bin/vi/cl/cl_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cl_main.c,v 1.14 2003/07/18 23:11:43 david Exp $ */ +/* $OpenBSD: cl_main.c,v 1.15 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -196,7 +196,6 @@ static GS * gs_init(name) char *name; { - CL_PRIVATE *clp; GS *gp; char *p; diff --git a/usr.bin/vi/cl/cl_screen.c b/usr.bin/vi/cl/cl_screen.c index a870d1bc63e..6f786ad6389 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.16 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: cl_screen.c,v 1.17 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -64,8 +64,8 @@ cl_screen(sp, flags) } /* See if we're already in the right mode. */ - if (LF_ISSET(SC_EX) && F_ISSET(sp, SC_SCR_EX) || - LF_ISSET(SC_VI) && F_ISSET(sp, SC_SCR_VI)) + if ((LF_ISSET(SC_EX) && F_ISSET(sp, SC_SCR_EX)) || + (LF_ISSET(SC_VI) && F_ISSET(sp, SC_SCR_VI))) return (0); /* diff --git a/usr.bin/vi/cl/cl_term.c b/usr.bin/vi/cl/cl_term.c index cbfb8119168..5269d69dd31 100644 --- a/usr.bin/vi/cl/cl_term.c +++ b/usr.bin/vi/cl/cl_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cl_term.c,v 1.13 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: cl_term.c,v 1.14 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -412,16 +412,18 @@ cl_ssize(sp, sigwinch, rowp, colp, changedp) if (row == 0 || col == 0) { if ((p = getenv("TERM")) == NULL) goto noterm; - if (row == 0) + if (row == 0) { if ((rval = tigetnum("lines")) < 0) msgq(sp, M_SYSERR, "tigetnum: lines"); else row = rval; - if (col == 0) + } + if (col == 0) { if ((rval = tigetnum("cols")) < 0) msgq(sp, M_SYSERR, "tigetnum: cols"); else col = rval; + } } /* If nothing else, well, it's probably a VT100. */ diff --git a/usr.bin/vi/common/cut.c b/usr.bin/vi/common/cut.c index c5beeb8fb0d..0148bdb6cbe 100644 --- a/usr.bin/vi/common/cut.c +++ b/usr.bin/vi/common/cut.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cut.c,v 1.8 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: cut.c,v 1.9 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -102,8 +102,8 @@ cut(sp, namep, fm, tm, flags) append = copy_one = copy_def = 0; if (namep != NULL) { name = *namep; - if (LF_ISSET(CUT_NUMREQ) || LF_ISSET(CUT_NUMOPT) && - (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno)) { + if (LF_ISSET(CUT_NUMREQ) || (LF_ISSET(CUT_NUMOPT) && + (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno))) { copy_one = 1; cb_rotate(sp); } @@ -113,8 +113,8 @@ cut(sp, namep, fm, tm, flags) name = tolower(name); } namecb: CBNAME(sp, cbp, name); - } else if (LF_ISSET(CUT_NUMREQ) || LF_ISSET(CUT_NUMOPT) && - (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno)) { + } else if (LF_ISSET(CUT_NUMREQ) || (LF_ISSET(CUT_NUMOPT) && + (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno))) { name = '1'; cb_rotate(sp); goto namecb; diff --git a/usr.bin/vi/common/cut.h b/usr.bin/vi/common/cut.h index 8ea31d58040..7433453b306 100644 --- a/usr.bin/vi/common/cut.h +++ b/usr.bin/vi/common/cut.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cut.h,v 1.5 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: cut.h,v 1.6 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -68,7 +68,7 @@ struct _text { /* Text: a linked list of lines. */ CHAR_T L__name; \ L__name = isupper(nch) ? tolower(nch) : (nch); \ LIST_FOREACH((cbp), &(sp)->gp->cutq, q) \ - if (cbp->name == L__name) \ + if ((cbp)->name == L__name) \ break; \ } diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c index 065ac0d8af9..64fe61249a5 100644 --- a/usr.bin/vi/common/exf.c +++ b/usr.bin/vi/common/exf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exf.c,v 1.21 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: exf.c,v 1.22 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -209,7 +209,7 @@ file_init(sp, frp, rcv_name, flags) if (frp->name == NULL) F_SET(frp, FR_TMPFILE); if ((frp->tname = strdup(tname)) == NULL || - frp->name == NULL && (frp->name = strdup(tname)) == NULL) { + (frp->name == NULL && (frp->name = strdup(tname)) == NULL)) { if (frp->tname != NULL) free(frp->tname); msgq(sp, M_SYSERR, NULL); @@ -406,9 +406,9 @@ file_init(sp, frp, rcv_name, flags) * probably isn't a problem for vi when it's running standalone. */ if (readonly || F_ISSET(sp, SC_READONLY) || - !F_ISSET(frp, FR_NEWFILE) && + (!F_ISSET(frp, FR_NEWFILE) && (!(sb.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)) || - access(frp->name, W_OK))) + access(frp->name, W_OK)))) O_SET(sp, O_READONLY); else O_CLR(sp, O_READONLY); @@ -476,8 +476,8 @@ file_spath(sp, frp, sbp, existsp) *existsp = 0; return (0); } - if (name[0] == '/' || name[0] == '.' && - (name[1] == '/' || name[1] == '.' && name[2] == '/')) { + if (name[0] == '/' || (name[0] == '.' && + (name[1] == '/' || (name[1] == '.' && name[2] == '/')))) { *existsp = !stat(name, sbp); return (0); } @@ -824,8 +824,8 @@ file_write(sp, fm, tm, name, flags) mtype = NEWFILE; else { if (noname && !LF_ISSET(FS_FORCE | FS_APPEND) && - (F_ISSET(ep, F_DEVSET) && - (sb.st_dev != ep->mdev || sb.st_ino != ep->minode) || + ((F_ISSET(ep, F_DEVSET) && + (sb.st_dev != ep->mdev || sb.st_ino != ep->minode)) || sb.st_mtime != ep->mtime)) { msgq_str(sp, M_ERR, name, LF_ISSET(FS_POSSIBLE) ? "250|%s: file modified more recently than this copy; use ! to override" : @@ -906,7 +906,7 @@ file_write(sp, fm, tm, name, flags) * we re-init the time. That way the user can clean up the disk * and rewrite without having to force it. */ - if (noname) + if (noname) { if (stat(name, &sb)) time(&ep->mtime); else { @@ -916,6 +916,7 @@ file_write(sp, fm, tm, name, flags) ep->mtime = sb.st_mtime; } + } /* * If the write failed, complain loudly. ex_writefp() has already @@ -944,11 +945,12 @@ file_write(sp, fm, tm, name, flags) */ if (LF_ISSET(FS_ALL) && !LF_ISSET(FS_APPEND)) { F_CLR(ep, F_MODIFIED); - if (F_ISSET(frp, FR_TMPFILE)) + if (F_ISSET(frp, FR_TMPFILE)) { if (noname) F_SET(frp, FR_TMPEXIT); else F_CLR(frp, FR_TMPEXIT); + } } p = msg_print(sp, name, &nf); @@ -1260,7 +1262,7 @@ file_m1(sp, force, flags) * unless force is also set. Otherwise, we fail unless forced or * there's another open screen on this file. */ - if (F_ISSET(ep, F_MODIFIED)) + if (F_ISSET(ep, F_MODIFIED)) { if (O_ISSET(sp, O_AUTOWRITE)) { if (!force && file_aw(sp, flags)) return (1); @@ -1270,6 +1272,7 @@ file_m1(sp, force, flags) "263|File modified since last complete write; write or use :edit! to override"); return (1); } + } return (file_m3(sp, force)); } diff --git a/usr.bin/vi/common/gs.h b/usr.bin/vi/common/gs.h index eca92f90ee5..b3c0fd42808 100644 --- a/usr.bin/vi/common/gs.h +++ b/usr.bin/vi/common/gs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gs.h,v 1.8 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: gs.h,v 1.9 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -119,10 +119,12 @@ struct _gs { #define MAX_FAST_KEY 254 /* Max fast check character.*/ #define KEY_LEN(sp, ch) \ ((unsigned char)(ch) <= MAX_FAST_KEY ? \ - sp->gp->cname[(unsigned char)ch].len : v_key_len(sp, ch)) + (sp)->gp->cname[(unsigned char)(ch)].len : \ + v_key_len((sp), (ch))) #define KEY_NAME(sp, ch) \ ((unsigned char)(ch) <= MAX_FAST_KEY ? \ - sp->gp->cname[(unsigned char)ch].name : v_key_name(sp, ch)) + (sp)->gp->cname[(unsigned char)(ch)].name : \ + v_key_name((sp), (ch))) struct { CHAR_T name[MAX_CHARACTER_COLUMNS + 1]; u_int8_t len; @@ -130,8 +132,9 @@ struct _gs { #define KEY_VAL(sp, ch) \ ((unsigned char)(ch) <= MAX_FAST_KEY ? \ - sp->gp->special_key[(unsigned char)ch] : \ - (unsigned char)(ch) > sp->gp->max_special ? 0 : v_key_val(sp,ch)) + (sp)->gp->special_key[(unsigned char)(ch)] : \ + (unsigned char)(ch) > (sp)->gp->max_special ? 0 : \ + v_key_val((sp),(ch))) CHAR_T max_special; /* Max special character. */ u_char /* Fast lookup table. */ special_key[MAX_FAST_KEY + 1]; diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c index f08a2039c5a..80b094e69c6 100644 --- a/usr.bin/vi/common/key.c +++ b/usr.bin/vi/common/key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: key.c,v 1.8 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -434,10 +434,10 @@ v_event_append(sp, argp) /* Remove events from the queue. */ #define QREM(len) { \ - if ((gp->i_cnt -= len) == 0) \ + if ((gp->i_cnt -= (len)) == 0) \ gp->i_next = 0; \ else \ - gp->i_next += len; \ + gp->i_next += (len); \ } /* @@ -632,7 +632,7 @@ newmap: evp = &gp->i_event[gp->i_next]; */ if (istimeout || F_ISSET(&evp->e_ch, CH_NOMAP) || !LF_ISSET(EC_MAPCOMMAND | EC_MAPINPUT) || - evp->e_c < MAX_BIT_SEQ && !bit_test(gp->seqb, evp->e_c)) + (evp->e_c < MAX_BIT_SEQ && !bit_test(gp->seqb, evp->e_c))) goto nomap; /* Search the map. */ diff --git a/usr.bin/vi/common/key.h b/usr.bin/vi/common/key.h index 6a82328d053..927081dbeea 100644 --- a/usr.bin/vi/common/key.h +++ b/usr.bin/vi/common/key.h @@ -1,4 +1,4 @@ -/* $OpenBSD: key.h,v 1.3 2001/01/29 01:58:29 niklas Exp $ */ +/* $OpenBSD: key.h,v 1.4 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -134,7 +134,7 @@ extern KEYLIST keylist[]; #define KEYS_WAITING(sp) ((sp)->gp->i_cnt != 0) #define MAPPED_KEYS_WAITING(sp) \ (KEYS_WAITING(sp) && \ - F_ISSET(&sp->gp->i_event[sp->gp->i_next].e_ch, CH_MAPPED)) + F_ISSET(&(sp)->gp->i_event[(sp)->gp->i_next].e_ch, CH_MAPPED)) /* * Ex/vi commands are generally separated by whitespace characters. We @@ -176,7 +176,7 @@ extern KEYLIST keylist[]; #define INTERRUPT_CHECK 100 #define INTERRUPTED(sp) \ (F_ISSET((sp)->gp, G_INTERRUPTED) || \ - (!v_event_get(sp, NULL, 0, EC_INTERRUPT) && \ + (!v_event_get((sp), NULL, 0, EC_INTERRUPT) && \ F_ISSET((sp)->gp, G_INTERRUPTED))) #define CLR_INTERRUPT(sp) \ F_CLR((sp)->gp, G_INTERRUPTED) diff --git a/usr.bin/vi/common/line.c b/usr.bin/vi/common/line.c index 0e64f8c761b..a6d02d99501 100644 --- a/usr.bin/vi/common/line.c +++ b/usr.bin/vi/common/line.c @@ -1,4 +1,4 @@ -/* $OpenBSD: line.c,v 1.6 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: line.c,v 1.7 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -62,7 +62,7 @@ db_eget(sp, lno, pp, lenp, isemptyp) return (1); /* If the file isn't empty, fail loudly. */ - if (lno != 0 && lno != 1 || l1 != 0) { + if ((lno != 0 && lno != 1) || l1 != 0) { db_err(sp, lno); return (1); } diff --git a/usr.bin/vi/common/main.c b/usr.bin/vi/common/main.c index d776e6153a3..7aea5e31ce1 100644 --- a/usr.bin/vi/common/main.c +++ b/usr.bin/vi/common/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.11 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: main.c,v 1.12 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -41,7 +41,9 @@ static const char sccsid[] = "@(#)main.c 10.48 (Berkeley) 10/11/96"; #include "../vi/vi.h" #include "pathnames.h" +#ifdef DEBUG static void attach(GS *); +#endif static void v_estr(char *, int, char *); static int v_obsolete(char *, char *[]); @@ -403,8 +405,8 @@ editor(gp, argc, argv) if (v_event_get(sp, &ev, 0, 0)) goto err; if (ev.e_event == E_INTERRUPT || - ev.e_event == E_CHARACTER && - (ev.e_value == K_CR || ev.e_value == K_NL)) + (ev.e_event == E_CHARACTER && + (ev.e_value == K_CR || ev.e_value == K_NL))) break; (void)gp->scr_bell(sp); } @@ -562,7 +564,7 @@ v_obsolete(name, argv) argv[0][1] = 'c'; (void)strlcpy(argv[0] + 2, p + 1, len); } - } else if (argv[0][0] == '-') + } else if (argv[0][0] == '-') { if (argv[0][1] == '\0') { argv[0] = strdup("-s"); if (argv[0] == NULL) { @@ -574,6 +576,7 @@ nomem: v_estr(name, errno, NULL); argv[0][1] == 't' || argv[0][1] == 'w') && argv[0][2] == '\0') ++argv; + } return (0); } diff --git a/usr.bin/vi/common/mark.c b/usr.bin/vi/common/mark.c index 53427bf0580..18709253911 100644 --- a/usr.bin/vi/common/mark.c +++ b/usr.bin/vi/common/mark.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mark.c,v 1.6 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: mark.c,v 1.7 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -237,12 +237,13 @@ mark_insdel(sp, op, lno) abort(); case LINE_DELETE: LIST_FOREACH(lmp, &sp->ep->marks, q) - if (lmp->lno >= lno) + if (lmp->lno >= lno) { if (lmp->lno == lno) { F_SET(lmp, MARK_DELETED); (void)log_mark(sp, lmp); } else --lmp->lno; + } break; case LINE_INSERT: /* diff --git a/usr.bin/vi/common/mem.h b/usr.bin/vi/common/mem.h index c7826504bb3..f230aa05044 100644 --- a/usr.bin/vi/common/mem.h +++ b/usr.bin/vi/common/mem.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.h,v 1.4 2001/01/29 01:58:30 niklas Exp $ */ +/* $OpenBSD: mem.h,v 1.5 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -16,26 +16,28 @@ */ #define BINC_GOTO(sp, lp, llen, nlen) { \ void *L__bincp; \ - if ((nlen) > llen) { \ - if ((L__bincp = binc(sp, lp, &(llen), nlen)) == NULL) \ + if ((nlen) > (llen)) { \ + if ((L__bincp = binc((sp), (lp), &(llen), (nlen))) \ + == NULL) \ goto alloc_err; \ /* \ * !!! \ * Possible pointer conversion. \ */ \ - lp = L__bincp; \ + (lp) = L__bincp; \ } \ } #define BINC_RET(sp, lp, llen, nlen) { \ void *L__bincp; \ - if ((nlen) > llen) { \ - if ((L__bincp = binc(sp, lp, &(llen), nlen)) == NULL) \ + if ((nlen) > (llen)) { \ + if ((L__bincp = binc((sp), (lp), &(llen), (nlen))) \ + == NULL) \ return (1); \ /* \ * !!! \ * Possible pointer conversion. \ */ \ - lp = L__bincp; \ + (lp) = L__bincp; \ } \ } @@ -47,26 +49,26 @@ #define GET_SPACE_GOTO(sp, bp, blen, nlen) { \ GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \ if (L__gp == NULL || F_ISSET(L__gp, G_TMP_INUSE)) { \ - bp = NULL; \ - blen = 0; \ - BINC_GOTO(sp, bp, blen, nlen); \ + (bp) = NULL; \ + (blen) = 0; \ + BINC_GOTO((sp), (bp), (blen), (nlen)); \ } else { \ - BINC_GOTO(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \ - bp = L__gp->tmp_bp; \ - blen = L__gp->tmp_blen; \ + BINC_GOTO((sp), L__gp->tmp_bp, L__gp->tmp_blen, (nlen));\ + (bp) = L__gp->tmp_bp; \ + (blen) = L__gp->tmp_blen; \ F_SET(L__gp, G_TMP_INUSE); \ } \ } #define GET_SPACE_RET(sp, bp, blen, nlen) { \ GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \ if (L__gp == NULL || F_ISSET(L__gp, G_TMP_INUSE)) { \ - bp = NULL; \ - blen = 0; \ - BINC_RET(sp, bp, blen, nlen); \ + (bp) = NULL; \ + (blen) = 0; \ + BINC_RET((sp), (bp), (blen), (nlen)); \ } else { \ - BINC_RET(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \ - bp = L__gp->tmp_bp; \ - blen = L__gp->tmp_blen; \ + BINC_RET((sp), L__gp->tmp_bp, L__gp->tmp_blen, (nlen)); \ + (bp) = L__gp->tmp_bp; \ + (blen) = L__gp->tmp_blen; \ F_SET(L__gp, G_TMP_INUSE); \ } \ } @@ -77,31 +79,31 @@ */ #define ADD_SPACE_GOTO(sp, bp, blen, nlen) { \ GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \ - if (L__gp == NULL || bp == L__gp->tmp_bp) { \ + if (L__gp == NULL || (bp) == L__gp->tmp_bp) { \ F_CLR(L__gp, G_TMP_INUSE); \ - BINC_GOTO(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \ - bp = L__gp->tmp_bp; \ - blen = L__gp->tmp_blen; \ + BINC_GOTO((sp), L__gp->tmp_bp, L__gp->tmp_blen, (nlen));\ + (bp) = L__gp->tmp_bp; \ + (blen) = L__gp->tmp_blen; \ F_SET(L__gp, G_TMP_INUSE); \ } else \ - BINC_GOTO(sp, bp, blen, nlen); \ + BINC_GOTO((sp), (bp), (blen), (nlen)); \ } #define ADD_SPACE_RET(sp, bp, blen, nlen) { \ GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \ - if (L__gp == NULL || bp == L__gp->tmp_bp) { \ + if (L__gp == NULL || (bp) == L__gp->tmp_bp) { \ F_CLR(L__gp, G_TMP_INUSE); \ - BINC_RET(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \ - bp = L__gp->tmp_bp; \ - blen = L__gp->tmp_blen; \ + BINC_RET((sp), L__gp->tmp_bp, L__gp->tmp_blen, (nlen)); \ + (bp) = L__gp->tmp_bp; \ + (blen) = L__gp->tmp_blen; \ F_SET(L__gp, G_TMP_INUSE); \ } else \ - BINC_RET(sp, bp, blen, nlen); \ + BINC_RET((sp), (bp), (blen), (nlen)); \ } /* Free a GET_SPACE returned buffer. */ #define FREE_SPACE(sp, bp, blen) { \ GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \ - if (L__gp != NULL && bp == L__gp->tmp_bp) \ + if (L__gp != NULL && (bp) == L__gp->tmp_bp) \ F_CLR(L__gp, G_TMP_INUSE); \ else \ free(bp); \ @@ -118,37 +120,37 @@ * in instead of explaining it all the time. */ #define CALLOC(sp, p, cast, nmemb, size) { \ - if ((p = (cast)calloc(nmemb, size)) == NULL) \ - msgq(sp, M_SYSERR, NULL); \ + if (((p) = (cast)calloc((nmemb), (size))) == NULL) \ + msgq((sp), M_SYSERR, NULL); \ } #define CALLOC_GOTO(sp, p, cast, nmemb, size) { \ - if ((p = (cast)calloc(nmemb, size)) == NULL) \ + if (((p) = (cast)calloc((nmemb), (size))) == NULL) \ goto alloc_err; \ } #define CALLOC_NOMSG(sp, p, cast, nmemb, size) { \ - p = (cast)calloc(nmemb, size); \ + (p) = (cast)calloc((nmemb), (size)); \ } #define CALLOC_RET(sp, p, cast, nmemb, size) { \ - if ((p = (cast)calloc(nmemb, size)) == NULL) { \ - msgq(sp, M_SYSERR, NULL); \ + if (((p) = (cast)calloc((nmemb), (size))) == NULL) { \ + msgq((sp), M_SYSERR, NULL); \ return (1); \ } \ } #define MALLOC(sp, p, cast, size) { \ - if ((p = (cast)malloc(size)) == NULL) \ - msgq(sp, M_SYSERR, NULL); \ + if (((p) = (cast)malloc(size)) == NULL) \ + msgq((sp), M_SYSERR, NULL); \ } #define MALLOC_GOTO(sp, p, cast, size) { \ - if ((p = (cast)malloc(size)) == NULL) \ + if (((p) = (cast)malloc(size)) == NULL) \ goto alloc_err; \ } #define MALLOC_NOMSG(sp, p, cast, size) { \ - p = (cast)malloc(size); \ + (p) = (cast)malloc(size); \ } #define MALLOC_RET(sp, p, cast, size) { \ - if ((p = (cast)malloc(size)) == NULL) { \ - msgq(sp, M_SYSERR, NULL); \ + if (((p) = (cast)malloc(size)) == NULL) { \ + msgq((sp), M_SYSERR, NULL); \ return (1); \ } \ } @@ -157,14 +159,14 @@ * Don't depend on realloc(NULL, size) working. */ #define REALLOC(sp, p, cast, size) { \ - if ((p = (cast)(p == NULL ? \ - malloc(size) : realloc(p, size))) == NULL) \ - msgq(sp, M_SYSERR, NULL); \ + if (((p) = (cast)((p) == NULL ? \ + malloc(size) : realloc((p), (size)))) == NULL) \ + msgq((sp), M_SYSERR, NULL); \ } /* * Versions of memmove(3) and memset(3) that use the size of the * initial pointer to figure out how much memory to manipulate. */ -#define MEMMOVE(p, t, len) memmove(p, t, (len) * sizeof(*(p))) -#define MEMSET(p, value, len) memset(p, value, (len) * sizeof(*(p))) +#define MEMMOVE(p, t, len) memmove((p), (t), (len) * sizeof(*(p))) +#define MEMSET(p, value, len) memset((p), (value), (len) * sizeof(*(p))) diff --git a/usr.bin/vi/common/msg.c b/usr.bin/vi/common/msg.c index 5adb67906ce..61a512a9c7b 100644 --- a/usr.bin/vi/common/msg.c +++ b/usr.bin/vi/common/msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msg.c,v 1.14 2003/04/25 23:44:08 deraadt Exp $ */ +/* $OpenBSD: msg.c,v 1.15 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -332,7 +332,7 @@ nofmt: mp += len; (void)fprintf(stderr, "%.*s", (int)mlen, bp); /* Cleanup. */ -ret: FREE_SPACE(sp, bp, blen); + FREE_SPACE(sp, bp, blen); alloc_err: reenter = 0; } @@ -684,8 +684,8 @@ msg_open(sp, file) char *p, *t, buf[MAXPATHLEN]; if ((p = strrchr(file, '/')) != NULL && p[1] == '\0' && - ((t = getenv("LC_MESSAGES")) != NULL && t[0] != '\0' || - (t = getenv("LANG")) != NULL && t[0] != '\0')) { + (((t = getenv("LC_MESSAGES")) != NULL && t[0] != '\0') || + ((t = getenv("LANG")) != NULL && t[0] != '\0'))) { (void)snprintf(buf, sizeof(buf), "%s%s", file, t); p = buf; } else diff --git a/usr.bin/vi/common/options.c b/usr.bin/vi/common/options.c index 71bd0c41a44..ba78641f3c7 100644 --- a/usr.bin/vi/common/options.c +++ b/usr.bin/vi/common/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.11 2003/04/07 21:13:54 deraadt Exp $ */ +/* $OpenBSD: options.c,v 1.12 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -302,8 +302,8 @@ opts_init(sp, oargs) /* Set numeric and string default values. */ #define OI(indx, str) { \ - if (str != b1) /* GCC puts strings in text-space. */ \ - (void)strlcpy(b1, str, sizeof b1); \ + if ((str) != b1) /* GCC puts strings in text-space. */ \ + (void)strlcpy(b1, (str), sizeof(b1)); \ a.len = strlen(b1); \ if (opts_set(sp, argv, NULL)) { \ optindx = indx; \ @@ -554,7 +554,7 @@ opts_set(sp, argv, usage) * Do nothing if the value is unchanged, the underlying * functions can be expensive. */ - if (!F_ISSET(op, OPT_ALWAYS)) + if (!F_ISSET(op, OPT_ALWAYS)) { if (turnoff) { if (!O_ISSET(sp, offset)) break; @@ -562,6 +562,7 @@ opts_set(sp, argv, usage) if (O_ISSET(sp, offset)) break; } + } if (F_ISSET(op, OPT_EARLYSET)) { /* Set the value. */ @@ -572,8 +573,8 @@ opts_set(sp, argv, usage) } /* Report to subsystems. */ - if (op->func != NULL && - op->func(sp, spo, NULL, &turnoff) || + if ((op->func != NULL && + op->func(sp, spo, NULL, &turnoff)) || ex_optchange(sp, offset, NULL, &turnoff) || v_optchange(sp, offset, NULL, &turnoff) || sp->gp->scr_optchange(sp, offset, NULL, &turnoff)) { @@ -667,8 +668,8 @@ badnum: p = msg_print(sp, name, &nf); } /* Report to subsystems. */ - if (op->func != NULL && - op->func(sp, spo, sep, &value) || + if ((op->func != NULL && + op->func(sp, spo, sep, &value)) || ex_optchange(sp, offset, sep, &value) || v_optchange(sp, offset, sep, &value) || sp->gp->scr_optchange(sp, offset, sep, &value)) { @@ -714,8 +715,8 @@ badnum: p = msg_print(sp, name, &nf); } /* Report to subsystems. */ - if (op->func != NULL && - op->func(sp, spo, sep, NULL) || + if ((op->func != NULL && + op->func(sp, spo, sep, NULL)) || ex_optchange(sp, offset, sep, NULL) || v_optchange(sp, offset, sep, NULL) || sp->gp->scr_optchange(sp, offset, sep, NULL)) { @@ -868,8 +869,8 @@ opts_dump(sp, type) break; case OPT_STR: if (O_STR(sp, cnt) == O_D_STR(sp, cnt) || - O_D_STR(sp, cnt) != NULL && - !strcmp(O_STR(sp, cnt), O_D_STR(sp, cnt))) + (O_D_STR(sp, cnt) != NULL && + !strcmp(O_STR(sp, cnt), O_D_STR(sp, cnt)))) continue; break; } diff --git a/usr.bin/vi/common/options.h b/usr.bin/vi/common/options.h index 9e1f424dba2..42f789a96d2 100644 --- a/usr.bin/vi/common/options.h +++ b/usr.bin/vi/common/options.h @@ -1,4 +1,4 @@ -/* $OpenBSD: options.h,v 1.7 2002/02/16 21:27:57 millert Exp $ */ +/* $OpenBSD: options.h,v 1.8 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -36,7 +36,7 @@ #define OG_SET(gp, o) ((gp)->opts[(o)].o_cur.val) = 1 #define OG_STR(gp, o) ((gp)->opts[(o)].o_cur.str) #define OG_VAL(gp, o) ((gp)->opts[(o)].o_cur.val) -#define OG_ISSET(gp, o) OG_VAL(gp, o) +#define OG_ISSET(gp, o) OG_VAL((gp), (o)) #define OG_D_STR(gp, o) ((gp)->opts[(o)].o_def.str) #define OG_D_VAL(gp, o) ((gp)->opts[(o)].o_def.val) @@ -55,21 +55,21 @@ struct _option { u_long val; /* Value or boolean. */ char *str; /* String. */ } o_cur; -#define O_CLR(sp, o) o_set(sp, o, 0, NULL, 0) -#define O_SET(sp, o) o_set(sp, o, 0, NULL, 1) -#define O_STR(sp, o) O_V(sp, o, o_cur.str) -#define O_VAL(sp, o) O_V(sp, o, o_cur.val) -#define O_ISSET(sp, o) O_VAL(sp, o) +#define O_CLR(sp, o) o_set((sp), (o), 0, NULL, 0) +#define O_SET(sp, o) o_set((sp), (o), 0, NULL, 1) +#define O_STR(sp, o) O_V((sp), (o), o_cur.str) +#define O_VAL(sp, o) O_V((sp), (o), o_cur.val) +#define O_ISSET(sp, o) O_VAL((sp), (o)) union { u_long val; /* Value or boolean. */ char *str; /* String. */ } o_def; -#define O_D_CLR(sp, o) o_set(sp, o, OS_DEF, NULL, 0) -#define O_D_SET(sp, o) o_set(sp, o, OS_DEF, NULL, 1) -#define O_D_STR(sp, o) O_V(sp, o, o_def.str) -#define O_D_VAL(sp, o) O_V(sp, o, o_def.val) -#define O_D_ISSET(sp, o) O_D_VAL(sp, o) +#define O_D_CLR(sp, o) o_set((sp), (o), OS_DEF, NULL, 0) +#define O_D_SET(sp, o) o_set((sp), (o), OS_DEF, NULL, 1) +#define O_D_STR(sp, o) O_V((sp), (o), o_def.str) +#define O_D_VAL(sp, o) O_V((sp), (o), o_def.val) +#define O_D_ISSET(sp, o) O_D_VAL((sp), (o)) #define OPT_GLOBAL 0x01 /* Option is global. */ #define OPT_SELECTED 0x02 /* Selected for display. */ diff --git a/usr.bin/vi/common/put.c b/usr.bin/vi/common/put.c index 9e855818ac2..a4bb62245db 100644 --- a/usr.bin/vi/common/put.c +++ b/usr.bin/vi/common/put.c @@ -1,4 +1,4 @@ -/* $OpenBSD: put.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: put.c,v 1.8 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -48,7 +48,7 @@ put(sp, cbp, namep, cp, rp, append) int rval; char *bp, *p, *t; - if (cbp == NULL) + if (cbp == NULL) { if (namep == NULL) { cbp = sp->gp->dcbp; if (cbp == NULL) { @@ -65,6 +65,7 @@ put(sp, cbp, namep, cp, rp, append) return (1); } } + } tp = CIRCLEQ_FIRST(&cbp->textq); /* diff --git a/usr.bin/vi/common/search.c b/usr.bin/vi/common/search.c index d6251effab8..d39737acf87 100644 --- a/usr.bin/vi/common/search.c +++ b/usr.bin/vi/common/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.7 2002/02/17 19:42:34 millert Exp $ */ +/* $OpenBSD: search.c,v 1.8 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -211,7 +211,7 @@ f_search(sp, fm, rm, ptrn, plen, eptrn, flags) } cnt = INTERRUPT_CHECK; } - if (wrapped && lno > fm->lno || db_get(sp, lno, 0, &l, &len)) { + if ((wrapped && lno > fm->lno) || db_get(sp, lno, 0, &l, &len)) { if (wrapped) { if (LF_ISSET(SEARCH_MSG)) search_msg(sp, S_NOTFOUND); @@ -342,7 +342,7 @@ b_search(sp, fm, rm, ptrn, plen, eptrn, flags) } cnt = INTERRUPT_CHECK; } - if (wrapped && lno < fm->lno || lno == 0) { + if ((wrapped && lno < fm->lno) || lno == 0) { if (wrapped) { if (LF_ISSET(SEARCH_MSG)) search_msg(sp, S_NOTFOUND); diff --git a/usr.bin/vi/common/util.h b/usr.bin/vi/common/util.h index ef1452cb511..60e2ef2f7f7 100644 --- a/usr.bin/vi/common/util.h +++ b/usr.bin/vi/common/util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: util.h,v 1.2 2001/01/29 01:58:32 niklas Exp $ */ +/* $OpenBSD: util.h,v 1.3 2006/01/08 21:05:39 miod Exp $ */ /*- * Copyright (c) 1994 @@ -17,15 +17,15 @@ #define FL_CLR(l, f) ((l) &= ~(f)) #define FL_ISSET(l, f) ((l) & (f)) -#define LF_INIT(f) FL_INIT(flags, f) /* Local variable flags. */ -#define LF_SET(f) FL_SET(flags, f) -#define LF_CLR(f) FL_CLR(flags, f) -#define LF_ISSET(f) FL_ISSET(flags, f) +#define LF_INIT(f) FL_INIT(flags, (f)) /* Local variable flags. */ +#define LF_SET(f) FL_SET(flags, (f)) +#define LF_CLR(f) FL_CLR(flags, (f)) +#define LF_ISSET(f) FL_ISSET(flags, (f)) -#define F_INIT(p, f) FL_INIT((p)->flags, f) /* Structure element flags. */ -#define F_SET(p, f) FL_SET((p)->flags, f) -#define F_CLR(p, f) FL_CLR((p)->flags, f) -#define F_ISSET(p, f) FL_ISSET((p)->flags, f) +#define F_INIT(p, f) FL_INIT((p)->flags, (f)) /* Structure element flags. */ +#define F_SET(p, f) FL_SET((p)->flags, (f)) +#define F_CLR(p, f) FL_CLR((p)->flags, (f)) +#define F_ISSET(p, f) FL_ISSET((p)->flags, (f)) /* Offset to next column of stop size, e.g. tab offsets. */ #define COL_OFF(c, stop) ((stop) - ((c) % (stop))) diff --git a/usr.bin/vi/ex/ex.c b/usr.bin/vi/ex/ex.c index 68d82bc8bb1..93ffa588d45 100644 --- a/usr.bin/vi/ex/ex.c +++ b/usr.bin/vi/ex/ex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex.c,v 1.12 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: ex.c,v 1.13 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -1250,7 +1250,7 @@ addr_verify: ex_badaddr(sp, ecp->cmd, A_ZERO, NUM_OK); goto err; } - } else if (!db_exist(sp, ecp->addr2.lno)) + } else if (!db_exist(sp, ecp->addr2.lno)) { if (FL_ISSET(ecp->iflags, E_C_COUNT)) { if (db_last(sp, &lno)) goto err; @@ -1259,6 +1259,7 @@ addr_verify: ex_badaddr(sp, NULL, A_EOF, NUM_OK); goto err; } + } /* FALLTHROUGH */ case 1: if (ecp->addr1.lno == 0) { @@ -1894,7 +1895,7 @@ ex_line(sp, ecp, mp, isaddrp, errp) * difference. C'est la vie. */ if (ecp->clen < 2 || - ecp->cp[1] != '/' && ecp->cp[1] != '?') { + (ecp->cp[1] != '/' && ecp->cp[1] != '?')) { msgq(sp, M_ERR, "096|\\ not followed by / or ?"); *errp = 1; return (0); @@ -2000,9 +2001,9 @@ search: mp->lno = sp->lno; for (;;) { for (; ecp->clen > 0 && isblank(ecp->cp[0]); ++ecp->cp, --ecp->clen); - if (ecp->clen == 0 || !isdigit(ecp->cp[0]) && + if (ecp->clen == 0 || (!isdigit(ecp->cp[0]) && ecp->cp[0] != '+' && ecp->cp[0] != '-' && - ecp->cp[0] != '^') + ecp->cp[0] != '^')) break; if (!isdigit(ecp->cp[0]) && !isdigit(ecp->cp[1])) { @@ -2119,7 +2120,7 @@ ex_load(sp) /* If it's a global/v command, fix up the last line. */ if (FL_ISSET(ecp->agv_flags, - AGV_GLOBAL | AGV_V) && ecp->range_lno != OOBLNO) + AGV_GLOBAL | AGV_V) && ecp->range_lno != OOBLNO) { if (db_exist(sp, ecp->range_lno)) sp->lno = ecp->range_lno; else { @@ -2128,6 +2129,7 @@ ex_load(sp) if (sp->lno == 0) sp->lno = 1; } + } free(ecp->o_cp); } diff --git a/usr.bin/vi/ex/ex.h b/usr.bin/vi/ex/ex.h index 5f0ea3183ea..95de526aa64 100644 --- a/usr.bin/vi/ex/ex.h +++ b/usr.bin/vi/ex/ex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ex.h,v 1.5 2002/02/16 21:27:57 millert Exp $ */ +/* $OpenBSD: ex.h,v 1.6 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -48,8 +48,8 @@ extern EXCMDLIST const cmds[]; /* Table of ex commands. */ * enforce that here, just in case someone depends on it. */ #define IS_ESCAPE(sp, cmdp, ch) \ - (F_ISSET(cmdp, E_VLITONLY) ? \ - (ch) == CH_LITERAL : KEY_VAL(sp, ch) == K_VLNEXT) + (F_ISSET((cmdp), E_VLITONLY) ? \ + (ch) == CH_LITERAL : KEY_VAL((sp), (ch)) == K_VLNEXT) /* * File state must be checked for each command -- any ex command may be entered @@ -58,7 +58,7 @@ extern EXCMDLIST const cmds[]; /* Table of ex commands. */ */ #define NEEDFILE(sp, cmdp) { \ if ((sp)->ep == NULL) { \ - ex_emsg(sp, (cmdp)->cmd->name, EXM_NOFILEYET); \ + ex_emsg((sp), (cmdp)->cmd->name, EXM_NOFILEYET); \ return (1); \ } \ } @@ -104,10 +104,10 @@ struct _excmd { /* Clear the structure before each ex command. */ #define CLEAR_EX_CMD(cmdp) { \ - u_int32_t L__f = F_ISSET(cmdp, E_PRESERVE); \ + u_int32_t L__f = F_ISSET((cmdp), E_PRESERVE); \ memset(&((cmdp)->buffer), 0, ((char *)&(cmdp)->flags - \ (char *)&((cmdp)->buffer)) + sizeof((cmdp)->flags)); \ - F_SET(cmdp, L__f); \ + F_SET((cmdp), L__f); \ } CHAR_T buffer; /* Command: named buffer. */ diff --git a/usr.bin/vi/ex/ex_bang.c b/usr.bin/vi/ex/ex_bang.c index e80c7594746..2532b7be7ed 100644 --- a/usr.bin/vi/ex/ex_bang.c +++ b/usr.bin/vi/ex/ex_bang.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_bang.c,v 1.5 2002/02/16 21:27:57 millert Exp $ */ +/* $OpenBSD: ex_bang.c,v 1.6 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -103,7 +103,7 @@ ex_bang(sp, cmdp) */ if (cmdp->addrcnt == 0) { msg = NULL; - if (sp->ep != NULL && F_ISSET(sp->ep, F_MODIFIED)) + if (sp->ep != NULL && F_ISSET(sp->ep, F_MODIFIED)) { if (O_ISSET(sp, O_AUTOWRITE)) { if (file_aw(sp, FS_ALL)) return (0); @@ -112,6 +112,7 @@ ex_bang(sp, cmdp) msg = msg_cat(sp, "303|File modified since last write.", NULL); + } /* If we're still in a vi screen, move out explicitly. */ (void)ex_exec_proc(sp, diff --git a/usr.bin/vi/ex/ex_cd.c b/usr.bin/vi/ex/ex_cd.c index 059c46d2ce5..d2782413331 100644 --- a/usr.bin/vi/ex/ex_cd.c +++ b/usr.bin/vi/ex/ex_cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_cd.c,v 1.7 2005/04/21 15:39:31 jmc Exp $ */ +/* $OpenBSD: ex_cd.c,v 1.8 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -93,9 +93,9 @@ ex_cd(sp, cmdp) */ if (cmdp->argc == 0 || (ap = cmdp->argv[0])->bp[0] == '/' || - ap->len == 1 && ap->bp[0] == '.' || - ap->len >= 2 && ap->bp[0] == '.' && ap->bp[1] == '.' && - (ap->bp[2] == '/' || ap->bp[2] == '\0')) + (ap->len == 1 && ap->bp[0] == '.') || + (ap->len >= 2 && ap->bp[0] == '.' && ap->bp[1] == '.' && + (ap->bp[2] == '/' || ap->bp[2] == '\0'))) goto err; /* Try the O_CDPATH option values. */ diff --git a/usr.bin/vi/ex/ex_cscope.c b/usr.bin/vi/ex/ex_cscope.c index 83b5ca5a3dd..b6344c3846f 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.11 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: ex_cscope.c,v 1.12 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1994, 1996 @@ -824,7 +824,7 @@ csc_help(sp, cmd) { CC const *ccp; - if (cmd != NULL && *cmd != '\0') + if (cmd != NULL && *cmd != '\0') { if ((ccp = lookup_ccmd(cmd)) == NULL) { ex_printf(sp, "%s doesn't match any cscope command\n", cmd); @@ -835,6 +835,7 @@ csc_help(sp, cmd) ex_printf(sp, " Usage: %s\n", ccp->usage_msg); return (0); } + } ex_printf(sp, "cscope commands:\n"); for (ccp = cscope_cmds; ccp->name != NULL; ++ccp) diff --git a/usr.bin/vi/ex/ex_filter.c b/usr.bin/vi/ex/ex_filter.c index 89d610efa39..e709f6e539f 100644 --- a/usr.bin/vi/ex/ex_filter.c +++ b/usr.bin/vi/ex/ex_filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_filter.c,v 1.7 2002/06/12 06:07:17 mpech Exp $ */ +/* $OpenBSD: ex_filter.c,v 1.8 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -181,11 +181,12 @@ err: if (input[0] != -1) if (ex_readfp(sp, "filter", ofp, fm, &nread, 1)) rval = 1; sp->rptlines[L_ADDED] += nread; - if (ftype == FILTER_READ) + if (ftype == FILTER_READ) { if (fm->lno == 0) rp->lno = nread; else rp->lno += nread; + } goto uwait; } diff --git a/usr.bin/vi/ex/ex_global.c b/usr.bin/vi/ex/ex_global.c index 8c55c211d8b..0858bebf70d 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.7 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: ex_global.c,v 1.8 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -125,11 +125,12 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE); *t = '\0'; break; } - if (p[0] == '\\') + if (p[0] == '\\') { if (p[1] == delim) ++p; else if (p[1] == '\\') *t++ = *p++; + } *t++ = *p++; } diff --git a/usr.bin/vi/ex/ex_script.c b/usr.bin/vi/ex/ex_script.c index a98bc633fa1..bb6bf982cd4 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.12 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: ex_script.c,v 1.13 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -379,7 +379,7 @@ sscr_input(sp) GS *gp; struct timeval tv; fd_set *rdfd; - int maxfd, nfd; + int maxfd; gp = sp->gp; @@ -434,7 +434,6 @@ static int sscr_insert(sp) SCR *sp; { - struct timeval tv; CHAR_T *endp, *p, *t; SCRIPT *sc; struct pollfd pfd[1]; diff --git a/usr.bin/vi/ex/ex_shell.c b/usr.bin/vi/ex/ex_shell.c index e5ce2832654..a8ff35b4bc4 100644 --- a/usr.bin/vi/ex/ex_shell.c +++ b/usr.bin/vi/ex/ex_shell.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_shell.c,v 1.9 2002/06/12 06:07:17 mpech Exp $ */ +/* $OpenBSD: ex_shell.c,v 1.10 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -226,136 +226,136 @@ typedef struct _sigs { SIGS const sigs[] = { #ifdef SIGABRT - SIGABRT, "Abort trap", + { SIGABRT, "Abort trap" }, #endif #ifdef SIGALRM - SIGALRM, "Alarm clock", + { SIGALRM, "Alarm clock" }, #endif #ifdef SIGBUS - SIGBUS, "Bus error", + { SIGBUS, "Bus error" }, #endif #ifdef SIGCLD - SIGCLD, "Child exited or stopped", + { SIGCLD, "Child exited or stopped" }, #endif #ifdef SIGCHLD - SIGCHLD, "Child exited", + { SIGCHLD, "Child exited" }, #endif #ifdef SIGCONT - SIGCONT, "Continued", + { SIGCONT, "Continued" }, #endif #ifdef SIGDANGER - SIGDANGER, "System crash imminent", + { SIGDANGER, "System crash imminent" }, #endif #ifdef SIGEMT - SIGEMT, "EMT trap", + { SIGEMT, "EMT trap" }, #endif #ifdef SIGFPE - SIGFPE, "Floating point exception", + { SIGFPE, "Floating point exception" }, #endif #ifdef SIGGRANT - SIGGRANT, "HFT monitor mode granted", + { SIGGRANT, "HFT monitor mode granted" }, #endif #ifdef SIGHUP - SIGHUP, "Hangup", + { SIGHUP, "Hangup" }, #endif #ifdef SIGILL - SIGILL, "Illegal instruction", + { SIGILL, "Illegal instruction" }, #endif #ifdef SIGINFO - SIGINFO, "Information request", + { SIGINFO, "Information request" }, #endif #ifdef SIGINT - SIGINT, "Interrupt", + { SIGINT, "Interrupt" }, #endif #ifdef SIGIO - SIGIO, "I/O possible", + { SIGIO, "I/O possible" }, #endif #ifdef SIGIOT - SIGIOT, "IOT trap", + { SIGIOT, "IOT trap" }, #endif #ifdef SIGKILL - SIGKILL, "Killed", + { SIGKILL, "Killed" }, #endif #ifdef SIGLOST - SIGLOST, "Record lock", + { SIGLOST, "Record lock" }, #endif #ifdef SIGMIGRATE - SIGMIGRATE, "Migrate process to another CPU", + { SIGMIGRATE, "Migrate process to another CPU" }, #endif #ifdef SIGMSG - SIGMSG, "HFT input data pending", + { SIGMSG, "HFT input data pending" }, #endif #ifdef SIGPIPE - SIGPIPE, "Broken pipe", + { SIGPIPE, "Broken pipe" }, #endif #ifdef SIGPOLL - SIGPOLL, "I/O possible", + { SIGPOLL, "I/O possible" }, #endif #ifdef SIGPRE - SIGPRE, "Programming error", + { SIGPRE, "Programming error" }, #endif #ifdef SIGPROF - SIGPROF, "Profiling timer expired", + { SIGPROF, "Profiling timer expired" }, #endif #ifdef SIGPWR - SIGPWR, "Power failure imminent", + { SIGPWR, "Power failure imminent" }, #endif #ifdef SIGRETRACT - SIGRETRACT, "HFT monitor mode retracted", + { SIGRETRACT, "HFT monitor mode retracted" }, #endif #ifdef SIGQUIT - SIGQUIT, "Quit", + { SIGQUIT, "Quit" }, #endif #ifdef SIGSAK - SIGSAK, "Secure Attention Key", + { SIGSAK, "Secure Attention Key" }, #endif #ifdef SIGSEGV - SIGSEGV, "Segmentation fault", + { SIGSEGV, "Segmentation fault" }, #endif #ifdef SIGSOUND - SIGSOUND, "HFT sound sequence completed", + { SIGSOUND, "HFT sound sequence completed" }, #endif #ifdef SIGSTOP - SIGSTOP, "Suspended (signal)", + { SIGSTOP, "Suspended (signal)" }, #endif #ifdef SIGSYS - SIGSYS, "Bad system call", + { SIGSYS, "Bad system call" }, #endif #ifdef SIGTERM - SIGTERM, "Terminated", + { SIGTERM, "Terminated" }, #endif #ifdef SIGTRAP - SIGTRAP, "Trace/BPT trap", + { SIGTRAP, "Trace/BPT trap" }, #endif #ifdef SIGTSTP - SIGTSTP, "Suspended", + { SIGTSTP, "Suspended" }, #endif #ifdef SIGTTIN - SIGTTIN, "Stopped (tty input)", + { SIGTTIN, "Stopped (tty input)" }, #endif #ifdef SIGTTOU - SIGTTOU, "Stopped (tty output)", + { SIGTTOU, "Stopped (tty output)" }, #endif #ifdef SIGURG - SIGURG, "Urgent I/O condition", + { SIGURG, "Urgent I/O condition" }, #endif #ifdef SIGUSR1 - SIGUSR1, "User defined signal 1", + { SIGUSR1, "User defined signal 1" }, #endif #ifdef SIGUSR2 - SIGUSR2, "User defined signal 2", + { SIGUSR2, "User defined signal 2" }, #endif #ifdef SIGVTALRM - SIGVTALRM, "Virtual timer expired", + { SIGVTALRM, "Virtual timer expired" }, #endif #ifdef SIGWINCH - SIGWINCH, "Window size changes", + { SIGWINCH, "Window size changes" }, #endif #ifdef SIGXCPU - SIGXCPU, "Cputime limit exceeded", + { SIGXCPU, "Cputime limit exceeded" }, #endif #ifdef SIGXFSZ - SIGXFSZ, "Filesize limit exceeded", + { SIGXFSZ, "Filesize limit exceeded" }, #endif }; diff --git a/usr.bin/vi/ex/ex_subst.c b/usr.bin/vi/ex/ex_subst.c index 454f1d2f85e..97eef49722c 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.13 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: ex_subst.c,v 1.14 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -122,11 +122,12 @@ subagain: return (ex_subagain(sp, cmdp)); *t = '\0'; break; } - if (p[0] == '\\') + if (p[0] == '\\') { if (p[1] == delim) ++p; else if (p[1] == '\\') *t++ = *p++; + } *t++ = *p++; } @@ -308,12 +309,12 @@ ex_subtilde(sp, cmdp) * confident. */ #define NEEDNEWLINE(sp) { \ - if (sp->newl_len == sp->newl_cnt) { \ - sp->newl_len += 25; \ - REALLOC(sp, sp->newl, size_t *, \ - sp->newl_len * sizeof(size_t)); \ - if (sp->newl == NULL) { \ - sp->newl_len = 0; \ + if ((sp)->newl_len == (sp)->newl_cnt) { \ + (sp)->newl_len += 25; \ + REALLOC((sp), (sp)->newl, size_t *, \ + (sp)->newl_len * sizeof(size_t)); \ + if ((sp)->newl == NULL) { \ + (sp)->newl_len = 0; \ return (1); \ } \ } \ @@ -322,25 +323,25 @@ ex_subtilde(sp, cmdp) #define BUILD(sp, l, len) { \ if (lbclen + (len) > lblen) { \ lblen += MAX(lbclen + (len), 256); \ - REALLOC(sp, lb, char *, lblen); \ + REALLOC((sp), lb, char *, lblen); \ if (lb == NULL) { \ lbclen = 0; \ return (1); \ } \ } \ - memcpy(lb + lbclen, l, len); \ - lbclen += len; \ + memcpy(lb + lbclen, (l), (len)); \ + lbclen += (len); \ } #define NEEDSP(sp, len, pnt) { \ if (lbclen + (len) > lblen) { \ lblen += MAX(lbclen + (len), 256); \ - REALLOC(sp, lb, char *, lblen); \ + REALLOC((sp), lb, char *, lblen); \ if (lb == NULL) { \ lbclen = 0; \ return (1); \ } \ - pnt = lb + lbclen; \ + (pnt) = lb + lbclen; \ } \ } @@ -476,7 +477,7 @@ s(sp, cmdp, s, re, flags) goto usage; } - if (*s != '\0' || !rflag && LF_ISSET(SUB_MUSTSETR)) { + if (*s != '\0' || (!rflag && LF_ISSET(SUB_MUSTSETR))) { usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE); return (1); } @@ -1367,7 +1368,7 @@ re_sub(sp, ip, lbp, lbclenp, lblenp, match) #define OUTCH(ch, nltrans) { \ CHAR_T __ch = (ch); \ u_int __value = KEY_VAL(sp, __ch); \ - if (nltrans && (__value == K_CR || __value == K_NL)) { \ + if ((nltrans) && (__value == K_CR || __value == K_NL)) { \ NEEDNEWLINE(sp); \ sp->newl[sp->newl_cnt++] = lbclen; \ } else if (conv != C_NOTSET) { \ diff --git a/usr.bin/vi/ex/ex_tag.c b/usr.bin/vi/ex/ex_tag.c index 56022d9b051..ea4ccc9a1cc 100644 --- a/usr.bin/vi/ex/ex_tag.c +++ b/usr.bin/vi/ex/ex_tag.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_tag.c,v 1.11 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: ex_tag.c,v 1.12 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -169,7 +169,7 @@ ex_tag_push(sp, cmdp) lno = sp->lno; cno = sp->cno; istmp = frp == NULL || - F_ISSET(frp, FR_TMPFILE) && !F_ISSET(cmdp, E_NEWSCREEN); + (F_ISSET(frp, FR_TMPFILE) && !F_ISSET(cmdp, E_NEWSCREEN)); /* Try to switch to the tag. */ force = FL_ISSET(cmdp->iflags, E_C_FORCE); @@ -939,7 +939,7 @@ ctag_search(sp, search, slen, tag) m.lno = 1; m.cno = 0; if (f_search(sp, &m, &m, - search, slen, NULL, SEARCH_FILE | SEARCH_TAG)) + search, slen, NULL, SEARCH_FILE | SEARCH_TAG)) { if ((p = strrchr(search, '(')) != NULL) { slen = p - search; if (f_search(sp, &m, &m, search, slen, @@ -949,6 +949,7 @@ ctag_search(sp, search, slen, tag) notfound: tag_msg(sp, TAG_SEARCH, tag); return (1); } + } /* * !!! * Historically, tags set the search direction if it wasn't @@ -1244,7 +1245,7 @@ ctag_file(sp, tfp, name, dirp, dlenp) #define GREATER 1 #define LESS (-1) -#define SKIP_PAST_NEWLINE(p, back) while (p < back && *p++ != '\n'); +#define SKIP_PAST_NEWLINE(p, back) while ((p) < (back) && *(p)++ != '\n'); static char * binary_search(string, front, back) diff --git a/usr.bin/vi/ex/ex_usage.c b/usr.bin/vi/ex/ex_usage.c index 389b012bc1c..654938ee56b 100644 --- a/usr.bin/vi/ex/ex_usage.c +++ b/usr.bin/vi/ex/ex_usage.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_usage.c,v 1.4 2002/02/16 21:27:57 millert Exp $ */ +/* $OpenBSD: ex_usage.c,v 1.5 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -79,7 +79,7 @@ ex_usage(sp, cmdp) for (cp = cmds; cp->name != NULL && memcmp(ap->bp, cp->name, ap->len); ++cp); if (cp->name == NULL || - newscreen && !F_ISSET(cp, E_NEWSCREEN)) { + (newscreen && !F_ISSET(cp, E_NEWSCREEN))) { if (newscreen) ap->bp[0] = toupper(ap->bp[0]); (void)ex_printf(sp, "The %.*s command is unknown\n", diff --git a/usr.bin/vi/include/bitstring.h b/usr.bin/vi/include/bitstring.h index f473245ea73..6adc7726508 100644 --- a/usr.bin/vi/include/bitstring.h +++ b/usr.bin/vi/include/bitstring.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bitstring.h,v 1.3 2003/06/03 02:56:22 millert Exp $ */ +/* $OpenBSD: bitstring.h,v 1.4 2006/01/08 21:05:40 miod Exp $ */ /* * Copyright (c) 1989, 1993 @@ -76,8 +76,8 @@ typedef unsigned char bitstr_t; /* clear bits start ... stop in bitstring */ #define bit_nclear(name, start, stop) { \ - register bitstr_t *_name = name; \ - register int _start = start, _stop = stop; \ + register bitstr_t *_name = (name); \ + register int _start = (start), _stop = (stop); \ register int _startbyte = _bit_byte(_start); \ register int _stopbyte = _bit_byte(_stop); \ if (_startbyte == _stopbyte) { \ @@ -93,8 +93,8 @@ typedef unsigned char bitstr_t; /* set bits start ... stop in bitstring */ #define bit_nset(name, start, stop) { \ - register bitstr_t *_name = name; \ - register int _start = start, _stop = stop; \ + register bitstr_t *_name = (name); \ + register int _start = (start), _stop = (stop); \ register int _startbyte = _bit_byte(_start); \ register int _stopbyte = _bit_byte(_stop); \ if (_startbyte == _stopbyte) { \ @@ -110,8 +110,8 @@ typedef unsigned char bitstr_t; /* find first bit clear in name */ #define bit_ffc(name, nbits, value) { \ - register bitstr_t *_name = name; \ - register int _byte, _nbits = nbits; \ + register bitstr_t *_name = (name); \ + register int _byte, _nbits = (nbits); \ register int _stopbyte = _bit_byte(_nbits), _value = -1; \ for (_byte = 0; _byte <= _stopbyte; ++_byte) \ if (_name[_byte] != 0xff) { \ @@ -125,8 +125,8 @@ typedef unsigned char bitstr_t; /* find first bit set in name */ #define bit_ffs(name, nbits, value) { \ - register bitstr_t *_name = name; \ - register int _byte, _nbits = nbits; \ + register bitstr_t *_name = (name); \ + register int _byte, _nbits = (nbits); \ register int _stopbyte = _bit_byte(_nbits), _value = -1; \ for (_byte = 0; _byte <= _stopbyte; ++_byte) \ if (_name[_byte]) { \ diff --git a/usr.bin/vi/vi/getc.c b/usr.bin/vi/vi/getc.c index 8ef4ddec901..e82abd772d1 100644 --- a/usr.bin/vi/vi/getc.c +++ b/usr.bin/vi/vi/getc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getc.c,v 1.6 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: getc.c,v 1.7 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -156,7 +156,7 @@ cs_fblank(sp, csp) if (cs_next(sp, csp)) return (1); if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP || - csp->cs_flags == 0 && isblank(csp->cs_ch)) + (csp->cs_flags == 0 && isblank(csp->cs_ch))) continue; break; } @@ -230,7 +230,7 @@ cs_bblank(sp, csp) if (cs_prev(sp, csp)) return (1); if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP || - csp->cs_flags == 0 && isblank(csp->cs_ch)) + (csp->cs_flags == 0 && isblank(csp->cs_ch))) continue; break; } diff --git a/usr.bin/vi/vi/v_at.c b/usr.bin/vi/vi/v_at.c index 62a65cc1999..fc05017ac0a 100644 --- a/usr.bin/vi/vi/v_at.c +++ b/usr.bin/vi/vi/v_at.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_at.c,v 1.5 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: v_at.c,v 1.6 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -90,9 +90,9 @@ v_at(sp, vp) * logging code to be available. */ CIRCLEQ_FOREACH_REVERSE(tp, &cbp->textq, q) - if ((F_ISSET(cbp, CB_LMODE) || + if (((F_ISSET(cbp, CB_LMODE) || CIRCLEQ_NEXT(tp, q) != CIRCLEQ_END(&cbp->textq)) && - v_event_push(sp, NULL, "\n", 1, 0) || + v_event_push(sp, NULL, "\n", 1, 0)) || v_event_push(sp, NULL, tp->lb, tp->len, 0)) return (1); diff --git a/usr.bin/vi/vi/v_increment.c b/usr.bin/vi/vi/v_increment.c index e4939cb94ba..f1848225422 100644 --- a/usr.bin/vi/vi/v_increment.c +++ b/usr.bin/vi/vi/v_increment.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_increment.c,v 1.5 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: v_increment.c,v 1.6 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -102,7 +102,7 @@ v_increment(sp, vp) } #undef ishex -#define ishex(c) (isdigit(c) || strchr("abcdefABCDEF", c)) +#define ishex(c) (isdigit(c) || strchr("abcdefABCDEF", (c))) #undef isoctal #define isoctal(c) (isdigit(c) && (c) != '8' && (c) != '9') diff --git a/usr.bin/vi/vi/v_mark.c b/usr.bin/vi/vi/v_mark.c index c57bb63e6bf..1d64171e2ca 100644 --- a/usr.bin/vi/vi/v_mark.c +++ b/usr.bin/vi/vi/v_mark.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_mark.c,v 1.5 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: v_mark.c,v 1.6 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -113,7 +113,7 @@ mark(sp, vp, cmd) if (db_get(sp, vp->m_stop.lno, DBG_FATAL, NULL, &len)) return (1); if (vp->m_stop.cno < len || - vp->m_stop.cno == len && len == 0) + (vp->m_stop.cno == len && len == 0)) break; if (ISMOTION(vp)) @@ -154,8 +154,8 @@ mark(sp, vp, cmd) * and backward motions can happen for any kind of search command. */ if (vp->m_start.lno > vp->m_stop.lno || - vp->m_start.lno == vp->m_stop.lno && - vp->m_start.cno > vp->m_stop.cno) { + (vp->m_start.lno == vp->m_stop.lno && + vp->m_start.cno > vp->m_stop.cno)) { m = vp->m_start; vp->m_start = vp->m_stop; vp->m_stop = m; diff --git a/usr.bin/vi/vi/v_match.c b/usr.bin/vi/vi/v_match.c index e7e7b9d9371..274c6636af9 100644 --- a/usr.bin/vi/vi/v_match.c +++ b/usr.bin/vi/vi/v_match.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_match.c,v 1.4 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: v_match.c,v 1.5 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -137,8 +137,8 @@ nomatch: msgq(sp, M_BERR, "184|No match character on this line"); * starting cursor position when deleting to a match. */ if (vp->m_start.lno < vp->m_stop.lno || - vp->m_start.lno == vp->m_stop.lno && - vp->m_start.cno < vp->m_stop.cno) + (vp->m_start.lno == vp->m_stop.lno && + vp->m_start.cno < vp->m_stop.cno)) vp->m_final = ISMOTION(vp) ? vp->m_start : vp->m_stop; else vp->m_final = vp->m_stop; diff --git a/usr.bin/vi/vi/v_paragraph.c b/usr.bin/vi/vi/v_paragraph.c index 11125b6241a..157ea5eef49 100644 --- a/usr.bin/vi/vi/v_paragraph.c +++ b/usr.bin/vi/vi/v_paragraph.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_paragraph.c,v 1.4 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: v_paragraph.c,v 1.5 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -51,7 +51,7 @@ static const char sccsid[] = "@(#)v_paragraph.c 10.7 (Berkeley) 3/6/96"; continue; \ for (lp = VIP(sp)->ps; *lp != '\0'; lp += 2) \ if (lp[0] == p[1] && \ - (lp[1] == ' ' && len == 2 || lp[1] == p[2]) && \ + ((lp[1] == ' ' && len == 2) || lp[1] == p[2]) && \ !--cnt) \ goto found; \ } @@ -90,7 +90,7 @@ v_paragraphf(sp, 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 { @@ -101,6 +101,7 @@ v_paragraphf(sp, 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; @@ -234,7 +235,7 @@ v_paragraphb(sp, 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); @@ -244,6 +245,7 @@ v_paragraphb(sp, vp) F_SET(vp, VM_LMODE); } else --vp->m_start.cno; + } if (vp->m_start.lno <= 1) goto sof; diff --git a/usr.bin/vi/vi/v_replace.c b/usr.bin/vi/vi/v_replace.c index 581f9a6e5df..01910b2ccb4 100644 --- a/usr.bin/vi/vi/v_replace.c +++ b/usr.bin/vi/vi/v_replace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_replace.c,v 1.5 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: v_replace.c,v 1.6 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -156,7 +156,7 @@ next: if (v_event_get(sp, &ev, 0, 0)) * is different from the historic vi, which replaced N characters with * a single new line. Users complained, so we match historic practice. */ - if (!quote && vip->rvalue == K_CR || vip->rvalue == K_NL) { + if ((!quote && vip->rvalue == K_CR) || vip->rvalue == K_NL) { /* Set return line. */ vp->m_stop.lno = vp->m_start.lno + 1; vp->m_stop.cno = 0; diff --git a/usr.bin/vi/vi/v_scroll.c b/usr.bin/vi/vi/v_scroll.c index b943a88f647..b8f2f023ea9 100644 --- a/usr.bin/vi/vi/v_scroll.c +++ b/usr.bin/vi/vi/v_scroll.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_scroll.c,v 1.5 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: v_scroll.c,v 1.6 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -201,8 +201,8 @@ goto_adjust(vp) * stay at the start of the range. Ignore others. */ if (vp->m_stop.lno < vp->m_start.lno || - vp->m_stop.lno == vp->m_start.lno && - vp->m_stop.cno < vp->m_start.cno) { + (vp->m_stop.lno == vp->m_start.lno && + vp->m_stop.cno < vp->m_start.cno)) { if (ISCMD(vp->rkp, 'y') && vp->m_stop.lno == vp->m_start.lno) vp->m_final = vp->m_start; } else diff --git a/usr.bin/vi/vi/v_search.c b/usr.bin/vi/vi/v_search.c index 1cb1a24b819..d644464d8f8 100644 --- a/usr.bin/vi/vi/v_search.c +++ b/usr.bin/vi/vi/v_search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_search.c,v 1.8 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: v_search.c,v 1.9 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -468,8 +468,8 @@ v_correct(sp, vp, isdelta) * because of the wrapscan option. */ if (vp->m_start.lno > vp->m_stop.lno || - vp->m_start.lno == vp->m_stop.lno && - vp->m_start.cno > vp->m_stop.cno) { + (vp->m_start.lno == vp->m_stop.lno && + vp->m_start.cno > vp->m_stop.cno)) { m = vp->m_start; vp->m_start = vp->m_stop; vp->m_stop = m; diff --git a/usr.bin/vi/vi/v_section.c b/usr.bin/vi/vi/v_section.c index 9e53f4fbf68..6040bc1198d 100644 --- a/usr.bin/vi/vi/v_section.c +++ b/usr.bin/vi/vi/v_section.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_section.c,v 1.4 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: v_section.c,v 1.5 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -84,7 +84,7 @@ v_sectionf(sp, 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 { @@ -95,12 +95,13 @@ v_sectionf(sp, 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);) { if (len == 0) continue; - if (p[0] == '{' || ISMOTION(vp) && p[0] == '}') { + if (p[0] == '{' || (ISMOTION(vp) && p[0] == '}')) { if (!--cnt) { if (p[0] == '{') goto adjust1; @@ -124,7 +125,7 @@ v_sectionf(sp, vp) continue; for (lp = list; *lp != '\0'; lp += 2 * sizeof(*lp)) if (lp[0] == p[1] && - (lp[1] == ' ' && len == 2 || lp[1] == p[2]) && + ((lp[1] == ' ' && len == 2) || lp[1] == p[2]) && !--cnt) { /* * !!! @@ -215,7 +216,7 @@ v_sectionb(sp, vp) continue; for (lp = list; *lp != '\0'; lp += 2 * sizeof(*lp)) if (lp[0] == p[1] && - (lp[1] == ' ' && len == 2 || lp[1] == p[2]) && + ((lp[1] == ' ' && len == 2) || lp[1] == p[2]) && !--cnt) { adjust1: vp->m_stop.lno = lno; vp->m_stop.cno = 0; diff --git a/usr.bin/vi/vi/v_sentence.c b/usr.bin/vi/vi/v_sentence.c index bc223e83530..54107f3fb03 100644 --- a/usr.bin/vi/vi/v_sentence.c +++ b/usr.bin/vi/vi/v_sentence.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_sentence.c,v 1.4 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: v_sentence.c,v 1.5 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -76,7 +76,7 @@ v_sentencef(sp, vp) * This may not handle " . " correctly, but it's real unclear * what correctly means in that case. */ - if (cs.cs_flags == CS_EMP || cs.cs_flags == 0 && isblank(cs.cs_ch)) { + if (cs.cs_flags == CS_EMP || (cs.cs_flags == 0 && isblank(cs.cs_ch))) { if (cs_fblank(sp, &cs)) return (1); if (--cnt == 0) { @@ -346,7 +346,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, @@ -356,6 +356,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/usr.bin/vi/vi/v_txt.c b/usr.bin/vi/vi/v_txt.c index f73fd7ba0ee..140bb2971c6 100644 --- a/usr.bin/vi/vi/v_txt.c +++ b/usr.bin/vi/vi/v_txt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_txt.c,v 1.16 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: v_txt.c,v 1.17 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -1563,7 +1563,7 @@ txt_abbrev(sp, tp, pushcp, isinfoline, didsubp, turnoffp) * * 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; @@ -1573,6 +1573,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) @@ -1732,7 +1733,7 @@ txt_ai_resolve(sp, tp, changedp) * If there are no spaces, or no tabs after spaces and less than * ts spaces, it's already minimal. */ - if (!spaces || !tab_after_sp && spaces < ts) + if (!spaces || (!tab_after_sp && spaces < ts)) return; /* Count up spaces/tabs needed to get to the target. */ @@ -1911,7 +1912,7 @@ txt_dent(sp, tp, isindent) { CHAR_T ch; u_long sw, ts; - size_t cno, current, spaces, target, tabs, off; + size_t cno, current, spaces, target, tabs; int ai_reset; ts = O_VAL(sp, O_TABSTOP); @@ -2707,7 +2708,7 @@ txt_resolve(sp, tiqh, flags) else changed = 0; if (db_set(sp, tp->lno, tp->lb, tp->len) || - changed && vs_change(sp, tp->lno, LINE_RESET)) + (changed && vs_change(sp, tp->lno, LINE_RESET))) return (1); for (lno = tp->lno; (tp = CIRCLEQ_NEXT(tp, q)) != (void *)&sp->tiq; ++lno) { @@ -2716,7 +2717,7 @@ txt_resolve(sp, tiqh, flags) else changed = 0; if (db_append(sp, 0, lno, tp->lb, tp->len) || - changed && vs_change(sp, tp->lno, LINE_RESET)) + (changed && vs_change(sp, tp->lno, LINE_RESET))) return (1); } @@ -2791,7 +2792,7 @@ txt_showmatch(sp, tp) } /* If the match is on the screen, move to it. */ - if (cs.cs_lno < m.lno || cs.cs_lno == m.lno && cs.cs_cno < m.cno) + if (cs.cs_lno < m.lno || (cs.cs_lno == m.lno && cs.cs_cno < m.cno)) return (0); sp->lno = cs.cs_lno; sp->cno = cs.cs_cno; diff --git a/usr.bin/vi/vi/v_word.c b/usr.bin/vi/vi/v_word.c index 44cc132dd7b..9cb613419b7 100644 --- a/usr.bin/vi/vi/v_word.c +++ b/usr.bin/vi/vi/v_word.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_word.c,v 1.4 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: v_word.c,v 1.5 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -127,7 +127,7 @@ fword(sp, vp, type) * counts as a single word move. If it's a motion command, * don't move off the end of the line. */ - if (cs.cs_flags == CS_EMP || cs.cs_flags == 0 && isblank(cs.cs_ch)) { + if (cs.cs_flags == CS_EMP || (cs.cs_flags == 0 && isblank(cs.cs_ch))) { if (ISMOTION(vp) && cs.cs_flags != CS_EMP && cnt == 1) { if (ISCMD(vp->rkp, 'c')) return (0); diff --git a/usr.bin/vi/vi/vi.c b/usr.bin/vi/vi/vi.c index d67e2a93215..19357ff7168 100644 --- a/usr.bin/vi/vi/vi.c +++ b/usr.bin/vi/vi/vi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vi.c,v 1.11 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: vi.c,v 1.12 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -349,9 +349,9 @@ gc_event: * command, since the tag may be moving to the same file. */ if ((F_ISSET(vp, V_ABS) || - F_ISSET(vp, V_ABS_L) && sp->lno != abs.lno || - F_ISSET(vp, V_ABS_C) && - (sp->lno != abs.lno || sp->cno != abs.cno)) && + (F_ISSET(vp, V_ABS_L) && sp->lno != abs.lno) || + (F_ISSET(vp, V_ABS_C) && + (sp->lno != abs.lno || sp->cno != abs.cno))) && mark_set(sp, ABSMARK1, &abs, 1)) goto err; @@ -416,13 +416,13 @@ ret: rval = 1; } #define KEY(key, ec_flags) { \ - if ((gcret = v_key(sp, 0, &ev, ec_flags)) != GC_OK) \ + if ((gcret = v_key(sp, 0, &ev, (ec_flags))) != GC_OK) \ return (gcret); \ if (ev.e_value == K_ESCAPE) \ goto esc; \ if (F_ISSET(&ev.e_ch, CH_MAPPED)) \ *mappedp = 1; \ - key = ev.e_c; \ + (key) = ev.e_c; \ } /* @@ -787,7 +787,7 @@ v_motion(sp, dm, vp, mappedp) vp->m_stop.lno = sp->lno + motion.count - 1; if (db_get(sp, vp->m_stop.lno, 0, NULL, &len)) { if (vp->m_stop.lno != 1 || - vp->key != 'c' && vp->key != '!') { + (vp->key != 'c' && vp->key != '!')) { v_emsg(sp, NULL, VIM_EMPTY); return (1); } @@ -859,7 +859,7 @@ v_motion(sp, dm, vp, mappedp) */ if (!db_exist(sp, vp->m_stop.lno)) { if (vp->m_stop.lno != 1 || - vp->key != 'c' && vp->key != '!') { + (vp->key != 'c' && vp->key != '!')) { v_emsg(sp, NULL, VIM_EMPTY); return (1); } @@ -903,8 +903,8 @@ v_motion(sp, dm, vp, mappedp) * Motions are from the from MARK to the to MARK (inclusive). */ if (motion.m_start.lno > motion.m_stop.lno || - motion.m_start.lno == motion.m_stop.lno && - motion.m_start.cno > motion.m_stop.cno) { + (motion.m_start.lno == motion.m_stop.lno && + motion.m_start.cno > motion.m_stop.cno)) { vp->m_start = motion.m_stop; vp->m_stop = motion.m_start; } else { diff --git a/usr.bin/vi/vi/vi.h b/usr.bin/vi/vi/vi.h index 8e90e6af3c1..54a536de164 100644 --- a/usr.bin/vi/vi/vi.h +++ b/usr.bin/vi/vi/vi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vi.h,v 1.5 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: vi.h,v 1.6 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -25,9 +25,9 @@ typedef struct _vicmd { u_long count2; /* Second count (only used by z). */ EVENT ev; /* Associated event. */ -#define ISCMD(p, key) ((p) == &vikeys[key]) +#define ISCMD(p, key) ((p) == &vikeys[(key)]) VIKEYS const *kp; /* Command/Motion VIKEYS entry. */ -#define ISMOTION(vp) (vp->rkp != NULL && F_ISSET(vp->rkp, V_MOTION)) +#define ISMOTION(vp) ((vp)->rkp != NULL && F_ISSET((vp)->rkp, V_MOTION)) VIKEYS const *rkp; /* Related C/M VIKEYS entry. */ /* @@ -293,7 +293,7 @@ typedef struct _vi_private { recno_t ss_lno; /* 1-N: vi_opt_screens cached line number. */ size_t ss_screens; /* vi_opt_screens cached return value. */ -#define VI_SCR_CFLUSH(vip) vip->ss_lno = OOBLNO +#define VI_SCR_CFLUSH(vip) ((vip)->ss_lno = OOBLNO) size_t srows; /* 1-N: rows in the terminal/window. */ recno_t olno; /* 1-N: old cursor file line. */ @@ -319,7 +319,7 @@ typedef struct _vi_private { #define O_NUMBER_FMT "%7lu " /* O_NUMBER format, length. */ #define O_NUMBER_LENGTH 8 #define SCREEN_COLS(sp) /* Screen columns. */ \ - ((O_ISSET(sp, O_NUMBER) ? (sp)->cols - O_NUMBER_LENGTH : (sp)->cols)) + ((O_ISSET((sp), O_NUMBER) ? (sp)->cols - O_NUMBER_LENGTH : (sp)->cols)) /* * LASTLINE is the zero-based, last line in the screen. Note that it is correct diff --git a/usr.bin/vi/vi/vs_line.c b/usr.bin/vi/vi/vs_line.c index 3d14d4a3d04..69804d6914f 100644 --- a/usr.bin/vi/vi/vs_line.c +++ b/usr.bin/vi/vi/vs_line.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vs_line.c,v 1.7 2003/07/21 07:20:18 dhartmei Exp $ */ +/* $OpenBSD: vs_line.c,v 1.8 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -174,7 +174,7 @@ vs_line(sp, smp, yp, 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) { @@ -191,6 +191,7 @@ vs_line(sp, smp, yp, xp) 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); diff --git a/usr.bin/vi/vi/vs_msg.c b/usr.bin/vi/vi/vs_msg.c index 6ac0236691b..305cbbc5097 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.8 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: vs_msg.c,v 1.9 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -250,12 +250,13 @@ vs_msg(sp, mtype, line, 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 @@ -281,13 +282,14 @@ vs_msg(sp, mtype, line, 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); @@ -349,13 +351,14 @@ vs_msg(sp, mtype, line, 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(*s); --len, ++s); diff --git a/usr.bin/vi/vi/vs_refresh.c b/usr.bin/vi/vi/vs_refresh.c index e842cc79dd0..80464ff9118 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.10 2005/10/17 19:12:16 otto Exp $ */ +/* $OpenBSD: vs_refresh.c,v 1.11 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -247,7 +247,7 @@ vs_paint(sp, flags) * 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)) @@ -284,6 +284,7 @@ small_fill: (void)gp->scr_move(sp, LASTLINE(sp), 0); goto adjust; } } + } /* * 6b: Line down, or current screen. @@ -395,7 +396,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); @@ -404,7 +405,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); @@ -413,6 +415,7 @@ adjust: if (!O_ISSET(sp, O_LEFTRIGHT) && while (cnt > TMAP->soff) if (vs_sm_1up(sp)) return (1); + } } /* @@ -613,8 +616,8 @@ slow: for (smp = HMAP; smp->lno != LNO; ++smp); } /* Adjust the window towards the end of the line. */ - if (off == 0 && off + SCREEN_COLS(sp) < cnt || - off != 0 && off + sp->cols < cnt) { + if ((off == 0 && off + SCREEN_COLS(sp) < cnt) || + (off != 0 && off + sp->cols < cnt)) { do { off += O_VAL(sp, O_SIDESCROLL); } while (off + sp->cols < cnt); diff --git a/usr.bin/vi/vi/vs_relative.c b/usr.bin/vi/vi/vs_relative.c index 34a68f39419..f92976d1669 100644 --- a/usr.bin/vi/vi/vs_relative.c +++ b/usr.bin/vi/vi/vs_relative.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vs_relative.c,v 1.3 2002/02/16 21:27:58 millert Exp $ */ +/* $OpenBSD: vs_relative.c,v 1.4 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -155,12 +155,13 @@ done: if (diffp != NULL) /* XXX */ */ #define TAB_RESET { \ 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; \ + } \ } if (cnop == NULL) while (len--) { diff --git a/usr.bin/vi/vi/vs_smap.c b/usr.bin/vi/vi/vs_smap.c index a6c160ea073..b81f3d27199 100644 --- a/usr.bin/vi/vi/vs_smap.c +++ b/usr.bin/vi/vi/vs_smap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vs_smap.c,v 1.5 2003/03/10 03:53:32 david Exp $ */ +/* $OpenBSD: vs_smap.c,v 1.6 2006/01/08 21:05:40 miod Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -66,7 +66,7 @@ vs_change(sp, lno, op) * * Check for line #2 before going to the end of the file. */ - if ((op == LINE_APPEND && lno == 0 || op == LINE_INSERT && lno == 1) && + if (((op == LINE_APPEND && lno == 0) || (op == LINE_INSERT && lno == 1)) && !db_exist(sp, 2)) { lno = 1; op = LINE_RESET; @@ -290,7 +290,7 @@ err: HMAP->lno = 1; * is amazingly slow, but it's not clear that anyone will care. */ #define HANDLE_WEIRDNESS(cnt) { \ - if (cnt >= sp->t_rows) { \ + if ((cnt) >= sp->t_rows) { \ F_SET(sp, SC_SCR_REFORMAT); \ return (0); \ } \ |