2024/ferguson1 bug fix, make goto complete (149)

A bug was discovered in prog.c (now prog.alt2.c, see below) that has
been fixed. It was not a critical bug but it came about when juggling
things during development, and fixing it means there should now only be
one place where an event might not trigger (or actually it's an event
within an event that does not trigger - polymorphism related).

The prog.c is the goto complete version - what was once prog.goto.max.c
(git status is confused however - it shows that that file is now
prog.alt2.c but actually prog.alt2.c is what prog.c was). For practical
reasons (and to make the judges not weep and curse me quite as much)
this was not the prog.c but since some others have made corrections to
their winning code I have decided to do the same thing here. It was a
hassle to juggle between the different versions and I ran out of the
number of files allowed - that is what I mean by practical reasons.

The prog.c has maintained its thematic 4666 bytes, after some formatting
updates.

Typo fixes were made in some of the supplementary C files.

Makefile updated so that one can compile prog.alt2.c.

.entry.json, index.html and obfuscation.html were all updated.

The judges' remarks were slightly corrected. It is not 134 (now 149)
jumps that occurs but rather gotos. The jumps can be over 1000, in fact
one test run was over 1400, although shorter games can be fewer (though
still a lot).

Other errors in documentation that were artefacts from earlier stages in
development were also corrected, although I'm sure there are more (the
ones that were discovered were ones near to stats that had to be
updated).
This commit is contained in:
Cody Boone Ferguson committed 2025-08-13 08:14:05 -07:00
1 parent a1c86c8a7a
commit ad622a5354
15 files changed
+813 -636

No files matched your search

+129 -69
View File
@@ -494,42 +494,45 @@ counter-example for that letter but oh is everyone in for a HUGE SHOCK!</p>
<p>24 is peanuts compared to what I did. And let’s be honest - 24 is ALREADY WAY
too many, even in a large program, let alone a small one. Even one <code>goto</code> is too
many. Unless I am very much mistaken, I have broken the record by a huge margin.</p>
<p>Here’s the horrifying and hilarious truth: I beat it out by 92 MORE, <strong>BEFORE</strong> the
cpp at 116 and after the cpp is through I beat it by <strong>110</strong> MORE (!!), <strong>AT
134!</strong> Yes, you read that right. 134 <code>goto</code>s! I even went further in an alt
version, where before the cpp it was 131 <code>goto</code>s and after the cpp 149 (!!)
<code>goto</code>s. I didn’t do this in the main entry for practical reasons but I wish I
had.</p>
<p>Even removing what I think are the only dead <code>goto</code>s, two of them, including one
that is in the <code>w()</code> macro that would be translated into more, I beat it by 90
more, at 114 before the cpp, and 99 more after the cpp, at 123!</p>
<p>Here’s the horrifying and hilarious truth: I beat it out by <del>92</del> 107
MORE, <strong>BEFORE</strong> the cpp at <del>116</del> 131 and after the cpp is through I
beat it by <strong>125</strong> MORE (!!), <strong>AT 149!</strong> Yes, you read that right.
<del>134</del> 149 <code>goto</code>s! The originally submitted prog.c, submitted for
practical reasons only, had it at, as might be guessed, 116/134 before and after
the cpp.</p>
<p>Even removing what I think were the only dead <code>goto</code>s in the incomplete version,
two of them, including one that is in the <code>w()</code> macro that would be translated
into more, I beat it by 90 more, at 114 before the cpp, and 99 more after the
cpp, at 123! But of course it’s more now…</p>
<p>Did I forget to mention the original Oregon Trail in <strong>BASIC</strong> from 1978 HAS A
MEASLY 109? THIS SHOULD NOT HAPPEN. Well it did happen and this HAS to be a
joke, right? I’m sorry but it is NOT a joke. I am for real. There REALLY are
that many and that is ridiculous.</p>
<p>Okay so it’s a joke in another way but nonetheless YES I <strong>REALLY DID</strong> put in
116/134 <code>goto</code>s, depending on if you pre-process it or not! YES I might be mad.
YES I think it’s HILARIOUS. But if it was not for the IOCCC… Well, as I
mention in my <a href="#devil">remarks above</a>, EVEN ONE IS TOO MANY
<del>116/134</del> 131/149 <code>goto</code>s, depending on if you pre-process it or not!
YES I might be mad. YES I think it’s HILARIOUS. But if it was not for the
IOCCC… Well, as I mention in my <a href="#devil">remarks above</a>, EVEN ONE IS TOO MANY
in real code.</p>
<p>I dare you to run the program in a debugger from start to finish to see how many
line jumps there truly are. After I won I did it once: removing the <code>#include</code>s,
blank lines, lines with only variables and lines with just braces (i.e. only
lines of code) the program has just 59 lines and in a single run there were a
total of <strong>985</strong> (!) line changes, counting function calls. In <code>main()</code> itself
the line changed a total of <strong>776</strong> (!) times!</p>
lines of code) the program has just 58 lines and in a single run there were a
total of <strong>1416</strong> (!) line changes, counting function calls. In <code>main()</code> itself
the line changed a total of <strong>1131</strong> (!) times!</p>
<p>The best (or worst, depending on how you look at it :-) ) part is this works. As
I note in those concluding remarks, a <a href="https://www.apple.com">famous company</a>
actually introduced a security hole from ONE <code>goto</code>. Yet I have 116/134 and it
actually works? That is surely obscene. And beautiful.</p>
<p>Oh and BTW: it appears that <code>hines</code> is a bit confused about my entry,
though I’m not really sure why. In any case, I not only have dethroned <code>hines</code>
(sorry …but also not sorry!) but I have, as noted already, beaten the original
BASIC game by <strong>7</strong> more <code>goto</code>s at 116 before the cpp and <strong>25 MORE</strong> after the
cpp, at 134!</p>
<p>It’s almost impossible to add more <code>goto</code>s. You’ll see why soon. But even if
that was not the case I wanted room for the other things I did, some of which
are quite cool and I believe unique as well.</p>
I note in those concluding remarks, a <a href="https://www.apple.com">nameless company</a>
actually introduced a security hole from ONE <code>goto</code>. Yet I have
<del>116/134</del> 131/149 and it actually works? That is surely obscene. And
beautiful. But wrong.</p>
<p>Oh and BTW: it appears that <code>hines</code> is a bit confused about my entry, though I’m
not really sure why. In any case, I not only have dethroned <code>hines</code> (sorry
…but also not sorry!) but I have, as noted already, beaten the original BASIC
game by <del>7</del> 22 more <code>goto</code>s at <del>116</del> 131 before the cpp
and <del><strong>18 MORE</strong></del> <strong>40 MORE</strong> after the cpp, at 149!</p>
<p>It’s almost impossible to add more <code>goto</code>s. With the iocccsize it is impossible,
if I don’t want to sacrifice the rest of the program. You’ll see why soon. But
even if that was not the case I wanted room for the other things I did, some of
which are quite cool and I believe unique as well.</p>
<p>And yes, I agree: the idea of <code>goto</code>s considered harmful considered harmful is
ludicrous, and as you just found out (probably in horror), I have taken it far
further.</p>
@@ -537,10 +540,11 @@ further.</p>
know about C when it comes to things like: loops, if/else, switch/case, blocks
in general, where code can be, where labels can be, really everything: the code
is in all the wrong places.</p>
<p>This is not counting other cool things like a single <code>char *</code> holding near
200 <code>char *</code>s. No. I do not mean an array of <code>char *</code>s! I mean a single flat
<code>char *</code>! Yet in the code I index it AS IF it’s a <code>char *[]</code>, just to add to
the confusion (as if the 134 <code>goto</code>s are not bad enough). But it’s not a <code>char *[]</code>. It’s a single <code>char *</code>, which is the contents of the data file.</p>
<p>This is not counting other cool things like a single <code>char *</code> holding near 200
<code>char *</code>s. No. I do not mean an array of <code>char *</code>s! I mean a single flat <code>char *</code>! Yet in the code I index it AS IF it’s a <code>char *[]</code>, just to add to the
confusion (as if the <del>134</del> 149 <code>goto</code>s are not bad enough). But it’s
not a <code>char *[]</code>. It’s a single <code>char *</code>, which is the contents of the data
file.</p>
<p>There are other things I have done, of course.</p>
<p>This program took two months, to the day, to develop and it was totally worth
it. But I was almost strangled by the spaghetti, kind of like the Devil, which
@@ -590,17 +594,19 @@ have lost my mind this program sure as hell lost its mind! And it’s my fault.
Hilarious.</p>
<p>Counting whitespace this program is only 4666 bytes according to <code>wc -c</code> (macOS
at the least, maybe others): quite intentionally to be on theme. That’s a
relatively short program to have 116 <code>goto</code>s or more when filtered through <code>cc -E</code> (134!), wouldn’t you say? If that’s NOT too many, then I ask you WHAT IS?</p>
relatively short program to have <del>116</del> 131 <code>goto</code>s or more when
filtered through <code>cc -E</code> (<del>134</del> 149!), wouldn’t you say? If that’s NOT
too many, then I ask you WHAT IS?</p>
<p>As said in numerous places, IT IS MUCH SMALLER than the BASIC file I included
even after stripping it of much of it. My program also has more events. I think
the BASIC one has 16 not counting the mountains code and mine is 23 not counting
the mountains code, which obviously I also include.</p>
<p>I discuss this some in my concluding <a href="#devil">remarks above</a>,
as well as mentioning that there are other events
besides those 23. I certainly will not reveal all though. The humour and jokes
sections of that file says more but the concluding remarks are for a summary and
why I think that this code is worthy of the contest AND also pointing out the
folly of <code>goto</code>.</p>
the mountains code, which obviously I also include and has more events (if we
count the doctor visits an event then even more).</p>
<p>I discuss this some in my concluding <a href="#devil">remarks above</a>, as well as
mentioning that there are other events besides those 23. I certainly will not
reveal all though. The humour and jokes sections of that file says more but the
concluding remarks are for a summary and why I think that this code is worthy of
the contest AND also pointing out the folly of <code>goto</code>.</p>
<p>In this file I will discuss how some events actually are polymorphic, in a
sense, having at least two different events.</p>
<p>THIS IS ALL OBSCENE.</p>
@@ -634,7 +640,58 @@ been mad enough to do what I have done.</p>
<p>Here are some fun statistics from a somewhat rudimentary program on both the
prog.c and after filtered through <code>cc -E</code>. First prog.c. Prepare to be
horrified, if you’re not already:</p>
<pre><code> 131 goto
301 semicolon
143 colons
51 if
11 else
3 while
4 for
0 do
6 switch
32 case
2 sizeof
0 break
0 continue
2 default
8 long
3 unsigned
4 return
1 void
1 int
1 char
1 size_t
Ratio: 1.01 gotos per keyword</code></pre>
<p>1.01 goto per keyword? But then there’s the cpp filtered code…</p>
<pre><code> 149 goto
339 semicolon
143 colons
51 if
11 else
7 while
4 for
0 do
6 switch
32 case
2 sizeof
0 break
0 continue
2 default
8 long
3 unsigned
4 return
1 void
1 int
1 char
1 size_t
Ratio: 1.11 gotos per keyword</code></pre>
<p>1.11!</p>
<p>For comparison, here is the original version:</p>
<pre><code> 116 goto
294 semicolon
138 colons
50 if
11 else
4 while
@@ -653,11 +710,12 @@ horrified, if you’re not already:</p>
1 int
1 char
1 size_t
1 FILE
Ratio: 0.83 gotos per keyword</code></pre>
<p>And the pre-processed one:</p>
<pre><code> 134 goto
332 semicolon
138 colons
50 if
11 else
8 while
@@ -676,13 +734,9 @@ horrified, if you’re not already:</p>
1 int
1 char
1 size_t
1 FILE
Ratio: 0.93 gotos per keyword</code></pre>
<p>LOOK AT THAT RATIO! And we could even suggest that <code>FILE</code> might not be a
keyword, but rather a struct.</p>
<p>Whether data types are keywords for this is also something to consider but we’ll
include them as keywords anyway. I don’t believe I use any others in any case.</p>
Ratio: 0.94 gotos per keyword</code></pre>
<p>Look at those ratios. This is not right.</p>
<p>This program is as cursed as the PC (player character) if not much more cursed.
It is totally bonkers and it was really hard to find places for labels even
after I put them in bizarre and unusual places. But I get into that in more
@@ -783,7 +837,8 @@ it.</p>
<p>There are a lot of ways to obscure code and I don’t believe anyone has taken
<code>goto</code> to this obscenity in C. I believe the one with the most <code>goto</code>s is
1987/hines and, as noted earlier, it reports on itself as having only 24
<code>goto</code>s. Yet I have 116 before the cpp and 134 (!!) after the cpp.</p>
<code>goto</code>s. Yet I have <del>116</del> 131 before the cpp and <del>134</del> 149
(!!) after the cpp.</p>
<p>And unfortunately for you dear reader I have done other things that also are
quite different and totally unrelated to <code>goto</code>s. Even so the <code>goto</code> madness by
itself is worth something or some things - including curses.</p>
@@ -940,6 +995,8 @@ one question their sanity even more. Yes I’m probably a sociopath.</p>
* WARNING: this code and its comments are not up to date. I wrote 116 before
* filtered through the cpp and 134 after the cpp and I didn&#39;t wish to
* repeatedly revisit this file trying to explain everything.</code></pre>
<p>…and of course now the count, prog.c being the full version and prog.alt2.c
being the practical version, have the count at 131/149.</p>
<p>I hope you understand but I do believe it’s a gain not a loss. It is good enough
especially as it’s only for educational value - or to examine my head (though
prog.c might be better for that?). As noted the code (and jokes) took a couple
@@ -1716,30 +1773,33 @@ padding?</p>
<h3 id="conclusions">Conclusions</h3>
<p>A question: is this well-rounded in obfuscation as the judges like? Definitely.</p>
<p>The fact that close to 200 NUL terminated strings are in a single <code>char *</code> (!!),
the odd looking compound literal, the maze of <code>goto</code>s (116 or 1134 depending on
if you pre-process the code), the bastardised Duff’s device, the strange labels
inside <code>switch()</code>s, the jumping into and out of <code>switch()</code>s only to jump back in
(or out), the for loops split across several parts of the code (one making it
look like variables are uninitialised), if/else code being swapped in location
(or moved to other parts of the code, even in what would otherwise be dead code,
including possibly this for for loops), the fall through of a label to a goto
that jumps back to right before that fall through just to exit the game (isn’t
that so cute?), the fact I had to write all those tools to verify things are
okay (showing how messed up it is), different blocks that have code that simply
should not be there, the nested ternary operators…</p>
<p>As for the <code>goto</code>s: yes I technically have more space. But it became almost
impossible to add more spaghetti to the pot without it overflowing, and I do not
the odd looking compound literal, the maze of <code>goto</code>s (<del>116</del> 131 or
<del>134</del> 149 depending on if you pre-process the code), the bastardised
Duff’s device, the strange labels inside <code>switch()</code>s, the jumping into and out
of <code>switch()</code>s only to jump back in (or out), the for loops split across several
parts of the code (one making it look like variables are uninitialised), if/else
code being swapped in location (or moved to other parts of the code, even in
what would otherwise be dead code, including possibly this for for loops), the
fall through of a label to a goto that jumps back to right before that fall
through just to exit the game (isn’t that so cute?), the fact I had to write all
those tools to verify things are okay (showing how messed up it is), different
blocks that have code that simply should not be there, the nested ternary
operators…</p>
<p>As for the <code>goto</code>s: yes I technically had more space. But it became almost
impossible to add more spaghetti to the pot without it overflowing, and I didn’t
want to waste perfectly good spaghetti. There comes a point when there’s just so
much spaghetti that it’s wasted, if it can even be cooked. I believe I have
reached the latter.</p>
<p>Do you REALLY expect me to add more spaghetti? There isn’t anything that could
be done, even if it was possible to maintain this huge platter of delicious
spaghetti without gaining fifty kilograms. Besides, I don’t want to see
spaghetti EVER AGAIN!! I’ve had enough of it for a lifetime! Okay, that’s not
really true…it DOES sound good but I won’t likely be having it for a while.
Can you actually blame me though? This spaghetti almost strangled me to death,
like it did the Devil (I provided photographic proof of this earlier if you
missed that).</p>
much spaghetti that it’s wasted, if it can even be cooked. I believed I reached
the latter. But of course that was a practical choice - and not my complete
version. It was just easier to test as I had another version to contend to.</p>
<p>But let’s say I had more space with iocccsize: do you REALLY expect me to add
more spaghetti? There isn’t anything that could be done, even if it was possible
to maintain this huge platter of delicious spaghetti without gaining fifty
kilograms. Besides, I don’t want to see spaghetti EVER AGAIN!! I’ve had enough
of it for a lifetime! Okay, that’s not really true…it DOES sound good but I
won’t likely be having it for a while. Can you actually blame me though? This
spaghetti almost strangled me to death, like it did the Devil (I provided
photographic proof of this earlier if you missed that). Still…now that things
have settled a bit, I rather desire very much a platter of spaghetti.</p>
<p>I have already demonstrated several other subtle and unique things but the
<code>goto</code>s are what really makes it hard to parse; the other things are REALLY cool
(unlike the spaghetti, at least hopefully) and interesting, and unique (or so I