[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.15 and 1.16

version 1.15, 2012/07/10 11:53:01 version 1.16, 2012/07/11 07:10:15
Line 29 
Line 29 
  * Saves a paste buffer to a file.   * Saves a paste buffer to a file.
  */   */
   
 int     cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *);  enum cmd_retval  cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *);
   
 const struct cmd_entry cmd_save_buffer_entry = {  const struct cmd_entry cmd_save_buffer_entry = {
         "save-buffer", "saveb",          "save-buffer", "saveb",
Line 41 
Line 41 
         cmd_save_buffer_exec          cmd_save_buffer_exec
 };  };
   
 int  enum cmd_retval
 cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)  cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
 {  {
         struct args             *args = self->args;          struct args             *args = self->args;
Line 57 
Line 57 
         if (!args_has(args, 'b')) {          if (!args_has(args, 'b')) {
                 if ((pb = paste_get_top(&global_buffers)) == NULL) {                  if ((pb = paste_get_top(&global_buffers)) == NULL) {
                         ctx->error(ctx, "no buffers");                          ctx->error(ctx, "no buffers");
                         return (-1);                          return (CMD_RETURN_ERROR);
                 }                  }
         } else {          } else {
                 buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);                  buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
                 if (cause != NULL) {                  if (cause != NULL) {
                         ctx->error(ctx, "buffer %s", cause);                          ctx->error(ctx, "buffer %s", cause);
                         free(cause);                          free(cause);
                         return (-1);                          return (CMD_RETURN_ERROR);
                 }                  }
   
                 pb = paste_get_index(&global_buffers, buffer);                  pb = paste_get_index(&global_buffers, buffer);
                 if (pb == NULL) {                  if (pb == NULL) {
                         ctx->error(ctx, "no buffer %d", buffer);                          ctx->error(ctx, "no buffer %d", buffer);
                         return (-1);                          return (CMD_RETURN_ERROR);
                 }                  }
         }          }
   
Line 78 
Line 78 
         if (strcmp(path, "-") == 0) {          if (strcmp(path, "-") == 0) {
                 if (c == NULL) {                  if (c == NULL) {
                         ctx->error(ctx, "%s: can't write to stdout", path);                          ctx->error(ctx, "%s: can't write to stdout", path);
                         return (-1);                          return (CMD_RETURN_ERROR);
                 }                  }
                 evbuffer_add(c->stdout_data, pb->data, pb->size);                  evbuffer_add(c->stdout_data, pb->data, pb->size);
                 server_push_stdout(c);                  server_push_stdout(c);
Line 105 
Line 105 
                 umask(mask);                  umask(mask);
                 if (f == NULL) {                  if (f == NULL) {
                         ctx->error(ctx, "%s: %s", path, strerror(errno));                          ctx->error(ctx, "%s: %s", path, strerror(errno));
                         return (-1);                          return (CMD_RETURN_ERROR);
                 }                  }
                 if (fwrite(pb->data, 1, pb->size, f) != pb->size) {                  if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
                         ctx->error(ctx, "%s: fwrite error", path);                          ctx->error(ctx, "%s: fwrite error", path);
                         fclose(f);                          fclose(f);
                         return (-1);                          return (CMD_RETURN_ERROR);
                 }                  }
                 fclose(f);                  fclose(f);
         }          }
   
         return (0);          return (CMD_RETURN_NORMAL);
 }  }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16