From: mdw Date: Fri, 16 Feb 2001 21:45:19 +0000 (+0000) Subject: Be more helpful. Improve full help message. Special-case error for X-Git-Tag: 1.0.0~4 X-Git-Url: https://git.distorted.org.uk/~mdw/anag/commitdiff_plain/2668675ca09a97897b3a1ea88bc5101e5cfe40a1 Be more helpful. Improve full help message. Special-case error for empty command strings. --- diff --git a/anag.c b/anag.c index f160fa1..724873d 100644 --- 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 * @@ -29,6 +29,10 @@ /*----- 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?)",