Fix loop index bug in scan for a[s] in b[s..s+len2-1].

a, b must both be indexed starting from s after the common
prefix "strip" phase.  This resolves issue 3477:
  https://github.com/nim-lang/Nim/issues/3477
This commit is contained in:
Charles Blake
2015-11-19 06:52:31 -05:00
parent ba6d0eb4db
commit 716c12a436

View File

@@ -1281,7 +1281,7 @@ proc editDistance*(a, b: string): int {.noSideEffect,
# another special case:
if len1 == 1:
for j in s..len2-1:
for j in s..s+len2-1:
if a[s] == b[j]: return len2 - 1
return len2