diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-01-06 17:04:10 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-01-06 17:04:10 +0000 |
commit | 4dc704e0b4bd25205b2599f94470621429f208db (patch) | |
tree | 860d242be7c5f984206686bac79a4885d1b6261d /usr.bin/mg/main.c | |
parent | f02178e518463a297d1c53a7b430f17c3e8b2bb5 (diff) |
support +number; rewritten from buggy code by mjc@bitz.ca, vincent ok
Diffstat (limited to 'usr.bin/mg/main.c')
-rw-r--r-- | usr.bin/mg/main.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c index 4aa35a298fa..15785a5a0d0 100644 --- a/usr.bin/mg/main.c +++ b/usr.bin/mg/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.22 2002/07/25 16:37:54 vincent Exp $ */ +/* $OpenBSD: main.c,v 1.23 2003/01/06 17:04:09 deraadt Exp $ */ /* * Mainline. @@ -15,6 +15,7 @@ int thisflag; /* flags, this command */ int lastflag; /* flags, last command */ int curgoal; /* goal column */ +int startrow; /* row to start */ BUFFER *curbp; /* current buffer */ BUFFER *bheadp; /* BUFFER listhead */ MGWIN *curwp; /* current window */ @@ -62,7 +63,26 @@ main(int argc, char **argv) (void)load(cp); #endif /* !NO_STARTUP */ while (--argc > 0) { - cp = adjustname(*++argv); + argv++; + + if (argv[0][0] == '+' && strlen(argv[0]) >= 2) { + long lval; + char *ep; + + errno = 0; + lval = strtoul(&argv[0][1], &ep, 10); + if (argv[0][1] == '\0' || *ep != '\0') + goto notnum; + if ((errno == ERANGE && + (lval == LONG_MAX || lval == LONG_MIN)) || + (lval > INT_MAX || lval < INT_MIN)) + goto notnum; + startrow = (int)lval; + continue; + } +notnum: + + cp = adjustname(*argv); if (cp != NULL) { curbp = findbuffer(cp); (void)showbuffer(curbp, curwp, 0); |