CVS commit: src/games/hangman
Module Name:src Committed By: dholland Date: Sun Jul 12 02:34:54 UTC 2020 Modified Files: src/games/hangman: prdata.c Log Message: Avoid messing up the display when too many letters are guessed at once. The field to put them in was made 26 characters wide... but includes the string "Guessed: ". So if you get to 17 it wraps to the next line and clreol()'s it. Instead, when reaching this point step on the "Guessed:" string instead. Reported by phil@. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/games/hangman/prdata.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/hangman/prdata.c diff -u src/games/hangman/prdata.c:1.7 src/games/hangman/prdata.c:1.8 --- src/games/hangman/prdata.c:1.7 Sat Oct 13 21:03:09 2012 +++ src/games/hangman/prdata.c Sun Jul 12 02:34:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: prdata.c,v 1.7 2012/10/13 21:03:09 dholland Exp $ */ +/* $NetBSD: prdata.c,v 1.8 2020/07/12 02:34:54 dholland Exp $ */ /*- * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)prdata.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: prdata.c,v 1.7 2012/10/13 21:03:09 dholland Exp $"); +__RCSID("$NetBSD: prdata.c,v 1.8 2020/07/12 02:34:54 dholland Exp $"); #endif #endif /* not lint */ @@ -47,9 +47,17 @@ __RCSID("$NetBSD: prdata.c,v 1.7 2012/10 void prdata(void) { - int i; + int i, n, l; - move(GUESSY, GUESSX + sizeof "Guessed: "); + for (i = n = 0; i < 26; i++) + if (Guessed[i]) + n++; + + move(GUESSY, GUESSX); + l = sizeof "Guessed: "; + if (GUESSX + l + n < COLS) { + addstr("Guessed: "); + } for (i = 0; i < 26; i++) if (Guessed[i]) addch(i + 'a');
CVS commit: src/games/hangman
Module Name:src Committed By: dholland Date: Sat Oct 13 21:01:13 UTC 2012 Modified Files: src/games/hangman: getguess.c playgame.c Log Message: Pass -Wstrict-overflow; while here, use curses TRUE and FALSE only with curses. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/games/hangman/getguess.c cvs rdiff -u -r1.6 -r1.7 src/games/hangman/playgame.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/hangman/getguess.c diff -u src/games/hangman/getguess.c:1.9 src/games/hangman/getguess.c:1.10 --- src/games/hangman/getguess.c:1.9 Tue Jun 19 05:45:00 2012 +++ src/games/hangman/getguess.c Sat Oct 13 21:01:13 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: getguess.c,v 1.9 2012/06/19 05:45:00 dholland Exp $ */ +/* $NetBSD: getguess.c,v 1.10 2012/10/13 21:01:13 dholland Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = @(#)getguess.c 8.1 (Berkeley) 5/31/93; #else -__RCSID($NetBSD: getguess.c,v 1.9 2012/06/19 05:45:00 dholland Exp $); +__RCSID($NetBSD: getguess.c,v 1.10 2012/10/13 21:01:13 dholland Exp $); #endif #endif /* not lint */ @@ -76,12 +76,12 @@ getguess(void) move(MESGY, MESGX); clrtoeol(); - Guessed[ch - 'a'] = TRUE; - correct = FALSE; + Guessed[ch - 'a'] = true; + correct = false; for (i = 0; Word[i] != '\0'; i++) if (Word[i] == ch) { Known[i] = ch; - correct = TRUE; + correct = true; } if (!correct) Errors++; Index: src/games/hangman/playgame.c diff -u src/games/hangman/playgame.c:1.6 src/games/hangman/playgame.c:1.7 --- src/games/hangman/playgame.c:1.6 Tue Jun 19 05:45:00 2012 +++ src/games/hangman/playgame.c Sat Oct 13 21:01:13 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: playgame.c,v 1.6 2012/06/19 05:45:00 dholland Exp $ */ +/* $NetBSD: playgame.c,v 1.7 2012/10/13 21:01:13 dholland Exp $ */ /*- * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = @(#)playgame.c 8.1 (Berkeley) 5/31/93; #else -__RCSID($NetBSD: playgame.c,v 1.6 2012/06/19 05:45:00 dholland Exp $); +__RCSID($NetBSD: playgame.c,v 1.7 2012/10/13 21:01:13 dholland Exp $); #endif #endif /* not lint */ @@ -47,13 +47,13 @@ __RCSID($NetBSD: playgame.c,v 1.6 2012/ void playgame(void) { - bool *bp; + int i; getword(); Errors = 0; - bp = Guessed; - while (bp Guessed[26]) - *bp++ = FALSE; + for (i=0; i26; i++) { + Guessed[i] = false; + } while (Errors MAXERRS strchr(Known, '-') != NULL) { prword(); prdata();
CVS commit: src/games/hangman
Module Name:src Committed By: dholland Date: Sat Oct 13 21:03:10 UTC 2012 Modified Files: src/games/hangman: prdata.c Log Message: Pass -Wstrict-overflow To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/games/hangman/prdata.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/hangman/prdata.c diff -u src/games/hangman/prdata.c:1.6 src/games/hangman/prdata.c:1.7 --- src/games/hangman/prdata.c:1.6 Tue Jun 19 05:45:00 2012 +++ src/games/hangman/prdata.c Sat Oct 13 21:03:09 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: prdata.c,v 1.6 2012/06/19 05:45:00 dholland Exp $ */ +/* $NetBSD: prdata.c,v 1.7 2012/10/13 21:03:09 dholland Exp $ */ /*- * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = @(#)prdata.c 8.1 (Berkeley) 5/31/93; #else -__RCSID($NetBSD: prdata.c,v 1.6 2012/06/19 05:45:00 dholland Exp $); +__RCSID($NetBSD: prdata.c,v 1.7 2012/10/13 21:03:09 dholland Exp $); #endif #endif /* not lint */ @@ -47,13 +47,12 @@ __RCSID($NetBSD: prdata.c,v 1.6 2012/06 void prdata(void) { - bool *bp; + int i; move(GUESSY, GUESSX + sizeof Guessed: ); - bp = Guessed; - while (bp Guessed[26]) - if (*bp++) - addch((bp - Guessed) + 'a' - 1); + for (i = 0; i 26; i++) + if (Guessed[i]) + addch(i + 'a'); clrtoeol(); mvprintw(NUMBERY, NUMBERX + sizeof Word #: , %d, Wordnum); mvprintw(AVGY, AVGX + sizeof Current Average: , %.3f,
CVS commit: src/games/hangman
Module Name:src Committed By: dholland Date: Tue Jun 19 05:45:00 UTC 2012 Modified Files: src/games/hangman: endgame.c getguess.c getword.c main.c playgame.c prdata.c prman.c prword.c setup.c Log Message: WARNS=5 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/games/hangman/endgame.c \ src/games/hangman/playgame.c src/games/hangman/prdata.c \ src/games/hangman/prman.c src/games/hangman/prword.c cvs rdiff -u -r1.8 -r1.9 src/games/hangman/getguess.c cvs rdiff -u -r1.9 -r1.10 src/games/hangman/getword.c cvs rdiff -u -r1.14 -r1.15 src/games/hangman/main.c cvs rdiff -u -r1.10 -r1.11 src/games/hangman/setup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/hangman/endgame.c diff -u src/games/hangman/endgame.c:1.5 src/games/hangman/endgame.c:1.6 --- src/games/hangman/endgame.c:1.5 Thu Aug 7 09:37:20 2003 +++ src/games/hangman/endgame.c Tue Jun 19 05:45:00 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: endgame.c,v 1.5 2003/08/07 09:37:20 agc Exp $ */ +/* $NetBSD: endgame.c,v 1.6 2012/06/19 05:45:00 dholland Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = @(#)endgame.c 8.1 (Berkeley) 5/31/93; #else -__RCSID($NetBSD: endgame.c,v 1.5 2003/08/07 09:37:20 agc Exp $); +__RCSID($NetBSD: endgame.c,v 1.6 2012/06/19 05:45:00 dholland Exp $); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ __RCSID($NetBSD: endgame.c,v 1.5 2003/0 * Do what's necessary at the end of the game */ void -endgame() +endgame(void) { char ch; Index: src/games/hangman/playgame.c diff -u src/games/hangman/playgame.c:1.5 src/games/hangman/playgame.c:1.6 --- src/games/hangman/playgame.c:1.5 Thu Aug 7 09:37:22 2003 +++ src/games/hangman/playgame.c Tue Jun 19 05:45:00 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: playgame.c,v 1.5 2003/08/07 09:37:22 agc Exp $ */ +/* $NetBSD: playgame.c,v 1.6 2012/06/19 05:45:00 dholland Exp $ */ /*- * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = @(#)playgame.c 8.1 (Berkeley) 5/31/93; #else -__RCSID($NetBSD: playgame.c,v 1.5 2003/08/07 09:37:22 agc Exp $); +__RCSID($NetBSD: playgame.c,v 1.6 2012/06/19 05:45:00 dholland Exp $); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ __RCSID($NetBSD: playgame.c,v 1.5 2003/ * play a game */ void -playgame() +playgame(void) { bool *bp; Index: src/games/hangman/prdata.c diff -u src/games/hangman/prdata.c:1.5 src/games/hangman/prdata.c:1.6 --- src/games/hangman/prdata.c:1.5 Thu Aug 7 09:37:22 2003 +++ src/games/hangman/prdata.c Tue Jun 19 05:45:00 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: prdata.c,v 1.5 2003/08/07 09:37:22 agc Exp $ */ +/* $NetBSD: prdata.c,v 1.6 2012/06/19 05:45:00 dholland Exp $ */ /*- * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = @(#)prdata.c 8.1 (Berkeley) 5/31/93; #else -__RCSID($NetBSD: prdata.c,v 1.5 2003/08/07 09:37:22 agc Exp $); +__RCSID($NetBSD: prdata.c,v 1.6 2012/06/19 05:45:00 dholland Exp $); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ __RCSID($NetBSD: prdata.c,v 1.5 2003/08 * Print out the current guesses */ void -prdata() +prdata(void) { bool *bp; Index: src/games/hangman/prman.c diff -u src/games/hangman/prman.c:1.5 src/games/hangman/prman.c:1.6 --- src/games/hangman/prman.c:1.5 Thu Aug 7 09:37:22 2003 +++ src/games/hangman/prman.c Tue Jun 19 05:45:00 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: prman.c,v 1.5 2003/08/07 09:37:22 agc Exp $ */ +/* $NetBSD: prman.c,v 1.6 2012/06/19 05:45:00 dholland Exp $ */ /*- * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = @(#)prman.c 8.1 (Berkeley) 5/31/93; #else -__RCSID($NetBSD: prman.c,v 1.5 2003/08/07 09:37:22 agc Exp $); +__RCSID($NetBSD: prman.c,v 1.6 2012/06/19 05:45:00 dholland Exp $); #endif #endif /* not lint */ @@ -46,7 +46,7 @@ __RCSID($NetBSD: prman.c,v 1.5 2003/08/ * of incorrect guesses. */ void -prman() +prman(void) { int i; Index: src/games/hangman/prword.c diff -u src/games/hangman/prword.c:1.5 src/games/hangman/prword.c:1.6 --- src/games/hangman/prword.c:1.5 Thu Aug 7 09:37:22 2003 +++ src/games/hangman/prword.c Tue Jun 19 05:45:00 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: prword.c,v 1.5 2003/08/07 09:37:22 agc Exp $ */ +/* $NetBSD: prword.c,v 1.6 2012/06/19 05:45:00 dholland Exp $ */ /*- * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = @(#)prword.c 8.1 (Berkeley) 5/31/93; #else -__RCSID($NetBSD: prword.c,v 1.5 2003/08/07 09:37:22 agc Exp $); +__RCSID($NetBSD: prword.c,v 1.6 2012/06/19 05:45:00 dholland Exp $); #endif #endif /* not lint */ @@ -45,7 +45,7 @@ __RCSID($NetBSD: prword.c,v 1.5 2003/08 * Print out the current state of the word */ void -prword() +prword(void) { move(KNOWNY, KNOWNX + sizeof Word: ); addstr(Known); Index: src/games/hangman/getguess.c diff -u src/games/hangman/getguess.c:1.8 src/games/hangman/getguess.c:1.9 ---