Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/cribbage PR/57164: Greywolf: Add -y to cribbage to kee...



details:   https://anonhg.NetBSD.org/src/rev/851edadf63ff
branches:  trunk
changeset: 372939:851edadf63ff
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jan 06 17:13:46 2023 +0000

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

diffstat:

 games/cribbage/crib.c     |  16 +++++++++++-----
 games/cribbage/cribbage.6 |   5 ++++-
 games/cribbage/extern.c   |   5 +++--
 3 files changed, 18 insertions(+), 8 deletions(-)

diffs (98 lines):

diff -r 40b2c019d78d -r 851edadf63ff games/cribbage/crib.c
--- a/games/cribbage/crib.c     Fri Jan 06 17:06:33 2023 +0000
+++ b/games/cribbage/crib.c     Fri Jan 06 17:13:46 2023 +0000
@@ -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 @@
 #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 @@
                        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 @@
                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 @@
                        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) {
diff -r 40b2c019d78d -r 851edadf63ff games/cribbage/cribbage.6
--- a/games/cribbage/cribbage.6 Fri Jan 06 17:06:33 2023 +0000
+++ b/games/cribbage/cribbage.6 Fri Jan 06 17:13:46 2023 +0000
@@ -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 @@
 .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
diff -r 40b2c019d78d -r 851edadf63ff games/cribbage/extern.c
--- a/games/cribbage/extern.c   Fri Jan 06 17:06:33 2023 +0000
+++ b/games/cribbage/extern.c   Fri Jan 06 17:13:46 2023 +0000
@@ -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        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 */
 



Home | Main Index | Thread Index | Old Index