The branch, master has been updated via e44bdcce4c661b52d07f30962aafa800d9ca5e28 (commit) via 2e8f6805eb911e3de82fc43e3c90c8d425df04a8 (commit) via a77355b6bf9a0beb2e9d0a8b9613266984bb598d (commit) via a27ba6e38006c12c48de88600b8cff9f6aabfed7 (commit) via 77efcf8bdd14cd19dc445cf6e44bba7af414939c (commit) via 6610e89689de1ba8afe492ad20b541271d39732d (commit) via d306bbe11e9701235a468e463699a832b89d6f4d (commit) via c011446e781eae4fd1116dacc63a3e26c2f47788 (commit) via 2f19df09b1850d80e60f2d37f0b7f0db22eae6f7 (commit) via 045d0c3b9f616fe76b68d4551a6d66f410e760e8 (commit) via a54b0055f66bc2d27bd57fc3f818dc185118470f (commit) via 304f86cdbb5bf87f7a266e84c0f4fbd7bf25bb5e (commit) from b6aef2490f086f3404f439308bb1746ec5134e9a (commit)
- Log ----------------------------------------------------------------- commit e44bdcce4c661b52d07f30962aafa800d9ca5e28 Merge: 2e8f680 b6aef24 Author: Thomas Adam <tho...@xteddy.org> Commit: Thomas Adam <tho...@xteddy.org> Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code osdep-sunos.c | 11 ++++++++++- server-client.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) commit 2e8f6805eb911e3de82fc43e3c90c8d425df04a8 Author: Thomas Adam <tho...@xteddy.org> Commit: Thomas Adam <tho...@xteddy.org> OSdep: Update for xrealloc() change This updates the code for xrealloc() which now only takes two parameters. --- osdep-cygwin.c | 2 +- osdep-linux.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osdep-cygwin.c b/osdep-cygwin.c index 01d2d0c..f28df37 100644 --- a/osdep-cygwin.c +++ b/osdep-cygwin.c @@ -50,7 +50,7 @@ osdep_get_name(int fd, unused char *tty) while ((ch = fgetc(f)) != EOF) { if (ch == '\0') break; - buf = xrealloc(buf, 1, len + 2); + buf = xrealloc(buf, len + 2); buf[len++] = ch; } if (buf != NULL) diff --git a/osdep-linux.c b/osdep-linux.c index 46aea68..706a273 100644 --- a/osdep-linux.c +++ b/osdep-linux.c @@ -50,7 +50,7 @@ osdep_get_name(int fd, unused char *tty) while ((ch = fgetc(f)) != EOF) { if (ch == '\0') break; - buf = xrealloc(buf, 1, len + 2); + buf = xrealloc(buf, len + 2); buf[len++] = ch; } if (buf != NULL) commit a77355b6bf9a0beb2e9d0a8b9613266984bb598d Merge: 2874a43 a27ba6e Author: Thomas Adam <tho...@xteddy.org> Commit: Thomas Adam <tho...@xteddy.org> Merge branch 'obsd-master' array.h | 4 +- client.c | 12 ++---- cmd-capture-pane.c | 2 +- cmd-save-buffer.c | 2 +- cmd-set-buffer.c | 2 +- cmd-string.c | 19 +++++----- cmd.c | 99 +++++++++++++++++++++++++++++---------------------- format.c | 8 ++-- grid.c | 15 +++++--- input.c | 4 +- paste.c | 2 +- screen-write.c | 2 + screen.c | 4 +- server-client.c | 1 + status.c | 13 +++++-- tmux.1 | 9 +++-- tmux.h | 3 +- tty-acs.c | 2 +- utf8.c | 8 ++-- window-choose.c | 2 +- window-copy.c | 18 +++++++--- xmalloc.c | 17 ++++++++- 22 files changed, 146 insertions(+), 102 deletions(-) commit a27ba6e38006c12c48de88600b8cff9f6aabfed7 Author: nicm <nicm> Commit: nicm <nicm> Add xreallocarray and remove nmemb argument from xrealloc. --- array.h | 4 ++-- cmd-capture-pane.c | 2 +- cmd-save-buffer.c | 2 +- cmd-set-buffer.c | 2 +- cmd-string.c | 19 ++++++++++--------- cmd.c | 6 +++--- format.c | 8 ++++---- grid.c | 14 ++++++++------ input.c | 4 ++-- paste.c | 2 +- screen.c | 4 ++-- status.c | 6 +++--- tmux.h | 3 ++- utf8.c | 8 ++++---- window-choose.c | 2 +- window-copy.c | 10 +++++----- xmalloc.c | 17 +++++++++++++++-- 17 files changed, 65 insertions(+), 48 deletions(-) diff --git a/array.h b/array.h index c811bf6..671bea4 100644 --- a/array.h +++ b/array.h @@ -39,10 +39,10 @@ fatalx("size too big"); \ if ((a)->space == 0) { \ (a)->space = ARRAY_INITIALSPACE(a); \ - (a)->list = xrealloc((a)->list, 1, (a)->space); \ + (a)->list = xrealloc((a)->list, (a)->space); \ } \ while ((a)->space <= ((a)->num + (n)) * ARRAY_ITEMSIZE(a)) { \ - (a)->list = xrealloc((a)->list, 2, (a)->space); \ + (a)->list = xreallocarray((a)->list, 2, (a)->space); \ (a)->space *= 2; \ } \ } while (0) diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index e3c551a..50bddc7 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -48,7 +48,7 @@ const struct cmd_entry cmd_capture_pane_entry = { char * cmd_capture_pane_append(char *buf, size_t *len, char *line, size_t linelen) { - buf = xrealloc(buf, 1, *len + linelen + 1); + buf = xrealloc(buf, *len + linelen + 1); memcpy(buf + *len, line, linelen); *len += linelen; return (buf); diff --git a/cmd-save-buffer.c b/cmd-save-buffer.c index ea23845..db80e48 100644 --- a/cmd-save-buffer.c +++ b/cmd-save-buffer.c @@ -147,7 +147,7 @@ do_print: size = pb->size - used; msglen = size * 4 + 1; - msg = xrealloc(msg, 1, msglen); + msg = xrealloc(msg, msglen); strvisx(msg, start, size, VIS_OCTAL|VIS_TAB); cmdq_print(cmdq, "%s", msg); diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c index 5a82b4d..88bd0c1 100644 --- a/cmd-set-buffer.c +++ b/cmd-set-buffer.c @@ -104,7 +104,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq) memcpy(pdata, pb->data, psize); } - pdata = xrealloc(pdata, 1, psize + newsize); + pdata = xrealloc(pdata, psize + newsize); memcpy(pdata + psize, args->argv[0], newsize); psize += newsize; diff --git a/cmd-string.c b/cmd-string.c index e19b885..db1723c 100644 --- a/cmd-string.c +++ b/cmd-string.c @@ -107,10 +107,11 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file, case ' ': case '\t': if (buf != NULL) { - buf = xrealloc(buf, 1, len + 1); + buf = xrealloc(buf, len + 1); buf[len] = '\0'; - argv = xrealloc(argv, argc + 1, sizeof *argv); + argv = xreallocarray(argv, argc + 1, + sizeof *argv); argv[argc++] = buf; buf = NULL; @@ -151,7 +152,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, const char *file, if (len >= SIZE_MAX - 2) goto error; - buf = xrealloc(buf, 1, len + 1); + buf = xrealloc(buf, len + 1); buf[len++] = ch; break; } @@ -179,7 +180,7 @@ cmd_string_copy(char **dst, char *src, size_t *len) srclen = strlen(src); - *dst = xrealloc(*dst, 1, *len + srclen + 1); + *dst = xrealloc(*dst, *len + srclen + 1); strlcpy(*dst + *len, src, srclen + 1); *len += srclen; @@ -231,11 +232,11 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc) if (len >= SIZE_MAX - 2) goto error; - buf = xrealloc(buf, 1, len + 1); + buf = xrealloc(buf, len + 1); buf[len++] = ch; } - buf = xrealloc(buf, 1, len + 1); + buf = xrealloc(buf, len + 1); buf[len] = '\0'; return (buf); @@ -278,7 +279,7 @@ cmd_string_variable(const char *s, size_t *p) return (t); } - buf = xrealloc(buf, 1, len + 1); + buf = xrealloc(buf, len + 1); buf[len++] = ch; for (;;) { @@ -288,7 +289,7 @@ cmd_string_variable(const char *s, size_t *p) else { if (len >= SIZE_MAX - 3) goto error; - buf = xrealloc(buf, 1, len + 1); + buf = xrealloc(buf, len + 1); buf[len++] = ch; } } @@ -299,7 +300,7 @@ cmd_string_variable(const char *s, size_t *p) if (ch != EOF && fch != '{') cmd_string_ungetc(p); /* ch */ - buf = xrealloc(buf, 1, len + 1); + buf = xrealloc(buf, len + 1); buf[len] = '\0'; envent = environ_find(&global_environ, buf); diff --git a/cmd.c b/cmd.c index 8241032..66ac58b 100644 --- a/cmd.c +++ b/cmd.c @@ -222,7 +222,7 @@ cmd_stringify_argv(int argc, char **argv) for (i = 0; i < argc; i++) { len += strlen(argv[i]) + 1; - buf = xrealloc(buf, 1, len); + buf = xrealloc(buf, len); if (i == 0) *buf = '\0'; @@ -1302,11 +1302,11 @@ cmd_template_replace(const char *template, const char *s, int idx) ptr++; len += strlen(s); - buf = xrealloc(buf, 1, len + 1); + buf = xrealloc(buf, len + 1); strlcat(buf, s, len + 1); continue; } - buf = xrealloc(buf, 1, len + 2); + buf = xrealloc(buf, len + 2); buf[len++] = ch; buf[len] = '\0'; } diff --git a/format.c b/format.c index ed3c203..b5e5149 100644 --- a/format.c +++ b/format.c @@ -267,7 +267,7 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, /* Expand the buffer and copy in the value. */ while (*len - *off < valuelen + 1) { - *buf = xrealloc(*buf, 2, *len); + *buf = xreallocarray(*buf, 2, *len); *len *= 2; } memcpy(*buf + *off, value, valuelen); @@ -298,7 +298,7 @@ format_expand(struct format_tree *ft, const char *fmt) while (*fmt != '\0') { if (*fmt != '#') { while (len - off < 2) { - buf = xrealloc(buf, 2, len); + buf = xreallocarray(buf, 2, len); len *= 2; } buf[off++] = *fmt++; @@ -326,7 +326,7 @@ format_expand(struct format_tree *ft, const char *fmt) continue; case '#': while (len - off < 2) { - buf = xrealloc(buf, 2, len); + buf = xreallocarray(buf, 2, len); len *= 2; } buf[off++] = '#'; @@ -339,7 +339,7 @@ format_expand(struct format_tree *ft, const char *fmt) s = format_lower[ch - 'a']; if (s == NULL) { while (len - off < 3) { - buf = xrealloc(buf, 2, len); + buf = xreallocarray(buf, 2, len); len *= 2; } buf[off++] = '#'; diff --git a/grid.c b/grid.c index b2351b2..ef7c374 100644 --- a/grid.c +++ b/grid.c @@ -172,7 +172,8 @@ grid_scroll_history(struct grid *gd) u_int yy; yy = gd->hsize + gd->sy; - gd->linedata = xrealloc(gd->linedata, yy + 1, sizeof *gd->linedata); + gd->linedata = xreallocarray(gd->linedata, yy + 1, + sizeof *gd->linedata); memset(&gd->linedata[yy], 0, sizeof gd->linedata[yy]); gd->hsize++; @@ -187,7 +188,8 @@ grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower) /* Create a space for a new line. */ yy = gd->hsize + gd->sy; - gd->linedata = xrealloc(gd->linedata, yy + 1, sizeof *gd->linedata); + gd->linedata = xreallocarray(gd->linedata, yy + 1, + sizeof *gd->linedata); /* Move the entire screen down to free a space for this line. */ gl_history = &gd->linedata[gd->hsize]; @@ -221,7 +223,7 @@ grid_expand_line(struct grid *gd, u_int py, u_int sx) if (sx <= gl->cellsize) return; - gl->celldata = xrealloc(gl->celldata, sx, sizeof *gl->celldata); + gl->celldata = xreallocarray(gl->celldata, sx, sizeof *gl->celldata); for (xx = gl->cellsize; xx < sx; xx++) grid_put_cell(gd, xx, py, &grid_default_cell); gl->cellsize = sx; @@ -610,7 +612,7 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx, } while (len < off + size + codelen + 1) { - buf = xrealloc(buf, 2, len); + buf = xreallocarray(buf, 2, len); len *= 2; } @@ -685,7 +687,7 @@ grid_reflow_join(struct grid *dst, u_int *py, struct grid_line *src_gl, nx = ox + to_copy; /* Resize the destination line. */ - dst_gl->celldata = xrealloc(dst_gl->celldata, nx, + dst_gl->celldata = xreallocarray(dst_gl->celldata, nx, sizeof *dst_gl->celldata); dst_gl->cellsize = nx; @@ -724,7 +726,7 @@ grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl, to_copy = src_gl->cellsize; /* Expand destination line. */ - dst_gl->celldata = xrealloc(NULL, to_copy, + dst_gl->celldata = xreallocarray(NULL, to_copy, sizeof *dst_gl->celldata); dst_gl->cellsize = to_copy; dst_gl->flags |= GRID_LINE_WRAPPED; diff --git a/input.c b/input.c index ac1db67..fcc9118 100644 --- a/input.c +++ b/input.c @@ -909,7 +909,7 @@ input_ground(struct input_ctx *ictx) if (ictx->input_space > INPUT_BUF_START) { ictx->input_space = INPUT_BUF_START; - ictx->input_buf = xrealloc(ictx->input_buf, 1, INPUT_BUF_START); + ictx->input_buf = xrealloc(ictx->input_buf, INPUT_BUF_START); } } @@ -974,7 +974,7 @@ input_input(struct input_ctx *ictx) ictx->flags |= INPUT_DISCARD; return (0); } - ictx->input_buf = xrealloc(ictx->input_buf, 1, available); + ictx->input_buf = xrealloc(ictx->input_buf, available); ictx->input_space = available; } ictx->input_buf[ictx->input_len++] = ictx->ch; diff --git a/paste.c b/paste.c index 603adda..0332e60 100644 --- a/paste.c +++ b/paste.c @@ -279,7 +279,7 @@ paste_make_sample(struct paste_buffer *pb, int utf8flag) len = pb->size; if (len > width) len = width; - buf = xrealloc(NULL, len, 4 + 4); + buf = xreallocarray(NULL, len, 4 + 4); if (utf8flag) used = utf8_strvis(buf, pb->data, len, flags); diff --git a/screen.c b/screen.c index 703f3e1..e555022 100644 --- a/screen.c +++ b/screen.c @@ -215,8 +215,8 @@ screen_resize_y(struct screen *s, u_int sy) } /* Resize line arrays. */ - gd->linedata = xrealloc( - gd->linedata, gd->hsize + sy, sizeof *gd->linedata); + gd->linedata = xreallocarray(gd->linedata, gd->hsize + sy, + sizeof *gd->linedata); /* Size increasing. */ if (sy > oldy) { diff --git a/status.c b/status.c index 96110c7..70e0551 100644 --- a/status.c +++ b/status.c @@ -992,7 +992,7 @@ status_prompt_key(struct client *c, int key) /* Insert the new word. */ size += strlen(s); off = first - c->prompt_buffer; - c->prompt_buffer = xrealloc(c->prompt_buffer, 1, size + 1); + c->prompt_buffer = xrealloc(c->prompt_buffer, size + 1); first = c->prompt_buffer + off; memmove(first + strlen(s), first, n); memcpy(first, s, strlen(s)); @@ -1170,7 +1170,7 @@ status_prompt_key(struct client *c, int key) break; } - c->prompt_buffer = xrealloc(c->prompt_buffer, 1, size + n + 1); + c->prompt_buffer = xrealloc(c->prompt_buffer, size + n + 1); if (c->prompt_index == size) { memcpy(c->prompt_buffer + c->prompt_index, pb->data, n); c->prompt_index += n; @@ -1210,7 +1210,7 @@ status_prompt_key(struct client *c, int key) case MODEKEY_OTHER: if ((key & 0xff00) != 0 || key < 32 || key == 127) break; - c->prompt_buffer = xrealloc(c->prompt_buffer, 1, size + 2); + c->prompt_buffer = xrealloc(c->prompt_buffer, size + 2); if (c->prompt_index == size) { c->prompt_buffer[c->prompt_index++] = key; diff --git a/tmux.h b/tmux.h index 9be247f..d119742 100644 --- a/tmux.h +++ b/tmux.h @@ -2408,7 +2408,8 @@ __dead void printflike1 log_fatalx(const char *, ...); char *xstrdup(const char *); void *xcalloc(size_t, size_t); void *xmalloc(size_t); -void *xrealloc(void *, size_t, size_t); +void *xrealloc(void *, size_t); +void *xreallocarray(void *, size_t, size_t); int printflike2 xasprintf(char **, const char *, ...); int xvasprintf(char **, const char *, va_list); int printflike3 xsnprintf(char *, size_t, const char *, ...); diff --git a/utf8.c b/utf8.c index 78ed167..2940ebb 100644 --- a/utf8.c +++ b/utf8.c @@ -419,7 +419,7 @@ utf8_fromcstr(const char *src) n = 0; while (*src != '\0') { - dst = xrealloc(dst, n + 1, sizeof *dst); + dst = xreallocarray(dst, n + 1, sizeof *dst); if (utf8_open(&dst[n], *src)) { more = 1; while (*++src != '\0' && more) @@ -436,7 +436,7 @@ utf8_fromcstr(const char *src) n++; } - dst = xrealloc(dst, n + 1, sizeof *dst); + dst = xreallocarray(dst, n + 1, sizeof *dst); dst[n].size = 0; return (dst); } @@ -452,12 +452,12 @@ utf8_tocstr(struct utf8_data *src) n = 0; for(; src->size != 0; src++) { - dst = xrealloc(dst, n + src->size, 1); + dst = xreallocarray(dst, n + src->size, 1); memcpy(dst + n, src->data, src->size); n += src->size; } - dst = xrealloc(dst, n + 1, 1); + dst = xreallocarray(dst, n + 1, 1); dst[n] = '\0'; return (dst); } diff --git a/window-choose.c b/window-choose.c index 99e8803..ef3b856 100644 --- a/window-choose.c +++ b/window-choose.c @@ -317,7 +317,7 @@ window_choose_prompt_input(enum window_choose_input_type input_type, data->input_prompt = prompt; input_len = strlen(data->input_str) + 2; - data->input_str = xrealloc(data->input_str, 1, input_len); + data->input_str = xrealloc(data->input_str, input_len); data->input_str[input_len - 2] = key; data->input_str[input_len - 1] = '\0'; diff --git a/window-copy.c b/window-copy.c index 44fe6ae..69921f6 100644 --- a/window-copy.c +++ b/window-copy.c @@ -794,7 +794,7 @@ window_copy_key_input(struct window_pane *wp, int key) } inputlen = strlen(data->inputstr); - data->inputstr = xrealloc(data->inputstr, 1, inputlen + n + 1); + data->inputstr = xrealloc(data->inputstr, inputlen + n + 1); memcpy(data->inputstr + inputlen, pb->data, n); data->inputstr[inputlen + n] = '\0'; break; @@ -840,7 +840,7 @@ window_copy_key_input(struct window_pane *wp, int key) break; inputlen = strlen(data->inputstr) + 2; - data->inputstr = xrealloc(data->inputstr, 1, inputlen); + data->inputstr = xrealloc(data->inputstr, inputlen); data->inputstr[inputlen - 2] = key; data->inputstr[inputlen - 1] = '\0'; break; @@ -1533,7 +1533,7 @@ window_copy_append_selection(struct window_pane *wp, const char *bufname) } else pb = paste_get_name(bufname); if (pb != NULL) { - buf = xrealloc(buf, 1, len + pb->size); + buf = xrealloc(buf, len + pb->size); memmove(buf + pb->size, buf, len); memcpy(buf, pb->data, pb->size); len += pb->size; @@ -1589,7 +1589,7 @@ window_copy_copy_line(struct window_pane *wp, } } - *buf = xrealloc(*buf, 1, (*off) + ud.size); + *buf = xrealloc(*buf, (*off) + ud.size); memcpy(*buf + *off, ud.data, ud.size); *off += ud.size; } @@ -1597,7 +1597,7 @@ window_copy_copy_line(struct window_pane *wp, /* Only add a newline if the line wasn't wrapped. */ if (!wrapped || ex != xx) { - *buf = xrealloc(*buf, 1, (*off) + 1); + *buf = xrealloc(*buf, (*off) + 1); (*buf)[(*off)++] = '\n'; } } diff --git a/xmalloc.c b/xmalloc.c index cb734ed..49a0eff 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -68,7 +68,20 @@ xmalloc(size_t size) } void * -xrealloc(void *oldptr, size_t nmemb, size_t size) +xrealloc(void *oldptr, size_t newsize) +{ + void *newptr; + + if (newsize == 0) + fatalx("zero size"); + if ((newptr = realloc(oldptr, newsize)) == NULL) + fatal("xrealloc failed"); + + return (newptr); +} + +void * +xreallocarray(void *oldptr, size_t nmemb, size_t size) { size_t newsize = nmemb * size; void *newptr; @@ -78,7 +91,7 @@ xrealloc(void *oldptr, size_t nmemb, size_t size) if (SIZE_MAX / nmemb < size) fatalx("nmemb * size > SIZE_MAX"); if ((newptr = realloc(oldptr, newsize)) == NULL) - fatal("xrealloc failed"); + fatal("xreallocarray failed"); return (newptr); } commit 77efcf8bdd14cd19dc445cf6e44bba7af414939c Author: nicm <nicm> Commit: nicm <nicm> Use xrealloc(NULL, n, m) instead of xmalloc(n * m) to get overflow check. --- grid.c | 3 ++- paste.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/grid.c b/grid.c index afb0e04..b2351b2 100644 --- a/grid.c +++ b/grid.c @@ -724,7 +724,8 @@ grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl, to_copy = src_gl->cellsize; /* Expand destination line. */ - dst_gl->celldata = xmalloc(to_copy * sizeof *dst_gl->celldata); + dst_gl->celldata = xrealloc(NULL, to_copy, + sizeof *dst_gl->celldata); dst_gl->cellsize = to_copy; dst_gl->flags |= GRID_LINE_WRAPPED; diff --git a/paste.c b/paste.c index e8ea0c3..603adda 100644 --- a/paste.c +++ b/paste.c @@ -279,7 +279,7 @@ paste_make_sample(struct paste_buffer *pb, int utf8flag) len = pb->size; if (len > width) len = width; - buf = xmalloc(len * 4 + 4); + buf = xrealloc(NULL, len, 4 + 4); if (utf8flag) used = utf8_strvis(buf, pb->data, len, flags); commit 6610e89689de1ba8afe492ad20b541271d39732d Author: nicm <nicm> Commit: nicm <nicm> Top function key is F12 now. --- tmux.1 | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tmux.1 b/tmux.1 index 7f8e0ba..bb7f5aa 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1856,7 +1856,7 @@ In addition, the following special key names are accepted: .Em Escape , .Em F1 to -.Em F20 , +.Em F12 , .Em Home , .Em IC (Insert), commit d306bbe11e9701235a468e463699a832b89d6f4d Author: nicm <nicm> Commit: nicm <nicm> Take account of window-status-separator when checking window position, based on diff from Balazs Kezes. --- status.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/status.c b/status.c index 4ea42f1..96110c7 100644 --- a/status.c +++ b/status.c @@ -121,12 +121,17 @@ status_set_window_at(struct client *c, u_int x) { struct session *s = c->session; struct winlink *wl; + struct options *oo; + size_t len; x += c->wlmouse; RB_FOREACH(wl, winlinks, &s->windows) { + oo = &wl->window->options; + + len = strlen(options_get_string(oo, "window-status-separator")); if (x < wl->status_width && session_select(s, wl->idx) == 0) server_redraw_session(s); - x -= wl->status_width + 1; + x -= wl->status_width + len; } } commit c011446e781eae4fd1116dacc63a3e26c2f47788 Author: nicm <nicm> Commit: nicm <nicm> Update status when pane selected with mouse, from Balazs Kezes. --- server-client.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/server-client.c b/server-client.c index 093f0a1..bd7579f 100644 --- a/server-client.c +++ b/server-client.c @@ -329,6 +329,7 @@ server_client_check_mouse(struct client *c, struct window_pane *wp) if (options_get_number(oo, "mouse-select-pane") && (m->event == MOUSE_EVENT_DOWN || m->event == MOUSE_EVENT_WHEEL)) { window_set_active_at(wp->window, m->x, m->y); + server_status_window(wp->window); server_redraw_window_borders(wp->window); wp = wp->window->active; /* may have changed */ } commit 2f19df09b1850d80e60f2d37f0b7f0db22eae6f7 Author: nicm <nicm> Commit: nicm <nicm> Copy ACS characters as UTF-8, from Balazs Kezes. --- screen-write.c | 2 ++ tty-acs.c | 2 +- window-copy.c | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletions(-) diff --git a/screen-write.c b/screen-write.c index 7251c93..094ea81 100644 --- a/screen-write.c +++ b/screen-write.c @@ -990,6 +990,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) memcpy(&tmp_gc, &s->sel.cell, sizeof tmp_gc); grid_cell_get(gc, &ud); grid_cell_set(&tmp_gc, &ud); + tmp_gc.attr = tmp_gc.attr & ~GRID_ATTR_CHARSET; + tmp_gc.attr |= gc->attr & GRID_ATTR_CHARSET; tmp_gc.flags = gc->flags & ~(GRID_FLAG_FG256|GRID_FLAG_BG256); tmp_gc.flags |= s->sel.cell.flags & (GRID_FLAG_FG256|GRID_FLAG_BG256); diff --git a/tty-acs.c b/tty-acs.c index 13dbbc7..5d03c3e 100644 --- a/tty-acs.c +++ b/tty-acs.c @@ -81,7 +81,7 @@ tty_acs_get(struct tty *tty, u_char ch) struct tty_acs_entry *entry; /* If not a UTF-8 terminal, use the ACS set. */ - if (!(tty->flags & TTY_UTF8)) { + if (tty != NULL && !(tty->flags & TTY_UTF8)) { if (tty->term->acs[ch][0] == '\0') return (NULL); return (&tty->term->acs[ch][0]); diff --git a/window-copy.c b/window-copy.c index c9ddf84..44fe6ae 100644 --- a/window-copy.c +++ b/window-copy.c @@ -1552,6 +1552,7 @@ window_copy_copy_line(struct window_pane *wp, struct grid_line *gl; struct utf8_data ud; u_int i, xx, wrapped = 0; + const char *s; if (sx > ex) return; @@ -1580,6 +1581,13 @@ window_copy_copy_line(struct window_pane *wp, if (gc->flags & GRID_FLAG_PADDING) continue; grid_cell_get(gc, &ud); + if (ud.size == 1 && (gc->attr & GRID_ATTR_CHARSET)) { + s = tty_acs_get(NULL, ud.data[0]); + if (s != NULL && strlen(s) <= sizeof ud.data) { + ud.size = strlen(s); + memcpy (ud.data, s, ud.size); + } + } *buf = xrealloc(*buf, 1, (*off) + ud.size); memcpy(*buf + *off, ud.data, ud.size); commit 045d0c3b9f616fe76b68d4551a6d66f410e760e8 Author: nicm <nicm> Commit: nicm <nicm> Call waitpid on SIGCHLD even if client not attached, it is possible (on very slow platforms) for the first daemon() child to still be running when client_attached is set so we end up with a zombie. From J Raynor. --- client.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-) diff --git a/client.c b/client.c index e92724a..a790f32 100644 --- a/client.c +++ b/client.c @@ -433,15 +433,11 @@ client_signal(int sig, unused short events, unused void *data) struct sigaction sigact; int status; - if (!client_attached) { - switch (sig) { - case SIGCHLD: - waitpid(WAIT_ANY, &status, WNOHANG); - break; - case SIGTERM: + if (sig == SIGCHLD) + waitpid(WAIT_ANY, &status, WNOHANG); + else if (!client_attached) { + if (sig == SIGTERM) event_loopexit(NULL); - break; - } } else { switch (sig) { case SIGHUP: commit a54b0055f66bc2d27bd57fc3f818dc185118470f Author: nicm <nicm> Commit: nicm <nicm> Support using pane id as part of session or window specifier (so %1 means session-of-%1 or window-of-%1) and window id as part of session (so @1 means session-of-@1). --- cmd.c | 85 +++++++++++++++++++++++++++++++++++----------------------------- 1 files changed, 46 insertions(+), 39 deletions(-) diff --git a/cmd.c b/cmd.c index ff36275..8241032 100644 --- a/cmd.c +++ b/cmd.c @@ -121,7 +121,7 @@ struct session *cmd_choose_session_list(struct sessionslist *); struct session *cmd_choose_session(int); struct client *cmd_choose_client(struct clients *); struct client *cmd_lookup_client(const char *); -struct session *cmd_lookup_session(const char *, int *); +struct session *cmd_lookup_session(struct cmd_q *, const char *, int *); struct session *cmd_lookup_session_id(const char *); struct winlink *cmd_lookup_window(struct session *, const char *, int *); int cmd_lookup_index(struct session *, const char *, int *); @@ -585,9 +585,11 @@ cmd_lookup_session_id(const char *arg) /* Lookup a session by name. If no session is found, NULL is returned. */ struct session * -cmd_lookup_session(const char *name, int *ambiguous) +cmd_lookup_session(struct cmd_q *cmdq, const char *name, int *ambiguous) { - struct session *s, *sfound; + struct session *s, *sfound; + struct window *w; + struct window_pane *wp; *ambiguous = 0; @@ -595,6 +597,12 @@ cmd_lookup_session(const char *name, int *ambiguous) if ((s = cmd_lookup_session_id(name)) != NULL) return (s); + /* Try as pane or window id. */ + if ((wp = cmd_lookup_paneid(name)) != NULL) + return (cmd_window_session(cmdq, wp->window, NULL)); + if ((w = cmd_lookup_windowid(name)) != NULL) + return (cmd_window_session(cmdq, w, NULL)); + /* * Look for matches. First look for exact matches - session names must * be unique so an exact match can't be ambigious and can just be @@ -630,16 +638,30 @@ cmd_lookup_session(const char *name, int *ambiguous) struct winlink * cmd_lookup_window(struct session *s, const char *name, int *ambiguous) { - struct winlink *wl, *wlfound; - const char *errstr; - u_int idx; + struct winlink *wl, *wlfound; + struct window *w; + struct window_pane *wp; + const char *errstr; + u_int idx; *ambiguous = 0; - /* Try as a window id. */ + /* Try as pane or window id. */ if ((wl = cmd_lookup_winlink_windowid(s, name)) != NULL) return (wl); + /* Lookup as pane or window id. */ + if ((wp = cmd_lookup_paneid(name)) != NULL) { + wl = winlink_find_by_window(&s->windows, wp->window); + if (wl != NULL) + return (wl); + } + if ((w = cmd_lookup_windowid(name)) != NULL) { + wl = winlink_find_by_window(&s->windows, w); + if (wl != NULL) + return (wl); + } + /* First see if this is a valid window index in this session. */ idx = strtonum(name, 0, INT_MAX, &errstr); if (errstr == NULL) { @@ -786,13 +808,11 @@ cmd_window_session(struct cmd_q *cmdq, struct window *w, struct winlink **wlp) struct session * cmd_find_session(struct cmd_q *cmdq, const char *arg, int prefer_unattached) { - struct session *s; - struct window_pane *wp; - struct window *w; - struct client *c; - char *tmparg; - size_t arglen; - int ambiguous; + struct session *s; + struct client *c; + char *tmparg; + size_t arglen; + int ambiguous; /* A NULL argument means the current session. */ if (arg == NULL) { @@ -801,12 +821,6 @@ cmd_find_session(struct cmd_q *cmdq, const char *arg, int prefer_unattached) return (s); } - /* Lookup as pane id or window id. */ - if ((wp = cmd_lookup_paneid(arg)) != NULL) - return (cmd_window_session(cmdq, wp->window, NULL)); - if ((w = cmd_lookup_windowid(arg)) != NULL) - return (cmd_window_session(cmdq, w, NULL)); - /* Trim a single trailing colon if any. */ tmparg = xstrdup(arg); arglen = strlen(tmparg); @@ -822,7 +836,7 @@ cmd_find_session(struct cmd_q *cmdq, const char *arg, int prefer_unattached) } /* Find the session, if any. */ - s = cmd_lookup_session(tmparg, &ambiguous); + s = cmd_lookup_session(cmdq, tmparg, &ambiguous); /* If it doesn't, try to match it as a client. */ if (s == NULL && (c = cmd_lookup_client(tmparg)) != NULL) @@ -844,12 +858,11 @@ cmd_find_session(struct cmd_q *cmdq, const char *arg, int prefer_unattached) struct winlink * cmd_find_window(struct cmd_q *cmdq, const char *arg, struct session **sp) { - struct session *s; - struct winlink *wl; - struct window_pane *wp; - const char *winptr; - char *sessptr = NULL; - int ambiguous = 0; + struct session *s; + struct winlink *wl; + const char *winptr; + char *sessptr = NULL; + int ambiguous = 0; /* * Find the current session. There must always be a current session, if @@ -867,14 +880,6 @@ cmd_find_window(struct cmd_q *cmdq, const char *arg, struct session **sp) return (s->curw); } - /* Lookup as pane id. */ - if ((wp = cmd_lookup_paneid(arg)) != NULL) { - s = cmd_window_session(cmdq, wp->window, &wl); - if (sp != NULL) - *sp = s; - return (wl); - } - /* Time to look at the argument. If it is empty, that is an error. */ if (*arg == '\0') goto not_found; @@ -889,7 +894,7 @@ cmd_find_window(struct cmd_q *cmdq, const char *arg, struct session **sp) /* Try to lookup the session if present. */ if (*sessptr != '\0') { - if ((s = cmd_lookup_session(sessptr, &ambiguous)) == NULL) + if ((s = cmd_lookup_session(cmdq, sessptr, &ambiguous)) == NULL) goto no_session; } if (sp != NULL) @@ -940,7 +945,8 @@ no_colon: lookup_session: if (ambiguous) goto not_found; - if (*arg != '\0' && (s = cmd_lookup_session(arg, &ambiguous)) == NULL) + if (*arg != '\0' && + (s = cmd_lookup_session(cmdq, arg, &ambiguous)) == NULL) goto no_session; if (sp != NULL) @@ -1030,7 +1036,7 @@ cmd_find_index(struct cmd_q *cmdq, const char *arg, struct session **sp) /* Try to lookup the session if present. */ if (sessptr != NULL && *sessptr != '\0') { - if ((s = cmd_lookup_session(sessptr, &ambiguous)) == NULL) + if ((s = cmd_lookup_session(cmdq, sessptr, &ambiguous)) == NULL) goto no_session; } if (sp != NULL) @@ -1078,7 +1084,8 @@ no_colon: lookup_session: if (ambiguous) goto not_found; - if (*arg != '\0' && (s = cmd_lookup_session(arg, &ambiguous)) == NULL) + if (*arg != '\0' && + (s = cmd_lookup_session(cmdq, arg, &ambiguous)) == NULL) goto no_session; if (sp != NULL) commit 304f86cdbb5bf87f7a266e84c0f4fbd7bf25bb5e Author: nicm <nicm> Commit: nicm <nicm> Support ! for last pane. --- cmd.c | 8 +++++++- tmux.1 | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd.c b/cmd.c index 185d39b..ff36275 100644 --- a/cmd.c +++ b/cmd.c @@ -1192,7 +1192,13 @@ cmd_find_pane(struct cmd_q *cmdq, *wpp = wl->window->active; else if (paneptr[0] == '+' || paneptr[0] == '-') *wpp = cmd_find_pane_offset(paneptr, wl); - else { + else if (paneptr[0] == '!' && paneptr[1] == '\0') { + if (wl->window->last == NULL) { + cmdq_error(cmdq, "no last pane"); + goto error; + } + *wpp = wl->window->last; + } else { idx = strtonum(paneptr, 0, INT_MAX, &errstr); if (errstr != NULL) goto lookup_string; diff --git a/tmux.1 b/tmux.1 index 4e86e9c..7f8e0ba 100644 --- a/tmux.1 +++ b/tmux.1 @@ -435,10 +435,11 @@ first attempts to use the argument as a pane index; if that fails, it is looked up as for .Ar target-window . A -.Ql + -or +.Ql + , .Ql - -indicate the next or previous pane index, respectively. +or +.Ql \&! +indicate the next, previous or last pane. One of the strings .Em top , .Em bottom , ----------------------------------------------------------------------- Summary of changes: array.h | 4 +- client.c | 12 ++---- cmd-capture-pane.c | 2 +- cmd-save-buffer.c | 2 +- cmd-set-buffer.c | 2 +- cmd-string.c | 19 +++++----- cmd.c | 99 +++++++++++++++++++++++++++++---------------------- format.c | 8 ++-- grid.c | 15 +++++--- input.c | 4 +- osdep-cygwin.c | 2 +- osdep-linux.c | 2 +- paste.c | 2 +- screen-write.c | 2 + screen.c | 4 +- server-client.c | 1 + status.c | 13 +++++-- tmux.1 | 9 +++-- tmux.h | 3 +- tty-acs.c | 2 +- utf8.c | 8 ++-- window-choose.c | 2 +- window-copy.c | 18 +++++++--- xmalloc.c | 17 ++++++++- 24 files changed, 148 insertions(+), 104 deletions(-) hooks/post-receive -- tmux ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho _______________________________________________ tmux-cvs mailing list tmux-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-cvs