1#	$NetBSD: $
2#
3# Copyright (c) 1989, 1993
4#	The Regents of the University of California.  All rights reserved.
5#
6# This code is derived from software contributed to Berkeley by
7# Ozan Yigit.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17# 3. All advertising materials mentioning features or use of this software
18#    must display the following acknowledgement:
19#	This product includes software developed by the University of
20#	California, Berkeley and its contributors.
21# 4. Neither the name of the University nor the names of its contributors
22#    may be used to endorse or promote products derived from this software
23#    without specific prior written permission.
24#
25# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35# SUCH DAMAGE.
36#
37#	@(#)test.m4	8.1 (Berkeley) 6/6/93
38#
39
40# test file for mp (not comprehensive)
41#
42# v7 m4 does not have `decr'.
43#
44define(DECR,`eval($1-1)')
45#
46# include string macros
47#
48include(string.m4)
49#
50# create some fortrash strings for an even uglier language
51#
52string(TEXT, "text")
53string(DATA, "data")
54string(BEGIN, "begin")
55string(END, "end")
56string(IF, "if")
57string(THEN, "then")
58string(ELSE, "else")
59string(CASE, "case")
60string(REPEAT, "repeat")
61string(WHILE, "while")
62string(DEFAULT, "default")
63string(UNTIL, "until")
64string(FUNCTION, "function")
65string(PROCEDURE, "procedure")
66string(EXTERNAL, "external")
67string(FORWARD, "forward")
68string(TYPE, "type")
69string(VAR, "var")
70string(CONST, "const")
71string(PROGRAM, "program")
72string(INPUT, "input")
73string(OUTPUT, "output")
74#
75divert(2)
76diversion #1
77divert(3)
78diversion #2
79divert(4)
80diversion #3
81divert(5)
82diversion #4
83divert(0)
84define(abc,xxx)
85ifdef(`abc',defined,undefined)
86#
87# v7 m4 does this wrong. The right output is 
88# 	this is A vEry lon sEntEnCE
89# see m4 documentation for translit.
90#
91translit(`this is a very long sentence', abcdefg, ABCDEF)
92#
93# include towers-of-hanoi
94#
95include(hanoi.m4)
96#
97# some reasonable set of disks
98#
99hanoi(6)
100#
101# include ackermann's function
102#
103include(ack.m4)
104#
105# something like (3,3) will blow away un*x m4.
106#
107ack(2,3)
108#
109# include a square_root function for fixed nums
110#
111include(sqroot.m4)
112#
113# some square roots.
114#
115square_root(15)
116square_root(100)
117square_root(-4)
118square_root(21372)
119#
120# some textual material for enjoyment.
121#
122[taken from the 'Clemson University Computer Newsletter',
123 September 1981, pp. 6-7]
124     
125I am a wizard in the magical Kingdom of Transformation and I
126slay dragons for a living.  Actually, I am a systems programmer.
127One of the problems with systems programming is explaining to
128non-computer enthusiasts what that is.  All of the terms I use to
129describe my job are totally meaningless to them.  Usually my response
130to questions about my work is to say as little as possible.  For
131instance, if someone asks what happened at work this week, I say
132"Nothing much" and then I change the subject.
133     
134With the assistance of my brother, a mechanical engineer, I have devised
135an analogy that everyone can understand.  The analogy describes the
136"Kingdom of Transformation" where travelers wander and are magically
137transformed.  This kingdom is the computer and the travelers are information.
138The purpose of the computer is to change information to a more meaningful
139forma.  The law of conservation applies here:  The computer never creates
140and never intentionally destroys data.  With no further ado, let us travel
141to the Kingdom of Transformation:
142     
143In a land far, far away, there is a magical kingdom called the Kingdom of
144Transformation.  A king rules over this land and employs a Council of
145Wizardry.  The main purpose of this kingdom is to provide a way for
146neighboring kingdoms to transform citizens into more useful citizens.  This
147is done by allowing the citizens to enter the kingdom at one of its ports
148and to travel any of the many routes in the kingdom.  They are magically
149transformed along the way.  The income of the Kingdom of Transformation
150comes from the many toll roads within its boundaries.
151     
152The Kingdom of Transformation was created when several kingdoms got
153together and discovered a mutual need for new talents and abilities for
154citizens.  They employed CTK, Inc. (Creators of Transformation, Inc.) to
155create this kingdom.  CTK designed the country, its transportation routes,
156and its laws of transformation, and created the major highway system.
157     
158Hazards
159=======
160     
161Because magic is not truly controllable, CTK invariably, but unknowingly,
162creates dragons.  Dragons are huge fire-breathing beasts which sometimes
163injure or kill travelers.  Fortunately, they do not travel, but always
164remain near their den.
165     
166Other hazards also exist which are potentially harmful.  As the roads
167become older and more weatherbeaten, pot-holes will develop, trees will
168fall on travelers, etc.  CTK maintenance men are called to fix these
169problems.
170     
171Wizards
172=======
173     
174The wizards play a major role in creating and maintaining the kingdom but
175get little credit for their work because it is performed secretly.  The
176wizards do not wan the workers or travelers to learn their incantations
177because many laws would be broken and chaos would result.
178     
179CTK's grand design is always general enough to be applicable in many
180different situations.  As a result, it is often difficult to use.  The
181first duty of the wizards is to tailor the transformation laws so as to be
182more beneficial and easier to use in their particular environment.
183     
184After creation of the kingdom, a major duty of the wizards is to search for
185and kill dragons.  If travelers do not return on time or if they return
186injured, the ruler of the country contacts the wizards.  If the wizards
187determine that the injury or death occurred due to the traveler's
188negligence, they provide the traveler's country with additional warnings.
189If not, they must determine if the cause was a road hazard or a dragon.  If
190the suspect a road hazard, they call in a CTK maintenance man to locate the
191hazard and to eliminate it, as in repairing the pothole in the road.  If
192they think that cause was a dragon, then they must find and slay it.
193     
194The most difficult part of eliminating a dragon is finding it.  Sometimes
195the wizard magically knows where the dragon's lair it, but often the wizard
196must send another traveler along the same route and watch to see where he
197disappears.  This sounds like a failsafe method for finding dragons (and a
198suicide mission for thr traveler) but the second traveler does not always
199disappear.  Some dragons eat any traveler who comes too close; others are
200very picky.
201     
202The wizards may call in CTK who designed the highway system and
203transformation laws to help devise a way to locate the dragon.  CTK also
204helps provide the right spell or incantation to slay the dragon. (There is
205no general spell to slay dragons; each dragon must be eliminated with a
206different spell.)
207     
208Because neither CTK nor wizards are perfect, spells to not always work
209correctly.  At best, nothing happens when the wrong spell is uttered.  At
210worst, the dragon becomes a much larger dragon or multiplies into several
211smaller ones.  In either case, new spells must be found.
212     
213If all existing dragons are quiet (i.e. have eaten sufficiently), wizards
214have time to do other things.  They hide in castles and practice spells and
215incatations.  They also devise shortcuts for travelers and new laws of
216transformation.
217     
218Changes in the Kingdom
219======================
220     
221As new transformation kingdoms are created and old ones are maintained,
222CTK, Inc. is constantly learning new things.  It learns ways to avoid
223creating some of the dragons that they have previously created.  It also
224discovers new and better laws of transformation.  As a result, CTK will
225periodically create a new grand design which is far better than the old.
226The wizards determine when is a good time to implement this new design.
227This is when the tourist season is slow or when no important travelers
228(VIPs) are to arrive.  The kingdom must be closed for the actual
229implementation and is leter reopened as a new and better place to go.
230     
231A final question you might ask is what happens when the number of tourists
232becomes too great for the kingdom to handle in a reasonable period of time
233(i.e., the tourist lines at the ports are too long).  The Kingdom of
234Transformation has three options: (1) shorten the paths that a tourist must
235travel, or (2) convince CTK to develop a faster breed of horses so that the
236travelers can finish sooner, or (3) annex more territories so that the
237kingdom can handle more travelers.
238     
239Thus ends the story of the Kingdom of Transformation.  I hope this has
240explained my job to you:  I slay dragons for a living.
241
242#
243#should do an automatic undivert..
244#
245