From bd1554d6636ce48c0a739cb7062dcc193cac070c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 11 Sep 2023 05:40:26 -0700 Subject: [PATCH 1/5] Add entries to FAQ + minor fixes to thanks file The following entries were added: 0. Makefile rules. 1. 32-bit entries not working in 64-bit systems. 2. Some entries not working in macOS either uncompilable or non-functional. 3. Entries that cannot be compiled with clang. For (3) this especially is problematic for macOS as even /usr/bin/gcc is clang (as has been noted many times before this but not in the FAQ). At least one typo fix was also made and at least one entry that already existed was updated a bit. The fixes to the thanks file are related to the FAQ entries added. --- faq.md | 87 ++++++++++++++++++++++++++++++++++++++++++++- thanks-for-fixes.md | 9 ++--- 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/faq.md b/faq.md index d43197cd2..3dbe3f3ad 100644 --- a/faq.md +++ b/faq.md @@ -31,8 +31,55 @@ By tradition, we do not say. ## Q: How many judging rounds do you have? + Are you trying to trick us? We will not say that either. +## Q: What are the general Makefile rules used in order to clean and build entries for use? + +In general the best way to compile everything in an entry directory is to run: + +```sh +make clobber all +``` + +If you wish to compile every entry for every year you should go to the top level +directory and run the same command as above, `make clobber all`. + +The `all` rule will build everything necessary except for the alternate +versions. Every Makefile has an `alt` rule but it will only do something if an +alternate version exists. To build all the entries along with any alternate code +you can do from the top level directory: + +``` +make clobber everything +``` + +If you wish to only build alternate code you can do: + +```sh +make clobber alt +``` + +If you wish to not remove the entry binaries and only compile the additional alt +versions: + +```sh +make alt +``` + + +The following Makefile rules should be in all Makefiles: + +- all: build the entry programs (main program and any supplementary program) +- alt: build alternate code +- clobber: clean up object files and all binary files (except for those that are +not compiled) +- clean: a simpler version of `clobber` that only removes object files. `make +clobber` depends on `clean` so running `make clobber` will invoke `make clean`. +- everything: equivalent to `make all alt`. + +Are there any other rules? You tell us! + ## Q: How come some entries have code that is incongruent with what the author(s) wrote about the entry? It is very likely in this case that the code was fixed to work for modern @@ -41,6 +88,7 @@ some entries you should look at the original code as in `winner.orig.c` or `prog.orig.c`. Sometimes the original is in an alt version like `winner.alt.c` or `prog.alt.c`. + ## Q: I cannot get entry XYZZY from year 19xx to compile! Some winners, particularly winners from long ago, no longer compile on more @@ -65,7 +113,7 @@ The microseconds defaults to 10000. Thank you Cody! See also [Yusuke Endoh](/winners.html#Yusuke_Endoh)'s entry -[2015/endoh3](/2015/endoh3/README.md) entry which lets one compile it and run +[2015/endoh3](/2015/endoh3/README.md) which lets one compile it and run it. Another entry that you can enjoy it under is [Christopher Mill](/winners.html#Christopher_Mills)'s entry [2018/mills](/2018/mills/README.md) which is a PDP-7 emulator as well as a @@ -79,6 +127,43 @@ time). In some cases we replaced the original code with code that works for modern systems but one can view the original code in the `.orig.c` files (sometimes the original code is also in the directory as a `winner.alt.c` or `prog.alt.c`). +Some entries should not have modern system versions replaced. See below. + +## Q: I can't get some entries to work in 64-bit systems that don't support 32-bit! + +Unfortunately some older entries are non-portable and require 32-bit support of +32-bit binaries. A problem system here is macOS Catalina (10.15) as as of that +version macOS no longer supports 32-bit binaries. + +There are numerous example entries that require 32-bit binaries. We have tried +to note these in both the respective Makefiles and README.md files but it is +possible that some were missed. These entries are very likely in the +[bugs.md](/bugs.md) file and we welcome any help in making an alternate version +for 64-bit systems. Many were fixed to work with modern systems but some are +supposed to only work with 32-bit systems so any updated version of these +entries should be an alternate version. + +## Q: Under macOS I can't compile some entries and/or they don't work right. Why? + +If the entry requires gcc and you did not explicitly install gcc in macOS you +will not be able to run or use these entries. This is because macOS gcc is +actually clang, even `/usr/bin/gcc`. + +## Q: I can't get XYZZY entry to compile with clang. What can I do? + +Although we have fixed numerous entries to work with clang (sometimes in an alt +version but usually in the program itself) there are some that simply cannot be +fixed or if they are fixable they have not yet been fixed (we are working on +this but other things have to be done too and all on free time). + +This is because clang has some defects where the args of main() are required to +be a specific type and some versions of clang allow only 1, 2 or 3 args, not 4, +to main(). In the case of types of args many were changed to the right type and +then what was main() became another function of the original main() type. + +At the same time some entries are not designed to work with clang. There might +be alternate code added at some point but as above this depends on free time and +other things that have to be done plus remembering to do it. ## Q: After running a program my terminal is all messed up! How do I restore my terminal? diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 16a2f4c05..5542ed46f 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -736,8 +736,8 @@ calls which has the four args. Cody fixed a segfault in this program that prevented it from working right but he notes it hangs in macOS. This is because some compilers compile it into an infinite loop and this was documented by the judges. It works fine in linux if -using gcc but macOS, having only clang by default (even the gcc binary) will not -work. +using gcc but macOS, having only clang by default (even the gcc binary +`/usr/bin/gcc`) will not work. ## [1996/dalbec](1996/dalbec/dalbec.c) ([README.md](1996/dalbec/README.md])) @@ -897,8 +897,9 @@ other version in. Cody fixed both the supplementary program and the program itself (both of which segfaulted and once that was fixed only the binary was modified; it was not run but according to the author's remarks it should be executed). He managed to do -this with linux but it will not work with macOS (see [bugs.md](/bugs.md) for why -this is); _this is **not** a bug, it's a feature_ inherent in what it does! +this with linux but it will not work with macOS Catalina (10.15). See +[bugs.md](/bugs.md) for why this is); _this is **not** a bug, it's a feature_ +inherent in what it does! Below is what it took to fix. From a194ac6cb3dab04fcc6499fa38b82762ffff5039 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 11 Sep 2023 05:51:47 -0700 Subject: [PATCH 2/5] Improve my original fix to 1987/wall This improvement redefines gets() to use fgets() with the correct args so that the code can refer to gets() to look more like the original code. Note that the prototype for gets() that is in the original code cannot be there because of conflicting types of fgets() and a couple other errors that arise from redefining gets(). This fix is part of issue #936 which with this commit is more than halfway complete. --- 1987/wall/wall.c | 3 ++- thanks-for-fixes.md | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/1987/wall/wall.c b/1987/wall/wall.c index 9aeadf78e..11a571ed7 100644 --- a/1987/wall/wall.c +++ b/1987/wall/wall.c @@ -3,11 +3,12 @@ #define XI(xi)int xi[iv*'V']; #define L(c,l,i)c(){d(l);m(i);} #include +#define gets(D) fgets((D),'x',stdin) int*cc,c,i,ix='\t',exit(),X='\n'*'\d';XI(VI)XI(xi)extern(*vi[])(),(* signal())();char*V,cm,D['x'],M='\n',I;L(MV,V,(c+='d',ix))m(x){v) signal(X/'I',vi[x]);}d(x)char*x;{v)write(i,x,i);}L(MC,V,M+I)xv(){c>=i?m( c/M/M+M):(d(&M),m(cm));}L(mi,V+cm,M)L(md,V,M)MM(){c=c*M%X;V-=cm;m(ix);} -LXX(){fgets(D,'x',stdin)||(vi[iv])();c=atoi(D);while(c>=X){c-=X;d("m");}V="ivxlcdm" +LXX(){gets(D)||(vi[iv])();c=atoi(D);while(c>=X){c-=X;d("m");}V="ivxlcdm" +iv;m(ix);}LV(){c-=c;while((i=cc[*D=getchar()])>-I)i?(c?(c Date: Mon, 11 Sep 2023 05:58:09 -0700 Subject: [PATCH 3/5] Improve my fix to 1990/cmills Redefined gets to use fgets() with the appropriate args so that the code can refer to gets() in the way it originally did. --- 1990/cmills/cmills.c | 5 +++-- thanks-for-fixes.md | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/1990/cmills/cmills.c b/1990/cmills/cmills.c index d27a29b54..333938915 100644 --- a/1990/cmills/cmills.c +++ b/1990/cmills/cmills.c @@ -4,16 +4,17 @@ #define W(w)if((w)<22)v= -v;else v-=10;else #define F for(r=d;r1;){if(r-d>N*3/4){B(8));F++r)*r=c[(r-d)%13];F)w= *(g=d+rand()%N),*g= -*r,*r++=w;r=d;}for(;;){B(3),y);if(!fgets(l,M,stdin)||(w=atoi(l))<1)exit(0);if(w&1||w>M||w>y)B(1),yM||w>y)B(1),y=w/2&&u(5)&&(y+=(3*(h(0,1[q])==10)-1)*w/2);if(x==-21)goto _;if(v==-21){y+=w/2;goto diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index b85eb7fe5..4e6bf7d2f 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -380,7 +380,9 @@ To prevent alarming warnings at linking or runtime Cody made the entry use `fgets()` rather than `gets()`. He notes that another option would have been to redirect `stderr` to `/dev/null` but he did not think of that at the time. -For the original code see the [1992 archive](/archive/archive-1990.tar.bz2). +Cody later improved upon the `gets()`/`fgets()` fix to make it more like the +original where the code can refer to `gets()` in the way it originally did. This +was done through a macro to redefine `gets`. BTW: Cody asks the following question: if the compiler compiles, the linker links and the user executes does that make the compiler the jury, the linker the From 8aad81aaebe3d74efb1a8afa5267b6ee8363b715 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 11 Sep 2023 06:11:11 -0700 Subject: [PATCH 4/5] Improve my fix to 1993/schnitzi Redefined gets() so that the code can refer to gets() not fgets(). That change was useful (as noted before) for preventing an annoying warning being interspersed with the output and warnings at compiler and/or linking. --- 1993/schnitzi/schnitzi.c | 4 ++-- thanks-for-fixes.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/1993/schnitzi/schnitzi.c b/1993/schnitzi/schnitzi.c index 55c4232b3..e947800a6 100644 --- a/1993/schnitzi/schnitzi.c +++ b/1993/schnitzi/schnitzi.c @@ -2,7 +2,7 @@ #include #include #include - +#define gets(x) fgets((x), 111, stdin) #define iii\ ( I ) if ( ii(I,6\ ) )I [ strlen(I ) -1]=!1 @@ -30,6 +30,6 @@ ) printf ( " %s",li1[l1l++] ) ;puts ( "." ) ;}}else{sprintf ( il1,"cat %s;echo",lll[1] ) ;system ( il1 ) ;}printf -( "\n? " ) ; fgets ( il1, 111 , stdin +( "\n? " ) ; gets ( il1 ) ;sprintf ( i1l,"%s %s %s",lll[!1 ] ,lll[1],il1);system ( i1l); } diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 4e6bf7d2f..932410ceb 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -663,6 +663,8 @@ Cody made this use `fgets()` not `gets()` to make it safer and to prevent an annoying warning with compiling and/or linking and/or runtime, the latter of which is unfortunately interspersed with the output of the program itself. +Cody later improved the fix to use `gets()` via a macro so that it looks like +the original code. ## [1993/vanb](1993/vanb/vanb.c) ([README.md](1993/vanb/README.md])) From 88eef478aaff2e895fa649c558460d2b3013a61e Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 11 Sep 2023 06:19:44 -0700 Subject: [PATCH 5/5] Improve my fix to 2000/anderson - redefine gets() --- 2000/anderson/anderson.c | 17 +++++++---------- thanks-for-fixes.md | 2 ++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/2000/anderson/anderson.c b/2000/anderson/anderson.c index 2e2af5632..422b4e358 100644 --- a/2000/anderson/anderson.c +++ b/2000/anderson/anderson.c @@ -1,5 +1,5 @@ #include - +#define gets(K) fgets((K)[1],1000,stdin) char *T="IeJKLMaYQCE]jbZRskc[SldU^V\\X\\|/_<[<:90!\"$434-./2>]s", K[3][1000],*F,x,A,*M[2],*J,r[4],*g,N,Y,*Q,W,*k,q,D;X(){r [r @@ -25,15 +25,12 @@ j((r[2]=0,R( )) ),r[1]-=q) && O(g-=-q) ;} C(){( J= -fgets (K -[1],1000,stdin))&&C((B(g=K[2]),*r=!(!*r&&(*g++=0)),(*r)[r]=g --K[2 -],g= -K[2] -,r[1 -]&&O -())) - ;;} +gets (&K +[1]))&&C((B(g=K[2]),*r=!(!*r&&(*g++=0)),(*r)[r]=g-K[2],g=K[2 +],r[ +1]&& +O()) +);;} main (){C ((l( diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 932410ceb..2d7a1d97d 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -856,6 +856,8 @@ Cody changed this entry to use `fgets()` instead of `gets()` to make it safer and to prevent annoying warnings from showing up at compiling, linking and/or runtime, the latter interspersed with the output of the program. +Cody later improved the fix to use `gets()` by redefining `gets()` so that the +code looks like before. ## [2000/briddlebane](2000/briddlebane/briddlebane.c) ([README.md](2000/briddlebane/README.md]))