[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.24 and 1.25

version 1.24, 2013/04/17 14:52:31 version 1.25, 2013/05/31 19:46:42
Line 46 
Line 46 
         return (strcmp(fe1->key, fe2->key));          return (strcmp(fe1->key, fe2->key));
 }  }
   
 /* Single-character aliases. */  /* Single-character uppercase aliases. */
 const char *format_aliases[26] = {  const char *format_upper[] = {
         NULL,           /* A */          NULL,           /* A */
         NULL,           /* B */          NULL,           /* B */
         NULL,           /* C */          NULL,           /* C */
Line 76 
Line 76 
         NULL            /* Z */          NULL            /* Z */
 };  };
   
   /* Single-character lowercase aliases. */
   const char *format_lower[] = {
           NULL,           /* a */
           NULL,           /* b */
           NULL,           /* c */
           NULL,           /* d */
           NULL,           /* e */
           NULL,           /* f */
           NULL,           /* g */
           "host_short",   /* h */
           NULL,           /* i */
           NULL,           /* j */
           NULL,           /* k */
           NULL,           /* l */
           NULL,           /* m */
           NULL,           /* n */
           NULL,           /* o */
           NULL,           /* p */
           NULL,           /* q */
           NULL,           /* r */
           NULL,           /* s */
           NULL,           /* t */
           NULL,           /* u */
           NULL,           /* v */
           NULL,           /* w */
           NULL,           /* x */
           NULL,           /* y */
           NULL            /* z */
   };
   
 /* Create a new tree. */  /* Create a new tree. */
 struct format_tree *  struct format_tree *
 format_create(void)  format_create(void)
 {  {
         struct format_tree      *ft;          struct format_tree      *ft;
         char                     host[MAXHOSTNAMELEN];          char                     host[MAXHOSTNAMELEN], *ptr;
   
         ft = xmalloc(sizeof *ft);          ft = xmalloc(sizeof *ft);
         RB_INIT(ft);          RB_INIT(ft);
   
         if (gethostname(host, sizeof host) == 0)          if (gethostname(host, sizeof host) == 0) {
                 format_add(ft, "host", "%s", host);                  format_add(ft, "host", "%s", host);
                   if ((ptr = strrchr(host, '.')) != NULL)
                           *ptr = '\0';
                   format_add(ft, "host_short", "%s", host);
           }
   
         return (ft);          return (ft);
 }  }
Line 109 
Line 143 
                 free(fe);                  free(fe);
         }          }
   
         free (ft);          free(ft);
 }  }
   
 /* Add a key-value pair. */  /* Add a key-value pair. */
Line 230 
Line 264 
                 fmt++;                  fmt++;
   
                 ch = (u_char) *fmt++;                  ch = (u_char) *fmt++;
   
                 switch (ch) {                  switch (ch) {
                 case '{':                  case '{':
                         ptr = strchr(fmt, '}');                          ptr = strchr(fmt, '}');
Line 242 
Line 277 
                         fmt += n + 1;                          fmt += n + 1;
                         continue;                          continue;
                 default:                  default:
                         if (ch >= 'A' && ch <= 'Z') {                          s = NULL;
                                 s = format_aliases[ch - 'A'];                          if (ch >= 'A' && ch <= 'Z')
                                 if (s != NULL) {                                  s = format_upper[ch - 'A'];
                                         n = strlen(s);                          else if (ch >= 'a' && ch <= 'z')
                                         if (format_replace (                                  s = format_lower[ch - 'a'];
                                             ft, s, n, &buf, &len, &off) != 0)                          if (s == NULL) {
                                                 break;                                  while (len - off < 3) {
                                         continue;                                          buf = xrealloc(buf, 2, len);
                                           len *= 2;
                                 }                                  }
                                   buf[off++] = '#';
                                   buf[off++] = ch;
                                   continue;
                         }                          }
                         while (len - off < 3) {                          n = strlen(s);
                                 buf = xrealloc(buf, 2, len);                          if (format_replace(ft, s, n, &buf, &len, &off) != 0)
                                 len *= 2;                                  break;
                         }  
                         buf[off++] = '#';  
                         buf[off++] = ch;  
                         continue;                          continue;
                 }                  }
   

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25