138818Sbostic# 2*62077Sbostic# Copyright (c) 1989, 1993 3*62077Sbostic# The Regents of the University of California. All rights reserved. 438818Sbostic# 538818Sbostic# This code is derived from software contributed to Berkeley by 638818Sbostic# Ozan Yigit. 738818Sbostic# 847964Sbostic# %sccs.include.redist.sh% 938818Sbostic# 10*62077Sbostic# @(#)test.m4 8.1 (Berkeley) 06/06/93 1138818Sbostic# 1238818Sbostic 1338818Sbostic# test file for mp (not comprehensive) 1438818Sbostic# 1538818Sbostic# v7 m4 does not have `decr'. 1638818Sbostic# 1738818Sbosticdefine(DECR,`eval($1-1)') 1838818Sbostic# 1938818Sbostic# include string macros 2038818Sbostic# 2138818Sbosticinclude(string.m4) 2238818Sbostic# 2338818Sbostic# create some fortrash strings for an even uglier language 2438818Sbostic# 2538818Sbosticstring(TEXT, "text") 2638818Sbosticstring(DATA, "data") 2738818Sbosticstring(BEGIN, "begin") 2838818Sbosticstring(END, "end") 2938818Sbosticstring(IF, "if") 3038818Sbosticstring(THEN, "then") 3138818Sbosticstring(ELSE, "else") 3238818Sbosticstring(CASE, "case") 3338818Sbosticstring(REPEAT, "repeat") 3438818Sbosticstring(WHILE, "while") 3538818Sbosticstring(DEFAULT, "default") 3638818Sbosticstring(UNTIL, "until") 3738818Sbosticstring(FUNCTION, "function") 3838818Sbosticstring(PROCEDURE, "procedure") 3938818Sbosticstring(EXTERNAL, "external") 4038818Sbosticstring(FORWARD, "forward") 4138818Sbosticstring(TYPE, "type") 4238818Sbosticstring(VAR, "var") 4338818Sbosticstring(CONST, "const") 4438818Sbosticstring(PROGRAM, "program") 4538818Sbosticstring(INPUT, "input") 4638818Sbosticstring(OUTPUT, "output") 4738818Sbostic# 4838818Sbosticdivert(2) 4938818Sbosticdiversion #1 5038818Sbosticdivert(3) 5138818Sbosticdiversion #2 5238818Sbosticdivert(4) 5338818Sbosticdiversion #3 5438818Sbosticdivert(5) 5538818Sbosticdiversion #4 5638818Sbosticdivert(0) 5738818Sbosticdefine(abc,xxx) 5838818Sbosticifdef(`abc',defined,undefined) 5938818Sbostic# 6038818Sbostic# v7 m4 does this wrong. The right output is 6138818Sbostic# this is A vEry lon sEntEnCE 6238818Sbostic# see m4 documentation for translit. 6338818Sbostic# 6438818Sbostictranslit(`this is a very long sentence', abcdefg, ABCDEF) 6538818Sbostic# 6638818Sbostic# include towers-of-hanoi 6738818Sbostic# 6838818Sbosticinclude(hanoi.m4) 6938818Sbostic# 7038818Sbostic# some reasonable set of disks 7138818Sbostic# 7238818Sbostichanoi(6) 7338818Sbostic# 7438818Sbostic# include ackermann's function 7538818Sbostic# 7638818Sbosticinclude(ack.m4) 7738818Sbostic# 7838818Sbostic# something like (3,3) will blow away un*x m4. 7938818Sbostic# 8038818Sbosticack(2,3) 8138818Sbostic# 8238818Sbostic# include a square_root function for fixed nums 8338818Sbostic# 8438818Sbosticinclude(sqroot.m4) 8538818Sbostic# 8638818Sbostic# some square roots. 8738818Sbostic# 8838818Sbosticsquare_root(15) 8938818Sbosticsquare_root(100) 9038818Sbosticsquare_root(-4) 9138818Sbosticsquare_root(21372) 9238818Sbostic# 9338818Sbostic# some textual material for enjoyment. 9438818Sbostic# 9538818Sbostic[taken from the 'Clemson University Computer Newsletter', 9638818Sbostic September 1981, pp. 6-7] 9738818Sbostic 9838818SbosticI am a wizard in the magical Kingdom of Transformation and I 9938818Sbosticslay dragons for a living. Actually, I am a systems programmer. 10038818SbosticOne of the problems with systems programming is explaining to 10138818Sbosticnon-computer enthusiasts what that is. All of the terms I use to 10238818Sbosticdescribe my job are totally meaningless to them. Usually my response 10338818Sbosticto questions about my work is to say as little as possible. For 10438818Sbosticinstance, if someone asks what happened at work this week, I say 10538818Sbostic"Nothing much" and then I change the subject. 10638818Sbostic 10738818SbosticWith the assistance of my brother, a mechanical engineer, I have devised 10838818Sbostican analogy that everyone can understand. The analogy describes the 10938818Sbostic"Kingdom of Transformation" where travelers wander and are magically 11038818Sbostictransformed. This kingdom is the computer and the travelers are information. 11138818SbosticThe purpose of the computer is to change information to a more meaningful 11238818Sbosticforma. The law of conservation applies here: The computer never creates 11338818Sbosticand never intentionally destroys data. With no further ado, let us travel 11438818Sbosticto the Kingdom of Transformation: 11538818Sbostic 11638818SbosticIn a land far, far away, there is a magical kingdom called the Kingdom of 11738818SbosticTransformation. A king rules over this land and employs a Council of 11838818SbosticWizardry. The main purpose of this kingdom is to provide a way for 11938818Sbosticneighboring kingdoms to transform citizens into more useful citizens. This 12038818Sbosticis done by allowing the citizens to enter the kingdom at one of its ports 12138818Sbosticand to travel any of the many routes in the kingdom. They are magically 12238818Sbostictransformed along the way. The income of the Kingdom of Transformation 12338818Sbosticcomes from the many toll roads within its boundaries. 12438818Sbostic 12538818SbosticThe Kingdom of Transformation was created when several kingdoms got 12638818Sbostictogether and discovered a mutual need for new talents and abilities for 12738818Sbosticcitizens. They employed CTK, Inc. (Creators of Transformation, Inc.) to 12838818Sbosticcreate this kingdom. CTK designed the country, its transportation routes, 12938818Sbosticand its laws of transformation, and created the major highway system. 13038818Sbostic 13138818SbosticHazards 13238818Sbostic======= 13338818Sbostic 13438818SbosticBecause magic is not truly controllable, CTK invariably, but unknowingly, 13538818Sbosticcreates dragons. Dragons are huge fire-breathing beasts which sometimes 13638818Sbosticinjure or kill travelers. Fortunately, they do not travel, but always 13738818Sbosticremain near their den. 13838818Sbostic 13938818SbosticOther hazards also exist which are potentially harmful. As the roads 14038818Sbosticbecome older and more weatherbeaten, pot-holes will develop, trees will 14138818Sbosticfall on travelers, etc. CTK maintenance men are called to fix these 14238818Sbosticproblems. 14338818Sbostic 14438818SbosticWizards 14538818Sbostic======= 14638818Sbostic 14738818SbosticThe wizards play a major role in creating and maintaining the kingdom but 14838818Sbosticget little credit for their work because it is performed secretly. The 14938818Sbosticwizards do not wan the workers or travelers to learn their incantations 15038818Sbosticbecause many laws would be broken and chaos would result. 15138818Sbostic 15238818SbosticCTK's grand design is always general enough to be applicable in many 15338818Sbosticdifferent situations. As a result, it is often difficult to use. The 15438818Sbosticfirst duty of the wizards is to tailor the transformation laws so as to be 15538818Sbosticmore beneficial and easier to use in their particular environment. 15638818Sbostic 15738818SbosticAfter creation of the kingdom, a major duty of the wizards is to search for 15838818Sbosticand kill dragons. If travelers do not return on time or if they return 15938818Sbosticinjured, the ruler of the country contacts the wizards. If the wizards 16038818Sbosticdetermine that the injury or death occurred due to the traveler's 16138818Sbosticnegligence, they provide the traveler's country with additional warnings. 16238818SbosticIf not, they must determine if the cause was a road hazard or a dragon. If 16338818Sbosticthe suspect a road hazard, they call in a CTK maintenance man to locate the 16438818Sbostichazard and to eliminate it, as in repairing the pothole in the road. If 16538818Sbosticthey think that cause was a dragon, then they must find and slay it. 16638818Sbostic 16738818SbosticThe most difficult part of eliminating a dragon is finding it. Sometimes 16838818Sbosticthe wizard magically knows where the dragon's lair it, but often the wizard 16938818Sbosticmust send another traveler along the same route and watch to see where he 17038818Sbosticdisappears. This sounds like a failsafe method for finding dragons (and a 17138818Sbosticsuicide mission for thr traveler) but the second traveler does not always 17238818Sbosticdisappear. Some dragons eat any traveler who comes too close; others are 17338818Sbosticvery picky. 17438818Sbostic 17538818SbosticThe wizards may call in CTK who designed the highway system and 17638818Sbostictransformation laws to help devise a way to locate the dragon. CTK also 17738818Sbostichelps provide the right spell or incantation to slay the dragon. (There is 17838818Sbosticno general spell to slay dragons; each dragon must be eliminated with a 17938818Sbosticdifferent spell.) 18038818Sbostic 18138818SbosticBecause neither CTK nor wizards are perfect, spells to not always work 18238818Sbosticcorrectly. At best, nothing happens when the wrong spell is uttered. At 18338818Sbosticworst, the dragon becomes a much larger dragon or multiplies into several 18438818Sbosticsmaller ones. In either case, new spells must be found. 18538818Sbostic 18638818SbosticIf all existing dragons are quiet (i.e. have eaten sufficiently), wizards 18738818Sbostichave time to do other things. They hide in castles and practice spells and 18838818Sbosticincatations. They also devise shortcuts for travelers and new laws of 18938818Sbostictransformation. 19038818Sbostic 19138818SbosticChanges in the Kingdom 19238818Sbostic====================== 19338818Sbostic 19438818SbosticAs new transformation kingdoms are created and old ones are maintained, 19538818SbosticCTK, Inc. is constantly learning new things. It learns ways to avoid 19638818Sbosticcreating some of the dragons that they have previously created. It also 19738818Sbosticdiscovers new and better laws of transformation. As a result, CTK will 19838818Sbosticperiodically create a new grand design which is far better than the old. 19938818SbosticThe wizards determine when is a good time to implement this new design. 20038818SbosticThis is when the tourist season is slow or when no important travelers 20138818Sbostic(VIPs) are to arrive. The kingdom must be closed for the actual 20238818Sbosticimplementation and is leter reopened as a new and better place to go. 20338818Sbostic 20438818SbosticA final question you might ask is what happens when the number of tourists 20538818Sbosticbecomes too great for the kingdom to handle in a reasonable period of time 20638818Sbostic(i.e., the tourist lines at the ports are too long). The Kingdom of 20738818SbosticTransformation has three options: (1) shorten the paths that a tourist must 20838818Sbostictravel, or (2) convince CTK to develop a faster breed of horses so that the 20938818Sbostictravelers can finish sooner, or (3) annex more territories so that the 21038818Sbostickingdom can handle more travelers. 21138818Sbostic 21238818SbosticThus ends the story of the Kingdom of Transformation. I hope this has 21338818Sbosticexplained my job to you: I slay dragons for a living. 21438818Sbostic 21538818Sbostic# 21638818Sbostic#should do an automatic undivert.. 21738818Sbostic# 218