summaryrefslogtreecommitdiff
path: root/usr.bin/mg/main.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-09-01 14:59:10 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-09-01 14:59:10 +0000
commita045bd2fd0eec255d59e94ac735e3096da56bfc7 (patch)
tree5d2398a23f5bfa85d6ea967969f36b1e419a9568 /usr.bin/mg/main.c
parent58c021b47d6326c960010c7261da73856d613f4b (diff)
More -Wall anmd KNF, from op2@tomahawk.SQUiSH.org
Diffstat (limited to 'usr.bin/mg/main.c')
-rw-r--r--usr.bin/mg/main.c119
1 files changed, 59 insertions, 60 deletions
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index cb84ca4ddbf..80047685af8 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,83 +1,84 @@
/*
- * Mainline
+ * Mainline.
*/
+
#include "def.h"
+
#ifndef NO_MACRO
#include "macro.h"
-#endif
+#endif /* NO_MACRO */
-int thisflag; /* Flags, this command */
-int lastflag; /* Flags, last command */
-int curgoal; /* Goal column */
-BUFFER *curbp; /* Current buffer */
-MGWIN *curwp; /* Current window */
-BUFFER *bheadp; /* BUFFER listhead */
-MGWIN *wheadp = (MGWIN *) NULL; /* MGWIN listhead */
-char pat[NPAT]; /* Pattern */
-#ifndef NO_DPROMPT
-extern char prompt[], *promptp; /* delayed prompting */
-#endif
+int thisflag; /* flags, this command */
+int lastflag; /* flags, last command */
+int curgoal; /* goal column */
+BUFFER *curbp; /* current buffer */
+BUFFER *bheadp; /* BUFFER listhead */
+MGWIN *curwp; /* current window */
+MGWIN *wheadp = (MGWIN *)NULL; /* MGWIN listhead */
+char pat[NPAT]; /* pattern */
-static VOID edinit();
+static VOID edinit __P((VOID));
int
main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
-#ifndef NO_STARTUP
- char *startupfile();
-#endif
- char *cp;
- VOID vtinit(), makename(), eerase();
- BUFFER *findbuffer();
+ char *cp;
#ifdef SYSINIT
- SYSINIT; /* system dependent. */
-#endif
- vtinit(); /* Virtual terminal. */
+ SYSINIT; /* System dependent. */
+#endif /* SYSINIT */
+ vtinit(); /* Virtual terminal. */
#ifndef NO_DIR
- dirinit(); /* Get current directory */
-#endif
- edinit(); /* Buffers, windows. */
- ttykeymapinit(); /* Symbols, bindings. */
+ dirinit(); /* Get current directory. */
+#endif /* !NO_DIR */
+ edinit(); /* Buffers, windows. */
+ ttykeymapinit(); /* Symbols, bindings. */
+
/*
* doing update() before reading files causes the error messages from
* the file I/O show up on the screen. (and also an extra display of
* the mode line if there are files specified on the command line.)
*/
update();
-#ifndef NO_STARTUP /* User startup file. */
- if ((cp = startupfile((char *) NULL)) != NULL)
- (VOID) load(cp);
-#endif
+
+#ifndef NO_STARTUP
+ /* user startup file */
+ if ((cp = startupfile((char *)NULL)) != NULL)
+ (VOID)load(cp);
+#endif /* !NO_STARTUP */
while (--argc > 0) {
cp = adjustname(*++argv);
curbp = findbuffer(cp);
- (VOID) showbuffer(curbp, curwp, 0);
- (VOID) readin(cp);
+ (VOID)showbuffer(curbp, curwp, 0);
+ (VOID)readin(cp);
}
- thisflag = 0; /* Fake last flags. */
+
+ /* fake last flags */
+ thisflag = 0;
for (;;) {
#ifndef NO_DPROMPT
*(promptp = prompt) = '\0';
if (epresf == KPROMPT)
eerase();
-#endif
+#endif /* !NO_DPROMPT */
update();
lastflag = thisflag;
thisflag = 0;
+
switch (doin()) {
case TRUE:
break;
case ABORT:
- ewprintf("Quit"); /* and fall through */
+ ewprintf("Quit");
+ /* and fall through */
case FALSE:
default:
ttbeep();
#ifndef NO_MACRO
macrodef = FALSE;
-#endif
+#endif /* !NO_MACRO */
}
}
}
@@ -85,62 +86,60 @@ main(argc, argv)
/*
* Initialize default buffer and window.
*/
-static VOID
+static VOID
edinit()
{
- register BUFFER *bp;
- register MGWIN *wp;
+ BUFFER *bp;
+ MGWIN *wp;
bheadp = NULL;
- bp = bfind("*scratch*", TRUE); /* Text buffer. */
- wp = (MGWIN *) malloc(sizeof(MGWIN)); /* Initial window. */
+ bp = bfind("*scratch*", TRUE); /* Text buffer. */
+ wp = (MGWIN *)malloc(sizeof(MGWIN)); /* Initial window. */
if (bp == NULL || wp == NULL)
panic("edinit");
- curbp = bp; /* Current ones. */
+ curbp = bp; /* Current ones. */
wheadp = wp;
curwp = wp;
- wp->w_wndp = NULL; /* Initialize window. */
+ wp->w_wndp = NULL; /* Initialize window. */
wp->w_bufp = bp;
- bp->b_nwnd = 1; /* Displayed. */
+ bp->b_nwnd = 1; /* Displayed. */
wp->w_linep = wp->w_dotp = bp->b_linep;
wp->w_doto = 0;
wp->w_markp = NULL;
wp->w_marko = 0;
wp->w_toprow = 0;
- wp->w_ntrows = nrow - 2;/* 2 = mode, echo. */
+ wp->w_ntrows = nrow - 2; /* 2 = mode, echo. */
wp->w_force = 0;
- wp->w_flag = WFMODE | WFHARD; /* Full. */
+ wp->w_flag = WFMODE | WFHARD; /* Full. */
}
/*
- * Quit command. If an argument, always
- * quit. Otherwise confirm if a buffer has been
- * changed and not written out. Normally bound
- * to "C-X C-C".
+ * Quit command. If an argument, always quit. Otherwise confirm if a buffer
+ * has been changed and not written out. Normally bound to "C-X C-C".
*/
/* ARGSUSED */
+int
quit(f, n)
+ int f, n;
{
- register int s;
- VOID vttidy();
+ int s;
if ((s = anycb(FALSE)) == ABORT)
return ABORT;
if (s == FALSE
|| eyesno("Some modified buffers exist, really exit") == TRUE) {
vttidy();
-#ifdef SYSCLEANUP
+#ifdef SYSCLEANUP
SYSCLEANUP;
-#endif
+#endif /* SYSCLEANUP */
exit(GOOD);
}
return TRUE;
}
/*
- * User abort. Should be called by any input routine that sees a C-g
- * to abort whatever C-g is aborting these days. Currently does
- * nothing.
+ * User abort. Should be called by any input routine that sees a C-g to abort
+ * whatever C-g is aborting these days. Currently does nothing.
*/
/* ARGSUSED */
int