From c0fa14424b1fc0b810b6a68d4e6daa2301e785d4 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Apr 2023 11:10:40 -0700 Subject: [PATCH] Reword note about fgets() in 1994/ldb/README.md The fact fgets() makes it print another line is less of a problem in macOS as it already printed two lines - one as a warning about gets() and then the output of the program. Keeping gets() is a problem but not keeping it can also be considered a problem. Given it prevents a warning it's a good thing as it can be potentially alarming. --- 1994/ldb/README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/1994/ldb/README.md b/1994/ldb/README.md index dffa8dc4a..0f435635a 100644 --- a/1994/ldb/README.md +++ b/1994/ldb/README.md @@ -16,12 +16,14 @@ make all compile and work with modern compilers. The problem was that `srand()` returns void but it was used in a `||` expression. Thus the comma operator was needed. Cody also changed the entry to use `fgets()` instead of `gets()` to make it -safe for lines greater than 231 in length. Note that this now prints a newline -after the output but this seems like a worthy compromise for making it safer -(fixing it is more problematic than it is worth). A subtlety about this fix: if -a line is greater than 231 in length if the program chooses that line it might -print the first 231 characters or it might print (up to) the next 231 characters -and so on. Thank you Cody for your assistance! +safe for lines greater than 231 in length and to prevent a warning at linking or +at runtime. Note that this now prints a newline after the output but this seems +like a worthy compromise for making it safer (fixing it is more problematic than +it is worth). In macOS another line of output would be shown anyway namely the +warning that it uses gets(). A subtlety about this fix: if a line is greater +than 231 in length if the program chooses that line it might print the first 231 +characters or it might print (up to) the next 231 characters and so on. Thank +you Cody for your assistance! For the original fixed version [ldb.alt.c](ldb.alt.c) see below.