improved indentation and whitespace for markdown code blocks

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

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

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

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

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

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

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

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

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

No files matched your search

+13 -13
View File
@@ -1,20 +1,20 @@
## To build:
```sh
make
make
```
## To use:
```sh
./prog "expression"
./prog "expression"
```
or:
```sh
./prog
./prog
```
Type in expressions on standard input.
@@ -23,13 +23,13 @@ Type in expressions on standard input.
## Try:
```sh
./try.sh
./try.sh
```
Notice how the script reads in from a file. If you type just:
```sh
./prog
./prog
```
it will prompt you in the same way. Send ctrl-c to exit.
@@ -38,7 +38,7 @@ it will prompt you in the same way. Send ctrl-c to exit.
Finally, if you wish to read the man page:
```sh
man ./calc.1
man ./calc.1
```
@@ -52,7 +52,7 @@ author's remarks below.
### Alternate build:
```sh
make alt
make alt
```
@@ -110,7 +110,7 @@ However, unlike any other calculator source code the author is aware of,
this one contains no digits. At all. Anywhere. As in
```sh
grep '[0-9]' prog.c || echo no digits!
grep '[0-9]' prog.c || echo no digits!
```
Nor are the digits simply obfuscated. There are no character constants. There
@@ -192,8 +192,8 @@ long`. Changing the two `long long` typedefs to `long`, and compiling with `gcc
shifts mod 32:
```
1<<48
65536 0x00010000
1<<48
65536 0x00010000
```
gcc 4.2.1 without arguments compiles cleanly (e.g. `cc prog.c -o prog`).
@@ -203,7 +203,7 @@ clang 3.6.0 lives up to its namesake, resounding on non-problems.
To stifle these complaints:
```
-Wno-return-type -Wno-parentheses -Wno-empty-body
-Wno-return-type -Wno-parentheses -Wno-empty-body
```
When invoked with `-ansi -pedantic`, there are two warnings, which can be ignored:
@@ -223,8 +223,8 @@ If the program name begins with an `e`, it echoes `stdin` to `stdout`.
This allows for a convenient test suite:
```sh
ln -sf prog eprog
PATH=. eprog < test.in | diff - test.out
ln -sf prog eprog
PATH=. eprog < test.in | diff - test.out
```
### Spoilers:
+14 -15
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Dave_Burton">Dave Burton</a><br>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
<br><br></li>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,25 +141,25 @@ 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">./prog</span> <span class="st">&quot;expression&quot;</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">./prog</span> <span class="st">&quot;expression&quot;</span></span></code></pre></div>
<p>or:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</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">./prog</span></span></code></pre></div>
<p>Type in expressions on standard input.</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>Notice how the script reads in from a file. If you type just:</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">./prog</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">./prog</span></span></code></pre></div>
<p>it will prompt you in the same way. Send ctrl-c to exit.</p>
<p>Finally, if you wish to read the man page:</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">man</span> ./calc.1</span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">man</span> ./calc.1</span></code></pre></div>
<h2 id="alternate-code">Alternate code:</h2>
<p>An alternate version of this entry, <a href="prog.alt.c">prog.alt.c</a>, is provided.
This alternate code is discussed in the “prog.c vs prog.alt.c” section of the
author’s remarks below.</p>
<h3 id="alternate-build">Alternate build:</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="fu">make</span> alt</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">make</span> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
@@ -190,7 +189,7 @@ corrected by adding <code>-fsigned-char</code> to the compile line.</p>
<p>Yes, this is another calculator program.</p>
<p>However, unlike any other calculator source code the author is aware of,
this one contains no digits. At all. Anywhere. As in</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">grep</span> <span class="st">&#39;[0-9]&#39;</span> prog.c <span class="kw">||</span> <span class="bu">echo</span> no digits!</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">grep</span> <span class="st">&#39;[0-9]&#39;</span> prog.c <span class="kw">||</span> <span class="bu">echo</span> no digits!</span></code></pre></div>
<p>Nor are the digits simply obfuscated. There are no character constants. There
is only one single, short string, and it does not contain any obfuscated digits.
And yet the output is in decimal and hexadecimal, and it accepts octal, decimal,
@@ -246,13 +245,13 @@ they are to write.</p></li>
<h3 id="compiler-warnings">Compiler warnings</h3>
<p><code>calc</code> is C99 compliant, and is ANSI/C90 compliant except for wanting 64-bit <code>long long</code>. Changing the two <code>long long</code> typedefs to <code>long</code>, and compiling with <code>gcc -m32</code> yields a program that operates on 32-bit values, with wrap-around of
shifts mod 32:</p>
<pre><code>1&lt;&lt;48
65536 0x00010000</code></pre>
<pre><code> 1&lt;&lt;48
65536 0x00010000</code></pre>
<p>gcc 4.2.1 without arguments compiles cleanly (e.g. <code>cc prog.c -o prog</code>).
This is my workaday compiler. gcc is also clean with <code>-ansi</code>, and <code>-std=c99</code>.</p>
<p>clang 3.6.0 lives up to its namesake, resounding on non-problems.
To stifle these complaints:</p>
<pre><code>-Wno-return-type -Wno-parentheses -Wno-empty-body</code></pre>
<pre><code> -Wno-return-type -Wno-parentheses -Wno-empty-body</code></pre>
<p>When invoked with <code>-ansi -pedantic</code>, there are two warnings, which can be ignored:</p>
<ul>
<li><code>ISO C90 does not support 'long long'</code></li>
@@ -266,8 +265,8 @@ To stifle these complaints:</p>
<h3 id="test-suite">Test Suite:</h3>
<p>If the program name begins with an <code>e</code>, it echoes <code>stdin</code> to <code>stdout</code>.
This allows for a convenient test suite:</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">ln</span> <span class="at">-sf</span> prog eprog</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="va">PATH</span><span class="op">=</span>. <span class="ex">eprog</span> <span class="op">&lt;</span> test.in <span class="kw">|</span> <span class="fu">diff</span> <span class="at">-</span> test.out</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">ln</span> <span class="at">-sf</span> prog eprog</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="va">PATH</span><span class="op">=</span>. <span class="ex">eprog</span> <span class="op">&lt;</span> test.in <span class="kw">|</span> <span class="fu">diff</span> <span class="at">-</span> test.out</span></code></pre></div>
<h3 id="spoilers">Spoilers:</h3>
<p>If you do not want to puzzle out how it works, see <a href="spoilers.html">spoilers.html</a>.</p>
<!--
+40 -40
View File
@@ -135,50 +135,50 @@ did the basic four operations, but as a programmer, I needed more, so those
were added over time.</p>
<p><code>calc</code> is a useful, functioning utility. The operators before the obfuscation
dance began (this is called foreshadowing):</p>
<pre><code>() forced precedence
- ~ ? unary minus, compl, byteswap
* / % &amp; &lt;&lt; &gt;&gt; mul, div, mod, bitand, shift: left, right
+ - | ^ add, sub, bitor, xor
NUM 0-9</code></pre>
<pre><code> () forced precedence
- ~ ? unary minus, compl, byteswap
* / % &amp; &lt;&lt; &gt;&gt; mul, div, mod, bitand, shift: left, right
+ - | ^ add, sub, bitor, xor
NUM 0-9</code></pre>
<p>This seemed like a reasonable candidate to experiment with obfuscation; perhaps
it might yield good results.</p>
<h2 id="principle-of-operation">Principle of operation</h2>
<p>The algorithm was and is rather straightforward:</p>
<pre><code>expr() {
n = term()
t = token()
if (t == ADD) return n += expr()
if (t == SUB) return n -= expr()
if (t == BOR) return n |= expr()
if (t == XOR) return n ^= expr()
ungettoken(t)
return n
}
term() {
n = factor()
t = token()
if (t == MUL) return n *= term()
if (t == DIV) return n /= term()
if (t == AND) return n &amp;= term()
if (t == RSH) return n &gt;&gt; term()
if (t == LSH) return n &lt;&lt; term()
ungettoken(t)
return n
}
factor() {
t = token()
if (t == LPAREN) {
n = expr()
if token() == RPAREN
return n
error()
}
if (t == SUB) return -factor()
if (t == CMP) return ~factor()
if (t == QUE) return byteswap(factor())
if (t == DIG) return strtol()
error()
}</code></pre>
<pre><code> expr() {
n = term()
t = token()
if (t == ADD) return n += expr()
if (t == SUB) return n -= expr()
if (t == BOR) return n |= expr()
if (t == XOR) return n ^= expr()
ungettoken(t)
return n
}
term() {
n = factor()
t = token()
if (t == MUL) return n *= term()
if (t == DIV) return n /= term()
if (t == AND) return n &amp;= term()
if (t == RSH) return n &gt;&gt; term()
if (t == LSH) return n &lt;&lt; term()
ungettoken(t)
return n
}
factor() {
t = token()
if (t == LPAREN) {
n = expr()
if token() == RPAREN
return n
error()
}
if (t == SUB) return -factor()
if (t == CMP) return ~factor()
if (t == QUE) return byteswap(factor())
if (t == DIG) return strtol()
error()
}</code></pre>
<h2 id="obfuscation-is-a-process">Obfuscation is a process</h2>
<p>Within the above algorithm, there are many details unmentioned, all ripe for
obfuscation:</p>
+40 -40
View File
@@ -17,11 +17,11 @@ were added over time.
dance began (this is called foreshadowing):
```
() forced precedence
- ~ ? unary minus, compl, byteswap
* / % & << >> mul, div, mod, bitand, shift: left, right
+ - | ^ add, sub, bitor, xor
NUM 0-9
() forced precedence
- ~ ? unary minus, compl, byteswap
* / % & << >> mul, div, mod, bitand, shift: left, right
+ - | ^ add, sub, bitor, xor
NUM 0-9
```
This seemed like a reasonable candidate to experiment with obfuscation; perhaps
@@ -33,41 +33,41 @@ it might yield good results.
The algorithm was and is rather straightforward:
```
expr() {
n = term()
t = token()
if (t == ADD) return n += expr()
if (t == SUB) return n -= expr()
if (t == BOR) return n |= expr()
if (t == XOR) return n ^= expr()
ungettoken(t)
return n
}
term() {
n = factor()
t = token()
if (t == MUL) return n *= term()
if (t == DIV) return n /= term()
if (t == AND) return n &= term()
if (t == RSH) return n >> term()
if (t == LSH) return n << term()
ungettoken(t)
return n
}
factor() {
t = token()
if (t == LPAREN) {
n = expr()
if token() == RPAREN
return n
error()
}
if (t == SUB) return -factor()
if (t == CMP) return ~factor()
if (t == QUE) return byteswap(factor())
if (t == DIG) return strtol()
error()
}
expr() {
n = term()
t = token()
if (t == ADD) return n += expr()
if (t == SUB) return n -= expr()
if (t == BOR) return n |= expr()
if (t == XOR) return n ^= expr()
ungettoken(t)
return n
}
term() {
n = factor()
t = token()
if (t == MUL) return n *= term()
if (t == DIV) return n /= term()
if (t == AND) return n &= term()
if (t == RSH) return n >> term()
if (t == LSH) return n << term()
ungettoken(t)
return n
}
factor() {
t = token()
if (t == LPAREN) {
n = expr()
if token() == RPAREN
return n
error()
}
if (t == SUB) return -factor()
if (t == CMP) return ~factor()
if (t == QUE) return byteswap(factor())
if (t == DIG) return strtol()
error()
}
```
## Obfuscation is a process
+5 -5
View File
@@ -134,11 +134,11 @@ global pointer variable, and the integers from uninitialized global <code>int</c
variables. If <code>x</code> is a global <code>int</code>, then <code>!x</code> is <code>1</code>, and the derivation
proceeds from there, using some identities that are confusingly similar and
interestingly combined (increasing obfuscation):</p>
<pre><code>obc clr
--- ---
-~x x+1
~-x x-1
y-~x y+x+1</code></pre>
<pre><code> obc clr
--- ---
-~x x+1
~-x x-1
y-~x y+x+1</code></pre>
<p>The derived constants are a compromise between simple expressions, maximum utility,
and minimum number of variables used.</p>
<p>Command line arguments are copied into the upper half of the input buffer,
+5 -5
View File
@@ -14,11 +14,11 @@ proceeds from there, using some identities that are confusingly similar and
interestingly combined (increasing obfuscation):
```
obc clr
--- ---
-~x x+1
~-x x-1
y-~x y+x+1
obc clr
--- ---
-~x x+1
~-x x-1
y-~x y+x+1
```
The derived constants are a compromise between simple expressions, maximum utility,