summaryrefslogtreecommitdiff
path: root/usr.bin/mg/main.c
diff options
context:
space:
mode:
authorKjell Wooding <kjell@cvs.openbsd.org>2006-07-17 14:11:56 +0000
committerKjell Wooding <kjell@cvs.openbsd.org>2006-07-17 14:11:56 +0000
commit32ec93ba4801a829863e6c4bf7fb9cb9493807d2 (patch)
tree9aa68e3bd2db12b7644d50e876808a7d12750016 /usr.bin/mg/main.c
parent491f53a2e25d4cf8c23713c23431ef717708a1c2 (diff)
Better usage() wording. Add -h to mean same. Some whitespace clean
Diffstat (limited to 'usr.bin/mg/main.c')
-rw-r--r--usr.bin/mg/main.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index aedd3315c73..80b3c0b7e05 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.52 2006/06/01 05:34:52 jason Exp $ */
+/* $OpenBSD: main.c,v 1.53 2006/07/17 14:11:55 kjell Exp $ */
/* This file is in the public domain. */
@@ -20,13 +20,24 @@ int thisflag; /* flags, this command */
int lastflag; /* flags, last command */
int curgoal; /* goal column */
int startrow; /* row to start */
-struct buffer *curbp; /* current buffer */
-struct buffer *bheadp; /* BUFFER list head */
-struct mgwin *curwp; /* current window */
-struct mgwin *wheadp; /* MGWIN listhead */
+struct buffer *curbp; /* current buffer */
+struct buffer *bheadp; /* BUFFER list head */
+struct mgwin *curwp; /* current window */
+struct mgwin *wheadp; /* MGWIN listhead */
char pat[NPAT]; /* pattern */
static void edinit(PF);
+static __dead void usage(void);
+
+extern char *__progname;
+
+static __dead void
+usage()
+{
+ fprintf(stderr, "usage: %s [+line] [-hn] [-f mode] [file ...]\n",
+ __progname);
+ exit(1);
+}
int
main(int argc, char **argv)
@@ -36,7 +47,7 @@ main(int argc, char **argv)
int o, i, nfiles;
int nobackups = 0;
- while ((o = getopt(argc, argv, "nf:")) != -1)
+ while ((o = getopt(argc, argv, "hnf:")) != -1)
switch (o) {
case 'n':
nobackups = 1;
@@ -47,8 +58,10 @@ main(int argc, char **argv)
"initial function");
init_fcn_name = optarg;
break;
+ case 'h':
+ /* FALLTHRU */
default:
- errx(1, "usage: mg [options] [file ...]");
+ usage();
}
argc -= optind;
argv += optind;