[BACK]Return to format.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/format.c between version 1.126 and 1.127

version 1.126, 2017/04/19 06:52:27 version 1.127, 2017/04/20 09:20:22
Line 39 
Line 39 
 struct format_entry;  struct format_entry;
 typedef void (*format_cb)(struct format_tree *, struct format_entry *);  typedef void (*format_cb)(struct format_tree *, struct format_entry *);
   
 static void      format_job_callback(struct job *);  
 static char     *format_job_get(struct format_tree *, const char *);  static char     *format_job_get(struct format_tree *, const char *);
 static void      format_job_timer(int, short, void *);  static void      format_job_timer(int, short, void *);
   
Line 83 
Line 82 
   
         time_t                   last;          time_t                   last;
         char                    *out;          char                    *out;
           int                      updated;
   
         struct job              *job;          struct job              *job;
         int                      status;          int                      status;
Line 203 
Line 203 
         NULL            /* z */          NULL            /* z */
 };  };
   
 /* Format job callback. */  /* Format job update callback. */
 static void  static void
 format_job_callback(struct job *job)  format_job_update(struct job *job)
 {  {
         struct format_job       *fj = job->data;          struct format_job       *fj = job->data;
           char                    *line;
           time_t                   t;
           struct client           *c;
   
           if ((line = evbuffer_readline(job->event->input)) == NULL)
                   return;
           fj->updated = 1;
   
           free(fj->out);
           fj->out = line;
   
           log_debug("%s: %s: %s", __func__, fj->cmd, fj->out);
   
           t = time (NULL);
           if (fj->status && fj->last != t) {
                   TAILQ_FOREACH(c, &clients, entry)
                       server_status_client(c);
                   fj->last = t;
           }
   }
   
   /* Format job complete callback. */
   static void
   format_job_complete(struct job *job)
   {
           struct format_job       *fj = job->data;
         char                    *line, *buf;          char                    *line, *buf;
         size_t                   len;          size_t                   len;
         struct client           *c;          struct client           *c;
   
         fj->job = NULL;          fj->job = NULL;
         free(fj->out);  
   
         buf = NULL;          buf = NULL;
         if ((line = evbuffer_readline(job->event->input)) == NULL) {          if ((line = evbuffer_readline(job->event->input)) == NULL) {
Line 224 
Line 249 
                 buf[len] = '\0';                  buf[len] = '\0';
         } else          } else
                 buf = line;                  buf = line;
         fj->out = buf;  
   
           if (*buf != '\0' || !fj->updated) {
                   free(fj->out);
                   fj->out = buf;
                   log_debug("%s: %s: %s", __func__, fj->cmd, fj->out);
           } else
                   free(buf);
   
         if (fj->status) {          if (fj->status) {
                 TAILQ_FOREACH(c, &clients, entry)                  TAILQ_FOREACH(c, &clients, entry)
                     server_status_client(c);                      server_status_client(c);
                 fj->status = 0;                  fj->status = 0;
         }          }
   
         log_debug("%s: %s: %s", __func__, fj->cmd, fj->out);  
 }  }
   
 /* Find a job. */  /* Find a job. */
Line 267 
Line 296 
   
         t = time(NULL);          t = time(NULL);
         if (fj->job == NULL && (force || fj->last != t)) {          if (fj->job == NULL && (force || fj->last != t)) {
                 fj->job = job_run(expanded, NULL, NULL, format_job_callback,                  fj->job = job_run(expanded, NULL, NULL, format_job_update,
                     NULL, fj);                      format_job_complete, NULL, fj);
                 if (fj->job == NULL) {                  if (fj->job == NULL) {
                         free(fj->out);                          free(fj->out);
                         xasprintf(&fj->out, "<'%s' didn't start>", fj->cmd);                          xasprintf(&fj->out, "<'%s' didn't start>", fj->cmd);

Legend:
Removed from v.1.126  
changed lines
  Added in v.1.127