diff options
author | David Malcolm <dmalcolm@redhat.com> | 2015-11-13 01:59:03 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2015-11-13 01:59:03 +0000 |
commit | 93ebf1fdbe35eadc5e54934061a7a4d7bcdc8262 (patch) | |
tree | 03490dac15713b742586dd8e47220bc1bc5db3a3 /gcc/spellcheck-tree.c | |
parent | 277fe616911ac1ce91e9f1178d648303b4a26940 (diff) | |
download | gcc-93ebf1fdbe35eadc5e54934061a7a4d7bcdc8262.zip gcc-93ebf1fdbe35eadc5e54934061a7a4d7bcdc8262.tar.gz gcc-93ebf1fdbe35eadc5e54934061a7a4d7bcdc8262.tar.bz2 |
PR driver/67613 - spell suggestions for misspelled command line options
gcc/ChangeLog:
PR driver/67613
* Makefile.in (GCC_OBJS): Add spellcheck.o.
(OBJS): Add spellcheck-tree.o.
* gcc.c: Include "spellcheck.h".
(suggest_option): New function.
(driver::handle_unrecognized_options): Call suggest_option to
provide a hint about misspelled options.
* spellcheck.c: Update file comment.
(levenshtein_distance): Convert 4-param implementation from static
to extern scope. Remove note about unit tests from leading
comment for const char * implementation. Move tree
implementation to...
* spellcheck-tree.c: New file.
* spellcheck.h (levenshtein_distance): Add 4-param decl.
gcc/testsuite/ChangeLog:
PR driver/67613
* gcc/testsuite/gcc.dg/spellcheck-options-1.c: New file.
* gcc/testsuite/gcc.dg/spellcheck-options-2.c: New file.
From-SVN: r230285
Diffstat (limited to 'gcc/spellcheck-tree.c')
-rw-r--r-- | gcc/spellcheck-tree.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/spellcheck-tree.c b/gcc/spellcheck-tree.c new file mode 100644 index 0000000..d203776 --- /dev/null +++ b/gcc/spellcheck-tree.c @@ -0,0 +1,39 @@ +/* Find near-matches for identifiers. + Copyright (C) 2015 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "spellcheck.h" + +/* Calculate Levenshtein distance between two identifiers. */ + +edit_distance_t +levenshtein_distance (tree ident_s, tree ident_t) +{ + gcc_assert (TREE_CODE (ident_s) == IDENTIFIER_NODE); + gcc_assert (TREE_CODE (ident_t) == IDENTIFIER_NODE); + + return levenshtein_distance (IDENTIFIER_POINTER (ident_s), + IDENTIFIER_LENGTH (ident_s), + IDENTIFIER_POINTER (ident_t), + IDENTIFIER_LENGTH (ident_t)); +} |