Just found someone breaking my code...

Index: src/dynext.c
===================================================================
--- src/dynext.c        (revision 28459)
+++ src/dynext.c        (working copy)
@@ -276,12 +276,10 @@
     /* And on cygwin replace a leading "lib" by "cyg". */
 #ifdef __CYGWIN__
     if (!STRING_IS_EMPTY(lib) && memcmp(lib->strstart, "lib", 3) == 0) {
-        strcpy(path->strstart, lib->strstart);
+        path = string_append(interp,
+            string_from_cstring(interp, "cyg", 3),
+            string_substr(interp, lib, 3, lib->strlen - 3, NULL, 0));

-        path->strstart[0] = 'c';
-        path->strstart[1] = 'y';
-        path->strstart[2] = 'g';
-
         *handle           = Parrot_dlopen(path->strstart);

         if (*handle)

That string_from_cstring could almost probably be CONST_STRING. If we can swing that, it's usually much better.

I wrote this heavily optimized code which was now patched away with an inferior solution. Is it because of possible multibyte char paths? Then it would be better indeed. But without mb-path support I see no advantage.

The patch for the next file:
--- lib/Parrot/Configure/Step/Methods.pm        (revision 28459)
+++ lib/Parrot/Configure/Step/Methods.pm        (working copy)
@@ -198,7 +198,8 @@
     my $args = shift;
     croak "_add_to_libs() takes hashref: $!" unless ref($args) eq 'HASH';
     my $platform =
-          ($args->{osname} =~ /mswin32/i &&
+          (($args->{osname} =~ /mswin32/i ||
+           $args->{osname} =~ /cygwin/i) &&
            $args->{cc} =~ /^gcc/i)          ? 'win32_gcc'
         :  $args->{osname} =~ /mswin32/i    ? 'win32_nongcc'
         :  $args->{osname} =~ /darwin/i     ? 'darwin'

This also caused me headaches. cygwin is definitely more posix than win32_gcc. OpenGL is the only case where it's more like mingw (win32_gcc). But this should be done in the opengl logic then, and not in this general case here.

--
Reini Urban
http://phpwiki.org/  http://murbreak.at/

Reply via email to