summaryrefslogtreecommitdiffstats
path: root/fortune
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>1999-09-08 21:17:44 +0000
committerjsm <jsm@NetBSD.org>1999-09-08 21:17:44 +0000
commit04f4d7044367099914cf1906ae27ac20c24e44cf (patch)
treec17cb5c2f270bbb70eeba18cbe2bcfa43cfd8e10 /fortune
parentf9706028dd6e2afabb6bd63d02d7bc90f78e4aab (diff)
downloadbsdgames-darwin-04f4d7044367099914cf1906ae27ac20c24e44cf.tar.gz
bsdgames-darwin-04f4d7044367099914cf1906ae27ac20c24e44cf.zip
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.
Diffstat (limited to 'fortune')
-rw-r--r--fortune/fortune/fortune.c64
-rw-r--r--fortune/strfile/strfile.c10
2 files changed, 39 insertions, 35 deletions
diff --git a/fortune/fortune/fortune.c b/fortune/fortune/fortune.c
index 1ed64301..a2c1075a 100644
--- a/fortune/fortune/fortune.c
+++ b/fortune/fortune/fortune.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fortune.c,v 1.15 1999/08/21 07:02:46 simonb Exp $ */
+/* $NetBSD: fortune.c,v 1.16 1999/09/08 21:17:48 jsm Exp $ */
/*-
* Copyright (c) 1986, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1986, 1993\n\
#if 0
static char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: fortune.c,v 1.15 1999/08/21 07:02:46 simonb Exp $");
+__RCSID("$NetBSD: fortune.c,v 1.16 1999/09/08 21:17:48 jsm Exp $");
#endif
#endif /* not lint */
@@ -89,8 +89,8 @@ typedef struct fd {
int fd, datfd;
off_t pos;
FILE *inf;
- char *name;
- char *path;
+ const char *name;
+ const char *path;
char *datfile, *posfile;
bool read_tbl;
bool was_pos_file;
@@ -129,9 +129,9 @@ STRFILE Noprob_tbl; /* sum of data for all no prob files */
int add_dir __P((FILEDESC *));
int add_file __P((int,
- char *, char *, FILEDESC **, FILEDESC **, FILEDESC *));
-void all_forts __P((FILEDESC *, char *));
-char *copy __P((char *, u_int));
+ const char *, const char *, FILEDESC **, FILEDESC **, FILEDESC *));
+void all_forts __P((FILEDESC *, const char *));
+char *copy __P((const char *, u_int));
void display __P((FILEDESC *));
void do_free __P((void *));
void *do_malloc __P((u_int));
@@ -142,14 +142,14 @@ void get_pos __P((FILEDESC *));
void get_tbl __P((FILEDESC *));
void getargs __P((int, char *[]));
void init_prob __P((void));
-int is_dir __P((char *));
-int is_fortfile __P((char *, char **, char **, int));
-int is_off_name __P((char *));
+int is_dir __P((const char *));
+int is_fortfile __P((const char *, char **, char **, int));
+int is_off_name __P((const char *));
int main __P((int, char *[]));
int max __P((int, int));
FILEDESC *
new_fp __P((void));
-char *off_name __P((char *));
+char *off_name __P((const char *));
void open_dat __P((FILEDESC *));
void open_fp __P((FILEDESC *));
FILEDESC *
@@ -409,7 +409,7 @@ form_file_list(files, file_cnt)
int file_cnt;
{
int i, percent;
- char *sp;
+ const char *sp;
if (file_cnt == 0) {
if (Find_files)
@@ -467,29 +467,32 @@ form_file_list(files, file_cnt)
int
add_file(percent, file, dir, head, tail, parent)
int percent;
- char *file;
- char *dir;
+ const char *file;
+ const char *dir;
FILEDESC **head, **tail;
FILEDESC *parent;
{
FILEDESC *fp;
int fd;
- char *path, *offensive;
+ const char *path;
+ char *tpath, *offensive;
bool was_malloc;
bool isdir;
if (dir == NULL) {
path = file;
+ tpath = NULL;
was_malloc = FALSE;
}
else {
- path = do_malloc((unsigned int) (strlen(dir) + strlen(file) + 2));
- (void) strcat(strcat(strcpy(path, dir), "/"), file);
+ tpath = do_malloc((unsigned int) (strlen(dir) + strlen(file) + 2));
+ (void) strcat(strcat(strcpy(tpath, dir), "/"), file);
+ path = tpath;
was_malloc = TRUE;
}
if ((isdir = is_dir(path)) && parent != NULL) {
if (was_malloc)
- free(path);
+ free(tpath);
return FALSE; /* don't recurse */
}
offensive = NULL;
@@ -499,7 +502,7 @@ add_file(percent, file, dir, head, tail, parent)
was_malloc = TRUE;
if (Offend) {
if (was_malloc)
- free(path);
+ free(tpath);
path = offensive;
file = off_name(file);
}
@@ -519,7 +522,7 @@ over:
if (All_forts && offensive != NULL) {
path = offensive;
if (was_malloc)
- free(path);
+ free(tpath);
offensive = NULL;
was_malloc = TRUE;
DPRINTF(1, (stderr, "\ttrying \"%s\"\n", path));
@@ -532,7 +535,7 @@ over:
if (parent == NULL)
warn("Cannot open `%s'", path);
if (was_malloc)
- free(path);
+ free(tpath);
return FALSE;
}
@@ -553,7 +556,7 @@ over:
warnx("`%s' not a fortune file or directory", path);
free((char *) fp);
if (was_malloc)
- free(path);
+ free(tpath);
do_free(fp->datfile);
do_free(fp->posfile);
do_free(offensive);
@@ -617,7 +620,7 @@ new_fp()
*/
char *
off_name(file)
- char *file;
+ const char *file;
{
char *new;
@@ -631,7 +634,7 @@ off_name(file)
*/
int
is_off_name(file)
- char *file;
+ const char *file;
{
int len;
@@ -647,7 +650,7 @@ is_off_name(file)
void
all_forts(fp, offensive)
FILEDESC *fp;
- char *offensive;
+ const char *offensive;
{
char *sp;
FILEDESC *scene, *obscene;
@@ -734,7 +737,7 @@ add_dir(fp)
*/
int
is_dir(file)
- char *file;
+ const char *file;
{
struct stat sbuf;
@@ -753,13 +756,14 @@ is_dir(file)
/* ARGSUSED */
int
is_fortfile(file, datp, posp, check_for_offend)
- char *file, **datp, **posp;
+ const char *file;
+ char **datp, **posp;
int check_for_offend;
{
int i;
- char *sp;
+ const char *sp;
char *datfile;
- static char *suflist[] = { /* list of "illegal" suffixes" */
+ static const char *const suflist[] = { /* list of "illegal" suffixes" */
"dat", "pos", "c", "h", "p", "i", "f",
"pas", "ftn", "ins.c", "ins,pas",
"ins.ftn", "sml",
@@ -822,7 +826,7 @@ is_fortfile(file, datp, posp, check_for_offend)
*/
char *
copy(str, len)
- char *str;
+ const char *str;
unsigned int len;
{
char *new, *sp;
diff --git a/fortune/strfile/strfile.c b/fortune/strfile/strfile.c
index a27c2711..69357391 100644
--- a/fortune/strfile/strfile.c
+++ b/fortune/strfile/strfile.c
@@ -1,4 +1,4 @@
-/* $NetBSD: strfile.c,v 1.9 1999/08/21 07:02:46 simonb Exp $ */
+/* $NetBSD: strfile.c,v 1.10 1999/09/08 21:17:49 jsm Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: strfile.c,v 1.9 1999/08/21 07:02:46 simonb Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.10 1999/09/08 21:17:49 jsm Exp $");
#endif
#endif /* not lint */
@@ -396,12 +396,12 @@ int
cmp_str(vp1, vp2)
const void *vp1, *vp2;
{
- STR *p1, *p2;
+ const STR *p1, *p2;
int c1, c2;
int n1, n2;
- p1 = (STR *)vp1;
- p2 = (STR *)vp2;
+ p1 = (const STR *)vp1;
+ p2 = (const STR *)vp2;
# define SET_N(nf,ch) (nf = (ch == '\n'))
# define IS_END(ch,nf) (ch == Delimch && nf)