]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Small rewrite of get_unbuffered
authorTom Tromey <tom@tromey.com>
Sun, 7 Dec 2025 00:45:16 +0000 (18:45 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 9 Feb 2026 15:09:08 +0000 (08:09 -0700)
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>
gdb/ui-out.c
gdb/ui-out.h

index 87874e22530f54a66139aee79694a5d773be4855..00c2055f492e7cd6a46f6393aee09d470a350b18 100644 (file)
@@ -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)
index 9d63b4c2940befb4aa52ebe660b6da0a57f77d93..ee5e68fa233c42f6d1da9e380620be94fb46067e 100644 (file)
@@ -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);