summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/COPYING8
-rw-r--r--doc/examples/WWW/COPYING8
-rw-r--r--doc/examples/WWW/Makefile45
-rw-r--r--doc/examples/WWW/_footer.htm10
-rw-r--r--doc/examples/WWW/_header.htm231
-rw-r--r--doc/examples/WWW/m4lib/COPYING8
-rw-r--r--doc/examples/WWW/m4lib/bugs.m453
-rw-r--r--doc/examples/WWW/m4lib/changelog.m418
-rw-r--r--doc/examples/WWW/m4lib/download.m424
-rw-r--r--doc/examples/WWW/m4lib/features.m458
-rw-r--r--doc/examples/WWW/m4lib/feedback.m420
-rw-r--r--doc/examples/WWW/m4lib/html.m4122
-rw-r--r--doc/examples/WWW/m4lib/index.m436
-rw-r--r--doc/examples/WWW/m4lib/layout.m465
-rw-r--r--doc/examples/WWW/m4lib/lists.m432
-rw-r--r--doc/examples/WWW/m4lib/menu.m474
-rw-r--r--doc/examples/WWW/m4lib/modules.m418
-rw-r--r--doc/examples/WWW/m4lib/news.m418
-rw-r--r--doc/examples/WWW/m4lib/readme.m418
-rw-r--r--doc/examples/WWW/m4lib/setup.m47
-rw-r--r--doc/examples/WWW/m4lib/test.m429
-rw-r--r--doc/examples/WWW/m4lib/thanks.m418
-rw-r--r--doc/examples/WWW/m4lib/thissite.m442
-rw-r--r--doc/examples/WWW/m4lib/tmpl.m411
-rw-r--r--doc/examples/WWW/m4lib/todo.m418
-rw-r--r--doc/examples/WWW/m4lib/uses.m443
-rw-r--r--doc/examples/WWW/m4lib/visions.m4232
-rw-r--r--doc/examples/WWW/m4lib/whatis.m448
-rw-r--r--doc/examples/capitalize.m412
-rw-r--r--doc/examples/capitalize2.m419
-rw-r--r--doc/examples/comments.m47
-rw-r--r--doc/examples/curry.m47
-rw-r--r--doc/examples/ddivert.m44
-rw-r--r--doc/examples/debug.m44
-rw-r--r--doc/examples/esyscmd.m46
-rw-r--r--doc/examples/exp.m43
-rw-r--r--doc/examples/foreach.m48
-rw-r--r--doc/examples/foreach2.m410
-rw-r--r--doc/examples/foreachq.m49
-rw-r--r--doc/examples/foreachq2.m410
-rw-r--r--doc/examples/foreachq3.m49
-rw-r--r--doc/examples/foreachq4.m413
-rw-r--r--doc/examples/forloop.m46
-rw-r--r--doc/examples/forloop2.m412
-rw-r--r--doc/examples/forloop3.m413
-rw-r--r--doc/examples/fstab.m46
-rw-r--r--doc/examples/hanoi.m417
-rw-r--r--doc/examples/incl-test.m43
-rw-r--r--doc/examples/incl.m43
-rw-r--r--doc/examples/include.m47
-rw-r--r--doc/examples/indir.m410
-rw-r--r--doc/examples/join.m415
-rw-r--r--doc/examples/loop.m418
-rw-r--r--doc/examples/misc.m48
-rw-r--r--doc/examples/modtest.m47
-rw-r--r--doc/examples/multiquotes.m417
-rw-r--r--doc/examples/patsubst.m48
-rw-r--r--doc/examples/pushpop.m425
-rw-r--r--doc/examples/quote.m49
-rw-r--r--doc/examples/regexp.m412
-rw-r--r--doc/examples/reverse.m44
-rw-r--r--doc/examples/shadow.m457
-rw-r--r--doc/examples/stack.m416
-rw-r--r--doc/examples/stack_sep.m417
-rw-r--r--doc/examples/stdlib.m444
-rw-r--r--doc/examples/sysv-args.m414
-rw-r--r--doc/examples/time.m420
-rw-r--r--doc/examples/time2.m418
-rw-r--r--doc/examples/trace.m430
-rw-r--r--doc/examples/translit.m48
-rw-r--r--doc/examples/undivert.incl1
-rw-r--r--doc/examples/undivert.m45
-rw-r--r--doc/examples/wrap.m410
-rw-r--r--doc/examples/wrapfifo.m410
-rw-r--r--doc/examples/wraplifo.m410
-rw-r--r--doc/examples/wraplifo2.m49
-rw-r--r--doc/m4.texi154
77 files changed, 1981 insertions, 77 deletions
diff --git a/doc/examples/COPYING b/doc/examples/COPYING
new file mode 100644
index 00000000..0b2d09ee
--- /dev/null
+++ b/doc/examples/COPYING
@@ -0,0 +1,8 @@
+The files in this directory provide example uses of GNU M4.
+The following copyright notice applies to each of these
+description files.
+
+Copyright (C) 2006, 2010, 2013 Free Software Foundation, Inc.
+This file is free software; the Free Software Foundation
+gives unlimited permission to copy and/or distribute it,
+with or without modifications, as long as this notice is preserved.
diff --git a/doc/examples/WWW/COPYING b/doc/examples/WWW/COPYING
new file mode 100644
index 00000000..0b2d09ee
--- /dev/null
+++ b/doc/examples/WWW/COPYING
@@ -0,0 +1,8 @@
+The files in this directory provide example uses of GNU M4.
+The following copyright notice applies to each of these
+description files.
+
+Copyright (C) 2006, 2010, 2013 Free Software Foundation, Inc.
+This file is free software; the Free Software Foundation
+gives unlimited permission to copy and/or distribute it,
+with or without modifications, as long as this notice is preserved.
diff --git a/doc/examples/WWW/Makefile b/doc/examples/WWW/Makefile
new file mode 100644
index 00000000..c296ccf4
--- /dev/null
+++ b/doc/examples/WWW/Makefile
@@ -0,0 +1,45 @@
+M4 = ./m4/src/m4
+M4OPTS = -Im4lib
+
+VPATH = .:m4lib
+
+HTM = _footer.htm _header.htm bugs.htm changelog.htm download.htm \
+ features.htm feedback.htm index.htm lists.htm modules.htm \
+ news.htm readme.htm thanks.htm thissite.htm todo.htm uses.htm \
+ visions.htm whatis.htm
+
+M4LIB = m4lib/bugs.m4 m4lib/changelog.m4 m4lib/download.m4 \
+ m4lib/features.m4 m4lib/feedback.m4 m4lib/html.m4 \
+ m4lib/index.m4 m4lib/layout.m4 m4lib/lists.m4 m4lib/menu.m4 \
+ m4lib/modules.m4 m4lib/news.m4 m4lib/readme.m4 \
+ m4lib/setup.m4 m4lib/test.m4 m4lib/thanks.m4 \
+ m4lib/thissite.m4 m4lib/tmpl.m4 m4lib/todo.m4 m4lib/uses.m4 \
+ m4lib/visions.m4 m4lib/whatis.m4
+
+all: ./m4 $(HTM)
+
+./m4:
+ ln -s ../.. m4
+
+%.htm: %.m4
+ @$(M4) $(M4OPTS) $< >new.htm && \
+ if cmp new.htm $@ >/dev/null 2>&1; then \
+ rm new.htm; \
+ echo "$@ has not changed"; \
+ else \
+ echo "$@ updated"; \
+ mv new.htm $@; \
+ fi
+
+.FORCE:
+$(HTM): .FORCE $(M4LIB)
+
+changelog.htm: m4/ChangeLog
+readme.htm: m4/README
+todo.htm: m4/TODO
+news.htm: m4/NEWS
+modules.htm: m4/modules/README
+
+.PHONY: man
+man:
+ cd man; $(MAKE)
diff --git a/doc/examples/WWW/_footer.htm b/doc/examples/WWW/_footer.htm
new file mode 100644
index 00000000..6bed8f2c
--- /dev/null
+++ b/doc/examples/WWW/_footer.htm
@@ -0,0 +1,10 @@
+</TD>
+
+</TR>
+
+</TABLE>
+
+</BODY>
+
+
+</HTML>
diff --git a/doc/examples/WWW/_header.htm b/doc/examples/WWW/_header.htm
new file mode 100644
index 00000000..1aea7999
--- /dev/null
+++ b/doc/examples/WWW/_header.htm
@@ -0,0 +1,231 @@
+<!DOCTYPE html public "-//w3c//dtd html 4.0 transitional//en">
+<HTML>
+<HEAD>
+<TITLE>GNU m4 - Development site</TITLE>
+<META NAME="AUTHOR" CONTENT="René Seindal">
+<META NAME="GENERATOR" CONTENT="GNU m4 __m4_version__">
+</HEAD>
+ <BODY text="#000000" bgcolor="#FFCC99" link="#0000EF" alink="#FF0000" vlink="#51188E">
+<TABLE cellpadding=5 width="100%">
+<TR align=left valign=bottom>
+<TD align=center valign=middle colspan="3" width="100%" bgcolor="#FF9900">
+
+<H1>GNU m4</H1>
+
+<H2>Discussion Forum</H2>
+
+</TD>
+
+</TR>
+ <TR >
+<TD align=left valign=top width="15%" bgcolor="#FF9900">
+
+
+
+
+
+
+
+
+
+
+
+<TABLE >
+<TR>
+<TD bgcolor="#CC6600">
+<P>
+<B>General info</B>
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD>
+<P>
+
+<FONT size=-1><B><A HREF="/rene/gnu/whatis.htm">What is m4</A><BR>
+<A HREF="/rene/gnu/features.htm">Features</A><BR>
+<A HREF="/rene/gnu/uses.htm">Uses of m4</A></B></FONT>
+
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD height=5>
+
+</TD>
+
+</TR>
+ <TR>
+<TD bgcolor="#CC6600">
+<P>
+<B>Documentation</B>
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD>
+<P>
+
+<FONT size=-1><B><A HREF="/rene/gnu/man/m4_toc.html">Manual</A></B></FONT>
+
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD height=5>
+
+</TD>
+
+</TR>
+ <TR>
+<TD bgcolor="#CC6600">
+<P>
+<B>Source files</B>
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD>
+<P>
+
+<FONT size=-1><B><A HREF="/rene/gnu/readme.htm">README</A><BR>
+<A HREF="/rene/gnu/todo.htm">TODO</A><BR>
+<A HREF="/rene/gnu/news.htm">NEWS</A><BR>
+<A HREF="/rene/gnu/changelog.htm">ChangeLog</A><BR>
+<A HREF="/rene/gnu/thanks.htm">Contributors</A><BR>
+<A HREF="/rene/gnu/m4/">Browse it</A></B></FONT>
+
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD height=5>
+
+</TD>
+
+</TR>
+ <TR>
+<TD bgcolor="#CC6600">
+<P>
+<B>The Future</B>
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD>
+<P>
+
+<FONT size=-1><B><A HREF="/rene/gnu/modules.htm">Modules</A><BR>
+<A HREF="/rene/gnu/visions.htm">Visions</A></B></FONT>
+
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD height=5>
+
+</TD>
+
+</TR>
+ <TR>
+<TD bgcolor="#CC6600">
+<P>
+<B>Feedback</B>
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD>
+<P>
+
+<FONT size=-1><B><A HREF="/rene/gnu/lists.htm">Mailing-lists</A><BR>
+<A HREF="/rene/gnu/feedback.htm">Feedback</A><BR>
+
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD height=5>
+
+</TD>
+
+</TR>
+ <TR>
+<TD bgcolor="#CC6600">
+<P>
+<B>Development</B>
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD>
+<P>
+
+<FONT size=-1><B><A HREF="/rene/gnu/download.htm">Download</A><BR>
+<A HREF="/rene/gnu/bugs.htm">Known bugs</A></B></FONT>
+
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD height=5>
+
+</TD>
+
+</TR>
+ <TR>
+<TD bgcolor="#CC6600">
+<P>
+<B>Examples</B>
+</P>
+
+</TD>
+
+</TR>
+ <TR>
+<TD>
+<P>
+
+<FONT size=-1><B><A HREF="/rene/gnu/thissite.htm">This site</A></B></FONT>
+
+</P>
+
+</TD>
+
+</TR>
+
+</TABLE>
+
+
+
+
+
+
+
+
+</TD>
+ <TD align=left valign=top width="90%">
diff --git a/doc/examples/WWW/m4lib/COPYING b/doc/examples/WWW/m4lib/COPYING
new file mode 100644
index 00000000..0b2d09ee
--- /dev/null
+++ b/doc/examples/WWW/m4lib/COPYING
@@ -0,0 +1,8 @@
+The files in this directory provide example uses of GNU M4.
+The following copyright notice applies to each of these
+description files.
+
+Copyright (C) 2006, 2010, 2013 Free Software Foundation, Inc.
+This file is free software; the Free Software Foundation
+gives unlimited permission to copy and/or distribute it,
+with or without modifications, as long as this notice is preserved.
diff --git a/doc/examples/WWW/m4lib/bugs.m4 b/doc/examples/WWW/m4lib/bugs.m4
new file mode 100644
index 00000000..5d8e5f52
--- /dev/null
+++ b/doc/examples/WWW/m4lib/bugs.m4
@@ -0,0 +1,53 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([Known bugs in GNU m4 \__m4_version__])
+
+\divert(1)
+\h2([Known bugs in GNU m4])
+
+\define([fixed], [\p([Fixed in version 1.4$1])])
+
+\define([notme], [\p([A <A
+HREF="mailto:m4-feedback@seindal.dk?subject=GNU m4: \defn([_item])"
+>volunteer</A> is badly needed for this, as I have no way of testing
+this myself.])])
+
+\ul([
+
+\item([undivert], [undivert(0) might read from standard output],
+
+[\p([If calling \tt(undivert(0)) when diverting to a non-zero diversion
+will cause m4 to read from standard output in an attempt to bring back
+diversion 0, which is not possible.])
+
+\fixed(n)
+
+])
+
+\item([sigaltstack], [failure if sigaltstack or sigstack returns ENOSYS],
+
+[\p([If stack overflow detection is configured but the system doesn't
+support sigaltstack(2) or sigstack(2), m4 fails when the system call
+returns ENOSYS. It should silently revert to default behaviour.])
+
+\notme
+])
+
+])
+
+\p([See also the \link(todo.htm, TODO) file.])
+
+\print_items
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
+
+
+\item([], [],
+
+[\p([])
+
+])
+\undivert
diff --git a/doc/examples/WWW/m4lib/changelog.m4 b/doc/examples/WWW/m4lib/changelog.m4
new file mode 100644
index 00000000..cdcab269
--- /dev/null
+++ b/doc/examples/WWW/m4lib/changelog.m4
@@ -0,0 +1,18 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([ChangeLog])
+
+\divert(1)
+
+<PRE>\dnl
+\changesyntax([A<>])\dnl
+\changequote(,)\dnl
+\include(m4/ChangeLog)
+\changequote([,])\dnl
+\changesyntax([O<>])\dnl
+</PRE>
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/download.m4 b/doc/examples/WWW/m4lib/download.m4
new file mode 100644
index 00000000..d9ee4095
--- /dev/null
+++ b/doc/examples/WWW/m4lib/download.m4
@@ -0,0 +1,24 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([Download])
+
+\divert(1)
+
+\p([In the download area there are usually several version
+present. Please take only the latest.])
+
+\p([The files are name \tt(m4-1.4\i(X).tar.gz) where X is a letter.])
+
+\p([\link([ftp://ftp.seindal.dk/pub/rene/gnu/], [Download latest
+development version]).])
+
+\p([\link([ftp://ftp.seindal.dk/pub/rene/gnu/m4-1.4.tar.gz],[Download
+latest stable version]).])
+
+\p([\link([ftp://ftp.seindal.dk/pub/rene/gnu/djgpp/],[Download
+DOS/Windows port of latest stable version]).])
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/features.m4 b/doc/examples/WWW/m4lib/features.m4
new file mode 100644
index 00000000..57b68c9e
--- /dev/null
+++ b/doc/examples/WWW/m4lib/features.m4
@@ -0,0 +1,58 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([New feaures since version 1.4])
+
+\divert(1)
+
+\p(Please look at the \link(news.htm, NEWS) and the \link(changelog.htm,
+ChangeLog) for all the gory details.)
+
+\dl(
+\dt(\b(GNU m4 uses GNU Automake and GNU Autoconf for configuration.))
+
+\dd(\p(This has been long overdue, and now hit is done thanks to Erick
+Branderhorst.))
+
+\dt(\b(GNU m4 uses GNU gettext for internationalisation.))
+
+\dd(\p(GNU m4 now speaks several languages. Translations for
+german, french, italian, japanese, dutch, polish, romenian and swedish
+have been made.))
+
+\dt(\b(Support for multiple precision arithmetic in eval.))
+
+\dd(\p(If appropriately configured, GNU m4 can now do multiple precision
+arithmetic in the built in macro 'eval'. If not configured, GNU m4
+will use the largest integer available for its calculations.))
+
+\dt(\b(An input syntax table to change how input is parsed.))
+
+\dd(\p(A new build in macro 'changesyntax' allows finer control over how input
+characters are parsed into input tokens.&nbsp; It is now possible to have
+several one character quote strings or comment delimiters, to change the
+format of macro calls, to use active characters like in TeX, and probably
+most useful, to change what input characters are treated as letters when
+looking for macro calls.)
+
+\p(See the \link(man/m4_7.html#SEC41, manual section) for more details.))
+
+\dt(\b(Support for loadable modules.))
+
+\dd(\p(GNU m4 now has support for dynamic loading of compiled modules at
+runtime. A module can define any number of new built in macros, which
+will be indistinguishable from the standard set of built in
+macros. Modules can also override existing built in macros.)
+)
+
+\dt(\b(Better control of sync-lines generation.))
+
+\dd(\p(The new built in macro 'syncoutput' allows better control of the
+generation of sync-lines. They can now be turned on or off at
+will.))
+
+)
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/feedback.m4 b/doc/examples/WWW/m4lib/feedback.m4
new file mode 100644
index 00000000..f61d63e5
--- /dev/null
+++ b/doc/examples/WWW/m4lib/feedback.m4
@@ -0,0 +1,20 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([Feedback])
+
+\divert(1)
+
+\p(Bug reports should be sent to \link(mailto:bug-m4@gnu.org,
+bug-m4@gnu.org).)
+
+\p(Generel discussion about GNU m4 should take place on
+\link(mailto:m4-forum@seindal.dk, m4-forum).)
+
+\p(Informal comments about this site and GNU m4 can be sent to
+\link(mailto:m4-feedback@seindal.dk, m4-feedback).)
+
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/html.m4 b/doc/examples/WWW/m4lib/html.m4
new file mode 100644
index 00000000..94ed69ed
--- /dev/null
+++ b/doc/examples/WWW/m4lib/html.m4
@@ -0,0 +1,122 @@
+\define([n], [
+])
+
+\define([concat], [\ifelse($#, 0, ,
+ $#, 1, [$1],
+ [$1 \concat(\shift($@))])])
+
+\define([toupper], [\translit([$*], [a-z], [A-Z])])
+
+\define([container],
+[\pushdef([_tag], \toupper([$1]))\dnl
+\ifelse($#, 1, [<\_tag></[\_tag]>],
+ $#, 2, [<\_tag>$2</\_tag>],
+ $#, 3, [<\_tag $2>$3</\_tag>],
+ [<\_tag $2>\concat(\shift(\shift($@)))</\_tag>])\dnl
+\popdef([_tag])\dnl
+])
+
+\define([large_container],
+[\pushdef([_tag], \toupper([$1]))\dnl
+\ifelse($#, 1, [<\_tag></\_tag>\n],
+ $#, 2, [<\_tag>\n[]$2\n</\_tag>\n],
+ $#, 3, [<\_tag $2>\n[]$3\n</\_tag>\n],
+ [<\_tag $2>\n\concat(\shift(\shift($@)))\n</\_tag>\n])\dnl
+\popdef([_tag])\dnl
+])
+
+\define([large_simple_container],
+[\pushdef([_tag], \toupper([$1]))\dnl
+<\_tag>\n\concat(\shift($@))\n</\_tag>\n\dnl
+\popdef([_tag])\dnl
+])
+
+\define([simple_container],
+[\pushdef([_tag], \toupper([$1]))\dnl
+<\_tag>\concat(\shift($@))</\_tag>\dnl
+\popdef([_tag])\dnl
+])
+
+\define([simple_tag],
+[\pushdef([_tag], \toupper([$1]))\dnl
+\ifelse([$2], [], [<\_tag>], [<\_tag $2>])\dnl
+\popdef([_tag])\dnl
+])
+
+\define([doctype], [\simple_tag([!DOCTYPE], $@)])
+
+\define([html], [\large_simple_container([$0], $@)])
+\define([head], [\large_simple_container([$0], $@)])
+\define([title], [\simple_container([$0], $@)])
+
+\define([meta], [\n<META NAME="[$1]" CONTENT="[$2]">])
+\define([http_equiv], [\n<META HTTP-EQUIV="[$1]" CONTENT="[$2]">])
+
+\define([body], [\large_container([$0], $@)])
+
+\define([center], [\large_simple_container([$0], $@)])
+\define([right], [\large_simple_container([$0], $@)])
+\define([left], [\large_simple_container([$0], $@)])
+\define([div], [\large_container([$0], $@)])
+
+\define([b], [\simple_container([$0], $@)])
+\define([i], [\simple_container([$0], $@)])
+\define([tt], [\simple_container([$0], $@)])
+
+\define([table], [\large_container([$0], $@)])
+\define([tr], [\large_container([$0], $@)])
+\define([td], [\large_container([$0], $@)])
+\define([th], [\large_container([$0], $@)])
+
+\define([link], [<A HREF="$1">\shift($*)</A>])
+\define([target], [<A NAME="$1">\shift($*)</A>])
+
+\define([font], [\n\container([$0], $@)\n])
+
+\define([h1], [\n\container([$0], $@)\n])
+\define([h2], [\n\container([$0], $@)\n])
+\define([h3], [\n\container([$0], $@)\n])
+\define([h4], [\n\container([$0], $@)\n])
+\define([h5], [\n\container([$0], $@)\n])
+\define([h6], [\n\container([$0], $@)\n])
+
+\define([p], [\large_simple_container([$0], $@)])
+
+\define([hr], [\simple_tag([$0], $@)])
+
+\define([ul], [\large_container([$0], $@)])
+\define([ol], [\large_container([$0], $@)])
+
+\define([li], [\simple_tag([$0], $@)])
+
+\define([blockquote], [\large_simple_container([$0], $@)])
+
+\define([dl], [\large_simple_container([$0], $@)])
+\define([dt], [\simple_container([$0], $@)])
+\define([dd], [\large_simple_container([$0], $@)])
+
+\define([br], [\simple_tag([$0], $@)])
+\define([hline], [\simple_tag([$0], $@)])
+
+\define([pre], [\simple_container([$0], $@)])
+
+
+
+\define([set_title], [\define([_TITLE], [$*])])
+\set_title(_TITLE)
+
+\define([set_author], [\define([_AUTHOR], [$*])])
+\set_author()
+
+\define([set_generator], [\define([_GENERATOR], [$*])])
+\set_generator([GNU m4 \__m4_version__])
+
+\define([set_keywords], [\define([_KEYWORDS], [$*])])
+\set_keywords()
+
+\define([set_body], [\define([_BODY], [$*])])
+\set_body()
+
+\define([meta_if_set],
+ [\ifelse(\defn([_$1]), [], [], \meta([$1], \defn([_$1])))]\dnl
+)
diff --git a/doc/examples/WWW/m4lib/index.m4 b/doc/examples/WWW/m4lib/index.m4
new file mode 100644
index 00000000..dbccc67b
--- /dev/null
+++ b/doc/examples/WWW/m4lib/index.m4
@@ -0,0 +1,36 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([Development site])
+
+\divert(1)
+\h2([Current development version is \__m4_version__.])
+
+\p([Development versions contain new features and experiments that might
+or might not make it into the next official release. The current
+development version contains among other things (browse the
+\link([features.htm], [new features]) for more detail):])
+
+\ul([
+ \li Uses GNU Automake and GNU Autoconf for configuration.
+
+ \li Uses GNU gettext for internationalisation.
+
+ \li Support for multiple precision arithmetic in eval.
+
+ \li An input syntax table to change how input is parsed.
+
+ \li Support for loadable modules.
+
+ \li Better control of sync-lines generation.
+
+ \li Various bug-fixes.
+])
+
+\p([A new release is expected ready for Spring 2000.])
+
+\p([GNU \tt(m4) 1.4 is from october 1994 and can be considered stable.])
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/layout.m4 b/doc/examples/WWW/m4lib/layout.m4
new file mode 100644
index 00000000..e54002db
--- /dev/null
+++ b/doc/examples/WWW/m4lib/layout.m4
@@ -0,0 +1,65 @@
+\divert(-1);
+The semicolons are just to get GNU Emacs C mode to indent properly.
+
+\define([C_TEXT], [text="#000000"]);
+\define([C_LINK], [link="#0000EF"]);
+\define([C_ALINK], [vlink="#51188E"]);
+\define([C_VLINK], [alink="#FF0000"]);
+\define([C_BG1], [bgcolor="#FFCC99"]);
+\define([C_BG2], [bgcolor="#FF9900"]);
+\define([C_BG3], [bgcolor="#CC6600"]);
+
+\define([DO_HEADER],
+ [\head([\title([GNU m4 - \defn([_TITLE])])],
+ [\meta_if_set([AUTHOR])],
+ [\meta_if_set([GENERATOR])],
+ [\meta_if_set([KEYWORDS])],
+ )]);
+
+\define([DO_BODY],
+ [\body([\C_TEXT \C_BG1 \C_LINK \C_VLINK \C_ALINK],
+ [\table([cellpadding=5 width="100%"],
+ [\tr([align=left valign=bottom],
+ [\td([align=center valign=middle colspan="3" width="100%" \C_BG2],
+ [\h1([GNU m4])],
+ [\h2(\defn([_TITLE]))],
+ )],
+ )],
+ [\tr([],
+ [\td([align=left valign=top width="15%" \C_BG2],
+ [\include([menu.m4])],
+ )],
+ [\td([align=left valign=top width="90%"],
+ [$*],
+ )],
+ )],
+ )],
+ )]
+ );
+
+\define([DO_LAYOUT],
+ [\doctype([html public "-//w3c//dtd html 4.0 transitional//en"])
+\html([\DO_HEADER], [\DO_BODY([$*])])]
+ );
+
+\define([<], [&lt;]);
+\define([>], [&gt;]);
+
+\define([showlink], [\link($1, $1)]);
+\define([mailto], [\link(mailto:$1, $1)]);
+
+
+<!-- These macros are for having first a simple toc and later a more
+thorough description of each item -->
+
+\define([print_items], [\undivert(2)])
+
+\define([item], [\li \link([[#]$1], [$2.])
+\pushdef([_div], \divnum)\dnl
+\divert(2)\dnl
+\hr([align=center width="50%"])\dnl
+\h2([\target([$1], [$2])])\dnl
+$3\dnl
+\divert(\_div)\dnl
+\popdef([_div])\dnl
+])
diff --git a/doc/examples/WWW/m4lib/lists.m4 b/doc/examples/WWW/m4lib/lists.m4
new file mode 100644
index 00000000..cc710eba
--- /dev/null
+++ b/doc/examples/WWW/m4lib/lists.m4
@@ -0,0 +1,32 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([Mailing lists])
+
+\define([me], \link([mailto:rene@seindal.dk], [rene@seindal.dk]))
+
+\divert(1)
+
+\h3(There are two mailing lists for GNU m4)
+
+\dl(
+
+\dt(\b(\link(mailto:m4-forum@seindal.dk, m4-forum@seindal.dk)))
+
+\dd(\p(This list is intended for discussions between people interested
+and/or participating in the further development of m4.))
+
+\dt(\b(m4-announce@seindal.dk))
+
+\dd(\p(Announcements regarding GNU m4 will posted here.)
+\p(The volume will certainly be very low.))
+
+)
+
+\p(Currently these lists are maintained manually. Send a message to \me
+saying whether you want to subscribe or unsubscribe to any of these
+lists.)
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/menu.m4 b/doc/examples/WWW/m4lib/menu.m4
new file mode 100644
index 00000000..78c8edfd
--- /dev/null
+++ b/doc/examples/WWW/m4lib/menu.m4
@@ -0,0 +1,74 @@
+\pushdef([header], [\tr([\td([\C_BG3], [\p([\b([$1])])])])])
+
+\pushdef([separator], [\tr([\td([height=5], [])])])
+
+\pushdef([_row], [\link([$1], [$2])])
+
+\pushdef([_rows],
+ [\ifelse($#, 0, [],
+ $#, 1, [],
+ $#, 2, [\_row([$1], [$2])],
+ $#, 3, [\_row([$1], [$2])],
+ [\_row([$1], [$2])\br\n\_rows(\shift(\shift($@)))])])
+
+\pushdef([rows], [\tr([\td([\p([\font([size=-1], [\b([\_rows($@)])])])])])])
+
+\table([],
+ [\header([General info])],
+ [\rows(
+ [whatis.htm], [What is m4],
+ [features.htm], [Features],
+ [uses.htm], [Uses of m4],
+ )],
+ [\separator],
+
+ [\header([Documentation])],
+ [\rows(
+ [man/m4_toc.html], [Manual],
+ )],
+ [\separator],
+
+ [\header([Source files])],
+ [\rows(
+ [readme.htm], [README],
+ [todo.htm], [TODO],
+ [news.htm], [NEWS],
+ [changelog.htm], [ChangeLog],
+ [thanks.htm], [Contributors],
+ [m4/], [Browse it],
+ )],
+ [\separator],
+
+ [\header([The Future])],
+ [\rows(
+ [modules.htm], [Modules],
+ [visions.htm], [Visions],
+ )],
+ [\separator],
+
+ [\header([Feedback])],
+ [\rows(
+ [lists.htm], [Mailing-lists],
+ [feedback.htm], [Feedback],
+ [/forum/list.php3?num=2], [Discussion Forum],
+ )],
+ [\separator],
+
+ [\header([Development])],
+ [\rows(
+ [download.htm], [Download],
+ [bugs.htm], [Known bugs],
+ )],
+ [\separator],
+
+ [\header([Examples])],
+ [\rows(
+ [thissite.htm], [This site],
+ )],
+)
+
+\popdef([header])
+\popdef([rows])
+\popdef([_rows])
+\popdef([_row])
+\popdef([separator])
diff --git a/doc/examples/WWW/m4lib/modules.m4 b/doc/examples/WWW/m4lib/modules.m4
new file mode 100644
index 00000000..b9c148f1
--- /dev/null
+++ b/doc/examples/WWW/m4lib/modules.m4
@@ -0,0 +1,18 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([Modules])
+
+\divert(1)
+
+<PRE>\dnl
+\changesyntax([A<>])\dnl
+\changequote(,)\dnl
+\include(m4/modules/README)
+\changequote([,])\dnl
+\changesyntax([O<>])\dnl
+</PRE>
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/news.m4 b/doc/examples/WWW/m4lib/news.m4
new file mode 100644
index 00000000..e5da0d89
--- /dev/null
+++ b/doc/examples/WWW/m4lib/news.m4
@@ -0,0 +1,18 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([NEWS - History of user-visible changes])
+
+\divert(1)
+
+<PRE>\dnl
+\changesyntax([A<>])\dnl
+\changequote(,)\dnl
+\include(m4/NEWS)
+\changequote([,])\dnl
+\changesyntax([O<>])\dnl
+</PRE>
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/readme.m4 b/doc/examples/WWW/m4lib/readme.m4
new file mode 100644
index 00000000..1612c7d1
--- /dev/null
+++ b/doc/examples/WWW/m4lib/readme.m4
@@ -0,0 +1,18 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([README])
+
+\divert(1)
+
+<PRE>\dnl
+\changesyntax([A<>])\dnl
+\changequote(,)\dnl
+\include(m4/README)
+\changequote([,])\dnl
+\changesyntax([O<>])\dnl
+</PRE>
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/setup.m4 b/doc/examples/WWW/m4lib/setup.m4
new file mode 100644
index 00000000..310b65f8
--- /dev/null
+++ b/doc/examples/WWW/m4lib/setup.m4
@@ -0,0 +1,7 @@
+divert(-1)
+changequote([,])
+changecom([<!--], [-->])
+changesyntax([@\])
+
+\include([html.m4])
+\include([layout.m4])
diff --git a/doc/examples/WWW/m4lib/test.m4 b/doc/examples/WWW/m4lib/test.m4
new file mode 100644
index 00000000..110cf12b
--- /dev/null
+++ b/doc/examples/WWW/m4lib/test.m4
@@ -0,0 +1,29 @@
+include(`setup.m4')
+
+\divert(1)
+
+\define([_ideas], [])
+
+\define([register_idea],
+[\define([H_$1], [$2])\dnl
+\define([T_$1], [$3])\dnl
+\define([_ideas], [\print_idea([$1])]\defn([_ideas]))])
+
+\define([print_idea], [
+\target([$1], [\h2([\indir([H_$1])])])
+\indir([T_$1])
+])
+
+\define([print_ideas], [\indir([_ideas])])
+
+\define([idea], [\li \p([\link([[#]$1], [$2.])])\register_idea([$1], [$2], [$3])])
+
+\idea([guile], [Guile as an extension language], [gfhjdsfsarhgew])
+\idea([pquote], [Persistent quotes],[asdffhfdghgdsfh])
+\idea([deps], [Dependencies generation],[afsdffasdf])
+
+\print_ideas
+
+\undivert(1)
+
+\defn([_ideas])
diff --git a/doc/examples/WWW/m4lib/thanks.m4 b/doc/examples/WWW/m4lib/thanks.m4
new file mode 100644
index 00000000..61928d07
--- /dev/null
+++ b/doc/examples/WWW/m4lib/thanks.m4
@@ -0,0 +1,18 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([People who have contributed to m4])
+
+\divert(1)
+
+<PRE>\dnl
+\changesyntax([A<>])\dnl
+\changequote(,)\dnl
+\include(m4/THANKS)
+\changequote([,])\dnl
+\changesyntax([O<>])\dnl
+</PRE>
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/thissite.m4 b/doc/examples/WWW/m4lib/thissite.m4
new file mode 100644
index 00000000..eecfa9cf
--- /dev/null
+++ b/doc/examples/WWW/m4lib/thissite.m4
@@ -0,0 +1,42 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([This site])
+
+\divert(1)
+
+\p([This GNU m4 site is maintained by René Seindal,
+(\mailto(rene@seindal.dk)).])
+
+\p([All files are generated using GNU m4 \__m4_version__. You can view
+the \link(m4lib/, source files). They are very simple. They use some
+features from GNU m4 1.4l])
+
+\p([The basic M4 definitions of quotes, comments, escapes are in
+\showlink(m4lib/setup.m4). This is first included by all files to
+configure the enviroment correctly for the other files. To avoid have
+macros called by accident, an escape character is defined with
+changesyntax. \i(This is a new feature in m4 1.4l).])
+
+\p([Some fairly general macros to generate various HTML construct are
+found in \showlink(m4lib/html.m4). There are macros for simple tags,
+containers with and without attributes, links and a few utility macros.])
+
+\p([The visual aspects of the pages are in \showlink(m4lib/layout.m4).
+The macros herein generate the complete HTML structure for the pages.
+There are macros for making the header and the body of the document.])
+
+\p([The definition of the left hand menu is in \showlink(m4lib/menu.m4).
+I convinced GNU Emacs to do the indentation by switching to c-mode.])
+
+\p([The page body is passed to the layout definitions as an argument. As
+the text can be large, it is first diverted and the text passed to the
+layout macros is simply a call to undivert. That way a very large text
+can be passed around with very little cost. This page is made with
+\link(m4lib/thissite.m4, these definitions).])
+
+\p([There is a single file for each HTML file.])
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/tmpl.m4 b/doc/examples/WWW/m4lib/tmpl.m4
new file mode 100644
index 00000000..8262d293
--- /dev/null
+++ b/doc/examples/WWW/m4lib/tmpl.m4
@@ -0,0 +1,11 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([])
+
+\divert(1)
+\h2([])
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/todo.m4 b/doc/examples/WWW/m4lib/todo.m4
new file mode 100644
index 00000000..7a22c151
--- /dev/null
+++ b/doc/examples/WWW/m4lib/todo.m4
@@ -0,0 +1,18 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([TODO - Things still to be done])
+
+\divert(1)
+
+<PRE>\dnl
+\changesyntax([A<>])\dnl
+\changequote(,)\dnl
+\include(m4/TODO)
+\changequote([,])\dnl
+\changesyntax([O<>])\dnl
+</PRE>
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/uses.m4 b/doc/examples/WWW/m4lib/uses.m4
new file mode 100644
index 00000000..e29acb7a
--- /dev/null
+++ b/doc/examples/WWW/m4lib/uses.m4
@@ -0,0 +1,43 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([Current uses of m4])
+
+\divert(1)
+
+\p(The MTA sendmail uses \tt(m4) for generating configuration files.)
+
+\p(\link(http://www.gnu.org/software/autoconf/autoconf.html, GNU
+Autoconf) uses \tt(m4) to generate "configure" scripts, that are used
+for configuring \link(http://www.gnu.org/, GNU) software for a
+particular platform.)
+
+\p(Htm4l is a set of macros for generating HTML. Html4 is written by
+Terry Jones (terry@cliffs.ucsd.edu). See
+\showlink(http://cliffs.ucsd.edu/terry/htm4l/htm4l/main.html) for
+details. )
+
+\p(Various programs uses m4 to preprocess configuration files, for
+example the X11 window manager fvwm.)
+
+\p(There is an \link(http://www.ssc.com/lg/issue22/using_m4.html,
+article in the Linux Gazette) about writing HTML with GNU m4 written by
+\link(mailto:bhepple@bit.net.au, Bob Hepple) . More recent versions
+are kept at \link(http://www.bit.net.au/~bhepple, Bob's home site).
+The macros are used to maintain a large commercial site at
+\showlink(http://www.finder.com.au).)
+
+\p(Other examples of GNU m4 generated HTML pages, written by
+\link(mailto:max@alcyone.com, Erik Max Francis) can be found at the sites
+\showlink(http://www.alcyone.com/max/),
+\showlink(http://www.catcam.com/),
+\showlink(http://www.crank.net/) and
+\showlink(http://www.pollywannacracka.com/).
+)
+
+\p(\link(thissite.htm, These files are created with GNU m4 \__m4_version__).)
+
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/WWW/m4lib/visions.m4 b/doc/examples/WWW/m4lib/visions.m4
new file mode 100644
index 00000000..ba238ca9
--- /dev/null
+++ b/doc/examples/WWW/m4lib/visions.m4
@@ -0,0 +1,232 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([The Road Ahead])
+
+\define([originator],
+[\p([Idea contributed by [$1]]\ifelse($#, 2, [ (\mailto([$2]))])[.])])
+
+\define([noone], [\p([There is no-one working on this now. Do you want
+to <A HREF="mailto:m4-feedback@seindal.dk?subject=GNU m4: \defn([_item])" >volunteer</A>?])])
+
+
+\define([done], [\p([Done in version 1.4$1])])
+
+
+\divert(1)
+\h2([Ideas for future versions of GNU m4])
+
+\p([Here are some ideas and suggestion for the future of GNU m4, large
+and small. The order here is fairly random.])
+
+\ul([
+
+\item([guile], [Guile as an extension language],
+
+[\p([\link([http://www.red-bean.com/guile/], [Guile]) can be used as an
+extension language so complicated macros can be written in Scheme while
+still maintaining the m4 interface. It will require some changes to the
+base code, as guile cannot be used from a module.])
+
+\noone <!-- \originator([René Seindal], [rene@seindal]) -->
+])
+
+
+\item([utf8], [UTF-8 or wide characters],
+
+[\p([GNU m4 should be able to handle UTF-8 input or wide characters so
+it can be more usable for different environments.])
+
+\noone <!-- \originator([François Pinard]) -->
+])
+
+
+\item([pquote], [Syntax: persistent quotes],
+
+[\p([Persistent quotes is a way of getting text unharmed through m4's
+processing. While normal quotes are stripped when a quoted string is
+read, the persistent quotes are removed just before being output. This
+will ensure that the quoted text is always output verbatim.])
+
+\p([The bulk of the changes will be in the parser (in input.c function
+next_token). Persistent quotes cannot be nested, they must balance
+within a normally quoted string, but normal quotes need not balance
+within persistent quotes (neither within persistent quotes within normal
+quotes). The quotes should be removed before being shipped out (in
+macro.c).])
+
+\noone <!-- \originator([Keith Bostic]) -->
+])
+
+
+
+
+\item([comment2], [Syntax: removable comments],
+
+[\p([With the syntax table a category for discardable comments can be
+defined, causing that type of comments to be discarded.])
+
+\noone
+])
+
+
+
+
+\item([comment1], [Option: remove comments],
+
+[\p([There should be an option (--discard-comments) to get m4 to discard
+comments instead of passing them to the output.])
+
+\done(n)
+])
+
+
+
+\item([deps], [Option: show dependencies],
+
+[\p([There should be an options to generate makefile dependencies for an
+M4 input file.])
+
+\p([It is not enough to scan the files for includes, as file names can
+be generated and builtins renamed. To make it work, m4 will have to do
+a complete run of the input file, discard the output and print the
+dependencies instead.])
+
+\p([It cannot be made to work in all cases when input file names are
+generated on the fly.])
+
+\noone <!-- \originator([Erick Branderhorst]) -->
+])
+
+
+\item([safer], [Option: render GNU m4 safer],
+
+[\p([There should be a --safer option that disables all functions, that
+could compromise system security if used by root. It will have to
+include various functions, such as file inclusion, sub shells, module
+loading, ...])
+
+\noone <!-- \originator([Santiago Vila]) -->
+])
+
+
+
+\item([import], [Option: import environment],
+
+[\p([An option to defined each environment variable as a macro on
+startup would be useful in many cases.])
+
+\done(n) <!-- \originator([René Seindal]) -->
+])
+
+
+
+\item([m4expand], [Builtin: quote expanded text],
+
+[\p([A builtin to quote expanded text would be useful. Now it is not
+possible to quote the expansion of a macro; the macro itself has to
+provide the quotes. Some builtins return quoted strings, others
+don't.])
+
+\p([A possible solution is a build in macro that takes one argument. It
+expands this argument fully and returns the quoted expansion.])
+
+\p([It will require changes to input handling and macro expansion code.])
+
+\noone <!-- \originator([Axel Boldt]) -->
+])
+
+
+
+\item([perl], [Module: embedded perl],
+
+[\p([Perl could be embedded in m4, giving users a powerful programming
+language for writing macros. A single builtin "perleval" could do the
+job. First argument could be a perl function and the rest arguments.
+The return value of the function as a string would be the expansion.])
+
+\p([The perl interpreter should be set up when the module is loaded and
+closed down before m4 exits, using the appropriate hooks in the module
+interface.])
+
+\p([A perl module could potentially give users access to any facility
+perl has access to, such as databases.])
+
+\p([On systems with perl compiled as a shared library the size penalty
+would be minimal.])
+
+\p([(It might not be workable as a module, as it will need to link with non-shared libraries. Don't know how it can be fixed. (RS))])
+
+\noone <!-- \originator([René Seindal]) -->
+])
+
+
+
+\item([output], [Module: better output control],
+
+[\p([It has been suggested a couple of times that it should be possible
+to divert to named files, in order to create several output files.])
+
+\p([I think this a bit a misunderstanding. Diversion are inteded to be
+brought back later, ie, they are temporary and recoverable. Output
+text, on the other hand, once output it is lost (for m4). Therefore
+better output control should be made in a different way.])
+
+\p([My suggestion is a set of builtins defined by a module:])
+
+\pre([setoutput(file)
+appendoutput(file)
+pipeoutput(command)])
+
+\p([With these output can be directed better, diversion can be sent to
+different files, and groups of files can be built by a single m4 run.
+Calling \tt(setoutput) without arguments should resume output to
+standard output.])
+
+\p([(Admittedly, diversion 0 (standard output) has always been
+different, as it cannot be undiverted.)])
+
+\noone <!-- \originator([René Seindal]) -->
+])
+
+
+
+\item([require], [Module: require/provide functionality],
+
+[\p([Two new builtins \tt(require) and \tt(provide) could provide a
+handy interface to include. It has proven difficult to write these
+robustly as normal macros. As an example, the files \tt(test.m4) and
+\tt(../test.m4) could be the same file or different files depending on
+the search path.])
+
+\noone <!-- \originator([Terry Jones]) -->
+])
+
+
+])
+
+
+
+\p([See also the \link(todo.htm, TODO) file.])
+
+\print_items
+
+
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
+
+\divert(3)saljdfnaskdjfndsa\divert(-1)
+
+
+
+
+\item([], [],
+
+[\p([])
+
+\noone
+])
+
+\undivert
diff --git a/doc/examples/WWW/m4lib/whatis.m4 b/doc/examples/WWW/m4lib/whatis.m4
new file mode 100644
index 00000000..2fa1c426
--- /dev/null
+++ b/doc/examples/WWW/m4lib/whatis.m4
@@ -0,0 +1,48 @@
+include(`setup.m4')
+
+\set_author([René Seindal])
+\set_title([What is GNU m4])
+
+\divert(1)
+
+\p([GNU \tt(m4) is an implementation of the traditional Unix macro
+processor. GNU m4 is mostly compatible with the System V, Release 3
+version, and SVR4, although it has some extensions (for example,
+handling more than 9 positional parameters to macros). GNU \tt(m4)
+also has built-in functions for including files, running shell
+commands, doing arithmetic, etc.])
+
+\p([GNU \tt(m4) is a macro processor, in the sense that it copies its
+input to the output, expanding macros as it goes. Macros are either
+builtin or user-defined, and can take any number of arguments. Besides
+just doing macro expansion, m4 has builtin functions for including named
+files, running UNIX commands, doing integer arithmetic, manipulating
+text in various ways, recursion, etc... m4 can be used either as a
+front-end to a compiler, or as a macro processor in its own right.])
+
+\p([The m4 macro processor is widely available on all UNIXes. Usually,
+only a small percentage of users are aware of its existence. However,
+those who do often become commited users. The growing popularity of GNU
+Autoconf, which prerequires GNU m4 for generating the `configure'
+scripts, is an incentive for many to install it, while these people will
+not themselves program in m4.])
+
+\p([Some people found m4 to be fairly addictive. They first use m4 for
+simple problems, then take bigger and bigger challenges, learning how to
+write complex m4 sets of macros along the way. Once really addicted,
+users pursue writing of sophisticated m4 applications even to solve
+simple problems, devoting more time debugging their m4 scripts than
+doing real work. Beware that m4 may be dangerous for the health of
+compulsive programmers.])
+
+\p([Autoconf needs GNU m4 for generating `configure' scripts, but not for
+running them.])
+
+\p([GNU m4 is a Unix program. It is designed to work in a Unix-like
+environment. GNU m4 1.4 has, however, been ported to DJGPP, the GNU C
+compiler for DOS/Windows. These files are present in the
+\link(download.htm, download area).])
+
+\divert(0)\dnl
+\DO_LAYOUT([\undivert(1)])
+\divert(-1)
diff --git a/doc/examples/capitalize.m4 b/doc/examples/capitalize.m4
new file mode 100644
index 00000000..d4e4a502
--- /dev/null
+++ b/doc/examples/capitalize.m4
@@ -0,0 +1,12 @@
+divert(`-1')
+# upcase(text)
+# downcase(text)
+# capitalize(text)
+# change case of text, simple version
+define(`upcase', `translit(`$*', `a-z', `A-Z')')
+define(`downcase', `translit(`$*', `A-Z', `a-z')')
+define(`_capitalize',
+ `regexp(`$1', `^\(\w\)\(\w*\)',
+ `upcase(`\1')`'downcase(`\2')')')
+define(`capitalize', `patsubst(`$1', `\w+', `_$0(`\&')')')
+divert`'dnl
diff --git a/doc/examples/capitalize2.m4 b/doc/examples/capitalize2.m4
new file mode 100644
index 00000000..154dc505
--- /dev/null
+++ b/doc/examples/capitalize2.m4
@@ -0,0 +1,19 @@
+divert(`-1')
+# upcase(text)
+# downcase(text)
+# capitalize(text)
+# change case of text, improved version
+define(`upcase', `translit(`$*', `a-z', `A-Z')')
+define(`downcase', `translit(`$*', `A-Z', `a-z')')
+define(`_arg1', `$1')
+define(`_to_alt', `changequote(`<<[', `]>>')')
+define(`_from_alt', `changequote(<<[`]>>, <<[']>>)')
+define(`_upcase_alt', `translit(<<[$*]>>, <<[a-z]>>, <<[A-Z]>>)')
+define(`_downcase_alt', `translit(<<[$*]>>, <<[A-Z]>>, <<[a-z]>>)')
+define(`_capitalize_alt',
+ `regexp(<<[$1]>>, <<[^\(\w\)\(\w*\)]>>,
+ <<[_upcase_alt(<<[<<[\1]>>]>>)_downcase_alt(<<[<<[\2]>>]>>)]>>)')
+define(`capitalize',
+ `_arg1(_to_alt()patsubst(<<[<<[$*]>>]>>, <<[\w+]>>,
+ _from_alt()`]>>_$0_alt(<<[\&]>>)<<['_to_alt())_from_alt())')
+divert`'dnl
diff --git a/doc/examples/comments.m4 b/doc/examples/comments.m4
new file mode 100644
index 00000000..c1e3be0a
--- /dev/null
+++ b/doc/examples/comments.m4
@@ -0,0 +1,7 @@
+# An ordinary comment
+define(`foo', # A comment in a macro
+`Macro `foo' expansion')
+foo
+define(`comment', `*** Macro `comment' expansion ***')
+changecom(`@', `@')
+foo
diff --git a/doc/examples/curry.m4 b/doc/examples/curry.m4
new file mode 100644
index 00000000..00997c38
--- /dev/null
+++ b/doc/examples/curry.m4
@@ -0,0 +1,7 @@
+divert(`-1')
+# curry(macro, args)
+# Expand to a macro call that takes one argument, then invoke
+# macro(args, extra).
+define(`curry', `$1(shift($@,)_$0')
+define(`_curry', ``$1')')
+divert`'dnl
diff --git a/doc/examples/ddivert.m4 b/doc/examples/ddivert.m4
new file mode 100644
index 00000000..e6e0017e
--- /dev/null
+++ b/doc/examples/ddivert.m4
@@ -0,0 +1,4 @@
+divert(1)Text diverted a first time.
+divert(0)undivert(1)dnl
+divert(1)Text diverted a second time.
+divert(0)undivert(1)dnl
diff --git a/doc/examples/debug.m4 b/doc/examples/debug.m4
new file mode 100644
index 00000000..16f4c74e
--- /dev/null
+++ b/doc/examples/debug.m4
@@ -0,0 +1,4 @@
+define(`countdown', `$1 ifelse(eval($1 > 0), 1, `countdown(decr($1))', `Liftoff')')
+debugmode(`aeqc')
+traceon(`countdown')
+countdown(2)
diff --git a/doc/examples/esyscmd.m4 b/doc/examples/esyscmd.m4
new file mode 100644
index 00000000..3c856e02
--- /dev/null
+++ b/doc/examples/esyscmd.m4
@@ -0,0 +1,6 @@
+# Cannot use real hostname program because test would fail
+define(`hostname', esyscmd(`echo www.gnu.org'))dnl
+`hostname = >>'hostname`<<'
+define(`hostname',
+pushdef(`_tmp', `$1')_tmp(translit(esyscmd(`echo www.gnu.org'), `.', `,'))`'popdef(`_tmp'))dnl
+`hostname = >>'hostname`<<'
diff --git a/doc/examples/exp.m4 b/doc/examples/exp.m4
new file mode 100644
index 00000000..e2bcf943
--- /dev/null
+++ b/doc/examples/exp.m4
@@ -0,0 +1,3 @@
+define(`countdown', `$1
+ifelse(eval($1 > 0), 1, `countdown(decr($1))', `Done')')dnl
+countdown(7)
diff --git a/doc/examples/foreach.m4 b/doc/examples/foreach.m4
new file mode 100644
index 00000000..9be25b08
--- /dev/null
+++ b/doc/examples/foreach.m4
@@ -0,0 +1,8 @@
+divert(`-1')
+# foreach(x, (item_1, item_2, ..., item_n), stmt)
+# parenthesized list, simple version
+define(`foreach', `pushdef(`$1')_foreach($@)popdef(`$1')')
+define(`_arg1', `$1')
+define(`_foreach', `ifelse(`$2', `()', `',
+ `define(`$1', _arg1$2)$3`'$0(`$1', (shift$2), `$3')')')
+divert`'dnl
diff --git a/doc/examples/foreach2.m4 b/doc/examples/foreach2.m4
new file mode 100644
index 00000000..74d00fb6
--- /dev/null
+++ b/doc/examples/foreach2.m4
@@ -0,0 +1,10 @@
+include(`quote.m4')dnl
+divert(`-1')
+# foreach(x, (item_1, item_2, ..., item_n), stmt)
+# parenthesized list, improved version
+define(`foreach', `pushdef(`$1')_$0(`$1',
+ (dquote(dquote_elt$2)), `$3')popdef(`$1')')
+define(`_arg1', `$1')
+define(`_foreach', `ifelse(`$2', `(`')', `',
+ `define(`$1', _arg1$2)$3`'$0(`$1', (dquote(shift$2)), `$3')')')
+divert`'dnl
diff --git a/doc/examples/foreachq.m4 b/doc/examples/foreachq.m4
new file mode 100644
index 00000000..d34fb5b9
--- /dev/null
+++ b/doc/examples/foreachq.m4
@@ -0,0 +1,9 @@
+include(`quote.m4')dnl
+divert(`-1')
+# foreachq(x, `item_1, item_2, ..., item_n', stmt)
+# quoted list, simple version
+define(`foreachq', `pushdef(`$1')_foreachq($@)popdef(`$1')')
+define(`_arg1', `$1')
+define(`_foreachq', `ifelse(quote($2), `', `',
+ `define(`$1', `_arg1($2)')$3`'$0(`$1', `shift($2)', `$3')')')
+divert`'dnl
diff --git a/doc/examples/foreachq2.m4 b/doc/examples/foreachq2.m4
new file mode 100644
index 00000000..f57d3edf
--- /dev/null
+++ b/doc/examples/foreachq2.m4
@@ -0,0 +1,10 @@
+include(`quote.m4')dnl
+divert(`-1')
+# foreachq(x, `item_1, item_2, ..., item_n', stmt)
+# quoted list, improved version
+define(`foreachq', `pushdef(`$1')_$0($@)popdef(`$1')')
+define(`_arg1q', ``$1'')
+define(`_rest', `ifelse(`$#', `1', `', `dquote(shift($@))')')
+define(`_foreachq', `ifelse(`$2', `', `',
+ `define(`$1', _arg1q($2))$3`'$0(`$1', _rest($2), `$3')')')
+divert`'dnl
diff --git a/doc/examples/foreachq3.m4 b/doc/examples/foreachq3.m4
new file mode 100644
index 00000000..5e656727
--- /dev/null
+++ b/doc/examples/foreachq3.m4
@@ -0,0 +1,9 @@
+divert(`-1')
+# foreachq(x, `item_1, item_2, ..., item_n', stmt)
+# quoted list, alternate improved version
+define(`foreachq', `ifelse(`$2', `', `',
+ `pushdef(`$1')_$0(`$1', `$3', `', $2)popdef(`$1')')')
+define(`_foreachq', `ifelse(`$#', `3', `',
+ `define(`$1', `$4')$2`'$0(`$1', `$2',
+ shift(shift(shift($@))))')')
+divert`'dnl
diff --git a/doc/examples/foreachq4.m4 b/doc/examples/foreachq4.m4
new file mode 100644
index 00000000..3da64c92
--- /dev/null
+++ b/doc/examples/foreachq4.m4
@@ -0,0 +1,13 @@
+include(`forloop2.m4')dnl
+divert(`-1')
+# foreachq(x, `item_1, item_2, ..., item_n', stmt)
+# quoted list, version based on forloop
+define(`foreachq',
+`ifelse(`$2', `', `', `_$0(`$1', `$3', $2)')')
+define(`_foreachq',
+`pushdef(`$1', forloop(`$1', `3', `$#',
+ `$0_(`1', `2', indir(`$1'))')`popdef(
+ `$1')')indir(`$1', $@)')
+define(`_foreachq_',
+``define(`$$1', `$$3')$$2`''')
+divert`'dnl
diff --git a/doc/examples/forloop.m4 b/doc/examples/forloop.m4
new file mode 100644
index 00000000..fdca2608
--- /dev/null
+++ b/doc/examples/forloop.m4
@@ -0,0 +1,6 @@
+divert(`-1')
+# forloop(var, from, to, stmt) - simple version
+define(`forloop', `pushdef(`$1', `$2')_forloop($@)popdef(`$1')')
+define(`_forloop',
+ `$4`'ifelse($1, `$3', `', `define(`$1', incr($1))$0($@)')')
+divert`'dnl
diff --git a/doc/examples/forloop2.m4 b/doc/examples/forloop2.m4
new file mode 100644
index 00000000..b7154e86
--- /dev/null
+++ b/doc/examples/forloop2.m4
@@ -0,0 +1,12 @@
+divert(`-1')
+# forloop(var, from, to, stmt) - improved version:
+# works even if VAR is not a strict macro name
+# performs sanity check that FROM is larger than TO
+# allows complex numerical expressions in TO and FROM
+define(`forloop', `ifelse(eval(`($2) <= ($3)'), `1',
+ `pushdef(`$1')_$0(`$1', eval(`$2'),
+ eval(`$3'), `$4')popdef(`$1')')')
+define(`_forloop',
+ `define(`$1', `$2')$4`'ifelse(`$2', `$3', `',
+ `$0(`$1', incr(`$2'), `$3', `$4')')')
+divert`'dnl
diff --git a/doc/examples/forloop3.m4 b/doc/examples/forloop3.m4
new file mode 100644
index 00000000..98db20f3
--- /dev/null
+++ b/doc/examples/forloop3.m4
@@ -0,0 +1,13 @@
+divert(`-1')
+# forloop_arg(from, to, macro) - invoke MACRO(value) for
+# each value between FROM and TO, without define overhead
+define(`forloop_arg', `ifelse(eval(`($1) <= ($2)'), `1',
+ `_forloop(`$1', eval(`$2'), `$3(', `)')')')
+# forloop(var, from, to, stmt) - refactored to share code
+define(`forloop', `ifelse(eval(`($2) <= ($3)'), `1',
+ `pushdef(`$1')_forloop(eval(`$2'), eval(`$3'),
+ `define(`$1',', `)$4')popdef(`$1')')')
+define(`_forloop',
+ `$3`$1'$4`'ifelse(`$1', `$2', `',
+ `$0(incr(`$1'), `$2', `$3', `$4')')')
+divert`'dnl
diff --git a/doc/examples/fstab.m4 b/doc/examples/fstab.m4
new file mode 100644
index 00000000..8d10e176
--- /dev/null
+++ b/doc/examples/fstab.m4
@@ -0,0 +1,6 @@
+define(`concat', `translit(``$*'', ` ')')
+define(`fsent', `format(`%-25s %-16s nfs %-16s 0 0', `$1:$2', `$3', concat$4)')
+
+fsent(freja, /home/gevn, /home/gevn, (rw, soft, bg, grpid))
+fsent(freja, /home/freja, /home/freja, (rw, soft, grpid))
+fsent(rimfaxe, /home/rimfaxe, /home/rimfaxe, (rw, soft, bg))
diff --git a/doc/examples/hanoi.m4 b/doc/examples/hanoi.m4
new file mode 100644
index 00000000..32fd8a41
--- /dev/null
+++ b/doc/examples/hanoi.m4
@@ -0,0 +1,17 @@
+divert(-1)
+
+# move(from, to)
+define(`move', `Move one disk from `$1' to `$2'.
+')
+
+# _hanoi (cnt, from, to, aux)
+define(`_hanoi', `ifelse(eval(`$1'<=1), 1, `move($2, $3)',
+`$0(decr($1), $2, $4, $3)move($2, $3)$0(decr($1), $4, $3, $2)')')
+
+# hanoi (cnt)
+define(`hanoi', `_$0(`$1', source, destination, auxilliary)')
+
+# traceon(`move', `_hanoi', `decr')
+divert`'dnl
+
+hanoi(3)
diff --git a/doc/examples/incl-test.m4 b/doc/examples/incl-test.m4
new file mode 100644
index 00000000..323fa05b
--- /dev/null
+++ b/doc/examples/incl-test.m4
@@ -0,0 +1,3 @@
+dnl noauto
+`include test file.'
+define()
diff --git a/doc/examples/incl.m4 b/doc/examples/incl.m4
new file mode 100644
index 00000000..ab9572eb
--- /dev/null
+++ b/doc/examples/incl.m4
@@ -0,0 +1,3 @@
+Include file start
+foo
+Include file end
diff --git a/doc/examples/include.m4 b/doc/examples/include.m4
new file mode 100644
index 00000000..8e9d9d2f
--- /dev/null
+++ b/doc/examples/include.m4
@@ -0,0 +1,7 @@
+Beginning.
+include(`NOFILE')
+Intermediate
+include(`incl-test.m4')
+After
+include(`NOFILE')
+very late
diff --git a/doc/examples/indir.m4 b/doc/examples/indir.m4
new file mode 100644
index 00000000..51d2b64f
--- /dev/null
+++ b/doc/examples/indir.m4
@@ -0,0 +1,10 @@
+define(`%%$$##', `>>>$0<<< cnt $#')
+
+# indir(`%%$$##', nonsense, nonsense)
+indir(`%%$$##', nonsense, nonsense)
+
+# indir(`indir', `%%$$##', nonsense)
+indir(`indir', `%%$$##', nonsense)
+
+# indir(`indir', `indir', `indir', `indir', `%%$$##')
+indir(`indir', `indir', `indir', `indir', `%%$$##')
diff --git a/doc/examples/join.m4 b/doc/examples/join.m4
new file mode 100644
index 00000000..8687ac70
--- /dev/null
+++ b/doc/examples/join.m4
@@ -0,0 +1,15 @@
+divert(`-1')
+# join(sep, args) - join each non-empty ARG into a single
+# string, with each element separated by SEP
+define(`join',
+`ifelse(`$#', `2', ``$2'',
+ `ifelse(`$2', `', `', ``$2'_')$0(`$1', shift(shift($@)))')')
+define(`_join',
+`ifelse(`$#$2', `2', `',
+ `ifelse(`$2', `', `', ``$1$2'')$0(`$1', shift(shift($@)))')')
+# joinall(sep, args) - join each ARG, including empty ones,
+# into a single string, with each element separated by SEP
+define(`joinall', ``$2'_$0(`$1', shift($@))')
+define(`_joinall',
+`ifelse(`$#', `2', `', ``$1$3'$0(`$1', shift(shift($@)))')')
+divert`'dnl
diff --git a/doc/examples/loop.m4 b/doc/examples/loop.m4
new file mode 100644
index 00000000..b2fc64c4
--- /dev/null
+++ b/doc/examples/loop.m4
@@ -0,0 +1,18 @@
+dnl Stress test for recursion algorithms. Usage:
+dnl m4 -Ipath/to/examples [-Doptions] loop.m4
+dnl Options include:
+dnl -Dalt[=<n>] - test with foreachq<n> instead of foreachq2, default 3
+dnl -Dlimit=<num> - set upper limit of sequence to <num>, default 1000
+dnl -Dverbose - print the sequence to the screen, rather than discarding
+dnl -Ddebug[=<code>] - execute <code> after forloop but before foreach
+dnl -Dsleep=<num> - sleep for <num> seconds before exit, to allow time
+dnl to examine peak process memory usage
+include(`forloop2.m4')dnl
+include(`quote.m4')dnl
+ifelse(alt, `alt', `define(`alt', `2')', alt, `', `define(`alt', `3')')dnl
+include(`foreachq'alt`.m4')dnl
+ifdef(`limit', `', `define(`limit', `1000')')dnl
+ifdef(`verbose', `', `divert(`-1')')dnl
+ifdef(`debug', `', `define(`debug')')dnl
+foreachq(`i', dquote(1forloop(`i', `2', limit, `,i'))debug, ` i')
+ifdef(`sleep',`syscmd(`echo done>/dev/tty;sleep 'sleep)')dnl
diff --git a/doc/examples/misc.m4 b/doc/examples/misc.m4
new file mode 100644
index 00000000..979b51aa
--- /dev/null
+++ b/doc/examples/misc.m4
@@ -0,0 +1,8 @@
+divert(-1)
+define(`USER', `root')
+define(`TMP', maketemp(`/tmp/hejXXXXXX'))
+syscmd(`grep "^'USER`:" /etc/passwd | awk -F: "{print \$3}"' > TMP)
+define(`UID', include(TMP))
+syscmd(`rm -f' TMP)
+divert
+UID
diff --git a/doc/examples/modtest.m4 b/doc/examples/modtest.m4
new file mode 100644
index 00000000..c61ed6f6
--- /dev/null
+++ b/doc/examples/modtest.m4
@@ -0,0 +1,7 @@
+dnl Copyright (C) 2006, 2010, 2013 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it
+dnl with or without modifications, as long as this notice is preserved.
+load(`modtest')
+test
+Dumpdef: dumpdef(`test').
diff --git a/doc/examples/multiquotes.m4 b/doc/examples/multiquotes.m4
new file mode 100644
index 00000000..b56cfbd8
--- /dev/null
+++ b/doc/examples/multiquotes.m4
@@ -0,0 +1,17 @@
+traceon
+changequote([,])dnl
+changequote([``], [''])dnl
+````traceon''''
+define(``foo'', ````FOO'''')dnl
+dumpdef(``foo'')dnl
+changequote(``!'', ``!'')dnl
+!foo!
+foo
+dumpdef(!foo!)dnl
+define(!bar!, !BAR!)
+bar
+changequote(!>*>*>*>*>!, !<*<*<*<*<!)dnl five of each
+>*>*>*>*>foo bar<*<*<*<*<
+foo bar
+>*>*>*>*>*>*><*<*<*<*<*<*<
+dumpdef(>*>*>*>*>foo<*<*<*<*<, >*>*>*>*>bar<*<*<*<*<)dnl
diff --git a/doc/examples/patsubst.m4 b/doc/examples/patsubst.m4
new file mode 100644
index 00000000..9b4c7591
--- /dev/null
+++ b/doc/examples/patsubst.m4
@@ -0,0 +1,8 @@
+# traceon(`patsubst')
+patsubst(`GNUs not Unix.', `^', `OBS: ')
+patsubst(`GNUs not Unix.', `\<', `OBS: ')
+patsubst(`GNUs not Unix.', `\<\w', `\0=')
+patsubst(`GNUs not Unix.', `\w*', `(\0)')
+patsubst(`GNUs not Unix.', `\w+', `(\0)')
+patsubst(`GNUs not Unix.', `\w+')
+patsubst(`GNUs not '` Unix.', `[ ]+', ` ')
diff --git a/doc/examples/pushpop.m4 b/doc/examples/pushpop.m4
new file mode 100644
index 00000000..d0f2ebb8
--- /dev/null
+++ b/doc/examples/pushpop.m4
@@ -0,0 +1,25 @@
+divert(-1)
+pushdef(`hej', `def 1.')
+dumpdef(`hej')
+pushdef(`hej', `def 2.')
+dumpdef(`hej')
+pushdef(`hej', `def 3.')
+dumpdef(`hej')
+pushdef(`hej', `def 4.')
+dumpdef(`hej')
+
+popdef(`hej')
+dumpdef(`hej')
+popdef(`hej')
+dumpdef(`hej')
+popdef(`hej')
+dumpdef(`hej')
+popdef(`hej')
+dumpdef(`hej')
+popdef(`hej')
+dumpdef(`hej')
+popdef(`hej')
+
+dumpdef(`mac2')
+popdef(`mac2')
+dumpdef(`mac2')
diff --git a/doc/examples/quote.m4 b/doc/examples/quote.m4
new file mode 100644
index 00000000..fae52c3e
--- /dev/null
+++ b/doc/examples/quote.m4
@@ -0,0 +1,9 @@
+divert(`-1')
+# quote(args) - convert args to single-quoted string
+define(`quote', `ifelse(`$#', `0', `', ``$*'')')
+# dquote(args) - convert args to quoted list of quoted strings
+define(`dquote', ``$@'')
+# dquote_elt(args) - convert args to list of double-quoted strings
+define(`dquote_elt', `ifelse(`$#', `0', `', `$#', `1', ```$1''',
+ ```$1'',$0(shift($@))')')
+divert`'dnl
diff --git a/doc/examples/regexp.m4 b/doc/examples/regexp.m4
new file mode 100644
index 00000000..a4ca573e
--- /dev/null
+++ b/doc/examples/regexp.m4
@@ -0,0 +1,12 @@
+traceon(`regexp')dnl
+regexp(`hej med dig', `.*', `>>\0<<')
+regexp(`hej med dig', `\w*', `>>\0<<')
+regexp(`hej med dig', `.+', `>>\0<<')
+regexp(`hej med dig', `m\w+', `>>\0<<')
+regexp(`hej med dig', `m\(.*\)', `>>\0<< >>\1<<')
+
+regexp(`hej med dig', `.*')
+regexp(`hej med dig', `\w*')
+regexp(`hej med dig', `.+')
+regexp(`hej med dig', `m\w+')
+regexp(`hej med dig', `m\(.*\)')
diff --git a/doc/examples/reverse.m4 b/doc/examples/reverse.m4
new file mode 100644
index 00000000..7e2374e2
--- /dev/null
+++ b/doc/examples/reverse.m4
@@ -0,0 +1,4 @@
+define(`reverse', `ifelse(eval($# > 1), 1, `reverse(shift($@)), `$1'', ``$1'')')
+``'' => reverse.
+``hej'' => reverse(hej).
+``hej, med, dig'' => reverse(hej, med, dig).
diff --git a/doc/examples/shadow.m4 b/doc/examples/shadow.m4
new file mode 100644
index 00000000..f13b7dfa
--- /dev/null
+++ b/doc/examples/shadow.m4
@@ -0,0 +1,57 @@
+dnl Copyright (C) 2006, 2010, 2013 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it
+dnl with or without modifications, as long as this notice is preserved.
+# no modules loaded yet
+test
+shadow
+
+# define our own macros for `test' and `shadow'
+define(`test', `local::`test'')
+define(`shadow', `local::`shadow'')
+test
+shadow
+
+# module Shadow defines `shadow' and `test' macros
+load(`shadow')
+dumpdef(`test')
+dumpdef(`shadow')
+test
+shadow
+
+# save the definition of `test' from the Shadow module
+define(`Shadow::test', defn(`test'))
+
+# module Test also defines a `test' macro
+load(`modtest')
+dumpdef(`test')
+dumpdef(`shadow')
+test
+shadow
+
+# Reloading Shadow shouldn't affect anything
+load(`shadow')
+dumpdef(`test')
+dumpdef(`shadow')
+test
+shadow
+
+# Unloading Test will unshadow the test definition in Shadow
+unload(`modtest')
+dumpdef(`test')
+dumpdef(`shadow')
+test
+shadow
+
+# Unloading Shadow once has no effect (we loaded it twice)
+unload(`shadow')
+dumpdef(`test')
+dumpdef(`shadow')
+test
+shadow
+
+# Unloading Shadow again will revert to copying `test' and the local
+# `shadow' macro.
+unload(`shadow')
+test
+shadow
diff --git a/doc/examples/stack.m4 b/doc/examples/stack.m4
new file mode 100644
index 00000000..c1b98333
--- /dev/null
+++ b/doc/examples/stack.m4
@@ -0,0 +1,16 @@
+divert(`-1')
+# stack_foreach(macro, action)
+# Invoke ACTION with a single argument of each definition
+# from the definition stack of MACRO, starting with the oldest.
+define(`stack_foreach',
+`_stack_reverse(`$1', `tmp-$1')'dnl
+`_stack_reverse(`tmp-$1', `$1', `$2(defn(`$1'))')')
+# stack_foreach_lifo(macro, action)
+# Invoke ACTION with a single argument of each definition
+# from the definition stack of MACRO, starting with the newest.
+define(`stack_foreach_lifo',
+`_stack_reverse(`$1', `tmp-$1', `$2(defn(`$1'))')'dnl
+`_stack_reverse(`tmp-$1', `$1')')
+define(`_stack_reverse',
+`ifdef(`$1', `pushdef(`$2', defn(`$1'))$3`'popdef(`$1')$0($@)')')
+divert`'dnl
diff --git a/doc/examples/stack_sep.m4 b/doc/examples/stack_sep.m4
new file mode 100644
index 00000000..767d15e2
--- /dev/null
+++ b/doc/examples/stack_sep.m4
@@ -0,0 +1,17 @@
+divert(`-1')
+# stack_foreach_sep(macro, pre, post, sep)
+# Invoke PRE`'defn`'POST with a single argument of each definition
+# from the definition stack of MACRO, starting with the oldest, and
+# separated by SEP between definitions.
+define(`stack_foreach_sep',
+`_stack_reverse_sep(`$1', `tmp-$1')'dnl
+`_stack_reverse_sep(`tmp-$1', `$1', `$2`'defn(`$1')$3', `$4`'')')
+# stack_foreach_sep_lifo(macro, pre, post, sep)
+# Like stack_foreach_sep, but starting with the newest definition.
+define(`stack_foreach_sep_lifo',
+`_stack_reverse_sep(`$1', `tmp-$1', `$2`'defn(`$1')$3', `$4`'')'dnl
+`_stack_reverse_sep(`tmp-$1', `$1')')
+define(`_stack_reverse_sep',
+`ifdef(`$1', `pushdef(`$2', defn(`$1'))$3`'popdef(`$1')$0(
+ `$1', `$2', `$4$3')')')
+divert`'dnl
diff --git a/doc/examples/stdlib.m4 b/doc/examples/stdlib.m4
new file mode 100644
index 00000000..df0a91dd
--- /dev/null
+++ b/doc/examples/stdlib.m4
@@ -0,0 +1,44 @@
+dnl Copyright (C) 2006, 2010, 2013 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it
+dnl with or without modifications, as long as this notice is preserved.
+load(`stdlib')
+
+`getenv - 'getenv(PATH)
+
+setenv TEST=??? setenv(`TEST', `???')
+getenv TEST - getenv(`TEST')
+
+setenv TEST=Second test setenv(`TEST', `Second test')
+getenv TEST - getenv(`TEST')
+
+unsetenv TEST unsetenv(`TEST')
+getenv TEST - getenv(`TEST')
+
+
+
+`getlogin - 'getlogin
+`getcwd = 'getcwd
+`getpid - 'getpid
+`getppid - 'getppid
+
+syscmd(`ps ajx|grep m4')
+
+`getuid - 'getuid
+
+user root - getpwnam(`root')
+user sync - getpwnam(`sync')
+user rene - getpwnam(`rene')
+
+uid 5 - getpwuid(5)
+me - getpwuid(getuid)
+
+`hostname = 'hostname
+
+`rand' - rand,rand,rand,rand
+`srand' srand
+`rand' - rand,rand,rand,rand
+`srand' srand
+`rand' - rand,rand,rand,rand
+
+`uname - ' uname
diff --git a/doc/examples/sysv-args.m4 b/doc/examples/sysv-args.m4
new file mode 100644
index 00000000..7c82beb0
--- /dev/null
+++ b/doc/examples/sysv-args.m4
@@ -0,0 +1,14 @@
+divert(-1)
+define(`nargs', `$#')
+define(`concat', `ifelse(1, $#, `$1', `$1` 'concat(shift($@))')')
+traceon(`concat', `nargs')
+divert
+
+nargs
+nargs()
+nargs(1,2,3,4,5,6)
+
+concat()
+concat(`hej', `med', `dig')
+concat(`hej', `med', `dig', `en gang igen')
+concat(an, awful, lot, of, argument, at, least, more, that, ten, silly, arguments)
diff --git a/doc/examples/time.m4 b/doc/examples/time.m4
new file mode 100644
index 00000000..77341308
--- /dev/null
+++ b/doc/examples/time.m4
@@ -0,0 +1,20 @@
+dnl Copyright (C) 2006, 2010, 2013 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it
+dnl with or without modifications, as long as this notice is preserved.
+load(`time')
+
+`currenttime' = currenttime
+`ctime' = ctime != ctime(eval(currenttime+60*60*24))
+gmtime = gmtime(currenttime)
+localtime = localtime(currenttime)
+define(`q', `$1,$2,$3,$4,$5,$6,$9')dnl
+
+currenttime
+eval(currenttime+60*60*24)
+localtime(eval(currenttime+60*60*24))
+q(localtime(eval(currenttime+60*60*24)))
+mktime = mktime(q(localtime(eval(currenttime+60*60*24))))
+
+%A %B %d, %Y = strftime(`%A %B %d, %Y', currenttime)
+%X on %x = strftime(`%X on %x', currenttime)
diff --git a/doc/examples/time2.m4 b/doc/examples/time2.m4
new file mode 100644
index 00000000..b0d17b35
--- /dev/null
+++ b/doc/examples/time2.m4
@@ -0,0 +1,18 @@
+dnl Copyright (C) 2006, 2010, 2013 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it
+dnl with or without modifications, as long as this notice is preserved.
+`currenttime' = currenttime
+`ctime' = ctime != ctime(eval(currenttime+60*60*24))
+gmtime = gmtime(currenttime)
+localtime = localtime(currenttime)
+define(`q', `$1,$2,$3,$4,$5,$6,$9')dnl
+
+currenttime
+eval(currenttime+60*60*24)
+localtime(eval(currenttime+60*60*24))
+q(localtime(eval(currenttime+60*60*24)))
+mktime = mktime(q(localtime(eval(currenttime+60*60*24))))
+
+%A %B %d, %Y = strftime(`%A %B %d, %Y', currenttime)
+%X on %x = strftime(`%X on %x', currenttime)
diff --git a/doc/examples/trace.m4 b/doc/examples/trace.m4
new file mode 100644
index 00000000..92ce9816
--- /dev/null
+++ b/doc/examples/trace.m4
@@ -0,0 +1,30 @@
+divert(-1)
+
+# move(from, to)
+define(`move', `Move one disk from `$1' to `$2'.
+')
+
+# _hanoi (cnt, from, to, aux)
+define(`_hanoi', `ifelse(eval(`$1'<=1), 1, `move($2, $3)',
+`$0(decr($1), $2, $4, $3)move($2, $3)$0(decr($1), $4, $3, $2)')')
+
+# hanoi (cnt)
+define(`hanoi', `_$0(`$1', source, destination, auxilliary)')
+divert`'dnl
+
+# Debugmode t
+debugmode(`t')
+hanoi(2)
+
+# Debugmode taeq
+debugmode(`taeq')
+hanoi(2)
+
+# Debugmode OFF
+debugmode
+hanoi(2)
+
+# Debugmode ae
+debugmode(`ae')
+traceon(`move', `_hanoi')
+hanoi(2)
diff --git a/doc/examples/translit.m4 b/doc/examples/translit.m4
new file mode 100644
index 00000000..078d1726
--- /dev/null
+++ b/doc/examples/translit.m4
@@ -0,0 +1,8 @@
+# traceon(`translit')dnl
+translit(`GNUs not Unix', `a-z')
+translit(`GNUs not Unix', `a-z', `A-Z')
+translit(`GNUs not Unix', `A-Z', `a-z')
+translit(`GNUs not Unix', `A-Z')
+translit(`a-z', `a-')
+translit(`A-Z', `A-Z-', `-A-Z')
+translit(`GNUs not Unix', `Z-A', `a-z')
diff --git a/doc/examples/undivert.incl b/doc/examples/undivert.incl
new file mode 100644
index 00000000..408e0e20
--- /dev/null
+++ b/doc/examples/undivert.incl
@@ -0,0 +1 @@
+This is to be undiverted soon.
diff --git a/doc/examples/undivert.m4 b/doc/examples/undivert.m4
new file mode 100644
index 00000000..61dfb391
--- /dev/null
+++ b/doc/examples/undivert.m4
@@ -0,0 +1,5 @@
+define(`undiverted', `UNDIVERTED')
+# undiverted file.
+undivert(`undivert.incl')
+# included file.
+include(`undivert.incl')
diff --git a/doc/examples/wrap.m4 b/doc/examples/wrap.m4
new file mode 100644
index 00000000..bbe7ae0b
--- /dev/null
+++ b/doc/examples/wrap.m4
@@ -0,0 +1,10 @@
+divert(-1)
+m4wrap(`Wrapper no. 1
+')
+
+m4wrap(`Wrapper no. 2
+m4wrap(`Wrapper no. 3
+m4wrap(`Wrapper no. 4
+')')')
+divert
+No. 33: The End.
diff --git a/doc/examples/wrapfifo.m4 b/doc/examples/wrapfifo.m4
new file mode 100644
index 00000000..95ff87a0
--- /dev/null
+++ b/doc/examples/wrapfifo.m4
@@ -0,0 +1,10 @@
+dnl Redefine m4wrap to have FIFO semantics.
+define(`_m4wrap_level', `0')dnl
+define(`m4wrap',
+`ifdef(`m4wrap'_m4wrap_level,
+ `define(`m4wrap'_m4wrap_level,
+ defn(`m4wrap'_m4wrap_level)`$1')',
+ `builtin(`m4wrap', `define(`_m4wrap_level',
+ incr(_m4wrap_level))dnl
+m4wrap'_m4wrap_level)dnl
+define(`m4wrap'_m4wrap_level, `$1')')')dnl
diff --git a/doc/examples/wraplifo.m4 b/doc/examples/wraplifo.m4
new file mode 100644
index 00000000..bdbf3fb6
--- /dev/null
+++ b/doc/examples/wraplifo.m4
@@ -0,0 +1,10 @@
+dnl Redefine m4wrap to have LIFO semantics.
+define(`_m4wrap_level', `0')dnl
+define(`_m4wrap', defn(`m4wrap'))dnl
+define(`m4wrap',
+`ifdef(`m4wrap'_m4wrap_level,
+ `define(`m4wrap'_m4wrap_level,
+ `$1'defn(`m4wrap'_m4wrap_level))',
+ `_m4wrap(`define(`_m4wrap_level', incr(_m4wrap_level))dnl
+m4wrap'_m4wrap_level)dnl
+define(`m4wrap'_m4wrap_level, `$1')')')dnl
diff --git a/doc/examples/wraplifo2.m4 b/doc/examples/wraplifo2.m4
new file mode 100644
index 00000000..5b450a76
--- /dev/null
+++ b/doc/examples/wraplifo2.m4
@@ -0,0 +1,9 @@
+dnl Redefine m4wrap to have LIFO semantics, improved example.
+include(`join.m4')dnl
+define(`_m4wrap', defn(`m4wrap'))dnl
+define(`_arg1', `$1')dnl
+define(`m4wrap',
+`ifdef(`_$0_text',
+ `define(`_$0_text', joinall(` ', $@)defn(`_$0_text'))',
+ `_$0(`_arg1(defn(`_$0_text')undefine(`_$0_text'))')dnl
+define(`_$0_text', joinall(` ', $@))')')dnl
diff --git a/doc/m4.texi b/doc/m4.texi
index 77c3a5fe..8d40caee 100644
--- a/doc/m4.texi
+++ b/doc/m4.texi
@@ -3408,7 +3408,7 @@ by @var{separator}. While @code{joinall} always outputs a
@end deffn
Here are some examples of its usage, based on the implementation
-@file{m4-@value{VERSION}/@/examples/@/join.m4} distributed in this
+@file{m4-@value{VERSION}/@/doc/examples/@/join.m4} distributed in this
package:
@comment examples
@@ -3442,7 +3442,7 @@ m4 programming idioms.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`join.m4')dnl
@result{}divert(`-1')
@result{}# join(sep, args) - join each non-empty ARG into a single
@@ -3515,12 +3515,12 @@ quoting are added around each element.
@end deffn
An actual implementation of these three macros is distributed as
-@file{m4-@value{VERSION}/@/examples/@/quote.m4} in this package. First,
-let's examine their usage:
+@file{m4-@value{VERSION}/@/doc/examples/@/quote.m4} in this package.
+First, let's examine their usage:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`quote.m4')
@result{}
-quote-dquote-dquote_elt-
@@ -3553,7 +3553,7 @@ resulting string.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`quote.m4')dnl
@result{}divert(`-1')
@result{}# quote(args) - convert args to single-quoted string
@@ -3618,7 +3618,7 @@ It can, for example, be used for simple counting:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`forloop.m4')
@result{}
forloop(`i', `1', `8', `i ')
@@ -3629,7 +3629,7 @@ For-loops can be nested, like:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`forloop.m4')
@result{}
forloop(`i', `1', `4', `forloop(`j', `1', `8', ` (i, j)')
@@ -3653,11 +3653,11 @@ not finished, it increments the iterator (using the predefined macro
@code{incr}, @pxref{Incr}), and recurses.
Here is an actual implementation of @code{forloop}, distributed as
-@file{m4-@value{VERSION}/@/examples/@/forloop.m4} in this package:
+@file{m4-@value{VERSION}/@/doc/examples/@/forloop.m4} in this package:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`forloop.m4')dnl
@result{}divert(`-1')
@result{}# forloop(var, from, to, stmt) - simple version
@@ -3699,12 +3699,12 @@ invocation is restored.
As an example, this displays each word in a list inside of a sentence,
using an implementation of @code{foreach} distributed as
-@file{m4-@value{VERSION}/@/examples/@/foreach.m4}, and @code{foreachq}
-in @file{m4-@value{VERSION}/@/examples/@/foreachq.m4}.
+@file{m4-@value{VERSION}/@/doc/examples/@/foreach.m4}, and @code{foreachq}
+in @file{m4-@value{VERSION}/@/doc/examples/@/foreachq.m4}.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`foreach.m4')
@result{}
foreach(`x', (foo, bar, foobar), `Word was: x
@@ -3727,7 +3727,7 @@ to a helper macro. This example generates a shell case statement:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`foreach.m4')
@result{}
define(`_case', ` $1)
@@ -3757,7 +3757,7 @@ through the original list. Here is a simple implementation of
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`foreach.m4')dnl
@result{}divert(`-1')
@result{}# foreach(x, (item_1, item_2, ..., item_n), stmt)
@@ -3784,7 +3784,7 @@ rescan:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
define(`a', `1')define(`b', `2')define(`c', `3')
@result{}
include(`foreach.m4')
@@ -3809,7 +3809,7 @@ Obviously, @code{foreachq} did a better job; here is its implementation:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`foreachq.m4')dnl
@result{}include(`quote.m4')dnl
@result{}divert(`-1')
@@ -3836,7 +3836,7 @@ Invoking m4}). Additionally, this implementation does not expand
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`foreach.m4')include(`foreachq.m4')
@result{}
foreach(`name', `(`a', `b')', ` defn(`name')')
@@ -3873,11 +3873,11 @@ few special macros, such as @code{defn}, which cannot be used as the
@end deffn
A sample implementation of these macros is distributed in the file
-@file{m4-@value{VERSION}/@/examples/@/stack.m4}.
+@file{m4-@value{VERSION}/@/doc/examples/@/stack.m4}.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`stack.m4')
@result{}
pushdef(`a', `1')pushdef(`a', `2')pushdef(`a', `3')
@@ -3913,7 +3913,7 @@ undefined during the algorithm.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`stack.m4')dnl
@result{}divert(`-1')
@result{}# stack_foreach(macro, action)
@@ -4018,12 +4018,12 @@ obvious. The macro @code{stack_foreach} mentioned earlier is an example
of a context that provides exactly one argument to a macro name. But
coupled with currying, we can invoke @code{reverse} with two arguments
for each definition of a macro stack. This example uses the file
-@file{m4-@value{VERSION}/@/examples/@/curry.m4} included in the
+@file{m4-@value{VERSION}/@/doc/examples/@/curry.m4} included in the
distribution.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`curry.m4')include(`stack.m4')
@result{}
define(`reverse', `ifelse(`$#', `0', , `$#', `1', ``$1'',
@@ -4048,7 +4048,7 @@ directly rather than going through @code{curry}.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`curry.m4')dnl
@result{}divert(`-1')
@result{}# curry(macro, args)
@@ -4067,7 +4067,7 @@ versions:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`curry.m4')
@result{}
curry(`define', `mylen')(defn(`len'))
@@ -4098,7 +4098,7 @@ M4 versions, or @pxref{Improved copy, , Answers}).
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`curry.m4')include(`stack.m4')
@result{}
define(`rename', `copy($@@)undefine(`$1')')dnl
@@ -4681,14 +4681,14 @@ to macro tracing.
@comment examples
@comment options: -dip
@example
-$ @kbd{m4 -dip -I examples}
+$ @kbd{m4 -dip -I doc/examples}
@error{}m4debug: input read from 'stdin'
define(`foo', `m4wrap(`wrapped text
')dnl')
@result{}
include(`incl.m4')dnl
-@error{}m4debug: path search for 'incl.m4' found 'examples/incl.m4'
-@error{}m4debug: input read from 'examples/incl.m4'
+@error{}m4debug: path search for 'incl.m4' found 'doc/examples/incl.m4'
+@error{}m4debug: input read from 'doc/examples/incl.m4'
@result{}Include file start
@result{}Include file end
@error{}m4debug: input reverted to stdin, line 3
@@ -5922,12 +5922,12 @@ However, earlier versions had reverse ordering (LIFO---last in, first
out), as this behavior is more like the semantics of the C function
@code{atexit}. It is possible to emulate POSIX behavior even
with older versions of GNU M4 by including the file
-@file{m4-@value{VERSION}/@/examples/@/wrapfifo.m4} from the
+@file{m4-@value{VERSION}/@/doc/examples/@/wrapfifo.m4} from the
distribution:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`wrapfifo.m4')dnl
@result{}dnl Redefine m4wrap to have FIFO semantics.
@result{}define(`_m4wrap_level', `0')dnl
@@ -5950,14 +5950,14 @@ m4wrap(`a`'m4wrap(`c
It is likewise possible to emulate LIFO behavior without resorting to
the GNU M4 extension of @code{builtin}, by including the file
-@file{m4-@value{VERSION}/@/examples/@/wraplifo.m4} from the
+@file{m4-@value{VERSION}/@/doc/examples/@/wraplifo.m4} from the
distribution. (Unfortunately, both examples shown here share some
subtle bugs. See if you can find and correct them; or @pxref{Improved
m4wrap, , Answers}).
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`wraplifo.m4')dnl
@result{}dnl Redefine m4wrap to have LIFO semantics.
@result{}define(`_m4wrap_level', `0')dnl
@@ -6086,14 +6086,14 @@ sinclude()
This section uses the @option{--include} command-line option (or
@option{-I}, @pxref{Preprocessor features, , Invoking m4}) to grab
-files from the @file{m4-@value{VERSION}/@/examples}
+files from the @file{m4-@value{VERSION}/@/doc/examples}
directory shipped as part of the GNU @code{m4} package. The
-file @file{m4-@value{VERSION}/@/examples/@/incl.m4} in the distribution
+file @file{m4-@value{VERSION}/@/doc/examples/@/incl.m4} in the distribution
contains the lines:
@comment ignore
@example
-$ @kbd{cat examples/incl.m4}
+$ @kbd{cat doc/examples/incl.m4}
@result{}Include file start
@result{}foo
@result{}Include file end
@@ -6105,7 +6105,7 @@ into the input stream. The contents of the file will be read by
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
define(`foo', `FOO')
@result{}
include(`incl.m4')
@@ -6122,7 +6122,7 @@ of @file{incl.m4}:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
define(`bar', include(`incl.m4'))
@result{}
This is `bar': >>bar<<
@@ -7371,11 +7371,11 @@ word to upper case and the remaining characters to lower case.
@end deffn
First, an example of their usage, using implementations distributed in
-@file{m4-@value{VERSION}/@/examples/@/capitalize.m4}.
+@file{m4-@value{VERSION}/@/doc/examples/@/capitalize.m4}.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`capitalize.m4')
@result{}
upcase(`GNUs not Unix')
@@ -7395,7 +7395,7 @@ them; or @pxref{Improved capitalize, , Answers}).
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`capitalize.m4')dnl
@result{}divert(`-1')
@result{}# upcase(text)
@@ -7502,7 +7502,7 @@ example shows how @code{format} can be used to produce tabular output.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`forloop.m4')
@result{}
forloop(`i', `1', `10', `format(`%6d squared is %10d
@@ -8605,14 +8605,14 @@ This example reuses the file @file{incl.m4} mentioned earlier
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
define(`foo', ``$0' called at __file__:__line__')
@result{}
foo
@result{}foo called at stdin:2
include(`incl.m4')
@result{}Include file start
-@result{}foo called at examples/incl.m4:2
+@result{}foo called at doc/examples/incl.m4:2
@result{}Include file end
@result{}
@end example
@@ -8811,9 +8811,9 @@ mentioned earlier (@pxref{Include}):
@comment examples
@comment options: -s
@example
-$ @kbd{m4 --synclines -I examples}
+$ @kbd{m4 --synclines -I doc/examples}
include(`incl.m4')
-@result{}#line 1 "examples/incl.m4"
+@result{}#line 1 "doc/examples/incl.m4"
@result{}Include file start
@result{}foo
@result{}Include file end
@@ -9503,14 +9503,14 @@ The @code{forloop} macro (@pxref{Forloop}) as presented earlier can go
into an infinite loop if given an iterator that is not parsed as a macro
name. It does not do any sanity checking on its numeric bounds, and
only permits decimal numbers for bounds. Here is an improved version,
-shipped as @file{m4-@value{VERSION}/@/examples/@/forloop2.m4}; this
+shipped as @file{m4-@value{VERSION}/@/doc/examples/@/forloop2.m4}; this
version also optimizes overhead by calling four macros instead of six
per iteration (excluding those in @var{text}), by not dereferencing the
@var{iterator} in the helper @code{@w{_forloop}}.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
undivert(`forloop2.m4')dnl
@result{}divert(`-1')
@result{}# forloop(var, from, to, stmt) - improved version:
@@ -9551,7 +9551,7 @@ to an infinite recursion loop in this example.
@comment status: 1
@comment examples
@example
-$ @kbd{m4 -d -L 9 -I examples}
+$ @kbd{m4 -d -L 9 -I doc/examples}
define(`arg1', `$1')include(`forloop2.m4')include(`quote.m4')
@result{}
define(`double', `define(`$1'`2',
@@ -9586,7 +9586,7 @@ to pass the current iterator value as a single argument. Coupled with
with helper macros if the argument is needed in more than one place in
the expansion, the output can be generated with three, rather than four,
macros of overhead per iteration. Notice how the file
-@file{m4-@value{VERSION}/@/examples/@/forloop3.m4} rearranges the
+@file{m4-@value{VERSION}/@/doc/examples/@/forloop3.m4} rearranges the
arguments of the helper @code{_forloop} to take two arguments that are
placed around the current value. By splitting a balanced set of
parantheses across multiple arguments, the helper macro can now be
@@ -9594,7 +9594,7 @@ shared by @code{forloop} and the new @code{forloop_arg}.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`forloop3.m4')
@result{}
undivert(`forloop3.m4')dnl
@@ -9645,7 +9645,7 @@ quadratic behavior of @code{foreachq}:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`foreachq.m4')
@result{}
traceon(`shift')debugmode(`aq')
@@ -9683,11 +9683,11 @@ recursion use fewer arguments, rather than adding additional quoted
uses of @code{shift}. By doing so, @code{m4} uses less memory, invokes
fewer macros, is less likely to run into machine limits, and most
importantly, performs faster. The fixed version of @code{foreachq} can
-be found in @file{m4-@value{VERSION}/@/examples/@/foreachq2.m4}:
+be found in @file{m4-@value{VERSION}/@/doc/examples/@/foreachq2.m4}:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`foreachq2.m4')
@result{}
undivert(`foreachq2.m4')dnl
@@ -9735,11 +9735,11 @@ place, and by using the fixed-length @samp{$#} instead of an arbitrary
length list as the key to end recursion. The result is an overhead of
six macro invocations per loop (excluding any macros in @var{text}),
instead of eight. This alternative approach is available as
-@file{m4-@value{VERSION}/@/examples/@/foreach3.m4}:
+@file{m4-@value{VERSION}/@/doc/examples/@/foreach3.m4}:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`foreachq3.m4')
@result{}
undivert(`foreachq3.m4')dnl
@@ -9831,7 +9831,7 @@ not yet supported.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`foreachq4.m4')
@result{}
undivert(`foreachq4.m4')dnl
@@ -9859,15 +9859,15 @@ foreachq(`x', ``1', `2', `3', `4'', `x
@end example
For yet another approach, the improved version of @code{foreach},
-available in @file{m4-@value{VERSION}/@/examples/@/foreach2.m4}, simply
-overquotes the arguments to @code{@w{_foreach}} to begin with, using
-@code{dquote_elt}. Then @code{@w{_foreach}} can just use
+available in @file{m4-@value{VERSION}/@/doc/examples/@/foreach2.m4},
+simply overquotes the arguments to @code{@w{_foreach}} to begin with,
+using @code{dquote_elt}. Then @code{@w{_foreach}} can just use
@code{@w{_arg1}} to remove the extra layer of quoting that was added up
front:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`foreach2.m4')
@result{}
undivert(`foreach2.m4')dnl
@@ -9921,7 +9921,7 @@ one, although a leading space still remains.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`quote.m4')include(`foreachq2.m4')
@result{}
pushdef(`sep', `define(`sep', ``, '')')
@@ -9954,7 +9954,7 @@ detrimental effects.
@comment examples
@example
-$ @kbd{m4 -d -I examples}
+$ @kbd{m4 -d -I doc/examples}
include(`foreach2.m4')
@result{}
include(`foreachq2.m4')
@@ -10074,11 +10074,11 @@ the other approach would give the same output, it does so at the expense
of increasing the argument size on each iteration of
@code{_stack_reverse_sep}, which results in quadratic instead of linear
execution time. The improved stack walking macros are available in
-@file{m4-@value{VERSION}/@/examples/@/stack_sep.m4}:
+@file{m4-@value{VERSION}/@/doc/examples/@/stack_sep.m4}:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`stack_sep.m4')
@result{}
define(`copy', `ifdef(`$2', `errprint(`$2 already defined
@@ -10130,7 +10130,7 @@ builtin preserves them for their intended use.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`wraplifo.m4')
@result{}
m4wrap(`define(`foo', ``$0:'-$1-$*-$#-')foo(`a', `b')
@@ -10157,13 +10157,13 @@ Finally, it is worth emulating the GNU M4 extension of saving
all arguments to @code{m4wrap}, separated by a space, rather than saving
just the first argument. This is done with the @code{join} macro
documented previously (@pxref{Shift}). The improved LIFO example is
-shipped as @file{m4-@value{VERSION}/@/examples/@/wraplifo2.m4}, and can
-easily be converted to a FIFO solution by swapping the adjacent
+shipped as @file{m4-@value{VERSION}/@/doc/examples/@/wraplifo2.m4}, and
+can easily be converted to a FIFO solution by swapping the adjacent
invocations of @code{joinall} and @code{defn}.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`wraplifo2.m4')
@result{}
undivert(`wraplifo2.m4')dnl
@@ -10235,7 +10235,7 @@ double-quoted string:
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`capitalize.m4')dnl
define(`active', `act1, ive')dnl
define(`Active', `Act2, Ive')dnl
@@ -10296,11 +10296,11 @@ string. In turn, that means the replacement text has unbalanced quotes,
necessitating another round of @code{changequote}.
In the fixed version below, (also shipped as
-@file{m4-@value{VERSION}/@/examples/@/capitalize.m4}), @code{capitalize}
-uses the alternate quotes of @samp{<<[} and @samp{]>>} (the longer
-strings are chosen so as to be less likely to appear in the text being
-converted). The helpers @code{_to_alt} and @code{_from_alt} merely
-reduce the number of characters required to perform a
+@file{m4-@value{VERSION}/@/doc/examples/@/capitalize.m4}),
+@code{capitalize} uses the alternate quotes of @samp{<<[} and @samp{]>>}
+(the longer strings are chosen so as to be less likely to appear in the
+text being converted). The helpers @code{_to_alt} and @code{_from_alt}
+merely reduce the number of characters required to perform a
@code{changequote}, since the definition changes twice. The outermost
pair means that @code{patsubst} and @code{_capitalize_alt} are invoked
with alternate quoting; the innermost pair is used so that the third
@@ -10312,7 +10312,7 @@ scheme in effect.
@comment examples
@example
-$ @kbd{m4 -I examples}
+$ @kbd{m4 -I doc/examples}
include(`capitalize2.m4')dnl
define(`active', `act1, ive')dnl
define(`Active', `Act2, Ive')dnl
@@ -10398,7 +10398,7 @@ restrictions, covered later (@pxref{Copying This Manual}).
This appendix covers the license for copying this manual. Note that
some of the longer examples in this manual are also distributed in the
-directory @file{m4-@value{VERSION}/@/examples/}, where a more
+directory @file{m4-@value{VERSION}/@/doc/examples/}, where a more
permissive license is in effect when copying just the examples.
@menu