From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93346 invoked by alias); 9 Sep 2016 13:59:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 93183 invoked by uid 89); 9 Sep 2016 13:59:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=octal, hexadecimal, digit, ambiguity 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 ESMTP; Fri, 09 Sep 2016 13:59:19 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1biMKq-0003aZ-99 from joseph_myers@mentor.com ; Fri, 09 Sep 2016 06:59:16 -0700 Received: from digraph.polyomino.org.uk (137.202.0.87) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Fri, 9 Sep 2016 14:59:13 +0100 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.86_2) (envelope-from ) id 1biMKi-0006mc-TQ; Fri, 09 Sep 2016 13:59:08 +0000 Date: Fri, 09 Sep 2016 14:00:00 -0000 From: Joseph Myers To: Martin Sebor CC: Gcc Patch List Subject: Re: [PATCH] avoid non-printable characters in diagnostics (c/77620, c/77521) In-Reply-To: <57D21C36.3020906@gmail.com> Message-ID: References: <57D21C36.3020906@gmail.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-SW-Source: 2016-09/txt/msg00500.txt.bz2 On Thu, 8 Sep 2016, Martin Sebor wrote: > PS I used hexadecimal based on what c-format.c does but now that > I checked more carefully how %qE formats string literals I see it > uses octal. I think hexadecimal is preferable because it avoids > ambiguity but I'm open to changing it to octal if there's a strong I'm not clear what you mean about ambiguity. In C strings, an octal escape sequence has up to three characters, so if it has three characters it's unambiguous, whereas a hex escape sequence can have any number of characters, so if the unprintable character is followed by a valid hex digit then in C you need to represent that as an escape (or use string constant concatenation, etc.). The patch doesn't try to do that as far as I can see. Now, presumably the output isn't intended to be interpreted as C strings anyway (if it was, you'd need to escape " and \ as well), so the patch is OK, but I don't think it avoids ambiguity (and there's a clear case that it shouldn't - that if the string passed to %qs is printable, it should be printed as-is even if it contains escape sequences that could also result from a non-printable string passed to %qs). -- Joseph S. Myers joseph@codesourcery.com