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
@@ -372,7 +372,7 @@ hit a key every time to move because it is blocking.</p></li>
|
||||
</ul>
|
||||
<h2 id="on-environmental-variables-more-generally-and-string-to-int-conversions"><a name="envvars" href="#toc">On environmental variables more generally and string to int conversions</a></h2>
|
||||
<p>What happens if you do:</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="va">WALLS</span><span class="op">=</span> <span class="ex">./prog</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="va">WALLS</span><span class="op">=</span> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>Can you run into the wall since you didn’t specify a value and the default is 1?
|
||||
No. That’s not the way it works. By saying WALLS= you have told the system that
|
||||
there is that environmental variable. However the way the <code>strtoul()</code> functions
|
||||
@@ -381,29 +381,29 @@ it’s wasteful (iocccsize wise) and I have never felt that having invalid input
|
||||
for a number could have a better value than 0.</p>
|
||||
<p>If however you were to give valid input followed by invalid input the valid
|
||||
input would be parsed. For example:</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="va">WALLS</span><span class="op">=</span>1test <span class="ex">./prog</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="va">WALLS</span><span class="op">=</span>1test <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>would let you go through the walls. On the other hand</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="va">WALLS</span><span class="op">=</span>test1 <span class="ex">./prog</span></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="va">WALLS</span><span class="op">=</span>test1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>would not. Furthermore if you specify the same variable more than once it’s the
|
||||
last one that counts. For example:</p>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="va">WALLS</span><span class="op">=</span>0 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WALLS</span><span class="op">=</span>0 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>would allow you to go through walls but you could not cannibalise.</p>
|
||||
<p>Also note that I specify base 0 which means that you can also have it in hex and
|
||||
octal. These are all the same:</p>
|
||||
<pre><code>SIZE=0x3
|
||||
SIZE=3
|
||||
SIZE=03</code></pre>
|
||||
<pre><code> SIZE=0x3
|
||||
SIZE=3
|
||||
SIZE=03</code></pre>
|
||||
<p>The way the functions work is if 0x (or 0X) it’s considered hex; if prefixed
|
||||
with a 0 it’s octal and otherwise it’s decimal. If you specify invalid data
|
||||
(even if only at the beginning of the string) the functions return 0. For
|
||||
example:</p>
|
||||
<pre><code>SIZE=0
|
||||
SIZE=f
|
||||
SIZE=-
|
||||
SIZE=f1</code></pre>
|
||||
<pre><code> SIZE=0
|
||||
SIZE=f
|
||||
SIZE=-
|
||||
SIZE=f1</code></pre>
|
||||
<p>are all equivalent.</p>
|
||||
<p>Observe that:</p>
|
||||
<pre><code>SIZE=08</code></pre>
|
||||
<pre><code> SIZE=08</code></pre>
|
||||
<p>is invalid input because octal only has digits 0 - 7: the resulting size will be
|
||||
0.</p>
|
||||
<p>I discuss the signed/unsigned issue to do with curses and sizes in C being
|
||||
@@ -421,17 +421,17 @@ will end (yes things that haven’t begun can be ended).</p>
|
||||
<p>If <code>calloc()</code> fails to obtain the needed memory you’ll see something like (here it
|
||||
was before I added proper - to make the perfect and obvious pun - capsizing
|
||||
so that by setting the size to -1 it went to the max unsigned value):</p>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> MAXSIZE=-1 ./prog</span>
|
||||
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="ex">memory</span> error</span>
|
||||
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a><span class="ex">X:0/157</span> Y:0/42 S:3/18446744073709551614 B:0</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> MAXSIZE=-1 ./prog</span>
|
||||
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">memory</span> error</span>
|
||||
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">X:0/157</span> Y:0/42 S:3/18446744073709551614 B:0</span></code></pre></div>
|
||||
<p>BTW: There are two arrays that have to be <strong>MAXSIZE</strong> (technically + 1).</p>
|
||||
<p>Is it possible that some value specified by the user could mess this up? I do
|
||||
not know but what I do know is that because it’s unsigned it can’t be negative;
|
||||
if the max size is 0 then the array size will be 1 but it won’t matter because
|
||||
the snake size will be >= that max anyway. But here’s a curious output:</p>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>1 <span class="va">MAXSIZE</span><span class="op">=</span>0 <span class="ex">./prog</span></span>
|
||||
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="ex">YOU</span> WIN!</span>
|
||||
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a><span class="ex">X:78/156</span> Y:20/41 S:0/0 B:0</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a> <span class="va">SIZE</span><span class="op">=</span>1 <span class="va">MAXSIZE</span><span class="op">=</span>0 <span class="ex">./prog</span></span>
|
||||
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">YOU</span> WIN!</span>
|
||||
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">X:78/156</span> Y:20/41 S:0/0 B:0</span></code></pre></div>
|
||||
<p>Why does it show snake size as 0 when I specified 1? It’s because the max size
|
||||
is 0 and I limit the size to be no bigger than the max size.</p>
|
||||
<!--
|
||||
|
||||
Reference in new issue
Block a user