[PATCH] games/canfield WARNS6

Peter Avalos pavalos at theshell.com
Mon Aug 1 01:00:43 PDT 2005


Here's a patch that brings games/canfield to WARNS6.

http://www.theshell.com/~pavalos/wip/canfield.diff

--Peter


Index: games/canfield/canfield/Makefile
===================================================================
RCS file: /home/dcvs/src/games/canfield/canfield/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- games/canfield/canfield/Makefile	17 Jun 2003 04:25:23 -0000	1.2
+++ games/canfield/canfield/Makefile	1 Aug 2005 05:48:52 -0000
@@ -4,10 +4,11 @@
 
 PROG=	canfield
 MAN=	canfield.6
-DPADD=	${LIBCURSES} ${LIBTERMCAP} ${LIBCOMPAT}
-LDADD=	-lcurses -ltermcap -lcompat
+DPADD=	${LIBCURSES}
+LDADD=	-lcurses
 HIDEGAME=hidegame
 MLINKS=	canfield.6 cfscores.6
+WARNS?=	6
 
 beforeinstall:
 .if !exists(${DESTDIR}/var/games/cfscores)
Index: games/canfield/canfield/canfield.c
===================================================================
RCS file: /home/dcvs/src/games/canfield/canfield/canfield.c,v
retrieving revision 1.3
diff -u -r1.3 canfield.c
--- games/canfield/canfield/canfield.c	12 Nov 2003 14:53:52 -0000	1.3
+++ games/canfield/canfield/canfield.c	1 Aug 2005 07:48:58 -0000
@@ -52,7 +52,6 @@
 #include <curses.h>
 #include <ctype.h>
 #include <signal.h>
-#include <termios.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
@@ -190,52 +189,52 @@
 time_t acctstart;
 int dbfd = -1;
 
-void askquit (int);
-void cleanup (int);
-void cleanupboard (void);
-void clearabovemovebox (void);
-void clearbelowmovebox (void);
-void clearmsg (void);
-void clearstat (void);
-void destinerror (void);
-bool diffcolor (struct cardtype *, struct cardtype *);
-void dumberror (void);
-bool finish (void);
-void fndbase (struct cardtype **, int, int);
-void getcmd (int, int, char *);
-void initall (void);
-void initdeck (struct cardtype *[]);
-void initgame (void);
-void instruct (void);
-void makeboard (void);
-void movebox (void);
-void movecard (void);
-void movetofound (struct cardtype **, int);
-void movetotalon (void);
-bool notempty (struct cardtype *);
-void printbottombettingbox (void);
-void printbottominstructions (void);
-void printcard (int, int, struct cardtype *);
-void printrank (int, int, struct cardtype *, bool);
-void printtopbettingbox (void);
-void printtopinstructions (void);
-bool rankhigher (struct cardtype *, int);
-bool ranklower (struct cardtype *, struct cardtype *);
-void removecard (int, int);
-bool samesuit (struct cardtype *, int);
-void showcards (void);
-void showstat (void);
-void shuffle (struct cardtype *[]);
-void simpletableau (struct cardtype **, int);
-void startgame (void);
-void suspend (void);
-bool tabok (struct cardtype *, int);
-void tabprint (int, int);
-void tabtotab (int, int);
-void transit (struct cardtype **, struct cardtype **);
-void updatebettinginfo (void);
-void usedstock (void);
-void usedtalon (void);
+static void	askquit(int);
+static void	cleanup(int);
+static void	cleanupboard(void);
+static void	clearabovemovebox(void);
+static void	clearbelowmovebox(void);
+static void	clearmsg(void);
+static void	clearstat(void);
+static void	destinerror(void);
+static bool	diffcolor(struct cardtype *, struct cardtype *);
+static void	dumberror(void);
+static bool	finish(void);
+static void	fndbase(struct cardtype **, int, int);
+static void	getcmd(int, int, const char *);
+static void	initall(void);
+static void	initdeck(struct cardtype **);
+static void	initgame(void);
+static void	instruct(void);
+static void	makeboard(void);
+static void	movebox(void);
+static void	movecard(void);
+static void	movetofound(struct cardtype **, int);
+static void	movetotalon(void);
+static bool	notempty(struct cardtype *);
+static void	printbottombettingbox(void);
+static void	printbottominstructions(void);
+static void	printcard(int, int, struct cardtype *);
+static void	printrank(int, int, struct cardtype *, bool);
+static void	printtopbettingbox(void);
+static void	printtopinstructions(void);
+static bool	rankhigher(struct cardtype *, int);
+static bool	ranklower(struct cardtype *, struct cardtype *);
+static void	removecard(int, int);
+static bool	samesuit(struct cardtype *, int);
+static void	showcards(void);
+static void	showstat(void);
+static void	shuffle(struct cardtype **);
+static void	simpletableau(struct cardtype **, int);
+static void	startgame(void);
+static void	suspend(void);
+static bool	tabok(struct cardtype *, int);
+static void	tabprint(int, int);
+static void	tabtotab(int, int);
+static void	transit(struct cardtype **, struct cardtype **);
+static void	updatebettinginfo(void);
+static void	usedstock(void);
+static void	usedtalon(void);
 
 /*
  * The following procedures print the board onto the screen using the
@@ -244,8 +243,8 @@
  *
  * procedure to set the move command box
  */
-void
-movebox()
+static void
+movebox(void)
 {
 	switch (status) {
 	case BETTINGBOX:
@@ -279,8 +278,8 @@
 /*
  * print directions above move box
  */
-void
-printtopinstructions()
+static void
+printtopinstructions(void)
 {
 	    move(tboxrow, boxcol);
 	    printw("*----------------------------------*");
@@ -313,8 +312,8 @@
 /*
  * Print the betting box.
  */
-void
-printtopbettingbox()
+static void
+printtopbettingbox(void)
 {
 
 	    move(tboxrow, boxcol);
@@ -348,8 +347,8 @@
 /*
  * clear info above move box
  */
-void
-clearabovemovebox()
+static void
+clearabovemovebox(void)
 {
 	int i;
 
@@ -364,8 +363,8 @@
 /*
  * print instructions below move box
  */
-void
-printbottominstructions()
+static void
+printbottominstructions(void)
 {
 	    move(bboxrow, boxcol);
 	    printw("|Replace # with the number of the  |");
@@ -378,8 +377,8 @@
 /*
  * print betting information below move box
  */
-void
-printbottombettingbox()
+static void
+printbottombettingbox(void)
 {
 	    move(bboxrow, boxcol);
 	    printw("|x = toggle information box        |");
@@ -392,8 +391,8 @@
 /*
  * clear info below move box
  */
-void
-clearbelowmovebox()
+static void
+clearbelowmovebox(void)
 {
 	int i;
 
@@ -408,8 +407,8 @@
 /*
  * procedure to put the board on the screen using addressable cursor
  */
-void
-makeboard()
+static void
+makeboard(void)
 {
 	clear();
 	refresh();
@@ -447,8 +446,8 @@
 /*
  * clean up the board for another game
  */
-void
-cleanupboard()
+static void
+cleanupboard(void)
 {
 	int cnt, row, col;
 	struct cardtype *ptr;
@@ -504,9 +503,8 @@
 /*
  * procedure to create a deck of cards
  */
-void
-initdeck(deck)
-	struct cardtype *deck[];
+static void
+initdeck(struct cardtype **ldeck)
 {
 	int i;
 	int scnt;
@@ -517,7 +515,7 @@
 	for (scnt=0; scnt<4; scnt++) {
 		s = suitmap[scnt];
 		for (r=Ace; r<=King; r++) {
-			deck[i] = &cards[i];
+			ldeck[i] = &cards[i];
 			cards[i].rank = r;
 			cards[i].suit = s;
 			cards[i].color = colormap[scnt];
@@ -530,23 +528,22 @@
 /*
  * procedure to shuffle the deck
  */
-void
-shuffle(deck)
-	struct cardtype *deck[];
+static void
+shuffle(struct cardtype **ldeck)
 {
 	int i,j;
 	struct cardtype *temp;
 
 	for (i=0; i<decksize; i++) {
-		deck[i]->visible = FALSE;
-		deck[i]->paid = FALSE;
+		ldeck[i]->visible = FALSE;
+		ldeck[i]->paid = FALSE;
 	}
 	for (i = decksize-1; i>=0; i--) {
 		j = random() % decksize;
 		if (i != j) {
-			temp = deck[i];
-			deck[i] = deck[j];
-			deck[j] = temp;
+			temp = ldeck[i];
+			ldeck[i] = ldeck[j];
+			ldeck[j] = temp;
 		}
 	}
 }
@@ -554,8 +551,8 @@
 /*
  * procedure to remove the card from the board
  */
-void
-removecard(a, b)
+static void
+removecard(int a, int b)
 {
 	move(b, a);
 	printw("   ");
@@ -564,10 +561,8 @@
 /*
  * procedure to print the cards on the board
  */
-void
-printrank(a, b, cp, inverse)
-	struct cardtype *cp;
-	bool inverse;
+static void
+printrank(int a, int b, struct cardtype *cp, bool inverse)
 {
 	move(b, a);
 	if (cp->rank != 10)
@@ -598,10 +593,8 @@
 /*
  * procedure to print out a card
  */
-void
-printcard(a, b, cp)
-	int a,b;
-	struct cardtype *cp;
+static void
+printcard(int a, int b, struct cardtype *cp)
 {
 	if (cp == NIL)
 		removecard(a, b);
@@ -625,9 +618,8 @@
  * of another location. The pointers always point to the top
  * of the piles.
  */
-void
-transit(source, dest)
-	struct cardtype **source, **dest;
+static void
+transit(struct cardtype **source, struct cardtype **dest)
 {
 	struct cardtype *temp;
 
@@ -642,9 +634,8 @@
  * Note that it is only called on a foundation pile at the beginning of
  * the game, so the pile will have exactly one card in it.
  */
-void
-fndbase(cp, column, row)
-	struct cardtype **cp;
+static void
+fndbase(struct cardtype **cp, int column, int row)
 {
 	bool nomore;
 
@@ -687,8 +678,8 @@
 /*
  * procedure to initialize the things necessary for the game
  */
-void
-initgame()
+static void
+initgame(void)
 {
 	int i;
 
@@ -733,8 +724,8 @@
 /*
  * procedure to print the beginning cards and to start each game
  */
-void
-startgame()
+static void
+startgame(void)
 {
 	int j;
 
@@ -774,8 +765,8 @@
 /*
  * procedure to clear the message printed from an error
  */
-void
-clearmsg()
+static void
+clearmsg(void)
 {
 	int i;
 
@@ -791,8 +782,8 @@
 /*
  * procedure to print an error message if the move is not listed
  */
-void
-dumberror()
+static void
+dumberror(void)
 {
 	errmsg = TRUE;
 	move(msgrow, msgcol);
@@ -802,8 +793,8 @@
 /*
  * procedure to print an error message if the move is not possible
  */
-void
-destinerror()
+static void
+destinerror(void)
 {
 	errmsg = TRUE;
 	move(msgrow, msgcol);
@@ -813,9 +804,8 @@
 /*
  * function to see if the source has cards in it
  */
-bool
-notempty(cp)
-struct cardtype *cp;
+static bool
+notempty(struct cardtype *cp)
 {
 	if (cp == NIL) {
 		errmsg = TRUE;
@@ -829,9 +819,8 @@
 /*
  * function to see if the rank of one card is less than another
  */
-bool
-ranklower(cp1, cp2)
-	struct cardtype *cp1, *cp2;
+static bool
+ranklower(struct cardtype *cp1, struct cardtype *cp2)
 {
 	if (cp2->rank == Ace)
 		if (cp1->rank == King)
@@ -847,9 +836,8 @@
 /*
  * function to check the cardcolor for moving to a tableau
  */
-bool
-diffcolor(cp1, cp2)
-	struct cardtype *cp1, *cp2;
+static bool
+diffcolor(struct cardtype *cp1, struct cardtype *cp2)
 {
 	if (cp1->color == cp2->color)
 		return (FALSE);
@@ -860,9 +848,8 @@
 /*
  * function to see if the card can move to the tableau
  */
-bool
-tabok(cp, des)
-	struct cardtype *cp;
+static bool
+tabok(struct cardtype *cp, int des)
 {
 	if ((cp == stock) && (tableau[des] == NIL))
 		return (TRUE);
@@ -882,8 +869,8 @@
 /*
  * procedure to turn the cards onto the talon from the deck
  */
-void
-movetotalon()
+static void
+movetotalon(void)
 {
 	int i, fin;
 
@@ -967,8 +954,8 @@
 /*
  * procedure to print card counting info on screen
  */
-void
-showstat()
+static void
+showstat(void)
 {
 	int row, col;
 	struct cardtype *ptr;
@@ -1010,8 +997,8 @@
 /*
  * procedure to clear card counting info from screen
  */
-void
-clearstat()
+static void
+clearstat(void)
 {
 	int row;
 
@@ -1030,8 +1017,8 @@
 /*
  * procedure to update card counting base
  */
-void
-usedtalon()
+static void
+usedtalon(void)
 {
 	removecard(coldcol, coldrow);
 	DECRHAND(coldrow, coldcol);
@@ -1055,8 +1042,8 @@
 /*
  * procedure to update stock card counting base
  */
-void
-usedstock()
+static void
+usedstock(void)
 {
 	stockcnt--;
 	if (Cflag) {
@@ -1068,8 +1055,8 @@
 /*
  * let 'em know how they lost!
  */
-void
-showcards()
+static void
+showcards(void)
 {
 	struct cardtype *ptr;
 	int row;
@@ -1116,8 +1103,8 @@
 /*
  * procedure to update the betting values
  */
-void
-updatebettinginfo()
+static void
+updatebettinginfo(void)
 {
 	long thiscosts, gamecosts, totalcosts;
 	double thisreturn, gamereturn, totalreturn;
@@ -1174,9 +1161,8 @@
 /*
  * procedure to move a card from the stock or talon to the tableau
  */
-void
-simpletableau(cp, des)
-struct cardtype **cp;
+static void
+simpletableau(struct cardtype **cp, int des)
 {
 	int origin;
 
@@ -1207,8 +1193,8 @@
 /*
  * print the tableau
  */
-void
-tabprint(sour, des)
+static void
+tabprint(int sour, int des)
 {
 	int dlength, slength, i;
 	struct cardtype *tempcard;
@@ -1233,9 +1219,8 @@
 /*
  * procedure to move from the tableau to the tableau
  */
-void
-tabtotab(sour, des)
-	int sour, des;
+static void
+tabtotab(int sour, int des)
 {
 	struct cardtype *temp;
 
@@ -1260,9 +1245,8 @@
 /*
  * functions to see if the card can go onto the foundation
  */
-bool
-rankhigher(cp, let)
-	struct cardtype *cp;
+static bool
+rankhigher(struct cardtype *cp, int let)
 {
 	if (found[let]->rank == King)
 		if (cp->rank == Ace)
@@ -1278,9 +1262,8 @@
 /*
  * function to determine if two cards are the same suit
  */
-bool
-samesuit(cp, let)
-	struct cardtype *cp;
+static bool
+samesuit(struct cardtype *cp, int let)
 {
 	if (cp->suit == found[let]->suit)
 		return (TRUE);
@@ -1291,9 +1274,8 @@
 /*
  * procedure to move a card to the correct foundation pile
  */
-void
-movetofound(cp, source)
-	struct cardtype **cp;
+static void
+movetofound(struct cardtype **cp, int source)
 {
 	tempbase = 0;
 	mtfdone = FALSE;
@@ -1342,10 +1324,8 @@
 /*
  * procedure to get a command
  */
-void
-getcmd(row, col, cp)
-	int row, col;
-	char *cp;
+static void
+getcmd(int row, int col, const char *cp)
 {
 	char cmd[2], ch;
 	int i;
@@ -1393,8 +1373,8 @@
 /*
  * Suspend the game (shell escape if no process control on system)
  */
-void
-suspend()
+static void
+suspend(void)
 {
 #ifndef SIGTSTP
 	char *sh;
@@ -1415,8 +1395,8 @@
 /*
  * procedure to evaluate and make the specific moves
  */
-void
-movecard()
+static void
+movecard(void)
 {
 	int source, dest;
 	char osrcpile, odestpile;
@@ -1566,7 +1546,7 @@
 	} while (!done);
 }
 
-char *basicinstructions[] = {
+const char *const basicinstructions[] = {
 	"Here are brief instuctions to the game of Canfield:\n\n",
 	"     If you have never played solitaire before, it is recom-\n",
 	"mended  that  you  consult  a solitaire instruction book. In\n",
@@ -1588,7 +1568,7 @@
 	"push any key when you are finished: ",
 	0 };
 
-char *bettinginstructions[] = {
+const char *const bettinginstructions[] = {
 	"     The rules for betting are  somewhat  less  strict  than\n",
 	"those  used in the official version of the game. The initial\n",
 	"deal costs $13. You may quit at this point  or  inspect  the\n",
@@ -1613,10 +1593,10 @@
 /*
  * procedure to printout instructions
  */
-void
-instruct()
+static void
+instruct(void)
 {
-	char **cp;
+	const char *const *cp;
 
 	move(originrow, origincol);
 	printw("This is the game of solitaire called Canfield.  Do\n");
@@ -1649,8 +1629,8 @@
 /*
  * procedure to initialize the game
  */
-void
-initall()
+static void
+initall(void)
 {
 	int i;
 
@@ -1678,8 +1658,8 @@
 /*
  * procedure to end the game
  */
-bool
-finish()
+static bool
+finish(void)
 {
 	int row, col;
 
@@ -1716,9 +1696,8 @@
 /*
  * procedure to clean up and exit
  */
-void
-cleanup(sig)
-	int sig;
+static void
+cleanup(__unused int sig)
 {
 
 	total.thinktime += 1;
@@ -1740,9 +1719,8 @@
 /*
  * Field an interrupt.
  */
-void
-askquit(sig)
-	int sig;
+static void
+askquit(__unused int sig)
 {
 	move(msgrow, msgcol);
 	printw("Really wish to quit?    ");
@@ -1759,7 +1737,7 @@
  * Can you tell that this used to be a Pascal program?
  */
 int
-main()
+main(void)
 {
 	dbfd = open(_PATH_SCORE, O_RDWR);
 
@@ -1797,5 +1775,5 @@
 	}
 	cleanup(0);
 	/* NOTREACHED */
-	exit (EXIT_FAILURE);
+	return (EXIT_FAILURE);
 }
Index: games/canfield/cfscores/Makefile
===================================================================
RCS file: /home/dcvs/src/games/canfield/cfscores/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- games/canfield/cfscores/Makefile	17 Jun 2003 02:49:22 -0000	1.1
+++ games/canfield/cfscores/Makefile	1 Aug 2005 04:50:03 -0000
@@ -3,6 +3,7 @@
 PROG=	cfscores
 CFLAGS+=-I${.CURDIR}/../canfield
 NOMAN=	noman
+WARNS?=	6
 
 .include "../../Makefile.inc"
 .include <bsd.prog.mk>
Index: games/canfield/cfscores/cfscores.c
===================================================================
RCS file: /home/dcvs/src/games/canfield/cfscores/cfscores.c,v
retrieving revision 1.3
diff -u -r1.3 cfscores.c
--- games/canfield/cfscores/cfscores.c	12 Nov 2003 14:53:52 -0000	1.3
+++ games/canfield/cfscores/cfscores.c	1 Aug 2005 05:19:48 -0000
@@ -41,6 +41,8 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include "pathnames.h"
 
 struct betinfo {
@@ -56,12 +58,10 @@
 
 int dbfd;
 
-void printuser (struct passwd *, int);
+static void	printuser(struct passwd *, int);
 
 int
-main(argc, argv)
-	int argc;
-	char *argv[];
+main(int argc, char **argv)
 {
 	struct passwd *pw;
 	int uid;
@@ -98,24 +98,18 @@
 		exit(3);
 	}
 	printuser(pw, 1);
-	exit(0);
+	return(0);
 }
 
 /*
  * print out info for specified password entry
  */
-void
-printuser(pw, printfail)
-	struct passwd *pw;
-	int printfail;
+static void
+printuser(struct passwd *pw, int printfail)
 {
 	struct betinfo total;
 	int i;
 
-	if (pw->pw_uid < 0) {
-		printf("Bad uid %d\n", pw->pw_uid);
-		return;
-	}
 	i = lseek(dbfd, pw->pw_uid * sizeof(struct betinfo), SEEK_SET);
 	if (i < 0) {
 		perror("lseek");
Attachment:
pgp00000.pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00000.pgp
Type: application/octet-stream
Size: 189 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/submit/attachments/20050801/afd9c396/attachment-0016.obj>


More information about the Submit mailing list