From 8193024d960a8aa2a780fefe8b50321f4e6c5a93 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 31 Mar 2003 10:09:58 +0000 Subject: [PATCH] Additional check for the keywords. --- ChangeLog | 3 +++ src/search.cc | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6c21729..f7e8d3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2002-12-10 Bruno Haible + * 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(*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 ====================== */