Prefer simple case changes in spelling suggestions
authorTom Tromey <tromey@adacore.com>
Fri, 29 May 2020 16:46:57 +0000 (10:46 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 3 Jun 2020 12:19:06 +0000 (06:19 -0600)
commit079632de497a58a78971b8fc35cf3a52148857d1
tree909af8a4618bd7412f5a1274c3b39d7ab973bca9
parentf05c84ac139ccd5398542369aad2b5ff3059ced4
Prefer simple case changes in spelling suggestions

I got this error message when editing gcc and recompiling:

../../gcc/gcc/ada/gcc-interface/decl.c:7714:39: error: ‘DWARF_GNAT_ENCODINGS_all’ was not declared in this scope; did you mean ‘DWARF_GNAT_ENCODINGS_GDB’?
 7714 |     = debug_info && gnat_encodings == DWARF_GNAT_ENCODINGS_all;
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
      |                                       DWARF_GNAT_ENCODINGS_GDB

This suggestion could be improved -- what happened here is that I
failed to upper-case the word, and DWARF_GNAT_ENCODINGS_ALL was the
correct spelling.

This patch changes gcc's spell checker to prefer simple case changes
when possible.

I tested this using the self-tests.  A new self-test is also included.

gcc/ChangeLog:

* spellcheck.c (CASE_COST): New define.
(BASE_COST): New define.
(get_edit_distance): Recognize case changes.
(get_edit_distance_cutoff): Update.
(test_edit_distances): Update.
(get_old_cutoff): Update.
(test_find_closest_string): Add case sensitivity test.
gcc/spellcheck.c