diff options
author | Igor Sobrado <sobrado@cvs.openbsd.org> | 2009-01-28 13:02:23 +0000 |
---|---|---|
committer | Igor Sobrado <sobrado@cvs.openbsd.org> | 2009-01-28 13:02:23 +0000 |
commit | 1371450e829adc2273cb2391d20c39df89727bf7 (patch) | |
tree | a45a8568337df393361bc1d0ba2d6ee4650deaca /usr.bin | |
parent | 1156b379b9f5e2929b49d9def14f843765c8ed8f (diff) |
ex(1), vi(1), and view(1) have different synopses; each nex/nvi utility
should manage the right set of options and return an appropriate usage
when required.
jsing@ has suggested preserving "-e" in ex(1) as an undocumented
compatibility flag to avoid breaking silly scripts that may use this
option with the line-oriented editor.
diff sent upstream to nex/nvi maintainers.
ok ("put it in!") jsing@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/vi/cl/cl_funcs.c | 21 | ||||
-rw-r--r-- | usr.bin/vi/common/common.h | 5 | ||||
-rw-r--r-- | usr.bin/vi/common/main.c | 22 |
3 files changed, 38 insertions, 10 deletions
diff --git a/usr.bin/vi/cl/cl_funcs.c b/usr.bin/vi/cl/cl_funcs.c index 524acf7d0d3..92985444ce0 100644 --- a/usr.bin/vi/cl/cl_funcs.c +++ b/usr.bin/vi/cl/cl_funcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cl_funcs.c,v 1.12 2006/04/22 03:09:15 ray Exp $ */ +/* $OpenBSD: cl_funcs.c,v 1.13 2009/01/28 13:02:22 sobrado Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -688,11 +688,20 @@ cl_suspend(sp, allowedp) void cl_usage() { -#define USAGE "\ -usage: ex [-eFRrSsv] [-c command] [-t tag] [-w size] [file ...]\n\ -usage: vi [-eFlRrSv] [-c command] [-t tag] [-w size] [file ...]\n" - (void)fprintf(stderr, "%s", USAGE); -#undef USAGE + switch (pmode) { + case MODE_EX: + (void)fprintf(stderr, "usage: " + "ex [-FRrSsv] [-c cmd] [-t tag] [-w size] [file ...]\n"); + break; + case MODE_VI: + (void)fprintf(stderr, "usage: " + "vi [-eFRrS] [-c cmd] [-t tag] [-w size] [file ...]\n"); + break; + case MODE_VIEW: + (void)fprintf(stderr, "usage: " + "view [-eFrS] [-c cmd] [-t tag] [-w size] [file ...]\n"); + break; + } } #ifdef DEBUG diff --git a/usr.bin/vi/common/common.h b/usr.bin/vi/common/common.h index d9b71792a07..8904b272de0 100644 --- a/usr.bin/vi/common/common.h +++ b/usr.bin/vi/common/common.h @@ -1,4 +1,4 @@ -/* $OpenBSD: common.h,v 1.4 2001/01/29 01:58:28 niklas Exp $ */ +/* $OpenBSD: common.h,v 1.5 2009/01/28 13:02:22 sobrado Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -76,6 +76,9 @@ typedef enum { LOCK_FAILED, LOCK_SUCCESS, LOCK_UNAVAIL } lockr_t; /* Sequence types. */ typedef enum { SEQ_ABBREV, SEQ_COMMAND, SEQ_INPUT } seq_t; +/* Program modes. */ +enum { MODE_EX, MODE_VI, MODE_VIEW } pmode; + /* * Local includes. */ diff --git a/usr.bin/vi/common/main.c b/usr.bin/vi/common/main.c index 4f2f7643744..647b03e7a30 100644 --- a/usr.bin/vi/common/main.c +++ b/usr.bin/vi/common/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.15 2008/06/12 21:22:48 sobrado Exp $ */ +/* $OpenBSD: main.c,v 1.16 2009/01/28 13:02:22 sobrado Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -117,11 +117,27 @@ editor(gp, argc, argv) /* Set the file snapshot flag. */ F_SET(gp, G_SNAPSHOT); + pmode = MODE_EX; + if (!strcmp(gp->progname, "ex")) + pmode = MODE_EX; + else if (!strcmp(gp->progname, "vi")) + pmode = MODE_VI; + else if (!strcmp(gp->progname, "view")) + pmode = MODE_VIEW; + + static const char *optstr[3] = { #ifdef DEBUG - while ((ch = getopt(argc, argv, "c:D:eFlRrSsT:t:vw:")) != -1) + "c:D:eFlRrSsT:t:vw:", + "c:D:eFlRrST:t:w:", + "c:D:eFlrST:t:w:" #else - while ((ch = getopt(argc, argv, "c:eFlRrSst:vw:")) != -1) + "c:eFlRrSst:vw:", + "c:eFlRrSt:w:", + "c:eFlrSt:w:" #endif + }; + + while ((ch = getopt(argc, argv, optstr[pmode])) != -1) switch (ch) { case 'c': /* Run the command. */ /* |