X-Git-Url: https://git.distorted.org.uk/~mdw/anag/blobdiff_plain/6e4032210ea6c167fcf14c70ae6b18661c011310..162ffb5e5a4522b64f7fe891608b197d63f21535:/anag.c diff --git a/anag.c b/anag.c index 97b31c1..724873d 100644 --- a/anag.c +++ b/anag.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: anag.c,v 1.1 2001/02/04 17:14:42 mdw Exp $ + * $Id: anag.c,v 1.3 2001/02/16 21:45:19 mdw Exp $ * * Main driver for anag * @@ -29,6 +29,13 @@ /*----- 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. + * * Revision 1.1 2001/02/04 17:14:42 mdw * Initial checkin * @@ -61,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\ @@ -230,6 +245,7 @@ static unsigned nextopt(const char *const **arg) default: return (oo->tag); } + continue; bad: die("syntax error near `%s': unknown token type", av[ai - 1]); } @@ -383,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?)",