summaryrefslogtreecommitdiffstats
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
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).
-rw-r--r--backgammon/backgammon/main.c80
-rw-r--r--backgammon/backgammon/text.c10
-rw-r--r--backgammon/backgammon/version.c6
-rw-r--r--backgammon/common_source/back.h23
-rw-r--r--backgammon/common_source/board.c8
-rw-r--r--backgammon/common_source/fancy.c8
-rw-r--r--backgammon/common_source/init.c14
-rw-r--r--backgammon/common_source/save.c28
-rw-r--r--backgammon/common_source/subs.c16
-rw-r--r--backgammon/common_source/table.c8
-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
16 files changed, 162 insertions, 195 deletions
diff --git a/backgammon/backgammon/main.c b/backgammon/backgammon/main.c
index e019c8df..0a4ff8a2 100644
--- a/backgammon/backgammon/main.c
+++ b/backgammon/backgammon/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.8 1998/09/15 13:43:34 frueauf Exp $ */
+/* $NetBSD: main.c,v 1.9 1999/02/10 12:29:47 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: main.c,v 1.8 1998/09/15 13:43:34 frueauf Exp $");
+__RCSID("$NetBSD: main.c,v 1.9 1999/02/10 12:29:47 hubertf Exp $");
#endif
#endif /* not lint */
@@ -51,53 +51,42 @@ __RCSID("$NetBSD: main.c,v 1.8 1998/09/15 13:43:34 frueauf Exp $");
#include "backlocal.h"
#define MVPAUSE 5 /* time to sleep when stuck */
-#define MAXUSERS 35 /* maximum number of users */
-extern char *instr[]; /* text of instructions */
-extern char *message[]; /* update message */
+extern const char *const instr[]; /* text of instructions */
+extern const char *const message[]; /* update message */
speed_t ospeed; /* tty output speed */
-char *helpm[] = { /* help message */
+const char *const helpm[] = { /* help message */
"Enter a space or newline to roll, or",
" R to reprint the board\tD to double",
" S to save the game\tQ to quit",
0
};
-char *contin[] = { /* pause message */
+const char *const contin[] = { /* pause message */
"(Type a newline to continue.)",
"",
0
};
-#if 0
-static char user1a[] =
-"Sorry, you cannot play backgammon when there are more than ";
-static char user1b[] =
-" users\non the system.";
-static char user2a[] =
-"\nThere are now more than ";
-static char user2b[] =
-" users on the system, so you cannot play\nanother game. ";
-#endif
-static char rules[] = "\nDo you want the rules of the game?";
-static char noteach[] = "Teachgammon not available!\n\007";
-static char need[] = "Do you need instructions for this program?";
-static char askcol[] =
+static const char rules[] = "\nDo you want the rules of the game?";
+static const char noteach[] = "Teachgammon not available!\n\007";
+static const char need[] = "Do you need instructions for this program?";
+static const char askcol[] =
"Enter 'r' to play red, 'w' to play white, 'b' to play both:";
-static char rollr[] = "Red rolls a ";
-static char rollw[] = ". White rolls a ";
-static char rstart[] = ". Red starts.\n";
-static char wstart[] = ". White starts.\n";
-static char toobad1[] = "Too bad, ";
-static char unable[] = " is unable to use that roll.\n";
-static char toobad2[] = ". Too bad, ";
-static char cantmv[] = " can't move.\n";
-static char bgammon[] = "Backgammon! ";
-static char gammon[] = "Gammon! ";
-static char again[] = ".\nWould you like to play again?";
-static char svpromt[] = "Would you like to save this game?";
-
-static char password[] = "losfurng";
+static const char rollr[] = "Red rolls a ";
+static const char rollw[] = ". White rolls a ";
+static const char rstart[] = ". Red starts.\n";
+static const char wstart[] = ". White starts.\n";
+static const char toobad1[] = "Too bad, ";
+static const char unable[] = " is unable to use that roll.\n";
+static const char toobad2[] = ". Too bad, ";
+static const char cantmv[] = " can't move.\n";
+static const char bgammon[] = "Backgammon! ";
+static const char gammon[] = "Gammon! ";
+static const char again[] = ".\nWould you like to play again?";
+static const char svpromt[] = "Would you like to save this game?";
+
+static const char password[] = "losfurng";
static char pbuf[10];
int
@@ -121,16 +110,6 @@ main(argc, argv)
raw.c_lflag &= ~ICANON; /* set up modes */
ospeed = cfgetospeed(&old); /* for termlib */
- /* check user count */
-#ifdef CORY
- if (ucount() > MAXUSERS) {
- writel(user1a);
- wrint(MAXUSERS);
- writel(user1b);
- getout(0);
- }
-#endif
-
/* get terminal capabilities, and decide if it can cursor address */
tflag = getcaps(getenv("TERM"));
/* use whole screen for text */
@@ -519,17 +498,6 @@ main(argc, argv)
/* write score */
wrscore();
- /* check user count */
-#ifdef CORY
- if (ucount() > MAXUSERS) {
- writel(user2a);
- wrint(MAXUSERS);
- writel(user2b);
- rfl = 1;
- break;
- }
-#endif
-
/* see if he wants another game */
writel(again);
if ((i = yorn('S')) == 0)
diff --git a/backgammon/backgammon/text.c b/backgammon/backgammon/text.c
index b6685a42..27b9bb1b 100644
--- a/backgammon/backgammon/text.c
+++ b/backgammon/backgammon/text.c
@@ -1,4 +1,4 @@
-/* $NetBSD: text.c,v 1.5 1997/10/10 08:59:38 lukem Exp $ */
+/* $NetBSD: text.c,v 1.6 1999/02/10 12:29:47 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,13 +38,13 @@
#if 0
static char sccsid[] = "@(#)text.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: text.c,v 1.5 1997/10/10 08:59:38 lukem Exp $");
+__RCSID("$NetBSD: text.c,v 1.6 1999/02/10 12:29:47 hubertf Exp $");
#endif
#endif /* not lint */
#include "back.h"
-char *instr[] = {
+const char *const instr[] = {
" If you did not notice by now, this program reacts to things as",
"soon as you type them, without waiting for a newline. This means that",
"the special characters RUBOUT, ESC, and CONTROL-D, will not perform",
@@ -112,10 +112,10 @@ char *instr[] = {
int
text(t)
- char **t;
+ const char *const *t;
{
int i;
- char *s, *a;
+ const char *s, *a;
fixtty(&noech);
while (*t != 0) {
diff --git a/backgammon/backgammon/version.c b/backgammon/backgammon/version.c
index 23ebb2e6..676ecbc0 100644
--- a/backgammon/backgammon/version.c
+++ b/backgammon/backgammon/version.c
@@ -1,4 +1,4 @@
-/* $NetBSD: version.c,v 1.4 1997/10/10 08:59:39 lukem Exp $ */
+/* $NetBSD: version.c,v 1.5 1999/02/10 12:29:47 hubertf Exp $ */
/*
* Copyright (c) 1980, 1987, 1993
@@ -38,11 +38,11 @@
#if 0
static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: version.c,v 1.4 1997/10/10 08:59:39 lukem Exp $");
+__RCSID("$NetBSD: version.c,v 1.5 1999/02/10 12:29:47 hubertf Exp $");
#endif
#endif /* not lint */
-char *message[] = {
+const char *const message[] = {
"Last updated on Friday, October 10, 1997.",
0
};
diff --git a/backgammon/common_source/back.h b/backgammon/common_source/back.h
index 8121dfea..f507061e 100644
--- a/backgammon/common_source/back.h
+++ b/backgammon/common_source/back.h
@@ -1,4 +1,4 @@
-/* $NetBSD: back.h,v 1.9 1998/09/13 15:31:07 hubertf Exp $ */
+/* $NetBSD: back.h,v 1.10 1999/02/10 12:29:47 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -65,8 +65,8 @@
*
*/
-extern char EXEC[]; /* object for main program */
-extern char TEACH[]; /* object for tutorial program */
+extern const char EXEC[]; /* object for main program */
+extern const char TEACH[]; /* object for tutorial program */
extern int pnum; /* color of player:
-1 = white
@@ -120,10 +120,10 @@ extern char cin[100]; /* input line of current move
(used for reconstructing input after
a backspace) */
-extern char *color[];
+extern const char *const color[];
/* colors as strings */
-extern char **colorptr; /* color of current player */
-extern char **Colorptr; /* color of current player, capitalized */
+extern const char *const *colorptr; /* color of current player */
+extern const char *const *Colorptr; /* color of current player, capitalized */
extern int colen; /* length of color of current player */
extern struct termios old, noech, raw;/* original tty status */
@@ -153,7 +153,7 @@ void fixcol __P((int, int, int, int, int));
void fixpos __P((int, int, int, int, int));
void fixtty __P((struct termios *));
void getarg __P((char ***));
-int getcaps __P((char *));
+int getcaps __P((const char *));
void getmove __P((void));
void getout __P((int)) __attribute__((__noreturn__));
void gwrite __P((void));
@@ -168,23 +168,22 @@ int movokay __P((int));
void newline __P((void));
void newpos __P((void));
void nexturn __P((void));
-void norec __P((char *));
+void norec __P((const char *));
void odds __P((int, int, int));
void proll __P((void));
int quit __P((void));
int readc __P((void));
-void recover __P((char *));
+void recover __P((const char *));
void refresh __P((void));
void roll __P((void));
int rsetbrd __P((void));
void save __P((int));
-int text __P((char **));
-void tos __P((void));
+int text __P((const char *const *));
void wrboard __P((void));
void wrbsub __P((void));
void wrhit __P((int));
void wrint __P((int));
void writec __P((char));
-void writel __P((char *));
+void writel __P((const char *));
void wrscore __P((void));
int yorn __P((char));
diff --git a/backgammon/common_source/board.c b/backgammon/common_source/board.c
index eeac31cc..110e0b4a 100644
--- a/backgammon/common_source/board.c
+++ b/backgammon/common_source/board.c
@@ -1,4 +1,4 @@
-/* $NetBSD: board.c,v 1.5 1997/10/10 08:59:43 lukem Exp $ */
+/* $NetBSD: board.c,v 1.6 1999/02/10 12:29:47 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)board.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: board.c,v 1.5 1997/10/10 08:59:43 lukem Exp $");
+__RCSID("$NetBSD: board.c,v 1.6 1999/02/10 12:29:47 hubertf Exp $");
#endif
#endif /* not lint */
@@ -51,9 +51,9 @@ void
wrboard()
{
int l;
- static char bl[] =
+ static const char bl[] =
"| | | |\n";
- static char sv[] =
+ static const char sv[] =
"| | | | \n";
fixtty(&noech);
diff --git a/backgammon/common_source/fancy.c b/backgammon/common_source/fancy.c
index e0dfcd42..b9efe906 100644
--- a/backgammon/common_source/fancy.c
+++ b/backgammon/common_source/fancy.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fancy.c,v 1.7 1998/09/13 15:19:35 hubertf Exp $ */
+/* $NetBSD: fancy.c,v 1.8 1999/02/10 12:29:47 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)fancy.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: fancy.c,v 1.7 1998/09/13 15:19:35 hubertf Exp $");
+__RCSID("$NetBSD: fancy.c,v 1.8 1999/02/10 12:29:47 hubertf Exp $");
#endif
#endif /* not lint */
@@ -691,14 +691,14 @@ newline()
int
getcaps(s)
- char *s;
+ const char *s;
{
char *code; /* two letter code */
char ***cap; /* pointer to cap string */
char *bufp; /* pointer to cap buffer */
char tentry[1024]; /* temporary uncoded caps buffer */
- tgetent(tentry, s); /* get uncoded termcap entry */
+ tgetent(tentry, (char *)s); /* get uncoded termcap entry */
LI = tgetnum("li"); /* get number of lines */
if (LI == -1)
diff --git a/backgammon/common_source/init.c b/backgammon/common_source/init.c
index 4addd6cb..e812b1c5 100644
--- a/backgammon/common_source/init.c
+++ b/backgammon/common_source/init.c
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.6 1997/10/14 00:53:31 lukem Exp $ */
+/* $NetBSD: init.c,v 1.7 1999/02/10 12:29:48 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: init.c,v 1.6 1997/10/14 00:53:31 lukem Exp $");
+__RCSID("$NetBSD: init.c,v 1.7 1999/02/10 12:29:48 hubertf Exp $");
#endif
#endif /* not lint */
@@ -49,8 +49,8 @@ __RCSID("$NetBSD: init.c,v 1.6 1997/10/14 00:53:31 lukem Exp $");
*/
/* name of executable object programs */
-char EXEC[] = "/usr/games/backgammon";
-char TEACH[] = "/usr/games/teachgammon";
+const char EXEC[] = "/usr/games/backgammon";
+const char TEACH[] = "/usr/games/teachgammon";
int pnum = 2; /* color of player: -1 = white 1 = red 0 =
* both 2 = not yet init'ed */
@@ -66,11 +66,11 @@ int tflag = 0; /* cursor addressing flag */
int iroll = 0; /* special flag for inputting rolls */
int rfl = 0;
-char *color[] = {"White", "Red", "white", "red"};
+const char *const color[] = {"White", "Red", "white", "red"};
-char **Colorptr;
-char **colorptr;
+const char *const *Colorptr;
+const char *const *colorptr;
int *inopp;
int *inptr;
int *offopp;
diff --git a/backgammon/common_source/save.c b/backgammon/common_source/save.c
index be5def93..107dd8d2 100644
--- a/backgammon/common_source/save.c
+++ b/backgammon/common_source/save.c
@@ -1,4 +1,4 @@
-/* $NetBSD: save.c,v 1.7 1998/09/13 15:41:34 hubertf Exp $ */
+/* $NetBSD: save.c,v 1.8 1999/02/10 12:29:48 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: save.c,v 1.7 1998/09/13 15:41:34 hubertf Exp $");
+__RCSID("$NetBSD: save.c,v 1.8 1999/02/10 12:29:48 hubertf Exp $");
#endif
#endif /* not lint */
@@ -46,16 +46,16 @@ __RCSID("$NetBSD: save.c,v 1.7 1998/09/13 15:41:34 hubertf Exp $");
#include "back.h"
-static char confirm[] = "Are you sure you want to leave now?";
-static char prompt[] = "Enter a file name: ";
-static char exist1[] = "The file '";
-static char exist2[] =
+static const char confirm[] = "Are you sure you want to leave now?";
+static const char prompt[] = "Enter a file name: ";
+static const char exist1[] = "The file '";
+static const char exist2[] =
"' already exists.\nAre you sure you want to use this file?";
-static char cantuse[] = "\nCan't use ";
-static char saved[] = "This game has been saved on the file '";
-static char type[] = "'.\nType \"backgammon ";
-static char rec[] = "\" to recover your game.\n\n";
-static char cantrec[] = "Can't recover file: ";
+static const char cantuse[] = "\nCan't use ";
+static const char saved[] = "This game has been saved on the file '";
+static const char type[] = "'.\nType \"backgammon ";
+static const char rec[] = "\" to recover your game.\n\n";
+static const char cantrec[] = "Can't recover file: ";
void
save(n)
@@ -150,7 +150,7 @@ save(n)
void
recover(s)
- char *s;
+ const char *s;
{
int fdesc;
@@ -173,9 +173,9 @@ recover(s)
void
norec(s)
- char *s;
+ const char *s;
{
- char *c;
+ const char *c;
tflag = 0;
writel(cantrec);
diff --git a/backgammon/common_source/subs.c b/backgammon/common_source/subs.c
index 95375f8c..29baf64c 100644
--- a/backgammon/common_source/subs.c
+++ b/backgammon/common_source/subs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subs.c,v 1.9 1998/09/15 13:43:35 frueauf Exp $ */
+/* $NetBSD: subs.c,v 1.10 1999/02/10 12:29:48 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: subs.c,v 1.9 1998/09/15 13:43:35 frueauf Exp $");
+__RCSID("$NetBSD: subs.c,v 1.10 1999/02/10 12:29:48 hubertf Exp $");
#endif
#endif /* not lint */
@@ -47,11 +47,11 @@ __RCSID("$NetBSD: subs.c,v 1.9 1998/09/15 13:43:35 frueauf Exp $");
int buffnum;
char outbuff[BUFSIZ];
-static char plred[] = "Player is red, computer is white.";
-static char plwhite[] = "Player is white, computer is red.";
-static char nocomp[] = "(No computer play.)";
+static const char plred[] = "Player is red, computer is white.";
+static const char plwhite[] = "Player is white, computer is red.";
+static const char nocomp[] = "(No computer play.)";
-char *descr[] = {
+const char *const descr[] = {
"Usage: backgammon [-] [n r w b pr pw pb t3a]\n",
"\t-\tgets this list\n\tn\tdon't ask for rules or instructions",
"\tr\tplayer is red (implies n)\n\tw\tplayer is white (implies n)",
@@ -136,10 +136,10 @@ writec(c)
void
writel(l)
- char *l;
+ const char *l;
{
#ifdef DEBUG
- char *s;
+ const char *s;
if (trace == NULL)
trace = fopen("bgtrace", "w");
diff --git a/backgammon/common_source/table.c b/backgammon/common_source/table.c
index 36f2e69e..5f545e5d 100644
--- a/backgammon/common_source/table.c
+++ b/backgammon/common_source/table.c
@@ -1,4 +1,4 @@
-/* $NetBSD: table.c,v 1.5 1997/10/10 08:59:49 lukem Exp $ */
+/* $NetBSD: table.c,v 1.6 1999/02/10 12:29:48 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,13 +38,13 @@
#if 0
static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: table.c,v 1.5 1997/10/10 08:59:49 lukem Exp $");
+__RCSID("$NetBSD: table.c,v 1.6 1999/02/10 12:29:48 hubertf Exp $");
#endif
#endif /* not lint */
#include "back.h"
-char *help2[] = {
+const char *const help2[] = {
" Enter moves as <s>-<f> or <s>/<r> where <s> is the starting",
"position, <f> is the finishing position, and <r> is the roll.",
"Remember, each die roll must be moved separately.",
@@ -57,7 +57,7 @@ struct state {
int newst;
};
-struct state atmata[] = {
+static const struct state atmata[] = {
{'R', 1, 0}, {'?', 7, 0}, {'Q', 0, -3}, {'B', 8, 25},
{'9', 2, 25}, {'8', 2, 25}, {'7', 2, 25}, {'6', 2, 25},
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__));