This one was also wrapped:
Index: fish.c
===================================================================
RCS file: /cvs/src/games/fish/fish.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 fish.c
--- fish.c 18 Feb 2015 23:20:45 -0000 1.17
+++ fish.c 23 Nov 2015 19:16:15 -0000
@@ -79,7 +79,7 @@ int nrandom(int);
void printhand(const int *);
void printplayer(int);
int promove(void);
-void usage(void);
+__dead void usage(void);
int usermove(void);
int
@@ -99,6 +99,10 @@ main(int argc, char *argv[])
}
instructions();
+
+ if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
+
init();
if (nrandom(2) == 1) {
@@ -444,46 +448,26 @@ getans(const char *prompt)
void
instructions(void)
{
- const char *pager;
- pid_t pid;
- int status;
int input;
- int fd;
+ char buf[1024];
+ FILE *fp;
if (getans("Would you like instructions (y or n)? ") == 0)
return;
- if ((fd = open(_PATH_INSTR, O_RDONLY)) == -1)
+ if ((fp = fopen(_PATH_INSTR, "r")) == NULL)
(void)printf("No instruction file found!\n");
else {
- switch (pid = fork()) {
- case 0: /* child */
- if (!isatty(1))
- pager = "/bin/cat";
- else {
- if (!(pager = getenv("PAGER")) || (*pager == 0))
- pager = _PATH_MORE;
- }
- if (dup2(fd, 0) == -1)
- err(1, "dup2");
- (void)execl(_PATH_BSHELL, "sh", "-c", pager, (char
*)NULL);
- err(1, "exec sh -c %s", pager);
- /* NOT REACHED */
- case -1:
- err(1, "fork");
- /* NOT REACHED */
- default:
- (void)waitpid(pid, &status, 0);
- close(fd);
- break;
- }
+ while (fgets(buf, sizeof(buf), fp))
+ fputs(buf, stdout);
+ fclose(fp);
}
(void)printf("Hit return to continue...\n");
while ((input = getchar()) != EOF && input != '\n');
}
-void
+__dead void
usage(void)
{
(void)fprintf(stderr, "usage: fish [-p]\n");
Index: pathnames.h
===================================================================
RCS file: /cvs/src/games/fish/pathnames.h,v
retrieving revision 1.3
diff -u -p -u -r1.3 pathnames.h
--- pathnames.h 3 Jun 2003 03:01:39 -0000 1.3
+++ pathnames.h 23 Nov 2015 19:16:23 -0000
@@ -33,4 +33,3 @@
*/
#define _PATH_INSTR "/usr/share/games/fish.instr"
-#define _PATH_MORE "/usr/bin/more"
Index: fish.instr
===================================================================
RCS file: /cvs/src/games/fish/fish.instr,v
retrieving revision 1.2
diff -u -p -u -r1.2 fish.instr
--- fish.instr 22 Aug 1998 09:10:13 -0000 1.2
+++ fish.instr 23 Nov 2015 19:16:29 -0000
@@ -1,29 +1,22 @@
-This is the traditional children's card game "Go Fish". We each get seven
-cards, and the rest of the deck is kept to be drawn from later. The
-object of the game is to collect "books", or all of the cards of a single
-value. For example, getting four 2's would give you a "book of 2's".
-
-We take turns asking each other for cards, but you can't ask me for a card
-value if you don't have one of them in your hand! If I have any cards of
-the value you ask for, I have to give them to you. As long as I have one
-of the cards you ask for, you get to keep asking. If you ask me for a
-card value that I don't have, then I'll tell you to "Go Fish!" This means
-that you draw a card from the deck. If you draw the card you asked me
-for, you get to keep asking me for cards. If not, it's my turn and I ask
-you for a card.
-
-Sometimes you get to ask first, sometimes I do. I'll tell you when it's
+ This is the traditional children's card game "Go Fish". We each get seven
+cards and the rest of the deck is kept to be drawn from later. The object of
+the game is to collect "books", or all of the cards of a single value. For
+example, getting four 2's would give you a "book of 2's".
+ We take turns asking each other for cards, but you can't ask me for a card
+value if you don't have one of them in your hand! As long as I have one of the
+cards you ask for, I have to give them to you and you get to keep asking.
+If you ask me for a card value that I don't have, then I'll tell you to
+"Go Fish!" This means that you draw a card from the deck. If you draw the card
+you asked me for, you get to keep asking me for cards. If not, it's my turn
+and I ask you for a card.
+ Sometimes you get to ask first, sometimes I do. I'll tell you when it's
your turn to move, I'll draw cards from the deck for you, and I'll tell
you what you have in your hand. (Don't worry, I don't look at your hand
when I'm trying to decide what card to ask for, honest!)
-
-Your input can be a card value ("A", "2", "3", "4", "5", "6", "7", "8",
-"9", "10", "J", "Q" or "K") or the letter "p", or "quit". The letter "p"
-makes my game much smarter, and the line "quit" stops the game. Just
-hitting the carriage return key displays how many cards I have in my hand,
-how many are left in the deck, and which books I've gotten.
-
-Normally, the game stops when one of us runs out of cards, and the winner
-is whoever has the most books!
-
-Good luck!
+ Your input can be a card value ("A", "2", "3", "4", "5", "6", "7", "8", "9"
+, "10", "J", "Q" or "K") or the letter "p" (makes my game much smarter), or
+"quit" (stops game). Just hitting the return key displays how many cards I have
+in my hand, how many are left in the deck, and which books I've gotten.
+ Normally, the game stops when one of us runs out of cards, and the winner is
+whoever has the most books!
+ Good luck!