From bf91bce7d7ed529935d5a919a7c2a0ea16fb0001 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Tue, 29 Sep 2009 14:57:52 +0200 Subject: [PATCH] Code Improvement : C4/Matcher.pm substr dans act when passed only subfield offset --- C4/Matcher.pm | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/C4/Matcher.pm b/C4/Matcher.pm index c9a1e46881..ae6fb7d2b9 100644 --- a/C4/Matcher.pm +++ b/C4/Matcher.pm @@ -774,26 +774,23 @@ sub _get_match_keys { last FIELD if $j > 0 and $check_only_first_repeat; last FIELD if $i > 0 and $j > $#keys; my $key = ""; + my $string; if ($field->is_control_field()) { - if ($component->{'length'}) { - $key = _normalize(substr($field->data(), $component->{'offset'}, $component->{'length'})) - # FIXME normalize, substr - } else { - $key = _normalize($field->data()); - } + $string=$field->data(); } else { foreach my $subfield ($field->subfields()) { if (exists $component->{'subfields'}->{$subfield->[0]}) { - $key .= " " . $subfield->[1]; + $string .= " " . $subfield->[1]; } } - $key = _normalize($key); - if ($component->{'length'}){ - if (length($key) > $component->{'length'}){ - $key = _normalize(substr($key,$component->{'offset'},$component->{'length'})); - } - } + } + if ($component->{'length'}>0) { + $string= substr($string, $component->{'offset'}, $component->{'length'}); + # FIXME normalize, substr + } elsif ($component->{'offset'}) { + $string= substr($string, $component->{'offset'}); } + $key = _normalize($string); if ($i == 0) { push @keys, $key if $key; } else { @@ -802,7 +799,6 @@ sub _get_match_keys { } } return @keys; - } -- 2.39.5