summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-05-07 10:25:16 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-05-07 10:25:16 +0000
commit6003901da47a976f0919eed374ca8aebf26f604b (patch)
treee34ad57e901e513988b474365e6fc2947a436776 /usr.bin/tmux
parent5d4bc8385297649608da7409dc5fd55a2e737a69 (diff)
Do not use evbuffer_add_buffer because it is destructive and doesn't
work in newer libevent.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/control-notify.c9
-rw-r--r--usr.bin/tmux/input.c27
-rw-r--r--usr.bin/tmux/notify.c6
-rw-r--r--usr.bin/tmux/tmux.h7
-rw-r--r--usr.bin/tmux/window.c10
5 files changed, 29 insertions, 30 deletions
diff --git a/usr.bin/tmux/control-notify.c b/usr.bin/tmux/control-notify.c
index 5927a5e9322..650e42e9528 100644
--- a/usr.bin/tmux/control-notify.c
+++ b/usr.bin/tmux/control-notify.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control-notify.c,v 1.22 2018/11/19 13:35:40 nicm Exp $ */
+/* $OpenBSD: control-notify.c,v 1.23 2019/05/07 10:25:15 nicm Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -28,19 +28,14 @@
void
control_notify_input(struct client *c, struct window_pane *wp,
- struct evbuffer *input)
+ const u_char *buf, size_t len)
{
- u_char *buf;
- size_t len;
struct evbuffer *message;
u_int i;
if (c->session == NULL)
return;
- buf = EVBUFFER_DATA(input);
- len = EVBUFFER_LENGTH(input);
-
/*
* Only write input if the window pane is linked to a window belonging
* to the client's session.
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c
index 27123b74a49..b831734b01e 100644
--- a/usr.bin/tmux/input.c
+++ b/usr.bin/tmux/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.151 2019/05/03 20:44:24 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.152 2019/05/07 10:25:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -874,18 +874,27 @@ input_set_state(struct window_pane *wp, const struct input_transition *itr)
void
input_parse(struct window_pane *wp)
{
+ struct evbuffer *evb = wp->event->input;
+
+ input_parse_buffer(wp, EVBUFFER_DATA(evb), EVBUFFER_LENGTH(evb));
+ evbuffer_drain(evb, EVBUFFER_LENGTH(evb));
+}
+
+/* Parse given input. */
+void
+input_parse_buffer(struct window_pane *wp, u_char *buf, size_t len)
+{
struct input_ctx *ictx = wp->ictx;
struct screen_write_ctx *sctx = &ictx->ctx;
const struct input_transition *itr;
- struct evbuffer *evb = wp->event->input;
- u_char *buf;
- size_t len, off;
+ size_t off = 0;
- if (EVBUFFER_LENGTH(evb) == 0)
+ if (len == 0)
return;
window_update_activity(wp->window);
wp->flags |= PANE_CHANGED;
+ notify_input(wp, buf, len);
/*
* Open the screen. Use NULL wp if there is a mode set as don't want to
@@ -897,12 +906,6 @@ input_parse(struct window_pane *wp)
screen_write_start(sctx, NULL, &wp->base);
ictx->wp = wp;
- buf = EVBUFFER_DATA(evb);
- len = EVBUFFER_LENGTH(evb);
- off = 0;
-
- notify_input(wp, evb);
-
log_debug("%s: %%%u %s, %zu bytes: %.*s", __func__, wp->id,
ictx->state->name, len, (int)len, buf);
@@ -950,8 +953,6 @@ input_parse(struct window_pane *wp)
/* Close the screen. */
screen_write_stop(sctx);
-
- evbuffer_drain(evb, len);
}
/* Split the parameter list (if any). */
diff --git a/usr.bin/tmux/notify.c b/usr.bin/tmux/notify.c
index ec246516f59..042163c3f5d 100644
--- a/usr.bin/tmux/notify.c
+++ b/usr.bin/tmux/notify.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: notify.c,v 1.27 2019/04/26 11:38:51 nicm Exp $ */
+/* $OpenBSD: notify.c,v 1.28 2019/05/07 10:25:15 nicm Exp $ */
/*
* Copyright (c) 2012 George Nachman <tmux@georgester.com>
@@ -199,13 +199,13 @@ notify_hook(struct cmdq_item *item, const char *name)
}
void
-notify_input(struct window_pane *wp, struct evbuffer *input)
+notify_input(struct window_pane *wp, const u_char *buf, size_t len)
{
struct client *c;
TAILQ_FOREACH(c, &clients, entry) {
if (c->flags & CLIENT_CONTROL)
- control_notify_input(c, wp, input);
+ control_notify_input(c, wp, buf, len);
}
}
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 69815d6673a..c29507c191e 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.887 2019/05/03 20:44:24 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.888 2019/05/07 10:25:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1699,7 +1699,7 @@ char *format_trim_right(const char *, u_int);
/* notify.c */
void notify_hook(struct cmdq_item *, const char *);
-void notify_input(struct window_pane *, struct evbuffer *);
+void notify_input(struct window_pane *, const u_char *, size_t);
void notify_client(const char *, struct client *);
void notify_session(const char *, struct session *);
void notify_winlink(const char *, struct winlink *);
@@ -2087,6 +2087,7 @@ void input_free(struct window_pane *);
void input_reset(struct window_pane *, int);
struct evbuffer *input_pending(struct window_pane *);
void input_parse(struct window_pane *);
+void input_parse_buffer(struct window_pane *, u_char *, size_t);
/* input-key.c */
void input_key(struct window_pane *, key_code, struct mouse_event *);
@@ -2428,7 +2429,7 @@ void control_write_buffer(struct client *, struct evbuffer *);
/* control-notify.c */
void control_notify_input(struct client *, struct window_pane *,
- struct evbuffer *);
+ const u_char *, size_t);
void control_notify_pane_mode_changed(int);
void control_notify_window_layout_changed(struct window *);
void control_notify_window_pane_changed(struct window *);
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 00559a93039..f388e74f3d0 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.228 2019/05/03 20:44:24 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.229 2019/05/07 10:25:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1477,6 +1477,9 @@ window_pane_input_callback(struct client *c, int closed, void *data)
{
struct window_pane_input_data *cdata = data;
struct window_pane *wp;
+ struct evbuffer *evb = c->stdin_data;
+ u_char *buf = EVBUFFER_DATA(evb);
+ size_t len = EVBUFFER_LENGTH(evb);
wp = window_pane_find_by_id(cdata->wp);
if (wp == NULL || closed || c->flags & CLIENT_DEAD) {
@@ -1489,9 +1492,8 @@ window_pane_input_callback(struct client *c, int closed, void *data)
return;
}
- if (evbuffer_add_buffer(wp->event->input, c->stdin_data) != 0)
- evbuffer_drain(c->stdin_data, EVBUFFER_LENGTH(c->stdin_data));
- input_parse(wp);
+ input_parse_buffer(wp, buf, len);
+ evbuffer_drain(evb, len);
}
int