summaryrefslogtreecommitdiff
path: root/usr.bin/vi/common
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-01-08 21:05:41 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-01-08 21:05:41 +0000
commitfcde5ec1a7e7dda343ba822c73be5f080b0ff0c8 (patch)
treefae8f53125cc8dbd05f4b107c32d3733dbfdd6da /usr.bin/vi/common
parente36b0788688a5dd823dc99c40167de645deb9988 (diff)
Explicit braces around macro fields and logical operations, gets rid of 148
warnings, no functional change. From Ray Lai.
Diffstat (limited to 'usr.bin/vi/common')
-rw-r--r--usr.bin/vi/common/cut.c10
-rw-r--r--usr.bin/vi/common/cut.h4
-rw-r--r--usr.bin/vi/common/exf.c25
-rw-r--r--usr.bin/vi/common/gs.h13
-rw-r--r--usr.bin/vi/common/key.c8
-rw-r--r--usr.bin/vi/common/key.h6
-rw-r--r--usr.bin/vi/common/line.c4
-rw-r--r--usr.bin/vi/common/main.c11
-rw-r--r--usr.bin/vi/common/mark.c5
-rw-r--r--usr.bin/vi/common/mem.h96
-rw-r--r--usr.bin/vi/common/msg.c8
-rw-r--r--usr.bin/vi/common/options.c25
-rw-r--r--usr.bin/vi/common/options.h24
-rw-r--r--usr.bin/vi/common/put.c5
-rw-r--r--usr.bin/vi/common/search.c6
-rw-r--r--usr.bin/vi/common/util.h18
16 files changed, 141 insertions, 127 deletions
diff --git a/usr.bin/vi/common/cut.c b/usr.bin/vi/common/cut.c
index c5beeb8fb0d..0148bdb6cbe 100644
--- a/usr.bin/vi/common/cut.c
+++ b/usr.bin/vi/common/cut.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cut.c,v 1.8 2005/10/17 19:12:16 otto Exp $ */
+/* $OpenBSD: cut.c,v 1.9 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -102,8 +102,8 @@ cut(sp, namep, fm, tm, flags)
append = copy_one = copy_def = 0;
if (namep != NULL) {
name = *namep;
- if (LF_ISSET(CUT_NUMREQ) || LF_ISSET(CUT_NUMOPT) &&
- (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno)) {
+ if (LF_ISSET(CUT_NUMREQ) || (LF_ISSET(CUT_NUMOPT) &&
+ (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno))) {
copy_one = 1;
cb_rotate(sp);
}
@@ -113,8 +113,8 @@ cut(sp, namep, fm, tm, flags)
name = tolower(name);
}
namecb: CBNAME(sp, cbp, name);
- } else if (LF_ISSET(CUT_NUMREQ) || LF_ISSET(CUT_NUMOPT) &&
- (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno)) {
+ } else if (LF_ISSET(CUT_NUMREQ) || (LF_ISSET(CUT_NUMOPT) &&
+ (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno))) {
name = '1';
cb_rotate(sp);
goto namecb;
diff --git a/usr.bin/vi/common/cut.h b/usr.bin/vi/common/cut.h
index 8ea31d58040..7433453b306 100644
--- a/usr.bin/vi/common/cut.h
+++ b/usr.bin/vi/common/cut.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cut.h,v 1.5 2005/10/17 19:12:16 otto Exp $ */
+/* $OpenBSD: cut.h,v 1.6 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -68,7 +68,7 @@ struct _text { /* Text: a linked list of lines. */
CHAR_T L__name; \
L__name = isupper(nch) ? tolower(nch) : (nch); \
LIST_FOREACH((cbp), &(sp)->gp->cutq, q) \
- if (cbp->name == L__name) \
+ if ((cbp)->name == L__name) \
break; \
}
diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c
index 065ac0d8af9..64fe61249a5 100644
--- a/usr.bin/vi/common/exf.c
+++ b/usr.bin/vi/common/exf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exf.c,v 1.21 2005/10/17 19:12:16 otto Exp $ */
+/* $OpenBSD: exf.c,v 1.22 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -209,7 +209,7 @@ file_init(sp, frp, rcv_name, flags)
if (frp->name == NULL)
F_SET(frp, FR_TMPFILE);
if ((frp->tname = strdup(tname)) == NULL ||
- frp->name == NULL && (frp->name = strdup(tname)) == NULL) {
+ (frp->name == NULL && (frp->name = strdup(tname)) == NULL)) {
if (frp->tname != NULL)
free(frp->tname);
msgq(sp, M_SYSERR, NULL);
@@ -406,9 +406,9 @@ file_init(sp, frp, rcv_name, flags)
* probably isn't a problem for vi when it's running standalone.
*/
if (readonly || F_ISSET(sp, SC_READONLY) ||
- !F_ISSET(frp, FR_NEWFILE) &&
+ (!F_ISSET(frp, FR_NEWFILE) &&
(!(sb.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)) ||
- access(frp->name, W_OK)))
+ access(frp->name, W_OK))))
O_SET(sp, O_READONLY);
else
O_CLR(sp, O_READONLY);
@@ -476,8 +476,8 @@ file_spath(sp, frp, sbp, existsp)
*existsp = 0;
return (0);
}
- if (name[0] == '/' || name[0] == '.' &&
- (name[1] == '/' || name[1] == '.' && name[2] == '/')) {
+ if (name[0] == '/' || (name[0] == '.' &&
+ (name[1] == '/' || (name[1] == '.' && name[2] == '/')))) {
*existsp = !stat(name, sbp);
return (0);
}
@@ -824,8 +824,8 @@ file_write(sp, fm, tm, name, flags)
mtype = NEWFILE;
else {
if (noname && !LF_ISSET(FS_FORCE | FS_APPEND) &&
- (F_ISSET(ep, F_DEVSET) &&
- (sb.st_dev != ep->mdev || sb.st_ino != ep->minode) ||
+ ((F_ISSET(ep, F_DEVSET) &&
+ (sb.st_dev != ep->mdev || sb.st_ino != ep->minode)) ||
sb.st_mtime != ep->mtime)) {
msgq_str(sp, M_ERR, name, LF_ISSET(FS_POSSIBLE) ?
"250|%s: file modified more recently than this copy; use ! to override" :
@@ -906,7 +906,7 @@ file_write(sp, fm, tm, name, flags)
* we re-init the time. That way the user can clean up the disk
* and rewrite without having to force it.
*/
- if (noname)
+ if (noname) {
if (stat(name, &sb))
time(&ep->mtime);
else {
@@ -916,6 +916,7 @@ file_write(sp, fm, tm, name, flags)
ep->mtime = sb.st_mtime;
}
+ }
/*
* If the write failed, complain loudly. ex_writefp() has already
@@ -944,11 +945,12 @@ file_write(sp, fm, tm, name, flags)
*/
if (LF_ISSET(FS_ALL) && !LF_ISSET(FS_APPEND)) {
F_CLR(ep, F_MODIFIED);
- if (F_ISSET(frp, FR_TMPFILE))
+ if (F_ISSET(frp, FR_TMPFILE)) {
if (noname)
F_SET(frp, FR_TMPEXIT);
else
F_CLR(frp, FR_TMPEXIT);
+ }
}
p = msg_print(sp, name, &nf);
@@ -1260,7 +1262,7 @@ file_m1(sp, force, flags)
* unless force is also set. Otherwise, we fail unless forced or
* there's another open screen on this file.
*/
- if (F_ISSET(ep, F_MODIFIED))
+ if (F_ISSET(ep, F_MODIFIED)) {
if (O_ISSET(sp, O_AUTOWRITE)) {
if (!force && file_aw(sp, flags))
return (1);
@@ -1270,6 +1272,7 @@ file_m1(sp, force, flags)
"263|File modified since last complete write; write or use :edit! to override");
return (1);
}
+ }
return (file_m3(sp, force));
}
diff --git a/usr.bin/vi/common/gs.h b/usr.bin/vi/common/gs.h
index eca92f90ee5..b3c0fd42808 100644
--- a/usr.bin/vi/common/gs.h
+++ b/usr.bin/vi/common/gs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: gs.h,v 1.8 2005/10/17 19:12:16 otto Exp $ */
+/* $OpenBSD: gs.h,v 1.9 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -119,10 +119,12 @@ struct _gs {
#define MAX_FAST_KEY 254 /* Max fast check character.*/
#define KEY_LEN(sp, ch) \
((unsigned char)(ch) <= MAX_FAST_KEY ? \
- sp->gp->cname[(unsigned char)ch].len : v_key_len(sp, ch))
+ (sp)->gp->cname[(unsigned char)(ch)].len : \
+ v_key_len((sp), (ch)))
#define KEY_NAME(sp, ch) \
((unsigned char)(ch) <= MAX_FAST_KEY ? \
- sp->gp->cname[(unsigned char)ch].name : v_key_name(sp, ch))
+ (sp)->gp->cname[(unsigned char)(ch)].name : \
+ v_key_name((sp), (ch)))
struct {
CHAR_T name[MAX_CHARACTER_COLUMNS + 1];
u_int8_t len;
@@ -130,8 +132,9 @@ struct _gs {
#define KEY_VAL(sp, ch) \
((unsigned char)(ch) <= MAX_FAST_KEY ? \
- sp->gp->special_key[(unsigned char)ch] : \
- (unsigned char)(ch) > sp->gp->max_special ? 0 : v_key_val(sp,ch))
+ (sp)->gp->special_key[(unsigned char)(ch)] : \
+ (unsigned char)(ch) > (sp)->gp->max_special ? 0 : \
+ v_key_val((sp),(ch)))
CHAR_T max_special; /* Max special character. */
u_char /* Fast lookup table. */
special_key[MAX_FAST_KEY + 1];
diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c
index f08a2039c5a..80b094e69c6 100644
--- a/usr.bin/vi/common/key.c
+++ b/usr.bin/vi/common/key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */
+/* $OpenBSD: key.c,v 1.8 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -434,10 +434,10 @@ v_event_append(sp, argp)
/* Remove events from the queue. */
#define QREM(len) { \
- if ((gp->i_cnt -= len) == 0) \
+ if ((gp->i_cnt -= (len)) == 0) \
gp->i_next = 0; \
else \
- gp->i_next += len; \
+ gp->i_next += (len); \
}
/*
@@ -632,7 +632,7 @@ newmap: evp = &gp->i_event[gp->i_next];
*/
if (istimeout || F_ISSET(&evp->e_ch, CH_NOMAP) ||
!LF_ISSET(EC_MAPCOMMAND | EC_MAPINPUT) ||
- evp->e_c < MAX_BIT_SEQ && !bit_test(gp->seqb, evp->e_c))
+ (evp->e_c < MAX_BIT_SEQ && !bit_test(gp->seqb, evp->e_c)))
goto nomap;
/* Search the map. */
diff --git a/usr.bin/vi/common/key.h b/usr.bin/vi/common/key.h
index 6a82328d053..927081dbeea 100644
--- a/usr.bin/vi/common/key.h
+++ b/usr.bin/vi/common/key.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: key.h,v 1.3 2001/01/29 01:58:29 niklas Exp $ */
+/* $OpenBSD: key.h,v 1.4 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -134,7 +134,7 @@ extern KEYLIST keylist[];
#define KEYS_WAITING(sp) ((sp)->gp->i_cnt != 0)
#define MAPPED_KEYS_WAITING(sp) \
(KEYS_WAITING(sp) && \
- F_ISSET(&sp->gp->i_event[sp->gp->i_next].e_ch, CH_MAPPED))
+ F_ISSET(&(sp)->gp->i_event[(sp)->gp->i_next].e_ch, CH_MAPPED))
/*
* Ex/vi commands are generally separated by whitespace characters. We
@@ -176,7 +176,7 @@ extern KEYLIST keylist[];
#define INTERRUPT_CHECK 100
#define INTERRUPTED(sp) \
(F_ISSET((sp)->gp, G_INTERRUPTED) || \
- (!v_event_get(sp, NULL, 0, EC_INTERRUPT) && \
+ (!v_event_get((sp), NULL, 0, EC_INTERRUPT) && \
F_ISSET((sp)->gp, G_INTERRUPTED)))
#define CLR_INTERRUPT(sp) \
F_CLR((sp)->gp, G_INTERRUPTED)
diff --git a/usr.bin/vi/common/line.c b/usr.bin/vi/common/line.c
index 0e64f8c761b..a6d02d99501 100644
--- a/usr.bin/vi/common/line.c
+++ b/usr.bin/vi/common/line.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: line.c,v 1.6 2005/10/17 19:12:16 otto Exp $ */
+/* $OpenBSD: line.c,v 1.7 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -62,7 +62,7 @@ db_eget(sp, lno, pp, lenp, isemptyp)
return (1);
/* If the file isn't empty, fail loudly. */
- if (lno != 0 && lno != 1 || l1 != 0) {
+ if ((lno != 0 && lno != 1) || l1 != 0) {
db_err(sp, lno);
return (1);
}
diff --git a/usr.bin/vi/common/main.c b/usr.bin/vi/common/main.c
index d776e6153a3..7aea5e31ce1 100644
--- a/usr.bin/vi/common/main.c
+++ b/usr.bin/vi/common/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.11 2005/10/17 19:12:16 otto Exp $ */
+/* $OpenBSD: main.c,v 1.12 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -41,7 +41,9 @@ static const char sccsid[] = "@(#)main.c 10.48 (Berkeley) 10/11/96";
#include "../vi/vi.h"
#include "pathnames.h"
+#ifdef DEBUG
static void attach(GS *);
+#endif
static void v_estr(char *, int, char *);
static int v_obsolete(char *, char *[]);
@@ -403,8 +405,8 @@ editor(gp, argc, argv)
if (v_event_get(sp, &ev, 0, 0))
goto err;
if (ev.e_event == E_INTERRUPT ||
- ev.e_event == E_CHARACTER &&
- (ev.e_value == K_CR || ev.e_value == K_NL))
+ (ev.e_event == E_CHARACTER &&
+ (ev.e_value == K_CR || ev.e_value == K_NL)))
break;
(void)gp->scr_bell(sp);
}
@@ -562,7 +564,7 @@ v_obsolete(name, argv)
argv[0][1] = 'c';
(void)strlcpy(argv[0] + 2, p + 1, len);
}
- } else if (argv[0][0] == '-')
+ } else if (argv[0][0] == '-') {
if (argv[0][1] == '\0') {
argv[0] = strdup("-s");
if (argv[0] == NULL) {
@@ -574,6 +576,7 @@ nomem: v_estr(name, errno, NULL);
argv[0][1] == 't' || argv[0][1] == 'w') &&
argv[0][2] == '\0')
++argv;
+ }
return (0);
}
diff --git a/usr.bin/vi/common/mark.c b/usr.bin/vi/common/mark.c
index 53427bf0580..18709253911 100644
--- a/usr.bin/vi/common/mark.c
+++ b/usr.bin/vi/common/mark.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mark.c,v 1.6 2005/10/17 19:12:16 otto Exp $ */
+/* $OpenBSD: mark.c,v 1.7 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -237,12 +237,13 @@ mark_insdel(sp, op, lno)
abort();
case LINE_DELETE:
LIST_FOREACH(lmp, &sp->ep->marks, q)
- if (lmp->lno >= lno)
+ if (lmp->lno >= lno) {
if (lmp->lno == lno) {
F_SET(lmp, MARK_DELETED);
(void)log_mark(sp, lmp);
} else
--lmp->lno;
+ }
break;
case LINE_INSERT:
/*
diff --git a/usr.bin/vi/common/mem.h b/usr.bin/vi/common/mem.h
index c7826504bb3..f230aa05044 100644
--- a/usr.bin/vi/common/mem.h
+++ b/usr.bin/vi/common/mem.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.h,v 1.4 2001/01/29 01:58:30 niklas Exp $ */
+/* $OpenBSD: mem.h,v 1.5 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -16,26 +16,28 @@
*/
#define BINC_GOTO(sp, lp, llen, nlen) { \
void *L__bincp; \
- if ((nlen) > llen) { \
- if ((L__bincp = binc(sp, lp, &(llen), nlen)) == NULL) \
+ if ((nlen) > (llen)) { \
+ if ((L__bincp = binc((sp), (lp), &(llen), (nlen))) \
+ == NULL) \
goto alloc_err; \
/* \
* !!! \
* Possible pointer conversion. \
*/ \
- lp = L__bincp; \
+ (lp) = L__bincp; \
} \
}
#define BINC_RET(sp, lp, llen, nlen) { \
void *L__bincp; \
- if ((nlen) > llen) { \
- if ((L__bincp = binc(sp, lp, &(llen), nlen)) == NULL) \
+ if ((nlen) > (llen)) { \
+ if ((L__bincp = binc((sp), (lp), &(llen), (nlen))) \
+ == NULL) \
return (1); \
/* \
* !!! \
* Possible pointer conversion. \
*/ \
- lp = L__bincp; \
+ (lp) = L__bincp; \
} \
}
@@ -47,26 +49,26 @@
#define GET_SPACE_GOTO(sp, bp, blen, nlen) { \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
if (L__gp == NULL || F_ISSET(L__gp, G_TMP_INUSE)) { \
- bp = NULL; \
- blen = 0; \
- BINC_GOTO(sp, bp, blen, nlen); \
+ (bp) = NULL; \
+ (blen) = 0; \
+ BINC_GOTO((sp), (bp), (blen), (nlen)); \
} else { \
- BINC_GOTO(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
- bp = L__gp->tmp_bp; \
- blen = L__gp->tmp_blen; \
+ BINC_GOTO((sp), L__gp->tmp_bp, L__gp->tmp_blen, (nlen));\
+ (bp) = L__gp->tmp_bp; \
+ (blen) = L__gp->tmp_blen; \
F_SET(L__gp, G_TMP_INUSE); \
} \
}
#define GET_SPACE_RET(sp, bp, blen, nlen) { \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
if (L__gp == NULL || F_ISSET(L__gp, G_TMP_INUSE)) { \
- bp = NULL; \
- blen = 0; \
- BINC_RET(sp, bp, blen, nlen); \
+ (bp) = NULL; \
+ (blen) = 0; \
+ BINC_RET((sp), (bp), (blen), (nlen)); \
} else { \
- BINC_RET(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
- bp = L__gp->tmp_bp; \
- blen = L__gp->tmp_blen; \
+ BINC_RET((sp), L__gp->tmp_bp, L__gp->tmp_blen, (nlen)); \
+ (bp) = L__gp->tmp_bp; \
+ (blen) = L__gp->tmp_blen; \
F_SET(L__gp, G_TMP_INUSE); \
} \
}
@@ -77,31 +79,31 @@
*/
#define ADD_SPACE_GOTO(sp, bp, blen, nlen) { \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
- if (L__gp == NULL || bp == L__gp->tmp_bp) { \
+ if (L__gp == NULL || (bp) == L__gp->tmp_bp) { \
F_CLR(L__gp, G_TMP_INUSE); \
- BINC_GOTO(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
- bp = L__gp->tmp_bp; \
- blen = L__gp->tmp_blen; \
+ BINC_GOTO((sp), L__gp->tmp_bp, L__gp->tmp_blen, (nlen));\
+ (bp) = L__gp->tmp_bp; \
+ (blen) = L__gp->tmp_blen; \
F_SET(L__gp, G_TMP_INUSE); \
} else \
- BINC_GOTO(sp, bp, blen, nlen); \
+ BINC_GOTO((sp), (bp), (blen), (nlen)); \
}
#define ADD_SPACE_RET(sp, bp, blen, nlen) { \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
- if (L__gp == NULL || bp == L__gp->tmp_bp) { \
+ if (L__gp == NULL || (bp) == L__gp->tmp_bp) { \
F_CLR(L__gp, G_TMP_INUSE); \
- BINC_RET(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
- bp = L__gp->tmp_bp; \
- blen = L__gp->tmp_blen; \
+ BINC_RET((sp), L__gp->tmp_bp, L__gp->tmp_blen, (nlen)); \
+ (bp) = L__gp->tmp_bp; \
+ (blen) = L__gp->tmp_blen; \
F_SET(L__gp, G_TMP_INUSE); \
} else \
- BINC_RET(sp, bp, blen, nlen); \
+ BINC_RET((sp), (bp), (blen), (nlen)); \
}
/* Free a GET_SPACE returned buffer. */
#define FREE_SPACE(sp, bp, blen) { \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
- if (L__gp != NULL && bp == L__gp->tmp_bp) \
+ if (L__gp != NULL && (bp) == L__gp->tmp_bp) \
F_CLR(L__gp, G_TMP_INUSE); \
else \
free(bp); \
@@ -118,37 +120,37 @@
* in instead of explaining it all the time.
*/
#define CALLOC(sp, p, cast, nmemb, size) { \
- if ((p = (cast)calloc(nmemb, size)) == NULL) \
- msgq(sp, M_SYSERR, NULL); \
+ if (((p) = (cast)calloc((nmemb), (size))) == NULL) \
+ msgq((sp), M_SYSERR, NULL); \
}
#define CALLOC_GOTO(sp, p, cast, nmemb, size) { \
- if ((p = (cast)calloc(nmemb, size)) == NULL) \
+ if (((p) = (cast)calloc((nmemb), (size))) == NULL) \
goto alloc_err; \
}
#define CALLOC_NOMSG(sp, p, cast, nmemb, size) { \
- p = (cast)calloc(nmemb, size); \
+ (p) = (cast)calloc((nmemb), (size)); \
}
#define CALLOC_RET(sp, p, cast, nmemb, size) { \
- if ((p = (cast)calloc(nmemb, size)) == NULL) { \
- msgq(sp, M_SYSERR, NULL); \
+ if (((p) = (cast)calloc((nmemb), (size))) == NULL) { \
+ msgq((sp), M_SYSERR, NULL); \
return (1); \
} \
}
#define MALLOC(sp, p, cast, size) { \
- if ((p = (cast)malloc(size)) == NULL) \
- msgq(sp, M_SYSERR, NULL); \
+ if (((p) = (cast)malloc(size)) == NULL) \
+ msgq((sp), M_SYSERR, NULL); \
}
#define MALLOC_GOTO(sp, p, cast, size) { \
- if ((p = (cast)malloc(size)) == NULL) \
+ if (((p) = (cast)malloc(size)) == NULL) \
goto alloc_err; \
}
#define MALLOC_NOMSG(sp, p, cast, size) { \
- p = (cast)malloc(size); \
+ (p) = (cast)malloc(size); \
}
#define MALLOC_RET(sp, p, cast, size) { \
- if ((p = (cast)malloc(size)) == NULL) { \
- msgq(sp, M_SYSERR, NULL); \
+ if (((p) = (cast)malloc(size)) == NULL) { \
+ msgq((sp), M_SYSERR, NULL); \
return (1); \
} \
}
@@ -157,14 +159,14 @@
* Don't depend on realloc(NULL, size) working.
*/
#define REALLOC(sp, p, cast, size) { \
- if ((p = (cast)(p == NULL ? \
- malloc(size) : realloc(p, size))) == NULL) \
- msgq(sp, M_SYSERR, NULL); \
+ if (((p) = (cast)((p) == NULL ? \
+ malloc(size) : realloc((p), (size)))) == NULL) \
+ msgq((sp), M_SYSERR, NULL); \
}
/*
* Versions of memmove(3) and memset(3) that use the size of the
* initial pointer to figure out how much memory to manipulate.
*/
-#define MEMMOVE(p, t, len) memmove(p, t, (len) * sizeof(*(p)))
-#define MEMSET(p, value, len) memset(p, value, (len) * sizeof(*(p)))
+#define MEMMOVE(p, t, len) memmove((p), (t), (len) * sizeof(*(p)))
+#define MEMSET(p, value, len) memset((p), (value), (len) * sizeof(*(p)))
diff --git a/usr.bin/vi/common/msg.c b/usr.bin/vi/common/msg.c
index 5adb67906ce..61a512a9c7b 100644
--- a/usr.bin/vi/common/msg.c
+++ b/usr.bin/vi/common/msg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msg.c,v 1.14 2003/04/25 23:44:08 deraadt Exp $ */
+/* $OpenBSD: msg.c,v 1.15 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -332,7 +332,7 @@ nofmt: mp += len;
(void)fprintf(stderr, "%.*s", (int)mlen, bp);
/* Cleanup. */
-ret: FREE_SPACE(sp, bp, blen);
+ FREE_SPACE(sp, bp, blen);
alloc_err:
reenter = 0;
}
@@ -684,8 +684,8 @@ msg_open(sp, file)
char *p, *t, buf[MAXPATHLEN];
if ((p = strrchr(file, '/')) != NULL && p[1] == '\0' &&
- ((t = getenv("LC_MESSAGES")) != NULL && t[0] != '\0' ||
- (t = getenv("LANG")) != NULL && t[0] != '\0')) {
+ (((t = getenv("LC_MESSAGES")) != NULL && t[0] != '\0') ||
+ ((t = getenv("LANG")) != NULL && t[0] != '\0'))) {
(void)snprintf(buf, sizeof(buf), "%s%s", file, t);
p = buf;
} else
diff --git a/usr.bin/vi/common/options.c b/usr.bin/vi/common/options.c
index 71bd0c41a44..ba78641f3c7 100644
--- a/usr.bin/vi/common/options.c
+++ b/usr.bin/vi/common/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.11 2003/04/07 21:13:54 deraadt Exp $ */
+/* $OpenBSD: options.c,v 1.12 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -302,8 +302,8 @@ opts_init(sp, oargs)
/* Set numeric and string default values. */
#define OI(indx, str) { \
- if (str != b1) /* GCC puts strings in text-space. */ \
- (void)strlcpy(b1, str, sizeof b1); \
+ if ((str) != b1) /* GCC puts strings in text-space. */ \
+ (void)strlcpy(b1, (str), sizeof(b1)); \
a.len = strlen(b1); \
if (opts_set(sp, argv, NULL)) { \
optindx = indx; \
@@ -554,7 +554,7 @@ opts_set(sp, argv, usage)
* Do nothing if the value is unchanged, the underlying
* functions can be expensive.
*/
- if (!F_ISSET(op, OPT_ALWAYS))
+ if (!F_ISSET(op, OPT_ALWAYS)) {
if (turnoff) {
if (!O_ISSET(sp, offset))
break;
@@ -562,6 +562,7 @@ opts_set(sp, argv, usage)
if (O_ISSET(sp, offset))
break;
}
+ }
if (F_ISSET(op, OPT_EARLYSET)) {
/* Set the value. */
@@ -572,8 +573,8 @@ opts_set(sp, argv, usage)
}
/* Report to subsystems. */
- if (op->func != NULL &&
- op->func(sp, spo, NULL, &turnoff) ||
+ if ((op->func != NULL &&
+ op->func(sp, spo, NULL, &turnoff)) ||
ex_optchange(sp, offset, NULL, &turnoff) ||
v_optchange(sp, offset, NULL, &turnoff) ||
sp->gp->scr_optchange(sp, offset, NULL, &turnoff)) {
@@ -667,8 +668,8 @@ badnum: p = msg_print(sp, name, &nf);
}
/* Report to subsystems. */
- if (op->func != NULL &&
- op->func(sp, spo, sep, &value) ||
+ if ((op->func != NULL &&
+ op->func(sp, spo, sep, &value)) ||
ex_optchange(sp, offset, sep, &value) ||
v_optchange(sp, offset, sep, &value) ||
sp->gp->scr_optchange(sp, offset, sep, &value)) {
@@ -714,8 +715,8 @@ badnum: p = msg_print(sp, name, &nf);
}
/* Report to subsystems. */
- if (op->func != NULL &&
- op->func(sp, spo, sep, NULL) ||
+ if ((op->func != NULL &&
+ op->func(sp, spo, sep, NULL)) ||
ex_optchange(sp, offset, sep, NULL) ||
v_optchange(sp, offset, sep, NULL) ||
sp->gp->scr_optchange(sp, offset, sep, NULL)) {
@@ -868,8 +869,8 @@ opts_dump(sp, type)
break;
case OPT_STR:
if (O_STR(sp, cnt) == O_D_STR(sp, cnt) ||
- O_D_STR(sp, cnt) != NULL &&
- !strcmp(O_STR(sp, cnt), O_D_STR(sp, cnt)))
+ (O_D_STR(sp, cnt) != NULL &&
+ !strcmp(O_STR(sp, cnt), O_D_STR(sp, cnt))))
continue;
break;
}
diff --git a/usr.bin/vi/common/options.h b/usr.bin/vi/common/options.h
index 9e1f424dba2..42f789a96d2 100644
--- a/usr.bin/vi/common/options.h
+++ b/usr.bin/vi/common/options.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.h,v 1.7 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: options.h,v 1.8 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -36,7 +36,7 @@
#define OG_SET(gp, o) ((gp)->opts[(o)].o_cur.val) = 1
#define OG_STR(gp, o) ((gp)->opts[(o)].o_cur.str)
#define OG_VAL(gp, o) ((gp)->opts[(o)].o_cur.val)
-#define OG_ISSET(gp, o) OG_VAL(gp, o)
+#define OG_ISSET(gp, o) OG_VAL((gp), (o))
#define OG_D_STR(gp, o) ((gp)->opts[(o)].o_def.str)
#define OG_D_VAL(gp, o) ((gp)->opts[(o)].o_def.val)
@@ -55,21 +55,21 @@ struct _option {
u_long val; /* Value or boolean. */
char *str; /* String. */
} o_cur;
-#define O_CLR(sp, o) o_set(sp, o, 0, NULL, 0)
-#define O_SET(sp, o) o_set(sp, o, 0, NULL, 1)
-#define O_STR(sp, o) O_V(sp, o, o_cur.str)
-#define O_VAL(sp, o) O_V(sp, o, o_cur.val)
-#define O_ISSET(sp, o) O_VAL(sp, o)
+#define O_CLR(sp, o) o_set((sp), (o), 0, NULL, 0)
+#define O_SET(sp, o) o_set((sp), (o), 0, NULL, 1)
+#define O_STR(sp, o) O_V((sp), (o), o_cur.str)
+#define O_VAL(sp, o) O_V((sp), (o), o_cur.val)
+#define O_ISSET(sp, o) O_VAL((sp), (o))
union {
u_long val; /* Value or boolean. */
char *str; /* String. */
} o_def;
-#define O_D_CLR(sp, o) o_set(sp, o, OS_DEF, NULL, 0)
-#define O_D_SET(sp, o) o_set(sp, o, OS_DEF, NULL, 1)
-#define O_D_STR(sp, o) O_V(sp, o, o_def.str)
-#define O_D_VAL(sp, o) O_V(sp, o, o_def.val)
-#define O_D_ISSET(sp, o) O_D_VAL(sp, o)
+#define O_D_CLR(sp, o) o_set((sp), (o), OS_DEF, NULL, 0)
+#define O_D_SET(sp, o) o_set((sp), (o), OS_DEF, NULL, 1)
+#define O_D_STR(sp, o) O_V((sp), (o), o_def.str)
+#define O_D_VAL(sp, o) O_V((sp), (o), o_def.val)
+#define O_D_ISSET(sp, o) O_D_VAL((sp), (o))
#define OPT_GLOBAL 0x01 /* Option is global. */
#define OPT_SELECTED 0x02 /* Selected for display. */
diff --git a/usr.bin/vi/common/put.c b/usr.bin/vi/common/put.c
index 9e855818ac2..a4bb62245db 100644
--- a/usr.bin/vi/common/put.c
+++ b/usr.bin/vi/common/put.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: put.c,v 1.7 2005/10/17 19:12:16 otto Exp $ */
+/* $OpenBSD: put.c,v 1.8 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -48,7 +48,7 @@ put(sp, cbp, namep, cp, rp, append)
int rval;
char *bp, *p, *t;
- if (cbp == NULL)
+ if (cbp == NULL) {
if (namep == NULL) {
cbp = sp->gp->dcbp;
if (cbp == NULL) {
@@ -65,6 +65,7 @@ put(sp, cbp, namep, cp, rp, append)
return (1);
}
}
+ }
tp = CIRCLEQ_FIRST(&cbp->textq);
/*
diff --git a/usr.bin/vi/common/search.c b/usr.bin/vi/common/search.c
index d6251effab8..d39737acf87 100644
--- a/usr.bin/vi/common/search.c
+++ b/usr.bin/vi/common/search.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: search.c,v 1.7 2002/02/17 19:42:34 millert Exp $ */
+/* $OpenBSD: search.c,v 1.8 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -211,7 +211,7 @@ f_search(sp, fm, rm, ptrn, plen, eptrn, flags)
}
cnt = INTERRUPT_CHECK;
}
- if (wrapped && lno > fm->lno || db_get(sp, lno, 0, &l, &len)) {
+ if ((wrapped && lno > fm->lno) || db_get(sp, lno, 0, &l, &len)) {
if (wrapped) {
if (LF_ISSET(SEARCH_MSG))
search_msg(sp, S_NOTFOUND);
@@ -342,7 +342,7 @@ b_search(sp, fm, rm, ptrn, plen, eptrn, flags)
}
cnt = INTERRUPT_CHECK;
}
- if (wrapped && lno < fm->lno || lno == 0) {
+ if ((wrapped && lno < fm->lno) || lno == 0) {
if (wrapped) {
if (LF_ISSET(SEARCH_MSG))
search_msg(sp, S_NOTFOUND);
diff --git a/usr.bin/vi/common/util.h b/usr.bin/vi/common/util.h
index ef1452cb511..60e2ef2f7f7 100644
--- a/usr.bin/vi/common/util.h
+++ b/usr.bin/vi/common/util.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.h,v 1.2 2001/01/29 01:58:32 niklas Exp $ */
+/* $OpenBSD: util.h,v 1.3 2006/01/08 21:05:39 miod Exp $ */
/*-
* Copyright (c) 1994
@@ -17,15 +17,15 @@
#define FL_CLR(l, f) ((l) &= ~(f))
#define FL_ISSET(l, f) ((l) & (f))
-#define LF_INIT(f) FL_INIT(flags, f) /* Local variable flags. */
-#define LF_SET(f) FL_SET(flags, f)
-#define LF_CLR(f) FL_CLR(flags, f)
-#define LF_ISSET(f) FL_ISSET(flags, f)
+#define LF_INIT(f) FL_INIT(flags, (f)) /* Local variable flags. */
+#define LF_SET(f) FL_SET(flags, (f))
+#define LF_CLR(f) FL_CLR(flags, (f))
+#define LF_ISSET(f) FL_ISSET(flags, (f))
-#define F_INIT(p, f) FL_INIT((p)->flags, f) /* Structure element flags. */
-#define F_SET(p, f) FL_SET((p)->flags, f)
-#define F_CLR(p, f) FL_CLR((p)->flags, f)
-#define F_ISSET(p, f) FL_ISSET((p)->flags, f)
+#define F_INIT(p, f) FL_INIT((p)->flags, (f)) /* Structure element flags. */
+#define F_SET(p, f) FL_SET((p)->flags, (f))
+#define F_CLR(p, f) FL_CLR((p)->flags, (f))
+#define F_ISSET(p, f) FL_ISSET((p)->flags, (f))
/* Offset to next column of stop size, e.g. tab offsets. */
#define COL_OFF(c, stop) ((stop) - ((c) % (stop)))