The default file to open in the code did not exist: it was submitted as
adgrep.c but the judges changed the entry to be adrian.c. The adgrep is
a link to adrian but adgrep.c does not exist. Instead of changing it to
be adrian.c, however, I changed it to __FILE__.
If the file cannot be opened it no longer will segfault. This is the
only crash that was fixed; two are explicitly noted by the author as
features though it could possibly be implied that the same goes for the
entry itself.
The bugs.md has had some bugs that seem to be genuine bugs that might
want to be fixed and it also has had features added, things that should
not be fixed (including adsleep and adbasename crashing if no arg
specified).
The README.md file was typo/format checked/fixed.
The Makefile had several fixes, most importantly that now running 'make'
will link adgrep as it's now a target.
The thanks file has been updated as well as various things have, as
noted above, changed.
Originally there was one call to gets() and one call to fgets(). The
gets() was changed to the fgets() to prevent warnings including (in
macOS) warnings interspersed with output of the program.
But to make it more like the original gets() has been redefined to use
fgets(). However this does not mean that we can make the macro do a &&
... to strip off the newline as doing this will make a different file
fail to generate properly (I might look at that later as it would be
nicer if it looked exactly like before). Thus the 'Y[strlen(Y)-1]='\0';'
is still there in the body of the while loop at least for now.
The README.md was updated to remove the address - just have name and
country.
Updated thanks-for-fixes.md for the above change as well as some typo
fixes elsewhere.
As both Landon and I have been wondering if changing entries to use
fgets() is bordering on tampering with entries I decided to make the
original (sometimes bug fixed) versions (using gets()) alt code. I had
originally started to make the fgets() version of each entry the alt but
since the fgets() versions can handle input better and since some also
fixed bugs (see below) I decided to make the original version the alt
code (this also is how it is for other entries).
There were some exceptions here. If the change also fixed some crashes
or other bugs outside of the gets() to fgets() conversion I did not
bother to make an alt version. An example is 1992/dds. In some cases the
alt code does have bug fixes in which case they were added.
Updated the Makefiles and .gitignore files as well for the alt target
and the new files (compiled and in the case of 1992/adrian additional
source files in the Makefile alt rule).
This should solve the problem observed by Landon and me. It wouldn't be
a problem to change it so the alt version is the one that uses fgets()
but I think that might be the wrong choice.
In some entries I altogether avoided changing to fgets() say if the
author notes it uses gets() (in one case even providing a version that
uses fgets()). In some cases using fgets() introduces a bug so those are
also not changed.
As for 1990/tbr there's a strong reason for not having the fgets()
version being the alt. In macOS in particular (in linux - or maybe gcc,
not sure - it shows a warning at linker time) it will mess up the first
line of output in a potentially confusing way. For instance:
$ ./tbr.alt
$ warning: this program uses gets(), which is unsafe.
# nothing here, what to do?
And that touches on another issue of making the alt version the one that
uses gets(): the warnings that can be alarming during compilation,
linking and (in the case of macOS) runtime.
Not all entries should be or can be changed to fgets() but some can and
it's warranted for these reasons. More will possibly happen in the
future.
There was only one call to gets() and one call to fgets(). gets() reads
from stdin so the fgets() call has to as well. But why was it using
gets() and not fgets()? My guess is because fgets() stores the final
newline which means that the output had extra lines. The entry was
relying on this string NOT having a newline printed after the line
matched! Having a newline in turn broke the generation of some output
like that of adhead.c. Thus if fgets() != NULL we trim off the trailing
newline first. This allows the entry and all generated code to compile
successfully (adhead.c ended up having a multi-line macro messed up
because of an empty line after the \ at the end of the line). Since
gets() does not store the final newline and since we trim that off the
code is functionally equivalent but now safer.
As was discussed with Landon this was a mistake even if it helped with
consistency. There was even a brilliant pun that was destroyed with that
commit which I think is worth pointing out:
cp README.md hill
./ant hill
in 1991/ant ... even if it's technically 'anthill'.
I hope that I got all links fixed in years.html and winners.html. As
well I tried to make sure I got all handles fixed in all/summary.txt.
Nevertheless these should be checked. For some handles they were never
updated (at least in the html files - though maybe summary.txt too, not
sure) in the first place so there was nothing to do.
Typo fixes like references to *.hint when it should be README.md. There
probably are others that need to be fixed but haven't been located yet.
There were many files renamed in this commit and I hope I got all the
references to the old names changed to the new names. To explain this
commit there were some older entries that had the wrong directory name:
not the surname but something else.
Very possibly there are other directories that need to be renamed and I
am actually aware of one right now but since it's in 2005 (which is
close to being worked on) I am not changing that now but just noting it:
2005/anon should be changed to 2005/anonymous (unless there's a very
good reason I am unaware of). But like I said since 2005 will be worked
on soon I have not touched it.
The Makefiles, .gitignore, the all/summary.txt, years.html and
winners.html files as well as the directories and the files under the
renamed directories have all been updated.
This is a rather big update and it might be that there are conflicts. If
so I will fix them. I will have to update 2005/anon later on to try and
prevent this from happening but very possibly there will be conflicts
here. It's also possible I missed some changes in years.html and/or
winners.html and/or summary/all.txt but I think I got them all. These
should be verified later on.
We we move 1988-2004 entries from all of a year's winning entries
in a single directory to each winner being in their own sub-directory
under the given year directory.