diff --git a/1985/sicherman/Makefile b/1985/sicherman/Makefile index c77ea6b88..3580f8705 100644 --- a/1985/sicherman/Makefile +++ b/1985/sicherman/Makefile @@ -141,6 +141,8 @@ ${PROG}: ${PROG}.c ${PROG}.alt2.c alt: data ${ALT_TARGET} @${TRUE} +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} -traditional-cpp $< -o $@ ${LDFLAGS} # data files # diff --git a/1985/sicherman/README.md b/1985/sicherman/README.md index 66cc35005..7cef74eea 100644 --- a/1985/sicherman/README.md +++ b/1985/sicherman/README.md @@ -4,13 +4,14 @@ make all ``` -NOTE: there is an [alternate version](#alternate-code) for those who have an old -enough compiler or have a compiler that supports the option `-traditional-cpp`. -There is also an alternate version that is meant to work in the case that your -version of clang fails to compile it due to the wrong number of args to `main()` -should that ever happen (a compiler error of some versions of clang if `main()` -has four args is that `main()` can only have 0, 2 or 3 args but it does -currently accept 1 arg to `main()` nonetheless). +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. ## To use: @@ -35,8 +36,8 @@ echo IOCCC | ./sicherman ## Alternate code: -This alternate version, which is the original entry, requires either an old -enough compiler or a compiler that supports `-traditional-cpp`. If you have such +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. @@ -44,6 +45,7 @@ a compiler you can try this version. ```sh make alt + ``` diff --git a/1985/sicherman/try.sh b/1985/sicherman/try.sh new file mode 100755 index 000000000..801e1a224 --- /dev/null +++ b/1985/sicherman/try.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1985/sicherman +# + +# 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 < sicherman.c: " +echo 1>&2 +./sicherman < sicherman.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo IOCCC | ./sicherman: " +echo 1>&2 +echo IOCCC | ./sicherman +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./sicherman < sicherman.c | ./sicherman: " +echo 1>&2 +./sicherman < sicherman.c | ./sicherman +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./sicherman < sicherman.c | ./sicherman | diff -s - sicherman.c: " +echo 1>&2 +./sicherman < sicherman.c | ./sicherman | diff -s - sicherman.c diff --git a/thanks-for-help.md b/thanks-for-help.md index 866978ace..81063b2c2 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -304,18 +304,18 @@ case as `c`. - The code in `main()` is where there are significant changes, changing from: - ```c - while (read(0,&__,1) & write((_=(_=C_C_(__),C)), - _C_,1)) _=C-V+subr(&V); - ``` + ```c + while (read(0,&__,1) & write((_=(_=C_C_(__),C)), + _C_,1)) _=C-V+subr(&V); + ``` - to: + to: - ```c - 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)); - ``` + ```c + 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)); + ``` Note how numerous of the macros (though two changed in case) can still be used but some cannot be. Can you figure out why? Why too is it that the @@ -324,6 +324,12 @@ case as `c`. remove it from `main()`? What happens if you remove it from `subr()` or don't even bother calling `subr()`? +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. + +Cody also added the [try.sh](/1985/sicherman/try.sh) script. + # 1986