Sun May 2 12:25:56 2021 UTC ()
fish: remove trailing whitespace


(rillig)
diff -r1.25 -r1.26 src/games/fish/fish.c

cvs diff -r1.25 -r1.26 src/games/fish/fish.c (expand / switch to unified diff)

--- src/games/fish/fish.c 2021/05/02 12:24:59 1.25
+++ src/games/fish/fish.c 2021/05/02 12:25:55 1.26
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fish.c,v 1.25 2021/05/02 12:24:59 rillig Exp $ */ 1/* $NetBSD: fish.c,v 1.26 2021/05/02 12:25:55 rillig Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1990, 1993 4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Muffy Barkocy. 8 * Muffy Barkocy.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -32,27 +32,27 @@ @@ -32,27 +32,27 @@
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36#ifndef lint 36#ifndef lint
37__COPYRIGHT("@(#) Copyright (c) 1990, 1993\ 37__COPYRIGHT("@(#) Copyright (c) 1990, 1993\
38 The Regents of the University of California. All rights reserved."); 38 The Regents of the University of California. All rights reserved.");
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#ifndef lint 41#ifndef lint
42#if 0 42#if 0
43static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93"; 43static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93";
44#else 44#else
45__RCSID("$NetBSD: fish.c,v 1.25 2021/05/02 12:24:59 rillig Exp $"); 45__RCSID("$NetBSD: fish.c,v 1.26 2021/05/02 12:25:55 rillig Exp $");
46#endif 46#endif
47#endif /* not lint */ 47#endif /* not lint */
48 48
49#include <sys/types.h> 49#include <sys/types.h>
50#include <sys/wait.h> 50#include <sys/wait.h>
51#include <errno.h> 51#include <errno.h>
52#include <fcntl.h> 52#include <fcntl.h>
53#include <stdio.h> 53#include <stdio.h>
54#include <stdlib.h> 54#include <stdlib.h>
55#include <unistd.h> 55#include <unistd.h>
56#include <string.h> 56#include <string.h>
57#include <err.h> 57#include <err.h>
58#include "pathnames.h" 58#include "pathnames.h"
@@ -110,27 +110,27 @@ main(int argc, char **argv) @@ -110,27 +110,27 @@ main(int argc, char **argv)
110 usage(); 110 usage();
111 } 111 }
112 112
113 instructions(); 113 instructions();
114 init(); 114 init();
115 115
116 if (arc4random_uniform(2) == 1) { 116 if (arc4random_uniform(2) == 1) {
117 printplayer(COMPUTER); 117 printplayer(COMPUTER);
118 (void)printf("get to start.\n"); 118 (void)printf("get to start.\n");
119 goto istart; 119 goto istart;
120 } 120 }
121 printplayer(USER); 121 printplayer(USER);
122 (void)printf("get to start.\n"); 122 (void)printf("get to start.\n");
123  123
124 for (;;) { 124 for (;;) {
125 move = usermove(); 125 move = usermove();
126 if (!comphand[move]) { 126 if (!comphand[move]) {
127 if (gofish(move, USER, userhand)) 127 if (gofish(move, USER, userhand))
128 continue; 128 continue;
129 } else { 129 } else {
130 goodmove(USER, move, userhand, comphand); 130 goodmove(USER, move, userhand, comphand);
131 continue; 131 continue;
132 } 132 }
133 133
134istart: for (;;) { 134istart: for (;;) {
135 move = compmove(); 135 move = compmove();
136 if (!userhand[move]) { 136 if (!userhand[move]) {
@@ -233,32 +233,32 @@ promove(void) @@ -233,32 +233,32 @@ promove(void)
233 233
234 for (i = 0; i < RANKS; ++i) 234 for (i = 0; i < RANKS; ++i)
235 if (userasked[i] && 235 if (userasked[i] &&
236 comphand[i] > 0 && comphand[i] < CARDS) { 236 comphand[i] > 0 && comphand[i] < CARDS) {
237 userasked[i] = 0; 237 userasked[i] = 0;
238 return(i); 238 return(i);
239 } 239 }
240 if (arc4random_uniform(3) == 1) { 240 if (arc4random_uniform(3) == 1) {
241 for (i = 0;; ++i) 241 for (i = 0;; ++i)
242 if (comphand[i] && comphand[i] != CARDS) { 242 if (comphand[i] && comphand[i] != CARDS) {
243 max = i; 243 max = i;
244 break; 244 break;
245 } 245 }
246 while (++i < RANKS)  246 while (++i < RANKS)
247 if (comphand[i] != CARDS && 247 if (comphand[i] != CARDS &&
248 comphand[i] > comphand[max]) 248 comphand[i] > comphand[max])
249 max = i; 249 max = i;
250 return(max); 250 return(max);
251 }  251 }
252 if (arc4random_uniform(1024) == 0723) { 252 if (arc4random_uniform(1024) == 0723) {
253 for (i = 0; i < RANKS; ++i) 253 for (i = 0; i < RANKS; ++i)
254 if (userhand[i] && comphand[i]) 254 if (userhand[i] && comphand[i])
255 return(i); 255 return(i);
256 } 256 }
257 for (;;) { 257 for (;;) {
258 for (i = 0; i < RANKS; ++i) 258 for (i = 0; i < RANKS; ++i)
259 if (comphand[i] && comphand[i] != CARDS && 259 if (comphand[i] && comphand[i] != CARDS &&
260 !asked[i]) 260 !asked[i])
261 return(i); 261 return(i);
262 for (i = 0; i < RANKS; ++i) 262 for (i = 0; i < RANKS; ++i)
263 asked[i] = 0; 263 asked[i] = 0;
264 } 264 }
@@ -359,27 +359,27 @@ printplayer(int player) @@ -359,27 +359,27 @@ printplayer(int player)
359 case USER: 359 case USER:
360 (void)printf("You "); 360 (void)printf("You ");
361 break; 361 break;
362 } 362 }
363} 363}
364 364
365static void 365static void
366printhand(const int *hand) 366printhand(const int *hand)
367{ 367{
368 int book, i, j; 368 int book, i, j;
369 369
370 for (book = i = 0; i < RANKS; i++) 370 for (book = i = 0; i < RANKS; i++)
371 if (hand[i] < CARDS) 371 if (hand[i] < CARDS)
372 for (j = hand[i]; --j >= 0;)  372 for (j = hand[i]; --j >= 0;)
373 PRC(i); 373 PRC(i);
374 else 374 else
375 ++book; 375 ++book;
376 if (book) { 376 if (book) {
377 (void)printf(" + Book%s of", book > 1 ? "s" : ""); 377 (void)printf(" + Book%s of", book > 1 ? "s" : "");
378 for (i = 0; i < RANKS; i++) 378 for (i = 0; i < RANKS; i++)
379 if (hand[i] == CARDS) 379 if (hand[i] == CARDS)
380 PRC(i); 380 PRC(i);
381 } 381 }
382 (void)putchar('\n'); 382 (void)putchar('\n');
383} 383}
384 384
385static int 385static int