[Koha-patches] [PATCH] Bug 2500 Tweaking DDCN Split for Hyphenated Volumn Numbers

Chris Nighswonger cnighswonger at foundations.edu
Wed May 27 17:30:14 CEST 2009


Presently 252.051 T147 v.1-2 is split as

252.051
T147
v.1
-2

This patch corrects the algorithm so that it splits as

252.051
T147
v.1-2

It also updates Labels_split_ddcn.t to include this particular case.
---
 C4/Labels.pm          |    2 +-
 t/Labels_split_ddcn.t |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/C4/Labels.pm b/C4/Labels.pm
index ac3ce7c..2ee2568 100644
--- a/C4/Labels.pm
+++ b/C4/Labels.pm
@@ -953,7 +953,7 @@ sub split_ddcn {
 
     push @parts, split /\s+/, pop @parts;   # split the last piece into an arbitrary number of pieces at spaces
 
-    if ($parts[-1] =~ /^(.*\d+)(\D.*)$/) {
+    if ($parts[-1] !~ /^.*\d-\d.*$/ && $parts[-1] =~ /^(.*\d+)(\D.*)$/) {
          pop @parts;            # pull off the mathching last element, like example 2
         push @parts, $1, $2;    # replace it with the two pieces
     }
diff --git a/t/Labels_split_ddcn.t b/t/Labels_split_ddcn.t
index 20ff5bd..26aad55 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 => 72;
+use Test::More tests => 82;
 
 BEGIN {
     use_ok('C4::Labels');
@@ -19,6 +19,7 @@ my $ddcns = {
     '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)],
+    '252.051 T147 v.1-2'    => [qw(252.051 T147 v.1-2)],
 };
 
 foreach my $ddcn (sort keys %$ddcns) {
-- 
1.6.3.1




More information about the Koha-patches mailing list