1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 21:19:24 +00:00

Additional check for the keywords.

This commit is contained in:
Bruno Haible
2003-03-31 10:09:58 +00:00
parent d51ed07a80
commit 8193024d96
2 changed files with 23 additions and 1 deletions

View File

@@ -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.

View File

@@ -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 ====================== */