add hack-a-round for language specified markdown code blocks
When language is specified in a markdown code block such as:
````
```c
printf("Hello, world!\n");
```
````
is used, the resulting HTML as produced by `pandoc(1)` combined
with our revised `ioccc.css` is not intent the code block well.
A temporary "_hack-a-round_" is to turn the "markdown code language
specifier" into an HTML comment. For example:
````
```<!---c-->
printf("Hello, world!\n");
```
````
This commits turns off existing markdown code language specifiers
for now, while preserving our ability to restore them in the future
when a better "_hack-a-round_" to the "markdown code language
specifier" problem is found.
The HTML impact if this "_hack-a-round_" is to produce HTML that
looks like this:
```
<pre class="<!---c-->"><code> .. </code></pre>
```
We might be able to create a complex set of classes for each markdown
code language (there won't be very many) in `ioccc.css`, or we might
find a more general CSS (or maybe `pandoc(1)`?) solution.
For now, this hack-a-round will have to do.
This commit is contained in:
1 parent
3919df50fb
commit
b66c79254a
700 files changed
+7052
-7056
No files matched your search
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
@@ -34,14 +34,14 @@ macros to, depending on what controls you wish to redefine. For instance, to set
|
||||
the throttle up and down to `u` and `d`:
|
||||
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
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
|
||||
```<!---c-->
|
||||
#define XK_d 0x0064 /* U+0064 LATIN SMALL LETTER D */
|
||||
#define XK_u 0x0075 /* U+0075 LATIN SMALL LETTER U */
|
||||
```
|
||||
@@ -63,7 +63,7 @@ preselected alternative keys.
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat horizon.sc pittsburgh.sc | ./banks
|
||||
```
|
||||
|
||||
@@ -106,7 +106,7 @@ the right side for movement. These are hard coded, as noted.
|
||||
|
||||
To use the default settings for the alternate build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
@@ -231,7 +231,7 @@ Here is a brief description of the scenery files:
|
||||
|
||||
A few examples of how to input scenery:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
cat horizon.sc pittsburgh.sc | ./banks
|
||||
cat mountains.sc bb.sc | ./banks
|
||||
cat mountains.sc river.sc pyramids.sc | ./banks
|
||||
@@ -240,7 +240,7 @@ A few examples of how to input scenery:
|
||||
You can simulate flying through a cloud bank as well:
|
||||
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./banks < /dev/null
|
||||
```
|
||||
|
||||
|
||||
+10
-10
@@ -141,7 +141,7 @@ 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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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
|
||||
@@ -164,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>
|
||||
<pre class="<!---sh-->"><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>
|
||||
<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>
|
||||
<pre class="<!---c-->"><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="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
|
||||
@@ -181,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>
|
||||
<pre class="<!---sh-->"><code> cat horizon.sc pittsburgh.sc | ./banks</code></pre>
|
||||
<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>
|
||||
@@ -208,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>
|
||||
<pre class="<!---sh-->"><code> make alt</code></pre>
|
||||
<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>
|
||||
@@ -289,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>
|
||||
<pre class="<!---sh-->"><code> cat horizon.sc pittsburgh.sc | ./banks
|
||||
cat mountains.sc bb.sc | ./banks
|
||||
cat mountains.sc river.sc pyramids.sc | ./banks</code></pre>
|
||||
<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"><</span> /dev/null</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./banks < /dev/null</code></pre>
|
||||
<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
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./bas1.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -141,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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./bas1.sh</code></pre>
|
||||
<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
|
||||
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./bas2 < file
|
||||
echo text | ./bas2
|
||||
```
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
|
||||
./try.sh "foo bar" "baz" "IOCCC 1998/bas2" README.md
|
||||
|
||||
@@ -141,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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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"><</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>
|
||||
<pre class="<!---sh-->"><code> ./bas2 < file
|
||||
echo text | ./bas2</code></pre>
|
||||
<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>
|
||||
<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">"foo bar"</span> <span class="st">"baz"</span> <span class="st">"IOCCC 1998/bas2"</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">"bas2.c"</span> bas2.orig.c</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./try.sh
|
||||
|
||||
./try.sh "foo bar" "baz" "IOCCC 1998/bas2" README.md
|
||||
|
||||
./try.sh try.sh "bas2.c" bas2.orig.c</code></pre>
|
||||
<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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make chaos
|
||||
```
|
||||
|
||||
@@ -8,21 +8,21 @@ NOTE: Some systems do not implement `halfdelay()` in their `libcurses`.
|
||||
You might try compiling with -lncurses if you have that library.
|
||||
Or you can build this entry without the `halfdelay()` call by:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make chaos_nohalf
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./chaos
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -141,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>
|
||||
<pre class="<!---sh-->"><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.
|
||||
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>
|
||||
<pre class="<!---sh-->"><code> make chaos_nohalf</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./chaos</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>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<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
@@ -1,20 +1,20 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./df
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
+3
-3
@@ -141,11 +141,11 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></l
|
||||
<!-- 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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./df</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<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>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
@@ -10,7 +10,7 @@ below for more details.
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./dlowe < file > pootfile
|
||||
|
||||
./dlowe < file
|
||||
@@ -30,7 +30,7 @@ For more detailed information see [1998 dlowe bugs](../../bugs.html#1998_dlowe).
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./dlowe < README.md
|
||||
./dlowe < README.md > README.poot.md
|
||||
```
|
||||
@@ -39,7 +39,7 @@ Why is there different output?
|
||||
|
||||
Also try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -54,7 +54,7 @@ that program.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
@@ -70,7 +70,7 @@ What's the difference between this and `dlowe`?
|
||||
|
||||
### Alternate try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.alt.sh
|
||||
```
|
||||
|
||||
@@ -93,7 +93,7 @@ more consistent level of quality. :-)
|
||||
|
||||
A CGI script such as:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
#!/bin/sh
|
||||
# pootify - a sample CGI pootifier
|
||||
#
|
||||
@@ -131,7 +131,7 @@ should use the above one instead. You can use the script
|
||||
[pootify.sh](pootify.sh), however, to download and generate html files that you
|
||||
can look at locally in a browser or pipe through `less(1)`. For instance:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./pootify.sh URL=https://microsoft.com | less
|
||||
|
||||
./pootify.sh -r URL=https://microsoft.com > ms.html
|
||||
@@ -143,7 +143,7 @@ it in a browser.
|
||||
|
||||
For an old example of it working as a CGI script see:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org
|
||||
```
|
||||
|
||||
|
||||
+34
-34
@@ -141,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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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"><</span> file <span class="op">></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"><</span> file</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./dlowe < file > pootfile
|
||||
|
||||
./dlowe < file</code></pre>
|
||||
<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>
|
||||
<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"><</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"><</span> README.md <span class="op">></span> README.poot.md</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./dlowe < README.md
|
||||
./dlowe < README.md > README.poot.md</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> make alt</code></pre>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<pre><code> ./dlowe.alt < file > 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>
|
||||
<pre class="<!---sh-->"><code> ./try.alt.sh</code></pre>
|
||||
<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
|
||||
@@ -179,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">"/usr/local/bin/dlowe"</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">"/usr/local/bin/lynx"</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">"/usr/bin/echo"</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">"/usr/bin/expr"</span></span>
|
||||
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> <span class="va">${ECHO}</span> <span class="st">"Content-type: text/html"</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">"</span><span class="va">${QUERY_STRING}</span><span class="st">"</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">"QUERY_STRING not found"</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">"</span><span class="va">$QUERY_STRING</span><span class="st">"</span> : <span class="st">'[Uu][Rr][Ll]=\(.*\)'</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">"</span><span class="va">${URL}</span><span class="st">"</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">"No URL given in QUERY_STRING"</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">"</span><span class="va">${URL}</span><span class="st">"</span> : <span class="st">'[Ff][Ii][Ll][Ee]:'</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">"file: based URLs are not allowed"</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">"</span><span class="va">${URL}</span><span class="st">"</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>
|
||||
<pre class="<!---sh-->"><code> #!/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"
|
||||
else
|
||||
${LYNX} -restrictions=all -source "${URL}" | ${POOT}
|
||||
fi
|
||||
fi</code></pre>
|
||||
<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,
|
||||
@@ -212,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>
|
||||
<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">></span> ms.html</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./pootify.sh URL=https://microsoft.com | less
|
||||
|
||||
./pootify.sh -r URL=https://microsoft.com > ms.html</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org</code></pre>
|
||||
<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>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
@@ -22,7 +22,7 @@ For more detailed information see [1998 dloweneil bugs](../../bugs.html#1998_dlo
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./pootris [X size of board] [Y size of board]
|
||||
```
|
||||
|
||||
@@ -45,14 +45,14 @@ clockwise `l` does as well. Instead of using `d` to drop the letter you can do
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
### Alternate use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./pootris.alt [X size of board] [Y size of board]
|
||||
```
|
||||
|
||||
@@ -73,7 +73,7 @@ experience may mirror one of our experiences:
|
||||
|
||||
### Usage
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./pootris [X size of board] [Y size of board]
|
||||
```
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></l
|
||||
<!-- 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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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>
|
||||
@@ -153,7 +153,7 @@ code</a> below.</p>
|
||||
<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 class="ex">./pootris</span> [X size of board] [Y size of board]</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./pootris [X size of board] [Y size of board]</code></pre>
|
||||
<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
|
||||
@@ -165,9 +165,9 @@ 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>
|
||||
<pre class="<!---sh-->"><code> make alt</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./pootris.alt [X size of board] [Y size of board]</code></pre>
|
||||
<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>
|
||||
@@ -176,7 +176,7 @@ experience may mirror one of our experiences:</p>
|
||||
I spelled my first "poot". 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>
|
||||
<pre class="<!---sh-->"><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
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./dorssel
|
||||
# input some text
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -48,7 +48,7 @@ altering the behavior ?
|
||||
Try doing what the last part of the last command in [try.sh](try.sh) suggests.
|
||||
As in, do the following:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
echo ". -..- . .-. -.-. .. ... .
|
||||
-.-. .... .- -. --. . - .... . .--. .-. --- --. .-. .- -- ... --- .. - -.. --- . ... -. --- - ... .... --- ..- -" | ./dorssel
|
||||
```
|
||||
@@ -91,7 +91,7 @@ invoke undefined behavior.
|
||||
|
||||
Try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./dorssel < dorssel.c | ./dorssel
|
||||
```
|
||||
|
||||
@@ -101,20 +101,20 @@ better job than most C beautifiers).
|
||||
- Filter your text twice (as in the previous sample) to obtain a version of your
|
||||
text that can be reversibly Morsified, i.e.
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./dorssel < dorssel.c | ./dorssel | ./dorssel | ./dorssel
|
||||
```
|
||||
|
||||
is the same as
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./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
|
||||
```<!---sh-->
|
||||
./dorssel < dorssel.md
|
||||
```
|
||||
|
||||
|
||||
+15
-15
@@ -150,11 +150,11 @@ two bits would suffice, e.g.</p>
|
||||
<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">&</span> <span class="dv">96</span><span class="op">)</span> <span class="op">>></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">&</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">'-'</span> <span class="op">:</span> <span class="ch">'.'</span><span class="op">);</span></span>
|
||||
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">>>=</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>
|
||||
<pre class="<!---c-->"><code> length = (encoding & 96) >> 5;
|
||||
do {
|
||||
putchar(encoding & 1 ? '-' : '.');
|
||||
encoding >>= 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 > 00000.11
|
||||
length 2: 0000.1xx
|
||||
@@ -162,10 +162,10 @@ counter before shifting out each symbol, such as</p>
|
||||
length 4: 00.1xxxx Z > 00.11100
|
||||
length 5: 0.1xxxxx 3 > 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">&</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">'-'</span> <span class="op">:</span> <span class="ch">'.'</span><span class="op">);</span></span>
|
||||
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> encoding <span class="op">>>=</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">></span> <span class="dv">1</span><span class="op">);</span></span></code></pre></div>
|
||||
<pre class="<!---c-->"><code> do {
|
||||
putchar(encoding & 1 ? '-' : '.');
|
||||
encoding >>= 1;
|
||||
while (encoding > 1);</code></pre>
|
||||
<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 < 32, i.e. they will be control codes. This would make
|
||||
@@ -179,21 +179,21 @@ following</p>
|
||||
<p>Notice these encodings in the initialization string. Only the coding for
|
||||
<code>5</code> needs an escape (<code>5 = ..... > 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">&</span> <span class="dv">1</span> <span class="op">?</span> <span class="ch">'-'</span> <span class="op">:</span> <span class="ch">'.'</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">>></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">></span> <span class="dv">35</span><span class="op">);</span></span></code></pre></div>
|
||||
<pre class="<!---c-->"><code> do {
|
||||
putchar(encoding & 1 ? '-' : '.');
|
||||
encoding = (encoding + 32) >> 1;
|
||||
} while (encoding > 35);</code></pre>
|
||||
<p>The last shift will always result in <code>00100010</code>, hence the test for <code>>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><= 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>
|
||||
<pre class="<!---c-->"><code> putchar(45 + encoding % 2);</code></pre>
|
||||
<p>I used the modulo operator this time, because <code>+</code> takes precedence over <code>&</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">>></span> <span class="dv">1</span><span class="op">);</span></span></code></pre></div>
|
||||
<pre class="<!---c-->"><code> while(putchar(45 + encoding % 2), encoding = encoding + 32 >> 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
|
||||
|
||||
@@ -42,7 +42,7 @@ 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
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
length = (encoding & 96) >> 5;
|
||||
do {
|
||||
putchar(encoding & 1 ? '-' : '.');
|
||||
@@ -62,7 +62,7 @@ We can also use the remaining bits to *include* the counter
|
||||
|
||||
with 1 bit still to be chosen freely (let's assume it is 0). Now we can do
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
do {
|
||||
putchar(encoding & 1 ? '-' : '.');
|
||||
encoding >>= 1;
|
||||
@@ -87,7 +87,7 @@ Notice these encodings in the initialization string. Only the coding for
|
||||
`5` needs an escape (`5 = ..... > 01111111 = '\177'`). The way the length
|
||||
is encoded still allows the encoding to be its own counter:
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
do {
|
||||
putchar(encoding & 1 ? '-' : '.');
|
||||
encoding = (encoding + 32) >> 1;
|
||||
@@ -101,7 +101,7 @@ 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
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
putchar(45 + encoding % 2);
|
||||
```
|
||||
|
||||
@@ -110,7 +110,7 @@ The assignment can be incorporated into the `while` control test, and a
|
||||
`do-while` loop with a body of a single expression statement can be written
|
||||
as a `while` loop with a comma operator in the test:
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
while(putchar(45 + encoding % 2), encoding = encoding + 32 >> 1);
|
||||
```
|
||||
|
||||
|
||||
+12
-12
@@ -141,14 +141,14 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></l
|
||||
<!-- 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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./dorssel
|
||||
# input some text
|
||||
|
||||
echo text | ./dorssel</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<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
|
||||
@@ -166,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">". -..- . .-. -.-. .. ... .</span></span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="st"> -.-. .... .- -. --. . - .... . .--. .-. --- --. .-. .- -- ... --- .. - -.. --- . ... -. --- - ... .... --- ..- -"</span> <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> echo ". -..- . .-. -.-. .. ... .
|
||||
-.-. .... .- -. --. . - .... . .--. .-. --- --. .-. .- -- ... --- .. - -.. --- . ... -. --- - ... .... --- ..- -" | ./dorssel</code></pre>
|
||||
<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>
|
||||
@@ -195,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"><</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./dorssel < dorssel.c | ./dorssel</code></pre>
|
||||
<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"><</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>
|
||||
<pre class="<!---sh-->"><code> ./dorssel < dorssel.c | ./dorssel | ./dorssel | ./dorssel</code></pre>
|
||||
<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"><</span> dorssel.c <span class="kw">|</span> <span class="ex">./dorssel</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./dorssel < dorssel.c | ./dorssel</code></pre>
|
||||
<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"><</span> dorssel.md</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./dorssel < dorssel.md</code></pre>
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
@@ -10,7 +10,7 @@ this entry because of the system resources it requires.
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./fanf
|
||||
```
|
||||
|
||||
@@ -19,7 +19,7 @@ this entry because of the system resources it requires.
|
||||
|
||||
Enter an expression on standard input. To try some we have selected:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -47,7 +47,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
|
||||
```<!---sh-->
|
||||
cc fanf.c -E > fanftmp1.c
|
||||
```
|
||||
|
||||
|
||||
@@ -141,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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./fanf</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<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>
|
||||
@@ -165,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">></span> fanftmp1.c</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> cc fanf.c -E > fanftmp1.c</code></pre>
|
||||
<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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ For more detailed information see [1998 schnitzi bugs](../../bugs.html#1998_schn
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./schnitzi n > sort.c
|
||||
make sort
|
||||
./sort
|
||||
@@ -32,14 +32,14 @@ where `n` and `x`, `y` and `z` are numbers.
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
What happens if at the command line you don't specify `n` numbers that the
|
||||
program expects? For instance try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./schnitzi 5 > sort.c
|
||||
make sort
|
||||
|
||||
@@ -99,7 +99,7 @@ a depth of one.
|
||||
So what does it do? Give it an integer `(1 < n < 27)` on the command
|
||||
line, such as
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./schnitzi 5
|
||||
```
|
||||
|
||||
@@ -109,7 +109,7 @@ them, however, using only `if/else` statements, without arrays or
|
||||
looping. To see the resulting program run, redirect the output from
|
||||
`schnitzi` into another file, like this
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./schnitzi 4 > sort.c
|
||||
```
|
||||
|
||||
|
||||
+15
-15
@@ -141,28 +141,28 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></l
|
||||
<!-- 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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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>
|
||||
<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">></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>
|
||||
<pre class="<!---sh-->"><code> ./schnitzi n > sort.c
|
||||
make sort
|
||||
./sort
|
||||
# enter three numbers, space separated
|
||||
|
||||
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>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<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">></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>
|
||||
<pre class="<!---sh-->"><code> ./schnitzi 5 > sort.c
|
||||
make sort
|
||||
|
||||
# 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
|
||||
@@ -201,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 < n < 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>
|
||||
<pre class="<!---sh-->"><code> ./schnitzi 5</code></pre>
|
||||
<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">></span> sort.c</span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> ./schnitzi 4 > sort.c</code></pre>
|
||||
<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
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
@@ -12,7 +12,7 @@ includes some interesting details about the entry.
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./schweikh1
|
||||
```
|
||||
|
||||
@@ -30,7 +30,7 @@ if you don't have a Mac as it has some interesting details about the entry.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
@@ -126,7 +126,7 @@ macros can be defined, because you could write strictly conforming
|
||||
programs that may fail to compile due to syntax errors: supposing that
|
||||
`<stdio.h>` defines `PIPE_BUF`, then the conforming
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
#include <assert.h>
|
||||
#include <stdio.h> /* <- or where the bogus macro is defined */
|
||||
#include <string.h>
|
||||
@@ -155,7 +155,7 @@ C compilers.
|
||||
must resemble one of the canonical forms, `"foo.h"` or `<bar.h>`.
|
||||
This lets us write things like
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
#define HEADER "foo.h"
|
||||
#include HEADER
|
||||
```
|
||||
@@ -164,7 +164,7 @@ C compilers.
|
||||
torturing the preprocessor a little more, by using token pasting,
|
||||
at least one compiler falls over.
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
#define H(x) <st##x##.h>
|
||||
#include H(dio) /* expands to <stdio.h> */
|
||||
```
|
||||
@@ -187,7 +187,7 @@ C compilers.
|
||||
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
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
#include <stdio.h>
|
||||
#line 42 "foo\0bar"
|
||||
int main (void) {
|
||||
@@ -214,7 +214,7 @@ C compilers.
|
||||
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
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
case <some_token>:
|
||||
case <some_token>:
|
||||
```
|
||||
@@ -255,7 +255,7 @@ script to compute the character count according to the rules.
|
||||
The advantages of an independent clean room approach...
|
||||
|
||||
|
||||
```perl
|
||||
```<!---perl-->
|
||||
#!/usr/bin/perl -w
|
||||
$/ = "\0";
|
||||
$_ = <>;
|
||||
@@ -266,7 +266,7 @@ The advantages of an independent clean room approach...
|
||||
|
||||
To use, try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
perl ./charcount.pl schweikh1.c
|
||||
```
|
||||
|
||||
|
||||
+33
-33
@@ -141,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>
|
||||
<pre class="<!---sh-->"><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>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><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
|
||||
@@ -157,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>
|
||||
<pre class="<!---sh-->"><code> make alt</code></pre>
|
||||
<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>
|
||||
@@ -220,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><stdio.h></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"><assert.h></span></span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im"><stdio.h></span><span class="pp"> </span><span class="co">/* <- 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"><string.h></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">"PIPE_BUF"</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>
|
||||
<pre class="<!---c-->"><code> #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;
|
||||
}</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="why-i-think-my-program-is-obfuscated">Why I think my program is obfuscated</h3>
|
||||
@@ -243,13 +243,13 @@ C compilers.</p>
|
||||
must resemble one of the canonical forms, <code>"foo.h"</code> or <code><bar.h></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">"foo.h"</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>
|
||||
<pre class="<!---c-->"><code> #define HEADER "foo.h"
|
||||
#include HEADER</code></pre>
|
||||
<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"><</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">></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 <stdio.h> */</span></span></code></pre></div>
|
||||
<pre class="<!---c-->"><code> #define H(x) <st##x##.h>
|
||||
#include H(dio) /* expands to <stdio.h> */</code></pre>
|
||||
<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
|
||||
@@ -264,12 +264,12 @@ 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"><stdio.h></span></span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#line 42 "foo\0bar"</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">"</span><span class="sc">%s</span><span class="st"> </span><span class="sc">%d\n</span><span class="st">"</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>
|
||||
<pre class="<!---c-->"><code> #include <stdio.h>
|
||||
#line 42 "foo\0bar"
|
||||
int main (void) {
|
||||
printf ("%s %d\n", __FILE__, (int)sizeof __FILE__);
|
||||
return 0;
|
||||
}</code></pre>
|
||||
<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 "\0" into "\\0", ugh!</code></pre>
|
||||
@@ -283,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"><</span>some_token<span class="op">>:</span></span>
|
||||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="op"><</span>some_token<span class="op">>:</span></span></code></pre></div>
|
||||
<pre class="<!---c-->"><code> case <some_token>:
|
||||
case <some_token>:</code></pre>
|
||||
<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>
|
||||
@@ -315,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="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">"</span><span class="st">\0</span><span class="ot">"</span>;</span>
|
||||
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="wa">$_</span> = <>;</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">"</span><span class="ch">\n</span><span class="ot">"</span>;</span></code></pre></div>
|
||||
<pre class="<!---perl-->"><code> #!/usr/bin/perl -w
|
||||
$/ = "\0";
|
||||
$_ = <>;
|
||||
s/[;{}][ \t\n]/\n/g;
|
||||
s/[ \t\n]+//g;
|
||||
print length ($_),"\n";</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><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
|
||||
|
||||
@@ -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>
|
||||
<pre class="<!---sh-->"><code> sudo xcode-select --install</code></pre>
|
||||
<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>
|
||||
@@ -154,9 +154,9 @@ the command is:</p>
|
||||
<p>which has been changed to be:</p>
|
||||
<pre><code>"0cc -ansi -E -dM -undef %s /usr/include/%s>r\0 ("</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>
|
||||
<pre class="<!---c-->"><code> if ((H = fopen (__FILE__+43, 43+__FILE__)))
|
||||
while ((fgets (L, (int)sizeof L, H)) != 0) {
|
||||
I[strcspn (I, 45+__FILE__)] = O = 0;</code></pre>
|
||||
<p>The first number in the above C means the length starting from 0 up through the
|
||||
<code>></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
|
||||
|
||||
@@ -19,7 +19,7 @@ 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
|
||||
command line tools installed which can be done like:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
sudo xcode-select --install
|
||||
```
|
||||
|
||||
@@ -50,7 +50,7 @@ which has been changed to be:
|
||||
|
||||
Shortly below that you will see, as noted above, the numbers:
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
if ((H = fopen (__FILE__+43, 43+__FILE__)))
|
||||
while ((fgets (L, (int)sizeof L, H)) != 0) {
|
||||
I[strcspn (I, 45+__FILE__)] = O = 0;
|
||||
|
||||
+14
-14
@@ -1,26 +1,26 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./yarng
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./yarng integer_number
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
|
||||
./yarng
|
||||
@@ -42,13 +42,13 @@ 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:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make schweikh2
|
||||
```
|
||||
|
||||
often produced an error of the form:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
gcc -ansi schweikh2.alt.c -o schweikh2.alt
|
||||
as: Error: cca00NzV.s, line 58: Missing " at end of string
|
||||
"
|
||||
@@ -58,20 +58,20 @@ often produced an error of the form:
|
||||
|
||||
because the line:
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
#line 10 ONE(O(1,1,2,6,0,6))
|
||||
```
|
||||
|
||||
turned into the line:
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
# 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
|
||||
```<!---asm-->
|
||||
.stabs "schweikh2.c
|
||||
",132,0,0,Ltext1
|
||||
```
|
||||
@@ -80,7 +80,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
|
||||
```<!---sh-->
|
||||
make schweikh2 CFLAGS=-g
|
||||
```
|
||||
|
||||
@@ -105,7 +105,7 @@ still can :-) ).
|
||||
|
||||
Because of this bug, the code was changed to be instead:
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
#line 10 "01\015"
|
||||
```
|
||||
|
||||
@@ -122,13 +122,13 @@ compiler error:
|
||||
|
||||
so the line:
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
#line 10 "01\015"
|
||||
```
|
||||
|
||||
was changed to:
|
||||
|
||||
```c
|
||||
```<!---c-->
|
||||
#line 10 ONE(O(1,1,2,6,0,6))
|
||||
```
|
||||
|
||||
@@ -158,7 +158,7 @@ different values? How long would you need for an empirical test?
|
||||
|
||||
For example:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
$ ./yarng 32
|
||||
10111001010101110110010101001111
|
||||
$ ./yarng 5
|
||||
|
||||
+25
-25
@@ -141,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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./yarng</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./yarng integer_number</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>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./try.sh
|
||||
|
||||
./yarng
|
||||
# watch what it does</code></pre>
|
||||
<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>
|
||||
@@ -160,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>
|
||||
<pre class="<!---sh-->"><code> make schweikh2</code></pre>
|
||||
<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">" at end of string</span></span>
|
||||
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="st"> "</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>
|
||||
<pre class="<!---sh-->"><code> 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)</code></pre>
|
||||
<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>
|
||||
<pre class="<!---c-->"><code> #line 10 ONE(O(1,1,2,6,0,6))</code></pre>
|
||||
<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 "01\012"</span></span></code></pre></div>
|
||||
<pre class="<!---c-->"><code> # 9 "01\012"</code></pre>
|
||||
<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">"schweikh2.c</span></span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> ",132,0,0,Ltext1</span></code></pre></div>
|
||||
<pre class="<!---asm-->"><code> .stabs "schweikh2.c
|
||||
",132,0,0,Ltext1</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> make schweikh2 CFLAGS=-g</code></pre>
|
||||
<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>
|
||||
@@ -191,7 +191,7 @@ 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 "01\015"</span></span></code></pre></div>
|
||||
<pre class="<!---c-->"><code> #line 10 "01\015"</code></pre>
|
||||
<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>
|
||||
@@ -200,9 +200,9 @@ compiler error:</p>
|
||||
:12:1: warning: missing terminating " character
|
||||
:12:19: internal compiler error: invalid built-in macro "__FILE__"</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 "01\015"</span></span></code></pre></div>
|
||||
<pre class="<!---c-->"><code> #line 10 "01\015"</code></pre>
|
||||
<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>
|
||||
<pre class="<!---c-->"><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="what-this-program-does">What this program does</h3>
|
||||
@@ -223,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>
|
||||
<pre class="<!---sh-->"><code> $ ./yarng 32
|
||||
10111001010101110110010101001111
|
||||
$ ./yarng 5
|
||||
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>
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
@@ -23,7 +23,7 @@ If `dir` is the directory (or a directory tree) where you keep
|
||||
all your favorite pictures off the Internet or from
|
||||
`alt.binaries.pictures.*`, do
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
find dir -type f -print | ./samefile
|
||||
```
|
||||
|
||||
@@ -34,7 +34,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
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -53,7 +53,7 @@ which if (in the code) is unset will be set to the default, 32767.
|
||||
If you wish to change the size to say, 55555:
|
||||
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make clobber SIZE=55555 alt
|
||||
```
|
||||
|
||||
@@ -83,7 +83,7 @@ Thank God the IEEE does not standardize a coding style...
|
||||
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
|
||||
```<!---sh-->
|
||||
`man ./samefile.1
|
||||
```
|
||||
|
||||
@@ -100,7 +100,7 @@ Otherwise:
|
||||
|
||||
#### SYNOPSIS
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./samefile
|
||||
```
|
||||
|
||||
@@ -141,7 +141,7 @@ 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:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
$ ls -i # output edited for readability:
|
||||
10 file1 20 file4 30 file6
|
||||
10 file2 20 file5
|
||||
@@ -177,7 +177,7 @@ For everybody:
|
||||
|
||||
What are the duplicates under my home directory?
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
find $HOME | ./samefile
|
||||
```
|
||||
|
||||
@@ -185,14 +185,14 @@ For the sysadmin folks:
|
||||
|
||||
Report all duplicate files under /usr larger than 16k:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
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
|
||||
```<!---sh-->
|
||||
find /pub -type f | samefile | awk '{sum += $1} END {print sum}'
|
||||
```
|
||||
|
||||
|
||||
+16
-16
@@ -141,7 +141,7 @@ 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>
|
||||
<pre class="<!---sh-->"><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
|
||||
@@ -153,11 +153,11 @@ code</a> below.</p>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> find dir -type f -print | ./samefile</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<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
|
||||
@@ -165,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>
|
||||
<pre class="<!---sh-->"><code> make clobber SIZE=55555 alt</code></pre>
|
||||
<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
|
||||
@@ -181,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>
|
||||
<pre class="<!---sh-->"><code> `man ./samefile.1</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./samefile</code></pre>
|
||||
<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
|
||||
@@ -219,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>
|
||||
<pre class="<!---sh-->"><code> $ 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</code></pre>
|
||||
<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
|
||||
@@ -245,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>
|
||||
<pre class="<!---sh-->"><code> find $HOME | ./samefile</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> find /usr -size +16384c -a -type f | ./samefile</code></pre>
|
||||
<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">'{sum += $1} END {print sum}'</span></span></code></pre></div>
|
||||
<pre class="<!---sh-->"><code> find /pub -type f | samefile | awk '{sum += $1} END {print sum}'</code></pre>
|
||||
<h4 id="exit-status">EXIT STATUS</h4>
|
||||
<p>If <code>samefile</code> runs out of memory the exit status is 1, zero
|
||||
otherwise.</p>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./tomtorfs filename bitwidth polynom reflected init xor
|
||||
```
|
||||
|
||||
@@ -25,7 +25,7 @@ where:
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -56,7 +56,7 @@ archiver that uses the CRC-32 algorithm.
|
||||
|
||||
#### CRC-16:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./tomtorfs filename 16 1021 0 FFFF 0000
|
||||
```
|
||||
|
||||
@@ -64,21 +64,21 @@ archiver that uses the CRC-32 algorithm.
|
||||
#### CRC-32:
|
||||
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./tomtorfs filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF
|
||||
```
|
||||
|
||||
|
||||
#### XMODEM:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./tomtorfs filename 16 8408 1 0000 0000
|
||||
```
|
||||
|
||||
|
||||
#### ARC:
|
||||
|
||||
```sh
|
||||
```<!---sh-->
|
||||
./tomtorfs filename 16 8005 1 0000 0000
|
||||
```
|
||||
|
||||
|
||||
@@ -141,9 +141,9 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></l
|
||||
<!-- 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>
|
||||
<pre class="<!---sh-->"><code> make all</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><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)
|
||||
@@ -152,7 +152,7 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></l
|
||||
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>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<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
|
||||
@@ -169,13 +169,13 @@ archiver that uses the CRC-32 algorithm.</p>
|
||||
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>
|
||||
<pre class="<!---sh-->"><code> ./tomtorfs filename 16 1021 0 FFFF 0000</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./tomtorfs filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./tomtorfs filename 16 8408 1 0000 0000</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./tomtorfs filename 16 8005 1 0000 0000</code></pre>
|
||||
<h3 id="portability-notes">Portability notes</h3>
|
||||
<p>The program assumes <code>CHAR_BIT==8</code>. Results are undefined if <code>bitwidth > 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.
|
||||
|
||||
Reference in new issue
Block a user