mirror of
https://github.com/vattam/BSDGames.git
synced 2025-12-20 19:04:49 +00:00
* Added -m option to hangman to set MINLEN. Closes: #129998
git-svn-id: file:///srv/svn/joey/bsdgames-trunk@5180 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
6
debian/changelog
vendored
6
debian/changelog
vendored
@@ -1,3 +1,9 @@
|
|||||||
|
bsdgames (2.13-3) unstable; urgency=low
|
||||||
|
|
||||||
|
* Added -m option to hangman to set MINLEN. Closes: #129998
|
||||||
|
|
||||||
|
-- Joey Hess <joeyh@debian.org> Sat, 19 Jan 2002 18:04:06 -0500
|
||||||
|
|
||||||
bsdgames (2.13-2) unstable; urgency=low
|
bsdgames (2.13-2) unstable; urgency=low
|
||||||
|
|
||||||
* Fixed bad merge (that's why sail was broken).
|
* Fixed bad merge (that's why sail was broken).
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: extern.c,v 1.4 1997/10/11 01:16:27 lukem Exp $ */
|
/* $NetBSD: extern.c,v 1.6 1999/09/17 20:45:48 jsm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
|
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: extern.c,v 1.4 1997/10/11 01:16:27 lukem Exp $");
|
__RCSID("$NetBSD: extern.c,v 1.6 1999/09/17 20:45:48 jsm Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@@ -61,6 +61,7 @@ const char *const Noose_pict[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int Errors, Wordnum = 0;
|
int Errors, Wordnum = 0;
|
||||||
|
unsigned int Minlen = MINLEN;
|
||||||
|
|
||||||
double Average = 0.0;
|
double Average = 0.0;
|
||||||
|
|
||||||
@@ -74,6 +75,8 @@ const ERR_POS Err_pos[MAXERRS] = {
|
|||||||
{5, 11, '\\'}
|
{5, 11, '\\'}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *Dict_name = _PATH_DICT;
|
||||||
|
|
||||||
FILE *Dict = NULL;
|
FILE *Dict = NULL;
|
||||||
|
|
||||||
off_t Dict_size;
|
off_t Dict_size;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: getword.c,v 1.5 1997/10/11 01:16:30 lukem Exp $ */
|
/* $NetBSD: getword.c,v 1.6 1999/09/08 21:57:17 jsm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)getword.c 8.1 (Berkeley) 5/31/93";
|
static char sccsid[] = "@(#)getword.c 8.1 (Berkeley) 5/31/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: getword.c,v 1.5 1997/10/11 01:16:30 lukem Exp $");
|
__RCSID("$NetBSD: getword.c,v 1.6 1999/09/08 21:57:17 jsm Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@@ -58,13 +58,13 @@ getword()
|
|||||||
inf = Dict;
|
inf = Dict;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
pos = (double) rand() / (RAND_MAX + 1.0) * (double) Dict_size;
|
pos = (double) rand() / (RAND_MAX + 1.0) * (double) Dict_size;
|
||||||
fseek(inf, pos, 0);
|
fseek(inf, pos, SEEK_SET);
|
||||||
if (fgets(Word, BUFSIZ, inf) == NULL)
|
if (fgets(Word, BUFSIZ, inf) == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (fgets(Word, BUFSIZ, inf) == NULL)
|
if (fgets(Word, BUFSIZ, inf) == NULL)
|
||||||
continue;
|
continue;
|
||||||
Word[strlen(Word) - 1] = '\0';
|
Word[strlen(Word) - 1] = '\0';
|
||||||
if (strlen(Word) < MINLEN)
|
if (strlen(Word) < Minlen)
|
||||||
continue;
|
continue;
|
||||||
for (wp = Word; *wp; wp++)
|
for (wp = Word; *wp; wp++)
|
||||||
if (!islower(*wp))
|
if (!islower(*wp))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.\" $NetBSD: hangman.6,v 1.6 1997/10/11 01:16:32 lukem Exp $
|
.\" $NetBSD: hangman.6,v 1.7 1999/09/17 20:45:49 jsm Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1983, 1993
|
.\" Copyright (c) 1983, 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
@@ -41,6 +41,8 @@
|
|||||||
.Nd Computer version of the game hangman
|
.Nd Computer version of the game hangman
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
|
.Op Fl d Ar wordlist
|
||||||
|
.Op Fl m Ar minlen
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
In
|
In
|
||||||
.Nm "" ,
|
.Nm "" ,
|
||||||
@@ -48,6 +50,15 @@ the computer picks a word from the on-line word list
|
|||||||
and you must try to guess it.
|
and you must try to guess it.
|
||||||
The computer keeps track of which letters have been guessed
|
The computer keeps track of which letters have been guessed
|
||||||
and how many wrong guesses you have made on the screen in a graphic fashion.
|
and how many wrong guesses you have made on the screen in a graphic fashion.
|
||||||
|
.Sh OPTIONS
|
||||||
|
.Bl -tag -width flag
|
||||||
|
.It Fl d
|
||||||
|
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
|
.Sh FILES
|
||||||
.Bl -tag -width @hangman_wordsfile@ -compact
|
.Bl -tag -width @hangman_wordsfile@ -compact
|
||||||
.It Pa @hangman_wordsfile@
|
.It Pa @hangman_wordsfile@
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: hangman.h,v 1.7 1998/09/11 13:42:03 hubertf Exp $ */
|
/* $NetBSD: hangman.h,v 1.10 1999/09/17 20:45:49 jsm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@@ -73,18 +73,21 @@ extern char Word[], Known[];
|
|||||||
extern const char *const Noose_pict[];
|
extern const char *const Noose_pict[];
|
||||||
|
|
||||||
extern int Errors, Wordnum;
|
extern int Errors, Wordnum;
|
||||||
|
extern unsigned int Minlen;
|
||||||
|
|
||||||
extern double Average;
|
extern double Average;
|
||||||
|
|
||||||
extern const ERR_POS Err_pos[];
|
extern const ERR_POS Err_pos[];
|
||||||
|
|
||||||
|
extern const char *Dict_name;
|
||||||
|
|
||||||
extern FILE *Dict;
|
extern FILE *Dict;
|
||||||
|
|
||||||
extern off_t Dict_size;
|
extern off_t Dict_size;
|
||||||
|
|
||||||
void die __P((int));
|
void die __P((int)) __attribute__((__noreturn__));
|
||||||
void endgame __P((void));
|
void endgame __P((void));
|
||||||
int main __P((void));
|
int main __P((int, char *[]));
|
||||||
void getguess __P((void));
|
void getguess __P((void));
|
||||||
void getword __P((void));
|
void getword __P((void));
|
||||||
void playgame __P((void));
|
void playgame __P((void));
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: main.c,v 1.5 1998/09/11 13:42:03 hubertf Exp $ */
|
/* $NetBSD: main.c,v 1.9 2000/05/08 07:56:04 mycroft Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
|
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: main.c,v 1.5 1998/09/11 13:42:03 hubertf Exp $");
|
__RCSID("$NetBSD: main.c,v 1.9 2000/05/08 07:56:04 mycroft Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@@ -53,11 +53,34 @@ __RCSID("$NetBSD: main.c,v 1.5 1998/09/11 13:42:03 hubertf Exp $");
|
|||||||
* This game written by Ken Arnold.
|
* This game written by Ken Arnold.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
main(void)
|
main(argc, argv)
|
||||||
|
int argc;
|
||||||
|
char *argv[];
|
||||||
{
|
{
|
||||||
|
int ch;
|
||||||
|
|
||||||
/* Revoke setgid privileges */
|
/* Revoke setgid privileges */
|
||||||
setregid(getgid(), getgid());
|
setregid(getgid(), getgid());
|
||||||
|
|
||||||
|
while ((ch = getopt(argc, argv, "m:d:")) != -1) {
|
||||||
|
switch (ch) {
|
||||||
|
case 'd':
|
||||||
|
Dict_name = optarg;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
Minlen = atoi(optarg);
|
||||||
|
if (Minlen < 2) {
|
||||||
|
fprintf(stderr, "minlen too short\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
default:
|
||||||
|
(void)fprintf(stderr, "usage: hangman [-d wordlist] [-m minlen]\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
initscr();
|
initscr();
|
||||||
signal(SIGINT, die);
|
signal(SIGINT, die);
|
||||||
setup();
|
setup();
|
||||||
@@ -74,7 +97,7 @@ main(void)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
die(dummy)
|
die(dummy)
|
||||||
int dummy __attribute__((unused));
|
int dummy __attribute__((__unused__));
|
||||||
{
|
{
|
||||||
mvcur(0, COLS - 1, LINES - 1, 0);
|
mvcur(0, COLS - 1, LINES - 1, 0);
|
||||||
endwin();
|
endwin();
|
||||||
|
|||||||
Reference in New Issue
Block a user