While not strictly necessary, replacing the two ASCII tab characters in the markdown copyright comment makes it easier to detect problematic TAB indentation within markdown files. After this commit, only 90 markdown files have leading ASCII TAB characters. And again, while not strictly necessary, we can consider running expand on those 90 markdown files to see what effect that might have on the HTML files they produce. Replace leading ASCII TAB characters with multiples of 8 ASCII SPACE characters (the default action of the `expand(1)` tool) might have an negative effect on some HTML formatting where **hack-a-round** formatting was attempted to fix broken indentation caused by problematic ASCII TAB characters. Think of this as a baseline for evaluating leading TAB characters within markdown files. TODO: Consider either using `expand(1)` to replace leading ASCII TAB characters with multiples of 8 ASCII SPACE characters AND/OR modifying the appropriate `bin` tool to convert leading ASCII TAB characters into multiples of 8 ASCII SPACE characters.
675 lines
28 KiB
HTML
675 lines
28 KiB
HTML
<!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>The International Obfuscated C Code Contest</title>
|
||
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
|
||
<meta name="description" content="road.to.obscurity.md for 2015/burton">
|
||
<meta name="keywords" content="IOCCC, 2015/burton, road.to.obscurity.md">
|
||
</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/gen-other-html.sh -->
|
||
<!-- The content of main section of this web page came from: 2015/burton/road.to.obscurity.md -->
|
||
<!-- -->
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2015/burton/road.to.obscurity.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2015/burton/road.to.obscurity.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2015/burton/road.to.obscurity.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 winning authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../bugs.html" class="sub-item-link">
|
||
Bugs and (mis)features
|
||
</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">
|
||
IOCCC 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/index.html" class="sub-item-link">
|
||
Rules and Guidelines
|
||
</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">
|
||
FAQ
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#submit" class="sub-item-link">
|
||
How to enter the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
|
||
Fixing IOCCC entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_web_site" class="sub-item-link">
|
||
Fixing the website
|
||
</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">
|
||
About
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../index.html" class="sub-item-link">
|
||
IOCCC Home
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../judges.html" class="sub-item-link">
|
||
The IOCCC Judges
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../contact.html" class="sub-item-link">
|
||
Contacting the IOCCC
|
||
</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="../../markdown.html" class="sub-item-link">
|
||
IOCCC markdown guidelines
|
||
</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">
|
||
Authors of winning IOCCC entries
|
||
</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>
|
||
|
||
</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="../../status.html">
|
||
Contest status
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/index.html">
|
||
Rules and Guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../news.html">
|
||
IOCCC News
|
||
</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="../../faq.html#submit">
|
||
How to enter the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
|
||
Fixing IOCCC entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_web_site">
|
||
Fixing the website
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
|
||
Fixing author info
|
||
</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">
|
||
IOCCC Home
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../judges.html">
|
||
The IOCCC Judges
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../contact.html">
|
||
Contacting the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
|
||
Thanks for the help
|
||
</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>road.to.obscurity.html for 2015/burton</h2>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/header.default.html -->
|
||
<!-- START: this line starts content from: inc/navbar.up2index.html -->
|
||
|
||
<div class="navbar">
|
||
<a class="Left" href="index.html">↑ jump to index.html ↑</a>
|
||
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2015%2Fburton%2Froad.to.obscurity.html">✓</a>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/navbar.up2index.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 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
|
||
<!-- BEFORE: 1st line of markdown file: 2015/burton/road.to.obscurity.md -->
|
||
<h1 id="development-of-the-obfuscated-calculator.">Development of the obfuscated calculator.</h1>
|
||
<p>I wanted to enter the IOCCC….</p>
|
||
<p>I think I can write something clever. Possibly even obscure. The competition
|
||
is fierce, but not a closed door.</p>
|
||
<p>I needed an interesting program, that had a reasonable chance of being shrunk
|
||
within 4096 bytes, and lent itself to obfuscation. I had been revisiting
|
||
utilities I’ve written over the years. One useful program was <code>calc</code>, a simple
|
||
recursive descent signed integer expression parser I developed from first
|
||
principles as a demonstration of how computers work for my son. That program
|
||
did the basic four operations, but as a programmer, I needed more, so those
|
||
were added over time.</p>
|
||
<p><code>calc</code> is a useful, functioning utility. The operators before the obfuscation
|
||
dance began (this is called foreshadowing):</p>
|
||
<pre><code> () forced precedence
|
||
- ~ ? unary minus, compl, byteswap
|
||
* / % & << >> mul, div, mod, bitand, shift: left, right
|
||
+ - | ^ add, sub, bitor, xor
|
||
NUM 0-9</code></pre>
|
||
<p>This seemed like a reasonable candidate to experiment with obfuscation; perhaps
|
||
it might yield good results.</p>
|
||
<h2 id="principle-of-operation">Principle of operation</h2>
|
||
<p>The algorithm was and is rather straightforward:</p>
|
||
<pre><code> expr() {
|
||
n = term()
|
||
t = token()
|
||
if (t == ADD) return n += expr()
|
||
if (t == SUB) return n -= expr()
|
||
if (t == BOR) return n |= expr()
|
||
if (t == XOR) return n ^= expr()
|
||
ungettoken(t)
|
||
return n
|
||
}
|
||
term() {
|
||
n = factor()
|
||
t = token()
|
||
if (t == MUL) return n *= term()
|
||
if (t == DIV) return n /= term()
|
||
if (t == AND) return n &= term()
|
||
if (t == RSH) return n >> term()
|
||
if (t == LSH) return n << term()
|
||
ungettoken(t)
|
||
return n
|
||
}
|
||
factor() {
|
||
t = token()
|
||
if (t == LPAREN) {
|
||
n = expr()
|
||
if token() == RPAREN
|
||
return n
|
||
error()
|
||
}
|
||
if (t == SUB) return -factor()
|
||
if (t == CMP) return ~factor()
|
||
if (t == QUE) return byteswap(factor())
|
||
if (t == DIG) return strtol()
|
||
error()
|
||
}</code></pre>
|
||
<h2 id="obfuscation-is-a-process">Obfuscation is a process</h2>
|
||
<p>Within the above algorithm, there are many details unmentioned, all ripe for
|
||
obfuscation:</p>
|
||
<ul>
|
||
<li>input</li>
|
||
<li>tokenization</li>
|
||
<li><code>atoi(3)</code> input values</li>
|
||
<li><code>sprintf(3)</code> results</li>
|
||
<li>error recovery</li>
|
||
<li>swapping bytes</li>
|
||
<li>user interface (command line vs <code>stdin</code>)</li>
|
||
</ul>
|
||
<p>Uncertain as to how this would progress, I started obfuscating/condensing
|
||
everything except the conversion operations, leaving those to <code>sprintf(3)</code> and
|
||
<code>strtol(3)</code>. The first version of the obfuscated code used an homage to 1984 anon
|
||
for I/O, and it featured a <code>#define</code> for <code>else</code>s and the types, to help minimize
|
||
the repetition. And of course, most functions were renamed with one or two
|
||
letters, and most of the variables became single letter globals. Tokenization
|
||
was rather easy with a declared array, just initialized with unique values for
|
||
each.</p>
|
||
<p>This was when the obfuscation took a turn for the better (worse): it was easy
|
||
to hide the operations via a simple transformation. The code now dealt with
|
||
small integer values instead of direct ASCII representation of the operations.
|
||
And the strings were collapsed into a single combined error message and
|
||
operator tokenization table. This was relatively obscure.</p>
|
||
<p>Next, <code>sprintf(3)</code> was replaced with a custom formatter. This was rather simple,
|
||
but at least the formatting was not obvious. Formatting and printing were
|
||
split early. <code>strtol(3)</code> was replaced with custom logic, limited to 3 practical
|
||
bases: octal, decimal, and hex. The last result was remembered in a special
|
||
variable, dot.</p>
|
||
<p>By this time, I had a version which I considered obscure, and shared this early
|
||
version with a couple of colleagues for comments. I suggested I could improve
|
||
the obfuscation of a <code>term()</code> and <code>factor()</code>, and would like to have assignable
|
||
memories.</p>
|
||
<p>This code was pretty dense, but inspired by previous IOCCC entries, I thought I
|
||
might get rid of all the <code>else</code>s, which showed the structure of the parser
|
||
rather clearly. Investing in the ternary operator, the code got quite a bit
|
||
more difficult to follow, used only <code>for</code> loops, and I had to start taking notes
|
||
to follow it. This was a good sign! ;-)</p>
|
||
<p>I started testing the code. I wrote a test suite to ensure the changes I made
|
||
did not corrupt the processing (oh so easy to do with this obfuscated mess).
|
||
Why does <code>-1>>32</code> yield <code>-1</code>? Oh, yeah: signed arithmetic. Enter Java’s
|
||
<code>unsigned</code> shift: <code>>>></code>. Better. But with more features, more to get wrong,
|
||
and harder to know which expression is causing the error. The easy solution: if
|
||
the name begins with <code>e</code>, echo the input. Now I can see the failing expression.
|
||
Wait, what is this test expression supposed to be testing?</p>
|
||
<p>Wouldn’t it be nice to have comments?</p>
|
||
<p>Adding new functionality to an obscure program is … going about it backwards.
|
||
Get the functionality correct and complete, THEN obscure. Sounds obvious, but
|
||
that did not happen. I got comments working, then desired to have multiple
|
||
statements on a single line (read: semicolon expression terminators). This
|
||
involved quite a bit of rework of the input code, but now allowed very
|
||
convenient user interaction.</p>
|
||
<h2 id="better-obscurity-is-a-laborious-process">Better Obscurity is a laborious process</h2>
|
||
<p>Satisfied with the functionality, but unsatisfied with the obscurity, I
|
||
pondered if I could get rid of all the constants? This had not been done
|
||
before (to my knowledge), and I was able to work out the how-tos and the
|
||
compromises. Now I can no longer declare my arrays, I have to allocate them.
|
||
Obscurity now increased!</p>
|
||
<p>But wouldn’t it be nice to have assignable memories?</p>
|
||
<p>Around this time, the formatted code no longer fit with the 2053 limit (due to a
|
||
lack of comprehension of the significance of the space-after-brace-and-semi
|
||
rule, and a layout program that did not know how to do this). Frustrated, I
|
||
wrote another program to reformat this code into <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/burton/rule2.c">rule2.c</a>, which was a
|
||
single C token per line. This solved the formatting problem, but intriguingly
|
||
introduced another. Now I was faced with the 4096 rule as well as the 2053
|
||
rule. But this was a challenge!</p>
|
||
<p>I wrote a de-obfuscator, and worked on both the unobfuscated version and the
|
||
master code. I worked on the template formatter to make this as automated as
|
||
possible, and worked to achieve both a perfectly presented picture AND the
|
||
single-line exactly-at-4096 <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/burton/rule2.c">rule2.c</a>.</p>
|
||
<p>Finally, “perfection”, with assignable memories! Where perfection is defined
|
||
as a nicely formatted picture at less than 2053, and exactly 4096
|
||
token-per-line <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/burton/rule2.c">rule2.c</a>.</p>
|
||
<h2 id="testing-testing-testing">Testing Testing Testing</h2>
|
||
<p>Cross platform, it works on Mac OSX, fails on Linux. It works if <code>#include <stdlib.h></code>, but it dumps core without it (the only change!)?. 64-bits without
|
||
proper declaration of <code>int</code>s in syscalls yields unpredictable results. 32-bit
|
||
compilation showed problems with byte-swapping in using addition versus
|
||
bitwise-or. In 32-bit land, <code>x<<32 == x</code>, so <code>x<<32 + x>>32</code> does not yield the
|
||
desired result, but <code>x<<32 | x>>32</code> does (with appropriate care and feeding).
|
||
And the different compilers on different hosts complained loudly and
|
||
differently, although all produced correct bits in spite of the noise.</p>
|
||
<p>Further, the program did not do UNIX pipelines well, due to the unbuffered
|
||
homage code (byte-at-a-time I/O), of which <code>write(2)</code> was also the source of the
|
||
portability problem. Replace <code>write(2)</code> with <code>getchar(3)</code>/<code>putchar(3)</code>, and it
|
||
piped well but lost some obscurity and no longer paid (direct) homage to
|
||
history.</p>
|
||
<p>Another problem: only one expression at a time was allowed on the command line,
|
||
no semis, no comments, and it turns out <code>$2</code>, <code>$3</code>, … were not handled correctly.
|
||
Given the new I/O code, it was now possible to copy the command line arguments
|
||
into a buffer, and write a small routine to retrieve bytes from this buffer
|
||
like <code>getchar(3)</code>. Voila! Better obfuscation with much better functionality!</p>
|
||
<p>But wouldn’t it be nice to show what the current variables hold?</p>
|
||
<p>Bytes are now hard to find to keep exactly at 4096, and adding functionality to
|
||
obscured code is not easy. Restructuring the logic to gain the bytes
|
||
necessary, code to display the variables was added.</p>
|
||
<p>Test. Test. Test. Oh, noes! More bugs! Typing “<code>1 + 2 5</code>” yields <code>3</code>, but
|
||
no syntax error. “<code>g = 1</code>” yields a syntax error, and “<code>0xg</code>” does not! “<code>)</code>”
|
||
causes a segfault! Why didn’t I test these before I started obfuscating?! By
|
||
this point, everything I did to the code perturbed the 4096 bytes, all variables
|
||
were already a single character, and it was really difficult to follow the logic
|
||
in a debugger (single-stepping an expression did the entire line of code, even
|
||
if it involved multiple statements – and it did, everywhere, even in the
|
||
unobfuscated version; think: a complex chain of ternary expressions is a single
|
||
statement). This involved careful examination of all the expressions within the
|
||
logic, trying to find a different way of getting the same result, but typically
|
||
within fewer bytes than before to allow for the added logic to fix the bugs.</p>
|
||
<p>The bugs were fixed, the code re-formatted, and <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/burton/rule2.c">rule2.c</a> was again
|
||
4096 bytes.</p>
|
||
<p>But wouldn’t it be nice for unary plus to work?</p>
|
||
<p>Add unary plus, re-balance. Little things now take a fair bit of work. Adding
|
||
anything requires taking away in others, but since all the logic is functional,
|
||
this means rewriting the logic to be more concise. After several rounds of
|
||
this, bytes are scarce to come by.</p>
|
||
<p>But wouldn’t it be nice for assignments to be silent?</p>
|
||
<p>Made them silent (easier said than done!). Why does “<code>1 + 2 5</code>” print a syntax
|
||
error, but “<code>a = 1 + 2 5</code>” does not? Rewrite(!) the assignment logic – and
|
||
this requires more bytes!</p>
|
||
<h2 id="better-obscurity-through-simplification">Better Obscurity Through Simplification</h2>
|
||
<p>Except there were not enough bytes to do this, unless <code>#include <unistd.h></code> is
|
||
removed. But then <code>sbrk()</code> must be declared, eating into the savings. If only
|
||
there were 512 bytes of memory already allocated that could be portably touched
|
||
for free….</p>
|
||
<p>Light bulb! Memory allocation was excised, and the code became more obscure.</p>
|
||
<p>It was working again! It formats beautifully, it compiled cleanly (with apropos
|
||
<code>-Wno-guards</code>), it remains obscure after <code>cpp(1)</code> and <code>clang-format(1)</code>, it
|
||
measures within the limits and exactly at 4096 (this latter was really getting
|
||
challenging to maintain). No more bugs known, it is feature complete,
|
||
documentation written.</p>
|
||
<p>But wouldn’t it be nice to have a logical not?</p>
|
||
<p>Sigh. This was the last operation added. Another round of code churn,
|
||
expressions are difficult to rewrite because they are both obscure and
|
||
relatively tight. But changing around the stable initialization code – by now
|
||
the largest piece of logic – yielded the necessary bytes, and improved
|
||
obscurity by double duty encoding of the operations initialization.</p>
|
||
<p>The utility is now truly functional, and feature complete, and obscure. Without
|
||
<a href="src.doc.txt">src.doc.txt</a> (basic documentation of the code structure), and some
|
||
commented expanded logic stashed away, and the familiarity I have with the code
|
||
having written and revised it repeatedly, I would not even want to attempt to
|
||
decipher the logic. Many times in the debugging, I was thwarted by my own
|
||
obfuscations, and went down blind paths in trying to fix a bug or add
|
||
functionality. Now I think I have a good entry.</p>
|
||
<p>But wouldn’t it be nice to import pre-set definitions from a file?</p>
|
||
<hr style="width:10%;text-align:left;margin-left:0">
|
||
<p>Jump to: <a href="#">top</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: 2015/burton/road.to.obscurity.md -->
|
||
|
||
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.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.default.html -->
|
||
|
||
<!--
|
||
|
||
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/
|
||
|
||
-->
|
||
|
||
<div class="footer">
|
||
|
||
<div id="copyright"><h3>Copyright © 1984-2024 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%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2015%2Fburton%2Froad.to.obscurity.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>
|
||
</p>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/footer.default.html -->
|
||
<!-- START: this line starts content from: inc/bottom.default.html -->
|
||
|
||
</body>
|
||
</html>
|
||
|
||
<!-- END: this line ends content from: inc/bottom.default.html -->
|