In all versions the program would segfault if the file could not be
opened as it would write/close the NULL FILE *. Now it doesn't act on
the file unless f != NULL. If it is it just does the usual of writing
'Ok' to stdout.
The Makefile had -include stdio.h which made it fail to compile under
macOS (mismatch type of fopen()). I removed the prototype in the code.
I also made it use fgets() instead of gets() to make it safer.
I had updated it after a commit and thought I did a commit -v --amend
but apparently I did not (or I missed the README.md though I thought I
did '.'). Thus the README.md was not as it should be.
This was a fun one to figure out and fix!
The original code did not work; there were several things wrong with it
as below. The macOS version was even more complicated but also fun and
also described below.
The problem with the original was a bad call to freopen() where the arg
parameter was actually 5+__FILE__ when it should be "r" (though of
course it used to work fine). A call to fopen() had a similar mode:
44+__FILE__ though this actually did not seem to affect the output. But
it didn't work with macOS at all. The following is some of what I put in
the README.md so that one can see here too what was wrong. Spoilers for
the original entry (at least some spoilers) are here!
For this alternative version you will need the command line tools which
you can install like:
```sh
sudo xcode-select --install
```
This how it works: if you look at line 55 you see a funny command.
This goes for both versions. Now the key are two magic numbers, one on a
different line shortly below the string. In the original the numbers are,
respectively, 44 and 46. But how does this work? Well the string is:
"0gcc -ansi -E -dM -undef %s /usr/include/%s>r\0 ("
The first number means: the length starting from 0 up through the `>`. The
second number is the same starting point but up through the `\0` which is why
it's +2. Somehow it was basic intuition that made me figure out these
two numbers and a quick test confirmed it. But what happens if only the
first number is updated? Most of the output will be just `#define` by
itself; in the cases where there was text after that it was macros that
certainly were not defined. There might have been other errors as well.
This allows for opening the right files. The problem with the macOS is
/usr/include does not exist: instead it's
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include which is
why the different command line and the different numbers.
It said that the program will fail if the program's name's second letter
isn't r but this restriction was removed for publication so I changed it
to past tense.
The make test rule ends up creating quite a few temporary files so I
have added them to the .gitignore. Perhaps I should add just *.tmp but I
added the globs individually instead.
Add instructions on how to install SDL or SDL2 for macOS, Linux and
Debian for:
2005/jetro
2014/maffiodo1
2018/giles
Put variables and instructions into the top level `var.mk` file.
Simply the Makefile header.
Refer to the //www.ioccc.org/bugs.md URL (that will eventually exist).
Now using CC BY-SA 4.0 License to how you may share and adapt the
Makefile.
Fix dead link. Apout is no longer available at the location in the
README.md. Instead it's on GitHub. I checked it and it's the same
author, Warren Toomey of TUHS so I know it's good (or at least the
program is: not sure if the repo is owned by him).
Format fixes.
Fix ioccc.org link (though it shouldn't be necessary since mullender.c
is actually in the repo).
With all README.md files I changed the copyright years to refer not to
2016 but 2015 as the year was 2015 and 2016 did not even have a contest.
I fixed formatting and some typos in a few of the README.md files but
mostly the changes are the copyright years.
As a reminder to myself I have only looked at (counting those of commit
fa31f80b39) burton, dogon, duble and part
of endoh1. The rest will come in a future commit or maybe commits.