From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output)
Date: Mon, 01 Jul 2019 12:37:00 -0000 [thread overview]
Message-ID: <5372d765-b75f-8d2c-bf0f-e3c0ddc3a802@redhat.com> (raw)
In-Reply-To: <87ef3aq6ux.fsf@tromey.com>
On 7/1/19 1:25 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> 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<repeats %u times>%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[<repeats %u times>%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 <palves@redhat.com>
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 *));
--
2.14.5
next prev parent reply other threads:[~2019-07-01 12:37 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-05 2:01 [PATCH] Style "pwd" output Tom Tromey
2019-06-05 8:36 ` Pedro Alves
2019-06-05 13:42 ` Tom Tromey
2019-06-05 15:21 ` Pedro Alves
2019-06-05 18:12 ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Pedro Alves
2019-06-05 20:27 ` Tom Tromey
2019-06-05 20:39 ` Pedro Alves
2019-06-05 20:42 ` Pedro Alves
2019-06-05 20:49 ` Tom Tromey
2019-06-05 20:47 ` Tom Tromey
2019-06-05 21:25 ` Pedro Alves
2019-06-05 22:21 ` Tom Tromey
2019-06-06 15:49 ` Pedro Alves
2019-06-06 23:55 ` Tom Tromey
2019-06-07 18:27 ` Tom Tromey
2019-06-07 19:20 ` Tom Tromey
2019-07-01 12:23 ` Pedro Alves
2019-07-01 12:55 ` Pedro Alves
2019-07-01 13:06 ` Pedro Alves
2019-07-01 17:26 ` Tom Tromey
2019-07-01 19:24 ` [users/palves/format_strings] Down with .ptr() (Re: ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output)) Pedro Alves
2019-07-01 13:17 ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Pedro Alves
2019-07-01 13:20 ` Pedro Alves
2019-07-01 17:38 ` Tom Tromey
2019-07-01 18:49 ` Tom Tromey
2019-07-01 18:56 ` Pedro Alves
2019-07-01 19:30 ` [users/palves/format_strings] Document the gdb-specific formatters Pedro Alves
2019-07-01 19:25 ` [users/palves/format_strings] Introduce string_field Pedro Alves
2019-07-01 17:43 ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Tom Tromey
2019-07-01 19:29 ` [users/palves/format_strings] Make printf_filtered support the gdb-specific formatters too Pedro Alves
2019-07-01 12:01 ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Pedro Alves
2019-07-01 12:25 ` Tom Tromey
2019-07-01 12:37 ` Pedro Alves [this message]
2019-07-01 17:20 ` Tom Tromey
2019-07-01 19:27 ` [users/palves/format_strings] %pS/%pN -> %p[/%p] Pedro Alves
2019-07-01 19:32 ` ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output) Philippe Waroquiers
2019-07-03 12:20 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5372d765-b75f-8d2c-bf0f-e3c0ddc3a802@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox