This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output)
- From: Tom Tromey <tom at tromey dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Mon, 01 Jul 2019 11:38:21 -0600
- Subject: Re: ui_out format strings for fields and styles (Re: [PATCH] Style "pwd" output)
- 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> <b0299d9c-22d8-de30-72b5-99de4605d5dd@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> <87wohx5hir.fsf@tromey.com> <ef92b0b9-11cc-57ce-9253-157161d58860@redhat.com> <4e543ef2-eec3-b82c-a84a-a107e1ef2bc2@redhat.com> <3ff7dd5c-334b-3bcc-e43e-a350b3008304@redhat.com>
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> I'm not sure whether we could portably save the varargs like
Pedro> above, though. So that might be moot.
I'm not sure it matters a whole lot.
I looked through all the field_fmt calls, and many of them can be
replaced with some other call.
The few that remain can be rewritten in terms of string_printf if need
be.
Pedro> - uiout->text ("[Inferior ");
Pedro> - uiout->text (plongest (inf->num));
Pedro> - uiout->text (" (");
Pedro> - uiout->text (pidstr.c_str ());
Pedro> - uiout->text (") exited with code ");
Pedro> - uiout->field_fmt ("exit-code", "0%o", (unsigned int) exitstatus);
Pedro> - uiout->text ("]\n");
Pedro> + std::string exit_code_str
Pedro> + = string_printf ("0%o", (unsigned int) exitstatus);
Pedro> + uiout->message ("[Inferior %s (%s) exited with code %pF]\n",
Pedro> + plongest (inf->num), pidstr.c_str (),
Pedro> + string_field ("exit-code", exit_code_str.c_str ()));
This is so much better.
Tom