-Wall cleanup for vi

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

-Wall cleanup for vi

Ray Lai
Hi,

This patch removes ``suggest parentheses around && within ||'' and
``suggest explicit braces to avoid ambiguous `else''' warnings,
unused variable warnings (except variables used in #if blocks),
unused goto labels, and puts a function's prototype in an
``#ifdef DEBUG'' block because the function is in one as well.

No binary change.  More cleanup coming.

-Ray-

Index: cl/cl_main.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/cl/cl_main.c,v
retrieving revision 1.14
diff -u -r1.14 cl_main.c
--- cl/cl_main.c 18 Jul 2003 23:11:43 -0000 1.14
+++ cl/cl_main.c 29 Dec 2005 07:03:03 -0000
@@ -196,7 +196,6 @@
 gs_init(name)
  char *name;
 {
- CL_PRIVATE *clp;
  GS *gp;
  char *p;
 
Index: cl/cl_screen.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/cl/cl_screen.c,v
retrieving revision 1.16
diff -u -r1.16 cl_screen.c
--- cl/cl_screen.c 17 Oct 2005 19:12:16 -0000 1.16
+++ cl/cl_screen.c 29 Dec 2005 07:03:03 -0000
@@ -64,8 +64,8 @@
  }
 
  /* 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);
 
  /*
Index: cl/cl_term.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/cl/cl_term.c,v
retrieving revision 1.13
diff -u -r1.13 cl_term.c
--- cl/cl_term.c 17 Oct 2005 19:12:16 -0000 1.13
+++ cl/cl_term.c 29 Dec 2005 07:03:03 -0000
@@ -412,16 +412,18 @@
  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. */
Index: common/cut.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/cut.c,v
retrieving revision 1.8
diff -u -r1.8 cut.c
--- common/cut.c 17 Oct 2005 19:12:16 -0000 1.8
+++ common/cut.c 29 Dec 2005 07:03:04 -0000
@@ -102,8 +102,8 @@
  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 @@
  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;
Index: common/exf.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
retrieving revision 1.21
diff -u -r1.21 exf.c
--- common/exf.c 17 Oct 2005 19:12:16 -0000 1.21
+++ common/exf.c 29 Dec 2005 07:03:04 -0000
@@ -209,7 +209,7 @@
  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 @@
  * 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 @@
  *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 @@
  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 @@
  * 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 @@
 
  ep->mtime = sb.st_mtime;
  }
+ }
 
  /*
  * If the write failed, complain loudly.  ex_writefp() has already
@@ -944,11 +945,12 @@
  */
  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 @@
  * 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 @@
 "263|File modified since last complete write; write or use :edit! to override");
  return (1);
  }
+ }
 
  return (file_m3(sp, force));
 }
Index: common/key.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/key.c,v
retrieving revision 1.7
diff -u -r1.7 key.c
--- common/key.c 17 Oct 2005 19:12:16 -0000 1.7
+++ common/key.c 29 Dec 2005 07:03:04 -0000
@@ -632,7 +632,7 @@
  */
  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. */
Index: common/line.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/line.c,v
retrieving revision 1.6
diff -u -r1.6 line.c
--- common/line.c 17 Oct 2005 19:12:16 -0000 1.6
+++ common/line.c 29 Dec 2005 07:03:04 -0000
@@ -62,7 +62,7 @@
  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);
  }
Index: common/main.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/main.c,v
retrieving revision 1.11
diff -u -r1.11 main.c
--- common/main.c 17 Oct 2005 19:12:16 -0000 1.11
+++ common/main.c 29 Dec 2005 07:03:04 -0000
@@ -41,7 +41,9 @@
 #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 @@
  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 @@
  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 @@
     argv[0][1] == 't' || argv[0][1] == 'w') &&
     argv[0][2] == '\0')
  ++argv;
+ }
  return (0);
 }
 
Index: common/mark.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/mark.c,v
retrieving revision 1.6
diff -u -r1.6 mark.c
--- common/mark.c 17 Oct 2005 19:12:16 -0000 1.6
+++ common/mark.c 29 Dec 2005 07:03:04 -0000
@@ -237,12 +237,13 @@
  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:
  /*
Index: common/msg.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/msg.c,v
retrieving revision 1.14
diff -u -r1.14 msg.c
--- common/msg.c 25 Apr 2003 23:44:08 -0000 1.14
+++ common/msg.c 29 Dec 2005 07:03:04 -0000
@@ -332,7 +332,7 @@
  (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 @@
  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
Index: common/options.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/options.c,v
retrieving revision 1.11
diff -u -r1.11 options.c
--- common/options.c 7 Apr 2003 21:13:54 -0000 1.11
+++ common/options.c 29 Dec 2005 07:03:05 -0000
@@ -554,7 +554,7 @@
  * 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 @@
  if (O_ISSET(sp, offset))
  break;
  }
+ }
 
  if (F_ISSET(op, OPT_EARLYSET)) {
     /* Set the value. */
@@ -572,8 +573,8 @@
  }
 
  /* 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 @@
  }
 
  /* 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 @@
  }
 
  /* 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 @@
  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;
  }
Index: common/put.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/put.c,v
retrieving revision 1.7
diff -u -r1.7 put.c
--- common/put.c 17 Oct 2005 19:12:16 -0000 1.7
+++ common/put.c 29 Dec 2005 07:03:05 -0000
@@ -48,7 +48,7 @@
  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 @@
  return (1);
  }
  }
+ }
  tp = CIRCLEQ_FIRST(&cbp->textq);
 
  /*
Index: common/search.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/search.c,v
retrieving revision 1.7
diff -u -r1.7 search.c
--- common/search.c 17 Feb 2002 19:42:34 -0000 1.7
+++ common/search.c 29 Dec 2005 07:03:05 -0000
@@ -211,7 +211,7 @@
  }
  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 @@
  }
  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);
Index: ex/ex.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex.c,v
retrieving revision 1.12
diff -u -r1.12 ex.c
--- ex/ex.c 17 Oct 2005 19:12:16 -0000 1.12
+++ ex/ex.c 29 Dec 2005 07:03:05 -0000
@@ -1250,7 +1250,7 @@
  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 @@
  ex_badaddr(sp, NULL, A_EOF, NUM_OK);
  goto err;
  }
+ }
  /* FALLTHROUGH */
  case 1:
  if (ecp->addr1.lno == 0) {
@@ -1894,7 +1895,7 @@
  * 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 @@
  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 @@
 
  /* 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 @@
  if (sp->lno == 0)
  sp->lno = 1;
  }
+ }
  free(ecp->o_cp);
  }
 
Index: ex/ex_bang.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_bang.c,v
retrieving revision 1.5
diff -u -r1.5 ex_bang.c
--- ex/ex_bang.c 16 Feb 2002 21:27:57 -0000 1.5
+++ ex/ex_bang.c 29 Dec 2005 07:03:05 -0000
@@ -103,7 +103,7 @@
  */
  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 @@
  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,
Index: ex/ex_cd.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_cd.c,v
retrieving revision 1.7
diff -u -r1.7 ex_cd.c
--- ex/ex_cd.c 21 Apr 2005 15:39:31 -0000 1.7
+++ ex/ex_cd.c 29 Dec 2005 07:03:05 -0000
@@ -93,9 +93,9 @@
  */
  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. */
Index: ex/ex_cscope.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_cscope.c,v
retrieving revision 1.11
diff -u -r1.11 ex_cscope.c
--- ex/ex_cscope.c 17 Oct 2005 19:12:16 -0000 1.11
+++ ex/ex_cscope.c 29 Dec 2005 07:03:06 -0000
@@ -824,7 +824,7 @@
 {
  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 @@
  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)
Index: ex/ex_filter.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_filter.c,v
retrieving revision 1.7
diff -u -r1.7 ex_filter.c
--- ex/ex_filter.c 12 Jun 2002 06:07:17 -0000 1.7
+++ ex/ex_filter.c 29 Dec 2005 07:03:06 -0000
@@ -181,11 +181,12 @@
  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;
  }
 
Index: ex/ex_global.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_global.c,v
retrieving revision 1.7
diff -u -r1.7 ex_global.c
--- ex/ex_global.c 17 Oct 2005 19:12:16 -0000 1.7
+++ ex/ex_global.c 29 Dec 2005 07:03:06 -0000
@@ -125,11 +125,12 @@
  *t = '\0';
  break;
  }
- if (p[0] == '\\')
+ if (p[0] == '\\') {
  if (p[1] == delim)
  ++p;
  else if (p[1] == '\\')
  *t++ = *p++;
+ }
  *t++ = *p++;
  }
 
Index: ex/ex_script.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_script.c,v
retrieving revision 1.12
diff -u -r1.12 ex_script.c
--- ex/ex_script.c 17 Oct 2005 19:12:16 -0000 1.12
+++ ex/ex_script.c 29 Dec 2005 07:03:06 -0000
@@ -379,7 +379,7 @@
  GS *gp;
  struct timeval tv;
  fd_set *rdfd;
- int maxfd, nfd;
+ int maxfd;
 
  gp = sp->gp;
 
@@ -434,7 +434,6 @@
 sscr_insert(sp)
  SCR *sp;
 {
- struct timeval tv;
  CHAR_T *endp, *p, *t;
  SCRIPT *sc;
  struct pollfd pfd[1];
Index: ex/ex_shell.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_shell.c,v
retrieving revision 1.9
diff -u -r1.9 ex_shell.c
--- ex/ex_shell.c 12 Jun 2002 06:07:17 -0000 1.9
+++ ex/ex_shell.c 29 Dec 2005 07:03:06 -0000
@@ -226,136 +226,136 @@
 
 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
 };
 
Index: ex/ex_subst.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_subst.c,v
retrieving revision 1.13
diff -u -r1.13 ex_subst.c
--- ex/ex_subst.c 17 Oct 2005 19:12:16 -0000 1.13
+++ ex/ex_subst.c 29 Dec 2005 07:03:06 -0000
@@ -122,11 +122,12 @@
  *t = '\0';
  break;
  }
- if (p[0] == '\\')
+ if (p[0] == '\\') {
  if (p[1] == delim)
  ++p;
  else if (p[1] == '\\')
  *t++ = *p++;
+ }
  *t++ = *p++;
  }
 
@@ -476,7 +477,7 @@
  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);
  }
Index: ex/ex_tag.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_tag.c,v
retrieving revision 1.11
diff -u -r1.11 ex_tag.c
--- ex/ex_tag.c 17 Oct 2005 19:12:16 -0000 1.11
+++ ex/ex_tag.c 29 Dec 2005 07:03:06 -0000
@@ -169,7 +169,7 @@
  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 @@
  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 @@
 notfound: tag_msg(sp, TAG_SEARCH, tag);
  return (1);
  }
+ }
  /*
  * !!!
  * Historically, tags set the search direction if it wasn't
Index: ex/ex_usage.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_usage.c,v
retrieving revision 1.4
diff -u -r1.4 ex_usage.c
--- ex/ex_usage.c 16 Feb 2002 21:27:57 -0000 1.4
+++ ex/ex_usage.c 29 Dec 2005 07:03:07 -0000
@@ -79,7 +79,7 @@
  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",
Index: vi/getc.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/getc.c,v
retrieving revision 1.6
diff -u -r1.6 getc.c
--- vi/getc.c 16 Feb 2002 21:27:58 -0000 1.6
+++ vi/getc.c 29 Dec 2005 07:03:07 -0000
@@ -156,7 +156,7 @@
  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 @@
  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;
  }
Index: vi/v_at.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_at.c,v
retrieving revision 1.5
diff -u -r1.5 v_at.c
--- vi/v_at.c 17 Oct 2005 19:12:16 -0000 1.5
+++ vi/v_at.c 29 Dec 2005 07:03:07 -0000
@@ -90,9 +90,9 @@
  * 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);
 
Index: vi/v_mark.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_mark.c,v
retrieving revision 1.5
diff -u -r1.5 v_mark.c
--- vi/v_mark.c 16 Feb 2002 21:27:58 -0000 1.5
+++ vi/v_mark.c 29 Dec 2005 07:03:07 -0000
@@ -113,7 +113,7 @@
  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 @@
  * 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;
Index: vi/v_match.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_match.c,v
retrieving revision 1.4
diff -u -r1.4 v_match.c
--- vi/v_match.c 16 Feb 2002 21:27:58 -0000 1.4
+++ vi/v_match.c 29 Dec 2005 07:03:07 -0000
@@ -137,8 +137,8 @@
  * 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;
Index: vi/v_paragraph.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_paragraph.c,v
retrieving revision 1.4
diff -u -r1.4 v_paragraph.c
--- vi/v_paragraph.c 16 Feb 2002 21:27:58 -0000 1.4
+++ vi/v_paragraph.c 29 Dec 2005 07:03:07 -0000
@@ -51,7 +51,7 @@
  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 @@
  * 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 @@
  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 @@
  */
  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 @@
  F_SET(vp, VM_LMODE);
  } else
  --vp->m_start.cno;
+ }
 
  if (vp->m_start.lno <= 1)
  goto sof;
Index: vi/v_replace.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_replace.c,v
retrieving revision 1.5
diff -u -r1.5 v_replace.c
--- vi/v_replace.c 16 Feb 2002 21:27:58 -0000 1.5
+++ vi/v_replace.c 29 Dec 2005 07:03:07 -0000
@@ -156,7 +156,7 @@
  * 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;
Index: vi/v_scroll.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_scroll.c,v
retrieving revision 1.5
diff -u -r1.5 v_scroll.c
--- vi/v_scroll.c 16 Feb 2002 21:27:58 -0000 1.5
+++ vi/v_scroll.c 29 Dec 2005 07:03:07 -0000
@@ -201,8 +201,8 @@
  * 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
Index: vi/v_search.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_search.c,v
retrieving revision 1.8
diff -u -r1.8 v_search.c
--- vi/v_search.c 17 Oct 2005 19:12:16 -0000 1.8
+++ vi/v_search.c 29 Dec 2005 07:03:07 -0000
@@ -468,8 +468,8 @@
  * 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;
Index: vi/v_section.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_section.c,v
retrieving revision 1.4
diff -u -r1.4 v_section.c
--- vi/v_section.c 16 Feb 2002 21:27:58 -0000 1.4
+++ vi/v_section.c 29 Dec 2005 07:03:07 -0000
@@ -84,7 +84,7 @@
  * 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 @@
  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 @@
  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 @@
  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;
Index: vi/v_sentence.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_sentence.c,v
retrieving revision 1.4
diff -u -r1.4 v_sentence.c
--- vi/v_sentence.c 16 Feb 2002 21:27:58 -0000 1.4
+++ vi/v_sentence.c 29 Dec 2005 07:03:07 -0000
@@ -76,7 +76,7 @@
  * 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 @@
  * 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 @@
  F_SET(vp, VM_LMODE);
  } else
  --vp->m_start.cno;
+ }
  vp->m_final = vp->m_stop;
  return (0);
 }
Index: vi/v_txt.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_txt.c,v
retrieving revision 1.16
diff -u -r1.16 v_txt.c
--- vi/v_txt.c 17 Oct 2005 19:12:16 -0000 1.16
+++ vi/v_txt.c 29 Dec 2005 07:03:08 -0000
@@ -1563,7 +1563,7 @@
  *
  * 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 @@
  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 @@
  * 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 @@
 {
  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 @@
  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 @@
  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 @@
  }
 
  /* 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;
Index: vi/v_word.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_word.c,v
retrieving revision 1.4
diff -u -r1.4 v_word.c
--- vi/v_word.c 16 Feb 2002 21:27:58 -0000 1.4
+++ vi/v_word.c 29 Dec 2005 07:03:08 -0000
@@ -127,7 +127,7 @@
  * 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);
Index: vi/vi.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vi.c,v
retrieving revision 1.11
diff -u -r1.11 vi.c
--- vi/vi.c 17 Oct 2005 19:12:16 -0000 1.11
+++ vi/vi.c 29 Dec 2005 07:03:08 -0000
@@ -349,9 +349,9 @@
  * 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;
 
@@ -787,7 +787,7 @@
  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 @@
  */
  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 @@
  * 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 {
Index: vi/vs_line.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vs_line.c,v
retrieving revision 1.7
diff -u -r1.7 vs_line.c
--- vi/vs_line.c 21 Jul 2003 07:20:18 -0000 1.7
+++ vi/vs_line.c 29 Dec 2005 07:03:08 -0000
@@ -174,7 +174,7 @@
  * 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 @@
 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);
Index: vi/vs_msg.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vs_msg.c,v
retrieving revision 1.8
diff -u -r1.8 vs_msg.c
--- vi/vs_msg.c 17 Oct 2005 19:12:16 -0000 1.8
+++ vi/vs_msg.c 29 Dec 2005 07:03:08 -0000
@@ -250,12 +250,13 @@
  * 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 @@
  * 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 @@
  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);
Index: vi/vs_refresh.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vs_refresh.c,v
retrieving revision 1.10
diff -u -r1.10 vs_refresh.c
--- vi/vs_refresh.c 17 Oct 2005 19:12:16 -0000 1.10
+++ vi/vs_refresh.c 29 Dec 2005 07:03:09 -0000
@@ -247,7 +247,7 @@
  * 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 @@
  goto adjust;
  }
  }
+ }
 
  /*
  * 6b: Line down, or current screen.
@@ -395,7 +396,7 @@
 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 @@
  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 @@
  while (cnt > TMAP->soff)
  if (vs_sm_1up(sp))
  return (1);
+ }
  }
 
  /*
@@ -613,8 +616,8 @@
  }
 
  /* 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);
Index: vi/vs_relative.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vs_relative.c,v
retrieving revision 1.3
diff -u -r1.3 vs_relative.c
--- vi/vs_relative.c 16 Feb 2002 21:27:58 -0000 1.3
+++ vi/vs_relative.c 29 Dec 2005 07:03:09 -0000
@@ -155,12 +155,13 @@
  */
 #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--) {
Index: vi/vs_smap.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vs_smap.c,v
retrieving revision 1.5
diff -u -r1.5 vs_smap.c
--- vi/vs_smap.c 10 Mar 2003 03:53:32 -0000 1.5
+++ vi/vs_smap.c 29 Dec 2005 07:03:09 -0000
@@ -66,7 +66,7 @@
  *
  * 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;

Reply | Threaded
Open this post in threaded view
|

Re: -Wall cleanup for vi

Claudio Jeker
On Thu, Dec 29, 2005 at 02:13:03AM -0500, Ray Lai wrote:

> Hi,
>
> This patch removes ``suggest parentheses around && within ||'' and
> ``suggest explicit braces to avoid ambiguous `else''' warnings,
> unused variable warnings (except variables used in #if blocks),
> unused goto labels, and puts a function's prototype in an
> ``#ifdef DEBUG'' block because the function is in one as well.
>
> No binary change.  More cleanup coming.
>
> Index: cl/cl_screen.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/vi/cl/cl_screen.c,v
> retrieving revision 1.16
> diff -u -r1.16 cl_screen.c
> --- cl/cl_screen.c 17 Oct 2005 19:12:16 -0000 1.16
> +++ cl/cl_screen.c 29 Dec 2005 07:03:03 -0000
> @@ -64,8 +64,8 @@
>   }
>  
>   /* 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);
>  
>   /*

This here smells like a badly defined makro. You should add the () to the
makro.

The rest looks ok but I just glanced over it.

--
:wq Claudio

Reply | Threaded
Open this post in threaded view
|

Re: -Wall cleanup for vi

Claudio Jeker
On Thu, Dec 29, 2005 at 04:43:55PM +0059, Claudio Jeker wrote:

> On Thu, Dec 29, 2005 at 02:13:03AM -0500, Ray Lai wrote:
> > Hi,
> >
> > This patch removes ``suggest parentheses around && within ||'' and
> > ``suggest explicit braces to avoid ambiguous `else''' warnings,
> > unused variable warnings (except variables used in #if blocks),
> > unused goto labels, and puts a function's prototype in an
> > ``#ifdef DEBUG'' block because the function is in one as well.
> >
> > No binary change.  More cleanup coming.
> >
> > Index: cl/cl_screen.c
> > ===================================================================
> > RCS file: /cvs/src/usr.bin/vi/cl/cl_screen.c,v
> > retrieving revision 1.16
> > diff -u -r1.16 cl_screen.c
> > --- cl/cl_screen.c 17 Oct 2005 19:12:16 -0000 1.16
> > +++ cl/cl_screen.c 29 Dec 2005 07:03:03 -0000
> > @@ -64,8 +64,8 @@
> >   }
> >  
> >   /* 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);
> >  
> >   /*
>
> This here smells like a badly defined makro. You should add the () to the
> makro.
>

Bah. I should pay more attention and look better. I read it as
        if ((LF_ISSET(SC_EX)) && F_ISSET(sp, SC_SCR_EX))
looks like all those +, -, ( and ) got me totaly confused.
Sorry for the noise.

> The rest looks ok but I just glanced over it.
>

--
:wq Claudio

Reply | Threaded
Open this post in threaded view
|

Re: -Wall cleanup for vi

Cédric Berger-2
In reply to this post by Claudio Jeker
Claudio Jeker wrote:

> On Thu, Dec 29, 2005 at 02:13:03AM -0500, Ray Lai wrote:
>  
>> Hi,
>>
>> This patch removes ``suggest parentheses around && within ||'' and
>> ``suggest explicit braces to avoid ambiguous `else''' warnings,
>> unused variable warnings (except variables used in #if blocks),
>> unused goto labels, and puts a function's prototype in an
>> ``#ifdef DEBUG'' block because the function is in one as well.
>>
>> No binary change.  More cleanup coming.
>>
>> Index: cl/cl_screen.c
>> ===================================================================
>> RCS file: /cvs/src/usr.bin/vi/cl/cl_screen.c,v
>> retrieving revision 1.16
>> diff -u -r1.16 cl_screen.c
>> --- cl/cl_screen.c 17 Oct 2005 19:12:16 -0000 1.16
>> +++ cl/cl_screen.c 29 Dec 2005 07:03:03 -0000
>> @@ -64,8 +64,8 @@
>>   }
>>  
>>   /* 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);
>>  
>>   /*
>>    
>
> This here smells like a badly defined makro. You should add the () to the
> makro.
>  
Huh?
I think what gcc doesn't like is the "(a && b || c && d)" and this has
nothing to do with the macro themselves.
Cedric

Reply | Threaded
Open this post in threaded view
|

Re: -Wall cleanup for vi

Ray Lai
In reply to this post by Claudio Jeker
On Thu, Dec 29, 2005 at 05:10:40PM +0059, Claudio Jeker wrote:

> On Thu, Dec 29, 2005 at 04:43:55PM +0059, Claudio Jeker wrote:
> > On Thu, Dec 29, 2005 at 02:13:03AM -0500, Ray Lai wrote:
> > > This patch removes ``suggest parentheses around && within ||'' and
> > > ``suggest explicit braces to avoid ambiguous `else''' warnings,
> > > unused variable warnings (except variables used in #if blocks),
> > > unused goto labels, and puts a function's prototype in an
> > > ``#ifdef DEBUG'' block because the function is in one as well.
> > >
> > > No binary change.  More cleanup coming.
> > >
> > > Index: cl/cl_screen.c
> > > ===================================================================
> > > RCS file: /cvs/src/usr.bin/vi/cl/cl_screen.c,v
> > > retrieving revision 1.16
> > > diff -u -r1.16 cl_screen.c
> > > --- cl/cl_screen.c 17 Oct 2005 19:12:16 -0000 1.16
> > > +++ cl/cl_screen.c 29 Dec 2005 07:03:03 -0000
> > > @@ -64,8 +64,8 @@
> > >   }
> > >  
> > >   /* 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);
> > >  
> > >   /*
> >
> > This here smells like a badly defined makro. You should add the () to the
> > makro.
> >
>
> Bah. I should pay more attention and look better. I read it as
> if ((LF_ISSET(SC_EX)) && F_ISSET(sp, SC_SCR_EX))
> looks like all those +, -, ( and ) got me totaly confused.
> Sorry for the noise.

This diff also puts parentheses around macro variables.  No binary
change.

-Ray-

Index: catalog/dump.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/catalog/dump.c,v
retrieving revision 1.3
diff -u -r1.3 dump.c
--- catalog/dump.c 3 Jun 2003 02:56:21 -0000 1.3
+++ catalog/dump.c 29 Dec 2005 19:31:55 -0000
@@ -49,7 +49,7 @@
  int ch, s1, s2, s3;
 
 #define TESTD(s) { \
- if ((s = getc(fp)) == EOF) \
+ if (((s) = getc(fp)) == EOF) \
  return; \
  if (!isdigit(s)) \
  continue; \
Index: cl/cl.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/cl/cl.h,v
retrieving revision 1.6
diff -u -r1.6 cl.h
--- cl/cl.h 29 Jan 2001 01:58:26 -0000 1.6
+++ cl/cl.h 29 Dec 2005 19:31:55 -0000
@@ -54,7 +54,7 @@
 } 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;
Index: cl/cl_main.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/cl/cl_main.c,v
retrieving revision 1.14
diff -u -r1.14 cl_main.c
--- cl/cl_main.c 18 Jul 2003 23:11:43 -0000 1.14
+++ cl/cl_main.c 29 Dec 2005 19:31:55 -0000
@@ -196,7 +196,6 @@
 gs_init(name)
  char *name;
 {
- CL_PRIVATE *clp;
  GS *gp;
  char *p;
 
Index: cl/cl_screen.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/cl/cl_screen.c,v
retrieving revision 1.16
diff -u -r1.16 cl_screen.c
--- cl/cl_screen.c 17 Oct 2005 19:12:16 -0000 1.16
+++ cl/cl_screen.c 29 Dec 2005 19:31:55 -0000
@@ -64,8 +64,8 @@
  }
 
  /* 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);
 
  /*
Index: cl/cl_term.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/cl/cl_term.c,v
retrieving revision 1.13
diff -u -r1.13 cl_term.c
--- cl/cl_term.c 17 Oct 2005 19:12:16 -0000 1.13
+++ cl/cl_term.c 29 Dec 2005 19:31:55 -0000
@@ -412,16 +412,18 @@
  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. */
Index: common/cut.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/cut.c,v
retrieving revision 1.8
diff -u -r1.8 cut.c
--- common/cut.c 17 Oct 2005 19:12:16 -0000 1.8
+++ common/cut.c 29 Dec 2005 19:31:55 -0000
@@ -102,8 +102,8 @@
  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 @@
  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;
Index: common/cut.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/cut.h,v
retrieving revision 1.5
diff -u -r1.5 cut.h
--- common/cut.h 17 Oct 2005 19:12:16 -0000 1.5
+++ common/cut.h 29 Dec 2005 19:31:55 -0000
@@ -68,7 +68,7 @@
  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; \
 }
 
Index: common/exf.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
retrieving revision 1.21
diff -u -r1.21 exf.c
--- common/exf.c 17 Oct 2005 19:12:16 -0000 1.21
+++ common/exf.c 29 Dec 2005 19:31:56 -0000
@@ -209,7 +209,7 @@
  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 @@
  * 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 @@
  *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 @@
  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 @@
  * 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 @@
 
  ep->mtime = sb.st_mtime;
  }
+ }
 
  /*
  * If the write failed, complain loudly.  ex_writefp() has already
@@ -944,11 +945,12 @@
  */
  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 @@
  * 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 @@
 "263|File modified since last complete write; write or use :edit! to override");
  return (1);
  }
+ }
 
  return (file_m3(sp, force));
 }
Index: common/gs.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/gs.h,v
retrieving revision 1.8
diff -u -r1.8 gs.h
--- common/gs.h 17 Oct 2005 19:12:16 -0000 1.8
+++ common/gs.h 29 Dec 2005 19:31:56 -0000
@@ -119,10 +119,12 @@
 #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 @@
 
 #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];
Index: common/key.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/key.c,v
retrieving revision 1.7
diff -u -r1.7 key.c
--- common/key.c 17 Oct 2005 19:12:16 -0000 1.7
+++ common/key.c 29 Dec 2005 19:31:56 -0000
@@ -434,10 +434,10 @@
 
 /* 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 @@
  */
  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. */
Index: common/key.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/key.h,v
retrieving revision 1.3
diff -u -r1.3 key.h
--- common/key.h 29 Jan 2001 01:58:29 -0000 1.3
+++ common/key.h 29 Dec 2005 19:31:56 -0000
@@ -134,7 +134,7 @@
 #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 @@
 #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)
Index: common/line.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/line.c,v
retrieving revision 1.6
diff -u -r1.6 line.c
--- common/line.c 17 Oct 2005 19:12:16 -0000 1.6
+++ common/line.c 29 Dec 2005 19:31:56 -0000
@@ -62,7 +62,7 @@
  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);
  }
Index: common/main.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/main.c,v
retrieving revision 1.11
diff -u -r1.11 main.c
--- common/main.c 17 Oct 2005 19:12:16 -0000 1.11
+++ common/main.c 29 Dec 2005 19:31:56 -0000
@@ -41,7 +41,9 @@
 #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 @@
  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 @@
  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 @@
     argv[0][1] == 't' || argv[0][1] == 'w') &&
     argv[0][2] == '\0')
  ++argv;
+ }
  return (0);
 }
 
Index: common/mark.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/mark.c,v
retrieving revision 1.6
diff -u -r1.6 mark.c
--- common/mark.c 17 Oct 2005 19:12:16 -0000 1.6
+++ common/mark.c 29 Dec 2005 19:31:56 -0000
@@ -237,12 +237,13 @@
  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:
  /*
Index: common/mem.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/mem.h,v
retrieving revision 1.4
diff -u -r1.4 mem.h
--- common/mem.h 29 Jan 2001 01:58:30 -0000 1.4
+++ common/mem.h 29 Dec 2005 19:31:56 -0000
@@ -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)))
Index: common/msg.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/msg.c,v
retrieving revision 1.14
diff -u -r1.14 msg.c
--- common/msg.c 25 Apr 2003 23:44:08 -0000 1.14
+++ common/msg.c 29 Dec 2005 19:31:56 -0000
@@ -332,7 +332,7 @@
  (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 @@
  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
Index: common/options.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/options.c,v
retrieving revision 1.11
diff -u -r1.11 options.c
--- common/options.c 7 Apr 2003 21:13:54 -0000 1.11
+++ common/options.c 29 Dec 2005 19:31:57 -0000
@@ -302,8 +302,8 @@
 
  /* 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 @@
  * 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 @@
  if (O_ISSET(sp, offset))
  break;
  }
+ }
 
  if (F_ISSET(op, OPT_EARLYSET)) {
     /* Set the value. */
@@ -572,8 +573,8 @@
  }
 
  /* 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 @@
  }
 
  /* 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 @@
  }
 
  /* 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 @@
  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;
  }
Index: common/options.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/options.h,v
retrieving revision 1.7
diff -u -r1.7 options.h
--- common/options.h 16 Feb 2002 21:27:57 -0000 1.7
+++ common/options.h 29 Dec 2005 19:31:57 -0000
@@ -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 @@
  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. */
Index: common/put.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/put.c,v
retrieving revision 1.7
diff -u -r1.7 put.c
--- common/put.c 17 Oct 2005 19:12:16 -0000 1.7
+++ common/put.c 29 Dec 2005 19:31:57 -0000
@@ -48,7 +48,7 @@
  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 @@
  return (1);
  }
  }
+ }
  tp = CIRCLEQ_FIRST(&cbp->textq);
 
  /*
Index: common/search.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/search.c,v
retrieving revision 1.7
diff -u -r1.7 search.c
--- common/search.c 17 Feb 2002 19:42:34 -0000 1.7
+++ common/search.c 29 Dec 2005 19:31:57 -0000
@@ -211,7 +211,7 @@
  }
  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 @@
  }
  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);
Index: common/util.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/util.h,v
retrieving revision 1.2
diff -u -r1.2 util.h
--- common/util.h 29 Jan 2001 01:58:32 -0000 1.2
+++ common/util.h 29 Dec 2005 19:31:57 -0000
@@ -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)))
Index: ex/ex.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex.c,v
retrieving revision 1.12
diff -u -r1.12 ex.c
--- ex/ex.c 17 Oct 2005 19:12:16 -0000 1.12
+++ ex/ex.c 29 Dec 2005 19:31:57 -0000
@@ -1250,7 +1250,7 @@
  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 @@
  ex_badaddr(sp, NULL, A_EOF, NUM_OK);
  goto err;
  }
+ }
  /* FALLTHROUGH */
  case 1:
  if (ecp->addr1.lno == 0) {
@@ -1894,7 +1895,7 @@
  * 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 @@
  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 @@
 
  /* 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 @@
  if (sp->lno == 0)
  sp->lno = 1;
  }
+ }
  free(ecp->o_cp);
  }
 
Index: ex/ex.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex.h,v
retrieving revision 1.5
diff -u -r1.5 ex.h
--- ex/ex.h 16 Feb 2002 21:27:57 -0000 1.5
+++ ex/ex.h 29 Dec 2005 19:31:57 -0000
@@ -48,8 +48,8 @@
  * 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 @@
  */
 #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 @@
 
  /* 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. */
Index: ex/ex_bang.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_bang.c,v
retrieving revision 1.5
diff -u -r1.5 ex_bang.c
--- ex/ex_bang.c 16 Feb 2002 21:27:57 -0000 1.5
+++ ex/ex_bang.c 29 Dec 2005 19:31:58 -0000
@@ -103,7 +103,7 @@
  */
  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 @@
  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,
Index: ex/ex_cd.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_cd.c,v
retrieving revision 1.7
diff -u -r1.7 ex_cd.c
--- ex/ex_cd.c 21 Apr 2005 15:39:31 -0000 1.7
+++ ex/ex_cd.c 29 Dec 2005 19:31:58 -0000
@@ -93,9 +93,9 @@
  */
  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. */
Index: ex/ex_cscope.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_cscope.c,v
retrieving revision 1.11
diff -u -r1.11 ex_cscope.c
--- ex/ex_cscope.c 17 Oct 2005 19:12:16 -0000 1.11
+++ ex/ex_cscope.c 29 Dec 2005 19:31:58 -0000
@@ -824,7 +824,7 @@
 {
  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 @@
  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)
Index: ex/ex_filter.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_filter.c,v
retrieving revision 1.7
diff -u -r1.7 ex_filter.c
--- ex/ex_filter.c 12 Jun 2002 06:07:17 -0000 1.7
+++ ex/ex_filter.c 29 Dec 2005 19:31:58 -0000
@@ -181,11 +181,12 @@
  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;
  }
 
Index: ex/ex_global.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_global.c,v
retrieving revision 1.7
diff -u -r1.7 ex_global.c
--- ex/ex_global.c 17 Oct 2005 19:12:16 -0000 1.7
+++ ex/ex_global.c 29 Dec 2005 19:31:58 -0000
@@ -125,11 +125,12 @@
  *t = '\0';
  break;
  }
- if (p[0] == '\\')
+ if (p[0] == '\\') {
  if (p[1] == delim)
  ++p;
  else if (p[1] == '\\')
  *t++ = *p++;
+ }
  *t++ = *p++;
  }
 
Index: ex/ex_script.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_script.c,v
retrieving revision 1.12
diff -u -r1.12 ex_script.c
--- ex/ex_script.c 17 Oct 2005 19:12:16 -0000 1.12
+++ ex/ex_script.c 29 Dec 2005 19:31:58 -0000
@@ -379,7 +379,7 @@
  GS *gp;
  struct timeval tv;
  fd_set *rdfd;
- int maxfd, nfd;
+ int maxfd;
 
  gp = sp->gp;
 
@@ -434,7 +434,6 @@
 sscr_insert(sp)
  SCR *sp;
 {
- struct timeval tv;
  CHAR_T *endp, *p, *t;
  SCRIPT *sc;
  struct pollfd pfd[1];
Index: ex/ex_shell.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_shell.c,v
retrieving revision 1.9
diff -u -r1.9 ex_shell.c
--- ex/ex_shell.c 12 Jun 2002 06:07:17 -0000 1.9
+++ ex/ex_shell.c 29 Dec 2005 19:31:58 -0000
@@ -226,136 +226,136 @@
 
 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
 };
 
Index: ex/ex_subst.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_subst.c,v
retrieving revision 1.13
diff -u -r1.13 ex_subst.c
--- ex/ex_subst.c 17 Oct 2005 19:12:16 -0000 1.13
+++ ex/ex_subst.c 29 Dec 2005 19:31:58 -0000
@@ -122,11 +122,12 @@
  *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 @@
  * 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 @@
 #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 @@
  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 @@
 #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) { \
Index: ex/ex_tag.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_tag.c,v
retrieving revision 1.11
diff -u -r1.11 ex_tag.c
--- ex/ex_tag.c 17 Oct 2005 19:12:16 -0000 1.11
+++ ex/ex_tag.c 29 Dec 2005 19:31:59 -0000
@@ -169,7 +169,7 @@
  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 @@
  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 @@
 notfound: tag_msg(sp, TAG_SEARCH, tag);
  return (1);
  }
+ }
  /*
  * !!!
  * Historically, tags set the search direction if it wasn't
@@ -1244,7 +1245,7 @@
 #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)
Index: ex/ex_usage.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_usage.c,v
retrieving revision 1.4
diff -u -r1.4 ex_usage.c
--- ex/ex_usage.c 16 Feb 2002 21:27:57 -0000 1.4
+++ ex/ex_usage.c 29 Dec 2005 19:31:59 -0000
@@ -79,7 +79,7 @@
  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",
Index: include/bitstring.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/include/bitstring.h,v
retrieving revision 1.3
diff -u -r1.3 bitstring.h
--- include/bitstring.h 3 Jun 2003 02:56:22 -0000 1.3
+++ include/bitstring.h 29 Dec 2005 19:31:59 -0000
@@ -76,8 +76,8 @@
 
  /* 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 @@
 
  /* 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 @@
 
  /* 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 @@
 
  /* 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]) { \
Index: vi/getc.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/getc.c,v
retrieving revision 1.6
diff -u -r1.6 getc.c
--- vi/getc.c 16 Feb 2002 21:27:58 -0000 1.6
+++ vi/getc.c 29 Dec 2005 19:31:59 -0000
@@ -156,7 +156,7 @@
  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 @@
  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;
  }
Index: vi/v_at.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_at.c,v
retrieving revision 1.5
diff -u -r1.5 v_at.c
--- vi/v_at.c 17 Oct 2005 19:12:16 -0000 1.5
+++ vi/v_at.c 29 Dec 2005 19:31:59 -0000
@@ -90,9 +90,9 @@
  * 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);
 
Index: vi/v_increment.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_increment.c,v
retrieving revision 1.5
diff -u -r1.5 v_increment.c
--- vi/v_increment.c 16 Feb 2002 21:27:58 -0000 1.5
+++ vi/v_increment.c 29 Dec 2005 19:31:59 -0000
@@ -102,7 +102,7 @@
  }
 
 #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')
 
Index: vi/v_mark.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_mark.c,v
retrieving revision 1.5
diff -u -r1.5 v_mark.c
--- vi/v_mark.c 16 Feb 2002 21:27:58 -0000 1.5
+++ vi/v_mark.c 29 Dec 2005 19:31:59 -0000
@@ -113,7 +113,7 @@
  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 @@
  * 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;
Index: vi/v_match.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_match.c,v
retrieving revision 1.4
diff -u -r1.4 v_match.c
--- vi/v_match.c 16 Feb 2002 21:27:58 -0000 1.4
+++ vi/v_match.c 29 Dec 2005 19:31:59 -0000
@@ -137,8 +137,8 @@
  * 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;
Index: vi/v_paragraph.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_paragraph.c,v
retrieving revision 1.4
diff -u -r1.4 v_paragraph.c
--- vi/v_paragraph.c 16 Feb 2002 21:27:58 -0000 1.4
+++ vi/v_paragraph.c 29 Dec 2005 19:31:59 -0000
@@ -51,7 +51,7 @@
  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 @@
  * 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 @@
  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 @@
  */
  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 @@
  F_SET(vp, VM_LMODE);
  } else
  --vp->m_start.cno;
+ }
 
  if (vp->m_start.lno <= 1)
  goto sof;
Index: vi/v_replace.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_replace.c,v
retrieving revision 1.5
diff -u -r1.5 v_replace.c
--- vi/v_replace.c 16 Feb 2002 21:27:58 -0000 1.5
+++ vi/v_replace.c 29 Dec 2005 19:31:59 -0000
@@ -156,7 +156,7 @@
  * 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;
Index: vi/v_scroll.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_scroll.c,v
retrieving revision 1.5
diff -u -r1.5 v_scroll.c
--- vi/v_scroll.c 16 Feb 2002 21:27:58 -0000 1.5
+++ vi/v_scroll.c 29 Dec 2005 19:31:59 -0000
@@ -201,8 +201,8 @@
  * 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
Index: vi/v_search.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_search.c,v
retrieving revision 1.8
diff -u -r1.8 v_search.c
--- vi/v_search.c 17 Oct 2005 19:12:16 -0000 1.8
+++ vi/v_search.c 29 Dec 2005 19:31:59 -0000
@@ -468,8 +468,8 @@
  * 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;
Index: vi/v_section.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_section.c,v
retrieving revision 1.4
diff -u -r1.4 v_section.c
--- vi/v_section.c 16 Feb 2002 21:27:58 -0000 1.4
+++ vi/v_section.c 29 Dec 2005 19:31:59 -0000
@@ -84,7 +84,7 @@
  * 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 @@
  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 @@
  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 @@
  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;
Index: vi/v_sentence.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_sentence.c,v
retrieving revision 1.4
diff -u -r1.4 v_sentence.c
--- vi/v_sentence.c 16 Feb 2002 21:27:58 -0000 1.4
+++ vi/v_sentence.c 29 Dec 2005 19:31:59 -0000
@@ -76,7 +76,7 @@
  * 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 @@
  * 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 @@
  F_SET(vp, VM_LMODE);
  } else
  --vp->m_start.cno;
+ }
  vp->m_final = vp->m_stop;
  return (0);
 }
Index: vi/v_txt.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_txt.c,v
retrieving revision 1.16
diff -u -r1.16 v_txt.c
--- vi/v_txt.c 17 Oct 2005 19:12:16 -0000 1.16
+++ vi/v_txt.c 29 Dec 2005 19:32:00 -0000
@@ -1563,7 +1563,7 @@
  *
  * 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 @@
  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 @@
  * 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 @@
 {
  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 @@
  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 @@
  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 @@
  }
 
  /* 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;
Index: vi/v_word.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_word.c,v
retrieving revision 1.4
diff -u -r1.4 v_word.c
--- vi/v_word.c 16 Feb 2002 21:27:58 -0000 1.4
+++ vi/v_word.c 29 Dec 2005 19:32:00 -0000
@@ -127,7 +127,7 @@
  * 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);
Index: vi/vi.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vi.c,v
retrieving revision 1.11
diff -u -r1.11 vi.c
--- vi/vi.c 17 Oct 2005 19:12:16 -0000 1.11
+++ vi/vi.c 29 Dec 2005 19:32:00 -0000
@@ -349,9 +349,9 @@
  * 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 @@
 }
 
 #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 @@
  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 @@
  */
  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 @@
  * 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 {
Index: vi/vi.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vi.h,v
retrieving revision 1.5
diff -u -r1.5 vi.h
--- vi/vi.h 17 Oct 2005 19:12:16 -0000 1.5
+++ vi/vi.h 29 Dec 2005 19:32:00 -0000
@@ -25,9 +25,9 @@
  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 @@
 
  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 @@
 #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
Index: vi/vs_line.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vs_line.c,v
retrieving revision 1.7
diff -u -r1.7 vs_line.c
--- vi/vs_line.c 21 Jul 2003 07:20:18 -0000 1.7
+++ vi/vs_line.c 29 Dec 2005 19:32:01 -0000
@@ -174,7 +174,7 @@
  * 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 =
Reply | Threaded
Open this post in threaded view
|

Re: -Wall cleanup for vi

Ray Lai
Hi,

This diff removes ``operation on `VARIABLE' may be undefined'' -Wall
warnings.  No binary change on i386.  Please look at my previous
diff as well.

-Ray-

Index: ex/ex_txt.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex_txt.c,v
retrieving revision 1.8
diff -u -r1.8 ex_txt.c
--- ex/ex_txt.c 17 Oct 2005 19:12:16 -0000 1.8
+++ ex/ex_txt.c 3 Jan 2006 18:12:22 -0000
@@ -400,8 +400,8 @@
  ++scno;
 
  /* Get the previous shiftwidth column. */
- cno = scno;
- scno -= --scno % sw;
+ cno = scno--;
+ scno -= scno % sw;
 
  /*
  * Since we don't know what comes before the character(s) being
Index: vi/v_txt.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/v_txt.c,v
retrieving revision 1.16
diff -u -r1.16 v_txt.c
--- vi/v_txt.c 17 Oct 2005 19:12:16 -0000 1.16
+++ vi/v_txt.c 3 Jan 2006 18:12:23 -0000
@@ -1940,8 +1940,10 @@
  target = current;
  if (isindent)
  target += COL_OFF(target, sw);
- else
- target -= --target % sw;
+ else {
+ --target;
+ target -= target % sw;
+ }
 
  /*
  * The AI characters will be turned into overwrite characters if the

Reply | Threaded
Open this post in threaded view
|

Re: -Wall cleanup for vi

Ray Lai
Hi,

This diff removes a ``comparison is always true due to limited range
of data type'' -Wall warning.  An infinte loop occurs if isspace()
is false for 0x01 to 0xff (and then to 0x00 due to integer overflow).

The relevant code is:
    149 /* Find a non-printable character to use as a message separator. */
    150 for (ch = 1; ch <= MAX_CHAR_T; ++ch)
    151 if (!isprint(ch)) {
    152 gp->noprint = ch;
    153 break;
    154 }
    155 if (ch != gp->noprint) {
    156 msgq(sp, M_ERR, "079|No non-printable character found");
    157 return (1);
    158 }
    159 return (0);
(ch and gp->noprint are CHAR_T types, typedefed to unsigned char,
and MAX_CHAR_T is defined to be 0xff.)

Please look at my previous diffs as well.  Thank you.

-Ray-

Index: common/key.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/key.c,v
retrieving revision 1.7
diff -u -r1.7 key.c
--- common/key.c 17 Oct 2005 19:12:16 -0000 1.7
+++ common/key.c 3 Jan 2006 18:39:50 -0000
@@ -105,7 +105,7 @@
 v_key_init(sp)
  SCR *sp;
 {
- CHAR_T ch;
+ int ch;
  GS *gp;
  KEYLIST *kp;
  int cnt;

Reply | Threaded
Open this post in threaded view
|

Re: -Wall cleanup for vi

Ray Lai
Hi,

This diff removes the ```name' might be used uninitialized in this
function'' warning.  If the variable ``name'' is used, it is either
set equal to the argument ``*namep'' or set to the character `1'.
This diff initialized ``name'' to `1' and removes the lines that
set ``name'' to `1'.

The warning comes from when vi copies into the unnamed buffer.  In
this case, ``name'' is not set to anything, but it is never used.

Please look at my previous diffs as well.  Thank you.

-Ray-

Index: common/cut.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/cut.c,v
retrieving revision 1.8
diff -u -r1.8 cut.c
--- common/cut.c 17 Oct 2005 19:12:16 -0000 1.8
+++ common/cut.c 4 Jan 2006 15:54:20 -0000
@@ -73,7 +73,7 @@
  int flags;
 {
  CB *cbp;
- CHAR_T name;
+ CHAR_T name = '1'; /* default numeric buffer */
  recno_t lno;
  int append, copy_one, copy_def;
 
@@ -115,7 +115,7 @@
 namecb: CBNAME(sp, cbp, name);
  } else if (LF_ISSET(CUT_NUMREQ) || LF_ISSET(CUT_NUMOPT) &&
     (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno)) {
- name = '1';
+ /* Copy into numeric buffer 1. */
  cb_rotate(sp);
  goto namecb;
  } else
@@ -168,7 +168,6 @@
  sp->gp->dcbp = cbp; /* Repoint the default buffer on each pass. */
 
  if (copy_one) { /* Copy into numeric buffer 1. */
- name = '1';
  CBNAME(sp, cbp, name);
  copy_one = 0;
  goto copyloop;

Reply | Threaded
Open this post in threaded view
|

Re: -Wall cleanup for vi

Ray Lai
On Wed, Jan 04, 2006 at 11:07:58AM -0500, Ray Lai wrote:
Hi,

This diff removes an unused variable from a macro and removes an
unused macro.  No binary change.

Please look at my previous diffs as well.  Thank you.

-Ray-

Index: common/util.h
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/util.h,v
retrieving revision 1.2
diff -u -r1.2 util.h
--- common/util.h 29 Jan 2001 01:58:32 -0000 1.2
+++ common/util.h 4 Jan 2006 16:55:28 -0000
@@ -46,7 +46,7 @@
  (((long)(min)) - (cur) <= (add))
 #define NPFITS(max, cur, add) \
  (((unsigned long)(max)) - (cur) >= (add))
-#define NADD_SLONG(sp, v1, v2) \
+#define NADD_SLONG(v1, v2) \
  ((v1) < 0 ? \
     ((v2) < 0 && \
     NNFITS(LONG_MIN, (v1), (v2))) ? NUM_UNDER : NUM_OK : \
@@ -54,5 +54,3 @@
     (v2) > 0 && \
     NPFITS(LONG_MAX, (v1), (v2)) ? NUM_OK : NUM_OVER : \
  NUM_OK)
-#define NADD_USLONG(sp, v1, v2) \
- (NPFITS(ULONG_MAX, (v1), (v2)) ? NUM_OK : NUM_OVER)
Index: ex/ex.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex.c,v
retrieving revision 1.12
diff -u -r1.12 ex.c
--- ex/ex.c 17 Oct 2005 19:12:16 -0000 1.12
+++ ex/ex.c 4 Jan 2006 16:55:28 -0000
@@ -2021,8 +2021,7 @@
  /* Get a signed long, add it to the total. */
  if ((nret = nget_slong(&val,
     ecp->cp, &endp, 10)) != NUM_OK ||
-    (nret = NADD_SLONG(sp,
-    total, val)) != NUM_OK) {
+    (nret = NADD_SLONG(total, val)) != NUM_OK) {
  ex_badaddr(sp, NULL, A_NOTSET, nret);
  *errp = 1;
  return (0);