Merge pull request #285 from xexyl/gets-alt
This commit is contained in:
31 files changed
+672
-86
No files matched your search
@@ -1 +1,2 @@
|
||||
wall
|
||||
wall.alt
|
||||
+2
-2
@@ -115,8 +115,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
|
||||
+25
-15
@@ -7,27 +7,25 @@ Panorama City, CA 91402 USA
|
||||
|
||||
## To build:
|
||||
|
||||
make all
|
||||
```sh
|
||||
make all
|
||||
```
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made this entry safer
|
||||
by changing `gets()` to `fgets()`. Thank you Cody for your assistance! If you
|
||||
wish for the original unsafe version you can make the following change:
|
||||
|
||||
-signal())();char*V,cm,D['x'],M='\n',I;L(MV,V,(c+='d',ix))m(x){v)
|
||||
+signal())();char*V,cm,D['x'],M='\n',I,*gets();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"
|
||||
|
||||
## To run:
|
||||
|
||||
```sh
|
||||
./wall
|
||||
# enter some strings
|
||||
|
||||
./wall
|
||||
# enter some strings
|
||||
./wall | some_command
|
||||
# enter some strings
|
||||
```
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made this safer by
|
||||
using `fgets()` instead of `gets()`. The original source is in
|
||||
[wall.alt.c](wall.alt.c) described below. Thank you Cody!
|
||||
|
||||
./wall | some_command
|
||||
# enter some strings
|
||||
|
||||
## Try:
|
||||
|
||||
@@ -55,6 +53,18 @@ and enter some input like:
|
||||
2^x
|
||||
quit # for the cat version
|
||||
|
||||
### Alternate code:
|
||||
|
||||
|
||||
For the original version that uses `gets()` try:
|
||||
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `wall.alt` as you would `wall`.
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#define iv 4
|
||||
#define v ;(void
|
||||
#define XI(xi)int xi[iv*'V'];
|
||||
#define L(c,l,i)c(){d(l);m(i);}
|
||||
#include <stdio.h>
|
||||
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,*gets();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(){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<i&&l(-c-c,
|
||||
"%d"),l(i,"+%d")):l(i,"(%d")):(c&&l(M,")"),l(*D,"%c")),c=i;c&&l(X,")"),l
|
||||
(-i,"%c");m(iv-!(i&I));}L(ml,V,'\f')li(){m(cm+!isatty(i=I));}ii(){m(c=cm
|
||||
= ++I)v)pipe(VI);cc=xi+cm++;for(V="jWYmDEnX";*V;V++)xi[*V^' ']=c,xi[*V++]
|
||||
=c,c*=M,xi[*V^' ']=xi[*V]=c>>I;cc[-I]-=ix v)close(*VI);cc[M]-=M;}main(){
|
||||
(*vi)();for(;v)write(VI[I],V,M));}l(xl,lx)char*lx;{v)printf(lx,xl)v)
|
||||
fflush(stdout);}L(xx,V+I,(c-=X/cm,ix))int(*vi[])()={ii,li,LXX,LV,exit,l,
|
||||
d,l,d,xv,MM,md,MC,ml,MV,xx,xx,xx,xx,MV,mi};
|
||||
@@ -1 +1,2 @@
|
||||
cmills
|
||||
cmills.alt
|
||||
@@ -115,8 +115,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
|
||||
+23
-12
@@ -8,32 +8,43 @@
|
||||
|
||||
## To build:
|
||||
|
||||
make all
|
||||
```sh
|
||||
make all
|
||||
```
|
||||
|
||||
## To run
|
||||
|
||||
./cmills [starting_cash]
|
||||
```sh
|
||||
./cmills [starting_cash]
|
||||
```
|
||||
|
||||
We used a patch from [Yusuke Endoh](/winners.html#Yusuke_Endoh) to get this to
|
||||
work in modern systems (it resulted in a bus error otherwise). Thank you Yusuke
|
||||
for your assistance!
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made the program safer
|
||||
by using `fgets()` instead of `gets()`. Thank you Cody for your help in making
|
||||
this safer! For the original code you can change the instances of:
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made this safer by
|
||||
using `fgets()` instead of `gets()`. Thank you Cody!
|
||||
|
||||
|
||||
!fgets(l,M,stdin)
|
||||
|
||||
to:
|
||||
|
||||
!gets(l)
|
||||
The original bug fixed version is in [cmills.alt.c](cmills.alt.c), described in
|
||||
the `Alternate code` section.
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
./cmills 5000
|
||||
```sh
|
||||
./cmills 5000
|
||||
```
|
||||
|
||||
### Alternate code:
|
||||
|
||||
For the original version that uses `gets()` try:
|
||||
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `cmills.alt` as you would `cmills`.
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#include<stdio.h>
|
||||
#include<time.h>
|
||||
#define S(q)B(*e=0),q,p);
|
||||
#define W(w)if((w)<22)v= -v;else v-=10;else
|
||||
#define F for(r=d;r<d+N;
|
||||
#define H(v,g)v=h(v,*g++= *r++),*g=0;
|
||||
#define B(n)b(l,n),(V)printf(l
|
||||
V
|
||||
exit();char*g,c[M],d[N],q[N],p[N],*e,*r=d+N,l[M],t[]="??",*k,*m="DEATHISDSev2oinpohae3ttsluuln4a?uibfe 5l\0rtlfrb6 ?a?el:e7$!n\0?e t8%ccp\0.%s9deelc.s T.@?-t.\t<J /\0=a\nP=Q Sex \0l KW Sin a$\0ane-lay% ge#-slediefuk ar r$via-:o ?+}:r? n \0:) ee%lone 1-esy666!-~v\n.!^`'~@#\0\np~===:=q";b(o,n)char*o;{for(k=n+m;*o++=*k;k+=9);}int
|
||||
y=M*2,v,x,s,f,j,o;u(s){B(s));if(!gets(l))exit(0);return(o=
|
||||
*l)=='y'||o=='Y'||o!='n'&&o!='N'&&u(s);}h(v,m){for(k=c;*k!='J';)if(m==*k++)break;m=k-c;if(v<0)W(v=m-v)
|
||||
if(m==1)W(v+=11)
|
||||
v+=m;return
|
||||
v;}main(w,z)char**z;{b(c,2)*X;for(--w&&(y=atoi(1[z]));y>1;){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(!gets(l)||(w=atoi(l))<1)exit(0);if(w&1||w>M||w>y)B(1),y<M?y:M);else
|
||||
break;}y-=w,s=f=j=x=v=0,g=q,e=p;H(x,g)H(x,g)H(v,e)H(v,e)*t=
|
||||
*q;S(t)*q=='A'&&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
|
||||
_;}while(x>-17&&x<17)H(x,g)while((v==20||*p==-1[e])&&y>=w&&u(6)){y-=w;++s;for(g=e++;2[g]=
|
||||
*g,g!=p;)--g;*g++=
|
||||
*e;*g=' ';i:v=h(h(0,*p),*e++=
|
||||
*r++);S(t)if(*p=='A'&&-1[e]!=
|
||||
*p)goto
|
||||
_;}if(f=y>=w&&u(7))y-=w,H(v,e)while(!f&&v<22&&u(4)){H(v,e)if(v<22)S(t)}_:x<0&&(x=
|
||||
-x);v<0&&(v=
|
||||
-v);if(v<22)if(v==x)j+=w*++f;else
|
||||
if(x>21||v>x)j+=w*2*++f;if(s--){*e++=' ';*e++=
|
||||
*p;*e=0;for(e=p;*e=2[e];)e++;goto
|
||||
i;}y+=j;S(q)};}
|
||||
+21
-16
@@ -15,7 +15,9 @@
|
||||
|
||||
## To build:
|
||||
|
||||
make all
|
||||
```sh
|
||||
make all
|
||||
```
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work with
|
||||
modern compilers; `exit(3)` returns void but the function was used in a binary
|
||||
@@ -24,24 +26,14 @@ expression so this wouldn't even compile. Cody also changed the code to use
|
||||
`gets()` at execution which was interspersed with the output. Thank you Cody for
|
||||
your assistance!
|
||||
|
||||
For the original version with `gets()` see the alternative code section below.
|
||||
|
||||
## Alternative code:
|
||||
|
||||
If you wish to see the original source (fixed so it can compile) that uses
|
||||
`gets()` instead of `fgets()` you can look at [tbr.alt.c](tbr.alt.c). To compile
|
||||
it:
|
||||
|
||||
make alt
|
||||
|
||||
Use `./tbr.alt` instead of `./tbr` for this version. You'll likely get a warning
|
||||
about the usage of `gets()`.
|
||||
|
||||
For the original version with `gets()` see the alternate code section below.
|
||||
|
||||
## To run:
|
||||
|
||||
./tbr
|
||||
# enter some shell commands
|
||||
```sh
|
||||
./tbr
|
||||
# enter some shell commands
|
||||
```
|
||||
|
||||
NOTE: globs do not work with this entry. Why?
|
||||
|
||||
@@ -61,6 +53,19 @@ or ctrl-c (or kill it from another terminal :-) ).
|
||||
What happens if you try using `cd -` to return to previous directory? What about
|
||||
`cd` with no args?
|
||||
|
||||
## Alternate code:
|
||||
|
||||
If you wish to see the original source (fixed so it can compile) that uses
|
||||
`gets()` instead of `fgets()` you can look at [tbr.alt.c](tbr.alt.c). To compile
|
||||
it:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `tbr.alt` as you would `tbr`. You'll likely get a warning about the usage of
|
||||
`gets()` and with macOS it will mess up output of the first line.
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
|
||||
|
||||
@@ -10,3 +10,14 @@ adsleep.c
|
||||
adwc
|
||||
adwc.c
|
||||
adrian
|
||||
adrian.alt
|
||||
adbasename.alt
|
||||
adbasename.alt.c
|
||||
adecho.alt
|
||||
adecho.alt.c
|
||||
adhead.alt
|
||||
adhead.alt.c
|
||||
adsleep.alt
|
||||
adsleep.alt.c
|
||||
adwc.alt
|
||||
adwc.alt.c
|
||||
+21
-2
@@ -118,8 +118,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
@@ -160,6 +160,25 @@ adgrep: ${PROG}
|
||||
# alternative executable
|
||||
#
|
||||
alt: data ${ALT_TARGET}
|
||||
${RM} -f ad.alt.temp adwc.alt.c adbasename.alt.c adecho.alt.c adhead.alt.c adsleep.alt.c
|
||||
${SED} '1s/\..*\./. wc ./' adrian.alt.c > ad.alt.temp
|
||||
-./adrian.alt ad.alt.temp <ad.alt.temp >adwc.alt.c
|
||||
${CC} ${CFLAGS} -o adwc.alt adwc.alt.c
|
||||
${SED} '1s/\..*\./. basename ./' adrian.alt.c > ad.alt.temp
|
||||
-./adrian.alt ad.alt.temp <ad.alt.temp >adbasename.alt.c
|
||||
${CC} ${CFLAGS} -o adbasename.alt adbasename.alt.c
|
||||
${SED} '1s/\..*\./. echo| ./' adrian.alt.c > ad.alt.temp
|
||||
-./adrian.alt ad.alt.temp <ad.alt.temp >adecho.alt.c
|
||||
${CC} ${CFLAGS} -o adecho.alt adecho.alt.c
|
||||
${SED} '1s/\..*\./. head; ./' adrian.alt.c > ad.alt.temp
|
||||
-./adrian.alt ad.alt.temp <ad.alt.temp >adhead.alt.c
|
||||
${CC} ${CFLAGS} -o adhead.alt adhead.alt.c
|
||||
${SED} '1s/\..*\./. sleep ./' adrian.alt.c > ad.alt.temp
|
||||
-./adrian.alt ad.alt.temp <ad.alt.temp >adsleep.alt.c
|
||||
${CC} ${CFLAGS} -o adsleep.alt adsleep.alt.c
|
||||
${RM} -f ad.alt.temp
|
||||
|
||||
|
||||
@${TRUE}
|
||||
|
||||
# data files
|
||||
|
||||
+25
-4
@@ -8,7 +8,9 @@
|
||||
|
||||
## To build:
|
||||
|
||||
make all
|
||||
```sh
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) changed the location
|
||||
@@ -23,15 +25,34 @@ macro definition! Thus the code now first trims off the last character of the
|
||||
buffer read to get the same correct functionality but in a safe way. Thank you
|
||||
Cody for your assistance!
|
||||
|
||||
|
||||
For the original version [adrian.alt.c](adrian.alt.c) see the `Alternate code` section below.
|
||||
|
||||
## Try:
|
||||
|
||||
./adrian adrian.grep.try < README.md
|
||||
```sh
|
||||
./adrian adrian.grep.try < README.md
|
||||
```
|
||||
|
||||
For the slow minded, try:
|
||||
|
||||
./adsleep 32767
|
||||
```sh
|
||||
./adsleep 32767
|
||||
```
|
||||
|
||||
NOTE: if you do not specify an arg to the program it will segfault.
|
||||
|
||||
### Alternate code:
|
||||
|
||||
For the original version that uses `gets()` try:
|
||||
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `adrian.alt` as you would `adrian`.
|
||||
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/* . wc . */
|
||||
#include<stdio.h>/* Wht majr flwchrt? */
|
||||
#include<string.h>/* That mjr flwchrt! */
|
||||
#define P 257
|
||||
#define G 17
|
||||
#define z 8
|
||||
#define v(jr) jr
|
||||
int W ,head;
|
||||
#define S(W,b,f) strncpy(W,b,f),W[f]=0\
|
||||
|
||||
|
||||
char *wcs=" \t\n";
|
||||
struct{ char X[z+1];
|
||||
char f ;
|
||||
int e ;
|
||||
struct{ char g[z+1];
|
||||
int b ;
|
||||
} w[ G];
|
||||
} o[ P];
|
||||
int L=0,j= -28;
|
||||
|
||||
|
||||
void E(int i, int m,char*c)
|
||||
{
|
||||
for(; i<43; i+=3)
|
||||
putc("}|uutsrq`_^bji`[Zkediml[PO]a_M__]ISOYIRGTNR"[i]+i-9,stderr);
|
||||
fprintf(stderr,"(%d): %s\n" ,m,c);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int N(int m, char *t)
|
||||
{
|
||||
int i ;
|
||||
if (strlen (
|
||||
t)>z) t[z ]=0;
|
||||
for(i= 0; i< L ; i++) if(
|
||||
!strcmp (o[ i] . X
|
||||
, t))return i;
|
||||
if( L== P)
|
||||
E(0, m, t);
|
||||
S (o[ L] . X , t
|
||||
,z);
|
||||
head; W = .1* head;
|
||||
o[L ].f = !( strchr( t,']' )== 0 );
|
||||
o[L ++ ] . e = 0;
|
||||
return L -1 ; }
|
||||
|
||||
#define v(x )
|
||||
|
||||
int A(char *R)
|
||||
{
|
||||
int c=0, i;
|
||||
while(* R) {
|
||||
i = -1;
|
||||
while(j){
|
||||
if( ++ i==o[ c].e ) return 0;
|
||||
if(o[
|
||||
c] .w[i ] .g[0 ]
|
||||
=='.' ||strchr (o[ c].w[i] .g ,* R)){
|
||||
c=
|
||||
o[ c ] .w[i].b; break;/*
|
||||
main(int sl,char *j[]){
|
||||
sleep (~~~~~~~~atoi(j[1])) ;/* . sl
|
||||
sl s l . sl
|
||||
l l ]
|
||||
sl */ }
|
||||
}
|
||||
R++;
|
||||
}
|
||||
return o[ c].f;
|
||||
}
|
||||
|
||||
|
||||
main(int wc,char *V[]){char Y[999],*s;FILE*W;int m=0,echo,jr,q,wcl=0,wcw=0,wcc=0;
|
||||
v(s = V[1]; if (*V=strrchr(s,'/'))s=*V+1; if(( !strncmp( s + (jr=strlen(s)) -
|
||||
(q=strlen(V[2]) ),V[2],q))&&jr!=q) s[jr-q] = 0; puts(s); )
|
||||
int e,p,C=0,Q ,basename;
|
||||
W= fopen(wc>= 2 ? V[1] : "adgrep.c","rt");
|
||||
echo| m^ e| 5| (int) .8| echo|
|
||||
wc |C ==o[o[C] .e] .
|
||||
e| e==+p,p; s[o[C] .e ]
|
||||
;
|
||||
while( fgets(Y,998,W)) { wcc += strlen(Y); m++;
|
||||
if( s = strtok(Y,wcs)) wcw++;
|
||||
else continue ;
|
||||
C=
|
||||
basename= j +j+*"* . basename"
|
||||
+j+*"* r ] " + N(m,s) ;
|
||||
while( s = strtok(0,wcs)) {
|
||||
if( o[ C ] . e ==
|
||||
G) E(1 ,m,o[C] .X) ;
|
||||
S(o[C
|
||||
] .w[o[C ] .e].g,s, z);
|
||||
Q= C ;
|
||||
if(! ( s =strtok ( 0 ,wcs )))wcw --
|
||||
,E( 2 , m, o[C]
|
||||
. w[ o[ Q ] .e] . g );
|
||||
e
|
||||
= o[C ] .w[o[C ] .e++ ] .b= N(m,s)
|
||||
; wcw += 2; }
|
||||
0&&
|
||||
W && wcl++
|
||||
< 10 && printf((W,Y)); }
|
||||
if(j+28) { {
|
||||
; } printf("%7u%7u%7u\n", wcl , wcw , wcc); }
|
||||
while( gets(Y) ) if(A(Y)) puts(Y);
|
||||
W, jr; }
|
||||
|
||||
O(int wc,char**V) {
|
||||
--wc && (printf("%s ",*++V), main(wc,V), 1) || printf("\n"); }
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define v(jr) jr
|
||||
int W ,head;
|
||||
#define S(W,b,f) strncpy(W,b,f),W[f]=0\
|
||||
|
||||
|
||||
char *wcs=" \t\n";
|
||||
struct{ char X[z+1];
|
||||
char f ;
|
||||
|
||||
+6
-6
@@ -17,12 +17,12 @@
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) changed the buffer size
|
||||
in such a way that gets() should be safe (theoretically) as it comes from the
|
||||
command line. Ideally `fgets()` would be used but this is a more problematic.
|
||||
Previously it had a buffer size of 256 which could easily overflow. Now in this
|
||||
entry `gets()` is used in a more complicated way. First `m` is set to `*++p` in
|
||||
a for loop where `p` is argv and then later `m` is set to point to `h` which is
|
||||
of size 256. `gets()` is called as `m = gets(m)`) but trying to change it to use
|
||||
fgets() proved more a problem. Since the input must come from the command line
|
||||
Cody changed the buffer size to `ARG_MAX+1` which should be enough (again
|
||||
Previously it had a buffer size of 256 which could easily overflow. In this
|
||||
entry `gets()` is used in a more complicated way: first `m` is set to `*++p` in
|
||||
a for loop where `p` is argv. Later `m` is set to point to `h` which was of size
|
||||
\256. `gets()` is called as `m = gets(m)`) but trying to change it to use fgets()
|
||||
proved more a problem. Since the input must come from the command line Cody
|
||||
changed the buffer size to `ARG_MAX+1` which should be enough (again
|
||||
theoretically) especially since the command expects redirecting a dictionary
|
||||
file as part of the command line. This also makes it possible for longer strings
|
||||
to be read (in case the `gets()` was not used in a loop). Thank you Cody for
|
||||
|
||||
+2
-2
@@ -112,8 +112,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
|
||||
+21
-5
@@ -15,11 +15,27 @@
|
||||
|
||||
|
||||
[Yusuke Endoh](/winners.html#Yusuke_Endoh) supplied a patch which makes this
|
||||
work with gcc. Thank you Yusuke! [Cody Boone
|
||||
Ferguson](/winners.html#Cody_Boone_Ferguson) made it use `fgets()` instead of
|
||||
`gets()` and also added the `runme.sh` script to demonstrate it (using make was
|
||||
problematic). Cody notes that unfortunately this does not work with clang due to
|
||||
different compiler messages. Thank you Cody!
|
||||
work with gcc. Due to how it works (see Judges' comments below) this will not
|
||||
work with clang. Thank you Yusuke!
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made it use `fgets()`
|
||||
instead of `gets()` and also added the `runme.sh` script to demonstrate it
|
||||
(using make was problematic). Cody notes that unfortunately this does not work
|
||||
with clang due to different compiler messages. Thank you Cody!
|
||||
|
||||
For the original entry see [lush.alt.c](lush.alt.c) described in the `Alternate
|
||||
code` section below.
|
||||
|
||||
### Alternate code:
|
||||
|
||||
The original source (fixed to work with gcc) which uses gets() try:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `lush.alt` as you would `lush`.
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
#define f 000:
|
||||
char
|
||||
*s,*
|
||||
t,v;
|
||||
char
|
||||
_ [
|
||||
999]
|
||||
,x [
|
||||
999]
|
||||
,*p=
|
||||
x ;
|
||||
char
|
||||
*av[
|
||||
]= {
|
||||
"W",
|
||||
"H",
|
||||
"o",
|
||||
"l",
|
||||
"N",
|
||||
"e",
|
||||
" ",
|
||||
"r",
|
||||
"d",
|
||||
".",
|
||||
"m",
|
||||
"s",
|
||||
"g",
|
||||
"!",
|
||||
"*",
|
||||
"\n"
|
||||
} ;
|
||||
int
|
||||
n= 0
|
||||
;int
|
||||
__ =
|
||||
0,i=
|
||||
000;
|
||||
main
|
||||
() {
|
||||
#define f 001:
|
||||
#define F 042:
|
||||
#define f 100:
|
||||
_[i--
|
||||
#define f 126:
|
||||
#define f 132:
|
||||
#define f 103:
|
||||
#define f 202:
|
||||
#define f 666:
|
||||
#define f 77::
|
||||
#define f 101:
|
||||
]=0
|
||||
#define f 232:
|
||||
#define f 151:
|
||||
;if(
|
||||
#define f 256:
|
||||
!i){
|
||||
puts
|
||||
("I"
|
||||
"BM"
|
||||
" S"
|
||||
"UX"
|
||||
);;;
|
||||
;;;}
|
||||
;for
|
||||
( ;
|
||||
gets
|
||||
(_);
|
||||
) {
|
||||
for(
|
||||
#define f 301:
|
||||
t=_,
|
||||
#define f 700:
|
||||
#define f 999:
|
||||
s=t,
|
||||
#define f 77 :
|
||||
#define f 300:
|
||||
s=t;
|
||||
#define f s=t;
|
||||
#define f 123:
|
||||
#define f 127:
|
||||
*t&&
|
||||
!(!(
|
||||
*t <
|
||||
'0'
|
||||
||*t
|
||||
>'9'
|
||||
)&&!
|
||||
((t[
|
||||
1] ^
|
||||
':')
|
||||
&&(t
|
||||
[1]^
|
||||
'.')
|
||||
)) ;
|
||||
t++)
|
||||
#define f 137:
|
||||
#define f 133:
|
||||
;if(
|
||||
#define f 111:
|
||||
#define f 220:
|
||||
v^*t
|
||||
&&*t
|
||||
){v=
|
||||
*t;;
|
||||
n=n*
|
||||
2+(1
|
||||
&*t)
|
||||
;__=
|
||||
(__+
|
||||
1)&3
|
||||
; __
|
||||
||((
|
||||
n<15
|
||||
&&(*
|
||||
p= *
|
||||
av[n
|
||||
] ),
|
||||
#define f 2+2:
|
||||
p++)
|
||||
,n=0
|
||||
);}}
|
||||
#define f ==4:
|
||||
;*p=
|
||||
'\0'
|
||||
;;;;
|
||||
#define f puts
|
||||
puts
|
||||
(x);
|
||||
s=t;
|
||||
#define f s=5;
|
||||
s=t;
|
||||
#define f s=5:
|
||||
s=t;
|
||||
#define f 445:
|
||||
#define f 113:
|
||||
#define f 900:
|
||||
s=t;
|
||||
#define f n22:
|
||||
#define f n40:
|
||||
s=t;
|
||||
#define f nn6:
|
||||
s=t;
|
||||
#define f nn1:
|
||||
#define f 0:--
|
||||
s=t;
|
||||
#define f 19:-
|
||||
#define f x2:x
|
||||
s=t;
|
||||
#define f x1:x
|
||||
s=t;
|
||||
#define f y2:x
|
||||
#define f y7:y
|
||||
s=t;
|
||||
#define f 1:::
|
||||
s=t;
|
||||
#define f @3:@
|
||||
#define f 10:0
|
||||
#define f x+1:
|
||||
s=t;
|
||||
#define f 2:::
|
||||
#define f 3:::
|
||||
#define x 7:::
|
||||
#define y 3:::
|
||||
#define z 990:
|
||||
#define Z 47::
|
||||
;;;}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
make all
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to not
|
||||
segfault when no file is specified or the file cannot be opened for reading. he
|
||||
segfault when no file is specified or the file cannot be opened for reading. He
|
||||
also made this use `fgets()` not `gets()` to make it safer. Thank you Cody for
|
||||
your assistance!
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
ldb
|
||||
ldb.alt
|
||||
+2
-2
@@ -111,8 +111,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
# FORCE use of -trigraphs
|
||||
#
|
||||
|
||||
+26
-7
@@ -8,7 +8,9 @@ USA
|
||||
|
||||
## To build:
|
||||
|
||||
make all
|
||||
```sh
|
||||
make all
|
||||
```
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this so it would
|
||||
compile and work with modern compilers. The problem was that `srand()` returns
|
||||
@@ -21,21 +23,38 @@ a line is greater than 231 in length if the program chooses that line it might
|
||||
print the first 231 characters or it might print (up to) the next 231 characters
|
||||
and so on. Thank you Cody for your assistance!
|
||||
|
||||
For the original fixed version [ldb.alt.c](ldb.alt.c) see below.
|
||||
|
||||
|
||||
## To run:
|
||||
|
||||
./ldb < file
|
||||
```sh
|
||||
./ldb < file
|
||||
|
||||
some_command | ./ldb
|
||||
some_command | ./ldb
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
./ldb < /etc/passwd
|
||||
```sh
|
||||
./ldb < /etc/passwd
|
||||
|
||||
printf "The International Obfuscated C Code Contest\n
|
||||
Best One-liner\n
|
||||
by Laurion Burchall" | ./ldb
|
||||
printf "The International Obfuscated C Code Contest\n
|
||||
Best One-liner\n
|
||||
by Laurion Burchall" | ./ldb
|
||||
```
|
||||
|
||||
### Alternate code:
|
||||
|
||||
For the original version fixed so that it will compile with modern compiles,
|
||||
try:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `ldb.alt` as you would `ldb`.
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
int _,O,__??('}'??);main(){while(O?gets((rand()%O++?':':_)+__)||puts(&__??(_??))&_:(srand(time((O+++_))),0)||O);}
|
||||
@@ -1 +1,2 @@
|
||||
schnitzi
|
||||
schnitzi.alt
|
||||
@@ -112,8 +112,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
|
||||
+22
-5
@@ -8,11 +8,15 @@ USA
|
||||
|
||||
## To build:
|
||||
|
||||
make all
|
||||
```sh
|
||||
make all
|
||||
```
|
||||
|
||||
## To run:
|
||||
|
||||
./schnitzi < textfile
|
||||
```sh
|
||||
./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
|
||||
@@ -21,17 +25,30 @@ 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 this Makefile. Cody
|
||||
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:
|
||||
|
||||
./schnitzi < /etc/motd
|
||||
./schnitzi < /etc/passwd
|
||||
```sh
|
||||
./schnitzi < /etc/motd
|
||||
./schnitzi < /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
### Alternate code:
|
||||
|
||||
For the original version with a smaller buffer try:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `schnitzi.alt` as you would `schnitzi`.
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#include <stdio.h>
|
||||
int r=0,x,y=0, /*
|
||||
nt /
|
||||
c
|
||||
lx /\ / \ /|\ /|\
|
||||
u, \/ \\/ \-/ \ /
|
||||
dn ]
|
||||
e= ||| /|\ /\ /\ = p p
|
||||
0 \/ \ / ||| \/ f f f r r
|
||||
<, tw t s s i i
|
||||
sy || /|\ /\ i eh e e c n n
|
||||
t= /- \ / ||| n li l e a t t
|
||||
d0 ||| t ll l {< k n f f
|
||||
i, || /|\ /|\ (e s ( fr ( f ( (
|
||||
o _ ||\ \ / \-/ tu s( t usw o; i s ( " "
|
||||
. || - / c [[ tg rv [th rx=f t " % \
|
||||
h mh111 de{l) +di (+'( d+% c n+
|
||||
> aa000 itte; > +il x+ n inc " "+
|
||||
/ ir000[ns[nytyrrne<=)'<xn," , );
|
||||
*/ n = 0 ;
|
||||
main ( ) {
|
||||
char v [
|
||||
100 ] , s;
|
||||
int t[100 ] ,
|
||||
u[100 ] ; u
|
||||
[ 0
|
||||
]=ftell(stdin ) ;
|
||||
while(gets (v ) )
|
||||
{t [ r ]=
|
||||
strlen (
|
||||
v);y=
|
||||
t[ r ]
|
||||
>y ? t [
|
||||
r ] : y;
|
||||
u[++r ] =
|
||||
ftell(stdin ) ; }
|
||||
while ( n
|
||||
< y )
|
||||
{for(x=0 ; x
|
||||
<r;x++) { s
|
||||
=' ' ;
|
||||
if(n< t [
|
||||
x ] ) {
|
||||
fseek(stdin ,u [ x ]
|
||||
+n , 0 ) ;
|
||||
scanf("%c", &
|
||||
s )
|
||||
; }
|
||||
printf("%c", s )
|
||||
; }
|
||||
printf("\n"); n
|
||||
++ ; } }
|
||||
@@ -1 +1,2 @@
|
||||
anderson
|
||||
anderson.alt
|
||||
@@ -114,8 +114,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
|
||||
@@ -15,6 +15,8 @@ make
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) changed this entry to
|
||||
use `fgets()` instead of `gets()` to make it safer. Thank you Cody!
|
||||
|
||||
For the original source [anderson.alt.c](anderson.alt.c) see below.
|
||||
|
||||
|
||||
## To run:
|
||||
|
||||
@@ -28,6 +30,17 @@ echo something | ./anderson
|
||||
echo Obfuscate | ./anderson
|
||||
```
|
||||
|
||||
### Alternate code:
|
||||
|
||||
For the original version that uses `gets()` try:
|
||||
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `anderson.alt` as you would `anderson`.
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
This small program might be a nice addition to a digital personal
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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
|
||||
[r[3]=M[1-(x&1)][*r=W,1],2]=*Q+2,1]=x+1+Y,*g++=((((x& 7)
|
||||
-1)>>1)-1)?*r:r[x>>3],(++x<*r)&&X();}E(){A||X(x=0,g =J
|
||||
),x=7&(*T>>A*3),J[(x[F]-W-x)^A*7]=Q[x&3]^A*(*M)[2 +(
|
||||
x&1)],g=J+((x[k]-W)^A*7)-A,g[1]=(*M)[*g=M[T+=A ,1
|
||||
][x&1],x&1],(A^=1)&&(E(),J+=W);}l(){E(--q&&l ()
|
||||
);}B(){*J&&B((D=*J,Q[2]<D&&D<k[1]&&(*g++=1 ),
|
||||
!(D-W&&D-9&&D-10&&D-13)&&(!*r&&(*g++=0) ,*
|
||||
r=1)||64<D&&D<91&&(*r=0,*g++=D-63)||D >=
|
||||
97&&D<123&&(*r=0,*g++=D-95)||!(D-k[ 3]
|
||||
)&&(*r=0,*g++=12)||D>k[3]&&D<=k[ 1]
|
||||
-1&&(*r=0,*g++=D-47),J++));}j( ){
|
||||
putchar(A);}b(){(j(A=(*K)[D* W+
|
||||
r[2]*Y+x]),++x<Y)&&b();}t ()
|
||||
{(j((b(D=q[g],x=0),A=W) ),
|
||||
++q<(*(r+1)<Y?*(r+1): Y)
|
||||
)&&t();}R(){(A=(t( q=
|
||||
0),'\n'),j(),++r [2
|
||||
]<N)&&R();}O() {(
|
||||
j((r[2]=0,R( ))
|
||||
),r[1]-=q) &&
|
||||
O(g-=-q) ;}
|
||||
C(){( J=
|
||||
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(
|
||||
(J=(
|
||||
A=0)
|
||||
[K],
|
||||
A[M]
|
||||
=(F=
|
||||
(k=(
|
||||
M[!A
|
||||
]=(Q
|
||||
=T+(
|
||||
q=(Y
|
||||
=(W=
|
||||
32)-
|
||||
(N=4
|
||||
))))
|
||||
+N)+
|
||||
2)+7
|
||||
)+7)
|
||||
),Y=
|
||||
N<<(
|
||||
*r=!
|
||||
-A))
|
||||
);;}
|
||||
Reference in new issue
Block a user