Merge pull request #10 from xexyl/birthday-updates
This commit is contained in:
15 files changed
+80
-37
No files matched your search
+17
-14
@@ -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
|
||||
|
||||
+2
-2
@@ -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 ;}
|
||||
Reference in new issue
Block a user