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