Project

General

Profile

Actions

Bug #1787

closed

Hangman: case-sensitive problem?

Added by Anonymous over 13 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

While playing hangman, the word offered was 'Theocritan', but when I guessed
't', it only filled in the second 't'. I haven't looked at the code, but
I'm guessing that it's not recognizing the uppercase T.

Tim


Files

unnamed (389 Bytes) unnamed Anonymous, 06/23/2010 09:35 PM
unnamed (2.14 KB) unnamed dylan, 06/24/2010 03:55 AM
Actions #1

Updated by dylan over 13 years ago

The code makes all your answers lower case.

This patch will also compare the uppercase version of your letter.

diff --git a/games/hangman/getguess.c b/games/hangman/getguess.c
index b5b60c0..8a40c7c 100644
--- a/games/hangman/getguess.c
++ b/games/hangman/getguess.c
@ -71,8 +71,8 @ getguess(void)
Guessed[ch - 'a'] = TRUE;
correct = FALSE;
for (i = 0; Word[i] != '\0'; i
+) {
- if (Word[i] == ch) {
- Known[i] = ch;
+ if (Word[i] ch || Word[i] toupper(ch) ) {
+ Known[i] = Word[i];
correct = TRUE;
}
}

Dylan

On 06/23/2010 02:33 PM, Tim Darby wrote:

While playing hangman, the word offered was 'Theocritan', but when I
guessed 't', it only filled in the second 't'. I haven't looked at
the code, but I'm guessing that it's not recognizing the uppercase T.

Tim

Actions #2

Updated by swildner over 13 years ago

On 6/24/2010 5:53, Dylan Reinhold wrote:

The code makes all your answers lower case.

This patch will also compare the uppercase version of your letter.

I've fixed it. However I took OpenBSD's code (oops, should have noted
that in the commit message) which calls toupper() only once.

Regards,
Sascha

Actions #3

Updated by swildner over 13 years ago

Committed -> 09871f9d92dfbc060605c073f2615ebca6c12c94

Thanks, guys

Actions

Also available in: Atom PDF