summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2003-03-31 10:09:58 +0000
committerBruno Haible <bruno@clisp.org>2003-03-31 10:09:58 +0000
commit8193024d960a8aa2a780fefe8b50321f4e6c5a93 (patch)
treed1bb0bc23204969e21920d846c8c21359f03fbd1
parentd51ed07a8009457f385fc81fdf2c825f7175dd28 (diff)
downloadgperf-8193024d960a8aa2a780fefe8b50321f4e6c5a93.tar.gz
Additional check for the keywords.
-rw-r--r--ChangeLog3
-rw-r--r--src/search.cc21
2 files changed, 23 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 6c21729..f7e8d3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2002-12-10 Bruno Haible <bruno@clisp.org>
+ * src/search.cc (Search::preprepare): Exit if keywords contain
+ out-of-range characters.
+
* src/search.cc (for): Define so as to avoid errors with old compilers.
* src/options.h (SHAREDLIB): New enum value.
diff --git a/src/search.cc b/src/search.cc
index cb98457..f24a0c7 100644
--- a/src/search.cc
+++ b/src/search.cc
@@ -114,7 +114,7 @@ Search::preprepare ()
_min_key_len = keyword->_allchars_length;
}
- /* Exit program if an empty string is used as key, since the comparison
+ /* Exit program if an empty string is used as keyword, since the comparison
expressions don't work correctly for looking up an empty string. */
if (_min_key_len == 0)
{
@@ -123,6 +123,25 @@ Search::preprepare ()
"len == 0 before calling the gperf generated lookup function.\n");
exit (1);
}
+
+ /* Exit program if the characters in the keywords are not in the required
+ range. */
+ if (option[SEVENBIT])
+ for (temp = _head; temp; temp = temp->rest())
+ {
+ KeywordExt *keyword = temp->first();
+
+ const char *k = keyword->_allchars;
+ for (int i = keyword->_allchars_length; i > 0; k++, i--)
+ if (!(static_cast<unsigned char>(*k) < 128))
+ {
+ fprintf (stderr, "Option --seven-bit has been specified,\n"
+ "but keyword \"%.*s\" contains non-ASCII characters.\n"
+ "Try removing option --seven-bit.\n",
+ keyword->_allchars_length, keyword->_allchars);
+ exit (1);
+ }
+ }
}
/* ====================== Finding good byte positions ====================== */