public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use gdbfmt for vprintf_filtered.
@ 2021-08-30 19:01 John Baldwin
  2021-08-30 21:21 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: John Baldwin @ 2021-08-30 19:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom

gdbfmt was already used for printf_filtered, so using it for
vprintf_filtered is more consistent.

As a result, all callers of vfprintf_maybe_filtered now use gdbfmt, so
the function can be simplified to assume the gdbfmt case and remove
the associated bool argument.  Similary, vprintf_filtered is now a
simple wrapper around vfprintf_filtered.
---
 gdb/utils.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/gdb/utils.c b/gdb/utils.c
index 1c226d5d85e..ae6fb594dbb 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -81,7 +81,7 @@ void (*deprecated_error_begin_hook) (void);
 /* Prototypes for local functions */
 
 static void vfprintf_maybe_filtered (struct ui_file *, const char *,
-				     va_list, bool, bool)
+				     va_list, bool)
   ATTRIBUTE_PRINTF (2, 0);
 
 static void fputs_maybe_filtered (const char *, struct ui_file *, int);
@@ -2102,27 +2102,19 @@ puts_debug (char *prefix, char *string, char *suffix)
 
 static void
 vfprintf_maybe_filtered (struct ui_file *stream, const char *format,
-			 va_list args, bool filter, bool gdbfmt)
+			 va_list args, bool filter)
 {
-  if (gdbfmt)
-    {
-      ui_out_flags flags = disallow_ui_out_field;
-      if (!filter)
-	flags |= unfiltered_output;
-      cli_ui_out (stream, flags).vmessage (applied_style, format, args);
-    }
-  else
-    {
-      std::string str = string_vprintf (format, args);
-      fputs_maybe_filtered (str.c_str (), stream, filter);
-    }
+  ui_out_flags flags = disallow_ui_out_field;
+  if (!filter)
+    flags |= unfiltered_output;
+  cli_ui_out (stream, flags).vmessage (applied_style, format, args);
 }
 
 
 void
 vfprintf_filtered (struct ui_file *stream, const char *format, va_list args)
 {
-  vfprintf_maybe_filtered (stream, format, args, true, true);
+  vfprintf_maybe_filtered (stream, format, args, true);
 }
 
 void
@@ -2156,13 +2148,13 @@ vfprintf_unfiltered (struct ui_file *stream, const char *format, va_list args)
       needs_timestamp = (len > 0 && linebuffer[len - 1] == '\n');
     }
   else
-    vfprintf_maybe_filtered (stream, format, args, false, true);
+    vfprintf_maybe_filtered (stream, format, args, false);
 }
 
 void
 vprintf_filtered (const char *format, va_list args)
 {
-  vfprintf_maybe_filtered (gdb_stdout, format, args, true, false);
+  vfprintf_filtered (gdb_stdout, format, args);
 }
 
 void
-- 
2.32.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Use gdbfmt for vprintf_filtered.
  2021-08-30 19:01 [PATCH] Use gdbfmt for vprintf_filtered John Baldwin
@ 2021-08-30 21:21 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2021-08-30 21:21 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb-patches, tom

>>>>> "John" == John Baldwin <jhb@FreeBSD.org> writes:

John> gdbfmt was already used for printf_filtered, so using it for
John> vprintf_filtered is more consistent.

John> As a result, all callers of vfprintf_maybe_filtered now use gdbfmt, so
John> the function can be simplified to assume the gdbfmt case and remove
John> the associated bool argument.  Similary, vprintf_filtered is now a
John> simple wrapper around vfprintf_filtered.

Thanks.  This is ok.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-30 21:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 19:01 [PATCH] Use gdbfmt for vprintf_filtered John Baldwin
2021-08-30 21:21 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).