mirror of
git://slackware.nl/current.git
synced 2024-12-29 10:25:00 +01:00
66b0761fe7
ap/cups-filters-1.22.1-x86_64-1.txz: Upgraded. y/bsd-games-2.17-x86_64-1.txz: Upgraded.
46 lines
1 KiB
Diff
46 lines
1 KiB
Diff
From: Peter Pentchev <roam@ringlet.net>
|
|
Date: Thu, 16 Feb 2012 22:37:50 +0100
|
|
Subject: hangman: Error out on 1000 unsuitable words. Closes: #610270
|
|
|
|
---
|
|
hangman/getword.c | 18 +++++++++++++++++-
|
|
1 file changed, 17 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/hangman/getword.c b/hangman/getword.c
|
|
index 1b5396a..dc42a53 100644
|
|
--- a/hangman/getword.c
|
|
+++ b/hangman/getword.c
|
|
@@ -50,8 +50,10 @@ getword()
|
|
FILE *inf;
|
|
char *wp, *gp;
|
|
long pos;
|
|
+ int tries;
|
|
|
|
inf = Dict;
|
|
+ tries = 0;
|
|
for (;;) {
|
|
pos = (double) rand() / (RAND_MAX + 1.0) * (double) Dict_size;
|
|
fseek(inf, pos, SEEK_SET);
|
|
@@ -66,7 +68,21 @@ getword()
|
|
if (!islower((unsigned char)*wp))
|
|
goto cont;
|
|
break;
|
|
-cont: ;
|
|
+cont:
|
|
+ if (++tries >= 1000) {
|
|
+ move(MESGY, MESGX);
|
|
+ deleteln();
|
|
+ deleteln();
|
|
+ deleteln();
|
|
+ move(MESGY, MESGX);
|
|
+ printw("No suitable word found, try using "
|
|
+ "another dictionary!");
|
|
+ leaveok(stdscr, FALSE);
|
|
+ refresh();
|
|
+ readch();
|
|
+ leaveok(stdscr, TRUE);
|
|
+ die(0);
|
|
+ }
|
|
}
|
|
gp = Known;
|
|
wp = Word;
|