Skip to contentSkip to conversation

Fixes curses on msys2/mingw

PATCH Superseded Yonggang Luo 2 participants 7 messages Oct 2, 2020 – Oct 5, 2020

v7 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v7 cover Fixes curses on msys2/mingw

V6-V7
Update the configure script for
* curses: Fixes compiler error that complain don't have langinfo.h on msys2/m= ingw

V5-V6
Dropping configure: Fixes ncursesw detection under msys2/mingw by convert the= m to meson first.
That need the meson 0.56 upstream to fixes the curses detection. Add
* configure: fixes indent of $meson setup

Yonggang Luo (4):
configure: fixes indent of $meson setup
curses: Fixes compiler error that complain don't have langinfo.h on
msys2/mingw
curses: Fixes curses compiling errors.
win32: Simplify gmtime_r detection not depends on if _POSIX_C_SOURCE
are defined on msys2/mingw

 configure                 | 47 +++++----------------------------------
 include/sysemu/os-win32.h |  4 ++--
 ui/curses.c               | 14 ++++++------
 util/oslib-win32.c        |  4 ++--
 4 files changed, 16 insertions(+), 53 deletions(-)

--=20
2.28.0.windows.1

#1 lore raw

PATCH v7 2/4 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)

---
 configure   |  5 +----
 ui/curses.c | 10 +++++-----
 2 files changed, 6 insertions(+), 9 deletions(-)
configure +1 -4
index 8f7bdbfdd3..fa53bd5c43 100755
@@ -3672,17 +3672,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=:
ui/curses.c +5 -5
index a59b23a9cf..12bc682cf9 100644
@@ -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];
Signature · 1 line
2.28.0.windows.1
#2 lore raw

Re: [PATCH v7 2/4] curses: Fixes compiler error that complain don't have langinfo.h on msys2/mingw

Forget to cc you

Quoted 4 lines · Yonggang Luo

msys2/mingw lacks the POSIX-required langinfo.h.

gcc test.c -DNCURSES_WIDECHAR -I/mingw64/include/ncursesw -pipe

-lncursesw -lgnurx -ltre -lintl -liconv

Quoted 58 lines

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)

---
 configure   |  5 +----
 ui/curses.c | 10 +++++-----
 2 files changed, 6 insertions(+), 9 deletions(-)
configure +1 -4
index 8f7bdbfdd3..fa53bd5c43 100755
@@ -3672,17 +3672,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=:
ui/curses.c +1 -1
index a59b23a9cf..12bc682cf9 100644
@@ -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

ui/curses.c static void font_setup(void) · line 571

Quoted 7 lines
ui/curses.c +1 -1
@@ -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",

Quoted 19 lines
ui/curses.c +2 -2
                         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);

ui/curses.c static void font_setup(void) · line 606

Quoted 6 lines
ui/curses.c +1 -1
@@ -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 */

Quoted 5 lines
ui/curses.c +0 -1
         for (i = 0; i <= 0xFF; i++) {
             wchar_t wch[CCHARW_MAX];
--

2.28.0.windows.1

--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo

Reviewed-by on v7 2/4
#3 lore raw

Re: [PATCH v7 2/4] curses: Fixes compiler error that complain don't have langinfo.h on msys2/mingw

In reply to Yonggang Luo
Quoted 8 lines · Yonggang Luo

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.

Quoted 8 lines

So we using g_get_codeset instead of nl_langinfo(CODESET)

---
 configure   |  5 +----
 ui/curses.c | 10 +++++-----
 2 files changed, 6 insertions(+), 9 deletions(-)

Regards,
Daniel

Signature · 3 lines
|: 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 :|
#4 lore raw
In reply to Yonggang Luo

Only one of the 4 patches in this series appears to have been sent.

Quoted 20 lines · Yonggang Luo

V6-V7
Update the configure script for
* curses: Fixes compiler error that complain don't have langinfo.h on msys2/m= ingw

V5-V6
Dropping configure: Fixes ncursesw detection under msys2/mingw by convert the= m to meson first.
That need the meson 0.56 upstream to fixes the curses detection. Add
* configure: fixes indent of $meson setup

Yonggang Luo (4):
configure: fixes indent of $meson setup
curses: Fixes compiler error that complain don't have langinfo.h on
msys2/mingw
curses: Fixes curses compiling errors.
win32: Simplify gmtime_r detection not depends on if _POSIX_C_SOURCE
are defined on msys2/mingw

Quoted 10 lines
 configure                 | 47 +++++----------------------------------
 include/sysemu/os-win32.h |  4 ++--
 ui/curses.c               | 14 ++++++------
 util/oslib-win32.c        |  4 ++--
 4 files changed, 16 insertions(+), 53 deletions(-)

--=20
2.28.0.windows.1

Regards,
Daniel

Signature · 3 lines
|: 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 :|
#5 lore raw
Quoted 2 lines · Daniel P. Berrangé

Only one of the 4 patches in this series appears to have been sent.

All other are revied and preserve the same, I prefer not disturb by re sending same patches
as other contributor suggested

Quoted 5 lines · Yonggang Luo
Quoted 3 lines

V6-V7
Update the configure script for
* curses: Fixes compiler error that complain don't have langinfo.h on

msys2/m=

Quoted 4 lines
Quoted 4 lines

ingw

V5-V6
Dropping configure: Fixes ncursesw detection under msys2/mingw by

convert the=

Quoted 24 lines
Quoted 13 lines

m to meson first.
That need the meson 0.56 upstream to fixes the curses detection. Add
* configure: fixes indent of $meson setup

Yonggang Luo (4):
configure: fixes indent of $meson setup
curses: Fixes compiler error that complain don't have langinfo.h on
msys2/mingw
curses: Fixes curses compiling errors.
win32: Simplify gmtime_r detection not depends on if _POSIX_C_SOURCE
are defined on msys2/mingw

Quoted 10 lines
 configure                 | 47 +++++----------------------------------
 include/sysemu/os-win32.h |  4 ++--
 ui/curses.c               | 14 ++++++------
 util/oslib-win32.c        |  4 ++--
 4 files changed, 16 insertions(+), 53 deletions(-)

--=20
2.28.0.windows.1

Quoted 4 lines

Regards,
Daniel
--
|: https://berrange.com -o-

https://www.flickr.com/photos/dberrange :|

Quoted 1 line

|: https://libvirt.org -o-

https://fstop138.berrange.com :|

Quoted 1 line

|: https://entangle-photo.org -o-

https://www.instagram.com/dberrange :|

Quoted 1 line

--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo

#6 lore raw
Quoted 6 lines · 罗勇刚(Yonggang Luo)
Quoted 2 lines · Daniel P. Berrangé

Only one of the 4 patches in this series appears to have been sent.

All other are revied and preserve the same, I prefer not disturb by re sending same patches as other contributor suggested

I don't know where that is suggested, but I think that is very unhelpful.

It breaks any kind of automation around fetching patch series.

I don't want to have to fetch some patches from version 6 and some patches from version 7 to test the combined work.

Every patch series posted should be complete, so contributors arent left wondering which are the correct versions for each patch.

Quoted 47 lines
Quoted 5 lines · Yonggang Luo
Quoted 3 lines

V6-V7
Update the configure script for
* curses: Fixes compiler error that complain don't have langinfo.h on

msys2/m=

Quoted 4 lines
Quoted 4 lines

ingw

V5-V6
Dropping configure: Fixes ncursesw detection under msys2/mingw by

convert the=

Quoted 24 lines
Quoted 13 lines

m to meson first.
That need the meson 0.56 upstream to fixes the curses detection. Add
* configure: fixes indent of $meson setup

Yonggang Luo (4):
configure: fixes indent of $meson setup
curses: Fixes compiler error that complain don't have langinfo.h on
msys2/mingw
curses: Fixes curses compiling errors.
win32: Simplify gmtime_r detection not depends on if _POSIX_C_SOURCE
are defined on msys2/mingw

Quoted 10 lines
 configure                 | 47 +++++----------------------------------
 include/sysemu/os-win32.h |  4 ++--
 ui/curses.c               | 14 ++++++------
 util/oslib-win32.c        |  4 ++--
 4 files changed, 16 insertions(+), 53 deletions(-)

--=20
2.28.0.windows.1

Quoted 4 lines

Regards,
Daniel
--
|: https://berrange.com -o-

https://www.flickr.com/photos/dberrange :|

Quoted 1 line

|: https://libvirt.org -o-

https://fstop138.berrange.com :|

Quoted 1 line

|: https://entangle-photo.org -o-

https://www.instagram.com/dberrange :|

Quoted 1 line
Quoted 7 lines

--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo

Regards,
Daniel

Signature · 3 lines
|: 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 :|