line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2011-2015 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.01. |
5
|
2
|
|
|
2
|
|
16141
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
52
|
|
6
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
58
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package POSIX::1003; |
9
|
2
|
|
|
2
|
|
5
|
use vars '$VERSION'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
78
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.99_07'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
10
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
90
|
|
14
|
2
|
|
|
2
|
|
227
|
use POSIX::1003::Module (); # preload |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
568
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %own_functions = map +($_ => 1), qw/ |
17
|
|
|
|
|
|
|
posix_1003_modules |
18
|
|
|
|
|
|
|
posix_1003_names |
19
|
|
|
|
|
|
|
show_posix_names |
20
|
|
|
|
|
|
|
/; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our (%EXPORT_TAGS, %IMPORT_FROM, %SUBSET); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my %tags = |
26
|
|
|
|
|
|
|
( confstr => 'POSIX::1003::Confstr' |
27
|
|
|
|
|
|
|
, cs => 'POSIX::1003::Confstr' |
28
|
|
|
|
|
|
|
, errno => 'POSIX::1003::Errno' |
29
|
|
|
|
|
|
|
, errors => 'POSIX::1003::Errno' |
30
|
|
|
|
|
|
|
, events => 'POSIX::1003::Events' |
31
|
|
|
|
|
|
|
, ev => 'POSIX::1003::Events' |
32
|
|
|
|
|
|
|
, fcntl => 'POSIX::1003::Fcntl' |
33
|
|
|
|
|
|
|
, fdio => 'POSIX::1003::FdIO' |
34
|
|
|
|
|
|
|
, fd => 'POSIX::1003::FdIO' |
35
|
|
|
|
|
|
|
, filesystem => 'POSIX::1003::FS' |
36
|
|
|
|
|
|
|
, fs => 'POSIX::1003::FS' |
37
|
|
|
|
|
|
|
, glob => 'POSIX::1003::FS' |
38
|
|
|
|
|
|
|
, limit => 'POSIX::1003::Limit' |
39
|
|
|
|
|
|
|
, limits => 'POSIX::1003::Limit' |
40
|
|
|
|
|
|
|
, locale => 'POSIX::1003::Locale' |
41
|
|
|
|
|
|
|
, math => 'POSIX::1003::Math' |
42
|
|
|
|
|
|
|
, os => 'POSIX::1003::OS' |
43
|
|
|
|
|
|
|
, opsys => 'POSIX::1003::OS' |
44
|
|
|
|
|
|
|
, pathconf => 'POSIX::1003::Pathconf' |
45
|
|
|
|
|
|
|
, pc => 'POSIX::1003::Pathconf' |
46
|
|
|
|
|
|
|
, processes => 'POSIX::1003::Proc' |
47
|
|
|
|
|
|
|
, proc => 'POSIX::1003::Proc' |
48
|
|
|
|
|
|
|
, properties => 'POSIX::1003::Properties' |
49
|
|
|
|
|
|
|
, property => 'POSIX::1003::Properties' |
50
|
|
|
|
|
|
|
, props => 'POSIX::1003::Properties' |
51
|
|
|
|
|
|
|
, posix => 'POSIX::1003::Properties' |
52
|
|
|
|
|
|
|
, sc => 'POSIX::1003::Sysconf' |
53
|
|
|
|
|
|
|
, sigaction => 'POSIX::SigAction' |
54
|
|
|
|
|
|
|
, signals => [qw/POSIX::1003::Signals POSIX::SigSet POSIX::SigAction/] |
55
|
|
|
|
|
|
|
, sigset => 'POSIX::SigSet' |
56
|
|
|
|
|
|
|
, socket => 'POSIX::1003::Socket' |
57
|
|
|
|
|
|
|
, sysconf => 'POSIX::1003::Sysconf' |
58
|
|
|
|
|
|
|
, termio => 'POSIX::1003::Termios' |
59
|
|
|
|
|
|
|
, termios => 'POSIX::1003::Termios' |
60
|
|
|
|
|
|
|
, time => 'POSIX::1003::Time' |
61
|
|
|
|
|
|
|
, user => 'POSIX::1003::User' |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my %mod_tag; |
65
|
|
|
|
|
|
|
while(my ($tag, $pkg) = each %tags) |
66
|
|
|
|
|
|
|
{ $pkg = $pkg->[0] if ref $pkg eq 'ARRAY'; |
67
|
|
|
|
|
|
|
$mod_tag{$pkg} = $tag |
68
|
|
|
|
|
|
|
if !$mod_tag{$pkg} |
69
|
|
|
|
|
|
|
|| length $mod_tag{$pkg} < length $tag; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
{ eval "require POSIX::1003::Symbols"; |
73
|
|
|
|
|
|
|
die $@ if $@; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
while(my ($pkg, $tag) = each %mod_tag) # unique modules |
77
|
|
|
|
|
|
|
{ $IMPORT_FROM{$_} = $tag for @{$EXPORT_TAGS{$tag}}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _tag2mods($) |
81
|
4
|
|
|
4
|
|
7
|
{ my $tag = shift; |
82
|
4
|
50
|
|
|
|
9
|
my $r = $tags{$tag} or croak "unknown tag '$tag'"; |
83
|
4
|
50
|
|
|
|
17
|
ref $r eq 'ARRAY' ? @$r : $r; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
0
|
|
0
|
sub _mod2tag($) { $mod_tag{$_[0]} } |
87
|
0
|
|
|
0
|
|
0
|
sub _tags() { keys %tags} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub import(@) |
90
|
4
|
|
|
4
|
|
21
|
{ my $class = shift; |
91
|
4
|
|
|
|
|
4
|
my (%mods, %modset, %from); |
92
|
|
|
|
|
|
|
|
93
|
4
|
50
|
33
|
|
|
17
|
my $level = @_ && $_[0] =~ /^\+(\d+)$/ ? shift : 0; |
94
|
4
|
100
|
66
|
|
|
40
|
return if @_==1 && $_[0] eq ':none'; |
95
|
3
|
50
|
|
|
|
4
|
@_ = ':all' if !@_; |
96
|
|
|
|
|
|
|
|
97
|
2
|
|
|
2
|
|
8
|
no strict 'refs'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
43
|
|
98
|
2
|
|
|
2
|
|
6
|
no warnings 'once'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1087
|
|
99
|
3
|
|
|
|
|
12
|
my $to = (caller $level)[0]; |
100
|
|
|
|
|
|
|
|
101
|
3
|
|
|
|
|
4
|
foreach (@_) |
102
|
3
|
50
|
|
|
|
10
|
{ if($_ eq ':all') |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
{ $mods{$_}++ for values %mod_tag; |
104
|
0
|
|
|
|
|
0
|
*{$to.'::'.$_} = \&$_ for keys %own_functions; |
|
0
|
|
|
|
|
0
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
elsif(m/^\:(.*)/) |
107
|
1
|
50
|
|
|
|
3
|
{ if(exists $tags{$1}) |
|
|
0
|
|
|
|
|
|
108
|
|
|
|
|
|
|
{ # module by longest alias |
109
|
1
|
|
|
|
|
1
|
$mods{$_}++ for map $mod_tag{$_}, _tag2mods $1; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
elsif(my $subset = $SUBSET{$1}) |
112
|
0
|
|
|
|
|
0
|
{ push @{$modset{$subset}}, $1; |
|
0
|
|
|
|
|
0
|
|
113
|
|
|
|
|
|
|
} |
114
|
0
|
|
|
|
|
0
|
else { croak "unknown tag '$_'" }; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
elsif($own_functions{$_}) |
117
|
1
|
|
|
|
|
2
|
{ *{$to.'::'.$_} = \&$_; |
|
1
|
|
|
|
|
5
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
else |
120
|
1
|
50
|
|
|
|
4
|
{ my $mod = $IMPORT_FROM{$_} or croak "unknown symbol '$_'"; |
121
|
1
|
|
|
|
|
0
|
push @{$from{$mod}}, $_; |
|
1
|
|
|
|
|
3
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# no need for separate symbols when we need all |
126
|
3
|
|
|
|
|
7
|
delete $from{$_} for keys %mods; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
#print "from $_ all\n" for keys %mods; |
129
|
|
|
|
|
|
|
#print "from $_ @{$from{$_}}\n" for keys %from; |
130
|
|
|
|
|
|
|
|
131
|
3
|
|
|
|
|
5
|
my $up = '+' . ($level+1); |
132
|
3
|
|
|
|
|
3
|
foreach my $tag (keys %mods) # whole tags |
133
|
1
|
|
|
|
|
21
|
{ delete $modset{$tag}; |
134
|
1
|
|
|
|
|
2
|
delete $from{$tag}; |
135
|
1
|
|
|
|
|
1
|
foreach my $pkg (_tag2mods($tag)) |
136
|
1
|
50
|
|
|
|
36
|
{ eval "require $pkg"; die $@ if $@; |
|
1
|
|
|
|
|
5
|
|
137
|
1
|
|
|
|
|
6
|
$pkg->import($up, ':all'); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
3
|
|
|
|
|
6
|
foreach my $tag (keys %modset) |
141
|
0
|
|
|
|
|
0
|
{ foreach my $pkg (_tag2mods($tag)) |
142
|
0
|
0
|
|
|
|
0
|
{ eval "require $pkg"; die $@ if $@; |
|
0
|
|
|
|
|
0
|
|
143
|
0
|
|
|
|
|
0
|
my @subsets = @{$modset{$tag}}; |
|
0
|
|
|
|
|
0
|
|
144
|
0
|
|
|
|
|
0
|
my $et = \%{"$pkg\::EXPORT_TAGS"}; |
|
0
|
|
|
|
|
0
|
|
145
|
0
|
|
|
|
|
0
|
$pkg->import($up, @{$et->{$_}}) |
146
|
0
|
|
|
|
|
0
|
for @subsets; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
} |
149
|
3
|
|
|
|
|
1357
|
foreach my $tag (keys %from) # separate symbols |
150
|
1
|
|
|
|
|
2
|
{ foreach my $pkg (_tag2mods($tag)) |
151
|
1
|
50
|
|
|
|
40
|
{ eval "require $pkg"; die $@ if $@; |
|
1
|
|
|
|
|
4
|
|
152
|
1
|
|
|
|
|
2
|
$pkg->import($up, @{$from{$tag}}); |
|
1
|
|
|
|
|
6
|
|
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub posix_1003_modules() |
159
|
1
|
|
|
1
|
1
|
2
|
{ my %mods; |
160
|
1
|
|
|
|
|
6
|
foreach my $mods (values %tags) |
161
|
36
|
100
|
|
|
|
72
|
{ $mods{$_}++ for ref $mods eq 'ARRAY' ? @$mods : $mods; |
162
|
|
|
|
|
|
|
} |
163
|
1
|
|
|
|
|
7
|
keys %mods; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub posix_1003_names(@) |
168
|
3
|
|
|
3
|
1
|
898
|
{ my %names; |
169
|
|
|
|
|
|
|
my @modules; |
170
|
3
|
100
|
|
|
|
7
|
if(@_) |
171
|
2
|
|
|
|
|
3
|
{ my %mods; |
172
|
2
|
|
|
|
|
3
|
foreach my $sel (@_) |
173
|
2
|
100
|
|
|
|
12
|
{ $mods{$_}++ for $sel =~ m/^:(\w+)/ ? _tag2mods($1) : $sel; |
174
|
|
|
|
|
|
|
} |
175
|
2
|
|
|
|
|
6
|
@modules = keys %mods; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
else |
178
|
1
|
|
|
|
|
3
|
{ @modules = posix_1003_modules; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
3
|
|
|
|
|
6
|
foreach my $pkg (@modules) |
182
|
23
|
|
|
|
|
843
|
{ eval "require $pkg"; |
183
|
23
|
50
|
|
|
|
72
|
$@ && next; # die? |
184
|
23
|
100
|
|
|
|
202
|
$pkg->can('import') or next; |
185
|
21
|
|
|
|
|
40
|
$pkg->import(':none'); # create %EXPORT_OK |
186
|
|
|
|
|
|
|
|
187
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
235
|
|
188
|
21
|
|
|
|
|
17
|
my $exports = \%{"${pkg}::EXPORT_OK"}; |
|
21
|
|
|
|
|
92
|
|
189
|
21
|
|
|
|
|
728
|
$names{$_} = $pkg for keys %$exports; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
3
|
50
|
|
|
|
354
|
wantarray ? keys %names : \%names; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub show_posix_names(@) |
197
|
0
|
|
|
0
|
1
|
|
{ my $pkg_of = posix_1003_names @_; |
198
|
0
|
|
|
|
|
|
my %order = map {(my $n = lc $_) =~ s/[^A-Za-z0-9]//g; ($n => $_)} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
keys %$pkg_of; # Swartzian transform |
200
|
|
|
|
|
|
|
|
201
|
2
|
|
|
2
|
|
8
|
no strict 'refs'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
286
|
|
202
|
0
|
|
|
|
|
|
foreach (sort keys %order) |
203
|
0
|
|
|
|
|
|
{ my $name = $order{$_}; |
204
|
0
|
|
|
|
|
|
my $pkg = $pkg_of->{$name}; |
205
|
0
|
|
|
|
|
|
$pkg->import($name); |
206
|
0
|
|
|
|
|
|
my $val = $pkg->exampleValue($name); |
207
|
0
|
|
|
|
|
|
(my $abbrev = $pkg) =~ s/^POSIX\:\:1003\:\:/::/; |
208
|
0
|
|
|
|
|
|
my $mod = $mod_tag{$pkg}; |
209
|
0
|
0
|
|
|
|
|
if(defined $val) |
210
|
0
|
|
|
|
|
|
{ printf "%-12s :%-10s %-30s %s\n", $abbrev, $mod, $name, $val; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
else |
213
|
0
|
|
|
|
|
|
{ printf "%-12s :%-10s %s\n", $abbrev, $mod, $name; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
} |
216
|
0
|
|
|
|
|
|
print "*** ".(keys %$pkg_of)." symbols in total\n"; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
#------------ |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
1; |