From patchwork Tue Aug 14 05:54:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LIU Hao X-Patchwork-Id: 957355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483606-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=126.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vyrFox+3"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.b="Jr/O1O3y"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41qMJs4cBRz9s8f for ; Tue, 14 Aug 2018 15:55:39 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:cc:message-id:date:mime-version:content-type; q= dns; s=default; b=rSJOerTH24ByZ1PwFVS+V0n7TW6VUXHp5hl192dE4eIarS mXKw40peZoEUFs5qRabo0SKnyZ3HB1c4mgkJ/JZIL/6pBpzcPsYwL+lRJVtHpcgU E8IIEpS07S9k/slJc1IfSzvtWTJimN9280SZRhAtavzw6NGD85cz6XbcuyxZg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:cc:message-id:date:mime-version:content-type; s= default; bh=0LwMnV6J9ZTJABdimx+oEA7PALc=; b=vyrFox+3yaP2K7S7/7bA CGwJmk09zzAh8ZrIO7da0+f2Gbx1Xm0+dngK1mrmbADjkBFNR1AX313J8PEon8O4 J5463hzdJj5azXk7C9kax05ODoKlK5aC1QniHkaw/J0hS1UlJKVd9lNND7mZNS3v Q5UQuXpw8qmoKy4ElmZV2Ic= Received: (qmail 64871 invoked by alias); 14 Aug 2018 05:55:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 63944 invoked by uid 89); 14 Aug 2018 05:55:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.2 spammy=console, 126.com, 126com, 6847 X-HELO: m15-112.126.com Received: from m15-112.126.com (HELO m15-112.126.com) (220.181.15.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Aug 2018 05:55:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Message-ID:Date:MIME-Version; bh=+LbB7 ZqwITfy9/RlIfFmDyFPxPVIZQ1CCGEz9Q3qK1I=; b=Jr/O1O3y4ChRJjMK5ayZ8 eXhku3Tw+5jHbA4ppcmD3vllUb9OIApzWFSQ/47MelT0BS9QvXZ2IRjJ8QB4EaJl yOireP3RmKwBjjfo4wYyNnm9/xEYnlCeWXNgYrtSJcgDbjlCyASF1YqYHaUBVuWt S9haY9l+ilr+EvPWhjV5k0= Received: from [192.168.1.2] (unknown [114.84.167.143]) by smtp2 (Coremail) with SMTP id DMmowABHFjfDbnJb0kJ0FA--.8968S2; Tue, 14 Aug 2018 13:55:16 +0800 (CST) To: gcc-patches@gcc.gnu.org From: Liu Hao Subject: Two fixes for pretty-print.c for mingw-w64 Cc: JonY <10walls@gmail.com> Message-ID: <3d84c0e9-6684-e74b-08e5-afc4b57acee4@126.com> Date: Tue, 14 Aug 2018 13:54:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 The two patches attached have addressed two issues in the ANSI escape sequence translator I sent before. Please review, and consider backporting these to gcc-8-branch. commit 5e79ccaa625169fcaca5847feff0ee168cbad83f (HEAD -> makepkg) Author: Liu Hao Date: Tue Aug 14 12:22:08 2018 +0800 gcc/pretty-print.c: Make reverse video work for non-DBCS environments. `COMMON_LVB_REVERSE_VIDEO` only works for DBCS environments (such as CJK charsets). As it is unreliable, we swap the foreground and background by hand if this flag is set. Signed-off-by: Liu Hao commit a250716957205fee0de3553f318d04b9bfc1f35f Author: Liu Hao Date: Tue Aug 14 12:13:32 2018 +0800 gcc/pretty-print.c: Do not call `_close()` on the handle returned by `_get_osfhandle()`. Microsoft documentation about `_get_osfhandle()` is misleading. It shouldn't have mentioned that the handle can be closed in such a way, as the handle is automatically closed when the associated `FILE *` or FD is closed. Under no circumstance does it make any sense to `_close()` it by hand. The non-debug versions of MSVCRT and UCRTBASE tolerate such errors, but with the debug version of UCRTBASE an assertion is triggered. Reference: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle Signed-off-by: Liu Hao diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index 736af8f7735..31eb8893f2a 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -684,7 +684,6 @@ mingw_ansi_fputs (const char *str, FILE *fp) /* If it is not a console, write everything as-is. */ write_all (h, read, strlen (read)); - _close ((intptr_t) h); return 1; }