From b4b4ff8bc9d8b41ac3d291cfed3a30a5d5e23213 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 10 Jun 2023 10:24:20 -0700 Subject: [PATCH] Minor adjustment to 1992/westley INABIAF status --- 1992/westley/README.md | 5 +++-- bugs.md | 41 +++++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/1992/westley/README.md b/1992/westley/README.md index 7ee7f2543..18db56abd 100644 --- a/1992/westley/README.md +++ b/1992/westley/README.md @@ -56,8 +56,9 @@ NOTE: this alternative version also needs a terminal that wraps at 80 columns. ### INABIAF - it's not a bug it's a feature! :-) -This program and the alternate version will very likely crash or nuke the world -without enough args. This should not be fixed. +This program and the alternate version will very likely crash or nuke the entire +world or just the USA, respectively, without enough args. This should not be +fixed. ## Judges' remarks: diff --git a/bugs.md b/bugs.md index b96056697..ab16a6b80 100644 --- a/bugs.md +++ b/bugs.md @@ -679,9 +679,9 @@ this simply does not work with them. Can you help us? ## [1992/westley](1992/westley/westley.c) ([README.md](1992/westley/README.md)) ## STATUS: INABIAF - please **DO NOT** fix -This entry will very likely crash or nuke the world without enough args. This is -not considered a bug but a feature and should not be fixed in the repo. - +This program and the alternate version will very likely crash or nuke the entire +world or just the USA, respectively, without enough args. This should not be +fixed. # 1993 @@ -713,9 +713,10 @@ else. This should NOT be fixed. [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to compile with modern systems (see the README.md file for what had to change) but the -entry also used `gets()`. This could overflow long lines. Cody changed it to -`fgets()` but this introduces another problem namely that newlines can be -printed if the line length < 231. +entry also used `gets()` which in some systems would print out a warning along +with the output of the program. Naturally it could also overflow long lines. +Cody changed it to `fgets()` to prevent the display problem but this introduces +another problem namely that newlines can be printed if the line length < 231. This seems like a worthy compromise but it would be ideal for it to never print a newline unless that's the line itself (a blank line). @@ -817,15 +818,27 @@ We would be grateful if you could provide it to us. If you can provide this file you might consider removing this entry from this file as well but if not we'll take care of it. -### Important reminder to fix the `-1` value check for `getc()`: +### Important reminder and a note about the `-1` value check for `getc()`: + +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the code to not +use `-1` for the return value of `getc()`; this is important because `EOF` is +**NOT** guaranteed to be `-1` but rather any negative value. On systems where +`EOF != -1` the program would enter an infinite loop until the program crashed, +by chance reads a `-1` or was killed (it is for this same reason that one should +not use `EOF` for the `getopt()` functions as they return `-1` when all options +are parsed (for details on the definition of `EOF` see `7.21 +Input/output` subsection 1 of the standard)). + + +An interesting problem occurred where changing the `-1` to `EOF` caused both +`warning: illegal character encoding in string literal` and `error: source file +is not valid UTF-8`. But since `EOF` is simply an int < 0 and making the loop +condition check that the return value is >= 0 does not cause a compilation error +and it functions correctly it will address the systems where `EOF != -1` just as +if it checked for `!= EOF`. + +Since it works there is no need to fix this except for a challenge to yourself. -Cody wants to remind you that he fixed the code to not use `-1` for the return -value of `getc()`; this is important because `EOF` is **NOT** guaranteed to be -`-1` but rather any negative value. On systems where `EOF != -1` the program -would enter an infinite loop until the program crashed, by chance reads a `-1` -or was killed. See the README.md for more details. If you don't feel comfortable -changing it to `EOF` Cody will happily do it for you but otherwise go right -ahead. We'll credit you in the [thanks file](thanks-for-fixes.md) regardless. # 1995