summaryrefslogtreecommitdiff
path: root/gcc/params.c
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-30 00:05:39 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-30 00:05:39 +0000
commit26a2e9934e1f679b767e631ef75123712575e7f5 (patch)
treef0226fa372c19600fd529ccba821f68b9b1613ba /gcc/params.c
parent63abcf45e6ae2e8ad40005ded995ad6230bf6474 (diff)
downloadgcc-26a2e9934e1f679b767e631ef75123712575e7f5.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237865 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/params.c')
-rw-r--r--gcc/params.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/params.c b/gcc/params.c
index 41660b47393..1b5000bb8d7 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. */