summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-06-24 08:20:03 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-06-24 08:20:03 +0000
commit9f18fb39bd48df66a878b9f7092f8707cce051aa (patch)
treec057b635b0af5d71d7f6187ae79bbd2089d71a7c /usr.bin
parent2c0e15102f15cc7f6ce7e29572cdc7a5c1685a98 (diff)
Trim trailing spaces when matching.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/window.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index fe210533d8c..9c121374483 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.235 2019/06/20 13:40:22 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.236 2019/06/24 08:20:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
@@ -1222,6 +1223,7 @@ window_pane_search(struct window_pane *wp, const char *term, int regex,
char *new = NULL, *line;
u_int i;
int flags = 0, found;
+ size_t n;
if (!regex) {
if (ignore)
@@ -1236,6 +1238,12 @@ window_pane_search(struct window_pane *wp, const char *term, int regex,
for (i = 0; i < screen_size_y(s); i++) {
line = grid_view_string_cells(s->grid, 0, i, screen_size_x(s));
+ for (n = strlen(line); n > 0; n--) {
+ if (!isspace((u_char)line[n - 1]))
+ break;
+ line[n - 1] = '\0';
+ }
+ log_debug("%s: %s", __func__, line);
if (!regex)
found = (fnmatch(new, line, 0) == 0);
else