Be more helpful. Improve full help message. Special-case error for
authormdw <mdw>
Fri, 16 Feb 2001 21:45:19 +0000 (21:45 +0000)
committermdw <mdw>
Fri, 16 Feb 2001 21:45:19 +0000 (21:45 +0000)
empty command strings.

anag.c

diff --git a/anag.c b/anag.c
index f160fa1..724873d 100644 (file)
--- a/anag.c
+++ b/anag.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: anag.c,v 1.2 2001/02/07 09:09:11 mdw Exp $
+ * $Id: anag.c,v 1.3 2001/02/16 21:45:19 mdw Exp $
  *
  * Main driver for anag
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: anag.c,v $
+ * Revision 1.3  2001/02/16 21:45:19  mdw
+ * Be more helpful.  Improve full help message.  Special-case error for
+ * empty command strings.
+ *
  * Revision 1.2  2001/02/07 09:09:11  mdw
  * Fix spurious error when `-file' is used.
  *
@@ -64,6 +68,14 @@ static void help(FILE *fp)
   usage(fp);
   fputs("\n\
 Searches a wordlist, printing all of the words which match an expression.\n\
+\n\
+Options supported are:\n\
+\n\
+-h, --help             display this help text\n\
+-v, --version          display the program's version number\n\
+-u, --usage            display a very brief usage message\n\
+-f, --file FILE                read wordlist from FILE, not `" DICTIONARY "'\n\
+\n\
 The basic tests in the expression are:\n\
 \n\
 -anagram WORD          matches a full-length anagram\n\
@@ -387,6 +399,11 @@ static node *p_argv(int argc, const char *const argv[])
   ac = argc;
   ai = 1;
   p_next(&p);
+  if (p.t == O_EOF) {
+    usage(stderr);
+    pquis(stderr, "(Run `$ --help' for more detail.)\n");
+    exit(EXIT_FAILURE);
+  }
   p_expr(&p, &n);
   if (p.t != O_EOF) {
     die("syntax error near `%s': rubbish at end of line (too many `)'s?)",