[Top][All Lists]

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

Re: AC_TRY_COMPILE() annoyances with 2.63b

From: Eric Blake
Subject: Re: AC_TRY_COMPILE() annoyances with 2.63b
Date: Mon, 06 Apr 2009 06:59:32 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20090302 Thunderbird/ Mnenhy/

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_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, 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             address@hidden
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at
Comment: Using GnuPG with Mozilla -


reply via email to

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