[hackers] [scroll] fix mismatch of several esc seq. in one input || Jan Klemkow

From: <git_AT_suckless.org>
Date: Fri, 24 Apr 2020 22:26:11 +0200 (CEST)

commit baaf9c0bb7db5e59ffb4f08e2f4383b29dd5a52e
Author: Jan Klemkow <j.klemkow_AT_wemelug.de>
AuthorDate: Fri Apr 24 22:22:08 2020 +0200
Commit: Jan Klemkow <j.klemkow_AT_wemelug.de>
CommitDate: Fri Apr 24 22:26:06 2020 +0200

    fix mismatch of several esc seq. in one input
    
    scroll does not detect two esc seq. with scroll up/down
    command in the input buffer and handle it as regular input.
    By using strncmp(3) with strlen(3) of the matching sequence,
    we detect the fist command and irgnore the rest of the input
    buffer.

diff --git a/scroll.c b/scroll.c
index ef9d5cd..e147bbd 100644
--- a/scroll.c
+++ b/scroll.c
_AT_@ -493,7 +493,8 @@ main(int argc, char *argv[])
                                 goto noevent;
 
                         for (size_t i = 0; i < LENGTH(rules); i++) {
- if (strcmp(rules[i].seq, input) == 0) {
+ if (strncmp(rules[i].seq, input,
+ strlen(rules[i].seq)) == 0) {
                                         if (rules[i].event == SCROLL_UP)
                                                 scrollup(rules[i].lines);
                                         if (rules[i].event == SCROLL_DOWN)
Received on Fri Apr 24 2020 - 22:26:11 CEST

This archive was generated by hypermail 2.3.0 : Fri Apr 24 2020 - 22:36:36 CEST