Re: [perl #55978] [PATCH] [OpenGL] cygwin fixes from donaldh++

2008-07-29 Thread Reini Urban

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/


Re: [perl #55978] [PATCH] [OpenGL] cygwin fixes from donaldh++

2008-06-18 Thread Geoffrey Broadwell
On Wed, 2008-06-18 at 09:06 -0700, chromatic wrote:
> On Tuesday 17 June 2008 21:06:58 Geoffrey Broadwell wrote:
> 
> >   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));
> 
> That string_from_cstring could almost probably be CONST_STRING.  If we can 
> swing that, it's usually much better.

OK, regenerated with this change.  Tested to not break on Linux, but
that's not saying much, given the #ifdef __CYGWIN__ 


-'f

Index: src/dynext.c
===
--- src/dynext.c	(revision 28514)
+++ src/dynext.c	(working copy)
@@ -276,12 +276,9 @@
 /* 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, CONST_STRING(interp, "cyg"),
+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)
Index: lib/Parrot/Configure/Step/Methods.pm
===
--- lib/Parrot/Configure/Step/Methods.pm	(revision 28514)
+++ 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'
Index: config/gen/opengl.pm
===
--- config/gen/opengl.pm	(revision 28514)
+++ config/gen/opengl.pm	(working copy)
@@ -410,6 +410,9 @@
 '/System/Library/Frameworks/OpenGL.framework/Headers/*.h',
 '/System/Library/Frameworks/GLUT.framework/Headers/*.h',
 
+# Cygwin
+'/usr/include/w32api/GL/*.h',
+
 # Windows/MSVC
 (map "$_/gl/*.h" => @include_paths_win32),
 
@@ -444,11 +447,19 @@
 # "$ENV{HOME}/src/osx-insane/usr/X11R6 1/include/GL/*.h",
 );
 
+print "\nChecking for OpenGL headers using the following globs:\n\t",
+join("\n\t", @header_globs), "\n"
+if $verbose;
+
 my @header_files = sort map {File::Glob::bsd_glob($_)} @header_globs;
 
 my %skip = map {($_ => 1)} @SKIP;
 @header_files = grep {my ($file) = m{([^/]+)$}; !$skip{$file}} @header_files;
 
+print "\nFound the following OpenGL headers:\n\t",
+join("\n\t", @header_files), "\n"
+if $verbose;
+
 die "OpenGL enabled and detected, but no OpenGL headers found!"
 unless @header_files;
 


Re: [perl #55978] [PATCH] [OpenGL] cygwin fixes from donaldh++

2008-06-18 Thread chromatic
On Tuesday 17 June 2008 21:06:58 Geoffrey Broadwell wrote:

>   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));

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

-- c