From: Andreas König Date: Tue, 29 Nov 2005 08:07:19 +0000 (+0100) Subject: Re: [perl #37716] Re: File::Compare broken for filenames with whitespace X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d569369663d5f1104f258f47a91ede9f4feb155e;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #37716] Re: File::Compare broken for filenames with whitespace Message-ID: <878xv89bko.fsf@k75.linux.bogus> p4raw-id: //depot/perl@26225 --- diff --git a/lib/File/Compare.pm b/lib/File/Compare.pm index bcc996e..7418fe6 100644 --- a/lib/File/Compare.pm +++ b/lib/File/Compare.pm @@ -7,7 +7,7 @@ our($VERSION, @ISA, @EXPORT, @EXPORT_OK, $Too_Big); require Exporter; -$VERSION = '1.1004'; +$VERSION = '1.1005'; @ISA = qw(Exporter); @EXPORT = qw(compare); @EXPORT_OK = qw(cmp compare_text); @@ -38,7 +38,7 @@ sub compare { } elsif (ref(\$from) eq 'GLOB') { *FROM = $from; } else { - open(FROM,"<$from") or goto fail_open1; + open(FROM,"<",$from) or goto fail_open1; unless ($text_mode) { binmode FROM; $fromsize = -s FROM; @@ -52,7 +52,7 @@ sub compare { } elsif (ref(\$to) eq 'GLOB') { *TO = $to; } else { - open(TO,"<$to") or goto fail_open2; + open(TO,"<",$to) or goto fail_open2; binmode TO unless $text_mode; $closeto = 1; } diff --git a/lib/File/Compare.t b/lib/File/Compare.t index aedc323..c52d873 100644 --- a/lib/File/Compare.t +++ b/lib/File/Compare.t @@ -14,7 +14,7 @@ BEGIN { } } -print "1..12\n"; +print "1..13\n"; use File::Compare qw(compare compare_text); @@ -78,6 +78,8 @@ eval { my $template = File::Spec->catfile(File::Spec->tmpdir, 'fcmpXXXX'); my($tfh,$filename) = mkstemp($template); + open my $tfhCR, ">", "$filename\cM" + or die "Could no open '$filename^M' for writing: $!"; { local $/; #slurp my $fh; @@ -86,29 +88,35 @@ eval { my $data = <$fh>; print $tfh $data; close($fh); + print $tfhCR $data; + close($tfhCR); } seek($tfh,0,0); $donetests[0] = compare($tfh, 'README'); $donetests[1] = compare($filename, 'README'); unlink0($tfh,$filename); + $donetests[2] = compare('README', "$filename\cM"); + unlink "$filename\cM"; }; -print "# problems when testing with a tempory file\n" if $@; +print "# problem '$@' when testing with a temporary file\n" if $@; -if (@donetests == 2) { +if (@donetests == 3) { print "not " unless $donetests[0] == 0; - print "ok 11\n"; + print "ok 11 # fh/file [$donetests[0]]\n"; if ($^O eq 'VMS') { # The open attempt on FROM in File::Compare::compare should fail # on this OS since files are not shared by default. print "not " unless $donetests[1] == -1; - print "ok 12\n"; + print "ok 12 # file/file [$donetests[1]]\n"; } else { print "not " unless $donetests[1] == 0; - print "ok 12\n"; + print "ok 12 # file/file [$donetests[1]]\n"; } + print "not " unless $donetests[2] == 0; + print "ok 13 # file/fileCR [$donetests[2]]\n"; } else { - print "ok 11# Skip\nok 12 # Skip Likely due to File::Temp\n"; + print "ok 11# Skip\nok 12 # Skip\nok 13 # Skip Likely due to File::Temp\n"; }