Allow minimum word length to be set on command line. Patch based on
one by Joey Hess <joeyh@debian.org>.
This commit is contained in:
parent
71a4ca8acd
commit
26891a9fd2
@ -1,4 +1,4 @@
|
||||
/* $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
|
||||
@ -38,7 +38,7 @@
|
||||
#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 */
|
||||
|
||||
@ -61,6 +61,7 @@ const char *const Noose_pict[] = {
|
||||
};
|
||||
|
||||
int Errors, Wordnum = 0;
|
||||
unsigned int Minlen = MINLEN;
|
||||
|
||||
double Average = 0.0;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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
|
||||
@ -38,7 +38,7 @@
|
||||
#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 */
|
||||
|
||||
@ -64,7 +64,7 @@ getword()
|
||||
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))
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $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.
|
||||
@ -42,6 +42,7 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl d Ar wordlist
|
||||
.Op Fl m Ar minlen
|
||||
.Sh DESCRIPTION
|
||||
In
|
||||
.Nm "" ,
|
||||
@ -55,6 +56,8 @@ and how many wrong guesses you have made on the screen in a graphic fashion.
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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
|
||||
@ -73,6 +73,7 @@ extern char Word[], Known[];
|
||||
extern const char *const Noose_pict[];
|
||||
|
||||
extern int Errors, Wordnum;
|
||||
extern unsigned int Minlen;
|
||||
|
||||
extern double Average;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $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
|
||||
@ -43,10 +43,11 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
|
||||
#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"
|
||||
|
||||
/*
|
||||
@ -62,14 +63,19 @@ main(argc, argv)
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user