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

Diff for /src/usr.bin/tmux/Attic/options-cmd.c between version 1.4 and 1.5

version 1.4, 2009/09/21 14:56:03 version 1.5, 2009/09/22 12:38:10
Line 28 
Line 28 
 {  {
         static char     out[BUFSIZ];          static char     out[BUFSIZ];
         const char     *s;          const char     *s;
           struct keylist *keylist;
           u_int           i;
   
         *out = '\0';          *out = '\0';
         switch (entry->type) {          switch (entry->type) {
Line 37 
Line 39 
                 case SET_OPTION_NUMBER:                  case SET_OPTION_NUMBER:
                         xsnprintf(out, sizeof out, "%lld", o->num);                          xsnprintf(out, sizeof out, "%lld", o->num);
                         break;                          break;
                 case SET_OPTION_KEY:                  case SET_OPTION_KEYS:
                         s = key_string_lookup_key(o->num);                          keylist = o->data;
                         xsnprintf(out, sizeof out, "%s", s);                          for (i = 0; i < ARRAY_LENGTH(keylist); i++) {
                                   strlcat(out, key_string_lookup_key(
                                       ARRAY_ITEM(keylist, i)), sizeof out);
                                   if (i != ARRAY_LENGTH(keylist) - 1)
                                           strlcat(out, ",", sizeof out);
                           }
                         break;                          break;
                 case SET_OPTION_COLOUR:                  case SET_OPTION_COLOUR:
                         s = colour_tostring(o->num);                          s = colour_tostring(o->num);
Line 114 
Line 121 
 }  }
   
 void  void
 set_option_key(struct cmd_ctx *ctx, struct options *oo,  set_option_keys(struct cmd_ctx *ctx, struct options *oo,
     const struct set_option_entry *entry, char *value)      const struct set_option_entry *entry, char *value)
 {  {
         struct options_entry    *o;          struct options_entry    *o;
         int                      key;          struct keylist          *keylist;
           char                    *copyvalue, *ptr, *str;
           int                      key;
   
         if (value == NULL) {          if (value == NULL) {
                 ctx->error(ctx, "empty value");                  ctx->error(ctx, "empty value");
                 return;                  return;
         }          }
   
         if ((key = key_string_lookup_string(value)) == KEYC_NONE) {          keylist = xmalloc(sizeof *keylist);
                 ctx->error(ctx, "unknown key: %s", value);          ARRAY_INIT(keylist);
                 return;  
           ptr = copyvalue = xstrdup(value);
           while ((str = strsep(&ptr, ",")) != NULL) {
                   if ((key = key_string_lookup_string(str)) == KEYC_NONE) {
                           xfree(keylist);
                           ctx->error(ctx, "unknown key: %s", str);
                           xfree(copyvalue);
                           return;
                   }
                   ARRAY_ADD(keylist, key);
         }          }
           xfree(copyvalue);
   
         o = options_set_number(oo, entry->name, key);          o = options_set_data(oo, entry->name, keylist, xfree);
         ctx->info(          ctx->info(
             ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));              ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
 }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5