1*8ce3644cSJung-uk Kim# $OpenBSD: test.m4,v 1.3 2003/06/03 02:56:11 millert Exp $ 23a68a926SJuli Mallett# $NetBSD: test.m4,v 1.4 1995/09/28 05:38:05 tls Exp $ 33a68a926SJuli Mallett# 43a68a926SJuli Mallett# Copyright (c) 1989, 1993 53a68a926SJuli Mallett# The Regents of the University of California. All rights reserved. 63a68a926SJuli Mallett# 73a68a926SJuli Mallett# This code is derived from software contributed to Berkeley by 83a68a926SJuli Mallett# Ozan Yigit. 93a68a926SJuli Mallett# 103a68a926SJuli Mallett# Redistribution and use in source and binary forms, with or without 113a68a926SJuli Mallett# modification, are permitted provided that the following conditions 123a68a926SJuli Mallett# are met: 133a68a926SJuli Mallett# 1. Redistributions of source code must retain the above copyright 143a68a926SJuli Mallett# notice, this list of conditions and the following disclaimer. 153a68a926SJuli Mallett# 2. Redistributions in binary form must reproduce the above copyright 163a68a926SJuli Mallett# notice, this list of conditions and the following disclaimer in the 173a68a926SJuli Mallett# documentation and/or other materials provided with the distribution. 18*8ce3644cSJung-uk Kim# 3. Neither the name of the University nor the names of its contributors 193a68a926SJuli Mallett# may be used to endorse or promote products derived from this software 203a68a926SJuli Mallett# without specific prior written permission. 213a68a926SJuli Mallett# 223a68a926SJuli Mallett# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 233a68a926SJuli Mallett# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 243a68a926SJuli Mallett# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 253a68a926SJuli Mallett# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 263a68a926SJuli Mallett# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 273a68a926SJuli Mallett# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 283a68a926SJuli Mallett# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 293a68a926SJuli Mallett# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 303a68a926SJuli Mallett# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 313a68a926SJuli Mallett# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 323a68a926SJuli Mallett# SUCH DAMAGE. 333a68a926SJuli Mallett# 343a68a926SJuli Mallett 353a68a926SJuli Mallett# test file for mp (not comprehensive) 363a68a926SJuli Mallett# 373a68a926SJuli Mallett# v7 m4 does not have `decr'. 383a68a926SJuli Mallett# 393a68a926SJuli Mallettdefine(DECR,`eval($1-1)') 403a68a926SJuli Mallett# 413a68a926SJuli Mallett# include string macros 423a68a926SJuli Mallett# 433a68a926SJuli Mallettinclude(string.m4) 443a68a926SJuli Mallett# 453a68a926SJuli Mallett# create some fortrash strings for an even uglier language 463a68a926SJuli Mallett# 473a68a926SJuli Mallettstring(TEXT, "text") 483a68a926SJuli Mallettstring(DATA, "data") 493a68a926SJuli Mallettstring(BEGIN, "begin") 503a68a926SJuli Mallettstring(END, "end") 513a68a926SJuli Mallettstring(IF, "if") 523a68a926SJuli Mallettstring(THEN, "then") 533a68a926SJuli Mallettstring(ELSE, "else") 543a68a926SJuli Mallettstring(CASE, "case") 553a68a926SJuli Mallettstring(REPEAT, "repeat") 563a68a926SJuli Mallettstring(WHILE, "while") 573a68a926SJuli Mallettstring(DEFAULT, "default") 583a68a926SJuli Mallettstring(UNTIL, "until") 593a68a926SJuli Mallettstring(FUNCTION, "function") 603a68a926SJuli Mallettstring(PROCEDURE, "procedure") 613a68a926SJuli Mallettstring(EXTERNAL, "external") 623a68a926SJuli Mallettstring(FORWARD, "forward") 633a68a926SJuli Mallettstring(TYPE, "type") 643a68a926SJuli Mallettstring(VAR, "var") 653a68a926SJuli Mallettstring(CONST, "const") 663a68a926SJuli Mallettstring(PROGRAM, "program") 673a68a926SJuli Mallettstring(INPUT, "input") 683a68a926SJuli Mallettstring(OUTPUT, "output") 693a68a926SJuli Mallett# 703a68a926SJuli Mallettdivert(2) 713a68a926SJuli Mallettdiversion #1 723a68a926SJuli Mallettdivert(3) 733a68a926SJuli Mallettdiversion #2 743a68a926SJuli Mallettdivert(4) 753a68a926SJuli Mallettdiversion #3 763a68a926SJuli Mallettdivert(5) 773a68a926SJuli Mallettdiversion #4 783a68a926SJuli Mallettdivert(0) 793a68a926SJuli Mallettdefine(abc,xxx) 803a68a926SJuli Mallettifdef(`abc',defined,undefined) 813a68a926SJuli Mallett# 823a68a926SJuli Mallett# v7 m4 does this wrong. The right output is 833a68a926SJuli Mallett# this is A vEry lon sEntEnCE 843a68a926SJuli Mallett# see m4 documentation for translit. 853a68a926SJuli Mallett# 863a68a926SJuli Malletttranslit(`this is a very long sentence', abcdefg, ABCDEF) 873a68a926SJuli Mallett# 883a68a926SJuli Mallett# include towers-of-hanoi 893a68a926SJuli Mallett# 903a68a926SJuli Mallettinclude(hanoi.m4) 913a68a926SJuli Mallett# 923a68a926SJuli Mallett# some reasonable set of disks 933a68a926SJuli Mallett# 943a68a926SJuli Malletthanoi(6) 953a68a926SJuli Mallett# 963a68a926SJuli Mallett# include ackermann's function 973a68a926SJuli Mallett# 983a68a926SJuli Mallettinclude(ack.m4) 993a68a926SJuli Mallett# 1003a68a926SJuli Mallett# something like (3,3) will blow away un*x m4. 1013a68a926SJuli Mallett# 1023a68a926SJuli Mallettack(2,3) 1033a68a926SJuli Mallett# 1043a68a926SJuli Mallett# include a square_root function for fixed nums 1053a68a926SJuli Mallett# 1063a68a926SJuli Mallettinclude(sqroot.m4) 1073a68a926SJuli Mallett# 1083a68a926SJuli Mallett# some square roots. 1093a68a926SJuli Mallett# 1103a68a926SJuli Mallettsquare_root(15) 1113a68a926SJuli Mallettsquare_root(100) 1123a68a926SJuli Mallettsquare_root(-4) 1133a68a926SJuli Mallettsquare_root(21372) 1143a68a926SJuli Mallett# 1153a68a926SJuli Mallett# some textual material for enjoyment. 1163a68a926SJuli Mallett# 1173a68a926SJuli Mallett[taken from the 'Clemson University Computer Newsletter', 1183a68a926SJuli Mallett September 1981, pp. 6-7] 1193a68a926SJuli Mallett 1203a68a926SJuli MallettI am a wizard in the magical Kingdom of Transformation and I 1213a68a926SJuli Mallettslay dragons for a living. Actually, I am a systems programmer. 1223a68a926SJuli MallettOne of the problems with systems programming is explaining to 1233a68a926SJuli Mallettnon-computer enthusiasts what that is. All of the terms I use to 1243a68a926SJuli Mallettdescribe my job are totally meaningless to them. Usually my response 1253a68a926SJuli Mallettto questions about my work is to say as little as possible. For 1263a68a926SJuli Mallettinstance, if someone asks what happened at work this week, I say 1273a68a926SJuli Mallett"Nothing much" and then I change the subject. 1283a68a926SJuli Mallett 1293a68a926SJuli MallettWith the assistance of my brother, a mechanical engineer, I have devised 1303a68a926SJuli Mallettan analogy that everyone can understand. The analogy describes the 1313a68a926SJuli Mallett"Kingdom of Transformation" where travelers wander and are magically 1323a68a926SJuli Malletttransformed. This kingdom is the computer and the travelers are information. 1333a68a926SJuli MallettThe purpose of the computer is to change information to a more meaningful 1343a68a926SJuli Mallettforma. The law of conservation applies here: The computer never creates 1353a68a926SJuli Mallettand never intentionally destroys data. With no further ado, let us travel 1363a68a926SJuli Mallettto the Kingdom of Transformation: 1373a68a926SJuli Mallett 1383a68a926SJuli MallettIn a land far, far away, there is a magical kingdom called the Kingdom of 1393a68a926SJuli MallettTransformation. A king rules over this land and employs a Council of 1403a68a926SJuli MallettWizardry. The main purpose of this kingdom is to provide a way for 1413a68a926SJuli Mallettneighboring kingdoms to transform citizens into more useful citizens. This 1423a68a926SJuli Mallettis done by allowing the citizens to enter the kingdom at one of its ports 1433a68a926SJuli Mallettand to travel any of the many routes in the kingdom. They are magically 1443a68a926SJuli Malletttransformed along the way. The income of the Kingdom of Transformation 1453a68a926SJuli Mallettcomes from the many toll roads within its boundaries. 1463a68a926SJuli Mallett 1473a68a926SJuli MallettThe Kingdom of Transformation was created when several kingdoms got 1483a68a926SJuli Malletttogether and discovered a mutual need for new talents and abilities for 1493a68a926SJuli Mallettcitizens. They employed CTK, Inc. (Creators of Transformation, Inc.) to 1503a68a926SJuli Mallettcreate this kingdom. CTK designed the country, its transportation routes, 1513a68a926SJuli Mallettand its laws of transformation, and created the major highway system. 1523a68a926SJuli Mallett 1533a68a926SJuli MallettHazards 1543a68a926SJuli Mallett======= 1553a68a926SJuli Mallett 1563a68a926SJuli MallettBecause magic is not truly controllable, CTK invariably, but unknowingly, 1573a68a926SJuli Mallettcreates dragons. Dragons are huge fire-breathing beasts which sometimes 1583a68a926SJuli Mallettinjure or kill travelers. Fortunately, they do not travel, but always 1593a68a926SJuli Mallettremain near their den. 1603a68a926SJuli Mallett 1613a68a926SJuli MallettOther hazards also exist which are potentially harmful. As the roads 1623a68a926SJuli Mallettbecome older and more weatherbeaten, pot-holes will develop, trees will 1633a68a926SJuli Mallettfall on travelers, etc. CTK maintenance men are called to fix these 1643a68a926SJuli Mallettproblems. 1653a68a926SJuli Mallett 1663a68a926SJuli MallettWizards 1673a68a926SJuli Mallett======= 1683a68a926SJuli Mallett 1693a68a926SJuli MallettThe wizards play a major role in creating and maintaining the kingdom but 1703a68a926SJuli Mallettget little credit for their work because it is performed secretly. The 1713a68a926SJuli Mallettwizards do not wan the workers or travelers to learn their incantations 1723a68a926SJuli Mallettbecause many laws would be broken and chaos would result. 1733a68a926SJuli Mallett 1743a68a926SJuli MallettCTK's grand design is always general enough to be applicable in many 1753a68a926SJuli Mallettdifferent situations. As a result, it is often difficult to use. The 1763a68a926SJuli Mallettfirst duty of the wizards is to tailor the transformation laws so as to be 1773a68a926SJuli Mallettmore beneficial and easier to use in their particular environment. 1783a68a926SJuli Mallett 1793a68a926SJuli MallettAfter creation of the kingdom, a major duty of the wizards is to search for 1803a68a926SJuli Mallettand kill dragons. If travelers do not return on time or if they return 1813a68a926SJuli Mallettinjured, the ruler of the country contacts the wizards. If the wizards 1823a68a926SJuli Mallettdetermine that the injury or death occurred due to the traveler's 1833a68a926SJuli Mallettnegligence, they provide the traveler's country with additional warnings. 1843a68a926SJuli MallettIf not, they must determine if the cause was a road hazard or a dragon. If 1853a68a926SJuli Mallettthe suspect a road hazard, they call in a CTK maintenance man to locate the 1863a68a926SJuli Malletthazard and to eliminate it, as in repairing the pothole in the road. If 1873a68a926SJuli Mallettthey think that cause was a dragon, then they must find and slay it. 1883a68a926SJuli Mallett 1893a68a926SJuli MallettThe most difficult part of eliminating a dragon is finding it. Sometimes 1903a68a926SJuli Mallettthe wizard magically knows where the dragon's lair it, but often the wizard 1913a68a926SJuli Mallettmust send another traveler along the same route and watch to see where he 1923a68a926SJuli Mallettdisappears. This sounds like a failsafe method for finding dragons (and a 1933a68a926SJuli Mallettsuicide mission for thr traveler) but the second traveler does not always 1943a68a926SJuli Mallettdisappear. Some dragons eat any traveler who comes too close; others are 1953a68a926SJuli Mallettvery picky. 1963a68a926SJuli Mallett 1973a68a926SJuli MallettThe wizards may call in CTK who designed the highway system and 1983a68a926SJuli Malletttransformation laws to help devise a way to locate the dragon. CTK also 1993a68a926SJuli Malletthelps provide the right spell or incantation to slay the dragon. (There is 2003a68a926SJuli Mallettno general spell to slay dragons; each dragon must be eliminated with a 2013a68a926SJuli Mallettdifferent spell.) 2023a68a926SJuli Mallett 2033a68a926SJuli MallettBecause neither CTK nor wizards are perfect, spells to not always work 2043a68a926SJuli Mallettcorrectly. At best, nothing happens when the wrong spell is uttered. At 2053a68a926SJuli Mallettworst, the dragon becomes a much larger dragon or multiplies into several 2063a68a926SJuli Mallettsmaller ones. In either case, new spells must be found. 2073a68a926SJuli Mallett 2083a68a926SJuli MallettIf all existing dragons are quiet (i.e. have eaten sufficiently), wizards 2093a68a926SJuli Malletthave time to do other things. They hide in castles and practice spells and 2103a68a926SJuli Mallettincatations. They also devise shortcuts for travelers and new laws of 2113a68a926SJuli Malletttransformation. 2123a68a926SJuli Mallett 2133a68a926SJuli MallettChanges in the Kingdom 2143a68a926SJuli Mallett====================== 2153a68a926SJuli Mallett 2163a68a926SJuli MallettAs new transformation kingdoms are created and old ones are maintained, 2173a68a926SJuli MallettCTK, Inc. is constantly learning new things. It learns ways to avoid 2183a68a926SJuli Mallettcreating some of the dragons that they have previously created. It also 2193a68a926SJuli Mallettdiscovers new and better laws of transformation. As a result, CTK will 2203a68a926SJuli Mallettperiodically create a new grand design which is far better than the old. 2213a68a926SJuli MallettThe wizards determine when is a good time to implement this new design. 2223a68a926SJuli MallettThis is when the tourist season is slow or when no important travelers 2233a68a926SJuli Mallett(VIPs) are to arrive. The kingdom must be closed for the actual 2243a68a926SJuli Mallettimplementation and is leter reopened as a new and better place to go. 2253a68a926SJuli Mallett 2263a68a926SJuli MallettA final question you might ask is what happens when the number of tourists 2273a68a926SJuli Mallettbecomes too great for the kingdom to handle in a reasonable period of time 2283a68a926SJuli Mallett(i.e., the tourist lines at the ports are too long). The Kingdom of 2293a68a926SJuli MallettTransformation has three options: (1) shorten the paths that a tourist must 2303a68a926SJuli Malletttravel, or (2) convince CTK to develop a faster breed of horses so that the 2313a68a926SJuli Malletttravelers can finish sooner, or (3) annex more territories so that the 2323a68a926SJuli Mallettkingdom can handle more travelers. 2333a68a926SJuli Mallett 2343a68a926SJuli MallettThus ends the story of the Kingdom of Transformation. I hope this has 2353a68a926SJuli Mallettexplained my job to you: I slay dragons for a living. 2363a68a926SJuli Mallett 2373a68a926SJuli Mallett# 2383a68a926SJuli Mallett#should do an automatic undivert.. 2393a68a926SJuli Mallett# 240