add patch preextend global string table, tweak for 512 entries
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / Liblist.pm
index 5c35dc7..5388641 100644 (file)
@@ -182,6 +182,9 @@ sub _unix_os2_ext {
 }
 
 sub _win32_ext {
+
+    require Text::ParseWords;
+
     my($self, $potential_libs, $verbose) = @_;
 
     # If user did not supply a list, we punt.
@@ -203,17 +206,21 @@ sub _win32_ext {
     }
     warn "Potential libraries are '$potential_libs':\n" if $verbose;
 
+    # normalize to forward slashes
+    $libpth =~ s,\\,/,g;
+    $potential_libs =~ s,\\,/,g;
+
     # compute $extralibs from $potential_libs
 
     my(@searchpath); # from "-L/path" entries in $potential_libs
-    my(@libpath) = split " ", $libpth;
+    my(@libpath) = Text::ParseWords::quotewords('\s+', 0, $libpth);
     my(@extralibs);
     my($fullname, $thislib, $thispth);
     my($pwd) = cwd(); # from Cwd.pm
     my($lib) = '';
     my($found) = 0;
 
-    foreach $thislib (split ' ', $potential_libs){
+    foreach $thislib (Text::ParseWords::quotewords('\s+', 0, $potential_libs)){
 
        # Handle possible linker path arguments.
        if ($thislib =~ s/^-L// and not -d $thislib) {
@@ -223,7 +230,7 @@ sub _win32_ext {
        }
        elsif (-d $thislib) {
            unless ($self->file_name_is_absolute($thislib)) {
-             warn "Warning: -L$thislib changed to -L$pwd/$thislib\n";
+             warn "Warning: '-L$thislib' changed to '-L$pwd/$thislib'\n";
              $thislib = $self->catdir($pwd,$thislib);
            }
            push(@searchpath, $thislib);
@@ -253,6 +260,9 @@ sub _win32_ext {
            unless $found_lib>0;
     }
     return ('','','','') unless $found;
+
+    # make sure paths with spaces are properly quoted
+    @extralibs = map { (/\s/ && !/^".*"$/) ? qq["$_"] : $_ } @extralibs;
     $lib = join(' ',@extralibs);
     warn "Result: $lib\n" if $verbose;
     wantarray ? ($lib, '', $lib, '') : $lib;
@@ -595,6 +605,17 @@ distinguish between them.
 LDLOADLIBS and EXTRALIBS are always identical under Win32, and BSLOADLIBS
 and LD_RUN_PATH are always empty (this may change in future).
 
+=item *
+
+You must make sure that any paths and path components are properly
+surrounded with double-quotes if they contain spaces. For example,
+C<$potential_libs> could be (literally):
+
+       "-Lc:\Program Files\vc\lib" msvcrt.lib "la test\foo bar.lib"
+
+Note how the first and last entries are protected by quotes in order
+to protect the spaces.
+
 =back