This file is indexed.

/usr/lib/perl5/Device/Cdio/Util.pm is in libdevice-cdio-perl 0.3.0-2build1.

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
170
171
172
package Device::Cdio::Util;
require 5.8.6;
#
#  $Id$
#
#  Copyright (C) 2006, 2008 Rocky Bernstein <rocky@cpan.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 3 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 <http://www.gnu.org/licenses/>.

# These are internal routines. Not all that useful for external consumption.

use strict;
use vars qw($VERSION @EXPORT_OK @ISA );
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(_rearrange _make_attributes _check_arg_count _extra_args);

$VERSION = $Device::Cdio::VERSION;

# Check that we $count (the argument count of arguments passed has
# between $min and $max arguments.
sub _check_arg_count {
    my ($count, $min, $max) = @_;
    my $msg = undef;
    if (!defined($max)) {
	if ($count != $min) {
	    $msg = sprintf("Need to supply exactly %d arguments. (got %d)",
			   $min, $count);
	}
    } elsif ($count < $min) {
	$msg = sprintf("Need to supply at least %d arguments. (got %d)",
		       $min, $count);
    } elsif ($count > $max) {
	$msg = sprintf("Need to supply no more than %d arguments. (got %d)",
		       $max, $count);
    }
    if (defined($msg)) {
	my (undef, $file, $line, $called)= caller(1);
	print "$msg.\n\tCalled $called from file $file at line $line\n";
	return 0;
    }
    return 1;
}

# Check that we $count (the argument count of arguments passed has
# between $min and $max arguments.
sub _extra_args {
    my @args = @_;
    if (@args != 0) {
	my (undef, $file, $line, $called)= caller(1);
	my $arg_count = @args;
	print "$arg_count extraneous parameter given in call\n";
	print "\tCalled $called from file $file at line $line\n";
	return 1;
    }
    return 0;
}

# Taken from CGI::Util
sub _make_attributes {
    my $attr = shift;
    return () unless $attr && ref($attr) && ref($attr) eq 'HASH';
    my $escape =  shift || 0;
    my(@att);
    foreach (keys %{$attr}) {
	my($key) = $_;
	$key=~s/^\-//;     # get rid of initial - if present

	# old way: breaks EBCDIC!
	# $key=~tr/A-Z_/a-z-/; # parameters are lower case, use dashes

	($key="\L$key") =~ tr/_/-/; # parameters are lower case, use dashes

	my $value = $escape ? _simple_escape($attr->{$_}) : $attr->{$_};
	push(@att,defined($attr->{$_}) ? qq/$key="$value"/ : qq/$key/);
    }
    return @att;
}

# Taken from CGI::Util
# Smart rearrangement of parameters to allow named parameter
# calling.  We do the rearangement if:
# the first parameter begins with a -
sub _rearrange {
    my($order,@param) = @_;
    return () unless @param;

    if (ref($param[0]) eq 'HASH') {
	@param = %{$param[0]};
    } else {
	return @param 
	    unless (defined($param[0]) && substr($param[0],0,1) eq '-' 
		    && $param[0] !~ m{\A-\d+});
    }

    # map parameters into positional indices
    my ($i,%pos);
    $i = 0;
    foreach (@$order) {
	foreach (ref($_) eq 'ARRAY' ? @$_ : $_) { $pos{lc($_)} = $i; }
	$i++;
    }

    my (@result,%leftover);
    $#result = $#$order;  # preextend
    while (@param) {
	my $key = lc(shift(@param));
	$key =~ s/^\-//;
	if (exists $pos{$key}) {
	    $result[$pos{$key}] = shift(@param);
	} else {
	    $leftover{$key} = shift(@param);
	}
    }

    push (@result,_make_attributes(\%leftover,defined $CGI::Q ? $CGI::Q->{escape} : 1)) if %leftover;
    @result;
}

# Also from CGI::Util.pm
sub _simple_escape {
  return unless defined(my $toencode = shift);
  $toencode =~ s{&}{&amp;}gso;
  $toencode =~ s{<}{&lt;}gso;
  $toencode =~ s{>}{&gt;}gso;
  $toencode =~ s{\"}{&quot;}gso;
# Doesn't work.  Can't work.  forget it.
#  $toencode =~ s{\x8b}{&#139;}gso;
#  $toencode =~ s{\x9b}{&#155;}gso;
  $toencode;
}

1; # Magic true value required at the end of a module

__END__

=head1 NAME

Device::Cdio::Util - Internal utilities used by Cdio modules

=head1 SYNOPSIS

none

=head1 DESCRIPTION

no public subroutines

=head1 AUTHOR INFORMATION

Code taken from CGI::Util.pm which reads: 
Copyright 1995-1998, Lincoln D. Stein.  All rights reserved.  

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 SEE ALSO

L<Device::Cdio>

=cut