diff options
author | Vincent Labrecque <vincent@cvs.openbsd.org> | 2003-12-04 01:52:02 +0000 |
---|---|---|
committer | Vincent Labrecque <vincent@cvs.openbsd.org> | 2003-12-04 01:52:02 +0000 |
commit | 30e16f375df95c348eec454a5e319431c62ee56c (patch) | |
tree | b98327235b53cc7e200820490ce97f7c987c1825 | |
parent | a954f0d1e9d622a88e3ea98b5a971ad78da7ae87 (diff) |
split the screen in multiple windows when more than one files are given
on the command line
ok deraadt
-rw-r--r-- | usr.bin/mg/main.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c index 568b20ed60a..8bd4f80d77a 100644 --- a/usr.bin/mg/main.c +++ b/usr.bin/mg/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.26 2003/10/27 11:21:12 vincent Exp $ */ +/* $OpenBSD: main.c,v 1.27 2003/12/04 01:52:01 vincent Exp $ */ /* * Mainline. @@ -31,7 +31,7 @@ main(int argc, char **argv) { char *cp, *init_fcn_name = NULL; PF init_fcn = NULL; - int o; + int o, i, nfiles; while ((o = getopt(argc, argv, "f:")) != -1) switch (o) { @@ -86,14 +86,15 @@ main(int argc, char **argv) if ((cp = startupfile(NULL)) != NULL) (void)load(cp); #endif /* !NO_STARTUP */ - while (argc > 0) { - if (argv[0][0] == '+' && strlen(argv[0]) >= 2) { + + for (nfiles = 0, i = 0; i < argc; i++) { + if (argv[i][0] == '+' && strlen(argv[i]) >= 2) { long lval; char *ep; errno = 0; - lval = strtoul(&argv[0][1], &ep, 10); - if (argv[0][1] == '\0' || *ep != '\0') + lval = strtoul(&argv[i][1], &ep, 10); + if (argv[i][1] == '\0' || *ep != '\0') goto notnum; if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) || @@ -102,17 +103,18 @@ main(int argc, char **argv) startrow = (int)lval; } else { notnum: - cp = adjustname(*argv); + cp = adjustname(argv[i]); if (cp != NULL) { + if (nfiles > 0 && nfiles < 3) + splitwind(0, 1); curbp = findbuffer(cp); (void)showbuffer(curbp, curwp, 0); (void)readin(cp); if (init_fcn_name) init_fcn(0, 1); + nfiles++; } } - argc--; - argv++; } /* fake last flags */ |