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@.
This commit is contained in:
dholland 2020-07-12 02:34:54 +00:00
parent 1594258707
commit 7ca3fbbe70
1 changed files with 12 additions and 4 deletions

View File

@ -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/13 21:03:09 dholland Exp $");
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');