improve handleinput: match escape (0x1b) and control chars (includes 127==del) - sob - simple output bar
(HTM) git clone git://git.codemadness.org/sob
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit b68741f2fe59eb350edf3dca744ad26800013893
(DIR) parent 5cfc09e6af0a5fec859dc9938210646ea97da167
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 12 Oct 2014 22:07:39 +0000
improve handleinput: match escape (0x1b) and control chars (includes 127==del)
Diffstat:
M sob.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/sob.c b/sob.c
@@ -777,12 +777,12 @@ handleinput(const unsigned char *input, size_t len)
line.dirtylen = line.collen;
while(p < len && input[p] != '\0') {
- if(input[p] <= 0x1b) {
+ if(input[p] == 0x1b || iscntrl(input[p])) {
ismatch = 0;
for(i = 0; i < LEN(keybinds); i++) {
keylen = strlen((char*)keybinds[i].key);
- if(strncmp((const char*)&input[p],
- (const char *)keybinds[i].key, keylen) == 0) {
+ if(len - p >= keylen &&
+ memcmp(&input[p], keybinds[i].key, keylen) == 0) {
keybinds[i].func();
p += keylen;
ismatch = 1;