[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: macro name with `:'
From: |
Eric Blake |
Subject: |
Re: macro name with `:' |
Date: |
Tue, 21 Sep 2010 10:48:47 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.3 |
On 09/21/2010 08:46 AM, Marc Chantreux wrote:
hello guys,
define(`H1',"ok ... this is title ")
works fine and i would like to figure out how to make this work:
define(`H1:',"ok ... this is title ")
Depends on what you mean by work.
If you intend for your script to be portable to POSIX m4 (that is,
behave the same in Solaris and BSD implementations of m4), then you are
doomed to failure - it is not portable to define a macro that doesn't
have an invocable name.
If you only care about GNU m4, then it depends on what you want to do
with that macro. Your definition worked just fine, what you are lacking
is a way to invoke the macro.
In all versions of GNU m4, you can use:
indir(`H1:', args)
as a way to invoke an oddly-named macro with the given set of args.
Likewise, you can also use defn(`H1:') to get at the definition of the
macro. In fact, autoconf makes extensive use of the indir builtin
exactly for it's ability to call macros that can't be mistakenly invoked
outside of an indir.
If you built m4 1.4.x with the --enable-changeword configure option,
then you can use:
changeword(`[a-zA-Z_][a-zA-Z0-9_:]*')
H1:()
as a way of invoking the macro, basically by redefining the set of valid
macro names. However, use of the changeword builtin causes an
order-of-magnitude slowdown in m4 operation, and as such, is not enabled
by default, and will be withdrawn from future m4 builds.
If you built bleeding edge m4.git (which will someday become m4 2.0),
you can use the changesyntax() builtin to do all that changeword was
doing, and more, and without the speed penalty. But that means relying
on unreleased software, which is subject to change.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org