On Wed, Sep 9, 2020 at 8:51 PM Daniel P. Berrangé <berra...@redhat.com> wrote:
> On Wed, Sep 09, 2020 at 05:45:59PM +0800, Yonggang Luo wrote: > > The mingw pkg-config are showing following absolute path and contains : > as the separator, > > so we must handling : properly. > > > > -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L > -IC:/CI-Tools/msys64/mingw64/include/ncursesw:-I/usr/include/ncursesw: > > -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC > -pipe -lncursesw -lgnurx -ltre -lintl -liconv > > -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC > -lncursesw > > -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC > -lcursesw > > -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -pipe > -lncursesw -lgnurx -ltre -lintl -liconv > > -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lncursesw > > -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lcursesw > > -DNCURSES_WIDECHAR -I/usr/include/ncursesw -pipe -lncursesw -lgnurx > -ltre -lintl -liconv > > -DNCURSES_WIDECHAR -I/usr/include/ncursesw -lncursesw > > -DNCURSES_WIDECHAR -I/usr/include/ncursesw -lcursesw > > > > 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 <luoyongg...@gmail.com> > > Reviewed-by: Gerd Hoffmann <kra...@redhat.com> > > --- > > configure | 9 +++------ > > ui/curses.c | 10 +++++----- > > 2 files changed, 8 insertions(+), 11 deletions(-) > > > > diff --git a/configure b/configure > > index f4f8bc3756..2e6d54e15b 100755 > > --- a/configure > > +++ b/configure > > @@ -3653,8 +3653,8 @@ if test "$iconv" = "no" ; then > > fi > > if test "$curses" != "no" ; then > > if test "$mingw32" = "yes" ; then > > - curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):" > > - curses_lib_list="$($pkg_config --libs ncurses > 2>/dev/null):-lpdcurses" > > + curses_inc_list="$($pkg_config --cflags ncursesw > 2>/dev/null):-I/${MSYSTEM,,}/include/ncursesw:" > > + curses_lib_list="$($pkg_config --libs ncursesw > 2>/dev/null):-lncursesw" > > The original code would try ncurses via pkg-config and if that failed, > would > falback to pdcurses. > > The new code tries ncursesw via pkg-config and then tries ncursesw again > via manually specified args, and doesn't try ncurses or pdcurses at all. > Gotcha, Indeed $pkg_config --cflags ncurses can find curses on mingw32, the problem is onw mingw32 the include path have :, so we can not use : as the path sepaerator, for cross-paltform reason, which is best for path separator? > > This fixes your build as you've installed ncursesw, but breaks anyone > who was using ncurses or pdcurses previously. At least on Fedora only > pdcurses is available for mingw, so I don't think we should be dropping > this. It looks like we just need to check all three of ncursesw, ncurses > and pdcurses. > > Copying Samuel who introduced this logic originally in > commit 8ddc5bf9e5de51c2a4842c01dd3a97f5591776fd > > > else > > curses_inc_list="$($pkg_config --cflags ncursesw > 2>/dev/null):-I/usr/include/ncursesw:" > > curses_lib_list="$($pkg_config --libs ncursesw > 2>/dev/null):-lncursesw:-lcursesw" > > @@ -3664,17 +3664,14 @@ if test "$curses" != "no" ; then > > #include <locale.h> > > #include <curses.h> > > #include <wchar.h> > > -#include <langinfo.h> > > int main(void) { > > - const char *codeset; > > wchar_t wch = L'w'; > > setlocale(LC_ALL, ""); > > resize_term(0, 0); > > addwstr(L"wide chars\n"); > > addnwstr(&wch, 1); > > add_wch(WACS_DEGREE); > > - codeset = nl_langinfo(CODESET); > > - return codeset != 0; > > + return 0; > > } > > EOF > > IFS=: > > 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]; > > -- > > 2.28.0.windows.1 > > > > > > Regards, > Daniel > -- > |: https://berrange.com -o- > https://www.flickr.com/photos/dberrange :| > |: https://libvirt.org -o- > https://fstop138.berrange.com :| > |: https://entangle-photo.org -o- > https://www.instagram.com/dberrange :| > > -- 此致 礼 罗勇刚 Yours sincerely, Yonggang Luo