Reverse reversal of alt/original 2005/giljade code
In other words now the version that can compile with clang is the giljade.c and the other is giljade.alt.c. The reason is that the actual award is about a 2D puzzle and this still works with the clang compilable version. It also lets those who are forced to use clang compile the code and at least enjoy the puzzle. The Makefile has been updated to remove the note about clang or rather reworded so that the user is made aware that the alt version will run the self-test but the original will not and to see the README.md for more details.
This commit is contained in:
1 parent
85599f1571
commit
dbd9994ca4
5 files changed
+85
-74
No files matched your search
@@ -134,8 +134,8 @@ all: data ${TARGET}
|
|||||||
supernova deep_magic magic charon pluto
|
supernova deep_magic magic charon pluto
|
||||||
|
|
||||||
${PROG}: ${PROG}.c
|
${PROG}: ${PROG}.c
|
||||||
@echo "NOTE: this version requires non-standard args to main() and will fail with"
|
@echo "NOTE: this version cannot successfully run the self-test. Use make alt"
|
||||||
@echo "some compilers like clang. Try make alt for such compilers."
|
@echo "for a version which will work. See README.md for why it is this way."
|
||||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||||
|
|
||||||
# alternative executable
|
# alternative executable
|
||||||
|
|||||||
+34
-32
@@ -11,9 +11,15 @@ make
|
|||||||
```
|
```
|
||||||
|
|
||||||
NOTE: if you do not have access to a compiler that lets you have alternative arg
|
NOTE: if you do not have access to a compiler that lets you have alternative arg
|
||||||
types to `main()` you must use the alternate code. This is hopefully just a
|
types to `main()` the self-test feature will fail. If your compiler does not
|
||||||
temporary problem but it's a complicated problem as well. See 'To run' and
|
have this defect you can use the Alternate code described below. The reason to
|
||||||
'Alternate code' sections as well as [bugs.md](/bugs.md) for more information.
|
have it as the alternate version is that there is more to the entry that can
|
||||||
|
still be enjoyed with compilers with the `main()` args defect including the
|
||||||
|
primary purpose of the entry, a puzzle.
|
||||||
|
|
||||||
|
Hopefully this will be resolved in time where there is no need for an alternate
|
||||||
|
version but it's a complicated one. See also the [bugs.md](/bugs.md) file for
|
||||||
|
more information.
|
||||||
|
|
||||||
## To run:
|
## To run:
|
||||||
|
|
||||||
@@ -21,23 +27,25 @@ temporary problem but it's a complicated problem as well. See 'To run' and
|
|||||||
./giljade
|
./giljade
|
||||||
```
|
```
|
||||||
|
|
||||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this for modern
|
After Landon fixed the entry to compile with clang (but see above and below)
|
||||||
systems but there was a problem with both the clang fixed version (which Landon
|
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) noticed this does not
|
||||||
originally put in but Cody further fixed so that it would work somewhat) and the
|
work at all in modern systems. He fixed this to work but he notes that the fix
|
||||||
original version. There remains a problem with the clang version.
|
to let clang compile it breaks the self-test feature.
|
||||||
|
|
||||||
The problem that was showing up is that with either optimising or anything but
|
The problem that was showing up is that with either optimising or if anything
|
||||||
32-bit was used it would not work. The optimising cannot be used still but it
|
but 32-bit (as in `-m32`) was used it would not work (at least in 64-bit
|
||||||
now works with both 32-bit and 64-bit. The solution has to do with the size
|
systems?). The optimising cannot be used still but it now works with both 32-bit
|
||||||
difference between `int` and `long` so that the `long *E` is now `int *E`. This
|
and 64-bit. The solution has to do with the size difference between `int` and
|
||||||
solves a specific problem for linux (32-bit, 64-bit) and macOS (arm64).
|
`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
|
But as noted there is another problem with clang: the self-test feature only
|
||||||
completely works with the original version, not the one that will compile with
|
completely works with the original version ([giljade.alt.c](giljade.alt.c)), not
|
||||||
clang. The alt version only passes some of its tests. If your compiler does not
|
the one that will compile with clang ([giljade.c](giljade.c)). The alternate
|
||||||
have the defect that clang has about arg types to `main()` you can use
|
version, which will not compile with clang, is the only one that passes the
|
||||||
successfully run the self-test feature completely. Otherwise see the Alternate
|
self-tests. If your compiler does not have the defect that clang has about arg
|
||||||
code section below.
|
types to `main()` see the Alternate code section below at least for the
|
||||||
|
self-test feature.
|
||||||
|
|
||||||
Thank you Cody for your assistance!
|
Thank you Cody for your assistance!
|
||||||
|
|
||||||
@@ -61,23 +69,11 @@ vi out
|
|||||||
|
|
||||||
Press ^F (control F) repeatedly.
|
Press ^F (control F) repeatedly.
|
||||||
|
|
||||||
### Also try:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
./giljade > out
|
|
||||||
./giljade out
|
|
||||||
```
|
|
||||||
|
|
||||||
NOTE: this will only completely work with the original version at least at this
|
|
||||||
time.
|
|
||||||
|
|
||||||
### Alternate code:
|
### Alternate code:
|
||||||
|
|
||||||
This version is compilable with clang but as noted the self-test feature is
|
This version will work only with compilers that let you have alternate types to
|
||||||
incomplete. It did not work at all but Cody added a hack to make part of it work
|
the args of `main()` and will also successfully run its self-test (the other
|
||||||
until this can be looked at further. See also the [bugs.md](/bugs.md) file.
|
version only runs some of them successfully). To use:
|
||||||
|
|
||||||
If you have clang you can use this version like:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make alt
|
make alt
|
||||||
@@ -85,6 +81,12 @@ make alt
|
|||||||
|
|
||||||
Use `giljade.alt` as you would `giljade` above.
|
Use `giljade.alt` as you would `giljade` above.
|
||||||
|
|
||||||
|
#### Try:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./giljade.alt > out
|
||||||
|
./giljade.alt out
|
||||||
|
```
|
||||||
|
|
||||||
## Judges' remarks:
|
## Judges' remarks:
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,14 @@
|
|||||||
\
|
\
|
||||||
)u=(f&p)i(m) ;s=u&E[3];I(t(m),3)s=(u)a &E[l];I(t(m\
|
)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\
|
),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*/
|
(t(m),(0));; /*echo/Line/%d;sed/-n/-e/ %d,%dp/%s>*/
|
||||||
/*-e/ 's,intUa,int/ Ua,g'>c.c;cc/c.c/-Wno-implicit-function-declaration /-c*/
|
/*c.c;cc/c.c /-c*/;;char*A=0,*_,*R,*Q, D[9999],*r,l
|
||||||
;;char*A=0,*_,*R,*Q, D[9999],*r,l[9999],T=42, M,V=32;int*E,k[9999],B[1 <<+21],*N=B+
|
[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
|
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]||
|
[3];(B[h]&&+ memcmp(N,B+B[h],16));h=B[ h]+4);B[h]||
|
||||||
(B[h]=N-B,N= N+6);}main(int Ua,char **wa){char*U
|
(B[h]=N-B,N= N+6);}main(char*U,int*w[] ){;;F(_=A=D+
|
||||||
=Ua;int**w= wa;;F(_=A=D+6666,A[fread(A,1,3333,fopen
|
6666,A[fread (A,1,3333,fopen(__FILE__, "r"))]=0;*++
|
||||||
(__FILE__, "r"))]=0;*++ _;h||(*_=V))
|
_;h||(*_=V))
|
||||||
*_-59|_[1]-* _||(h&&(*_=+ 35),h---2||(_[9]=V));;F(_
|
*_-59|_[1]-* _||(h&&(*_=+ 35),h---2||(_[9]=V));;F(_
|
||||||
=A;*_;_++)10 -*_&&*_-V&&( *_-92)&&(k[q]=isalnum(l[q
|
=A;*_;_++)10 -*_&&*_-V&&( *_-92)&&(k[q]=isalnum(l[q
|
||||||
]=*_),q++);M =47;*(E=N-6) =64;E[1]=289;E[2]=270336;
|
]=*_),q++);M =47;*(E=N-6) =64;E[1]=289;E[2]=270336;
|
||||||
|
|||||||
@@ -10,14 +10,14 @@
|
|||||||
\
|
\
|
||||||
)u=(f&p)i(m) ;s=u&E[3];I(t(m),3)s=(u)a &E[l];I(t(m\
|
)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\
|
),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>*/
|
(t(m),(0));; /*echo/Line/%d;sed/-n/-e/ %d,%dp/%s/|sed*/
|
||||||
/*c.c;cc/c.c /-c*/;;char*A=0,*_,*R,*Q, D[9999],*r,l
|
/*-e/ 's,intZ,int/ Z,g'>c.c;cc/c.c/-Wno-implicit-function-declaration /-c*/
|
||||||
[9999],T=42, M,V=32;int*E,k[9999],B[1 <<+21],*N=B+
|
;;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
|
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]||
|
[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+
|
(B[h]=N-B,N= N+6);}main(int Z,char*Y[] ){char*U=Z;int**w=Y;
|
||||||
6666,A[fread (A,1,3333,fopen(__FILE__, "r"))]=0;*++
|
;;F(_=A=D+6666,A[fread(A,1,3333,fopen
|
||||||
_;h||(*_=V))
|
(__FILE__, "r"))]=0;*++ _;h||(*_=V))
|
||||||
*_-59|_[1]-* _||(h&&(*_=+ 35),h---2||(_[9]=V));;F(_
|
*_-59|_[1]-* _||(h&&(*_=+ 35),h---2||(_[9]=V));;F(_
|
||||||
=A;*_;_++)10 -*_&&*_-V&&( *_-92)&&(k[q]=isalnum(l[q
|
=A;*_;_++)10 -*_&&*_-V&&( *_-92)&&(k[q]=isalnum(l[q
|
||||||
]=*_),q++);M =47;*(E=N-6) =64;E[1]=289;E[2]=270336;
|
]=*_),q++);M =47;*(E=N-6) =64;E[1]=289;E[2]=270336;
|
||||||
|
|||||||
@@ -1581,24 +1581,24 @@ dimensions. Try `100 100 100` for instance and see what happens!
|
|||||||
## [2005/giljade](2005/giljade/giljade.c) ([README.md](2005/giljade/README.md))
|
## [2005/giljade](2005/giljade/giljade.c) ([README.md](2005/giljade/README.md))
|
||||||
## STATUS: known bug - please help us fix
|
## STATUS: known bug - please help us fix
|
||||||
|
|
||||||
This is currently for the [alt version](2005/giljade/giljade.alt.c) of the code:
|
The alternate code will not compile with compilers that do not let you have
|
||||||
due to clang's defect where it requires args of main() to be of a specific type
|
alternate types of the args to `main()`. An example compiler with this defect is
|
||||||
the code had to be changed. However when this happens the code no longer works
|
`clang`. If you have `gcc` you can use `make alt` and there is no problem.
|
||||||
properly. [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the
|
|
||||||
entry to work itself but Landon made the original alt version. This also however
|
|
||||||
did not work due to some other issues that had to be worked out.
|
|
||||||
|
|
||||||
First the optimisation had to be disabled. Second is that for this to do
|
The reason the clang fixed (but see below) version is [giljade.c](giljade.c) is
|
||||||
anything (except perhaps crash .. I (Cody) cannot recall now exactly) in 64-bit
|
that the primary purpose of the entry is a 2D puzzle and this works with the
|
||||||
systems (and also 32-bit compilation via `-m32`) the `long*E` had to be changed
|
clang fix, more or less (if not entirely hard to know with the many layouts it
|
||||||
to `int*E`. These changes let it work properly for compilers that do not have
|
generates). The problem is that with the clang fix the self-test version does
|
||||||
the defect described above but then there is clang.
|
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.
|
||||||
|
|
||||||
At first we had the clang fix be the [giljade.c](2005/giljade/giljade.c) file
|
Now [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work
|
||||||
but since it does not fully work we for now have swapped the alt and the
|
in both the clang version (which Landon added) and the original version
|
||||||
original until such a time that it can be fixed for clang too. The below
|
([giljade.alt.c](giljade.alt.c)) as there were two problems: `-O` level cannot
|
||||||
describes the problem with the alt version, that which will only partially work
|
be specified and a `long *` had to be changed to a `int *`.
|
||||||
with clang.
|
|
||||||
|
### The actual problem
|
||||||
|
|
||||||
One is supposed to be able to do:
|
One is supposed to be able to do:
|
||||||
|
|
||||||
@@ -1610,9 +1610,16 @@ One is supposed to be able to do:
|
|||||||
and see all layouts compile without error. If you wish to see this in action and
|
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:
|
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`).
|
||||||
|
|
||||||
But if you try this with the alt code we run into some problems depending on
|
|
||||||
what `cc` is in the system. In macOS it's clang but in linux it's probably gcc.
|
|
||||||
Since macOS is clang the below shows what happens with macOS after some of the
|
Since macOS is clang the below shows what happens with macOS after some of the
|
||||||
generated files are compiled successfully:
|
generated files are compiled successfully:
|
||||||
|
|
||||||
@@ -1625,7 +1632,7 @@ c.c:76:72: error: expected expression
|
|||||||
^
|
^
|
||||||
c.c:76:72: error: expected '}'
|
c.c:76:72: error: expected '}'
|
||||||
c.c:50:72: note: to match this '{'
|
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 Ua,char**wa){
|
(N,B+B[h],16));h= B[h]+4);B[h]||(B[ h]=N-B,N=N+6);}main(int Z,char*Y[]){
|
||||||
^
|
^
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -1642,12 +1649,12 @@ a look at the comment in the code:
|
|||||||
|
|
||||||
```c
|
```c
|
||||||
/*echo/Line/%d;sed/-n/-e/ %d,%dp/%s/|sed*/
|
/*echo/Line/%d;sed/-n/-e/ %d,%dp/%s/|sed*/
|
||||||
/*-e/ 's,intUa,int/ Ua,g'>c.c;cc/c.c/-Wno-implicit-function-declaration /-c*/
|
/*-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
|
That is actually called via `system()`. But if you observe in
|
||||||
[giljade.c](2005/giljade/giljade.c) the comment is quite different being just:
|
[giljade.alt.c](2005/giljade/giljade.alt.c) the comment is quite different being
|
||||||
|
just:
|
||||||
|
|
||||||
|
|
||||||
```c
|
```c
|
||||||
@@ -1659,8 +1666,8 @@ 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
|
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`
|
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
|
and the arg in `main()` which is of course a big problem. Thus the additional
|
||||||
`sed` command fixes this problem but somewhere in the process some of the
|
`sed` command fixes the problem of `int` and `Z` becoming one word but somewhere
|
||||||
generated code fails.
|
in the process some of the generated code fails.
|
||||||
|
|
||||||
What might the translation of the comment end up being? Here's an example:
|
What might the translation of the comment end up being? Here's an example:
|
||||||
|
|
||||||
@@ -1677,23 +1684,25 @@ 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
|
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 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
|
compile the generated output which is why the extra `sed` command shown above
|
||||||
(which has a special way to input spaces). But it can show up in other ways too.
|
(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
|
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
|
warning about this with some compilers. If it's removed you'll see something
|
||||||
like:
|
like:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sh: -c: line 0: ` echo Line 2;sed -n -e 2,77p out> 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);}intmain(intUa,char wa){char U=Ua;int w=wa'
|
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.
|
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
|
Observe too that the `*` part of pointers have been removed! You also see the
|
||||||
merge of `int` and `Ua` as noted earlier. With the two `;`s this is not a
|
merge of `int` and `Z` as noted earlier. With the two `;`s this is not a
|
||||||
problem.
|
problem.
|
||||||
|
|
||||||
|
|
||||||
Cody will look at this all later on.
|
Cody will look at this all later on.
|
||||||
|
|
||||||
## STATUS: INABIAF - please **DO NOT** fix
|
## STATUS: INABIAF - please **DO NOT** fix
|
||||||
|
|||||||
Reference in new issue
Block a user