diff options
author | 2008-06-13 18:41:57 +0000 | |
---|---|---|
committer | 2008-06-13 18:41:57 +0000 | |
commit | 0a8b54ad952e2c902fb395eb9568d37900f15203 (patch) | |
tree | 976bdc0bd250000a6a5aabed7f9dd474ea8bd2ad | |
parent | rearrange on-disk structures to the top of the file, wrap kernel-only (diff) | |
download | wireguard-openbsd-0a8b54ad952e2c902fb395eb9568d37900f15203.tar.xz wireguard-openbsd-0a8b54ad952e2c902fb395eb9568d37900f15203.zip |
Fix autoexec file handling.
Two issues: *scratch* did not inherit any modes set from
~/.mg, as it was created too early. Switch to using *init* buffer
until after autoexec, then kill it and inherit correct *scratch*.
Second, -f should force the mode. Not toggle it.
ok phessler@
-rw-r--r-- | usr.bin/mg/main.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c index b67c08b53ad..961690f2b02 100644 --- a/usr.bin/mg/main.c +++ b/usr.bin/mg/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.58 2008/06/12 01:58:44 kjell Exp $ */ +/* $OpenBSD: main.c,v 1.59 2008/06/13 18:41:57 kjell Exp $ */ /* This file is in the public domain. */ @@ -46,6 +46,7 @@ main(int argc, char **argv) PF init_fcn = NULL; int o, i, nfiles; int nobackups = 0; + struct buffer *bp; while ((o = getopt(argc, argv, "nf:")) != -1) switch (o) { @@ -107,6 +108,20 @@ main(int argc, char **argv) (void)load(cp); #endif /* !NO_STARTUP */ + /* + * Create scratch buffer now, killing old *init* buffer. + * This causes *scratch* to be created and made curbp, + * ensuring default modes are inherited from the startup + * file correctly + */ + + if ((bp = bfind("*init*", FALSE)) != NULL) + killbuffer(bp); + + /* Force FFOTHARG=1 so that this mode is enabled, not simply toggled */ + if (init_fcn) + init_fcn(FFOTHARG, 1); + if (nobackups) makebkfile(FFARG, 0); @@ -134,8 +149,9 @@ notnum: if (readin(cp) != TRUE) killbuffer(curbp); else { + /* Ensure enabled, not just toggled */ if (init_fcn_name) - init_fcn(0, 1); + init_fcn(FFOTHARG, 1); nfiles++; } } @@ -178,6 +194,8 @@ notnum: /* * Initialize default buffer and window. + * Initially, buffer is named *init*. This is changed later + * to *scratch* after the startup files are read. */ static void edinit(PF init_fcn) @@ -186,7 +204,7 @@ edinit(PF init_fcn) struct mgwin *wp; bheadp = NULL; - bp = bfind("*scratch*", TRUE); /* Text buffer. */ + bp = bfind("*init*", TRUE); /* Text buffer. */ wp = new_window(bp); if (wp == NULL) panic("Out of memory"); @@ -199,9 +217,6 @@ edinit(PF init_fcn) wp->w_linep = wp->w_dotp = bp->b_headp; wp->w_ntrows = nrow - 2; /* 2 = mode, echo. */ wp->w_flag = WFMODE | WFFULL; /* Full. */ - - if (init_fcn) - init_fcn(0, 1); } /* |