diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-08-13 05:47:58 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-08-15 00:28:41 +0200 |
commit | 8727f7a6a4ef10ce7536fbc003ef13b768f1aa91 (patch) | |
tree | 8b577b3e7b8e997341bbad3747dd19f7015da216 /src/nvim/message.c | |
parent | fc60d92795d20f3f3c498b97aae5e46a71cafa8d (diff) | |
download | rneovim-8727f7a6a4ef10ce7536fbc003ef13b768f1aa91.tar.gz rneovim-8727f7a6a4ef10ce7536fbc003ef13b768f1aa91.tar.bz2 rneovim-8727f7a6a4ef10ce7536fbc003ef13b768f1aa91.zip |
utf8_to_utf16: align with libuv
- take a size parameter
- always NUL-terminate the result
- return libuv error code
- handle error in caller only (avoid redundant messages)
https://github.com/libuv/libuv/commit/53995a3825d23eacd01e2bcfa35642c4a188d32b
https://github.com/libuv/libuv/commit/4c945f49365ab4d6e1b07bf0ef2893455dc04622
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index b043df17d3..6e935022ca 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2559,10 +2559,11 @@ static int do_more_prompt(int typed_char) #if defined(WIN32) void mch_errmsg(char *str) { + assert(str != NULL); wchar_t *utf16str; - int conversion_result = utf8_to_utf16((str), &utf16str); - if (conversion_result != 0) { - EMSG2("utf8_to_utf16 failed: %d", conversion_result); + int r = utf8_to_utf16(str, -1, &utf16str); + if (r != 0) { + fprintf(stderr, "utf8_to_utf16 failed: %d", r); } else { fwprintf(stderr, L"%ls", utf16str); xfree(utf16str); @@ -2572,10 +2573,11 @@ void mch_errmsg(char *str) // Give a message. To be used when the UI is not initialized yet. void mch_msg(char *str) { + assert(str != NULL); wchar_t *utf16str; - int conversion_result = utf8_to_utf16((str), &utf16str); - if (conversion_result != 0) { - EMSG2("utf8_to_utf16 failed: %d", conversion_result); + int r = utf8_to_utf16(str, -1, &utf16str); + if (r != 0) { + fprintf(stderr, "utf8_to_utf16 failed: %d", r); } else { wprintf(L"%ls", utf16str); xfree(utf16str); |