mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 21:19:24 +00:00
Don't accept empty keys.
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
2000-08-19 Bruno Haible <bruno@linuix.math.u-bordeaux.fr>
|
2000-08-19 Bruno Haible <bruno@linuix.math.u-bordeaux.fr>
|
||||||
|
|
||||||
|
* src/key-list.cc (Key_List::read_keys): Don't accept an empty key.
|
||||||
|
|
||||||
* src/Makefile.in (install, installdirs, uninstall): Respect
|
* src/Makefile.in (install, installdirs, uninstall): Respect
|
||||||
$(DESTDIR).
|
$(DESTDIR).
|
||||||
* doc/Makefile.in (install, installdirs, uninstall): Likewise.
|
* doc/Makefile.in (install, installdirs, uninstall): Likewise.
|
||||||
@@ -26,9 +28,6 @@
|
|||||||
* tests/Makefile.in (check-lang-syntax): Perform each test with -D
|
* tests/Makefile.in (check-lang-syntax): Perform each test with -D
|
||||||
once without and once with duplicates.
|
once without and once with duplicates.
|
||||||
|
|
||||||
* src/key-list.cc (Key_List::output_lookup_function_body): Avoid
|
|
||||||
outputting a trivially satisfied test for len.
|
|
||||||
|
|
||||||
* src/key-list.cc (output_keyword_entry): Avoid outputting a struct
|
* src/key-list.cc (output_keyword_entry): Avoid outputting a struct
|
||||||
initializer of the form {"key",}.
|
initializer of the form {"key",}.
|
||||||
|
|
||||||
|
|||||||
@@ -320,6 +320,13 @@ Key_List::read_keys (void)
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Exit program if an empty string is used as key, since the comparison
|
||||||
|
expressions don't work correctly for looking up an empty string. */
|
||||||
|
if (min_key_len == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Empty input key is not allowed.\nTo recognize an empty input key, your code should check for\nlen == 0 before calling the gperf generated lookup function.\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
if (option[ALLCHARS])
|
if (option[ALLCHARS])
|
||||||
option.set_keysig_size (max_key_len);
|
option.set_keysig_size (max_key_len);
|
||||||
}
|
}
|
||||||
@@ -1523,14 +1530,8 @@ Key_List::output_lookup_function_body (const Output_Compare& comparison)
|
|||||||
{
|
{
|
||||||
T (Trace t ("Key_List::output_lookup_function_body");)
|
T (Trace t ("Key_List::output_lookup_function_body");)
|
||||||
|
|
||||||
/* Since `len' is of type `unsigned int', we can avoid comparing it
|
printf (" if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)\n"
|
||||||
against zero. */
|
" {\n"
|
||||||
if (min_key_len == 0)
|
|
||||||
printf (" if (len <= MAX_WORD_LENGTH)\n");
|
|
||||||
else
|
|
||||||
printf (" if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)\n");
|
|
||||||
|
|
||||||
printf (" {\n"
|
|
||||||
" register int key = %s (str, len);\n\n",
|
" register int key = %s (str, len);\n\n",
|
||||||
option.get_hash_name ());
|
option.get_hash_name ());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user