diff options
author | erw7 <erw7.github@gmail.com> | 2019-05-01 06:10:42 +0900 |
---|---|---|
committer | erw7 <erw7.github@gmail.com> | 2019-06-09 13:27:54 +0900 |
commit | 9609f327daee70fbb6752bde41a1accc5e38a65b (patch) | |
tree | 1386f903b40c861b34c0a361b1cfa7fc5af86bbf /src/nvim/vim.h | |
parent | 0b4c53fc23581abb14b6d4c567dc08720f509020 (diff) | |
download | rneovim-9609f327daee70fbb6752bde41a1accc5e38a65b.tar.gz rneovim-9609f327daee70fbb6752bde41a1accc5e38a65b.tar.bz2 rneovim-9609f327daee70fbb6752bde41a1accc5e38a65b.zip |
Fix garbled problem with msg_puts_printf on Windows
Diffstat (limited to 'src/nvim/vim.h')
-rw-r--r-- | src/nvim/vim.h | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 3e0a5907be..d74427ef26 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -35,6 +35,10 @@ enum { NUMBUFLEN = 65 }; #include "nvim/gettext.h" +#ifdef WIN32 +# include "nvim/mbyte.h" // for utf8_to_utf16 +#endif + // special attribute addition: Put message in history #define MSG_HIST 0x1000 @@ -287,9 +291,34 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() // functions of these names. The declarations would break if the defines had // been seen at that stage. But it must be before globals.h, where error_ga // is declared. -#define mch_errmsg(str) fprintf(stderr, "%s", (str)) +#ifdef WIN32 +# define mch_errmsg(str) \ + do { \ + wchar_t *utf16str; \ + int conversion_result = utf8_to_utf16((str), &utf16str); \ + if (conversion_result != 0) { \ + EMSG2("utf8_to_utf16 failed: %d", conversion_result); \ + } else { \ + fwprintf(stderr, L"%ls", utf16str); \ + xfree(utf16str); \ + } \ + } while (0) +# define mch_msg(str) \ + do { \ + wchar_t *utf16str; \ + int conversion_result = utf8_to_utf16((str), &utf16str); \ + if (conversion_result != 0) { \ + EMSG2("utf8_to_utf16 failed: %d", conversion_result); \ + } else { \ + wprintf(L"%ls", utf16str); \ + xfree(utf16str); \ + } \ + } while (0) +#else +# define mch_errmsg(str) fprintf(stderr, "%s", (str)) +# define mch_msg(str) printf("%s", (str)) +#endif #define display_errors() fflush(stderr) -#define mch_msg(str) printf("%s", (str)) #include "nvim/globals.h" // global variables and messages #include "nvim/buffer_defs.h" // buffer and windows |