summaryrefslogtreecommitdiffstats
path: root/cmd-show-buffer.c
diff options
context:
space:
mode:
authorRaghavendra D Prabhu <raghu.prabhu13@gmail.com>2011-01-23 17:29:16 +0530
committerRaghavendra D Prabhu <raghu.prabhu13@gmail.com>2011-01-23 17:29:16 +0530
commit0426ab2b383afd38af7274759c3a8d017bc88f00 (patch)
tree2cc4bf1da4062c9ef91f2e94a9625f2423f57102 /cmd-show-buffer.c
parent4e4aed43dc2b40b36f1b31cd3af9f874b78fa454 (diff)
parentb67bfd382d3401de572bb3487b1af3382a9cbeda (diff)
downloadtmux-old-0426ab2b383afd38af7274759c3a8d017bc88f00.tar.gz
tmux-old-0426ab2b383afd38af7274759c3a8d017bc88f00.tar.bz2
tmux-old-0426ab2b383afd38af7274759c3a8d017bc88f00.zip
merged new changesmaster
Diffstat (limited to 'cmd-show-buffer.c')
-rw-r--r--cmd-show-buffer.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/cmd-show-buffer.c b/cmd-show-buffer.c
index 0d9d9b5b..4222697e 100644
--- a/cmd-show-buffer.c
+++ b/cmd-show-buffer.c
@@ -1,4 +1,4 @@
1/* $Id: cmd-show-buffer.c,v 1.12 2009/12/04 22:14:47 tcunha Exp $ */ 1/* $Id: cmd-show-buffer.c,v 1.14 2011/01/07 14:45:34 tcunha Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> 4 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -28,39 +28,47 @@ int cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *);
28 28
29const struct cmd_entry cmd_show_buffer_entry = { 29const struct cmd_entry cmd_show_buffer_entry = {
30 "show-buffer", "showb", 30 "show-buffer", "showb",
31 CMD_BUFFER_SESSION_USAGE, 31 "b:", 0, 0,
32 0, "", 32 CMD_BUFFER_USAGE,
33 cmd_buffer_init, 33 0,
34 cmd_buffer_parse, 34 NULL,
35 cmd_show_buffer_exec, 35 NULL,
36 cmd_buffer_free, 36 cmd_show_buffer_exec
37 cmd_buffer_print
38}; 37};
39 38
40int 39int
41cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) 40cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
42{ 41{
43 struct cmd_buffer_data *data = self->data; 42 struct args *args = self->args;
44 struct session *s; 43 struct session *s;
45 struct paste_buffer *pb; 44 struct paste_buffer *pb;
46 char *in, *buf, *ptr; 45 int buffer;
46 char *in, *buf, *ptr, *cause;
47 size_t size, len; 47 size_t size, len;
48 u_int width; 48 u_int width;
49 49
50 if ((s = cmd_find_session(ctx, data->target)) == NULL) 50 if ((s = cmd_find_session(ctx, NULL)) == NULL)
51 return (-1); 51 return (-1);
52 52
53 if (data->buffer == -1) { 53 if (!args_has(args, 'b')) {
54 if ((pb = paste_get_top(&s->buffers)) == NULL) { 54 if ((pb = paste_get_top(&global_buffers)) == NULL) {
55 ctx->error(ctx, "no buffers"); 55 ctx->error(ctx, "no buffers");
56 return (-1); 56 return (-1);
57 } 57 }
58 } else if ((pb = paste_get_index(&s->buffers, data->buffer)) == NULL) { 58 } else {
59 ctx->error(ctx, "no buffer %d", data->buffer); 59 buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
60 return (-1); 60 if (cause != NULL) {
61 ctx->error(ctx, "buffer %s", cause);
62 xfree(cause);
63 return (-1);
64 }
65
66 pb = paste_get_index(&global_buffers, buffer);
67 if (pb == NULL) {
68 ctx->error(ctx, "no buffer %d", buffer);
69 return (-1);
70 }
61 } 71 }
62 if (pb == NULL)
63 return (0);
64 72
65 size = pb->size; 73 size = pb->size;
66 if (size > SIZE_MAX / 4 - 1) 74 if (size > SIZE_MAX / 4 - 1)