← 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:09 2021

Filename/usr/local/lib/perl5/site_perl/mach/5.32/XML/LibXML/Error.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sXML::LibXML::Error::::BEGIN@11XML::LibXML::Error::BEGIN@11
0000s0sXML::LibXML::Error::::BEGIN@12XML::LibXML::Error::BEGIN@12
0000s0sXML::LibXML::Error::::BEGIN@15XML::LibXML::Error::BEGIN@15
0000s0sXML::LibXML::Error::::BEGIN@17XML::LibXML::Error::BEGIN@17
0000s0sXML::LibXML::Error::::BEGIN@19XML::LibXML::Error::BEGIN@19
0000s0sXML::LibXML::Error::::BEGIN@21XML::LibXML::Error::BEGIN@21
0000s0sXML::LibXML::Error::::BEGIN@244XML::LibXML::Error::BEGIN@244
0000s0sXML::LibXML::Error::::BEGIN@33XML::LibXML::Error::BEGIN@33
0000s0sXML::LibXML::Error::::BEGIN@34XML::LibXML::Error::BEGIN@34
0000s0sXML::LibXML::Error::::BEGIN@35XML::LibXML::Error::BEGIN@35
0000s0sXML::LibXML::Error::::BEGIN@36XML::LibXML::Error::BEGIN@36
0000s0sXML::LibXML::Error::::BEGIN@38XML::LibXML::Error::BEGIN@38
0000s0sXML::LibXML::Error::::BEGIN@39XML::LibXML::Error::BEGIN@39
0000s0sXML::LibXML::Error::::BEGIN@40XML::LibXML::Error::BEGIN@40
0000s0sXML::LibXML::Error::::BEGIN@41XML::LibXML::Error::BEGIN@41
0000s0sXML::LibXML::Error::::BEGIN@42XML::LibXML::Error::BEGIN@42
0000s0sXML::LibXML::Error::::BEGIN@43XML::LibXML::Error::BEGIN@43
0000s0sXML::LibXML::Error::::BEGIN@44XML::LibXML::Error::BEGIN@44
0000s0sXML::LibXML::Error::::BEGIN@45XML::LibXML::Error::BEGIN@45
0000s0sXML::LibXML::Error::::BEGIN@46XML::LibXML::Error::BEGIN@46
0000s0sXML::LibXML::Error::::BEGIN@47XML::LibXML::Error::BEGIN@47
0000s0sXML::LibXML::Error::::BEGIN@48XML::LibXML::Error::BEGIN@48
0000s0sXML::LibXML::Error::::BEGIN@49XML::LibXML::Error::BEGIN@49
0000s0sXML::LibXML::Error::::BEGIN@50XML::LibXML::Error::BEGIN@50
0000s0sXML::LibXML::Error::::BEGIN@51XML::LibXML::Error::BEGIN@51
0000s0sXML::LibXML::Error::::BEGIN@52XML::LibXML::Error::BEGIN@52
0000s0sXML::LibXML::Error::::BEGIN@53XML::LibXML::Error::BEGIN@53
0000s0sXML::LibXML::Error::::BEGIN@54XML::LibXML::Error::BEGIN@54
0000s0sXML::LibXML::Error::::BEGIN@55XML::LibXML::Error::BEGIN@55
0000s0sXML::LibXML::Error::::BEGIN@56XML::LibXML::Error::BEGIN@56
0000s0sXML::LibXML::Error::::BEGIN@57XML::LibXML::Error::BEGIN@57
0000s0sXML::LibXML::Error::::BEGIN@58XML::LibXML::Error::BEGIN@58
0000s0sXML::LibXML::Error::::BEGIN@59XML::LibXML::Error::BEGIN@59
0000s0sXML::LibXML::Error::::BEGIN@60XML::LibXML::Error::BEGIN@60
0000s0sXML::LibXML::Error::::BEGIN@61XML::LibXML::Error::BEGIN@61
0000s0sXML::LibXML::Error::::BEGIN@62XML::LibXML::Error::BEGIN@62
0000s0sXML::LibXML::Error::::BEGIN@63XML::LibXML::Error::BEGIN@63
0000s0sXML::LibXML::Error::::BEGIN@64XML::LibXML::Error::BEGIN@64
0000s0sXML::LibXML::Error::::BEGIN@65XML::LibXML::Error::BEGIN@65
0000s0sXML::LibXML::Error::::BEGIN@66XML::LibXML::Error::BEGIN@66
0000s0sXML::LibXML::Error::::BEGIN@82XML::LibXML::Error::BEGIN@82
0000s0sXML::LibXML::Error::::__ANON__[:24]XML::LibXML::Error::__ANON__[:24]
0000s0sXML::LibXML::Error::::__ANON__[:27]XML::LibXML::Error::__ANON__[:27]
0000s0sXML::LibXML::Error::::__ANON__[:81]XML::LibXML::Error::__ANON__[:81]
0000s0sXML::LibXML::Error::::_callback_errorXML::LibXML::Error::_callback_error
0000s0sXML::LibXML::Error::::_instant_error_callbackXML::LibXML::Error::_instant_error_callback
0000s0sXML::LibXML::Error::::_report_errorXML::LibXML::Error::_report_error
0000s0sXML::LibXML::Error::::_report_warningXML::LibXML::Error::_report_warning
0000s0sXML::LibXML::Error::::as_stringXML::LibXML::Error::as_string
0000s0sXML::LibXML::Error::::domainXML::LibXML::Error::domain
0000s0sXML::LibXML::Error::::dumpXML::LibXML::Error::dump
0000s0sXML::LibXML::Error::::int1XML::LibXML::Error::int1
0000s0sXML::LibXML::Error::::int2XML::LibXML::Error::int2
0000s0sXML::LibXML::Error::::newXML::LibXML::Error::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# $Id: Error.pm,v 1.1.2.1 2004/04/20 20:09:48 pajas Exp $
2#
3# This is free software, you may use it and distribute it under the same terms as
4# Perl itself.
5#
6# Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas
7#
8#
9package XML::LibXML::Error;
10
11use strict;
12use warnings;
13
14# To avoid a "Deep recursion on subroutine as_string" warning
15no warnings 'recursion';
16
17use Encode ();
18
19use vars qw(@error_domains $VERSION $WARNINGS);
20use overload
21 '""' => \&as_string,
22 'eq' => sub {
23 ("$_[0]" eq "$_[1]")
24 },
25 'cmp' => sub {
26 ("$_[0]" cmp "$_[1]")
27 },
28 fallback => 1;
29
30$WARNINGS = 0; # 0: suppress, 1: report via warn, 2: report via die
31$VERSION = "2.0207"; # VERSION TEMPLATE: DO NOT CHANGE
32
33use constant XML_ERR_NONE => 0;
34use constant XML_ERR_WARNING => 1; # A simple warning
35use constant XML_ERR_ERROR => 2; # A recoverable error
36use constant XML_ERR_FATAL => 3; # A fatal error
37
38use constant XML_ERR_FROM_NONE => 0;
39use constant XML_ERR_FROM_PARSER => 1; # The XML parser
40use constant XML_ERR_FROM_TREE => 2; # The tree module
41use constant XML_ERR_FROM_NAMESPACE => 3; # The XML Namespace module
42use constant XML_ERR_FROM_DTD => 4; # The XML DTD validation
43use constant XML_ERR_FROM_HTML => 5; # The HTML parser
44use constant XML_ERR_FROM_MEMORY => 6; # The memory allocator
45use constant XML_ERR_FROM_OUTPUT => 7; # The serialization code
46use constant XML_ERR_FROM_IO => 8; # The Input/Output stack
47use constant XML_ERR_FROM_FTP => 9; # The FTP module
48use constant XML_ERR_FROM_HTTP => 10; # The FTP module
49use constant XML_ERR_FROM_XINCLUDE => 11; # The XInclude processing
50use constant XML_ERR_FROM_XPATH => 12; # The XPath module
51use constant XML_ERR_FROM_XPOINTER => 13; # The XPointer module
52use constant XML_ERR_FROM_REGEXP => 14; # The regular expressions module
53use constant XML_ERR_FROM_DATATYPE => 15; # The W3C XML Schemas Datatype module
54use constant XML_ERR_FROM_SCHEMASP => 16; # The W3C XML Schemas parser module
55use constant XML_ERR_FROM_SCHEMASV => 17; # The W3C XML Schemas validation module
56use constant XML_ERR_FROM_RELAXNGP => 18; # The Relax-NG parser module
57use constant XML_ERR_FROM_RELAXNGV => 19; # The Relax-NG validator module
58use constant XML_ERR_FROM_CATALOG => 20; # The Catalog module
59use constant XML_ERR_FROM_C14N => 21; # The Canonicalization module
60use constant XML_ERR_FROM_XSLT => 22; # The XSLT engine from libxslt
61use constant XML_ERR_FROM_VALID => 23; # The DTD validation module with valid context
62use constant XML_ERR_FROM_CHECK => 24; # The error-checking module
63use constant XML_ERR_FROM_WRITER => 25; # The xmlwriter module
64use constant XML_ERR_FROM_MODULE => 26; # The dynamically-loaded module module
65use constant XML_ERR_FROM_I18N => 27; # The module handling character conversion
66use constant XML_ERR_FROM_SCHEMATRONV=> 28; # The Schematron validator module
67
68@error_domains = ("", "parser", "tree", "namespace", "validity",
69 "HTML parser", "memory", "output", "I/O", "ftp",
70 "http", "XInclude", "XPath", "xpointer", "regexp",
71 "Schemas datatype", "Schemas parser", "Schemas validity",
72 "Relax-NG parser", "Relax-NG validity",
73 "Catalog", "C14N", "XSLT", "validity", "error-checking",
74 "xmlwriter", "dynamic loading", "i18n",
75 "Schematron validity");
76
77my $MAX_ERROR_PREV_DEPTH = 100;
78
79for my $field (qw<code _prev level file line nodename message column context
80 str1 str2 str3 num1 num2 __prev_depth>) {
81 my $method = sub { $_[0]{$field} };
82 no strict 'refs';
83 *$field = $method;
84}
85
86{
87
88 sub new {
89 my ($class,$xE) = @_;
90 my $terr;
91 if (ref($xE)) {
92 my ($context,$column) = $xE->context_and_column();
93 $terr =bless {
94 domain => $xE->domain(),
95 level => $xE->level(),
96 code => $xE->code(),
97 message => $xE->message(),
98 file => $xE->file(),
99 line => $xE->line(),
100 str1 => $xE->str1(),
101 str2 => $xE->str2(),
102 str3 => $xE->str3(),
103 num1 => $xE->num1(),
104 num2 => $xE->num2(),
105 __prev_depth => 0,
106 (defined($context) ?
107 (
108 context => $context,
109 column => $column,
110 ) : ()),
111 }, $class;
112 } else {
113 # !!!! problem : got a flat error
114 # warn("PROBLEM: GOT A FLAT ERROR $xE\n");
115 $terr =bless {
116 domain => 0,
117 level => 2,
118 code => -1,
119 message => $xE,
120 file => undef,
121 line => undef,
122 str1 => undef,
123 str2 => undef,
124 str3 => undef,
125 num1 => undef,
126 num2 => undef,
127 __prev_depth => 0,
128 }, $class;
129 }
130 return $terr;
131 }
132
133 sub _callback_error {
134 #print "CALLBACK\n";
135 my ($xE,$prev) = @_;
136 my $terr;
137 $terr=XML::LibXML::Error->new($xE);
138 if ($terr->{level} == XML_ERR_WARNING and $WARNINGS!=2) {
139 warn $terr if $WARNINGS;
140 return $prev;
141 }
142 #unless ( defined $terr->{file} and length $terr->{file} ) {
143 # this would make it easier to recognize parsed strings
144 # but it breaks old implementations
145 # [CG] $terr->{file} = 'string()';
146 #}
147 #warn "Saving the error ",$terr->dump;
148
149 if (ref($prev))
150 {
151 if ($prev->__prev_depth() >= $MAX_ERROR_PREV_DEPTH)
152 {
153 return $prev;
154 }
155 $terr->{_prev} = $prev;
156 $terr->{__prev_depth} = $prev->__prev_depth() + 1;
157 }
158 else
159 {
160 $terr->{_prev} = defined($prev) && length($prev) ? XML::LibXML::Error->new($prev) : undef;
161 }
162 return $terr;
163 }
164 sub _instant_error_callback {
165 my $xE = shift;
166 my $terr= XML::LibXML::Error->new($xE);
167 print "Reporting an instanteous error ",$terr->dump;
168 die $terr;
169 }
170 sub _report_warning {
171 my ($saved_error) = @_;
172 #print "CALLBACK WARN\n";
173 if ( defined $saved_error ) {
174 #print "reporting a warning ",$saved_error->dump;
175 warn $saved_error;
176 }
177 }
178 sub _report_error {
179 my ($saved_error) = @_;
180 #print "CALLBACK ERROR: $saved_error\n";
181 if ( defined $saved_error ) {
182 die $saved_error;
183 }
184 }
185}
186
187
188# backward compatibility
189sub int1 { $_[0]->num1 }
190sub int2 { $_[0]->num2 }
191
192sub domain {
193 my ($self)=@_;
194 return undef unless ref($self);
195 my $domain = $self->{domain};
196 # Newer versions of libxml2 might yield errors in domains that aren't
197 # listed above. Invent something reasonable in that case.
198 return $domain < @error_domains ? $error_domains[$domain] : "domain_$domain";
199}
200
201sub as_string {
202 my ($self)=@_;
203 my $msg = "";
204 my $level;
205
206 if (defined($self->{_prev})) {
207 $msg = $self->{_prev}->as_string;
208 }
209
210 if ($self->{level} == XML_ERR_NONE) {
211 $level = "";
212 } elsif ($self->{level} == XML_ERR_WARNING) {
213 $level = "warning";
214 } elsif ($self->{level} == XML_ERR_ERROR ||
215 $self->{level} == XML_ERR_FATAL) {
216 $level = "error";
217 }
218 my $where="";
219 if (defined($self->{file})) {
220 $where="$self->{file}:$self->{line}";
221 } elsif (($self->{domain} == XML_ERR_FROM_PARSER)
222 and
223 $self->{line}) {
224 $where="Entity: line $self->{line}";
225 }
226 if ($self->{nodename}) {
227 $where.=": element ".$self->{nodename};
228 }
229 $msg.=$where.": " if $where ne "";
230 $msg.=$self->domain." ".$level." :";
231 my $str=$self->{message}||"";
232 chomp($str);
233 $msg.=" ".$str."\n";
234 if (($self->{domain} == XML_ERR_FROM_XPATH) and
235 defined($self->{str1})) {
236 $msg.=$self->{str1}."\n";
237 $msg.=(" " x $self->{num1})."^\n";
238 } elsif (defined $self->{context}) {
239 # If the error relates to character-encoding problems in the context,
240 # then doing textual operations on it will spew warnings that
241 # XML::LibXML can do nothing to fix. So just disable all such
242 # warnings. This has the pleasing benefit of making the test suite
243 # run warning-free.
244 no warnings 'utf8';
245 my $context = Encode::encode('UTF-8', $self->{context});
246 $msg.=$context."\n";
247 $context = substr($context,0,$self->{column});
248 $context=~s/[^\t]/ /g;
249 $msg.=$context."^\n";
250 }
251 return $msg;
252}
253
254sub dump {
255 my ($self)=@_;
256 require Data::Dumper;
257 return Data::Dumper->new([$self],['error'])->Dump;
258}
259
2601;