From nobody Tue Feb 10 02:00:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1599668436; cv=none; d=zohomail.com; s=zohoarc; b=FDfGhPKoGnA+Vw0W/weGzzWQLEtcNG2SygN3OfJHByEOLf204Wnd1hGlFkCahisKjrWZ+eG95lr24lDO/Cxz2h7XdPwNf7BAXkhy4nHWdi50NiJZwcZTBVbqX/zBNP7/Ki9WcUw3guiTj4o24vMrL45rptfhifw3/6DprQVy1gY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599668436; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TsNOy56cT/aZuPzlGfi9G8/JBTKitoxne2lgskAEKvc=; b=a84HOI61y0o/LsbficnZzlOk7dqfNCGHdwDfcIakCIKXQfw0mLU4AF51ZEWGhlGmCmlcvOFE/NDKq6yP2FVqFiCCFEfZAQW5z68tWCRcOOwxEzB1qp4rUwBdZFRIkrjE5VwlGiDlya3RzhTo9Q0Yc9MbgoYDTdr3uHhXzoohVt0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599668436695913.0902097247795; Wed, 9 Sep 2020 09:20:36 -0700 (PDT) Received: from localhost ([::1]:53438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kG2pn-0007qN-30 for importer@patchew.org; Wed, 09 Sep 2020 12:20:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG2kY-0000Qn-D2; Wed, 09 Sep 2020 12:15:10 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:35297) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kG2kV-0006Xg-F1; Wed, 09 Sep 2020 12:15:10 -0400 Received: by mail-pg1-x543.google.com with SMTP id g29so2435001pgl.2; Wed, 09 Sep 2020 09:15:06 -0700 (PDT) Received: from localhost.localdomain ([222.95.248.6]) by smtp.googlemail.com with ESMTPSA id l123sm2506987pgl.24.2020.09.09.09.15.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 09:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TsNOy56cT/aZuPzlGfi9G8/JBTKitoxne2lgskAEKvc=; b=mEc05JasyK7ebruCxoDW6cCOc1ZSB+FYd9tmP0TXruyXBot/3/5BHbOyYoosymhu3n o4vQ/n7F/fxgKDtQBy3cquTLtU8HjnF/27PQOzf9s79I3arHCxP4YPLhafwtgGcoe2TE Z+Qpw59mxLGA9FSIvP+UXGdDjI6T/n8QzKEeKwq9Y9b3ToQyQIkjJmVifxEdIA3CqOL6 V6tn0/6ZyX6MW72lRf9ppyL6xZ1hTGl1qWugXxGqwg5GT+PJRngnP9mF1EkXQ1TkmXhb IemSN8nk0f34Na2kAXlaOUVmjU/r4vzQqd7YZ8ndidMva6cj2o0z+KaoZTnO727J8G+w FweQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TsNOy56cT/aZuPzlGfi9G8/JBTKitoxne2lgskAEKvc=; b=CmSA3DyLYCSD0shtNfIrBTnEF9LxNZqknKpXurDSLnJqtFjNshVpX+pznnEWbqStXN U+kp8CekWeYGiC+U1clqO8X/KQ7bCKFidobz5yrW+Yza+MxQc4q5D3kiI8zNVA+HTNvW P8Z2ro+FYluiNcSJC2pQtbK0FYCaXGN0+78tJ5N5s6bWHWGYQZ0bRG+mkAazDoGz7cj3 fW2q/1noSglQa9wysODuOjHwUOrXW/i4LKgluWS6+bhcUVNSeo9lIN1NPlXlyPHOaFYq BgG2kKNxUhcU0632BRNrRa27Yu67V9tFB2JUBZmTb/6SYX5qGFXdaTwsJWKuWJfGdVwa WOYQ== X-Gm-Message-State: AOAM530HOGIb01tJrcgi5/2Q3aAmPahTIFHxijRuDGDOUhfJEF3pmHUH /ZlnJT3gUpXUdWPFZWGqnRjJKH+v/qMTVAj6 X-Google-Smtp-Source: ABdhPJyvSC92Nsvmi9eRnPmhWohK/EVt6KrVNqFTvVkNsRpOLzoqsmOPwZF+5cKfgW+whCsRga8YnQ== X-Received: by 2002:a62:878f:: with SMTP id i137mr1379096pfe.24.1599668105248; Wed, 09 Sep 2020 09:15:05 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v4 05/24] configure: Fixes ncursesw detection under msys2/mingw and enable curses Date: Thu, 10 Sep 2020 00:14:24 +0800 Message-Id: <20200909161430.1789-5-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20200909161430.1789-1-luoyonggang@gmail.com> References: <20200909161430.1789-1-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=luoyonggang@gmail.com; helo=mail-pg1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Ed Maste , Michael Roth , qemu-block@nongnu.org, Stefan Weil , Xie Changlong , Richard Henderson , Markus Armbruster , Max Reitz , Yonggang Luo , Gerd Hoffmann , Wen Congyang , Li-Wen Hsu , Peter Lieven Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The mingw pkg-config are showing following absolute path and contains : as = the separator, so we must not use : as path separator. and we know the command line parame= ter are not likely contains newline, we could use newline as path command line parameter separ= ator -D_XOPEN_SOURCE=3D600 -D_POSIX_C_SOURCE=3D199506L -IC:/CI-Tools/msys64/ming= w64/include/ncursesw:-I/usr/include/ncursesw: -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=3D600 -D_POSIX_C_SOURCE=3D199506L -IC -p= ipe -lncursesw -lgnurx -ltre -lintl -liconv -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=3D600 -D_POSIX_C_SOURCE=3D199506L -IC -l= ncursesw -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=3D600 -D_POSIX_C_SOURCE=3D199506L -IC -l= cursesw -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -pipe -lncurse= sw -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 Refer to https://unix.stackexchange.com/a/103011/218958 If your file names are guaranteed not to contain newlines, you can use newl= ines as the separator. W hen you expand the variable, first turn off globbing with set -f and set th= e list of field splitting characters IFS to contain only a newline. 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 | ^~~~~~~~~~~~ compilation terminated. So we using g_get_codeset instead of nl_langinfo(CODESET) Signed-off-by: Yonggang Luo Reviewed-by: Gerd Hoffmann --- configure | 25 +++++++++++++++---------- ui/curses.c | 10 +++++----- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/configure b/configure index f4f8bc3756..b21843fdb9 100755 --- a/configure +++ b/configure @@ -3653,35 +3653,40 @@ if test "$iconv" =3D "no" ; then fi if test "$curses" !=3D "no" ; then if test "$mingw32" =3D "yes" ; then - curses_inc_list=3D"$($pkg_config --cflags ncurses 2>/dev/null):" - curses_lib_list=3D"$($pkg_config --libs ncurses 2>/dev/null):-lpdcurse= s" + curses_inc_list=3D"$($pkg_config --cflags ncurses 2>/dev/null) + $($pkg_config --cflags ncursesw 2>/dev/null)" + curses_lib_list=3D"$($pkg_config --libs ncurses 2>/dev/null) + $($pkg_config --libs ncursesw 2>/dev/null) + -lpdcurses" else - curses_inc_list=3D"$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr= /include/ncursesw:" - curses_lib_list=3D"$($pkg_config --libs ncursesw 2>/dev/null):-lncurse= sw:-lcursesw" + curses_inc_list=3D"$($pkg_config --cflags ncursesw 2>/dev/null) + -I/usr/include/ncursesw:" + curses_lib_list=3D"$($pkg_config --libs ncursesw 2>/dev/null) + -lncursesw + -lcursesw" fi curses_found=3Dno cat > $TMPC << EOF #include #include #include -#include int main(void) { - const char *codeset; wchar_t wch =3D L'w'; setlocale(LC_ALL, ""); resize_term(0, 0); addwstr(L"wide chars\n"); addnwstr(&wch, 1); add_wch(WACS_DEGREE); - codeset =3D nl_langinfo(CODESET); - return codeset !=3D 0; + return 0; } EOF - IFS=3D: + IFS=3D' +' # turn off variable value expansion except for= splitting at newlines for curses_inc in $curses_inc_list; do # Make sure we get the wide character prototypes curses_inc=3D"-DNCURSES_WIDECHAR $curses_inc" - IFS=3D: + IFS=3D' +' # turn off variable value expansion except for= splitting at newlines for curses_lib in $curses_lib_list; do unset IFS if compile_prog "$curses_inc" "$curses_lib" ; then 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 #include -#include #include =20 #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 =3D g_get_codeset(); =20 /* * Control characters are normally non-printable, but VGA does have @@ -566,14 +566,14 @@ static void font_setup(void) 0x25bc }; =20 - ucs2_to_nativecharset =3D iconv_open(nl_langinfo(CODESET), "UCS-2"); + ucs2_to_nativecharset =3D iconv_open(local_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 - nativecharset_to_ucs2 =3D iconv_open("UCS-2", nl_langinfo(CODESET)); + nativecharset_to_ucs2 =3D iconv_open("UCS-2", local_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", @@ -581,7 +581,7 @@ static void font_setup(void) exit(1); } =20 - font_conv =3D iconv_open(nl_langinfo(CODESET), font_charset); + font_conv =3D iconv_open(local_codeset, font_charset); if (font_conv =3D=3D (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); =20 - if (strcmp(nl_langinfo(CODESET), "UTF-8")) { + if (strcmp(local_codeset, "UTF-8")) { /* Non-Unicode capable, use termcap equivalents for those availabl= e */ for (i =3D 0; i <=3D 0xFF; i++) { wchar_t wch[CCHARW_MAX]; --=20 2.28.0.windows.1