[binutils-gdb] Small rewrite of get_unbuffered

Tom Tromey tromey@sourceware.org
Mon Feb 9 15:51:01 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e8f5d59294b77b0ffa72f1e2da04b623d6fd1ef6

commit e8f5d59294b77b0ffa72f1e2da04b623d6fd1ef6
Author: Tom Tromey <tom@tromey.com>
Date:   Sat Dec 6 18:45:16 2025 -0600

    Small rewrite of get_unbuffered
    
    This rewrites get_unbuffered to use iteration rather than recursion.
    
    I also noticed a typo in the documentation comment, so that's fixed as
    well.
    
    Approved-By: Andrew Burgess <aburgess@redhat.com>

Diff:
---
 gdb/ui-out.c | 11 +++++++----
 gdb/ui-out.h |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 87874e22530..00c2055f492 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -907,12 +907,15 @@ buffer_group::flush_here (ui_file *stream)
 ui_file *
 get_unbuffered (ui_file *stream)
 {
-  buffering_file *buf = dynamic_cast<buffering_file *> (stream);
+  while (true)
+    {
+      buffering_file *buf = dynamic_cast<buffering_file *> (stream);
 
-  if (buf == nullptr)
-    return stream;
+      if (buf == nullptr)
+	return stream;
 
-  return get_unbuffered (buf->stream ());
+      stream = buf->stream ();
+    }
 }
 
 buffered_streams::buffered_streams (buffer_group *group, ui_out *uiout)
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 9d63b4c2940..ee5e68fa233 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -529,7 +529,7 @@ private:
   std::unique_ptr<buffered_streams> m_buffered_streams;
 };
 
-/* If FILE is a buffering_file, return it's underlying stream.  */
+/* If FILE is a buffering_file, return its underlying stream.  */
 
 extern ui_file *get_unbuffered (ui_file *file);


More information about the Gdb-cvs mailing list