Bugzilla – Attachment 15977 Details for
Bug 9770
C4::ClassSortRoutine::Dewey can pad the wrong part of a call number internally
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to Dewey.pm
0001-Bug-9770-C4-ClassSortRoutine-Dewey-sorting.patch (text/plain), 1.96 KB, created by
Jason Etheridge
on 2013-03-08 15:22:19 UTC
(
hide
)
Description:
patch to Dewey.pm
Filename:
MIME Type:
Creator:
Jason Etheridge
Created:
2013-03-08 15:22:19 UTC
Size:
1.96 KB
patch
obsolete
>From 991537e9315513e9a06d66d6ea269490b68588ef Mon Sep 17 00:00:00 2001 >From: Jason Etheridge <jason@esilibrary.com> >Date: Fri, 8 Mar 2013 10:41:06 -0500 >Subject: [PATCH] Bug 9770: C4::ClassSortRoutine::Dewey sorting > >C4::ClassSortRoutine::Dewey can pad the wrong part of a call number internally > >The subroutine get_class_sort_key tokenizes a call number string (splitting on >periods and whitespace) and counts the number of tokens that solely contain >digits. If there is only one such digit group, a comment in the code states >that it will pad said digit group. However, the bug is that the code assumes >said digit group is the first token, when this may not be the case. > >In practice, this can cause poor sorting when used a call number is in the form >of PREFIX _space_ 3DIGITS. > >Signed-off-by: Jason Etheridge <jason@esilibrary.com> >--- > C4/ClassSortRoutine/Dewey.pm | 6 +++++- > 1 files changed, 5 insertions(+), 1 deletions(-) > >diff --git a/C4/ClassSortRoutine/Dewey.pm b/C4/ClassSortRoutine/Dewey.pm >index 1f8b3ef..25480ec 100644 >--- a/C4/ClassSortRoutine/Dewey.pm >+++ b/C4/ClassSortRoutine/Dewey.pm >@@ -67,9 +67,13 @@ sub get_class_sort_key { > $init =~ s/^([\p{IsAlpha}]+)/$1 /; > my @tokens = split /\.|\s+/, $init; > my $digit_group_count = 0; >+ my $first_digit_group_idx; > for (my $i = 0; $i <= $#tokens; $i++) { > if ($tokens[$i] =~ /^\d+$/) { > $digit_group_count++; >+ if (1 == $digit_group_count) { >+ $first_digit_group_idx = $i; >+ } > if (2 == $digit_group_count) { > $tokens[$i] = sprintf("%-15.15s", $tokens[$i]); > $tokens[$i] =~ tr/ /0/; >@@ -78,7 +82,7 @@ sub get_class_sort_key { > } > # Pad the first digit_group if there was only one > if (1 == $digit_group_count) { >- $tokens[0] .= '_000000000000000' >+ $tokens[$first_digit_group_idx] .= '_000000000000000' > } > my $key = join("_", @tokens); > $key =~ s/[^\p{IsAlnum}_]//g; >-- >1.7.2.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9770
:
15977
|
19195
|
19383
|
19384
|
19385
|
19386
|
19387
|
19629
|
19630