summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-02-14 14:24:22 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-02-14 14:24:22 +0000
commitbf173a2604bd859e8f923f89df06fce145944f3c (patch)
treebc6fab0af70644c69f78c1cd5abc96b1cf7cd225
parente672b0adc93b18c8f8186dbe2abee2a2d006664b (diff)
some KNF
-rw-r--r--usr.bin/mg/buffer.c24
-rw-r--r--usr.bin/mg/display.c21
-rw-r--r--usr.bin/mg/echo.c16
-rw-r--r--usr.bin/mg/file.c6
-rw-r--r--usr.bin/mg/fileio.c4
-rw-r--r--usr.bin/mg/grep.c10
-rw-r--r--usr.bin/mg/line.c16
-rw-r--r--usr.bin/mg/paragraph.c30
-rw-r--r--usr.bin/mg/random.c12
-rw-r--r--usr.bin/mg/tty.c4
-rw-r--r--usr.bin/mg/window.c6
11 files changed, 74 insertions, 75 deletions
diff --git a/usr.bin/mg/buffer.c b/usr.bin/mg/buffer.c
index dd76ccfdc90..a18f0545e09 100644
--- a/usr.bin/mg/buffer.c
+++ b/usr.bin/mg/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.20 2002/02/13 03:03:49 vincent Exp $ */
+/* $OpenBSD: buffer.c,v 1.21 2002/02/14 14:24:21 deraadt Exp $ */
/*
* Buffer handling.
@@ -26,8 +26,8 @@ usebuffer(f, n)
char bufn[NBUFN];
/* Get buffer to use from user */
- if ((curbp->b_altb == NULL)
- && ((curbp->b_altb = bfind("*scratch*", TRUE)) == NULL))
+ if ((curbp->b_altb == NULL) &&
+ ((curbp->b_altb = bfind("*scratch*", TRUE)) == NULL))
s = eread("Switch to buffer: ", bufn, NBUFN, EFNEW | EFBUF);
else
s = eread("Switch to buffer: (default %s) ", bufn, NBUFN,
@@ -59,8 +59,8 @@ poptobuffer(f, n)
char bufn[NBUFN];
/* Get buffer to use from user */
- if ((curbp->b_altb == NULL)
- && ((curbp->b_altb = bfind("*scratch*", TRUE)) == NULL))
+ if ((curbp->b_altb == NULL) &&
+ ((curbp->b_altb = bfind("*scratch*", TRUE)) == NULL))
s = eread("Switch to buffer in other window: ", bufn, NBUFN,
EFNEW | EFBUF);
else
@@ -101,7 +101,7 @@ killbuffer(f, n)
char bufn[NBUFN];
if ((s = eread("Kill buffer: (default %s) ", bufn, NBUFN, EFNEW | EFBUF,
- curbp->b_bname)) == ABORT)
+ curbp->b_bname)) == ABORT)
return (s);
else if (s == FALSE)
bp = curbp;
@@ -379,12 +379,12 @@ anycb(f)
char prompt[NFILEN + 11];
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
- if (bp->b_fname != NULL && *(bp->b_fname) != '\0'
- && (bp->b_flag & BFCHG) != 0) {
+ if (bp->b_fname != NULL && *(bp->b_fname) != '\0' &&
+ (bp->b_flag & BFCHG) != 0) {
snprintf(prompt, sizeof prompt, "Save file %s",
bp->b_fname);
- if ((f == TRUE || (save = eyorn(prompt)) == TRUE)
- && buffsave(bp) == TRUE) {
+ if ((f == TRUE || (save = eyorn(prompt)) == TRUE) &&
+ buffsave(bp) == TRUE) {
bp->b_flag &= ~BFCHG;
upmodes(bp);
} else
@@ -477,8 +477,8 @@ bclear(bp)
LINE *lp;
int s;
- if ((bp->b_flag & BFCHG) != 0 /* Changed. */
- && (s = eyesno("Buffer modified; kill anyway")) != TRUE)
+ if ((bp->b_flag & BFCHG) != 0 && /* Changed. */
+ (s = eyesno("Buffer modified; kill anyway")) != TRUE)
return (s);
bp->b_flag &= ~BFCHG; /* Not changed */
while ((lp = lforw(bp->b_linep)) != bp->b_linep)
diff --git a/usr.bin/mg/display.c b/usr.bin/mg/display.c
index e00c7f6a5ab..c3c8d110bc0 100644
--- a/usr.bin/mg/display.c
+++ b/usr.bin/mg/display.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: display.c,v 1.8 2002/02/14 00:11:46 vincent Exp $ */
+/* $OpenBSD: display.c,v 1.9 2002/02/14 14:24:21 deraadt Exp $ */
/*
* The functions in this file handle redisplay. The
@@ -141,7 +141,7 @@ vtresize(int force, int newrow, int newcol)
if (first_run) {
memset(&blanks, 0, sizeof(blanks));
}
-
+
if (rowchanged || first_run) {
int vidstart;
@@ -197,13 +197,13 @@ vtresize(int force, int newrow, int newcol)
nrow = newrow;
ncol = newcol;
-
+
if (ttrow > nrow)
ttrow = nrow;
if (ttcol > ncol)
ttcol = ncol;
- first_run = 0;
+ first_run = 0;
return 0;
}
@@ -227,7 +227,7 @@ vtinit()
ttopen();
ttinit();
-
+
/*
* ttinit called ttresize(), which called vtresize(), so our data
* structures are setup correctly.
@@ -292,7 +292,7 @@ vtputc(c)
VIDEO *vp;
c &= 0xff;
-
+
vp = vscreen[vtrow];
if (vtcol >= ncol)
vp->v_text[ncol - 1] = '$';
@@ -323,7 +323,7 @@ vtpute(c)
VIDEO *vp;
c &= 0xff;
-
+
vp = vscreen[vtrow];
if (vtcol >= ncol)
vp->v_text[ncol - 1] = '$';
@@ -400,7 +400,7 @@ update()
*/
if (wp->w_flag == 0)
continue;
-
+
if ((wp->w_flag & WFFORCE) == 0) {
lp = wp->w_linep;
for (i = 0; i < wp->w_ntrows; ++i) {
@@ -424,9 +424,8 @@ update()
if (i < 0)
i = 0;
} else
- i = wp->w_ntrows / 2; /* current center,
- * no change */
-
+ i = wp->w_ntrows / 2; /* current center, no change */
+
/*
* Find the line
*/
diff --git a/usr.bin/mg/echo.c b/usr.bin/mg/echo.c
index 387be8ffa98..ff940775888 100644
--- a/usr.bin/mg/echo.c
+++ b/usr.bin/mg/echo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: echo.c,v 1.17 2002/01/18 08:37:08 art Exp $ */
+/* $OpenBSD: echo.c,v 1.18 2002/02/14 14:24:21 deraadt Exp $ */
/*
* Echo line reading and writing.
@@ -101,14 +101,14 @@ eyesno(sp)
free((char *)lp);
}
#endif /* !NO_MACRO */
- if ((buf[0] == 'y' || buf[0] == 'Y')
- && (buf[1] == 'e' || buf[1] == 'E')
- && (buf[2] == 's' || buf[2] == 'S')
- && (buf[3] == '\0'))
+ if ((buf[0] == 'y' || buf[0] == 'Y') &&
+ (buf[1] == 'e' || buf[1] == 'E') &&
+ (buf[2] == 's' || buf[2] == 'S') &&
+ (buf[3] == '\0'))
return TRUE;
- if ((buf[0] == 'n' || buf[0] == 'N')
- && (buf[1] == 'o' || buf[0] == 'O')
- && (buf[2] == '\0'))
+ if ((buf[0] == 'n' || buf[0] == 'N') &&
+ (buf[1] == 'o' || buf[0] == 'O') &&
+ (buf[2] == '\0'))
return FALSE;
}
s = ereply("Please answer yes or no. %s? (yes or no) ",
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index 1818add331d..19415e16a15 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.12 2002/02/13 22:50:40 vincent Exp $ */
+/* $OpenBSD: file.c,v 1.13 2002/02/14 14:24:21 deraadt Exp $ */
/*
* File commands.
@@ -72,7 +72,7 @@ poptofile(f, n)
char *adjf;
if ((s = eread("Find file in other window: ", fname, NFILEN,
- EFNEW | EFCR | EFFILE)) != TRUE)
+ EFNEW | EFCR | EFFILE)) != TRUE)
return s;
adjf = adjustname(fname);
if ((bp = findbuffer(adjf)) == NULL)
@@ -337,7 +337,7 @@ filewrite(f, n)
char *adjfname;
if ((s = eread("Write file: ", fname, NFILEN,
- EFNEW | EFCR | EFFILE)) != TRUE)
+ EFNEW | EFCR | EFFILE)) != TRUE)
return (s);
adjfname = adjustname(fname);
/* old attributes are no longer current */
diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c
index 448597836c5..090ccec0209 100644
--- a/usr.bin/mg/fileio.c
+++ b/usr.bin/mg/fileio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fileio.c,v 1.21 2002/02/13 03:03:49 vincent Exp $ */
+/* $OpenBSD: fileio.c,v 1.22 2002/02/14 14:24:21 deraadt Exp $ */
/*
* POSIX fileio.c
@@ -202,7 +202,7 @@ fbackupfile(fn)
}
free(nname);
errno = serrno;
-
+
return (nread == -1 ? FALSE : TRUE);
}
#endif
diff --git a/usr.bin/mg/grep.c b/usr.bin/mg/grep.c
index 56e1019c23b..d2db802c87f 100644
--- a/usr.bin/mg/grep.c
+++ b/usr.bin/mg/grep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grep.c,v 1.2 2001/11/25 07:34:17 deraadt Exp $ */
+/* $OpenBSD: grep.c,v 1.3 2002/02/14 14:24:21 deraadt Exp $ */
/*
* Copyright (c) 2001 Artur Grabowski <art@openbsd.org>. All rights reserved.
*
@@ -100,7 +100,7 @@ compile(int f, int n)
BUFFER *bp;
MGWIN *wp;
- strcpy(prompt, "make ");
+ strlcpy(prompt, "make ", sizeof prompt);
if (eread("Compile command: ", prompt, NFILEN, EFDEF|EFNEW|EFCR) == ABORT)
return ABORT;
@@ -151,7 +151,7 @@ compile_mode(char *name, char *command)
if (bclear(bp) != TRUE)
return NULL;
- addlinef(bp, "Running (%s).", command);
+ addlinef(bp, "Running (%s).", command);
addline(bp, "");
if ((pipe = popen(command, "r")) == NULL) {
@@ -224,14 +224,14 @@ retry:
gotoline(FFARG, lineno);
return TRUE;
fail:
- free(line);
+ free(line);
if (curwp->w_dotp != lback(curbp->b_linep)) {
curwp->w_dotp = lforw(curwp->w_dotp);
curwp->w_flag |= WFMOVE;
goto retry;
}
ewprintf("No more hits");
- return FALSE;
+ return FALSE;
}
static int
diff --git a/usr.bin/mg/line.c b/usr.bin/mg/line.c
index 0cfb1fe32f8..e3f6c4430a9 100644
--- a/usr.bin/mg/line.c
+++ b/usr.bin/mg/line.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: line.c,v 1.10 2002/02/14 03:15:04 vincent Exp $ */
+/* $OpenBSD: line.c,v 1.11 2002/02/14 14:24:21 deraadt Exp $ */
/*
* Text line handling.
@@ -72,7 +72,7 @@ lrealloc(LINE *lp, int newsize)
return FALSE;
lp->l_text = tmp;
lp->l_size = newsize;
-
+
return TRUE;
}
@@ -169,11 +169,11 @@ linsert(n, c)
/* current line */
lp1 = curwp->w_dotp;
-
+
/* special case for the end */
if (lp1 == curbp->b_linep) {
LINE *lp2, *lp3;
-
+
/* now should only happen in empty buffer */
if (curwp->w_doto != 0) {
ewprintf("bug: linsert");
@@ -182,7 +182,7 @@ linsert(n, c)
/* allocate a new line */
if ((lp2 = lalloc(n)) == NULL)
return FALSE;
-
+
/* previous line */
lp3 = lp1->l_bp;
/* link in */
@@ -200,7 +200,7 @@ linsert(n, c)
if (wp->w_markp == lp1)
wp->w_markp = lp2;
}
-
+
curwp->w_doto = n;
return TRUE;
}
@@ -211,9 +211,9 @@ linsert(n, c)
if ((lp1->l_used + n) > lp1->l_size) {
if (lrealloc(lp1, lp1->l_used + n) == FALSE)
return FALSE;
- }
+ }
lp1->l_used += n;
- if (lp1->l_used != n)
+ if (lp1->l_used != n)
memmove(&lp1->l_text[doto + n], &lp1->l_text[doto],
lp1->l_used - n - doto);
diff --git a/usr.bin/mg/paragraph.c b/usr.bin/mg/paragraph.c
index a3d0912e42a..0e592f876f9 100644
--- a/usr.bin/mg/paragraph.c
+++ b/usr.bin/mg/paragraph.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: paragraph.c,v 1.6 2001/05/24 03:05:25 mickey Exp $ */
+/* $OpenBSD: paragraph.c,v 1.7 2002/02/14 14:24:21 deraadt Exp $ */
/*
* Code for dealing with paragraphs and filling. Adapted from MicroEMACS 3.6
@@ -37,14 +37,14 @@ gotobop(f, n)
* <NL><NL>
*/
while (lback(curwp->w_dotp) != curbp->b_linep)
- if (llength(lback(curwp->w_dotp))
- && lgetc(curwp->w_dotp, 0) != ' '
- && lgetc(curwp->w_dotp, 0) != '.'
- && lgetc(curwp->w_dotp, 0) != '\t')
+ if (llength(lback(curwp->w_dotp)) &&
+ lgetc(curwp->w_dotp, 0) != ' ' &&
+ lgetc(curwp->w_dotp, 0) != '.' &&
+ lgetc(curwp->w_dotp, 0) != '\t')
curwp->w_dotp = lback(curwp->w_dotp);
else {
- if (llength(lback(curwp->w_dotp))
- && lgetc(curwp->w_dotp, 0) == '.') {
+ if (llength(lback(curwp->w_dotp)) &&
+ lgetc(curwp->w_dotp, 0) == '.') {
curwp->w_dotp = lforw(curwp->w_dotp);
if (curwp->w_dotp == curbp->b_linep) {
/*
@@ -90,10 +90,10 @@ gotoeop(f, n)
/* and scan forword until we hit a <NL><SP> or ... */
while (curwp->w_dotp != curbp->b_linep) {
- if (llength(curwp->w_dotp)
- && lgetc(curwp->w_dotp, 0) != ' '
- && lgetc(curwp->w_dotp, 0) != '.'
- && lgetc(curwp->w_dotp, 0) != '\t')
+ if (llength(curwp->w_dotp) &&
+ lgetc(curwp->w_dotp, 0) != ' ' &&
+ lgetc(curwp->w_dotp, 0) != '.' &&
+ lgetc(curwp->w_dotp, 0) != '\t')
curwp->w_dotp = lforw(curwp->w_dotp);
else
break;
@@ -304,14 +304,14 @@ fillword(f, n)
if ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' && c != '\t')
do {
(void)backchar(FFRAND, 1);
- } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' '
- && c != '\t' && curwp->w_doto > 0);
+ } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' &&
+ c != '\t' && curwp->w_doto > 0);
if (curwp->w_doto == 0)
do {
(void)forwchar(FFRAND, 1);
- } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' '
- && c != '\t' && curwp->w_doto < llength(curwp->w_dotp));
+ } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ' &&
+ c != '\t' && curwp->w_doto < llength(curwp->w_dotp));
(void)delwhite(FFRAND, 1);
(void)lnewline();
diff --git a/usr.bin/mg/random.c b/usr.bin/mg/random.c
index 933b1899ae7..bd652c4d66a 100644
--- a/usr.bin/mg/random.c
+++ b/usr.bin/mg/random.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: random.c,v 1.6 2001/05/24 03:05:25 mickey Exp $ */
+/* $OpenBSD: random.c,v 1.7 2002/02/14 14:24:21 deraadt Exp $ */
/*
* Assorted commands.
@@ -180,9 +180,9 @@ newline(f, n)
while (n--) {
lp = curwp->w_dotp;
#ifdef undef
- if (llength(lp) == curwp->w_doto
- && lforw(lp) != curbp->b_linep
- && llength(lforw(lp)) == 0) {
+ if (llength(lp) == curwp->w_doto &&
+ lforw(lp) != curbp->b_linep &&
+ llength(lforw(lp)) == 0) {
if ((s = forwchar(FFRAND, 1)) != TRUE)
return s;
} else
@@ -246,8 +246,8 @@ delwhite(f, n)
col = curwp->w_doto;
- while (((c = lgetc(curwp->w_dotp, col)) == ' ' || c == '\t')
- && col < llength(curwp->w_dotp))
+ while (((c = lgetc(curwp->w_dotp, col)) == ' ' || c == '\t') &&
+ col < llength(curwp->w_dotp))
++col;
do {
if (curwp->w_doto == 0) {
diff --git a/usr.bin/mg/tty.c b/usr.bin/mg/tty.c
index 2e32d22321f..b40b77cb23c 100644
--- a/usr.bin/mg/tty.c
+++ b/usr.bin/mg/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.12 2002/02/05 20:47:32 art Exp $ */
+/* $OpenBSD: tty.c,v 1.13 2002/02/14 14:24:21 deraadt Exp $ */
/*
* Terminfo display driver
@@ -371,7 +371,7 @@ ttnowindow()
{
if (change_scroll_region) {
putpad(tgoto(change_scroll_region,
- (nrow > lines ? nrow : lines) - 1, 0), nrow - ttrow);
+ (nrow > lines ? nrow : lines) - 1, 0), nrow - ttrow);
ttrow = HUGE; /* Unknown. */
ttcol = HUGE;
tttop = HUGE; /* No scroll region. */
diff --git a/usr.bin/mg/window.c b/usr.bin/mg/window.c
index 6969bc0a1b6..a4b63a35dab 100644
--- a/usr.bin/mg/window.c
+++ b/usr.bin/mg/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.8 2002/02/08 21:21:11 deraadt Exp $ */
+/* $OpenBSD: window.c,v 1.9 2002/02/14 14:24:21 deraadt Exp $ */
/*
* Window handling.
@@ -409,8 +409,8 @@ wpopup()
{
MGWIN *wp;
- if (wheadp->w_wndp == NULL
- && splitwind(FFRAND, 0) == FALSE)
+ if (wheadp->w_wndp == NULL &&
+ splitwind(FFRAND, 0) == FALSE)
return NULL;
/* find a window to use */