=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/status.c,v retrieving revision 1.180 retrieving revision 1.181 diff -c -r1.180 -r1.181 *** src/usr.bin/tmux/status.c 2018/08/29 08:56:51 1.180 --- src/usr.bin/tmux/status.c 2018/08/29 09:50:32 1.181 *************** *** 1,4 **** ! /* $OpenBSD: status.c,v 1.180 2018/08/29 08:56:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: status.c,v 1.181 2018/08/29 09:50:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 766,771 **** --- 766,774 ---- free(c->prompt_buffer); c->prompt_buffer = NULL; + free(c->prompt_saved); + c->prompt_saved = NULL; + c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); c->flags |= CLIENT_ALLREDRAWFLAGS; /* was frozen and may have changed */ *************** *** 1217,1222 **** --- 1220,1231 ---- } } + free(c->prompt_saved); + c->prompt_saved = xcalloc(sizeof *c->prompt_buffer, + (c->prompt_index - idx) + 1); + memcpy(c->prompt_saved, c->prompt_buffer + idx, + (c->prompt_index - idx) * sizeof *c->prompt_buffer); + memmove(c->prompt_buffer + idx, c->prompt_buffer + c->prompt_index, (size + 1 - c->prompt_index) * *************** *** 1290,1311 **** c->prompt_index = utf8_strlen(c->prompt_buffer); goto changed; case '\031': /* C-y */ ! if ((pb = paste_get_top(NULL)) == NULL) ! break; ! bufdata = paste_buffer_data(pb, &bufsize); ! for (n = 0; n < bufsize; n++) { ! ch = (u_char)bufdata[n]; ! if (ch < 32 || ch >= 127) break; } c->prompt_buffer = xreallocarray(c->prompt_buffer, size + n + 1, sizeof *c->prompt_buffer); if (c->prompt_index == size) { ! for (idx = 0; idx < n; idx++) { ! ud = &c->prompt_buffer[c->prompt_index + idx]; ! utf8_set(ud, bufdata[idx]); ! } c->prompt_index += n; c->prompt_buffer[c->prompt_index].size = 0; } else { --- 1299,1326 ---- c->prompt_index = utf8_strlen(c->prompt_buffer); goto changed; case '\031': /* C-y */ ! if (c->prompt_saved != NULL) { ! ud = c->prompt_saved; ! n = utf8_strlen(c->prompt_saved); ! } else { ! if ((pb = paste_get_top(NULL)) == NULL) break; + bufdata = paste_buffer_data(pb, &bufsize); + for (n = 0; n < bufsize; n++) { + ch = (u_char)bufdata[n]; + if (ch < 32 || ch >= 127) + break; + } + ud = xreallocarray(NULL, n, sizeof *ud); + for (idx = 0; idx < n; idx++) + utf8_set(&ud[idx], bufdata[idx]); } c->prompt_buffer = xreallocarray(c->prompt_buffer, size + n + 1, sizeof *c->prompt_buffer); if (c->prompt_index == size) { ! memcpy(c->prompt_buffer + c->prompt_index, ud, ! n * sizeof *c->prompt_buffer); c->prompt_index += n; c->prompt_buffer[c->prompt_index].size = 0; } else { *************** *** 1313,1324 **** c->prompt_buffer + c->prompt_index, (size + 1 - c->prompt_index) * sizeof *c->prompt_buffer); ! for (idx = 0; idx < n; idx++) { ! ud = &c->prompt_buffer[c->prompt_index + idx]; ! utf8_set(ud, bufdata[idx]); ! } c->prompt_index += n; } goto changed; case '\024': /* C-t */ idx = c->prompt_index; --- 1328,1340 ---- c->prompt_buffer + c->prompt_index, (size + 1 - c->prompt_index) * sizeof *c->prompt_buffer); ! memcpy(c->prompt_buffer + c->prompt_index, ud, ! n * sizeof *c->prompt_buffer); c->prompt_index += n; } + + if (ud != c->prompt_saved) + free(ud); goto changed; case '\024': /* C-t */ idx = c->prompt_index;