home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume15 / ioccc / part02 < prev    next >
Encoding:
Internet Message Format  |  1988-08-11  |  9.7 KB

  1. Subject:  v15i106:  International Obfuscated C Code Contest, Part02/07
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Landon Curt Noll <chongo@uts.amdahl.com>
  7. Posting-number: Volume 15, Issue 106
  8. Archive-name: ioccc/part02
  9.  
  10. # This is a shell archive.  Remove anything before this line, then
  11. # unpack it by saving it in a file and typing "sh file".  (Files
  12. # unpacked will be owned by you and have default permissions.)
  13. #
  14. # This archive contains:
  15. # ./README ./Makefile
  16.  
  17. echo x - ./README
  18. sed -e 's/^X//' > "./README" << '//E*O*F ./README//'
  19. X               The International Obfuscated C Code Contest
  20. XObfuscate:  tr.v.  -cated, -cating, -cates.  1. a.  To render obscure.
  21. X        b.  To darken.  2. To confuse:  His emotions obfuscated his
  22. X        judgement.  [LLat. obfuscare, to darken : ob(intensive) +
  23. X        Lat. fuscare, to darken < fuscus, dark.] -obfuscation n.
  24. X        obfuscatory adj.
  25. X
  26. X
  27. X
  28. XHow it was started:
  29. X
  30. XThe original inspiration of the International Obfuscated C Code
  31. XContest came from the Bourne Shell source and the finger command as
  32. Xdistributed in 4.2BSD.  If this is what could result from what some
  33. Xpeople claim is reasonable programming practice, then to what depths
  34. Xmight quality sink if people really tried to write poor code?
  35. X
  36. XI put that question to the USENET news groups net.lang.c and
  37. Xnet.unix-wizards in the form of a contest.  I selected a form similar
  38. Xto the contest (Bulwer-Lytton) that asks people to create the worst
  39. Xopening line to a novel.  (that contest in turn was inspired by disgust
  40. Xover a novel that opened with the line "It was a dark and stormy
  41. Xnight.")  The rules were simple: write, in 512 bytes or less, the worst
  42. Xcomplete C program.
  43. X
  44. XThru the contest I have tried to instill two things in people.  First
  45. Xis a disgust for poor coding style.  Second was the notion of just how
  46. Xmuch utility is lost when a program is written in an unstructured
  47. Xfashion.  Contest winners help do this by what I call satirical
  48. Xprogramming.  To see why, observe one of the definitions of satire:
  49. X
  50. X    Keen or energetic activity of the mind used for the purpose 
  51. X    of exposing and discrediting vice or folly.
  52. X
  53. XThe authors of the winning entries placed a great deal of thought into
  54. Xtheir programs.  These programs in turn exposed and discredited what I
  55. Xconsidered to be the programmer's equivalent of "vice or folly".
  56. X
  57. XThere were two unexpected benefits that came from the contest winners.
  58. XFirst was an educational value to the programs.  To understand these C
  59. Xprograms is to understand subtle points of the C programming language.
  60. XThe second benefit is the entertainment value, which should become
  61. Xevident as you read further!
  62. X
  63. X
  64. X
  65. XSuggestions on how to understand the winning entries:
  66. X
  67. XYou are strongly urged to try to determine what each program will
  68. Xproduce by visual inspection.  Often this is an impossible task, but
  69. Xthe difficulty that you encounter should give you more appreciation
  70. Xfor the entry.
  71. X
  72. XIf you have the energy to type in the text, or if you have access to
  73. Xa machine readable version of these programs, you should next consider
  74. Xsome preprocessing such as:
  75. X
  76. X    sed -e '/^#.*include/d' program.c | cc -E
  77. X
  78. XThis strips away comments and expands the program's macros without
  79. Xhaving things such as <stdio.h> macros clutter up the output.  If the
  80. Xentry requires or suggests the use of compile line options (such as
  81. X-Dindex=strchr) they should be added after the '-E' flag.
  82. X
  83. XThe next stage towards understanding is to use a C beautifier or C
  84. Xindenting program on the source.  Be warned that a number of these
  85. Xentries are so twisted that such tools may abort or become very
  86. Xconfused.  You may need to help out by doing some initial formatting
  87. Xwith an editor.  You might also try renaming variables and labels to
  88. Xgive more meaningful names.
  89. X
  90. XNow try linting the program.  You may be surprised at how little lint
  91. Xcomplains about these programs.  Pay careful attention to messages
  92. Xabout unused variables, wrong types, pointer conversions, etc.  But be
  93. Xcareful, some lints produce incorrect error messages or even abort!
  94. XYour lint may detect syntax errors in the source.  See the next
  95. Xparagraph for suggestions on how to deal with this.
  96. X
  97. XWhen you get to the stage where you are ready to compile the program
  98. Xexamine the compilation comments above each entry.  A simple define or
  99. Xedit may be required due to differing semantics between operating
  100. Xsystems.  If you are able to successfully compile the program,
  101. Xexperiment with it by giving it different arguments or input.
  102. XYou may also use the makefile provided to compile the program.
  103. XKeep in mind that C compilers often have bugs, or features which
  104. Xresult the program failing to compile.  You may have to do some
  105. Xsyntax changing as we did to get old programs to compile on strict
  106. XANSI C compilers.
  107. X
  108. XLast, read the judges' comments/spoilers on the program.  Hints
  109. Xfor `foo.c' are given in `foo.hint'.  Often they will contain suggested
  110. Xarguments or recommended data to use.
  111. X
  112. XIf you do gain some understanding of how a program works, go back to
  113. Xthe source and reexamine it using some of the techniques outlined above.
  114. XSee if you can convince yourself of why the program does what it does.
  115. X
  116. X
  117. X
  118. XAbout the judges:
  119. X
  120. XAs of 1988 the contest had two judges: Landon Curt Noll (contest
  121. Xfounder) and Larry Bassel (judge since 1985).  Landon works as a
  122. Xsystems programmer for Amdahl Corporation and Larry works as an systems
  123. Xprogrammer for Sun Microsystems.  In real life, both judges strongly
  124. Xdislike obfuscated code.
  125. X
  126. X
  127. X
  128. XRegarding the source archive:
  129. X
  130. XEach sub-directory contains all the entries for a single year.  Often
  131. Xthe file names match one of the last names of the author.  Judges'
  132. Xhints are given in files of the form ``*.hint''.  The makefiles
  133. Xgiven are set up for a System V based machine.  You may need to
  134. Xtweak this makefile to get everything to compile correctly.
  135. XRead the hint files for suggestions.  The rules for a given
  136. Xyear are given in the file named ``rules''.  The last year
  137. Xin an archive contains a copy of the rules for the upcoming
  138. Xcontest.
  139. X
  140. X
  141. X
  142. XRegarding the distribution of sources:
  143. X
  144. XAll contest results are in the public domain.  We do ask that you observe 
  145. Xthe following request:
  146. X
  147. XYou may shar these files with others, but please do not prevent them of
  148. Xdoing the same.  If some of these files and/or contest entries are
  149. Xpublished in printed form, or if you use them in a business or classroom
  150. Xsetting, please let us know.  We ask that you drop a line to the
  151. X'judges' Email box.  As of 1988, it is:
  152. X
  153. X    judges@uts.amdahl.com    -or-    amdahl!judges
  154. X
  155. X    [this could change from year to year, so consult the current rules]
  156. X
  157. X
  158. X
  159. XSome final things to remember:
  160. X
  161. XWhile the idea for the contests has remained the same through the
  162. Xyears, the contest rules and guidelines vary.  What was novel one year
  163. Xmay be considered common the next.  The categories for awards differ
  164. Xbecause they are determined after the judges examine all of the
  165. Xentries.
  166. X
  167. XThe judges' hints assume that the program resides in a file with the
  168. Xsame username as the author.  Where there is more than one author, the
  169. Xfirst named author is used.
  170. X
  171. XSome C compilers are unable to compile some of these programs.  The
  172. Xjudges tried to select programs that were widely portable and
  173. Xcompilable, but did not always succeed.  As of 1988, only ``K&R''
  174. Xcompilers were used.  Due to the timing of the ANSI C standard, ANSI C
  175. Xissues were not addressed until 1988 at all (and in 1988 there were
  176. Xjust a few comments in the hint files).  Often only a simple edit is
  177. Xneeded to get a new C compiler to accept the source file.
  178. X
  179. XThe contest rules are posted in early March.  The winners are announced
  180. Xat the Usenet BOF of the Summer Usenix conference.  Later they
  181. Xare posted to the net.
  182. X
  183. XThe rules are posted to the following Usenet news groups:
  184. X
  185. X    comp.unix.wizards
  186. X    comp.lang.c        
  187. X
  188. XAs of 1988, the winners were posted to the following Usenet news groups:
  189. X
  190. X    comp.sources.unix        
  191. X    comp.lang.c        
  192. X    alt.sources    
  193. X
  194. XPeople are strongly encouraged to wait until the new contest rules
  195. Xhave been posted before sending entries.  The rules, and sometimes
  196. Xthe contest Email address itself, change from time to time.
  197. XThe typical start date for a contest is March 15.  The typical
  198. Xend date for a contest is May 20.
  199. X
  200. XLast, PLEASE don't code in the style of these programs (unless you
  201. Xare submitting a contest entry of course!)  It is hoped that you will
  202. Xgain an understanding that bad style destroys an otherwise correct
  203. Xprogram.  Real programmers don't write obfuscated programs that other
  204. Xpeople have to use!
  205. X
  206. XHappy pondering,
  207. X
  208. X    Landon Curt Noll   (chongo@uts.amdahl.com)
  209. X    Larry Bassel       (lab@sun.com)
  210. //E*O*F ./README//
  211.  
  212. echo x - ./Makefile
  213. sed -e 's/^X//' > "./Makefile" << '//E*O*F ./Makefile//'
  214. X# %W% %G% %U%
  215. X#
  216. X
  217. XSHELL=/bin/sh
  218. X
  219. Xall:
  220. X    @-for i in [12][0-9][0-9]?; do \
  221. X        if [ -f $$i/[Mm]akefile ]; then \
  222. X        echo "cd $$i; make all"; \
  223. X        (cd $$i; make all); \
  224. X        fi; \
  225. X    done
  226. X
  227. Xclean:
  228. X    @-for i in [12][0-9][0-9]?; do \
  229. X        if [ -f $$i/[Mm]akefile ]; then \
  230. X        echo "cd $$i; make clean"; \
  231. X        (cd $$i; make clean); \
  232. X        fi; \
  233. X    done
  234. Xclobber:
  235. X    @-for i in [12][0-9][0-9]?; do \
  236. X        if [ -f $$i/[Mm]akefile ]; then \
  237. X        echo "cd $$i; make clobber"; \
  238. X        (cd $$i; make clobber); \
  239. X        fi; \
  240. X    done
  241. Xinstall:
  242. X    @-for i in [12][0-9][0-9]?; do \
  243. X        if [ -f $$i/[Mm]akefile ]; then \
  244. X        echo "cd $$i; make install"; \
  245. X        (cd $$i; make install); \
  246. X        fi; \
  247. X    done
  248. //E*O*F ./Makefile//
  249.  
  250. echo Possible errors detected by \'wc\' [hopefully none]:
  251. temp=/tmp/shar$$
  252. trap "rm -f $temp; exit" 0 1 2 3 15
  253. cat > $temp <<\!!!
  254.  193  1346  8065  README
  255.  34  118  655  Makefile
  256.  227  1464  8720  total
  257. !!!
  258. wc  ./README ./Makefile | sed 's=[^ ]*/==' | diff -b $temp -
  259. exit 0
  260.  
  261.