autoconf
[Top][All Lists]
Advanced

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

Re: [gettext] changequote considered harmful


From: Gary V. Vaughan
Subject: Re: [gettext] changequote considered harmful
Date: Wed, 03 Aug 2005 09:44:40 +0100
User-agent: Mozilla Thunderbird 1.0 (X11/20050305)

Hi Bruno, Stepan,

Bruno Haible wrote:

The desirable way to mix C or sh syntax and a macro language - for me as
someone who has to maintain some of these macros - is so that
  1) A valid C or sh snippet without specific macro invocations is
     valid inside the macro, and does not change its meaning.
     Brackets count as normal C or sh syntax here, since they are frequent
     in C and sh.
  2) There is a way to insert macro invocation in C or sh snippets,
     either directly by writing    MACRONAME(ARGS)   or with some similar
     syntax.
  3) There is normally no need to switch into a TeX {verbatim} or XML CDATA
     section, because 1) is usually enough.

[[snip]]

The style that fulfills goals 1 and 2 here is like this:

  [...
    # Found it, now check the version.
    ]AC_MSG_CHECKING([version of bison])[
    ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* 
\([0-9]*\.[0-9.]*\).*$/\1/p'`
    case $ac_prog_version in
      '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
      1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
         ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
      *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
    esac
    ]AC_MSG_RESULT([$ac_prog_version])[
  ...]

I.e. put braces around everything, but unbrace the macro invocations and
don't put dnl comments. Unfortunately as long as autoconf does not recommend
this style, other people will not like this style; therefore I cannot really
use this style yet.

In the bad old days, before I understood this idiom, I used to write (and libtool still contains code in this style :-():

     # Found it, now check the version.
     AC_MSG_CHECKING([version of bison])
ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([[0-9]]*\.[[0-9.]]*\).*$/\1/p'`
     case $ac_prog_version in
       '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
       1.2[[6-9]]* | 1.[[3-9]][[0-9]]* | [[2-9]].*)
          ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
       *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
     esac
     AC_MSG_RESULT([$ac_prog_version])

which, as you point out is ugly and error prone. More recently I have been writing code as you describe above, and life is much better. Whether the style is widely accepted or understood yet is not an issue IMNSHO, it is *correct*... and that is far more important. It will become acceptable style as more projects adopt it when they realise it is the technically correct thing to do!

Cheers,
        Gary.
--
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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