diff options
-rw-r--r-- | MDK/Common/DataStructure.pm | 4 | ||||
-rw-r--r-- | MDK/Common/String.pm | 2 | ||||
-rw-r--r-- | perl-MDK-Common.spec | 6 |
3 files changed, 8 insertions, 4 deletions
diff --git a/MDK/Common/DataStructure.pm b/MDK/Common/DataStructure.pm index ecdb45f..83e49f1 100644 --- a/MDK/Common/DataStructure.pm +++ b/MDK/Common/DataStructure.pm @@ -57,7 +57,7 @@ is the scalar undefined or is the hash empty =item uniq(LIST) -returns the list with no duplicates +returns the list with no duplicates (keeping the first elements) =item difference2(ARRAY REF, ARRAY REF) @@ -111,7 +111,7 @@ sub deref { ref $_[0] eq "ARRAY" ? @{$_[0]} : ref $_[0] eq "HASH" ? %{$_[0]} : $ sub is_empty_array_ref { my $a = shift; !defined $a || @$a == 0 } sub is_empty_hash_ref { my $a = shift; !defined $a || keys(%$a) == 0 } -sub uniq { my %l; @l{@_} = (); keys %l } +sub uniq { my %l; $l{$_} = 1 foreach @_; grep { delete $l{$_} } @_ } sub difference2 { my %l; @l{@{$_[1]}} = (); grep { !exists $l{$_} } @{$_[0]} } sub intersection { my (%l, @m); @l{@{shift @_}} = (); foreach (@_) { @m = grep { exists $l{$_} } @$_; %l = (); @l{@m} = (); } keys %l } diff --git a/MDK/Common/String.pm b/MDK/Common/String.pm index 480c8f4..76cc34c 100644 --- a/MDK/Common/String.pm +++ b/MDK/Common/String.pm @@ -134,7 +134,7 @@ sub warp_text { my ($beg) = /^(\s*)/; my $t = ''; foreach (split /\s+/, $_) { - if (length "$t $_" > $width) { + if (length "$beg$t $_" > $width) { push @l, "$beg$t"; $beg = ''; $t = $_; diff --git a/perl-MDK-Common.spec b/perl-MDK-Common.spec index 28b3a7c..82d0033 100644 --- a/perl-MDK-Common.spec +++ b/perl-MDK-Common.spec @@ -2,7 +2,7 @@ # do not change the version here, change in MDK/Common.pm.pl %define version THEVERSION -%define release 3mdk +%define release 4mdk %define perl_sitelib %(eval "`perl -V:installsitelib`"; echo $installsitelib) Summary: Various simple functions @@ -50,6 +50,10 @@ rm -rf $RPM_BUILD_ROOT # MODIFY IN THE CVS: cvs.mandrakesoft.com:/cooker soft/perl-MDK-Common %changelog +* Mon Sep 10 2001 Pixel <pixel@mandrakesoft.com> 1.0.2-4mdk +- DataStructure::uniq : keep the order +- String::warp_text : fixed + * Thu Sep 6 2001 Pixel <pixel@mandrakesoft.com> 1.0.2-3mdk - substInFile works on empty files |