From: schwarze Date: Fri, 9 May 2014 23:39:10 +0000 (+0000) Subject: Fix a mini-bug reported by pjanzen@: X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e94b4bde53af0a2be95d8c634dcd8117f8e59e23;p=openbsd Fix a mini-bug reported by pjanzen@: When entering card names, you can use multiple words (like KING OF SPADES). If you entered more than one consecutive blank character between words, the function incard() took that as end-of-string and ignored the rest. Fix this by dropping duplicate blanks up front, in get_line(). Patch simplified by me, ok pjanzen@. While here, use beep(3) in an adjacent line instead of manually fiddling with control characters, suggested by pjanzen@. --- diff --git a/games/cribbage/io.c b/games/cribbage/io.c index dcb7e61df8e..8636c443f1d 100644 --- a/games/cribbage/io.c +++ b/games/cribbage/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.17 2014/05/09 03:13:24 schwarze Exp $ */ +/* $OpenBSD: io.c,v 1.18 2014/05/09 23:39:10 schwarze Exp $ */ /* $NetBSD: io.c,v 1.9 1997/07/09 06:25:47 phil Exp $ */ /*- @@ -526,6 +526,8 @@ get_line(void) for (pos = 0; (c = readchar()) != '\n'; clrtoeol(), refresh()) { if (c == -1) continue; + if (c == ' ' && (pos == 0 || linebuf[pos - 1] == ' ')) + continue; if (c == erasechar()) { if (pos > 0) { int i; @@ -540,10 +542,8 @@ get_line(void) move(oy, ox); continue; } - if (pos == 0 && c == ' ') - continue; - if (pos >= LINESIZE - 1 || !(isprint(c) || c == ' ')) { - putchar(CTRL('G')); + if (pos >= LINESIZE - 1 || !(isalnum(c) || c == ' ')) { + beep(); continue; } if (islower(c))