diff options
author | Bruno Haible <bruno@clisp.org> | 2003-03-31 10:09:58 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2003-03-31 10:09:58 +0000 |
commit | 8193024d960a8aa2a780fefe8b50321f4e6c5a93 (patch) | |
tree | d1bb0bc23204969e21920d846c8c21359f03fbd1 | |
parent | d51ed07a8009457f385fc81fdf2c825f7175dd28 (diff) | |
download | gperf-8193024d960a8aa2a780fefe8b50321f4e6c5a93.tar.gz |
Additional check for the keywords.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/search.cc | 21 |
2 files changed, 23 insertions, 1 deletions
@@ -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 ====================== */ |