Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: gperf/src/gperf/3.0.1/gperf-3.0.1-src/tests/test2.c

Issue 10804012: Add native Windows binary for gperf. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gperf/src/gperf/3.0.1/gperf-3.0.1-src/tests/test2.c
===================================================================
--- gperf/src/gperf/3.0.1/gperf-3.0.1-src/tests/test2.c (revision 0)
+++ gperf/src/gperf/3.0.1/gperf-3.0.1-src/tests/test2.c (revision 0)
@@ -0,0 +1,69 @@
+/*
+ Tests the generated perfect hash function.
+ The -v option prints diagnostics as to whether a word is in
+ the set or not. Without -v the program is useful for timing.
+*/
+
+#include <stdio.h>
+
+/* Support for SET_BINARY. */
+#include <fcntl.h>
+#if !defined O_BINARY && defined _O_BINARY
+# define O_BINARY _O_BINARY
+#endif
+#ifdef __BEOS__
+# undef O_BINARY
+#endif
+#if O_BINARY
+# define SET_BINARY(f) setmode (f, O_BINARY)
+#else
+# define SET_BINARY(f) (void)0
+#endif
+
+#define MAX_LEN 80
+
+int
+main (argc, argv)
+ int argc;
+ char *argv[];
+{
+ int verbose = argc > 1 ? 1 : 0;
+ char buf[2*MAX_LEN];
+ int buflen;
+
+ /* We need to read stdin in binary mode. */
+ SET_BINARY (0);
+
+ for (;;)
+ {
+ /* Simulate gets(buf) with 2 bytes per character. */
+ char *p = buf;
+ while (fread (p, 2, 1, stdin) == 1)
+ {
+ if ((p[0] << 8) + p[1] == '\n')
+ break;
+ p += 2;
+ }
+ buflen = p - buf;
+
+ if (buflen == 0)
+ break;
+
+ if (in_word_set (buf, buflen))
+ {
+ if (verbose)
+ printf ("in word set:");
+ }
+ else
+ {
+ if (verbose)
+ printf ("NOT in word set:");
+ }
+
+ for (p = buf; p < buf + buflen; p += 2)
+ printf (" %02X%02X", (unsigned char) p[0], (unsigned char) p[1]);
+ printf("\n");
+ }
+
+ return 0;
+}
Property changes on: gperf\src\gperf\3.0.1\gperf-3.0.1-src\tests\test2.c
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « gperf/src/gperf/3.0.1/gperf-3.0.1-src/tests/test-7.exp ('k') | gperf/src/gperf/3.0.1/gperf-3.0.1-src/tests/validate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698