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

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.general
Organization Red Hat
Message-ID <[email protected]>
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   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.