force use of pandoc version >= 3.1.12.2

The `bin/pandoc-wrapper.sh` tool will verify that the ssytem
has a recent enough version of `pandoc(1)`.

We explain why we insist on `pandoc(1)`. version >= 3.1.12.2
in comments where the $PANDOC_MIN_VERSION is set.

Added `--wrap=preserve` as a default argument to `pandoc(1)`.
While this change will impact every HTML file generated,
we believe this will improve the ability of someone to look
at the generated HTML and correlate with the original markdown.

Changed `bin/pandoc-wrapper.sh` VERSION from "1.4.2 2024-03-17"
to "1.4.3 2024-03-18".

Performed `make www` to achieve all of the above and to generate
HTML using the new  `--wrap=preserve` `pandoc(1)` mode.
This commit is contained in:
Landon Curt Noll committed 2024-03-18 01:26:39 -07:00
1 parent 9eb7a54e9f
commit b0b212acb1
402 files changed
+37061 -55132

No files matched your search

+113 -168
View File
@@ -130,8 +130,8 @@
<h2 id="author"><a name="author"></a>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>) <br><br></li>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
<br><br></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -141,64 +141,58 @@ America</em> (<em>United States</em>) <br><br></li>
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
<p>There is an alternate version of this entry. See <a
href="#alternate-code">Alternate code</a> below.</p>
<p>There is an alternate version of this entry. See <a href="#alternate-code">Alternate
code</a> below.</p>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="op">&lt;</span> any-file</span></code></pre></div>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
<h2 id="alternate-code">Alternate code:</h2>
<p>An alternate version of this entry, <a
href="prog.alt.c">prog.alt.c</a>, is provided This alternate code was
supposed to compile without warnings, however with modern compilers this
is no longer the case so it will only cleanly compile with
<code>-Wno-</code> options.</p>
<p>An alternate version of this entry, <a href="prog.alt.c">prog.alt.c</a>, is provided
This alternate code was supposed to compile without warnings, however
with modern compilers this is no longer the case so it will only cleanly compile
with <code>-Wno-</code> options.</p>
<h3 id="alternate-build">Alternate build:</h3>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>prog.alt</code> as you would <code>prog</code>.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>One line, one array, one loop and one statement but it prints many
bytes. It won.</p>
<p>One line, one array, one loop and one statement but it prints many bytes. It won.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>Feed this anything on <code>stdin</code>.</p>
<p>The <a href="scripthd.sh">included script.sh</a> may be used as a
driver program for this entry. It adds several nice-to-have features,
and allows salt-to-taste customizability.</p>
<p>The <a href="scripthd.sh">included script.sh</a> may be used as a driver program for this entry.
It adds several nice-to-have features, and allows salt-to-taste customizability.</p>
<p>This code has been compiled and tested on:</p>
<ul>
<li>OSX-10.11, gcc 4.2.1 and clang 3.0, -O0 and -O3</li>
<li>X86-Linux, gcc 4.1.2 and 4.8.4, -O0 and -O3</li>
<li>ARM-QEMU, gcc 4.8.4, -O0 and -O3</li>
<li>X86-FreeBSD 10.3, clang 3.4.1, -O0 and -O3</li>
<li>TCC 0.9.26 (x86-64) (used as a proxy for <a
href="../../years.html#2001_bellard">2001/bellard</a>)</li>
<li>UNIX V7 pcc (Johnson’s C compiler) on a <a
href="http://simh.trailing-edge.com/">simulated PDP-11/45</a> (see
spoiler for further detail)</li>
<li>TCC 0.9.26 (x86-64) (used as a proxy for <a href="../../years.html#2001_bellard">2001/bellard</a>)</li>
<li>UNIX V7 pcc (Johnson’s C compiler) on a <a href="http://simh.trailing-edge.com/">simulated PDP-11/45</a>
(see spoiler for further detail)</li>
</ul>
<div style="margin-bottom:60em;margin-top:4em">
<strong>Spoiler below; scroll down.</strong>
</div>
<h3 id="spoiler">SPOILER:</h3>
<p>This started life as a personal challenge: write the shortest hex
dump utility in C.</p>
<p>This started life as a personal challenge: write the shortest hex dump utility
in C.</p>
<p>The self-imposed ground rules in the hunt for shortest:</p>
<ul>
<li>The code has to output correctly.</li>
<li>No extraneous newlines, the code must be portable, and without
bypassing the solution using <code>execve(2)</code>, or functions built
upon it (<code>system(3)</code>, <code>popen(3)</code>, etc).</li>
<li>No extraneous newlines, the code must be portable,
and without bypassing the solution using <code>execve(2)</code>, or functions built upon it
(<code>system(3)</code>, <code>popen(3)</code>, etc).</li>
</ul>
<p>E.g:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>main<span class="op">(){</span>system<span class="op">(</span><span class="st">&quot;hd&quot;</span><span class="op">);}</span> <span class="co">// it&#39;s turtles all the way down!</span></span></code></pre></div>
<p>is not acceptable.</p>
<p>And, “output correctly” is the output format of this entry. QED.</p>
<p>Early attempts ended up at a reasonably short 157 characters. This
was too long for a one-liner, so it had to be formatted as something
more interesting. This solution is pleasing, but a true one-liner was
the hoped-for goal. Here is the 157 character version in it’s
entirety:</p>
<p>Early attempts ended up at a reasonably short 157 characters.
This was too long for a one-liner, so it had to be formatted as something more interesting.
This solution is pleasing, but a true one-liner was the hoped-for goal.
Here is the 157 character version in it’s entirety:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="dt">char</span> O<span class="op">,</span>o<span class="op">[</span> <span class="dv">20</span><span class="op">];</span>L<span class="op">(</span>O<span class="op">){</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>putchar <span class="op">(</span> O<span class="op">+</span> <span class="dv">48</span><span class="op">+</span><span class="dv">39</span> <span class="op">*(</span><span class="dv">9</span><span class="op">&lt;</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>O<span class="op">));}</span> I<span class="op">(</span>O<span class="op">)</span> <span class="op">{</span>L<span class="op">(~</span> <span class="dv">15</span><span class="op">);</span></span>
@@ -208,12 +202,12 @@ entirety:</p>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a><span class="op">(</span><span class="dv">4</span><span class="op">^</span>l <span class="op">&gt;&gt;</span><span class="dv">5</span><span class="op">)</span> <span class="op">?</span>l<span class="op">:</span> <span class="dv">46</span><span class="op">,</span>L</span>
<span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a><span class="op">(</span>l<span class="op">&gt;&gt;</span> <span class="dv">4</span><span class="op">),</span>L <span class="op">(</span>l<span class="op">&amp;</span><span class="dv">15</span><span class="op">);</span>O<span class="op">&amp;&amp;</span></span>
<span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a>I<span class="op">(</span>o<span class="op">[</span> O<span class="op">]=</span><span class="dv">0</span> <span class="op">);}</span><span class="co">//157c</span></span></code></pre></div>
<p>While thinking about this in the shower (you are not the only one
that does this!) came the idea which reduced the code to just 119 chars.
This dramatic reduction started to feel close to minimal, and the hunt
resumed. The progression to the present size is interesting, and it is
interesting that the same algorithm can be expressed so differently by
slight rearrangement of its parts.</p>
<p>While thinking about this in the shower (you are not the only one that does this!)
came the idea which reduced the code to just 119 chars.
This dramatic reduction started to feel close to minimal, and the hunt resumed.
The progression to the present size is interesting,
and it is interesting that the same algorithm can be expressed so differently
by slight rearrangement of its parts.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co">// 119</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="dt">char</span> O<span class="op">,</span>o<span class="op">[</span><span class="dv">20</span><span class="op">];</span>main<span class="op">(</span>l<span class="op">){</span><span class="cf">for</span><span class="op">(;~(</span>l<span class="op">=</span>getchar<span class="op">());</span>O<span class="op">||</span>puts<span class="op">(</span>o<span class="op">))</span>o<span class="op">[</span>O<span class="op">++]=</span>isprint<span class="op">(</span>l<span class="op">)?</span>l<span class="op">:</span><span class="dv">46</span><span class="op">,</span>O<span class="op">&amp;=</span><span class="dv">15</span><span class="op">,</span>printf<span class="op">(</span><span class="st">&quot;</span><span class="sc">%02x</span><span class="st"> &quot;</span><span class="op">,</span>l<span class="op">);</span>O<span class="op">[</span>o<span class="op">]=</span><span class="dv">0</span><span class="op">;</span>O<span class="op">&amp;&amp;</span>puts<span class="op">(</span>o<span class="op">);}</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="co">// 116</span></span>
@@ -230,11 +224,10 @@ slight rearrangement of its parts.</p>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a><span class="dt">char</span> O<span class="op">,</span>o<span class="op">[</span><span class="dv">0</span><span class="op">];</span>main<span class="op">(</span>l<span class="op">){</span><span class="cf">for</span><span class="op">(;~</span>l<span class="op">;</span>O<span class="op">||</span>puts<span class="op">(</span>o<span class="op">))</span>O<span class="op">=(</span>O<span class="op">[</span>o<span class="op">]=~(</span>l<span class="op">=</span>getchar<span class="op">())?</span><span class="dv">4</span><span class="op">&lt;(</span><span class="dv">4</span><span class="op">^</span>l<span class="op">&gt;&gt;</span><span class="dv">5</span><span class="op">)?</span>l<span class="op">:</span><span class="dv">46</span><span class="op">:</span><span class="dv">0</span><span class="op">)?-~</span>O<span class="op">&amp;</span>printf<span class="op">(</span><span class="st">&quot;</span><span class="sc">%02x</span><span class="st"> &quot;</span><span class="op">,</span>l<span class="op">)*</span><span class="dv">5</span><span class="op">:!</span>O<span class="op">;}</span></span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a><span class="co">// 109</span></span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a><span class="dt">char</span> O<span class="op">,</span>o<span class="op">[];</span>main<span class="op">(</span>l<span class="op">){</span><span class="cf">for</span><span class="op">(;~</span>l<span class="op">;</span>O<span class="op">||</span>puts<span class="op">(</span>o<span class="op">))</span>O<span class="op">=(</span>O<span class="op">[</span>o<span class="op">]=~(</span>l<span class="op">=</span>getchar<span class="op">())?</span><span class="dv">4</span><span class="op">&lt;(</span><span class="dv">4</span><span class="op">^</span>l<span class="op">&gt;&gt;</span><span class="dv">5</span><span class="op">)?</span>l<span class="op">:</span><span class="dv">46</span><span class="op">:</span><span class="dv">0</span><span class="op">)?-~</span>O<span class="op">&amp;</span>printf<span class="op">(</span><span class="st">&quot;</span><span class="sc">%02x</span><span class="st"> &quot;</span><span class="op">,</span>l<span class="op">)*</span><span class="dv">5</span><span class="op">:!</span>O<span class="op">;}</span></span></code></pre></div>
<p>There are solutions without the ASCII sidebar that are significantly
shorter. These do not compete in the same category, since their output
is materially different. They are derived from the solutions above, but
are still fascinating as concise utilities, so here is their
progression, for the curious:</p>
<p>There are solutions without the ASCII sidebar that are significantly shorter.
These do not compete in the same category, since their output is materially different.
They are derived from the solutions above, but are still fascinating as concise utilities,
so here is their progression, for the curious:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="co">// 102</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>I<span class="op">;</span>O<span class="op">(</span>O<span class="op">){</span>putchar<span class="op">(</span>O<span class="op">+</span><span class="dv">48</span><span class="op">+</span><span class="dv">39</span><span class="op">*(</span><span class="dv">9</span><span class="op">&lt;</span>O<span class="op">));}</span>main<span class="op">(</span>l<span class="op">){</span><span class="cf">for</span><span class="op">(;~(</span>l<span class="op">=</span>getchar<span class="op">());</span>O<span class="op">(++</span>I<span class="op">&amp;</span><span class="dv">15</span><span class="op">?~</span><span class="dv">15</span><span class="op">:~</span><span class="dv">37</span><span class="op">))</span>O<span class="op">(</span>l<span class="op">&gt;&gt;</span><span class="dv">4</span><span class="op">),</span>O<span class="op">(</span>l<span class="op">&amp;</span><span class="dv">15</span><span class="op">);</span>O<span class="op">(-</span><span class="dv">38</span><span class="op">);}</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="co">// 80</span></span>
@@ -245,10 +238,9 @@ progression, for the curious:</p>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a>O<span class="op">;</span>main<span class="op">(</span>l<span class="op">){</span><span class="cf">for</span><span class="op">(;~</span>l<span class="op">;(</span>O<span class="op">=~(</span>l<span class="op">=</span>getchar<span class="op">())?-~</span>O<span class="op">&amp;</span>printf<span class="op">(</span><span class="st">&quot;</span><span class="sc">%02x</span><span class="st"> &quot;</span><span class="op">,</span>l<span class="op">)*</span><span class="dv">5</span><span class="op">:!</span>O<span class="op">)||</span>puts<span class="op">(</span><span class="st">&quot;&quot;</span><span class="op">));}</span></span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a><span class="co">// 76</span></span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a>O<span class="op">;</span>main<span class="op">(</span>l<span class="op">){</span><span class="cf">for</span><span class="op">(;~</span>l<span class="op">;</span>O<span class="op">||</span>puts<span class="op">(&amp;</span>O<span class="op">))</span>O<span class="op">=~(</span>l<span class="op">=</span>getchar<span class="op">())?-~</span>O<span class="op">&amp;</span>printf<span class="op">(</span><span class="st">&quot;</span><span class="sc">%02x</span><span class="st"> &quot;</span><span class="op">,</span>l<span class="op">)*</span><span class="dv">5</span><span class="op">:!</span>O<span class="op">;}</span></span></code></pre></div>
<p>It is possible to reduce the size of each of these by one by eliding
the trailing newline. This was not reported above since the newline kept
getting appended by processing software, and it is more interesting to
remove characters by changing code than by filtering:</p>
<p>It is possible to reduce the size of each of these by one by eliding the trailing newline.
This was not reported above since the newline kept getting appended by processing software,
and it is more interesting to remove characters by changing code than by filtering:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> tr <span class="at">-d</span> <span class="st">&#39;\012&#39;</span> <span class="op">&lt;</span> 109.c <span class="kw">|</span> <span class="fu">wc</span> <span class="at">-c</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="ex">108</span></span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> tr <span class="at">-d</span> <span class="st">&#39;\012&#39;</span> <span class="op">&lt;</span> 76.c <span class="kw">|</span> <span class="fu">wc</span> <span class="at">-c</span></span>
@@ -256,159 +248,112 @@ remove characters by changing code than by filtering:</p>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> tr <span class="at">-d</span> <span class="st">&#39;\012&#39;</span> <span class="op">&lt;</span> 109.c <span class="kw">|</span> <span class="fu">cc</span> <span class="at">-o</span> 108 <span class="at">-xc</span> <span class="at">-</span></span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> verify 108</span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span></span></code></pre></div>
<p>An obfuscated hex dump has been done before: <a
href="../../1986/bright/index.html">1986/bright</a> is similar in
function, but it uses more characters in just setting up its obfuscation
than this entire solution!</p>
<p>An obfuscated hex dump has been done before:
<a href="../../1986/bright/index.html">1986/bright</a> is similar in function,
but it uses more characters in just setting up its obfuscation than this entire
solution!</p>
<h3 id="bigger-spoiler">BIGGER SPOILER:</h3>
<p>If you are unhappy with the way DEL (character 127) is handled,
replace the cryptic expression <code>4&lt;(4^l&gt;&gt;5)?l:46</code>
with <code>32&gt;l|l&gt;126?46:l</code>. Both take the same number of
characters, but the former is a bit more interesting. Bonus question:
how does the first expression work?</p>
<h3 id="biggest-spoiler-and-some-history">BIGGEST SPOILER (and some
history):</h3>
<p>Technically, <code>char o[0];</code> is illegal (SS 6.7.6.2)
according to ISO (N1570). And <code>char o[];</code> is a conditionally
supported feature (SS 6.7.6.2, 6.10.8.3). However, it works in modern C
implementations as an extension, including GCC, Clang and TCC, for X86
and ARM, on multiple operating systems (Linux, OSX/macOS, FreeBSD), so
it is <em>functionally</em> correct. MicroSoft Visual C++ does not allow
<code>char o[]</code> or <code>char o[0]</code>, and implements its
close relative <code>char o[1]</code> such that writing more than a
single char will cause a fault, which is <em>technically</em>
replace the cryptic expression <code>4&lt;(4^l&gt;&gt;5)?l:46</code> with <code>32&gt;l|l&gt;126?46:l</code>.
Both take the same number of characters, but the former is a bit more interesting.
Bonus question: how does the first expression work?</p>
<h3 id="biggest-spoiler-and-some-history">BIGGEST SPOILER (and some history):</h3>
<p>Technically, <code>char o[0];</code> is illegal (SS 6.7.6.2) according to ISO (N1570). And
<code>char o[];</code> is a conditionally supported feature (SS 6.7.6.2, 6.10.8.3).
However, it works in modern C implementations as an extension, including GCC,
Clang and TCC, for X86 and ARM, on multiple operating systems (Linux, OSX/macOS,
FreeBSD), so it is <em>functionally</em> correct. MicroSoft Visual C++ does not allow
<code>char o[]</code> or <code>char o[0]</code>, and implements its close relative <code>char o[1]</code> such
that writing more than a single char will cause a fault, which is <em>technically</em>
correct.</p>
<p>But how does this work at all, even as an extension? <code>o[]</code>
allocates one(!) byte in a zero-filled data area (formerly <a
href="https://en.wikipedia.org/wiki/.bss">BSS</a>). The UNIX-derived
systems this code was run upon all place the storage of <code>O</code>
and <code>o</code> into a zero-filled VM page with nothing following:
thus, there are plenty of available and unused zero bytes following
<code>O</code>, addressed via <code>o</code>, and this code only needs
17. This is <em>undefined</em> behavior, but as shown, it is widely
available.</p>
<p>The <a href="http://minnie.tuhs.org/cgi-bin/utree.pl">1979 Seventh
Edition UNIX</a> (v7) system pre-dates the IOCCC by several years, and
the source code to <code>sh</code>(1) was a <a
href="../../faq.html#ioccc_start">significant inspiration for this
contest</a>. There are two C compilers present: <code>cc</code> written
by Dennis Ritchie, and <code>pcc</code> written by Steven Johnson. The
nested conditional expressions in 116 and smaller are too complex for
<code>cc</code> (“Illegal conditional”) but <code>pcc</code> handles
them correctly, and neither compiler accepts <code>char o[]</code> or
<code>char o[0]</code> and neither put the bytes in a zero-filled page
(as a paged VM was not yet written for UNIX).</p>
<p>More significant is that v7 <code>printf(3)</code> does not report
the number of characters written, and therefore 111 compiles but does
not work correctly; 113 is the shortest code that compiles and runs
correctly in Ancient UNIX.</p>
<p>Interesting digression: v7 <code>printf</code> (<code>_doprnt</code>)
was written in PDP-11 assembly. It pre-dates <code>varargs.h</code>, and
assembly was the only way to gain access to the variable argument types.
The first edition <em>The C Programming Language</em>, 1978, page 71,
remarks:</p>
<p>But how does this work at all, even as an extension? <code>o[]</code> allocates one(!)
byte in a zero-filled data area (formerly
<a href="https://en.wikipedia.org/wiki/.bss">BSS</a>). The UNIX-derived systems this code
was run upon all place the storage of <code>O</code> and <code>o</code> into a zero-filled VM page
with nothing following: thus, there are plenty of available and unused zero
bytes following <code>O</code>, addressed via <code>o</code>, and this code only needs 17. This is
<em>undefined</em> behavior, but as shown, it is widely available.</p>
<p>The <a href="http://minnie.tuhs.org/cgi-bin/utree.pl">1979 Seventh Edition UNIX</a> (v7) system pre-dates the IOCCC by several years,
and the source code to <code>sh</code>(1) was a <a href="../../faq.html#ioccc_start">significant inspiration for this contest</a>.
There are two C compilers present: <code>cc</code> written by Dennis Ritchie, and <code>pcc</code> written by Steven Johnson.
The nested conditional expressions in 116 and smaller are too complex for <code>cc</code> (“Illegal conditional”)
but <code>pcc</code> handles them correctly, and neither compiler accepts <code>char o[]</code> or
<code>char o[0]</code> and neither put the bytes in a zero-filled page (as a paged VM was
not yet written for UNIX).</p>
<p>More significant is that v7 <code>printf(3)</code> does not report the number of characters
written, and therefore 111 compiles but does not work correctly; 113 is the
shortest code that compiles and runs correctly in Ancient UNIX.</p>
<p>Interesting digression: v7 <code>printf</code> (<code>_doprnt</code>) was written in PDP-11 assembly.
It pre-dates <code>varargs.h</code>, and assembly was the only way to gain access to the
variable argument types. The first edition <em>The C Programming Language</em>, 1978,
page 71, remarks:</p>
<blockquote>
<p>By the way, there is no entirely satisfactory way to write a portable
function that accepts a variable number of arguments, because there is
no portable way for the called function to determine how many arguments
where actually passed to it in a given call. …<br />
<code>printf</code>, the most common C function with a variable number
of arguments, … is also non-portable and must be modified for different
environments.</p>
<p>By the way, there is no entirely satisfactory way to write a portable function
that accepts a variable number of arguments, because there is no portable way
for the called function to determine how many arguments where actually passed
to it in a given call.
…<br />
<code>printf</code>, the most common C function with a variable number of arguments,
… is also non-portable and must be modified for different environments.</p>
</blockquote>
<p>It is fascinating to explore the roots of C through the history of
the operating system it was birthed within. C is often criticized as a
difficult, inscrutable language, but as this contest demonstrates, this
is in parody. <em>Shell-gol</em> is one of those instances where someone
<a
href="https://web.archive.org/web/20180521074522/http://www.computerworld.com.au/article/279011/a-z_programming_languages_bourne_shell_sh/?pp=4">preferred
a different language</a>, and (ab)used the preprocessor to re-mold C
into something they found comfortable. Most of the rest of the system,
especially in the kernel, are models of clarity and efficient
expression.</p>
<p>It is fascinating to explore the roots of C through the history of the operating
system it was birthed within. C is often criticized as a difficult, inscrutable
language, but as this contest demonstrates, this is in parody. <em>Shell-gol</em> is
one of those instances where someone <a href="https://web.archive.org/web/20180521074522/http://www.computerworld.com.au/article/279011/a-z_programming_languages_bourne_shell_sh/?pp=4">preferred a different language</a>, and
(ab)used the preprocessor to re-mold C into something they found comfortable.
Most of the rest of the system, especially in the kernel, are models of clarity
and efficient expression.</p>
<h3 id="tldr">TL;DR:</h3>
<p>So which version is the shortest, portable hex dump?</p>
<ul>
<li>109 works with (most?) modern Unix-like systems and compilers, see
example list above.</li>
<li>111 works adds Microsoft, is standards-approved, and does not
exploit undefined behavior.</li>
<li>109 works with (most?) modern Unix-like systems and compilers, see example list above.</li>
<li>111 works adds Microsoft, is standards-approved, and does not exploit undefined behavior.</li>
<li>113 works on Ancient UNIX and the portable C compiler.</li>
<li>119 works on all platforms, including the original Ritchie PDP-11 C
compiler.</li>
<li>119 works on all platforms, including the original Ritchie PDP-11 C compiler.</li>
</ul>
<h3 id="coda">Coda:</h3>
<p>Clearly, the smallest possible program violates modern best practice.
It is not even possible to compile cleanly, but it will compile
correctly.</p>
<p>Included is <a href="prog.alt.c">prog.alt.c</a>, a modern C
implementation that is – perhaps – the smallest, clean-compiling version
using <code>clang</code> or <code>gcc</code> with
<code>-Wall -pedantic</code>. Note that while this is larger than all
but the original attempt, it will <em>not</em> work with the original
Ritchie PDP-11 C compiler, since the expression within the ternary
remains too complex.</p>
It is not even possible to compile cleanly, but it will compile correctly.</p>
<p>Included is <a href="prog.alt.c">prog.alt.c</a>, a modern C implementation that is –
perhaps – the smallest, clean-compiling version using <code>clang</code> or <code>gcc</code> with
<code>-Wall -pedantic</code>. Note that while this is larger than all but the original
attempt, it will <em>not</em> work with the original Ritchie PDP-11 C compiler, since
the expression within the ternary remains too complex.</p>
<p>Try:</p>
<div class="sourceCode" id="cb10"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> prog.c prog.alt.c</span></code></pre></div>
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> prog.c prog.alt.c</span></code></pre></div>
<p>or</p>
<div class="sourceCode" id="cb11"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cmp</span> <span class="at">-b</span> prog.c prog.alt.c</span></code></pre></div>
<p>to compare the differences (<code>diff</code> is not helpful on a
one-liner).</p>
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
License:</h2>
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
Reserved. You are free to share and adapt this file under the terms of
this license:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cmp</span> <span class="at">-b</span> prog.c prog.alt.c</span></code></pre></div>
<p>to compare the differences (<code>diff</code> is not helpful on a one-liner).</p>
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
You are free to share and adapt this file under the terms of this license:</p>
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
<p>For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/</p>
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
<!-- 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 -->
<h1 id="inventory-for-2018burton1"><a name="inventory"></a>Inventory for
2018/burton1</h1>
<h1 id="inventory-for-2018burton1"><a name="inventory"></a>Inventory for 2018/burton1</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/prog.c">prog.c</a>
- entry source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/Makefile">Makefile</a>
- entry Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/prog.alt.c">prog.alt.c</a>
- alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/prog.orig.c">prog.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/scripthd.sh">scripthd.sh</a>
- driver program - adds several nice-to-have features</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/try.sh">try.sh</a>
- how to run</li>
<li><a href="2018_burton1.tar.bz2">2018_burton1.tar.bz2</a> - download
entry source</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/prog.c">prog.c</a> - entry source</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/Makefile">Makefile</a> - entry Makefile</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/prog.alt.c">prog.alt.c</a> - alternative source</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/prog.orig.c">prog.orig.c</a> - original source</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/scripthd.sh">scripthd.sh</a> - driver program - adds several nice-to-have features</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/try.sh">try.sh</a> - how to run</li>
<li><a href="2018_burton1.tar.bz2">2018_burton1.tar.bz2</a> - download entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/.entry.json">.entry.json</a>
- description of entry in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/.gitignore">.gitignore</a>
- list of files that should not be committed under git</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/.entry.json">.entry.json</a> - description of entry in JSON</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
<li><a href=".path">.path</a> - directory path from top directory</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/README.md">README.md</a>
- markdown source for index.html</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/burton1/README.md">README.md</a> - markdown source for index.html</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->