Fixes in 1998 html files

This includes some notices to those who wish for a greater challenge.

In the 1998/schweikh3 the man page (and its copy to demonstrate the
entry) have been updated slightly but only in comment (move 'or' from
the command suggested to render it in text to its own line before the
next command also in comment).

The bugs file was updated for an entry or two.
This commit is contained in:
Cody Boone Ferguson committed 2024-07-29 08:47:22 -07:00
1 parent e297d4541a
commit 1fad29cd2f
28 files changed
+647 -370

No files matched your search

+2 -2
View File
@@ -46,8 +46,8 @@ 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](%%REPO_URL%%/1998/banks/keysym.h) file is not complete from X11; it's just the
+2 -2
View File
@@ -437,8 +437,8 @@ the throttle up and down to <code>u</code> and <code>d</code>:</p>
<pre><code> make clobber IT=XK_u DT=XK_d all</code></pre>
<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>
<pre><code> #define XK_d 0x0064 /* U+0064 LATIN SMALL LETTER D */
#define XK_u 0x0075 /* U+0075 LATIN SMALL LETTER U */</code></pre>
<pre><code> #define XK_d 0x0064 /* U+0064 LATIN SMALL LETTER D */
#define XK_u 0x0075 /* U+0075 LATIN SMALL LETTER U */</code></pre>
<p>Note that the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/banks/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
+10 -1
View File
@@ -5,13 +5,22 @@
```
NOTE: Some systems do not implement `halfdelay()` in their `libcurses`.
You might try compiling with -lncurses if you have that library.
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
```
### Bugs and (Mis)features:
The current status of this entry is:
> **STATUS: INABIAF - please DO NOT fix**
For more detailed information see [1998/chaos in bugs.html](../../bugs.html#1998_chaos).
## To use:
+7 -1
View File
@@ -410,9 +410,15 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<h2 id="to-build">To build:</h2>
<pre><code> make chaos</code></pre>
<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.
You might try compiling with <code>-lncurses</code> if you have that library.
Or you can build this entry without the <code>halfdelay()</code> call by:</p>
<pre><code> make chaos_nohalf</code></pre>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<blockquote>
<p><strong>STATUS: INABIAF - please DO NOT fix</strong></p>
</blockquote>
<p>For more detailed information see <a href="../../bugs.html#1998_chaos">1998/chaos in bugs.html</a>.</p>
<h2 id="to-use">To use:</h2>
<pre><code> ./chaos</code></pre>
<h2 id="try">Try:</h2>
+2 -5
View File
@@ -139,11 +139,8 @@ where the first one would show the text as rendered but without links, images
etc. and the second one would write the html to `ms.html` so that you could open
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
```
For an old example of it working as a CGI script see
<https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org>.
## Author's remarks:
+2 -2
View File
@@ -487,8 +487,8 @@ can look at locally in a browser or pipe through <code>less(1)</code>. For insta
<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>
<pre><code> https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org</code></pre>
<p>For an old example of it working as a CGI script see
<a href="https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org" class="uri">https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org</a>.</p>
<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>
+4 -6
View File
@@ -60,11 +60,9 @@ clockwise `l` does as well. Instead of using `d` to drop the letter you can do
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 ...
## Author's remarks:
@@ -79,7 +77,7 @@ experience may mirror one of our experiences:
The object of this game is to spell `POOT` as much as possible. There
is no time pressure. You're given one letter at a time (sort of randomly
chosen from the set 'P', 'O', and 'T') and you get to move it freely
chosen from the set '`P`', '`O`', and '`T`') and you get to move it freely
around the border of the playing board, and decide when and where to drop
it into the board. Sound easy? Of course, there's a catch...
+6 -4
View File
@@ -442,16 +442,18 @@ clockwise <code>l</code> does as well. Instead of using <code>d</code> to drop t
<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>
<blockquote>
<p>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 …</p>
</blockquote>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="usage">Usage</h3>
<pre><code> ./pootris [X size of board] [Y size of board]</code></pre>
<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
chosen from the set ‘P’, ‘O’, and ‘T’) and you get to move it freely
chosen from the set ‘<code>P</code>’, ‘<code>O</code>’, and ‘<code>T</code>’) and you get to move it freely
around the border of the playing board, and decide when and where to drop
it into the board. Sound easy? Of course, there’s a catch…</p>
<h3 id="controls">Controls</h3>
+5 -13
View File
@@ -116,25 +116,17 @@ is the same as
**If you want a greater challenge, don't read any further**:
just try to understand the program without running the command below.
If you get stuck, come back and read the below.
If you get stuck, come back and run the following command:
The file [dorssel.html](dorssel.html) contains all the information needed to
understand this program.
For more information you might also try:
``` <!---sh-->
./dorssel < dorssel.md
```
### NOTICE to those who wish for a greater challenge:
**If you want a greater challenge, don't read any further**:
just try to understand the program via the source.
If you get stuck, come back and read below for additional hints and information.
- The file [dorssel.html](dorssel.html) contains all the information needed to
understand this program. For spoiler information, try:
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
+60 -38
View File
@@ -423,7 +423,7 @@ counter before shifting out each symbol, such as</p>
encoding &gt;&gt;= 1;
} while (length--);</code></pre>
<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
<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
@@ -438,11 +438,11 @@ 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>
@@ -454,13 +454,14 @@ is encoded still allows the encoding to be its own counter:</p>
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>
sequence, so the <code>putchar(3)</code> can simply be</p>
<pre><code> putchar(45 + encoding % 2);</code></pre>
<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>
<pre><code> while(putchar(45 + encoding % 2), encoding = encoding + 32 &gt;&gt; 1);</code></pre>
<pre><code> while(putchar(45 + encoding % 2),
encoding = encoding + 32 &gt;&gt; 1);</code></pre>
<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
@@ -484,23 +485,23 @@ and letters. This is OK, since neither of these characters, or the <code>'\0'</c
is a valid encoding ! We must, however, use <code>memchr(3)</code> instead of <code>strchr(3)</code> in
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>
<p>The outline of the program is roughly as follows (pseudo C):</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>
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
@@ -512,27 +513,48 @@ line of text. This does not disturb the <code>if (line is in morse)</code> test,
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>
<p>Summary of the use of <code>l[999]</code>:</p>
<ul>
<li><code>l[0]</code>
<ul>
<li><strong>result of “is this line in morse” test</strong></li>
</ul></li>
<li><code>l[0]</code>
<ul>
<li><strong>temporary shift during encoding</strong></li>
</ul></li>
<li><code>l[0] - l[33]</code>
<ul>
<li><strong>Morse codings (letters and digits, plus garbage)</strong></li>
</ul></li>
<li><code>l[11] - l[14]</code>
<ul>
<li><strong><code>strspn(3)</code> argument</strong></li>
</ul></li>
<li><code>l[12] - l[14]</code>
<ul>
<li><strong><code>strspn(3)</code> argument</strong></li>
</ul></li>
<li><code>l[34]</code>
<ul>
<li><strong>terminator for backward decoding</strong></li>
</ul></li>
<li><code>l[35] - l[998]</code>
<ul>
<li><strong>input line</strong></li>
</ul></li>
</ul>
<hr style="width:10%;text-align:left;margin-left:0">
<p>Selected notes:</p>
<ul>
<li>We don’t need to declare <code>isalnum(3)</code> (or include ctype.h) as its implicit
declaration is correct (int argument, int result). This is not so for
<li>We don’t need to declare <code>isalnum(3)</code> (or include <code>ctype.h</code>) as its implicit
declaration is correct (<code>int</code> argument, <code>int</code> result). This is not so for
<code>strlen(3)</code>, <code>strspn(3)</code>, and <code>memchr(3)</code> as they use <code>size_t</code>.</li>
<li>During development, my gcc 2.7.2.3 had an internal compiler error (signal
<ol start="6" type="1">
<li>on code that was correct !</li>
</ol></li>
6) on code that was correct !</li>
<li>lclint 2.4b thinks that “the observer is modified” a couple of times,
whereas it is not. Well, it is, but there is a sequence point in between.</li>
<li>lclint 2.4b parses line 13 as <code>&lt;error&gt;</code>, whereas it is correct code.</li>
<li>lclint 2.4b parses <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/dorssel/dorssel.c:L13">line 13</a> as <code>&lt;error&gt;</code>, whereas it is correct code.</li>
<li>lclint 2.4b is positive the second <code>while</code> loop is infinite, whereas it is
not.</li>
</ul>
+49 -37
View File
@@ -53,7 +53,7 @@ counter before shifting out each symbol, such as
We can also use the remaining bits to *include* the counter
```
length 1: 00000.1x E > 00000.11
length 1: 00000.1x `E > 00000.11
length 2: 0000.1xx
length 3: 000.1xxx
length 4: 00.1xxxx Z > 00.11100
@@ -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
@@ -99,7 +99,7 @@ Note that the calculation for the next value of `encoding` is done at `int`
precision, so that the actual value of the `char` remains `<= 127`.
The character `'-'` (ASCII 45) and `'.'` (ASCII 46) are conveniently in
sequence, so the putchar can simply be
sequence, so the `putchar(3)` can simply be
``` <!---c-->
putchar(45 + encoding % 2);
@@ -111,7 +111,8 @@ 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.
@@ -141,25 +142,25 @@ is a valid encoding ! We must, however, use `memchr(3)` instead of `strchr(3)`
the decoding lookup because of this `'\0'`. Since it is far more obscure
this way, I hope you'll forgive me.
The outline of the program is roughly as follows
The outline of the program is roughly as follows (pseudo C):
```
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(' ');
}
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
@@ -176,30 +177,41 @@ as the temporary `l[0]` will remain `!= 0`.
I've put the `if`s in the above layout into a single switch. Hope you don't
mind ;-)
Summary of the use of l[999]:
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(3)` argument**
- `l[12] - l[14]`
* **`strspn(3)` argument**
- `l[34]`
* **terminator for backward decoding**
- `l[35] - l[998]`
* **input line**
<hr style="width:10%;text-align:left;margin-left:0">
Selected notes:
- We don't need to declare `isalnum(3)` (or include ctype.h) as its implicit
declaration is correct (int argument, int result). This is not so for
- We don't need to declare `isalnum(3)` (or include `ctype.h`) as its implicit
declaration is correct (`int` argument, `int` result). This is not so for
`strlen(3)`, `strspn(3)`, and `memchr(3)` as they use `size_t`.
- During development, my gcc 2.7.2.3 had an internal compiler error (signal
6) on code that was correct !
6\) on code that was correct !
- lclint 2.4b thinks that "the observer is modified" a couple of times,
whereas it is not. Well, it is, but there is a sequence point in between.
- lclint 2.4b parses line 13 as `<error>`, whereas it is correct code.
- lclint 2.4b parses [line 13](%%REPO_URL%%/1998/dorssel/dorssel.c:L13) as `<error>`, whereas it is correct code.
- lclint 2.4b is positive the second `while` loop is infinite, whereas it is
not.
+5 -10
View File
@@ -474,17 +474,12 @@ text that can be reversibly Morsified, i.e.</li>
<pre><code> ./dorssel &lt; dorssel.c | ./dorssel</code></pre>
<h3 id="notice-to-those-who-wish-for-a-greater-challenge">NOTICE to those who wish for a greater challenge:</h3>
<p><strong>If you want a greater challenge, don’t read any further</strong>:
just try to understand the program without running the command below.</p>
<p>If you get stuck, come back and run the following command:</p>
just try to understand the program without running the command below.
If you get stuck, come back and read the below.</p>
<p>The file <a href="dorssel.html">dorssel.html</a> contains all the information needed to
understand this program.</p>
<p>For more information you might also try:</p>
<pre><code> ./dorssel &lt; dorssel.md</code></pre>
<h3 id="notice-to-those-who-wish-for-a-greater-challenge-1">NOTICE to those who wish for a greater challenge:</h3>
<p><strong>If you want a greater challenge, don’t read any further</strong>:
just try to understand the program via the source.</p>
<p>If you get stuck, come back and read below for additional hints and information.</p>
<ul>
<li>The file <a href="dorssel.html">dorssel.html</a> contains all the information needed to
understand this program. For spoiler information, try:</li>
</ul>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
+22 -16
View File
@@ -20,8 +20,10 @@ For more detailed information see [1998/schnitzi in bugs.html](../../bugs.html#1
./schnitzi n > sort.c
make sort
./sort
# enter three numbers, space separated
# enter three numbers, space
# separated
# then try:
echo x y z | ./sort
```
@@ -41,7 +43,8 @@ program expects? For instance try:
./schnitzi 5 > sort.c
make sort
# try running the next command four or five times:
# now try running the next
# command four or five times:
echo 2 5 3 1 | ./sort
```
@@ -51,33 +54,36 @@ Why does this happen?
## Judges' remarks:
This is a beautiful program. How can a program with no conditional (except for
the fixes for modern systems though still no `if`s) behavior at all have output
which depends on anything?
the fixes for modern systems although there are still no `if`s) behavior at all
have output which depends on anything?
For hints on deciphering this, see below past the Author's remarks;
they're a nice summary, but they leave the mystery intact.
BTW: the author notes an incredible lipogram story called
BTW: the author notes an incredible
[lipogram](https://en.wikipedia.org/wiki/Lipogram) story called
[Gadsby](https://www.gutenberg.org/cache/epub/47342/pg47342.txt) which has no
letter E in the story. He did not note this but it has over 50000 (50 thousand)
(!!) words without the letter E which is one of the most common letters!
letter `E` in the story. He did not note this but it has over `50000` (50
thousand) (!!) words without the letter `E` which is one of the most common
letters!
## Author's remarks:
In literary circles, there is a poetic form called a "lipogram",
which is a poem in which a specific letter has been distinctly
avoided. This principle can be applied in other ways. For
instance, in this paragraph, the vowel which immediately follows
`t` in the alphabet is nowhere to be seen. There is even an
entire novel (E. V. Wright's "Gadsby") in which no word contains
the letter `e`.
In literary circles, there is a poetic form called a
"[lipogram](https://en.wikipedia.org/wiki/Lipogram)", which is a poem in which a
specific letter has been distinctly avoided. This principle can be applied in
other ways. For instance, in this paragraph, the vowel which immediately
follows `t` in the alphabet is nowhere to be seen. There is even an entire
novel (E. V. Wright's
"[Gadsby](https://www.gutenberg.org/cache/epub/47342/pg47342.txt)") in which no
word contains the letter `e`.
The IOCCC has been no stranger to this concept. Several winning entries from
years past have accomplished interesting feats while completely avoiding the use
of certain C constructs thought to be essential (e.g.,
[1988/robison.c](%%REPO_URL%%/1988/robison/robison.c) file). If you have to ask why they would
do it this way, then this contest just isn't for you.
[1988/robison.c](%%REPO_URL%%/1988/robison/robison.c) file). If you have to ask
why they would do it this way, then this contest just isn't for you.
In continuing with this fine tradition, this program suggests to the ANSI
committee some new practical simplifications for the C language. For instance,
+22 -16
View File
@@ -419,8 +419,10 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<pre><code> ./schnitzi n &gt; sort.c
make sort
./sort
# enter three numbers, space separated
# enter three numbers, space
# separated
# then try:
echo x y z | ./sort</code></pre>
<p>where <code>n</code> and <code>x</code>, <code>y</code> and <code>z</code> are numbers.</p>
<h2 id="try">Try:</h2>
@@ -430,32 +432,36 @@ program expects? For instance try:</p>
<pre><code> ./schnitzi 5 &gt; sort.c
make sort
# try running the next command four or five times:
# now try running the next
# command four or five times:
echo 2 5 3 1 | ./sort</code></pre>
<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
the fixes for modern systems though still no <code>if</code>s) behavior at all have output
which depends on anything?</p>
the fixes for modern systems although there are still no <code>if</code>s) behavior at all
have output which depends on anything?</p>
<p>For hints on deciphering this, see below past the Author’s remarks;
they’re a nice summary, but they leave the mystery intact.</p>
<p>BTW: the author notes an incredible lipogram story called
<p>BTW: the author notes an incredible
<a href="https://en.wikipedia.org/wiki/Lipogram">lipogram</a> story called
<a href="https://www.gutenberg.org/cache/epub/47342/pg47342.txt">Gadsby</a> which has no
letter E in the story. He did not note this but it has over 50000 (50 thousand)
(!!) words without the letter E which is one of the most common letters!</p>
letter <code>E</code> in the story. He did not note this but it has over <code>50000</code> (50
thousand) (!!) words without the letter <code>E</code> which is one of the most common
letters!</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>In literary circles, there is a poetic form called a “lipogram”,
which is a poem in which a specific letter has been distinctly
avoided. This principle can be applied in other ways. For
instance, in this paragraph, the vowel which immediately follows
<code>t</code> in the alphabet is nowhere to be seen. There is even an
entire novel (E. V. Wright’s “Gadsby”) in which no word contains
the letter <code>e</code>.</p>
<p>In literary circles, there is a poetic form called a
“<a href="https://en.wikipedia.org/wiki/Lipogram">lipogram</a>”, which is a poem in which a
specific letter has been distinctly avoided. This principle can be applied in
other ways. For instance, in this paragraph, the vowel which immediately
follows <code>t</code> in the alphabet is nowhere to be seen. There is even an entire
novel (E. V. Wright’s
“<a href="https://www.gutenberg.org/cache/epub/47342/pg47342.txt">Gadsby</a>”) in which no
word contains the letter <code>e</code>.</p>
<p>The IOCCC has been no stranger to this concept. Several winning entries from
years past have accomplished interesting feats while completely avoiding the use
of certain C constructs thought to be essential (e.g.,
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1988/robison/robison.c">1988/robison.c</a> file). If you have to ask why they would
do it this way, then this contest just isn’t for you.</p>
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1988/robison/robison.c">1988/robison.c</a> file). If you have to ask
why they would do it this way, then this contest just isn’t for you.</p>
<p>In continuing with this fine tradition, this program suggests to the ANSI
committee some new practical simplifications for the C language. For instance,
it appears that CONDITIONAL BRANCHING isn’t really necessary. So, we can do
+30 -27
View File
@@ -5,9 +5,8 @@
```
There is an alternate version of this entry that will work with macOS. See the
[Alternate code](#alternate-code) 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.
[Alternate code](#alternate-code) section below. We recommend you look at the
code at the last, even if you don't have a Mac.
## To use:
@@ -22,9 +21,9 @@ includes some interesting details about the entry.
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
(the details of which are relevant to the original entry that no longer works as
well as the fixed version but are described in the context of the macOS
well as the fixed version, but are described in the context of the macOS
adjustments). For details of what had to change, see [macos.html](macos.html).
Unless you wish to figure it out yourself, we recommend that you read this even
**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.
@@ -66,13 +65,12 @@ crufty internationalization support.
#### Historical note:
Some non-gcc compilers that were not fully ANSI standard did not
compile this entry correctly. Using cc by default was not helpful
most of the time on this entry, because the program had a hardcoded
gcc invocation anyway. Anyone who uses egcs and has no plain gcc
will need to frob the source anyway and can be expected to do the
right thing with `${CC}`. This limitation was removed in 2023 but in the past
one should have used gcc.
Some non-`gcc` compilers that were not fully ANSI standard did not compile this
entry correctly. Using cc by default was not helpful most of the time on this
entry, because the program had a hardcoded `gcc` invocation anyway. Anyone who
uses egcs and has no plain `gcc` will need to frob the source anyway and can be
expected to do the right thing with `${CC}`. This limitation was removed in 2023
but in the past one should have used `gcc`.
## Author's remarks:
@@ -109,12 +107,12 @@ itself. Just load it in your favorite editor.
`gcc` (the GNU C compiler) must be available at runtime. It is assumed that your
C implementation keeps headers as files in the `/usr/include` directory. The
[info](%%REPO_URL%%/1998/schweikh1/info) file must be readable and reside in the current working directory.
The current working directory must be writable in order to create a temporary
file (which is removed upon program termination). In case you don't have gcc at
runtime, not all is lost if your compiler or preprocessor can produce a list of
defined macros in the format output by `gcc -dM`, i.e. lines of the form
`#define MACRO value`.
[info](%%REPO_URL%%/1998/schweikh1/info) file must be readable and reside in the
current working directory. The current working directory must be writable in
order to create a temporary file (which is removed upon program termination). In
case you don't have gcc at runtime, not all is lost if your compiler or
preprocessor can produce a list of defined macros in the format output by `gcc
-dM`, i.e. lines of the form `#define MACRO value`.
Edit the source at line 55 in this case.
@@ -143,6 +141,12 @@ programs that may fail to compile due to syntax errors: supposing that
is expected to compile and meet the assertion. If it does not, your
compiler compiles some other language than ISO C.
### NOTICE to those who wish for a greater challenge:
**If you want a greater challenge, don't read any further**:
just try to understand the program via the source.
If you get stuck, come back and read below for additional hints and information.
### Why I think my program is obfuscated
@@ -271,17 +275,16 @@ To use, try:
```
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
use `indent` on the source. The code is extremely fragile because of the
myriads of `__LINE__` macros -- indenting is a sure way to break
the program. Don't even think of maintaining that beast; I've
had my share of core dumps during development :-) A test suite
was used after every minor change to find out if the program still
I have tried, as suggested in the [guidelines](../guidelines.txt), 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 use `indent` on
the source. The code is extremely fragile because of the myriads of `__LINE__`
macros -- indenting is a sure way to break the program. Don't even think of
maintaining that beast; I've had my share of core dumps during development :-) A
test suite was used after every minor change to find out if the program still
does what it should.
From the goals: "To stress C compilers with unusual code."
From the goals: "`To stress C compilers with unusual code.`"
That describes exactly my modest attempts...
+27 -27
View File
@@ -410,18 +410,17 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
<h2 id="to-build">To build:</h2>
<pre><code> make all</code></pre>
<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>
<a href="#alternate-code">Alternate code</a> section below. We recommend you look at the
code at the last, even if you don’t have a Mac.</p>
<h2 id="to-use">To use:</h2>
<pre><code> ./schweikh1</code></pre>
<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
(the details of which are relevant to the original entry that no longer works as
well as the fixed version but are described in the context of the macOS
well as the fixed version, but are described in the context of the macOS
adjustments). For details of what had to change, see <a href="macos.html">macos.html</a>.
Unless you wish to figure it out yourself, we recommend that you read this even
<strong>Unless you wish to figure it out yourself</strong>, 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>
<pre><code> make alt</code></pre>
@@ -444,13 +443,12 @@ Do not read them if you want to figure this out yourself. “Amendment
One” refers to “NA1”, the add-on to C89 which added some fairly
crufty internationalization support.</p>
<h4 id="historical-note">Historical note:</h4>
<p>Some non-gcc compilers that were not fully ANSI standard did not
compile this entry correctly. Using cc by default was not helpful
most of the time on this entry, because the program had a hardcoded
gcc invocation anyway. Anyone who uses egcs and has no plain gcc
will need to frob the source anyway and can be expected to do the
right thing with <code>${CC}</code>. This limitation was removed in 2023 but in the past
one should have used gcc.</p>
<p>Some non-<code>gcc</code> compilers that were not fully ANSI standard did not compile this
entry correctly. Using cc by default was not helpful most of the time on this
entry, because the program had a hardcoded <code>gcc</code> invocation anyway. Anyone who
uses egcs and has no plain <code>gcc</code> will need to frob the source anyway and can be
expected to do the right thing with <code>${CC}</code>. This limitation was removed in 2023
but in the past one should have used <code>gcc</code>.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>Important! This program, if it compiles at all, is mis-compiled by many
compilers due to compiler bugs. It could be the “least likely
@@ -474,12 +472,11 @@ itself. Just load it in your favorite editor.</p>
<h3 id="requirements">Requirements</h3>
<p><code>gcc</code> (the GNU C compiler) must be available at runtime. It is assumed that your
C implementation keeps headers as files in the <code>/usr/include</code> directory. The
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/info">info</a> file must be readable and reside in the current working directory.
The current working directory must be writable in order to create a temporary
file (which is removed upon program termination). In case you don’t have gcc at
runtime, not all is lost if your compiler or preprocessor can produce a list of
defined macros in the format output by <code>gcc -dM</code>, i.e. lines of the form
<code>#define MACRO value</code>.</p>
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/info">info</a> file must be readable and reside in the
current working directory. The current working directory must be writable in
order to create a temporary file (which is removed upon program termination). In
case you don’t have gcc at runtime, not all is lost if your compiler or
preprocessor can produce a list of defined macros in the format output by <code>gcc -dM</code>, i.e. lines of the form <code>#define MACRO value</code>.</p>
<p>Edit the source at line 55 in this case.</p>
<h3 id="background">Background</h3>
<p>ISO C has a very strict idea of visibility of identifiers. All possible
@@ -500,6 +497,10 @@ programs that may fail to compile due to syntax errors: supposing that
}</code></pre>
<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="notice-to-those-who-wish-for-a-greater-challenge">NOTICE to those who wish for a greater challenge:</h3>
<p><strong>If you want a greater challenge, don’t read any further</strong>:
just try to understand the program via the source.</p>
<p>If you get stuck, come back and read below for additional hints and information.</p>
<h3 id="why-i-think-my-program-is-obfuscated">Why I think my program is obfuscated</h3>
<p>Not only is the program’s purpose a thorough standard conformance
test, the source itself is a beast and has uncovered bugs in many
@@ -590,16 +591,15 @@ The advantages of an independent clean room approach…</p>
print length ($_),&quot;\n&quot;;</code></pre>
<p>To use, try:</p>
<pre><code> perl ./charcount.pl schweikh1.c</code></pre>
<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
use <code>indent</code> on the source. The code is extremely fragile because of the
myriads of <code>__LINE__</code> macros – indenting is a sure way to break
the program. Don’t even think of maintaining that beast; I’ve
had my share of core dumps during development :-) A test suite
was used after every minor change to find out if the program still
<p>I have tried, as suggested in the <a href="../guidelines.txt">guidelines</a>, 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 use <code>indent</code> on
the source. The code is extremely fragile because of the myriads of <code>__LINE__</code>
macros – indenting is a sure way to break the program. Don’t even think of
maintaining that beast; I’ve had my share of core dumps during development :-) A
test suite was used after every minor change to find out if the program still
does what it should.</p>
<p>From the goals: “To stress C compilers with unusual code.”
<p>From the goals: “<code>To stress C compilers with unusual code.</code>”
That describes exactly my modest attempts…</p>
<!--
+19 -6
View File
@@ -389,11 +389,18 @@
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- BEFORE: 1st line of markdown file: 1998/schweikh1/macos.md -->
<h1 id="introduction-to-this-document">Introduction to this document:</h1>
<p>This document describes how this was fixed to work with macOS as well as some of
the magic in the entry. Even if you don’t have a Mac it might be worth your time
reading especially as some of it details some important fixes and changes in the
original entry as well.</p>
<h1 id="macos-changes">macOS changes</h1>
<h2 id="notice-to-those-who-wish-for-a-greater-challenge">NOTICE to those who wish for a greater challenge:</h2>
<p><strong>If you want a greater challenge, don’t read any further</strong>:
just try to understand the program via the source.</p>
<p>If you get stuck, come back and read below for additional hints and information.
Of course, if you do not have a Mac the code might make less sense, so you might
just wish to read this in that case, should you wish to understand it.</p>
<h1 id="macos-aside">macOS aside:</h1>
<p>As an aside: if you have a Mac with the Apple chip, some of the header files
will report an unsupported architecture and unsupported compiler (error,
warning). This will not make the program abort, however, but even with an Intel
@@ -401,20 +408,26 @@ CPU though, the original entry will not work in macOS as it stands because
<code>/usr/include</code> is hard-coded in the code and macOS does not have it.</p>
<p>Nevertheless, although some of it would not work in other systems where
<code>/usr/include</code> exists, the <code>#define</code>s would still be found okay, at least until
a file was not found (this limitation was removed in both versions in 2023). see</p>
a file was not found (this limitation was removed in both versions in 2023).</p>
<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>
<pre><code> sudo xcode-select --install</code></pre>
<h1 id="important-point-about-the-hard-coded-compiler">Important point about the hard-coded compiler:</h1>
<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>
existing (though it’s <code>clang</code>) in macOS; instead it is <code>cc</code>.</p>
<h1 id="how-this-entry-works-the-magic">How this entry works (the magic):</h1>
<p>Now as far as how this works if you look at the code of
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.c">schweikh1.c</a>, on line 55 you’ll see a funny command (this goes for
the alternate version as well but a bit different).</p>
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.c">schweikh1.c</a>, on <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.c#L55">line
55</a> you’ll see a funny command
(this goes for the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.alt.c">alternate
version</a>, also on <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.c#L55">line
55</a>, but the command is necessarily
different).</p>
<p>Now the key is two magic numbers, one (two times) on a different line shortly below the
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
<p>In the original the numbers are, respectively, <code>44</code> and <code>46</code>, but with the <code>gcc</code>
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>
+25 -6
View File
@@ -1,9 +1,20 @@
# Introduction to this document:
This document describes how this was fixed to work with macOS as well as some of
the magic in the entry. Even if you don't have a Mac it might be worth your time
reading especially as some of it details some important fixes and changes in the
original entry as well.
# macOS changes
## NOTICE to those who wish for a greater challenge:
**If you want a greater challenge, don't read any further**:
just try to understand the program via the source.
If you get stuck, come back and read below for additional hints and information.
Of course, if you do not have a Mac the code might make less sense, so you might
just wish to read this in that case, should you wish to understand it.
# macOS aside:
As an aside: if you have a Mac with the Apple chip, some of the header files
will report an unsupported architecture and unsupported compiler (error,
@@ -13,7 +24,7 @@ CPU though, the original entry will not work in macOS as it stands because
Nevertheless, although some of it would not work in other systems where
`/usr/include` exists, the `#define`s would still be found okay, at least until
a file was not found (this limitation was removed in both versions in 2023). see
a file was not found (this limitation was removed in both versions in 2023).
However, as noted, macOS does **not** have `/usr/include` so this would never
work for macOS without some changes, described next. For macOS you will need the
@@ -23,18 +34,26 @@ command line tools installed which can be done like:
sudo xcode-select --install
```
# Important point about the hard-coded compiler:
An important point is that the original version hard-coded `gcc` but just like
the entry, the alternate version has also removed this limitation despite `gcc`
existing (though it's `clang`) in macOS.
existing (though it's `clang`) in macOS; instead it is `cc`.
# How this entry works (the magic):
Now as far as how this works if you look at the code of
[schweikh1.c](%%REPO_URL%%/1998/schweikh1/schweikh1.c), on line 55 you'll see a funny command (this goes for
the alternate version as well but a bit different).
[schweikh1.c](%%REPO_URL%%/1998/schweikh1/schweikh1.c), on [line
55](%%REPO_URL%%/1998/schweikh1/schweikh1.c#L55) you'll see a funny command
(this goes for the [alternate
version](%%REPO_URL%%/1998/schweikh1/schweikh1.alt.c), also on [line
55](%%REPO_URL%%/1998/schweikh1/schweikh1.c#L55), but the command is necessarily
different).
Now the key is two magic numbers, one (two times) on a different line shortly below the
string and the other a couple lines further below.
In the original the numbers are, respectively, `44` and `46`, but with the gcc
In the original the numbers are, respectively, `44` and `46`, but with the `gcc`
limitation removed the numbers now are `43` and `45`. But how does this work? Well
the command is:
+9 -1
View File
@@ -137,6 +137,14 @@ and now it works with both clang and gcc.
## Author's remarks:
### NOTICE to those who wish for a greater challenge:
**If you want a greater challenge, don't read any further**:
just try to understand the program via the source.
If you get stuck, come back and read below for additional hints and information.
### What this program does
My entry is a `yarng`, which stands for, you guessed it, yet another
@@ -167,7 +175,7 @@ For example:
### Why I think this is obfuscated
- Ever seen a 'do for ... while' loop?
- Ever seen a `do for ... while` loop?
- I avoided `int` like the plague. Instead I used storage class specifiers
(`register`, `auto`) to get implicit `int`. The Standard allows implicit `int` even in
+5 -1
View File
@@ -472,6 +472,10 @@ compiler error:</p>
<pre><code> #line 10 ONE(O(1,1,2,6,0,6))</code></pre>
<p>and now it works with both clang and gcc.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="notice-to-those-who-wish-for-a-greater-challenge">NOTICE to those who wish for a greater challenge:</h3>
<p><strong>If you want a greater challenge, don’t read any further</strong>:
just try to understand the program via the source.</p>
<p>If you get stuck, come back and read below for additional hints and information.</p>
<h3 id="what-this-program-does">What this program does</h3>
<p>My entry is a <code>yarng</code>, which stands for, you guessed it, yet another
random number generator, and is pronounced ‘yawn’ due to its
@@ -496,7 +500,7 @@ different values? How long would you need for an empirical test?</p>
10011</code></pre>
<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>
<li><p>Ever seen a <code>do for ... while</code> loop?</p></li>
<li><p>I avoided <code>int</code> like the plague. Instead I used storage class specifiers
(<code>register</code>, <code>auto</code>) to get implicit <code>int</code>. The Standard allows implicit <code>int</code> even in
casts as you can see in <code>(void(*)(register))main</code>. Where implicit <code>int</code> is
+17 -10
View File
@@ -6,14 +6,12 @@
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](%%REPO_URL%%/1998/schweikh3/schweikh3.c#L31).
An alternate version allows one to fix this; see [alternate
An alternate version allows one to fix this; see [Alternate
code](#alternate-code) below.
@@ -78,10 +76,11 @@ The source is expected to conform to IEEE Std 1003.1-1990 ("POSIX").
Thank God the IEEE does not standardize a coding style...
### What this program does
### What this program does
This is best explained in the man page. The troff source for this
man page can be found in the file [samefile.1](%%REPO_URL%%/1998/schweikh3/samefile.1). To render try:
This is best explained in the man page. The troff source for this man page can
be found in the file [samefile.1](%%REPO_URL%%/1998/schweikh3/samefile.1). To
render try:
``` <!---sh-->
`man ./samefile.1
@@ -207,6 +206,14 @@ otherwise.
`find(1)`, `ln(1)`, `rm(1)`
### NOTICE to those who wish for a greater challenge
**If you want a greater challenge, don't read any further**:
just try to understand the program via the source.
If you get stuck, come back and read below for additional hints and information.
### Why I think it is obfuscated
- The code is commented but this gives only an *extremely* faint clue.
+13 -7
View File
@@ -410,11 +410,12 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
<h2 id="to-build">To build:</h2>
<pre><code> make all</code></pre>
<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>
<p>An alternate version allows one to fix this; see <a href="#alternate-code">alternate
<blockquote>
<p>In the remote event that the input has more than <code>8192</code> files with the same
size (on systems where <code>sizeof (char *) == 4</code>, or <code>4096</code> when <code>sizeof (char *) == 8</code>), increase the manifest constant 32767 on <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh3/schweikh3.c#L31">line
31</a>.</p>
</blockquote>
<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
@@ -446,8 +447,9 @@ the tool as well at <a href="http://www.schweikhardt.net/samefile" class="uri">h
<p>The source is expected to conform to IEEE Std 1003.1-1990 (“POSIX”).
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="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh3/samefile.1">samefile.1</a>. To render try:</p>
<p>This is best explained in the man page. The troff source for this man page can
be found in the file <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh3/samefile.1">samefile.1</a>. To
render try:</p>
<pre><code> `man ./samefile.1</code></pre>
<p>Otherwise:</p>
<h3 id="samefile1-user-manuals-samefile1">SAMEFILE(1) User Manuals SAMEFILE(1)</h3>
@@ -524,6 +526,10 @@ How much space is wasted below our site’s /pub directory?</p>
otherwise.</p>
<h4 id="see-also">SEE ALSO</h4>
<p><code>find(1)</code>, <code>ln(1)</code>, <code>rm(1)</code></p>
<h3 id="notice-to-those-who-wish-for-a-greater-challenge">NOTICE to those who wish for a greater challenge</h3>
<p><strong>If you want a greater challenge, don’t read any further</strong>:
just try to understand the program via the source.</p>
<p>If you get stuck, come back and read below for additional hints and information.</p>
<h3 id="why-i-think-it-is-obfuscated">Why I think it is obfuscated</h3>
<ul>
<li>The code is commented but this gives only an <em>extremely</em> faint clue.</li>
+4 -1
View File
@@ -1,7 +1,10 @@
.\"
.\" To format this file into a text file say
.\"
.\" nroff -man samefile.1 or
.\" nroff -man samefile.1
.\"
.\" or
.\"
.\" groff -man -Tascii samefile.1
.\"
.TH SAMEFILE 1 "OCTOBER 1997" IOCCC "User Manuals"
+4 -1
View File
@@ -1,7 +1,10 @@
.\"
.\" To format this file into a text file say
.\"
.\" nroff -man samefile.1 or
.\" nroff -man samefile.1
.\"
.\" or
.\"
.\" groff -man -Tascii samefile.1
.\"
.TH SAMEFILE 1 "OCTOBER 1997" IOCCC "User Manuals"
+57 -33
View File
@@ -13,14 +13,18 @@
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:
@@ -39,18 +43,28 @@ archiver that uses the CRC-32 algorithm.
## Author's remarks:
```
Usage:
./tomtorfs filename bitwidth polynom reflected init xor
Usage:
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)
``` <!---sh-->
./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)
### Examples
@@ -116,24 +130,34 @@ readable.
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
in the `b[]` array. The third parameter to `strtoul(3)` causes
+109 -31
View File
@@ -412,12 +412,32 @@ Location: <a href="../../location.html#BE">BE</a> - <em>Kingdom of Belgium</em>
<h2 id="to-use">To use:</h2>
<pre><code> ./tomtorfs filename bitwidth polynom reflected init xor</code></pre>
<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>
<ul>
<li><code>filename</code>
<ul>
<li>file to calculate the CRC of</li>
</ul></li>
<li><code>bitwidth</code>
<ul>
<li>width of the CRC in bits (decimal)</li>
</ul></li>
<li><code>polynom</code>
<ul>
<li>polynomial used for the CRC (hexadecimal)</li>
</ul></li>
<li><code>reflected</code>
<ul>
<li>0 if the CRC is not reflected, 1 if it is</li>
</ul></li>
<li><code>init</code>
<ul>
<li>initial value for the CRC (hexadecimal)</li>
</ul></li>
<li><code>xor</code>
<ul>
<li>value to xor the final CRC with (hexadecimal)</li>
</ul></li>
</ul>
<h2 id="try">Try:</h2>
<pre><code> ./try.sh</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
@@ -425,15 +445,35 @@ Location: <a href="../../location.html#BE">BE</a> - <em>Kingdom of Belgium</em>
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
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>
<p>Usage:</p>
<pre><code> ./tomtorfs filename bitwidth polynom reflected init xor</code></pre>
<p>where:</p>
<ul>
<li><code>filename</code>
<ul>
<li>file to calculate the CRC of</li>
</ul></li>
<li><code>bitwidth</code>
<ul>
<li>width of the CRC in bits (decimal)</li>
</ul></li>
<li><code>polynom</code>
<ul>
<li>polynomial used for the CRC (hexadecimal)</li>
</ul></li>
<li><code>reflected</code>
<ul>
<li>0 if the CRC is not reflected, 1 if it is</li>
</ul></li>
<li><code>init</code>
<ul>
<li>initial value for the CRC (hexadecimal)</li>
</ul></li>
<li><code>xor</code>
<ul>
<li>value to xor the final CRC with (hexadecimal)</li>
</ul></li>
</ul>
<h3 id="examples">Examples</h3>
<h4 id="crc-16">CRC-16:</h4>
<pre><code> ./tomtorfs filename 16 1021 0 FFFF 0000</code></pre>
@@ -461,22 +501,60 @@ 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
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
C = typedef for unsigned long</code></pre>
<ul>
<li><code>a</code>
<ul>
<li>argc</li>
</ul></li>
<li><code>A</code>
<ul>
<li>argv</li>
</ul></li>
<li><code>b</code>
<ul>
<li>array of <code>unsigned long</code> variables:</li>
<li><code>b[0]</code>
<ul>
<li>bit-width of the CRC (<code>argv[2]</code>)</li>
</ul></li>
<li><code>b[1]</code>
<ul>
<li>CRC polynomial (<code>argv[3]</code>)</li>
</ul></li>
<li><code>b[2]</code>
<ul>
<li>nonzero if CRC is reflected (argv[4])</li>
</ul></li>
<li><code>b[3]</code>
<ul>
<li>initial value of CRC (argv[5])</li>
</ul></li>
<li><code>b[4]</code>
<ul>
<li>value final CRC is XORed with (argv[6])</li>
</ul></li>
<li><code>b[5]</code>
<ul>
<li>CRC value</li>
</ul></li>
<li><code>b[6]</code>
<ul>
<li>byte from file</li>
</ul></li>
<li><code>b[7]</code>
<ul>
<li>counter</li>
</ul></li>
</ul></li>
<li><code>B</code>
<ul>
<li><code>FILE *</code> through which the file <code>argv[1]</code> is opened</li>
</ul></li>
<li><code>C</code>
<ul>
<li><code>typedef</code> for <code>unsigned long</code></li>
</ul></li>
</ul>
<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,