X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=selector.git;a=blobdiff_plain;f=selector.c;h=9e09b8a6a217369256dc85aefeff4e06576ff0ae;hp=d4ddb27af2e50683f5c362ef8e435773ca1beb5e;hb=7d4ebedc2605ec1c7d7ce343665b0ad73eec6f47;hpb=c12e106a918136ed474eca04d9bcf592d2324d5d diff --git a/selector.c b/selector.c index d4ddb27..9e09b8a 100644 --- a/selector.c +++ b/selector.c @@ -214,6 +214,8 @@ void usage(FILE *out) { /* A quick and dirty hash table */ +#define MAGIC_HASH_MULTIPLIER 387433 + /* The table itself stores indexes of the strings taken in a char** table. When a string is added, if it was already in the table, the new index replaces the previous one. */ @@ -256,11 +258,11 @@ int add_and_get_previous_index(struct hash_table_t *hash_table, int k; /* This is my recipe. I checked, it seems to work (as long as - hash_table->size is not a multiple of 387433 that should be - okay) */ + hash_table->size is not a multiple of MAGIC_HASH_MULTIPLIER that + should be okay) */ for(k = 0; new_string[k]; k++) { - code = code * 387433 + (unsigned int) (new_string[k]); + code = code * MAGIC_HASH_MULTIPLIER + (unsigned int) (new_string[k]); } code = code % hash_table->size; @@ -1204,6 +1206,11 @@ int main(int argc, char **argv) { clear(); } + else { + /* Unknown key */ + error_feedback(); + } + update_screen(¤t_focus_line, &displayed_focus_line, motion, nb_lines, labels, cursor_position, pattern);