summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorlum <lum@cvs.openbsd.org>2012-05-29 05:52:47 +0000
committerlum <lum@cvs.openbsd.org>2012-05-29 05:52:47 +0000
commit5e3d81e6e487faebd41faed591c0df34be5a89b5 (patch)
treed94fa9680f684904dcd0679fc0145d89ffa408e2 /usr.bin
parent2a2b3a3879f142f02ae55d2925dec1fef3c3066a (diff)
There is no need to use an *init* buffer if we go back and update
opened file(s)/*scratch* with default modes after they are open. Also, pass buffer (bp) to edinit(), this fixes theo mode from the command line (mg -f theo).
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/main.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index 5de9d53e790..28a848b7ac6 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.65 2012/05/25 05:05:48 lum Exp $ */
+/* $OpenBSD: main.c,v 1.66 2012/05/29 05:52:46 lum Exp $ */
/* This file is in the public domain. */
@@ -23,7 +23,7 @@ struct mgwin *curwp; /* current window */
struct mgwin *wheadp; /* MGWIN listhead */
char pat[NPAT]; /* pattern */
-static void edinit(PF);
+static void edinit(struct buffer *);
static __dead void usage(void);
extern char *__progname;
@@ -40,11 +40,11 @@ usage()
int
main(int argc, char **argv)
{
- char *cp, *init_fcn_name = NULL;
- PF init_fcn = NULL;
- int o, i, nfiles;
- int nobackups = 0;
- struct buffer *bp;
+ char *cp, *init_fcn_name = NULL;
+ PF init_fcn = NULL;
+ int o, i, nfiles;
+ int nobackups = 0;
+ struct buffer *bp = NULL;
while ((o = getopt(argc, argv, "nf:")) != -1)
switch (o) {
@@ -88,7 +88,7 @@ main(int argc, char **argv)
vtinit(); /* Virtual terminal. */
dirinit(); /* Get current directory. */
- edinit(init_fcn); /* Buffers, windows. */
+ edinit(bp); /* Buffers, windows. */
ttykeymapinit(); /* Symbols, bindings. */
/*
@@ -98,13 +98,6 @@ main(int argc, char **argv)
*/
update();
- /*
- * Create scratch buffer now, killing old *init* buffer.
- * This causes *scratch* to be created and made curbp.
- */
- if ((bp = bfind("*init*", FALSE)) != NULL)
- killbuffer(bp);
-
/* user startup file. */
if ((cp = startupfile(NULL)) != NULL)
(void)load(cp);
@@ -194,26 +187,23 @@ notnum:
}
/*
- * Initialize default buffer and window.
- * Initially, buffer is named *init*. This is changed later
- * to *scratch* after the startup files are read.
+ * Initialize default buffer and window. Default buffer is called *scratch*.
*/
static void
-edinit(PF init_fcn)
+edinit(struct buffer *bp)
{
- struct buffer *bp;
struct mgwin *wp;
bheadp = NULL;
- bp = bfind("*init*", TRUE); /* Text buffer. */
+ bp = bfind("*scratch*", TRUE); /* Text buffer. */
if (bp == NULL)
panic("edinit");
wp = new_window(bp);
if (wp == NULL)
- panic("Out of memory");
+ panic("edinit: Out of memory");
- curbp = bp; /* Current ones. */
+ curbp = bp; /* Current buffer. */
wheadp = wp;
curwp = wp;
wp->w_wndp = NULL; /* Initialize window. */