Skip to content

Commit d21fe26

Browse files
mohawk2bingos
authored andcommitted
unix test, support -L with spaces
1 parent b779abf commit d21fe26

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/ExtUtils/Liblist/Kid.pm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ sub _unix_os2_ext {
4949
# $potential_libs
5050
# this is a rewrite of Andy Dougherty's extliblist in perl
5151

52+
require Text::ParseWords;
53+
5254
my ( @searchpath ); # from "-L/path" entries in $potential_libs
53-
my ( @libpath ) = split " ", $Config{'libpth'} || '';
55+
my ( @libpath ) = Text::ParseWords::quotewords( '\s+', 0, $Config{'libpth'} || '' );
5456
my ( @ldloadlibs, @bsloadlibs, @extralibs, @ld_run_path, %ld_run_path_seen );
5557
my ( @libs, %libs_seen );
5658
my ( $fullname, @fullname );
@@ -63,7 +65,7 @@ sub _unix_os2_ext {
6365
$potential_libs =~ s/(^|\s)(-F)\s*(\S+)/$1-Wl,$2 -Wl,$3/g;
6466
}
6567

66-
foreach my $thislib ( split ' ', $potential_libs ) {
68+
foreach my $thislib ( Text::ParseWords::quotewords( '\s+', 0, $potential_libs) ) {
6769
my ( $custom_name ) = '';
6870

6971
# Handle possible linker path arguments.
@@ -88,6 +90,7 @@ sub _unix_os2_ext {
8890
$thislib = $self->catdir( $pwd, $thislib );
8991
}
9092
push( @searchpath, $thislib );
93+
$thislib = qq{"$thislib"} if $thislib =~ / /; # protect spaces if there
9194
push( @extralibs, "$ptype$thislib" );
9295
push( @ldloadlibs, "$rtype$thislib" );
9396
next;

t/Liblist_Kid.t

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ sub move_to_os_test_data_dir {
9393
},
9494
unix_os2 => {
9595
"libfoo.$Config{so}" => '',
96+
"di r/libdir_test.$Config{so}" => '',
9697
},
9798
);
9899
$cwd = getcwd; END { chdir $cwd } # so File::Temp can cleanup
@@ -131,6 +132,9 @@ sub test_kid_unix_os2 {
131132
like( $out[2], $qlibre, 'existing file results in quotes ldloadlibs' );
132133
ok $out[3], 'existing file results in true LD_RUN_PATH';
133134
is_deeply [ _ext( '-L. -lnotthere' ) ], [ ('') x 4 ], 'non-present lib = empty';
135+
my $curr_dirspace = File::Spec->rel2abs( 'di r' );
136+
my $cmd_frag = '-L'.quote($curr_dirspace) . ' -ldir_test';
137+
is_deeply [ _ext( '-L"di r" -ldir_test' ) ], [ $cmd_frag, '', $cmd_frag, $curr_dirspace ], '-L directories with spaces work';
134138
}
135139

136140
sub test_kid_win32 {

0 commit comments

Comments
 (0)