From e9c8e76089e57d605c17550161ab47509161a07d Mon Sep 17 00:00:00 2001 From: Florian Ragwitz Date: Fri, 10 Dec 2010 13:50:00 +0100 Subject: [PATCH] Dual-life I18N::Collate --- MANIFEST | 4 ++-- Porting/Maintainers.pl | 9 ++++++++- {lib => dist/I18N-Collate/lib}/I18N/Collate.pm | 16 ++++++++-------- lib/I18N/Collate.t => dist/I18N-Collate/t/I18N-Collate.t | 8 +++++--- lib/.gitignore | 1 + 5 files changed, 24 insertions(+), 14 deletions(-) rename {lib => dist/I18N-Collate/lib}/I18N/Collate.pm (96%) rename lib/I18N/Collate.t => dist/I18N-Collate/t/I18N-Collate.t (78%) diff --git a/MANIFEST b/MANIFEST index 06456d3..082ddb6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2748,6 +2748,8 @@ dist/Filter-Simple/t/lib/Filter/Simple/ExportTest.pm Helper file for Filter::Si dist/Filter-Simple/t/lib/Filter/Simple/FilterOnlyTest.pm Helper file for Filter::Simple tests dist/Filter-Simple/t/lib/Filter/Simple/FilterTest.pm Helper file for Filter::Simple tests dist/Filter-Simple/t/lib/Filter/Simple/ImportTest.pm Helper file for Filter::Simple tests +dist/I18N-Collate/lib/I18N/Collate.pm Routines to do strxfrm-based collation +dist/I18N-Collate/t/I18N-Collate.t See if I18N::Collate works dist/I18N-LangTags/ChangeLog I18N::LangTags dist/I18N-LangTags/lib/I18N/LangTags/Detect.pm Detect language preferences dist/I18N-LangTags/lib/I18N/LangTags/List.pm List of tags for human languages @@ -3727,8 +3729,6 @@ lib/Getopt/Std.t See if Getopt::Std and Getopt::Long work lib/h2ph.t See if h2ph works like it should lib/h2xs.t See if h2xs produces expected lists of files lib/hostname.pl Old hostname code -lib/I18N/Collate.pm Routines to do strxfrm-based collation -lib/I18N/Collate.t See if I18N::Collate works lib/importenv.pl Perl routine to get environment into variables lib/integer.pm For "use integer" lib/integer.t For "use integer" testing diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index 33d0607..3228cc4 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -721,6 +721,14 @@ use File::Glob qw(:case); 'UPSTREAM' => 'cpan', }, + 'I18N::Collate' => + { + 'MAINTAINER' => 'p5p', + 'DISTRIBUTION' => 'FLORA/I18N-Collate-1.01.tar.gz', + 'FILES' => q[dist/I18N-Collate], + 'UPSTREAM' => 'blead', + }, + # Sean has donated it to us. # Nothing has changed since his last CPAN release. # (not strictly true: there have been some trivial typo fixes; DAPM 6/2009) @@ -1712,7 +1720,6 @@ use File::Glob qw(:case); lib/FileHandle.{pm,t} lib/FindBin.{pm,t} lib/Getopt/Std.{pm,t} - lib/I18N/Collate.{pm,t} lib/Internals.t lib/Module/Build/ConfigData.pm lib/Net/hostent.{pm,t} diff --git a/lib/I18N/Collate.pm b/dist/I18N-Collate/lib/I18N/Collate.pm similarity index 96% rename from lib/I18N/Collate.pm rename to dist/I18N-Collate/lib/I18N/Collate.pm index decc86c..95c9c1c 100644 --- a/lib/I18N/Collate.pm +++ b/dist/I18N-Collate/lib/I18N/Collate.pm @@ -10,7 +10,7 @@ I18N::Collate - compare 8-bit scalar data according to the current locale =head1 SYNOPSIS use I18N::Collate; - setlocale(LC_COLLATE, 'locale-of-your-choice'); + setlocale(LC_COLLATE, 'locale-of-your-choice'); $s1 = I18N::Collate->new("scalar_data_1"); $s2 = I18N::Collate->new("scalar_data_2"); @@ -33,8 +33,8 @@ I18N::Collate - compare 8-bit scalar data according to the current locale *** -This module provides you with objects that will collate -according to your national character set, provided that the +This module provides you with objects that will collate +according to your national character set, provided that the POSIX setlocale() function is supported on your system. You can compare $s1 and $s2 above with @@ -83,11 +83,11 @@ European character set. # setlocale(LC_COLLATE, 'locale-of-your-choice'); # 4) # $s1 = I18N::Collate->("scalar_data_1"); # $s2 = I18N::Collate->("scalar_data_2"); -# +# # now you can compare $s1 and $s2: $s1 le $s2 # to extract the data itself, you need to deref: $$s1 -# -# Notes: +# +# Notes: # 1) this uses POSIX::setlocale # 2) the basic collation conversion is done by strxfrm() which # terminates at NUL characters being a decent C routine. @@ -161,7 +161,7 @@ sub setlocale { my ($category, $locale) = @_[0,1]; POSIX::setlocale($category, $locale) if (defined $category); - # the current $LOCALE + # the current $LOCALE $LOCALE = $locale || $ENV{'LC_COLLATE'} || $ENV{'LC_ALL'} || ''; } @@ -177,7 +177,7 @@ sub C { sub collate_xfrm { my $s = $_[0]; my $x = ''; - + for (split(/(\000+)/, $s)) { $x .= (/^\000/) ? $_ : strxfrm("$_\000"); } diff --git a/lib/I18N/Collate.t b/dist/I18N-Collate/t/I18N-Collate.t similarity index 78% rename from lib/I18N/Collate.t rename to dist/I18N-Collate/t/I18N-Collate.t index bf3ba20..1728026 100644 --- a/lib/I18N/Collate.t +++ b/dist/I18N-Collate/t/I18N-Collate.t @@ -1,8 +1,11 @@ #!./perl +# at least in the CPAN version we're sometimes called with -w, for example +# during 'make test', so disable them explicitly and only turn them on again for +# the deprecation test. +no warnings; + BEGIN { - chdir 't' if -d 't'; - @INC = '../lib'; require Config; import Config; if (!$Config{d_setlocale} || $Config{ccflags} =~ /\bD?NO_LOCALE\b/) { print "1..0\n"; @@ -41,4 +44,3 @@ print "ok 6\n"; print "not " if $a lt $b == $a gt $b; print "ok 7\n"; - diff --git a/lib/.gitignore b/lib/.gitignore index e35ae28..7f45114 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -183,6 +183,7 @@ /Filter/Util /GDBM_File.pm /Hash +/I18N/Collate.pm /I18N/LangTags /I18N/LangTags.pm /I18N/Langinfo.pm -- 2.7.4