1*38818Sbostic# 2*38818Sbostic# Copyright (c) 1989 The Regents of the University of California. 3*38818Sbostic# All rights reserved. 4*38818Sbostic# 5*38818Sbostic# This code is derived from software contributed to Berkeley by 6*38818Sbostic# Ozan Yigit. 7*38818Sbostic# 8*38818Sbostic# Redistribution and use in source and binary forms are permitted 9*38818Sbostic# provided that the above copyright notice and this paragraph are 10*38818Sbostic# duplicated in all such forms and that any documentation, 11*38818Sbostic# advertising materials, and other materials related to such 12*38818Sbostic# distribution and use acknowledge that the software was developed 13*38818Sbostic# by the University of California, Berkeley. The name of the 14*38818Sbostic# University may not be used to endorse or promote products derived 15*38818Sbostic# from this software without specific prior written permission. 16*38818Sbostic# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17*38818Sbostic# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18*38818Sbostic# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19*38818Sbostic# 20*38818Sbostic# @(#)test.m4 5.1 (Berkeley) 08/28/89 21*38818Sbostic# 22*38818Sbostic 23*38818Sbostic# 24*38818Sbostic# test file for mp (not comprehensive) 25*38818Sbostic# 26*38818Sbostic# v7 m4 does not have `decr'. 27*38818Sbostic# 28*38818Sbosticdefine(DECR,`eval($1-1)') 29*38818Sbostic# 30*38818Sbostic# include string macros 31*38818Sbostic# 32*38818Sbosticinclude(string.m4) 33*38818Sbostic# 34*38818Sbostic# create some fortrash strings for an even uglier language 35*38818Sbostic# 36*38818Sbosticstring(TEXT, "text") 37*38818Sbosticstring(DATA, "data") 38*38818Sbosticstring(BEGIN, "begin") 39*38818Sbosticstring(END, "end") 40*38818Sbosticstring(IF, "if") 41*38818Sbosticstring(THEN, "then") 42*38818Sbosticstring(ELSE, "else") 43*38818Sbosticstring(CASE, "case") 44*38818Sbosticstring(REPEAT, "repeat") 45*38818Sbosticstring(WHILE, "while") 46*38818Sbosticstring(DEFAULT, "default") 47*38818Sbosticstring(UNTIL, "until") 48*38818Sbosticstring(FUNCTION, "function") 49*38818Sbosticstring(PROCEDURE, "procedure") 50*38818Sbosticstring(EXTERNAL, "external") 51*38818Sbosticstring(FORWARD, "forward") 52*38818Sbosticstring(TYPE, "type") 53*38818Sbosticstring(VAR, "var") 54*38818Sbosticstring(CONST, "const") 55*38818Sbosticstring(PROGRAM, "program") 56*38818Sbosticstring(INPUT, "input") 57*38818Sbosticstring(OUTPUT, "output") 58*38818Sbostic# 59*38818Sbosticdivert(2) 60*38818Sbosticdiversion #1 61*38818Sbosticdivert(3) 62*38818Sbosticdiversion #2 63*38818Sbosticdivert(4) 64*38818Sbosticdiversion #3 65*38818Sbosticdivert(5) 66*38818Sbosticdiversion #4 67*38818Sbosticdivert(0) 68*38818Sbosticdefine(abc,xxx) 69*38818Sbosticifdef(`abc',defined,undefined) 70*38818Sbostic# 71*38818Sbostic# v7 m4 does this wrong. The right output is 72*38818Sbostic# this is A vEry lon sEntEnCE 73*38818Sbostic# see m4 documentation for translit. 74*38818Sbostic# 75*38818Sbostictranslit(`this is a very long sentence', abcdefg, ABCDEF) 76*38818Sbostic# 77*38818Sbostic# include towers-of-hanoi 78*38818Sbostic# 79*38818Sbosticinclude(hanoi.m4) 80*38818Sbostic# 81*38818Sbostic# some reasonable set of disks 82*38818Sbostic# 83*38818Sbostichanoi(6) 84*38818Sbostic# 85*38818Sbostic# include ackermann's function 86*38818Sbostic# 87*38818Sbosticinclude(ack.m4) 88*38818Sbostic# 89*38818Sbostic# something like (3,3) will blow away un*x m4. 90*38818Sbostic# 91*38818Sbosticack(2,3) 92*38818Sbostic# 93*38818Sbostic# include a square_root function for fixed nums 94*38818Sbostic# 95*38818Sbosticinclude(sqroot.m4) 96*38818Sbostic# 97*38818Sbostic# some square roots. 98*38818Sbostic# 99*38818Sbosticsquare_root(15) 100*38818Sbosticsquare_root(100) 101*38818Sbosticsquare_root(-4) 102*38818Sbosticsquare_root(21372) 103*38818Sbostic# 104*38818Sbostic# some textual material for enjoyment. 105*38818Sbostic# 106*38818Sbostic[taken from the 'Clemson University Computer Newsletter', 107*38818Sbostic September 1981, pp. 6-7] 108*38818Sbostic 109*38818SbosticI am a wizard in the magical Kingdom of Transformation and I 110*38818Sbosticslay dragons for a living. Actually, I am a systems programmer. 111*38818SbosticOne of the problems with systems programming is explaining to 112*38818Sbosticnon-computer enthusiasts what that is. All of the terms I use to 113*38818Sbosticdescribe my job are totally meaningless to them. Usually my response 114*38818Sbosticto questions about my work is to say as little as possible. For 115*38818Sbosticinstance, if someone asks what happened at work this week, I say 116*38818Sbostic"Nothing much" and then I change the subject. 117*38818Sbostic 118*38818SbosticWith the assistance of my brother, a mechanical engineer, I have devised 119*38818Sbostican analogy that everyone can understand. The analogy describes the 120*38818Sbostic"Kingdom of Transformation" where travelers wander and are magically 121*38818Sbostictransformed. This kingdom is the computer and the travelers are information. 122*38818SbosticThe purpose of the computer is to change information to a more meaningful 123*38818Sbosticforma. The law of conservation applies here: The computer never creates 124*38818Sbosticand never intentionally destroys data. With no further ado, let us travel 125*38818Sbosticto the Kingdom of Transformation: 126*38818Sbostic 127*38818SbosticIn a land far, far away, there is a magical kingdom called the Kingdom of 128*38818SbosticTransformation. A king rules over this land and employs a Council of 129*38818SbosticWizardry. The main purpose of this kingdom is to provide a way for 130*38818Sbosticneighboring kingdoms to transform citizens into more useful citizens. This 131*38818Sbosticis done by allowing the citizens to enter the kingdom at one of its ports 132*38818Sbosticand to travel any of the many routes in the kingdom. They are magically 133*38818Sbostictransformed along the way. The income of the Kingdom of Transformation 134*38818Sbosticcomes from the many toll roads within its boundaries. 135*38818Sbostic 136*38818SbosticThe Kingdom of Transformation was created when several kingdoms got 137*38818Sbostictogether and discovered a mutual need for new talents and abilities for 138*38818Sbosticcitizens. They employed CTK, Inc. (Creators of Transformation, Inc.) to 139*38818Sbosticcreate this kingdom. CTK designed the country, its transportation routes, 140*38818Sbosticand its laws of transformation, and created the major highway system. 141*38818Sbostic 142*38818SbosticHazards 143*38818Sbostic======= 144*38818Sbostic 145*38818SbosticBecause magic is not truly controllable, CTK invariably, but unknowingly, 146*38818Sbosticcreates dragons. Dragons are huge fire-breathing beasts which sometimes 147*38818Sbosticinjure or kill travelers. Fortunately, they do not travel, but always 148*38818Sbosticremain near their den. 149*38818Sbostic 150*38818SbosticOther hazards also exist which are potentially harmful. As the roads 151*38818Sbosticbecome older and more weatherbeaten, pot-holes will develop, trees will 152*38818Sbosticfall on travelers, etc. CTK maintenance men are called to fix these 153*38818Sbosticproblems. 154*38818Sbostic 155*38818SbosticWizards 156*38818Sbostic======= 157*38818Sbostic 158*38818SbosticThe wizards play a major role in creating and maintaining the kingdom but 159*38818Sbosticget little credit for their work because it is performed secretly. The 160*38818Sbosticwizards do not wan the workers or travelers to learn their incantations 161*38818Sbosticbecause many laws would be broken and chaos would result. 162*38818Sbostic 163*38818SbosticCTK's grand design is always general enough to be applicable in many 164*38818Sbosticdifferent situations. As a result, it is often difficult to use. The 165*38818Sbosticfirst duty of the wizards is to tailor the transformation laws so as to be 166*38818Sbosticmore beneficial and easier to use in their particular environment. 167*38818Sbostic 168*38818SbosticAfter creation of the kingdom, a major duty of the wizards is to search for 169*38818Sbosticand kill dragons. If travelers do not return on time or if they return 170*38818Sbosticinjured, the ruler of the country contacts the wizards. If the wizards 171*38818Sbosticdetermine that the injury or death occurred due to the traveler's 172*38818Sbosticnegligence, they provide the traveler's country with additional warnings. 173*38818SbosticIf not, they must determine if the cause was a road hazard or a dragon. If 174*38818Sbosticthe suspect a road hazard, they call in a CTK maintenance man to locate the 175*38818Sbostichazard and to eliminate it, as in repairing the pothole in the road. If 176*38818Sbosticthey think that cause was a dragon, then they must find and slay it. 177*38818Sbostic 178*38818SbosticThe most difficult part of eliminating a dragon is finding it. Sometimes 179*38818Sbosticthe wizard magically knows where the dragon's lair it, but often the wizard 180*38818Sbosticmust send another traveler along the same route and watch to see where he 181*38818Sbosticdisappears. This sounds like a failsafe method for finding dragons (and a 182*38818Sbosticsuicide mission for thr traveler) but the second traveler does not always 183*38818Sbosticdisappear. Some dragons eat any traveler who comes too close; others are 184*38818Sbosticvery picky. 185*38818Sbostic 186*38818SbosticThe wizards may call in CTK who designed the highway system and 187*38818Sbostictransformation laws to help devise a way to locate the dragon. CTK also 188*38818Sbostichelps provide the right spell or incantation to slay the dragon. (There is 189*38818Sbosticno general spell to slay dragons; each dragon must be eliminated with a 190*38818Sbosticdifferent spell.) 191*38818Sbostic 192*38818SbosticBecause neither CTK nor wizards are perfect, spells to not always work 193*38818Sbosticcorrectly. At best, nothing happens when the wrong spell is uttered. At 194*38818Sbosticworst, the dragon becomes a much larger dragon or multiplies into several 195*38818Sbosticsmaller ones. In either case, new spells must be found. 196*38818Sbostic 197*38818SbosticIf all existing dragons are quiet (i.e. have eaten sufficiently), wizards 198*38818Sbostichave time to do other things. They hide in castles and practice spells and 199*38818Sbosticincatations. They also devise shortcuts for travelers and new laws of 200*38818Sbostictransformation. 201*38818Sbostic 202*38818SbosticChanges in the Kingdom 203*38818Sbostic====================== 204*38818Sbostic 205*38818SbosticAs new transformation kingdoms are created and old ones are maintained, 206*38818SbosticCTK, Inc. is constantly learning new things. It learns ways to avoid 207*38818Sbosticcreating some of the dragons that they have previously created. It also 208*38818Sbosticdiscovers new and better laws of transformation. As a result, CTK will 209*38818Sbosticperiodically create a new grand design which is far better than the old. 210*38818SbosticThe wizards determine when is a good time to implement this new design. 211*38818SbosticThis is when the tourist season is slow or when no important travelers 212*38818Sbostic(VIPs) are to arrive. The kingdom must be closed for the actual 213*38818Sbosticimplementation and is leter reopened as a new and better place to go. 214*38818Sbostic 215*38818SbosticA final question you might ask is what happens when the number of tourists 216*38818Sbosticbecomes too great for the kingdom to handle in a reasonable period of time 217*38818Sbostic(i.e., the tourist lines at the ports are too long). The Kingdom of 218*38818SbosticTransformation has three options: (1) shorten the paths that a tourist must 219*38818Sbostictravel, or (2) convince CTK to develop a faster breed of horses so that the 220*38818Sbostictravelers can finish sooner, or (3) annex more territories so that the 221*38818Sbostickingdom can handle more travelers. 222*38818Sbostic 223*38818SbosticThus ends the story of the Kingdom of Transformation. I hope this has 224*38818Sbosticexplained my job to you: I slay dragons for a living. 225*38818Sbostic 226*38818Sbostic# 227*38818Sbostic#should do an automatic undivert.. 228*38818Sbostic# 229