Autoconf 2.57 defines a macro m4_do as follows:
m4_define([m4_do], [m4_if($#, 0, [], $#, 1, [$1], [$1[]m4_do(m4_shift($@))])])
This definition is contained in the Autoconf 2.57 source file m4sugar.m4, which was taken from the Autoconf CVS repository under lib/m4sugar/m4sugar.m4 revision 2.68.
For example, you might include the following lines and comments:
# For quotation, m4 uses ` ' but Autoconf uses [ ]. changequote([,]) # To define a macro, m4 uses "define" but Autoconf uses "m4_define". define([m4_define], defn([define]))
Write a text file hw1.m4 with the following contents, in order:
{m4_do()} {m4_do(1)} {m4_do(1, 2)} {m4_do([m4_do(3, 4)], [[dnl not 5]], 6)} {m4_do([m4_define([foo], [bar])], [foo])} {m4_do([m4_define([foo1], [bar])], [m4_define([abark], [abite])], [a], [foo], [k])}
If your hw1.m4 file is constructed correctly and you are using GNU m4, the command:
m4 hw1.m4
should output the following lines:
{} {1} {12} {34dnl not 56}
and so forth for each test case. Only the first four test outputs are given here; the others are left as an exercise for the reader. The curly braces {} merely show you where each test case starts and stops, and are not necessary to invoke the macros themselves.
To turn in your assignment, submit the file hw1.m4.