aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2020-04-09 16:01:45 +0100
committerThomas Adam <thomas@xteddy.org>2020-04-09 16:01:45 +0100
commit52e3d960e7ebe2006509d48c427ffd8f25a0cf52 (patch)
tree8f6deb3d44616e92ff05735b4c587dfe3c5d8235
parent916c3787d7464f66287f83814d563ff36ff3a96a (diff)
parent26f5dfbe46c75f8b907ee75daaadde9a310d8dfb (diff)
downloadrtmux-52e3d960e7ebe2006509d48c427ffd8f25a0cf52.tar.gz
rtmux-52e3d960e7ebe2006509d48c427ffd8f25a0cf52.tar.bz2
rtmux-52e3d960e7ebe2006509d48c427ffd8f25a0cf52.zip
Merge branch 'obsd-master'
-rw-r--r--client.c2
-rw-r--r--cmd-find.c22
-rw-r--r--cmd-list-keys.c4
-rw-r--r--cmd-new-session.c17
-rw-r--r--cmd-send-keys.c2
-rw-r--r--cmd-show-options.c4
-rw-r--r--cmd-switch-client.c2
-rw-r--r--format.c6
-rw-r--r--grid.c8
-rw-r--r--key-string.c4
-rw-r--r--regsub.c3
-rw-r--r--server-client.c7
-rw-r--r--tmux.h1
-rw-r--r--window-buffer.c3
-rw-r--r--window-copy.c8
-rw-r--r--window.c2
16 files changed, 45 insertions, 50 deletions
diff --git a/client.c b/client.c
index c608ec9d..32565184 100644
--- a/client.c
+++ b/client.c
@@ -646,7 +646,7 @@ client_read_open(void *data, size_t datalen)
struct msg_read_done reply;
struct client_file find, *cf;
const int flags = O_NONBLOCK|O_RDONLY;
- int error = 0;
+ int error;
if (datalen < sizeof *msg)
fatalx("bad MSG_READ_OPEN size");
diff --git a/cmd-find.c b/cmd-find.c
index 154842ab..aa36bc35 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -1230,29 +1230,31 @@ no_pane:
static struct client *
cmd_find_current_client(struct cmdq_item *item, int quiet)
{
- struct client *c;
+ struct client *c = NULL, *found;
struct session *s;
struct window_pane *wp;
struct cmd_find_state fs;
- if (item->client != NULL && item->client->session != NULL)
- return (item->client);
+ if (item != NULL)
+ c = item->client;
+ if (c != NULL && c->session != NULL)
+ return (c);
- c = NULL;
- if ((wp = cmd_find_inside_pane(item->client)) != NULL) {
+ found = NULL;
+ if (c != NULL && (wp = cmd_find_inside_pane(c)) != NULL) {
cmd_find_clear_state(&fs, CMD_FIND_QUIET);
fs.w = wp->window;
if (cmd_find_best_session_with_window(&fs) == 0)
- c = cmd_find_best_client(fs.s);
+ found = cmd_find_best_client(fs.s);
} else {
s = cmd_find_best_session(NULL, 0, CMD_FIND_QUIET);
if (s != NULL)
- c = cmd_find_best_client(s);
+ found = cmd_find_best_client(s);
}
- if (c == NULL && !quiet)
+ if (found == NULL && item != NULL && !quiet)
cmdq_error(item, "no current client");
- log_debug("%s: no target, return %p", __func__, c);
- return (c);
+ log_debug("%s: no target, return %p", __func__, found);
+ return (found);
}
/* Find the target client or report an error and return NULL. */
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index 7e340516..e1ec4d3c 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -269,7 +269,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
tmpsize *= 2;
tmp = xrealloc(tmp, tmpsize);
}
- tmpused = strlcat(tmp, cp, tmpsize);
+ strlcat(tmp, cp, tmpsize);
tmpused = strlcat(tmp, " ", tmpsize);
free(cp);
@@ -279,7 +279,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
tmpsize *= 2;
tmp = xrealloc(tmp, tmpsize);
}
- tmpused = strlcat(tmp, cp, tmpsize);
+ strlcat(tmp, cp, tmpsize);
tmpused = strlcat(tmp, " ", tmpsize);
free(cp);
diff --git a/cmd-new-session.c b/cmd-new-session.c
index a75fc972..725448fd 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -207,7 +207,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
goto fail;
}
}
- }
+ } else
+ dsx = 80;
if (args_has(args, 'y')) {
tmp = args_get(args, 'y');
if (strcmp(tmp, "-") == 0) {
@@ -222,7 +223,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
goto fail;
}
}
- }
+ } else
+ dsy = 24;
/* Find new session size. */
if (!detached && !is_control) {
@@ -233,13 +235,14 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
} else {
tmp = options_get_string(global_s_options, "default-size");
if (sscanf(tmp, "%ux%u", &sx, &sy) != 2) {
- sx = 80;
- sy = 24;
- }
- if (args_has(args, 'x'))
sx = dsx;
- if (args_has(args, 'y'))
sy = dsy;
+ } else {
+ if (args_has(args, 'x'))
+ sx = dsx;
+ if (args_has(args, 'y'))
+ sy = dsy;
+ }
}
if (sx == 0)
sx = 1;
diff --git a/cmd-send-keys.c b/cmd-send-keys.c
index 5770572a..15967b0c 100644
--- a/cmd-send-keys.c
+++ b/cmd-send-keys.c
@@ -152,7 +152,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR);
}
if (wme != NULL && (args_has(args, 'X') || args->argc == 0)) {
- if (wme == NULL || wme->mode->command == NULL) {
+ if (wme->mode->command == NULL) {
cmdq_error(item, "not in a mode");
return (CMD_RETURN_ERROR);
}
diff --git a/cmd-show-options.c b/cmd-show-options.c
index da481139..bd044412 100644
--- a/cmd-show-options.c
+++ b/cmd-show-options.c
@@ -211,11 +211,9 @@ cmd_show_options_all(struct cmd *self, struct cmdq_item *item, int scope,
if ((self->entry != &cmd_show_hooks_entry &&
!args_has(self->args, 'H') &&
- oe != NULL &&
(oe->flags & OPTIONS_TABLE_IS_HOOK)) ||
(self->entry == &cmd_show_hooks_entry &&
- (oe == NULL ||
- (~oe->flags & OPTIONS_TABLE_IS_HOOK))))
+ (~oe->flags & OPTIONS_TABLE_IS_HOOK)))
continue;
o = options_get_only(oo, oe->name);
diff --git a/cmd-switch-client.c b/cmd-switch-client.c
index 61677761..cf84c319 100644
--- a/cmd-switch-client.c
+++ b/cmd-switch-client.c
@@ -73,7 +73,6 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR);
s = item->target.s;
wl = item->target.wl;
- w = wl->window;
wp = item->target.wp;
if (args_has(args, 'r'))
@@ -115,6 +114,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
if (item->client == NULL)
return (CMD_RETURN_NORMAL);
if (wl != NULL && wp != NULL) {
+ w = wl->window;
if (window_push_zoom(w, args_has(self->args, 'Z')))
server_redraw_window(w);
window_redraw_active_switch(w, wp);
diff --git a/format.c b/format.c
index 10ea3201..16b3e26c 100644
--- a/format.c
+++ b/format.c
@@ -900,11 +900,12 @@ static void
format_cb_pane_at_top(struct format_tree *ft, struct format_entry *fe)
{
struct window_pane *wp = ft->wp;
- struct window *w = wp->window;
+ struct window *w;
int status, flag;
if (wp == NULL)
return;
+ w = wp->window;
status = options_get_number(w->options, "pane-border-status");
if (status == PANE_STATUS_TOP)
@@ -919,11 +920,12 @@ static void
format_cb_pane_at_bottom(struct format_tree *ft, struct format_entry *fe)
{
struct window_pane *wp = ft->wp;
- struct window *w = wp->window;
+ struct window *w;
int status, flag;
if (wp == NULL)
return;
+ w = wp->window;
status = options_get_number(w->options, "pane-border-status");
if (status == PANE_STATUS_BOTTOM)
diff --git a/grid.c b/grid.c
index 9678bf59..f33bc98d 100644
--- a/grid.c
+++ b/grid.c
@@ -1343,17 +1343,13 @@ grid_wrap_position(struct grid *gd, u_int px, u_int py, u_int *wx, u_int *wy)
void
grid_unwrap_position(struct grid *gd, u_int *px, u_int *py, u_int wx, u_int wy)
{
- u_int yy, ax = 0, ay = 0;
+ u_int yy, ay = 0;
for (yy = 0; yy < gd->hsize + gd->sy - 1; yy++) {
if (ay == wy)
break;
- if (gd->linedata[yy].flags & GRID_LINE_WRAPPED)
- ax += gd->linedata[yy].cellused;
- else {
- ax = 0;
+ if (~gd->linedata[yy].flags & GRID_LINE_WRAPPED)
ay++;
- }
}
/*
diff --git a/key-string.c b/key-string.c
index 76ee4fbe..2a0602b2 100644
--- a/key-string.c
+++ b/key-string.c
@@ -229,10 +229,8 @@ key_string_lookup_string(const char *string)
key -= 64;
else if (key == 32)
key = 0;
- else if (key == '?')
- key = 127;
else if (key == 63)
- key = KEYC_BSPACE;
+ key = 127;
else
return (KEYC_UNKNOWN);
modifiers &= ~KEYC_CTRL;
diff --git a/regsub.c b/regsub.c
index 22e236dc..4039b9be 100644
--- a/regsub.c
+++ b/regsub.c
@@ -24,8 +24,7 @@
#include "tmux.h"
static void
-regsub_copy(char **buf, size_t *len, const char *text, size_t start,
- size_t end)
+regsub_copy(char **buf, size_t *len, const char *text, size_t start, size_t end)
{
size_t add = end - start;
diff --git a/server-client.c b/server-client.c
index 355e4eca..76d20ddb 100644
--- a/server-client.c
+++ b/server-client.c
@@ -604,10 +604,9 @@ have_event:
wp = window_get_active_at(s->curw->window, px, py);
if (wp != NULL)
where = PANE;
+ else
+ return (KEYC_UNKNOWN);
}
-
- if (where == NOWHERE)
- return (KEYC_UNKNOWN);
if (where == PANE)
log_debug("mouse %u,%u on pane %%%u", x, y, wp->id);
else if (where == BORDER)
@@ -1541,7 +1540,7 @@ server_client_reset_state(struct client *c)
struct window_pane *wp = w->active, *loop;
struct screen *s;
struct options *oo = c->session->options;
- int mode, cursor = 0;
+ int mode, cursor;
u_int cx = 0, cy = 0, ox, oy, sx, sy;
if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED))
diff --git a/tmux.h b/tmux.h
index b3b7ace0..f0ea4a79 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2471,7 +2471,6 @@ void screen_select_cell(struct screen *, struct grid_cell *,
void screen_alternate_on(struct screen *, struct grid_cell *, int);
void screen_alternate_off(struct screen *, struct grid_cell *, int);
-
/* window.c */
extern struct windows windows;
extern struct window_pane_tree all_window_panes;
diff --git a/window-buffer.c b/window-buffer.c
index a1939b0f..80092fbd 100644
--- a/window-buffer.c
+++ b/window-buffer.c
@@ -347,9 +347,8 @@ window_buffer_do_paste(void *modedata, void *itemdata, struct client *c,
{
struct window_buffer_modedata *data = modedata;
struct window_buffer_itemdata *item = itemdata;
- struct paste_buffer *pb;
- if ((pb = paste_get_name(item->name)) != NULL)
+ if (paste_get_name(item->name) != NULL)
mode_tree_run_command(c, NULL, data->command, item->name);
}
diff --git a/window-copy.c b/window-copy.c
index 5a1a03ec..14f7a284 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1055,14 +1055,15 @@ window_copy_cmd_history_bottom(struct window_copy_cmd_state *cs)
{
struct window_mode_entry *wme = cs->wme;
struct window_copy_mode_data *data = wme->data;
+ struct screen *s = data->backing;
u_int oy;
- oy = screen_hsize(data->backing) + data->cy - data->oy;
+ oy = screen_hsize(s) + data->cy - data->oy;
if (data->lineflag == LINE_SEL_RIGHT_LEFT && oy == data->endsely)
window_copy_other_end(wme);
data->cy = screen_size_y(&data->screen) - 1;
- data->cx = window_copy_find_length(wme, data->cy);
+ data->cx = window_copy_find_length(wme, screen_hsize(s) + data->cy);
data->oy = 0;
if (data->searchmark != NULL && !data->timeout)
@@ -4151,7 +4152,6 @@ window_copy_cursor_previous_word_pos(struct window_mode_entry *wme,
data->oy >=
screen_hsize(data->backing) - 1))
goto out;
- py--;
py = screen_hsize(data->backing) + data->cy -
data->oy;
@@ -4360,7 +4360,7 @@ window_copy_start_drag(struct client *c, struct mouse_event *m)
data->selflag = SEL_CHAR;
switch (data->selflag) {
case SEL_WORD:
- if (data->ws) {
+ if (data->ws != NULL) {
window_copy_update_cursor(wme, x, y);
window_copy_cursor_previous_word_pos(wme,
data->ws, 0, &x, &y);
diff --git a/window.c b/window.c
index 4aca6d32..092e7865 100644
--- a/window.c
+++ b/window.c
@@ -1223,7 +1223,7 @@ window_pane_search(struct window_pane *wp, const char *term, int regex,
}
log_debug("%s: %s", __func__, line);
if (!regex)
- found = (fnmatch(new, line, 0) == 0);
+ found = (fnmatch(new, line, flags) == 0);
else
found = (regexec(&r, line, 0, NULL, 0) == 0);
free(line);