improved indentation and whitespace for markdown code blocks

All code blocks in markdown have been intended by at least 4 spaces.

We add `--tab-stop=8` to all `pandoc(1)` executions in order to set
a better tab stop indentation, especially for tab intended code blocks.

Changed `bin/pandoc-wrapper.sh` VERSION from "1.5.3 2024-03-26"
to "1.6 2024-03-31".

Fixed `1991/brnstnd/sorta.README.md` so that the sorta code
is code blocks.

Removed unneeded paragraph group in copyright in `inc/footer.default.html`.

Fixed excess whitespace after list Author on entry `index.html` page.

Changed `bin/output-index-author.sh` VERSION from "1.5.2 2024-03-26"
to "1.6 2024-03-31".

Performed `make www` to perform the above and test under macOS.

TODO: Fix the problem of the initial line of code being extra intended.
TODO: Fix excess whitespace around code that is inline.
This commit is contained in:
Landon Curt Noll committed 2024-04-01 04:48:48 -07:00
1 parent b84c27ce02
commit a996f8d2b8
734 files changed
+16723 -16963

No files matched your search

+1 -1
View File
@@ -108,7 +108,7 @@ Also include anything else that you would like to see in future contests.
Send such email to:
```
questions@ioccc.org
questions@ioccc.org
```
**IMPORTANT NOTE**: The email addresses found above are for historical
+28 -28
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
If you do not have a page up or page down key you might wish to see the
@@ -12,15 +12,15 @@ default value. The author provided the following table:
```
Control Description Default Key
------- ------------------------- -----------
IT Increase throttle XK_Page_Up
DT Decrease throttle XK_Page_Down
FD Move stick forward XK_Up
BK Move stick back XK_Down
LT Move stick left XK_Left
RT Move stick right XK_Right
CS Center stick XK_Enter
Control Description Default Key
------- ------------------------- -----------
IT Increase throttle XK_Page_Up
DT Decrease throttle XK_Page_Down
FD Move stick forward XK_Up
BK Move stick back XK_Down
LT Move stick left XK_Left
RT Move stick right XK_Right
CS Center stick XK_Enter
```
There is another macro, `dt`, which is the time step. See some important points
@@ -35,15 +35,15 @@ the throttle up and down to `u` and `d`:
```sh
make clobber IT=XK_u DT=XK_d all
make clobber IT=XK_u DT=XK_d all
```
because in the header file you can see that `XK_u` corresponds to `u` and `XK_d`
corresponds to `d`:
```c
#define XK_d 0x0064 /* U+0064 LATIN SMALL LETTER D */
#define XK_u 0x0075 /* U+0075 LATIN SMALL LETTER U */
#define XK_d 0x0064 /* U+0064 LATIN SMALL LETTER D */
#define XK_u 0x0075 /* U+0075 LATIN SMALL LETTER U */
```
Note that the [keysym.h](keysym.h) file is not complete from X11; it's just the
@@ -64,7 +64,7 @@ preselected alternative keys.
## To use:
```sh
cat horizon.sc pittsburgh.sc | ./banks
cat horizon.sc pittsburgh.sc | ./banks
```
See the author's remarks in [scenery](#scenery) for more details on the scenery
@@ -107,7 +107,7 @@ the right side for movement. These are hard coded, as noted.
To use the default settings for the alternate build:
```sh
make alt
make alt
```
You may change the other keys as described in the build instructions, above, but
@@ -232,16 +232,16 @@ Here is a brief description of the scenery files:
A few examples of how to input scenery:
```sh
cat horizon.sc pittsburgh.sc | ./banks
cat mountains.sc bb.sc | ./banks
cat mountains.sc river.sc pyramids.sc | ./banks
cat horizon.sc pittsburgh.sc | ./banks
cat mountains.sc bb.sc | ./banks
cat mountains.sc river.sc pyramids.sc | ./banks
```
You can simulate flying through a cloud bank as well:
```sh
./banks < /dev/null
./banks < /dev/null
```
@@ -272,15 +272,15 @@ compiler in the format `-Dcontrol=key` or if you use the Makefile you can do
The possible controls you can map are described in the table below:
```
Control Description Default Key
------- ------------------------- -----------
IT Increase throttle XK_Page_Up
DT Decrease throttle XK_Page_Down
FD Move stick forward XK_Up
BK Move stick back XK_Down
LT Move stick left XK_Left
RT Move stick right XK_Right
CS Center stick XK_Enter
Control Description Default Key
------- ------------------------- -----------
IT Increase throttle XK_Page_Up
DT Decrease throttle XK_Page_Down
FD Move stick forward XK_Up
BK Move stick back XK_Down
LT Move stick left XK_Left
RT Move stick right XK_Right
CS Center stick XK_Enter
```
Values for the possible keys can be found in the X Windows
+29 -30
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Carl_Banks">Carl Banks</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>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,21 +141,21 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<p>If you do not have a page up or page down key you might wish to see the
<a href="#alternate-code">Alternate code</a> section below. You may redefine all the keys
and the time step with predefined macros, however, so one lacking page up / page
down does not strictly need the alternate code; it jut gives those controls a
default value. The author provided the following table:</p>
<pre><code>Control Description Default Key
------- ------------------------- -----------
IT Increase throttle XK_Page_Up
DT Decrease throttle XK_Page_Down
FD Move stick forward XK_Up
BK Move stick back XK_Down
LT Move stick left XK_Left
RT Move stick right XK_Right
CS Center stick XK_Enter</code></pre>
<pre><code> Control Description Default Key
------- ------------------------- -----------
IT Increase throttle XK_Page_Up
DT Decrease throttle XK_Page_Down
FD Move stick forward XK_Up
BK Move stick back XK_Down
LT Move stick left XK_Left
RT Move stick right XK_Right
CS Center stick XK_Enter</code></pre>
<p>There is another macro, <code>dt</code>, which is the time step. See some important points
on this in the author’s comments in the <a href="#alternate-build-instructions">Alternate Build
Instructions</a> section.</p>
@@ -165,11 +164,11 @@ Instructions</a> section.</p>
to use. The name of the macro in the header file is what you need to set the
macros to, depending on what controls you wish to redefine. For instance, to set
the throttle up and down to <code>u</code> and <code>d</code>:</p>
<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="fu">make</span> clobber IT=XK_u DT=XK_d all</span></code></pre></div>
<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="fu">make</span> clobber IT=XK_u DT=XK_d all</span></code></pre></div>
<p>because in the header file you can see that <code>XK_u</code> corresponds to <code>u</code> and <code>XK_d</code>
corresponds to <code>d</code>:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define XK_d </span><span class="bn">0x0064</span><span class="pp"> </span><span class="co">/* U+0064 LATIN SMALL LETTER D */</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="pp">#define XK_u </span><span class="bn">0x0075</span><span class="pp"> </span><span class="co">/* U+0075 LATIN SMALL LETTER U */</span></span></code></pre></div>
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define XK_d </span><span class="bn">0x0064</span><span class="pp"> </span><span class="co">/* U+0064 LATIN SMALL LETTER D */</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define XK_u </span><span class="bn">0x0075</span><span class="pp"> </span><span class="co">/* U+0075 LATIN SMALL LETTER U */</span></span></code></pre></div>
<p>Note that the <a href="keysym.h">keysym.h</a> file is not complete from X11; it’s just the
more likely candidates (and some that are probably unlikely :-) ).</p>
<p>The upper case letters would be <code>XK_U</code> and <code>XK_D</code> and you can search the header
@@ -182,7 +181,7 @@ instructions. Since you can use the original entry to redefine these this is not
a problem and is purely a convenience .. if only for those who are okay with the
preselected alternative keys.</p>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> horizon.sc pittsburgh.sc <span class="kw">|</span> <span class="ex">./banks</span></span></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> horizon.sc pittsburgh.sc <span class="kw">|</span> <span class="ex">./banks</span></span></code></pre></div>
<p>See the author’s remarks in <a href="#scenery">scenery</a> for more details on the scenery
files.</p>
<h2 id="try">Try:</h2>
@@ -209,7 +208,7 @@ you should use the original entry as described in the to build section above.</p
letters on the left side of the keyboard which is easier to use if one is using
the right side for movement. These are hard coded, as noted.</p>
<p>To use the default settings for the alternate build:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
<p>You may change the other keys as described in the build instructions, above, but
this alt code can be seen as an alternative for those who don’t have or don’t
want to use page up and page down.</p>
@@ -290,11 +289,11 @@ landscape.</p></li>
<p>Follow a flowing river from the sky.</p></li>
</ul>
<p>A few examples of how to input scenery:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> horizon.sc pittsburgh.sc <span class="kw">|</span> <span class="ex">./banks</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> mountains.sc bb.sc <span class="kw">|</span> <span class="ex">./banks</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> mountains.sc river.sc pyramids.sc <span class="kw">|</span> <span class="ex">./banks</span></span></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> horizon.sc pittsburgh.sc <span class="kw">|</span> <span class="ex">./banks</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> mountains.sc bb.sc <span class="kw">|</span> <span class="ex">./banks</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> mountains.sc river.sc pyramids.sc <span class="kw">|</span> <span class="ex">./banks</span></span></code></pre></div>
<p>You can simulate flying through a cloud bank as well:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./banks</span> <span class="op">&lt;</span> /dev/null</span></code></pre></div>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./banks</span> <span class="op">&lt;</span> /dev/null</span></code></pre></div>
<p>You will usually want at least a horizon, though.</p>
<p>The format of scenery files is simple, by the way. They’re just
a list of 3D coordinates, and the simulator simply draws line
@@ -312,15 +311,15 @@ different options.</p>
compiler in the format <code>-Dcontrol=key</code> or if you use the Makefile you can do
<code>make control=key</code>.</p>
<p>The possible controls you can map are described in the table below:</p>
<pre><code>Control Description Default Key
------- ------------------------- -----------
IT Increase throttle XK_Page_Up
DT Decrease throttle XK_Page_Down
FD Move stick forward XK_Up
BK Move stick back XK_Down
LT Move stick left XK_Left
RT Move stick right XK_Right
CS Center stick XK_Enter</code></pre>
<pre><code> Control Description Default Key
------- ------------------------- -----------
IT Increase throttle XK_Page_Up
DT Decrease throttle XK_Page_Down
FD Move stick forward XK_Up
BK Move stick back XK_Down
LT Move stick left XK_Left
RT Move stick right XK_Right
CS Center stick XK_Enter</code></pre>
<p>Values for the possible keys can be found in the X Windows
header file <code>&lt;X11/keysym.h&gt;</code>. This file is most likely a
cross-reference to another header, <code>&lt;X11/keysymdef.h&gt;</code>.</p>
+2 -2
View File
@@ -1,14 +1,14 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./bas1.sh
./bas1.sh
```
+3 -4
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Bas_de_Bakker">Bas de Bakker</a><br>
Location: <a href="../../location.html#NL">NL</a> - <em>Kingdom of the Netherlands</em> (<em>Netherlands</em>)
<br><br></li>
Location: <a href="../../location.html#NL">NL</a> - <em>Kingdom of the Netherlands</em> (<em>Netherlands</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,9 +141,9 @@ Location: <a href="../../location.html#NL">NL</a> - <em>Kingdom of the Netherlan
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<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">./bas1.sh</span></span></code></pre></div>
<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">./bas1.sh</span></span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The output is supposed to be a 3D maze, but it is somewhat more
than that. If you’ve seen any of the <a href="https://en.wikipedia.org/wiki/M._C._Escher">Maurits
+6 -6
View File
@@ -1,26 +1,26 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./bas2 < file
echo text | ./bas2
./bas2 < file
echo text | ./bas2
```
## Try:
```sh
./try.sh
./try.sh
./try.sh "foo bar" "baz" "IOCCC 1998/bas2" README.md
./try.sh "foo bar" "baz" "IOCCC 1998/bas2" README.md
./try.sh try.sh "bas2.c" bas2.orig.c
./try.sh try.sh "bas2.c" bas2.orig.c
```
+7 -8
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Bas_de_Bakker">Bas de Bakker</a><br>
Location: <a href="../../location.html#NL">NL</a> - <em>Kingdom of the Netherlands</em> (<em>Netherlands</em>)
<br><br></li>
Location: <a href="../../location.html#NL">NL</a> - <em>Kingdom of the Netherlands</em> (<em>Netherlands</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,16 +141,16 @@ Location: <a href="../../location.html#NL">NL</a> - <em>Kingdom of the Netherlan
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<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">./bas2</span> <span class="op">&lt;</span> file</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> text <span class="kw">|</span> <span class="ex">./bas2</span></span></code></pre></div>
<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">./bas2</span> <span class="op">&lt;</span> file</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> text <span class="kw">|</span> <span class="ex">./bas2</span></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>
<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>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> <span class="st">&quot;foo bar&quot;</span> <span class="st">&quot;baz&quot;</span> <span class="st">&quot;IOCCC 1998/bas2&quot;</span> README.md</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> <span class="st">&quot;foo bar&quot;</span> <span class="st">&quot;baz&quot;</span> <span class="st">&quot;IOCCC 1998/bas2&quot;</span> README.md</span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> try.sh <span class="st">&quot;bas2.c&quot;</span> bas2.orig.c</span></code></pre></div>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> try.sh <span class="st">&quot;bas2.c&quot;</span> bas2.orig.c</span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<h3 id="questions-to-ponder">Questions to ponder:</h3>
<p>Can you determine the relationship between the input and the resulting numeric
+4 -5
View File
@@ -1,8 +1,7 @@
## To build:
```sh
make chaos
make chaos
```
NOTE: Some systems do not implement `halfdelay()` in their `libcurses`.
@@ -10,21 +9,21 @@ You might try compiling with -lncurses if you have that library.
Or you can build this entry without the `halfdelay()` call by:
```sh
make chaos_nohalf
make chaos_nohalf
```
## To use:
```sh
./chaos
./chaos
```
## Try:
```sh
./try.sh
./try.sh
```
This script will run the program on each data file. To quit the program hit `q`.
+5 -6
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Alan_De_Smet">Alan De Smet</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>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,15 +141,15 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> chaos</span></code></pre></div>
<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> chaos</span></code></pre></div>
<p>NOTE: Some systems do not implement <code>halfdelay()</code> in their <code>libcurses</code>.
You might try compiling with -lncurses if you have that library.
Or you can build this entry without the <code>halfdelay()</code> call by:</p>
<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="fu">make</span> chaos_nohalf</span></code></pre></div>
<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="fu">make</span> chaos_nohalf</span></code></pre></div>
<h2 id="to-use">To use:</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">./chaos</span></span></code></pre></div>
<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">./chaos</span></span></code></pre></div>
<h2 id="try">Try:</h2>
<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="ex">./try.sh</span></span></code></pre></div>
<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="ex">./try.sh</span></span></code></pre></div>
<p>This script will run the program on each data file. To quit the program hit <code>q</code>.
If not all files have been used it will go to the next one; otherwise the script
will be finished. To end the script early send intr/ctrl-c.</p>
+3 -3
View File
@@ -1,21 +1,21 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./df
./df
```
## Try:
```sh
./try.sh
./try.sh
```
This will run the program in a loop until you exit (`q` when prompted or
+4 -5
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Daniel_Fischer">Daniel Fischer</a><br>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<br><br></li>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,11 +141,11 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<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">./df</span></span></code></pre></div>
<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">./df</span></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>
<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>
<p>This will run the program in a loop until you exit (<code>q</code> when prompted or
ctrl-c/intr).</p>
<p>Can you figure out a very simple pipeline to cheat?</p>
+32 -33
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
There is an alternate version available. See [Alternate code](#alternate-code)
@@ -11,9 +11,9 @@ below for more details.
## To use:
```sh
./dlowe < file > pootfile
./dlowe < file > pootfile
./dlowe < file
./dlowe < file
```
@@ -22,7 +22,7 @@ below for more details.
The current status of this entry is:
```
STATUS: missing or dead link - please provide them
STATUS: missing or dead link - please provide them
```
For more detailed information see [1998 dlowe bugs](../../bugs.html#1998_dlowe).
@@ -31,9 +31,8 @@ For more detailed information see [1998 dlowe bugs](../../bugs.html#1998_dlowe).
## Try:
```sh
./dlowe < README.md
./dlowe < README.md > README.poot.md
./dlowe < README.md
./dlowe < README.md > README.poot.md
```
Why is there different output?
@@ -41,7 +40,7 @@ Why is there different output?
Also try:
```sh
./try.sh
./try.sh
```
Did you spot the Easter egg there?
@@ -56,14 +55,14 @@ that program.
### Alternate build:
```sh
make alt
make alt
```
### Alternate use:
```
./dlowe.alt < file > pootfile
./dlowe.alt < file > pootfile
```
What's the difference between this and `dlowe`?
@@ -72,7 +71,7 @@ What's the difference between this and `dlowe`?
### Alternate try:
```sh
./try.alt.sh
./try.alt.sh
```
Did you spot the Easter egg there?
@@ -95,27 +94,27 @@ more consistent level of quality. :-)
A CGI script such as:
```sh
#!/bin/sh
# pootify - a sample CGI pootifier
#
POOT="/usr/local/bin/dlowe"
LYNX="/usr/local/bin/lynx"
ECHO="/usr/bin/echo"
EXPR="/usr/bin/expr"
${ECHO} "Content-type: text/html"
${ECHO}
if [ -z "${QUERY_STRING}" ]; then
${ECHO} "QUERY_STRING not found"
else
URL=`${EXPR} "$QUERY_STRING" : '[Uu][Rr][Ll]=\(.*\)'`
if [ -z "${URL}" ]; then
${ECHO} "No URL given in QUERY_STRING"
elif [ X`${EXPR} "${URL}" : '[Ff][Ii][Ll][Ee]:'` != X0 ]; then
${ECHO} "file: based URLs are not allowed"
#!/bin/sh
# pootify - a sample CGI pootifier
#
POOT="/usr/local/bin/dlowe"
LYNX="/usr/local/bin/lynx"
ECHO="/usr/bin/echo"
EXPR="/usr/bin/expr"
${ECHO} "Content-type: text/html"
${ECHO}
if [ -z "${QUERY_STRING}" ]; then
${ECHO} "QUERY_STRING not found"
else
${LYNX} -restrictions=all -source "${URL}" | ${POOT}
URL=`${EXPR} "$QUERY_STRING" : '[Uu][Rr][Ll]=\(.*\)'`
if [ -z "${URL}" ]; then
${ECHO} "No URL given in QUERY_STRING"
elif [ X`${EXPR} "${URL}" : '[Ff][Ii][Ll][Ee]:'` != X0 ]; then
${ECHO} "file: based URLs are not allowed"
else
${LYNX} -restrictions=all -source "${URL}" | ${POOT}
fi
fi
fi
```
can be used to pootify web pages. This has been added as
@@ -133,9 +132,9 @@ should use the above one instead. You can use the script
can look at locally in a browser or pipe through `less(1)`. For instance:
```sh
./pootify.sh URL=https://microsoft.com | less
./pootify.sh URL=https://microsoft.com | less
./pootify.sh -r URL=https://microsoft.com > ms.html
./pootify.sh -r URL=https://microsoft.com > ms.html
```
where the first one would show the text as rendered but without links, images
@@ -145,7 +144,7 @@ it in a browser.
For an old example of it working as a CGI script see:
```sh
https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org
https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org
```
+35 -36
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#J_David_Lowe">J. David Lowe</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>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,34 +141,34 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<p>There is an alternate version available. See <a href="#alternate-code">Alternate code</a>
below for more details.</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">./dlowe</span> <span class="op">&lt;</span> file <span class="op">&gt;</span> pootfile</span>
<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">./dlowe</span> <span class="op">&lt;</span> file <span class="op">&gt;</span> pootfile</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./dlowe</span> <span class="op">&lt;</span> file</span></code></pre></div>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dlowe</span> <span class="op">&lt;</span> file</span></code></pre></div>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code>STATUS: missing or dead link - please provide them</code></pre>
<pre><code> STATUS: missing or dead link - please provide them</code></pre>
<p>For more detailed information see <a href="../../bugs.html#1998_dlowe">1998 dlowe bugs</a>.</p>
<h2 id="try">Try:</h2>
<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="ex">./dlowe</span> <span class="op">&lt;</span> README.md</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./dlowe</span> <span class="op">&lt;</span> README.md <span class="op">&gt;</span> README.poot.md</span></code></pre></div>
<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="ex">./dlowe</span> <span class="op">&lt;</span> README.md</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dlowe</span> <span class="op">&lt;</span> README.md <span class="op">&gt;</span> README.poot.md</span></code></pre></div>
<p>Why is there different output?</p>
<p>Also try:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<p>Did you spot the Easter egg there?</p>
<h2 id="alternate-code">Alternate code:</h2>
<p>The original entry was just a text based pootifier. This alternate version is
that program.</p>
<h3 id="alternate-build">Alternate build:</h3>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<pre><code>./dlowe.alt &lt; file &gt; pootfile</code></pre>
<pre><code> ./dlowe.alt &lt; file &gt; pootfile</code></pre>
<p>What’s the difference between this and <code>dlowe</code>?</p>
<h3 id="alternate-try">Alternate try:</h3>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.alt.sh</span></span></code></pre></div>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.sh</span></span></code></pre></div>
<p>Did you spot the Easter egg there?</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Why could this this entry be considered a utility? Well because it
@@ -180,27 +179,27 @@ a CGI program: <a href="https://web.archive.org/web/20001025182142/http://pootpo
more consistent level of quality. :-)</p>
<h3 id="historical-remarks">Historical remarks:</h3>
<p>A CGI script such as:</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="co">#!/bin/sh</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="co"># pootify - a sample CGI pootifier</span></span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="co">#</span></span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="va">POOT</span><span class="op">=</span><span class="st">&quot;/usr/local/bin/dlowe&quot;</span></span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="va">LYNX</span><span class="op">=</span><span class="st">&quot;/usr/local/bin/lynx&quot;</span></span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="va">ECHO</span><span class="op">=</span><span class="st">&quot;/usr/bin/echo&quot;</span></span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a><span class="va">EXPR</span><span class="op">=</span><span class="st">&quot;/usr/bin/expr&quot;</span></span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a><span class="va">${ECHO}</span> <span class="st">&quot;Content-type: text/html&quot;</span></span>
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a><span class="va">${ECHO}</span></span>
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="bu">[</span> <span class="ot">-z</span> <span class="st">&quot;</span><span class="va">${QUERY_STRING}</span><span class="st">&quot;</span> <span class="bu">]</span><span class="kw">;</span> <span class="cf">then</span></span>
<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> <span class="va">${ECHO}</span> <span class="st">&quot;QUERY_STRING not found&quot;</span></span>
<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a><span class="cf">else</span></span>
<span id="cb9-13"><a href="#cb9-13" aria-hidden="true" tabindex="-1"></a> <span class="va">URL</span><span class="op">=</span><span class="kw">`</span><span class="va">${EXPR}</span> <span class="st">&quot;</span><span class="va">$QUERY_STRING</span><span class="st">&quot;</span> : <span class="st">&#39;[Uu][Rr][Ll]=\(.*\)&#39;</span><span class="kw">`</span></span>
<span id="cb9-14"><a href="#cb9-14" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="bu">[</span> <span class="ot">-z</span> <span class="st">&quot;</span><span class="va">${URL}</span><span class="st">&quot;</span> <span class="bu">]</span><span class="kw">;</span> <span class="cf">then</span></span>
<span id="cb9-15"><a href="#cb9-15" aria-hidden="true" tabindex="-1"></a> <span class="va">${ECHO}</span> <span class="st">&quot;No URL given in QUERY_STRING&quot;</span></span>
<span id="cb9-16"><a href="#cb9-16" aria-hidden="true" tabindex="-1"></a> <span class="cf">elif</span> <span class="bu">[</span> X<span class="kw">`</span><span class="va">${EXPR}</span> <span class="st">&quot;</span><span class="va">${URL}</span><span class="st">&quot;</span> : <span class="st">&#39;[Ff][Ii][Ll][Ee]:&#39;</span><span class="kw">`</span> <span class="ot">!=</span> X0 <span class="bu">]</span><span class="kw">;</span> <span class="cf">then</span></span>
<span id="cb9-17"><a href="#cb9-17" aria-hidden="true" tabindex="-1"></a> <span class="va">${ECHO}</span> <span class="st">&quot;file: based URLs are not allowed&quot;</span></span>
<span id="cb9-18"><a href="#cb9-18" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span></span>
<span id="cb9-19"><a href="#cb9-19" aria-hidden="true" tabindex="-1"></a> <span class="va">${LYNX}</span> <span class="at">-restrictions</span><span class="op">=</span>all <span class="at">-source</span> <span class="st">&quot;</span><span class="va">${URL}</span><span class="st">&quot;</span> <span class="kw">|</span> <span class="va">${POOT}</span></span>
<span id="cb9-20"><a href="#cb9-20" aria-hidden="true" tabindex="-1"></a> <span class="cf">fi</span></span>
<span id="cb9-21"><a href="#cb9-21" aria-hidden="true" tabindex="-1"></a><span class="cf">fi</span></span></code></pre></div>
<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="co">#!/bin/sh</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># pootify - a sample CGI pootifier</span></span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="co">#</span></span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> <span class="va">POOT</span><span class="op">=</span><span class="st">&quot;/usr/local/bin/dlowe&quot;</span></span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="va">LYNX</span><span class="op">=</span><span class="st">&quot;/usr/local/bin/lynx&quot;</span></span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="va">ECHO</span><span class="op">=</span><span class="st">&quot;/usr/bin/echo&quot;</span></span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> <span class="va">EXPR</span><span class="op">=</span><span class="st">&quot;/usr/bin/expr&quot;</span></span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> <span class="va">${ECHO}</span> <span class="st">&quot;Content-type: text/html&quot;</span></span>
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a> <span class="va">${ECHO}</span></span>
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="bu">[</span> <span class="ot">-z</span> <span class="st">&quot;</span><span class="va">${QUERY_STRING}</span><span class="st">&quot;</span> <span class="bu">]</span><span class="kw">;</span> <span class="cf">then</span></span>
<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> <span class="va">${ECHO}</span> <span class="st">&quot;QUERY_STRING not found&quot;</span></span>
<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span></span>
<span id="cb9-13"><a href="#cb9-13" aria-hidden="true" tabindex="-1"></a> <span class="va">URL</span><span class="op">=</span><span class="kw">`</span><span class="va">${EXPR}</span> <span class="st">&quot;</span><span class="va">$QUERY_STRING</span><span class="st">&quot;</span> : <span class="st">&#39;[Uu][Rr][Ll]=\(.*\)&#39;</span><span class="kw">`</span></span>
<span id="cb9-14"><a href="#cb9-14" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="bu">[</span> <span class="ot">-z</span> <span class="st">&quot;</span><span class="va">${URL}</span><span class="st">&quot;</span> <span class="bu">]</span><span class="kw">;</span> <span class="cf">then</span></span>
<span id="cb9-15"><a href="#cb9-15" aria-hidden="true" tabindex="-1"></a> <span class="va">${ECHO}</span> <span class="st">&quot;No URL given in QUERY_STRING&quot;</span></span>
<span id="cb9-16"><a href="#cb9-16" aria-hidden="true" tabindex="-1"></a> <span class="cf">elif</span> <span class="bu">[</span> X<span class="kw">`</span><span class="va">${EXPR}</span> <span class="st">&quot;</span><span class="va">${URL}</span><span class="st">&quot;</span> : <span class="st">&#39;[Ff][Ii][Ll][Ee]:&#39;</span><span class="kw">`</span> <span class="ot">!=</span> X0 <span class="bu">]</span><span class="kw">;</span> <span class="cf">then</span></span>
<span id="cb9-17"><a href="#cb9-17" aria-hidden="true" tabindex="-1"></a> <span class="va">${ECHO}</span> <span class="st">&quot;file: based URLs are not allowed&quot;</span></span>
<span id="cb9-18"><a href="#cb9-18" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span></span>
<span id="cb9-19"><a href="#cb9-19" aria-hidden="true" tabindex="-1"></a> <span class="va">${LYNX}</span> <span class="at">-restrictions</span><span class="op">=</span>all <span class="at">-source</span> <span class="st">&quot;</span><span class="va">${URL}</span><span class="st">&quot;</span> <span class="kw">|</span> <span class="va">${POOT}</span></span>
<span id="cb9-20"><a href="#cb9-20" aria-hidden="true" tabindex="-1"></a> <span class="cf">fi</span></span>
<span id="cb9-21"><a href="#cb9-21" aria-hidden="true" tabindex="-1"></a> <span class="cf">fi</span></span></code></pre></div>
<p>can be used to pootify web pages. This has been added as
<a href="pootify.cgi.sh">pootify.cgi.sh</a> which forbids <code>file://</code> based URLs and which
uses <code>lynx(1)</code> with the option referred to above. This will not, of course,
@@ -213,14 +212,14 @@ added bonus that one can use <code>file://</code> URLs. If one wants a CGI scrip
should use the above one instead. You can use the script
<a href="pootify.sh">pootify.sh</a>, however, to download and generate html files that you
can look at locally in a browser or pipe through <code>less(1)</code>. For instance:</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="ex">./pootify.sh</span> URL=https://microsoft.com <span class="kw">|</span> <span class="fu">less</span></span>
<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="ex">./pootify.sh</span> URL=https://microsoft.com <span class="kw">|</span> <span class="fu">less</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./pootify.sh</span> <span class="at">-r</span> URL=https://microsoft.com <span class="op">&gt;</span> ms.html</span></code></pre></div>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./pootify.sh</span> <span class="at">-r</span> URL=https://microsoft.com <span class="op">&gt;</span> ms.html</span></code></pre></div>
<p>where the first one would show the text as rendered but without links, images
etc. and the second one would write the html to <code>ms.html</code> so that you could open
it in a browser.</p>
<p>For an old example of it working as a CGI script see:</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="ex">https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org</span></span></code></pre></div>
<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="ex">https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org</span></span></code></pre></div>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>This program is a text filter, it reads <code>stdin</code> and outputs the
“corrected” text to <code>stdout</code>.</p>
+9 -10
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
There is an alternate version available that has a key configuration that will
@@ -14,7 +14,7 @@ code](#alternate-code) below.
The current status of this entry is:
```
STATUS: missing or dead link - please provide them
STATUS: missing or dead link - please provide them
```
For more detailed information see [1998 dloweneil bugs](../../bugs.html#1998_dloweneil).
@@ -23,8 +23,7 @@ For more detailed information see [1998 dloweneil bugs](../../bugs.html#1998_dlo
## To use:
```sh
./pootris [X size of board] [Y size of board]
./pootris [X size of board] [Y size of board]
```
Pressing `a` moves the current letter position counterclockwise/anticlockwise
@@ -47,14 +46,14 @@ clockwise `l` does as well. Instead of using `d` to drop the letter you can do
### Alternate build:
```sh
make alt
make alt
```
### Alternate use:
```sh
./pootris.alt [X size of board] [Y size of board]
./pootris.alt [X size of board] [Y size of board]
```
@@ -64,9 +63,9 @@ Read the authors' remarks below to find out how to play. We believe that your
experience may mirror one of our experiences:
```
Originally, I didn't appreciate the game. Then I actually read the
description of the controls. I started playing. I struggled.
I spelled my first "poot". I was hooked ...
Originally, I didn't appreciate the game. Then I actually read the
description of the controls. I started playing. I struggled.
I spelled my first "poot". I was hooked ...
```
@@ -75,7 +74,7 @@ I spelled my first "poot". I was hooked ...
### Usage
```sh
./pootris [X size of board] [Y size of board]
./pootris [X size of board] [Y size of board]
```
### Synopsis
+10 -12
View File
@@ -135,8 +135,7 @@
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
<br><br></li>
<li>Name: <a href="../../authors.html#Neil_Mix">Neil Mix</a><br>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<br><br></li>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -145,17 +144,16 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<p>There is an alternate version available that has a key configuration that will
be more familiar to vi(m) users and also allows one to quit. See <a href="#alternate-code">alternate
code</a> below.</p>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code>STATUS: missing or dead link - please provide them</code></pre>
<pre><code> STATUS: missing or dead link - please provide them</code></pre>
<p>For more detailed information see <a href="../../bugs.html#1998_dloweneil">1998 dloweneil bugs</a>.</p>
<h2 id="to-use">To use:</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>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./pootris</span> [X size of board] [Y size of board]</span></code></pre></div>
<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">./pootris</span> [X size of board] [Y size of board]</span></code></pre></div>
<p>Pressing <code>a</code> moves the current letter position counterclockwise/anticlockwise
(a)round the border of the playing field.</p>
<p>Pressing <code>s</code> moves the current letter one position clockwise around the border
@@ -167,18 +165,18 @@ counterclockwise/anticlockwise <code>h</code> does as well; and in addition to <
clockwise <code>l</code> does as well. Instead of using <code>d</code> to drop the letter you can do
<code>j</code> or space. Finally to quit this version you can press <code>q</code>.</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>
<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>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./pootris.alt</span> [X size of board] [Y size of board]</span></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./pootris.alt</span> [X size of board] [Y size of board]</span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Read the authors’ remarks below to find out how to play. We believe that your
experience may mirror one of our experiences:</p>
<pre><code>Originally, I didn&#39;t appreciate the game. Then I actually read the
description of the controls. I started playing. I struggled.
I spelled my first &quot;poot&quot;. I was hooked ...</code></pre>
<pre><code> Originally, I didn&#39;t appreciate the game. Then I actually read the
description of the controls. I started playing. I struggled.
I spelled my first &quot;poot&quot;. I was hooked ...</code></pre>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="usage">Usage</h3>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./pootris</span> [X size of board] [Y size of board]</span></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./pootris</span> [X size of board] [Y size of board]</span></code></pre></div>
<h3 id="synopsis">Synopsis</h3>
<p>The object of this game is to spell <code>POOT</code> as much as possible. There
is no time pressure. You’re given one letter at a time (sort of randomly
+11 -11
View File
@@ -1,24 +1,24 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./dorssel
# input some text
./dorssel
# input some text
echo text | ./dorssel
echo text | ./dorssel
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -49,8 +49,8 @@ Try doing what the last part of the last command in [try.sh](try.sh) suggests.
As in, do the following:
```sh
echo ". -..- . .-. -.-. .. ... .
-.-. .... .- -. --. . - .... . .--. .-. --- --. .-. .- -- ... --- .. - -.. --- . ... -. --- - ... .... --- ..- -" | ./dorssel
echo ". -..- . .-. -.-. .. ... .
-.-. .... .- -. --. . - .... . .--. .-. --- --. .-. .- -- ... --- .. - -.. --- . ... -. --- - ... .... --- ..- -" | ./dorssel
```
and make the necessary adjustments.
@@ -92,7 +92,7 @@ invoke undefined behavior.
Try:
```sh
./dorssel < dorssel.c | ./dorssel
./dorssel < dorssel.c | ./dorssel
```
to see what variables, numbers, and functions are used. (Does a
@@ -102,20 +102,20 @@ better job than most C beautifiers).
text that can be reversibly Morsified, i.e.
```sh
./dorssel < dorssel.c | ./dorssel | ./dorssel | ./dorssel
./dorssel < dorssel.c | ./dorssel | ./dorssel | ./dorssel
```
is the same as
```sh
./dorssel < dorssel.c | ./dorssel
./dorssel < dorssel.c | ./dorssel
```
- The file [dorssel.md](dorssel.md) contains all the information needed to
understand this program. For an obfuscated spoiler, try
```sh
./dorssel < dorssel.md
./dorssel < dorssel.md
```
+57 -57
View File
@@ -125,9 +125,9 @@
<h1 id="information-about-this-entry">Information about this entry</h1>
<p>Morse codes for letters and digits use sequences of 1 to 5 (inclusive)
Morse symbols (denoted as <code>.</code> or <code>-</code>), e.g.</p>
<pre><code>E .
Z --..
3 ...--</code></pre>
<pre><code> E .
Z --..
3 ...--</code></pre>
<p>(BTW: digits always have 5 symbols, letters 1 to 4. I didn’t use this fact.)</p>
<p>Of course we can encode these symbols with bits in a byte. I chose <code>-</code>
to be a bit set to 0, <code>.</code> to be a bit set to 1. Characters in C are at
@@ -138,62 +138,62 @@ can use type <code>char</code> (using <code>unsigned char</code> for an extra bi
the source code excessively large ;-)</p>
<p>The least significant bit contains the first symbol of a Morse code, so
we have</p>
<pre><code>E &gt; 0......1
Z &gt; 0...1100
3 &gt; 0..00111</code></pre>
<pre><code> E &gt; 0......1
Z &gt; 0...1100
3 &gt; 0..00111</code></pre>
<p>The dots still have to be determined. But we also need to encode the
length of the sequence. Since there are only 4 different kind of lengths,
two bits would suffice, e.g.</p>
<pre><code>E &gt; 000....1
Z &gt; 010.1100
3 &gt; 01100111</code></pre>
<pre><code> E &gt; 000....1
Z &gt; 010.1100
3 &gt; 01100111</code></pre>
<p>That means bits 6 and 5 set to 00 is length 1, set to 01 is length 2, etc.
But this would mean that we would have to extract the length into a
counter before shifting out each symbol, such as</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>length <span class="op">=</span> <span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">96</span><span class="op">)</span> <span class="op">&gt;&gt;</span> <span class="dv">5</span><span class="op">;</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="cf">do</span> <span class="op">{</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">&#39;-&#39;</span> <span class="op">:</span> <span class="ch">&#39;.&#39;</span><span class="op">);</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">&gt;&gt;=</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="op">}</span> <span class="cf">while</span> <span class="op">(</span>length<span class="op">--);</span></span></code></pre></div>
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> length <span class="op">=</span> <span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">96</span><span class="op">)</span> <span class="op">&gt;&gt;</span> <span class="dv">5</span><span class="op">;</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">do</span> <span class="op">{</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">&#39;-&#39;</span> <span class="op">:</span> <span class="ch">&#39;.&#39;</span><span class="op">);</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">&gt;&gt;=</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span> <span class="cf">while</span> <span class="op">(</span>length<span class="op">--);</span></span></code></pre></div>
<p>We can also use the remaining bits to <em>include</em> the counter</p>
<pre><code>length 1: 00000.1x E &gt; 00000.11
length 2: 0000.1xx
length 3: 000.1xxx
length 4: 00.1xxxx Z &gt; 00.11100
length 5: 0.1xxxxx 3 &gt; 0.100111</code></pre>
<pre><code> length 1: 00000.1x E &gt; 00000.11
length 2: 0000.1xx
length 3: 000.1xxx
length 4: 00.1xxxx Z &gt; 00.11100
length 5: 0.1xxxxx 3 &gt; 0.100111</code></pre>
<p>with 1 bit still to be chosen freely (let’s assume it is 0). Now we can do</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="cf">do</span> <span class="op">{</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">&#39;-&#39;</span> <span class="op">:</span> <span class="ch">&#39;.&#39;</span><span class="op">);</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">&gt;&gt;=</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a><span class="cf">while</span> <span class="op">(</span>encoding <span class="op">&gt;</span> <span class="dv">1</span><span class="op">);</span></span></code></pre></div>
<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="cf">do</span> <span class="op">{</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">&#39;-&#39;</span> <span class="op">:</span> <span class="ch">&#39;.&#39;</span><span class="op">);</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">&gt;&gt;=</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">while</span> <span class="op">(</span>encoding <span class="op">&gt;</span> <span class="dv">1</span><span class="op">);</span></span></code></pre></div>
<p>As you see, the encoded Morse sequence can be the counter itself. But
this is not very pleasant, as some Morse sequences will end up having
an ASCII value &lt; 32, i.e. they will be control codes. This would make
the initializing (encoding) string awkward. Hence I came up with the
following</p>
<pre><code>length 1: 0010010x E &gt; 00100101 (= &#39;%&#39;)
length 2: 001010xx
length 3: 00110xxx
length 4: 0100xxxx Z &gt; 01001100 (= &#39;L&#39;)
length 5: 011xxxxx 3 &gt; 01100111 (= &#39;g&#39;)</code></pre>
<pre><code> length 1: 0010010x E &gt; 00100101 (= &#39;%&#39;)
length 2: 001010xx
length 3: 00110xxx
length 4: 0100xxxx Z &gt; 01001100 (= &#39;L&#39;)
length 5: 011xxxxx 3 &gt; 01100111 (= &#39;g&#39;)</code></pre>
<p>Notice these encodings in the initialization string. Only the coding for
<code>5</code> needs an escape (<code>5 = ..... &gt; 01111111 = '\177'</code>). The way the length
is encoded still allows the encoding to be its own counter:</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="cf">do</span> <span class="op">{</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">&#39;-&#39;</span> <span class="op">:</span> <span class="ch">&#39;.&#39;</span><span class="op">);</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">=</span> <span class="op">(</span>encoding <span class="op">+</span> <span class="dv">32</span><span class="op">)</span> <span class="op">&gt;&gt;</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a><span class="op">}</span> <span class="cf">while</span> <span class="op">(</span>encoding <span class="op">&gt;</span> <span class="dv">35</span><span class="op">);</span></span></code></pre></div>
<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="cf">do</span> <span class="op">{</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span>encoding <span class="op">&amp;</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">&#39;-&#39;</span> <span class="op">:</span> <span class="ch">&#39;.&#39;</span><span class="op">);</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">=</span> <span class="op">(</span>encoding <span class="op">+</span> <span class="dv">32</span><span class="op">)</span> <span class="op">&gt;&gt;</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span> <span class="cf">while</span> <span class="op">(</span>encoding <span class="op">&gt;</span> <span class="dv">35</span><span class="op">);</span></span></code></pre></div>
<p>The last shift will always result in <code>00100010</code>, hence the test for <code>&gt;35</code>.
Note that the calculation for the next value of <code>encoding</code> is done at <code>int</code>
precision, so that the actual value of the <code>char</code> remains <code>&lt;= 127</code>.</p>
<p>The character <code>'-'</code> (ASCII 45) and <code>'.'</code> (ASCII 46) are conveniently in
sequence, so the putchar can simply be</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>putchar<span class="op">(</span><span class="dv">45</span> <span class="op">+</span> encoding <span class="op">%</span> <span class="dv">2</span><span class="op">);</span></span></code></pre></div>
<div class="sourceCode" id="cb9"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> putchar<span class="op">(</span><span class="dv">45</span> <span class="op">+</span> encoding <span class="op">%</span> <span class="dv">2</span><span class="op">);</span></span></code></pre></div>
<p>I used the modulo operator this time, because <code>+</code> takes precedence over <code>&amp;</code>.
The assignment can be incorporated into the <code>while</code> control test, and a
<code>do-while</code> loop with a body of a single expression statement can be written
as a <code>while</code> loop with a comma operator in the test:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="cf">while</span><span class="op">(</span>putchar<span class="op">(</span><span class="dv">45</span> <span class="op">+</span> encoding <span class="op">%</span> <span class="dv">2</span><span class="op">),</span> encoding <span class="op">=</span> encoding <span class="op">+</span> <span class="dv">32</span> <span class="op">&gt;&gt;</span> <span class="dv">1</span><span class="op">);</span></span></code></pre></div>
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">while</span><span class="op">(</span>putchar<span class="op">(</span><span class="dv">45</span> <span class="op">+</span> encoding <span class="op">%</span> <span class="dv">2</span><span class="op">),</span> encoding <span class="op">=</span> encoding <span class="op">+</span> <span class="dv">32</span> <span class="op">&gt;&gt;</span> <span class="dv">1</span><span class="op">);</span></span></code></pre></div>
<p>Voila.</p>
<p>Now, the decoding of Morse codes is just the reverse. We shift in <code>0</code>s
and <code>1</code>s as we scan the line. But: we have to scan from back to front
@@ -218,22 +218,22 @@ is a valid encoding ! We must, however, use <code>memchr(3)</code> instead of <c
the decoding lookup because of this <code>'\0'</code>. Since it is far more obscure
this way, I hope you’ll forgive me.</p>
<p>The outline of the program is roughly as follows</p>
<pre><code>while (more lines) {
if (line is in morse) {
while (more characters) {
skip next sequence
if (&#39; &#39;)
putchar(&#39; &#39;);
else
decode_sequence; /* backwards */
}
} else {
while (more characters) {
if (isalnum)
encode_character;
putchar(&#39; &#39;);
}
}</code></pre>
<pre><code> while (more lines) {
if (line is in morse) {
while (more characters) {
skip next sequence
if (&#39; &#39;)
putchar(&#39; &#39;);
else
decode_sequence; /* backwards */
}
} else {
while (more characters) {
if (isalnum)
encode_character;
putchar(&#39; &#39;);
}
}</code></pre>
<p>Because of the <em>two</em> <code>while(more characters)</code> loops are the same, I’ve
exchanged the <code>if(line is in morse)</code> and the two <code>while</code> loops (so there
is <em>single</em> <code>while</code> loop). However, we must now store the <code>if(line is in morse)</code> test for efficiency (it would be stupid to test the entire line
@@ -246,13 +246,13 @@ as the temporary <code>l[0]</code> will remain <code>!= 0</code>.</p>
<p>I’ve put the <code>if</code>s in the above layout into a single switch. Hope you don’t
mind ;-)</p>
<p>Summary of the use of l[999]:</p>
<pre><code>l[0] result of &quot;is this line in morse&quot; test
l[0] temporary shift during encoding
l[0] - l[33] Morse codings (letters and digits, plus garbage)
l[11] - l[14] strspn argument
l[12] - l[14] strspn argument
l[34] terminator for backward decoding
l[35] - l[998] input line</code></pre>
<pre><code> l[0] result of &quot;is this line in morse&quot; test
l[0] temporary shift during encoding
l[0] - l[33] Morse codings (letters and digits, plus garbage)
l[11] - l[14] strspn argument
l[12] - l[14] strspn argument
l[34] terminator for backward decoding
l[35] - l[998] input line</code></pre>
<hr />
<p>Selected notes:
- We don’t need to declare <code>isalnum(3)</code> (or include ctype.h) as its implicit
+57 -57
View File
@@ -4,9 +4,9 @@ Morse codes for letters and digits use sequences of 1 to 5 (inclusive)
Morse symbols (denoted as `.` or `-`), e.g.
```
E .
Z --..
3 ...--
E .
Z --..
3 ...--
```
(BTW: digits always have 5 symbols, letters 1 to 4. I didn't use this fact.)
@@ -23,9 +23,9 @@ The least significant bit contains the first symbol of a Morse code, so
we have
```
E > 0......1
Z > 0...1100
3 > 0..00111
E > 0......1
Z > 0...1100
3 > 0..00111
```
The dots still have to be determined. But we also need to encode the
@@ -33,9 +33,9 @@ length of the sequence. Since there are only 4 different kind of lengths,
two bits would suffice, e.g.
```
E > 000....1
Z > 010.1100
3 > 01100111
E > 000....1
Z > 010.1100
3 > 01100111
```
That means bits 6 and 5 set to 00 is length 1, set to 01 is length 2, etc.
@@ -43,30 +43,30 @@ But this would mean that we would have to extract the length into a
counter before shifting out each symbol, such as
```c
length = (encoding & 96) >> 5;
do {
putchar(encoding & 1 ? '-' : '.');
encoding >>= 1;
} while (length--);
length = (encoding & 96) >> 5;
do {
putchar(encoding & 1 ? '-' : '.');
encoding >>= 1;
} while (length--);
```
We can also use the remaining bits to *include* the counter
```
length 1: 00000.1x E > 00000.11
length 2: 0000.1xx
length 3: 000.1xxx
length 4: 00.1xxxx Z > 00.11100
length 5: 0.1xxxxx 3 > 0.100111
length 1: 00000.1x E > 00000.11
length 2: 0000.1xx
length 3: 000.1xxx
length 4: 00.1xxxx Z > 00.11100
length 5: 0.1xxxxx 3 > 0.100111
```
with 1 bit still to be chosen freely (let's assume it is 0). Now we can do
```c
do {
putchar(encoding & 1 ? '-' : '.');
encoding >>= 1;
while (encoding > 1);
do {
putchar(encoding & 1 ? '-' : '.');
encoding >>= 1;
while (encoding > 1);
```
As you see, the encoded Morse sequence can be the counter itself. But
@@ -76,11 +76,11 @@ the initializing (encoding) string awkward. Hence I came up with the
following
```
length 1: 0010010x E > 00100101 (= '%')
length 2: 001010xx
length 3: 00110xxx
length 4: 0100xxxx Z > 01001100 (= 'L')
length 5: 011xxxxx 3 > 01100111 (= 'g')
length 1: 0010010x E > 00100101 (= '%')
length 2: 001010xx
length 3: 00110xxx
length 4: 0100xxxx Z > 01001100 (= 'L')
length 5: 011xxxxx 3 > 01100111 (= 'g')
```
Notice these encodings in the initialization string. Only the coding for
@@ -88,10 +88,10 @@ Notice these encodings in the initialization string. Only the coding for
is encoded still allows the encoding to be its own counter:
```c
do {
putchar(encoding & 1 ? '-' : '.');
encoding = (encoding + 32) >> 1;
} while (encoding > 35);
do {
putchar(encoding & 1 ? '-' : '.');
encoding = (encoding + 32) >> 1;
} while (encoding > 35);
```
The last shift will always result in `00100010`, hence the test for `>35`.
@@ -102,7 +102,7 @@ The character `'-'` (ASCII 45) and `'.'` (ASCII 46) are conveniently in
sequence, so the putchar can simply be
```c
putchar(45 + encoding % 2);
putchar(45 + encoding % 2);
```
I used the modulo operator this time, because `+` takes precedence over `&`.
@@ -111,7 +111,7 @@ The assignment can be incorporated into the `while` control test, and a
as a `while` loop with a comma operator in the test:
```c
while(putchar(45 + encoding % 2), encoding = encoding + 32 >> 1);
while(putchar(45 + encoding % 2), encoding = encoding + 32 >> 1);
```
Voila.
@@ -144,22 +144,22 @@ this way, I hope you'll forgive me.
The outline of the program is roughly as follows
```
while (more lines) {
if (line is in morse) {
while (more characters) {
skip next sequence
if (' ')
putchar(' ');
else
decode_sequence; /* backwards */
}
} else {
while (more characters) {
if (isalnum)
encode_character;
putchar(' ');
}
}
while (more lines) {
if (line is in morse) {
while (more characters) {
skip next sequence
if (' ')
putchar(' ');
else
decode_sequence; /* backwards */
}
} else {
while (more characters) {
if (isalnum)
encode_character;
putchar(' ');
}
}
```
Because of the *two* `while(more characters)` loops are the same, I've
@@ -179,13 +179,13 @@ mind ;-)
Summary of the use of l[999]:
```
l[0] result of "is this line in morse" test
l[0] temporary shift during encoding
l[0] - l[33] Morse codings (letters and digits, plus garbage)
l[11] - l[14] strspn argument
l[12] - l[14] strspn argument
l[34] terminator for backward decoding
l[35] - l[998] input line
l[0] result of "is this line in morse" test
l[0] temporary shift during encoding
l[0] - l[33] Morse codings (letters and digits, plus garbage)
l[11] - l[14] strspn argument
l[12] - l[14] strspn argument
l[34] terminator for backward decoding
l[35] - l[998] input line
```
---
+12 -13
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Frans_van_Dorsselaer">Frans van Dorsselaer</a><br>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<br><br></li>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,14 +141,14 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<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">./dorssel</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co"># input some text</span></span>
<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">./dorssel</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># input some text</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> text <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> text <span class="kw">|</span> <span class="ex">./dorssel</span></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>
<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="judges-remarks">Judges’ remarks:</h2>
<p>How does the program decide which way to convert?</p>
<p>What obsolescent feature are we talking about? (No, it’s not a
@@ -167,8 +166,8 @@ altering the behavior ?</p></li>
<h3 id="extra-credit">Extra credit:</h3>
<p>Try doing what the last part of the last command in <a href="try.sh">try.sh</a> suggests.
As in, do the following:</p>
<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="bu">echo</span> <span class="st">&quot;. -..- . .-. -.-. .. ... .</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="st">-.-. .... .- -. --. . - .... . .--. .-. --- --. .-. .- -- ... --- .. - -.. --- . ... -. --- - ... .... --- ..- -&quot;</span> <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<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="bu">echo</span> <span class="st">&quot;. -..- . .-. -.-. .. ... .</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="st"> -.-. .... .- -. --. . - .... . .--. .-. --- --. .-. .- -- ... --- .. - -.. --- . ... -. --- - ... .... --- ..- -&quot;</span> <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<p>and make the necessary adjustments.</p>
<p>You might also want to read the <a href="dorssel.html">dorssel.html</a> file.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
@@ -196,21 +195,21 @@ ASCII. As far as I can tell, the program is conforming and does not
invoke undefined behavior.</p>
<h3 id="hints">Hints</h3>
<p>Try:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<p>to see what variables, numbers, and functions are used. (Does a
better job than most C beautifiers).</p>
<ul>
<li>Filter your text twice (as in the previous sample) to obtain a version of your
text that can be reversibly Morsified, i.e.</li>
</ul>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span> <span class="kw">|</span> <span class="ex">./dorssel</span> <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span> <span class="kw">|</span> <span class="ex">./dorssel</span> <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<p>is the same as</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
<ul>
<li>The file <a href="dorssel.md">dorssel.md</a> contains all the information needed to
understand this program. For an obfuscated spoiler, try</li>
</ul>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.md</span></code></pre></div>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dorssel</span> <span class="op">&lt;</span> dorssel.md</span></code></pre></div>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
+48 -48
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
NOTE: this may take a while. Some systems may have problems building
@@ -11,7 +11,7 @@ this entry because of the system resources it requires.
## To use:
```sh
./fanf
./fanf
```
@@ -20,7 +20,7 @@ this entry because of the system resources it requires.
Enter an expression on standard input. To try some we have selected:
```sh
./try.sh
./try.sh
```
@@ -48,7 +48,7 @@ can you begin to understand what it is doing?
Look at the first stage of the C pre-processing which was done like:
```sh
cc fanf.c -E > fanftmp1.c
cc fanf.c -E > fanftmp1.c
```
Skip to the bottom of `fanftmp1.c` (after all of the C pre-processor header
@@ -122,9 +122,9 @@ expressions works as follows. There are three forms of lambda expression
to consider: variables, applications, and abstractions.
```
trans v -> v (variable)
trans a b -> (trans a) (trans b ) (application)
trans \ab -> abs a (trans b) (abstraction)
trans v -> v (variable)
trans a b -> (trans a) (trans b ) (application)
trans \ab -> abs a (trans b) (abstraction)
```
There are a further three cases to consider for the body of lambda
@@ -132,33 +132,33 @@ expressions, where we need to do the magic that transforms away the
variables.
```
abs a f x -> S (abs a f) (abs a x)
abs a b -> K b (b != a)
abs a a -> I
abs a f x -> S (abs a f) (abs a x)
abs a b -> K b (b != a)
abs a a -> I
```
E.g. suppose we had combinator expressions for `+` and `3` and we wanted
to see what the combinator expression for doubling 3 looked like:
```
trans \x(+ x x) 3
-> (trans \x(+ x x)) (trans 3)
-> (abs x (trans + x x)) 3
-> (abs x + x x) 3
-> S (abs x + x) (abs x x) 3
-> S (S (abs x +) (abs x x)) I 3
-> S (S (K +) I) I 3
-> S (S (K +) I) I 3
trans \x(+ x x) 3
-> (trans \x(+ x x)) (trans 3)
-> (abs x (trans + x x)) 3
-> (abs x + x x) 3
-> S (abs x + x) (abs x x) 3
-> S (S (abs x +) (abs x x)) I 3
-> S (S (K +) I) I 3
-> S (S (K +) I) I 3
```
We can then check that this evaluates to the expected result:
```
S (S (K +) I) I 3
-> S (K +) I 3 (I 3)
-> K + 3 (I 3) (I 3)
-> + (I 3) (I 3)
-> + 3 3
S (S (K +) I) I 3
-> S (K +) I 3 (I 3)
-> K + 3 (I 3) (I 3)
-> + (I 3) (I 3)
-> + 3 3
```
It is possible to perform a slightly more compact translation with a
@@ -166,24 +166,24 @@ couple of simple optimisations. For example, note that `K (a b)` is the
same as `S (K a) (K b)`, because
```
K (a b) x
-> a b
K (a b) x
-> a b
```
and
```
S (K a) (K b) x
-> K a x (K b x)
-> a b
S (K a) (K b) x
-> K a x (K b x)
-> a b
```
Also, `S (K a) I` is the same as just `a` because
```
S (K a) I x
-> K a x (I x)
-> a x
S (K a) I x
-> K a x (I x)
-> a x
```
The program simply reads a lambda expression from the standard input,
@@ -245,7 +245,7 @@ writes that character on `stdout`, and finally it calls its second
argument as a function with the argument `I`, i.e.
```
P x f -> f I
P x f -> f I
```
with a side-effect.
@@ -255,7 +255,7 @@ argument as a function with the appropriate `E` combinator as an
argument, i.e.
```
G f -> f E(c)
G f -> f E(c)
```
with a side-effect.
@@ -274,7 +274,7 @@ The `Y` combinator is used for implementing recursive functions. It has
the evaluation rule
```
Y f -> f (Y f)
Y f -> f (Y f)
```
so that it can be used to call a function with itself as an argument.
@@ -282,7 +282,7 @@ For example, if I had the appropriate arithmetic operators defined, I
could write a factorial function in the lambda calculus like this:
```
Y \f\n((= n 0) 1 (* n (f (- n 1))))
Y \f\n((= n 0) 1 (* n (f (- n 1))))
```
`OFL` provides a facility for naming expressions so that they can be used
@@ -302,11 +302,11 @@ when translating an expression from the lambda calculus to combinators,
and therefore more compact programs. Their evaluation rules are:
```
B f g x -> f (g x)
C f g x -> (f x) g
BB c f g x -> c (f (g x))
CC c f g x -> c (f x) g
SS c f g x -> c (f x) (g x)
B f g x -> f (g x)
C f g x -> (f x) g
BB c f g x -> c (f (g x))
CC c f g x -> c (f x) g
SS c f g x -> c (f x) (g x)
```
I used them to help fit my program into the required space; unfortunately
@@ -315,14 +315,14 @@ it reads into the required space. The complete optimisation rules
including the ones it doesn't use are:
```
S (K p) I -> p
S (K p) (K r) -> K ( p r )
S (K p) (B r s) -> BB p r s
S (K p) r -> B p r
S (B p q) (K r) -> CC p q r
S p (K r) -> C p r
S (B p q) r -> SS p q r
S p r -> S p r
S (K p) I -> p
S (K p) (K r) -> K ( p r )
S (K p) (B r s) -> BB p r s
S (K p) r -> B p r
S (B p q) (K r) -> CC p q r
S p (K r) -> C p r
S (B p q) r -> SS p q r
S p r -> S p r
```
### The implementation of `OFL`
+49 -50
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Tony_Finch">Tony Finch</a><br>
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)
<br><br></li>
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,14 +141,14 @@ Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<p>NOTE: this may take a while. Some systems may have problems building
this entry because of the system resources it requires.</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">./fanf</span></span></code></pre></div>
<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">./fanf</span></span></code></pre></div>
<h2 id="try">Try:</h2>
<p>Enter an expression on standard input. To try some we have selected:</p>
<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>
<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="judges-remarks">Judges’ remarks:</h2>
<h3 id="historical-aside">Historical aside:</h3>
<p>At a time the code in <a href="fanf.c">fanf.c</a> was that of <a href="fanf.orig.c">fanf.orig.c</a>
@@ -166,7 +165,7 @@ source.</p>
<code>fanftmp2.c</code> C program. Take a look at that final C program again,
can you begin to understand what it is doing?</p>
<p>Look at the first stage of the C pre-processing which was done like:</p>
<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">cc</span> fanf.c <span class="at">-E</span> <span class="op">&gt;</span> fanftmp1.c</span></code></pre></div>
<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">cc</span> fanf.c <span class="at">-E</span> <span class="op">&gt;</span> fanftmp1.c</span></code></pre></div>
<p>Skip to the bottom of <code>fanftmp1.c</code> (after all of the C pre-processor header
stuff … look for a line of the form: <code># 38 "fanf.c"</code> near the bottom)
and look at the resulting code. This code, when C pre-processed
@@ -218,44 +217,44 @@ since it is equivalent to <code>S K K</code>:</p>
<p>The algorithm for translating lambda expressions into combinator
expressions works as follows. There are three forms of lambda expression
to consider: variables, applications, and abstractions.</p>
<pre><code>trans v -&gt; v (variable)
trans a b -&gt; (trans a) (trans b ) (application)
trans \ab -&gt; abs a (trans b) (abstraction)</code></pre>
<pre><code> trans v -&gt; v (variable)
trans a b -&gt; (trans a) (trans b ) (application)
trans \ab -&gt; abs a (trans b) (abstraction)</code></pre>
<p>There are a further three cases to consider for the body of lambda
expressions, where we need to do the magic that transforms away the
variables.</p>
<pre><code>abs a f x -&gt; S (abs a f) (abs a x)
abs a b -&gt; K b (b != a)
abs a a -&gt; I</code></pre>
<pre><code> abs a f x -&gt; S (abs a f) (abs a x)
abs a b -&gt; K b (b != a)
abs a a -&gt; I</code></pre>
<p>E.g. suppose we had combinator expressions for <code>+</code> and <code>3</code> and we wanted
to see what the combinator expression for doubling 3 looked like:</p>
<pre><code> trans \x(+ x x) 3
-&gt; (trans \x(+ x x)) (trans 3)
-&gt; (abs x (trans + x x)) 3
-&gt; (abs x + x x) 3
-&gt; S (abs x + x) (abs x x) 3
-&gt; S (S (abs x +) (abs x x)) I 3
-&gt; S (S (K +) I) I 3
-&gt; S (S (K +) I) I 3</code></pre>
<pre><code> trans \x(+ x x) 3
-&gt; (trans \x(+ x x)) (trans 3)
-&gt; (abs x (trans + x x)) 3
-&gt; (abs x + x x) 3
-&gt; S (abs x + x) (abs x x) 3
-&gt; S (S (abs x +) (abs x x)) I 3
-&gt; S (S (K +) I) I 3
-&gt; S (S (K +) I) I 3</code></pre>
<p>We can then check that this evaluates to the expected result:</p>
<pre><code> S (S (K +) I) I 3
-&gt; S (K +) I 3 (I 3)
-&gt; K + 3 (I 3) (I 3)
-&gt; + (I 3) (I 3)
-&gt; + 3 3</code></pre>
<pre><code> S (S (K +) I) I 3
-&gt; S (K +) I 3 (I 3)
-&gt; K + 3 (I 3) (I 3)
-&gt; + (I 3) (I 3)
-&gt; + 3 3</code></pre>
<p>It is possible to perform a slightly more compact translation with a
couple of simple optimisations. For example, note that <code>K (a b)</code> is the
same as <code>S (K a) (K b)</code>, because</p>
<pre><code> K (a b) x
-&gt; a b</code></pre>
<pre><code> K (a b) x
-&gt; a b</code></pre>
<p>and</p>
<pre><code> S (K a) (K b) x
-&gt; K a x (K b x)
-&gt; a b</code></pre>
<pre><code> S (K a) (K b) x
-&gt; K a x (K b x)
-&gt; a b</code></pre>
<p>Also, <code>S (K a) I</code> is the same as just <code>a</code> because</p>
<pre><code> S (K a) I x
-&gt; K a x (I x)
-&gt; a x</code></pre>
<pre><code> S (K a) I x
-&gt; K a x (I x)
-&gt; a x</code></pre>
<p>The program simply reads a lambda expression from the standard input,
translates it into a combinator expression using the transformation and
optimisations described above, and prints out the result.</p>
@@ -305,12 +304,12 @@ obfuscated form <code>E('a') char then else</code>.</p>
its first argument and checking that it is some form of <code>E</code>. It then
writes that character on <code>stdout</code>, and finally it calls its second
argument as a function with the argument <code>I</code>, i.e.</p>
<pre><code>P x f -&gt; f I</code></pre>
<pre><code> P x f -&gt; f I</code></pre>
<p>with a side-effect.</p>
<p>The <code>G</code> combinator just reads a character from <code>stdin</code> then calls its
argument as a function with the appropriate <code>E</code> combinator as an
argument, i.e.</p>
<pre><code>G f -&gt; f E(c)</code></pre>
<pre><code> G f -&gt; f E(c)</code></pre>
<p>with a side-effect.</p>
<p>One of the problems with non-strict languages is that it is hard to
predict in advance in which order side-effects will occur. In my program
@@ -323,11 +322,11 @@ CPS form of the I/O monad from page 6 of “Imperative Functional
Programming”.)</p>
<p>The <code>Y</code> combinator is used for implementing recursive functions. It has
the evaluation rule</p>
<pre><code>Y f -&gt; f (Y f)</code></pre>
<pre><code> Y f -&gt; f (Y f)</code></pre>
<p>so that it can be used to call a function with itself as an argument.
For example, if I had the appropriate arithmetic operators defined, I
could write a factorial function in the lambda calculus like this:</p>
<pre><code>Y \f\n((= n 0) 1 (* n (f (- n 1))))</code></pre>
<pre><code> Y \f\n((= n 0) 1 (* n (f (- n 1))))</code></pre>
<p><code>OFL</code> provides a facility for naming expressions so that they can be used
more than once without writing them in full. A definition must be written
on one line in the form <code>l name b expression</code> where <code>l</code> is short for
@@ -342,23 +341,23 @@ expression must be surrounded by brackets.</p>
basic eight. These combinators provide greater scope for optimisation
when translating an expression from the lambda calculus to combinators,
and therefore more compact programs. Their evaluation rules are:</p>
<pre><code>B f g x -&gt; f (g x)
C f g x -&gt; (f x) g
BB c f g x -&gt; c (f (g x))
CC c f g x -&gt; c (f x) g
SS c f g x -&gt; c (f x) (g x)</code></pre>
<pre><code> B f g x -&gt; f (g x)
C f g x -&gt; (f x) g
BB c f g x -&gt; c (f (g x))
CC c f g x -&gt; c (f x) g
SS c f g x -&gt; c (f x) (g x)</code></pre>
<p>I used them to help fit my program into the required space; unfortunately
I couldn’t fit the version that fully optimises the lambda expressions
it reads into the required space. The complete optimisation rules
including the ones it doesn’t use are:</p>
<pre><code>S (K p) I -&gt; p
S (K p) (K r) -&gt; K ( p r )
S (K p) (B r s) -&gt; BB p r s
S (K p) r -&gt; B p r
S (B p q) (K r) -&gt; CC p q r
S p (K r) -&gt; C p r
S (B p q) r -&gt; SS p q r
S p r -&gt; S p r</code></pre>
<pre><code> S (K p) I -&gt; p
S (K p) (K r) -&gt; K ( p r )
S (K p) (B r s) -&gt; BB p r s
S (K p) r -&gt; B p r
S (B p q) (K r) -&gt; CC p q r
S p (K r) -&gt; C p r
S (B p q) r -&gt; SS p q r
S p r -&gt; S p r</code></pre>
<h3 id="the-implementation-of-ofl">The implementation of <code>OFL</code></h3>
<p>Although <code>OFL</code> has completely different syntax and semantics to C, all you
need to compile <code>OFL</code> programs is a C compiler and a header file (which in
+1 -1
View File
@@ -207,7 +207,7 @@ skipped over 1997.</p>
<p>Please send us comments and suggestions what we have expressed above.
Also include anything else that you would like to see in future contests.
Send such email to:</p>
<pre><code>questions@ioccc.org</code></pre>
<pre><code> questions@ioccc.org</code></pre>
<p><strong>IMPORTANT NOTE</strong>: The email addresses found above are for historical
purposes only, and should not be used today. See
<a href="../contact.html">contact.html</a> for up to date contact details
+14 -14
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
@@ -10,7 +10,7 @@ make all
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [1998 schnitzi bugs](../../bugs.html#1998_schnitzi).
@@ -19,12 +19,12 @@ For more detailed information see [1998 schnitzi bugs](../../bugs.html#1998_schn
## To use:
```sh
./schnitzi n > sort.c
make sort
./sort
# enter three numbers, space separated
./schnitzi n > sort.c
make sort
./sort
# enter three numbers, space separated
echo x y z | ./sort
echo x y z | ./sort
```
where `n` and `x`, `y` and `z` are numbers.
@@ -33,18 +33,18 @@ where `n` and `x`, `y` and `z` are numbers.
## Try:
```sh
./try.sh
./try.sh
```
What happens if at the command line you don't specify `n` numbers that the
program expects? For instance try:
```sh
./schnitzi 5 > sort.c
make sort
./schnitzi 5 > sort.c
make sort
# try running the next command four or five times:
echo 2 5 3 1 | ./sort
# try running the next command four or five times:
echo 2 5 3 1 | ./sort
```
Why does this happen?
@@ -100,7 +100,7 @@ So what does it do? Give it an integer `(1 < n < 27)` on the command
line, such as
```sh
./schnitzi 5
./schnitzi 5
```
The output will itself be a lipographic program, one which expects input of
@@ -110,7 +110,7 @@ looping. To see the resulting program run, redirect the output from
`schnitzi` into another file, like this
```sh
./schnitzi 4 > sort.c
./schnitzi 4 > sort.c
```
and then compile it.
+15 -16
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Mark_Schnitzius">Mark Schnitzius</a><br>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<br><br></li>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,28 +141,28 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#1998_schnitzi">1998 schnitzi bugs</a>.</p>
<h2 id="to-use">To use:</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">./schnitzi</span> n <span class="op">&gt;</span> sort.c</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> sort</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./sort</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="co"># enter three numbers, space separated</span></span>
<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">./schnitzi</span> n <span class="op">&gt;</span> sort.c</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> sort</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./sort</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="co"># enter three numbers, space separated</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> x y z <span class="kw">|</span> <span class="ex">./sort</span></span></code></pre></div>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> x y z <span class="kw">|</span> <span class="ex">./sort</span></span></code></pre></div>
<p>where <code>n</code> and <code>x</code>, <code>y</code> and <code>z</code> are numbers.</p>
<h2 id="try">Try:</h2>
<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="ex">./try.sh</span></span></code></pre></div>
<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="ex">./try.sh</span></span></code></pre></div>
<p>What happens if at the command line you don’t specify <code>n</code> numbers that the
program expects? For instance try:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./schnitzi</span> 5 <span class="op">&gt;</span> sort.c</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> sort</span>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./schnitzi</span> 5 <span class="op">&gt;</span> sort.c</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> sort</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="co"># try running the next command four or five times:</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> 2 5 3 1 <span class="kw">|</span> <span class="ex">./sort</span></span></code></pre></div>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="co"># try running the next command four or five times:</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> 2 5 3 1 <span class="kw">|</span> <span class="ex">./sort</span></span></code></pre></div>
<p>Why does this happen?</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>This is a beautiful program. How can a program with no conditional (except for
@@ -202,13 +201,13 @@ memory capacity, since the function call stack never goes beyond
a depth of one.</p>
<p>So what does it do? Give it an integer <code>(1 &lt; n &lt; 27)</code> on the command
line, such as</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./schnitzi</span> 5</span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./schnitzi</span> 5</span></code></pre></div>
<p>The output will itself be a lipographic program, one which expects input of
(in this case) five numbers and prints them out sorted. It sorts
them, however, using only <code>if/else</code> statements, without arrays or
looping. To see the resulting program run, redirect the output from
<code>schnitzi</code> into another file, like this</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./schnitzi</span> 4 <span class="op">&gt;</span> sort.c</span></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./schnitzi</span> 4 <span class="op">&gt;</span> sort.c</span></code></pre></div>
<p>and then compile it.</p>
<h3 id="spoilers-and-hints">Spoilers And Hints:</h3>
<p>The big key to this program is figuring out what the names of the
+46 -47
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
There is an alternate version of this entry that will work with macOS. See the
@@ -13,7 +13,7 @@ includes some interesting details about the entry.
## To use:
```sh
./schweikh1
./schweikh1
```
@@ -31,7 +31,7 @@ if you don't have a Mac as it has some interesting details about the entry.
### Alternate build:
```sh
make alt
make alt
```
@@ -88,15 +88,15 @@ the most likely result is no output and/or an exit status of 1.
If Amendment One headers are missing you will see something like:
```
<iso646.h>:
gcc: /usr/include/iso646.h: No such file or directory
gcc: No input files specified
<wctype.h>:
gcc: /usr/include/wctype.h: No such file or directory
gcc: No input files specified
<wchar.h>:
gcc: /usr/include/wchar.h: No such file or directory
gcc: No input files specified
<iso646.h>:
gcc: /usr/include/iso646.h: No such file or directory
gcc: No input files specified
<wctype.h>:
gcc: /usr/include/wctype.h: No such file or directory
gcc: No input files specified
<wchar.h>:
gcc: /usr/include/wchar.h: No such file or directory
gcc: No input files specified
```
Bug your vendor for an upgrade.
@@ -127,17 +127,17 @@ programs that may fail to compile due to syntax errors: supposing that
`<stdio.h>` defines `PIPE_BUF`, then the conforming
```c
#include <assert.h>
#include <stdio.h> /* <- or where the bogus macro is defined */
#include <string.h>
#define STR(x) #x
#define XSTR(x) STR(x)
int main (void)
{
int PIPE_BUF = 0;
assert (strcmp ("PIPE_BUF", XSTR (PIPE_BUF)) == 0);
return 0;
}
#include <assert.h>
#include <stdio.h> /* <- or where the bogus macro is defined */
#include <string.h>
#define STR(x) #x
#define XSTR(x) STR(x)
int main (void)
{
int PIPE_BUF = 0;
assert (strcmp ("PIPE_BUF", XSTR (PIPE_BUF)) == 0);
return 0;
}
```
is expected to compile and meet the assertion. If it does not, your
@@ -155,18 +155,18 @@ C compilers.
must resemble one of the canonical forms, `"foo.h"` or `<bar.h>`.
This lets us write things like
```c
#define HEADER "foo.h"
#include HEADER
```
```c
#define HEADER "foo.h"
#include HEADER
```
I could not find a compiler rejecting this. However, if we're
torturing the preprocessor a little more, by using token pasting,
at least one compiler falls over.
```c
#define H(x) <st##x##.h>
#include H(dio) /* expands to <stdio.h> */
#define H(x) <st##x##.h>
#include H(dio) /* expands to <stdio.h> */
```
is rejected by tcc version 4.1.2, the TenDRA compiler:
@@ -188,19 +188,19 @@ C compilers.
which may include octal escape sequences. Let's look at
```c
#include <stdio.h>
#line 42 "foo\0bar"
int main (void) {
printf ("%s %d\n", __FILE__, (int)sizeof __FILE__);
return 0;
}
#include <stdio.h>
#line 42 "foo\0bar"
int main (void) {
printf ("%s %d\n", __FILE__, (int)sizeof __FILE__);
return 0;
}
```
This is supposed to output `'foo 8'`. Here's what happens in RL:
```
foo 4 gcc 2.7.2.1, lcc
foo\0bar 9 tcc 4.1.2, Sunsoft cc turn "\0" into "\\0", ugh!
foo 4 gcc 2.7.2.1, lcc
foo\0bar 9 tcc 4.1.2, Sunsoft cc turn "\0" into "\\0", ugh!
```
(I have written a bug report for gcc. Newer versions and egcs are ok.)
@@ -215,8 +215,8 @@ foo\0bar 9 tcc 4.1.2, Sunsoft cc turn "\0" into "\\0", ugh!
no chance to use Standardese weasel words as an escape: can I have
```c
case <some_token>:
case <some_token>:
case <some_token>:
case <some_token>:
```
in the same switch? (Note that you need the [invisible] newline. You
@@ -256,19 +256,18 @@ The advantages of an independent clean room approach...
```perl
#!/usr/bin/perl -w
$/ = "\0";
$_ = <>;
s/[;{}][ \t\n]/\n/g;
s/[ \t\n]+//g;
print length ($_),"\n";
#!/usr/bin/perl -w
$/ = "\0";
$_ = <>;
s/[;{}][ \t\n]/\n/g;
s/[ \t\n]+//g;
print length ($_),"\n";
```
To use, try:
```sh
perl ./charcount.pl schweikh1.c
perl ./charcount.pl schweikh1.c
```
+45 -46
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Jens_Schweikhardt">Jens Schweikhardt</a><br>
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)
<br><br></li>
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,13 +141,13 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<p>There is an alternate version of this entry that will work with macOS. See the
<a href="#alternate-code">Alternate code</a> section below. We recommend you look at it
even if you don’t have a Mac, unless you want to figure it out yourself, as it
includes some interesting details about the entry.</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">./schweikh1</span></span></code></pre></div>
<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">./schweikh1</span></span></code></pre></div>
<h2 id="alternate-code">Alternate code:</h2>
<p>As noted above this entry will not work as it stands for macOS and there are
some important notes as well as a description of how the fixed version works
@@ -158,7 +157,7 @@ adjustments). For details of what had to change, see <a href="macos.html">macos.
Unless you wish to figure it out yourself, we recommend that you read this even
if you don’t have a Mac as it has some interesting details about the entry.</p>
<h3 id="alternate-build">Alternate build:</h3>
<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="fu">make</span> alt</span></code></pre></div>
<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="fu">make</span> alt</span></code></pre></div>
<h3 id="alternate-build-1">Alternate build:</h3>
<p>Use <code>schweikh1.alt</code> as you would <code>schweikh1</code> above.</p>
<h3 id="alternate-try">Alternate try:</h3>
@@ -193,15 +192,15 @@ When run, it is likely to uncover bugs in your system headers.</p>
<p>The program is run without arguments. If your compiler is buggy,
the most likely result is no output and/or an exit status of 1.</p>
<p>If Amendment One headers are missing you will see something like:</p>
<pre><code>&lt;iso646.h&gt;:
gcc: /usr/include/iso646.h: No such file or directory
gcc: No input files specified
&lt;wctype.h&gt;:
gcc: /usr/include/wctype.h: No such file or directory
gcc: No input files specified
&lt;wchar.h&gt;:
gcc: /usr/include/wchar.h: No such file or directory
gcc: No input files specified</code></pre>
<pre><code> &lt;iso646.h&gt;:
gcc: /usr/include/iso646.h: No such file or directory
gcc: No input files specified
&lt;wctype.h&gt;:
gcc: /usr/include/wctype.h: No such file or directory
gcc: No input files specified
&lt;wchar.h&gt;:
gcc: /usr/include/wchar.h: No such file or directory
gcc: No input files specified</code></pre>
<p>Bug your vendor for an upgrade.</p>
<p>The format of the info file is straightforward and described in the file
itself. Just load it in your favorite editor.</p>
@@ -221,17 +220,17 @@ macros are explicitly enumerated. In a compliant implementation no other
macros can be defined, because you could write strictly conforming
programs that may fail to compile due to syntax errors: supposing that
<code>&lt;stdio.h&gt;</code> defines <code>PIPE_BUF</code>, then the conforming</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><span class="pp">#include </span><span class="im">&lt;assert.h&gt;</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="pp">#include </span><span class="im">&lt;stdio.h&gt;</span><span class="pp"> </span><span class="co">/* &lt;- or where the bogus macro is defined */</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="pp">#include </span><span class="im">&lt;string.h&gt;</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="pp">#define STR</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span><span class="pp"> </span><span class="op">#</span><span class="pp">x</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="pp">#define XSTR</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span><span class="pp"> STR</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a><span class="dt">int</span> main <span class="op">(</span><span class="dt">void</span><span class="op">)</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> PIPE_BUF <span class="op">=</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a> assert <span class="op">(</span>strcmp <span class="op">(</span><span class="st">&quot;PIPE_BUF&quot;</span><span class="op">,</span> XSTR <span class="op">(</span>PIPE_BUF<span class="op">))</span> <span class="op">==</span> <span class="dv">0</span><span class="op">);</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<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> <span class="pp">#include </span><span class="im">&lt;assert.h&gt;</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im">&lt;stdio.h&gt;</span><span class="pp"> </span><span class="co">/* &lt;- or where the bogus macro is defined */</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im">&lt;string.h&gt;</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define STR</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span><span class="pp"> </span><span class="op">#</span><span class="pp">x</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define XSTR</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span><span class="pp"> STR</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> main <span class="op">(</span><span class="dt">void</span><span class="op">)</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> PIPE_BUF <span class="op">=</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a> assert <span class="op">(</span>strcmp <span class="op">(</span><span class="st">&quot;PIPE_BUF&quot;</span><span class="op">,</span> XSTR <span class="op">(</span>PIPE_BUF<span class="op">))</span> <span class="op">==</span> <span class="dv">0</span><span class="op">);</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
<p>is expected to compile and meet the assertion. If it does not, your
compiler compiles some other language than ISO C.</p>
<h3 id="why-i-think-my-program-is-obfuscated">Why I think my program is obfuscated</h3>
@@ -244,13 +243,13 @@ C compilers.</p>
must resemble one of the canonical forms, <code>"foo.h"</code> or <code>&lt;bar.h&gt;</code>.
This lets us write things like</li>
</ol>
<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="pp">#define HEADER </span><span class="st">&quot;foo.h&quot;</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="pp">#include HEADER</span></span></code></pre></div>
<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="pp">#define HEADER </span><span class="st">&quot;foo.h&quot;</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include HEADER</span></span></code></pre></div>
<p>I could not find a compiler rejecting this. However, if we’re
torturing the preprocessor a little more, by using token pasting,
at least one compiler falls over.</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="pp">#define H</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span><span class="pp"> </span><span class="op">&lt;</span><span class="pp">st</span><span class="op">##</span><span class="pp">x</span><span class="op">##.</span><span class="pp">h</span><span class="op">&gt;</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="pp">#include H(dio) </span><span class="co">/* expands to &lt;stdio.h&gt; */</span></span></code></pre></div>
<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="pp">#define H</span><span class="op">(</span><span class="pp">x</span><span class="op">)</span><span class="pp"> </span><span class="op">&lt;</span><span class="pp">st</span><span class="op">##</span><span class="pp">x</span><span class="op">##.</span><span class="pp">h</span><span class="op">&gt;</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include H(dio) </span><span class="co">/* expands to &lt;stdio.h&gt; */</span></span></code></pre></div>
<p>is rejected by tcc version 4.1.2, the TenDRA compiler:
<code>"t.c", line 3: Error:\ [ISO 6.8.3.3]: Invalid result for '##' operator in macro 'H'.</code></p>
<p>To be honest, I don’t know if the rules for pp-tokens and token
@@ -265,15 +264,15 @@ allows: in <code>#line num "file"</code> the <code>"file"</code> is an s-char-se
ISO 6.8.4. ISO 6.1.4 defines string literals as s-char-sequences,
which may include octal escape sequences. Let’s look at</li>
</ol>
<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="pp">#include </span><span class="im">&lt;stdio.h&gt;</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="pp">#line 42 &quot;foo\0bar&quot;</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="dt">int</span> main <span class="op">(</span><span class="dt">void</span><span class="op">)</span> <span class="op">{</span></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> printf <span class="op">(</span><span class="st">&quot;</span><span class="sc">%s</span><span class="st"> </span><span class="sc">%d\n</span><span class="st">&quot;</span><span class="op">,</span> __FILE__<span class="op">,</span> <span class="op">(</span><span class="dt">int</span><span class="op">)</span><span class="kw">sizeof</span> __FILE__<span class="op">);</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<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="pp">#include </span><span class="im">&lt;stdio.h&gt;</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#line 42 &quot;foo\0bar&quot;</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> main <span class="op">(</span><span class="dt">void</span><span class="op">)</span> <span class="op">{</span></span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> printf <span class="op">(</span><span class="st">&quot;</span><span class="sc">%s</span><span class="st"> </span><span class="sc">%d\n</span><span class="st">&quot;</span><span class="op">,</span> __FILE__<span class="op">,</span> <span class="op">(</span><span class="dt">int</span><span class="op">)</span><span class="kw">sizeof</span> __FILE__<span class="op">);</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="dv">0</span><span class="op">;</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
<p>This is supposed to output <code>'foo 8'</code>. Here’s what happens in RL:</p>
<pre><code>foo 4 gcc 2.7.2.1, lcc
foo\0bar 9 tcc 4.1.2, Sunsoft cc turn &quot;\0&quot; into &quot;\\0&quot;, ugh!</code></pre>
<pre><code> foo 4 gcc 2.7.2.1, lcc
foo\0bar 9 tcc 4.1.2, Sunsoft cc turn &quot;\0&quot; into &quot;\\0&quot;, ugh!</code></pre>
<p>(I have written a bug report for gcc. Newer versions and egcs are ok.)</p>
<ol start="3" type="1">
<li><p>The <code>%:</code> and <code>%:%:</code> digraphs test for conformance to Amendment One.</p>
@@ -284,8 +283,8 @@ ISO 6.6.4.2. Then make fun of the guru’s answer by waving <code>case __LINE__:
under his/her nose. Easy money from a bet! Make sure your guru has
no chance to use Standardese weasel words as an escape: can I have</p></li>
</ol>
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="op">&lt;</span>some_token<span class="op">&gt;:</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="op">&lt;</span>some_token<span class="op">&gt;:</span></span></code></pre></div>
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="op">&lt;</span>some_token<span class="op">&gt;:</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="op">&lt;</span>some_token<span class="op">&gt;:</span></span></code></pre></div>
<p>in the same switch? (Note that you need the [invisible] newline. You
can generously allow the additional constraint that no <code>#undef</code>s or
<code>#define</code>s are allowed between the two cases.)</p>
@@ -316,14 +315,14 @@ I could have used a lot more <code>^K</code> and <code>^L</code> probably undete
counter but decided to err on the side of safety. I use a perl
script to compute the character count according to the rules.
The advantages of an independent clean room approach…</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode perl"><code class="sourceCode perl"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="kw">#!/usr/bin/perl -w</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="wa">$/</span> = <span class="ot">&quot;</span><span class="st">\0</span><span class="ot">&quot;</span>;</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="wa">$_</span> = &lt;&gt;;</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="ot">s/</span><span class="ch">[</span><span class="bn">;{}</span><span class="ch">][</span><span class="bn"> \t\n</span><span class="ch">]</span><span class="ot">/</span><span class="ch">\n</span><span class="ot">/g</span>;</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a><span class="ot">s/</span><span class="ch">[</span><span class="bn"> \t\n</span><span class="ch">]+</span><span class="ot">//g</span>;</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span> <span class="fu">length</span> (<span class="wa">$_</span>),<span class="ot">&quot;</span><span class="ch">\n</span><span class="ot">&quot;</span>;</span></code></pre></div>
<div class="sourceCode" id="cb11"><pre class="sourceCode perl"><code class="sourceCode perl"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="co">#!/usr/bin/perl -w</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="wa">$/</span> = <span class="ot">&quot;</span><span class="st">\0</span><span class="ot">&quot;</span>;</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="wa">$_</span> = &lt;&gt;;</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="ot">s/</span><span class="ch">[</span><span class="bn">;{}</span><span class="ch">][</span><span class="bn"> \t\n</span><span class="ch">]</span><span class="ot">/</span><span class="ch">\n</span><span class="ot">/g</span>;</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="ot">s/</span><span class="ch">[</span><span class="bn"> \t\n</span><span class="ch">]+</span><span class="ot">//g</span>;</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span> <span class="fu">length</span> (<span class="wa">$_</span>),<span class="ot">&quot;</span><span class="ch">\n</span><span class="ot">&quot;</span>;</span></code></pre></div>
<p>To use, try:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="fu">perl</span> ./charcount.pl schweikh1.c</span></code></pre></div>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">perl</span> ./charcount.pl schweikh1.c</span></code></pre></div>
<p>I have tried, as suggested in the guidelines, to let the code look
like ordinary C code. Apart from a few long lines I think I left
the indentation like I would in RL. You should however not try to
+5 -5
View File
@@ -138,7 +138,7 @@ a file was not found (this limitation was removed in both versions in 2023). see
<p>However, as noted, macOS does <strong>not</strong> have <code>/usr/include</code> so this would never
work for macOS without some changes, described next. For macOS you will need the
command line tools installed which can be done like:</p>
<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">sudo</span> xcode-select <span class="at">--install</span></span></code></pre></div>
<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">sudo</span> xcode-select <span class="at">--install</span></span></code></pre></div>
<p>An important point is that the original version hard-coded <code>gcc</code> but just like
the entry, the alternate version has also removed this limitation despite <code>gcc</code>
existing (though it’s <code>clang</code>) in macOS.</p>
@@ -150,13 +150,13 @@ string and the other a couple lines further below.</p>
<p>In the original the numbers are, respectively, <code>44</code> and <code>46</code>, but with the gcc
limitation removed the numbers now are <code>43</code> and <code>45</code>. But how does this work? Well
the command is:</p>
<pre><code>&quot;0gcc -ansi -E -dM -undef %s /usr/include/%s&gt;r\0 (&quot;</code></pre>
<pre><code> &quot;0gcc -ansi -E -dM -undef %s /usr/include/%s&gt;r\0 (&quot;</code></pre>
<p>which has been changed to be:</p>
<pre><code>&quot;0cc -ansi -E -dM -undef %s /usr/include/%s&gt;r\0 (&quot;</code></pre>
<p>Shortly below that you will see, as noted above, the numbers:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="op">((</span>H <span class="op">=</span> fopen <span class="op">(</span>__FILE__<span class="op">+</span><span class="dv">43</span><span class="op">,</span> <span class="dv">43</span><span class="op">+</span>__FILE__<span class="op">)))</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="cf">while</span> <span class="op">((</span>fgets <span class="op">(</span>L<span class="op">,</span> <span class="op">(</span><span class="dt">int</span><span class="op">)</span><span class="kw">sizeof</span> L<span class="op">,</span> H<span class="op">))</span> <span class="op">!=</span> <span class="dv">0</span><span class="op">)</span> <span class="op">{</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> I<span class="op">[</span>strcspn <span class="op">(</span>I<span class="op">,</span> <span class="dv">45</span><span class="op">+</span>__FILE__<span class="op">)]</span> <span class="op">=</span> O <span class="op">=</span> <span class="dv">0</span><span class="op">;</span></span></code></pre></div>
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">((</span>H <span class="op">=</span> fopen <span class="op">(</span>__FILE__<span class="op">+</span><span class="dv">43</span><span class="op">,</span> <span class="dv">43</span><span class="op">+</span>__FILE__<span class="op">)))</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">while</span> <span class="op">((</span>fgets <span class="op">(</span>L<span class="op">,</span> <span class="op">(</span><span class="dt">int</span><span class="op">)</span><span class="kw">sizeof</span> L<span class="op">,</span> H<span class="op">))</span> <span class="op">!=</span> <span class="dv">0</span><span class="op">)</span> <span class="op">{</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> I<span class="op">[</span>strcspn <span class="op">(</span>I<span class="op">,</span> <span class="dv">45</span><span class="op">+</span>__FILE__<span class="op">)]</span> <span class="op">=</span> O <span class="op">=</span> <span class="dv">0</span><span class="op">;</span></span></code></pre></div>
<p>The first number in the above C means the length starting from 0 up through the
<code>&gt;</code>. The second number is the same starting point but up through the <code>\0</code> which
is why it’s <code>+2</code>. But what happens if only the first number is updated (from the
+5 -5
View File
@@ -20,7 +20,7 @@ work for macOS without some changes, described next. For macOS you will need the
command line tools installed which can be done like:
```sh
sudo xcode-select --install
sudo xcode-select --install
```
An important point is that the original version hard-coded `gcc` but just like
@@ -39,7 +39,7 @@ limitation removed the numbers now are `43` and `45`. But how does this work? We
the command is:
```
"0gcc -ansi -E -dM -undef %s /usr/include/%s>r\0 ("
"0gcc -ansi -E -dM -undef %s /usr/include/%s>r\0 ("
```
which has been changed to be:
@@ -51,9 +51,9 @@ which has been changed to be:
Shortly below that you will see, as noted above, the numbers:
```c
if ((H = fopen (__FILE__+43, 43+__FILE__)))
while ((fgets (L, (int)sizeof L, H)) != 0) {
I[strcspn (I, 45+__FILE__)] = O = 0;
if ((H = fopen (__FILE__+43, 43+__FILE__)))
while ((fgets (L, (int)sizeof L, H)) != 0) {
I[strcspn (I, 45+__FILE__)] = O = 0;
```
The first number in the above C means the length starting from 0 up through the
+28 -29
View File
@@ -1,30 +1,30 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./yarng
./yarng
```
or
```sh
./yarng integer_number
./yarng integer_number
```
## Try:
```sh
./try.sh
./try.sh
./yarng
# watch what it does
./yarng
# watch what it does
```
What is the difference between what is in the script and running `yarng` without
@@ -43,38 +43,37 @@ did not compile this entry correctly. Also at that time, some gcc and egcs
implementations ran into a problem when building the entry. Doing:
```sh
make schweikh2
make schweikh2
```
often produced an error of the form:
```sh
gcc -ansi schweikh2.alt.c -o schweikh2.alt
as: Error: cca00NzV.s, line 58: Missing " at end of string
"
as: Error: cca00NzV.s, line 58: malformed statement
*** Error code 1 (bu21)
gcc -ansi schweikh2.alt.c -o schweikh2.alt
as: Error: cca00NzV.s, line 58: Missing " at end of string
"
as: Error: cca00NzV.s, line 58: malformed statement
*** Error code 1 (bu21)
```
because the line:
```c
#line 10 ONE(O(1,1,2,6,0,6))
#line 10 ONE(O(1,1,2,6,0,6))
```
turned into the line:
```c
# 9 "01\012"
# 9 "01\012"
```
(note, though, how that line is on line 11) which caused gcc to give to the
assembler the following two lines:
```asm
.stabs "schweikh2.c
",132,0,0,Ltext1
.stabs "schweikh2.c
",132,0,0,Ltext1
```
and the lone `"` after the `#.file` line resulted in an assembly syntax error.
@@ -82,7 +81,7 @@ and the lone `"` after the `#.file` line resulted in an assembly syntax error.
In some cases one had to compile using `gcc -g`:
```sh
make schweikh2 CFLAGS=-g
make schweikh2 CFLAGS=-g
```
to trigger this error.
@@ -107,7 +106,7 @@ still can :-) ).
Because of this bug, the code was changed to be instead:
```c
#line 10 "01\015"
#line 10 "01\015"
```
However in 2023 it was observed that _it is gcc_ (at least some versions?) that
@@ -115,22 +114,22 @@ has a problem with the compilation of the _modified_ program, giving an internal
compiler error:
```
:10:16: warning: type defaults to 'int' in declaration of 'zero' [-Wimplicit-int]
: In function 'main':
:12:1: warning: missing terminating " character
:12:19: internal compiler error: invalid built-in macro "__FILE__"
:10:16: warning: type defaults to 'int' in declaration of 'zero' [-Wimplicit-int]
: In function 'main':
:12:1: warning: missing terminating " character
:12:19: internal compiler error: invalid built-in macro "__FILE__"
```
so the line:
```c
#line 10 "01\015"
#line 10 "01\015"
```
was changed to:
```c
#line 10 ONE(O(1,1,2,6,0,6))
#line 10 ONE(O(1,1,2,6,0,6))
```
and now it works with both clang and gcc.
@@ -160,10 +159,10 @@ different values? How long would you need for an empirical test?
For example:
```sh
$ ./yarng 32
10111001010101110110010101001111
$ ./yarng 5
10011
$ ./yarng 32
10111001010101110110010101001111
$ ./yarng 5
10011
```
### Why I think this is obfuscated
+29 -30
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Jens_Schweikhardt">Jens Schweikhardt</a><br>
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)
<br><br></li>
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,16 +141,16 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<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">./yarng</span></span></code></pre></div>
<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">./yarng</span></span></code></pre></div>
<p>or</p>
<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">./yarng</span> integer_number</span></code></pre></div>
<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">./yarng</span> integer_number</span></code></pre></div>
<h2 id="try">Try:</h2>
<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="ex">./try.sh</span></span>
<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="ex">./try.sh</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./yarng</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="co"># watch what it does</span></span></code></pre></div>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./yarng</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="co"># watch what it does</span></span></code></pre></div>
<p>What is the difference between what is in the script and running <code>yarng</code> without
an arg?</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
@@ -161,24 +160,24 @@ results different? Why?</p>
<p>At the time of judging, some non-gcc compilers that were not fully ANSI standard
did not compile this entry correctly. Also at that time, some gcc and egcs
implementations ran into a problem when building the entry. Doing:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> schweikh2</span></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> schweikh2</span></code></pre></div>
<p>often produced an error of the form:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> <span class="at">-ansi</span> schweikh2.alt.c <span class="at">-o</span> schweikh2.alt</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="ex">as:</span> Error: cca00NzV.s, line 58: Missing <span class="st">&quot; at end of string</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="st"> &quot;</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a><span class="ex">as:</span> Error: cca00NzV.s, line 58: malformed statement</span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a><span class="ex">***</span> Error code 1 <span class="er">(</span><span class="ex">bu21</span><span class="kw">)</span></span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="at">-ansi</span> schweikh2.alt.c <span class="at">-o</span> schweikh2.alt</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">as:</span> Error: cca00NzV.s, line 58: Missing <span class="st">&quot; at end of string</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="st"> &quot;</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">as:</span> Error: cca00NzV.s, line 58: malformed statement</span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">***</span> Error code 1 <span class="er">(</span><span class="ex">bu21</span><span class="kw">)</span></span></code></pre></div>
<p>because the line:</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="pp">#line 10 ONE(O(1,1,2,6,0,6))</span></span></code></pre></div>
<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="pp">#line 10 ONE(O(1,1,2,6,0,6))</span></span></code></pre></div>
<p>turned into the line:</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="pp"># 9 &quot;01\012&quot;</span></span></code></pre></div>
<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="pp"># 9 &quot;01\012&quot;</span></span></code></pre></div>
<p>(note, though, how that line is on line 11) which caused gcc to give to the
assembler the following two lines:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode asm"><code class="sourceCode fasm"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>.stabs <span class="st">&quot;schweikh2.c</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>&quot;,132,0,0,Ltext1</span></code></pre></div>
<div class="sourceCode" id="cb9"><pre class="sourceCode asm"><code class="sourceCode fasm"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> .stabs <span class="st">&quot;schweikh2.c</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> &quot;,132,0,0,Ltext1</span></code></pre></div>
<p>and the lone <code>"</code> after the <code>#.file</code> line resulted in an assembly syntax error.</p>
<p>In some cases one had to compile using <code>gcc -g</code>:</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">make</span> schweikh2 CFLAGS=-g</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">make</span> schweikh2 CFLAGS=-g</span></code></pre></div>
<p>to trigger this error.</p>
<p>With the proper text beyond the <code>\012</code>, it was even possible to have all kinds
of fun adding inline assembly via <code>#line</code> directives. :-)</p>
@@ -192,18 +191,18 @@ for that matter :-) ).</p>
you could have emailed the author for a free pat on the back (and maybe you
still can :-) ).</p>
<p>Because of this bug, the code was changed to be instead:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#line 10 &quot;01\015&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#line 10 &quot;01\015&quot;</span></span></code></pre></div>
<p>However in 2023 it was observed that <em>it is gcc</em> (at least some versions?) that
has a problem with the compilation of the <em>modified</em> program, giving an internal
compiler error:</p>
<pre><code>:10:16: warning: type defaults to &#39;int&#39; in declaration of &#39;zero&#39; [-Wimplicit-int]
: In function &#39;main&#39;:
:12:1: warning: missing terminating &quot; character
:12:19: internal compiler error: invalid built-in macro &quot;__FILE__&quot;</code></pre>
<pre><code> :10:16: warning: type defaults to &#39;int&#39; in declaration of &#39;zero&#39; [-Wimplicit-int]
: In function &#39;main&#39;:
:12:1: warning: missing terminating &quot; character
:12:19: internal compiler error: invalid built-in macro &quot;__FILE__&quot;</code></pre>
<p>so the line:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#line 10 &quot;01\015&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb13"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#line 10 &quot;01\015&quot;</span></span></code></pre></div>
<p>was changed to:</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#line 10 ONE(O(1,1,2,6,0,6))</span></span></code></pre></div>
<div class="sourceCode" id="cb14"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#line 10 ONE(O(1,1,2,6,0,6))</span></span></code></pre></div>
<p>and now it works with both clang and gcc.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="what-this-program-does">What this program does</h3>
@@ -224,10 +223,10 @@ bits may be specified by an argument and defaults either to <code>UINT_MAX</code
(least likely) or <code>UINT_MAX+1</code> (most likely). Extra credit: why the
different values? How long would you need for an empirical test?</p>
<p>For example:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./yarng 32</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="ex">10111001010101110110010101001111</span></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./yarng 5</span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a><span class="ex">10011</span></span></code></pre></div>
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./yarng 32</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">10111001010101110110010101001111</span></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./yarng 5</span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">10011</span></span></code></pre></div>
<h3 id="why-i-think-this-is-obfuscated">Why I think this is obfuscated</h3>
<ul>
<li><p>Ever seen a ‘do for … while’ loop?</p></li>
+20 -20
View File
@@ -1,16 +1,16 @@
## To build:
```sh
make all
make all
```
The author stated:
```
In the remote event that the input has more than `8192` files with
the same size (on systems where `sizeof (char *) == 4`, or `4096` when
`sizeof (char *) == 8`), increase the manifest constant 32767 on line
31.
In the remote event that the input has more than `8192` files with
the same size (on systems where `sizeof (char *) == 4`, or `4096` when
`sizeof (char *) == 8`), increase the manifest constant 32767 on line
31.
```
An alternate version allows one to fix this; see [alternate
@@ -24,7 +24,7 @@ all your favorite pictures off the Internet or from
`alt.binaries.pictures.*`, do
```sh
find dir -type f -print | ./samefile
find dir -type f -print | ./samefile
```
Maybe you will not need to buy another 10 GB disk to store them. :-)
@@ -35,7 +35,7 @@ Maybe you will not need to buy another 10 GB disk to store them. :-)
If you're in this winning entry's directory:
```sh
./try.sh
./try.sh
```
Notice that the tool finds some files that are duplicates.
@@ -54,7 +54,7 @@ If you wish to change the size to say, 55555:
```sh
make clobber SIZE=55555 alt
make clobber SIZE=55555 alt
```
or whatever you wish to redefine it to.
@@ -84,7 +84,7 @@ This is best explained in the man page. The troff source for this
man page can be found in the file [samefile.1](samefile.1). To render try:
```sh
`man ./samefile.1
`man ./samefile.1
```
Otherwise:
@@ -101,7 +101,7 @@ Otherwise:
#### SYNOPSIS
```sh
./samefile
./samefile
```
#### DESCRIPTION
@@ -142,13 +142,13 @@ identical files of size 100 in an inode group consisting
of the three inodes with numbers 10, 20 and 30:
```sh
$ ls -i # output edited for readability:
10 file1 20 file4 30 file6
10 file2 20 file5
10 file3
$ ls | ./samefile
100 file1 file4 = 3 2
100 file1 file6 = 3 1
$ ls -i # output edited for readability:
10 file1 20 file4 30 file6
10 file2 20 file5
10 file3
$ ls | ./samefile
100 file1 file4 = 3 2
100 file1 file6 = 3 1
```
The sum of the sizes in the first column is the amount of
@@ -178,7 +178,7 @@ For everybody:
What are the duplicates under my home directory?
```sh
find $HOME | ./samefile
find $HOME | ./samefile
```
For the sysadmin folks:
@@ -186,14 +186,14 @@ For the sysadmin folks:
Report all duplicate files under /usr larger than 16k:
```sh
find /usr -size +16384c -a -type f | ./samefile
find /usr -size +16384c -a -type f | ./samefile
```
For the ftp and WWW admins:
How much space is wasted below our site's /pub directory?
```sh
find /pub -type f | samefile | awk '{sum += $1} END {print sum}'
find /pub -type f | samefile | awk '{sum += $1} END {print sum}'
```
+21 -22
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Jens_Schweikhardt">Jens Schweikhardt</a><br>
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)
<br><br></li>
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,23 +141,23 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<p>The author stated:</p>
<pre><code>In the remote event that the input has more than `8192` files with
the same size (on systems where `sizeof (char *) == 4`, or `4096` when
`sizeof (char *) == 8`), increase the manifest constant 32767 on line
31.</code></pre>
<pre><code> In the remote event that the input has more than `8192` files with
the same size (on systems where `sizeof (char *) == 4`, or `4096` when
`sizeof (char *) == 8`), increase the manifest constant 32767 on line
31.</code></pre>
<p>An alternate version allows one to fix this; see <a href="#alternate-code">alternate
code</a> below.</p>
<h2 id="to-use">To use:</h2>
<p>If <code>dir</code> is the directory (or a directory tree) where you keep
all your favorite pictures off the Internet or from
<code>alt.binaries.pictures.*</code>, do</p>
<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="fu">find</span> dir <span class="at">-type</span> f <span class="at">-print</span> <span class="kw">|</span> <span class="ex">./samefile</span></span></code></pre></div>
<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="fu">find</span> dir <span class="at">-type</span> f <span class="at">-print</span> <span class="kw">|</span> <span class="ex">./samefile</span></span></code></pre></div>
<p>Maybe you will not need to buy another 10 GB disk to store them. :-)</p>
<h2 id="try">Try:</h2>
<p>If you’re in this winning entry’s directory:</p>
<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="ex">./try.sh</span></span></code></pre></div>
<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="ex">./try.sh</span></span></code></pre></div>
<p>Notice that the tool finds some files that are duplicates.</p>
<h2 id="alternate-code">Alternate code:</h2>
<p>If you run into the problem that the author described (above) you can redefine
@@ -166,7 +165,7 @@ the size as described; this was done with the <code>SZ</code> macro defined in t
which if (in the code) is unset will be set to the default, 32767.</p>
<h3 id="alternate-build">Alternate build:</h3>
<p>If you wish to change the size to say, 55555:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber SIZE=55555 alt</span></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber SIZE=55555 alt</span></code></pre></div>
<p>or whatever you wish to redefine it to.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>This program is not as smart as to detect identity of JPEG files with the same
@@ -182,13 +181,13 @@ Thank God the IEEE does not standardize a coding style…</p>
<h3 id="what-this-program-does">What this program does</h3>
<p>This is best explained in the man page. The troff source for this
man page can be found in the file <a href="samefile.1">samefile.1</a>. To render try:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="kw">`</span><span class="fu">man</span> ./samefile.1</span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">`</span><span class="fu">man</span> ./samefile.1</span></code></pre></div>
<p>Otherwise:</p>
<h3 id="samefile1-user-manuals-samefile1">SAMEFILE(1) User Manuals SAMEFILE(1)</h3>
<h4 id="name">NAME</h4>
<p><code>samefile</code> - find identical files</p>
<h4 id="synopsis">SYNOPSIS</h4>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./samefile</span></span></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./samefile</span></span></code></pre></div>
<h4 id="description">DESCRIPTION</h4>
<p><code>samefile</code> reads a list of file names (one file name per
line) from <code>stdin</code>. For each file name pair with identical
@@ -220,13 +219,13 @@ the output for a group of identical files with different
inode numbers is also minimized. Suppose you have six
identical files of size 100 in an inode group consisting
of the three inodes with numbers 10, 20 and 30:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ls <span class="at">-i</span> <span class="co"># output edited for readability:</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">10</span> file1 20 file4 30 file6</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">10</span> file2 20 file5</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">10</span> file3</span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ls <span class="kw">|</span> <span class="ex">./samefile</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a><span class="ex">100</span> file1 file4 = 3 2</span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a><span class="ex">100</span> file1 file6 = 3 1</span></code></pre></div>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ls <span class="at">-i</span> <span class="co"># output edited for readability:</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">10</span> file1 20 file4 30 file6</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">10</span> file2 20 file5</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">10</span> file3</span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ls <span class="kw">|</span> <span class="ex">./samefile</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">100</span> file1 file4 = 3 2</span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">100</span> file1 file6 = 3 1</span></code></pre></div>
<p>The sum of the sizes in the first column is the amount of
disk space you could gain by making all 6 files links to
only one file or remove all but one of the files. To be
@@ -246,13 +245,13 @@ more than a couple dozen files of the same size.</p>
<h4 id="examples">EXAMPLES</h4>
<p>For everybody:</p>
<p>What are the duplicates under my home directory?</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="fu">find</span> <span class="va">$HOME</span> <span class="kw">|</span> <span class="ex">./samefile</span></span></code></pre></div>
<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="fu">find</span> <span class="va">$HOME</span> <span class="kw">|</span> <span class="ex">./samefile</span></span></code></pre></div>
<p>For the sysadmin folks:</p>
<p>Report all duplicate files under /usr larger than 16k:</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">find</span> /usr <span class="at">-size</span> +16384c <span class="at">-a</span> <span class="at">-type</span> f <span class="kw">|</span> <span class="ex">./samefile</span></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">find</span> /usr <span class="at">-size</span> +16384c <span class="at">-a</span> <span class="at">-type</span> f <span class="kw">|</span> <span class="ex">./samefile</span></span></code></pre></div>
<p>For the ftp and WWW admins:
How much space is wasted below our site’s /pub directory?</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">find</span> /pub <span class="at">-type</span> f <span class="kw">|</span> <span class="ex">samefile</span> <span class="kw">|</span> <span class="fu">awk</span> <span class="st">&#39;{sum += $1} END {print sum}&#39;</span></span></code></pre></div>
<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">find</span> /pub <span class="at">-type</span> f <span class="kw">|</span> <span class="ex">samefile</span> <span class="kw">|</span> <span class="fu">awk</span> <span class="st">&#39;{sum += $1} END {print sum}&#39;</span></span></code></pre></div>
<h4 id="exit-status">EXIT STATUS</h4>
<p>If <code>samefile</code> runs out of memory the exit status is 1, zero
otherwise.</p>
+34 -35
View File
@@ -1,32 +1,32 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./tomtorfs filename bitwidth polynom reflected init xor
./tomtorfs filename bitwidth polynom reflected init xor
```
where:
```
filename : file to calculate the CRC of
bitwidth : width of the CRC in bits (decimal)
polynom : polynomial used for the CRC (hexadecimal)
reflected : 0 if the CRC is not reflected, 1 if it is
init : initial value for the CRC (hexadecimal)
xor : value to xor the final CRC with (hexadecimal)
filename : file to calculate the CRC of
bitwidth : width of the CRC in bits (decimal)
polynom : polynomial used for the CRC (hexadecimal)
reflected : 0 if the CRC is not reflected, 1 if it is
init : initial value for the CRC (hexadecimal)
xor : value to xor the final CRC with (hexadecimal)
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -40,15 +40,15 @@ archiver that uses the CRC-32 algorithm.
## Author's remarks:
```
Usage:
./tomtorfs filename bitwidth polynom reflected init xor
Usage:
./tomtorfs filename bitwidth polynom reflected init xor
filename : file to calculate the CRC of
bitwidth : width of the CRC in bits (decimal)
polynom : polynomial used for the CRC (hexadecimal)
reflected : 0 if the CRC is not reflected, 1 if it is
init : initial value for the CRC (hexadecimal)
xor : value to xor the final CRC with (hexadecimal)
filename : file to calculate the CRC of
bitwidth : width of the CRC in bits (decimal)
polynom : polynomial used for the CRC (hexadecimal)
reflected : 0 if the CRC is not reflected, 1 if it is
init : initial value for the CRC (hexadecimal)
xor : value to xor the final CRC with (hexadecimal)
```
### Examples
@@ -57,7 +57,7 @@ xor : value to xor the final CRC with (hexadecimal)
#### CRC-16:
```sh
./tomtorfs filename 16 1021 0 FFFF 0000
./tomtorfs filename 16 1021 0 FFFF 0000
```
@@ -65,22 +65,21 @@ xor : value to xor the final CRC with (hexadecimal)
```sh
./tomtorfs filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF
./tomtorfs filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF
```
#### XMODEM:
```sh
./tomtorfs filename 16 8408 1 0000 0000
./tomtorfs filename 16 8408 1 0000 0000
```
#### ARC:
```sh
./tomtorfs filename 16 8005 1 0000 0000
./tomtorfs filename 16 8005 1 0000 0000
```
@@ -110,22 +109,22 @@ The variable names are not very descriptive. They have the
following meanings:
```
a = argc
A = argv
a = argc
A = argv
b = array of unsigned long variables
b[0] = bit-width of the CRC (argv[2])
b[1] = CRC polynomial (argv[3])
b[2] = nonzero if CRC is reflected (argv[4])
b[3] = initial value of CRC (argv[5])
b[4] = value final CRC is XORed with (argv[6])
b[5] = CRC value
b[6] = byte from file
b[7] = counter
b = array of unsigned long variables
b[0] = bit-width of the CRC (argv[2])
b[1] = CRC polynomial (argv[3])
b[2] = nonzero if CRC is reflected (argv[4])
b[3] = initial value of CRC (argv[5])
b[4] = value final CRC is XORed with (argv[6])
b[5] = CRC value
b[6] = byte from file
b[7] = counter
B = FILE * through which the file argv[1] is opened
B = FILE * through which the file argv[1] is opened
C = typedef for unsigned long
C = typedef for unsigned long
```
The first `for` loop simply reads the command-line arguments
+35 -36
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Tom_Torfs">Tom Torfs</a><br>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<br><br></li>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,41 +141,41 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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> all</span></code></pre></div>
<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> all</span></code></pre></div>
<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">./tomtorfs</span> filename bitwidth polynom reflected init xor</span></code></pre></div>
<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">./tomtorfs</span> filename bitwidth polynom reflected init xor</span></code></pre></div>
<p>where:</p>
<pre><code>filename : file to calculate the CRC of
bitwidth : width of the CRC in bits (decimal)
polynom : polynomial used for the CRC (hexadecimal)
reflected : 0 if the CRC is not reflected, 1 if it is
init : initial value for the CRC (hexadecimal)
xor : value to xor the final CRC with (hexadecimal)</code></pre>
<pre><code> filename : file to calculate the CRC of
bitwidth : width of the CRC in bits (decimal)
polynom : polynomial used for the CRC (hexadecimal)
reflected : 0 if the CRC is not reflected, 1 if it is
init : initial value for the CRC (hexadecimal)
xor : value to xor the final CRC with (hexadecimal)</code></pre>
<h2 id="try">Try:</h2>
<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="ex">./try.sh</span></span></code></pre></div>
<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="ex">./try.sh</span></span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>If you don’t believe the program is correct, try and compare the output
of the program with the value of CRCs computed by PKZIP or any other
archiver that uses the CRC-32 algorithm.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<pre><code>Usage:
./tomtorfs filename bitwidth polynom reflected init xor
<pre><code> Usage:
./tomtorfs filename bitwidth polynom reflected init xor
filename : file to calculate the CRC of
bitwidth : width of the CRC in bits (decimal)
polynom : polynomial used for the CRC (hexadecimal)
reflected : 0 if the CRC is not reflected, 1 if it is
init : initial value for the CRC (hexadecimal)
xor : value to xor the final CRC with (hexadecimal)</code></pre>
filename : file to calculate the CRC of
bitwidth : width of the CRC in bits (decimal)
polynom : polynomial used for the CRC (hexadecimal)
reflected : 0 if the CRC is not reflected, 1 if it is
init : initial value for the CRC (hexadecimal)
xor : value to xor the final CRC with (hexadecimal)</code></pre>
<h3 id="examples">Examples</h3>
<h4 id="crc-16">CRC-16:</h4>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./tomtorfs</span> filename 16 1021 0 FFFF 0000</span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./tomtorfs</span> filename 16 1021 0 FFFF 0000</span></code></pre></div>
<h4 id="crc-32">CRC-32:</h4>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./tomtorfs</span> filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF</span></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./tomtorfs</span> filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF</span></code></pre></div>
<h4 id="xmodem">XMODEM:</h4>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./tomtorfs</span> filename 16 8408 1 0000 0000</span></code></pre></div>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./tomtorfs</span> filename 16 8408 1 0000 0000</span></code></pre></div>
<h4 id="arc">ARC:</h4>
<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">./tomtorfs</span> filename 16 8005 1 0000 0000</span></code></pre></div>
<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">./tomtorfs</span> filename 16 8005 1 0000 0000</span></code></pre></div>
<h3 id="portability-notes">Portability notes</h3>
<p>The program assumes <code>CHAR_BIT==8</code>. Results are undefined if <code>bitwidth &gt; sizeof(unsigned long) * 8</code>. It is also assumed that <code>EOF</code> is <code>-1</code> and <code>1</code> is a
valid exit value to indicate failure (replace them with <code>EOF</code> resp.
@@ -191,22 +190,22 @@ the nice code shape I worked so hard on ;-) ) the code will become a bit more
readable.</p>
<p>The variable names are not very descriptive. They have the
following meanings:</p>
<pre><code>a = argc
A = argv
<pre><code> a = argc
A = argv
b = array of unsigned long variables
b[0] = bit-width of the CRC (argv[2])
b[1] = CRC polynomial (argv[3])
b[2] = nonzero if CRC is reflected (argv[4])
b[3] = initial value of CRC (argv[5])
b[4] = value final CRC is XORed with (argv[6])
b[5] = CRC value
b[6] = byte from file
b[7] = counter
b = array of unsigned long variables
b[0] = bit-width of the CRC (argv[2])
b[1] = CRC polynomial (argv[3])
b[2] = nonzero if CRC is reflected (argv[4])
b[3] = initial value of CRC (argv[5])
b[4] = value final CRC is XORed with (argv[6])
b[5] = CRC value
b[6] = byte from file
b[7] = counter
B = FILE * through which the file argv[1] is opened
B = FILE * through which the file argv[1] is opened
C = typedef for unsigned long</code></pre>
C = typedef for unsigned long</code></pre>
<p>The first <code>for</code> loop simply reads the command-line arguments
in the <code>b[]</code> array. The third parameter to <code>strtoul(3)</code> causes
all arguments to be in base-16 (hex) except the first one,