From patchwork Mon Jul 1 12:37:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 33496 Received: (qmail 19487 invoked by alias); 1 Jul 2019 12:37:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 19478 invoked by uid 89); 1 Jul 2019 12:37:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=opinions X-HELO: mail-wm1-f67.google.com Received: from mail-wm1-f67.google.com (HELO mail-wm1-f67.google.com) (209.85.128.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 01 Jul 2019 12:37:56 +0000 Received: by mail-wm1-f67.google.com with SMTP id 207so15671657wma.1 for ; Mon, 01 Jul 2019 05:37:56 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4c97:6d52:2cea:997b? ([2001:8a0:f913:f700:4c97:6d52:2cea:997b]) by smtp.gmail.com with ESMTPSA id p4sm10804800wrx.97.2019.07.01.05.37.53 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jul 2019 05:37:53 -0700 (PDT) Subject: Re: ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) To: Tom Tromey References: <20190605020116.1550-1-tom@tromey.com> <1ee4bd6b-4cdf-f3a9-74af-0843bf123a8b@redhat.com> <87lfygi1x0.fsf@tromey.com> <32872d6a-15d6-9718-59ae-957694e114c9@redhat.com> <87imtjhj6b.fsf@tromey.com> <625cd0ba-058d-d4bf-8ba3-8676f335b0f3@redhat.com> <87blzbep47.fsf@tromey.com> <2180f72f-da10-5333-90a1-666ba3bd145e@redhat.com> <87imtjbrmx.fsf@tromey.com> <871s056yjw.fsf@tromey.com> <87ef3aq6ux.fsf@tromey.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <5372d765-b75f-8d2c-bf0f-e3c0ddc3a802@redhat.com> Date: Mon, 1 Jul 2019 13:37:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <87ef3aq6ux.fsf@tromey.com> On 7/1/19 1:25 PM, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves writes: > > Pedro> Do you still see value in keeping %pN? If we make nullptr mean > Pedro> "keep the default", as you mentioned earlier, then the above can be > Pedro> rewritten as: > > Pedro> fprintf_filtered (stream, " %pS%pS", > Pedro> metadata_style.style ().ptr (), reps, nullptr); > > I was thinking that we'd change the spelling to some form of brackets, > in which case it would be good. So like "%p[%p]". > We discussed this before but I don't recall whether there was some > counter-argument to it. > > If we're just using letters, then there doesn't seem to be a reason to > have two %p suffixes. Ah, my counter-argument which I guess I may have never expressed was that I liked the idea of making %pS+nullptr mean "default", for eliminating the having to explain/think about the "must pass a nullptr to %pN" wart. The visual balance of brackets is appealing as well, so I can't say I have a strong preference either way. If you've been converting things already, you'll have a better judgment, so I'll defer to you. (And it should go without saying, but, to everyone else, you're more than welcome to voice your opinions too, of course.) If we went the always-%pS way, I had written the patch and it'd look like this: From 74899ceab18b23e45225d5560033993596c2a942 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 7 Jun 2019 22:42:57 +0100 Subject: [PATCH] Eliminate %pN --- gdb/common/format.c | 1 - gdb/ui-out.c | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gdb/common/format.c b/gdb/common/format.c index 177f79afee3..6fcbaba290d 100644 --- a/gdb/common/format.c +++ b/gdb/common/format.c @@ -259,7 +259,6 @@ format_pieces::format_pieces (const char **arg, bool gdb_extensions) case 's': case 'S': case 'F': - case 'N': f++; break; } diff --git a/gdb/ui-out.c b/gdb/ui-out.c index d50fb3a3e3f..25efa98d56a 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -618,11 +618,14 @@ ui_out::vmessage (const char *format, va_list args) } break; case 'S': - style = *va_arg (args, const ui_file_style *); - break; - case 'N': - va_arg (args, void *); - style = {}; + { + const ui_file_style *style_p + = va_arg (args, const ui_file_style *); + if (style_p != nullptr) + style = *style_p; + else + style = {}; + } break; default: call_do_message (style, current_substring, va_arg (args, void *));