Re: How to not expand in strings

"Gary V. Vaughan" <[email protected]>
Newsgroups gmane.comp.gnu.m4.general
Message-ID <[email protected]>
Hi Mike,

On 1 Oct 2010, at 11:00, Mike Gran wrote:
> I need to avoid processing
> a curly bracket that appears inside a string, as in the 
> following
> 
> (set! str 
>      m4_ifdef({USE_REGEX},
>               {" } "},
>               {" > "}))

This is what changequote was designed for.  If you want to avoid
using it, then you can either pick a different quote character,
perhaps using a multi-character string to avoid clashing with
legitimate uses by the surrounding text -- maybe something like

  m4_changequote(,)
  m4_changequote({:,:})

or you could have a post-processing stage that substitutes unlikely
strings when m4 has finished, like Autoconf does with quadrigraphs:

  m4_ifdef({USE_REGEX},
           {" @:)@ "},
           {" > "}))

  m4 source-file.m4 | sed 's|@:)@|}|g;s|@(:@|{|g' > out-file.scm

Cheers,
-- 
Gary V. Vaughan ([email protected])
PGP.sig (application/pgp-signature, 195 B) - not displayed
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.