Files
Landon Curt Noll a1c86c8a7a add original C links to entry navigation bars
The navigation bar for a winning entry now has a "_Original C_" link
(between the ✅ and the Inventory on the right hand side) so that one
may easily view the original C code that was submitted for IOCCC judging.

Ran `make www timestamp` to perform the above.
2025-08-10 12:46:23 -07:00

948 lines
46 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>2018/burton2 - Best abuse of the rules</title>
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
<meta name="description" content="2018 IOCCC entry burton2 - Best abuse of the rules">
<meta name="keywords" content="IOCCC, 2018, IOCCC 2018, IOCCC entry, burton2, Best abuse of the rules">
</head>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- END: this line ends content from: inc/head.default.html -->
<!-- -->
<!-- This web page was formed via the tool: bin/readme2index.sh -->
<!-- The content of main section of this web page came from: 2018/burton2/README.md -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2018/burton2/README.md !!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2018/burton2/README.md !!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2018/burton2/README.md !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/topbar.default.html -->
<div class="theader">
<nav class="topbar">
<div class="container">
<div class="logo">
<a href="../../index.html" class="logo-link">
IOCCC
</a>
</div>
<div class="topbar-items">
<div class="item">
<span class="item-header">
Entries
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../years.html" class="sub-item-link">
Winning entries
</a>
</div>
<div class="outfit-font">
<a href="../../authors.html" class="sub-item-link">
Winning authors
</a>
</div>
<div class="outfit-font">
<a href="../../location.html" class="sub-item-link">
Location of authors
</a>
</div>
<div class="outfit-font">
<a href="../../bugs.html" class="sub-item-link">
Bugs and (mis)features
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
Fixing entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#fix_author" class="sub-item-link">
Updating author info
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
Status
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../news.html" class="sub-item-link">
News
</a>
</div>
<div class="outfit-font">
<a href="../../status.html" class="sub-item-link">
Contest status
</a>
</div>
<div class="outfit-font">
<a href="../../next/rules.html" class="sub-item-link">
IOCCC rules
</a>
</div>
<div class="outfit-font">
<a href="../../next/guidelines.html" class="sub-item-link">
IOCCC guidelines
</a>
</div>
<div class="outfit-font">
<a href="../../markdown.html" class="sub-item-link">
Markdown guidelines
</a>
</div>
<div class="outfit-font">
<a href="../../SECURITY.html" class="sub-item-link">
Security policy
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
FAQ
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../faq.html" class="sub-item-link">
Frequently asked questions
</a>
</div>
<div class="outfit-font">
<a href="../../quick-start.html#enter" class="sub-item-link">
Enter the IOCCC
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#compiling" class="sub-item-link">
Compiling entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#running_entries" class="sub-item-link">
Running entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#help" class="sub-item-link">
How to help
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
About
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../index.html" class="sub-item-link">
Home page
</a>
</div>
<div class="outfit-font">
<a href="../../social.html" class="sub-item-link">
IOCCC social media
</a>
</div>
<div class="outfit-font">
<a href="../../about.html" class="sub-item-link">
About the IOCCC
</a>
</div>
<div class="outfit-font">
<a href="../../judges.html" class="sub-item-link">
The judges
</a>
</div>
<div class="outfit-font">
<a href="../../thanks-for-help.html" class="sub-item-link">
Thanks for the help
</a>
</div>
<div class="outfit-font">
<a href="../../contact.html" class="sub-item-link">
Contact us
</a>
</div>
</div>
</div>
</div>
</div>
</nav>
<div class="header-mobile-menu">
<noscript>
<a href="../../nojs-menu.html" class="topbar-js-label">
Please Enable JavaScript
</a>
</noscript>
<button id="header-open-menu-button" class="topbar-mobile-menu">
<img
src="../../png/hamburger-icon-open.png"
alt="hamburger style menu icon - open state"
width=48
height=48>
</button>
<button id="header-close-menu-button" class="hide-content">
<img
src="../../png/hamburger-icon-closed.png"
alt="hamburger style menu icon - closed state"
width=48
height=48>
</button>
<div id="mobile-menu-panel" class="hide-content">
<div class="mobile-menu-container">
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
Entries
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../years.html">
Winning entries
</a>
<a class="mobile-submenu-item" href="../../authors.html">
Winning authors
</a>
<a class="mobile-submenu-item" href="../../location.html">
Location of authors
</a>
<a class="mobile-submenu-item" href="../../bugs.html">
Bugs and (mis)features
</a>
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
Fixing entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
Updating author info
</a>
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
Thanks for the help
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
Status
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../news.html">
News
</a>
<a class="mobile-submenu-item" href="../../status.html">
Contest status
</a>
<a class="mobile-submenu-item" href="../../next/rules.html">
IOCCC rules
</a>
<a class="mobile-submenu-item" href="../../next/guidelines.html">
IOCCC guidelines
</a>
<a class="mobile-submenu-item" href="../../markdown.html">
Markdown guidelines
</a>
<a class="mobile-submenu-item" href="../../SECURITY.html">
Security policy
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
FAQ
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../faq.html">
Frequently asked questions
</a>
<a class="mobile-submenu-item" href="../../quick-start.html#enter">
Enter the IOCCC
</a>
<a class="mobile-submenu-item" href="../../faq.html#compiling">
Compiling entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#running_entries">
Running entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#help">
How to help
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
About
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../index.html">
Home page
</a>
<a class="mobile-submenu-item" href="../../social.html">
IOCCC social media
</a>
<a class="mobile-submenu-item" href="../../about.html">
About the IOCCC
</a>
<a class="mobile-submenu-item" href="../../judges.html">
The judges
</a>
<a class="mobile-submenu-item" href="../../contact.html">
Contact us
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
headerOpenMenuButton.addEventListener("click", () => {
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
headerOpenMenuButton.classList.add("hide-content");
headerCloseMenuButton.classList.remove("hide-content");
headerCloseMenuButton.classList.add("topbar-mobile-menu");
mobileMenuPanel.classList.remove("hide-content");
mobileMenuPanel.classList.add("topbar-mobile-panel");
});
headerCloseMenuButton.addEventListener("click", () => {
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
headerCloseMenuButton.classList.add("hide-content");
mobileMenuPanel.classList.add("hide-content");
mobileMenuPanel.classList.remove("topbar-mobile-panel");
headerOpenMenuButton.classList.add("topbar-mobile-menu");
headerOpenMenuButton.classList.remove("hide-content");
});
</script>
<!-- END: this line ends content from: inc/topbar.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<a href="../../2011/zucker/index.html">
<img src="../../png/ioccc.png"
alt="IOCCC image by Matt Zucker"
width=300
height=110>
</a>
<h1>The International Obfuscated C Code Contest</h1>
<h2>2018/burton2 - Best abuse of the rules</h2>
<h3>Tokenize and count</h3>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/navbar.mid.html -->
<div class="navbar">
<a class="Left" href="../burton1/index.html">&larr; 2018/burton1</a>
<a class="Left" href="../index.html">&uarr; 2018 &uarr;</a>
<a class="Left" href="../ciura/index.html">2018/ciura &rarr;</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/prog.c">C code</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/Makefile">Makefile</a>
<a class="Right" href="#inventory">Inventory</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/prog.orig.c">Original C</a>
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2018%2Fburton2%2Findex.html">&#x2713;</a>
</div>
<!-- END: this line ends content from: inc/navbar.mid.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<div class="content" id="content">
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
<!-- START: this line starts content generated by: bin/output-index-author.sh -->
<h2 id="author">Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Dave_Burton">Dave Burton</a><br>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- BEFORE: 1st line of markdown file: 2018/burton2/README.md -->
<h2 id="to-build">To build:</h2>
<pre><code> make</code></pre>
<h2 id="to-use">To use:</h2>
<pre><code> ./prog [-tcksri] &lt; file.c</code></pre>
<h2 id="try">Try:</h2>
<pre><code> ./try.sh</code></pre>
<p>If you get really stuck, try:</p>
<pre><code> man ./tac.1</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>They say size isn’t everything, and in the case of IOCCC
<a href="https://github.com/ioccc-src/winner/blob/master/2018/iocccsize.c">iocccsize.c</a> that is saying something!
What is this program weighing and how much does it weigh?</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="tac---tokenize-and-count-c-and-derivative-languages">tac - tokenize and count C and derivative languages:</h3>
<p><code>tac</code> computes C program size<br>
(obfuscated / otherwise)<br>
by splitting code as tokens small,<br>
ignoring space, then counting all.<br></p>
<p>It tries quite hard to act the same<br>
as counting tool of I-OCCC fame.<br>
Some bugs were fixed, it’s faster too,<br>
and does more things, just add some glue!<br></p>
<p>It does far more than print the size:<br>
the token part’s a better prize!<br>
With each upon on a single line,<br>
how many things can you design?<br></p>
<p>Included is a keyword sorter,<br>
de-obfuscator, freq reporter.<br>
With code produced as little parts,<br>
just add your own creative arts.<br></p>
<p>But first you have to figure out<br>
the braces part, without a doubt!<br>
And then the code - it isn’t easy:<br>
for as else? That’s rather cheesy!<br></p>
<p>The rest of it is standard fare:<br>
expressions strange, the globals bare,<br>
confusing symbols one and oh,<br>
and precedence you have to know.<br></p>
<p>The keyword list was made external,<br>
because of standards change eternal.<br>
Thus other languages can now,<br>
be counted just like C, somehow!<br></p>
<p>I hope you find this code obscure<br>
enough to win, and thus procure<br>
a public place for all to see<br>
how badly I can butcher C!<br></p>
<h3 id="said-another-way.">Said another way….</h3>
<p><code>tac</code> is the inverse of <code>cat</code>(1): it un-concatenates its input into C tokens,
writing the token stream to <code>stdout</code>. There are options to suppress the token
ids, summarize the token counts, and several options to allow it to be
compatible with <code>iocccsize</code>.</p>
<p>The token-based output is quite useful in analyzing source code (see below),
and the counter is more accurate than <code>iocccsize</code> (see below); but this can be
fixed by using the <code>-c</code> compatibility flag, restoring the following problems as
in the official tool:</p>
<ul>
<li>Whitespace <strong>within</strong> a string is <strong>not</strong> counted;
this seems wrong, as these chars <strong>are</strong> significant.</li>
<li>“<code>{;}</code>” is not counted within a double-quoted string.</li>
<li>Whitespace preceding a comment is <code>char</code>-counted, unless the comment starts a
line.</li>
<li><code>-k</code> processes the reserved words within <code>//</code> comments(!), but not <code>/*</code>,
changing the counts.</li>
</ul>
<p>The following bugs are always corrected:</p>
<ul>
<li>Treats <code>/*/</code> as a complete comment (<code>/*/int if for/*/</code> has three keywords)</li>
<li><code>-k</code> enables <code>//*</code> or within a line comment <code>/*</code> to initiate a comment block until following <code>*/</code></li>
<li><code>-k</code> processes double quote characters in <code>//</code> comments - thus a solitary
quote consumes everything until the next quote</li>
<li>Single quotes are not handled correctly (<code>'"'</code> starts a double quote in <code>iocccsize</code>)</li>
<li><code>#ifndef</code> is omitted as a keyword (but <code>#ifdef</code> is allowed?)</li>
<li><code>I</code> is not a reserved word.</li>
<li><code>tac</code> correctly penetrates <a href="../../2014/birken/index.html" title="Best use of port 1701">23rd century cloaking technology</a>. ;-)</li>
</ul>
<p>There is one (known) remaining problem with detection:</p>
<ul>
<li>Comments between preprocessor hash and keyword are not replaced with whitespace;
the following counts #include as two tokens, <code>#</code> and <code>include</code> (not as a reserved word):</li>
</ul>
<pre><code> #/*this will not be counted*/include/*correctly*/&lt;stdio.h&gt;</code></pre>
<p>Fixing this properly hampers backwards compatibility in counting. This requires
eliding comments during the translation phases (ISO 5.1.1.2, phase 3), and yet still
counting words correctly absent <code>-k</code>.</p>
<h3 id="backwards-compatibility">Backwards Compatibility:</h3>
<p><code>tac</code> was run over all 366 previous IOCCC winning entries:</p>
<pre><code> find ~/src/obc -type f -name \*.c | wc</code></pre>
<p>The discrepancies found are documented and explained in the file
<a href="discrepancies.html">discrepancies.html</a>.</p>
<pre><code> find ~/src/obc -type f -a -name &quot;*.c&quot; | xargs ./spotcheck.sh ./prog | ./spotdiff.sh |
grep -v keep | diff -bw - discrep* | grep &quot;[&lt;&gt;] cl &quot;</code></pre>
<p>In summary, there are only 6 unique entries out of 366 that have any variation
in Rule 2 counts; in all cases, the differences are due to bugs within
<code>iocccsize</code>, described in detail in the file
<a href="discrepancies.html">discrepancies.html</a>. There are only 40
files (40/366, ~11%, including originals and variations) that differ at all, 31
only in word count; most word count differences appear related to comment block
detection, weighted more towards recent entries (2011 and onward = 20/40 ~50%).</p>
<p>This (minor) variation in word count values has not been addressed since
it is not a qualifying metric, nor is it very useful in a programming context:
whitespace surrounds English words, not necessarily C tokens, as in <code>a+=1;</code>.</p>
<p>Accuracy (versus compatibility) is demonstrated through a series of small test cases
designed to allow exhaustive, hand-counted values for comparison with the tool values.
These test cases were vital in debugging and regression testing, and provided a way to
determine which tool was correct when there were differences.</p>
<blockquote>
<p>A version of this tool in more clearly written C<br>
is presented for the Judge’s consideration as a more accurate replacement for <code>iocccsize</code>.<br>
This obfuscated entry is derived from (and compatible with) that code,<br>
but due to obfuscation, has had some significant, deep changes for the contest.<br>
Nevertheless, the more clearly written code remains a spoiler for this entry.</p>
</blockquote>
<p>NB: <code>iocccsize</code> gets a different answer from <code>tac</code> on its own
<a href="https://github.com/ioccc-src/winner/blob/master/2018/iocccsize.c">iocccsize.c</a> source code;
<code>tac</code> gets the correct answer. This is due to the aforementioned bugs within <code>iocccsize</code>,
proved by fixing
<a href="https://github.com/ioccc-src/winner/blob/master/2018/iocccsize.c">iocccsize.c</a> with the included patch, so <code>iocccsize</code> reports
the correct answer for itself.</p>
<h3 id="but-wait-theres-more">But wait… There’s More!</h3>
<p>There is no limit on line length, file length, comment length, or identifier length.</p>
<p><code>tac</code> features an accurate tokenizer; which presents each C token on a line by itself.
This feature enables interesting analyses of C (and C++) code that’s hard to get any other way.</p>
<p>For instance, here is a simple token counter, useful in finding repeated long tokens, or operator
frequency, or counting the references to identifiers, constants, or breadth of use of the
language:</p>
<pre><code> #!/usr/bin/env bash
cat $* | ./prog -t | sort | uniq -c | sort -k1nr</code></pre>
<p>And here is a C keyword frequency counter:</p>
<pre><code> #!/usr/bin/env bash
function iskeyword {
awk &#39;BEGIN{f=&quot;c11&quot;;while(getline&lt;f)k[$1]=0} {if($1 in k)k[$1]++}END{for(i in k)print k[i],i}&#39;
}
cat $* | ./prog -t | iskeyword | sort -k1nr</code></pre>
<p>This script was used to “optimize” the reserved word order so the most frequent IOCCC
winning entry keywords are checked first.</p>
<p>An interesting aside: as might be expected, obfuscation has changed the frequency of
keyword distribution over time. The top five for the decades:</p>
<pre><code> 1980s 1990s 2000s 2010s
----- ----- ----- -----
94 if 532 char 375 if 254 int
69 for 524 if 372 char 217 for
59 while 417 int 332 int 198 if
48 char 223 for 184 for 121 return
43 int 223 void 165 return 104 char</code></pre>
<p>The keyword list is external to the program, and is easily changed, sorted, checked, verified.
This allows such additional programs in concert with the tool’s primary operation.</p>
<p>A poor-man’s de-obfuscator can be based upon the output of <code>tac -t</code> and a
handful of simple rules (and another use of the external keyword file). A more
refined version of this is included in the file <a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/unob.sh">unob.sh</a>, but the
simple code below is a serviceable obfuscated C de-obfuscator in a <em>scripting
language</em>. It really is this easy with <code>tac</code>:</p>
<pre><code> #!/usr/bin/env bash
script=&#39;
BEGIN {
last=nl=&quot;\n&quot;;
f=&quot;c11&quot;; while(getline &lt;f &gt; 0) kw[$0]++; close(f);
}
function iskw(a) { return a in kw }
function indent(a) { return sprintf(&quot;%*s&quot;, n*3, &quot; &quot;) }
function newline() { if (!infor &amp;&amp; last != nl) printf last=nl; }
function show(a) {
if (last==nl) printf &quot;%s&quot;, indent()
printf &quot;%s%s&quot;, space(), a
last=a
}
function space() {
return iskw(last) ||
(last ~ /[A-Za-z0-9_+-\/%^[&amp;\]\)=:&lt;&gt;;]$/ &amp;&amp; $0 !~ /[:;()\[\],]/) ? &quot; &quot; : &quot;&quot;
}
/^\(/ { ++paren }
/^\)/ { --paren }
/^for/ { newline(); infor=1 }
infor &amp;&amp; /^;/ { ++infor; show($0 &quot; &quot;); next }
infor==1 &amp;&amp; /^:/ { ++infor }
infor&gt;1 &amp;&amp; paren==0 { infor=0 }
/^\?/ { tern++; n++; newline(); show($0 &quot; &quot;); next }
tern &amp;&amp; /^:/ { newline(); show($0); --tern; --n; next }
/^#/ { newline(); show($0); newline(); next }
/^;/ { show($0); newline(); next }
/^{/ { show($0); ++n; newline(); next }
/^}/ { n--; newline(); show($0); newline(); next }
{ show($0) }
&#39;
cat $* | sed &#39;s/#include/##include/&#39; | cpp -E -trigraphs |
sed &#39;s/^# .*$//&#39; | sed &#39;s/^#//&#39; |
./prog -t | awk &quot;$script&quot;</code></pre>
<h3 id="on-the-question-of-obfuscation">On the question of obfuscation:</h3>
<ul>
<li><p>I assume you noticed the <a href="https://www.youtube.com/watch?v=fUspLVStPbk&amp;start=53" title="Meaning of Life">braces</a>?</p>
<p><em>Every brace is sacred,<br>
Every brace is great.<br>
If a brace is wasted,<br>
Clang gets quite irate</em>.</p></li>
<li><p>Keywords follow the 2010s top five, without the <code>if</code>, for interesting flow control.</p></li>
<li><p>Sometimes a <code>for</code> can be an <code>else</code> - <a href="https://www.youtube.com/watch?v=OHVjs4aobqs" title="Inconceivable">inconceivable</a>!</p></li>
<li><p>I see the <code>getopt(3)</code>. But “<a href="https://www.youtube.com/watch?v=Ug75diEyiA0" title="Where&#39;s the beef?">where’s the beef?</a>”</p></li>
<li><p>No character constants, several <code>int</code> constants, and one string
(hint: which does not encode letters) – how does this code parse code?</p>
<ul>
<li><p>Interesting aside: how many is “several <code>int</code> constants”?</p>
<p>./prog &lt; prog.c 2&gt;/dev/null | awk ‘$1~/260/{a[$2]++}END{for(i in a)print i,a[i]}’
… | wc</p></li>
</ul>
<p>Which numbers are most often used?</p>
<p>… | sort -k2nr | sed 5q</p></li>
<li><p>The code describes its function by careful arrangement of variables up front…</p></li>
<li><p>…coupled with a description of the typical IOCCC contestant, or at least the author</p></li>
<li><p>Why shouldn’t trigraph parsing be written in trigraph?</p></li>
<li><p>Where <a href="https://github.com/ioccc-src/winner/blob/master/2018/iocccsize.c">iocccsize.c</a> mocks, this code flaunts:
“<em>no matter how well you may think you understand this code, you don’t, so don’t mess with it. :-)</em>”</p></li>
<li><p><code>O,0,l,1</code> are used to confusing effect, local names obscure global names.</p></li>
<li><p>Globals are used to pass information between routines: don’t reorder “unrelated” statements….</p></li>
<li><p>How does the compatibility mode account for the fundamentally different manner of computation?</p></li>
<li><p>The algorithm is quite efficient; reserved word detection and trigraph parsing particularly so.</p></li>
<li><p>This may be the first obfuscated submission that provides the means for its own de-obfuscation.</p></li>
</ul>
<h3 id="rule-2">Rule 2:</h3>
<p>The keyword list is externalized as an include file. This presents a useful
feature for the source code: not only can the reserved word script above be
produced, but the tool can be rebuilt with any set of reserved words, just by
using a different list. For instance: removing all the secondary keywords;
removing all the C11 keywords; trying just K&amp;R C. Since C++ and Java share the
same operators as C, just change the keyword list and <code>tac</code> will correctly
tokenize both of these; the tokens <code>&gt;&gt;&gt;</code> and <code>::</code> can be handled with a short
post-filter (<a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/tokenfix.sh">tokenfix.sh</a>, included).</p>
<p>I believe this entry may also satisfy the request for gratuitous use of all the
C11 keywords? Whether this context satisfies “intended C language context” is a
matter of interpretation. ;-) And <code>tac</code> is ready for the IOCCC++ contest. And
the IOJCC trash can.</p>
<p>The following reserved word files are included:</p>
<ul>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/kandr">kandr</a> from my venerable 1978 18th printing “The C Programming Language”</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/v7unix">v7unix</a> 7th edition Unix source code, extracted from c00.c</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/kandr2">kandr2</a> from my 1988 1st printing “The C Programming Language”, 2e</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/ansi">ansi</a> ANSI X3.159-1989</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/c99">c99</a> ISO/IEC 9899:1999(E)</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/c11">c11</a> ISO/IEC 9899:201x(E) N1570</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/c++98">c++98</a> http://en.cppreference.com/w/cpp/keyword</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/c++11">c++11</a> ISO/IEC 14882:2011(E) N3337 2012-01-16</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/c++14">c++14</a> ISO/IEC 14882:2014(E) N4296 2014-11-09</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/java8">java8</a> <a href="http://docs.oracle.com/javase/specs/index.html" class="uri">http://docs.oracle.com/javase/specs/index.html</a></li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/ioccc.kw.freq">ioccc.kw.freq</a> c11 + additional words, sorted on frequency of occurrence in IOCCC entries</li>
</ul>
<p>NB: The keyword file used in this code is derived from the list in <a href="https://github.com/ioccc-src/winner/blob/master/2018/iocccsize.c">iocccsize.c</a>,
which is neither complete (<code>#define</code>, <code>#ifndef</code>, <code>#undef</code> are missing</p>
<pre><code> yes, Virginia knows about `#define` omitted on purpose</code></pre>
<p>nor correct (many more are added: <code>I</code>, <code>true</code>, <code>bool</code>, <code>compl</code>, …):</p>
<pre><code> (sed -n &#39;1p&#39; c11; sed -n &#39;2,$p&#39; ioccc.kw.freq | sort) | comm -3 - c11</code></pre>
<p>That is an obfuscated way to say “diff”. But it also more clearly shows the, um, diffs.</p>
<p>The usage string is similarly externalized, providing a better usability string than
the limits would otherwise allow. If this is considered bending the rules too far,
just <code>-DU=O</code> to get a passible, if cryptic, usage message using no additional octets
than without the define.
This also allows the builder to configure the amount of help a utility should provide
(<a href="https://www.youtube.com/watch?v=VU0GYSA1POs" title="Ants">you want a manpage? Because that’s how you get a manpage.</a>) – a rather
significant point of contention made moot.</p>
<p>There is definitely abuse of the Rule2 counter, exploiting a “feature” of
<code>iocccsize</code>: <code>iocccsize</code> does not Rule2 count <code>{</code>, <code>}</code> and <code>;</code> when followed by
whitespace – even within a string! Thus: Freecode, a simple, uncounted, highly
obfuscated encoding of a central part of this program. (The reserved word list
is not Freecoded, both because it is useful apart from the program, and because
Freecode is not entirely free.)</p>
<ul>
<li>Some restrictions apply. Not approved for all uses. Some assembly required.</li>
</ul>
<h3 id="compilation">Compilation:</h3>
<p>The code is ANSI compliant, but it does have a string longer than 509 characters.
It has been tested on OSX and Linux, Clang and GCC.</p>
<p>The code uses trigraphs, ironically: it parses trigraphs with trigraph code.
Because that’s funny. And it remains obscure after, so trigraphs are not used
for obfuscation. Thus <code>-trigraphs -Wno-trigraphs</code> (which is also humorous).</p>
<p>It’s obfuscated C. Thus <code>-Wno-parentheses -Wno-empty-body -Wno-char-subscripts</code>.</p>
<p>The code uses <code>unsigned char</code>s, but C strings are <code>signed</code>. Thus <code>-Wno-pointer-sign</code>.
NB: This is <em>not</em> a portability concern, the one string holds only printable ASCII characters.</p>
<p>Thus:</p>
<pre><code> cc -ansi -Wall -trigraphs -Wno-trigraphs -Wno-parentheses -Wno-empty-body -Wno-char-subscripts -Wno-pointer-sign -DU=O -DW=\&quot;keywords\&quot; -o prog prog.c</code></pre>
<h3 id="final-remarks">Final remarks:</h3>
<p><a href="../../authors.html#Cody_Boone_Ferguson">Cody Boone Ferguson</a> was relentless in his pursuit of bugs.
Thanks to his reports, the version of <a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/unob.sh">unob.sh</a> is stronger,
<code>tac</code> groks digraphs, <a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/tokenfix.sh">tokenfix.sh</a> corrects for missing digraphs
in <a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/prog.c">prog.c</a>, and the program
<a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/manpage.sh">manpage.sh</a> was added to the corpus.</p>
<p><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/manpage.sh">manpage.sh</a> is a useful program that turns ASCII versions of man
pages (e.g., <a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/tac.1">tac(1)</a> man page) into real man pages. It works for C and C-like
languages, command lines, and was designed to handle man page sections 1-8. It
works well on most inputs, but tends to need some raw nroff for more fancy
constructions, such as combined arguments (e.g. the <code>-r</code> and <code>-s</code> arguments to tac
are not recognised when written as <code>-rs</code> in prose).</p>
<p>Try:</p>
<pre><code> ./manpage.sh tac
./manpage.sh -h
./manpage.sh -h | ./manpage.sh
./manpage.sh -h | ./manpage.sh -R | less
./manpage.sh -h | ./manpage.sh -P | lpr</code></pre>
<p><strong>NOTE</strong>: in 2023 the <code>tac.man</code> was updated to proper man format and renamed
<a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/tac.1">tac.1</a>.</p>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
You are free to share and adapt this file under the terms of this license:
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/
-->
<!-- AFTER: last line of markdown file: 2018/burton2/README.md -->
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
<!-- START: this line starts content generated by: bin/output-index-inventory.sh -->
<div id="inventory">
<h1 id="inventory-for-2018burton2">Inventory for 2018/burton2</h1>
</div>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/prog.c">prog.c</a> - entry source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/Makefile">Makefile</a> - entry Makefile</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/prog.orig.c">prog.orig.c</a> - original source code</li>
<li><a href="discrepancies.html">discrepancies.html</a> - field-by-field difference between iocccsize and entry’s ioc</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/freqcount.sh">freqcount.sh</a> - frequency count utility</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/tac.1">tac.1</a> - tac.c man page</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/tokcount.sh">tokcount.sh</a> - count the tokens produced by ./prog -t</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/try.sh">try.sh</a> - script to try entry</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/fixed_iocccsize.c">fixed_iocccsize.c</a> - iocccsize.c with author patch applied</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/iocccbug01.c">iocccbug01.c</a> - test cases demonstrating problems with iocccsize</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/iocccbug02.c">iocccbug02.c</a> - test cases demonstrating problems with iocccsize</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/iocccbug03.c">iocccbug03.c</a> - test cases demonstrating problems with iocccsize</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/iocccbug04.c">iocccbug04.c</a> - test cases demonstrating problems with iocccsize</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/iocccbug05.c">iocccbug05.c</a> - test cases demonstrating problems with iocccsize</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/iocccbug06.c">iocccbug06.c</a> - test cases demonstrating problems with iocccsize</li>
<li><a href="ioccc.kw.freq">ioccc.kw.freq</a> - C keywords sorted by 201x frequency</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/ioc_without_quote">ioc_without_quote</a> - test suite data</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/manpage.sh">manpage.sh</a> - turns ASCII versions of man into real man pages</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/mkkeywords.sh">mkkeywords.sh</a> - reads a file from variations - produces string for prog.c</li>
<li><a href="results.k">results.k</a> - results with -k option</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/tac.c">tac.c</a> - tokenize and count C-like languages</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test01.c">test01.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test02.c">test02.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test03.c">test03.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test04.c">test04.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test05.c">test05.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test06.c">test06.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test07.c">test07.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test08.c">test08.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test09.c">test09.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test10.c">test10.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test11.c">test11.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test12.c">test12.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test13.c">test13.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/test14.c">test14.c</a> - test case source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/tokenfix.sh">tokenfix.sh</a> - short post-filter</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/unob.sh">unob.sh</a> - refined version of de-obfuscator</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/ansi">ansi</a> - reserved words for ANSI C standard</li>
<li><a href="author-README.txt">author-README.txt</a> - author supplied README</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/c++11">c++11</a> - reserved words for C++11 standard</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/c11">c11</a> - reserved words for C11 standard</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/c++14">c++14</a> - reserved words for C++14 standard</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/c++98">c++98</a> - reserved words for C++98 standard</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/c99">c99</a> - reserved words for C99 standard</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/java8">java8</a> - reserved words for Java v8</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/kandr2">kandr2</a> - reserved words for K&amp;amp;R2 C</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/kandr">kandr</a> - reserved words for K&amp;amp;R C</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/patch">patch</a> - author supplied patch to fix iocccsize.c source</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/results">results</a> - results without -k</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/runtest.sh">runtest.sh</a> - test suite</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/spotcheck.sh">spotcheck.sh</a> - script to test a lot of files vs iocccsize</li>
<li><a href="v7unix">v7unix</a> - reserved words for a v7 UNIX C standard</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/spotdiff.sh">spotdiff.sh</a> - summarize the results of spotcheck</li>
<li><a href="src.doc.txt">src.doc.txt</a> - deobfuscation hints about the source code</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="2018_burton2.tar.bz2">2018_burton2.tar.bz2</a> - download entry tarball</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/README.md">README.md</a> - markdown source for this web page</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/discrepancies.md">discrepancies.md</a> - markdown source for discrepancies.html</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2018/burton2/.path">.path</a> - directory path from top level directory</li>
<li><a href="index.html">index.html</a> - this web page</li>
</ul>
<hr style="width:10%;text-align:left;margin-left:0">
<h4>
Jump to: <a href="#">top</a>
</h4>
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
<!-- END: this line ends content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
</div>
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/footer.inventory.html -->
<!--
Copyright © 1984-2025 by Landon Curt Noll. All Rights Reserved.
You are free to share and adapt this file under the terms of this license:
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/
-->
<div class="footer">
<div id="copyright"><h3>Copyright &copy; 1984-2025 by Landon Curt Noll:
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
target="_blank"
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
<p>
This work is <b>licensed by Landon Curt Noll</b> under
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
target="_blank"
rel="license noopener noreferrer"
style="display:inline-block;">CC BY-SA 4.0</a></b>.
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/cc.png"
alt="cc inside circle symbol">
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/by.png"
alt="person inside circle symbol">
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/sa.png"
alt="arrow looping back on itself inside circle symbol"><br>
You should <b>carefully review</b> the
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
target="_blank"
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
before using the licensed material.<br>
You may wish to review the
<b><a href="../../license.html"
target="_blank"
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
of <b>CC BY-SA 4.0</b>.<br>
</p>
</div>
<div id="coda"><h3>Coda</h3>
<p>
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2018%2Fburton2%2Findex.html" rel="nofollow">Nu HTML check this web page</a><br>
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a><br>
</p>
</div>
</div>
<!-- END: this line ends content from: inc/footer.inventory.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->