#include #define BUFFER_SIZE 0x10000 #define BUFFER_MASK (BUFFER_SIZE - 1) /* Input byte. */ static int c; /* Ring buffer of input bytes. */ static char input[BUFFER_SIZE]; static int i_read, i_write; /* Define a single header dictionary entry. */ #define D(d) ,#d /* Header text: - Uppercase letters causes a dictionary entry to be expanded recursively. - Tilde (~) causes the next letter to be copied as is. - Everything else is copied as is. */ static char *header_data[] = { /*M*/ "Pzoltraak", /*N*/ "," /*O*/ D( ZifWUUQjmp_bufPj;XmNINi=1NlNk[999]={1<<30}N*o=k;Xmain(XdNY**a){switch(S(j)){default:i--;I=14;m=0;VP_P__LI~NE__VPpPT(I=_+1)VPqP(i=3N--R(jN*o--)):VMPcaseP_:i%2?m=0*--iNp:(_-4)%9?T(m|=1<<(_-I)):_-I-17?(putY(m^32)Nm=0N--*o)?p:q(l=m%256+3Nm=m/512+3Ni)?(*o-=l)>0?m=i=0Np:q((o[2]=*o 32 ) c >= 'M' && c <= 'Z' ? Expand(header_data[c - 'M']) : (void)putchar(c != '~' ? c : *++s); } } /* Output a set of lines. */ static void OutputInstruction(int i) { for(; i != 0; i /= 2) puts((i % 2 ? 1 : 9) + *header_data); } int main(int argc, char **argv) { Expand(header_data[2]); for(;;) { /* Fill ring buffer. */ while( ((i_write + 1) & BUFFER_MASK) != i_read ) { if( (c = getchar()) == EOF ) break; input[i_write++] = c; i_write &= BUFFER_MASK; } if( i_read == i_write ) break; /* Consume ring buffer. */ while( i_read != i_write ) { OutputInstruction((input[i_read++] & 0xff) ^ 0x120); i_read &= BUFFER_MASK; } } return 0; }