1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
doio.c
Can't open bidirectional pipe [Perl_do_open9]
open(F, "| true |");
Missing command in piped open [Perl_do_open9]
open(F, "| ");
Missing command in piped open [Perl_do_open9]
open(F, " |");
warn(warn_nl, "open"); [Perl_do_open9]
open(F, "true\ncd")
close() on unopened filehandle %s [Perl_do_close]
$a = "fred";close("$a")
tell() on closed filehandle [Perl_do_tell]
$a = "fred";$a = tell($a)
seek() on closed filehandle [Perl_do_seek]
$a = "fred";$a = seek($a,1,1)
sysseek() on closed filehandle [Perl_do_sysseek]
$a = "fred";$a = seek($a,1,1)
warn(warn_uninit); [Perl_do_print]
print $a ;
-x on closed filehandle %s [Perl_my_stat]
close STDIN ; -x STDIN ;
warn(warn_nl, "stat"); [Perl_my_stat]
stat "ab\ncd"
warn(warn_nl, "lstat"); [Perl_my_lstat]
lstat "ab\ncd"
Use of -l on filehandle %s [Perl_my_lstat]
Can't exec \"%s\": %s [Perl_do_aexec5]
Can't exec \"%s\": %s [Perl_do_exec3]
Filehandle %s opened only for output [Perl_do_eof]
my $a = eof STDOUT
Mandatory Warnings ALL TODO
------------------
Can't do inplace edit: %s is not a regular file [Perl_nextargv]
edit a directory
Can't do inplace edit: %s would not be unique [Perl_nextargv]
Can't rename %s to %s: %s, skipping file [Perl_nextargv]
Can't rename %s to %s: %s, skipping file [Perl_nextargv]
Can't remove %s: %s, skipping file [Perl_nextargv]
Can't do inplace edit on %s: %s [Perl_nextargv]
__END__
# doio.c [Perl_do_open9]
use warnings 'io' ;
open(F, '|'."$^X -e 1|");
close(F);
no warnings 'io' ;
open(G, '|'."$^X -e 1|");
close(G);
EXPECT
Can't open bidirectional pipe at - line 3.
########
# doio.c [Perl_do_open9]
use warnings 'io' ;
open(F, "| ");
no warnings 'io' ;
open(G, "| ");
EXPECT
Missing command in piped open at - line 3.
########
# doio.c [Perl_do_open9]
use warnings 'io' ;
open(F, " |");
no warnings 'io' ;
open(G, " |");
EXPECT
Missing command in piped open at - line 3.
########
# doio.c [Perl_do_open9]
use warnings 'io' ;
open(F, "<true\ncd");
open(G, "<truecd\n");
open(H, "<truecd\n\0");
no warnings 'io' ;
open(H, "<true\ncd");
open(I, "<truecd\n");
open(I, "<truecd\n\0");
EXPECT
Unsuccessful open on filename containing newline at - line 4.
Unsuccessful open on filename containing newline at - line 5.
########
# doio.c [Perl_do_close] <<TODO
use warnings 'unopened' ;
close "fred" ;
no warnings 'unopened' ;
close "joe" ;
EXPECT
close() on unopened filehandle fred at - line 3.
########
# doio.c [Perl_do_tell Perl_do_seek Perl_do_sysseek Perl_my_stat]
use warnings 'io' ;
close STDIN ;
tell(STDIN);
$a = seek(STDIN,1,1);
$a = sysseek(STDIN,1,1);
-x STDIN ;
stat(STDIN) ;
$a = "fred";
tell($a);
seek($a,1,1);
sysseek($a,1,1);
-x $a; # ok
stat($a); # ok
no warnings 'io' ;
close STDIN ;
tell(STDIN);
$a = seek(STDIN,1,1);
$a = sysseek(STDIN,1,1);
-x STDIN ;
stat(STDIN) ;
$a = "fred";
tell($a);
seek($a,1,1);
sysseek($a,1,1);
-x $a;
stat($a);
EXPECT
tell() on closed filehandle STDIN at - line 4.
seek() on closed filehandle STDIN at - line 5.
sysseek() on closed filehandle STDIN at - line 6.
-x on closed filehandle STDIN at - line 7.
stat() on closed filehandle STDIN at - line 8.
tell() on unopened filehandle at - line 10.
seek() on unopened filehandle at - line 11.
sysseek() on unopened filehandle at - line 12.
########
# doio.c [Perl_do_print]
use warnings 'uninitialized' ;
print $a ;
no warnings 'uninitialized' ;
print $b ;
EXPECT
Use of uninitialized value $a in print at - line 3.
########
# doio.c [Perl_my_stat Perl_my_lstat]
use warnings 'io' ;
stat "ab\ncd";
lstat "ab\ncd";
stat "abcd\n";
lstat "abcd\n";
stat "abcd\n\0";
lstat "abcd\n\0";
no warnings 'io' ;
stat "ab\ncd";
lstat "ab\ncd";
stat "abcd\n";
lstat "abcd\n";
stat "abcd\n\0";
lstat "abcd\n\0";
EXPECT
Unsuccessful stat on filename containing newline at - line 5.
Unsuccessful stat on filename containing newline at - line 6.
Unsuccessful stat on filename containing newline at - line 7.
Unsuccessful stat on filename containing newline at - line 8.
########
# doio.c [Perl_my_stat]
use warnings 'io';
-l STDIN;
-l $fh;
open $fh, $0 or die "# $!";
-l $fh;
no warnings 'io';
-l STDIN;
-l $fh;
close $fh;
EXPECT
Use of -l on filehandle STDIN at - line 3.
Use of -l on filehandle $fh at - line 6.
########
# doio.c [Perl_my_stat]
use utf8;
use open qw( :utf8 :std );
use warnings 'io';
-l ᶠᚻ;
no warnings 'io';
-l ᶠᚻ;
EXPECT
Use of -l on filehandle ᶠᚻ at - line 5.
########
# doio.c [Perl_do_aexec5]
use warnings 'io' ;
exec "lskdjfalksdjfdjfkls","" ;
no warnings 'io' ;
exec "lskdjfalksdjfdjfkls","" ;
EXPECT
OPTION regex
Statement unlikely to be reached at - line .+
\(Maybe you meant system\(\) when you said exec\(\)\?\)
Can't exec "lskdjfalksdjfdjfkls": .+
########
# doio.c [Perl_do_exec3]
use warnings 'io' ;
exec "lskdjfalksdjfdjfkls", "abc" ;
no warnings 'io' ;
exec "lskdjfalksdjfdjfkls", "abc" ;
EXPECT
OPTION regex
Statement unlikely to be reached at - line .+
\(Maybe you meant system\(\) when you said exec\(\)\?\)
Can't exec "lskdjfalksdjfdjfkls(:? abc)?": .+
########
# doio.c [win32_execvp]
use warnings 'exec' ;
exec $^X, "-e0" ;
EXPECT
########
# doio.c [Perl_nextargv]
$^W = 0 ;
# These happen to warn at different points within doio.c
# This will open read only, and then be caught by an explicit check:
my $filename = "./temp.dir" ;
# Whereas these two will fail to open:
my $dir0 = "./zero.dir" ;
# but files and directories have a different error message if they don't open:
my $file3 = "date|" ;
mkdir $filename, 0777
or die "Cannot create directory $filename: $!\n" ;
mkdir $dir0, 0
or die "Cannot create directory dir0: $!\n" ;
{
local (@ARGV) = ($filename, $dir0, $file3) ;
local ($^I) = "" ;
my $x = <> ;
}
{
no warnings 'inplace' ;
local (@ARGV) = ($filename, $dir0, $file3) ;
local ($^I) = "" ;
my $x = <> ;
}
{
use warnings 'inplace' ;
local (@ARGV) = ($filename, $dir0, $file3) ;
local ($^I) = "" ;
my $x = <> ;
}
rmdir $filename ;
chmod 0777, $dir0 ;
rmdir $dir0 ;
EXPECT
OPTION regex
Can't do inplace edit: \./temp\.dir is not a regular file at - line 17\.
Can't do inplace edit: \./zero\.dir is not a regular file at - line 17\.
Can't open date\|: .*? at - line 17\.
Can't do inplace edit: \./temp\.dir is not a regular file at - line 29\.
Can't do inplace edit: \./zero\.dir is not a regular file at - line 29\.
Can't open date\|: .*? at - line 29\.
########
# doio.c [Perl_do_eof]
use warnings 'io' ;
my $a = eof STDOUT ;
no warnings 'io' ;
$a = eof STDOUT ;
EXPECT
Filehandle STDOUT opened only for output at - line 3.
########
# doio.c [Perl_do_openn]
use Config;
BEGIN {
if ($Config{useperlio}) {
print <<EOM;
SKIPPED
# warns only without perlio
EOM
exit;
}
}
use warnings 'io';
my $x = "foo";
open FOO, '>', \$x;
open BAR, '>&', \*STDOUT; # should not warn
no warnings 'io';
open FOO, '>', \$x;
EXPECT
Can't open a reference at - line 14.
########
# doio.c [Perl_do_openn]
use Config;
BEGIN {
if (!$Config{useperlio}) {
print <<EOM;
SKIPPED
# warns only with perlio
EOM
exit;
}
}
use warnings 'io' ;
close STDOUT;
open FH1, "../harness"; close FH1;
no warnings 'io' ;
open FH2, "../harness"; close FH2;
EXPECT
Filehandle STDOUT reopened as FH1 only for input at - line 14.
########
# doio.c [Perl_do_openn]
use Config;
use utf8;
use open qw( :utf8 :std );
BEGIN {
if (!$Config{useperlio}) {
print <<EOM;
SKIPPED
# warns only with perlio
EOM
exit;
}
}
use warnings 'io' ;
close STDOUT;
open ᶠᚻ1, "../harness"; close ᶠᚻ1;
no warnings 'io' ;
open ᶠᚻ2, "../harness"; close ᶠᚻ2;
EXPECT
Filehandle STDOUT reopened as ᶠᚻ1 only for input at - line 16.
########
# doio.c [Perl_do_openn]
use Config;
BEGIN {
if (!$Config{useperlio}) {
print <<EOM;
SKIPPED
# warns only with perlio
EOM
exit;
}
}
use warnings 'io' ;
close STDIN;
open my $fh1, ">doiowarn.tmp"; close $fh1;
no warnings 'io' ;
open my $fh2, ">doiowarn.tmp"; close $fh2;
unlink "doiowarn.tmp";
EXPECT
Filehandle STDIN reopened as $fh1 only for output at - line 14.
########
# doio.c [Perl_do_openn]
use Config;
use utf8;
use open qw( :utf8 :std );
BEGIN {
if (!$Config{useperlio}) {
print <<EOM;
SKIPPED
# warns only with perlio
EOM
exit;
}
}
use warnings 'io' ;
close STDIN;
open my $ᶠᚻ1, ">doiowarn.tmp"; close $ᶠᚻ1;
no warnings 'io' ;
open my $ᶠᚻ2, ">doiowarn.tmp"; close $ᶠᚻ2;
unlink "doiowarn.tmp";
EXPECT
Filehandle STDIN reopened as $ᶠᚻ1 only for output at - line 16.
########
# doio.c [Perl_do_openn]
use Config;
use utf8;
use open qw( :utf8 :std );
BEGIN {
if (!$Config{useperlio}) {
print <<EOM;
SKIPPED
# warns only with perlio
EOM
exit;
}
}
use warnings 'io' ;
close STDIN;
open ᶠᚻ1, ">doiowarn.tmp"; close ᶠᚻ1;
no warnings 'io' ;
open ᶠᚻ2, ">doiowarn.tmp"; close ᶠᚻ2;
unlink "doiowarn.tmp";
EXPECT
Filehandle STDIN reopened as ᶠᚻ1 only for output at - line 16.
########
open(my $i, "foo\0bar");
use warnings 'io';
open(my $i, "foo\0bar");
EXPECT
Invalid \0 character in pathname for open: foo\0bar at - line 3.
########
chmod(0, "foo\0bar");
use warnings 'io';
chmod(0, "foo\0bar");
EXPECT
Invalid \0 character in pathname for chmod: foo\0bar at - line 3.
########
unlink("foo\0bar", "foo\0bar2");
use warnings 'io';
unlink("foo\0bar", "foo\0bar2");
EXPECT
Invalid \0 character in pathname for unlink: foo\0bar at - line 3.
Invalid \0 character in pathname for unlink: foo\0bar2 at - line 3.
########
utime(-1, -1, "foo\0bar", "foo\0bar2");
use warnings 'io';
utime(-1, -1, "foo\0bar", "foo\0bar2");
EXPECT
Invalid \0 character in pathname for utime: foo\0bar at - line 3.
Invalid \0 character in pathname for utime: foo\0bar2 at - line 3.
########
my @foo = glob "foo\0bar";
use warnings 'io';
my @bar = glob "foo\0bar";
EXPECT
Invalid \0 character in pattern for glob: foo\0bar at - line 3.
|