Reword note about fgets() in 1992/adrian

This commit is contained in:
Cody Boone Ferguson committed 2023-04-07 11:06:00 -07:00
1 parent 58f30bd65e
commit 6186baa8eb
1 file changed
+11 -10
+11 -10
View File
@@ -14,16 +14,17 @@ make all
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) changed the location [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) changed the location
that it used `gets()` to be `fgets()` instead to make it safer. One might think that it used `gets()` to be `fgets()` instead to make it safer and to prevent
that simply changing the gets() to fgets() (with stdin) would work but it did any warnings during linking or runtime. One might think that simply changing the
not because `fgets()` stores the newline and `gets()` does not. The code was gets() to fgets() (with stdin) would work but it did not because `fgets()`
relying on not having this newline. With `fgets()` the code `if(A(Y)) puts(Y);` stores the newline and `gets()` does not. The code was relying on not having
ended up printing an extra line which made the generation of some files (like this newline. With `fgets()` the code `if(A(Y)) puts(Y);` ended up printing an
`adhead.c`) fail to compile (`gets()` does not store the newline but `fgets()` extra line which made the generation of some files (like `adhead.c`) fail to
does). Why? There was a blank line after a `\` at the end of the first line of a compile (`gets()` does not store the newline but `fgets()` does). Why? There was
macro definition! Thus the code now first trims off the last character of the a blank line after a `\` at the end of the first line of a macro definition!
buffer read to get the same correct functionality but in a safe way. Thank you Thus the code now first trims off the last character of the buffer read to get
Cody for your assistance! the same correct functionality but in a safe way. Thank you Cody for your
assistance!
For the original version [adrian.alt.c](adrian.alt.c) see the `Alternate code` section below. For the original version [adrian.alt.c](adrian.alt.c) see the `Alternate code` section below.