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

Diff for /src/usr.bin/tmux/options.c between version 1.21 and 1.22

version 1.21, 2017/01/11 14:56:44 version 1.22, 2017/01/12 15:36:35
Line 65 
Line 65 
 }  }
   
 static struct options_entry *  static struct options_entry *
 options_new(struct options *oo, const char *name, char **s)  options_new(struct options *oo, const char *name)
 {  {
         struct options_entry    *o;          struct options_entry    *o;
   
         if (s != NULL)  
                 *s = NULL;  
   
         if ((o = options_find1(oo, name)) == NULL) {          if ((o = options_find1(oo, name)) == NULL) {
                 o = xmalloc(sizeof *o);                  o = xmalloc(sizeof *o);
                 o->name = xstrdup(name);                  o->name = xstrdup(name);
                 RB_INSERT(options_tree, &oo->tree, o);                  RB_INSERT(options_tree, &oo->tree, o);
                 memcpy(&o->style, &grid_default_cell, sizeof o->style);                  memcpy(&o->style, &grid_default_cell, sizeof o->style);
         } else if (o->type == OPTIONS_STRING) {          } else if (o->type == OPTIONS_STRING)
                 if (s != NULL)                  free(o->str);
                         *s = o->str;  
                 else  
                         free(o->str);  
         }  
         return (o);          return (o);
 }  }
   
Line 143 
Line 136 
 }  }
   
 struct options_entry *  struct options_entry *
 options_set_string(struct options *oo, const char *name, const char *fmt, ...)  options_set_string(struct options *oo, const char *name, int append,
       const char *fmt, ...)
 {  {
         struct options_entry    *o;          struct options_entry    *o;
         va_list                  ap;          va_list                  ap;
         char                    *s;          char                    *s, *value;
   
         va_start(ap, fmt);          va_start(ap, fmt);
           xvasprintf(&s, fmt, ap);
           va_end(ap);
   
         o = options_new(oo, name, &s);          o = options_find1(oo, name);
           if (o == NULL || !append)
                   value = s;
           else {
                   xasprintf(&value, "%s%s", s, o->str);
                   free(s);
           }
   
           o = options_new(oo, name);
         o->type = OPTIONS_STRING;          o->type = OPTIONS_STRING;
         xvasprintf(&o->str, fmt, ap);          o->str = value;
         free(s);  
   
         va_end(ap);  
         return (o);          return (o);
 }  }
   
Line 177 
Line 179 
 {  {
         struct options_entry    *o;          struct options_entry    *o;
   
         o = options_new(oo, name, NULL);          o = options_new(oo, name);
         o->type = OPTIONS_NUMBER;          o->type = OPTIONS_NUMBER;
         o->num = value;          o->num = value;
   
Line 197 
Line 199 
 }  }
   
 struct options_entry *  struct options_entry *
 options_set_style(struct options *oo, const char *name, const char *value,  options_set_style(struct options *oo, const char *name, int append,
     int append)      const char *value)
 {  {
         struct options_entry    *o;          struct options_entry    *o;
         struct grid_cell         tmpgc;          struct grid_cell         tmpgc;
Line 212 
Line 214 
         if (style_parse(&grid_default_cell, &tmpgc, value) == -1)          if (style_parse(&grid_default_cell, &tmpgc, value) == -1)
                 return (NULL);                  return (NULL);
   
         o = options_new(oo, name, NULL);          o = options_new(oo, name);
         o->type = OPTIONS_STYLE;          o->type = OPTIONS_STYLE;
         memcpy(&o->style, &tmpgc, sizeof o->style);          memcpy(&o->style, &tmpgc, sizeof o->style);
   

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22