Filename | /var/www/foswiki11/lib/Foswiki/Macros/MAKETEXT.pm |
Statements | Executed 725 statements in 1.92ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 7.84ms | 15.5ms | BEGIN@7 | Foswiki::
33 | 1 | 1 | 800µs | 5.63ms | MAKETEXT | Foswiki::
4 | 1 | 1 | 44µs | 44µs | _validate | Foswiki::
1 | 1 | 1 | 38µs | 102µs | BEGIN@4 | Foswiki::
1 | 1 | 1 | 30µs | 58µs | BEGIN@5.39 | Foswiki::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki; | ||||
3 | |||||
4 | 2 | 78µs | 2 | 166µs | # spent 102µs (38+64) within Foswiki::BEGIN@4 which was called:
# once (38µs+64µs) by Foswiki::_expandMacroOnTopicRendering at line 4 # spent 102µs making 1 call to Foswiki::BEGIN@4
# spent 64µs making 1 call to strict::import |
5 | 2 | 70µs | 2 | 84µs | # spent 58µs (30+27) within Foswiki::BEGIN@5.39 which was called:
# once (30µs+27µs) by Foswiki::_expandMacroOnTopicRendering at line 5 # spent 58µs making 1 call to Foswiki::BEGIN@5.39
# spent 27µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 984µs | 1 | 15.5ms | # spent 15.5ms (7.84+7.61) within Foswiki::BEGIN@7 which was called:
# once (7.84ms+7.61ms) by Foswiki::_expandMacroOnTopicRendering at line 7 # spent 15.5ms making 1 call to Foswiki::BEGIN@7 |
8 | |||||
9 | # spent 5.63ms (800µs+4.83) within Foswiki::MAKETEXT which was called 33 times, avg 171µs/call:
# 33 times (800µs+4.83ms) by Foswiki::_expandMacroOnTopicRendering at line 3160 of /var/www/foswiki11/lib/Foswiki.pm, avg 171µs/call | ||||
10 | 33 | 23µs | my ( $this, $params ) = @_; | ||
11 | |||||
12 | 33 | 35µs | my $str = $params->{_DEFAULT} || $params->{string} || ""; | ||
13 | 33 | 7µs | return "" unless $str; | ||
14 | |||||
15 | # escape everything: | ||||
16 | 33 | 38µs | $str =~ s/\[/~[/g; | ||
17 | 33 | 22µs | $str =~ s/\]/~]/g; | ||
18 | |||||
19 | # restore already escaped stuff: | ||||
20 | 33 | 17µs | $str =~ s/~~+\[/~[/g; | ||
21 | 33 | 13µs | $str =~ s/~~+\]/~]/g; | ||
22 | |||||
23 | 33 | 14µs | my $max = 0; | ||
24 | 33 | 9µs | my $min = 1; | ||
25 | 33 | 9µs | my $param_error = 0; | ||
26 | |||||
27 | # unescape parameters and calculate highest parameter number: | ||||
28 | 37 | 54µs | 4 | 44µs | $str =~ s/~\[(\_(\d+))~\]/_validate($1, $2, $max, $min, $param_error)/ge; # spent 44µs making 4 calls to Foswiki::_validate, avg 11µs/call |
29 | $str =~ | ||||
30 | 33 | 15µs | s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_error)/ge; | ||
31 | 33 | 8µs | return $str if ($param_error); | ||
32 | |||||
33 | # get the args to be interpolated. | ||||
34 | 33 | 27µs | my $argsStr = $params->{args} || ""; | ||
35 | |||||
36 | # Escape any escapes. | ||||
37 | 33 | 25µs | $str =~ s#\\#\\\\#g | ||
38 | if ( $Foswiki::cfg{UserInterfaceInternationalisation} | ||||
39 | && $Locale::Maketext::VERSION | ||||
40 | && $Locale::Maketext::VERSION < 1.23 ); # escape any escapes | ||||
41 | |||||
42 | 33 | 47µs | my @args = split( /\s*,\s*/, $argsStr ); | ||
43 | |||||
44 | # fill omitted args with empty strings | ||||
45 | 33 | 37µs | while ( ( scalar @args ) < $max ) { | ||
46 | 1 | 1µs | push( @args, '' ); | ||
47 | } | ||||
48 | |||||
49 | # do the magic: | ||||
50 | 33 | 149µs | 66 | 4.79ms | my $result = $this->i18n->maketext( $str, @args ); # spent 4.62ms making 33 calls to Foswiki::i18n, avg 140µs/call
# spent 173µs making 33 calls to Foswiki::I18N::Fallback::maketext, avg 5µs/call |
51 | |||||
52 | # replace accesskeys: | ||||
53 | 33 | 63µs | $result =~ | ||
54 | s#(^|[^&])&([a-zA-Z])#$1<span class='foswikiAccessKey'>$2</span>#g; | ||||
55 | |||||
56 | # replace escaped amperstands: | ||||
57 | 33 | 11µs | $result =~ s/&&/\&/g; | ||
58 | |||||
59 | 33 | 112µs | return $result; | ||
60 | } | ||||
61 | |||||
62 | # spent 44µs within Foswiki::_validate which was called 4 times, avg 11µs/call:
# 4 times (44µs+0s) by Foswiki::MAKETEXT at line 28, avg 11µs/call | ||||
63 | |||||
64 | #my ( $contents, $number, $max, $min, $param_error ) = @_ | ||||
65 | |||||
66 | 4 | 14µs | $_[2] = $_[1] if ( $_[1] > $_[2] ); # Record maximum param number | ||
67 | 4 | 5µs | $_[3] = $_[1] if ( $_[1] < $_[3] ); # Record minimum param number | ||
68 | |||||
69 | 4 | 3µs | if ( $_[1] > 100 ) { | ||
70 | $_[4] = 1; # Set error flag | ||||
71 | return | ||||
72 | "<span class=\"foswikiAlert\">Excessive parameter number $_[2], MAKETEXT rejected.</span>"; | ||||
73 | } | ||||
74 | 4 | 3µs | if ( $_[1] < 1 ) { | ||
75 | $_[4] = 1; # Set error flag | ||||
76 | return | ||||
77 | "<span class=\"foswikiAlert\">Invalid parameter <code>\"$_[0]\"</code>, MAKETEXT rejected.</span>"; | ||||
78 | } | ||||
79 | 4 | 26µs | return "[$_[0]]"; # Return the complete bracket parameter without escapes | ||
80 | } | ||||
81 | |||||
82 | 1 | 4µs | 1; | ||
83 | __END__ |