mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 08:18:48 +00:00
Sync OpenBSD patchset 337:
Drop tiny union from option struct.
This commit is contained in:
parent
c28d4e41cf
commit
f2d249fdc7
18
options.c
18
options.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: options.c,v 1.6 2009-07-22 17:46:53 tcunha Exp $ */
|
/* $Id: options.c,v 1.7 2009-09-22 13:49:13 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -53,7 +53,7 @@ options_free(struct options *oo)
|
|||||||
SPLAY_REMOVE(options_tree, &oo->tree, o);
|
SPLAY_REMOVE(options_tree, &oo->tree, o);
|
||||||
xfree(o->name);
|
xfree(o->name);
|
||||||
if (o->type == OPTIONS_STRING)
|
if (o->type == OPTIONS_STRING)
|
||||||
xfree(o->value.string);
|
xfree(o->str);
|
||||||
xfree(o);
|
xfree(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ options_remove(struct options *oo, const char *name)
|
|||||||
SPLAY_REMOVE(options_tree, &oo->tree, o);
|
SPLAY_REMOVE(options_tree, &oo->tree, o);
|
||||||
xfree(o->name);
|
xfree(o->name);
|
||||||
if (o->type == OPTIONS_STRING)
|
if (o->type == OPTIONS_STRING)
|
||||||
xfree(o->value.string);
|
xfree(o->str);
|
||||||
xfree(o);
|
xfree(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,11 +109,11 @@ options_set_string(struct options *oo, const char *name, const char *fmt, ...)
|
|||||||
o->name = xstrdup(name);
|
o->name = xstrdup(name);
|
||||||
SPLAY_INSERT(options_tree, &oo->tree, o);
|
SPLAY_INSERT(options_tree, &oo->tree, o);
|
||||||
} else if (o->type == OPTIONS_STRING)
|
} else if (o->type == OPTIONS_STRING)
|
||||||
xfree(o->value.string);
|
xfree(o->str);
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
o->type = OPTIONS_STRING;
|
o->type = OPTIONS_STRING;
|
||||||
xvasprintf(&o->value.string, fmt, ap);
|
xvasprintf(&o->str, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ options_get_string(struct options *oo, const char *name)
|
|||||||
fatalx("missing option");
|
fatalx("missing option");
|
||||||
if (o->type != OPTIONS_STRING)
|
if (o->type != OPTIONS_STRING)
|
||||||
fatalx("option not a string");
|
fatalx("option not a string");
|
||||||
return (o->value.string);
|
return (o->str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -139,10 +139,10 @@ options_set_number(struct options *oo, const char *name, long long value)
|
|||||||
o->name = xstrdup(name);
|
o->name = xstrdup(name);
|
||||||
SPLAY_INSERT(options_tree, &oo->tree, o);
|
SPLAY_INSERT(options_tree, &oo->tree, o);
|
||||||
} else if (o->type == OPTIONS_STRING)
|
} else if (o->type == OPTIONS_STRING)
|
||||||
xfree(o->value.string);
|
xfree(o->str);
|
||||||
|
|
||||||
o->type = OPTIONS_NUMBER;
|
o->type = OPTIONS_NUMBER;
|
||||||
o->value.number = value;
|
o->num = value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,5 +155,5 @@ options_get_number(struct options *oo, const char *name)
|
|||||||
fatalx("missing option");
|
fatalx("missing option");
|
||||||
if (o->type != OPTIONS_NUMBER)
|
if (o->type != OPTIONS_NUMBER)
|
||||||
fatalx("option not a number");
|
fatalx("option not a number");
|
||||||
return (o->value.number);
|
return (o->num);
|
||||||
}
|
}
|
||||||
|
9
tmux.h
9
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.446 2009-09-22 13:45:06 tcunha Exp $ */
|
/* $Id: tmux.h,v 1.447 2009-09-22 13:49:13 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -543,10 +543,9 @@ struct options_entry {
|
|||||||
OPTIONS_STRING,
|
OPTIONS_STRING,
|
||||||
OPTIONS_NUMBER,
|
OPTIONS_NUMBER,
|
||||||
} type;
|
} type;
|
||||||
union {
|
|
||||||
char *string;
|
char *str;
|
||||||
long long number;
|
long long num;
|
||||||
} value;
|
|
||||||
|
|
||||||
SPLAY_ENTRY(options_entry) entry;
|
SPLAY_ENTRY(options_entry) entry;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user