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

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

version 1.126, 2016/10/16 19:04:05 version 1.127, 2016/10/21 13:51:59
Line 653 
Line 653 
 cmd_template_replace(const char *template, const char *s, int idx)  cmd_template_replace(const char *template, const char *s, int idx)
 {  {
         char             ch, *buf;          char             ch, *buf;
         const char      *ptr;          const char      *ptr, *cp;
         int              replaced;          int              replaced, quoted;
         size_t           len;          size_t           len;
   
         if (strchr(template, '%') == NULL)          if (strchr(template, '%') == NULL)
Line 676 
Line 676 
                         }                          }
                         ptr++;                          ptr++;
   
                         len += strlen(s);                          quoted = (*ptr == '%');
                         buf = xrealloc(buf, len + 1);                          if (quoted)
                         strlcat(buf, s, len + 1);                                  ptr++;
   
                           buf = xrealloc(buf, len + (strlen(s) * 2) + 1);
                           for (cp = s; *cp != '\0'; cp++) {
                                   if (quoted && *cp == '"')
                                           buf[len++] = '\\';
                                   buf[len++] = *cp;
                           }
                           buf[len] = '\0';
                         continue;                          continue;
                 }                  }
                 buf = xrealloc(buf, len + 2);                  buf = xrealloc(buf, len + 2);

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