Code

Fix deletion of last character in levenshtein distance
[git.git] / levenshtein.c
index db52f2c205029229c7eedc8fbc042d3945436803..98fea723d4b70422ca18e3fab4c65f4c1f9f3744 100644 (file)
@@ -25,7 +25,7 @@ int levenshtein(const char *string1, const char *string2,
                                        row2[j + 1] > row0[j - 1] + w)
                                row2[j + 1] = row0[j - 1] + w;
                        /* deletion */
-                       if (j + 1 < len2 && row2[j + 1] > row1[j + 1] + d)
+                       if (row2[j + 1] > row1[j + 1] + d)
                                row2[j + 1] = row1[j + 1] + d;
                        /* insertion */
                        if (row2[j + 1] > row2[j] + a)