From: Tom Tromey Date: Sun, 7 Dec 2025 00:45:16 +0000 (-0600) Subject: Small rewrite of get_unbuffered X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8f5d59294b77b0ffa72f1e2da04b623d6fd1ef6;p=thirdparty%2Fbinutils-gdb.git 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 --- 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 (stream); + while (true) + { + buffering_file *buf = dynamic_cast (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 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);