Subject: bin/6660: [PATCH] Battlestar: patch to use const
To: None <gnats-bugs@gnats.netbsd.org>
From: Joseph Myers <jsm28@cam.ac.uk>
List: netbsd-bugs
Date: 12/27/1998 23:03:06
>Number: 6660
>Category: bin
>Synopsis: [PATCH] Battlestar: patch to use const
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Dec 27 15:50:00 1998
>Last-Modified:
>Originator: Joseph S. Myers
>Organization:
Trinity College, University of Cambridge, UK
>Release: NetBSD-current of 1998-12-07
>Environment:
[
System: Linux decomino 2.0.36 #1 Mon Nov 16 14:25:34 UTC 1998 i686 unknown
Architecture: i686
]
>Description:
The appended patch makes battlestar(6) use `const' where appropriate.
>How-To-Repeat:
>Fix:
diff -ruN battlestar/com1.c battlestar+/com1.c
--- battlestar/com1.c Sat Oct 11 11:50:07 1997
+++ battlestar+/com1.c Sun Dec 27 22:51:16 1998
@@ -75,7 +75,7 @@
int tothis; /* Day objects are permanent. Night objects
* are added */
{ /* at dusk, and subtracted at dawn. */
- struct objs *p;
+ const struct objs *p;
int i, j;
if (tothis == TONIGHT) {
diff -ruN battlestar/com4.c battlestar+/com4.c
--- battlestar/com4.c Sat Oct 11 11:50:10 1997
+++ battlestar+/com4.c Sun Dec 27 22:51:40 1998
@@ -192,7 +192,7 @@
int
throw(name)
- char *name;
+ const char *name;
{
int n;
int deposit = 0;
@@ -273,7 +273,7 @@
int
drop(name)
- char *name;
+ const char *name;
{
int firstnumber, value;
diff -ruN battlestar/com6.c battlestar+/com6.c
--- battlestar/com6.c Tue Oct 14 11:09:14 1997
+++ battlestar+/com6.c Sun Dec 27 22:52:07 1998
@@ -136,7 +136,7 @@
sigprocmask(SIG_SETMASK, &osigset, (sigset_t *) 0);
}
-char *
+const char *
rate()
{
int score;
diff -ruN battlestar/dayobjs.c battlestar+/dayobjs.c
--- battlestar/dayobjs.c Sat Oct 11 11:50:16 1997
+++ battlestar+/dayobjs.c Sun Dec 27 22:52:20 1998
@@ -44,7 +44,7 @@
#include "extern.h"
-struct objs dayobjs[] = {
+const struct objs dayobjs[] = {
{236, HORSE},
{237, CAR},
{275, POT},
diff -ruN battlestar/extern.h battlestar+/extern.h
--- battlestar/extern.h Mon Sep 14 11:04:50 1998
+++ battlestar+/extern.h Sun Dec 27 22:54:37 1998
@@ -223,7 +223,7 @@
#define MAXCUMBER 10
struct room {
- char *name;
+ const char *name;
int link[8];
#define north link[0]
#define south link[1]
@@ -233,7 +233,7 @@
#define access link[5]
#define down link[6]
#define flyhere link[7]
- char *desc;
+ const char *desc;
unsigned int objects[NUMOFWORDS];
};
extern struct room dayfile[];
@@ -241,11 +241,11 @@
struct room *location;
/* object characteristics */
-char *objdes[NUMOFOBJECTS];
-char *objsht[NUMOFOBJECTS];
-char *ouch[NUMOFINJURIES];
-int objwt[NUMOFOBJECTS];
-int objcumber[NUMOFOBJECTS];
+const char *const objdes[NUMOFOBJECTS];
+const char *const objsht[NUMOFOBJECTS];
+const char *const ouch[NUMOFINJURIES];
+const int objwt[NUMOFOBJECTS];
+const int objcumber[NUMOFOBJECTS];
/* current input line */
#define NWORD 20 /* words per line */
@@ -286,7 +286,7 @@
char uname[9];
struct wlist {
- char *string;
+ const char *string;
int value, article;
struct wlist *next;
};
@@ -300,13 +300,13 @@
short room;
short obj;
};
-extern struct objs dayobjs[];
-extern struct objs nightobjs[];
+extern const struct objs dayobjs[];
+extern const struct objs nightobjs[];
void blast __P((void));
void bury __P((void));
-int card __P((char *, int));
-int checkout __P((char *));
+int card __P((const char *, int));
+int checkout __P((const char *));
void chime __P((void));
void convert __P((int));
void crash __P((void));
@@ -317,14 +317,14 @@
int draw __P((void));
void drink __P((void));
int drive __P((void));
-int drop __P((char *));
+int drop __P((const char *));
int eat __P((void));
void endfly __P((void));
int fight __P((int, int));
int follow __P((void));
void getutmp __P((char *));
int give __P((void));
-int hash __P((char *));
+int hash __P((const char *));
void initialize __P((char));
void install __P((struct wlist *));
int jump __P((void));
@@ -355,18 +355,18 @@
int take __P((unsigned int[]));
int takeoff __P((void));
void target __P((void));
-int throw __P((char *));
-int ucard __P((unsigned int *));
+int throw __P((const char *));
+int ucard __P((const unsigned int *));
int use __P((void));
int visual __P((void));
int wearit __P((void));
void whichway __P((struct room));
-int wizard __P((char *));
+int wizard __P((const char *));
void wordinit __P((void));
void writedes __P((void));
int zzz __P((void));
-char *getcom __P((char *, int, char *, char *));
+char *getcom __P((char *, int, const char *, const char *));
char *getword __P((char *, char *, int));
-char *rate __P((void));
-char *truedirec __P((int, char));
-struct wlist *lookup __P((char *));
+const char *rate __P((void));
+const char *truedirec __P((int, char));
+struct wlist *lookup __P((const char *));
diff -ruN battlestar/getcom.c battlestar+/getcom.c
--- battlestar/getcom.c Sat Oct 11 11:50:19 1997
+++ battlestar+/getcom.c Sun Dec 27 22:54:54 1998
@@ -48,7 +48,7 @@
getcom(buf, size, prompt, error)
char *buf;
int size;
- char *prompt, *error;
+ const char *prompt, *error;
{
for (;;) {
fputs(prompt, stdout);
diff -ruN battlestar/globals.c battlestar+/globals.c
--- battlestar/globals.c Sat Oct 11 11:50:20 1997
+++ battlestar+/globals.c Sun Dec 27 22:55:37 1998
@@ -47,7 +47,7 @@
int WEIGHT = MAXWEIGHT;
int CUMBER = MAXCUMBER;
-char *objdes[NUMOFOBJECTS] = {
+const char *const objdes[NUMOFOBJECTS] = {
"There is a knife here",
"There is an exquisitely crafted sword and scabbard here.",
0, /* can land from here */
@@ -115,7 +115,7 @@
};
-char *objsht[NUMOFOBJECTS] = {
+const char *const objsht[NUMOFOBJECTS] = {
"knife",
"fine sword",
0,
@@ -182,7 +182,7 @@
"diamond block"
};
-char *ouch[NUMOFINJURIES] = {
+const char *const ouch[NUMOFINJURIES] = {
"some minor abrasions",
"some minor lacerations",
"a minor puncture wound",
@@ -198,7 +198,7 @@
"a broken neck"
};
-int objwt[NUMOFOBJECTS] = {
+const int objwt[NUMOFOBJECTS] = {
1, 5, 0, 10, 15, 2, 10, 10,
3, 5, 50, 2500, 2, 1, 100, 1,
2, 1, 1, 1, 60, 10, 5, 0,
@@ -209,7 +209,7 @@
50, 45, 45, 100, 2000, 30, 20, 10
};
-int objcumber[NUMOFOBJECTS] = {
+const int objcumber[NUMOFOBJECTS] = {
1, 5, 0, 150, 10, 1, 5, 2,
2, 1, 5, 10, 1, 1, 10, 1,
1, 1, 1, 1, 7, 5, 4, 0,
diff -ruN battlestar/init.c battlestar+/init.c
--- battlestar/init.c Sat Oct 11 11:50:21 1997
+++ battlestar+/init.c Sun Dec 27 22:56:33 1998
@@ -48,7 +48,7 @@
initialize(startup)
char startup;
{
- struct objs *p;
+ const struct objs *p;
puts("Version 4.2, fall 1984.");
puts("First Adventure game written by His Lordship, the honorable");
@@ -83,7 +83,7 @@
strcpy(uname, ptr ? ptr->pw_name : "");
}
-char *list[] = { /* hereditary wizards */
+const char *const list[] = { /* hereditary wizards */
"riggle",
"chris",
"edward",
@@ -94,7 +94,7 @@
0
};
-char *badguys[] = {
+const char *const badguys[] = {
"wnj",
"root",
"ted",
@@ -103,7 +103,7 @@
int
wizard(uname)
- char *uname;
+ const char *uname;
{
int flag;
@@ -114,9 +114,9 @@
int
checkout(uname)
- char *uname;
+ const char *uname;
{
- char **ptr;
+ const char *const *ptr;
for (ptr = list; *ptr; ptr++)
if (strcmp(*ptr, uname) == 0)
diff -ruN battlestar/misc.c battlestar+/misc.c
--- battlestar/misc.c Sat Oct 11 11:50:22 1997
+++ battlestar+/misc.c Sun Dec 27 22:56:46 1998
@@ -46,7 +46,7 @@
int
card(array, size) /* for beenthere, injuries */
- char *array;
+ const char *array;
int size;
{
char *end = array + size;
@@ -60,7 +60,7 @@
int
ucard(array)
- unsigned int *array;
+ const unsigned int *array;
{
int j = 0, n;
diff -ruN battlestar/nightobjs.c battlestar+/nightobjs.c
--- battlestar/nightobjs.c Sat Oct 11 11:50:25 1997
+++ battlestar+/nightobjs.c Sun Dec 27 22:56:53 1998
@@ -44,7 +44,7 @@
#include "extern.h"
-struct objs nightobjs[] = {
+const struct objs nightobjs[] = {
{218, PAJAMAS},
{235, NATIVE},
{92, PAPAYAS},
diff -ruN battlestar/parse.c battlestar+/parse.c
--- battlestar/parse.c Sat Oct 11 11:50:25 1997
+++ battlestar+/parse.c Sun Dec 27 22:57:08 1998
@@ -55,7 +55,7 @@
int
hash(s)
- char *s;
+ const char *s;
{
int hashval = 0;
@@ -69,7 +69,7 @@
struct wlist *
lookup(s)
- char *s;
+ const char *s;
{
struct wlist *wp;
diff -ruN battlestar/room.c battlestar+/room.c
--- battlestar/room.c Sat Oct 11 11:50:26 1997
+++ battlestar+/room.c Sun Dec 27 22:57:30 1998
@@ -48,7 +48,7 @@
writedes()
{
int compass;
- char *p;
+ const char *p;
int c;
printf("\n\t%s\n", location[position].name);
@@ -114,7 +114,7 @@
}
}
-char *
+const char *
truedirec(way, option)
int way;
char option;
>Audit-Trail:
>Unformatted: