Merge pull request #835 from xexyl/fix-fixes

Fixes in thanks-for-fixes.md file
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-06-10 20:02:25 -07:00
commit d616ab8211
4 files changed
+272 -297

No files matched your search

+2 -2
View File
@@ -14,7 +14,7 @@ make all
and then type a C program into followed by EOF (usually `^D`, ctrl-d). and then type a C program into followed by EOF (usually `^D`, ctrl-d).
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made a version (also [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made a version (also
one line) for clang. See the alternative code section below for how to use. one line) for clang. See the Alternate code section below for how to use.
Thank you Cody for your assistance! Thank you Cody for your assistance!
## Try: ## Try:
@@ -41,7 +41,7 @@ int main()
NOTE: you need to make clobber first for this entry to work right. NOTE: you need to make clobber first for this entry to work right.
## Alternative code: ## Alternate code:
For clang try the alt code like: For clang try the alt code like:
+14 -4
View File
@@ -14,10 +14,8 @@ U.S.A.
make all make all
``` ```
Misha Dynin provided a fix for [westley.c](westley.c) so that it may compile on NOTE: this version is a fixed version for modern C compilers. The Alternate
both K&R and more modern C compilers. Thank you Misha! The original code, used code below is the original.
for entertainment and educational value, is in [westley.alt.c](westley.alt.c),
described below.
## Try: ## Try:
@@ -25,6 +23,18 @@ described below.
./westley ./westley
``` ```
### Alternate code:
The alternate code in [westley.alt.c](westley.alt.c) is the original version
submitted to the contest. If you have an old enough compiler you can run it
like:
```sh
make alt
```
Use `westley.alt` as you would `westley` above.
## Judges' remarks: ## Judges' remarks:
Your compiler must parse Your compiler must parse
+8 -11
View File
@@ -62,15 +62,14 @@ You'll get errors yes but what does the generated file look like? What about
other types of files? other types of files?
### Alternative code: ### Alternate code:
The alternate code allows this entry to work successfully even with clang. [Cody
The alternative code allows this entry to work successfully Boone Ferguson](/winners.html#Cody_Boone_Ferguson) notes that unfortunately it's
even with clang. He notes that unfortunately it's something of a hack or maybe something of a hack or maybe even a kludge. This however seems important because
even a kludge. This however seems important because it works well and allows for it works well and allows for not messing with the `s` string which is quite
not messing with the `s` string which is quite complicated. complicated. Even changing the length could break functionality and indeed the
Even changing the length could break functionality and indeed the length would length would have to be longer for this to work with clang.
have to be longer for this to work with clang.
How does it work? The code (which you will see in [dds.c](dds.c)) does a `return How does it work? The code (which you will see in [dds.c](dds.c)) does a `return
system(q-6);` which equates to `return system("cc a.c");` but clang by default, system(q-6);` which equates to `return system("cc a.c");` but clang by default,
@@ -81,7 +80,7 @@ that the compilation failed with clang (because it didn't use `make` so no
and the use of functions not yet declared. and the use of functions not yet declared.
Now as noted since the string `s` is complicated and to not Now as noted since the string `s` is complicated and to not
inadvertently mess something up he changed that code to `system("make a");` inadvertently mess something up Cody changed that code to `system("make a");`
and then added the right rule to the Makefile. Thus for the alternative version and then added the right rule to the Makefile. Thus for the alternative version
you now need both `make` and `cc`. If you use gcc you may change the system() you now need both `make` and `cc`. If you use gcc you may change the system()
call to what was given in this description to get a more authentic feel. If you call to what was given in this description to get a more authentic feel. If you
@@ -94,10 +93,8 @@ make clobber alt
./a 2>/dev/null ./a 2>/dev/null
``` ```
## Judges' remarks: ## Judges' remarks:
Notice that a file `a.c` has been generated. Can you tell how `a.c` was Notice that a file `a.c` has been generated. Can you tell how `a.c` was
produced? How does `a.c` relate to [LANDER.BAS](LANDER.BAS)? produced? How does `a.c` relate to [LANDER.BAS](LANDER.BAS)?
+248 -280
View File
@@ -9,12 +9,13 @@ There are several people who have contributed to the above mentioned
several thousand changes and important improvements. several thousand changes and important improvements.
We call out the extensive contributions of [Cody Boone We call out the extensive contributions of [Cody Boone
Ferguson](/winners.html#Cody_Boone_Ferguson) who is responsible for Ferguson](/winners.html#Cody_Boone_Ferguson) who is responsible for many of the
many of the improvements including many, many complicated bug fixes like improvements including many, many complicated bug fixes like
[2001/anonymous](2001/anonymous/anonymous.c), making entries not require [2001/anonymous](2001/anonymous/anonymous.c), making entries not require
`-traditional-cpp`, typo and consistency `-traditional-cpp`, fixing entries to compile with clang, providing alternate
fixes. Thank you **very much** for the extensive efforts in helping code where useful or necessary, typo and consistency fixes. Thank you **very
improve the IOCCC presentation of past IOCCC winners! much** for the extensive efforts in helping improve the IOCCC presentation of
past IOCCC winners!
[Yusuke Endoh](/winners.html#Yusuke_Endoh) supplied a number of [Yusuke Endoh](/winners.html#Yusuke_Endoh) supplied a number of
important bug fixes to a number of past IOCCC winners. Some of important bug fixes to a number of past IOCCC winners. Some of
@@ -42,12 +43,11 @@ on a winner by winner basis.
## [1984/decot](1984/decot/decot.c) ([README.md](1984/decot/README.md])) ## [1984/decot](1984/decot/decot.c) ([README.md](1984/decot/README.md]))
Cody fixed this to not Cody fixed this to not require `-traditional-cpp` which not all compilers
require `-traditional-cpp` which not all compilers support (clang does not support (clang does not support it for example). Clang is also more strict about
support it for example). Clang is also more strict about the args' types in the args' types in `main()` and this was also a problem that Cody fixed, making
`main()` and this was also a problem that Cody fixed, making it work with both it work with both clang and gcc. For the original code with the gcc fix
clang and gcc. For the original code with the gcc fix described below, see the described below, see the alternate code section in the README.md file.
alternate code section below.
Originally Yusuke supplied a patch so that this entry would compile with gcc - Originally Yusuke supplied a patch so that this entry would compile with gcc -
but not clang - or at least some versions. but not clang - or at least some versions.
@@ -55,18 +55,16 @@ but not clang - or at least some versions.
## [1984/mullender](1984/mullender/mullender.c) ([README.md](1984/mullender/README.md])) ## [1984/mullender](1984/mullender/mullender.c) ([README.md](1984/mullender/README.md]))
Cody provided an alternate Cody provided an alternate version which was an improved version from the judges
version which was an improved version from the judges so that everyone can enjoy so that everyone can enjoy it in systems that are not VAX/PDP. We also refer you
it in systems that are not VAX/PDP. We also refer you to the [faq](faq.md) as to the [faq](faq.md) as there are some winning entries that also let one enjoy
there are some winning entries that also let one enjoy it - with more to them of it - with more to them of course!
course!
## [1985/applin](1985/applin/applin.c) ([README.md](1985/applin/README.md])) ## [1985/applin](1985/applin/applin.c) ([README.md](1985/applin/README.md]))
Yusuke provided a patch to get this to Yusuke provided a patch to get this to not issue crash and Cody fixed this to
not issue crash and Cody work with macOS (it printed the string `H????` in a seemingly infinite loop of
fixed this to work with macOS (it printed the string `H????` in a seemingly printing more and more `?`s).
infinite loop of printing more and more `?`s).
The problem with the crash is that it destructively rewrites string literals but The problem with the crash is that it destructively rewrites string literals but
with `strdup()` it's safe. with `strdup()` it's safe.
@@ -85,78 +83,77 @@ shell.
## [1985/lycklama](1985/lycklama/lycklama.c) ([README.md](1985/lycklama/README.md])) ## [1985/lycklama](1985/lycklama/lycklama.c) ([README.md](1985/lycklama/README.md]))
Cody fixed this to compile Cody fixed this to compile with modern compilers. In the past one could get away
with modern compilers. In the past one could get away with defining some macro with defining some macro to `#define` and then use `#foo` to have the same
to `#define` and then use `#foo` to have the same effect as using `#define` but effect as using `#define` but this does not work in modern systems so Cody
this does not work in modern systems so Cody changed the `#o` lines to changed the `#o` lines to `#define`. The
`#define`. The `lycklama.alt.c` is the original source code as it provides some [lycklama.alt.c](1985/lycklama/lycklama.alt.c) is the original source
fun input for the entry. code as it provides some fun input for the entry.
Yusuke provided some useful information that Yusuke provided some useful information that amounts to an alternate version but
amounts to an alternate version but which does not actually modify the code. which does not actually modify the code except by a provided macro for a
Perhaps it should be an alternate version but in any case see the README.md file `usleep()` call which Cody added. See the README.md file details.
for details.
## [1985/sicherman](1985/sicherman/sicherman.c) ([README.md](1985/sicherman/README.md])) ## [1985/sicherman](1985/sicherman/sicherman.c) ([README.md](1985/sicherman/README.md]))
Cody fixed this _very twisted Cody fixed this _very twisted entry_ to not require `-traditional-cpp`. He'd
entry_ to not require `-traditional-cpp`. He'd like to refer you to the original like to refer you to the original file in
file in [sicherman.alt.c](1985/sicherman.alt.c) and he suggests that you then compare [sicherman.alt.c](1985/sicherman.alt.c) and he suggests that you then compare it
it to [sicherman.c](1985/sicherman/sicherman.c) for some good old C-fashioned fun! to [sicherman.c](1985/sicherman/sicherman.c) for some good old C-fashioned fun!
## [1986/holloway](1986/holloway/holloway.c) ([README.md](1986/holloway/README.md])) ## [1986/holloway](1986/holloway/holloway.c) ([README.md](1986/holloway/README.md]))
Cody fixed this to Cody fixed this to compile and work with clang (it already worked with gcc).
compile and work with clang (it already worked with gcc). The problem was that The problem was that clang is more strict about the type of second arg to
clang is more strict about the type of second arg to main(). However simply main(). However simply changing it to a `char **` and updating the `*s` to `**s`
changing it to a `char **` and updating the `*s` to `**s` caused a segfault. By caused a segfault. By adding a new variable, `char *t`, initialising it to `s`
adding a new variable, `char *t`, initialising it to `s` and then using `t` and then using `t` instead of `s` it compiles and runs successfully under clang
instead of `s` it compiles and runs successfully under clang and gcc. and gcc.
## [1986/marshall](1986/marshall/marshall.c) ([README.md](1986/marshall/README.md])) ## [1986/marshall](1986/marshall/marshall.c) ([README.md](1986/marshall/README.md]))
Cody got this to Cody got this to compile and work with clang. It did not work with clang because
compile and work with clang. It did not work with clang because it is more it is more strict about the second and third args to `main()` and the third arg
strict about the second and third args to main() and the third arg was an int. was an `int`. He notes that he tried to keep the ASCII art as close to the
He notes that he tried to keep the picture as close to the original. The line original as possible. The line lengths are the same but some spaces had to be
lengths are the same but some spaces had to be changed to non-spaces. changed to non-spaces.
## [1986/wall](1986/wall/wall.c) ([README.md](1986/wall/README.md])) ## [1986/wall](1986/wall/wall.c) ([README.md](1986/wall/README.md]))
We used a patch provided by Yusuke to make We used a patch provided by Yusuke to make this work with gcc (in particular the
this work with gcc (in particular the patch uses `strdup()` on two strings). patch uses `strdup()` on two strings).
Cody fixed this so that it does not require `-traditional-cpp`. This took a fair Cody fixed this so that it does not require `-traditional-cpp`. This took a fair
bit of tinkering as this entry *is* strange. The original code is provided to bit of tinkering as this entry *is* strange. The original code is provided to
allow one to easily see how different C was in those days. See below for allow one to easily see how different C was in those days. See the README.md
details. Thank you Cody for your assistance! file for details.
## [1987/wall](1987/wall/wall.c) ([README.md](1987/wall/README.md])) ## [1987/wall](1987/wall/wall.c) ([README.md](1987/wall/README.md]))
Cody made this safer by Cody made this safer by using `fgets()` instead of `gets()`. This prevents an
using `fgets()` instead of `gets()`. This prevents an annoying and potentially annoying and potentially alarming warning at compiling, linking or runtime.
alarming warning at compiling, linking or runtime. Though this could be partly remedied through redirecting `stderr` to `/dev/null`
this would not truly resolve the problem either.
## [1987/westley](1987/westley/westley.c) ([README.md](1987/westley/README.md])) ## [1987/westley](1987/westley/westley.c) ([README.md](1987/westley/README.md]))
Cody fixed this for modern Cody fixed this for modern systems. The problem was `'assignment to cast is
systems. The problem was 'assignment to cast is illegal, lvalue casts are not illegal, lvalue casts are not supported'`. For the original file see the
supported'. For the original file see below. README.md file.
## [1988/dale](1988/dale/dale.c) ([README.md](1988/dale/README.md])) ## [1988/dale](1988/dale/dale.c) ([README.md](1988/dale/README.md]))
Cody fixed this for modern Cody fixed this for modern compilers. There were two problems to address. One
compilers. There were two problems to address. One was that the entry required was that the entry required `-traditional-cpp` (which <strike>not all compilers
`-traditional-cpp` (which <strike>not all compilers support</strike> `clang` support</strike> `clang` does not support) which Cody fixed. It needed that
does not support) which Cody fixed. It needed that option because of two things option because of two things it did:
it did:
```c ```c
#define a(x)get/***/x/***/id()) #define a(x)get/***/x/***/id())
@@ -198,41 +195,46 @@ so Cody changed the lines to be in the form of:
## [1988/isaak](1988/isaak/isaak.c) ([README.md](1988/isaak/README.md])) ## [1988/isaak](1988/isaak/isaak.c) ([README.md](1988/isaak/README.md]))
Cody fixed this to work for Cody fixed this to work for modern systems. The problem was that the important
modern systems. The problem was that the important function, a redefinition of function, a redefinition of exit(), was not being called in main(). See below
exit(), was not being called in main(). See below notes for the original, notes for the original, alternative version.
alternative version.
The original version is in [1988/isaak/isaak.alt.c](1988/isaak/isaak.alt.c). The original version is in [1988/isaak/isaak.alt.c](1988/isaak/isaak.alt.c).
## [1988/phillipps](1988/phillipps/phillipps.c) ([README.md](1988/phillipps/README.md])) ## [1988/phillipps](1988/phillipps/phillipps.c) ([README.md](1988/phillipps/README.md]))
Cody fixed this for modern Cody fixed this for modern systems. It did not compile with clang because it
systems. It did not compile with clang because it requires the second and third requires the second and third args to main() to be `char **` but even before
args to main() to be `char **` but even before that with gcc it printed random that with gcc it printed random characters. After fixing it for clang by
characters. After fixing it for clang by changing main() to call the new changing main() to call the new function pain() (chosen because it's a pain that
function pain() (chosen because it's a pain that clang requires these args to clang requires these args to be `char **` :-) ) with the correct args it now
be `char **` :-) ) with the correct args it now works. works.
## [1988/spinellis](1988/spinellis/spinellis.c) ([README.md](1988/spinellis/README.md])) ## [1988/spinellis](1988/spinellis/spinellis.c) ([README.md](1988/spinellis/README.md]))
An alternate version was provided by Cody for this so that it works for An [alternate version](1988/spinellis/spinellis.alt.c) was provided by Cody for
compilers like clang. this so that it works for compilers like clang. See the README.md files for
details.
## [1988/westley](1988/westley/westley.c) ([README.md](1988/westley/README.md]))
The [original version](1988/westley/westley.c), provided as an alternate code,
was fixed by Misha Dynin, based on the judges' remarks so that this would work
with modern C compilers.
## [1989/fubar](1989/fubar/fubar.c) ([README.md](1989/fubar/README.md])) ## [1989/fubar](1989/fubar/fubar.c) ([README.md](1989/fubar/README.md]))
Cody got this to work with Cody got this to work with modern systems. The `main()` issues were an
modern systems. The main issues were an `#include` had to be added and fixing the `#include` had to be added and fixing the path to files referred to in the code
path to files referred to in the code was also needed. was also needed.
## [1989/jar.2](1989/jar.2/jar.2.c) ([README.md](1989/jar.2/README.md])) ## [1989/jar.2](1989/jar.2/jar.2.c) ([README.md](1989/jar.2/README.md]))
Cody fixed this to work with Cody fixed this to work with modern compilers. Modern compilers do not allow
modern compilers. Modern compilers do not allow code like: code like:
```c ```c
#define D define #define D define
@@ -247,16 +249,15 @@ you know how?
## [1989/ovdluhe](1989/ovdluhe/ovdluhe.c) ([README.md](1989/ovdluhe/README.md])) ## [1989/ovdluhe](1989/ovdluhe/ovdluhe.c) ([README.md](1989/ovdluhe/README.md]))
Cody provided an alternate version based on the author's remarks. See the Cody provided an [alternate version](1989/ovdluhe/ovdluhe.alt.c) based on the
README.md for details. author's remarks. See the README.md for details.
## [1989/paul](1989/paul/paul.c) ([README.md](1989/paul/README.md])) ## [1989/paul](1989/paul/paul.c) ([README.md](1989/paul/README.md]))
Cody fixed a segfault under Cody fixed a segfault under macOS. The problem was that the int (from `#define
macOS. The problem was that the int (from `#define f`) should be a long. This f`) should be a long. This became apparent when he was using lldb and saw that
became apparent when he was using lldb and saw that the type of a pointer was the type of a pointer was long.
long.
## [1989/robison](1989/robison/robison.c) ([README.md](1989/robison/README.md])) ## [1989/robison](1989/robison/robison.c) ([README.md](1989/robison/README.md]))
@@ -288,8 +289,8 @@ decided later.
## [1990/baruch](1990/baruch/baruch.c) ([README.md](1990/baruch/README.md])) ## [1990/baruch](1990/baruch/baruch.c) ([README.md](1990/baruch/README.md]))
Cody added an alternate version which allows certain compilers to compile the Cody added an [alternate version](1990/baruch/baruch.alt.c) which allows certain
code, based on the author's remarks. compilers to compile the code, based on the author's remarks.
## [1990/cmills](1990/cmills/cmills.c) ([README.md](1990/cmills/README.md])) ## [1990/cmills](1990/cmills/cmills.c) ([README.md](1990/cmills/README.md]))
@@ -305,8 +306,7 @@ For the original code see the [1992 archive](/archive/archive-1990.tar.bz2).
## [1990/dds](1990/dds/dds.c) ([README.md](1990/dds/README.md])) ## [1990/dds](1990/dds/dds.c) ([README.md](1990/dds/README.md]))
Yusuke fixed this for modern systems. Thank Yusuke fixed this for modern systems.
you Yusuke!
Cody removed the erroneous prototype to `fopen()` and made this use `fgets()` Cody removed the erroneous prototype to `fopen()` and made this use `fgets()`
instead of `gets()` to make it safer and to prevent an annoying and potentially instead of `gets()` to make it safer and to prevent an annoying and potentially
@@ -315,8 +315,8 @@ alarming warning at compiling and/or linking and/or runtime.
## [1990/jaw](1990/jaw/jaw.c) ([README.md](1990/jaw/README.md])) ## [1990/jaw](1990/jaw/jaw.c) ([README.md](1990/jaw/README.md]))
Cody fixed the script to work properly in modern environments (to do with PATH Cody fixed the script to work properly in modern environments (to do with `$PATH`
not having '.' in it). He notes that with an invocation in the try section will not having `.` in it). He notes that with an invocation in the try section will
with macOS show what appears to be an error message but is actually okay. He with macOS show what appears to be an error message but is actually okay. He
gives more information in the [bugs.md](/bugs.md) file. gives more information in the [bugs.md](/bugs.md) file.
@@ -336,31 +336,29 @@ program's output.
## [1990/theorem](1990/theorem/theorem.c) ([README.md](1990/theorem/README.md])) ## [1990/theorem](1990/theorem/theorem.c) ([README.md](1990/theorem/README.md]))
Cody fixed some bugs that Cody fixed some bugs that impacted the usability of this program including some
impacted the usability of this program including some segfaults under modern segfaults under modern systems (and possibly in some cases earlier systems) with
systems (and possibly in some cases earlier systems) with this entry. this entry. Originally we noted that the 4 trailing args '0 0 0 0' were
Originally we noted that the 4 trailing args '0 0 0 0' were required on systems required on systems that dump core when NULL is dereferenced but this problem
that dump core when NULL is dereferenced but this problem showed itself in showed itself in modern systems even with the 4 '0 0 0 0'. He also fixed a
modern systems even with the 4 '0 0 0 0'. He also fixed a segfault if not enough segfault if not enough args are specified and fixed the code so that the
args are specified and fixed the code so that the generated `fibonacci.c` generated `fibonacci.c` actually works; before it just printed `0` over and over
actually works; before it just printed `0` over and over again (since it did not again (since it did not work anyway a segfault prevention was added here). He
work anyway a segfault prevention was added here). He also fixed some array also fixed some array addressing (some of which might not be strictly necessary
addressing (some of which might not be strictly necessary but as he was testing but as he was testing the `fibonacci.c` bug he ended up changing it anyway).
the `fibonacci.c` bug he ended up changing it anyway). Finally he changed this Finally he changed this program to use `fgets()` not `gets()` to make it safer
program to use `fgets()` not `gets()` to make it safer and to prevent a warning and to prevent a warning about `gets()` at linking or runtime.
about `gets()` at linking or runtime.
Yusuke pointed out that `atof` nowadays Yusuke pointed out that `atof` nowadays needs `#include <stdlib.h>` which was
needs `#include <stdlib.h>` which was used in order to get this to work used in order to get this to work initially (prior to this output was there but
initially (prior to this the output was incomplete). incomplete).
## [1990/westley](1990/westley/westley.c) ([README.md](1990/westley/README.md])) ## [1990/westley](1990/westley/westley.c) ([README.md](1990/westley/README.md]))
Cody fixed this for modern Cody fixed this for modern systems. It had `1s` in places for a short int which
systems. It had `1s` in places for a short int which was changed to just `1`. was changed to just `1`. Since it's instructional to see the differences he has
Since it's instructional to see the differences he has provided an alternate provided an alternate version with the original code. See below.
version with the original code. See below.
Cody provided the original source in [westley.alt.c](1990/westley/westley.alt.c). Cody provided the original source in [westley.alt.c](1990/westley/westley.alt.c).
@@ -368,74 +366,70 @@ Cody provided the original source in [westley.alt.c](1990/westley/westley.alt.c)
## [1991/brnstnd](1991/brnstnd/brnstnd.c) ([README.md](1991/brnstnd/README.md])) ## [1991/brnstnd](1991/brnstnd/brnstnd.c) ([README.md](1991/brnstnd/README.md]))
Cody fixed this for modern Cody fixed this for modern systems. There were two invalid operands to binary
systems. There were two invalid operands to binary expression (`char *` and expression (`char *` and `void` and `int` and `void`) to resolve and
`void` and `int` and `void`) to resolve and additionally a mis-feature of the C additionally a mis-feature of the C pre-processor which no longer works had to
pre-processor which no longer works had to be changed as well in order to get be changed as well in order to get this to compile. In particular the macro `C`,
this to compile. In particular the macro `C`, defined as `C =G` to make `+=` and defined as `C =G` to make `+=` and similar operators no longer works. The
similar operators no longer works. The invalid operands to binary expressions invalid operands to binary expressions were resolved with the comma operator.
were resolved with the comma operator.
## [1991/dds](1991/dds/dds.c) ([README.md](1991/dds/README.md])) ## [1991/dds](1991/dds/dds.c) ([README.md](1991/dds/README.md]))
Cody fixed a segfault that Cody fixed a segfault that prevented this entry from working at all and made an
prevented this entry from working at all and made an alternate version [alternate version](1991/dds/dds.alt.c) that works with `clang`. The alternate
that works with `clang`. The alternate code, described below, is what is needed code, described in the README.md file, is what is needed for clang. Reading it
for clang. Reading it might be instructive even if you have gcc. might be instructive even if you have gcc.
## [1991/westley](1991/westley/westley.c) ([README.md](1991/westley/README.md])) ## [1991/westley](1991/westley/westley.c) ([README.md](1991/westley/README.md]))
Cody fixed a segfault in Cody fixed a segfault in this program which prevented it from working. The
this program which prevented it from working. The problem was that the read-only problem was that the read-only char array `char *z[]` was being written to. The
char array `char *z[]` was being written to. The fix was to change it to `char fix was to change it to `char z[][100]` in two spots (see if you can determine
z[][100]` in two spots (see if you can determine why two places, not one!). Why why two places, not one!). Why 100 when the longest string is < 100? Because a
100 when the longest string is < 100? Because a shorter value caused strange shorter value caused strange output and it's easier to just choose a larger
output and it's easier to just choose a larger value that works without having value that works without having to find the correct value.
to find the correct value.
## [1992/adrian](1992/adrian/adrian.c) ([README.md](1992/adrian/README.md])) ## [1992/adrian](1992/adrian/adrian.c) ([README.md](1992/adrian/README.md]))
Cody changed the location Cody changed the location that it used `gets()` to be `fgets()` instead to make
that it used `gets()` to be `fgets()` instead to make it safer and to prevent it safer and to prevent annoying warnings during compiling, linking or runtime
annoying warnings during compiling, linking or runtime (interspersed with the (interspersed with the program's output). One might think that simply changing
program's output). One might think that simply changing the gets() to fgets() the gets() to fgets() (with stdin) would work but it did not because `fgets()`
(with stdin) would work but it did not because `fgets()` stores the newline and stores the newline and `gets()` does not. The code was relying on not having
`gets()` does not. The code was relying on not having this newline. With this newline. With `fgets()` the code `if(A(Y)) puts(Y);` ended up printing an
`fgets()` the code `if(A(Y)) puts(Y);` ended up printing an extra line which extra line which made the generation of some files (like `adhead.c`) fail to
made the generation of some files (like `adhead.c`) fail to compile (`gets()` compile. Why? There was a blank line after a `\` at the end of the first line of
does not store the newline but `fgets()` does). Why? There was a blank line a macro definition! Thus the code now first trims off the last character of the
after a `\` at the end of the first line of a macro definition! Thus the code buffer read to get the same correct functionality but in a safe way and
now first trims off the last character of the buffer read to get the same non obnoxious way.
correct functionality but in a safe way.
## [1992/gson](1992/gson/gson.c) ([README.md](1992/gson/README.md])) ## [1992/gson](1992/gson/gson.c) ([README.md](1992/gson/README.md]))
Cody changed the buffer size Cody changed the buffer size in such a way that `gets()` should be safe
in such a way that gets() should be safe (theoretically) as it comes from the (theoretically) as it comes from the command line (though it can also read input
command line (though it can also read input from stdin after starting the from stdin after starting the program). Ideally `fgets()` would be used but this
program). Ideally `fgets()` would be used but this is a more problematic. is a more problematic. Previously it had a buffer size of 256 which could
Previously it had a buffer size of 256 which could easily overflow. In this easily overflow. In this entry `gets()` is used in a more complicated way:
entry `gets()` is used in a more complicated way: first `m` is set to `*++p` in first `m` is set to `*++p` in a for loop where `p` is argv. Later `m` is set to
a for loop where `p` is argv. Later `m` is set to point to `h` which was of size point to `h` which was of size \256. `gets()` is called as `m = gets(m)`) but
\256. `gets()` is called as `m = gets(m)`) but trying to change it to use trying to change it to use `fgets()` proved more a problem. Since the input must
fgets() proved more a problem. Since the input must come from the command line come from the command line Cody changed the buffer size to `ARG_MAX+1` which
Cody changed the buffer size to `ARG_MAX+1` which should be enough (again should be enough (again theoretically) especially since the command expects
theoretically) especially since the command expects redirecting a dictionary redirecting a dictionary file as part of the command line. This also makes it
file as part of the command line. This also makes it possible for longer strings possible for longer strings to be read (in case the `gets()` was not used in a
to be read (in case the `gets()` was not used in a loop). loop).
## [1992/kivinen](1992/kivinen/kivinen.c) ([README.md](1992/kivinen/README.md])) ## [1992/kivinen](1992/kivinen/kivinen.c) ([README.md](1992/kivinen/README.md]))
It was observed that on modern systems this goes much too quick. [Yusuke It was observed that on modern systems this goes much too quick. [Yusuke
Endoh](/winners.html#Yusuke_Endoh) created a patch that calls `usleep()` but Endoh](/winners.html#Yusuke_Endoh) created a patch that calls `usleep()` but
Cody thought the value was Cody thought the value was too slow so he made it a macro in the Makefile `Z`,
too slow so he made it a macro in the Makefile `Z`, defaulting at 15000. You can defaulting at 15000. You can reconfigure it like:
reconfigure it like:
```sh ```sh
make clobber Z=1000 all make clobber Z=1000 all
@@ -447,31 +441,27 @@ it moves towards the right but if you click the mouse it goes back.
## [1992/lush](1992/lush/lush.c) ([README.md](1992/lush/README.md])) ## [1992/lush](1992/lush/lush.c) ([README.md](1992/lush/README.md]))
Yusuke supplied a patch which makes this Yusuke supplied a patch which makes this work with gcc. Due to how it works (see
work with gcc. Due to how it works (see Judges' remarks below) this will not Judges' remarks in the README.md file) this will not work with clang.
work with clang.
Cody made it use `fgets()` Cody made it use `fgets()` instead of `gets()` to prevent annoying warnings
instead of `gets()` to prevent annoying warnings getting in the way and also getting in the way and also added the `runme.sh` script to demonstrate it (using
added the `runme.sh` script to demonstrate it (using make was problematic). Cody make was problematic). Cody notes that unfortunately this does not work with
notes that unfortunately this does not work with clang due to different compiler clang due to different compiler messages.
messages.
## [1992/westley](1992/westley/westley.c) ([README.md](1992/westley/README.md])) ## [1992/westley](1992/westley/westley.c) ([README.md](1992/westley/README.md]))
Cody fixed this for clang by Cody fixed this for clang by changing the third and fourth arg of `main()` to be
changing the third and fourth arg of main() to be ints inside main(); clang ints inside `main()`; clang requires args 2 - 4 to be `char **`. He also fixed
requires args 2 - 4 to be `char **`. He also fixed it so that the program would it so that the program would not segfault if not enough args were specified. He
not segfault if not enough args were specified. He did the same for the did the same for the alternative version (see below) provided by the author (the
alternative version (see below) provided by the author (the original can be seen original can be seen in the author's remarks below).
in the author's remarks below).
## [1993/jonth](1993/jonth/jonth.c) ([README.md](1993/jonth/README.md])) ## [1993/jonth](1993/jonth/jonth.c) ([README.md](1993/jonth/README.md]))
Both Cody and [Yusuke Both Cody and [Yusuke Endoh](/winners.html#Yusuke_Endoh) fixed this so that it
Endoh](/winners.html#Yusuke_Endoh) fixed this so that it
will work with modern systems. Yusuke provided some fixes of the X code and Cody will work with modern systems. Yusuke provided some fixes of the X code and Cody
fixed the C pre-processor directives so that it would compile. It used to be fixed the C pre-processor directives so that it would compile. It used to be
that you could get away with code like: that you could get away with code like:
@@ -493,131 +483,111 @@ Cody fixed this to work with modern compilers.
## [1993/lmfjyh](1993/lmfjyh/lmfjyh.c) ([README.md](1993/lmfjyh/README.md])) ## [1993/lmfjyh](1993/lmfjyh/lmfjyh.c) ([README.md](1993/lmfjyh/README.md]))
Cody added an alternate Cody added an [alternate version](1993/lmfjyh/lmfjyh.alt.c) which does what the
version which does what the program did with gcc < 2.3.3. program did with gcc < 2.3.3. See the README.md file for details.
## [1993/plummer](1993/plummer/plummer.c) ([README.md](1993/plummer/README.md])) ## [1993/plummer](1993/plummer/plummer.c) ([README.md](1993/plummer/README.md]))
Cody added an alternate Cody added an [alternate version](1993/plummer/plummer.alt.c) which uses
version which uses `usleep()` so you can see what is happening with faster `usleep()` so you can see what is happening with faster systems. See the
systems. README.md files for details.
## [1993/rince](1993/rince/rince.c) ([README.md](1993/rince/README.md])) ## [1993/rince](1993/rince/rince.c) ([README.md](1993/rince/README.md]))
Yusuke supplied a patch to get this to work Yusuke supplied a patch to get this to work in modern systems.
in modern systems.
## [1993/schnitzi](1993/schnitzi/schnitzi.c) ([README.md](1993/schnitzi/README.md])) ## [1993/schnitzi](1993/schnitzi/schnitzi.c) ([README.md](1993/schnitzi/README.md]))
Cody made this use `fgets()` Cody made this use `fgets()` not `gets()` to make it safer and to prevent an
not `gets()` to make it safer and to prevent an annoying warning with compiling annoying warning with compiling and/or linking and/or runtime, the latter of
and/or linking and/or runtime, the latter of which is interspersed with the which is interspersed with the output of the program itself.
output of the program itself.
## [1993/vanb](1993/vanb/vanb.c) ([README.md](1993/vanb/README.md])) ## [1993/vanb](1993/vanb/vanb.c) ([README.md](1993/vanb/README.md]))
Cody fixed this to work with Cody fixed this to work with clang. The problem was that the third arg to main()
clang. The problem was that the third arg to main() was not a `char **`. Instead was not a `char **`. Instead `O5()` (which was `main()`) is now its own function
`O5()` (which was `main()`) is now its own function which main() calls with the which main() calls with the right parameters.
right parameters.
## [1994/ldb](1994/ldb/ldb.c) ([README.md](1994/ldb/README.md])) ## [1994/ldb](1994/ldb/ldb.c) ([README.md](1994/ldb/README.md]))
Cody fixed this so it would Cody fixed this so it would compile and work with modern compilers. The problem
compile and work with modern compilers. The problem was that `srand()` returns was that `srand()` returns void but it was used in a `||` expression. Thus the
void but it was used in a `||` expression. Thus the comma operator was needed. comma operator was needed. Cody also changed the entry to use `fgets()` instead
Cody also changed the entry to use `fgets()` instead of `gets()` to make it safe of `gets()` to make it safe for lines greater than 231 in length and to prevent
for lines greater than 231 in length and to prevent a warning at linking or at a warning at linking or at runtime, the latter of which can be interspersed with
runtime, the latter of which can be interspersed with output of the program. output of the program. Note that this now prints a newline after the output but
Note that this now prints a newline after the output but this seems like a this seems like a worthy compromise for making it safer (fixing it is more
worthy compromise for making it safer (fixing it is more problematic than it is problematic than it is worth). In macOS another line of output would be shown
worth). In macOS another line of output would be shown anyway namely the warning anyway namely the warning that it uses gets(). A subtlety about this fix: if a
that it uses gets(). A subtlety about this fix: if a line is greater than 231 in line is greater than 231 in length if the program chooses that line it might
length if the program chooses that line it might print the first 231 characters print the first 231 characters or it might print (up to) the next 231 characters
or it might print (up to) the next 231 characters and so on. and so on.
your assistance!
## [1994/schnitzi](1994/schnitzi/schnitzi.c) ([README.md](1994/schnitzi/README.md]))
NOTE: the buffer size is very small at 100. It's easy to fix the buffer size but
it is not as easy to change it to `fgets()`. [Cody Boone
Ferguson](/winners.html#Cody_Boone_Ferguson) gives some hints in the
[bugs.md](/bugs.md) file on how this entry works which might be useful in order
to get this to use `fgets()` which would prevent a warning at linking or
runtime, the latter of which is interspersed with the output of the program. The
file [schnitzi.alt.c](schnitzi.alt.c) has this to get anyone started, should
they wish to tackle it (Cody might in time). The problem with changing the buffer
size is that even when it works the generated output (see judges' remarks below)
will not be 100% correct duplication of the program.
## [1994/shapiro](1994/shapiro/shapiro.c) ([README.md](1994/shapiro/README.md])) ## [1994/shapiro](1994/shapiro/shapiro.c) ([README.md](1994/shapiro/README.md]))
Cody fixed a bug on systems Cody fixed a bug on systems where `EOF != -1`. The problem is that `getc()` and
where `EOF != -1`. The problem is that `getc()` and the related functions do not the related functions do not return `-1` on EOF or error but rather `EOF`.
return `-1` on EOF or error but rather `EOF`. However `EOF` is not required to be However `EOF` is not required to be `-1` but merely an int < 0 and this program
`-1` but merely an int < 0 and this program assumed that `getc()` will return assumed that `getc()` will return `-1` on EOF or error, not `EOF`. On systems
`-1` on EOF or error, not `EOF`. On systems where `EOF != -1` it could result in where `EOF != -1` it could result in an infinite loop (for the same reason one
an infinite loop (for the same reason one should not use `EOF` for the `getopt()` should not use `EOF` for the `getopt()` functions as they return `-1` when all
functions as they return `-1` when all options are parsed (for details on the options are parsed (for details on the definition of `EOF` see `7.21
definition of `EOF` see `7.21 Input/output<stdio.h>` subsection 1 of the Input/output<stdio.h>` subsection 1 of the standard)). An interesting problem
standard)). An interesting problem occurred where changing the `-1` to `EOF` occurred where changing the `-1` to `EOF` caused both `warning: illegal
caused both `warning: illegal character encoding in string literal` and `error: character encoding in string literal` and `error: source file is not valid
source file is not valid UTF-8`. But since `EOF` is simply an int < 0 and making UTF-8`. But since `EOF` is simply an int < 0 and making the loop condition check
the loop condition check that the return value is >= 0 does not cause a that the return value is >= 0 does not cause a compilation error and it
compilation error and it functions correctly it will address the systems where functions correctly it will address the systems where `EOF != -1` just as if it
`EOF != -1` just as if it checked for `!= EOF`. checked for `!= EOF`.
## [1994/westley](1994/westley/westley.c) ([README.md](1994/westley/README.md])) ## [1994/westley](1994/westley/westley.c) ([README.md](1994/westley/README.md]))
Cody converted the spoiler Cody converted the spoiler compiler options (provided by the author) to be
compiler options to be compiler commands and added a script compiler commands and added a script [spoiler.sh](1994/westley/spoiler.sh) to
[spoiler.sh](spoiler.sh) to automate the spoiler commands provided by the author automate the spoiler commands to make it easier to see the game in action.
to make it easier to see the game in action.
## [1995/cdua](1995/cdua/cdua.c) ([README.md](1995/cdua/README.md])) ## [1995/cdua](1995/cdua/cdua.c) ([README.md](1995/cdua/README.md]))
Cody fixed this so that it Cody fixed this so that it would work with macOS. Once it could compile it
would work with macOS. Once it could compile it additionally segfaulted under additionally segfaulted under macOS which he also fixed. Cody also provided the
macOS which he also fixed. Cody also provided the Alternate code for fun :-) ). [Alternate code](1995/cdua/cdua.alt.c) for fun :-) ).
## [1995/garry](1995/garry/garry.c) ([README.md](1995/garry/README.md])) ## [1995/garry](1995/garry/garry.c) ([README.md](1995/garry/README.md]))
Cody fixed it Cody fixed it so that it will compile with modern compilers. The problem was a
so that it will compile with modern compilers. The problem was a missing `int` for missing `int` for the `f` variable. He felt it was important that it works
the `f` variable. He felt it was important that it works because the layout does because the layout does indeed look to him like a rat is dropping core, which
indeed look to him like a rat is dropping core. the judges suggested.
## [1996/august](1996/august/august.c) ([README.md](1996/august/README.md])) ## [1996/august](1996/august/august.c) ([README.md](1996/august/README.md]))
Cody fixed a segfault in Cody fixed a segfault in this program that prevented it from working right but
this program that prevented it from working right but he notes it hangs in he notes it hangs in macOS. It works fine in linux. This is because macOS has
macOS. It works fine in linux. This is because macOS has clang, not gcc, even clang, not gcc, even the gcc binary. He observed that with specific compiler
the gcc binary. He observed that with specific compiler flags it hangs in linux flags it hangs in linux too and perhaps it's related to this in macOS; maybe
too and perhaps it's related to this in macOS; maybe other flags are needed but other flags are needed but he doesn't know (at least not yet). He provided a bit
he doesn't know (at least not yet). He provided a bit more information in more information in [bugs.md](/bugs.md) for anyone who wants to have a go at
[bugs.md](/bugs.md) for anyone who wants to have a go at providing a fix for providing a fix for other compilers. As there are a lot of commands to try he
other compilers. As there are a lot of commands to try he also added also added [try.sh](1996/august/try.sh).
[try.sh](try.sh).
## [1996/dalbec](1996/dalbec/dalbec.c) ([README.md](1996/dalbec/README.md])) ## [1996/dalbec](1996/dalbec/dalbec.c) ([README.md](1996/dalbec/README.md]))
Cody proposed a fix for this Cody proposed a fix for this to compile with clang and Landon implemented it
to compile with clang and Landon implemented it after some discussion. The after some discussion. The reason Cody did not do it is because he thought it
reason Cody did not do it is because he thought it was the wrong output but as was the wrong output but as it happens the try section below was worded a bit
it happens the try section below was worded a bit confusingly. He looked at confusingly. He looked at [Yusuke Endoh's](/winners.html#Yusuke_Endoh) analysis
[Yusuke Endoh's](/winners.html#Yusuke_Endoh) analysis found found
[here](https://mame-github-io.translate.goog/ioccc-ja-spoilers/1996/dalbec.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp) [here](https://mame-github-io.translate.goog/ioccc-ja-spoilers/1996/dalbec.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp)
but he missed that Yusuke added a '...' after the result which made him think but he missed that Yusuke added a '...' after the result which made him think
the fix was wrong. Cody also made the recommended change of the author to make the fix was wrong. Cody also made the recommended change of the author to make
@@ -627,51 +597,49 @@ string of numbers on the same line.
## [1996/eldby](1996/eldby/eldby.c) ([README.md](1996/eldby/README.md])) ## [1996/eldby](1996/eldby/eldby.c) ([README.md](1996/eldby/README.md]))
Cody provided an alternate Cody provided an [alternate version](1996/eldby/eldby.alt.c) which uses
version which uses `usleep()` in between writing the output for those who are `usleep()` in between writing the output for those who are sensitive to text
sensitive to text flashing by rapidly (it affects him too but he also thinks it flashing by rapidly (it affects him too but he also thinks it moves too fast
moves too fast nowadays anyway). nowadays anyway).
## [1996/gandalf](1996/gandalf/gandalf.c) ([README.md](1996/gandalf/README.md])) ## [1996/gandalf](1996/gandalf/gandalf.c) ([README.md](1996/gandalf/README.md]))
Cody fixed this to compile Cody fixed this to compile and work with modern systems. As he loved the
and work with modern systems. As he loved the references in the code that could references in the code that could not compile he just commented out as little as
not compile he just commented out as little as possible to get this to compile. possible to get this to compile.
## [1996/westley](1996/westley/westley.c) ([README.md](1996/westley/README.md])) ## [1996/westley](1996/westley/westley.c) ([README.md](1996/westley/README.md]))
Cody fixed a segfault in Cody fixed a segfault in this entry as well as it displaying environmental
this entry as well as it displaying environmental variables. Although the variables. Although the scripts showed correct output, it somewhat lessened the
scripts showed correct output, it somewhat lessened the usability because they usability because they segfaulted and showed (an) environmental variable,
segfaulted and showed (an) environmental variable, interspersed with the output interspersed with the output of the program. With the fix they no longer have
of the program. With the fix they no longer have this problem. If `argc < 5` this problem. If `argc < 5` (`argv[4]` is referenced) it will not do anything
(`argv[4]` is referenced) it will not do anything and it will not segfault and it will not segfault either - this was caused by the body of the for() loop
either - this was caused by the body of the for() loop which is now empty (it which is now empty (it doesn't appear to be needed at all at least modernly).
doesn't appear to be needed at all at least modernly). Note that you should Note that you should check the [westley.alt.c](1996/westley/westley.alt.c) file
check the [westley.alt.c](westley.alt.c) file when reading the author's when reading the author's comments. To see how to use the original, see the
comments. To see how to use the original see below. README.md file.
## [1998/chaos](1998/chaos/chaos.c) ([README.md](1998/chaos/README.md])) ## [1998/chaos](1998/chaos/chaos.c) ([README.md](1998/chaos/README.md]))
Cody added a call to Cody added a call to `endwin()` to restore terminal sanity (echo etc.) when
`endwin()` to restore terminal sanity (echo etc.) when exiting the program. exiting the program.
## [1998/schnitzi](1998/schnitzi/schnitzi.c) ([README.md](1998/schnitzi/README.md])) ## [1998/schnitzi](1998/schnitzi/schnitzi.c) ([README.md](1998/schnitzi/README.md]))
Cody fixed invalid data Cody fixed invalid data types which prevented this entry from working, causing a
types which prevented this entry from working, causing a segfault. This showed segfault. This showed itself in two parts which required two fixes, one for
itself in two parts which required two fixes, one for linux and further changes linux and further changes for macOS. He also fixed a segfault (after printing
for macOS. He also fixed a segfault (after printing garbage) when the arg garbage) when the arg specified evaluated to 0.
specified evaluated to 0.
Cody made an Cody made an [alternate version](1998/schnitzi/schnitzi.alt.c) that works with
alternate version that works with macOS but there are some important notes as macOS but there are some important notes as well as a description of how it
well as a description of how it works (spoilers for the original version as works (spoilers for the original version as well), found in the README.md file.
well).
## [1998/schweikh1](1998/schweikh1/schweikh1.c) ([README.md](1998/schweikh1/README.md])) ## [1998/schweikh1](1998/schweikh1/schweikh1.c) ([README.md](1998/schweikh1/README.md]))