Skip to content

Commit a4142bd

Browse files
author
Nick Logan
committed
fix max distance bug, iimog++ (v0.502)
1 parent a7f03d7 commit a4142bd

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Revision history for Perl module Text::Levenshtein::XS
22

33
{{$NEXT}}
4+
- Fix max distance bug, iimog++
5+
6+
0.501 2015-08-28 14:08:32-04:00 America/New_York
47
- Manually add in version (Forgot how to use dzil + plugins)
58

69
0.500 2015-08-28 13:56:18-04:00 America/New_York

Makefile.PL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ my %WriteMakefileArgs = (
3535
"IPC::Open3" => 0,
3636
"Test::More" => 0
3737
},
38-
"VERSION" => "0.501",
38+
"VERSION" => "0.502",
3939
"test" => {
4040
"TESTS" => "t/*.t"
4141
}

README.mkdn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Text::Levenshtein::XS - Calculate edit distance based on insertion, deletion, su
44

55
# VERSION
66

7-
version 0.501
7+
version 0.502
88

99
# SYNOPSIS
1010

XS.xs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ PPCODE:
5252
}
5353

5454
for (i=0; i < lenSource; i++) {
55+
if( undef > 0 )
56+
break;
5557

5658
elem = sv_2mortal(av_shift(arraySource));
5759
s[i] = SvUV((SV *)elem);
@@ -70,10 +72,10 @@ PPCODE:
7072
/* v1[0] == index of current distance of v1 (i.e. v1[v1[0]] == current distance) */
7173
/* We also take diff into account so we can guess if current distance + length */
7274
/* difference would push the total edit distance over the max distance */
73-
if( v1[0] == j && (mdx+1) < ((diff > v1[j]) ? (diff - v1[j]) : (diff + v1[j])) ) {
74-
undef = 1;
75-
break;
76-
}
75+
if( v1[0] == j )
76+
if( mdx < ((diff > v1[j]) ? (diff - v1[j]) : (diff + v1[j])) )
77+
if( mdx > v1[j] )
78+
undef = 1;
7779
}
7880

7981

dist.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ author = ugexe <ugexe@cpan.org>
33
license = Perl_5
44
copyright_holder = Nick Logan
55
main_module = lib/Text/Levenshtein/XS.pm
6-
version = 0.501
6+
version = 0.502
77

88
[ReportPhase / Phase_Begins] ; report on everything
99

lib/Text/Levenshtein/XS.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require Exporter;
77

88
@Text::Levenshtein::XS::ISA = qw/Exporter/;
99
@Text::Levenshtein::XS::EXPORT_OK = qw/distance/;
10-
$Text::Levenshtein::XS::VERSION = 0.501;
10+
$Text::Levenshtein::XS::VERSION = 0.502;
1111

1212
eval {
1313
require XSLoader;

t/02_distance.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ subtest 'Testing previous bugs/issues' => sub {
7373

7474
is( distance('ACGTAG', 'AGTAG', 2), 1, 'iimog https://github.com/ugexe/Text--Levenshtein--XS/issues/10' );
7575
is( distance('ACGTAG', 'TCGG', 2), undef, 'iimog https://github.com/ugexe/Text--Levenshtein--XS/issues/10' );
76+
is( distance('ACGTAG', 'AGTAG', 1), 1, 'iimog https://github.com/ugexe/Text--Levenshtein--XS/issues/11' );
7677
};
7778

7879
# Not quite supported yet

0 commit comments

Comments
 (0)