-/* $NetBSD: mkdict.c,v 1.5 1999/09/18 20:50:28 jsm Exp $ */
+/* $NetBSD: mkdict.c,v 1.8 2001/08/29 18:22:56 jsm Exp $ */
/*-
* Copyright (c) 1993
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1993\n\
- The Regents of the University of California. All rights reserved.\n");
-#endif /* not lint */
-
#ifndef lint
+static const char copyright[] =
+ "@(#) Copyright (c) 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
#if 0
static char sccsid[] = "@(#)mkdict.c 8.1 (Berkeley) 6/11/93";
#else
-__RCSID("$NetBSD: mkdict.c,v 1.5 1999/09/18 20:50:28 jsm Exp $");
+static const char rcsid[] =
+ "$NetBSD: mkdict.c,v 1.8 2001/08/29 18:22:56 jsm Exp $";
#endif
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <err.h>
#include "bog.h"
-int main __P((int, char *[]));
+int main(int, char *[]);
int
main(argc, argv)
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)
}
if (*p != '\n' || len < 3 || len > MAXWORDLEN)
continue;
- if (argc == 2 && nwords % n)
+ if (argc == 2 && nwords % atoi(argv[1]))
continue;
*p = '\0';
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);
}