On 2020-10-21, Zack Weinberg <za...@panix.com> wrote: > On Tue, Oct 20, 2020 at 4:57 PM Nick Bowler <nbow...@draconx.ca> wrote: >> Note: the change you report is introduced by Zack's fix for related >> AC_INIT quoting regressions. This patch is not included in 2.69c (or >> even on git master), but does seem to be applied by the Gentoo package. > > Yeah, this is a "can't have it both ways" kind of thing. We can > reliably round-trip "unusual" characters (like the ones that appear > all the time in URLs and email addresses) through AC_INIT's arguments, > or we can expand macros in those arguments even when they're quoted on > input; I don't think there's any way to do both.
M4 macros (including AC_INIT) should normally follow the m4 quoting rule of thumb, which is that the amount of quotation should exactly equal the depth of macro expansion. Remembering that extra quotation added by macros such as m4_defn and m4_dquote count for this. Previously AC_INIT had not enough quotation, i.e., less levels of quotation than expansion, which lead to unexpected behaviour. Now, with the patch, AC_INIT is adding more levels of quotation than expansion, leading to different unexpected behaviour. M4 macros are happiest when the level of quotation is just right :) > This only works by accident in 2.69, incidentally. AC_PACKAGE_VERSION > is defined *after* AC_PACKAGE_TARNAME (see _AC_INIT_PACKAGE, lines > 235-261 of $prefix/share/autoconf/general.m4) so both old and new > autoconf set AC_PACKAGE_TARNAME to the literal string > "ghc-AC_PACKAGE_VERSION". While I agree it's probably a bit "naughty" to use AC_PACKAGE_VERSION in the argument to AC_INIT it is a red herring. Use of any macro would have the exact same problem. I'd expect double-quoted arguments to AC_INIT to be similarly broken with this patch while previously they would work as expected. > The value undergoes an extra round of expansion when it's used to set > the shell variable PACKAGE_TARNAME (lines 416-428 of the same file). > This extra round of expansion is undesirable in general. I don't think I agree, when macro expansion is undesired the normal way is to double-quote the arguments, which properly suppresses expansion when macro definitions follow quoting the rule of thumb. Cheers, Nick