This file is indexed.

/usr/share/perl5/Tk/Pod/Cache.pm is in libtk-pod-perl 0.9942-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
# -*- perl -*-

#
# Author: Slaven Rezic
#
# Copyright (C) 2002,2012 Slaven Rezic. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# Mail: slaven@rezic.de
# WWW:  http://www.rezic.de/eserte/
#

package Tk::Pod::Cache;
use strict;
use vars qw($VERSION $MAX_CACHE %CACHE);

BEGIN {  # Make a DEBUG constant very first thing...
  if(defined &DEBUG) {
  } elsif(($ENV{'TKPODDEBUG'} || '') =~ m/^(\d+)/) { # untaint
    my $debug = $1;
    *DEBUG = sub () { $debug };
  } else {
    *DEBUG = sub () {0};
  }
}

$VERSION = '5.02';

$MAX_CACHE = 20; # documents # XXX not yet used, LRU etc...

sub add_to_cache {
    my($w, $pod) = @_;
    $pod = $w->cget(-path) if !defined $pod;
    return if !defined $pod;
    return if $CACHE{$pod}; # XXX check for recentness
    DEBUG and warn "Add contents for $pod to cache.\n";
    $CACHE{$pod} = $w->dump_contents;
}

sub get_from_cache {
    my($w, $pod) = @_;
    $pod = $w->cget(-path) if !defined $pod;
    return 0 if !$CACHE{$pod};
    # XXX check for recentness
    $w->delete("1.0", "end");
    DEBUG and warn "Restore contents for $pod from cache.\n";
    $w->restore_contents($CACHE{$pod});
    1;
}

sub delete_from_cache {
    my($w, $pod) = @_;
    $pod = $w->cget(-path) if !defined $pod;
    return if !defined $pod;
    DEBUG and warn "Delete contents for $pod from cache.\n";
    delete $CACHE{$pod};
}

sub clear_cache {
    %CACHE = ();
}

sub dump_contents {
    my $w = shift;
    my @dump = $w->dump('-all', "1.0", "end");
    if (@dump == 0) {
	warn "Workaround strange bug under RedHat 8.0 --- try dump again...";	
	@dump = $w->dump('-all', "1.0", "end");
	if (@dump == 0) {
	    warn "Giving up, cache disabled for current page";
	    return undef;
	}
    }
    my %tags_def;
    foreach my $tag ($w->tagNames) {
	# XXX check for used/existing tags missing
	my @tag_def;
	foreach my $item ($w->tagConfigure($tag)) {
	    my $value  = $item->[4];
	    my $option = $item->[0];
	    push @tag_def, $option, $value;
	}
	$tags_def{$tag} = \@tag_def;
    }
    return {Dump => \@dump,
	    Tags => \%tags_def,
	    Sections => $w->{'sections'},
	    PodTitle => $w->{'pod_title'},
	   };
}

sub restore_contents {
    my($w, $def) = @_;

    my $dumpref = $def->{Dump};
    my $tagref  = $def->{Tags};
    $w->{'sections'}  = $def->{Sections};
    $w->{'pod_title'} = $def->{PodTitle};

    $w->toplevel->title( "Tkpod: " . $w->{'pod_title'} . " (restoring)");
    $w->idletasks;
    # XXX  Is it bad form to manipulate the top level?

    my $process_no;
    $w->{ProcessNo}++;
    $process_no = $w->{ProcessNo};

    if ($tagref) {
	while(my($tag,$def) = each %$tagref) {
	    #XXX tagDelete?
	    $w->tagConfigure($tag, @$def);
	}
    }

    my @taglist;

    my $last_update = Tk::timeofday();
    for(my $i=0; $i<$#$dumpref; $i+=3) {
	my($key, $val, $index) = @{$dumpref}[$i..$i+2];
	if      ($key eq 'text') {
	    $w->insert($index, $val, [@taglist]);
	} elsif ($key eq 'tagon') {
	    unshift @taglist, $val;
	} elsif ($key eq 'tagoff') {
	    my $j;
	    for (0 .. $#taglist) {
		if ($taglist[$_] eq $val) {
		    $j = $_;
		    last;
		}
	    }
	    if (defined $j) {
		splice @taglist, $j, 1;
	    }
	    $w->tag('remove', $val, 'insert');
	} elsif ($key eq 'mark') {
	    $w->markSet($val, $index); # XXX ->see() to current or insert?
	} elsif ($key eq 'windows') {
	    die "not yet supported";
	} elsif ($key eq 'image') {
	    die "not yet supported";
	} elsif ($key eq 'imgdef') {
	    die "not yet supported";
	}

	if (Tk::timeofday() > $last_update+0.5) { # XXX make configurable
	    $w->update;
	    $last_update = Tk::timeofday();
	    do { warn "ABORT!"; return } if $w->{ProcessNo} != $process_no;
	}
    }

    $w->parent->add_section_menu if $w->parent->can('add_section_menu');
    $w->Callback('-poddone', $w->cget(-file));

    $w->toplevel->title( "Tkpod: " . $w->{'pod_title'});
}

1;

__END__

=head1 NAME

Tk::Pod::Cache - internal Tk-Pod module for cache control

=head1 DESCRIPTION

No user-servicable parts here.

=cut