diff --git a/format.c b/format.c index 80bcc467..aecb9280 100644 --- a/format.c +++ b/format.c @@ -134,7 +134,7 @@ struct format_tree * format_create(void) { struct format_tree *ft; - char host[MAXHOSTNAMELEN], *ptr; + char host[HOST_NAME_MAX+1], *ptr; ft = xcalloc(1, sizeof *ft); RB_INIT(&ft->tree); diff --git a/osdep-openbsd.c b/osdep-openbsd.c index 7fe96d58..414228b7 100644 --- a/osdep-openbsd.c +++ b/osdep-openbsd.c @@ -16,7 +16,8 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include /* MAXCOMLEN */ +#include #include #include #include diff --git a/screen.c b/screen.c index 5b543eef..c1df95ad 100644 --- a/screen.c +++ b/screen.c @@ -32,11 +32,11 @@ void screen_resize_y(struct screen *, u_int); void screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit) { - char host[HOST_NAME_MAX]; + char host[HOST_NAME_MAX+1]; s->grid = grid_create(sx, sy, hlimit); - if (gethostname(host, HOST_NAME_MAX) == 0) + if (gethostname(host, sizeof(host)) == 0) s->title = xstrdup(host); else s->title = xstrdup(""); diff --git a/window-choose.c b/window-choose.c index 56016394..0d724746 100644 --- a/window-choose.c +++ b/window-choose.c @@ -330,14 +330,12 @@ window_choose_collapse(struct window_pane *wp, struct session *s) struct window_choose_mode_data *data = wp->modedata; struct window_choose_mode_item *item, *chosen; struct window_choose_data *wcd; - u_int i, pos; + u_int i; ARRAY_DECL(, struct window_choose_mode_item) list_copy; ARRAY_INIT(&list_copy); - pos = data->selected; - - chosen = &ARRAY_ITEM(&data->list, pos); + chosen = &ARRAY_ITEM(&data->list, data->selected); chosen->state &= ~TREE_EXPANDED; /* @@ -353,9 +351,8 @@ window_choose_collapse(struct window_pane *wp, struct session *s) /* We only show the session when collapsed. */ if (wcd->type & TREE_SESSION) { item->state &= ~TREE_EXPANDED; + ARRAY_ADD(&list_copy, *item); - ARRAY_ADD(&list_copy, - ARRAY_ITEM(&data->list, i)); /* * Update the selection to this session item so * we don't end up highlighting a non-existent diff --git a/window-copy.c b/window-copy.c index 8aae09be..6447a2d5 100644 --- a/window-copy.c +++ b/window-copy.c @@ -390,13 +390,16 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key) if (data->inputtype == WINDOW_COPY_JUMPFORWARD) { for (; np != 0; np--) window_copy_cursor_jump(wp); - } else if (data->inputtype == WINDOW_COPY_JUMPBACK) { + } + if (data->inputtype == WINDOW_COPY_JUMPBACK) { for (; np != 0; np--) window_copy_cursor_jump_back(wp); - } else if (data->inputtype == WINDOW_COPY_JUMPTOFORWARD) { + } + if (data->inputtype == WINDOW_COPY_JUMPTOFORWARD) { for (; np != 0; np--) window_copy_cursor_jump_to(wp); - } else if (data->inputtype == WINDOW_COPY_JUMPTOBACK) { + } + if (data->inputtype == WINDOW_COPY_JUMPTOBACK) { for (; np != 0; np--) window_copy_cursor_jump_to_back(wp); } @@ -1771,7 +1774,7 @@ window_copy_other_end(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; struct screen *s = &data->screen; - u_int selx, sely, cx, cy, yy; + u_int selx, sely, cx, cy, yy, hsize; if (!s->sel.flag && s->sel.lineflag == LINE_SEL_NONE) return; @@ -1791,13 +1794,13 @@ window_copy_other_end(struct window_pane *wp) data->sely = yy; data->cx = selx; - if (sely < screen_hsize(data->backing) - data->oy) { - data->oy = screen_hsize(data->backing) - sely; + hsize = screen_hsize(data->backing); + if (sely < hsize - data->oy) { + data->oy = hsize - sely; data->cy = 0; - } else if (sely > screen_hsize(data->backing) - data->oy + screen_size_y(s)) { - data->oy = screen_hsize(data->backing) - sely + screen_size_y(s) - 1; + } else if (sely > hsize - data->oy + screen_size_y(s)) { + data->oy = hsize - sely + screen_size_y(s) - 1; data->cy = screen_size_y(s) - 1; - } else data->cy = cy + sely - yy;