line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#============================================================= -*-Perl-*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Template::Constants.pm |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# DESCRIPTION |
6
|
|
|
|
|
|
|
# Definition of constants for the Template Toolkit. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# AUTHOR |
9
|
|
|
|
|
|
|
# Andy Wardley |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# COPYRIGHT |
12
|
|
|
|
|
|
|
# Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# This module is free software; you can redistribute it and/or |
15
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
#============================================================================ |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Template::Constants; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
require Exporter; |
22
|
86
|
|
|
86
|
|
29375
|
use strict; |
|
86
|
|
|
|
|
591
|
|
|
86
|
|
|
|
|
3238
|
|
23
|
86
|
|
|
86
|
|
426
|
use warnings; |
|
86
|
|
|
|
|
142
|
|
|
86
|
|
|
|
|
3099
|
|
24
|
86
|
|
|
86
|
|
424
|
use Exporter; |
|
86
|
|
|
|
|
179
|
|
|
86
|
|
|
|
|
4714
|
|
25
|
|
|
|
|
|
|
# Perl::MinimumVersion seems to think this is a Perl 5.008ism... |
26
|
|
|
|
|
|
|
# use base qw( Exporter ); |
27
|
86
|
|
|
86
|
|
442
|
use vars qw( @EXPORT_OK %EXPORT_TAGS ); |
|
86
|
|
|
|
|
283
|
|
|
86
|
|
|
|
|
6889
|
|
28
|
86
|
|
|
86
|
|
545
|
use vars qw( $DEBUG_OPTIONS @STATUS @ERROR @CHOMP @DEBUG @ISA ); |
|
86
|
|
|
|
|
181
|
|
|
86
|
|
|
|
|
23331
|
|
29
|
|
|
|
|
|
|
# ... so we'll do it the Old Skool way just to keep it quiet |
30
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = 2.75; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#======================================================================== |
36
|
|
|
|
|
|
|
# ----- EXPORTER ----- |
37
|
|
|
|
|
|
|
#======================================================================== |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# STATUS constants returned by directives |
40
|
86
|
|
|
86
|
|
492
|
use constant STATUS_OK => 0; # ok |
|
86
|
|
|
|
|
148
|
|
|
86
|
|
|
|
|
8362
|
|
41
|
86
|
|
|
86
|
|
542
|
use constant STATUS_RETURN => 1; # ok, block ended by RETURN |
|
86
|
|
|
|
|
170
|
|
|
86
|
|
|
|
|
4163
|
|
42
|
86
|
|
|
86
|
|
436
|
use constant STATUS_STOP => 2; # ok, stopped by STOP |
|
86
|
|
|
|
|
162
|
|
|
86
|
|
|
|
|
4031
|
|
43
|
86
|
|
|
86
|
|
533
|
use constant STATUS_DONE => 3; # ok, iterator done |
|
86
|
|
|
|
|
177
|
|
|
86
|
|
|
|
|
3951
|
|
44
|
86
|
|
|
86
|
|
544
|
use constant STATUS_DECLINED => 4; # ok, declined to service request |
|
86
|
|
|
|
|
504
|
|
|
86
|
|
|
|
|
4405
|
|
45
|
86
|
|
|
86
|
|
464
|
use constant STATUS_ERROR => 255; # error condition |
|
86
|
|
|
|
|
159
|
|
|
86
|
|
|
|
|
4481
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# ERROR constants for indicating exception types |
48
|
86
|
|
|
86
|
|
422
|
use constant ERROR_RETURN => 'return'; # return a status code |
|
86
|
|
|
|
|
153
|
|
|
86
|
|
|
|
|
4617
|
|
49
|
86
|
|
|
86
|
|
498
|
use constant ERROR_FILE => 'file'; # file error: I/O, parse, recursion |
|
86
|
|
|
|
|
267
|
|
|
86
|
|
|
|
|
6565
|
|
50
|
86
|
|
|
86
|
|
4666
|
use constant ERROR_VIEW => 'view'; # view error |
|
86
|
|
|
|
|
638
|
|
|
86
|
|
|
|
|
3904
|
|
51
|
86
|
|
|
86
|
|
410
|
use constant ERROR_UNDEF => 'undef'; # undefined variable value used |
|
86
|
|
|
|
|
177
|
|
|
86
|
|
|
|
|
4122
|
|
52
|
86
|
|
|
86
|
|
487
|
use constant ERROR_PERL => 'perl'; # error in [% PERL %] block |
|
86
|
|
|
|
|
169
|
|
|
86
|
|
|
|
|
5238
|
|
53
|
86
|
|
|
86
|
|
430
|
use constant ERROR_FILTER => 'filter'; # filter error |
|
86
|
|
|
|
|
140
|
|
|
86
|
|
|
|
|
4076
|
|
54
|
86
|
|
|
86
|
|
399
|
use constant ERROR_PLUGIN => 'plugin'; # plugin error |
|
86
|
|
|
|
|
141
|
|
|
86
|
|
|
|
|
4026
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# CHOMP constants for PRE_CHOMP and POST_CHOMP |
57
|
86
|
|
|
86
|
|
592
|
use constant CHOMP_NONE => 0; # do not remove whitespace |
|
86
|
|
|
|
|
163
|
|
|
86
|
|
|
|
|
9522
|
|
58
|
86
|
|
|
86
|
|
470
|
use constant CHOMP_ALL => 1; # remove whitespace up to newline |
|
86
|
|
|
|
|
185
|
|
|
86
|
|
|
|
|
3885
|
|
59
|
86
|
|
|
86
|
|
425
|
use constant CHOMP_ONE => 1; # new name for CHOMP_ALL |
|
86
|
|
|
|
|
195
|
|
|
86
|
|
|
|
|
3892
|
|
60
|
86
|
|
|
86
|
|
690
|
use constant CHOMP_COLLAPSE => 2; # collapse whitespace to a single space |
|
86
|
|
|
|
|
152
|
|
|
86
|
|
|
|
|
4689
|
|
61
|
86
|
|
|
86
|
|
467
|
use constant CHOMP_GREEDY => 3; # remove all whitespace including newlines |
|
86
|
|
|
|
|
172
|
|
|
86
|
|
|
|
|
13327
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# DEBUG constants to enable various debugging options |
64
|
86
|
|
|
86
|
|
557
|
use constant DEBUG_OFF => 0; # do nothing |
|
86
|
|
|
|
|
181
|
|
|
86
|
|
|
|
|
4419
|
|
65
|
86
|
|
|
86
|
|
703
|
use constant DEBUG_ON => 1; # basic debugging flag |
|
86
|
|
|
|
|
232
|
|
|
86
|
|
|
|
|
3628
|
|
66
|
86
|
|
|
86
|
|
481
|
use constant DEBUG_UNDEF => 2; # throw undef on undefined variables |
|
86
|
|
|
|
|
220
|
|
|
86
|
|
|
|
|
7189
|
|
67
|
86
|
|
|
86
|
|
411
|
use constant DEBUG_VARS => 4; # general variable debugging |
|
86
|
|
|
|
|
187
|
|
|
86
|
|
|
|
|
15305
|
|
68
|
86
|
|
|
86
|
|
448
|
use constant DEBUG_DIRS => 8; # directive debugging |
|
86
|
|
|
|
|
158
|
|
|
86
|
|
|
|
|
3938
|
|
69
|
86
|
|
|
86
|
|
531
|
use constant DEBUG_STASH => 16; # general stash debugging |
|
86
|
|
|
|
|
155
|
|
|
86
|
|
|
|
|
4048
|
|
70
|
86
|
|
|
86
|
|
539
|
use constant DEBUG_CONTEXT => 32; # context debugging |
|
86
|
|
|
|
|
179
|
|
|
86
|
|
|
|
|
4223
|
|
71
|
86
|
|
|
86
|
|
416
|
use constant DEBUG_PARSER => 64; # parser debugging |
|
86
|
|
|
|
|
315
|
|
|
86
|
|
|
|
|
3779
|
|
72
|
86
|
|
|
86
|
|
500
|
use constant DEBUG_PROVIDER => 128; # provider debugging |
|
86
|
|
|
|
|
163
|
|
|
86
|
|
|
|
|
4506
|
|
73
|
86
|
|
|
86
|
|
548
|
use constant DEBUG_PLUGINS => 256; # plugins debugging |
|
86
|
|
|
|
|
165
|
|
|
86
|
|
|
|
|
4580
|
|
74
|
86
|
|
|
86
|
|
661
|
use constant DEBUG_FILTERS => 512; # filters debugging |
|
86
|
|
|
|
|
179
|
|
|
86
|
|
|
|
|
4565
|
|
75
|
86
|
|
|
86
|
|
731
|
use constant DEBUG_SERVICE => 1024; # context debugging |
|
86
|
|
|
|
|
161
|
|
|
86
|
|
|
|
|
4032
|
|
76
|
86
|
|
|
86
|
|
522
|
use constant DEBUG_ALL => 2047; # everything |
|
86
|
|
|
|
|
154
|
|
|
86
|
|
|
|
|
3951
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# extra debugging flags |
79
|
86
|
|
|
86
|
|
762
|
use constant DEBUG_CALLER => 4096; # add caller file/line |
|
86
|
|
|
|
|
154
|
|
|
86
|
|
|
|
|
3781
|
|
80
|
86
|
|
|
86
|
|
419
|
use constant DEBUG_FLAGS => 4096; # bitmask to extract flags |
|
86
|
|
|
|
|
202
|
|
|
86
|
|
|
|
|
92156
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$DEBUG_OPTIONS = { |
83
|
|
|
|
|
|
|
&DEBUG_OFF => off => off => &DEBUG_OFF, |
84
|
|
|
|
|
|
|
&DEBUG_ON => on => on => &DEBUG_ON, |
85
|
|
|
|
|
|
|
&DEBUG_UNDEF => undef => undef => &DEBUG_UNDEF, |
86
|
|
|
|
|
|
|
&DEBUG_VARS => vars => vars => &DEBUG_VARS, |
87
|
|
|
|
|
|
|
&DEBUG_DIRS => dirs => dirs => &DEBUG_DIRS, |
88
|
|
|
|
|
|
|
&DEBUG_STASH => stash => stash => &DEBUG_STASH, |
89
|
|
|
|
|
|
|
&DEBUG_CONTEXT => context => context => &DEBUG_CONTEXT, |
90
|
|
|
|
|
|
|
&DEBUG_PARSER => parser => parser => &DEBUG_PARSER, |
91
|
|
|
|
|
|
|
&DEBUG_PROVIDER => provider => provider => &DEBUG_PROVIDER, |
92
|
|
|
|
|
|
|
&DEBUG_PLUGINS => plugins => plugins => &DEBUG_PLUGINS, |
93
|
|
|
|
|
|
|
&DEBUG_FILTERS => filters => filters => &DEBUG_FILTERS, |
94
|
|
|
|
|
|
|
&DEBUG_SERVICE => service => service => &DEBUG_SERVICE, |
95
|
|
|
|
|
|
|
&DEBUG_ALL => all => all => &DEBUG_ALL, |
96
|
|
|
|
|
|
|
&DEBUG_CALLER => caller => caller => &DEBUG_CALLER, |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
@STATUS = qw( STATUS_OK STATUS_RETURN STATUS_STOP STATUS_DONE |
100
|
|
|
|
|
|
|
STATUS_DECLINED STATUS_ERROR ); |
101
|
|
|
|
|
|
|
@ERROR = qw( ERROR_FILE ERROR_VIEW ERROR_UNDEF ERROR_PERL |
102
|
|
|
|
|
|
|
ERROR_RETURN ERROR_FILTER ERROR_PLUGIN ); |
103
|
|
|
|
|
|
|
@CHOMP = qw( CHOMP_NONE CHOMP_ALL CHOMP_ONE CHOMP_COLLAPSE CHOMP_GREEDY ); |
104
|
|
|
|
|
|
|
@DEBUG = qw( DEBUG_OFF DEBUG_ON DEBUG_UNDEF DEBUG_VARS |
105
|
|
|
|
|
|
|
DEBUG_DIRS DEBUG_STASH DEBUG_CONTEXT DEBUG_PARSER |
106
|
|
|
|
|
|
|
DEBUG_PROVIDER DEBUG_PLUGINS DEBUG_FILTERS DEBUG_SERVICE |
107
|
|
|
|
|
|
|
DEBUG_ALL DEBUG_CALLER DEBUG_FLAGS ); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
@EXPORT_OK = ( @STATUS, @ERROR, @CHOMP, @DEBUG ); |
110
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
111
|
|
|
|
|
|
|
'all' => [ @EXPORT_OK ], |
112
|
|
|
|
|
|
|
'status' => [ @STATUS ], |
113
|
|
|
|
|
|
|
'error' => [ @ERROR ], |
114
|
|
|
|
|
|
|
'chomp' => [ @CHOMP ], |
115
|
|
|
|
|
|
|
'debug' => [ @DEBUG ], |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub debug_flags { |
120
|
4
|
|
|
4
|
0
|
17
|
my ($self, $debug) = @_; |
121
|
4
|
|
|
|
|
5
|
my (@flags, $flag, $value); |
122
|
4
|
50
|
33
|
|
|
15
|
$debug = $self unless defined($debug) || ref($self); |
123
|
|
|
|
|
|
|
|
124
|
4
|
100
|
|
|
|
20
|
if ($debug =~ /^\d+$/) { |
125
|
1
|
|
|
|
|
4
|
foreach $flag (@DEBUG) { |
126
|
15
|
100
|
|
|
|
54
|
next if $flag =~ /^DEBUG_(OFF|ALL|FLAGS)$/; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# don't trash the original |
129
|
12
|
|
|
|
|
15
|
my $copy = $flag; |
130
|
12
|
|
|
|
|
42
|
$flag =~ s/^DEBUG_//; |
131
|
12
|
|
|
|
|
25
|
$flag = lc $flag; |
132
|
12
|
50
|
|
|
|
40
|
return $self->error("no value for flag: $flag") |
133
|
|
|
|
|
|
|
unless defined($value = $DEBUG_OPTIONS->{ $flag }); |
134
|
12
|
|
|
|
|
17
|
$flag = $value; |
135
|
|
|
|
|
|
|
|
136
|
12
|
100
|
|
|
|
32
|
if ($debug & $flag) { |
137
|
2
|
|
|
|
|
5
|
$value = $DEBUG_OPTIONS->{ $flag }; |
138
|
2
|
50
|
|
|
|
6
|
return $self->error("no value for flag: $flag") unless defined $value; |
139
|
2
|
|
|
|
|
5
|
push(@flags, $value); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
} |
142
|
1
|
50
|
|
|
|
10
|
return wantarray ? @flags : join(', ', @flags); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
else { |
145
|
3
|
|
|
|
|
24
|
@flags = split(/\W+/, $debug); |
146
|
3
|
|
|
|
|
7
|
$debug = 0; |
147
|
3
|
|
|
|
|
7
|
foreach $flag (@flags) { |
148
|
5
|
|
|
|
|
14
|
$value = $DEBUG_OPTIONS->{ $flag }; |
149
|
5
|
100
|
|
|
|
18
|
return $self->error("unknown debug flag: $flag") unless defined $value; |
150
|
4
|
|
|
|
|
9
|
$debug |= $value; |
151
|
|
|
|
|
|
|
} |
152
|
2
|
|
|
|
|
14
|
return $debug; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
1; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
__END__ |