summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2019-03-14 10:19:52 +0000
committernicm <nicm@openbsd.org>2019-03-14 10:19:52 +0000
commitfbc8812ee867a0540ef48b9e8618649d302a9602 (patch)
tree9a90183bf4d7098a44be9b3db13326299dd71fef
parentAdd a wrapper (struct style) around styles rather than using the (diff)
downloadwireguard-openbsd-fbc8812ee867a0540ef48b9e8618649d302a9602.tar.xz
wireguard-openbsd-fbc8812ee867a0540ef48b9e8618649d302a9602.zip
A little tidying in style_parse.
-rw-r--r--usr.bin/tmux/style.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/usr.bin/tmux/style.c b/usr.bin/tmux/style.c
index b28883fb50c..6c7b083c382 100644
--- a/usr.bin/tmux/style.c
+++ b/usr.bin/tmux/style.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: style.c,v 1.15 2019/03/14 09:53:52 nicm Exp $ */
+/* $OpenBSD: style.c,v 1.16 2019/03/14 10:19:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -39,23 +39,22 @@ static struct style style_default = {
int
style_parse(struct style *sy, const struct grid_cell *base, const char *in)
{
- struct grid_cell *gc = &sy->gc;
- struct grid_cell saved;
- const char delimiters[] = " ,";
- char tmp[32];
- int value, fg, bg, attr, flags;
- size_t end;
+ struct style saved;
+ const char delimiters[] = " ,";
+ char tmp[32];
+ int value, fg, bg, attr, flags;
+ size_t end;
if (*in == '\0')
return (0);
if (strchr(delimiters, in[strlen(in) - 1]) != NULL)
return (-1);
- memcpy(&saved, base, sizeof saved);
+ style_copy(&saved, sy);
- fg = gc->fg;
- bg = gc->bg;
- attr = gc->attr;
- flags = gc->flags;
+ fg = sy->gc.fg;
+ bg = sy->gc.bg;
+ attr = sy->gc.attr;
+ flags = sy->gc.flags;
do {
end = strcspn(in, delimiters);
@@ -99,15 +98,15 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in)
in += end + strspn(in + end, delimiters);
} while (*in != '\0');
- gc->fg = fg;
- gc->bg = bg;
- gc->attr = attr;
- gc->flags = flags;
+ sy->gc.fg = fg;
+ sy->gc.bg = bg;
+ sy->gc.attr = attr;
+ sy->gc.flags = flags;
return (0);
error:
- memcpy(gc, &saved, sizeof *gc);
+ style_copy(sy, &saved);
return (-1);
}