DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(m4.info.gz) Changequote

Info Catalog (m4.info.gz) Dnl (m4.info.gz) Input Control (m4.info.gz) Changecom
 
 7.2 Changing the quote characters
 =================================
 
 The default quote delimiters can be changed with the builtin
 `changequote':
 
  -- Builtin: changequote ([START = ``'], [END = `''])
      This sets START as the new begin-quote delimiter and END as the
      new end-quote delimiter.  If any of the arguments are missing, the
      default quotes (``' and `'') are used instead of the void
      arguments.
 
      The expansion of `changequote' is void.
 
      changequote(`[', `]')
      =>
      define([foo], [Macro [foo].])
      =>
      foo
      =>Macro foo.
 
    The quotation strings can safely contain eight-bit characters.  If
 no single character is appropriate, START and END can be of any length.
 
      changequote(`[[[', `]]]')
      =>
      define([[[foo]]], [[[Macro [[[[[foo]]]]].]]])
      =>
      foo
      =>Macro [[foo]].
 
    Changing the quotes to the empty strings will effectively disable the
 quoting mechanism, leaving no way to quote text.
 
      define(`foo', `Macro `FOO'.')
      =>
      changequote(, )
      =>
      foo
      =>Macro `FOO'.
      `foo'
      =>`Macro `FOO'.'
 
    There is no way in `m4' to quote a string containing an unmatched
 begin-quote, except using `changequote' to change the current quotes.
 
    If the quotes should be changed from, say, `[' to `[[', temporary
 quote characters have to be defined.  To achieve this, two calls of
 `changequote' must be made, one for the temporary quotes and one for
 the new quotes.
 
    Macros are recognized in preference to the begin-quote string, so if
 a prefix of START can be recognized as a potential macro name, the
 quoting mechanism is effectively disabled.  Unless you use `changeword'
 ( Changeword), this means that START should not begin with a
 letter or `_' (underscore).
 
      define(`hi', `HI')
      =>
      changequote(`q', `Q')
      =>
      q hi Q hi
      =>q HI Q HI
      changequote
      =>
      changequote(`-', `EOF')
      =>
      - hi EOF hi
      => hi  HI
 
    Quotes are recognized in preference to argument collection.  In
 particular, if START is a single `(', then argument collection is
 effectively disabled.  For portability with other implementations, it
 is a good idea to avoid `(', `,', and `)' as the first character in
 START.
 
      define(`echo', `$#:$@:')
      =>
      define(`hi', `HI')
      =>
      changequote(`(',`)')
      =>
      echo(hi)
      =>0::hi
      changequote
      =>
      changequote(`((', `))')
      =>
      echo(hi)
      =>1:HI:
      echo((hi))
      =>0::hi
      changequote
      =>
      changequote(`,', `)')
      =>
      echo(hi,hi)bye)
      =>1:HIhibye:
 
    If END is a prefix of START, the end-quote will be recognized in
 preference to a nested begin-quote.  In particular, changing the quotes
 to have the same string for START and END disables nesting of quotes.
 When quote nesting is disabled, it is impossible to double-quote
 strings across macro expansions, so using the same string is not done
 very often.
 
      define(`hi', `HI')
      =>
      changequote(`""', `"')
      =>
      ""hi"""hi"
      =>hihi
      ""hi" ""hi"
      =>hi hi
      ""hi"" "hi"
      =>hi" "HI"
      changequote
      =>
      `hi`hi'hi'
      =>hi`hi'hi
      changequote(`"', `"')
      =>
      "hi"hi"hi"
      =>hiHIhi
 
    It is an error if the end of file occurs within a quoted string.
 
      `dangling quote
      ^D
      error-->m4:stdin:1: ERROR: end of file in string
 
Info Catalog (m4.info.gz) Dnl (m4.info.gz) Input Control (m4.info.gz) Changecom
automatically generated byinfo2html