improve handleinput: dont handle rest of input if escape code is unhandled - sob - simple output bar
 (HTM) git clone git://git.codemadness.org/sob
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 0d01477d561d460a40b68ec469b23d9edb2e88a0
 (DIR) parent 39be364f31f527b59f6280d37eaa88e70fe79712
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Fri, 10 Oct 2014 20:59:17 +0000
       
       improve handleinput: dont handle rest of input if escape code is
       unhandled
       
       Diffstat:
         M sob.c                               |      10 +++++++---
       
       1 file changed, 7 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/sob.c b/sob.c
       @@ -754,7 +754,7 @@ handleinput(const unsigned char *input, size_t len)
                int ismatch = 0;
                char buf[BUFSIZ];
        
       -        while(p < len) {
       +        while(p < len && input[p] != '\0') {
                        if(input[p] <= 0x1b) {
                                ismatch = 0;
                                for(i = 0; i < LEN(keybinds); i++) {
       @@ -766,18 +766,22 @@ handleinput(const unsigned char *input, size_t len)
                                                break;
                                        }
                                }
       -                        if(!ismatch)
       +                        if(!ismatch) {
       +                                if(input[p] == 0x1b)
       +                                        return;
                                        p++;
       +                        }
                        } else {
                                for(i = p; input[i] && input[i] > 0x1b; i++)
                                        ;
       -                        buf[0] = '\0';
                                if(i - p < sizeof(buf)) {
                                        memcpy(buf, &input[p], i - p);
                                        buf[i - p] = '\0';
                                        p = i;
                                        line_inserttext((char*)buf);
                                        line_draw();
       +                        } else {
       +                                p++;
                                }
                        }
                }