Skip to content

Commit 092d313

Browse files
jsmjsm
jsm
authored and
jsm
committed
Add use of `const' where appropriate to the games.
This merges in all such remaining changes from the Linux port of the NetBSD games, except in hunt (where substantial changes from OpenBSD need to be looked at). Some such changes were previously covered in PRs bin/6041, bin/6146, bin/6148, bin/6150, bin/6151, bin/6580, bin/6660, bin/7993, bin/7994, bin/8039, bin/8057 and bin/8093.
1 parent 44a90d0 commit 092d313

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+653
-636
lines changed

games/boggle/boggle/bog.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: bog.c,v 1.11 1999/07/21 04:02:29 hubertf Exp $ */
1+
/* $NetBSD: bog.c,v 1.12 1999/09/08 21:17:44 jsm Exp $ */
22

33
/*-
44
* Copyright (c) 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\n\
4646
#if 0
4747
static char sccsid[] = "@(#)bog.c 8.2 (Berkeley) 5/4/95";
4848
#else
49-
__RCSID("$NetBSD: bog.c,v 1.11 1999/07/21 04:02:29 hubertf Exp $");
49+
__RCSID("$NetBSD: bog.c,v 1.12 1999/09/08 21:17:44 jsm Exp $");
5050
#endif
5151
#endif /* not lint */
5252

@@ -101,10 +101,12 @@ int wordpath[MAXWORDLEN + 1];
101101
int wordlen; /* Length of last word returned by nextword() */
102102
int usedbits;
103103

104-
char *pword[MAXPWORDS], pwords[MAXPSPACE], *pwordsp;
104+
const char *pword[MAXPWORDS];
105+
char pwords[MAXPSPACE], *pwordsp;
105106
int npwords;
106107

107-
char *mword[MAXMWORDS], mwords[MAXMSPACE], *mwordsp;
108+
const char *mword[MAXMWORDS];
109+
char mwords[MAXMSPACE], *mwordsp;
108110
int nmwords;
109111

110112
int ngames = 0;
@@ -415,10 +417,11 @@ timesup: ;
415417
*/
416418
int
417419
checkword(word, prev, path)
418-
char *word;
420+
const char *word;
419421
int prev, *path;
420422
{
421-
char *p, *q;
423+
const char *p;
424+
char *q;
422425
int i, *lm;
423426

424427
if (debug) {
@@ -498,10 +501,10 @@ checkword(word, prev, path)
498501
*/
499502
int
500503
validword(word)
501-
char *word;
504+
const char *word;
502505
{
503506
int j;
504-
char *q, *w;
507+
const char *q, *w;
505508

506509
j = word[0] - 'a';
507510
if (dictseek(dictfp, dictindex[j].start, SEEK_SET) < 0) {
@@ -534,7 +537,8 @@ validword(word)
534537
void
535538
checkdict()
536539
{
537-
char *p, **pw, *w;
540+
char *p, *w;
541+
const char **pw;
538542
int i;
539543
int prevch, previndex, *pi, *qi, st;
540544

@@ -612,12 +616,12 @@ checkdict()
612616
*/
613617
void
614618
newgame(b)
615-
char *b;
619+
const char *b;
616620
{
617621
int i, p, q;
618-
char *tmp;
622+
const char *tmp;
619623
int *lm[26];
620-
static char *cubes[16] = {
624+
static const char *cubes[16] = {
621625
"ednosw", "aaciot", "acelrs", "ehinps",
622626
"eefhiy", "elpstu", "acdemp", "gilruw",
623627
"egkluy", "ahmors", "abilty", "adenvz",
@@ -684,7 +688,7 @@ int
684688
compar(p, q)
685689
const void *p, *q;
686690
{
687-
return (strcmp(*(char **)p, *(char **)q));
691+
return (strcmp(*(const char *const *)p, *(const char *const *)q));
688692
}
689693

690694
void

games/boggle/boggle/extern.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: extern.h,v 1.4 1998/09/13 15:27:26 hubertf Exp $ */
1+
/* $NetBSD: extern.h,v 1.5 1999/09/08 21:17:44 jsm Exp $ */
22

33
/*-
44
* Copyright (c) 1993
@@ -35,11 +35,11 @@
3535
* @(#)extern.h 8.1 (Berkeley) 6/11/93
3636
*/
3737

38-
void addword __P((char *));
38+
void addword __P((const char *));
3939
void badword __P((void));
4040
char *batchword __P((FILE *));
4141
void checkdict __P((void));
42-
int checkword __P((char *, int, int *));
42+
int checkword __P((const char *, int, int *));
4343
void cleanup __P((void));
4444
void delay __P((int));
4545
long dictseek __P((FILE *, long, int));
@@ -50,24 +50,24 @@ void getword __P((char *));
5050
int help __P((void));
5151
int inputch __P((void));
5252
int loaddict __P((FILE *));
53-
int loadindex __P((char *));
54-
void newgame __P((char *));
53+
int loadindex __P((const char *));
54+
void newgame __P((const char *));
5555
char *nextword __P((FILE *));
56-
FILE *opendict __P((char *));
56+
FILE *opendict __P((const char *));
5757
void playgame __P((void));
58-
void prompt __P((char *));
59-
void prtable __P((char *[],
60-
int, int, int, void (*)(char *[], int), int (*)(char *[], int)));
61-
void putstr __P((char *));
58+
void prompt __P((const char *));
59+
void prtable __P((const char *const [],
60+
int, int, int, void (*)(const char *const [], int), int (*)(const char *const [], int)));
61+
void putstr __P((const char *));
6262
void redraw __P((void));
6363
void results __P((void));
6464
int setup __P((int, time_t));
65-
void showboard __P((char *));
66-
void showstr __P((char *, int));
65+
void showboard __P((const char *));
66+
void showstr __P((const char *, int));
6767
void showword __P((int));
6868
void starttime __P((void));
6969
void startwords __P((void));
7070
void stoptime __P((void));
7171
int timerch __P((void));
7272
void usage __P((void)) __attribute__((__noreturn__));
73-
int validword __P((char *));
73+
int validword __P((const char *));

games/boggle/boggle/mach.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: mach.c,v 1.8 1997/10/13 21:09:59 cjs Exp $ */
1+
/* $NetBSD: mach.c,v 1.9 1999/09/08 21:17:44 jsm Exp $ */
22

33
/*-
44
* Copyright (c) 1993
@@ -41,7 +41,7 @@
4141
#if 0
4242
static char sccsid[] = "@(#)mach.c 8.1 (Berkeley) 6/11/93";
4343
#else
44-
__RCSID("$NetBSD: mach.c,v 1.8 1997/10/13 21:09:59 cjs Exp $");
44+
__RCSID("$NetBSD: mach.c,v 1.9 1999/09/08 21:17:44 jsm Exp $");
4545
#endif
4646
#endif /* not lint */
4747

@@ -70,16 +70,16 @@ static int colstarts[MAXCOLS], ncolstarts;
7070
static int lastline;
7171
int ncols, nlines;
7272

73-
extern char *pword[], *mword[];
73+
extern const char *pword[], *mword[];
7474
extern int ngames, nmwords, npwords, tnmwords, tnpwords;
7575

7676
static void cont_catcher __P((int));
77-
static int prwidth __P((char *[], int));
78-
static void prword __P((char *[], int));
77+
static int prwidth __P((const char *const [], int));
78+
static void prword __P((const char *const [], int));
7979
static void stop_catcher __P((int));
8080
static void tty_cleanup __P((void));
8181
static int tty_setup __P((void));
82-
static void tty_showboard __P((char *));
82+
static void tty_showboard __P((const char *));
8383
static void winch_catcher __P((int));
8484

8585
/*
@@ -150,15 +150,15 @@ results()
150150

151151
static void
152152
prword(base, indx)
153-
char *base[];
153+
const char *const base[];
154154
int indx;
155155
{
156156
printw("%s", base[indx]);
157157
}
158158

159159
static int
160160
prwidth(base, indx)
161-
char *base[];
161+
const char *const base[];
162162
int indx;
163163
{
164164
return (strlen(base[indx]));
@@ -339,7 +339,7 @@ startwords()
339339
*/
340340
void
341341
addword(w)
342-
char *w;
342+
const char *w;
343343
{
344344
int n;
345345

@@ -410,7 +410,6 @@ findword()
410410
char buf[MAXWORDLEN + 1];
411411
extern char board[];
412412
extern int usedbits, wordpath[];
413-
extern char *mword[], *pword[];
414413
extern int nmwords, npwords;
415414

416415
getyx(stdscr, r, c);
@@ -480,7 +479,7 @@ findword()
480479
*/
481480
void
482481
showstr(str, delaysecs)
483-
char *str;
482+
const char *str;
484483
int delaysecs;
485484
{
486485
addstr(str);
@@ -493,7 +492,7 @@ showstr(str, delaysecs)
493492

494493
void
495494
putstr(s)
496-
char *s;
495+
const char *s;
497496
{
498497
addstr(s);
499498
}
@@ -561,14 +560,14 @@ getword(q)
561560

562561
void
563562
showboard(b)
564-
char *b;
563+
const char *b;
565564
{
566565
tty_showboard(b);
567566
}
568567

569568
void
570569
prompt(mesg)
571-
char *mesg;
570+
const char *mesg;
572571
{
573572
move(PROMPT_LINE, PROMPT_COL);
574573
printw("%s", mesg);
@@ -660,7 +659,7 @@ tty_cleanup()
660659

661660
static void
662661
tty_showboard(b)
663-
char *b;
662+
const char *b;
664663
{
665664
int i;
666665
int line;

games/boggle/boggle/prtable.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: prtable.c,v 1.4 1997/10/11 02:12:17 lukem Exp $ */
1+
/* $NetBSD: prtable.c,v 1.5 1999/09/08 21:17:45 jsm Exp $ */
22

33
/*-
44
* Copyright (c) 1993
@@ -40,7 +40,7 @@
4040

4141
#include <sys/cdefs.h>
4242
#ifndef lint
43-
__RCSID("$NetBSD: prtable.c,v 1.4 1997/10/11 02:12:17 lukem Exp $");
43+
__RCSID("$NetBSD: prtable.c,v 1.5 1999/09/08 21:17:45 jsm Exp $");
4444
#endif /* not lint */
4545

4646
#include <curses.h>
@@ -49,7 +49,7 @@ __RCSID("$NetBSD: prtable.c,v 1.4 1997/10/11 02:12:17 lukem Exp $");
4949

5050
#define NCOLS 5
5151

52-
static int get_maxlen __P((char *[], int, int (*)(char **, int)));
52+
static int get_maxlen __P((const char *const [], int, int (*)(const char *const *, int)));
5353

5454
/*
5555
* Routine to print a table
@@ -68,10 +68,10 @@ static int get_maxlen __P((char *[], int, int (*)(char **, int)));
6868
*/
6969
void
7070
prtable(base, num, d_cols, width, prentry, length)
71-
char *base[];
71+
const char *const base[];
7272
int num, d_cols, width;
73-
void (*prentry) __P((char *[], int));
74-
int (*length) __P((char *[], int));
73+
void (*prentry) __P((const char *const [], int));
74+
int (*length) __P((const char *const [], int));
7575
{
7676
int c, j;
7777
int a, b, cols, loc, maxlen, nrows, z;
@@ -119,9 +119,9 @@ prtable(base, num, d_cols, width, prentry, length)
119119

120120
static int
121121
get_maxlen(base, num, length)
122-
char *base[];
122+
const char *const base[];
123123
int num;
124-
int (*length) __P((char **, int));
124+
int (*length) __P((const char *const *, int));
125125
{
126126
int i, len, max;
127127

games/boggle/boggle/word.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: word.c,v 1.4 1997/10/11 02:12:18 lukem Exp $ */
1+
/* $NetBSD: word.c,v 1.5 1999/09/08 21:17:45 jsm Exp $ */
22

33
/*-
44
* Copyright (c) 1993
@@ -41,7 +41,7 @@
4141
#if 0
4242
static char sccsid[] = "@(#)word.c 8.1 (Berkeley) 6/11/93";
4343
#else
44-
__RCSID("$NetBSD: word.c,v 1.4 1997/10/11 02:12:18 lukem Exp $");
44+
__RCSID("$NetBSD: word.c,v 1.5 1999/09/08 21:17:45 jsm Exp $");
4545
#endif
4646
#endif /* not lint */
4747

@@ -127,7 +127,7 @@ dictseek(fp, offset, ptrname)
127127

128128
FILE *
129129
opendict(dict)
130-
char *dict;
130+
const char *dict;
131131
{
132132
FILE *fp;
133133

@@ -188,7 +188,7 @@ loaddict(fp)
188188
*/
189189
int
190190
loadindex(indexfile)
191-
char *indexfile;
191+
const char *indexfile;
192192
{
193193
int i, j;
194194
char buf[BUFSIZ];

games/caesar/caesar.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: caesar.c,v 1.8 1999/07/21 04:04:21 hubertf Exp $ */
1+
/* $NetBSD: caesar.c,v 1.9 1999/09/08 21:17:46 jsm Exp $ */
22

33
/*
44
* Copyright (c) 1989, 1993
@@ -51,7 +51,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
5151
#if 0
5252
static char sccsid[] = "@(#)caesar.c 8.1 (Berkeley) 5/31/93";
5353
#else
54-
__RCSID("$NetBSD: caesar.c,v 1.8 1999/07/21 04:04:21 hubertf Exp $");
54+
__RCSID("$NetBSD: caesar.c,v 1.9 1999/09/08 21:17:46 jsm Exp $");
5555
#endif
5656
#endif /* not lint */
5757

@@ -81,7 +81,7 @@ double stdf[26] = {
8181

8282

8383
int main __P((int, char *[]));
84-
void printit __P((char *)) __attribute__((__noreturn__));
84+
void printit __P((const char *)) __attribute__((__noreturn__));
8585

8686
int
8787
main(argc, argv)
@@ -152,7 +152,7 @@ main(argc, argv)
152152

153153
void
154154
printit(arg)
155-
char *arg;
155+
const char *arg;
156156
{
157157
int ch, rot;
158158

0 commit comments

Comments
 (0)