bug-gnulib
[Top][All Lists]
Advanced

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

Re: more m4 underquotations


From: Eric Blake
Subject: Re: more m4 underquotations
Date: Wed, 14 Feb 2007 15:57:08 +0000

> > If you prefer some other quoting style (e.g., maximal quoting or
> > quadrigraphs, but rather not changequote)
> 
> There is an important property that programming languages should have:
> the ability to copy and paste a piece of code from one place to another.
> 
> [[...]] doesn't have this property at all.

I concede that the following lacks cut-n-paste properties:

AC_DEFINE([foo],
  [
   case "$host_cpu" in
      i[[34567]]86) action ;;
    esac
  ])

But the following is equivalent, and DOES have the desired properties:

AC_DEFINE([foo],
  [[
    case "$host_cpu" in
      i[34567]86) action ;;
    esac
  ]])

Furthermore, if you follow the rule of thumb that literal text should
always be maximally quoted, then autoconf can help you out.
For example, if you decide that the above "action" should be
changed from literal shell output to a macro expansion, then
maximally quoted still has the nice property that it is easily
apparent that m4 expansion is being relied on, due to the
drop back to single-quoting in the middle:

AC_DEFINE([foo],
  [[
    case "$host_cpu" in
      i[34567]86) ]AC_FOO([argument])[ ;;
    esac
  ]])

not to mention the fact that if you forget to drop back to
single quoting, then autoconf warns you that an unexpanded
AC_FOO appears in ./configure.


Whereas, if you use changequote:

AC_DEFINE([foo],
  [
    changequote(,)
    case "$host_cpu" in
      i[34567]86) AC_FOO([argument]) ;;
    esac
  ])

you have just broken your use of AC_FOO, since it is now passed
a literal "[argument]" instead of the desired "argument", not to
mention that all quoting during the expansion of AC_FOO
is hosed.  And since the macro got expanded, albeit incorrectly,
autoconf can't warn you that a literal AC_FOO still appears in
your ./configure.

One more misfeature of changequote - changequote(,) is not
portable.  The BSD folks have been trying to get their m4
implementation to copy enough of GNU m4's traits that it
can be used in place of GNU M4 to support autoconf.  I don't
know if they will ever acheive that, but I DO know that in the
current source code of BSD m4, "changequote(,)" behaves
like "changequote" (ie. sets the quotes to ` and ') rather than
the GNU behavior of disabling quotes.  By using changequote,
you are actually hurting yourself if BSD m4 ever becomes an
acceptable substitute for GNU m4 for autoconf's purposes.

-- 
Eric Blake




reply via email to

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