The problem was a missing +1 for strlen() in a malloc() call. This entry still uses gets() and strangely changing it to fgets() makes it segfault but I'll worry about this later when more entries have been checked and (if possible) fixed.
134 lines
2.6 KiB
C
134 lines
2.6 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#define PI 314
|
|
#define Z if
|
|
#define P a->b
|
|
#define Q else
|
|
#define W =f();
|
|
#define X char
|
|
#define J while
|
|
#define N return
|
|
#define V struct e
|
|
|
|
#define g(_,a)((_&&a)?!strcmp(_,a):0)
|
|
typedef V*d; V{ d o,_; X*b; int c; };
|
|
d f() { d _=(d)malloc(sizeof(V)); _
|
|
->b=0; _->o=_->_=0; _->c=1>>1>1;
|
|
N _; } d k,l,m,n,o,p,q,r; d j
|
|
() { d _=l; d a W a->o W
|
|
l->o=a; l W l-> _=_;
|
|
N a; } d u(d _,
|
|
X*a){ J(_){
|
|
Z(g(a,_
|
|
->b)
|
|
){
|
|
N
|
|
_;
|
|
} _=
|
|
_->_; }
|
|
N 0; } d s
|
|
(X*q){ d _=n; Z
|
|
(g("q", q)){ N o; }
|
|
J(PI){ _=u(_,"cde"); _=_
|
|
-> _ ; Z ( g (q, _->b) ){ N _
|
|
->_ ; } } } void t(d a, d _) { d
|
|
S,I,M,U,L,A,T,O,R ; Z(a==o){ S W
|
|
S->o W m->o=S; I=m; m W m->_=I; _=_->
|
|
_; J(_) { S->o->o=_->o; I=S->o; S->o W
|
|
S->o->_=I; _->o->o->o=S; I=_->o->o; _
|
|
->o->o W _->o->o->_=I; _=_->_; } }
|
|
Q { M W _=_->_; J(57-*P){ U=M; U
|
|
->b=P; U->o=_->o; M W M->_=U;
|
|
_=_->_; a=a->_; } a=a->_
|
|
; J(a&&!g("qtm",P)&&
|
|
!g("cde",P)){ L
|
|
=s (P); a=a
|
|
->_; A=
|
|
L; T
|
|
W
|
|
O=
|
|
T;
|
|
J(*L
|
|
->b-57){ R
|
|
=g("/",P)?j():g
|
|
(P,"0")?p:g("b",P)?
|
|
q:g(P,"j")?r:0; Z(!!!R){
|
|
R=u(M,P); Z(!R) { R=j(); U=M;
|
|
U->b=P; U->o=R; M W M->_=U; } Q{
|
|
R=R->o; } } O=O->_ W O->o=R; O->b=L
|
|
->b; L=L->_; a=a->_; } t(A, T); } } }
|
|
void h(d e){ d _,a,c, z=e->o->_; J(z){
|
|
_=z->o; c=_->o->_; a= c->_->_->o; c=_
|
|
->c?c->_->o :c->o; Z(c->c<a->c) { c
|
|
->c++; h(c); } Q Z(a->c<c->c){ a
|
|
->c++; h(a); } z=z->_; } } X*
|
|
v(X*_,int O){ X*s=(X*)m\
|
|
alloc(1+strlen(_)*siz\
|
|
eof(X)); X*l=s;
|
|
J((*l++=*_?
|
|
*_-O:0)
|
|
)_++
|
|
;N
|
|
s;
|
|
}
|
|
/**/
|
|
int ma\
|
|
in(){d a,_
|
|
,b;d T,O,F,U
|
|
, R, E, L, A, Y
|
|
; X c[PI],x[PI],w[PI],*y
|
|
,*B,*d,*K=v("Cvjme!dpnqmfuf;\
|
|
!&e!dpnqpofout-!&e!opeft/\x0b",1
|
|
),*e=v("&e;!&t\x0b\0nbjo)*|jou!j>1\
|
|
<gps)<j=51<j,,*qsjoug)#&e!#-j+j,j,52\
|
|
*<~",1); int i,z,C,G,H,D,I ; k W l W m
|
|
W n W o W p W q W r W b=o; for(*x=D=I
|
|
=i=0; 5-i; i++){ b->b=i&4?v(";",2):
|
|
v("s",2); b=b->_ W } H=p->c=1; p
|
|
->o W r->o W q->o W a=n; J(g\
|
|
ets(c)){ d=c; J(*d){ *d=
|
|
*d<65||*d>90 ?*d:*d+
|
|
32; d++; } y=s\
|
|
trchr(c,35)
|
|
; Z(y){
|
|
*y=0
|
|
;
|
|
}
|
|
B
|
|
=st\
|
|
rtok(c,
|
|
" "); J(B)
|
|
{ a=a->_ W P=v(
|
|
B,1); Z(g("qtm",P))
|
|
{ _=a; } B=strtok(0," ")
|
|
; } } _=_->_; z=atoi(v(_->b,-
|
|
1)); _=_->_; C=atoi(v(_->b,-1));
|
|
G=C; _=_->_; T=s(_->b); _=_->_; O W
|
|
F=O; U=k; J(_&&!g( "cde",_->b)){ i=*_
|
|
->b; R=i-47?48-i?i-98?106-i?0:r:q:p:j(
|
|
); Z(!R){ R=j(); U=U->_ W U->o=R; } F
|
|
= F->_ W F->o=R; _=_->_; } t(T, O);
|
|
E=m->_; J(E){ D++; E=E->_; } L=l
|
|
->_; J(L){ I++; L =L->_; } p\
|
|
rintf(K,D,I); for(i='\''
|
|
/'\''; z>i; i++){ J(
|
|
!--G){ G=C; H=1
|
|
-H ; break;
|
|
} r->c=
|
|
! (q
|
|
->
|
|
c=
|
|
H)
|
|
; L=
|
|
l->_; J
|
|
(L) { L->o
|
|
->c=!1; L=L->_;
|
|
} h(p); Z(q->c){ h(
|
|
q); } Q{ h(r); } E=m->_;
|
|
J(E){ A=E->o; A->c=A->o->_->_
|
|
->_->_->o->c; E= E->_; } Y=k->_;
|
|
d=w; J(Y){ *d++=48+Y->o->c; Y=Y->_;
|
|
} *d=0; Z(!g(w,x)){ strcpy(x,w); pri\
|
|
ntf (e, i, w ) ; } } N 0 ; }
|