summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/README18
-rw-r--r--usr.bin/mg/autoexec.c26
-rw-r--r--usr.bin/mg/basic.c70
-rw-r--r--usr.bin/mg/buffer.c160
-rw-r--r--usr.bin/mg/chrdef.h4
-rw-r--r--usr.bin/mg/cinfo.c12
-rw-r--r--usr.bin/mg/def.h67
-rw-r--r--usr.bin/mg/dir.c15
-rw-r--r--usr.bin/mg/dired.c257
-rw-r--r--usr.bin/mg/display.c117
-rw-r--r--usr.bin/mg/echo.c90
-rw-r--r--usr.bin/mg/extend.c171
-rw-r--r--usr.bin/mg/file.c73
-rw-r--r--usr.bin/mg/fileio.c101
-rw-r--r--usr.bin/mg/funmap.c38
-rw-r--r--usr.bin/mg/funmap.h12
-rw-r--r--usr.bin/mg/grep.c124
-rw-r--r--usr.bin/mg/help.c76
-rw-r--r--usr.bin/mg/kbd.c57
-rw-r--r--usr.bin/mg/kbd.h22
-rw-r--r--usr.bin/mg/keymap.c113
-rw-r--r--usr.bin/mg/line.c100
-rw-r--r--usr.bin/mg/macro.c18
-rw-r--r--usr.bin/mg/mail.c20
-rw-r--r--usr.bin/mg/main.c34
-rw-r--r--usr.bin/mg/match.c19
-rw-r--r--usr.bin/mg/modes.c40
-rw-r--r--usr.bin/mg/paragraph.c48
-rw-r--r--usr.bin/mg/random.c76
-rw-r--r--usr.bin/mg/re_search.c27
-rw-r--r--usr.bin/mg/region.c49
-rw-r--r--usr.bin/mg/search.c81
-rw-r--r--usr.bin/mg/spawn.c6
-rw-r--r--usr.bin/mg/sysdef.h10
-rw-r--r--usr.bin/mg/theo.c27
-rw-r--r--usr.bin/mg/tty.c30
-rw-r--r--usr.bin/mg/ttydef.h10
-rw-r--r--usr.bin/mg/ttyio.c24
-rw-r--r--usr.bin/mg/ttykbd.c4
-rw-r--r--usr.bin/mg/tutorial6
-rw-r--r--usr.bin/mg/undo.c69
-rw-r--r--usr.bin/mg/version.c6
-rw-r--r--usr.bin/mg/window.c36
-rw-r--r--usr.bin/mg/word.c60
44 files changed, 1179 insertions, 1244 deletions
diff --git a/usr.bin/mg/README b/usr.bin/mg/README
index 3bc502ab408..88c588abc6b 100644
--- a/usr.bin/mg/README
+++ b/usr.bin/mg/README
@@ -19,7 +19,7 @@ agree with the opinions expressed by Richard Stallman in "The GNU
Manifesto".
Documentation of Mg is in the TeX file mg.tex. This should be
-formatted with the TeX text formatter and printed. A start twords a
+formatted with the TeX text formatter and printed. A start towards a
mg programmers guide is in mgprog.doc, and some of the changes from 1b
are mentioned briefly in mg2a.change.
@@ -44,8 +44,8 @@ This also comes from mod.sources, and is the latest version from the
original MicroEMACS author Dave Conroy. Mg is derived from this
version, and for the most part has replaced it.
-Mg is continuing to diverge from other MicroEmacs varients.
-Significant modifacations would me nessisary to adapt code from either
+Mg is continuing to diverge from other MicroEmacs variants.
+Significant modifications would me require to adapt code from either
the 3.x strains or v30. Command functions and key mapping, for
instance, are completely different.
@@ -79,7 +79,7 @@ These systems are known to work in the current version:
Ms-Dos support is planned, but did not get done in time for this
release. (Jeff Siegal <jbs@eddie.mit.edu> was the one doing it.)
-The Ms-Dos files will probably be distributed seperatly when it
+The Ms-Dos files will probably be distributed separately when it
becomes available.
Cpm/68k support was dropped due to compiler bugs. Eunice support was
@@ -112,7 +112,7 @@ There are several other directories under sys: osk, vms, amiga, atari,
prime. You should follow the directions contained therein to make one
of those versions.
-For most systems (everyting except the amiga, and atari currently),
+For most systems (everything except the amiga, and atari currently),
the termcap terminal definition is used. There is a readme file in
the default subdirectory of the sys directory explaining what entries
are used and how. (Termcap is a way to do display manipulation in a
@@ -123,13 +123,13 @@ example, in .mg.vt100 you may want to (global-set-key "\e[A"
Some changes made to make this version more like Gnu Emacs may break
startup files. Gnu Emacs 18 has both backward-delete-char and
-delete-backward-char that apperently do the same thing. This version
+delete-backward-char that apparently do the same thing. This version
has only the latter because that is what is documented in my manual
(version 17) and bound by Gnu Emacs to DEL.
----------------------------------------------------------------------
-Known limitaions:
+Known limitations:
Recursive bindings may cause help and key rebinding code to go into
an infinite loop, aborting with a stack overflow.
@@ -172,9 +172,9 @@ Internet. (UUCP sites that are customers of uunet can get it via
them. Contact uunet!uunet-request for details.) If you can't reach
one of us via a computer network, I suppose you could send a change to
my snail mail address below on 5" os9 format disks or 9 track tape
-(ANSI variable label or Prime magsav format), but this effectivly
+(ANSI variable label or Prime magsav format), but this effectively
rules you out as a potential beta tester. (Don't expect the disk or
-tape back unless you inculude a SASE with sufficent postage.) I will
+tape back unless you include a SASE with sufficient postage.) I will
not be sending out copies on magnetic media, so please don't ask. If
you somehow got an incomplete or non-standard copy, (i.e. missing one
of the sys directories mentioned here as working) complain to who you
diff --git a/usr.bin/mg/autoexec.c b/usr.bin/mg/autoexec.c
index 4b9969157f0..591b010f497 100644
--- a/usr.bin/mg/autoexec.c
+++ b/usr.bin/mg/autoexec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoexec.c,v 1.5 2005/03/10 16:58:57 deraadt Exp $ */
+/* $OpenBSD: autoexec.c,v 1.6 2005/04/03 02:09:28 db Exp $ */
/* this file is in the public domain */
/* Author: Vincent Labrecque <vincent@openbsd.org> April 2002 */
@@ -26,8 +26,8 @@ static int ready;
PF *
find_autoexec(const char *fname)
{
- PF *pfl, *npfl;
- int have, used;
+ PF *pfl, *npfl;
+ int have, used;
struct autoexec *ae;
if (!ready)
@@ -58,7 +58,7 @@ find_autoexec(const char *fname)
int
add_autoexec(const char *pattern, const char *func)
{
- PF fp;
+ PF fp;
struct autoexec *ae;
if (!ready) {
@@ -68,7 +68,7 @@ add_autoexec(const char *pattern, const char *func)
fp = name_function(func);
if (fp == NULL)
return (FALSE);
- ae = malloc(sizeof *ae);
+ ae = malloc(sizeof(*ae));
if (ae == NULL)
return (FALSE);
ae->fp = fp;
@@ -85,17 +85,17 @@ add_autoexec(const char *pattern, const char *func)
int
auto_execute(int f, int n)
{
- char patbuf[128], funcbuf[128], *patp, *funcp;
- int s;
+ char patbuf[128], funcbuf[128], *patp, *funcp;
+ int s;
- if ((patp = ereply("Filename pattern: ", patbuf, sizeof patbuf)) == NULL)
- return ABORT;
+ if ((patp = ereply("Filename pattern: ", patbuf, sizeof(patbuf))) == NULL)
+ return (ABORT);
else if (patp[0] == '\0')
- return FALSE;
- if ((funcp = ereply("Execute: ", funcbuf, sizeof funcbuf)) == NULL)
- return ABORT;
+ return (FALSE);
+ if ((funcp = ereply("Execute: ", funcbuf, sizeof(funcbuf))) == NULL)
+ return (ABORT);
else if (funcp[0] == '\0')
- return FALSE;
+ return (FALSE);
if ((s = add_autoexec(patp, funcp)) != TRUE)
return (s);
return (TRUE);
diff --git a/usr.bin/mg/basic.c b/usr.bin/mg/basic.c
index 8908b012013..378ffe7240e 100644
--- a/usr.bin/mg/basic.c
+++ b/usr.bin/mg/basic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: basic.c,v 1.17 2005/03/10 16:58:57 deraadt Exp $ */
+/* $OpenBSD: basic.c,v 1.18 2005/04/03 02:09:28 db Exp $ */
/*
* Basic cursor motion commands.
@@ -37,7 +37,7 @@ backchar(int f, int n)
LINE *lp;
if (n < 0)
- return forwchar(f, -n);
+ return (forwchar(f, -n));
while (n--) {
if (curwp->w_doto == 0) {
if ((lp = lback(curwp->w_dotp)) == curbp->b_linep) {
@@ -51,7 +51,7 @@ backchar(int f, int n)
} else
curwp->w_doto--;
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -75,9 +75,8 @@ gotoeol(int f, int n)
int
forwchar(int f, int n)
{
-
if (n < 0)
- return backchar(f, -n);
+ return (backchar(f, -n));
while (n--) {
if (curwp->w_doto == llength(curwp->w_dotp)) {
curwp->w_dotp = lforw(curwp->w_dotp);
@@ -85,14 +84,14 @@ forwchar(int f, int n)
curwp->w_dotp = lback(curwp->w_dotp);
if (!(f & FFRAND))
ewprintf("End of buffer");
- return FALSE;
+ return (FALSE);
}
curwp->w_doto = 0;
curwp->w_flag |= WFMOVE;
} else
curwp->w_doto++;
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -103,12 +102,11 @@ forwchar(int f, int n)
int
gotobob(int f, int n)
{
-
(void) setmark(f, n);
curwp->w_dotp = lforw(curbp->b_linep);
curwp->w_doto = 0;
curwp->w_flag |= WFHARD;
- return TRUE;
+ return (TRUE);
}
/*
@@ -119,12 +117,11 @@ gotobob(int f, int n)
int
gotoeob(int f, int n)
{
-
(void) setmark(f, n);
curwp->w_dotp = lback(curbp->b_linep);
curwp->w_doto = llength(curwp->w_dotp);
curwp->w_flag |= WFHARD;
- return TRUE;
+ return (TRUE);
}
/*
@@ -141,12 +138,12 @@ forwline(int f, int n)
LINE *dlp;
if (n < 0)
- return backline(f | FFRAND, -n);
+ return (backline(f | FFRAND, -n));
if ((lastflag & CFCPCN) == 0) /* Fix goal. */
setgoal();
thisflag |= CFCPCN;
if (n == 0)
- return TRUE;
+ return (TRUE);
dlp = curwp->w_dotp;
while (dlp != curbp->b_linep && n--)
dlp = lforw(dlp);
@@ -160,7 +157,7 @@ forwline(int f, int n)
curwp->w_doto = 0;
while (n-- >= 0) {
if ((dlp = lalloc(0)) == NULL)
- return FALSE;
+ return (FALSE);
dlp->l_fp = curbp->b_linep;
dlp->l_bp = lback(dlp->l_fp);
dlp->l_bp->l_fp = dlp->l_fp->l_bp = dlp;
@@ -170,7 +167,7 @@ forwline(int f, int n)
curwp->w_dotp = dlp;
curwp->w_doto = getgoal(dlp);
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -187,7 +184,7 @@ backline(int f, int n)
LINE *dlp;
if (n < 0)
- return forwline(f | FFRAND, -n);
+ return (forwline(f | FFRAND, -n));
if ((lastflag & CFCPCN) == 0) /* Fix goal. */
setgoal();
thisflag |= CFCPCN;
@@ -197,7 +194,7 @@ backline(int f, int n)
curwp->w_dotp = dlp;
curwp->w_doto = getgoal(dlp);
curwp->w_flag |= WFMOVE;
- return TRUE;
+ return (TRUE);
}
/*
@@ -240,7 +237,7 @@ getgoal(LINE *dlp)
else {
char tmp[5];
- snprintf(tmp, sizeof tmp, "\\%o", c);
+ snprintf(tmp, sizeof(tmp), "\\%o", c);
col += strlen(tmp);
}
if (col > curgoal)
@@ -268,7 +265,7 @@ forwpage(int f, int n)
if (n <= 0) /* Forget the overlap */
n = 1; /* if tiny window. */
} else if (n < 0)
- return backpage(f | FFRAND, -n);
+ return (backpage(f | FFRAND, -n));
#ifdef CVMVAS
else /* Convert from pages */
n *= curwp->w_ntrows; /* to lines. */
@@ -281,10 +278,10 @@ forwpage(int f, int n)
/* if in current window, don't move dot */
for (n = curwp->w_ntrows; n-- && lp != curbp->b_linep; lp = lforw(lp))
if (lp == curwp->w_dotp)
- return TRUE;
+ return (TRUE);
curwp->w_dotp = curwp->w_linep;
curwp->w_doto = 0;
- return TRUE;
+ return (TRUE);
}
/*
@@ -306,7 +303,7 @@ backpage(int f, int n)
if (n <= 0) /* Don't blow up if the */
n = 1; /* window is tiny. */
} else if (n < 0)
- return forwpage(f | FFRAND, -n);
+ return (forwpage(f | FFRAND, -n));
#ifdef CVMVAS
else /* Convert from pages */
n *= curwp->w_ntrows; /* to lines. */
@@ -319,10 +316,10 @@ backpage(int f, int n)
/* if in current window, don't move dot */
for (n = curwp->w_ntrows; n-- && lp != curbp->b_linep; lp = lforw(lp))
if (lp == curwp->w_dotp)
- return TRUE;
+ return (TRUE);
curwp->w_dotp = curwp->w_linep;
curwp->w_doto = 0;
- return TRUE;
+ return (TRUE);
}
/*
@@ -337,7 +334,7 @@ forw1page(int f, int n)
f = FFUNIV;
}
forwpage(f | FFRAND, n);
- return TRUE;
+ return (TRUE);
}
int
@@ -348,7 +345,7 @@ back1page(int f, int n)
f = FFUNIV;
}
backpage(f | FFRAND, n);
- return TRUE;
+ return (TRUE);
}
/*
@@ -362,14 +359,14 @@ pagenext(int f, int n)
if (wheadp->w_wndp == NULL) {
ewprintf("No other window");
- return FALSE;
+ return (FALSE);
}
wp = curwp;
(void) nextwind(f, n);
(void) forwpage(f, n);
curwp = wp;
curbp = wp->w_bufp;
- return TRUE;
+ return (TRUE);
}
/*
@@ -391,10 +388,9 @@ isetmark(void)
int
setmark(int f, int n)
{
-
isetmark();
ewprintf("Mark set");
- return TRUE;
+ return (TRUE);
}
/*
@@ -413,7 +409,7 @@ swapmark(int f, int n)
if (curwp->w_markp == NULL) {
ewprintf("No mark in this window");
- return FALSE;
+ return (FALSE);
}
odotp = curwp->w_dotp;
odoto = curwp->w_doto;
@@ -422,7 +418,7 @@ swapmark(int f, int n)
curwp->w_markp = odotp;
curwp->w_marko = odoto;
curwp->w_flag |= WFMOVE;
- return TRUE;
+ return (TRUE);
}
/*
@@ -442,18 +438,18 @@ gotoline(int f, int n)
if (!(f & FFARG)) {
if ((bufp = ereply("Goto line: ", buf, sizeof(buf))) == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
nl = strtol(bufp, &tmp, 10);
if (bufp[0] == '\0' || *tmp != '\0') {
ewprintf("Invalid number");
- return FALSE;
+ return (FALSE);
}
if (nl >= INT_MAX || nl <= INT_MIN) {
ewprintf("Out of range");
- return FALSE;
+ return (FALSE);
}
n = (int)nl;
}
@@ -476,5 +472,5 @@ gotoline(int f, int n)
curwp->w_dotp = clp;
curwp->w_doto = 0;
curwp->w_flag |= WFMOVE;
- return TRUE;
+ return (TRUE);
}
diff --git a/usr.bin/mg/buffer.c b/usr.bin/mg/buffer.c
index d287ad92d73..c3b66be610d 100644
--- a/usr.bin/mg/buffer.c
+++ b/usr.bin/mg/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.36 2005/03/10 16:58:57 deraadt Exp $ */
+/* $OpenBSD: buffer.c,v 1.37 2005/04/03 02:09:28 db Exp $ */
/*
* Buffer handling.
@@ -23,7 +23,7 @@ togglereadonly(int f, int n)
}
curwp->w_flag |= WFMODE;
- return(1);
+ return (1);
}
/*
@@ -48,15 +48,15 @@ usebuffer(int f, int n)
EFNEW | EFBUF, curbp->b_altb->b_bname);
if (bufp == NULL)
- return ABORT;
+ return (ABORT);
if (bufn[0] == 0 && curbp->b_altb != NULL)
bp = curbp->b_altb;
else if ((bp = bfind(bufn, TRUE)) == NULL)
- return FALSE;
+ return (FALSE);
/* and put it in current window */
curbp = bp;
- return showbuffer(bp, curwp, WFFORCE | WFHARD);
+ return (showbuffer(bp, curwp, WFFORCE | WFHARD));
}
/*
@@ -79,18 +79,18 @@ poptobuffer(int f, int n)
bufp = eread("Switch to buffer in other window: (default %s) ",
bufn, NBUFN, EFNEW | EFBUF, curbp->b_altb->b_bname);
if (bufp == NULL)
- return ABORT;
+ return (ABORT);
if (bufp[0] == 0 && curbp->b_altb != NULL)
bp = curbp->b_altb;
else if ((bp = bfind(bufn, TRUE)) == NULL)
- return FALSE;
+ return (FALSE);
/* and put it in a new window */
if ((wp = popbuf(bp)) == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
curwp = wp;
- return TRUE;
+ return (TRUE);
}
/*
@@ -109,12 +109,12 @@ killbuffer_cmd(int f, int n)
if ((bufp = eread("Kill buffer: (default %s) ", bufn, NBUFN, EFNEW | EFBUF,
curbp->b_bname)) == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == 0)
bp = curbp;
else if ((bp = bfind(bufn, FALSE)) == NULL)
- return FALSE;
- return killbuffer(bp);
+ return (FALSE);
+ return (killbuffer(bp));
}
int
@@ -125,7 +125,7 @@ killbuffer(BUFFER *bp)
MGWIN *wp;
/*
- * Find some other buffer to display. try the alternate buffer,
+ * Find some other buffer to display. Try the alternate buffer,
* then the first different buffer in the buffer list. If there's
* only one buffer, create buffer *scratch* and make it the alternate
* buffer. Return if *scratch* is only buffer...
@@ -135,14 +135,14 @@ killbuffer(BUFFER *bp)
if (bp1 == NULL) {
/* only one buffer. see if it's *scratch* */
if (bp == bfind("*scratch*", FALSE))
- return FALSE;
+ return (FALSE);
/* create *scratch* for alternate buffer */
if ((bp1 = bfind("*scratch*", TRUE)) == NULL)
- return FALSE;
+ return (FALSE);
}
}
if (bclear(bp) != TRUE)
- return TRUE;
+ return (TRUE);
for (wp = wheadp; bp->b_nwnd > 0; wp = wp->w_wndp) {
if (wp->w_bufp == bp) {
bp2 = bp1->b_altb; /* save alternate buffer */
@@ -175,7 +175,7 @@ killbuffer(BUFFER *bp)
}
free((char *)bp->b_bname); /* Release name block */
free(bp); /* Release buffer block */
- return TRUE;
+ return (TRUE);
}
/*
@@ -186,8 +186,8 @@ int
savebuffers(int f, int n)
{
if (anycb(f) == ABORT)
- return ABORT;
- return TRUE;
+ return (ABORT);
+ return (TRUE);
}
/*
@@ -198,7 +198,7 @@ static int listbuf_ncol;
static int listbuf_goto_buffer(int f, int n);
static PF listbuf_pf[] = {
- listbuf_goto_buffer,
+ listbuf_goto_buffer
};
static struct KEYMAPE (1 + IMAPEXT) listbufmap = {
@@ -206,7 +206,7 @@ static struct KEYMAPE (1 + IMAPEXT) listbufmap = {
1 + IMAPEXT,
rescan,
{
- { CCHR('M'), CCHR('M'), listbuf_pf, NULL },
+ { CCHR('M'), CCHR('M'), listbuf_pf, NULL }
}
};
@@ -221,9 +221,9 @@ static struct KEYMAPE (1 + IMAPEXT) listbufmap = {
int
listbuffers(int f, int n)
{
- static int initialized = 0;
- BUFFER *bp;
- MGWIN *wp;
+ static int initialized = 0;
+ BUFFER *bp;
+ MGWIN *wp;
if (!initialized) {
maps_add((KEYMAP *)&listbufmap, "listbufmap");
@@ -231,21 +231,22 @@ listbuffers(int f, int n)
}
if ((bp = makelist()) == NULL || (wp = popbuf(bp)) == NULL)
- return FALSE;
- wp->w_dotp = bp->b_dotp;/* fix up if window already on screen */
+ return (FALSE);
+ wp->w_dotp = bp->b_dotp; /* fix up if window already on screen */
wp->w_doto = bp->b_doto;
bp->b_modes[0] = name_mode("fundamental");
bp->b_modes[1] = name_mode("listbufmap");
bp->b_nmodes = 1;
- return TRUE;
+ return (TRUE);
}
/*
* This routine rebuilds the text for the
- * list buffers command. Return TRUE if
- * everything works. Return FALSE if there
- * is an error (if there is no memory).
+ * list buffers command. Return pointer
+ * to new list if everything works.
+ * Return NULL if there is an error (if
+ * there is no memory).
*/
static BUFFER *
makelist(void)
@@ -256,9 +257,9 @@ makelist(void)
if ((blp = bfind("*Buffer List*", TRUE)) == NULL)
- return NULL;
+ return (NULL);
if (bclear(blp) != TRUE)
- return NULL;
+ return (NULL);
blp->b_flag &= ~BFCHG; /* Blow away old. */
blp->b_flag |= BFREADONLY;
@@ -266,7 +267,7 @@ makelist(void)
if (addlinef(blp, "%-*s%s", w, " MR Buffer", "Size File") == FALSE ||
addlinef(blp, "%-*s%s", w, " -- ------", "---- ----") == FALSE)
- return NULL;
+ return (NULL);
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
RSIZE nbytes;
@@ -293,29 +294,29 @@ makelist(void)
nbytes, /* buffer size */
w - 7, /* seven chars already written */
bp->b_fname) == FALSE)
- return NULL;
+ return (NULL);
}
blp->b_dotp = lforw(blp->b_linep); /* put dot at beginning of
* buffer */
blp->b_doto = 0;
- return blp; /* All done */
+ return (blp); /* All done */
}
static int
listbuf_goto_buffer(int f, int n)
{
- BUFFER *bp;
- MGWIN *wp;
- char *line;
- int i;
+ BUFFER *bp;
+ MGWIN *wp;
+ char *line;
+ int i;
if (curwp->w_dotp->l_text[listbuf_ncol/2 - 1] == '$') {
ewprintf("buffer name truncated");
- return FALSE;
+ return (FALSE);
}
if ((line = malloc(listbuf_ncol/2)) == NULL)
- return FALSE;
+ return (FALSE);
memcpy(line, curwp->w_dotp->l_text + 4, listbuf_ncol/2 - 5);
for (i = listbuf_ncol/2 - 6; i > 0; i--) {
@@ -324,23 +325,22 @@ listbuf_goto_buffer(int f, int n)
break;
}
}
- if (i == 0) {
- return FALSE;
- }
+ if (i == 0)
+ return (FALSE);
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
if (strcmp(bp->b_bname, line) == 0)
break;
}
- if (bp == NULL) {
- return FALSE;
- }
+ if (bp == NULL)
+ return (FALSE);
+
if ((wp = popbuf(bp)) == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
curwp = wp;
- return TRUE;
+ return (TRUE);
}
/*
@@ -351,8 +351,8 @@ listbuf_goto_buffer(int f, int n)
int
addlinef(BUFFER *bp, char *fmt, ...)
{
- va_list ap;
- LINE *lp;
+ va_list ap;
+ LINE *lp;
if ((lp = lalloc(0)) == NULL)
return (FALSE);
@@ -370,7 +370,7 @@ addlinef(BUFFER *bp, char *fmt, ...)
bp->b_linep->l_bp = lp;
lp->l_fp = bp->b_linep;
- return TRUE;
+ return (TRUE);
}
/*
@@ -383,13 +383,13 @@ int
anycb(int f)
{
BUFFER *bp;
- int s = FALSE, save = FALSE;
- char prompt[NFILEN + 11];
+ int s = FALSE, save = FALSE;
+ 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) {
- snprintf(prompt, sizeof prompt, "Save file %s",
+ snprintf(prompt, sizeof(prompt), "Save file %s",
bp->b_fname);
if ((f == TRUE || (save = eyorn(prompt)) == TRUE) &&
buffsave(bp) == TRUE) {
@@ -404,7 +404,7 @@ anycb(int f)
}
if (save == FALSE /* && kbdmop == NULL */ ) /* experimental */
ewprintf("(No files need saving)");
- return s;
+ return (s);
}
/*
@@ -424,26 +424,26 @@ bfind(const char *bname, int cflag)
bp = bheadp;
while (bp != NULL) {
if (strcmp(bname, bp->b_bname) == 0)
- return bp;
+ return (bp);
bp = bp->b_bufp;
}
if (cflag != TRUE)
- return NULL;
+ return (NULL);
bp = calloc(1, sizeof(BUFFER));
if (bp == NULL) {
ewprintf("Can't get %d bytes", sizeof(BUFFER));
- return NULL;
+ return (NULL);
}
if ((bp->b_bname = strdup(bname)) == NULL) {
ewprintf("Can't get %d bytes", strlen(bname) + 1);
free(bp);
- return NULL;
+ return (NULL);
}
if ((lp = lalloc(0)) == NULL) {
free((char *) bp->b_bname);
free(bp);
- return NULL;
+ return (NULL);
}
bp->b_altb = bp->b_bufp = NULL;
bp->b_dotp = lp;
@@ -464,7 +464,7 @@ bfind(const char *bname, int cflag)
lp->l_bp = lp;
bp->b_bufp = bheadp;
bheadp = bp;
- return bp;
+ return (bp);
}
/*
@@ -483,7 +483,7 @@ bclear(BUFFER *bp)
LINE *lp;
int s;
- if ((bp->b_flag & BFCHG) != 0 && /* Changed. */
+ if ((bp->b_flag & BFCHG) != 0 && /* Changed. */
(s = eyesno("Buffer modified; kill anyway")) != TRUE)
return (s);
bp->b_flag &= ~BFCHG; /* Not changed */
@@ -493,7 +493,7 @@ bclear(BUFFER *bp)
bp->b_doto = 0;
bp->b_markp = NULL; /* Invalidate "mark" */
bp->b_marko = 0;
- return TRUE;
+ return (TRUE);
}
/*
@@ -510,9 +510,9 @@ showbuffer(BUFFER *bp, MGWIN *wp, int flags)
wp->w_flag |= flags;
wp->w_dotp = bp->b_dotp;
wp->w_doto = bp->b_doto;
- return TRUE;
+ return (TRUE);
}
- /* First, dettach the old buffer from the window */
+ /* First, detach the old buffer from the window */
if ((bp->b_altb = obp = wp->w_bufp) != NULL) {
if (--obp->b_nwnd == 0) {
obp->b_dotp = wp->w_dotp;
@@ -540,7 +540,7 @@ showbuffer(BUFFER *bp, MGWIN *wp, int flags)
break;
}
wp->w_flag |= WFMODE | flags;
- return TRUE;
+ return (TRUE);
}
/*
@@ -554,16 +554,16 @@ popbuf(BUFFER *bp)
if (bp->b_nwnd == 0) { /* Not on screen yet. */
if ((wp = wpopup()) == NULL)
- return NULL;
+ return (NULL);
} else
for (wp = wheadp; wp != NULL; wp = wp->w_wndp)
if (wp->w_bufp == bp) {
wp->w_flag |= WFHARD | WFFORCE;
- return wp;
+ return (wp);
}
if (showbuffer(bp, wp, WFHARD) != TRUE)
- return NULL;
- return wp;
+ return (NULL);
+ return (wp);
}
/*
@@ -585,15 +585,15 @@ bufferinsert(int f, int n)
else
bufp = eread("Insert buffer: ", bufn, NBUFN, EFNEW | EFBUF, NULL);
if (bufp == NULL)
- return ABORT;
+ return (ABORT);
if (bufp[0] == '\0' && curbp->b_altb != NULL)
bp = curbp->b_altb;
else if ((bp = bfind(bufn, FALSE)) == NULL)
- return FALSE;
+ return (FALSE);
if (bp == curbp) {
ewprintf("Cannot insert buffer into self");
- return FALSE;
+ return (FALSE);
}
/* insert the buffer */
nline = 0;
@@ -601,11 +601,11 @@ bufferinsert(int f, int n)
for (;;) {
for (clo = 0; clo < llength(clp); clo++)
if (linsert(1, lgetc(clp, clo)) == FALSE)
- return FALSE;
+ return (FALSE);
if ((clp = lforw(clp)) == bp->b_linep)
break;
if (newline(FFRAND, 1) == FALSE) /* fake newline */
- return FALSE;
+ return (FALSE);
nline++;
}
if (nline == 1)
@@ -613,11 +613,11 @@ bufferinsert(int f, int n)
else
ewprintf("[Inserted %d lines]", nline);
- clp = curwp->w_linep; /* cosmetic adjustment */
+ clp = curwp->w_linep; /* cosmetic adjustment */
if (curwp->w_dotp == clp) { /* for offscreen insert */
while (nline-- && lback(clp) != curbp->b_linep)
clp = lback(clp);
- curwp->w_linep = clp; /* adjust framing. */
+ curwp->w_linep = clp; /* adjust framing. */
curwp->w_flag |= WFHARD;
}
return (TRUE);
@@ -640,7 +640,7 @@ notmodified(int f, int n)
wp = wp->w_wndp;
}
ewprintf("Modification-flag cleared");
- return TRUE;
+ return (TRUE);
}
#ifndef NO_HELP
@@ -663,6 +663,6 @@ popbuftop(BUFFER *bp)
wp->w_flag |= WFHARD;
}
}
- return popbuf(bp) != NULL;
+ return (popbuf(bp) != NULL);
}
#endif
diff --git a/usr.bin/mg/chrdef.h b/usr.bin/mg/chrdef.h
index d75b098c139..1b0ec6da4ab 100644
--- a/usr.bin/mg/chrdef.h
+++ b/usr.bin/mg/chrdef.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: chrdef.h,v 1.5 2002/02/21 04:15:30 deraadt Exp $ */
+/* $OpenBSD: chrdef.h,v 1.6 2005/04/03 02:09:28 db Exp $ */
/*
* sys/default/chardef.h: character set specific #defines for Mg 2a
@@ -6,7 +6,7 @@
*/
/*
- * Casting should be at least as efficent as anding with 0xff,
+ * Casting should be at least as efficient as anding with 0xff,
* and won't have the size problems. Override in sysdef.h if no
* unsigned char type.
*/
diff --git a/usr.bin/mg/cinfo.c b/usr.bin/mg/cinfo.c
index 580a38184af..d14fa4eef42 100644
--- a/usr.bin/mg/cinfo.c
+++ b/usr.bin/mg/cinfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cinfo.c,v 1.10 2002/07/01 14:33:44 vincent Exp $ */
+/* $OpenBSD: cinfo.c,v 1.11 2005/04/03 02:09:28 db Exp $ */
/*
* Character class tables.
@@ -93,10 +93,10 @@ char *
keyname(char *cp, size_t len, int k)
{
const char *np;
- size_t copied;
+ size_t copied;
if (k < 0)
- k = CHARMASK(k);/* sign extended char */
+ k = CHARMASK(k); /* sign extended char */
switch (k) {
case CCHR('@'):
np = "C-SPC";
@@ -131,7 +131,7 @@ keyname(char *cp, size_t len, int k)
*cp++ = ((k >> 3) & 7) + '0';
*cp++ = (k & 7) + '0';
*cp = '\0';
- return cp;
+ return (cp);
} else if (k < ' ') {
*cp++ = 'C';
*cp++ = '-';
@@ -141,10 +141,10 @@ keyname(char *cp, size_t len, int k)
}
*cp++ = k;
*cp = '\0';
- return cp;
+ return (cp);
}
copied = strlcpy(cp, np, len);
if (copied >= len)
copied = len - 1;
- return cp + copied;
+ return (cp + copied);
}
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index 6caa5fbb8cb..5604c2e5abf 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.59 2005/03/12 06:16:07 deraadt Exp $ */
+/* $OpenBSD: def.h,v 1.60 2005/04/03 02:09:28 db Exp $ */
#include <sys/queue.h>
@@ -34,7 +34,7 @@ typedef int (*PF)(int, int); /* generally useful type */
#define HUGE 1000 /* A rather large number. */
#define NSRCH 128 /* Undoable search commands. */
#define NXNAME 64 /* Length, extended command. */
-#define NKNAME 20 /* Length, key names */
+#define NKNAME 20 /* Length, key names. */
/*
* Universal.
*/
@@ -53,7 +53,7 @@ typedef int (*PF)(int, int); /* generally useful type */
*/
#define CFCPCN 0x0001 /* Last command was C-P, C-N */
#define CFKILL 0x0002 /* Last command was a kill */
-#define CFINS 0x0004 /* Last command was self-insert */
+#define CFINS 0x0004 /* Last command was self-insert */
/*
* File I/O.
@@ -93,7 +93,7 @@ typedef int (*PF)(int, int); /* generally useful type */
#define EFFUNC 0x0001 /* Autocomplete functions. */
#define EFBUF 0x0002 /* Autocomplete buffers. */
#define EFFILE 0x0004 /* " files (maybe someday) */
-#define EFAUTO 0x0007 /* Some autocompleteion on */
+#define EFAUTO 0x0007 /* Some autocompletion on */
#define EFNEW 0x0008 /* New prompt. */
#define EFCR 0x0010 /* Echo CR at end; last read. */
#define EFDEF 0x0020 /* buffer contains default args */
@@ -114,8 +114,8 @@ typedef int (*PF)(int, int); /* generally useful type */
*/
typedef struct {
struct LINE *r_linep; /* Origin LINE address. */
- int r_offset; /* Origin LINE offset. */
- RSIZE r_size; /* Length in characters. */
+ int r_offset; /* Origin LINE offset. */
+ RSIZE r_size; /* Length in characters. */
} REGION;
@@ -124,7 +124,7 @@ typedef struct {
* lists of "LINE" structures. These begin at the
* header line (which is the blank line beyond the
* end of the buffer). This line is pointed to by
- * the "BUFFER". Each line contains a the number of
+ * the "BUFFER". Each line contains the number of
* bytes in the line (the "used" size), the size
* of the text array, and the text. The end of line
* is not stored as a byte; it's implied. Future
@@ -132,11 +132,11 @@ typedef struct {
* list of marks into the line.
*/
typedef struct LINE {
- struct LINE *l_fp; /* Link to the next line */
- struct LINE *l_bp; /* Link to the previous line */
- int l_size; /* Allocated size */
- int l_used; /* Used size */
- char *l_text; /* Content of the line */
+ struct LINE *l_fp; /* Link to the next line */
+ struct LINE *l_bp; /* Link to the previous line */
+ int l_size; /* Allocated size */
+ int l_used; /* Used size */
+ char *l_text; /* Content of the line */
} LINE;
/*
@@ -159,7 +159,7 @@ typedef struct LINE {
* All of these start with a LIST structure (except lines, which
* have their own abstraction). This will allow for
* later conversion to generic list manipulation routines should
- * I decide to do that. it does mean that there are four extra
+ * I decide to do that. It does mean that there are four extra
* bytes per window. I feel that this is an acceptable price,
* considering that there are usually only one or two windows.
*/
@@ -189,20 +189,20 @@ typedef struct LIST {
* expensive to run for every input character.
*/
typedef struct MGWIN {
- LIST w_list; /* List header */
+ LIST w_list; /* List header */
struct BUFFER *w_bufp; /* Buffer displayed in window */
struct LINE *w_linep; /* Top line in the window */
struct LINE *w_dotp; /* Line containing "." */
struct LINE *w_markp; /* Line containing "mark" */
- int w_doto; /* Byte offset for "." */
- int w_marko; /* Byte offset for "mark" */
- char w_toprow; /* Origin 0 top row of window */
- char w_ntrows; /* # of rows of text in window */
- char w_force; /* If NZ, forcing row. */
- char w_flag; /* Flags. */
- LIST_HEAD(, undo_rec) w_undo; /* Undo actions list */
- int w_undopos; /* Where we were during the last
- undo action */
+ int w_doto; /* Byte offset for "." */
+ int w_marko; /* Byte offset for "mark" */
+ char w_toprow; /* Origin 0 top row of window */
+ char w_ntrows; /* # of rows of text in window */
+ char w_force; /* If NZ, forcing row. */
+ char w_flag; /* Flags. */
+ LIST_HEAD(, undo_rec) w_undo; /* Undo actions list */
+ int w_undopos; /* Where we were during the */
+ /* last undo action. */
struct undo_rec *w_undoptr;
struct LINE *w_wrapline;
} MGWIN;
@@ -237,19 +237,19 @@ struct undo_rec;
* a pointer to the header line in "b_linep".
*/
typedef struct BUFFER {
- LIST b_list; /* buffer list pointer */
+ LIST b_list; /* buffer list pointer */
struct BUFFER *b_altb; /* Link to alternate buffer */
struct LINE *b_dotp; /* Link to "." LINE structure */
struct LINE *b_markp; /* ditto for mark */
struct LINE *b_linep; /* Link to the header LINE */
struct MAPS_S *b_modes[PBMODES]; /* buffer modes */
- int b_doto; /* Offset of "." in above LINE */
- int b_marko; /* ditto for the "mark" */
- short b_nmodes; /* number of non-fundamental modes */
- char b_nwnd; /* Count of windows on buffer */
- char b_flag; /* Flags */
- char b_fname[NFILEN];/* File name */
- struct fileinfo b_fi; /* File attributes */
+ int b_doto; /* Offset of "." in above LINE */
+ int b_marko; /* ditto for the "mark" */
+ short b_nmodes; /* number of non-fundamental modes */
+ char b_nwnd; /* Count of windows on buffer */
+ char b_flag; /* Flags */
+ char b_fname[NFILEN]; /* File name */
+ struct fileinfo b_fi; /* File attributes */
} BUFFER;
#define b_bufp b_list.l_p.x_bp
#define b_bname b_list.l_name
@@ -260,8 +260,7 @@ typedef struct BUFFER {
#define BFNOTAB 0x04 /* no tab mode */
#endif
#define BFOVERWRITE 0x08 /* overwrite mode */
-#define BFREADONLY 0x10 /* read only mode */
-
+#define BFREADONLY 0x10 /* read only mode */
/*
* This structure holds information about recent actions for the Undo command.
@@ -441,7 +440,7 @@ int ctrlg(int, int);
int quit(int, int);
/* ttyio.c */
-void panic(char *);
+void panic(char *);
/* cinfo.c */
char *keyname(char *, size_t, int);
diff --git a/usr.bin/mg/dir.c b/usr.bin/mg/dir.c
index 52407f72d00..715c8acca95 100644
--- a/usr.bin/mg/dir.c
+++ b/usr.bin/mg/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.11 2004/07/22 01:25:24 vincent Exp $ */
+/* $OpenBSD: dir.c,v 1.12 2005/04/03 02:09:28 db Exp $ */
/*
* Name: MG 2a
@@ -11,10 +11,10 @@
#ifndef NO_DIR
char *wdir;
-static char cwd[NFILEN];
+static char cwd[NFILEN];
/*
- * Initialize anything the directory management routines need
+ * Initialize anything the directory management routines need.
*/
void
dirinit(void)
@@ -27,7 +27,7 @@ dirinit(void)
}
/*
- * Change current working directory
+ * Change current working directory.
*/
/* ARGSUSED */
int
@@ -36,9 +36,9 @@ changedir(int f, int n)
char bufc[NPAT], *bufp;
if ((bufp = ereply("Change default directory: ", bufc, NPAT)) == NULL)
- return ABORT;
+ return (ABORT);
if (bufc[0] == '\0')
- (void)strlcpy(bufc, wdir, sizeof bufc);
+ (void)strlcpy(bufc, wdir, sizeof(bufc));
if (chdir(bufc) == -1) {
ewprintf("Can't change dir to %s", bufc);
return (FALSE);
@@ -51,13 +51,12 @@ changedir(int f, int n)
}
/*
- * Show current directory
+ * Show current directory.
*/
/* ARGSUSED */
int
showcwdir(int f, int n)
{
-
ewprintf("Current directory: %s", wdir);
return (TRUE);
}
diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c
index c6746b8bb7c..e08c41e71ed 100644
--- a/usr.bin/mg/dired.c
+++ b/usr.bin/mg/dired.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dired.c,v 1.14 2004/07/22 01:25:24 vincent Exp $ */
+/* $OpenBSD: dired.c,v 1.15 2005/04/03 02:09:28 db Exp $ */
/* dired module for mg 2a */
/* by Robert A. Larson */
@@ -30,71 +30,71 @@ static PF dired_cmds_1[] = {
rescan, /* ( */
rescan, /* ) */
rescan, /* * */
- d_create_directory, /* + */
+ d_create_directory /* + */
};
static PF dired_cmds_2[] = {
- rescan, /* a */
- rescan, /* b */
- rescan, /* c */
- rescan, /* d */
- d_findfile, /* e */
- d_findfile, /* f */
- rescan, /* g */
- rescan, /* h */
- rescan, /* i */
- rescan, /* j */
- rescan, /* k */
- rescan, /* l */
- rescan, /* m */
- forwline, /* n */
- d_ffotherwindow, /* o */
- rescan, /* p */
- rescan, /* q */
- rescan, /* r */
- rescan, /* s */
- rescan, /* t */
- rescan, /* u */
- d_findfile, /* v */
- rescan, /* w */
- d_expunge, /* x */
- rescan, /* y */
- rescan, /* z */
+ rescan, /* a */
+ rescan, /* b */
+ rescan, /* c */
+ rescan, /* d */
+ d_findfile, /* e */
+ d_findfile, /* f */
+ rescan, /* g */
+ rescan, /* h */
+ rescan, /* i */
+ rescan, /* j */
+ rescan, /* k */
+ rescan, /* l */
+ rescan, /* m */
+ forwline, /* n */
+ d_ffotherwindow, /* o */
+ rescan, /* p */
+ rescan, /* q */
+ rescan, /* r */
+ rescan, /* s */
+ rescan, /* t */
+ rescan, /* u */
+ d_findfile, /* v */
+ rescan, /* w */
+ d_expunge, /* x */
+ rescan, /* y */
+ rescan /* z */
};
static PF dired_cmds_3[] = {
- rescan, /* A */
- rescan, /* B */
- d_copy, /* C */
- d_del, /* D */
- rescan, /* E */
- rescan, /* F */
- rescan, /* G */
- rescan, /* H */
- rescan, /* I */
- rescan, /* J */
- rescan, /* K */
- rescan, /* L */
- rescan, /* M */
- rescan, /* N */
- rescan, /* O */
- rescan, /* P */
- rescan, /* Q */
- d_rename, /* R */
- rescan, /* S */
- rescan, /* T */
- rescan, /* U */
- d_findfile, /* V */
- rescan, /* W */
- d_expunge, /* X */
- rescan, /* Y */
- rescan, /* Z */
+ rescan, /* A */
+ rescan, /* B */
+ d_copy, /* C */
+ d_del, /* D */
+ rescan, /* E */
+ rescan, /* F */
+ rescan, /* G */
+ rescan, /* H */
+ rescan, /* I */
+ rescan, /* J */
+ rescan, /* K */
+ rescan, /* L */
+ rescan, /* M */
+ rescan, /* N */
+ rescan, /* O */
+ rescan, /* P */
+ rescan, /* Q */
+ d_rename, /* R */
+ rescan, /* S */
+ rescan, /* T */
+ rescan, /* U */
+ d_findfile, /* V */
+ rescan, /* W */
+ d_expunge, /* X */
+ rescan, /* Y */
+ rescan /* Z */
};
static PF dired_pf[] = {
- d_findfile, /* ^M */
- rescan, /* ^N */
- d_findfile, /* ^O */
+ d_findfile, /* ^M */
+ rescan, /* ^N */
+ d_findfile /* ^O */
};
static struct KEYMAPE (4 + IMAPEXT) diredmap = {
@@ -114,9 +114,9 @@ static struct KEYMAPE (4 + IMAPEXT) diredmap = {
int
dired(int f, int n)
{
- static int inited = 0;
- char dirname[NFILEN], *bufp;
- BUFFER *bp;
+ static int inited = 0;
+ char dirname[NFILEN], *bufp;
+ BUFFER *bp;
if (inited == 0) {
maps_add((KEYMAP *)&diredmap, "dired");
@@ -125,35 +125,35 @@ dired(int f, int n)
dirname[0] = '\0';
if ((bufp = eread("Dired: ", dirname, NFILEN, EFNEW | EFCR)) == NULL)
- return ABORT;
+ return (ABORT);
if ((bp = dired_(bufp)) == NULL)
- return FALSE;
+ return (FALSE);
bp->b_modes[0] = name_mode("fundamental");
bp->b_modes[1] = name_mode("dired");
bp->b_nmodes = 1;
curbp = bp;
- return showbuffer(bp, curwp, WFHARD | WFMODE);
+ return (showbuffer(bp, curwp, WFHARD | WFMODE));
}
/* ARGSUSED */
int
d_otherwindow(int f, int n)
{
- char dirname[NFILEN], *bufp;
+ char dirname[NFILEN], *bufp;
BUFFER *bp;
MGWIN *wp;
dirname[0] = '\0';
if ((bufp = eread("Dired other window: ", dirname, NFILEN,
EFNEW | EFCR)) == NULL)
- return ABORT;
+ return (ABORT);
if ((bp = dired_(bufp)) == NULL)
- return FALSE;
+ return (FALSE);
if ((wp = popbuf(bp)) == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
curwp = wp;
- return TRUE;
+ return (TRUE);
}
/* ARGSUSED */
@@ -161,7 +161,7 @@ int
d_del(int f, int n)
{
if (n < 0)
- return FALSE;
+ return (FALSE);
while (n--) {
if (llength(curwp->w_dotp) > 0)
lputc(curwp->w_dotp, 0, 'D');
@@ -170,7 +170,7 @@ d_del(int f, int n)
}
curwp->w_flag |= WFEDIT | WFMOVE;
curwp->w_doto = 0;
- return TRUE;
+ return (TRUE);
}
/* ARGSUSED */
@@ -178,7 +178,7 @@ int
d_undel(int f, int n)
{
if (n < 0)
- return d_undelbak(f, -n);
+ return (d_undelbak(f, -n));
while (n--) {
if (llength(curwp->w_dotp) > 0)
lputc(curwp->w_dotp, 0, ' ');
@@ -187,7 +187,7 @@ d_undel(int f, int n)
}
curwp->w_flag |= WFEDIT | WFMOVE;
curwp->w_doto = 0;
- return TRUE;
+ return (TRUE);
}
/* ARGSUSED */
@@ -195,7 +195,7 @@ int
d_undelbak(int f, int n)
{
if (n < 0)
- return d_undel(f, -n);
+ return (d_undel(f, -n));
while (n--) {
if (llength(curwp->w_dotp) > 0)
lputc(curwp->w_dotp, 0, ' ');
@@ -204,31 +204,31 @@ d_undelbak(int f, int n)
}
curwp->w_doto = 0;
curwp->w_flag |= WFEDIT | WFMOVE;
- return TRUE;
+ return (TRUE);
}
/* ARGSUSED */
int
d_findfile(int f, int n)
{
- BUFFER *bp;
- int s;
- char fname[NFILEN];
+ BUFFER *bp;
+ int s;
+ char fname[NFILEN];
- if ((s = d_makename(curwp->w_dotp, fname, sizeof fname)) == ABORT)
- return FALSE;
+ if ((s = d_makename(curwp->w_dotp, fname, sizeof(fname))) == ABORT)
+ return (FALSE);
if (s == TRUE)
bp = dired_(fname);
else
bp = findbuffer(fname);
if (bp == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
if (showbuffer(bp, curwp, WFHARD) != TRUE)
- return FALSE;
+ return (FALSE);
if (bp->b_fname[0] != 0)
- return TRUE;
- return readin(fname);
+ return (TRUE);
+ return (readin(fname));
}
/* ARGSUSED */
@@ -240,17 +240,17 @@ d_ffotherwindow(int f, int n)
BUFFER *bp;
MGWIN *wp;
- if ((s = d_makename(curwp->w_dotp, fname, sizeof fname)) == ABORT)
- return FALSE;
+ if ((s = d_makename(curwp->w_dotp, fname, sizeof(fname))) == ABORT)
+ return (FALSE);
if ((bp = (s ? dired_(fname) : findbuffer(fname))) == NULL)
- return FALSE;
+ return (FALSE);
if ((wp = popbuf(bp)) == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
curwp = wp;
if (bp->b_fname[0] != 0)
- return TRUE; /* never true for dired buffers */
- return readin(fname);
+ return (TRUE); /* never true for dired buffers */
+ return (readin(fname));
}
/* ARGSUSED */
@@ -258,27 +258,27 @@ int
d_expunge(int f, int n)
{
LINE *lp, *nlp;
- char fname[NFILEN];
+ char fname[NFILEN];
for (lp = lforw(curbp->b_linep); lp != curbp->b_linep; lp = nlp) {
nlp = lforw(lp);
if (llength(lp) && lgetc(lp, 0) == 'D') {
- switch (d_makename(lp, fname, sizeof fname)) {
+ switch (d_makename(lp, fname, sizeof(fname))) {
case ABORT:
ewprintf("Bad line in dired buffer");
- return FALSE;
+ return (FALSE);
case FALSE:
if (unlink(fname) < 0) {
ewprintf("Could not delete '%s'",
basename(fname));
- return FALSE;
+ return (FALSE);
}
break;
case TRUE:
if (rmdir(fname) < 0) {
ewprintf("Could not delete directory '%s'",
basename(fname));
- return FALSE;
+ return (FALSE);
}
break;
}
@@ -286,10 +286,9 @@ d_expunge(int f, int n)
curwp->w_flag |= WFHARD;
}
}
- return TRUE;
+ return (TRUE);
}
-
/* ARGSUSED */
int
d_copy(int f, int n)
@@ -299,20 +298,20 @@ d_copy(int f, int n)
int off;
BUFFER *bp;
- if (d_makename(curwp->w_dotp, frname, sizeof frname) != FALSE) {
+ if (d_makename(curwp->w_dotp, frname, sizeof(frname)) != FALSE) {
ewprintf("Not a file");
- return FALSE;
+ return (FALSE);
}
- off = strlcpy(toname, curbp->b_fname, sizeof toname);
- if (off >= sizeof toname - 1) { /* can't happen, really */
+ off = strlcpy(toname, curbp->b_fname, sizeof(toname));
+ if (off >= sizeof(toname) - 1) { /* can't happen, really */
ewprintf("too long directory name");
return (FALSE);
}
- if ((bufp = eread("Copy %s to: ", toname + off, sizeof toname - off,
+ if ((bufp = eread("Copy %s to: ", toname + off, sizeof(toname) - off,
EFNEW | EFCR, basename(frname))) == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return NULL;
+ return (NULL);
stat = (copy(frname, toname) >= 0) ? TRUE : FALSE;
if (stat != TRUE)
return (stat);
@@ -328,20 +327,20 @@ d_rename(int f, int n)
int stat, off;
BUFFER *bp;
- if (d_makename(curwp->w_dotp, frname, sizeof frname) != FALSE) {
+ if (d_makename(curwp->w_dotp, frname, sizeof(frname)) != FALSE) {
ewprintf("Not a file");
- return FALSE;
+ return (FALSE);
}
- off = strlcpy(toname, curbp->b_fname, sizeof toname);
- if (off >= sizeof toname - 1) { /* can't happen, really */
+ off = strlcpy(toname, curbp->b_fname, sizeof(toname));
+ if (off >= sizeof(toname) - 1) { /* can't happen, really */
ewprintf("too long directory name");
return (FALSE);
}
if ((bufp = eread("Rename %s to: ", toname + off,
- sizeof toname - off, EFNEW | EFCR, basename(frname))) == NULL)
- return ABORT;
+ sizeof(toname) - off, EFNEW | EFCR, basename(frname))) == NULL)
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
stat = (rename(frname, toname) >= 0) ? TRUE : FALSE;
if (stat != TRUE)
return (stat);
@@ -353,8 +352,8 @@ d_rename(int f, int n)
void
reaper(int signo __attribute__((unused)))
{
- pid_t ret;
- int status;
+ pid_t ret;
+ int status;
while ((ret = waitpid(-1, &status, WNOHANG)) >= 0)
;
@@ -366,25 +365,25 @@ reaper(int signo __attribute__((unused)))
int
d_shell_command(int f, int n)
{
- char command[512], fname[MAXPATHLEN], buf[BUFSIZ], *bufp, *cp;
- int infd, fds[2];
- pid_t pid;
- struct sigaction olda, newa;
- BUFFER *bp;
- MGWIN *wp;
- FILE *fin;
+ char command[512], fname[MAXPATHLEN], buf[BUFSIZ], *bufp, *cp;
+ int infd, fds[2];
+ pid_t pid;
+ struct sigaction olda, newa;
+ BUFFER *bp;
+ MGWIN *wp;
+ FILE *fin;
bp = bfind("*Shell Command Output*", TRUE);
if (bclear(bp) != TRUE)
return (ABORT);
- if (d_makename(curwp->w_dotp, fname, sizeof fname) != FALSE) {
+ if (d_makename(curwp->w_dotp, fname, sizeof(fname)) != FALSE) {
ewprintf("bad line");
return (ABORT);
}
command[0] = '\0';
- if ((bufp = eread("! on %s: ", command, sizeof command, 0,
+ if ((bufp = eread("! on %s: ", command, sizeof(command), 0,
basename(fname))) == NULL)
return (ABORT);
infd = open(fname, O_RDONLY);
@@ -424,7 +423,7 @@ d_shell_command(int f, int n)
fin = fdopen(fds[0], "r");
if (fin == NULL) /* "r" is surely a valid mode! */
panic("can't happen");
- while (fgets(buf, sizeof buf, fin) != NULL) {
+ while (fgets(buf, sizeof(buf), fin) != NULL) {
cp = strrchr(buf, '\n');
if (cp == NULL && !feof(fin)) { /* too long a line */
int c;
@@ -453,18 +452,18 @@ d_shell_command(int f, int n)
int
d_create_directory(int f, int n)
{
- char tocreate[MAXPATHLEN], *bufp;
- ssize_t off;
- BUFFER *bp;
+ char tocreate[MAXPATHLEN], *bufp;
+ ssize_t off;
+ BUFFER *bp;
- off = strlcpy(tocreate, curbp->b_fname, sizeof tocreate);
- if (off >= sizeof tocreate - 1)
+ off = strlcpy(tocreate, curbp->b_fname, sizeof(tocreate));
+ if (off >= sizeof(tocreate) - 1)
return (FALSE);
if ((bufp = ereply("Create directory: ", tocreate + off,
- sizeof tocreate - off)) == NULL)
+ sizeof(tocreate) - off)) == NULL)
return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
if (mkdir(tocreate, 0755) == -1) {
ewprintf("Creating directory: %s, %s", strerror(errno),
tocreate);
diff --git a/usr.bin/mg/display.c b/usr.bin/mg/display.c
index 354d4ca266b..6430cb7d812 100644
--- a/usr.bin/mg/display.c
+++ b/usr.bin/mg/display.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: display.c,v 1.20 2003/08/15 23:23:18 vincent Exp $ */
+/* $OpenBSD: display.c,v 1.21 2005/04/03 02:09:28 db Exp $ */
/*
* The functions in this file handle redisplay. The
@@ -12,8 +12,8 @@
* changes things around for memory mapped video. With
* both off, the terminal is a VT52.
*/
-#include "def.h"
-#include "kbd.h"
+#include "def.h"
+#include "kbd.h"
#include <ctype.h>
@@ -89,13 +89,13 @@ int ttrow = HUGE; /* Physical cursor row. */
int ttcol = HUGE; /* Physical cursor column. */
int tttop = HUGE; /* Top of scroll region. */
int ttbot = HUGE; /* Bottom of scroll region. */
-int lbound = 0; /* leftmost bound of the current line */
- /* being displayed */
+int lbound = 0; /* leftmost bound of the current */
+ /* line being displayed */
VIDEO **vscreen; /* Edge vector, virtual. */
VIDEO **pscreen; /* Edge vector, physical. */
-VIDEO *video; /* Actual screen data. */
-VIDEO blanks; /* Blank line image. */
+VIDEO *video; /* Actual screen data. */
+VIDEO blanks; /* Blank line image. */
#ifdef GOSLING
/*
@@ -115,10 +115,10 @@ SCORE *score; /* [NROW * NROW] */
int
vtresize(int force, int newrow, int newcol)
{
- int i;
- int rowchanged, colchanged;
- static int first_run = 1;
- VIDEO *vp;
+ int i;
+ int rowchanged, colchanged;
+ static int first_run = 1;
+ VIDEO *vp;
if (newrow < 1 || newcol < 1)
return (FALSE);
@@ -135,13 +135,11 @@ vtresize(int force, int newrow, int newcol)
} while (0)
/* No update needed */
- if (!first_run && !force && !rowchanged && !colchanged) {
+ if (!first_run && !force && !rowchanged && !colchanged)
return (TRUE);
- }
- if (first_run) {
+ if (first_run)
memset(&blanks, 0, sizeof(blanks));
- }
if (rowchanged || first_run) {
int vidstart;
@@ -155,7 +153,7 @@ vtresize(int force, int newrow, int newcol)
vidstart = 2 * (nrow - 1);
/*
- * We're shrinking, free some internal data
+ * We're shrinking, free some internal data.
*/
if (newrow < nrow) {
for (i = 2 * (newrow - 1); i < 2 * (nrow - 1); i++) {
@@ -172,7 +170,7 @@ vtresize(int force, int newrow, int newcol)
TRYREALLOC(video, (2 * (newrow - 1)) * sizeof(VIDEO));
/*
- * Zero-out the entries we just allocated
+ * Zero-out the entries we just allocated.
*/
for (i = vidstart; i < 2 * (newrow - 1); i++)
memset(&video[i], 0, sizeof(VIDEO));
@@ -247,7 +245,6 @@ vtinit(void)
void
vttidy(void)
{
-
ttcolor(CTEXT);
ttnowindow(); /* No scroll window. */
ttmove(nrow - 1, 0); /* Echo line. */
@@ -309,7 +306,7 @@ vtputc(int c)
else {
char bf[5];
- snprintf(bf, sizeof bf, "\\%o", c);
+ snprintf(bf, sizeof(bf), "\\%o", c);
vtputs(bf);
}
}
@@ -347,7 +344,6 @@ vtpute(int c)
}
}
-
/*
* Erase from the end of the software cursor to the end of the line on which
* the software cursor is located. The display routines will decide if a
@@ -379,13 +375,10 @@ update(void)
MGWIN *wp;
VIDEO *vp1;
VIDEO *vp2;
- int i, j;
- int c;
- int hflag;
- int currow;
- int curcol;
- int offs;
- int size;
+ int c, i, j;
+ int hflag;
+ int currow, curcol;
+ int offs, size;
if (typeahead())
return;
@@ -396,7 +389,7 @@ update(void)
wp = wp->w_wndp;
}
}
- hflag = FALSE; /* Not hard. */
+ hflag = FALSE; /* Not hard. */
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
/*
* Nothing to be done.
@@ -430,7 +423,7 @@ update(void)
i = wp->w_ntrows / 2; /* current center, no change */
/*
- * Find the line
+ * Find the line.
*/
lp = wp->w_dotp;
while (i != 0 && lback(lp) != wp->w_bufp->b_linep) {
@@ -473,7 +466,7 @@ update(void)
wp->w_flag = 0;
wp->w_force = 0;
}
- lp = curwp->w_linep; /* Cursor location. */
+ lp = curwp->w_linep; /* Cursor location. */
currow = curwp->w_toprow;
while (lp != curwp->w_dotp) {
++currow;
@@ -497,7 +490,7 @@ update(void)
else {
char bf[5];
- snprintf(bf, sizeof bf, "\\%o", c);
+ snprintf(bf, sizeof(bf), "\\%o", c);
curcol += strlen(bf);
}
}
@@ -509,8 +502,8 @@ update(void)
lbound = 0; /* not extended line */
/*
- * make sure no lines need to be de-extended because the cursor is no
- * longer on them
+ * Make sure no lines need to be de-extended because the cursor is no
+ * longer on them.
*/
wp = wheadp;
while (wp != NULL) {
@@ -541,9 +534,9 @@ update(void)
}
if (sgarbf != FALSE) { /* Screen is garbage. */
- sgarbf = FALSE; /* Erase-page clears */
- epresf = FALSE; /* the message area. */
- tttop = HUGE; /* Forget where you set */
+ sgarbf = FALSE; /* Erase-page clears. */
+ epresf = FALSE; /* The message area. */
+ tttop = HUGE; /* Forget where you set. */
ttbot = HUGE; /* scroll region. */
tthue = CNONE; /* Color unknown. */
ttmove(0, 0);
@@ -623,7 +616,6 @@ update(void)
void
ucopy(VIDEO *vvp, VIDEO *pvp)
{
-
vvp->v_flag &= ~VFCHG; /* Changes done. */
pvp->v_flag = vvp->v_flag; /* Update model. */
pvp->v_hash = vvp->v_hash;
@@ -635,13 +627,13 @@ ucopy(VIDEO *vvp, VIDEO *pvp)
/*
* updext: update the extended line which the cursor is currently on at a
* column greater than the terminal width. The line will be scrolled right or
- * left to let the user see where the cursor is
+ * left to let the user see where the cursor is.
*/
void
updext(int currow, int curcol)
{
LINE *lp; /* pointer to current line */
- int j; /* index into line */
+ int j; /* index into line */
if (ncol < 2)
return;
@@ -660,7 +652,7 @@ updext(int currow, int curcol)
lp = curwp->w_dotp; /* line to output */
for (j = 0; j < llength(lp); ++j) /* until the end-of-line */
vtpute(lgetc(lp, j));
- vteeol(); /* truncate the virtual line */
+ vteeol(); /* truncate the virtual line */
vscreen[currow]->v_text[0] = '$'; /* and put a '$' in column 1 */
}
@@ -681,7 +673,7 @@ uline(int row, VIDEO *vvp, VIDEO *pvp)
char *cp3;
char *cp4;
char *cp5;
- int nbflag;
+ int nbflag;
#ifdef MEMMAP
putline(row + 1, 1, &vvp->v_text[0]);
@@ -697,8 +689,8 @@ uline(int row, VIDEO *vvp, VIDEO *pvp)
#ifdef STANDOUT_GLITCH
cp1 = &vvp->v_text[magic_cookie_glitch > 0 ? magic_cookie_glitch : 0];
/*
- * the odd code for magic_cookie_glitch==0 is to avoid
- * putting the invisable glitch character on the next line.
+ * The odd code for magic_cookie_glitch==0 is to avoid
+ * putting the invisible glitch character on the next line.
* (Hazeltine executive 80 model 30)
*/
cp2 = &vvp->v_text[ncol - (magic_cookie_glitch >= 0 ? (magic_cookie_glitch != 0 ? magic_cookie_glitch : 1) : 0)];
@@ -715,7 +707,7 @@ uline(int row, VIDEO *vvp, VIDEO *pvp)
#endif
return;
}
- cp1 = &vvp->v_text[0]; /* Compute left match. */
+ cp1 = &vvp->v_text[0]; /* Compute left match. */
cp2 = &pvp->v_text[0];
while (cp1 != &vvp->v_text[ncol] && cp1[0] == cp2[0]) {
++cp1;
@@ -724,7 +716,7 @@ uline(int row, VIDEO *vvp, VIDEO *pvp)
if (cp1 == &vvp->v_text[ncol]) /* All equal. */
return;
nbflag = FALSE;
- cp3 = &vvp->v_text[ncol]; /* Compute right match. */
+ cp3 = &vvp->v_text[ncol]; /* Compute right match. */
cp4 = &pvp->v_text[ncol];
while (cp3[-1] == cp4[-1]) {
--cp3;
@@ -762,7 +754,7 @@ uline(int row, VIDEO *vvp, VIDEO *pvp)
/*
* Redisplay the mode line for the window pointed to by the "wp".
- * This is the only routine that has any idea of how the modeline is
+ * This is the only routine that has any idea of how the mode line is
* formatted. You can change the modeline format by hacking at this
* routine. Called by "update" any time there is a dirty window. Note
* that if STANDOUT_GLITCH is defined, first and last magic_cookie_glitch
@@ -773,7 +765,7 @@ modeline(MGWIN *wp)
{
int n;
BUFFER *bp;
- int mode;
+ int mode;
n = wp->w_toprow + wp->w_ntrows; /* Location. */
vscreen[n]->v_color = CMODE; /* Mode line color. */
@@ -800,7 +792,7 @@ modeline(MGWIN *wp)
n += vtputs("Mg: ");
if (bp->b_bname[0] != '\0')
n += vtputs(&(bp->b_bname[0]));
- while (n < 42) { /* Pad out with blanks */
+ while (n < 42) { /* Pad out with blanks. */
vtputc(' ');
++n;
}
@@ -815,13 +807,14 @@ modeline(MGWIN *wp)
}
vtputc(')');
++n;
- while (n < ncol) { /* Pad out. */
+ while (n < ncol) { /* Pad out. */
vtputc('-');
++n;
}
}
+
/*
- * output a string to the mode line, report how long it was.
+ * Output a string to the mode line, report how long it was.
*/
int
vtputs(const char *s)
@@ -832,7 +825,7 @@ vtputs(const char *s)
vtputc(*s++);
++n;
}
- return n;
+ return (n);
}
#ifdef GOSLING
@@ -847,9 +840,8 @@ vtputs(const char *s)
void
hash(VIDEO *vp)
{
- int i;
- int n;
- char *s;
+ int i, n;
+ char *s;
if ((vp->v_flag & VFHBAD) != 0) { /* Hash bad. */
s = &vp->v_text[ncol - 1];
@@ -896,13 +888,13 @@ hash(VIDEO *vp)
void
setscores(int offs, int size)
{
- SCORE *sp;
- SCORE *sp1;
- int tempcost;
- int bestcost;
- int j, i;
+ SCORE *sp;
+ SCORE *sp1;
VIDEO **vp, **pp;
VIDEO **vbase, **pbase;
+ int tempcost;
+ int bestcost;
+ int j, i;
vbase = &vscreen[offs - 1]; /* By hand CSE's. */
pbase = &pscreen[offs - 1];
@@ -983,12 +975,9 @@ setscores(int offs, int size)
void
traceback(int offs, int size, int i, int j)
{
- int itrace;
- int jtrace;
+ int itrace, jtrace;
int k;
- int ninsl;
- int ndraw;
- int ndell;
+ int ninsl, ndraw, ndell;
if (i == 0 && j == 0) /* End of update. */
return;
diff --git a/usr.bin/mg/echo.c b/usr.bin/mg/echo.c
index db300c0082e..40ff3eaeed0 100644
--- a/usr.bin/mg/echo.c
+++ b/usr.bin/mg/echo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: echo.c,v 1.30 2005/03/10 16:58:57 deraadt Exp $ */
+/* $OpenBSD: echo.c,v 1.31 2005/04/03 02:09:28 db Exp $ */
/*
* Echo line reading and writing.
*
@@ -17,13 +17,13 @@
#include <stdarg.h>
static char *veread(const char *, char *, size_t, int, va_list);
-static int complt(int, int, char *, size_t, int);
-static int complt_list(int, int, char *, int);
-static void eformat(const char *, va_list);
-static void eputi(int, int);
-static void eputl(long, int);
-static void eputs(const char *);
-static void eputc(char);
+static int complt(int, int, char *, size_t, int);
+static int complt_list(int, int, char *, int);
+static void eformat(const char *, va_list);
+static void eputi(int, int);
+static void eputl(long, int);
+static void eputs(const char *);
+static void eputc(char);
static LIST *copy_list(LIST *);
int epresf = FALSE; /* stuff in echo line flag */
@@ -54,17 +54,17 @@ eyorn(const char *sp)
#ifndef NO_MACRO
if (inmacro)
- return TRUE;
+ return (TRUE);
#endif /* !NO_MACRO */
ewprintf("%s? (y or n) ", sp);
for (;;) {
s = getkey(FALSE);
if (s == 'y' || s == 'Y')
- return TRUE;
+ return (TRUE);
if (s == 'n' || s == 'N')
- return FALSE;
+ return (FALSE);
if (s == CCHR('G'))
- return ctrlg(FFRAND, 1);
+ return (ctrlg(FFRAND, 1));
ewprintf("Please answer y or n. %s? (y or n) ", sp);
}
/* NOTREACHED */
@@ -72,7 +72,7 @@ eyorn(const char *sp)
/*
* Like eyorn, but for more important questions. User must type all of
- * "yes" or "no" and the trainling newline.
+ * "yes" or "no" and the trailing newline.
*/
int
eyesno(const char *sp)
@@ -81,12 +81,12 @@ eyesno(const char *sp)
#ifndef NO_MACRO
if (inmacro)
- return TRUE;
+ return (TRUE);
#endif /* !NO_MACRO */
rep = ereply("%s? (yes or no) ", buf, sizeof(buf), sp);
for (;;) {
if (rep == NULL)
- return ABORT;
+ return (ABORT);
if (rep[0] != '\0') {
#ifndef NO_MACRO
if (macrodef) {
@@ -101,11 +101,11 @@ eyesno(const char *sp)
(rep[1] == 'e' || rep[1] == 'E') &&
(rep[2] == 's' || rep[2] == 'S') &&
(rep[3] == '\0'))
- return TRUE;
+ return (TRUE);
if ((rep[0] == 'n' || rep[0] == 'N') &&
(rep[1] == 'o' || rep[0] == 'O') &&
(rep[2] == '\0'))
- return FALSE;
+ return (FALSE);
}
rep = ereply("Please answer yes or no. %s? (yes or no) ",
buf, sizeof(buf), sp);
@@ -129,7 +129,7 @@ ereply(const char *fmt, char *buf, size_t nbuf, ...)
va_start(ap, nbuf);
rep = veread(fmt, buf, nbuf, EFNEW | EFCR, ap);
va_end(ap);
- return rep;
+ return (rep);
}
/*
@@ -144,32 +144,31 @@ char *
eread(const char *fmt, char *buf, size_t nbuf, int flag, ...)
{
va_list ap;
- char *rep;
+ char *rep;
va_start(ap, flag);
rep = veread(fmt, buf, nbuf, flag, ap);
va_end(ap);
- return rep;
+ return (rep);
}
static char *
veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap)
{
int cpos, dynbuf = (buf == NULL);
- int i;
- int c;
+ int c, i;
#ifndef NO_MACRO
if (inmacro) {
if (dynbuf) {
if ((buf = malloc(maclcur->l_used + 1)) == NULL)
- return NULL;
+ return (NULL);
} else if (maclcur->l_used >= nbuf)
- return NULL;
+ return (NULL);
bcopy(maclcur->l_text, buf, maclcur->l_used);
buf[maclcur->l_used] = '\0';
maclcur = maclcur->l_fp;
- return buf;
+ return (buf);
}
#endif /* !NO_MACRO */
cpos = 0;
@@ -182,7 +181,7 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap)
eformat(fp, ap);
if ((flag & EFDEF) != 0) {
if (buf == NULL)
- return NULL;
+ return (NULL);
eputs(buf);
cpos += strlen(buf);
}
@@ -223,7 +222,7 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap)
/* XXX hackish */
if (dynbuf && buf != NULL)
free(buf);
- return falseval;
+ return (falseval);
}
lp->l_fp = maclcur->l_fp;
maclcur->l_fp = lp;
@@ -237,7 +236,7 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap)
eputc(CCHR('G'));
(void)ctrlg(FFRAND, 0);
ttflush();
- return NULL;
+ return (NULL);
case CCHR('H'): /* rubout, erase */
case CCHR('?'):
if (cpos != 0) {
@@ -310,7 +309,7 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap)
if ((newp = realloc(buf, newsize)) == NULL) {
ewprintf("Out of memory");
free(buf);
- return NULL;
+ return (NULL);
}
buf = newp;
nbuf = newsize;
@@ -323,11 +322,11 @@ veread(const char *fp, char *buf, size_t nbuf, int flag, va_list ap)
}
}
done:
- return buf;
+ return (buf);
}
/*
- * do completion on a list of objects.
+ * Do completion on a list of objects.
*/
static int
complt(int flags, int c, char *buf, size_t nbuf, int cpos)
@@ -392,17 +391,17 @@ complt(int flags, int c, char *buf, size_t nbuf, int cpos)
ttflush();
free_file_list(wholelist);
if (nxtra < 0 && c != CCHR('M'))
- return 0;
- return nxtra;
+ return (0);
+ return (nxtra);
}
/*
- * wholelist is null if we are doing buffers. want to free lists
+ * wholelist is NULL if we are doing buffers. Want to free lists
* that were created for us, but not the buffer list!
*/
free_file_list(wholelist);
- /* Set up backspaces, etc., being mindful of echo line limit */
+ /* Set up backspaces, etc., being mindful of echo line limit. */
msglen = strlen(msg);
nshown = (ttcol + msglen + 2 > ncol) ?
ncol - ttcol - 2 : msglen;
@@ -417,11 +416,11 @@ complt(int flags, int c, char *buf, size_t nbuf, int cpos)
ttcol -= (i = nshown); /* update ttcol on BS's */
while (i--)
ttputc('\b'); /* update ttcol again! */
- return 0;
+ return (0);
}
/*
- * do completion on a list of objects, listing instead of completing
+ * Do completion on a list of objects, listing instead of completing.
*/
static int
complt_list(int flags, int c, char *buf, int cpos)
@@ -442,13 +441,13 @@ complt_list(int flags, int c, char *buf, int cpos)
ttflush();
- /* the results are put into a help buffer */
+ /* The results are put into a help buffer. */
bp = bfind("*help*", TRUE);
if (bclear(bp) == FALSE)
- return FALSE;
+ return (FALSE);
/*
- * first get the list of objects. This list may contain only
+ * First get the list of objects. This list may contain only
* the ones that complete what has been typed, or may be the
* whole list of all objects of this type. They are filtered
* later in any case. Set wholelist if the list has been
@@ -477,7 +476,6 @@ complt_list(int flags, int c, char *buf, int cpos)
} else
panic("broken complt call: flags");
-
/*
* Sort the list, since users expect to see it in alphabetic
* order.
@@ -517,17 +515,17 @@ complt_list(int flags, int c, char *buf, int cpos)
maxwidth += 1 - preflen;
/*
- * Now do the display. objects are written into linebuf until
+ * Now do the display. Objects are written into linebuf until
* it fills, and then put into the help buffer.
*/
linesize = MAX(ncol, maxwidth) + 1;
if ((linebuf = malloc(linesize)) == NULL)
- return FALSE;
+ return (FALSE);
width = 0;
/*
* We're going to strlcat() into the buffer, so it has to be
- * NUL terminated
+ * NUL terminated.
*/
linebuf[0] = '\0';
for (lh2 = lh; lh2 != NULL; lh2 = lh2->l_next) {
@@ -570,7 +568,7 @@ complt_list(int flags, int c, char *buf, int cpos)
ttmove(oldrow, oldcol); /* update leaves cursor in arbitrary place */
ttcolor(oldhue); /* with arbitrary color */
ttflush();
- return 0;
+ return (0);
}
/*
@@ -667,7 +665,7 @@ eformat(const char *fp, va_list ap)
break;
case 'p':
- snprintf(tmp, sizeof tmp, "%p",
+ snprintf(tmp, sizeof(tmp), "%p",
va_arg(ap, void *));
eputs(tmp);
break;
diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c
index 81d28993e07..5280fc423c0 100644
--- a/usr.bin/mg/extend.c
+++ b/usr.bin/mg/extend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: extend.c,v 1.32 2005/03/10 16:58:57 deraadt Exp $ */
+/* $OpenBSD: extend.c,v 1.33 2005/04/03 02:09:28 db Exp $ */
/*
* Extended (M-X) commands, rebinding, and startup file processing.
@@ -30,7 +30,7 @@ static char *parsetoken(char *);
static int bindkey(KEYMAP **, const char *, KCHAR *, int);
/*
- * Insert a string, mainly for use from macros (created by selfinsert)
+ * Insert a string, mainly for use from macros (created by selfinsert).
*/
/* ARGSUSED */
int
@@ -45,35 +45,35 @@ insert(int f, int n)
for (count = 0; count < maclcur->l_used; count++) {
if ((((c = maclcur->l_text[count]) == '\n')
? lnewline() : linsert(1, c)) != TRUE)
- return FALSE;
+ return (FALSE);
}
}
maclcur = maclcur->l_fp;
- return TRUE;
+ return (TRUE);
}
if (n == 1)
/* CFINS means selfinsert can tack on the end */
thisflag |= CFINS;
#endif /* !NO_MACRO */
if ((bufp = eread("Insert: ", buf, sizeof(buf), EFNEW)) == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
while (--n >= 0) {
cp = buf;
while (*cp) {
if (((*cp == '\n') ? lnewline() : linsert(1, *cp))
!= TRUE)
- return FALSE;
+ return (FALSE);
cp++;
}
}
- return TRUE;
+ return (TRUE);
}
/*
* Bind a key to a function. Cases range from the trivial (replacing an
- * existing binding) to the extremly complex (creating a new prefix in a
+ * existing binding) to the extremely complex (creating a new prefix in a
* map_element that already has one, so the map_element must be split,
* but the keymap doesn't have enough room for another map_element, so
* the keymap is reallocated). No attempt is made to reclaim space no
@@ -110,7 +110,7 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
if ((pfp = (PF *)malloc((c - ele->k_base + 1) *
sizeof(PF))) == NULL) {
ewprintf("Out of memory");
- return FALSE;
+ return (FALSE);
}
nold = ele->k_num - ele->k_base + 1;
for (i = 0; i < nold; i++)
@@ -124,7 +124,7 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
if ((pfp = (PF *)malloc((ele->k_num - c + 1) *
sizeof(PF))) == NULL) {
ewprintf("Out of memory");
- return FALSE;
+ return (FALSE);
}
nold = ele->k_num - ele->k_base + 1;
for (i = 0; i < nold; i++)
@@ -137,12 +137,12 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
} else {
if (curmap->map_num >= curmap->map_max) {
if ((newmap = reallocmap(curmap)) == NULL)
- return FALSE;
+ return (FALSE);
curmap = newmap;
}
if ((pfp = malloc(sizeof(PF))) == NULL) {
ewprintf("Out of memory");
- return FALSE;
+ return (FALSE);
}
pfp[0] = funct;
for (mep = &curmap->map_element[curmap->map_num];
@@ -167,7 +167,7 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
ewprintf("Out of memory");
ele->k_funcp[c - ele->k_base] =
curmap->map_default;
- return FALSE;
+ return (FALSE);
}
mp->map_num = 0;
mp->map_max = MAPINIT;
@@ -180,7 +180,7 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
if (ele->k_funcp[n1] == funct && (funct != NULL ||
pref_map == NULL || pref_map == ele->k_prefmap))
/* no change */
- return TRUE;
+ return (TRUE);
if (funct != NULL || ele->k_prefmap == NULL) {
if (ele->k_funcp[n1] == NULL)
ele->k_prefmap = NULL;
@@ -196,7 +196,7 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
ewprintf("Out of memory");
ele->k_funcp[c - ele->k_base] =
curmap->map_default;
- return FALSE;
+ return (FALSE);
}
mp->map_num = 0;
mp->map_max = MAPINIT;
@@ -215,11 +215,11 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
n2 &= ele->k_funcp[i] != NULL;
if (curmap->map_num >= curmap->map_max &&
(curmap = reallocmap(curmap)) == NULL)
- return FALSE;
+ return (FALSE);
if ((pfp = malloc((ele->k_num - c + !n2) *
sizeof(PF))) == NULL) {
ewprintf("Out of memory");
- return FALSE;
+ return (FALSE);
}
ele->k_funcp[n1] = NULL;
for (i = n1 + n2; i <= ele->k_num - ele->k_base; i++)
@@ -243,7 +243,7 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
ewprintf("Out of memory");
ele->k_funcp[c - ele->k_base] =
curmap->map_default;
- return FALSE;
+ return (FALSE);
}
mp->map_num = 0;
mp->map_max = MAPINIT;
@@ -253,7 +253,7 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
ele->k_prefmap = pref_map;
}
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -262,7 +262,7 @@ remap(KEYMAP *curmap, /* pointer to the map being changed */
static KEYMAP *
reallocmap(KEYMAP *curmap)
{
- MAPS *mps;
+ MAPS *mps;
KEYMAP *mp;
int i;
@@ -270,7 +270,7 @@ reallocmap(KEYMAP *curmap)
(curmap->map_max + (MAPGROW - 1)) *
sizeof(MAP_ELEMENT)))) == NULL) {
ewprintf("Out of memory");
- return NULL;
+ return (NULL);
}
mp->map_num = curmap->map_num;
mp->map_max = curmap->map_max + MAPGROW;
@@ -288,7 +288,7 @@ reallocmap(KEYMAP *curmap)
fixmap(curmap, mp, mps->p_map);
}
ele = &mp->map_element[ele - &curmap->map_element[0]];
- return mp;
+ return (mp);
}
/*
@@ -310,7 +310,7 @@ fixmap(KEYMAP *curmap, KEYMAP *mp, KEYMAP *mt)
}
/*
- * do the input for local-set-key, global-set-key and define-key
+ * Do the input for local-set-key, global-set-key and define-key
* then call remap to do the work.
*/
static int
@@ -318,8 +318,7 @@ dobind(KEYMAP *curmap, const char *p, int unbind)
{
KEYMAP *pref_map = NULL;
PF funct;
- char prompt[80], *bufp;
- char *pep;
+ char prompt[80], *bufp, *pep;
int c, s, n;
#ifndef NO_MACRO
@@ -329,7 +328,7 @@ dobind(KEYMAP *curmap, const char *p, int unbind)
* Would not work for function keys in any case.
*/
ewprintf("Can't rebind key in macro");
- return FALSE;
+ return (FALSE);
}
#ifndef NO_STARTUP
if (inmacro) {
@@ -338,7 +337,7 @@ dobind(KEYMAP *curmap, const char *p, int unbind)
!= NULL) {
if (remap(curmap, c, NULL, NULL)
!= TRUE)
- return FALSE;
+ return (FALSE);
}
}
(void)doscan(curmap, c = maclcur->l_text[s], NULL);
@@ -346,9 +345,9 @@ dobind(KEYMAP *curmap, const char *p, int unbind)
} else {
#endif /* !NO_STARTUP */
#endif /* !NO_MACRO */
- n = strlcpy(prompt, p, sizeof prompt);
- if (n >= sizeof prompt)
- n = sizeof prompt - 1;
+ n = strlcpy(prompt, p, sizeof(prompt));
+ if (n >= sizeof(prompt))
+ n = sizeof(prompt) - 1;
pep = prompt + n;
for (;;) {
ewprintf("%s", prompt);
@@ -368,16 +367,16 @@ dobind(KEYMAP *curmap, const char *p, int unbind)
else {
if ((bufp = eread("%s to command: ", prompt, 80, EFFUNC | EFNEW,
prompt)) == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
if (((funct = name_function(prompt)) == NULL) ?
(pref_map = name_map(prompt)) == NULL : funct == NULL) {
ewprintf("[No match]");
- return FALSE;
+ return (FALSE);
}
}
- return remap(curmap, c, funct, pref_map);
+ return (remap(curmap, c, funct, pref_map));
}
/*
@@ -400,12 +399,12 @@ bindkey(KEYMAP **mapp, const char *fname, KCHAR *keys, int kcount)
else if (((funct = name_function(fname)) == NULL) ?
(pref_map = name_map(fname)) == NULL : funct == NULL) {
ewprintf("[No match: %s]", fname);
- return FALSE;
+ return (FALSE);
}
while (--kcount) {
if (doscan(curmap, c = *keys++, &curmap) != NULL) {
if (remap(curmap, c, NULL, NULL) != TRUE)
- return FALSE;
+ return (FALSE);
/*
* XXX - Bizzarreness. remap creates an empty KEYMAP
* that the last key is supposed to point to.
@@ -414,7 +413,7 @@ bindkey(KEYMAP **mapp, const char *fname, KCHAR *keys, int kcount)
}
}
(void)doscan(curmap, c = *keys, NULL);
- return remap(curmap, c, funct, pref_map);
+ return (remap(curmap, c, funct, pref_map));
}
#ifdef FKEYS
@@ -465,7 +464,7 @@ dobindkey(KEYMAP *map, const char *func, const char *str)
int
bindtokey(int f, int n)
{
- return dobind(fundamental_map, "Global set key: ", FALSE);
+ return (dobind(fundamental_map, "Global set key: ", FALSE));
}
/*
@@ -475,8 +474,8 @@ bindtokey(int f, int n)
int
localbind(int f, int n)
{
- return dobind(curbp->b_modes[curbp->b_nmodes]->p_map,
- "Local set key: ", FALSE);
+ return (dobind(curbp->b_modes[curbp->b_nmodes]->p_map,
+ "Local set key: ", FALSE));
}
/*
@@ -486,36 +485,36 @@ localbind(int f, int n)
int
define_key(int f, int n)
{
- static char buf[48];
- char tmp[32], *bufp;
- KEYMAP *mp;
+ static char buf[48];
+ char tmp[32], *bufp;
+ KEYMAP *mp;
- strlcpy(buf, "Define key map: ", sizeof buf);
- if ((bufp = eread(buf, tmp, sizeof tmp, EFNEW)) == NULL)
- return ABORT;
+ strlcpy(buf, "Define key map: ", sizeof(buf));
+ if ((bufp = eread(buf, tmp, sizeof(tmp), EFNEW)) == NULL)
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
- strlcat(buf, tmp, sizeof buf);
+ return (FALSE);
+ strlcat(buf, tmp, sizeof(buf));
if ((mp = name_map(tmp)) == NULL) {
ewprintf("Unknown map %s", tmp);
- return FALSE;
+ return (FALSE);
}
- strlcat(buf, "key: ", sizeof buf);
+ strlcat(buf, "key: ", sizeof(buf));
- return dobind(mp, buf, FALSE);
+ return (dobind(mp, buf, FALSE));
}
int
unbindtokey(int f, int n)
{
- return dobind(fundamental_map, "Global unset key: ", TRUE);
+ return (dobind(fundamental_map, "Global unset key: ", TRUE));
}
int
localunbind(int f, int n)
{
- return dobind(curbp->b_modes[curbp->b_nmodes]->p_map,
- "Local unset key: ", TRUE);
+ return (dobind(curbp->b_modes[curbp->b_nmodes]->p_map,
+ "Local unset key: ", TRUE));
}
/*
@@ -535,9 +534,9 @@ extend(int f, int n)
else
bufp = eread("%d M-x ", xname, NXNAME, EFNEW | EFFUNC, n);
if (bufp == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
if ((funct = name_function(bufp)) != NULL) {
#ifndef NO_MACRO
if (macrodef) {
@@ -548,10 +547,10 @@ extend(int f, int n)
free((char *)lp);
}
#endif /* !NO_MACRO */
- return (*funct)(f, n);
+ return ((*funct)(f, n));
}
ewprintf("[No match]");
- return FALSE;
+ return (FALSE);
}
#ifndef NO_STARTUP
@@ -580,10 +579,10 @@ evalexpr(int f, int n)
char exbuf[128], *bufp;
if ((bufp = ereply("Eval: ", exbuf, sizeof(exbuf))) == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
- return excline(exbuf);
+ return (FALSE);
+ return (excline(exbuf));
}
/*
@@ -601,15 +600,15 @@ evalbuffer(int f, int n)
for (lp = lforw(bp->b_linep); lp != bp->b_linep; lp = lforw(lp)) {
if (llength(lp) >= 128)
- return FALSE;
+ return (FALSE);
(void)strncpy(excbuf, ltext(lp), llength(lp));
/* make sure it's terminated */
excbuf[llength(lp)] = '\0';
if ((s = excline(excbuf)) != TRUE)
- return s;
+ return (s);
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -623,10 +622,10 @@ evalfile(int f, int n)
char fname[NFILEN], *bufp;
if ((bufp = ereply("Load file: ", fname, NFILEN)) == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
- return load(fname);
+ return (FALSE);
+ return (load(fname));
}
/*
@@ -641,10 +640,10 @@ load(const char *fname)
if ((fname = adjustname(fname)) == NULL)
/* just to be careful */
- return FALSE;
+ return (FALSE);
if (ffropen(fname, NULL) != FIOSUC)
- return FALSE;
+ return (FALSE);
line = 0;
while ((s = ffgetline(excbuf, sizeof(excbuf) - 1, &nbytes)) == FIOSUC) {
@@ -659,13 +658,13 @@ load(const char *fname)
(void)ffclose(NULL);
excbuf[nbytes] = '\0';
if (s != FIOEOF || (nbytes && excline(excbuf) != TRUE))
- return FALSE;
- return TRUE;
+ return (FALSE);
+ return (TRUE);
}
/*
- * excline - run a line from a load file or eval-expression. if FKEYS is
- * defined, duplicate functionallity of dobind so function key values don't
+ * excline - run a line from a load file or eval-expression. If FKEYS is
+ * defined, duplicate functionality of dobind so function key values don't
* have to fit in type char.
*/
int
@@ -693,13 +692,13 @@ excline(char *line)
if (macrodef || inmacro) {
ewprintf("Not now!");
- return FALSE;
+ return (FALSE);
}
f = 0;
n = 1;
funcp = skipwhite(line);
if (*funcp == '\0')
- return TRUE; /* No error on blank lines */
+ return (TRUE); /* No error on blank lines */
line = parsetoken(funcp);
if (*line != '\0') {
*line++ = '\0';
@@ -713,14 +712,14 @@ excline(char *line)
f = FFARG;
nl = strtol(argp, &tmp, 10);
if (*tmp != '\0')
- return FALSE;
+ return (FALSE);
if (nl >= INT_MAX || nl <= INT_MIN)
- return FALSE;
+ return (FALSE);
n = (int)nl;
}
if ((fp = name_function(funcp)) == NULL) {
ewprintf("Unknown function: %s", funcp);
- return FALSE;
+ return (FALSE);
}
#ifdef FKEYS
if (fp == bindtokey || fp == unbindtokey) {
@@ -736,7 +735,7 @@ excline(char *line)
#endif /* FKEYS */
/* Pack away all the args now... */
if ((np = lalloc(0)) == FALSE)
- return FALSE;
+ return (FALSE);
np->l_fp = np->l_bp = maclcur = np;
while (*line != '\0') {
argp = skipwhite(line);
@@ -771,9 +770,8 @@ excline(char *line)
}
lp->l_used = 0;
#ifdef FKEYS
- } else {
+ } else
key.k_count = 0;
- }
#endif /* FKEYS */
while (*argp != '"' && *argp != '\0') {
if (*argp != '\\')
@@ -890,10 +888,9 @@ excline(char *line)
lp->l_text[lp->l_used] = '\0';
status = bindkey(&curmap, lp->l_text, key.k_chars,
key.k_count);
- } else {
+ } else
status = bindkey(&curmap, NULL, key.k_chars,
key.k_count);
- }
break;
case BINDNO:
#endif /* FKEYS */
@@ -912,7 +909,7 @@ cleanup:
lp = np;
}
free((char *)lp);
- return status;
+ return (status);
}
/*
@@ -925,7 +922,7 @@ skipwhite(char *s)
s++;
if (*s == ';')
*s = '\0';
- return s;
+ return (s);
}
static char *
@@ -945,6 +942,6 @@ parsetoken(char *s)
if (*s == '\\')
++s;
} while (*++s != '"' && *s != '\0');
- return s;
+ return (s);
}
#endif /* !NO_STARTUP */
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index 2aab0dbb51e..5a168644f0a 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.31 2005/03/10 18:27:47 henning Exp $ */
+/* $OpenBSD: file.c,v 1.32 2005/04/03 02:09:28 db Exp $ */
/*
* File commands.
@@ -19,13 +19,13 @@ fileinsert(int f, int n)
bufp = eread("Insert file: ", fname, NFILEN, EFNEW | EFCR | EFFILE);
if (bufp == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
adjf = adjustname(bufp);
if (adjf == NULL)
return (FALSE);
- return insertfile(adjf, NULL, FALSE);
+ return (insertfile(adjf, NULL, FALSE));
}
/*
@@ -43,25 +43,25 @@ filevisit(int f, int n)
bufp = eread("Find file: ", fname, NFILEN, EFNEW | EFCR | EFFILE);
if (bufp == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
adjf = adjustname(fname);
if (adjf == NULL)
return (FALSE);
if ((bp = findbuffer(adjf)) == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
if (showbuffer(bp, curwp, WFHARD) != TRUE)
- return FALSE;
+ return (FALSE);
if (bp->b_fname[0] == 0) {
int status;
if ((status = readin(adjf)) != TRUE)
killbuffer(bp);
- return status;
+ return (status);
}
- return TRUE;
+ return (TRUE);
}
int
@@ -75,6 +75,7 @@ filevisitro(int f, int n)
curbp->b_flag |= BFREADONLY;
return (TRUE);
}
+
/*
* Pop to a file in the other window. Same as the last function, but uses
* popbuf instead of showbuffer.
@@ -89,16 +90,16 @@ poptofile(int f, int n)
if ((bufp = eread("Find file in other window: ", fname, NFILEN,
EFNEW | EFCR | EFFILE)) == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
adjf = adjustname(fname);
if (adjf == NULL)
return (FALSE);
if ((bp = findbuffer(adjf)) == NULL)
- return FALSE;
+ return (FALSE);
if ((wp = popbuf(bp)) == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
curwp = wp;
if (bp->b_fname[0] == 0) {
@@ -106,13 +107,13 @@ poptofile(int f, int n)
if ((status = readin(adjf)) != TRUE)
killbuffer(bp);
- return status;
+ return (status);
}
- return TRUE;
+ return (TRUE);
}
/*
- * given a file name, either find the buffer it uses, or create a new
+ * Given a file name, either find the buffer it uses, or create a new
* empty buffer to put it in.
*/
BUFFER *
@@ -124,14 +125,14 @@ findbuffer(char *fname)
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
if (strcmp(bp->b_fname, fname) == 0)
- return bp;
+ return (bp);
}
i = strlcpy(bname, basename(fname), sizeof(bname));
remain = sizeof(bname) - i;
for (count = 2; bfind(bname, FALSE) != NULL; count++)
snprintf(&bname[i], remain, "<%d>", count);
- return bfind(bname, TRUE);
+ return (bfind(bname, TRUE));
}
/*
@@ -149,10 +150,10 @@ readin(char *fname)
/* might be old */
if (bclear(curbp) != TRUE)
- return TRUE;
+ return (TRUE);
if ((status = insertfile(fname, fname, TRUE)) != TRUE) {
ewprintf("File is not readable: %s", fname);
- return FALSE;
+ return (FALSE);
}
/*
@@ -175,7 +176,7 @@ readin(char *fname)
}
}
- /* We need to set the READONLY flag after we insert the file */
+ /* We need to set the READONLY flag after we insert the file. */
if (access(fname, W_OK) && errno != ENOENT)
curbp->b_flag |= BFREADONLY;
else
@@ -184,7 +185,7 @@ readin(char *fname)
if (startrow)
gotoline(FFARG, startrow);
- return status;
+ return (status);
}
/*
@@ -198,7 +199,7 @@ readin(char *fname)
* Insert a file in the current buffer, after dot. Set mark at the end of
* the text inserted; point at the beginning. Return a standard status.
* Print a summary (lines read, error message) out as well. Unless the
- * NO_BACKUP conditional is set, this routine also does the read end of
+ * NO_BACKUP conditional is set, this routine also does the read end of
* backup processing. The BFBAK flag, if set in a buffer, says that a
* backup should be taken. It is set when a file is read in, but not on
* a new file. (You don't need to make a backup copy of nothing.)
@@ -341,7 +342,7 @@ endoffile:
bp->b_flag |= BFCHG;
#endif /* !NO_BACKUP */
/*
- * if the insert was at the end of buffer, set lp1 to the end of
+ * If the insert was at the end of buffer, set lp1 to the end of
* buffer line, and lp2 to the beginning of the newly inserted text.
* (Otherwise lp2 is set to NULL.) This is used below to set
* pointers in other windows correctly if they are also at the end of
@@ -372,7 +373,7 @@ out: lp2 = NULL;
undo_enable(x);
/* return false if error */
- return s != FIOERR;
+ return (s != FIOERR);
}
/*
@@ -391,9 +392,9 @@ filewrite(int f, int n)
if ((bufp = eread("Write file: ", fname, NFILEN,
EFNEW | EFCR | EFFILE)) == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
adjfname = adjustname(fname);
if (adjfname == NULL)
@@ -417,7 +418,7 @@ filewrite(int f, int n)
#endif /* !NO_BACKUP */
upmodes(curbp);
}
- return s;
+ return (s);
}
/*
@@ -434,7 +435,7 @@ static int makebackup = MAKEBACKUP;
int
filesave(int f, int n)
{
- return buffsave(curbp);
+ return (buffsave(curbp));
}
/*
@@ -453,7 +454,7 @@ buffsave(BUFFER *bp)
/* return, no changes */
if ((bp->b_flag & BFCHG) == 0) {
ewprintf("(No changes need to be saved)");
- return TRUE;
+ return (TRUE);
}
/* must have a name */
@@ -467,11 +468,11 @@ buffsave(BUFFER *bp)
s = fbackupfile(bp->b_fname);
/* hard error */
if (s == ABORT)
- return FALSE;
+ return (FALSE);
/* softer error */
if (s == FALSE &&
(s = eyesno("Backup error, save anyway")) != TRUE)
- return s;
+ return (s);
}
#endif /* !NO_BACKUP */
if ((s = writeout(bp, bp->b_fname)) == TRUE) {
@@ -482,7 +483,7 @@ buffsave(BUFFER *bp)
#endif /* !NO_BACKUP */
upmodes(bp);
}
- return s;
+ return (s);
}
#ifndef NO_BACKUP
@@ -502,7 +503,7 @@ makebkfile(int f, int n)
else
makebackup = !makebackup;
ewprintf("Backup files %sabled", makebackup ? "en" : "dis");
- return TRUE;
+ return (TRUE);
}
#endif /* !NO_BACKUP */
@@ -537,7 +538,7 @@ writeout(BUFFER *bp, char *fn)
} else
/* ignore close error if it is a write error */
(void)ffclose(bp);
- return s == FIOSUC;
+ return (s == FIOSUC);
}
/*
diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c
index e9dd02c6c64..5d6a101fbdd 100644
--- a/usr.bin/mg/fileio.c
+++ b/usr.bin/mg/fileio.c
@@ -1,11 +1,9 @@
-/* $OpenBSD: fileio.c,v 1.48 2005/03/10 16:58:57 deraadt Exp $ */
+/* $OpenBSD: fileio.c,v 1.49 2005/04/03 02:09:28 db Exp $ */
/*
* POSIX fileio.c
*/
-#include "def.h"
-
-static FILE *ffp;
+#include "def.h"
#include <sys/types.h>
#include <limits.h>
@@ -16,6 +14,8 @@ static FILE *ffp;
#include <unistd.h>
#include <ctype.h>
+static FILE *ffp;
+
/*
* Open a file for reading.
*/
@@ -40,14 +40,12 @@ ffropen(const char *fn, BUFFER *bp)
/*
* Open a file for writing.
- * Return TRUE if all is well, and
- * FALSE on error (cannot create).
*/
int
ffwopen(const char *fn, BUFFER *bp)
{
- int fd;
- mode_t mode = DEFFILEMODE;
+ int fd;
+ mode_t mode = DEFFILEMODE;
if (bp && bp->b_fi.fi_mode)
mode = bp->b_fi.fi_mode & 07777;
@@ -87,7 +85,6 @@ ffwopen(const char *fn, BUFFER *bp)
int
ffclose(BUFFER *bp)
{
-
(void) fclose(ffp);
return (FIOSUC);
}
@@ -105,7 +102,7 @@ ffputbuf(BUFFER *bp)
for (lp = lforw(lpend); lp != lpend; lp = lforw(lp)) {
if (fwrite(ltext(lp), 1, llength(lp), ffp) != llength(lp)) {
ewprintf("Write I/O error");
- return FIOERR;
+ return (FIOERR);
}
if (lforw(lp) != lpend) /* no implied \n on last line */
putc('\n', ffp);
@@ -137,14 +134,14 @@ ffgetline(char *buf, int nbuf, int *nbytes)
while ((c = getc(ffp)) != EOF && c != '\n') {
buf[i++] = c;
if (i >= nbuf)
- return FIOLONG;
+ return (FIOLONG);
}
if (c == EOF && ferror(ffp) != FALSE) {
ewprintf("File read error");
- return FIOERR;
+ return (FIOERR);
}
*nbytes = i;
- return c == EOF ? FIOEOF : FIOSUC;
+ return (c == EOF ? FIOEOF : FIOSUC);
}
#ifndef NO_BACKUP
@@ -159,10 +156,10 @@ ffgetline(char *buf, int nbuf, int *nbytes)
int
fbackupfile(const char *fn)
{
- struct stat sb;
- int from, to, serrno;
- ssize_t nread;
- char buf[BUFSIZ];
+ struct stat sb;
+ int from, to, serrno;
+ ssize_t nread;
+ char buf[BUFSIZ];
char *nname, *tname;
if (stat(fn, &sb) == -1) {
@@ -244,10 +241,10 @@ extern char *wdir;
char *
adjustname(const char *fn)
{
- static char fnb[MAXPATHLEN];
- const char *cp;
- char user[LOGIN_NAME_MAX + 1], path[MAXPATHLEN];
- int len;
+ static char fnb[MAXPATHLEN];
+ const char *cp;
+ char user[LOGIN_NAME_MAX + 1], path[MAXPATHLEN];
+ int len;
path[0] = '\0';
/* first handle tilde expansion */
@@ -263,7 +260,7 @@ adjustname(const char *fn)
return (NULL);
}
if (cp == &fn[1]) /* ~/ */
- strlcpy(user, getlogin(), sizeof user);
+ strlcpy(user, getlogin(), sizeof(user));
else
strlcpy(user, &fn[1], cp - &fn[1] + 1);
pw = getpwnam(user);
@@ -271,7 +268,7 @@ adjustname(const char *fn)
ewprintf("unknown user %s", user);
return (NULL);
}
- strlcpy(path, pw->pw_dir, sizeof path - 1);
+ strlcpy(path, pw->pw_dir, sizeof(path) - 1);
len = strlen(path);
if (path[len] != '/') {
path[len] = '/';
@@ -281,7 +278,7 @@ adjustname(const char *fn)
if (*fn == '/')
fn++;
}
- strlcat(path, fn, sizeof path);
+ strlcat(path, fn, sizeof(path));
if (realpath(path, fnb) == NULL)
strlcpy(fnb, path, sizeof(fnb));
@@ -299,7 +296,7 @@ adjustname(const char *fn)
char *
startupfile(char *suffix)
{
- static char file[NFILEN];
+ static char file[NFILEN];
char *home;
if ((home = getenv("HOME")) == NULL || *home == '\0')
@@ -343,10 +340,10 @@ nohome:
int
copy(char *frname, char *toname)
{
- int ifd, ofd, n;
- char buf[BUFSIZ];
- mode_t mode = DEFFILEMODE; /* XXX?? */
- struct stat orig;
+ int ifd, ofd, n;
+ char buf[BUFSIZ];
+ mode_t mode = DEFFILEMODE; /* XXX?? */
+ struct stat orig;
if ((ifd = open(frname, O_RDONLY)) == -1)
return (FALSE);
@@ -360,7 +357,7 @@ copy(char *frname, char *toname)
close(ifd);
return (FALSE);
}
- while ((n = read(ifd, buf, sizeof buf)) > 0) {
+ while ((n = read(ifd, buf, sizeof(buf))) > 0) {
if (write(ofd, buf, n) != n) {
ewprintf("write error : %s", strerror(errno));
break;
@@ -377,7 +374,7 @@ copy(char *frname, char *toname)
}
/*
* It is "normal" for this to fail since we can't guarantee that
- * we will be running as root
+ * we will be running as root.
*/
if (fchown(ofd, orig.st_uid, orig.st_gid) && errno != EPERM)
ewprintf("Cannot set owner : %s", strerror(errno));
@@ -396,12 +393,12 @@ dired_(char *dirname)
{
BUFFER *bp;
FILE *dirpipe;
- char line[256];
- int len;
+ char line[256];
+ int len;
if ((dirname = adjustname(dirname)) == NULL) {
ewprintf("Bad directory name");
- return NULL;
+ return (NULL);
}
/* this should not be done, instead adjustname() should get a flag */
len = strlen(dirname);
@@ -411,19 +408,19 @@ dired_(char *dirname)
}
if ((bp = findbuffer(dirname)) == NULL) {
ewprintf("Could not create buffer");
- return NULL;
+ return (NULL);
}
if (bclear(bp) != TRUE)
- return NULL;
+ return (NULL);
bp->b_flag |= BFREADONLY;
if (snprintf(line, sizeof(line), "ls -al %s", dirname)
>= sizeof(line)) {
ewprintf("Path too long");
- return NULL;
+ return (NULL);
}
if ((dirpipe = popen(line, "r")) == NULL) {
ewprintf("Problem opening pipe to ls");
- return NULL;
+ return (NULL);
}
line[0] = line[1] = ' ';
while (fgets(&line[2], sizeof(line) - 2, dirpipe) != NULL) {
@@ -433,17 +430,17 @@ dired_(char *dirname)
if (pclose(dirpipe) == -1) {
ewprintf("Problem closing pipe to ls : %s",
strerror(errno));
- return NULL;
+ return (NULL);
}
bp->b_dotp = lforw(bp->b_linep); /* go to first line */
- (void) strlcpy(bp->b_fname, dirname, sizeof bp->b_fname);
+ (void) strlcpy(bp->b_fname, dirname, sizeof(bp->b_fname));
if ((bp->b_modes[1] = name_mode("dired")) == NULL) {
bp->b_modes[0] = name_mode("fundamental");
ewprintf("Could not find mode dired");
- return NULL;
+ return (NULL);
}
bp->b_nmodes = 1;
- return bp;
+ return (bp);
}
#define NAME_FIELD 8
@@ -451,8 +448,8 @@ dired_(char *dirname)
int
d_makename(LINE *lp, char *fn, int len)
{
- int i;
- char *p, *ep;
+ int i;
+ char *p, *ep;
strlcpy(fn, curbp->b_fname, len);
p = lp->l_text;
@@ -468,7 +465,7 @@ d_makename(LINE *lp, char *fn, int len)
return (ABORT);
}
strlcat(fn, p, len);
- return (lgetc(lp, 2) == 'd') ? TRUE : FALSE;
+ return ((lgetc(lp, 2) == 'd') ? TRUE : FALSE);
}
#endif /* NO_DIRED */
@@ -480,17 +477,16 @@ struct filelist {
/*
* return list of file names that match the name in buf.
*/
-
LIST *
make_file_list(char *buf)
{
char *dir, *file, *cp;
- int len, preflen;
+ int len, preflen;
DIR *dirp;
struct dirent *dent;
LIST *last;
struct filelist *current;
- char prefixx[NFILEN + 1];
+ char prefixx[NFILEN + 1];
/*
* We need three different strings: dir - the name of the directory
@@ -498,7 +494,7 @@ make_file_list(char *buf)
* e.g. no ~user, etc.. Must not end in /. prefix - the portion of
* what the user typed that is before the names we are going to find
* in the directory. Must have a trailing / if the user typed it.
- * names from the directory. we open dir, and return prefix
+ * names from the directory. We open dir, and return prefix
* concatenated with names.
*/
@@ -527,12 +523,11 @@ make_file_list(char *buf)
*file = 0;
if (*dir == 0)
dir = "/";
- } else {
+ } else
return (NULL);
- }
}
/* Now we get the prefix of the name the user typed. */
- strlcpy(prefixx, buf, sizeof prefixx);
+ strlcpy(prefixx, buf, sizeof(prefixx));
cp = strrchr(prefixx, '/');
if (cp == NULL)
prefixx[0] = 0;
@@ -540,7 +535,7 @@ make_file_list(char *buf)
cp[1] = 0;
preflen = strlen(prefixx);
- /* cp is the tail of buf that really needs to be compared */
+ /* cp is the tail of buf that really needs to be compared. */
cp = buf + preflen;
len = strlen(cp);
diff --git a/usr.bin/mg/funmap.c b/usr.bin/mg/funmap.c
index 02698fe98a4..37d0c58f718 100644
--- a/usr.bin/mg/funmap.c
+++ b/usr.bin/mg/funmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: funmap.c,v 1.10 2005/03/09 16:20:48 jfb Exp $ */
+/* $OpenBSD: funmap.c,v 1.11 2005/04/03 02:09:28 db Exp $ */
/*
* Copyright (c) 2001 Artur Grabowski <art@openbsd.org>. All rights reserved.
*
@@ -43,7 +43,7 @@ static struct funmap functnames[] = {
#ifndef NO_HELP
{apropos_command, "apropos",},
#endif /* !NO_HELP */
- { auto_execute, "auto-execute", },
+ {auto_execute, "auto-execute", },
{fillmode, "auto-fill-mode",},
{indentmode, "auto-indent-mode",},
{backchar, "backward-char",},
@@ -220,15 +220,15 @@ static struct funmap functnames[] = {
{poptobuffer, "switch-to-buffer-other-window",},
{togglereadonly, "toggle-read-only" },
{twiddle, "transpose-chars",},
- { undo, "undo", },
- { undo_dump, "undo-list", },
+ {undo, "undo", },
+ {undo_dump, "undo-list", },
{universal_argument, "universal-argument",},
{upperregion, "upcase-region",},
{upperword, "upcase-word",},
{showcpos, "what-cursor-position",},
{filewrite, "write-file",},
{yank, "yank",},
- {NULL, NULL,},
+ {NULL, NULL,}
};
void
@@ -248,14 +248,14 @@ funmap_add(PF fun, const char *fname)
struct funmap *fn;
if ((fn = malloc(sizeof(*fn))) == NULL)
- return FALSE;
+ return (FALSE);
fn->fn_funct = fun;
fn->fn_name = fname;
fn->fn_next = funs;
funs = fn;
- return TRUE;
+ return (TRUE);
}
/*
@@ -268,9 +268,9 @@ name_function(const char *fname)
for (fn = funs; fn != NULL; fn = fn->fn_next) {
if (strcmp(fn->fn_name, fname) == 0)
- return fn->fn_funct;
+ return (fn->fn_funct);
}
- return NULL;
+ return (NULL);
}
const char *
@@ -280,20 +280,20 @@ function_name(PF fun)
for (fn = funs; fn != NULL; fn = fn->fn_next) {
if (fn->fn_funct == fun)
- return fn->fn_name;
+ return (fn->fn_name);
}
- return NULL;
+ return (NULL);
}
/*
- * list possible function name completions.
+ * List possible function name completions.
*/
LIST *
complete_function_list(const char *fname, int c)
{
- struct funmap *fn;
- LIST *head, *el;
- int len;
+ struct funmap *fn;
+ LIST *head, *el;
+ int len;
len = strlen(fname);
head = NULL;
@@ -301,16 +301,12 @@ complete_function_list(const char *fname, int c)
if (memcmp(fname, fn->fn_name, len) == 0) {
if ((el = malloc(sizeof(*el))) == NULL) {
free_file_list(head);
- return NULL;
+ return (NULL);
}
el->l_name = fn->fn_name;
el->l_next = head;
head = el;
}
}
-
- return head;
+ return (head);
}
-
-
-
diff --git a/usr.bin/mg/funmap.h b/usr.bin/mg/funmap.h
index ee35e27fa5d..81c3f902fce 100644
--- a/usr.bin/mg/funmap.h
+++ b/usr.bin/mg/funmap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: funmap.h,v 1.3 2002/03/11 13:02:56 vincent Exp $ */
+/* $OpenBSD: funmap.h,v 1.4 2005/04/03 02:09:28 db Exp $ */
/*
* Copyright (c) 2001 Artur Grabowski <art@openbsd.org>. All rights reserved.
*
@@ -23,8 +23,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-void funmap_init(void);
-PF name_function(const char *);
-const char *function_name(PF);
-LIST *complete_function_list(const char *, int);
-int funmap_add(PF, const char *);
+void funmap_init(void);
+PF name_function(const char *);
+const char *function_name(PF);
+LIST *complete_function_list(const char *, int);
+int funmap_add(PF, const char *);
diff --git a/usr.bin/mg/grep.c b/usr.bin/mg/grep.c
index feb74dc4185..1ca10e0c51e 100644
--- a/usr.bin/mg/grep.c
+++ b/usr.bin/mg/grep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grep.c,v 1.12 2004/07/22 01:25:25 vincent Exp $ */
+/* $OpenBSD: grep.c,v 1.13 2005/04/03 02:09:28 db Exp $ */
/*
* Copyright (c) 2001 Artur Grabowski <art@openbsd.org>. All rights reserved.
*
@@ -29,11 +29,11 @@
#include <ctype.h>
-static int compile_goto_error(int, int);
-static int next_error(int, int);
-static int grep(int, int);
-static int compile(int, int);
-static int gid(int, int);
+static int compile_goto_error(int, int);
+static int next_error(int, int);
+static int grep(int, int);
+static int compile(int, int);
+static int gid(int, int);
static BUFFER *compile_mode(char *, char *);
@@ -46,11 +46,11 @@ static char compile_last_command[NFILEN] = "make ";
*
* XXX - need some kind of callback to find out when those get killed.
*/
-MGWIN *compile_win;
-BUFFER *compile_buffer;
+MGWIN *compile_win;
+BUFFER *compile_buffer;
static PF compile_pf[] = {
- compile_goto_error,
+ compile_goto_error
};
static struct KEYMAPE (1 + IMAPEXT) compilemap = {
@@ -58,7 +58,7 @@ static struct KEYMAPE (1 + IMAPEXT) compilemap = {
1 + IMAPEXT,
rescan,
{
- { CCHR('M'), CCHR('M'), compile_pf, NULL },
+ { CCHR('M'), CCHR('M'), compile_pf, NULL }
}
};
@@ -76,60 +76,60 @@ grep_init(void)
static int
grep(int f, int n)
{
- char command[NFILEN + 20];
- char prompt[NFILEN], *bufp;
- BUFFER *bp;
- MGWIN *wp;
+ char command[NFILEN + 20];
+ char prompt[NFILEN], *bufp;
+ BUFFER *bp;
+ MGWIN *wp;
- (void)strlcpy(prompt, "grep -n ", sizeof prompt);
+ (void)strlcpy(prompt, "grep -n ", sizeof(prompt));
if ((bufp = eread("Run grep: ", prompt, NFILEN, EFDEF|EFNEW|EFCR))
== NULL)
- return ABORT;
+ return (ABORT);
- (void)snprintf(command, sizeof command, "%s /dev/null", bufp);
+ (void)snprintf(command, sizeof(command), "%s /dev/null", bufp);
if ((bp = compile_mode("*grep*", command)) == NULL)
- return FALSE;
+ return (FALSE);
if ((wp = popbuf(bp)) == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
compile_win = curwp = wp;
- return TRUE;
+ return (TRUE);
}
static int
compile(int f, int n)
{
- char command[NFILEN + 20];
- char prompt[NFILEN], *bufp;
- BUFFER *bp;
- MGWIN *wp;
+ char command[NFILEN + 20];
+ char prompt[NFILEN], *bufp;
+ BUFFER *bp;
+ MGWIN *wp;
- (void)strlcpy(prompt, compile_last_command, sizeof prompt);
+ (void)strlcpy(prompt, compile_last_command, sizeof(prompt));
if ((bufp = eread("Compile command: ", prompt, NFILEN, EFDEF|EFNEW|EFCR)) == NULL)
- return ABORT;
- (void)strlcpy(compile_last_command, bufp, sizeof compile_last_command);
+ return (ABORT);
+ (void)strlcpy(compile_last_command, bufp, sizeof(compile_last_command));
- (void)snprintf(command, sizeof command, "%s 2>&1", bufp);
+ (void)snprintf(command, sizeof(command), "%s 2>&1", bufp);
if ((bp = compile_mode("*compile*", command)) == NULL)
- return FALSE;
+ return (FALSE);
if ((wp = popbuf(bp)) == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
compile_win = curwp = wp;
- return TRUE;
+ return (TRUE);
}
/* id-utils foo. */
static int
gid(int f, int n)
{
- char command[NFILEN + 20];
- char prompt[NFILEN], c, *bufp;
- BUFFER *bp;
- MGWIN *wp;
- int i, j;
+ char command[NFILEN + 20];
+ char prompt[NFILEN], c, *bufp;
+ BUFFER *bp;
+ MGWIN *wp;
+ int i, j;
/* catch ([^\s(){}]+)[\s(){}]* */
@@ -158,37 +158,37 @@ gid(int f, int n)
if ((bufp = eread("Run gid (with args): ", prompt, NFILEN,
(j ? EFDEF : 0)|EFNEW|EFCR)) == NULL)
- return ABORT;
- (void)snprintf(command, sizeof command, "gid %s", prompt);
+ return (ABORT);
+ (void)snprintf(command, sizeof(command), "gid %s", prompt);
if ((bp = compile_mode("*gid*", command)) == NULL)
- return FALSE;
+ return (FALSE);
if ((wp = popbuf(bp)) == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
compile_win = curwp = wp;
- return TRUE;
+ return (TRUE);
}
BUFFER *
compile_mode(char *name, char *command)
{
- BUFFER *bp;
- FILE *pipe;
- char *buf;
- size_t len;
- int ret;
+ BUFFER *bp;
+ FILE *pipe;
+ char *buf;
+ size_t len;
+ int ret;
bp = bfind(name, TRUE);
if (bclear(bp) != TRUE)
- return NULL;
+ return (NULL);
addlinef(bp, "Running (%s).", command);
addline(bp, "");
if ((pipe = popen(command, "r")) == NULL) {
ewprintf("Problem opening pipe");
- return NULL;
+ return (NULL);
}
/*
* We know that our commands are nice and the last line will end with
@@ -210,17 +210,17 @@ compile_mode(char *name, char *command)
compile_buffer = bp;
- return bp;
+ return (bp);
}
static int
compile_goto_error(int f, int n)
{
- BUFFER *bp;
- MGWIN *wp;
- char *fname, *line, *lp, *ln, *lp1;
- int lineno, len;
- char *adjf;
+ BUFFER *bp;
+ MGWIN *wp;
+ char *fname, *line, *lp, *ln, *lp1;
+ int lineno, len;
+ char *adjf;
compile_win = curwp;
compile_buffer = curbp;
@@ -229,7 +229,7 @@ retry:
len = llength(curwp->w_dotp);
if ((line = malloc(len + 1)) == NULL)
- return FALSE;
+ return (FALSE);
(void)memcpy(line, curwp->w_dotp->l_text, len);
line[len] = '\0';
@@ -250,15 +250,15 @@ retry:
return (FALSE);
if ((bp = findbuffer(adjf)) == NULL)
- return FALSE;
+ return (FALSE);
if ((wp = popbuf(bp)) == NULL)
- return FALSE;
+ return (FALSE);
curbp = bp;
curwp = wp;
if (bp->b_fname[0] == 0)
readin(adjf);
gotoline(FFARG, lineno);
- return TRUE;
+ return (TRUE);
fail:
free(line);
if (curwp->w_dotp != lback(curbp->b_linep)) {
@@ -267,7 +267,7 @@ fail:
goto retry;
}
ewprintf("No more hits");
- return FALSE;
+ return (FALSE);
}
static int
@@ -275,16 +275,16 @@ next_error(int f, int n)
{
if (compile_win == NULL || compile_buffer == NULL) {
ewprintf("No compilation active");
- return FALSE;
+ return (FALSE);
}
curwp = compile_win;
curbp = compile_buffer;
if (curwp->w_dotp == lback(curbp->b_linep)) {
ewprintf("No more hits");
- return FALSE;
+ return (FALSE);
}
curwp->w_dotp = lforw(curwp->w_dotp);
curwp->w_flag |= WFMOVE;
- return compile_goto_error(f, n);
+ return (compile_goto_error(f, n));
}
diff --git a/usr.bin/mg/help.c b/usr.bin/mg/help.c
index 4670b0da993..799dec60b9e 100644
--- a/usr.bin/mg/help.c
+++ b/usr.bin/mg/help.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: help.c,v 1.21 2004/07/22 01:25:25 vincent Exp $ */
+/* $OpenBSD: help.c,v 1.22 2005/04/03 02:09:28 db Exp $ */
/*
* Help functions for Mg 2
@@ -23,8 +23,7 @@ static int findbind(KEYMAP *, PF, char *, size_t);
*/
/* ARGSUSED */
int
-desckey(f, n)
- int f, n;
+desckey(int f, int n)
{
KEYMAP *curmap;
PF funct;
@@ -34,11 +33,11 @@ desckey(f, n)
#ifndef NO_MACRO
if (inmacro)
- return TRUE; /* ignore inside keyboard macro */
+ return (TRUE); /* ignore inside keyboard macro */
#endif /* !NO_MACRO */
num = strlcpy(prompt, "Describe key briefly: ", sizeof(prompt));
- if (num >= sizeof prompt)
- num = sizeof prompt - 1;
+ if (num >= sizeof(prompt))
+ num = sizeof(prompt) - 1;
pep = prompt + num;
key.k_count = 0;
m = curbp->b_nmodes;
@@ -90,7 +89,7 @@ found:
ewprintf("%k runs the command %s", pep);
else
ewprintf("%k is bound to an unnamed function");
- return TRUE;
+ return (TRUE);
}
/*
@@ -100,8 +99,7 @@ found:
*/
/* ARGSUSED */
int
-wallchart(f, n)
- int f, n;
+wallchart(int f, int n)
{
int m;
BUFFER *bp;
@@ -109,31 +107,31 @@ wallchart(f, n)
bp = bfind("*help*", TRUE);
if (bclear(bp) != TRUE)
/* clear it out */
- return FALSE;
+ return (FALSE);
bp->b_flag |= BFREADONLY;
for (m = curbp->b_nmodes; m > 0; m--) {
if ((addlinef(bp, "Local keybindings for mode %s:",
curbp->b_modes[m]->p_name) == FALSE) ||
(showall(bp, curbp->b_modes[m]->p_map, "") == FALSE) ||
(addline(bp, "") == FALSE))
- return FALSE;
+ return (FALSE);
}
if ((addline(bp, "Global bindings:") == FALSE) ||
(showall(bp, fundamental_map, "") == FALSE))
- return FALSE;
- return popbuftop(bp);
+ return (FALSE);
+ return (popbuftop(bp));
}
static int
showall(BUFFER *bp, KEYMAP *map, char *prefix)
{
- KEYMAP *newmap;
- char buf[80], key[16];
- PF fun;
- int c;
+ KEYMAP *newmap;
+ char buf[80], key[16];
+ PF fun;
+ int c;
if (addline(bp, "") == FALSE)
- return FALSE;
+ return (FALSE);
/* XXX - 256 ? */
for (c = 0; c < 256; c++) {
@@ -141,29 +139,27 @@ showall(BUFFER *bp, KEYMAP *map, char *prefix)
if (fun == rescan || fun == selfinsert)
continue;
keyname(buf, sizeof(buf), c);
- (void)snprintf(key, sizeof key, "%s%s ", prefix, buf);
+ (void)snprintf(key, sizeof(key), "%s%s ", prefix, buf);
if (fun == NULL) {
if (showall(bp, newmap, key) == FALSE)
- return FALSE;
+ return (FALSE);
} else {
if (addlinef(bp, "%-16s%s", key,
function_name(fun)) == FALSE)
- return FALSE;
+ return (FALSE);
}
}
-
- return TRUE;
+ return (TRUE);
}
int
-help_help(f, n)
- int f, n;
+help_help(int f, int n)
{
KEYMAP *kp;
PF funct;
if ((kp = name_map("help")) == NULL)
- return FALSE;
+ return (FALSE);
ewprintf("a b c: ");
do {
funct = doscan(kp, getkey(FALSE), NULL);
@@ -172,24 +168,23 @@ help_help(f, n)
if (macrodef && macrocount < MAXMACRO)
macro[macrocount - 1].m_funct = funct;
#endif /* !NO_MACRO */
- return (*funct)(f, n);
+ return ((*funct)(f, n));
}
/* ARGSUSED */
int
-apropos_command(f, n)
- int f, n;
+apropos_command(int f, int n)
{
BUFFER *bp;
LIST *fnames, *el;
char string[32], *bufp;
if ((bufp = eread("apropos: ", string, sizeof(string), EFNEW)) == NULL)
- return ABORT;
+ return (ABORT);
/* FALSE means we got a 0 character string, which is fine */
bp = bfind("*help*", TRUE);
if (bclear(bp) == FALSE)
- return FALSE;
+ return (FALSE);
fnames = complete_function_list("", NULL);
for (el = fnames; el != NULL; el = el->l_next) {
@@ -204,37 +199,36 @@ apropos_command(f, n)
if (addlinef(bp, "%-32s%s", el->l_name, buf) == FALSE) {
free_file_list(fnames);
- return FALSE;
+ return (FALSE);
}
}
free_file_list(fnames);
- return popbuftop(bp);
+ return (popbuftop(bp));
}
static int
findbind(KEYMAP *map, PF fun, char *buf, size_t len)
{
- KEYMAP *newmap;
- PF nfun;
- char buf2[16], key[16];
- int c;
+ KEYMAP *newmap;
+ PF nfun;
+ char buf2[16], key[16];
+ int c;
/* XXX - 256 ? */
for (c = 0; c < 256; c++) {
nfun = doscan(map, c, &newmap);
if (nfun == fun) {
keyname(buf, len, c);
- return TRUE;
+ return (TRUE);
}
if (nfun == NULL) {
if (findbind(newmap, fun, buf2, sizeof(buf2)) == TRUE) {
keyname(key, sizeof(key), c);
(void)snprintf(buf, len, "%s %s", key, buf2);
- return TRUE;
+ return (TRUE);
}
}
}
-
- return FALSE;
+ return (FALSE);
}
#endif /* !NO_HELP */
diff --git a/usr.bin/mg/kbd.c b/usr.bin/mg/kbd.c
index 5c02d405430..4d82bbf8853 100644
--- a/usr.bin/mg/kbd.c
+++ b/usr.bin/mg/kbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kbd.c,v 1.15 2004/02/01 22:26:40 vincent Exp $ */
+/* $OpenBSD: kbd.c,v 1.16 2005/04/03 02:09:28 db Exp $ */
/*
* Terminal independent keyboard handling.
@@ -41,7 +41,7 @@ do_meta(int f, int n)
else
use_metakey = !use_metakey;
ewprintf("Meta keys %sabled", use_metakey ? "en" : "dis");
- return TRUE;
+ return (TRUE);
}
#endif /* DO_METAKEY */
@@ -58,7 +58,7 @@ bsmap(int f, int n)
else
bs_map = !bs_map;
ewprintf("Backspace mapping %sabled", bs_map ? "en" : "dis");
- return TRUE;
+ return (TRUE);
}
#endif /* BSMAP */
@@ -119,7 +119,7 @@ getkey(int flag)
*promptp = '\0';
}
#endif /* !NO_DPROMPT */
- return c;
+ return (c);
}
/*
@@ -132,7 +132,7 @@ doscan(KEYMAP *map, int c, KEYMAP **newmap)
{
MAP_ELEMENT *elec = &map->map_element[0];
MAP_ELEMENT *last = &map->map_element[map->map_num];
- PF ret;
+ PF ret;
while (elec < last && c > elec->k_num)
elec++;
@@ -146,7 +146,7 @@ doscan(KEYMAP *map, int c, KEYMAP **newmap)
if (ret == NULL && newmap != NULL)
*newmap = elec->k_prefmap;
- return ret;
+ return (ret);
}
int
@@ -162,12 +162,12 @@ doin(void)
key.k_count = 0;
while ((funct = doscan(curmap, (key.k_chars[key.k_count++] =
getkey(TRUE)), &curmap)) == NULL)
- /*nothing*/;
+ /* nothing */;
#ifndef NO_MACRO
if (macrodef && macrocount < MAXMACRO)
macro[macrocount++].m_funct = funct;
#endif /* !NO_MACRO */
- return (*funct)(0, 1);
+ return ((*funct)(0, 1));
}
int
@@ -193,20 +193,20 @@ rescan(int f, int n)
while ((fp = doscan(curmap,
key.k_chars[key.k_count++] =
getkey(TRUE), &curmap)) == NULL)
- /*nothing*/;
+ /* nothing */;
if (fp != rescan) {
#ifndef NO_MACRO
if (macrodef && macrocount <= MAXMACRO)
macro[macrocount - 1].m_funct
= fp;
#endif /* !NO_MACRO */
- return (*fp)(f, n);
+ return ((*fp)(f, n));
}
}
}
/* try previous mode */
if (--mode < 0)
- return ABORT;
+ return (ABORT);
curmap = curbp->b_modes[mode]->p_map;
for (i = 0; i < key.k_count; i++) {
if ((fp = doscan(curmap, (key.k_chars[i]), &curmap)) != NULL)
@@ -215,7 +215,7 @@ rescan(int f, int n)
if (fp == NULL) {
while ((fp = doscan(curmap, key.k_chars[i++] =
getkey(TRUE), &curmap)) == NULL)
- /*nothing*/;
+ /* nothing */;
key.k_count = i;
}
if (fp != rescan && i >= key.k_count - 1) {
@@ -223,7 +223,7 @@ rescan(int f, int n)
if (macrodef && macrocount <= MAXMACRO)
macro[macrocount - 1].m_funct = fp;
#endif /* !NO_MACRO */
- return (*fp)(f, n);
+ return ((*fp)(f, n));
}
}
}
@@ -233,8 +233,7 @@ universal_argument(int f, int n)
{
KEYMAP *curmap;
PF funct;
- int c;
- int nn = 4;
+ int c, nn = 4;
if (f & FFUNIV)
nn *= n;
@@ -242,9 +241,9 @@ universal_argument(int f, int n)
key.k_chars[0] = c = getkey(TRUE);
key.k_count = 1;
if (c == '-')
- return negative_argument(f, nn);
+ return (negative_argument(f, nn));
if (c >= '0' && c <= '9')
- return digit_argument(f, nn);
+ return (digit_argument(f, nn));
curmap = curbp->b_modes[curbp->b_nmodes]->p_map;
while ((funct = doscan(curmap, c, &curmap)) == NULL) {
key.k_chars[key.k_count++] = c = getkey(TRUE);
@@ -258,7 +257,7 @@ universal_argument(int f, int n)
macro[macrocount++].m_funct = funct;
}
#endif /* !NO_MACRO */
- return (*funct)(FFUNIV, nn);
+ return ((*funct)(FFUNIV, nn));
}
nn <<= 2;
}
@@ -296,7 +295,7 @@ digit_argument(int f, int n)
macro[macrocount++].m_funct = funct;
}
#endif /* !NO_MACRO */
- return (*funct)(FFOTHARG, nn);
+ return ((*funct)(FFOTHARG, nn));
}
int
@@ -334,7 +333,7 @@ negative_argument(int f, int n)
macro[macrocount++].m_funct = funct;
}
#endif /* !NO_MACRO */
- return (*funct)(FFNEGARG, nn);
+ return ((*funct)(FFNEGARG, nn));
}
/*
@@ -351,9 +350,9 @@ selfinsert(int f, int n)
int count;
if (n < 0)
- return FALSE;
+ return (FALSE);
if (n == 0)
- return TRUE;
+ return (TRUE);
c = key.k_chars[key.k_count - 1];
#ifndef NO_MACRO
if (macrodef && macrocount < MAXMACRO) {
@@ -367,7 +366,7 @@ selfinsert(int f, int n)
if (maclcur->l_size < maclcur->l_used + n) {
if (lrealloc(maclcur, maclcur->l_used + n) ==
FALSE)
- return FALSE;
+ return (FALSE);
}
maclcur->l_used += n;
/* Copy in the new data */
@@ -377,7 +376,7 @@ selfinsert(int f, int n)
} else {
macro[macrocount - 1].m_funct = insert;
if ((lp = lalloc(n)) == NULL)
- return FALSE;
+ return (FALSE);
lp->l_bp = maclcur;
lp->l_fp = maclcur->l_fp;
maclcur->l_fp = lp;
@@ -392,7 +391,7 @@ selfinsert(int f, int n)
do {
count = lnewline();
} while (--n && count == TRUE);
- return count;
+ return (count);
}
/* overwrite mode */
@@ -401,13 +400,13 @@ selfinsert(int f, int n)
while (curwp->w_doto < llength(curwp->w_dotp) && n--)
lputc(curwp->w_dotp, curwp->w_doto++, c);
if (n <= 0)
- return TRUE;
+ return (TRUE);
}
- return linsert(n, c);
+ return (linsert(n, c));
}
/*
- * This could be implemented as a keymap with everthing defined as self-insert.
+ * This could be implemented as a keymap with everything defined as self-insert.
*/
int
quote(int f, int n)
@@ -428,5 +427,5 @@ quote(int f, int n)
} else
ungetkey(c);
}
- return selfinsert(f, n);
+ return (selfinsert(f, n));
}
diff --git a/usr.bin/mg/kbd.h b/usr.bin/mg/kbd.h
index 0090258da34..75f6671513c 100644
--- a/usr.bin/mg/kbd.h
+++ b/usr.bin/mg/kbd.h
@@ -1,20 +1,20 @@
-/* $OpenBSD: kbd.h,v 1.14 2002/03/11 13:02:56 vincent Exp $ */
+/* $OpenBSD: kbd.h,v 1.15 2005/04/03 02:09:28 db Exp $ */
/*
* kbd.h: type definitions for symbol.c and kbd.c for mg experimental
*/
typedef struct {
- KCHAR k_base; /* first key in element */
- KCHAR k_num; /* last key in element */
- PF *k_funcp; /* pointer to array of pointers
- * to functions */
- struct keymap_s *k_prefmap; /* keymap of ONLY prefix key in
- * element */
+ KCHAR k_base; /* first key in element */
+ KCHAR k_num; /* last key in element */
+ PF *k_funcp; /* pointer to array of pointers */
+ /* to functions */
+ struct keymap_s *k_prefmap; /* keymap of ONLY prefix key in */
+ /* element */
} MAP_ELEMENT;
/*
- * predefined keymaps are NOT type KEYMAP because final array needs
+ * Predefined keymaps are NOT type KEYMAP because final array needs
* dimension. If any changes are made to this struct, they must be reflected
* in all keymap declarations.
*/
@@ -36,9 +36,9 @@ typedef struct keymap_s KEYMAPE(1) KEYMAP;
#define MAPELEDEF 4
typedef struct MAPS_S {
- KEYMAP *p_map;
- const char *p_name;
- struct MAPS_S *p_next;
+ KEYMAP *p_map;
+ const char *p_name;
+ struct MAPS_S *p_next;
} MAPS;
extern MAPS *maps;
diff --git a/usr.bin/mg/keymap.c b/usr.bin/mg/keymap.c
index ae12e8393c7..85ec1873048 100644
--- a/usr.bin/mg/keymap.c
+++ b/usr.bin/mg/keymap.c
@@ -1,12 +1,12 @@
-/* $OpenBSD: keymap.c,v 1.27 2005/03/09 16:20:48 jfb Exp $ */
+/* $OpenBSD: keymap.c,v 1.28 2005/04/03 02:09:28 db Exp $ */
/*
* Keyboard maps. This is character set dependent. The terminal specific
* parts of building the keymap has been moved to a better place.
*/
-#include "def.h"
-#include "kbd.h"
+#include "def.h"
+#include "kbd.h"
/*
* initial keymap declarations, deepest first
@@ -15,13 +15,13 @@
#ifndef NO_HELP
static PF cHcG[] = {
ctrlg, /* ^G */
- help_help, /* ^H */
+ help_help /* ^H */
};
static PF cHa[] = {
apropos_command, /* a */
wallchart, /* b */
- desckey, /* c */
+ desckey /* c */
};
static struct KEYMAPE (2 + IMAPEXT) helpmap = {
@@ -34,21 +34,21 @@ static struct KEYMAPE (2 + IMAPEXT) helpmap = {
},
{
'a', 'c', cHa, NULL
- },
+ }
}
};
#endif /* !NO_HELP */
static PF cX4cF[] = {
poptofile, /* ^f */
- ctrlg, /* ^g */
+ ctrlg /* ^g */
};
static PF cX4b[] = {
poptobuffer, /* b */
rescan, /* c */
rescan, /* d */
rescan, /* e */
- poptofile, /* f */
+ poptofile /* f */
};
static struct KEYMAPE (2 + IMAPEXT) cX4map = {
2,
@@ -60,7 +60,7 @@ static struct KEYMAPE (2 + IMAPEXT) cX4map = {
},
{
'b', 'f', cX4b, NULL
- },
+ }
}
};
@@ -70,7 +70,7 @@ static PF cXcB[] = {
rescan, /* ^D */
rescan, /* ^E */
filevisit, /* ^F */
- ctrlg, /* ^G */
+ ctrlg /* ^G */
};
static PF cXcL[] = {
@@ -86,13 +86,13 @@ static PF cXcL[] = {
upperregion, /* ^U */
rescan, /* ^V */
filewrite, /* ^W */
- swapmark, /* ^X */
+ swapmark /* ^X */
};
#ifndef NO_MACRO
static PF cXlp[] = {
definemacro, /* ( */
- finishmacro, /* ) */
+ finishmacro /* ) */
};
#endif /* !NO_MACRO */
@@ -101,11 +101,11 @@ static PF cX0[] = {
onlywind, /* 1 */
splitwind, /* 2 */
rescan, /* 3 */
- NULL, /* 4 */
+ NULL /* 4 */
};
static PF cXeq[] = {
- showcpos, /* = */
+ showcpos /* = */
};
static PF cXcar[] = {
@@ -173,24 +173,24 @@ static struct KEYMAPE (5 + IMAPEXT) cXmap = {
},
{
'^', 'u', cXcar, NULL
- },
+ }
}
};
static PF metacG[] = {
- ctrlg, /* ^G */
+ ctrlg /* ^G */
};
static PF metacV[] = {
- pagenext, /* ^V */
+ pagenext /* ^V */
};
static PF metasp[] = {
- justone, /* space */
+ justone /* space */
};
static PF metapct[] = {
- queryrepl, /* % */
+ queryrepl /* % */
};
static PF metami[] = {
@@ -211,7 +211,7 @@ static PF metami[] = {
rescan, /* ; */
gotobob, /* < */
rescan, /* = */
- gotoeob, /* > */
+ gotoeob /* > */
};
static PF metalb[] = {
@@ -226,7 +226,7 @@ static PF metalb[] = {
capword, /* c */
delfword, /* d */
rescan, /* e */
- forwword, /* f */
+ forwword /* f */
};
static PF metal[] = {
@@ -242,12 +242,12 @@ static PF metal[] = {
upperword, /* u */
backpage, /* v */
copyregion, /* w */
- extend, /* x */
+ extend /* x */
};
static PF metatilde[] = {
notmodified, /* ~ */
- delbword, /* DEL */
+ delbword /* DEL */
};
static struct KEYMAPE (8 + IMAPEXT) metamap = {
@@ -278,7 +278,7 @@ static struct KEYMAPE (8 + IMAPEXT) metamap = {
},
{
'~', CCHR('?'), metatilde, NULL
- },
+ }
}
};
@@ -316,7 +316,7 @@ static PF fund_CJ[] = {
killregion, /* ^W */
NULL, /* ^X */
yank, /* ^Y */
- spawncli, /* ^Z */
+ spawncli /* ^Z */
};
static PF fund_esc[] = {
@@ -324,11 +324,11 @@ static PF fund_esc[] = {
rescan, /* ^\ selfinsert is default on fundamental */
rescan, /* ^] */
rescan, /* ^^ */
- undo, /* ^_ */
+ undo /* ^_ */
};
static PF fund_del[] = {
- backdel, /* DEL */
+ backdel /* DEL */
};
#ifndef FUND_XMAPS
@@ -365,7 +365,7 @@ static struct KEYMAPE (4 + NFUND_XMAPS + IMAPEXT) fundmap = {
};
static PF fill_sp[] = {
- fillword, /* ' ' */
+ fillword /* ' ' */
};
static struct KEYMAPE (1 + IMAPEXT) fillmap = {
@@ -375,7 +375,7 @@ static struct KEYMAPE (1 + IMAPEXT) fillmap = {
{
{
' ', ' ', fill_sp, NULL
- },
+ }
}
};
@@ -383,7 +383,7 @@ static PF indent_lf[] = {
newline, /* ^J */
rescan, /* ^K */
rescan, /* ^L */
- indent, /* ^M */
+ indent /* ^M */
};
static struct KEYMAPE (1 + IMAPEXT) indntmap = {
@@ -393,12 +393,12 @@ static struct KEYMAPE (1 + IMAPEXT) indntmap = {
{
{
CCHR('J'), CCHR('M'), indent_lf, NULL
- },
+ }
}
};
static PF blink_rp[] = {
- showmatch, /* ) */
+ showmatch /* ) */
};
static struct KEYMAPE (1 + IMAPEXT) blinkmap = {
@@ -408,13 +408,13 @@ static struct KEYMAPE (1 + IMAPEXT) blinkmap = {
{
{
')', ')', blink_rp, NULL
- },
+ }
}
};
#ifdef NOTAB
static PF notab_tab[] = {
- space_to_tabstop, /* ^I */
+ space_to_tabstop /* ^I */
};
static struct KEYMAPE (1 + IMAPEXT) notabmap = {
@@ -424,7 +424,7 @@ static struct KEYMAPE (1 + IMAPEXT) notabmap = {
{
{
CCHR('I'), CCHR('I'), notab_tab, NULL
- },
+ }
}
};
#endif /* NOTAB */
@@ -437,7 +437,7 @@ static struct KEYMAPE (1 + IMAPEXT) overwmap = {
/* unused dummy entry for VMS C */
{
(KCHAR)0, (KCHAR)0, NULL, NULL
- },
+ }
}
};
@@ -469,7 +469,7 @@ static PF diredcl[] = {
universal_argument, /* ^U */
forwpage, /* ^V */
rescan, /* ^W */
- NULL, /* ^X */
+ NULL /* ^X */
};
static PF diredcz[] = {
@@ -479,14 +479,14 @@ static PF diredcz[] = {
rescan, /* ^] */
rescan, /* ^^ */
rescan, /* ^_ */
- forwline, /* SP */
+ forwline /* SP */
};
static PF diredc[] = {
d_copy, /* c */
d_del, /* d */
d_findfile, /* e */
- d_findfile, /* f */
+ d_findfile /* f */
};
static PF diredn[] = {
@@ -500,11 +500,11 @@ static PF diredn[] = {
d_undel, /* u */
rescan, /* v */
rescan, /* w */
- d_expunge, /* x */
+ d_expunge /* x */
};
static PF direddl[] = {
- d_undelbak, /* del */
+ d_undelbak /* del */
};
#ifndef DIRED_XMAPS
@@ -547,12 +547,12 @@ static struct KEYMAPE (6 + NDIRED_XMAPS + IMAPEXT) diredmap = {
};
#endif /* !NO_DIRED */
-MAPS fundamental_mode = { (KEYMAP *)&fundmap, "fundamental", };
+MAPS fundamental_mode = { (KEYMAP *)&fundmap, "fundamental" };
/*
* give names to the maps, for use by help etc. If the map is to be bindable,
* it must also be listed in the function name table below with the same
- * name. Maps created dynamicly currently don't get added here, thus are
+ * name. Maps created dynamically currently don't get added here, thus are
* unnamed. Modes are just named keymaps with functions to add/subtract them
* from a buffer's list of modes. If you change a mode name, change it in
* modes.c also.
@@ -575,7 +575,7 @@ static MAPS map_table[] = {
#ifndef NO_DIRED
{(KEYMAP *) &diredmap, "dired",},
#endif
- {NULL, NULL},
+ {NULL, NULL}
};
MAPS *maps;
@@ -583,8 +583,8 @@ MAPS *maps;
void
maps_init(void)
{
- int i;
- MAPS *mp;
+ int i;
+ MAPS *mp;
maps = &fundamental_mode;
for (i = 0; map_table[i].p_name != NULL; i++) {
@@ -597,45 +597,44 @@ maps_init(void)
int
maps_add(KEYMAP *map, const char *name)
{
- MAPS *mp;
+ MAPS *mp;
if ((mp = malloc(sizeof(*mp))) == NULL)
- return FALSE;
+ return (FALSE);
mp->p_name = name;
mp->p_map = map;
mp->p_next = maps;
maps = mp;
- return TRUE;
+ return (TRUE);
}
const char *
map_name(KEYMAP *map)
{
- MAPS *mp;
+ MAPS *mp;
for (mp = maps; mp != NULL; mp = mp->p_next)
if (mp->p_map == map)
- return mp->p_name;
- return NULL;
+ return (mp->p_name);
+ return (NULL);
}
MAPS *
name_mode(const char *name)
{
- MAPS *mp;
+ MAPS *mp;
for (mp = maps; mp != NULL; mp = mp->p_next)
if (strcmp(mp->p_name, name) == 0)
- return mp;
- return NULL;
+ return (mp);
+ return (NULL);
}
KEYMAP *
name_map(const char *name)
{
MAPS *mp;
- return (mp = name_mode(name)) == NULL ? NULL : mp->p_map;
+ return ((mp = name_mode(name)) == NULL ? NULL : mp->p_map);
}
-
diff --git a/usr.bin/mg/line.c b/usr.bin/mg/line.c
index b9129d91540..d82e580780e 100644
--- a/usr.bin/mg/line.c
+++ b/usr.bin/mg/line.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: line.c,v 1.21 2004/07/09 13:50:40 vincent Exp $ */
+/* $OpenBSD: line.c,v 1.22 2005/04/03 02:09:28 db Exp $ */
/*
* Text line handling.
@@ -28,7 +28,7 @@
#endif
#ifndef NBLOCK
-#define NBLOCK 16 /* Line block chunk size */
+#define NBLOCK 16 /* Line block chunk size. */
#endif
#ifndef KBLOCK
@@ -51,16 +51,16 @@ lalloc(int used)
{
LINE *lp;
- if ((lp = malloc(sizeof *lp)) == NULL)
- return NULL;
+ if ((lp = malloc(sizeof(*lp))) == NULL)
+ return (NULL);
lp->l_text = NULL;
lp->l_size = 0;
lp->l_used = used; /* XXX */
if (lrealloc(lp, used) == FALSE) {
free(lp);
- return NULL;
+ return (NULL);
}
- return lp;
+ return (lp);
}
int
@@ -70,12 +70,11 @@ lrealloc(LINE *lp, int newsize)
if (lp->l_size < newsize) {
if ((tmp = realloc(lp->l_text, newsize)) == NULL)
- return FALSE;
+ return (FALSE);
lp->l_text = tmp;
lp->l_size = newsize;
}
-
- return TRUE;
+ return (TRUE);
}
/*
@@ -159,14 +158,14 @@ lchange(int flag)
int
linsert_str(const char *s, int n)
{
- LINE *lp1;
+ LINE *lp1;
MGWIN *wp;
RSIZE i;
int doto;
if (curbp->b_flag & BFREADONLY) {
ewprintf("Buffer is read only");
- return FALSE;
+ return (FALSE);
}
if (!n)
@@ -186,7 +185,7 @@ linsert_str(const char *s, int n)
panic("bug: linsert_str");
/* allocate a new line */
if ((lp2 = lalloc(n)) == NULL)
- return FALSE;
+ return (FALSE);
/* previous line */
lp3 = lp1->l_bp;
/* link in */
@@ -206,14 +205,14 @@ linsert_str(const char *s, int n)
}
undo_add_insert(lp2, 0, n);
curwp->w_doto = n;
- return TRUE;
+ return (TRUE);
}
/* save for later */
doto = curwp->w_doto;
if ((lp1->l_used + n) > lp1->l_size) {
if (lrealloc(lp1, lp1->l_used + n) == FALSE)
- return FALSE;
+ return (FALSE);
}
lp1->l_used += n;
if (lp1->l_used != n)
@@ -234,7 +233,7 @@ linsert_str(const char *s, int n)
}
}
undo_add_insert(curwp->w_dotp, doto, n);
- return TRUE;
+ return (TRUE);
}
/*
@@ -249,7 +248,7 @@ linsert_str(const char *s, int n)
int
linsert(int n, int c)
{
- LINE *lp1;
+ LINE *lp1;
MGWIN *wp;
RSIZE i;
int doto;
@@ -259,7 +258,7 @@ linsert(int n, int c)
if (curbp->b_flag & BFREADONLY) {
ewprintf("Buffer is read only");
- return FALSE;
+ return (FALSE);
}
lchange(WFEDIT);
@@ -274,11 +273,11 @@ linsert(int n, int c)
/* now should only happen in empty buffer */
if (curwp->w_doto != 0) {
ewprintf("bug: linsert");
- return FALSE;
+ return (FALSE);
}
/* allocate a new line */
if ((lp2 = lalloc(n)) == NULL)
- return FALSE;
+ return (FALSE);
/* previous line */
lp3 = lp1->l_bp;
/* link in */
@@ -298,15 +297,14 @@ linsert(int n, int c)
}
undo_add_insert(lp2, 0, n);
curwp->w_doto = n;
- return TRUE;
+ return (TRUE);
}
/* save for later */
doto = curwp->w_doto;
-
if ((lp1->l_used + n) > lp1->l_size) {
if (lrealloc(lp1, lp1->l_used + n) == FALSE)
- return FALSE;
+ return (FALSE);
}
lp1->l_used += n;
if (lp1->l_used != n)
@@ -327,7 +325,7 @@ linsert(int n, int c)
}
}
undo_add_insert(curwp->w_dotp, doto, n);
- return TRUE;
+ return (TRUE);
}
int
@@ -347,7 +345,7 @@ lnewline_at(LINE *lp1, int doto)
if (doto == 0) {
/* new first part */
if ((lp2 = lalloc(0)) == NULL)
- return FALSE;
+ return (FALSE);
lp2->l_bp = lp1->l_bp;
lp1->l_bp->l_fp = lp2;
lp2->l_fp = lp1;
@@ -355,7 +353,7 @@ lnewline_at(LINE *lp1, int doto)
for (wp = wheadp; wp != NULL; wp = wp->w_wndp)
if (wp->w_linep == lp1)
wp->w_linep = lp2;
- return TRUE;
+ return (TRUE);
}
/* length of new part */
@@ -363,7 +361,7 @@ lnewline_at(LINE *lp1, int doto)
/* new second half line */
if ((lp2 = lalloc(nlen)) == NULL)
- return FALSE;
+ return (FALSE);
if (nlen != 0)
bcopy(&lp1->l_text[doto], &lp2->l_text[0], nlen);
lp1->l_used = doto;
@@ -382,7 +380,7 @@ lnewline_at(LINE *lp1, int doto)
wp->w_marko -= doto;
}
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -394,9 +392,9 @@ lnewline(void)
{
if (curbp->b_flag & BFREADONLY) {
ewprintf("Buffer is read only");
- return FALSE;
+ return (FALSE);
}
- return lnewline_at(curwp->w_dotp, curwp->w_doto);
+ return (lnewline_at(curwp->w_dotp, curwp->w_doto));
}
/*
@@ -417,7 +415,7 @@ ldelete(RSIZE n, int kflag)
if (curbp->b_flag & BFREADONLY) {
ewprintf("Buffer is read only");
- return FALSE;
+ return (FALSE);
}
undo_add_delete(curwp->w_dotp, curwp->w_doto, n);
@@ -434,7 +432,7 @@ ldelete(RSIZE n, int kflag)
doto = curwp->w_doto;
/* Hit the end of the buffer */
if (dotp == curbp->b_linep)
- return FALSE;
+ return (FALSE);
/* Size of the chunk */
chunk = dotp->l_used - doto;
@@ -444,11 +442,11 @@ ldelete(RSIZE n, int kflag)
if (chunk == 0) {
if (dotp == lback(curbp->b_linep))
/* End of buffer */
- return FALSE;
+ return (FALSE);
lchange(WFHARD);
if (ldelnewline() == FALSE ||
(kflag != KNONE && kinsert('\n', kflag) == FALSE))
- return FALSE;
+ return (FALSE);
--n;
continue;
}
@@ -458,13 +456,13 @@ ldelete(RSIZE n, int kflag)
if (kflag == KFORW) {
while (ksize - kused < chunk)
if (kgrow(FALSE) == FALSE)
- return FALSE;
+ return (FALSE);
bcopy(cp1, &(kbufp[kused]), (int)chunk);
kused += chunk;
} else if (kflag == KBACK) {
while (kstart < chunk)
if (kgrow(TRUE) == FALSE)
- return FALSE;
+ return (FALSE);
bcopy(cp1, &(kbufp[kstart - chunk]), (int)chunk);
kstart -= chunk;
} else if (kflag != KNONE)
@@ -489,7 +487,7 @@ ldelete(RSIZE n, int kflag)
}
n -= chunk;
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -509,14 +507,14 @@ ldelnewline(void)
if (curbp->b_flag & BFREADONLY) {
ewprintf("Buffer is read only");
- return FALSE;
+ return (FALSE);
}
lp1 = curwp->w_dotp;
lp2 = lp1->l_fp;
/* at the end of the buffer */
if (lp2 == curbp->b_linep)
- return TRUE;
+ return (TRUE);
if (lp2->l_used <= lp1->l_size - lp1->l_used) {
bcopy(&lp2->l_text[0], &lp1->l_text[lp1->l_used], lp2->l_used);
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
@@ -535,10 +533,10 @@ ldelnewline(void)
lp1->l_fp = lp2->l_fp;
lp2->l_fp->l_bp = lp1;
free((char *)lp2);
- return TRUE;
+ return (TRUE);
}
if ((lp3 = lalloc(lp1->l_used + lp2->l_used)) == NULL)
- return FALSE;
+ return (FALSE);
bcopy(&lp1->l_text[0], &lp3->l_text[0], lp1->l_used);
bcopy(&lp2->l_text[0], &lp3->l_text[lp1->l_used], lp2->l_used);
lp1->l_bp->l_fp = lp3;
@@ -563,10 +561,9 @@ ldelnewline(void)
}
free((char *)lp1);
free((char *)lp2);
- return TRUE;
+ return (TRUE);
}
-
/*
* Replace plen characters before dot with argument string. Control-J
* characters in st are interpreted as newlines. There is a casehack
@@ -583,7 +580,7 @@ lreplace(RSIZE plen, char *st, int f)
if (curbp->b_flag & BFREADONLY) {
ewprintf("Buffer is read only");
- return FALSE;
+ return (FALSE);
}
undo_add_change(curwp->w_dotp, curwp->w_doto, plen);
@@ -618,7 +615,7 @@ lreplace(RSIZE plen, char *st, int f)
(void)ldelete((RSIZE) (plen - rlen), KNONE);
else if (plen < rlen) {
if (linsert((int)(rlen - plen), ' ') == FALSE)
- return FALSE;
+ return (FALSE);
}
curwp->w_doto = doto;
@@ -651,7 +648,6 @@ lreplace(RSIZE plen, char *st, int f)
return (TRUE);
}
-
/*
* Delete all of the text saved in the kill buffer. Called by commands when
* a new kill context is created. The kill buffer array is released, just in
@@ -678,9 +674,9 @@ int
kinsert(int c, int dir)
{
if (kused == ksize && dir == KFORW && kgrow(FALSE) == FALSE)
- return FALSE;
+ return (FALSE);
if (kstart == 0 && dir == KBACK && kgrow(TRUE) == FALSE)
- return FALSE;
+ return (FALSE);
if (dir == KFORW)
kbufp[kused++] = c;
else if (dir == KBACK)
@@ -703,11 +699,11 @@ kgrow(int back)
if ((unsigned)(ksize + KBLOCK) <= (unsigned)ksize) {
/* probably 16 bit unsigned */
ewprintf("Kill buffer size at maximum");
- return FALSE;
+ return (FALSE);
}
if ((nbufp = malloc((unsigned)(ksize + KBLOCK))) == NULL) {
ewprintf("Can't get %ld bytes", (long)(ksize + KBLOCK));
- return FALSE;
+ return (FALSE);
}
nstart = (back == TRUE) ? (kstart + KBLOCK) : (KBLOCK / 4);
bcopy(&(kbufp[kstart]), &(nbufp[nstart]), (int)(kused - kstart));
@@ -717,7 +713,7 @@ kgrow(int back)
ksize += KBLOCK;
kused = kused - kstart + nstart;
kstart = nstart;
- return TRUE;
+ return (TRUE);
}
/*
@@ -729,6 +725,6 @@ int
kremove(int n)
{
if (n < 0 || n + kstart >= kused)
- return -1;
- return CHARMASK(kbufp[n + kstart]);
+ return (-1);
+ return (CHARMASK(kbufp[n + kstart]));
}
diff --git a/usr.bin/mg/macro.c b/usr.bin/mg/macro.c
index 466991a5584..46d38475aeb 100644
--- a/usr.bin/mg/macro.c
+++ b/usr.bin/mg/macro.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: macro.c,v 1.7 2004/02/01 22:26:41 vincent Exp $ */
+/* $OpenBSD: macro.c,v 1.8 2005/04/03 02:09:28 db Exp $ */
/*
* Keyboard macros.
@@ -28,7 +28,7 @@ definemacro(int f, int n)
if (macrodef) {
ewprintf("already defining macro");
- return macrodef = FALSE;
+ return (macrodef = FALSE);
}
/* free lines allocated for string arguments */
@@ -41,11 +41,11 @@ definemacro(int f, int n)
}
if ((maclhead = lp1 = lalloc(0)) == NULL)
- return FALSE;
+ return (FALSE);
ewprintf("Defining Keyboard Macro...");
maclcur = lp1->l_fp = lp1->l_bp = lp1;
- return macrodef = TRUE;
+ return (macrodef = TRUE);
}
/* ARGSUSED */
@@ -54,7 +54,7 @@ finishmacro(int f, int n)
{
macrodef = FALSE;
ewprintf("End Keyboard Macro Definition");
- return TRUE;
+ return (TRUE);
}
/* ARGSUSED */
@@ -66,10 +66,10 @@ executemacro(int f, int n)
if (macrodef ||
(macrocount >= MAXMACRO && macro[MAXMACRO].m_funct != finishmacro))
- return FALSE;
+ return (FALSE);
if (macrocount == 0)
- return TRUE;
+ return (TRUE);
inmacro = TRUE;
@@ -86,7 +86,7 @@ executemacro(int f, int n)
}
if ((*funct)(flag, num) != TRUE) {
inmacro = FALSE;
- return FALSE;
+ return (FALSE);
}
lastflag = thisflag;
thisflag = 0;
@@ -95,6 +95,6 @@ executemacro(int f, int n)
}
}
inmacro = FALSE;
- return TRUE;
+ return (TRUE);
}
#endif /* NO_MACRO */
diff --git a/usr.bin/mg/mail.c b/usr.bin/mg/mail.c
index b091fd6f946..8f046a61f70 100644
--- a/usr.bin/mg/mail.c
+++ b/usr.bin/mg/mail.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mail.c,v 1.4 2004/07/22 01:25:25 vincent Exp $ */
+/* $OpenBSD: mail.c,v 1.5 2005/04/03 02:09:28 db Exp $ */
/*
* This file is in the public domain.
*
@@ -48,7 +48,7 @@ static struct KEYMAPE (1 + IMAPEXT) mailmap = {
1 + IMAPEXT,
rescan,
{
- { ' ', '~', mail_fake, NULL },
+ { ' ', '~', mail_fake, NULL }
}
};
@@ -61,12 +61,12 @@ mail_set_limit(int f, int n)
limit = n;
} else {
if ((rep = ereply("Margin: ", buf, sizeof(buf))) == NULL)
- return ABORT;
+ return (ABORT);
else if (*rep == '\0')
- return FALSE;
+ return (FALSE);
limit = atoi(rep);
}
- return TRUE;
+ return (TRUE);
}
void
@@ -99,8 +99,8 @@ fake_self_insert(int f, int n)
if (len + 1 > limit) {
/*
- * find the column at which we should cut, taking
- * word boundaries into account
+ * Find the column at which we should cut, taking
+ * word boundaries into account.
*/
for (col = limit; col > 0; col--)
if (isspace(curwp->w_dotp->l_text[col])) {
@@ -110,7 +110,7 @@ fake_self_insert(int f, int n)
if (curbp->b_doto == len) {
/*
- * user is appending to the line; simple case.
+ * User is appending to the line; simple case.
*/
if (col) {
curwp->w_doto = col;
@@ -120,7 +120,7 @@ fake_self_insert(int f, int n)
curwp->w_wrapline = NULL;
} else if ((len - col) > 0) {
/*
- * user is shifting words by inserting in the middle.
+ * User is shifting words by inserting in the middle.
*/
const char *trail;
int save_doto = curwp->w_doto;
@@ -153,7 +153,7 @@ fake_self_insert(int f, int n)
}
/*
- * readjust dot to point at where the user expects
+ * Readjust dot to point at where the user expects
* it to be after an insertion.
*/
curwp->w_doto = save_doto;
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index b4554eb396e..e7ca3f6897c 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,15 +1,15 @@
-/* $OpenBSD: main.c,v 1.37 2005/03/12 10:36:13 jmc Exp $ */
+/* $OpenBSD: main.c,v 1.38 2005/04/03 02:09:28 db Exp $ */
/*
* Mainline.
*/
-#include "def.h"
-#include "kbd.h"
-#include "funmap.h"
+#include "def.h"
+#include "kbd.h"
+#include "funmap.h"
#ifndef NO_MACRO
-#include "macro.h"
+#include "macro.h"
#endif /* NO_MACRO */
#include <err.h>
@@ -19,7 +19,7 @@ int lastflag; /* flags, last command */
int curgoal; /* goal column */
int startrow; /* row to start */
BUFFER *curbp; /* current buffer */
-BUFFER *bheadp; /* BUFFER list head */
+BUFFER *bheadp; /* BUFFER list head */
MGWIN *curwp; /* current window */
MGWIN *wheadp; /* MGWIN listhead */
char pat[NPAT]; /* pattern */
@@ -30,9 +30,9 @@ int
main(int argc, char **argv)
{
char *cp, *init_fcn_name = NULL;
- PF init_fcn = NULL;
- int o, i, nfiles, status;
- int nobackups = 0;
+ PF init_fcn = NULL;
+ int o, i, nfiles, status;
+ int nobackups = 0;
while ((o = getopt(argc, argv, "nf:")) != -1)
switch (o) {
@@ -107,14 +107,14 @@ main(int argc, char **argv)
notnum:
cp = adjustname(argv[i]);
if (cp != NULL) {
- if (nfiles == 1) {
+ if (nfiles == 1)
splitwind(0, 1);
- }
+
curbp = findbuffer(cp);
(void)showbuffer(curbp, curwp, 0);
- if ((status = readin(cp)) != TRUE) {
+ if ((status = readin(cp)) != TRUE)
killbuffer(curbp);
- } else {
+ else {
if (init_fcn_name)
init_fcn(0, 1);
nfiles++;
@@ -178,8 +178,8 @@ edinit(PF init_fcn)
curwp = wp;
wp->w_wndp = NULL; /* Initialize window. */
wp->w_linep = wp->w_dotp = bp->b_linep;
- wp->w_ntrows = nrow - 2; /* 2 = mode, echo. */
- wp->w_flag = WFMODE | WFHARD; /* Full. */
+ wp->w_ntrows = nrow - 2; /* 2 = mode, echo. */
+ wp->w_flag = WFMODE | WFHARD; /* Full. */
if (init_fcn)
init_fcn(0, 1);
@@ -196,7 +196,7 @@ quit(int f, int n)
int s;
if ((s = anycb(FALSE)) == ABORT)
- return ABORT;
+ return (ABORT);
if (s == FALSE
|| eyesno("Some modified buffers exist, really exit") == TRUE) {
vttidy();
@@ -205,7 +205,7 @@ quit(int f, int n)
#endif /* SYSCLEANUP */
exit(GOOD);
}
- return TRUE;
+ return (TRUE);
}
/*
diff --git a/usr.bin/mg/match.c b/usr.bin/mg/match.c
index 94ec8792191..35797ae562a 100644
--- a/usr.bin/mg/match.c
+++ b/usr.bin/mg/match.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: match.c,v 1.9 2003/05/20 03:08:55 cloder Exp $ */
+/* $OpenBSD: match.c,v 1.10 2005/04/03 02:09:28 db Exp $ */
/*
* Limited parenthesis matching routines
@@ -23,7 +23,6 @@ static void displaymatch(LINE *, int);
* If the character is not in the table, the character is balanced by itself.
* This is to allow delimiters in Scribe documents to be matched.
*/
-
static struct balance {
char left, right;
} bal[] = {
@@ -54,15 +53,15 @@ showmatch(int f, int n)
int i, s;
if (f & FFRAND)
- return FALSE;
+ return (FALSE);
for (i = 0; i < n; i++) {
if ((s = selfinsert(FFRAND, 1)) != TRUE)
- return s;
+ return (s);
/* unbalanced -- warn user */
if (balance() != TRUE)
ttbeep();
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -72,17 +71,13 @@ showmatch(int f, int n)
* for a balancing character. If such a balancing character
* is found, it uses displaymatch() to display the match.
*/
-
static int
balance(void)
{
LINE *clp;
int cbo;
- int c;
- int i;
- int rbal;
- int lbal;
- int depth;
+ int c, i, depth;
+ int rbal, lbal;
rbal = key.k_chars[key.k_count - 1];
@@ -137,13 +132,11 @@ balance(void)
/* NOTREACHED */
}
-
/*
* Display matching character. Matching characters that are not in the
* current window are displayed in the echo line. If in the current window,
* move dot to the matching character, sit there a while, then move back.
*/
-
static void
displaymatch(LINE *clp, int cbo)
{
diff --git a/usr.bin/mg/modes.c b/usr.bin/mg/modes.c
index 9ab31267a0b..731b9f706e9 100644
--- a/usr.bin/mg/modes.c
+++ b/usr.bin/mg/modes.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: modes.c,v 1.9 2004/07/22 01:25:25 vincent Exp $ */
+/* $OpenBSD: modes.c,v 1.10 2005/04/03 02:09:28 db Exp $ */
/*
* Commands to toggle modes. Without an argument, these functions will
@@ -23,7 +23,7 @@ changemode(int f, int n, char *mode)
if ((m = name_mode(mode)) == NULL) {
ewprintf("Can't find mode %s", mode);
- return FALSE;
+ return (FALSE);
}
if (!(f & FFARG)) {
for (i = 0; i <= curbp->b_nmodes; i++)
@@ -37,10 +37,10 @@ changemode(int f, int n, char *mode)
for (i = 0; i <= curbp->b_nmodes; i++)
if (curbp->b_modes[i] == m)
/* mode already set */
- return TRUE;
+ return (TRUE);
if (curbp->b_nmodes >= PBMODES - 1) {
ewprintf("Too many modes");
- return FALSE;
+ return (FALSE);
}
curbp->b_modes[++(curbp->b_nmodes)] = m;
} else {
@@ -48,25 +48,25 @@ changemode(int f, int n, char *mode)
for (i = 1; i <= curbp->b_nmodes && m != curbp->b_modes[i];
i++);
if (i > curbp->b_nmodes)
- return TRUE; /* mode wasn't set */
+ return (TRUE); /* mode wasn't set */
for (; i < curbp->b_nmodes; i++)
curbp->b_modes[i] = curbp->b_modes[i + 1];
curbp->b_nmodes--;
}
upmodes(curbp);
- return TRUE;
+ return (TRUE);
}
int
indentmode(int f, int n)
{
- return changemode(f, n, "indent");
+ return (changemode(f, n, "indent"));
}
int
fillmode(int f, int n)
{
- return changemode(f, n, "fill");
+ return (changemode(f, n, "fill"));
}
/*
@@ -75,7 +75,7 @@ fillmode(int f, int n)
int
blinkparen(int f, int n)
{
- return changemode(f, n, "blink");
+ return (changemode(f, n, "blink"));
}
#ifdef NOTAB
@@ -83,7 +83,7 @@ int
notabmode(int f, int n)
{
if (changemode(f, n, "notab") == FALSE)
- return FALSE;
+ return (FALSE);
if (f & FFARG) {
if (n <= 0)
curbp->b_flag &= ~BFNOTAB;
@@ -91,7 +91,7 @@ notabmode(int f, int n)
curbp->b_flag |= BFNOTAB;
} else
curbp->b_flag ^= BFNOTAB;
- return TRUE;
+ return (TRUE);
}
#endif /* NOTAB */
@@ -99,7 +99,7 @@ int
overwrite(int f, int n)
{
if (changemode(f, n, "overwrite") == FALSE)
- return FALSE;
+ return (FALSE);
if (f & FFARG) {
if (n <= 0)
curbp->b_flag &= ~BFOVERWRITE;
@@ -107,7 +107,7 @@ overwrite(int f, int n)
curbp->b_flag |= BFOVERWRITE;
} else
curbp->b_flag ^= BFOVERWRITE;
- return TRUE;
+ return (TRUE);
}
int
@@ -118,12 +118,12 @@ set_default_mode(int f, int n)
char mode[32], *bufp;
if ((bufp = eread("Set Default Mode: ", mode, 32, EFNEW)) == NULL)
- return ABORT;
+ return (ABORT);
else if (bufp[0] == '\0')
- return FALSE;
+ return (FALSE);
if ((m = name_mode(mode)) == NULL) {
ewprintf("can't find mode %s", mode);
- return FALSE;
+ return (FALSE);
}
if (!(f & FFARG)) {
for (i = 0; i <= defb_nmodes; i++)
@@ -137,10 +137,10 @@ set_default_mode(int f, int n)
for (i = 0; i <= defb_nmodes; i++)
if (defb_modes[i] == m)
/* mode already set */
- return TRUE;
+ return (TRUE);
if (defb_nmodes >= PBMODES - 1) {
ewprintf("Too many modes");
- return FALSE;
+ return (FALSE);
}
defb_modes[++defb_nmodes] = m;
} else {
@@ -148,7 +148,7 @@ set_default_mode(int f, int n)
for (i = 1; i <= defb_nmodes && m != defb_modes[i]; i++);
if (i > defb_nmodes)
/* mode was not set */
- return TRUE;
+ return (TRUE);
for (; i < defb_nmodes; i++)
defb_modes[i] = defb_modes[i + 1];
defb_nmodes--;
@@ -166,5 +166,5 @@ set_default_mode(int f, int n)
else
defb_flag |= BFNOTAB;
#endif /* NOTAB */
- return TRUE;
+ return (TRUE);
}
diff --git a/usr.bin/mg/paragraph.c b/usr.bin/mg/paragraph.c
index d7499f92749..bf281c7ce30 100644
--- a/usr.bin/mg/paragraph.c
+++ b/usr.bin/mg/paragraph.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: paragraph.c,v 1.9 2003/10/24 20:32:06 avsm Exp $ */
+/* $OpenBSD: paragraph.c,v 1.10 2005/04/03 02:09:28 db Exp $ */
/*
* Code for dealing with paragraphs and filling. Adapted from MicroEMACS 3.6
@@ -12,9 +12,9 @@ static int fillcol = 70;
#define MAXWORD 256
/*
- * Move to start of paragraph. Go back to the begining of the current
+ * Move to start of paragraph. Go back to the beginning of the current
* paragraph here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
- * combination to delimit the begining of a paragraph.
+ * combination to delimit the beginning of a paragraph.
*/
/* ARGSUSED */
int
@@ -22,7 +22,7 @@ gotobop(int f, int n)
{
/* the other way... */
if (n < 0)
- return gotoeop(f, -n);
+ return (gotoeop(f, -n));
while (n-- > 0) {
/* first scan back until we are in a word */
@@ -47,7 +47,7 @@ gotobop(int f, int n)
curwp->w_dotp = lforw(curwp->w_dotp);
if (curwp->w_dotp == curbp->b_linep) {
/*
- * beond end of buffer,
+ * beyond end of buffer,
* cleanup time
*/
curwp->w_dotp =
@@ -61,13 +61,13 @@ gotobop(int f, int n)
}
/* force screen update */
curwp->w_flag |= WFMOVE;
- return TRUE;
+ return (TRUE);
}
/*
- * Move to end of paragraph. Go forword to the end of the current paragraph
+ * Move to end of paragraph. Go forward to the end of the current paragraph
* here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE> combination to
- * delimit the begining of a paragraph.
+ * delimit the beginning of a paragraph.
*/
/* ARGSUSED */
int
@@ -75,7 +75,7 @@ gotoeop(int f, int n)
{
/* the other way... */
if (n < 0)
- return gotobop(f, -n);
+ return (gotobop(f, -n));
/* for each one asked for */
while (n-- > 0) {
@@ -97,7 +97,7 @@ gotoeop(int f, int n)
break;
}
if (curwp->w_dotp == curbp->b_linep) {
- /* beond end of buffer, cleanup time */
+ /* beyond end of buffer, cleanup time */
curwp->w_dotp = lback(curwp->w_dotp);
curwp->w_doto = llength(curwp->w_dotp);
break;
@@ -105,7 +105,7 @@ gotoeop(int f, int n)
}
/* force screen update */
curwp->w_flag |= WFMOVE;
- return TRUE;
+ return (TRUE);
}
/*
@@ -116,7 +116,7 @@ gotoeop(int f, int n)
int
fillpara(int f, int n)
{
- int c; /* current char durring scan */
+ int c; /* current char during scan */
int wordlen; /* length of current word */
int clength; /* position on line during fill */
int i; /* index during word copy */
@@ -160,7 +160,7 @@ fillpara(int f, int n)
/* and then delete it */
if (ldelete((RSIZE) 1, KNONE) == FALSE && !eopflag)
- return FALSE;
+ return (FALSE);
/* if not a separator, just add it in */
if (c != ' ' && c != '\t') {
@@ -177,7 +177,7 @@ fillpara(int f, int n)
}
} else if (wordlen) {
- /* calculate tenatitive new length with word added */
+ /* calculate tentative new length with word added */
newlength = clength + 1 + wordlen;
/*
@@ -222,12 +222,12 @@ fillpara(int f, int n)
(void)lnewline();
/*
- * we realy should wind up where we started, (which is hard to keep
+ * We really should wind up where we started, (which is hard to keep
* track of) but I think the end of the last line is better than the
- * begining of the blank line.
+ * beginning of the blank line.
*/
(void)backchar(FFRAND, 1);
- return TRUE;
+ return (TRUE);
}
/*
@@ -242,14 +242,14 @@ killpara(int f, int n)
/* for each paragraph to delete */
while (n--) {
- /* mark out the end and begining of the para to delete */
+ /* mark out the end and beginning of the para to delete */
(void)gotoeop(FFRAND, 1);
/* set the mark here */
curwp->w_markp = curwp->w_dotp;
curwp->w_marko = curwp->w_doto;
- /* go to the begining of the paragraph */
+ /* go to the beginning of the paragraph */
(void)gotobop(FFRAND, 1);
/* force us to the beginning of line */
@@ -257,12 +257,12 @@ killpara(int f, int n)
/* and delete it */
if ((status = killregion(FFRAND, 1)) != TRUE)
- return status;
+ return (status);
/* and clean up the 2 extra lines */
(void)ldelete((RSIZE) 1, KFORW);
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -314,8 +314,8 @@ fillword(int f, int n)
curwp->w_doto = i > 0 ? i : 0;
curwp->w_flag |= WFMOVE;
if (nce == 0 && curwp->w_doto != 0)
- return fillword(f, n);
- return TRUE;
+ return (fillword(f, n));
+ return (TRUE);
}
/*
@@ -326,5 +326,5 @@ setfillcol(int f, int n)
{
fillcol = ((f & FFARG) ? n : getcolpos());
ewprintf("Fill column set to %d", fillcol);
- return TRUE;
+ return (TRUE);
}
diff --git a/usr.bin/mg/random.c b/usr.bin/mg/random.c
index 2867dc51621..24c8f8deb3b 100644
--- a/usr.bin/mg/random.c
+++ b/usr.bin/mg/random.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: random.c,v 1.10 2003/05/20 03:08:55 cloder Exp $ */
+/* $OpenBSD: random.c,v 1.11 2005/04/03 02:09:28 db Exp $ */
/*
* Assorted commands.
@@ -23,8 +23,7 @@ int
showcpos(int f, int n)
{
LINE *clp;
- long nchar;
- long cchar;
+ long nchar, cchar;
int nline, row;
int cline, cbyte; /* Current line/char/byte */
int ratio;
@@ -67,7 +66,7 @@ showcpos(int f, int n)
ratio = nchar ? (100L * cchar) / nchar : 100;
ewprintf("Char: %c (0%o) point=%ld(%d%%) line=%d row=%d col=%d",
cbyte, cbyte, cchar, ratio, cline, row, getcolpos());
- return TRUE;
+ return (TRUE);
}
int
@@ -93,12 +92,12 @@ getcolpos(void)
col++;
else {
char tmp[5];
- snprintf(tmp, sizeof tmp, "\\%o", c);
+ snprintf(tmp, sizeof(tmp), "\\%o", c);
col += strlen(tmp);
}
}
- return col;
+ return (col);
}
/*
@@ -120,36 +119,35 @@ twiddle(int f, int n)
doto = curwp->w_doto;
if (doto == llength(dotp)) {
if (--doto <= 0)
- return FALSE;
+ return (FALSE);
} else {
if (doto == 0)
- return FALSE;
+ return (FALSE);
++curwp->w_doto;
}
cr = lgetc(dotp, doto--);
lputc(dotp, doto + 1, lgetc(dotp, doto));
lputc(dotp, doto, cr);
lchange(WFEDIT);
- return TRUE;
+ return (TRUE);
}
/*
* Open up some blank space. The basic plan is to insert a bunch of
* newlines, and then back up over them. Everything is done by the
- * subcommand procerssors. They even handle the looping. Normally this
+ * subcommand processors. They even handle the looping. Normally this
* is bound to "C-O".
*/
/* ARGSUSED */
int
openline(int f, int n)
{
- int i;
- int s;
+ int i, s;
if (n < 0)
- return FALSE;
+ return (FALSE);
if (n == 0)
- return TRUE;
+ return (TRUE);
/* insert newlines */
i = n;
@@ -160,14 +158,14 @@ openline(int f, int n)
/* then go back up overtop of them all */
if (s == TRUE)
s = backchar(f | FFRAND, n);
- return s;
+ return (s);
}
/*
* Insert a newline. [following "feature" not present in current version of
* Gnu, and now disabled here too] If you are at the end of the line and the
* next line is a blank line, just move into the blank line. This makes
- * "C-O" and "C-X C-O" work nicely, and reduces the ammount of screen update
+ * "C-O" and "C-X C-O" work nicely, and reduces the amount of screen update
* that has to be done. This would not be as critical if screen update were a
* lot more efficient.
*/
@@ -179,7 +177,7 @@ newline(int f, int n)
int s;
if (n < 0)
- return FALSE;
+ return (FALSE);
while (n--) {
lp = curwp->w_dotp;
@@ -188,13 +186,13 @@ newline(int f, int n)
lforw(lp) != curbp->b_linep &&
llength(lforw(lp)) == 0) {
if ((s = forwchar(FFRAND, 1)) != TRUE)
- return s;
+ return (s);
} else
#endif /* undef */
if ((s = lnewline()) != TRUE)
- return s;
+ return (s);
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -223,7 +221,7 @@ deblank(int f, int n)
return (TRUE);
curwp->w_dotp = lforw(lp1);
curwp->w_doto = 0;
- return ldelete((RSIZE)nld, KNONE);
+ return (ldelete((RSIZE)nld, KNONE));
}
/*
@@ -233,7 +231,7 @@ int
justone(int f, int n)
{
(void)delwhite(f, n);
- return linsert(1, ' ');
+ return (linsert(1, ' '));
}
/*
@@ -262,7 +260,7 @@ delwhite(int f, int n)
if (s == TRUE)
(void)forwchar(FFRAND, 1);
(void)ldelete((RSIZE)(col - curwp->w_doto), KNONE);
- return TRUE;
+ return (TRUE);
}
/*
@@ -271,15 +269,13 @@ delwhite(int f, int n)
* simple. Figure out the indentation of the current line. Insert a newline
* by calling the standard routine. Insert the indentation by inserting the
* right number of tabs and spaces. Return TRUE if all ok. Return FALSE if
- * one of the subcomands failed. Normally bound to "C-J".
+ * one of the subcommands failed. Normally bound to "C-J".
*/
/* ARGSUSED */
int
indent(int f, int n)
{
- int nicol;
- int c;
- int i;
+ int c, i, nicol;
if (n < 0)
return (FALSE);
@@ -300,9 +296,9 @@ indent(int f, int n)
#endif /* NOTAB */
((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE) ||
((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE))))
- return FALSE;
+ return (FALSE);
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -316,7 +312,7 @@ int
forwdel(int f, int n)
{
if (n < 0)
- return backdel(f | FFRAND, -n);
+ return (backdel(f | FFRAND, -n));
/* really a kill */
if (f & FFARG) {
@@ -325,7 +321,7 @@ forwdel(int f, int n)
thisflag |= CFKILL;
}
- return ldelete((RSIZE) n, (f & FFARG) ? KFORW : KNONE);
+ return (ldelete((RSIZE) n, (f & FFARG) ? KFORW : KNONE));
}
/*
@@ -340,7 +336,7 @@ backdel(int f, int n)
int s;
if (n < 0)
- return forwdel(f | FFRAND, -n);
+ return (forwdel(f | FFRAND, -n));
/* really a kill */
if (f & FFARG) {
@@ -351,7 +347,7 @@ backdel(int f, int n)
if ((s = backchar(f | FFRAND, n)) == TRUE)
s = ldelete((RSIZE)n, (f & FFARG) ? KFORW : KNONE);
- return s;
+ return (s);
}
/*
@@ -434,7 +430,7 @@ yank(int f, int n)
int c, i, nline;
if (n < 0)
- return FALSE;
+ return (FALSE);
/* newline counting */
nline = 0;
@@ -446,11 +442,11 @@ yank(int f, int n)
while ((c = kremove(i)) >= 0) {
if (c == '\n') {
if (newline(FFRAND, 1) == FALSE)
- return FALSE;
+ return (FALSE);
++nline;
} else {
if (linsert(1, c) == FALSE)
- return FALSE;
+ return (FALSE);
}
++i;
}
@@ -466,7 +462,7 @@ yank(int f, int n)
curwp->w_linep = lp;
curwp->w_flag |= WFHARD;
}
- return TRUE;
+ return (TRUE);
}
#ifdef NOTAB
@@ -475,9 +471,9 @@ int
space_to_tabstop(int f, int n)
{
if (n < 0)
- return FALSE;
+ return (FALSE);
if (n == 0)
- return TRUE;
- return linsert((n << 3) - (curwp->w_doto & 7), ' ');
+ return (TRUE);
+ return (linsert((n << 3) - (curwp->w_doto & 7), ' '));
}
#endif /* NOTAB */
diff --git a/usr.bin/mg/re_search.c b/usr.bin/mg/re_search.c
index 221e01afa73..b89f4500816 100644
--- a/usr.bin/mg/re_search.c
+++ b/usr.bin/mg/re_search.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: re_search.c,v 1.13 2004/07/22 01:25:25 vincent Exp $ */
+/* $OpenBSD: re_search.c,v 1.14 2005/04/03 02:09:28 db Exp $ */
/*
* regular expression search commands for Mg
@@ -63,7 +63,7 @@ re_forwsearch(int f, int n)
/*
* Reverse search.
- * Get a search string from the user, and search, starting at "."
+ * Get a search string from the user, and search, starting at "."
* and proceeding toward the front of the buffer. If found "." is left
* pointing at the first character of the pattern [the last character that
* was matched].
@@ -128,7 +128,7 @@ static regmatch_t re_match[RE_NMATCH];
int
re_queryrepl(int f, int n)
{
- int rcnt = 0; /* replacements made so far */
+ int rcnt = 0; /* replacements made so far */
int plen, s; /* length of found string */
char news[NPAT], *rep; /* replacement string */
@@ -200,7 +200,7 @@ stopsearch:
else
ewprintf("(%d replacements done)", rcnt);
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -292,8 +292,6 @@ re_doreplace(RSIZE plen, char *st, int f)
return (s);
}
-
-
/*
* This routine does the real work of a forward search. The pattern is
* sitting in the external variable "pat". If found, dot is updated, the
@@ -340,7 +338,6 @@ re_forwsrch(void)
return (FALSE);
}
-
/*
* This routine does the real work of a backward search. The pattern is sitting
* in the external variable "re_pat". If found, dot is updated, the window
@@ -399,7 +396,6 @@ re_backsrch(void)
return (FALSE);
}
-
/*
* Read a pattern.
* Stash it in the external variable "re_pat". The "pat" is
@@ -422,7 +418,7 @@ re_readpattern(char *prompt)
if (rep != NULL && *rep != '\0') {
/* New pattern given */
- (void)strlcpy(re_pat, tpat, sizeof re_pat);
+ (void)strlcpy(re_pat, tpat, sizeof(re_pat));
if (casefoldsearch)
flags = REG_EXTENDED | REG_ICASE;
else
@@ -470,9 +466,8 @@ setcasefold(int f, int n)
return (TRUE);
}
-
/*
- * Delete all lines after dot that contain a string matching regex
+ * Delete all lines after dot that contain a string matching regex.
*/
int
delmatchlines(int f, int n)
@@ -488,7 +483,7 @@ delmatchlines(int f, int n)
}
/*
- * Delete all lines after dot that don't contain a string matching regex
+ * Delete all lines after dot that don't contain a string matching regex.
*/
int
delnonmatchlines(int f, int n)
@@ -504,7 +499,7 @@ delnonmatchlines(int f, int n)
}
/*
- * This function does the work of deleting matching lines
+ * This function does the work of deleting matching lines.
*/
static int
killmatches(int cond)
@@ -547,7 +542,7 @@ killmatches(int cond)
}
/*
- * Count lines matching regex
+ * Count lines matching regex.
*/
int
cntmatchlines(int f, int n)
@@ -557,11 +552,12 @@ cntmatchlines(int f, int n)
if ((s = re_readpattern("Count lines (matching regexp)")) != TRUE)
return (s);
s = countmatches(TRUE);
+
return (s);
}
/*
- * Count lines that fail to match regex
+ * Count lines that fail to match regex.
*/
int
cntnonmatchlines(int f, int n)
@@ -570,7 +566,6 @@ cntnonmatchlines(int f, int n)
if ((s = re_readpattern("Count lines (not matching regexp)")) != TRUE)
return (s);
-
s = countmatches(FALSE);
return (s);
diff --git a/usr.bin/mg/region.c b/usr.bin/mg/region.c
index 3bc292b6a1a..54e628a6e65 100644
--- a/usr.bin/mg/region.c
+++ b/usr.bin/mg/region.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: region.c,v 1.14 2004/07/22 01:25:25 vincent Exp $ */
+/* $OpenBSD: region.c,v 1.15 2005/04/03 02:09:28 db Exp $ */
/*
* Region based commands.
@@ -48,7 +48,7 @@ copyregion(int f, int n)
int s;
if ((s = getregion(&region)) != TRUE)
- return s;
+ return (s);
/* kill type command */
if ((lastflag & CFKILL) == 0)
@@ -69,11 +69,11 @@ copyregion(int f, int n)
loffs = 0;
} else { /* Middle of line. */
if ((s = kinsert(lgetc(linep, loffs), KFORW)) != TRUE)
- return s;
+ return (s);
++loffs;
}
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -96,7 +96,7 @@ lowerregion(int f, int n)
}
if ((s = getregion(&region)) != TRUE)
- return s;
+ return (s);
undo_add_change(region.r_linep, region.r_offset, region.r_size);
@@ -114,7 +114,7 @@ lowerregion(int f, int n)
++loffs;
}
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -136,7 +136,7 @@ upperregion(int f, int n)
return (FALSE);
}
if ((s = getregion(&region)) != TRUE)
- return s;
+ return (s);
undo_add_change(region.r_linep, region.r_offset, region.r_size);
@@ -154,7 +154,7 @@ upperregion(int f, int n)
++loffs;
}
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -166,7 +166,7 @@ upperregion(int f, int n)
* the size field of the region structure. If this assignment loses any bits,
* then we print an error. This is "type independent" overflow checking. All
* of the callers of this routine should be ready to get an ABORT status,
- * because I might add a "if regions is big, ask before clobberring" flag.
+ * because I might add a "if regions is big, ask before clobbering" flag.
*/
static int
getregion(REGION *rp)
@@ -189,7 +189,7 @@ getregion(REGION *rp)
rp->r_offset = curwp->w_marko;
rp->r_size = (RSIZE)(curwp->w_doto - curwp->w_marko);
}
- return TRUE;
+ return (TRUE);
}
/* get region size */
flp = blp = curwp->w_dotp;
@@ -218,7 +218,7 @@ getregion(REGION *rp)
}
}
ewprintf("Bug: lost mark");
- return FALSE;
+ return (FALSE);
}
/*
@@ -230,9 +230,9 @@ setsize(REGION *rp, RSIZE size)
rp->r_size = size;
if (rp->r_size != size) {
ewprintf("Region is too large");
- return FALSE;
+ return (FALSE);
}
- return TRUE;
+ return (TRUE);
}
#ifdef PREFIXREGION
@@ -267,7 +267,7 @@ prefixregion(int f, int n)
return (FALSE);
}
if ((f == TRUE) && ((s = setprefix(FFRAND, 1)) != TRUE))
- return s;
+ return (s);
/* get # of lines to affect */
if ((s = getregion(&region)) != TRUE)
@@ -289,7 +289,7 @@ prefixregion(int f, int n)
(void)forwline(FFRAND, 1);
}
(void)gotobol(FFRAND, 1);
- return TRUE;
+ return (TRUE);
}
/*
@@ -300,31 +300,30 @@ int
setprefix(int f, int n)
{
char buf[PREFIXLENGTH], *rep;
- int retval;
+ int retval;
if (prefix_string[0] == '\0')
- rep = ereply("Prefix string: ", buf, sizeof buf);
+ rep = ereply("Prefix string: ", buf, sizeof(buf));
else
rep = ereply("Prefix string (default %s): ",
- buf, sizeof buf, prefix_string);
+ buf, sizeof(buf), prefix_string);
if (rep != NULL && *rep != '\0') {
- (void)strlcpy(prefix_string, rep, sizeof prefix_string);
+ (void)strlcpy(prefix_string, rep, sizeof(prefix_string));
retval = TRUE;
} else if (*rep == '\0' && prefix_string[0] != '\0') {
/* CR -- use old one */
retval = TRUE;
} else
retval = FALSE;
- return retval;
+ return (retval);
}
#endif /* PREFIXREGION */
-
int
region_get_data(REGION *reg, char *buf, int len)
{
- int i, off;
- LINE *lp;
+ int i, off;
+ LINE *lp;
off = reg->r_offset;
lp = reg->r_linep;
@@ -341,7 +340,7 @@ region_get_data(REGION *reg, char *buf, int len)
}
}
buf[i] = '\0';
- return i;
+ return (i);
}
int
@@ -355,5 +354,5 @@ region_put_data(const char *buf, int len)
else
linsert(1, buf[i]);
}
- return 0;
+ return (0);
}
diff --git a/usr.bin/mg/search.c b/usr.bin/mg/search.c
index 8ee6f6a1c31..17d7b01e9f9 100644
--- a/usr.bin/mg/search.c
+++ b/usr.bin/mg/search.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: search.c,v 1.11 2004/07/22 01:25:25 vincent Exp $ */
+/* $OpenBSD: search.c,v 1.12 2005/04/03 02:09:28 db Exp $ */
/*
* Search commands.
@@ -57,13 +57,13 @@ forwsearch(int f, int n)
int s;
if ((s = readpattern("Search")) != TRUE)
- return s;
+ return (s);
if (forwsrch() == FALSE) {
ewprintf("Search failed: \"%s\"", pat);
- return FALSE;
+ return (FALSE);
}
srch_lastdir = SRCH_FORW;
- return TRUE;
+ return (TRUE);
}
/*
@@ -82,10 +82,10 @@ backsearch(int f, int n)
return (s);
if (backsrch() == FALSE) {
ewprintf("Search failed: \"%s\"", pat);
- return FALSE;
+ return (FALSE);
}
srch_lastdir = SRCH_BACK;
- return TRUE;
+ return (TRUE);
}
/*
@@ -100,19 +100,19 @@ searchagain(int f, int n)
if (srch_lastdir == SRCH_FORW) {
if (forwsrch() == FALSE) {
ewprintf("Search failed: \"%s\"", pat);
- return FALSE;
+ return (FALSE);
}
- return TRUE;
+ return (TRUE);
}
if (srch_lastdir == SRCH_BACK) {
if (backsrch() == FALSE) {
ewprintf("Search failed: \"%s\"", pat);
- return FALSE;
+ return (FALSE);
}
- return TRUE;
+ return (TRUE);
}
ewprintf("No last search");
- return FALSE;
+ return (FALSE);
}
/*
@@ -123,7 +123,7 @@ searchagain(int f, int n)
int
forwisearch(int f, int n)
{
- return isearch(SRCH_FORW);
+ return (isearch(SRCH_FORW));
}
/*
@@ -134,7 +134,7 @@ forwisearch(int f, int n)
int
backisearch(int f, int n)
{
- return isearch(SRCH_BACK);
+ return (isearch(SRCH_BACK));
}
/*
@@ -163,13 +163,13 @@ isearch(int dir)
#ifndef NO_MACRO
if (macrodef) {
ewprintf("Can't isearch in macro");
- return FALSE;
+ return (FALSE);
}
#endif /* !NO_MACRO */
for (cip = 0; cip < NSRCH; cip++)
cmds[cip].s_code = SRCH_NOPR;
- (void)strlcpy(opat, pat, sizeof opat);
+ (void)strlcpy(opat, pat, sizeof(opat));
cip = 0;
pptr = -1;
clp = curwp->w_dotp;
@@ -210,8 +210,8 @@ isearch(int dir)
curwp->w_flag |= WFMOVE;
srch_lastdir = dir;
(void)ctrlg(FFRAND, 0);
- (void)strlcpy(pat, opat, sizeof pat);
- return ABORT;
+ (void)strlcpy(pat, opat, sizeof(pat));
+ return (ABORT);
case CCHR(']'):
case CCHR('S'):
if (dir == SRCH_BACK) {
@@ -276,7 +276,7 @@ isearch(int dir)
curwp->w_marko = cbo;
ewprintf("Mark set");
curwp->w_flag |= WFMOVE;
- return TRUE;
+ return (TRUE);
} /* and continue */
case CCHR('I'):
case CCHR('J'):
@@ -288,7 +288,7 @@ isearch(int dir)
pat[pptr++] = c;
if (pptr == NPAT) {
ewprintf("Pattern too long");
- return FALSE;
+ return (FALSE);
}
pat[pptr] = '\0';
is_lpush();
@@ -345,7 +345,7 @@ is_pop(void)
static int
is_peek(void)
{
- return cmds[cip].s_code;
+ return (cmds[cip].s_code);
}
/* this used to always return TRUE (the return value was checked) */
@@ -396,23 +396,23 @@ is_find(int dir)
if (forwsrch() == FALSE) {
curwp->w_doto = odoto;
curwp->w_dotp = odotp;
- return FALSE;
+ return (FALSE);
}
- return TRUE;
+ return (TRUE);
}
if (dir == SRCH_BACK) {
(void)forwchar(FFARG | FFRAND, plen);
if (backsrch() == FALSE) {
curwp->w_doto = odoto;
curwp->w_dotp = odotp;
- return FALSE;
+ return (FALSE);
}
- return TRUE;
+ return (TRUE);
}
ewprintf("bad call to is_find");
- return FALSE;
+ return (FALSE);
}
- return FALSE;
+ return (FALSE);
}
/*
@@ -467,14 +467,14 @@ queryrepl(int f, int n)
#ifndef NO_MACRO
if (macrodef) {
ewprintf("Can't query replace in macro");
- return FALSE;
+ return (FALSE);
}
#endif /* !NO_MACRO */
if ((s = readpattern("Query replace")) != TRUE)
return (s);
if ((rep = ereply("Query replace %s with: ", news, NPAT, pat)) == NULL)
- return ABORT;
+ return (ABORT);
else if (rep[0] == '\0')
news[0] = '\0';
ewprintf("Query replacing %s with %s:", pat, news);
@@ -529,7 +529,7 @@ stopsearch:
ewprintf("(1 replacement done)");
else
ewprintf("(%d replacements done)", rcnt);
- return TRUE;
+ return (TRUE);
}
/*
@@ -574,11 +574,11 @@ forwsrch(void)
curwp->w_dotp = tlp;
curwp->w_doto = tbo;
curwp->w_flag |= WFMOVE;
- return TRUE;
+ return (TRUE);
}
fail: ;
}
- return FALSE;
+ return (FALSE);
}
/*
@@ -601,7 +601,7 @@ backsrch(void)
if (cbo == 0) {
clp = lback(clp);
if (clp == curbp->b_linep)
- return FALSE;
+ return (FALSE);
cbo = llength(clp) + 1;
}
if (--cbo == llength(clp))
@@ -629,7 +629,7 @@ backsrch(void)
curwp->w_dotp = tlp;
curwp->w_doto = tbo;
curwp->w_flag |= WFMOVE;
- return TRUE;
+ return (TRUE);
}
fail: ;
}
@@ -646,12 +646,12 @@ eq(int bc, int pc)
bc = CHARMASK(bc);
pc = CHARMASK(pc);
if (bc == pc)
- return TRUE;
+ return (TRUE);
if (ISUPPER(bc))
- return TOLOWER(bc) == pc;
+ return (TOLOWER(bc) == pc);
if (ISUPPER(pc))
- return bc == TOLOWER(pc);
- return FALSE;
+ return (bc == TOLOWER(pc));
+ return (FALSE);
}
/*
@@ -665,7 +665,7 @@ int
readpattern(char *prompt)
{
char tpat[NPAT], *rep;
- int retval;
+ int retval;
if (tpat[0] == '\0')
rep = ereply("%s: ", tpat, NPAT, prompt);
@@ -674,12 +674,11 @@ readpattern(char *prompt)
/* specified */
if (rep != NULL && *rep != '\0') {
- (void) strlcpy(pat, tpat, sizeof pat);
+ (void) strlcpy(pat, tpat, sizeof(pat));
retval = TRUE;
} else if (*rep == '\0' && pat[0] != '\0') {
retval = TRUE;
} else
retval = FALSE;
- return retval;
+ return (retval);
}
-
diff --git a/usr.bin/mg/spawn.c b/usr.bin/mg/spawn.c
index 58970ea4da6..a187f35fe2d 100644
--- a/usr.bin/mg/spawn.c
+++ b/usr.bin/mg/spawn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spawn.c,v 1.8 2003/05/20 03:08:55 cloder Exp $ */
+/* $OpenBSD: spawn.c,v 1.9 2005/04/03 02:09:28 db Exp $ */
/*
* Spawn. Actually just suspends Mg.
@@ -31,7 +31,7 @@ spawncli(int f, int n)
epresf = FALSE;
}
if (ttcooked() == FALSE)
- return(FALSE);
+ return (FALSE);
/* Exit application mode and tidy. */
tttidy();
@@ -43,5 +43,5 @@ spawncli(int f, int n)
/* Force repaint. */
sgarbf = TRUE;
- return ttraw();
+ return (ttraw());
}
diff --git a/usr.bin/mg/sysdef.h b/usr.bin/mg/sysdef.h
index 49c95e6837f..4e97a7b429f 100644
--- a/usr.bin/mg/sysdef.h
+++ b/usr.bin/mg/sysdef.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysdef.h,v 1.11 2002/02/21 04:16:23 deraadt Exp $ */
+/* $OpenBSD: sysdef.h,v 1.12 2005/04/03 02:09:28 db Exp $ */
/*
* POSIX system header file
@@ -10,14 +10,14 @@
#include <string.h>
#include <errno.h>
-#define KBLOCK 8192 /* Kill grow. */
-#define GOOD 0 /* Good exit status. */
-#define SYMBLINK 1 /* Handle symbolic links */
+#define KBLOCK 8192 /* Kill grow. */
+#define GOOD 0 /* Good exit status. */
+#define SYMBLINK 1 /* Handle symbolic links. */
typedef int RSIZE; /* Type for file/region sizes */
typedef short KCHAR; /* Type for internal keystrokes */
-#define MALLOCROUND(m) (m+=7,m&=~7) /* round up to 8 byte boundry */
+#define MALLOCROUND(m) (m+=7,m&=~7) /* round up to 8 byte boundary */
struct fileinfo {
uid_t fi_uid;
diff --git a/usr.bin/mg/theo.c b/usr.bin/mg/theo.c
index 717cb15a404..f91930476ef 100644
--- a/usr.bin/mg/theo.c
+++ b/usr.bin/mg/theo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: theo.c,v 1.80 2005/03/09 11:11:52 henning Exp $ */
+/* $OpenBSD: theo.c,v 1.81 2005/04/03 02:09:28 db Exp $ */
/*
* Copyright (c) 2002 Artur Grabowski <art@openbsd.org>
* All rights reserved.
@@ -28,12 +28,12 @@
#include "kbd.h"
#include "funmap.h"
-void theo_init(void);
+void theo_init(void);
static int theo_analyze(int, int);
static int theo(int, int);
static PF theo_pf[] = {
- theo_analyze,
+ theo_analyze
};
static struct KEYMAPE (1 + IMAPEXT) theomap = {
@@ -41,7 +41,7 @@ static struct KEYMAPE (1 + IMAPEXT) theomap = {
1 + IMAPEXT,
rescan,
{
- { CCHR('M'), CCHR('M'), theo_pf, NULL },
+ { CCHR('M'), CCHR('M'), theo_pf, NULL }
}
};
@@ -57,23 +57,23 @@ theo_init(void)
static int
theo(int f, int n)
{
- BUFFER *bp;
- MGWIN *wp;
+ BUFFER *bp;
+ MGWIN *wp;
bp = bfind("theo", TRUE);
if (bclear(bp) != TRUE)
- return FALSE;
+ return (FALSE);
bp->b_modes[0] = name_mode("fundamental");
bp->b_modes[1] = name_mode("theo");
bp->b_nmodes = 1;
if ((wp = popbuf(bp)) == NULL)
- return FALSE;
+ return (FALSE);
tbuf = curbp = bp;
curwp = wp;
- return TRUE;
+ return (TRUE);
}
static const char *talk[] = {
@@ -178,19 +178,18 @@ static const int ntalk = sizeof(talk)/sizeof(talk[0]);
static int
theo_analyze(int f, int n)
{
- const char *str;
- int len;
+ const char *str;
+ int len;
str = talk[arc4random() % ntalk];
len = strlen(str);
newline(FFRAND, 2);
- while (len--) {
+ while (len--)
linsert(1, *str++);
- }
newline(FFRAND, 2);
- return TRUE;
+ return (TRUE);
}
diff --git a/usr.bin/mg/tty.c b/usr.bin/mg/tty.c
index e9861cce2e5..22eb5aa040f 100644
--- a/usr.bin/mg/tty.c
+++ b/usr.bin/mg/tty.c
@@ -1,11 +1,11 @@
-/* $OpenBSD: tty.c,v 1.20 2003/06/10 22:20:48 deraadt Exp $ */
+/* $OpenBSD: tty.c,v 1.21 2005/04/03 02:09:28 db Exp $ */
/*
* Terminfo display driver
*
* Terminfo is a terminal information database and routines to describe
* terminals on most modern UNIX systems. Many other systems have adopted
- * this as a reasonable way to allow for widly varying and ever changing
+ * this as a reasonable way to allow for widely varying and ever changing
* varieties of terminal types. This should be used where practical.
*/
/*
@@ -15,14 +15,14 @@
* thought everyone with delete line would have clear to end of screen too...
*
* Code for terminals without clear to end of screen and/or clear to end of line
- * has not been extensivly tested.
+ * has not been extensively tested.
*
* Cost calculations are very rough. Costs of insert/delete line may be far
* from the truth. This is accentuated by display.c not knowing about
* multi-line insert/delete.
*
* Using scrolling region vs insert/delete line should probably be based on cost
- * rather than the assuption that scrolling region operations look better.
+ * rather than the assumption that scrolling region operations look better.
*/
#include "def.h"
@@ -39,7 +39,7 @@ static int cci;
static int insdel; /* Do we have both insert & delete line? */
static char *scroll_fwd; /* How to scroll forward. */
-static void winchhandler(int);
+static void winchhandler(int);
static void
winchhandler(int sig)
@@ -128,14 +128,13 @@ ttinit(void)
void
ttreinit(void)
{
- if (enter_ca_mode) {
+ if (enter_ca_mode)
/* enter application mode */
putpad(enter_ca_mode, 1);
- }
- if (keypad_xmit) {
+
+ if (keypad_xmit)
/* turn on keypad */
putpad(keypad_xmit, 1);
- }
ttresize();
}
@@ -282,11 +281,10 @@ ttinsl(int row, int bot, int nchunk)
* Delete nchunk line(s) from "row", replacing the bottom line on the
* screen with a blank line. Unless we're using the scrolling region,
* this is done with crafty sequences of insert and delete lines. The
- * presence of the echo area makes a boundry condition go away.
+ * presence of the echo area makes a boundary condition go away.
*/
void
-ttdell(row, bot, nchunk)
- int row, bot, nchunk;
+ttdell(int row, int bot, int nchunk)
{
int i, nl;
@@ -339,8 +337,7 @@ ttdell(row, bot, nchunk)
* window adjustment moves the cursor).
*/
void
-ttwindow(top, bot)
- int top, bot;
+ttwindow(int top, int bot)
{
if (change_scroll_region && (tttop != top || ttbot != bot)) {
putpad(tgoto(change_scroll_region, bot, top), nrow - ttrow);
@@ -380,8 +377,7 @@ ttnowindow(void)
* color shift.
*/
void
-ttcolor(color)
- int color;
+ttcolor(int color)
{
if (color != tthue) {
if (color == CTEXT)
@@ -433,7 +429,7 @@ static int
fakec(int c)
{
cci++;
- return 0;
+ return (0);
}
/* calculate the cost of doing string s */
diff --git a/usr.bin/mg/ttydef.h b/usr.bin/mg/ttydef.h
index 9a6da90289c..a907d579a67 100644
--- a/usr.bin/mg/ttydef.h
+++ b/usr.bin/mg/ttydef.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ttydef.h,v 1.7 2004/07/08 22:15:42 deraadt Exp $ */
+/* $OpenBSD: ttydef.h,v 1.8 2005/04/03 02:09:28 db Exp $ */
#ifndef TTYDEF_H
#define TTYDEF_H
@@ -9,12 +9,14 @@
*/
#define GOSLING /* Compile in fancy display. */
-/* #define MEMMAP *//* Not memory mapped video. */
-
-/* #define MOVE_STANDOUT *//* don't move in standout mode */
#define STANDOUT_GLITCH /* possible standout glitch */
#define TERMCAP /* for possible use in ttyio.c */
+#ifdef undef
+#define MEMMAP /* Not memory mapped video. */
+#define MOVE_STANDOUT /* don't move in standout mode */
+#endif /* undef */
+
#define putpad(str, num) tputs(str, num, ttputc)
#define KFIRST K00
diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c
index 4ea9f0e3ab7..2858f1c99d4 100644
--- a/usr.bin/mg/ttyio.c
+++ b/usr.bin/mg/ttyio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ttyio.c,v 1.25 2003/12/04 01:37:28 vincent Exp $ */
+/* $OpenBSD: ttyio.c,v 1.26 2005/04/03 02:09:28 db Exp $ */
/*
* POSIX terminal I/O.
@@ -7,14 +7,14 @@
* keyboard characters, and write characters to the display in a barely
* buffered fashion.
*/
-#include "def.h"
+#include "def.h"
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <term.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <termios.h>
+#include <term.h>
#define NOBUF 512 /* Output buffer size. */
@@ -136,8 +136,8 @@ ttputc(int c)
void
ttflush(void)
{
- ssize_t written;
- char *buf = obuf;
+ ssize_t written;
+ char *buf = obuf;
if (nobuf == 0)
return;
@@ -159,7 +159,7 @@ int
ttgetc(void)
{
char c;
- int ret;
+ int ret;
do {
ret = read(0, &c, 1);
@@ -200,7 +200,7 @@ panic(char *s)
/*
* This function returns FALSE if any characters have showed up on the
- * tty before 'msec' miliseconds.
+ * tty before 'msec' milliseconds.
*/
int
ttwait(int msec)
diff --git a/usr.bin/mg/ttykbd.c b/usr.bin/mg/ttykbd.c
index b7758b703a0..08f0212bf16 100644
--- a/usr.bin/mg/ttykbd.c
+++ b/usr.bin/mg/ttykbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ttykbd.c,v 1.12 2004/07/08 22:15:42 deraadt Exp $ */
+/* $OpenBSD: ttykbd.c,v 1.13 2005/04/03 02:09:28 db Exp $ */
/*
* Name: MG 2a
@@ -16,7 +16,7 @@
/*
* Get keyboard character. Very simple if you use keymaps and keys files.
* Bob was right -- the old XKEYS code is not the right solution.
- * FKEYS code is not usefull other than to help debug FKEYS code in
+ * FKEYS code is not useful other than to help debug FKEYS code in
* extend.c.
*/
diff --git a/usr.bin/mg/tutorial b/usr.bin/mg/tutorial
index 316692553a5..c986f945f2d 100644
--- a/usr.bin/mg/tutorial
+++ b/usr.bin/mg/tutorial
@@ -263,7 +263,7 @@ commands that can destroy a lot of text save it, while the ones that
attack only one character, or nothing but blank lines and spaces, do
not save.
-For instance, type C-n a couple times to postion the cursor
+For instance, type C-n a couple times to position the cursor
at some line on this screen.
>> Do this now, move the cursor and kill that line with C-k.
@@ -441,7 +441,7 @@ to replace it with--each one ended with a Return.
Then type M-x repl s<Return>changed<Return>altered<Return>.
Notice how this line has changed: you've replaced
- the word c-h-a-n-g-e-d with "altered" wherever it occured
+ the word c-h-a-n-g-e-d with "altered" wherever it occurred
after the cursor.
@@ -597,7 +597,7 @@ README file about differences from GNU emacs, and why Mg exists.
*** at the AAA users group meeting in Lafayette CA, an Amiga Users ***
*** Group. My profound thanks to Richard Stallman for his work, I ***
*** am proud to carry his initials. ***
-*** Additional modifacations were done by Robert A. Larson for Mg ***
+*** Additional modifications were done by Robert A. Larson for Mg ***
*** version 2a, mainly the name change from MicroGnuEmacs to Mg. ***
*******************************************************************************
diff --git a/usr.bin/mg/undo.c b/usr.bin/mg/undo.c
index 27a1c787178..8dbf7be260a 100644
--- a/usr.bin/mg/undo.c
+++ b/usr.bin/mg/undo.c
@@ -1,6 +1,6 @@
-/* $OpenBSD: undo.c,v 1.24 2003/12/15 00:00:12 vincent Exp $ */
+/* $OpenBSD: undo.c,v 1.25 2005/04/03 02:09:28 db Exp $ */
/*
- * Copyright (c) 2002 Vincent Labrecque
+ * Copyright (c) 2002 Vincent Labrecque <vincent@openbsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,12 +64,11 @@ static int drop_oldest_undo_record(void);
* Since lines can be deleted while they are referenced by undo record, we
* need to have an absolute dot to have something reliable.
*/
-
static int
find_dot(LINE *lp, int off)
{
- int count = 0;
- LINE *p;
+ int count = 0;
+ LINE *p;
for (p = curbp->b_linep; p != lp; p = lforw(p)) {
if (count != 0) {
@@ -116,7 +115,7 @@ new_undo_record(void)
LIST_REMOVE(rec, next); /* Remove it from the free-list */
undo_free_num--;
} else {
- if ((rec = malloc(sizeof *rec)) == NULL)
+ if ((rec = malloc(sizeof(*rec))) == NULL)
panic("Out of memory in undo code (record)");
}
memset(rec, 0, sizeof(struct undo_rec));
@@ -151,7 +150,7 @@ free_undo_record(struct undo_rec *rec)
/*
* Drop the oldest undo record in our list. Return 1 if we could remove it,
- * 0 if the undo list was empty
+ * 0 if the undo list was empty.
*/
static int
drop_oldest_undo_record(void)
@@ -206,9 +205,9 @@ undo_add_boundary(void)
int
undo_add_insert(LINE *lp, int offset, int size)
{
- REGION reg;
- struct undo_rec *rec;
- int pos;
+ REGION reg;
+ struct undo_rec *rec;
+ int pos;
if (undo_disable_flag)
return (TRUE);
@@ -230,7 +229,7 @@ undo_add_insert(LINE *lp, int offset, int size)
}
/*
- * We couldn't reuse the last undo record, so prepare a new one
+ * We couldn't reuse the last undo record, so prepare a new one.
*/
rec = new_undo_record();
rec->pos = pos;
@@ -247,14 +246,14 @@ undo_add_insert(LINE *lp, int offset, int size)
}
/*
- * This of course must be done _before_ the actual deletion is done
+ * This of course must be done _before_ the actual deletion is done.
*/
int
undo_add_delete(LINE *lp, int offset, int size)
{
- REGION reg;
- struct undo_rec *rec;
- int pos;
+ REGION reg;
+ struct undo_rec *rec;
+ int pos;
if (undo_disable_flag)
return (TRUE);
@@ -300,7 +299,7 @@ undo_add_delete(LINE *lp, int offset, int size)
}
/*
- * This of course must be called before the change takes place
+ * This of course must be called before the change takes place.
*/
int
undo_add_change(LINE *lp, int offset, int size)
@@ -323,11 +322,11 @@ undo_add_change(LINE *lp, int offset, int size)
int
undo_dump(int f, int n)
{
- struct undo_rec *rec;
- BUFFER *bp;
- MGWIN *wp;
- char buf[4096], tmp[1024];
- int num;
+ struct undo_rec *rec;
+ BUFFER *bp;
+ MGWIN *wp;
+ char buf[4096], tmp[1024];
+ int num;
/*
* Prepare the buffer for insertion.
@@ -349,7 +348,7 @@ undo_dump(int f, int n)
for (rec = LIST_FIRST(&curwp->w_undo); rec != NULL;
rec = LIST_NEXT(rec, next)) {
num++;
- snprintf(buf, sizeof buf,
+ snprintf(buf, sizeof(buf),
"Record %d =>\t %s at %d ", num,
(rec->type == DELETE) ? "DELETE":
(rec->type == INSERT) ? "INSERT":
@@ -357,21 +356,21 @@ undo_dump(int f, int n)
rec->pos);
if (rec->content) {
- strlcat(buf, "\"", sizeof buf);
- snprintf(tmp, sizeof tmp, "%.*s", rec->region.r_size,
+ strlcat(buf, "\"", sizeof(buf));
+ snprintf(tmp, sizeof(tmp), "%.*s", rec->region.r_size,
rec->content);
- strlcat(buf, tmp, sizeof buf);
- strlcat(buf, "\"", sizeof buf);
+ strlcat(buf, tmp, sizeof(buf));
+ strlcat(buf, "\"", sizeof(buf));
}
- snprintf(tmp, sizeof tmp, " [%d]", rec->region.r_size);
- strlcat(buf, tmp, sizeof buf);
+ snprintf(tmp, sizeof(tmp), " [%d]", rec->region.r_size);
+ strlcat(buf, tmp, sizeof(buf));
addlinef(bp, "%s", buf);
}
return (TRUE);
}
/*
- * After the user did action1, then action2, then action3 :
+ * After the user did action1, then action2, then action3:
*
* [action3] <--- Undoptr
* [action2]
@@ -396,8 +395,8 @@ undo_dump(int f, int n)
* ------
* [undo]
*
- * Note that the "undo of actionX" have no special meaning. Only when,
- * say, we undo a deletion, the insertion will be recorded just as if it
+ * Note that the "undo of actionX" have no special meaning. Only when
+ * we undo a deletion, the insertion will be recorded just as if it
* was typed on the keyboard. Resulting in the inverse operation being
* saved in the list.
*
@@ -408,10 +407,10 @@ undo_dump(int f, int n)
int
undo(int f, int n)
{
- struct undo_rec *ptr, *nptr;
- int done, rval;
- LINE *lp;
- int offset, save, dot;
+ struct undo_rec *ptr, *nptr;
+ int done, rval;
+ LINE *lp;
+ int offset, save, dot;
dot = find_dot(curwp->w_dotp, curwp->w_doto);
diff --git a/usr.bin/mg/version.c b/usr.bin/mg/version.c
index df5d9bc98e1..25723da150f 100644
--- a/usr.bin/mg/version.c
+++ b/usr.bin/mg/version.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: version.c,v 1.7 2003/06/01 23:58:04 art Exp $ */
+/* $OpenBSD: version.c,v 1.8 2005/04/03 02:09:28 db Exp $ */
/*
- * This file contains the string that get written
+ * This file contains the string that gets written
* out by the emacs-version command.
*/
@@ -18,5 +18,5 @@ int
showversion(int f, int n)
{
ewprintf("%s", version);
- return TRUE;
+ return (TRUE);
}
diff --git a/usr.bin/mg/window.c b/usr.bin/mg/window.c
index 8b42ae45a48..e5ab7f06205 100644
--- a/usr.bin/mg/window.c
+++ b/usr.bin/mg/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.15 2004/01/27 23:43:37 vincent Exp $ */
+/* $OpenBSD: window.c,v 1.16 2005/04/03 02:09:28 db Exp $ */
/*
* Window handling.
@@ -65,7 +65,7 @@ reposition(int f, int n)
#endif /* !GOSREC */
curwp->w_flag |= WFFORCE;
sgarbf = TRUE;
- return TRUE;
+ return (TRUE);
}
/*
@@ -107,7 +107,7 @@ refresh(int f, int n)
update();
} else
sgarbf = TRUE;
- return TRUE;
+ return (TRUE);
}
/*
@@ -125,7 +125,7 @@ nextwind(int f, int n)
wp = wheadp;
curwp = wp;
curbp = wp->w_bufp;
- return TRUE;
+ return (TRUE);
}
/* not in Gnu Emacs */
@@ -148,14 +148,14 @@ prevwind(int f, int n)
wp1 = wp1->w_wndp;
curwp = wp1;
curbp = wp1->w_bufp;
- return TRUE;
+ return (TRUE);
}
/*
* This command makes the current window the only window on the screen. Try
* to set the framing so that "." does not have to move on the display. Some
* care has to be taken to keep the values of dot and mark in the buffer
- * structures right if the distruction of a window makes a buffer become
+ * structures right if the destruction of a window makes a buffer become
* undisplayed.
*/
/* ARGSUSED */
@@ -200,7 +200,7 @@ onlywind(int f, int n)
curwp->w_ntrows = nrow - 2;
curwp->w_linep = lp;
curwp->w_flag |= WFMODE | WFHARD;
- return TRUE;
+ return (TRUE);
}
/*
@@ -282,7 +282,7 @@ splitwind(int f, int n)
curwp->w_flag |= WFMODE | WFHARD;
wp->w_flag |= WFMODE | WFHARD;
- return TRUE;
+ return (TRUE);
}
/*
@@ -300,10 +300,10 @@ enlargewind(int f, int n)
int i;
if (n < 0)
- return shrinkwind(f, -n);
+ return (shrinkwind(f, -n));
if (wheadp->w_wndp == NULL) {
ewprintf("Only one window");
- return FALSE;
+ return (FALSE);
}
if ((adjwp = curwp->w_wndp) == NULL) {
adjwp = wheadp;
@@ -312,7 +312,7 @@ enlargewind(int f, int n)
}
if (adjwp->w_ntrows <= n) {
ewprintf("Impossible change");
- return FALSE;
+ return (FALSE);
}
/* shrink below */
@@ -334,7 +334,7 @@ enlargewind(int f, int n)
adjwp->w_ntrows -= n;
curwp->w_flag |= WFMODE | WFHARD;
adjwp->w_flag |= WFMODE | WFHARD;
- return TRUE;
+ return (TRUE);
}
/*
@@ -349,10 +349,10 @@ shrinkwind(int f, int n)
int i;
if (n < 0)
- return enlargewind(f, -n);
+ return (enlargewind(f, -n));
if (wheadp->w_wndp == NULL) {
ewprintf("Only one window");
- return FALSE;
+ return (FALSE);
}
/*
* Bit of flakiness - KRANDOM means it was an internal call, and
@@ -404,7 +404,7 @@ delwind(int f, int n)
/* shrinkwind returning false means only one window... */
if (shrinkwind(FFRAND, wp->w_ntrows + 1) == FALSE)
- return FALSE;
+ return (FALSE);
if (--wp->w_bufp->b_nwnd == 0) {
wp->w_bufp->b_dotp = wp->w_dotp;
wp->w_bufp->b_doto = wp->w_doto;
@@ -424,7 +424,7 @@ delwind(int f, int n)
break;
}
free_window(wp);
- return TRUE;
+ return (TRUE);
}
/*
@@ -439,12 +439,12 @@ wpopup(void)
if (wheadp->w_wndp == NULL &&
splitwind(FFRAND, 0) == FALSE)
- return NULL;
+ return (NULL);
/* find a window to use */
wp = wheadp;
while (wp != NULL && wp == curwp)
wp = wp->w_wndp;
- return wp;
+ return (wp);
}
diff --git a/usr.bin/mg/word.c b/usr.bin/mg/word.c
index f230dfcbd42..f60fbf13469 100644
--- a/usr.bin/mg/word.c
+++ b/usr.bin/mg/word.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: word.c,v 1.8 2003/05/20 03:08:55 cloder Exp $ */
+/* $OpenBSD: word.c,v 1.9 2005/04/03 02:09:28 db Exp $ */
/*
* Word mode commands.
@@ -17,20 +17,20 @@ int
backword(int f, int n)
{
if (n < 0)
- return forwword(f | FFRAND, -n);
+ return (forwword(f | FFRAND, -n));
if (backchar(FFRAND, 1) == FALSE)
- return FALSE;
+ return (FALSE);
while (n--) {
while (inword() == FALSE) {
if (backchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
}
while (inword() != FALSE) {
if (backchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
}
}
- return forwchar(FFRAND, 1);
+ return (forwchar(FFRAND, 1));
}
/*
@@ -42,18 +42,18 @@ int
forwword(int f, int n)
{
if (n < 0)
- return backword(f | FFRAND, -n);
+ return (backword(f | FFRAND, -n));
while (n--) {
while (inword() == FALSE) {
if (forwchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
}
while (inword() != FALSE) {
if (forwchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
}
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -72,11 +72,11 @@ upperword(int f, int n)
}
if (n < 0)
- return FALSE;
+ return (FALSE);
while (n--) {
while (inword() == FALSE) {
if (forwchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
}
while (inword() != FALSE) {
c = lgetc(curwp->w_dotp, curwp->w_doto);
@@ -86,10 +86,10 @@ upperword(int f, int n)
lchange(WFHARD);
}
if (forwchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
}
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -107,11 +107,11 @@ lowerword(int f, int n)
return (FALSE);
}
if (n < 0)
- return FALSE;
+ return (FALSE);
while (n--) {
while (inword() == FALSE) {
if (forwchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
}
while (inword() != FALSE) {
c = lgetc(curwp->w_dotp, curwp->w_doto);
@@ -121,10 +121,10 @@ lowerword(int f, int n)
lchange(WFHARD);
}
if (forwchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
}
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -145,11 +145,11 @@ capword(int f, int n)
}
if (n < 0)
- return FALSE;
+ return (FALSE);
while (n--) {
while (inword() == FALSE) {
if (forwchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
}
if (inword() != FALSE) {
c = lgetc(curwp->w_dotp, curwp->w_doto);
@@ -159,7 +159,7 @@ capword(int f, int n)
lchange(WFHARD);
}
if (forwchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
while (inword() != FALSE) {
c = lgetc(curwp->w_dotp, curwp->w_doto);
if (ISUPPER(c) != FALSE) {
@@ -168,11 +168,11 @@ capword(int f, int n)
lchange(WFHARD);
}
if (forwchar(FFRAND, 1) == FALSE)
- return TRUE;
+ return (TRUE);
}
}
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -191,7 +191,7 @@ delfword(int f, int n)
return (FALSE);
}
if (n < 0)
- return FALSE;
+ return (FALSE);
/* purge kill buffer */
if ((lastflag & CFKILL) == 0)
@@ -243,7 +243,7 @@ delbword(int f, int n)
}
if (n < 0)
- return FALSE;
+ return (FALSE);
/* purge kill buffer */
if ((lastflag & CFKILL) == 0)
@@ -270,22 +270,22 @@ delbword(int f, int n)
}
}
if (forwchar(FFRAND, 1) == FALSE)
- return FALSE;
+ return (FALSE);
/* undo assumed delete */
--size;
out:
- return ldelete(size, KBACK);
+ return (ldelete(size, KBACK));
}
/*
* Return TRUE if the character at dot is a character that is considered to be
- * part of a word. The word character list is hard coded. Should be setable.
+ * part of a word. The word character list is hard coded. Should be settable.
*/
int
inword(void)
{
/* can't use lgetc in ISWORD due to bug in OSK cpp */
- return curwp->w_doto != llength(curwp->w_dotp) &&
- ISWORD(curwp->w_dotp->l_text[curwp->w_doto]);
+ return (curwp->w_doto != llength(curwp->w_dotp) &&
+ ISWORD(curwp->w_dotp->l_text[curwp->w_doto]));
}