home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13350 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  64.0 KB

  1. Xref: sparky comp.lang.c:13350 comp.sources.d:1249 comp.unix.wizards:3849 alt.sources:2019 misc.misc:3274
  2. Path: sparky!uunet!cis.ohio-state.edu!ucbvax!hoptoad!chongo
  3. From: chongo@hoptoad.uucp (Landon C. Noll)
  4. Newsgroups: comp.lang.c,comp.sources.d,comp.unix.wizards,alt.sources,misc.misc
  5. Subject: 1992 International Obfuscated C Code Contest winners, 1 of 4
  6. Keywords: ioccc
  7. Message-ID: <34848@hoptoad.uucp>
  8. Date: 9 Sep 92 01:38:12 GMT
  9. Expires: 28 Nov 92 00:00:00 GMT
  10. Reply-To: chongo@hoptoad.UUCP (Landon C. Noll)
  11. Organization: Nebula Consultants in San Francisco
  12. Lines: 1825
  13.  
  14. Enclosed is the first of a 4 part shar file containing the winners of
  15. the 1992 International Obfuscated C Code Contest.
  16.  
  17. First, we congratulate the winners for doing a fine job.  Their efforts
  18. and feedback have resulted another good year for the contest.
  19.  
  20. Second, the 1993 contest will not open until early March 1993.  The
  21. rules are expected to be very similar to the 1992 rules, though the
  22. input format will change slightly.  Please wait for the 1993 rules
  23. to be posted before submitting 1993 entries.
  24.  
  25. Third, an International Obfuscated Perl contest is being considered.
  26. Larry Wall and Landon Curt Noll plan to formulate the contest rules
  27. (and a contest name) sometime this year.  Watch comp.lang.perl for
  28. details.  Send contest ideas (but not entries!) to chongo@toad.com.
  29.  
  30. Last, we would like to make an apology to the 1992 winners and to the
  31. net for the delay in posting of these results.  The poster of this
  32. article (chongo) went on vacation, held extended discussions with
  33. several of the contest winners and attempted to deal with one entry
  34. that appears to conflict with US export regulations.
  35.  
  36. If you find problems with some of the contest entries, or find typos
  37. in our notes, please send ->PATCH FILES OR COMPLETE FILES<- containing
  38. the corrections to:
  39.  
  40.     judges@toad.com   -or-   ...!{sun,uunet,utzoo,pyramid}!hoptoad!judges
  41.  
  42. chongo <Landon Curt Noll> /\cc/\        hoptoad!chongo
  43. Larry Bassel                            {uunet,ucbvax,cbosgd}|sun!lab
  44.  
  45. p.s. previous winners are available on ftp.uu.net via anonymous ftp
  46.      under the directory ~/pub/ioccc.  Any 'patches' to the 1992 winners
  47.      will be deposited there in a few months.
  48.  
  49. =-=
  50.  
  51. Submitted-by: chongo@toad.com (Landon Curt Noll)
  52. #
  53. # Send comments, questions, bugs to: 
  54. #
  55. #    judges@toad.com   -or-   ...!{sun,uunet,utzoo,pyramid}!hoptoad!judges
  56. #
  57. # You are strongly encouraged to read the new contest rules before
  58. # sending any entries.  The rules, and sometimes the contest Email
  59. # address itself, change over time.  A valid entry one year may
  60. # be rejected in a later year due to changes in the rules.  The typical
  61. # start date for a contest is early March.  The typical end date for a
  62. # contest is early May.
  63. #
  64. # The contest rules are posted to comp.unix.wizards, comp.lang.c,
  65. # misc.misc, alt.sources and comp.sources.d.  If you do not have access 
  66. # to these groups, or if you missed the early March posting, you may 
  67. # request a copy from the judges, via Email, at the address above.
  68. #
  69. Archive-name: ioccc.1992/part01
  70.  
  71. ---- Cut Here and unpack ----
  72. #!/bin/sh
  73. # This is ioccc.1992, a shell archive (shar 3.32)
  74. # made 09/09/1992 00:40 UTC by chongo@toad.com (Landon Curt Noll)
  75. #
  76. # Send comments, questions, bugs to: 
  77. #
  78. #    judges@toad.com   -or-   ...!{sun,uunet,utzoo,pyramid}!hoptoad!judges
  79. #
  80. # You are strongly encouraged to read the new contest rules before
  81. # sending any entries.  The rules, and sometimes the contest Email
  82. # address itself, change over time.  A valid entry one year may
  83. # be rejected in a later year due to changes in the rules.  The typical
  84. # start date for a contest is early March.  The typical end date for a
  85. # contest is early May.
  86. #
  87. # The contest rules are posted to comp.unix.wizards, comp.lang.c,
  88. # misc.misc, alt.sources and comp.sources.d.  If you do not have access 
  89. # to these groups, or if you missed the early March posting, you may 
  90. # request a copy from the judges, via Email, at the address above.
  91. #
  92. # Source directory /u4/chongo/bench/ioccc
  93. #
  94. # existing files WILL be overwritten
  95. #
  96. # This shar contains:
  97. # length  mode       name
  98. # ------ ---------- ------------------------------------------
  99. #   3693 -r--r--r-- 1992/README
  100. #   7451 -r--r--r-- 1992/rules
  101. #  22215 -r--r--r-- 1992/guidelines
  102. #   5632 -r--r--r-- 1992/Makefile
  103. #   2583 -r--r--r-- 1992/adrian.c
  104. #    131 -r--r--r-- 1992/adrian.grep.1
  105. #     64 -r--r--r-- 1992/adrian.grep.2
  106. #     99 -r--r--r-- 1992/adrian.grep.3
  107. #     48 -r--r--r-- 1992/adrian.grep.4
  108. #     60 -r--r--r-- 1992/adrian.grep.5
  109. #     92 -r--r--r-- 1992/adrian.grep.from
  110. #    101 -r--r--r-- 1992/adrian.grep.try
  111. #   7292 -r--r--r-- 1992/adrian.hint
  112. #   2581 -r--r--r-- 1992/adrian.orig.c
  113. #   3164 -r--r--r-- 1992/albert.c
  114. #   3193 -r--r--r-- 1992/albert.hint
  115. #   3153 -r--r--r-- 1992/albert.orig.c
  116. #   8745 -r-------- 1992/ant.README
  117. #   2547 -r--r--r-- 1992/ant.c
  118. #    656 -r--r--r-- 1992/ant.hint
  119. #   3164 -r--r--r-- 1992/ant.test.mk
  120. #   2236 -r--r--r-- 1992/buzzard.1.c
  121. #   8217 -r--r--r-- 1992/buzzard.1.hint
  122. #    756 -r--r--r-- 1992/buzzard.2.README
  123. #    791 -r--r--r-- 1992/buzzard.2.c
  124. #  25773 -r--r--r-- 1992/buzzard.2.design
  125. #   8915 -r--r--r-- 1992/buzzard.2.hint
  126. #    794 -r--r--r-- 1992/buzzard.2.orig.c
  127. #    212 -r--r--r-- 1992/demo1.1st
  128. #     34 -r--r--r-- 1992/demo1.th
  129. #    135 -r--r--r-- 1992/demo2.th
  130. #    245 -r--r--r-- 1992/demo3.th
  131. #    439 -r--r--r-- 1992/demo4.th
  132. #    339 -r--r--r-- 1992/demo5.th
  133. #    388 -r--r--r-- 1992/demo6.th
  134. #   1513 -r--r--r-- 1992/gson.c
  135. #  10891 -r--r--r-- 1992/gson.hint
  136. #   1774 -r--r--r-- 1992/help.th
  137. #   1965 -r--r--r-- 1992/imc.c
  138. #   6479 -r--r--r-- 1992/imc.hint
  139. #   1937 -r--r--r-- 1992/imc.orig.c
  140. #   2119 -r--r--r-- 1992/kivinen.c
  141. #   2547 -r--r--r-- 1992/kivinen.hint
  142. #   2084 -r--r--r-- 1992/kivinen.orig.c
  143. #   1885 -r--r--r-- 1992/lush.c
  144. #    695 -r--r--r-- 1992/lush.hint
  145. #   1885 -r--r--r-- 1992/lush.orig.c
  146. #   1766 -r--r--r-- 1992/marangon.c
  147. #   1062 -r--r--r-- 1992/marangon.hint
  148. #   1743 -r--r--r-- 1992/marangon.orig.c
  149. #    878 -r--r--r-- 1992/nathan.c
  150. #   4546 -r--r--r-- 1992/nathan.hint
  151. #   6605 -r--r--r-- 1992/third
  152. #   3203 -r--r--r-- 1992/vern.c
  153. #   6513 -r--r--r-- 1992/vern.hint
  154. #    305 -r--r--r-- 1992/westley.c
  155. #   4374 -r--r--r-- 1992/westley.hint
  156. #   3201 -r--r--r-- 1992/vern.orig.c
  157. #
  158. if touch 2>&1 | fgrep 'amc' > /dev/null
  159.  then TOUCH=touch
  160.  else TOUCH=true
  161. fi
  162. # ============= 1992/README ==============
  163. if test ! -d '1992'; then
  164.     echo "x - creating directory 1992"
  165.     mkdir '1992'
  166. fi
  167. echo "x - extracting 1992/README (Text)"
  168. sed 's/^X//' << 'SHAR_EOF' > 1992/README &&
  169. X1992 marked the "The Ninth International Obfuscated C Code Contest"
  170. X
  171. XUse make to compile entries.  It is possible that on BSD or non-unix
  172. Xsystems the makefile needs to be changed.  See the Makefile for details.
  173. X
  174. XLook at the source and try to figure out what the programs do, and run
  175. Xthem with various inputs.  If you want to, look at the hints files for
  176. Xspoilers - this year we included most of the information included
  177. Xby the submitters.
  178. X
  179. XRead over the makefile for compile/build issues.  Your system may
  180. Xrequire certain changes (add or remove a library, add or remove a
  181. X#define).  A number of compilers had problems optimizing certain
  182. Xentries.  Some compilers do optimize, but the resulting program
  183. Xdoes not work.  By default we have left off -O from compile lines.  
  184. XYou might want to add -O back, or add it back for certain entries
  185. Xwhere performance is important.
  186. X
  187. XThis year marked an all time high for number of entries as well as the
  188. Xquality of entries.  Nearly twice the usual number of entries made it
  189. Xto the final judging rounds.  Even when we raised the standards for
  190. Xwinning, we still wound giving out a few more awards than in other
  191. Xyears.  The new size rules size probably contributed to the overall
  192. Xhigh quality.
  193. X
  194. XFYI: By tradition, we do not record the count the number entries,
  195. X     nor do we give our our guess as to the number of entries 
  196. X     received.  For folks who wonder, we can say that we consumed 
  197. X     about 2000 pages of output (printing between 2 and 4 normal 
  198. X     pages per side) during the judging process this year.
  199. X
  200. XThe new instructions for submitting entries worked well - we were
  201. Xable to write scripts to unpack them and eliminate duplicates.
  202. X
  203. XAs promised last year, we accepted programs that made use of the X
  204. Xlibraries for the first time.  We now consider ANSI C compilers to be
  205. Xthe "standard" version that the entries were compiled with.
  206. X
  207. XName and address information are separated from the actual program
  208. Xprior to judging.  This eliminates any chance that we would bias our
  209. Xjudging for/against any person or group.  In the end, we are surprised
  210. Xas you are to see who as won.  Even so, it is worth noting that
  211. XBrian Westley has submitted a winning entry for the past 6 years!
  212. X
  213. X
  214. XA few notes regarding future contests:
  215. X
  216. XWe did not give awards to some traditional contest categories such as
  217. X"Best Layout".  We felt that to do so would deny awards to more
  218. Xdeserving entries.  These categories have not been eliminated.  We will
  219. Xlikely be awarding them in future years.
  220. X
  221. XWe received a few entries whose instructions were rot13'd.  While
  222. Xnothing was said about this in the rules, we found that it made the 
  223. Xjudging process a little harder, so we may request that this not
  224. Xbe done this in the future.
  225. X
  226. XSome thought has been given to a separate obfuscated perl contest.
  227. XWatch comp.lang.perl for details!
  228. X
  229. XBe sure to wait until the 1993 rules are posted before submitting entries.  
  230. XWe may fine tune the rules to reflect the some ideas above.
  231. X
  232. XPlease send us comments and suggestions what we have expressed above.
  233. XAlso include anything else that you would like to see in future contests.
  234. XSend such email to:
  235. X
  236. X    ...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
  237. X    judges@toad.com
  238. X
  239. X
  240. XIf you use, distribute or publish these entries in some way, please drop
  241. Xus a line.  We enjoy seeing who, where and how the contest is used.
  242. X
  243. XIf you have problems with any of the entries, AND YOU HAVE A FIX, please
  244. XEmail the fix (patch file or the entire changed file) to the above address.
  245. X
  246. XCredits:
  247. X
  248. XWe would like to thank Barbara Frezza for her role as official chef of
  249. Xthe contest.  Landon Noll and Larry Bassel appreciated the opportunity
  250. Xto serve as official taste testers. Yummo!
  251. SHAR_EOF
  252. $TOUCH -am 0908163992 1992/README &&
  253. chmod 0444 1992/README ||
  254. echo "restore of 1992/README failed"
  255. set `wc -c 1992/README`;Wc_c=$1
  256. if test "$Wc_c" != "3693"; then
  257.     echo original size 3693, current size $Wc_c
  258. fi
  259. # ============= 1992/rules ==============
  260. echo "x - extracting 1992/rules (Text)"
  261. sed 's/^X//' << 'SHAR_EOF' > 1992/rules &&
  262. X9th International Obfuscated C Code Contest Rules
  263. X
  264. X    Obfuscate:  tr.v.  -cated, -cating, -cates.  1. a.  To render obscure.
  265. X        b.  To darken.  2. To confuse:  his emotions obfuscated his
  266. X        judgment.  [LLat. obfuscare, to darken : ob(intensive) +
  267. X        Lat. fuscare, to darken < fuscus, dark.] -obfuscation n.
  268. X        obfuscatory adj.
  269. X
  270. X
  271. XGOALS OF THE CONTEST:
  272. X
  273. X    * To write the most Obscure/Obfuscated C program under the rules below.
  274. X    * To show the importance of programming style, in an ironic way.
  275. X    * To stress C compilers with unusual code.
  276. X    * To illustrate some of the subtleties of the C language.
  277. X    * To provide a safe forum for poor C code.  :-)
  278. X
  279. X
  280. XRULES:
  281. X
  282. X    To help us with the volume of entries, we ask that you follow these rules:
  283. X
  284. X    1) Your entry must be a complete program.
  285. X
  286. X    2) Your entry must be <= 3217 bytes in length.  The number of characters
  287. X       excluding whitespace (tab, space, newline), and excluding any ; { or }
  288. X       followed by either whitespace or end of file, must be <= 1536.
  289. X
  290. X    3) Your entry must be submitted in the following format:
  291. X
  292. X---entry---
  293. Xrule:    1992
  294. Xtitle:    title of entry  (see comments below)
  295. Xentry:    Entry number from 0 to 7 inclusive
  296. Xdate:    Date/time of submission   (use the format of the date command)
  297. Xhost:    Machine(s) and OS(s) under which your entry was tested
  298. X    Use tab indented lines if needed
  299. X---remark---
  300. X    Place remarks about this entry in this section.  It would be helpful if
  301. X    you were to indent your remarks with 4 spaces, though it is not a
  302. X    requirement.  Also, if possible, try to avoid going beyond the 79th
  303. X    column.  Blank lines are ok.
  304. X---author---
  305. Xname:    your name
  306. Xorg:    School/Company/Organization
  307. Xaddr:    postal address
  308. X    use tab indented lines to continue
  309. X    don't forget to include the country
  310. Xemail:  Email address from a well known site or registered domain.
  311. X        If you give several forms, list them on separate tab indented lines.
  312. Xanon:    y or n       (y => remain anonymous, n => ok to publish this info)
  313. X---info---
  314. XIf your program needs an info file, place a uuencoded copy of it in
  315. Xthis section.  In the case of multiple info files, use multiple info
  316. Xsections.  If your entry does not need a info file, skip this section.
  317. X---build---
  318. XPlace a uuencoded copy of the command(s) used to compile/build your program
  319. Xin this section.  It must uudecode into a file named 'build'.  The resulting
  320. Xfile must be 255 bytes or less.
  321. X---program---
  322. XPlace a uuencoded copy of your program in this section.  It must uudecode
  323. Xinto a file named is 'prog.c'.  The resulting file must follow rule #2.
  324. X---end---
  325. X
  326. X      Regarding the above format:
  327. X
  328. X    * The title must match expression: [a-zA-Z0-9_+=,][a-zA-Z0-9_+=,.-]*
  329. X      and must be 1 to 10 characters in length.
  330. X
  331. X      It is suggested, but not required, that the title should
  332. X      incorporate your username; in the case of multiple authors,
  333. X      consider using parts of the usernames of the authors.
  334. X
  335. X    * All text outside of the above format will be kept confidential,
  336. X      unless otherwise stated.  Notes about an author of a winning entry
  337. X      will be published unless 'y' was given to that author's 'anon' line.
  338. X
  339. X    * To credit multiple authors, include an ---author--- section for
  340. X      each author.  Each should start with ---author--- line, and
  341. X      should be found between the ---entry--- and ---build--- sections.
  342. X
  343. X    * The entry's remarks should include:
  344. X        - what this program does
  345. X        - how to run the program (sample args or input)
  346. X        - special compile or execution instructions, if any
  347. X        - special filename requirements (see rule 4 and 5)
  348. X        - information about any ---data--- files
  349. X        - why you think the program is obfuscated
  350. X        - note if this entry is a re-submission of a previous entry.
  351. X        - any other remarks (humorous or otherwise)
  352. X
  353. X        * Info files should be used only to supplement your entry.  They 
  354. X      should not be required to exist.
  355. X
  356. X      If your entry does not need an info file, skip the ---info---
  357. X      section.  If your entry needs multiple info files, use multiple 
  358. X      ---info--- sections, one per info file.  You should describe
  359. X      each info file in the ---remark--- section.
  360. X
  361. X    4) If your entry is selected as a winner, it will be modified as follows:
  362. X
  363. X       'build' is incorporated into a makefile, and 'build' is removed
  364. X       'prog.c' is renamed to your entry's title, followed by an optional
  365. X           digit, followed by '.c'
  366. X       your entry is compiled into a file with the name of your entry's
  367. X           title, possibly followed by a digit
  368. X
  369. X       If your entry requires that a build file exist, state so in your
  370. X       entry's remark section.  The makefile will be arranged to execute a
  371. X       build shell script containing the 'build' information.  The name of
  372. X       this build shell script will be your entry's title, possibly followed
  373. X       by a digit, followed by '.sh'.
  374. X
  375. X       If needed, your entry's remarks should indicate how your entry must
  376. X       be changed in order to deal with the new filenames.
  377. X
  378. X    5) The build file, the source and the resulting executable should be
  379. X       treated as read-only files.  If your entry needs to modify these files,
  380. X       it should make and modify a copy of the appropriate file.  If this
  381. X       occurs, state so in your entry's remarks.
  382. X
  383. X    6) Your entry must be written in C.  Use of ANSI C is preferred.  Use
  384. X       of common C (K&R + extensions) is permitted, as long as it does not
  385. X       cause major problems for ANSI C compilers.
  386. X
  387. X    7) The program must be of original work.  All programs must be in the
  388. X       public domain.  All copyrighted programs will be rejected.
  389. X
  390. X    8) Entries must be received prior to 09-May-92 0:00 UTC.  (UTC is
  391. X       essentially equivalent to Greenwich Mean Time)  Email your entries to:
  392. X
  393. X        ...!{apple,pyramid,sun,uunet}!hoptoad!obfuscate
  394. X        obfuscate@toad.com
  395. X
  396. X       We request that your message use the subject 'ioccc entry'.
  397. X
  398. X       If possible, we request that you hold off on Emailing your entries
  399. X       until 1-Mar-92 0:00 UTC.  Early entries will be accepted, however.
  400. X       We will attempt to email a confirmation to the the first author for
  401. X       all entries received after 1-Mar-92 0:00 UTC.
  402. X
  403. X    9) Each person may submit up to 8 entries per contest year.  Each entry
  404. X       must be sent in a separate Email letter.
  405. X
  406. X   10) Entries requiring human interaction to be built are not allowed.  
  407. X       Compiling an entry produce a file (or files) which may be executed.
  408. X
  409. X
  410. XFOR MORE INFORMATION:
  411. X
  412. X    The Judging will be done by Landon Noll and Larry Bassel.  Please send
  413. X    questions or comments (but not entries) about the contest, to:
  414. X
  415. X    ...!{apple,pyramid,sun,uunet}!hoptoad!judges
  416. X    judges@toad.com
  417. X
  418. X    The rules and the guidelines may (and often do) change from year to
  419. X    year.  You should be sure you have the current rules and guidelines
  420. X    prior to submitting entries.  The IOCCC rules and guidelines may be
  421. X    obtained from the judges at the address above.  Please use one of
  422. X    the following subjects in your request:
  423. X
  424. X    send rules      to obtain the current IOCCC rules
  425. X    send guidelines      to obtain the current IOCCC guidelines
  426. X    send mkentry      to obtain the current IOCCC mkentry program
  427. X    send all      to obtain the current IOCCC rules,guidelines,mkentry
  428. X
  429. X    One may also obtain them via anonymous ftp from:
  430. X
  431. X    host: ftp.uu.net    (137.39.1.9)
  432. X    user: anonymous
  433. X    pass: yourname@yourhost
  434. X    dir:  /pub/ioccc
  435. X
  436. X
  437. Xchongo <Landon Curt Noll> /\cc/\      hoptoad!chongo
  438. XLarry Bassel                  {uunet,ucbvax,cbosgd}|sun!lab
  439. SHAR_EOF
  440. $TOUCH -am 0817110092 1992/rules &&
  441. chmod 0444 1992/rules ||
  442. echo "restore of 1992/rules failed"
  443. set `wc -c 1992/rules`;Wc_c=$1
  444. if test "$Wc_c" != "7451"; then
  445.     echo original size 7451, current size $Wc_c
  446. fi
  447. # ============= 1992/guidelines ==============
  448. echo "x - extracting 1992/guidelines (Text)"
  449. sed 's/^X//' << 'SHAR_EOF' > 1992/guidelines &&
  450. X9th International Obfuscated C Code Contest Guidelines, Hints and Comments
  451. X
  452. X
  453. XABOUT THIS FILE:
  454. X
  455. X    This file is intended to help people who wish to submit entries to
  456. X    the International Obfuscated C Code Contest (IOCCC for short).
  457. X
  458. X    This is not the IOCCC rules, though it does contain comments about
  459. X    them.  The guidelines should be viewed as hints and suggestions.
  460. X    Entries that violate the guidelines but remain within the rules are
  461. X    allowed.  Even so, you are safer if you remain within the guidelines.
  462. X
  463. X    You should read the current IOCCC rules, prior to submitting entries.
  464. X    The rules are typically sent out with these guidelines.
  465. X
  466. X
  467. XWHAT IS NEW IN 1992:
  468. X
  469. X    The size rules are different this year.  There is a more relaxed
  470. X    rule to encourage formatting styles beyond rectangular blobs of C
  471. X    code.  The build file (how to compile) has been expanded as well.
  472. X    See the rules, and OUR LIKES AND DISLIKES for details.
  473. X
  474. X    The entry format is better (for us anyway).  The program mkentry.c
  475. X    provides a convenient way to form an entry.  See ENTRY FORMAT.
  476. X
  477. X    The original entry source, build and resulting binary should be
  478. X    treated as read-only.  There is a provision to allow entries to
  479. X    modify these files indirectly.  See ENTRY FORMAT.
  480. X
  481. X    This year, we are experimenting with a new category of programs:
  482. X    X clients.  X client entries should be as portable as possible.
  483. X    See OUR LIKES AND DISLIKES.
  484. X
  485. X
  486. XHINTS AND SUGGESTIONS:
  487. X
  488. X    You are encouraged to examine the winners of previous contests.  See
  489. X    FOR MORE INFORMATION for details on how to get previous winners.
  490. X
  491. X    Keep in mind that rules change from year to year, so some winning entries
  492. X    may not be valid entries this year.  What was unique and novel one year
  493. X    might be 'old' the next year.
  494. X
  495. X    An entry is usually examined in a number of ways.  We typically apply
  496. X    a number of tests to an entry:
  497. X
  498. X    * look at the original source
  499. X    * If it is ANSI, convert tri-graphs to ASCII
  500. X    * C pre-process the source ignoring '#include' lines
  501. X    * C pre-process the source ignoring '#define' and '#include' lines
  502. X    * run it through a C beautifier
  503. X    * examine the algorithm
  504. X    * lint it
  505. X    * compile it
  506. X    * execute it
  507. X
  508. X    You should consider how your entry looks in each of the above tests.
  509. X    You should ask yourself if your entry remains obscure after it has been
  510. X    'cleaned up' by the C pre-processor and a C beautifier.
  511. X
  512. X    Your entry need not do well under all, or in most tests.  In certain
  513. X    cases, a test is not important.  Entries that compete for the
  514. X    'strangest/most creative source layout' need not do as well as
  515. X    others in terms of their algorithm.  On the other hand, given
  516. X    two such entries, we are more inclined to pick the entry that
  517. X    does something interesting when you run it.
  518. X
  519. X    We try to avoid limiting creativity in our rules.  As such, we leave
  520. X    the contest open for creative rule interpretation.  As in real life
  521. X    programming, interpreting a requirements document or a customer request
  522. X    is important.  For this reason, we often award 'worst abuse of the
  523. X    rules' to an entry that illustrates this point in an ironic way.
  524. X
  525. X    If you do plan to abuse the rules, we suggest that you let us know
  526. X    in the remarks section.  Please note that an invitation to abuse
  527. X    is not an invitation to break.  We are strict when it comes to the
  528. X    3217 byte size limit.  Also, abusing the entry format tends to
  529. X    annoy more than amuse.
  530. X
  531. X    We do realize that there are holes in the rules, and invite entries
  532. X    to attempt to exploit them.  We will award 'worst abuse of the rules'
  533. X    and then plug the hole next year.  Even so, we will attempt to use
  534. X    the smallest plug needed, if not smaller.  :-)
  535. X
  536. X    Check out your program and be sure that it works.  We sometimes make
  537. X    the effort to debug an entry that has a slight problem, particularly
  538. X    in or near the final round.  On the other hand, we have seen some
  539. X    of the best entries fall down because they didn't work.
  540. X
  541. X    We tend to look down on a prime number printer, that claims that
  542. X    16 is a prime number.  If you do have a bug, you are better off
  543. X    documenting it.  Noting "this entry sometimes prints the 4th power
  544. X    of a prime by mistake" would save the above entry.  And sometimes,
  545. X    a strange bug/feature can even help the entry!  Of course, a correctly
  546. X    working entry is best.
  547. X
  548. X
  549. XOUR LIKES AND DISLIKES:
  550. X
  551. X    Doing masses of #defines to obscure the source has become 'old'.  We
  552. X    tend to 'see thru' masses of #defines due to our pre-processor tests
  553. X    that we apply.  Simply abusing #defines or -Dfoo=bar won't go as far
  554. X    as a program that is more well rounded in confusion.
  555. X
  556. X    Many ANSI C compilers dislike the following code, and so do we:
  557. X
  558. X    #define d define
  559. X    #d foo           <-- don't expect this to turn into #define foo
  560. X
  561. X    int i;
  562. X    j;           <-- don't use such implicit type declarations
  563. X    int k;
  564. X
  565. X    We suggest that you use ANSI C compilers if possible.  If you must
  566. X    use non-ANSI C, such as K&R C, try to avoid areas that give ANSI C
  567. X    compilers problems.
  568. X
  569. X    Small programs are best when they are short, obscure and concise.
  570. X    While such programs are not as complex as other winners, they do
  571. X    serve a useful purpose.  They are often the only program that people
  572. X    attempt to completely understand.  For this reason, we look for
  573. X    programs that are compact, and are instructional.
  574. X
  575. X    One line programs should be short one line programs, say around 80
  576. X    bytes long.  Getting close to 160 bytes is a bit too long for one liners
  577. X    in our books.
  578. X
  579. X    We tend to dislike programs that:
  580. X
  581. X    * are very hardware specific
  582. X    * are very OS or Un*x version specific
  583. X         (index/strchr differences are ok, but socket/streams specific
  584. X          code is likely not to be)
  585. X    * dump core or have compiler warnings
  586. X         (it is ok only if you warn us in the 'remark' header item)
  587. X    * won't compile under both BSD or SYS V Un*x
  588. X    * abusing the build file to get around the size limit
  589. X    * obfuscate by excessive use of ANSI tri-graphs
  590. X    * are longer than they need to be
  591. X    * are similar to previous winners
  592. X    * are identical to previous losers  :-)
  593. X
  594. X    Unless you are cramped for space, or unless you are entering the
  595. X    'best one liner' category, we suggest that you format your program
  596. X    in a more creative way than simply forming excessively long lines.
  597. X
  598. X    The build file should not be used to try and get around the size
  599. X    limit.  It is one thing to make use of a several -D's to help out,
  600. X    but it is quite another to use 200+ bytes of -D's in order to
  601. X    try and squeeze the source under the size limit.  You should feel
  602. X    free to make use of the build file space, but you are better off
  603. X    if you show some amount of restraint.
  604. X
  605. X    We allowed whitespace, and in certain cases ; { or } do not impact
  606. X    your program size (up to a certain point), because we want to get
  607. X    away from source that is simply a compact blob of characters.
  608. X
  609. X    Given two versions of the same program, one that is a compact blob
  610. X    of code, and the other that is formatted more like a typical C
  611. X    program, we tend to favor the second version.  Of course, a third
  612. X    version of the same program that is formatted in an interesting
  613. X    and/or obfuscated way, would definitely win over the first two!
  614. X
  615. X    We suggest that you avoid trying for the 'smallest self-replicating'
  616. X    program.  We are amazed at the many different sizes that claim
  617. X    to be the smallest.  There is nothing wrong with self-replicating
  618. X    programs.  In fact, a number of winners have been self-replicating.
  619. X    You might want to avoid the claim of 'smallest', lest we (or others)
  620. X    know of a smaller one!
  621. X
  622. X    X client entries should be as portable as possible.  Entries that
  623. X    adapt to a wide collection of environments will be favored.  Don't
  624. X    depend on a particular type of display.  For example, don't depend
  625. X    on color or a given size.  Don't require backing store.
  626. X
  627. X    X client entries should avoid using X related libraries and
  628. X    software that is not in wide spread use.  We ask that such X client
  629. X    entries restrict themselves to only the low level Xlib and the
  630. X    Athena widget set (libX11.a, libXaw.a, libXmu.a and libXt.a).
  631. X    Don't use M*tif, Xv*ew, or OpenL*ok toolkits, since not everyone
  632. X    has them.  Avoid depending on a particular window manager.  Not
  633. X    everyone has X11r5, and some people are stuck back in X11r3 (or
  634. X    earlier), so try to target X11r4 without requiring X11r4.  Better
  635. X    yet, try to make your entry run on all version 11 X Window Systems.
  636. X
  637. X    X client entries should not to depend on particular items on
  638. X    .Xdefaults.  If you must do so, be sure to note the required lines
  639. X    in the ---remark--- section.  Better yet, give an xrdb -merge
  640. X    command as part of the build.
  641. X
  642. X    We like programs that:
  643. X
  644. X    * are as concise and small as they need to be
  645. X    * do something at least quasi-interesting
  646. X    * pass lint without complaint (not a requirement, but it is nice)
  647. X    * are portable
  648. X    * are unique or novel in their obfuscation style
  649. X    * MAKE USE OF A NUMBER OF DIFFERENT TYPES OF OBFUSCATION
  650. X    * make us laugh and/or throw up  :-)
  651. X
  652. X    Some types of programs can't excel in some areas.  Of course, your
  653. X    program doesn't have to excel in all areas, but doing well in several
  654. X    areas really does help.
  655. X
  656. X    We freely admit that interesting, creative or humorous comments in
  657. X    the ---remark--- section helps your chance of winning.  If you had to
  658. X    read of many twisted entries, you too would enjoy a good laugh or two.
  659. X    We think the readers of the contest winners do as well.
  660. X
  661. X    Be creative!
  662. X
  663. X
  664. XENTRY FORMAT:
  665. X
  666. X    In order to help us process the many entries, we must request your
  667. X    assistance by formatting your entries in a certain way.  This format,
  668. X    in addition, allows us to quickly separate information about the
  669. X    author from the program itself.  (see JUDGING PROCESS)
  670. X
  671. X    We have provided the program, mkentry, as an example of how to
  672. X    format entries.  You should be aware of the following warning that
  673. X    is found in mkentry.c:
  674. X
  675. X    This program attempts to implement the IOCCC rules.  Every
  676. X    attempt has been made to make sure that this program produces
  677. X    an entry that conforms to the contest rules.  In all cases,
  678. X    where this program differs from the contest rules, the
  679. X    contest rules will be used.  Be sure to check with the
  680. X    contest rules before submitting an entry.
  681. X
  682. X    You are not required to use mkentry.  It is convenient, however,
  683. X    as it attempts to uuencode the needed files, and attempt to check
  684. X    the entry against the size rules.
  685. X
  686. X    If you have any suggestions, comments, fixes or complaints about
  687. X    the mkentry.c program, please send Email to the judges.  (see below)
  688. X
  689. X    The following is a sample entry:
  690. X
  691. X---entry---
  692. Xrule:    1992
  693. Xtitle:    chonglab
  694. Xentry:    0
  695. Xdate:    Mon Feb 17 13:58:57 1992
  696. Xhost:    Un*x v6, pdp11/45
  697. X    2.9BSD, pdp11/70
  698. X---remark---
  699. X    This is a non-obfuscated obfuscated C program.
  700. X
  701. X    It is likely not to win a prize.  But what do you expect from
  702. X    a short example!  (yes, Hello world progs have become old too)
  703. X---author---
  704. Xname:    Landon Curt Noll
  705. Xorg:    IOCCC Judging Group
  706. Xaddr:    Toad Hall
  707. X    San Francisco, CA 94101
  708. X    USA
  709. Xemail:    chongo@toad.com
  710. Xanon:    n
  711. X---author---
  712. Xname:    Larry Bassel
  713. Xorg:    IOCCC Judging Group
  714. Xaddr:    Toad Hall
  715. X    San Francisco, CA 94101
  716. X    USA
  717. Xemail:    hoptoad!sun!lab
  718. X    lab@sun.com
  719. Xanon:    n
  720. X---info---
  721. Xbegin 444 info.file
  722. XM2&$A("!792!G;W0@>6]U('1O(&QO;VLA"@I4:&%T('1H870@:7,L(&ES+@I4
  723. XM:&%T('1H870@:7,@;F]T+`H@("`@:7,@;F]T('1H870@=&AA="!N;W0@:7,N
  724. XM"E1H870@:7,L('1H870@=&AA="!I<R!N;W0L(&ES(0H*"0DM+2!C:&]N9V\@
  725. X%,3DW-`H@
  726. X`
  727. Xend
  728. X---build---
  729. Xbegin 444 build
  730. X28V,@<')O9RYC("UO('!R;V<*
  731. X`
  732. Xend
  733. X---program---
  734. Xbegin 444 prog.c
  735. XC;6%I;B@I>W!R:6YT9B@B2&5L;&\L('=O<FQD(5QN(BD[?0H`
  736. X`
  737. Xend
  738. X---end---
  739. X
  740. X    Where build uudecodes into:
  741. X
  742. Xcc prog.c -o prog
  743. X
  744. X    and prog.c uudecodes into:
  745. X
  746. Xmain(){printf("Hello, world!\n");}
  747. X
  748. X    Typically the build file should assume that the source is prog.c
  749. X    and will compile into prog.  If an entry wins, we will rename
  750. X    its source and binary to avoid filename collision.  By tradition,
  751. X    we use the name of the entry's title, followed by an optional
  752. X    digit in case of name conflicts.
  753. X
  754. X    If the above entry somehow won the 'least likely to win' award,
  755. X    we would use chonglab.c and chonglab.
  756. X
  757. X    If your entry depends on, or requires that your build, source
  758. X    and/or binary files be a particular name, please say so in the
  759. X    ---remark--- section.  If this case applies, it would be be helpful
  760. X    if you did one of the following:
  761. X
  762. X    * Tell us how to change the filename(s) in your entry.
  763. X
  764. X    * Have the build file make copies of the files.  For example:
  765. X
  766. X        cc prog.c -o special_name        need special binary
  767. X
  768. X        or  rm -f special_src.c            need special source
  769. X        cp prog.c special_src.c
  770. X        cc special_src.c -o special_name
  771. X
  772. X        or  rm -f special_build            need special build
  773. X        tail +4 build > special_build
  774. X        sh < special_build
  775. X
  776. X    * Assume that we will use the entry title.  Send us a version of 
  777. X      your build/program files that uses the name convention.  You 
  778. X      should uuencode these files in ---data--- sections.
  779. X
  780. X    If your entry needs to modify its source, info or binary files,
  781. X    please say so in the ---remark--- section.  You should try to avoid
  782. X    touching your original build, source and binary files.  You should
  783. X    arrange to make copies of the files you intend to modify.  This
  784. X    will allow people to re-generate your entry from scratch.
  785. X
  786. X    Remember that your entry may be built without a build file.  We
  787. X    typically incorporate the build lines into a Makefile.  If the
  788. X    build file must exist, say so in the ---remark--- section.
  789. X
  790. X    If your entry needs special info files, you should uuencode them
  791. X    into ---info--- sections.  In the case of multiple info files,
  792. X    use multiple ---info--- sections.  If no info files are needed,
  793. X    then skip the ---info--- section.
  794. X
  795. X    Info files are intended to be input, or detailed information that
  796. X    does not fit well into the ---remark--- section.  For example, an
  797. X    entry that implements a compiler might want to provide some sample
  798. X    programs for the user to compile.  An entry might want to include a
  799. X    lengthly design document, that might not be appropriate for a
  800. X    'hints' file.
  801. X
  802. X    Info files should be used only to supplement your entry.  For
  803. X    example, info files may provide sample input or detailed
  804. X    information about your entry.  Because they are supplemental,
  805. X    the entry should not require them exist.
  806. X
  807. X    In some cases, your info files might be renamed to avoid name
  808. X    conflicts.  If info files should not be renamed for some reason,
  809. X    say so in the ---remark--- section.
  810. X
  811. X    Info files must uudecode into the current directory.  If they
  812. X    absolutely must be renamed, or moved into a sub-directory, say
  813. X    so in the ---remark--- section.
  814. X
  815. X
  816. XJUDGING PROCESS:
  817. X
  818. X    Entries are judged by Larry Bassel and Landon Curt Noll.
  819. X
  820. X    Entries are unpacked into individual directories.  The Email message
  821. X    is unpacked into individual files, each containing:
  822. X
  823. X    ---entry--- section
  824. X    all ---author--- sections
  825. X    all ---info--- sections
  826. X    ---build--- section
  827. X    ---program--- section
  828. X    any other text, including the Email message headers
  829. X
  830. X    Prior to judging, the 'any other text' file is scanned to be sure
  831. X    it does not contain useful information (or in case the entry was
  832. X    malformed and did not unpack correctly).  Information from the
  833. X    ---author--- sections are not read until the judging process is
  834. X    complete, and then only from entries that have won an award.
  835. X
  836. X    The above process helps keep us biased for/against any one particular
  837. X    individual.  We are usually kept in the dark as much as you are
  838. X    until the final awards are given.  We like the surprise of finding
  839. X    out in the end, who won and where they were from.
  840. X
  841. X    We attempt to keep all entries anonymous, unless they win an award.
  842. X    Because the main 'prize' of winning is being announced, we make all
  843. X    attempts to send non-winners into oblivion.  We remove all non-winning
  844. X    files, and shred all related paper.  By tradition, we do not even
  845. X    reveal the number of entries that we received.  (for the curious,
  846. X    we do indicate the volume of paper consumed when presenting the IOCCC
  847. X    winners at talks)
  848. X
  849. X    After the Usenix announcement, we attempt to send Email to the
  850. X    authors of the winning entries.  One reason we do this is to give
  851. X    the authors a chance to comment on the way we have presented their
  852. X    entry.  They are given the chance to correct mistakes, typos.  We
  853. X    often accept their suggestions/comments about our remarks as well.
  854. X    This is done prior to posting the winners to the wide world.
  855. X
  856. X    Judging consists of a number of elimination rounds.  During a round,
  857. X    the collection of entries are divided into two roughly equal piles;
  858. X    the pile that advances on to the next round, and the pile that does
  859. X    not.  We also re-examine the entries that were eliminated in the
  860. X    previous round.  Thus, an entry gets at least two readings.
  861. X
  862. X    A reading consists of a number of actions:
  863. X
  864. X    * reading the ---entry--- section
  865. X    * reading the uudecoded ---build--- section
  866. X    * reading the uudecoded ---program--- section
  867. X    * reading the uudecoded ---info--- section(s), if any
  868. X    * passing the source thru the C pre-processor
  869. X        shipping over any #include files
  870. X    * performing a number of C beautify/cleanup edits on the source
  871. X    * passing the beautified source thru the C pre-processor
  872. X        shipping over any #include files
  873. X
  874. X    In later rounds, other actions are performed:
  875. X
  876. X    * linting the source
  877. X    * compiling/building the source
  878. X    * running the program
  879. X    * performing misc tests on the source and binary
  880. X
  881. X    Until we reduce the stack of entries down to about 25 entries, entries
  882. X    are judged on an individual basis.  An entry is set aside because it
  883. X    does not, in our opinion, meet the standard established by the round.
  884. X    When the number of entries thins to about 25 entries, we begin to form
  885. X    award categories.  Entries begin to compete with each other for awards.
  886. X    An entry often will compete in several categories.
  887. X
  888. X    The actual award category list will vary depending on the types of entries
  889. X    we receive.  A typical category list might be:
  890. X
  891. X    * best small one line program
  892. X    * best small program
  893. X    * strangest/most creative source layout
  894. X    * most useful obfuscated program
  895. X    * best game that is obfuscated
  896. X    * most creatively obfuscated program
  897. X    * most deceptive C code
  898. X    * best X client (see OUR LIKES AND DISLIKES)
  899. X    * best abuse of ANSI C
  900. X    * worst abuse of the rules
  901. X    * <anything else so strange that it deserves an award>
  902. X
  903. X    We do not limit ourselves to this list.  For example, a few entries are so
  904. X    good/bad that they are declared winners at the start of the final round.
  905. X    We will invent awards categories for them, if necessary.
  906. X
  907. X    In the final round process, we perform the difficult tasks of
  908. X    reducing the remaining entries (typically about 25) down to 8 or 10
  909. X    winners.  Often we are confident that the entries that make it into
  910. X    the final round are definitely better than the ones that do not
  911. X    make it.  The selection of the winners out of the final round, is
  912. X    less clear cut.
  913. X
  914. X    Sometimes a final round entry good enough to win, but is beat out
  915. X    by a similar, but slightly better entry.  For this reason, it is
  916. X    sometimes worthwhile to re-enter an entry that failed to win on a
  917. X    previous year.  There have been winners that lost in a previous
  918. X    year.  Of course, in those cases, improving on the entry made
  919. X    the difference!
  920. X
  921. X    More often that not, we select a small entry (usually one line), a
  922. X    strange/creative layout entry, and an entry that abuses the contest
  923. X    rules in some way.
  924. X
  925. X    In the end, we traditionally pick one entry as 'best'.  Sometimes such
  926. X    an entry simply far exceeds any of the other entry.  More often, the
  927. X    'best' is picked because it does well in a number of categories.
  928. X
  929. X
  930. XANNOUNCEMENT OF WINNERS:
  931. X
  932. X    The first announcement, occurs at a Summer Usenix conference.  By 
  933. X    tradition, this is done during the latter part of the UUNET/IOCCC BOF, 
  934. X    just prior to the Berkeley BSD, and BSDI BOF.
  935. X
  936. X    Winning entries will be posted in late June to the following groups:
  937. X
  938. X        comp.lang.c          comp.unix.wizards    alt.sources
  939. X
  940. X    In addition, pointers to these postings are posted to the following
  941. X
  942. X        comp.sources.d      alt.sources.d        misc.misc
  943. X        comp.sources.misc
  944. X
  945. X    Winning entries will be deposited into the uunet archives.  See
  946. X    below for details.
  947. X
  948. X    Often, winning entries are published in magazines such as "The C Users
  949. X    Journal".  Winners have appeared in books ("The New Hackers Dictionary")
  950. X    and on T-Shirts.
  951. X
  952. X    Last, but not least, winners receive international fame and flames!  :-)
  953. X
  954. X
  955. XFOR MORE INFORMATION:
  956. X
  957. X    You may contact the judges by sending Email to the following address:
  958. X
  959. X    ...!{apple,pyramid,sun,uunet}!hoptoad!judges    (not the address for
  960. X    judges@toad.com                     submitting entries)
  961. X
  962. X    Questions and comments about the contest are welcome.
  963. X
  964. X    One may obtain a copy of the current rules, guidelines or mkentry
  965. X    program as well.  To stream line these common requests, we request
  966. X    that you use the following subjects when making such requests:
  967. X
  968. X    subject          to request
  969. X    -------          ----------
  970. X    send rules      to obtain the current IOCCC rules
  971. X    send guidelines      to obtain the current IOCCC guidelines
  972. X    send mkentry      to obtain the current IOCCC mkentry program
  973. X    send allinfo      to obtain the current IOCCC rules,guidelines,mkentry
  974. X
  975. X    One may also obtain the above items, we well as winners of previous
  976. X    contests, via anonymous ftp from:
  977. X
  978. X    host: ftp.uu.net    (137.39.1.9)
  979. X    user: anonymous
  980. X    pass: yourname@yourhost
  981. X    dir:  pub/ioccc
  982. X
  983. X    Often, contest rules, guidelines and winners are available from
  984. X    archive sites.  Check comp.sources.unix archives, for example.
  985. X    You may also request previous winners by Email, using the judges
  986. X    Email address, though we ask that you do this as a last resort.
  987. X
  988. X
  989. Xchongo <Landon Curt Noll> /\cc/\      hoptoad!chongo
  990. XLarry Bassel                  {uunet,ucbvax,cbosgd}|sun!lab
  991. SHAR_EOF
  992. $TOUCH -am 0908154692 1992/guidelines &&
  993. chmod 0444 1992/guidelines ||
  994. echo "restore of 1992/guidelines failed"
  995. set `wc -c 1992/guidelines`;Wc_c=$1
  996. if test "$Wc_c" != "22215"; then
  997.     echo original size 22215, current size $Wc_c
  998. fi
  999. # ============= 1992/Makefile ==============
  1000. echo "x - extracting 1992/Makefile (Text)"
  1001. sed 's/^X//' << 'SHAR_EOF' > 1992/Makefile &&
  1002. X# %W% %G% %U%
  1003. X#
  1004. X# 1992 makefile
  1005. X
  1006. XSHELL=/bin/sh
  1007. XCHMOD=chmod
  1008. XCP=cp
  1009. XRM=rm
  1010. XSED=sed
  1011. XLN=ln
  1012. XUNIQ=uniq
  1013. XCB=cb 
  1014. XGREP=grep
  1015. X# set this to where your C Processor resides
  1016. X#
  1017. X# On some systems:
  1018. X#    CPP=/lib/cpp
  1019. X#
  1020. XCPP=/usr/ccs/lib/acpp
  1021. X
  1022. X# flags for ansi compiles
  1023. X#
  1024. X# NOTE: Some ANSI compilers make use of -Xa to turn on ANSI mode,
  1025. X#    others such as gcc may want -ansi, others may want nothing
  1026. X#    at all.  Adjust the CFLAGS line as needed.
  1027. X#
  1028. X# NOTE: Some compilers cannot optimize, or optimize some entries
  1029. X#    entries incorrectly.  You might want need to turn on -O 
  1030. X#    to see if your compiler can handle them.
  1031. X#
  1032. X#CFLAGS=-O -Xa
  1033. XCFLAGS=-Xa
  1034. XCC=cc
  1035. X
  1036. X# misc shell babble
  1037. X#
  1038. XNOINCLUDE=$(SED) -e 's/^.\([     ]*\)include/%include/'
  1039. XSPACECLEAN=$(SED) -e 's/\([^     ]\)\([     ]\)[     ][     ]*/\1\2/g'
  1040. XCPPCLEAN=$(GREP) -v '^. [0-9][0-9]*'
  1041. X
  1042. X# winners that compile under ANSI C
  1043. X#
  1044. XWINNERS= adrian albert ant buzzard.1 buzzard.2 gson kivinen imc \
  1045. X    lush marangon nathan vern westley
  1046. XALT_NAMES= adgrep am babble first ag whereami
  1047. X
  1048. Xall: $(WINNERS) $(ALT_NAMES)
  1049. X
  1050. Xadrian: adrian.c
  1051. X    $(CC) $(CFLAGS) adrian.c -o adrian
  1052. X    $(RM) -f ad.temp adwc.c adbasename.c adecho.c adhead.c adsleep.c
  1053. X    $(SED) '1s/\..*\./. wc ./' adrian.c > ad.temp
  1054. X    -./adrian ad.temp <ad.temp >adwc.c
  1055. X    $(CC) -o adwc adwc.c
  1056. X    $(SED) '1s/\..*\./. basename ./' adrian.c > ad.temp
  1057. X    -./adrian ad.temp <ad.temp >adbasename.c
  1058. X    $(CC) -o adbasename adbasename.c
  1059. X    $(SED) '1s/\..*\./. echo| ./' adrian.c > ad.temp
  1060. X    -./adrian ad.temp <ad.temp >adecho.c
  1061. X    $(CC) -o adecho adecho.c
  1062. X    $(SED) '1s/\..*\./. head; ./' adrian.c > ad.temp
  1063. X    -./adrian ad.temp <ad.temp >adhead.c
  1064. X    $(CC) -o adhead adhead.c
  1065. X    $(SED) '1s/\..*\./. sleep ./' adrian.c > ad.temp
  1066. X    -./adrian ad.temp <ad.temp >adsleep.c
  1067. X    $(CC) -o adsleep adsleep.c
  1068. X    $(RM) -f ad.temp
  1069. X
  1070. X# NOTE: this is the original source that won
  1071. X#
  1072. Xadrian.orig: adrian.orig.c
  1073. X    $(CC) $(CFLAGS) adrian.orig.c -o adrian.orig
  1074. X
  1075. Xalbert: albert.c
  1076. X    $(CC) $(CFLAGS) albert.c -o albert
  1077. X
  1078. X# NOTE: this is the original source that won
  1079. X#
  1080. Xalbert.orig: albert.orig.c
  1081. X    $(CC) $(CFLAGS) albert.orig.c -o albert.orig
  1082. X
  1083. Xant: ant.c
  1084. X    $(CC) $(CFLAGS) ant.c -o ant
  1085. X
  1086. Xbuzzard.1: buzzard.1.c
  1087. X    $(CC) $(CFLAGS) buzzard.1.c -o buzzard.1
  1088. X
  1089. Xbabble.cppcb: buzzard.1.c
  1090. X    $(NOINCLUDE) buzzard.1.c | \
  1091. X        $(CPP) $(CPPFLAGS) | \
  1092. X        $(CPPCLEAN) | \
  1093. X        $(CB) $(CBFLAGS) | \
  1094. X        $(UNIQ) | \
  1095. X        $(SPACECLEAN) > babble.cppcb 2>&1
  1096. X
  1097. Xbuzzard.2: buzzard.2.c
  1098. X    $(CC) $(CFLAGS) buzzard.2.c -o buzzard.2
  1099. X
  1100. X# NOTE: this is the original source that won
  1101. X#
  1102. Xbuzzard.2.orig: buzzard.2.orig.c
  1103. X    $(CC) $(CFLAGS) buzzard.2.orig.c -o buzzard.2.orig
  1104. X
  1105. Xgson: gson.c
  1106. X    $(CC) $(CFLAGS) gson.c -o gson
  1107. X
  1108. X# NOTE: some systems may only need:
  1109. X#
  1110. X#  $(CC) $(CFLAGS) kivinen.c -o kivinen -lX11
  1111. X#
  1112. Xkivinen: kivinen.c
  1113. X    $(CC) $(CFLAGS) kivinen.c -o kivinen -lX11 -lsocket -lresolv -lnsl
  1114. X
  1115. X# NOTE: this is the original program that won
  1116. X#
  1117. X# NOTE: some systems may only need:
  1118. X#
  1119. X#  $(CC) $(CFLAGS) kivinen.c -o kivinen -lX11
  1120. X#
  1121. Xkivinen.orig: kivinen.orig.c
  1122. X    $(CC) $(CFLAGS) kivinen.orig.c -o kivinen.orig -lX11 \
  1123. X        -lsocket -lresolv -lnsl
  1124. X
  1125. Ximc: imc.c
  1126. X    $(CC) $(CFLAGS) imc.c -o imc
  1127. X
  1128. X# NOTE: this is the original program that won
  1129. X#
  1130. Ximc.orig: imc.orig.c
  1131. X    $(CC) $(CFLAGS) imc.orig.c -o imc.orig
  1132. X
  1133. Xlush: lush.c
  1134. X    $(CC) $(CFLAGS) lush.c -o lush
  1135. X
  1136. Xlush.again: lush.c
  1137. X    $(CC) $(CFLAGS) lush.c -o lush.again
  1138. X    $(RM) -f lush.again
  1139. X
  1140. X# NOTE: this is the original program that won
  1141. X#
  1142. Xlush.orig: lush.orig.c
  1143. X    $(CC) $(CFLAGS) lush.orig.c -o lush.orig
  1144. X
  1145. X# NOTE: some systems may need:
  1146. X#
  1147. X#  $(CC) $(CFLAGS) marangon.c -o marangon -lcurses -ltermcap
  1148. X#
  1149. Xmarangon: marangon.c
  1150. X    $(CC) $(CFLAGS) marangon.c -o marangon -lcurses
  1151. X
  1152. X# NOTE: this is the original program that won
  1153. X#
  1154. X# NOTE: some systems may need:
  1155. X#
  1156. X#  $(CC) $(CFLAGS) marangon.orig.c -o marangon.orig -lcurses -ltermcap
  1157. X#
  1158. Xmarangon.orig: marangon.orig.c
  1159. X    $(CC) $(CFLAGS) marangon.orig.c -o marangon.orig -lcurses
  1160. X
  1161. Xnathan: nathan.c
  1162. X    $(CC) $(CFLAGS) nathan.c -o nathan
  1163. X
  1164. X# NOTE: this is the original program that won
  1165. X#
  1166. Xnathan.orig: nathan.orig.c
  1167. X    $(CC) $(CFLAGS) nathan.orig.c -o nathan.orig
  1168. X
  1169. Xvern: vern.tmp.c
  1170. X    $(CC) $(CFLAGS) vern.tmp.c -o vern
  1171. X
  1172. Xvern.tmp.c: vern.c
  1173. X    $(RM) -f vern.tmp.c
  1174. X    $(SED) <vern.c 's/{ /(/g;s/} /)/g;s/;    /#define /' | \
  1175. X        $(SED) 's/}    /=/g;s/{    /i/g' >vern.tmp.c
  1176. X
  1177. X# NOTE: this is the original program that won
  1178. X#
  1179. Xvern.orig: vern.orig.tmp.c
  1180. X    $(CC) $(CFLAGS) vern.orig.tmp.c -o vern.orig
  1181. X
  1182. Xvern.orig.tmp.c: vern.orig.c
  1183. X    $(RM) -f vern.orig.tmp.c
  1184. X    $(SED) <vern.orig.c 's/{ /(/g;s/} /)/g;s/;    /#define /' | \
  1185. X        $(SED) 's/}    /=/g;s/{    /i/g' >vern.orig.tmp.c
  1186. X
  1187. Xwestley: westley.c
  1188. X    $(CC) $(CFLAGS) westley.c -o westley
  1189. X
  1190. X# alternate names for selected entries
  1191. X#
  1192. Xadgrep: adrian
  1193. X    $(RM) -f adgrep
  1194. X    $(LN) adrian adgrep
  1195. Xam: ant
  1196. X    $(RM) -f am
  1197. X    $(LN) ant am
  1198. Xbabble: buzzard.1
  1199. X    $(RM) -f babble
  1200. X    $(LN) buzzard.1 babble
  1201. Xfirst: buzzard.2
  1202. X    $(RM) -f first
  1203. X    $(LN) buzzard.2 first
  1204. Xag: gson
  1205. X    $(RM) -f ag
  1206. X    $(LN) gson ag
  1207. Xwhereami: westley
  1208. X    $(RM) -f whereami
  1209. X    $(LN) westley whereami
  1210. X
  1211. Xclean:
  1212. X    $(RM) -f *.o a.out core 
  1213. X    $(RM) -f vern.tmp.c lush.again babble.cppcb vern.orig.tmp.c
  1214. X    $(RM) -f ad.temp adwc.c adbasename.c adecho.c adhead.c adsleep.c
  1215. X
  1216. Xclobber: clean
  1217. X    $(RM) -f $(WINNERS) a.out
  1218. X    $(RM) -f $(ALT_NAMES)
  1219. X    $(RM) -f adwc adbasename adecho adhead adsleep
  1220. X    $(RM) -f adrian.orig lush.orig nathan.orig buzzard.2.orig
  1221. X    $(RM) -f kivinen.orig imc.orig albert.orig marangon.orig vern.orig
  1222. X
  1223. Xam_clobber: clean am
  1224. X    $(RM) -f am.safe
  1225. X    $(CP) am am.safe
  1226. X    $(RM) -f $(WINNERS) a.out
  1227. X    $(RM) -f $(ALT_NAMES)
  1228. X    $(RM) -f adwc adbasename adecho adhead adsleep
  1229. X    $(RM) -f adrian.orig lush.orig nathan.orig buzzard.2.orig
  1230. X    $(RM) -f kivinen.orig imc.orig albert.orig marangon.orig vern.orig
  1231. X    $(CP) am.safe am
  1232. X    $(RM) -f am.safe
  1233. X
  1234. Xnuke: clobber
  1235. X    @true
  1236. X
  1237. Xinstall: all
  1238. X    cat $(WINNERS) > /dev/null
  1239. SHAR_EOF
  1240. $TOUCH -am 0908160192 1992/Makefile &&
  1241. chmod 0444 1992/Makefile ||
  1242. echo "restore of 1992/Makefile failed"
  1243. set `wc -c 1992/Makefile`;Wc_c=$1
  1244. if test "$Wc_c" != "5632"; then
  1245.     echo original size 5632, current size $Wc_c
  1246. fi
  1247. # ============= 1992/adrian.c ==============
  1248. echo "x - extracting 1992/adrian.c (Text)"
  1249. sed 's/^X//' << 'SHAR_EOF' > 1992/adrian.c &&
  1250. X/* . wc . */
  1251. X#include<stdio.h>/* Wht majr flwchrt? */
  1252. X#include<string.h>/* That mjr flwchrt! */
  1253. X#define P 257
  1254. X#define G 17
  1255. X#define z 8
  1256. X#define v(jr) jr
  1257. Xint W ,head;
  1258. X#define S(W,b,f) strncpy(W,b,f),W[f]=0\
  1259. X
  1260. X  
  1261. Xchar *wcs=" \t\n";
  1262. Xstruct{ char X[z+1]; 
  1263. X        char f ;
  1264. X        int e ; 
  1265. X        struct{ char g[z+1];
  1266. X                int b ;
  1267. X              } w[ G];
  1268. X      } o[ P];
  1269. Xint L=0,j= -28;
  1270. X
  1271. X
  1272. Xvoid E(int i, int m,char*c)
  1273. X{   
  1274. X for(; i<43; i+=3) 
  1275. X   putc("}|uutsrq`_^bji`[Zkediml[PO]a_M__]ISOYIRGTNR"[i]+i-9,stderr);
  1276. X fprintf(stderr,"(%d): %s\n" ,m,c);
  1277. X exit(1);
  1278. X}
  1279. X
  1280. X
  1281. X
  1282. Xint N(int m, char *t)
  1283. X{ 
  1284. X  int i ;
  1285. X  if (strlen ( 
  1286. X              t)>z) t[z ]=0;
  1287. X  for(i= 0; i< L ; i++) if(
  1288. X                           !strcmp (o[ i] . X
  1289. X                                             , t))return i;
  1290. X  if( L== P)
  1291. X             E(0, m, t);
  1292. X  S (o[ L] . X , t
  1293. X                  ,z);
  1294. X  head; W = .1* head;
  1295. X  o[L ].f = !( strchr( t,']' )== 0 );
  1296. X  o[L ++ ] . e = 0;
  1297. X  return L -1 ; }
  1298. X
  1299. X#define v(x )
  1300. X
  1301. Xint A(char *R)
  1302. X{
  1303. X  int c=0, i;
  1304. X  while(* R) {
  1305. X    i = -1;
  1306. X    while(j){
  1307. X      if( ++ i==o[ c].e ) return 0;
  1308. X      if(o[ 
  1309. X           c] .w[i ] .g[0 ] 
  1310. X                            =='.' ||strchr (o[ c].w[i] .g ,* R)){
  1311. X      c=
  1312. X        o[ c ] .w[i].b; break;/*
  1313. Xmain(int sl,char *j[]){
  1314. X      sleep (~~~~~~~~atoi(j[1])) ;/* . sl
  1315. X      sl s l . sl
  1316. X      l l ]
  1317. X      sl */ }
  1318. X    }
  1319. X    R++;
  1320. X  }
  1321. X  return o[ c].f;
  1322. X}
  1323. X
  1324. X
  1325. X main(int wc,char *V[]){char Y[999],*s;FILE*W;int m=0,echo,jr,q,wcl=0,wcw=0,wcc=0;
  1326. X v(s = V[1]; if (*V=strrchr(s,'/'))s=*V+1;  if(( !strncmp( s + (jr=strlen(s)) -
  1327. X  (q=strlen(V[2]) ),V[2],q))&&jr!=q) s[jr-q] = 0;  puts(s); )
  1328. X int e,p,C=0,Q ,basename;
  1329. X W= fopen(wc>= 2 ? V[1] : "adgrep.c","rt");
  1330. Xecho| m^ e| 5| (int) .8| echo|
  1331. Xwc |C ==o[o[C] .e] . 
  1332. Xe| e==+p,p; s[o[C] .e ] 
  1333. X;
  1334. Xwhile( fgets(Y,998,W)) { wcc += strlen(Y); m++;
  1335. X     if( s = strtok(Y,wcs)) wcw++;
  1336. X     else continue ;
  1337. X     C=
  1338. X       basename= j +j+*"* . basename" 
  1339. X                +j+*"* r ] " + N(m,s) ;
  1340. Xwhile( s = strtok(0,wcs)) {
  1341. X       if( o[ C ] . e == 
  1342. X                         G) E(1 ,m,o[C] .X) ;
  1343. X       S(o[C
  1344. X             ] .w[o[C ] .e].g,s, z);
  1345. X       Q= C ;
  1346. X       if(! ( s =strtok ( 0 ,wcs )))wcw --
  1347. X       ,E( 2 , m, o[C]
  1348. X                   . w[ o[ Q ] .e] . g );
  1349. X       e
  1350. X         = o[C ] .w[o[C ] .e++ ] .b= N(m,s)
  1351. X       ; wcw += 2; }  
  1352. X     0&& 
  1353. X        W && wcl++
  1354. X                  < 10 && printf((W,Y)); }
  1355. X   if(j+28) { {
  1356. X                ; } printf("%7u%7u%7u\n", wcl , wcw , wcc); }
  1357. X   while( gets(Y) ) if(A(Y)) puts(Y);
  1358. X   W, jr; }
  1359. X
  1360. XO(int wc,char**V) {
  1361. X--wc && (printf("%s ",*++V), main(wc,V), 1) || printf("\n"); }
  1362. X
  1363. SHAR_EOF
  1364. $TOUCH -am 0817110092 1992/adrian.c &&
  1365. chmod 0444 1992/adrian.c ||
  1366. echo "restore of 1992/adrian.c failed"
  1367. set `wc -c 1992/adrian.c`;Wc_c=$1
  1368. if test "$Wc_c" != "2583"; then
  1369.     echo original size 2583, current size $Wc_c
  1370. fi
  1371. # ============= 1992/adrian.grep.1 ==============
  1372. echo "x - extracting 1992/adrian.grep.1 (Text)"
  1373. sed 's/^X//' << 'SHAR_EOF' > 1992/adrian.grep.1 &&
  1374. X    <q0> a <q1>          The first state to appear is the start state
  1375. X    <q1> b <q2>
  1376. X    <q2> c [q3]
  1377. X    [q3]                    
  1378. SHAR_EOF
  1379. $TOUCH -am 0817110092 1992/adrian.grep.1 &&
  1380. chmod 0444 1992/adrian.grep.1 ||
  1381. echo "restore of 1992/adrian.grep.1 failed"
  1382. set `wc -c 1992/adrian.grep.1`;Wc_c=$1
  1383. if test "$Wc_c" != "131"; then
  1384.     echo original size 131, current size $Wc_c
  1385. fi
  1386. # ============= 1992/adrian.grep.2 ==============
  1387. echo "x - extracting 1992/adrian.grep.2 (Text)"
  1388. sed 's/^X//' << 'SHAR_EOF' > 1992/adrian.grep.2 &&
  1389. X    <q0> a <q1>
  1390. X    <q1> b <q2>
  1391. X    <q2> c [q3]
  1392. X    [q3] . [q3]
  1393. SHAR_EOF
  1394. $TOUCH -am 0817110092 1992/adrian.grep.2 &&
  1395. chmod 0444 1992/adrian.grep.2 ||
  1396. echo "restore of 1992/adrian.grep.2 failed"
  1397. set `wc -c 1992/adrian.grep.2`;Wc_c=$1
  1398. if test "$Wc_c" != "64"; then
  1399.     echo original size 64, current size $Wc_c
  1400. fi
  1401. # ============= 1992/adrian.grep.3 ==============
  1402. echo "x - extracting 1992/adrian.grep.3 (Text)"
  1403. sed 's/^X//' << 'SHAR_EOF' > 1992/adrian.grep.3 &&
  1404. X    <q0> a <q1> . <q0>
  1405. X    <q1> b <q2> a <q1> . <q0>
  1406. X    <q2> c [q3] a <q1> . <q0>
  1407. X    [q3] . <q1>
  1408. SHAR_EOF
  1409. $TOUCH -am 0817110092 1992/adrian.grep.3 &&
  1410. chmod 0444 1992/adrian.grep.3 ||
  1411. echo "restore of 1992/adrian.grep.3 failed"
  1412. set `wc -c 1992/adrian.grep.3`;Wc_c=$1
  1413. if test "$Wc_c" != "99"; then
  1414.     echo original size 99, current size $Wc_c
  1415. fi
  1416. # ============= 1992/adrian.grep.4 ==============
  1417. echo "x - extracting 1992/adrian.grep.4 (Text)"
  1418. sed 's/^X//' << 'SHAR_EOF' > 1992/adrian.grep.4 &&
  1419. X    [q0] a <q1>
  1420. X    <q1> b <q2>
  1421. X    <q2> c [q0]
  1422. SHAR_EOF
  1423. $TOUCH -am 0817110092 1992/adrian.grep.4 &&
  1424. chmod 0444 1992/adrian.grep.4 ||
  1425. echo "restore of 1992/adrian.grep.4 failed"
  1426. set `wc -c 1992/adrian.grep.4`;Wc_c=$1
  1427. if test "$Wc_c" != "48"; then
  1428.     echo original size 48, current size $Wc_c
  1429. fi
  1430. # ============= 1992/adrian.grep.5 ==============
  1431. echo "x - extracting 1992/adrian.grep.5 (Text)"
  1432. sed 's/^X//' << 'SHAR_EOF' > 1992/adrian.grep.5 &&
  1433. X    <q0> ab <q1>
  1434. X    <q1> cd <q2>
  1435. X    <q2> ef [q3]
  1436. X    [q3]
  1437. SHAR_EOF
  1438. $TOUCH -am 0817110092 1992/adrian.grep.5 &&
  1439. chmod 0444 1992/adrian.grep.5 ||
  1440. echo "restore of 1992/adrian.grep.5 failed"
  1441. set `wc -c 1992/adrian.grep.5`;Wc_c=$1
  1442. if test "$Wc_c" != "60"; then
  1443.     echo original size 60, current size $Wc_c
  1444. fi
  1445. # ============= 1992/adrian.grep.from ==============
  1446. echo "x - extracting 1992/adrian.grep.from (Text)"
  1447. sed 's/^X//' << 'SHAR_EOF' > 1992/adrian.grep.from &&
  1448. X<q0> F <q1>
  1449. X<q1> r <q2>
  1450. X<q2> o <q3>
  1451. X<q3> m <q4>
  1452. X<q4> : <q5> . [q6]
  1453. X<q5> . <q5>
  1454. X[q6] . [q6]
  1455. X
  1456. SHAR_EOF
  1457. $TOUCH -am 0817110092 1992/adrian.grep.from &&
  1458. chmod 0444 1992/adrian.grep.from ||
  1459. echo "restore of 1992/adrian.grep.from failed"
  1460. set `wc -c 1992/adrian.grep.from`;Wc_c=$1
  1461. if test "$Wc_c" != "92"; then
  1462.     echo original size 92, current size $Wc_c
  1463. fi
  1464. # ============= 1992/adrian.grep.try ==============
  1465. echo "x - extracting 1992/adrian.grep.try (Text)"
  1466. sed 's/^X//' << 'SHAR_EOF' > 1992/adrian.grep.try &&
  1467. X    <q0> t <q1> . <q0>
  1468. X    <q1> hc <q2> t <q1> . <q0>
  1469. X    <q2> eh [q3] t <q1> . <q0>
  1470. X    [q3] . <q1>
  1471. SHAR_EOF
  1472. $TOUCH -am 0817110092 1992/adrian.grep.try &&
  1473. chmod 0444 1992/adrian.grep.try ||
  1474. echo "restore of 1992/adrian.grep.try failed"
  1475. set `wc -c 1992/adrian.grep.try`;Wc_c=$1
  1476. if test "$Wc_c" != "101"; then
  1477.     echo original size 101, current size $Wc_c
  1478. fi
  1479. # ============= 1992/adrian.hint ==============
  1480. echo "x - extracting 1992/adrian.hint (Text)"
  1481. sed 's/^X//' << 'SHAR_EOF' > 1992/adrian.hint &&
  1482. XMost Educational: <adrian@u.washington.edu> Adrian Mariano
  1483. X
  1484. X    Adrian Mariano
  1485. X    University of Washington
  1486. X    2729 72nd Ave SE
  1487. X    Mercer Island, WA 98040
  1488. X    USA
  1489. X
  1490. X
  1491. XJudges' comments:
  1492. X
  1493. X    To build:
  1494. X    make adrian
  1495. X
  1496. X    Try:
  1497. X    adrian adrian.grep.try < adrian.hint
  1498. X    
  1499. X    For the slow minded, try:
  1500. X    adsleep 32767
  1501. X    
  1502. X    Once you get past the obfuscation, you have an opportunity to learn
  1503. X    about regular expressions and state machines.
  1504. X
  1505. X    NOTE: Some compilers have had trouble optimizing this entry.
  1506. X
  1507. X
  1508. XSelected notes from the author:
  1509. X
  1510. X                            ADrian's GREP (adgrep)
  1511. X
  1512. X    For those confused by the complexity of full-blown egrep style regular
  1513. X    expressions, this program offers an alternative.  It implements an
  1514. X    equivalent search, using a deterministic finite automaton.
  1515. X
  1516. X    A deterministic finite automaton consists of a finite set of states,
  1517. X    along with transition rules to move from one state to another, an initial
  1518. X    state, and a set of accepting states.  The automaton takes a string as
  1519. X    input and begins in the start state.  It reads a character of the string
  1520. X    and consults the rules for the current state, moving to the new state
  1521. X    indicated by the appropriate rule.  This process is repeated until the
  1522. X    string is consumed.  If the current state at this point is one of the
  1523. X    accepting states, then the string is accepted.
  1524. X
  1525. X    The deterministic finite automaton is specified as a series of rules for
  1526. X    each state:
  1527. X
  1528. X       <state> chars1 <dest1> chars2 <dest2> ...
  1529. X
  1530. X    chars1 is a list of characters (only the first 8 are significant) which
  1531. X    should trigger a transition to <dest1>.  <dest1> is another state which
  1532. X    should have a similar specification somewhere.  A state is accepting if
  1533. X    it is specified in square brackets: [final], and state strings are
  1534. X    significant to only eight characters.
  1535. X
  1536. X    Example 1: matches ^abc$
  1537. X
  1538. X    <q0> a <q1>          The first state to appear is the start state
  1539. X    <q1> b <q2>
  1540. X    <q2> c [q3]
  1541. X    [q3]
  1542. X
  1543. X    Technically, a deterministic finite automaton should have a rule for each
  1544. X    possible input character at each state.  To simplify descriptions of the
  1545. X    automata, if no rule is present, the string will not be accepted. Also,
  1546. X    the '.' character matches any character if it occurs first in the
  1547. X    character list.
  1548. X
  1549. X
  1550. X    Example 2: ^abc
  1551. X
  1552. X    <q0> a <q1>
  1553. X    <q1> b <q2>
  1554. X    <q2> c [q3]
  1555. X    [q3] . [q3]
  1556. X
  1557. X
  1558. X    Example 3: abc$
  1559. X
  1560. X    <q0> a <q1> . <q0>
  1561. X    <q1> b <q2> a <q1> . <q0>
  1562. X    <q2> c [q3] a <q1> . <q0>
  1563. X    [q3] . <q1>
  1564. X
  1565. X
  1566. X    Example 4: ^(abc)*$
  1567. X
  1568. X    [q0] a <q1>
  1569. X    <q1> b <q2>
  1570. X    <q2> c [q0]
  1571. X
  1572. X
  1573. X    Example 5: ^[ab][cd][ef]$
  1574. X
  1575. X    <q0> ab <q1>
  1576. X    <q1> cd <q2>
  1577. X    <q2> ef [q3]
  1578. X    [q3]
  1579. X
  1580. X
  1581. X    Example 6: ^(abc|efg)$
  1582. X
  1583. X    <q0> a <q1> e <q3>
  1584. X    <q1> b <q2>
  1585. X    <q2> c [q5]
  1586. X    <q3> f <q4>
  1587. X    <q4> g [q5]
  1588. X    [q5]
  1589. X
  1590. X
  1591. X    With the automaton specification in 'filename', invoke the program by
  1592. X    typing
  1593. X
  1594. X                                adgrep 'filename'
  1595. X
  1596. X    It will read stdin and print out all the lines which the automaton
  1597. X    accepts.  If the file cannot be opened, a system error message will
  1598. X    be printed.  If the input contains errors, then an error message along
  1599. X    with the number of the offending line will be printed to stderr.  The 
  1600. X    number of rules for each state is limited to 17.  If more than 17 rules 
  1601. X    are present, you get the error to_many_rules, and the state that was 
  1602. X    being processed is printed.  Error no_destination occurs if you specify a 
  1603. X    set of characters, but no destination state, and error too_many_states 
  1604. X    occurs if your automaton has more than 257 states.
  1605. X
  1606. X    Running
  1607. X                             adgrep from < your_mailbox
  1608. X
  1609. X    will perform a function similar to that of the unix from command.
  1610. X
  1611. X    If no filename is specified on the command line, then "adgrep.c" is used
  1612. X    as the specification for the automaton.  (This file has been renamed 
  1613. X    to adrian.c by the judges.)  In this case, the program will search for 
  1614. X    matches to the regular expression:
  1615. X
  1616. X                        ^.[^|C][^w[Q]*(Q|[w[]c).*|^.[C|]$
  1617. X
  1618. X    I suggest using adgrep.c as input, and storing the output in adwc.c:
  1619. X
  1620. X                           adgrep < adgrep.c > adwc.c
  1621. X
  1622. X    Compiling the new file, mywc.c, yields a clone of the unix wc command. It
  1623. X    runs on one file (defaulting to "adgrep.c" if no file is given) and
  1624. X    displays the number of lines, words, and bytes in the input file.
  1625. X
  1626. X
  1627. X    Another possibly interesting automaton can be created by slightly
  1628. X    adjusting the adgrep.c file.  Change the first line to read
  1629. X
  1630. X                                 /* . echo| . */
  1631. X
  1632. X    and repeat the process above
  1633. X
  1634. X                           adgrep <adgrep.c > adecho.c
  1635. X
  1636. X    The new file now contains all lines which match
  1637. X
  1638. X                      ^.[^5|m^]*[m^]([e=p,;]|[^e=+p,;].*)$
  1639. X
  1640. X    Compile and run.  This is an echo clone.  Note the efficient algorithm
  1641. X    employed.
  1642. X
  1643. X
  1644. X    Two other adjustments to the first line also yield useful results. By
  1645. X    changing it to
  1646. X                                 /* . head; . */
  1647. X
  1648. X    you can search for matches to
  1649. X
  1650. X                                  ^.[^W]*W..*$
  1651. X
  1652. X    By some freak happenstance, lines of adgrep.c which match this regular
  1653. X    expression form a unix head command.  It prints the first ten lines of
  1654. X    the file specified on the command line (or adgrep.c if no file is
  1655. X    specified).
  1656. X
  1657. X    By setting the first line to
  1658. X
  1659. X                               /* . basename . */
  1660. X
  1661. X    a clone of the unix basename command can be unearthed. The automaton will
  1662. X    search for
  1663. X                                  ^.[^j]*jr.*$
  1664. X
  1665. X    on standard input.  And the program which results by running adgrep.c
  1666. X    through this filter requires two parameters.  The first is meant to be a
  1667. X    filename, and the second, an extension.  All leading pathname components
  1668. X    are removed from the filename, and the extension is removed if present.
  1669. X    The resulting base name is printed to stdout.
  1670. X
  1671. X    Lastly, by setting the first line to
  1672. X
  1673. X                                    /* . sleep . */
  1674. X
  1675. X    you can search for
  1676. X
  1677. X                        ^.[^(~][^s]*sl.*$
  1678. X
  1679. X    Filtering adgrep.c through this search yields a clone of the sleep
  1680. X    command.  Invoke with a single integer parameter, and it will pause
  1681. X    for that many seconds.
  1682. X
  1683. X    If either adbasename or adsleep is invoked with too few parameters,
  1684. X    the program will print the error message:
  1685. X                       Segmentation fault (core dumped)
  1686. X
  1687. X    (The exact text of the above error messages varies from machine to
  1688. X    machine.)  The four programs which read from stdin require lines
  1689. X    shorter than 999 characters.
  1690. X
  1691. X    The other info files are adrian.grep.[1-6] which contain the six
  1692. X    examples that appear above, and from, which is used to emulate the
  1693. X    unix from command.  For reasons of clarity, the name "from" should
  1694. X    probably not be changed if possible.  I wouldn't want to be accused of 
  1695. X    confusing people by giving the input files weird names.
  1696. X
  1697. X    If you want to change the default input filename (line 80) you must be
  1698. X    careful to choose a name that doesn't match the wrong search patterns,
  1699. X    introducing extra lines into one of the programs.
  1700. X
  1701. X    The program will produce at least one warning and possible several
  1702. X    when compiled depending on the compiler.
  1703. SHAR_EOF
  1704. $TOUCH -am 0908160292 1992/adrian.hint &&
  1705. chmod 0444 1992/adrian.hint ||
  1706. echo "restore of 1992/adrian.hint failed"
  1707. set `wc -c 1992/adrian.hint`;Wc_c=$1
  1708. if test "$Wc_c" != "7292"; then
  1709.     echo original size 7292, current size $Wc_c
  1710. fi
  1711. # ============= 1992/adrian.orig.c ==============
  1712. echo "x - extracting 1992/adrian.orig.c (Text)"
  1713. sed 's/^X//' << 'SHAR_EOF' > 1992/adrian.orig.c &&
  1714. X/* . wc . */
  1715. X#include<stdio.h>/* Wht majr flwchrt? */
  1716. X#include<string.h>/* That mjr flwchrt! */
  1717. X#define P 257
  1718. X#define G 17
  1719. X#define z 8
  1720. X#define v(jr) jr
  1721. Xint W ,head;
  1722. X#define S(W,b,f) strncpy(W,b,f),W[f]=0\
  1723. X
  1724. X  
  1725. Xchar *wcs=" \t\n";
  1726. Xstruct{ char X[z+1]; 
  1727. X        char f ;
  1728. X        int e ; 
  1729. X        struct{ char g[z+1];
  1730. X                int b ;
  1731. X              } w[ G];
  1732. X      } o[ P];
  1733. Xint L=0,j= -28;
  1734. X
  1735. X
  1736. Xvoid E(int i, int m,char*c)
  1737. X{   
  1738. X for(; i<43; i+=3) 
  1739. X   putc(i["}|uutsrq`_^bji`[Zkediml[PO]a_M__]ISOYIRGTNR"]+i-9,stderr);
  1740. X fprintf(stderr,"(%d): %s\n" ,m,c);
  1741. X exit(1);
  1742. X}
  1743. X
  1744. X
  1745. X
  1746. Xint N(int m, char *t)
  1747. X{ 
  1748. X  int i ;
  1749. X  if (strlen ( 
  1750. X              t)>z) t[z ]=0;
  1751. X  for(i= 0; i< L ; i++) if(
  1752. X                           !strcmp (o[ i] . X
  1753. X                                             , t))return i;
  1754. X  if( L== P)
  1755. X             E(0, m, t);
  1756. X  S (o[ L] . X , t
  1757. X                  ,z);
  1758. X  head; W = .1* head;
  1759. X  o[L ].f = !( strchr( t,']' )== 0 );
  1760. X  o[L ++ ] . e = 0;
  1761. X  return L -1 ; }
  1762. X
  1763. X#define v(x )
  1764. X
  1765. Xint A(char *R)
  1766. X{
  1767. X  int c=0, i;
  1768. X  while(* R) {
  1769. X    i = -1;
  1770. X    while(j){
  1771. X      if( ++ i==o[ c].e ) return 0;
  1772. X      if(o[ 
  1773. X           c] .w[i ] .g[0 ] 
  1774. X                            =='.' ||strchr (o[ c].w[i] .g ,* R)){
  1775. X      c=
  1776. X        o[ c ] .w[i].b; break;/*
  1777. Xmain(int sl,char *j[]){
  1778. X      sleep (~~~~~~~~atoi(j[1])) ;/* . sl
  1779. X      sl s l . sl
  1780. X      l l ]
  1781. X      sl */ }
  1782. X    }
  1783. X    R++;
  1784. X  }
  1785. X  return o[ c].f;
  1786. X}
  1787. X
  1788. X
  1789. X main(int wc,char *V[]){char Y[999],*s;FILE*W;int m=0,echo,jr,q,wcl=0,wcw=0,wcc=0;
  1790. X v(s = V[1]; if (*V=strrchr(s,'/'))s=*V+1;  if(( !strncmp( s + (jr=strlen(s)) -
  1791. X  (q=strlen(V[2]) ),V[2],q))&&jr!=q) s[jr-q] = 0;  puts(s); )
  1792. X int e,p,C,Q ,basename;
  1793. X W= fopen(wc>= 2 ? V[1] : "adgrep.c","rt");
  1794. Xecho| m^ e| 5| (int) .8| echo|
  1795. Xwc |C ==o[o[C] .e] . 
  1796. Xe| e==+p,p; s[o[C] .e ] 
  1797. X;
  1798. Xwhile( fgets(Y,998,W)) { wcc += strlen(Y); m++;
  1799. X     if( s = strtok(Y,wcs)) wcw++;
  1800. X     else continue ;
  1801. X     C=
  1802. X       basename= j +j+*"* . basename" 
  1803. X                +j+*"* r ] " + N(m,s) ;
  1804. Xwhile( s = strtok(0,wcs)) {
  1805. X       if( o[ C ] . e == 
  1806. X                         G) E(1 ,m,o[C] .X) ;
  1807. X       S(o[C
  1808. X             ] .w[o[C ] .e].g,s, z);
  1809. X       Q= C ;
  1810. X       if(! ( s =strtok ( 0 ,wcs )))wcw --
  1811. X       ,E( 2 , m, o[C]
  1812. X                   . w[ o[ Q ] .e] . g );
  1813. X       e
  1814. X         = o[C ] .w[o[C ] .e++ ] .b= N(m,s)
  1815. X       ; wcw += 2; }  
  1816. X     0&& 
  1817. X        W && wcl++
  1818. X                  < 10 && printf((W,Y)); }
  1819. X   if(j+28) { {
  1820. X                ; } printf("%7u%7u%7u\n", wcl , wcw , wcc); }
  1821. X   while( gets(Y) ) if(A(Y)) puts(Y);
  1822. X   W, jr; }
  1823. X
  1824. XO(int wc,char**V) {
  1825. X--wc && (printf("%s ",*++V), main(wc,V), 1) || printf("\n"); }
  1826. X
  1827. SHAR_EOF
  1828. $TOUCH -am 0817110092 1992/adrian.orig.c &&
  1829. chmod 0444 1992/adrian.orig.c ||
  1830. echo "restore of 1992/adrian.orig.c failed"
  1831. set `wc -c 1992/adrian.orig.c`;Wc_c=$1
  1832. if test "$Wc_c" != "2581"; then
  1833.     echo original size 2581, current size $Wc_c
  1834. fi
  1835. echo "End of part 1, continue with part 2"
  1836. exit 0
  1837. -- 
  1838. For a good prime, call:  391581 * 2^216193 - 1
  1839.