diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-06-30 00:05:39 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-06-30 00:05:39 +0000 |
commit | f4452176d8b7d718f50616c6908da8b8a9811bdf (patch) | |
tree | f0226fa372c19600fd529ccba821f68b9b1613ba /gcc/params.c | |
parent | c5e74d9d4ebeb29fab731464c206296ec651e9a6 (diff) | |
download | gcc-f4452176d8b7d718f50616c6908da8b8a9811bdf.zip gcc-f4452176d8b7d718f50616c6908da8b8a9811bdf.tar.gz gcc-f4452176d8b7d718f50616c6908da8b8a9811bdf.tar.bz2 |
Offer suggestions for misspelled --param names.
gcc/ChangeLog:
* opts.c (handle_param): Use find_param_fuzzy to offer suggestions
for misspelled param names.
* params.c: Include spellcheck.h.
(find_param_fuzzy): New function.
* params.h (find_param_fuzzy): New prototype.
* spellcheck.c (struct edit_distance_traits<const char *>): Move
to...
* spellcheck.h (struct edit_distance_traits<const char *>):
...here.
gcc/testsuite/ChangeLog:
* gcc.dg/spellcheck-params.c: New testcase.
* gcc.dg/spellcheck-params-2.c: New testcase.
From-SVN: r237865
Diffstat (limited to 'gcc/params.c')
-rw-r--r-- | gcc/params.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/params.c b/gcc/params.c index 41660b4..1b5000b 100644 --- a/gcc/params.c +++ b/gcc/params.c @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "params-enum.h" #include "diagnostic-core.h" +#include "spellcheck.h" /* An array containing the compiler parameters and their current values. */ @@ -142,6 +143,19 @@ find_param (const char *name, enum compiler_param *index) return false; } +/* Look for the closest match for NAME in the parameter table, returning it + if it is a reasonable suggestion for a misspelling. Return NULL + otherwise. */ + +const char * +find_param_fuzzy (const char *name) +{ + best_match <const char *, const char *> bm (name); + for (size_t i = 0; i < num_compiler_params; ++i) + bm.consider (compiler_params[i].option); + return bm.get_best_meaningful_candidate (); +} + /* Return true if param with entry index INDEX should be defined using strings. If so, return the value corresponding to VALUE_NAME in *VALUE_P. */ |