diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-05-22 16:09:52 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-05-22 16:09:52 +0000 |
commit | 618595e7c72c0a8007302fa8e855074f0fe8a823 (patch) | |
tree | 1583aa6efc4e950215a5b3ce4b3e034d80e63d76 /usr.bin | |
parent | a00707167bd6b6442a9ccd6fa939dbe69b779fab (diff) | |
download | FreeBSD-src-618595e7c72c0a8007302fa8e855074f0fe8a823.zip FreeBSD-src-618595e7c72c0a8007302fa8e855074f0fe8a823.tar.gz |
Add a usage().
Print usage() if right before executing the specified command, it comes to be
that *argv is NULL (i.e. a flag was specified without a command being given).
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sccs/sccs.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/usr.bin/sccs/sccs.c b/usr.bin/sccs/sccs.c index 7ef5f79..6f0ec6d 100644 --- a/usr.bin/sccs/sccs.c +++ b/usr.bin/sccs/sccs.c @@ -296,6 +296,8 @@ char *gstrcat(char *, const char *, size_t); char *gstrcpy(char *, const char *, size_t); char *gstrncat(char *, const char *, size_t, size_t); +static void usage(void); + #define FBUFSIZ BUFSIZ #define PFILELG 120 @@ -345,8 +347,7 @@ main(int argc, char *argv[]) if (argc < 2) { - fprintf(stderr, "Usage: %s [flags] command [flags]\n", MyName); - exit(EX_USAGE); + usage(); } argv[argc] = NULL; @@ -392,11 +393,27 @@ main(int argc, char *argv[]) SccsPath = "."; } + if (*argv == NULL) + { + usage(); + } i = command(argv, FALSE, ""); exit(i); } /* +** USAGE -- print usage +** +** This function prints the usage for this program. +*/ +static void +usage(void) +{ + fprintf(stderr, "Usage: %s [flags] command [flags]\n", MyName); + exit(EX_USAGE); +} + +/* ** COMMAND -- look up and perform a command ** ** This routine is the guts of this program. Given an |