diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2016-05-27 22:57:28 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2016-05-27 22:57:28 +0000 |
commit | c4101f3d7c2cab7b67226a9a6ba1c0b14b25c671 (patch) | |
tree | 67b0c2e1d707bd31d2fc9cc31017c92a0f472947 | |
parent | cc66e8cdb7df138cc4f9b475606f8dc2e2fb4580 (diff) |
Most of the utf8_data is fixed so simplify utf8_set to use a memcpy.
-rw-r--r-- | usr.bin/tmux/utf8.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/usr.bin/tmux/utf8.c b/usr.bin/tmux/utf8.c index 77656bc38ec..cf7c85419ba 100644 --- a/usr.bin/tmux/utf8.c +++ b/usr.bin/tmux/utf8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utf8.c,v 1.32 2016/04/29 09:11:19 nicm Exp $ */ +/* $OpenBSD: utf8.c,v 1.33 2016/05/27 22:57:27 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -32,16 +32,10 @@ static int utf8_width(wchar_t); void utf8_set(struct utf8_data *ud, u_char ch) { - u_int i; + static const struct utf8_data empty = { { 0 }, 1, 1, 1 }; + memcpy(ud, &empty, sizeof *ud); *ud->data = ch; - ud->have = 1; - ud->size = 1; - - ud->width = 1; - - for (i = ud->size; i < sizeof ud->data; i++) - ud->data[i] = '\0'; } /* Copy UTF-8 character. */ |