/* ANSI Filter */ /* Datei: agrep.c */ #include #include #include static int state = 1; int rmansi (unsigned ch) { switch (state) { case 1: if (ch == '\x1b') { state = '['; return EOF; } else return ch; case '[': if (ch == '[' || ch=='='||ch== '?') state = 'A'; else state = 'N'; return EOF; case 'A': if (isdigit (ch)) state = 'A'; else if (ch == ';') state = 'A'; else state = 'N'; return EOF; case 'N': state = 1; break; default: fprintf (stderr,"\nZustand ungültig."); exit (2); } }