From 5d1b7391007d3b5168367c2809422e464e0393a3 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 3 Jul 2023 11:48:05 -0700 Subject: [PATCH 1/3] Remove duplicate alt rule in 1989/westley/Makefile --- 1989/westley/Makefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/1989/westley/Makefile b/1989/westley/Makefile index ec5e061e1..9b97834c2 100644 --- a/1989/westley/Makefile +++ b/1989/westley/Makefile @@ -137,11 +137,6 @@ ${PROG}: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} -# alternative executable -# -alt: data ${ALT_TARGET} - @${TRUE} - ver0: ${PROG} ./${PROG} < westley.c > ver0.c -${CC} ${CFLAGS} ver0.c -o $@ ${LIBS} From 61de38e6f0186ac3e613bac7c7b213a5d737dc6f Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 4 Jul 2023 08:41:12 -0700 Subject: [PATCH 2/3] Fix 2004/burley There were two things that had to change with my previous fix (getting it to compile), one in code and one in the Makefile. Instead of doing ',1' after the calls to longjmp() do ',0'. The way it originally was is in binary expressions but since the function returns void I made the result be 0 rather than 1 and along with the other change it works (though maybe it would work with 1 anyway but it seems not to be necessary and I don't feel like testing it now). The Makefile change is that it won't work right with the optimiser enabled so that was disabled. I removed this entry from bugs.md (which was listed twice by accident - and some other things were too) and updated it in the thanks-for-fixes.md file as well. --- 2004/burley/Makefile | 2 +- 2004/burley/burley.c | 32 +++++------ bugs.md | 134 +++++-------------------------------------- thanks-for-fixes.md | 19 +++--- 4 files changed, 41 insertions(+), 146 deletions(-) diff --git a/2004/burley/Makefile b/2004/burley/Makefile index b5ac4c3a5..1117fd2bb 100644 --- a/2004/burley/Makefile +++ b/2004/burley/Makefile @@ -66,7 +66,7 @@ CINCLUDE= -include stdio.h -include setjmp.h -include string.h -include time.h - # Optimization # -OPT= -O3 +OPT= # Default flags for ANSI C compilation # diff --git a/2004/burley/burley.c b/2004/burley/burley.c index cdaa2c222..2b89cb8fe 100644 --- a/2004/burley/burley.c +++ b/2004/burley/burley.c @@ -19,31 +19,31 @@ setjmp(p[0]), setjmp(p[3]), (i||!++i)&&((h--||(k|=i), i/=2, -longjmp(p[3],4)),1), -longjmp(p[0],1)),1), +longjmp(p[3],4)),0), +longjmp(p[0],0)),0), k^=-1, k+=1<<037, setjmp(p[3]), k&&(((--i<5&&1&k)&&(s=(rand()>>9)%0x4, setjmp(p[0]), t+=(rand()>>3)%015-t, -e[s]&(1<>=1, i+=1<<1, -longjmp(p[3],4)),1), +longjmp(p[3],4)),0), setjmp(p[0]), putchar(0x20+!putchar(012+"(.7-A,G+@*J)/"[(017&(i=g[4-k]))*013%13])), -++k^005&&(longjmp(p[0],1),1), +++k^005&&(longjmp(p[0],0),0), putchar('\n'), setjmp(p[3]), putchar(0x1F+!!putchar(("BCDHS"[g[--k]>>4]))), -k&&(longjmp(p[3],4),1), +k&&(longjmp(p[3],4),0), putchar('\n'), j+=1<<0, 1^j||(d=(char*)fgets(a,sizeof a, stdin)), -longjmp(p[1],2)),1), +longjmp(p[1],2)),0), s=1==(f=0), i=0<<1, setjmp(p[3]), @@ -53,13 +53,13 @@ j<5&&(((017&g[j])>(g[i]&15)&&(k=g[i], g[i]=g[j], g[j]=k), j++, -longjmp(p[1],2)),1), +longjmp(p[1],2)),0), i++, -longjmp(p[3],4)),1), +longjmp(p[3],4)),0), setjmp(p[0]), -i--&&!((g[1+i]^g[i])>>4)&&(longjmp(p[0],1),1), +i--&&!((g[1+i]^g[i])>>4)&&(longjmp(p[0],0),0), setjmp(p[1]), ---j&&(!(k=(g[j]&15)-(g[j-1]&017)+1)||(!(j-1)&&(8==-k)))&&(longjmp(p[1],2),1), +--j&&(!(k=(g[j]&15)-(g[j-1]&017)+1)||(!(j-1)&&(8==-k)))&&(longjmp(p[1],2),0), s+=3*!j|!(++i^17), (j*=i*=4)&&(i=1), setjmp(p[3]), @@ -68,9 +68,9 @@ setjmp(p[1]), 5-i>j&&(((g[j]^g[j+1])&0xf?g[j]^=g[j]:(s+=((g[j]&0xf)>8&&f++, !!g[j]*i)), j++, -longjmp(p[1],2)),1), +longjmp(p[1],2)),0), i++, -longjmp(p[3],4)),1), +longjmp(p[3],4)),0), s=1^s?"AACEDJQZHello World"[s]-'A':!!f, s+=(!i)*(6+12*s-!!s*((g[2]&017)^0xa?8:-192)), s--, @@ -84,10 +84,10 @@ setjmp(p[0]), setjmp(p[1]), 0<=j&&((e[i+j]^=*(i-j+e+(j<<1)), --j, -longjmp(p[1],2)),1), +longjmp(p[1],2)),0), i+=i+1, -longjmp(p[0],1)),1), -longjmp(p[2],3)),1)); +longjmp(p[0],0)),0), +longjmp(p[2],3)),0)); } int main(int argc, char**d){ (void)argc; diff --git a/bugs.md b/bugs.md index c80a3b4ad..3fee61baa 100644 --- a/bugs.md +++ b/bugs.md @@ -252,9 +252,9 @@ fixed he did it by adding a function called `pain()`. :-) clang** despite the fact it might appear to be gcc: no symlink and both gcc and clang exist but the gcc is clang which you'll see if you run `gcc --version`. -A tip and some fix methods from Cody: in the older days args not given a type -were implicit ints but when they're required to be char ** this can cause a -problem. In some cases Cody was able to use a char * inside main() (see +A tip and some fix methods from Cody: in the older days args to main() not given +a type were implicit ints but when they're required to be char ** this can cause +a problem. In some cases Cody was able to use a char * inside main() (see [1989/tromp/tromp.c](1989/tromp/tromp.c) and [1986/holloway/holloway.c](1986/holloway) for two examples though done slightly differently). In other cases he was able to dereference the pointers to be used @@ -606,6 +606,7 @@ This entry will very likely crash or do something strange without an arg. This entry will also enter an infinite loop if input is not a number > 0. + # 1991 ## [1991/dds](1991/dds/dds.c) ([README.md)(1991/dds/README.md)) @@ -643,8 +644,8 @@ possibility. Can you find out how? ## [1992/buzzard.1](1992/buzzard.1/buzzard.1.c) ([README.md](1992/buzzard.1/README.md)) ## STATUS: INABIAF - please **DO NOT** fix -This entry will crash without enough args (2). At this time this is not -considered a bug to fix so it should not be fixed. +This entry will crash without enough args (2). + ## [1992/kivinen](1992/kivinen/kivinen.c) ([README.md](1992/kivinen/README.md)) ## STATUS: known bug - please help us fix @@ -669,7 +670,7 @@ This program and the alternate version will very likely crash or [nuke](https://en.wikipedia.org/wiki/Nuclear_weapon) the [entire world](https://en.wikipedia.org/wiki/Earth) or just the [USA](https://en.wikipedia.org/wiki/United_States), respectively, without enough -args. This should not be fixed. +args. This should not be fixed! :-) # 1993 @@ -700,11 +701,12 @@ else. This should NOT be fixed. ## STATUS: known bug - please help us fix [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to compile -with modern systems (see the README.md file for what had to change) but the -entry also used `gets()` which in some systems would print out a warning along -with the output of the program. Naturally it could also overflow long lines. -Cody changed it to `fgets()` to prevent the display problem but this introduces -another problem namely that newlines can be printed if the line length < 231. +with modern systems (see the [thanks-for-fixes.md](thanks-for-fixes.md) file for +what had to change) but the entry also used `gets()` which in some systems would +print out a warning along with the output of the program. Naturally it could +also overflow long lines. Cody changed it to `fgets()` to prevent the display +problem but this introduces another problem namely that newlines can be printed +if the line length < 231. This seems like a worthy compromise but it would be ideal for it to never print a newline unless that's the line itself (a blank line). @@ -1182,7 +1184,6 @@ animation but this does not seem to work with modern gcc versions. It appears that version 2.95 works but maybe others do as well. Do you have a fix? We would appreciate your help! -Do you have a fix for 64-bit compilation? Please provide it! ## [2001/kev](2001/kev/kev.c) ([README.md](2001/kev/README.md) ## STATUS: INABIAF - please **DO NOT** fix @@ -1231,56 +1232,8 @@ There was no IOCCC in 2002. There was no IOCCC in 2003. -# 2004 -## [2004/burley](2004/burley/burley.c) ([README.md](2004/burley/README.md)) -## STATUS: known bug - please help us fix - -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to compile -with clang. He notes however that both prior to the fix (with gcc) and after the -fix (gcc, clang) it does not work: it allows input of the bet but after it -prints the hand it does not do anything with your next move. Cody provided the -following notes and tips (including possible reasons it doesn't work): - -0. Originally the `jmp_buf` was just an `int p[4][1000]`. -1. The `setjmp.h` header file was not included so the calls to `longjmp()` had -not only the wrong number of arguments but also implicitly returned int when it -actually returns void. This means that the comma operator had to be used to get -the binary expressions to work. It might be this is part of the problem. It's -possible that actually changing this introduced it to not work as some old -entries actually use invalid prototypes and work but changing them to use the -proper prototype breaks them. -2. Another possible problem is the abuse of `setjmp()` and `longjmp()` which is -known to be a problem, at least as he interprets it in his tired head (and less -experience with `longjmp`). In particular: - > The longjmp() routines may not be called after the routine which called the - > setjmp() routines returns. - See also the NOTES section of the linux man pages for `setjmp(3)` and - `longjmp(3)`. -3. The main() originally returned a call to main() which appeared to be an -infinite recursion at least as it was; now it returns a call to poke() (since -it's a poker game) which has the same number and type of args (1, `char *`) that -main() originally had. This appears to not be an infinite recursion but I might -be reading it wrong. Changing it to not return itself and the same problem -occurs so perhaps this is not the problem. It's possible that the initial call -to the `poke()` function is incorrect. -4. It might be that the requirement of the comma operator in modern compilers is -a problem. Perhaps some instances of `,1` should be `,0`? That seems plausible -as they are often used with the `&&` operator. -5. As well main() had only one arg, a `char *`, and there was a (seemingly) -needless cast to `char *` from gets(). This cast remains in the code however. -6. The code no longer uses `gets()` but `fgets()`; this is not the problem -however. -7. Sometimes the lack of a _proper_ prototype lets code work if the function is -used incorrectly so one should be careful with adding the proper prototypes. -With this entry it didn't _appear_ to be relevant but maybe it is after another -change? - -# 1997 - -There was no IOCCC in 1997. - # 1998 ## [1998/schnitzi](1998/schnitzi/schnitzi.c) ([README.md](1998/schnitzi/README.md)) @@ -1325,12 +1278,6 @@ There was no IOCCC in 1999. # 2000 -## [2000/dlowe](2000/dlowe/dlowe.c) ([README.md](2000/dlowe/README.md)) -## STATUS: doesn't work with some platforms - please help us fix - -This entry crashes in macOS. This will be looked at later. - - [2000/primenum](2000/primenum/primenum.c) ([README.md](2000/primenum/README.md)) ## STATUS: INABIAF - please **DO NOT** fix @@ -1393,49 +1340,6 @@ There was no IOCCC in 2003. # 2004 -## [2004/burley](2004/burley/burley.c) ([README.md](2004/burley/README.md)) -## STATUS: known bug - please help us fix - -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to compile -with clang. He notes however that both prior to the fix (with gcc) and after the -fix (gcc, clang) it does not work: it allows input of the bet but after it -prints the hand it does not do anything with your next move. Cody provided the -following notes and tips (including possible reasons it doesn't work): - -0. Originally the `jmp_buf` was just an `int p[4][1000]`. -1. The `setjmp.h` header file was not included so the calls to `longjmp()` had -not only the wrong number of arguments but also implicitly returned int when it -actually returns void. This means that the comma operator had to be used to get -the binary expressions to work. It might be this is part of the problem. It's -possible that actually changing this introduced it to not work as some old -entries actually use invalid prototypes and work but changing them to use the -proper prototype breaks them. -2. Another possible problem is the abuse of `setjmp()` and `longjmp()` which is -known to be a problem, at least as he interprets it in his tired head (and less -experience with `longjmp`). In particular: -> The longjmp() routines may not be called after the routine which called the -> setjmp() routines returns. -See also the NOTES section of the linux man pages for `setjmp(3)` and -`longjmp(3)`. -3. The main() originally returned a call to main() which appeared to be an -infinite recursion at least as it was; now it returns a call to poke() (since -it's a poker game) which has the same number and type of args (1, `char *`) that -main() originally had. This appears to not be an infinite recursion but I might -be reading it wrong. Changing it to not return itself and the same problem -occurs so perhaps this is not the problem. It's possible that the initial call -to the `poke()` function is incorrect. -4. It might be that the requirement of the comma operator in modern compilers is -a problem. Perhaps some instances of `,1` should be `,0`? That seems plausible -as they are often used with the `&&` operator. -5. As well main() had only one arg, a `char *`, and there was a (seemingly) -needless cast to `char *` from gets(). This cast remains in the code however. -6. The code no longer uses `gets()` but `fgets()`; this is not the problem -however. -7. Sometimes the lack of a _proper_ prototype lets code work if the function is -used incorrectly so one should be careful with adding the proper prototypes. -With this entry it didn't _appear_ to be relevant but maybe it is after another -change? - ## [2004/gavin](2004/gavin/gavin.c) ([README.md](2004/gavin//README.md)) ## STATUS: compiled executable crashes - please help us fix @@ -1654,7 +1558,7 @@ in the process some of the generated code fails. What might the translation of the comment end up being? Here's an example: -```c +``` system(" echo Line 2;sed -n -e 2,77p out> c.c;cc c.c -c "); ``` @@ -1695,7 +1599,6 @@ does not exist. This entry requires that `sed` and `cc` are in the path. - ## [2005/mynx](2005/mynx/mynx.c) ([README.md](2005/mynx/README.md)) ## STATUS: INABIAF - please **DO NOT** fix @@ -2082,15 +1985,6 @@ Abort trap: 6 but this is expected and the file `ioccc.html` will be generated properly. -## [2018/poikola](2018/poikola/prog.c) ([README.md](2018/poikola/README.md])) -## STATUS: INABIAF - please **DO NOT** fix - -Some have reported that Terminal.app in macOS does not work and one might need a -different terminal emulator like that from [XQuartz](https://www.xquartz.org) -but [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) reported that this -works fine in macOS Ventura with Terminal.app. YMMV of course. - - # 2019 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index eb322e282..614f3792e 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -926,11 +926,10 @@ your keyboard instead of the more awkward '`,`' and '`.`'. ## [2001/westley](2001/westley/westley.c) ([README.md](2001/westley/README.md])) -Cody added the script -[westley.sh](westley.sh) to automate a heap of commands that we, the IOCCC -judges, suggested, as well as some additional ones that he thought would be fun. -He also provided the sort and punch card versions that he added, described in -the README.md, based on the author's remarks. +Cody added the script [westley.sh](westley.sh) to automate a heap of commands +that we, the IOCCC judges, suggested, as well as some additional ones that he +thought would be fun. He also provided the sort and punch card versions that he +added, described in the README.md, based on the author's remarks. ## [2004/arachnid](2004/arachnid/arachnid.c) ([README.md](2004/arachnid/README.md])) @@ -941,10 +940,12 @@ Dvorak typists are invited to get lost (or use the original version)! :-) ## [2004/burley](2004/burley/burley.c) ([README.md](2004/burley/README.md])) -Cody fixed this to compile with clang which requires that the first arg of -main() be an int and the remaining args to be a `char **`. Compile but not work. -It did not work before the fix when compiled with gcc and it does not work with -clang either. See [/bugs.md](/bugs.md) for information. +Cody fixed this to compile with clang and also fixed it to work. A problem was +that `longjmp()` was being used with one arg which compiled because `setjmp.h` +was not included. Another part of the `setjmp()`/`longjmp()` situation was that +instead of `jmp_buf` the array `p` was of `int`. Finally the optimiser cannot be +enabled. As for clang it is because of the defect where the first arg must be an +int and the rest must be a `char **`. ## [2004/gavin](2004/gavin/gavin.c) ([README.md](2004/gavin/README.md])) From 3f197122306362e64134956a74dae4898f3522b8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 4 Jul 2023 09:23:03 -0700 Subject: [PATCH 3/3] Add alt code for 2000/thadgavin This version allows for delaying between the writing of characters (for curses) or pixels (for SDL). I explained how to reconfigure it in the README.md file. This is useful for more modern systems as well as if you're sensitive to rapid swirling. Typo fixes in README.md. --- 2000/thadgavin/.gitignore | 2 + 2000/thadgavin/Makefile | 15 ++++-- 2000/thadgavin/README.md | 38 ++++++++++++-- 2000/thadgavin/thadgavin.alt.c | 93 ++++++++++++++++++++++++++++++++++ thanks-for-fixes.md | 6 +++ 5 files changed, 147 insertions(+), 7 deletions(-) create mode 100644 2000/thadgavin/thadgavin.alt.c diff --git a/2000/thadgavin/.gitignore b/2000/thadgavin/.gitignore index 5aeb20c6b..4b26fde7d 100644 --- a/2000/thadgavin/.gitignore +++ b/2000/thadgavin/.gitignore @@ -1,2 +1,4 @@ thadgavin thadgavin_sdl +thadgavin.alt +thadgavin.alt_sdl diff --git a/2000/thadgavin/Makefile b/2000/thadgavin/Makefile index 652f70d46..65e3070c0 100644 --- a/2000/thadgavin/Makefile +++ b/2000/thadgavin/Makefile @@ -57,11 +57,11 @@ ARCH= # Defines that are needed to compile # -CDEFINE= +CDEFINE= -DZ=30 -DZS=150000 # Include files that are needed to compile # -CINCLUDE= +CINCLUDE= -include unistd.h # Optimization # @@ -113,8 +113,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# @@ -140,6 +140,13 @@ ${PROG}_sdl: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + + +${PROG}.alt_sdl: ${PROG}.alt.c + ${CC} ${CFLAGS} -DSDL `${SDL1_CONFIG} --cflags` $< -o $@ ${LIBS} `${SDL1_CONFIG} --libs` + # data files # data: ${DATA} diff --git a/2000/thadgavin/README.md b/2000/thadgavin/README.md index d3360ffc3..b335a4c5a 100644 --- a/2000/thadgavin/README.md +++ b/2000/thadgavin/README.md @@ -22,7 +22,7 @@ make NOTE: the author suggested `-O6` but at least some gcc versions support no more than level 3 which is what the Makefile has. -To use the SDL version works independentlt from the cueses version: +To use the SDL version that works independently from the curses version: ```sh make thadgavin_sdl @@ -37,8 +37,8 @@ Use `thadgavin_sdl` as you would `thadgavin` below. ./thadgavin ``` -WARNING: if you are sensitive to rapid movement you should probably avoid -this entry, both the SDL version and the curses version. +WARNING: if you are sensitive to rapid movement or if you want to see better +what is going on then please see the Alternate code section. NOTE: in curses mode you might want to type `reset` after execution of this program as the program does not call `endwin()`. Using `reset` will clear the @@ -51,6 +51,38 @@ screen. echo "Do or do not. There is no try." ``` +## Alternate code: + +An alternate version exists which allows you to slow down the printing of the +characters, useful for those with modern systems or those who are sensitive to +rapid moving swirling. To use: + + +```sh +make alt +``` + +To make the SDL version: + +```sh +make thadgavin.alt_sdl +``` + +If you wish to reconfigure the delay you can do so like: + +```sh +make -DZ=50 clobber alt +make -DZS=5000 clobber thadgavin.alt_sdl +``` + +Use `thadgavin.alt` and `thadgavin.alt_sdl` as you would `thadgavin` and +`thadgavin_sdl` above. + +The default for the curses alt version is 30 and for SDL it is 150000. The +different macros is because the curses version is already slower but it's better +to not tie the two values together. The reason for such drastically different +numbers is because curses is already slower than SDL. + ## Judges' remarks: diff --git a/2000/thadgavin/thadgavin.alt.c b/2000/thadgavin/thadgavin.alt.c new file mode 100644 index 000000000..7432da25f --- /dev/null +++ b/2000/thadgavin/thadgavin.alt.c @@ -0,0 +1,93 @@ + + int + X=320 ,Y=200, + n=0,m, x,y, j=1024; + double T=44.0 /7,P[ + 333333 ],C[5] ={ 0,3, + 0,0,8} ,p=1, B=11.0 + /630, f=0,r = 3,g + =7,b =13,*q=P, D,*J; + unsigned char + U[66666],*v=U,*h,l[5555] + ,c=0,*e,*a,*z; + + #include + #define R1(t) t=(int)(t\ + *123456789 )%j; t/=j; + #define Rl(C,t)\ + n++[C] = t*n/12; + #define RI(C) B=-B; R1\ + (r)R1(g )R1(b )for(n\ + =0; n + #include + #include + #define Q(u,v) u##portb(0x3##v + #define W ; Q(out,C9),*h++/4) + void F(int i){ __dpmi_regs r + ; if(i){ for(; i>=0; i-=8)while( + ~Q(in,DA) + )&8^i); for(m=0,z + =h+j; h + SDL_Surface *s; void + F(int i){ if (i){ SDL_SetColors( + s,h,0,256); SDL_UpdateRect + (s,0,0,0, 0); usleep(ZS); } else { SDL_Init( + SDL_INIT_VIDEO); s=SDL_SetVideoMode + (X,Y,8,0); v=s->pixels; } } + #else + #include "curses.h" + void F(i){ if(i){ for(y=0; + y=X/2?x=-X/2,y++:4) + {*q++ = sqrt(x*x+y*y); + + *q++ = atan2(x,y); + + }for (;n1){p=2-p;RI(l+j)} + else if (p<0){p=-p;RI(l)} + + while(aT) + {C[1] += (f-T)/8; + + if (f>T*2) + C[0]=sin(f)+sin(f*2)/2; + } + } +} diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 614f3792e..542f28a9c 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -777,6 +777,12 @@ To see the craziness of the SDL fix (because of a terrible design choice of the SDL1 developers) see the log for commit dd0b26b5d6325e8b6fdef1232156c8bb8c66613f. Be prepared for a surprise! +Cody also added an alternate version to help see what is going on in more modern +systems and in case you're sensitive to rapidly moving swirling. See the +README.md for details on that. Note that this alternate version only will impact +the curses and the SDL versions as Cody does not have a DOS system to test the +other version in. + ## [2001/anonymous](2001/anonymous/anonymous.c) ([README.md](2001/anonymous/README.md]))