Message ID | 20200909094617.1582-4-luoyonggang@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | W32, W64 msys2/mingw patches | expand |
You can queue this instead On Wed, Sep 9, 2020 at 5:46 PM Yonggang Luo <luoyonggang@gmail.com> 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 <luoyonggang@gmail.com> > Reviewed-by: Gerd Hoffmann <kraxel@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" > 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 > -- 此致 礼 罗勇刚 Yours sincerely, Yonggang Luo <div dir="ltr">You can queue this instead<br><br>On Wed, Sep 9, 2020 at 5:46 PM Yonggang Luo <<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>> wrote:<br>><br>> The mingw pkg-config are showing following absolute path and contains : as the separator,<br>> so we must handling : properly.<br>><br>> -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC:/CI-Tools/msys64/mingw64/include/ncursesw:-I/usr/include/ncursesw:<br>> -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -pipe -lncursesw -lgnurx -ltre -lintl -liconv<br>> -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lncursesw<br>> -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lcursesw<br>> -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv<br>> -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lncursesw<br>> -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lcursesw<br>> -DNCURSES_WIDECHAR -I/usr/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv<br>> -DNCURSES_WIDECHAR -I/usr/include/ncursesw -lncursesw<br>> -DNCURSES_WIDECHAR -I/usr/include/ncursesw -lcursesw<br>><br>> msys2/mingw lacks the POSIX-required langinfo.h.<br>><br>> gcc test.c -DNCURSES_WIDECHAR -I/mingw64/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv<br>> test.c:4:10: fatal error: langinfo.h: No such file or directory<br>> 4 | #include <langinfo.h><br>> | ^~~~~~~~~~~~<br>> compilation terminated.<br>><br>> So we using g_get_codeset instead of nl_langinfo(CODESET)<br>><br>> Signed-off-by: Yonggang Luo <<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>><br>> Reviewed-by: Gerd Hoffmann <<a href="mailto:kraxel@redhat.com">kraxel@redhat.com</a>><br>> ---<br>> configure | 9 +++------<br>> ui/curses.c | 10 +++++-----<br>> 2 files changed, 8 insertions(+), 11 deletions(-)<br>><br>> diff --git a/configure b/configure<br>> index f4f8bc3756..2e6d54e15b 100755<br>> --- a/configure<br>> +++ b/configure<br>> @@ -3653,8 +3653,8 @@ if test "$iconv" = "no" ; then<br>> fi<br>> if test "$curses" != "no" ; then<br>> if test "$mingw32" = "yes" ; then<br>> - curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"<br>> - curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"<br>> + curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/${MSYSTEM,,}/include/ncursesw:"<br>> + curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw"<br>> else<br>> curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"<br>> curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"<br>> @@ -3664,17 +3664,14 @@ if test "$curses" != "no" ; then<br>> #include <locale.h><br>> #include <curses.h><br>> #include <wchar.h><br>> -#include <langinfo.h><br>> int main(void) {<br>> - const char *codeset;<br>> wchar_t wch = L'w';<br>> setlocale(LC_ALL, "");<br>> resize_term(0, 0);<br>> addwstr(L"wide chars\n");<br>> addnwstr(&wch, 1);<br>> add_wch(WACS_DEGREE);<br>> - codeset = nl_langinfo(CODESET);<br>> - return codeset != 0;<br>> + return 0;<br>> }<br>> EOF<br>> IFS=:<br>> diff --git a/ui/curses.c b/ui/curses.c<br>> index a59b23a9cf..12bc682cf9 100644<br>> --- a/ui/curses.c<br>> +++ b/ui/curses.c<br>> @@ -30,7 +30,6 @@<br>> #endif<br>> #include <locale.h><br>> #include <wchar.h><br>> -#include <langinfo.h><br>> #include <iconv.h><br>><br>> #include "qapi/error.h"<br>> @@ -526,6 +525,7 @@ static void font_setup(void)<br>> iconv_t nativecharset_to_ucs2;<br>> iconv_t font_conv;<br>> int i;<br>> + g_autofree gchar *local_codeset = g_get_codeset();<br>><br>> /*<br>> * Control characters are normally non-printable, but VGA does have<br>> @@ -566,14 +566,14 @@ static void font_setup(void)<br>> 0x25bc<br>> };<br>><br>> - ucs2_to_nativecharset = iconv_open(nl_langinfo(CODESET), "UCS-2");<br>> + ucs2_to_nativecharset = iconv_open(local_codeset, "UCS-2");<br>> if (ucs2_to_nativecharset == (iconv_t) -1) {<br>> fprintf(stderr, "Could not convert font glyphs from UCS-2: '%s'\n",<br>> strerror(errno));<br>> exit(1);<br>> }<br>><br>> - nativecharset_to_ucs2 = iconv_open("UCS-2", nl_langinfo(CODESET));<br>> + nativecharset_to_ucs2 = iconv_open("UCS-2", local_codeset);<br>> if (nativecharset_to_ucs2 == (iconv_t) -1) {<br>> iconv_close(ucs2_to_nativecharset);<br>> fprintf(stderr, "Could not convert font glyphs to UCS-2: '%s'\n",<br>> @@ -581,7 +581,7 @@ static void font_setup(void)<br>> exit(1);<br>> }<br>><br>> - font_conv = iconv_open(nl_langinfo(CODESET), font_charset);<br>> + font_conv = iconv_open(local_codeset, font_charset);<br>> if (font_conv == (iconv_t) -1) {<br>> iconv_close(ucs2_to_nativecharset);<br>> iconv_close(nativecharset_to_ucs2);<br>> @@ -602,7 +602,7 @@ static void font_setup(void)<br>> /* DEL */<br>> convert_ucs(0x7F, 0x2302, ucs2_to_nativecharset);<br>><br>> - if (strcmp(nl_langinfo(CODESET), "UTF-8")) {<br>> + if (strcmp(local_codeset, "UTF-8")) {<br>> /* Non-Unicode capable, use termcap equivalents for those available */<br>> for (i = 0; i <= 0xFF; i++) {<br>> wchar_t wch[CCHARW_MAX];<br>> --<br>> 2.28.0.windows.1<br>><br><br><br>--<br> 此致<br>礼<br>罗勇刚<br>Yours<br> sincerely,<br>Yonggang Luo</div>
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" 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];