From d8bd2345ed82919b071186d0445360464f31e8af Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 20 May 2009 11:20:20 -0500 Subject: [PATCH] bug 3120: tweak DDCN call number splitting for labels 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 Signed-off-by: Galen Charlton --- 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 02607c2855..ac3ce7c1e2 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 7927ec0c31..20ff5bd3bb 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) { -- 2.39.5