PR/57164: Greywolf: Add -y to cribbage to keep playing without asking

This commit is contained in:
christos 2023-01-06 17:13:46 +00:00
parent c726706b20
commit ab841a2491
3 changed files with 18 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: crib.c,v 1.25 2012/10/13 20:36:06 dholland Exp $ */
/* $NetBSD: crib.c,v 1.26 2023/01/06 17:13:46 christos Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#if 0
static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: crib.c,v 1.25 2012/10/13 20:36:06 dholland Exp $");
__RCSID("$NetBSD: crib.c,v 1.26 2023/01/06 17:13:46 christos Exp $");
#endif
#endif /* not lint */
@ -97,7 +97,7 @@ main(int argc, char *argv[])
err(1, "fcntl F_SETFD");
}
while ((ch = getopt(argc, argv, "eqr")) != -1)
while ((ch = getopt(argc, argv, "eqry")) != -1)
switch (ch) {
case 'e':
explain = TRUE;
@ -108,9 +108,12 @@ main(int argc, char *argv[])
case 'r':
rflag = TRUE;
break;
case 'y':
yes = TRUE;
break;
case '?':
default:
(void) fprintf(stderr, "usage: cribbage [-eqr]\n");
(void) fprintf(stderr, "usage: cribbage [-eqry]\n");
exit(1);
}
@ -154,7 +157,10 @@ main(int argc, char *argv[])
glimit = (getuchar() == 'S' ? SGAME : LGAME);
game();
msg("Another game? ");
playing = (getuchar() == 'Y');
if (!yes)
playing = (getuchar() == 'Y');
else
playing = (getuchar() != 'N');
} while (playing);
if (f != NULL) {

View File

@ -1,4 +1,4 @@
.\" $NetBSD: cribbage.6,v 1.11 2003/08/07 09:37:09 agc Exp $
.\" $NetBSD: cribbage.6,v 1.12 2023/01/06 17:13:46 christos Exp $
.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
@ -61,6 +61,9 @@ users who have played the game without specifying this option.
.It Fl r
Instead of asking the player to cut the deck, the program will randomly
cut the deck.
.It Fl y
Assume 'Y' to the query for another game if 'Y' is not explicitly typed
(default is to exit unless 'Y' is typed).
.El
.Pp
.Nm

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.c,v 1.7 2003/08/07 09:37:10 agc Exp $ */
/* $NetBSD: extern.c,v 1.8 2023/01/06 17:13:46 christos Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: extern.c,v 1.7 2003/08/07 09:37:10 agc Exp $");
__RCSID("$NetBSD: extern.c,v 1.8 2023/01/06 17:13:46 christos Exp $");
#endif
#endif /* not lint */
@ -47,6 +47,7 @@ BOOLEAN explain = FALSE; /* player mistakes explained */
BOOLEAN iwon = FALSE; /* if comp won last game */
BOOLEAN quiet = FALSE; /* if suppress random mess */
BOOLEAN rflag = FALSE; /* if all cuts random */
BOOLEAN yes = FALSE; /* default 'y' to "Another game?" */
char explan[128]; /* explanation */