autoconf-patches
[Top][All Lists]
Advanced

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

Re: Use newer m4_map_args_{w,sep}


From: Eric Blake
Subject: Re: Use newer m4_map_args_{w,sep}
Date: Wed, 12 Nov 2008 06:23:31 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666

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

Hi Ralf, Paolo,

According to Ralf Wildenhues on 11/11/2008 10:53 PM:
>>  ** The autoconf macros AC_DEFINE and AC_DEFINE_UNQUOTED now output
>>     fewer blank lines.
>
> It is not clear whether "output" refers to the configure or to the
> config.h file here.

Good point.  I'll add the phrase 'to the configure file' at the end.

According to Paolo Bonzini on 11/12/2008 4:50 AM:
> There is one famous package that has this problem: Ruby.
> 
> http://google.com/codesearch?hl=en&q=AC_DEFINE.*%23+-%23undef+show:we8yX7aPbNs:HuxpWw1qJ6A:PgJFo3MTLGM&sa=N&cd=2&ct=rc&cs_p=ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/ruby-1.8.6.tar.gz&cs_f=ruby-1.8.6/configure.in
> 
> While I disagree with Ralf that this kind of incompatibilities are "more
> common than we'd like" in Autoconf git, I do think this is a showstopper
> for this patch, unfortunately.

Ouch.  The patch is not dead yet, just stalled.  I have an (untested) idea
for a macro that will strip trailing newlines; does this name sound okay?
 The idea is using m4_regexp to grab the index of the last newline with no
subsequent text (if there is one), using m4_translit to work around
difficulties in matching literal newline in regexp.  Using a newline after
$1 guarantees a match, so I can avoid the m4 1.4.9 bug without using
_m4_index.

# m4_chop(STRING)
# ---------------
# Output a quoted version of STRING with all trailing newlines removed.
m4_define([m4_chop],
[m4_format([[%.*s]], m4_regexp(m4_translit([$1]m4_newline, [
]m4_defn([m4_cr_all]), [-]m4_for(,1,255,,.)), [-*$]), [$1])])

Once we have m4_chop, then AC_DEFINE should use:

m4_chop(m4_expand([$3
]))

then Ruby's use of unquoted # in $3 is matched with a newline during the
expansion, rather than the current issue where the # interferes with
detecting the end of the m4_expand; once the expansion is obtained, we can
safely remove the newline since AS_ECHO provides its own and since
m4_expand's output is properly quoted to no longer worry about raw #.

While we're at it, it is time to implement:

# m4_esyscmd_s(COMMAND)
# ---------------------
# Like m4_esyscmd, except strip any trailing newlines from the
# output (thus behaving more like ``).
m4_define([m4_esyscmd_s], [m4_chop(m4_esyscmd([$1]))])

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

Eric Blake             address@hidden
-----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

iEYEARECAAYFAkka2NMACgkQ84KuGfSFAYBrFgCeMtT1O7blF/qoOek1/2zmJssT
yo4An0/6i8xEkQD7i1Q1SBtoohb/+cWY
=Rzyv
-----END PGP SIGNATURE-----




reply via email to

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