-/* $NetBSD: mkdict.c,v 1.3 1997/10/11 02:12:21 lukem Exp $ */
+/* $NetBSD: mkdict.c,v 1.6 1999/09/19 18:10:48 jsm Exp $ */
/*-
* Copyright (c) 1993
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+__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.3 1997/10/11 02:12:21 lukem Exp $";
+__RCSID("$NetBSD: mkdict.c,v 1.6 1999/09/19 18:10:48 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(argc, argv)
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 (*q != 'u')
break;
else {
- while (*q = *(q + 1))
+ while ((*q = *(q + 1)))
q++;
}
len++;
}
if (*p != '\n' || len < 3 || len > MAXWORDLEN)
continue;
- if (argc == 2 && nwords % n)
+ if (argc == 2 && nwords % atoi(argv[1]))
continue;
*p = '\0';
current = !current;
}
warnx("%d words", nwords);
+ fflush(stdout);
+ if (ferror(stdout))
+ err(1, "writing standard output");
exit(0);
}