manpagez: man pages & more
info autoconf
Home | html | info | man

File: autoconf.info,  Node: Quadrigraphs,  Next: Balancing Parentheses,  Prev: Changequote is Evil,  Up: M4 Quotation

8.1.6 Quadrigraphs
------------------

When writing an Autoconf macro you may occasionally need to generate
special characters that are difficult to express with the standard
Autoconf quoting rules.  For example, you may need to output the regular
expression ‘[^[]’, which matches any character other than ‘[’.  This
expression contains unbalanced brackets so it cannot be put easily into
an M4 macro.

   Additionally, there are a few m4sugar macros (such as ‘m4_split’ and
‘m4_expand’) which internally use special markers in addition to the
regular quoting characters.  If the arguments to these macros contain
the literal strings ‘-=<{(’ or ‘)}>=-’, the macros might behave
incorrectly.

   You can work around these problems by using one of the following
“quadrigraphs”:

‘@<:@’
     ‘[’
‘@:>@’
     ‘]’
‘@S|@’
     ‘$’
‘@%:@’
     ‘#’
‘@{:@’
     ‘(’
‘@:}@’
     ‘)’
‘@&t@’
     Expands to nothing.

   Quadrigraphs are replaced at a late stage of the translation process,
after ‘m4’ is run, so they do not get in the way of M4 quoting.  For
example, the string ‘^@<:@’, independently of its quotation, appears as
‘^[’ in the output.

   The empty quadrigraph can be used:

   − to mark trailing spaces explicitly

     Trailing spaces are smashed by ‘autom4te’.  This is a feature.

   − to produce quadrigraphs and other strings reserved by m4sugar

     For instance ‘@<@&t@:@’ produces ‘@<:@’.  For a more contrived
     example:

          m4_define([a], [A])m4_define([b], [B])m4_define([c], [C])dnl
          m4_split([a )}>=- b -=<{( c])
          ⇒[a], [], [B], [], [c]
          m4_split([a )}@&t@>=- b -=<@&t@{( c])
          ⇒[a], [)}>=-], [b], [-=<{(], [c]

   − to escape _occurrences_ of forbidden patterns

     For instance you might want to mention ‘AC_FOO’ in a comment, while
     still being sure that ‘autom4te’ still catches unexpanded ‘AC_*’.
     Then write ‘AC@&t@_FOO’.

   The name ‘@&t@’ was suggested by Paul Eggert:

     I should give some credit to the ‘@&t@’ pun.  The ‘&’ is my own
     invention, but the ‘t’ came from the source code of the ALGOL68C
     compiler, written by Steve Bourne (of Bourne shell fame), and which
     used ‘mt’ to denote the empty string.  In C, it would have looked
     like something like:

          char const mt[] = "";

     but of course the source code was written in Algol 68.

     I don't know where he got ‘mt’ from: it could have been his own
     invention, and I suppose it could have been a common pun around the
     Cambridge University computer lab at the time.

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.