develooper Front page | perl.perl5.porters | Postings from December 2003

Re: [PATCH] Re: perl @ 21830

Thread Previous | Thread Next
From:
Steve Hay
Date:
December 4, 2003 03:00
Subject:
Re: [PATCH] Re: perl @ 21830
Message ID:
3FCF143E.1040905@uk.radan.com
Rafael Garcia-Suarez wrote:

>Steve Hay wrote:
>  
>
>>That's wrong -- config.h.new and ../lib/CORE/config.h are certainly not 
>>identical, it's just that File::Copy thinks they are since change 
>>21797.  This patch fixes it:
>>
>>=====
>>--- lib\File\Copy.pm.orig    2003-11-30 11:36:00.000000000 +0000
>>+++ lib\File\Copy.pm    2003-12-03 10:24:05.524700100 +0000
>>@@ -78,7 +78,7 @@
>>     }
>> 
>>     if ((($Config{d_symlink} && $Config{d_readlink}) || $Config{d_link}) &&
>>-    !($^O eq 'Win32' || $^O eq 'os2' || $^O eq 'vms')) {
>>+    !($^O eq 'MSWin32' || $^O eq 'os2' || $^O eq 'vms')) {
>>    
>>
>
>Good catch.
>
>  
>
>>     my @fs = stat($from);
>>     if (@fs) {
>>         my @ts = stat($to);
>>=====
>>
>>However, the testsuite fails lib/File/Copy.t tests 14 and 28.  These 
>>relate to hard links.  The tests would be skipped if $Config{d_link} 
>>isn't true, but it is:
>>
>>C:\Temp\perl-21830\t>perl -I..\lib -V:d_link
>>d_link='define';
>>
>>But Copy.pm will never emit the "are identical" error that Copy.t is 
>>expecting because the error is emitted within the "if" block in the 
>>patch above, the conditional of which is always false on MSWin32.  Is it 
>>the module or the test that is wrong?
>>    
>>
>
>Depends. How can we test if two files are identical, link()-wise,
>on MSWin32 ? If we can test it, we should fix Copy.pm by adding
>another branch to the if() :
>    elsif ($^O eq 'MSWin32' && $Config{d_link}) {...}
>If we can't, we should fix the test so it's skipped on Windows.
>
I can't think of any way to test it.  File::Copy uses the inode on other 
platforms to test hardlinks, but this is always returned as 1 on 
MSWin32.  The Microsoft documentation for stat() notes: "The inode, and 
therefore st_ino, has no meaning in the FAT, HPFS, or NTFS file systems."

So it's probably best to skip the test on MSWin32.  Here's a patch for that:

=====
--- Copy.t.orig    2003-12-03 10:53:11.209881400 +0000
+++ Copy.t    2003-12-04 10:43:50.721987100 +0000
@@ -164,15 +164,19 @@
   }
 
   if ($Config{d_link}) {
-    open(F, ">file-$$") or die $!;
-    print F "dummy content\n";
-    close F;
-    link("file-$$", "hardlink-$$") or die $!;
-    eval { copy("file-$$", "hardlink-$$") };
-    print "not " if $@ !~ /are identical/ || -z "file-$$";
-    printf "ok %d\n", (++$test_i)+$loopconst;
-    unlink "hardlink-$$";
-    unlink "file-$$";
+    if ($^O ne 'MSWin32') {
+      open(F, ">file-$$") or die $!;
+      print F "dummy content\n";
+      close F;
+      link("file-$$", "hardlink-$$") or die $!;
+      eval { copy("file-$$", "hardlink-$$") };
+      print "not " if $@ !~ /are identical/ || -z "file-$$";
+      printf "ok %d\n", (++$test_i)+$loopconst;
+      unlink "hardlink-$$";
+      unlink "file-$$";
+    } else {
+      printf "ok %d # Skipped: can't test hardlinks on MSWin32\n", 
(++$test_i)+$loopconst;
+    }
   } else {
     printf "ok %d # Skipped: no hardlinks on this platform\n", 
(++$test_i)+$loopconst;
   }
=====

Together with the earlier patch (at the head of this mail) for Copy.pm 
itself, this gets things working again on Windows.

- Steve



------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only.  If you have received this message in error or there are any problems, please notify the sender immediately.  The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden.  Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd.  The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About