Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit938d797

Browse files
committed
Avoid odd portability problem in TestLib.pm's slurp_file function.
For unclear reasons, this function doesn't always read the expected datain some old Perl versions. Rewriting it to avoid use of ARGV seems tododge the problem, and this version is clearer anyway if you ask me.In passing, also improve error message in adjacent append_to_file function.
1 parentd5563d7 commit938d797

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

‎src/test/perl/TestLib.pm

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,21 @@ sub slurp_dir
158158

159159
subslurp_file
160160
{
161+
my ($filename) =@_;
161162
local$/;
162-
local@ARGV =@_;
163-
my$contents = <>;
163+
open(my$in,'<',$filename)
164+
ordie"could not read\"$filename\":$!";
165+
my$contents = <$in>;
166+
close$in;
164167
$contents =~s/\r//gif$Config{osname}eq'msys';
165168
return$contents;
166169
}
167170

168171
subappend_to_file
169172
{
170173
my ($filename,$str) =@_;
171-
172-
openmy$fh,">>",$filenameordie"could notopen\"$filename\":$!";
174+
openmy$fh,">>",$filename
175+
ordie"could notwrite\"$filename\":$!";
173176
print$fh$str;
174177
close$fh;
175178
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp