[PATCH] games/fortune WARNS6
Peter Avalos
pavalos at theshell.com
Sun Jul 31 06:47:23 PDT 2005
Here's a patch to bring games/fortune up to WARNS6.
http://www.theshell.com/~pavalos/wip/fortune.diff
--Peter
Index: games/fortune/fortune/Makefile
===================================================================
RCS file: /home/dcvs/src/games/fortune/fortune/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- games/fortune/fortune/Makefile 17 Jun 2003 04:25:24 -0000 1.2
+++ games/fortune/fortune/Makefile 31 Jul 2005 10:03:12 -0000
@@ -7,6 +7,7 @@
CFLAGS+=-DDEBUG -Wall -I${.CURDIR}/../strfile
DPADD= ${LIBCOMPAT}
LDADD= -lcompat
+WARNS?= 6
.include "${.CURDIR}/../../Makefile.inc"
.include <bsd.prog.mk>
Index: games/fortune/fortune/fortune.c
===================================================================
RCS file: /home/dcvs/src/games/fortune/fortune/fortune.c,v
retrieving revision 1.3
diff -u -r1.3 fortune.c
--- games/fortune/fortune/fortune.c 12 Nov 2003 14:53:53 -0000 1.3
+++ games/fortune/fortune/fortune.c 31 Jul 2005 10:03:12 -0000
@@ -177,9 +177,7 @@
#endif
int
-main(ac, av)
-int ac;
-char *av[];
+main(int ac, char **av)
{
#ifdef OK_TO_WRITE_DISK
int fd;
@@ -233,8 +231,7 @@
}
void
-display(fp)
-FILEDESC *fp;
+display(FILEDESC *fp)
{
char *p;
unsigned char ch;
@@ -267,7 +264,7 @@
* Return the length of the fortune.
*/
int
-fortlen()
+fortlen(void)
{
int nchar;
char line[BUFSIZ];
@@ -290,16 +287,12 @@
* This routine evaluates the arguments on the command line
*/
void
-getargs(argc, argv)
-int argc;
-char **argv;
+getargs(int argc, char **argv)
{
int ignore_case;
# ifndef NO_REGEX
char *pat;
# endif /* NO_REGEX */
- extern char *optarg;
- extern int optind;
int ch;
ignore_case = FALSE;
@@ -394,9 +387,7 @@
* Form the file list from the file specifications.
*/
int
-form_file_list(files, file_cnt)
-char **files;
-int file_cnt;
+form_file_list(char **files, int file_cnt)
{
int i, percent;
char *sp;
@@ -458,12 +449,7 @@
* Add a file to the file list.
*/
int
-add_file(percent, file, dir, head, tail, parent)
-int percent;
-char *file;
-char *dir;
-FILEDESC **head, **tail;
-FILEDESC *parent;
+add_file(int percent, char *file, char *dir, FILEDESC **head, FILEDESC **tail, FILEDESC *parent)
{
FILEDESC *fp;
int fd;
@@ -588,7 +574,7 @@
* Return a pointer to an initialized new FILEDESC.
*/
FILEDESC *
-new_fp()
+new_fp(void)
{
FILEDESC *fp;
@@ -613,8 +599,7 @@
* Return a pointer to the offensive version of a file of this name.
*/
char *
-off_name(file)
-char *file;
+off_name(char *file)
{
char *new;
@@ -627,8 +612,7 @@
* Is the file an offensive-style name?
*/
int
-is_off_name(file)
-char *file;
+is_off_name(char *file)
{
int len;
@@ -642,9 +626,7 @@
* there are two children to be a parent of.
*/
void
-all_forts(fp, offensive)
-FILEDESC *fp;
-char *offensive;
+all_forts(FILEDESC *fp, char *offensive)
{
char *sp;
FILEDESC *scene, *obscene;
@@ -692,8 +674,7 @@
* Add the contents of an entire directory.
*/
int
-add_dir(fp)
-FILEDESC *fp;
+add_dir(FILEDESC *fp)
{
DIR *dir;
struct dirent *dirent;
@@ -731,8 +712,7 @@
* Return TRUE if the file is a directory, FALSE otherwise.
*/
int
-is_dir(file)
-char *file;
+is_dir(char *file)
{
auto struct stat sbuf;
@@ -750,9 +730,7 @@
*/
/* ARGSUSED */
int
-is_fortfile(file, datp, posp, check_for_offend)
-char *file, **datp, **posp;
-int check_for_offend;
+is_fortfile(char *file, char **datp, char **posp, int check_for_offend)
{
int i;
char *sp;
@@ -831,9 +809,7 @@
* Return a malloc()'ed copy of the string
*/
char *
-copy(str, len)
-char *str;
-unsigned int len;
+copy(char *str, unsigned int len)
{
char *new, *sp;
@@ -850,8 +826,7 @@
* Do a malloc, checking for NULL return.
*/
void *
-do_malloc(size)
-unsigned int size;
+do_malloc(unsigned int size)
{
void *new;
@@ -867,8 +842,7 @@
* Free malloc'ed space, if any.
*/
void
-do_free(ptr)
-void *ptr;
+do_free(void *ptr)
{
if (ptr != NULL)
free(ptr);
@@ -879,7 +853,7 @@
* Initialize the fortune probabilities.
*/
void
-init_prob()
+init_prob(void)
{
FILEDESC *fp, *last = NULL;
int percent, num_noprob, frac;
@@ -951,7 +925,7 @@
* Get the fortune data file's seek pointer for the next fortune.
*/
void
-get_fort()
+get_fort(void)
{
FILEDESC *fp;
int choice;
@@ -1014,8 +988,7 @@
* Pick a child from a chosen parent.
*/
FILEDESC *
-pick_child(parent)
-FILEDESC *parent;
+pick_child(FILEDESC *parent)
{
FILEDESC *fp;
int choice;
@@ -1051,8 +1024,7 @@
* Sum up all the noprob probabilities, starting with fp.
*/
void
-sum_noprobs(fp)
-FILEDESC *fp;
+sum_noprobs(FILEDESC *fp)
{
static bool did_noprobs = FALSE;
@@ -1068,8 +1040,7 @@
}
int
-max(i, j)
-int i, j;
+max(int i, int j)
{
return (i >= j ? i : j);
}
@@ -1079,8 +1050,7 @@
* Assocatiate a FILE * with the given FILEDESC.
*/
void
-open_fp(fp)
-FILEDESC *fp;
+open_fp(FILEDESC *fp)
{
if (fp->inf == NULL && (fp->inf = fdopen(fp->fd, "r")) == NULL) {
perror(fp->path);
@@ -1093,8 +1063,7 @@
* Open up the dat file if we need to.
*/
void
-open_dat(fp)
-FILEDESC *fp;
+open_dat(FILEDESC *fp)
{
if (fp->datfd < 0 && (fp->datfd = open(fp->datfile, 0)) < 0) {
perror(fp->datfile);
@@ -1108,8 +1077,7 @@
* return a random number.
*/
void
-get_pos(fp)
-FILEDESC *fp;
+get_pos(FILEDESC *fp)
{
#ifdef OK_TO_WRITE_DISK
int fd;
@@ -1139,8 +1107,7 @@
* Get the tbl data file the datfile.
*/
void
-get_tbl(fp)
-FILEDESC *fp;
+get_tbl(FILEDESC *fp)
{
auto int fd;
FILEDESC *child;
@@ -1179,8 +1146,7 @@
* Zero out the fields we care about in a tbl structure.
*/
void
-zero_tbl(tp)
-STRFILE *tp;
+zero_tbl(STRFILE *tp)
{
tp->str_numstr = 0;
tp->str_longlen = 0;
@@ -1192,8 +1158,7 @@
* Merge the tbl data of t2 into t1.
*/
void
-sum_tbl(t1, t2)
-STRFILE *t1, *t2;
+sum_tbl(STRFILE *t1, STRFILE *t2)
{
t1->str_numstr += t2->str_numstr;
if (t1->str_longlen < t2->str_longlen)
@@ -1209,7 +1174,7 @@
* Print out the file list
*/
void
-print_file_list()
+print_file_list(void)
{
print_list(File_list, 0);
}
@@ -1219,9 +1184,7 @@
* Print out the actual list, recursively.
*/
void
-print_list(list, lev)
-FILEDESC *list;
-int lev;
+print_list(FILEDESC *list, int lev)
{
while (list != NULL) {
fprintf(stderr, "%*s", lev * 4, "");
@@ -1245,8 +1208,7 @@
* Convert the pattern to an ignore-case equivalent.
*/
char *
-conv_pat(orig)
-char *orig;
+conv_pat(char *orig)
{
char *sp;
unsigned int cnt;
@@ -1288,7 +1250,7 @@
* Find all the fortunes which match the pattern we've been given.
*/
int
-find_matches()
+find_matches(void)
{
Fort_len = maxlen_in_list(File_list);
DPRINTF(2, (stderr, "Maximum length is %d\n", Fort_len));
@@ -1306,8 +1268,7 @@
* Return the maximum fortune len in the file list.
*/
int
-maxlen_in_list(list)
-FILEDESC *list;
+maxlen_in_list(FILEDESC *list)
{
FILEDESC *fp;
int len, maxlen;
@@ -1332,8 +1293,7 @@
* Print out the matches from the files in the list.
*/
void
-matches_in_list(list)
-FILEDESC *list;
+matches_in_list(FILEDESC *list)
{
char *sp, *p;
FILEDESC *fp;
@@ -1385,7 +1345,7 @@
# endif /* NO_REGEX */
void
-usage()
+usage(void)
{
(void) fprintf(stderr, "fortune [-a");
#ifdef DEBUG
Index: games/fortune/strfile/Makefile
===================================================================
RCS file: /home/dcvs/src/games/fortune/strfile/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- games/fortune/strfile/Makefile 17 Jun 2003 04:25:24 -0000 1.2
+++ games/fortune/strfile/Makefile 31 Jul 2005 10:03:12 -0000
@@ -6,6 +6,7 @@
MAN= strfile.8
MLINKS= strfile.8 unstr.8
CFLAGS+= -Wall
+WARNS?= 6
.include "${.CURDIR}/../../Makefile.inc"
.include <bsd.prog.mk>
Index: games/fortune/strfile/strfile.c
===================================================================
RCS file: /home/dcvs/src/games/fortune/strfile/strfile.c,v
retrieving revision 1.3
diff -u -r1.3 strfile.c
--- games/fortune/strfile/strfile.c 12 Nov 2003 14:53:53 -0000 1.3
+++ games/fortune/strfile/strfile.c 31 Jul 2005 10:03:12 -0000
@@ -138,13 +138,13 @@
* CHUNKSIZE blocks; if the latter, we just write each pointer,
* and then seek back to the beginning to write in the table.
*/
-int main(ac, av)
-int ac;
-char **av;
+int
+main(int ac, char **av)
{
char *sp, dc;
FILE *inf, *outf;
- long last_off, length, pos, *p;
+ long last_off, pos, *p;
+ unsigned long length;
int first, cnt;
char *nsp;
STR *fp;
@@ -255,9 +255,8 @@
/*
* This routine evaluates arguments from the command line
*/
-void getargs(argc, argv)
-int argc;
-char **argv;
+void
+getargs(int argc, char **argv)
{
int ch;
@@ -309,7 +308,8 @@
}
}
-void usage()
+void
+usage(void)
{
(void) fprintf(stderr,
"strfile [-Ciorsx] [-c char] sourcefile [datafile]\n");
@@ -320,9 +320,8 @@
* add_offset:
* Add an offset to the list, or write it out, as appropriate.
*/
-void add_offset(fp, off)
-FILE *fp;
-long off;
+void
+add_offset(FILE *fp, long off)
{
long net;
@@ -340,7 +339,8 @@
* do_order:
* Order the strings alphabetically (possibly ignoring case).
*/
-void do_order()
+void
+do_order(void)
{
int i;
long *lp;
@@ -359,8 +359,8 @@
Tbl.str_flags |= STR_ORDERED;
}
-static int collate_range_cmp (c1, c2)
- int c1, c2;
+static int
+collate_range_cmp(int c1, int c2)
{
static char s1[2], s2[2];
int ret;
@@ -380,8 +380,8 @@
* cmp_str:
* Compare two strings in the file
*/
-int cmp_str(s1, s2)
-const void *s1, *s2;
+int
+cmp_str(const void *s1, const void *s2)
{
const STR *p1, *p2;
int c1, c2;
@@ -436,7 +436,8 @@
* not to randomize across delimiter boundaries. All
* randomization is done within each block.
*/
-void randomize()
+void
+randomize(void)
{
int cnt, i;
long tmp;
Index: games/fortune/unstr/Makefile
===================================================================
RCS file: /home/dcvs/src/games/fortune/unstr/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- games/fortune/unstr/Makefile 17 Jun 2003 02:49:24 -0000 1.1
+++ games/fortune/unstr/Makefile 31 Jul 2005 10:03:12 -0000
@@ -4,5 +4,7 @@
NOMAN= noman
CFLAGS+=-Wall -I${.CURDIR}/../strfile
+WARNS?= 6
+
.include "${.CURDIR}/../../Makefile.inc"
.include <bsd.prog.mk>
Index: games/fortune/unstr/unstr.c
===================================================================
RCS file: /home/dcvs/src/games/fortune/unstr/unstr.c,v
retrieving revision 1.2
diff -u -r1.2 unstr.c
--- games/fortune/unstr/unstr.c 17 Jun 2003 04:25:24 -0000 1.2
+++ games/fortune/unstr/unstr.c 31 Jul 2005 10:03:12 -0000
@@ -57,6 +57,7 @@
# include <sys/param.h>
# include <stdio.h>
# include <ctype.h>
+# include <stdlib.h>
# include <string.h>
# include "strfile.h"
@@ -66,12 +67,12 @@
FILE *Inf, *Dataf;
-void getargs(), order_unstr();
+void getargs(char **);
+void order_unstr(STRFILE *);
/* ARGSUSED */
-int main(ac, av)
-int ac;
-char **av;
+int
+main(__unused int ac, char **av)
{
static STRFILE tbl; /* description table */
@@ -101,8 +102,8 @@
exit(0);
}
-void getargs(av)
-char *av[];
+void
+getargs(char **av)
{
if (!*++av) {
(void) fprintf(stderr, "usage: unstr datafile\n");
@@ -113,10 +114,10 @@
(void) strcat(Datafile, ".dat");
}
-void order_unstr(tbl)
-STRFILE *tbl;
+void
+order_unstr(STRFILE *tbl)
{
- int i;
+ unsigned int i;
char *sp;
long pos;
char buf[BUFSIZ];
Attachment:
pgp00016.pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00016.pgp
Type: application/octet-stream
Size: 189 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/submit/attachments/20050731/3106d1c8/attachment-0018.obj>
More information about the Submit
mailing list