Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / gperf / tests / test.cpp
blob6a936cfee689aafbb448c04cba21a35177299074
1 // Tests the generated perfect hash function.
3 // The -v option prints diagnostics as to whether a word is in the set
4 // or not. Without -v the program is useful for timing.
6 #include "ace/OS_NS_string.h"
7 #include "ace/OS_NS_stdio.h"
9 static const int MAX_LEN = 80;
11 // Lookup function.
12 const char *in_word_set (const char *str, unsigned int len);
14 int
15 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
17 int verbose = argc > 1 && ACE_OS::strcmp (argv[1], ACE_TEXT("-v")) == 0 ? 1 : 0;
18 char buf[MAX_LEN];
20 while (ACE_OS::fgets (buf, sizeof buf, stdin) != 0)
22 size_t len = ACE_OS::strlen (buf) - 1;
23 buf[len] = '\0';
24 if (in_word_set (buf, len) && verbose)
25 ACE_OS::printf ("in word set %s\n", buf);
26 else if (verbose)
27 ACE_OS::printf ("NOT in word set %s\n", buf);
30 return 0;