From eb9e69fde657acc8c85a618a8a99af4c2f93b21d Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 28 Oct 2023 05:32:19 -0700 Subject: [PATCH 1/3] Make progress in 1989/westley - alt code now main The code that was the alt code now works entirely with gcc! The ver2 and ver3 do not yet work with clang but the other versions do so it seems appropriate to make this the main version and remove the alt code and alt scripts. I will continue to work on this in between the README.md files but this feels like great progress and as it was all I felt up to at this time it is definitely worth the effort and time. --- 1989/westley/Makefile | 31 +++++-------------------------- 1989/westley/README.md | 29 +---------------------------- 1989/westley/westley.alt.c | 26 -------------------------- 1989/westley/westley.c | 18 +++++++++--------- bugs.md | 28 ++++++++++++---------------- thanks-for-fixes.md | 28 +++++++++++++--------------- 6 files changed, 40 insertions(+), 120 deletions(-) delete mode 100644 1989/westley/westley.alt.c diff --git a/1989/westley/Makefile b/1989/westley/Makefile index 6ccfe5be7..37e171fdd 100644 --- a/1989/westley/Makefile +++ b/1989/westley/Makefile @@ -60,7 +60,7 @@ ARCH= # Defines that are needed to compile # -CDEFINE= -Dtrgpune=putchar -Dpune=char -Dvag=int +CDEFINE= -Dtrgpune=putchar -Dpune=char -Dvag=int -Dznva=main # Include files that are needed to compile # @@ -115,8 +115,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= ${PROG}.alt.o -ALT_TARGET= ${PROG}.alt +ALT_OBJ= +ALT_TARGET= ################# @@ -140,9 +140,6 @@ ${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} @@ -155,30 +152,12 @@ ver1: ${PROG} ver2: ${PROG} -./${PROG} 1 2 < westley.c > ver2.c @echo "** NOTE: this version will not compile with clang **" - -${CC} ${CFLAGS} ver2.c -o $@ ${LDFLAGS} + -${CC} ${CFLAGS} -Uznva ver2.c -o $@ ${LDFLAGS} ver3: ${PROG} -./${PROG} 1 2 3 < westley.c > ver3.c @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} + -${CC} ${CFLAGS} -Uznva ver3.c -o $@ ${LDFLAGS} # data files diff --git a/1989/westley/README.md b/1989/westley/README.md index e6ef8cfa3..d185f8a20 100644 --- a/1989/westley/README.md +++ b/1989/westley/README.md @@ -40,7 +40,7 @@ CC=/opt/local/bin/gcc-mp-12 ./compile.sh If you wish to delay the script or remove the delay you can do so like: ```sh -DELAY=0 ./compile.sh +DELAY=2 ./compile.sh ``` Finally try: @@ -52,33 +52,6 @@ Finally try: ./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.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. - -### Alternate build: - -```sh -make alt -``` - -### Alternate try: - -```sh -./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/westley.alt.c b/1989/westley/westley.alt.c deleted file mode 100644 index c3d5958c5..000000000 --- a/1989/westley/westley.alt.c +++ /dev/null @@ -1,26 +0,0 @@ - -/**//*/;)/**/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(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 -,/**/);}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 -(0)))||(!ABBA&&(gnat=getchar(0-0)));(--tang&1)&&(gnat='n'<= -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);pain -(/*//**\**/tang^tang/**//*/,/* */,~/*//*-*/tang,gnat,ABBA- -0/**//*/(niam&&ABBA||))))tang( rahcteg&&1-1=]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 +,/**/);}main(/*//**/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 +,74,64,0,0,0,0,0,0,/**/)char**gnat,**ABBA;{ABBA='N'==65;(ABBA&&(gnat=trgpune (0)))||(!ABBA&&(gnat=getchar(0-0)));(--tang&1)&&(gnat='n'<= 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 +||'A'<=(int)gnat&&gnat<='M'?((((int)gnat&/*//**/31/**//*/,21,11,01,9,8 +,7,6,5,4,3,2,1,62,52,42,/**/)+12)%26)+((int)gnat&/*//**/32/**//*/, +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: Sat, 28 Oct 2023 05:37:29 -0700 Subject: [PATCH 2/3] Remove rest of alt files in 1989/westley The files compile.alt.sh and try.alt.sh are no longer useful. --- 1989/westley/compile.alt.sh | 61 ------------------------------------- 1989/westley/try.alt.sh | 39 ------------------------ 2 files changed, 100 deletions(-) delete mode 100755 1989/westley/compile.alt.sh delete mode 100755 1989/westley/try.alt.sh diff --git a/1989/westley/compile.alt.sh b/1989/westley/compile.alt.sh deleted file mode 100755 index f10c13181..000000000 --- a/1989/westley/compile.alt.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash -# -# compile.alt.sh - compile westley.alt.c then generate and compile alt versions -# -# 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/try.alt.sh b/1989/westley/try.alt.sh deleted file mode 100755 index 7ff1eef7c..000000000 --- a/1989/westley/try.alt.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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 From ce3e89a1801ac64804075eb7ccfb0fc20363e863 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 28 Oct 2023 05:42:05 -0700 Subject: [PATCH 3/3] 1989/westley/ver1 will compile with clang ... so remove the notice from the Makefile. --- 1989/westley/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/1989/westley/Makefile b/1989/westley/Makefile index 37e171fdd..636320e39 100644 --- a/1989/westley/Makefile +++ b/1989/westley/Makefile @@ -146,7 +146,6 @@ ver0: ${PROG} ver1: ${PROG} -./${PROG} 1 < westley.c > ver1.c - @echo "** NOTE: this version will not compile with clang **" -${CC} ${CFLAGS} ver1.c -o $@ ${LDFLAGS} ver2: ${PROG}