X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/b9e9a125627944dbfaacf50922e58f4900e9c567..788e63c4030f445936903fa008cacb72fc845953:/boggle/mkdict/mkdict.c?ds=sidebyside diff --git a/boggle/mkdict/mkdict.c b/boggle/mkdict/mkdict.c index e96bc5b9..6dc083b1 100644 --- a/boggle/mkdict/mkdict.c +++ b/boggle/mkdict/mkdict.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkdict.c,v 1.4 1999/09/10 00:18:20 jsm Exp $ */ +/* $NetBSD: mkdict.c,v 1.11 2005/07/01 16:38:24 jmc Exp $ */ /*- * Copyright (c) 1993 @@ -15,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,16 +33,14 @@ */ #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1993\n\ +static const char copyright[] = + "@(#) Copyright (c) 1993\n\ The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint #if 0 static char sccsid[] = "@(#)mkdict.c 8.1 (Berkeley) 6/11/93"; #else -static char rcsid[] = "$NetBSD: mkdict.c,v 1.4 1999/09/10 00:18:20 jsm Exp $"; +static const char rcsid[] = + "$NetBSD: mkdict.c,v 1.11 2005/07/01 16:38:24 jmc Exp $"; #endif #endif /* not lint */ @@ -62,30 +56,25 @@ static char rcsid[] = "$NetBSD: mkdict.c,v 1.4 1999/09/10 00:18:20 jsm Exp $"; #include #include #include -#include #include "bog.h" int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { char *p, *q; - int ch, common, n, nwords; + int ch, common, nwords; int current, len, prev, qcount; char buf[2][MAXWORDLEN + 1]; prev = 0; current = 1; buf[prev][0] = '\0'; - if (argc == 2) - n = atoi(argv[1]); for (nwords = 1; fgets(buf[current], MAXWORDLEN + 1, stdin) != NULL; ++nwords) { if ((p = strchr(buf[current], '\n')) == NULL) { - warnx("word too long: %s", buf[current]); + fprintf(stderr, "word too long: %s\n", buf[current]); while ((ch = getc(stdin)) != EOF && ch != '\n') ; if (ch == EOF) @@ -94,14 +83,14 @@ main(argc, argv) } len = 0; for (p = buf[current]; *p != '\n'; p++) { - if (!islower(*p)) + if (!islower((unsigned char)*p)) break; if (*p == 'q') { q = p + 1; if (*q != 'u') break; else { - while (*q = *(q + 1)) + while ((*q = *(q + 1))) q++; } len++; @@ -110,7 +99,7 @@ main(argc, argv) } if (*p != '\n' || len < 3 || len > MAXWORDLEN) continue; - if (argc == 2 && nwords % n) + if (argc == 2 && nwords % atoi(argv[1])) continue; *p = '\0'; @@ -125,9 +114,11 @@ main(argc, argv) prev = !prev; current = !current; } - warnx("%d words", nwords); + fprintf(stderr, "%d words\n", nwords); fflush(stdout); - if (ferror(stdout)) - err(1, "writing standard output"); + if (ferror(stdout)) { + perror("error writing standard output"); + exit(1); + } exit(0); }