| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Pod::Perldoc::GetOptsOO; |
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
2
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
57
|
|
|
5
|
|
|
|
|
|
|
$VERSION = '3.27'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { # Make a DEBUG constant ASAP |
|
8
|
|
|
|
|
|
|
*DEBUG = defined( &Pod::Perldoc::DEBUG ) |
|
9
|
|
|
|
|
|
|
? \&Pod::Perldoc::DEBUG |
|
10
|
1
|
50
|
|
1
|
|
358
|
: sub(){10}; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub getopts { |
|
15
|
0
|
|
|
0
|
1
|
|
my($target, $args, $truth) = @_; |
|
16
|
|
|
|
|
|
|
|
|
17
|
0
|
|
0
|
|
|
|
$args ||= \@ARGV; |
|
18
|
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
$target->aside( |
|
20
|
|
|
|
|
|
|
"Starting switch processing. Scanning arguments [@$args]\n" |
|
21
|
|
|
|
|
|
|
) if $target->can('aside'); |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
return unless @$args; |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
$truth = 1 unless @_ > 2; |
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
DEBUG > 3 and print " Truth is $truth\n"; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $error_count = 0; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
0
|
|
|
|
while( @$args and ($_ = $args->[0]) =~ m/^-(.)(.*)/s ) { |
|
33
|
0
|
|
|
|
|
|
my($first,$rest) = ($1,$2); |
|
34
|
0
|
0
|
|
|
|
|
if ($_ eq '--') { # early exit if "--" |
|
35
|
0
|
|
|
|
|
|
shift @$args; |
|
36
|
0
|
|
|
|
|
|
last; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
0
|
0
|
0
|
|
|
|
if ($first eq '-' and $rest) { # GNU style long param names |
|
39
|
0
|
|
|
|
|
|
($first, $rest) = split '=', $rest, 2; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
0
|
|
|
|
|
|
my $method = "opt_${first}_with"; |
|
42
|
0
|
0
|
|
|
|
|
if( $target->can($method) ) { # it's argumental |
|
43
|
0
|
0
|
|
|
|
|
if($rest eq '') { # like -f bar |
|
44
|
0
|
|
|
|
|
|
shift @$args; |
|
45
|
0
|
0
|
|
|
|
|
$target->warn( "Option $first needs a following argument!\n" ) unless @$args; |
|
46
|
0
|
|
|
|
|
|
$rest = shift @$args; |
|
47
|
|
|
|
|
|
|
} else { # like -fbar (== -f bar) |
|
48
|
0
|
|
|
|
|
|
shift @$args; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
DEBUG > 3 and print " $method => $rest\n"; |
|
52
|
0
|
|
|
|
|
|
$target->$method( $rest ); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Otherwise, it's not argumental... |
|
55
|
|
|
|
|
|
|
} else { |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if( $target->can( $method = "opt_$first" ) ) { |
|
|
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
DEBUG > 3 and print " $method is true ($truth)\n"; |
|
59
|
0
|
|
|
|
|
|
$target->$method( $truth ); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Otherwise it's an unknown option... |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} elsif( $target->can('handle_unknown_option') ) { |
|
64
|
0
|
|
|
|
|
|
DEBUG > 3 |
|
65
|
|
|
|
|
|
|
and print " calling handle_unknown_option('$first')\n"; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
0
|
|
|
|
$error_count += ( |
|
68
|
|
|
|
|
|
|
$target->handle_unknown_option( $first ) || 0 |
|
69
|
|
|
|
|
|
|
); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} else { |
|
72
|
0
|
|
|
|
|
|
++$error_count; |
|
73
|
0
|
|
|
|
|
|
$target->warn( "Unknown option: $first\n" ); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
if($rest eq '') { # like -f |
|
77
|
0
|
|
|
|
|
|
shift @$args |
|
78
|
|
|
|
|
|
|
} else { # like -fbar (== -f -bar ) |
|
79
|
0
|
|
|
|
|
|
DEBUG > 2 and print " Setting args->[0] to \"-$rest\"\n"; |
|
80
|
0
|
|
|
|
|
|
$args->[0] = "-$rest"; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$target->aside( |
|
87
|
0
|
0
|
|
|
|
|
"Ending switch processing. Args are [@$args] with $error_count errors.\n" |
|
88
|
|
|
|
|
|
|
) if $target->can('aside'); |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
$error_count == 0; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |