From 08a699bfe865ba9981bd898c7298e005c9f8f627 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Thu, 26 Oct 2023 08:32:00 -0700 Subject: [PATCH 1/4] Improve situation with clang for 1989/westley The alt code has been changed so that in addition to the main feature working it will also generate ver0 and ver1 correctly; ver2 and ver3 cannot be compiled still. This is not perfect but it is progress. I will look at this further later most likely. Added compile.alt.sh to compile the alt code and generate the alt code generated code. It generates it in the file name form alt.ver[0-3].c and the code will be compiled as such. Added try.sh to demonstrate the main (original) program. This is because there are a lot of commands to try. Added try.alt.sh to demonstrate the alt program (not trying the ver2 and ver3, naturally). The rationale is the same as for try.sh. The Makefile has been updated for these changes. Updated .gitignore as a number of new files will be created when running compile.alt.sh. The bugs.md has been updated as there has been some progress made. The hint was removed at this time as it's not applicable now; the problem of main() args not being allowed is no longer true. However the status line has not been updated because the root of the problem is this. There are currently no hints because I do not have any yet. The thanks file has also been updated for the new scripts as well as the situation being changed. --- 1989/westley/.gitignore | 9 +++++ 1989/westley/Makefile | 22 ++++++++++++ 1989/westley/README.md | 45 ++++++++---------------- 1989/westley/compile.alt.sh | 62 ++++++++++++++++++++++++++++++++ 1989/westley/compile.sh | 12 ++++--- 1989/westley/try.alt.sh | 39 +++++++++++++++++++++ 1989/westley/try.sh | 70 +++++++++++++++++++++++++++++++++++++ 1989/westley/westley.alt.c | 22 ++++++------ 1989/westley/westley.c | 2 +- bugs.md | 27 +++----------- thanks-for-fixes.md | 31 ++++++++++------ 11 files changed, 261 insertions(+), 80 deletions(-) create mode 100755 1989/westley/compile.alt.sh create mode 100755 1989/westley/try.alt.sh create mode 100755 1989/westley/try.sh diff --git a/1989/westley/.gitignore b/1989/westley/.gitignore index 25ce9886f..7a551420e 100644 --- a/1989/westley/.gitignore +++ b/1989/westley/.gitignore @@ -1,11 +1,20 @@ +alt.ver0 +alt.ver0.c ver0 ver0.c +alt.ver1 +alt.ver1.c ver1 ver1.c +alt.ver2 +alt.ver2.c ver2 ver2.c +alt.ver3 +alt.ver3.c ver3 ver3.c westley +westley.alt westley.orig prog.orig diff --git a/1989/westley/Makefile b/1989/westley/Makefile index fe541f499..6ccfe5be7 100644 --- a/1989/westley/Makefile +++ b/1989/westley/Makefile @@ -140,6 +140,9 @@ ${PROG}: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} +${ALT_TARGET}: ${PROG}.alt.c + ${CC} ${CFLAGS} -Dznva=main $< -o $@ ${LDFLAGS} + ver0: ${PROG} -./${PROG} < westley.c > ver0.c -${CC} ${CFLAGS} ver0.c -o $@ ${LDFLAGS} @@ -159,6 +162,25 @@ ver3: ${PROG} @echo "** NOTE: this version will not compile with clang **" -${CC} ${CFLAGS} ver3.c -o $@ ${LDFLAGS} +alt.ver0: ${PROG}.alt + -./${PROG}.alt < westley.alt.c > alt.ver0.c + -${CC} ${CFLAGS} -Dznva=main alt.ver0.c -o $@ ${LDFLAGS} + +alt.ver1: ${PROG}.alt + -./${PROG}.alt 1 < westley.alt.c > alt.ver1.c + -${CC} ${CFLAGS} -Dznva=main alt.ver1.c -o $@ ${LDFLAGS} + +alt.ver2: ${PROG}.alt + -./${PROG}.alt 1 2 < westley.alt.c > alt.ver2.c + @echo "** NOTE: this alt version will not currently compile **" + -${CC} ${CFLAGS} -Dznva=main alt.ver2.c -o $@ ${LDFLAGS} + +alt.ver3: ${PROG}.alt + -./${PROG}.alt 1 2 3 < westley.alt.c > alt.ver3.c + @echo "** NOTE: this alt version will not currently compile **" + -${CC} ${CFLAGS} -Dznva=main alt.ver3.c -o $@ ${LDFLAGS} + + # data files # data: ${DATA} diff --git a/1989/westley/README.md b/1989/westley/README.md index 444c18cbe..e6ef8cfa3 100644 --- a/1989/westley/README.md +++ b/1989/westley/README.md @@ -30,17 +30,6 @@ Try compiling and running the 4 resulting programs like: ./compile.sh ``` -This will remove the programs and then run: - -``` -./westley < westley.c > ver0.c -./westley 1 < westley.c > ver1.c -./westley 1 2 < westley.c > ver2.c -./westley 1 2 3 < westley.c > ver3.c -``` - -followed by compiling each version. - If you need to specify an alternate compiler path, say because your default compiler is clang (or in the case of macOS gcc is clang) you can do so like: @@ -60,39 +49,35 @@ Finally try: ./westley # input some lines of text, sending EOF (usually ctrl-d) to end -echo IOCCC | ./westley -echo IOCCC | ./westley 1 -echo IOCCC | ./westley 1 2 -echo IOCCC | ./westley 1 2 3 - -echo IOCCC | ./ver0 -echo Version 1 | ./ver1 -echo Version 2 | ./ver2 -echo Version 3 | ./ver3 +./try.sh # demo of some input ``` ## Alternate code: The alternate code allows SOME of the features to work with clang but some of -the code it generates (see [compile.sh](compile.sh), which does not use this -version) is not compilable even in gcc let alone clang. Nevertheless the main -feature should work for clang. +the code it generates (see [compile.alt.sh](compile.alt.sh) is not compilable +even in gcc let alone clang. Nevertheless the main feature should work and the +same goes for the `alt.ver0` and `alt.ver1`; currently `alt.ver2` and `alt.ver3` +will not compile even with gcc but it is nonetheless generated for when it is +(hopefully) fixed. -### To build: +### Alternate build: ```sh make alt ``` -### Try: +### Alternate try: ```sh -echo IOCCC | ./westley.alt -echo IOCCC | ./westley.alt 1 -echo IOCCC | ./westley.alt 1 2 -echo IOCCC | ./westley.alt 1 2 3 -``` +./westley.alt +# input some text +# generate alt code versions: +./compile.alt.sh + +./try.alt.sh # demo of some input +``` ## Judges' remarks: diff --git a/1989/westley/compile.alt.sh b/1989/westley/compile.alt.sh new file mode 100755 index 000000000..35a6b4f4c --- /dev/null +++ b/1989/westley/compile.alt.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# +# compile.sh - compile westley.alt.c, generate the alt versions and then attempt to +# compile them. +# +# To change what compiler is used you can do something like: +# +# CC=/path/to/cc ./compile.sh +# +# The following example was run on a MacBook Pro with the M1 Max which which +# could not normally compile everything because macOS's compiler, even when run +# as gcc, is actually clang: +# +# CC=/opt/local/bin/gcc-mp-12 ./compile.sh +# +# We sleep (by default) for approximately 1 second after each command so that +# the you can read what is being done. If this is too fast you can change it in +# a similar way to the above but using the variable DELAY like so: +# +# DELAY=2 ./compile.sh +# +# You can of course use both variables in the same command line like: +# +# CC=/opt/local/bin/gcc-mp-12 DELAY=2 ./compile.sh +# DELAY=2 CC=/opt/local/bin/gcc-mp-12 ./compile.sh +# +# ...and so on. + +# get the compiler using default cc if not specified in the command line +# +# we cannot use the form '${CC:=cc}' because at least in some versions of bash +# it tries to invoke the command which would be an error by itself. Thus we just +# check if it's empty before we set it. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +# get sleep duration +# we cannot use the form '${DELAY:=5}' because at least in some versions of bash +# it tries to invoke the command and obviously that won't work. Thus we check if +# it's empty before setting the default. +if [[ -z "$DELAY" ]]; then + DELAY=0 +fi + +# make clobber to make the directory clean and then compile westley.alt which we +# need to run everything else. Exit if make westley.alt fails as there would be +# nothing further that could be done in that case: +echo "$ make clobber westley.alt" +sleep "$DELAY" +make CC="$CC" clobber westley.alt || exit 1 +sleep "$DELAY" + +# run commands previously in the try section of the README.md, showing what the +# commands are as we go: + +# now generate and compile the files +# +echo "Generating and compiling alt versions ..." 1>&2 +sleep "$DELAY" +echo "$ make CC=$CC alt.ver0 alt.ver1 alt.ver2 alt.ver3" 1>&2 +make CC="$CC" alt.ver0 alt.ver1 alt.ver2 alt.ver3 diff --git a/1989/westley/compile.sh b/1989/westley/compile.sh index 1366968e9..f02219748 100755 --- a/1989/westley/compile.sh +++ b/1989/westley/compile.sh @@ -13,7 +13,9 @@ # # CC=/opt/local/bin/gcc-mp-12 ./compile.sh # -# If you wish to slow down the script you can use the DELAY variable like: +# We sleep (by default) for approximately 1 second after each command so that +# the you can read what is being done. If this is too fast you can change it in +# a similar way to the above but using the variable DELAY like so: # # DELAY=2 ./compile.sh # @@ -34,7 +36,7 @@ if [[ -z "$CC" ]]; then fi # get sleep duration -# we cannot use the form '${DELAY:=0}' because at least in some versions of bash +# we cannot use the form '${DELAY:=5}' because at least in some versions of bash # it tries to invoke the command and obviously that won't work. Thus we check if # it's empty before setting the default. if [[ -z "$DELAY" ]]; then @@ -68,8 +70,8 @@ sleep "$DELAY" # now compile the files by running make alt # -echo "Compiling alt versions ..." 1>&2 +echo "Compiling generated versions ..." 1>&2 sleep "$DELAY" -echo "$ make CC=$CC alt" 1>&2 +echo "$ make CC=$CC ver0 ver1 ver2 ver3" 1>&2 sleep "$DELAY" -make CC="$CC" alt +make CC="$CC" ver0 ver1 ver2 ver3 diff --git a/1989/westley/try.alt.sh b/1989/westley/try.alt.sh new file mode 100755 index 000000000..7ff1eef7c --- /dev/null +++ b/1989/westley/try.alt.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +make alt || exit 1 + + +echo "$ echo IOCCC | ./westley.alt" +echo IOCCC | ./westley.alt +echo + +echo "$ echo IOCCC | ./westley.alt 1" +echo IOCCC | ./westley.alt 1 +echo + +echo "$ echo IOCCC | ./westley.alt 1 2" +echo IOCCC | ./westley.alt 1 2 +echo + +echo "$ echo IOCCC | ./westley.alt 1 2 3" +echo IOCCC | ./westley.alt 1 2 3 +echo + +echo "$ echo IOCCC | ./alt.ver0" +echo IOCCC | ./alt.ver0 +echo + +echo "$ echo Version 1 | ./alt.ver1" +echo Version 1 | ./alt.ver1 +echo + +echo "$ echo Version 1 | ./alt.ver1 1" +echo Version 1 | ./alt.ver1 1 +echo + +echo "$ echo Version 1 | ./alt.ver1 1 2" +echo Version 1 | ./alt.ver1 1 2 +echo + +echo "$ echo Version 1 | ./alt.ver1 1 2 3" +echo Version 1 | ./alt.ver1 1 2 3 diff --git a/1989/westley/try.sh b/1989/westley/try.sh new file mode 100755 index 000000000..359b47730 --- /dev/null +++ b/1989/westley/try.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +make all || exit 1 + +echo "$ echo IOCCC | ./westley" +echo IOCCC | ./westley +echo + +echo "$ echo IOCCC | ./westley 1" +echo IOCCC | ./westley 1 +echo + +echo "$ echo IOCCC | ./westley 1 2" +echo IOCCC | ./westley 1 2 +echo + +echo "$ echo IOCCC | ./westley 1 2 3" +echo IOCCC | ./westley 1 2 3 +echo + +echo "$ echo IOCCC | ./ver0" +echo IOCCC | ./ver0 +echo + +echo "$ echo Version 1 | ./ver1" +echo Version 1 | ./ver1 +echo + +echo "$ echo Version 1 | ./ver1 1" +echo Version 1 | ./ver1 1 +echo + +echo "$ echo Version 1 | ./ver1 1 2" +echo Version 1 | ./ver1 1 2 +echo + +echo "$ echo Version 1 | ./ver1 1 2 3" +echo Version 1 | ./ver1 1 2 3 +echo + +echo "$ echo Version 2 | ./ver2" +echo Version 2 | ./ver2 +echo + +echo "$ echo Version 2 | ./ver2 1" +echo Version 2 | ./ver2 1 +echo + +echo "$ echo Version 2 | ./ver2 1 2" +echo Version 2 | ./ver2 1 2 +echo + +echo "$ echo Version 2 | ./ver2 1 2 3" +echo Version 2 | ./ver2 1 2 3 +echo + +echo "$ echo Version 3 | ./ver3" +echo Version 3 | ./ver3 +echo + +echo "$ echo Version 3 | ./ver3 1" +echo Version 3 | ./ver3 1 +echo + +echo "$ echo Version 3 | ./ver3 1 2" +echo Version 3 | ./ver3 1 2 +echo + +echo "$ echo Version 3 | ./ver3 1 2 3" +echo Version 3 | ./ver3 1 2 3 diff --git a/1989/westley/westley.alt.c b/1989/westley/westley.alt.c index 92cff6cd2..c5002fad7 100644 --- a/1989/westley/westley.alt.c +++ b/1989/westley/westley.alt.c @@ -1,13 +1,12 @@ -/**//*/};)/**/main(/*//**/tang ,gnat/**//*/,ABBA~,0-0(avnz;)0-0,tang,raeN -,ABBA(niam&&)))2-]--tang-[kri - =raeN(&&0<)/*clerk*/,noon,raeN)char -**gnat, **noon, **raeN;{int gn = gnat, ra = raeN, no = noon; (!tang&& -no!=-1&&(gn&2)&&((raeN&&( getchar(no+0)))||(1-ra&&(trgpune(no -)))))||tang&&znva(/*//**/tang ,tang,tang/**|**//*/((||)))0(enupgrt=raeN +/**//*/;)/**/pain(/*//**/tang ,gnat/**//*/,ABBA~,0-0(avnc-0,tang,raeN +,ABBA(niam&&)))2-]--tang-[kri - =raeN(&&0<)/*clerk*/,noon,raeN){(!tang&& +noon!=-1&&(gnat&2)&&((raeN&&( getchar(noon+0)))||(1-raeN&&(trgpune(noon +)))))||tang&&cnva(/*//**/tang ,tang/**|**//*/((||)))0(enupgrt=raeN (&&tang!(||)))0(rahcteg=raeN( &&1==tang((&&1-^)gnat=raeN(;;;)tang,gnat -,ABBA,0(avnz;)gnat:46+]552&)191+gnat([kri?0>]652%)191+gnat([kri=gnat +,ABBA,0(avnc;)gnat:46+]552&)191+gnat([kri?0>]652%)191+gnat([kri=gnat (&&)1-^gnat(&&)1& ABBA(!;)raeN,tang,gnat,ABBA(avnz&&0>ABBA{)raeN -,/**/);}znva(/*//**/tang,gnat,ABBA/**//*/(niam;}1-,78-,611-,321 +,/**/);}cnva(/*//**/tang,gnat,ABBA/**//*/(niam;}1-,78-,611-,321 -,321-,001-,64-,43-,801-,001-,301-,321-,511-,53-,54,44,34,24 ,14,04,93,83,73,63,53,43,33,85,75,65,55,45,35,25,15,05,94,84 ,74,64,0,0,0,0,0,0,/**/){ABBA='N'==65;(ABBA&&(gnat=trgpune @@ -15,11 +14,12 @@ no!=-1&&(gn&2)&&((raeN&&( getchar(no+0)))||(1-ra&&(trgpune(no gnat&&gnat<='z'||'a'<=gnat&&gnat<='m'||'N'<=gnat&&gnat<='Z' ||'A'<=gnat&&gnat<='M'?(((gnat&/*//**/31/**//*/,21,11,01,9,8 ,7,6,5,4,3,2,1,62,52,42,/**/)+12)%26)+(gnat&/*//**/32/**//*/, -22,12,02,91,81,71,61,51,41{=]652[kri};)/*pry*/)+65:gnat);main +22,12,02,91,81,71,61,51,41{=]652[kri};)/*pry*/)+65:gnat);pain (/*//**\**/tang^tang/**//*/,/* */,~/*//*-*/tang,gnat,ABBA- 0/**//*/(niam&&ABBA||))))tang( rahcteg&&1-1= Date: Thu, 26 Oct 2023 08:50:26 -0700 Subject: [PATCH 2/4] Fix alt code headers in 1989/ovdluhe/README.md --- 1989/ovdluhe/Makefile | 2 +- 1989/ovdluhe/README.md | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/1989/ovdluhe/Makefile b/1989/ovdluhe/Makefile index 30326a98e..1534720b8 100644 --- a/1989/ovdluhe/Makefile +++ b/1989/ovdluhe/Makefile @@ -41,7 +41,7 @@ include ../../var.mk CSILENCE= -Wno-char-subscripts -Wno-constant-conversion -Wno-empty-body \ -Wno-implicit-function-declaration -Wno-parentheses -Wno-unsequenced \ -Wno-unused-variable -Wno-strict-prototypes \ - -Wno-extra-semi -Wno-non-literal-null-conversion + -Wno-extra-semi -Wno-non-literal-null-conversion -Wno-implicit-int # Common C compiler warning flags # diff --git a/1989/ovdluhe/README.md b/1989/ovdluhe/README.md index db6a83b04..d4bca6376 100644 --- a/1989/ovdluhe/README.md +++ b/1989/ovdluhe/README.md @@ -38,13 +38,25 @@ by chance or is killed. ## Alternate code: The author suggested that one varies the definition of `P` from 2 through 10. As -it's a `#define` it's easy to set up. To use try: +it's a `#define` it's easy to set up. + + +### Alternate build: + ```sh make CFLAGS="-DP=9" clobber alt ``` -Use `ovdluhe.alt` as you would `ovdluhe`. +You do not have to define `P` but if you do you can replace the value with +whatever you wish, as long as it's an int. + + +### Alternate use: + +```sh +./ovdluhe.alt +``` ## Judges' remarks: From 0937a6920ab4a4eca68721e5f9e462d589f6b99b Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Thu, 26 Oct 2023 08:53:44 -0700 Subject: [PATCH 3/4] Fix alt code headers in 1989/tromp/README.md --- 1989/tromp/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/1989/tromp/README.md b/1989/tromp/README.md index 1baa1d9f3..b750569dd 100644 --- a/1989/tromp/README.md +++ b/1989/tromp/README.md @@ -16,6 +16,7 @@ make all ``` ## Try: + ```sh ./tromp 5 @@ -53,18 +54,21 @@ loser](https://web.archive.org/web/20181023221954/https://www.chicagotribune.com The author provided an alternate version of the code with some improvements. See the judges' additional remarks in the author's remarks, for more details. -### Alternate use: +### Alternate build: ```sh make alt ``` +### Alternate use: + Use `tromp.alt` as you would `tromp` above. NOTE: testing more than one user updating the high score file, one of the benefits of the alt version, has not been done. -The original unmodified alternate code is provided later. +The original unmodified alternate code, which will no longer work right if it +even compiles, is provided later in the author's remarks. ## Judges' remarks: From e601a8f595aea43498fa77d45d54c07fef556ead Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Thu, 26 Oct 2023 08:57:32 -0700 Subject: [PATCH 4/4] Change '#### Try' to '### Alternate try' This does not complete the alt code related headers but I noticed this and it was easy to do quickly. Unless I run across another when I am working on the README.md files of the entries I will probably have to do the rest manually as I come across them as most likely the headers are missing. This was done as sgit -e 's/^#### Try/### Alternate try/g' '*README.md' --- 1984/mullender/README.md | 4 ++-- 1985/lycklama/README.md | 2 +- 1985/sicherman/README.md | 2 +- 1988/litmaath/README.md | 2 +- 1993/plummer/README.md | 2 +- 1995/garry/README.md | 2 +- 2012/kang/README.md | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/1984/mullender/README.md b/1984/mullender/README.md index 4bcd2c477..fbbe982c4 100644 --- a/1984/mullender/README.md +++ b/1984/mullender/README.md @@ -58,7 +58,7 @@ overflow! BTW: is there such a thing as too fast a CPU ? :-) Actually yes for certain code which is probably not as uncommon as you think :-). -#### Try: +### Alternate try: ```sh @@ -137,7 +137,7 @@ make gentab ./gentab file ``` -#### Try: +### Alternate try: ```sh ./gentab gentab diff --git a/1985/lycklama/README.md b/1985/lycklama/README.md index eeb96f532..8ec3c2955 100644 --- a/1985/lycklama/README.md +++ b/1985/lycklama/README.md @@ -76,7 +76,7 @@ make all ./lycklama < some_file ``` -#### Try: +### Alternate try: ```sh ./lycklama < lycklama.c diff --git a/1985/sicherman/README.md b/1985/sicherman/README.md index 0cea686d6..63ff49234 100644 --- a/1985/sicherman/README.md +++ b/1985/sicherman/README.md @@ -45,7 +45,7 @@ make alt ./sicherman.alt < file ``` -#### Try: +### Alternate try: ```sh diff --git a/1988/litmaath/README.md b/1988/litmaath/README.md index c0513887f..934e66e29 100644 --- a/1988/litmaath/README.md +++ b/1988/litmaath/README.md @@ -40,7 +40,7 @@ make alt Use `litmaath.alt` as you would `litmaath` above. -#### Try: +### Alternate try: ```sh ./litmaath.alt six was afraid of seven because seven eight nine diff --git a/1993/plummer/README.md b/1993/plummer/README.md index 92fab4587..f3b5abfb6 100644 --- a/1993/plummer/README.md +++ b/1993/plummer/README.md @@ -52,7 +52,7 @@ make clobber CDEFINE="-DZ=50" alt ``` -#### Try: +### Alternate try: ```sh ./plummer.alt xyzzyzzyx 5555 diff --git a/1995/garry/README.md b/1995/garry/README.md index 1f56284c4..f8b0ba21f 100644 --- a/1995/garry/README.md +++ b/1995/garry/README.md @@ -48,7 +48,7 @@ make alt ./garry.alt output_file ``` -#### Try: +### Alternate try: ```sh diff --git a/2012/kang/README.md b/2012/kang/README.md index eade9adf1..e4823c0c2 100644 --- a/2012/kang/README.md +++ b/2012/kang/README.md @@ -57,7 +57,7 @@ echo vier | ./kang.alt echo uno | ./kang.alt ``` -#### Try: +### Alternate try: ```sh