summaryrefslogtreecommitdiffstats
path: root/WebKitTools/android/flex-2.5.4a/MISC/fastwc/mywc.c
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:30:52 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:30:52 -0800
commit8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (patch)
tree11425ea0b299d6fb89c6d3618a22d97d5bf68d0f /WebKitTools/android/flex-2.5.4a/MISC/fastwc/mywc.c
parent648161bb0edfc3d43db63caed5cc5213bc6cb78f (diff)
downloadexternal_webkit-8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2.zip
external_webkit-8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2.tar.gz
external_webkit-8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'WebKitTools/android/flex-2.5.4a/MISC/fastwc/mywc.c')
-rw-r--r--WebKitTools/android/flex-2.5.4a/MISC/fastwc/mywc.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/WebKitTools/android/flex-2.5.4a/MISC/fastwc/mywc.c b/WebKitTools/android/flex-2.5.4a/MISC/fastwc/mywc.c
new file mode 100644
index 0000000..92e5a36
--- /dev/null
+++ b/WebKitTools/android/flex-2.5.4a/MISC/fastwc/mywc.c
@@ -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 );
+}