From ec111eb6b2b46847c4b3e18c880c05c5708a63a8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:15:16 -0700 Subject: [PATCH 1/4] Undo segfault fix in 1984/laman w/o arg As part of redefining INABIAF this is necessary. The README.md and Makefile both warn about the crash. --- 1984/laman/Makefile | 1 + 1984/laman/README.md | 6 +++--- 1984/laman/laman.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/1984/laman/Makefile b/1984/laman/Makefile index 24f29119b..13746a975 100644 --- a/1984/laman/Makefile +++ b/1984/laman/Makefile @@ -128,6 +128,7 @@ all: data ${TARGET} supernova deep_magic magic charon pluto ${PROG}: ${PROG}.c + @echo "NOTE: this entry will segfault without an arg." ${CC} ${CFLAGS} $< -o $@ ${LIBS} # alternative executable diff --git a/1984/laman/README.md b/1984/laman/README.md index 162ce2062..d8fb88eaa 100644 --- a/1984/laman/README.md +++ b/1984/laman/README.md @@ -10,9 +10,9 @@ Mike Laman ./laman -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this entry to not -segfault if no arg is specified. Instead it'll print nothing. Thank you Cody for -your assistance! + +NOTE: this entry will segfault without an arg. + ## Try: diff --git a/1984/laman/laman.c b/1984/laman/laman.c index 9ce1e4c11..758e4480c 100644 --- a/1984/laman/laman.c +++ b/1984/laman/laman.c @@ -1,5 +1,5 @@ a[900]; b;c;d=1 ;e=1;f; g;h;O; main(k, -l)char* *l;{g= l[1]? atoi(*++l) :0;for(k= +l)char* *l;{g= atoi(* ++l); for(k= 0;k*k< g;b=k ++>>1) ;for(h= 0;h*h<= g;++h); --h;c=( (h+=g>h *(h+1)) -1)>>1; while(d <=g){ ++O;for (f=0;f< O&&d<=g From ffb639d42d46ce6694f4b557b4954e9921fe93e0 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:19:02 -0700 Subject: [PATCH 2/4] Undo buffer size increase in 1994/schnitzi As part of redefining INABIAF the entry now has an equivalent functionality with the generated output. The bugs.md file still has hints on how to get this to use fgets() (for why this is helpful see that file). As a starting point I have the original buffer size increase in schnitzi.alt.c as it would be useful to see how it works and to maybe get the entry to use fgets(). Unfortunately keeping it using gets() is a potential problem but changing it to fgets() is also a potential problem (this goes for all of the entries that use or used gets()). This entry however still uses gets(). The change is the smaller buffer size which means that the entry can not handle big files. The Makefile and README.md now refer to the small buffer size. --- 1994/schnitzi/Makefile | 1 + 1994/schnitzi/README.md | 26 +++++++++++--------------- 1994/schnitzi/schnitzi.alt.c | 2 +- 1994/schnitzi/schnitzi.c | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/1994/schnitzi/Makefile b/1994/schnitzi/Makefile index cf2666d21..0dcaaad8a 100644 --- a/1994/schnitzi/Makefile +++ b/1994/schnitzi/Makefile @@ -128,6 +128,7 @@ all: data ${TARGET} supernova deep_magic magic charon pluto ${PROG}: ${PROG}.c + @echo "NOTE: the buffer size of this entry is very small at 100." ${CC} ${CFLAGS} $< -o $@ ${LIBS} # alternative executable diff --git a/1994/schnitzi/README.md b/1994/schnitzi/README.md index a528218cb..c75f5b73c 100644 --- a/1994/schnitzi/README.md +++ b/1994/schnitzi/README.md @@ -18,20 +18,6 @@ make all ./schnitzi < textfile ``` -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) increased the buffer -size from 100 to 10000. Changing it to use `fgets()` instead of `gets()` is more -problematic because when feeding the source code to the program the output -results in compiler errors and not only that but the gets() is still there in -the generated output. Even changing the buffer size can result in compilation -errors if not done correctly. The generated output also does not have a changed -buffer size. Changing it to use fgets() can happen later, maybe, but bigger -files can now be parsed by the original code. An example is the Makefile. Cody -gave some tips on how this entry works, in order to make the entry use fgets() -and compile successfully too, in the [bugs.md](/bugs.md) file. Thank you Cody! - -For the original source file [schnitzi.alt.c](schnitzi.alt.c) see below. - - ## Try: ```sh @@ -39,10 +25,19 @@ For the original source file [schnitzi.alt.c](schnitzi.alt.c) see below. ./schnitzi < /etc/passwd ``` +NOTE: the buffer size is very small at 100. It's easy to fix the buffer size but +it is not as easy to change it to `fgets()`. [Cody Boone +Ferguson](/winners.html#Cody_Boone_Ferguson) gives some hints in the +[bugs.md](/bugs.md) file on how this entry works which might be useful in order +to get this to use `fgets()` which would prevent a warning at linking or +runtime. The file [schnitzi.alt.c](schnitzi.alt.c) has this to get anyone +started, should they wish to tackle it (Cody will in time). The problem with +changing the buffer size is that even when it works the generated output (see +judges' comments below) will not be 100% correct duplication of the program. ### Alternate code: -For the original version with a smaller buffer try: +To build the alternative code try: ```sh make alt @@ -50,6 +45,7 @@ make alt Use `schnitzi.alt` as you would `schnitzi`. + ## Judges' comments: diff --git a/1994/schnitzi/schnitzi.alt.c b/1994/schnitzi/schnitzi.alt.c index 45a5365e4..a28d79ee9 100644 --- a/1994/schnitzi/schnitzi.alt.c +++ b/1994/schnitzi/schnitzi.alt.c @@ -20,7 +20,7 @@ h mh111 de{l) +di (+'( d+% c n+ */ n = 0 ; main ( ) { char v [ - 100 ] , s; + 10000 ] , s; int t[100 ] , u[100 ] ; u [ 0 diff --git a/1994/schnitzi/schnitzi.c b/1994/schnitzi/schnitzi.c index a28d79ee9..45a5365e4 100644 --- a/1994/schnitzi/schnitzi.c +++ b/1994/schnitzi/schnitzi.c @@ -20,7 +20,7 @@ h mh111 de{l) +di (+'( d+% c n+ */ n = 0 ; main ( ) { char v [ - 10000 ] , s; + 100 ] , s; int t[100 ] , u[100 ] ; u [ 0 From c59ebbb6c8b0da899c946dffe97970741b141dd5 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:25:31 -0700 Subject: [PATCH 3/4] Undo NULL file protection in 2018/algmyr As part of the redefinition of INABIAF the entry no longer has the fix applied. --- 2018/algmyr/Makefile | 1 + 2018/algmyr/README.md | 18 +----------- 2018/algmyr/prog.alt.c | 66 ------------------------------------------ 2018/algmyr/prog.c | 2 +- 4 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 2018/algmyr/prog.alt.c diff --git a/2018/algmyr/Makefile b/2018/algmyr/Makefile index b9feaae4a..661ea0121 100644 --- a/2018/algmyr/Makefile +++ b/2018/algmyr/Makefile @@ -131,6 +131,7 @@ all: data ${TARGET} supernova deep_magic magic charon pluto ${PROG}: ${PROG}.c + @echo "NOTE: this program will crash if a file specified cannot be opened." ${CC} ${CFLAGS} $< -o $@ ${LIBS} # alternative executable diff --git a/2018/algmyr/README.md b/2018/algmyr/README.md index afae74a39..2d1031d9f 100644 --- a/2018/algmyr/README.md +++ b/2018/algmyr/README.md @@ -17,11 +17,7 @@ cat prog.c | ./prog # Printing garbage might break your font ./prog -d 2 0 out.raw # Decode the first (0th) channel out of two ``` -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made this entry not -crash when a file cannot be opened. The original file, kept for the wonderful -format, is in [prog.alt.c](prog.alt.c). See below for details. Thank you Cody -for your assistance! - +NOTE: this entry will crash if a file specified cannot be opened. ## Try: @@ -42,18 +38,6 @@ echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog | # now open spectrogram.png with a graphics viewer or editor ``` -### Alternate code: - -The original source which will crash if a file cannot be opened but which also -has a nicer layout can be found in [prog.alt.c](prog.alt.c). Try: - - -```sh -make alt -``` - -Use `prog.alt` as you would `prog`. - ## Judges' comments: Be warned, this is not your garden variety text-to-speech program! Earplugs are advised, diff --git a/2018/algmyr/prog.alt.c b/2018/algmyr/prog.alt.c deleted file mode 100644 index 76fe8d58e..000000000 --- a/2018/algmyr/prog.alt.c +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#define M malloc(sizeof( -#define R fread(x,sizeof(float),Z*w,f) -#define E free( - -char*G= -" " -" '" -"@(*AP( " -" " -" " -" " -" " -" _" -"0 #@ . \"C^*/XH\"Q2_U(D&(5*E0C 4B54DV X \"!9A@ 89H$ !" -"0(/@@4 @(/@@( #@T @(\" @( P, , P# , #Y1244^ ?R 0#%)14,A#9)24$B 1" -"_)!0,$Y145%R Y145$^&!81T! #9)24DV#Y)24DP ;&P -C4 $$B% @ !04%!04 @4(D$ #!(1" -"4 @#U574$^'^0D)!_&Z1D9'_$*!@8%^'Z!@8'_(&1D9'_(\"0D)#_%Z1D8%^/\\0$!#_ \"!_X$ /X! 0" -"$&(-$*!#_ $! 0'_/] ,$#_/\\&&&#_'Z!@8%^&\"0D)#_'V\"A8%^&>8D)#_$Z1D9%B(\" _X\" /X" -"! 0'^/ , PSP/P#' /\\,!@& 088!X!#@$>" -"!$*! H1#X)!04X!$9%1,1" -"(&!;A 0 _P " -" ! 0;H&!" -" @$\"" -"! (" -"\0"; int s,p,e,c,t,r,a,l; /* l e a k a g e */ - - int - F(int o - ,int n, int t - ){char*p=(o*(136-o) - >=1260)*7*(o-9)+G; for( - n=!(o=-1); n=*p+++64*n-*G - ,(o+=3)>>2<5-t; ); return 255 - &n>>2*o%8; } float L[0x400];int - T(float a,float b,float l,float*e) - {return L[0x3ff]||!(e[1]=b*a+l**e)|| - !T(l*a-b**e,b,l,e+1); } float f(int x) - {int w=s<>x&&P+(* - h+=f(e*(l+a*(2*x+1))*y)*f(s/2-e*a*y+e*a*y*y*(t/p - )/(s/p)))),++x); float z=f(y*t)*f(y*t); *h=z*(1+3* - z+2*z*z)/6**h/c; } return h-i-r+1; } void d(int w, - int n,FILE*f){int Z=s/t; int S[5]; float**P=M float* - )*c);for(r=0;r1?v[1][0]*c+v[1][1]:0; a=7;l=16;if(r ==11620){d (atoi - (v[2]), atoi(v[3]), q<5?stdin:fopen(v[4],"r")); return 0; } char*H=malloc(c),* h=H; sprintf (H,"\0" - "Usage\n" " %s [-" "h] [-d #c cid] file1 file2 ... (or stdin)"+(q-1&&r==11624 ),v[0]);if(* H)q=1;int - w=2>q?1:q -1; FILE**f=M FILE*)*w); f[0]=stdin; if(q>1)for(r=0; rungetc(* H++,*f); for(r =w; r--;) -{ i[r]=getc (f[r]); if(i[r]<0)i[r]=!++x; } if(x==w)break; while(++r<6){ while(C(b++,t,w,F(*i++,r< 5,r))); i-= -w; fwrite(b-=w,sizeof(float),l,stdout); } fflush(stdout); } while(fclose(f[--w]),w); E f); E b); E i); E h);} - diff --git a/2018/algmyr/prog.c b/2018/algmyr/prog.c index 55360384e..76fe8d58e 100644 --- a/2018/algmyr/prog.c +++ b/2018/algmyr/prog.c @@ -59,7 +59,7 @@ char*G= 44100 ;p=25; e= 55;c=256; t=75; r=q>1?v[1][0]*c+v[1][1]:0; a=7;l=16;if(r ==11620){d (atoi (v[2]), atoi(v[3]), q<5?stdin:fopen(v[4],"r")); return 0; } char*H=malloc(c),* h=H; sprintf (H,"\0" "Usage\n" " %s [-" "h] [-d #c cid] file1 file2 ... (or stdin)"+(q-1&&r==11624 ),v[0]);if(* H)q=1;int - w=2>q?1:q-1;FILE**f=M FILE*)*w);f[0]=stdin;if(q>1)for(r=0;rq?1:q -1; FILE**f=M FILE*)*w); f[0]=stdin; if(q>1)for(r=0; rungetc(* H++,*f); for(r =w; r--;) { i[r]=getc (f[r]); if(i[r]<0)i[r]=!++x; } if(x==w)break; while(++r<6){ while(C(b++,t,w,F(*i++,r< 5,r))); i-= w; fwrite(b-=w,sizeof(float),l,stdout); } fflush(stdout); } while(fclose(f[--w]),w); E f); E b); E i); E h);} From a4322d00ea96a46fbe5baf3857d754a978ae35e0 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:28:17 -0700 Subject: [PATCH 4/4] Slight rewording in 1985/lycklama/README.md --- 1985/lycklama/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1985/lycklama/README.md b/1985/lycklama/README.md index daee2f9ae..ac18490d3 100644 --- a/1985/lycklama/README.md +++ b/1985/lycklama/README.md @@ -9,7 +9,7 @@ make all ``` -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work with +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to compile with modern compilers. In the past 'define' in `#define` could even be defined but to get this to work on modern systems Cody changed the `#o` lines to `#define`. The `lycklama.alt.c` is the original source code as it provides some fun input for