# New Ticket Created by  Mike Mattie 
# Please include the string:  [perl #41889]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41889 >


Hello,

While mucking around in src/library.c I noticed some cut & paste duplication. 
It looked like a fairly simple hoist
so I have attached the changes I made.

I do not have a win32 platform available for testing so I haven't been able to 
compile test it.

    while ( (cnv = strchr(path->strstart, '/')) )
        *cnv = '\\';

this looks totally broken. unless path->strstart is a stateful iterator this 
will only
convert the first instance of a '/' character.

I think it should look like this:

    cnv = path->strstart;
    while ( (cnv = strchr(cnv, '/')) ) {
        *cnv = '\\';
        ++cnv;      
    }

I am not sure though because I can't imagine how parrot would pass any part of 
the win32 test suite with
this kind of a bug.

Note that the version I considered broken is in the patch. If I am wrong about 
the bug then the
hoisted code doesn't have to be reverted to the old form.

Cheers,
Mike Mattie ([EMAIL PROTECTED])


diff -U3 -aur parrot-0.4.9/src/library.c parrot-0.4.9.mine/src/library.c
--- parrot-0.4.9/src/library.c	2007-02-22 05:40:37.000000000 -0800
+++ parrot-0.4.9.mine/src/library.c	2007-03-18 03:59:29.000000000 -0700
@@ -160,6 +160,23 @@
     return 0;
 }
 
+
+#ifdef WIN32
+
+static void
+cnv_to_win32_filesep ( STRING *path ) {
+    
+    assert(path->encoding == Parrot_fixed_8_encoding_ptr ||
+	    path->encoding == Parrot_utf8_encoding_ptr);
+
+    char* cnv;
+    
+    while ( (cnv = strchr(path->strstart, '/')) )
+	*cnv = '\\';
+}
+
+#endif
+
 /*
 
 =item C<char* Parrot_locate_runtime_file(Interp *, const char *file_name,
@@ -235,15 +252,11 @@
         full_name = string_append(interp, full_name, nul);
         full_name->bufused--;
         full_name->strlen--;
+
 #ifdef WIN32
-        {
-            char *p;
-            assert(full_name->encoding == Parrot_fixed_8_encoding_ptr ||
-                   full_name->encoding == Parrot_utf8_encoding_ptr);
-            while ( (p = strchr(full_name->strstart, '/')) )
-                *p = '\\';
-        }
+	cnv_to_win32_filesep( full_name );
 #endif
+
         if (Parrot_stat_info_intval(interp, full_name, STAT_EXISTS)) {
             return full_name;
         }
@@ -252,15 +265,11 @@
     full_name = string_append(interp, file, nul);
     full_name->bufused--;
     full_name->strlen--;
+
 #ifdef WIN32
-    {
-        char *p;
-        assert(full_name->encoding == Parrot_fixed_8_encoding_ptr ||
-                full_name->encoding == Parrot_utf8_encoding_ptr);
-        while ( (p = strchr(full_name->strstart, '/')) )
-            *p = '\\';
-    }
+    cnv_to_win32_filesep( full_name );
 #endif
+
     if (Parrot_stat_info_intval(interp, full_name, STAT_EXISTS)) {
         return full_name;
     }

Attachment: signature.asc
Description: PGP signature

Reply via email to