[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.64 and 1.65

version 1.64, 2021/08/21 17:25:32 version 1.65, 2021/10/14 13:19:01
Line 989 
Line 989 
         return (0);          return (0);
 }  }
   
   int
   options_find_choice(const struct options_table_entry *oe, const char *value,
       char **cause)
   {
           const char      **cp;
           int               n = 0, choice = -1;
   
           for (cp = oe->choices; *cp != NULL; cp++) {
                   if (strcmp(*cp, value) == 0)
                           choice = n;
                   n++;
           }
           if (choice == -1) {
                   xasprintf(cause, "unknown value: %s", value);
                   return (-1);
           }
           return (choice);
   }
   
 static int  static int
 options_from_string_choice(const struct options_table_entry *oe,  options_from_string_choice(const struct options_table_entry *oe,
     struct options *oo, const char *name, const char *value, char **cause)      struct options *oo, const char *name, const char *value, char **cause)
 {  {
         const char      **cp;          int     choice = -1;
         int               n, choice = -1;  
   
         if (value == NULL) {          if (value == NULL) {
                 choice = options_get_number(oo, name);                  choice = options_get_number(oo, name);
                 if (choice < 2)                  if (choice < 2)
                         choice = !choice;                          choice = !choice;
         } else {          } else {
                 n = 0;                  choice = options_find_choice(oe, value, cause);
                 for (cp = oe->choices; *cp != NULL; cp++) {                  if (choice < 0)
                         if (strcmp(*cp, value) == 0)  
                                 choice = n;  
                         n++;  
                 }  
                 if (choice == -1) {  
                         xasprintf(cause, "unknown value: %s", value);  
                         return (-1);                          return (-1);
                 }  
         }          }
         options_set_number(oo, name, choice);          options_set_number(oo, name, choice);
         return (0);          return (0);

Legend:
Removed from v.1.64  
changed lines
  Added in v.1.65