From nobody Mon Nov 10 17:57:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558109699; cv=none; d=zoho.com; s=zohoarc; b=oIBWMKYXmOkecBce26Gu1fVE0amLHUU1pYY/3FKyc48rPKhaakKnMSQwQCZcTwRulX6ufp4E7BSMpAOSK0EXJaG2KrvewsCulGNDUpt/+y4mIC6Xhu9eaLNw5nWCbKV7KZ2OPj2w4QqOd1lYBe2+gyEXIhi13UqCnwyYHppMMfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558109699; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gLCCTtIP5z9jfj4zvZrQng0MbKfWqQgvQLZTXBZNygs=; b=KOPC4JvJB3FvLwsQGBdx4KYlSgY5AHM3wm/X31PyPOI1yfHOZr+3o8ahdmP3t/C4QINmFxJn6kUjPWVOL+cg6TAuFA84T/2mhvlqcdB4Ka86NKqRgFX0mmp2g70prZqfxK1jY/Gxy+2Q+qvVfNsS9AI3TmqCkA72xXd6dfVXefA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 155810969908962.41338041547385; Fri, 17 May 2019 09:14:59 -0700 (PDT) Received: from localhost ([127.0.0.1]:50842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRfVV-0005TC-05 for importer@patchew.org; Fri, 17 May 2019 12:14:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRfTs-0004GT-NA for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRfTn-00088z-1c for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44290) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hRfTl-0007zT-6X for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F8C230832F4; Fri, 17 May 2019 16:12:46 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-74.ams2.redhat.com [10.36.117.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id B326F5DC19; Fri, 17 May 2019 16:12:42 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id AADC51752B; Fri, 17 May 2019 18:12:41 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:12:38 +0200 Message-Id: <20190517161241.11813-2-kraxel@redhat.com> In-Reply-To: <20190517161241.11813-1-kraxel@redhat.com> References: <20190517161241.11813-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 17 May 2019 16:12:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/4] ui/curses: do not assume wchar_t contains unicode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Samuel Thibault E.g. BSD and Solaris even use locale-specific encoding there. We thus have to go through the native multibyte representation and use mbrtowc/wcrtomb to make a proper conversion. Signed-off-by: Samuel Thibault Tested-by: Kamil Rytarowski Message-Id: <20190427183307.12796-2-samuel.thibault@ens-lyon.org> Signed-off-by: Gerd Hoffmann --- ui/curses.c | 149 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 96 insertions(+), 53 deletions(-) diff --git a/ui/curses.c b/ui/curses.c index fb63945188b2..81d419879ede 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -400,65 +400,108 @@ static void curses_atexit(void) endwin(); } =20 +/* + * 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 + */ + /* Setup wchar glyph for one UCS-2 char */ -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) { + char mbch[MB_LEN_MAX]; wchar_t wch; - char *pch, *pwch; - size_t sch, swch; + char *puch, *pmbch; + size_t such, smbch; + mbstate_t ps; =20 - pch =3D (char *) &ch; - pwch =3D (char *) &wch; - sch =3D sizeof(ch); - swch =3D sizeof(wch); + puch =3D (char *) &uch; + pmbch =3D (char *) mbch; + such =3D sizeof(uch); + smbch =3D sizeof(mbch); =20 - if (iconv(conv, &pch, &sch, &pwch, &swch) =3D=3D (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] =3D wch; + if (iconv(conv, &puch, &such, &pmbch, &smbch) =3D=3D (size_t) -1) { + fprintf(stderr, "Could not convert 0x%04x " + "from UCS-2 to a multibyte character: %s\n", + uch, strerror(errno)); + return; } + + memset(&ps, 0, sizeof(ps)); + if (mbrtowc(&wch, mbch, sizeof(mbch) - smbch, &ps) =3D=3D -1) { + fprintf(stderr, "Could not convert 0x%04x " + "from a multibyte character to wchar_t: %s\n", + uch, strerror(errno)); + return; + } + vga_to_curses[fch].chars[0] =3D wch; } =20 /* 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) { + char mbch[MB_LEN_MAX]; wchar_t wch; - char *pch, *pwch; - size_t sch, swch; + char *pfch, *pmbch; + size_t sfch, smbch; + mbstate_t ps; =20 - pch =3D (char *) &ch; - pwch =3D (char *) &wch; - sch =3D sizeof(ch); - swch =3D sizeof(wch); + pfch =3D (char *) &fch; + pmbch =3D (char *) &mbch; + sfch =3D sizeof(fch); + smbch =3D sizeof(mbch); =20 - if (iconv(conv, &pch, &sch, &pwch, &swch) =3D=3D (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] =3D wch; + if (iconv(conv, &pfch, &sfch, &pmbch, &smbch) =3D=3D (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; } + + memset(&ps, 0, sizeof(ps)); + if (mbrtowc(&wch, mbch, sizeof(mbch) - smbch, &ps) =3D=3D -1) { + fprintf(stderr, "Could not convert font glyph 0x%02x " + "from a multibyte character to wchar_t: %s\n", + fch, strerror(errno)); + return; + } + vga_to_curses[fch].chars[0] =3D wch; } =20 /* 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; + char mbch[MB_LEN_MAX]; + uint16_t uch; + char *pmbch, *puch; + size_t smbch, such; + mbstate_t ps; + int ret; =20 - pch =3D (char *) &ch; - pwch =3D (char *) &wch; - sch =3D sizeof(ch); - swch =3D sizeof(wch); + memset(&ps, 0, sizeof(ps)); + ret =3D wcrtomb(mbch, wch, &ps); + if (ret =3D=3D -1) { + fprintf(stderr, "Could not convert 0x%04x " + "from wchar_t to a multibyte character: %s\n", + wch, strerror(errno)); + return 0xFFFD; + } + + pmbch =3D (char *) mbch; + puch =3D (char *) &uch; + smbch =3D ret; + such =3D sizeof(uch); =20 - if (iconv(conv, &pwch, &swch, &pch, &sch) =3D=3D (size_t) -1) { - fprintf(stderr, "Could not convert 0x%02lx from WCHAR_T to UCS-2: = %s\n", - (unsigned long)wch, strerror(errno)); + if (iconv(conv, &pmbch, &smbch, &puch, &such) =3D=3D (size_t) -1) { + fprintf(stderr, "Could not convert 0x%04x " + "from a multibyte character to UCS-2 : %s\n", + wch, strerror(errno)); return 0xFFFD; } =20 - return ch; + return uch; } =20 /* @@ -466,6 +509,11 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv) */ static void font_setup(void) { + iconv_t ucs2_to_nativecharset; + iconv_t nativecharset_to_ucs2; + iconv_t font_conv; + int i; + /* * Control characters are normally non-printable, but VGA does have * well-known glyphs for them. @@ -505,30 +553,25 @@ static void font_setup(void) 0x25bc }; =20 - iconv_t ucs_to_wchar_conv; - iconv_t wchar_to_ucs_conv; - iconv_t font_conv; - int i; - - ucs_to_wchar_conv =3D iconv_open("WCHAR_T", "UCS-2"); - if (ucs_to_wchar_conv =3D=3D (iconv_t) -1) { + ucs2_to_nativecharset =3D iconv_open(nl_langinfo(CODESET), "UCS-2"); + if (ucs2_to_nativecharset =3D=3D (iconv_t) -1) { fprintf(stderr, "Could not convert font glyphs from UCS-2: '%s'\n", strerror(errno)); exit(1); } =20 - wchar_to_ucs_conv =3D iconv_open("UCS-2", "WCHAR_T"); - if (wchar_to_ucs_conv =3D=3D (iconv_t) -1) { - iconv_close(ucs_to_wchar_conv); + nativecharset_to_ucs2 =3D iconv_open("UCS-2", nl_langinfo(CODESET)); + if (nativecharset_to_ucs2 =3D=3D (iconv_t) -1) { + iconv_close(ucs2_to_nativecharset); fprintf(stderr, "Could not convert font glyphs to UCS-2: '%s'\n", strerror(errno)); exit(1); } =20 - font_conv =3D iconv_open("WCHAR_T", font_charset); + font_conv =3D iconv_open(nl_langinfo(CODESET), font_charset); if (font_conv =3D=3D (iconv_t) -1) { - iconv_close(ucs_to_wchar_conv); - iconv_close(wchar_to_ucs_conv); + iconv_close(ucs2_to_nativecharset); + iconv_close(nativecharset_to_ucs2); fprintf(stderr, "Could not convert font glyphs from %s: '%s'\n", font_charset, strerror(errno)); exit(1); @@ -536,7 +579,7 @@ static void font_setup(void) =20 /* Control characters */ for (i =3D 0; i <=3D 0x1F; i++) { - convert_ucs(i, control_characters[i], ucs_to_wchar_conv); + convert_ucs(i, control_characters[i], ucs2_to_nativecharset); } =20 for (i =3D 0x20; i <=3D 0xFF; i++) { @@ -544,12 +587,12 @@ static void font_setup(void) } =20 /* DEL */ - convert_ucs(0x7F, 0x2302, ucs_to_wchar_conv); + convert_ucs(0x7F, 0x2302, ucs2_to_nativecharset); =20 if (strcmp(nl_langinfo(CODESET), "UTF-8")) { /* Non-Unicode capable, use termcap equivalents for those availabl= e */ for (i =3D 0; i <=3D 0xFF; i++) { - switch (get_ucs(vga_to_curses[i].chars[0], wchar_to_ucs_conv))= { + switch (get_ucs(vga_to_curses[i].chars[0], nativecharset_to_uc= s2)) { case 0x00a3: vga_to_curses[i] =3D *WACS_STERLING; break; @@ -649,8 +692,8 @@ static void font_setup(void) } } } - iconv_close(ucs_to_wchar_conv); - iconv_close(wchar_to_ucs_conv); + iconv_close(ucs2_to_nativecharset); + iconv_close(nativecharset_to_ucs2); iconv_close(font_conv); } =20 --=20 2.18.1 From nobody Mon Nov 10 17:57:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558109698; cv=none; d=zoho.com; s=zohoarc; b=FfmSiB3gSEpPKjFgU/7SMOgX3s8Q5PKnaxt0hxy+bE293V7XgZb51i1MpoYesUHn/sQ9ZOPScCWoK25yLoJGrNWI7kytoR2JovPCxHgN9gdIvYnSry7bA+CAZBfDYcvdtMKEVmtNMjY3zahshubMBcKOnw5KFfMbgcZ0fx56WOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558109698; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=n/uTcfZVc4kVcsNSm9RvzrWhF5r/W+NAx+onAgBAEsk=; b=GiHlw/t4bY3477IIO3XxiWi+NLL+fHcs73r2WT6gHrOi6WaRbdZAX4AcidJIaLt+B5jZraIIu/+/+gjMzI3OzbOFOLvxcOHKoH9Y6U3ajBeKFJqnwEC/ehAjvv15qCJi9Lyip4uor+3IPiNGNTELyZyoAoAlBCmLBQ+BADHfnf8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558109698388884.1297009264775; Fri, 17 May 2019 09:14:58 -0700 (PDT) Received: from localhost ([127.0.0.1]:50840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRfVS-0005RP-Cb for importer@patchew.org; Fri, 17 May 2019 12:14:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRfTs-0004GY-Of for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRfTo-0008AL-UZ for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33058) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hRfTl-0007zU-6V for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 662E3317916C; Fri, 17 May 2019 16:12:45 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-74.ams2.redhat.com [10.36.117.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2F8E5D71B; Fri, 17 May 2019 16:12:42 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B335317532; Fri, 17 May 2019 18:12:41 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:12:39 +0200 Message-Id: <20190517161241.11813-3-kraxel@redhat.com> In-Reply-To: <20190517161241.11813-1-kraxel@redhat.com> References: <20190517161241.11813-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 17 May 2019 16:12:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/4] ui/curses: manipulate cchar_t with standard curses functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Samuel Thibault The chars/attr fields are curses internals, setcchar and getcchar have to be used instead. Signed-off-by: Samuel Thibault Tested-by: Kamil Rytarowski Message-Id: <20190427183307.12796-3-samuel.thibault@ens-lyon.org> Signed-off-by: Gerd Hoffmann --- ui/curses.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/ui/curses.c b/ui/curses.c index 81d419879ede..1f3fcabb004b 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -66,20 +66,22 @@ static void curses_update(DisplayChangeListener *dcl, { console_ch_t *line; cchar_t curses_line[width]; + wchar_t wch[CCHARW_MAX]; + attr_t attrs; + short colors; + int ret; =20 line =3D screen + y * width; for (h +=3D y; y < h; y ++, line +=3D width) { for (x =3D 0; x < width; x++) { chtype ch =3D line[x] & 0xff; chtype at =3D line[x] & ~0xff; - if (vga_to_curses[ch].chars[0]) { - curses_line[x] =3D vga_to_curses[ch]; - } else { - curses_line[x] =3D (cchar_t) { - .chars[0] =3D ch, - }; + ret =3D getcchar(&vga_to_curses[ch], wch, &attrs, &colors, NUL= L); + if (ret =3D=3D ERR || wch[0] =3D=3D 0) { + wch[0] =3D ch; + wch[1] =3D 0; } - curses_line[x].attr |=3D at; + setcchar(&curses_line[x], wch, at, 0, NULL); } mvwadd_wchnstr(screenpad, y, 0, curses_line, width); } @@ -412,7 +414,7 @@ static void curses_atexit(void) static void convert_ucs(unsigned char fch, uint16_t uch, iconv_t conv) { char mbch[MB_LEN_MAX]; - wchar_t wch; + wchar_t wch[2]; char *puch, *pmbch; size_t such, smbch; mbstate_t ps; @@ -430,20 +432,22 @@ static void convert_ucs(unsigned char fch, uint16_t u= ch, iconv_t conv) } =20 memset(&ps, 0, sizeof(ps)); - if (mbrtowc(&wch, mbch, sizeof(mbch) - smbch, &ps) =3D=3D -1) { + if (mbrtowc(&wch[0], mbch, sizeof(mbch) - smbch, &ps) =3D=3D -1) { fprintf(stderr, "Could not convert 0x%04x " "from a multibyte character to wchar_t: %s\n", uch, strerror(errno)); return; } - vga_to_curses[fch].chars[0] =3D wch; + + wch[1] =3D 0; + setcchar(&vga_to_curses[fch], wch, 0, 0, NULL); } =20 /* Setup wchar glyph for one font character */ static void convert_font(unsigned char fch, iconv_t conv) { char mbch[MB_LEN_MAX]; - wchar_t wch; + wchar_t wch[2]; char *pfch, *pmbch; size_t sfch, smbch; mbstate_t ps; @@ -461,13 +465,15 @@ static void convert_font(unsigned char fch, iconv_t c= onv) } =20 memset(&ps, 0, sizeof(ps)); - if (mbrtowc(&wch, mbch, sizeof(mbch) - smbch, &ps) =3D=3D -1) { + if (mbrtowc(&wch[0], mbch, sizeof(mbch) - smbch, &ps) =3D=3D -1) { fprintf(stderr, "Could not convert font glyph 0x%02x " "from a multibyte character to wchar_t: %s\n", fch, strerror(errno)); return; } - vga_to_curses[fch].chars[0] =3D wch; + + wch[1] =3D 0; + setcchar(&vga_to_curses[fch], wch, 0, 0, NULL); } =20 /* Convert one wchar to UCS-2 */ @@ -592,7 +598,16 @@ static void font_setup(void) if (strcmp(nl_langinfo(CODESET), "UTF-8")) { /* Non-Unicode capable, use termcap equivalents for those availabl= e */ for (i =3D 0; i <=3D 0xFF; i++) { - switch (get_ucs(vga_to_curses[i].chars[0], nativecharset_to_uc= s2)) { + wchar_t wch[CCHARW_MAX]; + attr_t attr; + short color; + int ret; + + ret =3D getcchar(&vga_to_curses[i], wch, &attr, &color, NULL); + if (ret =3D=3D ERR) + continue; + + switch (get_ucs(wch[0], nativecharset_to_ucs2)) { case 0x00a3: vga_to_curses[i] =3D *WACS_STERLING; break; --=20 2.18.1 From nobody Mon Nov 10 17:57:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558109677; cv=none; d=zoho.com; s=zohoarc; b=WeDTGpJwZIgAPFfxBg1CKjy0k2QZ97h0Cai/D0uLPvEwWbO80+UDvvWX6u/1QLuCOAnH4ABEltRwafUUi74iVG2Ys92R3hvZ5mJPPmFMNFRVsLsHn0JN0ZE01ycJvyMu4C7RHgL2S8bEnBjNQo27UB5laJC6kAXOMCKkBAG7Gxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558109677; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=r1k5TDGeTWtGrz/6Bqp8Hzyp52q84r1UtpZRaHJixMw=; b=drt7KMctqgEVOC/sqIxMaUpuvER0cdTCeHIH/Z6cqqOLQZc6TfOLBxqiyKX7EV6zFekziS/2+qA3V/1OtU+16IgPohFJJqR7xSK91gY3u8K2RUMHRyKvi9YYftrZ79LbHleRBc197aPbTGLFqk9zHtYx/g2iBNFyDTZQy2OqAOc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558109677390612.2268589688342; Fri, 17 May 2019 09:14:37 -0700 (PDT) Received: from localhost ([127.0.0.1]:50837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRfV2-00056i-SN for importer@patchew.org; Fri, 17 May 2019 12:14:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRfTh-000420-0W for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRfTf-000827-9h for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hRfTf-0007v7-3T for qemu-devel@nongnu.org; Fri, 17 May 2019 12:12:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E3AA30BBE84; Fri, 17 May 2019 16:12:45 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-74.ams2.redhat.com [10.36.117.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9988A5D719; Fri, 17 May 2019 16:12:42 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BB54F17534; Fri, 17 May 2019 18:12:41 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:12:40 +0200 Message-Id: <20190517161241.11813-4-kraxel@redhat.com> In-Reply-To: <20190517161241.11813-1-kraxel@redhat.com> References: <20190517161241.11813-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 17 May 2019 16:12:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/4] ui/console: Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , HOU Qiming Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: HOU Qiming In a GVT-g setup with dmabuf and GTK GUI, the current 2D texture at surface_gl_update_texture is not necessarily surface->texture. Adding a glBindTexture fixes related crashes and artifacts, and is generally more secure. Signed-off-by: HOU Qiming Tested-by: Marcel Apfelbaum Signed-off-by: Marcel Apfelbaum Message-id: 20190507080501.26712-1-marcel.apfelbaum@gmail.com [fixed malformed patch, rebase to master] Signed-off-by: Marcel Apfelbaum Signed-off-by: Gerd Hoffmann --- ui/console-gl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ui/console-gl.c b/ui/console-gl.c index a56e1cd8ebce..c1cb3bd67359 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -92,13 +92,17 @@ void surface_gl_update_texture(QemuGLShader *gls, =20 assert(gls); =20 - glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, - surface_stride(surface) / surface_bytes_per_pixel(surfac= e)); - glTexSubImage2D(GL_TEXTURE_2D, 0, - x, y, w, h, - surface->glformat, surface->gltype, - data + surface_stride(surface) * y - + surface_bytes_per_pixel(surface) * x); + if (surface->texture) { + glBindTexture(GL_TEXTURE_2D, surface->texture); + glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, + surface_stride(surface) + / surface_bytes_per_pixel(surface)); + glTexSubImage2D(GL_TEXTURE_2D, 0, + x, y, w, h, + surface->glformat, surface->gltype, + data + surface_stride(surface) * y + + surface_bytes_per_pixel(surface) * x); + } } =20 void surface_gl_render_texture(QemuGLShader *gls, --=20 2.18.1 From nobody Mon Nov 10 17:57:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558110015; cv=none; d=zoho.com; s=zohoarc; b=SS465rI7C2TJv+angDlxvQR5jWu7p02EFsj2ylsjeZsAkMG8Q+LHgqbfm+c1JxaBpZA8qLZuxWG9qhAX4/Nro5Cb0/HZUBAW7AltHLO/TGfu9XYbHsM5R0zlojg/nBM2f3O8GvvlZmlriueFzTFJjggzcP7sNTenjfBQeiSVOdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558110015; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=SUK5DqfeAbSjS7+cZJDiBNlVE6lwfNoXm+rvPN6NiGc=; b=gRqRdYX5VKcW+N+C8n6pBaG0U6Fm+835eaKlBmWhnXhnL3v468qkYwHiNxI15xNMlt/0XeKtpuGz01bFZIvheFxDfrSwgrYKxTLhoJl5VuWV0kTtfajFdH5g2F5rf8Aol5SBU6gJgfrgYsUssbFvSY73ty/pGjydgSxb/SDo0fQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558110015332802.5767320492032; Fri, 17 May 2019 09:20:15 -0700 (PDT) Received: from localhost ([127.0.0.1]:50910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRfab-0000fj-7F for importer@patchew.org; Fri, 17 May 2019 12:20:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRfTs-0004GV-NK for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRfTn-000894-1p for qemu-devel@nongnu.org; Fri, 17 May 2019 12:13:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56320) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hRfTl-0007tt-6e; Fri, 17 May 2019 12:13:06 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 841B3308429D; Fri, 17 May 2019 16:12:46 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-74.ams2.redhat.com [10.36.117.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id A35061001E93; Fri, 17 May 2019 16:12:42 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C34BD17535; Fri, 17 May 2019 18:12:41 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 18:12:41 +0200 Message-Id: <20190517161241.11813-5-kraxel@redhat.com> In-Reply-To: <20190517161241.11813-1-kraxel@redhat.com> References: <20190517161241.11813-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 17 May 2019 16:12:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/4] kbd-state: fix autorepeat handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When allowing multiple down-events in a row (key autorepeat) we can't use change_bit() any more to update the state, because autorepeat events don't change the key state. We have to explicitly use set_bit() and clear_bit() instead. Cc: qemu-stable@nongnu.org Fixes: 35921860156e kbd-state: don't block auto-repeat events Buglink: https://bugs.launchpad.net/qemu/+bug/1828272 Signed-off-by: Gerd Hoffmann Message-id: 20190514042443.10735-1-kraxel@redhat.com --- ui/kbd-state.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/kbd-state.c b/ui/kbd-state.c index f3ab2d7a665d..1668d17ddabc 100644 --- a/ui/kbd-state.c +++ b/ui/kbd-state.c @@ -59,7 +59,11 @@ void qkbd_state_key_event(QKbdState *kbd, QKeyCode qcode= , bool down) } =20 /* update key and modifier state */ - change_bit(qcode, kbd->keys); + if (down) { + set_bit(qcode, kbd->keys); + } else { + clear_bit(qcode, kbd->keys); + } switch (qcode) { case Q_KEY_CODE_SHIFT: case Q_KEY_CODE_SHIFT_R: --=20 2.18.1