BSD 4_4_Lite2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Thu, 22 Jul 1993 14:33:14 +0000 (06:33 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Thu, 22 Jul 1993 14:33:14 +0000 (06:33 -0800)
Work on file usr/src/contrib/flex-2.5.2/MISC/fastwc/mywc.c

Synthesized-from: CSRG/cd3/4.4BSD-Lite2

usr/src/contrib/flex-2.5.2/MISC/fastwc/mywc.c [new file with mode: 0644]

diff --git a/usr/src/contrib/flex-2.5.2/MISC/fastwc/mywc.c b/usr/src/contrib/flex-2.5.2/MISC/fastwc/mywc.c
new file mode 100644 (file)
index 0000000..92e5a36
--- /dev/null
@@ -0,0 +1,26 @@
+/* A simple but fairly efficient C version of the Unix "wc" tool */
+
+#include <stdio.h>
+#include <ctype.h>
+
+main()
+{
+       register int c, cc = 0, wc = 0, lc = 0;
+       FILE *f = stdin;
+
+       while ((c = getc(f)) != EOF) {
+               ++cc;
+               if (isgraph(c)) {
+                       ++wc;
+                       do {
+                               c = getc(f);
+                               if (c == EOF)
+                                       goto done;
+                               ++cc;
+                       } while (isgraph(c));
+               }
+               if (c == '\n')
+                       ++lc;
+       }
+done:  printf( "%8d%8d%8d\n", lc, wc, cc );
+}