소스 검색

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.
Jan Klemkow 5 년 전
부모
커밋
baaf9c0bb7
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      scroll.c

+ 2 - 1
scroll.c

@@ -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)