diff --git a/1985/sicherman/Makefile b/1985/sicherman/Makefile index 3580f8705..316ef68c8 100644 --- a/1985/sicherman/Makefile +++ b/1985/sicherman/Makefile @@ -132,18 +132,15 @@ all: data ${TARGET} clean clobber install love haste waste maker easter_egg \ sandwich supernova deep_magic magic charon pluto -${PROG}: ${PROG}.c ${PROG}.alt2.c +${PROG}: ${PROG}.c ${PROG}.alt.c ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} || \ - ${CC} ${CFLAGS} ${PROG}.alt2.c -o $@ ${LDFLAGS} + ${CC} ${CFLAGS} ${PROG}.alt.c -o $@ ${LDFLAGS} # alternative executable # alt: data ${ALT_TARGET} @${TRUE} -${PROG}.alt: ${PROG}.alt.c - ${CC} ${CFLAGS} -traditional-cpp $< -o $@ ${LDFLAGS} - # data files # data: ${DATA} diff --git a/1985/sicherman/README.md b/1985/sicherman/README.md index 7cef74eea..dab9a3b79 100644 --- a/1985/sicherman/README.md +++ b/1985/sicherman/README.md @@ -4,14 +4,9 @@ make all ``` -There is an alternate version for those with an old enough compiler or one that -accepts `-traditional-cpp`. The second alt version will be compiled in the case -that you have a compiler that does not support 1 arg only in `main()`. For -instance clang has a number of defects and some versions say that `main()` can -only have 0, 2 or 3 args. The versions that have this that we know about do -support 1 arg but in case this is ever changed the -[sicherman.alt2.c](sicherman.alt2.c) is provided. See [Alternate -code](#alternate-code) below for details on the alt code, the original entry. +There is another version that will be compiled in case the first fails. This +should happen automatically. See [Alternate code](#alternate-code) below for +more details on it. ## To use: @@ -20,34 +15,40 @@ code](#alternate-code) below for details on the alt code, the original entry. ./sicherman < file echo foo | ./sicherman + +./sicherman +# type or paste some text, making sure to hit enter after each line typed ``` ### Try: ```sh -./sicherman < sicherman.c - -echo IOCCC | ./sicherman - -./sicherman < sicherman.c | ./sicherman +./try.sh ``` ## Alternate code: -The [sicherman.alt.c](sicherman.alt.c) is the original entry and requires either -an old enough compiler or a compiler that supports `-traditional-cpp`. If you have such -a compiler you can try this version. +The [sicherman.alt.c](sicherman.alt.c) is a slight change in the fixed version +(fixed so it does not require `-traditional-cpp`) in that it has two args to +`main()` as some compilers object to certain number of args in `main()`. This +will be built in the case of the [sicherman.c](sicherman.c) failing to compile. +In this case it'll be compiled to `sicherman` to simplify it for the larger +audience. ### Alternate build: +Although this will be built if the original fails to compile you can do it +manually like: + ```sh make alt - ``` +In this case it will be built as `sicherman.alt`. + ### Alternate use: @@ -59,7 +60,7 @@ make alt ### Alternate try: ```sh -./sicherman.alt < README.md | ./sicherman.alt +./try.alt.sh ``` diff --git a/1985/sicherman/sicherman.alt.c b/1985/sicherman/sicherman.alt.c index 5070cc8de..56262fe9f 100644 --- a/1985/sicherman/sicherman.alt.c +++ b/1985/sicherman/sicherman.alt.c @@ -2,22 +2,25 @@ #define _C_C(_)('\b'b'\b'>=C_C>'\t'b'\n') #define C_C _|_ #define b * -#define C /b/ -#define V _C_C( -main(C,V) -char **V; +#define c /**/ +#define v _C_C( +char _,__; +main( /* C program. (If you don't * understand it look it - */ up.) (In the C Manual) + * up.) (In the */C, Manual) +char **Manual; { - char _,__; - while (read(0,&__,1) & write((_=(_=C_C_(__),C)), - _C_,1)) _=C-V+subr(&V); + char _,__; + while (read(0,&__,1) & write((_=(_=C_C_(__), + v))?__:__-_+'\b'b'\b'|((_-52)%('\b'b'\b'+~ + ' '&'\t'b'\n')+1),1),&_,1))_=c-v+subr(&v)); } + subr(C) char *C; { - C="Lint says "argument Manual isn't used." What's that - mean?"; while (write((read(C_C('"'-'/*"'/*"*/))?__:__-_+ + C="Lint says \"argument Manual isn't used.\" What's that\ + mean?"; while (write((read(('"'-'/*"'))?__:__-_+ '\b'b'\b'|((_-52)%('\b'b'\b'+C_C_('\t'b'\n'))+1),1),&_,1)); } diff --git a/1985/sicherman/sicherman.alt2.c b/1985/sicherman/sicherman.alt2.c deleted file mode 100644 index 56262fe9f..000000000 --- a/1985/sicherman/sicherman.alt2.c +++ /dev/null @@ -1,26 +0,0 @@ -#define C_C_(_)~' '&_ -#define _C_C(_)('\b'b'\b'>=C_C>'\t'b'\n') -#define C_C _|_ -#define b * -#define c /**/ -#define v _C_C( -char _,__; -main( -/* C program. (If you don't - * understand it look it - * up.) (In the */C, Manual) -char **Manual; -{ - char _,__; - while (read(0,&__,1) & write((_=(_=C_C_(__), - v))?__:__-_+'\b'b'\b'|((_-52)%('\b'b'\b'+~ - ' '&'\t'b'\n')+1),1),&_,1))_=c-v+subr(&v)); -} - -subr(C) -char *C; -{ - C="Lint says \"argument Manual isn't used.\" What's that\ - mean?"; while (write((read(('"'-'/*"'))?__:__-_+ - '\b'b'\b'|((_-52)%('\b'b'\b'+C_C_('\t'b'\n'))+1),1),&_,1)); -} diff --git a/1985/sicherman/try.alt.sh b/1985/sicherman/try.alt.sh new file mode 100755 index 000000000..806feb1eb --- /dev/null +++ b/1985/sicherman/try.alt.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# try.alt.sh - demonstrate IOCCC winner 1985/sicherman.alt alt code +# + +# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it +# this way allows us to have the user specify a different compiler in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +make CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + + +read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c: " +echo 1>&2 +./sicherman.alt < sicherman.alt.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo IOCCC | ./sicherman.alt: " +echo 1>&2 +echo IOCCC | ./sicherman.alt +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c | ./sicherman.alt: " +echo 1>&2 +./sicherman.alt < sicherman.alt.c | ./sicherman.alt +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c | ./sicherman.alt | diff -s - sicherman.alt.c: " +echo 1>&2 +./sicherman.alt < sicherman.alt.c | ./sicherman.alt | diff -s - sicherman.alt.c diff --git a/thanks-for-help.md b/thanks-for-help.md index 2928d2a51..c95fb98a7 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -326,9 +326,14 @@ case as `c`. Additional code was added in case the fix cannot be compiled by some compilers should they object to `main()` having only one arg. This version will -automatically be compiled if the entry fails to compile for some reason. +automatically be compiled if the entry fails to compile for some reason but one +can compile it manually as `make alt` in which case it'll be compiled as +`sicherman.alt` (if it's done because [sicherman.c](/1985/sicherman/sicherman.c) +fails to compile it will be built as `sicherman` as part of the `sicherman` +rule). -Cody also added the [try.sh](/1985/sicherman/try.sh) script. +Cody also added the [try.sh](/1985/sicherman/try.sh) and +[try.alt.sh](/1985/sicherman/try.alt.sh) scripts. # 1986