Previous: Text processing Macros, Up: Programming in M4sugar


8.3.5 Forbidden Patterns

M4sugar provides a means to define suspicious patterns, patterns describing tokens which should not be found in the output. For instance, if an Autoconf configure script includes tokens such as ‘AC_DEFINE’, or ‘dnl’, then most probably something went wrong (typically a macro was not evaluated because of overquotation).

M4sugar forbids all the tokens matching ‘^m4_’ and ‘^dnl$’.

— Macro: m4_pattern_forbid (pattern)

Declare that no token matching pattern must be found in the output. Comments are not checked; this can be a problem if, for instance, you have some macro left unexpanded after an ‘#include’. No consensus is currently found in the Autoconf community, as some people consider it should be valid to name macros in comments (which doesn't make sense to the author of this documentation, as ‘#’-comments should document the output, not the input, documented by ‘dnl’ comments).

Of course, you might encounter exceptions to these generic rules, for instance you might have to refer to ‘$m4_flags’.

— Macro: m4_pattern_allow (pattern)

Any token matching pattern is allowed, including if it matches an m4_pattern_forbid pattern.