Remove ui_file::reset_style

Message ID 20250410003115.2762371-1-tom@tromey.com
State New
Headers
Series Remove ui_file::reset_style |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed

Commit Message

Tom Tromey April 10, 2025, 12:31 a.m. UTC
  ui_file::reset_style doesn't seem to be needed.  This patch removes
it.  Regression tested on x86-64 Fedora 40.
---
 gdb/cli/cli-cmds.c |  2 +-
 gdb/pager.h        |  1 -
 gdb/printcmd.c     |  2 +-
 gdb/ui-file.c      | 12 ------------
 gdb/ui-file.h      | 17 -----------------
 gdb/utils.c        | 12 ------------
 6 files changed, 2 insertions(+), 44 deletions(-)
  

Patch

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 7e13ef8062a..9a5021f9d08 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -833,7 +833,7 @@  echo_command (const char *text, int from_tty)
 	  gdb_printf ("%c", c);
       }
 
-  gdb_stdout->reset_style ();
+  gdb_stdout->emit_style_escape (ui_file_style ());
 
   /* Force this output to appear now.  */
   gdb_flush (gdb_stdout);
diff --git a/gdb/pager.h b/gdb/pager.h
index 3c4fcdfd08f..052337d976e 100644
--- a/gdb/pager.h
+++ b/gdb/pager.h
@@ -50,7 +50,6 @@  class pager_file : public wrapped_file
   }
 
   void emit_style_escape (const ui_file_style &style) override;
-  void reset_style () override;
 
   void flush () override;
 
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index e8be470e211..2be5eaa15a2 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2883,7 +2883,7 @@  static void
 printf_command (const char *arg, int from_tty)
 {
   ui_printf (arg, gdb_stdout);
-  gdb_stdout->reset_style ();
+  gdb_stdout->emit_style_escape (ui_file_style ());
   gdb_stdout->wrap_here (0);
   gdb_stdout->flush ();
 }
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index 09e8b0b1d20..f86b6b171f2 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -87,18 +87,6 @@  ui_file::emit_style_escape (const ui_file_style &style)
 
 /* See ui-file.h.  */
 
-void
-ui_file::reset_style ()
-{
-  if (can_emit_style_escape ())
-    {
-      m_applied_style = ui_file_style ();
-      this->puts (m_applied_style.to_ansi ().c_str ());
-    }
-}
-
-/* See ui-file.h.  */
-
 void
 ui_file::printchar (int c, int quoter, bool async_safe)
 {
diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index 351cf1f5747..3919e528da9 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -123,9 +123,6 @@  class ui_file
   /* Emit an ANSI style escape for STYLE.  */
   virtual void emit_style_escape (const ui_file_style &style);
 
-  /* Rest the current output style to the empty style.  */
-  virtual void reset_style ();
-
   /* Print STR, bypassing any paging that might be done by this
      ui_file.  Note that nearly no code should call this -- it's
      intended for use by gdb_printf, but nothing else.  */
@@ -353,12 +350,6 @@  class tee_file : public ui_file
     m_two->emit_style_escape (style);
   }
 
-  void reset_style () override
-  {
-    m_one->reset_style ();
-    m_two->reset_style ();
-  }
-
   void puts_unfiltered (const char *str) override
   {
     m_one->puts_unfiltered (str);
@@ -389,10 +380,6 @@  class no_terminal_escape_file : public stdio_file
   void emit_style_escape (const ui_file_style &style) override
   {
   }
-
-  void reset_style () override
-  {
-  }
 };
 
 /* A base class for ui_file types that wrap another ui_file.  */
@@ -419,10 +406,6 @@  class wrapped_file : public ui_file
   void emit_style_escape (const ui_file_style &style) override
   { m_stream->emit_style_escape (style); }
 
-  /* Rest the current output style to the empty style.  */
-  void reset_style () override
-  { m_stream->reset_style (); }
-
   int fd () const override
   { return m_stream->fd (); }
 
diff --git a/gdb/utils.c b/gdb/utils.c
index 986b90699e9..ce3c26ef140 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1407,18 +1407,6 @@  pager_file::emit_style_escape (const ui_file_style &style)
     }
 }
 
-/* See pager.h.  */
-
-void
-pager_file::reset_style ()
-{
-  if (can_emit_style_escape ())
-    {
-      m_applied_style = ui_file_style ();
-      m_wrap_buffer.append (m_applied_style.to_ansi ());
-    }
-}
-
 /* Wait, so the user can read what's on the screen.  Prompt the user
    to continue by pressing RETURN.  'q' is also provided because
    telling users what to do in the prompt is more user-friendly than