commit 5cfe13ab217d60cbfcdb6d7f5e60f5c290e5e3d1
parent bdffbbb6cea57ba66bce83ac7ffa09cb827ac4fe
Author: Jan Klemkow <j.klemkow@wemelug.de>
Date: Sat, 4 Apr 2020 22:45:58 +0200
fix compare bug for scroll events
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/scroll.c b/scroll.c
@@ -385,18 +385,19 @@ main(int argc, char *argv[])
die("poll:");
if (pfd[0].revents & POLLIN) {
- ssize_t n = read(STDIN_FILENO, input, sizeof input);
+ ssize_t n = read(STDIN_FILENO, input, sizeof(input)-1);
if (n <= 0 && errno != EINTR)
die("read:");
- if (!altscreen && strncmp(KB_SCROLL_UP, input, n) == 0)
+ input[n] = '\0';
+ if (!altscreen && strcmp(KB_SCROLL_UP, input) == 0)
scrollup(ws.ws_row);
- else if (!altscreen && strncmp(MS_SCROLL_UP, input, n) == 0)
+ else if (!altscreen && strcmp(MS_SCROLL_UP, input) == 0)
scrollup(1);
- else if (!altscreen && strncmp(KB_SCROLL_DOWN, input, n) == 0)
+ else if (!altscreen && strcmp(KB_SCROLL_DOWN, input) == 0)
scrolldown(buf, pos, ws.ws_row);
- else if (!altscreen && strncmp(MS_SCROLL_DOWN, input, n) == 0)
+ else if (!altscreen && strcmp(MS_SCROLL_DOWN, input) == 0)
scrolldown(buf, pos, 1);
else if (write(mfd, input, n) == -1)
die("write:");