Add 1992/gson/try.sh, add note about optimiser

The optimiser must be disabled due to it otherwise crashing in macOS in
some invocations. This has been added to the Makefile, the use of -O0 is
forced and a note has been added to the README.md file.

The bugs.md file has been updated on details of how it uses gets() and
that text has been removed from the thanks file.

Minor format fixes in README.md.

The script added makes use of the author's script (that I added as
mkdict.sh for easier use) after first trying to find a dictionary file.
But one can override the dictionary file with the DICT environmental
variable.

This entry should now truly be done.
This commit is contained in:
Cody Boone Ferguson committed 2023-12-19 09:07:37 -08:00
1 parent fed6b32f0a
commit 54c5271117
5 files changed
+158 -20

No files matched your search

+9 -15
View File
@@ -1420,25 +1420,19 @@ commands that we suggested and some additional ones that provide for some fun.
[Cody](#cody) fixed a crash that prevented this entry from working in some cases in some
systems (like macOS) by disabling the optimiser in the Makefile.
Cody also changed the buffer size in such a way that `gets(3)` should be safe
(theoretically) as it comes from the command line (though it can also read input
from stdin after starting the program). Ideally `fgets(3)` would be used but this
is a more problematic. Previously it had a buffer size of 256 which could
easily overflow. In this entry `gets(3)` is used in a more complicated way:
first `m` is set to `*++p` in a for loop where `p` is argv. Later `m` is set to
point to `h` which was of size 256. `gets(3)` is called as `m = gets(m)`) but
trying to change it to use `fgets(3)` proved more a problem. Since the input must
come from the command line Cody changed the buffer size to `ARG_MAX+1` which
should be enough (again theoretically) especially since the command expects
redirecting a dictionary file as part of the command line. This also makes it
possible for longer strings to be read (in case the `gets(3)` was not used in a
loop).
Cody also added the [try.sh](/1992/gson/try.sh) script.
Cody also added the [mkdict.sh](/1992/gson/mkdict.sh) script that the author
included in their remarks. See the README.md for its purpose. It was NOT fixed
for [ShellCheck](https://github.com/koalaman/shellcheck)
because the author deliberately obfuscated it so **PLEASE DO NOT
FIX THIS**.
because the author deliberately obfuscated it so **PLEASE *DO NOT* FIX THIS OR
MODERNISE IT**.
Cody also changed the buffer size in such a way that `gets(3)` should be safe
(well, theoretically) as it comes from the command line (though it can also read input
from `stdin` after starting the program). Ideally `fgets(3)` would be used but this
is a more problematic. See [1992/gson in bugs.md](/bugs.md#1992-gson) for more
details if you're interested in trying to understand it (or fix?).
## <a name="1992_imc"></a>[1992/imc](/1992/imc/imc.c) ([README.md](/1992/imc/README.md]))