diff options
Diffstat (limited to 'fortune/fortune/fortune.c')
| -rw-r--r-- | fortune/fortune/fortune.c | 64 |
1 files changed, 34 insertions, 30 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; |
