r21437 - in /branches/upstream/libsort-versions-perl: ./ current/ current/Changes current/MANIFEST current/Makefile.PL current/README current/Versions.pm current/t/ current/t/versions.t
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Sun Jun 15 15:08:08 UTC 2008
Author: gregoa
Date: Sun Jun 15 15:08:08 2008
New Revision: 21437
URL: http://svn.debian.org/wsvn/?sc=1&rev=21437
Log:
[svn-inject] Installing original source of libsort-versions-perl
Added:
branches/upstream/libsort-versions-perl/
branches/upstream/libsort-versions-perl/current/
branches/upstream/libsort-versions-perl/current/Changes
branches/upstream/libsort-versions-perl/current/MANIFEST
branches/upstream/libsort-versions-perl/current/Makefile.PL
branches/upstream/libsort-versions-perl/current/README
branches/upstream/libsort-versions-perl/current/Versions.pm
branches/upstream/libsort-versions-perl/current/t/
branches/upstream/libsort-versions-perl/current/t/versions.t (with props)
Added: branches/upstream/libsort-versions-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libsort-versions-perl/current/Changes?rev=21437&op=file
==============================================================================
--- branches/upstream/libsort-versions-perl/current/Changes (added)
+++ branches/upstream/libsort-versions-perl/current/Changes Sun Jun 15 15:08:08 2008
@@ -1,0 +1,122 @@
+2003-08-24 23:58 ed
+
+ * README, Versions.pm: Version 1.5.
+
+2003-08-24 23:57 ed
+
+ * mkdist: Changed to 'mkdist' written in Perl; now checks version
+ numbers.
+
+2003-08-24 23:43 ed
+
+ * Makefile.PL: Removed DISTNAME - change to Perl standard
+ convention of calling the package Sort-Versions-xxx.tar.gz. Though
+ I don't know quite what DISTNAME did.
+
+2003-08-24 23:41 ed
+
+ * Makefile.PL: Get the version number from Versions.pm rather than
+ hardcoding it in Makefile.PL.
+
+2003-08-24 23:37 ed
+
+ * Versions.pm: Removed CVS log; I'm not that keen on it, especially
+ as most of the log messages were empty.
+
+2003-08-24 23:33 ed
+
+ * t/versions.t: Use Test::More (based on patch from mwj99).
+
+2003-08-24 23:25 ed
+
+ * t/versions.t: Added some more test cases and commented the
+ existing tests. I think this partly follows a patch from mwj99.
+
+2002-09-01 19:20 ed
+
+ * README: Some revisions and modernizing prompted by Matt's new
+ version (although I didn't incorporate all his changes).
+
+2002-09-01 15:03 ed
+
+ * Versions.pm: Updated my email address.
+
+2002-03-09 18:19 ed
+
+ * t/versions.t: Added some tests for calling versioncmp directly,
+ if perl >= 5.6.
+
+2002-03-09 18:19 ed
+
+ * Versions.pm: Made versions() deprecated, so versioncmp() is the
+ routine to call. Small code tidying.
+
+2002-03-09 17:38 ed
+
+ * t/versions.t: Run each test in package main and package Foo.
+
+2002-03-09 17:26 ed
+
+ * Versions.pm, t/versions.t: Applied patch from Slaven Rezic to let
+ versions() work when called from a package other than main. But
+ this is not the final answer, I intend to deprecate versions() and
+ move the code into versioncmp(), which has saner argument passing
+ (not the magic $a and $b).
+
+2002-01-28 19:06 ed
+
+ * Versions.pm: Version 1.3: patch from Hack Kampbjørn for '-' digit
+ groupings as well as '.'.
+
+2002-01-28 19:05 ed
+
+ * README: Added some rather lame examples of -.
+
+2002-01-28 19:03 ed
+
+ * t/versions.t: Added some tests for - digit grouping.
+
+2001-07-28 18:07 ed
+
+ * t/versions.t: Whoops - got the leading-zero tests the wrong way
+ round.
+
+2001-07-28 18:07 ed
+
+ * README: Whoops - got the leading-zero examples the wrong way
+ round in the README.
+
+2001-07-28 18:02 ed
+
+ * mkdist: Modified from Lingua::Preferred to Sort::Versions.
+
+2001-07-28 17:52 ed
+
+ * Versions.pm: Added $VERSION.
+
+2001-07-28 17:40 ed
+
+ * mkdist: Initial revision
+
+2001-07-28 17:34 ed
+
+ * t/versions.t: Added tests for leading-zero numeric comparisons.
+
+2001-07-28 17:33 ed
+
+ * Versions.pm: Added support for numeric comparisons where one
+ version number has a leading zero.
+
+2001-07-28 17:32 ed
+
+ * README: Fixed spelling mistake.
+
+2001-07-28 17:32 ed
+
+ * Makefile.PL: Version 1.2.
+
+2001-07-27 23:27 ed
+
+ * MANIFEST, Makefile.PL, README, Versions.pm, t/versions.t: Initial
+ revision
+
Added: branches/upstream/libsort-versions-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libsort-versions-perl/current/MANIFEST?rev=21437&op=file
==============================================================================
--- branches/upstream/libsort-versions-perl/current/MANIFEST (added)
+++ branches/upstream/libsort-versions-perl/current/MANIFEST Sun Jun 15 15:08:08 2008
@@ -1,0 +1,5 @@
+MANIFEST
+Makefile.PL
+README
+Versions.pm
+t/versions.t
Added: branches/upstream/libsort-versions-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libsort-versions-perl/current/Makefile.PL?rev=21437&op=file
==============================================================================
--- branches/upstream/libsort-versions-perl/current/Makefile.PL (added)
+++ branches/upstream/libsort-versions-perl/current/Makefile.PL Sun Jun 15 15:08:08 2008
@@ -1,0 +1,9 @@
+use ExtUtils::MakeMaker;
+use Carp;
+
+# $Id: Makefile.PL,v 1.4 2003/08/24 22:43:19 ed Exp $
+
+&WriteMakefile(
+ NAME => 'Sort::Versions',
+ VERSION_FROM => 'Versions.pm',
+);
Added: branches/upstream/libsort-versions-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libsort-versions-perl/current/README?rev=21437&op=file
==============================================================================
--- branches/upstream/libsort-versions-perl/current/README (added)
+++ branches/upstream/libsort-versions-perl/current/README Sun Jun 15 15:08:08 2008
@@ -1,0 +1,51 @@
+
+ Sort::Versions - a perl 5 module for sorting of revision (and similar)
+ numbers
+
+This module allows easy sorting (via comparisons) of mixed text and numeric
+strings, similar to the complex "version numbers" that many revision control
+packages and shared library systems use. For an explanation of the
+algorithm, it's easiest to look at these examples:
+
+ 1.1 < 1.2
+ 1.1a < 1.2
+ 1.1 < 1.1.1
+ 1.1 < 1.1a
+ 1.1.a < 1.1a
+ 1 < a
+ a < b
+ 1 < 2
+
+ (special handling for leading zeros)
+ 0002 < 1
+ 1.06 < 1.5
+
+ (a hyphen binds looser than a period)
+ 1-1 < 1-2
+ 1-2 < 1.2
+
+To install, unpack the tarball and say:
+
+ perl Makefile.PL
+ make
+ make test
+
+If the tests are successful, say as root:
+
+ make install
+
+And that's it. Further documentation is available in the Versions.pm file,
+which may be accessed via 'perldoc Sort::Versions' after installation.
+
+* Changes in this release
+
+This is version 1.5; there are no functional changes since the last
+version but some tidying and extra tests.
+
+* Author and copying
+
+The files in this package are copyright Kenneth J. Albanowski, Ed
+Avis, and Matt Johnson. This package is free software; you can
+redistribute it and/or modify it under the same terms as Perl itself.
+
+
Added: branches/upstream/libsort-versions-perl/current/Versions.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libsort-versions-perl/current/Versions.pm?rev=21437&op=file
==============================================================================
--- branches/upstream/libsort-versions-perl/current/Versions.pm (added)
+++ branches/upstream/libsort-versions-perl/current/Versions.pm Sun Jun 15 15:08:08 2008
@@ -1,0 +1,151 @@
+#!/usr/bin/perl
+
+# $Id: Versions.pm,v 1.9 2003/08/24 22:58:14 ed Exp $
+
+# Copyright (c) 1996, Kenneth J. Albanowski. All rights reserved. This
+# program is free software; you can redistribute it and/or modify it under
+# the same terms as Perl itself.
+
+package Sort::Versions;
+use vars '$VERSION';
+$VERSION = '1.5';
+
+require Exporter;
+ at ISA=qw(Exporter);
+
+ at EXPORT=qw(&versions &versioncmp);
+ at EXPORT_OK=qw();
+
+sub versioncmp( $$ ) {
+ my @A = ($_[0] =~ /([-.]|\d+|[^-.\d]+)/g);
+ my @B = ($_[1] =~ /([-.]|\d+|[^-.\d]+)/g);
+
+ my ($A, $B);
+ while (@A and @B) {
+ $A = shift @A;
+ $B = shift @B;
+ if ($A eq '-' and $B eq '-') {
+ next;
+ } elsif ( $A eq '-' ) {
+ return -1;
+ } elsif ( $B eq '-') {
+ return 1;
+ } elsif ($A eq '.' and $B eq '.') {
+ next;
+ } elsif ( $A eq '.' ) {
+ return -1;
+ } elsif ( $B eq '.' ) {
+ return 1;
+ } elsif ($A =~ /^\d+$/ and $B =~ /^\d+$/) {
+ if ($A =~ /^0/ || $B =~ /^0/) {
+ return $A cmp $B if $A cmp $B;
+ } else {
+ return $A <=> $B if $A <=> $B;
+ }
+ } else {
+ $A = uc $A;
+ $B = uc $B;
+ return $A cmp $B if $A cmp $B;
+ }
+ }
+ @A <=> @B;
+}
+
+sub versions() {
+ my $callerpkg = (caller)[0];
+ my $caller_a = "${callerpkg}::a";
+ my $caller_b = "${callerpkg}::b";
+ no strict 'refs';
+ return versioncmp($$caller_a, $$caller_b);
+}
+
+=head1 NAME
+
+Sort::Versions - a perl 5 module for sorting of revision-like numbers
+
+=head1 SYNOPSIS
+
+ use Sort::Versions;
+ @l = sort { versioncmp($a, $b) } qw( 1.2 1.2.0 1.2a.0 1.2.a 1.a 02.a );
+
+ ...
+
+ use Sort::Versions;
+ print 'lower' if versioncmp('1.2', '1.2a') == -1;
+
+ ...
+
+ use Sort::Versions;
+ %h = (1 => 'd', 2 => 'c', 3 => 'b', 4 => 'a');
+ @h = sort { versioncmp($h{$a}, $h{$b}) } keys %h;
+
+=head1 DESCRIPTION
+
+Sort::Versions allows easy sorting of mixed non-numeric and numeric strings,
+like the 'version numbers' that many shared library systems and revision
+control packages use. This is quite useful if you are trying to deal with
+shared libraries. It can also be applied to applications that intersperse
+variable-width numeric fields within text. Other applications can
+undoubtedly be found.
+
+For an explanation of the algorithm, itE<39>s simplest to look at these examples:
+
+ 1.1 < 1.2
+ 1.1a < 1.2
+ 1.1 < 1.1.1
+ 1.1 < 1.1a
+ 1.1.a < 1.1a
+ 1 < a
+ a < b
+ 1 < 2
+ 1.1-3 < 1.1-4
+ 1.1-5 < 1.1.6
+
+More precisely (but less comprehensibly), the two strings are treated
+as subunits delimited by periods or hyphens. Each subunit can contain
+any number of groups of digits or non-digits. If digit groups are
+being compared on both sides, a numeric comparison is used, otherwise
+a ASCII ordering is used. A group or subgroup with more units will win
+if all comparisons are equal. A period binds digit groups together
+more tightly than a hyphen.
+
+Some packages use a different style of version numbering: a simple
+real number written as a decimal. Sort::Versions has limited support
+for this style: when comparing two subunits which are both digit
+groups, if either subunit has a leading zero, then both are treated
+like digits after a decimal point. So for example:
+
+ 0002 < 1
+ 1.06 < 1.5
+
+This wonE<39>t always work, because there wonE<39>t always be a leading zero
+in real-number style version numbers. There is no way for
+Sort::Versions to know which style was intended. But a lot of the time
+it will do the right thing. If you are making up version numbers, the
+style with (possibly) more than one dot is the style to use.
+
+=head1 USAGE
+
+The function C<versioncmp()> takes two arguments and compares them like C<cmp>.
+With perl 5.6 or later, you can also use this function directly in sorting:
+
+ @l = sort versioncmp qw(1.1 1.2 1.0.3);
+
+The function C<versions()> can be used directly as a sort function even on
+perl 5.005 and earlier, but its use is deprecated.
+
+=head1 AUTHOR
+
+Ed Avis <ed at membled.com> and Matt Johnson <mwj99 at doc.ic.ac.uk> for
+recent releases; the original author is Kenneth J. Albanowski
+<kjahds at kjahds.com>. Thanks to Hack Kampbjørn and Slaven Rezic for
+patches and bug reports.
+
+Copyright (c) 1996, Kenneth J. Albanowski. All rights reserved. This
+program is free software; you can redistribute it and/or modify it under the
+same terms as Perl itself.
+
+=cut
+
+1;
+
Added: branches/upstream/libsort-versions-perl/current/t/versions.t
URL: http://svn.debian.org/wsvn/branches/upstream/libsort-versions-perl/current/t/versions.t?rev=21437&op=file
==============================================================================
--- branches/upstream/libsort-versions-perl/current/t/versions.t (added)
+++ branches/upstream/libsort-versions-perl/current/t/versions.t Sun Jun 15 15:08:08 2008
@@ -1,0 +1,113 @@
+#!/usr/bin/perl
+#$Id: versions.t,v 1.9 2003/08/24 22:33:03 ed Exp $
+
+use strict;
+use Sort::Versions;
+use Test::More;
+
+my @tests;
+
+while(<DATA>) {
+ if(/^\s*(\S+)\s*([<>])\s*(\S+)\s*$/) {
+ push @tests, $1,$3 if $2 eq "<";
+ push @tests, $3,$1 if $2 eq ">";
+ }
+}
+
+plan tests => (@tests / 2 * 3) + 3;
+
+my @l = sort versions qw(1.2 1.2a);
+is($l[0], "1.2");
+
+ at l = sort { versioncmp($a, $b) } qw(1.2 1.2a);
+is($l[0], "1.2");
+
+SKIP: {
+ skip "requires perl 5.6.0", 1 unless ($] >= 5.006);
+ @l = sort versioncmp qw(1.2 1.2a);
+ is($l[0], "1.2");
+}
+
+my $i=4;
+while (@tests) {
+ ($a, $b) = @tests[0, 1];
+
+ # Test both the versioncmp() and versions() interfaces, in both
+ # the main package and other packages.
+ #
+ is(versions(), -1, "versions($a, $b)");
+ $i++;
+
+ is(versioncmp($a, $b), -1, "versioncmp($a, $b)");
+ $i++;
+
+ undef $a; undef $b; # just in case
+
+ eval {
+ package Foo;
+ use Sort::Versions;
+ ($a, $b) = @tests[0, 1];
+
+ if (versions() != -1) {
+ die "failed versions() in foreign package";
+ }
+
+ if (versioncmp($a, $b) != -1) {
+ die "failed versioncmp() in foreign package";
+ }
+ };
+ if ($@) {
+ fail($@);
+ }
+ else {
+ pass("foreign package tests ($tests[0], $tests[1])");
+ }
+
+ shift @tests; shift @tests;
+}
+
+
+__END__
+
+# Simple . only tests
+1.2 < 1.3
+1.2 < 1.2.1
+1.2.1 < 1.3
+1.2 < 1.2a
+1.2a < 1.3
+1.2 < 1.2.b
+1.2.1 < 1.2a
+1.2.b < 1.2a
+
+# Assorted non-numerics
+a < b
+a < a.b
+a.b < a.c
+a.1 < a.a
+1 < a
+1a < a
+1a < 2
+
+# Null version point
+1..1 < 1.1.1
+
+# Leading 0 tests
+1 > 0002
+1.5 > 1.06
+
+# Handling mixed -. versions
+1 < 1-1
+1-1 < 1-2
+1-2 < 1.2
+1-2 < 1.0-1
+1-2 < 1.0
+1-2 < 1.3
+1.2-1 < 1.2a-1
+1.3-4.6-7 < 1.3-4.8
+1.3-4.6-7 < 1.3-4.6.7
+1.3-4a-7 < 1.3-4a-7.4
+
+# 'Bug' reported by pgw99
+1.2-1 < 1.2.1-1
+1.2.1-1 < 1.2.1-2
+1.2.1-2 < 1.3.0-1
Propchange: branches/upstream/libsort-versions-perl/current/t/versions.t
------------------------------------------------------------------------------
svn:executable =
More information about the Pkg-perl-cvs-commits
mailing list