Fix 2005/giljade and remove alt code
This was fun! There were a few things that had to be done. First the
expression O-b-f-u-s-c-a-t-e-d; had to be removed from the end of the
code. This served no purpose but it caused compilation errors in the
self-test feature and it does not affect the output of the puzzle
either. Besides that when the variables are declared it spells out the
same thing, Obfuscated.
I also had to change main() to be the old style that is
'main(argc,argv)char**argv;{...}' and I also changed the use of 'cc' to
'make' along with 'rm -f' on the compiled output (due to make otherwise
not wanting to update it).
Now this works with clang too!
Updated thanks-for-fixes.md and bugs.md: for thanks file it now works
full stop and for bugs.md I removed the part that says it doesn't work
fully. There still is the feature where if the source file is not in the
current working directory it will crash or do something strange.
BTW: if a directory only has broken links is it still a working
directory ? :-)
This commit is contained in:
1 parent
b8a945b642
commit
5e73b217b1
6 files changed
+49
-220
No files matched your search
@@ -1,5 +1,4 @@
|
||||
giljade
|
||||
giljade.alt
|
||||
out
|
||||
c.c
|
||||
giljade.orig
|
||||
|
||||
+3
-16
@@ -51,24 +51,11 @@ vi out
|
||||
Press ^F (control F) repeatedly.
|
||||
|
||||
|
||||
### Alternate code:
|
||||
|
||||
This version will work only with compilers that let you have alternate types to
|
||||
the args of `main()` and will also successfully run its self-test (the other
|
||||
version only runs some of them successfully). To use:
|
||||
### Self-test feature to try:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `giljade.alt` as you would `giljade` above.
|
||||
|
||||
|
||||
#### Try:
|
||||
|
||||
```sh
|
||||
./giljade.alt > out
|
||||
./giljade.alt out
|
||||
./giljade > out
|
||||
./giljade out
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
#define/**/F/***/for/*A*/
|
||||
#define/***/H()f=*E<<4|*\
|
||||
E,f=~(f|f<<1|E[3]|E[1]|E\
|
||||
[1]<<4|E[2]|E[(2)]<<(1));
|
||||
#define/***/I(x,d)F(;s;C\
|
||||
()){s=s^(b=s&s-1^s);F(N[\
|
||||
4]=q=0;q<4;q++)N[q]=E[q]\
|
||||
;N[5]=E-B;N[d]^=+b^(b)x;}
|
||||
#define/**/o(p,t,i,m,a,l\
|
||||
\
|
||||
)u=(f&p)i(m) ;s=u&E[3];I(t(m),3)s=(u)a &E[l];I(t(m\
|
||||
),l)u=u>>5-m &u;s=u&E[3-l];I(t(m),3-l) s=(u)a&*E;I\
|
||||
(t(m),(0));; /*echo/Line/%d;sed/-n/-e/ %d,%dp/%s>*/
|
||||
/*c.c;cc/c.c /-c*/;;char*A=0,*_,*R,*Q, D[9999],*r,l
|
||||
[9999],T=42, M,V=32;int *E,k[9999],B[1 <<+21],*N=B+
|
||||
1234567,q=0, h=3,j=2,O,b,f,u,s,c,a,t,e ,d;C(){F(h=N
|
||||
[3];(B[h]&&+ memcmp(N,B+B[h],16));h=B[ h]+4);B[h]||
|
||||
(B[h]=N-B,N= N+6);}main(char*U,int*w[] ){;;F(_=A=D+
|
||||
6666,A[fread (A,1,3333,fopen(__FILE__, "r"))]=0;*++
|
||||
_;h||(*_=V))
|
||||
*_-59|_[1]-* _||(h&&(*_=+ 35),h---2||(_[9]=V));;F(_
|
||||
=A;*_;_++)10 -*_&&*_-V&&( *_-92)&&(k[q]=isalnum(l[q
|
||||
]=*_),q++);M =47;*(E=N-6) =64;E[1]=289;E[2]=270336;
|
||||
F(E[3]=32782 ;E<N;E=E+6){ H()o(1048560,<<,>>,4,>>4,
|
||||
1)o(+489335, >>,<<,1,,2)o (978670,<<,>>,1,>>1,2)o(+
|
||||
65535,>>,<<, 4,,1)if(8192 &*E){F(N=B;E>B;E=B+E[5])*
|
||||
N++=E-B;F(;N >B;){h=*(E=B +*--N);H()s=~(E[1]|h|h<<1
|
||||
);u=~(E[2]|h |h<<4);r=l;_ =D;d=1;a=2;O=8;F(q=74;q;q
|
||||
--){F(b=0;b< 72;b++){h=+1 <<(q-1)/14*4+(b-1)/18;j=b
|
||||
?(!(b%18)&&u &h)|h&f|(!(q%14)&&s&h)?1:
|
||||
0:2;if(O<3)O ?j?j-1&&(O-2 &&d--,*R=34,O=2):(*_++=O-
|
||||
2?l[d]?l[d++ ]:(d=t,O=e=3 ,34):(O=1,34)):j||(*_++=d
|
||||
<t?l[d++]:(O =1,d=0,34)); else{if(O<6)if(j){j-2|e||
|
||||
(_=R,O-4?d-- :M-_[-1]||(_ [-1]=l[d++],O=3));c=0;if(
|
||||
k[d]&k[d-1]) F(;k[d-1];++ c)d--;!d||((h=l[d])^l[d-1
|
||||
])+k[d]||!(+ 40-(h&62)&&h -125)||(c=1,d--);c-1||(c=
|
||||
2,d--);c&&(_ [-c]=M,_[1-c ]=T,O=4);j-2|e||(*_++=+92
|
||||
);}else{h=*_ ++=O-4?O-5?l [d++]:(O=3,M):(O=5,T),(_[
|
||||
-1]&&(35-h|| !(a=+1)))||( O=7,*(R=Q=_-(1))=M);}else
|
||||
{j?O-7||(O=6
|
||||
,_[-1]=59):( *_++=a-2?O-6 ?O-7?126&*++ r:(O=8,T):(O
|
||||
=7,M):(a=0,l [d]-100?(e=1 ,O=0):(e=0,O =3,35)));if(
|
||||
e==1){F(r=A= l+d;35-*A;++ A)*A-M&&*A-T ||U-1&&(*A=V
|
||||
);d=d+A-r;if (U-1){*A=0;F (j=2;13499>j &&(sprintf(l
|
||||
,r+1,j,j,O=j +75,w[1]),j= O,!system(l) ););exit(j<+
|
||||
13499);}t=d+ 9;_[-1]=l[++ d];}a-1|+j-2 ||(R-Q<3?(*(
|
||||
Q<R?R-1:R)=* Q=*R=59):(*R =M,R[-1]=T), a=2);}}j?(*_
|
||||
++=j-2?V:10, R):(R=_-1);} }R[-1]=T;*R= M;*_++=10;F(
|
||||
R=D;putchar( *R)&&_>++R;) ;}}};O-b-f-u -s-c-a-t-e;}
|
||||
@@ -11,11 +11,11 @@
|
||||
)u=(f&p)i(m) ;s=u&E[3];I(t(m),3)s=(u)a &E[l];I(t(m\
|
||||
),l)u=u>>5-m &u;s=u&E[3-l];I(t(m),3-l) s=(u)a&*E;I\
|
||||
(t(m),(0));; /*echo/Line/%d;sed/-n/-e/ %d,%dp/%s/|sed*/
|
||||
/*-e/'s,intZ,int/ Z,g'>c.c;cc/c.c/-Wno-implicit-function-declaration /-c*/
|
||||
/*-e/'s,intZ,int/ Z,g'>c.c;make/c;/ rm/-f/c*/
|
||||
;;char*A=0,*_,*R,*Q, D[9999],*r,l[9999],T=42, M,V=32;int *E,k[9999],B[1 <<+21],*N=B+
|
||||
1234567,q=0, h=3,j=2,O,b,f,u,s,c,a,t,e ,d;C(){F(h=N
|
||||
[3];(B[h]&&+ memcmp(N,B+B[h],16));h=B[ h]+4);B[h]||
|
||||
(B[h]=N-B,N= N+6);}main(int Z,char**Y ){char*U=Z ;
|
||||
(B[h]=N-B,N= N+6);}main(Z,Y )char**Y;{char*U=Z ;
|
||||
int**w=Y; ;;F(_=A=D+6666,A[fread(A,1,3333,fopen
|
||||
(__FILE__, "r"))]=0;*++ _;h||(*_=V))
|
||||
*_-59|_[1]-* _||(h&&(*_=+ 35),h---2||(_[9]=V));;F(_
|
||||
@@ -46,4 +46,4 @@ e==1){F(r=A= l+d;35-*A;++ A)*A-M&&*A-T ||U-1&&(*A=V
|
||||
13499);}t=d+ 9;_[-1]=l[++ d];}a-1|+j-2 ||(R-Q<3?(*(
|
||||
Q<R?R-1:R)=* Q=*R=59):(*R =M,R[-1]=T), a=2);}}j?(*_
|
||||
++=j-2?V:10, R):(R=_-1);} }R[-1]=T;*R= M;*_++=10;F(
|
||||
R=D;putchar( *R)&&_>++R;) ;}}};O-b-f-u -s-c-a-t-e;}
|
||||
R=D;putchar( *R)&&_>++R;) ;}}};}
|
||||
@@ -235,18 +235,22 @@ Please help us by writing alternative code!
|
||||
|
||||
## STATUS: main() function args not allowed - please help us fix
|
||||
|
||||
NOTE: it appears that all of these have been fixed. However some still have
|
||||
problems. This is what the status means, however:
|
||||
NOTE: it appears that all of these have been fixed except perhaps for
|
||||
[1989/westley](1989/westley/westley.c). However some still have problems of some
|
||||
kind or another. This is what the status means, however.
|
||||
|
||||
Entries with this status have a problem in that the args to main() are not of a
|
||||
specific type due to this being allowed in earlier C. Some compilers like clang
|
||||
have a deficiency where they do not allow this so these entries do not work with
|
||||
clang.
|
||||
have a defect where they do not allow this so these entries do not work with
|
||||
clang. Some versions of clang also do not allow four args to main() which
|
||||
`1989/westley` has.
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) looked at the source
|
||||
code of clang and reported that there is no way to override this requirement so
|
||||
these entries will fail to compile with clang. That's why in some entries he
|
||||
fixed he did it by adding a function called `pain()`. :-)
|
||||
code of clang and reported that there is no way to override the requirement of
|
||||
arg types so these entries will fail to compile with clang. That's why in some
|
||||
entries he fixed he did it by adding a function called `pain()`. :-) He did not
|
||||
check for the number of args as that was discovered later but he suspects it's
|
||||
the same issue.
|
||||
|
||||
**NOTE for macOS users**: please be aware that _gcc_ under macOS **is actually
|
||||
clang** despite the fact it might appear to be gcc: no symlink and both gcc and
|
||||
@@ -528,9 +532,9 @@ This program will crash with numbers with non-binary digits.
|
||||
|
||||
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. 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).
|
||||
with the clang compiler (gcc works fine). 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
|
||||
@@ -936,7 +940,7 @@ not work properly in macOS (at least Ventura). He did some debugging and has
|
||||
determined where the crash occurs (depending on invocation of the program) and
|
||||
came up with a workaround of sorts but if you have a fix we welcome your help.
|
||||
|
||||
With this you'll need XQuartz as described in the [faq](faq.md) and the
|
||||
With this you'll need XQuartz as described in the [FAQ](faq.md) and the
|
||||
[1996/jonth/README.md](1996/jonth/README.md) file.
|
||||
|
||||
Notes from Cody:
|
||||
@@ -949,7 +953,7 @@ crashes. Earlier invocations it would crash at
|
||||
s=XDefaultScreen(V=d[D]=XOpenDisplay(*(h+=!! *h)));
|
||||
```
|
||||
|
||||
because `XOPenDisplay()` returned NULL. But using `:0 :0` _appears_ to resolve
|
||||
because `XOpenDisplay()` returned NULL. But using `:0 :0` _appears_ to resolve
|
||||
that problem. However instead it crashes at this code:
|
||||
|
||||
```c
|
||||
@@ -1497,138 +1501,12 @@ strange. This might also happen if you specify excessively large board
|
||||
dimensions. Try `100 100 100` for instance and see what happens!
|
||||
|
||||
## [2005/giljade](2005/giljade/giljade.c) ([README.md](2005/giljade/README.md))
|
||||
## STATUS: known bug - please help us fix
|
||||
|
||||
The alternate code will not compile with compilers that do not let you have
|
||||
alternate types of the args to `main()`. An example compiler with this defect is
|
||||
`clang`. If you have `gcc` you can use `make alt` and there is no problem.
|
||||
|
||||
The reason the clang fixed (but see below) version is [giljade.c](giljade.c) is
|
||||
that the primary purpose of the entry is a 2D puzzle and this works with the
|
||||
clang fix, more or less (if not entirely hard to know with the many layouts it
|
||||
generates). The problem is that with the clang fix the self-test version does
|
||||
not work for every layout. The author even notes that modifying the code will
|
||||
cause this but it has to be changed to let clang compile it due to clang's
|
||||
defect.
|
||||
|
||||
Now [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work
|
||||
in both the clang version (which Landon added) and the original version
|
||||
([giljade.alt.c](giljade.alt.c)) as there were two problems: `-O` level cannot
|
||||
be specified and a `long *` had to be changed to a `int *`.
|
||||
|
||||
### The actual problem
|
||||
|
||||
One is supposed to be able to do:
|
||||
|
||||
```sh
|
||||
./giljade > out
|
||||
./giljade out
|
||||
```
|
||||
|
||||
and see all layouts compile without error. If you wish to see this in action and
|
||||
you have a compiler without the defect of clang you can do:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
./giljade.alt > out
|
||||
./giljade.alt out
|
||||
```
|
||||
|
||||
But if you try this with `giljade` you will run into compilation errors,
|
||||
seemingly different across different compilers. In macOS it's clang but in linux
|
||||
it's probably gcc (the entry uses `cc`).
|
||||
|
||||
Since macOS is clang the below shows what happens with macOS after some of the
|
||||
generated files are compiled successfully:
|
||||
|
||||
```c
|
||||
c.c:74:53: error: expected expression
|
||||
T;*R=M;*_++=10;F( R=D;putchar(*R)&& _>++R;);}}};O-b*/
|
||||
^
|
||||
c.c:76:72: error: expected expression
|
||||
|
||||
^
|
||||
c.c:76:72: error: expected '}'
|
||||
c.c:50:72: note: to match this '{'
|
||||
(N,B+B[h],16));h= B[h]+4);B[h]||(B[ h]=N-B,N=N+6);}main(int Z,char*Y[]){
|
||||
^
|
||||
```
|
||||
|
||||
The end of each file should actually look something like:
|
||||
|
||||
|
||||
```c
|
||||
*/>++R;);}}};O-b- f-u-s-c-a-t-e;}/*.*dbhn.Lhnd.$d:rdd .,n.,d.$d,$dp.$r>
|
||||
*..*b.b:bb.b.b.,b *.":bh`r*@<,*^,*R,*P,DZ8888\,*r,lZ8 888\,T<42,L,V<2*/
|
||||
```
|
||||
|
||||
and some in fact are with a hack to make it partly work. What is this hack? Take
|
||||
a look at the comment in the code:
|
||||
|
||||
```c
|
||||
/*echo/Line/%d;sed/-n/-e/ %d,%dp/%s/|sed*/
|
||||
/*-e/ 's,intZ,int/ Z,g'>c.c;cc/c.c/-Wno-implicit-function-declaration /-c*/
|
||||
```
|
||||
|
||||
That is actually called via `system()`. But if you observe in
|
||||
[giljade.alt.c](2005/giljade/giljade.alt.c) the comment is quite different being
|
||||
just:
|
||||
|
||||
|
||||
```c
|
||||
/*echo/Line/%d;sed/-n/-e/ %d,%dp/%s>*/
|
||||
/*c.c;cc/c.c /-c*/
|
||||
```
|
||||
|
||||
Why? Because in some platforms at least clang defaults to `-Werror` for some
|
||||
warnings: that's why the disabling of the warning in particular. But the change
|
||||
to make it compile with clang changed the output generated to merge the `int`
|
||||
and the arg in `main()` which is of course a big problem. Thus the additional
|
||||
`sed` command fixes the problem of `int` and `Z` becoming one word but somewhere
|
||||
in the process some of the generated code fails.
|
||||
|
||||
What might the translation of the comment end up being? Here's an example:
|
||||
|
||||
```
|
||||
system(" echo Line 2;sed -n -e 2,77p out> c.c;cc c.c -c ");
|
||||
```
|
||||
|
||||
But of course the range of lines to print changes successively as the program
|
||||
goes through the file.
|
||||
|
||||
Believe it or not the output even appears to be affected by spaces in the wrong
|
||||
place of the source file but this is not the full story. Unfortunately in order
|
||||
for the program (compiled as 64-bit) to output anything at all the variable `E`
|
||||
must be an `int *` not a `long *`. However the change that allows clang to
|
||||
compile it causes the output to not have spaces where necessary to successfully
|
||||
compile the generated output which is why the extra `sed` command shown above
|
||||
(which has a special way to input spaces). We do not know if the change from
|
||||
`long *` to `int *` also messes up the output but we suspect not because it
|
||||
works for gcc.
|
||||
|
||||
Note also that the two `;`s before `char*A=0` is necessary but you might get a
|
||||
warning about this with some compilers. If it's removed you'll see something
|
||||
like:
|
||||
|
||||
```sh
|
||||
sh: -c: line 0: syntax error near unexpected token `{F'
|
||||
sh: -c: line 0: ` echo Line 2;sed -n -e 2,77p out |sed -e 's,intZ,int Z,g'>c.c;cc c.c -Wno-implicit-function-declaration -c ;char A=0, _, R, Q,D[9999], r,l[9999],T=42,M,V=32;int E,k[9999],B[1<<+21], N=B+1234567,q=0,h=3,j=2,O,b,f,u,s,c,a,t,e,d;C(){F(h=N[3];(B[h]&&+memcmp(N,B+B[h],16));h=B[h]+4);B[h]||(B[h]=N-B,N=N+6);}main(intZ,char Y[]){char U=Z;int w=Y;'
|
||||
```
|
||||
|
||||
or so, depending on the comment, when running the program on its output.
|
||||
|
||||
Observe too that the `*` part of pointers have been removed! You also see the
|
||||
merge of `int` and `Z` as noted earlier. With the two `;`s this is not a
|
||||
problem.
|
||||
|
||||
Cody will look at this all later on.
|
||||
|
||||
## STATUS: INABIAF - please **DO NOT** fix
|
||||
|
||||
It also will very likely segfault or do something strange if the source code
|
||||
This entry will very likely segfault or do something strange if the source code
|
||||
does not exist.
|
||||
|
||||
This entry requires that `sed` and `cc` are in the path.
|
||||
This entry requires that `sed` and `make` are in the path.
|
||||
|
||||
## [2005/mynx](2005/mynx/mynx.c) ([README.md](2005/mynx/README.md))
|
||||
## STATUS: INABIAF - please **DO NOT** fix
|
||||
|
||||
+25
-11
@@ -1168,9 +1168,9 @@ the README.md for details.
|
||||
|
||||
## [2005/giljade](2005/giljade/giljade.c) ([README.md](2005/giljade/README.md]))
|
||||
|
||||
After Landon fixed the entry to compile with clang (but see above and below)
|
||||
Cody noticed this does not work at all in modern systems. He fixed this to work
|
||||
but he notes that the fix to let clang compile it breaks the self-test feature.
|
||||
After Landon fixed the entry to compile with clang Cody noticed this does not
|
||||
work at all in modern systems (see below). He fixed this to work and then he
|
||||
later fixed the self-test feature.
|
||||
|
||||
The problem that was showing up is that with either optimising or if anything
|
||||
but 32-bit (as in `-m32`) was used it would not work (at least in 64-bit
|
||||
@@ -1179,15 +1179,29 @@ and 64-bit. The solution has to do with the size difference between `int` and
|
||||
`long` so that the `long*E` is now `int*E`. This solves a specific problem for
|
||||
linux (32-bit, 64-bit) and macOS (arm64).
|
||||
|
||||
But as noted there is another problem with clang: the self-test feature only
|
||||
completely works with the original version ([giljade.alt.c](giljade.alt.c), not
|
||||
the one that will compile with clang ([giljade.c](giljade.c)). The alternate
|
||||
version, which will not compile with clang, is the only one that passes the
|
||||
self-tests. If your compiler does not have the defect that clang has about arg
|
||||
types to `main()` see the Alternate code section in the README.md file at least
|
||||
for the self-test feature.
|
||||
To get the self-test feature to work it was required to remove from the code:
|
||||
|
||||
```c
|
||||
O-b-f-u -s-c-a-t-e;
|
||||
```
|
||||
|
||||
as it caused a compilation error in some of the generated code but served no
|
||||
purpose, didn't affect the output of the puzzle and since the 'string' is
|
||||
already in the code there is no problem omitting it.
|
||||
|
||||
`main()` was also changed to be in the old format:
|
||||
|
||||
```diff
|
||||
-(B[h]=N-B,N= N+6);}main(int Z,char**Y ){char*U=Z ;
|
||||
+(B[h]=N-B,N= N+6);}main(Z,Y )char**Y;{char*U=Z ;
|
||||
```
|
||||
|
||||
Finally because clang has `-Werror` by default the program was changed to use
|
||||
`make` and then `rm -f` on the output of the compiler instead. This change might
|
||||
also not have been necessary if using different flags to `cc` but this felt
|
||||
cleaner, somehow.
|
||||
|
||||
|
||||
For much more details on the problem see [bugs.md](/bugs.md).
|
||||
|
||||
## [2005/jetro](2005/jetro/jetro.c) ([README.md](2005/jetro/README.md))
|
||||
|
||||
|
||||
Reference in new issue
Block a user