diff --git a/1994/ldb/Makefile b/1994/ldb/Makefile index 1b8d8425f..09ddf4d3b 100644 --- a/1994/ldb/Makefile +++ b/1994/ldb/Makefile @@ -38,7 +38,7 @@ include ../../var.mk # Common C compiler warnings to silence # -CSILENCE= -Wno-trigraphs +CSILENCE= -Wno-trigraphs -Wno-int-conversion # Common C compiler warning flags # diff --git a/1994/ldb/ldb.c b/1994/ldb/ldb.c index b219ce3ca..01ed9498b 100644 --- a/1994/ldb/ldb.c +++ b/1994/ldb/ldb.c @@ -1 +1 @@ -int _,O,__??('}'??);main(){while(O?(fgets((rand()%O++?':':_)+__,232,stdin))||puts(&__??(_??))&_:(srand(time((O+++_))),0)||O);} +int _,O,__??('}'??);main(){while(O?(fgets((rand()%O++?':':_)+__,232,stdin))||puts(&__??(_??))&_:(srand(time((time_t *)(O+++_))),0)||O);} diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index edc60486a..d65c9a16d 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -604,14 +604,19 @@ which main() calls with the right parameters. Cody fixed this so it would 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 and to prevent -a warning at linking or at runtime, the latter of which can be interspersed with -output of the program. Note that this now prints a newline after the output but -this seems like a worthy compromise for making the output incorrect in macOS and -at the same time it's safer (fixing it to not have the extra newline is more -problematic than it's worth and in macOS another line of output would be shown -anyway). +comma operator was needed. + +Cody also fixed it for clang under linux which objected to incompatible pointer +type (because `time(2)` takes a `time_t *` which in some systems is a `long *` +but what was being passed to it is an `int`). + +Cody also changed the entry to use `fgets()` instead of `gets()` to make it safe +for lines greater than 231 in length and to prevent a warning at linking or at +runtime, the latter of which can be interspersed with output of the program. +Note that this now prints a newline after the output but this seems like a +worthy compromise for making the output incorrect in macOS and at the same time +it's safer (fixing it to not have the extra newline is more problematic than +it's worth and in macOS another line of output would be shown anyway). 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