contrib/buildsystems: handle quoted spaces in filenames

The engine.pl script expects file names not to contain spaces. However, paths with spaces are quite prevalent on Windows. Use shellwords() rather than split() to parse them correctly. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Philip Oakley <philipoakley@iee.org> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Philip Oakley committed Jul 29, 2019 at 13:08 UTC d8c07013b93496fff8e16b75560a22aa44da1625
1 file changed +4 -3
contrib/buildsystems/engine.pl
+4 -3
@@ -12,6 +12,7 @@ use File::Basename;
12 use File::Spec;
13 use Cwd;
14 use Generators;
15 +use Text::ParseWords;
16
17 my (%build_structure, %compile_options, @makedry);
18 my $out_dir = getcwd();
@@ -231,7 +232,7 @@ sub removeDuplicates
232 sub handleCompileLine
233 {
234 my ($line, $lineno) = @_;
234 - my @parts = split(' ', $line);
235 + my @parts = shellwords($line);
236 my $sourcefile;
237 shift(@parts); # ignore cmd
238 while (my $part = shift @parts) {
@@ -265,7 +266,7 @@ sub handleLibLine
266 my (@objfiles, @lflags, $libout, $part);
267 # kill cmd and rm 'prefix'
268 $line =~ s/^rm -f .* && .* rcs //;
268 - my @parts = split(' ', $line);
269 + my @parts = shellwords($line);
270 while ($part = shift @parts) {
271 if ($part =~ /^-/) {
272 push(@lflags, $part);
@@ -306,7 +307,7 @@ sub handleLinkLine
307 {
308 my ($line, $lineno) = @_;
309 my (@objfiles, @lflags, @libs, $appout, $part);
309 - my @parts = split(' ', $line);
310 + my @parts = shellwords($line);
311 shift(@parts); # ignore cmd
312 while ($part = shift @parts) {
313 if ($part =~ /^-IGNORE/) {