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

Diff for /src/usr.bin/tmux/cmd-queue.c between version 1.85 and 1.86

version 1.85, 2020/04/13 13:42:35 version 1.86, 2020/04/13 14:04:25
Line 51 
Line 51 
   
         int                      flags;          int                      flags;
   
         struct cmdq_shared      *shared;          struct cmdq_state       *state;
         struct cmd_find_state    source;          struct cmd_find_state    source;
         struct cmd_find_state    target;          struct cmd_find_state    target;
   
Line 142 
Line 142 
         return (&item->source);          return (&item->source);
 }  }
   
 /* Get item shared. */  /* Get item state. */
 struct cmdq_shared *  struct cmdq_state *
 cmdq_get_shared(struct cmdq_item *item)  cmdq_get_state(struct cmdq_item *item)
 {  {
         return (item->shared);          return (item->state);
 }  }
   
 /* Merge formats from item. */  /* Merge formats from item. */
Line 159 
Line 159 
                 entry = cmd_get_entry (item->cmd);                  entry = cmd_get_entry (item->cmd);
                 format_add(ft, "command", "%s", entry->name);                  format_add(ft, "command", "%s", entry->name);
         }          }
         if (item->shared->formats != NULL)          if (item->state->formats != NULL)
                 format_merge(ft, item->shared->formats);                  format_merge(ft, item->state->formats);
 }  }
   
 /* Append an item. */  /* Append an item. */
Line 228 
Line 228 
         struct options_array_item       *a;          struct options_array_item       *a;
         struct cmd_list                 *cmdlist;          struct cmd_list                 *cmdlist;
   
         if (item->shared->flags & CMDQ_SHARED_NOHOOKS)          if (item->state->flags & CMDQ_STATE_NOHOOKS)
                 return;                  return;
         if (s == NULL)          if (s == NULL)
                 oo = global_s_options;                  oo = global_s_options;
Line 255 
Line 255 
                 }                  }
   
                 new_item = cmdq_get_command(cmdlist, fs, NULL,                  new_item = cmdq_get_command(cmdlist, fs, NULL,
                     CMDQ_SHARED_NOHOOKS);                      CMDQ_STATE_NOHOOKS);
                 cmdq_format(new_item, "hook", "%s", name);                  cmdq_format(new_item, "hook", "%s", name);
                 if (item != NULL)                  if (item != NULL)
                         item = cmdq_insert_after(item, new_item);                          item = cmdq_insert_after(item, new_item);
Line 279 
Line 279 
 static void  static void
 cmdq_remove(struct cmdq_item *item)  cmdq_remove(struct cmdq_item *item)
 {  {
         if (item->shared != NULL && --item->shared->references == 0) {          if (item->state != NULL && --item->state->references == 0) {
                 if (item->shared->formats != NULL)                  if (item->state->formats != NULL)
                         format_free(item->shared->formats);                          format_free(item->state->formats);
                 free(item->shared);                  free(item->state);
         }          }
   
         if (item->client != NULL)          if (item->client != NULL)
Line 322 
Line 322 
         struct cmdq_item        *item, *first = NULL, *last = NULL;          struct cmdq_item        *item, *first = NULL, *last = NULL;
         struct cmd              *cmd;          struct cmd              *cmd;
         const struct cmd_entry  *entry;          const struct cmd_entry  *entry;
         struct cmdq_shared      *shared = NULL;          struct cmdq_state       *state = NULL;
         u_int                    group, last_group = 0;          u_int                    group, last_group = 0;
   
         cmd = cmd_list_first(cmdlist, &group);          cmd = cmd_list_first(cmdlist, &group);
         while (cmd != NULL) {          while (cmd != NULL) {
                 if (group != last_group) {                  if (group != last_group) {
                         shared = xcalloc(1, sizeof *shared);                          state = xcalloc(1, sizeof *state);
                         if (current != NULL)                          if (current != NULL)
                                 cmd_find_copy_state(&shared->current, current);                                  cmd_find_copy_state(&state->current, current);
                         else                          else
                                 cmd_find_clear_state(&shared->current, 0);                                  cmd_find_clear_state(&state->current, 0);
                         if (m != NULL) {                          if (m != NULL) {
                                 shared->event.key = KEYC_NONE;                                  state->event.key = KEYC_NONE;
                                 memcpy(&shared->event.m, m,                                  memcpy(&state->event.m, m,
                                     sizeof shared->event.m);                                      sizeof state->event.m);
                         }                          }
                         shared->flags = flags;                          state->flags = flags;
                         last_group = group;                          last_group = group;
                 }                  }
                 entry = cmd_get_entry(cmd);                  entry = cmd_get_entry(cmd);
Line 348 
Line 348 
                 item->type = CMDQ_COMMAND;                  item->type = CMDQ_COMMAND;
                 item->group = group;                  item->group = group;
   
                 item->shared = shared;                  item->state = state;
                 item->cmdlist = cmdlist;                  item->cmdlist = cmdlist;
                 item->cmd = cmd;                  item->cmd = cmd;
   
                 log_debug("%s: %s group %u", __func__, item->name, item->group);                  log_debug("%s: %s group %u", __func__, item->name, item->group);
   
                 shared->references++;                  state->references++;
                 cmdlist->references++;                  cmdlist->references++;
   
                 if (first == NULL)                  if (first == NULL)
Line 394 
Line 394 
 {  {
         struct client           *c = item->client;          struct client           *c = item->client;
         const char              *name = cmdq_name(c);          const char              *name = cmdq_name(c);
         struct cmdq_shared      *shared = item->shared;          struct cmdq_state       *state = item->state;
         struct cmd              *cmd = item->cmd;          struct cmd              *cmd = item->cmd;
         const struct cmd_entry  *entry = cmd_get_entry(cmd);          const struct cmd_entry  *entry = cmd_get_entry(cmd);
         enum cmd_retval          retval;          enum cmd_retval          retval;
Line 408 
Line 408 
                 free(tmp);                  free(tmp);
         }          }
   
         flags = !!(shared->flags & CMDQ_SHARED_CONTROL);          flags = !!(state->flags & CMDQ_STATE_CONTROL);
         cmdq_guard(item, "begin", flags);          cmdq_guard(item, "begin", flags);
   
         if (item->client == NULL)          if (item->client == NULL)
Line 427 
Line 427 
         if (entry->flags & CMD_AFTERHOOK) {          if (entry->flags & CMD_AFTERHOOK) {
                 if (cmd_find_valid_state(&item->target))                  if (cmd_find_valid_state(&item->target))
                         fsp = &item->target;                          fsp = &item->target;
                 else if (cmd_find_valid_state(&item->shared->current))                  else if (cmd_find_valid_state(&item->state->current))
                         fsp = &item->shared->current;                          fsp = &item->state->current;
                 else if (cmd_find_from_client(&fs, item->client, 0) == 0)                  else if (cmd_find_from_client(&fs, item->client, 0) == 0)
                         fsp = &fs;                          fsp = &fs;
                 else                  else
Line 492 
Line 492 
 void  void
 cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...)  cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...)
 {  {
         struct cmdq_shared      *shared = item->shared;          struct cmdq_state       *state = item->state;
         va_list                  ap;          va_list                  ap;
         char                    *value;          char                    *value;
   
Line 500 
Line 500 
         xvasprintf(&value, fmt, ap);          xvasprintf(&value, fmt, ap);
         va_end(ap);          va_end(ap);
   
         if (shared->formats == NULL)          if (state->formats == NULL)
                 shared->formats = format_create(NULL, NULL, FORMAT_NONE, 0);                  state->formats = format_create(NULL, NULL, FORMAT_NONE, 0);
         format_add(shared->formats, key, "%s", value);          format_add(state->formats, key, "%s", value);
   
         free(value);          free(value);
 }  }

Legend:
Removed from v.1.85  
changed lines
  Added in v.1.86