This file is indexed.

/usr/lib/perl5/B/Hooks/Parser.pm is in libb-hooks-parser-perl 0.09-1build2.

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
use strict;
use warnings;

package B::Hooks::Parser;

use B::Hooks::OP::Check;
use parent qw/DynaLoader/;

our $VERSION = '0.09';

sub dl_load_flags { 0x01 }

__PACKAGE__->bootstrap($VERSION);

sub inject {
    my ($code) = @_;

    setup();

    my $line   = get_linestr();
    my $offset = get_linestr_offset();

    substr($line, $offset, 0) = $code;

    set_linestr($line);

    return;
}

1;

__END__

=head1 NAME

B::Hooks::Parser - Interface to perls parser variables

=head1 DESCRIPTION

This module provides an API for parts of the perl parser. It can be used to
modify code while it's being parsed.

=head1 Perl API

=head2 setup()

Does some initialization work. This must be called before any other functions
of this module if you intend to use C<set_linestr>. Returns an id that can be
used to disable the magic using C<teardown>.

=head2 teardown($id)

Disables magic registed using C<setup>.

=head2 get_linestr()

Returns the line the parser is currently working on, or undef if perl isn't
parsing anything right now.

=head2 get_linestr_offset()

Returns the position within the current line to which perl has already parsed
the input, or -1 if nothing is being parsed currently.

=head2 set_linestr($string)

Sets the line the perl parser is currently working on to C<$string>.

Note that perl won't notice any changes in the line string after the position
returned by C<get_linestr_offset>.

Throws an exception when nothing is being compiled.

=head2 inject($string)

Convenience function to insert a piece of perl code into the current line
string (as returned by C<get_linestr>) at the current offset (as returned by
C<get_linestr_offset>).

=head1 C API

The following functions work just like their equivalent in the perl api.

=head2 hook_op_check_id hook_parser_setup (void)

=head2 void hook_parser_teardown (hook_op_check_id id)

=head2 const char *hook_parser_get_linestr (pTHX)

=head2 IV hook_parser_get_linestr_offset (pTHX)

=head2 hook_parser_set_linestr (pTHX_ const char *new_value)

=head1 AUTHOR

Florian Ragwitz E<lt>rafl@debian.orgE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2008  Florian Ragwitz

This module is free software.

You may distribute this code under the same terms as Perl itself.

=cut