diff --git a/1989/westley/Makefile b/1989/westley/Makefile index b7f8fffa4..fe541f499 100644 --- a/1989/westley/Makefile +++ b/1989/westley/Makefile @@ -115,8 +115,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= ver0.o ver1.o ver2.o ver3.o -ALT_TARGET= ver0 ver1 ver2 ver3 +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# diff --git a/1989/westley/README.md b/1989/westley/README.md index 09107354b..444c18cbe 100644 --- a/1989/westley/README.md +++ b/1989/westley/README.md @@ -10,9 +10,17 @@ US\ make all ``` +### Bugs and (Mis)features + +This entry a listed in [bugs.md](/bugs.md) as: + +``` +STATUS: main() function args not allowed - please help us fix +STATUS: known bug - please help us fix +``` + +For more detailed information see [bugs.md](/bugs.md#1989westley-readmemd). -NOTE: this entry only partly works with clang and only some versions of clang, -due to defects in the compiler. See [bugs.md](/bugs.md) for more details. ## Try: @@ -51,20 +59,39 @@ Finally try: ```sh ./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 ``` +## Alternate code: -### INAFIAB - it's not a feature it's a bug :-( +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. -There might have been a segfault that was fixed in the original code but as we -no longer know what condition or conditions caused this we cannot be sure. It -seems like, according to various files, that `ver1` and/or `ver2` also have this -problem but we also do not know about the status of this. See -[bugs.md](/bugs.md) for more information. +### To build: + +```sh +make alt +``` + +### Try: + +```sh +echo IOCCC | ./westley.alt +echo IOCCC | ./westley.alt 1 +echo IOCCC | ./westley.alt 1 2 +echo IOCCC | ./westley.alt 1 2 3 +``` diff --git a/1989/westley/compile.sh b/1989/westley/compile.sh index b4d497d72..1366968e9 100755 --- a/1989/westley/compile.sh +++ b/1989/westley/compile.sh @@ -13,9 +13,7 @@ # # 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: +# If you wish to slow down the script you can use the DELAY variable like: # # DELAY=2 ./compile.sh # @@ -36,11 +34,11 @@ if [[ -z "$CC" ]]; then fi # get sleep duration -# we cannot use the form '${DELAY:=5}' because at least in some versions of bash +# we cannot use the form '${DELAY:=0}' 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=2 + DELAY=0 fi # make clobber to make the directory clean and then compile westley which we diff --git a/1989/westley/westley.alt.c b/1989/westley/westley.alt.c new file mode 100644 index 000000000..92cff6cd2 --- /dev/null +++ b/1989/westley/westley.alt.c @@ -0,0 +1,25 @@ + +/**//*/};)/**/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 +(&&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 +(&&)1-^gnat(&&)1& ABBA(!;)raeN,tang,gnat,ABBA(avnz&&0>ABBA{)raeN +,/**/);}znva(/*//**/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);main +(/*//**\**/tang^tang/**//*/,/* */,~/*//*-*/tang,gnat,ABBA- +0/**//*/(niam&&ABBA||))))tang( rahcteg&&1-1=]652%)191+gnat([kri=gnat diff --git a/bugs.md b/bugs.md index 60a70bf0c..f8c059b40 100644 --- a/bugs.md +++ b/bugs.md @@ -568,26 +568,22 @@ numbers with non-binary digits. ## [1989/westley](1989/westley/westley.c) ([README.md](1989/westley/README.md)) ### STATUS: main() function args not allowed - please help us fix -Although [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this for -some of the versions that are generated (see below tip) it will not work for all -with the clang compiler (gcc works fine) and in some versions of clang it will -not work at all due to yet another defect (see below also). +This entry is a big problem for clang due to the way it is designed. Earlier a +change was made to let it compile with clang but although it appeared to work +with gcc, all generated versions (see the README.md for details), this was +either a mistake or it no longer does. + +Thus the original was copied and this does not work at all in clang. It is very +easy to get the first one or two to work with clang but the others result in +compilation failures even besides clang. + +The problems with clang is that it does not allow `int` for any arg in `main()` +except the first one, argc, and some versions of clang do not even allow a +fourth arg at all (0, 2 or 3 args only). Cody noted that trying to fix it in some cases causes a segfault and in other cases it fails to generate some of the files (others are okay) at all (empty -files). - -There is another change that was thought up on 08 July 2023 which allows for -another version to be compiled with clang but it causes some of the versions to -not be correctly generated (whereas the current way does generate all files but -is not compilable with clang) so for now this is not in. If it is put in it will -be an alternate version. - -Some versions of clang have an additional defect where in additional to forcing -the args of `main()` to be of type `int` (for first arg) and the rest to be -`char **` it also does not allow a fourth arg to main(). This in fact is part of -the change thought up on 08 July 2023: main() calls a function which has the old -types of variables. +files). These changes were never committed. Cody gives these tips on the problem: `main()`'s second, third and fourth args (but on fourth arg see above) are supposed to be a `char **`. This didn't use to @@ -597,10 +593,14 @@ to decrypt the function `znva` to be main in _generated files_ (see the [README.md](1989/westley/README.md) for details). Since that function does not have the correct types when converted to main() it -fails to compile. But as he said changing the type causes either a segfault or -files not generated at all. `ver1`, `ver2` and `ver3` are the problematic ones. -The segfault happens when running the main program. Cody fixed that but as noted -as for the generated files only `ver0` will compile with clang. +fails to compile. But as he said changing the type causes either a segfault, +files not generated at all or files ended up with syntax errors. `ver1`, `ver2` +and `ver3` are the problematic ones. + +The file [westley.alt.c](1989/westley/westley.alt.c) will compile with clang +but although it can perform some of its functions it will generate code that +does not work. + ### STATUS: known bug - please help us fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index f565fb465..b8e228244 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -643,7 +643,10 @@ not his only reason :-) ) Cody got some of the versions (the original and `ver0`) to work with some versions of `clang`. Unfortunately there are some defects in `clang` that break -this entry either in full or in part. +this entry either in full or in part. Also, some of the code generated by it +cannot be compiled by gcc either. Thus these changes are in the alt code. +Nevertheless the main features of the program does work in the alt version, it +just cannot generate every C file correctly. Cody provided the compile.sh script to generate the files and then try and compile them (which ones succeed depend on whether or not clang is the