Next: Looping constructs, Up: Programming in M4sugar
With a few exceptions, all the M4 native macros are moved in the
`m4_' pseudo-namespace, e.g., M4sugar renames define as
m4_define etc.
   
Some M4 macros are redefined, and are slightly incompatible with their native equivalent.
Unlike the M4 builtin, this macro fails if macro is not defined. See
m4_undefine.
Like the M4 builtins, but warn against multiple inclusions of file.
This macro corresponds to
patsubst. The namem4_patsubstis kept for future versions of M4sh, on top of GNU M4 which will provide extended regular expression syntax viaepatsubst.
Unlike the M4 builtin, this macro fails if macro is not defined. See
m4_undefine.
This macro corresponds to
regexp. The namem4_regexpis kept for future versions of M4sh, on top of GNU M4 which will provide extended regular expression syntax viaeregexp.
This macro corresponds to
m4wrap.Posix requires arguments of multiple
m4wrapcalls to be reprocessed at EOF in the same order as the original calls. GNU M4 versions through 1.4.x, however, reprocess them in reverse order. Your code should not depend on the order.Also, Posix requires
m4wrapto ignore its second and succeeding arguments, but GNU M4 versions through 1.4.x concatenate the arguments with intervening spaces. Your code should not pass more than one argument.You are encouraged to end text with `[]', to avoid unexpected token pasting between consecutive invocations of
m4_wrap, as in:m4_define([foo], [bar]) m4_define([foofoo], [OUCH]) m4_wrap([foo]) m4_wrap([foo]) =>OUCH
Unlike the M4 builtin, this macro fails if macro is not defined. Use
m4_ifdef([macro], [m4_undefine([macro])])to recover the behavior of the builtin.
Posix requires
maketempto replace the trailing `X' characters in template with the process id, without regards to the existence of a file by that name, but this a security hole. When this was pointed out to the Posix folks, they agreed to invent a new macromkstempthat always creates a uniquely named file, but not all versions of GNU M4 support the new macro. In M4sugar,m4_maketempandm4_mkstempare synonyms for each other, and both have the secure semantics regardless of which macro the underlying M4 provides.