Merge pull request #948 from xexyl/1992-lush

Improve fgets() fix to 1992/lush
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-09-10 23:30:12 -07:00
commit 0e54ba7f72
3 files changed
+9 -7

No files matched your search

-5
View File
@@ -1,9 +1,6 @@
# Worst Abuse of the C Preprocessor # Worst Abuse of the C Preprocessor
Ed Luke Ed Luke
Mississippi State University
P.O. Box 6176
Mississippi State, MS 39762
US US
@@ -20,8 +17,6 @@ make all
./runme.sh ./runme.sh
``` ```
For the original entry see the [archive tarball](/archive/archive-1992.tar.bz2).
## Judges' remarks: ## Judges' remarks:
+4 -2
View File
@@ -1,3 +1,5 @@
#define gets(_) fgets((_),999,stdin)
#line 1
#define f 000: #define f 000:
char char
*s,* *s,*
@@ -63,8 +65,8 @@
;;;} ;;;}
;for ;for
( ; ( ;
fgets gets
(_,999,stdin); (_);
) { ) {
for( for(
#define f 301: #define f 301:
+5
View File
@@ -585,6 +585,11 @@ which can be confusing) and also added the `runme.sh` script to demonstrate it
(using make was problematic). Cody notes that unfortunately this does not work (using make was problematic). Cody notes that unfortunately this does not work
with clang due to different compiler messages. with clang due to different compiler messages.
Cody later improved the `fgets()` change to look more like the original i.e. it
now uses a redefined `gets()`. This did require modifying the line number with
`#line 1` under the macro `gets()`. Still this cannot work with clang due to
different compiler messages. See [bugs.md](/bugs.md) for details.
## [1992/westley](1992/westley/westley.c) ([README.md](1992/westley/README.md])) ## [1992/westley](1992/westley/westley.c) ([README.md](1992/westley/README.md]))