[Koha-patches] [PATCH] bug 3120: tweak splitting of Dewey call number

Galen Charlton galen.charlton at liblime.com
Sat May 9 00:31:14 CEST 2009


If a call number prefix contains a hyphen, try not to
split on the hyphen.  For example, rather than
splitting the call number 'CD-ROM 787.87 EAS'
like this:

CD
-ROM
787.87
EAS

it should be

CD-ROM
787.87
EAS
---
 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 14d3227..02607c2 100644
--- a/C4/Labels.pm
+++ b/C4/Labels.pm
@@ -936,7 +936,7 @@ sub split_ddcn {
     # ddcn examples: 'R220.3 H2793Z H32 c.2', 'BIO JP2 R5c.1'
 
     my (@parts) = m/
-        ^([a-zA-Z]+(?:$possible_decimal)?) # R220.3            # BIO   # first example will require extra splitting
+        ^([a-zA-Z-]+(?:$possible_decimal)?) # R220.3            # BIO   # first example will require extra splitting
         \s*
         (.+)                               # H2793Z H32 c.2   # R5c.1   # everything else (except bracketing spaces)
         \s*
diff --git a/t/Labels_split_ddcn.t b/t/Labels_split_ddcn.t
index ca879f3..7927ec0 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 => 52;
+use Test::More tests => 62;
 
 BEGIN {
     use_ok('C4::Labels');
@@ -17,6 +17,7 @@ my $ddcns = {
     'FIC GIR J5c.1'         => [qw(FIC GIR J5 c.1 )],
     '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)],
 };
 
 foreach my $ddcn (sort keys %$ddcns) {
-- 
1.5.6.5




More information about the Koha-patches mailing list