]> rtime.felk.cvut.cz Git - sojka/sterm.git/commitdiff
Fix escape sequence handling
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 2 Dec 2014 14:35:44 +0000 (15:35 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 2 Dec 2014 14:35:44 +0000 (15:35 +0100)
sterm.c

diff --git a/sterm.c b/sterm.c
index 2402c95dbd3e1c5ae19b0d7d184cb9d9fe62a075..e9d914abbb4fc4ae71ff56cce1cc2c432d8412fa 100644 (file)
--- a/sterm.c
+++ b/sterm.c
@@ -101,14 +101,16 @@ void exit_on_escapeseq(const char *buf, int len)
        static const char escseq[] = "\r~.";
        static const char *state = escseq+1;
        int i;
-
        for (i = 0; i < len; i++) {
                if (buf[i] == *state) {
                        state++;
                        if (*state == 0)
                                exit(0);
-               } else
+               } else {
                        state = escseq;
+                       if (buf[i] == *state)
+                               state++;
+               }
        }
 }