autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Let autom4te process arbitrary file names


From: Ralf Wildenhues
Subject: Re: Let autom4te process arbitrary file names
Date: Mon, 26 Nov 2007 19:41:42 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Benoit,

Thanks for the review.

* Benoit Sigoure wrote on Sat, Nov 24, 2007 at 03:24:33PM CET:
> On Nov 23, 2007, at 7:52 PM, Ralf Wildenhues wrote:
>
>> I did not use AT_DATA in the test because I'm not sure we want to
>> set in stone how it copes with special characters in its first
>> argument (I don't remember how it used to be when AT_DATA was used
>> for cleanup purposes also).  I guess that's another TODO item.
>
>
>>      * bin/autom4te.in (files_to_options): Quote active characters
>>      for the shell.
>
> Yup, this has been in my TODO list for quite a while (when I posted my 
> patch series to implement "unbootstrap" -- which I've imported in a topic 
> branch in Git btw -- Paul noted that autoreconf had this problem in all its 
> xsystem calls).

Yeah.  Currently, I'm not out to solve all issues out there, merely to
get Automake (and packages using Automake) to work in a source and build
tree with whitespace in the absolute name.  That's much more likely to
happen than somebody calling autoreconf explicitly with weird file
names: aclocal will always call autom4te with some absolute file names.

>> --- a/bin/autom4te.in
>> +++ b/bin/autom4te.in
>> @@ -235,14 +235,16 @@ sub files_to_options (@)
>>    my @res;
>>    foreach my $file (@file)
>>      {
>> +      (my $arg = $file) =~ s/'/'\\''/;
>
> This line of code isn't exercised by the testsuite.

Yep, indeed.  And it's broken, too: missing the `g' modifier at the end.
The test now catches that.  Thanks for noticing!

> So I you add another test that has both spaces and single quotes and 
> backslashes and maybe \' in its name, to ensure that it really works with 
> arbitrary file names.  If you don't want to deal with the stuff in 
> autoreconf, then just don't bother about it, I'll cook a couple of 
> patches...  when I'll have some free time in my hands :)

Whoever gets to it first I guess.

I've applied this.

Cheers,
Ralf

        Fix autom4te for unusual characters in input file names.
        * bin/autom4te.in (files_to_options): Quote active characters
        for the shell.
        * tests/tools.at (autom4te and white space in file names):
        New test.

diff --git a/bin/autom4te.in b/bin/autom4te.in
index 19bb964..b273b9a 100644
--- a/bin/autom4te.in
+++ b/bin/autom4te.in
@@ -235,14 +235,16 @@ sub files_to_options (@)
   my @res;
   foreach my $file (@file)
     {
+      (my $arg = $file) =~ s/'/'\\''/g;
       if ($file =~ /\.m4f$/)
        {
-         push @res, "--reload-state=$file";
+         $arg = "--reload-state=$file";
        }
-      else
+      if ($file =~ /[\t "'\\\$()]/)
        {
-         push @res, $file;
+         $arg = "'$arg'";
        }
+      push @res, $arg;
     }
   return join ' ', @res;
 }
diff --git a/tests/tools.at b/tests/tools.at
index aca2808..4096d9e 100644
--- a/tests/tools.at
+++ b/tests/tools.at
@@ -138,6 +138,24 @@ AT_CHECK([cat file], 0,
 AT_CLEANUP
 
 
+# autom4te and file names containing white space
+# ----------------------------------------------
+
+AT_SETUP([autom4te and white space in file names])
+
+file='file with  funny \ '\'' \'\'' $ & #!*? name'
+cat >"$file.m4" <<'END'
+right
+END
+# skip if we cannot create such a file
+AT_CHECK([test -f "$file.m4" || exit 77])
+AT_CHECK_AUTOM4TE([-o "$file" "$file.m4"])
+
+AT_CHECK([cat "$file"], [],
+[[right
+]])
+
+AT_CLEANUP
 
 
 ## ------------------ ##




reply via email to

[Prev in Thread] Current Thread [Next in Thread]