summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCharles Blake <cblake@csail.mit.edu>2015-11-19 06:52:31 -0500
committerCharles Blake <cblake@csail.mit.edu>2015-11-19 06:52:31 -0500
commit716c12a4365c04fcd164c8e1295805b3311cd517 (patch)
tree6b59d55ceee476a2569ccdabc4347f494c3492cb
parentba6d0eb4db5bb85c772dea3d4c5afb2bfbb5a6d5 (diff)
downloadNim-716c12a4365c04fcd164c8e1295805b3311cd517.tar.gz
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
-rw-r--r--lib/pure/strutils.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index b61df6086..6c561eaf9 100644
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -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