aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorYonggang Luo <luoyonggang@gmail.com>2020-10-13 07:43:45 +0800
committerGerd Hoffmann <kraxel@redhat.com>2020-10-14 06:05:56 +0200
commit80d3ab61ad1d60e02717b8fa5fec86d8d0d9520f (patch)
tree314f04bbd7bdbb09a2e8124cbbc8340c89809b40 /ui
parentc7146542b18a07672cf1d322b4c7500786b56275 (diff)
curses: Fixes compiler error that complain don't have langinfo.h on msys2/mingw
msys2/mingw lacks the POSIX-required langinfo.h. gcc test.c -DNCURSES_WIDECHAR -I/mingw64/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv test.c:4:10: fatal error: langinfo.h: No such file or directory 4 | #include <langinfo.h> | ^~~~~~~~~~~~ compilation terminated. So we using g_get_codeset instead of nl_langinfo(CODESET) Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20201012234348.1427-3-luoyonggang@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/curses.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ui/curses.c b/ui/curses.c
index a59b23a9cf..12bc682cf9 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -30,7 +30,6 @@
#endif
#include <locale.h>
#include <wchar.h>
-#include <langinfo.h>
#include <iconv.h>
#include "qapi/error.h"
@@ -526,6 +525,7 @@ static void font_setup(void)
iconv_t nativecharset_to_ucs2;
iconv_t font_conv;
int i;
+ g_autofree gchar *local_codeset = g_get_codeset();
/*
* Control characters are normally non-printable, but VGA does have
@@ -566,14 +566,14 @@ static void font_setup(void)
0x25bc
};
- ucs2_to_nativecharset = iconv_open(nl_langinfo(CODESET), "UCS-2");
+ ucs2_to_nativecharset = iconv_open(local_codeset, "UCS-2");
if (ucs2_to_nativecharset == (iconv_t) -1) {
fprintf(stderr, "Could not convert font glyphs from UCS-2: '%s'\n",
strerror(errno));
exit(1);
}
- nativecharset_to_ucs2 = iconv_open("UCS-2", nl_langinfo(CODESET));
+ nativecharset_to_ucs2 = iconv_open("UCS-2", local_codeset);
if (nativecharset_to_ucs2 == (iconv_t) -1) {
iconv_close(ucs2_to_nativecharset);
fprintf(stderr, "Could not convert font glyphs to UCS-2: '%s'\n",
@@ -581,7 +581,7 @@ static void font_setup(void)
exit(1);
}
- font_conv = iconv_open(nl_langinfo(CODESET), font_charset);
+ font_conv = iconv_open(local_codeset, font_charset);
if (font_conv == (iconv_t) -1) {
iconv_close(ucs2_to_nativecharset);
iconv_close(nativecharset_to_ucs2);
@@ -602,7 +602,7 @@ static void font_setup(void)
/* DEL */
convert_ucs(0x7F, 0x2302, ucs2_to_nativecharset);
- if (strcmp(nl_langinfo(CODESET), "UTF-8")) {
+ if (strcmp(local_codeset, "UTF-8")) {
/* Non-Unicode capable, use termcap equivalents for those available */
for (i = 0; i <= 0xFF; i++) {
wchar_t wch[CCHARW_MAX];