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
|
85
|
|
|
85
|
|
19677
|
use strict; |
|
85
|
|
|
|
|
648
|
|
|
85
|
|
|
|
|
2824
|
|
23
|
85
|
|
|
85
|
|
446
|
use warnings; |
|
85
|
|
|
|
|
135
|
|
|
85
|
|
|
|
|
2496
|
|
24
|
85
|
|
|
85
|
|
434
|
use Exporter; |
|
85
|
|
|
|
|
164
|
|
|
85
|
|
|
|
|
5840
|
|
25
|
|
|
|
|
|
|
# Perl::MinimumVersion seems to think this is a Perl 5.008ism... |
26
|
|
|
|
|
|
|
# use base qw( Exporter ); |
27
|
85
|
|
|
85
|
|
595
|
use vars qw( @EXPORT_OK %EXPORT_TAGS ); |
|
85
|
|
|
|
|
187
|
|
|
85
|
|
|
|
|
7729
|
|
28
|
85
|
|
|
85
|
|
558
|
use vars qw( $DEBUG_OPTIONS @STATUS @ERROR @CHOMP @DEBUG @ISA ); |
|
85
|
|
|
|
|
178
|
|
|
85
|
|
|
|
|
10523
|
|
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
|
85
|
|
|
85
|
|
466
|
use constant STATUS_OK => 0; # ok |
|
85
|
|
|
|
|
157
|
|
|
85
|
|
|
|
|
7934
|
|
41
|
85
|
|
|
85
|
|
2856
|
use constant STATUS_RETURN => 1; # ok, block ended by RETURN |
|
85
|
|
|
|
|
184
|
|
|
85
|
|
|
|
|
4180
|
|
42
|
85
|
|
|
85
|
|
431
|
use constant STATUS_STOP => 2; # ok, stopped by STOP |
|
85
|
|
|
|
|
150
|
|
|
85
|
|
|
|
|
4034
|
|
43
|
85
|
|
|
85
|
|
452
|
use constant STATUS_DONE => 3; # ok, iterator done |
|
85
|
|
|
|
|
158
|
|
|
85
|
|
|
|
|
4159
|
|
44
|
85
|
|
|
85
|
|
481
|
use constant STATUS_DECLINED => 4; # ok, declined to service request |
|
85
|
|
|
|
|
158
|
|
|
85
|
|
|
|
|
7432
|
|
45
|
85
|
|
|
85
|
|
435
|
use constant STATUS_ERROR => 255; # error condition |
|
85
|
|
|
|
|
147
|
|
|
85
|
|
|
|
|
4930
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# ERROR constants for indicating exception types |
48
|
85
|
|
|
85
|
|
412
|
use constant ERROR_RETURN => 'return'; # return a status code |
|
85
|
|
|
|
|
170
|
|
|
85
|
|
|
|
|
4316
|
|
49
|
85
|
|
|
85
|
|
428
|
use constant ERROR_FILE => 'file'; # file error: I/O, parse, recursion |
|
85
|
|
|
|
|
644
|
|
|
85
|
|
|
|
|
4395
|
|
50
|
85
|
|
|
85
|
|
438
|
use constant ERROR_VIEW => 'view'; # view error |
|
85
|
|
|
|
|
159
|
|
|
85
|
|
|
|
|
3936
|
|
51
|
85
|
|
|
85
|
|
398
|
use constant ERROR_UNDEF => 'undef'; # undefined variable value used |
|
85
|
|
|
|
|
156
|
|
|
85
|
|
|
|
|
3835
|
|
52
|
85
|
|
|
85
|
|
431
|
use constant ERROR_PERL => 'perl'; # error in [% PERL %] block |
|
85
|
|
|
|
|
151
|
|
|
85
|
|
|
|
|
4847
|
|
53
|
85
|
|
|
85
|
|
427
|
use constant ERROR_FILTER => 'filter'; # filter error |
|
85
|
|
|
|
|
142
|
|
|
85
|
|
|
|
|
4057
|
|
54
|
85
|
|
|
85
|
|
450
|
use constant ERROR_PLUGIN => 'plugin'; # plugin error |
|
85
|
|
|
|
|
150
|
|
|
85
|
|
|
|
|
3963
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# CHOMP constants for PRE_CHOMP and POST_CHOMP |
57
|
85
|
|
|
85
|
|
450
|
use constant CHOMP_NONE => 0; # do not remove whitespace |
|
85
|
|
|
|
|
149
|
|
|
85
|
|
|
|
|
3861
|
|
58
|
85
|
|
|
85
|
|
437
|
use constant CHOMP_ALL => 1; # remove whitespace up to newline |
|
85
|
|
|
|
|
438
|
|
|
85
|
|
|
|
|
4315
|
|
59
|
85
|
|
|
85
|
|
411
|
use constant CHOMP_ONE => 1; # new name for CHOMP_ALL |
|
85
|
|
|
|
|
177
|
|
|
85
|
|
|
|
|
3714
|
|
60
|
85
|
|
|
85
|
|
6282
|
use constant CHOMP_COLLAPSE => 2; # collapse whitespace to a single space |
|
85
|
|
|
|
|
147
|
|
|
85
|
|
|
|
|
5008
|
|
61
|
85
|
|
|
85
|
|
439
|
use constant CHOMP_GREEDY => 3; # remove all whitespace including newlines |
|
85
|
|
|
|
|
141
|
|
|
85
|
|
|
|
|
3688
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# DEBUG constants to enable various debugging options |
64
|
85
|
|
|
85
|
|
411
|
use constant DEBUG_OFF => 0; # do nothing |
|
85
|
|
|
|
|
145
|
|
|
85
|
|
|
|
|
4072
|
|
65
|
85
|
|
|
85
|
|
667
|
use constant DEBUG_ON => 1; # basic debugging flag |
|
85
|
|
|
|
|
163
|
|
|
85
|
|
|
|
|
3571
|
|
66
|
85
|
|
|
85
|
|
438
|
use constant DEBUG_UNDEF => 2; # throw undef on undefined variables |
|
85
|
|
|
|
|
169
|
|
|
85
|
|
|
|
|
3789
|
|
67
|
85
|
|
|
85
|
|
438
|
use constant DEBUG_VARS => 4; # general variable debugging |
|
85
|
|
|
|
|
152
|
|
|
85
|
|
|
|
|
10442
|
|
68
|
85
|
|
|
85
|
|
436
|
use constant DEBUG_DIRS => 8; # directive debugging |
|
85
|
|
|
|
|
155
|
|
|
85
|
|
|
|
|
4632
|
|
69
|
85
|
|
|
85
|
|
418
|
use constant DEBUG_STASH => 16; # general stash debugging |
|
85
|
|
|
|
|
388
|
|
|
85
|
|
|
|
|
3808
|
|
70
|
85
|
|
|
85
|
|
422
|
use constant DEBUG_CONTEXT => 32; # context debugging |
|
85
|
|
|
|
|
153
|
|
|
85
|
|
|
|
|
5519
|
|
71
|
85
|
|
|
85
|
|
6573
|
use constant DEBUG_PARSER => 64; # parser debugging |
|
85
|
|
|
|
|
295
|
|
|
85
|
|
|
|
|
4199
|
|
72
|
85
|
|
|
85
|
|
407
|
use constant DEBUG_PROVIDER => 128; # provider debugging |
|
85
|
|
|
|
|
156
|
|
|
85
|
|
|
|
|
5422
|
|
73
|
85
|
|
|
85
|
|
640
|
use constant DEBUG_PLUGINS => 256; # plugins debugging |
|
85
|
|
|
|
|
178
|
|
|
85
|
|
|
|
|
3647
|
|
74
|
85
|
|
|
85
|
|
1796
|
use constant DEBUG_FILTERS => 512; # filters debugging |
|
85
|
|
|
|
|
207
|
|
|
85
|
|
|
|
|
4328
|
|
75
|
85
|
|
|
85
|
|
420
|
use constant DEBUG_SERVICE => 1024; # context debugging |
|
85
|
|
|
|
|
162
|
|
|
85
|
|
|
|
|
3665
|
|
76
|
85
|
|
|
85
|
|
1508
|
use constant DEBUG_ALL => 2047; # everything |
|
85
|
|
|
|
|
135
|
|
|
85
|
|
|
|
|
3863
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# extra debugging flags |
79
|
85
|
|
|
85
|
|
400
|
use constant DEBUG_CALLER => 4096; # add caller file/line |
|
85
|
|
|
|
|
146
|
|
|
85
|
|
|
|
|
3809
|
|
80
|
85
|
|
|
85
|
|
400
|
use constant DEBUG_FLAGS => 4096; # bitmask to extract flags |
|
85
|
|
|
|
|
148
|
|
|
85
|
|
|
|
|
73118
|
|
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
|
13
|
my ($self, $debug) = @_; |
121
|
4
|
|
|
|
|
8
|
my (@flags, $flag, $value); |
122
|
4
|
50
|
33
|
|
|
14
|
$debug = $self unless defined($debug) || ref($self); |
123
|
|
|
|
|
|
|
|
124
|
4
|
100
|
|
|
|
18
|
if ($debug =~ /^\d+$/) { |
125
|
1
|
|
|
|
|
3
|
foreach $flag (@DEBUG) { |
126
|
15
|
100
|
|
|
|
46
|
next if $flag =~ /^DEBUG_(OFF|ALL|FLAGS)$/; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# don't trash the original |
129
|
12
|
|
|
|
|
12
|
my $copy = $flag; |
130
|
12
|
|
|
|
|
29
|
$flag =~ s/^DEBUG_//; |
131
|
12
|
|
|
|
|
19
|
$flag = lc $flag; |
132
|
12
|
50
|
|
|
|
31
|
return $self->error("no value for flag: $flag") |
133
|
|
|
|
|
|
|
unless defined($value = $DEBUG_OPTIONS->{ $flag }); |
134
|
12
|
|
|
|
|
15
|
$flag = $value; |
135
|
|
|
|
|
|
|
|
136
|
12
|
100
|
|
|
|
53
|
if ($debug & $flag) { |
137
|
2
|
|
|
|
|
7
|
$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
|
|
|
|
8
|
return wantarray ? @flags : join(', ', @flags); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
else { |
145
|
3
|
|
|
|
|
19
|
@flags = split(/\W+/, $debug); |
146
|
3
|
|
|
|
|
5
|
$debug = 0; |
147
|
3
|
|
|
|
|
7
|
foreach $flag (@flags) { |
148
|
5
|
|
|
|
|
12
|
$value = $DEBUG_OPTIONS->{ $flag }; |
149
|
5
|
100
|
|
|
|
16
|
return $self->error("unknown debug flag: $flag") unless defined $value; |
150
|
4
|
|
|
|
|
8
|
$debug |= $value; |
151
|
|
|
|
|
|
|
} |
152
|
2
|
|
|
|
|
11
|
return $debug; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
1; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
__END__ |