summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/vi/cl/cl_funcs.c21
-rw-r--r--usr.bin/vi/common/common.h5
-rw-r--r--usr.bin/vi/common/main.c22
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. */
/*