Bugzilla – Attachment 1966 Details for
Bug 4265
Sorting by call number in OPAC is slightly off
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Small script used to test the proposed changes to C4/ClassSortRoutine/Dewey.pm
sort_test.pl (text/plain), 1.96 KB, created by
Chris Cormack
on 2010-02-25 21:13:00 UTC
(
hide
)
Description:
Small script used to test the proposed changes to C4/ClassSortRoutine/Dewey.pm
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2010-02-25 21:13:00 UTC
Size:
1.96 KB
patch
obsolete
>#!/usr/bin/perl -w > >use strict; >use warnings; >use diagnostics; >use Data::Dumper; > >my @tests = ('306', '306. Les', '306.46', '306 Les', '306.0 Les', '306.4 Les', '306.40 Les', '306.46 Les'); > >printf "%-10s -> %-23s => %-20s\n", 'Input', 'Old routine', 'Proposed patch'; >for my $test (@tests) { > printf "%-10s -> %-23s => %-20s\n", $test, old_routine($test), new_routine($test); >} > >sub old_routine{ > my $init = shift; > > my @tokens = split /\.|\s+/, $init; > my $digit_group_count = 0; > for (my $i = 0; $i <= $#tokens; $i++) { > if ($tokens[$i] =~ /^\d+$/) { > $digit_group_count++; > if (2 == $digit_group_count) { > $tokens[$i] = sprintf("%-15.15s", $tokens[$i]); > $tokens[$i] =~ tr/ /0/; > } > } > } > my $key = join("_", @tokens); > $key =~ s/[^\p{IsAlnum}_]//g; > return $key; >} > >sub new_routine{ > my $init = shift; > > my @tokens = split /\.|\s+/, $init; > my $digit_group_count = 0; > for (my $i = 0; $i <= $#tokens; $i++) { > if ($tokens[$i] =~ /^\d+$/) { > $digit_group_count++; > if (2 == $digit_group_count) { > $tokens[$i] = sprintf("%-15.15s", $tokens[$i]); > $tokens[$i] =~ tr/ /0/; > } > } > } > # Pad the first digit_group if there was only one > if (1 == $digit_group_count) { > $tokens[0] .= '_000000000000000' > } > my $key = join("_", @tokens); > $key =~ s/[^\p{IsAlnum}_]//g; > return $key; >} > >__END__ > >Input -> Old routine => Proposed patch >306 -> 306 => 306_000000000000000 >306. Les -> 306__Les => 306_000000000000000__Les >306.46 -> 306_460000000000000 => 306_460000000000000 >306 Les -> 306_Les => 306_000000000000000_Les >306.0 Les -> 306_000000000000000_Les => 306_000000000000000_Les >306.4 Les -> 306_400000000000000_Les => 306_400000000000000_Les >306.40 Les -> 306_400000000000000_Les => 306_400000000000000_Les >306.46 Les -> 306_460000000000000_Les => 306_460000000000000_Les
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 Raw
Actions:
View
Attachments on
bug 4265
:
1964
|
1965
| 1966