=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/options.c,v retrieving revision 1.26 retrieving revision 1.27 diff -c -r1.26 -r1.27 *** src/usr.bin/tmux/options.c 2017/01/15 20:48:41 1.26 --- src/usr.bin/tmux/options.c 2017/01/16 14:49:14 1.27 *************** *** 1,4 **** ! /* $OpenBSD: options.c,v 1.26 2017/01/15 20:48:41 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: options.c,v 1.27 2017/01/16 14:49:14 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott *************** *** 30,36 **** * a red-black tree. */ ! struct option { struct options *owner; const char *name; --- 30,36 ---- * a red-black tree. */ ! struct options_entry { struct options *owner; const char *name; *************** *** 46,60 **** }; }; ! RB_ENTRY(option) entry; }; struct options { ! RB_HEAD(options_tree, option) tree; struct options *parent; }; ! static struct option *options_add(struct options *, const char *); #define OPTIONS_ARRAY_LIMIT 1000 --- 46,60 ---- }; }; ! RB_ENTRY(options_entry) entry; }; struct options { ! RB_HEAD(options_tree, options_entry) tree; struct options *parent; }; ! static struct options_entry *options_add(struct options *, const char *); #define OPTIONS_ARRAY_LIMIT 1000 *************** *** 76,86 **** ((o)->tableentry != NULL && \ (o)->tableentry->type == OPTIONS_TABLE_ARRAY) ! static int options_cmp(struct option *, struct option *); ! RB_GENERATE_STATIC(options_tree, option, entry, options_cmp); static int ! options_cmp(struct option *lhs, struct option *rhs) { return (strcmp(lhs->name, rhs->name)); } --- 76,86 ---- ((o)->tableentry != NULL && \ (o)->tableentry->type == OPTIONS_TABLE_ARRAY) ! static int options_cmp(struct options_entry *, struct options_entry *); ! RB_GENERATE_STATIC(options_tree, options_entry, entry, options_cmp); static int ! options_cmp(struct options_entry *lhs, struct options_entry *rhs) { return (strcmp(lhs->name, rhs->name)); } *************** *** 88,94 **** static const struct options_table_entry * options_parent_table_entry(struct options *oo, const char *s) { ! struct option *o; if (oo->parent == NULL) fatalx("no parent options for %s", s); --- 88,94 ---- static const struct options_table_entry * options_parent_table_entry(struct options *oo, const char *s) { ! struct options_entry *o; if (oo->parent == NULL) fatalx("no parent options for %s", s); *************** *** 112,149 **** void options_free(struct options *oo) { ! struct option *o, *tmp; RB_FOREACH_SAFE (o, options_tree, &oo->tree, tmp) options_remove(o); free(oo); } ! struct option * options_first(struct options *oo) { return (RB_MIN(options_tree, &oo->tree)); } ! struct option * ! options_next(struct option *o) { return (RB_NEXT(options_tree, &oo->tree, o)); } ! struct option * options_get_only(struct options *oo, const char *name) { ! struct option o; o.name = name; return (RB_FIND(options_tree, &oo->tree, &o)); } ! struct option * options_get(struct options *oo, const char *name) { ! struct option *o; o = options_get_only(oo, name); while (o == NULL) { --- 112,149 ---- void options_free(struct options *oo) { ! struct options_entry *o, *tmp; RB_FOREACH_SAFE (o, options_tree, &oo->tree, tmp) options_remove(o); free(oo); } ! struct options_entry * options_first(struct options *oo) { return (RB_MIN(options_tree, &oo->tree)); } ! struct options_entry * ! options_next(struct options_entry *o) { return (RB_NEXT(options_tree, &oo->tree, o)); } ! struct options_entry * options_get_only(struct options *oo, const char *name) { ! struct options_entry o; o.name = name; return (RB_FIND(options_tree, &oo->tree, &o)); } ! struct options_entry * options_get(struct options *oo, const char *name) { ! struct options_entry *o; o = options_get_only(oo, name); while (o == NULL) { *************** *** 155,164 **** return (o); } ! struct option * options_empty(struct options *oo, const struct options_table_entry *oe) { ! struct option *o; o = options_add(oo, oe->name); o->tableentry = oe; --- 155,164 ---- return (o); } ! struct options_entry * options_empty(struct options *oo, const struct options_table_entry *oe) { ! struct options_entry *o; o = options_add(oo, oe->name); o->tableentry = oe; *************** *** 166,177 **** return (o); } ! struct option * options_default(struct options *oo, const struct options_table_entry *oe) { ! struct option *o; ! char *cp, *copy, *next; ! u_int idx = 0; o = options_empty(oo, oe); --- 166,177 ---- return (o); } ! struct options_entry * options_default(struct options *oo, const struct options_table_entry *oe) { ! struct options_entry *o; ! char *cp, *copy, *next; ! u_int idx = 0; o = options_empty(oo, oe); *************** *** 195,204 **** return (o); } ! static struct option * options_add(struct options *oo, const char *name) { ! struct option *o; o = options_get_only(oo, name); if (o != NULL) --- 195,204 ---- return (o); } ! static struct options_entry * options_add(struct options *oo, const char *name) { ! struct options_entry *o; o = options_get_only(oo, name); if (o != NULL) *************** *** 213,219 **** } void ! options_remove(struct option *o) { struct options *oo = o->owner; u_int i; --- 213,219 ---- } void ! options_remove(struct options_entry *o) { struct options *oo = o->owner; u_int i; *************** *** 231,249 **** } const char * ! options_name(struct option *o) { return (o->name); } const struct options_table_entry * ! options_table_entry(struct option *o) { return (o->tableentry); } const char * ! options_array_get(struct option *o, u_int idx) { if (!OPTIONS_IS_ARRAY(o)) return (NULL); --- 231,249 ---- } const char * ! options_name(struct options_entry *o) { return (o->name); } const struct options_table_entry * ! options_table_entry(struct options_entry *o) { return (o->tableentry); } const char * ! options_array_get(struct options_entry *o, u_int idx) { if (!OPTIONS_IS_ARRAY(o)) return (NULL); *************** *** 253,259 **** } int ! options_array_set(struct option *o, u_int idx, const char *value) { u_int i; --- 253,259 ---- } int ! options_array_set(struct options_entry *o, u_int idx, const char *value) { u_int i; *************** *** 278,284 **** } int ! options_array_size(struct option *o, u_int *size) { if (!OPTIONS_IS_ARRAY(o)) return (-1); --- 278,284 ---- } int ! options_array_size(struct options_entry *o, u_int *size) { if (!OPTIONS_IS_ARRAY(o)) return (-1); *************** *** 288,294 **** } int ! options_isstring(struct option *o) { if (o->tableentry == NULL) return (1); --- 288,294 ---- } int ! options_isstring(struct options_entry *o) { if (o->tableentry == NULL) return (1); *************** *** 296,302 **** } const char * ! options_tostring(struct option *o, int idx) { static char s[1024]; const char *tmp; --- 296,302 ---- } const char * ! options_tostring(struct options_entry *o, int idx) { static char s[1024]; const char *tmp; *************** *** 370,380 **** return (copy); } ! struct option * options_parse_get(struct options *oo, const char *s, int *idx, int only) { ! struct option *o; ! char *name; name = options_parse(s, idx); if (name == NULL) --- 370,380 ---- return (copy); } ! struct options_entry * options_parse_get(struct options *oo, const char *s, int *idx, int only) { ! struct options_entry *o; ! char *name; name = options_parse(s, idx); if (name == NULL) *************** *** 426,437 **** return (xstrdup(found->name)); } ! struct option * options_match_get(struct options *oo, const char *s, int *idx, int only, int* ambiguous) { ! char *name; ! struct option *o; name = options_match(s, idx, ambiguous); if (name == NULL) --- 426,437 ---- return (xstrdup(found->name)); } ! struct options_entry * options_match_get(struct options *oo, const char *s, int *idx, int only, int* ambiguous) { ! char *name; ! struct options_entry *o; name = options_match(s, idx, ambiguous); if (name == NULL) *************** *** 455,461 **** const char * options_get_string(struct options *oo, const char *name) { ! struct option *o; o = options_get(oo, name); if (o == NULL) --- 455,461 ---- const char * options_get_string(struct options *oo, const char *name) { ! struct options_entry *o; o = options_get(oo, name); if (o == NULL) *************** *** 468,474 **** long long options_get_number(struct options *oo, const char *name) { ! struct option *o; o = options_get(oo, name); if (o == NULL) --- 468,474 ---- long long options_get_number(struct options *oo, const char *name) { ! struct options_entry *o; o = options_get(oo, name); if (o == NULL) *************** *** 481,487 **** const struct grid_cell * options_get_style(struct options *oo, const char *name) { ! struct option *o; o = options_get(oo, name); if (o == NULL) --- 481,487 ---- const struct grid_cell * options_get_style(struct options *oo, const char *name) { ! struct options_entry *o; o = options_get(oo, name); if (o == NULL) *************** *** 491,503 **** return (&o->style); } ! struct option * options_set_string(struct options *oo, const char *name, int append, const char *fmt, ...) { ! struct option *o; ! va_list ap; ! char *s, *value; va_start(ap, fmt); xvasprintf(&s, fmt, ap); --- 491,503 ---- return (&o->style); } ! struct options_entry * options_set_string(struct options *oo, const char *name, int append, const char *fmt, ...) { ! struct options_entry *o; ! va_list ap; ! char *s, *value; va_start(ap, fmt); xvasprintf(&s, fmt, ap); *************** *** 524,533 **** return (o); } ! struct option * options_set_number(struct options *oo, const char *name, long long value) { ! struct option *o; if (*name == '@') fatalx("user option %s must be a string", name); --- 524,533 ---- return (o); } ! struct options_entry * options_set_number(struct options *oo, const char *name, long long value) { ! struct options_entry *o; if (*name == '@') fatalx("user option %s must be a string", name); *************** *** 545,555 **** return (o); } ! struct option * options_set_style(struct options *oo, const char *name, int append, const char *value) { ! struct option *o; struct grid_cell gc; if (*name == '@') --- 545,555 ---- return (o); } ! struct options_entry * options_set_style(struct options *oo, const char *name, int append, const char *value) { ! struct options_entry *o; struct grid_cell gc; if (*name == '@') *************** *** 619,628 **** } void ! options_style_update_new(struct options *oo, struct option *o) { ! const char *newname = o->tableentry->style; ! struct option *new; if (newname == NULL) return; --- 619,628 ---- } void ! options_style_update_new(struct options *oo, struct options_entry *o) { ! const char *newname = o->tableentry->style; ! struct options_entry *new; if (newname == NULL) return; *************** *** 639,645 **** } void ! options_style_update_old(struct options *oo, struct option *o) { char newname[128]; int size; --- 639,645 ---- } void ! options_style_update_old(struct options *oo, struct options_entry *o) { char newname[128]; int size;