NetBSD-Bugs archive

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

bin/57164: Patch: Option for Cribbage to assume new game rather than exit



>Number:         57164
>Category:       bin
>Synopsis:       Adding -y flag to cribbage to assume 'Y' at "Another game?"
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 05 23:00:00 +0000 2023
>Originator:     greywolf%starwolf.com@localhost
>Release:        NetBSD 10.0_BETA
>Organization:
Star Wolf Innovations
>Environment:
	
	
System: NetBSD valentina.serenity.starwolf.com 10.0_BETA NetBSD 10.0_BETA (VALENTINA) #0: Tue Dec 27 14:17:36 PST 2022 greywolf%valentina.serenity.starwolf.com@localhost:/usr/src/sys/arch/amd64/compile/VALENTINA amd64
Architecture: x86_64
Machine: amd64
>Description:
	I have been frustrated by hitting a keystroke other than 'Y' --
	usually the space bar -- at the end of a game of cribbage, more
	often than not, and I have thought that it would be nice to have
	a flag by which to assume a positive response than a negative one.
>How-To-Repeat:
	cribbage
	[play a game]
	hit any other key besides 'y'.
>Fix:
### patches included below ###

--- crib.c.orig	2023-01-05 13:14:37.123861323 -0800
+++ crib.c	2023-01-05 13:21:55.528365976 -0800
@@ -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) {

--- cribbage.6.orig	2023-01-05 13:20:53.629462956 -0800
+++ cribbage.6	2023-01-05 13:20:16.027514907 -0800
@@ -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

--- extern.c.orig	2023-01-05 13:18:27.221983865 -0800
+++ extern.c	2023-01-05 13:16:48.957338493 -0800
@@ -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 */
 

>Unformatted:
 	
 	


Home | Main Index | Thread Index | Old Index