From patchwork Mon Apr 4 12:26:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 605859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3qdrpg4xpDz9s9G for ; Mon, 4 Apr 2016 22:27:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=SUzHeVc8; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=AWH144Qz0Q2iZXHnowccinNgOz7zp3jNUHlN/Grbb13rs1C0Am SWLv4J+VRCAWI0yllfMLSotNwaK6kh6s6cYiV2e3vd2sg02mkT7Z7/f3fX1DD9cc LnqgJASrUhVu+DanOVTemh5LoOISH0QZlB6GB0hRmL4l/4lAJP6w1dpqU= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=2hw7lWbZ+3XkiHeN3K8TF8kwL60=; b=SUzHeVc8PM+dPMsdOZB7 xzog6wzbcQOmIYdmDwx2JCOSLVh/StyE5T7Npq4AK+PbNkLK93nDTSwQrSWjXpme yAn8HNrnM3Ancu31DJad+33b6P4yoHRrFi29yf+8ysOfAZtaB6pw9mXnka3PSMdM dUdZzyVkwY9bw8s1ZG4h+ak= Received: (qmail 89056 invoked by alias); 4 Apr 2016 12:27:12 -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 88196 invoked by uid 89); 4 Apr 2016 12:27:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, WEIRD_QUOTING autolearn=ham version=3.3.2 spammy=1826, Escape, UD:php X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 04 Apr 2016 12:27:01 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1an3as-0005Vu-6I from Tom_deVries@mentor.com ; Mon, 04 Apr 2016 05:26:58 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.224.2; Mon, 4 Apr 2016 13:26:56 +0100 To: GCC Patches CC: From: Tom de Vries Subject: [PATCH, trivial, 3/3, PR70433] Handle backslash in pp_write_text_as_dot_label_to_stream Message-ID: <57025D8C.9090101@mentor.com> Date: Mon, 4 Apr 2016 14:26:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 Hi, this patch fixes PR70433. Consider test.c: ... #include void test (void) { printf ("\"%s\"",__FUNCTION__); } ... In the dump file we find the backslashes in the string: ... printf ("\"%s\"", &__FUNCTION__); ... But the dot file contains: ... printf\ (\"\\"%s\\"\",\ &__FUNCTION__); ... Which translates to this string in the pdf file, without the backslashes: ... printf (""%s"", &__FUNCTION__); ... The patch classifies the backslash as always-escape in pp_write_text_as_dot_label_to_stream, and that fixes the PR. [ Also, the patch adds an assert to prevent running into a known graphiz PR related to backslashes. ] Bootstrapped and reg-tested on x86_64. Will commit to stage1 trunk as trivial. [ I'd add a testcase, but that is blocked on the lib/scandump.exp/dump-suffix bit of https://gcc.gnu.org/ml/gcc-patches/2016-03/msg01077.html which is awaiting review. ] Thanks, - Tom Handle backslash in pp_write_text_as_dot_label_to_stream 2016-04-04 Tom de Vries PR other/70433 * pretty-print.c (pp_write_text_as_dot_label_to_stream): Escape backslash in label. --- gcc/pretty-print.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index c3a90a7..8ac3d34 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -182,6 +182,12 @@ pp_write_text_as_dot_label_to_stream (pretty_printer *pp, bool for_record) /* The following characters always have to be escaped for use in labels. */ + case '\\': + /* There is a bug in some (f.i. 2.36.0) versions of graphiz + ( http://www.graphviz.org/mantisbt/view.php?id=2524 ) related to + backslash as last char in label. Let's avoid triggering it. */ + gcc_assert (*(p + 1) != '\0'); + /* Fall through. */ case '"': escape_char = true; break;