aboutsummaryrefslogtreecommitdiff
path: root/gcc/spellcheck.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2015-11-13 01:54:41 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2015-11-13 01:54:41 +0000
commit277fe616911ac1ce91e9f1178d648303b4a26940 (patch)
tree574b1272f86df52172c56c614532ff5032b6f73d /gcc/spellcheck.h
parent6d82151f8c08d123eaab63409cd8ba6f85d0539c (diff)
downloadgcc-277fe616911ac1ce91e9f1178d648303b4a26940.zip
gcc-277fe616911ac1ce91e9f1178d648303b4a26940.tar.gz
gcc-277fe616911ac1ce91e9f1178d648303b4a26940.tar.bz2
Implement Levenshtein distance; use in C FE for misspelled field names
This is the combination of: [PATCH 1/2] Implement Levenshtein distance [PATCH 2/2] C FE: suggest corrections for misspelled field names plus some nit fixes in spellcheck.c. gcc/ChangeLog: * Makefile.in (OBJS): Add spellcheck.o. * spellcheck.c: New file. * spellcheck.h: New file. gcc/c/ChangeLog: * c-typeck.c: Include spellcheck.h. (lookup_field_fuzzy_find_candidates): New function. (lookup_field_fuzzy): New function. (build_component_ref): If the field was not found, try using lookup_field_fuzzy and potentially offer a suggestion. gcc/testsuite/ChangeLog: * gcc.dg/plugin/levenshtein-test-1.c: New file. * gcc.dg/plugin/levenshtein_plugin.c: New file. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add levenshtein_plugin.c. * gcc.dg/spellcheck-fields.c: New file. From-SVN: r230284
Diffstat (limited to 'gcc/spellcheck.h')
-rw-r--r--gcc/spellcheck.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/spellcheck.h b/gcc/spellcheck.h
new file mode 100644
index 0000000..58355d6
--- /dev/null
+++ b/gcc/spellcheck.h
@@ -0,0 +1,32 @@
+/* Find near-matches for strings and 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/>. */
+
+#ifndef GCC_SPELLCHECK_H
+#define GCC_SPELLCHECK_H
+
+typedef unsigned int edit_distance_t;
+const edit_distance_t MAX_EDIT_DISTANCE = UINT_MAX;
+
+extern edit_distance_t
+levenshtein_distance (const char *s, const char *t);
+
+extern edit_distance_t
+levenshtein_distance (tree ident_s, tree ident_t);
+
+#endif /* GCC_SPELLCHECK_H */