0
      platform:serial8250
  A   ˆl–Ü4ý(TÐ;â�À·q ©‹Fÿ�þYd¬ãDp¢�‘¶�üÿÅ„ q¿Ä_ˆI|¥�+V[(ÃÂ 3	    # Copyright Â© Colin Watson <cjwatson@debian.org>
# Copyright Â© Ian Jackson <ijackson@chiark.greenend.org.uk>
# Copyright Â© 2007 Don Armstrong <don@donarmstrong.com>.
# Copyright Â© 2009 RaphaÃ«l Hertzog <hertzog@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

package Dpkg::Version;

use strict;
use warnings;
use warnings::register qw(semantic_change::overload::bool);

our $VERSION = '1.03';
our @EXPORT = qw(
    version_compare
    version_compare_relation
    version_normalize_relation
    version_compare_string
    version_compare_part
    version_split_digits
    version_check
    REL_LT
    REL_LE
    REL_EQ
    REL_GE
    REL_GT
);

use Exporter qw(import);
use Carp;

use Dpkg::Gettext;
use Dpkg::ErrorHandling;

use constant {
    REL_LT => '<<',
    REL_LE => '<=',
    REL_EQ => '=',
    REL_GE => '>=',
    REL_GT => '>>',
};

use overload
    '<=>' => \&_comparison,
    'cmp' => \&_comparison,
    '""'  => sub { return $_[0]->as_string(); },
    'bool' => sub { return $_[0]->is_valid(); },
    'fallback' => 1;

=encoding utf8

=head1 NAME

Dpkg::Version - handling and comparing dpkg-style version numbers

=head1 DESCRIPTION

The Dpkg::Version module provides pure-Perl routines to compare
dpkg-style version numbers (as used in Debian packages) and also
an object oriented interface overriding perl operators
to do the right thing when you compare Dpkg::Version object between
them.

=head1 METHODS

=over 4

=item $v = Dpkg::Version->new($version, %opts)

Create a new Dpkg::Version object corresponding to the version indicated in
the string (scalar) $version. By default it will accepts any string
and consider it as a valid version. If you pass the option "check => 1",
it will return undef if the version is invalid (see version_check for
details).

You can always call $v->is_valid() later on to verify that the version is
valid.

=cut

sub new {
    my ($this, $ver, %opts) = @_;
    my $class = ref($this) || $this;
    $ver = "$ver" if ref($ver); # Try to stringify objects

    if ($opts{check}) {
	return unless version_check($ver);
    }

    my $self = {};
    if ($ver =~ /^([^:]*):(.+)$/) {
	$self->{epoch} = $1;
	$ver = $2;
    } else {
	$self->{epoch} = 0;
	$self->{no_epoch} = 1;
    }
    if ($ver =~ /(.*)-(.*)$/) {
	$self->{version} = $1;
	$self->{revision} = $2;
    } else {
	$self->{version} = $ver;
	$self->{revision} = 0;
	$self->{no_revision} = 1;
    }

    return bless $self, $class;
}

=item boolean evaluation

When the Dpkg::Version object is used in a boolean evaluation (for example
in "if ($v)" or "$v ? \"$v\" : 'default'") it returns true if the version
stored is valid ($v->is_valid()) and false otherwise.

B<Notice>: Between dpkg 1.15.7.2 and 1.19.1 this overload used to return
$v->as_string() if $v->is_valid(), a breaking change in behavior that caused
"0" versions to be evaluated as false. To catch any possibly intended code
that relied on those semantics, this overload will emit a warning with
category "Dpkg::Version::semantic_change::overload::bool" until dpkg 1.20.x.
Once fixed, or for already valid code the warning can be quiesced with

  no if $Dpkg::Version::VERSION ge '1.02',
     warnings => qw(Dpkg::Version::semantic_change::overload::bool);

added after the C<use Dpkg::Version>.

=item $v->is_valid()

Returns true if the version is valid, false otherwise.

=cut

sub is_valid {
    my $s