one by Joey Hess <joeyh@debian.org>.
-/* $NetBSD: extern.c,v 1.6 1999/09/17 20:45:48 jsm Exp $ */
+/* $NetBSD: extern.c,v 1.7 2002/01/20 00:42:51 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: extern.c,v 1.6 1999/09/17 20:45:48 jsm Exp $");
+__RCSID("$NetBSD: extern.c,v 1.7 2002/01/20 00:42:51 jsm Exp $");
#endif
#endif /* not lint */
};
int Errors, Wordnum = 0;
+unsigned int Minlen = MINLEN;
double Average = 0.0;
-/* $NetBSD: getword.c,v 1.6 1999/09/08 21:57:17 jsm Exp $ */
+/* $NetBSD: getword.c,v 1.7 2002/01/20 00:42:51 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)getword.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: getword.c,v 1.6 1999/09/08 21:57:17 jsm Exp $");
+__RCSID("$NetBSD: getword.c,v 1.7 2002/01/20 00:42:51 jsm Exp $");
#endif
#endif /* not lint */
if (fgets(Word, BUFSIZ, inf) == NULL)
continue;
Word[strlen(Word) - 1] = '\0';
- if (strlen(Word) < MINLEN)
+ if (strlen(Word) < Minlen)
continue;
for (wp = Word; *wp; wp++)
if (!islower(*wp))
-.\" $NetBSD: hangman.6,v 1.7 1999/09/17 20:45:49 jsm Exp $
+.\" $NetBSD: hangman.6,v 1.8 2002/01/20 00:42:51 jsm Exp $
.\"
.\" Copyright (c) 1983, 1993
.\" The Regents of the University of California. All rights reserved.
.Sh SYNOPSIS
.Nm
.Op Fl d Ar wordlist
+.Op Fl m Ar minlen
.Sh DESCRIPTION
In
.Nm "" ,
Use the specified
.Ar wordlist
instead of the default one named below.
+.It Fl m
+Set the minimum word length to use. The default is 6 letters.
.El
.Sh FILES
.Bl -tag -width /usr/share/dict/words -compact
-/* $NetBSD: hangman.h,v 1.10 1999/09/17 20:45:49 jsm Exp $ */
+/* $NetBSD: hangman.h,v 1.11 2002/01/20 00:42:51 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
extern const char *const Noose_pict[];
extern int Errors, Wordnum;
+extern unsigned int Minlen;
extern double Average;
-/* $NetBSD: main.c,v 1.9 2000/05/08 07:56:04 mycroft Exp $ */
+/* $NetBSD: main.c,v 1.10 2002/01/20 00:42:51 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: main.c,v 1.9 2000/05/08 07:56:04 mycroft Exp $");
+__RCSID("$NetBSD: main.c,v 1.10 2002/01/20 00:42:51 jsm Exp $");
#endif
#endif /* not lint */
+#include <err.h>
#include "hangman.h"
/*
/* Revoke setgid privileges */
setgid(getgid());
- while ((ch = getopt(argc, argv, "d:")) != -1) {
+ while ((ch = getopt(argc, argv, "d:m:")) != -1) {
switch (ch) {
case 'd':
Dict_name = optarg;
break;
+ case 'm':
+ Minlen = atoi(optarg);
+ if (Minlen < 2)
+ errx(1, "minimum word length too short");
+ break;
case '?':
default:
- (void)fprintf(stderr, "usage: hangman [-d wordlist]\n");
+ (void)fprintf(stderr, "usage: hangman [-d wordlist] [-m minlen]\n");
exit(1);
}
}