From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDB2BC4363A for ; Mon, 5 Oct 2020 15:57:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 72EF020663 for ; Mon, 5 Oct 2020 15:57:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VtHluAbm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72EF020663 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPSs6-0006DN-WE for qemu-devel@archiver.kernel.org; Mon, 05 Oct 2020 11:57:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPSq8-00045T-Ao; Mon, 05 Oct 2020 11:55:52 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:53643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kPSq5-0001Vu-UE; Mon, 05 Oct 2020 11:55:52 -0400 Received: by mail-pj1-x1042.google.com with SMTP id t7so13125pjd.3; Mon, 05 Oct 2020 08:55:49 -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=2WqjhroH5SRwZnm2hg+MQdn9o9Rvim5vvZIGkwtpMCA=; b=VtHluAbmnyEkFe4ffbt+2z5d89mFnZRTcVrz7BvsYoaluZBIfhwfBz2MB63ZTivZhM 4oMRx1wPoVQJ88FlNZbPoz28yknSa73RJbBgUVO8qO4iPCt1owRvlCNgA00SxVJFd/lM 7y9bfueWhj4Poda5VYSQu2myaF5ZyxTLsAqGp1QASyvuewJw4vw4089YZjrYdjlPv+8A 7gtGHaG060zkRYbfHxLGWFyIkSpgb1QlTuo+KpnKpAF/7U5Uq6pQfw3quGEFGvmwqac7 AQzT/ls6E0ZwdLIlch8bAEq13aku6eLM+v3BGk2SSkeDbtTCAaS2KIgP0zpb8RWtLHF5 ziSw== 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=2WqjhroH5SRwZnm2hg+MQdn9o9Rvim5vvZIGkwtpMCA=; b=HPnN/xRBDKBvR0nXshh9xr2VC3xU+nBKbSFpBHC9at2VzQTWYuGO6CaE5B55a/NHWz pIYvv6jRBBCV4LSu3tdLsmXkTyY3fDbsNq/CtIWbHjgabRWdgC1NHDvysJA3Ez6ULBjX TvhVvpV7XBJ2+7yCi3v3QxTZsvAlnju6Gn/CDDXV1DvNtCrHX0u/XBaE/5JTzLpWKZVA zPvZpXuUZqz4TeEyX6hR3d/1TG6clNOJnN/hijMTlwUiToznc69B+JUAX6Aa3KTLOikf hznlbne10zBkzu0nNqKdjAzQ738uaq7xu+1F0YrUy+yIOWUmK82cimrrCWiXUdNRyAid Purw== X-Gm-Message-State: AOAM531/OMCIcyehxGHOS7aABXe73p/l1vJaasapCyEl3ZKf+Z482HTP 4WNFmXu60vQTvjSmE9vG1zyVzHZ0kxkrfg== X-Google-Smtp-Source: ABdhPJxKxJ31YBgCHp1kyAkGHIbBtZ+ckjbH09U8GbTQcRpMRyEdQG8yeXRh8UYtwqPIAquq6LtTeA== X-Received: by 2002:a17:90b:3109:: with SMTP id gc9mr79842pjb.74.1601913347839; Mon, 05 Oct 2020 08:55:47 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id u22sm34803pgi.85.2020.10.05.08.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2020 08:55:47 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v8 2/4] curses: Fixes compiler error that complain don't have langinfo.h on msys2/mingw Date: Mon, 5 Oct 2020 23:55:22 +0800 Message-Id: <20201005155524.442-3-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201005155524.442-1-luoyonggang@gmail.com> References: <20201005155524.442-1-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=luoyonggang@gmail.com; helo=mail-pj1-x1042.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: QEMU Trivial , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Laurent Vivier , Yonggang Luo , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Daniel P. Berrangé --- configure | 5 +---- ui/curses.c | 10 +++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/configure b/configure index 7d5ffee29a..6acdd6fa88 100755 --- a/configure +++ b/configure @@ -3522,17 +3522,14 @@ if test "$curses" != "no" ; then #include #include #include -#include 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 #include -#include #include #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