From 632275a08951a91157d08f345f7b2fc4286cc911 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Mar 2024 07:06:44 -0700 Subject: [PATCH] Make 2004/burley fix more like original In particular although main() has to have two args don't do (void)argc as that was not in the code. To make it more consistent with other added functions (that I had to do in other entries for instance and for the same reason) I made the function poke() (r short of poker) pain() instead. The thanks file was modified for this entry too, improving it a bit (hopefully making certain points clearer too). --- 2004/burley/Makefile | 2 +- 2004/burley/burley.c | 9 ++++----- thanks-for-help.html | 16 +++++++++++----- thanks-for-help.md | 16 +++++++++++----- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/2004/burley/Makefile b/2004/burley/Makefile index db1a77fa1..84ec2d584 100644 --- a/2004/burley/Makefile +++ b/2004/burley/Makefile @@ -40,7 +40,7 @@ include ../../var.mk # CSILENCE= -Wno-bitwise-op-parentheses -Wno-char-subscripts -Wno-error \ -Wno-implicit-function-declaration -Wno-int-to-pointer-cast \ - -Wno-unused-value + -Wno-unused-value -Wno-unused-parameter # Common C compiler warning flags # diff --git a/2004/burley/burley.c b/2004/burley/burley.c index 2b89cb8fe..9d4e44fe4 100644 --- a/2004/burley/burley.c +++ b/2004/burley/burley.c @@ -1,8 +1,8 @@ char a[80]; int e[4],g[5],c=100,h,i,j,k,b,f,s,t; jmp_buf p[4]; -int poke(char *d){ -return poke((char*)((srand(time((time_t*)&h)), +int pain(char *d){ +return pain((char*)((srand(time((time_t*)&h)), setjmp(p[2]), (k=atoi((fgets(a,sizeof a, stdin), a+strspn(a," -")))) @@ -89,6 +89,5 @@ i+=i+1, longjmp(p[0],0)),0), longjmp(p[2],3)),0)); } -int main(int argc, char**d){ -(void)argc; -return poke((char*)d); } +int main(int argc,char**d){ +return pain((char*)d);} diff --git a/thanks-for-help.html b/thanks-for-help.html index 019c4fb82..39b543f49 100644 --- a/thanks-for-help.html +++ b/thanks-for-help.html @@ -2095,25 +2095,31 @@ use the original version)! :-)

file but a maze file. The extension .maz was not chosen to help with (some?) browsers knowing what to do with it.

2004/burley (index.html)

-

Cody fixed this to compile with clang and also fixed it to work.

+

Cody fixed this to compile with clang and to work with both gcc and +clang (even after fixing it to compile with clang it did not work properly).

For clang the problem was that main() had one arg, a char * and this is not allowed in any version of clang. In some versions it is allowed if the arg is an int but never if it’s anything else. To get it to work took numerous changes.

First the inclusion of setjmp.h was necessary. Without this longjmp(3) implicitly returned int which was used for the purpose of binary expression but -this no longer worked.

+this no longer appeared to work (though it might be that if the extra function +was added earlier on it would but this is unknown and the way it was changed is +safer for the future).

But by including setjmp.h it naturally made the binary expressions invalid (as it returns void which is not allowed in binary expressions) so the comma operator with 0 (,0) had to be used (,1 was tried first but this did not -work right).

+work right so you can see that it had to be false in those places, though it is +unknown by Cody if this is because it used to be allowed to have binary +expression with void or if it is for some other reason).

longjmp(3) was being called with one arg which was an element of an int[4][1000] which had to be changed to a jmp_buf p[4] (this due to the prototype being included).

main() also called itself but this was a problem so it now calls another function poke() which calls itself instead (this is sometimes necessary -nowadays).

+nowadays and other entries had to have this same kind of change, +2001/anonymous being a good example).

Finally the optimiser cannot be enabled so the compiler flags were changed for -this.

+this, forcing -O0.

2004/gavare (index.html)

Cody added three different alternate versions:

diff --git a/thanks-for-help.md b/thanks-for-help.md index d33dcef49..23d554cf2 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3012,7 +3012,8 @@ browsers knowing what to do with it. ## [2004/burley](2004/burley/burley.c) ([index.html](2004/burley/index.html])) -[Cody](#cody) fixed this to compile with clang and also fixed it to work. +[Cody](#cody) fixed this to compile with clang and to work with both gcc and +clang (even after fixing it to compile with clang it did not work properly). For clang the problem was that `main()` had one arg, a `char *` and this is not allowed in any version of clang. In some versions it is allowed if the arg is an @@ -3020,12 +3021,16 @@ allowed in any version of clang. In some versions it is allowed if the arg is an First the inclusion of `setjmp.h` was necessary. Without this `longjmp(3)` implicitly returned `int` which was used for the purpose of binary expression but -this no longer worked. +this no longer appeared to work (though it might be that if the extra function +was added earlier on it would but this is unknown and the way it was changed is +safer for the future). But by including `setjmp.h` it naturally made the binary expressions invalid (as it returns `void` which is not allowed in binary expressions) so the comma operator with `0` (`,0`) had to be used (`,1` was tried first but this did not -work right). +work right so you can see that it had to be false in those places, though it is +unknown by Cody if this is because it used to be allowed to have binary +expression with `void` or if it is for some other reason). `longjmp(3)` was being called with one arg which was an element of an `int[4][1000]` which had to be changed to a `jmp_buf p[4]` (this due to @@ -3033,10 +3038,11 @@ the prototype being included). `main()` also called itself but this was a problem so it now calls another function `poke()` which calls itself instead (this is sometimes necessary -nowadays). +nowadays and other entries had to have this same kind of change, +[2001/anonymous](/2001/anonymous/index.html) being a good example). Finally the optimiser cannot be enabled so the compiler flags were changed for -this. +this, forcing `-O0`. ## [2004/gavare](2004/gavare/gavare.c) ([index.html](2004/gavare/index.html]))