Add alt code 1989/westley

Unfortunately the fix to let the main program compile with clang even
breaks some versions generated (see compile.sh) in syntax error so even
gcc cannot compile those. Therefore it's now alt code. The alt version
will compile with clang and the main feature of the program will work
but the program cannot generate every version of the program.

The bugs.md and thanks-for-fixes.md have been updated along with the
README.md.

In the README.md there is a different heading level for the alt code
sections to compare to another as we try and figure out what heading
levels to use.

I changed the delay to 0 in the compile.sh script but one can set it to
another value if they like.

This entry will have to be worked on more at another time.
This commit is contained in:
Cody Boone Ferguson committed 2023-10-25 09:08:48 -07:00
1 parent 2469510d33
commit e51a012aa8
7 files changed
+92 -40

No files matched your search

+2 -2
View File
@@ -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
#################
+35 -8
View File
@@ -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
```
+3 -5
View File
@@ -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
+25
View File
@@ -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=<enrA(||))tang(
enupgrt&&1==enrA((&&)2&gnat(&& )1-^tang(&&ABBA!(;)85- =tang
(&&)'a\'=gnat(&&)1-==gnat(&&)4 ==ABBA(&&tang!;))))0(enupgrt=
gnat(&&)tang!((||)))0(rahcteg =gnat(&&tang((&&ABBA;;)1-'A'=!
'Z'=tang(&&ABBA{)enrA/***/);gnat ^-1&&znva(tang+1,gnat,1+gnat);
main(ABBA&2/*//*\\**/,tang,gnat ,ABBA/**//*/(avnz/**/);}/*//**/
+2 -3
View File
@@ -1,8 +1,7 @@
/**//*/};)/**/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
,ABBA(niam&&)))2-]--tang-[kri - =raeN(&&0<)/*clerk*/,noon,raeN){(!tang&&
noon!=-1&&(gnat&2)&&((raeN&&( getchar(noon+0)))||(1-raeN&&(trgpune(noon
)))))||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
+21 -21
View File
@@ -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
+4 -1
View File
@@ -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