From: <bru...@us...> - 2009-11-01 23:07:02
|
Revision: 1123 http://panotools.svn.sourceforge.net/panotools/?rev=1123&view=rev Author: brunopostle Date: 2009-11-01 23:06:49 +0000 (Sun, 01 Nov 2009) Log Message: ----------- Some more Makefile rule fixes Modified Paths: -------------- trunk/Panotools-Script/lib/Panotools/Makefile/Rule.pm trunk/Panotools-Script/t/101.makerule.t Modified: trunk/Panotools-Script/lib/Panotools/Makefile/Rule.pm =================================================================== --- trunk/Panotools-Script/lib/Panotools/Makefile/Rule.pm 2009-10-31 22:40:23 UTC (rev 1122) +++ trunk/Panotools-Script/lib/Panotools/Makefile/Rule.pm 2009-11-01 23:06:49 UTC (rev 1123) @@ -53,7 +53,7 @@ { my $self = shift; push @{$self->{targets}}, @_; - die 'Error: unescapable =;:$ in targets: '. join (' ', @_) if grep /[=;:\$]/, @_; + warn 'Error: unescapable =;: in targets: '. join (' ', @_) if grep /[=;:]/, @_; #warn 'Warning: non-portable target name: '. join (' ', @_) if grep /[?<>:*|"^]/, @_; } @@ -75,13 +75,13 @@ { my $self = shift; push @{$self->{prerequisites}}, @_; - die 'Error: unescapable =;:$ in prerequisites: '. join (' ', @_) if grep /[=;:\$]/, @_; + warn 'Error: unescapable =;: in prerequisites: '. join (' ', @_) if grep /[=;:]/, @_; #warn 'Warning: non-portable target name: '. join (' ', @_) if grep /[?<>:*|"^]/, @_; } =pod -Rules have optional 'commands': +Rules zero or more 'commands': $rule->Command ('cp', 'input1.txt', 'output1.txt'); $rule->Command ('cp', 'input2.txt', 'output2.txt'); @@ -137,9 +137,22 @@ sub _quoteshell { my $string = shift; - $string =~ s/(['"() `&*+^~<?>|])/\\$1/g; - # unquote $(FOO) variables - $string =~ s/\$\\\(([^)]+)\\\)/\$($1)/g; + if ($^O =~ /^(MSWin|dos)/) + { + # ?<>:*|"^ are unusable in Windows filenames + # so the only thing we can quote is a space + $string =~ s/^(.* .*)$/"$1"/g; + } + else + { + # some shell char sequences are real shell commands + unless ($string =~ /^([&<>|]|2>|\|\||&&|2>&1|`.+`)$/) + { + $string =~ s/(['"() `&*<?>|])/\\$1/g; + # unquote $(FOO) variables + $string =~ s/\$\\\(([^)]+)\\\)/\$($1)/g; + } + } return $string; } Modified: trunk/Panotools-Script/t/101.makerule.t =================================================================== --- trunk/Panotools-Script/t/101.makerule.t 2009-10-31 22:40:23 UTC (rev 1122) +++ trunk/Panotools-Script/t/101.makerule.t 2009-11-01 23:06:49 UTC (rev 1123) @@ -15,10 +15,6 @@ 'fooübar', 'fooébar', 'foo°bar', -'foo|bar', -'foo^bar', -'foo<bar', -'foo>bar', 'foo&bar', 'foo!bar', 'foo,bar', @@ -27,15 +23,12 @@ 'foo-bar', 'foo{bar', 'foo}bar', -'foo*bar', 'foo+bar', 'foo@bar', -'foo"bar', 'foo[bar', 'foo]bar', 'foo`bar', 'foo~bar', -'foo?bar', "foo'bar", 'foo(bar', 'foo)bar', @@ -45,6 +38,20 @@ ok (testfilename ($file)); } +# filenames that will never work on Windows +for my $file ('foo', +'foo?bar', +'foo<bar', +'foo>bar', +'foo*bar', +'foo|bar', +'foo"bar', +'foo^bar' +) +{ + ok (testfilename ($file)) unless ($^O =~ /^(MSWin|dos)/); +} + #'foo$(FOO)bar', #'foo${FOO}bar', #'foo/bar', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |