pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/emulators/qemu qemu: Switch curses.c patches to the on...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/0650577bb039
branches:  trunk
changeset: 332950:0650577bb039
user:      kamil <kamil%pkgsrc.org@localhost>
date:      Sat Apr 27 18:00:46 2019 +0000

description:
qemu: Switch curses.c patches to the ones pending upstream

 * fix compatibility with NetBSD curses(3)

https://patchwork.ozlabs.org/patch/1092056/

 * fix portability of iconv(3) usage

https://patchwork.ozlabs.org/patch/1092057/

Both work better than the existing one. Borders are printed now correctly.

Bump PKGREVISION

diffstat:

 emulators/qemu/Makefile                  |    4 +-
 emulators/qemu/distinfo                  |    4 +-
 emulators/qemu/patches/patch-ui_curses.c |  491 +++++++++++++++---------------
 3 files changed, 251 insertions(+), 248 deletions(-)

diffs (truncated from 563 to 300 lines):

diff -r 80445f695d5f -r 0650577bb039 emulators/qemu/Makefile
--- a/emulators/qemu/Makefile   Sat Apr 27 16:35:18 2019 +0000
+++ b/emulators/qemu/Makefile   Sat Apr 27 18:00:46 2019 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.206 2019/04/25 23:54:46 kamil Exp $
+# $NetBSD: Makefile,v 1.207 2019/04/27 18:00:46 kamil Exp $
 
 DISTNAME=      qemu-4.0.0
-PKGREVISION=   4
+PKGREVISION=   5
 CATEGORIES=    emulators
 MASTER_SITES=  https://download.qemu.org/
 EXTRACT_SUFX=  .tar.xz
diff -r 80445f695d5f -r 0650577bb039 emulators/qemu/distinfo
--- a/emulators/qemu/distinfo   Sat Apr 27 16:35:18 2019 +0000
+++ b/emulators/qemu/distinfo   Sat Apr 27 18:00:46 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.147 2019/04/25 23:54:46 kamil Exp $
+$NetBSD: distinfo,v 1.148 2019/04/27 18:00:46 kamil Exp $
 
 SHA1 (qemu-4.0.0.tar.xz) = 74cfb8f4724d9651fdd354560f2d291887b32cad
 RMD160 (qemu-4.0.0.tar.xz) = 58135f00c391823edce780d55a816f29dd73c34b
@@ -21,4 +21,4 @@
 SHA1 (patch-target_hppa_mem__helper.c) = 080d99b2a6dc7f5ab1df04ef6c316e5dcd133753
 SHA1 (patch-target_hppa_translate.c) = 8bdeaba3f19204ffd5465d33a44380bbcbfd7a57
 SHA1 (patch-target_i386_kvm-stub.c) = 4cd2b7a8d8d8a317829f982b5acff7fdf2479d9f
-SHA1 (patch-ui_curses.c) = 1809e6a35cc920dc42dbdef8ee8844d0108a8db7
+SHA1 (patch-ui_curses.c) = a8bd6ad93d53d6cfba3b6853aff5702fe40ae944
diff -r 80445f695d5f -r 0650577bb039 emulators/qemu/patches/patch-ui_curses.c
--- a/emulators/qemu/patches/patch-ui_curses.c  Sat Apr 27 16:35:18 2019 +0000
+++ b/emulators/qemu/patches/patch-ui_curses.c  Sat Apr 27 18:00:46 2019 +0000
@@ -1,284 +1,287 @@
-$NetBSD: patch-ui_curses.c,v 1.2 2019/04/25 23:54:46 kamil Exp $
+$NetBSD: patch-ui_curses.c,v 1.3 2019/04/27 18:00:46 kamil Exp $
+
+ * fix compatibility with NetBSD curses(3)
 
-* For NetBSD curses
-* Switch unportable iconv(3) UCS-2 <-> wchar_t conversions
-  to a portable algorithm with an intermediate step with
-  multibyte sequences
+https://patchwork.ozlabs.org/patch/1092056/
+
+ * fix portability of iconv(3) usage
+
+https://patchwork.ozlabs.org/patch/1092057/
 
 --- ui/curses.c.orig   2019-04-23 18:14:46.000000000 +0000
 +++ ui/curses.c
-@@ -46,6 +46,11 @@
- #define FONT_HEIGHT 16
- #define FONT_WIDTH 8
+@@ -66,20 +66,22 @@ static void curses_update(DisplayChangeL
+ {
+     console_ch_t *line;
+     cchar_t curses_line[width];
++    wchar_t wch[CCHARW_MAX];
++    attr_t attrs;
++    short colors;
++    int ret;
  
-+#if defined(__NetBSD__)
-+#define chars vals
-+#define attr attributes
-+#endif
-+
- enum maybe_keycode {
-     CURSES_KEYCODE,
-     CURSES_CHAR,
-@@ -400,6 +405,8 @@ static void curses_atexit(void)
+     line = screen + y * width;
+     for (h += y; y < h; y ++, line += width) {
+         for (x = 0; x < width; x++) {
+             chtype ch = line[x] & 0xff;
+             chtype at = line[x] & ~0xff;
+-            if (vga_to_curses[ch].chars[0]) {
+-                curses_line[x] = vga_to_curses[ch];
+-            } else {
+-                curses_line[x] = (cchar_t) {
+-                    .chars[0] = ch,
+-                };
++            ret = getcchar(&vga_to_curses[ch], wch, &attrs, &colors, NULL);
++            if (ret == ERR || wch[0] == 0) {
++                wch[0] = ch;
++                wch[1] = 0;
+             }
+-            curses_line[x].attr |= at;
++            setcchar(&curses_line[x], wch, at, 0, NULL);
+         }
+         mvwadd_wchnstr(screenpad, y, 0, curses_line, width);
+     }
+@@ -400,65 +402,106 @@ static void curses_atexit(void)
      endwin();
  }
  
++/*
++ * In the following:
++ * - fch is the font glyph number
++ * - uch is the unicode value
++ * - wch is the wchar_t value (may not be unicode, e.g. on BSD/solaris)
++ * - mbch is the native local-dependent multibyte representation
++ */
 +
-+#if 0
  /* Setup wchar glyph for one UCS-2 char */
- static void convert_ucs(int glyph, uint16_t ch, iconv_t conv)
+-static void convert_ucs(int glyph, uint16_t ch, iconv_t conv)
++static void convert_ucs(unsigned char fch, uint16_t uch, iconv_t conv)
  {
-@@ -653,6 +660,253 @@ static void font_setup(void)
-     iconv_close(wchar_to_ucs_conv);
-     iconv_close(font_conv);
- }
-+#else
-+static void convert_ucs(int glyph, uint16_t ch, iconv_t conv)
-+{
-+    char nch[MB_CUR_MAX];
-+    wchar_t wch;
-+    char *pch, *pwch, *pnch;
-+    size_t sch, swch, snch;
+-    wchar_t wch;
+-    char *pch, *pwch;
+-    size_t sch, swch;
+-
+-    pch = (char *) &ch;
+-    pwch = (char *) &wch;
+-    sch = sizeof(ch);
+-    swch = sizeof(wch);
+-
+-    if (iconv(conv, &pch, &sch, &pwch, &swch) == (size_t) -1) {
+-        fprintf(stderr, "Could not convert 0x%04x from UCS-2 to WCHAR_T: %s\n",
+-                        ch, strerror(errno));
+-    } else {
+-        vga_to_curses[glyph].chars[0] = wch;
++    char mbch[MB_CUR_MAX];
++    wchar_t wch[2];
++    char *puch, *pmbch;
++    size_t such, smbch;
 +
-+    pch = (char *) &ch;
-+    pwch = (char *) &wch;
-+    pnch = (char *) nch;
-+    sch = sizeof(ch);
-+    swch = sizeof(wch);
-+    snch = sizeof(nch);
++    puch = (char *) &uch;
++    pmbch = (char *) mbch;
++    such = sizeof(uch);
++    smbch = sizeof(mbch);
 +
-+    if (iconv(conv, &pch, &sch, &pnch, &snch) == (size_t) -1) {
-+        fprintf(stderr, "Could not convert 0x%04x from UCS-2 to a multibyte character: %s\n",
-+                        ch, strerror(errno));
++    if (iconv(conv, &puch, &such, &pmbch, &smbch) == (size_t) -1) {
++        fprintf(stderr, "Could not convert 0x%04x "
++                        "from UCS-2 to a multibyte character: %s\n",
++                        uch, strerror(errno));
 +        return;
 +    }
 +
-+    if (mbtowc(&wch, nch, sizeof(nch) - snch) == -1) {
-+        fprintf(stderr, "Could not convert 0x%04x from a multibyte character to wchar_t: %s\n",
-+                        ch, strerror(errno));
++    if (mbtowc(&wch[0], mbch, sizeof(mbch) - smbch) == -1) {
++        fprintf(stderr, "Could not convert 0x%04x "
++                        "from a multibyte character to wchar_t: %s\n",
++                        uch, strerror(errno));
++        return;
+     }
++
++    wch[1] = 0;
++    setcchar(&vga_to_curses[fch], wch, 0, 0, NULL);
+ }
+ 
+ /* Setup wchar glyph for one font character */
+-static void convert_font(unsigned char ch, iconv_t conv)
++static void convert_font(unsigned char fch, iconv_t conv)
+ {
+-    wchar_t wch;
+-    char *pch, *pwch;
+-    size_t sch, swch;
+-
+-    pch = (char *) &ch;
+-    pwch = (char *) &wch;
+-    sch = sizeof(ch);
+-    swch = sizeof(wch);
+-
+-    if (iconv(conv, &pch, &sch, &pwch, &swch) == (size_t) -1) {
+-        fprintf(stderr, "Could not convert 0x%02x from %s to WCHAR_T: %s\n",
+-                        ch, font_charset, strerror(errno));
+-    } else {
+-        vga_to_curses[ch].chars[0] = wch;
++    char mbch[MB_CUR_MAX];
++    wchar_t wch[2];
++    char *pfch, *pmbch;
++    size_t sfch, smbch;
++
++    pfch = (char *) &fch;
++    pmbch = (char *) &mbch;
++    sfch = sizeof(fch);
++    smbch = sizeof(mbch);
++
++    if (iconv(conv, &pfch, &sfch, &pmbch, &smbch) == (size_t) -1) {
++        fprintf(stderr, "Could not convert font glyph 0x%02x "
++                        "from %s to a multibyte character: %s\n",
++                        fch, font_charset, strerror(errno));
 +        return;
 +    }
-+    vga_to_curses[glyph].chars[0] = wch;
-+}
 +
-+static void convert_font(unsigned char ch)
-+{
-+    wchar_t wch;
-+
-+    mbtowc(&wch, (char *)&ch, 1);
-+    vga_to_curses[ch].chars[0] = wch;
-+}
-+
-+/* Convert one wchar to UCS-2 */
-+static uint16_t get_ucs(wchar_t wch, iconv_t conv)
-+{
-+    char nch[MB_CUR_MAX];
-+    char *pnch;
-+    size_t snch;
++    if (mbtowc(&wch[0], mbch, sizeof(mbch) - smbch) == -1) {
++        fprintf(stderr, "Could not convert font glyph 0x%02x "
++                        "from a multibyte character to wchar_t: %s\n",
++                        fch, strerror(errno));
++        return;
+     }
 +
-+    uint16_t ch;
-+    char *pch;
-+    size_t sch;
-+
-+    pnch = (char *) nch;
-+    pch = (char *) &ch;
-+    sch = sizeof(ch);
++    wch[1] = 0;
++    setcchar(&vga_to_curses[fch], wch, 0, 0, NULL);
+ }
+ 
+ /* Convert one wchar to UCS-2 */
+ static uint16_t get_ucs(wchar_t wch, iconv_t conv)
+ {
+-    uint16_t ch;
+-    char *pch, *pwch;
+-    size_t sch, swch;
+-
+-    pch = (char *) &ch;
+-    pwch = (char *) &wch;
+-    sch = sizeof(ch);
+-    swch = sizeof(wch);
+-
+-    if (iconv(conv, &pwch, &swch, &pch, &sch) == (size_t) -1) {
+-        fprintf(stderr, "Could not convert 0x%02lx from WCHAR_T to UCS-2: %s\n",
+-                (unsigned long)wch, strerror(errno));
++    char mbch[MB_CUR_MAX];
++    uint16_t uch;
++    char *pmbch, *puch;
++    size_t smbch, such;
++    int ret;
 +
-+    if ((snch = wctomb(nch, wch)) == -1) {
-+         fprintf(stderr, "Could not convert 0x%04x from wchar_t to a multibyte character: %s\n",
-+                        ch, strerror(errno));
-+         return 0xFFFD;
-+    }
-+
-+    if (iconv(conv, &sch, &snch, &pch, &sch) == (size_t) -1) {
-+        fprintf(stderr, "Could not convert 0x%04x from a multibyte character to UCS-2 : %s\n",
-+                        ch, strerror(errno));
++    ret = wctomb(mbch, wch);
++    if (ret == -1) {
++        fprintf(stderr, "Could not convert 0x%04x "
++                        "from wchar_t to a multibyte character: %s\n",
++                        wch, strerror(errno));
 +        return 0xFFFD;
 +    }
 +
-+    return ch;
-+}
++    pmbch = (char *) mbch;
++    puch = (char *) &uch;
++    smbch = ret;
++    such = sizeof(uch);
 +
-+static void font_setup(void)
-+{
++    if (iconv(conv, &pmbch, &smbch, &puch, &such) == (size_t) -1) {
++        fprintf(stderr, "Could not convert 0x%04x "
++                        "from a multibyte character to UCS-2 : %s\n",
++                        wch, strerror(errno));
+         return 0xFFFD;
+     }
+ 
+-    return ch;
++    return uch;
+ }



Home | Main Index | Thread Index | Old Index