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

Diff for /src/usr.bin/tmux/cmd-load-buffer.c between version 1.44 and 1.45

version 1.44, 2016/10/14 22:14:22 version 1.45, 2016/10/16 17:55:14
Line 46 
Line 46 
         .exec = cmd_load_buffer_exec          .exec = cmd_load_buffer_exec
 };  };
   
   struct cmd_load_buffer_data {
           struct cmd_q    *cmdq;
           char            *bufname;
   };
   
 static enum cmd_retval  static enum cmd_retval
 cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)  cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
 {  {
         struct args     *args = self->args;          struct args                     *args = self->args;
         struct client   *c = cmdq->client;          struct cmd_load_buffer_data     *cdata;
         struct session  *s;          struct client                   *c = cmdq->client;
         FILE            *f;          struct session                  *s;
         const char      *path, *bufname, *cwd;          FILE                            *f;
         char            *pdata, *new_pdata, *cause, *file, resolved[PATH_MAX];          const char                      *path, *bufname, *cwd;
         size_t           psize;          char                            *pdata, *new_pdata, *cause, *file;
         int              ch, error;          char                             resolved[PATH_MAX];
           size_t                           psize;
           int                              ch, error;
   
         bufname = NULL;          bufname = NULL;
         if (args_has(args, 'b'))          if (args_has(args, 'b'))
Line 64 
Line 71 
   
         path = args->argv[0];          path = args->argv[0];
         if (strcmp(path, "-") == 0) {          if (strcmp(path, "-") == 0) {
                   cdata = xcalloc(1, sizeof *cdata);
                   cdata->cmdq = cmdq;
                   cdata->bufname = xstrdup(bufname);
   
                 error = server_set_stdin_callback(c, cmd_load_buffer_callback,                  error = server_set_stdin_callback(c, cmd_load_buffer_callback,
                     (void *)bufname, &cause);                      cdata, &cause);
                 if (error != 0) {                  if (error != 0) {
                         cmdq_error(cmdq, "%s: %s", path, cause);                          cmdq_error(cmdq, "%s: %s", path, cause);
                         free(cause);                          free(cause);
Line 136 
Line 147 
 static void  static void
 cmd_load_buffer_callback(struct client *c, int closed, void *data)  cmd_load_buffer_callback(struct client *c, int closed, void *data)
 {  {
         const char      *bufname = data;          struct cmd_load_buffer_data     *cdata = data;
         char            *pdata, *cause, *saved;          char                            *pdata, *cause, *saved;
         size_t           psize;          size_t                           psize;
   
         if (!closed)          if (!closed)
                 return;                  return;
Line 146 
Line 157 
   
         server_client_unref(c);          server_client_unref(c);
         if (c->flags & CLIENT_DEAD)          if (c->flags & CLIENT_DEAD)
                 return;                  goto out;
   
         psize = EVBUFFER_LENGTH(c->stdin_data);          psize = EVBUFFER_LENGTH(c->stdin_data);
         if (psize == 0 || (pdata = malloc(psize + 1)) == NULL)          if (psize == 0 || (pdata = malloc(psize + 1)) == NULL)
Line 156 
Line 167 
         pdata[psize] = '\0';          pdata[psize] = '\0';
         evbuffer_drain(c->stdin_data, psize);          evbuffer_drain(c->stdin_data, psize);
   
         if (paste_set(pdata, psize, bufname, &cause) != 0) {          if (paste_set(pdata, psize, cdata->bufname, &cause) != 0) {
                 /* No context so can't use server_client_msg_error. */                  /* No context so can't use server_client_msg_error. */
                 if (~c->flags & CLIENT_UTF8) {                  if (~c->flags & CLIENT_UTF8) {
                         saved = cause;                          saved = cause;
Line 168 
Line 179 
                 free(pdata);                  free(pdata);
                 free(cause);                  free(cause);
         }          }
   
 out:  out:
         cmdq_continue(c->cmdq);          cdata->cmdq->flags &= ~CMD_Q_WAITING;
   
           free(cdata->bufname);
           free(cdata);
 }  }

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45