[Koha-patches] [PATCH] bug 3120: tweak DDCN call number splitting for labels
Galen Charlton
galen.charlton at liblime.com
Wed May 20 18:20:20 CEST 2009
Allow a call number of the form MP3-CD F PARKER to be split as
MP3-CD
F
PARKER
instead of
MP
3
-CD
F
PARKER
---
C4/Labels.pm | 6 +++---
t/Labels_split_ddcn.t | 3 ++-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/C4/Labels.pm b/C4/Labels.pm
index 02607c2..ac3ce7c 100644
--- a/C4/Labels.pm
+++ b/C4/Labels.pm
@@ -905,8 +905,6 @@ sub deduplicate_batch {
return $killed, undef;
}
-our $possible_decimal = qr/\d+(?:\.\d+)?/;
-
sub split_lccn {
my ($lccn) = @_;
$_ = $lccn;
@@ -929,6 +927,8 @@ sub split_lccn {
return @parts;
}
+our $possible_decimal = qr/\d{3,}(?:\.\d+)?/; # at least three digits for a DDCN
+
sub split_ddcn {
my ($ddcn) = @_;
$_ = $ddcn;
@@ -937,7 +937,7 @@ sub split_ddcn {
my (@parts) = m/
^([a-zA-Z-]+(?:$possible_decimal)?) # R220.3 # BIO # first example will require extra splitting
- \s*
+ \s+
(.+) # H2793Z H32 c.2 # R5c.1 # everything else (except bracketing spaces)
\s*
/x;
diff --git a/t/Labels_split_ddcn.t b/t/Labels_split_ddcn.t
index 7927ec0..20ff5bd 100755
--- a/t/Labels_split_ddcn.t
+++ b/t/Labels_split_ddcn.t
@@ -5,7 +5,7 @@
use strict;
use warnings;
-use Test::More tests => 62;
+use Test::More tests => 72;
BEGIN {
use_ok('C4::Labels');
@@ -18,6 +18,7 @@ my $ddcns = {
'J DAR G7c.11' => [qw( J DAR G7 c.11)],
'R220.3 H2793Z H32 c.2' => [qw(R 220.3 H2793Z H32 c.2)],
'CD-ROM 787.87 EAS' => [qw(CD-ROM 787.87 EAS)],
+ 'MP3-CD F PARKER' => [qw(MP3-CD F PARKER)],
};
foreach my $ddcn (sort keys %$ddcns) {
--
1.5.6.5
More information about the Koha-patches
mailing list