AC_TRY_COMPILE() annoyances with 2.63b

View: New views
20 Messages — Rating Filter:   Alert me  

AC_TRY_COMPILE() annoyances with 2.63b

by Mike Frysinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

after upgrading from 2.63 to 2.63b, i noticed some code configure.ac files
(like in openssh) results in invalid shell code.  this is because
AC_TRY_COMPILE() is invoked with an empty 4th argument: [].  i think

specifically, this:
        AC_TRY_COMPILE(
        [
#include <sys/types.h>
#include <shadow.h>
        struct spwd sp;
        ],[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ],
        [ sp_expire_available=yes ], []
        )

turned into this:
        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

#include <sys/types.h>
#include <shadow.h>
        struct spwd sp;

int
main ()
{
 sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0;
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then
   sp_expire_available=yes
else

fi

seems to be fallout of the conversion to using shell functions ... the else
case previously would always contain at least one statement where autoconf
internally would echo the build failure to the log file:
else
  $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5



fi
-mike


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

signature.asc (853 bytes) Download Attachment

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Eric Blake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Mike Frysinger on 4/5/2009 4:10 PM:
> AC_TRY_COMPILE() is invoked with an empty 4th argument: [].  i think
>
> [ sp_expire_available=yes ], []
> )

That's not an empty fourth argument.  Remember, trailing space IS
significant, and only leading space is stripped.  The bug is in your
configure.ac.

That said, autoconf could probably be taught that, for some macros, an
argument of all whitespace is morally equivalent to an empty argument.
Patches welcome.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknZUMsACgkQ84KuGfSFAYCmZwCgwYC8q26BJ96OCMAcDxajDAZE
imYAn3F8RfckbnOukq8BxCBtz/OrQfhV
=N2nL
-----END PGP SIGNATURE-----


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Mike Frysinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 05 April 2009 20:46:03 Eric Blake wrote:
> According to Mike Frysinger on 4/5/2009 4:10 PM:
> > AC_TRY_COMPILE() is invoked with an empty 4th argument: [].  i think
> >
> > [ sp_expire_available=yes ], []
> > )
>
> That's not an empty fourth argument.  Remember, trailing space IS
> significant, and only leading space is stripped.  The bug is in your
> configure.ac.

it isnt my code.  i have nothing to do with openssh.  i'm merely forwarding
along regression reports of 2.63b compared to every version previous.  even if
you decide to keep this behavior, it should be noted in the NEWS.

> That said, autoconf could probably be taught that, for some macros, an
> argument of all whitespace is morally equivalent to an empty argument.
> Patches welcome.

i'm not an expert by any means with internal autoconf/m4.  if there's a m4
helper function to test whether an argument contains something other than
whitespace, then the change to m4sh.m4:_AS_IF is trivial ... use that rather
than m4_ifvaln([$1],....
-mike


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Mike Frysinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 05 April 2009 21:01:29 Mike Frysinger wrote:
> On Sunday 05 April 2009 20:46:03 Eric Blake wrote:
> > That said, autoconf could probably be taught that, for some macros, an
> > argument of all whitespace is morally equivalent to an empty argument.
> > Patches welcome.
>
> i'm not an expert by any means with internal autoconf/m4.  if there's a m4
> helper function to test whether an argument contains something other than
> whitespace, then the change to m4sh.m4:_AS_IF is trivial ... use that
> rather than m4_ifvaln([$1],....

to answer my own question and to post a patch, m4_normalize can be used:

diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 88881b1..605918b 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -606,7 +606,7 @@ m4_define([_AS_IF],
   m4_default([$2], [:])
 ])
 m4_define([_AS_IF_ELSE],
-[m4_ifvaln([$1],
+[m4_ifvaln(m4_normalize([$1]),
 [else
   $1])])
 

this should "fix" every macro that uses AS_IF with an "else" argument.  it
certainly fixes my test case.
-mike


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

signature.asc (853 bytes) Download Attachment

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Eric Blake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Mike Frysinger on 4/5/2009 7:19 PM:
>> i'm not an expert by any means with internal autoconf/m4.  if there's a m4
>> helper function to test whether an argument contains something other than
>> whitespace, then the change to m4sh.m4:_AS_IF is trivial ... use that
>> rather than m4_ifvaln([$1],....
>
> to answer my own question and to post a patch, m4_normalize can be used:

Indeed.  However, m4_normalize is an expensive choice for doing this check
(it involves regular expressions).  I'm thinking of introducing a new
m4sugar macro (untested in this email) that can be used for this purpose
with less overhead - any suggestions for a better name?

# m4_ifblank(COND, [IF-BLANK], [IF-TEXT])
# ---------------------------------------
# If COND is empty, or consists only of blanks (space, tab, newline),
# expand IF-BLANK, else expand IF-TEXT.
m4_define([m4_ifblank],
[m4_if(m4_translit([[$1]],  [ ][ ][
]), [], [$2], [$3])])

Hmm, this means that in addition to differing on a COND consisting of just
whitespace, m4_ifval and m4_ifblank have opposite if-then sense:
m4_ifval([$1], [$1], [])
m4_ifblank([$1], [], [$1])

Is it worth trying to think of a better macro name so that both macros
will favor the second (rather than the third) argument when the first
argument is not empty?

>
> this should "fix" every macro that uses AS_IF with an "else" argument.  it
> certainly fixes my test case.

I think you are right that fixing AS_IF to detect blank instead of empty
arguments when performing optimizations will probably help a number of
poorly-written configure.ac, so I will probably be checking in a patch
along these lines soon.  Note, however, that this still doesn't help
situations like:

AS_IF([foo], [AC_REQUIRE([bar])])

since the presence of AC_REQUIRE will trigger the IF-TEXT expansion,
although the subsequent expansion pass will result in a blank body.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknZ/LMACgkQ84KuGfSFAYC1EACfY4IEyfl+qWBBnwRAQdrTiTxQ
11YAoMrXfwB7HZVbYFoz/CypJ1xar6Y6
=QqeD
-----END PGP SIGNATURE-----


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Mike Frysinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 06 April 2009 08:59:32 Eric Blake wrote:

> According to Mike Frysinger on 4/5/2009 7:19 PM:
> >> i'm not an expert by any means with internal autoconf/m4.  if there's a
> >> m4 helper function to test whether an argument contains something other
> >> than whitespace, then the change to m4sh.m4:_AS_IF is trivial ... use
> >> that rather than m4_ifvaln([$1],....
> >
> > to answer my own question and to post a patch, m4_normalize can be used:
>
> Indeed.  However, m4_normalize is an expensive choice for doing this check
> (it involves regular expressions).  I'm thinking of introducing a new
> m4sugar macro (untested in this email) that can be used for this purpose
> with less overhead - any suggestions for a better name?
"blank" is actually what i thought of at first when i went looking for a
preexisting function ;)

> # m4_ifblank(COND, [IF-BLANK], [IF-TEXT])
> # ---------------------------------------
> # If COND is empty, or consists only of blanks (space, tab, newline),
> # expand IF-BLANK, else expand IF-TEXT.
> m4_define([m4_ifblank],
> [m4_if(m4_translit([[$1]],  [ ][ ][
> ]), [], [$2], [$3])])
>
> Hmm, this means that in addition to differing on a COND consisting of just
> whitespace, m4_ifval and m4_ifblank have opposite if-then sense:
> m4_ifval([$1], [$1], [])
> m4_ifblank([$1], [], [$1])
call it m4_ifnblank() ?  or have both so people can swap as needed ?  i
imagine people would favor the form for their specific case which only
requires one argument.  i know i would.
m4_ifblank(COND, [IF-BLANK], [IF-TEXT])
m4_ifnblank(COND, [IF-TEXT], [IF-BLANK])

> > this should "fix" every macro that uses AS_IF with an "else" argument.
> > it certainly fixes my test case.
>
> I think you are right that fixing AS_IF to detect blank instead of empty
> arguments when performing optimizations will probably help a number of
> poorly-written configure.ac, so I will probably be checking in a patch
> along these lines soon.  Note, however, that this still doesn't help
> situations like:
>
> AS_IF([foo], [AC_REQUIRE([bar])])
>
> since the presence of AC_REQUIRE will trigger the IF-TEXT expansion,
> although the subsequent expansion pass will result in a blank body.
true, although i dont really know squat about m4 to propose any solution along
those lines.  perhaps have the else case always emit a leading null cmd ":" ?  
seems like adding 2 bytes is a small price to pay for the resulting syntax
safety ...

--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -607,7 +607,7 @@ m4_define([_AS_IF],
 ])
 m4_define([_AS_IF_ELSE],
 [m4_ifvaln([$1],
-[else
+[else :
   $1])])
 
 m4_defun([AS_IF],
-mike


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

signature.asc (853 bytes) Download Attachment

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Mike, Eric,

* Mike Frysinger wrote on Mon, Apr 06, 2009 at 03:16:53PM CEST:

> --- a/lib/m4sugar/m4sh.m4
> +++ b/lib/m4sugar/m4sh.m4
> @@ -607,7 +607,7 @@ m4_define([_AS_IF],
>  ])
>  m4_define([_AS_IF_ELSE],
>  [m4_ifvaln([$1],
> -[else
> +[else :
>    $1])])
>  
>  m4_defun([AS_IF],

I like this one, for simplicity and obvious correctness alone, but will
defer to Eric for the final decision.  Question is whether the "then"
and "elif" parts should receive the same treatment.

BTW, m4_normalize would have been wrong as it can change expanded text
that you wouldn't want changed, too.  (I think.)

Cheers,
Ralf


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Mike Frysinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 06 April 2009 14:09:29 Ralf Wildenhues wrote:

> Hello Mike, Eric,
>
> * Mike Frysinger wrote on Mon, Apr 06, 2009 at 03:16:53PM CEST:
> > --- a/lib/m4sugar/m4sh.m4
> > +++ b/lib/m4sugar/m4sh.m4
> > @@ -607,7 +607,7 @@ m4_define([_AS_IF],
> >  ])
> >  m4_define([_AS_IF_ELSE],
> >  [m4_ifvaln([$1],
> > -[else
> > +[else :
> >    $1])])
> >
> >  m4_defun([AS_IF],
>
> I like this one, for simplicity and obvious correctness alone, but will
> defer to Eric for the final decision.
personally, i prefer both :).  dont emit extraneous brackets when they arent
needed, and be safe when we think we must.

> Question is whether the "then"
> and "elif" parts should receive the same treatment.

if Eric is ok with this change, i can submit a "proper" one with those changed
as well.

> BTW, m4_normalize would have been wrong as it can change expanded text
> that you wouldn't want changed, too.  (I think.)

but that wouldnt matter would it ?  we're only expanding to check it
ifvaln(normalize($1)).  if we like the result, then we emit $1 as part of the
else.  but again, m4 subtleties are beyond me.
-mike


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

signature.asc (853 bytes) Download Attachment

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Eric Blake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Mike Frysinger on 4/6/2009 3:43 PM:

>>>  m4_define([_AS_IF_ELSE],
>>>  [m4_ifvaln([$1],
>>> -[else
>>> +[else :
>>>    $1])])
>>>
>>>  m4_defun([AS_IF],
>> I like this one, for simplicity and obvious correctness alone, but will
>> defer to Eric for the final decision.
>
> personally, i prefer both :).  dont emit extraneous brackets when they arent
> needed, and be safe when we think we must.

I'm also leaning towards omitting the else if $1 is provably blank,
otherwise providing the : in case non-blank $1 ultimately expands to a
blank (unless someone finds a shell where 'if false ; then :; fi; echo $?'
fails to output 0).  AS_CASE and AS_FOR are also candidates for this.  And
it will be easier with m4_ifblank.  Stay tuned; I'll have a patch by the
end of the week.

Now for a question - right now, m4_default([$1], [$2]) is a nice shorthand
for m4_ifval([$1], [$1], [$2]); is there any reason to create a shorthand
for m4_ifnblank([$1], [$1], [$2]) that likewise only needs two arguments?
 And if so, what to call it?

>> BTW, m4_normalize would have been wrong as it can change expanded text
>> that you wouldn't want changed, too.  (I think.)
>
> but that wouldnt matter would it ?  we're only expanding to check it
> ifvaln(normalize($1)).  if we like the result, then we emit $1 as part of the
> else.  but again, m4 subtleties are beyond me.

Actually, you nailed the subtleties on that one:

m4_ifval(m4_normalize([$1]), [else :
  $1
])

uses two copies of $1; the first can undergo arbitrary change to check for
blanks, while the second is used as-is.  I'd use exactly that if it
weren't for the fact that the future m4_ifblank is more efficient than
m4_ifval/m4_normalize.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknauYgACgkQ84KuGfSFAYAW0wCcCdQaXVK+3zkxA1fQ15DDca2E
Q8YAn1NVAGo58KaUumgZgemx75Fjk3Ea
=tBx2
-----END PGP SIGNATURE-----


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Eric Blake wrote on Tue, Apr 07, 2009 at 04:25:12AM CEST:
> I'm also leaning towards omitting the else if $1 is provably blank,

OK with me.

> otherwise providing the : in case non-blank $1 ultimately expands to a
> blank (unless someone finds a shell where 'if false ; then :; fi; echo $?'
> fails to output 0).

> AS_CASE and AS_FOR are also candidates for this.

AS_CASE copes well with empty args number 3, 5, 7, ... default, and
the output looks nice that way, too.

> Now for a question - right now, m4_default([$1], [$2]) is a nice shorthand
> for m4_ifval([$1], [$1], [$2]); is there any reason to create a shorthand
> for m4_ifnblank([$1], [$1], [$2]) that likewise only needs two arguments?
>  And if so, what to call it?

But that isn't what you need here.  There are situations in which you
cannot prove whether $1 is blank or not.  In that case, we should add
both the ":\n" as well as $1.

Cheers,
Ralf


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Ralf Wildenhues wrote on Tue, Apr 07, 2009 at 07:38:10AM CEST:
>
> But that isn't what you need here.  There are situations in which you
> cannot prove whether $1 is blank or not.  In that case, we should add
> both the ":\n" as well as $1.

Actually, $1 can just expand to `#\n' (that is, comment sign plus
newline) and the shell will still report a syntax error.  If you
want to disallow the user shooting himself in the foot, then `:\n'
or `:;' is probably needed.

Cheers,
Ralf


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Mike Frysinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 06 April 2009 22:25:12 Eric Blake wrote:
> Now for a question - right now, m4_default([$1], [$2]) is a nice shorthand
> for m4_ifval([$1], [$1], [$2]); is there any reason to create a shorthand
> for m4_ifnblank([$1], [$1], [$2]) that likewise only needs two arguments?
>  And if so, what to call it?

m4_default_blank([$1], [$2]) seems like a logical extension
-mike


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

signature.asc (853 bytes) Download Attachment

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Andreas Schwab-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Eric Blake <ebb9@...> writes:

> I'm also leaning towards omitting the else if $1 is provably blank,
> otherwise providing the : in case non-blank $1 ultimately expands to a
> blank (unless someone finds a shell where 'if false ; then :; fi; echo $?'
> fails to output 0).

From the autoconf manual:

     There are shells that do not reset the exit status from an `if':

          $ if (exit 42); then true; fi; echo $?
          42

     whereas a proper shell should have printed `0'.

Andreas.

--
Andreas Schwab, schwab@...
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

AS_IF optimization (was: AC_TRY_COMPILE() annoyances with 2.63b)

by Eric Blake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Andreas Schwab on 4/7/2009 3:47 AM:
>>From the autoconf manual:
>
>      There are shells that do not reset the exit status from an `if':
>
>           $ if (exit 42); then true; fi; echo $?
>           42
>
>      whereas a proper shell should have printed `0'.

Which shells?  Solaris /bin/sh passed this test (to my surprise, since if
fails the similar test for 'case `false` in *);; esac').  Even cygwin's
super-old ash passed this, although it falls flat on a number of other
constructs.  Could this be a case of urban legend?

To further reinforce my point, the autoconf testsuite currently has a test
of 'AS_IF([false]) && ...', but AS_IF currently omits the unused else
branch for that construct.  So if there really is such a shell that
botches the status after an omitted else, then it should trigger a
testsuite failure in at least 2.63b.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknbQqUACgkQ84KuGfSFAYDbDACfQ8FNFjH3r82XtckHyLxFFRhw
i9sAoLUg7oNwFCgY3CITtiaAjzisf2vn
=/K+9
-----END PGP SIGNATURE-----


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AS_IF optimization (was: AC_TRY_COMPILE() annoyances with 2.63b)

by Andreas Schwab-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Eric Blake <ebb9@...> writes:

> According to Andreas Schwab on 4/7/2009 3:47 AM:
>>>From the autoconf manual:
>>
>>      There are shells that do not reset the exit status from an `if':
>>
>>           $ if (exit 42); then true; fi; echo $?
>>           42
>>
>>      whereas a proper shell should have printed `0'.
>
> Which shells?  Solaris /bin/sh passed this test (to my surprise, since if
> fails the similar test for 'case `false` in *);; esac').  Even cygwin's
> super-old ash passed this, although it falls flat on a number of other
> constructs.  Could this be a case of urban legend?

According to <http://www.in-ulm.de/~mascheck/bourne/> this was fixed in
the System III shell.

Andreas.

--
Andreas Schwab, schwab@...
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AS_IF optimization

by Eric Blake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Andreas Schwab on 4/7/2009 7:01 AM:
>> Which shells?  Solaris /bin/sh passed this test (to my surprise, since if
>> fails the similar test for 'case `false` in *);; esac').  Even cygwin's
>> super-old ash passed this, although it falls flat on a number of other
>> constructs.  Could this be a case of urban legend?
>
> According to <http://www.in-ulm.de/~mascheck/bourne/> this was fixed in
> the System III shell.

Which pre-dates shell functions.  Therefore, since AS_IF is part of m4sh,
which guarantees a shell with functions, can elide empty else statements
with impunity.  Thanks for the research.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknbUY0ACgkQ84KuGfSFAYD9NwCgmSJs4DcZxEbGEg0X4QADilUh
/ycAn1LtsHwOIF5y3dZrrwhPwRe60jfy
=orUO
-----END PGP SIGNATURE-----


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Eric Blake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[adding autoconf-patches, replies can drop autoconf]

According to Eric Blake on 4/6/2009 8:25 PM:
> According to Mike Frysinger on 4/6/2009 3:43 PM:
> I'm also leaning towards omitting the else if $1 is provably blank,
> otherwise providing the : in case non-blank $1 ultimately expands to a
> blank (unless someone finds a shell where 'if false ; then :; fi; echo $?'
> fails to output 0).  AS_CASE and AS_FOR are also candidates for this.  And
> it will be easier with m4_ifblank.  Stay tuned; I'll have a patch by the
> end of the week.

Here's what I'm about to apply.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkneyqwACgkQ84KuGfSFAYA4xACeM27WusneT1UueEUy6khYtCCq
jDMAoNIacTpzZ+4wwaDXQrESVr6Ii7Z8
=yCfL
-----END PGP SIGNATURE-----

From 709c9c86af078eefd4c44f3df3de52dda678794e Mon Sep 17 00:00:00 2001
From: Eric Blake <ebb9@...>
Date: Thu, 9 Apr 2009 07:05:00 -0600
Subject: [PATCH 1/2] Add m4_blank and friends.

* lib/m4sugar/m4sugar.m4 (m4_blank, m4_nblank, m4_default_nblank)
(m4_default_nblank_quoted): New macros.
* NEWS: Document them.
* doc/autoconf.texi (Conditional constructs): Likewise.
* tests/m4sugar.at (m4sugar shorthand conditionals): New test.
Suggested by Mike Frysinger.

Signed-off-by: Eric Blake <ebb9@...>
---
 ChangeLog              |   10 ++++++
 NEWS                   |    3 ++
 doc/autoconf.texi      |   53 ++++++++++++++++++++++++++++-
 lib/m4sugar/m4sugar.m4 |   47 +++++++++++++++++++++++---
 tests/m4sugar.at       |   85 ++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 190 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index be9ab98..4429431 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2009-04-09  Eric Blake  <ebb9@...>

+ Add m4_blank and friends.
+ * lib/m4sugar/m4sugar.m4 (m4_blank, m4_nblank, m4_default_nblank)
+ (m4_default_nblank_quoted): New macros.
+ * NEWS: Document them.
+ * doc/autoconf.texi (Conditional constructs): Likewise.
+ * tests/m4sugar.at (m4sugar shorthand conditionals): New test.
+ Suggested by Mike Frysinger.
+
+2009-04-09  Eric Blake  <ebb9@...>
+
  Avoid problems caused by deleting in-use directory.
  * lib/autotest/general.m4 (AT_INIT) <at_fn_group_prepare>: Only
  remove the contents of $at_group_dir, not the directory itself.
diff --git a/NEWS b/NEWS
index e91fc39..0357cbd 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ GNU Autoconf NEWS - User visible changes.
    proper m4 quoting.  For shell comments, this is a new feature; for
    non-shell comments, this fixes a regression introduced in 2.63b.

+** The following documented m4sugar macros are new:
+   m4_default_nblank  m4_default_nblank_quoted  m4_ifblank  m4_ifnblank
+
 * Major changes in Autoconf 2.63b (2009-03-31) [beta]
   Released by Eric Blake, based on git versions 2.63.*.

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 5e490fe..a47d3c8 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -10987,25 +10987,74 @@ Conditional constructs

 @defmac m4_default (@var{expr-1}, @var{expr-2})
 @defmacx m4_default_quoted (@var{expr-1}, @var{expr-2})
+@defmacx m4_default_nblank (@var{expr-1}, @ovar{expr-2})
+@defmacx m4_default_nblank_quoted (@var{expr-1}, @ovar{expr-2})
 @msindex{default}
 @msindex{default_quoted}
-If @var{expr-1} is not empty, use it.  Otherwise, select @var{expr-2}.
+@msindex{default_nblank}
+@msindex{default_nblank_quoted}
+If @var{expr-1} contains text, use it.  Otherwise, select @var{expr-2}.
 @code{m4_default} expands the result, while @code{m4_default_quoted}
 does not.  Useful for providing a fixed default if the expression that
-results in @var{expr-1} would otherwise be empty.
+results in @var{expr-1} would otherwise be empty.  The difference
+between @code{m4_default} and @code{m4_default_nblank} is whether an
+argument consisting of just blanks (space, tab, newline) is
+significant.  When using the expanding versions, note that an argument
+may contain text but still expand to an empty string.

 @example
 m4_define([active], [ACTIVE])dnl
+m4_define([empty], [])dnl
 m4_define([demo1], [m4_default([$1], [$2])])dnl
 m4_define([demo2], [m4_default_quoted([$1], [$2])])dnl
+m4_define([demo3], [m4_default_nblank([$1], [$2])])dnl
+m4_define([demo4], [m4_default_nblank_quoted([$1], [$2])])dnl
 demo1([active], [default])
 @result{}ACTIVE
 demo1([], [active])
 @result{}ACTIVE
+demo1([empty], [text])
+@result{}
+-demo1([ ], [active])-
+@result{}- -
 demo2([active], [default])
 @result{}active
 demo2([], [active])
 @result{}active
+demo2([empty], [text])
+@result{}empty
+-demo2([ ], [active])-
+@result{}- -
+demo3([active], [default])
+@result{}ACTIVE
+demo3([], [active])
+@result{}ACTIVE
+demo3([empty], [text])
+@result{}
+-demo3([ ], [active])-
+@result{}-ACTIVE-
+demo4([active], [default])
+@result{}active
+demo4([], [active])
+@result{}active
+demo4([empty], [text])
+@result{}empty
+-demo4([ ], [active])-
+@result{}-active-
+@end example
+@end defmac
+
+@defmac m4_ifblank (@var{cond}, @ovar{if-blank}, @ovar{if-text})
+@defmacx m4_ifnblank (@var{cond}, @ovar{if-text}, @ovar{if-blank})
+@msindex{ifblank}
+@msindex{ifnblank}
+If @var{cond} is empty or consists only of blanks (space, tab, newline),
+then expand @var{if-blank}; otherwise, expand @var{if-text}.  Two
+variants exist, in order to make it easier to select the correct logical
+sense when using only two parameters.  Note that this is more efficient
+than the equivalent behavior of:
+@example
+m4_ifval(m4_normalize([@var{cond}]), @var{if-text}, @var{if-cond})
 @end example
 @end defmac

diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index 8356d08..420fd99 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -335,6 +335,29 @@ m4_builtin([sinclude], [$1])])
 # it runs TRUE, etc.


+# m4_ifblank(COND, [IF-BLANK], [IF-TEXT])
+# m4_ifnblank(COND, [IF-TEXT], [IF-BLANK])
+# ----------------------------------------
+# If COND is empty, or consists only of blanks (space, tab, newline),
+# then expand IF-BLANK, otherwise expand IF-TEXT.  This differs from
+# m4_ifval only if COND has just whitespace, but it helps optimize in
+# spite of users who mistakenly leave trailing space after what they
+# thought was an empty argument:
+#   macro(
+#         []
+#        )
+#
+# Writing one macro in terms of the other causes extra overhead, so
+# we inline both definitions.
+m4_define([m4_ifblank],
+[m4_if(m4_translit([[$1]],  [ ][ ][
+]), [], [$2], [$3])])
+
+m4_define([m4_ifnblank],
+[m4_if(m4_translit([[$1]],  [ ][ ][
+]), [], [$3], [$2])])
+
+
 # m4_ifval(COND, [IF-TRUE], [IF-FALSE])
 # -------------------------------------
 # If COND is not the empty string, expand IF-TRUE, otherwise IF-FALSE.
@@ -559,31 +582,43 @@ m4_define([m4_define_default],


 # m4_default(EXP1, EXP2)
-# ----------------------
-# Returns EXP1 if non empty, otherwise EXP2.  Expand the result.
+# m4_default_nblank(EXP1, EXP2)
+# -----------------------------
+# Returns EXP1 if not empty/blank, otherwise EXP2.  Expand the result.
 #
-# This macro is called on hot paths, so inline the contents of m4_ifval,
+# m4_default is called on hot paths, so inline the contents of m4_ifval,
 # for one less round of expansion.
 m4_define([m4_default],
 [m4_if([$1], [], [$2], [$1])])

+m4_define([m4_default_nblank],
+[m4_ifblank([$1], [$2], [$1])])
+

 # m4_default_quoted(EXP1, EXP2)
-# -----------------------------
-# Returns EXP1 if non empty, otherwise EXP2.  Leave the result quoted.
+# m4_default_nblank_quoted(EXP1, EXP2)
+# ------------------------------------
+# Returns EXP1 if non empty/blank, otherwise EXP2.  Leave the result quoted.
 #
 # For comparison:
 #   m4_define([active], [ACTIVE])
 #   m4_default([active], [default]) => ACTIVE
 #   m4_default([], [active]) => ACTIVE
+#   -m4_default([ ], [active])- => - -
+#   -m4_default_nblank([ ], [active])- => -ACTIVE-
 #   m4_default_quoted([active], [default]) => active
 #   m4_default_quoted([], [active]) => active
+#   -m4_default_quoted([ ], [active])- => - -
+#   -m4_default_nblank_quoted([ ], [active])- => -active-
 #
-# This macro is called on hot paths, so inline the contents of m4_ifval,
+# m4_default macro is called on hot paths, so inline the contents of m4_ifval,
 # for one less round of expansion.
 m4_define([m4_default_quoted],
 [m4_if([$1], [], [[$2]], [[$1]])])

+m4_define([m4_default_nblank_quoted],
+[m4_ifblank([$1], [[$2]], [[$1]])])
+

 # m4_defn(NAME)
 # -------------
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index 6286af2..2dd81dc 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -649,6 +649,91 @@ m
 AT_CLEANUP


+## ------------------------------------------------- ##
+## m4_ifval, m4_ifblank, m4_ifset, m4_default, etc.  ##
+## ------------------------------------------------- ##
+
+AT_SETUP([m4sugar shorthand conditionals])
+AT_KEYWORDS([m4@&t@_ifval m4@&t@_ifblank m4@&t@_ifnblank m4@&t@_ifset
+m4@&t@_default m4@&t@_default_quoted m4@&t@_default_nblank
+m4@&t@_default_nblank_quoted])
+
+AT_CHECK_M4SUGAR_TEXT([[m4_define([active], [ACTIVE])m4_define([empty])
+m4_ifval([active], [yes], [no])
+m4_ifval([empty], [yes], [no])
+m4_ifval([ ], [yes], [no])
+m4_ifval([], [yes], [no])
+m4_ifblank([active], [yes], [no])
+m4_ifblank([empty], [yes], [no])
+m4_ifblank([ ], [yes], [no])
+m4_ifblank([], [yes], [no])
+m4_ifnblank([active], [yes], [no])
+m4_ifnblank([empty], [yes], [no])
+m4_ifnblank([ ], [yes], [no])
+m4_ifnblank([], [yes], [no])
+m4_ifset([active], [yes], [no])
+m4_ifset([empty], [yes], [no])
+m4_ifset([ ], [yes], [no])
+m4_ifset([], [yes], [no])
+---
+m4_define([demo1], [m4_default([$1], [$2])])dnl
+m4_define([demo2], [m4_default_quoted([$1], [$2])])dnl
+m4_define([demo3], [m4_default_nblank([$1], [$2])])dnl
+m4_define([demo4], [m4_default_nblank_quoted([$1], [$2])])dnl
+demo1([active], [default])
+demo1([], [active])
+demo1([empty], [text])
+-demo1([ ], [active])-
+demo2([active], [default])
+demo2([], [active])
+demo2([empty], [text])
+-demo2([ ], [active])-
+demo3([active], [default])
+demo3([], [active])
+demo3([empty], [text])
+-demo3([ ], [active])-
+demo4([active], [default])
+demo4([], [active])
+demo4([empty], [text])
+-demo4([ ], [active])-
+]], [[
+yes
+yes
+yes
+no
+no
+no
+yes
+yes
+yes
+yes
+no
+no
+yes
+no
+no
+no
+---
+ACTIVE
+ACTIVE
+
+- -
+active
+active
+empty
+- -
+ACTIVE
+ACTIVE
+
+-ACTIVE-
+active
+active
+empty
+-active-
+]])
+
+AT_CLEANUP
+
 ## --------- ##
 ## m4_cond.  ##
 ## --------- ##
--
1.6.1.2


From 73b4250ff10680265b65215b5e72e41688f2308c Mon Sep 17 00:00:00 2001
From: Eric Blake <ebb9@...>
Date: Thu, 9 Apr 2009 21:45:18 -0600
Subject: [PATCH 2/2] Make AS_IF, AS_CASE, and AS_FOR more robust to blank arguments.

* lib/m4sugar/m4sh.m4 (_AS_CASE, _AS_CASE_DEFAULT, AS_FOR, _AS_IF)
(_AS_IF_ELSE, AS_IF): Avoid syntax error on blank argument.
* NEWS: Mention this.
* tests/m4sh.at (AS@&t@_IF and AS@&t@_CASE, AS@&t@_FOR): Update
tests.
Reported by Mike Frysinger.

Signed-off-by: Eric Blake <ebb9@...>
---
 ChangeLog           |    8 ++++++++
 NEWS                |    3 +++
 lib/m4sugar/m4sh.m4 |   29 ++++++++++++++++-------------
 tests/m4sh.at       |   11 ++++++++++-
 4 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4429431..071b418 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-04-09  Eric Blake  <ebb9@...>

+ Make AS_IF, AS_CASE, and AS_FOR more robust to blank arguments.
+ * lib/m4sugar/m4sh.m4 (_AS_CASE, _AS_CASE_DEFAULT, AS_FOR, _AS_IF)
+ (_AS_IF_ELSE, AS_IF): Avoid syntax error on blank argument.
+ * NEWS: Mention this.
+ * tests/m4sh.at (AS@&t@_IF and AS@&t@_CASE, AS@&t@_FOR): Update
+ tests.
+ Reported by Mike Frysinger.
+
  Add m4_blank and friends.
  * lib/m4sugar/m4sugar.m4 (m4_blank, m4_nblank, m4_default_nblank)
  (m4_default_nblank_quoted): New macros.
diff --git a/NEWS b/NEWS
index 0357cbd..8eb3a06 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ GNU Autoconf NEWS - User visible changes.
 * Major changes in Autoconf 2.64 (2009-??-??) [stable]
   Released by Eric Blake, based on git versions 2.63b.*.

+** AS_IF, AS_CASE, and AS_FOR have been taught to avoid syntax errors
+   even when given arguments that expand to just whitespace.
+
 ** Ensure AT_CHECK can support commands that include a # given with
    proper m4 quoting.  For shell comments, this is a new feature; for
    non-shell comments, this fixes a regression introduced in 2.63b.
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 88881b1..b3dc63a 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -514,14 +514,16 @@ _AS_UNSET_PREPARE
 # | esac
 # The shell comments are intentional, to work around people who don't
 # realize the impacts of using insufficient m4 quoting.  This macro
-# always provides a default case, to work around a Solaris /bin/sh
-# bug regarding the exit status when no case matches.
+# always uses : and provides a default case, to work around Solaris
+# /bin/sh bugs regarding the exit status.
 m4_define([_AS_CASE],
 [ [@%:@(]
-  $1[)] m4_default([$2], [:]) ;;])
+  $1[)] :
+    $2 ;;])
 m4_define([_AS_CASE_DEFAULT],
 [ [@%:@(]
-  *[)] m4_default([$1], [:]) ;;])
+  *[)] :
+    $1 ;;])

 m4_defun([AS_CASE],
 [case $1 in[]m4_map_args_pair([_$0], [_$0_DEFAULT],
@@ -583,8 +585,8 @@ m4_defun([AS_FOR],
 [m4_pushdef([$1], m4_if([$3], [], [[$$2]], m4_translit([$3], ]dnl
 m4_dquote(_m4_defn([m4_cr_symbols2]))[[%+=:,./-]), [], [[$3]], [[$$2]]))]dnl
 [for $2[]m4_ifval([$3], [ in $3])
-do
-  m4_default([$4], [:])
+do :
+  $4
 done[]_m4_popdef([$1])])


@@ -602,17 +604,18 @@ done[]_m4_popdef([$1])])
 # with simplifications if IF-TRUE1 and/or IF-FALSE is empty.
 #
 m4_define([_AS_IF],
-[elif $1; then
-  m4_default([$2], [:])
+[elif $1; then :
+  $2
 ])
 m4_define([_AS_IF_ELSE],
-[m4_ifvaln([$1],
-[else
-  $1])])
+[m4_ifnblank([$1],
+[else :
+  $1
+])])

 m4_defun([AS_IF],
-[if $1; then
-  m4_default([$2], [:])
+[if $1; then :
+  $2
 m4_map_args_pair([_$0], [_$0_ELSE], m4_shift2($@))]dnl
 [fi[]])# AS_IF

diff --git a/tests/m4sh.at b/tests/m4sh.at
index def63aa..fecb59a 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -859,6 +859,11 @@ rm -f file
 AS_CASE([`touch file; false`]) && test -f file && echo fifteen
 dnl The next line is badly underquoted; don't intentionally copy this style.
 AS_CASE([foo], [foo], m4_do(AS_CASE([bar], [bar], [echo sixteen])))
+dnl Handle blank arguments.
+AS_IF([false], [:], [ ]) && AS_CASE([foo], [foo], []
+) && echo seventeen
+m4_define([empty])AS_IF([false], [:], [empty]
+) && AS_CASE([foo], [foo], [empty]) && echo eighteen

 # check that require works correctly
 m4_for([n], 1, 9, [],
@@ -911,6 +916,8 @@ thirteen
 fourteen
 fifteen
 sixteen
+seventeen
+eighteen
 foo1=1 bar1=1
 foo2=2 bar2=
 foo3=3 bar3=
@@ -979,13 +986,15 @@ AS_FOR([m4var], [shvar], ['$list'],
 AS_FOR([m4var], [shvar], [\'],
 [echo "m4var $shvar"])

-# Syntax checks: cope with empty arguments.
+# Syntax checks: cope with empty/blank arguments.
 set f g
 AS_FOR([], [shvar], [],
 [echo "m4_defn([]) $shvar"])
 rm -f file
 AS_FOR([], [shvar], [`touch file`])
 test -f file || exit 1
+AS_FOR([], [shvar], [], [ ])
+m4_define([empty])AS_FOR([], [shvar], [], [empty])

 # Check that break works.
 while :
--
1.6.1.2


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AS_IF optimization

by Eric Blake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[moving to autoconf-patches]

According to Eric Blake on 4/7/2009 7:13 AM:
> According to Andreas Schwab on 4/7/2009 7:01 AM:
>> According to <http://www.in-ulm.de/~mascheck/bourne/> this was fixed in
>> the System III shell.
>
> Which pre-dates shell functions.  Therefore, since AS_IF is part of m4sh,
> which guarantees a shell with functions, can elide empty else statements
> with impunity.  Thanks for the research.

I'm thinking of applying this patch; any objections to the wording?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkne00oACgkQ84KuGfSFAYCR5wCeJ5TS1DVHUndZwj5GP+huU2EP
p4oAoKrG9dvOX6sHAM7OxR2FG0/Yneok
=Y+rt
-----END PGP SIGNATURE-----

>From a65adc795cbf283604fbf56045e47c8af1a2685c Mon Sep 17 00:00:00 2001
From: Eric Blake <ebb9@...>
Date: Thu, 9 Apr 2009 22:33:37 -0600
Subject: [PATCH] Improve documentation about if exit status.

* doc/autoconf.texi (Limitations of Builtins) <if>: Mention that
exit status bugs don't affect modern targets.
Reported by Andreas Schwab.

Signed-off-by: Eric Blake <ebb9@...>
---
 ChangeLog         |    5 +++++
 doc/autoconf.texi |   10 ++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 071b418..9ac238d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-04-09  Eric Blake  <ebb9@...>

+ Improve documentation about if exit status.
+ * doc/autoconf.texi (Limitations of Builtins) <if>: Mention that
+ exit status bugs don't affect modern targets.
+ Reported by Andreas Schwab.
+
  Make AS_IF, AS_CASE, and AS_FOR more robust to blank arguments.
  * lib/m4sugar/m4sh.m4 (_AS_CASE, _AS_CASE_DEFAULT, AS_FOR, _AS_IF)
  (_AS_IF_ELSE, AS_IF): Avoid syntax error on blank argument.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index a47d3c8..c3033cd 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -15829,7 +15829,8 @@ Limitations of Builtins
 This is especially useful in other M4 macros, where the @dfn{then} and
 @dfn{else} branches might be macro arguments.

-There are shells that do not reset the exit status from an @command{if}:
+Some very old shells did not reset the exit status from an @command{if}
+with no @command{else}:

 @example
 $ @kbd{if (exit 42); then true; fi; echo $?}
@@ -15837,9 +15838,10 @@ Limitations of Builtins
 @end example

 @noindent
-whereas a proper shell should have printed @samp{0}.  This is especially
-bad in makefiles since it produces false failures.  This is why properly
-written makefiles, such as Automake's, have such hairy constructs:
+whereas a proper shell should have printed @samp{0}.  But this is no
+longer a portability problem; any shell that supports functions gets it
+correct.  However, it explains why some makefiles have such hairy
+constructs:

 @example
 if test -f "$file"; then
--
1.6.1.2




_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Mike Frysinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 05 April 2009 20:46:03 Eric Blake wrote:

> According to Mike Frysinger on 4/5/2009 4:10 PM:
> > AC_TRY_COMPILE() is invoked with an empty 4th argument: [].  i think
> >
> > [ sp_expire_available=yes ], []
> > )
>
> That's not an empty fourth argument.  Remember, trailing space IS
> significant, and only leading space is stripped.  The bug is in your
> configure.ac.
>
> That said, autoconf could probably be taught that, for some macros, an
> argument of all whitespace is morally equivalent to an empty argument.

seems the issue is worse than people being pedantic with [].  for example, if
a macro is expanded implicitly, then a user explicit call to that macro gets
nooped and we're back where we started -- syntax error

simple example:
$ cat configure.ac
AC_INIT
AS_IF([:], [
        : some random user stuff
],[
        AC_PROG_LEX
        AC_DECL_YYTEXT
])
AC_OUTPUT
$ autoconf --version
autoconf (GNU Autoconf) 2.64
$ autoconf && ./configure -q
./configure: line 2676: syntax error near unexpected token `fi'
./configure: line 2676: `fi'
-mike


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf

Re: AC_TRY_COMPILE() annoyances with 2.63b

by Paolo Bonzini-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> simple example:
> $ cat configure.ac
> AC_INIT
> AS_IF([:], [
> : some random user stuff
> ],[
> AC_PROG_LEX
> AC_DECL_YYTEXT
> ])
> AC_OUTPUT
> $ autoconf --version
> autoconf (GNU Autoconf) 2.64
> $ autoconf&&  ./configure -q
> ./configure: line 2676: syntax error near unexpected token `fi'
> ./configure: line 2676: `fi'
> -mike

This is a different issue.  AS_IF strips leading and trailing blanks,
but works on its unexpanded argument.  It's probably something Eric
could fix with his m4-fu in m4_if{,n}blank.

Minimized testcase:

echo 'm4_init[]m4_divert(0)[]m4_define([a], [])m4_ifblank([ a ],
[blank])' | m4 m4sugar/m4sugar.m4 -


Paolo


_______________________________________________
Autoconf mailing list
Autoconf@...
http://lists.gnu.org/mailman/listinfo/autoconf