summaryrefslogtreecommitdiffstats
path: root/backgammon/teachgammon
diff options
context:
space:
mode:
authorhubertf <hubertf@NetBSD.org>1999-02-10 12:29:47 +0000
committerhubertf <hubertf@NetBSD.org>1999-02-10 12:29:47 +0000
commitf2e552ba9ea473d3399e7b124077a7e4a856138b (patch)
treece3f13ceac941baa50c07a090d8cbd73be7fda90 /backgammon/teachgammon
parent19bd733c3aad11dcfb4bbcf06abf79ff64442032 (diff)
downloadbsdgames-darwin-f2e552ba9ea473d3399e7b124077a7e4a856138b.tar.gz
bsdgames-darwin-f2e552ba9ea473d3399e7b124077a7e4a856138b.tar.zst
bsdgames-darwin-f2e552ba9ea473d3399e7b124077a7e4a856138b.zip
The patch below makes the game backgammon(6) use `const' where
appropriate. It also removes some obsolete, unused code to check the number of users on the system (obsoleted by dm); removes a prototype for an unused function that was removed earlier; and removes a control character from one message that was I think intended to clear the screen on some particular terminal (though I can't find the comment to that effect in any of the BSD source trees I have handy) but no longer serves any useful purpose. From PR 6580 by Joseph Myers <jsm28@cam.ac.uk>. Also contains two more patches, one in teachgammon/tutor.h (by Joseph) and one in common_source/fancy.c (by me).
Diffstat (limited to 'backgammon/teachgammon')
-rw-r--r--backgammon/teachgammon/data.c54
-rw-r--r--backgammon/teachgammon/teach.c8
-rw-r--r--backgammon/teachgammon/ttext1.c26
-rw-r--r--backgammon/teachgammon/ttext2.c20
-rw-r--r--backgammon/teachgammon/tutor.c10
-rw-r--r--backgammon/teachgammon/tutor.h38
6 files changed, 78 insertions, 78 deletions
diff --git a/backgammon/teachgammon/data.c b/backgammon/teachgammon/data.c
index 94b1d43e..8af936d5 100644
--- a/backgammon/teachgammon/data.c
+++ b/backgammon/teachgammon/data.c
@@ -1,4 +1,4 @@
-/* $NetBSD: data.c,v 1.4 1997/10/10 08:59:51 lukem Exp $ */
+/* $NetBSD: data.c,v 1.5 1999/02/10 12:29:48 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: data.c,v 1.4 1997/10/10 08:59:51 lukem Exp $");
+__RCSID("$NetBSD: data.c,v 1.5 1999/02/10 12:29:48 hubertf Exp $");
#endif
#endif /* not lint */
@@ -46,7 +46,7 @@ __RCSID("$NetBSD: data.c,v 1.4 1997/10/10 08:59:51 lukem Exp $");
int maxmoves = 23;
-char *text0[] = {
+const char *const text0[] = {
"To start the game, I roll a 3, and you roll a 1. This means",
"that I get to start first. I move 8-5,6-5 since this makes a",
"new point and helps to trap your back men on 1. You should be",
@@ -54,7 +54,7 @@ char *text0[] = {
0
};
-char *text1[] = {
+const char *const text1[] = {
"Now you shall see a move using doubles. I just rolled double",
"5's. I will move two men from position 13 to position 3. The",
"notation for this is 13-8,13-8,8-3,8-3. You will also roll dou-",
@@ -62,7 +62,7 @@ char *text1[] = {
0
};
-char *text2[] = {
+const char *const text2[] = {
"Excellent! As you can see, you are beginning to develop a wall",
"which is trapping my men on position 24. Also, moving your back",
"men forward not only improves your board position safely, but it",
@@ -75,7 +75,7 @@ char *text2[] = {
0
};
-char *text3[] = {
+const char *const text3[] = {
"As you can see, although you left a man open, it is a rela-",
"tively safe move to an advantageous position, which might help",
"you make a point later. Only two rolls (4 5 or 5 4) will allow",
@@ -84,13 +84,13 @@ char *text3[] = {
0
};
-char *text4[] = {
+const char *const text4[] = {
"You're pretty lucky yourself, you know. I follow by rolling 2 3",
"and moving 25-22,24-22, forming a new point.",
0
};
-char *text5[] = {
+const char *const text5[] = {
"Not a spectacular move, but a safe one. I follow by rolling 6 1.",
"I decide to use this roll to move 22-16,16-17. It leaves me with",
"one man still open, but the blot is farther back on the board, and",
@@ -98,7 +98,7 @@ char *text5[] = {
0
};
-char *text6[] = {
+const char *const text6[] = {
"By moving your two men from 17 to 20, you lessen my chance of",
"getting my man off the board. In fact, the odds are 5 to 4",
"against me getting off. I roll with the odds and helplessly",
@@ -106,7 +106,7 @@ char *text6[] = {
0
};
-char *text7[] = {
+const char *const text7[] = {
"Note that the blot on 7 cannot be hit unless I get off the bar",
"and have a 1 or a 6 left over, and doing so will leave two of",
"my men open. Also, the blot on 16 cannot be hit at all! With",
@@ -114,27 +114,27 @@ char *text7[] = {
0
};
-char *text8[] = {
+const char *const text8[] = {
"See, you did not get hit and, you got to 'cover up' your open men.",
"Quite an accomplishment. Finally, I get off the bar by rolling",
"6 2 and moving 25-23,23-17.",
0
};
-char *text9[] = {
+const char *const text9[] = {
"My venture off the bar did not last long. However, I got lucky",
"and rolled double 1's, allowing me to move 0-1,1-2,15-14,15-14.",
0
};
-char *text10[] = {
+const char *const text10[] = {
"You are improving your position greatly and safely, and are well",
"on the way to winning the game. I roll a 6 2 and squeak past",
"your back man. Now the game becomes a race to the finish.",
0
};
-char *text11[] = {
+const char *const text11[] = {
"Now that it is merely a race, you are trying to get as many men",
"as possible into the inner table, so you can start removing them.",
"I roll a 3 4 and move my two men farthest back to position 11",
@@ -142,20 +142,20 @@ char *text11[] = {
0
};
-char *text12[] = {
+const char *const text12[] = {
"The race is still on, and you have seem to be doing all right.",
"I roll 6 1 and move 14-8,13-12.",
0
};
-char *text13[] = {
+const char *const text13[] = {
"Notice that you get to remove men the instant you have all of",
"them at your inner table, even if it is the middle of a turn.",
"I roll 1 2 and move 13-11,12-11.",
0
};
-char *text14[] = {
+const char *const text14[] = {
"Although you could have removed a man, this move illustrates two",
"points: 1) You never have to remove men, and 2) You should try",
"to spread out your men on your inner table. Since you have one",
@@ -164,25 +164,25 @@ char *text14[] = {
0
};
-char *text15[] = {
+const char *const text15[] = {
"This time you were able to remove men. I roll 3 4 and move",
"11-7,11-8. The race continues.",
0
};
-char *text16[] = {
+const char *const text16[] = {
"More holes are opening up in your inner table, but you are",
"still very much ahead. If we were doubling, you would have",
"doubled long ago. I roll 2 6 and move 8-6,11-5.",
0
};
-char *text17[] = {
+const char *const text17[] = {
"It pays to spread out your men. I roll 3 5 and move 7-4,8-3.",
0
};
-char *text18[] = {
+const char *const text18[] = {
"You can only remove some men, but you spread out more and",
"more, in order to be able to remove men more efficiently.",
"I roll double 3's, which help, but not that much. I move",
@@ -190,30 +190,30 @@ char *text18[] = {
0
};
-char *text19[] = {
+const char *const text19[] = {
"I roll 1 4 and move 5-4,4-0.",
0
};
-char *text20[] = {
+const char *const text20[] = {
"You are now nicely spread out to win a game. I roll 5 6 and",
"move 5-0,6-0.",
0
};
-char *text21[] = {
+const char *const text21[] = {
"Any minute now. Just a few short steps from victory. I roll",
"2 4 and move 6-4,4-0.",
0
};
-char *text22[] = {
+const char *const text22[] = {
"It looks pretty hopeless for me, but I play on, rolling 1 3 and",
"moving 4-3,3-0.",
0
};
-char *text23[] = {
+const char *const text23[] = {
"Congratulations! You just won a game of backgammon against the",
"computer! You will now be able to play a game, but remember,",
"when you start playing, that doubling will be enabled, which",
@@ -222,7 +222,7 @@ char *text23[] = {
0
};
-struct situatn test[] = {
+const struct situatn test[] = {
{
{0, 2, 0, 0, 0, 0, -5, 0, -3, 0, 0, 0, 5, -5, 0, 0, 0, 3, 0,
5, 0, 0, 0, 0, -2, 0},
diff --git a/backgammon/teachgammon/teach.c b/backgammon/teachgammon/teach.c
index 146f4a72..c6c7c30a 100644
--- a/backgammon/teachgammon/teach.c
+++ b/backgammon/teachgammon/teach.c
@@ -1,4 +1,4 @@
-/* $NetBSD: teach.c,v 1.7 1998/09/15 13:43:35 frueauf Exp $ */
+/* $NetBSD: teach.c,v 1.8 1999/02/10 12:29:48 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0
static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: teach.c,v 1.7 1998/09/15 13:43:35 frueauf Exp $");
+__RCSID("$NetBSD: teach.c,v 1.8 1999/02/10 12:29:48 hubertf Exp $");
#endif
#endif /* not lint */
@@ -52,7 +52,7 @@ __RCSID("$NetBSD: teach.c,v 1.7 1998/09/15 13:43:35 frueauf Exp $");
extern speed_t ospeed; /* tty output speed for termlib */
-char *helpm[] = {
+const char *const helpm[] = {
"\nEnter a space or newline to roll, or",
" b to display the board",
" d to double",
@@ -60,7 +60,7 @@ char *helpm[] = {
0
};
-char *contin[] = {
+const char *const contin[] = {
"",
0
};
diff --git a/backgammon/teachgammon/ttext1.c b/backgammon/teachgammon/ttext1.c
index 33a96253..e3486e19 100644
--- a/backgammon/teachgammon/ttext1.c
+++ b/backgammon/teachgammon/ttext1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ttext1.c,v 1.4 1997/10/10 08:59:53 lukem Exp $ */
+/* $NetBSD: ttext1.c,v 1.5 1999/02/10 12:29:48 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,17 +38,17 @@
#if 0
static char sccsid[] = "@(#)ttext1.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: ttext1.c,v 1.4 1997/10/10 08:59:53 lukem Exp $");
+__RCSID("$NetBSD: ttext1.c,v 1.5 1999/02/10 12:29:48 hubertf Exp $");
#endif
#endif /* not lint */
#include "back.h"
#include "tutor.h"
-char *opts = " QIMRHEDSPT";
-char *prompt = "-->";
+const char *opts = " QIMRHEDSPT";
+const char *prompt = "-->";
-char *list[] = {
+const char *const list[] = {
"\n\n\tI\tIntroduction to Backgammon",
"\tM\tMoves and Points",
"\tR\tRemoving Men from the Board",
@@ -64,8 +64,8 @@ char *list[] = {
0
};
-char *hello[] = {
- "\n\032 These rules consist of text describing how to play Backgammon",
+const char *const hello[] = {
+ "\n These rules consist of text describing how to play Backgammon",
"followed by a tutorial session where you play a practice game",
"against the computer. When using this program, think carefuly",
"before typing, since it reacts as soon as you type something. In",
@@ -82,7 +82,7 @@ char *hello[] = {
0
};
-char *intro1[] = {
+const char *const intro1[] = {
"\nIntroduction:",
"\n Backgammon is a game involving the skill of two players and",
"the luck of two dice. There are two players, red and white, and",
@@ -93,7 +93,7 @@ char *intro1[] = {
"",
0};
-char *intro2[] = {
+const char *const intro2[] = {
"",
"\n Although not indicated on the board, the players' homes are",
"located just to the right of the board. A player's men are placed",
@@ -107,7 +107,7 @@ char *intro2[] = {
"",
0};
-char *moves[] = {
+const char *const moves[] = {
"\nMoves and Points:",
"\n Moves are made along the positions on the board according to",
"their numbers. Red moves in the positive direction (clockwise",
@@ -138,7 +138,7 @@ char *moves[] = {
"",
0};
-char *removepiece[] = {
+const char *const removepiece[] = {
"\nRemoving Men from the Board:",
"\n The most important part of the game is removing men, since",
"that is how you win the game. Once a man is removed, he stays",
@@ -162,7 +162,7 @@ char *removepiece[] = {
"",
0};
-char *hits[] = {
+const char *const hits[] = {
"\nHitting Blots:",
"\n Although two men on a position form an impenetrable point, a",
"lone man is not so secure. Such a man is called a 'blot' and has",
@@ -179,7 +179,7 @@ char *hits[] = {
"",
0};
-char *endgame[] = {
+const char *const endgame[] = {
"\nEnding the Game and Scoring:",
"\n Winning a game usually wins one point, the normal value of a",
"game. However, if the losing player has not removed any men yet,",
diff --git a/backgammon/teachgammon/ttext2.c b/backgammon/teachgammon/ttext2.c
index 01eafaee..09ebf440 100644
--- a/backgammon/teachgammon/ttext2.c
+++ b/backgammon/teachgammon/ttext2.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ttext2.c,v 1.5 1997/10/10 08:59:53 lukem Exp $ */
+/* $NetBSD: ttext2.c,v 1.6 1999/02/10 12:29:48 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,14 +38,14 @@
#if 0
static char sccsid[] = "@(#)ttext2.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: ttext2.c,v 1.5 1997/10/10 08:59:53 lukem Exp $");
+__RCSID("$NetBSD: ttext2.c,v 1.6 1999/02/10 12:29:48 hubertf Exp $");
#endif
#endif /* not lint */
#include "back.h"
#include "tutor.h"
-char *doubl[] = {
+const char *const doubl[] = {
"\nDoubling:",
"\n If a player thinks he is in a good position, he may double the",
"value of the game. However, his opponent may not accept the pro-",
@@ -60,7 +60,7 @@ char *doubl[] = {
"",
0};
-char *stragy[] = {
+const char *const stragy[] = {
"\nStrategy:",
"\n Some general hints when playing: Try not to leave men open",
"unless absolutely necessary. Also, it is good to make as many",
@@ -76,7 +76,7 @@ char *stragy[] = {
"",
0};
-char *prog[] = {
+const char *const prog[] = {
"\nThe Program and How It Works:",
"\n A general rule of thumb is when you don't know what to do,",
"type a question mark, and you should get some help. When it is",
@@ -110,7 +110,7 @@ char *prog[] = {
"",
0};
-char *lastch[] = {
+const char *const lastch[] = {
"\nTutorial (Practice Game):",
"\n This tutorial, for simplicity's sake, will let you play one",
"predetermined game. All the rolls have been pre-arranged, and",
@@ -132,12 +132,12 @@ char *lastch[] = {
int
text(txt)
- char **txt;
+ const char *const *txt;
{
- char **begin;
- char *a;
+ const char *const *begin;
+ const char *a;
char b;
- char *c;
+ const char *c;
int i;
fixtty(&noech);
diff --git a/backgammon/teachgammon/tutor.c b/backgammon/teachgammon/tutor.c
index 06b4d114..c1a122da 100644
--- a/backgammon/teachgammon/tutor.c
+++ b/backgammon/teachgammon/tutor.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tutor.c,v 1.4 1997/10/10 08:59:54 lukem Exp $ */
+/* $NetBSD: tutor.c,v 1.5 1999/02/10 12:29:48 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,14 +38,14 @@
#if 0
static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: tutor.c,v 1.4 1997/10/10 08:59:54 lukem Exp $");
+__RCSID("$NetBSD: tutor.c,v 1.5 1999/02/10 12:29:48 hubertf Exp $");
#endif
#endif /* not lint */
#include "back.h"
#include "tutor.h"
-static char better[] = "That is a legal move, but there is a better one.\n";
+static const char better[] = "That is a legal move, but there is a better one.\n";
void
tutor()
@@ -148,9 +148,9 @@ clrest()
int
brdeq(b1, b2)
- int *b1, *b2;
+ const int *b1, *b2;
{
- int *e;
+ const int *e;
e = b1 + 26;
while (b1 < e)
diff --git a/backgammon/teachgammon/tutor.h b/backgammon/teachgammon/tutor.h
index b709d075..e3ba2f7e 100644
--- a/backgammon/teachgammon/tutor.h
+++ b/backgammon/teachgammon/tutor.h
@@ -1,4 +1,4 @@
-/* $NetBSD: tutor.h,v 1.5 1998/09/13 15:27:26 hubertf Exp $ */
+/* $NetBSD: tutor.h,v 1.6 1999/02/10 12:29:48 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,30 +43,30 @@ struct situatn {
int mg[4];
int new1;
int new2;
- char *(*com[8]);
+ const char *const (*com[8]);
};
-extern char *doubl[];
-extern char *endgame[];
-extern char *finis[];
-extern char *hello[];
-extern char *hits[];
-extern char *intro1[];
-extern char *intro2[];
-extern char *lastch[];
-extern char *list[];
+extern const char *const doubl[];
+extern const char *const endgame[];
+extern const char *const finis[];
+extern const char *const hello[];
+extern const char *const hits[];
+extern const char *const intro1[];
+extern const char *const intro2[];
+extern const char *const lastch[];
+extern const char *const list[];
extern int maxmoves;
-extern char *moves[];
-extern char *opts;
-extern char *prog[];
-extern char *prompt;
-extern char *removepiece[];
-extern char *stragy[];
-extern struct situatn test[];
+extern const char *const moves[];
+extern const char *const opts;
+extern const char *const prog[];
+extern const char *const prompt;
+extern const char *const removepiece[];
+extern const char *const stragy[];
+extern const struct situatn test[];
-int brdeq __P((int *, int *));
+int brdeq __P((const int *, const int *));
void clrest __P((void));
void leave __P((void)) __attribute__((__noreturn__));
void tutor __P((void)) __attribute__((__noreturn__));