Fix links, typos etc. for thanks in 1991

This commit is contained in:
Cody Boone Ferguson committed 2024-05-14 07:21:52 -07:00
1 parent d430a7af4c
commit a238404e5f
2 files changed
+115 -103

No files matched your search

+57 -51
View File
@@ -1397,7 +1397,8 @@ original code.</p>
<h3 id="source-code-ant.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.c">ant.c</a></h3> <h3 id="source-code-ant.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.c">ant.c</a></h3>
</div> </div>
<p><a href="#cody">Cody</a> added <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt.c">alt code</a> that will be a bit easier to use for <p><a href="#cody">Cody</a> added <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt.c">alt code</a> that will be a bit easier to use for
those familiar with vim in the following ways:</p> those familiar with vim in the following ways (we don’t want vi users to also
not be able to use it or exit it, now do we ? :-) ):</p>
<ul> <ul>
<li>Use <code>0</code> to go to first column.</li> <li>Use <code>0</code> to go to first column.</li>
<li>Use <code>$</code> to go to last column.</li> <li>Use <code>$</code> to go to last column.</li>
@@ -1412,7 +1413,7 @@ those familiar with vim in the following ways:</p>
<h3 id="source-code-brnstnd.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/brnstnd/brnstnd.c">brnstnd.c</a></h3> <h3 id="source-code-brnstnd.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/brnstnd/brnstnd.c">brnstnd.c</a></h3>
</div> </div>
<p><a href="#cody">Cody</a> fixed this for modern systems. There were two invalid operands to binary <p><a href="#cody">Cody</a> fixed this for modern systems. There were two invalid operands to binary
expression (<code>char *</code> and <code>void</code> and <code>int</code> and <code>void</code>) to resolve and expression (<code>char *</code>, <code>void</code> and <code>int</code>, <code>void</code>) to resolve and
additionally a mis-feature of the C pre-processor which no longer works had to additionally a mis-feature of the C pre-processor which no longer works had to
be changed as well in order to get this to compile. In particular the macro <code>C</code>, be changed as well in order to get this to compile. In particular the macro <code>C</code>,
defined as <code>C =G</code> to make <code>+=</code> and similar operators no longer works. The defined as <code>C =G</code> to make <code>+=</code> and similar operators no longer works. The
@@ -1425,58 +1426,60 @@ slightly more like the original, even though it’s unused.</p>
<h2 id="buzzard"><a href="1991/buzzard/index.html">1991/buzzard</a></h2> <h2 id="buzzard"><a href="1991/buzzard/index.html">1991/buzzard</a></h2>
<h3 id="source-code-buzzard.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/buzzard/buzzard.c">buzzard.c</a></h3> <h3 id="source-code-buzzard.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/buzzard/buzzard.c">buzzard.c</a></h3>
</div> </div>
<p><a href="#cody">Cody</a> fixed this so that the coordinates being specified would not crash the <p><a href="#cody">Cody</a> fixed this so that the coordinates being specified, a documented
program. This happened because the function that calls <code>atoi(3)</code> took an arg feature, would not crash the program. This happened because the function that
without any type specified and as an implicit <code>int</code> it was not a <code>char *</code> which calls <code>atoi(3)</code> took an arg without any type specified and as an implicit <code>int</code>
crashed the program in modern systems.</p> it was not a <code>char *</code> which crashed the program in modern systems.</p>
<p>Cody also made the file name in the code (which is the default maze file) not <p>Cody also made the file name in the code (which is the default maze file) not
hard-coded but instead be <code>__FILE__</code>.</p> hard-coded but instead be <code>__FILE__</code>.</p>
<p>Finally Cody added the <a href="1991/buzzard/index.html#alternate-code">alternate <p>Finally Cody added the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/buzzard/buzzard.alt.c">alternate
version</a> which will possibly feel more at version</a> which will possibly feel more
home with those familiar with vi(m) (it certainly does feel more at home with at home with those familiar with vi(m): <code>k</code> for forward, <code>h</code> for left and <code>l</code>
him): <code>k</code> for forward, <code>h</code> for left and <code>l</code> for right. This version also has a for right. This version also has a more useful way to exit, just entering <code>q</code>
more useful way to exit, just entering <code>q</code> followed by enter, rather than followed by enter, rather than completing (and it’s a maze) or killing the
completing or killing the program.</p> program. We still recommend you try the original version first, of course.</p>
<div id="1991_davidguy"> <div id="1991_davidguy">
<h2 id="davidguy"><a href="1991/davidguy/index.html">1991/davidguy</a></h2> <h2 id="davidguy"><a href="1991/davidguy/index.html">1991/davidguy</a></h2>
<h3 id="source-code-davidguy.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/davidguy/davidguy.c">davidguy.c</a></h3> <h3 id="source-code-davidguy.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/davidguy/davidguy.c">davidguy.c</a></h3>
</div> </div>
<p>As some systems like macOS can be particular about not declaring functions <a href="#cody">Cody</a> <p>As some systems like macOS can be particular about not declaring functions
added to the Makefile some <code>-include</code> options. These appear to not be strictly <a href="#cody">Cody</a> added to the <code>Makefile</code> some <code>-include</code> options. These appear to
necessary but it was done due to other syscalls being a problem not being not be strictly necessary (currently) but it was done due to other syscalls
declared first.</p> being a problem not being declared first, to hopefully future-proof it.</p>
<div id="1991_dds"> <div id="1991_dds">
<h2 id="dds-1"><a href="1991/dds/index.html">1991/dds</a></h2> <h2 id="dds-1"><a href="1991/dds/index.html">1991/dds</a></h2>
<h3 id="source-code-dds.c-1">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/dds/dds.c">dds.c</a></h3> <h3 id="source-code-dds.c-1">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/dds/dds.c">dds.c</a></h3>
</div> </div>
<p><a href="#cody">Cody</a> fixed a segfault that prevented this entry from working in any condition <p><a href="#cody">Cody</a> fixed a segfault that prevented this entry from working in any
and he also made it work for <code>clang</code>. He also added checks for NULL <code>FILE *</code>s. condition (the <code>char *s</code> had to be changed to <code>char s[]</code>) and he also made it
Furthermore he changed it so that the C from the BASIC uses <code>fgets()</code>, not and the generated code work for <code>clang</code>.</p>
<p>Furthermore Cody changed it so that the C from the BASIC uses <code>fgets()</code>, not
<code>gets()</code>. See <a href="faq.html#faq4_1">FAQ 4.1 - Why were some calls to <code>gets()</code>. See <a href="faq.html#faq4_1">FAQ 4.1 - Why were some calls to
the libc function gets(3) changed to use the libc function gets(3) changed to use
fgets(3)?</a> for why this was done.</p> fgets(3)?</a> for why this was done.</p>
<p>For the magic of <code>clang</code> and <code>fgets()</code> see below.</p> <p>For the magic of <code>clang</code> (which was done manually except the returning a value
<p><code>Clang</code> (at least in some systems?) defaults to having <code>-Werror</code> and the code that in <code>main()</code>) and <code>fgets(3)</code>, see below. The problem with <code>clang</code> can be
the entry generates had some warnings that were causing compilation to fail if described simply as: <code>clang</code> (at least in some systems?) defaults to having
<code>cc</code> is <code>clang</code> as it just ran <code>cc a.c</code>. It ran it by what was once <code>system(q-6);</code> <code>-Werror</code> and the code that the entry generates had some warnings that were
but if <code>cc</code> is <code>clang</code> like in macOS this is not enough.</p> causing compilation to fail if <code>cc</code> is <code>clang</code> (the entry runs <code>cc a.c</code>). An
<p>(Cody said he stupidly did the below manually until he thought to write a simple example problem that had to be fixed is that the generated code returned from
program to do the conversions which he used for <code>gets()</code> to <code>fgets()</code> and for <code>main()</code> no value but rather just had <code>return;</code>.</p>
making the generated code return a value from <code>main()</code> rather than just <p>The code used to run <code>cc a.c</code> by what was once <code>system(q-6);</code> but if <code>cc</code> is <code>clang</code>
<code>return;</code>).</p> like in macOS this is not enough.</p>
<p>The following had to be added to the string <code>s</code> (which to fix the segfault was <p>If you have the time and interest and you wish to follow the below a bit better,
changed from <code>char*s</code> to <code>char s[]</code>):</p> see the author’s remarks for the way the string works. The following had to be
added to the string <code>s</code>:</p>
<pre><code> !.Xop.fssps!.Xop.sfuvso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo</code></pre> <pre><code> !.Xop.fssps!.Xop.sfuvso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo</code></pre>
<p>and then the call to <code>system()</code> had to be changed to:</p> <p>and then the call to <code>system(3)</code> had to be changed to:</p>
<pre><code> system(q-69);</code></pre> <pre><code> system(q-69);</code></pre>
<p>An important point is that the placement of this string in the <code>s</code> array does <p>An important point is that the placement of this string in the <code>s</code> array
matter. This is because of the code:</p> <strong><em>does</em> matter</strong>. This is because of the code:</p>
<pre><code> *o=fopen(q-3,&quot;w&quot;);</code></pre> <pre><code> *o=fopen(q-3,&quot;w&quot;);</code></pre>
<p>which means the file name that translates to <code>a.c</code> has to be at the end of the <p>which means the file name that translates to <code>a.c</code> has to be at the end of the
string. Thus the end of the string actually looks like:</p> string. Thus the end of the string actually looks like:</p>
<pre><code> !.Xop.fssps!.Xop.sfuvso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!b/d</code></pre> <pre><code> !.Xop.fssps!.Xop.sfuvso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!b/d</code></pre>
<p>But then there is the matter of getting the C to use <code>fgets(3)</code>. As can be seen <p>But then there is the matter of getting the C to use <code>fgets(3)</code>. As can be seen
above it’s not as simple as changing <code>gets(3)</code> to <code>fgets(3)</code>. This was more magic above it’s not as simple as changing <code>gets(3)</code> to <code>fgets(3)</code>. This involved more magic
characters that had to be updated and some added. The C code:</p> characters that had to be updated and some added. The C code:</p>
<pre><code> atoi(gets(b))</code></pre> <pre><code> atoi(gets(b))</code></pre>
<p>is in the string:</p> <p>is in the string:</p>
@@ -1491,7 +1494,7 @@ have <code>-include stdio.h</code> which in this rotated string is:</p>
<pre><code> .jodmvef!tuejp/i</code></pre> <pre><code> .jodmvef!tuejp/i</code></pre>
<p>which had to be added after:</p> <p>which had to be added after:</p>
<pre><code> efdmbsbujpo!</code></pre> <pre><code> efdmbsbujpo!</code></pre>
<p>which is the end of the warning disabled for <code>clang</code> as described above.</p> <p>which is the end of the warning disabled for <code>clang</code> (as described above).</p>
<p>But now the <code>system(q-69);</code> had to be changed to <code>system(q-86);</code>.</p> <p>But now the <code>system(q-69);</code> had to be changed to <code>system(q-86);</code>.</p>
<p>Then, later on, Cody discovered that in some systems, <code>clang</code> triggers even more <p>Then, later on, Cody discovered that in some systems, <code>clang</code> triggers even more
warnings so this had to be corrected too so the string was updated again and warnings so this had to be corrected too so the string was updated again and
@@ -1511,15 +1514,17 @@ Thus in full the string became:</p>
b/d&quot;;</code></pre> b/d&quot;;</code></pre>
<p>and it now is <code>system(q-87);</code>.</p> <p>and it now is <code>system(q-87);</code>.</p>
<p>It is hoped that this is the last time the string has to be updated to work with <p>It is hoped that this is the last time the string has to be updated to work with
all versions of <code>clang</code> but if not the above is how it works.</p> all versions of <code>clang</code>, but if not the above is how it works.</p>
<p>With these changes in place it will compile and work with both <code>gcc</code> and <code>clang</code> and <p>With these changes in place it will compile and work with both <code>gcc</code> and <code>clang</code> and
the C code generated will use <code>fgets(3)</code>, not <code>gets(3)</code>, therefore removing the the C code generated will use <code>fgets(3)</code>, not <code>gets(3)</code>, therefore removing the
annoying warnings. Note that the array passed to <code>fgets(3)</code> is an int but that annoying warnings. Note that the array passed to <code>fgets(3)</code> is an <code>int</code> but that
was the same for <code>gets()</code> and is not necessary to update to a <code>char[]</code>.</p> was the same for <code>gets()</code> and is not necessary to update to a <code>char[]</code>. Thus you
might still get some warnings there.</p>
<p>The key to the string is that it rotates the character by <code>+1</code>. This was not <p>The key to the string is that it rotates the character by <code>+1</code>. This was not
immediately clear until reading the author’s remarks so there was an alt version immediately clear until reading the author’s remarks so there was an alt version
that was something of a kludge, running <code>make a</code> instead but that was removed.</p> that was something of a kludge, running <code>make a</code> instead, but after the proper
<p>Cody also fixed a typo in LANDER.BAS and made it so that if a file could not be fix was implemented the alt code was removed.</p>
<p>Cody also fixed a typo in <code>LANDER.BAS</code> and made it so that if a file could not be
opened for reading or a file could not be opened for writing it would not crash. opened for reading or a file could not be opened for writing it would not crash.
The definition of whether that should be a bug to fix or a feature to not fix The definition of whether that should be a bug to fix or a feature to not fix
was pondered and changed numerous times and ultimately that problem with this was pondered and changed numerous times and ultimately that problem with this
@@ -1528,16 +1533,17 @@ entry was fixed. It has not been done in all.</p>
<h2 id="fine"><a href="1991/fine/index.html">1991/fine</a></h2> <h2 id="fine"><a href="1991/fine/index.html">1991/fine</a></h2>
<h3 id="source-code-fine.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/fine/fine.c">fine.c</a></h3> <h3 id="source-code-fine.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/fine/fine.c">fine.c</a></h3>
</div> </div>
<p><a href="#cody">Cody</a> made it look much more like the original entry even after the fix that <p><a href="#cody">Cody</a> made it look much more like the original entry even after the fix
increased the count in characters from 80 to 106, getting it back down to just for <code>clang</code> (by the judges) that increased the count in characters from 80 to
85 (and later back down to 80, see below).</p> 106, getting it back down to just 85 (and later back down to 80, see below).</p>
<p>This was done by redefining <code>main</code> at the compiler line so that it looks like <p>This was done by redefining <code>main</code> at the compiler line so that it looks like
the original where one didn’t have to worry about the type of args of main() and the original where one didn’t have to worry about the type of args of <code>main()</code>
there were other fewer restrictions and also by removing a cast that was (when there were fewer restrictions), and also by removing a cast that was
not strictly necessary (this does create a new warning: <code>ordered comparison between pointer and integer ('char **' and 'int')</code> but it works just <code>fine</code>).</p> not strictly necessary (this created a new warning: <code>ordered comparison between pointer and integer ('char **' and 'int')</code> but it’s no longer there, as
described below).</p>
<p>That was <code>fine</code> as well but Cody decided to drop it back down to its original 80 <p>That was <code>fine</code> as well but Cody decided to drop it back down to its original 80
which also resolved the warning described above. This was by more clever use of characters which also resolved the warning described above. This was by more clever use of
the Makefile which now has a <code>-DB=(int)b</code> so that <code>B</code> can be used in place where the <code>Makefile</code> which now has a <code>-DB=(int)b</code> so that <code>B</code> can be used in place where
<code>(int)b</code> used to be necessary.</p> <code>(int)b</code> used to be necessary.</p>
<p>Cody also added the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/fine/try.sh">try.sh</a> script which feeds the program <p>Cody also added the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/fine/try.sh">try.sh</a> script which feeds the program
some fun input for fun but mostly different output. He added a great string from some fun input for fun but mostly different output. He added a great string from
@@ -1562,7 +1568,7 @@ the above fix was applied to these versions too.</p>
<h3 id="source-code-westley.c-4">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/westley/westley.c">westley.c</a></h3> <h3 id="source-code-westley.c-4">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/westley/westley.c">westley.c</a></h3>
</div> </div>
<p><a href="#cody">Cody</a> fixed a segfault in this program which prevented it from working. The <p><a href="#cody">Cody</a> fixed a segfault in this program which prevented it from working. The
problem was that the read-only char array <code>char *z[]</code> was being written to. The problem was that the read-only <code>char</code> array <code>char *z[]</code> was being written to. The
fix was to change it to <code>char z[][100]</code> in two spots (see if you can determine fix was to change it to <code>char z[][100]</code> in two spots (see if you can determine
why two places, not one!). Why 100 when the longest string is &lt; 100? Because a why two places, not one!). Why 100 when the longest string is &lt; 100? Because a
shorter value caused strange output and it’s easier to just choose a larger shorter value caused strange output and it’s easier to just choose a larger
@@ -1572,8 +1578,8 @@ also improved it so that warnings/errors/about to compile messages are not shown
unless the <code>-e</code> option is used. This is because the errors being shown kind of unless the <code>-e</code> option is used. This is because the errors being shown kind of
ruins the experience. Finally he made it pass ruins the experience. Finally he made it pass
<a href="https://github.com/koalaman/shellcheck">ShellCheck</a>.</p> <a href="https://github.com/koalaman/shellcheck">ShellCheck</a>.</p>
<p>Cody also added the alt version which is based on the author’s remarks, a <p>Cody also added the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/westley/westley.alt.c">alt version</a> which
version that supposedly (:-) ) always wins.</p> is based on the author’s remarks, a version that supposedly (:-) ) always wins.</p>
<p>Cody also fixed the make clobber rule where a file was left lying about when it <p>Cody also fixed the make clobber rule where a file was left lying about when it
should have been removed.</p> should have been removed.</p>
<div id="1992"> <div id="1992">
+58 -52
View File
@@ -1452,7 +1452,8 @@ Cody also added the [try.sh](%%REPO_URL%%/1990/westley/try.sh) script.
</div> </div>
[Cody](#cody) added [alt code](%%REPO_URL%%/1991/ant/ant.alt.c) that will be a bit easier to use for [Cody](#cody) added [alt code](%%REPO_URL%%/1991/ant/ant.alt.c) that will be a bit easier to use for
those familiar with vim in the following ways: those familiar with vim in the following ways (we don't want vi users to also
not be able to use it or exit it, now do we ? :-) ):
- Use `0` to go to first column. - Use `0` to go to first column.
- Use `$` to go to last column. - Use `$` to go to last column.
@@ -1470,7 +1471,7 @@ The other keys were left unchanged.
</div> </div>
[Cody](#cody) fixed this for modern systems. There were two invalid operands to binary [Cody](#cody) fixed this for modern systems. There were two invalid operands to binary
expression (`char *` and `void` and `int` and `void`) to resolve and expression (`char *`, `void` and `int`, `void`) to resolve and
additionally a mis-feature of the C pre-processor which no longer works had to additionally a mis-feature of the C pre-processor which no longer works had to
be changed as well in order to get this to compile. In particular the macro `C`, be changed as well in order to get this to compile. In particular the macro `C`,
defined as `C =G` to make `+=` and similar operators no longer works. The defined as `C =G` to make `+=` and similar operators no longer works. The
@@ -1488,20 +1489,20 @@ Cody also added the [try.sh](%%REPO_URL%%/1991/brnstnd/try.sh) script and
### Source code: [buzzard.c](%%REPO_URL%%/1991/buzzard/buzzard.c) ### Source code: [buzzard.c](%%REPO_URL%%/1991/buzzard/buzzard.c)
</div> </div>
[Cody](#cody) fixed this so that the coordinates being specified would not crash the [Cody](#cody) fixed this so that the coordinates being specified, a documented
program. This happened because the function that calls `atoi(3)` took an arg feature, would not crash the program. This happened because the function that
without any type specified and as an implicit `int` it was not a `char *` which calls `atoi(3)` took an arg without any type specified and as an implicit `int`
crashed the program in modern systems. it was not a `char *` which crashed the program in modern systems.
Cody also made the file name in the code (which is the default maze file) not Cody also made the file name in the code (which is the default maze file) not
hard-coded but instead be `__FILE__`. hard-coded but instead be `__FILE__`.
Finally Cody added the [alternate Finally Cody added the [alternate
version](1991/buzzard/index.html#alternate-code) which will possibly feel more at version](%%REPO_URL%%/1991/buzzard/buzzard.alt.c) which will possibly feel more
home with those familiar with vi(m) (it certainly does feel more at home with at home with those familiar with vi(m): `k` for forward, `h` for left and `l`
him): `k` for forward, `h` for left and `l` for right. This version also has a for right. This version also has a more useful way to exit, just entering `q`
more useful way to exit, just entering `q` followed by enter, rather than followed by enter, rather than completing (and it's a maze) or killing the
completing or killing the program. program. We still recommend you try the original version first, of course.
<div id="1991_davidguy"> <div id="1991_davidguy">
@@ -1509,10 +1510,10 @@ completing or killing the program.
### Source code: [davidguy.c](%%REPO_URL%%/1991/davidguy/davidguy.c) ### Source code: [davidguy.c](%%REPO_URL%%/1991/davidguy/davidguy.c)
</div> </div>
As some systems like macOS can be particular about not declaring functions [Cody](#cody) As some systems like macOS can be particular about not declaring functions
added to the Makefile some `-include` options. These appear to not be strictly [Cody](#cody) added to the `Makefile` some `-include` options. These appear to
necessary but it was done due to other syscalls being a problem not being not be strictly necessary (currently) but it was done due to other syscalls
declared first. being a problem not being declared first, to hopefully future-proof it.
<div id="1991_dds"> <div id="1991_dds">
@@ -1520,40 +1521,42 @@ declared first.
### Source code: [dds.c](%%REPO_URL%%/1991/dds/dds.c) ### Source code: [dds.c](%%REPO_URL%%/1991/dds/dds.c)
</div> </div>
[Cody](#cody) fixed a segfault that prevented this entry from working in any condition [Cody](#cody) fixed a segfault that prevented this entry from working in any
and he also made it work for `clang`. He also added checks for NULL `FILE *`s. condition (the `char *s` had to be changed to `char s[]`) and he also made it
Furthermore he changed it so that the C from the BASIC uses `fgets()`, not and the generated code work for `clang`.
Furthermore Cody changed it so that the C from the BASIC uses `fgets()`, not
`gets()`. See [FAQ 4.1 - Why were some calls to `gets()`. See [FAQ 4.1 - Why were some calls to
the libc function gets&#x28;3&#x29; changed to use the libc function gets&#x28;3&#x29; changed to use
fgets&#x28;3&#x29;?](faq.html#faq4_1) for why this was done. fgets&#x28;3&#x29;?](faq.html#faq4_1) for why this was done.
For the magic of `clang` and `fgets()` see below. For the magic of `clang` (which was done manually except the returning a value
in `main()`) and `fgets(3)`, see below. The problem with `clang` can be
described simply as: `clang` (at least in some systems?) defaults to having
`-Werror` and the code that the entry generates had some warnings that were
causing compilation to fail if `cc` is `clang` (the entry runs `cc a.c`). An
example problem that had to be fixed is that the generated code returned from
`main()` no value but rather just had `return;`.
`Clang` (at least in some systems?) defaults to having `-Werror` and the code that The code used to run `cc a.c` by what was once `system(q-6);` but if `cc` is `clang`
the entry generates had some warnings that were causing compilation to fail if like in macOS this is not enough.
`cc` is `clang` as it just ran `cc a.c`. It ran it by what was once `system(q-6);`
but if `cc` is `clang` like in macOS this is not enough.
(Cody said he stupidly did the below manually until he thought to write a simple If you have the time and interest and you wish to follow the below a bit better,
program to do the conversions which he used for `gets()` to `fgets()` and for see the author's remarks for the way the string works. The following had to be
making the generated code return a value from `main()` rather than just added to the string `s`:
`return;`).
The following had to be added to the string `s` (which to fix the segfault was
changed from `char*s` to `char s[]`):
``` ```
!.Xop.fssps!.Xop.sfuvso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo !.Xop.fssps!.Xop.sfuvso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo
``` ```
and then the call to `system()` had to be changed to: and then the call to `system(3)` had to be changed to:
``` <!---c--> ``` <!---c-->
system(q-69); system(q-69);
``` ```
An important point is that the placement of this string in the `s` array does An important point is that the placement of this string in the `s` array
matter. This is because of the code: **_does_ matter**. This is because of the code:
``` <!---c--> ``` <!---c-->
*o=fopen(q-3,"w"); *o=fopen(q-3,"w");
@@ -1567,7 +1570,7 @@ string. Thus the end of the string actually looks like:
``` ```
But then there is the matter of getting the C to use `fgets(3)`. As can be seen But then there is the matter of getting the C to use `fgets(3)`. As can be seen
above it's not as simple as changing `gets(3)` to `fgets(3)`. This was more magic above it's not as simple as changing `gets(3)` to `fgets(3)`. This involved more magic
characters that had to be updated and some added. The C code: characters that had to be updated and some added. The C code:
``` <!---c--> ``` <!---c-->
@@ -1606,7 +1609,7 @@ which had to be added after:
efdmbsbujpo! efdmbsbujpo!
``` ```
which is the end of the warning disabled for `clang` as described above. which is the end of the warning disabled for `clang` (as described above).
But now the `system(q-69);` had to be changed to `system(q-86);`. But now the `system(q-69);` had to be changed to `system(q-86);`.
@@ -1634,18 +1637,20 @@ Thus in full the string became:
and it now is `system(q-87);`. and it now is `system(q-87);`.
It is hoped that this is the last time the string has to be updated to work with It is hoped that this is the last time the string has to be updated to work with
all versions of `clang` but if not the above is how it works. all versions of `clang`, but if not the above is how it works.
With these changes in place it will compile and work with both `gcc` and `clang` and With these changes in place it will compile and work with both `gcc` and `clang` and
the C code generated will use `fgets(3)`, not `gets(3)`, therefore removing the the C code generated will use `fgets(3)`, not `gets(3)`, therefore removing the
annoying warnings. Note that the array passed to `fgets(3)` is an int but that annoying warnings. Note that the array passed to `fgets(3)` is an `int` but that
was the same for `gets()` and is not necessary to update to a `char[]`. was the same for `gets()` and is not necessary to update to a `char[]`. Thus you
might still get some warnings there.
The key to the string is that it rotates the character by `+1`. This was not The key to the string is that it rotates the character by `+1`. This was not
immediately clear until reading the author's remarks so there was an alt version immediately clear until reading the author's remarks so there was an alt version
that was something of a kludge, running `make a` instead but that was removed. that was something of a kludge, running `make a` instead, but after the proper
fix was implemented the alt code was removed.
Cody also fixed a typo in LANDER.BAS and made it so that if a file could not be Cody also fixed a typo in `LANDER.BAS` and made it so that if a file could not be
opened for reading or a file could not be opened for writing it would not crash. opened for reading or a file could not be opened for writing it would not crash.
The definition of whether that should be a bug to fix or a feature to not fix The definition of whether that should be a bug to fix or a feature to not fix
was pondered and changed numerous times and ultimately that problem with this was pondered and changed numerous times and ultimately that problem with this
@@ -1657,19 +1662,20 @@ entry was fixed. It has not been done in all.
### Source code: [fine.c](%%REPO_URL%%/1991/fine/fine.c) ### Source code: [fine.c](%%REPO_URL%%/1991/fine/fine.c)
</div> </div>
[Cody](#cody) made it look much more like the original entry even after the fix that [Cody](#cody) made it look much more like the original entry even after the fix
increased the count in characters from 80 to 106, getting it back down to just for `clang` (by the judges) that increased the count in characters from 80 to
85 (and later back down to 80, see below). 106, getting it back down to just 85 (and later back down to 80, see below).
This was done by redefining `main` at the compiler line so that it looks like This was done by redefining `main` at the compiler line so that it looks like
the original where one didn't have to worry about the type of args of main() and the original where one didn't have to worry about the type of args of `main()`
there were other fewer restrictions and also by removing a cast that was (when there were fewer restrictions), and also by removing a cast that was
not strictly necessary (this does create a new warning: `ordered comparison not strictly necessary (this created a new warning: `ordered comparison
between pointer and integer ('char **' and 'int')` but it works just `fine`). between pointer and integer ('char **' and 'int')` but it's no longer there, as
described below).
That was `fine` as well but Cody decided to drop it back down to its original 80 That was `fine` as well but Cody decided to drop it back down to its original 80
which also resolved the warning described above. This was by more clever use of characters which also resolved the warning described above. This was by more clever use of
the Makefile which now has a `-DB=(int)b` so that `B` can be used in place where the `Makefile` which now has a `-DB=(int)b` so that `B` can be used in place where
`(int)b` used to be necessary. `(int)b` used to be necessary.
Cody also added the [try.sh](%%REPO_URL%%/1991/fine/try.sh) script which feeds the program Cody also added the [try.sh](%%REPO_URL%%/1991/fine/try.sh) script which feeds the program
@@ -1702,7 +1708,7 @@ the above fix was applied to these versions too.
</div> </div>
[Cody](#cody) fixed a segfault in this program which prevented it from working. The [Cody](#cody) fixed a segfault in this program which prevented it from working. The
problem was that the read-only char array `char *z[]` was being written to. The problem was that the read-only `char` array `char *z[]` was being written to. The
fix was to change it to `char z[][100]` in two spots (see if you can determine fix was to change it to `char z[][100]` in two spots (see if you can determine
why two places, not one!). Why 100 when the longest string is < 100? Because a why two places, not one!). Why 100 when the longest string is < 100? Because a
shorter value caused strange output and it's easier to just choose a larger shorter value caused strange output and it's easier to just choose a larger
@@ -1714,8 +1720,8 @@ unless the `-e` option is used. This is because the errors being shown kind of
ruins the experience. Finally he made it pass ruins the experience. Finally he made it pass
[ShellCheck](https://github.com/koalaman/shellcheck). [ShellCheck](https://github.com/koalaman/shellcheck).
Cody also added the alt version which is based on the author's remarks, a Cody also added the [alt version](%%REPO_URL%%/1991/westley/westley.alt.c) which
version that supposedly (:-) ) always wins. is based on the author's remarks, a version that supposedly (:-) ) always wins.
Cody also fixed the make clobber rule where a file was left lying about when it Cody also fixed the make clobber rule where a file was left lying about when it
should have been removed. should have been removed.