[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.215 and 1.216

version 1.215, 2019/11/15 11:21:32 version 1.216, 2019/11/25 15:02:48
Line 1560 
Line 1560 
 format_replace(struct format_tree *ft, const char *key, size_t keylen,  format_replace(struct format_tree *ft, const char *key, size_t keylen,
     char **buf, size_t *len, size_t *off)      char **buf, size_t *len, size_t *off)
 {  {
         struct window_pane      *wp = ft->wp;          struct window_pane       *wp = ft->wp;
         const char              *errptr, *copy, *cp, *marker = NULL;          const char               *errptr, *copy, *cp, *marker = NULL;
         char                    *copy0, *condition, *found, *new;          char                     *copy0, *condition, *found, *new;
         char                    *value, *left, *right;          char                     *value, *left, *right;
         size_t                   valuelen;          size_t                    valuelen;
         int                      modifiers = 0, limit = 0, j;          int                       modifiers = 0, limit = 0, j;
         struct format_modifier  *list, *fm, *cmp = NULL, *search = NULL;          struct format_modifier   *list, *fm, *cmp = NULL, *search = NULL;
         struct format_modifier  *sub = NULL;          struct format_modifier  **sub = NULL;
         u_int                    i, count;          u_int                     i, count, nsub = 0;
   
         /* Make a copy of the key. */          /* Make a copy of the key. */
         copy = copy0 = xstrndup(key, keylen);          copy = copy0 = xstrndup(key, keylen);
Line 1597 
Line 1597 
                         case 's':                          case 's':
                                 if (fm->argc < 2)                                  if (fm->argc < 2)
                                         break;                                          break;
                                 sub = fm;                                  sub = xreallocarray (sub, nsub + 1,
                                       sizeof *sub);
                                   sub[nsub++] = fm;
                                 break;                                  break;
                         case '=':                          case '=':
                                 if (fm->argc < 1)                                  if (fm->argc < 1)
Line 1809 
Line 1811 
         }          }
   
         /* Perform substitution if any. */          /* Perform substitution if any. */
         if (sub != NULL) {          for (i = 0; i < nsub; i++) {
                 left = format_expand(ft, sub->argv[0]);                  left = format_expand(ft, sub[i]->argv[0]);
                 right = format_expand(ft, sub->argv[1]);                  right = format_expand(ft, sub[i]->argv[1]);
                 new = format_sub(sub, value, left, right);                  new = format_sub(sub[i], value, left, right);
                 format_log(ft, "substitute '%s' to '%s': %s", left, right, new);                  format_log(ft, "substitute '%s' to '%s': %s", left, right, new);
                 free(value);                  free(value);
                 value = new;                  value = new;
Line 1855 
Line 1857 
         format_log(ft, "replaced '%s' with '%s'", copy0, value);          format_log(ft, "replaced '%s' with '%s'", copy0, value);
         free(value);          free(value);
   
           free(sub);
         format_free_modifiers(list, count);          format_free_modifiers(list, count);
         free(copy0);          free(copy0);
         return (0);          return (0);
   
 fail:  fail:
         format_log(ft, "failed %s", copy0);          format_log(ft, "failed %s", copy0);
   
           free(sub);
         format_free_modifiers(list, count);          format_free_modifiers(list, count);
         free(copy0);          free(copy0);
         return (-1);          return (-1);

Legend:
Removed from v.1.215  
changed lines
  Added in v.1.216