This file is indexed.

/usr/share/perl5/Test/Valgrind/Version.pm is in libtest-valgrind-perl 1.18-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package Test::Valgrind::Version;

use strict;
use warnings;

=head1 NAME

Test::Valgrind::Version - Object class for valgrind versions.

=head1 VERSION

Version 1.18

=cut

our $VERSION = '1.18';

=head1 DESCRIPTION

This class is used to parse, store and compare C<valgrind> versions.

=cut

use base 'Test::Valgrind::Carp';

use Scalar::Util ();

my $instanceof = sub {
 Scalar::Util::blessed($_[0]) && $_[0]->isa($_[1]);
};

=head1 METHODS

=head2 C<new>

    my $vg_version = Test::Valgrind::Version->new(
     command_output => qx{valgrind --version},
    );

    my $vg_version = Test::Valgrind::Version->new(
     string => '1.2.3',
    );

Creates a new L<Test::Valgrind::Version> object representing a C<valgrind> version from one of these two sources :

=over 4

=item *

if the C<command_output> option is specified, then C<new> will try to parse it as the output of C<valgrind --version>.

=item *

otherwise the C<string> option must be passed, and its value will be parsed as a 'dotted-integer' version number.

=back

An exception is raised if the version number cannot be inferred from the supplied data.

=cut

sub new {
 my ($class, %args) = @_;

 my $output = $args{command_output};
 my $string;
 if (defined $output) {
  ($string) = $output =~ /^valgrind-([0-9]+(?:\.[0-9]+)*)(?!\.)/;
 } else {
  $string = $args{string};
  return $string if $string->$instanceof(__PACKAGE__);
  if (defined $string and $string =~ /^([0-9]+(?:\.[0-9]+)*)(?!\.)/) {
   $string = $1;
  } else {
   $string = undef;
  }
 }
 $class->_croak('Invalid argument') unless defined $string;

 my @digits = map int, split /\./, $string;
 my $last   = $#digits;
 for my $i (reverse 0 .. $#digits) {
  last if $digits[$i];
  --$last;
 }

 bless {
  _digits => [ @digits[0 .. $last] ],
  _last   => $last,
 }, $class;
}

BEGIN {
 local $@;
 eval "sub $_ { \$_[0]->{$_} }" for qw<_digits _last>;
 die $@ if $@;
}

=head1 OVERLOADING

This class overloads numeric comparison operators (C<< <=> >>, C<< < >>, C<< <= >>, C< == >, C<< => >> and C<< > >>), as well as stringification.

=cut

sub _spaceship {
 my ($left, $right, $swap) = @_;

 unless ($right->$instanceof(__PACKAGE__)) {
  $right = __PACKAGE__->new(string => $right);
 }
 ($right, $left) = ($left, $right) if $swap;

 my $left_digits  = $left->_digits;
 my $right_digits = $right->_digits;

 my $last_cmp = $left->_last <=> $right->_last;
 my $last     = ($last_cmp < 0) ? $left->_last : $right->_last;

 for my $i (0 .. $last) {
  my $cmp = $left_digits->[$i] <=> $right_digits->[$i];
  return $cmp if $cmp;
 }

 return $last_cmp;
}

sub _stringify {
 my $self   = shift;
 my @digits = @{ $self->_digits };
 push @digits, 0 until @digits >= 3;
 join '.', @digits;
}

use overload (
 '<=>'    => \&_spaceship,
 '""'     => \&_stringify,
 fallback => 1,
);

=head1 SEE ALSO

L<Test::Valgrind>.

=head1 AUTHOR

Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.

You can contact me by mail or on C<irc.perl.org> (vincent).

=head1 BUGS

Please report any bugs or feature requests to C<bug-test-valgrind at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>.
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Test::Valgrind::Component

=head1 COPYRIGHT & LICENSE

Copyright 2015 Vincent Pit, 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; # End of Test::Valgrind::Version