summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-05-09 23:39:10 +0000
committerschwarze <schwarze@openbsd.org>2014-05-09 23:39:10 +0000
commite94b4bde53af0a2be95d8c634dcd8117f8e59e23 (patch)
treede5f32a7dff44e70955913b72da338c369e338c3
parentTypo in C99 field initializer introduced in r1.3; (diff)
downloadwireguard-openbsd-e94b4bde53af0a2be95d8c634dcd8117f8e59e23.tar.xz
wireguard-openbsd-e94b4bde53af0a2be95d8c634dcd8117f8e59e23.zip
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@.
-rw-r--r--games/cribbage/io.c10
1 files changed, 5 insertions, 5 deletions
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))