m4-discuss
[Top][All Lists]
Advanced

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

Re: Simple method of including a file that bypasses macro expansion


From: Eric Blake
Subject: Re: Simple method of including a file that bypasses macro expansion
Date: Mon, 18 Jul 2011 13:00:56 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.11

On 07/17/2011 01:15 AM, John Allsup (M4) wrote:
Hi,

I am relatively new to m4, but can't seem to find an equivalent to include that
bypasses macro expansion.

If you are okay with GNU extensions, then the 'undivert' macro is what you are looking for:

http://www.gnu.org/software/m4/manual/m4.html#Undivert


Suppose file 'a' contains
   hello world
and file 'b' contains
   goodbye world
and in my m4 I have defined
   define(world,and).

I'd recommend getting in the habit of using full quoting:

define(`world', `and')

I a macro which I will call 'oinclude' such that
   include(a) oinclude(b)
expands to
   hello and goodbye world.

include(`a') undivert(`b').

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

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