This file is indexed.

/usr/share/perl5/XMLTV/Grep.pm is in libxmltv-perl 0.5.70-1.

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
173
174
175
176
# This is intended mostly as a helper library for tv_grep and not for
# general purpose use (yet).
#
# $Id: Grep.pm,v 1.5 2004/01/03 14:52:53 epaepa Exp $
#
package XMLTV::Grep;
use strict;
use XMLTV;
use base 'Exporter'; our @EXPORT_OK;
@EXPORT_OK = qw(get_matcher);

my %key_type = %{XMLTV::list_programme_keys()};

# Parameters:
#   key found in programme hashes
#   ignore-case flag
#
# Returns:
#   extra argument type needed to filter on this key:
#     undef: no extra argument required
#     'regexp': extra argument should be regexp
#     'empty': extra argument must be the empty string, and is ignored
#
#   subroutine which may take an argument (depending on whether
#   argument type is 'regexp'), and matches a programme hash in $_.
#
sub get_matcher( $$ ) {
    my ($key, $ignore_case) = @_;
    my ($handler, $mult) = @{$key_type{$key}};
    if ($handler eq 'presence') {
	die "bad multiplicity $mult for 'presence'"
	  if $mult ne '?';
	return [ undef, sub { exists $_->{$key} } ];
    }
    elsif ($handler eq 'scalar') {
	if ($mult eq '?') {
	    return [ 'regexp', sub {
			 my $regexp = shift;
			 return 0 if not exists $_->{$key};
			 return 1 if $regexp eq '';
			 if ($ignore_case) {
			     return $_->{$key} =~ /$regexp/i;
			 }
			 else {
			     return $_->{$key} =~ /$regexp/;
			 }
		     } ];
	}
	elsif ($mult eq '1') {
	    return [ 'regexp', sub {
			 my $regexp = shift;
			 die if not exists $_->{$key};
			 return 1 if $regexp eq '';
			 if ($ignore_case) {
			     return $_->{$key} =~ /$regexp/i;
			 }
			 else {
			     return $_->{$key} =~ /$regexp/;
			 }
		     } ];
	}
	elsif ($mult eq '*') {
	    return [ 'regexp', sub {
			 my $regexp = shift;
			 # It is possible (though unusual) for the key
			 # to exist but be an empty list.
			 #
			 return 0 if not exists $_->{$key} or not @{$_->{$key}};
			 return 1 if $regexp eq '';
			 foreach (@{$_->{$key}}) {
			     return 1 if ($ignore_case ? /$regexp/i : /$regexp/);
			 }
			 return 0;
		     } ];
	}
	elsif ($mult eq '+') {
	    return [ 'regexp', sub {
			 my $regexp = shift;
			 die if not @{$_->{$key}};
			 return 1 if $regexp eq '';
			 foreach (@{$_->{$key}}) {
			     return 1 if ($ignore_case ? /$regexp/i : /$regexp/);
			 }
			 return 0;
		     } ];
	}
	else { die }
    }
    elsif ($handler =~ m!^with-lang(?:/[a-z]*)?$!) {
	if ($mult eq '?') {
	    return [ 'regexp', sub {
			 my $regexp = shift;
			 return 0 if not exists $_->{$key};
			 return 1 if $regexp eq '';
			 for ($_->{$key}->[0]) {
			     return 0 if not defined;
			     if ($ignore_case) {
				 return /$regexp/i;
			     }
			     else {
				 return /$regexp/;
			     }
			 }
		     } ];
	}
	elsif ($mult eq '1') {
	    return [ 'regexp', sub {
			 my $regexp = shift;
			 die if not exists $_->{$key};
			 return 1 if $regexp eq '';
			 for ($_->{$key}->[0]) {
			     if (not defined) {
				 warn "undef text for $key";
				 return 0;
			     }
			     if ($ignore_case) {
				 return /$regexp/i;
			     }
			     else {
				 return /$regexp/;
			     }
			 }
		     } ];
	}
	elsif ($mult eq '*') {
	    return [ 'regexp', sub {
			 my $regexp = shift;
			 return 0 if not exists $_->{$key} or not @{$_->{$key}};
			 return 1 if $regexp eq '';
			 foreach (map { $_->[0] } @{$_->{$key}}) {
			     if (not defined) {
				 warn "undef text for $key";
				 next;
			     }
			     return 1 if ($ignore_case ? /$regexp/i : /$regexp/);
			 }
			 return 0;
		     } ];
	}
	elsif ($mult eq '+') {
	    return [ 'regexp', sub {
			 my $regexp = shift;
			 die if not @{$_->{$key}};
			 return 1 if $regexp eq '';
			 foreach (map { $_->[0] } @{$_->{$key}}) {
			     if (not defined) {
				 warn "undef text for $key";
				 next;
			     }
			     return 1 if ($ignore_case ? /$regexp/i : /$regexp/);
			 }
			 return 0;
		     } ];
	} 
	else { die }
    }
    elsif ($handler eq 'icon'
	   or $handler eq 'credits'
	   or $handler eq 'length'      # TODO
	   or $handler eq 'episode-num' # TODO
	   or $handler eq 'video'
	   or $handler eq 'audio'
	   or $handler eq 'previously-shown'
	   or $handler eq 'subtitles'
	   or $handler eq 'rating'      # TODO
	   or $handler eq 'star-rating' # TODO
	  ) {
	# Cannot query on this except for presence.  But empty string
	# argument for future expansion.
	#
	return [ 'empty', sub { exists $_->{$key} } ];
    }
    else { die }
}

1;