From 9c9ef4a17b3e2e050e99af86c0202a265f19ff2f Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Mon, 9 May 2016 15:12:41 -0400
Subject: [PATCH 13/13] FIXME: rename levenshtein_distance to
 calc_edit_distance

---
 gcc/spellcheck-tree.c                            | 14 ++++++------
 gcc/spellcheck.c                                 | 14 ++++++------
 gcc/spellcheck.h                                 |  8 +++----
 gcc/testsuite/gcc.dg/plugin/levenshtein_plugin.c | 28 ++++++++++++------------
 4 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/gcc/spellcheck-tree.c b/gcc/spellcheck-tree.c
index eb6e72a..f574724 100644
--- a/gcc/spellcheck-tree.c
+++ b/gcc/spellcheck-tree.c
@@ -24,18 +24,18 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "spellcheck.h"
 
-/* Calculate Levenshtein distance between two identifiers.  */
+/* Calculate edit distance between two identifiers.  */
 
 edit_distance_t
-levenshtein_distance (tree ident_s, tree ident_t)
+calc_edit_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));
+  return calc_edit_distance (IDENTIFIER_POINTER (ident_s),
+			     IDENTIFIER_LENGTH (ident_s),
+			     IDENTIFIER_POINTER (ident_t),
+			     IDENTIFIER_LENGTH (ident_t));
 }
 
 /* Given TARGET, an identifier, and CANDIDATES, a vec of identifiers,
@@ -58,7 +58,7 @@ find_closest_identifier (tree target, const auto_vec<tree> *candidates)
   FOR_EACH_VEC_ELT (*candidates, i, identifier)
     {
       gcc_assert (TREE_CODE (identifier) == IDENTIFIER_NODE);
-      edit_distance_t dist = levenshtein_distance (target, identifier);
+      edit_distance_t dist = calc_edit_distance (target, identifier);
       if (dist < best_distance)
 	{
 	  best_distance = dist;
diff --git a/gcc/spellcheck.c b/gcc/spellcheck.c
index e4e83a5..3d4f752 100644
--- a/gcc/spellcheck.c
+++ b/gcc/spellcheck.c
@@ -31,8 +31,8 @@ along with GCC; see the file COPYING3.  If not see
    This implementation uses the Wagner-Fischer algorithm.  */
 
 edit_distance_t
-levenshtein_distance (const char *s, int len_s,
-		      const char *t, int len_t)
+calc_edit_distance (const char *s, int len_s,
+		    const char *t, int len_t)
 {
   const bool debug = false;
 
@@ -112,12 +112,12 @@ levenshtein_distance (const char *s, int len_s,
   return result;
 }
 
-/* Calculate Levenshtein distance between two nil-terminated strings.  */
+/* Calculate edit distance between two nil-terminated strings.  */
 
 edit_distance_t
-levenshtein_distance (const char *s, const char *t)
+calc_edit_distance (const char *s, const char *t)
 {
-  return levenshtein_distance (s, strlen (s), t, strlen (t));
+  return calc_edit_distance (s, strlen (s), t, strlen (t));
 }
 
 /* Given TARGET, a non-NULL string, and CANDIDATES, a non-NULL ptr to
@@ -145,8 +145,8 @@ find_closest_string (const char *target,
     {
       gcc_assert (candidate);
       edit_distance_t dist
-	= levenshtein_distance (target, len_target,
-				candidate, strlen (candidate));
+	= calc_edit_distance (target, len_target,
+			      candidate, strlen (candidate));
       if (dist < best_distance)
 	{
 	  best_distance = dist;
diff --git a/gcc/spellcheck.h b/gcc/spellcheck.h
index 040c33e..e84f37c 100644
--- a/gcc/spellcheck.h
+++ b/gcc/spellcheck.h
@@ -25,11 +25,11 @@ const edit_distance_t MAX_EDIT_DISTANCE = UINT_MAX;
 
 /* spellcheck.c  */
 extern edit_distance_t
-levenshtein_distance (const char *s, int len_s,
-		      const char *t, int len_t);
+calc_edit_distance (const char *s, int len_s,
+		    const char *t, int len_t);
 
 extern edit_distance_t
-levenshtein_distance (const char *s, const char *t);
+calc_edit_distance (const char *s, const char *t);
 
 extern const char *
 find_closest_string (const char *target,
@@ -38,7 +38,7 @@ find_closest_string (const char *target,
 /* spellcheck-tree.c  */
 
 extern edit_distance_t
-levenshtein_distance (tree ident_s, tree ident_t);
+calc_edit_distance (tree ident_s, tree ident_t);
 
 extern tree
 find_closest_identifier (tree target, const auto_vec<tree> *candidates);
diff --git a/gcc/testsuite/gcc.dg/plugin/levenshtein_plugin.c b/gcc/testsuite/gcc.dg/plugin/levenshtein_plugin.c
index 3e7dc78..be4ceac 100644
--- a/gcc/testsuite/gcc.dg/plugin/levenshtein_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/levenshtein_plugin.c
@@ -10,42 +10,42 @@
 int plugin_is_GPL_compatible;
 
 static void
-levenshtein_distance_unit_test_oneway (const char *a, const char *b,
+calc_edit_distance_unit_test_oneway (const char *a, const char *b,
 				       edit_distance_t expected)
 {
-  edit_distance_t actual = levenshtein_distance (a, b);
+  edit_distance_t actual = calc_edit_distance (a, b);
   if (actual != expected)
-    error ("levenshtein_distance (\"%s\", \"%s\") : expected: %i got %i",
+    error ("calc_edit_distance (\"%s\", \"%s\") : expected: %i got %i",
 	   a, b, expected, actual);
 }
 
 
 static void
-levenshtein_distance_unit_test (const char *a, const char *b,
+calc_edit_distance_unit_test (const char *a, const char *b,
 				edit_distance_t expected)
 {
   /* Run every test both ways to ensure it's symmetric.  */
-  levenshtein_distance_unit_test_oneway (a, b, expected);
-  levenshtein_distance_unit_test_oneway (b, a, expected);
+  calc_edit_distance_unit_test_oneway (a, b, expected);
+  calc_edit_distance_unit_test_oneway (b, a, expected);
 }
 
 /* Callback handler for the PLUGIN_FINISH event; run
-   levenshtein_distance unit tests here.  */
+   calc_edit_distance unit tests here.  */
 
 static void
 on_finish (void */*gcc_data*/, void */*user_data*/)
 {
-  levenshtein_distance_unit_test ("", "nonempty", strlen ("nonempty"));
-  levenshtein_distance_unit_test ("saturday", "sunday", 3);
-  levenshtein_distance_unit_test ("foo", "m_foo", 2);
-  levenshtein_distance_unit_test ("hello_world", "HelloWorld", 3);
-  levenshtein_distance_unit_test
+  calc_edit_distance_unit_test ("", "nonempty", strlen ("nonempty"));
+  calc_edit_distance_unit_test ("saturday", "sunday", 3);
+  calc_edit_distance_unit_test ("foo", "m_foo", 2);
+  calc_edit_distance_unit_test ("hello_world", "HelloWorld", 3);
+  calc_edit_distance_unit_test
     ("the quick brown fox jumps over the lazy dog", "dog", 40);
-  levenshtein_distance_unit_test
+  calc_edit_distance_unit_test
     ("the quick brown fox jumps over the lazy dog",
      "the quick brown dog jumps over the lazy fox",
      4);
-  levenshtein_distance_unit_test
+  calc_edit_distance_unit_test
     ("Lorem ipsum dolor sit amet, consectetur adipiscing elit,",
      "All your base are belong to us",
      44);
-- 
1.8.5.3

