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>
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)
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);