Add alt code to 1986/hague - fgets()

The reason it is in alt code is because one of the forms of input (see
below) will, although print out correct output, segfault after
outputting the text. That is when one does something like:

    echo foo | ./hague.alt

Whether it might be worth making it the entry itself with a note in the
Makefile and README.md and bugs.md (because it does print out correct
output) can be determined later - or not.

This change required several files to be updated besides the new file
hague.alt.c.
This commit is contained in:
Cody Boone Ferguson committed 2023-10-04 04:09:38 -07:00
1 parent 4836ed4622
commit c1c8197c34
8 files changed
+114 -10

No files matched your search

+19 -3
View File
@@ -469,11 +469,27 @@ the judges and shouldn't be fixed.
This entry uses `gets()` which is unsafe. In particular the buffer size is a
mere 81 and it does not read a single string at command invocation but instead
until the program is terminated. This size can be increased to start out but it
would be better if it used `fgets()`. This will be addressed in time but is
noted here as a reminder.
would be better if it used `fgets()`.
The way this entry is formed has made it not as simple as some of the others
that have been addressed.
that have been addressed at least in part. It is easy to get it to use `fgets()`
and this has been done in the [alternate code](1986/hague/hague.alt.c) but it
will segfault after outputting the (correct) text in one of the forms. In
particular whereas this:
```sh
./hague.alt
foo
works the following will print out the correct output but then segfault:
```
```sh
echo foo | ./hague.alt
```
Whether or not it is worth making the entry itself (since the output is correct)
this alt version is to be determined later but it's might very well not be.
## [1986/holloway](1986/holloway/holloway.c) ([README.md](1986/holloway/README.md))