← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:08 2021

Filename/usr/local/lib/perl5/site_perl/mach/5.32/HTML/Parser.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sHTML::Parser::::BEGIN@3HTML::Parser::BEGIN@3
0000s0sHTML::Parser::::__ANON__[:47]HTML::Parser::__ANON__[:47]
0000s0sHTML::Parser::::__ANON__[:53]HTML::Parser::__ANON__[:53]
0000s0sHTML::Parser::::initHTML::Parser::init
0000s0sHTML::Parser::::netscape_buggy_commentHTML::Parser::netscape_buggy_comment
0000s0sHTML::Parser::::newHTML::Parser::new
0000s0sHTML::Parser::::parse_fileHTML::Parser::parse_file
0000s0sHTML::Parser::::textHTML::Parser::text
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package HTML::Parser;
2
3use strict;
4
5our $VERSION = '3.76';
6
7require HTML::Entities;
8
9require XSLoader;
10XSLoader::load('HTML::Parser', $VERSION);
11
12sub new
13{
14 my $class = shift;
15 my $self = bless {}, $class;
16 return $self->init(@_);
17}
18
19
20sub init
21{
22 my $self = shift;
23 $self->_alloc_pstate;
24
25 my %arg = @_;
26 my $api_version = delete $arg{api_version} || (@_ ? 3 : 2);
27 if ($api_version >= 4) {
28 require Carp;
29 Carp::croak("API version $api_version not supported " .
30 "by HTML::Parser $VERSION");
31 }
32
33 if ($api_version < 3) {
34 # Set up method callbacks compatible with HTML-Parser-2.xx
35 $self->handler(text => "text", "self,text,is_cdata");
36 $self->handler(end => "end", "self,tagname,text");
37 $self->handler(process => "process", "self,token0,text");
38 $self->handler(start => "start",
39 "self,tagname,attr,attrseq,text");
40
41 $self->handler(comment =>
42 sub {
43 my($self, $tokens) = @_;
44 for (@$tokens) {
45 $self->comment($_);
46 }
47 }, "self,tokens");
48
49 $self->handler(declaration =>
50 sub {
51 my $self = shift;
52 $self->declaration(substr($_[0], 2, -1));
53 }, "self,text");
54 }
55
56 if (my $h = delete $arg{handlers}) {
57 $h = {@$h} if ref($h) eq "ARRAY";
58 while (my($event, $cb) = each %$h) {
59 $self->handler($event => @$cb);
60 }
61 }
62
63 # In the end we try to assume plain attribute or handler
64 while (my($option, $val) = each %arg) {
65 if ($option =~ /^(\w+)_h$/) {
66 $self->handler($1 => @$val);
67 }
68 elsif ($option =~ /^(text|start|end|process|declaration|comment)$/) {
69 require Carp;
70 Carp::croak("Bad constructor option '$option'");
71 }
72 else {
73 $self->$option($val);
74 }
75 }
76
77 return $self;
78}
79
80
81sub parse_file
82{
83 my($self, $file) = @_;
84 my $opened;
85 if (!ref($file) && ref(\$file) ne "GLOB") {
86 # Assume $file is a filename
87 local(*F);
88 open(F, "<", $file) || return undef;
89 binmode(F); # should we? good for byte counts
90 $opened++;
91 $file = *F;
92 }
93 my $chunk = '';
94 while (read($file, $chunk, 512)) {
95 $self->parse($chunk) || last;
96 }
97 close($file) if $opened;
98 $self->eof;
99}
100
101
102sub netscape_buggy_comment # legacy
103{
104 my $self = shift;
105 require Carp;
106 Carp::carp("netscape_buggy_comment() is deprecated. " .
107 "Please use the strict_comment() method instead");
108 my $old = !$self->strict_comment;
109 $self->strict_comment(!shift) if @_;
110 return $old;
111}
112
113# set up method stubs
114sub text { }
115*start = \&text;
116*end = \&text;
117*comment = \&text;
118*declaration = \&text;
119*process = \&text;
120
1211;
122
123__END__