[BACK]Return to cmd-save-buffer.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/cmd-save-buffer.c between version 1.28 and 1.29

version 1.28, 2015/04/27 16:25:57 version 1.29, 2015/08/29 09:25:00
Line 57 
Line 57 
         struct client           *c = cmdq->client;          struct client           *c = cmdq->client;
         struct session          *s;          struct session          *s;
         struct paste_buffer     *pb;          struct paste_buffer     *pb;
         const char              *path, *bufname;          const char              *path, *bufname, *bufdata;
         char                    *start, *end, *msg;          char                    *start, *end, *msg;
         size_t                   size, used, msglen;          size_t                   size, used, msglen, bufsize;
         int                      cwd, fd;          int                      cwd, fd;
         FILE                    *f;          FILE                    *f;
   
         if (!args_has(args, 'b')) {          if (!args_has(args, 'b')) {
                 if ((pb = paste_get_top()) == NULL) {                  if ((pb = paste_get_top(NULL)) == NULL) {
                         cmdq_error(cmdq, "no buffers");                          cmdq_error(cmdq, "no buffers");
                         return (CMD_RETURN_ERROR);                          return (CMD_RETURN_ERROR);
                 }                  }
Line 76 
Line 76 
                         return (CMD_RETURN_ERROR);                          return (CMD_RETURN_ERROR);
                 }                  }
         }          }
           bufdata = paste_buffer_data(pb, &bufsize);
   
         if (self->entry == &cmd_show_buffer_entry)          if (self->entry == &cmd_show_buffer_entry)
                 path = "-";                  path = "-";
Line 114 
Line 115 
                 cmdq_error(cmdq, "%s: %s", path, strerror(errno));                  cmdq_error(cmdq, "%s: %s", path, strerror(errno));
                 return (CMD_RETURN_ERROR);                  return (CMD_RETURN_ERROR);
         }          }
         if (fwrite(pb->data, 1, pb->size, f) != pb->size) {          if (fwrite(bufdata, 1, bufsize, f) != bufsize) {
                 cmdq_error(cmdq, "%s: fwrite error", path);                  cmdq_error(cmdq, "%s: fwrite error", path);
                 fclose(f);                  fclose(f);
                 return (CMD_RETURN_ERROR);                  return (CMD_RETURN_ERROR);
Line 124 
Line 125 
         return (CMD_RETURN_NORMAL);          return (CMD_RETURN_NORMAL);
   
 do_stdout:  do_stdout:
         evbuffer_add(c->stdout_data, pb->data, pb->size);          evbuffer_add(c->stdout_data, bufdata, bufsize);
         server_push_stdout(c);          server_push_stdout(c);
         return (CMD_RETURN_NORMAL);          return (CMD_RETURN_NORMAL);
   
 do_print:  do_print:
         if (pb->size > (INT_MAX / 4) - 1) {          if (bufsize > (INT_MAX / 4) - 1) {
                 cmdq_error(cmdq, "buffer too big");                  cmdq_error(cmdq, "buffer too big");
                 return (CMD_RETURN_ERROR);                  return (CMD_RETURN_ERROR);
         }          }
         msg = NULL;          msg = NULL;
   
         used = 0;          used = 0;
         while (used != pb->size) {          while (used != bufsize) {
                 start = pb->data + used;                  start = bufdata + used;
                 end = memchr(start, '\n', pb->size - used);                  end = memchr(start, '\n', bufsize - used);
                 if (end != NULL)                  if (end != NULL)
                         size = end - start;                          size = end - start;
                 else                  else
                         size = pb->size - used;                          size = bufsize - used;
   
                 msglen = size * 4 + 1;                  msglen = size * 4 + 1;
                 msg = xrealloc(msg, msglen);                  msg = xrealloc(msg, msglen);

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29