summaryrefslogtreecommitdiffstats
path: root/backgammon/common_source
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/common_source
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/common_source')
-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
7 files changed, 52 insertions, 53 deletions
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},