From 267f05fad6a1dda34c7c3d67058da3db6c09e72f Mon Sep 17 00:00:00 2001 From: Dan Sully Date: Wed, 19 Oct 2005 16:18:05 +0000 Subject: [PATCH] Strip any BOM from the string - so it's sorted correctly. Remove a bunch of unused functions. Bug: 2311 git-svn-id: file:///home/awy/mirror/slim/trunk/server@4691 62299810-d8cb-41fd-93b7-d32162e5a4a4 --- Slim/Utils/Text.pm | 71 ++++++---------------------------------------- 1 file changed, 8 insertions(+), 63 deletions(-) diff --git a/Slim/Utils/Text.pm b/Slim/Utils/Text.pm index 5f4b29af0c3..b91cb010e0d 100644 --- a/Slim/Utils/Text.pm +++ b/Slim/Utils/Text.pm @@ -1,8 +1,5 @@ package Slim::Utils::Text; -use strict; -use Tie::Cache::LRU; - # $Id$ # SlimServer Copyright (c) 2001-2004 Sean Adams, Slim Devices Inc. @@ -10,8 +7,12 @@ use Tie::Cache::LRU; # modify it under the terms of the GNU General Public License, # version 2. +use strict; +use Tie::Cache::LRU; + +use Slim::Utils::Unicode; + tie our %caseArticlesMemoize, 'Tie::Cache::LRU', 128; -tie our %sortCache, 'Tie::Cache::LRU', 128; sub ignorePunct { my $s = shift || return undef; @@ -23,6 +24,9 @@ sub ignorePunct { $s =~ s/^ +//o; # zap leading/trailing spaces. $s =~ s/ +$//o; + # See bug: 2311 + $s = Slim::Utils::Unicode::stripBOM($s); + $s = $orig if $s eq ''; return $s; @@ -80,65 +84,6 @@ sub clearCaseArticleCache { %caseArticlesMemoize = (); } -sub sortIgnoringCase { - use locale; - - # set up an array without case for sorting - my @nocase = map { ignoreCaseArticles($_) } @_; - - # return the original array sliced by the sorted caseless array - return @_[sort {$nocase[$a] cmp $nocase[$b]} 0..$#_]; -} - -sub sortuniq { - use locale; - - my %seen = (); - my @uniq = (); - - for my $item (@_) { - if (defined($item) && ($item ne '') && !$seen{ignoreCaseArticles($item)}++) { - push(@uniq, $item); - } - } - - return sort @uniq ; -} - -# similar to above but ignore preceeding articles when sorting -sub sortuniq_ignore_articles { - use locale; - - my %seen = (); - my @uniq = (); - my $articles = Slim::Utils::Prefs::get("ignoredarticles"); - - # allow a space seperated list in preferences (easier for humans to deal with) - $articles =~ s/\s+/|/g; - - for my $item (@_) { - if (defined($item) && ($item ne '') && !$seen{ignoreCaseArticles($item)}++) { - push(@uniq, $item); - } - } - - # set up array for sorting items without leading articles - my @noarts = map { - my $item = $_; - exists($sortCache{$item}) ? $item = $sortCache{$item} : $item =~ s/^($articles)\s+//i; - $item; - } @uniq; - - # return the uniq array sliced by the sorted articleless array - return @uniq[sort {$noarts[$a] cmp $noarts[$b]} 0..$#uniq]; -} - -sub getSortName { - my $item = shift || return; - - return exists($sortCache{ignoreCaseArticles($item)}) ? $sortCache{ignoreCaseArticles($item)} : $item; -} - 1; __END__