Make -a append to top buffer if -b is not specified.

This commit is contained in:
Nicholas Marriott 2014-03-08 08:53:48 +00:00
parent 3625bcba24
commit 9880114aff

View File

@ -53,6 +53,9 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
psize = 0; psize = 0;
pdata = NULL; pdata = NULL;
pb = NULL;
buffer = -1;
if (args_has(args, 'b')) { if (args_has(args, 'b')) {
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
if (cause != NULL) { if (cause != NULL) {
@ -65,13 +68,17 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
cmdq_error(cmdq, "no buffer %d", buffer); cmdq_error(cmdq, "no buffer %d", buffer);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (args_has(args, 'a')) { } else if (args_has(args, 'a')) {
psize = pb->size; pb = paste_get_top(&global_buffers);
pdata = xmalloc(psize); if (pb != NULL)
memcpy(pdata, pb->data, psize); buffer = 0;
} }
} else
buffer = -1; if (args_has(args, 'a') && pb != NULL) {
psize = pb->size;
pdata = xmalloc(psize);
memcpy(pdata, pb->data, psize);
}
newsize = strlen(args->argv[0]); newsize = strlen(args->argv[0]);