From 37fb84c37c50cf490fd7f38722e185936960fc2d Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 14 Feb 2023 03:08:25 -0800 Subject: [PATCH] All 1990 entries now compile! My first 41st, 51st and 29th (all depending on the base) birthday updates (possibly more will follow but this is not a certainty). All the 1990 entries now compile! In one we used a patch from Yusuke Endoh (thank you Yusuke!) which we credited him in the README and in another we used a tip from him (use -ansi at the compiler line) to get the other to compile (again, thank you Yusuke!). We fixed the others. In the case of 1990/tbr/tbr.c the author had supplied a shorter version and we fixed that one too. Added 1990/.gitignore which has the built files of 1990 so that after doing `cd 1990 ; make all' running `git status .' will not show any untracked files. --- 1990/.gitignore | 18 ++++++ 1990/dds/README.md | 11 +++- 1990/dds/dds.c | 4 +- 1990/dg/README.md | 12 ++-- 1990/dg/dg.c | 124 ++++++++++++++++++++--------------------- 1990/scjones/Makefile | 2 +- 1990/scjones/README.md | 13 ++++- 1990/tbr/README.md | 31 ++++++----- 1990/tbr/tbr.c | 4 +- 1990/westley/README.md | 4 +- 1990/westley/westley.c | 6 +- 11 files changed, 135 insertions(+), 94 deletions(-) create mode 100644 1990/.gitignore diff --git a/1990/.gitignore b/1990/.gitignore new file mode 100644 index 000000000..7f047df8e --- /dev/null +++ b/1990/.gitignore @@ -0,0 +1,18 @@ +baruch/baruch +cmills/cmills +dds/dds +dg/dg +jaw/atob +jaw/jaw +jaw/zcat +pjr/pjr +scjones/scjones +stig/o +stig/o.c +tbr/tbr +theorem/fibonacci +theorem/fibonacci.c +theorem/sorter +theorem/sorter.c +theorem/theorem +westley/westley diff --git a/1990/dds/README.md b/1990/dds/README.md index 8002af0bf..4844aa5e6 100644 --- a/1990/dds/README.md +++ b/1990/dds/README.md @@ -10,12 +10,16 @@ make all - NOTE: This entry may not compile when using modern compilers. ### To run ./dds + +NOTE: this entry uses `gets()` so you might get a warning when compiling and +running this entry. + + ## Judges' comments Give the following lines as input: @@ -25,6 +29,11 @@ Be sure not to run out of fuel! + + Modern compilers could not compile this entry but Yusuke Endoh supplied a patch + which lets it compile. Thank you Yusuke! + + ## Author's comments This is the DDS-BASIC Interpreter (Version 1.00). diff --git a/1990/dds/dds.c b/1990/dds/dds.c index 176b266ae..3cac21f3d 100644 --- a/1990/dds/dds.c +++ b/1990/dds/dds.c @@ -16,9 +16,9 @@ X'R':B[2]!='M'&&(l=*--C)X'I':B[1]=='N'?gets(p=B),P[*d]=S():(*(q=Q(B,"TH"))=0,p =B+2,S()&&(p=q+4,l=S()-1))X'P':B[5]=='"'?*d=0,puts(B+6):(p=B+5,printf("%d\n",S ()))X'G':p=B+4,B[2]=='S'&&(*C++=l,p++),l=S()-1 X'F':*(q=Q(B,"TO"))=0;p=B+5;P[i =B[3]]=S();p=q+2;M[i]=S();L[i]=l X'N':++P[*d]<=M[*d]&&(l=L[*d]);}else p=B+2,P[ -*B]=S();l++;}X'L':N printf(I)X'N':N free(m[i]),m[i]=0 X'B':_ 0 t('S',5,"w",N +*B]=S();l++;}X'L':N printf(I)X'N':N(free(m[i]),0),m[i]=0 X'B':_ 0 t('S',5,"w",N fprintf(f,I))t('O',4,"r",while(fgets(B,R,f))(*Q(B,"\n")=0,G()))X 0:default:G() -;}_ 0;}G(){l=atoi(B);m[l]&&free(m[l]);(p=Q(B," "))?strcpy(m[l]=malloc(strlen(p +;}_ 0;}G(){l=atoi(B);m[l]&&(free(m[l]),0);(p=Q(B," "))?strcpy(m[l]=malloc(strlen(p )),p+1):(m[l]=0,0);}O(S,J,'=',==,'#',!=)O(J,K,'<',<,'>',>)O(K,V,'$',<=,'!',>=) O(V,W,'+',+,'-',-)O(W,Y,'*',*,'/',/)Y(){int o;_*p=='-'?p++,-Y():*p>='0'&&*p<= '9'?strtol(p,&p,0):*p=='('?p++,o=S(),p++,o:P[*p++];} diff --git a/1990/dg/README.md b/1990/dg/README.md index 2e8e4c8ff..9740d9b33 100644 --- a/1990/dg/README.md +++ b/1990/dg/README.md @@ -18,16 +18,18 @@ ## Judges' comments - Some C preprocessors get confused about single quotes in certain cases. + Some C preprocessors got confused about single quotes in certain cases. In particular, the following source line: - Cb12(ase(bco(acp(bi(acp(bcp(acp(bpl(aqu(bqu(A)))))))))))))))))))))))))))))) + b12(ase(bco(acp(bi(acp(bcp(acp(bpl(aqu(bqu(A)))))))))))))))))))))))))))))) - may need to be changed to: + sometimes has to be changed to: - Cb12(ase(bco(acp(bi(acp(bcp(acp(bpl('A')))))))))))))))))))))))))))) + b12(ase(bco(acp(bi(acp(bcp(acp(bpl('A')))))))))))))))))))))))))))) + + if the C preprocessor botches single quotes in cpp expansions, which we have + done for the wider audience. - if your C preprocessor botches single quotes in cpp expansions. ## Author's comments diff --git a/1990/dg/dg.c b/1990/dg/dg.c index 348efd2e8..ccbb6fa29 100644 --- a/1990/dg/dg.c +++ b/1990/dg/dg.c @@ -1,69 +1,67 @@ #include -#define d define - -#d b12(x) 12 x -#d a13(x) x 13 -#d a16(x) x 16 -#d a32(x) x 32 -#d acb(x) x] -#d acc(x) x} -#d aco(x) x: -#d bco(x) :x -#d acp(x) x) -#d bef(x) EOF x -#d aeq(x) x= -#d afo(x) x for -#d age(x) x fgetc -#d asi(x) x stdin -#d aso(x) x stdout -#d bgt(x) >x -#d ai(x) x i -#d aj(x) x j -#d al(x) x l -#d ami(x) x- -#d bne(x) !=x -#d aob(x) x[ -#d aop(x) x( -#d apl(x) x+ -#d bpu(x) fputc x -#d bqm(x) ?x -#d aqm(x) x? -#d aqu(x) x' -#d ase(x) x; -#d awh(x) x while -#d axo(x) x^ -#d a0(x) x 0 -#d b13(x) 13 x -#d b16(x) 16 x -#d b19(x) 19 x -#d b48(x) 48 x -#d a64(x) x 64 -#d b66(x) 66 x -#d bcb(x) ]x -#d bch(x) char x -#d bcm(x) ,x -#d acm(x) x, -#d bcp(x) )x -#d beq(x) =x -#d bex(x) extern x -#d bi(x) i x -#d bin(x) int x -#d bix(x) index x -#d bj(x) j x -#d bl(x) l x -#d alt(x) x< -#d bma(x) main x -#d bob(x) [x -#d boc(x) {x -#d bop(x) (x -#d bpl(x) +x -#d app(x) x++ -#d bqu(x) 'x -#d bse(x) ;x -#d bst(x) *x +#define b12(x) 12 x +#define a13(x) x 13 +#define a16(x) x 16 +#define a32(x) x 32 +#define acb(x) x] +#define acc(x) x} +#define aco(x) x: +#define bco(x) :x +#define acp(x) x) +#define bef(x) EOF x +#define aeq(x) x= +#define afo(x) x for +#define age(x) x fgetc +#define asi(x) x stdin +#define aso(x) x stdout +#define bgt(x) >x +#define ai(x) x i +#define aj(x) x j +#define al(x) x l +#define ami(x) x- +#define bne(x) !=x +#define aob(x) x[ +#define aop(x) x( +#define apl(x) x+ +#define bpu(x) fputc x +#define bqm(x) ?x +#define aqm(x) x? +#define aqu(x) x' +#define ase(x) x; +#define awh(x) x while +#define axo(x) x^ +#define a0(x) x 0 +#define b13(x) 13 x +#define b16(x) 16 x +#define b19(x) 19 x +#define b48(x) 48 x +#define a64(x) x 64 +#define b66(x) 66 x +#define bcb(x) ]x +#define bch(x) char x +#define bcm(x) ,x +#define acm(x) x, +#define bcp(x) )x +#define beq(x) =x +#define bex(x) extern x +#define bi(x) i x +#define bin(x) int x +#define bix(x) index x +#define bj(x) j x +#define bl(x) l x +#define alt(x) x< +#define bma(x) main x +#define bob(x) [x +#define boc(x) {x +#define bop(x) (x +#define bpl(x) +x +#define app(x) x++ +#define bqu(x) 'x +#define bse(x) ;x +#define bst(x) *x bma(acp(bop(app(bcp(ai(boc(ase(bch(a16(bl(alt(bob(ai(b66(ase(bcb(a0(bcm(aeq(bst(acb(bj(a64(bse(aob(bin(al(bi(aeq(bse(ai(bex(aop(bch(afo(bst(ase(bix(()))))))))))))))))))))))))))))))))))))))) bl(ai(bob(aob(bi(al(bcb(aop(beq(apl(b13(a13(bpl(aeq(bop(acb(bl(bob(a32(bi(bpl(apl(b16(bcb(ai(beq(b19(aob(bpl(bop(l)))))))))))))))))))))))))))))) -bpl(acp(b48(acp(asi(bcb(aop(beq(age(bop(aeq(bi(ai(bgt(aop(b12(aop(bqm(awh(b12(ase(bco(acp(bi(acp(bcp(acp(bpl(aqu(bqu(A)))))))))))))))))))))))))))))) +bpl(acp(b48(acp(asi(bcb(aop(beq(age(bop(aeq(bi(ai(bgt(aop(b12(aop(bqm(awh(b12(ase(bco(acp(bi(acp(bcp(acp(bpl('A')))))))))))))))))))))))))))) bne(acc(bef(ase(bcp(acp(aso(bpu(acm(ai(bop(aco(bop(acb(bj(al(beq(ami(bix(aj(axo(bop(a16(aob(bl(al(aqm(bcm(acp(acp(i)))))))))))))))))))))))))))))) diff --git a/1990/scjones/Makefile b/1990/scjones/Makefile index f5b1a9768..ac3c0f03f 100644 --- a/1990/scjones/Makefile +++ b/1990/scjones/Makefile @@ -379,7 +379,7 @@ endif # #CSTD= #CSTD= -ansi -CSTD= -std=gnu90 +CSTD= -std=gnu90 -ansi # compiler bit architecture # diff --git a/1990/scjones/README.md b/1990/scjones/README.md index 0c94bad17..af1f9504f 100644 --- a/1990/scjones/README.md +++ b/1990/scjones/README.md @@ -10,7 +10,18 @@ make all - NOTE: This entry may not compile when using modern compilers. + + Modern compilers might fail to compile this entry: + + scjones.c:1:7: error: expected ';' after top level declarator + char*a??(??)=??< + ^ + ; + + + but we were able to get it to compile with modern compilers by specifying the + `-ansi` flag with a tip from Yusuke Endoh. Thank you Yusuke! + ### To run diff --git a/1990/tbr/README.md b/1990/tbr/README.md index 7df5eadf2..80e7adc83 100644 --- a/1990/tbr/README.md +++ b/1990/tbr/README.md @@ -10,8 +10,6 @@ make all - NOTE: This entry may not compile when using modern compilers. - ### To run ./tbr @@ -20,23 +18,28 @@ This program implements a subject a well known Un*x utility whose original source was considered to be extremely obfuscated by many - people, excluding its author. In fact, this utility one a major + people, excluding its author. In fact, this utility was a major inspiration for the formation of this contest. The author supplied us with a slightly smaller unformatted version of the program which we include below: - #define D ,close( - char*c,q[512],m[256],*v[99],**u,*i[3];int f[2],p;main(){for(m[m[60]=m[62]= - 32]=m[*m=124[m]=9]=6;e(-8),gets(1+(c=q))||exit(0);r(0,0))for(;*++c;);} - r(t,o){*i=i[2]=0;for(u=v+98;m[*--c]^9;m[*c]&32?i[*c&2]= - *u,u-v^98&&++u:3)if(!m[*c]){for(*++c=0;!m[*--c];);*--u= - ++c;}u-v^98?strcmp(*u,"cd")?*c?pipe(f),o=f[1]:1,(p=fork())?e(p),o? - r(o,0)D o)D*f):4,wait(0):(o?dup2(*f,0)D*f)D o):*i?1 D - 0),e(open(*i,0)):5,t?dup2(t,1)D t):i[2]?9 D - 1),e(creat(i[2],438)):2,e(execvp(*u,u))):e(chdir(u[1])*2):6;} - e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||exit(1):5;} - + #define D ,close( + char*c,q[512],m[256],*v[99],**u,*i[3];int f[2],p;main(){for(m[m[60]=m[62]= + 32]=m[*m=124[m]=9]=6;e(-8),gets(1+(c=q))||(exit(0),0);r(0,0))for(;*++c;);} + r(t,o){*i=i[2]=0;for(u=v+98;m[*--c]^9;m[*c]&32?i[*c&2]= + *u,u-v^98&&++u:3)if(!m[*c]){for(*++c=0;!m[*--c];);*--u= + ++c;}u-v^98?strcmp(*u,"cd")?*c?pipe(f),o=f[1]:1,(p=fork())?e(p),o? + r(o,0)D o)D*f):4,wait(0):(o?dup2(*f,0)D*f)D o):*i?1 D + 0),e(open(*i,0)):5,t?dup2(t,1)D t):i[2]?9 D + 1),e(creat(i[2],438)):2,e(execvp(*u,u))):e(chdir(u[1])*2):6;} + e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||(exit(1),0):5;} + + + Modern compilers had a problem with this entry because the exit(3) function + returns void but we were able to get it to compile by using the comma + operator which we also did in the smaller version. + ## Author's comments Guvf cebtenz vf n ehqvzragnel furyy. Vg qbrf v/b erqverpgvba, cvcrf diff --git a/1990/tbr/tbr.c b/1990/tbr/tbr.c index 44e342e08..70c39ee19 100644 --- a/1990/tbr/tbr.c +++ b/1990/tbr/tbr.c @@ -4,7 +4,7 @@ char *c,q [512 ],m[ 256 ],*v[ 99], **u, *i[3];int f[2],p;main (){for (m[m [60]= m[62 ]=32 ]=m[* m=124 [m]= 9]=6; - e(-8) ,gets (1+( c=q) )|| exit (0); r(0,0) + e(-8) ,gets (1+( c=q) )|| (exit (0),0); r(0,0) )for( ;*++ c;); }r(t, o){ *i=i [2]= 0;for (u=v +98 ;m[*--c] ^9;m [*c] &32 ?i[*c &2]= *u,u- v^98 &&++u: @@ -19,5 +19,5 @@ char *c,q [512 ],m[ 256 2 ]? 6 D 1),e(creat(i[2],438)): 5 ,e(execvp(*u,u))):e(chdir(u[1])*2): - 3 ;}e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||exit(1): + 3 ;}e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||(exit(1),0): 5 ;} diff --git a/1990/westley/README.md b/1990/westley/README.md index e8fd3e7e5..e3ab0e9a0 100644 --- a/1990/westley/README.md +++ b/1990/westley/README.md @@ -36,8 +36,8 @@ make it easier on news readers, we converted each control-L to a blank line. - Some ANSI compilers will not accept '1s' as a short integer - for - these compilers replace the '1s' with '1'. + Some modern compilers will not accept '1s' as a short integer - for + these compilers we replaced the instances of `1s` with `1`. ## Author's comments diff --git a/1990/westley/westley.c b/1990/westley/westley.c index 5d63757cc..70f787618 100644 --- a/1990/westley/westley.c +++ b/1990/westley/westley.c @@ -28,7 +28,7 @@ dear; (char)lotte--; #define love (char*)lie - - love 1s *!(not= atoi(let + love 1 *!(not= atoi(let [get -me? @@ -90,13 +90,13 @@ get; !out; (char)*lie & 0xD0- !not) return!! register this; switch( (char)lie - [(char)lotte] -1s *!out) { + [(char)lotte] -1 *!out) { char*les, get= 0xFF, my; case' ': *((char*)&lotte) += 15; !not +(char)*lie*'s'; - this +1s+ not; default: 0xF +(char*)lie;}}} + this +1+ not; default: 0xF +(char*)lie;}}} get - !out;