improved indentation and whitespace for markdown code blocks
All code blocks in markdown have been intended by at least 4 spaces. We add `--tab-stop=8` to all `pandoc(1)` executions in order to set a better tab stop indentation, especially for tab intended code blocks. Changed `bin/pandoc-wrapper.sh` VERSION from "1.5.3 2024-03-26" to "1.6 2024-03-31". Fixed `1991/brnstnd/sorta.README.md` so that the sorta code is code blocks. Removed unneeded paragraph group in copyright in `inc/footer.default.html`. Fixed excess whitespace after list Author on entry `index.html` page. Changed `bin/output-index-author.sh` VERSION from "1.5.2 2024-03-26" to "1.6 2024-03-31". Performed `make www` to perform the above and test under macOS. TODO: Fix the problem of the initial line of code being extra intended. TODO: Fix excess whitespace around code that is inline.
This commit is contained in:
1 parent
b84c27ce02
commit
a996f8d2b8
734 files changed
+16723
-16963
No files matched your search
+3
-3
@@ -58,9 +58,9 @@ were not correctly parsed by the tool. The guidelines stated:
|
||||
|
||||
|
||||
```
|
||||
In cases where the above summary and the algorithm implemented by
|
||||
the IOCCC size tool source code conflict, the algorithm implemented
|
||||
by the IOCCC size tool source code is preferred by the judges.
|
||||
In cases where the above summary and the algorithm implemented by
|
||||
the IOCCC size tool source code conflict, the algorithm implemented
|
||||
by the IOCCC size tool source code is preferred by the judges.
|
||||
```
|
||||
|
||||
so this abuse was allowed (and encouraged). The judges hope that
|
||||
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
We recommend that you use the alt version first to see what this entry looked
|
||||
@@ -12,7 +12,7 @@ version see the [original code](#original-code) section below.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./birken.alt < 17_columns_wide_paint_by_numbers_file
|
||||
./birken.alt < 17_columns_wide_paint_by_numbers_file
|
||||
```
|
||||
|
||||
NOTE: if your terminal is messed up after running this (perhaps from exiting
|
||||
@@ -31,7 +31,7 @@ it should you wish (see below).
|
||||
To see the program run on each text file, try:
|
||||
|
||||
```sh
|
||||
./try.alt.sh
|
||||
./try.alt.sh
|
||||
```
|
||||
|
||||
If you have perl installed it will also try a random run.
|
||||
@@ -45,7 +45,7 @@ compile time. If you wish to speed it up by 100% you can instead do:
|
||||
|
||||
|
||||
```sh
|
||||
make clobber SLEEP=7500 alt
|
||||
make clobber SLEEP=7500 alt
|
||||
```
|
||||
|
||||
and then try `birken.alt` as above.
|
||||
@@ -56,7 +56,7 @@ ctrl-c to terminate the program early but note that the terminal is likely to be
|
||||
messed up. In that case try:
|
||||
|
||||
```sh
|
||||
reset
|
||||
reset
|
||||
```
|
||||
|
||||
to make it sane again (running to completion will do that for you).
|
||||
@@ -71,7 +71,7 @@ hard to see the art of the entry but you may do so if you wish.
|
||||
### Original build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ Use `birken` as you would `birken.alt` above.
|
||||
To use the demo script with the original code, try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
PLEASE be careful if you are sensitive to flashing colours!
|
||||
@@ -320,16 +320,16 @@ This program demonstrates how to exploit a bug in IOCCC size tool version
|
||||
If that line is added to the top of any program, the tool will report a size of 8.
|
||||
|
||||
```sh
|
||||
$ ./iocccsize -i < prog.c
|
||||
8
|
||||
$ ./iocccsize -i < prog.c
|
||||
8
|
||||
```
|
||||
|
||||
When that line is deleted from this program, the tool properly reports the
|
||||
secondary size limit of the program as 2048.
|
||||
|
||||
```sh
|
||||
$ ./iocccsize -i < birken.c
|
||||
2048
|
||||
$ ./iocccsize -i < birken.c
|
||||
2048
|
||||
```
|
||||
|
||||
Although this bug provides an easy means of circumventing contest rule 2, as
|
||||
@@ -358,7 +358,7 @@ Carefully selected variable names also yielded wonderful expressions like `l=0`,
|
||||
sorts:
|
||||
|
||||
```c
|
||||
[T][e][t]--; while(R+i) { s
|
||||
[T][e][t]--; while(R+i) { s
|
||||
```
|
||||
|
||||
The source is formatted to resemble the
|
||||
|
||||
+13
-14
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Michael_Birken">Michael Birken</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,12 +141,12 @@ 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> alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<p>We recommend that you use the alt version first to see what this entry looked
|
||||
like back in 2013 (with a configurable speed). If you wish to use the original
|
||||
version see the <a href="#original-code">original code</a> section below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./birken.alt</span> <span class="op"><</span> 17_columns_wide_paint_by_numbers_file</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./birken.alt</span> <span class="op"><</span> 17_columns_wide_paint_by_numbers_file</span></code></pre></div>
|
||||
<p>NOTE: if your terminal is messed up after running this (perhaps from exiting
|
||||
before it finishes) try using <code>reset</code> to restore the terminal. This will clear
|
||||
the screen.</p>
|
||||
@@ -158,7 +157,7 @@ be problematic for some people, can be configured to different speeds by way of
|
||||
the value used in <code>usleep(3)</code>. The default is <code>13500</code> but you can reconfigure
|
||||
it should you wish (see below).</p>
|
||||
<p>To see the program run on each text file, try:</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.alt.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.sh</span></span></code></pre></div>
|
||||
<p>If you have perl installed it will also try a random run.</p>
|
||||
<p>Finding the ‘right’ default value was a fine line; the default, 15000
|
||||
microseconds (0.015 seconds), will take quite a while to finish but it allows
|
||||
@@ -166,24 +165,24 @@ one to more easily see what is going on. Even easier to see would be 25000 but
|
||||
these values make it quite slow and one could easily lose interest. Like some
|
||||
other entries where this was made an alternate version it is configurable at
|
||||
compile time. If you wish to speed it up by 100% you can instead do:</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">make</span> clobber SLEEP=7500 alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber SLEEP=7500 alt</span></code></pre></div>
|
||||
<p>and then try <code>birken.alt</code> as above.</p>
|
||||
<p>If you wish to speed that up 200% (300% total) you can use instead try
|
||||
<code>SLEEP=3750</code>. Doing this you might find the right value to your liking; use
|
||||
ctrl-c to terminate the program early but note that the terminal is likely to be
|
||||
messed up. In that case 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">reset</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">reset</span></span></code></pre></div>
|
||||
<p>to make it sane again (running to completion will do that for you).</p>
|
||||
<h2 id="original-code">Original code:</h2>
|
||||
<p>The original code will run faster with modern systems which is likely to make it
|
||||
hard to see the art of the entry but you may do so if you wish.</p>
|
||||
<h3 id="original-build">Original 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> all</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> all</span></code></pre></div>
|
||||
<h3 id="original-use">Original use:</h3>
|
||||
<p>Use <code>birken</code> as you would <code>birken.alt</code> above.</p>
|
||||
<h3 id="original-try">Original try:</h3>
|
||||
<p>To use the demo script with the original code, try:</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">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>PLEASE be careful if you are sensitive to flashing colours!</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>This program also wins the “Most amusing abuse of the iocccsize tool” award;
|
||||
@@ -347,12 +346,12 @@ call to <code>fflush(3)</code> (N.B: see <a href="birken.alt.c">birken.alt.c</a>
|
||||
<code>2013-07-30-v17</code>. The first line of the program is reproduced below.</p>
|
||||
<p>char<em>_ = “’”“/</em>”;</p>
|
||||
<p>If that line is added to the top of any program, the tool will report a size of 8.</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./iocccsize <span class="at">-i</span> <span class="op"><</span> prog.c</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="ex">8</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./iocccsize <span class="at">-i</span> <span class="op"><</span> prog.c</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">8</span></span></code></pre></div>
|
||||
<p>When that line is deleted from this program, the tool properly reports the
|
||||
secondary size limit of the program as 2048.</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">$</span> ./iocccsize <span class="at">-i</span> <span class="op"><</span> birken.c</span>
|
||||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="ex">2048</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./iocccsize <span class="at">-i</span> <span class="op"><</span> birken.c</span>
|
||||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">2048</span></span></code></pre></div>
|
||||
<p>Although this bug provides an easy means of circumventing contest rule 2, as
|
||||
demonstrated from the size value, this entry is not necessarily striving for a
|
||||
‘worst abuse of the rules’ award.</p>
|
||||
@@ -372,7 +371,7 @@ Pajitnov</a>’s original 1984
|
||||
<p>Carefully selected variable names also yielded wonderful expressions like <code>l=0</code>,
|
||||
<code>O=0</code>, <code>O=1</code> and <code>while(O)</code>. <code>"Tetris"</code> also makes a second appearance of
|
||||
sorts:</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="op">[</span>T<span class="op">][</span>e<span class="op">][</span>t<span class="op">]--;</span> <span class="cf">while</span><span class="op">(</span>R<span class="op">+</span>i<span class="op">)</span> <span class="op">{</span> s</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span>T<span class="op">][</span>e<span class="op">][</span>t<span class="op">]--;</span> <span class="cf">while</span><span class="op">(</span>R<span class="op">+</span>i<span class="op">)</span> <span class="op">{</span> s</span></code></pre></div>
|
||||
<p>The source is formatted to resemble the
|
||||
<a href="https://en.wikipedia.org/wiki/Tetris">Tetris</a> play-field mid-game. It is also
|
||||
an homage to all the <a href="../../years.html">past IOCCC entries</a> formatted as a compact
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./cable1 name group1 group2
|
||||
./cable1 name group1 group2
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -27,39 +27,39 @@ We need not limit ourselves to the two major political parties in the US today.
|
||||
Let us consider:
|
||||
|
||||
```sh
|
||||
./cable1 Cooper Mac PC
|
||||
./cable1 Cooper Mac PC
|
||||
```
|
||||
|
||||
Simon works for Apple, so you would expect Mac. :-)
|
||||
Landon is a long time Mac user:
|
||||
|
||||
```sh
|
||||
./cable1 Noll Mac PC
|
||||
./cable1 Noll Mac PC
|
||||
```
|
||||
|
||||
That works too! Now Leo brings PCs to the IOCCC judging for cross-platform
|
||||
testing:
|
||||
|
||||
```sh
|
||||
./cable1 Broukhis Mac PC
|
||||
./cable1 Broukhis Mac PC
|
||||
```
|
||||
|
||||
We can test other people. The late Steve Jobs:
|
||||
|
||||
```sh
|
||||
./cable1 Jobs Mac PC
|
||||
./cable1 Jobs Mac PC
|
||||
```
|
||||
|
||||
That works! How about Bill?
|
||||
|
||||
```sh
|
||||
./cable1 Gates Mac PC
|
||||
./cable1 Gates Mac PC
|
||||
```
|
||||
|
||||
A PC guy as expected. What about that other Steve?
|
||||
|
||||
```sh
|
||||
./cable1 Ballmer Mac PC
|
||||
./cable1 Ballmer Mac PC
|
||||
```
|
||||
|
||||
Humm .. maybe there is a hidden reason he is leaving the late Micro$oft? :-)
|
||||
|
||||
+10
-11
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Adrian_Cable">Adrian Cable</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,28 +141,28 @@ 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></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./cable1</span> name group1 group2</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable1</span> name group1 group2</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Partisan may be defined as a strong supporter of a cause, party or person.
|
||||
We need not limit ourselves to the two major political parties in the US today.</p>
|
||||
<p>Let us consider:</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">./cable1</span> Cooper Mac PC</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable1</span> Cooper Mac PC</span></code></pre></div>
|
||||
<p>Simon works for Apple, so you would expect Mac. :-)
|
||||
Landon is a long time Mac user:</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">./cable1</span> Noll Mac PC</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable1</span> Noll Mac PC</span></code></pre></div>
|
||||
<p>That works too! Now Leo brings PCs to the IOCCC judging for cross-platform
|
||||
testing:</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">./cable1</span> Broukhis Mac PC</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable1</span> Broukhis Mac PC</span></code></pre></div>
|
||||
<p>We can test other people. The late Steve Jobs:</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">./cable1</span> Jobs Mac PC</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable1</span> Jobs Mac PC</span></code></pre></div>
|
||||
<p>That works! How about Bill?</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">./cable1</span> Gates Mac PC</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable1</span> Gates Mac PC</span></code></pre></div>
|
||||
<p>A PC guy as expected. What about that other Steve?</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./cable1</span> Ballmer Mac PC</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable1</span> Ballmer Mac PC</span></code></pre></div>
|
||||
<p>Humm .. maybe there is a hidden reason he is leaving the late Micro$oft? :-)
|
||||
Why late? Because:</p>
|
||||
<figure>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2013 cable2 bugs](../../bugs.html#2013_cable2).
|
||||
@@ -19,7 +19,7 @@ For more detailed information see [2013 cable2 bugs](../../bugs.html#2013_cable2
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./cable2 file.bmp [color]
|
||||
./cable2 file.bmp [color]
|
||||
```
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ For more detailed information see [2013 cable2 bugs](../../bugs.html#2013_cable2
|
||||
For different OCR examples:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Adrian_Cable">Adrian Cable</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,16 +141,16 @@ 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></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2013_cable2">2013 cable2 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">./cable2</span> file.bmp <span class="pp">[</span><span class="ss">color</span><span class="pp">]</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable2</span> file.bmp <span class="pp">[</span><span class="ss">color</span><span class="pp">]</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<p>For different OCR examples:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>We can confirm that this is the first time the IOCCC has been used
|
||||
to peer-review a new research. We had quite a bit of fun with a sharpie and a
|
||||
|
||||
+16
-16
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
An alternate version that should compile in Windows/MS Visual Studio is
|
||||
@@ -11,14 +11,14 @@ available. See the [Alternate code](#alternate-code) section below.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
|
||||
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./cable3.sh
|
||||
./cable3.sh
|
||||
```
|
||||
|
||||
NOTE: to quit the program type `QUITEMU`. You might have to be at the top level
|
||||
@@ -47,7 +47,7 @@ Assuming `make` is available and will function:
|
||||
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ Makefile definition of KB, use something slightly different - add the following
|
||||
entry to the Preprocessor Definitions list in the Project Properties page:
|
||||
|
||||
```c
|
||||
KB=(kb=H(8),kbhit())&&(r[1190]=getch(),H(7))
|
||||
KB=(kb=H(8),kbhit())&&(r[1190]=getch(),H(7))
|
||||
```
|
||||
|
||||
NOTE: this is done in the [Alternate code](#alternate-code).
|
||||
@@ -190,7 +190,7 @@ will need to explicitly declare these functions by adding the appropriate
|
||||
include to the top of the source:
|
||||
|
||||
```c
|
||||
#include <unistd.h>
|
||||
#include <unistd.h>
|
||||
```
|
||||
|
||||
NOTE: this has been done in [cable3.c](cable3.c).
|
||||
@@ -198,7 +198,7 @@ NOTE: this has been done in [cable3.c](cable3.c).
|
||||
### Usage
|
||||
|
||||
```sh
|
||||
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
|
||||
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
|
||||
```
|
||||
|
||||
PLEASE NOTE that under Unices the keyboard must be in raw mode for the emulator
|
||||
@@ -206,9 +206,9 @@ to work properly. Therefore the emulator is best run from a shell script that
|
||||
looks something like:
|
||||
|
||||
```sh
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios floppy.img harddisk.img
|
||||
stty cooked echo
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios floppy.img harddisk.img
|
||||
stty cooked echo
|
||||
```
|
||||
|
||||
See the [cable3.sh](cable3.sh) script.
|
||||
@@ -224,9 +224,9 @@ cooked). So, run the emulator using something like this script (provided as
|
||||
[cable3.sh](cable3.sh)):
|
||||
|
||||
```sh
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios fd.img
|
||||
stty cooked echo
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios fd.img
|
||||
stty cooked echo
|
||||
```
|
||||
|
||||
## To use the emulator - floppy + HD mode
|
||||
@@ -238,9 +238,9 @@ For the more adventurous, you can start off with (for example) a blank 40MB
|
||||
image file called hd.img made using e.g. Makefile. Then use:
|
||||
|
||||
```sh
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios fd.img hd.img
|
||||
stty cooked echo
|
||||
stty cbreak raw -echo min 0
|
||||
./cable3 bios fd.img hd.img
|
||||
stty cooked echo
|
||||
```
|
||||
|
||||
Preparing the hard disk for use in the emulator is done just like a real PC.
|
||||
|
||||
+17
-18
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Adrian_Cable">Adrian Cable</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,13 +141,13 @@ 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></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>An alternate version that should compile in Windows/MS Visual Studio is
|
||||
available. See the <a href="#alternate-code">Alternate code</a> section below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./cable3</span> bios-image-file floppy-image-file <span class="pp">[</span><span class="ss">harddisk</span><span class="pp">-</span><span class="ss">image</span><span class="pp">-</span><span class="ss">file</span><span class="pp">]</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable3</span> bios-image-file floppy-image-file <span class="pp">[</span><span class="ss">harddisk</span><span class="pp">-</span><span class="ss">image</span><span class="pp">-</span><span class="ss">file</span><span class="pp">]</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./cable3.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable3.sh</span></span></code></pre></div>
|
||||
<p>NOTE: to quit the program type <code>QUITEMU</code>. You might have to be at the top level
|
||||
directory of the drive, <code>A:</code> or <code>C:</code>.</p>
|
||||
<p>To send an <code>Alt+XXX</code> key combination, press (<code>^A</code> / <code>Ctrl+A</code>) then the key, so
|
||||
@@ -163,7 +162,7 @@ combinations are left for the discovery of the user.</p>
|
||||
<p>An alternate version, which should compile in Windows, is provided.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<p>Assuming <code>make</code> is available and will function:</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">make</span> alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>cable3.alt</code> as you would <code>cable3</code> above.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -265,7 +264,7 @@ has no <code>stty</code>. Therefore the Makefile includes a <code>-D</code> opti
|
||||
non-UNIX platforms. For example, for Windows/MS Visual Studio, instead of the
|
||||
Makefile definition of KB, use something slightly different - add the following
|
||||
entry to the Preprocessor Definitions list in the Project Properties page:</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>KB<span class="op">=(</span>kb<span class="op">=</span>H<span class="op">(</span><span class="dv">8</span><span class="op">),</span>kbhit<span class="op">())&&(</span>r<span class="op">[</span><span class="dv">1190</span><span class="op">]=</span>getch<span class="op">(),</span>H<span class="op">(</span><span class="dv">7</span><span class="op">))</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> KB<span class="op">=(</span>kb<span class="op">=</span>H<span class="op">(</span><span class="dv">8</span><span class="op">),</span>kbhit<span class="op">())&&(</span>r<span class="op">[</span><span class="dv">1190</span><span class="op">]=</span>getch<span class="op">(),</span>H<span class="op">(</span><span class="dv">7</span><span class="op">))</span></span></code></pre></div>
|
||||
<p>NOTE: this is done in the <a href="#alternate-code">Alternate code</a>.</p>
|
||||
<h3 id="posix-portability-note">POSIX portability note</h3>
|
||||
<p>The code as supplied uses implicit function declarations for POSIX file I/O and
|
||||
@@ -274,16 +273,16 @@ architecture. For some systems (e.g. 32-bit Mac OS X, which uses 64-bit file
|
||||
offsets) this is not the case, and to run successfully on these systems, you
|
||||
will need to explicitly declare these functions by adding the appropriate
|
||||
include to the top of the source:</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="pp">#include </span><span class="im"><unistd.h></span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im"><unistd.h></span></span></code></pre></div>
|
||||
<p>NOTE: this has been done in <a href="cable3.c">cable3.c</a>.</p>
|
||||
<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">./cable3</span> bios-image-file floppy-image-file <span class="pp">[</span><span class="ss">harddisk</span><span class="pp">-</span><span class="ss">image</span><span class="pp">-</span><span class="ss">file</span><span class="pp">]</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable3</span> bios-image-file floppy-image-file <span class="pp">[</span><span class="ss">harddisk</span><span class="pp">-</span><span class="ss">image</span><span class="pp">-</span><span class="ss">file</span><span class="pp">]</span></span></code></pre></div>
|
||||
<p>PLEASE NOTE that under Unices the keyboard must be in raw mode for the emulator
|
||||
to work properly. Therefore the emulator is best run from a shell script that
|
||||
looks something like:</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="fu">stty</span> cbreak raw <span class="at">-echo</span> min 0</span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./cable3</span> bios floppy.img harddisk.img</span>
|
||||
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="fu">stty</span> cooked echo</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">stty</span> cbreak raw <span class="at">-echo</span> min 0</span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable3</span> bios floppy.img harddisk.img</span>
|
||||
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">stty</span> cooked echo</span></code></pre></div>
|
||||
<p>See the <a href="cable3.sh">cable3.sh</a> script.</p>
|
||||
<h2 id="to-use-the-emulator---floppy-mode-only">To use the emulator - floppy mode only</h2>
|
||||
<p>The simplest use of the emulator is with a single floppy boot disk image, like
|
||||
@@ -292,17 +291,17 @@ the <code>fd.img</code> provided, which is a FreeDOS boot disk.</p>
|
||||
put the keyboard into raw mode (and afterwards it needs to be put back to
|
||||
cooked). So, run the emulator using something like this script (provided as
|
||||
<a href="cable3.sh">cable3.sh</a>):</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">stty</span> cbreak raw <span class="at">-echo</span> min 0</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./cable3</span> bios fd.img</span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="fu">stty</span> cooked echo</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">stty</span> cbreak raw <span class="at">-echo</span> min 0</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable3</span> bios fd.img</span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">stty</span> cooked echo</span></code></pre></div>
|
||||
<h2 id="to-use-the-emulator---floppy-hd-mode">To use the emulator - floppy + HD mode</h2>
|
||||
<p>Easiest to start with is to try a ready-made 40MB hard disk image containing a
|
||||
whole bunch of software which is in the included file <code>hd.img</code>.</p>
|
||||
<p>For the more adventurous, you can start off with (for example) a blank 40MB
|
||||
image file called hd.img made using e.g. Makefile. Then use:</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">stty</span> cbreak raw <span class="at">-echo</span> min 0</span>
|
||||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./cable3</span> bios fd.img hd.img</span>
|
||||
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="fu">stty</span> cooked echo</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">stty</span> cbreak raw <span class="at">-echo</span> min 0</span>
|
||||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable3</span> bios fd.img hd.img</span>
|
||||
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">stty</span> cooked echo</span></code></pre></div>
|
||||
<p>Preparing the hard disk for use in the emulator is done just like a real PC.
|
||||
Boot the emulator, and use <code>FDISK</code> to partition the hard disk. When it’s done
|
||||
<code>FDISK</code> will reboot the emulator. Then you can use <code>FORMAT C:</code> and you are done. The
|
||||
|
||||
+21
-21
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2013 dlowe bugs](../../bugs.html#2013_dlowe).
|
||||
@@ -19,7 +19,7 @@ For more detailed information see [2013 dlowe bugs](../../bugs.html#2013_dlowe).
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./dlowe [number...]
|
||||
./dlowe [number...]
|
||||
```
|
||||
|
||||
where `[number...]` is one or more number, space separated.
|
||||
@@ -28,15 +28,15 @@ where `[number...]` is one or more number, space separated.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
What is different about the above if you do something like:
|
||||
|
||||
```sh
|
||||
echo 'IOCCC winning entry 2013/dlowe' > ioccc.txt
|
||||
./try.sh
|
||||
rm -f ioccc.txt
|
||||
echo 'IOCCC winning entry 2013/dlowe' > ioccc.txt
|
||||
./try.sh
|
||||
rm -f ioccc.txt
|
||||
```
|
||||
|
||||
?
|
||||
@@ -44,7 +44,7 @@ rm -f ioccc.txt
|
||||
To make it simpler to see try showing just the different line like:
|
||||
|
||||
```sh
|
||||
./diff.sh
|
||||
./diff.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ with one argument or when all arguments are equal?
|
||||
For extra fun, compile and run [fun.c](fun.c):
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
printf("%d %d %d\n", (int)(-1.0/0.0), (int)(0.0/0.0), (int)(1.0/0.0));
|
||||
}
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
printf("%d %d %d\n", (int)(-1.0/0.0), (int)(0.0/0.0), (int)(1.0/0.0));
|
||||
}
|
||||
```
|
||||
|
||||
with gcc and clang.
|
||||
@@ -71,19 +71,19 @@ with gcc and clang.
|
||||
With GCC (4.7.2), we get
|
||||
|
||||
```
|
||||
-2147483648 -2147483648 -2147483648
|
||||
-2147483648 -2147483648 -2147483648
|
||||
```
|
||||
|
||||
and with clang (3.3), we get
|
||||
|
||||
```
|
||||
-2147483648 0 2147483647
|
||||
-2147483648 0 2147483647
|
||||
```
|
||||
|
||||
and with Apple clang version 15.0.0 (clang-1500.0.40.1) in 2023, we get:
|
||||
|
||||
```
|
||||
1840985120 -2033041452 35979112
|
||||
1840985120 -2033041452 35979112
|
||||
```
|
||||
|
||||
Which one is correct? :)
|
||||
@@ -92,7 +92,7 @@ NOTE: `make all` will compile [fun.c](fun.c) but to provide a different compiler
|
||||
you can do something like:
|
||||
|
||||
```sh
|
||||
make CC=clang fun
|
||||
make CC=clang fun
|
||||
```
|
||||
|
||||
|
||||
@@ -106,17 +106,17 @@ A tiny implementation of command-line
|
||||
### Synopsis
|
||||
|
||||
```sh
|
||||
$ ./sparkl 0 1 2 3 4 5 6 7
|
||||
▁▂▃▄▅▆▇▉
|
||||
$ ./sparkl 0 1 2 3 4 5 6 7
|
||||
▁▂▃▄▅▆▇▉
|
||||
|
||||
$ echo "sparkline of file lengths: $(wc -c * | awk '{print $1}' | xargs ./sparkl)"
|
||||
sparkline of file sizes: ▁▁▁▃▃▂▁▂▁▁▉
|
||||
$ echo "sparkline of file lengths: $(wc -c * | awk '{print $1}' | xargs ./sparkl)"
|
||||
sparkline of file sizes: ▁▁▁▃▃▂▁▂▁▁▉
|
||||
```
|
||||
|
||||
NOTE: this has been provided in [slflen.sh](slflen.sh) so you can try:
|
||||
|
||||
```sh
|
||||
./slflen.sh
|
||||
./slflen.sh
|
||||
```
|
||||
|
||||
instead (which [try.sh](try.sh) also uses).
|
||||
|
||||
+22
-23
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#J_David_Lowe">J. David Lowe</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,56 +141,56 @@ 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></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2013_dlowe">2013 dlowe 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">./dlowe</span> <span class="pp">[</span><span class="ss">number...</span><span class="pp">]</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dlowe</span> <span class="pp">[</span><span class="ss">number...</span><span class="pp">]</span></span></code></pre></div>
|
||||
<p>where <code>[number...]</code> is one or more number, space separated.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>What is different about the above if you do something like:</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="bu">echo</span> <span class="st">'IOCCC winning entry 2013/dlowe'</span> <span class="op">></span> ioccc.txt</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="fu">rm</span> <span class="at">-f</span> ioccc.txt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">'IOCCC winning entry 2013/dlowe'</span> <span class="op">></span> ioccc.txt</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">rm</span> <span class="at">-f</span> ioccc.txt</span></code></pre></div>
|
||||
<p>?</p>
|
||||
<p>To make it simpler to see try showing just the different line like:</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">./diff.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./diff.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>We liked how this entry used Unicode, specifically UTF-8, in a somewhat
|
||||
obfuscated way.</p>
|
||||
<p>Also, why doesn’t it crash but instead produces a correct output when called
|
||||
with one argument or when all arguments are equal?</p>
|
||||
<p>For extra fun, compile and run <a href="fun.c">fun.c</a>:</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">#include </span><span class="im"><stdio.h></span></span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="dt">int</span> main<span class="op">()</span> <span class="op">{</span></span>
|
||||
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">"</span><span class="sc">%d</span><span class="st"> </span><span class="sc">%d</span><span class="st"> </span><span class="sc">%d\n</span><span class="st">"</span><span class="op">,</span> <span class="op">(</span><span class="dt">int</span><span class="op">)(-</span><span class="fl">1.0</span><span class="op">/</span><span class="fl">0.0</span><span class="op">),</span> <span class="op">(</span><span class="dt">int</span><span class="op">)(</span><span class="fl">0.0</span><span class="op">/</span><span class="fl">0.0</span><span class="op">),</span> <span class="op">(</span><span class="dt">int</span><span class="op">)(</span><span class="fl">1.0</span><span class="op">/</span><span class="fl">0.0</span><span class="op">));</span></span>
|
||||
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im"><stdio.h></span></span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> main<span class="op">()</span> <span class="op">{</span></span>
|
||||
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">"</span><span class="sc">%d</span><span class="st"> </span><span class="sc">%d</span><span class="st"> </span><span class="sc">%d\n</span><span class="st">"</span><span class="op">,</span> <span class="op">(</span><span class="dt">int</span><span class="op">)(-</span><span class="fl">1.0</span><span class="op">/</span><span class="fl">0.0</span><span class="op">),</span> <span class="op">(</span><span class="dt">int</span><span class="op">)(</span><span class="fl">0.0</span><span class="op">/</span><span class="fl">0.0</span><span class="op">),</span> <span class="op">(</span><span class="dt">int</span><span class="op">)(</span><span class="fl">1.0</span><span class="op">/</span><span class="fl">0.0</span><span class="op">));</span></span>
|
||||
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
|
||||
<p>with gcc and clang.</p>
|
||||
<p>With GCC (4.7.2), we get</p>
|
||||
<pre><code>-2147483648 -2147483648 -2147483648</code></pre>
|
||||
<pre><code> -2147483648 -2147483648 -2147483648</code></pre>
|
||||
<p>and with clang (3.3), we get</p>
|
||||
<pre><code>-2147483648 0 2147483647</code></pre>
|
||||
<pre><code> -2147483648 0 2147483647</code></pre>
|
||||
<p>and with Apple clang version 15.0.0 (clang-1500.0.40.1) in 2023, we get:</p>
|
||||
<pre><code>1840985120 -2033041452 35979112</code></pre>
|
||||
<pre><code> 1840985120 -2033041452 35979112</code></pre>
|
||||
<p>Which one is correct? :)</p>
|
||||
<p>NOTE: <code>make all</code> will compile <a href="fun.c">fun.c</a> but to provide a different compiler
|
||||
you can do something like:</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">make</span> CC=clang fun</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> CC=clang fun</span></code></pre></div>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="sparkl">sparkl</h3>
|
||||
<p>A tiny implementation of command-line
|
||||
<a href="https://en.wikipedia.org/wiki/Sparkline">sparkline</a> data visualization.</p>
|
||||
<h3 id="synopsis">Synopsis</h3>
|
||||
<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="ex">$</span> ./sparkl 0 1 2 3 4 5 6 7</span>
|
||||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="ex">▁▂▃▄▅▆▇▉</span></span>
|
||||
<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="ex">$</span> ./sparkl 0 1 2 3 4 5 6 7</span>
|
||||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">▁▂▃▄▅▆▇▉</span></span>
|
||||
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="st">"sparkline of file lengths: </span><span class="va">$(</span><span class="fu">wc</span> <span class="at">-c</span> <span class="pp">*</span> <span class="kw">|</span> <span class="fu">awk</span> <span class="st">'{print $1}'</span> <span class="kw">|</span> <span class="fu">xargs</span> ./sparkl<span class="va">)</span><span class="st">"</span></span>
|
||||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a><span class="ex">sparkline</span> of file sizes: ▁▁▁▃▃▂▁▂▁▁▉</span></code></pre></div>
|
||||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo <span class="st">"sparkline of file lengths: </span><span class="va">$(</span><span class="fu">wc</span> <span class="at">-c</span> <span class="pp">*</span> <span class="kw">|</span> <span class="fu">awk</span> <span class="st">'{print $1}'</span> <span class="kw">|</span> <span class="fu">xargs</span> ./sparkl<span class="va">)</span><span class="st">"</span></span>
|
||||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">sparkline</span> of file sizes: ▁▁▁▃▃▂▁▂▁▁▉</span></code></pre></div>
|
||||
<p>NOTE: this has been provided in <a href="slflen.sh">slflen.sh</a> so you can try:</p>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./slflen.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./slflen.sh</span></span></code></pre></div>
|
||||
<p>instead (which <a href="try.sh">try.sh</a> also uses).</p>
|
||||
<h3 id="description">Description</h3>
|
||||
<p>This is a handy little tool for visualizing numeric series from the
|
||||
|
||||
+23
-23
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2013 endoh1 bugs](../../bugs.html#2013_endoh1).
|
||||
@@ -19,20 +19,20 @@ For more detailed information see [2013 endoh1 bugs](../../bugs.html#2013_endoh1
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./endoh1 [file.lazy]
|
||||
./endoh1 [file.lazy]
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
You might also enjoy running:
|
||||
|
||||
```sh
|
||||
cc -E endoh1.c | less
|
||||
cc -E endoh1.c | less
|
||||
```
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ This entry can be considered an abuse of the GCC's optimizer; it takes GCC about
|
||||
### Remarks
|
||||
|
||||
```sh
|
||||
less endoh1.c
|
||||
gcc -o endoh1 endoh1.c
|
||||
./endoh1
|
||||
less endoh1.c
|
||||
gcc -o endoh1 endoh1.c
|
||||
./endoh1
|
||||
```
|
||||
|
||||
... Isn't there any more to it?
|
||||
@@ -67,8 +67,8 @@ This program will shine when it is used as a library. For example,
|
||||
[hello.lazy](hello.lazy) is a "Hello world" program written in Lazy K.
|
||||
|
||||
```sh
|
||||
$ lazy hello.lazy
|
||||
Hello, world!
|
||||
$ lazy hello.lazy
|
||||
Hello, world!
|
||||
```
|
||||
|
||||
where `lazy` is [a reference implementation of Lazy K][3]. At the same time,
|
||||
@@ -76,9 +76,9 @@ where `lazy` is [a reference implementation of Lazy K][3]. At the same time,
|
||||
as a library.
|
||||
|
||||
```sh
|
||||
$ gcc -o hello -xc hello.lazy
|
||||
$ ./hello
|
||||
Hello, world!
|
||||
$ gcc -o hello -xc hello.lazy
|
||||
$ ./hello
|
||||
Hello, world!
|
||||
```
|
||||
|
||||
In other words, this program is a kind of [polyglot][4].
|
||||
@@ -137,9 +137,9 @@ I confirmed that the program successfully worked with the following compilers:
|
||||
Recent compilers with `-Wall -W -Wextra -pedantic` say nothing.
|
||||
|
||||
```sh
|
||||
gcc -Wall -W -Wextra -pedantic prog.c
|
||||
clang -Wall -W -Wextra -pedantic prog.c
|
||||
tcc -Wall -W -Wextra -pedantic prog.c
|
||||
gcc -Wall -W -Wextra -pedantic prog.c
|
||||
clang -Wall -W -Wextra -pedantic prog.c
|
||||
tcc -Wall -W -Wextra -pedantic prog.c
|
||||
```
|
||||
|
||||
I think it will work on almost all platforms. I confirmed:
|
||||
@@ -174,7 +174,7 @@ combinator calculus. The rewriting rules are shown in the shape of the code.
|
||||
Consider a sequence of function applications in C:
|
||||
|
||||
```c
|
||||
s(x)(x)(x)(x)...
|
||||
s(x)(x)(x)(x)...
|
||||
```
|
||||
|
||||
What type should `s` have? Unfortunately, C does *not* provide a "recursive
|
||||
@@ -183,7 +183,7 @@ type", such as `typedef f (*f)();`.
|
||||
So, I used a heavily nested function pointer type:
|
||||
|
||||
```c
|
||||
typedef void *(*(*(*...(*(f))()...)())())
|
||||
typedef void *(*(*(*...(*(f))()...)())())
|
||||
```
|
||||
|
||||
This limits how many arguments one function can be consecutively applied to.
|
||||
@@ -208,11 +208,11 @@ So, I addressed this issue by generating many function definitions
|
||||
statically by (ab)using macros:
|
||||
|
||||
```c
|
||||
void *x1; void f1(void *y) { return apply(x1, y); }
|
||||
void *x2; void f2(void *y) { return apply(x2, y); }
|
||||
void *x3; void f3(void *y) { return apply(x3, y); }
|
||||
...
|
||||
void *(h[]) = { f1, f2, f3, ... }
|
||||
void *x1; void f1(void *y) { return apply(x1, y); }
|
||||
void *x2; void f2(void *y) { return apply(x2, y); }
|
||||
void *x3; void f3(void *y) { return apply(x3, y); }
|
||||
...
|
||||
void *(h[]) = { f1, f2, f3, ... }
|
||||
```
|
||||
|
||||
and by allotting each of them when a closure is needed.
|
||||
|
||||
+24
-25
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,17 +141,17 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2013_endoh1">2013 endoh1 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">./endoh1</span> <span class="pp">[</span><span class="ss">file.lazy</span><span class="pp">]</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh1</span> <span class="pp">[</span><span class="ss">file.lazy</span><span class="pp">]</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>You might also enjoy running:</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">cc</span> <span class="at">-E</span> endoh1.c <span class="kw">|</span> <span class="fu">less</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-E</span> endoh1.c <span class="kw">|</span> <span class="fu">less</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>We liked this entry because it can serve as a standalone program as well as an
|
||||
include file; and, as usual, because its input data is at least as obfuscated as
|
||||
@@ -161,23 +160,23 @@ the program itself.</p>
|
||||
4x longer to compile it with -O3 than without, compared to clang’s 2x.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="remarks">Remarks</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">less</span> endoh1.c</span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> <span class="at">-o</span> endoh1 endoh1.c</span>
|
||||
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh1</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">less</span> endoh1.c</span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="at">-o</span> endoh1 endoh1.c</span>
|
||||
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh1</span></span></code></pre></div>
|
||||
<p>… Isn’t there any more to it?</p>
|
||||
<p>Yes, of course.</p>
|
||||
<p>This is a tool <em>for C programmers</em> to play the <a href="http://en.wikipedia.org/wiki/SKI_combinator_calculus">SKI combinator calculus</a>,
|
||||
especially, <a href="https://tromp.github.io/cl/lazy-k.html">Lazy K</a>.</p>
|
||||
<p>This program will shine when it is used as a library. For example,
|
||||
<a href="hello.lazy">hello.lazy</a> is a “Hello world” program written in Lazy K.</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">$</span> lazy hello.lazy</span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Hello,</span> world!</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> lazy hello.lazy</span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Hello,</span> world!</span></code></pre></div>
|
||||
<p>where <code>lazy</code> is <a href="https://github.com/irori/lazyk">a reference implementation of Lazy K</a>. At the same time,
|
||||
<a href="hello.lazy">hello.lazy</a> is <em>a valid C program</em> that uses <a href="endoh1.c">endoh1.c</a>
|
||||
as a library.</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> gcc <span class="at">-o</span> hello <span class="at">-xc</span> hello.lazy</span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./hello</span>
|
||||
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Hello,</span> world!</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> gcc <span class="at">-o</span> hello <span class="at">-xc</span> hello.lazy</span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./hello</span>
|
||||
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">Hello,</span> world!</span></code></pre></div>
|
||||
<p>In other words, this program is a kind of <a href="http://en.wikipedia.org/wiki/Polyglot_%28computing%29">polyglot</a>.</p>
|
||||
<p>The usage is simple: you just have to wrap Lazy K program with <code>#include "endoh1.c"</code>. Note that <code>#</code> is a comment in Lazy K.</p>
|
||||
<h3 id="obfuscation">Obfuscation</h3>
|
||||
@@ -211,9 +210,9 @@ section</a>.</p>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<p>Recent compilers with <code>-Wall -W -Wextra -pedantic</code> say nothing.</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">gcc</span> <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> prog.c</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> prog.c</span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="ex">tcc</span> <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> prog.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> prog.c</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> prog.c</span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">tcc</span> <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> prog.c</span></code></pre></div>
|
||||
<p>I think it will work on almost all platforms. I confirmed:</p>
|
||||
<ul>
|
||||
<li>Ubuntu Linux</li>
|
||||
@@ -236,11 +235,11 @@ evaluates it.</p>
|
||||
combinator calculus. The rewriting rules are shown in the shape of the code.</p>
|
||||
<h4 id="abuse-of-function-pointers">Abuse of function pointers</h4>
|
||||
<p>Consider a sequence of function applications in C:</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>s<span class="op">(</span>x<span class="op">)(</span>x<span class="op">)(</span>x<span class="op">)(</span>x<span class="op">)...</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> s<span class="op">(</span>x<span class="op">)(</span>x<span class="op">)(</span>x<span class="op">)(</span>x<span class="op">)...</span></span></code></pre></div>
|
||||
<p>What type should <code>s</code> have? Unfortunately, C does <em>not</em> provide a “recursive
|
||||
type”, such as <code>typedef f (*f)();</code>.</p>
|
||||
<p>So, I used a heavily nested function pointer type:</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="kw">typedef</span> <span class="dt">void</span> <span class="op">*(*(*(*...(*(</span>f<span class="op">))()...)())())</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">typedef</span> <span class="dt">void</span> <span class="op">*(*(*(*...(*(</span>f<span class="op">))()...)())())</span></span></code></pre></div>
|
||||
<p>This limits how many arguments one function can be consecutively applied to.
|
||||
But you can increase the number by tweaking the definition of macro <code>p</code>.</p>
|
||||
<h4 id="code-duplication-by-macros">Code duplication by macros</h4>
|
||||
@@ -256,11 +255,11 @@ environment which is a reference to non-local variable.</p>
|
||||
(It is feasible by dynamic code generation, but it is far from portable.)</p>
|
||||
<p>So, I addressed this issue by generating many function definitions
|
||||
statically by (ab)using macros:</p>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> <span class="op">*</span>x1<span class="op">;</span> <span class="dt">void</span> f1<span class="op">(</span><span class="dt">void</span> <span class="op">*</span>y<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> apply<span class="op">(</span>x1<span class="op">,</span> y<span class="op">);</span> <span class="op">}</span></span>
|
||||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> <span class="op">*</span>x2<span class="op">;</span> <span class="dt">void</span> f2<span class="op">(</span><span class="dt">void</span> <span class="op">*</span>y<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> apply<span class="op">(</span>x2<span class="op">,</span> y<span class="op">);</span> <span class="op">}</span></span>
|
||||
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> <span class="op">*</span>x3<span class="op">;</span> <span class="dt">void</span> f3<span class="op">(</span><span class="dt">void</span> <span class="op">*</span>y<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> apply<span class="op">(</span>x3<span class="op">,</span> y<span class="op">);</span> <span class="op">}</span></span>
|
||||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="op">...</span></span>
|
||||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> <span class="op">*(</span>h<span class="op">[])</span> <span class="op">=</span> <span class="op">{</span> f1<span class="op">,</span> f2<span class="op">,</span> f3<span class="op">,</span> <span class="op">...</span> <span class="op">}</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> <span class="op">*</span>x1<span class="op">;</span> <span class="dt">void</span> f1<span class="op">(</span><span class="dt">void</span> <span class="op">*</span>y<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> apply<span class="op">(</span>x1<span class="op">,</span> y<span class="op">);</span> <span class="op">}</span></span>
|
||||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> <span class="op">*</span>x2<span class="op">;</span> <span class="dt">void</span> f2<span class="op">(</span><span class="dt">void</span> <span class="op">*</span>y<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> apply<span class="op">(</span>x2<span class="op">,</span> y<span class="op">);</span> <span class="op">}</span></span>
|
||||
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> <span class="op">*</span>x3<span class="op">;</span> <span class="dt">void</span> f3<span class="op">(</span><span class="dt">void</span> <span class="op">*</span>y<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> apply<span class="op">(</span>x3<span class="op">,</span> y<span class="op">);</span> <span class="op">}</span></span>
|
||||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="op">...</span></span>
|
||||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> <span class="op">*(</span>h<span class="op">[])</span> <span class="op">=</span> <span class="op">{</span> f1<span class="op">,</span> f2<span class="op">,</span> f3<span class="op">,</span> <span class="op">...</span> <span class="op">}</span></span></code></pre></div>
|
||||
<p>and by allotting each of them when a closure is needed.</p>
|
||||
<p>This leads to another limitation: the number of pre-defined closures limits how
|
||||
many identifiers (<code>S</code> <code>K</code> <code>I</code>) one program can use.</p>
|
||||
|
||||
+19
-19
@@ -1,14 +1,14 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
make check
|
||||
make check
|
||||
```
|
||||
|
||||
You'll need to have both [Ruby](https://www.ruby-lang.org) and
|
||||
@@ -24,7 +24,7 @@ download one or both before exiting.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
less jpeg.c
|
||||
less jpeg.c
|
||||
```
|
||||
|
||||
Next look at `jpeg.jpg` in an image viewer program.
|
||||
@@ -74,25 +74,25 @@ This program uses (a part of) Proggy Tiny Fonts
|
||||
which is distributed in MIT License:
|
||||
|
||||
```
|
||||
Copyright (c) 2004, 2005 Tristan Grimmer
|
||||
Copyright (c) 2004, 2005 Tristan Grimmer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
|
||||
|
||||
|
||||
+20
-21
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,9 +141,9 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> check</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> check</span></code></pre></div>
|
||||
<p>You’ll need to have both <a href="https://www.ruby-lang.org">Ruby</a> and
|
||||
<a href="https://imagemagick.org/">ImageMagick</a> installed to run all the automated
|
||||
checks.</p>
|
||||
@@ -153,7 +152,7 @@ section to enjoy the entry. The <a href="Makefile">Makefile</a> <code>check</cod
|
||||
you have both and if either is not found it will report it and tell you where to
|
||||
download one or both before exiting.</p>
|
||||
<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="fu">less</span> jpeg.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">less</span> jpeg.c</span></code></pre></div>
|
||||
<p>Next look at <code>jpeg.jpg</code> in an image viewer program.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>This is a program which, when fed its own source, generates a program that
|
||||
@@ -187,25 +186,25 @@ year.</p>
|
||||
<h3 id="legal">Legal</h3>
|
||||
<p>This program uses (a part of) Proggy Tiny Fonts
|
||||
which is distributed in MIT License:</p>
|
||||
<pre><code>Copyright (c) 2004, 2005 Tristan Grimmer
|
||||
<pre><code> Copyright (c) 2004, 2005 Tristan Grimmer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.</code></pre>
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.</code></pre>
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||||
|
||||
+35
-35
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2013 endoh3 bugs](../../bugs.html#2013_endoh3).
|
||||
@@ -19,7 +19,7 @@ For more detailed information see [2013 endoh3 bugs](../../bugs.html#2013_endoh3
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./endoh3
|
||||
./endoh3
|
||||
```
|
||||
|
||||
This program plays sound. See [FAQ 3.10 - How do I compile and use an IOCCC
|
||||
@@ -30,13 +30,13 @@ system up for this or if you want to verify that everything is oky.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
|
||||
./try.sh ABC
|
||||
./try.sh ABC
|
||||
|
||||
./try.sh test.abc yankee.abc
|
||||
./try.sh test.abc yankee.abc
|
||||
|
||||
./try.sh *.abc
|
||||
./try.sh *.abc
|
||||
```
|
||||
|
||||
The script will check for SoX first and next `padsp` from `PulseAudio` and
|
||||
@@ -76,28 +76,28 @@ notation](http://en.wikipedia.org/wiki/ABC_notation).
|
||||
Try:
|
||||
|
||||
```sh
|
||||
cc -o endoh3 endoh3.c
|
||||
echo "CDEFGABc" | ./endoh3 > /dev/dsp
|
||||
cc -o endoh3 endoh3.c
|
||||
echo "CDEFGABc" | ./endoh3 > /dev/dsp
|
||||
```
|
||||
|
||||
If `/dev/dsp` is not available on your system, use an OSS sound wrapper such
|
||||
as `padsp` or `aoss`:
|
||||
|
||||
```sh
|
||||
echo "CDEFGABc" | ./endoh3 | padsp tee /dev/dsp > /dev/null
|
||||
echo "CDEFGABc" | ./endoh3 | padsp tee /dev/dsp > /dev/null
|
||||
```
|
||||
|
||||
If you are using Mac OS X, try [sox](http://sox.sourceforge.net/) like so:
|
||||
|
||||
```sh
|
||||
echo "CDEFGABc" | ./endoh3 | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
|
||||
echo "CDEFGABc" | ./endoh3 | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
|
||||
```
|
||||
|
||||
If that does not work, use the attached script to convert the output into a wave
|
||||
file format:
|
||||
|
||||
```sh
|
||||
echo "CDEFGABc" | ./endoh3 | ruby wavify.rb > cde.wav
|
||||
echo "CDEFGABc" | ./endoh3 | ruby wavify.rb > cde.wav
|
||||
```
|
||||
|
||||
and play `cde.wav`.
|
||||
@@ -108,8 +108,8 @@ do so like:
|
||||
|
||||
|
||||
```sh
|
||||
cat twinkle.abc | ./endoh3 > /dev/dsp
|
||||
cat menuet.abc | ./endoh3 > /dev/dsp
|
||||
cat twinkle.abc | ./endoh3 > /dev/dsp
|
||||
cat menuet.abc | ./endoh3 > /dev/dsp
|
||||
```
|
||||
|
||||
but you should be able to modify it a way to meet your system requirements as
|
||||
@@ -186,37 +186,37 @@ You know, it is ["the famous song"](http://en.wikipedia.org/wiki/4%E2%80%B233%E2
|
||||
Here is a magical expression which I found by brute-force:
|
||||
|
||||
```c
|
||||
(c % 32 + 5) * 9 / 5 % 13 + n / 32 * 12 - 22
|
||||
(c % 32 + 5) * 9 / 5 % 13 + n / 32 * 12 - 22
|
||||
```
|
||||
|
||||
Interestingly, it converts an ASCII number of ABC notes
|
||||
to the corresponding tone number.
|
||||
|
||||
```
|
||||
'C' (ASCII 67) => 3
|
||||
'D' (ASCII 68) => 5
|
||||
'E' (ASCII 69) => 7
|
||||
'F' (ASCII 70) => 9
|
||||
'G' (ASCII 71) => 10
|
||||
'A' (ASCII 65) => 12
|
||||
'B' (ASCII 66) => 14
|
||||
'c' (ASCII 99) => 15
|
||||
'd' (ASCII 100) => 17
|
||||
'e' (ASCII 101) => 19
|
||||
'f' (ASCII 102) => 20
|
||||
'g' (ASCII 103) => 22
|
||||
'a' (ASCII 97) => 24
|
||||
'b' (ASCII 98) => 26
|
||||
'C' (ASCII 67) => 3
|
||||
'D' (ASCII 68) => 5
|
||||
'E' (ASCII 69) => 7
|
||||
'F' (ASCII 70) => 9
|
||||
'G' (ASCII 71) => 10
|
||||
'A' (ASCII 65) => 12
|
||||
'B' (ASCII 66) => 14
|
||||
'c' (ASCII 99) => 15
|
||||
'd' (ASCII 100) => 17
|
||||
'e' (ASCII 101) => 19
|
||||
'f' (ASCII 102) => 20
|
||||
'g' (ASCII 103) => 22
|
||||
'a' (ASCII 97) => 24
|
||||
'b' (ASCII 98) => 26
|
||||
```
|
||||
|
||||
By the way, you can write a half-tone by the following characters.
|
||||
|
||||
```
|
||||
'K' => 4 (= C#)
|
||||
'L' => 6 (= D#)
|
||||
'U' => 8 (= F#)
|
||||
'V' => 11 (= G#)
|
||||
'P' => 13 (= A#)
|
||||
'K' => 4 (= C#)
|
||||
'L' => 6 (= D#)
|
||||
'U' => 8 (= F#)
|
||||
'V' => 11 (= G#)
|
||||
'P' => 13 (= A#)
|
||||
```
|
||||
|
||||
Note that the tone numbers simply enumerate the semi-tone steps. So we can
|
||||
@@ -229,7 +229,7 @@ frequency by multiplying the value by `n` times.
|
||||
Finally, the following code generates a saw wave:
|
||||
|
||||
```c
|
||||
for(c = 0; c < len; c++) putchar(a = n * D);
|
||||
for(c = 0; c < len; c++) putchar(a = n * D);
|
||||
```
|
||||
|
||||
where `D` is a frequency and `a` is a variable whose type is `char`. By
|
||||
|
||||
+36
-37
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,24 +141,24 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2013_endoh3">2013 endoh3 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">./endoh3</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh3</span></span></code></pre></div>
|
||||
<p>This program plays sound. See <a href="../../faq.html#sox">FAQ 3.10 - How do I compile and use an IOCCC
|
||||
entry that requires sound?</a> if you do not know how to set your
|
||||
system up for this or if you want to verify that everything is oky.</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>
|
||||
<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">./try.sh</span> ABC</span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> ABC</span>
|
||||
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> test.abc yankee.abc</span>
|
||||
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> test.abc yankee.abc</span>
|
||||
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> <span class="pp">*</span>.abc</span></code></pre></div>
|
||||
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> <span class="pp">*</span>.abc</span></code></pre></div>
|
||||
<p>The script will check for SoX first and next <code>padsp</code> from <code>PulseAudio</code> and
|
||||
finally if neither are found if you have <code>ruby(1)</code> installed it’ll use the
|
||||
included ruby script to convert it to a WAV file for you to play.</p>
|
||||
@@ -181,21 +180,21 @@ will remain the same for historical purposes.</p>
|
||||
<p>This is a sound synthesizer for a subset of <a href="http://en.wikipedia.org/wiki/ABC_notation">ABC music
|
||||
notation</a>.</p>
|
||||
<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="fu">cc</span> <span class="at">-o</span> endoh3 endoh3.c</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"CDEFGABc"</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="op">></span> /dev/dsp</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-o</span> endoh3 endoh3.c</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">"CDEFGABc"</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="op">></span> /dev/dsp</span></code></pre></div>
|
||||
<p>If <code>/dev/dsp</code> is not available on your system, use an OSS sound wrapper such
|
||||
as <code>padsp</code> or <code>aoss</code>:</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="bu">echo</span> <span class="st">"CDEFGABc"</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="kw">|</span> <span class="ex">padsp</span> tee /dev/dsp <span class="op">></span> /dev/null</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">"CDEFGABc"</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="kw">|</span> <span class="ex">padsp</span> tee /dev/dsp <span class="op">></span> /dev/null</span></code></pre></div>
|
||||
<p>If you are using Mac OS X, try <a href="http://sox.sourceforge.net/">sox</a> like so:</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="bu">echo</span> <span class="st">"CDEFGABc"</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="kw">|</span> <span class="fu">sox</span> <span class="at">-q</span> <span class="at">-traw</span> <span class="at">-r8000</span> <span class="at">-b8</span> <span class="at">-e</span> unsigned-integer <span class="at">-</span> <span class="at">-tcoreaudio</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">"CDEFGABc"</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="kw">|</span> <span class="fu">sox</span> <span class="at">-q</span> <span class="at">-traw</span> <span class="at">-r8000</span> <span class="at">-b8</span> <span class="at">-e</span> unsigned-integer <span class="at">-</span> <span class="at">-tcoreaudio</span></span></code></pre></div>
|
||||
<p>If that does not work, use the attached script to convert the output into a wave
|
||||
file format:</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="bu">echo</span> <span class="st">"CDEFGABc"</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="kw">|</span> <span class="ex">ruby</span> wavify.rb <span class="op">></span> cde.wav</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">"CDEFGABc"</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="kw">|</span> <span class="ex">ruby</span> wavify.rb <span class="op">></span> cde.wav</span></code></pre></div>
|
||||
<p>and play <code>cde.wav</code>.</p>
|
||||
<p>You can also enjoy some music scores that I attached. With <code>/dev/dsp</code> you can
|
||||
do so like:</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">cat</span> twinkle.abc <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="op">></span> /dev/dsp</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> menuet.abc <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="op">></span> /dev/dsp</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> twinkle.abc <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="op">></span> /dev/dsp</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> menuet.abc <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="op">></span> /dev/dsp</span></code></pre></div>
|
||||
<p>but you should be able to modify it a way to meet your system requirements as
|
||||
described above.</p>
|
||||
<h3 id="obfuscation">Obfuscation</h3>
|
||||
@@ -258,29 +257,29 @@ But I do not attach it to protect you from W****r.</p>
|
||||
You know, it is <a href="http://en.wikipedia.org/wiki/4%E2%80%B233%E2%80%B3">“the famous song”</a>.</p>
|
||||
<h3 id="spoiler">Spoiler</h3>
|
||||
<p>Here is a magical expression which I found by brute-force:</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="op">(</span>c <span class="op">%</span> <span class="dv">32</span> <span class="op">+</span> <span class="dv">5</span><span class="op">)</span> <span class="op">*</span> <span class="dv">9</span> <span class="op">/</span> <span class="dv">5</span> <span class="op">%</span> <span class="dv">13</span> <span class="op">+</span> n <span class="op">/</span> <span class="dv">32</span> <span class="op">*</span> <span class="dv">12</span> <span class="op">-</span> <span class="dv">22</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="op">(</span>c <span class="op">%</span> <span class="dv">32</span> <span class="op">+</span> <span class="dv">5</span><span class="op">)</span> <span class="op">*</span> <span class="dv">9</span> <span class="op">/</span> <span class="dv">5</span> <span class="op">%</span> <span class="dv">13</span> <span class="op">+</span> n <span class="op">/</span> <span class="dv">32</span> <span class="op">*</span> <span class="dv">12</span> <span class="op">-</span> <span class="dv">22</span></span></code></pre></div>
|
||||
<p>Interestingly, it converts an ASCII number of ABC notes
|
||||
to the corresponding tone number.</p>
|
||||
<pre><code>'C' (ASCII 67) => 3
|
||||
'D' (ASCII 68) => 5
|
||||
'E' (ASCII 69) => 7
|
||||
'F' (ASCII 70) => 9
|
||||
'G' (ASCII 71) => 10
|
||||
'A' (ASCII 65) => 12
|
||||
'B' (ASCII 66) => 14
|
||||
'c' (ASCII 99) => 15
|
||||
'd' (ASCII 100) => 17
|
||||
'e' (ASCII 101) => 19
|
||||
'f' (ASCII 102) => 20
|
||||
'g' (ASCII 103) => 22
|
||||
'a' (ASCII 97) => 24
|
||||
'b' (ASCII 98) => 26</code></pre>
|
||||
<pre><code> 'C' (ASCII 67) => 3
|
||||
'D' (ASCII 68) => 5
|
||||
'E' (ASCII 69) => 7
|
||||
'F' (ASCII 70) => 9
|
||||
'G' (ASCII 71) => 10
|
||||
'A' (ASCII 65) => 12
|
||||
'B' (ASCII 66) => 14
|
||||
'c' (ASCII 99) => 15
|
||||
'd' (ASCII 100) => 17
|
||||
'e' (ASCII 101) => 19
|
||||
'f' (ASCII 102) => 20
|
||||
'g' (ASCII 103) => 22
|
||||
'a' (ASCII 97) => 24
|
||||
'b' (ASCII 98) => 26</code></pre>
|
||||
<p>By the way, you can write a half-tone by the following characters.</p>
|
||||
<pre><code>'K' => 4 (= C#)
|
||||
'L' => 6 (= D#)
|
||||
'U' => 8 (= F#)
|
||||
'V' => 11 (= G#)
|
||||
'P' => 13 (= A#)</code></pre>
|
||||
<pre><code> 'K' => 4 (= C#)
|
||||
'L' => 6 (= D#)
|
||||
'U' => 8 (= F#)
|
||||
'V' => 11 (= G#)
|
||||
'P' => 13 (= A#)</code></pre>
|
||||
<p>Note that the tone numbers simply enumerate the semi-tone steps. So we can
|
||||
calculate the frequency easily: <code>pow(2, n / 12.0)</code>. Then, how can we calculate
|
||||
<code>pow</code> without <code>math.h</code>? <code>pow(2, 1.0 / 12.0)</code> is approximated by <code>89/84.</code>. (I
|
||||
@@ -288,7 +287,7 @@ found this approximation by using the <a href="http://en.wikipedia.org/wiki/Ster
|
||||
tree</a>.) We can gain the
|
||||
frequency by multiplying the value by <code>n</code> times.</p>
|
||||
<p>Finally, the following code generates a saw wave:</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="cf">for</span><span class="op">(</span>c <span class="op">=</span> <span class="dv">0</span><span class="op">;</span> c <span class="op"><</span> len<span class="op">;</span> c<span class="op">++)</span> putchar<span class="op">(</span>a <span class="op">=</span> n <span class="op">*</span> D<span class="op">);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span><span class="op">(</span>c <span class="op">=</span> <span class="dv">0</span><span class="op">;</span> c <span class="op"><</span> len<span class="op">;</span> c<span class="op">++)</span> putchar<span class="op">(</span>a <span class="op">=</span> n <span class="op">*</span> D<span class="op">);</span></span></code></pre></div>
|
||||
<p>where <code>D</code> is a frequency and <code>a</code> is a variable whose type is <code>char</code>. By
|
||||
assigning <code>float</code> to <code>char</code> variable, the implicit type conversion is performed
|
||||
from <code>float</code> to <code>char</code> (modulo 256).</p>
|
||||
|
||||
+15
-15
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
If you wish to change the size (see the [Author's remarks](#authors-remarks)
|
||||
@@ -9,7 +9,7 @@ below) you can do so with the `SIZE` variable. For instance you can do:
|
||||
|
||||
|
||||
```sh
|
||||
make clobber SIZE=50,50 all
|
||||
make clobber SIZE=50,50 all
|
||||
```
|
||||
|
||||
but you can also do this directly with the [endoh4.sh](endoh4.sh) script as
|
||||
@@ -21,7 +21,7 @@ described below.
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2013 endoh4 bugs](../../bugs.html#2013_endoh4).
|
||||
@@ -30,8 +30,8 @@ For more detailed information see [2013 endoh4 bugs](../../bugs.html#2013_endoh4
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./endoh4 < file
|
||||
./endoh4.sh file
|
||||
./endoh4 < file
|
||||
./endoh4.sh file
|
||||
```
|
||||
|
||||
The second form is preferable as it will temporarily make the cursor invisible
|
||||
@@ -42,7 +42,7 @@ line it will feed to the program [endoh4.c](endoh4.c).
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./endoh4.sh cube.txt
|
||||
./endoh4.sh cube.txt
|
||||
```
|
||||
|
||||
Hit ctrl-c to end the program.
|
||||
@@ -52,13 +52,13 @@ The author recommends the use of xterm.
|
||||
For an example, if you are a football/soccer fan, try:
|
||||
|
||||
```sh
|
||||
./endoh4.sh solids/archimedian-solid/a11-truncated-icosahedron.txt
|
||||
./endoh4.sh solids/archimedian-solid/a11-truncated-icosahedron.txt
|
||||
```
|
||||
|
||||
You can provide more than one file:
|
||||
|
||||
```sh
|
||||
./endoh4.sh solids/archimedian-solid/a11-truncated-icosahedron.txt cube.txt
|
||||
./endoh4.sh solids/archimedian-solid/a11-truncated-icosahedron.txt cube.txt
|
||||
```
|
||||
|
||||
Hit ctrl-c/intr to go to the next file.
|
||||
@@ -67,7 +67,7 @@ If you wish to change the size to `50,50` without passing any arg:
|
||||
|
||||
|
||||
```sh
|
||||
SIZE=50,50 ./endoh4.sh
|
||||
SIZE=50,50 ./endoh4.sh
|
||||
```
|
||||
|
||||
Not specifying a file feeds [endoh4.c](endoh4.c) to the program.
|
||||
@@ -116,15 +116,15 @@ clang, and tcc. It should not trigger warnings with `-pedantic` and `-Wextra`.
|
||||
You may want to use `tput` to hide the terminal cursor.
|
||||
|
||||
```sh
|
||||
tput civis
|
||||
./endoh4 < cube.txt
|
||||
tput cnorm
|
||||
tput civis
|
||||
./endoh4 < cube.txt
|
||||
tput cnorm
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
./endoh4.sh cube.txt
|
||||
./endoh4.sh cube.txt
|
||||
```
|
||||
|
||||
### Bonuses
|
||||
@@ -132,14 +132,14 @@ or
|
||||
You can change the screen size. Let the aspect ratio be about 3:1.
|
||||
|
||||
```sh
|
||||
cc -DS=120,40 -o endoh4 endoh4.c
|
||||
cc -DS=120,40 -o endoh4 endoh4.c
|
||||
```
|
||||
|
||||
The shape of this code is the geometric net of a regular tetrahedron.
|
||||
So, try:
|
||||
|
||||
```sh
|
||||
./endoh4 < endoh4.c # or ./endoh4.sh
|
||||
./endoh4 < endoh4.c # or ./endoh4.sh
|
||||
```
|
||||
|
||||
The [solids/](solids/) directory includes various solid data:
|
||||
|
||||
+16
-17
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,33 +141,33 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>If you wish to change the size (see the <a href="#authors-remarks">Author’s remarks</a>
|
||||
below) you can do so with the <code>SIZE</code> variable. For instance you can do:</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> clobber SIZE=50,50 all</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber SIZE=50,50 all</span></code></pre></div>
|
||||
<p>but you can also do this directly with the <a href="endoh4.sh">endoh4.sh</a> script as
|
||||
described below.</p>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2013_endoh4">2013 endoh4 bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</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">./endoh4</span> <span class="op"><</span> file</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh4.sh</span> file</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4</span> <span class="op"><</span> file</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4.sh</span> file</span></code></pre></div>
|
||||
<p>The second form is preferable as it will temporarily make the cursor invisible
|
||||
as recommended by the author. If no file is specified in the <code>./endoh4.sh</code> command
|
||||
line it will feed to the program <a href="endoh4.c">endoh4.c</a>.</p>
|
||||
<h2 id="try">Try:</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="ex">./endoh4.sh</span> cube.txt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4.sh</span> cube.txt</span></code></pre></div>
|
||||
<p>Hit ctrl-c to end the program.</p>
|
||||
<p>The author recommends the use of xterm.</p>
|
||||
<p>For an example, if you are a football/soccer fan, 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="ex">./endoh4.sh</span> solids/archimedian-solid/a11-truncated-icosahedron.txt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4.sh</span> solids/archimedian-solid/a11-truncated-icosahedron.txt</span></code></pre></div>
|
||||
<p>You can provide more than one file:</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">./endoh4.sh</span> solids/archimedian-solid/a11-truncated-icosahedron.txt cube.txt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4.sh</span> solids/archimedian-solid/a11-truncated-icosahedron.txt cube.txt</span></code></pre></div>
|
||||
<p>Hit ctrl-c/intr to go to the next file.</p>
|
||||
<p>If you wish to change the size to <code>50,50</code> without passing any arg:</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="va">SIZE</span><span class="op">=</span>50,50 <span class="ex">./endoh4.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="va">SIZE</span><span class="op">=</span>50,50 <span class="ex">./endoh4.sh</span></span></code></pre></div>
|
||||
<p>Not specifying a file feeds <a href="endoh4.c">endoh4.c</a> to the program.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>This program is formatted as the net for a tetrahedron (hint: try feeding the
|
||||
@@ -204,17 +203,17 @@ triangulated)</li>
|
||||
clang, and tcc. It should not trigger warnings with <code>-pedantic</code> and <code>-Wextra</code>.</p>
|
||||
<h3 id="tips">Tips</h3>
|
||||
<p>You may want to use <code>tput</code> to hide the terminal cursor.</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">tput</span> civis</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh4</span> <span class="op"><</span> cube.txt</span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="fu">tput</span> cnorm</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">tput</span> civis</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4</span> <span class="op"><</span> cube.txt</span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">tput</span> cnorm</span></code></pre></div>
|
||||
<p>or</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">./endoh4.sh</span> cube.txt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4.sh</span> cube.txt</span></code></pre></div>
|
||||
<h3 id="bonuses">Bonuses</h3>
|
||||
<p>You can change the screen size. Let the aspect ratio be about 3:1.</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">cc</span> <span class="at">-DS</span><span class="op">=</span>120,40 <span class="at">-o</span> endoh4 endoh4.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-DS</span><span class="op">=</span>120,40 <span class="at">-o</span> endoh4 endoh4.c</span></code></pre></div>
|
||||
<p>The shape of this code is the geometric net of a regular tetrahedron.
|
||||
So, 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="ex">./endoh4</span> <span class="op"><</span> endoh4.c <span class="co"># or ./endoh4.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4</span> <span class="op"><</span> endoh4.c <span class="co"># or ./endoh4.sh</span></span></code></pre></div>
|
||||
<p>The <a href="solids/">solids/</a> directory includes various solid data:</p>
|
||||
<ul>
|
||||
<li><a href="http://en.wikipedia.org/wiki/Platonic_solid">Platonic solids</a></li>
|
||||
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make all
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2013 hou bugs](../../bugs.html#2013_hou).
|
||||
@@ -19,7 +19,7 @@ For more detailed information see [2013 hou bugs](../../bugs.html#2013_hou).
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./hou [scene-file-name] [options]
|
||||
./hou [scene-file-name] [options]
|
||||
```
|
||||
|
||||
Follow the instructions in `stdout`, preferably with an auto-refreshing PPM
|
||||
@@ -30,7 +30,7 @@ effects should be more or less recognizable when you see 16.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
Try opening the file noted by the program then let the program run a while and
|
||||
@@ -63,8 +63,8 @@ NOTE: the author refers to [a.c](a.c), placed in a gzipped file `a.c.gz`. We do
|
||||
include it but it can be generated like:
|
||||
|
||||
```sh
|
||||
cc -Wall hou.c -o hou -lm
|
||||
./hou > a.c
|
||||
cc -Wall hou.c -o hou -lm
|
||||
./hou > a.c
|
||||
```
|
||||
|
||||
but there is no need to do this as the Makefile takes care of it without even
|
||||
@@ -79,7 +79,7 @@ This program is a programmable rendering engine with a built-in default scene.
|
||||
The standard command line is:
|
||||
|
||||
```sh
|
||||
./hou [scene-file-name] [options]
|
||||
./hou [scene-file-name] [options]
|
||||
```
|
||||
|
||||
As `hou` runs, it writes a progressively refining image to a ppm file specified
|
||||
@@ -182,11 +182,11 @@ doesn't copy saved sessions across different endianness.
|
||||
### Spoiler
|
||||
|
||||
```
|
||||
3225 3225 3225 9 9 3225 3225
|
||||
1 1 1 1 1 1 1 1 1 1
|
||||
4225 1226 1 1 1 1 1222 1226
|
||||
1 1 1 1 1 1 1 1 1
|
||||
4226 1 4226 8 4222 4226 1 1
|
||||
3225 3225 3225 9 9 3225 3225
|
||||
1 1 1 1 1 1 1 1 1 1
|
||||
4225 1226 1 1 1 1 1222 1226
|
||||
1 1 1 1 1 1 1 1 1
|
||||
4226 1 4226 8 4222 4226 1 1
|
||||
```
|
||||
|
||||
The program consists of a recursive-descent interpreter, a `3DDDA` (3D Discrete
|
||||
|
||||
+219
-219
@@ -125,38 +125,38 @@
|
||||
<h1 id="scene-format-documentation">Scene format documentation</h1>
|
||||
<p>The file must be encoded in UTF-8 as the BOF marker indicates.</p>
|
||||
<p>You can directly feed it to the renderer. If you’re wondering about what the following code block does, that’s why:)</p>
|
||||
<pre><code>@|?|?z#
|
||||
@|||?z&
|
||||
>?Sedvf
|
||||
??Tdeu#
|
||||
>>Tdeui
|
||||
??Tdmmf
|
||||
??[[euf
|
||||
?}?Oq}e
|
||||
?}?Oqqf
|
||||
v}?|q}e
|
||||
v}?|qqf
|
||||
?Sj|?{f
|
||||
?Tjk?{e
|
||||
FF?Oqq$
|
||||
RR?Oqq$
|
||||
^^?Oqq$
|
||||
jj?Oqq$
|
||||
vv?|qq$
|
||||
IOBMqqe
|
||||
U]BMqqe
|
||||
aiBMqqe
|
||||
muBMqqe
|
||||
EEEJpp%
|
||||
QQEJpp%
|
||||
]]EJpp%
|
||||
iiEJpp%
|
||||
uuEJpp%
|
||||
ZnY|{|e
|
||||
[mZ|\{\{#
|
||||
[mZ|||f
|
||||
kkdr\{\{\%
|
||||
lkdr\{\{></code></pre>
|
||||
<pre><code> @|?|?z#
|
||||
@|||?z&
|
||||
>?Sedvf
|
||||
??Tdeu#
|
||||
>>Tdeui
|
||||
??Tdmmf
|
||||
??[[euf
|
||||
?}?Oq}e
|
||||
?}?Oqqf
|
||||
v}?|q}e
|
||||
v}?|qqf
|
||||
?Sj|?{f
|
||||
?Tjk?{e
|
||||
FF?Oqq$
|
||||
RR?Oqq$
|
||||
^^?Oqq$
|
||||
jj?Oqq$
|
||||
vv?|qq$
|
||||
IOBMqqe
|
||||
U]BMqqe
|
||||
aiBMqqe
|
||||
muBMqqe
|
||||
EEEJpp%
|
||||
QQEJpp%
|
||||
]]EJpp%
|
||||
iiEJpp%
|
||||
uuEJpp%
|
||||
ZnY|{|e
|
||||
[mZ|\{\{#
|
||||
[mZ|||f
|
||||
kkdr\{\{\%
|
||||
lkdr\{\{></code></pre>
|
||||
<h2 id="basic-structure">Basic structure</h2>
|
||||
<p>A scene file begins with arbitrary binary data, followed by several shader
|
||||
functions.</p>
|
||||
@@ -164,33 +164,33 @@ functions.</p>
|
||||
character. There are some special function names, which will be explained below.</p>
|
||||
<p>The language used to write shader functions is very simple. Basically, you write
|
||||
a sequence of assignment statements like this:</p>
|
||||
<pre><code>A=A+D
|
||||
B=B+E</code></pre>
|
||||
<pre><code> A=A+D
|
||||
B=B+E</code></pre>
|
||||
<p>Namely, you write a one-character variable name, an equal sign (<code>=</code>), followed
|
||||
by an expression (made of operators and one-character variable names, of
|
||||
course).</p>
|
||||
<h2 id="expressions">Expressions</h2>
|
||||
<p>The shader language supports seven operators, listed highest priority first:</p>
|
||||
<pre><code>*/+-<#:</code></pre>
|
||||
<pre><code> */+-<#:</code></pre>
|
||||
<p><code>*/+-<</code> each mean what they mean in C, but the priority part is a bit different.
|
||||
Basically, <code>*</code> has higher priority than <code>/</code>, so <code>A/4*4</code> actually computes
|
||||
<code>A/(4*4)</code>. And you can’t write <code>(A/4)*4</code> – brackets are not supported. As an
|
||||
advice, keep your expressions simple :) If you really needs to write something
|
||||
like <code>C=(A/4)*4</code>, write instead:</p>
|
||||
<pre><code>B=A/4+
|
||||
C=B*4</code></pre>
|
||||
<pre><code> B=A/4+
|
||||
C=B*4</code></pre>
|
||||
<p>The <code>#</code> operator acts somewhat like the C <code>?:</code>. It returns one of its two
|
||||
operands based on, what else, the value of variable <code>#</code>. When <code>#</code> is true, <code>#</code>
|
||||
returns its second operand.</p>
|
||||
<p>The <code>:</code> operator calls built-in functions. The first operand is the function id and the second is the parameter. Here is a list of functions:</p>
|
||||
<pre><code>0:x = the x-th byte of the scene file
|
||||
1:x = sin(x*PI)
|
||||
2:x = atan2(x,#)/PI
|
||||
3:x = sqrt(max(x,0))
|
||||
4:x = floor(x)
|
||||
5:x = the next number in the (allegedly random) number sequence, can't be called in volume shaders
|
||||
6:x = value of the variable (char)(120+x)
|
||||
7:x = write #'s value to the variable (char)(120+x)</code></pre>
|
||||
<pre><code> 0:x = the x-th byte of the scene file
|
||||
1:x = sin(x*PI)
|
||||
2:x = atan2(x,#)/PI
|
||||
3:x = sqrt(max(x,0))
|
||||
4:x = floor(x)
|
||||
5:x = the next number in the (allegedly random) number sequence, can't be called in volume shaders
|
||||
6:x = value of the variable (char)(120+x)
|
||||
7:x = write #'s value to the variable (char)(120+x)</code></pre>
|
||||
<p>Contrary to popular belief, the language itself doesn’t support numerical
|
||||
constants. Any character sitting between operators is a variable. When you see
|
||||
1/2, it’s in fact dividing the variable 1’s value by the variable 2’s value. For
|
||||
@@ -208,7 +208,7 @@ the Windows <code>\r\n</code>), and it terminates your function. Also, the first
|
||||
must begin immediately after <code>]</code>.</p>
|
||||
<p>When a function terminates, the interpreter calls the next function specified by
|
||||
variable <code>R</code>. If you want to call function <code>n</code>, just write somewhere:</p>
|
||||
<pre><code>R=n</code></pre>
|
||||
<pre><code> R=n</code></pre>
|
||||
<p>providing you have left <code>n</code> at its initial value. If you want to actually return
|
||||
to the renderer, put in <code>R=0</code>.</p>
|
||||
<p>As you may have noticed, you can put in all kinds of stuff between functions,
|
||||
@@ -224,28 +224,28 @@ material shaders.</p>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre><code>//As an (optional) assignment, figure out what function 'n' does. And why there is a plus sign at every EOL except the last.
|
||||
n]#=1+
|
||||
x=X+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
x=Y+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
x=Z+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1+
|
||||
U=U+2+
|
||||
C=C#d+3*9+
|
||||
#=d+
|
||||
R=0#n</code></pre>
|
||||
<pre><code> //As an (optional) assignment, figure out what function 'n' does. And why there is a plus sign at every EOL except the last.
|
||||
n]#=1+
|
||||
x=X+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
x=Y+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
x=Z+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1+
|
||||
U=U+2+
|
||||
C=C#d+3*9+
|
||||
#=d+
|
||||
R=0#n</code></pre>
|
||||
<hr />
|
||||
<p>The function <code>A</code> initializes global settings:</p>
|
||||
<pre><code>G -- Image width, in pixels
|
||||
H -- Image height, in pixels
|
||||
I -- Perturbation probability
|
||||
J -- Camera ray stratification probability</code></pre>
|
||||
<pre><code> G -- Image width, in pixels
|
||||
H -- Image height, in pixels
|
||||
I -- Perturbation probability
|
||||
J -- Camera ray stratification probability</code></pre>
|
||||
<p>If you have used a MLT renderer before, you probably know what <code>I</code> and <code>J</code> does.
|
||||
If you don’t, well, use the same value as the default scene. Everything
|
||||
converges just fine under suboptimal settings, just a little slower. Generally,
|
||||
@@ -280,17 +280,17 @@ the one facing my bed, to thank me for the effort.</p>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre><code>//As a bonus, find out what the first line does
|
||||
A]#=#-#;"=7:0-p+^;#="+
|
||||
R=n+
|
||||
G=p*:+
|
||||
#=0<B+
|
||||
G=G*2#G+
|
||||
H=G*3/4+
|
||||
I=4/5+
|
||||
J=1/2+
|
||||
C=p+1+
|
||||
U=w+w+w</code></pre>
|
||||
<pre><code> //As a bonus, find out what the first line does
|
||||
A]#=#-#;"=7:0-p+^;#="+
|
||||
R=n+
|
||||
G=p*:+
|
||||
#=0<B+
|
||||
G=G*2#G+
|
||||
H=G*3/4+
|
||||
I=4/5+
|
||||
J=1/2+
|
||||
C=p+1+
|
||||
U=w+w+w</code></pre>
|
||||
<hr />
|
||||
<p>The function <code>a</code> is the camera shader, which, well, generates the camera ray.
|
||||
It’s supposed to return the ray in variables <code>UVWXYZ</code> and <code>ABCDEF</code> (that may
|
||||
@@ -312,8 +312,8 @@ coordinate space, volume 0 is scaled up 64x here to <code>(0,0,0)-(4096,4096,409
|
||||
happen. Wall up everything.</p>
|
||||
<p>Variables <code>ABCDEF</code> control the color returned from the ray. They will be
|
||||
explained in the material shaders part. For now, just put in:</p>
|
||||
<pre><code>A=0;B=0;C=0
|
||||
D=1;E=1;F=1</code></pre>
|
||||
<pre><code> A=0;B=0;C=0
|
||||
D=1;E=1;F=1</code></pre>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
@@ -321,29 +321,29 @@ D=1;E=1;F=1</code></pre>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre><code>a]R=0+
|
||||
X=5:5+
|
||||
Y=5:5+
|
||||
X=X-1/2+
|
||||
Y=Y-1/2+
|
||||
x=5:5+
|
||||
y=5:5+
|
||||
x=x-1/2+
|
||||
y=y-1/2+
|
||||
x=x*8*7;y=y*8*7+
|
||||
X=X*G+
|
||||
Y=Y*H+
|
||||
Z=H*2/3+
|
||||
d=4*;+
|
||||
d=d*p/Z+
|
||||
X=x+X*d+
|
||||
Y=y+Y*d+
|
||||
Z=Z*d+
|
||||
U=p*p/2-p*2+x+
|
||||
V=p*p/2+p*1-y+
|
||||
W=p*8+
|
||||
A=0;B=0;C=0+
|
||||
D=1;E=1;F=1</code></pre>
|
||||
<pre><code> a]R=0+
|
||||
X=5:5+
|
||||
Y=5:5+
|
||||
X=X-1/2+
|
||||
Y=Y-1/2+
|
||||
x=5:5+
|
||||
y=5:5+
|
||||
x=x-1/2+
|
||||
y=y-1/2+
|
||||
x=x*8*7;y=y*8*7+
|
||||
X=X*G+
|
||||
Y=Y*H+
|
||||
Z=H*2/3+
|
||||
d=4*;+
|
||||
d=d*p/Z+
|
||||
X=x+X*d+
|
||||
Y=y+Y*d+
|
||||
Z=Z*d+
|
||||
U=p*p/2-p*2+x+
|
||||
V=p*p/2+p*1-y+
|
||||
W=p*8+
|
||||
A=0;B=0;C=0+
|
||||
D=1;E=1;F=1</code></pre>
|
||||
<hr />
|
||||
<p>The numbered functions define materials, i.e., surface reflectance properties.
|
||||
As the name suggests, the shader simulates ray-surface interaction. It’s done by
|
||||
@@ -374,32 +374,32 @@ Function) importance sampling. Let’s continue to function <code>o</code>.</p>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre><code>//This function computes the starred wallpaper
|
||||
//Original color: 0.36 0.714285 0.8
|
||||
1]R=o+
|
||||
d=p*6+
|
||||
x=U+W+
|
||||
x=4:x/d+
|
||||
z=4:V/d+
|
||||
#=3*x-4*z+
|
||||
y=4:#/5+
|
||||
#=#-y*5+
|
||||
y=1#0+
|
||||
x=x*d+d/2-U+W+
|
||||
z=z*d+d/2-V+
|
||||
r=3:x*x+z*z+
|
||||
#=z+
|
||||
u=2:x+
|
||||
d=1:u*5+
|
||||
d=d*d*d+3/2+
|
||||
d=d*p+
|
||||
#=r<d+
|
||||
#=#*y+
|
||||
d=2/5#I+
|
||||
D=D*d+
|
||||
E=E*4/7+
|
||||
d=I#2/5+
|
||||
F=F*d</code></pre>
|
||||
<pre><code> //This function computes the starred wallpaper
|
||||
//Original color: 0.36 0.714285 0.8
|
||||
1]R=o+
|
||||
d=p*6+
|
||||
x=U+W+
|
||||
x=4:x/d+
|
||||
z=4:V/d+
|
||||
#=3*x-4*z+
|
||||
y=4:#/5+
|
||||
#=#-y*5+
|
||||
y=1#0+
|
||||
x=x*d+d/2-U+W+
|
||||
z=z*d+d/2-V+
|
||||
r=3:x*x+z*z+
|
||||
#=z+
|
||||
u=2:x+
|
||||
d=1:u*5+
|
||||
d=d*d*d+3/2+
|
||||
d=d*p+
|
||||
#=r<d+
|
||||
#=#*y+
|
||||
d=2/5#I+
|
||||
D=D*d+
|
||||
E=E*4/7+
|
||||
d=I#2/5+
|
||||
F=F*d</code></pre>
|
||||
<hr />
|
||||
<p>Function <code>o</code> defines a diffuse (that is, dull) surface. To define reflectance
|
||||
properties like this, one needs to sample an outgoing ray direction, based on
|
||||
@@ -415,9 +415,9 @@ defined as a bunch of cube-shaped cells, there are only 6 possible normals:
|
||||
<code>(±1,0,0) (0,±1,0) (0,0,±1)</code>. Here <code>S</code> is the sign and <code>T</code> is the dimension. If
|
||||
you get <code>S=-1</code> and <code>T=1</code>, the normal is <code>(0,-1,0)</code>.</p>
|
||||
<p>If you don’t want to redo all the math yourself… this file provides a few simple shader functions:</p>
|
||||
<pre><code>o -- Diffuse surface. Do the color thing your self and call R=o
|
||||
5 -- Perfect mirror.
|
||||
f -- Surface with a Fresnel term. Basically, it resembles a polished surface made from a dielectric material.</code></pre>
|
||||
<pre><code> o -- Diffuse surface. Do the color thing your self and call R=o
|
||||
5 -- Perfect mirror.
|
||||
f -- Surface with a Fresnel term. Basically, it resembles a polished surface made from a dielectric material.</code></pre>
|
||||
<p>For something more complex like a fluffy carpet, well, you could use a volume to
|
||||
directly model the
|
||||
<a href="https://en.wikipedia.org/wiki/Mesoscopic_physics">mesoscopic</a> detail. Shader
|
||||
@@ -430,107 +430,107 @@ appearance.</p>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre><code>//diffuse ray generation
|
||||
o]R=0+
|
||||
u=5:5+
|
||||
v=5:5+
|
||||
v=v*2+
|
||||
r=3:u+
|
||||
z=1:v+
|
||||
y=1:1/2+v+
|
||||
z=z*r+
|
||||
y=y*r+
|
||||
x=3:1-u+
|
||||
x=0-x*S+
|
||||
X=6:T+
|
||||
w=x;x=z;z=y;y=w+
|
||||
Y=6:T+
|
||||
w=x;x=z;z=y;y=w+
|
||||
Z=6:T
|
||||
<pre><code> //diffuse ray generation
|
||||
o]R=0+
|
||||
u=5:5+
|
||||
v=5:5+
|
||||
v=v*2+
|
||||
r=3:u+
|
||||
z=1:v+
|
||||
y=1:1/2+v+
|
||||
z=z*r+
|
||||
y=y*r+
|
||||
x=3:1-u+
|
||||
x=0-x*S+
|
||||
X=6:T+
|
||||
w=x;x=z;z=y;y=w+
|
||||
Y=6:T+
|
||||
w=x;x=z;z=y;y=w+
|
||||
Z=6:T
|
||||
|
||||
//reflector
|
||||
5]R=0+
|
||||
x=1;y=1;z=1+
|
||||
#=0-1+
|
||||
#=7:T+
|
||||
X=x*X;Y=y*Y;Z=z*Z
|
||||
//reflector
|
||||
5]R=0+
|
||||
x=1;y=1;z=1+
|
||||
#=0-1+
|
||||
#=7:T+
|
||||
X=x*X;Y=y*Y;Z=z*Z
|
||||
|
||||
//approximate Fresnel, works better than the real thing when you don't want to tweak the IOR
|
||||
f]x=X;y=Y;z=Z+
|
||||
r=3:x*x+z*z+y*y+
|
||||
d=6:T+
|
||||
d=1-d*S/r+
|
||||
d=d*d*d+
|
||||
#=5:5+
|
||||
#=d<#+
|
||||
R=5#o+
|
||||
d=d#1-d+
|
||||
u=1#u+
|
||||
v=1#v+
|
||||
w=1#w+
|
||||
D=D*d*u+
|
||||
E=E*d*v+
|
||||
F=F*d*w
|
||||
//approximate Fresnel, works better than the real thing when you don't want to tweak the IOR
|
||||
f]x=X;y=Y;z=Z+
|
||||
r=3:x*x+z*z+y*y+
|
||||
d=6:T+
|
||||
d=1-d*S/r+
|
||||
d=d*d*d+
|
||||
#=5:5+
|
||||
#=d<#+
|
||||
R=5#o+
|
||||
d=d#1-d+
|
||||
u=1#u+
|
||||
v=1#v+
|
||||
w=1#w+
|
||||
D=D*d*u+
|
||||
E=E*d*v+
|
||||
F=F*d*w
|
||||
|
||||
//the handles
|
||||
B]R=0+
|
||||
#=X<8*3+
|
||||
C=3#0
|
||||
//the handles
|
||||
B]R=0+
|
||||
#=X<8*3+
|
||||
C=3#0
|
||||
|
||||
C]R=0+
|
||||
#=X<8*4+
|
||||
C=0#4
|
||||
C]R=0+
|
||||
#=X<8*4+
|
||||
C=0#4
|
||||
|
||||
//red-Fresnel
|
||||
2]R=f+
|
||||
u=1/2;v=1/9;w=v
|
||||
//red-Fresnel
|
||||
2]R=f+
|
||||
u=1/2;v=1/9;w=v
|
||||
|
||||
//white-Fresnel and the full moon
|
||||
3]R=f+
|
||||
u=7*9/p;v=u;w=v+
|
||||
x=3*:+8+
|
||||
z=U-x*p+p/2+
|
||||
x=V-x*p-p/2+
|
||||
r=3:x*x+z*z+
|
||||
#=4<r/p+
|
||||
D=D*I#D+
|
||||
E=E*4/7#E+
|
||||
F=F*2/5#F+
|
||||
d=1/5#0+
|
||||
A=A+D*d+
|
||||
B=B+E*d+
|
||||
C=C+F*d
|
||||
//white-Fresnel and the full moon
|
||||
3]R=f+
|
||||
u=7*9/p;v=u;w=v+
|
||||
x=3*:+8+
|
||||
z=U-x*p+p/2+
|
||||
x=V-x*p-p/2+
|
||||
r=3:x*x+z*z+
|
||||
#=4<r/p+
|
||||
D=D*I#D+
|
||||
E=E*4/7#E+
|
||||
F=F*2/5#F+
|
||||
d=1/5#0+
|
||||
A=A+D*d+
|
||||
B=B+E*d+
|
||||
C=C+F*d
|
||||
|
||||
//handle
|
||||
4]R=5+
|
||||
D=D*I;E=E*4/7;F=F*2/5
|
||||
//handle
|
||||
4]R=5+
|
||||
D=D*I;E=E*4/7;F=F*2/5
|
||||
|
||||
//light from the window
|
||||
6]R=0+
|
||||
#=P+
|
||||
d=2#8*2+
|
||||
A=A+D*d+
|
||||
B=B+E*d+
|
||||
C=C+F*d*I+
|
||||
P=9
|
||||
//light from the window
|
||||
6]R=0+
|
||||
#=P+
|
||||
d=2#8*2+
|
||||
A=A+D*d+
|
||||
B=B+E*d+
|
||||
C=C+F*d*I+
|
||||
P=9
|
||||
|
||||
//carpet
|
||||
7]R=o+
|
||||
D=D/7+
|
||||
E=E/3+
|
||||
F=F/7
|
||||
//carpet
|
||||
7]R=o+
|
||||
D=D/7+
|
||||
E=E/3+
|
||||
F=F/7
|
||||
|
||||
D]R=0+
|
||||
#=8<Y+
|
||||
C=0#3+
|
||||
#=4:3*X-4*Z+
|
||||
y=4:#/7+
|
||||
#=#-y*7+
|
||||
C=7#C</code></pre>
|
||||
D]R=0+
|
||||
#=8<Y+
|
||||
C=0#3+
|
||||
#=4:3*X-4*Z+
|
||||
y=4:#/7+
|
||||
#=#-y*7+
|
||||
C=7#C</code></pre>
|
||||
<hr />
|
||||
<p>The last line, well, is the output filename. Just remember to throw in two <code>]</code>s
|
||||
and don’t put a newline after it.</p>
|
||||
<pre><code>]]example.ppm</code></pre>
|
||||
<pre><code> ]]example.ppm</code></pre>
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||||
|
||||
+225
-226
@@ -1,43 +1,42 @@
|
||||
|
||||
# Scene format documentation
|
||||
# Scene format documentation
|
||||
|
||||
The file must be encoded in UTF-8 as the BOF marker indicates.
|
||||
|
||||
You can directly feed it to the renderer. If you're wondering about what the following code block does, that's why:)
|
||||
|
||||
```
|
||||
@|?|?z#
|
||||
@|||?z&
|
||||
>?Sedvf
|
||||
??Tdeu#
|
||||
>>Tdeui
|
||||
??Tdmmf
|
||||
??[[euf
|
||||
?}?Oq}e
|
||||
?}?Oqqf
|
||||
v}?|q}e
|
||||
v}?|qqf
|
||||
?Sj|?{f
|
||||
?Tjk?{e
|
||||
FF?Oqq$
|
||||
RR?Oqq$
|
||||
^^?Oqq$
|
||||
jj?Oqq$
|
||||
vv?|qq$
|
||||
IOBMqqe
|
||||
U]BMqqe
|
||||
aiBMqqe
|
||||
muBMqqe
|
||||
EEEJpp%
|
||||
QQEJpp%
|
||||
]]EJpp%
|
||||
iiEJpp%
|
||||
uuEJpp%
|
||||
ZnY|{|e
|
||||
[mZ|\{\{#
|
||||
[mZ|||f
|
||||
kkdr\{\{\%
|
||||
lkdr\{\{>
|
||||
@|?|?z#
|
||||
@|||?z&
|
||||
>?Sedvf
|
||||
??Tdeu#
|
||||
>>Tdeui
|
||||
??Tdmmf
|
||||
??[[euf
|
||||
?}?Oq}e
|
||||
?}?Oqqf
|
||||
v}?|q}e
|
||||
v}?|qqf
|
||||
?Sj|?{f
|
||||
?Tjk?{e
|
||||
FF?Oqq$
|
||||
RR?Oqq$
|
||||
^^?Oqq$
|
||||
jj?Oqq$
|
||||
vv?|qq$
|
||||
IOBMqqe
|
||||
U]BMqqe
|
||||
aiBMqqe
|
||||
muBMqqe
|
||||
EEEJpp%
|
||||
QQEJpp%
|
||||
]]EJpp%
|
||||
iiEJpp%
|
||||
uuEJpp%
|
||||
ZnY|{|e
|
||||
[mZ|\{\{#
|
||||
[mZ|||f
|
||||
kkdr\{\{\%
|
||||
lkdr\{\{>
|
||||
```
|
||||
|
||||
|
||||
@@ -53,8 +52,8 @@ The language used to write shader functions is very simple. Basically, you write
|
||||
a sequence of assignment statements like this:
|
||||
|
||||
```
|
||||
A=A+D
|
||||
B=B+E
|
||||
A=A+D
|
||||
B=B+E
|
||||
```
|
||||
|
||||
Namely, you write a one-character variable name, an equal sign (`=`), followed
|
||||
@@ -67,7 +66,7 @@ course).
|
||||
The shader language supports seven operators, listed highest priority first:
|
||||
|
||||
```
|
||||
*/+-<#:
|
||||
*/+-<#:
|
||||
```
|
||||
|
||||
`*/+-<` each mean what they mean in C, but the priority part is a bit different.
|
||||
@@ -77,8 +76,8 @@ advice, keep your expressions simple :) If you really needs to write something
|
||||
like `C=(A/4)*4`, write instead:
|
||||
|
||||
```
|
||||
B=A/4+
|
||||
C=B*4
|
||||
B=A/4+
|
||||
C=B*4
|
||||
```
|
||||
|
||||
The `#` operator acts somewhat like the C `?:`. It returns one of its two
|
||||
@@ -88,14 +87,14 @@ returns its second operand.
|
||||
The `:` operator calls built-in functions. The first operand is the function id and the second is the parameter. Here is a list of functions:
|
||||
|
||||
```
|
||||
0:x = the x-th byte of the scene file
|
||||
1:x = sin(x*PI)
|
||||
2:x = atan2(x,#)/PI
|
||||
3:x = sqrt(max(x,0))
|
||||
4:x = floor(x)
|
||||
5:x = the next number in the (allegedly random) number sequence, can't be called in volume shaders
|
||||
6:x = value of the variable (char)(120+x)
|
||||
7:x = write #'s value to the variable (char)(120+x)
|
||||
0:x = the x-th byte of the scene file
|
||||
1:x = sin(x*PI)
|
||||
2:x = atan2(x,#)/PI
|
||||
3:x = sqrt(max(x,0))
|
||||
4:x = floor(x)
|
||||
5:x = the next number in the (allegedly random) number sequence, can't be called in volume shaders
|
||||
6:x = value of the variable (char)(120+x)
|
||||
7:x = write #'s value to the variable (char)(120+x)
|
||||
```
|
||||
|
||||
Contrary to popular belief, the language itself doesn't support numerical
|
||||
@@ -120,14 +119,14 @@ When a function terminates, the interpreter calls the next function specified by
|
||||
variable `R`. If you want to call function `n`, just write somewhere:
|
||||
|
||||
```
|
||||
R=n
|
||||
```
|
||||
R=n
|
||||
```
|
||||
|
||||
providing you have left `n` at its initial value. If you want to actually return
|
||||
to the renderer, put in `R=0`.
|
||||
providing you have left `n` at its initial value. If you want to actually return
|
||||
to the renderer, put in `R=0`.
|
||||
|
||||
As you may have noticed, you can put in all kinds of stuff between functions,
|
||||
like this comment.
|
||||
As you may have noticed, you can put in all kinds of stuff between functions,
|
||||
like this comment.
|
||||
|
||||
|
||||
## How the ____ do I render an image with shaders?
|
||||
@@ -143,22 +142,22 @@ Continue to the comments before function A
|
||||
|
||||
|
||||
```
|
||||
//As an (optional) assignment, figure out what function 'n' does. And why there is a plus sign at every EOL except the last.
|
||||
n]#=1+
|
||||
x=X+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
x=Y+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
x=Z+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1+
|
||||
U=U+2+
|
||||
C=C#d+3*9+
|
||||
#=d+
|
||||
R=0#n
|
||||
//As an (optional) assignment, figure out what function 'n' does. And why there is a plus sign at every EOL except the last.
|
||||
n]#=1+
|
||||
x=X+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
x=Y+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
x=Z+1/2+
|
||||
d=0:U;d=d-n;U=U+1;A=d<x;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1;A=x<d+1;#=#*A+
|
||||
d=0:U;d=d-n;U=U+1+
|
||||
U=U+2+
|
||||
C=C#d+3*9+
|
||||
#=d+
|
||||
R=0#n
|
||||
```
|
||||
|
||||
-------------------------------------------
|
||||
@@ -166,10 +165,10 @@ R=0#n
|
||||
The function `A` initializes global settings:
|
||||
|
||||
```
|
||||
G -- Image width, in pixels
|
||||
H -- Image height, in pixels
|
||||
I -- Perturbation probability
|
||||
J -- Camera ray stratification probability
|
||||
G -- Image width, in pixels
|
||||
H -- Image height, in pixels
|
||||
I -- Perturbation probability
|
||||
J -- Camera ray stratification probability
|
||||
```
|
||||
|
||||
If you have used a MLT renderer before, you probably know what `I` and `J` does.
|
||||
@@ -210,17 +209,17 @@ Continue to the comments before function a
|
||||
-------------------------------------------
|
||||
|
||||
```
|
||||
//As a bonus, find out what the first line does
|
||||
A]#=#-#;"=7:0-p+^;#="+
|
||||
R=n+
|
||||
G=p*:+
|
||||
#=0<B+
|
||||
G=G*2#G+
|
||||
H=G*3/4+
|
||||
I=4/5+
|
||||
J=1/2+
|
||||
C=p+1+
|
||||
U=w+w+w
|
||||
//As a bonus, find out what the first line does
|
||||
A]#=#-#;"=7:0-p+^;#="+
|
||||
R=n+
|
||||
G=p*:+
|
||||
#=0<B+
|
||||
G=G*2#G+
|
||||
H=G*3/4+
|
||||
I=4/5+
|
||||
J=1/2+
|
||||
C=p+1+
|
||||
U=w+w+w
|
||||
```
|
||||
|
||||
|
||||
@@ -253,8 +252,8 @@ Variables `ABCDEF` control the color returned from the ray. They will be
|
||||
explained in the material shaders part. For now, just put in:
|
||||
|
||||
```
|
||||
A=0;B=0;C=0
|
||||
D=1;E=1;F=1
|
||||
A=0;B=0;C=0
|
||||
D=1;E=1;F=1
|
||||
```
|
||||
|
||||
-------------------------------------------
|
||||
@@ -262,29 +261,29 @@ Continue to the comments before function 1
|
||||
-------------------------------------------
|
||||
|
||||
```
|
||||
a]R=0+
|
||||
X=5:5+
|
||||
Y=5:5+
|
||||
X=X-1/2+
|
||||
Y=Y-1/2+
|
||||
x=5:5+
|
||||
y=5:5+
|
||||
x=x-1/2+
|
||||
y=y-1/2+
|
||||
x=x*8*7;y=y*8*7+
|
||||
X=X*G+
|
||||
Y=Y*H+
|
||||
Z=H*2/3+
|
||||
d=4*;+
|
||||
d=d*p/Z+
|
||||
X=x+X*d+
|
||||
Y=y+Y*d+
|
||||
Z=Z*d+
|
||||
U=p*p/2-p*2+x+
|
||||
V=p*p/2+p*1-y+
|
||||
W=p*8+
|
||||
A=0;B=0;C=0+
|
||||
D=1;E=1;F=1
|
||||
a]R=0+
|
||||
X=5:5+
|
||||
Y=5:5+
|
||||
X=X-1/2+
|
||||
Y=Y-1/2+
|
||||
x=5:5+
|
||||
y=5:5+
|
||||
x=x-1/2+
|
||||
y=y-1/2+
|
||||
x=x*8*7;y=y*8*7+
|
||||
X=X*G+
|
||||
Y=Y*H+
|
||||
Z=H*2/3+
|
||||
d=4*;+
|
||||
d=d*p/Z+
|
||||
X=x+X*d+
|
||||
Y=y+Y*d+
|
||||
Z=Z*d+
|
||||
U=p*p/2-p*2+x+
|
||||
V=p*p/2+p*1-y+
|
||||
W=p*8+
|
||||
A=0;B=0;C=0+
|
||||
D=1;E=1;F=1
|
||||
```
|
||||
|
||||
|
||||
@@ -324,32 +323,32 @@ Continue to the comments before function o
|
||||
-------------------------------------------
|
||||
|
||||
```
|
||||
//This function computes the starred wallpaper
|
||||
//Original color: 0.36 0.714285 0.8
|
||||
1]R=o+
|
||||
d=p*6+
|
||||
x=U+W+
|
||||
x=4:x/d+
|
||||
z=4:V/d+
|
||||
#=3*x-4*z+
|
||||
y=4:#/5+
|
||||
#=#-y*5+
|
||||
y=1#0+
|
||||
x=x*d+d/2-U+W+
|
||||
z=z*d+d/2-V+
|
||||
r=3:x*x+z*z+
|
||||
#=z+
|
||||
u=2:x+
|
||||
d=1:u*5+
|
||||
d=d*d*d+3/2+
|
||||
d=d*p+
|
||||
#=r<d+
|
||||
#=#*y+
|
||||
d=2/5#I+
|
||||
D=D*d+
|
||||
E=E*4/7+
|
||||
d=I#2/5+
|
||||
F=F*d
|
||||
//This function computes the starred wallpaper
|
||||
//Original color: 0.36 0.714285 0.8
|
||||
1]R=o+
|
||||
d=p*6+
|
||||
x=U+W+
|
||||
x=4:x/d+
|
||||
z=4:V/d+
|
||||
#=3*x-4*z+
|
||||
y=4:#/5+
|
||||
#=#-y*5+
|
||||
y=1#0+
|
||||
x=x*d+d/2-U+W+
|
||||
z=z*d+d/2-V+
|
||||
r=3:x*x+z*z+
|
||||
#=z+
|
||||
u=2:x+
|
||||
d=1:u*5+
|
||||
d=d*d*d+3/2+
|
||||
d=d*p+
|
||||
#=r<d+
|
||||
#=#*y+
|
||||
d=2/5#I+
|
||||
D=D*d+
|
||||
E=E*4/7+
|
||||
d=I#2/5+
|
||||
F=F*d
|
||||
```
|
||||
|
||||
-------------------------------------------
|
||||
@@ -373,9 +372,9 @@ you get `S=-1` and `T=1`, the normal is `(0,-1,0)`.
|
||||
If you don't want to redo all the math yourself... this file provides a few simple shader functions:
|
||||
|
||||
```
|
||||
o -- Diffuse surface. Do the color thing your self and call R=o
|
||||
5 -- Perfect mirror.
|
||||
f -- Surface with a Fresnel term. Basically, it resembles a polished surface made from a dielectric material.
|
||||
o -- Diffuse surface. Do the color thing your self and call R=o
|
||||
5 -- Perfect mirror.
|
||||
f -- Surface with a Fresnel term. Basically, it resembles a polished surface made from a dielectric material.
|
||||
```
|
||||
|
||||
For something more complex like a fluffy carpet, well, you could use a volume to
|
||||
@@ -391,103 +390,103 @@ Continue to the EOF
|
||||
-------------------------------------------
|
||||
|
||||
```
|
||||
//diffuse ray generation
|
||||
o]R=0+
|
||||
u=5:5+
|
||||
v=5:5+
|
||||
v=v*2+
|
||||
r=3:u+
|
||||
z=1:v+
|
||||
y=1:1/2+v+
|
||||
z=z*r+
|
||||
y=y*r+
|
||||
x=3:1-u+
|
||||
x=0-x*S+
|
||||
X=6:T+
|
||||
w=x;x=z;z=y;y=w+
|
||||
Y=6:T+
|
||||
w=x;x=z;z=y;y=w+
|
||||
Z=6:T
|
||||
//diffuse ray generation
|
||||
o]R=0+
|
||||
u=5:5+
|
||||
v=5:5+
|
||||
v=v*2+
|
||||
r=3:u+
|
||||
z=1:v+
|
||||
y=1:1/2+v+
|
||||
z=z*r+
|
||||
y=y*r+
|
||||
x=3:1-u+
|
||||
x=0-x*S+
|
||||
X=6:T+
|
||||
w=x;x=z;z=y;y=w+
|
||||
Y=6:T+
|
||||
w=x;x=z;z=y;y=w+
|
||||
Z=6:T
|
||||
|
||||
//reflector
|
||||
5]R=0+
|
||||
x=1;y=1;z=1+
|
||||
#=0-1+
|
||||
#=7:T+
|
||||
X=x*X;Y=y*Y;Z=z*Z
|
||||
//reflector
|
||||
5]R=0+
|
||||
x=1;y=1;z=1+
|
||||
#=0-1+
|
||||
#=7:T+
|
||||
X=x*X;Y=y*Y;Z=z*Z
|
||||
|
||||
//approximate Fresnel, works better than the real thing when you don't want to tweak the IOR
|
||||
f]x=X;y=Y;z=Z+
|
||||
r=3:x*x+z*z+y*y+
|
||||
d=6:T+
|
||||
d=1-d*S/r+
|
||||
d=d*d*d+
|
||||
#=5:5+
|
||||
#=d<#+
|
||||
R=5#o+
|
||||
d=d#1-d+
|
||||
u=1#u+
|
||||
v=1#v+
|
||||
w=1#w+
|
||||
D=D*d*u+
|
||||
E=E*d*v+
|
||||
F=F*d*w
|
||||
//approximate Fresnel, works better than the real thing when you don't want to tweak the IOR
|
||||
f]x=X;y=Y;z=Z+
|
||||
r=3:x*x+z*z+y*y+
|
||||
d=6:T+
|
||||
d=1-d*S/r+
|
||||
d=d*d*d+
|
||||
#=5:5+
|
||||
#=d<#+
|
||||
R=5#o+
|
||||
d=d#1-d+
|
||||
u=1#u+
|
||||
v=1#v+
|
||||
w=1#w+
|
||||
D=D*d*u+
|
||||
E=E*d*v+
|
||||
F=F*d*w
|
||||
|
||||
//the handles
|
||||
B]R=0+
|
||||
#=X<8*3+
|
||||
C=3#0
|
||||
//the handles
|
||||
B]R=0+
|
||||
#=X<8*3+
|
||||
C=3#0
|
||||
|
||||
C]R=0+
|
||||
#=X<8*4+
|
||||
C=0#4
|
||||
C]R=0+
|
||||
#=X<8*4+
|
||||
C=0#4
|
||||
|
||||
//red-Fresnel
|
||||
2]R=f+
|
||||
u=1/2;v=1/9;w=v
|
||||
//red-Fresnel
|
||||
2]R=f+
|
||||
u=1/2;v=1/9;w=v
|
||||
|
||||
//white-Fresnel and the full moon
|
||||
3]R=f+
|
||||
u=7*9/p;v=u;w=v+
|
||||
x=3*:+8+
|
||||
z=U-x*p+p/2+
|
||||
x=V-x*p-p/2+
|
||||
r=3:x*x+z*z+
|
||||
#=4<r/p+
|
||||
D=D*I#D+
|
||||
E=E*4/7#E+
|
||||
F=F*2/5#F+
|
||||
d=1/5#0+
|
||||
A=A+D*d+
|
||||
B=B+E*d+
|
||||
C=C+F*d
|
||||
//white-Fresnel and the full moon
|
||||
3]R=f+
|
||||
u=7*9/p;v=u;w=v+
|
||||
x=3*:+8+
|
||||
z=U-x*p+p/2+
|
||||
x=V-x*p-p/2+
|
||||
r=3:x*x+z*z+
|
||||
#=4<r/p+
|
||||
D=D*I#D+
|
||||
E=E*4/7#E+
|
||||
F=F*2/5#F+
|
||||
d=1/5#0+
|
||||
A=A+D*d+
|
||||
B=B+E*d+
|
||||
C=C+F*d
|
||||
|
||||
//handle
|
||||
4]R=5+
|
||||
D=D*I;E=E*4/7;F=F*2/5
|
||||
//handle
|
||||
4]R=5+
|
||||
D=D*I;E=E*4/7;F=F*2/5
|
||||
|
||||
//light from the window
|
||||
6]R=0+
|
||||
#=P+
|
||||
d=2#8*2+
|
||||
A=A+D*d+
|
||||
B=B+E*d+
|
||||
C=C+F*d*I+
|
||||
P=9
|
||||
//light from the window
|
||||
6]R=0+
|
||||
#=P+
|
||||
d=2#8*2+
|
||||
A=A+D*d+
|
||||
B=B+E*d+
|
||||
C=C+F*d*I+
|
||||
P=9
|
||||
|
||||
//carpet
|
||||
7]R=o+
|
||||
D=D/7+
|
||||
E=E/3+
|
||||
F=F/7
|
||||
//carpet
|
||||
7]R=o+
|
||||
D=D/7+
|
||||
E=E/3+
|
||||
F=F/7
|
||||
|
||||
D]R=0+
|
||||
#=8<Y+
|
||||
C=0#3+
|
||||
#=4:3*X-4*Z+
|
||||
y=4:#/7+
|
||||
#=#-y*7+
|
||||
C=7#C
|
||||
D]R=0+
|
||||
#=8<Y+
|
||||
C=0#3+
|
||||
#=4:3*X-4*Z+
|
||||
y=4:#/7+
|
||||
#=#-y*7+
|
||||
C=7#C
|
||||
```
|
||||
|
||||
-------------------------------------------
|
||||
@@ -496,7 +495,7 @@ The last line, well, is the output filename. Just remember to throw in two `]`s
|
||||
and don't put a newline after it.
|
||||
|
||||
```
|
||||
]]example.ppm
|
||||
]]example.ppm
|
||||
```
|
||||
|
||||
|
||||
|
||||
+13
-14
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Qiming_HOU">Qiming HOU</a><br>
|
||||
Location: <a href="../../location.html#CN">CN</a> - <em>People’s Republic of China</em> (<em>China</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#CN">CN</a> - <em>People’s Republic of China</em> (<em>China</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,18 +141,18 @@ Location: <a href="../../location.html#CN">CN</a> - <em>People’s Republic of C
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> all</span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2013_hou">2013 hou 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">./hou</span> <span class="pp">[</span><span class="ss">scene</span><span class="pp">-</span><span class="ss">file</span><span class="pp">-</span><span class="ss">name</span><span class="pp">]</span> <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./hou</span> <span class="pp">[</span><span class="ss">scene</span><span class="pp">-</span><span class="ss">file</span><span class="pp">-</span><span class="ss">name</span><span class="pp">]</span> <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span></code></pre></div>
|
||||
<p>Follow the instructions in <code>stdout</code>, preferably with an auto-refreshing PPM
|
||||
image viewer ready. Refresh the image every time the output refreshes, all
|
||||
effects should be more or less recognizable when you see 16.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>Try opening the file noted by the program then let the program run a while and
|
||||
every so often reopen the file, to see how it changes. The author suggests that
|
||||
you leave the program running overnight to see what happens. If however you do
|
||||
@@ -182,15 +181,15 @@ program.</p>
|
||||
<a href="https://en.wikipedia.org/wiki/Ray_tracing_(graphics)">raytraced</a> image.</p>
|
||||
<p>NOTE: the author refers to <a href="a.c">a.c</a>, placed in a gzipped file <code>a.c.gz</code>. We do not
|
||||
include it but it can be generated like:</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">cc</span> <span class="at">-Wall</span> hou.c <span class="at">-o</span> hou <span class="at">-lm</span></span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./hou</span> <span class="op">></span> a.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-Wall</span> hou.c <span class="at">-o</span> hou <span class="at">-lm</span></span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./hou</span> <span class="op">></span> a.c</span></code></pre></div>
|
||||
<p>but there is no need to do this as the Makefile takes care of it without even
|
||||
needing to create a temporary file.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="using-hou">Using hou</h3>
|
||||
<p>This program is a programmable rendering engine with a built-in default scene.
|
||||
The standard command line is:</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">./hou</span> <span class="pp">[</span><span class="ss">scene</span><span class="pp">-</span><span class="ss">file</span><span class="pp">-</span><span class="ss">name</span><span class="pp">]</span> <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./hou</span> <span class="pp">[</span><span class="ss">scene</span><span class="pp">-</span><span class="ss">file</span><span class="pp">-</span><span class="ss">name</span><span class="pp">]</span> <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span></code></pre></div>
|
||||
<p>As <code>hou</code> runs, it writes a progressively refining image to a ppm file specified
|
||||
in the scene. The initialization may take a while, but once it’s done, a rough
|
||||
preview should be available in seconds. Leave <code>hou</code> running for the night, and you
|
||||
@@ -280,11 +279,11 @@ quite memory consuming, requires IEEE754-compliant <code>double</code>, and assu
|
||||
doesn’t copy saved sessions across different endianness.</li>
|
||||
</ul>
|
||||
<h3 id="spoiler">Spoiler</h3>
|
||||
<pre><code> 3225 3225 3225 9 9 3225 3225
|
||||
1 1 1 1 1 1 1 1 1 1
|
||||
4225 1226 1 1 1 1 1222 1226
|
||||
1 1 1 1 1 1 1 1 1
|
||||
4226 1 4226 8 4222 4226 1 1</code></pre>
|
||||
<pre><code> 3225 3225 3225 9 9 3225 3225
|
||||
1 1 1 1 1 1 1 1 1 1
|
||||
4225 1226 1 1 1 1 1222 1226
|
||||
1 1 1 1 1 1 1 1 1
|
||||
4226 1 4226 8 4222 4226 1 1</code></pre>
|
||||
<p>The program consists of a recursive-descent interpreter, a <code>3DDDA</code> (3D Discrete
|
||||
Differential Analysis) ray tracer, a <code>PSSMLT</code> (Primary Sample Space Metropolis
|
||||
Light Transport) light path sampler, all squeezed into the size limit using a
|
||||
|
||||
+3
-3
@@ -160,9 +160,9 @@ certain comments such as:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="op">*</span>\</span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="op">/</span></span></code></pre></div>
|
||||
<p>were not correctly parsed by the tool. The guidelines stated:</p>
|
||||
<pre><code>In cases where the above summary and the algorithm implemented by
|
||||
the IOCCC size tool source code conflict, the algorithm implemented
|
||||
by the IOCCC size tool source code is preferred by the judges.</code></pre>
|
||||
<pre><code> In cases where the above summary and the algorithm implemented by
|
||||
the IOCCC size tool source code conflict, the algorithm implemented
|
||||
by the IOCCC size tool source code is preferred by the judges.</code></pre>
|
||||
<p>so this abuse was allowed (and encouraged). The judges hope that
|
||||
the IOCCC size tool author will patch the tool to block this kind
|
||||
of size abuse in future contests.</p>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2013 mills bugs](../../bugs.html#2013_mills).
|
||||
@@ -19,14 +19,14 @@ For more detailed information see [2013 mills bugs](../../bugs.html#2013_mills).
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./mills
|
||||
./mills
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./mills &
|
||||
./mills &
|
||||
```
|
||||
|
||||
While that is running, point your favorite browser at:
|
||||
@@ -62,7 +62,7 @@ while you are there, click on an ad. They could use the money.
|
||||
It would be possible to fix this by adding
|
||||
|
||||
```c
|
||||
n=1,setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&n,sizeof n),
|
||||
n=1,setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&n,sizeof n),
|
||||
```
|
||||
|
||||
at an appropriate spot in the code (an exercise left to the reader). However,
|
||||
|
||||
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Christopher_Mills">Christopher Mills</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,15 +141,15 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2013_mills">2013 mills 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">./mills</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./mills</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./mills</span> <span class="kw">&</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./mills</span> <span class="kw">&</span></span></code></pre></div>
|
||||
<p>While that is running, point your favorite browser at:
|
||||
<a href="http://localhost:8224">http://localhost:8224</a>.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -171,7 +170,7 @@ doing so. For details as to why this is necessary, feel free to Google
|
||||
<code>"TIME_WAIT"</code>, <code>"SO_REUSEADDR"</code> and <code>"SO_REUSEPORT"</code> (with the quotes). And
|
||||
while you are there, click on an ad. They could use the money.</p>
|
||||
<p>It would be possible to fix this by adding</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>n<span class="op">=</span><span class="dv">1</span><span class="op">,</span>setsockopt<span class="op">(</span>s<span class="op">,</span>SOL_SOCKET<span class="op">,</span>SO_REUSEADDR<span class="op">,&</span>n<span class="op">,</span><span class="kw">sizeof</span> n<span class="op">),</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> n<span class="op">=</span><span class="dv">1</span><span class="op">,</span>setsockopt<span class="op">(</span>s<span class="op">,</span>SOL_SOCKET<span class="op">,</span>SO_REUSEADDR<span class="op">,&</span>n<span class="op">,</span><span class="kw">sizeof</span> n<span class="op">),</span></span></code></pre></div>
|
||||
<p>at an appropriate spot in the code (an exercise left to the reader). However,
|
||||
as this limitation is documented, it is not technically a bug.</p>
|
||||
<h3 id="details-of-operation">Details of Operation</h3>
|
||||
|
||||
+36
-36
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
This will build a bunch of versions of the code. See the author's details for
|
||||
@@ -11,8 +11,8 @@ information on all of these builds.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./horizontal_cat [files...] > [output]
|
||||
./vertical_cat [files...] > [output]
|
||||
./horizontal_cat [files...] > [output]
|
||||
./vertical_cat [files...] > [output]
|
||||
```
|
||||
|
||||
|
||||
@@ -21,19 +21,19 @@ information on all of these builds.
|
||||
To understand the various intermediate source files that are built, try:
|
||||
|
||||
```sh
|
||||
make understanding
|
||||
make understanding
|
||||
```
|
||||
|
||||
Also try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
NOTE: Use - for standard input. For example:
|
||||
|
||||
```sh
|
||||
./vertical_cat - -
|
||||
./vertical_cat - -
|
||||
```
|
||||
|
||||
|
||||
@@ -70,12 +70,12 @@ judging this entry.
|
||||
operation:
|
||||
|
||||
```sh
|
||||
cc misaka.c -o horizontal_cat
|
||||
./horizontal_cat [files...] > [output]
|
||||
cc misaka.c -o horizontal_cat
|
||||
./horizontal_cat [files...] > [output]
|
||||
|
||||
./horizontal_cat misaka.c misaka.c > misaka2.c
|
||||
cc misaka2.c -o vertical_cat
|
||||
./vertical_cat [files...] > [output]
|
||||
./horizontal_cat misaka.c misaka.c > misaka2.c
|
||||
cc misaka2.c -o vertical_cat
|
||||
./vertical_cat [files...] > [output]
|
||||
```
|
||||
|
||||
Where `[files...]` is a list of text file names. Use `-` to read from `stdin`.
|
||||
@@ -95,8 +95,8 @@ I thought the lack of horizontal concatenation must have been an oversight,
|
||||
so I implemented this utility:
|
||||
|
||||
```sh
|
||||
cc misaka.c -o horizontal_cat
|
||||
./horizontal_cat files...
|
||||
cc misaka.c -o horizontal_cat
|
||||
./horizontal_cat files...
|
||||
```
|
||||
|
||||
`horizontal_cat` concatenates files horizontally and write the output to
|
||||
@@ -110,7 +110,7 @@ example, if you have `seq(1)` in your shell, you can add line numbers to both
|
||||
sides of [misaka.c](misaka.c) like this:
|
||||
|
||||
```sh
|
||||
seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c -
|
||||
seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c -
|
||||
```
|
||||
|
||||
|
||||
@@ -127,16 +127,16 @@ mode with command line options would be no fun. Instead, vertical mode is
|
||||
enabled by concatenating the source code horizontally:
|
||||
|
||||
```sh
|
||||
./horizontal_cat misaka.c misaka.c > misaka2.c
|
||||
gcc misaka2.c -o vertical_cat
|
||||
./vertical_cat files...
|
||||
./horizontal_cat misaka.c misaka.c > misaka2.c
|
||||
gcc misaka2.c -o vertical_cat
|
||||
./vertical_cat files...
|
||||
```
|
||||
|
||||
`vertical_cat` works more or less like `cat`, except you can use
|
||||
`vertical_cat` to duplicate `stdin`:
|
||||
|
||||
```sh
|
||||
./vertical_cat - -
|
||||
./vertical_cat - -
|
||||
```
|
||||
|
||||
|
||||
@@ -148,9 +148,9 @@ one more mode, this one is enabled by concatenating [misaka.c](misaka.c)
|
||||
vertically:
|
||||
|
||||
```sh
|
||||
./vertical_cat misaka.c misaka.c > misaka3.c
|
||||
gcc misaka3.c -o long_cat
|
||||
./long_cat
|
||||
./vertical_cat misaka.c misaka.c > misaka3.c
|
||||
gcc misaka3.c -o long_cat
|
||||
./long_cat
|
||||
```
|
||||
|
||||
`long_cat` outputs ASCII art of a cat to `stdout`. You can make this cat
|
||||
@@ -158,33 +158,33 @@ exponentially longer by concatenating more files vertically (up to 31 levels
|
||||
high, depending on `sizeof(int)` for your compiler):
|
||||
|
||||
```sh
|
||||
./vertical_cat misaka.c misaka.c misaka.c > misaka4.c
|
||||
gcc misaka4.c -o loong_cat
|
||||
./vertical_cat misaka.c misaka.c misaka.c > misaka4.c
|
||||
gcc misaka4.c -o loong_cat
|
||||
|
||||
./vertical_cat misaka.c misaka.c misaka.c misaka.c > misaka5.c
|
||||
gcc misaka5.c -o loooong_cat
|
||||
./vertical_cat misaka.c misaka.c misaka.c misaka.c > misaka5.c
|
||||
gcc misaka5.c -o loooong_cat
|
||||
|
||||
./vertical_cat misaka.c misaka.c misaka.c misaka.c misaka.c > misaka6.c
|
||||
gcc misaka6.c -o loooooooong_cat
|
||||
./vertical_cat misaka.c misaka.c misaka.c misaka.c misaka.c > misaka6.c
|
||||
gcc misaka6.c -o loooooooong_cat
|
||||
```
|
||||
|
||||
If your terminal has really thin fonts, you can also make this output fatter
|
||||
by concatenating files horizontally:
|
||||
|
||||
```sh
|
||||
./vertical_cat misaka.c misaka.c | ./horizontal_cat - - > misaka7.c
|
||||
gcc misaka7.c -o long_fat_cat
|
||||
./vertical_cat misaka.c misaka.c | ./horizontal_cat - - > misaka7.c
|
||||
gcc misaka7.c -o long_fat_cat
|
||||
|
||||
./vertical_cat misaka.c misaka.c | ./horizontal_cat - - - > misaka8.c
|
||||
gcc misaka8.c -o long_faat_cat
|
||||
./vertical_cat misaka.c misaka.c | ./horizontal_cat - - - > misaka8.c
|
||||
gcc misaka8.c -o long_faat_cat
|
||||
```
|
||||
|
||||
Output width is determined by the first level of stacked programs, so a
|
||||
triangle like the following will not have horizontally expanded output:
|
||||
|
||||
```sh
|
||||
./horizontal_cat misaka.c misaka.c | ./vertical_cat misaka.c - > misaka9.c
|
||||
gcc misaka9.c -o same_as_long_cat
|
||||
./horizontal_cat misaka.c misaka.c | ./vertical_cat misaka.c - > misaka9.c
|
||||
gcc misaka9.c -o same_as_long_cat
|
||||
```
|
||||
|
||||
Finally, if you lost track of how many [misaka.c](misaka.c) you have stacked
|
||||
@@ -193,14 +193,14 @@ together, you can feed the source to a
|
||||
overview of how the programs are stacked. Example:
|
||||
|
||||
```sh
|
||||
perl bf.pl misaka9.c
|
||||
perl bf.pl misaka9.c
|
||||
```
|
||||
|
||||
This outputs:
|
||||
|
||||
```
|
||||
MISAKA
|
||||
MISAKA MISAKA
|
||||
MISAKA
|
||||
MISAKA MISAKA
|
||||
```
|
||||
|
||||
|
||||
|
||||
+37
-38
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Don_Yang">Don Yang</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,19 +141,19 @@ 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></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>This will build a bunch of versions of the code. See the author’s details for
|
||||
information on all of these builds.</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">./horizontal_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">></span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./vertical_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">></span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./horizontal_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">></span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">></span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<p>To understand the various intermediate source files that are built, try:</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> understanding</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> understanding</span></code></pre></div>
|
||||
<p>Also try:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>NOTE: Use - for standard input. For example:</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">./vertical_cat</span> <span class="at">-</span> <span class="at">-</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> <span class="at">-</span> <span class="at">-</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>There is more to cat than <a href="http://cheezburger.com/1680494336">mere cats</a>. Be
|
||||
they tall, fat, long or squat, this source code is sure to amuse.</p>
|
||||
@@ -177,12 +176,12 @@ judging this entry.</p>
|
||||
<h3 id="overview">Overview</h3>
|
||||
<p><code>Misaka</code> is a file concatenation utility, with at least two modes of
|
||||
operation:</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">cc</span> misaka.c <span class="at">-o</span> horizontal_cat</span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./horizontal_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">></span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span>
|
||||
<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">cc</span> misaka.c <span class="at">-o</span> horizontal_cat</span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./horizontal_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">></span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span>
|
||||
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./horizontal_cat</span> misaka.c misaka.c <span class="op">></span> misaka2.c</span>
|
||||
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> misaka2.c <span class="at">-o</span> vertical_cat</span>
|
||||
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a><span class="ex">./vertical_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">></span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span></code></pre></div>
|
||||
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./horizontal_cat</span> misaka.c misaka.c <span class="op">></span> misaka2.c</span>
|
||||
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> misaka2.c <span class="at">-o</span> vertical_cat</span>
|
||||
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">></span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span></code></pre></div>
|
||||
<p>Where <code>[files...]</code> is a list of text file names. Use <code>-</code> to read from <code>stdin</code>.</p>
|
||||
<h3 id="details">Details</h3>
|
||||
<h3 id="horizontal-cat">Horizontal cat</h3>
|
||||
@@ -193,8 +192,8 @@ concatenating files, that function only seem to work if I wanted to concatenate
|
||||
files vertically.</p>
|
||||
<p>I thought the lack of horizontal concatenation must have been an oversight,
|
||||
so I implemented this utility:</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">cc</span> misaka.c <span class="at">-o</span> horizontal_cat</span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./horizontal_cat</span> files...</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> misaka.c <span class="at">-o</span> horizontal_cat</span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./horizontal_cat</span> files...</span></code></pre></div>
|
||||
<p><code>horizontal_cat</code> concatenates files horizontally and write the output to
|
||||
<code>stdout</code>. Each input file is padded with spaces on the right so that the
|
||||
original text alignments are preserved.</p>
|
||||
@@ -203,7 +202,7 @@ Unlike <code>cat</code>, <code>horizontal_cat</code> loads all input to memory f
|
||||
can specify <code>-</code> multiple times to get <code>stdin</code> multiplied horizontally. For
|
||||
example, if you have <code>seq(1)</code> in your shell, you can add line numbers to both
|
||||
sides of <a href="misaka.c">misaka.c</a> like this:</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="fu">seq</span> <span class="at">-f</span> <span class="st">' %.0f '</span> 45 <span class="kw">|</span> <span class="ex">./horizontal_cat</span> <span class="at">-</span> misaka.c <span class="at">-</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">seq</span> <span class="at">-f</span> <span class="st">' %.0f '</span> 45 <span class="kw">|</span> <span class="ex">./horizontal_cat</span> <span class="at">-</span> misaka.c <span class="at">-</span></span></code></pre></div>
|
||||
<h3 id="vertical-cat">Vertical cat</h3>
|
||||
<p>Because <code>horizontal_cat</code> must know the maximum width of all files before
|
||||
writing any output, all files must be processed at least twice. To support
|
||||
@@ -213,50 +212,50 @@ writing any output, all files must be processed at least twice. To support
|
||||
files vertically, so I included a vertical mode. But supporting vertical
|
||||
mode with command line options would be no fun. Instead, vertical mode is
|
||||
enabled by concatenating the source code horizontally:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./horizontal_cat</span> misaka.c misaka.c <span class="op">></span> misaka2.c</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> misaka2.c <span class="at">-o</span> vertical_cat</span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./vertical_cat</span> files...</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./horizontal_cat</span> misaka.c misaka.c <span class="op">></span> misaka2.c</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka2.c <span class="at">-o</span> vertical_cat</span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> files...</span></code></pre></div>
|
||||
<p><code>vertical_cat</code> works more or less like <code>cat</code>, except you can use
|
||||
<code>vertical_cat</code> to duplicate <code>stdin</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="ex">./vertical_cat</span> <span class="at">-</span> <span class="at">-</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> <span class="at">-</span> <span class="at">-</span></span></code></pre></div>
|
||||
<h3 id="long-cat">Long cat</h3>
|
||||
<p>After <code>horizontal_cat</code> and <code>vertical_cat</code>, I thought, maybe all I really wanted
|
||||
was just more <a href="https://rationalwiki.org/wiki/Fun:Cat">cats</a>. So I implemented
|
||||
one more mode, this one is enabled by concatenating <a href="misaka.c">misaka.c</a>
|
||||
vertically:</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">./vertical_cat</span> misaka.c misaka.c <span class="op">></span> misaka3.c</span>
|
||||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> misaka3.c <span class="at">-o</span> long_cat</span>
|
||||
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./long_cat</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> misaka.c misaka.c <span class="op">></span> misaka3.c</span>
|
||||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka3.c <span class="at">-o</span> long_cat</span>
|
||||
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./long_cat</span></span></code></pre></div>
|
||||
<p><code>long_cat</code> outputs ASCII art of a cat to <code>stdout</code>. You can make this cat
|
||||
exponentially longer by concatenating more files vertically (up to 31 levels
|
||||
high, depending on <code>sizeof(int)</code> for your compiler):</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="ex">./vertical_cat</span> misaka.c misaka.c misaka.c <span class="op">></span> misaka4.c</span>
|
||||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> misaka4.c <span class="at">-o</span> loong_cat</span>
|
||||
<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="ex">./vertical_cat</span> misaka.c misaka.c misaka.c <span class="op">></span> misaka4.c</span>
|
||||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka4.c <span class="at">-o</span> loong_cat</span>
|
||||
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./vertical_cat</span> misaka.c misaka.c misaka.c misaka.c <span class="op">></span> misaka5.c</span>
|
||||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> misaka5.c <span class="at">-o</span> loooong_cat</span>
|
||||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> misaka.c misaka.c misaka.c misaka.c <span class="op">></span> misaka5.c</span>
|
||||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka5.c <span class="at">-o</span> loooong_cat</span>
|
||||
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a><span class="ex">./vertical_cat</span> misaka.c misaka.c misaka.c misaka.c misaka.c <span class="op">></span> misaka6.c</span>
|
||||
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> misaka6.c <span class="at">-o</span> loooooooong_cat</span></code></pre></div>
|
||||
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> misaka.c misaka.c misaka.c misaka.c misaka.c <span class="op">></span> misaka6.c</span>
|
||||
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka6.c <span class="at">-o</span> loooooooong_cat</span></code></pre></div>
|
||||
<p>If your terminal has really thin fonts, you can also make this output fatter
|
||||
by concatenating files horizontally:</p>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./vertical_cat</span> misaka.c misaka.c <span class="kw">|</span> <span class="ex">./horizontal_cat</span> <span class="at">-</span> <span class="at">-</span> <span class="op">></span> misaka7.c</span>
|
||||
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> misaka7.c <span class="at">-o</span> long_fat_cat</span>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> misaka.c misaka.c <span class="kw">|</span> <span class="ex">./horizontal_cat</span> <span class="at">-</span> <span class="at">-</span> <span class="op">></span> misaka7.c</span>
|
||||
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka7.c <span class="at">-o</span> long_fat_cat</span>
|
||||
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./vertical_cat</span> misaka.c misaka.c <span class="kw">|</span> <span class="ex">./horizontal_cat</span> <span class="at">-</span> <span class="at">-</span> <span class="at">-</span> <span class="op">></span> misaka8.c</span>
|
||||
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> misaka8.c <span class="at">-o</span> long_faat_cat</span></code></pre></div>
|
||||
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> misaka.c misaka.c <span class="kw">|</span> <span class="ex">./horizontal_cat</span> <span class="at">-</span> <span class="at">-</span> <span class="at">-</span> <span class="op">></span> misaka8.c</span>
|
||||
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka8.c <span class="at">-o</span> long_faat_cat</span></code></pre></div>
|
||||
<p>Output width is determined by the first level of stacked programs, so a
|
||||
triangle like the following will not have horizontally expanded output:</p>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./horizontal_cat</span> misaka.c misaka.c <span class="kw">|</span> <span class="ex">./vertical_cat</span> misaka.c <span class="at">-</span> <span class="op">></span> misaka9.c</span>
|
||||
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> misaka9.c <span class="at">-o</span> same_as_long_cat</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./horizontal_cat</span> misaka.c misaka.c <span class="kw">|</span> <span class="ex">./vertical_cat</span> misaka.c <span class="at">-</span> <span class="op">></span> misaka9.c</span>
|
||||
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka9.c <span class="at">-o</span> same_as_long_cat</span></code></pre></div>
|
||||
<p>Finally, if you lost track of how many <a href="misaka.c">misaka.c</a> you have stacked
|
||||
together, you can feed the source to a
|
||||
<a href="https://en.wikipedia.org/wiki/Brainfuck">brainfuck</a> interpreter to get an
|
||||
overview of how the programs are stacked. 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="fu">perl</span> bf.pl misaka9.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">perl</span> bf.pl misaka9.c</span></code></pre></div>
|
||||
<p>This outputs:</p>
|
||||
<pre><code>MISAKA
|
||||
MISAKA MISAKA</code></pre>
|
||||
<pre><code> MISAKA
|
||||
MISAKA MISAKA</code></pre>
|
||||
<h3 id="return-value">Return value</h3>
|
||||
<p><code>horizontal_cat</code> and <code>vertical_cat</code> will exit with zero status on success.</p>
|
||||
<p>If any input file fails to open, <code>horizontal_cat</code> and <code>vertical_cat</code> will
|
||||
|
||||
+12
-12
@@ -1,14 +1,14 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
echo "YYYY/MM/DD" | ./morgan1
|
||||
echo "YYYY/MM/DD" | ./morgan1
|
||||
```
|
||||
|
||||
where `YYYY` is the four digit year, `MM` is the two digit month and `DD` is two
|
||||
@@ -24,7 +24,7 @@ follows:
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
Use the same keys as described above to change the dates each time the program
|
||||
@@ -107,20 +107,20 @@ degrees sometimes).
|
||||
With gcc 4.7.2 on Linux Ubuntu 12.10:
|
||||
|
||||
```
|
||||
morgan1.c:38:3: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
morgan1.c:40:34: warning: value computed is not used [-Wunused-value]
|
||||
morgan1.c:56:6: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
morgan1.c:58:50: warning: value computed is not used [-Wunused-value]
|
||||
morgan1.c:61:5: warning: suggest parentheses around ‘-’ inside ‘>>’ [-Wparentheses]
|
||||
morgan1.c:38:3: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
morgan1.c:40:34: warning: value computed is not used [-Wunused-value]
|
||||
morgan1.c:56:6: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
morgan1.c:58:50: warning: value computed is not used [-Wunused-value]
|
||||
morgan1.c:61:5: warning: suggest parentheses around ‘-’ inside ‘>>’ [-Wparentheses]
|
||||
```
|
||||
|
||||
With clang 3.1 on Linux Ubuntu 12.10 :
|
||||
|
||||
```
|
||||
morgan1.c:38:49: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:38:27: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:55:13: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:56:14: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:38:49: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:38:27: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:55:13: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:56:14: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
```
|
||||
|
||||
This is due to most of the parentheses and braces being removed when
|
||||
|
||||
+13
-14
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yves-Marie_Morgan">Yves-Marie Morgan</a><br>
|
||||
Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<em>France</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<em>France</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,9 +141,9 @@ Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<e
|
||||
<!-- 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></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"YYYY/MM/DD"</span> <span class="kw">|</span> <span class="ex">./morgan1</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">"YYYY/MM/DD"</span> <span class="kw">|</span> <span class="ex">./morgan1</span></span></code></pre></div>
|
||||
<p>where <code>YYYY</code> is the four digit year, <code>MM</code> is the two digit month and <code>DD</code> is two
|
||||
digit day of the month. The arrow keys control the shifting of the date as
|
||||
follows:</p>
|
||||
@@ -155,7 +154,7 @@ follows:</p>
|
||||
<li>Down : go backwards 20 days.</li>
|
||||
</ul>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>Use the same keys as described above to change the dates each time the program
|
||||
window is in focus.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -218,16 +217,16 @@ degrees sometimes).</li>
|
||||
</ul>
|
||||
<h3 id="compilation-warnings">Compilation warnings</h3>
|
||||
<p>With gcc 4.7.2 on Linux Ubuntu 12.10:</p>
|
||||
<pre><code>morgan1.c:38:3: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
morgan1.c:40:34: warning: value computed is not used [-Wunused-value]
|
||||
morgan1.c:56:6: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
morgan1.c:58:50: warning: value computed is not used [-Wunused-value]
|
||||
morgan1.c:61:5: warning: suggest parentheses around ‘-’ inside ‘>>’ [-Wparentheses]</code></pre>
|
||||
<pre><code> morgan1.c:38:3: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
morgan1.c:40:34: warning: value computed is not used [-Wunused-value]
|
||||
morgan1.c:56:6: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
morgan1.c:58:50: warning: value computed is not used [-Wunused-value]
|
||||
morgan1.c:61:5: warning: suggest parentheses around ‘-’ inside ‘>>’ [-Wparentheses]</code></pre>
|
||||
<p>With clang 3.1 on Linux Ubuntu 12.10 :</p>
|
||||
<pre><code>morgan1.c:38:49: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:38:27: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:55:13: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:56:14: warning: '&&' within '||' [-Wlogical-op-parentheses]</code></pre>
|
||||
<pre><code> morgan1.c:38:49: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:38:27: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:55:13: warning: '&&' within '||' [-Wlogical-op-parentheses]
|
||||
morgan1.c:56:14: warning: '&&' within '||' [-Wlogical-op-parentheses]</code></pre>
|
||||
<p>This is due to most of the parentheses and braces being removed when
|
||||
unnecessary.</p>
|
||||
<p>To verify the display, you can look at one of these programs :
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ make
|
||||
For the console version (ncurses):
|
||||
|
||||
```sh
|
||||
./morgan2
|
||||
./morgan2
|
||||
```
|
||||
|
||||
For the graphical version (X11):
|
||||
|
||||
```sh
|
||||
./morgan2 X
|
||||
./morgan2 X
|
||||
```
|
||||
|
||||
|
||||
@@ -133,13 +133,13 @@ simply press `q` when you have finished...
|
||||
With gcc 4.7.2 on Linux Ubuntu 12.10 :
|
||||
|
||||
```
|
||||
morgan2.c:46:65: warning: value computed is not used [-Wunused-value]
|
||||
morgan2.c:46:65: warning: value computed is not used [-Wunused-value]
|
||||
```
|
||||
|
||||
With clang 3.1 on Linux Ubuntu 12.10 :
|
||||
|
||||
```
|
||||
morgan2.c:23:24: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
|
||||
morgan2.c:23:24: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
|
||||
```
|
||||
|
||||
**!!!!! HAVE FUN !!!!!**
|
||||
|
||||
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yves-Marie_Morgan">Yves-Marie Morgan</a><br>
|
||||
Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<em>France</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<em>France</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,12 +141,12 @@ Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<e
|
||||
<!-- 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></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<p>For the console version (ncurses):</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="ex">./morgan2</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./morgan2</span></span></code></pre></div>
|
||||
<p>For the graphical version (X11):</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">./morgan2</span> X</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./morgan2</span> X</span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>The judges enjoyed playing the game almost to completion; if we remember
|
||||
correctly, we managed to place 59 or 60 dominoes. We wonder, what would be
|
||||
@@ -228,9 +227,9 @@ use.</li>
|
||||
</ul>
|
||||
<h3 id="compilation-warnings">Compilation warnings</h3>
|
||||
<p>With gcc 4.7.2 on Linux Ubuntu 12.10 :</p>
|
||||
<pre><code>morgan2.c:46:65: warning: value computed is not used [-Wunused-value]</code></pre>
|
||||
<pre><code> morgan2.c:46:65: warning: value computed is not used [-Wunused-value]</code></pre>
|
||||
<p>With clang 3.1 on Linux Ubuntu 12.10 :</p>
|
||||
<pre><code>morgan2.c:23:24: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]</code></pre>
|
||||
<pre><code> morgan2.c:23:24: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]</code></pre>
|
||||
<p><strong>!!!!! HAVE FUN !!!!!</strong></p>
|
||||
<!--
|
||||
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./robison
|
||||
# enter an expression
|
||||
./robison
|
||||
# enter an expression
|
||||
|
||||
echo expression | ./robison
|
||||
echo expression | ./robison
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Arch_D_Robison">Arch D. Robison</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,14 +141,14 @@ 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></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./robison</span></span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co"># enter an expression</span></span>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./robison</span></span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># enter an expression</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> expression <span class="kw">|</span> <span class="ex">./robison</span></span></code></pre></div>
|
||||
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> expression <span class="kw">|</span> <span class="ex">./robison</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Of integers this prog does a lot,<br />
|
||||
plus minus, div times (and what not).</p>
|
||||
|
||||
Reference in new issue
Block a user