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